From 948e66c3d6930924b54ec48a0dfc929040befb0a Mon Sep 17 00:00:00 2001 From: Fabio Alessandrelli Date: Mon, 31 Jan 2022 15:28:12 +0100 Subject: [HTML5] Implement JavaScript PWA update callbacks. Allows detecting when a new version of the progressive web app service worker is waiting (i.e. an update is pending), along a function to force the update and reload all clients. --- platform/javascript/api/api.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'platform/javascript/api/api.cpp') diff --git a/platform/javascript/api/api.cpp b/platform/javascript/api/api.cpp index 0c4accccc3..4190b24b8e 100644 --- a/platform/javascript/api/api.cpp +++ b/platform/javascript/api/api.cpp @@ -71,6 +71,9 @@ void JavaScript::_bind_methods() { ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT, "create_object", &JavaScript::_create_object_bind, mi); } ClassDB::bind_method(D_METHOD("download_buffer", "buffer", "name", "mime"), &JavaScript::download_buffer, DEFVAL("application/octet-stream")); + ClassDB::bind_method(D_METHOD("pwa_needs_update"), &JavaScript::pwa_needs_update); + ClassDB::bind_method(D_METHOD("pwa_update"), &JavaScript::pwa_update); + ADD_SIGNAL(MethodInfo("pwa_update_available")); } #if !defined(JAVASCRIPT_ENABLED) || !defined(JAVASCRIPT_EVAL_ENABLED) @@ -102,6 +105,12 @@ Variant JavaScript::_create_object_bind(const Variant **p_args, int p_argcount, } #endif #if !defined(JAVASCRIPT_ENABLED) +bool JavaScript::pwa_needs_update() const { + return false; +} +Error JavaScript::pwa_update() { + return ERR_UNAVAILABLE; +} void JavaScript::download_buffer(Vector p_arr, const String &p_name, const String &p_mime) { } #endif -- cgit v1.2.3