typengine 0.0.2 → 0.0.4
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 +21 -1
- package/package.json +5 -1
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 = {
|
|
@@ -489,4 +509,4 @@ const createJapaneseSentenceDefinition = (text, reading) => {
|
|
|
489
509
|
};
|
|
490
510
|
|
|
491
511
|
//#endregion
|
|
492
|
-
export { Character, Sentence, Session, createJapaneseSentenceDefinition };
|
|
512
|
+
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.4",
|
|
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",
|