Skip to content

Commit

Permalink
Merge remote-branch 'misskey/develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
noridev committed Dec 14, 2023
2 parents fda2c88 + 4178527 commit 8f65b96
Show file tree
Hide file tree
Showing 34 changed files with 236 additions and 103 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
- Feat: モデレーターがユーザーのアイコンもしくはバナー画像を未設定状態にできる機能を追加 (cherry-pick from https://github.com/TeamNijimiss/misskey/commit/e0eb5a752f6e5616d6312bb7c9790302f9dbff83)
- Feat: TL上からノートが見えなくなるワードミュートであるハードミュートを追加
- Enhance: アイコンデコレーションを複数設定できるように
- Enhance: アイコンデコレーションの位置を微調整できるように
- Fix: MFM `$[unixtime ]` に不正な値を入力した際に発生する各種エラーを修正

### Client
Expand Down
2 changes: 0 additions & 2 deletions locales/en-US.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
---
_lang_: "English"
cannotBeUsedFunc: "This feature is currently unavailable."
Xcoordinate: "X-Coordinate"
Ycoordinate: "Y-Coordinate"
scale: "Scale"
opacity: "Opacity"
noteUpdatedAt: "Edited: {date} {time}"
Expand Down
2 changes: 0 additions & 2 deletions locales/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
export interface Locale {
"_lang_": string;
"cannotBeUsedFunc": string;
"Xcoordinate": string;
"Ycoordinate": string;
"scale": string;
"opacity": string;
"noteUpdatedAt": string;
Expand Down
2 changes: 0 additions & 2 deletions locales/ja-JP.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
_lang_: "日本語"

cannotBeUsedFunc: "この機能は現在使用できません。"
Xcoordinate: "X座標"
Ycoordinate: "Y座標"
scale: "大きさ"
opacity: "不透明度"
noteUpdatedAt: "編集済み: {date} {time}"
Expand Down
2 changes: 0 additions & 2 deletions locales/ko-KR.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
---
_lang_: "한국어"
cannotBeUsedFunc: "이 기능은 현재 사용할 수 없어요."
Xcoordinate: "X 좌표"
Ycoordinate: "Y 좌표"
scale: "크기"
opacity: "불투명도"
noteUpdatedAt: "편집됨: {date} {time}"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"migrateandstart": "pnpm migrate && pnpm start",
"migrateandstart:docker": "pnpm migrate && exec pnpm start:docker",
"watch": "pnpm dev",
"dev": "pnpm -r dev",
"dev": "node scripts/dev.mjs",
"lint": "pnpm -r lint",
"cy:open": "pnpm cypress open --browser --e2e --config-file=cypress.config.ts",
"cy:run": "pnpm cypress run",
Expand Down
4 changes: 3 additions & 1 deletion packages/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"watch:swc": "swc src -d built -D -w",
"build:tsc": "tsc -p tsconfig.json && tsc-alias -p tsconfig.json",
"watch": "node watch.mjs",
"dev": "node ./built/boot/entry.js",
"restart": "pnpm build && pnpm start",
"dev": "nodemon -w src -e ts,js,mjs,cjs,json --exec \"cross-env NODE_ENV=development pnpm run restart\"",
"typecheck": "tsc --noEmit",
"eslint": "eslint --quiet \"src/**/*.ts\"",
"lint": "pnpm typecheck && pnpm eslint",
Expand Down Expand Up @@ -231,6 +232,7 @@
"execa": "8.0.1",
"jest": "29.7.0",
"jest-mock": "29.7.0",
"nodemon": "3.0.2",
"simple-oauth2": "5.0.0"
}
}
4 changes: 2 additions & 2 deletions packages/backend/src/core/AvatarDecorationService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,9 @@ export class AvatarDecorationService implements OnApplicationShutdown {
id: findDecoration?.id ?? '',
angle: avatarDecorations.angle ?? 0,
flipH: avatarDecorations.flipH ?? false,
offsetX: avatarDecorations.offsetX ?? 0,
offsetY: avatarDecorations.offsetY ?? 0,
scale: avatarDecorations.scale ?? 1,
moveX: avatarDecorations.moveX ?? 0,
moveY: avatarDecorations.moveY ?? 0,
opacity: avatarDecorations.opacity ?? 1,
}];
await this.usersRepository.update({ id: user.id }, updates);
Expand Down
4 changes: 2 additions & 2 deletions packages/backend/src/core/entities/UserEntityService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -398,9 +398,9 @@ export class UserEntityService implements OnModuleInit {
id: ud.id,
angle: ud.angle || undefined,
flipH: ud.flipH || undefined,
offsetX: ud.offsetX || undefined,
offsetY: ud.offsetY || undefined,
scale: ud.scale || undefined,
moveX: ud.moveX || undefined,
moveY: ud.moveY || undefined,
opacity: ud.opacity || undefined,
url: decorations.find(d => d.id === ud.id)!.url,
}))) : [],
Expand Down
12 changes: 6 additions & 6 deletions packages/backend/src/models/User.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,12 @@ export class MiUser {
})
public avatarDecorations: {
id: string;
angle: number;
flipH: boolean;
scale: number;
moveX: number;
moveY: number;
opacity: number;
angle?: number;
flipH?: boolean;
offsetX?: number;
offsetY?: number;
scale?: number;
opacity?: number;
}[];

