mirror of
https://github.com/scummvm/scummvm-web.git
synced 2026-05-21 05:40:47 +00:00
DUMPER-COMPANION: More typescript fixes
This commit is contained in:
Generated
+1
-2
@@ -8,6 +8,7 @@
|
||||
"name": "dumper-companion",
|
||||
"version": "0.0.1",
|
||||
"dependencies": {
|
||||
"@types/punycode": "^2.1.4",
|
||||
"@zip.js/zip.js": "^2.8.26",
|
||||
"preact": "^10.29.0",
|
||||
"punycode": "^2.3.1",
|
||||
@@ -18,7 +19,6 @@
|
||||
"devDependencies": {
|
||||
"@eslint/js": "^9.39.1",
|
||||
"@stylistic/eslint-plugin": "^5.7.1",
|
||||
"@types/punycode": "^2.1.4",
|
||||
"eslint": "^9.39.1",
|
||||
"eslint-config-preact": "^2.0.0",
|
||||
"globals": "^17.3.0",
|
||||
@@ -714,7 +714,6 @@
|
||||
"version": "2.1.4",
|
||||
"resolved": "https://registry.npmjs.org/@types/punycode/-/punycode-2.1.4.tgz",
|
||||
"integrity": "sha512-trzh6NzBnq8yw5e35f8xe8VTYjqM3NE7bohBtvDVf/dtUer3zYTLK1Ka3DG3p7bdtoaOHZucma6FfVKlQ134pQ==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@typescript-eslint/eslint-plugin": {
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
"@zip.js/zip.js": "^2.8.26",
|
||||
"preact": "^10.29.0",
|
||||
"punycode": "^2.3.1",
|
||||
"@types/punycode": "^2.1.4",
|
||||
"ts-loader": "^9.5.7",
|
||||
"webpack": "^5.105.4",
|
||||
"webpack-cli": "^7.0.2"
|
||||
@@ -20,7 +21,6 @@
|
||||
"eslint": "^9.39.1",
|
||||
"eslint-config-preact": "^2.0.0",
|
||||
"globals": "^17.3.0",
|
||||
"typescript-eslint": "^8.54.0",
|
||||
"@types/punycode": "^2.1.4"
|
||||
"typescript-eslint": "^8.54.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,8 +44,8 @@ async function dumpVolume(file: ArrayBuffer, s: DumpSettings): Promise<void> {
|
||||
|
||||
export default function Dumper() {
|
||||
type Image = {
|
||||
file: File;
|
||||
name: string;
|
||||
file: File | null;
|
||||
name: string | null;
|
||||
};
|
||||
|
||||
type Progress = {
|
||||
@@ -103,7 +103,11 @@ export default function Dumper() {
|
||||
}
|
||||
|
||||
function handleImage(e: Event): void {
|
||||
const file = (e.target as HTMLInputElement).files[0];
|
||||
const files = (e.target as HTMLInputElement).files;
|
||||
if (!files) {
|
||||
return;
|
||||
}
|
||||
const file = files[0];
|
||||
const name = file.name.replace(/\.\w+$/, '');
|
||||
setImage({file, name});
|
||||
}
|
||||
@@ -124,6 +128,9 @@ export default function Dumper() {
|
||||
}}
|
||||
|
||||
function handleDump(): void {
|
||||
if (!image.file) {
|
||||
return;
|
||||
}
|
||||
starting();
|
||||
log(`Loading volume "${image.name}"...`);
|
||||
const reader = new FileReader();
|
||||
|
||||
@@ -20,12 +20,12 @@ export enum Language {
|
||||
|
||||
export function getLanguages(): string[] {
|
||||
return Object.keys(Language).map(
|
||||
// Typecast to string as the key obviously exists
|
||||
(key: string): string => Language[key] as string);
|
||||
// Typecast to keyof as the key obviously exists
|
||||
(key: string): string => Language[key as keyof typeof Language]);
|
||||
}
|
||||
|
||||
|
||||
export function decodeLanguage(str: Uint8Array, lang: Language, log: (string) => void): string {
|
||||
export function decodeLanguage(str: Uint8Array, lang: Language, log: (_:string) => void): string {
|
||||
switch (lang) {
|
||||
case Language.DA:
|
||||
case Language.NL:
|
||||
@@ -92,7 +92,7 @@ function needsPunycode(str: string) {
|
||||
}
|
||||
|
||||
|
||||
export function encodeFileName(str: Uint8Array, lang: Language, puny: boolean, log: (string) => void): string {
|
||||
export function encodeFileName(str: Uint8Array, lang: Language, puny: boolean, log: (_:string) => void): string {
|
||||
const unicodeStr = decodeLanguage(str, lang, log);
|
||||
|
||||
const forcePunycode = needsPunycode(unicodeStr);
|
||||
@@ -138,7 +138,7 @@ export function decodeMacRoman(str: Uint8Array): string {
|
||||
*/
|
||||
|
||||
/* eslint-disable no-sparse-arrays */
|
||||
const macJapaneseMap: Record<string, string[]> = {
|
||||
const macJapaneseMap: Record<string, (string | undefined)[]> = {
|
||||
'81': [' ','、','。',',','.','・',':',';','?','!','゛','゜','´','`','¨','^',' ̄','_','ヽ','ヾ','ゝ','ゞ','〃','仝','々','〆','〇','ー','—','‐','/','\','〜','‖','|','…','‥','‘','’','“','”','(',')','〔','〕','[',']','{','}','〈','〉','《','》','「','」','『','』','【','】','+','−','±','×',,'÷','=','≠','<','>','≦','≧','∞','∴','♂','♀','°','′','″','℃','¥','$','¢','£','%','#','&','*','@','§','☆','★','○','●','◎','◇','◆','□','■','△','▲','▽','▼','※','〒','→','←','↑','↓','〓',,,,,,,,,,,,'∈','∋','⊆','⊇','⊂','⊃','∪','∩',,,,,,,,,'∧','∨','¬','⇒','⇔','∀','∃',,,,,,,,,,,,'∠','⊥','⌒','∂','∇','≡','≒','≪','≫','√','∽','∝','∵','∫','∬',,,,,,,,'Å','‰','♯','♭','♪','†','‡','¶',,,,,'◯'],
|
||||
'82': [,,,,,,,,,,,,,,,'0','1','2','3','4','5','6','7','8','9',,,,,,,,'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',,,,,,,,'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',,,,,'ぁ','あ','ぃ','い','ぅ','う','ぇ','え','ぉ','お','か','が','き','ぎ','く','ぐ','け','げ','こ','ご','さ','ざ','し','じ','す','ず','せ','ぜ','そ','ぞ','た','だ','ち','ぢ','っ','つ','づ','て','で','と','ど','な','に','ぬ','ね','の','は','ば','ぱ','ひ','び','ぴ','ふ','ぶ','ぷ','へ','べ','ぺ','ほ','ぼ','ぽ','ま','み','む','め','も','ゃ','や','ゅ','ゆ','ょ','よ','ら','り','る','れ','ろ','ゎ','わ','ゐ','ゑ','を','ん'],
|
||||
'83': ['ァ','ア','ィ','イ','ゥ','ウ','ェ','エ','ォ','オ','カ','ガ','キ','ギ','ク','グ','ケ','ゲ','コ','ゴ','サ','ザ','シ','ジ','ス','ズ','セ','ゼ','ソ','ゾ','タ','ダ','チ','ヂ','ッ','ツ','ヅ','テ','デ','ト','ド','ナ','ニ','ヌ','ネ','ノ','ハ','バ','パ','ヒ','ビ','ピ','フ','ブ','プ','ヘ','ベ','ペ','ホ','ボ','ポ','マ','ミ',,'ム','メ','モ','ャ','ヤ','ュ','ユ','ョ','ヨ','ラ','リ','ル','レ','ロ','ヮ','ワ','ヰ','ヱ','ヲ','ン','ヴ','ヵ','ヶ',,,,,,,,,'Α','Β','Γ','Δ','Ε','Ζ','Η','Θ','Ι','Κ','Λ','Μ','Ν','Ξ','Ο','Π','Ρ','Σ','Τ','Υ','Φ','Χ','Ψ','Ω',,,,,,,,,'α','β','γ','δ','ε','ζ','η','θ','ι','κ','λ','μ','ν','ξ','ο','π','ρ','σ','τ','υ','φ','χ','ψ','ω'],
|
||||
@@ -187,7 +187,7 @@ const macJapaneseMap: Record<string, string[]> = {
|
||||
};
|
||||
/* eslint-enable no-sparse-arrays */
|
||||
|
||||
export function decodeMacJapanese(str: Uint8Array, log: (string) => void): string {
|
||||
export function decodeMacJapanese(str: Uint8Array, log: (_:string) => void): string {
|
||||
let res = '';
|
||||
for (let i = 0; i < str.length; i++) {
|
||||
const hi = str[i];
|
||||
|
||||
@@ -85,14 +85,14 @@ export class AbstractFolder {
|
||||
res.push([[name], child]);
|
||||
if (child instanceof AbstractFolder) {
|
||||
for (const [each_path, each_child] of child.iter_paths()) {
|
||||
res.push([[].concat(name, each_path), each_child]);
|
||||
res.push([(<Uint8Array[]>[]).concat(name, each_path), each_child]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
dumpToZip(zipDir: ZipDirectoryEntry, lang: Language, puny: boolean, forceMacBinary: boolean, log: (string) => void): ZipDirectoryEntry {
|
||||
dumpToZip(zipDir: ZipDirectoryEntry, lang: Language, puny: boolean, forceMacBinary: boolean, log: (_: string) => void): ZipDirectoryEntry {
|
||||
for (const [name, child] of this.items()) {
|
||||
const encodedName = encodeFileName(name, lang, puny, log);
|
||||
if (child instanceof AbstractFolder) {
|
||||
@@ -109,7 +109,7 @@ export class AbstractFolder {
|
||||
}
|
||||
}
|
||||
|
||||
function hfs_ts_to_date(hfs_ts) {
|
||||
function hfs_ts_to_date(hfs_ts: number) {
|
||||
const HFS_UTC_OFFSET = 2082844800;
|
||||
if (!hfs_ts) {
|
||||
return new Date();
|
||||
@@ -145,7 +145,7 @@ export class MacFile {
|
||||
mddate: number;
|
||||
bkdate: number;
|
||||
|
||||
aliastarget: FileOrFolder;
|
||||
aliastarget: FileOrFolder | null;
|
||||
|
||||
rsrc: Uint8Array;
|
||||
data: Uint8Array;
|
||||
|
||||
@@ -135,6 +135,8 @@ export class Volume extends AbstractFolder {
|
||||
fork = 'rsrc';
|
||||
else if (xkrFkType === 0)
|
||||
fork = 'data';
|
||||
else
|
||||
throw new Error("Invalid fork type");
|
||||
extoflow[`${xkrFNum},${fork},${xkrFABN}`] = extrec;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { render } from 'preact';
|
||||
import App from './App';
|
||||
|
||||
render(<App/>, document.getElementById('app-container'));
|
||||
render(<App/>, document.getElementById('app-container') as HTMLElement);
|
||||
|
||||
@@ -3,7 +3,7 @@ export function charCode(charStr: string): number {
|
||||
}
|
||||
|
||||
export function codePoint(charStr: string): number {
|
||||
return charStr.codePointAt(0);
|
||||
return charStr.codePointAt(0) || NaN;
|
||||
}
|
||||
|
||||
export function byteToHex(byte: number): string {
|
||||
|
||||
Reference in New Issue
Block a user