@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/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Shigma
|
|
4
|
+
Copyright (c) 2026 ChatLunaLab
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,47 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @chatluna/qface
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A maintenance fork of [`qface`](https://github.com/koishijs/QFace) (MIT, Shigma). The QQ system face table: 275 faces with their ids, Chinese names and pinyin shortcuts, plus the url each one is served as. Zero dependencies, Node 20+.
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
npm install @chatluna/qface
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
import { data, findFace, getFace, getFaceUrl } from '@chatluna/qface'
|
|
11
|
+
|
|
12
|
+
getFace(14) // { QSid: '14', QDes: '/微笑', EMCode: '100', Input: ['weixiao', 'wx'], … }
|
|
13
|
+
findFace('jk') // '26', also 'jingkong', '/微笑', 'wx'…
|
|
14
|
+
getFaceUrl(178) // https://koishi.js.org/QFace/gif/s178.gif
|
|
15
|
+
getFaceUrl(347) // https://koishi.js.org/QFace/static/s347.png — isStatic faces are png
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## API
|
|
19
|
+
|
|
20
|
+
### `data`
|
|
21
|
+
|
|
22
|
+
The whole `Face[]` table, keyed by the string `QSid`. A face carries `QDes` (the `/`-prefixed Chinese name), the historical `IQLid`/`AQLid`/`EMCode` codes, and optional flags: `isStatic` for faces that only exist as a png, `AniStickerType`/`AniStickerId` for the animated-sticker faces, `QHide` for faces not in the picker. `Input` lists the pinyin inputs, full spellings before abbreviations, and is absent on the newest faces.
|
|
23
|
+
|
|
24
|
+
### `getFace(id)`
|
|
25
|
+
|
|
26
|
+
The face with `QSid === String(id)`, or `undefined`.
|
|
27
|
+
|
|
28
|
+
### `findFace(input)`
|
|
29
|
+
|
|
30
|
+
The `QSid` of the first face matching `input`, or `null`. Matches, in order: a `QDes` equal to the input (a leading `/` on the input is ignored), an exact `Input` entry, then an `Input` entry that starts with the input — so `'j'` finds `/惊恐` first because its `Input` starts with `jk`.
|
|
31
|
+
|
|
32
|
+
### `getFaceUrl(id, base?)`
|
|
33
|
+
|
|
34
|
+
`{base}/gif/s{id}.gif`, or `{base}/static/s{id}.png` when `isStatic` is set. `base` defaults to `https://koishi.js.org/QFace`, the public mirror; pass your own host to serve the images yourself. Returns `''` for an unknown id.
|
|
35
|
+
|
|
36
|
+
## Sync
|
|
37
|
+
|
|
38
|
+
`src/data.json` is a checked-in copy of `lib/data.json` from [koishijs/QFace](https://github.com/koishijs/QFace). Refresh it with:
|
|
39
|
+
|
|
40
|
+
```sh
|
|
41
|
+
yarn sync # fetches the current table and rewrites src/data.json
|
|
42
|
+
yarn test # builds lib/ and runs the unit tests
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## License
|
|
46
|
+
|
|
47
|
+
MIT
|
package/lib/data.d.ts
ADDED
package/lib/data.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// data.json is authored upstream (github.com/koishijs/QFace) and synced by `yarn sync`;
|
|
2
|
+
// it is typed at this boundary rather than asserted field by field.
|
|
3
|
+
import { readFileSync } from 'node:fs';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
5
|
+
export const data = JSON.parse(readFileSync(fileURLToPath(new URL('./data.json', import.meta.url)), 'utf8'));
|