@flanksource/clicky-ui 0.3.57 → 0.3.59

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/dist/clicky.cjs +3 -1
  2. package/dist/clicky.d.ts +1 -0
  3. package/dist/clicky.d.ts.map +1 -1
  4. package/dist/clicky.js +3 -1
  5. package/dist/data/Clicky.cjs +22 -270
  6. package/dist/data/Clicky.cjs.map +1 -1
  7. package/dist/data/Clicky.d.ts +3 -29
  8. package/dist/data/Clicky.d.ts.map +1 -1
  9. package/dist/data/Clicky.js +10 -259
  10. package/dist/data/Clicky.js.map +1 -1
  11. package/dist/data/clicky-download.cjs +251 -0
  12. package/dist/data/clicky-download.cjs.map +1 -0
  13. package/dist/data/clicky-download.d.ts +55 -0
  14. package/dist/data/clicky-download.d.ts.map +1 -0
  15. package/dist/data/clicky-download.js +244 -0
  16. package/dist/data/clicky-download.js.map +1 -0
  17. package/dist/data/traces/index.d.ts +2 -0
  18. package/dist/data/traces/index.d.ts.map +1 -1
  19. package/dist/data/traces/otel/OtelTraceDetail.cjs +102 -78
  20. package/dist/data/traces/otel/OtelTraceDetail.cjs.map +1 -1
  21. package/dist/data/traces/otel/OtelTraceDetail.d.ts +6 -2
  22. package/dist/data/traces/otel/OtelTraceDetail.d.ts.map +1 -1
  23. package/dist/data/traces/otel/OtelTraceDetail.js +102 -78
  24. package/dist/data/traces/otel/OtelTraceDetail.js.map +1 -1
  25. package/dist/data/traces/otel/OtelTraceTable.cjs +43 -7
  26. package/dist/data/traces/otel/OtelTraceTable.cjs.map +1 -1
  27. package/dist/data/traces/otel/OtelTraceTable.d.ts +14 -3
  28. package/dist/data/traces/otel/OtelTraceTable.d.ts.map +1 -1
  29. package/dist/data/traces/otel/OtelTraceTable.js +44 -8
  30. package/dist/data/traces/otel/OtelTraceTable.js.map +1 -1
  31. package/dist/data/traces/otel/profile-listing.cjs +61 -0
  32. package/dist/data/traces/otel/profile-listing.cjs.map +1 -0
  33. package/dist/data/traces/otel/profile-listing.d.ts +23 -0
  34. package/dist/data/traces/otel/profile-listing.d.ts.map +1 -0
  35. package/dist/data/traces/otel/profile-listing.js +60 -0
  36. package/dist/data/traces/otel/profile-listing.js.map +1 -0
  37. package/dist/data/traces/otel/profile-spans.cjs +22 -0
  38. package/dist/data/traces/otel/profile-spans.cjs.map +1 -0
  39. package/dist/data/traces/otel/profile-spans.d.ts +4 -0
  40. package/dist/data/traces/otel/profile-spans.d.ts.map +1 -0
  41. package/dist/data/traces/otel/profile-spans.js +22 -0
  42. package/dist/data/traces/otel/profile-spans.js.map +1 -0
  43. package/dist/data/traces/otel/span-traces.cjs +7 -1
  44. package/dist/data/traces/otel/span-traces.cjs.map +1 -1
  45. package/dist/data/traces/otel/span-traces.d.ts +2 -0
  46. package/dist/data/traces/otel/span-traces.d.ts.map +1 -1
  47. package/dist/data/traces/otel/span-traces.js +7 -2
  48. package/dist/data/traces/otel/span-traces.js.map +1 -1
  49. package/dist/data/useClickyTableMenu.cjs +33 -0
  50. package/dist/data/useClickyTableMenu.cjs.map +1 -0
  51. package/dist/data/useClickyTableMenu.d.ts +17 -0
  52. package/dist/data/useClickyTableMenu.d.ts.map +1 -0
  53. package/dist/data/useClickyTableMenu.js +33 -0
  54. package/dist/data/useClickyTableMenu.js.map +1 -0
  55. package/dist/data/version-info.cjs +3 -3
  56. package/dist/data/version-info.js +3 -3
  57. package/dist/data.cjs +7 -2
  58. package/dist/data.js +5 -3
  59. package/dist/index.cjs +14 -3
  60. package/dist/index.js +9 -4
  61. package/dist/rpc/CommandForm.cjs +1 -1
  62. package/dist/rpc/CommandForm.cjs.map +1 -1
  63. package/dist/rpc/CommandForm.js +1 -1
  64. package/dist/rpc/CommandForm.js.map +1 -1
  65. package/dist/rpc/EntityExplorerApp.cjs +49 -12
  66. package/dist/rpc/EntityExplorerApp.cjs.map +1 -1
  67. package/dist/rpc/EntityExplorerApp.d.ts +10 -1
  68. package/dist/rpc/EntityExplorerApp.d.ts.map +1 -1
  69. package/dist/rpc/EntityExplorerApp.js +51 -14
  70. package/dist/rpc/EntityExplorerApp.js.map +1 -1
  71. package/dist/rpc/EntitySurface.cjs +38 -0
  72. package/dist/rpc/EntitySurface.cjs.map +1 -0
  73. package/dist/rpc/EntitySurface.d.ts +17 -0
  74. package/dist/rpc/EntitySurface.d.ts.map +1 -0
  75. package/dist/rpc/EntitySurface.js +38 -0
  76. package/dist/rpc/EntitySurface.js.map +1 -0
  77. package/dist/rpc/ExplorerNav.cjs +48 -0
  78. package/dist/rpc/ExplorerNav.cjs.map +1 -0
  79. package/dist/rpc/ExplorerNav.d.ts +12 -0
  80. package/dist/rpc/ExplorerNav.d.ts.map +1 -0
  81. package/dist/rpc/ExplorerNav.js +48 -0
  82. package/dist/rpc/ExplorerNav.js.map +1 -0
  83. package/dist/rpc/explorer-nav-context.cjs +5 -0
  84. package/dist/rpc/explorer-nav-context.cjs.map +1 -0
  85. package/dist/rpc/explorer-nav-context.d.ts +11 -0
  86. package/dist/rpc/explorer-nav-context.d.ts.map +1 -0
  87. package/dist/rpc/explorer-nav-context.js +6 -0
  88. package/dist/rpc/explorer-nav-context.js.map +1 -0
  89. package/dist/rpc.cjs +4 -0
  90. package/dist/rpc.d.ts +2 -0
  91. package/dist/rpc.d.ts.map +1 -1
  92. package/dist/rpc.js +3 -1
  93. package/dist/styles.css +1 -1
  94. package/package.json +1 -1
