@lunora/react 1.0.0-alpha.24 → 1.0.0-alpha.240

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 (70) hide show
  1. package/README.md +25 -18
  2. package/dist/index.d.mts +1218 -358
  3. package/dist/index.d.ts +1218 -358
  4. package/dist/index.mjs +1 -19
  5. package/dist/packem_shared/AuthLoading-024-XH0I.mjs +2 -0
  6. package/dist/packem_shared/LunoraProvider-Cge6aAOa.mjs +1 -0
  7. package/dist/packem_shared/hydratePreloaded-qs8nspKB.mjs +2 -0
  8. package/dist/packem_shared/lunora-provider-_WqSuvf9.mjs +2 -0
  9. package/dist/packem_shared/lunoraQueryOptions-IJB_aFzi.mjs +1 -0
  10. package/dist/packem_shared/query-key-BysXrewF.mjs +1 -0
  11. package/dist/packem_shared/query-options.d-CdgGQ9s4.d.mts +38 -0
  12. package/dist/packem_shared/query-options.d-CdgGQ9s4.d.ts +38 -0
  13. package/dist/packem_shared/stream-state-abygFxmy.mjs +1 -0
  14. package/dist/packem_shared/use-paginated-core-Bf9xLRSk.mjs +2 -0
  15. package/dist/packem_shared/useAction-jJl4KPEw.mjs +2 -0
  16. package/dist/packem_shared/useAgent-C2jMXz2-.mjs +2 -0
  17. package/dist/packem_shared/useAgentChat-DiBCl0Rr.mjs +2 -0
  18. package/dist/packem_shared/useAgentState-CDAO3aLL.mjs +2 -0
  19. package/dist/packem_shared/useAgentToolEvents-Bb94yV7R.mjs +2 -0
  20. package/dist/packem_shared/useAuth-CpGKVRsv.mjs +2 -0
  21. package/dist/packem_shared/useAuthSessions-jJWdw8Zw.mjs +2 -0
  22. package/dist/packem_shared/useAuthState-CqN1F2FM.mjs +2 -0
  23. package/dist/packem_shared/useClientQuery-DUEUAqPh.mjs +2 -0
  24. package/dist/packem_shared/useConnectionStatus-Dtx_OWez.mjs +2 -0
  25. package/dist/packem_shared/useFlag-A7XPHExt.mjs +2 -0
  26. package/dist/packem_shared/useHttpStream-CzryjxVH.mjs +2 -0
  27. package/dist/packem_shared/useInfiniteQuery-D_AG59dX.mjs +2 -0
  28. package/dist/packem_shared/useMutation-Bz9uwvGf.mjs +2 -0
  29. package/dist/packem_shared/useMutator-BtUd-xEA.mjs +2 -0
  30. package/dist/packem_shared/usePaginatedQuery-DhQAsxgX.mjs +2 -0
  31. package/dist/packem_shared/usePresence-X5Ax04Cf.mjs +2 -0
  32. package/dist/packem_shared/useQuery-CETQat99.mjs +2 -0
  33. package/dist/packem_shared/useRateLimit-Cckxi8m9.mjs +2 -0
  34. package/dist/packem_shared/useStream-D8GB__4j.mjs +2 -0
  35. package/dist/packem_shared/useSubscription-CwZgOrE4.mjs +2 -0
  36. package/dist/packem_shared/useVoiceAgent-DAh27XxD.mjs +2 -0
  37. package/dist/payment.d.mts +105 -0
  38. package/dist/payment.d.ts +105 -0
  39. package/dist/payment.mjs +2 -0
  40. package/dist/server.d.mts +47 -29
  41. package/dist/server.d.ts +47 -29
  42. package/dist/server.mjs +1 -31
  43. package/dist/upload.d.mts +24 -0
  44. package/dist/upload.d.ts +24 -0
  45. package/dist/upload.mjs +2 -0
  46. package/package.json +14 -4
  47. package/dist/packem_shared/AuthLoading-DezUWNB2.mjs +0 -33
  48. package/dist/packem_shared/CheckoutButton-DUite8jJ.mjs +0 -189
  49. package/dist/packem_shared/LunoraProvider-BsuiW4Lk.mjs +0 -81
  50. package/dist/packem_shared/cache-D1O_xfAe.mjs +0 -80
  51. package/dist/packem_shared/hydratePreloaded-uMDH_xA9.mjs +0 -54
  52. package/dist/packem_shared/lunoraQueryOptions-C3uwOTMW.mjs +0 -16
  53. package/dist/packem_shared/query-key-BmCbgidV.mjs +0 -13
  54. package/dist/packem_shared/query-options.d-D4okOpO8.d.mts +0 -38
  55. package/dist/packem_shared/query-options.d-D4okOpO8.d.ts +0 -38
  56. package/dist/packem_shared/stable-key-CGp4e2Ux.mjs +0 -38
  57. package/dist/packem_shared/use-paginated-core-DafedU4l.mjs +0 -179
  58. package/dist/packem_shared/useAuth-BSutjJaa.mjs +0 -129
  59. package/dist/packem_shared/useAuthState-CyF35qZR.mjs +0 -36
  60. package/dist/packem_shared/useConnectionStatus-PJ7vyCHy.mjs +0 -30
  61. package/dist/packem_shared/useFlag-C2Pkghli.mjs +0 -128
  62. package/dist/packem_shared/useInfiniteQuery-BeaehE9f.mjs +0 -97
  63. package/dist/packem_shared/useMutation-BeqeIjTr.mjs +0 -67
  64. package/dist/packem_shared/useMutator-IIrLtDiM.mjs +0 -47
  65. package/dist/packem_shared/usePaginatedQuery-_6ETVUmf.mjs +0 -46
  66. package/dist/packem_shared/usePresence-Rnx1Fznc.mjs +0 -115
  67. package/dist/packem_shared/useQuery-D3_ZxMYs.mjs +0 -54
  68. package/dist/packem_shared/useRateLimit-DTEffQEi.mjs +0 -64
  69. package/dist/packem_shared/useStream-CGC26afa.mjs +0 -128
  70. package/dist/packem_shared/useSubscription-D38Jdyr8.mjs +0 -139
