feat!: unified migration logic in server electron, and browser (#4079)

Co-authored-by: Mirone <Saul-Mirone@outlook.com>
This commit is contained in:
Alex Yang
2023-09-06 00:44:53 -07:00
committed by GitHub
parent 925c18300f
commit 1b6a78cd00
61 changed files with 10776 additions and 10267 deletions
+1
View File
@@ -236,6 +236,7 @@ jobs:
spec:
- { package: 0.7.0-canary.18 }
- { package: 0.8.0-canary.7 }
- { package: 0.8.3 }
steps:
- uses: actions/checkout@v3
- name: Setup Node.js
+1 -1
View File
@@ -8,7 +8,7 @@ packages/graphql/src/graphql/index.ts
out
dist
.yarn
tests/affine-legacy/0.7.0-canary.18/static
tests/affine-legacy/**/static
.github/helm
_next
storybook-static
+6 -6
View File
@@ -24,13 +24,13 @@
"@affine/jotai": "workspace:*",
"@affine/templates": "workspace:*",
"@affine/workspace": "workspace:*",
"@blocksuite/block-std": "0.0.0-20230829150056-df43987c-nightly",
"@blocksuite/blocks": "0.0.0-20230829150056-df43987c-nightly",
"@blocksuite/editor": "0.0.0-20230829150056-df43987c-nightly",
"@blocksuite/global": "0.0.0-20230829150056-df43987c-nightly",
"@blocksuite/block-std": "0.0.0-20230905170607-94acf22c-nightly",
"@blocksuite/blocks": "0.0.0-20230905170607-94acf22c-nightly",
"@blocksuite/editor": "0.0.0-20230905170607-94acf22c-nightly",
"@blocksuite/global": "0.0.0-20230905170607-94acf22c-nightly",
"@blocksuite/icons": "^2.1.32",
"@blocksuite/lit": "0.0.0-20230829150056-df43987c-nightly",
"@blocksuite/store": "0.0.0-20230829150056-df43987c-nightly",
"@blocksuite/lit": "0.0.0-20230905170607-94acf22c-nightly",
"@blocksuite/store": "0.0.0-20230905170607-94acf22c-nightly",
"@dnd-kit/core": "^6.0.8",
"@dnd-kit/sortable": "^7.0.2",
"@emotion/cache": "^11.11.0",
+5 -1
View File
@@ -15,7 +15,10 @@ import {
CRUD,
saveWorkspaceToLocalStorage,
} from '@affine/workspace/local/crud';
import { getOrCreateWorkspace } from '@affine/workspace/manager';
import {
getOrCreateWorkspace,
globalBlockSuiteSchema,
} from '@affine/workspace/manager';
import { createIndexedDBDownloadProvider } from '@affine/workspace/providers';
import { nanoid } from '@blocksuite/store';
import { useStaticBlockSuiteWorkspace } from '@toeverything/infra/__internal__/react';
@@ -49,6 +52,7 @@ export const LocalAdapter: WorkspaceAdapter<WorkspaceFlavour.LOCAL> = {
blockSuiteWorkspace.meta.setName(DEFAULT_WORKSPACE_NAME);
if (runtimeConfig.enablePreloading) {
buildShowcaseWorkspace(blockSuiteWorkspace, {
schema: globalBlockSuiteSchema,
store: getCurrentStore(),
atoms: {
pageMode: setPageModeAtom,
+49 -34
View File
@@ -18,10 +18,9 @@ import {
migrateWorkspace,
WorkspaceVersion,
} from '@toeverything/infra/blocksuite';
import { downloadBinary } from '@toeverything/y-indexeddb';
import { downloadBinary, overwriteBinary } from '@toeverything/y-indexeddb';
import type { createStore } from 'jotai/vanilla';
import { Doc } from 'yjs';
import { applyUpdate } from 'yjs';
import { applyUpdate, Doc as YDoc, encodeStateAsUpdate } from 'yjs';
import { WorkspaceAdapters } from '../adapters/workspace';
@@ -34,37 +33,39 @@ async function tryMigration() {
const newMetadata = [...metadata];
metadata.forEach(oldMeta => {
if (oldMeta.flavour === WorkspaceFlavour.LOCAL) {
let doc: YDoc;
const options = {
getCurrentRootDoc: async () => {
doc = new YDoc({
guid: oldMeta.id,
});
const downloadWorkspace = async (doc: YDoc): Promise<void> => {
const binary = await downloadBinary(doc.guid);
if (binary) {
applyUpdate(doc, binary);
}
await Promise.all(
[...doc.subdocs.values()].map(subdoc =>
downloadWorkspace(subdoc)
)
);
};
await downloadWorkspace(doc);
return doc;
},
createWorkspace: async () =>
getOrCreateWorkspace(nanoid(), WorkspaceFlavour.LOCAL),
getSchema: () => globalBlockSuiteSchema,
};
promises.push(
migrateWorkspace(
'version' in oldMeta ? oldMeta.version : undefined,
{
getCurrentRootDoc: async () => {
const doc = new Doc({
guid: oldMeta.id,
});
const downloadWorkspace = async (doc: Doc): Promise<void> => {
const binary = await downloadBinary(doc.guid);
if (binary) {
applyUpdate(doc, binary);
}
return Promise.all(
[...doc.subdocs.values()].map(subdoc =>
downloadWorkspace(subdoc)
)
).then();
};
await downloadWorkspace(doc);
return doc;
},
createWorkspace: async () =>
getOrCreateWorkspace(nanoid(), WorkspaceFlavour.LOCAL),
getSchema: () => globalBlockSuiteSchema,
}
).then(async workspace => {
if (typeof workspace !== 'boolean') {
options
).then(async status => {
if (typeof status !== 'boolean') {
const adapter = WorkspaceAdapters[oldMeta.flavour];
const oldWorkspace = await adapter.CRUD.get(oldMeta.id);
const newId = await adapter.CRUD.create(workspace);
const newId = await adapter.CRUD.create(status);
assertExists(
oldWorkspace,
'workspace should exist after migrate'
@@ -76,11 +77,25 @@ async function tryMigration() {
newMetadata[index] = {
...oldMeta,
id: newId,
version: WorkspaceVersion.DatabaseV3,
version: WorkspaceVersion.Surface,
};
await migrateLocalBlobStorage(workspace.id, newId);
await migrateLocalBlobStorage(status.id, newId);
console.log('workspace migrated', oldMeta.id, newId);
} else if (workspace) {
} else if (status) {
const index = newMetadata.findIndex(
meta => meta.id === oldMeta.id
);
newMetadata[index] = {
...oldMeta,
version: WorkspaceVersion.Surface,
};
const overWrite = async (doc: YDoc): Promise<void> => {
await overwriteBinary(doc.guid, encodeStateAsUpdate(doc));
return Promise.all(
[...doc.subdocs.values()].map(subdoc => overWrite(subdoc))
).then();
};
await overWrite(doc);
console.log('workspace migrated', oldMeta.id);
}
})
@@ -106,7 +121,7 @@ async function tryMigration() {
}
}
function createFirstAppData(store: ReturnType<typeof createStore>) {
export function createFirstAppData(store: ReturnType<typeof createStore>) {
const createFirst = (): RootWorkspaceMetadataV2[] => {
const Plugins = Object.values(WorkspaceAdapters).sort(
(a, b) => a.loadPriority - b.loadPriority
@@ -144,8 +159,8 @@ export async function setup(store: ReturnType<typeof createStore>) {
console.log('setup global');
setupGlobal();
createFirstAppData(store);
await tryMigration();
// do not read `rootWorkspacesMetadataAtom` before migration
await store.get(rootWorkspacesMetadataAtom);
console.log('setup done');
}
@@ -0,0 +1,111 @@
import type {
AffineSocketIOProvider,
LocalIndexedDBBackgroundProvider,
SQLiteProvider,
} from '@affine/env/workspace';
import { assertExists } from '@blocksuite/global/utils';
import { Button } from '@toeverything/components/button';
import { forceUpgradePages } from '@toeverything/infra/blocksuite';
import { useCallback, useMemo, useState } from 'react';
import type { Doc as YDoc } from 'yjs';
import { applyUpdate, encodeStateAsUpdate, encodeStateVector } from 'yjs';
import { useCurrentWorkspace } from '../hooks/current/use-current-workspace';
export const MigrationFallback = function MigrationFallback() {
const [done, setDone] = useState(false);
const [workspace] = useCurrentWorkspace();
const providers = workspace.blockSuiteWorkspace.providers;
const remoteProvider: AffineSocketIOProvider | undefined = useMemo(() => {
return providers.find(
(provider): provider is AffineSocketIOProvider =>
provider.flavour === 'affine-socket-io'
);
}, [providers]);
const localProvider = useMemo(() => {
const sqliteProvider = providers.find(
(provider): provider is SQLiteProvider => provider.flavour === 'sqlite'
);
const indexedDbProvider = providers.find(
(provider): provider is LocalIndexedDBBackgroundProvider =>
provider.flavour === 'local-indexeddb-background'
);
const provider = sqliteProvider || indexedDbProvider;
assertExists(provider, 'no local provider');
return provider;
}, [providers]);
const handleClick = useCallback(async () => {
setDone(false);
const downloadRecursively = async (doc: YDoc) => {
{
const docState = await localProvider.datasource.queryDocState(
doc.guid,
{
stateVector: encodeStateVector(doc),
}
);
console.log('download indexeddb', doc.guid);
if (docState) {
applyUpdate(doc, docState.missing, 'migration');
}
}
if (remoteProvider) {
{
const docState = await remoteProvider.datasource.queryDocState(
doc.guid,
{
stateVector: encodeStateVector(doc),
}
);
console.log('download remote', doc.guid);
if (docState) {
applyUpdate(doc, docState.missing, 'migration');
}
}
}
await Promise.all(
[...doc.subdocs].map(async subdoc => {
await downloadRecursively(subdoc);
})
);
{
await localProvider.datasource.sendDocUpdate(
doc.guid,
encodeStateAsUpdate(doc)
);
console.log('upload indexeddb', doc.guid);
if (remoteProvider) {
await remoteProvider.datasource.sendDocUpdate(
doc.guid,
encodeStateAsUpdate(doc)
);
console.log('upload remote', doc.guid);
}
}
};
await downloadRecursively(workspace.blockSuiteWorkspace.doc);
console.log('download done');
console.log('start migration');
await forceUpgradePages({
getCurrentRootDoc: async () => workspace.blockSuiteWorkspace.doc,
getSchema: () => workspace.blockSuiteWorkspace.schema,
});
console.log('migration done');
setDone(true);
}, [
localProvider.datasource,
remoteProvider,
workspace.blockSuiteWorkspace.doc,
workspace.blockSuiteWorkspace.schema,
]);
if (done) {
return <div>Done, please refresh the page.</div>;
}
return (
<Button data-testid="upgrade-workspace" onClick={handleClick}>
Upgrade Workspace
</Button>
);
};
+5 -1
View File
@@ -2,7 +2,10 @@ import { DebugLogger } from '@affine/debug';
import { WorkspaceFlavour } from '@affine/env/workspace';
import { rootWorkspacesMetadataAtom } from '@affine/workspace/atom';
import { saveWorkspaceToLocalStorage } from '@affine/workspace/local/crud';
import { getOrCreateWorkspace } from '@affine/workspace/manager';
import {
getOrCreateWorkspace,
globalBlockSuiteSchema,
} from '@affine/workspace/manager';
import { nanoid } from '@blocksuite/store';
import { getWorkspace } from '@toeverything/infra/__internal__/workspace';
import { getCurrentStore } from '@toeverything/infra/atom';
@@ -73,6 +76,7 @@ export function useAppHelper() {
WorkspaceFlavour.LOCAL
);
await buildShowcaseWorkspace(blockSuiteWorkspace, {
schema: globalBlockSuiteSchema,
store: getCurrentStore(),
atoms: {
pageMode: setPageModeAtom,
+15 -4
View File
@@ -47,6 +47,7 @@ import { useAppSetting } from '../atoms/settings';
import { AdapterProviderWrapper } from '../components/adapter-worksapce-wrapper';
import { AppContainer } from '../components/affine/app-container';
import { usePageHelper } from '../components/blocksuite/block-suite-page-list/utils';
import { MigrationFallback } from '../components/migration-fallback';
import type { IslandItemNames } from '../components/pure/help-island';
import { HelpIsland } from '../components/pure/help-island';
import { processCollectionsDrag } from '../components/pure/workspace-slider-bar/collections';
@@ -112,9 +113,14 @@ export const CurrentWorkspaceContext = ({
return <>{children}</>;
};
type WorkspaceLayoutProps = {
incompatible?: boolean;
};
export const WorkspaceLayout = function WorkspacesSuspense({
children,
}: PropsWithChildren) {
incompatible = false,
}: PropsWithChildren<WorkspaceLayoutProps>) {
return (
<AdapterProviderWrapper>
<CurrentWorkspaceContext>
@@ -124,14 +130,19 @@ export const WorkspaceLayout = function WorkspacesSuspense({
<CurrentWorkspaceModals />
</Suspense>
<Suspense fallback={<WorkspaceFallback />}>
<WorkspaceLayoutInner>{children}</WorkspaceLayoutInner>
<WorkspaceLayoutInner incompatible={incompatible}>
{children}
</WorkspaceLayoutInner>
</Suspense>
</CurrentWorkspaceContext>
</AdapterProviderWrapper>
);
};
export const WorkspaceLayoutInner = ({ children }: PropsWithChildren) => {
export const WorkspaceLayoutInner = ({
children,
incompatible = false,
}: PropsWithChildren<WorkspaceLayoutProps>) => {
const [currentWorkspace] = useCurrentWorkspace();
const { openPage } = useNavigateHelper();
@@ -263,7 +274,7 @@ export const WorkspaceLayoutInner = ({ children }: PropsWithChildren) => {
ref={setMainContainer}
padding={appSetting.clientBorder}
>
{children}
{incompatible ? <MigrationFallback /> : children}
<ToolContainer>
<BlockHubWrapper blockHubAtom={rootBlockHubAtom} />
<HelpIsland showList={pageId ? undefined : showList} />
+3 -5
View File
@@ -17,6 +17,8 @@ const logger = new DebugLogger('index-page');
export const loader: LoaderFunction = async () => {
const rootStore = getCurrentStore();
const { createFirstAppData } = await import('../bootstrap/setup');
createFirstAppData(rootStore);
const meta = await rootStore.get(rootWorkspacesMetadataAtom);
const lastId = localStorage.getItem('last_workspace_id');
const lastPageId = localStorage.getItem('last_page_id');
@@ -52,9 +54,5 @@ export const loader: LoaderFunction = async () => {
};
export const Component = () => {
return (
<>
<AllWorkspaceModals />
</>
);
return <AllWorkspaceModals />;
};
+27 -3
View File
@@ -1,18 +1,27 @@
import { WorkspaceFlavour } from '@affine/env/workspace';
import { rootWorkspacesMetadataAtom } from '@affine/workspace/atom';
import { assertExists } from '@blocksuite/global/utils';
import { getActiveBlockSuiteWorkspaceAtom } from '@toeverything/infra/__internal__/workspace';
import {
currentPageIdAtom,
currentWorkspaceIdAtom,
getCurrentStore,
} from '@toeverything/infra/atom';
import type { ReactElement } from 'react';
import { type LoaderFunction, Outlet, redirect } from 'react-router-dom';
import {
type LoaderFunction,
Outlet,
redirect,
useLoaderData,
} from 'react-router-dom';
import { WorkspaceLayout } from '../../layouts/workspace-layout';
export const loader: LoaderFunction = async args => {
const rootStore = getCurrentStore();
const meta = await rootStore.get(rootWorkspacesMetadataAtom);
if (!meta.some(({ id }) => id === args.params.workspaceId)) {
const currentMetadata = meta.find(({ id }) => id === args.params.workspaceId);
if (!currentMetadata) {
return redirect('/404');
}
if (args.params.workspaceId) {
@@ -22,12 +31,27 @@ export const loader: LoaderFunction = async args => {
if (!args.params.pageId) {
rootStore.set(currentPageIdAtom, null);
}
if (currentMetadata.flavour === WorkspaceFlavour.AFFINE_CLOUD) {
const workspaceAtom = getActiveBlockSuiteWorkspaceAtom(currentMetadata.id);
const workspace = await rootStore.get(workspaceAtom);
return (() => {
const blockVersions = workspace.meta.blockVersions;
assertExists(blockVersions, 'blockVersions should not be null');
for (const [flavour, schema] of workspace.schema.flavourSchemaMap) {
if (blockVersions[flavour] !== schema.version) {
return true;
}
}
return false;
})();
}
return null;
};
export const Component = (): ReactElement => {
const incompatible = useLoaderData();
return (
<WorkspaceLayout>
<WorkspaceLayout incompatible={!!incompatible}>
<Outlet />
</WorkspaceLayout>
);
+6 -6
View File
@@ -10,12 +10,12 @@
},
"dependencies": {
"@affine/component": "workspace:*",
"@blocksuite/block-std": "0.0.0-20230829150056-df43987c-nightly",
"@blocksuite/blocks": "0.0.0-20230829150056-df43987c-nightly",
"@blocksuite/editor": "0.0.0-20230829150056-df43987c-nightly",
"@blocksuite/global": "0.0.0-20230829150056-df43987c-nightly",
"@blocksuite/lit": "0.0.0-20230829150056-df43987c-nightly",
"@blocksuite/store": "0.0.0-20230829150056-df43987c-nightly",
"@blocksuite/block-std": "0.0.0-20230905170607-94acf22c-nightly",
"@blocksuite/blocks": "0.0.0-20230905170607-94acf22c-nightly",
"@blocksuite/editor": "0.0.0-20230905170607-94acf22c-nightly",
"@blocksuite/global": "0.0.0-20230905170607-94acf22c-nightly",
"@blocksuite/lit": "0.0.0-20230905170607-94acf22c-nightly",
"@blocksuite/store": "0.0.0-20230905170607-94acf22c-nightly",
"express": "^4.18.2",
"jotai": "^2.4.1",
"react": "18.3.0-canary-7118f5dd7-20230705",
+4 -4
View File
@@ -29,10 +29,10 @@
"@affine/env": "workspace:*",
"@affine/native": "workspace:*",
"@affine/sdk": "workspace:*",
"@blocksuite/blocks": "0.0.0-20230829150056-df43987c-nightly",
"@blocksuite/editor": "0.0.0-20230829150056-df43987c-nightly",
"@blocksuite/lit": "0.0.0-20230829150056-df43987c-nightly",
"@blocksuite/store": "0.0.0-20230829150056-df43987c-nightly",
"@blocksuite/blocks": "0.0.0-20230905170607-94acf22c-nightly",
"@blocksuite/editor": "0.0.0-20230905170607-94acf22c-nightly",
"@blocksuite/lit": "0.0.0-20230905170607-94acf22c-nightly",
"@blocksuite/store": "0.0.0-20230905170607-94acf22c-nightly",
"@electron-forge/cli": "^6.4.1",
"@electron-forge/core": "^6.4.1",
"@electron-forge/core-utils": "^6.4.1",
@@ -3,8 +3,9 @@ import {
SqliteConnection,
ValidationResult,
} from '@affine/native';
import { WorkspaceVersion } from '@toeverything/infra/blocksuite';
import { migrateToLatestDatabase } from '../db/migration';
import { migrateToLatest } from '../db/migration';
import { logger } from '../logger';
/**
@@ -20,10 +21,14 @@ export abstract class BaseSQLiteAdapter {
if (!this.db) {
const validation = await SqliteConnection.validate(this.path);
if (validation === ValidationResult.MissingVersionColumn) {
await migrateToLatestDatabase(this.path);
await migrateToLatest(this.path, WorkspaceVersion.SubDoc);
}
this.db = new SqliteConnection(this.path);
await this.db.connect();
const maxVersion = await this.db.getMaxVersion();
if (maxVersion !== WorkspaceVersion.Surface) {
await migrateToLatest(this.path, WorkspaceVersion.Surface);
}
logger.info(`[SQLiteAdapter:${this.role}]`, 'connected:', this.path);
}
return this.db;
+15 -21
View File
@@ -2,7 +2,10 @@ import { equal } from 'node:assert';
import { resolve } from 'node:path';
import { SqliteConnection } from '@affine/native';
import { __unstableSchemas, AffineSchemas } from '@blocksuite/blocks/models';
import { Schema } from '@blocksuite/store';
import {
forceUpgradePages,
migrateToSubdoc,
WorkspaceVersion,
} from '@toeverything/infra/blocksuite';
@@ -34,15 +37,19 @@ export const migrateToSubdocAndReplaceDatabase = async (path: string) => {
await db.close();
};
import { __unstableSchemas, AffineSchemas } from '@blocksuite/blocks/models';
import { Schema, Workspace } from '@blocksuite/store';
import { migrateWorkspace } from '@toeverything/infra/blocksuite';
// v1 v2 -> v3
export const migrateToLatestDatabase = async (path: string) => {
// v3 -> v4
export const migrateToLatest = async (
path: string,
version: WorkspaceVersion
) => {
const connection = new SqliteConnection(path);
await connection.connect();
await connection.initVersion();
if (version === WorkspaceVersion.SubDoc) {
await connection.initVersion();
} else {
await connection.setVersion(version);
}
const schema = new Schema();
schema.register(AffineSchemas).register(__unstableSchemas);
const rootDoc = new YDoc();
@@ -69,24 +76,11 @@ export const migrateToLatestDatabase = async (path: string) => {
);
};
await downloadBinary(rootDoc, true);
const result = await migrateWorkspace(WorkspaceVersion.SubDoc, {
const result = await forceUpgradePages({
getSchema: () => schema,
getCurrentRootDoc: () => Promise.resolve(rootDoc),
createWorkspace: () =>
Promise.resolve(
new Workspace({
id: nanoid(10),
schema,
blobStorages: [],
providerCreators: [],
})
),
});
equal(
typeof result,
'boolean',
'migrateWorkspace should return boolean value'
);
equal(result, true, 'migrateWorkspace should return boolean value');
const uploadBinary = async (doc: YDoc, isRoot: boolean) => {
await connection.replaceUpdates(doc.guid, [
{ docId: isRoot ? undefined : doc.guid, data: encodeStateAsUpdate(doc) },
+21 -2
View File
@@ -1,6 +1,7 @@
import path from 'node:path';
import { ValidationResult } from '@affine/native';
import { WorkspaceVersion } from '@toeverything/infra/blocksuite';
import type {
FakeDialogResult,
LoadDBFileResult,
@@ -14,7 +15,7 @@ import { nanoid } from 'nanoid';
import { ensureSQLiteDB } from '../db/ensure-db';
import {
copyToTemp,
migrateToLatestDatabase,
migrateToLatest,
migrateToSubdocAndReplaceDatabase,
} from '../db/migration';
import type { WorkspaceSQLiteDB } from '../db/workspace-db-adapter';
@@ -204,7 +205,7 @@ export async function loadDBFile(): Promise<LoadDBFileResult> {
if (validationResult === ValidationResult.MissingVersionColumn) {
try {
const tmpDBPath = await copyToTemp(originalPath);
await migrateToLatestDatabase(tmpDBPath);
await migrateToLatest(tmpDBPath, WorkspaceVersion.SubDoc);
originalPath = tmpDBPath;
} catch (error) {
logger.warn(
@@ -223,6 +224,24 @@ export async function loadDBFile(): Promise<LoadDBFileResult> {
return { error: 'DB_FILE_INVALID' }; // invalid db file
}
const db = new SqliteConnection(originalPath);
try {
await db.connect();
if ((await db.getMaxVersion()) === WorkspaceVersion.DatabaseV3) {
const tmpDBPath = await copyToTemp(originalPath);
await migrateToLatest(tmpDBPath, WorkspaceVersion.SubDoc);
originalPath = tmpDBPath;
}
} catch (error) {
logger.warn(
`loadDBFile, migration version column failed: ${originalPath}`,
error
);
return { error: 'DB_FILE_MIGRATION_FAILED' };
} finally {
await db.close();
}
// copy the db file to a new workspace id
const workspaceId = nanoid(10);
const internalFilePath = await getWorkspaceDBPath(workspaceId);
+6 -6
View File
@@ -18,13 +18,13 @@
"@affine/jotai": "workspace:*",
"@affine/templates": "workspace:*",
"@affine/workspace": "workspace:*",
"@blocksuite/block-std": "0.0.0-20230829150056-df43987c-nightly",
"@blocksuite/blocks": "0.0.0-20230829150056-df43987c-nightly",
"@blocksuite/editor": "0.0.0-20230829150056-df43987c-nightly",
"@blocksuite/global": "0.0.0-20230829150056-df43987c-nightly",
"@blocksuite/block-std": "0.0.0-20230905170607-94acf22c-nightly",
"@blocksuite/blocks": "0.0.0-20230905170607-94acf22c-nightly",
"@blocksuite/editor": "0.0.0-20230905170607-94acf22c-nightly",
"@blocksuite/global": "0.0.0-20230905170607-94acf22c-nightly",
"@blocksuite/icons": "^2.1.32",
"@blocksuite/lit": "0.0.0-20230829150056-df43987c-nightly",
"@blocksuite/store": "0.0.0-20230829150056-df43987c-nightly",
"@blocksuite/lit": "0.0.0-20230905170607-94acf22c-nightly",
"@blocksuite/store": "0.0.0-20230905170607-94acf22c-nightly",
"@toeverything/hooks": "workspace:*",
"@toeverything/y-indexeddb": "workspace:*",
"react": "^18.2.0",
+6 -6
View File
@@ -31,13 +31,13 @@
"wait-on": "^7.0.1"
},
"devDependencies": {
"@blocksuite/block-std": "0.0.0-20230829150056-df43987c-nightly",
"@blocksuite/blocks": "0.0.0-20230829150056-df43987c-nightly",
"@blocksuite/editor": "0.0.0-20230829150056-df43987c-nightly",
"@blocksuite/global": "0.0.0-20230829150056-df43987c-nightly",
"@blocksuite/block-std": "0.0.0-20230905170607-94acf22c-nightly",
"@blocksuite/blocks": "0.0.0-20230905170607-94acf22c-nightly",
"@blocksuite/editor": "0.0.0-20230905170607-94acf22c-nightly",
"@blocksuite/global": "0.0.0-20230905170607-94acf22c-nightly",
"@blocksuite/icons": "^2.1.32",
"@blocksuite/lit": "0.0.0-20230829150056-df43987c-nightly",
"@blocksuite/store": "0.0.0-20230829150056-df43987c-nightly",
"@blocksuite/lit": "0.0.0-20230905170607-94acf22c-nightly",
"@blocksuite/store": "0.0.0-20230905170607-94acf22c-nightly",
"@tomfreudenberg/next-auth-mock": "^0.5.6",
"chromatic": "^6.24.1",
"react": "18.2.0",
+5 -5
View File
@@ -52,12 +52,12 @@
"rxjs": "^7.8.1"
},
"devDependencies": {
"@blocksuite/blocks": "0.0.0-20230829150056-df43987c-nightly",
"@blocksuite/editor": "0.0.0-20230829150056-df43987c-nightly",
"@blocksuite/global": "0.0.0-20230829150056-df43987c-nightly",
"@blocksuite/blocks": "0.0.0-20230905170607-94acf22c-nightly",
"@blocksuite/editor": "0.0.0-20230905170607-94acf22c-nightly",
"@blocksuite/global": "0.0.0-20230905170607-94acf22c-nightly",
"@blocksuite/icons": "^2.1.32",
"@blocksuite/lit": "0.0.0-20230829150056-df43987c-nightly",
"@blocksuite/store": "0.0.0-20230829150056-df43987c-nightly",
"@blocksuite/lit": "0.0.0-20230905170607-94acf22c-nightly",
"@blocksuite/store": "0.0.0-20230905170607-94acf22c-nightly",
"@types/react": "^18.2.21",
"@types/react-datepicker": "^4.15.0",
"@types/react-dnd": "^3.0.2",
@@ -1,12 +1,10 @@
import { editorContainerModuleAtom } from '@affine/jotai';
import type { BlockHub } from '@blocksuite/blocks';
import type { EditorContainer } from '@blocksuite/editor';
import { EditorContainer } from '@blocksuite/editor';
import { assertExists } from '@blocksuite/global/utils';
import type { LitBlockSpec } from '@blocksuite/lit';
import type { Page } from '@blocksuite/store';
import { Skeleton } from '@mui/material';
import { use } from 'foxact/use';
import { useAtomValue } from 'jotai';
import type { CSSProperties, ReactElement } from 'react';
import { memo, Suspense, useCallback, useEffect, useRef } from 'react';
import type { FallbackProps } from 'react-error-boundary';
@@ -45,14 +43,11 @@ const BlockSuiteEditorImpl = (props: EditorProps): ReactElement => {
if (!page.loaded) {
use(page.waitForLoaded());
}
const JotaiEditorContainer = useAtomValue(
editorContainerModuleAtom
) as typeof EditorContainer;
assertExists(page, 'page should not be null');
const editorRef = useRef<EditorContainer | null>(null);
const blockHubRef = useRef<BlockHub | null>(null);
if (editorRef.current === null) {
editorRef.current = new JotaiEditorContainer();
editorRef.current = new EditorContainer();
editorRef.current.autofocus = true;
globalThis.currentEditor = editorRef.current;
+1 -1
View File
@@ -5,7 +5,7 @@
"main": "./src/index.ts",
"module": "./src/index.ts",
"devDependencies": {
"@blocksuite/global": "0.0.0-20230829150056-df43987c-nightly",
"@blocksuite/global": "0.0.0-20230905170607-94acf22c-nightly",
"react": "18.2.0",
"react-dom": "18.2.0",
"zod": "^3.22.2"
+6 -6
View File
@@ -12,12 +12,12 @@
"devDependencies": {
"@affine/env": "workspace:*",
"@affine/y-provider": "workspace:*",
"@blocksuite/block-std": "0.0.0-20230829150056-df43987c-nightly",
"@blocksuite/blocks": "0.0.0-20230829150056-df43987c-nightly",
"@blocksuite/editor": "0.0.0-20230829150056-df43987c-nightly",
"@blocksuite/global": "0.0.0-20230829150056-df43987c-nightly",
"@blocksuite/lit": "0.0.0-20230829150056-df43987c-nightly",
"@blocksuite/store": "0.0.0-20230829150056-df43987c-nightly",
"@blocksuite/block-std": "0.0.0-20230905170607-94acf22c-nightly",
"@blocksuite/blocks": "0.0.0-20230905170607-94acf22c-nightly",
"@blocksuite/editor": "0.0.0-20230905170607-94acf22c-nightly",
"@blocksuite/global": "0.0.0-20230905170607-94acf22c-nightly",
"@blocksuite/lit": "0.0.0-20230905170607-94acf22c-nightly",
"@blocksuite/store": "0.0.0-20230905170607-94acf22c-nightly",
"@types/lodash.debounce": "^4.0.7"
},
"peerDependencies": {
+5 -5
View File
@@ -50,15 +50,15 @@
},
"dependencies": {
"@affine/sdk": "workspace:*",
"@blocksuite/blocks": "0.0.0-20230829150056-df43987c-nightly",
"@blocksuite/global": "0.0.0-20230829150056-df43987c-nightly",
"@blocksuite/store": "0.0.0-20230829150056-df43987c-nightly",
"@blocksuite/blocks": "0.0.0-20230905170607-94acf22c-nightly",
"@blocksuite/global": "0.0.0-20230905170607-94acf22c-nightly",
"@blocksuite/store": "0.0.0-20230905170607-94acf22c-nightly",
"jotai": "^2.4.1",
"zod": "^3.22.2"
},
"devDependencies": {
"@blocksuite/editor": "0.0.0-20230829150056-df43987c-nightly",
"@blocksuite/lit": "0.0.0-20230829150056-df43987c-nightly",
"@blocksuite/editor": "0.0.0-20230905170607-94acf22c-nightly",
"@blocksuite/lit": "0.0.0-20230905170607-94acf22c-nightly",
"async-call-rpc": "^6.3.1",
"electron": "link:../../apps/electron/node_modules/electron",
"react": "^18.2.0",
+4 -17
View File
@@ -1,11 +1,11 @@
import type { Workspace } from '@blocksuite/store';
import { type PassiveDocProvider } from '@blocksuite/store';
import { useAtomValue } from 'jotai/react';
import { useEffect } from 'react';
import {
disablePassiveProviders,
enablePassiveProviders,
getActiveBlockSuiteWorkspaceAtom,
workspacePassiveEffectWeakMap,
} from './workspace.js';
export function useStaticBlockSuiteWorkspace(id: string): Workspace {
@@ -14,22 +14,9 @@ export function useStaticBlockSuiteWorkspace(id: string): Workspace {
export function usePassiveWorkspaceEffect(workspace: Workspace) {
useEffect(() => {
if (workspacePassiveEffectWeakMap.get(workspace) === true) {
return;
}
const providers = workspace.providers.filter(
(provider): provider is PassiveDocProvider =>
'passive' in provider && provider.passive === true
);
providers.forEach(provider => {
provider.connect();
});
workspacePassiveEffectWeakMap.set(workspace, true);
enablePassiveProviders(workspace);
return () => {
providers.forEach(provider => {
provider.disconnect();
});
workspacePassiveEffectWeakMap.delete(workspace);
disablePassiveProviders(workspace);
};
}, [workspace]);
}
+35 -6
View File
@@ -1,4 +1,5 @@
import type { ActiveDocProvider, Workspace } from '@blocksuite/store';
import type { PassiveDocProvider } from '@blocksuite/store';
import type { Atom } from 'jotai/vanilla';
import { atom } from 'jotai/vanilla';
@@ -8,16 +9,44 @@ import { atom } from 'jotai/vanilla';
*/
export const INTERNAL_BLOCKSUITE_HASH_MAP = new Map<string, Workspace>([]);
const workspacePassiveAtomWeakMap = new WeakMap<
const workspaceActiveAtomWeakMap = new WeakMap<
Workspace,
Atom<Promise<Workspace>>
>();
// Whether the workspace is active to use
export const workspaceActiveWeakMap = new WeakMap<Workspace, boolean>();
const workspaceActiveWeakMap = new WeakMap<Workspace, boolean>();
// Whether the workspace has been enabled the passive effect (background)
export const workspacePassiveEffectWeakMap = new WeakMap<Workspace, boolean>();
const workspacePassiveEffectWeakMap = new WeakMap<Workspace, boolean>();
export function enablePassiveProviders(workspace: Workspace) {
if (workspacePassiveEffectWeakMap.get(workspace) === true) {
return;
}
const providers = workspace.providers.filter(
(provider): provider is PassiveDocProvider =>
'passive' in provider && provider.passive === true
);
providers.forEach(provider => {
provider.connect();
});
workspacePassiveEffectWeakMap.set(workspace, true);
}
export function disablePassiveProviders(workspace: Workspace) {
if (workspacePassiveEffectWeakMap.get(workspace) !== true) {
return;
}
const providers = workspace.providers.filter(
(provider): provider is PassiveDocProvider =>
'passive' in provider && provider.passive === true
);
providers.forEach(provider => {
provider.disconnect();
});
workspacePassiveEffectWeakMap.delete(workspace);
}
export async function waitForWorkspace(workspace: Workspace) {
if (workspaceActiveWeakMap.get(workspace) !== true) {
@@ -48,12 +77,12 @@ export function getActiveBlockSuiteWorkspaceAtom(
throw new Error('Workspace not found');
}
const workspace = INTERNAL_BLOCKSUITE_HASH_MAP.get(id) as Workspace;
if (!workspacePassiveAtomWeakMap.has(workspace)) {
if (!workspaceActiveAtomWeakMap.has(workspace)) {
const baseAtom = atom(async () => {
await waitForWorkspace(workspace);
return workspace;
});
workspacePassiveAtomWeakMap.set(workspace, baseAtom);
workspaceActiveAtomWeakMap.set(workspace, baseAtom);
}
return workspacePassiveAtomWeakMap.get(workspace) as Atom<Promise<Workspace>>;
return workspaceActiveAtomWeakMap.get(workspace) as Atom<Promise<Workspace>>;
}
+60 -38
View File
@@ -1,6 +1,7 @@
import type { Page, PageMeta, Workspace } from '@blocksuite/store';
import { createIndexeddbStorage } from '@blocksuite/store';
import type { createStore, WritableAtom } from 'jotai/vanilla';
import type { Doc } from 'yjs';
import { Array as YArray, Doc as YDoc, Map as YMap } from 'yjs';
export async function initEmptyPage(page: Page, title?: string) {
@@ -24,6 +25,7 @@ export async function buildEmptyBlockSuite(workspace: Workspace) {
export async function buildShowcaseWorkspace(
workspace: Workspace,
options: {
schema: Schema;
atoms: {
pageMode: WritableAtom<
undefined,
@@ -196,7 +198,11 @@ export async function buildShowcaseWorkspace(
await Promise.all(
data.map(async ([id, promise]) => {
const { default: template } = await promise;
await workspace.importPageSnapshot(structuredClone(template), id);
await workspace
.importPageSnapshot(structuredClone(template), id)
.catch(error => {
console.error('error importing page', id, error);
});
workspace.setPageMeta(id, pageMetas[id]);
})
);
@@ -214,6 +220,16 @@ function deserializeXYWH(xywh: string): XYWH {
return JSON.parse(xywh) as XYWH;
}
const getLatestVersions = (schema: Schema): Record<string, number> => {
return [...schema.flavourSchemaMap.entries()].reduce(
(record, [flavour, schema]) => {
record[flavour] = schema.version;
return record;
},
{} as Record<string, number>
);
};
function migrateDatabase(data: YMap<unknown>) {
data.delete('prop:mode');
data.set('prop:views', new YArray());
@@ -450,30 +466,6 @@ export function migrateToSubdoc(oldDoc: YDoc): YDoc {
return newDoc;
}
export async function migrateDatabaseBlockTo3(rootDoc: YDoc, schema: Schema) {
const spaces = rootDoc.getMap('spaces') as YMap<any>;
spaces.forEach(space => {
schema.upgradePage(
{
'affine:note': 1,
'affine:bookmark': 1,
'affine:database': 2,
'affine:divider': 1,
'affine:image': 1,
'affine:list': 1,
'affine:code': 1,
'affine:page': 2,
'affine:paragraph': 1,
'affine:surface': 3,
},
space
);
});
const meta = rootDoc.getMap('meta') as YMap<unknown>;
const versions = meta.get('blockVersions') as YMap<number>;
versions.set('affine:database', 3);
}
export type UpgradeOptions = {
getCurrentRootDoc: () => Promise<YDoc>;
createWorkspace: () => Promise<Workspace>;
@@ -495,20 +487,42 @@ const upgradeV1ToV2 = async (options: UpgradeOptions) => {
return newWorkspace;
};
const upgradeV2ToV3 = async (options: UpgradeOptions): Promise<boolean> => {
/**
* Force upgrade block schema to the latest.
* Don't force to upgrade the pages without the check.
*
* Please note that this function will not upgrade the workspace version.
*
* @returns true if any schema is upgraded.
* @returns false if no schema is upgraded.
*/
export async function forceUpgradePages(
options: Omit<UpgradeOptions, 'createWorkspace'>
): Promise<boolean> {
const rootDoc = await options.getCurrentRootDoc();
const spaces = rootDoc.getMap('spaces') as YMap<any>;
const meta = rootDoc.getMap('meta') as YMap<unknown>;
const versions = meta.get('blockVersions') as YMap<number>;
if ('affine:database' in versions) {
if (versions['affine:database'] === 3) {
return false;
}
} else if (versions.get('affine:database') === 3) {
return false;
}
const schema = options.getSchema();
spaces.forEach(space => {
const oldVersions = versions.toJSON();
spaces.forEach((space: Doc) => {
schema.upgradePage(oldVersions, space);
});
const newVersions = getLatestVersions(schema);
meta.set('blockVersions', new YMap(Object.entries(newVersions)));
return Object.entries(oldVersions).some(
([flavour, version]) => newVersions[flavour] !== version
);
}
// database from 2 to 3
async function upgradeV2ToV3(options: UpgradeOptions): Promise<boolean> {
const rootDoc = await options.getCurrentRootDoc();
const spaces = rootDoc.getMap('spaces') as YMap<any>;
const meta = rootDoc.getMap('meta') as YMap<unknown>;
const versions = meta.get('blockVersions') as YMap<number>;
const schema = options.getSchema();
spaces.forEach((space: Doc) => {
schema.upgradePage(
{
'affine:note': 1,
@@ -526,18 +540,23 @@ const upgradeV2ToV3 = async (options: UpgradeOptions): Promise<boolean> => {
);
});
if ('affine:database' in versions) {
versions['affine:database'] = 3;
meta.set('blockVersions', new YMap(Object.entries(versions)));
meta.set(
'blockVersions',
new YMap(Object.entries(getLatestVersions(schema)))
);
} else {
versions.set('affine:database', 3);
Object.entries(getLatestVersions(schema)).map(([flavour, version]) =>
versions.set(flavour, version)
);
}
return true;
};
}
export enum WorkspaceVersion {
// v1 is treated as undefined
SubDoc = 2,
DatabaseV3 = 3,
Surface = 4,
}
/**
@@ -560,6 +579,9 @@ export async function migrateWorkspace(
}
if (currentVersion === WorkspaceVersion.SubDoc) {
return upgradeV2ToV3(options);
} else if (currentVersion === WorkspaceVersion.DatabaseV3) {
// surface from 3 to 5
return forceUpgradePages(options);
} else {
return false;
}
+6 -6
View File
@@ -6,12 +6,12 @@
"jotai": "^2.4.1"
},
"devDependencies": {
"@blocksuite/block-std": "0.0.0-20230829150056-df43987c-nightly",
"@blocksuite/blocks": "0.0.0-20230829150056-df43987c-nightly",
"@blocksuite/editor": "0.0.0-20230829150056-df43987c-nightly",
"@blocksuite/global": "0.0.0-20230829150056-df43987c-nightly",
"@blocksuite/lit": "0.0.0-20230829150056-df43987c-nightly",
"@blocksuite/store": "0.0.0-20230829150056-df43987c-nightly",
"@blocksuite/block-std": "0.0.0-20230905170607-94acf22c-nightly",
"@blocksuite/blocks": "0.0.0-20230905170607-94acf22c-nightly",
"@blocksuite/editor": "0.0.0-20230905170607-94acf22c-nightly",
"@blocksuite/global": "0.0.0-20230905170607-94acf22c-nightly",
"@blocksuite/lit": "0.0.0-20230905170607-94acf22c-nightly",
"@blocksuite/store": "0.0.0-20230905170607-94acf22c-nightly",
"lottie-web": "^5.12.2"
},
"peerDependencies": {
-10
View File
@@ -1,13 +1,3 @@
import type { EditorContainer } from '@blocksuite/editor';
import { atom } from 'jotai';
export const lottieAtom = atom(import('lottie-web').then(m => m.default));
export const editorContainerModuleAtom = atom<Promise<typeof EditorContainer>>(
typeof window === 'undefined'
? async () =>
import('@blocksuite/editor').then(module => module.EditorContainer)
: (import('@blocksuite/editor').then(
module => module.EditorContainer
) as any)
);
+1
View File
@@ -78,6 +78,7 @@ export class SqliteConnection {
): Promise<void>;
initVersion(): Promise<void>;
setVersion(version: number): Promise<void>;
getMaxVersion(): Promise<number>;
close(): Promise<void>;
get isClose(): boolean;
static validate(path: string): Promise<ValidationResult>;
+12 -1
View File
@@ -8,7 +8,7 @@ use sqlx::{
};
// latest version
const LATEST_VERSION: i32 = 3;
const LATEST_VERSION: i32 = 4;
#[napi(object)]
pub struct BlobRow {
@@ -265,6 +265,17 @@ impl SqliteConnection {
Ok(())
}
#[napi]
pub async fn get_max_version(&self) -> napi::Result<i32> {
// 4 is the current version
let version = sqlx::query!("SELECT COALESCE(MAX(version), 4) AS max_version FROM version_info")
.fetch_one(&self.pool)
.await
.map_err(anyhow::Error::from)?
.max_version;
Ok(version)
}
#[napi]
pub async fn close(&self) {
self.pool.close().await;
+3 -3
View File
@@ -22,9 +22,9 @@
"dist"
],
"dependencies": {
"@blocksuite/blocks": "0.0.0-20230829150056-df43987c-nightly",
"@blocksuite/global": "0.0.0-20230829150056-df43987c-nightly",
"@blocksuite/store": "0.0.0-20230829150056-df43987c-nightly",
"@blocksuite/blocks": "0.0.0-20230905170607-94acf22c-nightly",
"@blocksuite/global": "0.0.0-20230905170607-94acf22c-nightly",
"@blocksuite/store": "0.0.0-20230905170607-94acf22c-nightly",
"jotai": "^2.4.1",
"zod": "^3.22.2"
},
@@ -14,7 +14,10 @@
"sys:id": "XSMCxudQf4",
"sys:flavour": "affine:surface",
"sys:children": [],
"prop:elements": {}
"prop:elements": {
"type": "$blocksuite:internal:native$",
"value": {}
}
},
"2xxenQgE1-": {
"sys:id": "2xxenQgE1-",
@@ -14,7 +14,10 @@
"sys:id": "_07_dOaECY",
"sys:flavour": "affine:surface",
"sys:children": [],
"prop:elements": {}
"prop:elements": {
"type": "$blocksuite:internal:native$",
"value": {}
}
},
"0n7YghSHPc": {
"sys:id": "0n7YghSHPc",
+4 -1
View File
@@ -14,7 +14,10 @@
"sys:id": "f7o2Osxfa_",
"sys:flavour": "affine:surface",
"sys:children": [],
"prop:elements": {}
"prop:elements": {
"type": "$blocksuite:internal:native$",
"value": {}
}
},
"NDAzEfCZnv": {
"sys:id": "NDAzEfCZnv",
+4 -1
View File
@@ -14,7 +14,10 @@
"sys:id": "86K_nlhKXG",
"sys:flavour": "affine:surface",
"sys:children": [],
"prop:elements": {}
"prop:elements": {
"type": "$blocksuite:internal:native$",
"value": {}
}
},
"q7fYMX90uJ": {
"sys:id": "q7fYMX90uJ",
+4 -1
View File
@@ -14,7 +14,10 @@
"sys:id": "-SeDPuI6pE",
"sys:flavour": "affine:surface",
"sys:children": [],
"prop:elements": {}
"prop:elements": {
"type": "$blocksuite:internal:native$",
"value": {}
}
},
"gjPKqwOdlZ": {
"sys:id": "gjPKqwOdlZ",
+4 -1
View File
@@ -14,7 +14,10 @@
"sys:id": "f4WAKZ67ki",
"sys:flavour": "affine:surface",
"sys:children": [],
"prop:elements": {}
"prop:elements": {
"type": "$blocksuite:internal:native$",
"value": {}
}
},
"xj7QSmgQgT": {
"sys:id": "xj7QSmgQgT",
@@ -15,45 +15,48 @@
"sys:flavour": "affine:surface",
"sys:children": [],
"prop:elements": {
"aAOeeA4jhz": {
"type": "connector",
"mode": 1,
"strokeWidth": 2,
"stroke": "--affine-palette-line-blue",
"strokeStyle": "solid",
"roughness": 1.4,
"source": {
"id": "f6Owaa00aK",
"position": [0.5, 1]
"type": "$blocksuite:internal:native$",
"value": {
"aAOeeA4jhz": {
"type": "connector",
"mode": 1,
"strokeWidth": 2,
"stroke": "--affine-palette-line-blue",
"strokeStyle": "solid",
"roughness": 1.4,
"source": {
"id": "f6Owaa00aK",
"position": [0.5, 1]
},
"target": {
"id": "W6M-MPQ5-F"
},
"controllers": [],
"id": "aAOeeA4jhz",
"index": "a1",
"seed": 1493853178,
"xywh": "[181.61467354910715,-359.54656036633406,400,379.64]"
},
"target": {
"id": "W6M-MPQ5-F"
},
"controllers": [],
"id": "aAOeeA4jhz",
"index": "a1",
"seed": 1493853178,
"xywh": "[181.61467354910715,-359.54656036633406,400,379.64]"
},
"pMyfZPwXXU": {
"type": "connector",
"mode": 1,
"strokeWidth": 2,
"stroke": "--affine-palette-line-black",
"strokeStyle": "solid",
"roughness": 1.4,
"source": {
"id": "f6Owaa00aK",
"position": [0.5010332476508476, 1]
},
"target": {
"id": "-tH5D5Hf4J"
},
"controllers": [],
"id": "pMyfZPwXXU",
"index": "a2",
"seed": 1151132732,
"xywh": "[581.9546735491072,-359.54656036633406,650.69,379.64]"
"pMyfZPwXXU": {
"type": "connector",
"mode": 1,
"strokeWidth": 2,
"stroke": "--affine-palette-line-black",
"strokeStyle": "solid",
"roughness": 1.4,
"source": {
"id": "f6Owaa00aK",
"position": [0.5010332476508476, 1]
},
"target": {
"id": "-tH5D5Hf4J"
},
"controllers": [],
"id": "pMyfZPwXXU",
"index": "a2",
"seed": 1151132732,
"xywh": "[581.9546735491072,-359.54656036633406,650.69,379.64]"
}
}
}
},
@@ -14,7 +14,10 @@
"sys:id": "9eBKQxt8ax",
"sys:flavour": "affine:surface",
"sys:children": [],
"prop:elements": {}
"prop:elements": {
"type": "$blocksuite:internal:native$",
"value": {}
}
},
"2nHeyqzDMf": {
"sys:id": "2nHeyqzDMf",
File diff suppressed because it is too large Load Diff
@@ -14,7 +14,10 @@
"sys:id": "PCxQvHuwt1",
"sys:flavour": "affine:surface",
"sys:children": [],
"prop:elements": {}
"prop:elements": {
"type": "$blocksuite:internal:native$",
"value": {}
}
},
"PMY4JPuq4o": {
"sys:id": "PMY4JPuq4o",
File diff suppressed because it is too large Load Diff
+108 -105
View File
@@ -28,111 +28,114 @@
"sys:flavour": "affine:surface",
"sys:children": [],
"prop:elements": {
"sw8Uxi4bBo": {
"type": "text",
"xywh": "[-536.8747010075784,-1579.765008069904,1543.7942406924883,394.2045498052795]",
"rotate": 0,
"text": [
{
"insert": "You can switch from edgeless mode to paper mode if you want to add more notes! "
}
],
"color": "--affine-palette-line-navy",
"fontSize": 82.63458496823259,
"fontFamily": "'Kalam', cursive",
"textAlign": "left",
"isBold": false,
"isItalic": false,
"id": "sw8Uxi4bBo",
"index": "b0u",
"seed": 615352575
},
"Tubq5p548e": {
"type": "text",
"xywh": "[-513.3186960556048,-1403.9329998657581,1624.0512882883274,77.08483854034749]",
"rotate": 0,
"text": [
{
"insert": "If you want creat your own template, click + New Page to start your journey! "
}
],
"color": "--affine-palette-line-navy",
"fontSize": 48.17803589166863,
"fontFamily": "'Kalam', cursive",
"textAlign": "left",
"isBold": false,
"isItalic": false,
"id": "Tubq5p548e",
"index": "b0v",
"seed": 1725612619
},
"ieZVmhh5WF": {
"type": "shape",
"xywh": "[-536.8747010075784,-1425.8756349679952,1777.647429124084,120.9701087448215]",
"rotate": 0,
"shapeType": "rect",
"radius": 0.1,
"filled": false,
"fillColor": "--affine-palette-transparent",
"strokeWidth": 4,
"strokeColor": "--affine-palette-line-navy",
"strokeStyle": "solid",
"roughness": 2,
"id": "ieZVmhh5WF",
"index": "b0w",
"seed": 1287209158
},
"yGt4uK3Jrz": {
"type": "frame",
"xywh": "[-559.1114681167911,-596.5645426128128,1121.628897543559,640]",
"title": [
{
"insert": "Start from here"
}
],
"batch": "a0",
"id": "yGt4uK3Jrz",
"index": "a1",
"seed": 1327354607
},
"dPCGvkzOF1": {
"type": "frame",
"xywh": "[-559.1114681167911,289.07749381963725,1075.8482127510565,640]",
"title": [
{
"insert": "Part 1"
}
],
"batch": "a0",
"id": "dPCGvkzOF1",
"index": "a2",
"seed": 122824650
},
"nIZLp-sa3n": {
"type": "frame",
"xywh": "[-559.1114681167911,1174.7195302520875,1130.582694488373,640]",
"title": [
{
"insert": "Part 2"
}
],
"batch": "a0",
"id": "nIZLp-sa3n",
"index": "a3",
"seed": 1488143224
},
"8FjxUtSCG6": {
"type": "frame",
"xywh": "[1019.2666610517662,-621.9153214705414,2150.370188968697,1619.1792632492125]",
"title": [
{
"insert": "Part 3"
}
],
"batch": "a0",
"id": "8FjxUtSCG6",
"index": "a4",
"seed": 219967056
"type": "$blocksuite:internal:native$",
"value": {
"sw8Uxi4bBo": {
"type": "text",
"xywh": "[-536.8747010075784,-1579.765008069904,1543.7942406924883,394.2045498052795]",
"rotate": 0,
"text": [
{
"insert": "You can switch from edgeless mode to paper mode if you want to add more notes! "
}
],
"color": "--affine-palette-line-navy",
"fontSize": 82.63458496823259,
"fontFamily": "'Kalam', cursive",
"textAlign": "left",
"isBold": false,
"isItalic": false,
"id": "sw8Uxi4bBo",
"index": "b0u",
"seed": 615352575
},
"Tubq5p548e": {
"type": "text",
"xywh": "[-513.3186960556048,-1403.9329998657581,1624.0512882883274,77.08483854034749]",
"rotate": 0,
"text": [
{
"insert": "If you want creat your own template, click + New Page to start your journey! "
}
],
"color": "--affine-palette-line-navy",
"fontSize": 48.17803589166863,
"fontFamily": "'Kalam', cursive",
"textAlign": "left",
"isBold": false,
"isItalic": false,
"id": "Tubq5p548e",
"index": "b0v",
"seed": 1725612619
},
"ieZVmhh5WF": {
"type": "shape",
"xywh": "[-536.8747010075784,-1425.8756349679952,1777.647429124084,120.9701087448215]",
"rotate": 0,
"shapeType": "rect",
"radius": 0.1,
"filled": false,
"fillColor": "--affine-palette-transparent",
"strokeWidth": 4,
"strokeColor": "--affine-palette-line-navy",
"strokeStyle": "solid",
"roughness": 2,
"id": "ieZVmhh5WF",
"index": "b0w",
"seed": 1287209158
},
"yGt4uK3Jrz": {
"type": "frame",
"xywh": "[-559.1114681167911,-596.5645426128128,1121.628897543559,640]",
"title": [
{
"insert": "Start from here"
}
],
"batch": "a0",
"id": "yGt4uK3Jrz",
"index": "a1",
"seed": 1327354607
},
"dPCGvkzOF1": {
"type": "frame",
"xywh": "[-559.1114681167911,289.07749381963725,1075.8482127510565,640]",
"title": [
{
"insert": "Part 1"
}
],
"batch": "a0",
"id": "dPCGvkzOF1",
"index": "a2",
"seed": 122824650
},
"nIZLp-sa3n": {
"type": "frame",
"xywh": "[-559.1114681167911,1174.7195302520875,1130.582694488373,640]",
"title": [
{
"insert": "Part 2"
}
],
"batch": "a0",
"id": "nIZLp-sa3n",
"index": "a3",
"seed": 1488143224
},
"8FjxUtSCG6": {
"type": "frame",
"xywh": "[1019.2666610517662,-621.9153214705414,2150.370188968697,1619.1792632492125]",
"title": [
{
"insert": "Part 3"
}
],
"batch": "a0",
"id": "8FjxUtSCG6",
"index": "a4",
"seed": 219967056
}
}
}
},
+4 -1
View File
@@ -14,7 +14,10 @@
"sys:id": "yC-F6Rj9bA",
"sys:flavour": "affine:surface",
"sys:children": [],
"prop:elements": {}
"prop:elements": {
"type": "$blocksuite:internal:native$",
"value": {}
}
},
"pk_Cjkpyd4": {
"sys:id": "pk_Cjkpyd4",
+2 -3
View File
@@ -7,9 +7,8 @@
"./type": "./src/type.ts",
"./migration": "./src/migration/index.ts",
"./local/crud": "./src/local/crud.ts",
"./affine/crud": "./src/affine/crud.ts",
"./affine/gql": "./src/affine/gql.ts",
"./affine/sync": "./src/affine/sync.ts",
"./affine": "./src/affine/index.ts",
"./affine/*": "./src/affine/*.ts",
"./providers": "./src/providers/index.ts"
},
"peerDependencies": {
+21
View File
@@ -1,3 +1,4 @@
import { DebugLogger } from '@affine/debug';
import type { DatasourceDocAdapter } from '@affine/y-provider';
import type { Socket } from 'socket.io-client';
import { Manager } from 'socket.io-client';
@@ -15,6 +16,7 @@ import {
} from './utils';
let ioManager: Manager | null = null;
// use lazy initialization to avoid global side effect
function getIoManager(): Manager {
if (ioManager) {
@@ -27,6 +29,8 @@ function getIoManager(): Manager {
return ioManager;
}
const logger = new DebugLogger('affine:sync');
export const createAffineDataSource = (
id: string,
rootDoc: Doc,
@@ -36,6 +40,7 @@ export const createAffineDataSource = (
console.warn('important!! please use doc.guid as roomName');
}
logger.debug('createAffineDataSource', id, rootDoc.guid, awareness);
const socket = getIoManager().socket('/');
return {
@@ -48,6 +53,11 @@ export const createAffineDataSource = (
: undefined;
return new Promise((resolve, reject) => {
logger.debug('doc-load', {
workspaceId: rootDoc.guid,
guid,
stateVector,
});
socket.emit(
'doc-load',
{
@@ -56,6 +66,12 @@ export const createAffineDataSource = (
stateVector,
},
(docState: Error | { missing: string; state: string } | null) => {
logger.debug('doc-load callback', {
workspaceId: rootDoc.guid,
guid,
stateVector,
docState,
});
if (docState instanceof Error) {
reject(docState);
return;
@@ -76,6 +92,11 @@ export const createAffineDataSource = (
});
},
sendDocUpdate: async (guid: string, update: Uint8Array) => {
logger.debug('client-update', {
workspaceId: rootDoc.guid,
guid,
update,
});
socket.emit('client-update', {
workspaceId: rootDoc.guid,
guid,
+2 -2
View File
@@ -38,8 +38,8 @@
},
"devDependencies": {
"@affine/y-provider": "workspace:*",
"@blocksuite/blocks": "0.0.0-20230829150056-df43987c-nightly",
"@blocksuite/store": "0.0.0-20230829150056-df43987c-nightly",
"@blocksuite/blocks": "0.0.0-20230905170607-94acf22c-nightly",
"@blocksuite/store": "0.0.0-20230905170607-94acf22c-nightly",
"vite": "^4.4.9",
"vite-plugin-dts": "3.5.3",
"y-indexeddb": "^9.0.11"
+1 -1
View File
@@ -9,7 +9,7 @@
".": "./src/index.ts"
},
"devDependencies": {
"@blocksuite/store": "0.0.0-20230829150056-df43987c-nightly"
"@blocksuite/store": "0.0.0-20230905170607-94acf22c-nightly"
},
"peerDependencies": {
"yjs": "^13.5.51"
+70 -1
View File
@@ -1,15 +1,27 @@
import { readFile } from 'node:fs/promises';
import { resolve } from 'node:path';
import { test } from '@affine-test/kit/playwright';
import {
createRandomUser,
deleteUser,
enableCloudWorkspace,
getLoginCookie,
loginUser,
runPrisma,
} from '@affine-test/kit/utils/cloud';
import { waitForEditorLoad } from '@affine-test/kit/utils/page-logic';
import { clickEdgelessModeButton } from '@affine-test/kit/utils/editor';
import { coreUrl } from '@affine-test/kit/utils/load-page';
import {
clickNewPageButton,
waitForEditorLoad,
} from '@affine-test/kit/utils/page-logic';
import { clickSideBarSettingButton } from '@affine-test/kit/utils/sidebar';
import { createLocalWorkspace } from '@affine-test/kit/utils/workspace';
import { expect } from '@playwright/test';
let user: {
id: string;
name: string;
email: string;
password: string;
@@ -40,6 +52,63 @@ test.afterEach(async () => {
});
test.describe('basic', () => {
test('migration', async ({ page, browser }) => {
let workspaceId: string;
{
// create the old cloud workspace in another browser
const context = await browser.newContext();
const page = await context.newPage();
await loginUser(page, user.email);
await page.reload();
await createLocalWorkspace(
{
name: 'test',
},
page
);
await enableCloudWorkspace(page);
await clickNewPageButton(page);
await waitForEditorLoad(page);
// http://localhost:8080/workspace/2bc0b6c8-f68d-4dd3-98a8-be746754f9e1/xxx
workspaceId = page.url().split('/')[4];
await runPrisma(async client => {
const sqls = (
await readFile(
resolve(__dirname, 'fixtures', '0.9.0-canary.9-snapshots.sql'),
'utf-8'
)
)
.replaceAll('2bc0b6c8-f68d-4dd3-98a8-be746754f9e1', workspaceId)
.split('\n');
await client.snapshot.deleteMany({
where: {
workspaceId,
},
});
for (const sql of sqls) {
await client.$executeRawUnsafe(sql);
}
});
await page.close();
}
await page.reload();
await page.waitForTimeout(1000);
await page.goto(`${coreUrl}/workspace/${workspaceId}/all`);
await page.getByTestId('upgrade-workspace').click();
await expect(page.getByText('Done, please refresh the page.')).toBeVisible({
timeout: 60000,
});
await page.goto(
`${coreUrl}/workspace/${workspaceId}/gc5FeppNDv-hello-world`
);
await waitForEditorLoad(page);
await clickEdgelessModeButton(page);
await expect(page.locator('affine-edgeless-page')).toBeVisible({
timeout: 1000,
});
});
test('can see and change email and password in setting panel', async ({
page,
}) => {
File diff suppressed because one or more lines are too long
@@ -10,10 +10,10 @@
"devDependencies": {
"@affine-test/fixtures": "workspace:*",
"@affine-test/kit": "workspace:*",
"@blocksuite/block-std": "0.0.0-20230829150056-df43987c-nightly",
"@blocksuite/blocks": "0.0.0-20230829150056-df43987c-nightly",
"@blocksuite/global": "0.0.0-20230829150056-df43987c-nightly",
"@blocksuite/store": "0.0.0-20230829150056-df43987c-nightly",
"@blocksuite/block-std": "0.0.0-20230905170607-94acf22c-nightly",
"@blocksuite/blocks": "0.0.0-20230905170607-94acf22c-nightly",
"@blocksuite/global": "0.0.0-20230905170607-94acf22c-nightly",
"@blocksuite/store": "0.0.0-20230905170607-94acf22c-nightly",
"@playwright/test": "^1.37.1",
"express": "^4.18.2",
"http-proxy-middleware": "^3.0.0-beta.1",
@@ -32,17 +32,17 @@ test('database migration', async ({ page, context }) => {
await page.keyboard.press('a', { delay: 50 });
await page.keyboard.press('Enter', { delay: 50 });
const url = page.url();
await switchToNext();
await page.waitForTimeout(1000);
await page.goto('http://localhost:8081/');
await page.click('text=hello');
await page.goto(url);
await waitForEditorLoad(page);
// check page mode is correct
expect(await page.locator('v-line').nth(0).textContent()).toBe('hello');
expect(await page.locator('affine-database').isVisible()).toBe(true);
// check edgeless mode is correct
await page.getByTestId('switch-edgeless-mode-button').click();
await clickEdgelessModeButton(page);
await page.waitForTimeout(200);
expect(await page.locator('affine-database').isVisible()).toBe(true);
@@ -9,10 +9,10 @@
"devDependencies": {
"@affine-test/fixtures": "workspace:*",
"@affine-test/kit": "workspace:*",
"@blocksuite/block-std": "0.0.0-20230829150056-df43987c-nightly",
"@blocksuite/blocks": "0.0.0-20230829150056-df43987c-nightly",
"@blocksuite/global": "0.0.0-20230829150056-df43987c-nightly",
"@blocksuite/store": "0.0.0-20230829150056-df43987c-nightly",
"@blocksuite/block-std": "0.0.0-20230905170607-94acf22c-nightly",
"@blocksuite/blocks": "0.0.0-20230905170607-94acf22c-nightly",
"@blocksuite/global": "0.0.0-20230905170607-94acf22c-nightly",
"@blocksuite/store": "0.0.0-20230905170607-94acf22c-nightly",
"@playwright/test": "^1.37.1",
"express": "^4.18.2",
"http-proxy-middleware": "^3.0.0-beta.1",
+3
View File
@@ -0,0 +1,3 @@
static
fixtures/*.ydoc
test-results
+7
View File
@@ -0,0 +1,7 @@
# AFFiNE Legacy 0.8.3
> This package is static output of AFFiNE 0.8.3
>
> **This package is for debug only**.
>
> DO NOT MODIFY `affine-core.zip`
Binary file not shown.
@@ -0,0 +1,45 @@
import { resolve } from 'node:path';
import { clickEdgelessModeButton } from '@affine-test/kit/utils/editor';
import {
getBlockSuiteEditorTitle,
waitForEditorLoad,
} from '@affine-test/kit/utils/page-logic';
import {
check8080Available,
setupProxyServer,
} from '@affine-test/kit/utils/proxy';
import { test } from '@playwright/test';
const { switchToNext } = setupProxyServer(
test,
resolve(__dirname, '..', 'static')
);
test('surface migration', async ({ page, context }) => {
await check8080Available(context);
await page.goto('http://localhost:8081/');
await page.waitForSelector('v-line', {
timeout: 10000,
});
await page.getByTestId('new-page-button').click();
const title = getBlockSuiteEditorTitle(page);
await title.type('hello');
await page.keyboard.press('Enter', { delay: 50 });
await page.keyboard.type('world', {
delay: 50,
});
await page.getByTestId('switch-edgeless-mode-button').click({
delay: 50,
});
const url = page.url();
await switchToNext();
await page.waitForTimeout(1000);
await page.goto(url);
await waitForEditorLoad(page);
// check edgeless mode is correct
await clickEdgelessModeButton(page);
await page.waitForTimeout(200);
});
+22
View File
@@ -0,0 +1,22 @@
{
"name": "@affine-legacy/0.8.3",
"description": "AFFiNE 0.8.3 static output",
"scripts": {
"unzip": "unzip affine-core -d static",
"start": "yarn exec serve -s static -l 8082",
"e2e": "yarn playwright test"
},
"devDependencies": {
"@affine-test/fixtures": "workspace:*",
"@affine-test/kit": "workspace:*",
"@blocksuite/block-std": "0.0.0-20230905170607-94acf22c-nightly",
"@blocksuite/blocks": "0.0.0-20230905170607-94acf22c-nightly",
"@blocksuite/global": "0.0.0-20230905170607-94acf22c-nightly",
"@blocksuite/store": "0.0.0-20230905170607-94acf22c-nightly",
"@playwright/test": "^1.37.1",
"express": "^4.18.2",
"http-proxy-middleware": "^3.0.0-beta.1",
"serve": "^14.2.1"
},
"version": "0.9.0-canary.7"
}
@@ -0,0 +1,45 @@
import type {
PlaywrightTestConfig,
PlaywrightWorkerOptions,
} from '@playwright/test';
const config: PlaywrightTestConfig = {
testDir: './e2e',
fullyParallel: true,
timeout: process.env.CI ? 50_000 : 30_000,
use: {
baseURL: 'http://localhost:8081/',
browserName:
(process.env.BROWSER as PlaywrightWorkerOptions['browserName']) ??
'chromium',
permissions: ['clipboard-read', 'clipboard-write'],
viewport: { width: 1440, height: 800 },
actionTimeout: 5 * 1000,
locale: 'en-US',
trace: 'on-first-retry',
video: 'on-first-retry',
},
forbidOnly: !!process.env.CI,
workers: 4,
retries: 1,
reporter: process.env.CI ? 'github' : 'list',
webServer: [
// Intentionally not building the web, reminds you to run it by yourself.
{
command: 'yarn -T run start:web-static',
port: 8080,
timeout: 120 * 1000,
reuseExistingServer: !process.env.CI,
env: {
COVERAGE: process.env.COVERAGE || 'false',
},
},
],
};
if (process.env.CI) {
config.retries = 3;
config.workers = '50%';
}
export default config;
+16
View File
@@ -0,0 +1,16 @@
{
"extends": "../../../tsconfig.json",
"compilerOptions": {
"esModuleInterop": true,
"outDir": "lib"
},
"include": ["e2e"],
"references": [
{
"path": "../../fixtures"
},
{
"path": "../../kit"
}
]
}
+3
View File
@@ -181,6 +181,9 @@
},
{
"path": "./tests/affine-legacy/0.8.0-canary.7"
},
{
"path": "./tests/affine-legacy/0.8.3"
}
],
"files": [],
+133 -128
View File
@@ -25,10 +25,10 @@ __metadata:
dependencies:
"@affine-test/fixtures": "workspace:*"
"@affine-test/kit": "workspace:*"
"@blocksuite/block-std": 0.0.0-20230829150056-df43987c-nightly
"@blocksuite/blocks": 0.0.0-20230829150056-df43987c-nightly
"@blocksuite/global": 0.0.0-20230829150056-df43987c-nightly
"@blocksuite/store": 0.0.0-20230829150056-df43987c-nightly
"@blocksuite/block-std": 0.0.0-20230905170607-94acf22c-nightly
"@blocksuite/blocks": 0.0.0-20230905170607-94acf22c-nightly
"@blocksuite/global": 0.0.0-20230905170607-94acf22c-nightly
"@blocksuite/store": 0.0.0-20230905170607-94acf22c-nightly
"@playwright/test": ^1.37.1
express: ^4.18.2
http-proxy-middleware: ^3.0.0-beta.1
@@ -42,10 +42,27 @@ __metadata:
dependencies:
"@affine-test/fixtures": "workspace:*"
"@affine-test/kit": "workspace:*"
"@blocksuite/block-std": 0.0.0-20230829150056-df43987c-nightly
"@blocksuite/blocks": 0.0.0-20230829150056-df43987c-nightly
"@blocksuite/global": 0.0.0-20230829150056-df43987c-nightly
"@blocksuite/store": 0.0.0-20230829150056-df43987c-nightly
"@blocksuite/block-std": 0.0.0-20230905170607-94acf22c-nightly
"@blocksuite/blocks": 0.0.0-20230905170607-94acf22c-nightly
"@blocksuite/global": 0.0.0-20230905170607-94acf22c-nightly
"@blocksuite/store": 0.0.0-20230905170607-94acf22c-nightly
"@playwright/test": ^1.37.1
express: ^4.18.2
http-proxy-middleware: ^3.0.0-beta.1
serve: ^14.2.1
languageName: unknown
linkType: soft
"@affine-legacy/0.8.3@workspace:tests/affine-legacy/0.8.3":
version: 0.0.0-use.local
resolution: "@affine-legacy/0.8.3@workspace:tests/affine-legacy/0.8.3"
dependencies:
"@affine-test/fixtures": "workspace:*"
"@affine-test/kit": "workspace:*"
"@blocksuite/block-std": 0.0.0-20230905170607-94acf22c-nightly
"@blocksuite/blocks": 0.0.0-20230905170607-94acf22c-nightly
"@blocksuite/global": 0.0.0-20230905170607-94acf22c-nightly
"@blocksuite/store": 0.0.0-20230905170607-94acf22c-nightly
"@playwright/test": ^1.37.1
express: ^4.18.2
http-proxy-middleware: ^3.0.0-beta.1
@@ -151,12 +168,12 @@ __metadata:
"@affine/i18n": "workspace:*"
"@affine/jotai": "workspace:*"
"@affine/workspace": "workspace:*"
"@blocksuite/blocks": 0.0.0-20230829150056-df43987c-nightly
"@blocksuite/editor": 0.0.0-20230829150056-df43987c-nightly
"@blocksuite/global": 0.0.0-20230829150056-df43987c-nightly
"@blocksuite/blocks": 0.0.0-20230905170607-94acf22c-nightly
"@blocksuite/editor": 0.0.0-20230905170607-94acf22c-nightly
"@blocksuite/global": 0.0.0-20230905170607-94acf22c-nightly
"@blocksuite/icons": ^2.1.32
"@blocksuite/lit": 0.0.0-20230829150056-df43987c-nightly
"@blocksuite/store": 0.0.0-20230829150056-df43987c-nightly
"@blocksuite/lit": 0.0.0-20230905170607-94acf22c-nightly
"@blocksuite/store": 0.0.0-20230905170607-94acf22c-nightly
"@dnd-kit/core": ^6.0.8
"@dnd-kit/sortable": ^7.0.2
"@emotion/cache": ^11.11.0
@@ -243,13 +260,13 @@ __metadata:
"@affine/templates": "workspace:*"
"@affine/workspace": "workspace:*"
"@aws-sdk/client-s3": 3.400.0
"@blocksuite/block-std": 0.0.0-20230829150056-df43987c-nightly
"@blocksuite/blocks": 0.0.0-20230829150056-df43987c-nightly
"@blocksuite/editor": 0.0.0-20230829150056-df43987c-nightly
"@blocksuite/global": 0.0.0-20230829150056-df43987c-nightly
"@blocksuite/block-std": 0.0.0-20230905170607-94acf22c-nightly
"@blocksuite/blocks": 0.0.0-20230905170607-94acf22c-nightly
"@blocksuite/editor": 0.0.0-20230905170607-94acf22c-nightly
"@blocksuite/global": 0.0.0-20230905170607-94acf22c-nightly
"@blocksuite/icons": ^2.1.32
"@blocksuite/lit": 0.0.0-20230829150056-df43987c-nightly
"@blocksuite/store": 0.0.0-20230829150056-df43987c-nightly
"@blocksuite/lit": 0.0.0-20230905170607-94acf22c-nightly
"@blocksuite/store": 0.0.0-20230905170607-94acf22c-nightly
"@dnd-kit/core": ^6.0.8
"@dnd-kit/sortable": ^7.0.2
"@emotion/cache": ^11.11.0
@@ -326,12 +343,12 @@ __metadata:
resolution: "@affine/docs@workspace:apps/docs"
dependencies:
"@affine/component": "workspace:*"
"@blocksuite/block-std": 0.0.0-20230829150056-df43987c-nightly
"@blocksuite/blocks": 0.0.0-20230829150056-df43987c-nightly
"@blocksuite/editor": 0.0.0-20230829150056-df43987c-nightly
"@blocksuite/global": 0.0.0-20230829150056-df43987c-nightly
"@blocksuite/lit": 0.0.0-20230829150056-df43987c-nightly
"@blocksuite/store": 0.0.0-20230829150056-df43987c-nightly
"@blocksuite/block-std": 0.0.0-20230905170607-94acf22c-nightly
"@blocksuite/blocks": 0.0.0-20230905170607-94acf22c-nightly
"@blocksuite/editor": 0.0.0-20230905170607-94acf22c-nightly
"@blocksuite/global": 0.0.0-20230905170607-94acf22c-nightly
"@blocksuite/lit": 0.0.0-20230905170607-94acf22c-nightly
"@blocksuite/store": 0.0.0-20230905170607-94acf22c-nightly
"@types/react": ^18.2.21
"@types/react-dom": ^18.2.7
"@vanilla-extract/css": ^1.13.0
@@ -356,10 +373,10 @@ __metadata:
"@affine/env": "workspace:*"
"@affine/native": "workspace:*"
"@affine/sdk": "workspace:*"
"@blocksuite/blocks": 0.0.0-20230829150056-df43987c-nightly
"@blocksuite/editor": 0.0.0-20230829150056-df43987c-nightly
"@blocksuite/lit": 0.0.0-20230829150056-df43987c-nightly
"@blocksuite/store": 0.0.0-20230829150056-df43987c-nightly
"@blocksuite/blocks": 0.0.0-20230905170607-94acf22c-nightly
"@blocksuite/editor": 0.0.0-20230905170607-94acf22c-nightly
"@blocksuite/lit": 0.0.0-20230905170607-94acf22c-nightly
"@blocksuite/store": 0.0.0-20230905170607-94acf22c-nightly
"@electron-forge/cli": ^6.4.1
"@electron-forge/core": ^6.4.1
"@electron-forge/core-utils": ^6.4.1
@@ -403,7 +420,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@affine/env@workspace:packages/env"
dependencies:
"@blocksuite/global": 0.0.0-20230829150056-df43987c-nightly
"@blocksuite/global": 0.0.0-20230905170607-94acf22c-nightly
lit: ^2.8.0
react: 18.2.0
react-dom: 18.2.0
@@ -479,12 +496,12 @@ __metadata:
version: 0.0.0-use.local
resolution: "@affine/jotai@workspace:packages/jotai"
dependencies:
"@blocksuite/block-std": 0.0.0-20230829150056-df43987c-nightly
"@blocksuite/blocks": 0.0.0-20230829150056-df43987c-nightly
"@blocksuite/editor": 0.0.0-20230829150056-df43987c-nightly
"@blocksuite/global": 0.0.0-20230829150056-df43987c-nightly
"@blocksuite/lit": 0.0.0-20230829150056-df43987c-nightly
"@blocksuite/store": 0.0.0-20230829150056-df43987c-nightly
"@blocksuite/block-std": 0.0.0-20230905170607-94acf22c-nightly
"@blocksuite/blocks": 0.0.0-20230905170607-94acf22c-nightly
"@blocksuite/editor": 0.0.0-20230905170607-94acf22c-nightly
"@blocksuite/global": 0.0.0-20230905170607-94acf22c-nightly
"@blocksuite/lit": 0.0.0-20230905170607-94acf22c-nightly
"@blocksuite/store": 0.0.0-20230905170607-94acf22c-nightly
jotai: ^2.4.1
lottie-web: ^5.12.2
peerDependencies:
@@ -622,13 +639,13 @@ __metadata:
"@affine/jotai": "workspace:*"
"@affine/templates": "workspace:*"
"@affine/workspace": "workspace:*"
"@blocksuite/block-std": 0.0.0-20230829150056-df43987c-nightly
"@blocksuite/blocks": 0.0.0-20230829150056-df43987c-nightly
"@blocksuite/editor": 0.0.0-20230829150056-df43987c-nightly
"@blocksuite/global": 0.0.0-20230829150056-df43987c-nightly
"@blocksuite/block-std": 0.0.0-20230905170607-94acf22c-nightly
"@blocksuite/blocks": 0.0.0-20230905170607-94acf22c-nightly
"@blocksuite/editor": 0.0.0-20230905170607-94acf22c-nightly
"@blocksuite/global": 0.0.0-20230905170607-94acf22c-nightly
"@blocksuite/icons": ^2.1.32
"@blocksuite/lit": 0.0.0-20230829150056-df43987c-nightly
"@blocksuite/store": 0.0.0-20230829150056-df43987c-nightly
"@blocksuite/lit": 0.0.0-20230905170607-94acf22c-nightly
"@blocksuite/store": 0.0.0-20230905170607-94acf22c-nightly
"@toeverything/hooks": "workspace:*"
"@toeverything/y-indexeddb": "workspace:*"
"@types/react": ^18.2.21
@@ -645,9 +662,9 @@ __metadata:
version: 0.0.0-use.local
resolution: "@affine/sdk@workspace:packages/sdk"
dependencies:
"@blocksuite/blocks": 0.0.0-20230829150056-df43987c-nightly
"@blocksuite/global": 0.0.0-20230829150056-df43987c-nightly
"@blocksuite/store": 0.0.0-20230829150056-df43987c-nightly
"@blocksuite/blocks": 0.0.0-20230905170607-94acf22c-nightly
"@blocksuite/global": 0.0.0-20230905170607-94acf22c-nightly
"@blocksuite/store": 0.0.0-20230905170607-94acf22c-nightly
jotai: ^2.4.1
vite: ^4.4.9
vite-plugin-dts: 3.5.3
@@ -758,13 +775,13 @@ __metadata:
dependencies:
"@affine/component": "workspace:*"
"@affine/i18n": "workspace:*"
"@blocksuite/block-std": 0.0.0-20230829150056-df43987c-nightly
"@blocksuite/blocks": 0.0.0-20230829150056-df43987c-nightly
"@blocksuite/editor": 0.0.0-20230829150056-df43987c-nightly
"@blocksuite/global": 0.0.0-20230829150056-df43987c-nightly
"@blocksuite/block-std": 0.0.0-20230905170607-94acf22c-nightly
"@blocksuite/blocks": 0.0.0-20230905170607-94acf22c-nightly
"@blocksuite/editor": 0.0.0-20230905170607-94acf22c-nightly
"@blocksuite/global": 0.0.0-20230905170607-94acf22c-nightly
"@blocksuite/icons": ^2.1.32
"@blocksuite/lit": 0.0.0-20230829150056-df43987c-nightly
"@blocksuite/store": 0.0.0-20230829150056-df43987c-nightly
"@blocksuite/lit": 0.0.0-20230905170607-94acf22c-nightly
"@blocksuite/store": 0.0.0-20230905170607-94acf22c-nightly
"@storybook/addon-actions": ^7.4.0
"@storybook/addon-essentials": ^7.4.0
"@storybook/addon-interactions": ^7.4.0
@@ -861,7 +878,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@affine/y-provider@workspace:packages/y-provider"
dependencies:
"@blocksuite/store": 0.0.0-20230829150056-df43987c-nightly
"@blocksuite/store": 0.0.0-20230905170607-94acf22c-nightly
peerDependencies:
yjs: ^13.5.51
languageName: unknown
@@ -3451,30 +3468,30 @@ __metadata:
languageName: node
linkType: hard
"@blocksuite/block-std@npm:0.0.0-20230829150056-df43987c-nightly":
version: 0.0.0-20230829150056-df43987c-nightly
resolution: "@blocksuite/block-std@npm:0.0.0-20230829150056-df43987c-nightly"
"@blocksuite/block-std@npm:0.0.0-20230905170607-94acf22c-nightly":
version: 0.0.0-20230905170607-94acf22c-nightly
resolution: "@blocksuite/block-std@npm:0.0.0-20230905170607-94acf22c-nightly"
dependencies:
"@blocksuite/global": 0.0.0-20230829150056-df43987c-nightly
"@blocksuite/global": 0.0.0-20230905170607-94acf22c-nightly
w3c-keyname: ^2.2.8
peerDependencies:
"@blocksuite/store": 0.0.0-20230829150056-df43987c-nightly
checksum: 09793a1fe9fa7a16e6881440a2cda40e1018cd0f0a557b2e7323784424d46b781c1959174294049345eec7e03813cae53f51bc7a653aab56a08ad775145fa7c6
"@blocksuite/store": 0.0.0-20230905170607-94acf22c-nightly
checksum: c9952e051c05bf6d0a08720420bebba01dc189027a4735f31eb5be418e88e3deed63d880dd82483dc60c51d6b269dec0306b80fdd7768b3bd3e30ef8ba01a1a6
languageName: node
linkType: hard
"@blocksuite/blocks@npm:0.0.0-20230829150056-df43987c-nightly":
version: 0.0.0-20230829150056-df43987c-nightly
resolution: "@blocksuite/blocks@npm:0.0.0-20230829150056-df43987c-nightly"
"@blocksuite/blocks@npm:0.0.0-20230905170607-94acf22c-nightly":
version: 0.0.0-20230905170607-94acf22c-nightly
resolution: "@blocksuite/blocks@npm:0.0.0-20230905170607-94acf22c-nightly"
dependencies:
"@blocksuite/global": 0.0.0-20230829150056-df43987c-nightly
"@blocksuite/phasor": 0.0.0-20230829150056-df43987c-nightly
"@blocksuite/virgo": 0.0.0-20230829150056-df43987c-nightly
"@blocksuite/global": 0.0.0-20230905170607-94acf22c-nightly
"@blocksuite/virgo": 0.0.0-20230905170607-94acf22c-nightly
"@floating-ui/dom": ^1.5.1
"@types/webfontloader": ^1.6.35
buffer: ^6.0.3
date-fns: ^2.30.0
file-type: ^16.5.4
fractional-indexing: ^3.2.0
html2canvas: ^1.4.1
jszip: ^3.10.1
lit: ^2.8.0
@@ -3486,33 +3503,34 @@ __metadata:
webfontloader: ^1.6.28
zod: ^3.22.2
peerDependencies:
"@blocksuite/block-std": 0.0.0-20230829150056-df43987c-nightly
"@blocksuite/lit": 0.0.0-20230829150056-df43987c-nightly
"@blocksuite/store": 0.0.0-20230829150056-df43987c-nightly
"@toeverything/theme": ^0.7.13
"@blocksuite/block-std": 0.0.0-20230905170607-94acf22c-nightly
"@blocksuite/lit": 0.0.0-20230905170607-94acf22c-nightly
"@blocksuite/store": 0.0.0-20230905170607-94acf22c-nightly
"@toeverything/theme": ^0.7.15
nanoid: ^4
yjs: ^13
checksum: 1fa3c778013e1f3d6f1ba605cd336ff3f48673d12b0136797348f37a64f83ae97e1bdcd780e55b50d3817f78dc1416a476c43e1f365623284055021744eb6247
checksum: 939a3a50f67c87a1a475cd4d5a88b887ee7f74d79c6e2fd910a7e34dd5c98aab52ecdf851c5819d4b23b42fdaff54e9cd29a4676e4259cfd7d230b88906183d6
languageName: node
linkType: hard
"@blocksuite/editor@npm:0.0.0-20230829150056-df43987c-nightly":
version: 0.0.0-20230829150056-df43987c-nightly
resolution: "@blocksuite/editor@npm:0.0.0-20230829150056-df43987c-nightly"
"@blocksuite/editor@npm:0.0.0-20230905170607-94acf22c-nightly":
version: 0.0.0-20230905170607-94acf22c-nightly
resolution: "@blocksuite/editor@npm:0.0.0-20230905170607-94acf22c-nightly"
dependencies:
"@blocksuite/global": 0.0.0-20230829150056-df43987c-nightly
"@blocksuite/global": 0.0.0-20230905170607-94acf22c-nightly
lit: ^2.8.0
peerDependencies:
"@blocksuite/blocks": 0.0.0-20230829150056-df43987c-nightly
"@blocksuite/lit": 0.0.0-20230829150056-df43987c-nightly
"@blocksuite/store": 0.0.0-20230829150056-df43987c-nightly
"@toeverything/theme": ^0.7.13
checksum: 25fcb690e63ad8982bc030745d431bad84c40e8f19663ce9a066af414f6e68757fdd3db211ff3e3a644007a3d8b0b3e6fa1d6a4d2dec3ccb3fdd0bffba2f9865
"@blocksuite/blocks": 0.0.0-20230905170607-94acf22c-nightly
"@blocksuite/lit": 0.0.0-20230905170607-94acf22c-nightly
"@blocksuite/store": 0.0.0-20230905170607-94acf22c-nightly
"@toeverything/theme": ^0.7.15
checksum: 3ec10f858851854f6750ff9ad4a065da9834597a9e671dbabda6f323baf0b409f8ec33abb44d9eb78a83741a343489fdb400dc51f79947e1effc500a6bb7fa6e
languageName: node
linkType: hard
"@blocksuite/global@npm:0.0.0-20230829150056-df43987c-nightly":
version: 0.0.0-20230829150056-df43987c-nightly
resolution: "@blocksuite/global@npm:0.0.0-20230829150056-df43987c-nightly"
"@blocksuite/global@npm:0.0.0-20230905170607-94acf22c-nightly":
version: 0.0.0-20230905170607-94acf22c-nightly
resolution: "@blocksuite/global@npm:0.0.0-20230905170607-94acf22c-nightly"
dependencies:
ansi-colors: ^4.1.3
zod: ^3.22.2
@@ -3521,7 +3539,7 @@ __metadata:
peerDependenciesMeta:
lit:
optional: true
checksum: 657682a777ddf0b877cab7ed529569e6a1cd219f83e4610fd329b2472d443c2f81fc82928cae6a0e4e3d7d0284d2d07f2334aa4849b61bb865294877b853cc5a
checksum: dc88742b65a0881bab53f03aaf970299edb181f2145e4a6804cba7a757bdd5bfdf8d9c075574bf47939d5f65bd1ce89386095bcd9cf4dd6a9b9865ef2ead0a48
languageName: node
linkType: hard
@@ -3555,44 +3573,31 @@ __metadata:
languageName: node
linkType: hard
"@blocksuite/lit@npm:0.0.0-20230829150056-df43987c-nightly":
version: 0.0.0-20230829150056-df43987c-nightly
resolution: "@blocksuite/lit@npm:0.0.0-20230829150056-df43987c-nightly"
"@blocksuite/lit@npm:0.0.0-20230905170607-94acf22c-nightly":
version: 0.0.0-20230905170607-94acf22c-nightly
resolution: "@blocksuite/lit@npm:0.0.0-20230905170607-94acf22c-nightly"
dependencies:
"@blocksuite/global": 0.0.0-20230829150056-df43987c-nightly
"@blocksuite/virgo": 0.0.0-20230829150056-df43987c-nightly
"@blocksuite/global": 0.0.0-20230905170607-94acf22c-nightly
"@blocksuite/virgo": 0.0.0-20230905170607-94acf22c-nightly
lit: ^2.8.0
peerDependencies:
"@blocksuite/block-std": 0.0.0-20230829150056-df43987c-nightly
"@blocksuite/store": 0.0.0-20230829150056-df43987c-nightly
checksum: 0d6270b8d961288e276a19451aa05f32377943d60f94e0662deb89975dac037d2358beaf89f3a4ea9cd1416def258bb7d6703d70d15771a0a640a92dc85650f1
"@blocksuite/block-std": 0.0.0-20230905170607-94acf22c-nightly
"@blocksuite/store": 0.0.0-20230905170607-94acf22c-nightly
checksum: 9ef7572a8854ee8091dccf7a11a3c7e526ecb68291cac5e13a7255993d643725e1f51c2f9f5488f222d9c0eb5103b12cf87a1f4f4396821034dd335aeb5a73e6
languageName: node
linkType: hard
"@blocksuite/phasor@npm:0.0.0-20230829150056-df43987c-nightly":
version: 0.0.0-20230829150056-df43987c-nightly
resolution: "@blocksuite/phasor@npm:0.0.0-20230829150056-df43987c-nightly"
"@blocksuite/store@npm:0.0.0-20230905170607-94acf22c-nightly":
version: 0.0.0-20230905170607-94acf22c-nightly
resolution: "@blocksuite/store@npm:0.0.0-20230905170607-94acf22c-nightly"
dependencies:
"@blocksuite/global": 0.0.0-20230829150056-df43987c-nightly
fractional-indexing: ^3.2.0
peerDependencies:
nanoid: ^4
yjs: ^13
checksum: e0796643115e1805064ba916b08f466f37afaea3091b02646567c93a1bea0b6b4860fa11ede579ded11f71f92fa3613fd47271be3faf11e43776210005c261e9
languageName: node
linkType: hard
"@blocksuite/store@npm:0.0.0-20230829150056-df43987c-nightly":
version: 0.0.0-20230829150056-df43987c-nightly
resolution: "@blocksuite/store@npm:0.0.0-20230829150056-df43987c-nightly"
dependencies:
"@blocksuite/global": 0.0.0-20230829150056-df43987c-nightly
"@blocksuite/virgo": 0.0.0-20230829150056-df43987c-nightly
"@blocksuite/global": 0.0.0-20230905170607-94acf22c-nightly
"@blocksuite/virgo": 0.0.0-20230905170607-94acf22c-nightly
"@types/flexsearch": ^0.7.3
buffer: ^6.0.3
flexsearch: 0.7.21
idb-keyval: ^6.2.1
ky: ^0.33.3
jszip: ^3.10.1
lib0: ^0.2.83
merge: ^2.1.1
minimatch: ^9.0.3
@@ -3602,20 +3607,20 @@ __metadata:
peerDependencies:
async-call-rpc: ^6
yjs: ^13
checksum: 53879fee28b3bc89bfcd16595d084b43516bedfe548faeeeceb4d0589dda64dceacdd473d29dd87b484755f6fd403e6b79011072b2239bc72315b1bd4ea3d69f
checksum: 8b18eecd727b35edd88fd7331dfc7d7e0b003812f8d69fd8bcbd924bf21ea7be4b45d86446bb0b12364b8d183596d8b8f0c424a44795ec647eaa9b0e886af0f4
languageName: node
linkType: hard
"@blocksuite/virgo@npm:0.0.0-20230829150056-df43987c-nightly":
version: 0.0.0-20230829150056-df43987c-nightly
resolution: "@blocksuite/virgo@npm:0.0.0-20230829150056-df43987c-nightly"
"@blocksuite/virgo@npm:0.0.0-20230905170607-94acf22c-nightly":
version: 0.0.0-20230905170607-94acf22c-nightly
resolution: "@blocksuite/virgo@npm:0.0.0-20230905170607-94acf22c-nightly"
dependencies:
"@blocksuite/global": 0.0.0-20230829150056-df43987c-nightly
"@blocksuite/global": 0.0.0-20230905170607-94acf22c-nightly
zod: ^3.22.2
peerDependencies:
lit: ^2.7
yjs: ^13
checksum: df0511f45df13394d5c1f493409da8000894efd3f7ae30b86579e3b0a1d1904e76fb7012316e9c945aba9e9f1da9432e49503a857cc32fad20a6aca0e2544265
checksum: e4d4266e1f5fb01d64b26f756ec133d8e5d5fd258bce00d7cf0ad2bb4e0e8b00dac00a75ed902f15769538fdd49cc80113f707799f139840d81e5495053cdb1f
languageName: node
linkType: hard
@@ -12493,12 +12498,12 @@ __metadata:
dependencies:
"@affine/env": "workspace:*"
"@affine/y-provider": "workspace:*"
"@blocksuite/block-std": 0.0.0-20230829150056-df43987c-nightly
"@blocksuite/blocks": 0.0.0-20230829150056-df43987c-nightly
"@blocksuite/editor": 0.0.0-20230829150056-df43987c-nightly
"@blocksuite/global": 0.0.0-20230829150056-df43987c-nightly
"@blocksuite/lit": 0.0.0-20230829150056-df43987c-nightly
"@blocksuite/store": 0.0.0-20230829150056-df43987c-nightly
"@blocksuite/block-std": 0.0.0-20230905170607-94acf22c-nightly
"@blocksuite/blocks": 0.0.0-20230905170607-94acf22c-nightly
"@blocksuite/editor": 0.0.0-20230905170607-94acf22c-nightly
"@blocksuite/global": 0.0.0-20230905170607-94acf22c-nightly
"@blocksuite/lit": 0.0.0-20230905170607-94acf22c-nightly
"@blocksuite/store": 0.0.0-20230905170607-94acf22c-nightly
"@types/lodash.debounce": ^4.0.7
foxact: ^0.2.20
lodash.debounce: ^4.0.8
@@ -12535,11 +12540,11 @@ __metadata:
resolution: "@toeverything/infra@workspace:packages/infra"
dependencies:
"@affine/sdk": "workspace:*"
"@blocksuite/blocks": 0.0.0-20230829150056-df43987c-nightly
"@blocksuite/editor": 0.0.0-20230829150056-df43987c-nightly
"@blocksuite/global": 0.0.0-20230829150056-df43987c-nightly
"@blocksuite/lit": 0.0.0-20230829150056-df43987c-nightly
"@blocksuite/store": 0.0.0-20230829150056-df43987c-nightly
"@blocksuite/blocks": 0.0.0-20230905170607-94acf22c-nightly
"@blocksuite/editor": 0.0.0-20230905170607-94acf22c-nightly
"@blocksuite/global": 0.0.0-20230905170607-94acf22c-nightly
"@blocksuite/lit": 0.0.0-20230905170607-94acf22c-nightly
"@blocksuite/store": 0.0.0-20230905170607-94acf22c-nightly
async-call-rpc: ^6.3.1
electron: "link:../../apps/electron/node_modules/electron"
jotai: ^2.4.1
@@ -12586,8 +12591,8 @@ __metadata:
resolution: "@toeverything/y-indexeddb@workspace:packages/y-indexeddb"
dependencies:
"@affine/y-provider": "workspace:*"
"@blocksuite/blocks": 0.0.0-20230829150056-df43987c-nightly
"@blocksuite/store": 0.0.0-20230829150056-df43987c-nightly
"@blocksuite/blocks": 0.0.0-20230905170607-94acf22c-nightly
"@blocksuite/store": 0.0.0-20230905170607-94acf22c-nightly
idb: ^7.1.1
vite: ^4.4.9
vite-plugin-dts: 3.5.3