@read-frog/definitions 0.0.1 → 0.0.2

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.
@@ -1,12 +0,0 @@
1
- export const CHROME_EXTENSION_ORIGIN = 'chrome-extension://modkelfkcfjpgbfmnbnllalkiogfofhb'
2
- export const EDGE_EXTENSION_ORIGIN = 'extension://cbcbomlgikfbdnoaohcjfledcoklcjbo'
3
- export const TRUSTED_ORIGINS = [CHROME_EXTENSION_ORIGIN, EDGE_EXTENSION_ORIGIN]
4
-
5
- export const WEBSITE_DEV_PORT = 8888
6
- export const WEBSITE_DEV_URL = `http://localhost:${WEBSITE_DEV_PORT}`
7
- export const WEBSITE_PROD_URL = 'https://www.readfrog.app'
8
-
9
- // Domain constants for cookie monitoring and other domain-based operations
10
- export const READFROG_DOMAIN = 'readfrog.app'
11
- export const LOCALHOST_DOMAIN = 'localhost'
12
- export const AUTH_DOMAINS = [READFROG_DOMAIN, LOCALHOST_DOMAIN] as const
package/src/index.ts DELETED
@@ -1,6 +0,0 @@
1
- export * from './constants/app'
2
- export * from './constants/auth'
3
- export * from './constants/dictionary'
4
- export * from './constants/url'
5
- export * from './schemas/version'
6
- export * from './types/languages'
@@ -1,101 +0,0 @@
1
- import { z } from 'zod'
2
-
3
- /**
4
- * Semantic version regex pattern
5
- * Matches versions like: 1.0.0, 10.20.30
6
- * Does NOT match: v1.0.0, 1.0.0-alpha, 1.0, 1.-1.0
7
- */
8
- export const SEMANTIC_VERSION_REGEX = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/
9
-
10
- /**
11
- * Zod schema for semantic version validation
12
- * Validates semantic version strings according to SemVer conventions
13
- * Requires exactly 3 parts: major.minor.patch
14
- *
15
- * @example
16
- * semanticVersionSchema.parse('1.0.0') // ✓ valid
17
- * semanticVersionSchema.parse('10.20.30') // ✓ valid
18
- * semanticVersionSchema.parse('1.11') // ✗ throws error (must have 3 parts)
19
- * semanticVersionSchema.parse('v1.0.0') // ✗ throws error
20
- * semanticVersionSchema.parse('1.0.0-alpha') // ✗ throws error
21
- */
22
- export const semanticVersionSchema = z.string().regex(
23
- SEMANTIC_VERSION_REGEX,
24
- 'Must be a valid semantic version with exactly 3 parts (e.g., 1.0.0, 10.20.30)',
25
- ).refine(
26
- (version) => {
27
- // Additional validation: ensure all parts are non-negative numbers
28
- const parts = version.split('.')
29
- return parts.length === 3 && parts.every(part => !Number.isNaN(Number(part)) && Number(part) >= 0)
30
- },
31
- { message: 'Version must have exactly 3 parts and all parts must be non-negative numbers' },
32
- )
33
-
34
- /**
35
- * Type for semantic version string
36
- */
37
- export type SemanticVersion = z.infer<typeof semanticVersionSchema>
38
-
39
- /**
40
- * Version type classification
41
- */
42
- export type VersionType = 'major' | 'minor' | 'patch'
43
-
44
- /**
45
- * Parse a semantic version string into its components
46
- * Validates the input using semanticVersionSchema before parsing
47
- *
48
- * @param version - The version string to parse (must be in format major.minor.patch)
49
- * @returns An object containing the major, minor, and patch numbers
50
- * @throws {z.ZodError} If the version string is invalid
51
- *
52
- * @example
53
- * parseSemanticVersion('1.2.3') // { major: 1, minor: 2, patch: 3 }
54
- * parseSemanticVersion('10.20.30') // { major: 10, minor: 20, patch: 30 }
55
- * parseSemanticVersion('1.0') // throws error - must have 3 parts
56
- * parseSemanticVersion('v1.0.0') // throws error - invalid format
57
- */
58
- export function parseSemanticVersion(version: string): {
59
- major: number
60
- minor: number
61
- patch: number
62
- } {
63
- // Validate the version string first
64
- const validatedVersion = semanticVersionSchema.parse(version)
65
-
66
- const parts = validatedVersion.split('.')
67
- return {
68
- major: Number.parseInt(parts[0]!, 10),
69
- minor: Number.parseInt(parts[1]!, 10),
70
- patch: Number.parseInt(parts[2]!, 10),
71
- }
72
- }
73
-
74
- /**
75
- * Determine the version type (major, minor, or patch) based on semantic versioning rules
76
- * Validates the input using semanticVersionSchema before classification
77
- *
78
- * @param version - The version string to classify
79
- * @returns The version type classification
80
- * @throws {z.ZodError} If the version string is invalid
81
- *
82
- * @example
83
- * getVersionType('1.0.0') // 'major'
84
- * getVersionType('1.2.0') // 'minor'
85
- * getVersionType('1.2.3') // 'patch'
86
- * getVersionType('1.0') // throws error - must have 3 parts
87
- */
88
- export function getVersionType(version: string): VersionType {
89
- // parseSemanticVersion already validates the version
90
- const { major, minor, patch } = parseSemanticVersion(version)
91
-
92
- if (major > 0 && minor === 0 && patch === 0) {
93
- return 'major'
94
- }
95
- else if (minor > 0 && patch === 0) {
96
- return 'minor'
97
- }
98
- else {
99
- return 'patch'
100
- }
101
- }
@@ -1,415 +0,0 @@
1
- import { z } from 'zod'
2
-
3
- export const LANG_CODE_ISO6393_OPTIONS = [
4
- 'eng',
5
- 'cmn',
6
- 'cmn-Hant',
7
- 'yue',
8
- 'spa',
9
- 'rus',
10
- 'arb',
11
- 'ben',
12
- 'hin',
13
- 'por',
14
- 'ind',
15
- 'jpn',
16
- 'fra',
17
- 'deu',
18
- 'jav',
19
- 'kor',
20
- 'tel',
21
- 'vie',
22
- 'mar',
23
- 'ita',
24
- 'tam',
25
- 'tur',
26
- 'urd',
27
- 'guj',
28
- 'pol',
29
- 'ukr',
30
- 'kan',
31
- 'mai',
32
- 'mal',
33
- 'pes',
34
- 'mya',
35
- 'swh',
36
- 'sun',
37
- 'ron',
38
- 'pan',
39
- 'bho',
40
- 'amh',
41
- 'hau',
42
- 'fuv',
43
- 'bos',
44
- 'hrv',
45
- 'nld',
46
- 'srp',
47
- 'tha',
48
- 'ckb',
49
- 'yor',
50
- 'uzn',
51
- 'zlm',
52
- 'ibo',
53
- 'npi',
54
- 'ceb',
55
- 'skr',
56
- 'tgl',
57
- 'hun',
58
- 'azj',
59
- 'sin',
60
- 'koi',
61
- 'ell',
62
- 'ces',
63
- 'mag',
64
- 'run',
65
- 'bel',
66
- 'plt',
67
- 'qug',
68
- 'mad',
69
- 'nya',
70
- 'zyb',
71
- 'pbu',
72
- 'kin',
73
- 'zul',
74
- 'bul',
75
- 'swe',
76
- 'lin',
77
- 'som',
78
- 'hms',
79
- 'hnj',
80
- 'ilo',
81
- 'kaz',
82
- ] as const
83
-
84
- export const langCodeISO6393Schema = z.enum(LANG_CODE_ISO6393_OPTIONS)
85
-
86
- export const langCodeISO6391Schema = z.enum([
87
- 'en', // English
88
- 'zh', // Chinese(包含简/粤等;只是在 BCP-47 里再加 -Hans / -Hant / -yue)
89
- 'zh-TW', // Traditional Chinese
90
- 'es',
91
- 'ru',
92
- 'ar',
93
- 'bn',
94
- 'hi',
95
- 'pt',
96
- 'id',
97
- 'ja',
98
- 'fr',
99
- 'de',
100
- 'jv',
101
- 'ko',
102
- 'te',
103
- 'vi',
104
- 'mr',
105
- 'it',
106
- 'ta',
107
- 'tr',
108
- 'ur',
109
- 'gu',
110
- 'pl',
111
- 'uk',
112
- 'kn',
113
- 'ml',
114
- 'fa',
115
- 'my',
116
- 'sw',
117
- 'su',
118
- 'ro',
119
- 'pa',
120
- 'am',
121
- 'ha',
122
- 'ff',
123
- 'bs',
124
- 'hr',
125
- 'nl',
126
- 'sr',
127
- 'th',
128
- 'ku',
129
- 'yo',
130
- 'uz',
131
- 'ms',
132
- 'ig',
133
- 'ne',
134
- 'tl',
135
- 'hu',
136
- 'az',
137
- 'si',
138
- 'el',
139
- 'cs',
140
- 'ny',
141
- 'rw',
142
- 'zu',
143
- 'bg',
144
- 'sv',
145
- 'ln',
146
- 'so',
147
- 'kk',
148
- 'be',
149
- ] as const)
150
-
151
- export type LangCodeISO6391 = z.infer<typeof langCodeISO6391Schema>
152
-
153
- export type LangCodeISO6393 = z.infer<typeof langCodeISO6393Schema>
154
-
155
- export const LANG_CODE_TO_EN_NAME: Record<LangCodeISO6393, string> = {
156
- 'eng': 'English',
157
- 'cmn': 'Simplified Mandarin Chinese',
158
- 'cmn-Hant': 'Traditional Mandarin Chinese',
159
- 'yue': 'Cantonese', // not supported by franc-min
160
- 'spa': 'Spanish',
161
- 'rus': 'Russian',
162
- 'arb': 'Standard Arabic',
163
- 'ben': 'Bengali',
164
- 'hin': 'Hindi',
165
- 'por': 'Portuguese',
166
- 'ind': 'Indonesian',
167
- 'jpn': 'Japanese',
168
- 'fra': 'French',
169
- 'deu': 'German',
170
- 'jav': 'Javanese (Javanese)',
171
- 'kor': 'Korean',
172
- 'tel': 'Telugu',
173
- 'vie': 'Vietnamese',
174
- 'mar': 'Marathi',
175
- 'ita': 'Italian',
176
- 'tam': 'Tamil',
177
- 'tur': 'Turkish',
178
- 'urd': 'Urdu',
179
- 'guj': 'Gujarati',
180
- 'pol': 'Polish',
181
- 'ukr': 'Ukrainian',
182
- 'kan': 'Kannada',
183
- 'mai': 'Maithili',
184
- 'mal': 'Malayalam',
185
- 'pes': 'Iranian Persian',
186
- 'mya': 'Burmese',
187
- 'swh': 'Swahili (individual language)',
188
- 'sun': 'Sundanese',
189
- 'ron': 'Romanian',
190
- 'pan': 'Panjabi',
191
- 'bho': 'Bhojpuri',
192
- 'amh': 'Amharic',
193
- 'hau': 'Hausa',
194
- 'fuv': 'Nigerian Fulfulde',
195
- 'bos': 'Bosnian (Cyrillic)',
196
- 'hrv': 'Croatian',
197
- 'nld': 'Dutch',
198
- 'srp': 'Serbian (Cyrillic)',
199
- 'tha': 'Thai',
200
- 'ckb': 'Central Kurdish',
201
- 'yor': 'Yoruba',
202
- 'uzn': 'Northern Uzbek (Cyrillic)',
203
- 'zlm': 'Malay (individual language) (Arabic)',
204
- 'ibo': 'Igbo',
205
- 'npi': 'Nepali (individual language)',
206
- 'ceb': 'Cebuano',
207
- 'skr': 'Saraiki',
208
- 'tgl': 'Tagalog',
209
- 'hun': 'Hungarian',
210
- 'azj': 'North Azerbaijani (Cyrillic)',
211
- 'sin': 'Sinhala',
212
- 'koi': 'Komi-Permyak',
213
- 'ell': 'Modern Greek (1453-)',
214
- 'ces': 'Czech',
215
- 'mag': 'Magahi',
216
- 'run': 'Rundi',
217
- 'bel': 'Belarusian',
218
- 'plt': 'Plateau Malagasy',
219
- 'qug': 'Chimborazo Highland Quichua',
220
- 'mad': 'Madurese',
221
- 'nya': 'Nyanja',
222
- 'zyb': 'Yongbei Zhuang',
223
- 'pbu': 'Northern Pashto',
224
- 'kin': 'Kinyarwanda',
225
- 'zul': 'Zulu',
226
- 'bul': 'Bulgarian',
227
- 'swe': 'Swedish',
228
- 'lin': 'Lingala',
229
- 'som': 'Somali',
230
- 'hms': 'Southern Qiandong Miao',
231
- 'hnj': 'Hmong Njua',
232
- 'ilo': 'Iloko',
233
- 'kaz': 'Kazakh',
234
- }
235
-
236
- export const LANG_CODE_TO_LOCALE_NAME: Record<LangCodeISO6393, string> = {
237
- 'eng': 'English',
238
- 'cmn': '简体中文',
239
- 'cmn-Hant': '繁體中文',
240
- 'yue': '粵語',
241
- 'spa': 'Español',
242
- 'rus': 'Русский',
243
- 'arb': 'العربية',
244
- 'ben': 'বাংলা',
245
- 'hin': 'हिन्दी',
246
- 'por': 'Português',
247
- 'ind': 'Bahasa Indonesia',
248
- 'jpn': '日本語',
249
- 'fra': 'Français',
250
- 'deu': 'Deutsch',
251
- 'jav': 'Basa Jawa',
252
- 'kor': '한국어',
253
- 'tel': 'తెలుగు',
254
- 'vie': 'Tiếng Việt',
255
- 'mar': 'मराठी',
256
- 'ita': 'Italiano',
257
- 'tam': 'தமிழ்',
258
- 'tur': 'Türkçe',
259
- 'urd': 'اردو',
260
- 'guj': 'ગુજરાતી',
261
- 'pol': 'Polski',
262
- 'ukr': 'Українська',
263
- 'kan': 'ಕನ್ನಡ',
264
- 'mai': 'मैथिली',
265
- 'mal': 'മലയാളം',
266
- 'pes': 'فارسی',
267
- 'mya': 'မြန်မာစာ',
268
- 'swh': 'Kiswahili',
269
- 'sun': 'Basa Sunda',
270
- 'ron': 'Română',
271
- 'pan': 'ਪੰਜਾਬੀ',
272
- 'bho': 'भोजपुरी',
273
- 'amh': 'አማርኛ',
274
- 'hau': 'Hausa',
275
- 'fuv': 'Fulfulde',
276
- 'bos': 'Босански',
277
- 'hrv': 'Hrvatski',
278
- 'nld': 'Nederlands',
279
- 'srp': 'Српски',
280
- 'tha': 'ไทย',
281
- 'ckb': 'کوردیی ناوەندی',
282
- 'yor': 'Yorùbá',
283
- 'uzn': 'Ўзбекча',
284
- 'zlm': 'بهاس ملايو',
285
- 'ibo': 'Asụsụ Igbo',
286
- 'npi': 'नेपाली',
287
- 'ceb': 'Cebuano',
288
- 'skr': 'سرائیکی',
289
- 'tgl': 'Tagalog',
290
- 'hun': 'Magyar',
291
- 'azj': 'Азәрбајҹан дили',
292
- 'sin': 'සිංහල',
293
- 'koi': 'Перем Коми кыв',
294
- 'ell': 'Ελληνικά',
295
- 'ces': 'Čeština',
296
- 'mag': 'मगही',
297
- 'run': 'Ikirundi',
298
- 'bel': 'Беларуская',
299
- 'plt': 'Fiteny Malagasy',
300
- 'qug': 'Kichwa',
301
- 'mad': 'Madhurâ',
302
- 'nya': 'Chinyanja',
303
- 'zyb': 'Yongbei Bouxcuengh',
304
- 'pbu': 'پښتو',
305
- 'kin': 'Kinyarwanda',
306
- 'zul': 'isiZulu',
307
- 'bul': 'Български',
308
- 'swe': 'Svenska',
309
- 'lin': 'Lingála',
310
- 'som': 'Af Soomaali',
311
- 'hms': 'Hmongb Shuad',
312
- 'hnj': 'Hmong Njua',
313
- 'ilo': 'Ilokano',
314
- 'kaz': 'Қазақ тілі',
315
- }
316
-
317
- export const ISO6393_TO_6391: Record<LangCodeISO6393, LangCodeISO6391 | undefined> = {
318
- 'eng': 'en',
319
- 'cmn': 'zh',
320
- 'cmn-Hant': 'zh-TW',
321
- 'yue': 'zh',
322
- 'spa': 'es',
323
- 'rus': 'ru',
324
- 'arb': 'ar',
325
- 'ben': 'bn',
326
- 'hin': 'hi',
327
- 'por': 'pt',
328
- 'ind': 'id',
329
- 'jpn': 'ja',
330
- 'fra': 'fr',
331
- 'deu': 'de',
332
- 'jav': 'jv',
333
- 'kor': 'ko',
334
- 'tel': 'te',
335
- 'vie': 'vi',
336
- 'mar': 'mr',
337
- 'ita': 'it',
338
- 'tam': 'ta',
339
- 'tur': 'tr',
340
- 'urd': 'ur',
341
- 'guj': 'gu',
342
- 'pol': 'pl',
343
- 'ukr': 'uk',
344
- 'kan': 'kn',
345
- 'mai': undefined, // 无 2-letter -> undefined
346
- 'mal': 'ml',
347
- 'pes': 'fa', // Iranian Persian ⇢ fa
348
- 'mya': 'my',
349
- 'swh': 'sw',
350
- 'sun': 'su',
351
- 'ron': 'ro',
352
- 'pan': 'pa',
353
- 'bho': undefined,
354
- 'amh': 'am',
355
- 'hau': 'ha',
356
- 'fuv': 'ff', // Fulah
357
- 'bos': 'bs',
358
- 'hrv': 'hr',
359
- 'nld': 'nl',
360
- 'srp': 'sr',
361
- 'tha': 'th',
362
- 'ckb': 'ku', // 有人也写 'ckb',但 ISO-639-1 是 ku
363
- 'yor': 'yo',
364
- 'uzn': 'uz',
365
- 'zlm': 'ms', // Malay
366
- 'ibo': 'ig',
367
- 'npi': 'ne',
368
- 'ceb': undefined,
369
- 'skr': undefined,
370
- 'tgl': 'tl',
371
- 'hun': 'hu',
372
- 'azj': 'az',
373
- 'sin': 'si',
374
- 'koi': undefined,
375
- 'ell': 'el',
376
- 'ces': 'cs',
377
- 'mag': undefined,
378
- 'run': undefined,
379
- 'bel': 'be',
380
- 'plt': undefined,
381
- 'qug': undefined,
382
- 'mad': undefined,
383
- 'nya': 'ny',
384
- 'zyb': undefined,
385
- 'pbu': undefined,
386
- 'kin': 'rw',
387
- 'zul': 'zu',
388
- 'bul': 'bg',
389
- 'swe': 'sv',
390
- 'lin': 'ln',
391
- 'som': 'so',
392
- 'hms': undefined,
393
- 'hnj': undefined,
394
- 'ilo': undefined,
395
- 'kaz': 'kk',
396
- }
397
-
398
- export const LOCALE_TO_ISO6393: Partial<Record<LangCodeISO6391, LangCodeISO6393>> = {
399
- en: 'eng',
400
- zh: 'cmn',
401
- }
402
-
403
- export const langLevel = z.enum(['beginner', 'intermediate', 'advanced'])
404
- export type LangLevel = z.infer<typeof langLevel>
405
-
406
- // RTL (Right-to-Left) languages basically Arabic-based languages
407
- export const RTL_LANG_CODES: readonly LangCodeISO6393[] = [
408
- 'arb', // Standard Arabic
409
- 'urd', // Urdu
410
- 'pes', // Iranian Persian
411
- 'ckb', // Central Kurdish
412
- 'zlm', // Malay (individual language) (Arabic)
413
- 'skr', // Saraiki
414
- 'pbu', // Northern Pashto
415
- ] as const
package/tsconfig.json DELETED
@@ -1,10 +0,0 @@
1
- {
2
- "extends": "@repo/typescript-config/base.json",
3
- "compilerOptions": {
4
- "baseUrl": "."
5
- },
6
- "include": [
7
- "src/**/*.ts",
8
- "tsdown.config.ts"
9
- ]
10
- }
package/tsdown.config.ts DELETED
@@ -1,8 +0,0 @@
1
- import { defineConfig } from 'tsdown'
2
-
3
- export default defineConfig({
4
- entry: ['./src/index.ts'],
5
- platform: 'browser',
6
- exports: true,
7
- dts: true,
8
- })