@brickkit/cli 0.12.0 → 0.13.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.
- package/dashboard-dist/{api-reference-B-bZRtNV.js → api-reference-mT9VNcPb.js} +69 -69
- package/dashboard-dist/app.js +12 -13
- package/dashboard-dist/{client-BJJtVSVr.js → client-CwATkLJa.js} +1 -1
- package/dashboard-dist/{core-Z7NJFk0K.js → core-BEUWp6B5.js} +1 -1
- package/dashboard-dist/docs-BRrtyxDB.js +4 -0
- package/dashboard-dist/kit.js +1 -1
- package/dashboard-dist/popover-Bj9x-88h.js +1 -0
- package/dist/bin.js +154 -217
- package/dist/bin.js.map +1 -1
- package/dist/build.js +463 -0
- package/dist/build.js.map +1 -0
- package/dist/client-contract-file.js +356 -1
- package/dist/client-contract-file.js.map +1 -0
- package/dist/compiler.d.ts +12 -2
- package/dist/compiler2.js +12 -5
- package/dist/compiler2.js.map +1 -1
- package/dist/config.d.ts +3 -0
- package/dist/config.js +1 -250
- package/dist/config2.d.ts +122 -0
- package/dist/config2.js +207 -0
- package/dist/config2.js.map +1 -0
- package/dist/dashboard-extension.d.ts +3 -0
- package/dist/{dev-telemetry-store.js → dashboard-host.js} +1533 -1574
- package/dist/dashboard-host.js.map +1 -0
- package/dist/dashboard-protocol.js +189 -0
- package/dist/dashboard-protocol.js.map +1 -0
- package/dist/dashboard.d.ts +4 -1
- package/dist/definitions.js +33 -0
- package/dist/definitions.js.map +1 -0
- package/dist/dev-application.js +34 -0
- package/dist/dev-application.js.map +1 -0
- package/dist/dev-protocol.js +21 -0
- package/dist/dev-protocol.js.map +1 -0
- package/dist/dev-reporter.js +2 -1
- package/dist/dev-reporter.js.map +1 -1
- package/dist/dev-telemetry.js +5 -20
- package/dist/dev-telemetry.js.map +1 -1
- package/dist/dev-worker.js +79 -19
- package/dist/dev-worker.js.map +1 -1
- package/dist/index.d.ts +15 -74
- package/dist/index.js +12 -5
- package/dist/index.js.map +1 -0
- package/dist/lint/oxlint.js +5 -3
- package/dist/lint/oxlint.js.map +1 -1
- package/dist/own-module.js +7 -0
- package/dist/own-module.js.map +1 -0
- package/dist/plugin.d.ts +6 -5
- package/dist/plugin.js +5 -39
- package/dist/plugin.js.map +1 -1
- package/dist/production-dashboard.d.ts +2 -0
- package/dist/production-dashboard.js +51 -0
- package/dist/production-dashboard.js.map +1 -0
- package/dist/production-dashboard2.d.ts +34 -0
- package/dist/{presets.js → project.js} +104 -106
- package/dist/project.js.map +1 -0
- package/dist/serve.d.ts +24 -0
- package/dist/serve.js +1 -0
- package/dist/serve2.js +49 -0
- package/dist/serve2.js.map +1 -0
- package/dist/vite.js +26 -47
- package/dist/vite.js.map +1 -1
- package/dist/workflows.d.ts +2 -2
- package/dist/workflows2.js +59 -37
- package/dist/workflows2.js.map +1 -1
- package/inspector-dist/client/assets/app-CeSwVsRm.css +2 -0
- package/inspector-dist/client/assets/{highlighted-body-B3W2YXNL-DYVdwGy2.js → highlighted-body-B3W2YXNL-CfRnuITN.js} +1 -1
- package/inspector-dist/client/assets/{home-CyjkvtII.js → home-hwPlkNhv.js} +1529 -378
- package/inspector-dist/client/assets/manifest-0e76e9ac.js +1 -0
- package/inspector-dist/client/assets/mermaid-3ZIDBTTL-ZDR2PNY_.js +1 -0
- package/inspector-dist/client/assets/root-ChBNTZd2.css +2 -0
- package/inspector-dist/client/assets/{root-DX9wtogx.js → root-SLeEf-sT.js} +17 -29
- package/inspector-dist/client/assets/{run-detail-C69EJGql.js → run-detail-DYbVkIFH.js} +398 -76
- package/inspector-dist/client/assets/{tabs-B6B88IjT.js → tabs-CaJisoyb.js} +189 -2130
- package/inspector-dist/client/assets/{zstd-browser-decoder-ByUgcY9H.js → zstd-browser-decoder-D94wmfAU.js} +1 -1
- package/inspector-dist/server/assets/{app-WoDoT62X.js → app-DGlfWVUI.js} +69783 -70608
- package/inspector-dist/server/assets/{chunk-RLXIAIE6-CbvDIAEa.js → chunk-RLXIAIE6-F0SJZlei.js} +4 -6
- package/inspector-dist/server/assets/{dist-qR-969AD.js → dist-BCbwm6jl.js} +2 -4
- package/inspector-dist/server/assets/{dist-CQnQcIJg.js → dist-CG2aVufI.js} +0 -2
- package/inspector-dist/server/assets/{dist-BRxZSWUN.js → dist-Ce0I2PUv.js} +2 -5
- package/inspector-dist/server/assets/{dist-DqRd9pyS.js → dist-DY0UlahA.js} +0 -2
- package/inspector-dist/server/assets/{encryption-_PuklZNX.js → encryption-DdQgC8Rk.js} +2 -4
- package/inspector-dist/server/assets/{event-metadata-BVakQJ_y.js → event-metadata-n7E4zEmT.js} +0 -2
- package/inspector-dist/server/assets/{functions-CImcpqNl.js → functions-CNVQtbgg.js} +2 -4
- package/inspector-dist/server/assets/{global-singleton-CPirHxFh.js → global-singleton-D8sIN5du.js} +0 -2
- package/inspector-dist/server/assets/{highlighted-body-B3W2YXNL-fPMB_t7F.js → highlighted-body-B3W2YXNL-CWRzMxYD.js} +2 -4
- package/inspector-dist/server/assets/mermaid-3ZIDBTTL-D0v0ngVr.js +1 -0
- package/inspector-dist/server/assets/{parse-D9Vvgzt9.js → parse-Begau9cA.js} +0 -2
- package/inspector-dist/server/assets/{rolldown-runtime-CLg409Sh.js → rolldown-runtime-C1I3wEg2.js} +1 -2
- package/inspector-dist/server/assets/{serialization-format-DDtsVTU1.js → serialization-format-BbuGfHog.js} +6 -8
- package/inspector-dist/server/assets/{token-BW4GdQZh.js → token-BgMmJNP5.js} +2 -4
- package/inspector-dist/server/assets/{token-D6FXdkJT.js → token-BrUX0bxz.js} +2 -4
- package/inspector-dist/server/assets/{token-util-BoNmi-wE.js → token-util-DZN32qmT.js} +1 -3
- package/inspector-dist/server/assets/{wrapper-wiqsGXcE.js → wrapper-CIC3w0oC.js} +1 -3
- package/inspector-dist/server/assets/{ws-transport-DV7oG4mL.js → ws-transport-CxTYB11n.js} +24094 -24096
- package/inspector-dist/server/assets/{zstd-browser-decoder-Cswf0KO6.js → zstd-browser-decoder-D7bCXbGg.js} +2 -4
- package/inspector-dist/server/index.js +1 -3
- package/package.json +12 -2
- package/dashboard-dist/docs-Dpfc0wJb.js +0 -4
- package/dashboard-dist/popover-BzejBolB.js +0 -1
- package/dist/app-entry.js +0 -1
- package/dist/app-entry2.js +0 -18
- package/dist/app-entry2.js.map +0 -1
- package/dist/client-contract-file2.js +0 -33
- package/dist/client-contract-file2.js.map +0 -1
- package/dist/client-contract.js +0 -1
- package/dist/client-contract2.js +0 -296
- package/dist/client-contract2.js.map +0 -1
- package/dist/config.js.map +0 -1
- package/dist/dev-telemetry-store.js.map +0 -1
- package/dist/emit.d.ts +0 -5
- package/dist/presets.js.map +0 -1
- package/dist/runner.js +0 -519
- package/dist/runner.js.map +0 -1
- package/inspector-dist/client/assets/app-CCzpuUz_.css +0 -2
- package/inspector-dist/client/assets/manifest-ba30b52d.js +0 -1
- package/inspector-dist/client/assets/mermaid-3ZIDBTTL-Dy6IVqPy.js +0 -1
- package/inspector-dist/client/assets/root-8BMab1lL.css +0 -2
- package/inspector-dist/client/assets/world-config-context-C3BqXPIv.js +0 -30
- package/inspector-dist/server/assets/mermaid-3ZIDBTTL-bADXySE3.js +0 -3
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { D as useLocation, F as require_react, M as withComponentProps, O as useNavigate, P as require_react_dom, R as __toESM, j as useSearchParams, r as Link, t as require_jsx_runtime } from "./jsx-runtime-CPEah4WQ.js";
|
|
2
|
-
import {
|
|
1
|
+
import { D as useLocation, F as require_react, I as __commonJSMin, M as withComponentProps, O as useNavigate, P as require_react_dom, R as __toESM, j as useSearchParams, r as Link, t as require_jsx_runtime } from "./jsx-runtime-CPEah4WQ.js";
|
|
2
|
+
import { A as PopperContent, B as useCallbackRef, Bt as ChevronRight, C as DropdownMenuTrigger, D as Portal, E as Presence, Ft as Ellipsis, G as useControllableState, H as createCollection, Ht as Check, It as Copy, J as useComposedRefs, K as useLayoutEffect2, L as useFocusGuards, Lt as CircleX, M as useSize, Mt as Zap, N as useId, Nt as X, O as Popper, P as FocusScope, Q as AlertTitle, R as DismissableLayer, Rt as CircleAlert, S as DropdownMenuItem, T as hideOthers, U as Primitive, Ut as createLucideIcon, V as useDirection, Vt as ChevronDown, W as createSlot, Wt as parseWorkflowName, X as Alert, Y as composeEventHandlers, Z as AlertDescription, _ as unwrapOrThrow, b as DropdownMenu, c as STATUS_COLORS, d as rpc, dt as ResolveHookDropdownItem, et as cn, ft as useHookActions, g as getErrorMessage, gt as TooltipTrigger, h as WorkflowWebAPIError, ht as TooltipContent, i as TabsTrigger, j as createPopperScope, jt as ErrorBoundary, k as PopperAnchor, l as Skeleton, mt as Tooltip, n as TabsContent, o as RunActionsDropdownItems, q as createContextScope, r as TabsList, s as StatusBadge, t as Tabs, tt as getPaginationDisplay, u as RelativeTime, ut as HookResolveModalWrapper, vt as Button, w as ReactRemoveScroll, x as DropdownMenuContent, y as CopyableText, zt as ChevronUp } from "./tabs-CaJisoyb.js";
|
|
3
3
|
import { n as toast } from "./dist-BK8w6xOr.js";
|
|
4
|
-
import { n as useServerConfig } from "./world-config-context-C3BqXPIv.js";
|
|
5
4
|
/**
|
|
6
5
|
* @license lucide-react v0.575.0 - ISC
|
|
7
6
|
*
|
|
@@ -230,7 +229,7 @@ TableCaption.displayName = "TableCaption";
|
|
|
230
229
|
* time (via `fetchHookToken`) only when the user clicks to copy it. This keeps
|
|
231
230
|
* the secret out of bulk list responses while preserving the copy affordance.
|
|
232
231
|
*/
|
|
233
|
-
function HookTokenCell({
|
|
232
|
+
function HookTokenCell({ runId, hookId }) {
|
|
234
233
|
const [status, setStatus] = (0, import_react.useState)("idle");
|
|
235
234
|
const [error, setError] = (0, import_react.useState)(null);
|
|
236
235
|
const handleCopy = async (e) => {
|
|
@@ -239,7 +238,10 @@ function HookTokenCell({ env, runId, hookId }) {
|
|
|
239
238
|
setStatus("loading");
|
|
240
239
|
setError(null);
|
|
241
240
|
try {
|
|
242
|
-
const token = await fetchHookToken
|
|
241
|
+
const { token } = await unwrapOrThrow(rpc("fetchHookToken", {
|
|
242
|
+
runId,
|
|
243
|
+
hookId
|
|
244
|
+
}));
|
|
243
245
|
await navigator.clipboard.writeText(token);
|
|
244
246
|
setStatus("copied");
|
|
245
247
|
setTimeout(() => setStatus("idle"), 2e3);
|
|
@@ -268,24 +270,23 @@ function HookTokenCell({ env, runId, hookId }) {
|
|
|
268
270
|
});
|
|
269
271
|
}
|
|
270
272
|
// app/components/display-utils/table-skeleton.tsx
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
273
|
+
/** The hooks table while its first page loads: Hook ID, Run ID, Token, Created, Invocations, Actions. */
|
|
274
|
+
function TableSkeleton({ rows = 10 }) {
|
|
275
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Card, {
|
|
276
|
+
className: "overflow-hidden mt-4 bg-background",
|
|
277
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(CardContent, {
|
|
278
|
+
className: "p-0",
|
|
279
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
280
|
+
className: "grid grid-cols-[1.2fr_1.2fr_0.8fr_1fr_0.5fr_40px] items-center gap-4 py-3 px-4 border-b",
|
|
276
281
|
children: [
|
|
277
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Skeleton, { className: "h-4 w-
|
|
278
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Skeleton, { className: "h-4 w-
|
|
279
|
-
/* @__PURE__ */ (0, import_jsx_runtime.
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
})
|
|
283
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Skeleton, { className: "h-3 w-3/4" }),
|
|
284
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Skeleton, { className: "h-3 w-3/4" }),
|
|
285
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Skeleton, { className: "h-6 w-6 rounded" })
|
|
282
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Skeleton, { className: "h-4 w-16" }),
|
|
283
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Skeleton, { className: "h-4 w-14" }),
|
|
284
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Skeleton, { className: "h-4 w-12" }),
|
|
285
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Skeleton, { className: "h-4 w-14" }),
|
|
286
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Skeleton, { className: "h-4 w-20" }),
|
|
287
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "w-6" })
|
|
286
288
|
]
|
|
287
|
-
},
|
|
288
|
-
case "hooks": return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
289
|
+
}), Array.from({ length: rows }, (_, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
289
290
|
className: "grid grid-cols-[1.2fr_1.2fr_0.8fr_1fr_0.5fr_40px] items-center gap-4 py-3 px-4",
|
|
290
291
|
children: [
|
|
291
292
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Skeleton, { className: "h-4 w-4/5" }),
|
|
@@ -295,81 +296,208 @@ function TableSkeleton({ rows = 10, variant = "runs" }) {
|
|
|
295
296
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Skeleton, { className: "h-4 w-8" }),
|
|
296
297
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Skeleton, { className: "h-6 w-6 rounded" })
|
|
297
298
|
]
|
|
298
|
-
}, `skeleton-row-${i}`)
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
299
|
+
}, `skeleton-row-${i}`))]
|
|
300
|
+
})
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
// app/lib/client/hooks/use-paginated-list.ts
|
|
304
|
+
/**
|
|
305
|
+
* Generic hook for cursor-based paginated lists with caching and navigation.
|
|
306
|
+
* Callers should memoize `fetchFn` with useCallback to control when data is refetched.
|
|
307
|
+
*/
|
|
308
|
+
function usePaginatedList(fetchFn) {
|
|
309
|
+
const [cursor, setCursor] = (0, import_react.useState)(void 0);
|
|
310
|
+
const [hasMore, setHasMore] = (0, import_react.useState)(false);
|
|
311
|
+
const [currentPage, setCurrentPage] = (0, import_react.useState)(0);
|
|
312
|
+
const [pageHistory, setPageHistory] = (0, import_react.useState)([void 0]);
|
|
313
|
+
const [maxPagesVisited, setMaxPagesVisited] = (0, import_react.useState)(1);
|
|
314
|
+
const [allPageResults, setAllPageResults] = (0, import_react.useState)(/* @__PURE__ */ new Map([[0, {
|
|
315
|
+
data: null,
|
|
316
|
+
isLoading: false,
|
|
317
|
+
error: null
|
|
318
|
+
}]]));
|
|
319
|
+
const pageCache = (0, import_react.useRef)(/* @__PURE__ */ new Map());
|
|
320
|
+
const fetchPage = (0, import_react.useCallback)(async (pageIndex, pageCursor, force = false) => {
|
|
321
|
+
const cacheKey = pageCursor ?? "initial";
|
|
322
|
+
setAllPageResults((prev) => {
|
|
323
|
+
const newMap = new Map(prev);
|
|
324
|
+
newMap.set(pageIndex, {
|
|
325
|
+
data: prev.get(pageIndex)?.data ?? null,
|
|
326
|
+
isLoading: true,
|
|
327
|
+
error: null
|
|
328
|
+
});
|
|
329
|
+
return newMap;
|
|
330
|
+
});
|
|
331
|
+
if (!force && pageCache.current.has(cacheKey)) {
|
|
332
|
+
const cached = pageCache.current.get(cacheKey);
|
|
333
|
+
if (cached) {
|
|
334
|
+
setAllPageResults((prev) => {
|
|
335
|
+
const newMap = new Map(prev);
|
|
336
|
+
newMap.set(pageIndex, {
|
|
337
|
+
data: cached.data,
|
|
338
|
+
isLoading: false,
|
|
339
|
+
error: null
|
|
340
|
+
});
|
|
341
|
+
return newMap;
|
|
342
|
+
});
|
|
343
|
+
setCursor(cached.cursor);
|
|
344
|
+
setHasMore(cached.hasMore);
|
|
345
|
+
return;
|
|
346
|
+
}
|
|
308
347
|
}
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Skeleton, { className: "h-4 w-20" }),
|
|
316
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Skeleton, { className: "h-4 w-14" }),
|
|
317
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Skeleton, { className: "h-4 w-12" }),
|
|
318
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Skeleton, { className: "h-4 w-14" }),
|
|
319
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Skeleton, { className: "h-4 w-20" }),
|
|
320
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "w-6" })
|
|
321
|
-
]
|
|
348
|
+
try {
|
|
349
|
+
const result = await fetchFn(pageCursor);
|
|
350
|
+
pageCache.current.set(cacheKey, {
|
|
351
|
+
data: result.data,
|
|
352
|
+
cursor: result.cursor,
|
|
353
|
+
hasMore: result.hasMore
|
|
322
354
|
});
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "w-6" })
|
|
332
|
-
]
|
|
355
|
+
setAllPageResults((prev) => {
|
|
356
|
+
const newMap = new Map(prev);
|
|
357
|
+
newMap.set(pageIndex, {
|
|
358
|
+
data: result.data,
|
|
359
|
+
isLoading: false,
|
|
360
|
+
error: null
|
|
361
|
+
});
|
|
362
|
+
return newMap;
|
|
333
363
|
});
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
364
|
+
setCursor(result.cursor);
|
|
365
|
+
setHasMore(result.hasMore);
|
|
366
|
+
} catch (err) {
|
|
367
|
+
const error = err instanceof Error ? err : new WorkflowWebAPIError(String(err), { layer: "client" });
|
|
368
|
+
setAllPageResults((prev) => {
|
|
369
|
+
const newMap = new Map(prev);
|
|
370
|
+
newMap.set(pageIndex, {
|
|
371
|
+
data: prev.get(pageIndex)?.data ?? null,
|
|
372
|
+
isLoading: false,
|
|
373
|
+
error
|
|
374
|
+
});
|
|
375
|
+
return newMap;
|
|
341
376
|
});
|
|
342
|
-
default: return null;
|
|
343
377
|
}
|
|
378
|
+
}, [fetchFn]);
|
|
379
|
+
(0, import_react.useEffect)(() => {
|
|
380
|
+
fetchPage(0, void 0, true);
|
|
381
|
+
}, [fetchPage]);
|
|
382
|
+
const nextPage = (0, import_react.useCallback)(() => {
|
|
383
|
+
if (hasMore && cursor) {
|
|
384
|
+
const newPage = currentPage + 1;
|
|
385
|
+
setPageHistory((prev) => [...prev, cursor]);
|
|
386
|
+
setCurrentPage(newPage);
|
|
387
|
+
setMaxPagesVisited((prev) => Math.max(prev, newPage + 1));
|
|
388
|
+
if (!allPageResults.has(newPage)) setAllPageResults((prev) => {
|
|
389
|
+
const newMap = new Map(prev);
|
|
390
|
+
newMap.set(newPage, {
|
|
391
|
+
data: null,
|
|
392
|
+
isLoading: true,
|
|
393
|
+
error: null
|
|
394
|
+
});
|
|
395
|
+
return newMap;
|
|
396
|
+
});
|
|
397
|
+
fetchPage(newPage, cursor);
|
|
398
|
+
}
|
|
399
|
+
}, [
|
|
400
|
+
hasMore,
|
|
401
|
+
cursor,
|
|
402
|
+
fetchPage,
|
|
403
|
+
currentPage,
|
|
404
|
+
allPageResults
|
|
405
|
+
]);
|
|
406
|
+
const previousPage = (0, import_react.useCallback)(() => {
|
|
407
|
+
if (currentPage > 0) {
|
|
408
|
+
const newPage = currentPage - 1;
|
|
409
|
+
const prevCursor = pageHistory[newPage];
|
|
410
|
+
setCurrentPage(newPage);
|
|
411
|
+
fetchPage(newPage, prevCursor);
|
|
412
|
+
}
|
|
413
|
+
}, [
|
|
414
|
+
currentPage,
|
|
415
|
+
pageHistory,
|
|
416
|
+
fetchPage
|
|
417
|
+
]);
|
|
418
|
+
const reload = (0, import_react.useCallback)(() => {
|
|
419
|
+
pageCache.current.clear();
|
|
420
|
+
setAllPageResults(/* @__PURE__ */ new Map([[0, {
|
|
421
|
+
data: null,
|
|
422
|
+
isLoading: true,
|
|
423
|
+
error: null
|
|
424
|
+
}]]));
|
|
425
|
+
setCurrentPage(0);
|
|
426
|
+
setPageHistory([void 0]);
|
|
427
|
+
setMaxPagesVisited(1);
|
|
428
|
+
fetchPage(0, void 0, true);
|
|
429
|
+
}, [fetchPage]);
|
|
430
|
+
const refresh = (0, import_react.useCallback)(() => {
|
|
431
|
+
const currentCursor = pageHistory[currentPage];
|
|
432
|
+
const cacheKey = currentCursor ?? "initial";
|
|
433
|
+
pageCache.current.delete(cacheKey);
|
|
434
|
+
fetchPage(currentPage, currentCursor, true);
|
|
435
|
+
}, [
|
|
436
|
+
fetchPage,
|
|
437
|
+
currentPage,
|
|
438
|
+
pageHistory
|
|
439
|
+
]);
|
|
440
|
+
const currentPageResult = allPageResults.get(currentPage) ?? {
|
|
441
|
+
data: null,
|
|
442
|
+
isLoading: true,
|
|
443
|
+
error: null
|
|
444
|
+
};
|
|
445
|
+
const globalError = Array.from(allPageResults.values()).find((p) => p.error)?.error ?? null;
|
|
446
|
+
const globalLoading = Array.from(allPageResults.values()).some((p) => p.isLoading);
|
|
447
|
+
const totalPages = hasMore ? currentPage + 2 : currentPage + 1;
|
|
448
|
+
const currentPageNumber = currentPage + 1;
|
|
449
|
+
const pageInfo = getPaginationDisplay(currentPageNumber, maxPagesVisited, currentPageNumber === maxPagesVisited && hasMore);
|
|
450
|
+
return {
|
|
451
|
+
data: currentPageResult,
|
|
452
|
+
allData: Array.from(allPageResults.values()),
|
|
453
|
+
error: globalError,
|
|
454
|
+
isLoading: globalLoading,
|
|
455
|
+
currentPage,
|
|
456
|
+
totalPages,
|
|
457
|
+
nextPage,
|
|
458
|
+
previousPage,
|
|
459
|
+
hasNextPage: hasMore,
|
|
460
|
+
hasPreviousPage: currentPage > 0,
|
|
461
|
+
reload,
|
|
462
|
+
refresh,
|
|
463
|
+
pageInfo
|
|
344
464
|
};
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
465
|
+
}
|
|
466
|
+
/**
|
|
467
|
+
* Returns a list of hooks with pagination control
|
|
468
|
+
*/
|
|
469
|
+
function useWorkflowHooks(params) {
|
|
470
|
+
const { runId, limit = 10, sortOrder = "desc" } = params;
|
|
471
|
+
return usePaginatedList((0, import_react.useCallback)((cursor) => unwrapOrThrow(rpc("fetchHooks", {
|
|
472
|
+
runId,
|
|
473
|
+
cursor,
|
|
474
|
+
sortOrder,
|
|
475
|
+
limit
|
|
476
|
+
})), [
|
|
477
|
+
runId,
|
|
478
|
+
limit,
|
|
479
|
+
sortOrder
|
|
480
|
+
]));
|
|
352
481
|
}
|
|
353
482
|
// app/components/hooks-table.tsx
|
|
483
|
+
var INVOCATION_EVENTS_LIMIT = 100;
|
|
354
484
|
/**
|
|
355
|
-
*
|
|
356
|
-
*
|
|
357
|
-
* Fetches invocation counts in the background for each hook.
|
|
358
|
-
*
|
|
359
|
-
* World configuration is read from server-side environment variables.
|
|
360
|
-
* The env object passed to server actions is empty - the server uses process.env.
|
|
485
|
+
* Hooks with server-side pagination. Fetches invocation counts in the
|
|
486
|
+
* background for each hook.
|
|
361
487
|
*/
|
|
362
|
-
function HooksTable({
|
|
488
|
+
function HooksTable({ onHookClick, selectedHookId }) {
|
|
363
489
|
const [lastRefreshTime, setLastRefreshTime] = (0, import_react.useState)(() => /* @__PURE__ */ new Date());
|
|
364
|
-
const
|
|
365
|
-
const { data, error, nextPage, previousPage, hasNextPage, hasPreviousPage, refresh, pageInfo } = useWorkflowHooks(env, {
|
|
366
|
-
runId,
|
|
367
|
-
sortOrder: "desc"
|
|
368
|
-
});
|
|
490
|
+
const { data, error, nextPage, previousPage, hasNextPage, hasPreviousPage, refresh, pageInfo } = useWorkflowHooks({ sortOrder: "desc" });
|
|
369
491
|
const hookActions = useHookActions({
|
|
370
492
|
onResolve: async (hook, payload) => {
|
|
371
|
-
const token = await fetchHookToken
|
|
372
|
-
|
|
493
|
+
const { token } = await unwrapOrThrow(rpc("fetchHookToken", {
|
|
494
|
+
runId: hook.runId,
|
|
495
|
+
hookId: hook.hookId
|
|
496
|
+
}));
|
|
497
|
+
await unwrapOrThrow(rpc("resumeHook", {
|
|
498
|
+
token,
|
|
499
|
+
payload
|
|
500
|
+
}));
|
|
373
501
|
},
|
|
374
502
|
callbacks: { onSuccess: refresh }
|
|
375
503
|
});
|
|
@@ -381,63 +509,34 @@ function HooksTable({ runId, onHookClick, selectedHookId }) {
|
|
|
381
509
|
};
|
|
382
510
|
const [invocationData, setInvocationData] = (0, import_react.useState)(/* @__PURE__ */ new Map());
|
|
383
511
|
(0, import_react.useEffect)(() => {
|
|
384
|
-
if (!hooks.length
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
const serverResult = await fetchEvents(env, runId, {
|
|
395
|
-
sortOrder: "asc",
|
|
396
|
-
limit: 1e3
|
|
397
|
-
});
|
|
398
|
-
if (!serverResult.success) {
|
|
399
|
-
setInvocationData((prev) => {
|
|
400
|
-
const updated = new Map(prev);
|
|
401
|
-
for (const hook of hooks) updated.set(hook.hookId, {
|
|
402
|
-
count: 0,
|
|
403
|
-
hasMore: false,
|
|
404
|
-
loading: false
|
|
405
|
-
});
|
|
406
|
-
return updated;
|
|
407
|
-
});
|
|
408
|
-
return;
|
|
409
|
-
}
|
|
410
|
-
const allEvents = serverResult.data.data;
|
|
411
|
-
const hookIds = new Set(hooks.map((h) => h.hookId));
|
|
412
|
-
const counts = /* @__PURE__ */ new Map();
|
|
413
|
-
for (const event of allEvents) if (event.eventType === "hook_received" && event.correlationId && hookIds.has(event.correlationId)) counts.set(event.correlationId, (counts.get(event.correlationId) ?? 0) + 1);
|
|
414
|
-
setInvocationData((prev) => {
|
|
415
|
-
const updated = new Map(prev);
|
|
416
|
-
for (const hook of hooks) updated.set(hook.hookId, {
|
|
417
|
-
count: counts.get(hook.hookId) ?? 0,
|
|
418
|
-
hasMore: serverResult.data.hasMore,
|
|
419
|
-
loading: false
|
|
420
|
-
});
|
|
421
|
-
return updated;
|
|
422
|
-
});
|
|
423
|
-
} catch {
|
|
424
|
-
setInvocationData((prev) => {
|
|
425
|
-
const updated = new Map(prev);
|
|
426
|
-
for (const hook of hooks) updated.set(hook.hookId, {
|
|
427
|
-
count: 0,
|
|
428
|
-
hasMore: false,
|
|
429
|
-
loading: false
|
|
430
|
-
});
|
|
431
|
-
return updated;
|
|
432
|
-
});
|
|
433
|
-
}
|
|
512
|
+
if (!hooks.length) return;
|
|
513
|
+
let ignore = false;
|
|
514
|
+
setInvocationData(new Map(hooks.map((hook) => [hook.hookId, {
|
|
515
|
+
count: 0,
|
|
516
|
+
hasMore: false,
|
|
517
|
+
loading: true
|
|
518
|
+
}])));
|
|
519
|
+
const settle = (hookId, data) => {
|
|
520
|
+
if (ignore) return;
|
|
521
|
+
setInvocationData((prev) => new Map(prev).set(hookId, data));
|
|
434
522
|
};
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
523
|
+
for (const hook of hooks) unwrapOrThrow(rpc("fetchEventsByCorrelationId", {
|
|
524
|
+
correlationId: hook.hookId,
|
|
525
|
+
runId: hook.runId,
|
|
526
|
+
limit: INVOCATION_EVENTS_LIMIT
|
|
527
|
+
})).then(({ data: events, hasMore }) => settle(hook.hookId, {
|
|
528
|
+
count: events.filter((event) => event.eventType === "hook_received").length,
|
|
529
|
+
hasMore,
|
|
530
|
+
loading: false
|
|
531
|
+
}), (error) => settle(hook.hookId, {
|
|
532
|
+
count: error,
|
|
533
|
+
hasMore: false,
|
|
534
|
+
loading: false
|
|
535
|
+
}));
|
|
536
|
+
return () => {
|
|
537
|
+
ignore = true;
|
|
538
|
+
};
|
|
539
|
+
}, [hooks]);
|
|
441
540
|
const renderInvocationCount = (hook) => {
|
|
442
541
|
const data = invocationData.get(hook.hookId);
|
|
443
542
|
if (!data || data.loading) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
@@ -461,9 +560,13 @@ function HooksTable({ runId, onHookClick, selectedHookId }) {
|
|
|
461
560
|
})
|
|
462
561
|
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TooltipContent, {
|
|
463
562
|
className: "max-w-xs",
|
|
464
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.
|
|
563
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
465
564
|
className: "text-xs",
|
|
466
|
-
children:
|
|
565
|
+
children: [
|
|
566
|
+
"Counted from the first ",
|
|
567
|
+
INVOCATION_EVENTS_LIMIT,
|
|
568
|
+
" events. There may be more."
|
|
569
|
+
]
|
|
467
570
|
})
|
|
468
571
|
})] });
|
|
469
572
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
@@ -503,7 +606,7 @@ function HooksTable({ runId, onHookClick, selectedHookId }) {
|
|
|
503
606
|
variant: "destructive",
|
|
504
607
|
children: [
|
|
505
608
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(CircleAlert, { className: "h-4 w-4" }),
|
|
506
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(AlertTitle, { children:
|
|
609
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(AlertTitle, { children: "Error loading hooks" }),
|
|
507
610
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(AlertDescription, { children: getErrorMessage(error) })
|
|
508
611
|
]
|
|
509
612
|
}) : !loading && (!hooks || hooks.length === 0) ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
@@ -516,7 +619,7 @@ function HooksTable({ runId, onHookClick, selectedHookId }) {
|
|
|
516
619
|
children: "Learn how to create a hook"
|
|
517
620
|
})
|
|
518
621
|
]
|
|
519
|
-
}) : loading && !data?.data ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableSkeleton, {
|
|
622
|
+
}) : loading && !data?.data ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableSkeleton, {}) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Card, {
|
|
520
623
|
className: "overflow-hidden mt-4 bg-background",
|
|
521
624
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CardContent, {
|
|
522
625
|
className: "p-0 max-h-[calc(100vh-280px)] overflow-auto",
|
|
@@ -566,7 +669,6 @@ function HooksTable({ runId, onHookClick, selectedHookId }) {
|
|
|
566
669
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableCell, {
|
|
567
670
|
className: "font-mono text-xs py-2",
|
|
568
671
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(HookTokenCell, {
|
|
569
|
-
env,
|
|
570
672
|
runId: hook.runId,
|
|
571
673
|
hookId: hook.hookId
|
|
572
674
|
})
|
|
@@ -772,7 +874,7 @@ function SelectProvider(props) {
|
|
|
772
874
|
scope: __scopeSelect,
|
|
773
875
|
onNativeOptionAdd: handleNativeOptionAdd,
|
|
774
876
|
onNativeOptionRemove: handleNativeOptionRemove,
|
|
775
|
-
children: isFunction$
|
|
877
|
+
children: isFunction$2(internal_do_not_use_render) ? internal_do_not_use_render(context) : children
|
|
776
878
|
})
|
|
777
879
|
})
|
|
778
880
|
})
|
|
@@ -1619,10 +1721,10 @@ var SelectBubbleInput = /* @__PURE__ */ import_react.forwardRef(/* @__PURE__ */
|
|
|
1619
1721
|
children: [shouldShowPlaceholder(value) && !hasEmptyValueOption ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "" }) : null, Array.from(nativeOptions)]
|
|
1620
1722
|
}, nativeSelectKey);
|
|
1621
1723
|
}, "SelectBubbleInput"));
|
|
1622
|
-
function isFunction$
|
|
1724
|
+
function isFunction$2(value) {
|
|
1623
1725
|
return typeof value === "function";
|
|
1624
1726
|
}
|
|
1625
|
-
__name$1(isFunction$
|
|
1727
|
+
__name$1(isFunction$2, "isFunction");
|
|
1626
1728
|
function shouldShowPlaceholder(value) {
|
|
1627
1729
|
return value === "" || value === void 0;
|
|
1628
1730
|
}
|
|
@@ -1759,34 +1861,6 @@ function bulkCancelToastSeverity(summary) {
|
|
|
1759
1861
|
function shouldRetainSelectionAfterBulkCancel(result) {
|
|
1760
1862
|
return result.outcome === "failed" && result.retryable;
|
|
1761
1863
|
}
|
|
1762
|
-
// app/lib/client/listing-window.ts
|
|
1763
|
-
var windows = /* @__PURE__ */ new Map();
|
|
1764
|
-
function createWindow(periodMs) {
|
|
1765
|
-
const end = Date.now();
|
|
1766
|
-
return {
|
|
1767
|
-
startTime: new Date(end - periodMs).toISOString(),
|
|
1768
|
-
endTime: new Date(end).toISOString()
|
|
1769
|
-
};
|
|
1770
|
-
}
|
|
1771
|
-
/**
|
|
1772
|
-
* The frozen window for a period, creating it on first use. Subsequent calls
|
|
1773
|
-
* (including from a remounted component) return the same window until
|
|
1774
|
-
* `advanceListingWindow` replaces it.
|
|
1775
|
-
*/
|
|
1776
|
-
function getListingWindow(periodId, periodMs) {
|
|
1777
|
-
let window = windows.get(periodId);
|
|
1778
|
-
if (!window) {
|
|
1779
|
-
window = createWindow(periodMs);
|
|
1780
|
-
windows.set(periodId, window);
|
|
1781
|
-
}
|
|
1782
|
-
return window;
|
|
1783
|
-
}
|
|
1784
|
-
/** Slide the period's window forward to now (explicit refresh/reload). */
|
|
1785
|
-
function advanceListingWindow(periodId, periodMs) {
|
|
1786
|
-
const window = createWindow(periodMs);
|
|
1787
|
-
windows.set(periodId, window);
|
|
1788
|
-
return window;
|
|
1789
|
-
}
|
|
1790
1864
|
// app/lib/hooks/use-table-selection.ts
|
|
1791
1865
|
/**
|
|
1792
1866
|
* Hook for managing table row selection state.
|
|
@@ -1828,13 +1902,6 @@ function useTableSelection({ getItemId }) {
|
|
|
1828
1902
|
clearSelection,
|
|
1829
1903
|
selectAll
|
|
1830
1904
|
]);
|
|
1831
|
-
const selectById = (0, import_react.useCallback)((id) => {
|
|
1832
|
-
setSelectedIds((prev) => {
|
|
1833
|
-
const next = new Set(prev);
|
|
1834
|
-
next.add(id);
|
|
1835
|
-
return next;
|
|
1836
|
-
});
|
|
1837
|
-
}, []);
|
|
1838
1905
|
const deselectById = (0, import_react.useCallback)((id) => {
|
|
1839
1906
|
setSelectedIds((prev) => {
|
|
1840
1907
|
const next = new Set(prev);
|
|
@@ -1847,25 +1914,21 @@ function useTableSelection({ getItemId }) {
|
|
|
1847
1914
|
selectedIds,
|
|
1848
1915
|
isSelected,
|
|
1849
1916
|
toggleSelection,
|
|
1850
|
-
selectAll,
|
|
1851
1917
|
clearSelection,
|
|
1852
1918
|
toggleSelectAll,
|
|
1853
1919
|
selectionCount,
|
|
1854
1920
|
isAllSelected,
|
|
1855
1921
|
isSomeSelected,
|
|
1856
|
-
selectById,
|
|
1857
1922
|
deselectById
|
|
1858
1923
|
}), [
|
|
1859
1924
|
selectedIds,
|
|
1860
1925
|
isSelected,
|
|
1861
1926
|
toggleSelection,
|
|
1862
|
-
selectAll,
|
|
1863
1927
|
clearSelection,
|
|
1864
1928
|
toggleSelectAll,
|
|
1865
1929
|
selectionCount,
|
|
1866
1930
|
isAllSelected,
|
|
1867
1931
|
isSomeSelected,
|
|
1868
|
-
selectById,
|
|
1869
1932
|
deselectById
|
|
1870
1933
|
]);
|
|
1871
1934
|
}
|
|
@@ -1953,7 +2016,7 @@ function CheckboxProvider(props) {
|
|
|
1953
2016
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CheckboxProviderImpl, {
|
|
1954
2017
|
scope: __scopeCheckbox,
|
|
1955
2018
|
...context,
|
|
1956
|
-
children: isFunction(internal_do_not_use_render) ? internal_do_not_use_render(context) : children
|
|
2019
|
+
children: isFunction$1(internal_do_not_use_render) ? internal_do_not_use_render(context) : children
|
|
1957
2020
|
});
|
|
1958
2021
|
}
|
|
1959
2022
|
__name(CheckboxProvider, "CheckboxProvider");
|
|
@@ -2102,10 +2165,10 @@ var CheckboxBubbleInput = /* @__PURE__ */ import_react.forwardRef(/* @__PURE__ *
|
|
|
2102
2165
|
}
|
|
2103
2166
|
});
|
|
2104
2167
|
}, "CheckboxBubbleInput"));
|
|
2105
|
-
function isFunction(value) {
|
|
2168
|
+
function isFunction$1(value) {
|
|
2106
2169
|
return typeof value === "function";
|
|
2107
2170
|
}
|
|
2108
|
-
__name(isFunction, "isFunction");
|
|
2171
|
+
__name(isFunction$1, "isFunction");
|
|
2109
2172
|
function isIndeterminate(checked) {
|
|
2110
2173
|
return checked === "indeterminate";
|
|
2111
2174
|
}
|
|
@@ -2141,8 +2204,1255 @@ var Checkbox = import_react.forwardRef(({ className, checked, indeterminate, onC
|
|
|
2141
2204
|
});
|
|
2142
2205
|
});
|
|
2143
2206
|
Checkbox.displayName = "Checkbox";
|
|
2207
|
+
// ../../node_modules/.bun/use-sync-external-store@1.7.0+4bcfe187168658ad/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.js
|
|
2208
|
+
/**
|
|
2209
|
+
* @license React
|
|
2210
|
+
* use-sync-external-store-shim.production.js
|
|
2211
|
+
*
|
|
2212
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2213
|
+
*
|
|
2214
|
+
* This source code is licensed under the MIT license found in the
|
|
2215
|
+
* LICENSE file in the root directory of this source tree.
|
|
2216
|
+
*/
|
|
2217
|
+
var require_use_sync_external_store_shim_production = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
2218
|
+
var React = require_react();
|
|
2219
|
+
function is(x, y) {
|
|
2220
|
+
return x === y && (0 !== x || 1 / x === 1 / y) || x !== x && y !== y;
|
|
2221
|
+
}
|
|
2222
|
+
var objectIs = "function" === typeof Object.is ? Object.is : is;
|
|
2223
|
+
var useState = React.useState;
|
|
2224
|
+
var useEffect = React.useEffect;
|
|
2225
|
+
var useLayoutEffect = React.useLayoutEffect;
|
|
2226
|
+
var useDebugValue = React.useDebugValue;
|
|
2227
|
+
function useSyncExternalStore$2(subscribe, getSnapshot) {
|
|
2228
|
+
var value = getSnapshot(), _useState = useState({ inst: {
|
|
2229
|
+
value,
|
|
2230
|
+
getSnapshot
|
|
2231
|
+
} }), inst = _useState[0].inst, forceUpdate = _useState[1];
|
|
2232
|
+
useLayoutEffect(function() {
|
|
2233
|
+
inst.value = value;
|
|
2234
|
+
inst.getSnapshot = getSnapshot;
|
|
2235
|
+
checkIfSnapshotChanged(inst) && forceUpdate({ inst });
|
|
2236
|
+
}, [
|
|
2237
|
+
subscribe,
|
|
2238
|
+
value,
|
|
2239
|
+
getSnapshot
|
|
2240
|
+
]);
|
|
2241
|
+
useEffect(function() {
|
|
2242
|
+
checkIfSnapshotChanged(inst) && forceUpdate({ inst });
|
|
2243
|
+
return subscribe(function() {
|
|
2244
|
+
checkIfSnapshotChanged(inst) && forceUpdate({ inst });
|
|
2245
|
+
});
|
|
2246
|
+
}, [subscribe]);
|
|
2247
|
+
useDebugValue(value);
|
|
2248
|
+
return value;
|
|
2249
|
+
}
|
|
2250
|
+
function checkIfSnapshotChanged(inst) {
|
|
2251
|
+
var latestGetSnapshot = inst.getSnapshot;
|
|
2252
|
+
inst = inst.value;
|
|
2253
|
+
try {
|
|
2254
|
+
var nextValue = latestGetSnapshot();
|
|
2255
|
+
return !objectIs(inst, nextValue);
|
|
2256
|
+
} catch (error) {
|
|
2257
|
+
return !0;
|
|
2258
|
+
}
|
|
2259
|
+
}
|
|
2260
|
+
function useSyncExternalStore$1(subscribe, getSnapshot) {
|
|
2261
|
+
return getSnapshot();
|
|
2262
|
+
}
|
|
2263
|
+
var shim = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? useSyncExternalStore$1 : useSyncExternalStore$2;
|
|
2264
|
+
exports.useSyncExternalStore = void 0 !== React.useSyncExternalStore ? React.useSyncExternalStore : shim;
|
|
2265
|
+
}));
|
|
2266
|
+
// ../../node_modules/.bun/dequal@2.0.3/node_modules/dequal/lite/index.mjs
|
|
2267
|
+
var import_shim = (/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2268
|
+
module.exports = require_use_sync_external_store_shim_production();
|
|
2269
|
+
})))();
|
|
2270
|
+
var has = Object.prototype.hasOwnProperty;
|
|
2271
|
+
function dequal(foo, bar) {
|
|
2272
|
+
var ctor, len;
|
|
2273
|
+
if (foo === bar) return true;
|
|
2274
|
+
if (foo && bar && (ctor = foo.constructor) === bar.constructor) {
|
|
2275
|
+
if (ctor === Date) return foo.getTime() === bar.getTime();
|
|
2276
|
+
if (ctor === RegExp) return foo.toString() === bar.toString();
|
|
2277
|
+
if (ctor === Array) {
|
|
2278
|
+
if ((len = foo.length) === bar.length) while (len-- && dequal(foo[len], bar[len]));
|
|
2279
|
+
return len === -1;
|
|
2280
|
+
}
|
|
2281
|
+
if (!ctor || typeof foo === "object") {
|
|
2282
|
+
len = 0;
|
|
2283
|
+
for (ctor in foo) {
|
|
2284
|
+
if (has.call(foo, ctor) && ++len && !has.call(bar, ctor)) return false;
|
|
2285
|
+
if (!(ctor in bar) || !dequal(foo[ctor], bar[ctor])) return false;
|
|
2286
|
+
}
|
|
2287
|
+
return Object.keys(bar).length === len;
|
|
2288
|
+
}
|
|
2289
|
+
}
|
|
2290
|
+
return foo !== foo && bar !== bar;
|
|
2291
|
+
}
|
|
2292
|
+
var SWRGlobalState = /* @__PURE__ */ new WeakMap();
|
|
2293
|
+
var noop = () => {};
|
|
2294
|
+
var OBJECT = Object;
|
|
2295
|
+
var isUndefined = (v) => v === void 0;
|
|
2296
|
+
var isFunction = (v) => typeof v == "function";
|
|
2297
|
+
var mergeObjects = (a, b) => ({
|
|
2298
|
+
...a,
|
|
2299
|
+
...b
|
|
2300
|
+
});
|
|
2301
|
+
var isPromiseLike = (x) => isFunction(x.then);
|
|
2302
|
+
var EMPTY_CACHE = {};
|
|
2303
|
+
var INITIAL_CACHE = {};
|
|
2304
|
+
var STR_UNDEFINED = "undefined";
|
|
2305
|
+
var isWindowDefined = typeof window != STR_UNDEFINED;
|
|
2306
|
+
var isDocumentDefined = typeof document != STR_UNDEFINED;
|
|
2307
|
+
var isLegacyDeno = isWindowDefined && "Deno" in window;
|
|
2308
|
+
var hasRequestAnimationFrame = () => isWindowDefined && typeof window["requestAnimationFrame"] != STR_UNDEFINED;
|
|
2309
|
+
var createCacheHelper = (cache, key) => {
|
|
2310
|
+
const state = SWRGlobalState.get(cache);
|
|
2311
|
+
return [
|
|
2312
|
+
() => !isUndefined(key) && cache.get(key) || EMPTY_CACHE,
|
|
2313
|
+
(info) => {
|
|
2314
|
+
if (!isUndefined(key)) {
|
|
2315
|
+
const prev = cache.get(key);
|
|
2316
|
+
if (!(key in INITIAL_CACHE)) INITIAL_CACHE[key] = prev;
|
|
2317
|
+
state[5](key, mergeObjects(prev, info), prev || EMPTY_CACHE);
|
|
2318
|
+
}
|
|
2319
|
+
},
|
|
2320
|
+
state[6],
|
|
2321
|
+
() => {
|
|
2322
|
+
if (!isUndefined(key)) {
|
|
2323
|
+
if (key in INITIAL_CACHE) return INITIAL_CACHE[key];
|
|
2324
|
+
}
|
|
2325
|
+
return !isUndefined(key) && cache.get(key) || EMPTY_CACHE;
|
|
2326
|
+
}
|
|
2327
|
+
];
|
|
2328
|
+
};
|
|
2329
|
+
/**
|
|
2330
|
+
* Due to the bug https://bugs.chromium.org/p/chromium/issues/detail?id=678075,
|
|
2331
|
+
* it's not reliable to detect if the browser is currently online or offline
|
|
2332
|
+
* based on `navigator.onLine`.
|
|
2333
|
+
* As a workaround, we always assume it's online on the first load, and change
|
|
2334
|
+
* the status upon `online` or `offline` events.
|
|
2335
|
+
*/ var online = true;
|
|
2336
|
+
var isOnline = () => online;
|
|
2337
|
+
var [onWindowEvent, offWindowEvent] = isWindowDefined && window.addEventListener ? [window.addEventListener.bind(window), window.removeEventListener.bind(window)] : [noop, noop];
|
|
2338
|
+
var isVisible = () => {
|
|
2339
|
+
const visibilityState = isDocumentDefined && document.visibilityState;
|
|
2340
|
+
return isUndefined(visibilityState) || visibilityState !== "hidden";
|
|
2341
|
+
};
|
|
2342
|
+
var initFocus = (callback) => {
|
|
2343
|
+
if (isDocumentDefined) document.addEventListener("visibilitychange", callback);
|
|
2344
|
+
onWindowEvent("focus", callback);
|
|
2345
|
+
return () => {
|
|
2346
|
+
if (isDocumentDefined) document.removeEventListener("visibilitychange", callback);
|
|
2347
|
+
offWindowEvent("focus", callback);
|
|
2348
|
+
};
|
|
2349
|
+
};
|
|
2350
|
+
var initReconnect = (callback) => {
|
|
2351
|
+
const onOnline = () => {
|
|
2352
|
+
online = true;
|
|
2353
|
+
callback();
|
|
2354
|
+
};
|
|
2355
|
+
const onOffline = () => {
|
|
2356
|
+
online = false;
|
|
2357
|
+
};
|
|
2358
|
+
onWindowEvent("online", onOnline);
|
|
2359
|
+
onWindowEvent("offline", onOffline);
|
|
2360
|
+
return () => {
|
|
2361
|
+
offWindowEvent("online", onOnline);
|
|
2362
|
+
offWindowEvent("offline", onOffline);
|
|
2363
|
+
};
|
|
2364
|
+
};
|
|
2365
|
+
var preset = {
|
|
2366
|
+
isOnline,
|
|
2367
|
+
isVisible
|
|
2368
|
+
};
|
|
2369
|
+
var defaultConfigOptions = {
|
|
2370
|
+
initFocus,
|
|
2371
|
+
initReconnect
|
|
2372
|
+
};
|
|
2373
|
+
var IS_REACT_LEGACY = !import_react.useId;
|
|
2374
|
+
var IS_SERVER = !isWindowDefined || isLegacyDeno;
|
|
2375
|
+
var rAF = (f) => hasRequestAnimationFrame() ? window["requestAnimationFrame"](f) : setTimeout(f, 1);
|
|
2376
|
+
var useIsomorphicLayoutEffect = IS_SERVER ? import_react.useEffect : import_react.useLayoutEffect;
|
|
2377
|
+
var navigatorConnection = typeof navigator !== "undefined" && navigator.connection;
|
|
2378
|
+
var slowConnection = !IS_SERVER && navigatorConnection && (["slow-2g", "2g"].includes(navigatorConnection.effectiveType) || navigatorConnection.saveData);
|
|
2379
|
+
var table = /* @__PURE__ */ new WeakMap();
|
|
2380
|
+
var getTypeName = (value) => OBJECT.prototype.toString.call(value);
|
|
2381
|
+
var isObjectTypeName = (typeName, type) => typeName === `[object ${type}]`;
|
|
2382
|
+
var counter = 0;
|
|
2383
|
+
var stableHash = (arg) => {
|
|
2384
|
+
const type = typeof arg;
|
|
2385
|
+
const typeName = getTypeName(arg);
|
|
2386
|
+
const isDate = isObjectTypeName(typeName, "Date");
|
|
2387
|
+
const isRegex = isObjectTypeName(typeName, "RegExp");
|
|
2388
|
+
const isPlainObject = isObjectTypeName(typeName, "Object");
|
|
2389
|
+
let result;
|
|
2390
|
+
let index;
|
|
2391
|
+
if (OBJECT(arg) === arg && !isDate && !isRegex) {
|
|
2392
|
+
result = table.get(arg);
|
|
2393
|
+
if (result) return result;
|
|
2394
|
+
result = ++counter + "~";
|
|
2395
|
+
table.set(arg, result);
|
|
2396
|
+
if (Array.isArray(arg)) {
|
|
2397
|
+
result = "@";
|
|
2398
|
+
for (index = 0; index < arg.length; index++) result += stableHash(arg[index]) + ",";
|
|
2399
|
+
table.set(arg, result);
|
|
2400
|
+
}
|
|
2401
|
+
if (isPlainObject) {
|
|
2402
|
+
result = "#";
|
|
2403
|
+
const keys = OBJECT.keys(arg).sort();
|
|
2404
|
+
while (!isUndefined(index = keys.pop())) if (!isUndefined(arg[index])) result += index + ":" + stableHash(arg[index]) + ",";
|
|
2405
|
+
table.set(arg, result);
|
|
2406
|
+
}
|
|
2407
|
+
} else result = isDate ? arg.toJSON() : type == "symbol" ? arg.toString() : type == "string" ? JSON.stringify(arg) : "" + arg;
|
|
2408
|
+
return result;
|
|
2409
|
+
};
|
|
2410
|
+
var serialize = (key) => {
|
|
2411
|
+
if (isFunction(key)) try {
|
|
2412
|
+
key = key();
|
|
2413
|
+
} catch (err) {
|
|
2414
|
+
key = "";
|
|
2415
|
+
}
|
|
2416
|
+
const args = key;
|
|
2417
|
+
key = typeof key == "string" ? key : (Array.isArray(key) ? key.length : key) ? stableHash(key) : "";
|
|
2418
|
+
return [key, args];
|
|
2419
|
+
};
|
|
2420
|
+
var __timestamp = 0;
|
|
2421
|
+
var getTimestamp = () => ++__timestamp;
|
|
2422
|
+
async function internalMutate(...args) {
|
|
2423
|
+
const [cache, _key, _data, _opts] = args;
|
|
2424
|
+
const options = mergeObjects({
|
|
2425
|
+
populateCache: true,
|
|
2426
|
+
throwOnError: true
|
|
2427
|
+
}, typeof _opts === "boolean" ? { revalidate: _opts } : _opts || {});
|
|
2428
|
+
let populateCache = options.populateCache;
|
|
2429
|
+
const rollbackOnErrorOption = options.rollbackOnError;
|
|
2430
|
+
let optimisticData = options.optimisticData;
|
|
2431
|
+
const rollbackOnError = (error) => {
|
|
2432
|
+
return typeof rollbackOnErrorOption === "function" ? rollbackOnErrorOption(error) : rollbackOnErrorOption !== false;
|
|
2433
|
+
};
|
|
2434
|
+
const throwOnError = options.throwOnError;
|
|
2435
|
+
if (isFunction(_key)) {
|
|
2436
|
+
const keyFilter = _key;
|
|
2437
|
+
const matchedKeys = [];
|
|
2438
|
+
const it = cache.keys();
|
|
2439
|
+
for (const key of it) if (!/^\$(inf|sub)\$/.test(key) && keyFilter(cache.get(key)._k)) matchedKeys.push(key);
|
|
2440
|
+
return Promise.all(matchedKeys.map(mutateByKey));
|
|
2441
|
+
}
|
|
2442
|
+
return mutateByKey(_key);
|
|
2443
|
+
async function mutateByKey(_k) {
|
|
2444
|
+
const [key] = serialize(_k);
|
|
2445
|
+
if (!key) return;
|
|
2446
|
+
const [get, set] = createCacheHelper(cache, key);
|
|
2447
|
+
const [EVENT_REVALIDATORS, MUTATION, FETCH, PRELOAD] = SWRGlobalState.get(cache);
|
|
2448
|
+
const startRevalidate = () => {
|
|
2449
|
+
const revalidators = EVENT_REVALIDATORS[key];
|
|
2450
|
+
if (isFunction(options.revalidate) ? options.revalidate(get().data, _k) : options.revalidate !== false) {
|
|
2451
|
+
delete FETCH[key];
|
|
2452
|
+
delete PRELOAD[key];
|
|
2453
|
+
if (revalidators && revalidators[0]) return revalidators[0](2).then(() => get().data);
|
|
2454
|
+
}
|
|
2455
|
+
return get().data;
|
|
2456
|
+
};
|
|
2457
|
+
if (args.length < 3) return startRevalidate();
|
|
2458
|
+
let data = _data;
|
|
2459
|
+
let error;
|
|
2460
|
+
let isError = false;
|
|
2461
|
+
const beforeMutationTs = getTimestamp();
|
|
2462
|
+
MUTATION[key] = [beforeMutationTs, 0];
|
|
2463
|
+
const hasOptimisticData = !isUndefined(optimisticData);
|
|
2464
|
+
const state = get();
|
|
2465
|
+
const displayedData = state.data;
|
|
2466
|
+
const currentData = state._c;
|
|
2467
|
+
const committedData = isUndefined(currentData) ? displayedData : currentData;
|
|
2468
|
+
if (hasOptimisticData) {
|
|
2469
|
+
optimisticData = isFunction(optimisticData) ? optimisticData(committedData, displayedData) : optimisticData;
|
|
2470
|
+
set({
|
|
2471
|
+
data: optimisticData,
|
|
2472
|
+
_c: committedData
|
|
2473
|
+
});
|
|
2474
|
+
}
|
|
2475
|
+
if (isFunction(data)) try {
|
|
2476
|
+
data = data(committedData);
|
|
2477
|
+
} catch (err) {
|
|
2478
|
+
error = err;
|
|
2479
|
+
isError = true;
|
|
2480
|
+
}
|
|
2481
|
+
if (data && isPromiseLike(data)) {
|
|
2482
|
+
data = await data.catch((err) => {
|
|
2483
|
+
error = err;
|
|
2484
|
+
isError = true;
|
|
2485
|
+
});
|
|
2486
|
+
if (beforeMutationTs !== MUTATION[key][0]) {
|
|
2487
|
+
if (isError) throw error;
|
|
2488
|
+
return data;
|
|
2489
|
+
} else if (isError && hasOptimisticData && rollbackOnError(error)) {
|
|
2490
|
+
populateCache = true;
|
|
2491
|
+
set({
|
|
2492
|
+
data: committedData,
|
|
2493
|
+
_c: void 0
|
|
2494
|
+
});
|
|
2495
|
+
}
|
|
2496
|
+
}
|
|
2497
|
+
if (populateCache) {
|
|
2498
|
+
if (!isError) {
|
|
2499
|
+
if (isFunction(populateCache)) set({
|
|
2500
|
+
data: populateCache(data, committedData),
|
|
2501
|
+
error: void 0,
|
|
2502
|
+
_c: void 0
|
|
2503
|
+
});
|
|
2504
|
+
else set({
|
|
2505
|
+
data,
|
|
2506
|
+
error: void 0,
|
|
2507
|
+
_c: void 0
|
|
2508
|
+
});
|
|
2509
|
+
}
|
|
2510
|
+
}
|
|
2511
|
+
MUTATION[key][1] = getTimestamp();
|
|
2512
|
+
Promise.resolve(startRevalidate()).then(() => {
|
|
2513
|
+
set({ _c: void 0 });
|
|
2514
|
+
});
|
|
2515
|
+
if (isError) {
|
|
2516
|
+
if (throwOnError) throw error;
|
|
2517
|
+
return;
|
|
2518
|
+
}
|
|
2519
|
+
return data;
|
|
2520
|
+
}
|
|
2521
|
+
}
|
|
2522
|
+
var revalidateAllKeys = (revalidators, type) => {
|
|
2523
|
+
for (const key in revalidators) if (revalidators[key][0]) revalidators[key][0](type);
|
|
2524
|
+
};
|
|
2525
|
+
var initCache = (provider, options) => {
|
|
2526
|
+
if (!SWRGlobalState.has(provider)) {
|
|
2527
|
+
const opts = mergeObjects(defaultConfigOptions, options);
|
|
2528
|
+
const EVENT_REVALIDATORS = Object.create(null);
|
|
2529
|
+
const mutate = internalMutate.bind(void 0, provider);
|
|
2530
|
+
let unmount = noop;
|
|
2531
|
+
const subscriptions = Object.create(null);
|
|
2532
|
+
const subscribe = (key, callback) => {
|
|
2533
|
+
const subs = subscriptions[key] || [];
|
|
2534
|
+
subscriptions[key] = subs;
|
|
2535
|
+
subs.push(callback);
|
|
2536
|
+
return () => {
|
|
2537
|
+
const index = subs.indexOf(callback);
|
|
2538
|
+
if (index >= 0) {
|
|
2539
|
+
subs[index] = subs[subs.length - 1];
|
|
2540
|
+
subs.pop();
|
|
2541
|
+
}
|
|
2542
|
+
};
|
|
2543
|
+
};
|
|
2544
|
+
const setter = (key, value, prev) => {
|
|
2545
|
+
provider.set(key, value);
|
|
2546
|
+
const subs = subscriptions[key];
|
|
2547
|
+
if (subs) for (const fn of subs) fn(value, prev);
|
|
2548
|
+
};
|
|
2549
|
+
const unload = (unloadOptions) => {
|
|
2550
|
+
const state = SWRGlobalState.get(provider);
|
|
2551
|
+
const [, MUTATION, FETCH, PRELOAD] = state;
|
|
2552
|
+
const ts = getTimestamp();
|
|
2553
|
+
state[8]++;
|
|
2554
|
+
for (const key in FETCH) delete FETCH[key];
|
|
2555
|
+
for (const key in PRELOAD) delete PRELOAD[key];
|
|
2556
|
+
for (const key in MUTATION) MUTATION[key] = [ts, ts];
|
|
2557
|
+
const emptyState = {};
|
|
2558
|
+
for (const key of [...provider.keys()]) {
|
|
2559
|
+
const prev = provider.get(key);
|
|
2560
|
+
provider.delete(key);
|
|
2561
|
+
const subs = subscriptions[key];
|
|
2562
|
+
if (subs) for (const fn of subs) fn(emptyState, prev);
|
|
2563
|
+
}
|
|
2564
|
+
const revalidate = !unloadOptions || unloadOptions.revalidate !== false;
|
|
2565
|
+
for (const key in EVENT_REVALIDATORS) {
|
|
2566
|
+
const revalidators = EVENT_REVALIDATORS[key];
|
|
2567
|
+
for (let i = 0; i < revalidators.length; i++) revalidators[i](4, { revalidate: revalidate && !i });
|
|
2568
|
+
}
|
|
2569
|
+
};
|
|
2570
|
+
const initProvider = () => {
|
|
2571
|
+
if (!SWRGlobalState.has(provider)) {
|
|
2572
|
+
SWRGlobalState.set(provider, [
|
|
2573
|
+
EVENT_REVALIDATORS,
|
|
2574
|
+
Object.create(null),
|
|
2575
|
+
Object.create(null),
|
|
2576
|
+
Object.create(null),
|
|
2577
|
+
mutate,
|
|
2578
|
+
setter,
|
|
2579
|
+
subscribe,
|
|
2580
|
+
unload,
|
|
2581
|
+
0
|
|
2582
|
+
]);
|
|
2583
|
+
if (!IS_SERVER) {
|
|
2584
|
+
const releaseFocus = opts.initFocus(setTimeout.bind(void 0, revalidateAllKeys.bind(void 0, EVENT_REVALIDATORS, 0)));
|
|
2585
|
+
const releaseReconnect = opts.initReconnect(setTimeout.bind(void 0, revalidateAllKeys.bind(void 0, EVENT_REVALIDATORS, 1)));
|
|
2586
|
+
unmount = () => {
|
|
2587
|
+
releaseFocus && releaseFocus();
|
|
2588
|
+
releaseReconnect && releaseReconnect();
|
|
2589
|
+
SWRGlobalState.delete(provider);
|
|
2590
|
+
};
|
|
2591
|
+
}
|
|
2592
|
+
}
|
|
2593
|
+
};
|
|
2594
|
+
initProvider();
|
|
2595
|
+
return [
|
|
2596
|
+
provider,
|
|
2597
|
+
mutate,
|
|
2598
|
+
initProvider,
|
|
2599
|
+
unmount,
|
|
2600
|
+
unload
|
|
2601
|
+
];
|
|
2602
|
+
}
|
|
2603
|
+
const state = SWRGlobalState.get(provider);
|
|
2604
|
+
return [
|
|
2605
|
+
provider,
|
|
2606
|
+
state[4],
|
|
2607
|
+
void 0,
|
|
2608
|
+
void 0,
|
|
2609
|
+
state[7]
|
|
2610
|
+
];
|
|
2611
|
+
};
|
|
2612
|
+
var onErrorRetry = (_, __, config, revalidate, opts) => {
|
|
2613
|
+
const maxRetryCount = config.errorRetryCount;
|
|
2614
|
+
const currentRetryCount = opts.retryCount;
|
|
2615
|
+
const timeout = ~~((Math.random() + .5) * (1 << (currentRetryCount < 8 ? currentRetryCount : 8))) * config.errorRetryInterval;
|
|
2616
|
+
if (!isUndefined(maxRetryCount) && currentRetryCount > maxRetryCount) return;
|
|
2617
|
+
setTimeout(revalidate, timeout, opts);
|
|
2618
|
+
};
|
|
2619
|
+
var compare = dequal;
|
|
2620
|
+
var [cache, mutate, , , unload] = initCache(/* @__PURE__ */ new Map());
|
|
2621
|
+
var defaultConfig = mergeObjects({
|
|
2622
|
+
onLoadingSlow: noop,
|
|
2623
|
+
onSuccess: noop,
|
|
2624
|
+
onError: noop,
|
|
2625
|
+
onErrorRetry,
|
|
2626
|
+
onDiscarded: noop,
|
|
2627
|
+
revalidateOnFocus: true,
|
|
2628
|
+
revalidateOnReconnect: true,
|
|
2629
|
+
revalidateIfStale: true,
|
|
2630
|
+
shouldRetryOnError: true,
|
|
2631
|
+
errorRetryInterval: slowConnection ? 1e4 : 5e3,
|
|
2632
|
+
focusThrottleInterval: 5e3,
|
|
2633
|
+
dedupingInterval: 2e3,
|
|
2634
|
+
loadingTimeout: slowConnection ? 5e3 : 3e3,
|
|
2635
|
+
compare,
|
|
2636
|
+
isPaused: () => false,
|
|
2637
|
+
cache,
|
|
2638
|
+
mutate,
|
|
2639
|
+
unload,
|
|
2640
|
+
fallback: {}
|
|
2641
|
+
}, preset);
|
|
2642
|
+
var mergeConfigs = (a, b) => {
|
|
2643
|
+
const v = mergeObjects(a, b);
|
|
2644
|
+
if (b) {
|
|
2645
|
+
const { use: u1, fallback: f1, cacheData: c1 } = a;
|
|
2646
|
+
const { use: u2, fallback: f2, cacheData: c2 } = b;
|
|
2647
|
+
if (u1 && u2) v.use = u1.concat(u2);
|
|
2648
|
+
if (f1 && f2) v.fallback = mergeObjects(f1, f2);
|
|
2649
|
+
if (c1 && c2) v.cacheData = mergeObjects(c1, c2);
|
|
2650
|
+
}
|
|
2651
|
+
return v;
|
|
2652
|
+
};
|
|
2653
|
+
var SWRConfigContext = (0, import_react.createContext)({});
|
|
2654
|
+
var SWRConfig$1 = (props) => {
|
|
2655
|
+
const { value } = props;
|
|
2656
|
+
const parentConfig = (0, import_react.useContext)(SWRConfigContext);
|
|
2657
|
+
const isFunctionalConfig = isFunction(value);
|
|
2658
|
+
const config = (0, import_react.useMemo)(() => isFunctionalConfig ? value(parentConfig) : value, [
|
|
2659
|
+
isFunctionalConfig,
|
|
2660
|
+
parentConfig,
|
|
2661
|
+
value
|
|
2662
|
+
]);
|
|
2663
|
+
const extendedConfig = (0, import_react.useMemo)(() => isFunctionalConfig ? config : mergeConfigs(parentConfig, config), [
|
|
2664
|
+
isFunctionalConfig,
|
|
2665
|
+
parentConfig,
|
|
2666
|
+
config
|
|
2667
|
+
]);
|
|
2668
|
+
const provider = config && config.provider;
|
|
2669
|
+
const cacheContextRef = (0, import_react.useRef)(void 0);
|
|
2670
|
+
if (provider && !cacheContextRef.current) cacheContextRef.current = initCache(provider(extendedConfig.cache || cache), config);
|
|
2671
|
+
const cacheContext = cacheContextRef.current;
|
|
2672
|
+
if (cacheContext) {
|
|
2673
|
+
extendedConfig.cache = cacheContext[0];
|
|
2674
|
+
extendedConfig.mutate = cacheContext[1];
|
|
2675
|
+
extendedConfig.unload = cacheContext[4];
|
|
2676
|
+
}
|
|
2677
|
+
useIsomorphicLayoutEffect(() => {
|
|
2678
|
+
if (cacheContext) {
|
|
2679
|
+
cacheContext[2] && cacheContext[2]();
|
|
2680
|
+
return cacheContext[3];
|
|
2681
|
+
}
|
|
2682
|
+
}, []);
|
|
2683
|
+
return (0, import_react.createElement)(SWRConfigContext.Provider, mergeObjects(props, { value: extendedConfig }));
|
|
2684
|
+
};
|
|
2685
|
+
// ../../node_modules/.bun/swr@2.5.1+4bcfe187168658ad/node_modules/swr/dist/_internal/constants.mjs
|
|
2686
|
+
var INFINITE_PREFIX = "$inf$";
|
|
2687
|
+
// ../../node_modules/.bun/swr@2.5.1+4bcfe187168658ad/node_modules/swr/dist/_internal/index.mjs
|
|
2688
|
+
var enableDevtools = isWindowDefined && window.__SWR_DEVTOOLS_USE__;
|
|
2689
|
+
var use$1 = enableDevtools ? window.__SWR_DEVTOOLS_USE__ : [];
|
|
2690
|
+
var setupDevTools = () => {
|
|
2691
|
+
if (enableDevtools) window.__SWR_DEVTOOLS_REACT__ = import_react.default;
|
|
2692
|
+
};
|
|
2693
|
+
var normalize = (args) => {
|
|
2694
|
+
return isFunction(args[1]) ? [
|
|
2695
|
+
args[0],
|
|
2696
|
+
args[1],
|
|
2697
|
+
args[2] || {}
|
|
2698
|
+
] : [
|
|
2699
|
+
args[0],
|
|
2700
|
+
null,
|
|
2701
|
+
(args[1] === null ? args[2] : args[1]) || {}
|
|
2702
|
+
];
|
|
2703
|
+
};
|
|
2704
|
+
var useSWRConfig = () => {
|
|
2705
|
+
const parentConfig = (0, import_react.useContext)(SWRConfigContext);
|
|
2706
|
+
return (0, import_react.useMemo)(() => mergeObjects(defaultConfig, parentConfig), [parentConfig]);
|
|
2707
|
+
};
|
|
2708
|
+
var middleware = (useSWRNext) => (key_, fetcher_, config) => {
|
|
2709
|
+
return useSWRNext(key_, fetcher_ && ((...args) => {
|
|
2710
|
+
const [key] = serialize(key_);
|
|
2711
|
+
const [, , , PRELOAD] = SWRGlobalState.get(cache);
|
|
2712
|
+
if (key.startsWith("$inf$")) return fetcher_(...args);
|
|
2713
|
+
const req = PRELOAD[key];
|
|
2714
|
+
if (isUndefined(req)) return fetcher_(...args);
|
|
2715
|
+
delete PRELOAD[key];
|
|
2716
|
+
return req;
|
|
2717
|
+
}), config);
|
|
2718
|
+
};
|
|
2719
|
+
var BUILT_IN_MIDDLEWARE = use$1.concat(middleware);
|
|
2720
|
+
var withArgs = (hook) => {
|
|
2721
|
+
return function useSWRArgs(...args) {
|
|
2722
|
+
const fallbackConfig = useSWRConfig();
|
|
2723
|
+
const [key, fn, _config] = normalize(args);
|
|
2724
|
+
const config = mergeConfigs(fallbackConfig, _config);
|
|
2725
|
+
let next = hook;
|
|
2726
|
+
const { use } = config;
|
|
2727
|
+
const middleware = (use || []).concat(BUILT_IN_MIDDLEWARE);
|
|
2728
|
+
for (let i = middleware.length; i--;) next = middleware[i](next);
|
|
2729
|
+
return next(key, fn || config.fetcher || null, config);
|
|
2730
|
+
};
|
|
2731
|
+
};
|
|
2732
|
+
var subscribeCallback = (key, callbacks, callback) => {
|
|
2733
|
+
const keyedRevalidators = callbacks[key] || (callbacks[key] = []);
|
|
2734
|
+
keyedRevalidators.push(callback);
|
|
2735
|
+
return () => {
|
|
2736
|
+
const index = keyedRevalidators.indexOf(callback);
|
|
2737
|
+
if (index >= 0) {
|
|
2738
|
+
keyedRevalidators[index] = keyedRevalidators[keyedRevalidators.length - 1];
|
|
2739
|
+
keyedRevalidators.pop();
|
|
2740
|
+
}
|
|
2741
|
+
};
|
|
2742
|
+
};
|
|
2743
|
+
var withMiddleware = (useSWR, middleware) => {
|
|
2744
|
+
return (...args) => {
|
|
2745
|
+
const [key, fn, config] = normalize(args);
|
|
2746
|
+
const uses = (config.use || []).concat(middleware);
|
|
2747
|
+
return useSWR(key, fn, {
|
|
2748
|
+
...config,
|
|
2749
|
+
use: uses
|
|
2750
|
+
});
|
|
2751
|
+
};
|
|
2752
|
+
};
|
|
2753
|
+
setupDevTools();
|
|
2754
|
+
// ../../node_modules/.bun/swr@2.5.1+4bcfe187168658ad/node_modules/swr/dist/use-swr-emll9s78.mjs
|
|
2755
|
+
var use = import_react.use || ((thenable) => {
|
|
2756
|
+
switch (thenable.status) {
|
|
2757
|
+
case "pending": throw thenable;
|
|
2758
|
+
case "fulfilled": return thenable.value;
|
|
2759
|
+
case "rejected": throw thenable.reason;
|
|
2760
|
+
default:
|
|
2761
|
+
thenable.status = "pending";
|
|
2762
|
+
thenable.then((v) => {
|
|
2763
|
+
thenable.status = "fulfilled";
|
|
2764
|
+
thenable.value = v;
|
|
2765
|
+
}, (e) => {
|
|
2766
|
+
thenable.status = "rejected";
|
|
2767
|
+
thenable.reason = e;
|
|
2768
|
+
});
|
|
2769
|
+
throw thenable;
|
|
2770
|
+
}
|
|
2771
|
+
});
|
|
2772
|
+
var WITH_DEDUPE = { dedupe: true };
|
|
2773
|
+
var isCacheDataConsumed = (consumedCacheData, cacheData, key) => {
|
|
2774
|
+
var _consumedCacheData_get;
|
|
2775
|
+
return cacheData ? ((_consumedCacheData_get = consumedCacheData.get(cacheData)) == null ? void 0 : _consumedCacheData_get.has(key)) === true : false;
|
|
2776
|
+
};
|
|
2777
|
+
var markCacheDataConsumed = (consumedCacheData, cacheData, key) => {
|
|
2778
|
+
if (!cacheData) return;
|
|
2779
|
+
let consumedKeys = consumedCacheData.get(cacheData);
|
|
2780
|
+
if (!consumedKeys) {
|
|
2781
|
+
consumedKeys = /* @__PURE__ */ new Set();
|
|
2782
|
+
consumedCacheData.set(cacheData, consumedKeys);
|
|
2783
|
+
}
|
|
2784
|
+
consumedKeys.add(key);
|
|
2785
|
+
};
|
|
2786
|
+
var commitCacheData = ({ value, getCacheData, canCommit, setCache }) => {
|
|
2787
|
+
const commit = (state) => {
|
|
2788
|
+
if (canCommit() && isUndefined(getCacheData())) setCache(state);
|
|
2789
|
+
};
|
|
2790
|
+
Promise.resolve(value).then((data) => {
|
|
2791
|
+
commit({
|
|
2792
|
+
data,
|
|
2793
|
+
error: void 0
|
|
2794
|
+
});
|
|
2795
|
+
}, (error) => {
|
|
2796
|
+
commit({ error });
|
|
2797
|
+
});
|
|
2798
|
+
};
|
|
2799
|
+
var resolvedUndef = Promise.resolve(void 0);
|
|
2800
|
+
resolvedUndef.status = "fulfilled";
|
|
2801
|
+
resolvedUndef.value = void 0;
|
|
2802
|
+
var sub = () => noop;
|
|
2803
|
+
/**
|
|
2804
|
+
* The core implementation of the useSWR hook.
|
|
2805
|
+
*
|
|
2806
|
+
* This is the main handler function that implements all SWR functionality including
|
|
2807
|
+
* data fetching, caching, revalidation, error handling, and state management.
|
|
2808
|
+
* It manages the complete lifecycle of SWR requests from initialization through
|
|
2809
|
+
* cleanup.
|
|
2810
|
+
*
|
|
2811
|
+
* Key responsibilities:
|
|
2812
|
+
* - Key serialization and normalization
|
|
2813
|
+
* - Cache state management and synchronization
|
|
2814
|
+
* - Automatic and manual revalidation
|
|
2815
|
+
* - Error handling and retry logic
|
|
2816
|
+
* - Suspense integration
|
|
2817
|
+
* - Loading state management
|
|
2818
|
+
* - Effect cleanup and memory management
|
|
2819
|
+
*
|
|
2820
|
+
* @template Data - The type of data returned by the fetcher
|
|
2821
|
+
* @template Error - The type of error that can be thrown
|
|
2822
|
+
*
|
|
2823
|
+
* @param _key - The SWR key (string, array, object, function, or falsy)
|
|
2824
|
+
* @param fetcher - The fetcher function to retrieve data, or null to disable fetching
|
|
2825
|
+
* @param config - Complete SWR configuration object with both public and internal options
|
|
2826
|
+
*
|
|
2827
|
+
* @returns SWRResponse object containing data, error, mutate function, and loading states
|
|
2828
|
+
*
|
|
2829
|
+
* @internal This is the internal implementation. Use `useSWR` instead.
|
|
2830
|
+
*/ var useSWRHandler = (_key, fetcher, config) => {
|
|
2831
|
+
const { cache, compare, suspense, fallbackData, revalidateOnMount, revalidateIfStale, refreshInterval, refreshWhenHidden, refreshWhenOffline, keepPreviousData, strictServerPrefetchWarning } = config;
|
|
2832
|
+
const [EVENT_REVALIDATORS, MUTATION, FETCH, PRELOAD] = SWRGlobalState.get(cache);
|
|
2833
|
+
const [key, fnArg] = serialize(_key);
|
|
2834
|
+
const initialMountedRef = (0, import_react.useRef)(false);
|
|
2835
|
+
const unmountedRef = (0, import_react.useRef)(false);
|
|
2836
|
+
const keyRef = (0, import_react.useRef)(key);
|
|
2837
|
+
const fetcherRef = (0, import_react.useRef)(fetcher);
|
|
2838
|
+
const configRef = (0, import_react.useRef)(config);
|
|
2839
|
+
const getConfig = () => configRef.current;
|
|
2840
|
+
const isActive = () => getConfig().isVisible() && getConfig().isOnline();
|
|
2841
|
+
const [getCache, setCache, subscribeCache, getInitialCache] = createCacheHelper(cache, key);
|
|
2842
|
+
const stateDependencies = (0, import_react.useRef)({}).current;
|
|
2843
|
+
const fallback = isUndefined(fallbackData) ? isUndefined(config.fallback) ? void 0 : config.fallback[key] : fallbackData;
|
|
2844
|
+
const serverCacheData = config.cacheData;
|
|
2845
|
+
const configCacheData = !key ? void 0 : serverCacheData == null ? void 0 : serverCacheData[key];
|
|
2846
|
+
const req = key ? PRELOAD[key] : void 0;
|
|
2847
|
+
const hasCacheData = isUndefined(req) && !isUndefined(configCacheData);
|
|
2848
|
+
const preloadedData = hasCacheData ? configCacheData : req;
|
|
2849
|
+
const isEqual = (prev, current) => {
|
|
2850
|
+
for (const _ in stateDependencies) {
|
|
2851
|
+
const t = _;
|
|
2852
|
+
if (t === "data") {
|
|
2853
|
+
if (!compare(prev[t], current[t])) {
|
|
2854
|
+
if (!isUndefined(prev[t])) return false;
|
|
2855
|
+
if (!compare(returnedData, current[t])) return false;
|
|
2856
|
+
}
|
|
2857
|
+
} else if (current[t] !== prev[t]) return false;
|
|
2858
|
+
}
|
|
2859
|
+
return true;
|
|
2860
|
+
};
|
|
2861
|
+
const isInitialMount = !initialMountedRef.current;
|
|
2862
|
+
const getSnapshot = (0, import_react.useMemo)(() => {
|
|
2863
|
+
const cachedData = getCache();
|
|
2864
|
+
const initialData = getInitialCache();
|
|
2865
|
+
const getSelectedCache = (state) => {
|
|
2866
|
+
const snapshot = mergeObjects(state);
|
|
2867
|
+
delete snapshot._k;
|
|
2868
|
+
if (!(() => {
|
|
2869
|
+
if (!key) return false;
|
|
2870
|
+
if (!fetcher) return false;
|
|
2871
|
+
if (getConfig().isPaused()) return false;
|
|
2872
|
+
if (isInitialMount && !isUndefined(revalidateOnMount)) return revalidateOnMount;
|
|
2873
|
+
const data = !isUndefined(fallback) ? fallback : snapshot.data;
|
|
2874
|
+
if (suspense && hasCacheData && isUndefined(data)) return false;
|
|
2875
|
+
if (suspense) return isUndefined(data) || revalidateIfStale;
|
|
2876
|
+
return isUndefined(data) || revalidateIfStale;
|
|
2877
|
+
})()) return snapshot;
|
|
2878
|
+
return {
|
|
2879
|
+
isValidating: true,
|
|
2880
|
+
isLoading: true,
|
|
2881
|
+
...snapshot
|
|
2882
|
+
};
|
|
2883
|
+
};
|
|
2884
|
+
const clientSnapshot = getSelectedCache(cachedData);
|
|
2885
|
+
const serverSnapshot = cachedData === initialData ? clientSnapshot : getSelectedCache(initialData);
|
|
2886
|
+
let memorizedSnapshot = clientSnapshot;
|
|
2887
|
+
return [() => {
|
|
2888
|
+
const newSnapshot = getSelectedCache(getCache());
|
|
2889
|
+
if (isEqual(newSnapshot, memorizedSnapshot)) {
|
|
2890
|
+
memorizedSnapshot.data = newSnapshot.data;
|
|
2891
|
+
memorizedSnapshot.isLoading = newSnapshot.isLoading;
|
|
2892
|
+
memorizedSnapshot.isValidating = newSnapshot.isValidating;
|
|
2893
|
+
memorizedSnapshot.error = newSnapshot.error;
|
|
2894
|
+
return memorizedSnapshot;
|
|
2895
|
+
} else {
|
|
2896
|
+
memorizedSnapshot = newSnapshot;
|
|
2897
|
+
return newSnapshot;
|
|
2898
|
+
}
|
|
2899
|
+
}, () => serverSnapshot];
|
|
2900
|
+
}, [cache, key]);
|
|
2901
|
+
const cached = (0, import_shim.useSyncExternalStore)((0, import_react.useCallback)((callback) => subscribeCache(key, (current, prev) => {
|
|
2902
|
+
if (!isEqual(prev, current)) callback();
|
|
2903
|
+
}), [cache, key]), getSnapshot[0], getSnapshot[1]);
|
|
2904
|
+
const hasRevalidator = EVENT_REVALIDATORS[key] && EVENT_REVALIDATORS[key].length > 0;
|
|
2905
|
+
const cachedData = cached.data;
|
|
2906
|
+
let data = isUndefined(cachedData) ? fallback && isPromiseLike(fallback) ? use(fallback) : fallback : cachedData;
|
|
2907
|
+
const error = cached.error;
|
|
2908
|
+
const laggyDataRef = (0, import_react.useRef)(data);
|
|
2909
|
+
const consumedCacheDataRef = (0, import_react.useRef)(void 0);
|
|
2910
|
+
let consumedCacheData = consumedCacheDataRef.current;
|
|
2911
|
+
if (!consumedCacheData) {
|
|
2912
|
+
consumedCacheData = /* @__PURE__ */ new WeakMap();
|
|
2913
|
+
consumedCacheDataRef.current = consumedCacheData;
|
|
2914
|
+
}
|
|
2915
|
+
const preloadCacheRef = (0, import_react.useRef)(null);
|
|
2916
|
+
let returnedData = keepPreviousData ? isUndefined(cachedData) ? isUndefined(laggyDataRef.current) ? data : laggyDataRef.current : cachedData : data;
|
|
2917
|
+
const hasKeyButNoData = key && isUndefined(data);
|
|
2918
|
+
const hydrationRef = (0, import_react.useRef)(null);
|
|
2919
|
+
!IS_SERVER && (0, import_shim.useSyncExternalStore)(sub, () => {
|
|
2920
|
+
hydrationRef.current = false;
|
|
2921
|
+
return hydrationRef;
|
|
2922
|
+
}, () => {
|
|
2923
|
+
hydrationRef.current = true;
|
|
2924
|
+
return hydrationRef;
|
|
2925
|
+
});
|
|
2926
|
+
const isHydration = hydrationRef.current;
|
|
2927
|
+
if (strictServerPrefetchWarning && isHydration && !suspense && hasKeyButNoData) console.warn(`Missing pre-initiated data for serialized key "${key}" during server-side rendering. Data fetching should be initiated on the server and provided to SWR via fallback data. You can set "strictServerPrefetchWarning: false" to disable this warning.`);
|
|
2928
|
+
const shouldDoInitialRevalidation = (() => {
|
|
2929
|
+
if (!key || !fetcher) return false;
|
|
2930
|
+
if (getConfig().isPaused()) return false;
|
|
2931
|
+
if (hasRevalidator && !isUndefined(error)) return false;
|
|
2932
|
+
if (isInitialMount && !isUndefined(revalidateOnMount)) return revalidateOnMount;
|
|
2933
|
+
if (suspense && hasCacheData && hasKeyButNoData) return false;
|
|
2934
|
+
if (suspense) return isUndefined(data) ? false : revalidateIfStale;
|
|
2935
|
+
return isUndefined(data) || revalidateIfStale;
|
|
2936
|
+
})();
|
|
2937
|
+
const defaultValidatingState = isInitialMount && shouldDoInitialRevalidation;
|
|
2938
|
+
const isValidating = isUndefined(cached.isValidating) ? defaultValidatingState : cached.isValidating;
|
|
2939
|
+
const isLoading = isUndefined(cached.isLoading) ? defaultValidatingState : cached.isLoading;
|
|
2940
|
+
const revalidate = (0, import_react.useCallback)(async (revalidateOpts) => {
|
|
2941
|
+
const currentFetcher = fetcherRef.current;
|
|
2942
|
+
if (!key || !currentFetcher || unmountedRef.current || getConfig().isPaused()) return false;
|
|
2943
|
+
let newData;
|
|
2944
|
+
let startAt;
|
|
2945
|
+
let loading = true;
|
|
2946
|
+
const opts = revalidateOpts || {};
|
|
2947
|
+
const shouldStartNewRequest = !FETCH[key] || !opts.dedupe;
|
|
2948
|
+
const shouldUseRSCPreload = hasCacheData && !isCacheDataConsumed(consumedCacheData, serverCacheData, key) && !isUndefined(preloadedData) && isUndefined(getCache().data);
|
|
2949
|
+
const callbackSafeguard = () => {
|
|
2950
|
+
if (IS_REACT_LEGACY) return !unmountedRef.current && key === keyRef.current && initialMountedRef.current;
|
|
2951
|
+
return key === keyRef.current;
|
|
2952
|
+
};
|
|
2953
|
+
const finalState = {
|
|
2954
|
+
isValidating: false,
|
|
2955
|
+
isLoading: false
|
|
2956
|
+
};
|
|
2957
|
+
const finishRequestAndUpdateState = () => {
|
|
2958
|
+
setCache(finalState);
|
|
2959
|
+
};
|
|
2960
|
+
const cleanupState = () => {
|
|
2961
|
+
const requestInfo = FETCH[key];
|
|
2962
|
+
if (requestInfo && requestInfo[1] === startAt) delete FETCH[key];
|
|
2963
|
+
};
|
|
2964
|
+
const initialState = { isValidating: true };
|
|
2965
|
+
if (isUndefined(getCache().data)) initialState.isLoading = true;
|
|
2966
|
+
try {
|
|
2967
|
+
if (shouldStartNewRequest) {
|
|
2968
|
+
setCache(initialState);
|
|
2969
|
+
if (config.loadingTimeout && isUndefined(getCache().data)) setTimeout(() => {
|
|
2970
|
+
if (loading && callbackSafeguard()) getConfig().onLoadingSlow(key, config);
|
|
2971
|
+
}, config.loadingTimeout);
|
|
2972
|
+
if (shouldUseRSCPreload) markCacheDataConsumed(consumedCacheData, serverCacheData, key);
|
|
2973
|
+
FETCH[key] = [shouldUseRSCPreload ? preloadedData : currentFetcher(fnArg), getTimestamp()];
|
|
2974
|
+
if (shouldUseRSCPreload && PRELOAD[key]) delete PRELOAD[key];
|
|
2975
|
+
}
|
|
2976
|
+
[newData, startAt] = FETCH[key];
|
|
2977
|
+
newData = await newData;
|
|
2978
|
+
if (shouldStartNewRequest) setTimeout(cleanupState, config.dedupingInterval);
|
|
2979
|
+
if (!FETCH[key] || FETCH[key][1] !== startAt) {
|
|
2980
|
+
if (shouldStartNewRequest) {
|
|
2981
|
+
if (callbackSafeguard()) getConfig().onDiscarded(key);
|
|
2982
|
+
}
|
|
2983
|
+
return false;
|
|
2984
|
+
}
|
|
2985
|
+
finalState.error = void 0;
|
|
2986
|
+
const mutationInfo = MUTATION[key];
|
|
2987
|
+
if (!isUndefined(mutationInfo) && (startAt <= mutationInfo[0] || startAt <= mutationInfo[1] || mutationInfo[1] === 0)) {
|
|
2988
|
+
finishRequestAndUpdateState();
|
|
2989
|
+
if (shouldStartNewRequest) {
|
|
2990
|
+
if (callbackSafeguard()) getConfig().onDiscarded(key);
|
|
2991
|
+
}
|
|
2992
|
+
return false;
|
|
2993
|
+
}
|
|
2994
|
+
const cacheData = getCache().data;
|
|
2995
|
+
finalState.data = compare(cacheData, newData) ? cacheData : newData;
|
|
2996
|
+
if (shouldStartNewRequest) {
|
|
2997
|
+
if (callbackSafeguard()) getConfig().onSuccess(newData, key, config);
|
|
2998
|
+
}
|
|
2999
|
+
} catch (err) {
|
|
3000
|
+
cleanupState();
|
|
3001
|
+
const currentConfig = getConfig();
|
|
3002
|
+
const { shouldRetryOnError } = currentConfig;
|
|
3003
|
+
if (!currentConfig.isPaused()) {
|
|
3004
|
+
finalState.error = err;
|
|
3005
|
+
if (shouldStartNewRequest && callbackSafeguard()) {
|
|
3006
|
+
currentConfig.onError(err, key, currentConfig);
|
|
3007
|
+
if (shouldRetryOnError === true || isFunction(shouldRetryOnError) && shouldRetryOnError(err)) {
|
|
3008
|
+
if (!getConfig().revalidateOnFocus || !getConfig().revalidateOnReconnect || isActive()) currentConfig.onErrorRetry(err, key, currentConfig, (_opts) => {
|
|
3009
|
+
const revalidators = EVENT_REVALIDATORS[key];
|
|
3010
|
+
if (revalidators && revalidators[0]) revalidators[0](3, _opts);
|
|
3011
|
+
}, {
|
|
3012
|
+
retryCount: (opts.retryCount || 0) + 1,
|
|
3013
|
+
dedupe: true
|
|
3014
|
+
});
|
|
3015
|
+
}
|
|
3016
|
+
}
|
|
3017
|
+
}
|
|
3018
|
+
}
|
|
3019
|
+
loading = false;
|
|
3020
|
+
finishRequestAndUpdateState();
|
|
3021
|
+
return true;
|
|
3022
|
+
}, [key, cache]);
|
|
3023
|
+
const boundMutate = (0, import_react.useCallback)((...args) => {
|
|
3024
|
+
return internalMutate(cache, keyRef.current, ...args);
|
|
3025
|
+
}, []);
|
|
3026
|
+
useIsomorphicLayoutEffect(() => {
|
|
3027
|
+
const preloaded = preloadCacheRef.current;
|
|
3028
|
+
if (!preloaded) return;
|
|
3029
|
+
preloadCacheRef.current = null;
|
|
3030
|
+
markCacheDataConsumed(consumedCacheData, preloaded.cacheData, preloaded.key);
|
|
3031
|
+
if (isUndefined(getCache().data)) setCache({
|
|
3032
|
+
data: preloaded.data,
|
|
3033
|
+
error: void 0,
|
|
3034
|
+
_k: preloaded._k
|
|
3035
|
+
});
|
|
3036
|
+
if (PRELOAD[preloaded.key]) delete PRELOAD[preloaded.key];
|
|
3037
|
+
});
|
|
3038
|
+
useIsomorphicLayoutEffect(() => {
|
|
3039
|
+
fetcherRef.current = fetcher;
|
|
3040
|
+
configRef.current = config;
|
|
3041
|
+
if (!isUndefined(cachedData)) laggyDataRef.current = cachedData;
|
|
3042
|
+
});
|
|
3043
|
+
useIsomorphicLayoutEffect(() => {
|
|
3044
|
+
if (fetcher || !hasCacheData || isUndefined(preloadedData) || isCacheDataConsumed(consumedCacheData, serverCacheData, key) || !isUndefined(getCache().data)) return;
|
|
3045
|
+
markCacheDataConsumed(consumedCacheData, serverCacheData, key);
|
|
3046
|
+
const mutation = MUTATION[key];
|
|
3047
|
+
commitCacheData({
|
|
3048
|
+
value: preloadedData,
|
|
3049
|
+
getCacheData: () => getCache().data,
|
|
3050
|
+
canCommit: () => !unmountedRef.current && key === keyRef.current && MUTATION[key] === mutation,
|
|
3051
|
+
setCache: (state) => setCache({
|
|
3052
|
+
...state,
|
|
3053
|
+
_k: fnArg
|
|
3054
|
+
})
|
|
3055
|
+
});
|
|
3056
|
+
});
|
|
3057
|
+
useIsomorphicLayoutEffect(() => {
|
|
3058
|
+
if (!key) return;
|
|
3059
|
+
const softRevalidate = revalidate.bind(void 0, WITH_DEDUPE);
|
|
3060
|
+
let nextFocusRevalidatedAt = 0;
|
|
3061
|
+
if (getConfig().revalidateOnFocus) nextFocusRevalidatedAt = Date.now() + getConfig().focusThrottleInterval;
|
|
3062
|
+
const onRevalidate = (type, opts = {}) => {
|
|
3063
|
+
if (type == 0) {
|
|
3064
|
+
const now = Date.now();
|
|
3065
|
+
if (getConfig().revalidateOnFocus && now > nextFocusRevalidatedAt && isActive()) {
|
|
3066
|
+
nextFocusRevalidatedAt = now + getConfig().focusThrottleInterval;
|
|
3067
|
+
softRevalidate();
|
|
3068
|
+
}
|
|
3069
|
+
} else if (type == 1) {
|
|
3070
|
+
if (getConfig().revalidateOnReconnect && isActive()) softRevalidate();
|
|
3071
|
+
} else if (type == 2) return revalidate();
|
|
3072
|
+
else if (type == 3) return revalidate(opts);
|
|
3073
|
+
else if (type == 4) {
|
|
3074
|
+
laggyDataRef.current = void 0;
|
|
3075
|
+
if (opts.revalidate) return revalidate();
|
|
3076
|
+
}
|
|
3077
|
+
};
|
|
3078
|
+
const unsubEvents = subscribeCallback(key, EVENT_REVALIDATORS, onRevalidate);
|
|
3079
|
+
unmountedRef.current = false;
|
|
3080
|
+
keyRef.current = key;
|
|
3081
|
+
initialMountedRef.current = true;
|
|
3082
|
+
setCache({ _k: fnArg });
|
|
3083
|
+
if (shouldDoInitialRevalidation) {
|
|
3084
|
+
if (!FETCH[key]) {
|
|
3085
|
+
if (isUndefined(data) || IS_SERVER) softRevalidate();
|
|
3086
|
+
else rAF(softRevalidate);
|
|
3087
|
+
}
|
|
3088
|
+
}
|
|
3089
|
+
return () => {
|
|
3090
|
+
unmountedRef.current = true;
|
|
3091
|
+
unsubEvents();
|
|
3092
|
+
};
|
|
3093
|
+
}, [key]);
|
|
3094
|
+
useIsomorphicLayoutEffect(() => {
|
|
3095
|
+
let timer;
|
|
3096
|
+
function next() {
|
|
3097
|
+
const interval = isFunction(refreshInterval) ? refreshInterval(getCache().data) : refreshInterval;
|
|
3098
|
+
if (interval && timer !== -1) timer = setTimeout(execute, interval);
|
|
3099
|
+
}
|
|
3100
|
+
function execute() {
|
|
3101
|
+
if (!getCache().error && (refreshWhenHidden || getConfig().isVisible()) && (refreshWhenOffline || getConfig().isOnline())) revalidate(WITH_DEDUPE).then(next);
|
|
3102
|
+
else next();
|
|
3103
|
+
}
|
|
3104
|
+
next();
|
|
3105
|
+
return () => {
|
|
3106
|
+
if (timer) {
|
|
3107
|
+
clearTimeout(timer);
|
|
3108
|
+
timer = -1;
|
|
3109
|
+
}
|
|
3110
|
+
};
|
|
3111
|
+
}, [
|
|
3112
|
+
refreshInterval,
|
|
3113
|
+
refreshWhenHidden,
|
|
3114
|
+
refreshWhenOffline,
|
|
3115
|
+
key
|
|
3116
|
+
]);
|
|
3117
|
+
(0, import_react.useDebugValue)(returnedData);
|
|
3118
|
+
if (suspense) {
|
|
3119
|
+
if (!IS_REACT_LEGACY && IS_SERVER && hasKeyButNoData && isUndefined(preloadedData)) throw new Error("Fallback data is required when using Suspense in SSR.");
|
|
3120
|
+
if (hasKeyButNoData) {
|
|
3121
|
+
fetcherRef.current = fetcher;
|
|
3122
|
+
configRef.current = config;
|
|
3123
|
+
unmountedRef.current = false;
|
|
3124
|
+
}
|
|
3125
|
+
const shouldConsumePreload = !isUndefined(preloadedData) && hasKeyButNoData;
|
|
3126
|
+
let preloadData = void 0;
|
|
3127
|
+
if (shouldConsumePreload && hasCacheData) {
|
|
3128
|
+
preloadData = preloadedData && isPromiseLike(preloadedData) ? use(preloadedData) : preloadedData;
|
|
3129
|
+
data = preloadData;
|
|
3130
|
+
returnedData = preloadData;
|
|
3131
|
+
if (!IS_SERVER) preloadCacheRef.current = {
|
|
3132
|
+
data: preloadData,
|
|
3133
|
+
_k: fnArg,
|
|
3134
|
+
key,
|
|
3135
|
+
cacheData: serverCacheData
|
|
3136
|
+
};
|
|
3137
|
+
} else use(shouldConsumePreload ? boundMutate(preloadedData) : resolvedUndef);
|
|
3138
|
+
if (!isUndefined(error) && hasKeyButNoData) throw error;
|
|
3139
|
+
const revalidation = hasKeyButNoData && isUndefined(preloadData) ? revalidate(WITH_DEDUPE) : resolvedUndef;
|
|
3140
|
+
if (!isUndefined(returnedData) && hasKeyButNoData) {
|
|
3141
|
+
revalidation.status = "fulfilled";
|
|
3142
|
+
revalidation.value = true;
|
|
3143
|
+
}
|
|
3144
|
+
use(revalidation);
|
|
3145
|
+
}
|
|
3146
|
+
return {
|
|
3147
|
+
mutate: boundMutate,
|
|
3148
|
+
get data() {
|
|
3149
|
+
stateDependencies.data = true;
|
|
3150
|
+
return returnedData;
|
|
3151
|
+
},
|
|
3152
|
+
get error() {
|
|
3153
|
+
stateDependencies.error = true;
|
|
3154
|
+
return error;
|
|
3155
|
+
},
|
|
3156
|
+
get isValidating() {
|
|
3157
|
+
stateDependencies.isValidating = true;
|
|
3158
|
+
return isValidating;
|
|
3159
|
+
},
|
|
3160
|
+
get isLoading() {
|
|
3161
|
+
stateDependencies.isLoading = true;
|
|
3162
|
+
return isLoading;
|
|
3163
|
+
}
|
|
3164
|
+
};
|
|
3165
|
+
};
|
|
3166
|
+
OBJECT.defineProperty(SWRConfig$1, "defaultValue", { value: defaultConfig });
|
|
3167
|
+
/**
|
|
3168
|
+
* A hook to fetch data.
|
|
3169
|
+
*
|
|
3170
|
+
* @see {@link https://swr.vercel.app}
|
|
3171
|
+
*
|
|
3172
|
+
* @example
|
|
3173
|
+
* ```jsx
|
|
3174
|
+
* import useSWR from 'swr'
|
|
3175
|
+
* function Profile() {
|
|
3176
|
+
* const { data, error, isLoading } = useSWR('/api/user', fetcher)
|
|
3177
|
+
* if (error) return <div>failed to load</div>
|
|
3178
|
+
* if (isLoading) return <div>loading...</div>
|
|
3179
|
+
* return <div>hello {data.name}!</div>
|
|
3180
|
+
* }
|
|
3181
|
+
* ```
|
|
3182
|
+
*/ var useSWR = withArgs(useSWRHandler);
|
|
3183
|
+
// ../../node_modules/.bun/swr@2.5.1+4bcfe187168658ad/node_modules/swr/dist/infinite/index.mjs
|
|
3184
|
+
var getFirstPageKey = (getKey) => {
|
|
3185
|
+
return serialize(getKey ? getKey(0, null) : null)[0];
|
|
3186
|
+
};
|
|
3187
|
+
var EMPTY_PROMISE = Promise.resolve();
|
|
3188
|
+
var infinite = (useSWRNext) => (getKey, fn, config) => {
|
|
3189
|
+
const didMountRef = (0, import_react.useRef)(false);
|
|
3190
|
+
const { cache: cache$1, initialSize = 1, revalidateAll = false, persistSize = false, revalidateFirstPage = true, revalidateOnMount = false, parallel = false } = config;
|
|
3191
|
+
const [, , , PRELOAD] = SWRGlobalState.get(cache);
|
|
3192
|
+
let infiniteKey;
|
|
3193
|
+
try {
|
|
3194
|
+
infiniteKey = getFirstPageKey(getKey);
|
|
3195
|
+
if (infiniteKey) infiniteKey = INFINITE_PREFIX + infiniteKey;
|
|
3196
|
+
} catch (err) {}
|
|
3197
|
+
const [get, set, subscribeCache] = createCacheHelper(cache$1, infiniteKey);
|
|
3198
|
+
const getSnapshot = (0, import_react.useCallback)(() => {
|
|
3199
|
+
return isUndefined(get()._l) ? initialSize : get()._l;
|
|
3200
|
+
}, [
|
|
3201
|
+
cache$1,
|
|
3202
|
+
infiniteKey,
|
|
3203
|
+
initialSize
|
|
3204
|
+
]);
|
|
3205
|
+
(0, import_shim.useSyncExternalStore)((0, import_react.useCallback)((callback) => {
|
|
3206
|
+
if (infiniteKey) return subscribeCache(infiniteKey, () => {
|
|
3207
|
+
callback();
|
|
3208
|
+
});
|
|
3209
|
+
return () => {};
|
|
3210
|
+
}, [cache$1, infiniteKey]), getSnapshot, getSnapshot);
|
|
3211
|
+
const resolvePageSize = (0, import_react.useCallback)(() => {
|
|
3212
|
+
const cachedPageSize = get()._l;
|
|
3213
|
+
return isUndefined(cachedPageSize) ? initialSize : cachedPageSize;
|
|
3214
|
+
}, [infiniteKey, initialSize]);
|
|
3215
|
+
const lastPageSizeRef = (0, import_react.useRef)(resolvePageSize());
|
|
3216
|
+
useIsomorphicLayoutEffect(() => {
|
|
3217
|
+
if (!didMountRef.current) {
|
|
3218
|
+
didMountRef.current = true;
|
|
3219
|
+
return;
|
|
3220
|
+
}
|
|
3221
|
+
if (infiniteKey) set({ _l: persistSize ? lastPageSizeRef.current : resolvePageSize() });
|
|
3222
|
+
}, [infiniteKey, cache$1]);
|
|
3223
|
+
const shouldRevalidateOnMount = revalidateOnMount && !didMountRef.current;
|
|
3224
|
+
const swr = useSWRNext(infiniteKey, async (key) => {
|
|
3225
|
+
const forceRevalidateAll = get()._i;
|
|
3226
|
+
const shouldRevalidatePage = get()._r;
|
|
3227
|
+
const state = SWRGlobalState.get(cache$1);
|
|
3228
|
+
const unloadGeneration = state[8];
|
|
3229
|
+
const unloadedDuringRequest = () => state[8] !== unloadGeneration;
|
|
3230
|
+
set({ _r: void 0 });
|
|
3231
|
+
const data = [];
|
|
3232
|
+
const pageSize = resolvePageSize();
|
|
3233
|
+
const [getCache] = createCacheHelper(cache$1, key);
|
|
3234
|
+
const cacheData = getCache().data;
|
|
3235
|
+
const revalidators = [];
|
|
3236
|
+
let previousPageData = null;
|
|
3237
|
+
for (let i = 0; i < pageSize; ++i) {
|
|
3238
|
+
const [pageKey, pageArg] = serialize(getKey(i, parallel ? null : previousPageData));
|
|
3239
|
+
if (!pageKey) break;
|
|
3240
|
+
const [getSWRCache, setSWRCache] = createCacheHelper(cache$1, pageKey);
|
|
3241
|
+
let pageData = getSWRCache().data;
|
|
3242
|
+
const shouldFetchPage = revalidateAll || forceRevalidateAll || isUndefined(pageData) || revalidateFirstPage && !i && !isUndefined(cacheData) || shouldRevalidateOnMount || cacheData && !isUndefined(cacheData[i]) && !config.compare(cacheData[i], pageData);
|
|
3243
|
+
if (fn && (typeof shouldRevalidatePage === "function" ? shouldRevalidatePage(pageData, pageArg) : shouldFetchPage)) {
|
|
3244
|
+
const revalidate = async () => {
|
|
3245
|
+
if (!(pageKey in PRELOAD)) pageData = await fn(pageArg);
|
|
3246
|
+
else {
|
|
3247
|
+
const req = PRELOAD[pageKey];
|
|
3248
|
+
delete PRELOAD[pageKey];
|
|
3249
|
+
pageData = await req;
|
|
3250
|
+
}
|
|
3251
|
+
if (!unloadedDuringRequest()) setSWRCache({
|
|
3252
|
+
data: pageData,
|
|
3253
|
+
_k: pageArg
|
|
3254
|
+
});
|
|
3255
|
+
data[i] = pageData;
|
|
3256
|
+
};
|
|
3257
|
+
if (parallel) revalidators.push(revalidate);
|
|
3258
|
+
else await revalidate();
|
|
3259
|
+
} else data[i] = pageData;
|
|
3260
|
+
if (!parallel) previousPageData = pageData;
|
|
3261
|
+
}
|
|
3262
|
+
if (parallel) await Promise.all(revalidators.map((r) => r()));
|
|
3263
|
+
if (!unloadedDuringRequest()) set({ _i: void 0 });
|
|
3264
|
+
return data;
|
|
3265
|
+
}, config);
|
|
3266
|
+
const mutate = (0, import_react.useCallback)(function(data, opts) {
|
|
3267
|
+
const options = typeof opts === "boolean" ? { revalidate: opts } : opts || {};
|
|
3268
|
+
const shouldRevalidate = options.revalidate !== false;
|
|
3269
|
+
if (!infiniteKey) return EMPTY_PROMISE;
|
|
3270
|
+
if (shouldRevalidate) {
|
|
3271
|
+
if (!isUndefined(data)) set({
|
|
3272
|
+
_i: false,
|
|
3273
|
+
_r: options.revalidate
|
|
3274
|
+
});
|
|
3275
|
+
else set({
|
|
3276
|
+
_i: true,
|
|
3277
|
+
_r: options.revalidate
|
|
3278
|
+
});
|
|
3279
|
+
}
|
|
3280
|
+
return arguments.length ? swr.mutate(data, {
|
|
3281
|
+
...options,
|
|
3282
|
+
revalidate: shouldRevalidate
|
|
3283
|
+
}) : swr.mutate();
|
|
3284
|
+
}, [infiniteKey, cache$1]);
|
|
3285
|
+
const setSize = (0, import_react.useCallback)((arg) => {
|
|
3286
|
+
if (!infiniteKey) return EMPTY_PROMISE;
|
|
3287
|
+
const [, changeSize] = createCacheHelper(cache$1, infiniteKey);
|
|
3288
|
+
let size;
|
|
3289
|
+
if (isFunction(arg)) size = arg(resolvePageSize());
|
|
3290
|
+
else if (typeof arg == "number") size = arg;
|
|
3291
|
+
if (typeof size != "number") return EMPTY_PROMISE;
|
|
3292
|
+
changeSize({ _l: size });
|
|
3293
|
+
lastPageSizeRef.current = size;
|
|
3294
|
+
const data = [];
|
|
3295
|
+
const [getInfiniteCache] = createCacheHelper(cache$1, infiniteKey);
|
|
3296
|
+
let previousPageData = null;
|
|
3297
|
+
for (let i = 0; i < size; ++i) {
|
|
3298
|
+
const [pageKey] = serialize(getKey(i, previousPageData));
|
|
3299
|
+
const [getCache] = createCacheHelper(cache$1, pageKey);
|
|
3300
|
+
const pageData = pageKey ? getCache().data : void 0;
|
|
3301
|
+
if (isUndefined(pageData)) return mutate(getInfiniteCache().data);
|
|
3302
|
+
data.push(pageData);
|
|
3303
|
+
previousPageData = pageData;
|
|
3304
|
+
}
|
|
3305
|
+
return mutate(data);
|
|
3306
|
+
}, [
|
|
3307
|
+
infiniteKey,
|
|
3308
|
+
cache$1,
|
|
3309
|
+
mutate,
|
|
3310
|
+
resolvePageSize
|
|
3311
|
+
]);
|
|
3312
|
+
return {
|
|
3313
|
+
size: resolvePageSize(),
|
|
3314
|
+
setSize,
|
|
3315
|
+
mutate,
|
|
3316
|
+
get data() {
|
|
3317
|
+
return swr.data;
|
|
3318
|
+
},
|
|
3319
|
+
get error() {
|
|
3320
|
+
return swr.error;
|
|
3321
|
+
},
|
|
3322
|
+
get isValidating() {
|
|
3323
|
+
return swr.isValidating;
|
|
3324
|
+
},
|
|
3325
|
+
get isLoading() {
|
|
3326
|
+
return swr.isLoading;
|
|
3327
|
+
}
|
|
3328
|
+
};
|
|
3329
|
+
};
|
|
3330
|
+
var useSWRInfinite = withMiddleware(useSWR, infinite);
|
|
3331
|
+
// app/lib/client/hooks/use-infinite-list.ts
|
|
3332
|
+
/**
|
|
3333
|
+
* Cursor-based infinite list backed by SWR's global cache.
|
|
3334
|
+
*
|
|
3335
|
+
* Pages are keyed by `[cacheKey, cursor]`, so switching tabs (unmount +
|
|
3336
|
+
* remount) restores previously fetched pages instantly instead of refetching.
|
|
3337
|
+
* Revalidation is deliberately conservative: cached pages are NOT refetched on remount or
|
|
3338
|
+
* when loading further pages (`revalidateFirstPage: false`,
|
|
3339
|
+
* `revalidateIfStale: false`). Freshness comes from explicit `reload()`/
|
|
3340
|
+
* `refresh()` calls (the Refresh button and the tab-visibility auto-reload).
|
|
3341
|
+
*
|
|
3342
|
+
* Rows are deduped by `getItemKey` when pages are flattened, so cursor drift
|
|
3343
|
+
* on live data cannot produce duplicate rows.
|
|
3344
|
+
*/
|
|
3345
|
+
function useInfiniteList(cacheKey, fetchFn, getItemKey) {
|
|
3346
|
+
const { data: pages, error, isLoading, isValidating, size, setSize, mutate } = useSWRInfinite((0, import_react.useCallback)((_index, prev) => {
|
|
3347
|
+
if (prev && (!prev.hasMore || !prev.cursor)) return null;
|
|
3348
|
+
return [cacheKey, prev?.cursor ?? null];
|
|
3349
|
+
}, [cacheKey]), ([, cursor]) => fetchFn(cursor ?? void 0), {
|
|
3350
|
+
revalidateFirstPage: false,
|
|
3351
|
+
revalidateIfStale: false,
|
|
3352
|
+
revalidateOnFocus: false,
|
|
3353
|
+
keepPreviousData: true
|
|
3354
|
+
});
|
|
3355
|
+
const items = (0, import_react.useMemo)(() => {
|
|
3356
|
+
if (!pages) return [];
|
|
3357
|
+
const seen = /* @__PURE__ */ new Set();
|
|
3358
|
+
const result = [];
|
|
3359
|
+
for (const page of pages) for (const item of page.data) {
|
|
3360
|
+
const key = getItemKey(item);
|
|
3361
|
+
if (seen.has(key)) continue;
|
|
3362
|
+
seen.add(key);
|
|
3363
|
+
result.push(item);
|
|
3364
|
+
}
|
|
3365
|
+
return result;
|
|
3366
|
+
}, [pages, getItemKey]);
|
|
3367
|
+
const lastPage = pages?.[pages.length - 1];
|
|
3368
|
+
const hasMore = Boolean(lastPage?.hasMore && lastPage?.cursor);
|
|
3369
|
+
const isLoadingMore = size > 0 && Boolean(pages) && pages.length < size;
|
|
3370
|
+
const loadMore = (0, import_react.useCallback)(() => {
|
|
3371
|
+
if (isValidating || !hasMore) return;
|
|
3372
|
+
setSize((s) => s + 1);
|
|
3373
|
+
}, [
|
|
3374
|
+
isValidating,
|
|
3375
|
+
hasMore,
|
|
3376
|
+
setSize
|
|
3377
|
+
]);
|
|
3378
|
+
const reload = (0, import_react.useCallback)(() => {
|
|
3379
|
+
setSize(1);
|
|
3380
|
+
mutate();
|
|
3381
|
+
}, [setSize, mutate]);
|
|
3382
|
+
return {
|
|
3383
|
+
items,
|
|
3384
|
+
error: error ? error instanceof Error ? error : new WorkflowWebAPIError(String(error), { layer: "client" }) : null,
|
|
3385
|
+
isLoading,
|
|
3386
|
+
isLoadingMore,
|
|
3387
|
+
hasMore,
|
|
3388
|
+
loadMore,
|
|
3389
|
+
reload
|
|
3390
|
+
};
|
|
3391
|
+
}
|
|
3392
|
+
/**
|
|
3393
|
+
* Infinite-scrolling list of workflow runs.
|
|
3394
|
+
*
|
|
3395
|
+
* Pages are large since rows accumulate, which keeps the number of
|
|
3396
|
+
* round-trips low while scrolling.
|
|
3397
|
+
*/
|
|
3398
|
+
function useWorkflowRunsInfinite(params) {
|
|
3399
|
+
const { workflowName, status, limit = 25, sortOrder = "desc" } = params;
|
|
3400
|
+
return useInfiniteList(`workflow-runs:${workflowName ?? ""}:${status ?? ""}:${sortOrder}:${limit}`, (0, import_react.useCallback)((cursor) => unwrapOrThrow(rpc("fetchRuns", {
|
|
3401
|
+
cursor,
|
|
3402
|
+
sortOrder,
|
|
3403
|
+
limit,
|
|
3404
|
+
workflowName,
|
|
3405
|
+
status
|
|
3406
|
+
})), [
|
|
3407
|
+
workflowName,
|
|
3408
|
+
limit,
|
|
3409
|
+
sortOrder,
|
|
3410
|
+
status
|
|
3411
|
+
]), (0, import_react.useCallback)((run) => run.runId, []));
|
|
3412
|
+
}
|
|
3413
|
+
// app/lib/client/hooks/use-load-more-on-scroll.ts
|
|
3414
|
+
/**
|
|
3415
|
+
* Fires `loadMore` when a sentinel element scrolls into view.
|
|
3416
|
+
*
|
|
3417
|
+
* Attach the returned ref to an empty element placed after the list. The
|
|
3418
|
+
* observer only fires while `hasMore && !isLoadingMore`, and `loadMore` is
|
|
3419
|
+
* held in a ref so its identity changing does not re-create the observer.
|
|
3420
|
+
*
|
|
3421
|
+
* Pass the scrollable container as `root` when the list scrolls inside a
|
|
3422
|
+
* fixed-height element (rather than the viewport) so `rootMargin` prefetching
|
|
3423
|
+
* is measured against the container edge.
|
|
3424
|
+
*/
|
|
3425
|
+
function useLoadMoreOnScroll(loadMore, { hasMore, isLoadingMore, root = null, rootMargin = "400px" }) {
|
|
3426
|
+
const sentinelRef = (0, import_react.useRef)(null);
|
|
3427
|
+
const loadMoreRef = (0, import_react.useRef)(loadMore);
|
|
3428
|
+
(0, import_react.useEffect)(() => {
|
|
3429
|
+
loadMoreRef.current = loadMore;
|
|
3430
|
+
}, [loadMore]);
|
|
3431
|
+
(0, import_react.useEffect)(() => {
|
|
3432
|
+
const sentinel = sentinelRef.current;
|
|
3433
|
+
if (!sentinel || !hasMore || isLoadingMore) return;
|
|
3434
|
+
const observer = new IntersectionObserver((entries) => {
|
|
3435
|
+
for (const entry of entries) if (entry.isIntersecting) {
|
|
3436
|
+
loadMoreRef.current();
|
|
3437
|
+
break;
|
|
3438
|
+
}
|
|
3439
|
+
}, {
|
|
3440
|
+
root,
|
|
3441
|
+
rootMargin,
|
|
3442
|
+
threshold: 0
|
|
3443
|
+
});
|
|
3444
|
+
observer.observe(sentinel);
|
|
3445
|
+
return () => observer.disconnect();
|
|
3446
|
+
}, [
|
|
3447
|
+
hasMore,
|
|
3448
|
+
isLoadingMore,
|
|
3449
|
+
root,
|
|
3450
|
+
rootMargin
|
|
3451
|
+
]);
|
|
3452
|
+
return sentinelRef;
|
|
3453
|
+
}
|
|
2144
3454
|
// app/components/runs-table.tsx
|
|
2145
|
-
function RunActionsDropdownContentInner({
|
|
3455
|
+
function RunActionsDropdownContentInner({ runId, runStatus, onSuccess }) {
|
|
2146
3456
|
const [events, setEvents] = (0, import_react.useState)(void 0);
|
|
2147
3457
|
const [eventsLoading, setEventsLoading] = (0, import_react.useState)(true);
|
|
2148
3458
|
const [run, setRun] = (0, import_react.useState)(void 0);
|
|
@@ -2151,7 +3461,10 @@ function RunActionsDropdownContentInner({ env, runId, runStatus, onSuccess }) {
|
|
|
2151
3461
|
(0, import_react.useEffect)(() => {
|
|
2152
3462
|
setRun(void 0);
|
|
2153
3463
|
setRunIdentityLoading(true);
|
|
2154
|
-
|
|
3464
|
+
rpc("fetchRun", {
|
|
3465
|
+
runId,
|
|
3466
|
+
resolveData: "none"
|
|
3467
|
+
}).then((runResult) => {
|
|
2155
3468
|
if (runResult.success) setRun(runResult.data);
|
|
2156
3469
|
}).catch((err) => {
|
|
2157
3470
|
console.error("Failed to fetch run:", err);
|
|
@@ -2160,7 +3473,8 @@ function RunActionsDropdownContentInner({ env, runId, runStatus, onSuccess }) {
|
|
|
2160
3473
|
});
|
|
2161
3474
|
setEvents(void 0);
|
|
2162
3475
|
setEventsLoading(true);
|
|
2163
|
-
fetchEvents
|
|
3476
|
+
rpc("fetchEvents", {
|
|
3477
|
+
runId,
|
|
2164
3478
|
limit: 1e3,
|
|
2165
3479
|
sortOrder: "desc"
|
|
2166
3480
|
}).then((eventsResult) => {
|
|
@@ -2170,9 +3484,8 @@ function RunActionsDropdownContentInner({ env, runId, runStatus, onSuccess }) {
|
|
|
2170
3484
|
}).finally(() => {
|
|
2171
3485
|
setEventsLoading(false);
|
|
2172
3486
|
});
|
|
2173
|
-
}, [
|
|
3487
|
+
}, [runId]);
|
|
2174
3488
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RunActionsDropdownItems, {
|
|
2175
|
-
env,
|
|
2176
3489
|
runId,
|
|
2177
3490
|
runStatus: status,
|
|
2178
3491
|
events,
|
|
@@ -2182,7 +3495,7 @@ function RunActionsDropdownContentInner({ env, runId, runStatus, onSuccess }) {
|
|
|
2182
3495
|
callbacks: { onSuccess }
|
|
2183
3496
|
});
|
|
2184
3497
|
}
|
|
2185
|
-
function LazyDropdownMenu({
|
|
3498
|
+
function LazyDropdownMenu({ runId, runStatus, onSuccess }) {
|
|
2186
3499
|
const [isOpen, setIsOpen] = (0, import_react.useState)(false);
|
|
2187
3500
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(DropdownMenu, {
|
|
2188
3501
|
open: isOpen,
|
|
@@ -2200,7 +3513,6 @@ function LazyDropdownMenu({ env, runId, runStatus, onSuccess }) {
|
|
|
2200
3513
|
}), isOpen && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DropdownMenuContent, {
|
|
2201
3514
|
align: "end",
|
|
2202
3515
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RunActionsDropdownContentInner, {
|
|
2203
|
-
env,
|
|
2204
3516
|
runId,
|
|
2205
3517
|
runStatus,
|
|
2206
3518
|
onSuccess
|
|
@@ -2211,70 +3523,25 @@ function LazyDropdownMenu({ env, runId, runStatus, onSuccess }) {
|
|
|
2211
3523
|
var statusMap = {
|
|
2212
3524
|
pending: {
|
|
2213
3525
|
label: "Pending",
|
|
2214
|
-
color:
|
|
3526
|
+
color: STATUS_COLORS.pending
|
|
2215
3527
|
},
|
|
2216
3528
|
running: {
|
|
2217
3529
|
label: "Running",
|
|
2218
|
-
color:
|
|
3530
|
+
color: STATUS_COLORS.running
|
|
2219
3531
|
},
|
|
2220
3532
|
completed: {
|
|
2221
3533
|
label: "Completed",
|
|
2222
|
-
color:
|
|
3534
|
+
color: STATUS_COLORS.completed
|
|
2223
3535
|
},
|
|
2224
3536
|
failed: {
|
|
2225
3537
|
label: "Failed",
|
|
2226
|
-
color:
|
|
3538
|
+
color: STATUS_COLORS.failed
|
|
2227
3539
|
},
|
|
2228
3540
|
cancelled: {
|
|
2229
3541
|
label: "Cancelled",
|
|
2230
|
-
color:
|
|
3542
|
+
color: STATUS_COLORS.cancelled
|
|
2231
3543
|
}
|
|
2232
3544
|
};
|
|
2233
|
-
var HOUR_MS = 36e5;
|
|
2234
|
-
var DAY_MS = 24 * HOUR_MS;
|
|
2235
|
-
/**
|
|
2236
|
-
* Listing-window presets, mirroring front's workflows o11y period picker.
|
|
2237
|
-
* The selected preset is sent to the backend as an explicit
|
|
2238
|
-
* startTime/endTime window so the analytics scan stays bounded. Presets
|
|
2239
|
-
* longer than the plan's observability lookback are disabled in the picker
|
|
2240
|
-
* (the backend would reject them with 402 observability-upgrade-required).
|
|
2241
|
-
*/
|
|
2242
|
-
var PERIOD_PRESETS = [
|
|
2243
|
-
{
|
|
2244
|
-
id: "1h",
|
|
2245
|
-
label: "Last hour",
|
|
2246
|
-
ms: HOUR_MS
|
|
2247
|
-
},
|
|
2248
|
-
{
|
|
2249
|
-
id: "6h",
|
|
2250
|
-
label: "Last 6 hours",
|
|
2251
|
-
ms: 6 * HOUR_MS
|
|
2252
|
-
},
|
|
2253
|
-
{
|
|
2254
|
-
id: "24h",
|
|
2255
|
-
label: "Last 24 hours",
|
|
2256
|
-
ms: DAY_MS
|
|
2257
|
-
},
|
|
2258
|
-
{
|
|
2259
|
-
id: "3d",
|
|
2260
|
-
label: "Last 3 days",
|
|
2261
|
-
ms: 3 * DAY_MS
|
|
2262
|
-
},
|
|
2263
|
-
{
|
|
2264
|
-
id: "7d",
|
|
2265
|
-
label: "Last 7 days",
|
|
2266
|
-
ms: 7 * DAY_MS
|
|
2267
|
-
},
|
|
2268
|
-
{
|
|
2269
|
-
id: "30d",
|
|
2270
|
-
label: "Last 30 days",
|
|
2271
|
-
ms: 30 * DAY_MS
|
|
2272
|
-
}
|
|
2273
|
-
];
|
|
2274
|
-
var DEFAULT_PERIOD = "24h";
|
|
2275
|
-
function isPeriodId(value) {
|
|
2276
|
-
return PERIOD_PRESETS.some((preset) => preset.id === value);
|
|
2277
|
-
}
|
|
2278
3545
|
function useWorkflowFilter() {
|
|
2279
3546
|
const navigate = useNavigate();
|
|
2280
3547
|
const { pathname } = useLocation();
|
|
@@ -2307,22 +3574,7 @@ function useStatusFilter() {
|
|
|
2307
3574
|
searchParams
|
|
2308
3575
|
]);
|
|
2309
3576
|
}
|
|
2310
|
-
function
|
|
2311
|
-
const navigate = useNavigate();
|
|
2312
|
-
const { pathname } = useLocation();
|
|
2313
|
-
const [searchParams] = useSearchParams();
|
|
2314
|
-
return (0, import_react.useCallback)((value) => {
|
|
2315
|
-
const params = new URLSearchParams(searchParams.toString());
|
|
2316
|
-
if (value === DEFAULT_PERIOD) params.delete("period");
|
|
2317
|
-
else params.set("period", value);
|
|
2318
|
-
navigate(`${pathname}?${params.toString()}`);
|
|
2319
|
-
}, [
|
|
2320
|
-
navigate,
|
|
2321
|
-
pathname,
|
|
2322
|
-
searchParams
|
|
2323
|
-
]);
|
|
2324
|
-
}
|
|
2325
|
-
function FilterControls({ workflowNameFilter, status, seenWorkflowNames, sortOrder, loading, period, showPeriodPicker, planWindowMs, planUpgradeAvailable, onWorkflowChange, onStatusChange, onPeriodChange, onSortToggle, onRefresh, lastRefreshTime }) {
|
|
3577
|
+
function FilterControls({ workflowNameFilter, status, seenWorkflowNames, sortOrder, loading, onWorkflowChange, onStatusChange, onSortToggle, onRefresh, lastRefreshTime }) {
|
|
2326
3578
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
2327
3579
|
className: "flex items-center justify-between",
|
|
2328
3580
|
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
@@ -2338,31 +3590,6 @@ function FilterControls({ workflowNameFilter, status, seenWorkflowNames, sortOrd
|
|
|
2338
3590
|
}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
2339
3591
|
className: "flex items-center gap-4",
|
|
2340
3592
|
children: [
|
|
2341
|
-
showPeriodPicker && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Tooltip, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(TooltipTrigger, {
|
|
2342
|
-
asChild: true,
|
|
2343
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Select, {
|
|
2344
|
-
value: period,
|
|
2345
|
-
onValueChange: onPeriodChange,
|
|
2346
|
-
disabled: loading,
|
|
2347
|
-
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectTrigger, {
|
|
2348
|
-
className: "w-[150px] h-9",
|
|
2349
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectValue, { placeholder: "Time window" })
|
|
2350
|
-
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectContent, { children: PERIOD_PRESETS.map((preset) => {
|
|
2351
|
-
const beyondPlan = planWindowMs !== void 0 && preset.ms > planWindowMs;
|
|
2352
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectItem, {
|
|
2353
|
-
value: preset.id,
|
|
2354
|
-
disabled: beyondPlan,
|
|
2355
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
2356
|
-
className: "flex items-center gap-2",
|
|
2357
|
-
children: [preset.label, beyondPlan && planUpgradeAvailable && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
2358
|
-
className: "text-xs text-muted-foreground",
|
|
2359
|
-
children: "Observability Plus"
|
|
2360
|
-
})]
|
|
2361
|
-
})
|
|
2362
|
-
}, preset.id);
|
|
2363
|
-
}) })]
|
|
2364
|
-
}) })
|
|
2365
|
-
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TooltipContent, { children: planUpgradeAvailable ? "Time window for the runs list. Longer windows require Observability Plus." : "Time window for the runs list" })] }),
|
|
2366
3593
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Select, {
|
|
2367
3594
|
value: workflowNameFilter ?? "all",
|
|
2368
3595
|
onValueChange: onWorkflowChange,
|
|
@@ -2423,63 +3650,24 @@ function FilterControls({ workflowNameFilter, status, seenWorkflowNames, sortOrd
|
|
|
2423
3650
|
})]
|
|
2424
3651
|
});
|
|
2425
3652
|
}
|
|
2426
|
-
/**
|
|
2427
|
-
* RunsTable - Displays workflow runs with server-side pagination.
|
|
2428
|
-
* Uses the PaginatingTable pattern: fetches data for each page as needed from the server.
|
|
2429
|
-
* The table and fetching behavior are intertwined - pagination controls trigger new API calls.
|
|
2430
|
-
*
|
|
2431
|
-
* World configuration is read from server-side environment variables.
|
|
2432
|
-
* The env object passed to server actions is empty - the server uses process.env.
|
|
2433
|
-
*/
|
|
3653
|
+
/** Workflow runs, loading further pages from the server as the list scrolls. */
|
|
2434
3654
|
function RunsTable({ onRunClick }) {
|
|
2435
3655
|
const [searchParams] = useSearchParams();
|
|
2436
3656
|
const handleWorkflowFilter = useWorkflowFilter();
|
|
2437
3657
|
const handleStatusFilter = useStatusFilter();
|
|
2438
|
-
const { serverConfig } = useServerConfig();
|
|
2439
3658
|
const rawStatus = searchParams.get("status");
|
|
2440
3659
|
const validStatuses = Object.keys(statusMap);
|
|
2441
3660
|
const status = rawStatus === "all" || rawStatus && validStatuses.includes(rawStatus) ? rawStatus : void 0;
|
|
2442
3661
|
const workflowNameFilter = searchParams.get("workflow");
|
|
2443
|
-
const rawPeriod = searchParams.get("period");
|
|
2444
|
-
const period = isPeriodId(rawPeriod) ? rawPeriod : DEFAULT_PERIOD;
|
|
2445
|
-
const periodPreset = PERIOD_PRESETS.find((preset) => preset.id === period) ?? PERIOD_PRESETS[2];
|
|
2446
|
-
const handlePeriodFilter = usePeriodFilter();
|
|
2447
3662
|
const [sortOrder, setSortOrder] = (0, import_react.useState)("desc");
|
|
2448
3663
|
const [lastRefreshTime, setLastRefreshTime] = (0, import_react.useState)(() => /* @__PURE__ */ new Date());
|
|
2449
3664
|
const [hasLoadedOnce, setHasLoadedOnce] = (0, import_react.useState)(false);
|
|
2450
|
-
const env = (0, import_react.useMemo)(() => ({}), []);
|
|
2451
|
-
const isLocal = serverConfig.backendId === "local" || serverConfig.backendId === "@workflow/world-local";
|
|
2452
|
-
const localDataDirPath = serverConfig.displayInfo?.["local.dataDirPath"];
|
|
2453
|
-
const localShortName = serverConfig.displayInfo?.["local.shortName"];
|
|
2454
3665
|
const [seenWorkflowNames, setSeenWorkflowNames] = (0, import_react.useState)(/* @__PURE__ */ new Set());
|
|
2455
|
-
const
|
|
2456
|
-
const [listingWindow, setListingWindow] = (0, import_react.useState)(() => isVercelBackend ? getListingWindow(period, periodPreset.ms) : void 0);
|
|
2457
|
-
(0, import_react.useEffect)(() => {
|
|
2458
|
-
setListingWindow(isVercelBackend ? getListingWindow(period, periodPreset.ms) : void 0);
|
|
2459
|
-
}, [
|
|
2460
|
-
isVercelBackend,
|
|
2461
|
-
period,
|
|
2462
|
-
periodPreset.ms
|
|
2463
|
-
]);
|
|
2464
|
-
const refreshListingWindow = (0, import_react.useCallback)(() => {
|
|
2465
|
-
if (isVercelBackend) setListingWindow(advanceListingWindow(period, periodPreset.ms));
|
|
2466
|
-
}, [
|
|
2467
|
-
isVercelBackend,
|
|
2468
|
-
period,
|
|
2469
|
-
periodPreset.ms
|
|
2470
|
-
]);
|
|
2471
|
-
const { items: runs, error, isLoading, isLoadingMore, hasMore, loadMore, reload, refresh, pageInfo: analyticsPageInfo } = useWorkflowRunsInfinite(env, {
|
|
3666
|
+
const { items: runs, error, isLoading, isLoadingMore, hasMore, loadMore, reload } = useWorkflowRunsInfinite({
|
|
2472
3667
|
sortOrder,
|
|
2473
3668
|
workflowName: workflowNameFilter === "all" ? void 0 : workflowNameFilter,
|
|
2474
|
-
status: status === "all" ? void 0 : status
|
|
2475
|
-
startTime: listingWindow?.startTime,
|
|
2476
|
-
endTime: listingWindow?.endTime
|
|
3669
|
+
status: status === "all" ? void 0 : status
|
|
2477
3670
|
});
|
|
2478
|
-
const [planInfo, setPlanInfo] = (0, import_react.useState)(void 0);
|
|
2479
|
-
(0, import_react.useEffect)(() => {
|
|
2480
|
-
if (analyticsPageInfo) setPlanInfo(analyticsPageInfo);
|
|
2481
|
-
}, [analyticsPageInfo]);
|
|
2482
|
-
const planWindowMs = planInfo !== void 0 ? planInfo.currentLookbackDays * DAY_MS : void 0;
|
|
2483
3671
|
const [scrollRoot, setScrollRoot] = (0, import_react.useState)(null);
|
|
2484
3672
|
const sentinelRef = useLoadMoreOnScroll(loadMore, {
|
|
2485
3673
|
hasMore,
|
|
@@ -2489,7 +3677,6 @@ function RunsTable({ onRunClick }) {
|
|
|
2489
3677
|
const selection = useTableSelection({ getItemId: (run) => run.runId });
|
|
2490
3678
|
const [isBulkCancelling, setIsBulkCancelling] = (0, import_react.useState)(false);
|
|
2491
3679
|
const [isBulkReenqueuing, setIsBulkReenqueuing] = (0, import_react.useState)(false);
|
|
2492
|
-
const isLocalAndHasMissingData = isLocal && (!localDataDirPath || !runs.length);
|
|
2493
3680
|
(0, import_react.useEffect)(() => {
|
|
2494
3681
|
if (runs.length > 0) {
|
|
2495
3682
|
const newNames = new Set(runs.map((run) => run.workflowName));
|
|
@@ -2514,14 +3701,8 @@ function RunsTable({ onRunClick }) {
|
|
|
2514
3701
|
const onReload = (0, import_react.useCallback)(() => {
|
|
2515
3702
|
setLastRefreshTime(() => /* @__PURE__ */ new Date());
|
|
2516
3703
|
setHasLoadedOnce(false);
|
|
2517
|
-
refreshListingWindow();
|
|
2518
3704
|
reload();
|
|
2519
|
-
}, [reload
|
|
2520
|
-
const onRefresh = (0, import_react.useCallback)(() => {
|
|
2521
|
-
setLastRefreshTime(() => /* @__PURE__ */ new Date());
|
|
2522
|
-
refreshListingWindow();
|
|
2523
|
-
refresh();
|
|
2524
|
-
}, [refresh, refreshListingWindow]);
|
|
3705
|
+
}, [reload]);
|
|
2525
3706
|
const selectedRuns = (0, import_react.useMemo)(() => {
|
|
2526
3707
|
return runs.filter((run) => selection.selectedIds.has(run.runId));
|
|
2527
3708
|
}, [runs, selection.selectedIds]);
|
|
@@ -2534,7 +3715,7 @@ function RunsTable({ onRunClick }) {
|
|
|
2534
3715
|
if (isBulkCancelling || cancellableSelectedRuns.length === 0 || cancellableSelectedRuns.length > 500) return;
|
|
2535
3716
|
setIsBulkCancelling(true);
|
|
2536
3717
|
try {
|
|
2537
|
-
const { summary, results } = await bulkCancelRuns
|
|
3718
|
+
const { summary, results } = await unwrapOrThrow(rpc("bulkCancelRuns", { runIds: cancellableSelectedRuns.map((run) => run.runId) }));
|
|
2538
3719
|
const parts = [];
|
|
2539
3720
|
if (summary.cancelled > 0) parts.push(`${summary.cancelled} cancelled`);
|
|
2540
3721
|
if (summary.alreadyCancelled > 0) parts.push(`${summary.alreadyCancelled} already cancelled`);
|
|
@@ -2554,7 +3735,6 @@ function RunsTable({ onRunClick }) {
|
|
|
2554
3735
|
setIsBulkCancelling(false);
|
|
2555
3736
|
}
|
|
2556
3737
|
}, [
|
|
2557
|
-
env,
|
|
2558
3738
|
cancellableSelectedRuns,
|
|
2559
3739
|
isBulkCancelling,
|
|
2560
3740
|
selection,
|
|
@@ -2564,7 +3744,7 @@ function RunsTable({ onRunClick }) {
|
|
|
2564
3744
|
if (isBulkReenqueuing || selectedRuns.length === 0) return;
|
|
2565
3745
|
setIsBulkReenqueuing(true);
|
|
2566
3746
|
try {
|
|
2567
|
-
const results = await Promise.allSettled(selectedRuns.map((run) => reenqueueRun
|
|
3747
|
+
const results = await Promise.allSettled(selectedRuns.map((run) => unwrapOrThrow(rpc("reenqueueRun", { runId: run.runId }))));
|
|
2568
3748
|
const succeeded = results.filter((r) => r.status === "fulfilled").length;
|
|
2569
3749
|
const failed = results.filter((r) => r.status === "rejected").length;
|
|
2570
3750
|
if (failed === 0) toast.success(`Re-enqueued ${succeeded} run${succeeded !== 1 ? "s" : ""}`);
|
|
@@ -2578,7 +3758,6 @@ function RunsTable({ onRunClick }) {
|
|
|
2578
3758
|
setIsBulkReenqueuing(false);
|
|
2579
3759
|
}
|
|
2580
3760
|
}, [
|
|
2581
|
-
env,
|
|
2582
3761
|
selectedRuns,
|
|
2583
3762
|
isBulkReenqueuing,
|
|
2584
3763
|
selection,
|
|
@@ -2587,14 +3766,6 @@ function RunsTable({ onRunClick }) {
|
|
|
2587
3766
|
const toggleSortOrder = () => {
|
|
2588
3767
|
setSortOrder((prev) => prev === "desc" ? "asc" : "desc");
|
|
2589
3768
|
};
|
|
2590
|
-
(0, import_react.useEffect)(() => {
|
|
2591
|
-
if (isLocalAndHasMissingData) {
|
|
2592
|
-
const interval = setInterval(() => {
|
|
2593
|
-
onRefresh();
|
|
2594
|
-
}, 5e3);
|
|
2595
|
-
return () => clearInterval(interval);
|
|
2596
|
-
}
|
|
2597
|
-
}, [isLocalAndHasMissingData, onRefresh]);
|
|
2598
3769
|
(0, import_react.useEffect)(() => {
|
|
2599
3770
|
const handleVisibilityChange = () => {
|
|
2600
3771
|
if (document.visibilityState === "visible" && lastRefreshTime) {
|
|
@@ -2606,10 +3777,6 @@ function RunsTable({ onRunClick }) {
|
|
|
2606
3777
|
document.removeEventListener("visibilitychange", handleVisibilityChange);
|
|
2607
3778
|
};
|
|
2608
3779
|
}, [lastRefreshTime, onReload]);
|
|
2609
|
-
const localDirText = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("code", {
|
|
2610
|
-
className: "font-mono",
|
|
2611
|
-
children: localShortName || "current directory"
|
|
2612
|
-
});
|
|
2613
3780
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
|
|
2614
3781
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(FilterControls, {
|
|
2615
3782
|
workflowNameFilter,
|
|
@@ -2617,13 +3784,8 @@ function RunsTable({ onRunClick }) {
|
|
|
2617
3784
|
seenWorkflowNames,
|
|
2618
3785
|
sortOrder,
|
|
2619
3786
|
loading,
|
|
2620
|
-
period,
|
|
2621
|
-
showPeriodPicker: isVercelBackend,
|
|
2622
|
-
planWindowMs,
|
|
2623
|
-
planUpgradeAvailable: planInfo?.upgradeAvailable ?? false,
|
|
2624
3787
|
onWorkflowChange: handleWorkflowFilter,
|
|
2625
3788
|
onStatusChange: handleStatusFilter,
|
|
2626
|
-
onPeriodChange: handlePeriodFilter,
|
|
2627
3789
|
onSortToggle: toggleSortOrder,
|
|
2628
3790
|
onRefresh: onReload,
|
|
2629
3791
|
lastRefreshTime
|
|
@@ -2675,7 +3837,7 @@ function RunsTable({ onRunClick }) {
|
|
|
2675
3837
|
className: "max-w-md",
|
|
2676
3838
|
children: [
|
|
2677
3839
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(CircleAlert, { className: "h-4 w-4" }),
|
|
2678
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(AlertTitle, { children:
|
|
3840
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(AlertTitle, { children: "Error loading runs" }),
|
|
2679
3841
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(AlertDescription, { children: getErrorMessage(error) })
|
|
2680
3842
|
]
|
|
2681
3843
|
})
|
|
@@ -2690,19 +3852,12 @@ function RunsTable({ onRunClick }) {
|
|
|
2690
3852
|
}) }) : runs.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableRow, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableCell, {
|
|
2691
3853
|
colSpan: 7,
|
|
2692
3854
|
className: "h-[400px]",
|
|
2693
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.
|
|
3855
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
2694
3856
|
className: "text-sm text-center text-muted-foreground flex flex-col items-center justify-center gap-3 h-full",
|
|
2695
|
-
children:
|
|
3857
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
2696
3858
|
className: "text-sm",
|
|
2697
|
-
children:
|
|
2698
|
-
|
|
2699
|
-
isLocalAndHasMissingData ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [" in ", localDirText] }) : "",
|
|
2700
|
-
"."
|
|
2701
|
-
]
|
|
2702
|
-
}), isLocalAndHasMissingData && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
2703
|
-
className: "text-sm flex items-center gap-2",
|
|
2704
|
-
children: "This view will update once you run a workflow."
|
|
2705
|
-
})]
|
|
3859
|
+
children: "No workflow runs found."
|
|
3860
|
+
})
|
|
2706
3861
|
})
|
|
2707
3862
|
}) }) : runs.map((run) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(TableRow, {
|
|
2708
3863
|
className: "cursor-pointer group relative",
|
|
@@ -2752,7 +3907,6 @@ function RunsTable({ onRunClick }) {
|
|
|
2752
3907
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableCell, {
|
|
2753
3908
|
className: "py-2",
|
|
2754
3909
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LazyDropdownMenu, {
|
|
2755
|
-
env,
|
|
2756
3910
|
runId: run.runId,
|
|
2757
3911
|
runStatus: run.status,
|
|
2758
3912
|
onSuccess: onReload
|
|
@@ -2773,15 +3927,15 @@ function RunsTable({ onRunClick }) {
|
|
|
2773
3927
|
})]
|
|
2774
3928
|
})
|
|
2775
3929
|
}),
|
|
2776
|
-
/* @__PURE__ */ (0, import_jsx_runtime.
|
|
3930
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
2777
3931
|
className: "flex items-center justify-between mt-4 text-sm text-muted-foreground",
|
|
2778
|
-
children:
|
|
3932
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: runs.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
2779
3933
|
"Showing ",
|
|
2780
3934
|
runs.length,
|
|
2781
3935
|
" run",
|
|
2782
3936
|
runs.length === 1 ? "" : "s",
|
|
2783
3937
|
!hasMore && !loading ? " · end of list" : ""
|
|
2784
|
-
] }) })
|
|
3938
|
+
] }) })
|
|
2785
3939
|
}),
|
|
2786
3940
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectionBar, {
|
|
2787
3941
|
selectionCount: selection.selectionCount,
|
|
@@ -2834,10 +3988,7 @@ var home_default = withComponentProps(function Home() {
|
|
|
2834
3988
|
}, { replace: true });
|
|
2835
3989
|
};
|
|
2836
3990
|
const selectedHookId = sidebar === "hook" && hookId ? hookId : void 0;
|
|
2837
|
-
const handleRunClick = (runId
|
|
2838
|
-
if (!streamId) navigate(`/run/${runId}`);
|
|
2839
|
-
else navigate(`/run/${runId}/streams/${streamId}`);
|
|
2840
|
-
};
|
|
3991
|
+
const handleRunClick = (runId) => navigate(`/run/${runId}`);
|
|
2841
3992
|
const handleHookSelect = (hookId, runId) => {
|
|
2842
3993
|
if (hookId) navigate(`/run/${runId}?sidebar=hook&hookId=${hookId}`);
|
|
2843
3994
|
else navigate(`/run/${runId}`);
|