package/dist/clicky.cjs CHANGED
@@ -1,5 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_useClickyTableMenu = require("./data/useClickyTableMenu.cjs");
2
3
  const require_Clicky = require("./data/Clicky.cjs");
3
4
  exports.Clicky = require_Clicky.Clicky;
4
- exports.ClickyNodeView = require_Clicky.ClickyNodeView;
5
+ exports.ClickyNodeView = require_Clicky.ClickyNodeRenderer;
5
6
  exports.ClickyTable = require_Clicky.ClickyTable;
7
+ exports.useClickyTableMenu = require_useClickyTableMenu.useClickyTableMenu;
package/dist/clicky.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export { Clicky, ClickyNodeView, ClickyTable, type ClickyCommandRequest, type ClickyCommandRuntime, type ClickyLinkTarget, type ClickyResolvedCommand, type ClickyColumn, type ClickyDownloadOptions, type ClickyDownloadScope, type ClickyDocument, type ClickyField, type ClickyNode, type ClickyNodeViewProps, type ClickyProps, type ClickyRemoteFormat, type ClickyRow, type ClickyRowDetailRenderer, type ClickyStyle, type ClickyTableProps, type ClickyTableRowHref, type ClickyTableRowClick, type ClickyTableRowPredicate, type ClickyTableRowSelection, type ClickyTreeItem, type ClickyViewOptions, } from './data/Clicky.js';
2
+ export { useClickyTableMenu } from './data/useClickyTableMenu.js';
2
3
  //# sourceMappingURL=clicky.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"clicky.d.ts","sourceRoot":"","sources":["../src/clicky.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,cAAc,EACd,WAAW,EACX,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,EACrB,KAAK,qBAAqB,EAC1B,KAAK,YAAY,EACjB,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,EACxB,KAAK,cAAc,EACnB,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,mBAAmB,EACxB,KAAK,WAAW,EAChB,KAAK,kBAAkB,EACvB,KAAK,SAAS,EACd,KAAK,uBAAuB,EAC5B,KAAK,WAAW,EAChB,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACxB,KAAK,uBAAuB,EAC5B,KAAK,uBAAuB,EAC5B,KAAK,cAAc,EACnB,KAAK,iBAAiB,GACvB,MAAM,eAAe,CAAC"}
