From b5fd5782cd0ac482df87e88192e6cae5faa199b9 Mon Sep 17 00:00:00 2001 From: freddyaboulton Date: Thu, 28 Sep 2023 18:20:46 -0400 Subject: [PATCH 1/6] Use posix path --- js/preview/src/dev_server.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/js/preview/src/dev_server.ts b/js/preview/src/dev_server.ts index d8df15d00922c..68f984a84b9b6 100644 --- a/js/preview/src/dev_server.ts +++ b/js/preview/src/dev_server.ts @@ -204,14 +204,18 @@ function find_frontend_folders( return results; } +function toPosix(pathString: string): string { + return pathString.split(path.sep).join(path.posix.sep); +} + function generate_imports(component_dir: string): string { const components = find_frontend_folders(component_dir); const imports = components.reduce((acc, component) => { const x = { - interactive: join(component.dir, "interactive"), - static: join(component.dir, "static"), - example: join(component.dir, "example") + interactive: toPosix(join(component.dir, "interactive")), + static: toPosix(join(component.dir, "static")), + example: toPosix(join(component.dir, "example")) }; const interactive = fs.existsSync(x.interactive) ? `interactive: () => import("${x.interactive}"),\n` : "" From 780543e2bc85d3e22453f5f4c6599319090e6f68 Mon Sep 17 00:00:00 2001 From: gradio-pr-bot Date: Thu, 28 Sep 2023 22:53:58 +0000 Subject: [PATCH 2/6] add changeset --- .changeset/dark-cups-see.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/dark-cups-see.md diff --git a/.changeset/dark-cups-see.md b/.changeset/dark-cups-see.md new file mode 100644 index 0000000000000..5091948d4c1db --- /dev/null +++ b/.changeset/dark-cups-see.md @@ -0,0 +1,5 @@ +--- +"@gradio/preview": minor +--- + +feat:WIP: Fix windows parths From d14f465a342c0dfa8c6d32598a4a633e9a2c4796 Mon Sep 17 00:00:00 2001 From: gradio-pr-bot Date: Fri, 29 Sep 2023 17:53:47 +0000 Subject: [PATCH 3/6] add changeset --- .changeset/dark-cups-see.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/dark-cups-see.md b/.changeset/dark-cups-see.md index 5091948d4c1db..b95de5a6ccd22 100644 --- a/.changeset/dark-cups-see.md +++ b/.changeset/dark-cups-see.md @@ -2,4 +2,4 @@ "@gradio/preview": minor --- -feat:WIP: Fix windows parths +feat:WIP: Fix windows paths From f2c86c6c1346f13f5f828630a14db35f13cdd00c Mon Sep 17 00:00:00 2001 From: freddyaboulton Date: Fri, 29 Sep 2023 14:14:16 -0400 Subject: [PATCH 4/6] Try normalize --- js/preview/src/dev_server.ts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/js/preview/src/dev_server.ts b/js/preview/src/dev_server.ts index 68f984a84b9b6..8f9a09d8ad983 100644 --- a/js/preview/src/dev_server.ts +++ b/js/preview/src/dev_server.ts @@ -204,18 +204,15 @@ function find_frontend_folders( return results; } -function toPosix(pathString: string): string { - return pathString.split(path.sep).join(path.posix.sep); -} function generate_imports(component_dir: string): string { const components = find_frontend_folders(component_dir); const imports = components.reduce((acc, component) => { const x = { - interactive: toPosix(join(component.dir, "interactive")), - static: toPosix(join(component.dir, "static")), - example: toPosix(join(component.dir, "example")) + interactive: join(component.dir, "interactive").normalize(), + static: join(component.dir, "static").normalize(), + example: join(component.dir, "example").normalize() }; const interactive = fs.existsSync(x.interactive) ? `interactive: () => import("${x.interactive}"),\n` : "" From d70f6402347537388ebe97961d1c77f127866c62 Mon Sep 17 00:00:00 2001 From: freddyaboulton Date: Fri, 29 Sep 2023 14:43:59 -0400 Subject: [PATCH 5/6] to_posix v2 --- js/preview/src/dev_server.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/js/preview/src/dev_server.ts b/js/preview/src/dev_server.ts index 8f9a09d8ad983..5fbac339b66b2 100644 --- a/js/preview/src/dev_server.ts +++ b/js/preview/src/dev_server.ts @@ -204,15 +204,25 @@ function find_frontend_folders( return results; } +function to_posix(_path: string): string { + const isExtendedLengthPath = /^\\\\\?\\/.test(_path); + const hasNonAscii = /[^\u0000-\u0080]+/.test(_path); // eslint-disable-line no-control-regex + + if (isExtendedLengthPath || hasNonAscii) { + return _path; + } + + return _path.replace(/\\/g, '/'); +} function generate_imports(component_dir: string): string { const components = find_frontend_folders(component_dir); const imports = components.reduce((acc, component) => { const x = { - interactive: join(component.dir, "interactive").normalize(), - static: join(component.dir, "static").normalize(), - example: join(component.dir, "example").normalize() + interactive: to_posix(join(component.dir, "interactive")), + static: to_posix(join(component.dir, "static")), + example: to_posix(join(component.dir, "example")) }; const interactive = fs.existsSync(x.interactive) ? `interactive: () => import("${x.interactive}"),\n` : "" From acf6665ef314fe18e86601ec4f0934a7db8c5949 Mon Sep 17 00:00:00 2001 From: gradio-pr-bot Date: Fri, 29 Sep 2023 18:57:32 +0000 Subject: [PATCH 6/6] add changeset --- .changeset/dark-cups-see.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/dark-cups-see.md b/.changeset/dark-cups-see.md index b95de5a6ccd22..50f8ea879105b 100644 --- a/.changeset/dark-cups-see.md +++ b/.changeset/dark-cups-see.md @@ -2,4 +2,4 @@ "@gradio/preview": minor --- -feat:WIP: Fix windows paths +feat:Fix windows paths