Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

refactor(workspace): split workspace interface and implementation (#5463)

EYHN104c21d84c9d
diff --git a/.github/labeler.yml b/.github/labeler.yml
index 1e233e629f..79c9e0c192 100644
--- a/.github/labeler.yml
+++ b/.github/labeler.yml
@@ -32,7 +32,12 @@ mod:plugin-cli:
mod:workspace:
- changed-files:
- any-glob-to-any-file:
- - 'packages/frontend/workspace/**/*'
+ - 'packages/common/workspace/**/*'
+
+mod:workspace-impl:
+ - changed-files:
+ - any-glob-to-any-file:
+ - 'packages/frontend/workspace-impl/**/*'
mod:i18n:
- changed-files:
diff --git a/packages/frontend/workspace/.gitignore b/packages/common/workspace/.gitignore
similarity index 100%
rename from packages/frontend/workspace/.gitignore
rename to packages/common/workspace/.gitignore
diff --git a/packages/common/workspace/package.json b/packages/common/workspace/package.json
new file mode 100644
index 0000000000..05e697fb22
--- /dev/null
+++ b/packages/common/workspace/package.json
@@ -0,0 +1,24 @@
+{
+ "name": "@affine/workspace",
+ "private": true,
+ "main": "./src/index.ts",
+ "exports": {
+ ".": "./src/index.ts"
+ },
+ "peerDependencies": {
+ "@blocksuite/blocks": "*",
+ "@blocksuite/global": "*",
+ "@blocksuite/store": "*"
+ },
+ "dependencies": {
+ "@affine/debug": "workspace:*",
+ "@affine/env": "workspace:*",
+ "@toeverything/infra": "workspace:*",
+ "lodash-es": "^4.17.21",
+ "yjs": "^13.6.10"
+ },
+ "devDependencies": {
+ "vitest": "1.1.0"
+ },
+ "version": "0.11.0"
+}
diff --git a/packages/frontend/workspace/src/engine/awareness.ts b/packages/common/workspace/src/engine/awareness.ts
similarity index 100%
rename from packages/frontend/workspace/src/engine/awareness.ts
rename to packages/common/workspace/src/engine/awareness.ts
diff --git a/packages/frontend/workspace/src/engine/blob.ts b/packages/common/workspace/src/engine/blob.ts
similarity index 100%
rename from packages/frontend/workspace/src/engine/blob.ts
rename to packages/common/workspace/src/engine/blob.ts
diff --git a/packages/frontend/workspace/src/engine/index.ts b/packages/common/workspace/src/engine/index.ts
similarity index 100%
rename from packages/frontend/workspace/src/engine/index.ts
rename to packages/common/workspace/src/engine/index.ts
diff --git a/packages/frontend/workspace/src/engine/sync/consts.ts b/packages/common/workspace/src/engine/sync/consts.ts
similarity index 100%
rename from packages/frontend/workspace/src/engine/sync/consts.ts
rename to packages/common/workspace/src/engine/sync/consts.ts
diff --git a/packages/frontend/workspace/src/engine/sync/engine.ts b/packages/common/workspace/src/engine/sync/engine.ts
similarity index 100%
rename from packages/frontend/workspace/src/engine/sync/engine.ts
rename to packages/common/workspace/src/engine/sync/engine.ts
diff --git a/packages/frontend/workspace/src/engine/sync/index.ts b/packages/common/workspace/src/engine/sync/index.ts
similarity index 100%
rename from packages/frontend/workspace/src/engine/sync/index.ts
rename to packages/common/workspace/src/engine/sync/index.ts
diff --git a/packages/frontend/workspace/src/engine/sync/peer.ts b/packages/common/workspace/src/engine/sync/peer.ts
similarity index 100%
rename from packages/frontend/workspace/src/engine/sync/peer.ts
rename to packages/common/workspace/src/engine/sync/peer.ts
diff --git a/packages/frontend/workspace/src/engine/sync/storage.ts b/packages/common/workspace/src/engine/sync/storage.ts
similarity index 100%
rename from packages/frontend/workspace/src/engine/sync/storage.ts
rename to packages/common/workspace/src/engine/sync/storage.ts
diff --git a/packages/frontend/workspace/src/factory.ts b/packages/common/workspace/src/factory.ts
similarity index 100%
rename from packages/frontend/workspace/src/factory.ts
rename to packages/common/workspace/src/factory.ts
diff --git a/packages/frontend/workspace/src/global-schema.ts b/packages/common/workspace/src/global-schema.ts
similarity index 100%
rename from packages/frontend/workspace/src/global-schema.ts
rename to packages/common/workspace/src/global-schema.ts
diff --git a/packages/common/workspace/src/index.ts b/packages/common/workspace/src/index.ts
new file mode 100644
index 0000000000..bd084ab359
--- /dev/null
+++ b/packages/common/workspace/src/index.ts
@@ -0,0 +1,7 @@
+export * from './engine';
+export * from './factory';
+export * from './global-schema';
+export * from './list';
+export * from './manager';
+export * from './metadata';
+export * from './workspace';
diff --git a/packages/frontend/workspace/src/list/cache.ts b/packages/common/workspace/src/list/cache.ts
similarity index 100%
rename from packages/frontend/workspace/src/list/cache.ts
rename to packages/common/workspace/src/list/cache.ts
diff --git a/packages/frontend/workspace/src/list/index.ts b/packages/common/workspace/src/list/index.ts
similarity index 100%
rename from packages/frontend/workspace/src/list/index.ts
rename to packages/common/workspace/src/list/index.ts
diff --git a/packages/frontend/workspace/src/list/information.ts b/packages/common/workspace/src/list/information.ts
similarity index 100%
rename from packages/frontend/workspace/src/list/information.ts
rename to packages/common/workspace/src/list/information.ts
diff --git a/packages/frontend/workspace/src/manager.ts b/packages/common/workspace/src/manager.ts
similarity index 91%
rename from packages/frontend/workspace/src/manager.ts
rename to packages/common/workspace/src/manager.ts
index 9b32ebff92..52e4bf98d8 100644
--- a/packages/frontend/workspace/src/manager.ts
+++ b/packages/common/workspace/src/manager.ts
@@ -7,7 +7,6 @@ import { applyUpdate, encodeStateAsUpdate } from 'yjs';
import type { BlobStorage } from '.';
import type { WorkspaceFactory } from './factory';
-import { LOCAL_WORKSPACE_LOCAL_STORAGE_KEY } from './impl/local/consts';
import type { WorkspaceList } from './list';
import type { WorkspaceMetadata } from './metadata';
import { WorkspacePool } from './pool';
@@ -151,21 +150,6 @@ export class WorkspaceManager {
return factory.getWorkspaceBlob(metadata.id, blobKey);
}
- /**
- * a hack for directly add local workspace to workspace list
- * Used after copying sqlite database file to appdata folder
- */
- _addLocalWorkspace(id: string) {
- const allWorkspaceIDs: string[] = JSON.parse(
- localStorage.getItem(LOCAL_WORKSPACE_LOCAL_STORAGE_KEY) ?? '[]'
- );
- allWorkspaceIDs.push(id);
- localStorage.setItem(
- LOCAL_WORKSPACE_LOCAL_STORAGE_KEY,
- JSON.stringify(allWorkspaceIDs)
- );
- }
-
private open(metadata: WorkspaceMetadata) {
logger.info(`open workspace [${metadata.flavour}] ${metadata.id} `);
const factory = this.factories.find(x => x.name === metadata.flavour);
diff --git a/packages/frontend/workspace/src/metadata.ts b/packages/common/workspace/src/metadata.ts
similarity index 100%
rename from packages/frontend/workspace/src/metadata.ts
rename to packages/common/workspace/src/metadata.ts
diff --git a/packages/frontend/workspace/src/pool.ts b/packages/common/workspace/src/pool.ts
similarity index 100%
rename from packages/frontend/workspace/src/pool.ts
rename to packages/common/workspace/src/pool.ts
diff --git a/packages/frontend/workspace/src/upgrade/index.ts b/packages/common/workspace/src/upgrade/index.ts
similarity index 100%
rename from packages/frontend/workspace/src/upgrade/index.ts
rename to packages/common/workspace/src/upgrade/index.ts
diff --git a/packages/frontend/workspace/src/utils/__tests__/async-queue.spec.ts b/packages/common/workspace/src/utils/__tests__/async-queue.spec.ts
similarity index 100%
rename from packages/frontend/workspace/src/utils/__tests__/async-queue.spec.ts
rename to packages/common/workspace/src/utils/__tests__/async-queue.spec.ts
diff --git a/packages/frontend/workspace/src/utils/__tests__/throw-if-aborted.spec.ts b/packages/common/workspace/src/utils/__tests__/throw-if-aborted.spec.ts
similarity index 100%
rename from packages/frontend/workspace/src/utils/__tests__/throw-if-aborted.spec.ts
rename to packages/common/workspace/src/utils/__tests__/throw-if-aborted.spec.ts
diff --git a/packages/frontend/workspace/src/utils/async-queue.ts b/packages/common/workspace/src/utils/async-queue.ts
similarity index 100%
rename from packages/frontend/workspace/src/utils/async-queue.ts
rename to packages/common/workspace/src/utils/async-queue.ts
diff --git a/packages/frontend/workspace/src/utils/merge-updates.ts b/packages/common/workspace/src/utils/merge-updates.ts
similarity index 100%
rename from packages/frontend/workspace/src/utils/merge-updates.ts
rename to packages/common/workspace/src/utils/merge-updates.ts
diff --git a/packages/frontend/workspace/src/utils/throw-if-aborted.ts b/packages/common/workspace/src/utils/throw-if-aborted.ts
similarity index 100%
rename from packages/frontend/workspace/src/utils/throw-if-aborted.ts
rename to packages/common/workspace/src/utils/throw-if-aborted.ts
diff --git a/packages/frontend/workspace/src/workspace.ts b/packages/common/workspace/src/workspace.ts
similarity index 100%
rename from packages/frontend/workspace/src/workspace.ts
rename to packages/common/workspace/src/workspace.ts
diff --git a/packages/frontend/workspace/tsconfig.json b/packages/common/workspace/tsconfig.json
similarity index 100%
rename from packages/frontend/workspace/tsconfig.json
rename to packages/common/workspace/tsconfig.json
diff --git a/packages/frontend/component/tsconfig.json b/packages/frontend/component/tsconfig.json
index 67e47712d2..387ccdb91f 100644
--- a/packages/frontend/component/tsconfig.json
+++ b/packages/frontend/component/tsconfig.json
@@ -14,7 +14,7 @@
{
"path": "../../frontend/electron-api"
},
- { "path": "../../frontend/workspace" },
+ { "path": "../../common/workspace" },
{
"path": "../../common/debug"
},
diff --git a/packages/frontend/core/package.json b/packages/frontend/core/package.json
index 9fd0ac01ad..410b650a77 100644
--- a/packages/frontend/core/package.json
+++ b/packages/frontend/core/package.json
@@ -26,6 +26,7 @@
"@affine/i18n": "workspace:*",
"@affine/templates": "workspace:*",
"@affine/workspace": "workspace:*",
+ "@affine/workspace-impl": "workspace:*",
"@blocksuite/block-std": "0.11.0-nightly-202312220916-e3abcbb",
"@blocksuite/blocks": "0.11.0-nightly-202312220916-e3abcbb",
"@blocksuite/global": "0.11.0-nightly-202312220916-e3abcbb",
diff --git a/packages/frontend/core/src/bootstrap/first-app-data.ts b/packages/frontend/core/src/bootstrap/first-app-data.ts
index 22a7339842..d040b73b40 100644
--- a/packages/frontend/core/src/bootstrap/first-app-data.ts
+++ b/packages/frontend/core/src/bootstrap/first-app-data.ts
@@ -1,7 +1,7 @@
import { DebugLogger } from '@affine/debug';
import { DEFAULT_WORKSPACE_NAME } from '@affine/env/constant';
import { WorkspaceFlavour } from '@affine/env/workspace';
-import { workspaceManager } from '@affine/workspace';
+import { workspaceManager } from '@affine/workspace-impl';
import { getCurrentStore } from '@toeverything/infra/atom';
import {
buildShowcaseWorkspace,
diff --git a/packages/frontend/core/src/components/affine/create-workspace-modal/index.tsx b/packages/frontend/core/src/components/affine/create-workspace-modal/index.tsx
index ca80f0f97f..0f28f86522 100644
--- a/packages/frontend/core/src/components/affine/create-workspace-modal/index.tsx
+++ b/packages/frontend/core/src/components/affine/create-workspace-modal/index.tsx
@@ -10,6 +10,7 @@ import { DebugLogger } from '@affine/debug';
import { apis } from '@affine/electron-api';
import { WorkspaceFlavour } from '@affine/env/workspace';
import { useAFFiNEI18N } from '@affine/i18n/hooks';
+import { _addLocalWorkspace } from '@affine/workspace-impl';
import { getCurrentStore } from '@toeverything/infra/atom';
import {
buildShowcaseWorkspace,
@@ -119,7 +120,7 @@ export const CreateWorkspaceModal = ({
setStep(undefined);
const result = await apis.dialog.loadDBFile();
if (result.workspaceId && !canceled) {
- workspaceManager._addLocalWorkspace(result.workspaceId);
+ _addLocalWorkspace(result.workspaceId);
onCreate(result.workspaceId);
} else if (result.error || result.canceled) {
if (result.error) {
diff --git a/packages/frontend/core/src/components/affine/page-history-modal/data.ts b/packages/frontend/core/src/components/affine/page-history-modal/data.ts
index d2a572fb7c..ba716dbdcd 100644
--- a/packages/frontend/core/src/components/affine/page-history-modal/data.ts
+++ b/packages/frontend/core/src/components/affine/page-history-modal/data.ts
@@ -7,10 +7,8 @@ import {
listHistoryQuery,
recoverDocMutation,
} from '@affine/graphql';
-import {
- createAffineCloudBlobStorage,
- globalBlockSuiteSchema,
-} from '@affine/workspace';
+import { globalBlockSuiteSchema } from '@affine/workspace';
+import { createAffineCloudBlobStorage } from '@affine/workspace-impl';
import { assertEquals } from '@blocksuite/global/utils';
import { Workspace } from '@blocksuite/store';
import { revertUpdate } from '@toeverything/y-indexeddb';
diff --git a/packages/frontend/core/src/modules/workspace/atoms.ts b/packages/frontend/core/src/modules/workspace/atoms.ts
index 606013b00a..1833db2178 100644
--- a/packages/frontend/core/src/modules/workspace/atoms.ts
+++ b/packages/frontend/core/src/modules/workspace/atoms.ts
@@ -1,9 +1,6 @@
import { DebugLogger } from '@affine/debug';
-import {
- type Workspace,
- workspaceManager,
- type WorkspaceMetadata,
-} from '@affine/workspace';
+import type { Workspace, WorkspaceMetadata } from '@affine/workspace';
+import { workspaceManager } from '@affine/workspace-impl';
import { atom } from 'jotai';
import { atomWithObservable } from 'jotai/utils';
import { Observable } from 'rxjs';
diff --git a/packages/frontend/core/src/pages/share/share-detail-page.tsx b/packages/frontend/core/src/pages/share/share-detail-page.tsx
index 28a6e12854..fa667a19db 100644
--- a/packages/frontend/core/src/pages/share/share-detail-page.tsx
+++ b/packages/frontend/core/src/pages/share/share-detail-page.tsx
@@ -1,11 +1,11 @@
import { MainContainer } from '@affine/component/workspace';
import { DebugLogger } from '@affine/debug';
import { fetchWithTraceReport } from '@affine/graphql';
+import { globalBlockSuiteSchema } from '@affine/workspace';
import {
createAffineCloudBlobStorage,
createStaticBlobStorage,
- globalBlockSuiteSchema,
-} from '@affine/workspace';
+} from '@affine/workspace-impl';
import { assertExists } from '@blocksuite/global/utils';
import { type Page, Workspace } from '@blocksuite/store';
import { noop } from 'foxact/noop';
diff --git a/packages/frontend/core/src/providers/session-provider.tsx b/packages/frontend/core/src/providers/session-provider.tsx
index e44f17089c..9decb80477 100644
--- a/packages/frontend/core/src/providers/session-provider.tsx
+++ b/packages/frontend/core/src/providers/session-provider.tsx
@@ -2,7 +2,7 @@ import { pushNotificationAtom } from '@affine/component/notification-center';
import { useAsyncCallback } from '@affine/core/hooks/affine-async-hooks';
import { affine } from '@affine/electron-api';
import { useAFFiNEI18N } from '@affine/i18n/hooks';
-import { CLOUD_WORKSPACE_CHANGED_BROADCAST_CHANNEL_KEY } from '@affine/workspace';
+import { CLOUD_WORKSPACE_CHANGED_BROADCAST_CHANNEL_KEY } from '@affine/workspace-impl';
import { useAtom, useSetAtom } from 'jotai';
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
import { SessionProvider, useSession } from 'next-auth/react';
diff --git a/packages/frontend/core/src/utils/cloud-utils.tsx b/packages/frontend/core/src/utils/cloud-utils.tsx
index 7d18b3eddc..4d27e54515 100644
--- a/packages/frontend/core/src/utils/cloud-utils.tsx
+++ b/packages/frontend/core/src/utils/cloud-utils.tsx
@@ -4,7 +4,7 @@ import {
TRACE_ID_BYTES,
traceReporter,
} from '@affine/graphql';
-import { CLOUD_WORKSPACE_CHANGED_BROADCAST_CHANNEL_KEY } from '@affine/workspace';
+import { CLOUD_WORKSPACE_CHANGED_BROADCAST_CHANNEL_KEY } from '@affine/workspace-impl';
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
import { signIn, signOut } from 'next-auth/react';
diff --git a/packages/frontend/core/tsconfig.json b/packages/frontend/core/tsconfig.json
index 6a65ddf119..0251c35af4 100644
--- a/packages/frontend/core/tsconfig.json
+++ b/packages/frontend/core/tsconfig.json
@@ -18,7 +18,10 @@
"path": "../../frontend/i18n"
},
{
- "path": "../../frontend/workspace"
+ "path": "../../common/workspace"
+ },
+ {
+ "path": "../../frontend/workspace-impl"
},
{
"path": "../../frontend/electron-api"
diff --git a/packages/frontend/electron-api/src/index.ts b/packages/frontend/electron-api/src/index.ts
index 66a23ef780..2cccdddc6a 100644
--- a/packages/frontend/electron-api/src/index.ts
+++ b/packages/frontend/electron-api/src/index.ts
@@ -27,10 +27,12 @@ type ClientHandler = {
} & HelperHandlers;
type ClientEvents = MainEvents & HelperEvents;
-export const appInfo = (window as any).appInfo as typeof exposedAppInfo | null;
-export const apis = (window as any).apis as ClientHandler | null;
-export const events = (window as any).events as ClientEvents | null;
-export const affine = (window as any).affine as
+export const appInfo = (globalThis as any).appInfo as
+ | typeof exposedAppInfo
+ | null;
+export const apis = (globalThis as any).apis as ClientHandler | null;
+export const events = (globalThis as any).events as ClientEvents | null;
+export const affine = (globalThis as any).affine as
| typeof exposedAffineGlobal
| null;
diff --git a/packages/frontend/workspace-impl/.gitignore b/packages/frontend/workspace-impl/.gitignore
new file mode 100644
index 0000000000..a65b41774a
--- /dev/null
+++ b/packages/frontend/workspace-impl/.gitignore
@@ -0,0 +1 @@
+lib
diff --git a/packages/frontend/workspace/package.json b/packages/frontend/workspace-impl/package.json
similarity index 56%
rename from packages/frontend/workspace/package.json
rename to packages/frontend/workspace-impl/package.json
index fedd487f1f..dfbb34627c 100644
--- a/packages/frontend/workspace/package.json
+++ b/packages/frontend/workspace-impl/package.json
@@ -1,10 +1,9 @@
{
- "name": "@affine/workspace",
+ "name": "@affine/workspace-impl",
"private": true,
+ "main": "./src/index.ts",
"exports": {
- ".": "./src/index.ts",
- "./atom": "./src/atom.ts",
- "./affine/*": "./src/affine/*.ts"
+ ".": "./src/index.ts"
},
"peerDependencies": {
"@blocksuite/blocks": "*",
@@ -12,37 +11,23 @@
"@blocksuite/store": "*"
},
"dependencies": {
- "@affine-test/fixtures": "workspace:*",
"@affine/debug": "workspace:*",
"@affine/electron-api": "workspace:*",
"@affine/env": "workspace:*",
"@affine/graphql": "workspace:*",
+ "@affine/workspace": "workspace:*",
"@toeverything/infra": "workspace:*",
- "async-call-rpc": "^6.3.1",
"idb": "^8.0.0",
"idb-keyval": "^6.2.1",
"is-svg": "^5.0.0",
- "jotai": "^2.5.1",
- "js-base64": "^3.7.5",
- "ky": "^1.0.1",
- "lib0": "^0.2.87",
"lodash-es": "^4.17.21",
"nanoid": "^5.0.3",
"next-auth": "^4.24.5",
- "react": "18.2.0",
- "react-dom": "18.2.0",
- "rxjs": "^7.8.1",
"socket.io-client": "^4.7.2",
- "swr": "2.2.4",
- "valtio": "^1.11.2",
"y-protocols": "^1.0.6",
- "y-provider": "workspace:*",
- "yjs": "^13.6.10",
- "zod": "^3.22.4"
+ "yjs": "^13.6.10"
},
"devDependencies": {
- "@testing-library/react": "^14.0.0",
- "@types/ws": "^8.5.7",
"fake-indexeddb": "^5.0.0",
"vitest": "1.1.1",
"ws": "^8.14.2"
diff --git a/packages/frontend/workspace/src/impl/cloud/awareness.ts b/packages/frontend/workspace-impl/src/cloud/awareness.ts
similarity index 93%
rename from packages/frontend/workspace/src/impl/cloud/awareness.ts
rename to packages/frontend/workspace-impl/src/cloud/awareness.ts
index 396108b907..0add462ef6 100644
--- a/packages/frontend/workspace/src/impl/cloud/awareness.ts
+++ b/packages/frontend/workspace-impl/src/cloud/awareness.ts
@@ -1,4 +1,5 @@
import { DebugLogger } from '@affine/debug';
+import type { AwarenessProvider } from '@affine/workspace';
import {
applyAwarenessUpdate,
type Awareness,
@@ -6,9 +7,8 @@ import {
removeAwarenessStates,
} from 'y-protocols/awareness';
-import type { AwarenessProvider } from '../../engine/awareness';
-import { getIoManager } from '../../utils/affine-io';
-import { base64ToUint8Array, uint8ArrayToBase64 } from '../../utils/base64';
+import { getIoManager } from '../utils/affine-io';
+import { base64ToUint8Array, uint8ArrayToBase64 } from '../utils/base64';
const logger = new DebugLogger('affine:awareness:socketio');
diff --git a/packages/frontend/workspace/src/impl/cloud/blob.ts b/packages/frontend/workspace-impl/src/cloud/blob.ts
similarity index 93%
rename from packages/frontend/workspace/src/impl/cloud/blob.ts
rename to packages/frontend/workspace-impl/src/cloud/blob.ts
index c7cde8a153..62e690051b 100644
--- a/packages/frontend/workspace/src/impl/cloud/blob.ts
+++ b/packages/frontend/workspace-impl/src/cloud/blob.ts
@@ -7,9 +7,9 @@ import {
setBlobMutation,
} from '@affine/graphql';
import { fetcher } from '@affine/graphql';
+import type { BlobStorage } from '@affine/workspace';
-import type { BlobStorage } from '../../engine/blob';
-import { bufferToBlob } from '../../utils/buffer-to-blob';
+import { bufferToBlob } from '../utils/buffer-to-blob';
export const createAffineCloudBlobStorage = (
workspaceId: string
diff --git a/packages/frontend/workspace/src/impl/cloud/consts.ts b/packages/frontend/workspace-impl/src/cloud/consts.ts
similarity index 100%
rename from packages/frontend/workspace/src/impl/cloud/consts.ts
rename to packages/frontend/workspace-impl/src/cloud/consts.ts
diff --git a/packages/frontend/workspace/src/impl/cloud/index.ts b/packages/frontend/workspace-impl/src/cloud/index.ts
similarity index 100%
rename from packages/frontend/workspace/src/impl/cloud/index.ts
rename to packages/frontend/workspace-impl/src/cloud/index.ts
diff --git a/packages/frontend/workspace/src/impl/cloud/list.ts b/packages/frontend/workspace-impl/src/cloud/list.ts
similarity index 97%
rename from packages/frontend/workspace/src/impl/cloud/list.ts
rename to packages/frontend/workspace-impl/src/cloud/list.ts
index e1e86a7ce2..26ffbed04c 100644
--- a/packages/frontend/workspace/src/impl/cloud/list.ts
+++ b/packages/frontend/workspace-impl/src/cloud/list.ts
@@ -5,13 +5,13 @@ import {
getWorkspacesQuery,
} from '@affine/graphql';
import { fetcher } from '@affine/graphql';
+import type { WorkspaceListProvider } from '@affine/workspace';
+import { globalBlockSuiteSchema } from '@affine/workspace';
import { Workspace as BlockSuiteWorkspace } from '@blocksuite/store';
import { difference } from 'lodash-es';
import { nanoid } from 'nanoid';
import { applyUpdate, encodeStateAsUpdate } from 'yjs';
-import { globalBlockSuiteSchema } from '../../global-schema';
-import type { WorkspaceListProvider } from '../../list';
import { createLocalBlobStorage } from '../local/blob';
import { createLocalStorage } from '../local/sync';
import { CLOUD_WORKSPACE_CHANGED_BROADCAST_CHANNEL_KEY } from './consts';
diff --git a/packages/frontend/workspace/src/impl/cloud/sync/batch-sync-sender.ts b/packages/frontend/workspace-impl/src/cloud/sync/batch-sync-sender.ts
similarity index 100%
rename from packages/frontend/workspace/src/impl/cloud/sync/batch-sync-sender.ts
rename to packages/frontend/workspace-impl/src/cloud/sync/batch-sync-sender.ts
diff --git a/packages/frontend/workspace/src/impl/cloud/sync/index.ts b/packages/frontend/workspace-impl/src/cloud/sync/index.ts
similarity index 96%
rename from packages/frontend/workspace/src/impl/cloud/sync/index.ts
rename to packages/frontend/workspace-impl/src/cloud/sync/index.ts
index c5a092cce1..14f4588690 100644
--- a/packages/frontend/workspace/src/impl/cloud/sync/index.ts
+++ b/packages/frontend/workspace-impl/src/cloud/sync/index.ts
@@ -1,9 +1,9 @@
import { DebugLogger } from '@affine/debug';
import { fetchWithTraceReport } from '@affine/graphql';
+import type { SyncStorage } from '@affine/workspace';
-import type { SyncStorage } from '../../../engine/sync';
-import { getIoManager } from '../../../utils/affine-io';
-import { base64ToUint8Array, uint8ArrayToBase64 } from '../../../utils/base64';
+import { getIoManager } from '../../utils/affine-io';
+import { base64ToUint8Array, uint8ArrayToBase64 } from '../../utils/base64';
import { MultipleBatchSyncSender } from './batch-sync-sender';
const logger = new DebugLogger('affine:storage:socketio');
diff --git a/packages/frontend/workspace/src/impl/cloud/workspace-factory.ts b/packages/frontend/workspace-impl/src/cloud/workspace-factory.ts
similarity index 90%
rename from packages/frontend/workspace/src/impl/cloud/workspace-factory.ts
rename to packages/frontend/workspace-impl/src/cloud/workspace-factory.ts
index 1877817f61..1b747e2c1e 100644
--- a/packages/frontend/workspace/src/impl/cloud/workspace-factory.ts
+++ b/packages/frontend/workspace-impl/src/cloud/workspace-factory.ts
@@ -1,11 +1,11 @@
import { setupEditorFlags } from '@affine/env/global';
+import type { WorkspaceFactory } from '@affine/workspace';
+import { BlobEngine, SyncEngine, WorkspaceEngine } from '@affine/workspace';
+import { globalBlockSuiteSchema } from '@affine/workspace';
+import { Workspace } from '@affine/workspace';
import { Workspace as BlockSuiteWorkspace } from '@blocksuite/store';
import { nanoid } from 'nanoid';
-import { BlobEngine, SyncEngine, WorkspaceEngine } from '../../engine';
-import type { WorkspaceFactory } from '../../factory';
-import { globalBlockSuiteSchema } from '../../global-schema';
-import { Workspace } from '../../workspace';
import { createBroadcastChannelAwarenessProvider } from '../local/awareness';
import { createLocalBlobStorage } from '../local/blob';
import { createStaticBlobStorage } from '../local/blob-static';
diff --git a/packages/frontend/workspace-impl/src/index.ts b/packages/frontend/workspace-impl/src/index.ts
new file mode 100644
index 0000000000..27a2e38a91
--- /dev/null
+++ b/packages/frontend/workspace-impl/src/index.ts
@@ -0,0 +1,41 @@
+import { WorkspaceList, WorkspaceManager } from '@affine/workspace';
+
+import {
+ cloudWorkspaceFactory,
+ createCloudWorkspaceListProvider,
+} from './cloud';
+import {
+ createLocalWorkspaceListProvider,
+ LOCAL_WORKSPACE_LOCAL_STORAGE_KEY,
+ localWorkspaceFactory,
+} from './local';
+
+const list = new WorkspaceList([
+ createLocalWorkspaceListProvider(),
+ createCloudWorkspaceListProvider(),
+]);
+
+export const workspaceManager = new WorkspaceManager(list, [
+ localWorkspaceFactory,
+ cloudWorkspaceFactory,
+]);
+
+(window as any).workspaceManager = workspaceManager;
+
+export * from './cloud';
+export * from './local';
+
+/**
+ * a hack for directly add local workspace to workspace list
+ * Used after copying sqlite database file to appdata folder
+ */
+export function _addLocalWorkspace(id: string) {
+ const allWorkspaceIDs: string[] = JSON.parse(
+ localStorage.getItem(LOCAL_WORKSPACE_LOCAL_STORAGE_KEY) ?? '[]'
+ );
+ allWorkspaceIDs.push(id);
+ localStorage.setItem(
+ LOCAL_WORKSPACE_LOCAL_STORAGE_KEY,
+ JSON.stringify(allWorkspaceIDs)
+ );
+}
diff --git a/packages/frontend/workspace/src/engine/sync/__tests__/engine.spec.ts b/packages/frontend/workspace-impl/src/local/__tests__/engine.spec.ts
similarity index 97%
rename from packages/frontend/workspace/src/engine/sync/__tests__/engine.spec.ts
rename to packages/frontend/workspace-impl/src/local/__tests__/engine.spec.ts
index 963af3d3a4..675b6b565c 100644
--- a/packages/frontend/workspace/src/engine/sync/__tests__/engine.spec.ts
+++ b/packages/frontend/workspace-impl/src/local/__tests__/engine.spec.ts
@@ -1,12 +1,12 @@
import 'fake-indexeddb/auto';
+import { SyncEngine, SyncEngineStep, SyncPeerStep } from '@affine/workspace';
import { __unstableSchemas, AffineSchemas } from '@blocksuite/blocks/models';
import { Schema, Workspace } from '@blocksuite/store';
import { beforeEach, describe, expect, test, vi } from 'vitest';
import { Doc } from 'yjs';
-import { createIndexedDBStorage } from '../../../impl/local/sync-indexeddb';
-import { SyncEngine, SyncEngineStep, SyncPeerStep } from '../';
+import { createIndexedDBStorage } from '..';
import { createTestStorage } from './test-storage';
const schema = new Schema();
diff --git a/packages/frontend/workspace/src/engine/sync/__tests__/peer.spec.ts b/packages/frontend/workspace-impl/src/local/__tests__/peer.spec.ts
similarity index 95%
rename from packages/frontend/workspace/src/engine/sync/__tests__/peer.spec.ts
rename to packages/frontend/workspace-impl/src/local/__tests__/peer.spec.ts
index d1fce352c0..1b0a8018aa 100644
--- a/packages/frontend/workspace/src/engine/sync/__tests__/peer.spec.ts
+++ b/packages/frontend/workspace-impl/src/local/__tests__/peer.spec.ts
@@ -1,11 +1,11 @@
import 'fake-indexeddb/auto';
+import { SyncPeer, SyncPeerStep } from '@affine/workspace';
import { __unstableSchemas, AffineSchemas } from '@blocksuite/blocks/models';
import { Schema, Workspace } from '@blocksuite/store';
import { beforeEach, describe, expect, test, vi } from 'vitest';
-import { createIndexedDBStorage } from '../../../impl/local/sync-indexeddb';
-import { SyncPeer, SyncPeerStep } from '../';
+import { createIndexedDBStorage } from '..';
const schema = new Schema();
diff --git a/packages/frontend/workspace/src/engine/sync/__tests__/test-storage.ts b/packages/frontend/workspace-impl/src/local/__tests__/test-storage.ts
similarity index 95%
rename from packages/frontend/workspace/src/engine/sync/__tests__/test-storage.ts
rename to packages/frontend/workspace-impl/src/local/__tests__/test-storage.ts
index 07cd557166..a0653d4d30 100644
--- a/packages/frontend/workspace/src/engine/sync/__tests__/test-storage.ts
+++ b/packages/frontend/workspace-impl/src/local/__tests__/test-storage.ts
@@ -1,4 +1,4 @@
-import type { SyncStorage } from '..';
+import type { SyncStorage } from '@affine/workspace';
export function createTestStorage(origin: SyncStorage) {
const controler = {
diff --git a/packages/frontend/workspace/src/impl/local/awareness.ts b/packages/frontend/workspace-impl/src/local/awareness.ts
similarity index 96%
rename from packages/frontend/workspace/src/impl/local/awareness.ts
rename to packages/frontend/workspace-impl/src/local/awareness.ts
index 4472479808..8674046c2d 100644
--- a/packages/frontend/workspace/src/impl/local/awareness.ts
+++ b/packages/frontend/workspace-impl/src/local/awareness.ts
@@ -1,11 +1,10 @@
+import type { AwarenessProvider } from '@affine/workspace';
import type { Awareness } from 'y-protocols/awareness.js';
import {
applyAwarenessUpdate,
encodeAwarenessUpdate,
} from 'y-protocols/awareness.js';
-import type { AwarenessProvider } from '../../engine/awareness';
-
type AwarenessChanges = Record<'added' | 'updated' | 'removed', number[]>;
type ChannelMessage =
diff --git a/packages/frontend/workspace/src/impl/local/blob-indexeddb.ts b/packages/frontend/workspace-impl/src/local/blob-indexeddb.ts
similarity index 88%
rename from packages/frontend/workspace/src/impl/local/blob-indexeddb.ts
rename to packages/frontend/workspace-impl/src/local/blob-indexeddb.ts
index 8117151306..fe9ec6314a 100644
--- a/packages/frontend/workspace/src/impl/local/blob-indexeddb.ts
+++ b/packages/frontend/workspace-impl/src/local/blob-indexeddb.ts
@@ -1,7 +1,7 @@
+import type { BlobStorage } from '@affine/workspace';
import { createStore, del, get, keys, set } from 'idb-keyval';
-import type { BlobStorage } from '../../engine/blob';
-import { bufferToBlob } from '../../utils/buffer-to-blob';
+import { bufferToBlob } from '../utils/buffer-to-blob';
export const createIndexeddbBlobStorage = (
workspaceId: string
diff --git a/packages/frontend/workspace/src/impl/local/blob-sqlite.ts b/packages/frontend/workspace-impl/src/local/blob-sqlite.ts
similarity index 89%
rename from packages/frontend/workspace/src/impl/local/blob-sqlite.ts
rename to packages/frontend/workspace-impl/src/local/blob-sqlite.ts
index 07bb5ac82c..f92ba06e51 100644
--- a/packages/frontend/workspace/src/impl/local/blob-sqlite.ts
+++ b/packages/frontend/workspace-impl/src/local/blob-sqlite.ts
@@ -1,8 +1,8 @@
import { apis } from '@affine/electron-api';
+import type { BlobStorage } from '@affine/workspace';
import { assertExists } from '@blocksuite/global/utils';
-import type { BlobStorage } from '../../engine/blob';
-import { bufferToBlob } from '../../utils/buffer-to-blob';
+import { bufferToBlob } from '../utils/buffer-to-blob';
export const createSQLiteBlobStorage = (workspaceId: string): BlobStorage => {
assertExists(apis);
diff --git a/packages/frontend/workspace/src/impl/local/blob-static.ts b/packages/frontend/workspace-impl/src/local/blob-static.ts
similarity index 97%
rename from packages/frontend/workspace/src/impl/local/blob-static.ts
rename to packages/frontend/workspace-impl/src/local/blob-static.ts
index 0ac9fcaeff..35ff5d1299 100644
--- a/packages/frontend/workspace/src/impl/local/blob-static.ts
+++ b/packages/frontend/workspace-impl/src/local/blob-static.ts
@@ -1,4 +1,4 @@
-import type { BlobStorage } from '../../engine/blob';
+import type { BlobStorage } from '@affine/workspace';
export const predefinedStaticFiles = [
'029uztLz2CzJezK7UUhrbGiWUdZ0J7NVs_qR6RDsvb8=',
diff --git a/packages/frontend/workspace/src/impl/local/blob.ts b/packages/frontend/workspace-impl/src/local/blob.ts
similarity index 100%
rename from packages/frontend/workspace/src/impl/local/blob.ts
rename to packages/frontend/workspace-impl/src/local/blob.ts
diff --git a/packages/frontend/workspace/src/impl/local/consts.ts b/packages/frontend/workspace-impl/src/local/consts.ts
similarity index 100%
rename from packages/frontend/workspace/src/impl/local/consts.ts
rename to packages/frontend/workspace-impl/src/local/consts.ts
diff --git a/packages/frontend/workspace/src/impl/local/index.ts b/packages/frontend/workspace-impl/src/local/index.ts
similarity index 100%
rename from packages/frontend/workspace/src/impl/local/index.ts
rename to packages/frontend/workspace-impl/src/local/index.ts
diff --git a/packages/frontend/workspace/src/impl/local/list.ts b/packages/frontend/workspace-impl/src/local/list.ts
similarity index 96%
rename from packages/frontend/workspace/src/impl/local/list.ts
rename to packages/frontend/workspace-impl/src/local/list.ts
index 5d7fa69439..d147da76d2 100644
--- a/packages/frontend/workspace/src/impl/local/list.ts
+++ b/packages/frontend/workspace-impl/src/local/list.ts
@@ -1,12 +1,12 @@
import { apis } from '@affine/electron-api';
import { WorkspaceFlavour } from '@affine/env/workspace';
+import type { WorkspaceListProvider } from '@affine/workspace';
+import { globalBlockSuiteSchema } from '@affine/workspace';
import { Workspace as BlockSuiteWorkspace } from '@blocksuite/store';
import { difference } from 'lodash-es';
import { nanoid } from 'nanoid';
import { applyUpdate, encodeStateAsUpdate } from 'yjs';
-import { globalBlockSuiteSchema } from '../../global-schema';
-import type { WorkspaceListProvider } from '../../list';
import { createLocalBlobStorage } from './blob';
import {
LOCAL_WORKSPACE_CREATED_BROADCAST_CHANNEL_KEY,
diff --git a/packages/frontend/workspace/src/impl/local/sync-indexeddb.ts b/packages/frontend/workspace-impl/src/local/sync-indexeddb.ts
similarity index 96%
rename from packages/frontend/workspace/src/impl/local/sync-indexeddb.ts
rename to packages/frontend/workspace-impl/src/local/sync-indexeddb.ts
index c6cedffa5c..fe418239e9 100644
--- a/packages/frontend/workspace/src/impl/local/sync-indexeddb.ts
+++ b/packages/frontend/workspace-impl/src/local/sync-indexeddb.ts
@@ -1,8 +1,8 @@
+import type { SyncStorage } from '@affine/workspace';
import { type DBSchema, type IDBPDatabase, openDB } from 'idb';
import { diffUpdate, encodeStateVectorFromUpdate } from 'yjs';
-import type { SyncStorage } from '../../engine/sync';
-import { mergeUpdates } from '../../utils/merge-updates';
+import { mergeUpdates } from '../utils/merge-updates';
export const dbVersion = 1;
export const DEFAULT_DB_NAME = 'affine-local';
diff --git a/packages/frontend/workspace/src/impl/local/sync-sqlite.ts b/packages/frontend/workspace-impl/src/local/sync-sqlite.ts
similarity index 94%
rename from packages/frontend/workspace/src/impl/local/sync-sqlite.ts
rename to packages/frontend/workspace-impl/src/local/sync-sqlite.ts
index 8472e4b9fd..a0f3b99c93 100644
--- a/packages/frontend/workspace/src/impl/local/sync-sqlite.ts
+++ b/packages/frontend/workspace-impl/src/local/sync-sqlite.ts
@@ -1,8 +1,7 @@
import { apis } from '@affine/electron-api';
+import type { SyncStorage } from '@affine/workspace';
import { encodeStateVectorFromUpdate } from 'yjs';
-import type { SyncStorage } from '../../engine/sync';
-
export function createSQLiteStorage(workspaceId: string): SyncStorage {
if (!apis?.db) {
throw new Error('sqlite datasource is not available');
diff --git a/packages/frontend/workspace/src/impl/local/sync.ts b/packages/frontend/workspace-impl/src/local/sync.ts
similarity index 100%
rename from packages/frontend/workspace/src/impl/local/sync.ts
rename to packages/frontend/workspace-impl/src/local/sync.ts
diff --git a/packages/frontend/workspace/src/impl/local/workspace-factory.ts b/packages/frontend/workspace-impl/src/local/workspace-factory.ts
similarity index 81%
rename from packages/frontend/workspace/src/impl/local/workspace-factory.ts
rename to packages/frontend/workspace-impl/src/local/workspace-factory.ts
index 08ed43a187..d143924142 100644
--- a/packages/frontend/workspace/src/impl/local/workspace-factory.ts
+++ b/packages/frontend/workspace-impl/src/local/workspace-factory.ts
@@ -1,13 +1,13 @@
import { setupEditorFlags } from '@affine/env/global';
+import type { WorkspaceFactory } from '@affine/workspace';
+import { WorkspaceEngine } from '@affine/workspace';
+import { BlobEngine } from '@affine/workspace';
+import { SyncEngine } from '@affine/workspace';
+import { globalBlockSuiteSchema } from '@affine/workspace';
+import { Workspace } from '@affine/workspace';
import { Workspace as BlockSuiteWorkspace } from '@blocksuite/store';
import { nanoid } from 'nanoid';
-import { WorkspaceEngine } from '../../engine';
-import { BlobEngine } from '../../engine/blob';
-import { SyncEngine } from '../../engine/sync';
-import type { WorkspaceFactory } from '../../factory';
-import { globalBlockSuiteSchema } from '../../global-schema';
-import { Workspace } from '../../workspace';
import { createBroadcastChannelAwarenessProvider } from './awareness';
import { createLocalBlobStorage } from './blob';
import { createStaticBlobStorage } from './blob-static';
diff --git a/packages/frontend/workspace/src/utils/__tests__/buffer-to-blob.spec.ts b/packages/frontend/workspace-impl/src/utils/__tests__/buffer-to-blob.spec.ts
similarity index 100%
rename from packages/frontend/workspace/src/utils/__tests__/buffer-to-blob.spec.ts
rename to packages/frontend/workspace-impl/src/utils/__tests__/buffer-to-blob.spec.ts
diff --git a/packages/frontend/workspace/src/utils/affine-io.ts b/packages/frontend/workspace-impl/src/utils/affine-io.ts
similarity index 100%
rename from packages/frontend/workspace/src/utils/affine-io.ts
rename to packages/frontend/workspace-impl/src/utils/affine-io.ts
diff --git a/packages/frontend/workspace/src/utils/base64.ts b/packages/frontend/workspace-impl/src/utils/base64.ts
similarity index 100%
rename from packages/frontend/workspace/src/utils/base64.ts
rename to packages/frontend/workspace-impl/src/utils/base64.ts
diff --git a/packages/frontend/workspace/src/utils/buffer-to-blob.ts b/packages/frontend/workspace-impl/src/utils/buffer-to-blob.ts
similarity index 100%
rename from packages/frontend/workspace/src/utils/buffer-to-blob.ts
rename to packages/frontend/workspace-impl/src/utils/buffer-to-blob.ts
diff --git a/packages/frontend/workspace-impl/src/utils/merge-updates.ts b/packages/frontend/workspace-impl/src/utils/merge-updates.ts
new file mode 100644
index 0000000000..e3c8a4a06a
--- /dev/null
+++ b/packages/frontend/workspace-impl/src/utils/merge-updates.ts
@@ -0,0 +1,17 @@
+import { applyUpdate, Doc, encodeStateAsUpdate } from 'yjs';
+
+export function mergeUpdates(updates: Uint8Array[]) {
+ if (updates.length === 0) {
+ return new Uint8Array();
+ }
+ if (updates.length === 1) {
+ return updates[0];
+ }
+ const doc = new Doc();
+ doc.transact(() => {
+ updates.forEach(update => {
+ applyUpdate(doc, update);
+ });
+ });
+ return encodeStateAsUpdate(doc);
+}
diff --git a/packages/frontend/workspace-impl/tsconfig.json b/packages/frontend/workspace-impl/tsconfig.json
new file mode 100644
index 0000000000..15af0a0980
--- /dev/null
+++ b/packages/frontend/workspace-impl/tsconfig.json
@@ -0,0 +1,16 @@
+{
+ "extends": "../../../tsconfig.json",
+ "include": ["./src"],
+ "compilerOptions": {
+ "noEmit": false,
+ "outDir": "lib"
+ },
+ "references": [
+ { "path": "../../../tests/fixtures" },
+ { "path": "../../common/env" },
+ { "path": "../../common/debug" },
+ { "path": "../../common/infra" },
+ { "path": "../../frontend/graphql" },
+ { "path": "../../frontend/electron-api" }
+ ]
+}
diff --git a/packages/frontend/workspace/src/impl/index.ts b/packages/frontend/workspace/src/impl/index.ts
deleted file mode 100644
index a2d3a7baa9..0000000000
--- a/packages/frontend/workspace/src/impl/index.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-export * from './cloud';
-export * from './local';
diff --git a/packages/frontend/workspace/src/index.ts b/packages/frontend/workspace/src/index.ts
deleted file mode 100644
index 84c8aa193b..0000000000
--- a/packages/frontend/workspace/src/index.ts
+++ /dev/null
@@ -1,29 +0,0 @@
-import {
- cloudWorkspaceFactory,
- createCloudWorkspaceListProvider,
- createLocalWorkspaceListProvider,
- localWorkspaceFactory,
-} from './impl';
-import { WorkspaceList } from './list';
-import { WorkspaceManager } from './manager';
-
-const list = new WorkspaceList([
- createLocalWorkspaceListProvider(),
- createCloudWorkspaceListProvider(),
-]);
-
-export const workspaceManager = new WorkspaceManager(list, [
- localWorkspaceFactory,
- cloudWorkspaceFactory,
-]);
-
-(window as any).workspaceManager = workspaceManager;
-
-export * from './engine';
-export * from './factory';
-export * from './global-schema';
-export * from './impl';
-export * from './list';
-export * from './manager';
-export * from './metadata';
-export * from './workspace';
diff --git a/tests/storybook/.storybook/preview.tsx b/tests/storybook/.storybook/preview.tsx
index ef9029d20a..161352956b 100644
--- a/tests/storybook/.storybook/preview.tsx
+++ b/tests/storybook/.storybook/preview.tsx
@@ -8,7 +8,7 @@ import MockSessionContext, {
import { ThemeProvider, useTheme } from 'next-themes';
import { useDarkMode } from 'storybook-dark-mode';
import { AffineContext } from '@affine/component/context';
-import { workspaceManager } from '@affine/workspace';
+import { workspaceManager } from '@affine/workspace-impl';
import useSWR from 'swr';
import type { Decorator } from '@storybook/react';
import { createStore } from 'jotai/vanilla';
diff --git a/tests/storybook/tsconfig.json b/tests/storybook/tsconfig.json
index 196f3b13ed..50c1e0d170 100644
--- a/tests/storybook/tsconfig.json
+++ b/tests/storybook/tsconfig.json
@@ -22,7 +22,7 @@
"path": "../../packages/common/infra"
},
{
- "path": "../../packages/frontend/workspace"
+ "path": "../../packages/common/workspace"
},
{
"path": "./tsconfig.node.json"
diff --git a/tsconfig.json b/tsconfig.json
index a956f6ad96..0a9b0cee9d 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -60,7 +60,8 @@
"@affine/debug": ["./packages/common/debug"],
"@affine/env": ["./packages/common/env/src"],
"@affine/env/*": ["./packages/common/env/src/*"],
- "@affine/workspace/*": ["./packages/frontend/workspace/src/*"],
+ "@affine/workspace/*": ["./packages/common/workspace/src/*"],
+ "@affine/workspace-impl/*": ["./packages/frontend/workspace-impl/src/*"],
"@affine/graphql": ["./packages/frontend/graphql/src"],
"@affine/electron/scripts/*": ["./packages/frontend/electron/scripts/*"],
"@affine-test/kit/*": ["./tests/kit/*"],
@@ -100,7 +101,10 @@
"path": "./packages/frontend/i18n"
},
{
- "path": "./packages/frontend/workspace"
+ "path": "./packages/common/workspace"
+ },
+ {
+ "path": "./packages/frontend/workspace-impl"
},
// Common
{
diff --git a/yarn.lock b/yarn.lock
index 9397ed4d99..7a052616ef 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -316,6 +316,7 @@ __metadata:
"@affine/i18n": "workspace:*"
"@affine/templates": "workspace:*"
"@affine/workspace": "workspace:*"
+ "@affine/workspace-impl": "workspace:*"
"@aws-sdk/client-s3": "npm:3.484.0"
"@blocksuite/block-std": "npm:0.11.0-nightly-202312220916-e3abcbb"
"@blocksuite/blocks": "npm:0.11.0-nightly-202312220916-e3abcbb"
@@ -791,42 +792,45 @@ __metadata:
languageName: unknown
linkType: soft
-"@affine/workspace@workspace:*, @affine/workspace@workspace:packages/frontend/workspace":
+"@affine/workspace-impl@workspace:*, @affine/workspace-impl@workspace:packages/frontend/workspace-impl":
version: 0.0.0-use.local
- resolution: "@affine/workspace@workspace:packages/frontend/workspace"
+ resolution: "@affine/workspace-impl@workspace:packages/frontend/workspace-impl"
dependencies:
- "@affine-test/fixtures": "workspace:*"
"@affine/debug": "workspace:*"
"@affine/electron-api": "workspace:*"
"@affine/env": "workspace:*"
"@affine/graphql": "workspace:*"
- "@testing-library/react": "npm:^14.0.0"
+ "@affine/workspace": "workspace:*"
"@toeverything/infra": "workspace:*"
- "@types/ws": "npm:^8.5.7"
- async-call-rpc: "npm:^6.3.1"
fake-indexeddb: "npm:^5.0.0"
idb: "npm:^8.0.0"
idb-keyval: "npm:^6.2.1"
is-svg: "npm:^5.0.0"
- jotai: "npm:^2.5.1"
- js-base64: "npm:^3.7.5"
- ky: "npm:^1.0.1"
- lib0: "npm:^0.2.87"
lodash-es: "npm:^4.17.21"
nanoid: "npm:^5.0.3"
next-auth: "npm:^4.24.5"
- react: "npm:18.2.0"
- react-dom: "npm:18.2.0"
- rxjs: "npm:^7.8.1"
socket.io-client: "npm:^4.7.2"
- swr: "npm:2.2.4"
- valtio: "npm:^1.11.2"
vitest: "npm:1.1.1"
ws: "npm:^8.14.2"
y-protocols: "npm:^1.0.6"
- y-provider: "workspace:*"
yjs: "npm:^13.6.10"
- zod: "npm:^3.22.4"
+ peerDependencies:
+ "@blocksuite/blocks": "*"
+ "@blocksuite/global": "*"
+ "@blocksuite/store": "*"
+ languageName: unknown
+ linkType: soft
+
+"@affine/workspace@workspace:*, @affine/workspace@workspace:packages/common/workspace":
+ version: 0.0.0-use.local
+ resolution: "@affine/workspace@workspace:packages/common/workspace"
+ dependencies:
+ "@affine/debug": "workspace:*"
+ "@affine/env": "workspace:*"
+ "@toeverything/infra": "workspace:*"
+ lodash-es: "npm:^4.17.21"
+ vitest: "npm:1.1.0"
+ yjs: "npm:^13.6.10"
peerDependencies:
"@blocksuite/blocks": "*"
"@blocksuite/global": "*"
@@ -14428,7 +14432,7 @@ __metadata:
languageName: node
linkType: hard
-"@types/ws@npm:^8.0.0, @types/ws@npm:^8.5.10, @types/ws@npm:^8.5.5, @types/ws@npm:^8.5.7":
+"@types/ws@npm:^8.0.0, @types/ws@npm:^8.5.10, @types/ws@npm:^8.5.5":
version: 8.5.10
resolution: "@types/ws@npm:8.5.10"
dependencies:
@@ -14774,6 +14778,17 @@ __metadata:
languageName: node
linkType: hard
+"@vitest/expect@npm:1.1.0":
+ version: 1.1.0
+ resolution: "@vitest/expect@npm:1.1.0"
+ dependencies:
+ "@vitest/spy": "npm:1.1.0"
+ "@vitest/utils": "npm:1.1.0"
+ chai: "npm:^4.3.10"
+ checksum: 08d1ea192cf638da4b6f19e67642ea6a181593bca3c21ca8cb741d8d0792f95876281414b9cce0c0583701489a1ebbbdc4a83eec3012874bba3282d15664eaaa
+ languageName: node
+ linkType: hard
+
"@vitest/expect@npm:1.1.1":
version: 1.1.1
resolution: "@vitest/expect@npm:1.1.1"
@@ -14785,6 +14800,17 @@ __metadata:
languageName: node
linkType: hard
+"@vitest/runner@npm:1.1.0":
+ version: 1.1.0
+ resolution: "@vitest/runner@npm:1.1.0"
+ dependencies:
+ "@vitest/utils": "npm:1.1.0"
+ p-limit: "npm:^5.0.0"
+ pathe: "npm:^1.1.1"
+ checksum: f21c503ea944cdafcf33160913759ae686739ccde7b36d060128a4f7387245019ab4508d825ddf51268aea6e72bc8afd4806ca6ba88f564274d5265229c8e91f
+ languageName: node
+ linkType: hard
+
"@vitest/runner@npm:1.1.1":
version: 1.1.1
resolution: "@vitest/runner@npm:1.1.1"
@@ -14796,6 +14822,17 @@ __metadata:
languageName: node
linkType: hard
+"@vitest/snapshot@npm:1.1.0":
+ version: 1.1.0
+ resolution: "@vitest/snapshot@npm:1.1.0"
+ dependencies:
+ magic-string: "npm:^0.30.5"
+ pathe: "npm:^1.1.1"
+ pretty-format: "npm:^29.7.0"
+ checksum: e4db6344019aae10fe880cecf0a058e22e4952172cc9bb2a8ea9fc41d3e32a3dc3e99520676cffd4d870ba77108e24f2d8ab1e391da423d21c2533e1933def5e
+ languageName: node
+ linkType: hard
+
"@vitest/snapshot@npm:1.1.1":
version: 1.1.1
resolution: "@vitest/snapshot@npm:1.1.1"
@@ -14807,6 +14844,15 @@ __metadata:
languageName: node
linkType: hard
+"@vitest/spy@npm:1.1.0":
+ version: 1.1.0
+ resolution: "@vitest/spy@npm:1.1.0"
+ dependencies:
+ tinyspy: "npm:^2.2.0"
+ checksum: 99d507df9e0f4224fa21b841721af2ed03d7538e534fb55627d5e8ba684b8659b79a1d46cfaa87d24121ce14fd0a93a04c01099e0758ba40fbdd6efebc4278d1
+ languageName: node
+ linkType: hard
+
"@vitest/spy@npm:1.1.1":
version: 1.1.1
resolution: "@vitest/spy@npm:1.1.1"
@@ -14833,6 +14879,17 @@ __metadata:
languageName: node
linkType: hard
+"@vitest/utils@npm:1.1.0":
+ version: 1.1.0
+ resolution: "@vitest/utils@npm:1.1.0"
+ dependencies:
+ diff-sequences: "npm:^29.6.3"
+ loupe: "npm:^2.3.7"
+ pretty-format: "npm:^29.7.0"
+ checksum: d1e5443b366664f244d8cbce8a36fcc74a5c784a97aeabd93511afc86c04acdd57414c16d97151656466626af9553cf10074618c16722fff88bbb7545186eeb8
+ languageName: node
+ linkType: hard
+
"@vitest/utils@npm:1.1.1":
version: 1.1.1
resolution: "@vitest/utils@npm:1.1.1"
@@ -24700,13 +24757,6 @@ __metadata:
languageName: node
linkType: hard
-"js-base64@npm:^3.7.5":
- version: 3.7.5
- resolution: "js-base64@npm:3.7.5"
- checksum: 97642fdef112cb99aed25a092156029e2f44cef0e4e3bf64dba0b6f8d85b9f4ee80b65ab8fa11a051dfcd09133bcd96c130167afdf90e4e4b21933632157a4f9
- languageName: node
- linkType: hard
-
"js-levenshtein@npm:^1.1.6":
version: 1.1.6
resolution: "js-levenshtein@npm:1.1.6"
@@ -25059,13 +25109,6 @@ __metadata:
languageName: node
linkType: hard
-"ky@npm:^1.0.1":
- version: 1.1.3
- resolution: "ky@npm:1.1.3"
- checksum: 0545fd228d7e21aa51adc1b317559da317cdd3131d5af86480dcd323231d5e5831987dbb1d1a61317a9a7d615a9d822faff827fd22956f14cd345bf764da95fe
- languageName: node
- linkType: hard
-
"launch-editor@npm:^2.6.0":
version: 2.6.1
resolution: "launch-editor@npm:2.6.1"
@@ -34719,6 +34762,21 @@ __metadata:
languageName: node
linkType: hard
+"vite-node@npm:1.1.0":
+ version: 1.1.0
+ resolution: "vite-node@npm:1.1.0"
+ dependencies:
+ cac: "npm:^6.7.14"
+ debug: "npm:^4.3.4"
+ pathe: "npm:^1.1.1"
+ picocolors: "npm:^1.0.0"
+ vite: "npm:^5.0.0"
+ bin:
+ vite-node: vite-node.mjs
+ checksum: 2978b2fa7091233c234a86d60be6d6b407748471ae7b0e10a93ccd707ed2c888f04bc1c0e0737fa243f85e8477c18d6ed998b5bf67fd42cdd8778cc9cd40868c
+ languageName: node
+ linkType: hard
+
"vite-node@npm:1.1.1":
version: 1.1.1
resolution: "vite-node@npm:1.1.1"
@@ -34880,6 +34938,57 @@ __metadata:
languageName: node
linkType: hard
+"vitest@npm:1.1.0":
+ version: 1.1.0
+ resolution: "vitest@npm:1.1.0"
+ dependencies:
+ "@vitest/expect": "npm:1.1.0"
+ "@vitest/runner": "npm:1.1.0"
+ "@vitest/snapshot": "npm:1.1.0"
+ "@vitest/spy": "npm:1.1.0"
+ "@vitest/utils": "npm:1.1.0"
+ acorn-walk: "npm:^8.3.0"
+ cac: "npm:^6.7.14"
+ chai: "npm:^4.3.10"
+ debug: "npm:^4.3.4"
+ execa: "npm:^8.0.1"
+ local-pkg: "npm:^0.5.0"
+ magic-string: "npm:^0.30.5"
+ pathe: "npm:^1.1.1"
+ picocolors: "npm:^1.0.0"
+ std-env: "npm:^3.5.0"
+ strip-literal: "npm:^1.3.0"
+ tinybench: "npm:^2.5.1"
+ tinypool: "npm:^0.8.1"
+ vite: "npm:^5.0.0"
+ vite-node: "npm:1.1.0"
+ why-is-node-running: "npm:^2.2.2"
+ peerDependencies:
+ "@edge-runtime/vm": "*"
+ "@types/node": ^18.0.0 || >=20.0.0
+ "@vitest/browser": ^1.0.0
+ "@vitest/ui": ^1.0.0
+ happy-dom: "*"
+ jsdom: "*"
+ peerDependenciesMeta:
+ "@edge-runtime/vm":
+ optional: true
+ "@types/node":
+ optional: true
+ "@vitest/browser":
+ optional: true
+ "@vitest/ui":
+ optional: true
+ happy-dom:
+ optional: true
+ jsdom:
+ optional: true
+ bin:
+ vitest: vitest.mjs
+ checksum: 5e4ac0231b2dc9cf51892e0414c7ab092e70bf5eacdb9c4a8cdd941bdd325544eb4ffe8eb89586aa6e399f9a34739f330482c64c13300bf1b7c5b130101d7e7c
+ languageName: node
+ linkType: hard
+
"vitest@npm:1.1.1":
version: 1.1.1
resolution: "vitest@npm:1.1.1"