Skip to content

Commit

Permalink
Merge pull request #110 from xpadev-net/develop
Browse files Browse the repository at this point in the history
release: v0.0.27
  • Loading branch information
xpadev-net authored Nov 22, 2024
2 parents 3ed58f2 + 2e02fb9 commit 6c91789
Show file tree
Hide file tree
Showing 55 changed files with 2,415 additions and 2,002 deletions.
38 changes: 0 additions & 38 deletions .eslintrc.json

This file was deleted.

6 changes: 0 additions & 6 deletions .prettierignore

This file was deleted.

1 change: 0 additions & 1 deletion .prettierrc.json

This file was deleted.

16 changes: 16 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"$schema": "https://biomejs.dev/schemas/1.7.1/schema.json",
"organizeImports": {
"enabled": true
},
"linter": {
"enabled": true,
"rules": {
"recommended": true
}
},
"formatter": {
"enabled": true,
"indentStyle": "space"
}
}
22 changes: 12 additions & 10 deletions electron/assets.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import * as fs from "node:fs";
import * as os from "node:os";
import * as path from "node:path";
import type * as Stream from "node:stream";
import type { AxiosProgressEvent, AxiosResponse } from "axios";
import axios from "axios";
import * as fs from "fs";
import * as os from "os";
import * as path from "path";
import type * as Stream from "stream";