1
+ {"version":3,"file":"clicky.d.ts","sourceRoot":"","sources":["../src/clicky.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,cAAc,EACd,WAAW,EACX,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,EACrB,KAAK,qBAAqB,EAC1B,KAAK,YAAY,EACjB,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,EACxB,KAAK,cAAc,EACnB,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,mBAAmB,EACxB,KAAK,WAAW,EAChB,KAAK,kBAAkB,EACvB,KAAK,SAAS,EACd,KAAK,uBAAuB,EAC5B,KAAK,WAAW,EAChB,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACxB,KAAK,uBAAuB,EAC5B,KAAK,uBAAuB,EAC5B,KAAK,cAAc,EACnB,KAAK,iBAAiB,GACvB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC"}
package/dist/clicky.js CHANGED
@@ -1 +1,3 @@
1
- export { Clicky, ClickyNodeView, ClickyTable } from "./data/Clicky.js";
1
+ import { useClickyTableMenu } from "./data/useClickyTableMenu.js";
2
+ import { Clicky, ClickyNodeRenderer, ClickyTable } from "./data/Clicky.js";
3
+ export { Clicky, ClickyNodeRenderer as ClickyNodeView, ClickyTable, useClickyTableMenu };
@@ -1,14 +1,6 @@
1
1
  const require_utils = require("../lib/utils.cjs");
2
2
  const require_UiEllipsis = require("../icons/components/UiEllipsis.cjs");
3
- const require_UiEye = require("../icons/components/UiEye.cjs");
4
3
  const require_UiCheck = require("../icons/components/UiCheck.cjs");
5
- const require_UiTable = require("../icons/components/UiTable.cjs");
6
- const require_UiComment = require("../icons/components/UiComment.cjs");
7
- const require_UiFileCode = require("../icons/components/UiFileCode.cjs");
8
- const require_UiJson = require("../icons/components/UiJson.cjs");
9
- const require_UiMarkdown = require("../icons/components/UiMarkdown.cjs");
10
- const require_UiFileText = require("../icons/components/UiFileText.cjs");
11
- const require_UiFileSpreadsheet = require("../icons/components/UiFileSpreadsheet.cjs");
12
4
  const require_UiCloudDownload = require("../icons/components/UiCloudDownload.cjs");
13
5
  const require_Icon = require("./Icon.cjs");
14
6
  const require_modalStack = require("../overlay/modalStack.cjs");
@@ -35,31 +27,13 @@ const require_ObjectGraph = require("./ObjectGraph.cjs");
35
27
  const require_ExecutionTree = require("./ExecutionTree.cjs");
36
28
  const require_RenderedStackTrace = require("./diagnostics/RenderedStackTrace.cjs");
37
29
  const require_clicky_parse = require("./clicky-parse.cjs");
38
- const require_useDebugAction = require("./useDebugAction.cjs");
39
30
  const require_ClickyExportDialog = require("./clicky-export/ClickyExportDialog.cjs");
40
- const require_useClickyExport = require("./clicky-export/useClickyExport.cjs");
31
+ const require_clicky_download = require("./clicky-download.cjs");
32
+ const require_useClickyTableMenu = require("./useClickyTableMenu.cjs");
41
33
  let react = require("react");
42
34
  let react_jsx_runtime = require("react/jsx-runtime");
43
35
  let _tanstack_react_query = require("@tanstack/react-query");
44
36
  // src/data/Clicky.tsx
45
- var CLICKY_PRIMARY_VIEW_FORMATS = ["clicky", "json"];
46
- var CLICKY_OVERFLOW_VIEW_FORMATS = [
47
- "pdf",
48
- "html",
49
- "markdown",
50
- "yaml",
51
- "csv",
52
- "pretty",
53
- "excel",
54
- "slack"
55
- ];
56
- var CLICKY_DOWNLOAD_FORMATS = [
57
- "yaml",
58
- "json",
59
- "csv",
60
- "pdf",
61
- "markdown"
62
- ];
63
37
  var clickyRuntimeContextDefault = {
64
38
  operations: [],
65
39
  operationsLoading: false
@@ -71,22 +45,12 @@ function Clicky(props) {
71
45
  staleTime: 3e4,
72
46
  retry: 1
73
47
  } } }));
