@laisuk/opencc-fmmseg-wasm 0.3.1 → 0.3.3

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/bin/opencc.js CHANGED
@@ -57,6 +57,7 @@ Convert options:
57
57
  --detofu [level] Replace tofu-risk rare CJK extension chars after conversion
58
58
  level: all | ext-b | ext-c | ext-d | ext-e | ext-f | ext-g | ext-h | ext-i
59
59
  default when omitted value: all
60
+ --keep-ids Preserve complete IDS expressions during conversion (default: false)
60
61
  --in-enc <encoding> Input encoding (default: utf8)
61
62
  --out-enc <encoding> Output encoding (default: utf8)
62
63
 
@@ -247,6 +248,7 @@ async function runConvert(args) {
247
248
  const inEnc = getArg(args, null, "--in-enc", "utf8");
248
249
  const outEnc = getArg(args, null, "--out-enc", "utf8");
249
250
  const punct = hasFlag(args, "-p", "--punct");
251
+ const keepIds = hasFlag(args, null, "--keep-ids");
250
252
 
251
253
  const detofuIndex = args.indexOf("--detofu");
252
254
  const detofuEnabled = detofuIndex !== -1;
@@ -266,6 +268,10 @@ async function runConvert(args) {
266
268
 
267
269
  const cc = new OpenccWasm(config);
268
270
 
271
+ if (keepIds) {
272
+ cc.setPreserveIds(true);
273
+ }
274
+
269
275
  // Prompt user if reading from interactive terminal
270
276
  if (!input && process.stdin.isTTY) {
271
277
  console.error("Input text to convert, <Ctrl+Z>/<Ctrl+D> to submit:");
@@ -288,7 +294,11 @@ async function runConvert(args) {
288
294
  console.error();
289
295
  }
290
296
 
291
- const suffix = detofuEnabled ? ", detofu" : "";
297
+ const suffixParts = [];
298
+ if (detofuEnabled) suffixParts.push("detofu");
299
+ if (keepIds) suffixParts.push("keep-ids");
300
+
301
+ const suffix = suffixParts.length ? `, ${suffixParts.join(", ")}` : "";
292
302
  console.error(`Conversion completed (${config}${suffix}): ${inFrom} -> ${outTo}`);
293
303
  }
294
304
  }
@@ -42,6 +42,7 @@ export class OpenccWasm {
42
42
  detofu(text: string, level: DetofuLevelWasm): string;
43
43
  getConfig(): string;
44
44
  getConfigId(): number;
45
+ getPreserveIds(): boolean;
45
46
  static getSupportedConfigs(): string[];
46
47
  static isValidConfig(config: string): boolean;
47
48
  constructor(config?: string | null);
@@ -49,6 +50,7 @@ export class OpenccWasm {
49
50
  static newWithEnum(config?: OpenccConfigWasm | null): OpenccWasm;
50
51
  setConfig(config: string): boolean;
51
52
  setConfigEnum(config: OpenccConfigWasm): void;
53
+ setPreserveIds(value: boolean): void;
52
54
  static version(): string;
53
55
  zhoCheck(text: string): number;
54
56
  }
@@ -67,6 +69,7 @@ export interface InitOutput {
67
69
  readonly openccwasm_detofu: (a: number, b: number, c: number, d: number) => [number, number];
68
70
  readonly openccwasm_getConfig: (a: number) => [number, number];
69
71
  readonly openccwasm_getConfigId: (a: number) => number;
72
+ readonly openccwasm_getPreserveIds: (a: number) => number;
70
73
  readonly openccwasm_getSupportedConfigs: () => [number, number];
71
74
  readonly openccwasm_isValidConfig: (a: number, b: number) => number;
72
75
  readonly openccwasm_new: (a: number, b: number) => [number, number, number];
@@ -74,6 +77,7 @@ export interface InitOutput {
74
77
  readonly openccwasm_newWithEnum: (a: number) => [number, number, number];
75
78
  readonly openccwasm_setConfig: (a: number, b: number, c: number) => number;
76
79
  readonly openccwasm_setConfigEnum: (a: number, b: number) => void;
80
+ readonly openccwasm_setPreserveIds: (a: number, b: number) => void;
77
81
  readonly openccwasm_version: () => [number, number];
78
82
  readonly openccwasm_zhoCheck: (a: number, b: number, c: number) => number;
79
83
  readonly __wbindgen_malloc: (a: number, b: number) => number;
@@ -150,6 +150,13 @@ export class OpenccWasm {
150
150
  const ret = wasm.openccwasm_getConfigId(this.__wbg_ptr);
151
151
  return ret >>> 0;
152
152
  }
153
+ /**
154
+ * @returns {boolean}
155
+ */
156
+ getPreserveIds() {
157
+ const ret = wasm.openccwasm_getPreserveIds(this.__wbg_ptr);
158
+ return ret !== 0;
159
+ }
153
160
  /**
154
161
  * @returns {string[]}
155
162
  */
@@ -224,6 +231,12 @@ export class OpenccWasm {
224
231
  setConfigEnum(config) {
225
232
  wasm.openccwasm_setConfigEnum(this.__wbg_ptr, config);
226
233
  }
234
+ /**
235
+ * @param {boolean} value
236
+ */
237
+ setPreserveIds(value) {
238
+ wasm.openccwasm_setPreserveIds(this.__wbg_ptr, value);
239
+ }
227
240
  /**
228
241
  * @returns {string}
229
242
  */
Binary file
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@laisuk/opencc-fmmseg-wasm",
3
3
  "type": "module",
4
4
  "description": "WebAssembly bindings for opencc-fmmseg, a high-performance OpenCC-compatible Simplified/Traditional Chinese converter.",
5
- "version": "0.3.1",
5
+ "version": "0.3.3",
6
6
  "license": "MIT",
7
7
  "repository": {
8
8
  "type": "git",