@helloao/tools 0.0.4 → 0.0.6-alpha

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.
Files changed (105) hide show
  1. package/README.md +6 -6
  2. package/dist/cjs/generation/api.cjs +240 -0
  3. package/dist/cjs/generation/api.cjs.map +7 -0
  4. package/dist/cjs/generation/audio.cjs +83 -0
  5. package/dist/cjs/generation/audio.cjs.map +7 -0
  6. package/dist/cjs/generation/book-order.cjs +508 -0
  7. package/dist/cjs/generation/book-order.cjs.map +7 -0
  8. package/dist/cjs/generation/common-types.cjs +17 -0
  9. package/dist/cjs/generation/common-types.cjs.map +7 -0
  10. package/dist/cjs/generation/dataset.cjs +158 -0
  11. package/dist/cjs/generation/dataset.cjs.map +7 -0
  12. package/dist/cjs/generation/index.cjs +51 -0
  13. package/dist/cjs/generation/index.cjs.map +7 -0
  14. package/dist/cjs/index.cjs +45 -0
  15. package/dist/cjs/index.cjs.map +7 -0
  16. package/dist/cjs/parser/codex-parser.cjs +176 -0
  17. package/dist/cjs/parser/codex-parser.cjs.map +7 -0
  18. package/dist/cjs/parser/index.cjs +48 -0
  19. package/dist/cjs/parser/index.cjs.map +7 -0
  20. package/dist/cjs/parser/iterators.cjs +204 -0
  21. package/dist/cjs/parser/iterators.cjs.map +7 -0
  22. package/dist/cjs/parser/types.cjs +17 -0
  23. package/dist/cjs/parser/types.cjs.map +7 -0
  24. package/dist/cjs/parser/usfm-parser.cjs +791 -0
  25. package/dist/cjs/parser/usfm-parser.cjs.map +7 -0
  26. package/dist/cjs/parser/usx-parser.cjs +471 -0
  27. package/dist/cjs/parser/usx-parser.cjs.map +7 -0
  28. package/dist/cjs/utils.cjs +85 -0
  29. package/dist/cjs/utils.cjs.map +7 -0
  30. package/dist/esm/generation/api.js +198 -0
  31. package/dist/esm/generation/api.js.map +7 -0
  32. package/dist/esm/generation/audio.js +53 -0
  33. package/dist/esm/generation/audio.js.map +7 -0
  34. package/dist/esm/generation/book-order.js +478 -0
  35. package/dist/esm/generation/book-order.js.map +7 -0
  36. package/dist/esm/generation/common-types.js +2 -0
  37. package/dist/esm/generation/common-types.js.map +7 -0
  38. package/dist/esm/generation/dataset.js +132 -0
  39. package/dist/esm/generation/dataset.js.map +7 -0
  40. package/dist/esm/generation/index.js +8 -0
  41. package/dist/esm/generation/index.js.map +7 -0
  42. package/dist/esm/index.js +6 -0
  43. package/dist/esm/index.js.map +7 -0
  44. package/dist/esm/parser/codex-parser.js +144 -0
  45. package/dist/esm/parser/codex-parser.js.map +7 -0
  46. package/dist/esm/parser/index.js +8 -0
  47. package/dist/esm/parser/index.js.map +7 -0
  48. package/dist/esm/parser/iterators.js +152 -0
  49. package/dist/esm/parser/iterators.js.map +7 -0
  50. package/dist/esm/parser/types.js +2 -0
  51. package/dist/esm/parser/types.js.map +7 -0
  52. package/dist/esm/parser/usfm-parser.js +749 -0
  53. package/dist/esm/parser/usfm-parser.js.map +7 -0
  54. package/dist/esm/parser/usx-parser.js +447 -0
  55. package/dist/esm/parser/usx-parser.js.map +7 -0
  56. package/dist/esm/utils.js +51 -0
  57. package/dist/esm/utils.js.map +7 -0
  58. package/{generation → dist/types/generation}/api.d.ts +46 -5
  59. package/{generation → dist/types/generation}/audio.d.ts +1 -1
  60. package/{generation → dist/types/generation}/dataset.d.ts +1 -1
  61. package/dist/types/generation/index.d.ts +7 -0
  62. package/dist/types/index.d.ts +5 -0
  63. package/{parser → dist/types/parser}/codex-parser.d.ts +1 -1
  64. package/dist/types/parser/index.d.ts +7 -0
  65. package/{parser → dist/types/parser}/usfm-parser.d.ts +1 -1
  66. package/{parser → dist/types/parser}/usx-parser.d.ts +2 -2
  67. package/package.json +25 -4
  68. package/generation/api.js +0 -153
  69. package/generation/api.spec.d.ts +0 -2
  70. package/generation/api.spec.js +0 -463
  71. package/generation/audio.js +0 -60
  72. package/generation/audio.spec.d.ts +0 -2
  73. package/generation/audio.spec.js +0 -36
  74. package/generation/book-order.js +0 -494
  75. package/generation/book-order.spec.d.ts +0 -2
  76. package/generation/book-order.spec.js +0 -8
  77. package/generation/common-types.js +0 -2
  78. package/generation/dataset.js +0 -106
  79. package/generation/index.d.ts +0 -7
  80. package/generation/index.js +0 -38
  81. package/index.d.ts +0 -5
  82. package/index.js +0 -32
  83. package/parser/codex-parser.js +0 -160
  84. package/parser/codex-parser.spec.d.ts +0 -2
  85. package/parser/codex-parser.spec.js +0 -645
  86. package/parser/index.d.ts +0 -7
  87. package/parser/index.js +0 -35
  88. package/parser/iterators.js +0 -222
  89. package/parser/iterators.spec.d.ts +0 -2
  90. package/parser/iterators.spec.js +0 -174
  91. package/parser/types.js +0 -2
  92. package/parser/usfm-parser.js +0 -840
  93. package/parser/usfm-parser.spec.d.ts +0 -2
  94. package/parser/usfm-parser.spec.js +0 -1593
  95. package/parser/usx-parser.js +0 -425
  96. package/parser/usx-parser.spec.d.ts +0 -2
  97. package/parser/usx-parser.spec.js +0 -1260
  98. package/utils.js +0 -73
  99. package/utils.spec.d.ts +0 -2
  100. package/utils.spec.js +0 -42
  101. /package/{generation → dist/types/generation}/book-order.d.ts +0 -0
  102. /package/{generation → dist/types/generation}/common-types.d.ts +0 -0
  103. /package/{parser → dist/types/parser}/iterators.d.ts +0 -0
  104. /package/{parser → dist/types/parser}/types.d.ts +0 -0
  105. /package/{utils.d.ts → dist/types/utils.d.ts} +0 -0
