@gukhanmun/napi 0.1.0-dev.15 → 0.1.0-dev.18
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/dist/index.d.ts +26 -4
- package/dist/index.js +11 -6
- package/package.json +8 -8
package/dist/index.d.ts
CHANGED
|
@@ -123,6 +123,19 @@ type NumeralStrategy = "hangul-phonetic" | "positional-arabic" | "additive-arabi
|
|
|
123
123
|
* accuracy matters more than latency.
|
|
124
124
|
*/
|
|
125
125
|
type ContextWindow = "off" | "per-block" | "per-section" | "per-document";
|
|
126
|
+
/**
|
|
127
|
+
* Selects how the homophone marker decides that a reading needs its hanja shown
|
|
128
|
+
* in `rendering: "hangul-only"`. Corresponds to Rust `HomophoneDetection`.
|
|
129
|
+
*
|
|
130
|
+
* - `"context-local"` — Gloss a reading only when a different-meaning homophone
|
|
131
|
+
* actually appears within the {@link ContextWindow}. This keeps hangul-only
|
|
132
|
+
* output clean and is the default.
|
|
133
|
+
* - `"dictionary-wide"` — Also gloss readings shared by other hanja forms
|
|
134
|
+
* anywhere in the dictionary, even when no homophone appears in the text.
|
|
135
|
+
* With a large reference dictionary this glosses most Sino-Korean words; words
|
|
136
|
+
* that should always be glossed are better expressed with `requireHanja`.
|
|
137
|
+
*/
|
|
138
|
+
type HomophoneDetection = "context-local" | "dictionary-wide";
|
|
126
139
|
/**
|
|
127
140
|
* Controls how the pipeline handles reader errors encountered during HTML
|
|
128
141
|
* scanning. Corresponds to Rust `Recovery`.
|
|
@@ -324,13 +337,22 @@ interface GukhanmunOptions {
|
|
|
324
337
|
readonly initialSoundLaw?: boolean;
|
|
325
338
|
/**
|
|
326
339
|
* Context window for homophone disambiguation. The `HomophoneMarker`
|
|
327
|
-
* middleware sets `homophone = true` on annotations whose hangul reading
|
|
328
|
-
*
|
|
329
|
-
* `"per-block"`.
|
|
340
|
+
* middleware sets `homophone = true` on annotations whose hangul reading
|
|
341
|
+
* collides within this window. Defaults to `"per-block"`.
|
|
330
342
|
*
|
|
331
343
|
* @see {@link ContextWindow}
|
|
332
344
|
*/
|
|
333
345
|
readonly homophoneWindow?: ContextWindow;
|
|
346
|
+
/**
|
|
347
|
+
* Strategy that decides which readings count as homophones needing a hanja
|
|
348
|
+
* gloss. Defaults to `"context-local"`, which glosses a reading only when a
|
|
349
|
+
* different-meaning homophone appears within {@link homophoneWindow}. Use
|
|
350
|
+
* `"dictionary-wide"` to also gloss readings shared by other dictionary
|
|
351
|
+
* entries.
|
|
352
|
+
*
|
|
353
|
+
* @see {@link HomophoneDetection}
|
|
354
|
+
*/
|
|
355
|
+
readonly homophoneDetection?: HomophoneDetection;
|
|
334
356
|
/**
|
|
335
357
|
* Context window for first-occurrence filtering. The
|
|
336
358
|
* `FirstOccurrenceFilter` middleware clears `requireHanja` /
|
|
@@ -571,4 +593,4 @@ declare class GukhanmunError extends Error {
|
|
|
571
593
|
*/
|
|
572
594
|
declare function load(options?: GukhanmunOptions): Promise<Gukhanmun>;
|
|
573
595
|
//#endregion
|
|
574
|
-
export { type ContextWindow, type DictionaryEntry, type DictionarySource, type Directives, type ErrorCode, type FileDictionarySource, type Format, type Gukhanmun, GukhanmunError, type GukhanmunFactory, type GukhanmunOptions, type HtmlOptions, type NumeralStrategy, type OriginalGloss, type Preset, type Recovery, type RenderMode, type Segmentation, load };
|
|
596
|
+
export { type ContextWindow, type DictionaryEntry, type DictionarySource, type Directives, type ErrorCode, type FileDictionarySource, type Format, type Gukhanmun, GukhanmunError, type GukhanmunFactory, type GukhanmunOptions, type HomophoneDetection, type HtmlOptions, type NumeralStrategy, type OriginalGloss, type Preset, type Recovery, type RenderMode, type Segmentation, load };
|
package/dist/index.js
CHANGED
|
@@ -45,19 +45,22 @@ function detectPlatformPackage() {
|
|
|
45
45
|
/**
|
|
46
46
|
* Loads the native addon at module initialisation time.
|
|
47
47
|
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
48
|
+
* A locally-built binary (produced by `mise run napi-build`) is tried first so
|
|
49
|
+
* development and CI exercise the freshly compiled addon; a stale platform
|
|
50
|
+
* optional-dependency binary must never shadow it. A published install ships
|
|
51
|
+
* only `dist/` (see the package `files` field), so no local binary is present
|
|
52
|
+
* there and resolution falls through to the platform-specific optional
|
|
53
|
+
* dependency.
|
|
51
54
|
*/
|
|
52
55
|
const nativeAddon = (() => {
|
|
53
56
|
const req = createRequire(import.meta.url);
|
|
54
57
|
try {
|
|
55
|
-
return req(
|
|
58
|
+
return req("./gukhanmun_napi.node");
|
|
56
59
|
} catch {
|
|
57
60
|
try {
|
|
58
|
-
return req("./gukhanmun_napi.node");
|
|
59
|
-
} catch {
|
|
60
61
|
return req("../gukhanmun_napi.node");
|
|
62
|
+
} catch {
|
|
63
|
+
return req(detectPlatformPackage());
|
|
61
64
|
}
|
|
62
65
|
}
|
|
63
66
|
})();
|
|
@@ -154,6 +157,7 @@ function resolveOptions(opts = {}) {
|
|
|
154
157
|
numerals: opts.numerals ?? "hangul-phonetic",
|
|
155
158
|
initialSoundLaw: opts.initialSoundLaw ?? (koKp ? false : true),
|
|
156
159
|
homophoneWindow: opts.homophoneWindow ?? (koKp ? "off" : "per-block"),
|
|
160
|
+
homophoneDetection: opts.homophoneDetection ?? "context-local",
|
|
157
161
|
firstOccurrenceWindow: opts.firstOccurrenceWindow ?? "off",
|
|
158
162
|
recovery: opts.recovery ?? "strict"
|
|
159
163
|
};
|
|
@@ -166,6 +170,7 @@ function buildRawOptions(opts, resolved) {
|
|
|
166
170
|
numerals: resolved.numerals,
|
|
167
171
|
initialSoundLaw: resolved.initialSoundLaw,
|
|
168
172
|
homophoneWindow: resolved.homophoneWindow,
|
|
173
|
+
homophoneDetection: resolved.homophoneDetection,
|
|
169
174
|
firstOccurrenceWindow: resolved.firstOccurrenceWindow,
|
|
170
175
|
recovery: resolved.recovery
|
|
171
176
|
};
|
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.18",
|
|
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-
|
|
20
|
-
"@gukhanmun/napi-x86_64-unknown-linux-gnu": "0.1.0-dev.
|
|
21
|
-
"@gukhanmun/napi-aarch64-
|
|
22
|
-
"@gukhanmun/napi-x86_64-pc-windows-msvc": "0.1.0-dev.
|
|
17
|
+
"@gukhanmun/napi-aarch64-apple-darwin": "0.1.0-dev.18+25611433dc656544ad355f3b96f45650c351cab9",
|
|
18
|
+
"@gukhanmun/napi-x86_64-apple-darwin": "0.1.0-dev.18+25611433dc656544ad355f3b96f45650c351cab9",
|
|
19
|
+
"@gukhanmun/napi-aarch64-unknown-linux-gnu": "0.1.0-dev.18+25611433dc656544ad355f3b96f45650c351cab9",
|
|
20
|
+
"@gukhanmun/napi-x86_64-unknown-linux-gnu": "0.1.0-dev.18+25611433dc656544ad355f3b96f45650c351cab9",
|
|
21
|
+
"@gukhanmun/napi-aarch64-pc-windows-msvc": "0.1.0-dev.18+25611433dc656544ad355f3b96f45650c351cab9",
|
|
22
|
+
"@gukhanmun/napi-x86_64-pc-windows-msvc": "0.1.0-dev.18+25611433dc656544ad355f3b96f45650c351cab9"
|
|
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.18+25611433dc656544ad355f3b96f45650c351cab9"
|
|
56
56
|
},
|
|
57
57
|
"scripts": {
|
|
58
58
|
"build": "tsdown"
|