@lunora/react 1.0.0-alpha.31 → 1.0.0-alpha.33

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 (64) hide show
  1. package/dist/index.mjs +1 -28
  2. package/dist/packem_shared/AuthLoading-eLWn4Z7G.mjs +2 -0
  3. package/dist/packem_shared/CheckoutButton-DS_DKgNf.mjs +2 -0
  4. package/dist/packem_shared/LunoraProvider-InsjxtOB.mjs +2 -0
  5. package/dist/packem_shared/cache-odCgnNLz.mjs +1 -0
  6. package/dist/packem_shared/hydratePreloaded-DltXxPnp.mjs +2 -0
  7. package/dist/packem_shared/lunoraQueryOptions-BhiUY9ZF.mjs +1 -0
  8. package/dist/packem_shared/query-key-Y92N0Dci.mjs +1 -0
  9. package/dist/packem_shared/stable-key-BSG0zK_E.mjs +1 -0
  10. package/dist/packem_shared/use-paginated-core-DYjRFno_.mjs +2 -0
  11. package/dist/packem_shared/useAgent-DNKxqQ9F.mjs +2 -0
  12. package/dist/packem_shared/useAgentChat-BmYXshp0.mjs +2 -0
  13. package/dist/packem_shared/useAgentState-DO0yz6OU.mjs +2 -0
  14. package/dist/packem_shared/useAgentToolEvents-DTWZCIfd.mjs +2 -0
  15. package/dist/packem_shared/useAuth-CWkJn7i9.mjs +2 -0
  16. package/dist/packem_shared/useAuthState-jnCMkIwt.mjs +2 -0
  17. package/dist/packem_shared/useClientQuery-EPo__hzu.mjs +2 -0
  18. package/dist/packem_shared/useConnectionStatus-PL5D-S7t.mjs +2 -0
  19. package/dist/packem_shared/useFlag-Dh7bXXPx.mjs +2 -0
  20. package/dist/packem_shared/useHttpStream-DFswZrRk.mjs +2 -0
  21. package/dist/packem_shared/useInfiniteQuery-DyExohf2.mjs +2 -0
  22. package/dist/packem_shared/useMutation-B4uL3Rde.mjs +2 -0
  23. package/dist/packem_shared/useMutator-D3CGrk5-.mjs +2 -0
  24. package/dist/packem_shared/usePaginatedQuery-Roo_jyC9.mjs +2 -0
  25. package/dist/packem_shared/usePresence-SJBy81um.mjs +2 -0
  26. package/dist/packem_shared/useQuery-m-trnMUV.mjs +2 -0
  27. package/dist/packem_shared/useRateLimit-DqikMrX9.mjs +2 -0
  28. package/dist/packem_shared/useStream-CGcSWvPI.mjs +2 -0
  29. package/dist/packem_shared/useSubscription-CiQk8tFR.mjs +2 -0
  30. package/dist/packem_shared/useVoiceAgent-4gj2W2jc.mjs +2 -0
  31. package/dist/packem_shared/wire-key-8Ju6XYoB.mjs +1 -0
  32. package/dist/server.mjs +1 -31
  33. package/dist/upload.mjs +1 -2
  34. package/package.json +4 -4
  35. package/dist/packem_shared/AuthLoading-DezUWNB2.mjs +0 -33
  36. package/dist/packem_shared/CheckoutButton-DUite8jJ.mjs +0 -189
  37. package/dist/packem_shared/LunoraProvider-BsuiW4Lk.mjs +0 -81
  38. package/dist/packem_shared/cache-JeuDAXfE.mjs +0 -80
  39. package/dist/packem_shared/hydratePreloaded-2omLtadR.mjs +0 -54
  40. package/dist/packem_shared/lunoraQueryOptions-CefbPBId.mjs +0 -16
  41. package/dist/packem_shared/query-key-LGnArBTB.mjs +0 -13
  42. package/dist/packem_shared/stable-key-DePnevIy.mjs +0 -38
  43. package/dist/packem_shared/use-paginated-core-xxvd1YA0.mjs +0 -179
  44. package/dist/packem_shared/useAgent-BNLlIYHz.mjs +0 -101
  45. package/dist/packem_shared/useAgentChat-0cebQe7-.mjs +0 -304
  46. package/dist/packem_shared/useAgentState-Cqyd3Dfy.mjs +0 -37
  47. package/dist/packem_shared/useAgentToolEvents-gF7U4_KY.mjs +0 -129
  48. package/dist/packem_shared/useAuth-BSutjJaa.mjs +0 -129
  49. package/dist/packem_shared/useAuthState-CyF35qZR.mjs +0 -36
  50. package/dist/packem_shared/useClientQuery-DIkNT4QA.mjs +0 -17
  51. package/dist/packem_shared/useConnectionStatus-PJ7vyCHy.mjs +0 -30
  52. package/dist/packem_shared/useFlag-Beyeiq2b.mjs +0 -128
  53. package/dist/packem_shared/useHttpStream-oc4s1pMy.mjs +0 -127
  54. package/dist/packem_shared/useInfiniteQuery-CJNw1XaZ.mjs +0 -97
  55. package/dist/packem_shared/useMutation-BeqeIjTr.mjs +0 -67
  56. package/dist/packem_shared/useMutator-IIrLtDiM.mjs +0 -47
  57. package/dist/packem_shared/usePaginatedQuery-DWzydaVR.mjs +0 -46
  58. package/dist/packem_shared/usePresence-Rnx1Fznc.mjs +0 -115
  59. package/dist/packem_shared/useQuery-CE8_QUgh.mjs +0 -77
  60. package/dist/packem_shared/useRateLimit-DTEffQEi.mjs +0 -64
  61. package/dist/packem_shared/useStream-GYNgc9J5.mjs +0 -128
  62. package/dist/packem_shared/useSubscription-DcDlvVuI.mjs +0 -139
  63. package/dist/packem_shared/useVoiceAgent-w7fzAMSB.mjs +0 -422
  64. package/dist/packem_shared/wire-key-Bg8BJ8YM.mjs +0 -101
