@tangle-network/ui 11.9.0 → 11.11.0

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 (155) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/README.md +14 -0
  3. package/dist/active-sessions-store-Gt1R0rFG.js +262 -0
  4. package/dist/{active-sessions-store-CeOmXgv5.d.ts → active-sessions-store-nl70ZnMC.d.ts} +40 -41
  5. package/dist/artifact-pane-BL_DFWNl.d.ts +32 -0
  6. package/dist/artifact-pane-DMXT9a8U.js +70 -0
  7. package/dist/auth-DixfCMCk.js +154 -0
  8. package/dist/auth.d.ts +2 -74
  9. package/dist/auth.js +2 -15
  10. package/dist/branding-26d5ARIr.d.ts +14 -0
  11. package/dist/button-uhNnwdsD.js +78 -0
  12. package/dist/button-yoIv77e2.d.ts +16 -0
  13. package/dist/chat-CPLL0Fd9.js +667 -0
  14. package/dist/chat.d.ts +2 -201
  15. package/dist/chat.js +2 -30
  16. package/dist/code-block-B9miUPht.d.ts +23 -0
  17. package/dist/code-block-CngSn37j.js +165 -0
  18. package/dist/diff-preview-cySuqowW.js +533 -0
  19. package/dist/document-editor-pane-BcoABlhn.d.ts +131 -0
  20. package/dist/document-editor-pane-Cz6oEF1o.js +1287 -0
  21. package/dist/dropdown-menu-BpcLa5vF.js +101 -0
  22. package/dist/editor.d.ts +76 -78
  23. package/dist/editor.js +2 -33
  24. package/dist/file-format-BgXbr-Ib.js +160 -0
  25. package/dist/files-CYlOo0mE.js +743 -0
  26. package/dist/files.d.ts +2 -243
  27. package/dist/files.js +3 -40
  28. package/dist/focus-Cw02pNSr.js +56 -0
  29. package/dist/format-DfcLWqMa.js +54 -0
  30. package/dist/hooks.d.ts +30 -37
  31. package/dist/hooks.js +111 -45
  32. package/dist/index-2UntyjBb.d.ts +52 -0
  33. package/dist/index-COgqsFAQ.d.ts +42 -0
  34. package/dist/index-CPDET_s1.d.ts +549 -0
  35. package/dist/index-CUhfHT_V.d.ts +204 -0
  36. package/dist/index-Cg6gYAqh.d.ts +73 -0
  37. package/dist/index-Cq-EJzqW.d.ts +16 -0
  38. package/dist/index-DhYmSaLF.d.ts +245 -0
  39. package/dist/index-DjKxO357.d.ts +128 -0
  40. package/dist/index-b56ew9aF.d.ts +107 -0
  41. package/dist/index.d.ts +26 -43
  42. package/dist/index.js +35 -460
  43. package/dist/markdown-BprL96Gl.js +45 -0
  44. package/dist/markdown.d.ts +3 -18
  45. package/dist/markdown.js +3 -14
  46. package/dist/message-vhUI0c5G.d.ts +16 -0
  47. package/dist/nav.d.ts +6 -8
  48. package/dist/nav.js +29 -11
  49. package/dist/openui-artifact-renderer-D3E5bIAI.d.ts +114 -0
  50. package/dist/openui-artifact-renderer-DT4xbvWt.js +266 -0
  51. package/dist/openui.d.ts +2 -115
  52. package/dist/openui.js +2 -12
  53. package/dist/parts-5mhy9yJ3.d.ts +37 -0
  54. package/dist/primitives-DE-blUz-.js +1239 -0
  55. package/dist/primitives.d.ts +5 -523
  56. package/dist/primitives.js +9 -211
  57. package/dist/redaction-CGGB2ENG.js +74 -0
  58. package/dist/redaction.d.ts +2 -42
  59. package/dist/redaction.js +2 -7
  60. package/dist/run-OyWmIDqu.d.ts +41 -0
  61. package/dist/run-ZsIKPA6J.js +17 -0
  62. package/dist/run-group-D1InSdQu.js +410 -0
  63. package/dist/run.d.ts +3 -126
  64. package/dist/run.js +5 -39
  65. package/dist/sdk-hooks.d.ts +2 -285
  66. package/dist/sdk-hooks.js +3 -35
  67. package/dist/stores.d.ts +13 -14
  68. package/dist/stores.js +34 -76
  69. package/dist/table-DHyqDPbU.js +146 -0
  70. package/dist/tabs-ujuqAdtb.js +40 -0
  71. package/dist/text-shimmer-BUUo6I-g.js +64 -0
  72. package/dist/tool-call-feed-BeB1_4pX.d.ts +47 -0
  73. package/dist/tool-call-feed-C1W1N54c.js +109 -0
  74. package/dist/tool-call-step-Bi3_YJRV.js +434 -0
  75. package/dist/tool-display-BAuAVa43.js +158 -0
  76. package/dist/{tool-display-z4JcDmMQ.d.ts → tool-display-DgmL5rIU.d.ts} +16 -16
  77. package/dist/tool-previews.d.ts +2 -48
  78. package/dist/tool-previews.js +2 -22
  79. package/dist/types.d.ts +6 -19
  80. package/dist/types.js +0 -1
  81. package/dist/use-auto-scroll-C5Pjeqon.js +153 -0
  82. package/dist/use-sse-stream-BjVBDbxK.js +884 -0
  83. package/dist/use-sse-stream-Dm6R5YWz.d.ts +282 -0
  84. package/dist/utils-Bl_CZ0Qp.js +37 -0
  85. package/dist/{chunk-RQHJBTEU.js → utils-C_uf36nf.js} +4 -6
  86. package/dist/utils.d.ts +2 -51
  87. package/dist/utils.js +6 -32
  88. package/package.json +39 -41
  89. package/src/auth/auth.tsx +5 -1
  90. package/src/chat/agent-timeline.tsx +6 -1
  91. package/src/chat/chat-container.tsx +2 -1
  92. package/src/editor/document-editor-pane.test.tsx +3 -1
  93. package/src/editor/document-editor-pane.tsx +5 -1
  94. package/src/editor/markdown-document-editor.test.tsx +9 -4
  95. package/src/files/file-artifact-pane.tsx +3 -2
  96. package/src/files/file-preview.tsx +3 -1
  97. package/src/files/file-tabs.tsx +9 -2
  98. package/src/lib/focus.ts +63 -0
  99. package/src/markdown/code-block.tsx +5 -1
  100. package/src/primitives/badge.tsx +2 -1
  101. package/src/primitives/button.tsx +2 -1
  102. package/src/primitives/card.tsx +1 -2
  103. package/src/primitives/dialog.tsx +7 -1
  104. package/src/primitives/input.tsx +15 -14
  105. package/src/primitives/segmented-control.tsx +5 -3
  106. package/src/primitives/select.tsx +3 -1
  107. package/src/primitives/switch.tsx +3 -1
  108. package/src/primitives/tabs.tsx +6 -4
  109. package/src/primitives/terminal-display.tsx +6 -8
  110. package/src/primitives/toast.tsx +5 -1
  111. package/src/tool-previews/command-preview.tsx +5 -1
  112. package/src/tool-previews/web-search-preview.tsx +2 -1
  113. package/src/utils/index.ts +7 -0
  114. package/dist/artifact-pane-DpuWcAiF.d.ts +0 -33
  115. package/dist/button-CMQuQEW_.d.ts +0 -17
  116. package/dist/chunk-34A66VBG.js +0 -214
  117. package/dist/chunk-3OI2QKFD.js +0 -0
  118. package/dist/chunk-3TI5DEHV.js +0 -299
  119. package/dist/chunk-4CLN43XT.js +0 -45
  120. package/dist/chunk-565EATZZ.js +0 -156
  121. package/dist/chunk-5Z5ZYMOJ.js +0 -0
  122. package/dist/chunk-6BGQA4BQ.js +0 -0
  123. package/dist/chunk-7YOCS6IF.js +0 -728
  124. package/dist/chunk-EOAX2ENE.js +0 -60
  125. package/dist/chunk-GYPQXTJU.js +0 -230
  126. package/dist/chunk-HFL6R6IF.js +0 -37
  127. package/dist/chunk-HGML45QH.js +0 -104
  128. package/dist/chunk-KNYSKNZX.js +0 -550
  129. package/dist/chunk-L57WRIND.js +0 -59
  130. package/dist/chunk-LDLOJKPC.js +0 -1585
  131. package/dist/chunk-LTEKI7YJ.js +0 -59
  132. package/dist/chunk-MKTSMWVD.js +0 -109
  133. package/dist/chunk-ND3ZFXQK.js +0 -179
  134. package/dist/chunk-NKDZ7GZE.js +0 -192
  135. package/dist/chunk-NWECTSOH.js +0 -589
  136. package/dist/chunk-OEX7NZE3.js +0 -321
  137. package/dist/chunk-Q56BYXQF.js +0 -61
  138. package/dist/chunk-REJESC5U.js +0 -117
  139. package/dist/chunk-RQGKSCEZ.js +0 -0
  140. package/dist/chunk-TN4FUEWY.js +0 -437
  141. package/dist/chunk-VPWY4I5O.js +0 -1048
  142. package/dist/chunk-WUQDUBJG.js +0 -168
  143. package/dist/chunk-XGKULLYE.js +0 -40
  144. package/dist/chunk-XU3HB5QL.js +0 -127
  145. package/dist/chunk-XYAIX4SU.js +0 -133
  146. package/dist/chunk-YJ6RE5WV.js +0 -875
  147. package/dist/chunk-YTO5V6QS.js +0 -19
  148. package/dist/chunk-ZKCEAIIZ.js +0 -1395
  149. package/dist/code-block-0kSpWMnf.d.ts +0 -25
  150. package/dist/document-editor-pane-EX25CEYW.js +0 -12
  151. package/dist/document-editor-pane-IAEQn_Dl.d.ts +0 -128
  152. package/dist/message-BHWbxBtT.d.ts +0 -15
  153. package/dist/parts-dj7AcUg0.d.ts +0 -36
  154. package/dist/run-PfLmDAox.d.ts +0 -41
  155. package/dist/tool-call-feed-D9iofJgW.d.ts +0 -46