74
- const debugAction = require_useDebugAction.useDebugAction();
75
- const exporter = require_useClickyExport.useClickyExport({
76
- formats: (0, react.useMemo)(() => exportFormatOptions({
77
- url: props.url,
78
- download: props.download
79
- }), [props.download, props.url]),
80
- scopes: (0, react.useMemo)(() => exportScopeOptions(props.download, props.pagination), [props.download, props.pagination]),
81
- onDownload: (0, react.useCallback)(({ format, scope }) => runClickyDownload({
82
- url: props.url ?? "",
83
- format,
84
- scope,
85
- download: props.download
86
- }), [props.download, props.url])
48
+ const { actions: tableMenuActions, dialog: exportDialog } = require_useClickyTableMenu.useClickyTableMenu({
49
+ url: props.url,
50
+ download: props.download,
51
+ pagination: props.pagination
87
52
  });
88
- const tableMenuActions = (0, react.useMemo)(() => [exporter.action, debugAction].filter((action) => action !== void 0), [exporter.action, debugAction]);
89
- const content = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [exporter.dialog, /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ClickyRuntimeProvider, {
53
+ const content = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [exportDialog, /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ClickyRuntimeProvider, {
90
54
  ...props.commandRuntime ? { commandRuntime: props.commandRuntime } : {},
91
55
  ...props.onTableRowClick ? { onTableRowClick: props.onTableRowClick } : {},
92
56
  ...props.getTableRowHref ? { getTableRowHref: props.getTableRowHref } : {},
@@ -271,7 +235,7 @@ function ClickyRemoteRenderer({ data, dataFormat, url, view, download, className
271
235
  ]);
272
236
  const primaryViews = (0, react.useMemo)(() => availableViews.filter(isPrimaryViewFormat), [availableViews]);
273
237
  const overflowViews = (0, react.useMemo)(() => availableViews.filter(isOverflowViewFormat), [availableViews]);
274
- const downloadFormats = (0, react.useMemo)(() => getDownloadFormats({
238
+ const downloadFormats = (0, react.useMemo)(() => require_clicky_download.getDownloadFormats({
275
239
  url,
276
240
  download
277
241
  }), [download, url]);
@@ -279,7 +243,7 @@ function ClickyRemoteRenderer({ data, dataFormat, url, view, download, className
279
243
  (0, react.useEffect)(() => {
280
244
  if (!availableViews.includes(activeView)) setActiveView(availableViews[0] ?? "clicky");
281
245
  }, [activeView, availableViews]);
282
- const formattedUrl = buildFormatUrl(url, activeView);
246
+ const formattedUrl = require_clicky_download.buildFormatUrl(url, activeView);
283
247
  const suppliedView = data !== void 0 ? dataFormat : void 0;
284
248
  const activeQuery = (0, _tanstack_react_query.useQuery)({
285
249
  queryKey: [
@@ -302,7 +266,7 @@ function ClickyRemoteRenderer({ data, dataFormat, url, view, download, className
302
266
  const tableHostsControls = downloadHandledByTable && activeView === "clicky";
303
267
  const viewMenuActions = (0, react.useMemo)(() => {
304
268
  if (!tableHostsControls || availableViews.length <= 1) return [];
305
- const activeMeta = getRemoteFormatMeta(activeView);
269
+ const activeMeta = require_clicky_download.getRemoteFormatMeta(activeView);
306
270
  return [{
307
271
  id: "view",
308
272
  label: `View: ${formatViewLabel(activeView)}`,
@@ -310,7 +274,7 @@ function ClickyRemoteRenderer({ data, dataFormat, url, view, download, className
310
274
  ...activeMeta.iconClassName ? { iconClassName: activeMeta.iconClassName } : {},
311
275
  section: "",
312
276
  children: availableViews.map((format) => {
313
- const meta = getRemoteFormatMeta(format);
277
+ const meta = require_clicky_download.getRemoteFormatMeta(format);
314
278
  return {
315
279
  id: `view-${format}`,
316
280
  label: formatViewLabel(format),
@@ -417,7 +381,7 @@ function ClickyViewMenu({ activeFormat, formats, onSelect }) {
417
381
  className: "absolute left-0 top-[calc(100%+0.375rem)] z-50 min-w-[18rem] rounded-md border border-border bg-popover p-1.5 text-popover-foreground shadow-lg shadow-black/5",
418
382
  children: formats.map((format) => {
419
383
  const active = format === activeFormat;
420
- const meta = getRemoteFormatMeta(format);
384
+ const meta = require_clicky_download.getRemoteFormatMeta(format);
421
385
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
422
386
  type: "button",
423
387
  role: "menuitemradio",
@@ -453,11 +417,11 @@ function ClickyViewMenu({ activeFormat, formats, onSelect }) {
453
417
  }
454
418
  function ClickyExportButton({ url, download }) {
455
419
  const [open, setOpen] = (0, react.useState)(false);
456
- const formats = (0, react.useMemo)(() => exportFormatOptions({
420
+ const formats = (0, react.useMemo)(() => require_clicky_download.exportFormatOptions({
457
421
  url,
458
422
  download
459
423
  }), [download, url]);
460
- const scopes = (0, react.useMemo)(() => exportScopeOptions(download), [download]);
424
+ const scopes = (0, react.useMemo)(() => require_clicky_download.exportScopeOptions(download), [download]);
461
425
  if (formats.length === 0) return null;
462
426
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
463
427
  type: "button",
@@ -473,7 +437,7 @@ function ClickyExportButton({ url, download }) {
473
437
  onClose: () => setOpen(false),
474
438
  formats,
475
439
  scopes,
476
- onDownload: ({ format, scope }) => runClickyDownload({
440
+ onDownload: ({ format, scope }) => require_clicky_download.runClickyDownload({
477
441
  url,
478
442
  format,
479
443
  scope,
@@ -503,7 +467,7 @@ function useDismissablePopup(open, rootRef, triggerRef, onClose) {
503
467
  ]);
504
468
  }
505
469
  function fetchRemoteFormat(url, format) {
506
- return fetch(url, { headers: { Accept: getRemoteFormatMeta(format).accept } }).then(async (response) => {
470
+ return fetch(url, { headers: { Accept: require_clicky_download.getRemoteFormatMeta(format).accept } }).then(async (response) => {
507
471
  if (!response.ok) throw require_apiClient.errorFromResponse(response, "GET", url, await require_apiClient.readResponseBody(response, "json"));
508
472
  const contentType = response.headers.get("Content-Type") ?? "";
509
473
  if (format === "excel") return {
@@ -594,7 +558,7 @@ function ClickyUnsupportedPreview({ title, message, href }) {
594
558
  });
595
559
  }
596
560
  function ClickyRemotePreview({ format, response }) {
597
- const meta = getRemoteFormatMeta(format);
561
+ const meta = require_clicky_download.getRemoteFormatMeta(format);
598
562
  if (format === "slack") {
599
563
  const parsed = response?.kind === "text" ? parseJsonValue(response.text) : void 0;
600
564
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ClickyJsonTree, {
@@ -671,215 +635,21 @@ function getAvailableViews({ data, url, view }) {
671
635
  const next = [];
672
636
  if (allowClicky && (url || data !== void 0)) next.push("clicky");
673
637
  if (allowJson && (url || data !== void 0)) next.push("json");
674
- for (const format of CLICKY_OVERFLOW_VIEW_FORMATS) if (resolveViewConfigFlag(view, format, data, url) && url) next.push(format);
638
+ for (const format of require_clicky_download.CLICKY_OVERFLOW_VIEW_FORMATS) if (resolveViewConfigFlag(view, format, data, url) && url) next.push(format);
675
639
  if (next.length === 0 && (url || data !== void 0)) next.push("clicky");
676
640
  return next;
677
641
  }
678
- function getDownloadFormats({ url, download }) {
679
- if (!(download ? download.all ?? true : !!url) || !url) return [];
680
- return download?.formats?.length ? [...download.formats] : [...CLICKY_DOWNLOAD_FORMATS];
681
- }
682
- function getDownloadScopes(download) {
683
- return download?.scopes?.length ? download.scopes : [void 0];
684
- }
685
- function downloadDescription(format, scope, download) {
686
- const maxRows = download?.formatMaxRows?.[format];
687
- if (maxRows) return `Limited to ${maxRows.toLocaleString()} rows`;
688
- if (scope === "all" && download?.allRowsMode === "buffered") return "Compatibility mode buffers the complete result";
689
- if (scope === "all" && download?.allRowsMode === "streaming") return "Streams rows as they are read";
690
- }
691
- function exportFormatOptions({ url, download }) {
692
- if (!url) return [];
693
- return getDownloadFormats({
694
- url,
695
- download
696
- }).map((format) => {
697
- const meta = getRemoteFormatMeta(format);
698
- return {
699
- format,
700
- label: meta.label,
701
- description: meta.description,
702
- icon: meta.icon,
703
- ...meta.iconClassName ? { iconClassName: meta.iconClassName } : {}
704
- };
705
- });
706
- }
707
- function exportScopeOptions(download, pagination) {
708
- return getDownloadScopes(download).map((scope) => ({
709
- scope,
710
- label: scope === "all" || scope === void 0 ? allRowsLabel(pagination) : "Current page",
711
- note: (format) => downloadDescription(format, scope, download)
712
- }));
713
- }
714
- function allRowsLabel(pagination) {
715
- const total = pagination?.total;
716
- if (total === void 0) return "All rows";
717
- const count = total.toLocaleString();
718
- return pagination?.totalRelation === "gte" ? `All ${count}+ rows` : `All ${count} rows`;
719
- }
720
- async function runClickyDownload({ url, format, scope, download }) {
721
- let failure = "";
722
- await prepareDownload({
723
- url,
724
- format,
725
- ...scope ? { scope } : {},
726
- ...download ? { download } : {},
727
- onError: (message) => {
728
- failure = message;
729
- }
730
- });
731
- if (failure) throw new Error(failure);
732
- }
733
- async function prepareDownload({ url, format, scope, download, onPending, onError }) {
734
- onError?.("");
735
- onPending?.(true);
736
- try {
737
- const prepared = download?.prepare ? await download.prepare({
738
- format,
739
- ...scope ? { scope } : {}
740
- }) : {
741
- url,
742
- ...download?.label ? { label: download.label } : {}
743
- };
744
- if (!prepared.url.trim()) throw new Error("The prepared download URL is empty");
745
- triggerDownload(buildDownloadUrl(prepared.url, format, prepared.label ?? download?.label, scope));
746
- } catch (error) {
747
- onError?.(error instanceof Error ? error.message : "Preparing the download failed");
748
- } finally {
749
- onPending?.(false);
750
- }
751
- }
752
- function getRemoteFormatMeta(format) {
753
- switch (format) {
754
- case "clicky": return {
755
- label: "Clicky",
756
- description: "Rendered Clicky JSON with the rich Clicky viewer",
757
- icon: require_UiEye.UiEye,
758
- accept: "application/json+clicky, application/clicky+json;q=0.9, application/json;q=0.8,*/*;q=0.7"
759
- };
760
- case "json": return {
761
- label: "JSON",
762
- description: "Plain JSON for inspecting the raw response body",
763
- icon: require_UiJson.UiJson,
764
- accept: "application/json, text/plain;q=0.8,*/*;q=0.7"
765
- };
766
- case "ndjson": return {
767
- label: "NDJSON",
768
- description: "Newline-delimited JSON for streaming data pipelines",
769
- icon: require_UiJson.UiJson,
770
- accept: "application/x-ndjson, application/ndjson;q=0.9,*/*;q=0.7"
771
- };
772
- case "pdf": return {
773
- label: "PDF",
774
- description: "Portable document for sharing and printing",
775
- icon: require_UiFileText.UiFileText,
776
- iconClassName: "text-rose-600 dark:text-rose-400",
777
- accept: "application/pdf, */*;q=0.7"
778
- };
779
- case "html": return {
780
- label: "HTML",
781
- description: "Browser-ready HTML preview of the formatted output",
782
- icon: require_UiFileCode.UiFileCode,
783
- accept: "text/html, */*;q=0.7"
784
- };
785
- case "markdown": return {
786
- label: "Markdown",
787
- description: "Markdown formatted for docs, comments, and chat",
788
- icon: require_UiMarkdown.UiMarkdown,
789
- accept: "text/markdown, text/plain;q=0.8,*/*;q=0.7"
790
- };
791
- case "yaml": return {
792
- label: "YAML",
793
- description: "YAML for config-friendly inspection and export",
794
- icon: require_UiFileCode.UiFileCode,
795
- iconClassName: "text-violet-600 dark:text-violet-400",
796
- accept: "application/yaml, text/yaml;q=0.9, text/plain;q=0.8,*/*;q=0.7"
797
- };
798
- case "csv": return {
799
- label: "CSV",
800
- description: "Comma-separated values for spreadsheets and imports",
801
- icon: require_UiFileSpreadsheet.UiFileSpreadsheet,
802
- iconClassName: "text-emerald-600 dark:text-emerald-400",
803
- accept: "text/csv, text/plain;q=0.8,*/*;q=0.7"
804
- };
805
- case "pretty": return {
806
- label: "Pretty",
807
- description: "Human-readable plain text output from the formatter",
808
- icon: require_UiFileCode.UiFileCode,
809
- accept: "text/plain, */*;q=0.7"
810
- };
811
- case "excel": return {
812
- label: "Excel",
813
- description: "Spreadsheet workbook for offline analysis",
814
- icon: require_UiTable.UiTable,
815
- accept: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, */*;q=0.7"
816
- };
817
- case "slack": return {
818
- label: "Slack",
819
- description: "Slack Block Kit JSON for chat-native output",
820
- icon: require_UiComment.UiComment,
821
- accept: "application/vnd.slack.block-kit+json, application/json;q=0.8,*/*;q=0.7"
822
- };
823
- }
824
- }
825
642
  function formatViewLabel(mode) {
826
- return getRemoteFormatMeta(mode).label;
827
- }
828
- function buildFormatUrl(url, format) {
829
- const base = typeof window === "undefined" ? "http://localhost" : window.location.origin;
830
- const resolved = new URL(url, base);
831
- resolved.searchParams.set("format", format === "clicky" ? "clicky-json" : format);
832
- if (isAbsoluteUrl(url)) return resolved.toString();
833
- return `${resolved.pathname}${resolved.search}${resolved.hash}`;
834
- }
835
- function buildDownloadUrl(url, format, label, scope) {
836
- const formatted = buildFormatUrl(url, format);
837
- const base = typeof window === "undefined" ? "http://localhost" : window.location.origin;
838
- const resolved = new URL(formatted, base);
839
- resolved.searchParams.set("filename", downloadFilename(url, format, label));
840
- resolved.searchParams.set("_download", Date.now().toString());
841
- if (scope) resolved.searchParams.set("scope", scope);
842
- if (scope === "all") {
843
- resolved.searchParams.delete("limit");
844
- resolved.searchParams.delete("offset");
845
- resolved.searchParams.delete("page");
846
- }
847
- if (isAbsoluteUrl(formatted)) return resolved.toString();
848
- return `${resolved.pathname}${resolved.search}${resolved.hash}`;
849
- }
850
- function downloadFilename(url, format, label) {
851
- return `${sanitizeFilenameStem(label || filenameStemFromUrl(url) || "clicky-output")}${downloadExtension(format)}`;
852
- }
853
- function filenameStemFromUrl(url) {
854
- const base = typeof window === "undefined" ? "http://localhost" : window.location.origin;
855
- return new URL(url, base).pathname.split("/").filter(Boolean).at(-1) ?? "";
856
- }
857
- function sanitizeFilenameStem(value) {
858
- return require_string.stripSurroundingChars(value.trim().replace(/\.[a-z0-9]+$/i, "").replace(/[^a-z0-9._-]+/gi, "-").replace(/-+/g, "-"), "._-") || "clicky-output";
859
- }
860
- function downloadExtension(format) {
861
- switch (format) {
862
- case "clicky": return ".clicky.json";
863
- case "json": return ".json";
864
- case "ndjson": return ".ndjson";
865
- case "pdf": return ".pdf";
866
- case "html": return ".html";
867
- case "markdown": return ".md";
868
- case "yaml": return ".yaml";
869
- case "csv": return ".csv";
870
- case "pretty": return ".txt";
871
- case "excel": return ".xlsx";
872
- case "slack": return ".slack.json";
873
- }
643
+ return require_clicky_download.getRemoteFormatMeta(mode).label;
874
644
  }
875
645
  function shouldFetchRemoteView(format) {
876
646
  return format !== "pdf" && format !== "html" && format !== "excel";
877
647
  }
878
648
  function isPrimaryViewFormat(format) {
879
- return CLICKY_PRIMARY_VIEW_FORMATS.includes(format);
649
+ return require_clicky_download.CLICKY_PRIMARY_VIEW_FORMATS.includes(format);
880
650
  }
881
651
  function isOverflowViewFormat(format) {
882
- return CLICKY_OVERFLOW_VIEW_FORMATS.includes(format);
652
+ return require_clicky_download.CLICKY_OVERFLOW_VIEW_FORMATS.includes(format);
883
653
  }
884
654
  function resolveViewConfigFlag(view, format, data, url) {
885
655
  const defaultEnabled = format === "clicky" || format === "json" ? url != null || data !== void 0 : !!url;
@@ -956,25 +726,6 @@ function summarizeJsonValue(value) {
956
726
  function isPlainObject(value) {
957
727
  return value != null && typeof value === "object" && !Array.isArray(value);
958
728
  }
959
- var CLICKY_DOWNLOAD_FRAME_ID = "clicky-download-frame";
960
- function triggerDownload(url) {
961
- if (typeof document === "undefined") return;
962
- let frame = document.getElementById(CLICKY_DOWNLOAD_FRAME_ID);
963
- if (!frame) {
964
- frame = document.createElement("iframe");
965
- frame.id = CLICKY_DOWNLOAD_FRAME_ID;
966
- frame.name = CLICKY_DOWNLOAD_FRAME_ID;
967
- frame.title = "Clicky download target";
968
- frame.setAttribute("aria-hidden", "true");
969
- frame.tabIndex = -1;
970
- frame.style.display = "none";
971
- document.body.appendChild(frame);
972
- }
973
- frame.src = url;
974
- }
975
- function isAbsoluteUrl(url) {
976
- return /^[a-z][a-z\d+\-.]*:/i.test(url) || url.startsWith("//");
977
- }
978
729
  /**
979
730
  * clicky's Go text styling (e.g. xetrace/pretty.go, clicky/api/text.go) uses
980
731
  * "text-muted" as the terminal's "dim" style, the same way it uses
@@ -2350,6 +2101,7 @@ function isInlineNode(node) {
2350
2101
  return node.kind === "text" || node.kind === "link" || node.kind === "link-command" || node.kind === "icon" || node.kind === "html" || node.kind === "footnote-ref" || node.kind === "badge" || node.kind === "button" || node.kind === "button-group";
2351
2102
  }
2352
2103
  exports.Clicky = Clicky;
2104
+ exports.ClickyNodeRenderer = ClickyNodeRenderer;
2353
2105
  exports.ClickyNodeView = ClickyNodeRenderer;
2354
2106
  exports.ClickyTable = ClickyTable;
2355
2107