File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -298,5 +298,14 @@ npm install
298298npm test
299299```
300300
301+ The ` OpenCCConfig ` TypeScript declarations in ` opencc.d.ts ` ,
302+ ` opencc.d.cts ` , and ` opencc.d.mts ` are generated from
303+ ` data/config/opencc_config.schema.json ` . Regenerate them after changing the
304+ schema:
305+
306+ ``` bash
307+ npm run generate:node-config-types
308+ ```
309+
301310To build prebuilt native addons for publishing, see
302311[ ` node/PUBLISHING.md ` ] ( ./PUBLISHING.md ) .
Original file line number Diff line number Diff line change 1- type OpenCCConfig = Record < string , unknown > ;
1+ type OpenCCDict = OpenCCFileDict | OpenCCInlineDict | OpenCCGroupDict ;
2+ type OpenCCSegmentation = OpenCCMmsegSegmentation | OpenCCPluginSegmentation ;
3+ type OpenCCPluginSegmentation = {
4+ type : string ;
5+ resources ?: Record < string , string > ;
6+ [ key : string ] : string | Record < string , string > | undefined ;
7+ } ;
8+
9+ interface OpenCCConfig {
10+ name : string ;
11+ normalization ?: [ OpenCCConversion , ...OpenCCConversion [ ] ] ;
12+ segmentation ?: OpenCCSegmentation ;
13+ conversion_chain : [ OpenCCConversion , ...OpenCCConversion [ ] ] ;
14+ }
15+ interface OpenCCConversion {
16+ dict : OpenCCDict ;
17+ }
18+ interface OpenCCFileDict {
19+ type : "text" | "ocd" | "ocd2" ;
20+ file : string ;
21+ may_output_tofu ?: boolean ;
22+ }
23+ interface OpenCCInlineDict {
24+ type : "inline" ;
25+ entries : {
26+ [ k : string ] : string ;
27+ } ;
28+ }
29+ interface OpenCCGroupDict {
30+ type : "group" ;
31+ match_policy : "short_circuit" | "union" ;
32+ dicts : [ OpenCCDict , ...OpenCCDict [ ] ] ;
33+ may_output_tofu ?: boolean ;
34+ }
35+ interface OpenCCMmsegSegmentation {
36+ type : "mmseg" ;
37+ dict : OpenCCDict ;
38+ }
239
340interface OpenCCOptions {
441 includeTofuRiskDictionaries ?: boolean ;
Original file line number Diff line number Diff line change 1- type OpenCCConfig = Record < string , unknown > ;
1+ type OpenCCDict = OpenCCFileDict | OpenCCInlineDict | OpenCCGroupDict ;
2+ type OpenCCSegmentation = OpenCCMmsegSegmentation | OpenCCPluginSegmentation ;
3+ type OpenCCPluginSegmentation = {
4+ type : string ;
5+ resources ?: Record < string , string > ;
6+ [ key : string ] : string | Record < string , string > | undefined ;
7+ } ;
8+
9+ interface OpenCCConfig {
10+ name : string ;
11+ normalization ?: [ OpenCCConversion , ...OpenCCConversion [ ] ] ;
12+ segmentation ?: OpenCCSegmentation ;
13+ conversion_chain : [ OpenCCConversion , ...OpenCCConversion [ ] ] ;
14+ }
15+ interface OpenCCConversion {
16+ dict : OpenCCDict ;
17+ }
18+ interface OpenCCFileDict {
19+ type : "text" | "ocd" | "ocd2" ;
20+ file : string ;
21+ may_output_tofu ?: boolean ;
22+ }
23+ interface OpenCCInlineDict {
24+ type : "inline" ;
25+ entries : {
26+ [ k : string ] : string ;
27+ } ;
28+ }
29+ interface OpenCCGroupDict {
30+ type : "group" ;
31+ match_policy : "short_circuit" | "union" ;
32+ dicts : [ OpenCCDict , ...OpenCCDict [ ] ] ;
33+ may_output_tofu ?: boolean ;
34+ }
35+ interface OpenCCMmsegSegmentation {
36+ type : "mmseg" ;
37+ dict : OpenCCDict ;
38+ }
239
340interface OpenCCOptions {
441 includeTofuRiskDictionaries ?: boolean ;
Original file line number Diff line number Diff line change 1- type OpenCCConfig = Record < string , unknown > ;
1+ type OpenCCDict = OpenCCFileDict | OpenCCInlineDict | OpenCCGroupDict ;
2+ type OpenCCSegmentation = OpenCCMmsegSegmentation | OpenCCPluginSegmentation ;
3+ type OpenCCPluginSegmentation = {
4+ type : string ;
5+ resources ?: Record < string , string > ;
6+ [ key : string ] : string | Record < string , string > | undefined ;
7+ } ;
8+
9+ interface OpenCCConfig {
10+ name : string ;
11+ normalization ?: [ OpenCCConversion , ...OpenCCConversion [ ] ] ;
12+ segmentation ?: OpenCCSegmentation ;
13+ conversion_chain : [ OpenCCConversion , ...OpenCCConversion [ ] ] ;
14+ }
15+ interface OpenCCConversion {
16+ dict : OpenCCDict ;
17+ }
18+ interface OpenCCFileDict {
19+ type : "text" | "ocd" | "ocd2" ;
20+ file : string ;
21+ may_output_tofu ?: boolean ;
22+ }
23+ interface OpenCCInlineDict {
24+ type : "inline" ;
25+ entries : {
26+ [ k : string ] : string ;
27+ } ;
28+ }
29+ interface OpenCCGroupDict {
30+ type : "group" ;
31+ match_policy : "short_circuit" | "union" ;
32+ dicts : [ OpenCCDict , ...OpenCCDict [ ] ] ;
33+ may_output_tofu ?: boolean ;
34+ }
35+ interface OpenCCMmsegSegmentation {
36+ type : "mmseg" ;
37+ dict : OpenCCDict ;
38+ }
239
340interface OpenCCOptions {
441 includeTofuRiskDictionaries ?: boolean ;
Original file line number Diff line number Diff line change 2525 },
2626 "scripts" : {
2727 "test" : " node --test --test-reporter=spec node/test.js && node node/esm-test.mjs" ,
28+ "generate:node-config-types" : " node scripts/generate-node-opencc-config-types.js" ,
2829 "prebuild" : " prebuildify --napi --strip --postinstall \" node scripts/prepare-node-prebuild-artifacts.js\" " ,
2930 "prepare:scoped-packages" : " node scripts/prepare-node-scoped-packages.js" ,
3031 "prepack" : " node scripts/verify-node-main-package.js" ,
6364 " prebuilds/assets/*.ocd2" ,
6465 " scripts/prepare-node-prebuild-artifacts.js" ,
6566 " scripts/install.js" ,
67+ " scripts/generate-node-opencc-config-types.js" ,
6668 " scripts/prepare-node-scoped-packages.js" ,
6769 " scripts/verify-node-main-package.js" ,
6870 " scripts/verify-node-scoped-packages-published.js" ,
148150 " Traditional Chinese"
149151 ],
150152 "devDependencies" : {
153+ "json-schema-to-typescript" : " ^15.0.4" ,
151154 "prebuildify" : " ^6.0.1"
152155 },
153156 "dependencies" : {
You can’t perform that action at this time.
0 commit comments