@@ -1,128 +0,0 @@
1
- 'use client';
2
- import { useState, useRef, useEffect } from 'react';
3
- import { useLunora } from './LunoraProvider-BsuiW4Lk.mjs';
4
- import { s as stableStringify } from './stable-key-CGp4e2Ux.mjs';
5
-
6
- const FLAGS_EVAL_PATH = "__lunora_flags__:eval";
7
- const flagKind = (value) => {
8
- const kind = typeof value;
9
- if (kind === "boolean" || kind === "number" || kind === "string") {
10
- return kind;
11
- }
12
- return "object";
13
- };
14
- const flagsReference = {
15
- __lunoraRef: FLAGS_EVAL_PATH
16
- };
17
- const useFlag = (key, defaultValue, context) => {
18
- const client = useLunora();
19
- const [value, setValue] = useState(defaultValue);
20
- const type = flagKind(defaultValue);
21
- const serializedContext = context === void 0 ? "" : stableStringify(context);
22
- const resetKey = `${key}::${type}::${serializedContext}`;
23
- const resetKeyRef = useRef(resetKey);
24
- if (resetKeyRef.current !== resetKey) {
25
- resetKeyRef.current = resetKey;
26
- setValue(defaultValue);
27
- }
28
- const latest = useRef({
29
- context,
30
- defaultValue
31
- });
32
- useEffect(() => {
33
- latest.current = {
34
- context,
35
- defaultValue
36
- };
37
- });
38
- useEffect(() => {
39
- let cancelled = false;
40
- const {
41
- context: currentContext,
42
- defaultValue: currentDefault
43
- } = latest.current;
44
- setValue(currentDefault);
45
- let unsubscribe;
46
- try {
47
- unsubscribe = client.subscribe(flagsReference, {
48
- context: currentContext,
49
- default: currentDefault,
50
- key,
51
- type
52
- }, (next) => {
53
- if (!cancelled) {
54
- setValue(next);
55
- }
56
- });
57
- } catch {
58
- return () => {
59
- cancelled = true;
60
- };
61
- }
62
- return () => {
63
- cancelled = true;
64
- unsubscribe();
65
- };
66
- }, [client, key, type, serializedContext]);
67
- return value;
68
- };
69
- const useFlags = (flags, context) => {
70
- const client = useLunora();
71
- const [values, setValues] = useState(flags);
72
- const spec = stableStringify(flags);
73
- const serializedContext = context === void 0 ? "" : stableStringify(context);
74
- const resetKey = `${spec}::${serializedContext}`;
75
- const resetKeyRef = useRef(resetKey);
76
- if (resetKeyRef.current !== resetKey) {
77
- resetKeyRef.current = resetKey;
78
- setValues(flags);
79
- }
80
- const latest = useRef({
81
- context,
82
- flags
83
- });
84
- useEffect(() => {
85
- latest.current = {
86
- context,
87
- flags
88
- };
89
- });
90
- useEffect(() => {
91
- let cancelled = false;
92
- const {
93
- context: currentContext,
94
- flags: currentFlags
95
- } = latest.current;
96
- setValues(currentFlags);
97
- const unsubscribes = [];
98
- for (const [key, defaultValue] of Object.entries(currentFlags)) {
99
- try {
100
- unsubscribes.push(client.subscribe(flagsReference, {
101
- context: currentContext,
102
- default: defaultValue,
103
- key,
104
- type: flagKind(defaultValue)
105
- }, (next) => {
106
- if (!cancelled) {
107
- setValues((previous) => {
108
- return {
109
- ...previous,
110
- [key]: next
111
- };
112
- });
113
- }
114
- }));
115
- } catch {
116
- }
117
- }
118
- return () => {
119
- cancelled = true;
120
- for (const unsubscribe of unsubscribes) {
121
- unsubscribe();
122
- }
123
- };
124
- }, [client, spec, serializedContext]);
125
- return values;
126
- };
127
-
128
- export { useFlag, useFlags };
@@ -1,97 +0,0 @@
1
- 'use client';
2
- import { c } from 'react/compiler-runtime';
3
- import { useRef, useEffect } from 'react';
4
- import { u as usePaginatedCore } from './use-paginated-core-DafedU4l.mjs';
5
-
6
- const useInfiniteQuery = (function_, args, options) => {
7
- const $ = c(15);
8
- const {
9
- initialNumItems
10
- } = options;
11
- const {
12
- loadMore,
13
- pageResults,
14
- status
15
- } = usePaginatedCore(function_, args === "skip" ? "skip" : args, options);
16
- const skipped = args === "skip";
17
- let resolvedPages;
18
- if ($[0] !== pageResults) {
19
- resolvedPages = [];
20
- for (const result of pageResults) {
21
- if (result) {
22
- resolvedPages.push(result.page);
23
- }
24
- }
25
- $[0] = pageResults;
26
- $[1] = resolvedPages;
27
- } else {
28
- resolvedPages = $[1];
29
- }
30
- let t0;
31
- if ($[2] !== initialNumItems || $[3] !== loadMore) {
32
- t0 = {
33
- defaultNumItems: initialNumItems,
34
- loadMore
35
- };
36
- $[2] = initialNumItems;
37
- $[3] = loadMore;
38
- $[4] = t0;
39
- } else {
40
- t0 = $[4];
41
- }
42
- const nextRef = useRef(t0);
43
- let t1;
44
- if ($[5] !== initialNumItems || $[6] !== loadMore) {
45
- t1 = () => {
46
- nextRef.current = {
47
- defaultNumItems: initialNumItems,
48
- loadMore
49
- };
50
- };
51
- $[5] = initialNumItems;
52
- $[6] = loadMore;
53
- $[7] = t1;
54
- } else {
55
- t1 = $[7];
56
- }
57
- useEffect(t1);
58
- let t2;
59
- if ($[8] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
60
- t2 = (numberItems) => {
61
- const {
62
- defaultNumItems,
63
- loadMore: load
64
- } = nextRef.current;
65
- load(numberItems ?? defaultNumItems);
66
- };
67
- $[8] = t2;
68
- } else {
69
- t2 = $[8];
70
- }
71
- const fetchNextPage = t2;
72
- const t3 = status === "CanLoadMore";
73
- const t4 = !skipped && status === "LoadingMore";
74
- const t5 = !skipped && status === "LoadingFirstPage";
75
- let t6;
76
- if ($[9] !== resolvedPages || $[10] !== status || $[11] !== t3 || $[12] !== t4 || $[13] !== t5) {
77
- t6 = {
78
- fetchNextPage,
79
- hasNextPage: t3,
80
- isFetchingNextPage: t4,
81
- isLoading: t5,
82
- pages: resolvedPages,
83
- status
84
- };
85
- $[9] = resolvedPages;
86
- $[10] = status;
87
- $[11] = t3;
88
- $[12] = t4;
89
- $[13] = t5;
90
- $[14] = t6;
91
- } else {
92
- t6 = $[14];
93
- }
94
- return t6;
95
- };
96
-
97
- export { useInfiniteQuery as default };
@@ -1,67 +0,0 @@
1
- 'use client';
2
- import { useMutation as useMutation$1 } from '@tanstack/react-query';
3
- import { useRef, useState, useCallback } from 'react';
4
- import { useLunora } from './LunoraProvider-BsuiW4Lk.mjs';
5
-
6
- const useMutation = (function_) => {
7
- const client = useLunora();
8
- const pendingCountRef = useRef(0);
9
- const [pending, setPending] = useState(false);
10
- const mutation = useMutation$1({
11
- mutationFn: ({
12
- args,
13
- options
14
- }) => client.mutation(function_, args, options),
15
- // `onMutate` fires when a call starts, `onSettled` when it resolves or
16
- // rejects — so overlapping calls compose and `pending` only clears once
17
- // the last one settles.
18
- onMutate: () => {
19
- pendingCountRef.current += 1;
20
- setPending(true);
21
- },
22
- onSettled: () => {
23
- pendingCountRef.current -= 1;
24
- setPending(pendingCountRef.current > 0);
25
- }
26
- });
27
- const {
28
- data,
29
- error,
30
- isError,
31
- mutateAsync,
32
- reset
33
- } = mutation;
34
- const mutate = useCallback((args_0, options_0) => mutateAsync({
35
- args: args_0,
36
- options: options_0
37
- }), [mutateAsync]);
38
- const withOptimisticUpdate = useCallback((update) => {
39
- const boundMutate = (args_1, options_1) => mutateAsync({
40
- args: args_1,
41
- options: {
42
- optimisticUpdate: update,
43
- ...options_1
44
- }
45
- });
46
- return {
47
- data,
48
- error,
49
- isError,
50
- mutate: boundMutate,
51
- pending,
52
- reset,
53
- withOptimisticUpdate
54
- };
55
- }, [mutateAsync, data, error, isError, pending, reset]);
56
- return {
57
- data,
58
- error,
59
- isError,
60
- mutate,
61
- pending,
62
- reset,
63
- withOptimisticUpdate
64
- };
65
- };
66
-
67
- export { useMutation };
@@ -1,47 +0,0 @@
1
- 'use client';
2
- import { c } from 'react/compiler-runtime';
3
- import { createMutatorRunner } from '@lunora/client';
4
- import { useState } from 'react';
5
-
6
- const useMutator = function useMutator2(handle) {
7
- const $ = c(8);
8
- const [pending, setPending] = useState(false);
9
- const [error, setError] = useState(void 0);
10
- let t0;
11
- if ($[0] !== handle) {
12
- t0 = createMutatorRunner(handle, {
13
- setError,
14
- setPending
15
- });
16
- $[0] = handle;
17
- $[1] = t0;
18
- } else {
19
- t0 = $[1];
20
- }
21
- const {
22
- mutate,
23
- reset
24
- } = t0;
25
- const t1 = error !== void 0;
26
- let t2;
27
- if ($[2] !== error || $[3] !== mutate || $[4] !== pending || $[5] !== reset || $[6] !== t1) {
28
- t2 = {
29
- error,
30
- isError: t1,
31
- mutate,
32
- pending,
33
- reset
34
- };
35
- $[2] = error;
36
- $[3] = mutate;
37
- $[4] = pending;
38
- $[5] = reset;
39
- $[6] = t1;
40
- $[7] = t2;
41
- } else {
42
- t2 = $[7];
43
- }
44
- return t2;
45
- };
46
-
47
- export { useMutator };
@@ -1,46 +0,0 @@
1
- 'use client';
2
- import { c } from 'react/compiler-runtime';
3
- import { u as usePaginatedCore } from './use-paginated-core-DafedU4l.mjs';
4
-
5
- const usePaginatedQuery = (function_, args, options) => {
6
- const $ = c(7);
7
- const {
8
- loadMore,
9
- pageResults,
10
- status
11
- } = usePaginatedCore(function_, args === "skip" ? "skip" : args, options);
12
- let results;
13
- if ($[0] !== pageResults) {
14
- results = [];
15
- for (const result of pageResults) {
16
- if (result) {
17
- results.push(...result.page);
18
- }
19
- }
20
- $[0] = pageResults;
21
- $[1] = results;
22
- } else {
23
- results = $[1];
24
- }
25
- const skipped = args === "skip";
26
- const t0 = !skipped && (status === "LoadingFirstPage" || status === "LoadingMore");
27
- let t1;
28
- if ($[2] !== loadMore || $[3] !== results || $[4] !== status || $[5] !== t0) {
29
- t1 = {
30
- isLoading: t0,
31
- loadMore,
32
- results,
33
- status
34
- };
35
- $[2] = loadMore;
36
- $[3] = results;
37
- $[4] = status;
38
- $[5] = t0;
39
- $[6] = t1;
40
- } else {
41
- t1 = $[6];
42
- }
43
- return t1;
44
- };
45
-
46
- export { usePaginatedQuery };
@@ -1,115 +0,0 @@
1
- 'use client';
2
- import { useMemo, useState, useRef, useEffect, useCallback } from 'react';
3
- import { useLunora } from './LunoraProvider-BsuiW4Lk.mjs';
4
-
5
- const randomSessionId = (prefix = "sess") => {
6
- if (typeof crypto !== "undefined") {
7
- if (typeof crypto.randomUUID === "function") {
8
- return crypto.randomUUID();
9
- }
10
- if (typeof crypto.getRandomValues === "function") {
11
- const bytes = crypto.getRandomValues(new Uint8Array(16));
12
- return `${prefix}-${Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join("")}`;
13
- }
14
- }
15
- return `${prefix}-${Date.now().toString(36)}`;
16
- };
17
-
18
- const DEFAULT_INTERVAL_MS = 1e4;
19
- const usePresence = (roomId, options) => {
20
- const client = useLunora();
21
- const {
22
- heartbeat,
23
- intervalMs = DEFAULT_INTERVAL_MS,
24
- listPresent,
25
- shardKey
26
- } = options;
27
- const generatedSessionId = useMemo(() => options.sessionId ?? randomSessionId(), [options.sessionId]);
28
- const [present, setPresent] = useState(void 0);
29
- const dataRef = useRef(options.data);
30
- const inputsRef = useRef({
31
- client,
32
- heartbeat,
33
- roomId,
34
- sessionId: generatedSessionId,
35
- shardKey
36
- });
37
- useEffect(() => {
38
- inputsRef.current = {
39
- client,
40
- heartbeat,
41
- roomId,
42
- sessionId: generatedSessionId,
43
- shardKey
44
- };
45
- });
46
- const sendHeartbeat = useCallback(() => {
47
- const {
48
- client: c,
49
- heartbeat: hb,
50
- roomId: room,
51
- sessionId: sid,
52
- shardKey: sk
53
- } = inputsRef.current;
54
- const args = {
55
- roomId: room,
56
- sessionId: sid,
57
- ...dataRef.current === void 0 ? {} : {
58
- data: dataRef.current
59
- }
60
- };
61
- c.mutation(hb, args, {
62
- shardKey: sk
63
- }).catch(() => void 0);
64
- }, []);
65
- const setData = useCallback((next) => {
66
- dataRef.current = next;
67
- sendHeartbeat();
68
- }, [sendHeartbeat]);
69
- useEffect(() => {
70
- sendHeartbeat();
71
- const handle = setInterval(sendHeartbeat, intervalMs);
72
- const onVisible = () => {
73
- if (document.visibilityState === "visible") {
74
- sendHeartbeat();
75
- }
76
- };
77
- document.addEventListener("visibilitychange", onVisible);
78
- return () => {
79
- clearInterval(handle);
80
- document.removeEventListener("visibilitychange", onVisible);
81
- };
82
- }, [sendHeartbeat, intervalMs]);
83
- useEffect(() => {
84
- const release = client.acquireConnectionContext({
85
- roomId,
86
- sessionId: generatedSessionId
87
- }, {
88
- shardKey
89
- });
90
- return release;
91
- }, [client, roomId, generatedSessionId, shardKey]);
92
- useEffect(() => {
93
- let cancelled = false;
94
- const unsubscribe = client.subscribe(listPresent, {
95
- roomId
96
- }, (value) => {
97
- if (!cancelled) {
98
- setPresent(value);
99
- }
100
- }, {
101
- shardKey
102
- });
103
- return () => {
104
- cancelled = true;
105
- unsubscribe();
106
- };
107
- }, [client, listPresent.__lunoraRef, roomId, shardKey]);
108
- return {
109
- present,
110
- sessionId: generatedSessionId,
111
- setData
112
- };
113
- };
114
-
115
- export { usePresence };
@@ -1,54 +0,0 @@
1
- 'use client';
2
- import { c } from 'react/compiler-runtime';
3
- import { useQueryClient, useQuery as useQuery$1 } from '@tanstack/react-query';
4
- import { useEffect } from 'react';
5
- import { g as getSubscriptionRegistry } from './cache-D1O_xfAe.mjs';
6
- import { useLunora } from './LunoraProvider-BsuiW4Lk.mjs';
7
- import { s as serializeQueryKey, l as lunoraQueryKey } from './query-key-BmCbgidV.mjs';
8
-
9
- const useQuery = (function_, args, t0) => {
10
- const $ = c(5);
11
- const options = t0 === void 0 ? {} : t0;
12
- const client = useLunora();
13
- const queryClient = useQueryClient();
14
- const {
15
- shardKey
16
- } = options;
17
- const skipped = args === "skip";
18
- const argsRecord = skipped ? {} : args;
19
- const queryKey = lunoraQueryKey(function_, argsRecord, shardKey);
20
- const {
21
- data
22
- } = useQuery$1({
23
- enabled: !skipped,
24
- queryFn: () => client.query(function_, argsRecord, {
25
- shardKey
26
- }),
27
- queryKey,
28
- staleTime: Number.POSITIVE_INFINITY
29
- });
30
- const t1 = serializeQueryKey(queryKey);
31
- let t2;
32
- if ($[0] !== client || $[1] !== queryClient || $[2] !== skipped || $[3] !== t1) {
33
- t2 = [client, queryClient, t1, skipped];
34
- $[0] = client;
35
- $[1] = queryClient;
36
- $[2] = skipped;
37
- $[3] = t1;
38
- $[4] = t2;
39
- } else {
40
- t2 = $[4];
41
- }
42
- useEffect(() => {
43
- if (skipped) {
44
- return _temp;
45
- }
46
- const registry = getSubscriptionRegistry(client);
47
- return registry.attach(queryClient, queryKey, function_, argsRecord, shardKey);
48
- }, t2);
49
- return skipped ? void 0 : data;
50
- };
51
- function _temp() {
52
- }
53
-
54
- export { useQuery as default };
@@ -1,64 +0,0 @@
1
- 'use client';
2
- import { evaluate } from '@lunora/ratelimit';
3
- import { useRef, useReducer, useCallback, useEffect } from 'react';
4
-
5
- const useRateLimit = (config, options = {}) => {
6
- const now = options.now ?? Date.now;
7
- const tickMs = options.tickMs ?? 1e3;
8
- const valueRef = useRef(void 0);
9
- const [, forceRender] = useReducer((count) => count + 1, 0);
10
- const consume = useCallback((count_0 = 1) => {
11
- const {
12
- status,
13
- value
14
- } = evaluate(config, valueRef.current, {
15
- consume: true,
16
- count: count_0,
17
- now: now(),
18
- reserve: false
19
- });
20
- if (value !== void 0) {
21
- valueRef.current = value;
22
- }
23
- forceRender();
24
- return status;
25
- }, [config, now]);
26
- const check = useCallback((count_1 = 1) => evaluate(config, valueRef.current, {
27
- consume: false,
28
- count: count_1,
29
- now: now(),
30
- reserve: false
31
- }).status.ok, [config, now]);
32
- const reset = useCallback(() => {
33
- valueRef.current = void 0;
34
- forceRender();
35
- }, []);
36
- const {
37
- status: status_0
38
- } = evaluate(config, valueRef.current, {
39
- consume: false,
40
- count: 1,
41
- now: now(),
42
- reserve: false
43
- });
44
- useEffect(() => {
45
- if (status_0.ok) {
46
- return () => {
47
- };
48
- }
49
- const handle = setInterval(forceRender, tickMs);
50
- return () => {
51
- clearInterval(handle);
52
- };
53
- }, [status_0.ok, tickMs]);
54
- return {
55
- check,
56
- consume,
57
- disabled: !status_0.ok,
58
- ok: status_0.ok,
59
- reset,
60
- retryAfter: status_0.retryAfter
61
- };
62
- };
63
-
64
- export { useRateLimit };