-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
make all component SSR compatible #9187
Conversation
🪼 branch checks and previews
Install Gradio from this PR pip install https://gradio-pypi-previews.s3.amazonaws.com/c440b0d45a2a0501dc54f02e64330e966964c848/gradio-4.42.0-py3-none-any.whl Install Gradio Python Client from this PR pip install "gradio-client @ git+https://github.com/gradio-app/gradio@c440b0d45a2a0501dc54f02e64330e966964c848#subdirectory=client/python" Install Gradio JS Client from this PR npm install https://gradio-npm-previews.s3.amazonaws.com/c440b0d45a2a0501dc54f02e64330e966964c848/gradio-client-1.5.1.tgz |
🦄 change detectedThis Pull Request includes changes to the following packages.
With the following changelog entry.
Maintainers or the PR author can modify the PR title to modify this entry.
|
@@ -84,13 +84,13 @@ | |||
|
|||
let editor_box: EditorContext["editor_box"] = writable({ | |||
parent_width: 0, | |||
parent_height: 0, | |||
parent_height: 400, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use provided height value if it is passed
js/markdown/package.json
Outdated
@@ -31,6 +31,7 @@ | |||
"@types/prismjs": "1.26.4", | |||
"dompurify": "^3.0.3", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove
DOMPurify.addHook("afterSanitizeAttributes", function (node) { | ||
if ("target" in node) { | ||
if (is_external_url(node.getAttribute("href"))) { | ||
node.setAttribute("target", "_blank"); | ||
node.setAttribute("rel", "noopener noreferrer"); | ||
} | ||
} | ||
}); | ||
const is_browser = typeof window !== "undefined"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need to be moved?
Do we need the browser var?
js/wasm/svelte/DownloadLink.svelte
Outdated
@@ -64,9 +64,14 @@ | |||
is_downloading = false; | |||
}); | |||
} | |||
|
|||
let should_proxy = false; | |||
onMount(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove?
Thanks for going through the changes! Have done a test and can't see any issues. Once those comments are sorted lgtm :) |
@pngwn was reviewing the components yesterday and it looked good to me. But now I'm getting "SSR Module" errors when running the demo. Could just be me tho. |
Locally or on the Deployed PR Space @dawoodkhan82? |
@abidlabs locally |
I can't repro that @dawoodkhan82. I checked out this branch, rebuilt the frontend, and ran some demos (like |
@abidlabs did you try with disabled JS from the dev tools? The components-test demo looks good to me, but once I disable JS (SSR only) then I get 500 internal server errors when clicking through the components. |
Ah yeah sorry missed those testing instructions. I'm seeing 500 errors as well. The web app looks like this: Partial stack trace:
|
I'll take a look at this. Seems to just be the utils package that is causing issues. |
@abidlabs @dawoodkhan82 I left something out of my instructions which doesn't affect other packages but apparently does affect the utils package for some reason. You need to run |
(5) Issue #4 is preventing me from being able to fully test and also when I click on the draw tool, its very laggy and colors the canvas at the wrong spot when clicked |
Okay, almost all of those are expected. The main purpose of this test app is to test the initial rendering (i.e. will the component initialise on the server) not the full functionality. This test app lacks the business logic of the gradio app to do that properly.
So 1, 3, 4 are expected. I'll take care of the others. For 1, 3, 4 specifically, as long as they work in gradio proper, then they are working as expected. |
Fixed everything but can't reproduce #4. Screen.Recording.2024-08-31.at.02.31.18.mov |
Can't repro it anymore either! |
Ok went through and tested everything with and without JS, everything works great @pngwn with one exception: native plots don't work if you start with a different component and then switch to the native plots tab. If you hard refresh, then they work. Recording: Screen.Recording.2024-08-30.at.12.06.44.PM.mov |
Oh interesting. |
Okay fixed! Gonna merge this in so I can continue but feel free to make any additional comments and i'll fix in a follow up! |
description
closes #9111 closes #9112
Makes all component SSR compatible.
dompurify
.to test
While running the app. I would recommend doping the following to see how things behave: