@laisuk/opencc-fmmseg-wasm 0.4.0 → 0.4.1

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/README.md CHANGED
@@ -32,6 +32,14 @@ Package profile:
32
32
  - 20 conversion configs
33
33
  - 100% offline
34
34
 
35
+ ### 🌐 Live Demo
36
+
37
+ Try `opencc-fmmseg-wasm` directly in your browser:
38
+
39
+ **[Open the live WASM demo: CJK Conversion Tool](https://laisuk.github.io/opencc-fmmseg-wasm/)**
40
+
41
+ No installation or server backend required.
42
+
35
43
  ---
36
44
 
37
45
  ## Installation
@@ -40,25 +48,27 @@ Package profile:
40
48
  npm install @laisuk/opencc-fmmseg-wasm
41
49
  ```
42
50
 
51
+ Or installation from the mirror package:
52
+
53
+ ```bash
54
+ npm install opencc-fmmseg-wasm
55
+ ```
56
+
43
57
  ---
44
58
 
45
59
  ## Quick Start
46
60
 
47
61
  ```javascript
48
62
  import init, {
49
- OpenccWasm,
50
- DetofuLevelWasm
63
+ OpenccWasm
51
64
  } from "@laisuk/opencc-fmmseg-wasm";
52
65
 
53
66
  await init();
54
67
 
55
- const cc = new OpenccWasm("t2s");
56
-
57
- console.log(cc.convert("漢字", false));
58
- // 汉字
68
+ const cc = new OpenccWasm("s2t");
59
69
 
60
- console.log(cc.convertDetofu("儼驂騑於上路", false, DetofuLevelWasm.ExtB));
61
- // 俨骖騑于上路
70
+ console.log(cc.convert("汉字转换测试", false));
71
+ // 漢字轉換測試
62
72
  ```
63
73
 
64
74
  ---
@@ -82,13 +92,22 @@ Example:
82
92
  const cc = new OpenccWasm("t2s");
83
93
  ```
84
94
 
95
+ Taiwan phrase config example:
96
+
97
+ ```javascript
98
+ const cc = new OpenccWasm("s2twp");
99
+
100
+ cc.convert("预订‘奔驰’品牌出租车", true);
101
+ // 預訂『賓士』品牌計程車
102
+ ```
103
+
85
104
  Hong Kong phrase config example:
86
105
 
87
106
  ```javascript
88
- const cc = new OpenccWasm("s2hkp");
107
+ const cc = new OpenccWasm("hk2sp");
89
108
 
90
- cc.convert("别随便录影侵犯个人隐私权", false);
91
- // 別隨便錄影侵犯個人私隱權
109
+ cc.convert("作業系統加密保護個人私隱權", false);
110
+ // 操作系统加密保护个人隐私权
92
111
  ```
93
112
 
94
113
  ---
@@ -544,8 +563,8 @@ const cc = OpenccWasm.newWithEnum(
544
563
  OpenccConfigWasm.S2hkp
545
564
  );
546
565
 
547
- console.log(cc.convert("别随便录影侵犯个人隐私权", false));
548
- // 別隨便錄影侵犯個人私隱權
566
+ console.log(cc.convert("操作系统加密保护个人隐私权", false));
567
+ // 作業系統加密保護個人私隱權
549
568
  ```
550
569
 
551
570
  ---
@@ -564,8 +583,12 @@ docx, xlsx, pptx, odt, ods, odp, epub
564
583
  File size is limited by available browser or Node.js memory, but there is no upload or server-side limit. Font
565
584
  preservation is supported with the `keepFont` option.
566
585
 
567
- Use the instance method when possible. It reuses the converter configuration and any custom dictionaries already held by
568
- the `OpenccWasm` instance.
586
+ Use the instance methods when possible. They reuse the converter configuration, custom dictionaries, and other converter
587
+ state already held by the `OpenccWasm` instance.
588
+
589
+ ### Basic Office Conversion
590
+
591
+ For normal OpenCC conversion, use:
569
592
 
570
593
  ```javascript
571
594
  cc.convertOfficeBytes(inputBytes, format, punctuation, keepFont)
@@ -582,12 +605,84 @@ Returns:
582
605
 
583
606
  - converted output bytes
584
607
 
585
- The older free function remains available for compatibility:
608
+ The existing free function remains available for compatibility:
586
609
 
587
610
  ```javascript
588
611
  convert_office_bytes(inputBytes, format, config, punctuation, keepFont)
589
612
  ```
590
613
 
614
+ ### Office Conversion Pipeline
615
+
616
+ For compatibility normalization and optional DeTofu processing, use:
617
+
618
+ ```javascript
619
+ cc.convertOfficeBytesPipeline(
620
+ inputBytes,
621
+ format,
622
+ punctuation,
623
+ keepFont,
624
+ normalizeMode,
625
+ detofuLevel
626
+ )
627
+ ```
628
+
629
+ The text-processing order is:
630
+
631
+ ```text
632
+ Normalize -> OpenCC -> DeTofu
633
+ ```
634
+
635
+ `normalizeMode` is a `NormalizeModeWasm` value:
636
+
637
+ ```javascript
638
+ NormalizeModeWasm.None
639
+ NormalizeModeWasm.Compat
640
+ NormalizeModeWasm.UnicodeCompat
641
+ NormalizeModeWasm.CompatExtended
642
+ ```
643
+
644
+ The final `detofuLevel` argument is optional. When omitted or `undefined`, DeTofu is not applied.
645
+
646
+ To enable DeTofu, pass a `DetofuLevelWasm` value:
647
+
648
+ ```javascript
649
+ DetofuLevelWasm.ExtB
650
+ DetofuLevelWasm.ExtC
651
+ DetofuLevelWasm.ExtD
652
+ DetofuLevelWasm.ExtE
653
+ DetofuLevelWasm.ExtF
654
+ DetofuLevelWasm.ExtG
655
+ DetofuLevelWasm.ExtH
656
+ DetofuLevelWasm.ExtI
657
+ ```
658
+
659
+ `ExtB` applies all supported DeTofu mappings from Extension B onward.
660
+
661
+ For example, extended compatibility normalization followed by OpenCC conversion, without DeTofu:
662
+
663
+ ```javascript
664
+ const outputBytes = cc.convertOfficeBytesPipeline(
665
+ inputBytes,
666
+ "docx",
667
+ true,
668
+ true,
669
+ NormalizeModeWasm.CompatExtended
670
+ );
671
+ ```
672
+
673
+ To additionally apply DeTofu:
674
+
675
+ ```javascript
676
+ const outputBytes = cc.convertOfficeBytesPipeline(
677
+ inputBytes,
678
+ "docx",
679
+ true,
680
+ true,
681
+ NormalizeModeWasm.CompatExtended,
682
+ DetofuLevelWasm.ExtB
683
+ );
684
+ ```
685
+
591
686
  ### Browser Office Example
592
687
 
593
688
  ```javascript
@@ -617,6 +712,41 @@ a.click();
617
712
  URL.revokeObjectURL(a.href);
618
713
  ```
619
714
 
715
+ ### Browser Office Pipeline Example
716
+
717
+ ```javascript
718
+ import init, {
719
+ OpenccWasm,
720
+ NormalizeModeWasm,
721
+ DetofuLevelWasm
722
+ } from "@laisuk/opencc-fmmseg-wasm";
723
+
724
+ await init();
725
+
726
+ const cc = new OpenccWasm("t2s");
727
+ const file = document.querySelector("input[type=file]").files[0];
728
+ const inputBytes = new Uint8Array(await file.arrayBuffer());
729
+
730
+ const outputBytes = cc.convertOfficeBytesPipeline(
731
+ inputBytes,
732
+ "docx",
733
+ true,
734
+ true,
735
+ NormalizeModeWasm.CompatExtended,
736
+ DetofuLevelWasm.ExtB
737
+ );
738
+
739
+ const blob = new Blob([outputBytes], {
740
+ type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
741
+ });
742
+
743
+ const a = document.createElement("a");
744
+ a.href = URL.createObjectURL(blob);
745
+ a.download = "converted.docx";
746
+ a.click();
747
+ URL.revokeObjectURL(a.href);
748
+ ```
749
+
620
750
  ### Node.js Office Example
621
751
 
622
752
  ```javascript
@@ -638,6 +768,33 @@ const outputBytes = cc.convertOfficeBytes(
638
768
  fs.writeFileSync("output.docx", outputBytes);
639
769
  ```
640
770
 
771
+ ### Node.js Office Pipeline Example
772
+
773
+ ```javascript
774
+ import fs from "fs";
775
+ import init, {
776
+ OpenccWasm,
777
+ NormalizeModeWasm,
778
+ DetofuLevelWasm
779
+ } from "@laisuk/opencc-fmmseg-wasm";
780
+
781
+ await init();
782
+
783
+ const cc = new OpenccWasm("t2s");
784
+ const inputBytes = fs.readFileSync("input.epub");
785
+
786
+ const outputBytes = cc.convertOfficeBytesPipeline(
787
+ inputBytes,
788
+ "epub",
789
+ true,
790
+ true,
791
+ NormalizeModeWasm.CompatExtended,
792
+ DetofuLevelWasm.ExtB
793
+ );
794
+
795
+ fs.writeFileSync("output.epub", outputBytes);
796
+ ```
797
+
641
798
  ---
642
799
 
643
800
  ## Browser Example
@@ -698,7 +855,7 @@ The package includes a zero-dependency Node.js CLI:
698
855
  ```bash
699
856
  opencc-fmmseg convert -i input.txt -o output.txt -c s2t -p
700
857
  opencc-fmmseg convert -i input.txt -o output.txt -c t2s -p --detofu all
701
- echo "别随便录影侵犯个人隐私权" | opencc-fmmseg convert -c s2hkp
858
+ echo "操作系统加密保护个人隐私权" | opencc-fmmseg convert -c s2hkp
702
859
  echo "天龍八部書裡的喬峰是契丹人" | opencc-fmmseg convert -c t2s --norm-compat
703
860
  // 天龙八部书里的乔峰是契丹人
704
861
  echo "這個細路哥很靈活" | opencc-fmmseg convert -c hk2sp --custom-dict hkphrasesrev:append:my_hk_dict.txt
@@ -758,12 +915,18 @@ tw2s, tw2sp, tw2t, tw2tp, hk2s, hk2sp, hk2t, hk2tp, jp2t, t2jp
758
915
  -F, --convert-filename Convert generated output filename stem (default: false)
759
916
  --keep-font Preserve font-family information (default)
760
917
  --no-keep-font Do not preserve font-family information
761
- --custom-dict <slot:mode:file>
762
- Load a custom dictionary.
763
- May be specified multiple times.
764
- Examples:
765
- --custom-dict hkphrasesrev:append:my_hk_dict.txt
766
- --custom-dict stphrases:override:terms.txt
918
+ --keep-ids Preserve complete IDS expressions during conversion (default: false)
919
+ -n, --norm-compat Normalize CJK Compatibility Ideographs before conversion (default: false)
920
+ -E, --norm-compat-extended Normalize extended Unicode compatibility forms before conversion (default: false)
921
+ --detofu [level] Replace tofu-risk rare CJK extension chars after conversion
922
+ level: all | ext-b | ext-c | ext-d | ext-e | ext-f | ext-g | ext-h | ext-i
923
+ default when omitted value: all
924
+ -D, --custom-dict <slot:mode:file>
925
+ Load a custom dictionary.
926
+ May be specified multiple times.
927
+ Examples:
928
+ --custom-dict hkphrasesrev:append:my_hk_dict.txt
929
+ --custom-dict stphrases:override:terms.txt
767
930
  ```
768
931
 
769
932
  For `office`, the format is inferred from the input file extension when `--format` is omitted.
@@ -801,6 +964,7 @@ The WASM-facing enum is exported as `OpenccConfigWasm`, alongside `OpenccWasm`.
801
964
  - C API: https://github.com/laisuk/opencc-fmmseg/tree/master/capi/opencc-fmmseg-capi
802
965
  - .NET: https://github.com/laisuk/OpenccNet
803
966
  - Python: https://github.com/laisuk/opencc_purepy
967
+ - Java: https://github.com/laisuk/OpenccJava
804
968
 
805
969
  ---
806
970
 
package/bin/opencc.js CHANGED
@@ -6,7 +6,8 @@ import process from "process";
6
6
 
7
7
  import init, {
8
8
  OpenccWasm,
9
- DetofuLevelWasm
9
+ DetofuLevelWasm,
10
+ NormalizeModeWasm
10
11
  } from "../opencc_fmmseg_wasm.js";
11
12
 
12
13
  const OFFICE_FORMATS = new Set([
@@ -52,13 +53,13 @@ Convert options:
52
53
  -i, --input <file> Input text file; stdin if omitted
53
54
  -o, --output <file> Output text file; stdout if omitted
54
55
  -c, --config <conversion> Conversion config (default: s2t)
55
- -p, --punct Enable punctuation conversion
56
- --detofu [level] Replace tofu-risk rare CJK extension chars after conversion
57
- level: all | ext-b | ext-c | ext-d | ext-e | ext-f | ext-g | ext-h | ext-i
58
- default when omitted value: all
59
- --keep-ids Preserve complete IDS expressions during conversion (default: false)
56
+ -p, --punct Enable punctuation conversion
57
+ --keep-ids Preserve complete IDS expressions during conversion (default: false)
60
58
  -n, --norm-compat Normalize CJK Compatibility Ideographs before conversion (default: false)
61
59
  -E, --norm-compat-extended Normalize extended Unicode compatibility forms before conversion (default: false)
60
+ --detofu [level] Replace tofu-risk rare CJK extension chars after conversion
61
+ level: all | ext-b | ext-c | ext-d | ext-e | ext-f | ext-g | ext-h | ext-i
62
+ default when omitted value: all
62
63
  -D, --custom-dict <slot:mode:file>
63
64
  Load a custom dictionary.
64
65
  May be specified multiple times.
@@ -89,6 +90,12 @@ Office options:
89
90
  -F, --convert-filename Convert generated output filename stem (default: false)
90
91
  --keep-font Preserve font-family information (default)
91
92
  --no-keep-font Do not preserve font-family information
93
+ --keep-ids Preserve complete IDS expressions during conversion (default: false)
94
+ -n, --norm-compat Normalize CJK Compatibility Ideographs before conversion (default: false)
95
+ -E, --norm-compat-extended Normalize extended Unicode compatibility forms before conversion (default: false)
96
+ --detofu [level] Replace tofu-risk rare CJK extension chars after conversion
97
+ level: all | ext-b | ext-c | ext-d | ext-e | ext-f | ext-g | ext-h | ext-i
98
+ default when omitted value: all
92
99
  -D, --custom-dict <slot:mode:file>
93
100
  Load a custom dictionary.
94
101
  May be specified multiple times.
@@ -397,10 +404,15 @@ function inferOfficeFormat(inputFile, explicitFormat) {
397
404
  return ext;
398
405
  }
399
406
 
400
- function makeDefaultOfficeOutput(inputFile, officeFormat, convertFilename, cc, config, punct) {
407
+ function makeDefaultOfficeOutput(
408
+ inputFile,
409
+ officeFormat,
410
+ convertStem = null
411
+ ) {
401
412
  const parsed = path.parse(inputFile);
402
- const stem = convertFilename
403
- ? cc.convert(parsed.name, punct)
413
+
414
+ const stem = convertStem
415
+ ? convertStem(parsed.name)
404
416
  : parsed.name;
405
417
 
406
418
  return path.join(
@@ -571,6 +583,27 @@ async function runOffice(args) {
571
583
  const punct = hasFlag(args, "-p", "--punct");
572
584
  const convertFilename = hasFlag(args, "-F", "--convert-filename");
573
585
  const keepFont = !hasFlag(args, null, "--no-keep-font");
586
+ const normCompat = hasFlag(args, "-n", "--norm-compat");
587
+ const normCompatExtended = hasFlag(args, "-E", "--norm-compat-extended");
588
+
589
+ const normMode = normCompatExtended
590
+ ? NormalizeModeWasm.CompatExtended
591
+ : normCompat
592
+ ? NormalizeModeWasm.Compat
593
+ : NormalizeModeWasm.None;
594
+
595
+ const detofuIndex = args.indexOf("--detofu");
596
+ const detofuEnabled = detofuIndex !== -1;
597
+ let detofuLevel;
598
+
599
+ if (detofuEnabled) {
600
+ const next = args[detofuIndex + 1];
601
+
602
+ detofuLevel = (!next || next.startsWith("-"))
603
+ ? parseDetofuLevel("all")
604
+ : parseDetofuLevel(next);
605
+ }
606
+
574
607
  const customDicts = getArgs(args, "-D", "--custom-dict")
575
608
  .map(parseCustomDictSpec);
576
609
 
@@ -589,8 +622,34 @@ async function runOffice(args) {
589
622
  ? new OpenccWasm(config)
590
623
  : OpenccWasm.newWithCustomDicts(config, customDicts);
591
624
 
625
+ const keepIds = hasFlag(args, null, "--keep-ids");
626
+
627
+ if (keepIds) {
628
+ cc.setPreserveIds(true);
629
+ }
630
+
631
+ const filenameConverter = convertFilename
632
+ ? text => {
633
+ let result = text;
634
+
635
+ if (normCompatExtended) {
636
+ result = cc.normalizeCompatExtended(result);
637
+ } else if (normCompat) {
638
+ result = cc.normalizeCompat(result);
639
+ }
640
+
641
+ result = cc.convert(result, punct);
642
+
643
+ if (detofuEnabled) {
644
+ result = cc.detofu(result, detofuLevel);
645
+ }
646
+
647
+ return result;
648
+ }
649
+ : null;
650
+
592
651
  if (!output) {
593
- output = makeDefaultOfficeOutput(input, officeFormat, convertFilename, cc, config, punct);
652
+ output = makeDefaultOfficeOutput(input, officeFormat, filenameConverter);
594
653
  console.error(`Output file not specified. Using: ${output}`);
595
654
  } else {
596
655
  output = applyOutputExtension(output, officeFormat);
@@ -600,11 +659,13 @@ async function runOffice(args) {
600
659
 
601
660
  const inputBytes = fs.readFileSync(input);
602
661
 
603
- const outputBytes = cc.convertOfficeBytes(
662
+ const outputBytes = cc.convertOfficeBytesPipeline(
604
663
  inputBytes,
605
664
  officeFormat,
606
665
  punct,
607
- keepFont
666
+ keepFont,
667
+ normMode,
668
+ detofuLevel
608
669
  );
609
670
 
610
671
  fs.writeFileSync(output, outputBytes);
@@ -2,7 +2,7 @@
2
2
  /* eslint-disable */
3
3
 
4
4
  /**
5
- * CJK Extension support level used by DeToFu fallback processing.
5
+ * CJK Extension support level used by DeTofu fallback processing.
6
6
  *
7
7
  * Characters beyond the selected extension level may be replaced with safer
8
8
  * fallback forms when mappings are available.
@@ -11,35 +11,62 @@ export enum DetofuLevelWasm {
11
11
  /**
12
12
  * Treat CJK Extension B as the maximum supported extension level.
13
13
  */
14
- ExtB = 2,
14
+ ExtB = 0,
15
15
  /**
16
16
  * Treat CJK Extension C as the maximum supported extension level.
17
17
  */
18
- ExtC = 3,
18
+ ExtC = 1,
19
19
  /**
20
20
  * Treat CJK Extension D as the maximum supported extension level.
21
21
  */
22
- ExtD = 4,
22
+ ExtD = 2,
23
23
  /**
24
24
  * Treat CJK Extension E as the maximum supported extension level.
25
25
  */
26
- ExtE = 5,
26
+ ExtE = 3,
27
27
  /**
28
28
  * Treat CJK Extension F as the maximum supported extension level.
29
29
  */
30
- ExtF = 6,
30
+ ExtF = 4,
31
31
  /**
32
32
  * Treat CJK Extension G as the maximum supported extension level.
33
33
  */
34
- ExtG = 7,
34
+ ExtG = 5,
35
35
  /**
36
36
  * Treat CJK Extension H as the maximum supported extension level.
37
37
  */
38
- ExtH = 8,
38
+ ExtH = 6,
39
39
  /**
40
40
  * Treat CJK Extension I as the maximum supported extension level.
41
41
  */
42
- ExtI = 9,
42
+ ExtI = 7,
43
+ }
44
+
45
+ /**
46
+ * Optional normalization stage used by Office/EPUB pipeline conversion.
47
+ *
48
+ * Pipeline order is always normalization -> OpenCC conversion -> optional DeTofu.
49
+ * `None` skips normalization entirely. The remaining variants map directly to
50
+ * the corresponding normalization APIs exposed by [`OpenccWasm`].
51
+ */
52
+ export enum NormalizeModeWasm {
53
+ /**
54
+ * Do not normalize before OpenCC conversion.
55
+ */
56
+ None = 0,
57
+ /**
58
+ * Normalize CJK Compatibility Ideographs.
59
+ */
60
+ Compat = 1,
61
+ /**
62
+ * Apply the extended Unicode compatibility table only.
63
+ */
64
+ UnicodeCompat = 2,
65
+ /**
66
+ * Apply extended Unicode compatibility normalization together with CJK
67
+ * Compatibility Ideograph normalization.
68
+ */
69
+ CompatExtended = 3,
43
70
  }
44
71
 
45
72
  /**
@@ -139,19 +166,26 @@ export class OpenccWasm {
139
166
  free(): void;
140
167
  [Symbol.dispose](): void;
141
168
  /**
142
- * Converts text using the instance's current OpenCC configuration.
169
+ * Converts text and then applies DeTofu fallback processing.
143
170
  *
144
- * `punctuation` enables the configuration's punctuation conversion when
145
- * supported. The instance configuration can be changed with [`Self::set_config`].
171
+ * This is equivalent to calling [`Self::convert`] followed by [`Self::detofu`],
172
+ * while reusing an internal output buffer for the DeTofu pass.
146
173
  */
147
- convert(text: string, punctuation: boolean): string;
174
+ convertDetofu(text: string, punctuation: boolean, level: DetofuLevelWasm): string;
148
175
  /**
149
- * Converts text and then applies DeToFu fallback processing.
176
+ * Converts a ZIP-based Office or EPUB document using the full text pipeline.
150
177
  *
151
- * This is equivalent to calling [`Self::convert`] followed by [`Self::detofu`],
152
- * while reusing an internal output buffer for the DeToFu pass.
178
+ * Processing order is fixed and explicit:
179
+ * 1. normalization selected by `norm_mode`
180
+ * 2. OpenCC conversion using this instance's current configuration
181
+ * 3. optional DeTofu processing selected by `detofu_level`
182
+ *
183
+ * `NormalizeModeWasm::None` skips normalization. Passing `None` for
184
+ * `detofu_level` skips DeTofu. Package parsing, XLSX inline-string handling,
185
+ * font preservation, EPUB rules, and ZIP validation remain owned by
186
+ * [`OfficeConverter`].
153
187
  */
154
- convertDetofu(text: string, punctuation: boolean, level: DetofuLevelWasm): string;
188
+ convertOfficeBytesPipeline(input: Uint8Array, format: string, punctuation: boolean, keep_font: boolean, norm_mode: NormalizeModeWasm, detofu_level?: DetofuLevelWasm | null): Uint8Array;
155
189
  /**
156
190
  * Converts a ZIP-based Office or EPUB document entirely in memory.
157
191
  *
@@ -163,7 +197,14 @@ export class OpenccWasm {
163
197
  */
164
198
  convertOfficeBytes(input: Uint8Array, format: string, punctuation: boolean, keep_font: boolean): Uint8Array;
165
199
  /**
166
- * Applies DeToFu fallback processing for rare CJK extension characters.
200
+ * Converts text using the instance's current OpenCC configuration.
201
+ *
202
+ * `punctuation` enables the configuration's punctuation conversion when
203
+ * supported. The instance configuration can be changed with [`Self::set_config`].
204
+ */
205
+ convert(text: string, punctuation: boolean): string;
206
+ /**
207
+ * Applies DeTofu fallback processing for rare CJK extension characters.
167
208
  *
168
209
  * `level` specifies the highest CJK Extension block considered safe for
169
210
  * display. Characters beyond that level are replaced when a fallback mapping
@@ -174,14 +215,14 @@ export class OpenccWasm {
174
215
  * Returns all canonical dictionary slot names available for custom dictionaries.
175
216
  */
176
217
  static getAvailableSlots(): string[];
177
- /**
178
- * Returns the current OpenCC configuration name.
179
- */
180
- getConfig(): string;
181
218
  /**
182
219
  * Returns the numeric FFI ID of the current OpenCC configuration.
183
220
  */
184
221
  getConfigId(): number;
222
+ /**
223
+ * Returns the current OpenCC configuration name.
224
+ */
225
+ getConfig(): string;
185
226
  /**
186
227
  * Returns whether ID-preservation behavior is enabled in the backend.
187
228
  */
@@ -194,14 +235,6 @@ export class OpenccWasm {
194
235
  * Returns whether a configuration name is supported.
195
236
  */
196
237
  static isValidConfig(config: string): boolean;
197
- /**
198
- * Creates a converter using the embedded dictionaries.
199
- *
200
- * `config` is an OpenCC configuration name such as `"s2t"` or `"t2s"`.
201
- * When omitted, the default configuration is `"s2t"`. Invalid names throw
202
- * a JavaScript error.
203
- */
204
- constructor(config?: string | null);
205
238
  /**
206
239
  * Creates a converter with one or more custom dictionary specifications.
207
240
  *
@@ -217,12 +250,13 @@ export class OpenccWasm {
217
250
  */
218
251
  static newWithEnum(config?: OpenccConfigWasm | null): OpenccWasm;
219
252
  /**
220
- * Normalizes Unicode CJK Compatibility Ideographs.
253
+ * Creates a converter using the embedded dictionaries.
221
254
  *
222
- * This is an optional pre-conversion pass. Mapped compatibility ideographs
223
- * are replaced with their unified forms; unmapped characters are preserved.
255
+ * `config` is an OpenCC configuration name such as `"s2t"` or `"t2s"`.
256
+ * When omitted, the default configuration is `"s2t"`. Invalid names throw
257
+ * a JavaScript error.
224
258
  */
225
- normalizeCompat(text: string): string;
259
+ constructor(config?: string | null);
226
260
  /**
227
261
  * Performs extended Unicode compatibility normalization.
228
262
  *
@@ -231,6 +265,13 @@ export class OpenccWasm {
231
265
  * optional normalization pre-pass before OpenCC conversion.
232
266
  */
233
267
  normalizeCompatExtended(text: string): string;
268
+ /**
269
+ * Normalizes Unicode CJK Compatibility Ideographs.
270
+ *
271
+ * This is an optional pre-conversion pass. Mapped compatibility ideographs
272
+ * are replaced with their unified forms; unmapped characters are preserved.
273
+ */
274
+ normalizeCompat(text: string): string;
234
275
  /**
235
276
  * Normalizes characters using the extended Unicode compatibility table only.
236
277
  *
@@ -238,6 +279,10 @@ export class OpenccWasm {
238
279
  * compatibility-like punctuation defined by the bundled extended table.
239
280
  */
240
281
  normalizeUnicodeCompat(text: string): string;
282
+ /**
283
+ * Changes the current configuration using an [`OpenccConfigWasm`] enum value.
284
+ */
285
+ setConfigEnum(config: OpenccConfigWasm): void;
241
286
  /**
242
287
  * Changes the current OpenCC configuration by name.
243
288
  *
@@ -245,10 +290,6 @@ export class OpenccWasm {
245
290
  * leaves the current configuration unchanged.
246
291
  */
247
292
  setConfig(config: string): boolean;
248
- /**
249
- * Changes the current configuration using an [`OpenccConfigWasm`] enum value.
250
- */
251
- setConfigEnum(config: OpenccConfigWasm): void;
252
293
  /**
253
294
  * Enables or disables ID-preservation behavior in the backend.
254
295
  */
@@ -276,15 +317,27 @@ export class OpenccWasm {
276
317
  */
277
318
  export function convert_office_bytes(input: Uint8Array, format: string, config: string, punctuation: boolean, keep_font: boolean): Uint8Array;
278
319
 
320
+ /**
321
+ * Converts a ZIP-based Office or EPUB document with the full normalization ->
322
+ * OpenCC -> optional DeTofu pipeline without creating an [`OpenccWasm`] instance.
323
+ *
324
+ * `config` is an OpenCC configuration name. `norm_mode` selects the optional
325
+ * normalization stage, and `detofu_level` selects the optional DeTofu stage.
326
+ * Package processing itself remains conversion-policy-independent.
327
+ */
328
+ export function convert_office_bytes_pipeline(input: Uint8Array, format: string, config: string, punctuation: boolean, keep_font: boolean, norm_mode: NormalizeModeWasm, detofu_level?: DetofuLevelWasm | null): Uint8Array;
329
+
279
330
  export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
280
331
 
281
332
  export interface InitOutput {
282
333
  readonly memory: WebAssembly.Memory;
283
334
  readonly __wbg_openccwasm_free: (a: number, b: number) => void;
284
335
  readonly convert_office_bytes: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => [number, number, number, number];
336
+ readonly convert_office_bytes_pipeline: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => [number, number, number, number];
285
337
  readonly openccwasm_convert: (a: number, b: number, c: number, d: number) => [number, number];
286
338
  readonly openccwasm_convertDetofu: (a: number, b: number, c: number, d: number, e: number) => [number, number];
287
339
  readonly openccwasm_convertOfficeBytes: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number, number, number];
340
+ readonly openccwasm_convertOfficeBytesPipeline: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => [number, number, number, number];
288
341
  readonly openccwasm_detofu: (a: number, b: number, c: number, d: number) => [number, number];
289
342
  readonly openccwasm_getAvailableSlots: () => [number, number];
290
343
  readonly openccwasm_getConfig: (a: number) => [number, number];
@@ -1,45 +1,73 @@
1
1
  /* @ts-self-types="./opencc_fmmseg_wasm.d.ts" */
2
2
 
3
3
  /**
4
- * CJK Extension support level used by DeToFu fallback processing.
4
+ * CJK Extension support level used by DeTofu fallback processing.
5
5
  *
6
6
  * Characters beyond the selected extension level may be replaced with safer
7
7
  * fallback forms when mappings are available.
8
- * @enum {2 | 3 | 4 | 5 | 6 | 7 | 8 | 9}
8
+ * @enum {0 | 1 | 2 | 3 | 4 | 5 | 6 | 7}
9
9
  */
10
10
  export const DetofuLevelWasm = Object.freeze({
11
11
  /**
12
12
  * Treat CJK Extension B as the maximum supported extension level.
13
13
  */
14
- ExtB: 2, "2": "ExtB",
14
+ ExtB: 0, "0": "ExtB",
15
15
  /**
16
16
  * Treat CJK Extension C as the maximum supported extension level.
17
17
  */
18
- ExtC: 3, "3": "ExtC",
18
+ ExtC: 1, "1": "ExtC",
19
19
  /**
20
20
  * Treat CJK Extension D as the maximum supported extension level.
21
21
  */
22
- ExtD: 4, "4": "ExtD",
22
+ ExtD: 2, "2": "ExtD",
23
23
  /**
24
24
  * Treat CJK Extension E as the maximum supported extension level.
25
25
  */
26
- ExtE: 5, "5": "ExtE",
26
+ ExtE: 3, "3": "ExtE",
27
27
  /**
28
28
  * Treat CJK Extension F as the maximum supported extension level.
29
29
  */
30
- ExtF: 6, "6": "ExtF",
30
+ ExtF: 4, "4": "ExtF",
31
31
  /**
32
32
  * Treat CJK Extension G as the maximum supported extension level.
33
33
  */
34
- ExtG: 7, "7": "ExtG",
34
+ ExtG: 5, "5": "ExtG",
35
35
  /**
36
36
  * Treat CJK Extension H as the maximum supported extension level.
37
37
  */
38
- ExtH: 8, "8": "ExtH",
38
+ ExtH: 6, "6": "ExtH",
39
39
  /**
40
40
  * Treat CJK Extension I as the maximum supported extension level.
41
41
  */
42
- ExtI: 9, "9": "ExtI",
42
+ ExtI: 7, "7": "ExtI",
43
+ });
44
+
45
+ /**
46
+ * Optional normalization stage used by Office/EPUB pipeline conversion.
47
+ *
48
+ * Pipeline order is always normalization -> OpenCC conversion -> optional DeTofu.
49
+ * `None` skips normalization entirely. The remaining variants map directly to
50
+ * the corresponding normalization APIs exposed by [`OpenccWasm`].
51
+ * @enum {0 | 1 | 2 | 3}
52
+ */
53
+ export const NormalizeModeWasm = Object.freeze({
54
+ /**
55
+ * Do not normalize before OpenCC conversion.
56
+ */
57
+ None: 0, "0": "None",
58
+ /**
59
+ * Normalize CJK Compatibility Ideographs.
60
+ */
61
+ Compat: 1, "1": "Compat",
62
+ /**
63
+ * Apply the extended Unicode compatibility table only.
64
+ */
65
+ UnicodeCompat: 2, "2": "UnicodeCompat",
66
+ /**
67
+ * Apply extended Unicode compatibility normalization together with CJK
68
+ * Compatibility Ideograph normalization.
69
+ */
70
+ CompatExtended: 3, "3": "CompatExtended",
43
71
  });
44
72
 
45
73
  /**
@@ -154,21 +182,22 @@ export class OpenccWasm {
154
182
  wasm.__wbg_openccwasm_free(ptr, 0);
155
183
  }
156
184
  /**
157
- * Converts text using the instance's current OpenCC configuration.
185
+ * Converts text and then applies DeTofu fallback processing.
158
186
  *
159
- * `punctuation` enables the configuration's punctuation conversion when
160
- * supported. The instance configuration can be changed with [`Self::set_config`].
187
+ * This is equivalent to calling [`Self::convert`] followed by [`Self::detofu`],
188
+ * while reusing an internal output buffer for the DeTofu pass.
161
189
  * @param {string} text
162
190
  * @param {boolean} punctuation
191
+ * @param {DetofuLevelWasm} level
163
192
  * @returns {string}
164
193
  */
165
- convert(text, punctuation) {
194
+ convertDetofu(text, punctuation, level) {
166
195
  let deferred2_0;
167
196
  let deferred2_1;
168
197
  try {
169
198
  const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
170
199
  const len0 = WASM_VECTOR_LEN;
171
- const ret = wasm.openccwasm_convert(this.__wbg_ptr, ptr0, len0, punctuation);
200
+ const ret = wasm.openccwasm_convertDetofu(this.__wbg_ptr, ptr0, len0, punctuation, level);
172
201
  deferred2_0 = ret[0];
173
202
  deferred2_1 = ret[1];
174
203
  return getStringFromWasm0(ret[0], ret[1]);
@@ -177,28 +206,37 @@ export class OpenccWasm {
177
206
  }
178
207
  }
179
208
  /**
180
- * Converts text and then applies DeToFu fallback processing.
209
+ * Converts a ZIP-based Office or EPUB document using the full text pipeline.
181
210
  *
182
- * This is equivalent to calling [`Self::convert`] followed by [`Self::detofu`],
183
- * while reusing an internal output buffer for the DeToFu pass.
184
- * @param {string} text
211
+ * Processing order is fixed and explicit:
212
+ * 1. normalization selected by `norm_mode`
213
+ * 2. OpenCC conversion using this instance's current configuration
214
+ * 3. optional DeTofu processing selected by `detofu_level`
215
+ *
216
+ * `NormalizeModeWasm::None` skips normalization. Passing `None` for
217
+ * `detofu_level` skips DeTofu. Package parsing, XLSX inline-string handling,
218
+ * font preservation, EPUB rules, and ZIP validation remain owned by
219
+ * [`OfficeConverter`].
220
+ * @param {Uint8Array} input
221
+ * @param {string} format
185
222
  * @param {boolean} punctuation
186
- * @param {DetofuLevelWasm} level
187
- * @returns {string}
223
+ * @param {boolean} keep_font
224
+ * @param {NormalizeModeWasm} norm_mode
225
+ * @param {DetofuLevelWasm | null} [detofu_level]
226
+ * @returns {Uint8Array}
188
227
  */
189
- convertDetofu(text, punctuation, level) {
190
- let deferred2_0;
191
- let deferred2_1;
192
- try {
193
- const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
194
- const len0 = WASM_VECTOR_LEN;
195
- const ret = wasm.openccwasm_convertDetofu(this.__wbg_ptr, ptr0, len0, punctuation, level);
196
- deferred2_0 = ret[0];
197
- deferred2_1 = ret[1];
198
- return getStringFromWasm0(ret[0], ret[1]);
199
- } finally {
200
- wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
228
+ convertOfficeBytesPipeline(input, format, punctuation, keep_font, norm_mode, detofu_level) {
229
+ const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_malloc);
230
+ const len0 = WASM_VECTOR_LEN;
231
+ const ptr1 = passStringToWasm0(format, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
232
+ const len1 = WASM_VECTOR_LEN;
233
+ const ret = wasm.openccwasm_convertOfficeBytesPipeline(this.__wbg_ptr, ptr0, len0, ptr1, len1, punctuation, keep_font, norm_mode, isLikeNone(detofu_level) ? 8 : detofu_level);
234
+ if (ret[3]) {
235
+ throw takeFromExternrefTable0(ret[2]);
201
236
  }
237
+ var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
238
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
239
+ return v3;
202
240
  }
203
241
  /**
204
242
  * Converts a ZIP-based Office or EPUB document entirely in memory.
@@ -228,7 +266,30 @@ export class OpenccWasm {
228
266
  return v3;
229
267
  }
230
268
  /**
231
- * Applies DeToFu fallback processing for rare CJK extension characters.
269
+ * Converts text using the instance's current OpenCC configuration.
270
+ *
271
+ * `punctuation` enables the configuration's punctuation conversion when
272
+ * supported. The instance configuration can be changed with [`Self::set_config`].
273
+ * @param {string} text
274
+ * @param {boolean} punctuation
275
+ * @returns {string}
276
+ */
277
+ convert(text, punctuation) {
278
+ let deferred2_0;
279
+ let deferred2_1;
280
+ try {
281
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
282
+ const len0 = WASM_VECTOR_LEN;
283
+ const ret = wasm.openccwasm_convert(this.__wbg_ptr, ptr0, len0, punctuation);
284
+ deferred2_0 = ret[0];
285
+ deferred2_1 = ret[1];
286
+ return getStringFromWasm0(ret[0], ret[1]);
287
+ } finally {
288
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
289
+ }
290
+ }
291
+ /**
292
+ * Applies DeTofu fallback processing for rare CJK extension characters.
232
293
  *
233
294
  * `level` specifies the highest CJK Extension block considered safe for
234
295
  * display. Characters beyond that level are replaced when a fallback mapping
@@ -261,6 +322,14 @@ export class OpenccWasm {
261
322
  wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
262
323
  return v1;
263
324
  }
325
+ /**
326
+ * Returns the numeric FFI ID of the current OpenCC configuration.
327
+ * @returns {number}
328
+ */
329
+ getConfigId() {
330
+ const ret = wasm.openccwasm_getConfigId(this.__wbg_ptr);
331
+ return ret >>> 0;
332
+ }
264
333
  /**
265
334
  * Returns the current OpenCC configuration name.
266
335
  * @returns {string}
@@ -277,14 +346,6 @@ export class OpenccWasm {
277
346
  wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
278
347
  }
279
348
  }
280
- /**
281
- * Returns the numeric FFI ID of the current OpenCC configuration.
282
- * @returns {number}
283
- */
284
- getConfigId() {
285
- const ret = wasm.openccwasm_getConfigId(this.__wbg_ptr);
286
- return ret >>> 0;
287
- }
288
349
  /**
289
350
  * Returns whether ID-preservation behavior is enabled in the backend.
290
351
  * @returns {boolean}
@@ -314,25 +375,6 @@ export class OpenccWasm {
314
375
  const ret = wasm.openccwasm_isValidConfig(ptr0, len0);
315
376
  return ret !== 0;
316
377
  }
317
- /**
318
- * Creates a converter using the embedded dictionaries.
319
- *
320
- * `config` is an OpenCC configuration name such as `"s2t"` or `"t2s"`.
321
- * When omitted, the default configuration is `"s2t"`. Invalid names throw
322
- * a JavaScript error.
323
- * @param {string | null} [config]
324
- */
325
- constructor(config) {
326
- var ptr0 = isLikeNone(config) ? 0 : passStringToWasm0(config, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
327
- var len0 = WASM_VECTOR_LEN;
328
- const ret = wasm.openccwasm_new(ptr0, len0);
329
- if (ret[2]) {
330
- throw takeFromExternrefTable0(ret[1]);
331
- }
332
- this.__wbg_ptr = ret[0];
333
- OpenccWasmFinalization.register(this, this.__wbg_ptr, this);
334
- return this;
335
- }
336
378
  /**
337
379
  * Creates a converter with one or more custom dictionary specifications.
338
380
  *
@@ -367,20 +409,40 @@ export class OpenccWasm {
367
409
  return OpenccWasm.__wrap(ret[0]);
368
410
  }
369
411
  /**
370
- * Normalizes Unicode CJK Compatibility Ideographs.
412
+ * Creates a converter using the embedded dictionaries.
371
413
  *
372
- * This is an optional pre-conversion pass. Mapped compatibility ideographs
373
- * are replaced with their unified forms; unmapped characters are preserved.
414
+ * `config` is an OpenCC configuration name such as `"s2t"` or `"t2s"`.
415
+ * When omitted, the default configuration is `"s2t"`. Invalid names throw
416
+ * a JavaScript error.
417
+ * @param {string | null} [config]
418
+ */
419
+ constructor(config) {
420
+ var ptr0 = isLikeNone(config) ? 0 : passStringToWasm0(config, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
421
+ var len0 = WASM_VECTOR_LEN;
422
+ const ret = wasm.openccwasm_new(ptr0, len0);
423
+ if (ret[2]) {
424
+ throw takeFromExternrefTable0(ret[1]);
425
+ }
426
+ this.__wbg_ptr = ret[0];
427
+ OpenccWasmFinalization.register(this, this.__wbg_ptr, this);
428
+ return this;
429
+ }
430
+ /**
431
+ * Performs extended Unicode compatibility normalization.
432
+ *
433
+ * This applies the extended Unicode compatibility table together with CJK
434
+ * Compatibility Ideograph normalization. It is intended as the broadest
435
+ * optional normalization pre-pass before OpenCC conversion.
374
436
  * @param {string} text
375
437
  * @returns {string}
376
438
  */
377
- normalizeCompat(text) {
439
+ normalizeCompatExtended(text) {
378
440
  let deferred2_0;
379
441
  let deferred2_1;
380
442
  try {
381
443
  const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
382
444
  const len0 = WASM_VECTOR_LEN;
383
- const ret = wasm.openccwasm_normalizeCompat(this.__wbg_ptr, ptr0, len0);
445
+ const ret = wasm.openccwasm_normalizeCompatExtended(this.__wbg_ptr, ptr0, len0);
384
446
  deferred2_0 = ret[0];
385
447
  deferred2_1 = ret[1];
386
448
  return getStringFromWasm0(ret[0], ret[1]);
@@ -389,21 +451,20 @@ export class OpenccWasm {
389
451
  }
390
452
  }
391
453
  /**
392
- * Performs extended Unicode compatibility normalization.
454
+ * Normalizes Unicode CJK Compatibility Ideographs.
393
455
  *
394
- * This applies the extended Unicode compatibility table together with CJK
395
- * Compatibility Ideograph normalization. It is intended as the broadest
396
- * optional normalization pre-pass before OpenCC conversion.
456
+ * This is an optional pre-conversion pass. Mapped compatibility ideographs
457
+ * are replaced with their unified forms; unmapped characters are preserved.
397
458
  * @param {string} text
398
459
  * @returns {string}
399
460
  */
400
- normalizeCompatExtended(text) {
461
+ normalizeCompat(text) {
401
462
  let deferred2_0;
402
463
  let deferred2_1;
403
464
  try {
404
465
  const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
405
466
  const len0 = WASM_VECTOR_LEN;
406
- const ret = wasm.openccwasm_normalizeCompatExtended(this.__wbg_ptr, ptr0, len0);
467
+ const ret = wasm.openccwasm_normalizeCompat(this.__wbg_ptr, ptr0, len0);
407
468
  deferred2_0 = ret[0];
408
469
  deferred2_1 = ret[1];
409
470
  return getStringFromWasm0(ret[0], ret[1]);
@@ -433,6 +494,13 @@ export class OpenccWasm {
433
494
  wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
434
495
  }
435
496
  }
497
+ /**
498
+ * Changes the current configuration using an [`OpenccConfigWasm`] enum value.
499
+ * @param {OpenccConfigWasm} config
500
+ */
501
+ setConfigEnum(config) {
502
+ wasm.openccwasm_setConfigEnum(this.__wbg_ptr, config);
503
+ }
436
504
  /**
437
505
  * Changes the current OpenCC configuration by name.
438
506
  *
@@ -447,13 +515,6 @@ export class OpenccWasm {
447
515
  const ret = wasm.openccwasm_setConfig(this.__wbg_ptr, ptr0, len0);
448
516
  return ret !== 0;
449
517
  }
450
- /**
451
- * Changes the current configuration using an [`OpenccConfigWasm`] enum value.
452
- * @param {OpenccConfigWasm} config
453
- */
454
- setConfigEnum(config) {
455
- wasm.openccwasm_setConfigEnum(this.__wbg_ptr, config);
456
- }
457
518
  /**
458
519
  * Enables or disables ID-preservation behavior in the backend.
459
520
  * @param {boolean} value
@@ -523,10 +584,42 @@ export function convert_office_bytes(input, format, config, punctuation, keep_fo
523
584
  wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
524
585
  return v4;
525
586
  }
587
+
588
+ /**
589
+ * Converts a ZIP-based Office or EPUB document with the full normalization ->
590
+ * OpenCC -> optional DeTofu pipeline without creating an [`OpenccWasm`] instance.
591
+ *
592
+ * `config` is an OpenCC configuration name. `norm_mode` selects the optional
593
+ * normalization stage, and `detofu_level` selects the optional DeTofu stage.
594
+ * Package processing itself remains conversion-policy-independent.
595
+ * @param {Uint8Array} input
596
+ * @param {string} format
597
+ * @param {string} config
598
+ * @param {boolean} punctuation
599
+ * @param {boolean} keep_font
600
+ * @param {NormalizeModeWasm} norm_mode
601
+ * @param {DetofuLevelWasm | null} [detofu_level]
602
+ * @returns {Uint8Array}
603
+ */
604
+ export function convert_office_bytes_pipeline(input, format, config, punctuation, keep_font, norm_mode, detofu_level) {
605
+ const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_malloc);
606
+ const len0 = WASM_VECTOR_LEN;
607
+ const ptr1 = passStringToWasm0(format, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
608
+ const len1 = WASM_VECTOR_LEN;
609
+ const ptr2 = passStringToWasm0(config, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
610
+ const len2 = WASM_VECTOR_LEN;
611
+ const ret = wasm.convert_office_bytes_pipeline(ptr0, len0, ptr1, len1, ptr2, len2, punctuation, keep_font, norm_mode, isLikeNone(detofu_level) ? 8 : detofu_level);
612
+ if (ret[3]) {
613
+ throw takeFromExternrefTable0(ret[2]);
614
+ }
615
+ var v4 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
616
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
617
+ return v4;
618
+ }
526
619
  function __wbg_get_imports() {
527
620
  const import0 = {
528
621
  __proto__: null,
529
- __wbg_Error_408e67f47ca7b58b: function(arg0, arg1) {
622
+ __wbg_Error_67e7344beaa85059: function(arg0, arg1) {
530
623
  const ret = Error(getStringFromWasm0(arg0, arg1));
531
624
  return ret;
532
625
  },
@@ -537,46 +630,46 @@ function __wbg_get_imports() {
537
630
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
538
631
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
539
632
  },
540
- __wbg___wbindgen_boolean_get_c9c83ebd41b34df3: function(arg0) {
633
+ __wbg___wbindgen_boolean_get_7a12af2b3f899c5a: function(arg0) {
541
634
  const v = arg0;
542
635
  const ret = typeof(v) === 'boolean' ? v : undefined;
543
636
  return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
544
637
  },
545
- __wbg___wbindgen_debug_string_a57024b9c6e4a48b: function(arg0, arg1) {
638
+ __wbg___wbindgen_debug_string_0e68cf47c9cbd9b0: function(arg0, arg1) {
546
639
  const ret = debugString(arg1);
547
640
  const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
548
641
  const len1 = WASM_VECTOR_LEN;
549
642
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
550
643
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
551
644
  },
552
- __wbg___wbindgen_in_ac983077f137f2e6: function(arg0, arg1) {
645
+ __wbg___wbindgen_in_50072d4d6e45c193: function(arg0, arg1) {
553
646
  const ret = arg0 in arg1;
554
647
  return ret;
555
648
  },
556
- __wbg___wbindgen_is_function_5e4570eb24ffa122: function(arg0) {
649
+ __wbg___wbindgen_is_function_fcda5e3902d732fe: function(arg0) {
557
650
  const ret = typeof(arg0) === 'function';
558
651
  return ret;
559
652
  },
560
- __wbg___wbindgen_is_object_a2790eb24c211ea0: function(arg0) {
653
+ __wbg___wbindgen_is_object_edb6b15aa3afe12e: function(arg0) {
561
654
  const val = arg0;
562
655
  const ret = typeof(val) === 'object' && val !== null;
563
656
  return ret;
564
657
  },
565
- __wbg___wbindgen_is_undefined_6cff064c44e0d823: function(arg0) {
658
+ __wbg___wbindgen_is_undefined_8c687d0b90d5b524: function(arg0) {
566
659
  const ret = arg0 === undefined;
567
660
  return ret;
568
661
  },
569
- __wbg___wbindgen_jsval_loose_eq_acf2776254a8d832: function(arg0, arg1) {
662
+ __wbg___wbindgen_jsval_loose_eq_3c30021c243b64cd: function(arg0, arg1) {
570
663
  const ret = arg0 == arg1;
571
664
  return ret;
572
665
  },
573
- __wbg___wbindgen_number_get_136b9679cab35cfb: function(arg0, arg1) {
666
+ __wbg___wbindgen_number_get_1dc732b810cb937c: function(arg0, arg1) {
574
667
  const obj = arg1;
575
668
  const ret = typeof(obj) === 'number' ? obj : undefined;
576
669
  getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
577
670
  getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
578
671
  },
579
- __wbg___wbindgen_string_get_d154f1e671052120: function(arg0, arg1) {
672
+ __wbg___wbindgen_string_get_92ab86bb19cbc12f: function(arg0, arg1) {
580
673
  const obj = arg1;
581
674
  const ret = typeof(obj) === 'string' ? obj : undefined;
582
675
  var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
@@ -584,22 +677,22 @@ function __wbg_get_imports() {
584
677
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
585
678
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
586
679
  },
587
- __wbg___wbindgen_throw_bb96b2010945f0bc: function(arg0, arg1) {
680
+ __wbg___wbindgen_throw_5d9e815e6fdf150f: function(arg0, arg1) {
588
681
  throw new Error(getStringFromWasm0(arg0, arg1));
589
682
  },
590
- __wbg_call_1c5886ab9c57d1c7: function() { return handleError(function (arg0, arg1) {
683
+ __wbg_call_269c5566fbede3eb: function() { return handleError(function (arg0, arg1) {
591
684
  const ret = arg0.call(arg1);
592
685
  return ret;
593
686
  }, arguments); },
594
- __wbg_done_669171204c3dcae2: function(arg0) {
687
+ __wbg_done_cffed884d87aa22e: function(arg0) {
595
688
  const ret = arg0.done;
596
689
  return ret;
597
690
  },
598
- __wbg_get_d173c0308df22d37: function() { return handleError(function (arg0, arg1) {
691
+ __wbg_get_6cf5a4d4d8ad3c5a: function() { return handleError(function (arg0, arg1) {
599
692
  const ret = Reflect.get(arg0, arg1);
600
693
  return ret;
601
694
  }, arguments); },
602
- __wbg_get_unchecked_e20b893aeafc3fca: function(arg0, arg1) {
695
+ __wbg_get_unchecked_363572bdd397d473: function(arg0, arg1) {
603
696
  const ret = arg0[arg1 >>> 0];
604
697
  return ret;
605
698
  },
@@ -607,7 +700,7 @@ function __wbg_get_imports() {
607
700
  const ret = arg0[arg1];
608
701
  return ret;
609
702
  },
610
- __wbg_instanceof_ArrayBuffer_993d02d2d254cad1: function(arg0) {
703
+ __wbg_instanceof_ArrayBuffer_d4ff01f8247925ae: function(arg0) {
611
704
  let result;
612
705
  try {
613
706
  result = arg0 instanceof ArrayBuffer;
@@ -617,7 +710,7 @@ function __wbg_get_imports() {
617
710
  const ret = result;
618
711
  return ret;
619
712
  },
620
- __wbg_instanceof_Uint8Array_f935dbb0aa7cdeed: function(arg0) {
713
+ __wbg_instanceof_Uint8Array_598adc0fef426aa8: function(arg0) {
621
714
  let result;
622
715
  try {
623
716
  result = arg0 instanceof Uint8Array;
@@ -627,42 +720,42 @@ function __wbg_get_imports() {
627
720
  const ret = result;
628
721
  return ret;
629
722
  },
630
- __wbg_isArray_6339f732981044bf: function(arg0) {
723
+ __wbg_isArray_5674713bb7b79043: function(arg0) {
631
724
  const ret = Array.isArray(arg0);
632
725
  return ret;
633
726
  },
634
- __wbg_iterator_5cebbb86e33c6dd6: function() {
727
+ __wbg_iterator_22ddeb808cf55a6f: function() {
635
728
  const ret = Symbol.iterator;
636
729
  return ret;
637
730
  },
638
- __wbg_length_36bd29c6848c2144: function(arg0) {
731
+ __wbg_length_31bdaf014f5fbde2: function(arg0) {
639
732
  const ret = arg0.length;
640
733
  return ret;
641
734
  },
642
- __wbg_length_ecfa2c63d3d0d82c: function(arg0) {
735
+ __wbg_length_4e1adc0d42e23620: function(arg0) {
643
736
  const ret = arg0.length;
644
737
  return ret;
645
738
  },
646
- __wbg_new_77cc4f4f472aeb81: function(arg0) {
739
+ __wbg_new_1da3429bc3c4541c: function(arg0) {
647
740
  const ret = new Uint8Array(arg0);
648
741
  return ret;
649
742
  },
650
- __wbg_next_42cf16ee0dafc9e2: function() { return handleError(function (arg0) {
651
- const ret = arg0.next();
652
- return ret;
653
- }, arguments); },
654
- __wbg_next_8f26b64fa5e9f64b: function(arg0) {
743
+ __wbg_next_95053e306b1c3aed: function(arg0) {
655
744
  const ret = arg0.next;
656
745
  return ret;
657
746
  },
658
- __wbg_prototypesetcall_de8e0d9553586985: function(arg0, arg1, arg2) {
747
+ __wbg_next_f31ecb8646d2c605: function() { return handleError(function (arg0) {
748
+ const ret = arg0.next();
749
+ return ret;
750
+ }, arguments); },
751
+ __wbg_prototypesetcall_ae9f5e7459250748: function(arg0, arg1, arg2) {
659
752
  Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
660
753
  },
661
- __wbg_value_1e2369fab29b420e: function(arg0) {
754
+ __wbg_value_c227f843d21da141: function(arg0) {
662
755
  const ret = arg0.value;
663
756
  return ret;
664
757
  },
665
- __wbindgen_cast_0000000000000001: function(arg0, arg1) {
758
+ __wbindgen_generic_0000000000000001: function(arg0, arg1) {
666
759
  // Cast intrinsic for `Ref(String) -> Externref`.
667
760
  const ret = getStringFromWasm0(arg0, arg1);
668
761
  return ret;
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.4.0",
5
+ "version": "0.4.1",
6
6
  "license": "MIT",
7
7
  "repository": {
8
8
  "type": "git",