From 7be96a2e41d425ff02092de8fce208bd9970bfa1 Mon Sep 17 00:00:00 2001 From: Himself65 Date: Mon, 17 Apr 2023 23:11:46 -0500 Subject: [PATCH] build: remove unused config (#1990) --- apps/web/README.md | 3 --- apps/web/preset.config.mjs | 5 ----- apps/web/src/blocksuite/index.ts | 3 +-- apps/web/src/components/pure/help-island/index.tsx | 5 +---- .../src/components/pure/workspace-slider-bar/index.tsx | 3 +-- apps/web/src/layouts/workspace-layout.tsx | 8 ++------ packages/env/src/config.ts | 8 +------- packages/workspace/src/providers/index.ts | 3 +-- scripts/vitest/next-config-mock.ts | 5 ----- tests/parallels/affine/affine-public-single-page.spec.ts | 1 - 10 files changed, 7 insertions(+), 37 deletions(-) diff --git a/apps/web/README.md b/apps/web/README.md index 522e73e063..0462cf7a4d 100644 --- a/apps/web/README.md +++ b/apps/web/README.md @@ -20,10 +20,7 @@ For more information on Next.js, take a look at the [Next.js Documentation](http `preset.config.mjs` contains the build presets for the application. The presets are used to configure the build process for different environments. The presets are: -- `enableIndexedDBProvider`: Enables the IndexedDB provider for the application. This is used to store data in the browser. - `enableBroadCastChannelProvider`: Enables the Broadcast Channel provider for the application. This is used to communicate between local browser tabs. -- `prefetchWorkspace`: **deprecated** -- `exposeInternal`: Exposes internal variables into `globalThis` for debugging purposes. - `enableDebugPage`: Enables the debug page for the application. This is used for debugging purposes. ## BlockSuite Integration diff --git a/apps/web/preset.config.mjs b/apps/web/preset.config.mjs index bcb8567f3d..a617e45ab9 100644 --- a/apps/web/preset.config.mjs +++ b/apps/web/preset.config.mjs @@ -1,16 +1,11 @@ import 'dotenv/config'; const config = { - enableIndexedDBProvider: Boolean(process.env.ENABLE_IDB_PROVIDER ?? '1'), enableBroadCastChannelProvider: Boolean( process.env.ENABLE_BC_PROVIDER ?? '1' ), - prefetchWorkspace: Boolean(process.env.PREFETCH_WORKSPACE ?? '1'), - exposeInternal: Boolean(process.env.EXPOSE_INTERNAL ?? '1'), enableDebugPage: Boolean( process.env.ENABLE_DEBUG_PAGE ?? process.env.NODE_ENV === 'development' ), - enableSubpage: Boolean(process.env.ENABLE_SUBPAGE ?? '1'), - enableChangeLog: Boolean(process.env.ENABLE_CHANGELOG ?? '1'), }; export default config; diff --git a/apps/web/src/blocksuite/index.ts b/apps/web/src/blocksuite/index.ts index a2d296c32f..5e4e33a890 100644 --- a/apps/web/src/blocksuite/index.ts +++ b/apps/web/src/blocksuite/index.ts @@ -19,8 +19,7 @@ export const createAffineProviders = ( createAffineWebSocketProvider(blockSuiteWorkspace), config.enableBroadCastChannelProvider && createBroadCastChannelProvider(blockSuiteWorkspace), - config.enableIndexedDBProvider && - createIndexedDBProvider(blockSuiteWorkspace), + createIndexedDBProvider(blockSuiteWorkspace), ] as any[] ).filter(v => Boolean(v)); }; diff --git a/apps/web/src/components/pure/help-island/index.tsx b/apps/web/src/components/pure/help-island/index.tsx index cd1c7e6d2d..cddb89265d 100644 --- a/apps/web/src/components/pure/help-island/index.tsx +++ b/apps/web/src/components/pure/help-island/index.tsx @@ -1,5 +1,4 @@ import { MuiFade, Tooltip } from '@affine/component'; -import { config } from '@affine/env'; import { useTranslation } from '@affine/i18n'; import { CloseIcon, NewIcon } from '@blocksuite/icons'; import { lazy, Suspense, useState } from 'react'; @@ -21,9 +20,7 @@ const ContactModal = lazy(() => export type IslandItemNames = 'whatNew' | 'contact' | 'shortcuts'; export const HelpIsland = ({ - showList = config.enableChangeLog - ? ['whatNew', 'contact', 'shortcuts'] - : ['contact', 'shortcuts'], + showList = ['whatNew', 'contact', 'shortcuts'], }: { showList?: IslandItemNames[]; }) => { diff --git a/apps/web/src/components/pure/workspace-slider-bar/index.tsx b/apps/web/src/components/pure/workspace-slider-bar/index.tsx index 24cc6293d2..1e31d4e6cb 100644 --- a/apps/web/src/components/pure/workspace-slider-bar/index.tsx +++ b/apps/web/src/components/pure/workspace-slider-bar/index.tsx @@ -1,4 +1,3 @@ -import { config } from '@affine/env'; import { useTranslation } from '@affine/i18n'; import { WorkspaceFlavour } from '@affine/workspace/type'; import { @@ -135,7 +134,7 @@ export const WorkSpaceSliderBar: React.FC = ({ currentWorkspace={currentWorkspace} onClick={onOpenWorkspaceListModal} /> - {config.enableChangeLog && } + { diff --git a/apps/web/src/layouts/workspace-layout.tsx b/apps/web/src/layouts/workspace-layout.tsx index 327158c07f..c9364f0720 100644 --- a/apps/web/src/layouts/workspace-layout.tsx +++ b/apps/web/src/layouts/workspace-layout.tsx @@ -1,5 +1,5 @@ import { DebugLogger } from '@affine/debug'; -import { config, DEFAULT_HELLO_WORLD_PAGE_ID } from '@affine/env'; +import { DEFAULT_HELLO_WORLD_PAGE_ID } from '@affine/env'; import { ensureRootPinboard, initPage } from '@affine/env/blocksuite'; import { setUpLanguage, useTranslation } from '@affine/i18n'; import { createAffineGlobalChannel } from '@affine/workspace/affine/sync'; @@ -448,11 +448,7 @@ export const WorkspaceLayoutInner: FC = ({ children }) => { {!isPublicWorkspace && ( )} diff --git a/packages/env/src/config.ts b/packages/env/src/config.ts index eeea0f2c7f..779fb956b3 100644 --- a/packages/env/src/config.ts +++ b/packages/env/src/config.ts @@ -11,14 +11,8 @@ export const publicRuntimeConfigSchema = z.object({ hash: z.string(), serverAPI: z.string(), editorVersion: z.string(), - enableIndexedDBProvider: z.boolean(), enableBroadCastChannelProvider: z.boolean(), - prefetchWorkspace: z.boolean(), enableDebugPage: z.boolean(), - // expose internal api to globalThis, **development only** - exposeInternal: z.boolean(), - enableSubpage: z.boolean(), - enableChangeLog: z.boolean(), }); export type PublicRuntimeConfig = z.infer; @@ -103,7 +97,7 @@ export function getEnvironment() { environment = { origin: window.location.origin, - isDesktop: window.appInfo?.electron, + isDesktop: !!window.appInfo?.electron, isBrowser: true, isServer: false, isDebug, diff --git a/packages/workspace/src/providers/index.ts b/packages/workspace/src/providers/index.ts index a9b57e2166..ddc2ea8a9a 100644 --- a/packages/workspace/src/providers/index.ts +++ b/packages/workspace/src/providers/index.ts @@ -162,8 +162,7 @@ export const createLocalProviders = ( [ config.enableBroadCastChannelProvider && createBroadCastChannelProvider(blockSuiteWorkspace), - config.enableIndexedDBProvider && - createIndexedDBProvider(blockSuiteWorkspace), + createIndexedDBProvider(blockSuiteWorkspace), ] as any[] ).filter(v => Boolean(v)); }; diff --git a/scripts/vitest/next-config-mock.ts b/scripts/vitest/next-config-mock.ts index 6559d20a10..ad6ae4039b 100644 --- a/scripts/vitest/next-config-mock.ts +++ b/scripts/vitest/next-config-mock.ts @@ -8,12 +8,7 @@ export default function getConfig() { editorVersion: 'UNKNOWN', serverAPI: 'http://127.0.0.1:3000/', enableBroadCastChannelProvider: true, - enableIndexedDBProvider: true, enableDebugPage: true, - prefetchWorkspace: false, - exposeInternal: true, - enableSubpage: true, - enableChangeLog: true, }, }; } diff --git a/tests/parallels/affine/affine-public-single-page.spec.ts b/tests/parallels/affine/affine-public-single-page.spec.ts index 54c705f511..12ff06b816 100644 --- a/tests/parallels/affine/affine-public-single-page.spec.ts +++ b/tests/parallels/affine/affine-public-single-page.spec.ts @@ -10,7 +10,6 @@ test('public single page', async ({ page, browser }) => { await openHomePage(page); const [a] = await createFakeUser(); await loginUser(page, a); - await waitMarkdownImported(page); const name = `test-${Date.now()}`; await createWorkspace({ name }, page); await waitMarkdownImported(page);