@@ -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 };
@@ -1,128 +0,0 @@
1
- 'use client';
2
- import { useReducer, useRef, useEffect } from 'react';
3
- import { useLunora } from './LunoraProvider-BsuiW4Lk.mjs';
4
- import { s as stableWireKey } from './wire-key-Bg8BJ8YM.mjs';
5
-
6
- const reducer = function(state, action) {
7
- switch (action.type) {
8
- case "chunk": {
9
- return {
10
- chunks: [...state.chunks, action.chunk],
11
- error: void 0,
12
- status: "streaming"
13
- };
14
- }
15
- case "complete": {
16
- return {
17
- ...state,
18
- status: "complete"
19
- };
20
- }
21
- case "error": {
22
- return {
23
- ...state,
24
- error: action.error,
25
- status: "error"
26
- };
27
- }
28
- case "reset": {
29
- return {
30
- chunks: [],
31
- error: void 0,
32
- status: "idle"
33
- };
34
- }
35
- case "start": {
36
- return {
37
- ...state,
38
- status: "streaming"
39
- };
40
- }
41
- default: {
42
- return state;
43
- }
44
- }
45
- };
46
- const useStream = (function_, args, options = {}) => {
47
- const client = useLunora();
48
- const [state, dispatch] = useReducer(reducer, {
49
- chunks: [],
50
- error: void 0,
51
- status: "idle"
52
- });
53
- const skipped = args === "skip";
54
- const serialized = skipped ? "skip" : stableWireKey(args);
55
- const cancelRef = useRef(void 0);
56
- useEffect(() => {
57
- if (skipped) {
58
- dispatch({
59
- type: "reset"
60
- });
61
- return () => {
62
- };
63
- }
64
- dispatch({
65
- type: "reset"
66
- });
67
- dispatch({
68
- type: "start"
69
- });
70
- let stillMounted = true;
71
- let cancelled = false;
72
- const iterable = client.stream(function_, args, {
73
- maxBuffer: options.maxBuffer,
74
- shardKey: options.shardKey
75
- });
76
- const cancel = () => {
77
- if (cancelled) {
78
- return;
79
- }
80
- cancelled = true;
81
- iterable.cancel();
82
- };
83
- cancelRef.current = cancel;
84
- (async () => {
85
- try {
86
- for await (const chunk of iterable) {
87
- if (!stillMounted) {
88
- return;
89
- }
90
- dispatch({
91
- chunk,
92
- type: "chunk"
93
- });
94
- }
95
- if (stillMounted) {
96
- dispatch({
97
- type: "complete"
98
- });
99
- }
100
- } catch (error) {
101
- if (!stillMounted) {
102
- return;
103
- }
104
- const normalized = error instanceof Error ? error : new Error(String(error));
105
- dispatch({
106
- error: normalized,
107
- type: "error"
108
- });
109
- }
110
- })().catch(() => {
111
- });
112
- return () => {
113
- stillMounted = false;
114
- cancel();
115
- cancelRef.current = void 0;
116
- };
117
- }, [client, function_.__lunoraRef, serialized, skipped, options.shardKey, options.maxBuffer]);
118
- return {
119
- cancel: () => {
120
- cancelRef.current?.();
121
- },
122
- chunks: state.chunks,
123
- error: state.error,
124
- status: state.status
125
- };
126
- };
127
-
128
- export { useStream };
@@ -1,139 +0,0 @@
1
- 'use client';
2
- import { c } from 'react/compiler-runtime';
3
- import { createQuerySubscription } from '@lunora/client/query';
4
- import { useState, useRef, useEffect } from 'react';
5
- import { useLunora } from './LunoraProvider-BsuiW4Lk.mjs';
6
- import { s as stableWireKey } from './wire-key-Bg8BJ8YM.mjs';
7
-
8
- const useSubscription = (function_, args, t0) => {
9
- const $ = c(22);
10
- let t1;
11
- if ($[0] !== t0) {
12
- t1 = t0 === void 0 ? {} : t0;
13
- $[0] = t0;
14
- $[1] = t1;
15
- } else {
16
- t1 = $[1];
17
- }
18
- const options = t1;
19
- const client = useLunora();
20
- let t2;
21
- if ($[2] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
22
- t2 = {
23
- data: void 0,
24
- error: void 0
25
- };
26
- $[2] = t2;
27
- } else {
28
- t2 = $[2];
29
- }
30
- const [state, setState] = useState(t2);
31
- const skipped = args === "skip";
32
- let t3;
33
- if ($[3] !== args || $[4] !== skipped) {
34
- t3 = skipped ? "skip" : stableWireKey(args);
35
- $[3] = args;
36
- $[4] = skipped;
37
- $[5] = t3;
38
- } else {
39
- t3 = $[5];
40
- }
41
- const serialized = t3;
42
- let t4;
43
- if ($[6] !== args || $[7] !== function_) {
44
- t4 = {
45
- args,
46
- fn: function_
47
- };
48
- $[6] = args;
49
- $[7] = function_;
50
- $[8] = t4;
51
- } else {
52
- t4 = $[8];
53
- }
54
- const subscribeRef = useRef(t4);
55
- let t5;
56
- if ($[9] !== args || $[10] !== function_) {
57
- t5 = () => {
58
- subscribeRef.current = {
59
- args,
60
- fn: function_
61
- };
62
- };
63
- $[9] = args;
64
- $[10] = function_;
65
- $[11] = t5;
66
- } else {
67
- t5 = $[11];
68
- }
69
- useEffect(t5);
70
- let t6;
71
- if ($[12] !== client || $[13] !== options.shardKey || $[14] !== skipped) {
72
- t6 = () => {
73
- if (skipped) {
74
- setState({
75
- data: void 0,
76
- error: void 0
77
- });
78
- return _temp;
79
- }
80
- let cancelled = false;
81
- const {
82
- args: currentArgs,
83
- fn: currentFunction
84
- } = subscribeRef.current;
85
- const unsubscribe = createQuerySubscription(client, currentFunction, currentArgs, {
86
- onData: (value) => {
87
- if (cancelled) {
88
- return;
89
- }
90
- setState({
91
- data: value,
92
- error: void 0
93
- });
94
- },
95
- onError: (error) => {
96
- const normalized = new Error(error.message);
97
- queueMicrotask(() => {
98
- if (!cancelled) {
99
- setState({
100
- data: void 0,
101
- error: normalized
102
- });
103
- }
104
- });
105
- }
106
- }, {
107
- shardKey: options.shardKey
108
- });
109
- return () => {
110
- cancelled = true;
111
- unsubscribe();
112
- };
113
- };
114
- $[12] = client;
115
- $[13] = options.shardKey;
116
- $[14] = skipped;
117
- $[15] = t6;
118
- } else {
119
- t6 = $[15];
120
- }
121
- let t7;
122
- if ($[16] !== client || $[17] !== function_.__lunoraRef || $[18] !== options.shardKey || $[19] !== serialized || $[20] !== skipped) {
123
- t7 = [client, function_.__lunoraRef, serialized, options.shardKey, skipped];
124
- $[16] = client;
125
- $[17] = function_.__lunoraRef;
126
- $[18] = options.shardKey;
127
- $[19] = serialized;
128
- $[20] = skipped;
129
- $[21] = t7;
130
- } else {
131
- t7 = $[21];
132
- }
133
- useEffect(t6, t7);
134
- return state;
135
- };
136
- function _temp() {
137
- }
138
-
139
- export { useSubscription as default };