summaryrefslogtreecommitdiffstats
path: root/platform/javascript/js
Commit message (Collapse)AuthorAgeFilesLines
* Revert "[HTML5] Better engine config parsing."Fabio Alessandrelli2022-02-031-21/+22
| | | | | | | This reverts commit 2f509f1b12c33234a0d8f0e254c727fd92e57720. Breaks closure compiler builds. And adds a warning for future readers.
* [HTML5] Fix gamepad samples not being properly reset.Fabio Alessandrelli2022-01-311-1/+1
|
* [HTML5] Better engine config parsing.Fabio Alessandrelli2022-01-311-20/+21
|
* Update copyright statements to 2022Rémi Verschelde2022-01-038-16/+16
| | | | Happy new year to the wonderful Godot community!
* Fix files_dropped in HTML5 export.Luis Sanchez2021-12-031-1/+1
| | | | (Ignore trailing slash when creating the temporary directory)
* [HTML5] Fix multi-touch input handling.Fabio Alessandrelli2021-11-301-3/+3
| | | | | | The code to populate the input data for WebAssembly was incorrectly overriding values when multiple touches were present due to wrong indexing.
* [HTML5] Fix focus (again) in Firefox's iframes.Fabio Alessandrelli2021-11-261-2/+6
| | | | | | | | This actually makes sense(?), when running inside an iframe the active element might be our canvas, while the iframe itself is not active in the parent window. Since we consume the event, the iframe does not get focused in Firefox (but does in Chromium-based browsers), so we must always call focus to handle such occasions.
* [HTML5] Add checks to Gamepad API events.Fabio Alessandrelli2021-11-191-2/+6
| | | | | | In some conditions the events might be generated even when the `gamepad` object is not accessible due to Security Context requirements. This commit adds a check to avoid firing the handler in those cases.
* [HTML5] Fix input not focusing canvas.Fabio Alessandrelli2021-11-191-0/+6
| | | | | mousedown and touchstart should focus the canvas to ensure correct application lifecycle.
* [HTML5] Refactor JS library listeners to OS.Fabio Alessandrelli2021-10-053-69/+69
|
* [HTML5] Refactor display/input JS library code.Fabio Alessandrelli2021-10-052-389/+405
|
* [HTML5] Implement Pointer Lock API in JS library.Fabio Alessandrelli2021-10-051-0/+28
| | | | Removes more emscripten HTML5 library dependencies.
* [HTML5] Implement window blur in JS library.Fabio Alessandrelli2021-10-051-0/+8
| | | | Removes more emscripten HTML5 library dependencies.
* [HTML5] Implement fullscreenchange in JS library.Fabio Alessandrelli2021-10-051-0/+14
| | | | Removes more emscripten HTML5 library dependencies.
* [HTML5] Implement mouse/touch/key events in JS library.Fabio Alessandrelli2021-10-052-9/+133
| | | | | This makes us more independent from emscripten libraries, giving us more control on the application lifecycle.
* HTML5: Fix minification error with Emscripten 1.39.9Rémi Verschelde2021-09-291-1/+1
| | | | | | | It used an old vendored version of acorn.js which seems to choke on this trailing comma. This is not a problem for more recent Emscripten versions. We disable the `comma-dangle` check in ESLint to prevent this issue.
* [HTML5] Refactor audio drivers. Implement AudioWorklet w/o threads.Fabio Alessandrelli2021-09-152-15/+152
| | | | | | | | | | Performances are not great in general, bad on Firefox, on Chrome, well, it could be an improvement. Leave it as a fallback for now, but can be forced via project settings if desired (or custom JavaScript logic via the "args" option). I'm actually surprised this works, it involves so many allocations, but there's no way around it when SharedArrayBuffer is not available :(.
* Merge pull request #52695 from Faless/js/4.x_audio_mix_rateFabio Alessandrelli2021-09-151-5/+12
|\ | | | | [HTML5] Use browser mix rate by default on the Web.
| * [HTML5] Use browser mix rate by default on the Web.Fabio Alessandrelli2021-09-151-5/+12
| | | | | | | | | | | | Browsers doesn't really like forcing the mix rate, e.g. Firefox does not allow input (microphone) if the mix rate is not the default one, Chrom* will exhibit worse performances, etc.
* | [HTML5] Fix bug in AudioWorklet when reading output buffer.Fabio Alessandrelli2021-09-151-7/+7
|/ | | | Would attempt an out of bounds read, causing an exception.
* [CI] Upgrade Emscripten to 2.0.27.Fabio Alessandrelli2021-08-181-1/+1
| | | | Update Godot Javascript FS library to manually depend on ERRNO_CODES.
* Fix various typos with codespellluz paz2021-07-251-1/+1
| | | | Found via `codespell -q 3 -S ./thirdparty,*.po,./DONORS.md -L ackward,ang,ans,ba,beng,cas,childs,childrens,dof,doubleclick,fave,findn,hist,inout,leapyear,lod,nd,numer,ois,ony,paket,seeked,sinc,switchs,te,uint`
* [HTML5] Add option to focus canvas on start.Fabio Alessandrelli2021-06-252-0/+13
| | | | Enabled by default.
* [HTML5] JS callback functions now returns passed value.Fabio Alessandrelli2021-06-181-1/+14
| | | | | | | | JavaScript callbacks created via the `JavaScript.create_callback` method used to always return void. With this patch they return the value returned by the Godot function as one would expect.
* [HTML5] Fix some JS library signature.Fabio Alessandrelli2021-06-143-5/+5
|
* Fixed missed IDHandler dependency in GodotFetchArthur Bikmullin2021-06-081-1/+1
|
* [HTML5] Add easy to use download API.Fabio Alessandrelli2021-05-212-57/+17
| | | | | New `JavaScript.download_buffer` method to create a prompt that let the user download a file.
* Merge pull request #48719 from Faless/js/4.x_interfacesRémi Verschelde2021-05-202-86/+333
|\ | | | | [HTML5] Implement Godot <-> JavaScript interface.
| * [HTML5] Implement Godot <-> JavaScript interface.Fabio Alessandrelli2021-05-202-86/+333
| |
* | Fix typos with codespellRémi Verschelde2021-05-201-1/+1
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Using codespell 2.0.0. Method: ``` $ cat > ../godot-word-whitelist.txt << EOF ang curvelinear dof doubleclick fave findn GIRD leapyear lod merchantibility nd numer ois ony que seeked synching te uint unselect webp EOF $ codespell -w -q 3 -I ../godot-word-whitelist.txt --skip="./thirdparty,*.po" $ git diff // undo unwanted changes ```
* [HTML5] Implement WebGL fallback.Fabio Alessandrelli2021-04-061-0/+11
| | | | | According to project settings and when WebGL2 is not available. This does nothing in current master, as we have no rendering yet!
* [HTML5] Disable body_size in fetch.Fabio Alessandrelli2021-04-032-29/+1
| | | | | | | | | | | | | | We were using `Content-Length` from the server when `Content-Encoding` was not set (i.e. response was not compressed). Sadly, in CORS requests accessing headers is restricted, and while `Content-Length` is enabled by default, `Content-Encoding` is not. This results in the impossibility of knowing if the content was compressed, unless the server explicitly enabled the encoding header via `Access-Control-Expose-Headers`. To keep maximum compatibility we must disable `body_size` completely.
* [HTML5] Fix WM notifications not being called.Fabio Alessandrelli2021-03-291-1/+1
| | | | | Regression from the library refactoring, binding and not calling is pretty useless 'o_o.
* [HTML5] Fix Mono builds (old emcc?)Fabio Alessandrelli2021-03-291-12/+16
| | | | | | | | | | | Promise chaining the emscripten module `then` function breaks it badly, causing an infinite loop. I'm unsure about the source of the issue, but most likely at this point is due to the old emscripten version (I remember very old html5 builds having issue with promise chaining too). With this commit, we no longer use the module as a promise, and instantiate it using `Promise` objects directly for compatibility.
* [HTML5] Fix loading when mime-type is missing.Fabio Alessandrelli2021-03-201-1/+1
| | | | | | | | | `WebAssembly.instantiateStreaming` requires the mime-type to be `application/wasm`, but some servers (including most debug servers) do not provide the content-type header. This commit forces it via JavaScript, by creating a `Response` object with the `wasm` content, and explicitly defined `content-type` header.
* [HTML5] Drag and drop zip in project manager.Fabio Alessandrelli2021-03-123-26/+48
| | | | | | | | | | | With a very nice hack, a new hidden configuration option that delays dropped files removal at exit. This still leaks while the project manager is running, but will clear memory as soon as it exits or load something. (reminder, dropped files are reguarly removed after the signal is emitted specifically to avoid leaks, but I prefer hacking the HTML5 config then the project manager).
* [HTML5] Opt-in virtual keyboard support.Fabio Alessandrelli2021-03-113-2/+147
| | | | | | | | | | | | | | | Added as an export option "Experimental Virtual Keyboard". There is no zoom, so text/line edit must be in the top part of the screen, or it will get hidden by the virtual keyboard. UTF8/Latin-1 only (I think regular UTF-8 should work out of the box in 4.0 but I can't test it). It uses an hidden textarea or input, based on the multiline variable, and only gets activated if the device has a touchscreen. This could cause problems on devices with both touchscreen and a real keyboard (although input should still work in general with some minor focus issues). I'm thinking of a system to detect the first physical keystroke and disable it in case, but it might do more harm then good, so it must be well thought.
* [HTML5] Properly set canvas size during setup.Fabio Alessandrelli2021-03-101-0/+1
| | | | | | It used to be updated before the first iteration, causing the window/viewport size values to be incorrect during the initialization phase (e.g. during the first `_ready` notification).
* [HTML5] Respect allow_hidpi option during setupFabio Alessandrelli2021-03-081-5/+10
| | | | The option was forced to `true` before, unlike on other platforms.
* [HTML5] Catch audio worklet errors on disconnect.Fabio Alessandrelli2021-03-081-1/+4
| | | | | Which could happen if the worklet was not fully loaded, or the audio context had already aborted.
* [HTML5] Replace XMLHttpRequest with Fetch.Fabio Alessandrelli2021-03-062-142/+258
| | | | | | This has some advantages: - Streaming/chunked response support. - Broader headers support.
* [HTML5] Rename heapCopy to heapSlice.Fabio Alessandrelli2021-03-053-4/+18
| | | | New heapCopy function copies a TypedArray to the heap.
* [HTML5] Export process writes sizes in template.Fabio Alessandrelli2021-03-053-10/+17
| | | | | | This allow the loading bar to be much more reliable, even in cases where realible stream loading status is not detectable (server-side compression, chunked encoding).
* [HTML5] Preloader fetch, streaming instantiation.Fabio Alessandrelli2021-03-054-70/+103
|
* [HTML5] Add jsdoc2rst tool.Fabio Alessandrelli2021-02-261-0/+354
| | | | | | | | | | | A template for `jsdoc` that generat the HTML5 public classref. The script can be run via `npm run docs` to print to stdout. You can dry run via `npm run docs -- --d dry-run` or write to file via `npm run docs -- -d /path/to/file.rst` Also update Makefile in `doc/` and add dry run test to CI.
* [HTML5] Document Engine and EngineConfig (jsdoc).Fabio Alessandrelli2021-02-263-258/+534
| | | | | This commit also removes the utils.js engine file, moving some of it's content to config.js and some to engine.js .
* [HTML5] Better fullscreen, canvas resizing.Fabio Alessandrelli2021-02-192-24/+167
| | | | | | | | | | | Three canvas resize policies: - `None`: Godot window settings are ignored. - `Project`: Godot handles the canvas like a native app (resizing it when setting the window size). - `Adaptive`: Canvas size will always adapt to browser window size. Use `None` if you want to control the canvas size with custom JavaScript code.
* [HTML5] Easier HTML templates, better deinit/cleanup.Fabio Alessandrelli2021-02-193-187/+166
|
* [HTML5] Implement get_processor_count.Fabio Alessandrelli2021-02-171-0/+5
|
* [HTML5] Detect screen scale and DPI.Fabio Alessandrelli2021-02-121-0/+26
| | | | | | | | `OS.get_screen_scale` will now return the `window.devicePixelRatio` value, `OS.get_screen_dpi` uses CSS media queries to find approximate DPI value for the current display. `OS.get_screen_size` also return the actual screen size (not the CSS pixel size).