@kosdev-code/kos-ui-sdk 2.0.5 → 2.0.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kosdev-code/kos-ui-sdk",
3
- "version": "2.0.5",
3
+ "version": "2.0.7",
4
4
  "type": "module",
5
5
  "main": "./index.cjs",
6
6
  "module": "./index.js",
@@ -36,7 +36,7 @@
36
36
  },
37
37
  "kos": {
38
38
  "build": {
39
- "gitHash": "609de03c7138d0851980c6120ed70b95bd33192b"
39
+ "gitHash": "3caa35fec5d055da290df0c4aa13813890ec98e3"
40
40
  }
41
41
  }
42
42
  }
@@ -15,6 +15,7 @@ export * from './use-config-bean';
15
15
  export * from './use-config-property';
16
16
  export * from './use-date-props';
17
17
  export * from './use-date-relative-prop';
18
+ export * from './use-function-warmup';
18
19
  export * from './use-kos-date-formats';
19
20
  export * from './use-kos-model';
20
21
  export * from './use-kos-region-timezones';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../packages/sdk/kos-ui-sdk/src/ui/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,eAAe,CAAC;AACtD,cAAc,YAAY,CAAC;AAC3B,cAAc,+BAA+B,CAAC;AAC9C,cAAc,OAAO,CAAC;AACtB,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAC9D,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,SAAS,CAAC;AACxB,cAAc,yBAAyB,CAAC;AACxC,cAAc,WAAW,CAAC;AAC1B,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../packages/sdk/kos-ui-sdk/src/ui/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,eAAe,CAAC;AACtD,cAAc,YAAY,CAAC;AAC3B,cAAc,+BAA+B,CAAC;AAC9C,cAAc,OAAO,CAAC;AACtB,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAC9D,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,SAAS,CAAC;AACxB,cAAc,yBAAyB,CAAC;AACxC,cAAc,WAAW,CAAC;AAC1B,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC"}
@@ -0,0 +1,44 @@
1
+ export type WarmupMarker = {
2
+ __warmup: true;
3
+ };
4
+ type Warmupable<T extends (arg?: any) => any> = (arg?: any | WarmupMarker) => ReturnType<T>;
5
+ /**
6
+ * A React hook that warms up a given function by invoking it during an idle period
7
+ * or after a short timeout. This is useful for preloading or preparing expensive
8
+ * computations or resources in advance.
9
+ *
10
+ * @template T - The type of the function to be warmed up. It must accept an optional
11
+ * argument and return any value.
12
+ *
13
+ * @param fn - The function to be warmed up. It should handle a special warmup argument
14
+ * (`{ __warmup: true }`) gracefully, as this argument is passed during the warmup phase.
15
+ *
16
+ * @remarks
17
+ * - If the browser supports `requestIdleCallback`, the warmup function will be invoked
18
+ * during an idle period. Otherwise, it will fall back to using `setTimeout` with a
19
+ * 1-millisecond delay.
20
+ * - Any errors thrown during the warmup invocation are caught and ignored to ensure
21
+ * that the warmup process does not disrupt the application.
22
+ *
23
+ * @example
24
+ * ```tsx
25
+ * import { useFunctionWarmup } from './use-function-warmup';
26
+ *
27
+ * const expensiveFunction = (options?: { __warmup?: boolean }) => {
28
+ * if (options?.__warmup) {
29
+ * console.log('Warming up...');
30
+ * } else {
31
+ * console.log('Executing expensive function...');
32
+ * }
33
+ * };
34
+ *
35
+ * function MyComponent() {
36
+ * useFunctionWarmup(expensiveFunction);
37
+ *
38
+ * return <div>My Component</div>;
39
+ * }
40
+ * ```
41
+ */
42
+ export declare function useFunctionWarmup<T extends (arg?: any) => any>(fn: Warmupable<T>): void;
43
+ export {};
44
+ //# sourceMappingURL=use-function-warmup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-function-warmup.d.ts","sourceRoot":"","sources":["../../../../../../packages/sdk/kos-ui-sdk/src/ui/hooks/use-function-warmup.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,YAAY,GAAG;IAAE,QAAQ,EAAE,IAAI,CAAA;CAAE,CAAC;AAG9C,KAAK,UAAU,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,GAAG,KAAK,GAAG,IAAI,CAC9C,GAAG,CAAC,EAAE,GAAG,GAAG,YAAY,KACrB,UAAU,CAAC,CAAC,CAAC,CAAC;AAEnB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,GAAG,KAAK,GAAG,EAC5D,EAAE,EAAE,UAAU,CAAC,CAAC,CAAC,QAiBlB"}