import {
closeBinaryDownloaderWindow,
Expand All @@ -19,9 +19,9 @@ let target: lib[] = [];

const ext = process.platform === "win32" ? ".exe" : "";

const binPath = path.join(basePath, "bin"),
ffmpegPath = path.join(binPath, `ffmpeg${ext}`),
ffprobePath = path.join(binPath, `ffprobe${ext}`);
const binPath = path.join(basePath, "bin");
const ffmpegPath = path.join(binPath, `ffmpeg${ext}`);
const ffprobePath = path.join(binPath, `ffprobe${ext}`);

const assetsBaseUrl = {
ffmpeg:
Expand All @@ -30,18 +30,20 @@ const assetsBaseUrl = {
const version = {
ffmpeg: "4.4",
};
const distro = (function () {
const distro = (() => {
const arch = os.arch();
const dist = process.platform;
if (dist === "win32" && arch === "x64") {
return {
ffmpeg: "win32-x64",
};
} else if (dist === "darwin" && arch === "arm64") {
}
if (dist === "darwin" && arch === "arm64") {
return {
ffmpeg: "darwin-arm64",
};
} else if (dist === "darwin" && arch === "x64") {
}
if (dist === "darwin" && arch === "x64") {
return {
ffmpeg: "darwin-x64",
};
Expand Down
4 changes: 2 additions & 2 deletions electron/binary-downloader-window.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { app, BrowserWindow } from "electron";
import * as path from "path";
import * as path from "node:path";
import { BrowserWindow, app } from "electron";

import type { ApiResponsesToBinaryDownloader } from "@/@types/response.binary-downloader";

Expand Down
2 changes: 1 addition & 1 deletion electron/context.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as path from "node:path";
import { app } from "electron";
import * as path from "path";

const baseUrl = app.isPackaged
? `file://${__dirname}/html/index.html`
Expand Down
4 changes: 2 additions & 2 deletions electron/controller-window.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { app, BrowserWindow } from "electron";
import * as path from "path";
import * as path from "node:path";
import { BrowserWindow, app } from "electron";

import type { ApiResponsesToController } from "@/@types/response.controller";

Expand Down
2 changes: 1 addition & 1 deletion electron/converter.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type * as Stream from "stream";
import type * as Stream from "node:stream";

import type { FfmpegOptions } from "@/@types/ffmpeg";
import type { ConvertQueue } from "@/@types/queue";
Expand Down
13 changes: 7 additions & 6 deletions electron/dialog.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as path from "node:path";
import type { OpenDialogReturnValue, SaveDialogOptions } from "electron";
import { dialog } from "electron";
import * as path from "path";

import type { FfprobeOutput } from "@/@types/ffmpeg";
import type {
Expand Down Expand Up @@ -30,7 +30,7 @@ const selectFile = async (
};

const selectMovie = async (): Promise<
ApiResponseMessage | ApiResponseSelectMovie | void
ApiResponseMessage | ApiResponseSelectMovie | undefined
> => {
const path = await dialog.showOpenDialog({
properties: ["openFile"],
Expand Down Expand Up @@ -98,9 +98,9 @@ const selectMovie = async (): Promise<
"動画ソースが見つかりませんでした\ndialog / selectMovie / empty streams",
};
}
let width: number = 0,
height: number = 0,
duration: number = 0;
let width = 0;
let height = 0;
let duration = 0;
for (const stream of metadata.streams) {
if (stream.width) {
width = stream.width;
Expand Down Expand Up @@ -155,7 +155,8 @@ const selectComment = async (): Promise<
sendMessageToController({
type: "message",
title: "非対応のフォーマットです",
message: `入力されたデータの識別に失敗しました\n対応していないフォーマットの可能性があります\n対応しているフォーマットについては以下のリンクを御覧ください\nhttps://xpadev-net.github.io/niconicomments/#p_format\n※フォーマットの識別は拡張子をもとに行っています\ndialog / selectComment`,
message:
"入力されたデータの識別に失敗しました\n対応していないフォーマットの可能性があります\n対応しているフォーマットについては以下のリンクを御覧ください\nhttps://xpadev-net.github.io/niconicomments/#p_format\n※フォーマットの識別は拡張子をもとに行っています\ndialog / selectComment",
});
return;
}
Expand Down
6 changes: 3 additions & 3 deletions electron/electron.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { app, BrowserWindow, globalShortcut } from "electron";
import { BrowserWindow, app, globalShortcut } from "electron";

import { onStartUp } from "./assets";
import { createControllerWindow } from "./controller-window";
Expand All @@ -19,7 +19,7 @@ app
})
.catch((e) => console.warn(e));
if (app.isPackaged) {
app.on("browser-window-focus", function () {
app.on("browser-window-focus", () => {
globalShortcut.register("CommandOrControl+R", () => {
console.log("CommandOrControl+R is pressed: Shortcut Disabled");
});
Expand All @@ -28,7 +28,7 @@ if (app.isPackaged) {
});
});

app.on("browser-window-blur", function () {
app.on("browser-window-blur", () => {
globalShortcut.unregister("CommandOrControl+R");
globalShortcut.unregister("F5");
});
Expand Down
37 changes: 20 additions & 17 deletions electron/ffmpeg-stream/stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ ffmpeg-stream
Released under the MIT License.
source file: https://github.com/phaux/node-ffmpeg-stream/blob/master/src/index.ts
*/
import type { ChildProcess } from "child_process";
import { spawn } from "child_process";
import { createReadStream, createWriteStream, unlink } from "fs";
import { tmpdir } from "os";
import { join } from "path";
import type { Readable, Writable } from "stream";
import { PassThrough } from "stream";
import { promisify } from "util";
import type { ChildProcess } from "node:child_process";
import { spawn } from "node:child_process";
import { createReadStream, createWriteStream, unlink } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import type { Readable, Writable } from "node:stream";
import { PassThrough } from "node:stream";
import { promisify } from "node:util";

import { ffmpegPath } from "../assets";
import { getLogger } from "../lib/log";
Expand Down Expand Up @@ -62,7 +62,7 @@ function getArgs(options: Options): string[] {
}
} else if (value != null && value !== false) {
args.push(`-${option}`);
if (typeof value != "boolean") {
if (typeof value !== "boolean") {
args.push(String(value));
}
}
Expand Down Expand Up @@ -95,14 +95,14 @@ export class Converter {
input(file: string, options?: Options): void;
input(arg0?: string | Options, arg1?: Options): Writable | undefined {
const [file, opts = {}] =
typeof arg0 == "string" ? [arg0, arg1] : [undefined, arg0];
typeof arg0 === "string" ? [arg0, arg1] : [undefined, arg0];

if (file != null) {
this.createInputFromFile(file, opts);
return;
}
if (opts.buffer) {
delete opts.buffer;
opts.buffer = undefined;
return this.createBufferedInputStream(opts);
}
return this.createInputStream(opts);
Expand All @@ -113,14 +113,14 @@ export class Converter {
output(file: string, options?: Options): void;
output(arg0?: string | Options, arg1?: Options): Readable | undefined {
const [file, opts = {}] =
typeof arg0 == "string" ? [arg0, arg1] : [undefined, arg0];
typeof arg0 === "string" ? [arg0, arg1] : [undefined, arg0];

if (file != null) {
this.createOutputToFile(file, opts);
return;
}
if (opts.buffer) {
delete opts.buffer;
opts.buffer = undefined;
return this.createBufferedOutputStream(opts);
}
return this.createOutputStream(opts);
Expand Down Expand Up @@ -194,7 +194,7 @@ export class Converter {
resolve();
});
stream.on("error", (err) => {
logger.error(`input buffered stream error`, err);
logger.error("input buffered stream error", err);
return reject(err);
});
});
Expand Down Expand Up @@ -222,7 +222,7 @@ export class Converter {
resolve();
});
reader.on("error", (err: Error) => {
logger.error(`output buffered stream error`, err);
logger.error("output buffered stream error", err);
reject(err);
});
});
Expand Down Expand Up @@ -315,7 +315,10 @@ export class Converter {
await new Promise<void>((resolve, reject): void => {
let logSectionNum = 0;

if (this.process == null) return reject(Error(`Converter not started`));
if (this.process == null) {
reject(Error("Converter not started"));
return;
}

if (this.process.stderr != null) {
this.process.stderr.setEncoding("utf8");
Expand Down Expand Up @@ -346,7 +349,7 @@ export class Converter {
);
if (code == null) return resolve();
if (EXIT_CODES.includes(code)) return resolve();
reject(Error(`Converting failed`));
reject(Error("Converting failed"));
});
});
}
Expand Down
2 changes: 1 addition & 1 deletion electron/lib/cookie.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ const filterCookies = (

const formatCookies = (
cookies: ParsedCookie[],
addSuffix: boolean = false,
addSuffix = false,
): string[] => {
return cookies.map((cookie) => {
return `${cookie.key}=${cookie.value}${
Expand Down
Loading

0 comments on commit 6c91789

Please sign in to comment.