@@ -1,494 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.bookIdMap = exports.bookChapterCountMap = exports.bookOrderMap = void 0;
4
- /**
5
- * Defines a map that maps the book ID to the numerical order of the book.
6
- */
7
- exports.bookOrderMap = new Map([
8
- ["GEN", 1],
9
- ["EXO", 2],
10
- ["LEV", 3],
11
- ["NUM", 4],
12
- ["DEU", 5],
13
- ["JOS", 6],
14
- ["JDG", 7],
15
- ["RUT", 8],
16
- ["1SA", 9],
17
- ["2SA", 10],
18
- ["1KI", 11],
19
- ["2KI", 12],
20
- ["1CH", 13],
21
- ["2CH", 14],
22
- ["EZR", 15],
23
- ["NEH", 16],
24
- ["EST", 17],
25
- ["JOB", 18],
26
- ["PSA", 19],
27
- ["PRO", 20],
28
- ["ECC", 21],
29
- ["SNG", 22],
30
- ["ISA", 23],
31
- ["JER", 24],
32
- ["LAM", 25],
33
- ["EZK", 26],
34
- ["DAN", 27],
35
- ["HOS", 28],
36
- ["JOL", 29],
37
- ["AMO", 30],
38
- ["OBA", 31],
39
- ["JON", 32],
40
- ["MIC", 33],
41
- ["NAM", 34],
42
- ["HAB", 35],
43
- ["ZEP", 36],
44
- ["HAG", 37],
45
- ["ZEC", 38],
46
- ["MAL", 39],
47
- ["MAT", 40],
48
- ["MRK", 41],
49
- ["LUK", 42],
50
- ["JHN", 43],
51
- ["ACT", 44],
52
- ["ROM", 45],
53
- ["1CO", 46],
54
- ["2CO", 47],
55
- ["GAL", 48],
56
- ["EPH", 49],
57
- ["PHP", 50],
58
- ["COL", 51],
59
- ["1TH", 52],
60
- ["2TH", 53],
61
- ["1TI", 54],
62
- ["2TI", 55],
63
- ["TIT", 56],
64
- ["PHM", 57],
65
- ["HEB", 58],
66
- ["JAS", 59],
67
- ["1PE", 60],
68
- ["2PE", 61],
69
- ["1JN", 62],
70
- ["2JN", 63],
71
- ["3JN", 64],
72
- ["JUD", 65],
73
- ["REV", 66]
74
- ]);
75
- /**
76
- * Defines a map that maps the book ID to the number of chapters the book has.
77
- */
78
- exports.bookChapterCountMap = new Map([
79
- [
80
- "GEN",
81
- 50
82
- ],
83
- [
84
- "EXO",
85
- 40
86
- ],
87
- [
88
- "LEV",
89
- 27
90
- ],
91
- [
92
- "NUM",
93
- 36
94
- ],
95
- [
96
- "DEU",
97
- 34
98
- ],
99
- [
100
- "JOS",
101
- 24
102
- ],
103
- [
104
- "JDG",
105
- 21
106
- ],
107
- [
108
- "RUT",
109
- 4
110
- ],
111
- [
112
- "1SA",
113
- 31
114
- ],
115
- [
116
- "2SA",
117
- 24
118
- ],
119
- [
120
- "1KI",
121
- 22
122
- ],
123
- [
124
- "2KI",
125
- 25
126
- ],
127
- [
128
- "1CH",
129
- 29
130
- ],
131
- [
132
- "2CH",
133
- 36
134
- ],
135
- [
136
- "EZR",
137
- 10
138
- ],
139
- [
140
- "NEH",
141
- 13
142
- ],
143
- [
144
- "EST",
145
- 10
146
- ],
147
- [
148
- "JOB",
149
- 42
150
- ],
151
- [
152
- "PSA",
153
- 150
154
- ],
155
- [
156
- "PRO",
157
- 31
158
- ],
159
- [
160
- "ECC",
161
- 12
162
- ],
163
- [
164
- "SNG",
165
- 8
166
- ],
167
- [
168
- "ISA",
169
- 66
170
- ],
171
- [
172
- "JER",
173
- 52
174
- ],
175
- [
176
- "LAM",
177
- 5
178
- ],
179
- [
180
- "EZK",
181
- 48
182
- ],
183
- [
184
- "DAN",
185
- 12
186
- ],
187
- [
188
- "HOS",
189
- 14
190
- ],
191
- [
192
- "JOL",
193
- 3
194
- ],
195
- [
196
- "AMO",
197
- 9
198
- ],
199
- [
200
- "OBA",
201
- 1
202
- ],
203
- [
204
- "JON",
205
- 4
206
- ],
207
- [
208
- "MIC",
209
- 7
210
- ],
211
- [
212
- "NAM",
213
- 3
214
- ],
215
- [
216
- "HAB",
217
- 3
218
- ],
219
- [
220
- "ZEP",
221
- 3
222
- ],
223
- [
224
- "HAG",
225
- 2
226
- ],
227
- [
228
- "ZEC",
229
- 14
230
- ],
231
- [
232
- "MAL",
233
- 4
234
- ],
235
- [
236
- "MAT",
237
- 28
238
- ],
239
- [
240
- "MRK",
241
- 16
242
- ],
243
- [
244
- "LUK",
245
- 24
246
- ],
247
- [
248
- "JHN",
249
- 21
250
- ],
251
- [
252
- "ACT",
253
- 28
254
- ],
255
- [
256
- "ROM",
257
- 16
258
- ],
259
- [
260
- "1CO",
261
- 16
262
- ],
263
- [
264
- "2CO",
265
- 13
266
- ],
267
- [
268
- "GAL",
269
- 6
270
- ],
271
- [
272
- "EPH",
273
- 6
274
- ],
275
- [
276
- "PHP",
277
- 4
278
- ],
279
- [
280
- "COL",
281
- 4
282
- ],
283
- [
284
- "1TH",
285
- 5
286
- ],
287
- [
288
- "2TH",
289
- 3
290
- ],
291
- [
292
- "1TI",
293
- 6
294
- ],
295
- [
296
- "2TI",
297
- 4
298
- ],
299
- [
300
- "TIT",
301
- 3
302
- ],
303
- [
304
- "PHM",
305
- 1
306
- ],
307
- [
308
- "HEB",
309
- 13
310
- ],
311
- [
312
- "JAS",
313
- 5
314
- ],
315
- [
316
- "1PE",
317
- 5
318
- ],
319
- [
320
- "2PE",
321
- 3
322
- ],
323
- [
324
- "1JN",
325
- 5
326
- ],
327
- [
328
- "2JN",
329
- 1
330
- ],
331
- [
332
- "3JN",
333
- 1
334
- ],
335
- [
336
- "JUD",
337
- 1
338
- ],
339
- [
340
- "REV",
341
- 22
342
- ]
343
- ]);
344
- /**
345
- * Defines a map that maps the book ID to the "common" enligsh name for the book.
346
- */
347
- const englishBookMap = new Map([
348
- ["GEN", { "commonName": "Genesis" }],
349
- ["EXO", { "commonName": "Exodus" }],
350
- ["LEV", { "commonName": "Leviticus" }],
351
- ["NUM", { "commonName": "Numbers" }],
352
- ["DEU", { "commonName": "Deuteronomy" }],
353
- ["JOS", { "commonName": "Joshua" }],
354
- ["JDG", { "commonName": "Judges" }],
355
- ["RUT", { "commonName": "Ruth" }],
356
- ["1SA", { "commonName": "1 Samuel" }],
357
- ["2SA", { "commonName": "2 Samuel" }],
358
- ["1KI", { "commonName": "1 Kings" }],
359
- ["2KI", { "commonName": "2 Kings" }],
360
- ["1CH", { "commonName": "1 Chronicles" }],
361
- ["2CH", { "commonName": "2 Chronicles" }],
362
- ["EZR", { "commonName": "Ezra" }],
363
- ["NEH", { "commonName": "Nehemiah" }],
364
- ["EST", { "commonName": "Esther" }],
365
- ["JOB", { "commonName": "Job" }],
366
- ["PSA", { "commonName": "Psalms" }],
367
- ["PRO", { "commonName": "Proverbs" }],
368
- ["ECC", { "commonName": "Ecclesiastes" }],
369
- ["SNG", { "commonName": "Song of Songs" }],
370
- ["ISA", { "commonName": "Isaiah" }],
371
- ["JER", { "commonName": "Jeremiah" }],
372
- ["LAM", { "commonName": "Lamentations" }],
373
- ["EZK", { "commonName": "Ezekiel" }],
374
- ["DAN", { "commonName": "Daniel" }],
375
- ["HOS", { "commonName": "Hosea" }],
376
- ["JOL", { "commonName": "Joel" }],
377
- ["AMO", { "commonName": "Amos" }],
378
- ["OBA", { "commonName": "Obadiah" }],
379
- ["JON", { "commonName": "Jonah" }],
380
- ["MIC", { "commonName": "Micah" }],
381
- ["NAM", { "commonName": "Nahum" }],
382
- ["HAB", { "commonName": "Habakkuk" }],
383
- ["ZEP", { "commonName": "Zephaniah" }],
384
- ["HAG", { "commonName": "Haggai" }],
385
- ["ZEC", { "commonName": "Zechariah" }],
386
- ["MAL", { "commonName": "Malachi" }],
387
- ["MAT", { "commonName": "Matthew" }],
388
- ["MRK", { "commonName": "Mark" }],
389
- ["LUK", { "commonName": "Luke" }],
390
- ["JHN", { "commonName": "John" }],
391
- ["ACT", { "commonName": "Acts" }],
392
- ["ROM", { "commonName": "Romans" }],
393
- ["1CO", { "commonName": "1 Corinthians" }],
394
- ["2CO", { "commonName": "2 Corinthians" }],
395
- ["GAL", { "commonName": "Galatians" }],
396
- ["EPH", { "commonName": "Ephesians" }],
397
- ["PHP", { "commonName": "Philippians" }],
398
- ["COL", { "commonName": "Colossians" }],
399
- ["1TH", { "commonName": "1 Thessalonians" }],
400
- ["2TH", { "commonName": "2 Thessalonians" }],
401
- ["1TI", { "commonName": "1 Timothy" }],
402
- ["2TI", { "commonName": "2 Timothy" }],
403
- ["TIT", { "commonName": "Titus" }],
404
- ["PHM", { "commonName": "Philemon" }],
405
- ["HEB", { "commonName": "Hebrews" }],
406
- ["JAS", { "commonName": "James" }],
407
- ["1PE", { "commonName": "1 Peter" }],
408
- ["2PE", { "commonName": "2 Peter" }],
409
- ["1JN", { "commonName": "1 John" }],
410
- ["2JN", { "commonName": "2 John" }],
411
- ["3JN", { "commonName": "3 John" }],
412
- ["JUD", { "commonName": "Jude" }],
413
- ["REV", { "commonName": "Revelation" }]
414
- ]);
415
- /**
416
- * Defines a map that maps the book ID to the "common" arabic name for the book.
417
- */
418
- const arabicBookMap = new Map([
419
- ["GEN", { "commonName": "التَّكوين" }],
420
- ["EXO", { "commonName": "الخُرُوج" }],
421
- ["LEV", { "commonName": "اللّاويِّين" }],
422
- ["NUM", { "commonName": "العَدَد" }],
423
- ["DEU", { "commonName": "التَّثْنِيَة" }],
424
- ["JOS", { "commonName": "يَشُوع" }],
425
- ["JDG", { "commonName": "القُضاة" }],
426
- ["RUT", { "commonName": "راعُوث" }],
427
- ["1SA", { "commonName": "صَمُوئيلَ الأوَّلُ" }],
428
- ["2SA", { "commonName": "صموئيلَ الثّانِي" }],
429
- ["1KI", { "commonName": "المُلُوكِ الأوَّلُ" }],
430
- ["2KI", { "commonName": "المُلُوكِ الثّانِي" }],
431
- ["1CH", { "commonName": "أخبارِ الأيّامِ الأوّلُ" }],
432
- ["2CH", { "commonName": " أخبارِ الأيّامِ الثّانِي" }],
433
- ["EZR", { "commonName": "عَزْرا" }],
434
- ["NEH", { "commonName": "نَحَمْيا" }],
435
- ["EST", { "commonName": "أسْتِير" }],
436
- ["JOB", { "commonName": "أيُّوب" }],
437
- ["PSA", { "commonName": "المَزامِير" }],
438
- ["PRO", { "commonName": "الأمثال" }],
439
- ["ECC", { "commonName": "الجامِعَة" }],
440
- ["SNG", { "commonName": "نَشِيدِ الأنشاد" }],
441
- ["ISA", { "commonName": "إشَعْياء" }],
442
- ["JER", { "commonName": "إرْمِيا" }],
443
- ["LAM", { "commonName": "ﻣﺮﺍﺛﻲ ﺇﺭﻣﻴﺎ" }],
444
- ["EZK", { "commonName": "حِزْقِيال" }],
445
- ["DAN", { "commonName": "دانيال" }],
446
- ["HOS", { "commonName": "هُوشَع" }],
447
- ["JOL", { "commonName": "يُوئيل" }],
448
- ["AMO", { "commonName": "عامُوس" }],
449
- ["OBA", { "commonName": "عُوبَدْيا" }],
450
- ["JON", { "commonName": "ﻳﻮﻧﺎﻥ" }],
451
- ["MIC", { "commonName": "ميخا" }],
452
- ["NAM", { "commonName": "ناحُوم" }],
453
- ["HAB", { "commonName": "حَبَقُّوق" }],
454
- ["ZEP", { "commonName": "صَفَنْيا" }],
455
- ["HAG", { "commonName": "حَجَّي" }],
456
- ["ZEC", { "commonName": "زَكَريّا" }],
457
- ["MAL", { "commonName": "مَلاخِي" }],
458
- ["MAT", { "commonName": "ﻣﺘﻰ" }],
459
- ["MRK", { "commonName": "مَرْقُس" }],
460
- ["LUK", { "commonName": "لُوقا" }],
461
- ["JHN", { "commonName": "يُوحَنّا" }],
462
- ["ACT", { "commonName": "اعمال الرسل" }],
463
- ["ROM", { "commonName": "ﺭﻭﻣﻴﺔ" }],
464
- ["1CO", { "commonName": "ﻛﻮﺭﻧﺜﻮﺱ ﺍﻻﻭﻝ" }],
465
- ["2CO", { "commonName": "ﻛﻮﺭﻧﺜﻮﺱ ﺍﻟﺜﺎﻧﻴﺔ" }],
466
- ["GAL", { "commonName": "غَلاطِيَّة" }],
467
- ["EPH", { "commonName": "أفَسُس" }],
468
- ["PHP", { "commonName": "فِيلِبِّي" }],
469
- ["COL", { "commonName": "كُولُوسِي" }],
470
- ["1TH", { "commonName": "الرِّسالَةُ الأُولَى إلَى تَسالُونِيكِي" }],
471
- ["2TH", { "commonName": "الرِّسالَةُ الثّانيَةُ إلَى تَسالُونِيكِي" }],
472
- ["1TI", { "commonName": "الرِّسالَةُ الأُولَى إلَى تِيمُوثاوُس" }],
473
- ["2TI", { "commonName": "الرِّسالَةُ الثّانيَةُ إلَى تِيمُوثاوُس" }],
474
- ["TIT", { "commonName": "تِيطُس" }],
475
- ["PHM", { "commonName": "فِلِيْمُون" }],
476
- ["HEB", { "commonName": "العِبرانِيّين" }],
477
- ["JAS", { "commonName": "يَعقُوب" }],
478
- ["1PE", { "commonName": "رسالَةُ بُطرُسَ الأُولَى" }],
479
- ["2PE", { "commonName": "رسالَةُ بُطرُسَ الثّانيَة" }],
480
- ["1JN", { "commonName": "رسالَةُ يُوحَنّا الأُولَى" }],
481
- ["2JN", { "commonName": "رسالَةُ يُوحَنّا الثّانيَة" }],
482
- ["3JN", { "commonName": "رسالَةُ يُوحَنّا الثّالثَة" }],
483
- ["JUD", { "commonName": "يَهُوذا" }],
484
- ["REV", { "commonName": "رُؤيا يُوحَنّا" }]
485
- ]);
486
- /**
487
- * Defines a map that maps a locale ID to a book name map.
488
- */
489
- exports.bookIdMap = new Map([
490
- ['en', englishBookMap],
491
- ['en-US', englishBookMap],
492
- ['eng', englishBookMap],
493
- ['arb', arabicBookMap]
494
- ]);
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=book-order.spec.d.ts.map
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const book_order_1 = require("./book-order");
4
- describe('bookIdMap', () => {
5
- it('should have all the books', () => {
6
- expect(book_order_1.bookIdMap).toMatchSnapshot();
7
- });
8
- });
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,106 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generateDataset = generateDataset;
4
- const parser_1 = require("../parser");
5
- const usx_parser_1 = require("../parser/usx-parser");
6
- const book_order_1 = require("./book-order");
7
- const lodash_1 = require("lodash");
8
- const audio_1 = require("./audio");
9
- const codex_parser_1 = require("../parser/codex-parser");
10
- /**
11
- * Generates a list of output files from the given list of input files.
12
- * @param file The list of files.
13
- */
14
- function generateDataset(files, parser = new globalThis.DOMParser()) {
15
- let output = {
16
- translations: [],
17
- };
18
- let usfmParser = new parser_1.UsfmParser();
19
- let usxParser = new usx_parser_1.USXParser(parser);
20
- let codexParser = new codex_parser_1.CodexParser();
21
- let parsedTranslations = new Map();
22
- const unknownLanguages = new Set();
23
- for (let file of files) {
24
- try {
25
- let parser;
26
- if (file.fileType === 'usfm') {
27
- parser = usfmParser;
28
- }
29
- else if (file.fileType === 'usx') {
30
- parser = usxParser;
31
- }
32
- else if (file.fileType === 'json') {
33
- parser = codexParser;
34
- }
35
- else {
36
- console.warn('[generate] File does not have a valid type!', file.name);
37
- continue;
38
- }
39
- const parsed = parser.parse(file.content);
40
- const id = parsed.id;
41
- if (!id) {
42
- console.warn('[generate] File does not have a valid book ID!', file.name, id);
43
- continue;
44
- }
45
- const order = book_order_1.bookOrderMap.get(id);
46
- if (typeof order !== 'number') {
47
- console.warn('[generate] Book does not have an order!', id);
48
- continue;
49
- }
50
- const bookMap = book_order_1.bookIdMap.get(file.metadata.translation.language);
51
- if (!bookMap) {
52
- if (!unknownLanguages.has(file.metadata.translation.language)) {
53
- console.warn('[generate] File does not have a known language!', file.name, file.metadata.translation.language);
54
- unknownLanguages.add(file.metadata.translation.language);
55
- }
56
- }
57
- const bookName = bookMap?.get(id);
58
- if (!!bookMap && !bookName) {
59
- console.warn('[generate] Book name not found for ID!', file.name, id);
60
- }
61
- let translation = parsedTranslations.get(file.metadata.translation.id);
62
- if (!translation) {
63
- translation = {
64
- ...(0, lodash_1.omit)(file.metadata.translation, 'direction'),
65
- textDirection: file.metadata.translation.direction,
66
- books: []
67
- };
68
- output.translations.push(translation);
69
- parsedTranslations.set(file.metadata.translation.id, translation);
70
- }
71
- const name = parsed.header ?? bookName?.commonName ?? parsed.title;
72
- if (!name) {
73
- console.warn('[generate] Book does not have a name!', file.name, id);
74
- continue;
75
- }
76
- const commonName = bookName?.commonName ?? parsed.header ?? parsed.title ?? id;
77
- const book = {
78
- id: id,
79
- name,
80
- commonName,
81
- title: parsed.title ?? null,
82
- order,
83
- chapters: [],
84
- };
85
- for (let content of parsed.content) {
86
- if (content.type === 'chapter') {
87
- book.chapters.push({
88
- chapter: {
89
- number: content.number,
90
- content: content.content,
91
- footnotes: content.footnotes
92
- },
93
- thisChapterAudioLinks: (0, audio_1.getAudioUrlsForChapter)(translation.id, id, content.number)
94
- });
95
- }
96
- }
97
- book.chapters = (0, lodash_1.sortBy)(book.chapters, c => c.chapter.number);
98
- const index = (0, lodash_1.sortedIndexBy)(translation.books, book, b => b.order);
99
- translation.books.splice(index, 0, book);
100
- }
101
- catch (err) {
102
- console.error(`[generate] Error occurred while parsing ${file.name}`, err);
103
- }
104
- }
105
- return output;
106
- }
@@ -1,7 +0,0 @@
1
- import * as api from './api';
2
- import * as audio from './audio';
3
- import * as dataset from './dataset';
4
- import * as bookOrder from './book-order';
5
- export * from './common-types';
6
- export { api, audio, dataset, bookOrder };
7
- //# sourceMappingURL=index.d.ts.map
@@ -1,38 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
26
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.bookOrder = exports.dataset = exports.audio = exports.api = void 0;
30
- const api = __importStar(require("./api"));
31
- exports.api = api;
32
- const audio = __importStar(require("./audio"));
33
- exports.audio = audio;
34
- const dataset = __importStar(require("./dataset"));
35
- exports.dataset = dataset;
36
- const bookOrder = __importStar(require("./book-order"));
37
- exports.bookOrder = bookOrder;
38
- __exportStar(require("./common-types"), exports);
package/index.d.ts DELETED
@@ -1,5 +0,0 @@
1
- import * as utils from './utils';
2
- import * as generation from './generation';
3
- import * as parser from './parser';
4
- export { utils, generation, parser, };
5
- //# sourceMappingURL=index.d.ts.map