From 833c901a9ca90a48f438c3986861608db1223cf9 Mon Sep 17 00:00:00 2001 From: ThatOneCalculator Date: Fri, 23 Jun 2023 21:22:44 -0700 Subject: [PATCH] chore: :art: format --- cypress.config.ts | 20 +-- cypress/e2e/basic.cy.js | 126 +++++++++--------- cypress/e2e/widgets.cy.js | 78 +++++------ cypress/plugins/index.js | 6 +- cypress/support/commands.js | 34 ++--- cypress/support/e2e.js | 18 +-- .../src/server/api/endpoints/notes/edit.ts | 2 +- packages/backend/src/services/note/create.ts | 20 +-- packages/calckey-js/package.json | 2 +- packages/client/src/components/mfm.ts | 2 +- packages/client/src/directives/tooltip.ts | 1 - packages/client/src/os.ts | 96 +++++++------ packages/client/src/scripts/emojilist.ts | 85 +++++++----- packages/client/src/scripts/get-note-menu.ts | 65 ++++----- packages/client/src/scripts/get-user-menu.ts | 4 +- packages/client/src/store.ts | 2 +- scripts/build-greet.js | 12 +- scripts/clean-all.js | 75 +++++++---- scripts/clean.js | 26 +++- scripts/dev.js | 28 ++-- 20 files changed, 381 insertions(+), 321 deletions(-) diff --git a/cypress.config.ts b/cypress.config.ts index e390c41a5..25ff2aa07 100644 --- a/cypress.config.ts +++ b/cypress.config.ts @@ -1,12 +1,12 @@ -import { defineConfig } from 'cypress' +import { defineConfig } from "cypress"; export default defineConfig({ - e2e: { - // We've imported your old cypress plugins here. - // You may want to clean this up later by importing these. - setupNodeEvents(on, config) { - return require('./cypress/plugins/index.js')(on, config) - }, - baseUrl: 'http://localhost:61812', - }, -}) + e2e: { + // We've imported your old cypress plugins here. + // You may want to clean this up later by importing these. + setupNodeEvents(on, config) { + return require("./cypress/plugins/index.js")(on, config); + }, + baseUrl: "http://localhost:61812", + }, +}); diff --git a/cypress/e2e/basic.cy.js b/cypress/e2e/basic.cy.js index eb5195c4b..f73a25efb 100644 --- a/cypress/e2e/basic.cy.js +++ b/cypress/e2e/basic.cy.js @@ -1,4 +1,4 @@ -describe('Before setup instance', () => { +describe("Before setup instance", () => { beforeEach(() => { cy.resetState(); }); @@ -9,31 +9,31 @@ describe('Before setup instance', () => { cy.wait(1000); }); - it('successfully loads', () => { - cy.visit('/'); - }); + it("successfully loads", () => { + cy.visit("/"); + }); - it('setup instance', () => { - cy.visit('/'); + it("setup instance", () => { + cy.visit("/"); - cy.intercept('POST', '/api/admin/accounts/create').as('signup'); - - cy.get('[data-cy-admin-username] input').type('admin'); - cy.get('[data-cy-admin-password] input').type('admin1234'); - cy.get('[data-cy-admin-ok]').click(); + cy.intercept("POST", "/api/admin/accounts/create").as("signup"); + + cy.get("[data-cy-admin-username] input").type("admin"); + cy.get("[data-cy-admin-password] input").type("admin1234"); + cy.get("[data-cy-admin-ok]").click(); // なぜか動かない //cy.wait('@signup').should('have.property', 'response.statusCode'); - cy.wait('@signup'); - }); + cy.wait("@signup"); + }); }); -describe('After setup instance', () => { +describe("After setup instance", () => { beforeEach(() => { cy.resetState(); // インスタンス初期セットアップ - cy.registerUser('admin', 'pass', true); + cy.registerUser("admin", "pass", true); }); afterEach(() => { @@ -42,34 +42,34 @@ describe('After setup instance', () => { cy.wait(1000); }); - it('successfully loads', () => { - cy.visit('/'); - }); + it("successfully loads", () => { + cy.visit("/"); + }); - it('signup', () => { - cy.visit('/'); + it("signup", () => { + cy.visit("/"); - cy.intercept('POST', '/api/signup').as('signup'); + cy.intercept("POST", "/api/signup").as("signup"); - cy.get('[data-cy-signup]').click(); - cy.get('[data-cy-signup-username] input').type('alice'); - cy.get('[data-cy-signup-password] input').type('alice1234'); - cy.get('[data-cy-signup-password-retype] input').type('alice1234'); - cy.get('[data-cy-signup-submit]').click(); + cy.get("[data-cy-signup]").click(); + cy.get("[data-cy-signup-username] input").type("alice"); + cy.get("[data-cy-signup-password] input").type("alice1234"); + cy.get("[data-cy-signup-password-retype] input").type("alice1234"); + cy.get("[data-cy-signup-submit]").click(); - cy.wait('@signup'); - }); + cy.wait("@signup"); + }); }); -describe('After user signup', () => { +describe("After user signup", () => { beforeEach(() => { cy.resetState(); // インスタンス初期セットアップ - cy.registerUser('admin', 'pass', true); + cy.registerUser("admin", "pass", true); // ユーザー作成 - cy.registerUser('alice', 'alice1234'); + cy.registerUser("alice", "alice1234"); }); afterEach(() => { @@ -78,51 +78,53 @@ describe('After user signup', () => { cy.wait(1000); }); - it('successfully loads', () => { - cy.visit('/'); - }); + it("successfully loads", () => { + cy.visit("/"); + }); - it('signin', () => { - cy.visit('/'); + it("signin", () => { + cy.visit("/"); - cy.intercept('POST', '/api/signin').as('signin'); + cy.intercept("POST", "/api/signin").as("signin"); - cy.get('[data-cy-signin]').click(); - cy.get('[data-cy-signin-username] input').type('alice'); + cy.get("[data-cy-signin]").click(); + cy.get("[data-cy-signin-username] input").type("alice"); // Enterキーでサインインできるかの確認も兼ねる - cy.get('[data-cy-signin-password] input').type('alice1234{enter}'); + cy.get("[data-cy-signin-password] input").type("alice1234{enter}"); - cy.wait('@signin'); - }); + cy.wait("@signin"); + }); - it('suspend', function() { - cy.request('POST', '/api/admin/suspend-user', { + it("suspend", function () { + cy.request("POST", "/api/admin/suspend-user", { i: this.admin.token, userId: this.alice.id, }); - cy.visit('/'); + cy.visit("/"); - cy.get('[data-cy-signin]').click(); - cy.get('[data-cy-signin-username] input').type('alice'); - cy.get('[data-cy-signin-password] input').type('alice1234{enter}'); + cy.get("[data-cy-signin]").click(); + cy.get("[data-cy-signin-username] input").type("alice"); + cy.get("[data-cy-signin-password] input").type("alice1234{enter}"); // TODO: cypressにブラウザの言語指定できる機能が実装され次第英語のみテストするようにする - cy.contains(/アカウントが凍結されています|This account has been suspended due to/gi); + cy.contains( + /アカウントが凍結されています|This account has been suspended due to/gi, + ); }); }); -describe('After user singed in', () => { +describe("After user singed in", () => { beforeEach(() => { cy.resetState(); // インスタンス初期セットアップ - cy.registerUser('admin', 'pass', true); + cy.registerUser("admin", "pass", true); // ユーザー作成 - cy.registerUser('alice', 'alice1234'); + cy.registerUser("alice", "alice1234"); - cy.login('alice', 'alice1234'); + cy.login("alice", "alice1234"); }); afterEach(() => { @@ -131,17 +133,17 @@ describe('After user singed in', () => { cy.wait(1000); }); - it('successfully loads', () => { - cy.get('[data-cy-open-post-form]').should('be.visible'); - }); + it("successfully loads", () => { + cy.get("[data-cy-open-post-form]").should("be.visible"); + }); - it('note', () => { - cy.get('[data-cy-open-post-form]').click(); - cy.get('[data-cy-post-form-text]').type('Hello, Misskey!'); - cy.get('[data-cy-open-post-form-submit]').click(); + it("note", () => { + cy.get("[data-cy-open-post-form]").click(); + cy.get("[data-cy-post-form-text]").type("Hello, Misskey!"); + cy.get("[data-cy-open-post-form-submit]").click(); - cy.contains('Hello, Misskey!'); - }); + cy.contains("Hello, Misskey!"); + }); }); // TODO: 投稿フォームの公開範囲指定のテスト diff --git a/cypress/e2e/widgets.cy.js b/cypress/e2e/widgets.cy.js index 9eea010bd..e3c9326db 100644 --- a/cypress/e2e/widgets.cy.js +++ b/cypress/e2e/widgets.cy.js @@ -1,14 +1,14 @@ -describe('After user signed in', () => { +describe("After user signed in", () => { beforeEach(() => { cy.resetState(); - cy.viewport('macbook-16'); + cy.viewport("macbook-16"); // インスタンス初期セットアップ - cy.registerUser('admin', 'pass', true); + cy.registerUser("admin", "pass", true); // ユーザー作成 - cy.registerUser('alice', 'alice1234'); + cy.registerUser("alice", "alice1234"); - cy.login('alice', 'alice1234'); + cy.login("alice", "alice1234"); }); afterEach(() => { @@ -17,47 +17,47 @@ describe('After user signed in', () => { cy.wait(1000); }); - it('widget edit toggle is visible', () => { - cy.get('.mk-widget-edit').should('be.visible'); - }); + it("widget edit toggle is visible", () => { + cy.get(".mk-widget-edit").should("be.visible"); + }); - it('widget select should be visible in edit mode', () => { - cy.get('.mk-widget-edit').click(); - cy.get('.mk-widget-select').should('be.visible'); - }); + it("widget select should be visible in edit mode", () => { + cy.get(".mk-widget-edit").click(); + cy.get(".mk-widget-select").should("be.visible"); + }); - it('first widget should be removed', () => { - cy.get('.mk-widget-edit').click(); - cy.get('.customize-container:first-child .remove._button').click(); - cy.get('.customize-container').should('have.length', 2); + it("first widget should be removed", () => { + cy.get(".mk-widget-edit").click(); + cy.get(".customize-container:first-child .remove._button").click(); + cy.get(".customize-container").should("have.length", 2); }); function buildWidgetTest(widgetName) { it(`${widgetName} widget should get added`, () => { - cy.get('.mk-widget-edit').click(); - cy.get('.mk-widget-select select').select(widgetName, { force: true }); - cy.get('.bg._modalBg.transparent').click({ multiple: true, force: true }); - cy.get('.mk-widget-add').click({ force: true }); - cy.get(`.mkw-${widgetName}`).should('exist'); + cy.get(".mk-widget-edit").click(); + cy.get(".mk-widget-select select").select(widgetName, { force: true }); + cy.get(".bg._modalBg.transparent").click({ multiple: true, force: true }); + cy.get(".mk-widget-add").click({ force: true }); + cy.get(`.mkw-${widgetName}`).should("exist"); }); } - buildWidgetTest('memo'); - buildWidgetTest('notifications'); - buildWidgetTest('timeline'); - buildWidgetTest('calendar'); - buildWidgetTest('rss'); - buildWidgetTest('trends'); - buildWidgetTest('clock'); - buildWidgetTest('activity'); - buildWidgetTest('photos'); - buildWidgetTest('digitalClock'); - buildWidgetTest('federation'); - buildWidgetTest('postForm'); - buildWidgetTest('slideshow'); - buildWidgetTest('serverMetric'); - buildWidgetTest('onlineUsers'); - buildWidgetTest('jobQueue'); - buildWidgetTest('button'); - buildWidgetTest('aiscript'); + buildWidgetTest("memo"); + buildWidgetTest("notifications"); + buildWidgetTest("timeline"); + buildWidgetTest("calendar"); + buildWidgetTest("rss"); + buildWidgetTest("trends"); + buildWidgetTest("clock"); + buildWidgetTest("activity"); + buildWidgetTest("photos"); + buildWidgetTest("digitalClock"); + buildWidgetTest("federation"); + buildWidgetTest("postForm"); + buildWidgetTest("slideshow"); + buildWidgetTest("serverMetric"); + buildWidgetTest("onlineUsers"); + buildWidgetTest("jobQueue"); + buildWidgetTest("button"); + buildWidgetTest("aiscript"); }); diff --git a/cypress/plugins/index.js b/cypress/plugins/index.js index aa9918d21..3a4b6deb1 100644 --- a/cypress/plugins/index.js +++ b/cypress/plugins/index.js @@ -16,6 +16,6 @@ * @type {Cypress.PluginConfig} */ module.exports = (on, config) => { - // `on` is used to hook into various events Cypress emits - // `config` is the resolved Cypress config -} + // `on` is used to hook into various events Cypress emits + // `config` is the resolved Cypress config +}; diff --git a/cypress/support/commands.js b/cypress/support/commands.js index 95bfcf685..3fe95b93d 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -24,32 +24,34 @@ // -- This will overwrite an existing command -- // Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... }) -Cypress.Commands.add('resetState', () => { - cy.window(win => { - win.indexedDB.deleteDatabase('keyval-store'); +Cypress.Commands.add("resetState", () => { + cy.window((win) => { + win.indexedDB.deleteDatabase("keyval-store"); }); - cy.request('POST', '/api/reset-db').as('reset'); - cy.get('@reset').its('status').should('equal', 204); + cy.request("POST", "/api/reset-db").as("reset"); + cy.get("@reset").its("status").should("equal", 204); cy.reload(true); }); -Cypress.Commands.add('registerUser', (username, password, isAdmin = false) => { - const route = isAdmin ? '/api/admin/accounts/create' : '/api/signup'; +Cypress.Commands.add("registerUser", (username, password, isAdmin = false) => { + const route = isAdmin ? "/api/admin/accounts/create" : "/api/signup"; - cy.request('POST', route, { + cy.request("POST", route, { username: username, password: password, - }).its('body').as(username); + }) + .its("body") + .as(username); }); -Cypress.Commands.add('login', (username, password) => { - cy.visit('/'); +Cypress.Commands.add("login", (username, password) => { + cy.visit("/"); - cy.intercept('POST', '/api/signin').as('signin'); + cy.intercept("POST", "/api/signin").as("signin"); - cy.get('[data-cy-signin]').click(); - cy.get('[data-cy-signin-username] input').type(username); - cy.get('[data-cy-signin-password] input').type(`${password}{enter}`); + cy.get("[data-cy-signin]").click(); + cy.get("[data-cy-signin-username] input").type(username); + cy.get("[data-cy-signin-password] input").type(`${password}{enter}`); - cy.wait('@signin').as('signedIn'); + cy.wait("@signin").as("signedIn"); }); diff --git a/cypress/support/e2e.js b/cypress/support/e2e.js index 9185be344..961c6ac88 100644 --- a/cypress/support/e2e.js +++ b/cypress/support/e2e.js @@ -14,19 +14,21 @@ // *********************************************************** // Import commands.js using ES2015 syntax: -import './commands' +import "./commands"; // Alternatively you can use CommonJS syntax: // require('./commands') -Cypress.on('uncaught:exception', (err, runnable) => { - if ([ - // Chrome - 'ResizeObserver loop limit exceeded', +Cypress.on("uncaught:exception", (err, runnable) => { + if ( + [ + // Chrome + "ResizeObserver loop limit exceeded", - // Firefox - 'ResizeObserver loop completed with undelivered notifications', - ].some(msg => err.message.includes(msg))) { + // Firefox + "ResizeObserver loop completed with undelivered notifications", + ].some((msg) => err.message.includes(msg)) + ) { return false; } }); diff --git a/packages/backend/src/server/api/endpoints/notes/edit.ts b/packages/backend/src/server/api/endpoints/notes/edit.ts index 511ea618c..14ce2faaf 100644 --- a/packages/backend/src/server/api/endpoints/notes/edit.ts +++ b/packages/backend/src/server/api/endpoints/notes/edit.ts @@ -530,7 +530,7 @@ export default define(meta, paramDef, async (ps, user) => { if (ps.cw !== note.cw || (ps.cw && !note.cw)) { update.cw = ps.cw; } - else if (!ps.cw && note.cw) { + if (!ps.cw && note.cw) { update.cw = null; } if (ps.visibility !== note.visibility) { diff --git a/packages/backend/src/services/note/create.ts b/packages/backend/src/services/note/create.ts index d765ff7aa..ba6859249 100644 --- a/packages/backend/src/services/note/create.ts +++ b/packages/backend/src/services/note/create.ts @@ -468,7 +468,9 @@ export default async ( } else if (boostedByRelay && data.renote?.uri) { // Use Redis transaction for atomicity await redisClient.watch(`publishedNote:${data.renote.uri}`); - const exists = await redisClient.exists(`publishedNote:${data.renote.uri}`); + const exists = await redisClient.exists( + `publishedNote:${data.renote.uri}`, + ); if (exists === 0) { // Start the transaction const transaction = redisClient.multi(); @@ -669,15 +671,15 @@ async function renderNoteOrRenoteActivity(data: Option, note: Note) { const content = data.renote && - data.text == null && - data.poll == null && - (data.files == null || data.files.length === 0) + data.text == null && + data.poll == null && + (data.files == null || data.files.length === 0) ? renderAnnounce( - data.renote.uri - ? data.renote.uri - : `${config.url}/notes/${data.renote.id}`, - note, - ) + data.renote.uri + ? data.renote.uri + : `${config.url}/notes/${data.renote.id}`, + note, + ) : renderCreate(await renderNote(note, false), note); return renderActivity(content); diff --git a/packages/calckey-js/package.json b/packages/calckey-js/package.json index d2235d04c..105f2fda9 100644 --- a/packages/calckey-js/package.json +++ b/packages/calckey-js/package.json @@ -11,7 +11,7 @@ "api": "pnpm api-extractor run --local --verbose", "api-prod": "pnpm api-extractor run --verbose", "api-doc": "pnpm api-documenter markdown -i ./etc/", - "lint": "pnpm rome check --apply * && pnpm rome check --apply 'src/*.ts'", + "lint": "pnpm rome check --apply *.ts", "format": "pnpm rome format --write '*' ; pnpm rome format --write '**/*.ts'", "jest": "jest --coverage --detectOpenHandles", "test": "pnpm jest && pnpm tsd" diff --git a/packages/client/src/components/mfm.ts b/packages/client/src/components/mfm.ts index 37e454fcf..cb0942a33 100644 --- a/packages/client/src/components/mfm.ts +++ b/packages/client/src/components/mfm.ts @@ -65,7 +65,7 @@ export default defineComponent({ }; // const validEase = (e: string | null | undefined) => { // if (e == null) return null; - // return e.match(/(steps)?\(-?[0-9.]+,-?[0-9.]+,-?[0-9.]+,-?[0-9.]+\)/) + // return e.match(/(steps)?\(-?[0-9.]+,-?[0-9.]+,-?[0-9.]+,-?[0-9.]+\)/) // ? (e.startsWith("steps") ? e : "cubic-bezier" + e) // : null // } diff --git a/packages/client/src/directives/tooltip.ts b/packages/client/src/directives/tooltip.ts index e9668f28f..e2db3fbf5 100644 --- a/packages/client/src/directives/tooltip.ts +++ b/packages/client/src/directives/tooltip.ts @@ -6,7 +6,6 @@ import { isTouchUsing } from "@/scripts/touch"; import { popup, alert } from "@/os"; import { mainRouter } from "@/router"; - const start = isTouchUsing ? "touchstart" : "mouseover"; const end = isTouchUsing ? "touchend" : "mouseleave"; diff --git a/packages/client/src/os.ts b/packages/client/src/os.ts index 376d5184e..32bb8f76b 100644 --- a/packages/client/src/os.ts +++ b/packages/client/src/os.ts @@ -22,7 +22,7 @@ const apiClient = new Misskey.api.APIClient({ export const api = (( endpoint: string, data: Record = {}, - token?: string | null | undefined + token?: string | null | undefined, ) => { pendingApiRequestsCount.value++; @@ -36,16 +36,13 @@ export const api = (( : undefined; const promise = new Promise((resolve, reject) => { - fetch( - endpoint.indexOf("://") > -1 ? endpoint : `${apiUrl}/${endpoint}`, - { - method: "POST", - body: JSON.stringify(data), - credentials: "omit", - cache: "no-cache", - headers: authorization ? { authorization } : {}, - } - ) + fetch(endpoint.indexOf("://") > -1 ? endpoint : `${apiUrl}/${endpoint}`, { + method: "POST", + body: JSON.stringify(data), + credentials: "omit", + cache: "no-cache", + headers: authorization ? { authorization } : {}, + }) .then(async (res) => { const body = res.status === 204 ? null : await res.json(); @@ -68,7 +65,7 @@ export const api = (( export const apiGet = (( endpoint: string, data: Record = {}, - token?: string | null | undefined + token?: string | null | undefined, ) => { pendingApiRequestsCount.value++; @@ -113,7 +110,7 @@ export const apiGet = (( export const apiWithDialog = (( endpoint: string, data: Record = {}, - token?: string | null | undefined + token?: string | null | undefined, ) => { const promise = api(endpoint, data, token); promiseDialog(promise, null, (err) => { @@ -130,7 +127,7 @@ export function promiseDialog>( promise: T, onSuccess?: ((res: any) => void) | null, onFailure?: ((err: Error) => void) | null, - text?: string + text?: string, ): T { const showing = ref(true); const success = ref(false); @@ -168,7 +165,7 @@ export function promiseDialog>( text: text, }, {}, - "closed" + "closed", ); return promise; @@ -189,7 +186,7 @@ const zIndexes = { high: 3000000, }; export function claimZIndex( - priority: "low" | "middle" | "high" = "low" + priority: "low" | "middle" | "high" = "low", ): number { zIndexes[priority] += 100; return zIndexes[priority]; @@ -204,7 +201,7 @@ export async function popup( component: Component, props: Record, events = {}, - disposeEvent?: string + disposeEvent?: string, ) { markRaw(component); @@ -245,7 +242,7 @@ export function pageWindow(path: string) { initialPath: path, }, {}, - "closed" + "closed", ); } @@ -260,7 +257,7 @@ export function modalPageWindow(path: string) { initialPath: path, }, {}, - "closed" + "closed", ); } @@ -271,7 +268,7 @@ export function toast(message: string) { message, }, {}, - "closed" + "closed", ); } @@ -292,7 +289,7 @@ export function alert(props: { resolve(); }, }, - "closed" + "closed", ); }); } @@ -316,7 +313,7 @@ export function confirm(props: { resolve(result ? result : { canceled: true }); }, }, - "closed" + "closed", ); }); } @@ -343,7 +340,7 @@ export function yesno(props: { resolve(result ? result : { canceled: true }); }, }, - "closed" + "closed", ); }); } @@ -384,7 +381,7 @@ export function inputText(props: { resolve(result ? result : { canceled: true }); }, }, - "closed" + "closed", ); }); } @@ -422,7 +419,7 @@ export function inputParagraph(props: { resolve(result ? result : { canceled: true }); }, }, - "closed" + "closed", ); }); } @@ -462,7 +459,7 @@ export function inputNumber(props: { resolve(result ? result : { canceled: true }); }, }, - "closed" + "closed", ); }); } @@ -499,11 +496,11 @@ export function inputDate(props: { result: new Date(result.result), canceled: false, } - : { canceled: true } + : { canceled: true }, ); }, }, - "closed" + "closed", ); }); } @@ -529,7 +526,7 @@ export function select( }[]; }[]; } - ) + ), ): Promise< | { canceled: true; result: undefined } | { @@ -554,7 +551,7 @@ export function select( resolve(result ? result : { canceled: true }); }, }, - "closed" + "closed", ); }); } @@ -574,7 +571,7 @@ export function success(): Promise { { done: () => resolve(), }, - "closed" + "closed", ); }); } @@ -591,7 +588,7 @@ export function waiting(): Promise { { done: () => resolve(), }, - "closed" + "closed", ); }); } @@ -610,7 +607,7 @@ export function form(title, form) { resolve(result); }, }, - "closed" + "closed", ); }); } @@ -629,7 +626,7 @@ export async function selectUser() { resolve(user); }, }, - "closed" + "closed", ); }); } @@ -648,7 +645,7 @@ export async function selectInstance(): Promise { resolve(instance); }, }, - "closed" + "closed", ); }); } @@ -672,7 +669,7 @@ export async function selectDriveFile(multiple: boolean) { } }, }, - "closed" + "closed", ); }); } @@ -696,7 +693,7 @@ export async function selectDriveFolder(multiple: boolean) { } }, }, - "closed" + "closed", ); }); } @@ -718,7 +715,7 @@ export async function pickEmoji(src: HTMLElement | null, opts) { resolve(emoji); }, }, - "closed" + "closed", ); }); } @@ -727,7 +724,7 @@ export async function cropImage( image: Misskey.entities.DriveFile, options: { aspectRatio: number; - } + }, ): Promise { return new Promise((resolve, reject) => { popup( @@ -745,7 +742,7 @@ export async function cropImage( resolve(x); }, }, - "closed" + "closed", ); }); } @@ -760,7 +757,7 @@ let activeTextarea: HTMLTextAreaElement | HTMLInputElement | null = null; export async function openEmojiPicker( src?: HTMLElement, opts, - initialTextarea: typeof activeTextarea + initialTextarea: typeof activeTextarea, ) { if (openingEmojiPicker) return; @@ -776,14 +773,13 @@ export async function openEmojiPicker( const observer = new MutationObserver((records) => { for (const record of records) { for (const node of Array.from(record.addedNodes).filter( - (node) => node instanceof HTMLElement + (node) => node instanceof HTMLElement, ) as HTMLElement[]) { const textareas = node.querySelectorAll("textarea, input"); for (const textarea of Array.from(textareas).filter( - (textarea) => textarea.dataset.preventEmojiInsert == null + (textarea) => textarea.dataset.preventEmojiInsert == null, )) { - if (document.activeElement === textarea) - activeTextarea = textarea; + if (document.activeElement === textarea) activeTextarea = textarea; textarea.addEventListener("focus", () => { activeTextarea = textarea; }); @@ -821,7 +817,7 @@ export async function openEmojiPicker( openingEmojiPicker = null; observer.disconnect(); }, - } + }, ); } @@ -833,7 +829,7 @@ export function popupMenu( width?: number; viaKeyboard?: boolean; noReturnFocus?: boolean; - } + }, ) { return new Promise((resolve, reject) => { let dispose; @@ -856,7 +852,7 @@ export function popupMenu( resolve(); dispose(); }, - } + }, ).then((res) => { dispose = res.dispose; }); @@ -865,7 +861,7 @@ export function popupMenu( export function contextMenu( items: MenuItem[] | Ref, - ev: MouseEvent + ev: MouseEvent, ) { ev.preventDefault(); return new Promise((resolve, reject) => { @@ -885,7 +881,7 @@ export function contextMenu( resolve(); dispose(); }, - } + }, ).then((res) => { dispose = res.dispose; }); diff --git a/packages/client/src/scripts/emojilist.ts b/packages/client/src/scripts/emojilist.ts index 0609600f6..a5ad7e368 100644 --- a/packages/client/src/scripts/emojilist.ts +++ b/packages/client/src/scripts/emojilist.ts @@ -28,11 +28,11 @@ export const categoryMapping = { "People & Body": "people", "Animals & Nature": "animals_and_nature", "Food & Drink": "food_and_drink", - "Activities": "activity", + Activities: "activity", "Travel & Places": "travel_and_places", - "Objects": "objects", - "Symbols": "symbols", - "Flags": "flags", + Objects: "objects", + Symbols: "symbols", + Flags: "flags", } as const; export const unicodeEmojiSkinTones = [ @@ -47,24 +47,39 @@ export const unicodeEmojiSkinTones = [ export function addSkinTone(emoji: string, skinTone?: number) { const chosenSkinTone = skinTone || defaultStore.state.reactionPickerSkinTone; const skinToneModifiers = [ - "", - emojiComponents.light_skin_tone, - emojiComponents.medium_light_skin_tone, - emojiComponents.medium_skin_tone, - emojiComponents.medium_dark_skin_tone, - emojiComponents.dark_skin_tone + "", + emojiComponents.light_skin_tone, + emojiComponents.medium_light_skin_tone, + emojiComponents.medium_skin_tone, + emojiComponents.medium_dark_skin_tone, + emojiComponents.dark_skin_tone, ]; return emoji + (skinToneModifiers[chosenSkinTone - 1] || ""); } const unicodeFifteenEmojis = [ - '🫨', '🩷', '🩵', '🩶', - '🫷', '🫸', '🫎', '🫏', - '🪽', '🐦‍⬛', '🪿', '🪼', - '🪻', '🫚', '🫛', '🪭', - '🪮', '🪇', '🪈', '🪯', - '🛜' -] + "🫨", + "🩷", + "🩵", + "🩶", + "🫷", + "🫸", + "🫎", + "🫏", + "🪽", + "🐦‍⬛", + "🪿", + "🪼", + "🪻", + "🫚", + "🫛", + "🪭", + "🪮", + "🪇", + "🪈", + "🪯", + "🛜", +]; const newData = {}; @@ -84,22 +99,26 @@ Object.keys(data).forEach((originalCategory) => { } }); -export const emojilist: UnicodeEmojiDef[] = Object.keys(newData).reduce((acc, category) => { - const categoryItems = newData[category].map((item) => { - return { - emoji: item.emoji, - slug: item.slug, - category: item.category, - skin_tone_support: item.skin_tone_support || false, - keywords: item.keywords || [], - }; - }); - return acc.concat(categoryItems); -}, []); - +export const emojilist: UnicodeEmojiDef[] = Object.keys(newData).reduce( + (acc, category) => { + const categoryItems = newData[category].map((item) => { + return { + emoji: item.emoji, + slug: item.slug, + category: item.category, + skin_tone_support: item.skin_tone_support || false, + keywords: item.keywords || [], + }; + }); + return acc.concat(categoryItems); + }, + [], +); export function getNicelyLabeledCategory(internalName) { - return Object.keys(categoryMapping).find( - (key) => categoryMapping[key] === internalName - ) || internalName; + return ( + Object.keys(categoryMapping).find( + (key) => categoryMapping[key] === internalName, + ) || internalName + ); } diff --git a/packages/client/src/scripts/get-note-menu.ts b/packages/client/src/scripts/get-note-menu.ts index 1eeaf29a5..fa78c7ce5 100644 --- a/packages/client/src/scripts/get-note-menu.ts +++ b/packages/client/src/scripts/get-note-menu.ts @@ -341,7 +341,7 @@ export function getNoteMenu(props: { action: () => { window.open(appearNote.url || appearNote.uri, "_blank"); }, - } + } : undefined, { type: "parent", @@ -358,19 +358,21 @@ export function getNoteMenu(props: { text: i18n.ts.copyLink, action: copyLink, }, - appearNote.url || appearNote.uri ? { - icon: "ph-link-simple ph-bold ph-lg", - text: `${i18n.ts.copyLink} (${i18n.ts.remote})`, - action: copyOriginal, - } : undefined, + appearNote.url || appearNote.uri + ? { + icon: "ph-link-simple ph-bold ph-lg", + text: `${i18n.ts.copyLink} (${i18n.ts.remote})`, + action: copyOriginal, + } + : undefined, shareAvailable() - ? { - icon: "ph-share-network ph-bold ph-lg", - text: i18n.ts.share, - action: share, - } - : undefined, - ] + ? { + icon: "ph-share-network ph-bold ph-lg", + text: i18n.ts.share, + action: share, + } + : undefined, + ], }, /* ...($i.isModerator || $i.isAdmin ? [ @@ -404,7 +406,7 @@ export function getNoteMenu(props: { "closed", ); }, - } + } : undefined, instance.features.postEditing && isAppearAuthor ? { @@ -432,11 +434,12 @@ export function getNoteMenu(props: { !isAppearAuthor ? null : undefined, !isAppearAuthor ? { - type: "parent", - icon: "ph-user ph-bold ph-lg", - text: i18n.ts.user, - children: getUserMenu(appearNote.user) - } : undefined, + type: "parent", + icon: "ph-user ph-bold ph-lg", + text: i18n.ts.user, + children: getUserMenu(appearNote.user), + } + : undefined, ].filter((x) => x !== undefined); } else { menu = [ @@ -459,18 +462,20 @@ export function getNoteMenu(props: { text: i18n.ts.copyLink, action: copyLink, }, - appearNote.url || appearNote.uri ? { - icon: "ph-link-simple ph-bold ph-lg", - text: `${i18n.ts.copyLink} (${i18n.ts.remote})`, - action: copyOriginal, - } : undefined, + appearNote.url || appearNote.uri + ? { + icon: "ph-link-simple ph-bold ph-lg", + text: `${i18n.ts.copyLink} (${i18n.ts.remote})`, + action: copyOriginal, + } + : undefined, shareAvailable() - ? { - icon: "ph-share-network ph-bold ph-lg", - text: i18n.ts.share, - action: share, - } - : undefined, + ? { + icon: "ph-share-network ph-bold ph-lg", + text: i18n.ts.share, + action: share, + } + : undefined, ].filter((x) => x !== undefined); } diff --git a/packages/client/src/scripts/get-user-menu.ts b/packages/client/src/scripts/get-user-menu.ts index 39e1912b7..48b97fed6 100644 --- a/packages/client/src/scripts/get-user-menu.ts +++ b/packages/client/src/scripts/get-user-menu.ts @@ -227,7 +227,9 @@ export function getUserMenu(user, router: Router = mainRouter) { let menu = [ { type: "label", - text: user.host ? `@${user.username}@${user.host || host}` : `@${user.username}` + text: user.host + ? `@${user.username}@${user.host || host}` + : `@${user.username}`, }, { icon: "ph-at ph-bold ph-lg", diff --git a/packages/client/src/store.ts b/packages/client/src/store.ts index 74ee6e755..e7be5135c 100644 --- a/packages/client/src/store.ts +++ b/packages/client/src/store.ts @@ -337,7 +337,7 @@ export const defaultStore = markRaw( showTimelineReplies: { where: "device", default: true, - } + }, }), ); diff --git a/scripts/build-greet.js b/scripts/build-greet.js index bbcc2aec7..4b119b0c9 100644 --- a/scripts/build-greet.js +++ b/scripts/build-greet.js @@ -8,16 +8,8 @@ console.log(themeColor("/ /__| (_| | | (__| < __/ |_| |")); console.log(themeColor("\\____/\\__,_|_|\\___|_|\\_\\___|\\__, |")); console.log(themeColor(" (___/ ")); +console.log(" Currently building Calckey!"); console.log( - " Currently building Calckey!", -); -console.log( - chalk.rgb( - 255, - 136, - 0, - )( - " Hang on for a moment, as this may take a while.", - ), + chalk.rgb(255, 136, 0)(" Hang on for a moment, as this may take a while."), ); console.log(""); diff --git a/scripts/clean-all.js b/scripts/clean-all.js index c5f682988..8c1032e33 100644 --- a/scripts/clean-all.js +++ b/scripts/clean-all.js @@ -1,30 +1,57 @@ -const fs = require('node:fs'); -const execa = require('execa'); -const { join } = require('node:path'); +const fs = require("node:fs"); +const execa = require("execa"); +const { join } = require("node:path"); (async () => { - fs.rmSync(join(__dirname, '/../packages/backend/built'), { recursive: true, force: true }); - fs.rmSync(join(__dirname, '/../packages/backend/node_modules'), { recursive: true, force: true }); - - fs.rmSync(join(__dirname, '/../packages/backend/native-utils/built'), { recursive: true, force: true }); - fs.rmSync(join(__dirname, '/../packages/backend/native-utils/node_modules'), { recursive: true, force: true }); - - fs.rmSync(join(__dirname, '/../packages/client/built'), { recursive: true, force: true }); - fs.rmSync(join(__dirname, '/../packages/client/node_modules'), { recursive: true, force: true }); - - fs.rmSync(join(__dirname, '/../packages/sw/built'), { recursive: true, force: true }); - fs.rmSync(join(__dirname, '/../packages/sw/node_modules'), { recursive: true, force: true }); - - fs.rmSync(join(__dirname, '/../built'), { recursive: true, force: true }); - fs.rmSync(join(__dirname, '/../node_modules'), { recursive: true, force: true }); - - execa('pnpm', ['store', 'prune'], { - cwd: join(__dirname, '/../'), - stdio: 'inherit' + fs.rmSync(join(__dirname, "/../packages/backend/built"), { + recursive: true, + force: true, + }); + fs.rmSync(join(__dirname, "/../packages/backend/node_modules"), { + recursive: true, + force: true, }); - execa('cargo', ['clean'], { - cwd: join(__dirname, '/../packages/backend/native-utils'), - stdio: 'inherit' + fs.rmSync(join(__dirname, "/../packages/backend/native-utils/built"), { + recursive: true, + force: true, + }); + fs.rmSync(join(__dirname, "/../packages/backend/native-utils/node_modules"), { + recursive: true, + force: true, + }); + + fs.rmSync(join(__dirname, "/../packages/client/built"), { + recursive: true, + force: true, + }); + fs.rmSync(join(__dirname, "/../packages/client/node_modules"), { + recursive: true, + force: true, + }); + + fs.rmSync(join(__dirname, "/../packages/sw/built"), { + recursive: true, + force: true, + }); + fs.rmSync(join(__dirname, "/../packages/sw/node_modules"), { + recursive: true, + force: true, + }); + + fs.rmSync(join(__dirname, "/../built"), { recursive: true, force: true }); + fs.rmSync(join(__dirname, "/../node_modules"), { + recursive: true, + force: true, + }); + + execa("pnpm", ["store", "prune"], { + cwd: join(__dirname, "/../"), + stdio: "inherit", + }); + + execa("cargo", ["clean"], { + cwd: join(__dirname, "/../packages/backend/native-utils"), + stdio: "inherit", }); })(); diff --git a/scripts/clean.js b/scripts/clean.js index cf8ee9bc5..76a7873b5 100644 --- a/scripts/clean.js +++ b/scripts/clean.js @@ -1,10 +1,22 @@ -const fs = require('node:fs'); -const { join } = require('node:path'); +const fs = require("node:fs"); +const { join } = require("node:path"); (async () => { - fs.rmSync(join(__dirname, '/../packages/backend/built'), { recursive: true, force: true }); - fs.rmSync(join(__dirname, '/../packages/backend/native-utils/built'), { recursive: true, force: true }); - fs.rmSync(join(__dirname, '/../packages/client/built'), { recursive: true, force: true }); - fs.rmSync(join(__dirname, '/../packages/sw/built'), { recursive: true, force: true }); - fs.rmSync(join(__dirname, '/../built'), { recursive: true, force: true }); + fs.rmSync(join(__dirname, "/../packages/backend/built"), { + recursive: true, + force: true, + }); + fs.rmSync(join(__dirname, "/../packages/backend/native-utils/built"), { + recursive: true, + force: true, + }); + fs.rmSync(join(__dirname, "/../packages/client/built"), { + recursive: true, + force: true, + }); + fs.rmSync(join(__dirname, "/../packages/sw/built"), { + recursive: true, + force: true, + }); + fs.rmSync(join(__dirname, "/../built"), { recursive: true, force: true }); })(); diff --git a/scripts/dev.js b/scripts/dev.js index 7a61070f5..0d6a05fe2 100644 --- a/scripts/dev.js +++ b/scripts/dev.js @@ -1,45 +1,45 @@ -const execa = require('execa'); +const execa = require("execa"); (async () => { - await execa('pnpm', ['clean'], { - cwd: __dirname + '/../', + await execa("pnpm", ["clean"], { + cwd: __dirname + "/../", stdout: process.stdout, stderr: process.stderr, }); - execa('pnpm', ['dlx', 'gulp', 'watch'], { - cwd: __dirname + '/../', + execa("pnpm", ["dlx", "gulp", "watch"], { + cwd: __dirname + "/../", stdout: process.stdout, stderr: process.stderr, }); - execa('pnpm', ['--filter', 'backend', 'watch'], { - cwd: __dirname + '/../', + execa("pnpm", ["--filter", "backend", "watch"], { + cwd: __dirname + "/../", stdout: process.stdout, stderr: process.stderr, }); - execa('pnpm', ['--filter', 'client', 'watch'], { - cwd: __dirname + '/../', + execa("pnpm", ["--filter", "client", "watch"], { + cwd: __dirname + "/../", stdout: process.stdout, stderr: process.stderr, }); - execa('pnpm', ['--filter', 'sw', 'watch'], { - cwd: __dirname + '/../', + execa("pnpm", ["--filter", "sw", "watch"], { + cwd: __dirname + "/../", stdout: process.stdout, stderr: process.stderr, }); const start = async () => { try { - await execa('pnpm', ['start'], { - cwd: __dirname + '/../', + await execa("pnpm", ["start"], { + cwd: __dirname + "/../", stdout: process.stdout, stderr: process.stderr, }); } catch (e) { - await new Promise(resolve => setTimeout(resolve, 3000)); + await new Promise((resolve) => setTimeout(resolve, 3000)); start(); } };