qstd 0.2.10 → 0.2.12

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.
Files changed (89) hide show
  1. package/dist/block/accordion.d.ts +18 -0
  2. package/dist/block/accordion.d.ts.map +1 -0
  3. package/dist/block/checkbox.d.ts +3 -0
  4. package/dist/block/checkbox.d.ts.map +1 -0
  5. package/dist/block/drawer.d.ts +9 -0
  6. package/dist/block/drawer.d.ts.map +1 -0
  7. package/dist/block/fns.d.ts +50 -0
  8. package/dist/block/fns.d.ts.map +1 -0
  9. package/dist/block/icon.d.ts +4 -0
  10. package/dist/block/icon.d.ts.map +1 -0
  11. package/dist/block/index.d.ts +62 -0
  12. package/dist/block/index.d.ts.map +1 -0
  13. package/dist/block/input.d.ts +23 -0
  14. package/dist/block/input.d.ts.map +1 -0
  15. package/dist/block/literals.d.ts +121 -0
  16. package/dist/block/literals.d.ts.map +1 -0
  17. package/dist/block/menu.d.ts +4 -0
  18. package/dist/block/menu.d.ts.map +1 -0
  19. package/dist/block/progress.d.ts +18 -0
  20. package/dist/block/progress.d.ts.map +1 -0
  21. package/dist/block/radio.d.ts +17 -0
  22. package/dist/block/radio.d.ts.map +1 -0
  23. package/dist/block/switch.d.ts +21 -0
  24. package/dist/block/switch.d.ts.map +1 -0
  25. package/dist/block/test-types.d.ts +4 -0
  26. package/dist/block/test-types.d.ts.map +1 -0
  27. package/dist/block/textarea.d.ts +33 -0
  28. package/dist/block/textarea.d.ts.map +1 -0
  29. package/dist/block/tooltip.d.ts +5 -0
  30. package/dist/block/tooltip.d.ts.map +1 -0
  31. package/dist/block/types.d.ts +384 -0
  32. package/dist/block/types.d.ts.map +1 -0
  33. package/dist/block/use-resize-observer.d.ts +24 -0
  34. package/dist/block/use-resize-observer.d.ts.map +1 -0
  35. package/dist/client/browser.d.ts +44 -0
  36. package/dist/client/browser.d.ts.map +1 -0
  37. package/dist/client/dom.d.ts +58 -0
  38. package/dist/client/dom.d.ts.map +1 -0
  39. package/dist/client/index.cjs +28 -0
  40. package/dist/client/index.d.ts +11 -75
  41. package/dist/client/index.d.ts.map +1 -0
  42. package/dist/client/index.js +28 -0
  43. package/dist/client/storage.d.ts +46 -0
  44. package/dist/client/storage.d.ts.map +1 -0
  45. package/dist/preset/index.d.ts +3 -4
  46. package/dist/preset/index.d.ts.map +1 -0
  47. package/dist/react/index.cjs +4 -3
  48. package/dist/react/index.d.ts +10 -21023
  49. package/dist/react/index.d.ts.map +1 -0
  50. package/dist/react/index.js +4 -3
  51. package/dist/react/use-theme/fns.d.ts +5 -0
  52. package/dist/react/use-theme/fns.d.ts.map +1 -0
  53. package/dist/react/use-theme/index.d.ts +13 -0
  54. package/dist/react/use-theme/index.d.ts.map +1 -0
  55. package/dist/react/use-theme/literals.d.ts +4 -0
  56. package/dist/react/use-theme/literals.d.ts.map +1 -0
  57. package/dist/react/use-theme/types.d.ts +6 -0
  58. package/dist/react/use-theme/types.d.ts.map +1 -0
  59. package/dist/server/file.d.ts +8 -0
  60. package/dist/server/file.d.ts.map +1 -0
  61. package/dist/server/index.cjs +28 -0
  62. package/dist/server/index.d.ts +11 -17
  63. package/dist/server/index.d.ts.map +1 -0
  64. package/dist/server/index.js +28 -0
  65. package/dist/shared/dict.d.ts +57 -0
  66. package/dist/shared/dict.d.ts.map +1 -0
  67. package/dist/shared/flow.d.ts +36 -0
  68. package/dist/shared/flow.d.ts.map +1 -0
  69. package/dist/shared/int.d.ts +49 -0
  70. package/dist/shared/int.d.ts.map +1 -0
  71. package/dist/shared/list.d.ts +29 -0
  72. package/dist/shared/list.d.ts.map +1 -0
  73. package/dist/shared/log.d.ts +98 -0
  74. package/dist/shared/log.d.ts.map +1 -0
  75. package/dist/shared/money.d.ts +18 -0
  76. package/dist/shared/money.d.ts.map +1 -0
  77. package/dist/shared/random.d.ts +41 -0
  78. package/dist/shared/random.d.ts.map +1 -0
  79. package/dist/shared/str.d.ts +74 -0
  80. package/dist/shared/str.d.ts.map +1 -0
  81. package/dist/shared/time.d.ts +112 -0
  82. package/dist/shared/time.d.ts.map +1 -0
  83. package/package.json +4 -2
  84. package/dist/client/index.d.cts +0 -75
  85. package/dist/log-DlaF8tUZ.d.cts +0 -496
  86. package/dist/log-DlaF8tUZ.d.ts +0 -496
  87. package/dist/preset/index.d.cts +0 -39
  88. package/dist/react/index.d.cts +0 -21058
  89. package/dist/server/index.d.cts +0 -17
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,gCAAgC,CAAC;AAKxC,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAGzC,YAAY,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAMlD,MAAM,MAAM,UAAU,GAAG,MAAM,EAAE,CAAC;AAClC,MAAM,MAAM,YAAY,GAAG,OAAO,EAAE,CAAC;AAErC;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,GAAE,MAAY,UAe7D;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAY,UAkChE;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,aAAa,CAC3B,OAAO,EAAE,UAAU,EACnB,aAAa,GAAE,YAAiB,GAC/B,YAAY,CAkCd;AAED,cAAc,aAAa,CAAC"}
@@ -8,11 +8,11 @@ import { BeatLoader } from 'react-spinners';
8
8
  import { Oval, ThreeDots, TailSpin, RotatingLines } from 'react-loader-spinner';
