Skip to content

Commit

Permalink
Fix reload mode (#9576)
Browse files Browse the repository at this point in the history
* Ddebuig

* Fixing

* fix

* notebook

* add changeset

* SSR MODE

* add changeset

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
  • Loading branch information
freddyaboulton and gradio-pr-bot authored Oct 8, 2024
1 parent 139152f commit 430a26a
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 21 deletions.
8 changes: 8 additions & 0 deletions .changeset/petite-months-fold.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@gradio/core": minor
"@self/app": minor
"@self/spa": minor
"gradio": minor
---

feat:Fix reload mode
18 changes: 10 additions & 8 deletions js/app/src/routes/[...catchall]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -265,12 +265,7 @@
//@ts-ignore
config = data.config;
window.gradio_config = config;
// api_url =
// BUILD_MODE === "dev" || gradio_dev_mode === "dev"
// ? `http://localhost:${
// typeof server_port === "number" ? server_port : 7860
// }`
// : host || space || src || location.origin;
const api_url = location.origin;
window.gradio_config = data.config;
config = data.config;
Expand Down Expand Up @@ -298,7 +293,7 @@
if (config.dev_mode) {
setTimeout(() => {
const { host } = new URL(api_url);
let url = new URL(`http://${host}/dev/reload`);
let url = new URL(`http://${host}${app.api_prefix}/dev/reload`);
stream = new EventSource(url);
stream.addEventListener("error", async (e) => {
new_message_fn("Error reloading app", "error");
Expand All @@ -317,9 +312,16 @@
throw new Error("Could not resolve app config");
}
// config = app.config;
config = app.config;
window.__gradio_space__ = config.space_id;
await mount_custom_css(config.css);
await add_custom_html_head(config.head);
css_ready = true;
window.__is_colab__ = config.is_colab;
dispatch("loaded");
// // config = app.config;
// window.__gradio_space__ = config.space_id;
// await mount_custom_css(config.css);
});
}, 200);
}
Expand Down
26 changes: 13 additions & 13 deletions js/core/src/Blocks.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -719,19 +719,19 @@

<div class="wrap" style:min-height={app_mode ? "100%" : "auto"}>
<div class="contain" style:flex-grow={app_mode ? "1" : "auto"}>
<!-- {#if $_layout} -->
<MountComponents
rootNode={$_layout}
{root}
{target}
{theme_mode}
on:mount={handle_mount}
{version}
{autoscroll}
{max_file_size}
client={app}
/>
<!-- {/if} -->
{#if $_layout && app.config}
<MountComponents
rootNode={$_layout}
{root}
{target}
{theme_mode}
on:mount={handle_mount}
{version}
{autoscroll}
{max_file_size}
client={app}
/>
{/if}
</div>

{#if show_footer}
Expand Down
4 changes: 4 additions & 0 deletions js/spa/src/Index.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,10 @@
config = app.config;
window.__gradio_space__ = config.space_id;
await mount_custom_css(config.css);
await add_custom_html_head(config.head);
css_ready = true;
window.__is_colab__ = config.is_colab;
dispatch("loaded");
});
}, 200);
}
Expand Down

0 comments on commit 430a26a

Please sign in to comment.