diff --git a/.github/workflows/check-spdx-license-id.yml b/.github/workflows/check-spdx-license-id.yml index 341b35664c..171ea9f4c5 100644 --- a/.github/workflows/check-spdx-license-id.yml +++ b/.github/workflows/check-spdx-license-id.yml @@ -48,6 +48,7 @@ jobs: "packages/backend/migration" "packages/backend/src" "packages/backend/test" + "packages/frontend-shared/src" "packages/frontend/.storybook" "packages/frontend/@types" "packages/frontend/lib" diff --git a/Dockerfile b/Dockerfile index 8b02e45770..e21b2a31fc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -21,8 +21,9 @@ WORKDIR /misskey COPY --link ["pnpm-lock.yaml", "pnpm-workspace.yaml", "package.json", "./"] COPY --link ["scripts", "./scripts"] COPY --link ["packages/backend/package.json", "./packages/backend/"] +COPY --link ["packages/frontend-shared/package.json", "./packages/frontend-shared/"] COPY --link ["packages/frontend/package.json", "./packages/frontend/"] -COPY --link ["packages/embed/package.json", "./packages/embed/"] +COPY --link ["packages/frontend-embed/package.json", "./packages/frontend-embed/"] COPY --link ["packages/sw/package.json", "./packages/sw/"] COPY --link ["packages/misskey-js/package.json", "./packages/misskey-js/"] COPY --link ["packages/misskey-reversi/package.json", "./packages/misskey-reversi/"] diff --git a/package.json b/package.json index 2f337d36e2..f6507acdb2 100644 --- a/package.json +++ b/package.json @@ -8,8 +8,9 @@ }, "packageManager": "pnpm@9.6.0", "workspaces": [ + "packages/frontend-shared", "packages/frontend", - "packages/embed", + "packages/frontend-embed", "packages/backend", "packages/sw", "packages/misskey-js", diff --git a/packages/embed/.gitignore b/packages/frontend-embed/.gitignore similarity index 100% rename from packages/embed/.gitignore rename to packages/frontend-embed/.gitignore diff --git a/packages/embed/eslint.config.js b/packages/frontend-embed/eslint.config.js similarity index 100% rename from packages/embed/eslint.config.js rename to packages/frontend-embed/eslint.config.js diff --git a/packages/embed/package.json b/packages/frontend-embed/package.json similarity index 98% rename from packages/embed/package.json rename to packages/frontend-embed/package.json index df7a403961..816b028cbd 100644 --- a/packages/embed/package.json +++ b/packages/frontend-embed/package.json @@ -1,5 +1,5 @@ { - "name": "embed", + "name": "frontend-embed", "private": true, "type": "module", "scripts": { diff --git a/packages/embed/src/boot.ts b/packages/frontend-embed/src/boot.ts similarity index 100% rename from packages/embed/src/boot.ts rename to packages/frontend-embed/src/boot.ts diff --git a/packages/embed/src/components/EmA.vue b/packages/frontend-embed/src/components/EmA.vue similarity index 100% rename from packages/embed/src/components/EmA.vue rename to packages/frontend-embed/src/components/EmA.vue diff --git a/packages/embed/src/components/EmAvatar.vue b/packages/frontend-embed/src/components/EmAvatar.vue similarity index 100% rename from packages/embed/src/components/EmAvatar.vue rename to packages/frontend-embed/src/components/EmAvatar.vue diff --git a/packages/embed/src/components/EmCustomEmoji.vue b/packages/frontend-embed/src/components/EmCustomEmoji.vue similarity index 100% rename from packages/embed/src/components/EmCustomEmoji.vue rename to packages/frontend-embed/src/components/EmCustomEmoji.vue diff --git a/packages/embed/src/components/EmEmoji.vue b/packages/frontend-embed/src/components/EmEmoji.vue similarity index 100% rename from packages/embed/src/components/EmEmoji.vue rename to packages/frontend-embed/src/components/EmEmoji.vue diff --git a/packages/embed/src/components/EmImgWithBlurhash.vue b/packages/frontend-embed/src/components/EmImgWithBlurhash.vue similarity index 100% rename from packages/embed/src/components/EmImgWithBlurhash.vue rename to packages/frontend-embed/src/components/EmImgWithBlurhash.vue diff --git a/packages/embed/src/components/EmMediaBanner.vue b/packages/frontend-embed/src/components/EmMediaBanner.vue similarity index 100% rename from packages/embed/src/components/EmMediaBanner.vue rename to packages/frontend-embed/src/components/EmMediaBanner.vue diff --git a/packages/embed/src/components/EmMediaImage.vue b/packages/frontend-embed/src/components/EmMediaImage.vue similarity index 100% rename from packages/embed/src/components/EmMediaImage.vue rename to packages/frontend-embed/src/components/EmMediaImage.vue diff --git a/packages/embed/src/components/EmMediaList.vue b/packages/frontend-embed/src/components/EmMediaList.vue similarity index 100% rename from packages/embed/src/components/EmMediaList.vue rename to packages/frontend-embed/src/components/EmMediaList.vue diff --git a/packages/embed/src/components/EmMediaVideo.vue b/packages/frontend-embed/src/components/EmMediaVideo.vue similarity index 100% rename from packages/embed/src/components/EmMediaVideo.vue rename to packages/frontend-embed/src/components/EmMediaVideo.vue diff --git a/packages/embed/src/components/EmNote.vue b/packages/frontend-embed/src/components/EmNote.vue similarity index 100% rename from packages/embed/src/components/EmNote.vue rename to packages/frontend-embed/src/components/EmNote.vue diff --git a/packages/embed/src/components/EmNoteDetailed.vue b/packages/frontend-embed/src/components/EmNoteDetailed.vue similarity index 100% rename from packages/embed/src/components/EmNoteDetailed.vue rename to packages/frontend-embed/src/components/EmNoteDetailed.vue diff --git a/packages/embed/src/components/EmNoteHeader.vue b/packages/frontend-embed/src/components/EmNoteHeader.vue similarity index 100% rename from packages/embed/src/components/EmNoteHeader.vue rename to packages/frontend-embed/src/components/EmNoteHeader.vue diff --git a/packages/embed/src/components/EmNoteSimple.vue b/packages/frontend-embed/src/components/EmNoteSimple.vue similarity index 100% rename from packages/embed/src/components/EmNoteSimple.vue rename to packages/frontend-embed/src/components/EmNoteSimple.vue diff --git a/packages/embed/src/components/EmNoteSub.vue b/packages/frontend-embed/src/components/EmNoteSub.vue similarity index 100% rename from packages/embed/src/components/EmNoteSub.vue rename to packages/frontend-embed/src/components/EmNoteSub.vue diff --git a/packages/embed/src/components/EmNotes.vue b/packages/frontend-embed/src/components/EmNotes.vue similarity index 100% rename from packages/embed/src/components/EmNotes.vue rename to packages/frontend-embed/src/components/EmNotes.vue diff --git a/packages/embed/src/components/EmPagination.vue b/packages/frontend-embed/src/components/EmPagination.vue similarity index 100% rename from packages/embed/src/components/EmPagination.vue rename to packages/frontend-embed/src/components/EmPagination.vue diff --git a/packages/embed/src/components/EmPoll.vue b/packages/frontend-embed/src/components/EmPoll.vue similarity index 100% rename from packages/embed/src/components/EmPoll.vue rename to packages/frontend-embed/src/components/EmPoll.vue diff --git a/packages/embed/src/components/EmSubNoteContent.vue b/packages/frontend-embed/src/components/EmSubNoteContent.vue similarity index 100% rename from packages/embed/src/components/EmSubNoteContent.vue rename to packages/frontend-embed/src/components/EmSubNoteContent.vue diff --git a/packages/embed/src/components/EmTime.vue b/packages/frontend-embed/src/components/EmTime.vue similarity index 100% rename from packages/embed/src/components/EmTime.vue rename to packages/frontend-embed/src/components/EmTime.vue diff --git a/packages/embed/src/components/EmTimelineContainer.vue b/packages/frontend-embed/src/components/EmTimelineContainer.vue similarity index 100% rename from packages/embed/src/components/EmTimelineContainer.vue rename to packages/frontend-embed/src/components/EmTimelineContainer.vue diff --git a/packages/embed/src/components/I18n.vue b/packages/frontend-embed/src/components/I18n.vue similarity index 100% rename from packages/embed/src/components/I18n.vue rename to packages/frontend-embed/src/components/I18n.vue diff --git a/packages/embed/src/config.ts b/packages/frontend-embed/src/config.ts similarity index 100% rename from packages/embed/src/config.ts rename to packages/frontend-embed/src/config.ts diff --git a/packages/embed/src/embed-page.ts b/packages/frontend-embed/src/embed-page.ts similarity index 100% rename from packages/embed/src/embed-page.ts rename to packages/frontend-embed/src/embed-page.ts diff --git a/packages/embed/src/i18n.ts b/packages/frontend-embed/src/i18n.ts similarity index 100% rename from packages/embed/src/i18n.ts rename to packages/frontend-embed/src/i18n.ts diff --git a/packages/embed/src/pages/clip.vue b/packages/frontend-embed/src/pages/clip.vue similarity index 100% rename from packages/embed/src/pages/clip.vue rename to packages/frontend-embed/src/pages/clip.vue diff --git a/packages/embed/src/pages/note.vue b/packages/frontend-embed/src/pages/note.vue similarity index 100% rename from packages/embed/src/pages/note.vue rename to packages/frontend-embed/src/pages/note.vue diff --git a/packages/embed/src/pages/tag.vue b/packages/frontend-embed/src/pages/tag.vue similarity index 100% rename from packages/embed/src/pages/tag.vue rename to packages/frontend-embed/src/pages/tag.vue diff --git a/packages/embed/src/pages/user-timeline.vue b/packages/frontend-embed/src/pages/user-timeline.vue similarity index 100% rename from packages/embed/src/pages/user-timeline.vue rename to packages/frontend-embed/src/pages/user-timeline.vue diff --git a/packages/embed/src/style.scss b/packages/frontend-embed/src/style.scss similarity index 100% rename from packages/embed/src/style.scss rename to packages/frontend-embed/src/style.scss diff --git a/packages/embed/src/ui.vue b/packages/frontend-embed/src/ui.vue similarity index 100% rename from packages/embed/src/ui.vue rename to packages/frontend-embed/src/ui.vue diff --git a/packages/embed/tsconfig.json b/packages/frontend-embed/tsconfig.json similarity index 100% rename from packages/embed/tsconfig.json rename to packages/frontend-embed/tsconfig.json diff --git a/packages/embed/vite.config.local-dev.ts b/packages/frontend-embed/vite.config.local-dev.ts similarity index 100% rename from packages/embed/vite.config.local-dev.ts rename to packages/frontend-embed/vite.config.local-dev.ts diff --git a/packages/embed/vite.config.ts b/packages/frontend-embed/vite.config.ts similarity index 100% rename from packages/embed/vite.config.ts rename to packages/frontend-embed/vite.config.ts diff --git a/packages/embed/vite.json5.ts b/packages/frontend-embed/vite.json5.ts similarity index 100% rename from packages/embed/vite.json5.ts rename to packages/frontend-embed/vite.json5.ts diff --git a/packages/embed/vue-shims.d.ts b/packages/frontend-embed/vue-shims.d.ts similarity index 100% rename from packages/embed/vue-shims.d.ts rename to packages/frontend-embed/vue-shims.d.ts diff --git a/packages/frontend-shared/.gitignore b/packages/frontend-shared/.gitignore new file mode 100644 index 0000000000..1aa0ac14e8 --- /dev/null +++ b/packages/frontend-shared/.gitignore @@ -0,0 +1 @@ +/storybook-static diff --git a/packages/frontend-shared/eslint.config.js b/packages/frontend-shared/eslint.config.js new file mode 100644 index 0000000000..dd8f03dac5 --- /dev/null +++ b/packages/frontend-shared/eslint.config.js @@ -0,0 +1,95 @@ +import globals from 'globals'; +import tsParser from '@typescript-eslint/parser'; +import parser from 'vue-eslint-parser'; +import pluginVue from 'eslint-plugin-vue'; +import pluginMisskey from '@misskey-dev/eslint-plugin'; +import sharedConfig from '../shared/eslint.config.js'; + +export default [ + ...sharedConfig, + { + files: ['src/**/*.vue'], + ...pluginMisskey.configs.typescript, + }, + ...pluginVue.configs['flat/recommended'], + { + files: ['src/**/*.{ts,vue}'], + languageOptions: { + globals: { + ...Object.fromEntries(Object.entries(globals.node).map(([key]) => [key, 'off'])), + ...globals.browser, + + // Node.js + module: false, + require: false, + __dirname: false, + + // Misskey + _DEV_: false, + _LANGS_: false, + _VERSION_: false, + _ENV_: false, + _PERF_PREFIX_: false, + _DATA_TRANSFER_DRIVE_FILE_: false, + _DATA_TRANSFER_DRIVE_FOLDER_: false, + _DATA_TRANSFER_DECK_COLUMN_: false, + }, + parser, + parserOptions: { + extraFileExtensions: ['.vue'], + parser: tsParser, + project: ['./tsconfig.json'], + sourceType: 'module', + tsconfigRootDir: import.meta.dirname, + }, + }, + rules: { + '@typescript-eslint/no-empty-interface': ['error', { + allowSingleExtends: true, + }], + // window の禁止理由: グローバルスコープと衝突し、予期せぬ結果を招くため + // e の禁止理由: error や event など、複数のキーワードの頭文字であり分かりにくいため + 'id-denylist': ['error', 'window', 'e'], + 'no-shadow': ['warn'], + 'vue/attributes-order': ['error', { + alphabetical: false, + }], + 'vue/no-use-v-if-with-v-for': ['error', { + allowUsingIterationVar: false, + }], + 'vue/no-ref-as-operand': 'error', + 'vue/no-multi-spaces': ['error', { + ignoreProperties: false, + }], + 'vue/no-v-html': 'warn', + 'vue/order-in-components': 'error', + 'vue/html-indent': ['warn', 'tab', { + attribute: 1, + baseIndent: 0, + closeBracket: 0, + alignAttributesVertically: true, + ignores: [], + }], + 'vue/html-closing-bracket-spacing': ['warn', { + startTag: 'never', + endTag: 'never', + selfClosingTag: 'never', + }], + 'vue/multi-word-component-names': 'warn', + 'vue/require-v-for-key': 'warn', + 'vue/no-unused-components': 'warn', + 'vue/no-unused-vars': 'warn', + 'vue/no-dupe-keys': 'warn', + 'vue/valid-v-for': 'warn', + 'vue/return-in-computed-property': 'warn', + 'vue/no-setup-props-reactivity-loss': 'warn', + 'vue/max-attributes-per-line': 'off', + 'vue/html-self-closing': 'off', + 'vue/singleline-html-element-content-newline': 'off', + 'vue/v-on-event-hyphenation': ['error', 'never', { + autofix: true, + }], + 'vue/attribute-hyphenation': ['error', 'never'], + }, + }, +]; diff --git a/packages/frontend-shared/package.json b/packages/frontend-shared/package.json new file mode 100644 index 0000000000..dd2c9ed735 --- /dev/null +++ b/packages/frontend-shared/package.json @@ -0,0 +1,36 @@ +{ + "name": "frontend-shared", + "type": "module", + "main": "./built/index.js", + "types": "./built/index.d.ts", + "exports": { + ".": { + "import": "./built/index.js", + "types": "./built/index.d.ts" + }, + "./*": { + "import": "./built/*", + "types": "./built/*" + } + }, + "scripts": { + "build": "node ./build.js", + "watch": "nodemon -w package.json -e json --exec \"node ./build.js --watch\"", + "tsd": "tsd", + "eslint": "eslint './**/*.{js,jsx,ts,tsx}'", + "typecheck": "tsc --noEmit", + "lint": "pnpm typecheck && pnpm eslint" + }, + "devDependencies": { + "@types/node": "20.14.12", + "@typescript-eslint/eslint-plugin": "7.17.0", + "@typescript-eslint/parser": "7.17.0", + "typescript": "5.5.4", + "esbuild": "0.23.0" + }, + "files": [ + "built" + ], + "dependencies": { + } +} diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index 29517ed6cf..d222614eda 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -1,7 +1,8 @@ packages: - 'packages/backend' + - 'packages/frontend-shared' - 'packages/frontend' - - 'packages/embed' + - 'packages/frontend-embed' - 'packages/sw' - 'packages/misskey-js' - 'packages/misskey-js/generator' diff --git a/scripts/clean-all.js b/scripts/clean-all.js index ddb331837f..dc391ecfd8 100644 --- a/scripts/clean-all.js +++ b/scripts/clean-all.js @@ -10,11 +10,14 @@ const fs = require('fs'); fs.rmSync(__dirname + '/../packages/backend/built', { recursive: true, force: true }); fs.rmSync(__dirname + '/../packages/backend/node_modules', { recursive: true, force: true }); + fs.rmSync(__dirname + '/../packages/frontend-shared/built', { recursive: true, force: true }); + fs.rmSync(__dirname + '/../packages/frontend-shared/node_modules', { recursive: true, force: true }); + fs.rmSync(__dirname + '/../packages/frontend/built', { recursive: true, force: true }); fs.rmSync(__dirname + '/../packages/frontend/node_modules', { recursive: true, force: true }); - fs.rmSync(__dirname + '/../packages/embed/built', { recursive: true, force: true }); - fs.rmSync(__dirname + '/../packages/embed/node_modules', { recursive: true, force: true }); + fs.rmSync(__dirname + '/../packages/frontend-embed/built', { recursive: true, force: true }); + fs.rmSync(__dirname + '/../packages/frontend-embed/node_modules', { recursive: true, force: true }); fs.rmSync(__dirname + '/../packages/sw/built', { recursive: true, force: true }); fs.rmSync(__dirname + '/../packages/sw/node_modules', { recursive: true, force: true }); diff --git a/scripts/clean.js b/scripts/clean.js index 6fd416fe2d..86c19281ea 100644 --- a/scripts/clean.js +++ b/scripts/clean.js @@ -7,8 +7,9 @@ const fs = require('fs'); (async () => { fs.rmSync(__dirname + '/../packages/backend/built', { recursive: true, force: true }); + fs.rmSync(__dirname + '/../packages/frontend-shared/built', { recursive: true, force: true }); fs.rmSync(__dirname + '/../packages/frontend/built', { recursive: true, force: true }); - fs.rmSync(__dirname + '/../packages/embed/built', { recursive: true, force: true }); + fs.rmSync(__dirname + '/../packages/frontend-embed/built', { recursive: true, force: true }); fs.rmSync(__dirname + '/../packages/sw/built', { recursive: true, force: true }); fs.rmSync(__dirname + '/../packages/misskey-js/built', { recursive: true, force: true }); fs.rmSync(__dirname + '/../packages/misskey-reversi/built', { recursive: true, force: true }); diff --git a/scripts/dev.mjs b/scripts/dev.mjs index be14903a29..a4c82d46e1 100644 --- a/scripts/dev.mjs +++ b/scripts/dev.mjs @@ -65,13 +65,19 @@ execa('pnpm', ['--filter', 'backend', 'dev'], { stderr: process.stderr, }); +execa('pnpm', ['--filter', 'frontend-shared', 'watch'], { + cwd: _dirname + '/../', + stdout: process.stdout, + stderr: process.stderr, +}); + execa('pnpm', ['--filter', 'frontend', process.env.MK_DEV_PREFER === 'backend' ? 'watch' : 'dev'], { cwd: _dirname + '/../', stdout: process.stdout, stderr: process.stderr, }); -execa('pnpm', ['--filter', 'embed', process.env.MK_DEV_PREFER === 'backend' ? 'watch' : 'dev'], { +execa('pnpm', ['--filter', 'frontend-embed', process.env.MK_DEV_PREFER === 'backend' ? 'watch' : 'dev'], { cwd: _dirname + '/../', stdout: process.stdout, stderr: process.stderr,