typengine 0.0.2 → 0.0.5
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 +4 -1
- package/dist/index.js +66 -14
- package/package.json +7 -3
package/dist/index.d.ts
CHANGED
|
@@ -107,7 +107,10 @@ declare class Session {
|
|
|
107
107
|
get completed(): boolean;
|
|
108
108
|
}
|
|
109
109
|
//#endregion
|
|
110
|
+
//#region lib/createEnglishSentenceDefinition.d.ts
|
|
111
|
+
declare const createEnglishSentenceDefinition: (text: string, reading?: string) => SentenceDefinition;
|
|
112
|
+
//#endregion
|
|
110
113
|
//#region lib/createJapaneseSentenceDefinition.d.ts
|
|
111
114
|
declare const createJapaneseSentenceDefinition: (text: string, reading: string) => SentenceDefinition;
|
|
112
115
|
//#endregion
|
|
113
|
-
export { Character, type CharacterDefinition, type CharacterOptions, type InputResult, Sentence, type SentenceDefinition, type SentenceOptions, Session, type SessionInputResult, type SessionOptions, createJapaneseSentenceDefinition };
|
|
116
|
+
export { Character, type CharacterDefinition, type CharacterOptions, type InputResult, Sentence, type SentenceDefinition, type SentenceOptions, Session, type SessionInputResult, type SessionOptions, createEnglishSentenceDefinition, createJapaneseSentenceDefinition };
|
package/dist/index.js
CHANGED
|
@@ -160,6 +160,26 @@ var Session = class {
|
|
|
160
160
|
}
|
|
161
161
|
};
|
|
162
162
|
|
|
163
|
+
//#endregion
|
|
164
|
+
//#region lib/createEnglishSentenceDefinition.ts
|
|
165
|
+
const ALLOWED_CHARACTER = /^[A-Za-z0-9 ,.!?'-]$/;
|
|
166
|
+
const isAllowedCharacter = (char) => ALLOWED_CHARACTER.test(char);
|
|
167
|
+
const createEnglishSentenceDefinition = (text, reading = text) => {
|
|
168
|
+
const characters = [];
|
|
169
|
+
for (const char of reading) {
|
|
170
|
+
if (!isAllowedCharacter(char)) throw new Error(`Unsupported English character: ${char}`);
|
|
171
|
+
characters.push({
|
|
172
|
+
reading: char,
|
|
173
|
+
patterns: [char]
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
return {
|
|
177
|
+
text,
|
|
178
|
+
reading,
|
|
179
|
+
characters
|
|
180
|
+
};
|
|
181
|
+
};
|
|
182
|
+
|
|
163
183
|
//#endregion
|
|
164
184
|
//#region lib/createJapaneseSentenceDefinition.ts
|
|
165
185
|
const KANA_ROMAJI_MAP = {
|
|
@@ -174,13 +194,13 @@ const KANA_ROMAJI_MAP = {
|
|
|
174
194
|
け: ["ke"],
|
|
175
195
|
こ: ["ko"],
|
|
176
196
|
さ: ["sa"],
|
|
177
|
-
し: ["
|
|
197
|
+
し: ["si", "shi"],
|
|
178
198
|
す: ["su"],
|
|
179
199
|
せ: ["se"],
|
|
180
200
|
そ: ["so"],
|
|
181
201
|
た: ["ta"],
|
|
182
|
-
ち: ["
|
|
183
|
-
つ: ["
|
|
202
|
+
ち: ["ti", "chi"],
|
|
203
|
+
つ: ["tu", "tsu"],
|
|
184
204
|
て: ["te"],
|
|
185
205
|
と: ["to"],
|
|
186
206
|
な: ["na"],
|
|
@@ -215,13 +235,13 @@ const KANA_ROMAJI_MAP = {
|
|
|
215
235
|
げ: ["ge"],
|
|
216
236
|
ご: ["go"],
|
|
217
237
|
ざ: ["za"],
|
|
218
|
-
じ: ["
|
|
238
|
+
じ: ["zi", "ji"],
|
|
219
239
|
ず: ["zu"],
|
|
220
240
|
ぜ: ["ze"],
|
|
221
241
|
ぞ: ["zo"],
|
|
222
242
|
だ: ["da"],
|
|
223
|
-
ぢ: ["
|
|
224
|
-
づ: ["
|
|
243
|
+
ぢ: ["di", "zi"],
|
|
244
|
+
づ: ["du", "zu"],
|
|
225
245
|
で: ["de"],
|
|
226
246
|
ど: ["do"],
|
|
227
247
|
ば: ["ba"],
|
|
@@ -290,8 +310,8 @@ const KANA_ROMAJI_MAP = {
|
|
|
290
310
|
],
|
|
291
311
|
じゃ: [
|
|
292
312
|
"ja",
|
|
293
|
-
"jya",
|
|
294
313
|
"zya",
|
|
314
|
+
"jya",
|
|
295
315
|
"jilya",
|
|
296
316
|
"jixya",
|
|
297
317
|
"zilya",
|
|
@@ -299,8 +319,8 @@ const KANA_ROMAJI_MAP = {
|
|
|
299
319
|
],
|
|
300
320
|
じゅ: [
|
|
301
321
|
"ju",
|
|
302
|
-
"jyu",
|
|
303
322
|
"zyu",
|
|
323
|
+
"jyu",
|
|
304
324
|
"jilyu",
|
|
305
325
|
"jixyu",
|
|
306
326
|
"zilyu",
|
|
@@ -308,8 +328,8 @@ const KANA_ROMAJI_MAP = {
|
|
|
308
328
|
],
|
|
309
329
|
じょ: [
|
|
310
330
|
"jo",
|
|
311
|
-
"jyo",
|
|
312
331
|
"zyo",
|
|
332
|
+
"jyo",
|
|
313
333
|
"jilyo",
|
|
314
334
|
"jixyo",
|
|
315
335
|
"zilyo",
|
|
@@ -317,8 +337,8 @@ const KANA_ROMAJI_MAP = {
|
|
|
317
337
|
],
|
|
318
338
|
ちゃ: [
|
|
319
339
|
"cha",
|
|
320
|
-
"cya",
|
|
321
340
|
"tya",
|
|
341
|
+
"cya",
|
|
322
342
|
"chilya",
|
|
323
343
|
"chixya",
|
|
324
344
|
"tilya",
|
|
@@ -326,8 +346,8 @@ const KANA_ROMAJI_MAP = {
|
|
|
326
346
|
],
|
|
327
347
|
ちゅ: [
|
|
328
348
|
"chu",
|
|
329
|
-
"cyu",
|
|
330
349
|
"tyu",
|
|
350
|
+
"cyu",
|
|
331
351
|
"chilyu",
|
|
332
352
|
"chixyu",
|
|
333
353
|
"tilyu",
|
|
@@ -335,8 +355,8 @@ const KANA_ROMAJI_MAP = {
|
|
|
335
355
|
],
|
|
336
356
|
ちょ: [
|
|
337
357
|
"cho",
|
|
338
|
-
"cyo",
|
|
339
358
|
"tyo",
|
|
359
|
+
"cyo",
|
|
340
360
|
"chilyo",
|
|
341
361
|
"chixyo",
|
|
342
362
|
"tilyo",
|
|
@@ -431,7 +451,39 @@ const KANA_ROMAJI_MAP = {
|
|
|
431
451
|
"pyo",
|
|
432
452
|
"pilyo",
|
|
433
453
|
"pixyo"
|
|
434
|
-
]
|
|
454
|
+
],
|
|
455
|
+
てぃ: [
|
|
456
|
+
"thi",
|
|
457
|
+
"texi",
|
|
458
|
+
"teli"
|
|
459
|
+
],
|
|
460
|
+
でぃ: [
|
|
461
|
+
"dhi",
|
|
462
|
+
"dexi",
|
|
463
|
+
"deli"
|
|
464
|
+
],
|
|
465
|
+
とぅ: [
|
|
466
|
+
"twu",
|
|
467
|
+
"toxu",
|
|
468
|
+
"tolu"
|
|
469
|
+
],
|
|
470
|
+
どぅ: [
|
|
471
|
+
"dwu",
|
|
472
|
+
"doxu",
|
|
473
|
+
"dolu"
|
|
474
|
+
],
|
|
475
|
+
"、": [","],
|
|
476
|
+
"。": ["."],
|
|
477
|
+
"!": ["!"],
|
|
478
|
+
"?": ["?"],
|
|
479
|
+
ー: ["-"],
|
|
480
|
+
"「": ["["],
|
|
481
|
+
"」": ["]"],
|
|
482
|
+
"(": ["("],
|
|
483
|
+
")": [")"],
|
|
484
|
+
"・": ["/"],
|
|
485
|
+
"~": ["~"],
|
|
486
|
+
"〜": ["~"]
|
|
435
487
|
};
|
|
436
488
|
const SMALL_TSU_PATTERNS = [
|
|
437
489
|
"ltu",
|
|
@@ -489,4 +541,4 @@ const createJapaneseSentenceDefinition = (text, reading) => {
|
|
|
489
541
|
};
|
|
490
542
|
|
|
491
543
|
//#endregion
|
|
492
|
-
export { Character, Sentence, Session, createJapaneseSentenceDefinition };
|
|
544
|
+
export { Character, Sentence, Session, createEnglishSentenceDefinition, createJapaneseSentenceDefinition };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "typengine",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"description": "Core library for building typing apps and games.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"japanese",
|
|
@@ -11,6 +11,10 @@
|
|
|
11
11
|
"typing-practice"
|
|
12
12
|
],
|
|
13
13
|
"license": "MIT",
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "https://github.com/aku11i/typengine"
|
|
17
|
+
},
|
|
14
18
|
"files": [
|
|
15
19
|
"dist",
|
|
16
20
|
"LICENSE",
|
|
@@ -27,10 +31,10 @@
|
|
|
27
31
|
},
|
|
28
32
|
"devDependencies": {
|
|
29
33
|
"@types/node": "^25.0.3",
|
|
30
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
34
|
+
"@typescript/native-preview": "7.0.0-dev.20251229.1",
|
|
31
35
|
"oxfmt": "^0.20.0",
|
|
32
36
|
"oxlint": "^1.35.0",
|
|
33
|
-
"tsdown": "^0.
|
|
37
|
+
"tsdown": "^0.18.3",
|
|
34
38
|
"typescript": "^5.9.3"
|
|
35
39
|
},
|
|
36
40
|
"scripts": {
|