@gukhanmun/napi 0.1.0-dev.0 → 0.1.0-dev.12
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/README.md +67 -0
- package/dist/index.js +2 -2
- package/package.json +8 -8
package/README.md
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
@gukhanmun/napi
|
|
2
|
+
===============
|
|
3
|
+
|
|
4
|
+
Node.js native addon implementation of the Gukhanmun hanja-to-hangul converter,
|
|
5
|
+
built with napi-rs. Requires Node.js 20+. For environments other than Node.js
|
|
6
|
+
(browsers, Deno, Bun via WASM), use `@gukhanmun/wasm` instead.
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
Installation
|
|
10
|
+
------------
|
|
11
|
+
|
|
12
|
+
~~~~ sh
|
|
13
|
+
npm install @gukhanmun/napi
|
|
14
|
+
~~~~
|
|
15
|
+
|
|
16
|
+
The package declares six optional platform dependencies
|
|
17
|
+
(`@gukhanmun/napi-aarch64-apple-darwin`, `@gukhanmun/napi-x86_64-apple-darwin`,
|
|
18
|
+
etc.). npm installs only the one matching the current OS, CPU architecture, and
|
|
19
|
+
libc variant. The supported targets are:
|
|
20
|
+
|
|
21
|
+
| Target | OS | Architecture |
|
|
22
|
+
| -------------------------- | ------------ | ------------ |
|
|
23
|
+
| aarch64-apple-darwin | macOS | ARM64 |
|
|
24
|
+
| x86\_64-apple-darwin | macOS | x86\_64 |
|
|
25
|
+
| aarch64-pc-windows-msvc | Windows | ARM64 |
|
|
26
|
+
| x86\_64-pc-windows-msvc | Windows | x86\_64 |
|
|
27
|
+
| aarch64-unknown-linux-gnu | Linux (glibc) | ARM64 |
|
|
28
|
+
| x86\_64-unknown-linux-gnu | Linux (glibc) | x86\_64 |
|
|
29
|
+
|
|
30
|
+
musl Linux (Alpine, etc.) is not covered by a prebuilt binary. Build from
|
|
31
|
+
source with `mise run napi-build` on those platforms.
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
Usage
|
|
35
|
+
-----
|
|
36
|
+
|
|
37
|
+
~~~~ ts
|
|
38
|
+
import { load } from "@gukhanmun/napi";
|
|
39
|
+
import { stdictFst } from "@gukhanmun/stdict-fst";
|
|
40
|
+
|
|
41
|
+
const g = await load({ dictionaries: [await stdictFst()] });
|
|
42
|
+
console.log(g.convert("漢字를 한글로")); // "한자를 한글로"
|
|
43
|
+
~~~~
|
|
44
|
+
|
|
45
|
+
The `load()` factory is asynchronous for API uniformity with `@gukhanmun/wasm`,
|
|
46
|
+
but the native addon itself is synchronous. The async part covers reading the
|
|
47
|
+
dictionary bytes from disk.
|
|
48
|
+
|
|
49
|
+
### Streaming
|
|
50
|
+
|
|
51
|
+
~~~~ ts
|
|
52
|
+
const stream = g.convertStream("text/html");
|
|
53
|
+
const writer = stream.writable.getWriter();
|
|
54
|
+
const reader = stream.readable.getReader();
|
|
55
|
+
|
|
56
|
+
await writer.write("<p>漢字</p>");
|
|
57
|
+
await writer.close();
|
|
58
|
+
|
|
59
|
+
const { value } = await reader.read();
|
|
60
|
+
console.log(value); // "<p>한자</p>"
|
|
61
|
+
~~~~
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
License
|
|
65
|
+
-------
|
|
66
|
+
|
|
67
|
+
GPL-3.0-only.
|
package/dist/index.js
CHANGED
|
@@ -34,8 +34,8 @@ function detectPlatformPackage() {
|
|
|
34
34
|
"darwin-x64": "x86_64-apple-darwin",
|
|
35
35
|
"win32-arm64": "aarch64-pc-windows-msvc",
|
|
36
36
|
"win32-x64": "x86_64-pc-windows-msvc",
|
|
37
|
-
"linux-arm64": "aarch64-unknown-linux-
|
|
38
|
-
"linux-x64": "x86_64-unknown-linux-
|
|
37
|
+
"linux-arm64": "aarch64-unknown-linux-gnu",
|
|
38
|
+
"linux-x64": "x86_64-unknown-linux-gnu"
|
|
39
39
|
};
|
|
40
40
|
const key = `${process.platform}-${process.arch}`;
|
|
41
41
|
const target = map[key];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gukhanmun/napi",
|
|
3
|
-
"version": "0.1.0-dev.
|
|
3
|
+
"version": "0.1.0-dev.12",
|
|
4
4
|
"description": "Node.js native addon (napi-rs) for the Gukhanmun hanja-to-hangul converter.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -14,12 +14,12 @@
|
|
|
14
14
|
"dist"
|
|
15
15
|
],
|
|
16
16
|
"optionalDependencies": {
|
|
17
|
-
"@gukhanmun/napi-aarch64-apple-darwin": "0.1.0-dev.
|
|
18
|
-
"@gukhanmun/napi-x86_64-apple-darwin": "0.1.0-dev.
|
|
19
|
-
"@gukhanmun/napi-aarch64-pc-windows-msvc": "0.1.0-dev.
|
|
20
|
-
"@gukhanmun/napi-x86_64-
|
|
21
|
-
"@gukhanmun/napi-
|
|
22
|
-
"@gukhanmun/napi-
|
|
17
|
+
"@gukhanmun/napi-aarch64-apple-darwin": "0.1.0-dev.12+2585cf2de491fd0f8b06f35e0c83fe8a779280cc",
|
|
18
|
+
"@gukhanmun/napi-x86_64-apple-darwin": "0.1.0-dev.12+2585cf2de491fd0f8b06f35e0c83fe8a779280cc",
|
|
19
|
+
"@gukhanmun/napi-aarch64-pc-windows-msvc": "0.1.0-dev.12+2585cf2de491fd0f8b06f35e0c83fe8a779280cc",
|
|
20
|
+
"@gukhanmun/napi-x86_64-unknown-linux-gnu": "0.1.0-dev.12+2585cf2de491fd0f8b06f35e0c83fe8a779280cc",
|
|
21
|
+
"@gukhanmun/napi-x86_64-pc-windows-msvc": "0.1.0-dev.12+2585cf2de491fd0f8b06f35e0c83fe8a779280cc",
|
|
22
|
+
"@gukhanmun/napi-aarch64-unknown-linux-gnu": "0.1.0-dev.12+2585cf2de491fd0f8b06f35e0c83fe8a779280cc"
|
|
23
23
|
},
|
|
24
24
|
"homepage": "https://github.com/dahlia/gukhanmun",
|
|
25
25
|
"bugs": "https://github.com/dahlia/gukhanmun/issues",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"@gukhanmun/types": "*"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@gukhanmun/types": "0.1.0-dev.
|
|
55
|
+
"@gukhanmun/types": "0.1.0-dev.12+2585cf2de491fd0f8b06f35e0c83fe8a779280cc"
|
|
56
56
|
},
|
|
57
57
|
"scripts": {
|
|
58
58
|
"build": "tsdown"
|