@@ -1,321 +0,0 @@
1
- // src/stores/active-sessions-store.ts
2
- import { useStore } from "@nanostores/react";
3
- import { atom } from "nanostores";
4
- import { useMemo } from "react";
5
- var INITIAL_STATE = {
6
- sessions: {},
7
- lastUpdatedAt: 0
8
- };
9
- var STATUS_PRIORITY = {
10
- running: 0,
11
- error: 1,
12
- "attention-needed": 2,
13
- idle: 3
14
- };
15
- var DEFAULT_RECORD = {
16
- status: "idle",
17
- isRunning: false,
18
- isForeground: false,
19
- needsAttention: false,
20
- connectionState: "disconnected",
21
- reconnectState: "idle",
22
- transportMode: null,
23
- lastError: null,
24
- lastEventAt: null
25
- };
26
- var activeSessionsAtom = atom(INITIAL_STATE);
27
- var foregroundSessionId = null;
28
- function createRecord(options, now) {
29
- return {
30
- sessionId: options.sessionId,
31
- projectId: options.projectId ?? null,
32
- projectLabel: options.projectLabel,
33
- title: options.title,
34
- href: options.href,
35
- registeredAt: now,
36
- lastActivityAt: now,
37
- metadata: options.metadata,
38
- ...DEFAULT_RECORD,
39
- isForeground: options.sessionId === foregroundSessionId
40
- };
41
- }
42
- function resolveStatus(session) {
43
- if (session.isRunning) return "running";
44
- if (session.lastError || session.reconnectState === "failed") return "error";
45
- if (session.needsAttention) return "attention-needed";
46
- return "idle";
47
- }
48
- function normalizeSession(session) {
49
- return {
50
- ...session,
51
- status: resolveStatus(session)
52
- };
53
- }
54
- function updateSession(sessionId, updater) {
55
- const current = activeSessionsAtom.get();
56
- const existing = current.sessions[sessionId];
57
- if (!existing) return;
58
- const now = Date.now();
59
- activeSessionsAtom.set({
60
- sessions: {
61
- ...current.sessions,
62
- [sessionId]: normalizeSession(updater(existing, now))
63
- },
64
- lastUpdatedAt: now
65
- });
66
- }
67
- function registerActiveSession(options) {
68
- const now = Date.now();
69
- const current = activeSessionsAtom.get();
70
- const existing = current.sessions[options.sessionId];
71
- activeSessionsAtom.set({
72
- sessions: {
73
- ...current.sessions,
74
- [options.sessionId]: normalizeSession(
75
- existing ? {
76
- ...existing,
77
- projectId: existing.projectId ?? options.projectId ?? null,
78
- projectLabel: options.projectLabel ?? existing.projectLabel,
79
- title: options.title ?? existing.title,
80
- href: options.href ?? existing.href,
81
- metadata: options.metadata ?? existing.metadata,
82
- lastActivityAt: now,
83
- isForeground: options.sessionId === foregroundSessionId || existing.isForeground
84
- } : createRecord(options, now)
85
- )
86
- },
87
- lastUpdatedAt: now
88
- });
89
- }
90
- function unregisterActiveSession(sessionId) {
91
- const current = activeSessionsAtom.get();
92
- if (!current.sessions[sessionId]) return;
93
- const { [sessionId]: _removed, ...remaining } = current.sessions;
94
- if (foregroundSessionId === sessionId) {
95
- foregroundSessionId = null;
96
- }
97
- activeSessionsAtom.set({
98
- sessions: remaining,
99
- lastUpdatedAt: Date.now()
100
- });
101
- }
102
- function setForegroundActiveSession(sessionId) {
103
- foregroundSessionId = sessionId;
104
- const current = activeSessionsAtom.get();
105
- const now = Date.now();
106
- let changed = false;
107
- const sessions = Object.fromEntries(
108
- Object.entries(current.sessions).map(([id, session]) => {
109
- const isForeground = id === sessionId;
110
- if (session.isForeground !== isForeground) {
111
- changed = true;
112
- }
113
- return [
114
- id,
115
- {
116
- ...session,
117
- isForeground,
118
- lastActivityAt: isForeground ? now : session.lastActivityAt
119
- }
120
- ];
121
- })
122
- );
123
- if (!changed) return;
124
- activeSessionsAtom.set({
125
- sessions,
126
- lastUpdatedAt: now
127
- });
128
- }
129
- function updateActiveSessionMeta(sessionId, meta) {
130
- updateSession(sessionId, (session, now) => ({
131
- ...session,
132
- ...meta,
133
- lastActivityAt: now
134
- }));
135
- }
136
- function setActiveSessionConnection(sessionId, options) {
137
- updateSession(sessionId, (session, now) => ({
138
- ...session,
139
- connectionState: options.connectionState,
140
- reconnectState: options.reconnectState ?? session.reconnectState,
141
- transportMode: options.transportMode ?? session.transportMode,
142
- lastError: options.lastError === void 0 ? session.lastError : options.lastError,
143
- lastEventAt: options.lastEventAt ?? session.lastEventAt,
144
- lastActivityAt: now
145
- }));
146
- }
147
- function setActiveSessionRunning(sessionId, isRunning, options) {
148
- updateSession(sessionId, (session, now) => ({
149
- ...session,
150
- isRunning,
151
- needsAttention: isRunning ? false : session.needsAttention,
152
- lastError: isRunning ? null : session.lastError,
153
- lastEventAt: options?.lastEventAt ?? session.lastEventAt,
154
- lastActivityAt: now
155
- }));
156
- }
157
- function setActiveSessionAttention(sessionId, needsAttention, options) {
158
- updateSession(sessionId, (session, now) => ({
159
- ...session,
160
- needsAttention,
161
- isRunning: needsAttention ? false : session.isRunning,
162
- lastEventAt: options?.lastEventAt ?? session.lastEventAt,
163
- lastActivityAt: now
164
- }));
165
- }
166
- function setActiveSessionError(sessionId, error) {
167
- updateSession(sessionId, (session, now) => ({
168
- ...session,
169
- isRunning: false,
170
- needsAttention: false,
171
- lastError: error,
172
- reconnectState: error ? "failed" : "idle",
173
- connectionState: error ? "error" : session.connectionState,
174
- lastEventAt: now,
175
- lastActivityAt: now
176
- }));
177
- }
178
- function bumpActiveSessionActivity(sessionId, options) {
179
- updateSession(sessionId, (session, now) => ({
180
- ...session,
181
- lastEventAt: options?.lastEventAt ?? session.lastEventAt ?? now,
182
- lastActivityAt: now
183
- }));
184
- }
185
- function resetActiveSessions() {
186
- foregroundSessionId = null;
187
- activeSessionsAtom.set(INITIAL_STATE);
188
- }
189
- function getAllActiveSessions(state) {
190
- return Object.values(state.sessions);
191
- }
192
- function getActiveSession(state, sessionId) {
193
- return state.sessions[sessionId] ?? null;
194
- }
195
- function getSessionsForProject(state, projectId) {
196
- return Object.values(state.sessions).filter((session) => session.projectId === projectId);
197
- }
198
- function getSessionsForNavbar(state, projectId) {
199
- const sessions = projectId == null ? Object.values(state.sessions) : getSessionsForProject(state, projectId);
200
- return [...sessions].sort((left, right) => {
201
- if (left.isForeground !== right.isForeground) {
202
- return Number(right.isForeground) - Number(left.isForeground);
203
- }
204
- const statusDiff = STATUS_PRIORITY[left.status] - STATUS_PRIORITY[right.status];
205
- if (statusDiff !== 0) {
206
- return statusDiff;
207
- }
208
- return right.lastActivityAt - left.lastActivityAt;
209
- });
210
- }
211
- function getSessionsByActivity(state) {
212
- return [...Object.values(state.sessions)].sort(
213
- (left, right) => right.lastActivityAt - left.lastActivityAt
214
- );
215
- }
216
- function getTotalRunningSessionCount(state) {
217
- return Object.values(state.sessions).filter((session) => session.isRunning).length;
218
- }
219
- function hasBackgroundRunningSessions(state) {
220
- return Object.values(state.sessions).some(
221
- (session) => session.isRunning && !session.isForeground
222
- );
223
- }
224
- function getAllProjectActivity(state) {
225
- const grouped = /* @__PURE__ */ new Map();
226
- for (const session of Object.values(state.sessions)) {
227
- if (session.projectId == null) continue;
228
- const existing = grouped.get(session.projectId);
229
- if (existing) {
230
- existing.activeSessionCount += 1;
231
- existing.lastActivityAt = Math.max(existing.lastActivityAt, session.lastActivityAt);
232
- if (session.isRunning) {
233
- existing.runningSessionIds.push(session.sessionId);
234
- }
235
- if (!existing.projectLabel && session.projectLabel) {
236
- existing.projectLabel = session.projectLabel;
237
- }
238
- continue;
239
- }
240
- grouped.set(session.projectId, {
241
- projectId: session.projectId,
242
- projectLabel: session.projectLabel,
243
- activeSessionCount: 1,
244
- runningSessionIds: session.isRunning ? [session.sessionId] : [],
245
- lastActivityAt: session.lastActivityAt
246
- });
247
- }
248
- return [...grouped.values()].sort((left, right) => right.lastActivityAt - left.lastActivityAt);
249
- }
250
- function useActiveSessionsState() {
251
- return useStore(activeSessionsAtom);
252
- }
253
- function useActiveSessions() {
254
- const state = useStore(activeSessionsAtom);
255
- return useMemo(() => getAllActiveSessions(state), [state]);
256
- }
257
- function useActiveSession(sessionId) {
258
- const state = useStore(activeSessionsAtom);
259
- return useMemo(
260
- () => sessionId ? getActiveSession(state, sessionId) : null,
261
- [sessionId, state]
262
- );
263
- }
264
- function useProjectSessions(projectId) {
265
- const state = useStore(activeSessionsAtom);
266
- return useMemo(
267
- () => projectId == null ? [] : getSessionsForProject(state, projectId),
268
- [projectId, state]
269
- );
270
- }
271
- function useNavbarSessions(projectId) {
272
- const state = useStore(activeSessionsAtom);
273
- return useMemo(() => getSessionsForNavbar(state, projectId), [projectId, state]);
274
- }
275
- function useSessionsByActivity() {
276
- const state = useStore(activeSessionsAtom);
277
- return useMemo(() => getSessionsByActivity(state), [state]);
278
- }
279
- function useProjectActivity() {
280
- const state = useStore(activeSessionsAtom);
281
- return useMemo(() => getAllProjectActivity(state), [state]);
282
- }
283
- function useTotalRunningSessions() {
284
- const state = useStore(activeSessionsAtom);
285
- return useMemo(() => getTotalRunningSessionCount(state), [state]);
286
- }
287
- function useHasBackgroundRunningSessions() {
288
- const state = useStore(activeSessionsAtom);
289
- return useMemo(() => hasBackgroundRunningSessions(state), [state]);
290
- }
291
-
292
- export {
293
- activeSessionsAtom,
294
- registerActiveSession,
295
- unregisterActiveSession,
296
- setForegroundActiveSession,
297
- updateActiveSessionMeta,
298
- setActiveSessionConnection,
299
- setActiveSessionRunning,
300
- setActiveSessionAttention,
301
- setActiveSessionError,
302
- bumpActiveSessionActivity,
303
- resetActiveSessions,
304
- getAllActiveSessions,
305
- getActiveSession,
306
- getSessionsForProject,
307
- getSessionsForNavbar,
308
- getSessionsByActivity,
309
- getTotalRunningSessionCount,
310
- hasBackgroundRunningSessions,
311
- getAllProjectActivity,
312
- useActiveSessionsState,
313
- useActiveSessions,
314
- useActiveSession,
315
- useProjectSessions,
316
- useNavbarSessions,
317
- useSessionsByActivity,
318
- useProjectActivity,
319
- useTotalRunningSessions,
320
- useHasBackgroundRunningSessions
321
- };
@@ -1,61 +0,0 @@
1
- import {
2
- cn
3
- } from "./chunk-RQHJBTEU.js";
4
-
5
- // src/primitives/tabs.tsx
6
- import * as TabsPrimitive from "@radix-ui/react-tabs";
7
- import * as React from "react";
8
- import { jsx } from "react/jsx-runtime";
9
- var Tabs = TabsPrimitive.Root;
10
- var TabsList = React.forwardRef(({ className, variant = "default", ...props }, ref) => {
11
- const variants = {
12
- default: "inline-flex h-10 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",
13
- pills: "inline-flex items-center gap-2",
14
- underline: "inline-flex items-center gap-4 border-b border-border"
15
- };
16
- return /* @__PURE__ */ jsx(
17
- TabsPrimitive.List,
18
- {
19
- ref,
20
- className: cn(variants[variant], className),
21
- ...props
22
- }
23
- );
24
- });
25
- TabsList.displayName = TabsPrimitive.List.displayName;
26
- var TabsTrigger = React.forwardRef(({ className, variant = "default", ...props }, ref) => {
27
- const variants = {
28
- default: "inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",
29
- pills: "inline-flex items-center justify-center whitespace-nowrap rounded-full px-4 py-2 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-primary data-[state=active]:text-primary-foreground data-[state=inactive]:text-muted-foreground data-[state=inactive]:hover:bg-muted",
30
- underline: "inline-flex items-center justify-center whitespace-nowrap pb-3 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:text-foreground data-[state=inactive]:text-muted-foreground"
31
- };
32
- return /* @__PURE__ */ jsx(
33
- TabsPrimitive.Trigger,
34
- {
35
- ref,
36
- className: cn(variants[variant], className),
37
- ...props
38
- }
39
- );
40
- });
41
- TabsTrigger.displayName = TabsPrimitive.Trigger.displayName;
42
- var TabsContent = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
43
- TabsPrimitive.Content,
44
- {
45
- ref,
46
- className: cn(
47
- "mt-4 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
48
- "data-[state=active]:fade-in-0 data-[state=active]:slide-in-from-bottom-2 data-[state=active]:animate-in",
49
- className
50
- ),
51
- ...props
52
- }
53
- ));
54
- TabsContent.displayName = TabsPrimitive.Content.displayName;
55
-
56
- export {
57
- Tabs,
58
- TabsList,
59
- TabsTrigger,
60
- TabsContent
61
- };
@@ -1,117 +0,0 @@
1
- // src/hooks/use-live-time.ts
2
- import * as React from "react";
3
- function useLiveTime(intervalMs = 1e3) {
4
- const [now, setNow] = React.useState(() => Date.now());
5
- React.useEffect(() => {
6
- const requested = Number.isFinite(intervalMs) && intervalMs > 0 ? intervalMs : 1e3;
7
- const delay = Math.max(requested, 100);
8
- const id = window.setInterval(() => {
9
- setNow(Date.now());
10
- }, delay);
11
- return () => {
12
- window.clearInterval(id);
13
- };
14
- }, [intervalMs]);
15
- return now;
16
- }
17
-
18
- // src/hooks/use-auth.ts
19
- import * as React2 from "react";
20
- function useAuth({
21
- apiBaseUrl,
22
- revalidateOnFocus = false,
23
- shouldRetryOnError = false
24
- }) {
25
- const [user, setUser] = React2.useState(null);
26
- const [isLoading, setIsLoading] = React2.useState(true);
27
- const [error, setError] = React2.useState(null);
28
- const retryTimerRef = React2.useRef(null);
29
- const abortRef = React2.useRef(null);
30
- const fetchSession = React2.useCallback(async () => {
31
- abortRef.current?.abort();
32
- const controller = new AbortController();
33
- abortRef.current = controller;
34
- setIsLoading(true);
35
- setError(null);
36
- try {
37
- const res = await fetch(`${apiBaseUrl}/auth/session`, {
38
- credentials: "include",
39
- signal: controller.signal
40
- });
41
- if (!res.ok) {
42
- throw new Error("Not authenticated");
43
- }
44
- const data = await res.json();
45
- if (data.success && data.data) {
46
- setUser(data.data);
47
- } else {
48
- setUser(null);
49
- }
50
- } catch (err) {
51
- if (err.name === "AbortError") return;
52
- setError(err instanceof Error ? err : new Error("Unknown error"));
53
- setUser(null);
54
- if (shouldRetryOnError) {
55
- if (retryTimerRef.current) clearTimeout(retryTimerRef.current);
56
- retryTimerRef.current = setTimeout(fetchSession, 5e3);
57
- }
58
- } finally {
59
- if (!controller.signal.aborted) {
60
- setIsLoading(false);
61
- }
62
- }
63
- }, [apiBaseUrl, shouldRetryOnError]);
64
- React2.useEffect(() => {
65
- fetchSession();
66
- return () => {
67
- abortRef.current?.abort();
68
- if (retryTimerRef.current) clearTimeout(retryTimerRef.current);
69
- };
70
- }, [fetchSession]);
71
- React2.useEffect(() => {
72
- if (!revalidateOnFocus) return;
73
- const handleFocus = () => {
74
- fetchSession();
75
- };
76
- window.addEventListener("focus", handleFocus);
77
- return () => window.removeEventListener("focus", handleFocus);
78
- }, [revalidateOnFocus, fetchSession]);
79
- return {
80
- user,
81
- isLoading,
82
- isError: !!error,
83
- error,
84
- mutate: fetchSession
85
- };
86
- }
87
- function createAuthFetcher(_apiBaseUrl) {
88
- return async function authFetcher(url, options) {
89
- const res = await fetch(url, {
90
- ...options,
91
- credentials: "include",
92
- headers: {
93
- ...options?.headers
94
- }
95
- });
96
- if (!res.ok) {
97
- throw new Error(`Request failed with status ${res.status}`);
98
- }
99
- return res.json();
100
- };
101
- }
102
- function useApiKey() {
103
- const [apiKey, setApiKey] = React2.useState(null);
104
- React2.useEffect(() => {
105
- if (typeof window !== "undefined") {
106
- setApiKey(localStorage.getItem("apiKey"));
107
- }
108
- }, []);
109
- return apiKey;
110
- }
111
-
112
- export {
113
- useLiveTime,
114
- useAuth,
115
- createAuthFetcher,
116
- useApiKey
117
- };
File without changes