From 162016884c8f6aaccb15bd3e48141814f83b65b3 Mon Sep 17 00:00:00 2001 From: Alex Yang Date: Fri, 8 Sep 2023 17:00:26 -0700 Subject: [PATCH] refactor: remove unused package (#4291) --- .commitlintrc.json | 1 - .eslintrc.js | 1 - .github/labeler.yml | 1 - apps/core/package.json | 1 - apps/core/tsconfig.json | 3 --- apps/electron/src/main/handlers.ts | 2 +- apps/prototype/package.json | 1 - apps/prototype/tsconfig.json | 3 --- packages/@types/env/__all.d.ts | 2 +- packages/component/package.json | 1 - .../app-updater-button/index.jotai.ts | 2 +- .../src/components/internal-lottie/index.tsx | 6 ++--- packages/component/tsconfig.json | 3 --- packages/i18n/src/scripts/sync.ts | 3 +-- packages/i18n/tsconfig.json | 11 ++++++-- packages/i18n/tsconfig.node.json | 7 +++++ packages/jotai/.gitignore | 1 - packages/jotai/README.md | 3 --- packages/jotai/package.json | 27 ------------------- packages/jotai/src/index.ts | 1 - packages/jotai/src/resource.ts | 3 --- packages/jotai/tsconfig.json | 9 ------- packages/native/tsconfig.json | 3 ++- .../__tests__/sqlite-provider.spec.ts | 9 +++++-- tsconfig.json | 1 - yarn.lock | 26 ------------------ 26 files changed, 31 insertions(+), 100 deletions(-) create mode 100644 packages/i18n/tsconfig.node.json delete mode 100644 packages/jotai/.gitignore delete mode 100644 packages/jotai/README.md delete mode 100644 packages/jotai/package.json delete mode 100644 packages/jotai/src/index.ts delete mode 100644 packages/jotai/src/resource.ts delete mode 100644 packages/jotai/tsconfig.json diff --git a/.commitlintrc.json b/.commitlintrc.json index 1c33fe25bc..4dbfd8e6b6 100644 --- a/.commitlintrc.json +++ b/.commitlintrc.json @@ -17,7 +17,6 @@ "cli", "hooks", "i18n", - "jotai", "native", "templates", "y-indexeddb", diff --git a/.eslintrc.js b/.eslintrc.js index 743a7cc814..e13090b43d 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -57,7 +57,6 @@ const allPackages = [ 'packages/graphql', 'packages/hooks', 'packages/i18n', - 'packages/jotai', 'packages/native', 'packages/infra', 'packages/sdk', diff --git a/.github/labeler.yml b/.github/labeler.yml index 87d0fa6dae..9bee8db1e6 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -46,7 +46,6 @@ mod:storage: 'packages/storage/**/*' mod:native: 'packages/native/**/*' mod:store: - - 'packages/jotai/**/*' - '**/atoms/**/*' rust: diff --git a/apps/core/package.json b/apps/core/package.json index 7901f549dc..ed488335bb 100644 --- a/apps/core/package.json +++ b/apps/core/package.json @@ -21,7 +21,6 @@ "@affine/env": "workspace:*", "@affine/graphql": "workspace:*", "@affine/i18n": "workspace:*", - "@affine/jotai": "workspace:*", "@affine/templates": "workspace:*", "@affine/workspace": "workspace:*", "@blocksuite/block-std": "0.0.0-20230907222710-102d1e99-nightly", diff --git a/apps/core/tsconfig.json b/apps/core/tsconfig.json index 1809b66040..1e342746d8 100644 --- a/apps/core/tsconfig.json +++ b/apps/core/tsconfig.json @@ -26,9 +26,6 @@ { "path": "../../packages/i18n" }, - { - "path": "../../packages/jotai" - }, { "path": "../../packages/workspace" }, diff --git a/apps/electron/src/main/handlers.ts b/apps/electron/src/main/handlers.ts index c7d07b5cb9..0da50044f7 100644 --- a/apps/electron/src/main/handlers.ts +++ b/apps/electron/src/main/handlers.ts @@ -5,7 +5,7 @@ import type { UIHandlerManager, UnwrapManagerHandlerToServerSide, UpdaterHandlerManager, -} from '@toeverything/infra'; +} from '@toeverything/infra/index'; import { ipcMain } from 'electron'; import { clipboardHandlers } from './clipboard'; diff --git a/apps/prototype/package.json b/apps/prototype/package.json index 1234bac0f1..200856227c 100644 --- a/apps/prototype/package.json +++ b/apps/prototype/package.json @@ -15,7 +15,6 @@ "@affine/env": "workspace:*", "@affine/graphql": "workspace:*", "@affine/i18n": "workspace:*", - "@affine/jotai": "workspace:*", "@affine/templates": "workspace:*", "@affine/workspace": "workspace:*", "@blocksuite/block-std": "0.0.0-20230907222710-102d1e99-nightly", diff --git a/apps/prototype/tsconfig.json b/apps/prototype/tsconfig.json index e871e17eef..96031a8fe9 100644 --- a/apps/prototype/tsconfig.json +++ b/apps/prototype/tsconfig.json @@ -24,9 +24,6 @@ { "path": "../../packages/i18n" }, - { - "path": "../../packages/jotai" - }, { "path": "../../packages/y-indexeddb" }, diff --git a/packages/@types/env/__all.d.ts b/packages/@types/env/__all.d.ts index 9be292bc30..0f6774fe09 100644 --- a/packages/@types/env/__all.d.ts +++ b/packages/@types/env/__all.d.ts @@ -9,7 +9,7 @@ import type { UnwrapManagerHandlerToClientSide, UpdaterHandlerManager, WorkspaceHandlerManager, -} from '@toeverything/infra'; +} from '@toeverything/infra/index'; declare global { interface Window { diff --git a/packages/component/package.json b/packages/component/package.json index f944b516d9..f501ebb6be 100644 --- a/packages/component/package.json +++ b/packages/component/package.json @@ -18,7 +18,6 @@ "dependencies": { "@affine/debug": "workspace:*", "@affine/i18n": "workspace:*", - "@affine/jotai": "workspace:*", "@affine/workspace": "workspace:*", "@dnd-kit/core": "^6.0.8", "@dnd-kit/modifiers": "^6.0.1", diff --git a/packages/component/src/components/app-sidebar/app-updater-button/index.jotai.ts b/packages/component/src/components/app-sidebar/app-updater-button/index.jotai.ts index 2c1eaf8532..c438a2ce9d 100644 --- a/packages/component/src/components/app-sidebar/app-updater-button/index.jotai.ts +++ b/packages/component/src/components/app-sidebar/app-updater-button/index.jotai.ts @@ -1,5 +1,5 @@ import { isBrowser } from '@affine/env/constant'; -import type { UpdateMeta } from '@toeverything/infra'; +import type { UpdateMeta } from '@toeverything/infra/type'; import { atomWithObservable, atomWithStorage } from 'jotai/utils'; import { Observable } from 'rxjs'; diff --git a/packages/component/src/components/internal-lottie/index.tsx b/packages/component/src/components/internal-lottie/index.tsx index a56ac07da2..c6e78ca12c 100644 --- a/packages/component/src/components/internal-lottie/index.tsx +++ b/packages/component/src/components/internal-lottie/index.tsx @@ -1,6 +1,5 @@ -import { lottieAtom } from '@affine/jotai'; -import { useAtomValue } from 'jotai'; import type { AnimationItem } from 'lottie-web'; +import lottie from 'lottie-web'; import { useEffect, useRef } from 'react'; interface CustomLottieProps { @@ -28,7 +27,6 @@ export const InternalLottie = ({ }: CustomLottieProps) => { const element = useRef(null); const lottieInstance = useRef(); - const lottie = useAtomValue(lottieAtom); const directionRef = useRef<1 | -1>(1); useEffect(() => { @@ -76,7 +74,7 @@ export const InternalLottie = ({ } lottieInstance.current?.destroy(); }; - }, [lottie, options]); + }, [options]); useEffect(() => { if (speed) { diff --git a/packages/component/tsconfig.json b/packages/component/tsconfig.json index a9aafe3ecd..ffddfded04 100644 --- a/packages/component/tsconfig.json +++ b/packages/component/tsconfig.json @@ -14,9 +14,6 @@ { "path": "../i18n" }, - { - "path": "../jotai" - }, { "path": "../hooks" }, diff --git a/packages/i18n/src/scripts/sync.ts b/packages/i18n/src/scripts/sync.ts index 9415a92b11..fa546eb774 100644 --- a/packages/i18n/src/scripts/sync.ts +++ b/packages/i18n/src/scripts/sync.ts @@ -1,8 +1,7 @@ // cSpell:ignore Tolgee +import { readFile } from 'node:fs/promises'; import { resolve } from 'node:path'; -import { readFile } from 'fs/promises'; - import { createsNewKey, getRemoteTranslations } from './api.js'; import type { TranslationRes } from './utils.js'; diff --git a/packages/i18n/tsconfig.json b/packages/i18n/tsconfig.json index 38fbfa4aaf..3f99f82d8d 100644 --- a/packages/i18n/tsconfig.json +++ b/packages/i18n/tsconfig.json @@ -1,11 +1,18 @@ { "extends": "../../tsconfig.json", "include": ["./src"], - "exclude": ["src/resources"], + "exclude": ["./src/resources", "./src/scripts"], "compilerOptions": { "noEmit": false, "composite": true, "outDir": "lib" }, - "references": [{ "path": "./tsconfig.resources.json" }] + "references": [ + { + "path": "./tsconfig.resources.json" + }, + { + "path": "./tsconfig.node.json" + } + ] } diff --git a/packages/i18n/tsconfig.node.json b/packages/i18n/tsconfig.node.json new file mode 100644 index 0000000000..344e213d32 --- /dev/null +++ b/packages/i18n/tsconfig.node.json @@ -0,0 +1,7 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "types": ["node"] + }, + "include": ["./src/scripts"] +} diff --git a/packages/jotai/.gitignore b/packages/jotai/.gitignore deleted file mode 100644 index a65b41774a..0000000000 --- a/packages/jotai/.gitignore +++ /dev/null @@ -1 +0,0 @@ -lib diff --git a/packages/jotai/README.md b/packages/jotai/README.md deleted file mode 100644 index 35e0d151b3..0000000000 --- a/packages/jotai/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# @affine/jotai - -Custom Jotai utilities. diff --git a/packages/jotai/package.json b/packages/jotai/package.json deleted file mode 100644 index 7b3567fb8a..0000000000 --- a/packages/jotai/package.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "name": "@affine/jotai", - "private": true, - "main": "./src/index.ts", - "dependencies": { - "jotai": "^2.4.1" - }, - "devDependencies": { - "@blocksuite/block-std": "0.0.0-20230907222710-102d1e99-nightly", - "@blocksuite/blocks": "0.0.0-20230907222710-102d1e99-nightly", - "@blocksuite/editor": "0.0.0-20230907222710-102d1e99-nightly", - "@blocksuite/global": "0.0.0-20230907222710-102d1e99-nightly", - "@blocksuite/lit": "0.0.0-20230907222710-102d1e99-nightly", - "@blocksuite/store": "0.0.0-20230907222710-102d1e99-nightly", - "lottie-web": "^5.12.2" - }, - "peerDependencies": { - "@blocksuite/block-std": "*", - "@blocksuite/blocks": "*", - "@blocksuite/editor": "*", - "@blocksuite/global": "*", - "@blocksuite/lit": "*", - "@blocksuite/store": "*", - "lottie-web": "*" - }, - "version": "0.9.0-canary.11" -} diff --git a/packages/jotai/src/index.ts b/packages/jotai/src/index.ts deleted file mode 100644 index c1cb5de6b7..0000000000 --- a/packages/jotai/src/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './resource'; diff --git a/packages/jotai/src/resource.ts b/packages/jotai/src/resource.ts deleted file mode 100644 index 44150d95f3..0000000000 --- a/packages/jotai/src/resource.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { atom } from 'jotai'; - -export const lottieAtom = atom(import('lottie-web').then(m => m.default)); diff --git a/packages/jotai/tsconfig.json b/packages/jotai/tsconfig.json deleted file mode 100644 index 8034f93ce4..0000000000 --- a/packages/jotai/tsconfig.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "extends": "../../tsconfig.json", - "include": ["./src"], - "compilerOptions": { - "composite": true, - "noEmit": false, - "outDir": "lib" - } -} diff --git a/packages/native/tsconfig.json b/packages/native/tsconfig.json index 338410b98f..3878213203 100644 --- a/packages/native/tsconfig.json +++ b/packages/native/tsconfig.json @@ -3,7 +3,8 @@ "compilerOptions": { "noEmit": false, "outDir": "lib", - "composite": true + "composite": true, + "types": ["node"] }, "include": ["index.d.ts", "__tests__/**/*.mts"], "ts-node": { diff --git a/packages/workspace/src/providers/__tests__/sqlite-provider.spec.ts b/packages/workspace/src/providers/__tests__/sqlite-provider.spec.ts index 3ed59a91b8..a48506aa50 100644 --- a/packages/workspace/src/providers/__tests__/sqlite-provider.spec.ts +++ b/packages/workspace/src/providers/__tests__/sqlite-provider.spec.ts @@ -6,6 +6,11 @@ import { getDoc } from '@affine/y-provider'; import { __unstableSchemas, AffineSchemas } from '@blocksuite/blocks/models'; import type { Y as YType } from '@blocksuite/store'; import { Schema, uuidv4, Workspace } from '@blocksuite/store'; +import type { DBHandlerManager } from '@toeverything/infra/handler'; +import type { + EventMap, + UnwrapManagerHandlerToClientSide, +} from '@toeverything/infra/type'; import { setTimeout } from 'timers/promises'; import { beforeEach, describe, expect, test, vi } from 'vitest'; @@ -51,7 +56,7 @@ vi.stubGlobal('window', { return []; }, addBlob: mockedAddBlob, - } as Partial['db']>, + } satisfies Partial>, }, events: { db: { @@ -62,7 +67,7 @@ vi.stubGlobal('window', { }; }, }, - } as Partial>, + } as Partial, }); vi.stubGlobal('environment', { diff --git a/tsconfig.json b/tsconfig.json index 7c223255f1..0da03a3fae 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -65,7 +65,6 @@ "@affine/i18n": ["./packages/i18n/src"], "@affine/i18n/hooks": ["./packages/i18n/src/i18n-generated"], "@affine/debug": ["./packages/debug"], - "@affine/jotai": ["./packages/jotai"], "@affine/env": ["./packages/env/src"], "@affine/env/*": ["./packages/env/src/*"], "@affine/utils": ["./packages/utils"], diff --git a/yarn.lock b/yarn.lock index 472569729a..f4d30fad66 100644 --- a/yarn.lock +++ b/yarn.lock @@ -166,7 +166,6 @@ __metadata: dependencies: "@affine/debug": "workspace:*" "@affine/i18n": "workspace:*" - "@affine/jotai": "workspace:*" "@affine/workspace": "workspace:*" "@blocksuite/blocks": 0.0.0-20230907222710-102d1e99-nightly "@blocksuite/editor": 0.0.0-20230907222710-102d1e99-nightly @@ -257,7 +256,6 @@ __metadata: "@affine/env": "workspace:*" "@affine/graphql": "workspace:*" "@affine/i18n": "workspace:*" - "@affine/jotai": "workspace:*" "@affine/templates": "workspace:*" "@affine/workspace": "workspace:*" "@aws-sdk/client-s3": 3.400.0 @@ -493,29 +491,6 @@ __metadata: languageName: unknown linkType: soft -"@affine/jotai@workspace:*, @affine/jotai@workspace:packages/jotai": - version: 0.0.0-use.local - resolution: "@affine/jotai@workspace:packages/jotai" - dependencies: - "@blocksuite/block-std": 0.0.0-20230907222710-102d1e99-nightly - "@blocksuite/blocks": 0.0.0-20230907222710-102d1e99-nightly - "@blocksuite/editor": 0.0.0-20230907222710-102d1e99-nightly - "@blocksuite/global": 0.0.0-20230907222710-102d1e99-nightly - "@blocksuite/lit": 0.0.0-20230907222710-102d1e99-nightly - "@blocksuite/store": 0.0.0-20230907222710-102d1e99-nightly - jotai: ^2.4.1 - lottie-web: ^5.12.2 - peerDependencies: - "@blocksuite/block-std": "*" - "@blocksuite/blocks": "*" - "@blocksuite/editor": "*" - "@blocksuite/global": "*" - "@blocksuite/lit": "*" - "@blocksuite/store": "*" - lottie-web: "*" - languageName: unknown - linkType: soft - "@affine/monorepo@workspace:.": version: 0.0.0-use.local resolution: "@affine/monorepo@workspace:." @@ -637,7 +612,6 @@ __metadata: "@affine/env": "workspace:*" "@affine/graphql": "workspace:*" "@affine/i18n": "workspace:*" - "@affine/jotai": "workspace:*" "@affine/templates": "workspace:*" "@affine/workspace": "workspace:*" "@blocksuite/block-std": 0.0.0-20230907222710-102d1e99-nightly