@bgskinner2/ts-utils 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1,10 +1,5 @@
1
1
  import * as react from 'react';
2
- import { ElementType, ComponentPropsWithoutRef, ReactElement, MouseEvent, ReactNode, ComponentType, ForwardRefExoticComponent, ReactPortal, Ref, RefObject } from 'react';
3
-
4
- /** @see {@link TypeDocs.TStaticMethods} */
5
- type TStaticMethods<T> = {
6
- [K in keyof T as T[K] extends (...args: any) => any ? K : never]: T[K];
7
- };
2
+ import { ElementType, ComponentPropsWithoutRef, ReactElement, MouseEvent, ReactNode, ComponentType, ForwardRefExoticComponent, ReactPortal, Ref, RefObject, CSSProperties, SyntheticEvent, RefCallback } from 'react';
8
3
 
9
4
  type TArrayLengthMutationKeys = 'splice' | 'push' | 'pop' | 'shift' | 'unshift' | number;
10
5
  type TArrayItems<T extends Array<unknown>> = T extends Array<infer TItems> ? TItems : never;
@@ -61,29 +56,6 @@ type CamelCaseFromArray<WordsArr extends string[], Options extends {
61
56
  ] ? Options['preserveConsecutiveUppercase'] extends true ? `${Capitalize<FirstWord>}${CamelCaseFromArray<Rest, Options>}` : `${Capitalize<Lowercase<FirstWord>>}${CamelCaseFromArray<Rest, Options>}` : OutputString;
62
57
  type TCamelCase<Type, Options extends TDelimiterCaseOptions = object> = Type extends string ? string extends Type ? Type : Uncapitalize<CamelCaseFromArray<TWords<Type extends Uppercase<Type> ? Lowercase<Type> : Type>, TMergeDelimiterCaseOptions<Options>>> : Type;
63
58
 
