diff --git a/blocksuite/affine/all/tsconfig.json b/blocksuite/affine/all/tsconfig.json index 7b7b05aec4..2a62a37aec 100644 --- a/blocksuite/affine/all/tsconfig.json +++ b/blocksuite/affine/all/tsconfig.json @@ -1,20 +1,18 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "rootDir": "./src/", - "outDir": "./dist/", - "noEmit": false + "rootDir": "./src", + "outDir": "./dist", + "tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo" }, "include": ["./src"], "references": [ - { - "path": "../../framework" - }, - { - "path": "../../blocks" - }, - { - "path": "../../presets" - } + { "path": "../../framework/block-std" }, + { "path": "../../blocks" }, + { "path": "../../framework/global" }, + { "path": "../../framework/inline" }, + { "path": "../../presets" }, + { "path": "../../framework/store" }, + { "path": "../../framework/sync" } ] } diff --git a/blocksuite/affine/block-attachment/tsconfig.json b/blocksuite/affine/block-attachment/tsconfig.json index e6302efe20..3f52439ca0 100644 --- a/blocksuite/affine/block-attachment/tsconfig.json +++ b/blocksuite/affine/block-attachment/tsconfig.json @@ -1,29 +1,20 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "rootDir": "./src/", - "outDir": "./dist/", - "noEmit": false + "rootDir": "./src", + "outDir": "./dist", + "tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo" }, "include": ["./src"], "references": [ - { - "path": "../../framework" - }, - { - "path": "../model" - }, - { - "path": "../components" - }, - { - "path": "../shared" - }, - { - "path": "../block-embed" - }, - { - "path": "../block-surface" - } + { "path": "../block-embed" }, + { "path": "../block-surface" }, + { "path": "../components" }, + { "path": "../model" }, + { "path": "../shared" }, + { "path": "../../framework/block-std" }, + { "path": "../../framework/global" }, + { "path": "../../framework/inline" }, + { "path": "../../framework/store" } ] } diff --git a/blocksuite/affine/block-bookmark/tsconfig.json b/blocksuite/affine/block-bookmark/tsconfig.json index 19089f9715..4494890a0c 100644 --- a/blocksuite/affine/block-bookmark/tsconfig.json +++ b/blocksuite/affine/block-bookmark/tsconfig.json @@ -1,26 +1,19 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "rootDir": "./src/", - "outDir": "./dist/", - "noEmit": false + "rootDir": "./src", + "outDir": "./dist", + "tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo" }, "include": ["./src"], "references": [ - { - "path": "../../framework" - }, - { - "path": "../model" - }, - { - "path": "../components" - }, - { - "path": "../shared" - }, - { - "path": "../block-embed" - } + { "path": "../block-embed" }, + { "path": "../components" }, + { "path": "../model" }, + { "path": "../shared" }, + { "path": "../../framework/block-std" }, + { "path": "../../framework/global" }, + { "path": "../../framework/inline" }, + { "path": "../../framework/store" } ] } diff --git a/blocksuite/affine/block-code/tsconfig.json b/blocksuite/affine/block-code/tsconfig.json index e91b896c92..230fca2705 100644 --- a/blocksuite/affine/block-code/tsconfig.json +++ b/blocksuite/affine/block-code/tsconfig.json @@ -1,23 +1,18 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "rootDir": "./src/", - "outDir": "./dist/", - "noEmit": false + "rootDir": "./src", + "outDir": "./dist", + "tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo" }, "include": ["./src"], "references": [ - { - "path": "../../framework" - }, - { - "path": "../model" - }, - { - "path": "../components" - }, - { - "path": "../shared" - } + { "path": "../components" }, + { "path": "../model" }, + { "path": "../shared" }, + { "path": "../../framework/block-std" }, + { "path": "../../framework/global" }, + { "path": "../../framework/inline" }, + { "path": "../../framework/store" } ] } diff --git a/blocksuite/affine/block-data-view/tsconfig.json b/blocksuite/affine/block-data-view/tsconfig.json index 72e42713b8..2642e82451 100644 --- a/blocksuite/affine/block-data-view/tsconfig.json +++ b/blocksuite/affine/block-data-view/tsconfig.json @@ -1,29 +1,20 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "rootDir": "./src/", - "outDir": "./dist/", - "noEmit": false + "rootDir": "./src", + "outDir": "./dist", + "tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo" }, "include": ["./src"], "references": [ - { - "path": "../../framework" - }, - { - "path": "../model" - }, - { - "path": "../components" - }, - { - "path": "../shared" - }, - { - "path": "../data-view" - }, - { - "path": "../block-database" - } + { "path": "../block-database" }, + { "path": "../components" }, + { "path": "../model" }, + { "path": "../shared" }, + { "path": "../../framework/block-std" }, + { "path": "../data-view" }, + { "path": "../../framework/global" }, + { "path": "../../framework/inline" }, + { "path": "../../framework/store" } ] } diff --git a/blocksuite/affine/block-database/tsconfig.json b/blocksuite/affine/block-database/tsconfig.json index 38a17899d3..fd8c582c32 100644 --- a/blocksuite/affine/block-database/tsconfig.json +++ b/blocksuite/affine/block-database/tsconfig.json @@ -1,29 +1,20 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "rootDir": "./src/", - "outDir": "./dist/", - "noEmit": false + "rootDir": "./src", + "outDir": "./dist", + "tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo" }, "include": ["./src"], "references": [ - { - "path": "../../framework" - }, - { - "path": "../model" - }, - { - "path": "../components" - }, - { - "path": "../shared" - }, - { - "path": "../data-view" - }, - { - "path": "../widget-drag-handle" - } + { "path": "../components" }, + { "path": "../model" }, + { "path": "../shared" }, + { "path": "../widget-drag-handle" }, + { "path": "../../framework/block-std" }, + { "path": "../data-view" }, + { "path": "../../framework/global" }, + { "path": "../../framework/inline" }, + { "path": "../../framework/store" } ] } diff --git a/blocksuite/affine/block-divider/tsconfig.json b/blocksuite/affine/block-divider/tsconfig.json index e91b896c92..230fca2705 100644 --- a/blocksuite/affine/block-divider/tsconfig.json +++ b/blocksuite/affine/block-divider/tsconfig.json @@ -1,23 +1,18 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "rootDir": "./src/", - "outDir": "./dist/", - "noEmit": false + "rootDir": "./src", + "outDir": "./dist", + "tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo" }, "include": ["./src"], "references": [ - { - "path": "../../framework" - }, - { - "path": "../model" - }, - { - "path": "../components" - }, - { - "path": "../shared" - } + { "path": "../components" }, + { "path": "../model" }, + { "path": "../shared" }, + { "path": "../../framework/block-std" }, + { "path": "../../framework/global" }, + { "path": "../../framework/inline" }, + { "path": "../../framework/store" } ] } diff --git a/blocksuite/affine/block-edgeless-text/tsconfig.json b/blocksuite/affine/block-edgeless-text/tsconfig.json index 8d845ec2f7..445ea6a4cc 100644 --- a/blocksuite/affine/block-edgeless-text/tsconfig.json +++ b/blocksuite/affine/block-edgeless-text/tsconfig.json @@ -1,26 +1,19 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "rootDir": "./src/", - "outDir": "./dist/", - "noEmit": false + "rootDir": "./src", + "outDir": "./dist", + "tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo" }, "include": ["./src"], "references": [ - { - "path": "../../framework" - }, - { - "path": "../model" - }, - { - "path": "../components" - }, - { - "path": "../shared" - }, - { - "path": "../block-surface" - } + { "path": "../block-surface" }, + { "path": "../components" }, + { "path": "../model" }, + { "path": "../shared" }, + { "path": "../../framework/block-std" }, + { "path": "../../framework/global" }, + { "path": "../../framework/inline" }, + { "path": "../../framework/store" } ] } diff --git a/blocksuite/affine/block-embed/tsconfig.json b/blocksuite/affine/block-embed/tsconfig.json index 8d845ec2f7..445ea6a4cc 100644 --- a/blocksuite/affine/block-embed/tsconfig.json +++ b/blocksuite/affine/block-embed/tsconfig.json @@ -1,26 +1,19 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "rootDir": "./src/", - "outDir": "./dist/", - "noEmit": false + "rootDir": "./src", + "outDir": "./dist", + "tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo" }, "include": ["./src"], "references": [ - { - "path": "../../framework" - }, - { - "path": "../model" - }, - { - "path": "../components" - }, - { - "path": "../shared" - }, - { - "path": "../block-surface" - } + { "path": "../block-surface" }, + { "path": "../components" }, + { "path": "../model" }, + { "path": "../shared" }, + { "path": "../../framework/block-std" }, + { "path": "../../framework/global" }, + { "path": "../../framework/inline" }, + { "path": "../../framework/store" } ] } diff --git a/blocksuite/affine/block-frame/tsconfig.json b/blocksuite/affine/block-frame/tsconfig.json index e91b896c92..230fca2705 100644 --- a/blocksuite/affine/block-frame/tsconfig.json +++ b/blocksuite/affine/block-frame/tsconfig.json @@ -1,23 +1,18 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "rootDir": "./src/", - "outDir": "./dist/", - "noEmit": false + "rootDir": "./src", + "outDir": "./dist", + "tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo" }, "include": ["./src"], "references": [ - { - "path": "../../framework" - }, - { - "path": "../model" - }, - { - "path": "../components" - }, - { - "path": "../shared" - } + { "path": "../components" }, + { "path": "../model" }, + { "path": "../shared" }, + { "path": "../../framework/block-std" }, + { "path": "../../framework/global" }, + { "path": "../../framework/inline" }, + { "path": "../../framework/store" } ] } diff --git a/blocksuite/affine/block-image/tsconfig.json b/blocksuite/affine/block-image/tsconfig.json index e91b896c92..230fca2705 100644 --- a/blocksuite/affine/block-image/tsconfig.json +++ b/blocksuite/affine/block-image/tsconfig.json @@ -1,23 +1,18 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "rootDir": "./src/", - "outDir": "./dist/", - "noEmit": false + "rootDir": "./src", + "outDir": "./dist", + "tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo" }, "include": ["./src"], "references": [ - { - "path": "../../framework" - }, - { - "path": "../model" - }, - { - "path": "../components" - }, - { - "path": "../shared" - } + { "path": "../components" }, + { "path": "../model" }, + { "path": "../shared" }, + { "path": "../../framework/block-std" }, + { "path": "../../framework/global" }, + { "path": "../../framework/inline" }, + { "path": "../../framework/store" } ] } diff --git a/blocksuite/affine/block-latex/tsconfig.json b/blocksuite/affine/block-latex/tsconfig.json index c3a5e9a724..5617ed4f35 100644 --- a/blocksuite/affine/block-latex/tsconfig.json +++ b/blocksuite/affine/block-latex/tsconfig.json @@ -1,26 +1,19 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "rootDir": "./src/", - "outDir": "./dist/", - "noEmit": false + "rootDir": "./src", + "outDir": "./dist", + "tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo" }, "include": ["./src"], "references": [ - { - "path": "../../framework" - }, - { - "path": "../model" - }, - { - "path": "../components" - }, - { - "path": "../shared" - }, - { - "path": "../block-note" - } + { "path": "../block-note" }, + { "path": "../components" }, + { "path": "../model" }, + { "path": "../shared" }, + { "path": "../../framework/block-std" }, + { "path": "../../framework/global" }, + { "path": "../../framework/inline" }, + { "path": "../../framework/store" } ] } diff --git a/blocksuite/affine/block-list/tsconfig.json b/blocksuite/affine/block-list/tsconfig.json index e91b896c92..230fca2705 100644 --- a/blocksuite/affine/block-list/tsconfig.json +++ b/blocksuite/affine/block-list/tsconfig.json @@ -1,23 +1,18 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "rootDir": "./src/", - "outDir": "./dist/", - "noEmit": false + "rootDir": "./src", + "outDir": "./dist", + "tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo" }, "include": ["./src"], "references": [ - { - "path": "../../framework" - }, - { - "path": "../model" - }, - { - "path": "../components" - }, - { - "path": "../shared" - } + { "path": "../components" }, + { "path": "../model" }, + { "path": "../shared" }, + { "path": "../../framework/block-std" }, + { "path": "../../framework/global" }, + { "path": "../../framework/inline" }, + { "path": "../../framework/store" } ] } diff --git a/blocksuite/affine/block-note/tsconfig.json b/blocksuite/affine/block-note/tsconfig.json index e6302efe20..3f52439ca0 100644 --- a/blocksuite/affine/block-note/tsconfig.json +++ b/blocksuite/affine/block-note/tsconfig.json @@ -1,29 +1,20 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "rootDir": "./src/", - "outDir": "./dist/", - "noEmit": false + "rootDir": "./src", + "outDir": "./dist", + "tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo" }, "include": ["./src"], "references": [ - { - "path": "../../framework" - }, - { - "path": "../model" - }, - { - "path": "../components" - }, - { - "path": "../shared" - }, - { - "path": "../block-embed" - }, - { - "path": "../block-surface" - } + { "path": "../block-embed" }, + { "path": "../block-surface" }, + { "path": "../components" }, + { "path": "../model" }, + { "path": "../shared" }, + { "path": "../../framework/block-std" }, + { "path": "../../framework/global" }, + { "path": "../../framework/inline" }, + { "path": "../../framework/store" } ] } diff --git a/blocksuite/affine/block-paragraph/tsconfig.json b/blocksuite/affine/block-paragraph/tsconfig.json index e91b896c92..230fca2705 100644 --- a/blocksuite/affine/block-paragraph/tsconfig.json +++ b/blocksuite/affine/block-paragraph/tsconfig.json @@ -1,23 +1,18 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "rootDir": "./src/", - "outDir": "./dist/", - "noEmit": false + "rootDir": "./src", + "outDir": "./dist", + "tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo" }, "include": ["./src"], "references": [ - { - "path": "../../framework" - }, - { - "path": "../model" - }, - { - "path": "../components" - }, - { - "path": "../shared" - } + { "path": "../components" }, + { "path": "../model" }, + { "path": "../shared" }, + { "path": "../../framework/block-std" }, + { "path": "../../framework/global" }, + { "path": "../../framework/inline" }, + { "path": "../../framework/store" } ] } diff --git a/blocksuite/affine/block-surface-ref/tsconfig.json b/blocksuite/affine/block-surface-ref/tsconfig.json index e91b896c92..445ea6a4cc 100644 --- a/blocksuite/affine/block-surface-ref/tsconfig.json +++ b/blocksuite/affine/block-surface-ref/tsconfig.json @@ -1,23 +1,19 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "rootDir": "./src/", - "outDir": "./dist/", - "noEmit": false + "rootDir": "./src", + "outDir": "./dist", + "tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo" }, "include": ["./src"], "references": [ - { - "path": "../../framework" - }, - { - "path": "../model" - }, - { - "path": "../components" - }, - { - "path": "../shared" - } + { "path": "../block-surface" }, + { "path": "../components" }, + { "path": "../model" }, + { "path": "../shared" }, + { "path": "../../framework/block-std" }, + { "path": "../../framework/global" }, + { "path": "../../framework/inline" }, + { "path": "../../framework/store" } ] } diff --git a/blocksuite/affine/block-surface/tsconfig.json b/blocksuite/affine/block-surface/tsconfig.json index e91b896c92..230fca2705 100644 --- a/blocksuite/affine/block-surface/tsconfig.json +++ b/blocksuite/affine/block-surface/tsconfig.json @@ -1,23 +1,18 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "rootDir": "./src/", - "outDir": "./dist/", - "noEmit": false + "rootDir": "./src", + "outDir": "./dist", + "tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo" }, "include": ["./src"], "references": [ - { - "path": "../../framework" - }, - { - "path": "../model" - }, - { - "path": "../components" - }, - { - "path": "../shared" - } + { "path": "../components" }, + { "path": "../model" }, + { "path": "../shared" }, + { "path": "../../framework/block-std" }, + { "path": "../../framework/global" }, + { "path": "../../framework/inline" }, + { "path": "../../framework/store" } ] } diff --git a/blocksuite/affine/components/tsconfig.json b/blocksuite/affine/components/tsconfig.json index 2fc3c51a7e..803c56929e 100644 --- a/blocksuite/affine/components/tsconfig.json +++ b/blocksuite/affine/components/tsconfig.json @@ -1,20 +1,17 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "rootDir": "./src/", - "outDir": "./dist/", - "noEmit": false + "rootDir": "./src", + "outDir": "./dist", + "tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo" }, "include": ["./src"], "references": [ - { - "path": "../../framework" - }, - { - "path": "../shared" - }, - { - "path": "../model" - } + { "path": "../model" }, + { "path": "../shared" }, + { "path": "../../framework/block-std" }, + { "path": "../../framework/global" }, + { "path": "../../framework/inline" }, + { "path": "../../framework/store" } ] } diff --git a/blocksuite/affine/data-view/tsconfig.json b/blocksuite/affine/data-view/tsconfig.json index 0bbb2ef3fc..ad636e4176 100644 --- a/blocksuite/affine/data-view/tsconfig.json +++ b/blocksuite/affine/data-view/tsconfig.json @@ -1,21 +1,17 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "rootDir": "./src/", - "outDir": "./dist/", - "noEmit": false, - "noUncheckedIndexedAccess": true + "noUncheckedIndexedAccess": true, + "rootDir": "./src", + "outDir": "./dist", + "tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo" }, "include": ["./src"], "references": [ - { - "path": "../components" - }, - { - "path": "../shared" - }, - { - "path": "../../framework" - } + { "path": "../components" }, + { "path": "../shared" }, + { "path": "../../framework/block-std" }, + { "path": "../../framework/global" }, + { "path": "../../framework/store" } ] } diff --git a/blocksuite/affine/model/tsconfig.json b/blocksuite/affine/model/tsconfig.json index 6dc12160be..1d990701ae 100644 --- a/blocksuite/affine/model/tsconfig.json +++ b/blocksuite/affine/model/tsconfig.json @@ -1,14 +1,15 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "rootDir": "./src/", - "outDir": "./dist/", - "noEmit": false + "rootDir": "./src", + "outDir": "./dist", + "tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo" }, "include": ["./src"], "references": [ - { - "path": "../../framework" - } + { "path": "../../framework/block-std" }, + { "path": "../../framework/global" }, + { "path": "../../framework/inline" }, + { "path": "../../framework/store" } ] } diff --git a/blocksuite/affine/shared/tsconfig.json b/blocksuite/affine/shared/tsconfig.json index 2be2813029..ea3d3e5d94 100644 --- a/blocksuite/affine/shared/tsconfig.json +++ b/blocksuite/affine/shared/tsconfig.json @@ -1,17 +1,16 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "rootDir": "./src/", - "outDir": "./dist/", - "noEmit": false + "rootDir": "./src", + "outDir": "./dist", + "tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo" }, "include": ["./src"], "references": [ - { - "path": "../../framework" - }, - { - "path": "../model" - } + { "path": "../model" }, + { "path": "../../framework/block-std" }, + { "path": "../../framework/global" }, + { "path": "../../framework/inline" }, + { "path": "../../framework/store" } ] } diff --git a/blocksuite/affine/widget-drag-handle/tsconfig.json b/blocksuite/affine/widget-drag-handle/tsconfig.json index b2be9ad6b4..e0e3344cf1 100644 --- a/blocksuite/affine/widget-drag-handle/tsconfig.json +++ b/blocksuite/affine/widget-drag-handle/tsconfig.json @@ -1,35 +1,22 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "rootDir": "./src/", - "outDir": "./dist/", - "noEmit": false + "rootDir": "./src", + "outDir": "./dist", + "tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo" }, "include": ["./src"], "references": [ - { - "path": "../../framework" - }, - { - "path": "../model" - }, - { - "path": "../components" - }, - { - "path": "../shared" - }, - { - "path": "../block-paragraph" - }, - { - "path": "../block-surface" - }, - { - "path": "../block-note" - }, - { - "path": "../block-list" - } + { "path": "../block-list" }, + { "path": "../block-note" }, + { "path": "../block-paragraph" }, + { "path": "../block-surface" }, + { "path": "../components" }, + { "path": "../model" }, + { "path": "../shared" }, + { "path": "../../framework/block-std" }, + { "path": "../../framework/global" }, + { "path": "../../framework/inline" }, + { "path": "../../framework/store" } ] } diff --git a/blocksuite/affine/widget-frame-title/tsconfig.json b/blocksuite/affine/widget-frame-title/tsconfig.json index 515e24c087..b95de654df 100644 --- a/blocksuite/affine/widget-frame-title/tsconfig.json +++ b/blocksuite/affine/widget-frame-title/tsconfig.json @@ -1,20 +1,15 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "rootDir": "./src/", - "outDir": "./dist/", - "noEmit": false + "rootDir": "./src", + "outDir": "./dist", + "tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo" }, "include": ["./src"], "references": [ - { - "path": "../../framework" - }, - { - "path": "../model" - }, - { - "path": "../shared" - } + { "path": "../model" }, + { "path": "../shared" }, + { "path": "../../framework/block-std" }, + { "path": "../../framework/global" } ] } diff --git a/blocksuite/affine/widget-remote-selection/tsconfig.json b/blocksuite/affine/widget-remote-selection/tsconfig.json index 515e24c087..b95de654df 100644 --- a/blocksuite/affine/widget-remote-selection/tsconfig.json +++ b/blocksuite/affine/widget-remote-selection/tsconfig.json @@ -1,20 +1,15 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "rootDir": "./src/", - "outDir": "./dist/", - "noEmit": false + "rootDir": "./src", + "outDir": "./dist", + "tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo" }, "include": ["./src"], "references": [ - { - "path": "../../framework" - }, - { - "path": "../model" - }, - { - "path": "../shared" - } + { "path": "../model" }, + { "path": "../shared" }, + { "path": "../../framework/block-std" }, + { "path": "../../framework/global" } ] } diff --git a/blocksuite/affine/widget-scroll-anchoring/tsconfig.json b/blocksuite/affine/widget-scroll-anchoring/tsconfig.json index 515e24c087..b95de654df 100644 --- a/blocksuite/affine/widget-scroll-anchoring/tsconfig.json +++ b/blocksuite/affine/widget-scroll-anchoring/tsconfig.json @@ -1,20 +1,15 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "rootDir": "./src/", - "outDir": "./dist/", - "noEmit": false + "rootDir": "./src", + "outDir": "./dist", + "tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo" }, "include": ["./src"], "references": [ - { - "path": "../../framework" - }, - { - "path": "../model" - }, - { - "path": "../shared" - } + { "path": "../model" }, + { "path": "../shared" }, + { "path": "../../framework/block-std" }, + { "path": "../../framework/global" } ] } diff --git a/blocksuite/blocks/tsconfig.json b/blocksuite/blocks/tsconfig.json index def85d1502..06299daf0f 100644 --- a/blocksuite/blocks/tsconfig.json +++ b/blocksuite/blocks/tsconfig.json @@ -1,86 +1,39 @@ { "extends": "../tsconfig.json", "compilerOptions": { - "rootDir": "./src/", - "outDir": "./dist/", - "noEmit": false + "rootDir": "./src", + "outDir": "./dist", + "tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo" }, "include": ["./src"], "references": [ - { - "path": "../framework" - }, - { - "path": "../affine/model" - }, - { - "path": "../affine/shared" - }, - { - "path": "../affine/components" - }, - { - "path": "../affine/block-paragraph" - }, - { - "path": "../affine/block-latex" - }, - { - "path": "../affine/block-list" - }, - { - "path": "../affine/block-code" - }, - { - "path": "../affine/block-embed" - }, - { - "path": "../affine/block-frame" - }, - { - "path": "../affine/block-note" - }, - { - "path": "../affine/block-bookmark" - }, - { - "path": "../affine/block-database" - }, - { - "path": "../affine/block-attachment" - }, - { - "path": "../affine/block-image" - }, - { - "path": "../affine/block-edgeless-text" - }, - { - "path": "../affine/block-divider" - }, - { - "path": "../affine/block-surface" - }, - { - "path": "../affine/block-surface-ref" - }, - { - "path": "../affine/block-data-view" - }, - { - "path": "../affine/data-view" - }, - { - "path": "../affine/widget-scroll-anchoring" - }, - { - "path": "../affine/widget-remote-selection" - }, - { - "path": "../affine/widget-drag-handle" - }, - { - "path": "../affine/widget-frame-title" - } + { "path": "../affine/block-attachment" }, + { "path": "../affine/block-bookmark" }, + { "path": "../affine/block-code" }, + { "path": "../affine/block-data-view" }, + { "path": "../affine/block-database" }, + { "path": "../affine/block-divider" }, + { "path": "../affine/block-edgeless-text" }, + { "path": "../affine/block-embed" }, + { "path": "../affine/block-frame" }, + { "path": "../affine/block-image" }, + { "path": "../affine/block-latex" }, + { "path": "../affine/block-list" }, + { "path": "../affine/block-note" }, + { "path": "../affine/block-paragraph" }, + { "path": "../affine/block-surface" }, + { "path": "../affine/block-surface-ref" }, + { "path": "../affine/components" }, + { "path": "../affine/model" }, + { "path": "../affine/shared" }, + { "path": "../affine/widget-drag-handle" }, + { "path": "../affine/widget-frame-title" }, + { "path": "../affine/widget-remote-selection" }, + { "path": "../affine/widget-scroll-anchoring" }, + { "path": "../framework/block-std" }, + { "path": "../affine/data-view" }, + { "path": "../framework/global" }, + { "path": "../framework/inline" }, + { "path": "../framework/store" } ] } diff --git a/blocksuite/framework/block-std/tsconfig.json b/blocksuite/framework/block-std/tsconfig.json index 9651613fc9..a607fe5a21 100644 --- a/blocksuite/framework/block-std/tsconfig.json +++ b/blocksuite/framework/block-std/tsconfig.json @@ -1,20 +1,14 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "rootDir": "./src/", - "outDir": "./dist/", - "noEmit": false + "rootDir": "./src", + "outDir": "./dist", + "tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo" }, "include": ["./src"], "references": [ - { - "path": "../global" - }, - { - "path": "../store" - }, - { - "path": "../inline" - } + { "path": "../global" }, + { "path": "../inline" }, + { "path": "../store" } ] } diff --git a/blocksuite/framework/global/tsconfig.json b/blocksuite/framework/global/tsconfig.json index d36e6e78a2..1b8af1ed22 100644 --- a/blocksuite/framework/global/tsconfig.json +++ b/blocksuite/framework/global/tsconfig.json @@ -1,11 +1,11 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "rootDir": "./src/", - "outDir": "./dist/", - "noEmit": false + "rootDir": "./src", + "outDir": "./dist", + "tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo" }, - "include": ["./src", "index.d.ts"], + "include": ["./src"], // This package MUST NOT use any other package. "references": [] } diff --git a/blocksuite/framework/inline/tsconfig.json b/blocksuite/framework/inline/tsconfig.json index 043859522f..fc09da4980 100644 --- a/blocksuite/framework/inline/tsconfig.json +++ b/blocksuite/framework/inline/tsconfig.json @@ -1,14 +1,10 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "rootDir": "./src/", - "outDir": "./dist/", - "noEmit": false + "rootDir": "./src", + "outDir": "./dist", + "tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo" }, "include": ["./src"], - "references": [ - { - "path": "../global" - } - ] + "references": [{ "path": "../global" }] } diff --git a/blocksuite/framework/store/tsconfig.json b/blocksuite/framework/store/tsconfig.json index cc52afd31c..d1f5670428 100644 --- a/blocksuite/framework/store/tsconfig.json +++ b/blocksuite/framework/store/tsconfig.json @@ -1,20 +1,14 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "rootDir": "./src/", - "outDir": "./dist/", - "noEmit": false + "rootDir": "./src", + "outDir": "./dist", + "tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo" }, "include": ["./src"], "references": [ - { - "path": "../global" - }, - { - "path": "../sync" - }, - { - "path": "../inline" - } + { "path": "../global" }, + { "path": "../inline" }, + { "path": "../sync" } ] } diff --git a/blocksuite/framework/sync/tsconfig.json b/blocksuite/framework/sync/tsconfig.json index 41db4cf724..fc09da4980 100644 --- a/blocksuite/framework/sync/tsconfig.json +++ b/blocksuite/framework/sync/tsconfig.json @@ -1,14 +1,10 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "rootDir": "./src/", - "outDir": "./dist/", - "noEmit": false + "rootDir": "./src", + "outDir": "./dist", + "tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo" }, - "include": ["./src", "index.d.ts"], - "references": [ - { - "path": "../global" - } - ] + "include": ["./src"], + "references": [{ "path": "../global" }] } diff --git a/blocksuite/playground/tsconfig.json b/blocksuite/playground/tsconfig.json index 4aa50535ad..b3705427a8 100644 --- a/blocksuite/playground/tsconfig.json +++ b/blocksuite/playground/tsconfig.json @@ -1,20 +1,21 @@ { "extends": "../tsconfig.json", "compilerOptions": { - "target": "ESNext", - "useDefineForClassFields": false, - "lib": ["DOM", "DOM.Iterable", "ESNext"], - "allowJs": false, - "skipLibCheck": true, - "esModuleInterop": false, - "allowSyntheticDefaultImports": true, - "strict": true, - "forceConsistentCasingInFileNames": true, - "module": "ESNext", - "moduleResolution": "Bundler", - "noEmit": true, - "composite": false + "rootDir": ".", + "outDir": "./dist", + "tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo" }, "include": ["./apps", "./examples"], - "references": [{ "path": "./tsconfig.node.json" }] + "references": [ + { "path": "../affine/components" }, + { "path": "../affine/model" }, + { "path": "../framework/block-std" }, + { "path": "../blocks" }, + { "path": "../affine/data-view" }, + { "path": "../framework/global" }, + { "path": "../framework/inline" }, + { "path": "../presets" }, + { "path": "../framework/store" }, + { "path": "../framework/sync" } + ] } diff --git a/blocksuite/playground/tsconfig.node.json b/blocksuite/playground/tsconfig.node.json index e649a770c5..b0c70d6370 100644 --- a/blocksuite/playground/tsconfig.node.json +++ b/blocksuite/playground/tsconfig.node.json @@ -1,9 +1,11 @@ { + "extends": "../tsconfig.json", "compilerOptions": { - "composite": true, - "module": "ESNext", - "moduleResolution": "Node", - "allowSyntheticDefaultImports": true + "allowSyntheticDefaultImports": true, + "noUncheckedIndexedAccess": false, + "rootDir": ".", + "outDir": "./lib", + "tsBuildInfoFile": "./lib/tsconfig.tsbuildinfo" }, "include": ["vite.config.ts", "./scripts"] } diff --git a/blocksuite/playground/vite.config.ts b/blocksuite/playground/vite.config.ts index f48dd1adb0..c5b126c241 100644 --- a/blocksuite/playground/vite.config.ts +++ b/blocksuite/playground/vite.config.ts @@ -29,6 +29,8 @@ export function sourcemapExclude(): Plugin { map: { mappings: '' }, }; } + + return undefined; }, }; } @@ -157,10 +159,10 @@ const clearSiteDataPlugin = () => }) as Plugin; // https://vitejs.dev/config/ -export default ({ mode }) => { +export default defineConfig(({ mode }) => { process.env = { ...process.env, ...loadEnv(mode, __dirname, '') }; - return defineConfig({ + return { envDir: __dirname, define: { 'import.meta.env.PLAYGROUND_SERVER': JSON.stringify( @@ -200,7 +202,10 @@ export default ({ mode }) => { cache: false, maxParallelFileOps: Math.max(1, cpus().length - 1), onwarn(warning, defaultHandler) { - if (['EVAL', 'SOURCEMAP_ERROR'].includes(warning.code)) { + if ( + warning.code && + ['EVAL', 'SOURCEMAP_ERROR'].includes(warning.code) + ) { return; } @@ -252,10 +257,11 @@ export default ({ mode }) => { } return group; } + return undefined; } }, }, }, }, - }); -}; + }; +}); diff --git a/blocksuite/presets/tsconfig.json b/blocksuite/presets/tsconfig.json index dc021d6b61..494e4a1244 100644 --- a/blocksuite/presets/tsconfig.json +++ b/blocksuite/presets/tsconfig.json @@ -1,19 +1,19 @@ { "extends": "../tsconfig.json", "compilerOptions": { - "rootDir": "./src/", - "outDir": "./dist/", - "noEmit": false, - "resolveJsonModule": true, - "esModuleInterop": true + "rootDir": "./src", + "outDir": "./dist", + "tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo" }, "include": ["./src", "./src/**/*.json"], "references": [ - { - "path": "../framework" - }, - { - "path": "../blocks" - } + { "path": "../affine/block-surface" }, + { "path": "../affine/model" }, + { "path": "../affine/shared" }, + { "path": "../framework/block-std" }, + { "path": "../blocks" }, + { "path": "../framework/global" }, + { "path": "../framework/inline" }, + { "path": "../framework/store" } ] } diff --git a/blocksuite/tests-legacy/package.json b/blocksuite/tests-legacy/package.json index d282b92f31..b403dc4362 100644 --- a/blocksuite/tests-legacy/package.json +++ b/blocksuite/tests-legacy/package.json @@ -9,6 +9,7 @@ "dependencies": { "@blocksuite/affine-components": "workspace:*", "@blocksuite/affine-model": "workspace:*", + "@blocksuite/affine-shared": "workspace:*", "@blocksuite/block-std": "workspace:*", "@blocksuite/global": "workspace:*", "@blocksuite/presets": "workspace:*", diff --git a/blocksuite/tests-legacy/tsconfig.json b/blocksuite/tests-legacy/tsconfig.json index 8e57bdabb7..aee9dd0c98 100644 --- a/blocksuite/tests-legacy/tsconfig.json +++ b/blocksuite/tests-legacy/tsconfig.json @@ -2,8 +2,7 @@ "extends": "../tsconfig.json", "compilerOptions": { "baseUrl": ".", - "noEmit": true, - "composite": false, + "outDir": "./dist", "paths": { "@blocks/*": ["../blocks/src/*"], "@inline/*": ["../framework/inline/src/*"], @@ -11,5 +10,14 @@ "@playground/*": ["../playground/*"] } }, - "include": ["**.spec.ts", "**.test.ts", "**/**.ts"] + "include": ["**.spec.ts", "**.test.ts", "**/**.ts"], + "exclude": ["dist"], + "references": [ + { "path": "../affine/components" }, + { "path": "../affine/model" }, + { "path": "../affine/shared" }, + { "path": "../framework/block-std" }, + { "path": "../framework/global" }, + { "path": "../presets" } + ] } diff --git a/blocksuite/tsconfig.json b/blocksuite/tsconfig.json index b5390ef145..c44d0c4067 100644 --- a/blocksuite/tsconfig.json +++ b/blocksuite/tsconfig.json @@ -1,28 +1,7 @@ { - "extends": "../tsconfig.json", + // exists for easier extending in blocksuite packages + "extends": "../tsconfig.web.json", "compilerOptions": { - "useDefineForClassFields": false, - "module": "ESNext", - "lib": ["ESNext", "DOM", "DOM.Iterable"], - "moduleResolution": "Bundler", - "esModuleInterop": true, - "noEmitOnError": true, - "noUnusedLocals": true, - "noUnusedParameters": true, - "noImplicitReturns": true, - "noImplicitOverride": true, - "skipLibCheck": true, - "incremental": true, - "composite": true - }, - "files": [], - "ts-node": { - "esm": true, - "experimentalSpecifierResolution": "node", - "compilerOptions": { - "noUnusedLocals": false, - "noUnusedParameters": false, - "noImplicitReturns": false - } + "types": [] } } diff --git a/package.json b/package.json index 34d8401ce0..f6d3a06fbd 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,6 @@ "@swc/core": "^1.10.1", "@taplo/cli": "^0.7.0", "@toeverything/infra": "workspace:*", - "@types/affine__env": "workspace:*", "@types/eslint": "^9.6.1", "@types/node": "^20.17.10", "@typescript-eslint/parser": "^8.18.0", diff --git a/packages/backend/native/tsconfig.json b/packages/backend/native/tsconfig.json index 0aa6c6582e..32fe80bd50 100644 --- a/packages/backend/native/tsconfig.json +++ b/packages/backend/native/tsconfig.json @@ -1,9 +1,8 @@ { - "extends": "../../../tsconfig.json", + "extends": "../../../tsconfig.node.json", "compilerOptions": { - "noEmit": false, - "outDir": "lib", - "composite": true + "outDir": "./dist" }, - "include": ["index.d.ts"] + "include": ["index.d.ts"], + "references": [] } diff --git a/packages/backend/server/scripts/gen-auth-key.ts b/packages/backend/server/scripts/gen-auth-key.ts deleted file mode 100644 index 83770409c0..0000000000 --- a/packages/backend/server/scripts/gen-auth-key.ts +++ /dev/null @@ -1,16 +0,0 @@ -import crypto from 'node:crypto'; - -const { privateKey, publicKey } = crypto.generateKeyPairSync('ec', { - namedCurve: 'prime256v1', - publicKeyEncoding: { - type: 'spki', - format: 'pem', - }, - privateKeyEncoding: { - type: 'pkcs8', - format: 'pem', - }, -}); - -console.log('ECDSA Public Key:\n', publicKey); -console.log('ECDSA Private Key:\n', privateKey); diff --git a/packages/backend/server/scripts/test-send-local-mail.ts b/packages/backend/server/scripts/test-send-local-mail.ts deleted file mode 100644 index 50e0872abd..0000000000 --- a/packages/backend/server/scripts/test-send-local-mail.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { createTransport } from 'nodemailer'; - -const transport = createTransport({ - host: '0.0.0.0', - port: 1025, - secure: false, - auth: { - user: 'himself65', - pass: '123456', - }, -}); - -await transport.sendMail({ - from: 'noreply@toeverything.info', - to: 'himself65@outlook.com', - subject: 'test', - html: `
hello world
`, -}); diff --git a/packages/backend/server/src/plugins/captcha/service.ts b/packages/backend/server/src/plugins/captcha/service.ts index eb95f2c114..556b36b22b 100644 --- a/packages/backend/server/src/plugins/captcha/service.ts +++ b/packages/backend/server/src/plugins/captcha/service.ts @@ -47,7 +47,7 @@ export class CaptchaService { body: formData, method: 'POST', }); - const outcome = await result.json(); + const outcome: any = await result.json(); return ( !!outcome.success && diff --git a/packages/backend/server/src/plugins/copilot/workflow/service.ts b/packages/backend/server/src/plugins/copilot/workflow/service.ts index 33ce015eb8..51393dd575 100644 --- a/packages/backend/server/src/plugins/copilot/workflow/service.ts +++ b/packages/backend/server/src/plugins/copilot/workflow/service.ts @@ -23,7 +23,7 @@ export class CopilotWorkflowService { const node = workflow.get(nodeData.id); if (!node) { this.logger.error( - `Failed to init workflow ${name}: node ${nodeData.id} not found` + `Failed to init workflow ${graph.name}: node ${nodeData.id} not found` ); throw new Error(`Node ${nodeData.id} not found`); } @@ -31,7 +31,7 @@ export class CopilotWorkflowService { const edge = workflow.get(edgeId); if (!edge) { this.logger.error( - `Failed to init workflow ${name}: edge ${edgeId} not found in node ${nodeData.id}` + `Failed to init workflow ${graph.name}: edge ${edgeId} not found in node ${nodeData.id}` ); throw new Error(`Edge ${edgeId} not found`); } diff --git a/packages/backend/server/tests/tsconfig.json b/packages/backend/server/tests/tsconfig.json deleted file mode 100644 index 445549efc4..0000000000 --- a/packages/backend/server/tests/tsconfig.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "extends": "../../../../tsconfig.json", - "compilerOptions": { - "composite": true, - "target": "ES2022", - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "rootDir": ".", - "outDir": "../lib/tests", - "verbatimModuleSyntax": false, - "tsBuildInfoFile": "../lib/tests/.tsbuildinfo" - }, - "references": [ - { - "path": "../tsconfig.json" - }, - { - "path": "../../../../tests/kit/tsconfig.json" - } - ], - "include": ["."], - "exclude": [] -} diff --git a/packages/backend/server/tsconfig.json b/packages/backend/server/tsconfig.json index 683dd2961e..8636e9fc63 100644 --- a/packages/backend/server/tsconfig.json +++ b/packages/backend/server/tsconfig.json @@ -1,33 +1,18 @@ { - "extends": "../../../tsconfig.json", + "extends": "../../../tsconfig.node.json", "compilerOptions": { - "composite": true, - "target": "ES2022", - "module": "ESNext", "emitDecoratorMetadata": true, "experimentalDecorators": true, - "moduleResolution": "Bundler", "allowSyntheticDefaultImports": true, - "isolatedModules": false, - "resolveJsonModule": true, - "types": ["node"], - "outDir": "dist", - "noEmit": false, "verbatimModuleSyntax": false, - "rootDir": "./src" + "rootDir": "./src", + "outDir": "./dist", + "tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo" }, "include": ["./src"], - "exclude": ["dist", "lib", "tests"], "references": [ - { - "path": "./tsconfig.node.json" - }, - { - "path": "../native/tsconfig.json" - } - ], - "ts-node": { - "esm": true, - "experimentalSpecifierResolution": "node" - } + { "path": "../../../tests/kit" }, + { "path": "../../../tools/cli" }, + { "path": "../native" } + ] } diff --git a/packages/backend/server/tsconfig.node.json b/packages/backend/server/tsconfig.node.json index 05724654fb..e9b94c81b5 100644 --- a/packages/backend/server/tsconfig.node.json +++ b/packages/backend/server/tsconfig.node.json @@ -1,20 +1,10 @@ { - "extends": "../../../tsconfig.json", + "extends": "./tsconfig.json", "compilerOptions": { - "composite": true, - "target": "ESNext", - "module": "ESNext", - "resolveJsonModule": true, - "moduleResolution": "Node", - "allowSyntheticDefaultImports": true, - "outDir": "./lib/scripts", - "rootDir": "." + "allowJs": true, + "rootDir": ".", + "outDir": "./lib", + "tsBuildInfoFile": "./lib/tsconfig.tsbuildinfo" }, - "references": [ - { - "path": "../../../tests/kit" - } - ], - "include": ["scripts", "package.json"], - "exclude": ["tests"] + "include": ["./scripts", "./tests"] } diff --git a/packages/common/debug/.gitignore b/packages/common/debug/.gitignore deleted file mode 100644 index a65b41774a..0000000000 --- a/packages/common/debug/.gitignore +++ /dev/null @@ -1 +0,0 @@ -lib diff --git a/packages/common/debug/package.json b/packages/common/debug/package.json index f8e0483bcd..e16097d0ac 100644 --- a/packages/common/debug/package.json +++ b/packages/common/debug/package.json @@ -1,7 +1,9 @@ { "name": "@affine/debug", "private": true, - "main": "./src/index.ts", + "exports": { + ".": "./src/index.ts" + }, "dependencies": { "debug": "^4.4.0" }, diff --git a/packages/common/debug/tsconfig.json b/packages/common/debug/tsconfig.json index e2e300ba74..76d5d68d61 100644 --- a/packages/common/debug/tsconfig.json +++ b/packages/common/debug/tsconfig.json @@ -1,13 +1,10 @@ { - "extends": "../../../tsconfig.json", + "extends": "../../../tsconfig.web.json", "compilerOptions": { - "module": "ESNext", - "target": "ESNext", - "sourceMap": true, - "composite": true, - "noEmit": false, - "outDir": "lib" + "rootDir": "./src", + "outDir": "./dist", + "tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo" }, "include": ["./src"], - "exclude": ["node_modules"] + "references": [] } diff --git a/packages/common/env/.gitignore b/packages/common/env/.gitignore deleted file mode 100644 index a65b41774a..0000000000 --- a/packages/common/env/.gitignore +++ /dev/null @@ -1 +0,0 @@ -lib diff --git a/packages/common/env/src/global.ts b/packages/common/env/src/global.ts index bee0e979d4..10ef177ce4 100644 --- a/packages/common/env/src/global.ts +++ b/packages/common/env/src/global.ts @@ -1,61 +1,5 @@ import { UaHelper } from './ua-helper.js'; -export type BUILD_CONFIG_TYPE = { - debug: boolean; - distribution: 'web' | 'desktop' | 'admin' | 'mobile' | 'ios' | 'android'; - /** - * 'web' | 'desktop' | 'admin' - */ - isDesktopEdition: boolean; - /** - * 'mobile' - */ - isMobileEdition: boolean; - - isElectron: boolean; - isWeb: boolean; - isMobileWeb: boolean; - isIOS: boolean; - isAndroid: boolean; - isAdmin: boolean; - - // this is for the electron app - /** - * @deprecated need to be refactored - */ - serverUrlPrefix: string; - appVersion: string; - editorVersion: string; - appBuildType: 'stable' | 'beta' | 'internal' | 'canary'; - - githubUrl: string; - changelogUrl: string; - downloadUrl: string; - // see: tools/workers - imageProxyUrl: string; - linkPreviewUrl: string; -}; - -export type Environment = { - // Variant - isSelfHosted: boolean; - - // Device - isLinux: boolean; - isMacOs: boolean; - isIOS: boolean; - isSafari: boolean; - isWindows: boolean; - isFireFox: boolean; - isMobile: boolean; - isChrome: boolean; - isPwa: boolean; - chromeVersion?: number; - - // runtime configs - publicPath: string; -}; - export function setupGlobal() { if (globalThis.$AFFINE_SETUP) { return; diff --git a/packages/common/env/tsconfig.json b/packages/common/env/tsconfig.json index 4bbd8d0b79..2a7d3518f1 100644 --- a/packages/common/env/tsconfig.json +++ b/packages/common/env/tsconfig.json @@ -1,9 +1,11 @@ { - "extends": "../../../tsconfig.json", - "include": ["./src"], + "extends": "../../../tsconfig.web.json", "compilerOptions": { - "composite": true, - "noEmit": false, - "outDir": "lib" - } + "types": ["build-config", "affine__env"], + "rootDir": "./src", + "outDir": "./dist", + "tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo" + }, + "include": ["./src"], + "references": [{ "path": "../../../blocksuite/affine/all" }] } diff --git a/packages/common/infra/tsconfig.json b/packages/common/infra/tsconfig.json index a4ea7715ed..0fbc4070c2 100644 --- a/packages/common/infra/tsconfig.json +++ b/packages/common/infra/tsconfig.json @@ -1,17 +1,10 @@ { - "extends": "../../../tsconfig.json", + "extends": "../../../tsconfig.web.json", "include": ["./src"], "compilerOptions": { - "composite": true, - "noEmit": false, - "outDir": "lib" + "rootDir": "./src", + "outDir": "./dist", + "tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo" }, - "references": [ - { - "path": "../env" - }, - { - "path": "../debug" - } - ] + "references": [{ "path": "../debug" }, { "path": "../env" }] } diff --git a/packages/common/nbstore/tsconfig.json b/packages/common/nbstore/tsconfig.json index ca7aecca3a..5c091c14fb 100644 --- a/packages/common/nbstore/tsconfig.json +++ b/packages/common/nbstore/tsconfig.json @@ -1,20 +1,10 @@ { - "extends": "../../../tsconfig.json", + "extends": "../../../tsconfig.web.json", "include": ["./src"], "compilerOptions": { - "composite": true, - "noEmit": false, - "outDir": "lib" + "rootDir": "./src", + "outDir": "./dist", + "tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo" }, - "references": [ - { - "path": "../../frontend/graphql" - }, - { - "path": "../infra" - }, - { - "path": "../../../blocksuite/affine/all" - } - ] + "references": [{ "path": "../infra" }, { "path": "../../frontend/graphql" }] } diff --git a/packages/frontend/admin/package.json b/packages/frontend/admin/package.json index 835999306b..c66f42d4b2 100644 --- a/packages/frontend/admin/package.json +++ b/packages/frontend/admin/package.json @@ -67,6 +67,7 @@ "update-shadcn": "shadcn-ui add -p src/components/ui" }, "exports": { - "./*": "./src/*" + "./*": "./src/*.ts", + "./components/ui/*": "./src/components/ui/*.tsx" } } diff --git a/packages/frontend/admin/src/components/ui/toaster.tsx b/packages/frontend/admin/src/components/ui/toaster.tsx index ccc286cf7f..d470a849a6 100644 --- a/packages/frontend/admin/src/components/ui/toaster.tsx +++ b/packages/frontend/admin/src/components/ui/toaster.tsx @@ -6,7 +6,8 @@ import { ToastTitle, ToastViewport, } from '@affine/admin/components/ui/toast'; -import { useToast } from '@affine/admin/components/ui/use-toast'; + +import { useToast } from './use-toast'; export function Toaster() { const { toasts } = useToast(); diff --git a/packages/frontend/admin/tsconfig.json b/packages/frontend/admin/tsconfig.json index 0bcb4e62ad..2f1a1405df 100644 --- a/packages/frontend/admin/tsconfig.json +++ b/packages/frontend/admin/tsconfig.json @@ -1,17 +1,15 @@ { - "extends": "../../../tsconfig.json", + "extends": "../../../tsconfig.web.json", "include": ["./src"], "compilerOptions": { + "rootDir": "./src", "outDir": "./dist", - "allowJs": true, - "composite": true, - "verbatimModuleSyntax": false, - "jsx": "react-jsx" + "tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo" }, "references": [ + { "path": "../component" }, { "path": "../core" }, { "path": "../graphql" }, { "path": "../../common/infra" } - ], - "exclude": ["dist"] + ] } diff --git a/packages/frontend/apps/android/package.json b/packages/frontend/apps/android/package.json index d3bed147d4..379794453e 100644 --- a/packages/frontend/apps/android/package.json +++ b/packages/frontend/apps/android/package.json @@ -3,7 +3,6 @@ "version": "0.19.0", "description": "AFFiNE Desktop Web application", "private": true, - "browser": "src/index.tsx", "scripts": { "build": "affine bundle", "dev": "affine bundle --dev" diff --git a/packages/frontend/apps/android/tsconfig.json b/packages/frontend/apps/android/tsconfig.json index 0bb809226a..65b3d37ec5 100644 --- a/packages/frontend/apps/android/tsconfig.json +++ b/packages/frontend/apps/android/tsconfig.json @@ -1,12 +1,15 @@ { - "extends": "../../../../tsconfig.json", + "extends": "../../../../tsconfig.web.json", "compilerOptions": { - "composite": true, - "outDir": "lib", - "moduleResolution": "Bundler", - "types": ["affine__env"], - "rootDir": "./src" + "rootDir": "./src", + "outDir": "./dist", + "tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo" }, "include": ["./src"], - "references": [{ "path": "../../core" }] + "references": [ + { "path": "../../component" }, + { "path": "../../core" }, + { "path": "../../i18n" }, + { "path": "../../../../blocksuite/affine/all" } + ] } diff --git a/packages/frontend/apps/electron-renderer/tsconfig.json b/packages/frontend/apps/electron-renderer/tsconfig.json index 250778f447..94ea68a849 100644 --- a/packages/frontend/apps/electron-renderer/tsconfig.json +++ b/packages/frontend/apps/electron-renderer/tsconfig.json @@ -1,17 +1,17 @@ { - "extends": "../../../../tsconfig.json", + "extends": "../../../../tsconfig.web.json", "compilerOptions": { - "composite": true, - "outDir": "lib", - "moduleResolution": "Bundler", - "types": ["affine__env"], - "rootDir": "./src" + "rootDir": "./src", + // dist is kept for webpack output + "outDir": "./lib", + "tsBuildInfoFile": "./lib/tsconfig.tsbuildinfo" }, "include": ["./src"], "references": [ + { "path": "../../component" }, { "path": "../../core" }, - { - "path": "../../electron-api" - } + { "path": "../../electron-api" }, + { "path": "../../i18n" }, + { "path": "../../../../tools/utils" } ] } diff --git a/packages/frontend/apps/electron/package.json b/packages/frontend/apps/electron/package.json index 06a434c75e..c1f80dce19 100644 --- a/packages/frontend/apps/electron/package.json +++ b/packages/frontend/apps/electron/package.json @@ -10,6 +10,15 @@ }, "description": "AFFiNE Desktop App", "homepage": "https://github.com/toeverything/AFFiNE", + "exports": { + "./helper/exposed": "./src/helper/exposed.ts", + "./main/exposed": "./src/main/exposed.ts", + "./preload/electron-api": "./src/preload/electron-api.ts", + "./preload/shared-storage": "./src/preload/shared-storage.ts", + "./main/shared-state-schema": "./src/main/shared-state-schema.ts", + "./main/updater/event": "./src/main/updater/event.ts", + "./main/windows-manager": "./src/main/windows-manager/index.ts" + }, "scripts": { "start": "electron .", "dev": "cross-env DEV_SERVER_URL=http://localhost:8080 node ./scripts/dev.ts", diff --git a/packages/frontend/apps/electron/src/main/ui/handlers.ts b/packages/frontend/apps/electron/src/main/ui/handlers.ts index 8ca0131d7f..9211f8d36a 100644 --- a/packages/frontend/apps/electron/src/main/ui/handlers.ts +++ b/packages/frontend/apps/electron/src/main/ui/handlers.ts @@ -106,7 +106,7 @@ export const uiHandlers = { link = 'https://api.fxtwitter.com/status/' + /\/status\/(.*)/.exec(link)?.[1]; try { - const { tweet } = await fetch(link).then(res => res.json()); + const { tweet } = (await fetch(link).then(res => res.json())) as any; return { title: tweet.author.name, icon: tweet.author.avatar_url, diff --git a/packages/frontend/apps/electron/src/main/windows-manager/context-menu.ts b/packages/frontend/apps/electron/src/main/windows-manager/context-menu.ts index ba1d670a44..9a6ce1fcd0 100644 --- a/packages/frontend/apps/electron/src/main/windows-manager/context-menu.ts +++ b/packages/frontend/apps/electron/src/main/windows-manager/context-menu.ts @@ -9,11 +9,14 @@ import { WebContentViewsManager, } from './tab-views'; -export const showTabContextMenu = async (tabId: string, viewIndex: number) => { +export const showTabContextMenu = async ( + tabId: string, + viewIndex: number +): Promise => { const workbenches = WebContentViewsManager.instance.tabViewsMeta.workbenches; const tabMeta = workbenches.find(w => w.id === tabId); if (!tabMeta) { - return; + return null; } const { resolve, promise } = Promise.withResolvers(); @@ -93,7 +96,7 @@ export const showTabContextMenu = async (tabId: string, viewIndex: number) => { ]; const menu = Menu.buildFromTemplate(template); menu.popup(); - // eslint-disable-next-line prefer-const + let unsub: (() => void) | undefined; const subscription = WebContentViewsManager.instance.tabAction$.subscribe( action => { diff --git a/packages/frontend/apps/electron/src/preload/electron-api.ts b/packages/frontend/apps/electron/src/preload/electron-api.ts index 5706a3d785..26b864ecdc 100644 --- a/packages/frontend/apps/electron/src/preload/electron-api.ts +++ b/packages/frontend/apps/electron/src/preload/electron-api.ts @@ -1,4 +1,6 @@ // Please add modules to `external` in `rollupOptions` to avoid wrong bundling. +import type { MessagePort } from 'node:worker_threads'; + import type { EventBasedChannel } from 'async-call-rpc'; import { AsyncCall } from 'async-call-rpc'; import { ipcRenderer } from 'electron'; @@ -135,12 +137,13 @@ const helperPort = new Promise(resolve => const createMessagePortChannel = (port: MessagePort): EventBasedChannel => { return { on(listener) { - port.onmessage = e => { + const listen = (e: MessageEvent) => { listener(e.data); }; + port.addEventListener('message', listen as any); port.start(); return () => { - port.onmessage = null; + port.removeEventListener('message', listen as any); try { port.close(); } catch (err) { @@ -246,10 +249,15 @@ export const events = { ...helperAPIs.events, }; -// Create MessagePort that can be used by web workers +/** + * Create MessagePort that can be used by web workers + * + * !!! + * SHOULD ONLY BE USED IN RENDERER PROCESS + * !!! + */ export function requestWebWorkerPort() { const ch = new MessageChannel(); - const localPort = ch.port1; const remotePort = ch.port2; @@ -274,6 +282,7 @@ export function requestWebWorkerPort() { const portId = crypto.randomUUID(); setTimeout(() => { + // @ts-expect-error this function should only be evaluated in the renderer process window.postMessage( { type: 'electron:request-api-port', diff --git a/packages/frontend/apps/electron/tsconfig.json b/packages/frontend/apps/electron/tsconfig.json index 2b455fb9ea..0d9fb082df 100644 --- a/packages/frontend/apps/electron/tsconfig.json +++ b/packages/frontend/apps/electron/tsconfig.json @@ -1,45 +1,16 @@ { - "extends": "../../../../tsconfig.json", + "extends": "../../../../tsconfig.node.json", "compilerOptions": { - "composite": true, - "skipLibCheck": true, - "target": "ES2022", - "module": "ESNext", - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "types": ["node", "affine__env"], - "outDir": "lib", - "moduleResolution": "Bundler", - "resolveJsonModule": true, - "noImplicitOverride": true, - "paths": { - "@toeverything/infra/*": ["../../common/infra/src/*"] - } + "rootDir": "./src", + "outDir": "./dist", + "tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo" }, "include": ["./src"], - "exclude": ["renderer", "node_modules", "lib", "dist", "**/__tests__/**/*"], "references": [ - { - "path": "../../../frontend/native" - }, - { - "path": "../../../common/infra" - }, - { - "path": "../../../common/env" - }, - { - "path": "./tsconfig.node.json" - }, - { - "path": "../../../../tests/kit" - }, - { - "path": "../../../../tools/utils" - } - ], - "ts-node": { - "esm": true, - "experimentalSpecifierResolution": "node" - } + { "path": "../../../../tests/kit" }, + { "path": "../../../../tools/utils" }, + { "path": "../../native" }, + { "path": "../../../common/nbstore" }, + { "path": "../../../common/infra" } + ] } diff --git a/packages/frontend/apps/electron/tsconfig.node.json b/packages/frontend/apps/electron/tsconfig.node.json index 2fcb612fd0..1ea724cf58 100644 --- a/packages/frontend/apps/electron/tsconfig.node.json +++ b/packages/frontend/apps/electron/tsconfig.node.json @@ -1,26 +1,9 @@ { - "extends": "../../../../tsconfig.json", + "extends": "./tsconfig.json", "compilerOptions": { - "composite": true, - "target": "ESNext", - "module": "ESNext", - "resolveJsonModule": true, - "moduleResolution": "bundler", - "allowSyntheticDefaultImports": true, - "noEmit": false, - "outDir": "./lib/scripts", - "types": ["node", "affine__env"], - "allowJs": true + "rootDir": ".", + "outDir": "./lib", + "tsBuildInfoFile": "./lib/tsconfig.tsbuildinfo" }, - "include": ["./scripts"], - "exclude": ["./renderer"], - "ts-node": { - "esm": true, - "experimentalSpecifierResolution": "node" - }, - "references": [ - { - "path": "../../../../tools/utils" - } - ] + "include": ["./test", "./scripts", "./vitest.config.ts"] } diff --git a/packages/frontend/apps/electron/tsconfig.test.json b/packages/frontend/apps/electron/tsconfig.test.json deleted file mode 100644 index 316f9c4e98..0000000000 --- a/packages/frontend/apps/electron/tsconfig.test.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "extends": "../../../../tsconfig.json", - "compilerOptions": { - "composite": true, - "target": "ESNext", - "module": "ESNext", - "resolveJsonModule": true, - "moduleResolution": "Node", - "allowSyntheticDefaultImports": true, - "noEmit": false, - "outDir": "./lib/tests", - "types": ["node", "affine__env"], - "allowJs": true - }, - "references": [ - { - "path": "./tsconfig.json" - } - ], - "include": ["./test"] -} diff --git a/packages/frontend/apps/ios/src/fetch.ts b/packages/frontend/apps/ios/src/fetch.ts index 4800e86094..cc7061e4cf 100644 --- a/packages/frontend/apps/ios/src/fetch.ts +++ b/packages/frontend/apps/ios/src/fetch.ts @@ -23,7 +23,6 @@ const readFileAsBase64 = (file: File) => }); const convertFormData = async (formData: FormData) => { const newFormData = []; - // @ts-expect-error FormData.entries for (const pair of formData.entries()) { const [key, value] = pair; if (value instanceof File) { @@ -47,7 +46,7 @@ const convertBody = async (body: unknown, contentType: string) => { if (body instanceof ReadableStream) { const reader = body.getReader(); const chunks = []; - // eslint-disable-next-line no-constant-condition + while (true) { const { done, value } = await reader.read(); if (done) break; @@ -129,7 +128,6 @@ export function configureFetchProvider(framework: Framework) { console.time(tag); try { const { body } = request; - // @ts-expect-error Headers.entries const optionHeaders = Object.fromEntries(request.headers.entries()); const { data: requestData, diff --git a/packages/frontend/apps/ios/src/index.tsx b/packages/frontend/apps/ios/src/index.tsx index 70470613e1..f6f8a74736 100644 --- a/packages/frontend/apps/ios/src/index.tsx +++ b/packages/frontend/apps/ios/src/index.tsx @@ -50,7 +50,7 @@ function main() { } function mountApp() { - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + // oxlint-disable-next-line @typescript-eslint/no-non-null-assertion const root = document.getElementById('app')!; createRoot(root).render( diff --git a/packages/frontend/apps/ios/tsconfig.json b/packages/frontend/apps/ios/tsconfig.json index 3ff8bf63c7..3a1e2fb196 100644 --- a/packages/frontend/apps/ios/tsconfig.json +++ b/packages/frontend/apps/ios/tsconfig.json @@ -1,16 +1,17 @@ { - "extends": "../../../../tsconfig.json", + "extends": "../../../../tsconfig.web.json", "compilerOptions": { - "composite": true, - "outDir": "lib", - "moduleResolution": "Bundler", - "types": ["affine__env"], - "rootDir": "./src" + "rootDir": "./src", + "outDir": "./dist", + "tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo" }, "include": ["./src"], "references": [ + { "path": "../../component" }, { "path": "../../core" }, - { "path": "../../native" }, - { "path": "../../../common/nbstore" } + { "path": "../../i18n" }, + { "path": "../../../../blocksuite/affine/all" }, + { "path": "../../../common/infra" }, + { "path": "../../native" } ] } diff --git a/packages/frontend/apps/mobile/tsconfig.json b/packages/frontend/apps/mobile/tsconfig.json index 0bb809226a..65b3d37ec5 100644 --- a/packages/frontend/apps/mobile/tsconfig.json +++ b/packages/frontend/apps/mobile/tsconfig.json @@ -1,12 +1,15 @@ { - "extends": "../../../../tsconfig.json", + "extends": "../../../../tsconfig.web.json", "compilerOptions": { - "composite": true, - "outDir": "lib", - "moduleResolution": "Bundler", - "types": ["affine__env"], - "rootDir": "./src" + "rootDir": "./src", + "outDir": "./dist", + "tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo" }, "include": ["./src"], - "references": [{ "path": "../../core" }] + "references": [ + { "path": "../../component" }, + { "path": "../../core" }, + { "path": "../../i18n" }, + { "path": "../../../../blocksuite/affine/all" } + ] } diff --git a/packages/frontend/apps/web/src/index.tsx b/packages/frontend/apps/web/src/index.tsx index ed4abc2710..67dcbe2bac 100644 --- a/packages/frontend/apps/web/src/index.tsx +++ b/packages/frontend/apps/web/src/index.tsx @@ -43,7 +43,7 @@ function main() { } function mountApp() { - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + // oxlint-disable-next-line @typescript-eslint/no-non-null-assertion const root = document.getElementById('app')!; createRoot(root).render( diff --git a/packages/frontend/apps/web/tsconfig.json b/packages/frontend/apps/web/tsconfig.json index 0bb809226a..eb999e4a26 100644 --- a/packages/frontend/apps/web/tsconfig.json +++ b/packages/frontend/apps/web/tsconfig.json @@ -1,12 +1,14 @@ { - "extends": "../../../../tsconfig.json", + "extends": "../../../../tsconfig.web.json", "compilerOptions": { - "composite": true, - "outDir": "lib", - "moduleResolution": "Bundler", - "types": ["affine__env"], - "rootDir": "./src" + "rootDir": "./src", + "outDir": "./dist", + "tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo" }, "include": ["./src"], - "references": [{ "path": "../../core" }] + "references": [ + { "path": "../../component" }, + { "path": "../../core" }, + { "path": "../../i18n" } + ] } diff --git a/packages/frontend/component/src/components/auth-components/onboarding-page.tsx b/packages/frontend/component/src/components/auth-components/onboarding-page.tsx index 50ba98eba4..a225b2a92d 100644 --- a/packages/frontend/component/src/components/auth-components/onboarding-page.tsx +++ b/packages/frontend/component/src/components/auth-components/onboarding-page.tsx @@ -2,7 +2,6 @@ import { ArrowRightSmallIcon } from '@blocksuite/icons/rc'; import clsx from 'clsx'; import { useMemo, useState } from 'react'; import type { Location } from 'react-router-dom'; -// eslint-disable-next-line @typescript-eslint/no-restricted-imports import { useLocation, useNavigate } from 'react-router-dom'; import useSWR from 'swr'; diff --git a/packages/frontend/component/src/components/global-loading/index.tsx b/packages/frontend/component/src/components/global-loading/index.tsx index 7d4f53d12b..412d1fbceb 100644 --- a/packages/frontend/component/src/components/global-loading/index.tsx +++ b/packages/frontend/component/src/components/global-loading/index.tsx @@ -1,5 +1,6 @@ export { type GlobalLoadingEvent, + globalLoadingEventsAtom, pushGlobalLoadingEventAtom, resolveGlobalLoadingEventAtom, } from './index.jotai'; diff --git a/packages/frontend/component/tsconfig.json b/packages/frontend/component/tsconfig.json index d22b9c1cfd..9d2d1396c3 100644 --- a/packages/frontend/component/tsconfig.json +++ b/packages/frontend/component/tsconfig.json @@ -1,6 +1,5 @@ { - "extends": "../../../tsconfig.json", - "exclude": ["lib"], + "extends": "../../../tsconfig.web.json", "include": [ "./src/**/*", "./src/**/*.json", @@ -8,25 +7,15 @@ "./.storybook" ], "compilerOptions": { - "composite": true, - "noEmit": false, - "outDir": "lib" + "rootDir": ".", + "outDir": "./dist", + "tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo" }, "references": [ - { - "path": "../../frontend/i18n" - }, - { - "path": "../../frontend/electron-api" - }, - { - "path": "../../frontend/graphql" - }, - { - "path": "../../common/debug" - }, - { - "path": "../../common/infra" - } + { "path": "../../common/debug" }, + { "path": "../electron-api" }, + { "path": "../graphql" }, + { "path": "../i18n" }, + { "path": "../../../blocksuite/affine/all" } ] } diff --git a/packages/frontend/core/src/desktop/pages/root/global-loading/index.tsx b/packages/frontend/core/src/desktop/pages/root/global-loading/index.tsx index 8e11e1d31c..1d93e9de59 100644 --- a/packages/frontend/core/src/desktop/pages/root/global-loading/index.tsx +++ b/packages/frontend/core/src/desktop/pages/root/global-loading/index.tsx @@ -1,5 +1,5 @@ import { Loading } from '@affine/component'; -import { globalLoadingEventsAtom } from '@affine/component/global-loading/index.jotai'; +import { globalLoadingEventsAtom } from '@affine/component/global-loading'; import { useAtomValue } from 'jotai'; import { type ReactNode, useEffect, useState } from 'react'; diff --git a/packages/frontend/core/src/modules/desktop-api/entities/electron-api.ts b/packages/frontend/core/src/modules/desktop-api/entities/electron-api.ts index 2342311420..eadba8592a 100644 --- a/packages/frontend/core/src/modules/desktop-api/entities/electron-api.ts +++ b/packages/frontend/core/src/modules/desktop-api/entities/electron-api.ts @@ -1,4 +1,4 @@ -/* eslint-disable @typescript-eslint/no-non-null-assertion */ +/* oxlint-disable @typescript-eslint/no-non-null-assertion */ import { Entity } from '@toeverything/infra'; import type { DesktopApiProvider } from '../provider'; diff --git a/packages/frontend/core/src/modules/desktop-api/provider/index.ts b/packages/frontend/core/src/modules/desktop-api/provider/index.ts index ce754ce5b8..95b1f65d40 100644 --- a/packages/frontend/core/src/modules/desktop-api/provider/index.ts +++ b/packages/frontend/core/src/modules/desktop-api/provider/index.ts @@ -1,5 +1,5 @@ -import type { AppInfo } from '@affine/electron/preload/electron-api'; import type { + AppInfo, ClientEvents, ClientHandler, SharedStorage, diff --git a/packages/frontend/core/tsconfig.json b/packages/frontend/core/tsconfig.json index 5d766cd108..3ffa0ca599 100644 --- a/packages/frontend/core/tsconfig.json +++ b/packages/frontend/core/tsconfig.json @@ -1,33 +1,19 @@ { - "extends": "../../../tsconfig.json", + "extends": "../../../tsconfig.web.json", "compilerOptions": { - "outDir": "lib", - "typeRoots": ["../../../node_modules", "../../../node_modules/@types"], - "types": ["webpack-env", "ses", "affine__env"] + "rootDir": "./src", + "outDir": "./dist", + "tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo" }, - "include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.json"], - "exclude": ["node_modules"], + "include": ["./src", "src/**/*.json"], "references": [ - { - "path": "../../frontend/component" - }, - { - "path": "../../frontend/graphql" - }, - { - "path": "../../frontend/i18n" - }, - { - "path": "../../frontend/electron-api" - }, - { - "path": "../../common/debug" - }, - { - "path": "../../common/env" - }, - { - "path": "../../../blocksuite/affine/all" - } + { "path": "../component" }, + { "path": "../../common/debug" }, + { "path": "../electron-api" }, + { "path": "../../common/env" }, + { "path": "../graphql" }, + { "path": "../i18n" }, + { "path": "../track" }, + { "path": "../../../blocksuite/affine/all" } ] } diff --git a/packages/frontend/electron-api/package.json b/packages/frontend/electron-api/package.json index dcc6aad30f..65bf5c3967 100644 --- a/packages/frontend/electron-api/package.json +++ b/packages/frontend/electron-api/package.json @@ -10,5 +10,8 @@ }, "dependencies": { "async-call-rpc": "^6.4.2" + }, + "devDependencies": { + "@affine/electron": "workspace:*" } } diff --git a/packages/frontend/electron-api/src/index.ts b/packages/frontend/electron-api/src/index.ts index 33a8f9d2be..6adb44d93a 100644 --- a/packages/frontend/electron-api/src/index.ts +++ b/packages/frontend/electron-api/src/index.ts @@ -6,7 +6,7 @@ import type { events as mainEvents, handlers as mainHandlers, } from '@affine/electron/main/exposed'; -import type { appInfo as exposedAppInfo } from '@affine/electron/preload/electron-api'; +import type { AppInfo } from '@affine/electron/preload/electron-api'; import type { SharedStorage } from '@affine/electron/preload/shared-storage'; type MainHandlers = typeof mainHandlers; @@ -29,9 +29,7 @@ export type ClientHandler = { } & HelperHandlers; export type ClientEvents = MainEvents & HelperEvents; -export const appInfo = (globalThis as any).__appInfo as - | typeof exposedAppInfo - | null; +export const appInfo = (globalThis as any).__appInfo as AppInfo | null; export const apis = (globalThis as any).__apis as ClientHandler | undefined; export const events = (globalThis as any).__events as ClientEvents | undefined; @@ -39,7 +37,7 @@ export const sharedStorage = (globalThis as any).__sharedStorage as | SharedStorage | undefined; -export type { SharedStorage }; +export type { AppInfo, SharedStorage }; export { type SpellCheckStateSchema, @@ -49,3 +47,7 @@ export { type WorkbenchViewModule, } from '@affine/electron/main/shared-state-schema'; export type { UpdateMeta } from '@affine/electron/main/updater/event'; +export type { + AddTabOption, + TabAction, +} from '@affine/electron/main/windows-manager'; diff --git a/packages/frontend/electron-api/tsconfig.json b/packages/frontend/electron-api/tsconfig.json index 04bc6f5556..1b1a0ec8ee 100644 --- a/packages/frontend/electron-api/tsconfig.json +++ b/packages/frontend/electron-api/tsconfig.json @@ -1,17 +1,10 @@ { - "extends": "../../../tsconfig.json", + "extends": "../../../tsconfig.web.json", "include": ["./src"], "compilerOptions": { - "composite": true, - "noEmit": false, - "outDir": "lib" + "rootDir": "./src", + "outDir": "./dist", + "tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo" }, - "references": [ - { - "path": "../../common/infra" - }, - { - "path": "../../frontend/apps/electron" - } - ] + "references": [{ "path": "../apps/electron" }] } diff --git a/packages/frontend/graphql/tsconfig.json b/packages/frontend/graphql/tsconfig.json index 239560eb21..77541e226c 100644 --- a/packages/frontend/graphql/tsconfig.json +++ b/packages/frontend/graphql/tsconfig.json @@ -1,14 +1,10 @@ { - "extends": "../../../tsconfig.json", + "extends": "../../../tsconfig.web.json", "include": ["./src"], "compilerOptions": { - "composite": true, - "noEmit": false, - "outDir": "lib" + "rootDir": "./src", + "outDir": "./dist", + "tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo" }, - "references": [ - { - "path": "../../common/env" - } - ] + "references": [{ "path": "../../common/env" }] } diff --git a/packages/frontend/i18n/tsconfig.json b/packages/frontend/i18n/tsconfig.json index 7292756207..6581598694 100644 --- a/packages/frontend/i18n/tsconfig.json +++ b/packages/frontend/i18n/tsconfig.json @@ -1,18 +1,14 @@ { - "extends": "../../../tsconfig.json", - "include": ["./src"], - "exclude": ["./src/resources", "./src/scripts"], + "extends": "../../../tsconfig.web.json", + "include": [ + "./src", + "./src/resources/*.json", + "./src/i18n-completenesses.json" + ], "compilerOptions": { - "noEmit": false, - "composite": true, - "outDir": "lib" + "rootDir": "./src", + "outDir": "./dist", + "tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo" }, - "references": [ - { - "path": "./tsconfig.resources.json" - }, - { - "path": "../../common/debug/tsconfig.json" - } - ] + "references": [{ "path": "../../common/debug" }] } diff --git a/packages/frontend/i18n/tsconfig.resources.json b/packages/frontend/i18n/tsconfig.resources.json deleted file mode 100644 index f59226b68c..0000000000 --- a/packages/frontend/i18n/tsconfig.resources.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "extends": "../../../tsconfig.json", - "compilerOptions": { - "composite": true, - "module": "NodeNext", - "resolveJsonModule": true, - "moduleResolution": "nodenext", - "outDir": "lib/resources", - "noEmit": false - }, - "include": ["./src/resources/**/*.ts", "./src/**/*.json"], - "exclude": ["dist", "lib"] -} diff --git a/packages/frontend/native/tsconfig.json b/packages/frontend/native/tsconfig.json index 9eea31a401..32fe80bd50 100644 --- a/packages/frontend/native/tsconfig.json +++ b/packages/frontend/native/tsconfig.json @@ -1,14 +1,8 @@ { - "extends": "../../../tsconfig.json", + "extends": "../../../tsconfig.node.json", "compilerOptions": { - "noEmit": false, - "outDir": "lib", - "composite": true, - "types": ["node"] + "outDir": "./dist" }, - "include": ["index.d.ts", "__tests__/**/*.mts"], - "ts-node": { - "esm": true, - "experimentalSpecifierResolution": "node" - } + "include": ["index.d.ts"], + "references": [] } diff --git a/packages/frontend/track/src/mixpanel.ts b/packages/frontend/track/src/mixpanel.ts index 7bfe8f3481..6d022a9c18 100644 --- a/packages/frontend/track/src/mixpanel.ts +++ b/packages/frontend/track/src/mixpanel.ts @@ -1,4 +1,3 @@ -// eslint-disable-next-line @typescript-eslint/no-unused-vars import { DebugLogger } from '@affine/debug'; import type { OverridedMixpanel } from 'mixpanel-browser'; import mixpanelBrowser from 'mixpanel-browser'; diff --git a/packages/frontend/track/tsconfig.json b/packages/frontend/track/tsconfig.json index 335e464abc..c4f3b34df8 100644 --- a/packages/frontend/track/tsconfig.json +++ b/packages/frontend/track/tsconfig.json @@ -1,15 +1,10 @@ { - "extends": "../../../tsconfig.json", + "extends": "../../../tsconfig.web.json", "compilerOptions": { - "outDir": "lib", - "typeRoots": ["../../../node_modules", "../../../node_modules/@types"], - "types": ["affine__env"] + "rootDir": "./src", + "outDir": "./dist", + "tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo" }, - "include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.json"], - "exclude": ["node_modules"], - "references": [ - { - "path": "../../common/debug" - } - ] + "include": ["./src"], + "references": [{ "path": "../../common/debug" }] } diff --git a/tests/affine-cloud-copilot/package.json b/tests/affine-cloud-copilot/package.json index ae094ad920..5f92f83865 100644 --- a/tests/affine-cloud-copilot/package.json +++ b/tests/affine-cloud-copilot/package.json @@ -1,6 +1,7 @@ { "name": "@affine-test/affine-cloud-copilot", "private": true, + "type": "module", "scripts": { "e2e": "yarn playwright test" }, diff --git a/tests/affine-cloud-copilot/tsconfig.json b/tests/affine-cloud-copilot/tsconfig.json index 0125ef7b40..379a590710 100644 --- a/tests/affine-cloud-copilot/tsconfig.json +++ b/tests/affine-cloud-copilot/tsconfig.json @@ -1,13 +1,10 @@ { - "extends": "../../tsconfig.json", + "extends": "../../tsconfig.web.json", "compilerOptions": { - "esModuleInterop": true, - "outDir": "lib" + "rootDir": "./e2e", + "outDir": "./dist", + "tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo" }, "include": ["e2e"], - "references": [ - { - "path": "../../tests/kit" - } - ] + "references": [{ "path": "../kit" }] } diff --git a/tests/affine-cloud/e2e/collaboration.spec.ts b/tests/affine-cloud/e2e/collaboration.spec.ts index 2c32719648..aa791b7a9b 100644 --- a/tests/affine-cloud/e2e/collaboration.spec.ts +++ b/tests/affine-cloud/e2e/collaboration.spec.ts @@ -1,6 +1,4 @@ -import { resolve } from 'node:path'; - -import { skipOnboarding, test } from '@affine-test/kit/playwright'; +import { Path, skipOnboarding, test } from '@affine-test/kit/playwright'; import { addUserToWorkspace, createRandomUser, @@ -172,7 +170,7 @@ test('can sync svg between different browsers', async ({ page, browser }) => { const fileChooserPromise = page.waitForEvent('filechooser'); await page.keyboard.press('Enter', { delay: 50 }); const fileChooser = await fileChooserPromise; - fileChooser.setFiles(resolve(__dirname, 'logo.svg')); + fileChooser.setFiles(Path.dir(import.meta.url).join('logo.svg').value); await expect(image).toBeVisible(); // the user should see the svg diff --git a/tests/affine-cloud/e2e/migration.spec.ts b/tests/affine-cloud/e2e/migration.spec.ts index f911fe4375..d27a0b3fd9 100644 --- a/tests/affine-cloud/e2e/migration.spec.ts +++ b/tests/affine-cloud/e2e/migration.spec.ts @@ -1,7 +1,6 @@ import { readFile } from 'node:fs/promises'; -import { resolve } from 'node:path'; -import { test } from '@affine-test/kit/playwright'; +import { Path, test } from '@affine-test/kit/playwright'; import { createRandomUser, deleteUser, @@ -72,7 +71,10 @@ test.skip('migration', async ({ page, browser }) => { await runPrisma(async client => { const sqls = ( await readFile( - resolve(__dirname, 'fixtures', '0.9.0-canary.9-snapshots.sql'), + Path.dir(import.meta.url).join( + 'fixtures', + '0.9.0-canary.9-snapshots.sql' + ).value, 'utf-8' ) ) diff --git a/tests/affine-cloud/package.json b/tests/affine-cloud/package.json index 3795ada4b5..7d641a1a13 100644 --- a/tests/affine-cloud/package.json +++ b/tests/affine-cloud/package.json @@ -1,6 +1,7 @@ { "name": "@affine-test/affine-cloud", "private": true, + "type": "module", "scripts": { "e2e": "yarn playwright test" }, diff --git a/tests/affine-cloud/tsconfig.json b/tests/affine-cloud/tsconfig.json index 0125ef7b40..379a590710 100644 --- a/tests/affine-cloud/tsconfig.json +++ b/tests/affine-cloud/tsconfig.json @@ -1,13 +1,10 @@ { - "extends": "../../tsconfig.json", + "extends": "../../tsconfig.web.json", "compilerOptions": { - "esModuleInterop": true, - "outDir": "lib" + "rootDir": "./e2e", + "outDir": "./dist", + "tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo" }, "include": ["e2e"], - "references": [ - { - "path": "../../tests/kit" - } - ] + "references": [{ "path": "../kit" }] } diff --git a/tests/affine-desktop-cloud/package.json b/tests/affine-desktop-cloud/package.json index 6d120a43e6..f956fffa46 100644 --- a/tests/affine-desktop-cloud/package.json +++ b/tests/affine-desktop-cloud/package.json @@ -1,6 +1,7 @@ { "name": "@affine-test/affine-desktop-cloud", "private": true, + "type": "module", "scripts": { "e2e": "yarn playwright test" }, diff --git a/tests/affine-desktop-cloud/tsconfig.json b/tests/affine-desktop-cloud/tsconfig.json index 0125ef7b40..379a590710 100644 --- a/tests/affine-desktop-cloud/tsconfig.json +++ b/tests/affine-desktop-cloud/tsconfig.json @@ -1,13 +1,10 @@ { - "extends": "../../tsconfig.json", + "extends": "../../tsconfig.web.json", "compilerOptions": { - "esModuleInterop": true, - "outDir": "lib" + "rootDir": "./e2e", + "outDir": "./dist", + "tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo" }, "include": ["e2e"], - "references": [ - { - "path": "../../tests/kit" - } - ] + "references": [{ "path": "../kit" }] } diff --git a/tests/affine-desktop/package.json b/tests/affine-desktop/package.json index 20324fb2b2..0db5350488 100644 --- a/tests/affine-desktop/package.json +++ b/tests/affine-desktop/package.json @@ -1,6 +1,7 @@ { "name": "@affine-test/affine-desktop", "private": true, + "type": "module", "scripts": { "e2e": "DEBUG=pw:browser yarn playwright test" }, diff --git a/tests/affine-desktop/playwright.config.ts b/tests/affine-desktop/playwright.config.ts index fa6315de87..414ac329e5 100644 --- a/tests/affine-desktop/playwright.config.ts +++ b/tests/affine-desktop/playwright.config.ts @@ -41,7 +41,7 @@ if (process.env.DEV_SERVER_URL) { ); config.webServer = [ { - command: 'yarn run -T affine bundle -p @affine/electron --dev', + command: 'yarn run -T affine bundle -p @affine/electron-renderer --dev', port: 8080, timeout: 120 * 1000, reuseExistingServer: !process.env.CI, diff --git a/tests/affine-desktop/tsconfig.json b/tests/affine-desktop/tsconfig.json index e06af8168b..5a058bda33 100644 --- a/tests/affine-desktop/tsconfig.json +++ b/tests/affine-desktop/tsconfig.json @@ -1,16 +1,13 @@ { - "extends": "../../tsconfig.json", + "extends": "../../tsconfig.web.json", "compilerOptions": { - "esModuleInterop": true, - "outDir": "lib" + "rootDir": "./e2e", + "outDir": "./dist", + "tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo" }, "include": ["e2e"], "references": [ - { - "path": "../../tests/kit" - }, - { - "path": "../../packages/frontend/electron-api" - } + { "path": "../kit" }, + { "path": "../../packages/frontend/electron-api" } ] } diff --git a/tests/affine-local/e2e/attachment-preview.spec.ts b/tests/affine-local/e2e/attachment-preview.spec.ts index b0b1283bc1..bf7cbb6f0e 100644 --- a/tests/affine-local/e2e/attachment-preview.spec.ts +++ b/tests/affine-local/e2e/attachment-preview.spec.ts @@ -1,6 +1,4 @@ -import path from 'node:path'; - -import { test } from '@affine-test/kit/playwright'; +import { Path, test } from '@affine-test/kit/playwright'; import { openHomePage } from '@affine-test/kit/utils/load-page'; import { clickNewPageButton, @@ -16,6 +14,8 @@ import { import type { Page } from '@playwright/test'; import { expect } from '@playwright/test'; +const fixturesDir = Path.dir(import.meta.url).join('../../fixtures'); + async function clickPeekViewControl(page: Page, n = 0) { await page.getByTestId('peek-view-control').nth(n).click(); await page.waitForTimeout(500); @@ -66,10 +66,7 @@ test('attachment preview should be shown', async ({ page }) => { await title.click(); await page.keyboard.press('Enter'); - await insertAttachment( - page, - path.join(__dirname, '../../fixtures/lorem-ipsum.pdf') - ); + await insertAttachment(page, fixturesDir.join('lorem-ipsum.pdf').value); await page.locator('affine-attachment').first().dblclick(); @@ -107,10 +104,7 @@ test('attachment preview can be expanded', async ({ page }) => { await title.click(); await page.keyboard.press('Enter'); - await insertAttachment( - page, - path.join(__dirname, '../../fixtures/lorem-ipsum.pdf') - ); + await insertAttachment(page, fixturesDir.join('lorem-ipsum.pdf').value); await page.locator('affine-attachment').first().dblclick(); @@ -161,10 +155,7 @@ test('should preview PDF in embed view', async ({ page }) => { await page.keyboard.press('Enter'); - await insertAttachment( - page, - path.join(__dirname, '../../fixtures/lorem-ipsum.pdf') - ); + await insertAttachment(page, fixturesDir.join('lorem-ipsum.pdf').value); const attachment = page.locator('affine-attachment'); await attachment.hover(); @@ -271,10 +262,7 @@ test('should sync name in pdf embed view', async ({ page }) => { await title.click(); await page.keyboard.press('Enter'); - await insertAttachment( - page, - path.join(__dirname, '../../fixtures/lorem-ipsum.pdf') - ); + await insertAttachment(page, fixturesDir.join('lorem-ipsum.pdf').value); const attachment = page.locator('affine-attachment'); await attachment.hover(); diff --git a/tests/affine-local/e2e/local-first-avatar.spec.ts b/tests/affine-local/e2e/local-first-avatar.spec.ts index f2f3577fa1..587ab051f6 100644 --- a/tests/affine-local/e2e/local-first-avatar.spec.ts +++ b/tests/affine-local/e2e/local-first-avatar.spec.ts @@ -1,6 +1,4 @@ -import { resolve } from 'node:path'; - -import { rootDir, test } from '@affine-test/kit/playwright'; +import { ProjectRoot, test } from '@affine-test/kit/playwright'; import { openHomePage } from '@affine-test/kit/utils/load-page'; import { clickNewPageButton, @@ -29,7 +27,7 @@ test('should create a page with a local first avatar and remove it', async ({ await page.getByTestId('current-workspace-label').click(); await page .getByTestId('upload-avatar') - .setInputFiles(resolve(rootDir, 'tests', 'fixtures', 'blue.png')); + .setInputFiles(ProjectRoot.join('tests', 'fixtures', 'blue.png').value); await page.mouse.click(0, 0); await page.getByTestId('workspace-name').click(); await page diff --git a/tests/affine-local/package.json b/tests/affine-local/package.json index a9cf83c572..394175dba3 100644 --- a/tests/affine-local/package.json +++ b/tests/affine-local/package.json @@ -1,6 +1,7 @@ { "name": "@affine-test/affine-local", "private": true, + "type": "module", "scripts": { "e2e": "yarn playwright test" }, diff --git a/tests/affine-local/tsconfig.json b/tests/affine-local/tsconfig.json index 0125ef7b40..95f29c8eff 100644 --- a/tests/affine-local/tsconfig.json +++ b/tests/affine-local/tsconfig.json @@ -1,13 +1,10 @@ { - "extends": "../../tsconfig.json", + "extends": "../../tsconfig.web.json", "compilerOptions": { - "esModuleInterop": true, - "outDir": "lib" + "rootDir": "./e2e", + "outDir": "./dist", + "tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo" }, - "include": ["e2e"], - "references": [ - { - "path": "../../tests/kit" - } - ] + "include": ["./e2e"], + "references": [{ "path": "../kit" }] } diff --git a/tests/affine-mobile/package.json b/tests/affine-mobile/package.json index f7d72cfbaf..9f86c2f67e 100644 --- a/tests/affine-mobile/package.json +++ b/tests/affine-mobile/package.json @@ -1,6 +1,7 @@ { "name": "@affine-test/affine-mobile", "private": true, + "type": "module", "scripts": { "e2e": "yarn playwright test" }, diff --git a/tests/affine-mobile/tsconfig.json b/tests/affine-mobile/tsconfig.json index 0125ef7b40..379a590710 100644 --- a/tests/affine-mobile/tsconfig.json +++ b/tests/affine-mobile/tsconfig.json @@ -1,13 +1,10 @@ { - "extends": "../../tsconfig.json", + "extends": "../../tsconfig.web.json", "compilerOptions": { - "esModuleInterop": true, - "outDir": "lib" + "rootDir": "./e2e", + "outDir": "./dist", + "tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo" }, "include": ["e2e"], - "references": [ - { - "path": "../../tests/kit" - } - ] + "references": [{ "path": "../kit" }] } diff --git a/tests/kit/.gitignore b/tests/kit/.gitignore deleted file mode 100644 index a65b41774a..0000000000 --- a/tests/kit/.gitignore +++ /dev/null @@ -1 +0,0 @@ -lib diff --git a/tests/kit/package.json b/tests/kit/package.json index 83601a8bc2..1c15cbc0c7 100644 --- a/tests/kit/package.json +++ b/tests/kit/package.json @@ -4,12 +4,13 @@ "type": "module", "version": "0.19.0", "exports": { - "./electron": "./electron.ts", - "./playwright": "./playwright.ts", - "./utils/*": "./utils/*.ts", - "./e2e-enhance/*": "./e2e-enhance/*.ts" + "./electron": "./src/electron.ts", + "./mobile": "./src/mobile.ts", + "./playwright": "./src/playwright.ts", + "./utils/*": "./src/utils/*.ts" }, "devDependencies": { + "@affine-tools/utils": "workspace:*", "@node-rs/argon2": "^2.0.2", "@playwright/test": "=1.49.1", "express": "^4.21.2", diff --git a/tests/kit/electron.ts b/tests/kit/src/electron.ts similarity index 90% rename from tests/kit/electron.ts rename to tests/kit/src/electron.ts index 84b831078c..bfa4e60457 100644 --- a/tests/kit/electron.ts +++ b/tests/kit/src/electron.ts @@ -1,6 +1,6 @@ import crypto from 'node:crypto'; -import { join, resolve } from 'node:path'; +import { Package } from '@affine-tools/utils/workspace'; import { expect, type Page } from '@playwright/test'; import fs from 'fs-extra'; import type { ElectronApplication } from 'playwright'; @@ -9,8 +9,7 @@ import { _electron as electron } from 'playwright'; import { test as base, testResultDir } from './playwright'; import { removeWithRetry } from './utils/utils'; -const projectRoot = join(__dirname, '..', '..'); -const electronRoot = join(projectRoot, 'packages/frontend/apps/electron'); +const electronRoot = new Package('@affine/electron').path; function generateUUID() { return crypto.randomUUID(); @@ -122,23 +121,23 @@ export const test = base.extend<{ }, }); }, - // eslint-disable-next-line no-empty-pattern + // oxlint-disable-next-line no-empty-pattern electronApp: async ({}, use) => { try { // a random id to avoid conflicts between tests const id = generateUUID(); - const dist = resolve(electronRoot, 'dist'); - const clonedDist = resolve(electronRoot, 'e2e-dist-' + id); + const dist = electronRoot.join('dist').value; + const clonedDist = electronRoot.join('e2e-dist-' + id).value; await fs.copy(dist, clonedDist); const packageJson = await fs.readJSON( - resolve(electronRoot, 'package.json') + electronRoot.join('package.json').value ); // overwrite the app name packageJson.name = 'affine-test-' + id; // overwrite the path to the main script packageJson.main = './main.js'; // write to the cloned dist - await fs.writeJSON(resolve(clonedDist, 'package.json'), packageJson); + await fs.writeJSON(clonedDist + '/package.json', packageJson); const env: Record = {}; for (const [key, value] of Object.entries(process.env)) { diff --git a/tests/kit/mobile.ts b/tests/kit/src/mobile.ts similarity index 100% rename from tests/kit/mobile.ts rename to tests/kit/src/mobile.ts diff --git a/tests/kit/playwright.ts b/tests/kit/src/playwright.ts similarity index 87% rename from tests/kit/playwright.ts rename to tests/kit/src/playwright.ts index baf7c06036..a259a746e8 100644 --- a/tests/kit/playwright.ts +++ b/tests/kit/src/playwright.ts @@ -1,25 +1,17 @@ -import { ok } from 'node:assert'; import crypto from 'node:crypto'; import fs from 'node:fs'; -import path, { resolve } from 'node:path'; +import path from 'node:path'; import process from 'node:process'; +import { Path, ProjectRoot } from '@affine-tools/utils/path'; import type { BrowserContext } from '@playwright/test'; import { test as baseTest } from '@playwright/test'; -export const rootDir = resolve(__dirname, '..', '..'); -// assert that the rootDir is the root of the project -ok( - // eslint-disable-next-line @typescript-eslint/no-var-requires - require(resolve(rootDir, 'package.json')).name.toLowerCase() === - '@affine/monorepo' -); - -export const testResultDir = resolve(rootDir, 'test-results'); - +export { Path, ProjectRoot }; +export const testResultDir = ProjectRoot.join('test-results').value; export const istanbulTempDir = process.env.ISTANBUL_TEMP_DIR ? path.resolve(process.env.ISTANBUL_TEMP_DIR) - : path.join(rootDir, '.nyc_output'); + : ProjectRoot.join('.nyc_output').value; function generateUUID() { return crypto.randomUUID(); diff --git a/tests/kit/utils/cloud.ts b/tests/kit/src/utils/cloud.ts similarity index 97% rename from tests/kit/utils/cloud.ts rename to tests/kit/src/utils/cloud.ts index 923ba1cf08..aa4e241c96 100644 --- a/tests/kit/utils/cloud.ts +++ b/tests/kit/src/utils/cloud.ts @@ -54,7 +54,7 @@ export const runPrisma = async ( cb: ( prisma: InstanceType< // oxlint-disable-next-line @typescript-eslint/consistent-type-imports - typeof import('../../../packages/backend/server/node_modules/@prisma/client').PrismaClient + typeof import('../../../../packages/backend/server/node_modules/@prisma/client').PrismaClient > ) => Promise ): Promise => { @@ -62,7 +62,7 @@ export const runPrisma = async ( PrismaClient, // oxlint-disable-next-line @typescript-eslint/consistent-type-imports } = await import( - '../../../packages/backend/server/node_modules/@prisma/client' + '../../../../packages/backend/server/node_modules/@prisma/client' ); const client = new PrismaClient({ datasourceUrl: diff --git a/tests/kit/utils/drop-file.ts b/tests/kit/src/utils/drop-file.ts similarity index 100% rename from tests/kit/utils/drop-file.ts rename to tests/kit/src/utils/drop-file.ts diff --git a/tests/kit/utils/editor.ts b/tests/kit/src/utils/editor.ts similarity index 100% rename from tests/kit/utils/editor.ts rename to tests/kit/src/utils/editor.ts diff --git a/tests/kit/utils/filter.ts b/tests/kit/src/utils/filter.ts similarity index 100% rename from tests/kit/utils/filter.ts rename to tests/kit/src/utils/filter.ts diff --git a/tests/kit/utils/image.ts b/tests/kit/src/utils/image.ts similarity index 81% rename from tests/kit/utils/image.ts rename to tests/kit/src/utils/image.ts index 852cb909e3..8d801507b3 100644 --- a/tests/kit/utils/image.ts +++ b/tests/kit/src/utils/image.ts @@ -1,5 +1,4 @@ -import { join } from 'node:path'; - +import { Path } from '@affine-tools/utils/path'; import type { Page } from '@playwright/test'; export async function importImage(page: Page, pathInFixtures: string) { @@ -17,7 +16,9 @@ export async function importImage(page: Page, pathInFixtures: string) { await page.keyboard.press('Enter'); await ( await fileChooser - ).setFiles(join(__dirname, '../../fixtures', pathInFixtures)); + ).setFiles( + Path.dir(import.meta.url).join('../../../fixtures', pathInFixtures).value + ); // TODO(@catsjuice): wait for image to be loaded more reliably await page.waitForTimeout(1000); } diff --git a/tests/kit/utils/keyboard.ts b/tests/kit/src/utils/keyboard.ts similarity index 100% rename from tests/kit/utils/keyboard.ts rename to tests/kit/src/utils/keyboard.ts diff --git a/tests/kit/utils/load-page.ts b/tests/kit/src/utils/load-page.ts similarity index 100% rename from tests/kit/utils/load-page.ts rename to tests/kit/src/utils/load-page.ts diff --git a/tests/kit/utils/page-logic.ts b/tests/kit/src/utils/page-logic.ts similarity index 100% rename from tests/kit/utils/page-logic.ts rename to tests/kit/src/utils/page-logic.ts diff --git a/tests/kit/utils/properties.ts b/tests/kit/src/utils/properties.ts similarity index 100% rename from tests/kit/utils/properties.ts rename to tests/kit/src/utils/properties.ts diff --git a/tests/kit/utils/setting.ts b/tests/kit/src/utils/setting.ts similarity index 100% rename from tests/kit/utils/setting.ts rename to tests/kit/src/utils/setting.ts diff --git a/tests/kit/utils/sidebar.ts b/tests/kit/src/utils/sidebar.ts similarity index 100% rename from tests/kit/utils/sidebar.ts rename to tests/kit/src/utils/sidebar.ts diff --git a/tests/kit/utils/url.ts b/tests/kit/src/utils/url.ts similarity index 100% rename from tests/kit/utils/url.ts rename to tests/kit/src/utils/url.ts diff --git a/tests/kit/utils/utils.ts b/tests/kit/src/utils/utils.ts similarity index 100% rename from tests/kit/utils/utils.ts rename to tests/kit/src/utils/utils.ts diff --git a/tests/kit/utils/workspace.ts b/tests/kit/src/utils/workspace.ts similarity index 100% rename from tests/kit/utils/workspace.ts rename to tests/kit/src/utils/workspace.ts diff --git a/tests/kit/tsconfig.json b/tests/kit/tsconfig.json index 5a45b77b64..de91285f6a 100644 --- a/tests/kit/tsconfig.json +++ b/tests/kit/tsconfig.json @@ -1,9 +1,10 @@ { - "extends": "../../tsconfig.json", + "extends": "../../tsconfig.web.json", "compilerOptions": { - "composite": true, - "noEmit": false, - "outDir": "lib" + "rootDir": "./src", + "outDir": "./dist", + "tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo" }, - "include": ["./*.ts", "utils", "e2e-enhance"] + "include": ["./src"], + "references": [{ "path": "../../tools/utils" }] } diff --git a/tools/@types/build-config/__all.d.ts b/tools/@types/build-config/__all.d.ts new file mode 100644 index 0000000000..818ee9e9e8 --- /dev/null +++ b/tools/@types/build-config/__all.d.ts @@ -0,0 +1,32 @@ +declare interface BUILD_CONFIG_TYPE { + debug: boolean; + distribution: 'web' | 'desktop' | 'admin' | 'mobile' | 'ios' | 'android'; + /** + * 'web' | 'desktop' | 'admin' + */ + isDesktopEdition: boolean; + /** + * 'mobile' + */ + isMobileEdition: boolean; + + isElectron: boolean; + isWeb: boolean; + isMobileWeb: boolean; + isIOS: boolean; + isAndroid: boolean; + isAdmin: boolean; + + appVersion: string; + editorVersion: string; + appBuildType: 'stable' | 'beta' | 'internal' | 'canary'; + + githubUrl: string; + changelogUrl: string; + downloadUrl: string; + // see: tools/workers + imageProxyUrl: string; + linkPreviewUrl: string; +} + +declare var BUILD_CONFIG: BUILD_CONFIG_TYPE; \ No newline at end of file diff --git a/tools/@types/build-config/package.json b/tools/@types/build-config/package.json new file mode 100644 index 0000000000..31ff5924b9 --- /dev/null +++ b/tools/@types/build-config/package.json @@ -0,0 +1,7 @@ +{ + "name": "@types/build-config", + "private": true, + "types": "./__all.d.ts", + "type": "module", + "version": "0.19.0" +} diff --git a/tools/@types/env/__all.d.ts b/tools/@types/env/__all.d.ts index 0a07cba982..3e7e84ed87 100644 --- a/tools/@types/env/__all.d.ts +++ b/tools/@types/env/__all.d.ts @@ -1,26 +1,6 @@ import '@affine/env/constant'; import '@blocksuite/affine/global/types' -import type { BUILD_CONFIG_TYPE, Environment } from '@affine/env/global'; - -declare global { - // eslint-disable-next-line no-var - var process: { - env: Record; - }; - // eslint-disable-next-line no-var - var environment: Environment; - // eslint-disable-next-line no-var - var BUILD_CONFIG: BUILD_CONFIG_TYPE; - // eslint-disable-next-line no-var - var $AFFINE_SETUP: boolean | undefined; - /** - * Inject by https://www.npmjs.com/package/@sentry/webpack-plugin - */ - // eslint-disable-next-line no-var - var SENTRY_RELEASE: { id: string } | undefined; -} - declare module '@blocksuite/affine/store' { interface DocMeta { /** @@ -35,3 +15,37 @@ declare module '@blocksuite/affine/store' { isPublic?: boolean; } } + + +declare global { + +declare type Environment = { + // Variant + isSelfHosted: boolean; + + // Device + isLinux: boolean; + isMacOs: boolean; + isIOS: boolean; + isSafari: boolean; + isWindows: boolean; + isFireFox: boolean; + isMobile: boolean; + isChrome: boolean; + isPwa: boolean; + chromeVersion?: number; + + // runtime configs + publicPath: string; +}; + + var process: { + env: Record; + }; + var environment: Environment; + var $AFFINE_SETUP: boolean | undefined; + /** + * Inject by https://www.npmjs.com/package/@sentry/webpack-plugin + */ + var SENTRY_RELEASE: { id: string } | undefined; +} diff --git a/tools/cli/hooks.js b/tools/cli/hooks.js index 9cf75089de..afd704db6d 100644 --- a/tools/cli/hooks.js +++ b/tools/cli/hooks.js @@ -4,7 +4,6 @@ const service = create({ experimentalSpecifierResolution: 'node', esm: true, transpileOnly: true, - swc: true, }); register(service); diff --git a/tools/cli/package.json b/tools/cli/package.json index 2d6a56b49f..b683c35174 100644 --- a/tools/cli/package.json +++ b/tools/cli/package.json @@ -28,6 +28,7 @@ "cssnano": "^7.0.6", "html-webpack-plugin": "^5.6.3", "inquirer": "^12.3.0", + "jsonc-parser": "^3.3.1", "lodash-es": "^4.17.21", "mime-types": "^2.1.35", "mini-css-extract-plugin": "^2.9.2", diff --git a/tools/cli/src/affine.ts b/tools/cli/src/affine.ts index d69acfaabe..30d0567b38 100644 --- a/tools/cli/src/affine.ts +++ b/tools/cli/src/affine.ts @@ -4,9 +4,9 @@ import { Cli } from 'clipanion'; import { BuildCommand } from './build'; import { BundleCommand } from './bundle'; import { CleanCommand } from './clean'; -import { CodegenCommand } from './codegen'; import type { CliContext } from './context'; import { DevCommand } from './dev'; +import { InitCommand } from './init'; import { RunCommand } from './run'; const cli = new Cli({ @@ -18,7 +18,7 @@ const cli = new Cli({ }); cli.register(RunCommand); -cli.register(CodegenCommand); +cli.register(InitCommand); cli.register(CleanCommand); cli.register(BuildCommand); cli.register(DevCommand); diff --git a/tools/cli/src/codegen.ts b/tools/cli/src/codegen.ts deleted file mode 100755 index 04f5dde410..0000000000 --- a/tools/cli/src/codegen.ts +++ /dev/null @@ -1,67 +0,0 @@ -import { readFileSync, writeFileSync } from 'node:fs'; - -import type { Path } from '@affine-tools/utils/path'; -import { type BuiltInParserName, format } from 'prettier'; - -import { Command } from './command'; - -export class CodegenCommand extends Command { - static override paths = [['init'], ['i'], ['codegen']]; - - async execute() { - this.logger.info('Generating Workspace configs'); - await this.generateWorkspaceFiles(); - this.logger.info('Workspace configs generated'); - } - - async generateWorkspaceFiles() { - const filesToGenerate: [Path, () => string, BuiltInParserName?][] = [ - [ - this.workspace.join('tsconfig.project.json'), - this.workspace.genProjectTsConfig.bind(this.workspace), - 'json', - ], - [ - this.workspace - .getPackage('@affine-tools/utils') - .join('src/workspace.gen.ts'), - this.workspace.genWorkspaceInfo.bind(this.workspace), - 'typescript', - ], - [this.workspace.join('oxlint.json'), this.genOxlintConfig, 'json'], - ]; - - for (const [path, content, formatter] of filesToGenerate) { - this.logger.info(`Output: ${path}`); - let file = content(); - if (formatter) { - file = await this.format(file, formatter); - } - writeFileSync(path.value, file); - } - } - - format(content: string, parser: BuiltInParserName) { - const config = JSON.parse( - readFileSync(this.workspace.join('.prettierrc').value, 'utf-8') - ); - return format(content, { parser, ...config }); - } - - genOxlintConfig = () => { - const json = JSON.parse( - readFileSync(this.workspace.join('oxlint.json').value, 'utf-8') - ); - - const ignoreList = readFileSync( - this.workspace.join('.prettierignore').value, - 'utf-8' - ) - .split('\n') - .filter(line => line.trim() && !line.startsWith('#')); - - json['ignorePatterns'] = ignoreList; - - return JSON.stringify(json, null, 2); - }; -} diff --git a/tools/cli/src/command.ts b/tools/cli/src/command.ts index dafc4c21f6..e73a5a7126 100644 --- a/tools/cli/src/command.ts +++ b/tools/cli/src/command.ts @@ -16,6 +16,10 @@ export abstract class Command extends BaseCommand { get workspace() { return this.context.workspace; } + + set workspace(workspace: Workspace) { + this.context.workspace = workspace; + } } export abstract class PackageCommand extends Command { diff --git a/tools/cli/src/init.ts b/tools/cli/src/init.ts new file mode 100755 index 0000000000..f59cc31e4e --- /dev/null +++ b/tools/cli/src/init.ts @@ -0,0 +1,140 @@ +import { readFileSync, writeFileSync } from 'node:fs'; + +import type { Path } from '@affine-tools/utils/path'; +import { type Package, Workspace } from '@affine-tools/utils/workspace'; +import { applyEdits, modify } from 'jsonc-parser'; +import { type BuiltInParserName, format } from 'prettier'; + +import { Command } from './command'; + +export class InitCommand extends Command { + static override paths = [['init'], ['i'], ['codegen']]; + + async execute() { + this.logger.info('Generating Workspace configs'); + await this.generateWorkspaceFiles(); + this.logger.info('Workspace configs generated'); + } + + async generateWorkspaceFiles() { + this.workspace = new Workspace(this.workspace.yarnList()); + const filesToGenerate: [ + Path, + (prev: string) => string, + BuiltInParserName?, + ][] = [ + [this.workspace.join('tsconfig.json'), this.genProjectTsConfig, 'json'], + [ + this.workspace + .getPackage('@affine-tools/utils') + .join('src/workspace.gen.ts'), + this.genWorkspaceInfo, + 'typescript', + ], + [this.workspace.join('oxlint.json'), this.genOxlintConfig, 'json'], + ...this.workspace.packages + .filter(p => p.isTsProject) + .map( + p => + [ + p.join('tsconfig.json'), + this.genPackageTsConfig.bind(this, p), + 'json', + ] as any + ), + ]; + + for (const [path, content, formatter] of filesToGenerate) { + this.logger.info(`Generating: ${path}`); + const previous = readFileSync(path.value, 'utf-8'); + let file = content(previous); + if (formatter) { + file = await this.format(file, formatter); + } + writeFileSync(path.value, file); + } + } + + format(content: string, parser: BuiltInParserName) { + const config = JSON.parse( + readFileSync(this.workspace.join('.prettierrc').value, 'utf-8') + ); + return format(content, { parser, ...config }); + } + + genOxlintConfig = () => { + const json = JSON.parse( + readFileSync(this.workspace.join('oxlint.json').value, 'utf-8') + ); + + const ignoreList = readFileSync( + this.workspace.join('.prettierignore').value, + 'utf-8' + ) + .split('\n') + .filter(line => line.trim() && !line.startsWith('#')); + + json['ignorePatterns'] = ignoreList; + + return JSON.stringify(json, null, 2); + }; + + genWorkspaceInfo = () => { + const list = this.workspace.yarnList(); + + const names = list.map(p => p.name); + + const content = [ + '// Auto generated content', + '// DO NOT MODIFY THIS FILE MANUALLY', + `export const PackageList = ${JSON.stringify(list, null, 2)}`, + '', + `export type PackageName = ${names.map(n => `'${n}'`).join(' | ')}`, + ]; + + return content.join('\n'); + }; + + genProjectTsConfig = (prev: string) => { + return applyEdits( + prev, + modify( + prev, + ['references'], + this.workspace.packages + .filter(p => p.isTsProject) + .filter( + p => + // NOTE(@forehalo): there two packages including outdated types, will be fixed when merged with affine-e2e + !['@blocksuite/playground', '@blocksuite/legacy-e2e'].includes( + p.name + ) + ) + .map(p => ({ path: p.path.relativePath })), + {} + ) + ); + }; + + genPackageTsConfig = (pkg: Package, prev: string) => { + // TODO(@forehalo): + // currently electron-api => electron => nbstore => electron-api + // this is a circular dependency, we need to fix it + // basically, the electron app don't need to use nbstore for exposing js bridge apis + if (pkg.name === '@affine/electron-api') { + return prev; + } + + return applyEdits( + prev, + modify( + prev, + ['references'], + pkg.deps + .filter(p => p.isTsProject) + .map(d => ({ path: pkg.path.relative(d.path.value) })), + {} + ) + ); + }; +} diff --git a/tools/cli/src/run.ts b/tools/cli/src/run.ts index d3b4ac1708..720dfaff7d 100644 --- a/tools/cli/src/run.ts +++ b/tools/cli/src/run.ts @@ -47,8 +47,8 @@ export class RunCommand extends PackageCommand { `Run custom 'xxx' script defined in @affine/web's package.json`, '$0 web xxx', ], - [`Run 'codegen' for workspace`, '$0 codegen'], - [`Clean tsbuild and dist under each package`, '$0 clean --ts --dist'], + [`Run 'init' for workspace`, '$0 init'], + [`Clean dist of each package`, '$0 clean --dist'], [`Clean node_modules under each package`, '$0 clean --node-modules'], [`Clean everything`, '$0 clean --all'], [`Run 'build' script for @affine/web`, '$0 build -p web'], diff --git a/tools/cli/src/webpack/html-plugin.ts b/tools/cli/src/webpack/html-plugin.ts index 99b1e1753e..3eee8b425f 100644 --- a/tools/cli/src/webpack/html-plugin.ts +++ b/tools/cli/src/webpack/html-plugin.ts @@ -1,7 +1,6 @@ import { execSync } from 'node:child_process'; import { readFileSync } from 'node:fs'; -import type { BUILD_CONFIG_TYPE } from '@affine/env/global'; import { Path, ProjectRoot } from '@affine-tools/utils/path'; import { Repository } from '@napi-rs/simple-git'; import HTMLPlugin from 'html-webpack-plugin'; diff --git a/tools/cli/tsconfig.json b/tools/cli/tsconfig.json index bbc4f69126..ab3bade10a 100644 --- a/tools/cli/tsconfig.json +++ b/tools/cli/tsconfig.json @@ -1,13 +1,10 @@ { - "extends": "../../tsconfig.json", + "extends": "../../tsconfig.node.json", "compilerOptions": { - "composite": true, "rootDir": "./src", - "outDir": "./dist" + "outDir": "./dist", + "tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo" }, "include": ["./src"], - "references": [ - { "path": "../../packages/common/env" }, - { "path": "../utils" } - ] + "references": [{ "path": "../utils" }] } diff --git a/tools/playstore-auto-bump/tsconfig.json b/tools/playstore-auto-bump/tsconfig.json index 7fd056768d..9b8fa83b8d 100644 --- a/tools/playstore-auto-bump/tsconfig.json +++ b/tools/playstore-auto-bump/tsconfig.json @@ -1,11 +1,8 @@ { - "extends": "../../tsconfig.json", + "extends": "../../tsconfig.node.json", "compilerOptions": { - "outDir": "dist", - "rootDir": ".", - "module": "ESNext", - "moduleResolution": "Bundler" + "outDir": "dist" }, - "exclude": ["dist"], - "include": ["index.ts"] + "files": ["index.ts"], + "references": [{ "path": "../cli" }, { "path": "../utils" }] } diff --git a/tools/utils/src/build-config.ts b/tools/utils/src/build-config.ts index c2615a3869..4c871e9dc6 100644 --- a/tools/utils/src/build-config.ts +++ b/tools/utils/src/build-config.ts @@ -1,4 +1,3 @@ -import type { BUILD_CONFIG_TYPE } from '@affine/env/global'; import type { Package } from '@affine-tools/utils/workspace'; import { PackageToDistribution } from './distribution'; @@ -37,7 +36,6 @@ export function getBuildConfig( isAdmin: distribution === 'admin', appBuildType: 'stable' as const, - serverUrlPrefix: 'https://app.affine.pro', appVersion: pkg.version, // editorVersion: pkg.dependencies['@blocksuite/affine'], editorVersion: pkg.version, @@ -52,7 +50,6 @@ export function getBuildConfig( return { ...this.stable, appBuildType: 'beta' as const, - serverUrlPrefix: 'https://insider.affine.pro', changelogUrl: 'https://github.com/toeverything/AFFiNE/releases', }; }, @@ -60,7 +57,6 @@ export function getBuildConfig( return { ...this.stable, appBuildType: 'internal' as const, - serverUrlPrefix: 'https://insider.affine.pro', changelogUrl: 'https://github.com/toeverything/AFFiNE/releases', }; }, @@ -69,7 +65,6 @@ export function getBuildConfig( return { ...this.stable, appBuildType: 'canary' as const, - serverUrlPrefix: 'https://affine.fail', changelogUrl: 'https://github.com/toeverything/AFFiNE/releases', }; }, @@ -87,10 +82,6 @@ export function getBuildConfig( changelogUrl: process.env.CHANGELOG_URL ?? currentBuildPreset.changelogUrl, }; - if (buildFlags.mode === 'development') { - currentBuildPreset.serverUrlPrefix = 'http://localhost:8080'; - } - return { ...currentBuildPreset, // environment preset will overwrite current build preset diff --git a/tools/utils/src/distribution.ts b/tools/utils/src/distribution.ts index f468247e61..5d32115c2a 100644 --- a/tools/utils/src/distribution.ts +++ b/tools/utils/src/distribution.ts @@ -1,5 +1,3 @@ -import type { BUILD_CONFIG_TYPE } from '@affine/env/global'; - import { PackageList, type PackageName } from './workspace.gen'; export const PackageToDistribution = new Map< diff --git a/tools/utils/src/path.ts b/tools/utils/src/path.ts index 4b00339595..644ae744ef 100644 --- a/tools/utils/src/path.ts +++ b/tools/utils/src/path.ts @@ -1,5 +1,5 @@ import { existsSync, statSync } from 'node:fs'; -import { join } from 'node:path'; +import { join, relative } from 'node:path'; import { fileURLToPath, pathToFileURL } from 'node:url'; export class Path { @@ -21,6 +21,10 @@ export class Path { return new Path(join(this.path, ...paths)); } + parent() { + return this.join('..'); + } + toString() { return this.path; } @@ -44,6 +48,10 @@ export class Path { toFileUrl() { return pathToFileURL(this.path); } + + relative(to: string) { + return relative(this.value, to); + } } export const ProjectRoot = Path.dir(import.meta.url).join('../../../'); diff --git a/tools/utils/src/workspace.gen.ts b/tools/utils/src/workspace.gen.ts index 6ed6e70517..249ff093b2 100644 --- a/tools/utils/src/workspace.gen.ts +++ b/tools/utils/src/workspace.gen.ts @@ -429,6 +429,7 @@ export const PackageList = [ workspaceDependencies: [ 'blocksuite/affine/components', 'blocksuite/affine/model', + 'blocksuite/affine/shared', 'blocksuite/framework/block-std', 'blocksuite/framework/global', 'blocksuite/presets', @@ -582,7 +583,7 @@ export const PackageList = [ { location: 'packages/frontend/electron-api', name: '@affine/electron-api', - workspaceDependencies: [], + workspaceDependencies: ['packages/frontend/apps/electron'], }, { location: 'packages/frontend/graphql', @@ -642,6 +643,11 @@ export const PackageList = [ { location: 'tests/kit', name: '@affine-test/kit', + workspaceDependencies: ['tools/utils'], + }, + { + location: 'tools/@types/build-config', + name: '@types/build-config', workspaceDependencies: [], }, { @@ -750,6 +756,7 @@ export type PackageName = | '@affine-test/affine-local' | '@affine-test/affine-mobile' | '@affine-test/kit' + | '@types/build-config' | '@types/affine__env' | '@affine/changelog' | '@affine-tools/cli' diff --git a/tools/utils/src/workspace.ts b/tools/utils/src/workspace.ts index 40f295267b..a8410a9579 100644 --- a/tools/utils/src/workspace.ts +++ b/tools/utils/src/workspace.ts @@ -49,11 +49,15 @@ export class Workspace { return this.packageJson.dependencies ?? {}; } - constructor() { + get isTsProject() { + return this.join('tsconfig.json').exists(); + } + + constructor(list: typeof PackageList = PackageList) { this.packageJson = readPackageJson(ProjectRoot); const packages = new Map(); - for (const meta of PackageList) { + for (const meta of list) { try { const pkg = new Package(meta.name as PackageName, meta); // @ts-expect-error internal api @@ -70,6 +74,7 @@ export class Workspace { } catch (e) { if (e instanceof CircularDependenciesError) { const inProcessPackages = Array.from(building); + console.log(inProcessPackages, e.currentName); const circle = inProcessPackages .slice(inProcessPackages.indexOf(e.currentName)) .concat(e.currentName); @@ -127,7 +132,7 @@ export class Workspace { } if (building.has(dep.name)) { - throw new CircularDependenciesError(pkg.name); + throw new CircularDependenciesError(dep.name); } if (!pkg.packageJson.private && dep.packageJson.private) { @@ -158,44 +163,6 @@ export class Workspace { return packageList.filter(p => p.location !== '.'); }); - genWorkspaceInfo() { - const list = this.yarnList(); - - const names = list.map(p => p.name); - - const content = [ - '// Auto generated content', - '// DO NOT MODIFY THIS FILE MANUALLY', - `export const PackageList = ${JSON.stringify(list, null, 2)}`, - '', - `export type PackageName = ${names.map(n => `'${n}'`).join(' | ')}`, - ]; - - return content.join('\n'); - } - - genProjectTsConfig() { - const content = [ - '// Auto generated content', - '// DO NOT MODIFY THIS FILE MANUALLY', - '{', - ' "compilerOptions": {', - ' "noEmit": true', - ' },', - ' "include": [],', - ' "references": [', - this.packages - .filter(p => p.isTsProject) - .map(p => ` { "path": "${p.path.relativePath}" }`) - .join(',\n'), - ' ]', - '}', - '', - ]; - - return content.join('\n'); - } - forEach(callback: (pkg: Package) => void) { this.packages.forEach(callback); } diff --git a/tools/utils/tsconfig.json b/tools/utils/tsconfig.json index dc8dfde479..ede9f26824 100644 --- a/tools/utils/tsconfig.json +++ b/tools/utils/tsconfig.json @@ -1,16 +1,10 @@ { - "extends": "../../tsconfig.json", + "extends": "../../tsconfig.node.json", "compilerOptions": { - "types": ["node"], - "moduleResolution": "bundler", - "composite": true, "rootDir": "./src", - "outDir": "./dist" + "outDir": "./dist", + "tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo" }, "include": ["./src"], - "references": [ - { - "path": "../../packages/common/env" - } - ] + "references": [] } diff --git a/tsconfig.json b/tsconfig.json index 1649792eb5..6a171079d9 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,171 +1,117 @@ { "compilerOptions": { - "verbatimModuleSyntax": true, - // Classification follows https://www.typescriptlang.org/tsconfig - // Type Checking + // Strictness "strict": true, + "verbatimModuleSyntax": true, "exactOptionalPropertyTypes": false, "noFallthroughCasesInSwitch": true, - "noImplicitAny": true, "noImplicitOverride": true, "noImplicitReturns": true, - "noImplicitThis": true, "noUnusedLocals": true, "noUnusedParameters": true, "noPropertyAccessFromIndexSignature": false, "noUncheckedIndexedAccess": false, - "useUnknownInCatchVariables": true, + "skipLibCheck": true, + // Modules "module": "ESNext", "moduleResolution": "bundler", "resolveJsonModule": true, - "types": ["affine__env"], + "typeRoots": ["./tools/@types", "./node_modules/@types"], + // Emit + "lib": ["ESNext"], + "target": "ES2024", + "useDefineForClassFields": false, "declaration": true, "declarationMap": true, "sourceMap": true, - // skip type emit for @internal types - // "stripInternal": true, - // JavaScript Support - "allowJs": false, - "checkJs": false, + "importsNotUsedAsValues": "remove", + // Interop Constraints "forceConsistentCasingInFileNames": true, "allowSyntheticDefaultImports": true, "isolatedModules": true, - // Language and Environment - "jsx": "react-jsx", - "jsxImportSource": "@emotion/react", - "lib": ["ESNext", "DOM"], - "target": "ES2022", - "useDefineForClassFields": false, - "experimentalDecorators": false, - "emitDecoratorMetadata": false, - // Projects + + // Composite "composite": true, - "incremental": true, - // For dev performance "disableReferencedProjectLoad": true, - // Completeness - "skipLibCheck": true, // skip all type checks for .d.ts files + + // NOTE(@forehalo): + // We now "fully" resolve package exports by standard "exports" field in package.json + // but core's exports are lit bit complex, so we left it here and will fix it when repos reorganization is done "paths": { - "@affine/core/*": ["./packages/frontend/core/src/*"], - "@affine/admin/*": ["./packages/frontend/admin/src/*"], - "@affine/admin/components/ui/*": [ - "./packages/frontend/admin/src/components/ui/*" - ], - "@affine/server/*": ["./packages/backend/server/src/*"], - "@affine/component": ["./packages/frontend/component/src/index"], - "@affine/component/*": [ - "./packages/frontend/component/src/components/*/index", - "./packages/frontend/component/src/components/*" - ], - "@affine/i18n": ["./packages/frontend/i18n/src"], - "@affine/debug": ["./packages/common/debug"], - "@affine/env": ["./packages/common/env/src"], - "@affine/env/*": ["./packages/common/env/src/*"], - "@affine/graphql": ["./packages/frontend/graphql/src"], - "@affine/electron/scripts/*": ["./packages/frontend/electron/scripts/*"], - "@affine-test/kit/*": ["./tests/kit/*"], - "@toeverything/infra": ["./packages/common/infra/src"], - "@affine/native": ["./packages/frontend/native/index.d.ts"], - "@affine/native/*": ["./packages/frontend/native/*"], - "@affine/server-native": ["./packages/backend/native/index.d.ts"], - // Development only - "@affine/electron/*": ["./packages/frontend/apps/electron/src/*"], - "@affine/nbstore": ["./packages/common/nbstore/src"] + "@affine/core/*": ["./packages/frontend/core/src/*"] } }, "include": [], - "references": [ - // Backend - { - "path": "./packages/backend/server" - }, - { - "path": "./packages/backend/server/tests" - }, - // Frontend - { - "path": "./packages/frontend/admin" - }, - { - "path": "./packages/frontend/component" - }, - { - "path": "./packages/frontend/core" - }, - { - "path": "./packages/frontend/track" - }, - { - "path": "./packages/frontend/apps/web" - }, - { - "path": "./packages/frontend/apps/electron-renderer" - }, - { - "path": "./packages/frontend/apps/mobile" - }, - { - "path": "./packages/frontend/apps/ios" - }, - { - "path": "./packages/frontend/apps/android" - }, - { - "path": "./packages/frontend/apps/electron/tsconfig.test.json" - }, - { - "path": "./packages/frontend/graphql" - }, - { - "path": "./packages/frontend/i18n" - }, - // Common - { - "path": "./packages/common/debug" - }, - { - "path": "./packages/common/env" - }, - { - "path": "./packages/common/infra" - }, - { - "path": "./packages/common/nbstore" - }, - // Tools - { - "path": "./tools/cli" - }, - { - "path": "./tools/utils" - }, - { - "path": "./tools/playstore-auto-bump" - }, - // Tests - { - "path": "./tests/kit" - }, - { - "path": "./tests/affine-local" - }, - { - "path": "./tests/affine-mobile" - }, - { - "path": "./tests/affine-cloud" - }, - { - "path": "./tests/affine-desktop" - }, - // Blocksuite - { - "path": "./blocksuite/affine/all" - } - ], "files": [], - "exclude": ["node_modules", "target", "lib", "test-results", "dist"] + "exclude": ["node_modules", "target", "dist", "lib"], + // NOTE(@forehalo): + // The references are generated by the cli, do not modify it manually + // COMMAND: `yarn affine init` + "references": [ + { "path": "./blocksuite/affine/all" }, + { "path": "./blocksuite/affine/block-attachment" }, + { "path": "./blocksuite/affine/block-bookmark" }, + { "path": "./blocksuite/affine/block-code" }, + { "path": "./blocksuite/affine/block-data-view" }, + { "path": "./blocksuite/affine/block-database" }, + { "path": "./blocksuite/affine/block-divider" }, + { "path": "./blocksuite/affine/block-edgeless-text" }, + { "path": "./blocksuite/affine/block-embed" }, + { "path": "./blocksuite/affine/block-frame" }, + { "path": "./blocksuite/affine/block-image" }, + { "path": "./blocksuite/affine/block-latex" }, + { "path": "./blocksuite/affine/block-list" }, + { "path": "./blocksuite/affine/block-note" }, + { "path": "./blocksuite/affine/block-paragraph" }, + { "path": "./blocksuite/affine/block-surface" }, + { "path": "./blocksuite/affine/block-surface-ref" }, + { "path": "./blocksuite/affine/components" }, + { "path": "./blocksuite/affine/data-view" }, + { "path": "./blocksuite/affine/model" }, + { "path": "./blocksuite/affine/shared" }, + { "path": "./blocksuite/affine/widget-drag-handle" }, + { "path": "./blocksuite/affine/widget-frame-title" }, + { "path": "./blocksuite/affine/widget-remote-selection" }, + { "path": "./blocksuite/affine/widget-scroll-anchoring" }, + { "path": "./blocksuite/blocks" }, + { "path": "./blocksuite/framework/block-std" }, + { "path": "./blocksuite/framework/global" }, + { "path": "./blocksuite/framework/inline" }, + { "path": "./blocksuite/framework/store" }, + { "path": "./blocksuite/framework/sync" }, + { "path": "./blocksuite/presets" }, + { "path": "./packages/backend/native" }, + { "path": "./packages/backend/server" }, + { "path": "./packages/common/debug" }, + { "path": "./packages/common/env" }, + { "path": "./packages/common/infra" }, + { "path": "./packages/common/nbstore" }, + { "path": "./packages/frontend/admin" }, + { "path": "./packages/frontend/apps/android" }, + { "path": "./packages/frontend/apps/electron" }, + { "path": "./packages/frontend/apps/electron-renderer" }, + { "path": "./packages/frontend/apps/ios" }, + { "path": "./packages/frontend/apps/mobile" }, + { "path": "./packages/frontend/apps/web" }, + { "path": "./packages/frontend/component" }, + { "path": "./packages/frontend/core" }, + { "path": "./packages/frontend/electron-api" }, + { "path": "./packages/frontend/graphql" }, + { "path": "./packages/frontend/i18n" }, + { "path": "./packages/frontend/native" }, + { "path": "./packages/frontend/track" }, + { "path": "./tests/affine-cloud" }, + { "path": "./tests/affine-cloud-copilot" }, + { "path": "./tests/affine-desktop" }, + { "path": "./tests/affine-desktop-cloud" }, + { "path": "./tests/affine-local" }, + { "path": "./tests/affine-mobile" }, + { "path": "./tests/kit" }, + { "path": "./tools/cli" }, + { "path": "./tools/playstore-auto-bump" }, + { "path": "./tools/utils" } + ] } diff --git a/tsconfig.node.json b/tsconfig.node.json index ed71f9f2f5..c0a510a976 100644 --- a/tsconfig.node.json +++ b/tsconfig.node.json @@ -1,16 +1,7 @@ { "extends": "./tsconfig.json", "compilerOptions": { - "composite": true, - "module": "ESNext", - "moduleResolution": "Node", - "allowSyntheticDefaultImports": true, - "outDir": "lib" - }, - "include": ["vite.config.ts", "vitest.config.ts", "scripts"], - "references": [ - { - "path": "./packages/common/env" - } - ] + "types": ["node", "build-config"], + "composite": true + } } diff --git a/tsconfig.project.json b/tsconfig.project.json deleted file mode 100644 index af4dcdb8de..0000000000 --- a/tsconfig.project.json +++ /dev/null @@ -1,74 +0,0 @@ -// Auto generated content -// DO NOT MODIFY THIS FILE MANUALLY -{ - "compilerOptions": { - "noEmit": true - }, - "include": [], - "references": [ - { "path": "./blocksuite/affine/all" }, - { "path": "./blocksuite/affine/block-attachment" }, - { "path": "./blocksuite/affine/block-bookmark" }, - { "path": "./blocksuite/affine/block-code" }, - { "path": "./blocksuite/affine/block-data-view" }, - { "path": "./blocksuite/affine/block-database" }, - { "path": "./blocksuite/affine/block-divider" }, - { "path": "./blocksuite/affine/block-edgeless-text" }, - { "path": "./blocksuite/affine/block-embed" }, - { "path": "./blocksuite/affine/block-frame" }, - { "path": "./blocksuite/affine/block-image" }, - { "path": "./blocksuite/affine/block-latex" }, - { "path": "./blocksuite/affine/block-list" }, - { "path": "./blocksuite/affine/block-note" }, - { "path": "./blocksuite/affine/block-paragraph" }, - { "path": "./blocksuite/affine/block-surface" }, - { "path": "./blocksuite/affine/block-surface-ref" }, - { "path": "./blocksuite/affine/components" }, - { "path": "./blocksuite/affine/data-view" }, - { "path": "./blocksuite/affine/model" }, - { "path": "./blocksuite/affine/shared" }, - { "path": "./blocksuite/affine/widget-drag-handle" }, - { "path": "./blocksuite/affine/widget-frame-title" }, - { "path": "./blocksuite/affine/widget-remote-selection" }, - { "path": "./blocksuite/affine/widget-scroll-anchoring" }, - { "path": "./blocksuite/blocks" }, - { "path": "./blocksuite/framework/block-std" }, - { "path": "./blocksuite/framework/global" }, - { "path": "./blocksuite/framework/inline" }, - { "path": "./blocksuite/framework/store" }, - { "path": "./blocksuite/framework/sync" }, - { "path": "./blocksuite/playground" }, - { "path": "./blocksuite/presets" }, - { "path": "./blocksuite/tests-legacy" }, - { "path": "./packages/backend/native" }, - { "path": "./packages/backend/server" }, - { "path": "./packages/common/debug" }, - { "path": "./packages/common/env" }, - { "path": "./packages/common/infra" }, - { "path": "./packages/common/nbstore" }, - { "path": "./packages/frontend/admin" }, - { "path": "./packages/frontend/apps/android" }, - { "path": "./packages/frontend/apps/electron" }, - { "path": "./packages/frontend/apps/electron-renderer" }, - { "path": "./packages/frontend/apps/ios" }, - { "path": "./packages/frontend/apps/mobile" }, - { "path": "./packages/frontend/apps/web" }, - { "path": "./packages/frontend/component" }, - { "path": "./packages/frontend/core" }, - { "path": "./packages/frontend/electron-api" }, - { "path": "./packages/frontend/graphql" }, - { "path": "./packages/frontend/i18n" }, - { "path": "./packages/frontend/native" }, - { "path": "./packages/frontend/track" }, - { "path": "./tests/affine-cloud" }, - { "path": "./tests/affine-cloud-copilot" }, - { "path": "./tests/affine-desktop" }, - { "path": "./tests/affine-desktop-cloud" }, - { "path": "./tests/affine-local" }, - { "path": "./tests/affine-mobile" }, - { "path": "./tests/kit" }, - { "path": "./tools/cli" }, - { "path": "./tools/playstore-auto-bump" }, - { "path": "./tools/utils" } - ] -} diff --git a/tsconfig.web.json b/tsconfig.web.json new file mode 100644 index 0000000000..ddd83819ee --- /dev/null +++ b/tsconfig.web.json @@ -0,0 +1,9 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "types": ["build-config", "affine__env", "webpack-env"], + "lib": ["ESNext", "DOM", "DOM.Iterable"], + "jsx": "react-jsx", + "composite": true + } +} diff --git a/yarn.lock b/yarn.lock index fd067e4760..aecbb09032 100644 --- a/yarn.lock +++ b/yarn.lock @@ -81,6 +81,7 @@ __metadata: version: 0.0.0-use.local resolution: "@affine-test/kit@workspace:tests/kit" dependencies: + "@affine-tools/utils": "workspace:*" "@node-rs/argon2": "npm:^2.0.2" "@playwright/test": "npm:=1.49.1" express: "npm:^4.21.2" @@ -115,6 +116,7 @@ __metadata: cssnano: "npm:^7.0.6" html-webpack-plugin: "npm:^5.6.3" inquirer: "npm:^12.3.0" + jsonc-parser: "npm:^3.3.1" lodash-es: "npm:^4.17.21" mime-types: "npm:^2.1.35" mini-css-extract-plugin: "npm:^2.9.2" @@ -455,6 +457,7 @@ __metadata: version: 0.0.0-use.local resolution: "@affine/electron-api@workspace:packages/frontend/electron-api" dependencies: + "@affine/electron": "workspace:*" async-call-rpc: "npm:^6.4.2" languageName: unknown linkType: soft @@ -482,7 +485,7 @@ __metadata: languageName: unknown linkType: soft -"@affine/electron@workspace:packages/frontend/apps/electron": +"@affine/electron@workspace:*, @affine/electron@workspace:packages/frontend/apps/electron": version: 0.0.0-use.local resolution: "@affine/electron@workspace:packages/frontend/apps/electron" dependencies: @@ -652,7 +655,6 @@ __metadata: "@swc/core": "npm:^1.10.1" "@taplo/cli": "npm:^0.7.0" "@toeverything/infra": "workspace:*" - "@types/affine__env": "workspace:*" "@types/eslint": "npm:^9.6.1" "@types/node": "npm:^20.17.10" "@typescript-eslint/parser": "npm:^8.18.0" @@ -3976,6 +3978,7 @@ __metadata: dependencies: "@blocksuite/affine-components": "workspace:*" "@blocksuite/affine-model": "workspace:*" + "@blocksuite/affine-shared": "workspace:*" "@blocksuite/block-std": "workspace:*" "@blocksuite/global": "workspace:*" "@blocksuite/presets": "workspace:*" @@ -14082,7 +14085,7 @@ __metadata: languageName: node linkType: hard -"@types/affine__env@workspace:*, @types/affine__env@workspace:tools/@types/env": +"@types/affine__env@workspace:tools/@types/env": version: 0.0.0-use.local resolution: "@types/affine__env@workspace:tools/@types/env" dependencies: @@ -14181,6 +14184,12 @@ __metadata: languageName: node linkType: hard +"@types/build-config@workspace:tools/@types/build-config": + version: 0.0.0-use.local + resolution: "@types/build-config@workspace:tools/@types/build-config" + languageName: unknown + linkType: soft + "@types/busboy@npm:^1.5.0": version: 1.5.4 resolution: "@types/busboy@npm:1.5.4" @@ -24686,6 +24695,13 @@ __metadata: languageName: node linkType: hard +"jsonc-parser@npm:^3.3.1": + version: 3.3.1 + resolution: "jsonc-parser@npm:3.3.1" + checksum: 10/9b0dc391f20b47378f843ef1e877e73ec652a5bdc3c5fa1f36af0f119a55091d147a86c1ee86a232296f55c929bba174538c2bf0312610e0817a22de131cc3f4 + languageName: node + linkType: hard + "jsonfile@npm:^4.0.0": version: 4.0.0 resolution: "jsonfile@npm:4.0.0"