From ad84c5eafe41b32b6313de276a9ac9118303d30e Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Mon, 20 Nov 2023 17:50:51 +0100 Subject: [PATCH] feat: error tab --- .../client/components/StacktraceList.vue | 42 ++++++++++ .../components/TimelineDetailsFunction.vue | 30 +------ .../devtools/client/pages/modules/error.vue | 78 +++++++++++++++++++ .../src/runtime/plugins/devtools.client.ts | 4 +- .../src/runtime/plugins/view/Main.vue | 2 + .../tab-timeline/components/GlobalNav.vue | 3 + playgrounds/tab-timeline/nuxt.config.ts | 2 +- playgrounds/tab-timeline/pages/empty.vue | 1 - playgrounds/tab-timeline/pages/error.vue | 9 +++ 9 files changed, 141 insertions(+), 30 deletions(-) create mode 100644 packages/devtools/client/components/StacktraceList.vue create mode 100644 packages/devtools/client/pages/modules/error.vue create mode 100644 playgrounds/tab-timeline/pages/error.vue diff --git a/packages/devtools/client/components/StacktraceList.vue b/packages/devtools/client/components/StacktraceList.vue new file mode 100644 index 000000000..aff60dfdc --- /dev/null +++ b/packages/devtools/client/components/StacktraceList.vue @@ -0,0 +1,42 @@ + + + diff --git a/packages/devtools/client/components/TimelineDetailsFunction.vue b/packages/devtools/client/components/TimelineDetailsFunction.vue index c1b11c8d5..d555395c6 100644 --- a/packages/devtools/client/components/TimelineDetailsFunction.vue +++ b/packages/devtools/client/components/TimelineDetailsFunction.vue @@ -5,20 +5,8 @@ const props = defineProps<{ record: TimelineEventFunction }>() -const config = useServerConfig() const timeAgo = useTimeAgo(() => props.record.start, { showSecond: true }) -function urlToFilepath(url: string) { - let pathname = new URL(url).pathname - if (pathname.startsWith('/_nuxt/')) - pathname = pathname.slice(6) - if (pathname.startsWith('/@id/virtual:nuxt:')) - return `#build/${pathname.split('/.nuxt/')[1]}`.replace(/\.m?js$/, '') - if (pathname.includes('/@fs/')) - return `/${pathname.split('/@fs/')[1]}` - return (config.value?.rootDir || '') + pathname -} - const autoImports = useAutoImports() const importsMetadata = computed(() => autoImports.value?.metadata) const importItem = computed(() => { @@ -60,19 +48,9 @@ const importItem = computed(() => { -
- -
+ diff --git a/packages/devtools/client/pages/modules/error.vue b/packages/devtools/client/pages/modules/error.vue new file mode 100644 index 000000000..c3ee1c0c3 --- /dev/null +++ b/packages/devtools/client/pages/modules/error.vue @@ -0,0 +1,78 @@ + + + diff --git a/packages/devtools/src/runtime/plugins/devtools.client.ts b/packages/devtools/src/runtime/plugins/devtools.client.ts index aefb83cec..c38b3b848 100644 --- a/packages/devtools/src/runtime/plugins/devtools.client.ts +++ b/packages/devtools/src/runtime/plugins/devtools.client.ts @@ -55,8 +55,8 @@ export default defineNuxtPlugin((nuxt: any) => { }) import('./view/client') - .then(({ setupDevToolsClient }) => { - setupDevToolsClient({ + .then(async ({ setupDevToolsClient }) => { + await setupDevToolsClient({ nuxt, clientHooks, timeMetric, diff --git a/packages/devtools/src/runtime/plugins/view/Main.vue b/packages/devtools/src/runtime/plugins/view/Main.vue index 78d86ecce..c1c3be383 100644 --- a/packages/devtools/src/runtime/plugins/view/Main.vue +++ b/packages/devtools/src/runtime/plugins/view/Main.vue @@ -57,6 +57,8 @@ const draggingOffset = reactive({ x: 0, y: 0 }) const mousePosition = reactive({ x: 0, y: 0 }) function onPointerDown(e: PointerEvent) { + if (!panelEl.value) + return isDragging.value = true const { left, top, width, height } = panelEl.value!.getBoundingClientRect() draggingOffset.x = e.clientX - left - width / 2 diff --git a/playgrounds/tab-timeline/components/GlobalNav.vue b/playgrounds/tab-timeline/components/GlobalNav.vue index 4c8dd5cdc..e40e8d8d9 100644 --- a/playgrounds/tab-timeline/components/GlobalNav.vue +++ b/playgrounds/tab-timeline/components/GlobalNav.vue @@ -23,6 +23,9 @@ /dynamic-bar + + /error + diff --git a/playgrounds/tab-timeline/nuxt.config.ts b/playgrounds/tab-timeline/nuxt.config.ts index 60a24a6f5..8583d0373 100644 --- a/playgrounds/tab-timeline/nuxt.config.ts +++ b/playgrounds/tab-timeline/nuxt.config.ts @@ -4,7 +4,7 @@ export default defineNuxtConfig({ '../../packages/devtools-ui-kit/src/module', '../../local', ], - ssr: false, + ssr: true, vite: { clearScreen: false, }, diff --git a/playgrounds/tab-timeline/pages/empty.vue b/playgrounds/tab-timeline/pages/empty.vue index 04e2cc2de..7b648447f 100644 --- a/playgrounds/tab-timeline/pages/empty.vue +++ b/playgrounds/tab-timeline/pages/empty.vue @@ -1,5 +1,4 @@