mirror of
https://github.com/godotengine/godot-docs.git
synced 2026-01-08 10:10:54 +03:00
classref: Sync with current master branch (f87858a8f)
This commit is contained in:
@@ -14,6 +14,8 @@ JavaScriptBridge
|
||||
|
||||
Singleton that connects the engine with the browser's JavaScript context in Web export.
|
||||
|
||||
.. rst-class:: classref-introduction-group
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
@@ -21,61 +23,92 @@ The JavaScriptBridge singleton is implemented only in the Web export. It's used
|
||||
|
||||
\ **Note:** This singleton can be disabled at build-time to improve security. By default, the JavaScriptBridge singleton is enabled. Official export templates also have the JavaScriptBridge singleton enabled. See :doc:`Compiling for the Web <../development/compiling/compiling_for_web>` in the documentation for more information.
|
||||
|
||||
.. rst-class:: classref-introduction-group
|
||||
|
||||
Tutorials
|
||||
---------
|
||||
|
||||
- `Exporting for the Web: Calling JavaScript from script <../tutorials/export/exporting_for_web.html#calling-javascript-from-script>`__
|
||||
|
||||
.. rst-class:: classref-reftable-group
|
||||
|
||||
Methods
|
||||
-------
|
||||
|
||||
+-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| :ref:`JavaScriptObject<class_JavaScriptObject>` | :ref:`create_callback<class_JavaScriptBridge_method_create_callback>` **(** :ref:`Callable<class_Callable>` callable **)** |
|
||||
+-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| :ref:`Variant<class_Variant>` | :ref:`create_object<class_JavaScriptBridge_method_create_object>` **(** :ref:`String<class_String>` object, ... **)** |vararg| |
|
||||
+-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| void | :ref:`download_buffer<class_JavaScriptBridge_method_download_buffer>` **(** :ref:`PackedByteArray<class_PackedByteArray>` buffer, :ref:`String<class_String>` name, :ref:`String<class_String>` mime="application/octet-stream" **)** |
|
||||
+-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| :ref:`Variant<class_Variant>` | :ref:`eval<class_JavaScriptBridge_method_eval>` **(** :ref:`String<class_String>` code, :ref:`bool<class_bool>` use_global_execution_context=false **)** |
|
||||
+-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| :ref:`JavaScriptObject<class_JavaScriptObject>` | :ref:`get_interface<class_JavaScriptBridge_method_get_interface>` **(** :ref:`String<class_String>` interface **)** |
|
||||
+-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| :ref:`bool<class_bool>` | :ref:`pwa_needs_update<class_JavaScriptBridge_method_pwa_needs_update>` **(** **)** |const| |
|
||||
+-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| :ref:`Error<enum_@GlobalScope_Error>` | :ref:`pwa_update<class_JavaScriptBridge_method_pwa_update>` **(** **)** |
|
||||
+-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
.. table::
|
||||
:widths: auto
|
||||
|
||||
+-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| :ref:`JavaScriptObject<class_JavaScriptObject>` | :ref:`create_callback<class_JavaScriptBridge_method_create_callback>` **(** :ref:`Callable<class_Callable>` callable **)** |
|
||||
+-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| :ref:`Variant<class_Variant>` | :ref:`create_object<class_JavaScriptBridge_method_create_object>` **(** :ref:`String<class_String>` object, ... **)** |vararg| |
|
||||
+-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| void | :ref:`download_buffer<class_JavaScriptBridge_method_download_buffer>` **(** :ref:`PackedByteArray<class_PackedByteArray>` buffer, :ref:`String<class_String>` name, :ref:`String<class_String>` mime="application/octet-stream" **)** |
|
||||
+-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| :ref:`Variant<class_Variant>` | :ref:`eval<class_JavaScriptBridge_method_eval>` **(** :ref:`String<class_String>` code, :ref:`bool<class_bool>` use_global_execution_context=false **)** |
|
||||
+-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| :ref:`JavaScriptObject<class_JavaScriptObject>` | :ref:`get_interface<class_JavaScriptBridge_method_get_interface>` **(** :ref:`String<class_String>` interface **)** |
|
||||
+-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| :ref:`bool<class_bool>` | :ref:`pwa_needs_update<class_JavaScriptBridge_method_pwa_needs_update>` **(** **)** |const| |
|
||||
+-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| :ref:`Error<enum_@GlobalScope_Error>` | :ref:`pwa_update<class_JavaScriptBridge_method_pwa_update>` **(** **)** |
|
||||
+-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
|
||||
.. rst-class:: classref-section-separator
|
||||
|
||||
----
|
||||
|
||||
.. rst-class:: classref-descriptions-group
|
||||
|
||||
Signals
|
||||
-------
|
||||
|
||||
.. _class_JavaScriptBridge_signal_pwa_update_available:
|
||||
|
||||
- **pwa_update_available** **(** **)**
|
||||
.. rst-class:: classref-signal
|
||||
|
||||
**pwa_update_available** **(** **)**
|
||||
|
||||
Emitted when an update for this progressive web app has been detected but is waiting to be activated because a previous version is active. See :ref:`pwa_update<class_JavaScriptBridge_method_pwa_update>` to force the update to take place immediately.
|
||||
|
||||
.. rst-class:: classref-section-separator
|
||||
|
||||
----
|
||||
|
||||
.. rst-class:: classref-descriptions-group
|
||||
|
||||
Method Descriptions
|
||||
-------------------
|
||||
|
||||
.. _class_JavaScriptBridge_method_create_callback:
|
||||
|
||||
- :ref:`JavaScriptObject<class_JavaScriptObject>` **create_callback** **(** :ref:`Callable<class_Callable>` callable **)**
|
||||
.. rst-class:: classref-method
|
||||
|
||||
:ref:`JavaScriptObject<class_JavaScriptObject>` **create_callback** **(** :ref:`Callable<class_Callable>` callable **)**
|
||||
|
||||
Creates a reference to a :ref:`Callable<class_Callable>` that can be used as a callback by JavaScript. The reference must be kept until the callback happens, or it won't be called at all. See :ref:`JavaScriptObject<class_JavaScriptObject>` for usage.
|
||||
|
||||
.. rst-class:: classref-item-separator
|
||||
|
||||
----
|
||||
|
||||
.. _class_JavaScriptBridge_method_create_object:
|
||||
|
||||
- :ref:`Variant<class_Variant>` **create_object** **(** :ref:`String<class_String>` object, ... **)** |vararg|
|
||||
.. rst-class:: classref-method
|
||||
|
||||
:ref:`Variant<class_Variant>` **create_object** **(** :ref:`String<class_String>` object, ... **)** |vararg|
|
||||
|
||||
Creates a new JavaScript object using the ``new`` constructor. The ``object`` must a valid property of the JavaScript ``window``. See :ref:`JavaScriptObject<class_JavaScriptObject>` for usage.
|
||||
|
||||
.. rst-class:: classref-item-separator
|
||||
|
||||
----
|
||||
|
||||
.. _class_JavaScriptBridge_method_download_buffer:
|
||||
|
||||
- void **download_buffer** **(** :ref:`PackedByteArray<class_PackedByteArray>` buffer, :ref:`String<class_String>` name, :ref:`String<class_String>` mime="application/octet-stream" **)**
|
||||
.. rst-class:: classref-method
|
||||
|
||||
void **download_buffer** **(** :ref:`PackedByteArray<class_PackedByteArray>` buffer, :ref:`String<class_String>` name, :ref:`String<class_String>` mime="application/octet-stream" **)**
|
||||
|
||||
Prompts the user to download a file containing the specified ``buffer``. The file will have the given ``name`` and ``mime`` type.
|
||||
|
||||
@@ -85,39 +118,55 @@ Prompts the user to download a file containing the specified ``buffer``. The fil
|
||||
|
||||
\ **Note:** Browsers might ask the user for permission or block the download if multiple download requests are made in a quick succession.
|
||||
|
||||
.. rst-class:: classref-item-separator
|
||||
|
||||
----
|
||||
|
||||
.. _class_JavaScriptBridge_method_eval:
|
||||
|
||||
- :ref:`Variant<class_Variant>` **eval** **(** :ref:`String<class_String>` code, :ref:`bool<class_bool>` use_global_execution_context=false **)**
|
||||
.. rst-class:: classref-method
|
||||
|
||||
:ref:`Variant<class_Variant>` **eval** **(** :ref:`String<class_String>` code, :ref:`bool<class_bool>` use_global_execution_context=false **)**
|
||||
|
||||
Execute the string ``code`` as JavaScript code within the browser window. This is a call to the actual global JavaScript function ``eval()``.
|
||||
|
||||
If ``use_global_execution_context`` is ``true``, the code will be evaluated in the global execution context. Otherwise, it is evaluated in the execution context of a function within the engine's runtime environment.
|
||||
|
||||
.. rst-class:: classref-item-separator
|
||||
|
||||
----
|
||||
|
||||
.. _class_JavaScriptBridge_method_get_interface:
|
||||
|
||||
- :ref:`JavaScriptObject<class_JavaScriptObject>` **get_interface** **(** :ref:`String<class_String>` interface **)**
|
||||
.. rst-class:: classref-method
|
||||
|
||||
:ref:`JavaScriptObject<class_JavaScriptObject>` **get_interface** **(** :ref:`String<class_String>` interface **)**
|
||||
|
||||
Returns an interface to a JavaScript object that can be used by scripts. The ``interface`` must be a valid property of the JavaScript ``window``. The callback must accept a single :ref:`Array<class_Array>` argument, which will contain the JavaScript ``arguments``. See :ref:`JavaScriptObject<class_JavaScriptObject>` for usage.
|
||||
|
||||
.. rst-class:: classref-item-separator
|
||||
|
||||
----
|
||||
|
||||
.. _class_JavaScriptBridge_method_pwa_needs_update:
|
||||
|
||||
- :ref:`bool<class_bool>` **pwa_needs_update** **(** **)** |const|
|
||||
.. rst-class:: classref-method
|
||||
|
||||
:ref:`bool<class_bool>` **pwa_needs_update** **(** **)** |const|
|
||||
|
||||
Returns ``true`` if a new version of the progressive web app is waiting to be activated.
|
||||
|
||||
\ **Note:** Only relevant when exported as a Progressive Web App.
|
||||
|
||||
.. rst-class:: classref-item-separator
|
||||
|
||||
----
|
||||
|
||||
.. _class_JavaScriptBridge_method_pwa_update:
|
||||
|
||||
- :ref:`Error<enum_@GlobalScope_Error>` **pwa_update** **(** **)**
|
||||
.. rst-class:: classref-method
|
||||
|
||||
:ref:`Error<enum_@GlobalScope_Error>` **pwa_update** **(** **)**
|
||||
|
||||
Performs the live update of the progressive web app. Forcing the new version to be installed and the page to be reloaded.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user