From 184627285c9340a183a62560094b4679361597cf Mon Sep 17 00:00:00 2001 From: "Yuichiro Tachibana (Tsuchiya)" Date: Tue, 24 Dec 2024 21:01:39 +0900 Subject: [PATCH 1/3] [WIP] Detect PWA mode and show notification when served inside iframe --- js/core/src/Blocks.svelte | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/js/core/src/Blocks.svelte b/js/core/src/Blocks.svelte index fe2fc093c98c0..d261f25b52212 100644 --- a/js/core/src/Blocks.svelte +++ b/js/core/src/Blocks.svelte @@ -718,6 +718,17 @@ /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test( navigator.userAgent ); + + if (window.top && window.self !== window.top) { + // This app is in an iframe + fetch("/manifest.json", { method: "GET" }).then((response) => { + if (response.ok) { + const self_url = new URL(window.self.location.href); + const bare_self_url = self_url.origin + self_url.pathname; + // TODO: Show a notification like `This app is served as PWA. Visit ${bare_self_url} to install it.` + } + }); + } }); From 0beb11becf928d65f39fc9f46dfaffbd19a0a578 Mon Sep 17 00:00:00 2001 From: gradio-pr-bot Date: Tue, 24 Dec 2024 12:02:55 +0000 Subject: [PATCH 2/3] add changeset --- .changeset/fuzzy-frogs-tap.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changeset/fuzzy-frogs-tap.md diff --git a/.changeset/fuzzy-frogs-tap.md b/.changeset/fuzzy-frogs-tap.md new file mode 100644 index 0000000000000..a5b1346ffebf5 --- /dev/null +++ b/.changeset/fuzzy-frogs-tap.md @@ -0,0 +1,6 @@ +--- +"@gradio/core": minor +"gradio": minor +--- + +feat:[WIP] Detect PWA mode and show notification when served inside iframe From f863d369e47ff74210917923aa6068d4e4741a36 Mon Sep 17 00:00:00 2001 From: gradio-pr-bot Date: Tue, 24 Dec 2024 12:05:07 +0000 Subject: [PATCH 3/3] add changeset --- .changeset/fuzzy-frogs-tap.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/fuzzy-frogs-tap.md b/.changeset/fuzzy-frogs-tap.md index a5b1346ffebf5..a49633d777a1f 100644 --- a/.changeset/fuzzy-frogs-tap.md +++ b/.changeset/fuzzy-frogs-tap.md @@ -3,4 +3,4 @@ "gradio": minor --- -feat:[WIP] Detect PWA mode and show notification when served inside iframe +feat:[DO NOT MERGE] Detect PWA mode and show notification when served inside iframe