@motiadev/plugin-logs 0.14.0-beta.165-277118 → 0.14.0-beta.165-912190
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/dist/index.js +341 -0
- package/dist/plugin.d.ts +1 -1
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +1 -1
- package/dist/plugin.js.map +1 -1
- package/dist/styles.css.map +1 -0
- package/dist/styles.js +0 -0
- package/package.json +4 -4
- package/dist/index.css.map +0 -1
- /package/dist/{index.css → styles.css} +0 -0
package/dist/index.js
CHANGED
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
import { Stream } from "@motiadev/stream-client-browser";
|
|
2
|
+
import { create } from "zustand";
|
|
3
|
+
import { c } from "react/compiler-runtime";
|
|
4
|
+
import { Button, Input, LevelDot, Sidebar, Table, TableBody, TableCell, TableRow, cn } from "@motiadev/ui";
|
|
5
|
+
import { Search, Trash, X } from "lucide-react";
|
|
6
|
+
import { useMemo, useState } from "react";
|
|
7
|
+
import ReactJson from "react18-json-view";
|
|
8
|
+
import "react18-json-view/src/dark.css";
|
|
9
|
+
import "react18-json-view/src/style.css";
|
|
10
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
+
|
|
12
|
+
//#region src/stores/use-logs-store.ts
|
|
13
|
+
const useLogsStore = create()((set) => ({
|
|
14
|
+
logs: [],
|
|
15
|
+
selectedLogId: void 0,
|
|
16
|
+
addLog: (log) => set((state) => {
|
|
17
|
+
if (state.logs.find((l) => l.id === log.id)) return state;
|
|
18
|
+
return { logs: [log, ...state.logs] };
|
|
19
|
+
}),
|
|
20
|
+
setLogs: (logs) => set({ logs: [...logs].reverse() }),
|
|
21
|
+
resetLogs: () => {
|
|
22
|
+
set({ logs: [] });
|
|
23
|
+
},
|
|
24
|
+
selectLogId: (logId) => set({ selectedLogId: logId })
|
|
25
|
+
}));
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region src/utils/init-log-listener.ts
|
|
29
|
+
const streamName = "__motia.logs";
|
|
30
|
+
const groupId = "default";
|
|
31
|
+
const type = "log";
|
|
32
|
+
const initLogListener = () => {
|
|
33
|
+
const subscription = new Stream(window.location.origin.replace("http", "ws")).subscribeGroup(streamName, groupId);
|
|
34
|
+
const store = useLogsStore.getState();
|
|
35
|
+
subscription.addChangeListener((logs) => {
|
|
36
|
+
if (logs) store.setLogs(logs);
|
|
37
|
+
});
|
|
38
|
+
subscription.onEvent(type, store.addLog);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
//#endregion
|
|
42
|
+
//#region src/utils/format-timestamp.ts
|
|
43
|
+
const formatTimestamp = (time) => {
|
|
44
|
+
const date = new Date(Number(time));
|
|
45
|
+
return `${date.toLocaleDateString("en-US", {
|
|
46
|
+
year: void 0,
|
|
47
|
+
month: "short",
|
|
48
|
+
day: "2-digit"
|
|
49
|
+
})}, ${date.toLocaleTimeString("en-US", {
|
|
50
|
+
hour: "2-digit",
|
|
51
|
+
minute: "2-digit",
|
|
52
|
+
second: "2-digit",
|
|
53
|
+
hourCycle: "h24"
|
|
54
|
+
})}.${date.getMilliseconds().toString().padStart(3, "0")}`;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
//#endregion
|
|
58
|
+
//#region src/components/log-detail.tsx
|
|
59
|
+
const defaultProps = [
|
|
60
|
+
"id",
|
|
61
|
+
"msg",
|
|
62
|
+
"time",
|
|
63
|
+
"level",
|
|
64
|
+
"step",
|
|
65
|
+
"flows",
|
|
66
|
+
"traceId"
|
|
67
|
+
];
|
|
68
|
+
const LogDetail = ({ log, onClose }) => {
|
|
69
|
+
const [hasOtherProps, setHasOtherProps] = useState(false);
|
|
70
|
+
const otherPropsObject = useMemo(() => {
|
|
71
|
+
if (!log) return null;
|
|
72
|
+
const otherProps = Object.keys(log ?? {}).filter((key) => !defaultProps.includes(key));
|
|
73
|
+
setHasOtherProps(otherProps.length > 0);
|
|
74
|
+
return otherProps.reduce((acc, key_0) => {
|
|
75
|
+
acc[key_0] = log[key_0];
|
|
76
|
+
return acc;
|
|
77
|
+
}, {});
|
|
78
|
+
}, [log]);
|
|
79
|
+
if (!log) return null;
|
|
80
|
+
return /* @__PURE__ */ jsx(Sidebar, {
|
|
81
|
+
onClose,
|
|
82
|
+
title: "Logs Details",
|
|
83
|
+
subtitle: "Details including custom properties",
|
|
84
|
+
actions: [{
|
|
85
|
+
icon: /* @__PURE__ */ jsx(X, {}),
|
|
86
|
+
onClick: onClose,
|
|
87
|
+
label: "Close"
|
|
88
|
+
}],
|
|
89
|
+
details: [
|
|
90
|
+
{
|
|
91
|
+
label: "Level",
|
|
92
|
+
value: /* @__PURE__ */ jsxs("div", {
|
|
93
|
+
className: "flex items-center gap-2",
|
|
94
|
+
children: [/* @__PURE__ */ jsx(LevelDot, { level: log.level }), /* @__PURE__ */ jsx("div", {
|
|
95
|
+
className: "capitalize",
|
|
96
|
+
children: log.level
|
|
97
|
+
})]
|
|
98
|
+
})
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
label: "Time",
|
|
102
|
+
value: formatTimestamp(log.time)
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
label: "Step",
|
|
106
|
+
value: log.step
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
label: "Flows",
|
|
110
|
+
value: log.flows.join(", ")
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
label: "Trace ID",
|
|
114
|
+
value: log.traceId
|
|
115
|
+
}
|
|
116
|
+
],
|
|
117
|
+
children: hasOtherProps && /* @__PURE__ */ jsx(ReactJson, {
|
|
118
|
+
src: otherPropsObject,
|
|
119
|
+
theme: "default",
|
|
120
|
+
enableClipboard: true
|
|
121
|
+
})
|
|
122
|
+
});
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
//#endregion
|
|
126
|
+
//#region src/components/logs-page.tsx
|
|
127
|
+
const LogsPage = () => {
|
|
128
|
+
const $ = c(42);
|
|
129
|
+
if ($[0] !== "84ffc385f6f2f10fa27a1ff3e09be855f00c73d8200553182ad70e6cfb527268") {
|
|
130
|
+
for (let $i = 0; $i < 42; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
|
|
131
|
+
$[0] = "84ffc385f6f2f10fa27a1ff3e09be855f00c73d8200553182ad70e6cfb527268";
|
|
132
|
+
}
|
|
133
|
+
const logs = useLogsStore(_temp);
|
|
134
|
+
const resetLogs = useLogsStore(_temp2);
|
|
135
|
+
const selectedLogId = useLogsStore(_temp3);
|
|
136
|
+
const selectLogId = useLogsStore(_temp4);
|
|
137
|
+
let t0;
|
|
138
|
+
if ($[1] !== logs || $[2] !== selectedLogId) {
|
|
139
|
+
t0 = selectedLogId ? logs.find((log) => log.id === selectedLogId) : void 0;
|
|
140
|
+
$[1] = logs;
|
|
141
|
+
$[2] = selectedLogId;
|
|
142
|
+
$[3] = t0;
|
|
143
|
+
} else t0 = $[3];
|
|
144
|
+
const selectedLog = t0;
|
|
145
|
+
const [search, setSearch] = useState("");
|
|
146
|
+
let t1;
|
|
147
|
+
if ($[4] !== logs || $[5] !== search) {
|
|
148
|
+
let t2$1;
|
|
149
|
+
if ($[7] !== search) {
|
|
150
|
+
t2$1 = (log_0) => log_0.msg.toLowerCase().includes(search.toLowerCase()) || log_0.traceId.toLowerCase().includes(search.toLowerCase()) || log_0.step.toLowerCase().includes(search.toLowerCase());
|
|
151
|
+
$[7] = search;
|
|
152
|
+
$[8] = t2$1;
|
|
153
|
+
} else t2$1 = $[8];
|
|
154
|
+
t1 = logs.filter(t2$1);
|
|
155
|
+
$[4] = logs;
|
|
156
|
+
$[5] = search;
|
|
157
|
+
$[6] = t1;
|
|
158
|
+
} else t1 = $[6];
|
|
159
|
+
const filteredLogs = t1;
|
|
160
|
+
let t2;
|
|
161
|
+
if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
|
|
162
|
+
t2 = (e) => setSearch(e.target.value);
|
|
163
|
+
$[9] = t2;
|
|
164
|
+
} else t2 = $[9];
|
|
165
|
+
let t3;
|
|
166
|
+
if ($[10] !== search) {
|
|
167
|
+
t3 = /* @__PURE__ */ jsx(Input, {
|
|
168
|
+
variant: "shade",
|
|
169
|
+
value: search,
|
|
170
|
+
onChange: t2,
|
|
171
|
+
className: "px-9! font-medium",
|
|
172
|
+
placeholder: "Search by Trace ID or Message"
|
|
173
|
+
});
|
|
174
|
+
$[10] = search;
|
|
175
|
+
$[11] = t3;
|
|
176
|
+
} else t3 = $[11];
|
|
177
|
+
let t4;
|
|
178
|
+
if ($[12] === Symbol.for("react.memo_cache_sentinel")) {
|
|
179
|
+
t4 = /* @__PURE__ */ jsx(Search, { className: "absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground/50" });
|
|
180
|
+
$[12] = t4;
|
|
181
|
+
} else t4 = $[12];
|
|
182
|
+
let t5;
|
|
183
|
+
if ($[13] === Symbol.for("react.memo_cache_sentinel")) {
|
|
184
|
+
t5 = /* @__PURE__ */ jsx(X, {
|
|
185
|
+
className: "cursor-pointer absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground/50 hover:text-muted-foreground",
|
|
186
|
+
onClick: () => setSearch("")
|
|
187
|
+
});
|
|
188
|
+
$[13] = t5;
|
|
189
|
+
} else t5 = $[13];
|
|
190
|
+
let t6;
|
|
191
|
+
if ($[14] !== t3) {
|
|
192
|
+
t6 = /* @__PURE__ */ jsxs("div", {
|
|
193
|
+
className: "flex-1 relative",
|
|
194
|
+
children: [
|
|
195
|
+
t3,
|
|
196
|
+
t4,
|
|
197
|
+
t5
|
|
198
|
+
]
|
|
199
|
+
});
|
|
200
|
+
$[14] = t3;
|
|
201
|
+
$[15] = t6;
|
|
202
|
+
} else t6 = $[15];
|
|
203
|
+
let t7;
|
|
204
|
+
if ($[16] === Symbol.for("react.memo_cache_sentinel")) {
|
|
205
|
+
t7 = /* @__PURE__ */ jsx(Trash, {});
|
|
206
|
+
$[16] = t7;
|
|
207
|
+
} else t7 = $[16];
|
|
208
|
+
let t8;
|
|
209
|
+
if ($[17] !== resetLogs) {
|
|
210
|
+
t8 = /* @__PURE__ */ jsxs(Button, {
|
|
211
|
+
variant: "default",
|
|
212
|
+
onClick: resetLogs,
|
|
213
|
+
className: "h-[34px]",
|
|
214
|
+
children: [t7, " Clear"]
|
|
215
|
+
});
|
|
216
|
+
$[17] = resetLogs;
|
|
217
|
+
$[18] = t8;
|
|
218
|
+
} else t8 = $[18];
|
|
219
|
+
let t9;
|
|
220
|
+
if ($[19] !== t6 || $[20] !== t8) {
|
|
221
|
+
t9 = /* @__PURE__ */ jsxs("div", {
|
|
222
|
+
className: "flex p-2 border-b gap-2",
|
|
223
|
+
"data-testid": "logs-search-container",
|
|
224
|
+
children: [t6, t8]
|
|
225
|
+
});
|
|
226
|
+
$[19] = t6;
|
|
227
|
+
$[20] = t8;
|
|
228
|
+
$[21] = t9;
|
|
229
|
+
} else t9 = $[21];
|
|
230
|
+
let t10;
|
|
231
|
+
if ($[22] !== filteredLogs || $[23] !== selectLogId || $[24] !== selectedLogId) {
|
|
232
|
+
let t11$1;
|
|
233
|
+
if ($[26] !== selectLogId || $[27] !== selectedLogId) {
|
|
234
|
+
t11$1 = (log_1, index) => /* @__PURE__ */ jsxs(TableRow, {
|
|
235
|
+
"data-testid": "log-row",
|
|
236
|
+
className: cn("font-mono font-semibold cursor-pointer border-0", {
|
|
237
|
+
"bg-muted-foreground/10 hover:bg-muted-foreground/20": selectedLogId === log_1.id,
|
|
238
|
+
"hover:bg-muted-foreground/10": selectedLogId !== log_1.id
|
|
239
|
+
}),
|
|
240
|
+
onClick: () => selectLogId(log_1.id),
|
|
241
|
+
children: [
|
|
242
|
+
/* @__PURE__ */ jsxs(TableCell, {
|
|
243
|
+
"data-testid": `time-${index}`,
|
|
244
|
+
className: "whitespace-nowrap flex items-center gap-2 text-muted-foreground",
|
|
245
|
+
children: [/* @__PURE__ */ jsx(LevelDot, { level: log_1.level }), formatTimestamp(log_1.time)]
|
|
246
|
+
}),
|
|
247
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
248
|
+
"data-testid": `trace-${log_1.traceId}`,
|
|
249
|
+
className: "whitespace-nowrap cursor-pointer hover:text-primary text-muted-foreground",
|
|
250
|
+
onClick: () => setSearch(log_1.traceId),
|
|
251
|
+
children: log_1.traceId
|
|
252
|
+
}),
|
|
253
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
254
|
+
"data-testid": `step-${index}`,
|
|
255
|
+
"aria-label": log_1.step,
|
|
256
|
+
className: "whitespace-nowrap",
|
|
257
|
+
children: log_1.step
|
|
258
|
+
}),
|
|
259
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
260
|
+
"data-testid": `msg-${index}`,
|
|
261
|
+
"aria-label": log_1.msg,
|
|
262
|
+
className: "whitespace-nowrap max-w-[500px] truncate w-full",
|
|
263
|
+
children: log_1.msg
|
|
264
|
+
})
|
|
265
|
+
]
|
|
266
|
+
}, index);
|
|
267
|
+
$[26] = selectLogId;
|
|
268
|
+
$[27] = selectedLogId;
|
|
269
|
+
$[28] = t11$1;
|
|
270
|
+
} else t11$1 = $[28];
|
|
271
|
+
t10 = filteredLogs.map(t11$1);
|
|
272
|
+
$[22] = filteredLogs;
|
|
273
|
+
$[23] = selectLogId;
|
|
274
|
+
$[24] = selectedLogId;
|
|
275
|
+
$[25] = t10;
|
|
276
|
+
} else t10 = $[25];
|
|
277
|
+
let t11;
|
|
278
|
+
if ($[29] !== t10) {
|
|
279
|
+
t11 = /* @__PURE__ */ jsx(Table, { children: /* @__PURE__ */ jsx(TableBody, {
|
|
280
|
+
className: "font-mono font-medium",
|
|
281
|
+
children: t10
|
|
282
|
+
}) });
|
|
283
|
+
$[29] = t10;
|
|
284
|
+
$[30] = t11;
|
|
285
|
+
} else t11 = $[30];
|
|
286
|
+
let t12;
|
|
287
|
+
if ($[31] !== t11 || $[32] !== t9) {
|
|
288
|
+
t12 = /* @__PURE__ */ jsxs("div", {
|
|
289
|
+
className: "grid grid-rows-[auto_1fr] h-full",
|
|
290
|
+
"data-testid": "logs-container",
|
|
291
|
+
children: [t9, t11]
|
|
292
|
+
});
|
|
293
|
+
$[31] = t11;
|
|
294
|
+
$[32] = t9;
|
|
295
|
+
$[33] = t12;
|
|
296
|
+
} else t12 = $[33];
|
|
297
|
+
let t13;
|
|
298
|
+
if ($[34] !== selectLogId) {
|
|
299
|
+
t13 = () => selectLogId(void 0);
|
|
300
|
+
$[34] = selectLogId;
|
|
301
|
+
$[35] = t13;
|
|
302
|
+
} else t13 = $[35];
|
|
303
|
+
let t14;
|
|
304
|
+
if ($[36] !== selectedLog || $[37] !== t13) {
|
|
305
|
+
t14 = /* @__PURE__ */ jsx(LogDetail, {
|
|
306
|
+
log: selectedLog,
|
|
307
|
+
onClose: t13
|
|
308
|
+
});
|
|
309
|
+
$[36] = selectedLog;
|
|
310
|
+
$[37] = t13;
|
|
311
|
+
$[38] = t14;
|
|
312
|
+
} else t14 = $[38];
|
|
313
|
+
let t15;
|
|
314
|
+
if ($[39] !== t12 || $[40] !== t14) {
|
|
315
|
+
t15 = /* @__PURE__ */ jsxs(Fragment, { children: [t12, t14] });
|
|
316
|
+
$[39] = t12;
|
|
317
|
+
$[40] = t14;
|
|
318
|
+
$[41] = t15;
|
|
319
|
+
} else t15 = $[41];
|
|
320
|
+
return t15;
|
|
321
|
+
};
|
|
322
|
+
function _temp(state) {
|
|
323
|
+
return state.logs;
|
|
324
|
+
}
|
|
325
|
+
function _temp2(state_0) {
|
|
326
|
+
return state_0.resetLogs;
|
|
327
|
+
}
|
|
328
|
+
function _temp3(state_1) {
|
|
329
|
+
return state_1.selectedLogId;
|
|
330
|
+
}
|
|
331
|
+
function _temp4(state_2) {
|
|
332
|
+
return state_2.selectLogId;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
//#endregion
|
|
336
|
+
//#region src/index.ts
|
|
337
|
+
initLogListener();
|
|
338
|
+
|
|
339
|
+
//#endregion
|
|
340
|
+
export { LogsPage };
|
|
341
|
+
//# sourceMappingURL=index.js.map
|
package/dist/plugin.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { MotiaPlugin, MotiaPluginContext } from "@motiadev/core";
|
|
2
2
|
|
|
3
3
|
//#region src/plugin.d.ts
|
|
4
|
-
declare function plugin(
|
|
4
|
+
declare function plugin(_motia: MotiaPluginContext): MotiaPlugin;
|
|
5
5
|
//#endregion
|
|
6
6
|
export { plugin as default };
|
|
7
7
|
//# sourceMappingURL=plugin.d.ts.map
|
package/dist/plugin.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","names":[],"sources":["../src/plugin.ts"],"sourcesContent":[],"mappings":";;;iBAEwB,MAAA,
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","names":[],"sources":["../src/plugin.ts"],"sourcesContent":[],"mappings":";;;iBAEwB,MAAA,SAAe,qBAAqB"}
|
package/dist/plugin.js
CHANGED
package/dist/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","names":["MotiaPlugin","MotiaPluginContext","plugin","
|
|
1
|
+
{"version":3,"file":"plugin.js","names":["MotiaPlugin","MotiaPluginContext","plugin","_motia","workbench","packageName","label","position","componentName","labelIcon"],"sources":["../src/plugin.ts"],"sourcesContent":["import type { MotiaPlugin, MotiaPluginContext } from '@motiadev/core'\n\nexport default function plugin(_motia: MotiaPluginContext): MotiaPlugin {\n return {\n workbench: [\n {\n packageName: '@motiadev/plugin-logs',\n label: 'Logs',\n position: 'bottom',\n componentName: 'LogsPage',\n labelIcon: 'logs',\n },\n ],\n }\n}\n"],"mappings":";AAEA,SAAwBE,OAAOC,QAAyC;AACtE,QAAO,EACLC,WAAW,CACT;EACEC,aAAa;EACbC,OAAO;EACPC,UAAU;EACVC,eAAe;EACfC,WAAW;EACZ,CAAA,EAEJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.css","names":[],"sources":["../src/styles.css"],"sourcesContent":["export default undefined;"],"mappings":"AAAA"}
|
package/dist/styles.js
ADDED
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@motiadev/plugin-logs",
|
|
3
|
-
"version": "0.14.0-beta.165-
|
|
3
|
+
"version": "0.14.0-beta.165-912190",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -19,9 +19,9 @@
|
|
|
19
19
|
"zustand": "^5.0.8"
|
|
20
20
|
},
|
|
21
21
|
"peerDependencies": {
|
|
22
|
-
"@motiadev/
|
|
23
|
-
"@motiadev/
|
|
24
|
-
"@motiadev/
|
|
22
|
+
"@motiadev/stream-client-browser": "0.14.0-beta.165-912190",
|
|
23
|
+
"@motiadev/core": "0.14.0-beta.165-912190",
|
|
24
|
+
"@motiadev/ui": "0.14.0-beta.165-912190"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@bosh-code/tsdown-plugin-inject-css": "^2.0.0",
|
package/dist/index.css.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.css","names":[],"sources":["../src/styles.css"],"sourcesContent":["export default undefined;"],"mappings":"AAAA"}
|
|
File without changes
|