@gukhanmun/napi 0.4.0-dev.245 → 0.4.0-dev.255
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 +2 -2
- package/dist/index.js +12 -2
- package/package.json +8 -8
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ContextWindow, CustomPunctuationProfile, DelimiterStyle, DictionaryEntry, DictionarySource, Directives, ErrorCode, ErrorCode as ErrorCode$1, FileDictionarySource, Format, Gukhanmun, Gukhanmun as Gukhanmun$1, GukhanmunFactory, GukhanmunOptions, GukhanmunOptions as GukhanmunOptions$1, HanjaVariantSet, HomophoneDetection, HtmlOptions, MapDictionarySource, NumeralStrategy, OriginalGloss, Preset, PunctuationPreset, Recovery, RenderMode, ResolvedPunctuationProfile, Segmentation, SpaceAfter, StopStyle } from "@gukhanmun/types";
|
|
1
|
+
import { ContextWindow, CustomPunctuationProfile, DelimiterStyle, DictionaryEntry, DictionarySource, Directives, ErrorCode, ErrorCode as ErrorCode$1, FileDictionarySource, Format, Gukhanmun, Gukhanmun as Gukhanmun$1, GukhanmunFactory, GukhanmunOptions, GukhanmunOptions as GukhanmunOptions$1, HanjaVariantSet, HomophoneDetection, HtmlOptions, MapDictionarySource, NumeralStrategy, OriginalGloss, Preset, PunctuationPreset, Recovery, RenderMode, ResolvedPunctuationProfile, Segmentation, SourcePolicy, SourceRole, SpaceAfter, StopStyle } from "@gukhanmun/types";
|
|
2
2
|
/**
|
|
3
3
|
* Error thrown by `{@link load}`, `{@link Gukhanmun.convert}`, and
|
|
4
4
|
* `{@link Gukhanmun.stream}` when the Rust engine reports a failure.
|
|
@@ -53,4 +53,4 @@ export declare class GukhanmunError extends Error {
|
|
|
53
53
|
* @throws {@link GukhanmunError} on invalid options or dictionary load failure.
|
|
54
54
|
*/
|
|
55
55
|
export declare function load(options?: GukhanmunOptions$1): Promise<Gukhanmun$1>;
|
|
56
|
-
export type { ContextWindow, CustomPunctuationProfile, DelimiterStyle, DictionaryEntry, DictionarySource, Directives, ErrorCode, FileDictionarySource, Format, Gukhanmun, GukhanmunFactory, GukhanmunOptions, HanjaVariantSet, HomophoneDetection, HtmlOptions, MapDictionarySource, NumeralStrategy, OriginalGloss, Preset, PunctuationPreset, Recovery, RenderMode, ResolvedPunctuationProfile, Segmentation, SpaceAfter, StopStyle };
|
|
56
|
+
export type { ContextWindow, CustomPunctuationProfile, DelimiterStyle, DictionaryEntry, DictionarySource, Directives, ErrorCode, FileDictionarySource, Format, Gukhanmun, GukhanmunFactory, GukhanmunOptions, HanjaVariantSet, HomophoneDetection, HtmlOptions, MapDictionarySource, NumeralStrategy, OriginalGloss, Preset, PunctuationPreset, Recovery, RenderMode, ResolvedPunctuationProfile, Segmentation, SourcePolicy, SourceRole, SpaceAfter, StopStyle };
|
package/dist/index.js
CHANGED
|
@@ -157,9 +157,14 @@ function encodeEntries(entries) {
|
|
|
157
157
|
}
|
|
158
158
|
async function resolveDictionary(source) {
|
|
159
159
|
if (typeof source !== "object" || source === null) throw new GukhanmunError("invalid-input", "Each dictionary must be an object");
|
|
160
|
+
const role = source.role;
|
|
161
|
+
if (role !== void 0 && role !== "override" && role !== "reference" && role !== "loanword") throw new GukhanmunError("invalid-input", `Unknown dictionary source role: ${String(role)}`);
|
|
160
162
|
if ("entries" in source) {
|
|
161
163
|
if ("format" in source || "data" in source) throw new GukhanmunError("invalid-input", "A dictionary must not combine 'entries' with 'format' or 'data'");
|
|
162
|
-
return {
|
|
164
|
+
return {
|
|
165
|
+
entriesJson: encodeEntries(source.entries),
|
|
166
|
+
role
|
|
167
|
+
};
|
|
163
168
|
}
|
|
164
169
|
let bytes;
|
|
165
170
|
if (source.data instanceof ArrayBuffer) bytes = Buffer.from(source.data);
|
|
@@ -191,7 +196,8 @@ async function resolveDictionary(source) {
|
|
|
191
196
|
}
|
|
192
197
|
return {
|
|
193
198
|
format: source.format,
|
|
194
|
-
bytes
|
|
199
|
+
bytes,
|
|
200
|
+
role
|
|
195
201
|
};
|
|
196
202
|
}
|
|
197
203
|
function resolveOptions(opts = {}) {
|
|
@@ -208,6 +214,8 @@ function resolveOptions(opts = {}) {
|
|
|
208
214
|
rendering: opts.rendering ?? "hangul-only",
|
|
209
215
|
hanjaVariantSet: opts.hanjaVariantSet ?? "as-dictionary",
|
|
210
216
|
segmentation: opts.segmentation ?? "lattice",
|
|
217
|
+
sourcePolicy: opts.sourcePolicy ?? "reference-authorized",
|
|
218
|
+
referenceOnly: opts.referenceOnly ?? false,
|
|
211
219
|
numerals: opts.numerals ?? "hangul-phonetic",
|
|
212
220
|
initialSoundLaw: opts.initialSoundLaw ?? (koKp ? false : true),
|
|
213
221
|
homophoneWindow: opts.homophoneWindow ?? (koKp ? "off" : "per-block"),
|
|
@@ -224,6 +232,8 @@ function buildRawOptions(opts, resolved) {
|
|
|
224
232
|
rendering: resolved.rendering,
|
|
225
233
|
hanjaVariantSet: resolved.hanjaVariantSet,
|
|
226
234
|
segmentation: resolved.segmentation,
|
|
235
|
+
sourcePolicy: resolved.sourcePolicy,
|
|
236
|
+
referenceOnly: resolved.referenceOnly,
|
|
227
237
|
numerals: resolved.numerals,
|
|
228
238
|
initialSoundLaw: resolved.initialSoundLaw,
|
|
229
239
|
homophoneWindow: resolved.homophoneWindow,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gukhanmun/napi",
|
|
3
|
-
"version": "0.4.0-dev.
|
|
3
|
+
"version": "0.4.0-dev.255",
|
|
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.4.0-dev.
|
|
18
|
-
"@gukhanmun/napi-x86_64-apple-darwin": "0.4.0-dev.
|
|
19
|
-
"@gukhanmun/napi-aarch64-pc-windows-msvc": "0.4.0-dev.
|
|
20
|
-
"@gukhanmun/napi-x86_64-pc-windows-msvc": "0.4.0-dev.
|
|
21
|
-
"@gukhanmun/napi-aarch64-unknown-linux-gnu": "0.4.0-dev.
|
|
22
|
-
"@gukhanmun/napi-x86_64-unknown-linux-gnu": "0.4.0-dev.
|
|
17
|
+
"@gukhanmun/napi-aarch64-apple-darwin": "0.4.0-dev.255+ffff005",
|
|
18
|
+
"@gukhanmun/napi-x86_64-apple-darwin": "0.4.0-dev.255+ffff005",
|
|
19
|
+
"@gukhanmun/napi-aarch64-pc-windows-msvc": "0.4.0-dev.255+ffff005",
|
|
20
|
+
"@gukhanmun/napi-x86_64-pc-windows-msvc": "0.4.0-dev.255+ffff005",
|
|
21
|
+
"@gukhanmun/napi-aarch64-unknown-linux-gnu": "0.4.0-dev.255+ffff005",
|
|
22
|
+
"@gukhanmun/napi-x86_64-unknown-linux-gnu": "0.4.0-dev.255+ffff005"
|
|
23
23
|
},
|
|
24
24
|
"homepage": "https://github.com/dahlia/gukhanmun",
|
|
25
25
|
"bugs": "https://github.com/dahlia/gukhanmun/issues",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"@gukhanmun/types": "*"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
|
-
"@gukhanmun/types": "0.4.0-dev.
|
|
64
|
+
"@gukhanmun/types": "0.4.0-dev.255+ffff005"
|
|
65
65
|
},
|
|
66
66
|
"scripts": {
|
|
67
67
|
"build": "tsdown"
|