qstd 0.2.9 → 0.2.11

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 -1
  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 -1
  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 -1
  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 -1
  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 +5 -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 +20 -19
  84. package/dist/client/index.d.cts +0 -75
  85. package/dist/log-ERvLs2Dx.d.cts +0 -460
  86. package/dist/log-ERvLs2Dx.d.ts +0 -460
  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"}
@@ -138,8 +138,35 @@ __export(str_exports, {
138
138
  concat: () => concat,
139
139
  countChar: () => countChar,
140
140
  countWords: () => countWords,
141
- createSentences: () => createSentences
141
+ createSentences: () => createSentences,
142
+ parseJson: () => parseJson
142
143
  });
144
+ function parseJson(input, opts) {
145
+ const strict = opts?.strict ?? false;
146
+ if (input === null || input === void 0) {
147
+ const error2 = new Error("[parseJson] input is null or undefined");
148
+ if (strict) throw error2;
149
+ return { ok: false, error: error2 };
150
+ }
151
+ if (input === "") {
152
+ const error2 = new Error("[parseJson] input is empty string");
153
+ if (strict) throw error2;
154
+ return { ok: false, error: error2 };
155
+ }
156
+ if (typeof input === "object") {
157
+ if (strict) return input;
158
+ return { ok: true, data: input };
159
+ }
160
+ try {
161
+ const data = JSON.parse(input);
162
+ if (strict) return data;
163
+ return { ok: true, data };
164
+ } catch (e) {
165
+ const error2 = e instanceof Error ? e : new Error("[parseJson] failed to parse JSON");
166
+ if (strict) throw error2;
167
+ return { ok: false, error: error2 };
168
+ }
169
+ }
143
170
  var createSentences = (text) => {
144
171
  if (!text) return [];
145
172
  return text?.replace(/([.?!])\s*(?=[A-Z])/g, "$1|").split("|");
@@ -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-ERvLs2Dx.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"}
@@ -132,8 +132,35 @@ __export(str_exports, {
132
132
  concat: () => concat,
133
133
  countChar: () => countChar,
134
134
  countWords: () => countWords,
135
- createSentences: () => createSentences
135
+ createSentences: () => createSentences,
136
+ parseJson: () => parseJson
136
137
  });
138
+ function parseJson(input, opts) {
139
+ const strict = opts?.strict ?? false;
140
+ if (input === null || input === void 0) {
141
+ const error2 = new Error("[parseJson] input is null or undefined");
142
+ if (strict) throw error2;
143
+ return { ok: false, error: error2 };
144
+ }
145
+ if (input === "") {
146
+ const error2 = new Error("[parseJson] input is empty string");
147
+ if (strict) throw error2;
148
+ return { ok: false, error: error2 };
149
+ }
150
+ if (typeof input === "object") {
151
+ if (strict) return input;
152
+ return { ok: true, data: input };
153
+ }
154
+ try {
155
+ const data = JSON.parse(input);
156
+ if (strict) return data;
157
+ return { ok: true, data };
158
+ } catch (e) {
159
+ const error2 = e instanceof Error ? e : new Error("[parseJson] failed to parse JSON");
160
+ if (strict) throw error2;
161
+ return { ok: false, error: error2 };
162
+ }
163
+ }
137
164
  var createSentences = (text) => {
138
165
  if (!text) return [];
139
166
  return text?.replace(/([.?!])\s*(?=[A-Z])/g, "$1|").split("|");
@@ -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,5 @@
1
+ export declare const log: (...values: unknown[]) => void;
2
+ export declare const info: (...values: unknown[]) => void;
3
+ export declare const warn: (...values: unknown[]) => void;
4
+ export declare const error: (...values: unknown[]) => void;
5
+ //# sourceMappingURL=log.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../src/shared/log.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,GAAG,GAAI,GAAG,QAAQ,OAAO,EAAE,SAEvC,CAAC;AAEF,eAAO,MAAM,IAAI,GAAI,GAAG,QAAQ,OAAO,EAAE,SAExC,CAAC;AAEF,eAAO,MAAM,IAAI,GAAI,GAAG,QAAQ,OAAO,EAAE,SAExC,CAAC;AAEF,eAAO,MAAM,KAAK,GAAI,GAAG,QAAQ,OAAO,EAAE,SAEzC,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"}
@@ -0,0 +1,74 @@
1
+ type ParseJsonResult<T> = {
2
+ ok: true;
3
+ data: T;
4
+ } | {
5
+ ok: false;
6
+ error: Error;
7
+ };
8
+ /**
9
+ * Parse a JSON string into an object
10
+ * - Safe by default: returns { ok, data/error }
11
+ * - Strict mode: throws on error, returns data directly
12
+ * - If input is already an object, returns it as-is
13
+ * - If input is null/undefined/empty string, returns error (or throws if strict)
14
+ * - Optional generic for typed output (no runtime validation)
15
+ *
16
+ * @example
17
+ * // Safe mode (default)
18
+ * const result = parseJson(event.body);
19
+ * if (result.ok) console.log(result.data);
20
+ *
21
+ * @example
22
+ * // Safe mode with type
23
+ * const result = parseJson<{ name: string }>(event.body);
24
+ * if (result.ok) console.log(result.data.name);
25
+ *
26
+ * @example
27
+ * // Strict mode - throws on error
28
+ * const data = parseJson<MyType>(event.body, { strict: true });
29
+ */
30
+ export declare function parseJson<T = Record<string, unknown>>(input: string | object | null | undefined, opts: {
31
+ strict: true;
32
+ }): T;
33
+ export declare function parseJson<T = Record<string, unknown>>(input: string | object | null | undefined, opts?: {
34
+ strict?: false;
35
+ }): ParseJsonResult<T>;
36
+ type CaseOpts = {
37
+ to: "title" | "snake" | "kebab";
38
+ clean?: boolean;
39
+ };
40
+ /**
41
+ * Split text into sentences
42
+ * @param text
43
+ * @returns
44
+ */
45
+ export declare const createSentences: (text?: string) => string[];
46
+ /**
47
+ * Count words in text
48
+ * @param text
49
+ * @returns
50
+ */
51
+ export declare const countWords: (text: string) => number;
52
+ /**
53
+ * Concatenate strings with optional delimiter
54
+ * @param xs
55
+ * @param delimiter
56
+ * @returns
57
+ */
58
+ export declare const concat: (xs: (string | undefined)[], delimiter?: string) => string;
59
+ /**
60
+ * The number of times a character appears in a string
61
+ * @param str
62
+ * @param ch
63
+ * @returns
64
+ */
65
+ export declare const countChar: (str: string, ch: string) => number;
66
+ /**
67
+ * Convert a str to specific casing
68
+ * @param text
69
+ * @param opts
70
+ * @returns
71
+ */
72
+ export declare const changeCase: <T extends string>(text: string, opts: CaseOpts) => string;
73
+ export {};
74
+ //# sourceMappingURL=str.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"str.d.ts","sourceRoot":"","sources":["../../src/shared/str.ts"],"names":[],"mappings":"AAAA,KAAK,eAAe,CAAC,CAAC,IAAI;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,CAAC,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,KAAK,CAAA;CAAE,CAAC;AAE9E;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,SAAS,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACnD,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,EACzC,IAAI,EAAE;IAAE,MAAM,EAAE,IAAI,CAAA;CAAE,GACrB,CAAC,CAAC;AACL,wBAAgB,SAAS,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACnD,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,EACzC,IAAI,CAAC,EAAE;IAAE,MAAM,CAAC,EAAE,KAAK,CAAA;CAAE,GACxB,eAAe,CAAC,CAAC,CAAC,CAAC;AAwCtB,KAAK,QAAQ,GAAG;IACd,EAAE,EAAE,OAAO,GAAG,OAAO,GAAG,OAAO,CAAC;IAChC,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAAI,OAAO,MAAM,aAG5C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,UAAU,GAAI,MAAM,MAAM,WAStC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,MAAM,GAAI,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC,EAAE,EAAE,YAAY,MAAM,WAEpE,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,SAAS,GAAI,KAAK,MAAM,EAAE,IAAI,MAAM,WAEhD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,UAAU,GAAI,CAAC,SAAS,MAAM,EAAE,MAAM,MAAM,EAAE,MAAM,QAAQ,WAmBxE,CAAC"}