9
9
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
10
10
  import { nanoid } from 'nanoid';
11
- import { fas } from '@fortawesome/free-solid-svg-icons';
12
11
  import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
13
12
  import { library } from '@fortawesome/fontawesome-svg-core';
14
13
  import { far } from '@fortawesome/free-regular-svg-icons';
15
14
  import { fab } from '@fortawesome/free-brands-svg-icons';
15
+ import { fas } from '@fortawesome/free-solid-svg-icons';
16
16
  import { useImmer } from 'use-immer';
17
17
 
18
18
  // src/react/index.ts
@@ -892,9 +892,9 @@ var extractAudioMetadata = async (f) => {
892
892
  const ext = f.name.split(".").pop();
893
893
  const id = `${ext}_${nanoid()}.${ext}`;
894
894
  const [cover] = meta.common.picture ?? [];
895
- const preview = URL.createObjectURL(
895
+ const preview = cover ? URL.createObjectURL(
896
896
  new Blob([cover.data], { type: cover.format })
897
- );
897
+ ) : "";
898
898
  const audioMetadata = {
899
899
  id,
900
900
  preview,
@@ -2227,6 +2227,7 @@ function useResizeObserver(opts = {}) {
2227
2227
  round,
2228
2228
  instance: new ResizeObserver((entries) => {
2229
2229
  const entry = entries[0];
2230
+ if (!entry) return;
2230
2231
  const boxProp = opts.box === "border-box" ? "borderBoxSize" : opts.box === "device-pixel-content-box" ? "devicePixelContentBoxSize" : "contentBoxSize";
2231
2232
  const reportedWidth = extractSize(entry, boxProp, "inlineSize");
2232
2233
  const reportedHeight = extractSize(entry, boxProp, "blockSize");
@@ -0,0 +1,5 @@
1
+ import * as _t from "./types";
2
+ export declare const getInitialTheme: () => _t.Theme;
3
+ export declare const getInitialStore: () => _t.ThemeStore;
4
+ export declare const saveStore: (store: _t.ThemeStore) => void;
5
+ //# sourceMappingURL=fns.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fns.d.ts","sourceRoot":"","sources":["../../../src/react/use-theme/fns.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAI9B,eAAO,MAAM,eAAe,QAAO,EAAE,CAAC,KAGrC,CAAC;AAGF,eAAO,MAAM,eAAe,QAAO,EAAE,CAAC,UAiBrC,CAAC;AAGF,eAAO,MAAM,SAAS,GAAI,OAAO,EAAE,CAAC,UAAU,SAW7C,CAAC"}
@@ -0,0 +1,13 @@
1
+ import * as _t from "./types";
2
+ export type { Theme, ThemeStore } from "./types";
3
+ /**
4
+ * Hook to manage light/dark theme
5
+ * Syncs with localStorage and across components using events
6
+ */
7
+ export declare function useTheme(): {
8
+ update: (updates: Partial<_t.ThemeStore>) => void;
9
+ toggle: (theme?: "light" | "dark") => void;
10
+ value: _t.Theme;
11
+ isManual: boolean;
12
+ };
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/react/use-theme/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAI9B,YAAY,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAEjD;;;GAGG;AACH,wBAAgB,QAAQ;sBA8CG,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC;qBAOvB,OAAO,GAAG,MAAM;;;EAWzC"}
@@ -0,0 +1,4 @@
1
+ export declare const THEME_STORAGE_KEY = "theme";
2
+ export declare const THEME_STORE_STORAGE_KEY = "themeStore";
3
+ export declare const THEME_CHANGE_EVENT = "qstd:theme-change";
4
+ //# sourceMappingURL=literals.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"literals.d.ts","sourceRoot":"","sources":["../../../src/react/use-theme/literals.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,iBAAiB,UAAU,CAAC;AACzC,eAAO,MAAM,uBAAuB,eAAe,CAAC;AACpD,eAAO,MAAM,kBAAkB,sBAAsB,CAAC"}
@@ -0,0 +1,6 @@
1
+ export type Theme = "light" | "dark";
2
+ export type ThemeStore = {
3
+ value: Theme;
4
+ isManual: boolean;
5
+ };
6
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/react/use-theme/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,KAAK,GAAG,OAAO,GAAG,MAAM,CAAC;AAErC,MAAM,MAAM,UAAU,GAAG;IACvB,KAAK,EAAE,KAAK,CAAC;IACb,QAAQ,EAAE,OAAO,CAAC;CACnB,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Read file contents as string
3
+ * @param filePath
4
+ * @param encoding
5
+ * @returns
6
+ */
7
+ export declare const readFile: (filePath: string, encoding?: BufferEncoding) => string;
8
+ //# sourceMappingURL=file.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../../src/server/file.ts"],"names":[],"mappings":"AAKA;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,GACnB,UAAU,MAAM,EAChB,WAAU,cAAwB,KACjC,MAEF,CAAC"}
@@ -552,11 +552,18 @@ var hexColor = () => {
552
552
  var log_exports = {};
553
553
  __export(log_exports, {
554
554
  error: () => error,
555
+ header: () => header,
555
556
  info: () => info,
557
+ label: () => label,
556
558
  log: () => log,
559
+ startTimer: () => startTimer,
557
560
  warn: () => warn
558
561
  });
559
562
  var stringify = (value) => JSON.stringify(value, null, 2);
563
+ var startTimer = () => {
564
+ const start = Date.now();
565
+ return () => Date.now() - start;
566
+ };
560
567
  var log = (...values) => {
561
568
  console.log(...values.map(stringify));
562
569
  };
@@ -569,6 +576,27 @@ var warn = (...values) => {
569
576
  var error = (...values) => {
570
577
  console.log("[error]", ...values.map(stringify));
571
578
  };
579
+ var header = (message) => {
580
+ console.log(`========== ${message} ==========`);
581
+ };
582
+ var label = (name) => ({
583
+ /** Logs values with [label] prefix. Output: `[label] "value"` */
584
+ info: (...values) => {
585
+ console.log(`[${name}]`, ...values.map(stringify));
586
+ },
587
+ /** Logs values with [label] [warn] prefix. Output: `[label] [warn] "value"` */
588
+ warn: (...values) => {
589
+ console.log(`[${name}]`, "[warn]", ...values.map(stringify));
590
+ },
591
+ /** Logs values with [label] [error] prefix. Output: `[label] [error] "value"` */
592
+ error: (...values) => {
593
+ console.log(`[${name}]`, "[error]", ...values.map(stringify));
594
+ },
595
+ /** Logs a header message with [label] prefix. Output: `[label] ========== MESSAGE ==========` */
596
+ header: (message) => {
597
+ console.log(`[${name}] ========== ${message} ==========`);
598
+ }
599
+ });
572
600
 
573
601
  // src/server/file.ts
574
602
  var file_exports = {};
@@ -1,17 +1,11 @@
1
- export { d as Dict, f as Flow, i as Int, l as List, a as Log, m as Money, r as Random, s as Str, t as Time } from '../log-DlaF8tUZ.js';
2
- import 'date-fns';
3
-
4
- /**
5
- * Read file contents as string
6
- * @param filePath
7
- * @param encoding
8
- * @returns
9
- */
10
- declare const readFile: (filePath: string, encoding?: BufferEncoding) => string;
11
-
12
- declare const file_readFile: typeof readFile;
13
- declare namespace file {
14
- export { file_readFile as readFile };
15
- }
16
-
17
- export { file as File };
1
+ export * as List from "../shared/list";
2
+ export * as Dict from "../shared/dict";
3
+ export * as Str from "../shared/str";
4
+ export * as Int from "../shared/int";
5
+ export * as Money from "../shared/money";
6
+ export * as Time from "../shared/time";
7
+ export * as Flow from "../shared/flow";
8
+ export * as Random from "../shared/random";
9
+ export * as Log from "../shared/log";
10
+ export * as File from "./file";
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAC;AACvC,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAC;AACvC,OAAO,KAAK,GAAG,MAAM,eAAe,CAAC;AACrC,OAAO,KAAK,GAAG,MAAM,eAAe,CAAC;AACrC,OAAO,KAAK,KAAK,MAAM,iBAAiB,CAAC;AACzC,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAC;AACvC,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAC;AACvC,OAAO,KAAK,MAAM,MAAM,kBAAkB,CAAC;AAC3C,OAAO,KAAK,GAAG,MAAM,eAAe,CAAC;AAGrC,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC"}
@@ -546,11 +546,18 @@ var hexColor = () => {
546
546
  var log_exports = {};
547
547
  __export(log_exports, {
548
548
  error: () => error,
549
+ header: () => header,
549
550
  info: () => info,
551
+ label: () => label,
550
552
  log: () => log,
553
+ startTimer: () => startTimer,
551
554
  warn: () => warn
552
555
  });
553
556
  var stringify = (value) => JSON.stringify(value, null, 2);
557
+ var startTimer = () => {
558
+ const start = Date.now();
559
+ return () => Date.now() - start;
560
+ };
554
561
  var log = (...values) => {
555
562
  console.log(...values.map(stringify));
556
563
  };
@@ -563,6 +570,27 @@ var warn = (...values) => {
563
570
  var error = (...values) => {
564
571
  console.log("[error]", ...values.map(stringify));
565
572
  };
573
+ var header = (message) => {
574
+ console.log(`========== ${message} ==========`);
575
+ };
576
+ var label = (name) => ({
577
+ /** Logs values with [label] prefix. Output: `[label] "value"` */
578
+ info: (...values) => {
579
+ console.log(`[${name}]`, ...values.map(stringify));
580
+ },
581
+ /** Logs values with [label] [warn] prefix. Output: `[label] [warn] "value"` */
582
+ warn: (...values) => {
583
+ console.log(`[${name}]`, "[warn]", ...values.map(stringify));
584
+ },
585
+ /** Logs values with [label] [error] prefix. Output: `[label] [error] "value"` */
586
+ error: (...values) => {
587
+ console.log(`[${name}]`, "[error]", ...values.map(stringify));
588
+ },
589
+ /** Logs a header message with [label] prefix. Output: `[label] ========== MESSAGE ==========` */
590
+ header: (message) => {
591
+ console.log(`[${name}] ========== ${message} ==========`);
592
+ }
593
+ });
566
594
 
567
595
  // src/server/file.ts
568
596
  var file_exports = {};
@@ -0,0 +1,57 @@
1
+ /**
2
+ * dicts are homogeneous- their values must be of the same type
3
+ * records can hold values of different types
4
+ */
5
+ type t = Record<string, unknown> | object;
6
+ /**
7
+ * Calculate the byte size of an object
8
+ * @param o
9
+ * @returns
10
+ */
11
+ export declare function byteSizeOfObj(o: any): number;
12
+ /**
13
+ * Return an object filter with a subset of properties.
14
+ * @param r
15
+ * @param predicate
16
+ */
17
+ export declare const filter: <R extends t>(r: R, predicate: (value: R[keyof R]) => boolean) => R;
18
+ /**
19
+ * Transform the values on an object
20
+ * @param r
21
+ * @param transformFn
22
+ */
23
+ export declare const transform: <R extends t>(r: R, transformFn: (key: keyof R, value: R[keyof R]) => Record<string, any>) => R;
24
+ /**
25
+ * First object contains key/value pairs that pass the predicate.
26
+ * Second object contains key/value pairs that failed.
27
+ * @param r
28
+ * @param predicate
29
+ * @returns
30
+ */
31
+ export declare const partition: <R extends t>(r: R, predicate: (key: keyof R) => boolean) => readonly [R, R];
32
+ /**
33
+ * Check if an object exists and has keys
34
+ * @param obj
35
+ * @returns
36
+ */
37
+ export declare const exists: <O>(obj: O) => boolean;
38
+ /**
39
+ * Determine if an object is empty.
40
+ * @param obj
41
+ * @returns
42
+ */
43
+ export declare const isEmpty: <T extends t>(obj: T) => boolean;
44
+ /**
45
+ * Return an object with a subset of properties.
46
+ * @param r
47
+ * @param paths
48
+ */
49
+ export declare const pick: <R extends t, U extends keyof R>(r: R, paths: Array<U>) => Pick<R, U>;
50
+ /**
51
+ * Return an object with a subset of properties omitted.
52
+ * @param r
53
+ * @param paths
54
+ */
55
+ export declare const omit: <R extends Record<string, any>, U extends keyof R>(r: R, paths: Array<U>) => Omit<R, U>;
56
+ export {};
57
+ //# sourceMappingURL=dict.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dict.d.ts","sourceRoot":"","sources":["../../src/shared/dict.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,KAAK,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC;AAE1C;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,GAAG,UAwBnC;AAED;;;;GAIG;AACH,eAAO,MAAM,MAAM,GAAI,CAAC,SAAS,CAAC,EAChC,GAAG,CAAC,EACJ,WAAW,CAAC,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,OAAO,MAMxC,CAAC;AAEJ;;;;GAIG;AACH,eAAO,MAAM,SAAS,GAAI,CAAC,SAAS,CAAC,EACnC,GAAG,CAAC,EACJ,aAAa,CAAC,GAAG,EAAE,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,MAQpE,CAAC;AAEJ;;;;;;GAMG;AACH,eAAO,MAAM,SAAS,GAAI,CAAC,SAAS,CAAC,EACnC,GAAG,CAAC,EACJ,WAAW,CAAC,GAAG,EAAE,MAAM,CAAC,KAAK,OAAO,oBASrC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,MAAM,GAAI,CAAC,EAAE,KAAK,CAAC,YAE/B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,OAAO,GAAI,CAAC,SAAS,CAAC,EAAE,KAAK,CAAC,YAK1C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,IAAI,GAAI,CAAC,SAAS,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,EACjD,GAAG,CAAC,EACJ,OAAO,KAAK,CAAC,CAAC,CAAC,KACd,IAAI,CAAC,CAAC,EAAE,CAAC,CAKT,CAAC;AAEJ;;;;GAIG;AACH,eAAO,MAAM,IAAI,GAAI,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,EACnE,GAAG,CAAC,EACJ,OAAO,KAAK,CAAC,CAAC,CAAC,KACd,IAAI,CAAC,CAAC,EAAE,CAAC,CAYX,CAAC"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Throttle a function call
3
+ * @param fn
4
+ * @param ms
5
+ * @returns
6
+ */
7
+ export declare const throttle: (fn: any, ms: number) => (...args: any[]) => void;
8
+ /**
9
+ * Ensure code is only triggered once per user input.
10
+ * The debounce forces another function to wait a certain amount of time before running again.
11
+ * Its purpose is to prevent a function from being called several times in succession.
12
+ * @param fn
13
+ * @param timeout
14
+ * @returns
15
+ */
16
+ export declare const debounce: <T extends any[]>(fn: (...args: T) => any, timeout: number) => ((...args: T) => void);
17
+ /**
18
+ * Sleep for x milliseconds.
19
+ * @param ms
20
+ * @returns
21
+ */
22
+ export declare const sleep: (ms: number) => Promise<void>;
23
+ /**
24
+ * Async pool for concurrent iteration with concurrency limit
25
+ * @example
26
+ * ```
27
+ * for await (const ms of asyncPool(2, [1000, 5000, 3000, 2000], ms => sleep(ms))) {
28
+ * console.log(ms);
29
+ * }
30
+ * ```
31
+ * @param concurrency
32
+ * @param iterable
33
+ * @param iterator_fn
34
+ */
35
+ export declare function asyncPool<T>(concurrency: number, iterable: T[], iterator_fn: (x: T, xs: T[]) => any): AsyncGenerator<any, void, unknown>;
36
+ //# sourceMappingURL=flow.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flow.d.ts","sourceRoot":"","sources":["../../src/shared/flow.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,GAAI,IAAI,GAAG,EAAE,IAAI,MAAM,MAElC,GAAG,MAAM,GAAG,EAAE,SAMvB,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,QAAQ,GAAI,CAAC,SAAS,GAAG,EAAE,EACtC,IAAI,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,GAAG,EACvB,SAAS,MAAM,KACd,CAAC,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,IAAI,CAUvB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,KAAK,GAAI,IAAI,MAAM,KAAG,OAAO,CAAC,IAAI,CACJ,CAAC;AAE5C;;;;;;;;;;;GAWG;AACH,wBAAuB,SAAS,CAAC,CAAC,EAChC,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,CAAC,EAAE,EACb,WAAW,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,KAAK,GAAG,sCAyBpC"}
@@ -0,0 +1,49 @@
1
+ type Range = {
2
+ min: number;
3
+ max: number;
4
+ };
5
+ /**
6
+ * Clamp a number within a range
7
+ * @param num
8
+ * @param range
9
+ * @returns
10
+ */
11
+ export declare const clamp: (num: number, range: Range) => number;
12
+ /**
13
+ * Format a number with comma-separated thousandths
14
+ * @param n
15
+ * @returns
16
+ */
17
+ export declare const commaSeparateThousandths: (n: number | string) => string;
18
+ /**
19
+ * Convert bytes to other units.
20
+ * @param bytes
21
+ * @param decimals
22
+ * @param binaryUnits
23
+ * @example
24
+ * ```js
25
+ * formatBytes(293489203947847, 1); // 293.5 TB
26
+ * formatBytes(1234, 0); // 1 KB
27
+ * formatBytes(4534634523453678343456, 2); // 4.53 ZB
28
+ * formatBytes(4534634523453678343456, 2, true)); // 3.84 ZiB
29
+ * formatBytes(4566744, 1); // 4.6 MB
30
+ * formatBytes(534, 0); // 534 Bytes
31
+ * formatBytes(273403407, 0); // 273 MB
32
+ * ```
33
+ * @returns
34
+ */
35
+ export declare const formatBytes: (bytes?: number, decimals?: number, binaryUnits?: boolean) => {
36
+ value?: undefined;
37
+ unit?: undefined;
38
+ display?: undefined;
39
+ } | {
40
+ value: number;
41
+ unit: string;
42
+ display?: undefined;
43
+ } | {
44
+ value: number;
45
+ unit: string | undefined;
46
+ display: string;
47
+ };
48
+ export {};
49
+ //# sourceMappingURL=int.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"int.d.ts","sourceRoot":"","sources":["../../src/shared/int.ts"],"names":[],"mappings":"AAAA,KAAK,KAAK,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC;AAE1C;;;;;GAKG;AACH,eAAO,MAAM,KAAK,GAAI,KAAK,MAAM,EAAE,OAAO,KAAK,WACA,CAAC;AAWhD;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,GAAI,GAAG,MAAM,GAAG,MAAM,WAK1D,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,WAAW,GACtB,QAAQ,MAAM,EACd,iBAAY,EACZ,qBAAmB;;;;;;;;;;;;CAgBpB,CAAC"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Robust variadic zipWith with full type inference
3
+ */
4
+ export declare function zipWith<T extends readonly any[], R>(fn: (...args: T) => R, ...arrays: {
5
+ [K in keyof T]: T[K][];
6
+ }): R[];
7
+ /**
8
+ * Create an array of x length filled with items of type y.
9
+ * @param size
10
+ * @param fn
11
+ * @returns
12
+ */
13
+ export declare const create: <T>(size: number, fn?: (_: unknown, x: number) => T) => T[];
14
+ /**
15
+ * First list includes items that pass the predicate.
16
+ * Second list includes items that failed.
17
+ * @param xs
18
+ * @param predicate
19
+ * @returns
20
+ */
21
+ export declare const partition: <T>(xs: T[], predicate: (x: T) => boolean) => [T[], T[]];
22
+ /**
23
+ * Split an array into chunks of a specific size
24
+ * @param list
25
+ * @param chunkSize
26
+ * @returns
27
+ */
28
+ export declare const chunk: <T>(list: T[], chunkSize: number) => T[][];
29
+ //# sourceMappingURL=list.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../src/shared/list.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAgB,OAAO,CAAC,CAAC,SAAS,SAAS,GAAG,EAAE,EAAE,CAAC,EACjD,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,CAAC,EACrB,GAAG,MAAM,EAAE;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE;CAAE,GACpC,CAAC,EAAE,CAYL;AAED;;;;;GAKG;AACH,eAAO,MAAM,MAAM,GAAI,CAAC,EACtB,MAAM,MAAM,EACZ,KAAK,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC,KAChC,CAAC,EAAoE,CAAC;AAEzE;;;;;;GAMG;AACH,eAAO,MAAM,SAAS,GAAI,CAAC,EAAE,IAAI,CAAC,EAAE,EAAE,WAAW,CAAC,CAAC,EAAE,CAAC,KAAK,OAAO,eAS/D,CAAC;AAEJ;;;;;GAKG;AACH,eAAO,MAAM,KAAK,GAAI,CAAC,EAAE,MAAM,CAAC,EAAE,EAAE,WAAW,MAAM,UAQpD,CAAC"}
@@ -0,0 +1,98 @@
1
+ /**
2
+ * Usage Examples:
3
+ *
4
+ * ```typescript // Basic logging
5
+ * Log.info("stuff"); // [info] "stuff"
6
+ * Log.warn("uh oh"); // [warn] "uh oh"
7
+ * Log.error("bad"); // [error] "bad"
8
+ *
9
+ * // Standalone header
10
+ * Log.header("STARTING"); // ========== STARTING ==========
11
+ *
12
+ * // Scoped logger
13
+ * const log = Log.label("audio-processor");
14
+ * log.info("something"); // [audio-processor] "something"
15
+ * log.warn("hmm"); // [audio-processor] [warn] "hmm"
16
+ * log.error("failed"); // [audio-processor] [error] "failed"
17
+ * log.header("HANDLER START"); // [audio-processor] ========== HANDLER START ==========
18
+ *
19
+ */
20
+ /**
21
+ * Starts a timer and returns a function that returns elapsed milliseconds.
22
+ * @returns A function that returns the elapsed time in ms since the timer started
23
+ * @example
24
+ * ```typescript // Timer
25
+ * const elapsed = Log.startTimer();
26
+ * // ... do work ...
27
+ * log.header(`COMPLETE (${elapsed()}ms)`); // ========== COMPLETE (123ms) ==========```
28
+ */
29
+ export declare const startTimer: () => () => number;
30
+ /**
31
+ * Logs values to the console (no prefix).
32
+ * @param values - Values to log (will be JSON stringified)
33
+ * @example
34
+ * ```typescript
35
+ * log("hello"); // "hello"
36
+ * ```
37
+ */
38
+ export declare const log: (...values: unknown[]) => void;
39
+ /**
40
+ * Logs values with [info] prefix.
41
+ * @param values - Values to log (will be JSON stringified)
42
+ * @example
43
+ * ```typescript
44
+ * info("stuff"); // [info] "stuff"
45
+ * ```
46
+ */
47
+ export declare const info: (...values: unknown[]) => void;
48
+ /**
49
+ * Logs values with [warn] prefix.
50
+ * @param values - Values to log (will be JSON stringified)
51
+ * @example
52
+ * ```typescript
53
+ * warn("uh oh"); // [warn] "uh oh"
54
+ * ```
55
+ */
56
+ export declare const warn: (...values: unknown[]) => void;
57
+ /**
58
+ * Logs values with [error] prefix.
59
+ * @param values - Values to log (will be JSON stringified)
60
+ * @example
61
+ * ```typescript
62
+ * error("bad"); // [error] "bad"
63
+ * ```
64
+ */
65
+ export declare const error: (...values: unknown[]) => void;
66
+ /**
67
+ * Logs a message wrapped in header decoration.
68
+ * @param message - The header message
69
+ * @example
70
+ * ```typescript
71
+ * header("STARTING"); // ========== STARTING ==========
72
+ * ```
73
+ */
74
+ export declare const header: (message: string) => void;
75
+ /**
76
+ * Creates a scoped logger with a label prefix.
77
+ * @param name - The label to prefix all log messages with
78
+ * @returns A logger object with info, warn, error, and header methods
79
+ * @example
80
+ * ```typescript
81
+ * const log = label("audio-processor");
82
+ * log.info("something"); // [audio-processor] "something"
83
+ * log.warn("hmm"); // [audio-processor] [warn] "hmm"
84
+ * log.error("failed"); // [audio-processor] [error] "failed"
85
+ * log.header("HANDLER START"); // [audio-processor] ========== HANDLER START ==========
86
+ * ```
87
+ */
88
+ export declare const label: (name: string) => {
89
+ /** Logs values with [label] prefix. Output: `[label] "value"` */
90
+ info: (...values: unknown[]) => void;
91
+ /** Logs values with [label] [warn] prefix. Output: `[label] [warn] "value"` */
92
+ warn: (...values: unknown[]) => void;
93
+ /** Logs values with [label] [error] prefix. Output: `[label] [error] "value"` */
94
+ error: (...values: unknown[]) => void;
95
+ /** Logs a header message with [label] prefix. Output: `[label] ========== MESSAGE ==========` */
96
+ header: (message: string) => void;
97
+ };
98
+ //# sourceMappingURL=log.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../src/shared/log.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH;;;;;;;;GAQG;AACH,eAAO,MAAM,UAAU,oBAGtB,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,GAAG,GAAI,GAAG,QAAQ,OAAO,EAAE,SAEvC,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,IAAI,GAAI,GAAG,QAAQ,OAAO,EAAE,SAExC,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,IAAI,GAAI,GAAG,QAAQ,OAAO,EAAE,SAExC,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,KAAK,GAAI,GAAG,QAAQ,OAAO,EAAE,SAEzC,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,MAAM,GAAI,SAAS,MAAM,SAErC,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,KAAK,GAAI,MAAM,MAAM;IAChC,iEAAiE;sBAC/C,OAAO,EAAE;IAG3B,+EAA+E;sBAC7D,OAAO,EAAE;IAG3B,iFAAiF;uBAC9D,OAAO,EAAE;IAG5B,iGAAiG;sBAC/E,MAAM;CAGxB,CAAC"}
@@ -0,0 +1,18 @@
1
+ type Opts = {
2
+ symbol?: boolean;
3
+ };
4
+ /**
5
+ * Convert cents to USD currency string
6
+ * @param cents
7
+ * @param opts
8
+ * @returns
9
+ */
10
+ export declare const convertToUsd: (cents?: number | string, opts?: Opts) => string | undefined;
11
+ /**
12
+ * Convert dollars to cents
13
+ * @param dollars
14
+ * @returns
15
+ */
16
+ export declare const convertToCents: (dollars: string | number) => number;
17
+ export {};
18
+ //# sourceMappingURL=money.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"money.d.ts","sourceRoot":"","sources":["../../src/shared/money.ts"],"names":[],"mappings":"AAAA,KAAK,IAAI,GAAG;IACV,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,YAAY,GAAI,QAAQ,MAAM,GAAG,MAAM,EAAE,OAAM,IAAS,uBASpE,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,cAAc,GAAI,SAAS,MAAM,GAAG,MAAM,WAGtD,CAAC"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Randomly pick an item from an array.
3
+ * @param xs
4
+ * @returns
5
+ */
6
+ export declare const item: <T>(xs: T[]) => T | undefined;
7
+ type RandProps = {
8
+ min?: number;
9
+ max?: number;
10
+ };
11
+ /**
12
+ * Generate a random number (supposedly more random than v1)
13
+ * @param props
14
+ * @returns
15
+ */
16
+ export declare const num: (props?: RandProps) => number;
17
+ /**
18
+ * The Fisher-Yates shuffle is the most efficient algorithm for that purpose.
19
+ * @param xs
20
+ * @returns
21
+ */
22
+ export declare const shuffle: <T>(xs: T[]) => T[];
23
+ /**
24
+ * Randomly return true or false.
25
+ * @returns
26
+ */
27
+ export declare const coinFlip: () => boolean;
28
+ /**
29
+ * Generate a random date.
30
+ * 10000000000 keeps the date to within the current year.
31
+ * The more 0s, the greater the range.
32
+ * @returns
33
+ */
34
+ export declare const date: () => Date;
35
+ /**
36
+ * Generate a random hex color.
37
+ * @returns
38
+ */
39
+ export declare const hexColor: () => string;
40
+ export {};
41
+ //# sourceMappingURL=random.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"random.d.ts","sourceRoot":"","sources":["../../src/shared/random.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,IAAI,GAAI,CAAC,EAAE,IAAI,CAAC,EAAE,kBAI9B,CAAC;AAEF,KAAK,SAAS,GAAG;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,GAAG,GAAI,QAAO,SAAc,WAOxC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,OAAO,GAAI,CAAC,EAAE,IAAI,CAAC,EAAE,QAKjC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,QAAQ,eAEpB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,IAAI,YAEhB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,QAAQ,QAAO,MAO3B,CAAC"}