@gukhanmun/wasm 0.3.0-dev.196 → 0.3.0-dev.203
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 +48 -2
- package/dist/index.js +28 -1
- package/dist/wasm/deno/gukhanmun_wasm.d.ts +4 -0
- package/dist/wasm/deno/gukhanmun_wasm.js +16 -0
- package/dist/wasm/deno/gukhanmun_wasm_bg.wasm +0 -0
- package/dist/wasm/deno/gukhanmun_wasm_bg.wasm.d.ts +1 -0
- package/dist/wasm/nodejs/gukhanmun_wasm.d.ts +4 -0
- package/dist/wasm/nodejs/gukhanmun_wasm.js +16 -0
- package/dist/wasm/nodejs/gukhanmun_wasm_bg.wasm +0 -0
- package/dist/wasm/nodejs/gukhanmun_wasm_bg.wasm.d.ts +1 -0
- package/dist/wasm/web/gukhanmun_wasm.d.ts +5 -0
- package/dist/wasm/web/gukhanmun_wasm.js +16 -0
- package/dist/wasm/web/gukhanmun_wasm_bg.wasm +0 -0
- package/dist/wasm/web/gukhanmun_wasm_bg.wasm.d.ts +1 -0
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -288,6 +288,48 @@ interface Directives {
|
|
|
288
288
|
*/
|
|
289
289
|
readonly skipAnnotation?: readonly string[];
|
|
290
290
|
}
|
|
291
|
+
/** Policy for ordinary spaces following an eligible stop. */
|
|
292
|
+
type SpaceAfter = "preserve" | "remove" | "single";
|
|
293
|
+
/** Built-in output style; input recognition is independent of this choice. */
|
|
294
|
+
type PunctuationPreset = "preserve" | "modern" | "traditional" | "traditional-vertical";
|
|
295
|
+
/** A single Unicode scalar and its following U+0020 policy. */
|
|
296
|
+
interface StopStyle {
|
|
297
|
+
/** One Unicode scalar, validated by the shared profile resolver. */
|
|
298
|
+
readonly mark: string;
|
|
299
|
+
/** Policy applied only to U+0020 following this stop. */
|
|
300
|
+
readonly after: SpaceAfter;
|
|
301
|
+
}
|
|
302
|
+
/** Opening and closing Unicode punctuation scalars. */
|
|
303
|
+
interface DelimiterStyle {
|
|
304
|
+
/** Opening scalar with Unicode category Ps or Pi. */
|
|
305
|
+
readonly open: string;
|
|
306
|
+
/** Closing scalar with Unicode category Pe or Pf. */
|
|
307
|
+
readonly close: string;
|
|
308
|
+
}
|
|
309
|
+
/** Partial overrides; omitted roles inherit, null preserves the role. */
|
|
310
|
+
interface CustomPunctuationProfile {
|
|
311
|
+
/** Inherited preset, defaulting to preserve. */
|
|
312
|
+
readonly base?: PunctuationPreset;
|
|
313
|
+
/** Comma style; omitted inherits, null preserves. */
|
|
314
|
+
readonly comma?: StopStyle | null;
|
|
315
|
+
/** Period style; omitted inherits, null preserves. */
|
|
316
|
+
readonly period?: StopStyle | null;
|
|
317
|
+
/** Single delimiters; omitted inherits, null preserves. */
|
|
318
|
+
readonly single?: DelimiterStyle | null;
|
|
319
|
+
/** Double delimiters; omitted inherits, null preserves. */
|
|
320
|
+
readonly double?: DelimiterStyle | null;
|
|
321
|
+
}
|
|
322
|
+
/** Fully resolved styles, copied and deeply frozen by each binding. */
|
|
323
|
+
interface ResolvedPunctuationProfile {
|
|
324
|
+
/** Comma style, or null for preservation. */
|
|
325
|
+
readonly comma: StopStyle | null;
|
|
326
|
+
/** Period style, or null for preservation. */
|
|
327
|
+
readonly period: StopStyle | null;
|
|
328
|
+
/** Single delimiters, or null for preservation. */
|
|
329
|
+
readonly single: DelimiterStyle | null;
|
|
330
|
+
/** Double delimiters, or null for preservation. */
|
|
331
|
+
readonly double: DelimiterStyle | null;
|
|
332
|
+
}
|
|
291
333
|
/**
|
|
292
334
|
* Full set of options passed to {@link GukhanmunFactory.load} (or the
|
|
293
335
|
* top-level `load` function) to configure a {@link Gukhanmun} instance.
|
|
@@ -297,6 +339,8 @@ interface Directives {
|
|
|
297
339
|
* given, `"ko-kr"` is implicitly used.
|
|
298
340
|
*/
|
|
299
341
|
interface GukhanmunOptions {
|
|
342
|
+
/** Independent output punctuation policy. Defaults to preserve. */
|
|
343
|
+
readonly punctuation?: PunctuationPreset | CustomPunctuationProfile;
|
|
300
344
|
/**
|
|
301
345
|
* Named configuration preset. Defaults to `"ko-kr"`.
|
|
302
346
|
*
|
|
@@ -480,7 +524,9 @@ interface Gukhanmun {
|
|
|
480
524
|
* `originalGloss`, which are not meaningfully representable as plain
|
|
481
525
|
* values.
|
|
482
526
|
*/
|
|
483
|
-
readonly options: Readonly<Required<Omit<GukhanmunOptions, "dictionaries" | "directives" | "html" | "originalGloss"
|
|
527
|
+
readonly options: Readonly<Required<Omit<GukhanmunOptions, "dictionaries" | "directives" | "html" | "originalGloss" | "punctuation">> & {
|
|
528
|
+
readonly punctuation: ResolvedPunctuationProfile;
|
|
529
|
+
}>;
|
|
484
530
|
}
|
|
485
531
|
/**
|
|
486
532
|
* Factory interface satisfied by both `@gukhanmun/wasm` and
|
|
@@ -617,4 +663,4 @@ declare class GukhanmunError extends Error {
|
|
|
617
663
|
*/
|
|
618
664
|
declare function load(options?: GukhanmunOptions): Promise<Gukhanmun>;
|
|
619
665
|
//#endregion
|
|
620
|
-
export { type ContextWindow, type DictionaryEntry, type DictionarySource, type Directives, type ErrorCode, type FileDictionarySource, type Format, type Gukhanmun, GukhanmunError, type GukhanmunFactory, type GukhanmunOptions, type HanjaVariantSet, type HomophoneDetection, type HtmlOptions, type NumeralStrategy, type OriginalGloss, type Preset, type Recovery, type RenderMode, type Segmentation, load };
|
|
666
|
+
export { type ContextWindow, type CustomPunctuationProfile, type DelimiterStyle, type DictionaryEntry, type DictionarySource, type Directives, type ErrorCode, type FileDictionarySource, type Format, type Gukhanmun, GukhanmunError, type GukhanmunFactory, type GukhanmunOptions, type HanjaVariantSet, type HomophoneDetection, type HtmlOptions, type NumeralStrategy, type OriginalGloss, type Preset, type PunctuationPreset, type Recovery, type RenderMode, type ResolvedPunctuationProfile, type Segmentation, type SpaceAfter, type StopStyle, load };
|
package/dist/index.js
CHANGED
|
@@ -200,6 +200,12 @@ function resolveOptions(opts = {}) {
|
|
|
200
200
|
const preset = opts.preset ?? "ko-kr";
|
|
201
201
|
const koKp = preset === "ko-kp";
|
|
202
202
|
return {
|
|
203
|
+
punctuation: {
|
|
204
|
+
comma: null,
|
|
205
|
+
period: null,
|
|
206
|
+
single: null,
|
|
207
|
+
double: null
|
|
208
|
+
},
|
|
203
209
|
preset,
|
|
204
210
|
rendering: opts.rendering ?? "hangul-only",
|
|
205
211
|
hanjaVariantSet: opts.hanjaVariantSet ?? "as-dictionary",
|
|
@@ -241,11 +247,18 @@ async function load(options = {}) {
|
|
|
241
247
|
} catch (e) {
|
|
242
248
|
throw liftError(e);
|
|
243
249
|
}
|
|
244
|
-
|
|
250
|
+
const punctuation = JSON.parse(handle.punctuation_profile_json());
|
|
251
|
+
for (const style of Object.values(punctuation)) if (style != null) Object.freeze(style);
|
|
252
|
+
Object.freeze(punctuation);
|
|
253
|
+
return new GukhanmunImpl(handle, {
|
|
254
|
+
...resolved,
|
|
255
|
+
punctuation
|
|
256
|
+
});
|
|
245
257
|
}
|
|
246
258
|
/** Builds the plain-object options passed across the WASM boundary. */
|
|
247
259
|
function buildRawOptions(opts, resolved) {
|
|
248
260
|
const raw = {
|
|
261
|
+
punctuationJson: punctuationJson(opts.punctuation),
|
|
249
262
|
preset: resolved.preset,
|
|
250
263
|
rendering: resolved.rendering,
|
|
251
264
|
hanjaVariantSet: resolved.hanjaVariantSet,
|
|
@@ -270,5 +283,19 @@ function buildRawOptions(opts, resolved) {
|
|
|
270
283
|
};
|
|
271
284
|
return raw;
|
|
272
285
|
}
|
|
286
|
+
/** Reject ill-formed UTF-16 before a native boundary could replace surrogates. */
|
|
287
|
+
function punctuationJson(value) {
|
|
288
|
+
try {
|
|
289
|
+
return JSON.stringify(value === void 0 ? "preserve" : value, (_key, v) => {
|
|
290
|
+
if (typeof v === "string" && Array.from(v).some((c) => {
|
|
291
|
+
const code = c.codePointAt(0);
|
|
292
|
+
return code >= 55296 && code <= 57343;
|
|
293
|
+
})) throw new Error("Punctuation strings must contain Unicode scalars");
|
|
294
|
+
return v;
|
|
295
|
+
});
|
|
296
|
+
} catch (error) {
|
|
297
|
+
throw new GukhanmunError("invalid-input", error instanceof Error ? error.message : String(error));
|
|
298
|
+
}
|
|
299
|
+
}
|
|
273
300
|
//#endregion
|
|
274
301
|
export { GukhanmunError, load };
|
|
@@ -41,6 +41,10 @@ export class WasmGukhanmun {
|
|
|
41
41
|
* equals the result of a single `convert` call on the concatenated input.
|
|
42
42
|
*/
|
|
43
43
|
open_stream(format: any): WasmStream;
|
|
44
|
+
/**
|
|
45
|
+
* Returns the resolved punctuation profile for the public immutable view.
|
|
46
|
+
*/
|
|
47
|
+
punctuation_profile_json(): string;
|
|
44
48
|
}
|
|
45
49
|
|
|
46
50
|
/**
|
|
@@ -88,6 +88,22 @@ export class WasmGukhanmun {
|
|
|
88
88
|
}
|
|
89
89
|
return WasmStream.__wrap(ret[0]);
|
|
90
90
|
}
|
|
91
|
+
/**
|
|
92
|
+
* Returns the resolved punctuation profile for the public immutable view.
|
|
93
|
+
* @returns {string}
|
|
94
|
+
*/
|
|
95
|
+
punctuation_profile_json() {
|
|
96
|
+
let deferred1_0;
|
|
97
|
+
let deferred1_1;
|
|
98
|
+
try {
|
|
99
|
+
const ret = wasm.wasmgukhanmun_punctuation_profile_json(this.__wbg_ptr);
|
|
100
|
+
deferred1_0 = ret[0];
|
|
101
|
+
deferred1_1 = ret[1];
|
|
102
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
103
|
+
} finally {
|
|
104
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
91
107
|
}
|
|
92
108
|
if (Symbol.dispose) WasmGukhanmun.prototype[Symbol.dispose] = WasmGukhanmun.prototype.free;
|
|
93
109
|
|
|
Binary file
|
|
@@ -6,6 +6,7 @@ export const __wbg_wasmstream_free: (a: number, b: number) => void;
|
|
|
6
6
|
export const wasmgukhanmun_convert: (a: number, b: number, c: number, d: any) => [number, number, number, number];
|
|
7
7
|
export const wasmgukhanmun_new: (a: any, b: any) => [number, number, number];
|
|
8
8
|
export const wasmgukhanmun_open_stream: (a: number, b: any) => [number, number, number];
|
|
9
|
+
export const wasmgukhanmun_punctuation_profile_json: (a: number) => [number, number];
|
|
9
10
|
export const wasmstream_finish: (a: number) => [number, number, number, number];
|
|
10
11
|
export const wasmstream_push: (a: number, b: number, c: number) => [number, number, number, number];
|
|
11
12
|
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
@@ -41,6 +41,10 @@ export class WasmGukhanmun {
|
|
|
41
41
|
* equals the result of a single `convert` call on the concatenated input.
|
|
42
42
|
*/
|
|
43
43
|
open_stream(format: any): WasmStream;
|
|
44
|
+
/**
|
|
45
|
+
* Returns the resolved punctuation profile for the public immutable view.
|
|
46
|
+
*/
|
|
47
|
+
punctuation_profile_json(): string;
|
|
44
48
|
}
|
|
45
49
|
|
|
46
50
|
/**
|
|
@@ -88,6 +88,22 @@ class WasmGukhanmun {
|
|
|
88
88
|
}
|
|
89
89
|
return WasmStream.__wrap(ret[0]);
|
|
90
90
|
}
|
|
91
|
+
/**
|
|
92
|
+
* Returns the resolved punctuation profile for the public immutable view.
|
|
93
|
+
* @returns {string}
|
|
94
|
+
*/
|
|
95
|
+
punctuation_profile_json() {
|
|
96
|
+
let deferred1_0;
|
|
97
|
+
let deferred1_1;
|
|
98
|
+
try {
|
|
99
|
+
const ret = wasm.wasmgukhanmun_punctuation_profile_json(this.__wbg_ptr);
|
|
100
|
+
deferred1_0 = ret[0];
|
|
101
|
+
deferred1_1 = ret[1];
|
|
102
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
103
|
+
} finally {
|
|
104
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
91
107
|
}
|
|
92
108
|
if (Symbol.dispose) WasmGukhanmun.prototype[Symbol.dispose] = WasmGukhanmun.prototype.free;
|
|
93
109
|
exports.WasmGukhanmun = WasmGukhanmun;
|
|
Binary file
|
|
@@ -6,6 +6,7 @@ export const __wbg_wasmstream_free: (a: number, b: number) => void;
|
|
|
6
6
|
export const wasmgukhanmun_convert: (a: number, b: number, c: number, d: any) => [number, number, number, number];
|
|
7
7
|
export const wasmgukhanmun_new: (a: any, b: any) => [number, number, number];
|
|
8
8
|
export const wasmgukhanmun_open_stream: (a: number, b: any) => [number, number, number];
|
|
9
|
+
export const wasmgukhanmun_punctuation_profile_json: (a: number) => [number, number];
|
|
9
10
|
export const wasmstream_finish: (a: number) => [number, number, number, number];
|
|
10
11
|
export const wasmstream_push: (a: number, b: number, c: number) => [number, number, number, number];
|
|
11
12
|
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
@@ -41,6 +41,10 @@ export class WasmGukhanmun {
|
|
|
41
41
|
* equals the result of a single `convert` call on the concatenated input.
|
|
42
42
|
*/
|
|
43
43
|
open_stream(format: any): WasmStream;
|
|
44
|
+
/**
|
|
45
|
+
* Returns the resolved punctuation profile for the public immutable view.
|
|
46
|
+
*/
|
|
47
|
+
punctuation_profile_json(): string;
|
|
44
48
|
}
|
|
45
49
|
|
|
46
50
|
/**
|
|
@@ -76,6 +80,7 @@ export interface InitOutput {
|
|
|
76
80
|
readonly wasmgukhanmun_convert: (a: number, b: number, c: number, d: any) => [number, number, number, number];
|
|
77
81
|
readonly wasmgukhanmun_new: (a: any, b: any) => [number, number, number];
|
|
78
82
|
readonly wasmgukhanmun_open_stream: (a: number, b: any) => [number, number, number];
|
|
83
|
+
readonly wasmgukhanmun_punctuation_profile_json: (a: number) => [number, number];
|
|
79
84
|
readonly wasmstream_finish: (a: number) => [number, number, number, number];
|
|
80
85
|
readonly wasmstream_push: (a: number, b: number, c: number) => [number, number, number, number];
|
|
81
86
|
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
@@ -88,6 +88,22 @@ export class WasmGukhanmun {
|
|
|
88
88
|
}
|
|
89
89
|
return WasmStream.__wrap(ret[0]);
|
|
90
90
|
}
|
|
91
|
+
/**
|
|
92
|
+
* Returns the resolved punctuation profile for the public immutable view.
|
|
93
|
+
* @returns {string}
|
|
94
|
+
*/
|
|
95
|
+
punctuation_profile_json() {
|
|
96
|
+
let deferred1_0;
|
|
97
|
+
let deferred1_1;
|
|
98
|
+
try {
|
|
99
|
+
const ret = wasm.wasmgukhanmun_punctuation_profile_json(this.__wbg_ptr);
|
|
100
|
+
deferred1_0 = ret[0];
|
|
101
|
+
deferred1_1 = ret[1];
|
|
102
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
103
|
+
} finally {
|
|
104
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
91
107
|
}
|
|
92
108
|
if (Symbol.dispose) WasmGukhanmun.prototype[Symbol.dispose] = WasmGukhanmun.prototype.free;
|
|
93
109
|
|
|
Binary file
|
|
@@ -6,6 +6,7 @@ export const __wbg_wasmstream_free: (a: number, b: number) => void;
|
|
|
6
6
|
export const wasmgukhanmun_convert: (a: number, b: number, c: number, d: any) => [number, number, number, number];
|
|
7
7
|
export const wasmgukhanmun_new: (a: any, b: any) => [number, number, number];
|
|
8
8
|
export const wasmgukhanmun_open_stream: (a: number, b: any) => [number, number, number];
|
|
9
|
+
export const wasmgukhanmun_punctuation_profile_json: (a: number) => [number, number];
|
|
9
10
|
export const wasmstream_finish: (a: number) => [number, number, number, number];
|
|
10
11
|
export const wasmstream_push: (a: number, b: number, c: number) => [number, number, number, number];
|
|
11
12
|
export const __wbindgen_malloc: (a: number, b: number) => number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gukhanmun/wasm",
|
|
3
|
-
"version": "0.3.0-dev.
|
|
3
|
+
"version": "0.3.0-dev.203",
|
|
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.3.0-dev.
|
|
48
|
+
"@gukhanmun/types": "0.3.0-dev.203+7b876cb"
|
|
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'})\""
|