qstd 0.1.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/CHANGELOG.md +23 -0
- package/README.md +127 -0
- package/dist/client/index.cjs +587 -0
- package/dist/client/index.d.cts +75 -0
- package/dist/client/index.d.ts +75 -0
- package/dist/client/index.js +577 -0
- package/dist/preset/index.cjs +475 -0
- package/dist/preset/index.d.cts +39 -0
- package/dist/preset/index.d.ts +39 -0
- package/dist/preset/index.js +473 -0
- package/dist/random-DMErOOdk.d.cts +447 -0
- package/dist/random-DMErOOdk.d.ts +447 -0
- package/dist/react/index.cjs +3155 -0
- package/dist/react/index.css +1566 -0
- package/dist/react/index.d.cts +21092 -0
- package/dist/react/index.d.ts +21092 -0
- package/dist/react/index.js +3128 -0
- package/dist/server/index.cjs +541 -0
- package/dist/server/index.d.cts +17 -0
- package/dist/server/index.d.ts +17 -0
- package/dist/server/index.js +527 -0
- package/package.json +111 -0
- package/panda.config.ts +68 -0
|
@@ -0,0 +1,587 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var dateFns = require('date-fns');
|
|
4
|
+
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
// src/shared/list.ts
|
|
12
|
+
var list_exports = {};
|
|
13
|
+
__export(list_exports, {
|
|
14
|
+
chunk: () => chunk,
|
|
15
|
+
create: () => create,
|
|
16
|
+
partition: () => partition,
|
|
17
|
+
zipWith: () => zipWith
|
|
18
|
+
});
|
|
19
|
+
function zipWith(fn, ...arrays) {
|
|
20
|
+
if (arrays.length === 0) return [];
|
|
21
|
+
const minLength = Math.min(...arrays.map((arr) => arr.length));
|
|
22
|
+
const result = [];
|
|
23
|
+
for (let i = 0; i < minLength; i++) {
|
|
24
|
+
const args = arrays.map((arr) => arr[i]);
|
|
25
|
+
result.push(fn(...args));
|
|
26
|
+
}
|
|
27
|
+
return result;
|
|
28
|
+
}
|
|
29
|
+
var create = (size, fn) => fn ? Array(size).fill(null).map(fn) : Array(size).fill(null);
|
|
30
|
+
var partition = (xs, predicate) => xs.reduce(
|
|
31
|
+
([truthList, falseList], x) => {
|
|
32
|
+
const passes = predicate(x);
|
|
33
|
+
if (passes) truthList.push(x);
|
|
34
|
+
else falseList.push(x);
|
|
35
|
+
return [truthList, falseList];
|
|
36
|
+
},
|
|
37
|
+
[[], []]
|
|
38
|
+
);
|
|
39
|
+
var chunk = (list, chunkSize) => {
|
|
40
|
+
const totalChunks = Math.ceil(list.length / chunkSize);
|
|
41
|
+
return Array.from({ length: totalChunks }, (_, i) => {
|
|
42
|
+
const start = i * chunkSize;
|
|
43
|
+
const end = i * chunkSize + chunkSize;
|
|
44
|
+
return list.slice(start, end);
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
// src/shared/dict.ts
|
|
49
|
+
var dict_exports = {};
|
|
50
|
+
__export(dict_exports, {
|
|
51
|
+
byteSizeOfObj: () => byteSizeOfObj,
|
|
52
|
+
exists: () => exists,
|
|
53
|
+
filter: () => filter,
|
|
54
|
+
isEmpty: () => isEmpty,
|
|
55
|
+
omit: () => omit,
|
|
56
|
+
partition: () => partition2,
|
|
57
|
+
pick: () => pick,
|
|
58
|
+
transform: () => transform
|
|
59
|
+
});
|
|
60
|
+
function byteSizeOfObj(o) {
|
|
61
|
+
const objectList = [];
|
|
62
|
+
const stack = [o];
|
|
63
|
+
const bytes = [0];
|
|
64
|
+
while (stack.length) {
|
|
65
|
+
const value = stack.pop();
|
|
66
|
+
if (value == null) bytes[0] += 4;
|
|
67
|
+
else if (typeof value === "boolean") bytes[0] += 4;
|
|
68
|
+
else if (typeof value === "string") bytes[0] += value.length * 2;
|
|
69
|
+
else if (typeof value === "number") bytes[0] += 8;
|
|
70
|
+
else if (typeof value === "object" && objectList.indexOf(value) === -1) {
|
|
71
|
+
objectList.push(value);
|
|
72
|
+
if (typeof value.byteLength === "number") bytes[0] += value.byteLength;
|
|
73
|
+
else if (value[Symbol.iterator]) {
|
|
74
|
+
for (const v of value) stack.push(v);
|
|
75
|
+
} else {
|
|
76
|
+
Object.keys(value).forEach((k) => {
|
|
77
|
+
bytes[0] += k.length * 2;
|
|
78
|
+
stack.push(value[k]);
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return bytes[0];
|
|
84
|
+
}
|
|
85
|
+
var filter = (r, predicate) => Object.entries(r).reduce(
|
|
86
|
+
(store, [key, value]) => predicate(value) ? { ...store, [key]: value } : store,
|
|
87
|
+
{}
|
|
88
|
+
);
|
|
89
|
+
var transform = (r, transformFn) => Object.entries(r).reduce(
|
|
90
|
+
(store, [key, value]) => ({
|
|
91
|
+
...store,
|
|
92
|
+
...transformFn(key, value)
|
|
93
|
+
}),
|
|
94
|
+
{}
|
|
95
|
+
);
|
|
96
|
+
var partition2 = (r, predicate) => {
|
|
97
|
+
const passed = {};
|
|
98
|
+
const failed = {};
|
|
99
|
+
for (const key in r) {
|
|
100
|
+
if (predicate(key)) passed[key] = r[key];
|
|
101
|
+
else failed[key] = r[key];
|
|
102
|
+
}
|
|
103
|
+
return [passed, failed];
|
|
104
|
+
};
|
|
105
|
+
var exists = (obj) => {
|
|
106
|
+
return obj && typeof obj === "object" && Object.keys(obj).length > 0;
|
|
107
|
+
};
|
|
108
|
+
var isEmpty = (obj) => {
|
|
109
|
+
return !obj || Object.keys(obj).length === 0 && obj.constructor === Object;
|
|
110
|
+
};
|
|
111
|
+
var pick = (r, paths) => Object.entries(r).reduce(
|
|
112
|
+
(store, [key, value]) => paths.includes(key) ? { ...store, [key]: value } : store,
|
|
113
|
+
{}
|
|
114
|
+
);
|
|
115
|
+
var omit = (r, paths) => {
|
|
116
|
+
if (!r) {
|
|
117
|
+
throw new Error("[omit] item was not an object");
|
|
118
|
+
}
|
|
119
|
+
return Object.entries(r).reduce((store, [key, value]) => {
|
|
120
|
+
if (paths.includes(key)) {
|
|
121
|
+
return store;
|
|
122
|
+
} else {
|
|
123
|
+
store[key] = value;
|
|
124
|
+
return store;
|
|
125
|
+
}
|
|
126
|
+
}, {});
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
// src/shared/str.ts
|
|
130
|
+
var str_exports = {};
|
|
131
|
+
__export(str_exports, {
|
|
132
|
+
concat: () => concat,
|
|
133
|
+
countChar: () => countChar,
|
|
134
|
+
countWords: () => countWords,
|
|
135
|
+
createSentences: () => createSentences,
|
|
136
|
+
toCase: () => toCase
|
|
137
|
+
});
|
|
138
|
+
var createSentences = (text) => {
|
|
139
|
+
if (!text) return [];
|
|
140
|
+
return text?.replace(/([.?!])\s*(?=[A-Z])/g, "$1|").split("|");
|
|
141
|
+
};
|
|
142
|
+
var countWords = (text) => {
|
|
143
|
+
text = text.trim();
|
|
144
|
+
if (text.length === 0) {
|
|
145
|
+
return 0;
|
|
146
|
+
}
|
|
147
|
+
const wordPattern = /\w+/g;
|
|
148
|
+
const matches = text.match(wordPattern);
|
|
149
|
+
return matches ? matches.length : 0;
|
|
150
|
+
};
|
|
151
|
+
var concat = (xs, delimiter) => {
|
|
152
|
+
return xs.filter((x) => !!x).join(delimiter);
|
|
153
|
+
};
|
|
154
|
+
var countChar = (str, ch) => {
|
|
155
|
+
return str.split("").reduce((x, y) => y === ch ? x + 1 : x, 0);
|
|
156
|
+
};
|
|
157
|
+
var toCase = (text, opts) => {
|
|
158
|
+
switch (opts.to) {
|
|
159
|
+
case "title":
|
|
160
|
+
return text.charAt(0).toUpperCase() + text.slice(1);
|
|
161
|
+
case "snake":
|
|
162
|
+
return text.replace(
|
|
163
|
+
/[A-Z]/g,
|
|
164
|
+
(l, idx) => idx === 0 ? l.toLowerCase() : "_" + l.toLowerCase()
|
|
165
|
+
);
|
|
166
|
+
case "kebab": {
|
|
167
|
+
const lowered = text.toLowerCase().trim();
|
|
168
|
+
const cleaned = opts.clean ? lowered.replaceAll(/[:,]/g, "") : lowered;
|
|
169
|
+
return cleaned.replaceAll(/\s+/g, "-");
|
|
170
|
+
}
|
|
171
|
+
default:
|
|
172
|
+
return text;
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
// src/shared/int.ts
|
|
177
|
+
var int_exports = {};
|
|
178
|
+
__export(int_exports, {
|
|
179
|
+
clamp: () => clamp,
|
|
180
|
+
commaSeparateThousandths: () => commaSeparateThousandths,
|
|
181
|
+
formatBytes: () => formatBytes
|
|
182
|
+
});
|
|
183
|
+
var clamp = (num2, range) => Math.min(Math.max(num2, range.min), range.max);
|
|
184
|
+
var isNumeric = (x) => {
|
|
185
|
+
return /^[0-9]+$/.test(x);
|
|
186
|
+
};
|
|
187
|
+
var commaSeparateThousandths = (n) => {
|
|
188
|
+
if (typeof n === "string" && !isNumeric(n)) {
|
|
189
|
+
throw new Error(`[comma separate thousandths] Value ${n} must be a number`);
|
|
190
|
+
}
|
|
191
|
+
return Number(n).toLocaleString("en-US");
|
|
192
|
+
};
|
|
193
|
+
var formatBytes = (bytes, decimals = 1, binaryUnits = false) => {
|
|
194
|
+
if (!bytes) return {};
|
|
195
|
+
if (bytes === 0) return { value: 0, unit: "Bytes" };
|
|
196
|
+
const unitMultiple = binaryUnits ? 1024 : 1e3;
|
|
197
|
+
const unitNames = unitMultiple === 1024 ? ["Bytes", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"] : ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
|
|
198
|
+
const unitChanges = Math.floor(Math.log(bytes) / Math.log(unitMultiple));
|
|
199
|
+
const value = parseFloat(
|
|
200
|
+
(bytes / Math.pow(unitMultiple, unitChanges)).toFixed(decimals || 0)
|
|
201
|
+
);
|
|
202
|
+
const unit = unitNames[unitChanges];
|
|
203
|
+
return { value, unit, display: `${value}${unit}` };
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
// src/shared/money.ts
|
|
207
|
+
var money_exports = {};
|
|
208
|
+
__export(money_exports, {
|
|
209
|
+
convertToCents: () => convertToCents,
|
|
210
|
+
convertToUsd: () => convertToUsd
|
|
211
|
+
});
|
|
212
|
+
var convertToUsd = (cents, opts = {}) => {
|
|
213
|
+
if (!cents) return;
|
|
214
|
+
const dollars = (Number(cents) / 100).toLocaleString("en-US", {
|
|
215
|
+
style: "currency",
|
|
216
|
+
currency: "USD"
|
|
217
|
+
});
|
|
218
|
+
const showSymbol = opts.symbol ?? true;
|
|
219
|
+
return showSymbol ? dollars : dollars.slice(1);
|
|
220
|
+
};
|
|
221
|
+
var convertToCents = (dollars) => {
|
|
222
|
+
const str = dollars.toString().replaceAll(/[\$,]+/g, "");
|
|
223
|
+
return Number(str) * 100;
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
// src/shared/time.ts
|
|
227
|
+
var time_exports = {};
|
|
228
|
+
__export(time_exports, {
|
|
229
|
+
adjustDate: () => adjustDate,
|
|
230
|
+
formatDate: () => formatDate,
|
|
231
|
+
formatDateRange: () => formatDateRange,
|
|
232
|
+
formatDuration: () => formatDuration,
|
|
233
|
+
formatThreadDateRange: () => formatThreadDateRange,
|
|
234
|
+
now: () => now,
|
|
235
|
+
sleep: () => sleep,
|
|
236
|
+
toMs: () => toMs
|
|
237
|
+
});
|
|
238
|
+
var formatDuration = (ms, options = {}) => {
|
|
239
|
+
if (ms === null || ms === void 0) return "--:--";
|
|
240
|
+
const { format: fmt = "clock", showZero = false } = options;
|
|
241
|
+
const totalSeconds = Math.floor(Math.abs(ms) / 1e3);
|
|
242
|
+
const hours = Math.floor(totalSeconds / 3600);
|
|
243
|
+
const minutes = Math.floor(totalSeconds % 3600 / 60);
|
|
244
|
+
const seconds = totalSeconds % 60;
|
|
245
|
+
if (fmt === "clock") {
|
|
246
|
+
if (hours > 0) {
|
|
247
|
+
return `${hours}:${minutes.toString().padStart(2, "0")}:${seconds.toString().padStart(2, "0")}`;
|
|
248
|
+
}
|
|
249
|
+
return `${minutes}:${seconds.toString().padStart(2, "0")}`;
|
|
250
|
+
}
|
|
251
|
+
if (fmt === "full") {
|
|
252
|
+
const parts2 = [];
|
|
253
|
+
if (showZero) {
|
|
254
|
+
const hasHours = hours > 0;
|
|
255
|
+
const hasMinutes = minutes > 0;
|
|
256
|
+
const hasSeconds = seconds > 0;
|
|
257
|
+
if (hasHours || hasMinutes || hasSeconds) {
|
|
258
|
+
if (hasHours) parts2.push(`${hours} ${hours === 1 ? "hour" : "hours"}`);
|
|
259
|
+
if (hasHours || hasMinutes)
|
|
260
|
+
parts2.push(`${minutes} ${minutes === 1 ? "minute" : "minutes"}`);
|
|
261
|
+
parts2.push(`${seconds} ${seconds === 1 ? "second" : "seconds"}`);
|
|
262
|
+
} else {
|
|
263
|
+
parts2.push("0 seconds");
|
|
264
|
+
}
|
|
265
|
+
} else {
|
|
266
|
+
if (hours > 0) parts2.push(`${hours} ${hours === 1 ? "hour" : "hours"}`);
|
|
267
|
+
if (minutes > 0)
|
|
268
|
+
parts2.push(`${minutes} ${minutes === 1 ? "minute" : "minutes"}`);
|
|
269
|
+
if (seconds > 0)
|
|
270
|
+
parts2.push(`${seconds} ${seconds === 1 ? "second" : "seconds"}`);
|
|
271
|
+
}
|
|
272
|
+
return parts2.join(" ") || "0 seconds";
|
|
273
|
+
}
|
|
274
|
+
if (fmt === "fractional") {
|
|
275
|
+
const totalSecondsWithFraction = Math.abs(ms) / 1e3;
|
|
276
|
+
const totalMinutes = Math.floor(totalSecondsWithFraction / 60);
|
|
277
|
+
if (totalMinutes === 0) {
|
|
278
|
+
const fractionalSeconds = totalSecondsWithFraction.toFixed(1);
|
|
279
|
+
return `${fractionalSeconds}s`;
|
|
280
|
+
} else {
|
|
281
|
+
const remainingSeconds = totalSecondsWithFraction % 60;
|
|
282
|
+
const fractionalSeconds = remainingSeconds.toFixed(1);
|
|
283
|
+
return `${totalMinutes}m ${fractionalSeconds}s`;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
const parts = [];
|
|
287
|
+
if (showZero) {
|
|
288
|
+
const hasHours = hours > 0;
|
|
289
|
+
const hasMinutes = minutes > 0;
|
|
290
|
+
const hasSeconds = seconds > 0;
|
|
291
|
+
if (hasHours || hasMinutes || hasSeconds) {
|
|
292
|
+
if (hasHours) parts.push(`${hours}h`);
|
|
293
|
+
if (hasHours || hasMinutes) parts.push(`${minutes}m`);
|
|
294
|
+
parts.push(`${seconds}s`);
|
|
295
|
+
} else {
|
|
296
|
+
parts.push("0s");
|
|
297
|
+
}
|
|
298
|
+
} else {
|
|
299
|
+
if (hours > 0) parts.push(`${hours}h`);
|
|
300
|
+
if (minutes > 0) parts.push(`${minutes}m`);
|
|
301
|
+
if (seconds > 0) parts.push(`${seconds}s`);
|
|
302
|
+
}
|
|
303
|
+
return parts.join(" ") || "0s";
|
|
304
|
+
};
|
|
305
|
+
var formatDate = (input, options = {}) => {
|
|
306
|
+
const { style = "medium", pattern, includeTime = false } = options;
|
|
307
|
+
let date2;
|
|
308
|
+
if (typeof input === "string") {
|
|
309
|
+
date2 = new Date(input);
|
|
310
|
+
} else if (typeof input === "number") {
|
|
311
|
+
date2 = new Date(input);
|
|
312
|
+
} else {
|
|
313
|
+
date2 = input;
|
|
314
|
+
}
|
|
315
|
+
if (isNaN(date2.getTime())) {
|
|
316
|
+
return "Invalid Date";
|
|
317
|
+
}
|
|
318
|
+
if (pattern) {
|
|
319
|
+
return dateFns.format(date2, pattern);
|
|
320
|
+
}
|
|
321
|
+
switch (style) {
|
|
322
|
+
case "iso":
|
|
323
|
+
return dateFns.formatISO(date2);
|
|
324
|
+
case "short":
|
|
325
|
+
return includeTime ? dateFns.format(date2, "M/d/yy h:mm a") : dateFns.format(date2, "M/d/yy");
|
|
326
|
+
case "medium":
|
|
327
|
+
return includeTime ? dateFns.format(date2, "MMM d, yyyy h:mm a") : dateFns.format(date2, "MMM d, yyyy");
|
|
328
|
+
case "long":
|
|
329
|
+
return includeTime ? dateFns.format(date2, "MMMM d, yyyy 'at' h:mm a") : dateFns.format(date2, "MMMM d, yyyy");
|
|
330
|
+
case "relative":
|
|
331
|
+
return dateFns.formatDistanceToNow(date2, { addSuffix: true });
|
|
332
|
+
case "year":
|
|
333
|
+
return dateFns.format(date2, "yyyy");
|
|
334
|
+
default:
|
|
335
|
+
return includeTime ? dateFns.format(date2, "MMM d, yyyy h:mm a") : dateFns.format(date2, "MMM d, yyyy");
|
|
336
|
+
}
|
|
337
|
+
};
|
|
338
|
+
var toDate = (input) => typeof input === "string" || typeof input === "number" ? new Date(input) : input;
|
|
339
|
+
var formatDateRange = (startInput, endInput, options = {}) => {
|
|
340
|
+
const now2 = options.now ?? /* @__PURE__ */ new Date();
|
|
341
|
+
const showTimeWhenSameDay = options.showTimeWhenSameDay ?? true;
|
|
342
|
+
const markToday = options.markToday ?? true;
|
|
343
|
+
const todayLabel = options.todayLabel ?? "today";
|
|
344
|
+
const separator = options.separator ?? " - ";
|
|
345
|
+
const monthPattern = options.monthFormat === "long" ? "MMMM" : "MMM";
|
|
346
|
+
const lowercaseAmPm = options.lowercaseAmPm ?? true;
|
|
347
|
+
const { locale } = options;
|
|
348
|
+
let start = toDate(startInput);
|
|
349
|
+
let end = toDate(endInput);
|
|
350
|
+
if (start.getTime() > end.getTime()) {
|
|
351
|
+
const tmp = start;
|
|
352
|
+
start = end;
|
|
353
|
+
end = tmp;
|
|
354
|
+
}
|
|
355
|
+
if (isNaN(start.getTime()) || isNaN(end.getTime())) return "";
|
|
356
|
+
const sameYear = dateFns.isSameYear(start, end);
|
|
357
|
+
const sameMonth = sameYear && dateFns.isSameMonth(start, end);
|
|
358
|
+
const sameDay = sameMonth && dateFns.isSameDay(start, end);
|
|
359
|
+
const isStartToday = dateFns.isSameDay(start, now2);
|
|
360
|
+
const isEndToday = dateFns.isSameDay(end, now2);
|
|
361
|
+
const appendToday = (base, isTodayFlag) => markToday && isTodayFlag ? `${base} (${todayLabel})` : base;
|
|
362
|
+
const fmt = (d, pattern) => locale ? dateFns.format(d, pattern, { locale }) : dateFns.format(d, pattern);
|
|
363
|
+
if (sameDay) {
|
|
364
|
+
const dayPart = appendToday(
|
|
365
|
+
fmt(start, `${monthPattern} d`),
|
|
366
|
+
isStartToday || isEndToday
|
|
367
|
+
);
|
|
368
|
+
if (!showTimeWhenSameDay) return dayPart;
|
|
369
|
+
const timePattern = "h:mma";
|
|
370
|
+
const formatTime = (d) => lowercaseAmPm ? fmt(d, timePattern).toLowerCase() : fmt(d, timePattern);
|
|
371
|
+
const startTime = formatTime(start);
|
|
372
|
+
const endTime = formatTime(end);
|
|
373
|
+
return `${dayPart}, ${startTime}${separator}${endTime}`;
|
|
374
|
+
}
|
|
375
|
+
if (sameMonth) {
|
|
376
|
+
const monthPart = fmt(start, monthPattern);
|
|
377
|
+
const startDay = fmt(start, "d");
|
|
378
|
+
const endDay = fmt(end, "d");
|
|
379
|
+
const startSegment = appendToday(startDay, isStartToday);
|
|
380
|
+
const endSegment = appendToday(endDay, isEndToday);
|
|
381
|
+
const yearPart = fmt(start, "yyyy");
|
|
382
|
+
return `${monthPart} ${startSegment}${separator}${endSegment}, ${yearPart}`;
|
|
383
|
+
}
|
|
384
|
+
if (sameYear) {
|
|
385
|
+
const startPart2 = appendToday(
|
|
386
|
+
fmt(start, `${monthPattern} d`),
|
|
387
|
+
isStartToday
|
|
388
|
+
);
|
|
389
|
+
const endPart2 = appendToday(fmt(end, `${monthPattern} d`), isEndToday);
|
|
390
|
+
const yearPart = fmt(start, "yyyy");
|
|
391
|
+
return `${startPart2}${separator}${endPart2}, ${yearPart}`;
|
|
392
|
+
}
|
|
393
|
+
const startPart = appendToday(
|
|
394
|
+
fmt(start, `${monthPattern} d, yyyy`),
|
|
395
|
+
isStartToday
|
|
396
|
+
);
|
|
397
|
+
const endPart = appendToday(fmt(end, `${monthPattern} d, yyyy`), isEndToday);
|
|
398
|
+
return `${startPart}${separator}${endPart}`;
|
|
399
|
+
};
|
|
400
|
+
var formatThreadDateRange = (startInput, endInput, options = {}) => formatDateRange(startInput, endInput, options);
|
|
401
|
+
var adjustDate = (adjustment, baseDate = /* @__PURE__ */ new Date()) => {
|
|
402
|
+
let result = new Date(baseDate);
|
|
403
|
+
if (adjustment.seconds) result = dateFns.addSeconds(result, adjustment.seconds);
|
|
404
|
+
if (adjustment.minutes) result = dateFns.addMinutes(result, adjustment.minutes);
|
|
405
|
+
if (adjustment.hours) result = dateFns.addHours(result, adjustment.hours);
|
|
406
|
+
if (adjustment.days) result = dateFns.addDays(result, adjustment.days);
|
|
407
|
+
if (adjustment.weeks) result = dateFns.addWeeks(result, adjustment.weeks);
|
|
408
|
+
if (adjustment.businessDays)
|
|
409
|
+
result = dateFns.addBusinessDays(result, adjustment.businessDays);
|
|
410
|
+
if (adjustment.months) result = dateFns.addMonths(result, adjustment.months);
|
|
411
|
+
if (adjustment.years) result = dateFns.addYears(result, adjustment.years);
|
|
412
|
+
return result;
|
|
413
|
+
};
|
|
414
|
+
var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
415
|
+
var now = () => Date.now();
|
|
416
|
+
var toMs = (value, unit = "seconds") => {
|
|
417
|
+
const multipliers = {
|
|
418
|
+
seconds: 1e3,
|
|
419
|
+
minutes: 60 * 1e3,
|
|
420
|
+
hours: 60 * 60 * 1e3,
|
|
421
|
+
days: 24 * 60 * 60 * 1e3,
|
|
422
|
+
weeks: 7 * 24 * 60 * 60 * 1e3,
|
|
423
|
+
months: 30 * 24 * 60 * 60 * 1e3,
|
|
424
|
+
// approximate
|
|
425
|
+
years: 365 * 24 * 60 * 60 * 1e3
|
|
426
|
+
// approximate
|
|
427
|
+
};
|
|
428
|
+
return value * multipliers[unit];
|
|
429
|
+
};
|
|
430
|
+
|
|
431
|
+
// src/shared/flow.ts
|
|
432
|
+
var flow_exports = {};
|
|
433
|
+
__export(flow_exports, {
|
|
434
|
+
asyncPool: () => asyncPool,
|
|
435
|
+
debounce: () => debounce,
|
|
436
|
+
sleep: () => sleep2,
|
|
437
|
+
throttle: () => throttle
|
|
438
|
+
});
|
|
439
|
+
var throttle = (fn, ms) => {
|
|
440
|
+
let time = Date.now();
|
|
441
|
+
return (...args) => {
|
|
442
|
+
if (time + ms - Date.now() < 0) {
|
|
443
|
+
fn(...args);
|
|
444
|
+
time = Date.now();
|
|
445
|
+
}
|
|
446
|
+
};
|
|
447
|
+
};
|
|
448
|
+
var debounce = (fn, timeout) => {
|
|
449
|
+
let timer;
|
|
450
|
+
return (...args) => {
|
|
451
|
+
clearTimeout(timer);
|
|
452
|
+
timer = setTimeout(() => {
|
|
453
|
+
fn(...args);
|
|
454
|
+
}, timeout);
|
|
455
|
+
};
|
|
456
|
+
};
|
|
457
|
+
var sleep2 = (ms) => new Promise((res) => setTimeout(res, ms));
|
|
458
|
+
async function* asyncPool(concurrency, iterable, iterator_fn) {
|
|
459
|
+
const executing = /* @__PURE__ */ new Set();
|
|
460
|
+
const consume = async () => {
|
|
461
|
+
const [promise, value] = await Promise.race(executing);
|
|
462
|
+
executing.delete(promise);
|
|
463
|
+
return value;
|
|
464
|
+
};
|
|
465
|
+
for (const item2 of iterable) {
|
|
466
|
+
const promise = (async () => await iterator_fn(item2, iterable))().then(
|
|
467
|
+
(value) => [promise, value]
|
|
468
|
+
);
|
|
469
|
+
executing.add(promise);
|
|
470
|
+
if (executing.size >= concurrency) {
|
|
471
|
+
yield await consume();
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
while (executing.size) {
|
|
475
|
+
yield await consume();
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
// src/shared/random.ts
|
|
480
|
+
var random_exports = {};
|
|
481
|
+
__export(random_exports, {
|
|
482
|
+
coinFlip: () => coinFlip,
|
|
483
|
+
date: () => date,
|
|
484
|
+
hexColor: () => hexColor,
|
|
485
|
+
item: () => item,
|
|
486
|
+
num: () => num,
|
|
487
|
+
shuffle: () => shuffle
|
|
488
|
+
});
|
|
489
|
+
var item = (xs) => {
|
|
490
|
+
const rand = Math.random() * xs.length;
|
|
491
|
+
const flooredRand = Math.floor(rand);
|
|
492
|
+
return xs[flooredRand];
|
|
493
|
+
};
|
|
494
|
+
var num = (props = {}) => {
|
|
495
|
+
const { min = 0, max = Number.MAX_SAFE_INTEGER } = props;
|
|
496
|
+
return Math.floor(Math.pow(10, 14) * Math.random() * Math.random()) % (max - min + 1) + min;
|
|
497
|
+
};
|
|
498
|
+
var shuffle = (xs) => {
|
|
499
|
+
return xs.reduceRight((r, _, __, s) => {
|
|
500
|
+
const randomItem = s.splice(0 | Math.random() * s.length, 1)[0];
|
|
501
|
+
return r.push(randomItem), r;
|
|
502
|
+
}, []);
|
|
503
|
+
};
|
|
504
|
+
var coinFlip = () => {
|
|
505
|
+
return Math.random() < 0.5;
|
|
506
|
+
};
|
|
507
|
+
var date = () => {
|
|
508
|
+
return new Date(+/* @__PURE__ */ new Date() - Math.floor(Math.random() * 1e13));
|
|
509
|
+
};
|
|
510
|
+
var hexColor = () => {
|
|
511
|
+
const hex = Math.floor(Math.random() * 16777215).toString(16);
|
|
512
|
+
if (hex.length !== 6) {
|
|
513
|
+
console.warn(`${hex} was not 6 characters. Regenerating.`);
|
|
514
|
+
return hexColor();
|
|
515
|
+
}
|
|
516
|
+
return hex;
|
|
517
|
+
};
|
|
518
|
+
|
|
519
|
+
// src/client/dom.ts
|
|
520
|
+
var dom_exports = {};
|
|
521
|
+
__export(dom_exports, {
|
|
522
|
+
copy: () => copy,
|
|
523
|
+
getElement: () => getElement,
|
|
524
|
+
getScrollPosition: () => getScrollPosition,
|
|
525
|
+
isInViewport: () => isInViewport,
|
|
526
|
+
querySelector: () => querySelector,
|
|
527
|
+
querySelectorAll: () => querySelectorAll,
|
|
528
|
+
scrollIntoView: () => scrollIntoView,
|
|
529
|
+
scrollTo: () => scrollTo,
|
|
530
|
+
scrollToTop: () => scrollToTop
|
|
531
|
+
});
|
|
532
|
+
var getElement = (id) => {
|
|
533
|
+
return document.getElementById(id);
|
|
534
|
+
};
|
|
535
|
+
var querySelector = (selector) => {
|
|
536
|
+
return document.querySelector(selector);
|
|
537
|
+
};
|
|
538
|
+
var querySelectorAll = (selector) => {
|
|
539
|
+
return document.querySelectorAll(selector);
|
|
540
|
+
};
|
|
541
|
+
var scrollToTop = () => {
|
|
542
|
+
window.scrollTo({ top: 0, behavior: "smooth" });
|
|
543
|
+
};
|
|
544
|
+
var scrollTo = (x, y) => {
|
|
545
|
+
window.scrollTo({ top: y, left: x, behavior: "smooth" });
|
|
546
|
+
};
|
|
547
|
+
var getScrollPosition = () => {
|
|
548
|
+
return {
|
|
549
|
+
x: window.scrollX || window.pageXOffset,
|
|
550
|
+
y: window.scrollY || window.pageYOffset
|
|
551
|
+
};
|
|
552
|
+
};
|
|
553
|
+
var isInViewport = (el) => {
|
|
554
|
+
const rect = el.getBoundingClientRect();
|
|
555
|
+
return rect.top >= 0 && rect.left >= 0 && rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) && rect.right <= (window.innerWidth || document.documentElement.clientWidth);
|
|
556
|
+
};
|
|
557
|
+
var scrollIntoView = (el, options) => {
|
|
558
|
+
el.scrollIntoView(options);
|
|
559
|
+
};
|
|
560
|
+
var copy = async (text) => {
|
|
561
|
+
try {
|
|
562
|
+
await navigator.clipboard.writeText(text);
|
|
563
|
+
} catch (error) {
|
|
564
|
+
const textArea = document.createElement("textarea");
|
|
565
|
+
textArea.value = text;
|
|
566
|
+
textArea.style.position = "fixed";
|
|
567
|
+
textArea.style.left = "-999999px";
|
|
568
|
+
document.body.appendChild(textArea);
|
|
569
|
+
textArea.focus();
|
|
570
|
+
textArea.select();
|
|
571
|
+
try {
|
|
572
|
+
document.execCommand("copy");
|
|
573
|
+
} finally {
|
|
574
|
+
document.body.removeChild(textArea);
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
};
|
|
578
|
+
|
|
579
|
+
exports.Dict = dict_exports;
|
|
580
|
+
exports.Dom = dom_exports;
|
|
581
|
+
exports.Flow = flow_exports;
|
|
582
|
+
exports.Int = int_exports;
|
|
583
|
+
exports.List = list_exports;
|
|
584
|
+
exports.Money = money_exports;
|
|
585
|
+
exports.Random = random_exports;
|
|
586
|
+
exports.Str = str_exports;
|
|
587
|
+
exports.Time = time_exports;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
export { d as Dict, f as Flow, i as Int, l as List, m as Money, r as Random, s as Str, t as Time } from '../random-DMErOOdk.cjs';
|
|
2
|
+
import 'date-fns';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* DOM manipulation utilities
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Get element by ID
|
|
9
|
+
* @param id
|
|
10
|
+
* @returns
|
|
11
|
+
*/
|
|
12
|
+
declare const getElement: (id: string) => HTMLElement | null;
|
|
13
|
+
/**
|
|
14
|
+
* Query selector
|
|
15
|
+
* @param selector
|
|
16
|
+
* @returns
|
|
17
|
+
*/
|
|
18
|
+
declare const querySelector: (selector: string) => Element | null;
|
|
19
|
+
/**
|
|
20
|
+
* Query selector all
|
|
21
|
+
* @param selector
|
|
22
|
+
* @returns
|
|
23
|
+
*/
|
|
24
|
+
declare const querySelectorAll: (selector: string) => NodeListOf<Element>;
|
|
25
|
+
/**
|
|
26
|
+
* Scroll to top of page
|
|
27
|
+
*/
|
|
28
|
+
declare const scrollToTop: () => void;
|
|
29
|
+
/**
|
|
30
|
+
* Scroll to coordinates
|
|
31
|
+
* @param x
|
|
32
|
+
* @param y
|
|
33
|
+
*/
|
|
34
|
+
declare const scrollTo: (x: number, y: number) => void;
|
|
35
|
+
/**
|
|
36
|
+
* Get current scroll position
|
|
37
|
+
* @returns
|
|
38
|
+
*/
|
|
39
|
+
declare const getScrollPosition: () => {
|
|
40
|
+
x: number;
|
|
41
|
+
y: number;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Check if element is in viewport
|
|
45
|
+
* @param el
|
|
46
|
+
* @returns
|
|
47
|
+
*/
|
|
48
|
+
declare const isInViewport: (el: HTMLElement) => boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Scroll element into view
|
|
51
|
+
* @param el
|
|
52
|
+
* @param options
|
|
53
|
+
*/
|
|
54
|
+
declare const scrollIntoView: (el: HTMLElement, options?: ScrollIntoViewOptions) => void;
|
|
55
|
+
/**
|
|
56
|
+
* Copy text to clipboard
|
|
57
|
+
* @param text
|
|
58
|
+
* @returns
|
|
59
|
+
*/
|
|
60
|
+
declare const copy: (text: string) => Promise<void>;
|
|
61
|
+
|
|
62
|
+
declare const dom_copy: typeof copy;
|
|
63
|
+
declare const dom_getElement: typeof getElement;
|
|
64
|
+
declare const dom_getScrollPosition: typeof getScrollPosition;
|
|
65
|
+
declare const dom_isInViewport: typeof isInViewport;
|
|
66
|
+
declare const dom_querySelector: typeof querySelector;
|
|
67
|
+
declare const dom_querySelectorAll: typeof querySelectorAll;
|
|
68
|
+
declare const dom_scrollIntoView: typeof scrollIntoView;
|
|
69
|
+
declare const dom_scrollTo: typeof scrollTo;
|
|
70
|
+
declare const dom_scrollToTop: typeof scrollToTop;
|
|
71
|
+
declare namespace dom {
|
|
72
|
+
export { dom_copy as copy, dom_getElement as getElement, dom_getScrollPosition as getScrollPosition, dom_isInViewport as isInViewport, dom_querySelector as querySelector, dom_querySelectorAll as querySelectorAll, dom_scrollIntoView as scrollIntoView, dom_scrollTo as scrollTo, dom_scrollToTop as scrollToTop };
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export { dom as Dom };
|