@chatluna/qface 0.0.0-stage → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -0
- package/README.md +46 -2
- package/lib/data.d.ts +2 -0
- package/lib/data.js +5 -0
- package/lib/data.json +3083 -0
- package/lib/index.d.ts +23 -0
- package/lib/index.js +21 -0
- package/package.json +50 -4
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { data } from './data.ts';
|
|
2
|
+
export interface Face {
|
|
3
|
+
/** Face id, the `sid` in a QQ face element. */
|
|
4
|
+
QSid: string;
|
|
5
|
+
/** Chinese display name with a leading `/`. */
|
|
6
|
+
QDes: string;
|
|
7
|
+
IQLid: string;
|
|
8
|
+
AQLid: string;
|
|
9
|
+
EMCode: string;
|
|
10
|
+
/** `'1'` when the face is served as a png instead of a gif. */
|
|
11
|
+
isStatic?: '1';
|
|
12
|
+
isCMEmoji?: '1';
|
|
13
|
+
AniStickerType?: 1;
|
|
14
|
+
AniStickerPackId?: '1';
|
|
15
|
+
AniStickerId?: string;
|
|
16
|
+
QHide?: '1';
|
|
17
|
+
/** Pinyin aliases accepted by `findFace`, full name first then abbreviations. */
|
|
18
|
+
Input?: string[];
|
|
19
|
+
}
|
|
20
|
+
export { data };
|
|
21
|
+
export declare function getFace(id: string | number): Face | undefined;
|
|
22
|
+
export declare function findFace(input: string): string | null;
|
|
23
|
+
export declare function getFaceUrl(id: string | number, base?: string): string;
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// The table lives in data.json and is synced from github.com/koishijs/QFace by `yarn sync`.
|
|
2
|
+
import { data } from './data.js';
|
|
3
|
+
export { data };
|
|
4
|
+
export function getFace(id) {
|
|
5
|
+
const sid = String(id);
|
|
6
|
+
return data.find((el) => el.QSid === sid);
|
|
7
|
+
}
|
|
8
|
+
export function findFace(input) {
|
|
9
|
+
if (input[0] === '/')
|
|
10
|
+
input = input.substring(1);
|
|
11
|
+
const match = data.find((el) => el.QDes.substring(1) === input) ||
|
|
12
|
+
data.find((el) => el.Input?.includes(input)) ||
|
|
13
|
+
data.find((el) => el.Input?.some((i) => i.startsWith(input)));
|
|
14
|
+
return match ? match.QSid : null;
|
|
15
|
+
}
|
|
16
|
+
export function getFaceUrl(id, base = 'https://koishi.js.org/QFace') {
|
|
17
|
+
const item = getFace(id);
|
|
18
|
+
if (!item)
|
|
19
|
+
return '';
|
|
20
|
+
return `${base}${item.isStatic ? `/static/s${id}.png` : `/gif/s${id}.gif`}`;
|
|
21
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,52 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chatluna/qface",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.4.1",
|
|
4
|
+
"description": "Tencent QQ system face catalog: ids, names and pinyin shortcuts, with links to the gif or png each face is served as. Maintenance fork of koishijs/QFace",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/ChatLunaLab/qface.git"
|
|
10
|
+
},
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/ChatLunaLab/qface/issues"
|
|
13
|
+
},
|
|
14
|
+
"keywords": [
|
|
15
|
+
"qface",
|
|
16
|
+
"tencent",
|
|
17
|
+
"qq",
|
|
18
|
+
"face",
|
|
19
|
+
"oicq",
|
|
20
|
+
"emoji",
|
|
21
|
+
"reaction",
|
|
22
|
+
"chatluna"
|
|
23
|
+
],
|
|
24
|
+
"main": "lib/index.js",
|
|
25
|
+
"types": "lib/index.d.ts",
|
|
26
|
+
"exports": {
|
|
27
|
+
".": {
|
|
28
|
+
"types": "./lib/index.d.ts",
|
|
29
|
+
"default": "./lib/index.js"
|
|
30
|
+
},
|
|
31
|
+
"./data.json": "./lib/data.json",
|
|
32
|
+
"./package.json": "./package.json"
|
|
33
|
+
},
|
|
34
|
+
"files": [
|
|
35
|
+
"lib"
|
|
36
|
+
],
|
|
37
|
+
"engines": {
|
|
38
|
+
"node": ">=20"
|
|
39
|
+
},
|
|
40
|
+
"scripts": {
|
|
41
|
+
"build": "tsc -p tsconfig.build.json && cp src/data.json lib/data.json",
|
|
42
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
43
|
+
"test": "yarn build && node --test tests/*.test.ts",
|
|
44
|
+
"sync": "node scripts/sync.ts",
|
|
45
|
+
"prepack": "yarn build"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"@types/node": "^24.13.3",
|
|
49
|
+
"typescript": "7.0.2"
|
|
50
|
+
},
|
|
51
|
+
"packageManager": "yarn@4.18.0"
|
|
52
|
+
}
|