64
- declare const LOG_TYPES: readonly ["log", "warn", "error", "info", "debug", "table"];
65
- declare const REGEX_CONSTANTS: {
66
- readonly isoRegex: RegExp;
67
- readonly camelCase: RegExp;
68
- readonly kebabCase: RegExp;
69
- readonly snakeCase: RegExp;
70
- readonly hexString: RegExp;
71
- readonly hexColor: RegExp;
72
- readonly letterSeparator: RegExp;
73
- readonly camelCaseBoundary: RegExp;
74
- readonly kebabCaseBoundary: RegExp;
75
- readonly whitespace: RegExp;
76
- readonly wordBoundarySplitter: RegExp;
77
- readonly USPhoneNumber: RegExp;
78
- readonly EUPhoneNumber: RegExp;
79
- readonly genericPhoneNumber: RegExp;
80
- readonly genericEmail: RegExp;
81
- readonly emailRegex: RegExp;
82
- readonly imageSrcRegex: RegExp;
83
- readonly singleAlphabetChar: RegExp;
84
- readonly htmlDetection: RegExp;
85
- readonly stackTracePrefix: RegExp;
86
- };
87
59
  declare const ANSI_COLOR_CODES: {
88
60
  readonly reset: "\u001B[0m";
89
61
  readonly black: "\u001B[30m";
@@ -98,426 +70,7 @@ declare const ANSI_COLOR_CODES: {
98
70
  readonly underline: "\u001B[4m";
99
71
  };
100
72
 
101
- declare const VALID_DOM_PROPS: {
102
- abbr: true;
103
- accept: true;
104
- acceptCharset: true;
105
- accessKey: true;
106
- action: true;
107
- allow: true;
108
- allowFullScreen: true;
109
- allowPaymentRequest: true;
110
- alt: true;
111
- async: true;
112
- autoComplete: true;
113
- autoFocus: true;
114
- autoPlay: true;
115
- capture: true;
116
- cellPadding: true;
117
- cellSpacing: true;
118
- challenge: true;
119
- charSet: true;
120
- checked: true;
121
- cite: true;
122
- classID: true;
123
- className: true;
124
- cols: true;
125
- colSpan: true;
126
- content: true;
127
- contentEditable: true;
128
- contextMenu: true;
129
- controls: true;
130
- controlsList: true;
131
- coords: true;
132
- crossOrigin: true;
133
- data: true;
134
- dateTime: true;
135
- decoding: true;
136
- default: true;
137
- defer: true;
138
- dir: true;
139
- disabled: true;
140
- disablePictureInPicture: true;
141
- disableRemotePlayback: true;
142
- download: true;
143
- draggable: true;
144
- encType: true;
145
- enterKeyHint: true;
146
- form: true;
147
- formAction: true;
148
- formEncType: true;
149
- formMethod: true;
150
- formNoValidate: true;
151
- formTarget: true;
152
- frameBorder: true;
153
- headers: true;
154
- height: true;
155
- hidden: true;
156
- high: true;
157
- href: true;
158
- hrefLang: true;
159
- htmlFor: true;
160
- httpEquiv: true;
161
- id: true;
162
- inputMode: true;
163
- integrity: true;
164
- is: true;
165
- keyParams: true;
166
- keyType: true;
167
- kind: true;
168
- label: true;
169
- lang: true;
170
- list: true;
171
- loading: true;
172
- loop: true;
173
- low: true;
174
- marginHeight: true;
175
- marginWidth: true;
176
- max: true;
177
- maxLength: true;
178
- media: true;
179
- mediaGroup: true;
180
- method: true;
181
- min: true;
182
- minLength: true;
183
- multiple: true;
184
- muted: true;
185
- name: true;
186
- nonce: true;
187
- noValidate: true;
188
- open: true;
189
- optimum: true;
190
- pattern: true;
191
- placeholder: true;
192
- playsInline: true;
193
- poster: true;
194
- preload: true;
195
- profile: true;
196
- radioGroup: true;
197
- readOnly: true;
198
- referrerPolicy: true;
199
- rel: true;
200
- required: true;
201
- reversed: true;
202
- role: true;
203
- rows: true;
204
- rowSpan: true;
205
- sandbox: true;
206
- scope: true;
207
- scoped: true;
208
- scrolling: true;
209
- seamless: true;
210
- selected: true;
211
- shape: true;
212
- size: true;
213
- sizes: true;
214
- slot: true;
215
- span: true;
216
- spellCheck: true;
217
- src: true;
218
- srcDoc: true;
219
- srcLang: true;
220
- srcSet: true;
221
- start: true;
222
- step: true;
223
- style: true;
224
- summary: true;
225
- tabIndex: true;
226
- target: true;
227
- title: true;
228
- translate: true;
229
- type: true;
230
- useMap: true;
231
- value: true;
232
- width: true;
233
- wmode: true;
234
- wrap: true;
235
- alignmentBaseline: true;
236
- baselineShift: true;
237
- clip: true;
238
- clipPath: true;
239
- clipRule: true;
240
- color: true;
241
- colorInterpolation: true;
242
- colorInterpolationFilters: true;
243
- colorProfile: true;
244
- colorRendering: true;
245
- cursor: true;
246
- direction: true;
247
- display: true;
248
- dominantBaseline: true;
249
- enableBackground: true;
250
- fill: true;
251
- fillOpacity: true;
252
- fillRule: true;
253
- filter: true;
254
- floodColor: true;
255
- floodOpacity: true;
256
- imageRendering: true;
257
- lightingColor: true;
258
- markerEnd: true;
259
- markerMid: true;
260
- markerStart: true;
261
- mask: true;
262
- opacity: true;
263
- overflow: true;
264
- paintOrder: true;
265
- pointerEvents: true;
266
- shapeRendering: true;
267
- stopColor: true;
268
- stopOpacity: true;
269
- stroke: true;
270
- strokeDasharray: true;
271
- strokeDashoffset: true;
272
- strokeLinecap: true;
273
- strokeLinejoin: true;
274
- strokeMiterlimit: true;
275
- strokeOpacity: true;
276
- strokeWidth: true;
277
- textAnchor: true;
278
- textDecoration: true;
279
- textRendering: true;
280
- unicodeBidi: true;
281
- vectorEffect: true;
282
- visibility: true;
283
- wordSpacing: true;
284
- writingMode: true;
285
- cx: true;
286
- cy: true;
287
- d: true;
288
- dx: true;
289
- dy: true;
290
- fr: true;
291
- fx: true;
292
- fy: true;
293
- points: true;
294
- r: true;
295
- rx: true;
296
- ry: true;
297
- transform: true;
298
- version: true;
299
- viewBox: true;
300
- x: true;
301
- x1: true;
302
- x2: true;
303
- y: true;
304
- y1: true;
305
- y2: true;
306
- z: true;
307
- accumulate: true;
308
- additive: true;
309
- allowReorder: true;
310
- amplitude: true;
311
- attributeName: true;
312
- attributeType: true;
313
- autoReverse: true;
314
- begin: true;
315
- bias: true;
316
- by: true;
317
- calcMode: true;
318
- decelerate: true;
319
- diffuseConstant: true;
320
- divisor: true;
321
- dur: true;
322
- edgeMode: true;
323
- elevation: true;
324
- end: true;
325
- exponent: true;
326
- externalResourcesRequired: true;
327
- filterRes: true;
328
- filterUnits: true;
329
- from: true;
330
- in: true;
331
- in2: true;
332
- intercept: true;
333
- k: true;
334
- k1: true;
335
- k2: true;
336
- k3: true;
337
- k4: true;
338
- kernelMatrix: true;
339
- kernelUnitLength: true;
340
- keyPoints: true;
341
- keySplines: true;
342
- keyTimes: true;
343
- limitingConeAngle: true;
344
- mode: true;
345
- numOctaves: true;
346
- operator: true;
347
- order: true;
348
- orient: true;
349
- orientation: true;
350
- origin: true;
351
- pathLength: true;
352
- primitiveUnits: true;
353
- repeatCount: true;
354
- repeatDur: true;
355
- restart: true;
356
- result: true;
357
- rotate: true;
358
- scale: true;
359
- seed: true;
360
- slope: true;
361
- spacing: true;
362
- specularConstant: true;
363
- specularExponent: true;
364
- speed: true;
365
- spreadMethod: true;
366
- startOffset: true;
367
- stdDeviation: true;
368
- stitchTiles: true;
369
- surfaceScale: true;
370
- targetX: true;
371
- targetY: true;
372
- to: true;
373
- values: true;
374
- xChannelSelector: true;
375
- yChannelSelector: true;
376
- zoomAndPan: true;
377
- accentHeight: true;
378
- alphabetic: true;
379
- arabicForm: true;
380
- ascent: true;
381
- bbox: true;
382
- capHeight: true;
383
- descent: true;
384
- fontFamily: true;
385
- fontSize: true;
386
- fontSizeAdjust: true;
387
- fontStretch: true;
388
- fontStyle: true;
389
- fontVariant: true;
390
- fontWeight: true;
391
- format: true;
392
- g1: true;
393
- g2: true;
394
- glyphName: true;
395
- glyphOrientationHorizontal: true;
396
- glyphOrientationVertical: true;
397
- glyphRef: true;
398
- hanging: true;
399
- horizAdvX: true;
400
- horizOriginX: true;
401
- ideographic: true;
402
- kerning: true;
403
- lengthAdjust: true;
404
- letterSpacing: true;
405
- local: true;
406
- mathematical: true;
407
- overlinePosition: true;
408
- overlineThickness: true;
409
- panose1: true;
410
- refX: true;
411
- refY: true;
412
- renderingIntent: true;
413
- strikethroughPosition: true;
414
- strikethroughThickness: true;
415
- string: true;
416
- systemLanguage: true;
417
- tableValues: true;
418
- textLength: true;
419
- u1: true;
420
- u2: true;
421
- underlinePosition: true;
422
- underlineThickness: true;
423
- unicode: true;
424
- unicodeRange: true;
425
- unitsPerEm: true;
426
- vAlphabetic: true;
427
- vHanging: true;
428
- vIdeographic: true;
429
- vMathematical: true;
430
- vertAdvY: true;
431
- vertOriginX: true;
432
- vertOriginY: true;
433
- widths: true;
434
- xHeight: true;
435
- clipPathUnits: true;
436
- contentScriptType: true;
437
- contentStyleType: true;
438
- gradientTransform: true;
439
- gradientUnits: true;
440
- markerHeight: true;
441
- markerUnits: true;
442
- markerWidth: true;
443
- maskContentUnits: true;
444
- maskUnits: true;
445
- offset: true;
446
- patternContentUnits: true;
447
- patternTransform: true;
448
- patternUnits: true;
449
- preserveAlpha: true;
450
- preserveAspectRatio: true;
451
- requiredExtensions: true;
452
- requiredFeatures: true;
453
- viewTarget: true;
454
- xlinkActuate: true;
455
- xlinkArcrole: true;
456
- xlinkHref: true;
457
- xlinkRole: true;
458
- xlinkShow: true;
459
- xlinkTitle: true;
460
- xlinkType: true;
461
- xmlBase: true;
462
- xmlns: true;
463
- xmlnsXlink: true;
464
- xmlLang: true;
465
- xmlSpace: true;
466
- for: true;
467
- class: true;
468
- autofocus: true;
469
- children: true;
470
- dangerouslySetInnerHTML: true;
471
- key: true;
472
- ref: true;
473
- defaultValue: true;
474
- defaultChecked: true;
475
- innerHTML: true;
476
- suppressContentEditableWarning: true;
477
- suppressHydrationWarning: true;
478
- valueLink: true;
479
- onCaptured: true;
480
- precedence: true;
481
- blocking: true;
482
- autoCorrect: true;
483
- autoCapitalize: true;
484
- popover: true;
485
- popoverTarget: true;
486
- popoverTargetAction: true;
487
- inert: true;
488
- fetchpriority: true;
489
- fetchPriority: true;
490
- shadowRoot: true;
491
- ariaHasPopup: true;
492
- ariaLabel: true;
493
- ariaLabelledBy: true;
494
- about: true;
495
- datatype: true;
496
- inlist: true;
497
- prefix: true;
498
- property: true;
499
- resource: true;
500
- typeof: true;
501
- vocab: true;
502
- itemProp: true;
503
- itemScope: true;
504
- itemType: true;
505
- itemID: true;
506
- itemRef: true;
507
- autoSave: true;
508
- incremental: true;
509
- results: true;
510
- security: true;
511
- unselectable: true;
512
- on: true;
513
- option: true;
514
- fallback: true;
515
- };
516
- declare const VALID_DOM_TESTING_KEYS: string[];
517
-
518
73
  declare const HTML_TAGS: readonly ["div", "span", "a", "p", "ul", "li"];
519
- declare const SAFE_HTML_TAGS: readonly ["b", "i", "p", "ul", "li", "a", "span", "div", "br", "strong", "em", "u", "code", "pre", "blockquote"];
520
- declare const DEFAULT_KEYBOARD_CONFIG: Required<TKeyboardConfig>;
521
74
 
522
75
  declare const __brand: unique symbol;
523
76
  type Branded<T, B> = T & {
@@ -562,20 +115,7 @@ type TGetCallerLocationOptions = {
562
115
  /** Path prefix to strip from the returned line (default: process.cwd()) */
563
116
  stripPathPrefix?: string;
564
117
  };
565
- type TTableItem = {
566
- key?: string;
567
- start?: number;
568
- end?: number;
569
- };
570
- type TProcessedTableItem = {
571
- key: string | number;
572
- duration: string;
573
- };
574
118
 
575
- type TPropMap = Record<string, boolean>;
576
- type TPropCategories = {
577
- readonly [category: string]: TPropMap;
578
- };
579
119
  /**
580
120
  * A structural contract for any React component that might have
581
121
  * identification metadata.
@@ -1199,6 +739,58 @@ declare const isRecordOf: <V>(value: unknown, typeGuard: TTypeGuard<V>) => value
1199
739
  * @returns A type guard function that returns `true` if all `requiredKeys` are found and defined.
1200
740
  */
1201
741
  declare const hasDefinedKeys: <T extends object>(requiredKeys: (keyof T)[]) => ((value: unknown) => value is T);
742
+ /**
743
+ * ## 🧩 isShape — Recursive Structural Type Guard Factory
744
+ *
745
+ * Creates a **high-fidelity type guard** that validates whether an unknown object
746
+ * conforms to a specific structural "contract" defined by a schema of guards.
747
+ *
748
+ * ---
749
+ *
750
+ * ### ⚙️ Core Purpose
751
+ * - 🔹 **Eliminate `as` casting**: Moves from speculative assertions to deterministic verification.
752
+ * - 🔹 **Recursive Validation**: Safely audits nested object trees by composing guards.
753
+ * - 🔹 **Compile-Time Synchronization**: Using `[K in keyof T]` ensures the schema
754
+ * stays in sync with the interface. If the interface changes, the guard will fail to compile.
755
+ *
756
+ * ---
757
+ *
758
+ * ### 📘 Example Usage
759
+ * ```ts
760
+ * interface UserProfile {
761
+ * id: string;
762
+ * settings: { theme: 'dark' | 'light' };
763
+ * }
764
+ *
765
+ * // Define the contract once
766
+ * const isUserProfile = isShape<UserProfile>({
767
+ * id: isString,
768
+ * settings: isShape({
769
+ * theme: isInArray(['dark', 'light'] as const)
770
+ * })
771
+ * });
772
+ *
773
+ * const rawData: unknown = await fetchApi();
774
+ *
775
+ * if (isUserProfile(rawData)) {
776
+ * // ✅ rawData is now fully narrowed, including nested properties.
777
+ * console.log(rawData.settings.theme);
778
+ * }
779
+ * ```
780
+ *
781
+ * ---
782
+ *
783
+ * ### 📌 Notes
784
+ * - **Exorcises Ghost Objects**: Unlike `{} as T`, this verifies every required key.
785
+ * - **Optional Support**: If a key is missing in the value but allowed in the schema,
786
+ * the individual property guard must handle the `undefined` case.
787
+ * - **Zero Casts**: Internally leverages `isKeyInObject` for type-safe property discovery.
788
+ *
789
+ * @typeParam T - The target interface or object type to validate.
790
+ * @param schema - A mapping of keys from `T` to their corresponding `TTypeGuard`.
791
+ * @returns A type guard function that narrows `unknown` to `T`.
792
+ */
793
+ declare const isShape: <T extends object>(schema: { [K in keyof T]: TTypeGuard<T[K]>; }) => TTypeGuard<T>;
1202
794
 
1203
795
  /**
1204
796
  * Checks if a value is a **Buffer-like object**.
@@ -1516,6 +1108,7 @@ declare const CollectionTypeGuards: {
1516
1108
  readonly isKeyOfArray: <T extends readonly (string | number | symbol)[]>(keys: T) => TTypeGuard<T[number]>;
1517
1109
  readonly isInArray: <T>(target: readonly T[]) => TTypeGuard<T | undefined>;
1518
1110
  readonly hasKeys: <T extends object>(requiredKeys: (keyof T)[]) => ((value: unknown) => value is T);
1111
+ readonly isShape: <T extends object>(schema: { [K in keyof T]: TTypeGuard<T[K]>; }) => TTypeGuard<T>;
1519
1112
  };
1520
1113
 
1521
1114
  /**
@@ -2543,4 +2136,246 @@ declare class LinkUtils {
2543
2136
  static readonly handleHashScroll: ({ event, href, behavior, block, }: THashScrollOptions) => boolean;
2544
2137
  }
2545
2138
 
2546
- export { ANSI_COLOR_CODES, ArrayUtils, AssertionUtils, type Branded, CollectionTypeGuards, ColorUtils, ComputationUtils, CoreTypeGuards, DEFAULT_KEYBOARD_CONFIG, DebugUtils, DomUtils, FormatTypeGuards, HTML_TAGS, LOG_TYPES, LinkUtils, type ModifierKey, ObjectUtils, REGEX_CONSTANTS, ReactTypeGuards, RenamedArrayMethods, RenamedObjectMethods, SAFE_HTML_TAGS, type TAbsoluteURL, type TAnyFunction, type TArrayItems, type TArrayLengthMutationKeys, type TAssert, type TBaseImageObject, type TBufferLikeObject, type TCamelCase, type TCssRGB, type TElementLike, type TFixedLengthArray, type TGenericUrlObject, type TGetCallerLocationOptions, type THTMLTags, type THashScrollOptions, type THexByteString, type THighlighterMap, type TInternalUrl, type TJSONArrayString, type TJSONDataString, type TJSONObjectString, type TKebabCase, type TKeyboardActionResult, type TKeyboardConfig, type TLogOptions, type TLogType, type TNamedComponent, type TProcessedTableItem, type TPropCategories, type TPropMap, type TRGB, type TShortcutDefinition, type TSnakeCase, type TStaticMethods, type TTableItem, type TTypeGuard, TransformersUtils, VALID_DOM_PROPS, VALID_DOM_TESTING_KEYS, arrayFilter, arrayFilterNonNullable, arrayFlat, arrayFlatMap, arrayForEach, arrayIncludes, arrayMap, arrayReduce, assertIsAbsoluteUrl, assertIsArray, assertIsBigInt, assertIsBoolean, assertIsBufferLikeObject, assertIsCamelCase, assertIsDefined, assertIsFunction, assertIsInteger, assertIsInternalUrl, assertIsJSONArrayString, assertIsJSONObjectString, assertIsJsonString, assertIsMap, assertIsNil, assertIsNonEmptyString, assertIsNull, assertIsNumber, assertIsRGBTuple, assertIsSet, assertIsString, assertIsSymbol, assertIsUndefined, assertIsWeakMap, assertIsWeakSet, assertObject, capitalizeArray, capitalizeString, capitalizedKeys, contrastTextColor, extractRelativePath, generateKeyMap, getCallerLocation, getKeyboardAction, getLuminance, handleInternalHashScroll, hasChildren, hasDefinedKeys, hasNameMetadata, hasOnClick, hexToHSL, hexToNormalizedRGB, hexToRGB, hexToRGBShorthand, highlight, interpolateColor, isAbsoluteUrl, isArray, isArrayOf, isBigInt, isBoolean, isBufferLikeObject, isCamelCase, isComponentType, isDOMEntry, isDOMPropKey, isDarkColor, isDefined, isElementLike, isElementOfType, isEmail, isForwardRef, isFragment, isFunction, isHTMLString, isHexByteString, isInArray, isInstanceOf, isInteger, isInternalUrl, isJSONArrayString, isJSONObjectString, isJsonString, isKebabCase, isKeyInObject, isKeyOfArray, isKeyOfObject, isLumGreaterThan, isLumLessThan, isMap, isNil, isNonEmptyString, isNull, isNumber, isObject, isPhoneNumber, isPrimitive, isPromise, isPropValid, isRGBTuple, isReactElement, isReactPortal, isRecordOf, isRef, isRefObject, isSet, isSnakeCase, isString, isSymbol, isUndefined, isValidReactNode, isWeakMap, isWeakSet, logDev, normalizeImageSrc, normalizeUrl, objectEntries, objectFromEntries, objectGet, objectHas, objectKeys, objectSet, objectValues, preloadImages, serialize, stripHash, toCamelCase, toKebabCase, toKeyByField, toSnakeCase, validateRGB };
2139
+ /**
2140
+ * ## 🌐 fetchJson — Fetch and Parse JSON from a URL
2141
+ *
2142
+ * Performs a `fetch` request and attempts to parse the response as JSON.
2143
+ * Throws a detailed error if the request fails or the response is not valid JSON.
2144
+ *
2145
+ * ---
2146
+ *
2147
+ * ### Example
2148
+ *
2149
+ * ```ts
2150
+ * const data = await fetchJson<{ id: number; name: string }>(
2151
+ * 'https://api.example.com/users/1'
2152
+ * );
2153
+ * console.log(data.id, data.name);
2154
+ * ```
2155
+ *
2156
+ * @template T - Expected type of the JSON response
2157
+ * @param url - URL to fetch JSON from
2158
+ * @returns Parsed JSON data of type `T`
2159
+ * @throws Error if fetch fails or response is invalid JSON
2160
+ */
2161
+ declare function fetchJson<T = unknown>(url: string): Promise<T>;
2162
+ /**
2163
+ * ## ⏱ delay — Pause Execution for a Duration
2164
+ *
2165
+ * Returns a Promise that resolves after a specified number of milliseconds.
2166
+ * Useful for throttling, rate-limiting, or waiting between async operations.
2167
+ *
2168
+ * ---
2169
+ *
2170
+ * ### Example
2171
+ *
2172
+ * ```ts
2173
+ * await delay(1000); // Pause for 1 second
2174
+ * console.log('Done waiting!');
2175
+ * ```
2176
+ *
2177
+ * @param ms - Number of milliseconds to wait
2178
+ * @returns Promise that resolves after `ms` milliseconds
2179
+ */
2180
+ declare const delay: (ms: number) => Promise<void>;
2181
+ /**
2182
+ * ## 🔁 retry — Retry an Async Function with Exponential Backoff
2183
+ *
2184
+ * Executes an async function multiple times if it fails, with an **exponential backoff** strategy.
2185
+ * Automatically handles transient failures or rate-limiting errors.
2186
+ *
2187
+ * ---
2188
+ *
2189
+ * ### Example
2190
+ *
2191
+ * ```ts
2192
+ * const result = await retry(() => fetchJson('/api/data'), 3, 500);
2193
+ * console.log(result);
2194
+ * ```
2195
+ *
2196
+ * @template T - Return type of the async function
2197
+ * @param fn - Async function to retry
2198
+ * @param retries - Maximum number of retry attempts (default: 5)
2199
+ * @param delayMs - Base delay in milliseconds for exponential backoff (default: 500)
2200
+ * @returns Result of the async function if successful
2201
+ * @throws Last encountered error if all retries fail
2202
+ */
2203
+ declare function retry<T>(fn: () => Promise<T>, retries?: number, delayMs?: number): Promise<T>;
2204
+
2205
+ /**
2206
+ * Combines multiple React refs (callback refs or object refs) into a single ref callback.
2207
+ *
2208
+ * This is especially useful when a component needs to:
2209
+ * 1. Forward a ref to its parent via `forwardRef`
2210
+ * 2. Maintain its own internal ref for hooks like `useInView`, animations, or measurements
2211
+ *
2212
+ * The returned callback handles both:
2213
+ * - Function refs (calls the function with the new value)
2214
+ * - Object refs (assigns the `current` property)
2215
+ * - Properly supports `null` for unmounting
2216
+ *
2217
+ * @example
2218
+ * ```ts
2219
+ * const combinedRef = mergeRefs(forwardedRef, internalRef);
2220
+ * <div ref={combinedRef} />
2221
+ * ```
2222
+ *
2223
+ * @param refs - One or more React refs (callback or object refs)
2224
+ * @returns A single callback that updates all provided refs with the same value
2225
+ */
2226
+ declare const mergeRefs: <T>(...refs: (Ref<T> | undefined)[]) => RefCallback<T>;
2227
+ /**
2228
+ * Lazily evaluates the properties of an object that are functions and caches the results.
2229
+ *
2230
+ * This utility is useful when you have an object with expensive-to-compute properties
2231
+ * (functions) that you don’t want to execute until they are actually accessed. It also
2232
+ * ensures that each property is only computed **once**, even if accessed multiple times.
2233
+ *
2234
+ * The original object is **not mutated**; all computed results are stored in an internal cache.
2235
+ *
2236
+ * ### Features
2237
+ * - Lazy evaluation of function properties.
2238
+ * - Caches results for repeated access.
2239
+ * - Safe for shared or frozen objects.
2240
+ * - Works only on original string keys of the object.
2241
+ *
2242
+ * ### Example
2243
+ * ```ts
2244
+ * const config = {
2245
+ * a: 10,
2246
+ * b: () => Math.random() * 100,
2247
+ * c: () => 'computed',
2248
+ * };
2249
+ *
2250
+ * const lazyConfig = lazyProxy(config);
2251
+ *
2252
+ * console.log(lazyConfig.a); // 10
2253
+ * console.log(lazyConfig.b); // e.g., 42.3 (evaluated only once)
2254
+ * console.log(lazyConfig.b); // same value as above (cached)
2255
+ * console.log(lazyConfig.c); // 'computed'
2256
+ * ```
2257
+ *
2258
+ * ### Use Cases
2259
+ * - Configuration objects with expensive default values.
2260
+ * - Large objects where some properties are rarely used.
2261
+ * - Avoiding repeated computation in utility objects or library settings.
2262
+ * - Safe lazy initialization in complex apps without mutating original objects.
2263
+ *
2264
+ * @param obj - The object whose function properties should be lazily evaluated.
2265
+ * @returns A proxied version of the object where function properties are evaluated lazily and cached.
2266
+ */
2267
+ declare function lazyProxy<T extends Record<string, unknown>>(obj: T): T;
2268
+ /**
2269
+ * Merges CSS variables with an optional style object.
2270
+ *
2271
+ * @param vars - An object where keys are CSS variable names (like '--my-var') and values are strings
2272
+ * @param style - Optional existing style object to merge
2273
+ * @returns A CSSProperties object ready to pass to a React component
2274
+ */
2275
+ declare function mergeCssVars<T extends Record<string, string | number | undefined>>(vars: T, style?: CSSProperties): CSSProperties;
2276
+ /**
2277
+ * Merges a user-provided event handler with an internal component handler.
2278
+ *
2279
+ * The `internalHandler` will only execute if the `userHandler` does not call
2280
+ * `event.preventDefault()`. This allows users of your component to opt-out
2281
+ * of default behaviors.
2282
+ *
2283
+ * @template E - The type of the SyntheticEvent (e.g., React.MouseEvent)
2284
+ * @param userHandler - The external handler passed via props
2285
+ * @param internalHandler - The library/internal logic that should run by default
2286
+ * @returns A single function that orchestrates both calls
2287
+ *
2288
+ * @example
2289
+ * ```tsx
2290
+ * const handleClick = mergeEventHandlerClicks<React.MouseEvent>(
2291
+ * props.onClick,
2292
+ * (e) => console.log("Internal logic ran!")
2293
+ * );
2294
+ *
2295
+ * // In the component:
2296
+ * <button onClick={handleClick}>Click Me</button>
2297
+ * ```
2298
+ */
2299
+ declare function mergeEventHandlerClicks<E extends SyntheticEvent>(userHandler?: (event: E) => void, internalHandler?: (event: E) => void): (event: E) => void;
2300
+ /**
2301
+ * Automatically extracts valid DOM props from a combined props object.
2302
+ *
2303
+ * This utility prevents React warnings like: "React does not recognize the `prop` on a DOM element."
2304
+ * It works by filtering the object against a whitelist of valid HTML attributes at runtime,
2305
+ * while maintaining strict TypeScript narrowing so the return type matches the target element.
2306
+ *
2307
+ * ### Features
2308
+ * - **Auto-Filtering**: No need to manually maintain an array of keys to delete.
2309
+ * - **Type Safe**: Automatically narrows the return type to `ComponentPropsWithoutRef<T>`.
2310
+ * - **Standard Compliant**: Supports all standard HTML attributes, `data-*`, and `aria-*` props.
2311
+ *
2312
+ * ### Example
2313
+ * ```tsx
2314
+ * interface MyButtonProps extends ComponentPropsWithoutRef<'button'> {
2315
+ * mainCircleSize: number; // Custom prop: will be stripped
2316
+ * variant: 'primary'; // Custom prop: will be stripped
2317
+ * }
2318
+ *
2319
+ * const MyButton = (props: MyButtonProps) => {
2320
+ * // domProps is automatically inferred as ComponentPropsWithoutRef<'button'>
2321
+ * // 'mainCircleSize' and 'variant' are removed automatically.
2322
+ * const domProps = extractDOMProps<'button', MyButtonProps>(props);
2323
+ *
2324
+ * return <button {...domProps}>Click Me</button>;
2325
+ * };
2326
+ * ```
2327
+ *
2328
+ * @template TElement - The HTML element type (e.g., 'div', 'button', 'span')
2329
+ * @template TFullProps - The combined custom and DOM props interface
2330
+ *
2331
+ * @param props - The full props object containing both custom and DOM-valid keys.
2332
+ * @returns A cleaned object containing only valid DOM properties for the specified element.
2333
+ */
2334
+ declare function extractDOMProps<TElement extends ElementType, TFullProps extends ComponentPropsWithoutRef<TElement>>(props: TFullProps): ComponentPropsWithoutRef<TElement>;
2335
+ /**
2336
+ * Filters React children by a specific component display name.
2337
+ *
2338
+ * This utility iterates over a ReactNode tree and returns only the children
2339
+ * that are valid React elements with a `displayName` matching the provided string.
2340
+ * It is especially useful for composite components like steppers or tabs,
2341
+ * where you want to operate only on specific subcomponents while ignoring others.
2342
+ *
2343
+ * The original `children` array is **not mutated**; a new filtered array is returned.
2344
+ *
2345
+ * ### Features
2346
+ * - Type-safe filtering of React elements.
2347
+ * - Skips non-React elements automatically.
2348
+ * - Returns a typed array of `ReactElement` for further processing.
2349
+ *
2350
+ * ### Example
2351
+ * ```tsx
2352
+ * const steps = filterChildrenByDisplayName(children, 'StepperStep');
2353
+ * steps.forEach(step => console.log(step.props));
2354
+ * ```
2355
+ *
2356
+ * ### Use Cases
2357
+ * - Stepper components: only extract `StepperStep` children for layout/logic.
2358
+ * - Tab components: only process `TabPanel` children.
2359
+ * - Any composite React component requiring selective child processing.
2360
+ *
2361
+ * @param children - The ReactNode children to filter.
2362
+ * @param displayName - The displayName of the component type to include.
2363
+ * @returns An array of ReactElement matching the given displayName.
2364
+ */
2365
+ declare function filterChildrenByDisplayName<T extends ReactNode>(children: T, displayName: string): ReactElement[];
2366
+
2367
+ declare const ProcessorUtils: {
2368
+ readonly fetchJson: typeof fetchJson;
2369
+ readonly delay: (ms: number) => Promise<void>;
2370
+ readonly retry: typeof retry;
2371
+ };
2372
+ declare const ReactProcessorUtils: {
2373
+ readonly mergeRefs: <T>(...refs: (react.Ref<T> | undefined)[]) => react.RefCallback<T>;
2374
+ readonly lazyProxy: typeof lazyProxy;
2375
+ readonly mergeCssVars: typeof mergeCssVars;
2376
+ readonly mergeEventHandlerClicks: typeof mergeEventHandlerClicks;
2377
+ readonly extractDOMProps: typeof extractDOMProps;
2378
+ readonly filterChildrenByDisplayName: typeof filterChildrenByDisplayName;
2379
+ };
2380
+
2381
+ export { ArrayUtils, AssertionUtils, CollectionTypeGuards, ColorUtils, ComputationUtils, CoreTypeGuards, DebugUtils, DomUtils, FormatTypeGuards, LinkUtils, ObjectUtils, ProcessorUtils, ReactProcessorUtils, ReactTypeGuards, RenamedArrayMethods, RenamedObjectMethods, TransformersUtils, arrayFilter, arrayFilterNonNullable, arrayFlat, arrayFlatMap, arrayForEach, arrayIncludes, arrayMap, arrayReduce, assertIsAbsoluteUrl, assertIsArray, assertIsBigInt, assertIsBoolean, assertIsBufferLikeObject, assertIsCamelCase, assertIsDefined, assertIsFunction, assertIsInteger, assertIsInternalUrl, assertIsJSONArrayString, assertIsJSONObjectString, assertIsJsonString, assertIsMap, assertIsNil, assertIsNonEmptyString, assertIsNull, assertIsNumber, assertIsRGBTuple, assertIsSet, assertIsString, assertIsSymbol, assertIsUndefined, assertIsWeakMap, assertIsWeakSet, assertObject, capitalizeArray, capitalizeString, capitalizedKeys, contrastTextColor, delay, extractDOMProps, extractRelativePath, fetchJson, filterChildrenByDisplayName, generateKeyMap, getCallerLocation, getKeyboardAction, getLuminance, handleInternalHashScroll, hasChildren, hasDefinedKeys, hasNameMetadata, hasOnClick, hexToHSL, hexToNormalizedRGB, hexToRGB, hexToRGBShorthand, highlight, interpolateColor, isAbsoluteUrl, isArray, isArrayOf, isBigInt, isBoolean, isBufferLikeObject, isCamelCase, isComponentType, isDOMEntry, isDOMPropKey, isDarkColor, isDefined, isElementLike, isElementOfType, isEmail, isForwardRef, isFragment, isFunction, isHTMLString, isHexByteString, isInArray, isInstanceOf, isInteger, isInternalUrl, isJSONArrayString, isJSONObjectString, isJsonString, isKebabCase, isKeyInObject, isKeyOfArray, isKeyOfObject, isLumGreaterThan, isLumLessThan, isMap, isNil, isNonEmptyString, isNull, isNumber, isObject, isPhoneNumber, isPrimitive, isPromise, isPropValid, isRGBTuple, isReactElement, isReactPortal, isRecordOf, isRef, isRefObject, isSet, isShape, isSnakeCase, isString, isSymbol, isUndefined, isValidReactNode, isWeakMap, isWeakSet, lazyProxy, logDev, mergeCssVars, mergeEventHandlerClicks, mergeRefs, normalizeImageSrc, normalizeUrl, objectEntries, objectFromEntries, objectGet, objectHas, objectKeys, objectSet, objectValues, preloadImages, retry, serialize, stripHash, toCamelCase, toKebabCase, toKeyByField, toSnakeCase, validateRGB };