Merge remote-tracking branch 'misskey-original/develop' into develop
# Conflicts: # packages/backend/src/models/Meta.ts # packages/backend/src/server/api/endpoints/admin/meta.ts # packages/backend/src/server/api/endpoints/admin/update-meta.ts # packages/frontend/src/components/MkButton.vue # packages/frontend/src/components/MkMenu.vue # packages/frontend/src/components/MkNote.vue # packages/frontend/src/components/MkNoteDetailed.vue # packages/frontend/src/components/MkSwitch.button.vue # packages/frontend/src/pages/settings/general.vue
This commit is contained in:
commit
04fae906c9
|
@ -92,6 +92,6 @@ jobs:
|
||||||
- run: pnpm i --frozen-lockfile
|
- run: pnpm i --frozen-lockfile
|
||||||
- run: pnpm --filter misskey-js run build
|
- run: pnpm --filter misskey-js run build
|
||||||
if: ${{ matrix.workspace == 'backend' }}
|
if: ${{ matrix.workspace == 'backend' }}
|
||||||
- run: pnpm --filter misskey-reversi run build:tsc
|
- run: pnpm --filter misskey-reversi run build
|
||||||
if: ${{ matrix.workspace == 'backend' }}
|
if: ${{ matrix.workspace == 'backend' }}
|
||||||
- run: pnpm --filter ${{ matrix.workspace }} run typecheck
|
- run: pnpm --filter ${{ matrix.workspace }} run typecheck
|
||||||
|
|
|
@ -45,6 +45,8 @@ jobs:
|
||||||
with:
|
with:
|
||||||
version: 8
|
version: 8
|
||||||
run_install: false
|
run_install: false
|
||||||
|
- name: Install FFmpeg
|
||||||
|
uses: FedericoCarboni/setup-ffmpeg@v3
|
||||||
- name: Use Node.js ${{ matrix.node-version }}
|
- name: Use Node.js ${{ matrix.node-version }}
|
||||||
uses: actions/setup-node@v4.0.2
|
uses: actions/setup-node@v4.0.2
|
||||||
with:
|
with:
|
||||||
|
|
19
CHANGELOG.md
19
CHANGELOG.md
|
@ -1,6 +1,12 @@
|
||||||
## Unreleased
|
## Unreleased
|
||||||
|
|
||||||
|
### Note
|
||||||
|
- コントロールパネル内にあるサマリープロキシの設定個所がセキュリティから全般へ変更となります。
|
||||||
|
|
||||||
### General
|
### General
|
||||||
|
- Enhance: URLプレビューの有効化・無効化を設定できるように #13569
|
||||||
|
- Enhance: アンテナでBotによるノートを除外できるように
|
||||||
|
(Cherry-picked from https://github.com/MisskeyIO/misskey/pull/545)
|
||||||
- Fix: Play作成時に設定した公開範囲が機能していない問題を修正
|
- Fix: Play作成時に設定した公開範囲が機能していない問題を修正
|
||||||
|
|
||||||
### Client
|
### Client
|
||||||
|
@ -11,6 +17,12 @@
|
||||||
- Enhance: 設定>プラグインのページからプラグインの簡易的なログやエラーを見られるように
|
- Enhance: 設定>プラグインのページからプラグインの簡易的なログやエラーを見られるように
|
||||||
- 実装の都合により、プラグインは1つエラーを起こした時に即時停止するようになりました
|
- 実装の都合により、プラグインは1つエラーを起こした時に即時停止するようになりました
|
||||||
- Enhance: ページのデザインを変更
|
- Enhance: ページのデザインを変更
|
||||||
|
- Enhance: 2要素認証(ワンタイムパスワード)の入力欄を改善
|
||||||
|
- Enhance: 「今日誕生日のフォロー中ユーザー」ウィジェットを手動でリロードできるように
|
||||||
|
- Enhance: 映像・音声の再生にブラウザのネイティブプレイヤーを使用できるように
|
||||||
|
- Enhance: 映像・音声の再生メニューに「再生速度」「ループ再生」「ピクチャインピクチャ」を追加
|
||||||
|
- Enhance: 映像・音声の再生にキーボードショートカットが使えるように
|
||||||
|
- Enhance: ノートについているリアクションの「もっと!」から、リアクションの一覧を表示できるように
|
||||||
- Fix: 一部のページ内リンクが正しく動作しない問題を修正
|
- Fix: 一部のページ内リンクが正しく動作しない問題を修正
|
||||||
- Fix: 周年の実績が閏年を考慮しない問題を修正
|
- Fix: 周年の実績が閏年を考慮しない問題を修正
|
||||||
- Fix: ローカルURLのプレビューポップアップが左上に表示される
|
- Fix: ローカルURLのプレビューポップアップが左上に表示される
|
||||||
|
@ -18,11 +30,18 @@
|
||||||
(Cherry-picked from https://activitypub.software/TransFem-org/Sharkey/-/merge_requests/459)
|
(Cherry-picked from https://activitypub.software/TransFem-org/Sharkey/-/merge_requests/459)
|
||||||
- Fix: ページタイトルでローカルユーザーとリモートユーザーの区別がつかない問題を修正
|
- Fix: ページタイトルでローカルユーザーとリモートユーザーの区別がつかない問題を修正
|
||||||
(Cherry-picked from https://github.com/MisskeyIO/misskey/pull/528)
|
(Cherry-picked from https://github.com/MisskeyIO/misskey/pull/528)
|
||||||
|
- Fix: コードブロックのシンタックスハイライトで使用される定義ファイルをCDNから取得するように #13177
|
||||||
|
- CDNから取得せずMisskey本体にバンドルする場合は`pacakges/frontend/vite.config.ts`を修正してください。
|
||||||
|
- Fix: タイムゾーンによっては、「今日誕生日のフォロー中ユーザー」ウィジェットが正しく動作しない問題を修正
|
||||||
|
|
||||||
### Server
|
### Server
|
||||||
- Enhance: エンドポイント`antennas/update`の必須項目を`antennaId`のみに
|
- Enhance: エンドポイント`antennas/update`の必須項目を`antennaId`のみに
|
||||||
|
- Enhance: misskey-dev/summaly@5.1.0の取り込み(プレビュー生成処理の効率化)
|
||||||
- Fix: フォローリクエストを作成する際に既存のものは削除するように
|
- Fix: フォローリクエストを作成する際に既存のものは削除するように
|
||||||
(Cherry-picked from https://activitypub.software/TransFem-org/Sharkey/-/merge_requests/440)
|
(Cherry-picked from https://activitypub.software/TransFem-org/Sharkey/-/merge_requests/440)
|
||||||
|
- Fix: エンドポイント`notes/translate`のエラーを改善
|
||||||
|
- Fix: CleanRemoteFilesProcessorService report progress from 100% (#13632)
|
||||||
|
- Fix: 一部の音声ファイルが映像ファイルとして扱われる問題を修正
|
||||||
|
|
||||||
## 2024.3.1
|
## 2024.3.1
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ Cypress.Commands.add('visitHome', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
Cypress.Commands.add('resetState', () => {
|
Cypress.Commands.add('resetState', () => {
|
||||||
cy.window(win => {
|
cy.window().then(win => {
|
||||||
win.indexedDB.deleteDatabase('keyval-store');
|
win.indexedDB.deleteDatabase('keyval-store');
|
||||||
});
|
});
|
||||||
cy.request('POST', '/api/reset-db', {}).as('reset');
|
cy.request('POST', '/api/reset-db', {}).as('reset');
|
|
@ -0,0 +1,19 @@
|
||||||
|
declare global {
|
||||||
|
namespace Cypress {
|
||||||
|
interface Chainable {
|
||||||
|
login(username: string, password: string): Chainable<void>;
|
||||||
|
|
||||||
|
registerUser(
|
||||||
|
username: string,
|
||||||
|
password: string,
|
||||||
|
isAdmin?: boolean
|
||||||
|
): Chainable<void>;
|
||||||
|
|
||||||
|
resetState(): Chainable<void>;
|
||||||
|
|
||||||
|
visitHome(): Chainable<void>;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export {}
|
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"lib": ["dom", "es5"],
|
||||||
|
"target": "es5",
|
||||||
|
"types": ["cypress", "node"]
|
||||||
|
},
|
||||||
|
"include": ["./**/*.ts"]
|
||||||
|
}
|
|
@ -1740,6 +1740,10 @@ export interface Locale extends ILocale {
|
||||||
* 除外キーワード
|
* 除外キーワード
|
||||||
*/
|
*/
|
||||||
"antennaExcludeKeywords": string;
|
"antennaExcludeKeywords": string;
|
||||||
|
/**
|
||||||
|
* Botアカウントを除外
|
||||||
|
*/
|
||||||
|
"antennaExcludeBots": string;
|
||||||
/**
|
/**
|
||||||
* スペースで区切るとAND指定になり、改行で区切るとOR指定になります
|
* スペースで区切るとAND指定になり、改行で区切るとOR指定になります
|
||||||
*/
|
*/
|
||||||
|
@ -5144,6 +5148,26 @@ export interface Locale extends ILocale {
|
||||||
* リトライ
|
* リトライ
|
||||||
*/
|
*/
|
||||||
"gameRetry": string;
|
"gameRetry": string;
|
||||||
|
/**
|
||||||
|
* 使用しない場合は空欄にしてください
|
||||||
|
*/
|
||||||
|
"notUsePleaseLeaveBlank": string;
|
||||||
|
/**
|
||||||
|
* ワンタイムパスワードを使う
|
||||||
|
*/
|
||||||
|
"useTotp": string;
|
||||||
|
/**
|
||||||
|
* バックアップコードを使う
|
||||||
|
*/
|
||||||
|
"useBackupCode": string;
|
||||||
|
/**
|
||||||
|
* アプリを起動
|
||||||
|
*/
|
||||||
|
"launchApp": string;
|
||||||
|
/**
|
||||||
|
* 動画・音声の再生にブラウザのUIを使用する
|
||||||
|
*/
|
||||||
|
"useNativeUIForVideoAudioPlayer": string;
|
||||||
"_bubbleGame": {
|
"_bubbleGame": {
|
||||||
/**
|
/**
|
||||||
* 遊び方
|
* 遊び方
|
||||||
|
@ -7832,13 +7856,9 @@ export interface Locale extends ILocale {
|
||||||
*/
|
*/
|
||||||
"step1": ParameterizedString<"a" | "b">;
|
"step1": ParameterizedString<"a" | "b">;
|
||||||
/**
|
/**
|
||||||
* 次に、表示されているQRコードをアプリでスキャンします。
|
* 次に、表示されているQRコードをアプリでスキャンするか、ボタンをクリックして端末上でアプリを開きます。
|
||||||
*/
|
*/
|
||||||
"step2": string;
|
"step2": string;
|
||||||
/**
|
|
||||||
* QRコードをクリックすると、お使いの端末にインストールされている認証アプリやキーリングに登録できます。
|
|
||||||
*/
|
|
||||||
"step2Click": string;
|
|
||||||
/**
|
/**
|
||||||
* デスクトップアプリを使用する場合は次のURIを入力します
|
* デスクトップアプリを使用する場合は次のURIを入力します
|
||||||
*/
|
*/
|
||||||
|
@ -9128,6 +9148,14 @@ export interface Locale extends ILocale {
|
||||||
* ボタン
|
* ボタン
|
||||||
*/
|
*/
|
||||||
"button": string;
|
"button": string;
|
||||||
|
/**
|
||||||
|
* 動的ブロック
|
||||||
|
*/
|
||||||
|
"dynamic": string;
|
||||||
|
/**
|
||||||
|
* このブロックは廃止されています。今後は{play}を利用してください。
|
||||||
|
*/
|
||||||
|
"dynamicDescription": ParameterizedString<"play">;
|
||||||
/**
|
/**
|
||||||
* ノート埋め込み
|
* ノート埋め込み
|
||||||
*/
|
*/
|
||||||
|
@ -10116,6 +10144,74 @@ export interface Locale extends ILocale {
|
||||||
*/
|
*/
|
||||||
"header": string;
|
"header": string;
|
||||||
};
|
};
|
||||||
|
"_urlPreviewSetting": {
|
||||||
|
/**
|
||||||
|
* URLプレビューの設定
|
||||||
|
*/
|
||||||
|
"title": string;
|
||||||
|
/**
|
||||||
|
* URLプレビューを有効にする
|
||||||
|
*/
|
||||||
|
"enable": string;
|
||||||
|
/**
|
||||||
|
* プレビュー取得時のタイムアウト(ms)
|
||||||
|
*/
|
||||||
|
"timeout": string;
|
||||||
|
/**
|
||||||
|
* プレビュー取得の所要時間がこの値を超えた場合、プレビューは生成されません。
|
||||||
|
*/
|
||||||
|
"timeoutDescription": string;
|
||||||
|
/**
|
||||||
|
* Content-Lengthの最大値(byte)
|
||||||
|
*/
|
||||||
|
"maximumContentLength": string;
|
||||||
|
/**
|
||||||
|
* Content-Lengthがこの値を超えた場合、プレビューは生成されません。
|
||||||
|
*/
|
||||||
|
"maximumContentLengthDescription": string;
|
||||||
|
/**
|
||||||
|
* Content-Lengthが取得できた場合のみプレビューを生成
|
||||||
|
*/
|
||||||
|
"requireContentLength": string;
|
||||||
|
/**
|
||||||
|
* 相手サーバがContent-Lengthを返さない場合、プレビューは生成されません。
|
||||||
|
*/
|
||||||
|
"requireContentLengthDescription": string;
|
||||||
|
/**
|
||||||
|
* User-Agent
|
||||||
|
*/
|
||||||
|
"userAgent": string;
|
||||||
|
/**
|
||||||
|
* プレビュー取得時に使用されるUser-Agentを設定します。空欄の場合、デフォルトのUser-Agentが使用されます。
|
||||||
|
*/
|
||||||
|
"userAgentDescription": string;
|
||||||
|
/**
|
||||||
|
* プレビューを生成するプロキシのエンドポイント
|
||||||
|
*/
|
||||||
|
"summaryProxy": string;
|
||||||
|
/**
|
||||||
|
* Misskey本体ではなく、サマリープロキシを使用してプレビューを生成します。
|
||||||
|
*/
|
||||||
|
"summaryProxyDescription": string;
|
||||||
|
/**
|
||||||
|
* プロキシには下記パラメータがクエリ文字列として連携されます。プロキシ側がこれらをサポートしない場合、設定値は無視されます。
|
||||||
|
*/
|
||||||
|
"summaryProxyDescription2": string;
|
||||||
|
};
|
||||||
|
"_mediaControls": {
|
||||||
|
/**
|
||||||
|
* ピクチャインピクチャ
|
||||||
|
*/
|
||||||
|
"pip": string;
|
||||||
|
/**
|
||||||
|
* 再生速度
|
||||||
|
*/
|
||||||
|
"playbackRate": string;
|
||||||
|
/**
|
||||||
|
* ループ再生
|
||||||
|
*/
|
||||||
|
"loop": string;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
declare const locales: {
|
declare const locales: {
|
||||||
[lang: string]: Locale;
|
[lang: string]: Locale;
|
||||||
|
|
|
@ -431,6 +431,7 @@ name: "名前"
|
||||||
antennaSource: "受信ソース"
|
antennaSource: "受信ソース"
|
||||||
antennaKeywords: "受信キーワード"
|
antennaKeywords: "受信キーワード"
|
||||||
antennaExcludeKeywords: "除外キーワード"
|
antennaExcludeKeywords: "除外キーワード"
|
||||||
|
antennaExcludeBots: "Botアカウントを除外"
|
||||||
antennaKeywordsDescription: "スペースで区切るとAND指定になり、改行で区切るとOR指定になります"
|
antennaKeywordsDescription: "スペースで区切るとAND指定になり、改行で区切るとOR指定になります"
|
||||||
notifyAntenna: "新しいノートを通知する"
|
notifyAntenna: "新しいノートを通知する"
|
||||||
withFileAntenna: "ファイルが添付されたノートのみ"
|
withFileAntenna: "ファイルが添付されたノートのみ"
|
||||||
|
@ -1282,6 +1283,11 @@ enableHorizontalSwipe: "スワイプしてタブを切り替える"
|
||||||
loading: "読み込み中"
|
loading: "読み込み中"
|
||||||
surrender: "やめる"
|
surrender: "やめる"
|
||||||
gameRetry: "リトライ"
|
gameRetry: "リトライ"
|
||||||
|
notUsePleaseLeaveBlank: "使用しない場合は空欄にしてください"
|
||||||
|
useTotp: "ワンタイムパスワードを使う"
|
||||||
|
useBackupCode: "バックアップコードを使う"
|
||||||
|
launchApp: "アプリを起動"
|
||||||
|
useNativeUIForVideoAudioPlayer: "動画・音声の再生にブラウザのUIを使用する"
|
||||||
|
|
||||||
_bubbleGame:
|
_bubbleGame:
|
||||||
howToPlay: "遊び方"
|
howToPlay: "遊び方"
|
||||||
|
@ -2057,8 +2063,7 @@ _2fa:
|
||||||
alreadyRegistered: "既に設定は完了しています。"
|
alreadyRegistered: "既に設定は完了しています。"
|
||||||
registerTOTP: "認証アプリの設定を開始"
|
registerTOTP: "認証アプリの設定を開始"
|
||||||
step1: "まず、{a}や{b}などの認証アプリをお使いのデバイスにインストールします。"
|
step1: "まず、{a}や{b}などの認証アプリをお使いのデバイスにインストールします。"
|
||||||
step2: "次に、表示されているQRコードをアプリでスキャンします。"
|
step2: "次に、表示されているQRコードをアプリでスキャンするか、ボタンをクリックして端末上でアプリを開きます。"
|
||||||
step2Click: "QRコードをクリックすると、お使いの端末にインストールされている認証アプリやキーリングに登録できます。"
|
|
||||||
step2Uri: "デスクトップアプリを使用する場合は次のURIを入力します"
|
step2Uri: "デスクトップアプリを使用する場合は次のURIを入力します"
|
||||||
step3Title: "確認コードを入力"
|
step3Title: "確認コードを入力"
|
||||||
step3: "アプリに表示されている確認コード(トークン)を入力します。"
|
step3: "アプリに表示されている確認コード(トークン)を入力します。"
|
||||||
|
@ -2407,6 +2412,8 @@ _pages:
|
||||||
section: "セクション"
|
section: "セクション"
|
||||||
image: "画像"
|
image: "画像"
|
||||||
button: "ボタン"
|
button: "ボタン"
|
||||||
|
dynamic: "動的ブロック"
|
||||||
|
dynamicDescription: "このブロックは廃止されています。今後は{play}を利用してください。"
|
||||||
|
|
||||||
note: "ノート埋め込み"
|
note: "ノート埋め込み"
|
||||||
_note:
|
_note:
|
||||||
|
@ -2692,3 +2699,22 @@ _offlineScreen:
|
||||||
title: "オフライン - サーバーに接続できません"
|
title: "オフライン - サーバーに接続できません"
|
||||||
header: "サーバーに接続できません"
|
header: "サーバーに接続できません"
|
||||||
|
|
||||||
|
_urlPreviewSetting:
|
||||||
|
title: "URLプレビューの設定"
|
||||||
|
enable: "URLプレビューを有効にする"
|
||||||
|
timeout: "プレビュー取得時のタイムアウト(ms)"
|
||||||
|
timeoutDescription: "プレビュー取得の所要時間がこの値を超えた場合、プレビューは生成されません。"
|
||||||
|
maximumContentLength: "Content-Lengthの最大値(byte)"
|
||||||
|
maximumContentLengthDescription: "Content-Lengthがこの値を超えた場合、プレビューは生成されません。"
|
||||||
|
requireContentLength: "Content-Lengthが取得できた場合のみプレビューを生成"
|
||||||
|
requireContentLengthDescription: "相手サーバがContent-Lengthを返さない場合、プレビューは生成されません。"
|
||||||
|
userAgent: "User-Agent"
|
||||||
|
userAgentDescription: "プレビュー取得時に使用されるUser-Agentを設定します。空欄の場合、デフォルトのUser-Agentが使用されます。"
|
||||||
|
summaryProxy: "プレビューを生成するプロキシのエンドポイント"
|
||||||
|
summaryProxyDescription: "Misskey本体ではなく、サマリープロキシを使用してプレビューを生成します。"
|
||||||
|
summaryProxyDescription2: "プロキシには下記パラメータがクエリ文字列として連携されます。プロキシ側がこれらをサポートしない場合、設定値は無視されます。"
|
||||||
|
|
||||||
|
_mediaControls:
|
||||||
|
pip: "ピクチャインピクチャ"
|
||||||
|
playbackRate: "再生速度"
|
||||||
|
loop: "ループ再生"
|
||||||
|
|
|
@ -56,9 +56,12 @@
|
||||||
"postcss": "8.4.35",
|
"postcss": "8.4.35",
|
||||||
"tar": "6.2.0",
|
"tar": "6.2.0",
|
||||||
"terser": "5.28.1",
|
"terser": "5.28.1",
|
||||||
"typescript": "5.3.3"
|
"typescript": "5.3.3",
|
||||||
|
"esbuild": "0.19.11",
|
||||||
|
"glob": "10.3.10"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@types/node": "^20.11.28",
|
||||||
"@typescript-eslint/eslint-plugin": "7.1.0",
|
"@typescript-eslint/eslint-plugin": "7.1.0",
|
||||||
"@typescript-eslint/parser": "7.1.0",
|
"@typescript-eslint/parser": "7.1.0",
|
||||||
"cross-env": "7.0.3",
|
"cross-env": "7.0.3",
|
||||||
|
|
|
@ -19,5 +19,6 @@
|
||||||
},
|
},
|
||||||
"target": "es2022"
|
"target": "es2022"
|
||||||
},
|
},
|
||||||
"minify": false
|
"minify": false,
|
||||||
|
"sourceMaps": "inline"
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||||
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
*/
|
||||||
|
|
||||||
|
export class UrlPreviewMeta1710512074000 {
|
||||||
|
name = 'UrlPreviewMeta1710512074000'
|
||||||
|
|
||||||
|
async up(queryRunner) {
|
||||||
|
await queryRunner.query(`
|
||||||
|
alter table meta
|
||||||
|
rename column "summalyProxy" to "urlPreviewSummaryProxyUrl";
|
||||||
|
alter table meta
|
||||||
|
add "urlPreviewEnabled" boolean default true not null;
|
||||||
|
alter table meta
|
||||||
|
add "urlPreviewTimeout" integer default 10000 not null;
|
||||||
|
alter table meta
|
||||||
|
add "urlPreviewMaximumContentLength" bigint default 10485760 not null;
|
||||||
|
alter table meta
|
||||||
|
add "urlPreviewRequireContentLength" boolean default false not null;
|
||||||
|
alter table meta
|
||||||
|
add "urlPreviewUserAgent" varchar(1024) default null;
|
||||||
|
`);
|
||||||
|
}
|
||||||
|
|
||||||
|
async down(queryRunner) {
|
||||||
|
await queryRunner.query(`
|
||||||
|
alter table meta
|
||||||
|
rename column "urlPreviewSummaryProxyUrl" to "summalyProxy";
|
||||||
|
alter table meta
|
||||||
|
drop column "urlPreviewEnabled";
|
||||||
|
alter table meta
|
||||||
|
drop column "urlPreviewTimeout";
|
||||||
|
alter table meta
|
||||||
|
drop column "urlPreviewMaximumContentLength";
|
||||||
|
alter table meta
|
||||||
|
drop column "urlPreviewRequireContentLength";
|
||||||
|
alter table meta
|
||||||
|
drop column "urlPreviewUserAgent";
|
||||||
|
`);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||||
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
*/
|
||||||
|
|
||||||
|
export class AntennaExcludeBots1710919614510 {
|
||||||
|
name = 'AntennaExcludeBots1710919614510'
|
||||||
|
|
||||||
|
async up(queryRunner) {
|
||||||
|
await queryRunner.query(`ALTER TABLE "antenna" ADD "excludeBots" boolean NOT NULL DEFAULT false`);
|
||||||
|
}
|
||||||
|
|
||||||
|
async down(queryRunner) {
|
||||||
|
await queryRunner.query(`ALTER TABLE "antenna" DROP COLUMN "excludeBots"`);
|
||||||
|
}
|
||||||
|
}
|
|
@ -80,7 +80,7 @@
|
||||||
"@fastify/static": "6.12.0",
|
"@fastify/static": "6.12.0",
|
||||||
"@fastify/view": "8.2.0",
|
"@fastify/view": "8.2.0",
|
||||||
"@misskey-dev/sharp-read-bmp": "1.2.0",
|
"@misskey-dev/sharp-read-bmp": "1.2.0",
|
||||||
"@misskey-dev/summaly": "5.0.3",
|
"@misskey-dev/summaly": "5.1.0",
|
||||||
"@nestjs/common": "10.3.3",
|
"@nestjs/common": "10.3.3",
|
||||||
"@nestjs/core": "10.3.3",
|
"@nestjs/core": "10.3.3",
|
||||||
"@nestjs/testing": "10.3.3",
|
"@nestjs/testing": "10.3.3",
|
||||||
|
|
|
@ -92,7 +92,7 @@ export class AntennaService implements OnApplicationShutdown {
|
||||||
}
|
}
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
public async addNoteToAntennas(note: MiNote, noteUser: { id: MiUser['id']; username: string; host: string | null; }): Promise<void> {
|
public async addNoteToAntennas(note: MiNote, noteUser: { id: MiUser['id']; username: string; host: string | null; isBot: boolean; }): Promise<void> {
|
||||||
const antennas = await this.getAntennas();
|
const antennas = await this.getAntennas();
|
||||||
const antennasWithMatchResult = await Promise.all(antennas.map(antenna => this.checkHitAntenna(antenna, note, noteUser).then(hit => [antenna, hit] as const)));
|
const antennasWithMatchResult = await Promise.all(antennas.map(antenna => this.checkHitAntenna(antenna, note, noteUser).then(hit => [antenna, hit] as const)));
|
||||||
const matchedAntennas = antennasWithMatchResult.filter(([, hit]) => hit).map(([antenna]) => antenna);
|
const matchedAntennas = antennasWithMatchResult.filter(([, hit]) => hit).map(([antenna]) => antenna);
|
||||||
|
@ -110,10 +110,12 @@ export class AntennaService implements OnApplicationShutdown {
|
||||||
// NOTE: フォローしているユーザーのノート、リストのユーザーのノート、グループのユーザーのノート指定はパフォーマンス上の理由で無効になっている
|
// NOTE: フォローしているユーザーのノート、リストのユーザーのノート、グループのユーザーのノート指定はパフォーマンス上の理由で無効になっている
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
public async checkHitAntenna(antenna: MiAntenna, note: (MiNote | Packed<'Note'>), noteUser: { id: MiUser['id']; username: string; host: string | null; }): Promise<boolean> {
|
public async checkHitAntenna(antenna: MiAntenna, note: (MiNote | Packed<'Note'>), noteUser: { id: MiUser['id']; username: string; host: string | null; isBot: boolean; }): Promise<boolean> {
|
||||||
if (note.visibility === 'specified') return false;
|
if (note.visibility === 'specified') return false;
|
||||||
if (note.visibility === 'followers') return false;
|
if (note.visibility === 'followers') return false;
|
||||||
|
|
||||||
|
if (antenna.excludeBots && noteUser.isBot) return false;
|
||||||
|
|
||||||
if (antenna.localOnly && noteUser.host != null) return false;
|
if (antenna.localOnly && noteUser.host != null) return false;
|
||||||
|
|
||||||
if (!antenna.withReplies && note.replyId != null) return false;
|
if (!antenna.withReplies && note.replyId != null) return false;
|
||||||
|
|
|
@ -14,11 +14,12 @@ import FFmpeg from 'fluent-ffmpeg';
|
||||||
import isSvg from 'is-svg';
|
import isSvg from 'is-svg';
|
||||||
import probeImageSize from 'probe-image-size';
|
import probeImageSize from 'probe-image-size';
|
||||||
import { type predictionType } from 'nsfwjs';
|
import { type predictionType } from 'nsfwjs';
|
||||||
import sharp from 'sharp';
|
|
||||||
import { sharpBmp } from '@misskey-dev/sharp-read-bmp';
|
import { sharpBmp } from '@misskey-dev/sharp-read-bmp';
|
||||||
import { encode } from 'blurhash';
|
import { encode } from 'blurhash';
|
||||||
import { createTempDir } from '@/misc/create-temp.js';
|
import { createTempDir } from '@/misc/create-temp.js';
|
||||||
import { AiService } from '@/core/AiService.js';
|
import { AiService } from '@/core/AiService.js';
|
||||||
|
import { LoggerService } from '@/core/LoggerService.js';
|
||||||
|
import type Logger from '@/logger.js';
|
||||||
import { bindThis } from '@/decorators.js';
|
import { bindThis } from '@/decorators.js';
|
||||||
|
|
||||||
export type FileInfo = {
|
export type FileInfo = {
|
||||||
|
@ -49,9 +50,13 @@ const TYPE_SVG = {
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class FileInfoService {
|
export class FileInfoService {
|
||||||
|
private logger: Logger;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private aiService: AiService,
|
private aiService: AiService,
|
||||||
|
private loggerService: LoggerService,
|
||||||
) {
|
) {
|
||||||
|
this.logger = this.loggerService.getLogger('file-info');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -317,6 +322,34 @@ export class FileInfoService {
|
||||||
return mime;
|
return mime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ビデオファイルにビデオトラックがあるかどうかチェック
|
||||||
|
* (ない場合:m4a, webmなど)
|
||||||
|
*
|
||||||
|
* @param path ファイルパス
|
||||||
|
* @returns ビデオトラックがあるかどうか(エラー発生時は常に`true`を返す)
|
||||||
|
*/
|
||||||
|
@bindThis
|
||||||
|
private hasVideoTrackOnVideoFile(path: string): Promise<boolean> {
|
||||||
|
const sublogger = this.logger.createSubLogger('ffprobe');
|
||||||
|
sublogger.info(`Checking the video file. File path: ${path}`);
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
try {
|
||||||
|
FFmpeg.ffprobe(path, (err, metadata) => {
|
||||||
|
if (err) {
|
||||||
|
sublogger.warn(`Could not check the video file. Returns true. File path: ${path}`, err);
|
||||||
|
resolve(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
resolve(metadata.streams.some((stream) => stream.codec_type === 'video'));
|
||||||
|
});
|
||||||
|
} catch (err) {
|
||||||
|
sublogger.warn(`Could not check the video file. Returns true. File path: ${path}`, err as Error);
|
||||||
|
resolve(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Detect MIME Type and extension
|
* Detect MIME Type and extension
|
||||||
*/
|
*/
|
||||||
|
@ -339,6 +372,20 @@ export class FileInfoService {
|
||||||
return TYPE_SVG;
|
return TYPE_SVG;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((type.mime.startsWith('video') || type.mime === 'application/ogg') && !(await this.hasVideoTrackOnVideoFile(path))) {
|
||||||
|
const newMime = `audio/${type.mime.split('/')[1]}`;
|
||||||
|
if (newMime === 'audio/mp4') {
|
||||||
|
return {
|
||||||
|
mime: 'audio/mp4',
|
||||||
|
ext: 'm4a',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
mime: newMime,
|
||||||
|
ext: type.ext,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
mime: this.fixMime(type.mime),
|
mime: this.fixMime(type.mime),
|
||||||
ext: type.ext,
|
ext: type.ext,
|
||||||
|
|
|
@ -39,6 +39,7 @@ export class AntennaEntityService {
|
||||||
caseSensitive: antenna.caseSensitive,
|
caseSensitive: antenna.caseSensitive,
|
||||||
localOnly: antenna.localOnly,
|
localOnly: antenna.localOnly,
|
||||||
notify: antenna.notify,
|
notify: antenna.notify,
|
||||||
|
excludeBots: antenna.excludeBots,
|
||||||
withReplies: antenna.withReplies,
|
withReplies: antenna.withReplies,
|
||||||
withFile: antenna.withFile,
|
withFile: antenna.withFile,
|
||||||
isActive: antenna.isActive,
|
isActive: antenna.isActive,
|
||||||
|
|
|
@ -111,6 +111,7 @@ export class MetaEntityService {
|
||||||
policies: { ...DEFAULT_POLICIES, ...instance.policies },
|
policies: { ...DEFAULT_POLICIES, ...instance.policies },
|
||||||
|
|
||||||
mediaProxy: this.config.mediaProxy,
|
mediaProxy: this.config.mediaProxy,
|
||||||
|
enableUrlPreview: instance.urlPreviewEnabled,
|
||||||
};
|
};
|
||||||
|
|
||||||
return packed;
|
return packed;
|
||||||
|
|
|
@ -72,6 +72,11 @@ export class MiAntenna {
|
||||||
})
|
})
|
||||||
public caseSensitive: boolean;
|
public caseSensitive: boolean;
|
||||||
|
|
||||||
|
@Column('boolean', {
|
||||||
|
default: false,
|
||||||
|
})
|
||||||
|
public excludeBots: boolean;
|
||||||
|
|
||||||
@Column('boolean', {
|
@Column('boolean', {
|
||||||
default: false,
|
default: false,
|
||||||
})
|
})
|
||||||
|
|
|
@ -299,12 +299,6 @@ export class MiMeta {
|
||||||
})
|
})
|
||||||
public enableSensitiveMediaDetectionForVideos: boolean;
|
public enableSensitiveMediaDetectionForVideos: boolean;
|
||||||
|
|
||||||
@Column('varchar', {
|
|
||||||
length: 1024,
|
|
||||||
nullable: true,
|
|
||||||
})
|
|
||||||
public summalyProxy: string | null;
|
|
||||||
|
|
||||||
@Column('boolean', {
|
@Column('boolean', {
|
||||||
default: false,
|
default: false,
|
||||||
})
|
})
|
||||||
|
@ -631,4 +625,36 @@ export class MiMeta {
|
||||||
nullable: true,
|
nullable: true,
|
||||||
})
|
})
|
||||||
public proxyCheckioApiKey: string;
|
public proxyCheckioApiKey: string;
|
||||||
|
|
||||||
|
@Column('boolean', {
|
||||||
|
default: true,
|
||||||
|
})
|
||||||
|
public urlPreviewEnabled: boolean;
|
||||||
|
|
||||||
|
@Column('integer', {
|
||||||
|
default: 10000,
|
||||||
|
})
|
||||||
|
public urlPreviewTimeout: number;
|
||||||
|
|
||||||
|
@Column('bigint', {
|
||||||
|
default: 1024 * 1024 * 10,
|
||||||
|
})
|
||||||
|
public urlPreviewMaximumContentLength: number;
|
||||||
|
|
||||||
|
@Column('boolean', {
|
||||||
|
default: true,
|
||||||
|
})
|
||||||
|
public urlPreviewRequireContentLength: boolean;
|
||||||
|
|
||||||
|
@Column('varchar', {
|
||||||
|
length: 1024,
|
||||||
|
nullable: true,
|
||||||
|
})
|
||||||
|
public urlPreviewSummaryProxyUrl: string | null;
|
||||||
|
|
||||||
|
@Column('varchar', {
|
||||||
|
length: 1024,
|
||||||
|
nullable: true,
|
||||||
|
})
|
||||||
|
public urlPreviewUserAgent: string | null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,6 +76,11 @@ export const packedAntennaSchema = {
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
optional: false, nullable: false,
|
optional: false, nullable: false,
|
||||||
},
|
},
|
||||||
|
excludeBots: {
|
||||||
|
type: 'boolean',
|
||||||
|
optional: false, nullable: false,
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
withReplies: {
|
withReplies: {
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
optional: false, nullable: false,
|
optional: false, nullable: false,
|
||||||
|
|
|
@ -207,6 +207,10 @@ export const packedMetaLiteSchema = {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
optional: false, nullable: false,
|
optional: false, nullable: false,
|
||||||
},
|
},
|
||||||
|
enableUrlPreview: {
|
||||||
|
type: 'boolean',
|
||||||
|
optional: false, nullable: false,
|
||||||
|
},
|
||||||
backgroundImageUrl: {
|
backgroundImageUrl: {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
optional: false, nullable: true,
|
optional: false, nullable: true,
|
||||||
|
|
|
@ -63,7 +63,7 @@ export class CleanRemoteFilesProcessorService {
|
||||||
isLink: false,
|
isLink: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
job.updateProgress(deletedCount / total);
|
job.updateProgress(100 / total * deletedCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.logger.succ('All cached remote files has been deleted.');
|
this.logger.succ('All cached remote files has been deleted.');
|
||||||
|
|
|
@ -81,6 +81,7 @@ export class ExportAntennasProcessorService {
|
||||||
}) : null,
|
}) : null,
|
||||||
caseSensitive: antenna.caseSensitive,
|
caseSensitive: antenna.caseSensitive,
|
||||||
localOnly: antenna.localOnly,
|
localOnly: antenna.localOnly,
|
||||||
|
excludeBots: antenna.excludeBots,
|
||||||
withReplies: antenna.withReplies,
|
withReplies: antenna.withReplies,
|
||||||
withFile: antenna.withFile,
|
withFile: antenna.withFile,
|
||||||
notify: antenna.notify,
|
notify: antenna.notify,
|
||||||
|
|
|
@ -44,6 +44,7 @@ const validate = new Ajv().compile({
|
||||||
} },
|
} },
|
||||||
caseSensitive: { type: 'boolean' },
|
caseSensitive: { type: 'boolean' },
|
||||||
localOnly: { type: 'boolean' },
|
localOnly: { type: 'boolean' },
|
||||||
|
excludeBots: { type: 'boolean' },
|
||||||
withReplies: { type: 'boolean' },
|
withReplies: { type: 'boolean' },
|
||||||
withFile: { type: 'boolean' },
|
withFile: { type: 'boolean' },
|
||||||
notify: { type: 'boolean' },
|
notify: { type: 'boolean' },
|
||||||
|
@ -88,6 +89,7 @@ export class ImportAntennasProcessorService {
|
||||||
users: (antenna.src === 'list' && antenna.userListAccts !== null ? antenna.userListAccts : antenna.users).filter(Boolean),
|
users: (antenna.src === 'list' && antenna.userListAccts !== null ? antenna.userListAccts : antenna.users).filter(Boolean),
|
||||||
caseSensitive: antenna.caseSensitive,
|
caseSensitive: antenna.caseSensitive,
|
||||||
localOnly: antenna.localOnly,
|
localOnly: antenna.localOnly,
|
||||||
|
excludeBots: antenna.excludeBots,
|
||||||
withReplies: antenna.withReplies,
|
withReplies: antenna.withReplies,
|
||||||
withFile: antenna.withFile,
|
withFile: antenna.withFile,
|
||||||
notify: antenna.notify,
|
notify: antenna.notify,
|
||||||
|
|
|
@ -434,6 +434,8 @@ export const meta = {
|
||||||
summalyProxy: {
|
summalyProxy: {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
optional: false, nullable: true,
|
optional: false, nullable: true,
|
||||||
|
deprecated: true,
|
||||||
|
description: '[Deprecated] Use "urlPreviewSummaryProxyUrl" instead.',
|
||||||
},
|
},
|
||||||
themeColor: {
|
themeColor: {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
|
@ -470,6 +472,30 @@ export const meta = {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
optional: false, nullable: true,
|
optional: false, nullable: true,
|
||||||
},
|
},
|
||||||
|
urlPreviewEnabled: {
|
||||||
|
type: 'boolean',
|
||||||
|
optional: false, nullable: false,
|
||||||
|
},
|
||||||
|
urlPreviewTimeout: {
|
||||||
|
type: 'number',
|
||||||
|
optional: false, nullable: false,
|
||||||
|
},
|
||||||
|
urlPreviewMaximumContentLength: {
|
||||||
|
type: 'number',
|
||||||
|
optional: false, nullable: false,
|
||||||
|
},
|
||||||
|
urlPreviewRequireContentLength: {
|
||||||
|
type: 'boolean',
|
||||||
|
optional: false, nullable: false,
|
||||||
|
},
|
||||||
|
urlPreviewUserAgent: {
|
||||||
|
type: 'string',
|
||||||
|
optional: false, nullable: true,
|
||||||
|
},
|
||||||
|
urlPreviewSummaryProxyUrl: {
|
||||||
|
type: 'string',
|
||||||
|
optional: false, nullable: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
} as const;
|
} as const;
|
||||||
|
@ -553,7 +579,6 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
setSensitiveFlagAutomatically: instance.setSensitiveFlagAutomatically,
|
setSensitiveFlagAutomatically: instance.setSensitiveFlagAutomatically,
|
||||||
enableSensitiveMediaDetectionForVideos: instance.enableSensitiveMediaDetectionForVideos,
|
enableSensitiveMediaDetectionForVideos: instance.enableSensitiveMediaDetectionForVideos,
|
||||||
proxyAccountId: instance.proxyAccountId,
|
proxyAccountId: instance.proxyAccountId,
|
||||||
summalyProxy: instance.summalyProxy,
|
|
||||||
email: instance.email,
|
email: instance.email,
|
||||||
smtpSecure: instance.smtpSecure,
|
smtpSecure: instance.smtpSecure,
|
||||||
smtpHost: instance.smtpHost,
|
smtpHost: instance.smtpHost,
|
||||||
|
@ -604,6 +629,13 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
enableGDPRMode: instance.enableGDPRMode,
|
enableGDPRMode: instance.enableGDPRMode,
|
||||||
enableProxyCheckio: instance.enableProxyCheckio,
|
enableProxyCheckio: instance.enableProxyCheckio,
|
||||||
proxyCheckioApiKey: instance.proxyCheckioApiKey,
|
proxyCheckioApiKey: instance.proxyCheckioApiKey,
|
||||||
|
summalyProxy: instance.urlPreviewSummaryProxyUrl,
|
||||||
|
urlPreviewEnabled: instance.urlPreviewEnabled,
|
||||||
|
urlPreviewTimeout: instance.urlPreviewTimeout,
|
||||||
|
urlPreviewMaximumContentLength: instance.urlPreviewMaximumContentLength,
|
||||||
|
urlPreviewRequireContentLength: instance.urlPreviewRequireContentLength,
|
||||||
|
urlPreviewUserAgent: instance.urlPreviewUserAgent,
|
||||||
|
urlPreviewSummaryProxyUrl: instance.urlPreviewSummaryProxyUrl,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -153,6 +153,16 @@ export const paramDef = {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
summalyProxy: {
|
||||||
|
type: 'string', nullable: true,
|
||||||
|
description: '[Deprecated] Use "urlPreviewSummaryProxyUrl" instead.',
|
||||||
|
},
|
||||||
|
urlPreviewEnabled: { type: 'boolean' },
|
||||||
|
urlPreviewTimeout: { type: 'integer' },
|
||||||
|
urlPreviewMaximumContentLength: { type: 'integer' },
|
||||||
|
urlPreviewRequireContentLength: { type: 'boolean' },
|
||||||
|
urlPreviewUserAgent: { type: 'string', nullable: true },
|
||||||
|
urlPreviewSummaryProxyUrl: { type: 'string', nullable: true },
|
||||||
EmojiBotToken: { type: 'string', nullable: true },
|
EmojiBotToken: { type: 'string', nullable: true },
|
||||||
ApiBase: { type: 'string', nullable: true },
|
ApiBase: { type: 'string', nullable: true },
|
||||||
enableGDPRMode: { type: 'boolean' },
|
enableGDPRMode: { type: 'boolean' },
|
||||||
|
@ -391,10 +401,6 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
set.langs = ps.langs.filter(Boolean);
|
set.langs = ps.langs.filter(Boolean);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ps.summalyProxy !== undefined) {
|
|
||||||
set.summalyProxy = ps.summalyProxy;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ps.enableEmail !== undefined) {
|
if (ps.enableEmail !== undefined) {
|
||||||
set.enableEmail = ps.enableEmail;
|
set.enableEmail = ps.enableEmail;
|
||||||
}
|
}
|
||||||
|
@ -619,6 +625,32 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
set.bannedEmailDomains = ps.bannedEmailDomains;
|
set.bannedEmailDomains = ps.bannedEmailDomains;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ps.urlPreviewEnabled !== undefined) {
|
||||||
|
set.urlPreviewEnabled = ps.urlPreviewEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ps.urlPreviewTimeout !== undefined) {
|
||||||
|
set.urlPreviewTimeout = ps.urlPreviewTimeout;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ps.urlPreviewMaximumContentLength !== undefined) {
|
||||||
|
set.urlPreviewMaximumContentLength = ps.urlPreviewMaximumContentLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ps.urlPreviewRequireContentLength !== undefined) {
|
||||||
|
set.urlPreviewRequireContentLength = ps.urlPreviewRequireContentLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ps.urlPreviewUserAgent !== undefined) {
|
||||||
|
const value = (ps.urlPreviewUserAgent ?? '').trim();
|
||||||
|
set.urlPreviewUserAgent = value === '' ? null : ps.urlPreviewUserAgent;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ps.summalyProxy !== undefined || ps.urlPreviewSummaryProxyUrl !== undefined) {
|
||||||
|
const value = ((ps.urlPreviewSummaryProxyUrl ?? ps.summalyProxy) ?? '').trim();
|
||||||
|
set.urlPreviewSummaryProxyUrl = value === '' ? null : value;
|
||||||
|
}
|
||||||
|
|
||||||
const before = await this.metaService.fetch(true);
|
const before = await this.metaService.fetch(true);
|
||||||
|
|
||||||
await this.metaService.update(set);
|
await this.metaService.update(set);
|
||||||
|
|
|
@ -64,6 +64,7 @@ export const paramDef = {
|
||||||
} },
|
} },
|
||||||
caseSensitive: { type: 'boolean' },
|
caseSensitive: { type: 'boolean' },
|
||||||
localOnly: { type: 'boolean' },
|
localOnly: { type: 'boolean' },
|
||||||
|
excludeBots: { type: 'boolean' },
|
||||||
withReplies: { type: 'boolean' },
|
withReplies: { type: 'boolean' },
|
||||||
withFile: { type: 'boolean' },
|
withFile: { type: 'boolean' },
|
||||||
notify: { type: 'boolean' },
|
notify: { type: 'boolean' },
|
||||||
|
@ -124,6 +125,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
users: ps.users,
|
users: ps.users,
|
||||||
caseSensitive: ps.caseSensitive,
|
caseSensitive: ps.caseSensitive,
|
||||||
localOnly: ps.localOnly,
|
localOnly: ps.localOnly,
|
||||||
|
excludeBots: ps.excludeBots,
|
||||||
withReplies: ps.withReplies,
|
withReplies: ps.withReplies,
|
||||||
withFile: ps.withFile,
|
withFile: ps.withFile,
|
||||||
notify: ps.notify,
|
notify: ps.notify,
|
||||||
|
|
|
@ -63,6 +63,7 @@ export const paramDef = {
|
||||||
} },
|
} },
|
||||||
caseSensitive: { type: 'boolean' },
|
caseSensitive: { type: 'boolean' },
|
||||||
localOnly: { type: 'boolean' },
|
localOnly: { type: 'boolean' },
|
||||||
|
excludeBots: { type: 'boolean' },
|
||||||
withReplies: { type: 'boolean' },
|
withReplies: { type: 'boolean' },
|
||||||
withFile: { type: 'boolean' },
|
withFile: { type: 'boolean' },
|
||||||
notify: { type: 'boolean' },
|
notify: { type: 'boolean' },
|
||||||
|
@ -120,6 +121,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
users: ps.users,
|
users: ps.users,
|
||||||
caseSensitive: ps.caseSensitive,
|
caseSensitive: ps.caseSensitive,
|
||||||
localOnly: ps.localOnly,
|
localOnly: ps.localOnly,
|
||||||
|
excludeBots: ps.excludeBots,
|
||||||
withReplies: ps.withReplies,
|
withReplies: ps.withReplies,
|
||||||
withFile: ps.withFile,
|
withFile: ps.withFile,
|
||||||
notify: ps.notify,
|
notify: ps.notify,
|
||||||
|
|
|
@ -21,7 +21,7 @@ export const meta = {
|
||||||
|
|
||||||
res: {
|
res: {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
optional: false, nullable: false,
|
optional: true, nullable: false,
|
||||||
properties: {
|
properties: {
|
||||||
sourceLang: { type: 'string' },
|
sourceLang: { type: 'string' },
|
||||||
text: { type: 'string' },
|
text: { type: 'string' },
|
||||||
|
@ -39,6 +39,11 @@ export const meta = {
|
||||||
code: 'NO_SUCH_NOTE',
|
code: 'NO_SUCH_NOTE',
|
||||||
id: 'bea9b03f-36e0-49c5-a4db-627a029f8971',
|
id: 'bea9b03f-36e0-49c5-a4db-627a029f8971',
|
||||||
},
|
},
|
||||||
|
cannotTranslateInvisibleNote: {
|
||||||
|
message: 'Cannot translate invisible note.',
|
||||||
|
code: 'CANNOT_TRANSLATE_INVISIBLE_NOTE',
|
||||||
|
id: 'ea29f2ca-c368-43b3-aaf1-5ac3e74bbe5d',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
@ -72,17 +77,17 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!(await this.noteEntityService.isVisibleForMe(note, me.id))) {
|
if (!(await this.noteEntityService.isVisibleForMe(note, me.id))) {
|
||||||
return 204; // TODO: 良い感じのエラー返す
|
throw new ApiError(meta.errors.cannotTranslateInvisibleNote);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (note.text == null) {
|
if (note.text == null) {
|
||||||
return 204;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const instance = await this.metaService.fetch();
|
const instance = await this.metaService.fetch();
|
||||||
|
|
||||||
if (instance.deeplAuthKey == null) {
|
if (instance.deeplAuthKey == null) {
|
||||||
return 204; // TODO: 良い感じのエラー返す
|
throw new ApiError(meta.errors.unavailable);
|
||||||
}
|
}
|
||||||
|
|
||||||
let targetLang = ps.targetLang;
|
let targetLang = ps.targetLang;
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
import { IsNull } from 'typeorm';
|
import { IsNull } from 'typeorm';
|
||||||
import { Inject, Injectable } from '@nestjs/common';
|
import { Inject, Injectable } from '@nestjs/common';
|
||||||
import type { UsersRepository, FollowingsRepository, UserProfilesRepository } from '@/models/_.js';
|
import type { UsersRepository, FollowingsRepository, UserProfilesRepository } from '@/models/_.js';
|
||||||
|
import { birthdaySchema } from '@/models/User.js';
|
||||||
import { Endpoint } from '@/server/api/endpoint-base.js';
|
import { Endpoint } from '@/server/api/endpoint-base.js';
|
||||||
import { QueryService } from '@/core/QueryService.js';
|
import { QueryService } from '@/core/QueryService.js';
|
||||||
import { FollowingEntityService } from '@/core/entities/FollowingEntityService.js';
|
import { FollowingEntityService } from '@/core/entities/FollowingEntityService.js';
|
||||||
|
@ -66,7 +67,7 @@ export const paramDef = {
|
||||||
description: 'The local host is represented with `null`.',
|
description: 'The local host is represented with `null`.',
|
||||||
},
|
},
|
||||||
|
|
||||||
birthday: { type: 'string', nullable: true },
|
birthday: { ...birthdaySchema, nullable: true },
|
||||||
},
|
},
|
||||||
anyOf: [
|
anyOf: [
|
||||||
{ required: ['userId'] },
|
{ required: ['userId'] },
|
||||||
|
@ -127,9 +128,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
|
|
||||||
if (ps.birthday) {
|
if (ps.birthday) {
|
||||||
try {
|
try {
|
||||||
const d = new Date(ps.birthday);
|
const birthday = ps.birthday.substring(5, 10);
|
||||||
d.setHours(0, 0, 0, 0);
|
|
||||||
const birthday = `${(d.getMonth() + 1).toString().padStart(2, '0')}-${d.getDate().toString().padStart(2, '0')}`;
|
|
||||||
const birthdayUserQuery = this.userProfilesRepository.createQueryBuilder('user_profile');
|
const birthdayUserQuery = this.userProfilesRepository.createQueryBuilder('user_profile');
|
||||||
birthdayUserQuery.select('user_profile.userId')
|
birthdayUserQuery.select('user_profile.userId')
|
||||||
.where(`SUBSTR(user_profile.birthday, 6, 5) = '${birthday}'`);
|
.where(`SUBSTR(user_profile.birthday, 6, 5) = '${birthday}'`);
|
||||||
|
|
|
@ -93,7 +93,7 @@ export function genOpenapiSpec(config: Config, includeSelfRef = false) {
|
||||||
const hasBody = (schema.type === 'object' && schema.properties && Object.keys(schema.properties).length >= 1);
|
const hasBody = (schema.type === 'object' && schema.properties && Object.keys(schema.properties).length >= 1);
|
||||||
|
|
||||||
const info = {
|
const info = {
|
||||||
operationId: endpoint.name,
|
operationId: endpoint.name.replaceAll('/', '___'), // NOTE: スラッシュは使えない
|
||||||
summary: endpoint.name,
|
summary: endpoint.name,
|
||||||
description: desc,
|
description: desc,
|
||||||
externalDocs: {
|
externalDocs: {
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
import { Inject, Injectable } from '@nestjs/common';
|
import { Inject, Injectable } from '@nestjs/common';
|
||||||
import { summaly } from '@misskey-dev/summaly';
|
import { summaly } from '@misskey-dev/summaly';
|
||||||
|
import { SummalyResult } from '@misskey-dev/summaly/built/summary.js';
|
||||||
import { DI } from '@/di-symbols.js';
|
import { DI } from '@/di-symbols.js';
|
||||||
import type { Config } from '@/config.js';
|
import type { Config } from '@/config.js';
|
||||||
import { MetaService } from '@/core/MetaService.js';
|
import { MetaService } from '@/core/MetaService.js';
|
||||||
|
@ -14,6 +15,7 @@ import { query } from '@/misc/prelude/url.js';
|
||||||
import { LoggerService } from '@/core/LoggerService.js';
|
import { LoggerService } from '@/core/LoggerService.js';
|
||||||
import { bindThis } from '@/decorators.js';
|
import { bindThis } from '@/decorators.js';
|
||||||
import { ApiError } from '@/server/api/error.js';
|
import { ApiError } from '@/server/api/error.js';
|
||||||
|
import { MiMeta } from '@/models/Meta.js';
|
||||||
import type { FastifyRequest, FastifyReply } from 'fastify';
|
import type { FastifyRequest, FastifyReply } from 'fastify';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
|
@ -62,24 +64,25 @@ export class UrlPreviewService {
|
||||||
|
|
||||||
const meta = await this.metaService.fetch();
|
const meta = await this.metaService.fetch();
|
||||||
|
|
||||||
this.logger.info(meta.summalyProxy
|
if (!meta.urlPreviewEnabled) {
|
||||||
|
reply.code(403);
|
||||||
|
return {
|
||||||
|
error: new ApiError({
|
||||||
|
message: 'URL preview is disabled',
|
||||||
|
code: 'URL_PREVIEW_DISABLED',
|
||||||
|
id: '58b36e13-d2f5-0323-b0c6-76aa9dabefb8',
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
this.logger.info(meta.urlPreviewSummaryProxyUrl
|
||||||
? `(Proxy) Getting preview of ${url}@${lang} ...`
|
? `(Proxy) Getting preview of ${url}@${lang} ...`
|
||||||
: `Getting preview of ${url}@${lang} ...`);
|
: `Getting preview of ${url}@${lang} ...`);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const summary = meta.summalyProxy ?
|
const summary = meta.urlPreviewSummaryProxyUrl
|
||||||
await this.httpRequestService.getJson<ReturnType<typeof summaly>>(`${meta.summalyProxy}?${query({
|
? await this.fetchSummaryFromProxy(url, meta, lang)
|
||||||
url: url,
|
: await this.fetchSummary(url, meta, lang);
|
||||||
lang: lang ?? 'ja-JP',
|
|
||||||
})}`)
|
|
||||||
:
|
|
||||||
await summaly(url, {
|
|
||||||
followRedirects: false,
|
|
||||||
lang: lang ?? 'ja-JP',
|
|
||||||
agent: this.config.proxy ? {
|
|
||||||
http: this.httpRequestService.httpAgent,
|
|
||||||
https: this.httpRequestService.httpsAgent,
|
|
||||||
} : undefined,
|
|
||||||
});
|
|
||||||
|
|
||||||
this.logger.succ(`Got preview of ${url}: ${summary.title}`);
|
this.logger.succ(`Got preview of ${url}: ${summary.title}`);
|
||||||
|
|
||||||
|
@ -100,6 +103,7 @@ export class UrlPreviewService {
|
||||||
return summary;
|
return summary;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this.logger.warn(`Failed to get preview of ${url}: ${err}`);
|
this.logger.warn(`Failed to get preview of ${url}: ${err}`);
|
||||||
|
|
||||||
reply.code(422);
|
reply.code(422);
|
||||||
reply.header('Cache-Control', 'max-age=86400, immutable');
|
reply.header('Cache-Control', 'max-age=86400, immutable');
|
||||||
return {
|
return {
|
||||||
|
@ -111,4 +115,37 @@ export class UrlPreviewService {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fetchSummary(url: string, meta: MiMeta, lang?: string): Promise<SummalyResult> {
|
||||||
|
const agent = this.config.proxy
|
||||||
|
? {
|
||||||
|
http: this.httpRequestService.httpAgent,
|
||||||
|
https: this.httpRequestService.httpsAgent,
|
||||||
|
}
|
||||||
|
: undefined;
|
||||||
|
|
||||||
|
return summaly(url, {
|
||||||
|
followRedirects: false,
|
||||||
|
lang: lang ?? 'ja-JP',
|
||||||
|
agent: agent,
|
||||||
|
userAgent: meta.urlPreviewUserAgent ?? undefined,
|
||||||
|
operationTimeout: meta.urlPreviewTimeout,
|
||||||
|
contentLengthLimit: meta.urlPreviewMaximumContentLength,
|
||||||
|
contentLengthRequired: meta.urlPreviewRequireContentLength,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private fetchSummaryFromProxy(url: string, meta: MiMeta, lang?: string): Promise<SummalyResult> {
|
||||||
|
const proxy = meta.urlPreviewSummaryProxyUrl!;
|
||||||
|
const queryStr = query({
|
||||||
|
url: url,
|
||||||
|
lang: lang ?? 'ja-JP',
|
||||||
|
userAgent: meta.urlPreviewUserAgent ?? undefined,
|
||||||
|
operationTimeout: meta.urlPreviewTimeout,
|
||||||
|
contentLengthLimit: meta.urlPreviewMaximumContentLength,
|
||||||
|
contentLengthRequired: meta.urlPreviewRequireContentLength,
|
||||||
|
});
|
||||||
|
|
||||||
|
return this.httpRequestService.getJson<SummalyResult>(`${proxy}?${queryStr}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,6 +44,7 @@ describe('アンテナ', () => {
|
||||||
users: [''],
|
users: [''],
|
||||||
withFile: false,
|
withFile: false,
|
||||||
withReplies: false,
|
withReplies: false,
|
||||||
|
excludeBots: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
let root: User;
|
let root: User;
|
||||||
|
@ -156,6 +157,7 @@ describe('アンテナ', () => {
|
||||||
users: [''],
|
users: [''],
|
||||||
withFile: false,
|
withFile: false,
|
||||||
withReplies: false,
|
withReplies: false,
|
||||||
|
excludeBots: false,
|
||||||
localOnly: false,
|
localOnly: false,
|
||||||
};
|
};
|
||||||
assert.deepStrictEqual(response, expected);
|
assert.deepStrictEqual(response, expected);
|
||||||
|
|
|
@ -8,12 +8,13 @@ process.env.NODE_ENV = 'test';
|
||||||
import * as assert from 'assert';
|
import * as assert from 'assert';
|
||||||
import { MiNote } from '@/models/Note.js';
|
import { MiNote } from '@/models/Note.js';
|
||||||
import { MAX_NOTE_TEXT_LENGTH } from '@/const.js';
|
import { MAX_NOTE_TEXT_LENGTH } from '@/const.js';
|
||||||
import { api, initTestDb, post, signup, uploadFile, uploadUrl } from '../utils.js';
|
import { api, initTestDb, post, role, signup, uploadFile, uploadUrl } from '../utils.js';
|
||||||
import type * as misskey from 'misskey-js';
|
import type * as misskey from 'misskey-js';
|
||||||
|
|
||||||
describe('Note', () => {
|
describe('Note', () => {
|
||||||
let Notes: any;
|
let Notes: any;
|
||||||
|
|
||||||
|
let root: misskey.entities.SignupResponse;
|
||||||
let alice: misskey.entities.SignupResponse;
|
let alice: misskey.entities.SignupResponse;
|
||||||
let bob: misskey.entities.SignupResponse;
|
let bob: misskey.entities.SignupResponse;
|
||||||
let tom: misskey.entities.SignupResponse;
|
let tom: misskey.entities.SignupResponse;
|
||||||
|
@ -21,6 +22,7 @@ describe('Note', () => {
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
const connection = await initTestDb(true);
|
const connection = await initTestDb(true);
|
||||||
Notes = connection.getRepository(MiNote);
|
Notes = connection.getRepository(MiNote);
|
||||||
|
root = await signup({ username: 'root' });
|
||||||
alice = await signup({ username: 'alice' });
|
alice = await signup({ username: 'alice' });
|
||||||
bob = await signup({ username: 'bob' });
|
bob = await signup({ username: 'bob' });
|
||||||
tom = await signup({ username: 'tom', host: 'example.com' });
|
tom = await signup({ username: 'tom', host: 'example.com' });
|
||||||
|
@ -473,14 +475,14 @@ describe('Note', () => {
|
||||||
value: true,
|
value: true,
|
||||||
},
|
},
|
||||||
} as any,
|
} as any,
|
||||||
}, alice);
|
}, root);
|
||||||
|
|
||||||
assert.strictEqual(res.status, 200);
|
assert.strictEqual(res.status, 200);
|
||||||
|
|
||||||
const assign = await api('admin/roles/assign', {
|
const assign = await api('admin/roles/assign', {
|
||||||
userId: alice.id,
|
userId: alice.id,
|
||||||
roleId: res.body.id,
|
roleId: res.body.id,
|
||||||
}, alice);
|
}, root);
|
||||||
|
|
||||||
assert.strictEqual(assign.status, 204);
|
assert.strictEqual(assign.status, 204);
|
||||||
assert.strictEqual(file.body!.isSensitive, false);
|
assert.strictEqual(file.body!.isSensitive, false);
|
||||||
|
@ -508,11 +510,11 @@ describe('Note', () => {
|
||||||
await api('admin/roles/unassign', {
|
await api('admin/roles/unassign', {
|
||||||
userId: alice.id,
|
userId: alice.id,
|
||||||
roleId: res.body.id,
|
roleId: res.body.id,
|
||||||
});
|
}, root);
|
||||||
|
|
||||||
await api('admin/roles/delete', {
|
await api('admin/roles/delete', {
|
||||||
roleId: res.body.id,
|
roleId: res.body.id,
|
||||||
}, alice);
|
}, root);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -644,7 +646,7 @@ describe('Note', () => {
|
||||||
sensitiveWords: [
|
sensitiveWords: [
|
||||||
'test',
|
'test',
|
||||||
],
|
],
|
||||||
}, alice);
|
}, root);
|
||||||
|
|
||||||
assert.strictEqual(sensitive.status, 204);
|
assert.strictEqual(sensitive.status, 204);
|
||||||
|
|
||||||
|
@ -663,7 +665,7 @@ describe('Note', () => {
|
||||||
sensitiveWords: [
|
sensitiveWords: [
|
||||||
'/Test/i',
|
'/Test/i',
|
||||||
],
|
],
|
||||||
}, alice);
|
}, root);
|
||||||
|
|
||||||
assert.strictEqual(sensitive.status, 204);
|
assert.strictEqual(sensitive.status, 204);
|
||||||
|
|
||||||
|
@ -680,7 +682,7 @@ describe('Note', () => {
|
||||||
sensitiveWords: [
|
sensitiveWords: [
|
||||||
'Test hoge',
|
'Test hoge',
|
||||||
],
|
],
|
||||||
}, alice);
|
}, root);
|
||||||
|
|
||||||
assert.strictEqual(sensitive.status, 204);
|
assert.strictEqual(sensitive.status, 204);
|
||||||
|
|
||||||
|
@ -697,7 +699,7 @@ describe('Note', () => {
|
||||||
prohibitedWords: [
|
prohibitedWords: [
|
||||||
'test',
|
'test',
|
||||||
],
|
],
|
||||||
}, alice);
|
}, root);
|
||||||
|
|
||||||
assert.strictEqual(prohibited.status, 204);
|
assert.strictEqual(prohibited.status, 204);
|
||||||
|
|
||||||
|
@ -716,7 +718,7 @@ describe('Note', () => {
|
||||||
prohibitedWords: [
|
prohibitedWords: [
|
||||||
'/Test/i',
|
'/Test/i',
|
||||||
],
|
],
|
||||||
}, alice);
|
}, root);
|
||||||
|
|
||||||
assert.strictEqual(prohibited.status, 204);
|
assert.strictEqual(prohibited.status, 204);
|
||||||
|
|
||||||
|
@ -733,7 +735,7 @@ describe('Note', () => {
|
||||||
prohibitedWords: [
|
prohibitedWords: [
|
||||||
'Test hoge',
|
'Test hoge',
|
||||||
],
|
],
|
||||||
}, alice);
|
}, root);
|
||||||
|
|
||||||
assert.strictEqual(prohibited.status, 204);
|
assert.strictEqual(prohibited.status, 204);
|
||||||
|
|
||||||
|
@ -750,7 +752,7 @@ describe('Note', () => {
|
||||||
prohibitedWords: [
|
prohibitedWords: [
|
||||||
'test',
|
'test',
|
||||||
],
|
],
|
||||||
}, alice);
|
}, root);
|
||||||
|
|
||||||
assert.strictEqual(prohibited.status, 204);
|
assert.strictEqual(prohibited.status, 204);
|
||||||
|
|
||||||
|
@ -785,7 +787,7 @@ describe('Note', () => {
|
||||||
value: 0,
|
value: 0,
|
||||||
},
|
},
|
||||||
} as any,
|
} as any,
|
||||||
}, alice);
|
}, root);
|
||||||
|
|
||||||
assert.strictEqual(res.status, 200);
|
assert.strictEqual(res.status, 200);
|
||||||
|
|
||||||
|
@ -794,7 +796,7 @@ describe('Note', () => {
|
||||||
const assign = await api('admin/roles/assign', {
|
const assign = await api('admin/roles/assign', {
|
||||||
userId: alice.id,
|
userId: alice.id,
|
||||||
roleId: res.body.id,
|
roleId: res.body.id,
|
||||||
}, alice);
|
}, root);
|
||||||
|
|
||||||
assert.strictEqual(assign.status, 204);
|
assert.strictEqual(assign.status, 204);
|
||||||
|
|
||||||
|
@ -810,11 +812,11 @@ describe('Note', () => {
|
||||||
await api('admin/roles/unassign', {
|
await api('admin/roles/unassign', {
|
||||||
userId: alice.id,
|
userId: alice.id,
|
||||||
roleId: res.body.id,
|
roleId: res.body.id,
|
||||||
});
|
}, root);
|
||||||
|
|
||||||
await api('admin/roles/delete', {
|
await api('admin/roles/delete', {
|
||||||
roleId: res.body.id,
|
roleId: res.body.id,
|
||||||
}, alice);
|
}, root);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('ダイレクト投稿もエラーになる', async () => {
|
test('ダイレクト投稿もエラーになる', async () => {
|
||||||
|
@ -839,7 +841,7 @@ describe('Note', () => {
|
||||||
value: 0,
|
value: 0,
|
||||||
},
|
},
|
||||||
} as any,
|
} as any,
|
||||||
}, alice);
|
}, root);
|
||||||
|
|
||||||
assert.strictEqual(res.status, 200);
|
assert.strictEqual(res.status, 200);
|
||||||
|
|
||||||
|
@ -848,7 +850,7 @@ describe('Note', () => {
|
||||||
const assign = await api('admin/roles/assign', {
|
const assign = await api('admin/roles/assign', {
|
||||||
userId: alice.id,
|
userId: alice.id,
|
||||||
roleId: res.body.id,
|
roleId: res.body.id,
|
||||||
}, alice);
|
}, root);
|
||||||
|
|
||||||
assert.strictEqual(assign.status, 204);
|
assert.strictEqual(assign.status, 204);
|
||||||
|
|
||||||
|
@ -866,11 +868,11 @@ describe('Note', () => {
|
||||||
await api('admin/roles/unassign', {
|
await api('admin/roles/unassign', {
|
||||||
userId: alice.id,
|
userId: alice.id,
|
||||||
roleId: res.body.id,
|
roleId: res.body.id,
|
||||||
});
|
}, root);
|
||||||
|
|
||||||
await api('admin/roles/delete', {
|
await api('admin/roles/delete', {
|
||||||
roleId: res.body.id,
|
roleId: res.body.id,
|
||||||
}, alice);
|
}, root);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('ダイレクトの宛先とメンションが同じ場合は重複してカウントしない', async () => {
|
test('ダイレクトの宛先とメンションが同じ場合は重複してカウントしない', async () => {
|
||||||
|
@ -895,7 +897,7 @@ describe('Note', () => {
|
||||||
value: 1,
|
value: 1,
|
||||||
},
|
},
|
||||||
} as any,
|
} as any,
|
||||||
}, alice);
|
}, root);
|
||||||
|
|
||||||
assert.strictEqual(res.status, 200);
|
assert.strictEqual(res.status, 200);
|
||||||
|
|
||||||
|
@ -904,7 +906,7 @@ describe('Note', () => {
|
||||||
const assign = await api('admin/roles/assign', {
|
const assign = await api('admin/roles/assign', {
|
||||||
userId: alice.id,
|
userId: alice.id,
|
||||||
roleId: res.body.id,
|
roleId: res.body.id,
|
||||||
}, alice);
|
}, root);
|
||||||
|
|
||||||
assert.strictEqual(assign.status, 204);
|
assert.strictEqual(assign.status, 204);
|
||||||
|
|
||||||
|
@ -921,11 +923,11 @@ describe('Note', () => {
|
||||||
await api('admin/roles/unassign', {
|
await api('admin/roles/unassign', {
|
||||||
userId: alice.id,
|
userId: alice.id,
|
||||||
roleId: res.body.id,
|
roleId: res.body.id,
|
||||||
});
|
}, root);
|
||||||
|
|
||||||
await api('admin/roles/delete', {
|
await api('admin/roles/delete', {
|
||||||
roleId: res.body.id,
|
roleId: res.body.id,
|
||||||
}, alice);
|
}, root);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -960,4 +962,61 @@ describe('Note', () => {
|
||||||
assert.strictEqual(mainNote.repliesCount, 0);
|
assert.strictEqual(mainNote.repliesCount, 0);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('notes/translate', () => {
|
||||||
|
describe('翻訳機能の利用が許可されていない場合', () => {
|
||||||
|
let cannotTranslateRole: misskey.entities.Role;
|
||||||
|
|
||||||
|
beforeAll(async () => {
|
||||||
|
cannotTranslateRole = await role(root, {}, { canUseTranslator: false });
|
||||||
|
await api('admin/roles/assign', { roleId: cannotTranslateRole.id, userId: alice.id }, root);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('翻訳機能の利用が許可されていない場合翻訳できない', async () => {
|
||||||
|
const aliceNote = await post(alice, { text: 'Hello' });
|
||||||
|
const res = await api('notes/translate', {
|
||||||
|
noteId: aliceNote.id,
|
||||||
|
targetLang: 'ja',
|
||||||
|
}, alice);
|
||||||
|
|
||||||
|
assert.strictEqual(res.status, 400);
|
||||||
|
assert.strictEqual(res.body.error.code, 'UNAVAILABLE');
|
||||||
|
});
|
||||||
|
|
||||||
|
afterAll(async () => {
|
||||||
|
await api('admin/roles/unassign', { roleId: cannotTranslateRole.id, userId: alice.id }, root);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
test('存在しないノートは翻訳できない', async () => {
|
||||||
|
const res = await api('notes/translate', { noteId: 'foo', targetLang: 'ja' }, alice);
|
||||||
|
|
||||||
|
assert.strictEqual(res.status, 400);
|
||||||
|
assert.strictEqual(res.body.error.code, 'NO_SUCH_NOTE');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('不可視なノートは翻訳できない', async () => {
|
||||||
|
const aliceNote = await post(alice, { visibility: 'followers', text: 'Hello' });
|
||||||
|
const bobTranslateAttempt = await api('notes/translate', { noteId: aliceNote.id, targetLang: 'ja' }, bob);
|
||||||
|
|
||||||
|
assert.strictEqual(bobTranslateAttempt.status, 400);
|
||||||
|
assert.strictEqual(bobTranslateAttempt.body.error.code, 'CANNOT_TRANSLATE_INVISIBLE_NOTE');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('text: null なノートを翻訳すると空のレスポンスが返ってくる', async () => {
|
||||||
|
const aliceNote = await post(alice, { text: null, poll: { choices: ['kinoko', 'takenoko'] } });
|
||||||
|
const res = await api('notes/translate', { noteId: aliceNote.id, targetLang: 'ja' }, alice);
|
||||||
|
|
||||||
|
assert.strictEqual(res.status, 204);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('サーバーに DeepL 認証キーが登録されていない場合翻訳できない', async () => {
|
||||||
|
const aliceNote = await post(alice, { text: 'Hello' });
|
||||||
|
const res = await api('notes/translate', { noteId: aliceNote.id, targetLang: 'ja' }, alice);
|
||||||
|
|
||||||
|
// NOTE: デフォルトでは登録されていないので落ちる
|
||||||
|
assert.strictEqual(res.status, 400);
|
||||||
|
assert.strictEqual(res.body.error.code, 'UNAVAILABLE');
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -158,19 +158,17 @@ describe('Streaming', () => {
|
||||||
assert.strictEqual(fired, true);
|
assert.strictEqual(fired, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
/* なんか失敗する
|
|
||||||
test('フォローしているユーザーの visibility: followers な投稿への返信が流れる', async () => {
|
test('フォローしているユーザーの visibility: followers な投稿への返信が流れる', async () => {
|
||||||
const note = await api('notes/create', { text: 'foo', visibility: 'followers' }, kyoko);
|
const note = await post(kyoko, { text: 'foo', visibility: 'followers' });
|
||||||
|
|
||||||
const fired = await waitFire(
|
const fired = await waitFire(
|
||||||
ayano, 'homeTimeline', // ayano:home
|
ayano, 'homeTimeline', // ayano:home
|
||||||
() => api('notes/create', { text: 'bar', visibility: 'followers', replyId: note.body.id }, kyoko), // kyoko posts
|
() => api('notes/create', { text: 'bar', visibility: 'followers', replyId: note.id }, kyoko), // kyoko posts
|
||||||
msg => msg.type === 'note' && msg.body.userId === kyoko.id && msg.body.reply.text === 'foo',
|
msg => msg.type === 'note' && msg.body.userId === kyoko.id && msg.body.reply.text === 'foo',
|
||||||
);
|
);
|
||||||
|
|
||||||
assert.strictEqual(fired, true);
|
assert.strictEqual(fired, true);
|
||||||
});
|
});
|
||||||
*/
|
|
||||||
|
|
||||||
test('フォローしているユーザーのフォローしていないユーザーの visibility: followers な投稿への返信が流れない', async () => {
|
test('フォローしているユーザーのフォローしていないユーザーの visibility: followers な投稿への返信が流れない', async () => {
|
||||||
const chitoseNote = await post(chitose, { text: 'followers-only post', visibility: 'followers' });
|
const chitoseNote = await post(chitose, { text: 'followers-only post', visibility: 'followers' });
|
||||||
|
|
Binary file not shown.
|
@ -15,6 +15,7 @@ import { GlobalModule } from '@/GlobalModule.js';
|
||||||
import { FileInfoService } from '@/core/FileInfoService.js';
|
import { FileInfoService } from '@/core/FileInfoService.js';
|
||||||
//import { DI } from '@/di-symbols.js';
|
//import { DI } from '@/di-symbols.js';
|
||||||
import { AiService } from '@/core/AiService.js';
|
import { AiService } from '@/core/AiService.js';
|
||||||
|
import { LoggerService } from '@/core/LoggerService.js';
|
||||||
import type { TestingModule } from '@nestjs/testing';
|
import type { TestingModule } from '@nestjs/testing';
|
||||||
import type { MockFunctionMetadata } from 'jest-mock';
|
import type { MockFunctionMetadata } from 'jest-mock';
|
||||||
|
|
||||||
|
@ -35,6 +36,7 @@ describe('FileInfoService', () => {
|
||||||
],
|
],
|
||||||
providers: [
|
providers: [
|
||||||
AiService,
|
AiService,
|
||||||
|
LoggerService,
|
||||||
FileInfoService,
|
FileInfoService,
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
|
@ -323,8 +325,26 @@ describe('FileInfoService', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
/*
|
test('MPEG-4 AUDIO (M4A)', async () => {
|
||||||
* video/webmとして検出されてしまう
|
const path = `${resources}/kick_gaba7.m4a`;
|
||||||
|
const info = await fileInfoService.getFileInfo(path, { skipSensitiveDetection: true }) as any;
|
||||||
|
delete info.warnings;
|
||||||
|
delete info.blurhash;
|
||||||
|
delete info.sensitive;
|
||||||
|
delete info.porn;
|
||||||
|
delete info.width;
|
||||||
|
delete info.height;
|
||||||
|
delete info.orientation;
|
||||||
|
assert.deepStrictEqual(info, {
|
||||||
|
size: 9817,
|
||||||
|
md5: '74c9279a4abe98789565f1dc1a541a42',
|
||||||
|
type: {
|
||||||
|
mime: 'audio/mp4',
|
||||||
|
ext: 'm4a',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
test('WEBM AUDIO', async () => {
|
test('WEBM AUDIO', async () => {
|
||||||
const path = `${resources}/kick_gaba7.webm`;
|
const path = `${resources}/kick_gaba7.webm`;
|
||||||
const info = await fileInfoService.getFileInfo(path, { skipSensitiveDetection: true }) as any;
|
const info = await fileInfoService.getFileInfo(path, { skipSensitiveDetection: true }) as any;
|
||||||
|
@ -337,13 +357,12 @@ describe('FileInfoService', () => {
|
||||||
delete info.orientation;
|
delete info.orientation;
|
||||||
assert.deepStrictEqual(info, {
|
assert.deepStrictEqual(info, {
|
||||||
size: 8879,
|
size: 8879,
|
||||||
md5: '3350083dec312419cfdc06c16413aca7',
|
md5: '53bc1adcb6acbbda67ff9bd484896438',
|
||||||
type: {
|
type: {
|
||||||
mime: 'audio/webm',
|
mime: 'audio/webm',
|
||||||
ext: 'webm',
|
ext: 'webm',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
*/
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -60,7 +60,7 @@
|
||||||
"rollup": "4.12.0",
|
"rollup": "4.12.0",
|
||||||
"sanitize-html": "2.12.1",
|
"sanitize-html": "2.12.1",
|
||||||
"sass": "1.71.1",
|
"sass": "1.71.1",
|
||||||
"shiki": "1.1.7",
|
"shiki": "1.2.0",
|
||||||
"strict-event-emitter-types": "2.0.0",
|
"strict-event-emitter-types": "2.0.0",
|
||||||
"textarea-caret": "3.1.0",
|
"textarea-caret": "3.1.0",
|
||||||
"three": "0.162.0",
|
"three": "0.162.0",
|
||||||
|
|
|
@ -145,8 +145,11 @@ export async function common(createVue: () => App<Element>) {
|
||||||
// NOTE: この処理は必ずクライアント更新チェック処理より後に来ること(テーマ再構築のため)
|
// NOTE: この処理は必ずクライアント更新チェック処理より後に来ること(テーマ再構築のため)
|
||||||
watch(defaultStore.reactiveState.darkMode, (darkMode) => {
|
watch(defaultStore.reactiveState.darkMode, (darkMode) => {
|
||||||
applyTheme(darkMode ? ColdDeviceStorage.get('darkTheme') : ColdDeviceStorage.get('lightTheme'));
|
applyTheme(darkMode ? ColdDeviceStorage.get('darkTheme') : ColdDeviceStorage.get('lightTheme'));
|
||||||
|
document.documentElement.dataset.colorMode = darkMode ? 'dark' : 'light';
|
||||||
}, { immediate: miLocalStorage.getItem('theme') == null });
|
}, { immediate: miLocalStorage.getItem('theme') == null });
|
||||||
|
|
||||||
|
document.documentElement.dataset.colorMode = defaultStore.state.darkMode ? 'dark' : 'light';
|
||||||
|
|
||||||
const darkTheme = computed(ColdDeviceStorage.makeGetterSetter('darkTheme'));
|
const darkTheme = computed(ColdDeviceStorage.makeGetterSetter('darkTheme'));
|
||||||
const lightTheme = computed(ColdDeviceStorage.makeGetterSetter('lightTheme'));
|
const lightTheme = computed(ColdDeviceStorage.makeGetterSetter('lightTheme'));
|
||||||
|
|
||||||
|
|
|
@ -55,6 +55,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
}
|
}
|
||||||
]"
|
]"
|
||||||
:to="to ?? '#'"
|
:to="to ?? '#'"
|
||||||
|
:behavior="linkBehavior"
|
||||||
@mousedown="onMousedown"
|
@mousedown="onMousedown"
|
||||||
>
|
>
|
||||||
<div ref="ripples" :class="$style.ripples" :data-children-class="$style.ripple"></div>
|
<div ref="ripples" :class="$style.ripples" :data-children-class="$style.ripple"></div>
|
||||||
|
@ -76,7 +77,7 @@ const props = defineProps<{
|
||||||
inline?: boolean;
|
inline?: boolean;
|
||||||
link?: boolean;
|
link?: boolean;
|
||||||
to?: string;
|
to?: string;
|
||||||
autofocus?: boolean;
|
linkBehavior?: null | 'window' | 'browser';autofocus?: boolean;
|
||||||
wait?: boolean;
|
wait?: boolean;
|
||||||
danger?: boolean;
|
danger?: boolean;
|
||||||
full?: boolean;
|
full?: boolean;
|
||||||
|
|
|
@ -9,9 +9,9 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { ref, computed, watch } from 'vue';
|
import { computed, ref, watch } from 'vue';
|
||||||
import { bundledLanguagesInfo } from 'shiki';
|
import { bundledLanguagesInfo } from 'shiki/langs';
|
||||||
import type { BuiltinLanguage } from 'shiki';
|
import type { BundledLanguage } from 'shiki/langs';
|
||||||
import { getHighlighter, getTheme } from '@/scripts/code-highlighter.js';
|
import { getHighlighter, getTheme } from '@/scripts/code-highlighter.js';
|
||||||
import { defaultStore } from '@/store.js';
|
import { defaultStore } from '@/store.js';
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ const props = defineProps<{
|
||||||
|
|
||||||
const highlighter = await getHighlighter();
|
const highlighter = await getHighlighter();
|
||||||
const darkMode = defaultStore.reactiveState.darkMode;
|
const darkMode = defaultStore.reactiveState.darkMode;
|
||||||
const codeLang = ref<BuiltinLanguage | 'aiscript'>('js');
|
const codeLang = ref<BundledLanguage | 'aiscript'>('js');
|
||||||
|
|
||||||
const [lightThemeName, darkThemeName] = await Promise.all([
|
const [lightThemeName, darkThemeName] = await Promise.all([
|
||||||
getTheme('light', true),
|
getTheme('light', true),
|
||||||
|
@ -42,7 +42,7 @@ const html = computed(() => highlighter.codeToHtml(props.code, {
|
||||||
}));
|
}));
|
||||||
|
|
||||||
async function fetchLanguage(to: string): Promise<void> {
|
async function fetchLanguage(to: string): Promise<void> {
|
||||||
const language = to as BuiltinLanguage;
|
const language = to as BundledLanguage;
|
||||||
|
|
||||||
// Check for the loaded languages, and load the language if it's not loaded yet.
|
// Check for the loaded languages, and load the language if it's not loaded yet.
|
||||||
if (!highlighter.getLoadedLanguages().includes(language)) {
|
if (!highlighter.getLoadedLanguages().includes(language)) {
|
||||||
|
|
|
@ -80,11 +80,9 @@ function copy() {
|
||||||
.codePlaceholderRoot {
|
.codePlaceholderRoot {
|
||||||
display: block;
|
display: block;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
background: none;
|
|
||||||
border: none;
|
border: none;
|
||||||
outline: none;
|
outline: none;
|
||||||
font: inherit;
|
font: inherit;
|
||||||
color: inherit;
|
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
|
|
@ -22,6 +22,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
:autocomplete="autocomplete"
|
:autocomplete="autocomplete"
|
||||||
:autocapitalize="autocapitalize"
|
:autocapitalize="autocapitalize"
|
||||||
:spellcheck="spellcheck"
|
:spellcheck="spellcheck"
|
||||||
|
:inputmode="inputmode"
|
||||||
:step="step"
|
:step="step"
|
||||||
:list="id"
|
:list="id"
|
||||||
:min="min"
|
:min="min"
|
||||||
|
@ -63,6 +64,7 @@ const props = defineProps<{
|
||||||
mfmAutocomplete?: boolean | SuggestionType[],
|
mfmAutocomplete?: boolean | SuggestionType[],
|
||||||
autocapitalize?: string;
|
autocapitalize?: string;
|
||||||
spellcheck?: boolean;
|
spellcheck?: boolean;
|
||||||
|
inputmode?: 'none' | 'text' | 'search' | 'email' | 'url' | 'numeric' | 'tel' | 'decimal';
|
||||||
step?: any;
|
step?: any;
|
||||||
datalist?: string[];
|
datalist?: string[];
|
||||||
min?: number;
|
min?: number;
|
||||||
|
|
|
@ -18,6 +18,7 @@ import { defineAsyncComponent, ref } from 'vue';
|
||||||
import { url as local } from '@/config.js';
|
import { url as local } from '@/config.js';
|
||||||
import { useTooltip } from '@/scripts/use-tooltip.js';
|
import { useTooltip } from '@/scripts/use-tooltip.js';
|
||||||
import * as os from '@/os.js';
|
import * as os from '@/os.js';
|
||||||
|
import { isEnabledUrlPreview } from '@/instance.js';
|
||||||
|
|
||||||
const props = withDefaults(defineProps<{
|
const props = withDefaults(defineProps<{
|
||||||
url: string;
|
url: string;
|
||||||
|
@ -31,13 +32,15 @@ const target = self ? null : '_blank';
|
||||||
|
|
||||||
const el = ref<HTMLElement | { $el: HTMLElement }>();
|
const el = ref<HTMLElement | { $el: HTMLElement }>();
|
||||||
|
|
||||||
useTooltip(el, (showing) => {
|
if (isEnabledUrlPreview.value) {
|
||||||
os.popup(defineAsyncComponent(() => import('@/components/MkUrlPreviewPopup.vue')), {
|
useTooltip(el, (showing) => {
|
||||||
showing,
|
os.popup(defineAsyncComponent(() => import('@/components/MkUrlPreviewPopup.vue')), {
|
||||||
url: props.url,
|
showing,
|
||||||
source: el.value instanceof HTMLElement ? el.value : el.value?.$el,
|
url: props.url,
|
||||||
}, {}, 'closed');
|
source: el.value instanceof HTMLElement ? el.value : el.value?.$el,
|
||||||
});
|
}, {}, 'closed');
|
||||||
|
});
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" module>
|
<style lang="scss" module>
|
||||||
|
|
|
@ -5,11 +5,15 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div
|
<div
|
||||||
|
ref="playerEl"
|
||||||
|
v-hotkey="keymap"
|
||||||
|
tabindex="0"
|
||||||
:class="[
|
:class="[
|
||||||
$style.audioContainer,
|
$style.audioContainer,
|
||||||
(audio.isSensitive && defaultStore.state.highlightSensitiveMedia) && $style.sensitive,
|
(audio.isSensitive && defaultStore.state.highlightSensitiveMedia) && $style.sensitive,
|
||||||
]"
|
]"
|
||||||
@contextmenu.stop
|
@contextmenu.stop
|
||||||
|
@keydown.stop
|
||||||
>
|
>
|
||||||
<button v-if="hide" :class="$style.hidden" @click="hide = false">
|
<button v-if="hide" :class="$style.hidden" @click="hide = false">
|
||||||
<div :class="$style.hiddenTextWrapper">
|
<div :class="$style.hiddenTextWrapper">
|
||||||
|
@ -18,6 +22,19 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
<span style="display: block;">{{ i18n.ts.clickToShow }}</span>
|
<span style="display: block;">{{ i18n.ts.clickToShow }}</span>
|
||||||
</div>
|
</div>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
|
<div v-else-if="defaultStore.reactiveState.useNativeUIForVideoAudioPlayer.value" :class="$style.nativeAudioContainer">
|
||||||
|
<audio
|
||||||
|
ref="audioEl"
|
||||||
|
preload="metadata"
|
||||||
|
controls
|
||||||
|
:class="$style.nativeAudio"
|
||||||
|
@keydown.prevent
|
||||||
|
>
|
||||||
|
<source :src="audio.url">
|
||||||
|
</audio>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div v-else :class="$style.audioControls">
|
<div v-else :class="$style.audioControls">
|
||||||
<audio
|
<audio
|
||||||
ref="audioEl"
|
ref="audioEl"
|
||||||
|
@ -72,6 +89,41 @@ const props = defineProps<{
|
||||||
audio: Misskey.entities.DriveFile;
|
audio: Misskey.entities.DriveFile;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
|
const keymap = {
|
||||||
|
'up': () => {
|
||||||
|
if (hasFocus() && audioEl.value) {
|
||||||
|
volume.value = Math.min(volume.value + 0.1, 1);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'down': () => {
|
||||||
|
if (hasFocus() && audioEl.value) {
|
||||||
|
volume.value = Math.max(volume.value - 0.1, 0);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'left': () => {
|
||||||
|
if (hasFocus() && audioEl.value) {
|
||||||
|
audioEl.value.currentTime = Math.max(audioEl.value.currentTime - 5, 0);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'right': () => {
|
||||||
|
if (hasFocus() && audioEl.value) {
|
||||||
|
audioEl.value.currentTime = Math.min(audioEl.value.currentTime + 5, audioEl.value.duration);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'space': () => {
|
||||||
|
if (hasFocus()) {
|
||||||
|
togglePlayPause();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
// PlayerElもしくはその子要素にフォーカスがあるかどうか
|
||||||
|
function hasFocus() {
|
||||||
|
if (!playerEl.value) return false;
|
||||||
|
return playerEl.value === document.activeElement || playerEl.value.contains(document.activeElement);
|
||||||
|
}
|
||||||
|
|
||||||
|
const playerEl = shallowRef<HTMLDivElement>();
|
||||||
const audioEl = shallowRef<HTMLAudioElement>();
|
const audioEl = shallowRef<HTMLAudioElement>();
|
||||||
|
|
||||||
// eslint-disable-next-line vue/no-setup-props-destructure
|
// eslint-disable-next-line vue/no-setup-props-destructure
|
||||||
|
@ -85,6 +137,30 @@ function showMenu(ev: MouseEvent) {
|
||||||
|
|
||||||
menu = [
|
menu = [
|
||||||
// TODO: 再生キューに追加
|
// TODO: 再生キューに追加
|
||||||
|
{
|
||||||
|
type: 'switch',
|
||||||
|
text: i18n.ts._mediaControls.loop,
|
||||||
|
icon: 'ti ti-repeat',
|
||||||
|
ref: loop,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'radio',
|
||||||
|
text: i18n.ts._mediaControls.playbackRate,
|
||||||
|
icon: 'ti ti-clock-play',
|
||||||
|
ref: speed,
|
||||||
|
options: {
|
||||||
|
'0.25x': 0.25,
|
||||||
|
'0.5x': 0.5,
|
||||||
|
'0.75x': 0.75,
|
||||||
|
'1.0x': 1,
|
||||||
|
'1.25x': 1.25,
|
||||||
|
'1.5x': 1.5,
|
||||||
|
'2.0x': 2,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'divider',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
text: i18n.ts.hide,
|
text: i18n.ts.hide,
|
||||||
icon: 'ti ti-eye-off',
|
icon: 'ti ti-eye-off',
|
||||||
|
@ -147,6 +223,8 @@ const rangePercent = computed({
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const volume = ref(.25);
|
const volume = ref(.25);
|
||||||
|
const speed = ref(1);
|
||||||
|
const loop = ref(false); // TODO: ドライブファイルのフラグに置き換える
|
||||||
const bufferedEnd = ref(0);
|
const bufferedEnd = ref(0);
|
||||||
const bufferedDataRatio = computed(() => {
|
const bufferedDataRatio = computed(() => {
|
||||||
if (!audioEl.value) return 0;
|
if (!audioEl.value) return 0;
|
||||||
|
@ -176,6 +254,7 @@ function toggleMute() {
|
||||||
}
|
}
|
||||||
|
|
||||||
let onceInit = false;
|
let onceInit = false;
|
||||||
|
let mediaTickFrameId: number | null = null;
|
||||||
let stopAudioElWatch: () => void;
|
let stopAudioElWatch: () => void;
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
|
@ -195,8 +274,12 @@ function init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
elapsedTimeMs.value = audioEl.value.currentTime * 1000;
|
elapsedTimeMs.value = audioEl.value.currentTime * 1000;
|
||||||
|
|
||||||
|
if (audioEl.value.loop !== loop.value) {
|
||||||
|
loop.value = audioEl.value.loop;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
window.requestAnimationFrame(updateMediaTick);
|
mediaTickFrameId = window.requestAnimationFrame(updateMediaTick);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateMediaTick();
|
updateMediaTick();
|
||||||
|
@ -234,6 +317,14 @@ watch(volume, (to) => {
|
||||||
if (audioEl.value) audioEl.value.volume = to;
|
if (audioEl.value) audioEl.value.volume = to;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
watch(speed, (to) => {
|
||||||
|
if (audioEl.value) audioEl.value.playbackRate = to;
|
||||||
|
});
|
||||||
|
|
||||||
|
watch(loop, (to) => {
|
||||||
|
if (audioEl.value) audioEl.value.loop = to;
|
||||||
|
});
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
init();
|
init();
|
||||||
});
|
});
|
||||||
|
@ -252,6 +343,10 @@ onDeactivated(() => {
|
||||||
hide.value = (defaultStore.state.nsfw === 'force' || defaultStore.state.dataSaver.media) ? true : (props.audio.isSensitive && defaultStore.state.nsfw !== 'ignore');
|
hide.value = (defaultStore.state.nsfw === 'force' || defaultStore.state.dataSaver.media) ? true : (props.audio.isSensitive && defaultStore.state.nsfw !== 'ignore');
|
||||||
stopAudioElWatch();
|
stopAudioElWatch();
|
||||||
onceInit = false;
|
onceInit = false;
|
||||||
|
if (mediaTickFrameId) {
|
||||||
|
window.cancelAnimationFrame(mediaTickFrameId);
|
||||||
|
mediaTickFrameId = null;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -262,6 +357,10 @@ onDeactivated(() => {
|
||||||
border: .5px solid var(--divider);
|
border: .5px solid var(--divider);
|
||||||
border-radius: var(--radius);
|
border-radius: var(--radius);
|
||||||
overflow: clip;
|
overflow: clip;
|
||||||
|
|
||||||
|
&:focus {
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.sensitive {
|
.sensitive {
|
||||||
|
@ -367,4 +466,15 @@ onDeactivated(() => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.nativeAudioContainer {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
padding: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nativeAudio {
|
||||||
|
display: block;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -6,6 +6,8 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
<template>
|
<template>
|
||||||
<div
|
<div
|
||||||
ref="playerEl"
|
ref="playerEl"
|
||||||
|
v-hotkey="keymap"
|
||||||
|
tabindex="0"
|
||||||
:class="[
|
:class="[
|
||||||
$style.videoContainer,
|
$style.videoContainer,
|
||||||
controlsShowing && $style.active,
|
controlsShowing && $style.active,
|
||||||
|
@ -14,15 +16,37 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
@mouseover="onMouseOver"
|
@mouseover="onMouseOver"
|
||||||
@mouseleave="onMouseLeave"
|
@mouseleave="onMouseLeave"
|
||||||
@contextmenu.stop
|
@contextmenu.stop
|
||||||
|
@keydown.stop
|
||||||
>
|
>
|
||||||
<button v-if="hide" :class="$style.hidden" @click="hide = false">
|
<button v-if="hide" :class="$style.hidden" @click="hide = false">
|
||||||
<div :class="$style.hiddenTextWrapper">
|
<div :class="$style.hiddenTextWrapper">
|
||||||
<b v-if="video.isSensitive" style="display: block;"><i class="ti ti-eye-exclamation"></i> {{ i18n.ts.sensitive }}{{ defaultStore.state.dataSaver.media ? ` (${i18n.ts.video}${video.size ? ' ' + bytes(video.size) : ''})` : '' }}</b>
|
<b v-if="video.isSensitive" style="display: block;"><i class="ti ti-eye-exclamation"></i> {{ i18n.ts.sensitive }}{{ defaultStore.state.dataSaver.media ? ` (${i18n.ts.video}${video.size ? ' ' + bytes(video.size) : ''})` : '' }}</b>
|
||||||
<b v-else style="display: block;"><i class="ti ti-photo"></i> {{ defaultStore.state.dataSaver.media && video.size ? bytes(video.size) : i18n.ts.video }}</b>
|
<b v-else style="display: block;"><i class="ti ti-movie"></i> {{ defaultStore.state.dataSaver.media && video.size ? bytes(video.size) : i18n.ts.video }}</b>
|
||||||
<span style="display: block;">{{ i18n.ts.clickToShow }}</span>
|
<span style="display: block;">{{ i18n.ts.clickToShow }}</span>
|
||||||
</div>
|
</div>
|
||||||
</button>
|
</button>
|
||||||
<div v-else :class="$style.videoRoot" @click.self="togglePlayPause">
|
|
||||||
|
<div v-else-if="defaultStore.reactiveState.useNativeUIForVideoAudioPlayer.value" :class="$style.videoRoot">
|
||||||
|
<video
|
||||||
|
ref="videoEl"
|
||||||
|
:class="$style.video"
|
||||||
|
:poster="video.thumbnailUrl ?? undefined"
|
||||||
|
:title="video.comment ?? undefined"
|
||||||
|
:alt="video.comment"
|
||||||
|
preload="metadata"
|
||||||
|
controls
|
||||||
|
@keydown.prevent
|
||||||
|
>
|
||||||
|
<source :src="video.url">
|
||||||
|
</video>
|
||||||
|
<i class="ti ti-eye-off" :class="$style.hide" @click="hide = true"></i>
|
||||||
|
<div :class="$style.indicators">
|
||||||
|
<div v-if="video.comment" :class="$style.indicator">ALT</div>
|
||||||
|
<div v-if="video.isSensitive" :class="$style.indicator" style="color: var(--warn);" :title="i18n.ts.sensitive"><i class="ti ti-eye-exclamation"></i></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div v-else :class="$style.videoRoot">
|
||||||
<video
|
<video
|
||||||
ref="videoEl"
|
ref="videoEl"
|
||||||
:class="$style.video"
|
:class="$style.video"
|
||||||
|
@ -31,6 +55,8 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
:alt="video.comment"
|
:alt="video.comment"
|
||||||
preload="metadata"
|
preload="metadata"
|
||||||
playsinline
|
playsinline
|
||||||
|
@keydown.prevent
|
||||||
|
@click.self="togglePlayPause"
|
||||||
>
|
>
|
||||||
<source :src="video.url">
|
<source :src="video.url">
|
||||||
</video>
|
</video>
|
||||||
|
@ -100,6 +126,40 @@ const props = defineProps<{
|
||||||
video: Misskey.entities.DriveFile;
|
video: Misskey.entities.DriveFile;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
|
const keymap = {
|
||||||
|
'up': () => {
|
||||||
|
if (hasFocus() && videoEl.value) {
|
||||||
|
volume.value = Math.min(volume.value + 0.1, 1);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'down': () => {
|
||||||
|
if (hasFocus() && videoEl.value) {
|
||||||
|
volume.value = Math.max(volume.value - 0.1, 0);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'left': () => {
|
||||||
|
if (hasFocus() && videoEl.value) {
|
||||||
|
videoEl.value.currentTime = Math.max(videoEl.value.currentTime - 5, 0);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'right': () => {
|
||||||
|
if (hasFocus() && videoEl.value) {
|
||||||
|
videoEl.value.currentTime = Math.min(videoEl.value.currentTime + 5, videoEl.value.duration);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'space': () => {
|
||||||
|
if (hasFocus()) {
|
||||||
|
togglePlayPause();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
// PlayerElもしくはその子要素にフォーカスがあるかどうか
|
||||||
|
function hasFocus() {
|
||||||
|
if (!playerEl.value) return false;
|
||||||
|
return playerEl.value === document.activeElement || playerEl.value.contains(document.activeElement);
|
||||||
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line vue/no-setup-props-destructure
|
// eslint-disable-next-line vue/no-setup-props-destructure
|
||||||
const hide = ref((defaultStore.state.nsfw === 'force' || defaultStore.state.dataSaver.media) ? true : (props.video.isSensitive && defaultStore.state.nsfw !== 'ignore'));
|
const hide = ref((defaultStore.state.nsfw === 'force' || defaultStore.state.dataSaver.media) ? true : (props.video.isSensitive && defaultStore.state.nsfw !== 'ignore'));
|
||||||
|
|
||||||
|
@ -111,6 +171,35 @@ function showMenu(ev: MouseEvent) {
|
||||||
|
|
||||||
menu = [
|
menu = [
|
||||||
// TODO: 再生キューに追加
|
// TODO: 再生キューに追加
|
||||||
|
{
|
||||||
|
type: 'switch',
|
||||||
|
text: i18n.ts._mediaControls.loop,
|
||||||
|
icon: 'ti ti-repeat',
|
||||||
|
ref: loop,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'radio',
|
||||||
|
text: i18n.ts._mediaControls.playbackRate,
|
||||||
|
icon: 'ti ti-clock-play',
|
||||||
|
ref: speed,
|
||||||
|
options: {
|
||||||
|
'0.25x': 0.25,
|
||||||
|
'0.5x': 0.5,
|
||||||
|
'0.75x': 0.75,
|
||||||
|
'1.0x': 1,
|
||||||
|
'1.25x': 1.25,
|
||||||
|
'1.5x': 1.5,
|
||||||
|
'2.0x': 2,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
...(document.pictureInPictureEnabled ? [{
|
||||||
|
text: i18n.ts._mediaControls.pip,
|
||||||
|
icon: 'ti ti-picture-in-picture',
|
||||||
|
action: togglePictureInPicture,
|
||||||
|
}] : []),
|
||||||
|
{
|
||||||
|
type: 'divider',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
text: i18n.ts.hide,
|
text: i18n.ts.hide,
|
||||||
icon: 'ti ti-eye-off',
|
icon: 'ti ti-eye-off',
|
||||||
|
@ -186,6 +275,8 @@ const rangePercent = computed({
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const volume = ref(.25);
|
const volume = ref(.25);
|
||||||
|
const speed = ref(1);
|
||||||
|
const loop = ref(false); // TODO: ドライブファイルのフラグに置き換える
|
||||||
const bufferedEnd = ref(0);
|
const bufferedEnd = ref(0);
|
||||||
const bufferedDataRatio = computed(() => {
|
const bufferedDataRatio = computed(() => {
|
||||||
if (!videoEl.value) return 0;
|
if (!videoEl.value) return 0;
|
||||||
|
@ -243,6 +334,16 @@ function toggleFullscreen() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function togglePictureInPicture() {
|
||||||
|
if (videoEl.value) {
|
||||||
|
if (document.pictureInPictureElement) {
|
||||||
|
document.exitPictureInPicture();
|
||||||
|
} else {
|
||||||
|
videoEl.value.requestPictureInPicture();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function toggleMute() {
|
function toggleMute() {
|
||||||
if (volume.value === 0) {
|
if (volume.value === 0) {
|
||||||
volume.value = .25;
|
volume.value = .25;
|
||||||
|
@ -252,6 +353,7 @@ function toggleMute() {
|
||||||
}
|
}
|
||||||
|
|
||||||
let onceInit = false;
|
let onceInit = false;
|
||||||
|
let mediaTickFrameId: number | null = null;
|
||||||
let stopVideoElWatch: () => void;
|
let stopVideoElWatch: () => void;
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
|
@ -271,8 +373,12 @@ function init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
elapsedTimeMs.value = videoEl.value.currentTime * 1000;
|
elapsedTimeMs.value = videoEl.value.currentTime * 1000;
|
||||||
|
|
||||||
|
if (videoEl.value.loop !== loop.value) {
|
||||||
|
loop.value = videoEl.value.loop;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
window.requestAnimationFrame(updateMediaTick);
|
mediaTickFrameId = window.requestAnimationFrame(updateMediaTick);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateMediaTick();
|
updateMediaTick();
|
||||||
|
@ -316,6 +422,14 @@ watch(volume, (to) => {
|
||||||
if (videoEl.value) videoEl.value.volume = to;
|
if (videoEl.value) videoEl.value.volume = to;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
watch(speed, (to) => {
|
||||||
|
if (videoEl.value) videoEl.value.playbackRate = to;
|
||||||
|
});
|
||||||
|
|
||||||
|
watch(loop, (to) => {
|
||||||
|
if (videoEl.value) videoEl.value.loop = to;
|
||||||
|
});
|
||||||
|
|
||||||
watch(hide, (to) => {
|
watch(hide, (to) => {
|
||||||
if (to && isFullscreen.value) {
|
if (to && isFullscreen.value) {
|
||||||
document.exitFullscreen();
|
document.exitFullscreen();
|
||||||
|
@ -341,6 +455,10 @@ onDeactivated(() => {
|
||||||
hide.value = (defaultStore.state.nsfw === 'force' || defaultStore.state.dataSaver.media) ? true : (props.video.isSensitive && defaultStore.state.nsfw !== 'ignore');
|
hide.value = (defaultStore.state.nsfw === 'force' || defaultStore.state.dataSaver.media) ? true : (props.video.isSensitive && defaultStore.state.nsfw !== 'ignore');
|
||||||
stopVideoElWatch();
|
stopVideoElWatch();
|
||||||
onceInit = false;
|
onceInit = false;
|
||||||
|
if (mediaTickFrameId) {
|
||||||
|
window.cancelAnimationFrame(mediaTickFrameId);
|
||||||
|
mediaTickFrameId = null;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -349,6 +467,10 @@ onDeactivated(() => {
|
||||||
container-type: inline-size;
|
container-type: inline-size;
|
||||||
position: relative;
|
position: relative;
|
||||||
overflow: clip;
|
overflow: clip;
|
||||||
|
|
||||||
|
&:focus {
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.sensitive {
|
.sensitive {
|
||||||
|
@ -412,7 +534,7 @@ onDeactivated(() => {
|
||||||
font: inherit;
|
font: inherit;
|
||||||
color: inherit;
|
color: inherit;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
padding: 120px 0;
|
padding: 60px 0;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
@ -436,7 +558,6 @@ onDeactivated(() => {
|
||||||
display: block;
|
display: block;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
pointer-events: none;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.videoOverlayPlayButton {
|
.videoOverlayPlayButton {
|
||||||
|
|
|
@ -42,9 +42,26 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
</div>
|
</div>
|
||||||
</button>
|
</button>
|
||||||
<button v-else-if="item.type === 'switch'" role="menuitemcheckbox" :tabindex="i" class="_button" :class="[$style.item, $style.switch, { [$style.switchDisabled]: item.disabled } , { [$style.gamingDark]: gamingType === 'dark',[$style.gamingLight]: gamingType === 'light' }]" @click="switchItem(item)" @mouseenter.passive="onItemMouseEnter(item)" @mouseleave.passive="onItemMouseLeave(item)">
|
<button v-else-if="item.type === 'switch'" role="menuitemcheckbox" :tabindex="i" class="_button" :class="[$style.item, $style.switch, { [$style.switchDisabled]: item.disabled } , { [$style.gamingDark]: gamingType === 'dark',[$style.gamingLight]: gamingType === 'light' }]" @click="switchItem(item)" @mouseenter.passive="onItemMouseEnter(item)" @mouseleave.passive="onItemMouseLeave(item)">
|
||||||
<MkSwitchButton :class="$style.switchButton" :checked="item.ref" :disabled="item.disabled" @toggle="switchItem(item)" model-value/>
|
<i v-if="item.icon" class="ti-fw" :class="[$style.icon, item.icon]"></i>
|
||||||
|
<MkSwitchButton v-else :class="$style.switchButton" :checked="item.ref" :disabled="item.disabled" @toggle="switchItem(item)" model-value/>
|
||||||
<div :class="$style.item_content">
|
<div :class="$style.item_content">
|
||||||
<span :class="[$style.item_content_text, $style.switchText]">{{ item.text }}</span>
|
<span :class="[$style.item_content_text, { [$style.switchText]: !item.icon }]">{{ item.text }}</span>
|
||||||
|
<MkSwitchButton v-if="item.icon" :class="[$style.switchButton, $style.caret]" :checked="item.ref" :disabled="item.disabled" @toggle="switchItem(item)"/>
|
||||||
|
</div>
|
||||||
|
</button>
|
||||||
|
<button v-else-if="item.type === 'radio'" class="_button" role="menuitem" :tabindex="i" :class="[$style.item, $style.parent, { [$style.childShowing]: childShowingItem === item }]" @mouseenter="preferClick ? null : showRadioOptions(item, $event)" @click="!preferClick ? null : showRadioOptions(item, $event)">
|
||||||
|
<i v-if="item.icon" class="ti-fw" :class="[$style.icon, item.icon]" style="pointer-events: none;"></i>
|
||||||
|
<div :class="$style.item_content">
|
||||||
|
<span :class="$style.item_content_text" style="pointer-events: none;">{{ item.text }}</span>
|
||||||
|
<span :class="$style.caret" style="pointer-events: none;"><i class="ti ti-chevron-right ti-fw"></i></span>
|
||||||
|
</div>
|
||||||
|
</button>
|
||||||
|
<button v-else-if="item.type === 'radioOption'" :tabindex="i" class="_button" role="menuitem" :class="[$style.item, { [$style.radioActive]: item.active }]" @click="clicked(item.action, $event, false)" @mouseenter.passive="onItemMouseEnter(item)" @mouseleave.passive="onItemMouseLeave(item)">
|
||||||
|
<div :class="$style.icon">
|
||||||
|
<span :class="[$style.radio, { [$style.radioChecked]: item.active }]"></span>
|
||||||
|
</div>
|
||||||
|
<div :class="$style.item_content">
|
||||||
|
<span :class="$style.item_content_text">{{ item.text }}</span>
|
||||||
</div>
|
</div>
|
||||||
</button>
|
</button>
|
||||||
<button v-else-if="item.type === 'parent'" class="_button" role="menuitem" :tabindex="i" :class="[$style.item, $style.parent, { [$style.childShowing]: childShowingItem === item } , { [$style.gamingDark]: gamingType === 'dark',[$style.gamingLight]: gamingType === 'light' }]" @mouseenter="preferClick ? null : showChildren(item, $event)" @click="!preferClick ? null : showChildren(item, $event)">
|
<button v-else-if="item.type === 'parent'" class="_button" role="menuitem" :tabindex="i" :class="[$style.item, $style.parent, { [$style.childShowing]: childShowingItem === item } , { [$style.gamingDark]: gamingType === 'dark',[$style.gamingLight]: gamingType === 'light' }]" @mouseenter="preferClick ? null : showChildren(item, $event)" @click="!preferClick ? null : showChildren(item, $event)">
|
||||||
|
@ -76,7 +93,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { ComputedRef, computed, defineAsyncComponent, isRef, nextTick, onBeforeUnmount, onMounted, ref, shallowRef, watch } from 'vue';
|
import { ComputedRef, computed, defineAsyncComponent, isRef, nextTick, onBeforeUnmount, onMounted, ref, shallowRef, watch } from 'vue';
|
||||||
import { focusPrev, focusNext } from '@/scripts/focus.js';
|
import { focusPrev, focusNext } from '@/scripts/focus.js';
|
||||||
import { MenuItem, InnerMenuItem, MenuPending, MenuAction, MenuSwitch, MenuParent } from '@/types/menu.js';
|
import { MenuItem, InnerMenuItem, MenuPending, MenuAction, MenuSwitch, MenuRadio, MenuRadioOption, MenuParent } from '@/types/menu.js';
|
||||||
import * as os from '@/os.js';
|
import * as os from '@/os.js';
|
||||||
import { i18n } from '@/i18n.js';
|
import { i18n } from '@/i18n.js';
|
||||||
import { isTouchUsing } from '@/scripts/touch.js';
|
import { isTouchUsing } from '@/scripts/touch.js';
|
||||||
|
@ -170,6 +187,31 @@ function onItemMouseLeave(item) {
|
||||||
if (childCloseTimer) window.clearTimeout(childCloseTimer);
|
if (childCloseTimer) window.clearTimeout(childCloseTimer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function showRadioOptions(item: MenuRadio, ev: MouseEvent) {
|
||||||
|
const children: MenuItem[] = Object.keys(item.options).map<MenuRadioOption>(key => {
|
||||||
|
const value = item.options[key];
|
||||||
|
return {
|
||||||
|
type: 'radioOption',
|
||||||
|
text: key,
|
||||||
|
action: () => {
|
||||||
|
item.ref = value;
|
||||||
|
},
|
||||||
|
active: computed(() => item.ref === value),
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
if (props.asDrawer) {
|
||||||
|
os.popupMenu(children, ev.currentTarget ?? ev.target).finally(() => {
|
||||||
|
emit('close');
|
||||||
|
});
|
||||||
|
emit('hide');
|
||||||
|
} else {
|
||||||
|
childTarget.value = (ev.currentTarget ?? ev.target) as HTMLElement;
|
||||||
|
childMenu.value = children;
|
||||||
|
childShowingItem.value = item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function showChildren(item: MenuParent, ev: MouseEvent) {
|
async function showChildren(item: MenuParent, ev: MouseEvent) {
|
||||||
const children: MenuItem[] = await (async () => {
|
const children: MenuItem[] = await (async () => {
|
||||||
if (childrenCache.has(item)) {
|
if (childrenCache.has(item)) {
|
||||||
|
@ -198,8 +240,10 @@ async function showChildren(item: MenuParent, ev: MouseEvent) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function clicked(fn: MenuAction, ev: MouseEvent) {
|
function clicked(fn: MenuAction, ev: MouseEvent, doClose = true) {
|
||||||
fn(ev);
|
fn(ev);
|
||||||
|
|
||||||
|
if (!doClose) return;
|
||||||
close(true);
|
close(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -394,6 +438,15 @@ onBeforeUnmount(() => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&.radioActive {
|
||||||
|
color: var(--accent) !important;
|
||||||
|
opacity: 1;
|
||||||
|
|
||||||
|
&:before {
|
||||||
|
background-color: var(--accentedBg) !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
&:not(:active):focus-visible {
|
&:not(:active):focus-visible {
|
||||||
box-shadow: 0 0 0 2px var(--focus) inset;
|
box-shadow: 0 0 0 2px var(--focus) inset;
|
||||||
}
|
}
|
||||||
|
@ -484,11 +537,11 @@ onBeforeUnmount(() => {
|
||||||
|
|
||||||
.switchButton {
|
.switchButton {
|
||||||
margin-left: -2px;
|
margin-left: -2px;
|
||||||
|
--height: 1.35em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.switchText {
|
.switchText {
|
||||||
margin-left: 8px;
|
margin-left: 8px;
|
||||||
margin-top: 2px;
|
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
}
|
}
|
||||||
|
@ -529,6 +582,34 @@ onBeforeUnmount(() => {
|
||||||
margin: 8px 0;
|
margin: 8px 0;
|
||||||
border-top: solid 0.5px var(--divider);
|
border-top: solid 0.5px var(--divider);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.radio {
|
||||||
|
display: inline-block;
|
||||||
|
position: relative;
|
||||||
|
width: 1em;
|
||||||
|
height: 1em;
|
||||||
|
vertical-align: -.125em;
|
||||||
|
border-radius: 50%;
|
||||||
|
border: solid 2px var(--divider);
|
||||||
|
background-color: var(--panel);
|
||||||
|
|
||||||
|
&.radioChecked {
|
||||||
|
border-color: var(--accent);
|
||||||
|
|
||||||
|
&::after {
|
||||||
|
content: "";
|
||||||
|
display: block;
|
||||||
|
position: absolute;
|
||||||
|
top: 50%;
|
||||||
|
left: 50%;
|
||||||
|
transform: translate(-50%, -50%);
|
||||||
|
width: 50%;
|
||||||
|
height: 50%;
|
||||||
|
border-radius: 50%;
|
||||||
|
background-color: var(--accent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@-webkit-keyframes AnimationLight {
|
@-webkit-keyframes AnimationLight {
|
||||||
0% {
|
0% {
|
||||||
background-position: 0% 50%
|
background-position: 0% 50%
|
||||||
|
|
|
@ -90,7 +90,9 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
<MkMediaList :mediaList="appearNote.files"/>
|
<MkMediaList :mediaList="appearNote.files"/>
|
||||||
</div>
|
</div>
|
||||||
<MkPoll v-if="appearNote.poll" :noteId="appearNote.id" :poll="appearNote.poll" :class="$style.poll"/>
|
<MkPoll v-if="appearNote.poll" :noteId="appearNote.id" :poll="appearNote.poll" :class="$style.poll"/>
|
||||||
<MkUrlPreview v-for="url in urls" :key="url" :url="url" :compact="true" :detail="false" :class="$style.urlPreview"/>
|
<div v-if="isEnabledUrlPreview">
|
||||||
|
<MkUrlPreview v-for="url in urls" :key="url" :url="url" :compact="true" :detail="false" :class="$style.urlPreview"/>
|
||||||
|
</div>
|
||||||
<div v-if="appearNote.renote" :class="$style.quote"><MkNoteSimple :note="appearNote.renote" :class="$style.quoteNote"/></div>
|
<div v-if="appearNote.renote" :class="$style.quote"><MkNoteSimple :note="appearNote.renote" :class="$style.quoteNote"/></div>
|
||||||
<button v-if="isLong && collapsed" :class="$style.collapsed" class="_button" @click="collapsed = false">
|
<button v-if="isLong && collapsed" :class="$style.collapsed" class="_button" @click="collapsed = false">
|
||||||
<span :class="$style.collapsedLabel">{{ i18n.ts.showMore }}</span>
|
<span :class="$style.collapsedLabel">{{ i18n.ts.showMore }}</span>
|
||||||
|
@ -103,7 +105,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
</div>
|
</div>
|
||||||
<MkReactionsViewer v-if="appearNote.reactionAcceptance !== 'likeOnly'" :note="appearNote" :maxNumber="16" @mockUpdateMyReaction="emitUpdReaction">
|
<MkReactionsViewer v-if="appearNote.reactionAcceptance !== 'likeOnly'" :note="appearNote" :maxNumber="16" @mockUpdateMyReaction="emitUpdReaction">
|
||||||
<template #more>
|
<template #more>
|
||||||
<div :class="$style.reactionOmitted">{{ i18n.ts.more }}</div>
|
<MkA :to="`/notes/${appearNote.id}/reactions`" :class="[$style.reactionOmitted]">{{ i18n.ts.more }}</MkA>
|
||||||
</template>
|
</template>
|
||||||
</MkReactionsViewer>
|
</MkReactionsViewer>
|
||||||
<footer :class="$style.footer">
|
<footer :class="$style.footer">
|
||||||
|
@ -173,6 +175,7 @@ import MkNoteSub from '@/components/MkNoteSub.vue';
|
||||||
import MkNoteHeader from '@/components/MkNoteHeader.vue';
|
import MkNoteHeader from '@/components/MkNoteHeader.vue';
|
||||||
import MkNoteSimple from '@/components/MkNoteSimple.vue';
|
import MkNoteSimple from '@/components/MkNoteSimple.vue';
|
||||||
import MkReactionsViewer from '@/components/MkReactionsViewer.vue';
|
import MkReactionsViewer from '@/components/MkReactionsViewer.vue';
|
||||||
|
import MkReactionsViewerDetails from '@/components/MkReactionsViewer.details.vue';
|
||||||
import MkMediaList from '@/components/MkMediaList.vue';
|
import MkMediaList from '@/components/MkMediaList.vue';
|
||||||
import MkCwButton from '@/components/MkCwButton.vue';
|
import MkCwButton from '@/components/MkCwButton.vue';
|
||||||
import MkPoll from '@/components/MkPoll.vue';
|
import MkPoll from '@/components/MkPoll.vue';
|
||||||
|
@ -186,7 +189,7 @@ import {userPage} from '@/filters/user.js';
|
||||||
import number from '@/filters/number.js';
|
import number from '@/filters/number.js';
|
||||||
import * as os from '@/os.js';
|
import * as os from '@/os.js';
|
||||||
import * as sound from '@/scripts/sound.js';
|
import * as sound from '@/scripts/sound.js';
|
||||||
import { misskeyApi } from '@/scripts/misskey-api.js';
|
import { misskeyApi, misskeyApiGet } from '@/scripts/misskey-api.js';
|
||||||
import {defaultStore, noteViewInterruptors} from '@/store.js';
|
import {defaultStore, noteViewInterruptors} from '@/store.js';
|
||||||
import {reactionPicker} from '@/scripts/reaction-picker.js';
|
import {reactionPicker} from '@/scripts/reaction-picker.js';
|
||||||
import {extractUrlFromMfm} from '@/scripts/extract-url-from-mfm.js';
|
import {extractUrlFromMfm} from '@/scripts/extract-url-from-mfm.js';
|
||||||
|
@ -202,6 +205,7 @@ import {MenuItem} from '@/types/menu.js';
|
||||||
import MkRippleEffect from '@/components/MkRippleEffect.vue';
|
import MkRippleEffect from '@/components/MkRippleEffect.vue';
|
||||||
import {showMovedDialog} from '@/scripts/show-moved-dialog.js';
|
import {showMovedDialog} from '@/scripts/show-moved-dialog.js';
|
||||||
import {shouldCollapsed} from '@/scripts/collapsed.js';
|
import {shouldCollapsed} from '@/scripts/collapsed.js';
|
||||||
|
import { isEnabledUrlPreview } from '@/instance.js';
|
||||||
|
|
||||||
const props = withDefaults(defineProps<{
|
const props = withDefaults(defineProps<{
|
||||||
note: Misskey.entities.Note;
|
note: Misskey.entities.Note;
|
||||||
|
@ -275,7 +279,7 @@ const renoteCollapsed = ref(
|
||||||
defaultStore.state.collapseRenotes && isRenote && (
|
defaultStore.state.collapseRenotes && isRenote && (
|
||||||
($i && ($i.id === note.value.userId || $i.id === appearNote.value.userId)) || // `||` must be `||`! See https://github.com/misskey-dev/misskey/issues/13131
|
($i && ($i.id === note.value.userId || $i.id === appearNote.value.userId)) || // `||` must be `||`! See https://github.com/misskey-dev/misskey/issues/13131
|
||||||
(appearNote.value.myReaction != null)
|
(appearNote.value.myReaction != null)
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
/* Overload FunctionにLintが対応していないのでコメントアウト
|
/* Overload FunctionにLintが対応していないのでコメントアウト
|
||||||
|
@ -344,6 +348,28 @@ if (!props.mock) {
|
||||||
targetElement: renoteButton.value,
|
targetElement: renoteButton.value,
|
||||||
}, {}, 'closed');
|
}, {}, 'closed');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (appearNote.value.reactionAcceptance === 'likeOnly') {
|
||||||
|
useTooltip(reactButton, async (showing) => {
|
||||||
|
const reactions = await misskeyApiGet('notes/reactions', {
|
||||||
|
noteId: appearNote.value.id,
|
||||||
|
limit: 10,
|
||||||
|
_cacheKey_: appearNote.value.reactionCount,
|
||||||
|
});
|
||||||
|
|
||||||
|
const users = reactions.map(x => x.user);
|
||||||
|
|
||||||
|
if (users.length < 1) return;
|
||||||
|
|
||||||
|
os.popup(MkReactionsViewerDetails, {
|
||||||
|
showing,
|
||||||
|
reaction: '❤️',
|
||||||
|
users,
|
||||||
|
count: appearNote.value.reactionCount,
|
||||||
|
targetElement: reactButton.value!,
|
||||||
|
}, {}, 'closed');
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function renote(viaKeyboard = false) {
|
function renote(viaKeyboard = false) {
|
||||||
|
@ -1033,10 +1059,9 @@ function emitUpdReaction(emoji: string, delta: number) {
|
||||||
|
|
||||||
.reactionOmitted {
|
.reactionOmitted {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
height: 32px;
|
margin-left: 8px;
|
||||||
margin: 2px;
|
|
||||||
padding: 0 6px;
|
|
||||||
opacity: .8;
|
opacity: .8;
|
||||||
|
font-size: 95%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.root:has(.ti-home) {
|
.root:has(.ti-home) {
|
||||||
|
|
|
@ -94,7 +94,9 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
<MkMediaList :mediaList="appearNote.files"/>
|
<MkMediaList :mediaList="appearNote.files"/>
|
||||||
</div>
|
</div>
|
||||||
<MkPoll v-if="appearNote.poll" ref="pollViewer" :noteId="appearNote.id" :poll="appearNote.poll" :class="$style.poll"/>
|
<MkPoll v-if="appearNote.poll" ref="pollViewer" :noteId="appearNote.id" :poll="appearNote.poll" :class="$style.poll"/>
|
||||||
<MkUrlPreview v-for="url in urls" :key="url" :url="url" :compact="true" :detail="true" style="margin-top: 6px;"/>
|
<div v-if="isEnabledUrlPreview">
|
||||||
|
<MkUrlPreview v-for="url in urls" :key="url" :url="url" :compact="true" :detail="true" style="margin-top: 6px;"/>
|
||||||
|
</div>
|
||||||
<div v-if="appearNote.renote" :class="$style.quote"><MkNoteSimple :note="appearNote.renote" :class="$style.quoteNote"/></div>
|
<div v-if="appearNote.renote" :class="$style.quote"><MkNoteSimple :note="appearNote.renote" :class="$style.quoteNote"/></div>
|
||||||
</div>
|
</div>
|
||||||
<MkA v-if="appearNote.channel && !inChannel" :class="$style.channel" :to="`/channels/${appearNote.channel.id}`"><i class="ti ti-device-tv"></i> {{ appearNote.channel.name }}</MkA>
|
<MkA v-if="appearNote.channel && !inChannel" :class="$style.channel" :to="`/channels/${appearNote.channel.id}`"><i class="ti ti-device-tv"></i> {{ appearNote.channel.name }}</MkA>
|
||||||
|
@ -223,6 +225,7 @@ import MkNoteSub from '@/components/MkNoteSub.vue';
|
||||||
import MkNoteSimple from '@/components/MkNoteSimple.vue';
|
import MkNoteSimple from '@/components/MkNoteSimple.vue';
|
||||||
import MkNotePreview from '@/components/MkNotePreview.vue';
|
import MkNotePreview from '@/components/MkNotePreview.vue';
|
||||||
import MkReactionsViewer from '@/components/MkReactionsViewer.vue';
|
import MkReactionsViewer from '@/components/MkReactionsViewer.vue';
|
||||||
|
import MkReactionsViewerDetails from '@/components/MkReactionsViewer.details.vue';
|
||||||
import MkMediaList from '@/components/MkMediaList.vue';
|
import MkMediaList from '@/components/MkMediaList.vue';
|
||||||
import MkCwButton from '@/components/MkCwButton.vue';
|
import MkCwButton from '@/components/MkCwButton.vue';
|
||||||
import MkPoll from '@/components/MkPoll.vue';
|
import MkPoll from '@/components/MkPoll.vue';
|
||||||
|
@ -235,7 +238,7 @@ import { userPage } from '@/filters/user.js';
|
||||||
import { notePage } from '@/filters/note.js';
|
import { notePage } from '@/filters/note.js';
|
||||||
import number from '@/filters/number.js';
|
import number from '@/filters/number.js';
|
||||||
import * as os from '@/os.js';
|
import * as os from '@/os.js';
|
||||||
import { misskeyApi } from '@/scripts/misskey-api.js';
|
import { misskeyApi, misskeyApiGet } from '@/scripts/misskey-api.js';
|
||||||
import * as sound from '@/scripts/sound.js';
|
import * as sound from '@/scripts/sound.js';
|
||||||
import { defaultStore, noteViewInterruptors } from '@/store.js';
|
import { defaultStore, noteViewInterruptors } from '@/store.js';
|
||||||
import { reactionPicker } from '@/scripts/reaction-picker.js';
|
import { reactionPicker } from '@/scripts/reaction-picker.js';
|
||||||
|
@ -260,10 +263,14 @@ import { deviceKind } from '@/scripts/device-kind.js';
|
||||||
|
|
||||||
const MOBILE_THRESHOLD = 500;
|
const MOBILE_THRESHOLD = 500;
|
||||||
const isMobile = ref(deviceKind === 'smartphone' || window.innerWidth <= MOBILE_THRESHOLD);
|
const isMobile = ref(deviceKind === 'smartphone' || window.innerWidth <= MOBILE_THRESHOLD);
|
||||||
|
import { isEnabledUrlPreview } from '@/instance.js';
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = withDefaults(defineProps<{
|
||||||
note: Misskey.entities.Note;
|
note: Misskey.entities.Note;
|
||||||
}>();
|
initialTab: string;
|
||||||
|
}>(), {
|
||||||
|
initialTab: 'replies',
|
||||||
|
});
|
||||||
|
|
||||||
const inChannel = inject('inChannel', null);
|
const inChannel = inject('inChannel', null);
|
||||||
|
|
||||||
|
@ -362,7 +369,7 @@ provide('react', (reaction: string) => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
const tab = ref('replies');
|
const tab = ref(props.initialTab);
|
||||||
const reactionTabType = ref<string | null>(null);
|
const reactionTabType = ref<string | null>(null);
|
||||||
|
|
||||||
const renotesPagination = computed<Paging>(() => ({
|
const renotesPagination = computed<Paging>(() => ({
|
||||||
|
@ -407,6 +414,28 @@ useTooltip(renoteButton, async (showing) => {
|
||||||
}, {}, 'closed');
|
}, {}, 'closed');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (appearNote.value.reactionAcceptance === 'likeOnly') {
|
||||||
|
useTooltip(reactButton, async (showing) => {
|
||||||
|
const reactions = await misskeyApiGet('notes/reactions', {
|
||||||
|
noteId: appearNote.value.id,
|
||||||
|
limit: 10,
|
||||||
|
_cacheKey_: appearNote.value.reactionCount,
|
||||||
|
});
|
||||||
|
|
||||||
|
const users = reactions.map(x => x.user);
|
||||||
|
|
||||||
|
if (users.length < 1) return;
|
||||||
|
|
||||||
|
os.popup(MkReactionsViewerDetails, {
|
||||||
|
showing,
|
||||||
|
reaction: '❤️',
|
||||||
|
users,
|
||||||
|
count: appearNote.value.reactionCount,
|
||||||
|
targetElement: reactButton.value!,
|
||||||
|
}, {}, 'closed');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function renote(viaKeyboard = false) {
|
function renote(viaKeyboard = false) {
|
||||||
pleaseLogin();
|
pleaseLogin();
|
||||||
showMovedDialog();
|
showMovedDialog();
|
||||||
|
|
|
@ -19,18 +19,21 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
<div style="margin-top: 16px;">{{ i18n.ts.authenticationRequiredToContinue }}</div>
|
<div style="margin-top: 16px;">{{ i18n.ts.authenticationRequiredToContinue }}</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="_gaps">
|
<form @submit.prevent="done">
|
||||||
<MkInput ref="passwordInput" v-model="password" :placeholder="i18n.ts.password" type="password" autocomplete="current-password webauthn" :withPasswordToggle="true">
|
<div class="_gaps">
|
||||||
<template #prefix><i class="ti ti-password"></i></template>
|
<MkInput ref="passwordInput" v-model="password" :placeholder="i18n.ts.password" type="password" autocomplete="current-password webauthn" required :withPasswordToggle="true">
|
||||||
</MkInput>
|
<template #prefix><i class="ti ti-password"></i></template>
|
||||||
|
</MkInput>
|
||||||
|
|
||||||
<MkInput v-if="$i.twoFactorEnabled" v-model="token" type="text" pattern="^([0-9]{6}|[A-Z0-9]{32})$" autocomplete="one-time-code" :spellcheck="false">
|
<MkInput v-if="$i.twoFactorEnabled" v-model="token" type="text" :pattern="isBackupCode ? '^[A-Z0-9]{32}$' :'^[0-9]{6}$'" autocomplete="one-time-code" required :spellcheck="false" :inputmode="isBackupCode ? undefined : 'numeric'">
|
||||||
<template #label>{{ i18n.ts.token }} ({{ i18n.ts['2fa'] }})</template>
|
<template #label>{{ i18n.ts.token }} ({{ i18n.ts['2fa'] }})</template>
|
||||||
<template #prefix><i class="ti ti-123"></i></template>
|
<template #prefix><i v-if="isBackupCode" class="ti ti-key"></i><i v-else class="ti ti-123"></i></template>
|
||||||
</MkInput>
|
<template #caption><button class="_textButton" type="button" @click="isBackupCode = !isBackupCode">{{ isBackupCode ? i18n.ts.useTotp : i18n.ts.useBackupCode }}</button></template>
|
||||||
|
</MkInput>
|
||||||
|
|
||||||
<MkButton :disabled="(password ?? '') == '' || ($i.twoFactorEnabled && (token ?? '') == '')" primary rounded style="margin: 0 auto;" @click="done"><i class="ti ti-lock-open"></i> {{ i18n.ts.continue }}</MkButton>
|
<MkButton :disabled="(password ?? '') == '' || ($i.twoFactorEnabled && (token ?? '') == '')" type="submit" primary rounded style="margin: 0 auto;"><i class="ti ti-lock-open"></i> {{ i18n.ts.continue }}</MkButton>
|
||||||
</div>
|
</div>
|
||||||
|
</form>
|
||||||
</MkSpacer>
|
</MkSpacer>
|
||||||
</MkModalWindow>
|
</MkModalWindow>
|
||||||
</template>
|
</template>
|
||||||
|
@ -54,6 +57,7 @@ const emit = defineEmits<{
|
||||||
const dialog = shallowRef<InstanceType<typeof MkModalWindow>>();
|
const dialog = shallowRef<InstanceType<typeof MkModalWindow>>();
|
||||||
const passwordInput = shallowRef<InstanceType<typeof MkInput>>();
|
const passwordInput = shallowRef<InstanceType<typeof MkInput>>();
|
||||||
const password = ref('');
|
const password = ref('');
|
||||||
|
const isBackupCode = ref(false);
|
||||||
const token = ref<string | null>(null);
|
const token = ref<string | null>(null);
|
||||||
|
|
||||||
function onClose() {
|
function onClose() {
|
||||||
|
@ -61,7 +65,7 @@ function onClose() {
|
||||||
if (dialog.value) dialog.value.close();
|
if (dialog.value) dialog.value.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
function done(res) {
|
function done() {
|
||||||
emit('done', { password: password.value, token: token.value });
|
emit('done', { password: password.value, token: token.value });
|
||||||
if (dialog.value) dialog.value.close();
|
if (dialog.value) dialog.value.close();
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,6 +100,9 @@ watch([() => props.note.reactions, () => props.maxNumber], ([newSource, maxNumbe
|
||||||
}
|
}
|
||||||
|
|
||||||
.root {
|
.root {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
align-items: center;
|
||||||
margin: 4px -2px 0 -2px;
|
margin: 4px -2px 0 -2px;
|
||||||
|
|
||||||
&:empty {
|
&:empty {
|
||||||
|
|
|
@ -31,15 +31,15 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
<div v-if="user && user.securityKeys" class="or-hr">
|
<div v-if="user && user.securityKeys" class="or-hr">
|
||||||
<p class="or-msg">{{ i18n.ts.or }}</p>
|
<p class="or-msg">{{ i18n.ts.or }}</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="twofa-group totp-group">
|
<div class="twofa-group totp-group _gaps">
|
||||||
<p style="margin-bottom:0;">{{ i18n.ts['2fa'] }}</p>
|
|
||||||
<MkInput v-if="user && user.usePasswordLessLogin" v-model="password" type="password" autocomplete="current-password" :withPasswordToggle="true" required>
|
<MkInput v-if="user && user.usePasswordLessLogin" v-model="password" type="password" autocomplete="current-password" :withPasswordToggle="true" required>
|
||||||
<template #label>{{ i18n.ts.password }}</template>
|
<template #label>{{ i18n.ts.password }}</template>
|
||||||
<template #prefix><i class="ti ti-lock"></i></template>
|
<template #prefix><i class="ti ti-lock"></i></template>
|
||||||
</MkInput>
|
</MkInput>
|
||||||
<MkInput v-model="token" type="text" pattern="^([0-9]{6}|[A-Z0-9]{32})$" autocomplete="one-time-code" :spellcheck="false" required>
|
<MkInput v-model="token" type="text" :pattern="isBackupCode ? '^[A-Z0-9]{32}$' :'^[0-9]{6}$'" autocomplete="one-time-code" required :spellcheck="false" :inputmode="isBackupCode ? undefined : 'numeric'">
|
||||||
<template #label>{{ i18n.ts.token }}</template>
|
<template #label>{{ i18n.ts.token }} ({{ i18n.ts['2fa'] }})</template>
|
||||||
<template #prefix><i class="ti ti-123"></i></template>
|
<template #prefix><i v-if="isBackupCode" class="ti ti-key"></i><i v-else class="ti ti-123"></i></template>
|
||||||
|
<template #caption><button class="_textButton" type="button" @click="isBackupCode = !isBackupCode">{{ isBackupCode ? i18n.ts.useTotp : i18n.ts.useBackupCode }}</button></template>
|
||||||
</MkInput>
|
</MkInput>
|
||||||
<MkButton type="submit" :disabled="signing" large primary rounded style="margin: 0 auto;">{{ signing ? i18n.ts.loggingIn : i18n.ts.login }}</MkButton>
|
<MkButton type="submit" :disabled="signing" large primary rounded style="margin: 0 auto;">{{ signing ? i18n.ts.loggingIn : i18n.ts.login }}</MkButton>
|
||||||
</div>
|
</div>
|
||||||
|
@ -70,6 +70,7 @@ const password = ref('');
|
||||||
const token = ref('');
|
const token = ref('');
|
||||||
const host = ref(toUnicode(configHost));
|
const host = ref(toUnicode(configHost));
|
||||||
const totpLogin = ref(false);
|
const totpLogin = ref(false);
|
||||||
|
const isBackupCode = ref(false);
|
||||||
const queryingKey = ref(false);
|
const queryingKey = ref(false);
|
||||||
const credentialRequest = ref<CredentialRequestOptions | null>(null);
|
const credentialRequest = ref<CredentialRequestOptions | null>(null);
|
||||||
|
|
||||||
|
|
|
@ -48,13 +48,13 @@ const toggle = () => {
|
||||||
|
|
||||||
<style lang="scss" module>
|
<style lang="scss" module>
|
||||||
.button {
|
.button {
|
||||||
position: relative;
|
--height: 21px;position: relative;
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
width: 32px;
|
width: calc(var(--height) * 1.6);
|
||||||
height: 23px;
|
height: calc(var(--height) + 2px); // 枠線
|
||||||
outline: none;
|
outline: none;
|
||||||
background: var(--switchOffBg);
|
background: var(--switchOffBg);
|
||||||
background-clip: content-box;
|
background-clip: content-box;
|
||||||
|
@ -102,9 +102,9 @@ const toggle = () => {
|
||||||
|
|
||||||
.knob {
|
.knob {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 3px;
|
box-sizing: border-box;top: 3px;
|
||||||
width: 15px;
|
width: calc(var(--height) - 6px);
|
||||||
height: 15px;
|
height: calc(var(--height) - 6px);
|
||||||
border-radius: 999px;
|
border-radius: 999px;
|
||||||
transition: all 0.2s ease;
|
transition: all 0.2s ease;
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ const toggle = () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
.knobChecked {
|
.knobChecked {
|
||||||
left: 12px;
|
left: calc(calc(100% - var(--height)) + 3px);
|
||||||
background: var(--switchOnFg);
|
background: var(--switchOnFg);
|
||||||
|
|
||||||
&.gamingDark {
|
&.gamingDark {
|
||||||
|
|
|
@ -152,15 +152,16 @@ requestUrl.hash = '';
|
||||||
window.fetch(`/url?url=${encodeURIComponent(requestUrl.href)}&lang=${versatileLang}`)
|
window.fetch(`/url?url=${encodeURIComponent(requestUrl.href)}&lang=${versatileLang}`)
|
||||||
.then(res => {
|
.then(res => {
|
||||||
if (!res.ok) {
|
if (!res.ok) {
|
||||||
fetching.value = false;
|
if (_DEV_) {
|
||||||
unknownUrl.value = true;
|
console.warn(`[HTTP${res.status}] Failed to fetch url preview`);
|
||||||
return;
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return res.json();
|
return res.json();
|
||||||
})
|
})
|
||||||
.then((info: SummalyResult) => {
|
.then((info: SummalyResult | null) => {
|
||||||
if (info.url == null) {
|
if (!info || info.url == null) {
|
||||||
fetching.value = false;
|
fetching.value = false;
|
||||||
unknownUrl.value = true;
|
unknownUrl.value = true;
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -30,6 +30,7 @@ import { url as local } from '@/config.js';
|
||||||
import * as os from '@/os.js';
|
import * as os from '@/os.js';
|
||||||
import { useTooltip } from '@/scripts/use-tooltip.js';
|
import { useTooltip } from '@/scripts/use-tooltip.js';
|
||||||
import { safeURIDecode } from '@/scripts/safe-uri-decode.js';
|
import { safeURIDecode } from '@/scripts/safe-uri-decode.js';
|
||||||
|
import { isEnabledUrlPreview } from '@/instance.js';
|
||||||
|
|
||||||
const props = withDefaults(defineProps<{
|
const props = withDefaults(defineProps<{
|
||||||
url: string;
|
url: string;
|
||||||
|
@ -44,7 +45,7 @@ const url = new URL(props.url);
|
||||||
if (!['http:', 'https:'].includes(url.protocol)) throw new Error('invalid url');
|
if (!['http:', 'https:'].includes(url.protocol)) throw new Error('invalid url');
|
||||||
const el = ref();
|
const el = ref();
|
||||||
|
|
||||||
if (props.showUrlPreview) {
|
if (props.showUrlPreview && isEnabledUrlPreview.value) {
|
||||||
useTooltip(el, (showing) => {
|
useTooltip(el, (showing) => {
|
||||||
os.popup(defineAsyncComponent(() => import('@/components/MkUrlPreviewPopup.vue')), {
|
os.popup(defineAsyncComponent(() => import('@/components/MkUrlPreviewPopup.vue')), {
|
||||||
showing,
|
showing,
|
||||||
|
|
|
@ -14,6 +14,7 @@ import XText from './page.text.vue';
|
||||||
import XSection from './page.section.vue';
|
import XSection from './page.section.vue';
|
||||||
import XImage from './page.image.vue';
|
import XImage from './page.image.vue';
|
||||||
import XNote from './page.note.vue';
|
import XNote from './page.note.vue';
|
||||||
|
import XDynamic from './page.dynamic.vue';
|
||||||
|
|
||||||
function getComponent(type: string) {
|
function getComponent(type: string) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
@ -21,6 +22,20 @@ function getComponent(type: string) {
|
||||||
case 'section': return XSection;
|
case 'section': return XSection;
|
||||||
case 'image': return XImage;
|
case 'image': return XImage;
|
||||||
case 'note': return XNote;
|
case 'note': return XNote;
|
||||||
|
|
||||||
|
// 動的ページの代替用ブロック
|
||||||
|
case 'button':
|
||||||
|
case 'if':
|
||||||
|
case 'textarea':
|
||||||
|
case 'post':
|
||||||
|
case 'canvas':
|
||||||
|
case 'numberInput':
|
||||||
|
case 'textInput':
|
||||||
|
case 'switch':
|
||||||
|
case 'radioButton':
|
||||||
|
case 'counter':
|
||||||
|
return XDynamic;
|
||||||
|
|
||||||
default: return null;
|
default: return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
<!--
|
||||||
|
SPDX-FileCopyrightText: syuilo and misskey-project
|
||||||
|
SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
-->
|
||||||
|
|
||||||
|
<!-- 動的ページのブロックの代替。利用できないということを表示する -->
|
||||||
|
<template>
|
||||||
|
<div :class="$style.root">
|
||||||
|
<div :class="$style.heading"><i class="ti ti-dice-5"></i> {{ i18n.ts._pages.blocks.dynamic }}</div>
|
||||||
|
<I18n :src="i18n.ts._pages.blocks.dynamicDescription" tag="div" :class="$style.text">
|
||||||
|
<template #play>
|
||||||
|
<MkA to="/play" class="_link">Play</MkA>
|
||||||
|
</template>
|
||||||
|
</I18n>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import * as Misskey from 'misskey-js';
|
||||||
|
import { i18n } from '@/i18n.js';
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
block: Misskey.entities.PageBlock,
|
||||||
|
page: Misskey.entities.Page,
|
||||||
|
}>();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" module>
|
||||||
|
.root {
|
||||||
|
border: 1px solid var(--divider);
|
||||||
|
border-radius: var(--radius);
|
||||||
|
padding: var(--margin);
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.heading {
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|
||||||
|
.text {
|
||||||
|
font-size: 90%;
|
||||||
|
}
|
||||||
|
</style>
|
|
@ -6,7 +6,9 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
<template>
|
<template>
|
||||||
<div class="_gaps" :class="$style.textRoot">
|
<div class="_gaps" :class="$style.textRoot">
|
||||||
<Mfm :text="block.text ?? ''" :isNote="false"/>
|
<Mfm :text="block.text ?? ''" :isNote="false"/>
|
||||||
<MkUrlPreview v-for="url in urls" :key="url" :url="url"/>
|
<div v-if="isEnabledUrlPreview" class="_gaps_s">
|
||||||
|
<MkUrlPreview v-for="url in urls" :key="url" :url="url"/>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -15,6 +17,7 @@ import { defineAsyncComponent } from 'vue';
|
||||||
import * as mfm from 'mfm-js';
|
import * as mfm from 'mfm-js';
|
||||||
import * as Misskey from 'misskey-js';
|
import * as Misskey from 'misskey-js';
|
||||||
import { extractUrlFromMfm } from '@/scripts/extract-url-from-mfm.js';
|
import { extractUrlFromMfm } from '@/scripts/extract-url-from-mfm.js';
|
||||||
|
import { isEnabledUrlPreview } from '@/instance.js';
|
||||||
|
|
||||||
const MkUrlPreview = defineAsyncComponent(() => import('@/components/MkUrlPreview.vue'));
|
const MkUrlPreview = defineAsyncComponent(() => import('@/components/MkUrlPreview.vue'));
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
http-equiv="Content-Security-Policy"
|
http-equiv="Content-Security-Policy"
|
||||||
content="default-src 'self' https://newassets.hcaptcha.com/ https://challenges.cloudflare.com/ http://localhost:7493/;
|
content="default-src 'self' https://newassets.hcaptcha.com/ https://challenges.cloudflare.com/ http://localhost:7493/;
|
||||||
worker-src 'self';
|
worker-src 'self';
|
||||||
script-src 'self' 'unsafe-eval' https://*.hcaptcha.com https://challenges.cloudflare.com;
|
script-src 'self' 'unsafe-eval' https://*.hcaptcha.com https://challenges.cloudflare.com https://esm.sh;
|
||||||
style-src 'self' 'unsafe-inline';
|
style-src 'self' 'unsafe-inline';
|
||||||
img-src 'self' data: blob: www.google.com xn--931a.moe localhost:3000 localhost:5173 127.0.0.1:5173 127.0.0.1:3000;
|
img-src 'self' data: blob: www.google.com xn--931a.moe localhost:3000 localhost:5173 127.0.0.1:5173 127.0.0.1:3000;
|
||||||
media-src 'self' localhost:3000 localhost:5173 127.0.0.1:5173 127.0.0.1:3000;
|
media-src 'self' localhost:3000 localhost:5173 127.0.0.1:5173 127.0.0.1:3000;
|
||||||
|
|
|
@ -36,6 +36,8 @@ export const infoImageUrl = computed(() => instance.infoImageUrl ?? DEFAULT_INFO
|
||||||
|
|
||||||
export const notFoundImageUrl = computed(() => instance.notFoundImageUrl ?? DEFAULT_NOT_FOUND_IMAGE_URL);
|
export const notFoundImageUrl = computed(() => instance.notFoundImageUrl ?? DEFAULT_NOT_FOUND_IMAGE_URL);
|
||||||
|
|
||||||
|
export const isEnabledUrlPreview = computed(() => instance.enableUrlPreview ?? true);
|
||||||
|
|
||||||
export async function fetchInstance(force = false): Promise<void> {
|
export async function fetchInstance(force = false): Promise<void> {
|
||||||
if (!force) {
|
if (!force) {
|
||||||
const cachedAt = miLocalStorage.getItem('instanceCachedAt') ? parseInt(miLocalStorage.getItem('instanceCachedAt')!) : 0;
|
const cachedAt = miLocalStorage.getItem('instanceCachedAt') ? parseInt(miLocalStorage.getItem('instanceCachedAt')!) : 0;
|
||||||
|
|
|
@ -226,6 +226,15 @@ const patronsWithIcon = [{
|
||||||
}, {
|
}, {
|
||||||
name: '有栖かずみ',
|
name: '有栖かずみ',
|
||||||
icon: 'https://assets.misskey-hub.net/patrons/9240e8e0ba294a8884143e99ac7ed6a0.jpg',
|
icon: 'https://assets.misskey-hub.net/patrons/9240e8e0ba294a8884143e99ac7ed6a0.jpg',
|
||||||
|
}, {
|
||||||
|
name: 'イカロ(コアラ)',
|
||||||
|
icon: 'https://assets.misskey-hub.net/patrons/50b9bdc03735412c80807dbdf32cecb6.jpg',
|
||||||
|
}, {
|
||||||
|
name: 'ハチノス3号',
|
||||||
|
icon: 'https://assets.misskey-hub.net/patrons/030347a6f8ce4e82bc5184b5aad09a18.jpg',
|
||||||
|
}, {
|
||||||
|
name: 'Takeno',
|
||||||
|
icon: 'https://assets.misskey-hub.net/patrons/6fba81536aea48fe94a30909c502dfa1.jpg',
|
||||||
}];
|
}];
|
||||||
|
|
||||||
const patrons = [
|
const patrons = [
|
||||||
|
@ -329,6 +338,7 @@ const patrons = [
|
||||||
'たっくん',
|
'たっくん',
|
||||||
'SHO SEKIGUCHI',
|
'SHO SEKIGUCHI',
|
||||||
'塩キャベツ',
|
'塩キャベツ',
|
||||||
|
'はとぽぷさん',
|
||||||
];
|
];
|
||||||
|
|
||||||
const thereIsTreasure = ref($i && !claimedAchievements.includes('foundTreasure'));
|
const thereIsTreasure = ref($i && !claimedAchievements.includes('foundTreasure'));
|
||||||
|
|
|
@ -134,19 +134,6 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
</MkSwitch>
|
</MkSwitch>
|
||||||
</div>
|
</div>
|
||||||
</MkFolder>
|
</MkFolder>
|
||||||
|
|
||||||
<MkFolder>
|
|
||||||
<template #label>Summaly Proxy</template>
|
|
||||||
|
|
||||||
<div class="_gaps_m">
|
|
||||||
<MkInput v-model="summalyProxy">
|
|
||||||
<template #prefix><i class="ti ti-link"></i></template>
|
|
||||||
<template #label>Summaly Proxy URL</template>
|
|
||||||
</MkInput>
|
|
||||||
|
|
||||||
<MkButton primary @click="save"><i class="ti ti-device-floppy"></i> {{ i18n.ts.save }}</MkButton>
|
|
||||||
</div>
|
|
||||||
</MkFolder>
|
|
||||||
</div>
|
</div>
|
||||||
</FormSuspense>
|
</FormSuspense>
|
||||||
</MkSpacer>
|
</MkSpacer>
|
||||||
|
@ -171,7 +158,6 @@ import { fetchInstance } from '@/instance.js';
|
||||||
import { i18n } from '@/i18n.js';
|
import { i18n } from '@/i18n.js';
|
||||||
import { definePageMetadata } from '@/scripts/page-metadata.js';
|
import { definePageMetadata } from '@/scripts/page-metadata.js';
|
||||||
|
|
||||||
const summalyProxy = ref<string>('');
|
|
||||||
const enableHcaptcha = ref<boolean>(false);
|
const enableHcaptcha = ref<boolean>(false);
|
||||||
const enableMcaptcha = ref<boolean>(false);
|
const enableMcaptcha = ref<boolean>(false);
|
||||||
const enableRecaptcha = ref<boolean>(false);
|
const enableRecaptcha = ref<boolean>(false);
|
||||||
|
@ -193,7 +179,6 @@ const proxyCheckioApiKey = ref<string | null>(null);
|
||||||
|
|
||||||
async function init() {
|
async function init() {
|
||||||
const meta = await misskeyApi('admin/meta');
|
const meta = await misskeyApi('admin/meta');
|
||||||
summalyProxy.value = meta.summalyProxy;
|
|
||||||
enableHcaptcha.value = meta.enableHcaptcha;
|
enableHcaptcha.value = meta.enableHcaptcha;
|
||||||
enableMcaptcha.value = meta.enableMcaptcha;
|
enableMcaptcha.value = meta.enableMcaptcha;
|
||||||
enableRecaptcha.value = meta.enableRecaptcha;
|
enableRecaptcha.value = meta.enableRecaptcha;
|
||||||
|
@ -221,7 +206,6 @@ async function init() {
|
||||||
|
|
||||||
function save() {
|
function save() {
|
||||||
os.apiWithDialog('admin/update-meta', {
|
os.apiWithDialog('admin/update-meta', {
|
||||||
summalyProxy: summalyProxy.value,
|
|
||||||
sensitiveMediaDetection: sensitiveMediaDetection.value,
|
sensitiveMediaDetection: sensitiveMediaDetection.value,
|
||||||
sensitiveMediaDetectionSensitivity:
|
sensitiveMediaDetectionSensitivity:
|
||||||
sensitiveMediaDetectionSensitivity.value === 0 ? 'veryLow' :
|
sensitiveMediaDetectionSensitivity.value === 0 ? 'veryLow' :
|
||||||
|
|
|
@ -143,6 +143,53 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</FormSection>
|
</FormSection>
|
||||||
|
|
||||||
|
<FormSection>
|
||||||
|
<template #label>{{ i18n.ts._urlPreviewSetting.title }}</template>
|
||||||
|
|
||||||
|
<div class="_gaps_m">
|
||||||
|
<MkSwitch v-model="urlPreviewEnabled">
|
||||||
|
<template #label>{{ i18n.ts._urlPreviewSetting.enable }}</template>
|
||||||
|
</MkSwitch>
|
||||||
|
|
||||||
|
<MkSwitch v-model="urlPreviewRequireContentLength">
|
||||||
|
<template #label>{{ i18n.ts._urlPreviewSetting.requireContentLength }}</template>
|
||||||
|
<template #caption>{{ i18n.ts._urlPreviewSetting.requireContentLengthDescription }}</template>
|
||||||
|
</MkSwitch>
|
||||||
|
|
||||||
|
<MkInput v-model="urlPreviewMaximumContentLength" type="number">
|
||||||
|
<template #label>{{ i18n.ts._urlPreviewSetting.maximumContentLength }}</template>
|
||||||
|
<template #caption>{{ i18n.ts._urlPreviewSetting.maximumContentLengthDescription }}</template>
|
||||||
|
</MkInput>
|
||||||
|
|
||||||
|
<MkInput v-model="urlPreviewTimeout" type="number">
|
||||||
|
<template #label>{{ i18n.ts._urlPreviewSetting.timeout }}</template>
|
||||||
|
<template #caption>{{ i18n.ts._urlPreviewSetting.timeoutDescription }}</template>
|
||||||
|
</MkInput>
|
||||||
|
|
||||||
|
<MkInput v-model="urlPreviewUserAgent" type="text">
|
||||||
|
<template #label>{{ i18n.ts._urlPreviewSetting.userAgent }}</template>
|
||||||
|
<template #caption>{{ i18n.ts._urlPreviewSetting.userAgentDescription }}</template>
|
||||||
|
</MkInput>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<MkInput v-model="urlPreviewSummaryProxyUrl" type="text">
|
||||||
|
<template #label>{{ i18n.ts._urlPreviewSetting.summaryProxy }}</template>
|
||||||
|
<template #caption>[{{ i18n.ts.notUsePleaseLeaveBlank }}] {{ i18n.ts._urlPreviewSetting.summaryProxyDescription }}</template>
|
||||||
|
</MkInput>
|
||||||
|
|
||||||
|
<div :class="$style.subCaption">
|
||||||
|
{{ i18n.ts._urlPreviewSetting.summaryProxyDescription2 }}
|
||||||
|
<ul style="padding-left: 20px; margin: 4px 0">
|
||||||
|
<li>{{ i18n.ts._urlPreviewSetting.timeout }} / key:timeout</li>
|
||||||
|
<li>{{ i18n.ts._urlPreviewSetting.maximumContentLength }} / key:contentLengthLimit</li>
|
||||||
|
<li>{{ i18n.ts._urlPreviewSetting.requireContentLength }} / key:contentLengthRequired</li>
|
||||||
|
<li>{{ i18n.ts._urlPreviewSetting.userAgent }} / key:userAgent</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</FormSection>
|
||||||
</div>
|
</div>
|
||||||
</FormSuspense>
|
</FormSuspense>
|
||||||
</MkSpacer>
|
</MkSpacer>
|
||||||
|
@ -173,6 +220,8 @@ import { fetchInstance, instance } from '@/instance.js';
|
||||||
import { i18n } from '@/i18n.js';
|
import { i18n } from '@/i18n.js';
|
||||||
import { definePageMetadata } from '@/scripts/page-metadata.js';
|
import { definePageMetadata } from '@/scripts/page-metadata.js';
|
||||||
import MkButton from '@/components/MkButton.vue';
|
import MkButton from '@/components/MkButton.vue';
|
||||||
|
import MkFolder from '@/components/MkFolder.vue';
|
||||||
|
import MkSelect from '@/components/MkSelect.vue';
|
||||||
|
|
||||||
const name = ref<string | null>(null);
|
const name = ref<string | null>(null);
|
||||||
const shortName = ref<string | null>(null);
|
const shortName = ref<string | null>(null);
|
||||||
|
@ -194,6 +243,12 @@ const perRemoteUserUserTimelineCacheMax = ref<number>(0);
|
||||||
const perUserHomeTimelineCacheMax = ref<number>(0);
|
const perUserHomeTimelineCacheMax = ref<number>(0);
|
||||||
const perUserListTimelineCacheMax = ref<number>(0);
|
const perUserListTimelineCacheMax = ref<number>(0);
|
||||||
const notesPerOneAd = ref<number>(0);
|
const notesPerOneAd = ref<number>(0);
|
||||||
|
const urlPreviewEnabled = ref<boolean>(true);
|
||||||
|
const urlPreviewTimeout = ref<number>(10000);
|
||||||
|
const urlPreviewMaximumContentLength = ref<number>(1024 * 1024 * 10);
|
||||||
|
const urlPreviewRequireContentLength = ref<boolean>(true);
|
||||||
|
const urlPreviewUserAgent = ref<string | null>(null);
|
||||||
|
const urlPreviewSummaryProxyUrl = ref<string | null>(null);
|
||||||
|
|
||||||
async function init(): Promise<void> {
|
async function init(): Promise<void> {
|
||||||
const meta = await misskeyApi('admin/meta');
|
const meta = await misskeyApi('admin/meta');
|
||||||
|
@ -217,9 +272,15 @@ async function init(): Promise<void> {
|
||||||
perUserHomeTimelineCacheMax.value = meta.perUserHomeTimelineCacheMax;
|
perUserHomeTimelineCacheMax.value = meta.perUserHomeTimelineCacheMax;
|
||||||
perUserListTimelineCacheMax.value = meta.perUserListTimelineCacheMax;
|
perUserListTimelineCacheMax.value = meta.perUserListTimelineCacheMax;
|
||||||
notesPerOneAd.value = meta.notesPerOneAd;
|
notesPerOneAd.value = meta.notesPerOneAd;
|
||||||
|
urlPreviewEnabled.value = meta.urlPreviewEnabled;
|
||||||
|
urlPreviewTimeout.value = meta.urlPreviewTimeout;
|
||||||
|
urlPreviewMaximumContentLength.value = meta.urlPreviewMaximumContentLength;
|
||||||
|
urlPreviewRequireContentLength.value = meta.urlPreviewRequireContentLength;
|
||||||
|
urlPreviewUserAgent.value = meta.urlPreviewUserAgent;
|
||||||
|
urlPreviewSummaryProxyUrl.value = meta.urlPreviewSummaryProxyUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function save(): void {
|
async function save() {
|
||||||
await os.apiWithDialog('admin/update-meta', {
|
await os.apiWithDialog('admin/update-meta', {
|
||||||
name: name.value,
|
name: name.value,
|
||||||
shortName: shortName.value === '' ? null : shortName.value,
|
shortName: shortName.value === '' ? null : shortName.value,
|
||||||
|
@ -241,6 +302,12 @@ async function save(): void {
|
||||||
perUserHomeTimelineCacheMax: perUserHomeTimelineCacheMax.value,
|
perUserHomeTimelineCacheMax: perUserHomeTimelineCacheMax.value,
|
||||||
perUserListTimelineCacheMax: perUserListTimelineCacheMax.value,
|
perUserListTimelineCacheMax: perUserListTimelineCacheMax.value,
|
||||||
notesPerOneAd: notesPerOneAd.value,
|
notesPerOneAd: notesPerOneAd.value,
|
||||||
|
urlPreviewEnabled: urlPreviewEnabled.value,
|
||||||
|
urlPreviewTimeout: urlPreviewTimeout.value,
|
||||||
|
urlPreviewMaximumContentLength: urlPreviewMaximumContentLength.value,
|
||||||
|
urlPreviewRequireContentLength: urlPreviewRequireContentLength.value,
|
||||||
|
urlPreviewUserAgent: urlPreviewUserAgent.value,
|
||||||
|
urlPreviewSummaryProxyUrl: urlPreviewSummaryProxyUrl.value,
|
||||||
});
|
});
|
||||||
|
|
||||||
fetchInstance(true);
|
fetchInstance(true);
|
||||||
|
@ -259,4 +326,9 @@ definePageMetadata(() => ({
|
||||||
-webkit-backdrop-filter: var(--blur, blur(15px));
|
-webkit-backdrop-filter: var(--blur, blur(15px));
|
||||||
backdrop-filter: var(--blur, blur(15px));
|
backdrop-filter: var(--blur, blur(15px));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.subCaption {
|
||||||
|
font-size: 0.85em;
|
||||||
|
color: var(--fgTransparentWeak);
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -26,6 +26,7 @@ const draft = ref({
|
||||||
users: [],
|
users: [],
|
||||||
keywords: [],
|
keywords: [],
|
||||||
excludeKeywords: [],
|
excludeKeywords: [],
|
||||||
|
excludeBots: false,
|
||||||
withReplies: false,
|
withReplies: false,
|
||||||
caseSensitive: false,
|
caseSensitive: false,
|
||||||
localOnly: false,
|
localOnly: false,
|
||||||
|
|
|
@ -26,6 +26,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
<template #label>{{ i18n.ts.users }}</template>
|
<template #label>{{ i18n.ts.users }}</template>
|
||||||
<template #caption>{{ i18n.ts.antennaUsersDescription }} <button class="_textButton" @click="addUser">{{ i18n.ts.addUser }}</button></template>
|
<template #caption>{{ i18n.ts.antennaUsersDescription }} <button class="_textButton" @click="addUser">{{ i18n.ts.addUser }}</button></template>
|
||||||
</MkTextarea>
|
</MkTextarea>
|
||||||
|
<MkSwitch v-model="excludeBots">{{ i18n.ts.antennaExcludeBots }}</MkSwitch>
|
||||||
<MkSwitch v-model="withReplies">{{ i18n.ts.withReplies }}</MkSwitch>
|
<MkSwitch v-model="withReplies">{{ i18n.ts.withReplies }}</MkSwitch>
|
||||||
<MkTextarea v-model="keywords">
|
<MkTextarea v-model="keywords">
|
||||||
<template #label>{{ i18n.ts.antennaKeywords }}</template>
|
<template #label>{{ i18n.ts.antennaKeywords }}</template>
|
||||||
|
@ -78,6 +79,7 @@ const keywords = ref<string>(props.antenna.keywords.map(x => x.join(' ')).join('
|
||||||
const excludeKeywords = ref<string>(props.antenna.excludeKeywords.map(x => x.join(' ')).join('\n'));
|
const excludeKeywords = ref<string>(props.antenna.excludeKeywords.map(x => x.join(' ')).join('\n'));
|
||||||
const caseSensitive = ref<boolean>(props.antenna.caseSensitive);
|
const caseSensitive = ref<boolean>(props.antenna.caseSensitive);
|
||||||
const localOnly = ref<boolean>(props.antenna.localOnly);
|
const localOnly = ref<boolean>(props.antenna.localOnly);
|
||||||
|
const excludeBots = ref<boolean>(props.antenna.excludeBots);
|
||||||
const withReplies = ref<boolean>(props.antenna.withReplies);
|
const withReplies = ref<boolean>(props.antenna.withReplies);
|
||||||
const withFile = ref<boolean>(props.antenna.withFile);
|
const withFile = ref<boolean>(props.antenna.withFile);
|
||||||
const notify = ref<boolean>(props.antenna.notify);
|
const notify = ref<boolean>(props.antenna.notify);
|
||||||
|
@ -94,6 +96,7 @@ async function saveAntenna() {
|
||||||
name: name.value,
|
name: name.value,
|
||||||
src: src.value,
|
src: src.value,
|
||||||
userListId: userListId.value,
|
userListId: userListId.value,
|
||||||
|
excludeBots: excludeBots.value,
|
||||||
withReplies: withReplies.value,
|
withReplies: withReplies.value,
|
||||||
withFile: withFile.value,
|
withFile: withFile.value,
|
||||||
notify: notify.value,
|
notify: notify.value,
|
||||||
|
|
|
@ -21,7 +21,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
</div>
|
</div>
|
||||||
<div class="_margin _gaps_s">
|
<div class="_margin _gaps_s">
|
||||||
<MkRemoteCaution v-if="note.user.host != null" :href="note.url ?? note.uri"/>
|
<MkRemoteCaution v-if="note.user.host != null" :href="note.url ?? note.uri"/>
|
||||||
<MkNoteDetailed :key="note.id" v-model:note="note" :class="$style.note"/>
|
<MkNoteDetailed :key="note.id" v-model:note="note" :initialTab="initialTab" :class="$style.note"/>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="clips && clips.length > 0" class="_margin">
|
<div v-if="clips && clips.length > 0" class="_margin">
|
||||||
<div style="font-weight: bold; padding: 12px;">{{ i18n.ts.clip }}</div>
|
<div style="font-weight: bold; padding: 12px;">{{ i18n.ts.clip }}</div>
|
||||||
|
@ -66,6 +66,7 @@ import { defaultStore } from '@/store.js';
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
noteId: string;
|
noteId: string;
|
||||||
|
initialTab?: string;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const note = ref<null | Misskey.entities.Note>();
|
const note = ref<null | Misskey.entities.Note>();
|
||||||
|
|
|
@ -33,8 +33,12 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
<a href="https://support.google.com/accounts/answer/1066447" rel="noopener" target="_blank" class="_link">Google Authenticator</a>
|
<a href="https://support.google.com/accounts/answer/1066447" rel="noopener" target="_blank" class="_link">Google Authenticator</a>
|
||||||
</template>
|
</template>
|
||||||
</I18n>
|
</I18n>
|
||||||
<div>{{ i18n.ts._2fa.step2 }}<br>{{ i18n.ts._2fa.step2Click }}</div>
|
<div>{{ i18n.ts._2fa.step2 }}</div>
|
||||||
<a :href="twoFactorData.url"><img :class="$style.qr" :src="twoFactorData.qr"></a>
|
<div>
|
||||||
|
<a :class="$style.qrRoot" :href="twoFactorData.url"><img :class="$style.qr" :src="twoFactorData.qr"></a>
|
||||||
|
<!-- QRコード側にマージンが入っているので直下でOK -->
|
||||||
|
<div><MkButton inline rounded link :to="twoFactorData.url" :linkBehavior="'browser'">{{ i18n.ts.launchApp }}</MkButton></div>
|
||||||
|
</div>
|
||||||
<MkKeyValue :copy="twoFactorData.url">
|
<MkKeyValue :copy="twoFactorData.url">
|
||||||
<template #key>{{ i18n.ts._2fa.step2Uri }}</template>
|
<template #key>{{ i18n.ts._2fa.step2Uri }}</template>
|
||||||
<template #value>{{ twoFactorData.url }}</template>
|
<template #value>{{ twoFactorData.url }}</template>
|
||||||
|
@ -52,7 +56,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
<MkSpacer :marginMin="20" :marginMax="28">
|
<MkSpacer :marginMin="20" :marginMax="28">
|
||||||
<div class="_gaps">
|
<div class="_gaps">
|
||||||
<div>{{ i18n.ts._2fa.step3Title }}</div>
|
<div>{{ i18n.ts._2fa.step3Title }}</div>
|
||||||
<MkInput v-model="token" autocomplete="one-time-code"></MkInput>
|
<MkInput v-model="token" autocomplete="one-time-code" inputmode="numeric"></MkInput>
|
||||||
<div>{{ i18n.ts._2fa.step3 }}</div>
|
<div>{{ i18n.ts._2fa.step3 }}</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="_buttonsCenter" style="margin-top: 16px;">
|
<div class="_buttonsCenter" style="margin-top: 16px;">
|
||||||
|
@ -177,8 +181,14 @@ function allDone() {
|
||||||
transform: translateX(-50px);
|
transform: translateX(-50px);
|
||||||
}
|
}
|
||||||
|
|
||||||
.qr {
|
.qrRoot {
|
||||||
|
display: block;
|
||||||
|
margin: 0 auto;
|
||||||
width: 200px;
|
width: 200px;
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.qr {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -80,7 +80,7 @@ import MkSwitch from '@/components/MkSwitch.vue';
|
||||||
import FormSection from '@/components/form/section.vue';
|
import FormSection from '@/components/form/section.vue';
|
||||||
import MkFolder from '@/components/MkFolder.vue';
|
import MkFolder from '@/components/MkFolder.vue';
|
||||||
import * as os from '@/os.js';
|
import * as os from '@/os.js';
|
||||||
import { signinRequired } from '@/account.js';
|
import { signinRequired, updateAccount } from '@/account.js';
|
||||||
import { i18n } from '@/i18n.js';
|
import { i18n } from '@/i18n.js';
|
||||||
|
|
||||||
const $i = signinRequired();
|
const $i = signinRequired();
|
||||||
|
@ -116,6 +116,10 @@ async function unregisterTOTP(): Promise<void> {
|
||||||
os.apiWithDialog('i/2fa/unregister', {
|
os.apiWithDialog('i/2fa/unregister', {
|
||||||
password: auth.result.password,
|
password: auth.result.password,
|
||||||
token: auth.result.token,
|
token: auth.result.token,
|
||||||
|
}).then(res => {
|
||||||
|
updateAccount({
|
||||||
|
twoFactorEnabled: false,
|
||||||
|
});
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
os.alert({
|
os.alert({
|
||||||
type: 'error',
|
type: 'error',
|
||||||
|
|
|
@ -177,6 +177,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
<MkSwitch v-model="enableonlyAndWithSave">{{ i18n.ts.onlyAndWithSave }}<template #caption>{{ i18n.ts.onlyAndWithSaveInfo }} </template></MkSwitch>
|
<MkSwitch v-model="enableonlyAndWithSave">{{ i18n.ts.onlyAndWithSave }}<template #caption>{{ i18n.ts.onlyAndWithSaveInfo }} </template></MkSwitch>
|
||||||
<MkSwitch v-model="enablehanntenn">{{ i18n.ts.hanntenn }}<template #caption>{{ i18n.ts.hanntennInfo }} </template></MkSwitch>
|
<MkSwitch v-model="enablehanntenn">{{ i18n.ts.hanntenn }}<template #caption>{{ i18n.ts.hanntennInfo }} </template></MkSwitch>
|
||||||
<MkSwitch v-model="enableSeasonalScreenEffect">{{ i18n.ts.seasonalScreenEffect }}</MkSwitch>
|
<MkSwitch v-model="enableSeasonalScreenEffect">{{ i18n.ts.seasonalScreenEffect }}</MkSwitch>
|
||||||
|
<MkSwitch v-model="useNativeUIForVideoAudioPlayer">{{ i18n.ts.useNativeUIForVideoAudioPlayer }}</MkSwitch>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<MkRadios v-model="emojiStyle">
|
<MkRadios v-model="emojiStyle">
|
||||||
|
@ -475,6 +476,7 @@ const remoteLocalTimelineName2 = ref(defaultStore.state['remoteLocalTimelineName
|
||||||
const remoteLocalTimelineName3 = ref(defaultStore.state['remoteLocalTimelineName3']);
|
const remoteLocalTimelineName3 = ref(defaultStore.state['remoteLocalTimelineName3']);
|
||||||
const remoteLocalTimelineName4 = ref(defaultStore.state['remoteLocalTimelineName4']);
|
const remoteLocalTimelineName4 = ref(defaultStore.state['remoteLocalTimelineName4']);
|
||||||
const remoteLocalTimelineName5 = ref(defaultStore.state['remoteLocalTimelineName5']);
|
const remoteLocalTimelineName5 = ref(defaultStore.state['remoteLocalTimelineName5']);
|
||||||
|
const useNativeUIForVideoAudioPlayer = computed(defaultStore.makeGetterSetter('useNativeUIForVideoAudioPlayer'));
|
||||||
|
|
||||||
const remoteLocalTimelineEnable1 = computed(defaultStore.makeGetterSetter('remoteLocalTimelineEnable1'));
|
const remoteLocalTimelineEnable1 = computed(defaultStore.makeGetterSetter('remoteLocalTimelineEnable1'));
|
||||||
const remoteLocalTimelineEnable2 = computed(defaultStore.makeGetterSetter('remoteLocalTimelineEnable2'));
|
const remoteLocalTimelineEnable2 = computed(defaultStore.makeGetterSetter('remoteLocalTimelineEnable2'));
|
||||||
|
|
|
@ -35,7 +35,7 @@ const routes: RouteDef[] = [{
|
||||||
component: page(() => import('@/pages/user/index.vue')),
|
component: page(() => import('@/pages/user/index.vue')),
|
||||||
}, {
|
}, {
|
||||||
name: 'note',
|
name: 'note',
|
||||||
path: '/notes/:noteId',
|
path: '/notes/:noteId/:initialTab?',
|
||||||
component: page(() => import('@/pages/note.vue')),
|
component: page(() => import('@/pages/note.vue')),
|
||||||
}, {
|
}, {
|
||||||
name: 'list',
|
name: 'list',
|
||||||
|
|
|
@ -3,18 +3,19 @@
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { bundledThemesInfo } from 'shiki';
|
|
||||||
import { getHighlighterCore, loadWasm } from 'shiki/core';
|
import { getHighlighterCore, loadWasm } from 'shiki/core';
|
||||||
import darkPlus from 'shiki/themes/dark-plus.mjs';
|
import darkPlus from 'shiki/themes/dark-plus.mjs';
|
||||||
|
import { bundledThemesInfo } from 'shiki/themes';
|
||||||
|
import { bundledLanguagesInfo } from 'shiki/langs';
|
||||||
import { unique } from './array.js';
|
import { unique } from './array.js';
|
||||||
import { deepClone } from './clone.js';
|
import { deepClone } from './clone.js';
|
||||||
import { deepMerge } from './merge.js';
|
import { deepMerge } from './merge.js';
|
||||||
import type { Highlighter, LanguageRegistration, ThemeRegistration, ThemeRegistrationRaw } from 'shiki';
|
import type { HighlighterCore, LanguageRegistration, ThemeRegistration, ThemeRegistrationRaw } from 'shiki/core';
|
||||||
import { ColdDeviceStorage } from '@/store.js';
|
import { ColdDeviceStorage } from '@/store.js';
|
||||||
import lightTheme from '@/themes/_light.json5';
|
import lightTheme from '@/themes/_light.json5';
|
||||||
import darkTheme from '@/themes/_dark.json5';
|
import darkTheme from '@/themes/_dark.json5';
|
||||||
|
|
||||||
let _highlighter: Highlighter | null = null;
|
let _highlighter: HighlighterCore | null = null;
|
||||||
|
|
||||||
export async function getTheme(mode: 'light' | 'dark', getName: true): Promise<string>;
|
export async function getTheme(mode: 'light' | 'dark', getName: true): Promise<string>;
|
||||||
export async function getTheme(mode: 'light' | 'dark', getName?: false): Promise<ThemeRegistration | ThemeRegistrationRaw>;
|
export async function getTheme(mode: 'light' | 'dark', getName?: false): Promise<ThemeRegistration | ThemeRegistrationRaw>;
|
||||||
|
@ -51,16 +52,14 @@ export async function getTheme(mode: 'light' | 'dark', getName = false): Promise
|
||||||
return darkPlus;
|
return darkPlus;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getHighlighter(): Promise<Highlighter> {
|
export async function getHighlighter(): Promise<HighlighterCore> {
|
||||||
if (!_highlighter) {
|
if (!_highlighter) {
|
||||||
return await initHighlighter();
|
return await initHighlighter();
|
||||||
}
|
}
|
||||||
return _highlighter;
|
return _highlighter;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function initHighlighter() {
|
async function initHighlighter() {
|
||||||
const aiScriptGrammar = await import('aiscript-vscode/aiscript/syntaxes/aiscript.tmLanguage.json');
|
|
||||||
|
|
||||||
await loadWasm(import('shiki/onig.wasm?init'));
|
await loadWasm(import('shiki/onig.wasm?init'));
|
||||||
|
|
||||||
// テーマの重複を消す
|
// テーマの重複を消す
|
||||||
|
@ -69,11 +68,12 @@ export async function initHighlighter() {
|
||||||
...(await Promise.all([getTheme('light'), getTheme('dark')])),
|
...(await Promise.all([getTheme('light'), getTheme('dark')])),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
const jsLangInfo = bundledLanguagesInfo.find(t => t.id === 'javascript');
|
||||||
const highlighter = await getHighlighterCore({
|
const highlighter = await getHighlighterCore({
|
||||||
themes,
|
themes,
|
||||||
langs: [
|
langs: [
|
||||||
import('shiki/langs/javascript.mjs'),
|
...(jsLangInfo ? [async () => await jsLangInfo.import()] : []),
|
||||||
aiScriptGrammar.default as unknown as LanguageRegistration,
|
async () => (await import('aiscript-vscode/aiscript/syntaxes/aiscript.tmLanguage.json')).default as unknown as LanguageRegistration,
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@ export default (input: string): string[] => {
|
||||||
export const aliases = {
|
export const aliases = {
|
||||||
'esc': 'Escape',
|
'esc': 'Escape',
|
||||||
'enter': ['Enter', 'NumpadEnter'],
|
'enter': ['Enter', 'NumpadEnter'],
|
||||||
|
'space': [' ', 'Spacebar'],
|
||||||
'up': 'ArrowUp',
|
'up': 'ArrowUp',
|
||||||
'down': 'ArrowDown',
|
'down': 'ArrowDown',
|
||||||
'left': 'ArrowLeft',
|
'left': 'ArrowLeft',
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
import tinycolor from 'tinycolor2';
|
import tinycolor from 'tinycolor2';
|
||||||
import { deepClone } from './clone.js';
|
import { deepClone } from './clone.js';
|
||||||
import type { BuiltinTheme } from 'shiki';
|
import type { BundledTheme } from 'shiki/themes';
|
||||||
import { globalEvents } from '@/events.js';
|
import { globalEvents } from '@/events.js';
|
||||||
import lightTheme from '@/themes/_light.json5';
|
import lightTheme from '@/themes/_light.json5';
|
||||||
import darkTheme from '@/themes/_dark.json5';
|
import darkTheme from '@/themes/_dark.json5';
|
||||||
|
@ -20,7 +20,7 @@ export type Theme = {
|
||||||
base?: 'dark' | 'light';
|
base?: 'dark' | 'light';
|
||||||
props: Record<string, string>;
|
props: Record<string, string>;
|
||||||
codeHighlighter?: {
|
codeHighlighter?: {
|
||||||
base: BuiltinTheme;
|
base: BundledTheme;
|
||||||
overrides?: Record<string, any>;
|
overrides?: Record<string, any>;
|
||||||
} | {
|
} | {
|
||||||
base: '_none_';
|
base: '_none_';
|
||||||
|
|
|
@ -7,7 +7,6 @@ import { markRaw, ref } from 'vue';
|
||||||
import * as Misskey from 'misskey-js';
|
import * as Misskey from 'misskey-js';
|
||||||
import { miLocalStorage } from './local-storage.js';
|
import { miLocalStorage } from './local-storage.js';
|
||||||
import type { SoundType } from '@/scripts/sound.js';
|
import type { SoundType } from '@/scripts/sound.js';
|
||||||
import type { BuiltinTheme as ShikiBuiltinTheme } from 'shiki';
|
|
||||||
import { Storage } from '@/pizzax.js';
|
import { Storage } from '@/pizzax.js';
|
||||||
import { hemisphere } from '@/scripts/intl-const.js';
|
import { hemisphere } from '@/scripts/intl-const.js';
|
||||||
|
|
||||||
|
@ -709,6 +708,10 @@ export const defaultStore = markRaw(new Storage('base', {
|
||||||
where: 'device',
|
where: 'device',
|
||||||
default: true,
|
default: true,
|
||||||
},
|
},
|
||||||
|
useNativeUIForVideoAudioPlayer: {
|
||||||
|
where: 'device',
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
|
|
||||||
sound_masterVolume: {
|
sound_masterVolume: {
|
||||||
where: 'device',
|
where: 'device',
|
||||||
|
|
|
@ -439,12 +439,13 @@ rt {
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
|
|
||||||
--bg: #F1E8DC;
|
--bg: #F1E8DC;
|
||||||
--panel: #fff;
|
|
||||||
--fg: #693410;
|
--fg: #693410;
|
||||||
--switchOffBg: rgba(0, 0, 0, 0.1);
|
}
|
||||||
--switchOffFg: rgb(255, 255, 255);
|
|
||||||
--switchOnBg: var(--accent);
|
html[data-color-mode=dark] ._woodenFrame {
|
||||||
--switchOnFg: rgb(255, 255, 255);
|
--bg: #1d0c02;
|
||||||
|
--fg: #F1E8DC;
|
||||||
|
--panel: #192320;
|
||||||
}
|
}
|
||||||
|
|
||||||
._woodenFrameH {
|
._woodenFrameH {
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
import * as Misskey from 'misskey-js';
|
import * as Misskey from 'misskey-js';
|
||||||
import { ComputedRef, Ref } from 'vue';
|
import { ComputedRef, Ref } from 'vue';
|
||||||
|
|
||||||
|
interface MenuRadioOptionsDef extends Record<string, any> { }
|
||||||
|
|
||||||
export type MenuAction = (ev: MouseEvent) => void;
|
export type MenuAction = (ev: MouseEvent) => void;
|
||||||
|
|
||||||
export type MenuDivider = { type: 'divider' };
|
export type MenuDivider = { type: 'divider' };
|
||||||
|
@ -14,13 +16,15 @@ export type MenuLabel = { type: 'label', text: string };
|
||||||
export type MenuLink = { type: 'link', to: string, text: string, icon?: string, indicate?: boolean, avatar?: Misskey.entities.User };
|
export type MenuLink = { type: 'link', to: string, text: string, icon?: string, indicate?: boolean, avatar?: Misskey.entities.User };
|
||||||
export type MenuA = { type: 'a', href: string, target?: string, download?: string, text: string, icon?: string, indicate?: boolean };
|
export type MenuA = { type: 'a', href: string, target?: string, download?: string, text: string, icon?: string, indicate?: boolean };
|
||||||
export type MenuUser = { type: 'user', user: Misskey.entities.User, active?: boolean, indicate?: boolean, action: MenuAction };
|
export type MenuUser = { type: 'user', user: Misskey.entities.User, active?: boolean, indicate?: boolean, action: MenuAction };
|
||||||
export type MenuSwitch = { type: 'switch', ref: Ref<boolean>, text: string, disabled?: boolean | Ref<boolean> };
|
export type MenuSwitch = { type: 'switch', ref: Ref<boolean>, text: string, icon?: string, disabled?: boolean | Ref<boolean> };
|
||||||
export type MenuButton = { type?: 'button', text: string, icon?: string, indicate?: boolean, danger?: boolean, active?: boolean | ComputedRef<boolean>, avatar?: Misskey.entities.User; action: MenuAction };
|
export type MenuButton = { type?: 'button', text: string, icon?: string, indicate?: boolean, danger?: boolean, active?: boolean | ComputedRef<boolean>, avatar?: Misskey.entities.User; action: MenuAction };
|
||||||
|
export type MenuRadio = { type: 'radio', text: string, icon?: string, ref: Ref<MenuRadioOptionsDef[keyof MenuRadioOptionsDef]>, options: MenuRadioOptionsDef, disabled?: boolean | Ref<boolean> };
|
||||||
|
export type MenuRadioOption = { type: 'radioOption', text: string, action: MenuAction; active?: boolean | ComputedRef<boolean> };
|
||||||
export type MenuParent = { type: 'parent', text: string, icon?: string, children: MenuItem[] | (() => Promise<MenuItem[]> | MenuItem[]) };
|
export type MenuParent = { type: 'parent', text: string, icon?: string, children: MenuItem[] | (() => Promise<MenuItem[]> | MenuItem[]) };
|
||||||
|
|
||||||
export type MenuPending = { type: 'pending' };
|
export type MenuPending = { type: 'pending' };
|
||||||
|
|
||||||
type OuterMenuItem = MenuDivider | MenuNull | MenuLabel | MenuLink | MenuA | MenuUser | MenuSwitch | MenuButton | MenuParent;
|
type OuterMenuItem = MenuDivider | MenuNull | MenuLabel | MenuLink | MenuA | MenuUser | MenuSwitch | MenuButton | MenuRadio | MenuRadioOption | MenuParent;
|
||||||
type OuterPromiseMenuItem = Promise<MenuLabel | MenuLink | MenuA | MenuUser | MenuSwitch | MenuButton | MenuParent>;
|
type OuterPromiseMenuItem = Promise<MenuLabel | MenuLink | MenuA | MenuUser | MenuSwitch | MenuButton | MenuParent>;
|
||||||
export type MenuItem = OuterMenuItem | OuterPromiseMenuItem;
|
export type MenuItem = OuterMenuItem | OuterPromiseMenuItem;
|
||||||
export type InnerMenuItem = MenuDivider | MenuPending | MenuLabel | MenuLink | MenuA | MenuUser | MenuSwitch | MenuButton | MenuParent;
|
export type InnerMenuItem = MenuDivider | MenuPending | MenuLabel | MenuLink | MenuA | MenuUser | MenuSwitch | MenuButton | MenuRadio | MenuRadioOption | MenuParent;
|
||||||
|
|
|
@ -7,6 +7,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
<MkContainer :showHeader="widgetProps.showHeader" class="mkw-bdayfollowings">
|
<MkContainer :showHeader="widgetProps.showHeader" class="mkw-bdayfollowings">
|
||||||
<template #icon><i class="ti ti-cake"></i></template>
|
<template #icon><i class="ti ti-cake"></i></template>
|
||||||
<template #header>{{ i18n.ts._widgets.birthdayFollowings }}</template>
|
<template #header>{{ i18n.ts._widgets.birthdayFollowings }}</template>
|
||||||
|
<template #func="{ buttonStyleClass }"><button class="_button" :class="buttonStyleClass" @click="actualFetch()"><i class="ti ti-refresh"></i></button></template>
|
||||||
|
|
||||||
<div :class="$style.bdayFRoot">
|
<div :class="$style.bdayFRoot">
|
||||||
<MkLoading v-if="fetching"/>
|
<MkLoading v-if="fetching"/>
|
||||||
|
@ -53,7 +54,7 @@ const { widgetProps, configure } = useWidgetPropsManager(name,
|
||||||
emit,
|
emit,
|
||||||
);
|
);
|
||||||
|
|
||||||
const users = ref<Misskey.entities.FollowingFolloweePopulated[]>([]);
|
const users = ref<Misskey.Endpoints['users/following']['res']>([]);
|
||||||
const fetching = ref(true);
|
const fetching = ref(true);
|
||||||
let lastFetchedAt = '1970-01-01';
|
let lastFetchedAt = '1970-01-01';
|
||||||
|
|
||||||
|
@ -70,19 +71,35 @@ const fetch = () => {
|
||||||
now.setHours(0, 0, 0, 0);
|
now.setHours(0, 0, 0, 0);
|
||||||
|
|
||||||
if (now > lfAtD) {
|
if (now > lfAtD) {
|
||||||
misskeyApi('users/following', {
|
actualFetch();
|
||||||
limit: 18,
|
|
||||||
birthday: now.toISOString(),
|
|
||||||
userId: $i.id,
|
|
||||||
}).then(res => {
|
|
||||||
users.value = res;
|
|
||||||
fetching.value = false;
|
|
||||||
});
|
|
||||||
|
|
||||||
lastFetchedAt = now.toISOString();
|
lastFetchedAt = now.toISOString();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function actualFetch() {
|
||||||
|
if ($i == null) {
|
||||||
|
users.value = [];
|
||||||
|
fetching.value = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const now = new Date();
|
||||||
|
now.setHours(0, 0, 0, 0);
|
||||||
|
fetching.value = true;
|
||||||
|
misskeyApi('users/following', {
|
||||||
|
limit: 18,
|
||||||
|
birthday: `${now.getFullYear().toString().padStart(4, '0')}-${(now.getMonth() + 1).toString().padStart(2, '0')}-${now.getDate().toString().padStart(2, '0')}`,
|
||||||
|
userId: $i.id,
|
||||||
|
}).then(res => {
|
||||||
|
users.value = res;
|
||||||
|
window.setTimeout(() => {
|
||||||
|
// 早すぎるとチカチカする
|
||||||
|
fetching.value = false;
|
||||||
|
}, 100);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
useInterval(fetch, 1000 * 60, {
|
useInterval(fetch, 1000 * 60, {
|
||||||
immediate: true,
|
immediate: true,
|
||||||
afterMounted: true,
|
afterMounted: true,
|
||||||
|
|
|
@ -5,11 +5,30 @@ import {type UserConfig, defineConfig} from 'vite';
|
||||||
|
|
||||||
import locales from '../../locales/index.js';
|
import locales from '../../locales/index.js';
|
||||||
import meta from '../../package.json';
|
import meta from '../../package.json';
|
||||||
|
import packageInfo from './package.json' assert { type: 'json' };
|
||||||
import pluginUnwindCssModuleClassName from './lib/rollup-plugin-unwind-css-module-class-name.js';
|
import pluginUnwindCssModuleClassName from './lib/rollup-plugin-unwind-css-module-class-name.js';
|
||||||
import pluginJson5 from './vite.json5.js';
|
import pluginJson5 from './vite.json5.js';
|
||||||
|
|
||||||
const extensions = ['.ts', '.tsx', '.js', '.jsx', '.mjs', '.json', '.json5', '.svg', '.sass', '.scss', '.css', '.vue'];
|
const extensions = ['.ts', '.tsx', '.js', '.jsx', '.mjs', '.json', '.json5', '.svg', '.sass', '.scss', '.css', '.vue'];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Misskeyのフロントエンドにバンドルせず、CDNなどから別途読み込むリソースを記述する。
|
||||||
|
* CDNを使わずにバンドルしたい場合、以下の配列から該当要素を削除orコメントアウトすればOK
|
||||||
|
*/
|
||||||
|
const externalPackages = [
|
||||||
|
// shiki(コードブロックのシンタックスハイライトで使用中)はテーマ・言語の定義の容量が大きいため、それらはCDNから読み込む
|
||||||
|
{
|
||||||
|
name: 'shiki',
|
||||||
|
match: /^shiki\/(?<subPkg>(langs|themes))$/,
|
||||||
|
path(id: string, pattern: RegExp): string {
|
||||||
|
const match = pattern.exec(id)?.groups;
|
||||||
|
return match
|
||||||
|
? `https://esm.sh/shiki@${packageInfo.dependencies.shiki}/${match['subPkg']}`
|
||||||
|
: id;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
const hash = (str: string, seed = 0): number => {
|
const hash = (str: string, seed = 0): number => {
|
||||||
let h1 = 0xdeadbeef ^ seed,
|
let h1 = 0xdeadbeef ^ seed,
|
||||||
h2 = 0x41c6ce57 ^ seed;
|
h2 = 0x41c6ce57 ^ seed;
|
||||||
|
@ -112,6 +131,7 @@ export function getConfig(): UserConfig {
|
||||||
input: {
|
input: {
|
||||||
app: './src/_boot_.ts',
|
app: './src/_boot_.ts',
|
||||||
},
|
},
|
||||||
|
external: externalPackages.map(p => p.match),
|
||||||
output: {
|
output: {
|
||||||
manualChunks: {
|
manualChunks: {
|
||||||
vue: ['vue'],
|
vue: ['vue'],
|
||||||
|
@ -119,6 +139,15 @@ export function getConfig(): UserConfig {
|
||||||
},
|
},
|
||||||
chunkFileNames: process.env.NODE_ENV === 'production' ? '[hash:8].js' : '[name]-[hash:8].js',
|
chunkFileNames: process.env.NODE_ENV === 'production' ? '[hash:8].js' : '[name]-[hash:8].js',
|
||||||
assetFileNames: process.env.NODE_ENV === 'production' ? '[hash:8][extname]' : '[name]-[hash:8][extname]',
|
assetFileNames: process.env.NODE_ENV === 'production' ? '[hash:8][extname]' : '[name]-[hash:8][extname]',
|
||||||
|
paths(id) {
|
||||||
|
for (const p of externalPackages) {
|
||||||
|
if (p.match.test(id)) {
|
||||||
|
return p.path(id, p.match);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return id;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
cssCodeSplit: true,
|
cssCodeSplit: true,
|
||||||
|
|
|
@ -5,3 +5,4 @@ node_modules
|
||||||
/jest.config.ts
|
/jest.config.ts
|
||||||
/test
|
/test
|
||||||
/test-d
|
/test-d
|
||||||
|
build.js
|
||||||
|
|
|
@ -1,31 +1,105 @@
|
||||||
|
import * as esbuild from "esbuild";
|
||||||
import { build } from "esbuild";
|
import { build } from "esbuild";
|
||||||
import { globSync } from "glob";
|
import { globSync } from "glob";
|
||||||
|
import { execa } from "execa";
|
||||||
|
import fs from "node:fs";
|
||||||
|
import { fileURLToPath } from "node:url";
|
||||||
|
import { dirname } from "node:path";
|
||||||
|
|
||||||
|
const _filename = fileURLToPath(import.meta.url);
|
||||||
|
const _dirname = dirname(_filename);
|
||||||
|
const _package = JSON.parse(fs.readFileSync(_dirname + '/package.json', 'utf-8'));
|
||||||
|
|
||||||
const entryPoints = globSync("./src/**/**.{ts,tsx}");
|
const entryPoints = globSync("./src/**/**.{ts,tsx}");
|
||||||
|
|
||||||
/** @type {import('esbuild').BuildOptions} */
|
/** @type {import('esbuild').BuildOptions} */
|
||||||
const options = {
|
const options = {
|
||||||
entryPoints,
|
entryPoints,
|
||||||
minify: true,
|
minify: process.env.NODE_ENV === 'production',
|
||||||
outdir: "./built/esm",
|
outdir: "./built",
|
||||||
target: "es2022",
|
target: "es2022",
|
||||||
platform: "browser",
|
platform: "browser",
|
||||||
format: "esm",
|
format: "esm",
|
||||||
|
sourcemap: 'linked',
|
||||||
};
|
};
|
||||||
|
|
||||||
if (process.env.WATCH === "true") {
|
// built配下をすべて削除する
|
||||||
options.watch = {
|
fs.rmSync('./built', { recursive: true, force: true });
|
||||||
onRebuild(error, result) {
|
|
||||||
if (error) {
|
if (process.argv.map(arg => arg.toLowerCase()).includes("--watch")) {
|
||||||
console.error("watch build failed:", error);
|
await watchSrc();
|
||||||
} else {
|
} else {
|
||||||
console.log("watch build succeeded:", result);
|
await buildSrc();
|
||||||
}
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
build(options).catch((err) => {
|
async function buildSrc() {
|
||||||
process.stderr.write(err.stderr);
|
console.log(`[${_package.name}] start building...`);
|
||||||
process.exit(1);
|
|
||||||
});
|
await build(options)
|
||||||
|
.then(it => {
|
||||||
|
console.log(`[${_package.name}] build succeeded.`);
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
process.stderr.write(err.stderr);
|
||||||
|
process.exit(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (process.env.NODE_ENV === 'production') {
|
||||||
|
console.log(`[${_package.name}] skip building d.ts because NODE_ENV is production.`);
|
||||||
|
} else {
|
||||||
|
await buildDts();
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`[${_package.name}] finish building.`);
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildDts() {
|
||||||
|
return execa(
|
||||||
|
'tsc',
|
||||||
|
[
|
||||||
|
'--project', 'tsconfig.json',
|
||||||
|
'--outDir', 'built',
|
||||||
|
'--declaration', 'true',
|
||||||
|
'--emitDeclarationOnly', 'true',
|
||||||
|
],
|
||||||
|
{
|
||||||
|
stdout: process.stdout,
|
||||||
|
stderr: process.stderr,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function watchSrc() {
|
||||||
|
const plugins = [{
|
||||||
|
name: 'gen-dts',
|
||||||
|
setup(build) {
|
||||||
|
build.onStart(() => {
|
||||||
|
console.log(`[${_package.name}] detect changed...`);
|
||||||
|
});
|
||||||
|
build.onEnd(async result => {
|
||||||
|
if (result.errors.length > 0) {
|
||||||
|
console.error(`[${_package.name}] watch build failed:`, result);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
await buildDts();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
}];
|
||||||
|
|
||||||
|
console.log(`[${_package.name}] start watching...`)
|
||||||
|
|
||||||
|
const context = await esbuild.context({ ...options, plugins });
|
||||||
|
await context.watch();
|
||||||
|
|
||||||
|
await new Promise((resolve, reject) => {
|
||||||
|
process.on('SIGHUP', resolve);
|
||||||
|
process.on('SIGINT', resolve);
|
||||||
|
process.on('SIGTERM', resolve);
|
||||||
|
process.on('SIGKILL', resolve);
|
||||||
|
process.on('uncaughtException', reject);
|
||||||
|
process.on('exit', resolve);
|
||||||
|
}).finally(async () => {
|
||||||
|
await context.dispose();
|
||||||
|
console.log(`[${_package.name}] finish watching.`);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
|
@ -2,24 +2,21 @@
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"name": "misskey-bubble-game",
|
"name": "misskey-bubble-game",
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"types": "./built/dts/index.d.ts",
|
"main": "./built/index.js",
|
||||||
|
"types": "./built/index.d.ts",
|
||||||
"exports": {
|
"exports": {
|
||||||
".": {
|
".": {
|
||||||
"import": "./built/esm/index.js",
|
"import": "./built/index.js",
|
||||||
"types": "./built/dts/index.d.ts"
|
"types": "./built/index.d.ts"
|
||||||
},
|
},
|
||||||
"./*": {
|
"./*": {
|
||||||
"import": "./built/esm/*",
|
"import": "./built/*",
|
||||||
"types": "./built/dts/*"
|
"types": "./built/*"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "node ./build.js",
|
"build": "node ./build.js",
|
||||||
"build:tsc": "npm run tsc",
|
"watch": "nodemon -w package.json -e json --exec \"node ./build.js --watch\"",
|
||||||
"tsc": "npm run tsc-esm && npm run tsc-dts",
|
|
||||||
"tsc-esm": "tsc --outDir built/esm",
|
|
||||||
"tsc-dts": "tsc --outDir built/dts --declaration true --emitDeclarationOnly true --declarationMap true",
|
|
||||||
"watch": "nodemon -w src -e ts,js,cjs,mjs,json --exec \"pnpm run build:tsc\"",
|
|
||||||
"eslint": "eslint . --ext .js,.jsx,.ts,.tsx",
|
"eslint": "eslint . --ext .js,.jsx,.ts,.tsx",
|
||||||
"typecheck": "tsc --noEmit",
|
"typecheck": "tsc --noEmit",
|
||||||
"lint": "pnpm typecheck && pnpm eslint"
|
"lint": "pnpm typecheck && pnpm eslint"
|
||||||
|
@ -27,21 +24,22 @@
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@misskey-dev/eslint-plugin": "1.0.0",
|
"@misskey-dev/eslint-plugin": "1.0.0",
|
||||||
"@types/matter-js": "0.19.6",
|
"@types/matter-js": "0.19.6",
|
||||||
"@types/node": "20.11.5",
|
|
||||||
"@types/seedrandom": "3.0.8",
|
"@types/seedrandom": "3.0.8",
|
||||||
|
"@types/node": "20.11.5",
|
||||||
"@typescript-eslint/eslint-plugin": "7.1.0",
|
"@typescript-eslint/eslint-plugin": "7.1.0",
|
||||||
"@typescript-eslint/parser": "7.1.0",
|
"@typescript-eslint/parser": "7.1.0",
|
||||||
"eslint": "8.57.0",
|
"eslint": "8.57.0",
|
||||||
"nodemon": "3.0.2",
|
"nodemon": "3.0.2",
|
||||||
"typescript": "5.3.3"
|
"execa": "8.0.1",
|
||||||
|
"typescript": "5.3.3",
|
||||||
|
"esbuild": "0.19.11",
|
||||||
|
"glob": "10.3.10"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"built"
|
"built"
|
||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"esbuild": "0.19.11",
|
|
||||||
"eventemitter3": "5.0.1",
|
"eventemitter3": "5.0.1",
|
||||||
"glob": "^10.3.10",
|
|
||||||
"matter-js": "0.19.0",
|
"matter-js": "0.19.0",
|
||||||
"seedrandom": "3.0.5"
|
"seedrandom": "3.0.5"
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,5 +6,9 @@
|
||||||
import { DropAndFusionGame, Mono } from './game.js';
|
import { DropAndFusionGame, Mono } from './game.js';
|
||||||
|
|
||||||
export {
|
export {
|
||||||
DropAndFusionGame, Mono,
|
DropAndFusionGame,
|
||||||
|
};
|
||||||
|
|
||||||
|
export type {
|
||||||
|
Mono,
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
"moduleResolution": "nodenext",
|
"moduleResolution": "nodenext",
|
||||||
"declaration": true,
|
"declaration": true,
|
||||||
"declarationMap": true,
|
"declarationMap": true,
|
||||||
"sourceMap": true,
|
"sourceMap": false,
|
||||||
"outDir": "./built/",
|
"outDir": "./built/",
|
||||||
"removeComments": true,
|
"removeComments": true,
|
||||||
"strict": true,
|
"strict": true,
|
||||||
|
|
|
@ -5,3 +5,4 @@ node_modules
|
||||||
/jest.config.ts
|
/jest.config.ts
|
||||||
/test
|
/test
|
||||||
/test-d
|
/test-d
|
||||||
|
build.js
|
||||||
|
|
|
@ -45,7 +45,7 @@
|
||||||
*
|
*
|
||||||
* SUPPORTED TOKENS: <projectFolder>, <packageName>, <unscopedPackageName>
|
* SUPPORTED TOKENS: <projectFolder>, <packageName>, <unscopedPackageName>
|
||||||
*/
|
*/
|
||||||
"mainEntryPointFilePath": "<projectFolder>/built/dts/index.d.ts",
|
"mainEntryPointFilePath": "<projectFolder>/built/index.d.ts",
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A list of NPM package names whose exports should be treated as part of this package.
|
* A list of NPM package names whose exports should be treated as part of this package.
|
||||||
|
|
|
@ -0,0 +1,105 @@
|
||||||
|
import * as esbuild from "esbuild";
|
||||||
|
import { build } from "esbuild";
|
||||||
|
import { globSync } from "glob";
|
||||||
|
import { execa } from "execa";
|
||||||
|
import fs from "node:fs";
|
||||||
|
import { fileURLToPath } from "node:url";
|
||||||
|
import { dirname } from "node:path";
|
||||||
|
|
||||||
|
const _filename = fileURLToPath(import.meta.url);
|
||||||
|
const _dirname = dirname(_filename);
|
||||||
|
const _package = JSON.parse(fs.readFileSync(_dirname + '/package.json', 'utf-8'));
|
||||||
|
|
||||||
|
const entryPoints = globSync("./src/**/**.{ts,tsx}");
|
||||||
|
|
||||||
|
/** @type {import('esbuild').BuildOptions} */
|
||||||
|
const options = {
|
||||||
|
entryPoints,
|
||||||
|
minify: process.env.NODE_ENV === 'production',
|
||||||
|
outdir: "./built",
|
||||||
|
target: "es2022",
|
||||||
|
platform: "browser",
|
||||||
|
format: "esm",
|
||||||
|
sourcemap: 'linked',
|
||||||
|
};
|
||||||
|
|
||||||
|
// built配下をすべて削除する
|
||||||
|
fs.rmSync('./built', { recursive: true, force: true });
|
||||||
|
|
||||||
|
if (process.argv.map(arg => arg.toLowerCase()).includes("--watch")) {
|
||||||
|
await watchSrc();
|
||||||
|
} else {
|
||||||
|
await buildSrc();
|
||||||
|
}
|
||||||
|
|
||||||
|
async function buildSrc() {
|
||||||
|
console.log(`[${_package.name}] start building...`);
|
||||||
|
|
||||||
|
await build(options)
|
||||||
|
.then(it => {
|
||||||
|
console.log(`[${_package.name}] build succeeded.`);
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
process.stderr.write(err.stderr);
|
||||||
|
process.exit(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (process.env.NODE_ENV === 'production') {
|
||||||
|
console.log(`[${_package.name}] skip building d.ts because NODE_ENV is production.`);
|
||||||
|
} else {
|
||||||
|
await buildDts();
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`[${_package.name}] finish building.`);
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildDts() {
|
||||||
|
return execa(
|
||||||
|
'tsc',
|
||||||
|
[
|
||||||
|
'--project', 'tsconfig.json',
|
||||||
|
'--outDir', 'built',
|
||||||
|
'--declaration', 'true',
|
||||||
|
'--emitDeclarationOnly', 'true',
|
||||||
|
],
|
||||||
|
{
|
||||||
|
stdout: process.stdout,
|
||||||
|
stderr: process.stderr,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function watchSrc() {
|
||||||
|
const plugins = [{
|
||||||
|
name: 'gen-dts',
|
||||||
|
setup(build) {
|
||||||
|
build.onStart(() => {
|
||||||
|
console.log(`[${_package.name}] detect changed...`);
|
||||||
|
});
|
||||||
|
build.onEnd(async result => {
|
||||||
|
if (result.errors.length > 0) {
|
||||||
|
console.error(`[${_package.name}] watch build failed:`, result);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
await buildDts();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
}];
|
||||||
|
|
||||||
|
console.log(`[${_package.name}] start watching...`)
|
||||||
|
|
||||||
|
const context = await esbuild.context({ ...options, plugins });
|
||||||
|
await context.watch();
|
||||||
|
|
||||||
|
await new Promise((resolve, reject) => {
|
||||||
|
process.on('SIGHUP', resolve);
|
||||||
|
process.on('SIGINT', resolve);
|
||||||
|
process.on('SIGTERM', resolve);
|
||||||
|
process.on('SIGKILL', resolve);
|
||||||
|
process.on('uncaughtException', reject);
|
||||||
|
process.on('exit', resolve);
|
||||||
|
}).finally(async () => {
|
||||||
|
await context.dispose();
|
||||||
|
console.log(`[${_package.name}] finish watching.`);
|
||||||
|
});
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
|
@ -60,13 +60,17 @@ async function generateEndpoints(
|
||||||
// misskey-jsはPOST固定で送っているので、こちらも決め打ちする。別メソッドに対応することがあればこちらも直す必要あり
|
// misskey-jsはPOST固定で送っているので、こちらも決め打ちする。別メソッドに対応することがあればこちらも直す必要あり
|
||||||
const paths = openApiDocs.paths ?? {};
|
const paths = openApiDocs.paths ?? {};
|
||||||
const postPathItems = Object.keys(paths)
|
const postPathItems = Object.keys(paths)
|
||||||
.map(it => paths[it]?.post)
|
.map(it => ({
|
||||||
|
_path_: it.replace(/^\//, ''),
|
||||||
|
...paths[it]?.post,
|
||||||
|
}))
|
||||||
.filter(filterUndefined);
|
.filter(filterUndefined);
|
||||||
|
|
||||||
for (const operation of postPathItems) {
|
for (const operation of postPathItems) {
|
||||||
|
const path = operation._path_;
|
||||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||||
const operationId = operation.operationId!;
|
const operationId = operation.operationId!;
|
||||||
const endpoint = new Endpoint(operationId);
|
const endpoint = new Endpoint(path);
|
||||||
endpoints.push(endpoint);
|
endpoints.push(endpoint);
|
||||||
|
|
||||||
if (isRequestBodyObject(operation.requestBody)) {
|
if (isRequestBodyObject(operation.requestBody)) {
|
||||||
|
@ -76,19 +80,21 @@ async function generateEndpoints(
|
||||||
// いまのところ複数のメディアタイプをとるエンドポイントは無いので決め打ちする
|
// いまのところ複数のメディアタイプをとるエンドポイントは無いので決め打ちする
|
||||||
endpoint.request = new OperationTypeAlias(
|
endpoint.request = new OperationTypeAlias(
|
||||||
operationId,
|
operationId,
|
||||||
|
path,
|
||||||
supportMediaTypes[0],
|
supportMediaTypes[0],
|
||||||
OperationsAliasType.REQUEST,
|
OperationsAliasType.REQUEST,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isResponseObject(operation.responses['200']) && operation.responses['200'].content) {
|
if (operation.responses && isResponseObject(operation.responses['200']) && operation.responses['200'].content) {
|
||||||
const resContent = operation.responses['200'].content;
|
const resContent = operation.responses['200'].content;
|
||||||
const supportMediaTypes = Object.keys(resContent);
|
const supportMediaTypes = Object.keys(resContent);
|
||||||
if (supportMediaTypes.length > 0) {
|
if (supportMediaTypes.length > 0) {
|
||||||
// いまのところ複数のメディアタイプを返すエンドポイントは無いので決め打ちする
|
// いまのところ複数のメディアタイプを返すエンドポイントは無いので決め打ちする
|
||||||
endpoint.response = new OperationTypeAlias(
|
endpoint.response = new OperationTypeAlias(
|
||||||
operationId,
|
operationId,
|
||||||
|
path,
|
||||||
supportMediaTypes[0],
|
supportMediaTypes[0],
|
||||||
OperationsAliasType.RESPONSE,
|
OperationsAliasType.RESPONSE,
|
||||||
);
|
);
|
||||||
|
@ -98,6 +104,8 @@ async function generateEndpoints(
|
||||||
|
|
||||||
const entitiesOutputLine: string[] = [];
|
const entitiesOutputLine: string[] = [];
|
||||||
|
|
||||||
|
entitiesOutputLine.push('/* eslint @typescript-eslint/naming-convention: 0 */');
|
||||||
|
|
||||||
entitiesOutputLine.push(`import { operations } from '${toImportPath(typeFileName)}';`);
|
entitiesOutputLine.push(`import { operations } from '${toImportPath(typeFileName)}';`);
|
||||||
entitiesOutputLine.push('');
|
entitiesOutputLine.push('');
|
||||||
|
|
||||||
|
@ -138,12 +146,19 @@ async function generateApiClientJSDoc(
|
||||||
endpointsFileName: string,
|
endpointsFileName: string,
|
||||||
warningsOutputPath: string,
|
warningsOutputPath: string,
|
||||||
) {
|
) {
|
||||||
const endpoints: { operationId: string; description: string; }[] = [];
|
const endpoints: {
|
||||||
|
operationId: string;
|
||||||
|
path: string;
|
||||||
|
description: string;
|
||||||
|
}[] = [];
|
||||||
|
|
||||||
// misskey-jsはPOST固定で送っているので、こちらも決め打ちする。別メソッドに対応することがあればこちらも直す必要あり
|
// misskey-jsはPOST固定で送っているので、こちらも決め打ちする。別メソッドに対応することがあればこちらも直す必要あり
|
||||||
const paths = openApiDocs.paths ?? {};
|
const paths = openApiDocs.paths ?? {};
|
||||||
const postPathItems = Object.keys(paths)
|
const postPathItems = Object.keys(paths)
|
||||||
.map(it => paths[it]?.post)
|
.map(it => ({
|
||||||
|
_path_: it.replace(/^\//, ''),
|
||||||
|
...paths[it]?.post,
|
||||||
|
}))
|
||||||
.filter(filterUndefined);
|
.filter(filterUndefined);
|
||||||
|
|
||||||
for (const operation of postPathItems) {
|
for (const operation of postPathItems) {
|
||||||
|
@ -153,6 +168,7 @@ async function generateApiClientJSDoc(
|
||||||
if (operation.description) {
|
if (operation.description) {
|
||||||
endpoints.push({
|
endpoints.push({
|
||||||
operationId: operationId,
|
operationId: operationId,
|
||||||
|
path: operation._path_,
|
||||||
description: operation.description,
|
description: operation.description,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -173,7 +189,7 @@ async function generateApiClientJSDoc(
|
||||||
' /**',
|
' /**',
|
||||||
` * ${endpoint.description.split('\n').join('\n * ')}`,
|
` * ${endpoint.description.split('\n').join('\n * ')}`,
|
||||||
' */',
|
' */',
|
||||||
` request<E extends '${endpoint.operationId}', P extends Endpoints[E][\'req\']>(`,
|
` request<E extends '${endpoint.path}', P extends Endpoints[E][\'req\']>(`,
|
||||||
' endpoint: E,',
|
' endpoint: E,',
|
||||||
' params: P,',
|
' params: P,',
|
||||||
' credential?: string | null,',
|
' credential?: string | null,',
|
||||||
|
@ -232,21 +248,24 @@ interface IOperationTypeAlias {
|
||||||
|
|
||||||
class OperationTypeAlias implements IOperationTypeAlias {
|
class OperationTypeAlias implements IOperationTypeAlias {
|
||||||
public readonly operationId: string;
|
public readonly operationId: string;
|
||||||
|
public readonly path: string;
|
||||||
public readonly mediaType: string;
|
public readonly mediaType: string;
|
||||||
public readonly type: OperationsAliasType;
|
public readonly type: OperationsAliasType;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
operationId: string,
|
operationId: string,
|
||||||
|
path: string,
|
||||||
mediaType: string,
|
mediaType: string,
|
||||||
type: OperationsAliasType,
|
type: OperationsAliasType,
|
||||||
) {
|
) {
|
||||||
this.operationId = operationId;
|
this.operationId = operationId;
|
||||||
|
this.path = path;
|
||||||
this.mediaType = mediaType;
|
this.mediaType = mediaType;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
generateName(): string {
|
generateName(): string {
|
||||||
const nameBase = this.operationId.replace(/\//g, '-');
|
const nameBase = this.path.replace(/\//g, '-');
|
||||||
return toPascal(nameBase + this.type);
|
return toPascal(nameBase + this.type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -279,19 +298,19 @@ const emptyRequest = new EmptyTypeAlias(OperationsAliasType.REQUEST);
|
||||||
const emptyResponse = new EmptyTypeAlias(OperationsAliasType.RESPONSE);
|
const emptyResponse = new EmptyTypeAlias(OperationsAliasType.RESPONSE);
|
||||||
|
|
||||||
class Endpoint {
|
class Endpoint {
|
||||||
public readonly operationId: string;
|
public readonly path: string;
|
||||||
public request?: IOperationTypeAlias;
|
public request?: IOperationTypeAlias;
|
||||||
public response?: IOperationTypeAlias;
|
public response?: IOperationTypeAlias;
|
||||||
|
|
||||||
constructor(operationId: string) {
|
constructor(path: string) {
|
||||||
this.operationId = operationId;
|
this.path = path;
|
||||||
}
|
}
|
||||||
|
|
||||||
toLine(): string {
|
toLine(): string {
|
||||||
const reqName = this.request?.generateName() ?? emptyRequest.generateName();
|
const reqName = this.request?.generateName() ?? emptyRequest.generateName();
|
||||||
const resName = this.response?.generateName() ?? emptyResponse.generateName();
|
const resName = this.response?.generateName() ?? emptyResponse.generateName();
|
||||||
|
|
||||||
return `'${this.operationId}': { req: ${reqName}; res: ${resName} };`;
|
return `'${this.path}': { req: ${reqName}; res: ${resName} };`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,23 +3,21 @@
|
||||||
"name": "misskey-js",
|
"name": "misskey-js",
|
||||||
"version": "2024.3.1",
|
"version": "2024.3.1",
|
||||||
"description": "Misskey SDK for JavaScript",
|
"description": "Misskey SDK for JavaScript",
|
||||||
"types": "./built/dts/index.d.ts",
|
"main": "./built/index.js",
|
||||||
|
"types": "./built/index.d.ts",
|
||||||
"exports": {
|
"exports": {
|
||||||
".": {
|
".": {
|
||||||
"import": "./built/esm/index.js",
|
"import": "./built/index.js",
|
||||||
"types": "./built/dts/index.d.ts"
|
"types": "./built/index.d.ts"
|
||||||
},
|
},
|
||||||
"./*": {
|
"./*": {
|
||||||
"import": "./built/esm/*",
|
"import": "./built/*",
|
||||||
"types": "./built/dts/*"
|
"types": "./built/*"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "npm run ts",
|
"build": "node ./build.js",
|
||||||
"ts": "npm run ts-esm && npm run ts-dts",
|
"watch": "nodemon -w package.json -e json --exec \"node ./build.js --watch\"",
|
||||||
"ts-esm": "tsc --outDir built/esm",
|
|
||||||
"ts-dts": "tsc --outDir built/dts --declaration true --emitDeclarationOnly true --declarationMap true",
|
|
||||||
"watch": "nodemon -w src -e ts,js,cjs,mjs,json --exec \"pnpm run ts\"",
|
|
||||||
"tsd": "tsd",
|
"tsd": "tsd",
|
||||||
"api": "pnpm api-extractor run --local --verbose",
|
"api": "pnpm api-extractor run --local --verbose",
|
||||||
"api-prod": "pnpm api-extractor run --verbose",
|
"api-prod": "pnpm api-extractor run --verbose",
|
||||||
|
@ -49,17 +47,16 @@
|
||||||
"mock-socket": "9.3.1",
|
"mock-socket": "9.3.1",
|
||||||
"ncp": "2.0.0",
|
"ncp": "2.0.0",
|
||||||
"nodemon": "3.1.0",
|
"nodemon": "3.1.0",
|
||||||
|
"execa": "8.0.1",
|
||||||
"tsd": "0.30.7",
|
"tsd": "0.30.7",
|
||||||
"typescript": "5.3.3"
|
"typescript": "5.3.3",
|
||||||
|
"esbuild": "0.19.11",
|
||||||
|
"glob": "10.3.10"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"built",
|
"built"
|
||||||
"built/esm",
|
|
||||||
"built/dts"
|
|
||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@swc/cli": "0.1.63",
|
|
||||||
"@swc/core": "1.3.105",
|
|
||||||
"eventemitter3": "5.0.1",
|
"eventemitter3": "5.0.1",
|
||||||
"reconnecting-websocket": "4.4.0"
|
"reconnecting-websocket": "4.4.0"
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ import './autogen/apiClientJSDoc.js';
|
||||||
import { SwitchCaseResponseType } from './api.types.js';
|
import { SwitchCaseResponseType } from './api.types.js';
|
||||||
import type { Endpoints } from './api.types.js';
|
import type { Endpoints } from './api.types.js';
|
||||||
|
|
||||||
export {
|
export type {
|
||||||
SwitchCaseResponseType,
|
SwitchCaseResponseType,
|
||||||
} from './api.types.js';
|
} from './api.types.js';
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -1,17 +1,20 @@
|
||||||
import { Endpoints } from './api.types.js';
|
import { type Endpoints } from './api.types.js';
|
||||||
import Stream, { Connection } from './streaming.js';
|
import Stream, { Connection } from './streaming.js';
|
||||||
import { Channels } from './streaming.types.js';
|
import { type Channels } from './streaming.types.js';
|
||||||
import { Acct } from './acct.js';
|
import { type Acct } from './acct.js';
|
||||||
import * as consts from './consts.js';
|
import * as consts from './consts.js';
|
||||||
|
|
||||||
export {
|
export type {
|
||||||
Endpoints,
|
Endpoints,
|
||||||
Stream,
|
|
||||||
Connection as ChannelConnection,
|
|
||||||
Channels,
|
Channels,
|
||||||
Acct,
|
Acct,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export {
|
||||||
|
Stream,
|
||||||
|
Connection as ChannelConnection,
|
||||||
|
};
|
||||||
|
|
||||||
export const permissions = consts.permissions;
|
export const permissions = consts.permissions;
|
||||||
export const notificationTypes = consts.notificationTypes;
|
export const notificationTypes = consts.notificationTypes;
|
||||||
export const noteVisibilities = consts.noteVisibilities;
|
export const noteVisibilities = consts.noteVisibilities;
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
"moduleResolution": "nodenext",
|
"moduleResolution": "nodenext",
|
||||||
"declaration": true,
|
"declaration": true,
|
||||||
"declarationMap": true,
|
"declarationMap": true,
|
||||||
"sourceMap": true,
|
"sourceMap": false,
|
||||||
"outDir": "./built/",
|
"outDir": "./built/",
|
||||||
"removeComments": true,
|
"removeComments": true,
|
||||||
"strict": true,
|
"strict": true,
|
||||||
|
|
|
@ -5,3 +5,4 @@ node_modules
|
||||||
/jest.config.ts
|
/jest.config.ts
|
||||||
/test
|
/test
|
||||||
/test-d
|
/test-d
|
||||||
|
build.js
|
||||||
|
|
|
@ -1,31 +1,105 @@
|
||||||
|
import * as esbuild from "esbuild";
|
||||||
import { build } from "esbuild";
|
import { build } from "esbuild";
|
||||||
import { globSync } from "glob";
|
import { globSync } from "glob";
|
||||||
|
import { execa } from "execa";
|
||||||
|
import fs from "node:fs";
|
||||||
|
import { fileURLToPath } from "node:url";
|
||||||
|
import { dirname } from "node:path";
|
||||||
|
|
||||||
|
const _filename = fileURLToPath(import.meta.url);
|
||||||
|
const _dirname = dirname(_filename);
|
||||||
|
const _package = JSON.parse(fs.readFileSync(_dirname + '/package.json', 'utf-8'));
|
||||||
|
|
||||||
const entryPoints = globSync("./src/**/**.{ts,tsx}");
|
const entryPoints = globSync("./src/**/**.{ts,tsx}");
|
||||||
|
|
||||||
/** @type {import('esbuild').BuildOptions} */
|
/** @type {import('esbuild').BuildOptions} */
|
||||||
const options = {
|
const options = {
|
||||||
entryPoints,
|
entryPoints,
|
||||||
minify: true,
|
minify: process.env.NODE_ENV === 'production',
|
||||||
outdir: "./built/esm",
|
outdir: "./built",
|
||||||
target: "es2022",
|
target: "es2022",
|
||||||
platform: "browser",
|
platform: "browser",
|
||||||
format: "esm",
|
format: "esm",
|
||||||
|
sourcemap: 'linked',
|
||||||
};
|
};
|
||||||
|
|
||||||
if (process.env.WATCH === "true") {
|
// built配下をすべて削除する
|
||||||
options.watch = {
|
fs.rmSync('./built', { recursive: true, force: true });
|
||||||
onRebuild(error, result) {
|
|
||||||
if (error) {
|
if (process.argv.map(arg => arg.toLowerCase()).includes("--watch")) {
|
||||||
console.error("watch build failed:", error);
|
await watchSrc();
|
||||||
} else {
|
} else {
|
||||||
console.log("watch build succeeded:", result);
|
await buildSrc();
|
||||||
}
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
build(options).catch((err) => {
|
async function buildSrc() {
|
||||||
process.stderr.write(err.stderr);
|
console.log(`[${_package.name}] start building...`);
|
||||||
process.exit(1);
|
|
||||||
});
|
await build(options)
|
||||||
|
.then(it => {
|
||||||
|
console.log(`[${_package.name}] build succeeded.`);
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
process.stderr.write(err.stderr);
|
||||||
|
process.exit(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (process.env.NODE_ENV === 'production') {
|
||||||
|
console.log(`[${_package.name}] skip building d.ts because NODE_ENV is production.`);
|
||||||
|
} else {
|
||||||
|
await buildDts();
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`[${_package.name}] finish building.`);
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildDts() {
|
||||||
|
return execa(
|
||||||
|
'tsc',
|
||||||
|
[
|
||||||
|
'--project', 'tsconfig.json',
|
||||||
|
'--outDir', 'built',
|
||||||
|
'--declaration', 'true',
|
||||||
|
'--emitDeclarationOnly', 'true',
|
||||||
|
],
|
||||||
|
{
|
||||||
|
stdout: process.stdout,
|
||||||
|
stderr: process.stderr,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function watchSrc() {
|
||||||
|
const plugins = [{
|
||||||
|
name: 'gen-dts',
|
||||||
|
setup(build) {
|
||||||
|
build.onStart(() => {
|
||||||
|
console.log(`[${_package.name}] detect changed...`);
|
||||||
|
});
|
||||||
|
build.onEnd(async result => {
|
||||||
|
if (result.errors.length > 0) {
|
||||||
|
console.error(`[${_package.name}] watch build failed:`, result);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
await buildDts();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
}];
|
||||||
|
|
||||||
|
console.log(`[${_package.name}] start watching...`)
|
||||||
|
|
||||||
|
const context = await esbuild.context({ ...options, plugins });
|
||||||
|
await context.watch();
|
||||||
|
|
||||||
|
await new Promise((resolve, reject) => {
|
||||||
|
process.on('SIGHUP', resolve);
|
||||||
|
process.on('SIGINT', resolve);
|
||||||
|
process.on('SIGTERM', resolve);
|
||||||
|
process.on('SIGKILL', resolve);
|
||||||
|
process.on('uncaughtException', reject);
|
||||||
|
process.on('exit', resolve);
|
||||||
|
}).finally(async () => {
|
||||||
|
await context.dispose();
|
||||||
|
console.log(`[${_package.name}] finish watching.`);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue