@gukhanmun/wasm 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 +75 -0
- package/dist/wasm/deno/README.md +45 -0
- package/dist/wasm/deno/gukhanmun_wasm_bg.wasm +0 -0
- package/dist/wasm/nodejs/README.md +45 -0
- package/dist/wasm/nodejs/gukhanmun_wasm_bg.wasm +0 -0
- package/dist/wasm/nodejs/package.json +1 -1
- package/dist/wasm/web/README.md +45 -0
- package/dist/wasm/web/gukhanmun_wasm_bg.wasm +0 -0
- package/dist/wasm/web/package.json +1 -1
- package/package.json +2 -2
package/README.md
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
@gukhanmun/wasm
|
|
2
|
+
===============
|
|
3
|
+
|
|
4
|
+
WebAssembly implementation of the Gukhanmun hanja-to-hangul converter. Runs in
|
|
5
|
+
any WebAssembly-capable environment: browsers, Deno 2.0+, Node.js 20+, and Bun
|
|
6
|
+
1.0+.
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
Installation
|
|
10
|
+
------------
|
|
11
|
+
|
|
12
|
+
~~~~ sh
|
|
13
|
+
npm install @gukhanmun/wasm
|
|
14
|
+
~~~~
|
|
15
|
+
|
|
16
|
+
For Deno:
|
|
17
|
+
|
|
18
|
+
~~~~ ts
|
|
19
|
+
import { load } from "jsr:@gukhanmun/wasm";
|
|
20
|
+
~~~~
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
Usage
|
|
24
|
+
-----
|
|
25
|
+
|
|
26
|
+
The `load()` factory initializes the WASM module on the first call and caches
|
|
27
|
+
it for all subsequent calls. Dictionary data must be supplied explicitly
|
|
28
|
+
because the WASM bundle does not embed any dictionary.
|
|
29
|
+
|
|
30
|
+
~~~~ ts
|
|
31
|
+
import { load } from "@gukhanmun/wasm";
|
|
32
|
+
import { stdictFst } from "@gukhanmun/stdict-fst";
|
|
33
|
+
|
|
34
|
+
const g = await load({ dictionaries: [await stdictFst()] });
|
|
35
|
+
console.log(g.convert("漢字를 한글로")); // "한자를 한글로"
|
|
36
|
+
~~~~
|
|
37
|
+
|
|
38
|
+
### Streaming
|
|
39
|
+
|
|
40
|
+
~~~~ ts
|
|
41
|
+
const stream = g.convertStream("text/html");
|
|
42
|
+
const writer = stream.writable.getWriter();
|
|
43
|
+
const reader = stream.readable.getReader();
|
|
44
|
+
|
|
45
|
+
await writer.write("<p>漢字</p>");
|
|
46
|
+
await writer.close();
|
|
47
|
+
|
|
48
|
+
const { value } = await reader.read();
|
|
49
|
+
console.log(value); // "<p>한자</p>"
|
|
50
|
+
~~~~
|
|
51
|
+
|
|
52
|
+
### North Korean preset
|
|
53
|
+
|
|
54
|
+
~~~~ ts
|
|
55
|
+
const g = await load({
|
|
56
|
+
preset: "ko-kp",
|
|
57
|
+
dictionaries: [],
|
|
58
|
+
});
|
|
59
|
+
console.log(g.convert("來日")); // "래일"
|
|
60
|
+
~~~~
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
Relation to `@gukhanmun/napi`
|
|
64
|
+
-----------------------------
|
|
65
|
+
|
|
66
|
+
Both packages implement the same `Gukhanmun` interface from `@gukhanmun/types`.
|
|
67
|
+
`@gukhanmun/wasm` works in all environments including browsers;
|
|
68
|
+
`@gukhanmun/napi` uses a native Node.js addon and is faster for server-side
|
|
69
|
+
workloads.
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
License
|
|
73
|
+
-------
|
|
74
|
+
|
|
75
|
+
GPL-3.0-only.
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
gukhanmun-wasm
|
|
2
|
+
==============
|
|
3
|
+
|
|
4
|
+
WebAssembly binding for Gukhanmun, generated with `wasm-bindgen`. Exposes
|
|
5
|
+
`WasmGukhanmun` (an owning converter instance) and `WasmStream` (a streaming
|
|
6
|
+
handle for chunked input) to JavaScript.
|
|
7
|
+
|
|
8
|
+
This crate is the Rust side of the `@gukhanmun/wasm` npm package. End users
|
|
9
|
+
interact with the TypeScript wrapper, not with this crate directly.
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
Exposed types
|
|
13
|
+
-------------
|
|
14
|
+
|
|
15
|
+
`WasmGukhanmun` wraps a `gukhanmun::Converter` and exposes:
|
|
16
|
+
|
|
17
|
+
- `WasmGukhanmun.load(options_json, dicts)`: static factory; `options_json` is
|
|
18
|
+
a JSON-serialized `GukhanmunOptions` object and `dicts` is a JavaScript
|
|
19
|
+
array of `{ format, bytes }` records.
|
|
20
|
+
- `convert(input, format)`: one-shot conversion. `format` is either a MIME
|
|
21
|
+
type string (`"text/plain"`, `"text/html"`, `"text/markdown"`) or a
|
|
22
|
+
`{ format, gfm }` object for Markdown.
|
|
23
|
+
- `openStream(format)`/`streamPush(handle, chunk)`/`streamFinish(handle)`:
|
|
24
|
+
chunked streaming API; `handle` is a `WasmStream` returned by `openStream`.
|
|
25
|
+
|
|
26
|
+
Options and errors are passed as JSON strings so that the TypeScript wrapper
|
|
27
|
+
can reconstruct typed values without depending on wasm-bindgen's JS glue for
|
|
28
|
+
every field.
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
Build notes
|
|
32
|
+
-----------
|
|
33
|
+
|
|
34
|
+
The WASM binary is compiled with `release_max_level_off`, which strips all
|
|
35
|
+
`tracing` calls from the release artifact. This keeps the binary size small
|
|
36
|
+
and avoids a dependency on `console.log` at runtime.
|
|
37
|
+
|
|
38
|
+
`wasm-opt` is run as a post-processing step by `wasm-pack` to reduce the
|
|
39
|
+
binary further.
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
License
|
|
43
|
+
-------
|
|
44
|
+
|
|
45
|
+
GPL-3.0-only. See `LICENSE` at the repository root.
|
|
Binary file
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
gukhanmun-wasm
|
|
2
|
+
==============
|
|
3
|
+
|
|
4
|
+
WebAssembly binding for Gukhanmun, generated with `wasm-bindgen`. Exposes
|
|
5
|
+
`WasmGukhanmun` (an owning converter instance) and `WasmStream` (a streaming
|
|
6
|
+
handle for chunked input) to JavaScript.
|
|
7
|
+
|
|
8
|
+
This crate is the Rust side of the `@gukhanmun/wasm` npm package. End users
|
|
9
|
+
interact with the TypeScript wrapper, not with this crate directly.
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
Exposed types
|
|
13
|
+
-------------
|
|
14
|
+
|
|
15
|
+
`WasmGukhanmun` wraps a `gukhanmun::Converter` and exposes:
|
|
16
|
+
|
|
17
|
+
- `WasmGukhanmun.load(options_json, dicts)`: static factory; `options_json` is
|
|
18
|
+
a JSON-serialized `GukhanmunOptions` object and `dicts` is a JavaScript
|
|
19
|
+
array of `{ format, bytes }` records.
|
|
20
|
+
- `convert(input, format)`: one-shot conversion. `format` is either a MIME
|
|
21
|
+
type string (`"text/plain"`, `"text/html"`, `"text/markdown"`) or a
|
|
22
|
+
`{ format, gfm }` object for Markdown.
|
|
23
|
+
- `openStream(format)`/`streamPush(handle, chunk)`/`streamFinish(handle)`:
|
|
24
|
+
chunked streaming API; `handle` is a `WasmStream` returned by `openStream`.
|
|
25
|
+
|
|
26
|
+
Options and errors are passed as JSON strings so that the TypeScript wrapper
|
|
27
|
+
can reconstruct typed values without depending on wasm-bindgen's JS glue for
|
|
28
|
+
every field.
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
Build notes
|
|
32
|
+
-----------
|
|
33
|
+
|
|
34
|
+
The WASM binary is compiled with `release_max_level_off`, which strips all
|
|
35
|
+
`tracing` calls from the release artifact. This keeps the binary size small
|
|
36
|
+
and avoids a dependency on `console.log` at runtime.
|
|
37
|
+
|
|
38
|
+
`wasm-opt` is run as a post-processing step by `wasm-pack` to reduce the
|
|
39
|
+
binary further.
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
License
|
|
43
|
+
-------
|
|
44
|
+
|
|
45
|
+
GPL-3.0-only. See `LICENSE` at the repository root.
|
|
Binary file
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
gukhanmun-wasm
|
|
2
|
+
==============
|
|
3
|
+
|
|
4
|
+
WebAssembly binding for Gukhanmun, generated with `wasm-bindgen`. Exposes
|
|
5
|
+
`WasmGukhanmun` (an owning converter instance) and `WasmStream` (a streaming
|
|
6
|
+
handle for chunked input) to JavaScript.
|
|
7
|
+
|
|
8
|
+
This crate is the Rust side of the `@gukhanmun/wasm` npm package. End users
|
|
9
|
+
interact with the TypeScript wrapper, not with this crate directly.
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
Exposed types
|
|
13
|
+
-------------
|
|
14
|
+
|
|
15
|
+
`WasmGukhanmun` wraps a `gukhanmun::Converter` and exposes:
|
|
16
|
+
|
|
17
|
+
- `WasmGukhanmun.load(options_json, dicts)`: static factory; `options_json` is
|
|
18
|
+
a JSON-serialized `GukhanmunOptions` object and `dicts` is a JavaScript
|
|
19
|
+
array of `{ format, bytes }` records.
|
|
20
|
+
- `convert(input, format)`: one-shot conversion. `format` is either a MIME
|
|
21
|
+
type string (`"text/plain"`, `"text/html"`, `"text/markdown"`) or a
|
|
22
|
+
`{ format, gfm }` object for Markdown.
|
|
23
|
+
- `openStream(format)`/`streamPush(handle, chunk)`/`streamFinish(handle)`:
|
|
24
|
+
chunked streaming API; `handle` is a `WasmStream` returned by `openStream`.
|
|
25
|
+
|
|
26
|
+
Options and errors are passed as JSON strings so that the TypeScript wrapper
|
|
27
|
+
can reconstruct typed values without depending on wasm-bindgen's JS glue for
|
|
28
|
+
every field.
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
Build notes
|
|
32
|
+
-----------
|
|
33
|
+
|
|
34
|
+
The WASM binary is compiled with `release_max_level_off`, which strips all
|
|
35
|
+
`tracing` calls from the release artifact. This keeps the binary size small
|
|
36
|
+
and avoids a dependency on `console.log` at runtime.
|
|
37
|
+
|
|
38
|
+
`wasm-opt` is run as a post-processing step by `wasm-pack` to reduce the
|
|
39
|
+
binary further.
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
License
|
|
43
|
+
-------
|
|
44
|
+
|
|
45
|
+
GPL-3.0-only. See `LICENSE` at the repository root.
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gukhanmun/wasm",
|
|
3
|
-
"version": "0.1.0-dev.
|
|
3
|
+
"version": "0.1.0-dev.12",
|
|
4
4
|
"description": "WebAssembly implementation of the Gukhanmun hanja-to-hangul converter.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"@gukhanmun/types": "*"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@gukhanmun/types": "0.1.0-dev.
|
|
48
|
+
"@gukhanmun/types": "0.1.0-dev.12+2585cf2de491fd0f8b06f35e0c83fe8a779280cc"
|
|
49
49
|
},
|
|
50
50
|
"scripts": {
|
|
51
51
|
"build": "tsdown && node -e \"const fs=require('node:fs'),p=require('node:path');fs.cpSync('wasm','dist/wasm',{recursive:true,force:true,filter:(s)=>p.basename(s)!=='.gitignore'})\""
|