@gukhanmun/wasm 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
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.
|
|
@@ -54,4 +54,4 @@ export declare class GukhanmunError extends Error {
|
|
|
54
54
|
* @throws {@link GukhanmunError} on invalid options or dictionary load failure.
|
|
55
55
|
*/
|
|
56
56
|
export declare function load(options?: GukhanmunOptions$1): Promise<Gukhanmun$1>;
|
|
57
|
-
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 };
|
|
57
|
+
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
|
@@ -121,18 +121,25 @@ function encodeEntries(entries) {
|
|
|
121
121
|
}
|
|
122
122
|
async function resolveDictionary(source) {
|
|
123
123
|
if (typeof source !== "object" || source === null) throw new GukhanmunError("invalid-input", "Each dictionary must be an object");
|
|
124
|
+
const role = source.role;
|
|
125
|
+
if (role !== void 0 && role !== "override" && role !== "reference" && role !== "loanword") throw new GukhanmunError("invalid-input", `Unknown dictionary source role: ${String(role)}`);
|
|
124
126
|
if ("entries" in source) {
|
|
125
127
|
if ("format" in source || "data" in source) throw new GukhanmunError("invalid-input", "A dictionary must not combine 'entries' with 'format' or 'data'");
|
|
126
|
-
return {
|
|
128
|
+
return {
|
|
129
|
+
entriesJson: encodeEntries(source.entries),
|
|
130
|
+
role
|
|
131
|
+
};
|
|
127
132
|
}
|
|
128
133
|
if (source.data instanceof ArrayBuffer) return {
|
|
129
134
|
format: source.format,
|
|
135
|
+
role,
|
|
130
136
|
bytes: new Uint8Array(source.data)
|
|
131
137
|
};
|
|
132
138
|
if (ArrayBuffer.isView(source.data)) {
|
|
133
139
|
const view = source.data;
|
|
134
140
|
return {
|
|
135
141
|
format: source.format,
|
|
142
|
+
role,
|
|
136
143
|
bytes: new Uint8Array(view.buffer, view.byteOffset, view.byteLength)
|
|
137
144
|
};
|
|
138
145
|
}
|
|
@@ -160,6 +167,7 @@ async function resolveDictionary(source) {
|
|
|
160
167
|
}
|
|
161
168
|
return {
|
|
162
169
|
format: source.format,
|
|
170
|
+
role,
|
|
163
171
|
bytes: new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength)
|
|
164
172
|
};
|
|
165
173
|
}
|
|
@@ -172,6 +180,7 @@ async function resolveDictionary(source) {
|
|
|
172
180
|
if (!response.ok) throw new GukhanmunError("dictionary-load", `Failed to fetch dictionary: HTTP ${response.status}`);
|
|
173
181
|
return {
|
|
174
182
|
format: source.format,
|
|
183
|
+
role,
|
|
175
184
|
bytes: new Uint8Array(await response.arrayBuffer())
|
|
176
185
|
};
|
|
177
186
|
}
|
|
@@ -257,6 +266,8 @@ function resolveOptions(opts = {}) {
|
|
|
257
266
|
rendering: opts.rendering ?? "hangul-only",
|
|
258
267
|
hanjaVariantSet: opts.hanjaVariantSet ?? "as-dictionary",
|
|
259
268
|
segmentation: opts.segmentation ?? "lattice",
|
|
269
|
+
sourcePolicy: opts.sourcePolicy ?? "reference-authorized",
|
|
270
|
+
referenceOnly: opts.referenceOnly ?? false,
|
|
260
271
|
numerals: opts.numerals ?? "hangul-phonetic",
|
|
261
272
|
initialSoundLaw: opts.initialSoundLaw ?? (koKp ? false : true),
|
|
262
273
|
homophoneWindow: opts.homophoneWindow ?? (koKp ? "off" : "per-block"),
|
|
@@ -311,6 +322,8 @@ function buildRawOptions(opts, resolved) {
|
|
|
311
322
|
rendering: resolved.rendering,
|
|
312
323
|
hanjaVariantSet: resolved.hanjaVariantSet,
|
|
313
324
|
segmentation: resolved.segmentation,
|
|
325
|
+
sourcePolicy: resolved.sourcePolicy,
|
|
326
|
+
referenceOnly: resolved.referenceOnly,
|
|
314
327
|
numerals: resolved.numerals,
|
|
315
328
|
initialSoundLaw: resolved.initialSoundLaw,
|
|
316
329
|
homophoneWindow: resolved.homophoneWindow,
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gukhanmun/wasm",
|
|
3
|
-
"version": "0.4.0-dev.
|
|
3
|
+
"version": "0.4.0-dev.255",
|
|
4
4
|
"description": "WebAssembly implementation of the Gukhanmun hanja-to-hangul converter.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"@gukhanmun/types": "*"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
|
-
"@gukhanmun/types": "0.4.0-dev.
|
|
57
|
+
"@gukhanmun/types": "0.4.0-dev.255+ffff005"
|
|
58
58
|
},
|
|
59
59
|
"scripts": {
|
|
60
60
|
"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'})\""
|