@Index()
Expand Down
6 changes: 3 additions & 3 deletions packages/backend/src/models/json-schema/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,15 @@ export const packedUserLiteSchema = {
type: 'boolean',
nullable: false, optional: true,
},
scale: {
offsetX: {
type: 'number',
nullable: false, optional: true,
},
moveX: {
offsetY: {
type: 'number',
nullable: false, optional: true,
},
moveY: {
scale: {
type: 'number',
nullable: false, optional: true,
},
Expand Down
8 changes: 4 additions & 4 deletions packages/backend/src/server/api/endpoints/i/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,9 @@ export const paramDef = {
id: { type: 'string', format: 'misskey:id' },
angle: { type: 'number', nullable: true, maximum: 0.5, minimum: -0.5 },
flipH: { type: 'boolean', nullable: true },
offsetX: { type: 'number', nullable: true, maximum: 0.25, minimum: -0.25 },
offsetY: { type: 'number', nullable: true, maximum: 0.25, minimum: -0.25 },
scale: { type: 'number', nullable: true, maximum: 1.5, minimum: 0.5 },
moveX: { type: 'number', nullable: true, maximum: 25, minimum: -25 },
moveY: { type: 'number', nullable: true, maximum: 25, minimum: -25 },
opacity: { type: 'number', nullable: true, maximum: 1, minimum: 0.1 },
},
required: ['id'],
Expand Down Expand Up @@ -345,9 +345,9 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
id: d.id,
angle: d.angle ?? 0,
flipH: d.flipH ?? false,
offsetX: d.offsetX ?? 0,
offsetY: d.offsetY ?? 0,
scale: d.scale ?? 1,
moveX: d.moveX ?? 0,
moveY: d.moveY ?? 0,
opacity: d.opacity ?? 1,
}));
}
Expand Down
6 changes: 4 additions & 2 deletions packages/cherrypick-js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"types": "./built/index.d.ts",
"scripts": {
"build": "tsc",
"watch": "nodemon -w src -e ts,js,cjs,mjs,json --exec \"pnpm run build\"",
"tsd": "tsd",
"api": "pnpm api-extractor run --local --verbose",
"api-prod": "pnpm api-extractor run --verbose",
Expand All @@ -32,9 +33,10 @@
"jest-fetch-mock": "3.0.3",
"jest-websocket-mock": "2.5.0",
"mock-socket": "9.3.1",
"ncp": "2.0.0",
"nodemon": "3.0.2",
"tsd": "0.29.0",
"typescript": "5.3.3",
"ncp": "2.0.0"
"typescript": "5.3.3"
},
"files": [
"built"
Expand Down
2 changes: 1 addition & 1 deletion packages/cherrypick-js/src/autogen/apiClientJSDoc.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* version: 4.6.0-beta.4
* basedMisskeyVersion: 2023.12.0-beta.4
* generatedAt: 2023-12-14T16:00:54.542Z
* generatedAt: 2023-12-14T17:47:05.660Z
*/

import type { SwitchCaseResponseType } from '../api.js';
Expand Down
2 changes: 1 addition & 1 deletion packages/cherrypick-js/src/autogen/endpoint.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* version: 4.6.0-beta.4
* basedMisskeyVersion: 2023.12.0-beta.4
* generatedAt: 2023-12-14T16:00:54.540Z
* generatedAt: 2023-12-14T17:47:05.658Z
*/

import type {
Expand Down
2 changes: 1 addition & 1 deletion packages/cherrypick-js/src/autogen/entities.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* version: 4.6.0-beta.4
* basedMisskeyVersion: 2023.12.0-beta.4
* generatedAt: 2023-12-14T16:00:54.539Z
* generatedAt: 2023-12-14T17:47:05.657Z
*/

import { operations } from './types.js';
Expand Down
2 changes: 1 addition & 1 deletion packages/cherrypick-js/src/autogen/models.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* version: 4.6.0-beta.4
* basedMisskeyVersion: 2023.12.0-beta.4
* generatedAt: 2023-12-14T16:00:54.537Z
* generatedAt: 2023-12-14T17:47:05.656Z
*/

import { components } from './types.js';
Expand Down
10 changes: 5 additions & 5 deletions packages/cherrypick-js/src/autogen/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/*
* version: 4.6.0-beta.4
* basedMisskeyVersion: 2023.12.0-beta.4
* generatedAt: 2023-12-14T16:00:54.457Z
* generatedAt: 2023-12-14T17:47:05.577Z
*/

/**
Expand Down Expand Up @@ -3757,9 +3757,9 @@ export type components = {
id: string;
angle?: number;
flipH?: boolean;
offsetX?: number;
offsetY?: number;
scale?: number;
moveX?: number;
moveY?: number;
opacity?: number;
/** Format: url */
url: string;
Expand Down Expand Up @@ -18674,9 +18674,9 @@ export type operations = {
id: string;
angle?: number | null;
flipH?: boolean | null;
offsetX?: number | null;
offsetY?: number | null;
scale?: number | null;
moveX?: number | null;
moveY?: number | null;
opacity?: number | null;
})[];
/** Format: misskey:id */
Expand Down
3 changes: 3 additions & 0 deletions packages/frontend/@types/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ declare const _PERF_PREFIX_: string;
declare const _DATA_TRANSFER_DRIVE_FILE_: string;
declare const _DATA_TRANSFER_DRIVE_FOLDER_: string;
declare const _DATA_TRANSFER_DECK_COLUMN_: string;

// for dev-mode
declare const _LANGS_FULL_: string[][];
84 changes: 84 additions & 0 deletions packages/frontend/src/_dev_boot_.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,88 @@
// (pnpm start時はpugファイルの中で静的リソースとして読み込むようになっており、この問題は起こっていない)
import '@tabler/icons-webfont/tabler-icons.scss';

await main();

import('@/_boot_.js');

/**
* backend/src/server/web/boot.jsで差し込まれている起動処理のうち、最低限必要なものを模倣するための処理
*/
async function main() {
const forceError = localStorage.getItem('forceError');
if (forceError != null) {
renderError('FORCED_ERROR', 'This error is forced by having forceError in local storage.');
}

//#region Detect language & fetch translations

// dev-modeの場合は常に取り直す
const supportedLangs = _LANGS_.map(it => it[0]);
let lang: string | null | undefined = localStorage.getItem('lang');
if (lang == null || !supportedLangs.includes(lang)) {
if (supportedLangs.includes(navigator.language)) {
lang = navigator.language;
} else {
lang = supportedLangs.find(x => x.split('-')[0] === navigator.language);

// Fallback
if (lang == null) lang = 'en-US';
}
}

// TODO:今のままだと言語ファイル変更後はpnpm devをリスタートする必要があるので、chokidarを使ったり等で対応できるようにする
const locale = _LANGS_FULL_.find(it => it[0] === lang);
localStorage.setItem('lang', lang);
localStorage.setItem('locale', JSON.stringify(locale[1]));
localStorage.setItem('localeVersion', _VERSION_);
//#endregion

//#region Theme
const theme = localStorage.getItem('theme');
if (theme) {
for (const [k, v] of Object.entries(JSON.parse(theme))) {
document.documentElement.style.setProperty(`--${k}`, v.toString());

// HTMLの theme-color 適用
if (k === 'htmlThemeColor') {
for (const tag of document.head.children) {
if (tag.tagName === 'META' && tag.getAttribute('name') === 'theme-color') {
tag.setAttribute('content', v);
break;
}
}
}
}
}
const colorScheme = localStorage.getItem('colorScheme');
if (colorScheme) {
document.documentElement.style.setProperty('color-scheme', colorScheme);
}
//#endregion

const fontSize = localStorage.getItem('fontSize');
if (fontSize) {
document.documentElement.classList.add('f-' + fontSize);
}

const useSystemFont = localStorage.getItem('useSystemFont');
if (useSystemFont) {
document.documentElement.classList.add('useSystemFont');
}

const wallpaper = localStorage.getItem('wallpaper');
if (wallpaper) {
document.documentElement.style.backgroundImage = `url(${wallpaper})`;
}

const customCss = localStorage.getItem('customCss');
if (customCss && customCss.length > 0) {
const style = document.createElement('style');
style.innerHTML = customCss;
document.head.appendChild(style);
}
}

function renderError(code: string, details?: string) {
console.log(code, details);
}
4 changes: 2 additions & 2 deletions packages/frontend/src/boot/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { compareVersions } from 'compare-versions';
import widgets from '@/widgets/index.js';
import directives from '@/directives/index.js';
import components from '@/components/index.js';
import { version, basedMisskeyVersion, ui, lang, updateLocale } from '@/config.js';
import { version, basedMisskeyVersion, ui, lang, updateLocale, locale } from '@/config.js';
import { applyTheme } from '@/scripts/theme.js';
import { isDeviceDarkmode } from '@/scripts/is-device-darkmode.js';
import { i18n, updateI18n } from '@/i18n.js';
Expand Down Expand Up @@ -101,7 +101,7 @@ export async function common(createVue: () => App<Element>) {

//#region Detect language & fetch translations
const localeVersion = miLocalStorage.getItem('localeVersion');
const localeOutdated = (localeVersion == null || localeVersion !== version || lastBasedMisskeyVersion !== basedMisskeyVersion);
const localeOutdated = (localeVersion == null || localeVersion !== version || lastBasedMisskeyVersion !== basedMisskeyVersion || locale == null);
if (localeOutdated) {
const res = await window.fetch(`/assets/locales/${lang}.${version}.json`);
if (res.status === 200) {
Expand Down
11 changes: 8 additions & 3 deletions packages/frontend/src/components/global/CPAvatar-Friendly.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ SPDX-License-Identifier: AGPL-3.0-only
:style="{
rotate: getDecorationAngle(decoration),
scale: getDecorationScale(decoration),
translate: getDecorationOffset(decoration),
transform: getDecorationTransform(decoration),
opacity: getDecorationOpacity(decoration),
}"
Expand Down Expand Up @@ -91,11 +92,15 @@ function getDecorationScale(decoration: Omit<Misskey.entities.UserDetailed['avat
return scaleX === 1 ? undefined : `${scaleX} 1`;
}

function getDecorationOffset(decoration: Omit<Misskey.entities.UserDetailed['avatarDecorations'][number], 'id'>) {
const offsetX = decoration.offsetX ?? 0;
const offsetY = decoration.offsetY ?? 0;
return offsetX === 0 && offsetY === 0 ? undefined : `${offsetX * 100}% ${offsetY * 100}%`;
}

function getDecorationTransform(decoration: Omit<Misskey.entities.UserDetailed['avatarDecorations'][number], 'id'>) {
const scale = decoration.scale ?? 1;
const moveX = decoration.moveX ?? 0;
const moveY = decoration.moveY ?? 0;
return `${scale === 1 ? '' : `scale(${scale})`} ${moveX === 0 && moveY === 0 ? '' : `translate(${moveX}%, ${moveY}%)`}`;
return `${scale === 1 ? '' : `scale(${scale})`}`;
}

function getDecorationOpacity(decoration: Omit<Misskey.entities.UserDetailed['avatarDecorations'][number], 'id'>) {
Expand Down
Loading

0 comments on commit 8f65b96

Please sign in to comment.