Skip to content

Commit b5b259e

Browse files
chizukicnchizuki
andauthored
chore: upgrade deps (#2)
* chore: update * chore: update * chore: update * chore: update * chore: update --------- Co-authored-by: chizuki <kritsu@qq.com>
1 parent 60e34cc commit b5b259e

30 files changed

+3498
-3246
lines changed

.eslintignore

Lines changed: 0 additions & 5 deletions
This file was deleted.

.eslintrc

Lines changed: 0 additions & 6 deletions
This file was deleted.

.github/workflows/ci.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: ci
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
branches:
8+
- main
9+
10+
jobs:
11+
ci:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Set git to use LF
15+
run: |
16+
git config --global core.autocrlf false
17+
git config --global core.eol lf
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
- name: Install pnpm
21+
uses: pnpm/action-setup@v4
22+
- name: Setup ni
23+
run: npm add -g @antfu/ni
24+
- name: Install Dependencies
25+
run: nci
26+
- name: Typecheck
27+
run: nr typecheck && nr lint

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,7 @@ node_modules/
22
.idea/
33
dist/
44
yarn-error.log
5-
test-data/
5+
test-data/
6+
.eslintcache
7+
*.NPK
8+
.DS_Store

.husky/pre-commit

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/sh
2+
3+
if [ "$SKIP_SIMPLE_GIT_HOOKS" = "1" ]; then
4+
echo "[INFO] SKIP_SIMPLE_GIT_HOOKS is set to 1, skipping hook."
5+
exit 0
6+
fi
7+
8+
if [ -f "$SIMPLE_GIT_HOOKS_RC" ]; then
9+
. "$SIMPLE_GIT_HOOKS_RC"
10+
fi
11+
12+
npx lint-staged

build.config.ts

Lines changed: 0 additions & 14 deletions
This file was deleted.

eslint.config.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { curev } from "@curev/eslint-config";
2+
3+
export default curev({
4+
unocss: false
5+
});

example/extract.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import type { Img } from "../src/model/img";
2+
import fs from "node:fs";
3+
import path from "node:path";
4+
import process from "node:process";
5+
import { Extract } from "../src";
6+
7+
function getNumber(s: string) {
8+
return Number.parseInt(s.replace(/[^\d+]/g, ""));
9+
}
10+
(async () => {
11+
const createMatch = (code1: number) => {
12+
return (item: Img) => {
13+
const code0 = getNumber(item.path);
14+
if (code0 === code1) {
15+
return true;
16+
}
17+
return code0 % 100 === 0 && Math.floor(code0 / 100) === Math.floor(code1 / 100);
18+
};
19+
};
20+
fs.createReadStream(path.resolve(process.cwd(), "sprite_character_swordman_equipment_avatar_pants.NPK"))
21+
.pipe(new Extract({
22+
match: createMatch(5603)
23+
}))
24+
.on("finish", (list: Img[]) => {
25+
const sprite = list[0].sprites[0];
26+
sprite.toPng(path.resolve(process.cwd(), "test-data/test.png"));
27+
});
28+
})();

example/find.ts

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,16 @@
1-
/***
2-
@author kritsu
3-
@date 2019/12/6 12:27
4-
**/
1+
import type { Img } from "../src/model/img";
52

6-
import fs from "fs";
3+
import fs from "node:fs";
74

8-
import qs from "querystring";
5+
import path from "node:path";
6+
import qs from "node:querystring";
97

10-
import path from "path";
118
import { Extract } from "../src";
129

13-
import type { Img } from "../src/model/img";
14-
1510
export function find(outputPath: string, profession: string, code: string, excludes: string[] = []) {
1611
const parts = qs.parse(code) as Record<string, string>;
1712

18-
excludes.forEach(e => delete parts[e]);
13+
excludes.forEach((e) => delete parts[e]);
1914

2015
const entries = Object.entries(parts);
2116

@@ -37,7 +32,7 @@ export function find(outputPath: string, profession: string, code: string, exclu
3732
fs.createReadStream(path.resolve(outputPath, f))
3833
.pipe(new Extract({ match }))
3934
.on("finish", (list: Img[]) => {
40-
list = list.map(e => {
35+
list = list.map((e) => {
4136
const index = code1 % 100;
4237
e.path = replacePath(e.path, code1);
4338
e.paletteIndex = index;
@@ -47,7 +42,8 @@ export function find(outputPath: string, profession: string, code: string, exclu
4742
if (array.length === entries.length) {
4843
resolve(Array.from(array.flat()));
4944
}
50-
}).on("error", e => {
45+
})
46+
.on("error", (e) => {
5147
reject(e);
5248
});
5349
});
@@ -70,7 +66,6 @@ function getDressFileName(profession: string, part: string, type = "avatar") {
7066
return `sprite_character_${profession}equipment_${type}_${part}.NPK`;
7167
}
7268

73-
function getNumber(s) {
74-
return parseInt(s.replace(/[^\d+]/ig, ""));
69+
function getNumber(s: string) {
70+
return Number.parseInt(s.replace(/[^\d+]/g, ""));
7571
}
76-

example/index.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
1-
/***
2-
@author kritsu
3-
@date 2020/2/7 14:40
4-
**/
5-
6-
import { Merge } from "../src";
71
import type { Img } from "../src/model/img";
2+
import { Merge } from "../src";
83
import { find } from "./find";
94

10-
const outputPath = "E:\\WeGameApps\\地下城与勇士\\ImagePacks2";
5+
const outputPath = "F:\\WeGameApps\\地下城与勇士:创新世纪\\ImagePacks2";
116

12-
const code = "hair=11200&coat=17000&skin=0000&pants=5603&shoes=9900";
7+
const code = "pants=5603";
138

149
const profession = "swordman";
1510

@@ -20,9 +15,8 @@ const profession = "swordman";
2015
img.path = "test.img";
2116
const first = img.sprites[0];
2217

23-
first.toPng("D:/test.png");
18+
first.toPng("./test-data/test.png");
2419

2520
// eslint-disable-next-line no-console
2621
console.info(`${performance.now() - start}ms`);
2722
})();
28-

0 commit comments

Comments
 (0)