utilitify-core 1.0.0
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/LICENSE +21 -0
- package/README.md +338 -0
- package/dist/async.cjs +25 -0
- package/dist/async.cjs.map +1 -0
- package/dist/async.d.cts +104 -0
- package/dist/async.d.ts +104 -0
- package/dist/async.js +4 -0
- package/dist/async.js.map +1 -0
- package/dist/chunk-2ICNRTSN.cjs +346 -0
- package/dist/chunk-2ICNRTSN.cjs.map +1 -0
- package/dist/chunk-3DPF72DY.js +170 -0
- package/dist/chunk-3DPF72DY.js.map +1 -0
- package/dist/chunk-4CV4JOE5.js +24 -0
- package/dist/chunk-4CV4JOE5.js.map +1 -0
- package/dist/chunk-4SLYNSLH.cjs +783 -0
- package/dist/chunk-4SLYNSLH.cjs.map +1 -0
- package/dist/chunk-5WP7DWCG.js +1285 -0
- package/dist/chunk-5WP7DWCG.js.map +1 -0
- package/dist/chunk-BMQ6YPKV.js +876 -0
- package/dist/chunk-BMQ6YPKV.js.map +1 -0
- package/dist/chunk-BZCMWUKS.cjs +479 -0
- package/dist/chunk-BZCMWUKS.cjs.map +1 -0
- package/dist/chunk-C5R744DY.cjs +173 -0
- package/dist/chunk-C5R744DY.cjs.map +1 -0
- package/dist/chunk-C75J62CV.cjs +913 -0
- package/dist/chunk-C75J62CV.cjs.map +1 -0
- package/dist/chunk-CZLDE2OZ.cjs +28 -0
- package/dist/chunk-CZLDE2OZ.cjs.map +1 -0
- package/dist/chunk-DSMB6AF6.cjs +193 -0
- package/dist/chunk-DSMB6AF6.cjs.map +1 -0
- package/dist/chunk-ETWGPOPY.js +426 -0
- package/dist/chunk-ETWGPOPY.js.map +1 -0
- package/dist/chunk-FQBPVN63.cjs +403 -0
- package/dist/chunk-FQBPVN63.cjs.map +1 -0
- package/dist/chunk-G4GYQGTW.cjs +178 -0
- package/dist/chunk-G4GYQGTW.cjs.map +1 -0
- package/dist/chunk-GFDMZDMI.js +486 -0
- package/dist/chunk-GFDMZDMI.js.map +1 -0
- package/dist/chunk-HOTOYIPB.js +171 -0
- package/dist/chunk-HOTOYIPB.js.map +1 -0
- package/dist/chunk-HYADH4ZX.js +176 -0
- package/dist/chunk-HYADH4ZX.js.map +1 -0
- package/dist/chunk-JBN7C5WE.js +255 -0
- package/dist/chunk-JBN7C5WE.js.map +1 -0
- package/dist/chunk-JNCTPFTD.cjs +25 -0
- package/dist/chunk-JNCTPFTD.cjs.map +1 -0
- package/dist/chunk-N3BH3BV7.js +21 -0
- package/dist/chunk-N3BH3BV7.js.map +1 -0
- package/dist/chunk-NFPGAVRQ.js +749 -0
- package/dist/chunk-NFPGAVRQ.js.map +1 -0
- package/dist/chunk-OFFRGRBN.cjs +1332 -0
- package/dist/chunk-OFFRGRBN.cjs.map +1 -0
- package/dist/chunk-OZLKYIZL.cjs +490 -0
- package/dist/chunk-OZLKYIZL.cjs.map +1 -0
- package/dist/chunk-P3NUK46X.js +145 -0
- package/dist/chunk-P3NUK46X.js.map +1 -0
- package/dist/chunk-P7P2B7ZI.cjs +429 -0
- package/dist/chunk-P7P2B7ZI.cjs.map +1 -0
- package/dist/chunk-PB6SKSJN.cjs +150 -0
- package/dist/chunk-PB6SKSJN.cjs.map +1 -0
- package/dist/chunk-R3IXCJR7.js +378 -0
- package/dist/chunk-R3IXCJR7.js.map +1 -0
- package/dist/chunk-SD6P3WEJ.js +324 -0
- package/dist/chunk-SD6P3WEJ.js.map +1 -0
- package/dist/chunk-YSCHP26P.js +451 -0
- package/dist/chunk-YSCHP26P.js.map +1 -0
- package/dist/chunk-ZLMPRPCY.cjs +274 -0
- package/dist/chunk-ZLMPRPCY.cjs.map +1 -0
- package/dist/common-CBDYNJeh.d.cts +48 -0
- package/dist/common-CBDYNJeh.d.ts +48 -0
- package/dist/constants.cjs +42 -0
- package/dist/constants.cjs.map +1 -0
- package/dist/constants.d.cts +60 -0
- package/dist/constants.d.ts +60 -0
- package/dist/constants.js +5 -0
- package/dist/constants.js.map +1 -0
- package/dist/country/index.cjs +154 -0
- package/dist/country/index.cjs.map +1 -0
- package/dist/country/index.d.cts +1 -0
- package/dist/country/index.d.ts +1 -0
- package/dist/country/index.js +5 -0
- package/dist/country/index.js.map +1 -0
- package/dist/date/index.cjs +117 -0
- package/dist/date/index.cjs.map +1 -0
- package/dist/date/index.d.cts +283 -0
- package/dist/date/index.d.ts +283 -0
- package/dist/date/index.js +4 -0
- package/dist/date/index.js.map +1 -0
- package/dist/environment/index.cjs +73 -0
- package/dist/environment/index.cjs.map +1 -0
- package/dist/environment/index.d.cts +127 -0
- package/dist/environment/index.d.ts +127 -0
- package/dist/environment/index.js +4 -0
- package/dist/environment/index.js.map +1 -0
- package/dist/form/index.cjs +81 -0
- package/dist/form/index.cjs.map +1 -0
- package/dist/form/index.d.cts +227 -0
- package/dist/form/index.d.ts +227 -0
- package/dist/form/index.js +4 -0
- package/dist/form/index.js.map +1 -0
- package/dist/i18n.cjs +37 -0
- package/dist/i18n.cjs.map +1 -0
- package/dist/i18n.d.cts +102 -0
- package/dist/i18n.d.ts +102 -0
- package/dist/i18n.js +4 -0
- package/dist/i18n.js.map +1 -0
- package/dist/index-BXBmBHyL.d.ts +718 -0
- package/dist/index-BYsUCP3u.d.cts +718 -0
- package/dist/index-Cl26FrAZ.d.cts +362 -0
- package/dist/index-Cl26FrAZ.d.ts +362 -0
- package/dist/index.cjs +1265 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +205 -0
- package/dist/index.d.ts +205 -0
- package/dist/index.js +277 -0
- package/dist/index.js.map +1 -0
- package/dist/schema.cjs +13 -0
- package/dist/schema.cjs.map +1 -0
- package/dist/schema.d.cts +84 -0
- package/dist/schema.d.ts +84 -0
- package/dist/schema.js +4 -0
- package/dist/schema.js.map +1 -0
- package/dist/security/index.cjs +94 -0
- package/dist/security/index.cjs.map +1 -0
- package/dist/security/index.d.cts +216 -0
- package/dist/security/index.d.ts +216 -0
- package/dist/security/index.js +5 -0
- package/dist/security/index.js.map +1 -0
- package/dist/string/index.cjs +153 -0
- package/dist/string/index.cjs.map +1 -0
- package/dist/string/index.d.cts +471 -0
- package/dist/string/index.d.ts +471 -0
- package/dist/string/index.js +4 -0
- package/dist/string/index.js.map +1 -0
- package/dist/transform/index.cjs +105 -0
- package/dist/transform/index.cjs.map +1 -0
- package/dist/transform/index.d.cts +271 -0
- package/dist/transform/index.d.ts +271 -0
- package/dist/transform/index.js +4 -0
- package/dist/transform/index.js.map +1 -0
- package/dist/validators/index.cjs +195 -0
- package/dist/validators/index.cjs.map +1 -0
- package/dist/validators/index.d.cts +2 -0
- package/dist/validators/index.d.ts +2 -0
- package/dist/validators/index.js +6 -0
- package/dist/validators/index.js.map +1 -0
- package/package.json +229 -0
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Age calculation result
|
|
3
|
+
*/
|
|
4
|
+
interface AgeResult {
|
|
5
|
+
years: number;
|
|
6
|
+
months: number;
|
|
7
|
+
days: number;
|
|
8
|
+
totalDays: number;
|
|
9
|
+
isAdult: boolean;
|
|
10
|
+
isSenior: boolean;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Calculate age from date of birth
|
|
14
|
+
*
|
|
15
|
+
* @param dob - Date of birth
|
|
16
|
+
* @param referenceDate - Reference date (default: now)
|
|
17
|
+
* @returns Age details
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* calculateAge('1990-05-15'); // { years: 35, months: 7, days: 26, ... }
|
|
22
|
+
* calculateAge(new Date('2000-01-01')); // { years: 26, ... }
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
declare function calculateAge(dob: Date | string, referenceDate?: Date): AgeResult;
|
|
26
|
+
/**
|
|
27
|
+
* Get age in years
|
|
28
|
+
*
|
|
29
|
+
* @param dob - Date of birth
|
|
30
|
+
* @returns Age in years
|
|
31
|
+
*/
|
|
32
|
+
declare function getAgeInYears(dob: Date | string): number;
|
|
33
|
+
/**
|
|
34
|
+
* Check if person is adult
|
|
35
|
+
*
|
|
36
|
+
* @param dob - Date of birth
|
|
37
|
+
* @param minAge - Minimum adult age (default: 18)
|
|
38
|
+
* @returns true if adult
|
|
39
|
+
*/
|
|
40
|
+
declare function isAdult(dob: Date | string, minAge?: number): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Check if person is minor
|
|
43
|
+
*
|
|
44
|
+
* @param dob - Date of birth
|
|
45
|
+
* @param adultAge - Adult age threshold (default: 18)
|
|
46
|
+
* @returns true if minor
|
|
47
|
+
*/
|
|
48
|
+
declare function isMinor(dob: Date | string, adultAge?: number): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Get age bracket/category
|
|
51
|
+
*
|
|
52
|
+
* @param dob - Date of birth
|
|
53
|
+
* @returns Age bracket name
|
|
54
|
+
*/
|
|
55
|
+
declare function getAgeBracket(dob: Date | string): string;
|
|
56
|
+
/**
|
|
57
|
+
* Get date of birth required for minimum age
|
|
58
|
+
*
|
|
59
|
+
* @param minAge - Minimum age required
|
|
60
|
+
* @returns Date of birth that would make someone exactly that age today
|
|
61
|
+
*/
|
|
62
|
+
declare function getMinAgeDOB(minAge: number): Date;
|
|
63
|
+
/**
|
|
64
|
+
* Validate age is within range
|
|
65
|
+
*
|
|
66
|
+
* @param dob - Date of birth
|
|
67
|
+
* @param minAge - Minimum age
|
|
68
|
+
* @param maxAge - Maximum age
|
|
69
|
+
* @returns true if age is within range
|
|
70
|
+
*/
|
|
71
|
+
declare function isAgeInRange(dob: Date | string, minAge: number, maxAge: number): boolean;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Format options for dates
|
|
75
|
+
*/
|
|
76
|
+
interface DateFormatOptions {
|
|
77
|
+
/** Date style */
|
|
78
|
+
dateStyle?: 'full' | 'long' | 'medium' | 'short';
|
|
79
|
+
/** Time style */
|
|
80
|
+
timeStyle?: 'full' | 'long' | 'medium' | 'short';
|
|
81
|
+
/** Include time */
|
|
82
|
+
includeTime?: boolean;
|
|
83
|
+
/** Timezone */
|
|
84
|
+
timeZone?: string;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Format date by locale
|
|
88
|
+
*
|
|
89
|
+
* @param date - Date to format
|
|
90
|
+
* @param locale - Locale code (e.g., 'en-US', 'de-DE')
|
|
91
|
+
* @param options - Format options
|
|
92
|
+
* @returns Formatted date string
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* ```typescript
|
|
96
|
+
* formatDateByLocale(new Date(), 'en-US'); // 'January 11, 2026'
|
|
97
|
+
* formatDateByLocale(new Date(), 'de-DE'); // '11. Januar 2026'
|
|
98
|
+
* ```
|
|
99
|
+
*/
|
|
100
|
+
declare function formatDateByLocale(date: Date | string, locale?: string, options?: DateFormatOptions): string;
|
|
101
|
+
/**
|
|
102
|
+
* Format relative time (e.g., "2 hours ago", "in 3 days")
|
|
103
|
+
*
|
|
104
|
+
* @param date - Date to compare
|
|
105
|
+
* @param locale - Locale code
|
|
106
|
+
* @param referenceDate - Reference date (default: now)
|
|
107
|
+
* @returns Relative time string
|
|
108
|
+
*
|
|
109
|
+
* @example
|
|
110
|
+
* ```typescript
|
|
111
|
+
* formatRelativeTime(new Date(Date.now() - 3600000)); // '1 hour ago'
|
|
112
|
+
* formatRelativeTime(new Date(Date.now() + 86400000)); // 'in 1 day'
|
|
113
|
+
* ```
|
|
114
|
+
*/
|
|
115
|
+
declare function formatRelativeTime(date: Date | string, locale?: string, referenceDate?: Date): string;
|
|
116
|
+
/**
|
|
117
|
+
* Format date as ISO string (date only)
|
|
118
|
+
*
|
|
119
|
+
* @param date - Date to format
|
|
120
|
+
* @returns ISO date string (YYYY-MM-DD)
|
|
121
|
+
*/
|
|
122
|
+
declare function toISODate(date: Date | string): string;
|
|
123
|
+
/**
|
|
124
|
+
* Format date to common patterns
|
|
125
|
+
*/
|
|
126
|
+
declare function formatDate(date: Date | string, pattern: string): string;
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Check if a value is a valid date
|
|
130
|
+
*
|
|
131
|
+
* @param date - Value to check
|
|
132
|
+
* @returns true if valid date
|
|
133
|
+
*/
|
|
134
|
+
declare function isValidDate(date: unknown): boolean;
|
|
135
|
+
/**
|
|
136
|
+
* Parse date from various formats
|
|
137
|
+
*
|
|
138
|
+
* @param value - Value to parse
|
|
139
|
+
* @returns Date or null
|
|
140
|
+
*
|
|
141
|
+
* @example
|
|
142
|
+
* ```typescript
|
|
143
|
+
* parseDate('2024-01-15'); // ISO format
|
|
144
|
+
* parseDate('15/01/2024'); // DD/MM/YYYY
|
|
145
|
+
* parseDate('01-15-2024'); // MM-DD-YYYY
|
|
146
|
+
* parseDate('2024/01/15'); // YYYY/MM/DD
|
|
147
|
+
* parseDate('2024-01-15T10:30:00Z'); // ISO 8601
|
|
148
|
+
* ```
|
|
149
|
+
*/
|
|
150
|
+
declare function parseDate(value: unknown): Date | null;
|
|
151
|
+
/**
|
|
152
|
+
* Check if date is in the past
|
|
153
|
+
*
|
|
154
|
+
* @param date - Date to check
|
|
155
|
+
* @returns true if in the past
|
|
156
|
+
*/
|
|
157
|
+
declare function isInPast(date: Date | string): boolean;
|
|
158
|
+
/**
|
|
159
|
+
* Check if date is in the future
|
|
160
|
+
*
|
|
161
|
+
* @param date - Date to check
|
|
162
|
+
* @returns true if in the future
|
|
163
|
+
*/
|
|
164
|
+
declare function isInFuture(date: Date | string): boolean;
|
|
165
|
+
/**
|
|
166
|
+
* Check if date is today
|
|
167
|
+
*
|
|
168
|
+
* @param date - Date to check
|
|
169
|
+
* @returns true if today
|
|
170
|
+
*/
|
|
171
|
+
declare function isToday(date: Date | string): boolean;
|
|
172
|
+
/**
|
|
173
|
+
* Check if date is a weekend
|
|
174
|
+
*
|
|
175
|
+
* @param date - Date to check
|
|
176
|
+
* @returns true if Saturday or Sunday
|
|
177
|
+
*/
|
|
178
|
+
declare function isWeekend(date: Date | string): boolean;
|
|
179
|
+
/**
|
|
180
|
+
* Check if date is a weekday
|
|
181
|
+
*
|
|
182
|
+
* @param date - Date to check
|
|
183
|
+
* @returns true if Monday-Friday
|
|
184
|
+
*/
|
|
185
|
+
declare function isWeekday(date: Date | string): boolean;
|
|
186
|
+
/**
|
|
187
|
+
* Check if year is a leap year
|
|
188
|
+
*
|
|
189
|
+
* @param year - Year to check
|
|
190
|
+
* @returns true if leap year
|
|
191
|
+
*/
|
|
192
|
+
declare function isLeapYear(year: number): boolean;
|
|
193
|
+
/**
|
|
194
|
+
* Get number of days in a month
|
|
195
|
+
*
|
|
196
|
+
* @param year - Year
|
|
197
|
+
* @param month - Month (1-12)
|
|
198
|
+
* @returns Number of days
|
|
199
|
+
*/
|
|
200
|
+
declare function getDaysInMonth(year: number, month: number): number;
|
|
201
|
+
/**
|
|
202
|
+
* Check if date is between two dates
|
|
203
|
+
*
|
|
204
|
+
* @param date - Date to check
|
|
205
|
+
* @param start - Start date
|
|
206
|
+
* @param end - End date
|
|
207
|
+
* @param inclusive - Include start and end dates
|
|
208
|
+
* @returns true if date is between
|
|
209
|
+
*/
|
|
210
|
+
declare function isBetween(date: Date | string, start: Date | string, end: Date | string, inclusive?: boolean): boolean;
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Time difference result
|
|
214
|
+
*/
|
|
215
|
+
interface TimeDiff {
|
|
216
|
+
years: number;
|
|
217
|
+
months: number;
|
|
218
|
+
weeks: number;
|
|
219
|
+
days: number;
|
|
220
|
+
hours: number;
|
|
221
|
+
minutes: number;
|
|
222
|
+
seconds: number;
|
|
223
|
+
milliseconds: number;
|
|
224
|
+
totalDays: number;
|
|
225
|
+
totalHours: number;
|
|
226
|
+
totalMinutes: number;
|
|
227
|
+
totalSeconds: number;
|
|
228
|
+
totalMilliseconds: number;
|
|
229
|
+
isPast: boolean;
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Calculate difference between two dates
|
|
233
|
+
*
|
|
234
|
+
* @param date1 - First date
|
|
235
|
+
* @param date2 - Second date (default: now)
|
|
236
|
+
* @returns Time difference
|
|
237
|
+
*/
|
|
238
|
+
declare function getTimeDiff(date1: Date | string, date2?: Date | string): TimeDiff;
|
|
239
|
+
/**
|
|
240
|
+
* Get difference in specific unit
|
|
241
|
+
*
|
|
242
|
+
* @param date1 - First date
|
|
243
|
+
* @param date2 - Second date
|
|
244
|
+
* @param unit - Time unit
|
|
245
|
+
* @returns Difference in specified unit
|
|
246
|
+
*/
|
|
247
|
+
declare function diffIn(date1: Date | string, date2: Date | string, unit: 'years' | 'months' | 'weeks' | 'days' | 'hours' | 'minutes' | 'seconds'): number;
|
|
248
|
+
/**
|
|
249
|
+
* Add time to date
|
|
250
|
+
*
|
|
251
|
+
* @param date - Base date
|
|
252
|
+
* @param amount - Amount to add
|
|
253
|
+
* @param unit - Time unit
|
|
254
|
+
* @returns New date
|
|
255
|
+
*/
|
|
256
|
+
declare function addTime(date: Date | string, amount: number, unit: 'years' | 'months' | 'weeks' | 'days' | 'hours' | 'minutes' | 'seconds'): Date;
|
|
257
|
+
/**
|
|
258
|
+
* Subtract time from date
|
|
259
|
+
*
|
|
260
|
+
* @param date - Base date
|
|
261
|
+
* @param amount - Amount to subtract
|
|
262
|
+
* @param unit - Time unit
|
|
263
|
+
* @returns New date
|
|
264
|
+
*/
|
|
265
|
+
declare function subtractTime(date: Date | string, amount: number, unit: 'years' | 'months' | 'weeks' | 'days' | 'hours' | 'minutes' | 'seconds'): Date;
|
|
266
|
+
/**
|
|
267
|
+
* Get start of time period
|
|
268
|
+
*
|
|
269
|
+
* @param date - Date
|
|
270
|
+
* @param unit - Time unit
|
|
271
|
+
* @returns Start of period
|
|
272
|
+
*/
|
|
273
|
+
declare function startOf(date: Date | string, unit: 'year' | 'month' | 'week' | 'day' | 'hour' | 'minute'): Date;
|
|
274
|
+
/**
|
|
275
|
+
* Get end of time period
|
|
276
|
+
*
|
|
277
|
+
* @param date - Date
|
|
278
|
+
* @param unit - Time unit
|
|
279
|
+
* @returns End of period
|
|
280
|
+
*/
|
|
281
|
+
declare function endOf(date: Date | string, unit: 'year' | 'month' | 'week' | 'day' | 'hour' | 'minute'): Date;
|
|
282
|
+
|
|
283
|
+
export { type AgeResult, type DateFormatOptions, type TimeDiff, addTime, calculateAge, diffIn, endOf, formatDate, formatDateByLocale, formatRelativeTime, getAgeBracket, getAgeInYears, getDaysInMonth, getMinAgeDOB, getTimeDiff, isAdult, isAgeInRange, isBetween, isInFuture, isInPast, isLeapYear, isMinor, isToday, isValidDate, isWeekday, isWeekend, parseDate, startOf, subtractTime, toISODate };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { addTime, calculateAge, diffIn, endOf, formatDate, formatDateByLocale, formatRelativeTime, getAgeBracket, getAgeInYears, getDaysInMonth, getMinAgeDOB, getTimeDiff, isAdult, isAgeInRange, isBetween, isInFuture, isInPast, isLeapYear, isMinor, isToday, isValidDate, isWeekday, isWeekend, parseDate, startOf, subtractTime, toISODate } from '../chunk-YSCHP26P.js';
|
|
2
|
+
import '../chunk-4CV4JOE5.js';
|
|
3
|
+
//# sourceMappingURL=index.js.map
|
|
4
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkDSMB6AF6_cjs = require('../chunk-DSMB6AF6.cjs');
|
|
4
|
+
require('../chunk-CZLDE2OZ.cjs');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
Object.defineProperty(exports, "detectClient", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function () { return chunkDSMB6AF6_cjs.detectClient; }
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "getEnv", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () { return chunkDSMB6AF6_cjs.getEnv; }
|
|
15
|
+
});
|
|
16
|
+
Object.defineProperty(exports, "getEnvBoolean", {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: function () { return chunkDSMB6AF6_cjs.getEnvBoolean; }
|
|
19
|
+
});
|
|
20
|
+
Object.defineProperty(exports, "getEnvNumber", {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get: function () { return chunkDSMB6AF6_cjs.getEnvNumber; }
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "getRequiredEnv", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () { return chunkDSMB6AF6_cjs.getRequiredEnv; }
|
|
27
|
+
});
|
|
28
|
+
Object.defineProperty(exports, "getScreenSize", {
|
|
29
|
+
enumerable: true,
|
|
30
|
+
get: function () { return chunkDSMB6AF6_cjs.getScreenSize; }
|
|
31
|
+
});
|
|
32
|
+
Object.defineProperty(exports, "isBrowser", {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: function () { return chunkDSMB6AF6_cjs.isBrowser; }
|
|
35
|
+
});
|
|
36
|
+
Object.defineProperty(exports, "isDevelopment", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function () { return chunkDSMB6AF6_cjs.isDevelopment; }
|
|
39
|
+
});
|
|
40
|
+
Object.defineProperty(exports, "isMobile", {
|
|
41
|
+
enumerable: true,
|
|
42
|
+
get: function () { return chunkDSMB6AF6_cjs.isMobile; }
|
|
43
|
+
});
|
|
44
|
+
Object.defineProperty(exports, "isNode", {
|
|
45
|
+
enumerable: true,
|
|
46
|
+
get: function () { return chunkDSMB6AF6_cjs.isNode; }
|
|
47
|
+
});
|
|
48
|
+
Object.defineProperty(exports, "isProduction", {
|
|
49
|
+
enumerable: true,
|
|
50
|
+
get: function () { return chunkDSMB6AF6_cjs.isProduction; }
|
|
51
|
+
});
|
|
52
|
+
Object.defineProperty(exports, "isTest", {
|
|
53
|
+
enumerable: true,
|
|
54
|
+
get: function () { return chunkDSMB6AF6_cjs.isTest; }
|
|
55
|
+
});
|
|
56
|
+
Object.defineProperty(exports, "isTouchDevice", {
|
|
57
|
+
enumerable: true,
|
|
58
|
+
get: function () { return chunkDSMB6AF6_cjs.isTouchDevice; }
|
|
59
|
+
});
|
|
60
|
+
Object.defineProperty(exports, "prefersDarkMode", {
|
|
61
|
+
enumerable: true,
|
|
62
|
+
get: function () { return chunkDSMB6AF6_cjs.prefersDarkMode; }
|
|
63
|
+
});
|
|
64
|
+
Object.defineProperty(exports, "prefersReducedMotion", {
|
|
65
|
+
enumerable: true,
|
|
66
|
+
get: function () { return chunkDSMB6AF6_cjs.prefersReducedMotion; }
|
|
67
|
+
});
|
|
68
|
+
Object.defineProperty(exports, "validateEnv", {
|
|
69
|
+
enumerable: true,
|
|
70
|
+
get: function () { return chunkDSMB6AF6_cjs.validateEnv; }
|
|
71
|
+
});
|
|
72
|
+
//# sourceMappingURL=index.cjs.map
|
|
73
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.cjs"}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser/OS detection result
|
|
3
|
+
*/
|
|
4
|
+
interface ClientInfo {
|
|
5
|
+
browser: {
|
|
6
|
+
name: string;
|
|
7
|
+
version: string;
|
|
8
|
+
};
|
|
9
|
+
os: {
|
|
10
|
+
name: string;
|
|
11
|
+
version: string;
|
|
12
|
+
};
|
|
13
|
+
device: 'desktop' | 'mobile' | 'tablet' | 'unknown';
|
|
14
|
+
isMobile: boolean;
|
|
15
|
+
isTablet: boolean;
|
|
16
|
+
isDesktop: boolean;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Detect browser and OS from user agent
|
|
20
|
+
*
|
|
21
|
+
* @param userAgent - User agent string (defaults to navigator.userAgent)
|
|
22
|
+
* @returns Client information
|
|
23
|
+
*/
|
|
24
|
+
declare function detectClient(userAgent?: string): ClientInfo;
|
|
25
|
+
/**
|
|
26
|
+
* Check if running in browser
|
|
27
|
+
*/
|
|
28
|
+
declare function isBrowser(): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Check if running in Node.js
|
|
31
|
+
*/
|
|
32
|
+
declare function isNode(): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Check if running on mobile
|
|
35
|
+
*/
|
|
36
|
+
declare function isMobile(userAgent?: string): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Check if touch device
|
|
39
|
+
*/
|
|
40
|
+
declare function isTouchDevice(): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Get screen size category
|
|
43
|
+
*/
|
|
44
|
+
declare function getScreenSize(): 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'unknown';
|
|
45
|
+
/**
|
|
46
|
+
* Check if user prefers dark mode
|
|
47
|
+
*/
|
|
48
|
+
declare function prefersDarkMode(): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Check if user prefers reduced motion
|
|
51
|
+
*/
|
|
52
|
+
declare function prefersReducedMotion(): boolean;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Environment variable validation result
|
|
56
|
+
*/
|
|
57
|
+
interface EnvValidationResult {
|
|
58
|
+
isValid: boolean;
|
|
59
|
+
missing: string[];
|
|
60
|
+
invalid: string[];
|
|
61
|
+
values: Record<string, string>;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Environment variable schema
|
|
65
|
+
*/
|
|
66
|
+
interface EnvSchema {
|
|
67
|
+
[key: string]: {
|
|
68
|
+
required?: boolean;
|
|
69
|
+
type?: 'string' | 'number' | 'boolean' | 'url' | 'email';
|
|
70
|
+
pattern?: RegExp;
|
|
71
|
+
default?: string;
|
|
72
|
+
transform?: (value: string) => unknown;
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Get environment variable
|
|
77
|
+
*
|
|
78
|
+
* @param key - Variable name
|
|
79
|
+
* @param defaultValue - Default value if not found
|
|
80
|
+
* @returns Variable value
|
|
81
|
+
*/
|
|
82
|
+
declare function getEnv(key: string, defaultValue?: string): string | undefined;
|
|
83
|
+
/**
|
|
84
|
+
* Get required environment variable
|
|
85
|
+
*
|
|
86
|
+
* @param key - Variable name
|
|
87
|
+
* @returns Variable value
|
|
88
|
+
* @throws Error if not found
|
|
89
|
+
*/
|
|
90
|
+
declare function getRequiredEnv(key: string): string;
|
|
91
|
+
/**
|
|
92
|
+
* Get environment variable as number
|
|
93
|
+
*
|
|
94
|
+
* @param key - Variable name
|
|
95
|
+
* @param defaultValue - Default value
|
|
96
|
+
* @returns Parsed number
|
|
97
|
+
*/
|
|
98
|
+
declare function getEnvNumber(key: string, defaultValue?: number): number | undefined;
|
|
99
|
+
/**
|
|
100
|
+
* Get environment variable as boolean
|
|
101
|
+
*
|
|
102
|
+
* @param key - Variable name
|
|
103
|
+
* @param defaultValue - Default value
|
|
104
|
+
* @returns Parsed boolean
|
|
105
|
+
*/
|
|
106
|
+
declare function getEnvBoolean(key: string, defaultValue?: boolean): boolean;
|
|
107
|
+
/**
|
|
108
|
+
* Validate environment variables against schema
|
|
109
|
+
*
|
|
110
|
+
* @param schema - Validation schema
|
|
111
|
+
* @returns Validation result
|
|
112
|
+
*/
|
|
113
|
+
declare function validateEnv(schema: EnvSchema): EnvValidationResult;
|
|
114
|
+
/**
|
|
115
|
+
* Check if in development mode
|
|
116
|
+
*/
|
|
117
|
+
declare function isDevelopment(): boolean;
|
|
118
|
+
/**
|
|
119
|
+
* Check if in production mode
|
|
120
|
+
*/
|
|
121
|
+
declare function isProduction(): boolean;
|
|
122
|
+
/**
|
|
123
|
+
* Check if in test mode
|
|
124
|
+
*/
|
|
125
|
+
declare function isTest(): boolean;
|
|
126
|
+
|
|
127
|
+
export { type ClientInfo, type EnvSchema, type EnvValidationResult, detectClient, getEnv, getEnvBoolean, getEnvNumber, getRequiredEnv, getScreenSize, isBrowser, isDevelopment, isMobile, isNode, isProduction, isTest, isTouchDevice, prefersDarkMode, prefersReducedMotion, validateEnv };
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser/OS detection result
|
|
3
|
+
*/
|
|
4
|
+
interface ClientInfo {
|
|
5
|
+
browser: {
|
|
6
|
+
name: string;
|
|
7
|
+
version: string;
|
|
8
|
+
};
|
|
9
|
+
os: {
|
|
10
|
+
name: string;
|
|
11
|
+
version: string;
|
|
12
|
+
};
|
|
13
|
+
device: 'desktop' | 'mobile' | 'tablet' | 'unknown';
|
|
14
|
+
isMobile: boolean;
|
|
15
|
+
isTablet: boolean;
|
|
16
|
+
isDesktop: boolean;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Detect browser and OS from user agent
|
|
20
|
+
*
|
|
21
|
+
* @param userAgent - User agent string (defaults to navigator.userAgent)
|
|
22
|
+
* @returns Client information
|
|
23
|
+
*/
|
|
24
|
+
declare function detectClient(userAgent?: string): ClientInfo;
|
|
25
|
+
/**
|
|
26
|
+
* Check if running in browser
|
|
27
|
+
*/
|
|
28
|
+
declare function isBrowser(): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Check if running in Node.js
|
|
31
|
+
*/
|
|
32
|
+
declare function isNode(): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Check if running on mobile
|
|
35
|
+
*/
|
|
36
|
+
declare function isMobile(userAgent?: string): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Check if touch device
|
|
39
|
+
*/
|
|
40
|
+
declare function isTouchDevice(): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Get screen size category
|
|
43
|
+
*/
|
|
44
|
+
declare function getScreenSize(): 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'unknown';
|
|
45
|
+
/**
|
|
46
|
+
* Check if user prefers dark mode
|
|
47
|
+
*/
|
|
48
|
+
declare function prefersDarkMode(): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Check if user prefers reduced motion
|
|
51
|
+
*/
|
|
52
|
+
declare function prefersReducedMotion(): boolean;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Environment variable validation result
|
|
56
|
+
*/
|
|
57
|
+
interface EnvValidationResult {
|
|
58
|
+
isValid: boolean;
|
|
59
|
+
missing: string[];
|
|
60
|
+
invalid: string[];
|
|
61
|
+
values: Record<string, string>;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Environment variable schema
|
|
65
|
+
*/
|
|
66
|
+
interface EnvSchema {
|
|
67
|
+
[key: string]: {
|
|
68
|
+
required?: boolean;
|
|
69
|
+
type?: 'string' | 'number' | 'boolean' | 'url' | 'email';
|
|
70
|
+
pattern?: RegExp;
|
|
71
|
+
default?: string;
|
|
72
|
+
transform?: (value: string) => unknown;
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Get environment variable
|
|
77
|
+
*
|
|
78
|
+
* @param key - Variable name
|
|
79
|
+
* @param defaultValue - Default value if not found
|
|
80
|
+
* @returns Variable value
|
|
81
|
+
*/
|
|
82
|
+
declare function getEnv(key: string, defaultValue?: string): string | undefined;
|
|
83
|
+
/**
|
|
84
|
+
* Get required environment variable
|
|
85
|
+
*
|
|
86
|
+
* @param key - Variable name
|
|
87
|
+
* @returns Variable value
|
|
88
|
+
* @throws Error if not found
|
|
89
|
+
*/
|
|
90
|
+
declare function getRequiredEnv(key: string): string;
|
|
91
|
+
/**
|
|
92
|
+
* Get environment variable as number
|
|
93
|
+
*
|
|
94
|
+
* @param key - Variable name
|
|
95
|
+
* @param defaultValue - Default value
|
|
96
|
+
* @returns Parsed number
|
|
97
|
+
*/
|
|
98
|
+
declare function getEnvNumber(key: string, defaultValue?: number): number | undefined;
|
|
99
|
+
/**
|
|
100
|
+
* Get environment variable as boolean
|
|
101
|
+
*
|
|
102
|
+
* @param key - Variable name
|
|
103
|
+
* @param defaultValue - Default value
|
|
104
|
+
* @returns Parsed boolean
|
|
105
|
+
*/
|
|
106
|
+
declare function getEnvBoolean(key: string, defaultValue?: boolean): boolean;
|
|
107
|
+
/**
|
|
108
|
+
* Validate environment variables against schema
|
|
109
|
+
*
|
|
110
|
+
* @param schema - Validation schema
|
|
111
|
+
* @returns Validation result
|
|
112
|
+
*/
|
|
113
|
+
declare function validateEnv(schema: EnvSchema): EnvValidationResult;
|
|
114
|
+
/**
|
|
115
|
+
* Check if in development mode
|
|
116
|
+
*/
|
|
117
|
+
declare function isDevelopment(): boolean;
|
|
118
|
+
/**
|
|
119
|
+
* Check if in production mode
|
|
120
|
+
*/
|
|
121
|
+
declare function isProduction(): boolean;
|
|
122
|
+
/**
|
|
123
|
+
* Check if in test mode
|
|
124
|
+
*/
|
|
125
|
+
declare function isTest(): boolean;
|
|
126
|
+
|
|
127
|
+
export { type ClientInfo, type EnvSchema, type EnvValidationResult, detectClient, getEnv, getEnvBoolean, getEnvNumber, getRequiredEnv, getScreenSize, isBrowser, isDevelopment, isMobile, isNode, isProduction, isTest, isTouchDevice, prefersDarkMode, prefersReducedMotion, validateEnv };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { detectClient, getEnv, getEnvBoolean, getEnvNumber, getRequiredEnv, getScreenSize, isBrowser, isDevelopment, isMobile, isNode, isProduction, isTest, isTouchDevice, prefersDarkMode, prefersReducedMotion, validateEnv } from '../chunk-HYADH4ZX.js';
|
|
2
|
+
import '../chunk-4CV4JOE5.js';
|
|
3
|
+
//# sourceMappingURL=index.js.map
|
|
4
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|