@msqd/lydia 0.6.0 → 0.6.1

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.
@@ -1,13 +1,14 @@
1
- import { jsx as t, jsxs as c, Fragment as J } from "react/jsx-runtime";
2
- import { useState as O } from "react";
3
- import { twMerge as h } from "tailwind-merge";
1
+ import { jsx as t, jsxs as s, Fragment as O } from "react/jsx-runtime";
2
+ import { useState as S } from "react";
3
+ import { twMerge as j } from "tailwind-merge";
4
+ const N = 64;
4
5
  function I({
5
6
  data: r,
6
7
  initiallyExpanded: u = !1,
7
- expandedDepth: s = 1,
8
- onValueClick: a,
9
- className: l,
10
- ...i
8
+ expandedDepth: o = 1,
9
+ onValueClick: l,
10
+ className: i,
11
+ ...a
11
12
  }) {
12
13
  let n;
13
14
  try {
@@ -18,29 +19,29 @@ function I({
18
19
  return /* @__PURE__ */ t(
19
20
  "div",
20
21
  {
21
- className: h("font-mono text-sm text-gray-800 p-4 bg-white rounded-md border border-gray-200", l),
22
- ...i,
22
+ className: j("font-mono text-sm text-gray-800 p-4 bg-white rounded-md border border-gray-200", i),
23
+ ...a,
23
24
  children: /* @__PURE__ */ t(
24
- p,
25
+ f,
25
26
  {
26
27
  data: n,
27
28
  name: "root",
28
29
  path: "$",
29
30
  initiallyExpanded: u,
30
- expandedDepth: s,
31
+ expandedDepth: o,
31
32
  depth: 0,
32
- onValueClick: a
33
+ onValueClick: l
33
34
  }
34
35
  )
35
36
  }
36
37
  );
37
38
  }
38
- function p({ data: r, name: u, path: s, initiallyExpanded: a, expandedDepth: l, depth: i, onValueClick: n }) {
39
- const d = a || i < l, [m, y] = O(d), e = S(r), j = e === "object" ? Object.keys(r).length : e === "array" ? r.length : null, N = () => {
40
- y(!m);
41
- }, x = () => {
42
- e !== "object" && e !== "array" && n && n(s, r);
43
- }, w = () => {
39
+ function f({ data: r, name: u, path: o, initiallyExpanded: l, expandedDepth: i, depth: a, onValueClick: n }) {
40
+ const d = l || a < i, [m, x] = S(d), e = A(r), h = e === "object" ? Object.keys(r).length : e === "array" ? r.length : null, b = a >= N && !!h, w = () => {
41
+ x(!m);
42
+ }, $ = () => {
43
+ e !== "object" && e !== "array" && n && n(o, r);
44
+ }, v = () => {
44
45
  switch (e) {
45
46
  case "string":
46
47
  return "text-green-700";
@@ -53,7 +54,7 @@ function p({ data: r, name: u, path: s, initiallyExpanded: a, expandedDepth: l,
53
54
  default:
54
55
  return "";
55
56
  }
56
- }, $ = () => {
57
+ }, T = () => {
57
58
  switch (e) {
58
59
  case "string":
59
60
  return `"${r}"`;
@@ -62,48 +63,51 @@ function p({ data: r, name: u, path: s, initiallyExpanded: a, expandedDepth: l,
62
63
  default:
63
64
  return String(r);
64
65
  }
65
- }, v = () => {
66
+ }, J = () => {
66
67
  if (e === "object") {
67
- const b = r;
68
- return Object.keys(b).map((o) => /* @__PURE__ */ t("div", { className: "ml-4 my-1", children: /* @__PURE__ */ t(
69
- p,
68
+ const p = r;
69
+ return Object.keys(p).map((c) => /* @__PURE__ */ t("div", { className: "ml-4 my-1", children: /* @__PURE__ */ t(
70
+ f,
70
71
  {
71
- data: b[o],
72
- name: o,
73
- path: `${s}.${o}`,
74
- initiallyExpanded: a,
75
- expandedDepth: l,
76
- depth: i + 1,
72
+ data: p[c],
73
+ name: c,
74
+ path: `${o}.${c}`,
75
+ initiallyExpanded: l,
76
+ expandedDepth: i,
77
+ depth: a + 1,
77
78
  onValueClick: n
78
79
  }
79
- ) }, o));
80
+ ) }, c));
80
81
  } else if (e === "array")
81
- return r.map((o, g) => /* @__PURE__ */ t("div", { className: "ml-4 my-1", children: /* @__PURE__ */ t(
82
- p,
82
+ return r.map((c, g) => /* @__PURE__ */ t("div", { className: "ml-4 my-1", children: /* @__PURE__ */ t(
83
+ f,
83
84
  {
84
- data: o,
85
+ data: c,
85
86
  name: `${g}`,
86
- path: `${s}[${g}]`,
87
- initiallyExpanded: a,
88
- expandedDepth: l,
89
- depth: i + 1,
87
+ path: `${o}[${g}]`,
88
+ initiallyExpanded: l,
89
+ expandedDepth: i,
90
+ depth: a + 1,
90
91
  onValueClick: n
91
92
  }
92
93
  ) }, g));
93
94
  return null;
94
- }, f = s === "$" ? "" : u;
95
- return /* @__PURE__ */ c("div", { className: "node", children: [
96
- /* @__PURE__ */ c("div", { className: "flex items-start", children: [
97
- e === "object" || e === "array" ? /* @__PURE__ */ t("button", { type: "button", onClick: N, className: "mr-1 inline-block w-4 text-gray-500 focus:outline-none", children: m ? "▼" : "►" }) : /* @__PURE__ */ t("span", { className: "mr-1 inline-block w-4" }),
98
- f && /* @__PURE__ */ c("span", { className: "mr-1 font-semibold", children: [
99
- f,
95
+ }, y = o === "$" ? "" : u;
96
+ return /* @__PURE__ */ s("div", { className: "node", children: [
97
+ /* @__PURE__ */ s("div", { className: "flex items-start", children: [
98
+ b ? /* @__PURE__ */ t("span", { className: "mr-1 inline-block w-4" }) : e === "object" || e === "array" ? /* @__PURE__ */ t("button", { type: "button", onClick: w, className: "mr-1 inline-block w-4 text-gray-500 focus:outline-none", children: m ? "▼" : "►" }) : /* @__PURE__ */ t("span", { className: "mr-1 inline-block w-4" }),
99
+ y && /* @__PURE__ */ s("span", { className: "mr-1 font-semibold", children: [
100
+ y,
100
101
  ":"
101
102
  ] }),
102
- e === "object" || e === "array" ? /* @__PURE__ */ c("span", { children: [
103
+ e === "object" || e === "array" ? /* @__PURE__ */ s("span", { children: [
103
104
  e === "object" ? "{" : "[",
104
- !m && /* @__PURE__ */ c("span", { className: "text-gray-500", children: [
105
+ b ? /* @__PURE__ */ s("span", { className: "text-gray-500", title: `Maximum depth of ${N} levels reached`, children: [
106
+ " ",
107
+ "…"
108
+ ] }) : !m && /* @__PURE__ */ s("span", { className: "text-gray-500", children: [
105
109
  " ",
106
- j,
110
+ h,
107
111
  " ",
108
112
  e === "object" ? "properties" : "items",
109
113
  " ",
@@ -112,19 +116,19 @@ function p({ data: r, name: u, path: s, initiallyExpanded: a, expandedDepth: l,
112
116
  ] }) : /* @__PURE__ */ t(
113
117
  "span",
114
118
  {
115
- className: h(w(), n && "cursor-pointer hover:underline"),
116
- onClick: x,
117
- children: $()
119
+ className: j(v(), n && "cursor-pointer hover:underline"),
120
+ onClick: $,
121
+ children: T()
118
122
  }
119
123
  )
120
124
  ] }),
121
- m && (e === "object" || e === "array") && /* @__PURE__ */ c(J, { children: [
122
- /* @__PURE__ */ t("div", { children: v() }),
125
+ m && !b && (e === "object" || e === "array") && /* @__PURE__ */ s(O, { children: [
126
+ /* @__PURE__ */ t("div", { children: J() }),
123
127
  /* @__PURE__ */ t("div", { className: "ml-4", children: e === "object" ? "}" : "]" })
124
128
  ] })
125
129
  ] });
126
130
  }
127
- function S(r) {
131
+ function A(r) {
128
132
  if (r === null) return "null";
129
133
  if (Array.isArray(r)) return "array";
130
134
  switch (typeof r) {
@@ -1,73 +1,73 @@
1
1
  import { jsx as e, jsxs as s } from "react/jsx-runtime";
2
- import { ClipboardDocumentIcon as N, ArrowRightIcon as v } from "@heroicons/react/24/outline";
3
- import { Foldable as y } from "../../../../Components/Utilities/Foldable.js";
4
- import { TpdexBadge as a } from "../../../../Elements/Tpdex/TpdexBadge.js";
5
- import { splitRequestTarget as C } from "../../../../Models/Http/requestTarget.js";
2
+ import { ClipboardDocumentIcon as y, ArrowRightIcon as v } from "@heroicons/react/24/outline";
3
+ import { Foldable as C } from "../../../../Components/Utilities/Foldable.js";
4
+ import { TpdexBadge as i } from "../../../../Elements/Tpdex/TpdexBadge.js";
5
+ import { splitRequestTarget as T } from "../../../../Models/Http/requestTarget.js";
6
6
  import "react";
7
- import { twMerge as T } from "tailwind-merge";
8
- import { useSuccessToast as S } from "../../../../Components/Toast/ToastContext.js";
9
- import { RequestMethodBadge as l } from "../../../../Elements/Http/RequestMethodBadge.js";
10
- import { Button as b } from "../../../../Components/Buttons/Button.js";
11
- import { ResponseStatusBadge as c } from "../../../../Elements/Http/ResponseStatusBadge.js";
12
- import { CacheBadge as w } from "../../../../Elements/Http/CacheBadge.js";
13
- import { Badge as A } from "../../../../Components/Badges/Badge.js";
14
- import { contentPaddingClassName as R } from "../../../../Components/Cards/Card.js";
15
- import { CacheIndicator as D } from "../../../../Elements/Http/CacheIndicator.js";
16
- function H({
7
+ import { twMerge as S } from "tailwind-merge";
8
+ import { useSuccessToast as b, useErrorToast as w } from "../../../../Components/Toast/ToastContext.js";
9
+ import { RequestMethodBadge as a } from "../../../../Elements/Http/RequestMethodBadge.js";
10
+ import { Button as A } from "../../../../Components/Buttons/Button.js";
11
+ import { ResponseStatusBadge as l } from "../../../../Elements/Http/ResponseStatusBadge.js";
12
+ import { CacheBadge as R } from "../../../../Elements/Http/CacheBadge.js";
13
+ import { Badge as D } from "../../../../Components/Badges/Badge.js";
14
+ import { contentPaddingClassName as B } from "../../../../Components/Cards/Card.js";
15
+ import { CacheIndicator as j } from "../../../../Elements/Http/CacheIndicator.js";
16
+ function J({
17
17
  transaction: t,
18
18
  tags: d = {},
19
- defaultOpen: o = !1,
20
- className: n,
21
- ...h
19
+ defaultOpen: c = !1,
20
+ className: o,
21
+ ...n
22
22
  }) {
23
- const i = S(), x = new Date(t.timestamp).toLocaleString(), p = async (r, m) => {
23
+ const h = b(), p = w(), x = new Date(t.timestamp).toLocaleString(), u = async (m, r) => {
24
24
  try {
25
- await navigator.clipboard.writeText(r), i("Copied", `${m} copied to clipboard`);
25
+ await navigator.clipboard.writeText(m), h("Copied", `${r} copied to clipboard`);
26
26
  } catch {
27
- i("Copy", m);
27
+ p(`${r} not copied`, `Copy it by hand: ${m}`);
28
28
  }
29
29
  }, g = () => {
30
- const { path: r, query: m } = C(t.url);
30
+ const { path: m, query: r } = T(t.url);
31
31
  return /* @__PURE__ */ s("span", { className: "font-normal", children: [
32
- /* @__PURE__ */ e(l, { method: t.method }),
32
+ /* @__PURE__ */ e(a, { method: t.method }),
33
33
  t.apiName && /* @__PURE__ */ e("span", { className: "inline-flex items-center bg-gray-50 px-1 ml-2 py-0.5 text-xs font-medium text-gray-700 ring-1 ring-inset ring-gray-600/20", children: t.apiName }),
34
- /* @__PURE__ */ e("span", { className: "text-gray-500 font-mono text-xs ml-1", title: t.url, children: r }),
35
- m && /* @__PURE__ */ e("span", { className: "text-gray-500 font-mono text-xs", title: t.url, children: m })
34
+ /* @__PURE__ */ e("span", { className: "text-gray-500 font-mono text-xs ml-1", title: t.url, children: m }),
35
+ r && /* @__PURE__ */ e("span", { className: "text-gray-500 font-mono text-xs", title: t.url, children: r })
36
36
  ] });
37
- }, u = () => /* @__PURE__ */ e("span", { className: "font-normal", children: /* @__PURE__ */ e(c, { statusCode: t.statusCode }) }), f = () => /* @__PURE__ */ s("div", { className: "flex gap-x-1 items-center font-normal", children: [
38
- /* @__PURE__ */ e(a, { score: t.tpdex, responseTime: t.responseTime }),
37
+ }, f = () => /* @__PURE__ */ e("span", { className: "font-normal", children: /* @__PURE__ */ e(l, { statusCode: t.statusCode }) }), N = () => /* @__PURE__ */ s("div", { className: "flex gap-x-1 items-center font-normal", children: [
38
+ /* @__PURE__ */ e(i, { score: t.tpdex, responseTime: t.responseTime }),
39
39
  /* @__PURE__ */ s("span", { className: "text-sm", children: [
40
40
  t.responseTime,
41
41
  "ms"
42
42
  ] }),
43
- /* @__PURE__ */ e(D, { cacheStatus: t.cacheStatus, cached: t.cached, size: "sm" })
43
+ /* @__PURE__ */ e(j, { cacheStatus: t.cacheStatus, cached: t.cached, size: "sm" })
44
44
  ] });
45
- return /* @__PURE__ */ e("div", { className: T(R, n), ...h, children: /* @__PURE__ */ e(
46
- y,
45
+ return /* @__PURE__ */ e("div", { className: S(B, o), ...n, children: /* @__PURE__ */ e(
46
+ C,
47
47
  {
48
48
  title: /* @__PURE__ */ s("div", { className: "flex gap-x-1 items-center", children: [
49
49
  /* @__PURE__ */ e(g, {}),
50
50
  /* @__PURE__ */ e(v, { className: "h-4 w-4 text-gray-400 mx-1" }),
51
- /* @__PURE__ */ e(u, {}),
51
+ /* @__PURE__ */ e(f, {}),
52
52
  /* @__PURE__ */ e("div", { className: "flex-1" }),
53
- /* @__PURE__ */ e(f, {})
53
+ /* @__PURE__ */ e(N, {})
54
54
  ] }),
55
- defaultOpen: o,
55
+ defaultOpen: c,
56
56
  children: /* @__PURE__ */ s("div", { className: "space-y-4", children: [
57
57
  /* @__PURE__ */ s("div", { className: "flex items-center justify-between p-4 bg-gray-50 rounded-md", children: [
58
58
  /* @__PURE__ */ s("div", { className: "flex items-center space-x-3", children: [
59
- /* @__PURE__ */ e(l, { method: t.method }),
59
+ /* @__PURE__ */ e(a, { method: t.method }),
60
60
  /* @__PURE__ */ e("span", { className: "font-mono text-sm text-gray-900 break-all", children: t.url })
61
61
  ] }),
62
62
  /* @__PURE__ */ s(
63
- b,
63
+ A,
64
64
  {
65
65
  variant: "secondary",
66
66
  size: "sm",
67
- onClick: () => p(`${t.method} ${t.url}`, "Transaction URL"),
67
+ onClick: () => u(`${t.method} ${t.url}`, "Transaction URL"),
68
68
  className: "flex items-center space-x-1 flex-shrink-0",
69
69
  children: [
70
- /* @__PURE__ */ e(N, { className: "h-4 w-4" }),
70
+ /* @__PURE__ */ e(y, { className: "h-4 w-4" }),
71
71
  /* @__PURE__ */ e("span", { children: "Copy" })
72
72
  ]
73
73
  }
@@ -76,7 +76,7 @@ function H({
76
76
  /* @__PURE__ */ s("div", { className: "grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4", children: [
77
77
  /* @__PURE__ */ s("div", { children: [
78
78
  /* @__PURE__ */ e("div", { className: "text-sm font-medium text-gray-500", children: "Status" }),
79
- /* @__PURE__ */ e("div", { className: "mt-1", children: /* @__PURE__ */ e(c, { statusCode: t.statusCode }) })
79
+ /* @__PURE__ */ e("div", { className: "mt-1", children: /* @__PURE__ */ e(l, { statusCode: t.statusCode }) })
80
80
  ] }),
81
81
  /* @__PURE__ */ s("div", { children: [
82
82
  /* @__PURE__ */ e("div", { className: "text-sm font-medium text-gray-500", children: "Duration" }),
@@ -87,11 +87,11 @@ function H({
87
87
  ] }),
88
88
  /* @__PURE__ */ s("div", { children: [
89
89
  /* @__PURE__ */ e("div", { className: "text-sm font-medium text-gray-500", children: "TPDEX" }),
90
- /* @__PURE__ */ e("div", { className: "mt-1", children: /* @__PURE__ */ e(a, { score: t.tpdex, responseTime: t.responseTime, showScore: !0 }) })
90
+ /* @__PURE__ */ e("div", { className: "mt-1", children: /* @__PURE__ */ e(i, { score: t.tpdex, responseTime: t.responseTime, showScore: !0 }) })
91
91
  ] }),
92
92
  (t.cacheStatus || t.cached) && /* @__PURE__ */ s("div", { children: [
93
93
  /* @__PURE__ */ e("div", { className: "text-sm font-medium text-gray-500", children: "Cache Status" }),
94
- /* @__PURE__ */ e("div", { className: "mt-1", children: /* @__PURE__ */ e(w, { cacheStatus: t.cacheStatus, cached: t.cached }) })
94
+ /* @__PURE__ */ e("div", { className: "mt-1", children: /* @__PURE__ */ e(R, { cacheStatus: t.cacheStatus, cached: t.cached }) })
95
95
  ] }),
96
96
  /* @__PURE__ */ s("div", { children: [
97
97
  /* @__PURE__ */ e("div", { className: "text-sm font-medium text-gray-500", children: "Client" }),
@@ -112,16 +112,16 @@ function H({
112
112
  ] }),
113
113
  Object.keys(d).length > 0 && /* @__PURE__ */ s("div", { children: [
114
114
  /* @__PURE__ */ e("div", { className: "text-sm font-medium text-gray-500 mb-2", children: "Tags" }),
115
- /* @__PURE__ */ e("div", { className: "flex flex-wrap gap-2", children: Object.entries(d).map(([r, m]) => /* @__PURE__ */ s(A, { color: "blue", children: [
116
- r,
115
+ /* @__PURE__ */ e("div", { className: "flex flex-wrap gap-2", children: Object.entries(d).map(([m, r]) => /* @__PURE__ */ s(D, { color: "blue", children: [
116
+ m,
117
117
  "=",
118
- m
119
- ] }, r)) })
118
+ r
119
+ ] }, m)) })
120
120
  ] })
121
121
  ] })
122
122
  }
123
123
  ) });
124
124
  }
125
125
  export {
126
- H as TransactionMetadata
126
+ J as TransactionMetadata
127
127
  };
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "@bramus/pagination-sequence": "^1.2.1",
4
4
  "@heroicons/react": "^2.2.0",
5
5
  "date-fns": "^4.1.0",
6
- "echarts-for-react": "^3.0.2",
6
+ "echarts-for-react": "^3.0.4",
7
7
  "http-status-codes": "^2.3.0",
8
8
  "refractor": "^5.0.0",
9
9
  "tailwind-merge": "^3.3.0"
@@ -334,7 +334,7 @@
334
334
  ],
335
335
  "type": "module",
336
336
  "types": "./dist/index.d.ts",
337
- "version": "0.6.0",
337
+ "version": "0.6.1",
338
338
  "publishConfig": {
339
339
  "access": "public"
340
340
  },