summaryrefslogtreecommitdiff
path: root/platform/javascript/js
AgeCommit message (Collapse)Author
2021-09-29HTML5: Fix minification error with Emscripten 1.39.9Rémi Verschelde
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.
2021-09-15[HTML5] Refactor audio drivers. Implement AudioWorklet w/o threads.Fabio Alessandrelli
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 :(.
2021-09-15Merge pull request #52695 from Faless/js/4.x_audio_mix_rateFabio Alessandrelli
[HTML5] Use browser mix rate by default on the Web.
2021-09-15[HTML5] Fix bug in AudioWorklet when reading output buffer.Fabio Alessandrelli
Would attempt an out of bounds read, causing an exception.
2021-09-15[HTML5] Use browser mix rate by default on the Web.Fabio Alessandrelli
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.
2021-08-18[CI] Upgrade Emscripten to 2.0.27.Fabio Alessandrelli
Update Godot Javascript FS library to manually depend on ERRNO_CODES.
2021-07-25Fix various typos with codespellluz paz
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`
2021-06-25[HTML5] Add option to focus canvas on start.Fabio Alessandrelli
Enabled by default.
2021-06-18[HTML5] JS callback functions now returns passed value.Fabio Alessandrelli
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.
2021-06-14[HTML5] Fix some JS library signature.Fabio Alessandrelli
2021-06-08Fixed missed IDHandler dependency in GodotFetchArthur Bikmullin
2021-05-21[HTML5] Add easy to use download API.Fabio Alessandrelli
New `JavaScript.download_buffer` method to create a prompt that let the user download a file.
2021-05-20Merge pull request #48719 from Faless/js/4.x_interfacesRémi Verschelde
[HTML5] Implement Godot <-> JavaScript interface.
2021-05-20[HTML5] Implement Godot <-> JavaScript interface.Fabio Alessandrelli
2021-05-20Fix typos with codespellRémi Verschelde
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 ```
2021-04-06[HTML5] Implement WebGL fallback.Fabio Alessandrelli
According to project settings and when WebGL2 is not available. This does nothing in current master, as we have no rendering yet!
2021-04-03[HTML5] Disable body_size in fetch.Fabio Alessandrelli
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.
2021-03-29[HTML5] Fix WM notifications not being called.Fabio Alessandrelli
Regression from the library refactoring, binding and not calling is pretty useless 'o_o.
2021-03-29[HTML5] Fix Mono builds (old emcc?)Fabio Alessandrelli
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.
2021-03-20[HTML5] Fix loading when mime-type is missing.Fabio Alessandrelli
`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.
2021-03-12[HTML5] Drag and drop zip in project manager.Fabio Alessandrelli
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).
2021-03-11[HTML5] Opt-in virtual keyboard support.Fabio Alessandrelli
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.
2021-03-10[HTML5] Properly set canvas size during setup.Fabio Alessandrelli
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).
2021-03-08[HTML5] Respect allow_hidpi option during setupFabio Alessandrelli
The option was forced to `true` before, unlike on other platforms.
2021-03-08[HTML5] Catch audio worklet errors on disconnect.Fabio Alessandrelli
Which could happen if the worklet was not fully loaded, or the audio context had already aborted.
2021-03-06[HTML5] Replace XMLHttpRequest with Fetch.Fabio Alessandrelli
This has some advantages: - Streaming/chunked response support. - Broader headers support.
2021-03-05[HTML5] Rename heapCopy to heapSlice.Fabio Alessandrelli
New heapCopy function copies a TypedArray to the heap.
2021-03-05[HTML5] Export process writes sizes in template.Fabio Alessandrelli
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).
2021-03-05[HTML5] Preloader fetch, streaming instantiation.Fabio Alessandrelli
2021-02-26[HTML5] Add jsdoc2rst tool.Fabio Alessandrelli
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.
2021-02-26[HTML5] Document Engine and EngineConfig (jsdoc).Fabio Alessandrelli
This commit also removes the utils.js engine file, moving some of it's content to config.js and some to engine.js .
2021-02-19[HTML5] Better fullscreen, canvas resizing.Fabio Alessandrelli
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.
2021-02-19[HTML5] Easier HTML templates, better deinit/cleanup.Fabio Alessandrelli
2021-02-17[HTML5] Implement get_processor_count.Fabio Alessandrelli
2021-02-12[HTML5] Detect screen scale and DPI.Fabio Alessandrelli
`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).
2021-02-11Merge pull request #45888 from Faless/js/4.x_xhr_fixRémi Verschelde
[HTML5] Fix HTTPClient request_raw.
2021-02-11[HTML5] Fix HTTPClient request_raw.Fabio Alessandrelli
Now send data according to the spec, properly handle null data. Simplify JS code since we are at it.
2021-02-11[HTML5] Handle contextmenu, webglcontextlost internally.Fabio Alessandrelli
This way they are automatically cleaned up when the engine exits, landing a hand to browsers garbage collectors.
2021-01-25[HTML5] Better editor HTML, small refactor.Fabio Alessandrelli
Side and GDNative libraries are now added by engine.js , the dynlink pre js had been deleted.
2021-01-18[HTML5] Custom Gamepad library to allow remapping.Fabio Alessandrelli
No longer use emscripten functions for gamepads, implement them as library functions in library_godot_display.js instead. This allows us to do a better job at "guessing" vendorId, productId, OS, etc. thus allowing us to better find the remapping for the controller.
2021-01-01Update copyright statements to 2021Rémi Verschelde
Happy new year to the wonderful Godot community! 2020 has been a tough year for most of us personally, but a good year for Godot development nonetheless with a huge amount of work done towards Godot 4.0 and great improvements backported to the long-lived 3.2 branch. We've had close to 400 contributors to engine code this year, authoring near 7,000 commit! (And that's only for the `master` branch and for the engine code, there's a lot more when counting docs, demos and other first-party repos.) Here's to a great year 2021 for all Godot users 🎆
2020-12-09[HTML5] Fix errors when Mic is not allowed.Fabio Alessandrelli
2020-12-05[HTML5] EditorRunNative works with GDNative.Fabio Alessandrelli
This "breaks" our loading bar logic (libraries are not counted). Fixing it is non trivial and probably deserves investigating a different strategy.
2020-12-05[HTML5] GDNative support via SIDE_MODULE.Fabio Alessandrelli
Working with emscripten >= 2.0.10
2020-12-04[HTML5] Add function signatures to JS libraries.Fabio Alessandrelli
2020-11-30[HTML5] Remove file flags from writeFile in setup.Fabio Alessandrelli
Flags where deprecated and partly in removed in emscripten 2.0.9.
2020-11-23[HTML5] Run eslint --fix.Fabio Alessandrelli
Should I write a poem about this whole new world? ;)
2020-11-21[HTML5] Libraries refactor for linting.Fabio Alessandrelli
Initial work to make liniting easier. This includes: - Rename http_request.js to library_godot_http_request.js. - Rename externs.js to engine.externs.js. - New library_godot_runtime.js (GodotRuntime) wraps around emscripten functions. - Refactor of XMLHttpRequest handler in engine/preloader.js. - Few fixes to bugs spotted by early stage linting.