From f393b6b898d146fbd1c88d9713fba94c8b2f1284 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=8B=E3=81=A3=E3=81=93=E3=81=8B=E3=82=8A?= <67428053+kakkokari-gtyih@users.noreply.github.com> Date: Tue, 10 Sep 2024 16:14:02 +0900 Subject: [PATCH 01/38] =?UTF-8?q?fix(frontend/frontend-embed):=20=E3=82=A4?= =?UTF-8?q?=E3=83=B3=E3=83=9D=E3=83=BC=E3=83=88=E3=83=91=E3=82=B9=E3=83=BB?= =?UTF-8?q?=E3=83=86=E3=83=BC=E3=83=9E=E3=81=BE=E3=82=8F=E3=82=8A=E3=81=AA?= =?UTF-8?q?=E3=81=A9=E3=81=AE=E4=BF=AE=E6=AD=A3=20(#14535)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(frontend/frontend-embed): wrong imports * enhance(frontend-embed): サーバーデフォルトのテーマがある場合はそちらを利用するように * :art: * :art: * :art: --- packages/frontend-embed/src/boot.ts | 37 ++++++++++++++----- packages/frontend-embed/src/pages/clip.vue | 2 +- packages/frontend-embed/src/pages/tag.vue | 2 +- .../src/pages/user-timeline.vue | 2 +- .../frontend-embed/src/server-metadata.ts | 5 ++- packages/frontend-embed/src/theme.ts | 8 ++-- packages/frontend-embed/src/ui.vue | 2 +- .../src/components/MkEmbedCodeGenDialog.vue | 2 +- packages/frontend/src/scripts/theme.ts | 2 +- 9 files changed, 42 insertions(+), 20 deletions(-) diff --git a/packages/frontend-embed/src/boot.ts b/packages/frontend-embed/src/boot.ts index 4676baa905..6c73fecd76 100644 --- a/packages/frontend-embed/src/boot.ts +++ b/packages/frontend-embed/src/boot.ts @@ -10,23 +10,42 @@ import '@tabler/icons-webfont/dist/tabler-icons.scss'; import '@/style.scss'; import { createApp, defineAsyncComponent } from 'vue'; -import lightTheme from '@@/themes/l-light.json5'; -import darkTheme from '@@/themes/d-dark.json5'; +import defaultLightTheme from '@@/themes/l-light.json5'; +import defaultDarkTheme from '@@/themes/d-dark.json5'; import { MediaProxy } from '@@/js/media-proxy.js'; -import { applyTheme } from './theme.js'; -import { fetchCustomEmojis } from './custom-emojis.js'; -import { DI } from './di.js'; -import { serverMetadata } from './server-metadata.js'; -import { url } from './config.js'; +import { applyTheme, assertIsTheme } from '@/theme.js'; +import { fetchCustomEmojis } from '@/custom-emojis.js'; +import { DI } from '@/di.js'; +import { serverMetadata } from '@/server-metadata.js'; +import { url } from '@/config.js'; import { parseEmbedParams } from '@@/js/embed-page.js'; import { postMessageToParentWindow, setIframeId } from '@/post-message.js'; -console.info('Misskey Embed'); +import type { Theme } from '@/theme.js'; + +console.log('Misskey Embed'); const params = new URLSearchParams(location.search); const embedParams = parseEmbedParams(params); -console.info(embedParams); +if (_DEV_) console.log(embedParams); + +function parseThemeOrNull(theme: string | null): Theme | null { + if (theme == null) return null; + try { + const parsed = JSON.parse(theme); + if (assertIsTheme(parsed)) { + return parsed; + } else { + return null; + } + } catch (err) { + return null; + } +} + +const lightTheme = parseThemeOrNull(serverMetadata.defaultLightTheme) ?? defaultLightTheme; +const darkTheme = parseThemeOrNull(serverMetadata.defaultDarkTheme) ?? defaultDarkTheme; if (embedParams.colorMode === 'dark') { applyTheme(darkTheme); diff --git a/packages/frontend-embed/src/pages/clip.vue b/packages/frontend-embed/src/pages/clip.vue index 28bd0ab772..29b5480c35 100644 --- a/packages/frontend-embed/src/pages/clip.vue +++ b/packages/frontend-embed/src/pages/clip.vue @@ -135,7 +135,7 @@ misskeyApi('clips/show', { .instanceIcon { height: 24px; - border-radius: 4px; + border-radius: 3px; } } diff --git a/packages/frontend-embed/src/pages/tag.vue b/packages/frontend-embed/src/pages/tag.vue index d69555287a..ea45d7129e 100644 --- a/packages/frontend-embed/src/pages/tag.vue +++ b/packages/frontend-embed/src/pages/tag.vue @@ -119,7 +119,7 @@ function top(ev: MouseEvent) { .instanceIcon { height: 24px; - border-radius: 4px; + border-radius: 3px; } } diff --git a/packages/frontend-embed/src/pages/user-timeline.vue b/packages/frontend-embed/src/pages/user-timeline.vue index d590f6e650..431577d04b 100644 --- a/packages/frontend-embed/src/pages/user-timeline.vue +++ b/packages/frontend-embed/src/pages/user-timeline.vue @@ -132,7 +132,7 @@ misskeyApi('users/show', { .instanceIcon { height: 24px; - border-radius: 4px; + border-radius: 3px; } } diff --git a/packages/frontend-embed/src/server-metadata.ts b/packages/frontend-embed/src/server-metadata.ts index 2bd57a0990..6c94aacd48 100644 --- a/packages/frontend-embed/src/server-metadata.ts +++ b/packages/frontend-embed/src/server-metadata.ts @@ -3,13 +3,14 @@ * SPDX-License-Identifier: AGPL-3.0-only */ +import * as Misskey from 'misskey-js'; import { misskeyApi } from '@/misskey-api.js'; const providedMetaEl = document.getElementById('misskey_meta'); -const _serverMetadata = (providedMetaEl && providedMetaEl.textContent) ? JSON.parse(providedMetaEl.textContent) : null; +const _serverMetadata: Misskey.entities.MetaDetailed | null = (providedMetaEl && providedMetaEl.textContent) ? JSON.parse(providedMetaEl.textContent) : null; // NOTE: devモードのときしか _serverMetadata が null になることは無い -export const serverMetadata = _serverMetadata ?? await misskeyApi('meta', { +export const serverMetadata: Misskey.entities.MetaDetailed = _serverMetadata ?? await misskeyApi('meta', { detail: true, }); diff --git a/packages/frontend-embed/src/theme.ts b/packages/frontend-embed/src/theme.ts index 050d8cf63b..ee633fae94 100644 --- a/packages/frontend-embed/src/theme.ts +++ b/packages/frontend-embed/src/theme.ts @@ -26,6 +26,10 @@ export type Theme = { let timeout: number | null = null; +export function assertIsTheme(theme: Record): theme is Theme { + return typeof theme === 'object' && theme !== null && 'id' in theme && 'name' in theme && 'author' in theme && 'props' in theme; +} + export function applyTheme(theme: Theme, persist = true) { if (timeout) window.clearTimeout(timeout); @@ -35,8 +39,6 @@ export function applyTheme(theme: Theme, persist = true) { document.documentElement.classList.remove('_themeChanging_'); }, 1000); - const colorScheme = theme.base === 'dark' ? 'dark' : 'light'; - // Deep copy const _theme = JSON.parse(JSON.stringify(theme)); @@ -58,7 +60,7 @@ export function applyTheme(theme: Theme, persist = true) { document.documentElement.style.setProperty(`--${k}`, v.toString()); } - document.documentElement.style.setProperty('color-scheme', colorScheme); + // iframeを正常に透過させるために、cssのcolor-schemeは `light dark;` 固定にしてある。style.scss参照 } function compile(theme: Theme): Record { diff --git a/packages/frontend-embed/src/ui.vue b/packages/frontend-embed/src/ui.vue index 3b8449dac8..35d9946b12 100644 --- a/packages/frontend-embed/src/ui.vue +++ b/packages/frontend-embed/src/ui.vue @@ -40,7 +40,7 @@ import XNotFound from '@/pages/not-found.vue'; const page = location.pathname.split('/')[2]; const contentId = location.pathname.split('/')[3]; -console.log(page, contentId); +if (_DEV_) console.log(page, contentId); const embedParams = inject(DI.embedParams, defaultEmbedParams); diff --git a/packages/frontend/src/components/MkEmbedCodeGenDialog.vue b/packages/frontend/src/components/MkEmbedCodeGenDialog.vue index 51630c427c..c1de803007 100644 --- a/packages/frontend/src/components/MkEmbedCodeGenDialog.vue +++ b/packages/frontend/src/components/MkEmbedCodeGenDialog.vue @@ -13,7 +13,7 @@ SPDX-License-Identifier: AGPL-3.0-only @close="cancel()" @closed="$emit('closed')" > - +
Promise.all( 'd-cherry', 'd-ice', 'd-u0', - ].map(name => import(`@/themes/${name}.json5`).then(({ default: _default }): Theme => _default)), + ].map(name => import(`@@/themes/${name}.json5`).then(({ default: _default }): Theme => _default)), ); export const getBuiltinThemesRef = () => { From 05c944c2ccd9231f1e64f9ff67250102a1b27e10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=8B=E3=81=A3=E3=81=93=E3=81=8B=E3=82=8A?= <67428053+kakkokari-gtyih@users.noreply.github.com> Date: Tue, 10 Sep 2024 16:25:36 +0900 Subject: [PATCH 02/38] =?UTF-8?q?Update=20CHANGELOG.md=20(=E6=9B=B8?= =?UTF-8?q?=E3=81=8D=E6=96=B9=E3=82=92=E6=8F=83=E3=81=88=E3=82=8B)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 16c6eb674d..9d7425d463 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,12 +6,12 @@ ### Client - Feat: ノート単体・ユーザーのノート・クリップのノートの埋め込み機能 - 埋め込みコードやウェブサイトへの実装方法の詳細はMisskey Hubに掲載予定です -- サイズ制限を超過するファイルをアップロードしようとした際にエラーを出すように +- Enhance: サイズ制限を超過するファイルをアップロードしようとした際にエラーを出すように - Enhance: アイコンデコレーション管理画面にプレビューを追加 - Fix: サーバーメトリクスが2つ以上あるとリロード直後の表示がおかしくなる問題を修正 ### Server -- ファイルがサイズの制限を超えてアップロードされた際にエラーを返さなかった問題を修正 +- Fix: ファイルがサイズの制限を超えてアップロードされた際にエラーを返さなかった問題を修正 ## 2024.8.0 From 0c2cfe31a3bacefbcc84412c43ac058213b2a3d8 Mon Sep 17 00:00:00 2001 From: KanariKanaru <93921745+kanarikanaru@users.noreply.github.com> Date: Tue, 10 Sep 2024 16:33:14 +0900 Subject: [PATCH 03/38] =?UTF-8?q?Dev:=20cypress=E3=82=92dev=20container?= =?UTF-8?q?=E3=81=A7=E5=AE=9F=E8=A1=8C=E5=8F=AF=E3=81=AB(e2e-dev-container?= =?UTF-8?q?)=20(#14526)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .config/cypress-devcontainer.yml | 203 +++++++++++++++++++++++++++++++ .devcontainer/init.sh | 3 + .gitignore | 1 + package.json | 1 + 4 files changed, 208 insertions(+) create mode 100644 .config/cypress-devcontainer.yml diff --git a/.config/cypress-devcontainer.yml b/.config/cypress-devcontainer.yml new file mode 100644 index 0000000000..e8da5f5e27 --- /dev/null +++ b/.config/cypress-devcontainer.yml @@ -0,0 +1,203 @@ +#━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +# Misskey configuration +#━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +# ┌─────┐ +#───┘ URL └───────────────────────────────────────────────────── + +# Final accessible URL seen by a user. +url: 'http://misskey.local' + +# ONCE YOU HAVE STARTED THE INSTANCE, DO NOT CHANGE THE +# URL SETTINGS AFTER THAT! + +# ┌───────────────────────┐ +#───┘ Port and TLS settings └─────────────────────────────────── + +# +# Misskey requires a reverse proxy to support HTTPS connections. +# +# +----- https://example.tld/ ------------+ +# +------+ |+-------------+ +----------------+| +# | User | ---> || Proxy (443) | ---> | Misskey (3000) || +# +------+ |+-------------+ +----------------+| +# +---------------------------------------+ +# +# You need to set up a reverse proxy. (e.g. nginx) +# An encrypted connection with HTTPS is highly recommended +# because tokens may be transferred in GET requests. + +# The port that your Misskey server should listen on. +port: 61812 + +# ┌──────────────────────────┐ +#───┘ PostgreSQL configuration └──────────────────────────────── + +db: + host: db + port: 5432 + + # Database name + db: misskey + + # Auth + user: postgres + pass: postgres + + # Whether disable Caching queries + #disableCache: true + + # Extra Connection options + #extra: + # ssl: true + +dbReplications: false + +# You can configure any number of replicas here +#dbSlaves: +# - +# host: +# port: +# db: +# user: +# pass: +# - +# host: +# port: +# db: +# user: +# pass: + +# ┌─────────────────────┐ +#───┘ Redis configuration └───────────────────────────────────── + +redis: + host: redis + port: 6379 + #family: 0 # 0=Both, 4=IPv4, 6=IPv6 + #pass: example-pass + #prefix: example-prefix + #db: 1 + +#redisForPubsub: +# host: redis +# port: 6379 +# #family: 0 # 0=Both, 4=IPv4, 6=IPv6 +# #pass: example-pass +# #prefix: example-prefix +# #db: 1 + +#redisForJobQueue: +# host: redis +# port: 6379 +# #family: 0 # 0=Both, 4=IPv4, 6=IPv6 +# #pass: example-pass +# #prefix: example-prefix +# #db: 1 + +#redisForTimelines: +# host: redis +# port: 6379 +# #family: 0 # 0=Both, 4=IPv4, 6=IPv6 +# #pass: example-pass +# #prefix: example-prefix +# #db: 1 + +# ┌───────────────────────────┐ +#───┘ MeiliSearch configuration └───────────────────────────── + +#meilisearch: +# host: meilisearch +# port: 7700 +# apiKey: '' +# ssl: true +# index: '' + +# ┌───────────────┐ +#───┘ ID generation └─────────────────────────────────────────── + +# You can select the ID generation method. +# You don't usually need to change this setting, but you can +# change it according to your preferences. + +# Available methods: +# aid ... Short, Millisecond accuracy +# aidx ... Millisecond accuracy +# meid ... Similar to ObjectID, Millisecond accuracy +# ulid ... Millisecond accuracy +# objectid ... This is left for backward compatibility + +# ONCE YOU HAVE STARTED THE INSTANCE, DO NOT CHANGE THE +# ID SETTINGS AFTER THAT! + +id: 'aidx' + +# ┌────────────────┐ +#───┘ Error tracking └────────────────────────────────────────── + +# Sentry is available for error tracking. +# See the Sentry documentation for more details on options. + +#sentryForBackend: +# enableNodeProfiling: true +# options: +# dsn: 'https://examplePublicKey@o0.ingest.sentry.io/0' + +#sentryForFrontend: +# options: +# dsn: 'https://examplePublicKey@o0.ingest.sentry.io/0' + +# ┌─────────────────────┐ +#───┘ Other configuration └───────────────────────────────────── + +# Whether disable HSTS +#disableHsts: true + +# Number of worker processes +#clusterLimit: 1 + +# Job concurrency per worker +# deliverJobConcurrency: 128 +# inboxJobConcurrency: 16 + +# Job rate limiter +# deliverJobPerSec: 128 +# inboxJobPerSec: 32 + +# Job attempts +# deliverJobMaxAttempts: 12 +# inboxJobMaxAttempts: 8 + +# IP address family used for outgoing request (ipv4, ipv6 or dual) +#outgoingAddressFamily: ipv4 + +# Proxy for HTTP/HTTPS +#proxy: http://127.0.0.1:3128 + +proxyBypassHosts: + - api.deepl.com + - api-free.deepl.com + - www.recaptcha.net + - hcaptcha.com + - challenges.cloudflare.com + +# Proxy for SMTP/SMTPS +#proxySmtp: http://127.0.0.1:3128 # use HTTP/1.1 CONNECT +#proxySmtp: socks4://127.0.0.1:1080 # use SOCKS4 +#proxySmtp: socks5://127.0.0.1:1080 # use SOCKS5 + +# Media Proxy +#mediaProxy: https://example.com/proxy + +# Proxy remote files (default: true) +proxyRemoteFiles: true + +# Sign to ActivityPub GET request (default: true) +signToActivityPubGet: true + +allowedPrivateNetworks: [ + '127.0.0.1/32' +] + +# Upload or download file size limits (bytes) +#maxFileSize: 262144000 diff --git a/.devcontainer/init.sh b/.devcontainer/init.sh index 55fb1e6fa6..e02a533c15 100755 --- a/.devcontainer/init.sh +++ b/.devcontainer/init.sh @@ -3,6 +3,8 @@ set -xe sudo chown node node_modules +sudo apt-get update +sudo apt-get -y install libgtk2.0-0 libgtk-3-0 libgbm-dev libnotify-dev libnss3 libxss1 libasound2 libxtst6 xauth xvfb git config --global --add safe.directory /workspace git submodule update --init corepack install @@ -12,3 +14,4 @@ pnpm install --frozen-lockfile cp .devcontainer/devcontainer.yml .config/default.yml pnpm build pnpm migrate +pnpm exec cypress install diff --git a/.gitignore b/.gitignore index 0f896f4a98..4d5bd1ce08 100644 --- a/.gitignore +++ b/.gitignore @@ -35,6 +35,7 @@ coverage !/.config/example.yml !/.config/docker_example.yml !/.config/docker_example.env +!/.config/cypress-devcontainer.yml docker-compose.yml compose.yml .devcontainer/compose.yml diff --git a/package.json b/package.json index f6507acdb2..85b4f62752 100644 --- a/package.json +++ b/package.json @@ -37,6 +37,7 @@ "cy:open": "pnpm cypress open --browser --e2e --config-file=cypress.config.ts", "cy:run": "pnpm cypress run", "e2e": "pnpm start-server-and-test start:test http://localhost:61812 cy:run", + "e2e-dev-container": "cp ./.config/cypress-devcontainer.yml ./.config/test.yml && pnpm start-server-and-test start:test http://localhost:61812 cy:run", "jest": "cd packages/backend && pnpm jest", "jest-and-coverage": "cd packages/backend && pnpm jest-and-coverage", "test": "pnpm -r test", From 837a8e15d893a670ab2ce51b3ec87e6b62a51da7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=8B=E3=81=A3=E3=81=93=E3=81=8B=E3=82=8A?= <67428053+kakkokari-gtyih@users.noreply.github.com> Date: Tue, 10 Sep 2024 18:39:53 +0900 Subject: [PATCH 04/38] =?UTF-8?q?refactor(frontend):=20frontend-embed/src/?= =?UTF-8?q?to-be-shared=E3=82=92=E5=85=B1=E9=80=9A=E5=8C=96=20(#14536)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * refactor(frontend): shouldCollapsedを共通化 * refactor(frontend): config.js, worker-multi-dispatch.js, intl-const.jsを共通化 * fix(frontend-shared): fix type error * refactor(frontend): is-link.jsと、同一の振る舞いをする記述を共通化 * fix * fix lint * lint fixes --- packages/frontend-embed/src/boot.ts | 2 +- .../frontend-embed/src/components/EmAcct.vue | 2 +- .../src/components/EmImgWithBlurhash.vue | 2 +- .../frontend-embed/src/components/EmLink.vue | 2 +- .../src/components/EmMention.vue | 2 +- .../frontend-embed/src/components/EmMfm.ts | 2 +- .../frontend-embed/src/components/EmNote.vue | 4 +- .../src/components/EmNoteDetailed.vue | 4 +- .../src/components/EmSubNoteContent.vue | 4 +- .../frontend-embed/src/components/EmTime.vue | 2 +- .../frontend-embed/src/components/EmUrl.vue | 2 +- packages/frontend-embed/src/i18n.ts | 2 +- packages/frontend-embed/src/misskey-api.ts | 2 +- packages/frontend-embed/src/pages/clip.vue | 4 +- packages/frontend-embed/src/pages/tag.vue | 4 +- .../src/pages/user-timeline.vue | 2 +- .../src/to-be-shared/worker-multi-dispatch.ts | 82 ------------------- packages/frontend-embed/src/utils.ts | 2 +- packages/frontend-shared/@types/global.d.ts | 25 ++++++ packages/frontend-shared/eslint.config.js | 6 +- .../js}/collapsed.ts | 4 +- .../src => frontend-shared/js}/config.ts | 14 +++- packages/frontend-shared/js/emoji-base.ts | 4 +- .../js}/intl-const.ts | 3 +- .../js}/is-link.ts | 0 .../js}/worker-multi-dispatch.ts | 12 ++- packages/frontend-shared/tsconfig.json | 7 ++ packages/frontend/src/account.ts | 2 +- packages/frontend/src/boot/common.ts | 2 +- packages/frontend/src/boot/main-boot.ts | 2 +- .../src/components/MkAccountMoved.vue | 2 +- .../src/components/MkCropperDialog.vue | 2 +- .../frontend/src/components/MkDonation.vue | 2 +- .../src/components/MkEmbedCodeGenDialog.vue | 2 +- .../src/components/MkFollowButton.vue | 2 +- .../src/components/MkImgWithBlurhash.vue | 2 +- .../src/components/MkInstanceTicker.vue | 2 +- packages/frontend/src/components/MkLink.vue | 2 +- .../frontend/src/components/MkMention.vue | 2 +- packages/frontend/src/components/MkNote.vue | 15 +--- .../src/components/MkNoteDetailed.vue | 11 +-- .../frontend/src/components/MkPageWindow.vue | 2 +- packages/frontend/src/components/MkPoll.vue | 2 +- .../frontend/src/components/MkPostForm.vue | 2 +- .../frontend/src/components/MkPreview.vue | 2 +- packages/frontend/src/components/MkSignin.vue | 2 +- .../src/components/MkSignupDialog.form.vue | 2 +- .../components/MkSourceCodeAvailablePopup.vue | 2 +- .../src/components/MkSubNoteContent.vue | 2 +- .../src/components/MkTutorialDialog.vue | 2 +- .../frontend/src/components/MkUpdated.vue | 2 +- .../frontend/src/components/MkUrlPreview.vue | 4 +- .../src/components/MkUserSelectDialog.vue | 2 +- .../src/components/MkUserSetupDialog.vue | 2 +- .../src/components/MkVisitorDashboard.vue | 2 +- .../frontend/src/components/MkWidgets.vue | 8 +- .../src/components/MkYouTubePlayer.vue | 2 +- .../frontend/src/components/global/MkA.vue | 2 +- .../frontend/src/components/global/MkAcct.vue | 2 +- .../frontend/src/components/global/MkAd.vue | 2 +- .../global/MkMisskeyFlavoredMarkdown.ts | 2 +- .../components/global/MkTime.stories.impl.ts | 2 +- .../frontend/src/components/global/MkTime.vue | 2 +- .../frontend/src/components/global/MkUrl.vue | 2 +- packages/frontend/src/config.ts | 27 ------ packages/frontend/src/filters/date.ts | 2 +- packages/frontend/src/filters/number.ts | 2 +- packages/frontend/src/filters/user.ts | 2 +- packages/frontend/src/i18n.ts | 2 +- packages/frontend/src/navbar.ts | 2 +- packages/frontend/src/pages/_error_.vue | 2 +- packages/frontend/src/pages/about-misskey.vue | 2 +- .../frontend/src/pages/about.overview.vue | 2 +- packages/frontend/src/pages/admin-user.vue | 2 +- .../frontend/src/pages/admin/branding.vue | 2 +- packages/frontend/src/pages/admin/queue.vue | 2 +- packages/frontend/src/pages/channel.vue | 2 +- packages/frontend/src/pages/clip.vue | 2 +- .../src/pages/drop-and-fusion.game.vue | 2 +- packages/frontend/src/pages/flash/flash.vue | 2 +- packages/frontend/src/pages/gallery/post.vue | 2 +- .../src/pages/page-editor/page-editor.vue | 2 +- packages/frontend/src/pages/page.vue | 2 +- .../frontend/src/pages/reversi/game.board.vue | 2 +- packages/frontend/src/pages/reversi/game.vue | 2 +- packages/frontend/src/pages/role.vue | 2 +- .../frontend/src/pages/settings/general.vue | 2 +- .../pages/settings/preferences-backups.vue | 2 +- packages/frontend/src/pages/theme-editor.vue | 2 +- packages/frontend/src/pages/welcome.setup.vue | 2 +- packages/frontend/src/pages/welcome.vue | 2 +- packages/frontend/src/scripts/aiscript/api.ts | 2 +- packages/frontend/src/scripts/collapsed.ts | 22 ----- .../frontend/src/scripts/gen-search-query.ts | 2 +- .../frontend/src/scripts/get-embed-code.ts | 2 +- .../frontend/src/scripts/get-note-menu.ts | 2 +- .../frontend/src/scripts/get-user-menu.ts | 2 +- .../frontend/src/scripts/initialize-sw.ts | 2 +- packages/frontend/src/scripts/intl-const.ts | 2 +- packages/frontend/src/scripts/is-link.ts | 12 --- packages/frontend/src/scripts/media-proxy.ts | 2 +- packages/frontend/src/scripts/misskey-api.ts | 2 +- .../src/scripts/player-url-transform.ts | 2 +- packages/frontend/src/scripts/popout.ts | 2 +- packages/frontend/src/scripts/upload.ts | 2 +- packages/frontend/src/store.ts | 4 +- packages/frontend/src/stream.ts | 2 +- packages/frontend/src/ui/_common_/common.ts | 2 +- packages/frontend/src/ui/classic.sidebar.vue | 2 +- packages/frontend/src/ui/classic.vue | 10 +-- packages/frontend/src/ui/deck/main-column.vue | 7 +- packages/frontend/src/ui/minimum.vue | 2 +- packages/frontend/src/ui/universal.vue | 9 +- packages/frontend/src/ui/visitor.vue | 2 +- packages/frontend/src/ui/zen.vue | 2 +- .../src/widgets/WidgetInstanceInfo.vue | 2 +- packages/frontend/src/widgets/WidgetRss.vue | 2 +- .../frontend/src/widgets/WidgetRssTicker.vue | 2 +- 118 files changed, 181 insertions(+), 309 deletions(-) delete mode 100644 packages/frontend-embed/src/to-be-shared/worker-multi-dispatch.ts create mode 100644 packages/frontend-shared/@types/global.d.ts rename packages/{frontend-embed/src/to-be-shared => frontend-shared/js}/collapsed.ts (86%) rename packages/{frontend-embed/src => frontend-shared/js}/config.ts (58%) rename packages/{frontend-embed/src/to-be-shared => frontend-shared/js}/intl-const.ts (91%) rename packages/{frontend-embed/src/to-be-shared => frontend-shared/js}/is-link.ts (100%) rename packages/{frontend/src/scripts => frontend-shared/js}/worker-multi-dispatch.ts (84%) delete mode 100644 packages/frontend/src/config.ts delete mode 100644 packages/frontend/src/scripts/collapsed.ts delete mode 100644 packages/frontend/src/scripts/is-link.ts diff --git a/packages/frontend-embed/src/boot.ts b/packages/frontend-embed/src/boot.ts index 6c73fecd76..fcea7d32ea 100644 --- a/packages/frontend-embed/src/boot.ts +++ b/packages/frontend-embed/src/boot.ts @@ -17,7 +17,7 @@ import { applyTheme, assertIsTheme } from '@/theme.js'; import { fetchCustomEmojis } from '@/custom-emojis.js'; import { DI } from '@/di.js'; import { serverMetadata } from '@/server-metadata.js'; -import { url } from '@/config.js'; +import { url } from '@@/js/config.js'; import { parseEmbedParams } from '@@/js/embed-page.js'; import { postMessageToParentWindow, setIframeId } from '@/post-message.js'; diff --git a/packages/frontend-embed/src/components/EmAcct.vue b/packages/frontend-embed/src/components/EmAcct.vue index 07315e6a8b..6856b8272e 100644 --- a/packages/frontend-embed/src/components/EmAcct.vue +++ b/packages/frontend-embed/src/components/EmAcct.vue @@ -13,7 +13,7 @@ SPDX-License-Identifier: AGPL-3.0-only diff --git a/packages/frontend/src/scripts/code-highlighter.ts b/packages/frontend/src/scripts/code-highlighter.ts index b0ffac93d7..6710d9826e 100644 --- a/packages/frontend/src/scripts/code-highlighter.ts +++ b/packages/frontend/src/scripts/code-highlighter.ts @@ -3,7 +3,7 @@ * SPDX-License-Identifier: AGPL-3.0-only */ -import { getHighlighterCore, loadWasm } from 'shiki/core'; +import { createHighlighterCore, loadWasm } from 'shiki/core'; import darkPlus from 'shiki/themes/dark-plus.mjs'; import { bundledThemesInfo } from 'shiki/themes'; import { bundledLanguagesInfo } from 'shiki/langs'; @@ -69,7 +69,7 @@ async function initHighlighter() { ]); const jsLangInfo = bundledLanguagesInfo.find(t => t.id === 'javascript'); - const highlighter = await getHighlighterCore({ + const highlighter = await createHighlighterCore({ themes, langs: [ ...(jsLangInfo ? [async () => await jsLangInfo.import()] : []), From 6b2072f4b1e6a191634b51b448442aaf57df5434 Mon Sep 17 00:00:00 2001 From: Kisaragi <48310258+KisaragiEffective@users.noreply.github.com> Date: Sun, 15 Sep 2024 15:13:46 +0900 Subject: [PATCH 08/38] =?UTF-8?q?fix(backend/antenna):=20=E3=82=AD?= =?UTF-8?q?=E3=83=BC=E3=83=AF=E3=83=BC=E3=83=89=E3=81=8C=E4=B8=8E=E3=81=88?= =?UTF-8?q?=E3=82=89=E3=82=8C=E3=81=AA=E3=81=8B=E3=81=A3=E3=81=9F=E5=A0=B4?= =?UTF-8?q?=E5=90=88=E3=81=AE=E3=82=A8=E3=83=A9=E3=83=BC=E3=82=92ApiError?= =?UTF-8?q?=E3=81=A8=E3=81=97=E3=81=A6=E6=8A=95=E3=81=92=E3=82=8B=20(#1449?= =?UTF-8?q?1)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(backend/antenna): report validation failure as ApiError on update * test(backend/antenna): reflect change in previous commit * fix(backend/antenna): report validation failure as ApiError on create * test(backend/antenna): reflect change in previous commit * test(backend/antenna): semi * test(backend/antenna): bring being spread parameters first in object literal * chore: add CHANGELOG entry --------- Co-authored-by: syuilo <4439005+syuilo@users.noreply.github.com> --- CHANGELOG.md | 4 +++- .../server/api/endpoints/antennas/create.ts | 8 ++++++- .../server/api/endpoints/antennas/update.ts | 8 ++++++- packages/backend/test/e2e/antennas.ts | 23 +++++++++++++++++++ 4 files changed, 40 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bc2d9f102e..62d9d4defa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,11 +12,13 @@ - Fix: 月の違う同じ日はセパレータが表示されないのを修正 ### Server +- ファイルがサイズの制限を超えてアップロードされた際にエラーを返さなかった問題を修正 +- Fix: アンテナの書き込み時にキーワードが与えられなかった場合のエラーをApiErrorとして投げるように + - この変更により、公式フロントエンドでは入力の不備が内部エラーとして報告される代わりに一般的なエラーダイアログで報告されます - Fix: ファイルがサイズの制限を超えてアップロードされた際にエラーを返さなかった問題を修正 - Fix: 外部ページを解析する際に、ページに紐づけられた関連リソースも読み込まれてしまう問題を修正 (Cherry-picked from https://activitypub.software/TransFem-org/Sharkey/-/commit/26e0412fbb91447c37e8fb06ffb0487346063bb8) - ## 2024.8.0 ### General diff --git a/packages/backend/src/server/api/endpoints/antennas/create.ts b/packages/backend/src/server/api/endpoints/antennas/create.ts index 577b9e1b1f..e0c8ddcc84 100644 --- a/packages/backend/src/server/api/endpoints/antennas/create.ts +++ b/packages/backend/src/server/api/endpoints/antennas/create.ts @@ -34,6 +34,12 @@ export const meta = { code: 'TOO_MANY_ANTENNAS', id: 'faf47050-e8b5-438c-913c-db2b1576fde4', }, + + emptyKeyword: { + message: 'Either keywords or excludeKeywords is required.', + code: 'EMPTY_KEYWORD', + id: '53ee222e-1ddd-4f9a-92e5-9fb82ddb463a', + }, }, res: { @@ -87,7 +93,7 @@ export default class extends Endpoint { // eslint- ) { super(meta, paramDef, async (ps, me) => { if (ps.keywords.flat().every(x => x === '') && ps.excludeKeywords.flat().every(x => x === '')) { - throw new Error('either keywords or excludeKeywords is required.'); + throw new ApiError(meta.errors.emptyKeyword); } const currentAntennasCount = await this.antennasRepository.countBy({ diff --git a/packages/backend/src/server/api/endpoints/antennas/update.ts b/packages/backend/src/server/api/endpoints/antennas/update.ts index 0c30bca9e0..10f26b1912 100644 --- a/packages/backend/src/server/api/endpoints/antennas/update.ts +++ b/packages/backend/src/server/api/endpoints/antennas/update.ts @@ -32,6 +32,12 @@ export const meta = { code: 'NO_SUCH_USER_LIST', id: '1c6b35c9-943e-48c2-81e4-2844989407f7', }, + + emptyKeyword: { + message: 'Either keywords or excludeKeywords is required.', + code: 'EMPTY_KEYWORD', + id: '721aaff6-4e1b-4d88-8de6-877fae9f68c4', + }, }, res: { @@ -85,7 +91,7 @@ export default class extends Endpoint { // eslint- super(meta, paramDef, async (ps, me) => { if (ps.keywords && ps.excludeKeywords) { if (ps.keywords.flat().every(x => x === '') && ps.excludeKeywords.flat().every(x => x === '')) { - throw new Error('either keywords or excludeKeywords is required.'); + throw new ApiError(meta.errors.emptyKeyword); } } // Fetch the antenna diff --git a/packages/backend/test/e2e/antennas.ts b/packages/backend/test/e2e/antennas.ts index 6ac14cd8dc..a544db955a 100644 --- a/packages/backend/test/e2e/antennas.ts +++ b/packages/backend/test/e2e/antennas.ts @@ -228,6 +228,17 @@ describe('アンテナ', () => { assert.deepStrictEqual(response, expected); }); + test('を作成する時キーワードが指定されていないとエラーになる', async () => { + await failedApiCall({ + endpoint: 'antennas/create', + parameters: { ...defaultParam, keywords: [[]], excludeKeywords: [[]] }, + user: alice + }, { + status: 400, + code: 'EMPTY_KEYWORD', + id: '53ee222e-1ddd-4f9a-92e5-9fb82ddb463a' + }) + }); //#endregion //#region 更新(antennas/update) @@ -255,6 +266,18 @@ describe('アンテナ', () => { id: '1c6b35c9-943e-48c2-81e4-2844989407f7', }); }); + test('を変更する時キーワードが指定されていないとエラーになる', async () => { + const antenna = await successfulApiCall({ endpoint: 'antennas/create', parameters: defaultParam, user: alice }); + await failedApiCall({ + endpoint: 'antennas/update', + parameters: { ...defaultParam, antennaId: antenna.id, keywords: [[]], excludeKeywords: [[]] }, + user: alice + }, { + status: 400, + code: 'EMPTY_KEYWORD', + id: '721aaff6-4e1b-4d88-8de6-877fae9f68c4' + }) + }); //#endregion //#region 表示(antennas/show) From 366b79e4595b709f5a6b8b4700eb93510d41072a Mon Sep 17 00:00:00 2001 From: syuilo <4439005+syuilo@users.noreply.github.com> Date: Sun, 15 Sep 2024 15:14:13 +0900 Subject: [PATCH 09/38] Update CHANGELOG.md --- CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 62d9d4defa..ffe03c13c7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,7 +12,6 @@ - Fix: 月の違う同じ日はセパレータが表示されないのを修正 ### Server -- ファイルがサイズの制限を超えてアップロードされた際にエラーを返さなかった問題を修正 - Fix: アンテナの書き込み時にキーワードが与えられなかった場合のエラーをApiErrorとして投げるように - この変更により、公式フロントエンドでは入力の不備が内部エラーとして報告される代わりに一般的なエラーダイアログで報告されます - Fix: ファイルがサイズの制限を超えてアップロードされた際にエラーを返さなかった問題を修正 From 07f26bc8dd199ff366e6278a8ac1521497922b95 Mon Sep 17 00:00:00 2001 From: Juan Aguilar Santillana Date: Sun, 15 Sep 2024 10:43:24 +0200 Subject: [PATCH 10/38] refactor(backend): use Reflet for autobind deco (#14482) Using Reflect.defineProperty instead of Object.defineProperty gives a more consistent behavior with the rest of the modern JavaScript features. --- packages/backend/src/decorators.ts | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/packages/backend/src/decorators.ts b/packages/backend/src/decorators.ts index 21777657d1..42f925e125 100644 --- a/packages/backend/src/decorators.ts +++ b/packages/backend/src/decorators.ts @@ -10,8 +10,9 @@ * The getter will return a .bind version of the function * and memoize the result against a symbol on the instance */ +// eslint-disable-next-line @typescript-eslint/no-explicit-any export function bindThis(target: any, key: string, descriptor: any) { - let fn = descriptor.value; + const fn = descriptor.value; if (typeof fn !== 'function') { throw new TypeError(`@bindThis decorator can only be applied to methods not: ${typeof fn}`); @@ -21,26 +22,18 @@ export function bindThis(target: any, key: string, descriptor: any) { configurable: true, get() { // eslint-disable-next-line no-prototype-builtins - if (this === target.prototype || this.hasOwnProperty(key) || - typeof fn !== 'function') { + if (this === target.prototype || this.hasOwnProperty(key)) { return fn; } const boundFn = fn.bind(this); - Object.defineProperty(this, key, { + Reflect.defineProperty(this, key, { + value: boundFn, configurable: true, - get() { - return boundFn; - }, - set(value) { - fn = value; - delete this[key]; - }, + writable: true, }); + return boundFn; }, - set(value: any) { - fn = value; - }, }; } From 0e4b6d1dade90673af58af3480081c95984c0274 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=8B=E3=81=A3=E3=81=93=E3=81=8B=E3=82=8A?= <67428053+kakkokari-gtyih@users.noreply.github.com> Date: Sun, 15 Sep 2024 17:50:25 +0900 Subject: [PATCH 11/38] =?UTF-8?q?enhance(frontend):=20admin=E3=81=AE?= =?UTF-8?q?=E3=83=95=E3=82=A1=E3=82=A4=E3=83=AB=E3=83=AA=E3=82=B9=E3=83=88?= =?UTF-8?q?=E3=81=A7=E3=82=BB=E3=83=B3=E3=82=B7=E3=83=86=E3=82=A3=E3=83=96?= =?UTF-8?q?=E3=83=95=E3=82=A1=E3=82=A4=E3=83=AB=E3=81=AB=E6=9E=A0=E7=B7=9A?= =?UTF-8?q?=E3=82=92=E8=BF=BD=E5=8A=A0=20(#14510)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * enhance(frontend): adminのファイルリストでセンシティブファイルに枠線を追加 * Update Changelog --- CHANGELOG.md | 1 + .../src/components/MkDriveFileThumbnail.vue | 21 ++++++++++++++++++- .../src/components/MkFileListForAdmin.vue | 2 +- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ffe03c13c7..c01d284bdb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ - 埋め込みコードやウェブサイトへの実装方法の詳細はMisskey Hubに掲載予定です - Enhance: サイズ制限を超過するファイルをアップロードしようとした際にエラーを出すように - Enhance: アイコンデコレーション管理画面にプレビューを追加 +- Enhance: コントロールパネル内のファイル一覧でセンシティブなファイルを区別しやすく - Fix: サーバーメトリクスが2つ以上あるとリロード直後の表示がおかしくなる問題を修正 - Fix: 月の違う同じ日はセパレータが表示されないのを修正 diff --git a/packages/frontend/src/components/MkDriveFileThumbnail.vue b/packages/frontend/src/components/MkDriveFileThumbnail.vue index 2c47a70970..eb93aaab6e 100644 --- a/packages/frontend/src/components/MkDriveFileThumbnail.vue +++ b/packages/frontend/src/components/MkDriveFileThumbnail.vue @@ -4,7 +4,13 @@ SPDX-License-Identifier: AGPL-3.0-only -->