mirror of
https://github.com/mifi/lossless-cut.git
synced 2024-11-22 02:12:30 +01:00
improve types
This commit is contained in:
parent
13485fa686
commit
8eef3cbc16
@ -55,6 +55,7 @@
|
|||||||
"@types/lodash": "^4.14.202",
|
"@types/lodash": "^4.14.202",
|
||||||
"@types/lodash.debounce": "^4",
|
"@types/lodash.debounce": "^4",
|
||||||
"@types/luxon": "^3.4.2",
|
"@types/luxon": "^3.4.2",
|
||||||
|
"@types/mime-types": "^2.1.4",
|
||||||
"@types/morgan": "^1.9.9",
|
"@types/morgan": "^1.9.9",
|
||||||
"@types/node": "18",
|
"@types/node": "18",
|
||||||
"@types/react": "^18.2.66",
|
"@types/react": "^18.2.66",
|
||||||
|
@ -1687,7 +1687,7 @@ function App() {
|
|||||||
|
|
||||||
// first check if it is a single directory, and if so, read it recursively
|
// first check if it is a single directory, and if so, read it recursively
|
||||||
if (filePaths.length === 1) {
|
if (filePaths.length === 1) {
|
||||||
const firstFilePath = filePaths[0];
|
const firstFilePath = filePaths[0]!;
|
||||||
const firstFileStat = await lstat(firstFilePath);
|
const firstFileStat = await lstat(firstFilePath);
|
||||||
if (firstFileStat.isDirectory()) {
|
if (firstFileStat.isDirectory()) {
|
||||||
console.log('Reading directory...');
|
console.log('Reading directory...');
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import JSON5 from 'json5';
|
import JSON5 from 'json5';
|
||||||
import i18n from 'i18next';
|
import i18n from 'i18next';
|
||||||
import type { parse as CueParse } from 'cue-parser';
|
|
||||||
import invariant from 'tiny-invariant';
|
import invariant from 'tiny-invariant';
|
||||||
|
|
||||||
import { parseSrtToSegments, formatSrt, parseCuesheet, parseXmeml, parseFcpXml, parseCsv, parseCutlist, parsePbf, parseMplayerEdl, formatCsvHuman, formatTsv, formatCsvFrames, formatCsvSeconds, parseCsvTime, getFrameValParser, parseDvAnalyzerSummaryTxt } from './edlFormats';
|
import { parseSrtToSegments, formatSrt, parseCuesheet, parseXmeml, parseFcpXml, parseCsv, parseCutlist, parsePbf, parseMplayerEdl, formatCsvHuman, formatTsv, formatCsvFrames, formatCsvSeconds, parseCsvTime, getFrameValParser, parseDvAnalyzerSummaryTxt } from './edlFormats';
|
||||||
@ -9,7 +8,7 @@ import { getOutPath } from './util';
|
|||||||
import { EdlExportType, EdlFileType, EdlImportType, Segment, StateSegment } from './types';
|
import { EdlExportType, EdlFileType, EdlImportType, Segment, StateSegment } from './types';
|
||||||
|
|
||||||
const { readFile, writeFile } = window.require('fs/promises');
|
const { readFile, writeFile } = window.require('fs/promises');
|
||||||
const cueParser: { parse: typeof CueParse } = window.require('cue-parser');
|
const cueParser = window.require('cue-parser');
|
||||||
const { basename } = window.require('path');
|
const { basename } = window.require('path');
|
||||||
|
|
||||||
const { dialog } = window.require('@electron/remote');
|
const { dialog } = window.require('@electron/remote');
|
||||||
@ -85,7 +84,7 @@ export async function saveLlcProject({ savePath, filePath, cutSegments }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function loadLlcProject(path: string) {
|
export async function loadLlcProject(path: string) {
|
||||||
const parsed = JSON5.parse(await readFile(path)) as unknown;
|
const parsed = JSON5.parse(await readFile(path) as unknown as string) as unknown;
|
||||||
if (parsed == null || typeof parsed !== 'object') throw new Error('Invalid LLC file');
|
if (parsed == null || typeof parsed !== 'object') throw new Error('Invalid LLC file');
|
||||||
let mediaFileName: string | undefined;
|
let mediaFileName: string | undefined;
|
||||||
if ('mediaFileName' in parsed && typeof parsed.mediaFileName === 'string') {
|
if ('mediaFileName' in parsed && typeof parsed.mediaFileName === 'string') {
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import dataUriToBuffer from 'data-uri-to-buffer';
|
import dataUriToBuffer from 'data-uri-to-buffer';
|
||||||
import pMap from 'p-map';
|
import pMap from 'p-map';
|
||||||
import { useCallback } from 'react';
|
import { useCallback } from 'react';
|
||||||
import type * as FsPromises from 'node:fs/promises';
|
|
||||||
|
|
||||||
import { getSuffixedOutPath, getOutDir, transferTimestamps, getSuffixedFileName, getOutPath, escapeRegExp, fsOperationWithRetry } from '../util';
|
import { getSuffixedOutPath, getOutDir, transferTimestamps, getSuffixedFileName, getOutPath, escapeRegExp, fsOperationWithRetry } from '../util';
|
||||||
import { getNumDigits } from '../segments';
|
import { getNumDigits } from '../segments';
|
||||||
@ -11,7 +10,7 @@ import { FormatTimecode } from '../types';
|
|||||||
import { CaptureFormat } from '../../../../types';
|
import { CaptureFormat } from '../../../../types';
|
||||||
|
|
||||||
const mime = window.require('mime-types');
|
const mime = window.require('mime-types');
|
||||||
const { rename, readdir, writeFile }: typeof FsPromises = window.require('fs/promises');
|
const { rename, readdir, writeFile } = window.require('fs/promises');
|
||||||
|
|
||||||
|
|
||||||
function getFrameFromVideo(video: HTMLVideoElement, format: CaptureFormat, quality: number) {
|
function getFrameFromVideo(video: HTMLVideoElement, format: CaptureFormat, quality: number) {
|
||||||
|
@ -5,6 +5,12 @@ import { enableMapSet } from 'immer';
|
|||||||
import * as Electron from 'electron';
|
import * as Electron from 'electron';
|
||||||
import Remote from '@electron/remote';
|
import Remote from '@electron/remote';
|
||||||
import type path from 'node:path';
|
import type path from 'node:path';
|
||||||
|
import type fsPromises from 'node:fs/promises';
|
||||||
|
import type fsExtraRaw from 'fs-extra';
|
||||||
|
import type mimeTypes from 'mime-types';
|
||||||
|
import type i18nextFsBackend from 'i18next-fs-backend';
|
||||||
|
import type fileType from 'file-type';
|
||||||
|
import type cueParser from 'cue-parser';
|
||||||
|
|
||||||
import '@fontsource/open-sans/300.css';
|
import '@fontsource/open-sans/300.css';
|
||||||
import '@fontsource/open-sans/300-italic.css';
|
import '@fontsource/open-sans/300-italic.css';
|
||||||
@ -29,6 +35,9 @@ import './main.css';
|
|||||||
import './swal2.scss';
|
import './swal2.scss';
|
||||||
|
|
||||||
|
|
||||||
|
// something wrong with the tyep
|
||||||
|
type FsExtra = typeof fsExtraRaw & { exists: (p: string) => Promise<boolean> };
|
||||||
|
|
||||||
type TypedRemote = Omit<typeof Remote, 'require'> & {
|
type TypedRemote = Omit<typeof Remote, 'require'> & {
|
||||||
require: <T extends string>(module: T) => (
|
require: <T extends string>(module: T) => (
|
||||||
T extends './index.js' ? typeof main :
|
T extends './index.js' ? typeof main :
|
||||||
@ -43,9 +52,15 @@ declare global {
|
|||||||
T extends '@electron/remote' ? TypedRemote :
|
T extends '@electron/remote' ? TypedRemote :
|
||||||
T extends 'electron' ? typeof Electron :
|
T extends 'electron' ? typeof Electron :
|
||||||
T extends 'path' ? typeof path :
|
T extends 'path' ? typeof path :
|
||||||
// todo more
|
T extends 'node:path' ? typeof path :
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
T extends 'fs/promises' ? typeof fsPromises :
|
||||||
any
|
T extends 'node:fs/promises' ? typeof fsPromises :
|
||||||
|
T extends 'fs-extra' ? FsExtra :
|
||||||
|
T extends 'mime-types' ? typeof mimeTypes :
|
||||||
|
T extends 'i18next-fs-backend' ? typeof i18nextFsBackend :
|
||||||
|
T extends 'file-type' ? typeof fileType :
|
||||||
|
T extends 'cue-parser' ? typeof cueParser :
|
||||||
|
never
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,18 +5,15 @@ import prettyBytes from 'pretty-bytes';
|
|||||||
import sortBy from 'lodash/sortBy';
|
import sortBy from 'lodash/sortBy';
|
||||||
import pRetry, { Options } from 'p-retry';
|
import pRetry, { Options } from 'p-retry';
|
||||||
import { ExecaError } from 'execa';
|
import { ExecaError } from 'execa';
|
||||||
import type * as FsPromises from 'node:fs/promises';
|
|
||||||
import type * as FsExtra from 'fs-extra';
|
|
||||||
import type { PlatformPath } from 'node:path';
|
|
||||||
|
|
||||||
import isDev from './isDev';
|
import isDev from './isDev';
|
||||||
import Swal, { errorToast, toast } from './swal';
|
import Swal, { errorToast, toast } from './swal';
|
||||||
import { ffmpegExtractWindow } from './util/constants';
|
import { ffmpegExtractWindow } from './util/constants';
|
||||||
import { appName } from '../../main/common';
|
import { appName } from '../../main/common';
|
||||||
|
|
||||||
const { dirname, parse: parsePath, join, extname, isAbsolute, resolve, basename }: PlatformPath = window.require('path');
|
const { dirname, parse: parsePath, join, extname, isAbsolute, resolve, basename } = window.require('path');
|
||||||
const fsExtra: typeof FsExtra = window.require('fs-extra');
|
const fsExtra = window.require('fs-extra');
|
||||||
const { stat, lstat, readdir, utimes, unlink }: typeof FsPromises = window.require('fs/promises');
|
const { stat, lstat, readdir, utimes, unlink } = window.require('fs/promises');
|
||||||
const { ipcRenderer } = window.require('electron');
|
const { ipcRenderer } = window.require('electron');
|
||||||
const remote = window.require('@electron/remote');
|
const remote = window.require('@electron/remote');
|
||||||
const { isWindows, isMac } = remote.require('./index.js');
|
const { isWindows, isMac } = remote.require('./index.js');
|
||||||
|
@ -2089,6 +2089,13 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
|
"@types/mime-types@npm:^2.1.4":
|
||||||
|
version: 2.1.4
|
||||||
|
resolution: "@types/mime-types@npm:2.1.4"
|
||||||
|
checksum: 10/f8c521c54ee0c0b9f90a65356a80b1413ed27ccdc94f5c7ebb3de5d63cedb559cd2610ea55b4100805c7349606a920d96e54f2d16b2f0afa6b7cd5253967ccc9
|
||||||
|
languageName: node
|
||||||
|
linkType: hard
|
||||||
|
|
||||||
"@types/mime@npm:*":
|
"@types/mime@npm:*":
|
||||||
version: 3.0.4
|
version: 3.0.4
|
||||||
resolution: "@types/mime@npm:3.0.4"
|
resolution: "@types/mime@npm:3.0.4"
|
||||||
@ -7483,6 +7490,7 @@ __metadata:
|
|||||||
"@types/lodash": "npm:^4.14.202"
|
"@types/lodash": "npm:^4.14.202"
|
||||||
"@types/lodash.debounce": "npm:^4"
|
"@types/lodash.debounce": "npm:^4"
|
||||||
"@types/luxon": "npm:^3.4.2"
|
"@types/luxon": "npm:^3.4.2"
|
||||||
|
"@types/mime-types": "npm:^2.1.4"
|
||||||
"@types/morgan": "npm:^1.9.9"
|
"@types/morgan": "npm:^1.9.9"
|
||||||
"@types/node": "npm:18"
|
"@types/node": "npm:18"
|
||||||
"@types/react": "npm:^18.2.66"
|
"@types/react": "npm:^18.2.66"
|
||||||
|
Loading…
Reference in New Issue
Block a user