From 23831654701a375692b23a573dd6aaa83a86b6f7 Mon Sep 17 00:00:00 2001 From: Himself65 Date: Fri, 14 Apr 2023 17:07:41 -0500 Subject: [PATCH] refactor: remove NoSsr on top level (#1951) --- apps/electron/yarn.lock | 23 ++++--- apps/web/src/atoms/public-workspace/index.ts | 12 ++-- .../components/__debug__/client/Editor.tsx | 5 +- .../panel/publish/index.tsx | 4 +- .../web/src/components/page-detail-editor.tsx | 63 +++++++++---------- ...e-link.ts => use-reference-link-effect.ts} | 2 +- .../affine/use-toggle-workspace-publish.ts | 6 +- .../hooks/root/use-on-transform-workspace.ts | 11 +--- apps/web/src/hooks/use-router-helper.ts | 21 +++++++ apps/web/src/hooks/use-transform-workspace.ts | 7 ++- apps/web/src/layouts/index.tsx | 5 +- apps/web/src/pages/_debug/init-page.dev.tsx | 7 +-- .../[workspaceId]/[pageId].tsx | 46 +++++++------- .../workspace/[workspaceId]/[pageId].tsx | 4 +- packages/component/package.json | 11 ++-- .../block-suite-editor/index.stories.tsx | 6 +- .../components/block-suite-editor/index.tsx | 17 +++-- packages/jotai/package.json | 8 +++ packages/jotai/src/resource.ts | 13 +++- packages/workspace/package.json | 4 +- packages/workspace/src/affine/login.ts | 1 + packages/workspace/src/utils.ts | 16 +++-- playwright.config.ts | 2 - scripts/setup/lottie-web.ts | 18 ++++++ tests/libs/playwright.ts | 7 +++ vitest.config.ts | 2 +- yarn.lock | 23 ++++--- 27 files changed, 211 insertions(+), 133 deletions(-) rename apps/web/src/hooks/affine/{use-reference-link.ts => use-reference-link-effect.ts} (95%) create mode 100644 scripts/setup/lottie-web.ts diff --git a/apps/electron/yarn.lock b/apps/electron/yarn.lock index 708d6e3bc2..2124ebdbbe 100644 --- a/apps/electron/yarn.lock +++ b/apps/electron/yarn.lock @@ -75,6 +75,7 @@ __metadata: clsx: ^1.2.1 concurrently: ^8.0.1 jest-mock: ^29.5.0 + jotai: ^2.0.4 kebab-case: ^1.0.2 lit: ^2.7.2 lottie-web: ^5.11.0 @@ -92,11 +93,11 @@ __metadata: wait-on: ^7.0.1 yjs: ^13.5.52 peerDependencies: - "@blocksuite/blocks": 0.0.0-20230409084303-221991d4-nightly - "@blocksuite/editor": 0.0.0-20230409084303-221991d4-nightly - "@blocksuite/global": 0.0.0-20230409084303-221991d4-nightly - "@blocksuite/icons": 2.1.10 - "@blocksuite/store": 0.0.0-20230409084303-221991d4-nightly + "@blocksuite/blocks": "*" + "@blocksuite/editor": "*" + "@blocksuite/global": "*" + "@blocksuite/icons": "*" + "@blocksuite/store": "*" languageName: unknown linkType: soft @@ -175,9 +176,17 @@ __metadata: resolution: "@affine/jotai@workspace:../../packages/jotai" dependencies: "@affine/env": "workspace:*" + "@blocksuite/blocks": 0.0.0-20230413190748-4d32b79a-nightly + "@blocksuite/editor": 0.0.0-20230413190748-4d32b79a-nightly + "@blocksuite/global": 0.0.0-20230413190748-4d32b79a-nightly + "@blocksuite/store": 0.0.0-20230413190748-4d32b79a-nightly jotai: ^2.0.4 lottie-web: ^5.11.0 peerDependencies: + "@blocksuite/blocks": "*" + "@blocksuite/editor": "*" + "@blocksuite/global": "*" + "@blocksuite/store": "*" lottie-web: "*" languageName: unknown linkType: soft @@ -219,8 +228,8 @@ __metadata: yjs: ^13.5.52 zod: ^3.21.4 peerDependencies: - "@blocksuite/blocks": 0.0.0-20230409084303-221991d4-nightly - "@blocksuite/store": 0.0.0-20230409084303-221991d4-nightly + "@blocksuite/blocks": "*" + "@blocksuite/store": "*" languageName: unknown linkType: soft diff --git a/apps/web/src/atoms/public-workspace/index.ts b/apps/web/src/atoms/public-workspace/index.ts index 76924ecc8e..07ccc77ef9 100644 --- a/apps/web/src/atoms/public-workspace/index.ts +++ b/apps/web/src/atoms/public-workspace/index.ts @@ -9,13 +9,17 @@ import { affineApis } from '../../shared/apis'; function createPublicWorkspace( workspaceId: string, - binary: ArrayBuffer + binary: ArrayBuffer, + singlePage = false ): AffinePublicWorkspace { const blockSuiteWorkspace = createEmptyBlockSuiteWorkspace( workspaceId, (k: string) => // fixme: token could be expired - ({ api: `api/workspace`, token: getLoginStorage()?.token }[k]) + ({ api: `api/workspace`, token: getLoginStorage()?.token }[k]), + { + cachePrefix: WorkspaceFlavour.PUBLIC + (singlePage ? '-single-page' : ''), + } ); BlockSuiteWorkspace.Y.applyUpdate( blockSuiteWorkspace.doc, @@ -49,7 +53,7 @@ export const publicPageBlockSuiteAtom = atom>( workspaceId, pageId ); - return createPublicWorkspace(workspaceId, binary); + return createPublicWorkspace(workspaceId, binary, true); } ); export const publicWorkspaceAtom = atom>( @@ -59,6 +63,6 @@ export const publicWorkspaceAtom = atom>( throw new Error('No workspace id'); } const binary = await affineApis.downloadWorkspace(workspaceId, true); - return createPublicWorkspace(workspaceId, binary); + return createPublicWorkspace(workspaceId, binary, false); } ); diff --git a/apps/web/src/components/__debug__/client/Editor.tsx b/apps/web/src/components/__debug__/client/Editor.tsx index 23d859ba73..0e402cde38 100644 --- a/apps/web/src/components/__debug__/client/Editor.tsx +++ b/apps/web/src/components/__debug__/client/Editor.tsx @@ -1,4 +1,3 @@ -'use client'; import { createEmptyBlockSuiteWorkspace } from '@affine/workspace/utils'; import type { EditorContainer } from '@blocksuite/editor'; import type { Page } from '@blocksuite/store'; @@ -11,7 +10,9 @@ import { BlockSuiteEditor } from '../../blocksuite/block-suite-editor'; const blockSuiteWorkspace = createEmptyBlockSuiteWorkspace( 'test', _ => undefined, - Generator.AutoIncrement + { + idGenerator: Generator.AutoIncrement, + } ); const page = blockSuiteWorkspace.createPage('page0'); diff --git a/apps/web/src/components/affine/workspace-setting-detail/panel/publish/index.tsx b/apps/web/src/components/affine/workspace-setting-detail/panel/publish/index.tsx index d969355553..d0ccbe59ae 100644 --- a/apps/web/src/components/affine/workspace-setting-detail/panel/publish/index.tsx +++ b/apps/web/src/components/affine/workspace-setting-detail/panel/publish/index.tsx @@ -89,8 +89,8 @@ const PublishPanelAffine: React.FC = ({ {t('Publishing Description')}