From ecbf83322b03fc72161861dfed0de989b7b385cb Mon Sep 17 00:00:00 2001 From: Tom Meagher Date: Fri, 15 Mar 2024 16:43:39 -0400 Subject: [PATCH] feat: capture url --- src/dev/devtools.tsx | 18 +++++++++++---- ui/src/constants.ts | 2 ++ ui/src/hooks/useScrollLock.ts | 10 ++++----- ui/src/lib/api.ts | 5 ++--- ui/src/lib/store.ts | 14 +++++++++--- ui/src/utils/actions.ts | 21 +++++++++++++++++- ui/src/utils/deepEqual.ts | 42 +++++++++++++++++++++++++++++++++++ 7 files changed, 95 insertions(+), 17 deletions(-) create mode 100644 ui/src/constants.ts create mode 100644 ui/src/utils/deepEqual.ts diff --git a/src/dev/devtools.tsx b/src/dev/devtools.tsx index 29d06630..03958f2f 100644 --- a/src/dev/devtools.tsx +++ b/src/dev/devtools.tsx @@ -77,13 +77,23 @@ export function devtools< const app = new Hono() app .get('/', async (c) => { - const url = new URL(c.req.url) + const { origin } = new URL(c.req.url) + const baseUrl = `${origin}${devBasePath}` let frameUrls: string[] = [] let initialData: Bootstrap['data'] = undefined if (routes.length) { - frameUrls = getFrameUrls(url.origin, routes) - initialData = (await getInitialData(frameUrls[0])) as Bootstrap['data'] + frameUrls = getFrameUrls(origin, routes) + + let frameUrl = frameUrls[0] + const url = c.req.query('url') + if (url) { + const tmpUrl = `${origin}${url}` + if (url.startsWith('/')) frameUrl = tmpUrl + else if (frameUrls.includes(url)) frameUrl = url + } + + initialData = (await getInitialData(frameUrl)) as Bootstrap['data'] } let user: User | undefined = undefined @@ -116,7 +126,7 @@ export function devtools< frog