mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-14 21:27:20 +00:00
chore: bump version (#1404)
This commit is contained in:
@@ -14,11 +14,11 @@
|
||||
"@affine/debug": "workspace:*",
|
||||
"@affine/env": "workspace:*",
|
||||
"@affine/i18n": "workspace:*",
|
||||
"@blocksuite/blocks": "0.5.0-20230307101545-7d5aefc",
|
||||
"@blocksuite/editor": "0.5.0-20230307101545-7d5aefc",
|
||||
"@blocksuite/blocks": "0.5.0-20230308090832-6594d8d",
|
||||
"@blocksuite/editor": "0.5.0-20230308090832-6594d8d",
|
||||
"@blocksuite/icons": "2.0.17",
|
||||
"@blocksuite/react": "0.5.0-20230307101545-7d5aefc",
|
||||
"@blocksuite/store": "0.5.0-20230307101545-7d5aefc",
|
||||
"@blocksuite/react": "0.5.0-20230308090832-6594d8d",
|
||||
"@blocksuite/store": "0.5.0-20230308090832-6594d8d",
|
||||
"@emotion/cache": "^11.10.5",
|
||||
"@emotion/react": "^11.10.6",
|
||||
"@emotion/server": "^11.10.0",
|
||||
|
||||
@@ -11,9 +11,7 @@ import { createAffineProviders, createLocalProviders } from '..';
|
||||
let blockSuiteWorkspace: BlockSuiteWorkspace;
|
||||
|
||||
beforeEach(() => {
|
||||
blockSuiteWorkspace = new BlockSuiteWorkspace({
|
||||
room: 'test',
|
||||
});
|
||||
blockSuiteWorkspace = new BlockSuiteWorkspace({ id: 'test' });
|
||||
});
|
||||
|
||||
describe('blocksuite providers', () => {
|
||||
|
||||
@@ -9,8 +9,8 @@ const hashMap = new Map<string, ArrayBuffer>();
|
||||
export const createAffineDownloadProvider = (
|
||||
blockSuiteWorkspace: BlockSuiteWorkspace
|
||||
): AffineDownloadProvider => {
|
||||
assertExists(blockSuiteWorkspace.room);
|
||||
const id = blockSuiteWorkspace.room;
|
||||
assertExists(blockSuiteWorkspace.id);
|
||||
const id = blockSuiteWorkspace.id;
|
||||
return {
|
||||
flavour: 'affine-download',
|
||||
background: true,
|
||||
|
||||
@@ -78,17 +78,14 @@ export const createBroadCastChannelProvider = (
|
||||
flavour: 'broadcast-channel',
|
||||
background: false,
|
||||
connect: () => {
|
||||
assertExists(blockSuiteWorkspace.room);
|
||||
assertExists(blockSuiteWorkspace.id);
|
||||
broadcastChannel = Object.assign(
|
||||
new BroadcastChannel(blockSuiteWorkspace.room),
|
||||
new BroadcastChannel(blockSuiteWorkspace.id),
|
||||
{
|
||||
onmessage: handleBroadcastChannelMessage,
|
||||
}
|
||||
);
|
||||
providerLogger.info(
|
||||
'connect broadcast channel',
|
||||
blockSuiteWorkspace.room
|
||||
);
|
||||
providerLogger.info('connect broadcast channel', blockSuiteWorkspace.id);
|
||||
const docDiff = Y.encodeStateVector(doc);
|
||||
broadcastChannel.postMessage(['doc:diff', docDiff, awareness.clientID]);
|
||||
const docUpdateV2 = Y.encodeStateAsUpdate(doc);
|
||||
@@ -105,7 +102,7 @@ export const createBroadCastChannelProvider = (
|
||||
assertExists(broadcastChannel);
|
||||
providerLogger.info(
|
||||
'disconnect broadcast channel',
|
||||
blockSuiteWorkspace.room
|
||||
blockSuiteWorkspace.id
|
||||
);
|
||||
doc.off('update', handleDocUpdate);
|
||||
awareness.off('update', handleAwarenessUpdate);
|
||||
|
||||
@@ -29,7 +29,7 @@ const createAffineWebSocketProvider = (
|
||||
}://${window.location.host}/api/sync/`;
|
||||
webSocketProvider = new WebsocketProvider(
|
||||
wsUrl,
|
||||
blockSuiteWorkspace.room as string,
|
||||
blockSuiteWorkspace.id,
|
||||
blockSuiteWorkspace.doc,
|
||||
{
|
||||
params: { token: apis.auth.refresh },
|
||||
@@ -66,12 +66,9 @@ const createIndexedDBProvider = (
|
||||
indexeddbProvider = null;
|
||||
},
|
||||
connect: () => {
|
||||
providerLogger.info(
|
||||
'connect indexeddb provider',
|
||||
blockSuiteWorkspace.room
|
||||
);
|
||||
providerLogger.info('connect indexeddb provider', blockSuiteWorkspace.id);
|
||||
indexeddbProvider = new IndexeddbPersistence(
|
||||
blockSuiteWorkspace.room as string,
|
||||
blockSuiteWorkspace.id,
|
||||
blockSuiteWorkspace.doc
|
||||
);
|
||||
},
|
||||
@@ -79,7 +76,7 @@ const createIndexedDBProvider = (
|
||||
assertExists(indexeddbProvider);
|
||||
providerLogger.info(
|
||||
'disconnect indexeddb provider',
|
||||
blockSuiteWorkspace.room
|
||||
blockSuiteWorkspace.id
|
||||
);
|
||||
indexeddbProvider.destroy();
|
||||
indexeddbProvider = null;
|
||||
|
||||
@@ -94,7 +94,7 @@ export class AffineErrorBoundary extends Component<
|
||||
.replace({
|
||||
pathname: '/workspace/[workspaceId]/[pageId]',
|
||||
query: {
|
||||
workspaceId: error.workspace.room,
|
||||
workspaceId: error.workspace.id,
|
||||
pageId: error.workspace.meta.pageMetas[0].id,
|
||||
},
|
||||
})
|
||||
|
||||
@@ -123,7 +123,7 @@ export const BlockSuiteEditor = (props: EditorProps) => {
|
||||
}, [page]);
|
||||
return (
|
||||
<div
|
||||
data-testid={`editor-${props.blockSuiteWorkspace.room}-${props.page.id}`}
|
||||
data-testid={`editor-${props.blockSuiteWorkspace.id}-${props.page.id}`}
|
||||
className="editor-wrapper"
|
||||
style={props.style}
|
||||
ref={ref}
|
||||
|
||||
@@ -36,7 +36,7 @@ export const Footer: React.FC<FooterProps> = ({
|
||||
router.push({
|
||||
pathname: '/workspace/[workspaceId]/[pageId]',
|
||||
query: {
|
||||
workspaceId: blockSuiteWorkspace.room,
|
||||
workspaceId: blockSuiteWorkspace.id,
|
||||
pageId,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -31,8 +31,8 @@ export const Results: React.FC<ResultsProps> = ({
|
||||
}) => {
|
||||
useBlockSuiteWorkspaceHelper(blockSuiteWorkspace);
|
||||
const pageList = usePageMeta(blockSuiteWorkspace);
|
||||
assertExists(blockSuiteWorkspace.room);
|
||||
const List = useSwitchToConfig(blockSuiteWorkspace.room);
|
||||
assertExists(blockSuiteWorkspace.id);
|
||||
const List = useSwitchToConfig(blockSuiteWorkspace.id);
|
||||
const [results, setResults] = useState(new Map<string, string | undefined>());
|
||||
const recentlyViewed = useRecentlyViewed();
|
||||
const { t } = useTranslation();
|
||||
@@ -64,12 +64,12 @@ export const Results: React.FC<ResultsProps> = ({
|
||||
key={result.id}
|
||||
onSelect={() => {
|
||||
onClose();
|
||||
assertExists(blockSuiteWorkspace.room);
|
||||
assertExists(blockSuiteWorkspace.id);
|
||||
// fixme: refactor to `useRouterHelper`
|
||||
router.push({
|
||||
pathname: '/workspace/[workspaceId]/[pageId]',
|
||||
query: {
|
||||
workspaceId: blockSuiteWorkspace.room,
|
||||
workspaceId: blockSuiteWorkspace.id,
|
||||
pageId: result.id,
|
||||
},
|
||||
});
|
||||
@@ -108,7 +108,7 @@ export const Results: React.FC<ResultsProps> = ({
|
||||
router.push({
|
||||
pathname: '/workspace/[workspaceId]/[pageId]',
|
||||
query: {
|
||||
workspaceId: blockSuiteWorkspace.room,
|
||||
workspaceId: blockSuiteWorkspace.id,
|
||||
pageId: recent.id,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -70,9 +70,7 @@ async function getJotaiContext() {
|
||||
|
||||
beforeEach(async () => {
|
||||
return new Promise<void>(resolve => {
|
||||
blockSuiteWorkspace = new BlockSuiteWorkspace({
|
||||
room: 'test',
|
||||
})
|
||||
blockSuiteWorkspace = new BlockSuiteWorkspace({ id: 'test' })
|
||||
.register(builtInSchemas)
|
||||
.register(__unstableSchemas);
|
||||
blockSuiteWorkspace.slots.pageAdded.on(pageId => {
|
||||
@@ -265,7 +263,7 @@ describe('useBlockSuiteWorkspaceName', () => {
|
||||
describe('useRecentlyViewed', () => {
|
||||
test('basic', async () => {
|
||||
const { ProviderWrapper, store } = await getJotaiContext();
|
||||
const workspaceId = blockSuiteWorkspace.room as string;
|
||||
const workspaceId = blockSuiteWorkspace.id;
|
||||
const pageId = 'page0';
|
||||
store.set(jotaiWorkspacesAtom, [
|
||||
{
|
||||
@@ -279,9 +277,9 @@ describe('useRecentlyViewed', () => {
|
||||
blockSuiteWorkspace,
|
||||
providers: [],
|
||||
} satisfies LocalWorkspace);
|
||||
store.set(currentWorkspaceIdAtom, blockSuiteWorkspace.room as string);
|
||||
store.set(currentWorkspaceIdAtom, blockSuiteWorkspace.id);
|
||||
const workspace = await store.get(currentWorkspaceAtom);
|
||||
expect(workspace?.id).toBe(blockSuiteWorkspace.room as string);
|
||||
expect(workspace?.id).toBe(blockSuiteWorkspace.id);
|
||||
const currentHook = renderHook(() => useCurrentWorkspace(), {
|
||||
wrapper: ProviderWrapper,
|
||||
});
|
||||
|
||||
@@ -13,7 +13,7 @@ export function useBlockSuiteWorkspaceAvatarUrl(
|
||||
blockSuiteWorkspace
|
||||
? [
|
||||
QueryKey.getImage,
|
||||
blockSuiteWorkspace.room,
|
||||
blockSuiteWorkspace.id,
|
||||
blockSuiteWorkspace.meta.avatar,
|
||||
]
|
||||
: null,
|
||||
|
||||
@@ -61,7 +61,7 @@ const ListPageInner: React.FC<{
|
||||
<NavContainer>
|
||||
<Breadcrumbs>
|
||||
<StyledBreadcrumbs
|
||||
href={`/public-workspace/${blockSuiteWorkspace.room}`}
|
||||
href={`/public-workspace/${blockSuiteWorkspace.id}`}
|
||||
>
|
||||
<WorkspaceAvatar size={24} name={name} avatar={avatar} />
|
||||
<span>{name}</span>
|
||||
|
||||
@@ -90,15 +90,13 @@ const PublicWorkspaceDetailPageInner: React.FC<{
|
||||
<NavContainer>
|
||||
<Breadcrumbs>
|
||||
<StyledBreadcrumbs
|
||||
href={`/public-workspace/${blockSuiteWorkspace.room}`}
|
||||
href={`/public-workspace/${blockSuiteWorkspace.id}`}
|
||||
>
|
||||
<WorkspaceAvatar size={24} name={name} avatar={avatar} />
|
||||
<span>{name}</span>
|
||||
</StyledBreadcrumbs>
|
||||
<StyledBreadcrumbs
|
||||
href={`/public-workspace/${
|
||||
blockSuiteWorkspace.room as string
|
||||
}/${pageId}`}
|
||||
href={`/public-workspace/${blockSuiteWorkspace.id}/${pageId}`}
|
||||
>
|
||||
<PaperIcon fontSize={24} />
|
||||
<span>{pageTitle ? pageTitle : t('Untitled')}</span>
|
||||
|
||||
@@ -25,29 +25,23 @@ const AllPage: NextPageWithLayout = () => {
|
||||
if (!router.isReady) {
|
||||
return;
|
||||
}
|
||||
if (currentWorkspace) {
|
||||
const doc = currentWorkspace.blockSuiteWorkspace.doc;
|
||||
if (doc.store.clients.size === 1) {
|
||||
const items = [...doc.store.clients.values()][0];
|
||||
if (items.length <= 1) {
|
||||
// this is a new workspace, so we should redirect to the new page
|
||||
const pageId = nanoid();
|
||||
currentWorkspace.blockSuiteWorkspace.slots.pageAdded.once(id => {
|
||||
currentWorkspace.blockSuiteWorkspace.setPageMeta(id, {
|
||||
init: true,
|
||||
});
|
||||
assertExists(pageId, id);
|
||||
router.push({
|
||||
pathname: '/workspace/[workspaceId]/[pageId]',
|
||||
query: {
|
||||
workspaceId: currentWorkspace.id,
|
||||
pageId,
|
||||
},
|
||||
});
|
||||
});
|
||||
currentWorkspace.blockSuiteWorkspace.createPage(pageId);
|
||||
}
|
||||
}
|
||||
if (currentWorkspace?.blockSuiteWorkspace.isEmpty) {
|
||||
// this is a new workspace, so we should redirect to the new page
|
||||
const pageId = nanoid();
|
||||
currentWorkspace.blockSuiteWorkspace.slots.pageAdded.once(id => {
|
||||
currentWorkspace.blockSuiteWorkspace.setPageMeta(id, {
|
||||
init: true,
|
||||
});
|
||||
assertExists(pageId, id);
|
||||
router.push({
|
||||
pathname: '/workspace/[workspaceId]/[pageId]',
|
||||
query: {
|
||||
workspaceId: currentWorkspace.id,
|
||||
pageId,
|
||||
},
|
||||
});
|
||||
});
|
||||
currentWorkspace.blockSuiteWorkspace.createPage(pageId);
|
||||
}
|
||||
}, [currentWorkspace, router]);
|
||||
const onClickPage = useCallback(
|
||||
|
||||
@@ -26,19 +26,19 @@ export function stringToColour(str: string) {
|
||||
|
||||
const hashMap = new Map<string, BlockSuiteWorkspace>();
|
||||
export const createEmptyBlockSuiteWorkspace = (
|
||||
room: string,
|
||||
id: string,
|
||||
blobOptionsGetter?: BlobOptionsGetter
|
||||
): BlockSuiteWorkspace => {
|
||||
if (hashMap.has(room)) {
|
||||
return hashMap.get(room) as BlockSuiteWorkspace;
|
||||
if (hashMap.has(id)) {
|
||||
return hashMap.get(id) as BlockSuiteWorkspace;
|
||||
}
|
||||
const workspace = new BlockSuiteWorkspace({
|
||||
room,
|
||||
id,
|
||||
isSSR: typeof window === 'undefined',
|
||||
blobOptionsGetter,
|
||||
})
|
||||
.register(builtInSchemas)
|
||||
.register(__unstableSchemas);
|
||||
hashMap.set(room, workspace);
|
||||
hashMap.set(id, workspace);
|
||||
return workspace;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user