-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
manifest json
for PWA
#10187
manifest json
for PWA
#10187
Conversation
🪼 branch checks and previews
Install Gradio from this PR pip install https://gradio-pypi-previews.s3.amazonaws.com/5d233c8a6dd385641555a607befcde5f3f46abcf/gradio-5.9.1-py3-none-any.whl Install Gradio Python Client from this PR pip install "gradio-client @ git+https://github.com/gradio-app/gradio@5d233c8a6dd385641555a607befcde5f3f46abcf#subdirectory=client/python" Install Gradio JS Client from this PR npm install https://gradio-npm-previews.s3.amazonaws.com/5d233c8a6dd385641555a607befcde5f3f46abcf/gradio-client-1.8.0.tgz Use Lite from this PR <script type="module" src="https://gradio-lite-previews.s3.amazonaws.com/5d233c8a6dd385641555a607befcde5f3f46abcf/dist/lite.js""></script> |
🦄 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.
|
Very cool, cc @pngwn for visibility |
This looks great @whitphx but I'm not seeing the install icon when I test on Chrome on my Macbook. Is there something else I need to do? Here's my code: import gradio as gr
gr.Interface(lambda x:x, gr.File(), gr.Textbox()).launch(pwa=True) Here's what I see: ![]() |
@abidlabs The |
gradio/blocks.py
Outdated
@@ -2309,6 +2309,7 @@ def launch( | |||
node_server_name: str | None = None, | |||
node_port: int | None = None, | |||
ssr_mode: bool | None = None, | |||
pwa: bool = False, |
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.
What do you think about calling this parameter manifest
and letting it be either a bool
or a str
path to a user-specified manifest.json
file if the user wants more control over it?
pwa: bool = False, | |
manifest: bool | str = False, |
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.
Actually thinking about this some more, maybe we can enable this by default in Spaces, in which case, we could do
pwa: bool = False, | |
manifest: bool | None | str = None, |
and if a user doesn't override manifest
, we automatically set it to True
if on Spaces and False
otherwise
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.
Thanks!
Will set the Spaces default 👍
Also, the manifest
param has extensibility benefits but I also have some following ideas:
- In Gradio's case,
manifest.json
is used only for PWA, sopwa
may look clearer, hiding other things that users don't have to care. (This can be true if most Gradio users just want to use the PWA feature but don't want to think about things behind it e.g. manifest.json. wdyt? being simple vs detailed?)- If we will need to provide the full
manifest.json
configuration in the future, we can add themanifest
param at that moment andpwa
can work as a shorthand for it.
- If we will need to provide the full
- When we provide more flexible API to configure the
manifest.json
, defining the schema with TypedDict or Pydantic like this would be helpful rather than just allowing to pass the JSON string (and this may be too much at this moment):
class ManifestJson(TypedDict):
name: str
version: str
# ... and more fields
def launch(
# ...
pwa: bool | ManifestJson = False,
):
# ...
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.
My suggestion is just to provide pwa: bool | None
for now, and add manifest: ManifestJson | None
in the future if we find it's needed. This is an opinion biased for simplicity hiding the details, so Gradio's API design policy and/or users' potential demand may override it, wdyt?
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.
Sounds good to me, we can discuss the exact implementation later but fine with keeping the boolean .pwa attribute right now 👍
Nice @whitphx! Left a couple of comments, but overall very clean UI for installing an app. Of course, I think its going to be most handy when we have support for installing gradio apps directly from Hugging Face Spaces as well! |
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.
LGTM nice @whitphx!
Awesome. Great job team. |
First of all this is awesome now that we have support for PWA manifests is there a way to enable client side caching and state persistence in our Gradio apps? |
Description
Add
manifest.json
to make the app installable as PWA on Chrome.Closes: #6734