[Web] Rename JavaScript platform to Web.

Also rename export name from "HTML5" to "Web".
This commit is contained in:
Fabio Alessandrelli 2022-08-28 20:27:45 +02:00
parent 223e083d36
commit d20b32186f
120 changed files with 547 additions and 548 deletions

View File

@ -47,7 +47,7 @@ jobs:
- name: JavaScript style and documentation checks via ESLint and JSDoc - name: JavaScript style and documentation checks via ESLint and JSDoc
run: | run: |
cd platform/javascript cd platform/web
npm ci npm ci
npm run lint npm run lint
npm run docs -- -d dry-run npm run docs -- -d dry-run

View File

@ -1,4 +1,4 @@
name: 🌐 JavaScript Builds name: 🌐 Web Builds
on: [push, pull_request] on: [push, pull_request]
# Global Settings # Global Settings
@ -10,11 +10,11 @@ env:
EM_CACHE_FOLDER: "emsdk-cache" EM_CACHE_FOLDER: "emsdk-cache"
concurrency: concurrency:
group: ci-${{github.actor}}-${{github.head_ref || github.run_number}}-${{github.ref}}-javascript group: ci-${{github.actor}}-${{github.head_ref || github.run_number}}-${{github.ref}}-web
cancel-in-progress: true cancel-in-progress: true
jobs: jobs:
javascript-template: web-template:
runs-on: "ubuntu-20.04" runs-on: "ubuntu-20.04"
name: Template (target=release, tools=no) name: Template (target=release, tools=no)
@ -42,7 +42,7 @@ jobs:
uses: ./.github/actions/godot-build uses: ./.github/actions/godot-build
with: with:
sconsflags: ${{ env.SCONSFLAGS }} sconsflags: ${{ env.SCONSFLAGS }}
platform: javascript platform: web
target: release target: release
tools: false tools: false
tests: false tests: false

View File

@ -14,8 +14,7 @@ comprehensive set of [common tools](https://godotengine.org/features), so that u
without having to reinvent the wheel. Games can be exported with one click to a without having to reinvent the wheel. Games can be exported with one click to a
number of platforms, including the major desktop platforms (Linux, macOS, number of platforms, including the major desktop platforms (Linux, macOS,
Windows), mobile platforms (Android, iOS), as well as Web-based platforms Windows), mobile platforms (Android, iOS), as well as Web-based platforms
(HTML5) and and [consoles](https://docs.godotengine.org/en/latest/tutorials/platform/consoles.html).
[consoles](https://docs.godotengine.org/en/latest/tutorials/platform/consoles.html).
## Free, open source and community-driven ## Free, open source and community-driven

View File

@ -106,7 +106,7 @@ platform_arg = ARGUMENTS.get("platform", ARGUMENTS.get("p", False))
if platform_arg == "android": if platform_arg == "android":
custom_tools = ["clang", "clang++", "as", "ar", "link"] custom_tools = ["clang", "clang++", "as", "ar", "link"]
elif platform_arg == "javascript": elif platform_arg == "web":
# Use generic POSIX build toolchain for Emscripten. # Use generic POSIX build toolchain for Emscripten.
custom_tools = ["cc", "c++", "ar", "link", "textfile", "zip"] custom_tools = ["cc", "c++", "ar", "link", "textfile", "zip"]
elif os.name == "nt" and methods.get_cmdline_bool("use_mingw", False): elif os.name == "nt" and methods.get_cmdline_bool("use_mingw", False):

View File

@ -7,31 +7,31 @@ __XINPUT_DEVICE__,XInput Gamepad,a:b12,b:b13,x:b14,y:b15,start:b4,back:b5,leftst
# Android # Android
Default Android Gamepad,Default Controller,leftx:a0,lefty:a1,dpdown:h0.4,rightstick:b8,rightshoulder:b10,rightx:a2,start:b6,righty:a3,dpleft:h0.8,lefttrigger:a4,x:b2,dpup:h0.1,back:b4,leftstick:b7,leftshoulder:b9,y:b3,a:b0,dpright:h0.2,righttrigger:a5,b:b1,platform:Android, Default Android Gamepad,Default Controller,leftx:a0,lefty:a1,dpdown:h0.4,rightstick:b8,rightshoulder:b10,rightx:a2,start:b6,righty:a3,dpleft:h0.8,lefttrigger:a4,x:b2,dpup:h0.1,back:b4,leftstick:b7,leftshoulder:b9,y:b3,a:b0,dpright:h0.2,righttrigger:a5,b:b1,platform:Android,
# Javascript # Web
standard,Standard Gamepad Mapping,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a6,righttrigger:a7,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b8,start:b9,leftstick:b10,rightstick:b11,dpup:b12,dpdown:b13,dpleft:b14,dpright:b15,guide:b16,leftstick:b10,rightstick:b11,platform:Javascript, standard,Standard Gamepad Mapping,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a6,righttrigger:a7,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b8,start:b9,leftstick:b10,rightstick:b11,dpup:b12,dpdown:b13,dpleft:b14,dpright:b15,guide:b16,leftstick:b10,rightstick:b11,platform:Web,
Linux24c6581a,PowerA Xbox One Cabled,a:b0,b:b1,y:b3,x:b2,start:b7,guide:b8,back:b6,leftstick:b9,rightstick:b10,leftshoulder:b4,rightshoulder:b5,dpup:-a7,dpleft:-a6,dpdown:+a7,dpright:+a6,leftx:a0,lefty:a1,rightx:a3,righty:a4,lefttrigger:a2,righttrigger:a5,platform:Javascript, Linux24c6581a,PowerA Xbox One Cabled,a:b0,b:b1,y:b3,x:b2,start:b7,guide:b8,back:b6,leftstick:b9,rightstick:b10,leftshoulder:b4,rightshoulder:b5,dpup:-a7,dpleft:-a6,dpdown:+a7,dpright:+a6,leftx:a0,lefty:a1,rightx:a3,righty:a4,lefttrigger:a2,righttrigger:a5,platform:Web,
Linux0e6f0301,Logic 3 Controller (xbox compatible),a:b0,b:b1,y:b3,x:b2,start:b7,guide:b8,back:b6,leftstick:b9,rightstick:b10,leftshoulder:b4,rightshoulder:b5,dpup:-a7,dpleft:-a6,dpdown:+a7,dpright:+a6,leftx:a0,lefty:a1,rightx:a3,righty:a4,lefttrigger:a2,righttrigger:a5,platform:Javascript, Linux0e6f0301,Logic 3 Controller (xbox compatible),a:b0,b:b1,y:b3,x:b2,start:b7,guide:b8,back:b6,leftstick:b9,rightstick:b10,leftshoulder:b4,rightshoulder:b5,dpup:-a7,dpleft:-a6,dpdown:+a7,dpright:+a6,leftx:a0,lefty:a1,rightx:a3,righty:a4,lefttrigger:a2,righttrigger:a5,platform:Web,
Linux045e028e,Microsoft X-Box 360 pad,a:b0,b:b1,y:b3,x:b2,start:b7,guide:b8,back:b6,leftstick:b9,rightstick:b10,leftshoulder:b4,rightshoulder:b5,dpup:-a7,dpleft:-a6,dpdown:+a7,dpright:+a6,leftx:a0,lefty:a1,rightx:a3,righty:a4,lefttrigger:a2,righttrigger:a5,platform:Javascript, Linux045e028e,Microsoft X-Box 360 pad,a:b0,b:b1,y:b3,x:b2,start:b7,guide:b8,back:b6,leftstick:b9,rightstick:b10,leftshoulder:b4,rightshoulder:b5,dpup:-a7,dpleft:-a6,dpdown:+a7,dpright:+a6,leftx:a0,lefty:a1,rightx:a3,righty:a4,lefttrigger:a2,righttrigger:a5,platform:Web,
Linux045e02d1,Microsoft X-Box One pad,a:b0,b:b1,y:b3,x:b2,start:b7,guide:b8,back:b6,leftstick:b9,rightstick:b10,leftshoulder:b4,rightshoulder:b5,dpup:-a7,dpleft:-a6,dpdown:+a7,dpright:+a6,leftx:a0,lefty:a1,rightx:a3,righty:a4,lefttrigger:a2,righttrigger:a5,platform:Javascript, Linux045e02d1,Microsoft X-Box One pad,a:b0,b:b1,y:b3,x:b2,start:b7,guide:b8,back:b6,leftstick:b9,rightstick:b10,leftshoulder:b4,rightshoulder:b5,dpup:-a7,dpleft:-a6,dpdown:+a7,dpright:+a6,leftx:a0,lefty:a1,rightx:a3,righty:a4,lefttrigger:a2,righttrigger:a5,platform:Web,
Linux045e02ea,Microsoft X-Box One S pad,a:b0,b:b1,y:b3,x:b2,start:b7,guide:b8,back:b6,leftstick:b9,rightstick:b10,leftshoulder:b4,rightshoulder:b5,dpup:-a7,dpleft:-a6,dpdown:+a7,dpright:+a6,leftx:a0,lefty:a1,rightx:a3,righty:a4,lefttrigger:a2,righttrigger:a5,platform:Javascript, Linux045e02ea,Microsoft X-Box One S pad,a:b0,b:b1,y:b3,x:b2,start:b7,guide:b8,back:b6,leftstick:b9,rightstick:b10,leftshoulder:b4,rightshoulder:b5,dpup:-a7,dpleft:-a6,dpdown:+a7,dpright:+a6,leftx:a0,lefty:a1,rightx:a3,righty:a4,lefttrigger:a2,righttrigger:a5,platform:Web,
Linux045e0b12,Microsoft X-Box Series X pad,a:b0,b:b1,y:b3,x:b2,start:b7,guide:b8,back:b6,leftstick:b9,rightstick:b10,leftshoulder:b4,rightshoulder:b5,dpup:-a7,dpleft:-a6,dpdown:+a7,dpright:+a6,leftx:a0,lefty:a1,rightx:a3,righty:a4,lefttrigger:a2,righttrigger:a5,platform:Javascript, Linux045e0b12,Microsoft X-Box Series X pad,a:b0,b:b1,y:b3,x:b2,start:b7,guide:b8,back:b6,leftstick:b9,rightstick:b10,leftshoulder:b4,rightshoulder:b5,dpup:-a7,dpleft:-a6,dpdown:+a7,dpright:+a6,leftx:a0,lefty:a1,rightx:a3,righty:a4,lefttrigger:a2,righttrigger:a5,platform:Web,
Linux044fb315,Thrustmaster dual analog 3.2,a:b0,b:b2,y:b3,x:b1,start:b9,back:b8,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b6,dpup:-a5,dpleft:-a4,dpdown:+a5,dpright:+a4,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b5,righttrigger:b7,platform:Javascript, Linux044fb315,Thrustmaster dual analog 3.2,a:b0,b:b2,y:b3,x:b1,start:b9,back:b8,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b6,dpup:-a5,dpleft:-a4,dpdown:+a5,dpright:+a4,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b5,righttrigger:b7,platform:Web,
Linux0e8f0003,PS3 Controller,a:b2,b:b1,back:b8,dpdown:+a5,dpleft:-a4,dpright:+a4,dpup:-a5,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Javascript, Linux0e8f0003,PS3 Controller,a:b2,b:b1,back:b8,dpdown:+a5,dpleft:-a4,dpright:+a4,dpup:-a5,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Web,
MacOSX24c6581a,PowerA Xbox One Cabled,a:b11,b:b12,y:b14,x:b13,start:b4,back:b5,leftstick:b6,rightstick:b7,leftshoulder:b8,rightshoulder:b9,dpup:b0,dpleft:b2,dpdown:b1,dpright:b3,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,platform:Javascript MacOSX24c6581a,PowerA Xbox One Cabled,a:b11,b:b12,y:b14,x:b13,start:b4,back:b5,leftstick:b6,rightstick:b7,leftshoulder:b8,rightshoulder:b9,dpup:b0,dpleft:b2,dpdown:b1,dpright:b3,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,platform:Web
MacOSX045e028e,Xbox 360 Wired Controller,a:b11,b:b12,y:b14,x:b13,start:b4,back:b5,leftstick:b6,rightstick:b7,leftshoulder:b8,rightshoulder:b9,dpup:b0,dpleft:b2,dpdown:b1,dpright:b3,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,platform:Javascript MacOSX045e028e,Xbox 360 Wired Controller,a:b11,b:b12,y:b14,x:b13,start:b4,back:b5,leftstick:b6,rightstick:b7,leftshoulder:b8,rightshoulder:b9,dpup:b0,dpleft:b2,dpdown:b1,dpright:b3,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,platform:Web
MacOSX045e02d1,Xbox One Controller,a:b11,b:b12,y:b14,x:b13,start:b4,back:b5,leftstick:b6,rightstick:b7,leftshoulder:b8,rightshoulder:b9,dpup:b0,dpleft:b2,dpdown:b1,dpright:b3,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,platform:Javascript MacOSX045e02d1,Xbox One Controller,a:b11,b:b12,y:b14,x:b13,start:b4,back:b5,leftstick:b6,rightstick:b7,leftshoulder:b8,rightshoulder:b9,dpup:b0,dpleft:b2,dpdown:b1,dpright:b3,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,platform:Web
MacOSX045e02ea,Xbox One S Controller,a:b11,b:b12,y:b14,x:b13,start:b4,back:b5,leftstick:b6,rightstick:b7,leftshoulder:b8,rightshoulder:b9,dpup:b0,dpleft:b2,dpdown:b1,dpright:b3,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,platform:Javascript MacOSX045e02ea,Xbox One S Controller,a:b11,b:b12,y:b14,x:b13,start:b4,back:b5,leftstick:b6,rightstick:b7,leftshoulder:b8,rightshoulder:b9,dpup:b0,dpleft:b2,dpdown:b1,dpright:b3,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,platform:Web
MacOSX045e0b12,Xbox Series X Controller,a:b11,b:b12,y:b14,x:b13,start:b4,back:b5,leftstick:b6,rightstick:b7,leftshoulder:b8,rightshoulder:b9,dpup:b0,dpleft:b2,dpdown:b1,dpright:b3,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,platform:Javascript MacOSX045e0b12,Xbox Series X Controller,a:b11,b:b12,y:b14,x:b13,start:b4,back:b5,leftstick:b6,rightstick:b7,leftshoulder:b8,rightshoulder:b9,dpup:b0,dpleft:b2,dpdown:b1,dpright:b3,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,platform:Web
Linux15320a14,Razer Wolverine Ultimate,a:b0,b:b1,y:b3,x:b2,start:b7,back:b6,leftstick:b9,rightstick:b10,leftshoulder:b4,rightshoulder:b5,dpup:-a7,dpleft:-a6,dpdown:+a7,dpright:+a6,leftx:a0,lefty:a1,rightx:a3,righty:a4,lefttrigger:a2,righttrigger:a5,platform:Javascript Linux15320a14,Razer Wolverine Ultimate,a:b0,b:b1,y:b3,x:b2,start:b7,back:b6,leftstick:b9,rightstick:b10,leftshoulder:b4,rightshoulder:b5,dpup:-a7,dpleft:-a6,dpdown:+a7,dpright:+a6,leftx:a0,lefty:a1,rightx:a3,righty:a4,lefttrigger:a2,righttrigger:a5,platform:Web
Linux05832060,iBuffalo BSGP801,a:b1,b:b0,y:b2,x:b3,start:b7,back:b6,leftshoulder:b4,rightshoulder:b5,dpup:-a1,dpleft:-a0,dpdown:+a1,dpright:+a0,platform:Javascript Linux05832060,iBuffalo BSGP801,a:b1,b:b0,y:b2,x:b3,start:b7,back:b6,leftshoulder:b4,rightshoulder:b5,dpup:-a1,dpleft:-a0,dpdown:+a1,dpright:+a0,platform:Web
MacOSX05832060,iBuffalo BSGP801,a:b1,b:b0,y:b2,x:b3,start:b7,back:b6,leftshoulder:b4,rightshoulder:b5,dpup:-a1,dpleft:-a0,dpdown:+a1,dpright:+a0,platform:Javascript MacOSX05832060,iBuffalo BSGP801,a:b1,b:b0,y:b2,x:b3,start:b7,back:b6,leftshoulder:b4,rightshoulder:b5,dpup:-a1,dpleft:-a0,dpdown:+a1,dpright:+a0,platform:Web
Linux0e8f3013,HuiJia USB GamePad,a:b2,b:b1,y:b0,x:b3,start:b9,back:b8,leftshoulder:b6,rightshoulder:b7,dpup:-a1,dpleft:-a0,dpdown:+a1,dpright:+a0,platform:Javascript Linux0e8f3013,HuiJia USB GamePad,a:b2,b:b1,y:b0,x:b3,start:b9,back:b8,leftshoulder:b6,rightshoulder:b7,dpup:-a1,dpleft:-a0,dpdown:+a1,dpright:+a0,platform:Web
Windows0e8f3013,HuiJia USB GamePad,a:b2,b:b1,y:b0,x:b3,start:b9,back:b8,leftshoulder:b6,rightshoulder:b7,dpup:-a1,dpleft:-a0,dpdown:+a1,dpright:+a0,platform:Javascript Windows0e8f3013,HuiJia USB GamePad,a:b2,b:b1,y:b0,x:b3,start:b9,back:b8,leftshoulder:b6,rightshoulder:b7,dpup:-a1,dpleft:-a0,dpdown:+a1,dpright:+a0,platform:Web
MacOSX0e8f3013,HuiJia USB GamePad,a:b2,b:b1,y:b0,x:b3,start:b9,back:b8,leftshoulder:b6,rightshoulder:b7,dpup:-a4,dpleft:-a3,dpdown:+a4,dpright:+a3,platform:Javascript MacOSX0e8f3013,HuiJia USB GamePad,a:b2,b:b1,y:b0,x:b3,start:b9,back:b8,leftshoulder:b6,rightshoulder:b7,dpup:-a4,dpleft:-a3,dpdown:+a4,dpright:+a3,platform:Web
Linux046dc216,046d-c216-Logitech Logitech Dual Action,a:b1,b:b2,y:b3,x:b0,start:b9,back:b8,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:-a5,dpleft:-a4,dpdown:+a5,dpright:+a4,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7,platform:Javascript Linux046dc216,046d-c216-Logitech Logitech Dual Action,a:b1,b:b2,y:b3,x:b0,start:b9,back:b8,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:-a5,dpleft:-a4,dpdown:+a5,dpright:+a4,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7,platform:Web
Linux20d6a713,Bensussen Deutsch & Associates Inc.(BDA) NSW Wired controller,a:b1,b:b2,y:b3,x:b0,start:b9,back:b8,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:-a5,dpleft:-a4,dpdown:+a5,dpright:+a4,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7,platform:Javascript Linux20d6a713,Bensussen Deutsch & Associates Inc.(BDA) NSW Wired controller,a:b1,b:b2,y:b3,x:b0,start:b9,back:b8,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:-a5,dpleft:-a4,dpdown:+a5,dpright:+a4,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7,platform:Web
Linux054c05c4,Sony Computer Entertainment Wireless Controller,a:b0,b:b1,y:b2,x:b3,start:b9,back:b8,leftstick:b11,rightstick:b12,leftshoulder:b4,rightshoulder:b5,dpup:-a7,dpleft:-a6,dpdown:+a7,dpright:+a6,leftx:a0,lefty:a1,rightx:a3,righty:a4,lefttrigger:a2,righttrigger:a5,platform:Javascript Linux054c05c4,Sony Computer Entertainment Wireless Controller,a:b0,b:b1,y:b2,x:b3,start:b9,back:b8,leftstick:b11,rightstick:b12,leftshoulder:b4,rightshoulder:b5,dpup:-a7,dpleft:-a6,dpdown:+a7,dpright:+a6,leftx:a0,lefty:a1,rightx:a3,righty:a4,lefttrigger:a2,righttrigger:a5,platform:Web
Linux18d19400,18d1-9400-Google LLC Stadia Controller rev. A,a:b0,b:b1,y:b3,x:b2,start:b7,back:b6,leftstick:b9,rightstick:b10,leftshoulder:b4,rightshoulder:b5,dpup:-a7,dpleft:-a6,dpdown:+a7,dpright:+a6,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a5,righttrigger:a4,platform:Javascript Linux18d19400,18d1-9400-Google LLC Stadia Controller rev. A,a:b0,b:b1,y:b3,x:b2,start:b7,back:b6,leftstick:b9,rightstick:b10,leftshoulder:b4,rightshoulder:b5,dpup:-a7,dpleft:-a6,dpdown:+a7,dpright:+a6,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a5,righttrigger:a4,platform:Web
# UWP # UWP
__UWP_GAMEPAD__,Xbox Controller,a:b2,b:b3,x:b4,y:b5,start:b0,back:b1,leftstick:b12,rightstick:b13,leftshoulder:b10,rightshoulder:b11,dpup:b6,dpdown:b7,dpleft:b8,dpright:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,platform:UWP, __UWP_GAMEPAD__,Xbox Controller,a:b2,b:b3,x:b4,y:b5,start:b0,back:b1,leftstick:b12,rightstick:b13,leftshoulder:b10,rightshoulder:b11,dpup:b6,dpdown:b7,dpleft:b8,dpright:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,platform:UWP,

View File

@ -50,7 +50,7 @@ def make_default_controller_mappings(target, source, env):
"Mac OS X": "#ifdef MACOS_ENABLED", "Mac OS X": "#ifdef MACOS_ENABLED",
"Android": "#if defined(__ANDROID__)", "Android": "#if defined(__ANDROID__)",
"iOS": "#ifdef IOS_ENABLED", "iOS": "#ifdef IOS_ENABLED",
"Javascript": "#ifdef JAVASCRIPT_ENABLED", "Web": "#ifdef WEB_ENABLED",
"UWP": "#ifdef UWP_ENABLED", "UWP": "#ifdef UWP_ENABLED",
} }

View File

@ -28,7 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/ /*************************************************************************/
#ifndef JAVASCRIPT_ENABLED #ifndef WEB_ENABLED
#include "http_client_tcp.h" #include "http_client_tcp.h"
@ -788,4 +788,4 @@ HTTPClientTCP::HTTPClientTCP() {
HTTPClient *(*HTTPClient::_create)() = HTTPClientTCP::_create_func; HTTPClient *(*HTTPClient::_create)() = HTTPClientTCP::_create_func;
#endif // #ifndef JAVASCRIPT_ENABLED #endif // WEB_ENABLED

View File

@ -159,7 +159,7 @@ int OS::get_process_id() const {
} }
void OS::vibrate_handheld(int p_duration_ms) { void OS::vibrate_handheld(int p_duration_ms) {
WARN_PRINT("vibrate_handheld() only works with Android, iOS and HTML5"); WARN_PRINT("vibrate_handheld() only works with Android, iOS and Web");
} }
bool OS::is_stdout_verbose() const { bool OS::is_stdout_verbose() const {

View File

@ -2,7 +2,7 @@ BASEDIR = $(CURDIR)
CLASSES = $(BASEDIR)/classes/ $(BASEDIR)/../modules/ CLASSES = $(BASEDIR)/classes/ $(BASEDIR)/../modules/
OUTPUTDIR = $(BASEDIR)/_build OUTPUTDIR = $(BASEDIR)/_build
TOOLSDIR = $(BASEDIR)/tools TOOLSDIR = $(BASEDIR)/tools
JSDIR = $(BASEDIR)/../platform/javascript JSDIR = $(BASEDIR)/../platform/web
LANGARG ?= en LANGARG ?= en
LANGCMD = -l $(LANGARG) LANGCMD = -l $(LANGARG)

View File

@ -1277,7 +1277,7 @@
</member> </member>
<member name="JavaScript" type="JavaScript" setter="" getter=""> <member name="JavaScript" type="JavaScript" setter="" getter="">
The [JavaScript] singleton. The [JavaScript] singleton.
[b]Note:[/b] Only implemented on HTML5. [b]Note:[/b] Only implemented on the Web platform.
</member> </member>
<member name="Marshalls" type="Marshalls" setter="" getter=""> <member name="Marshalls" type="Marshalls" setter="" getter="">
The [Marshalls] singleton. The [Marshalls] singleton.

View File

@ -760,7 +760,7 @@
<param index="0" name="screen" type="int" default="-1" /> <param index="0" name="screen" type="int" default="-1" />
<description> <description>
Returns the current refresh rate of the specified screen. If [param screen] is [constant SCREEN_OF_MAIN_WINDOW] (the default value), a screen with the main window will be used. Returns the current refresh rate of the specified screen. If [param screen] is [constant SCREEN_OF_MAIN_WINDOW] (the default value), a screen with the main window will be used.
[b]Note:[/b] Returns [code]-1.0[/code] if the DisplayServer fails to find the refresh rate for the specified screen. On HTML5, [method screen_get_refresh_rate] will always return [code]-1.0[/code] as there is no way to retrieve the refresh rate on that platform. [b]Note:[/b] Returns [code]-1.0[/code] if the DisplayServer fails to find the refresh rate for the specified screen. On Web, [method screen_get_refresh_rate] will always return [code]-1.0[/code] as there is no way to retrieve the refresh rate on that platform.
To fallback to a default refresh rate if the method fails, try: To fallback to a default refresh rate if the method fails, try:
[codeblock] [codeblock]
var refresh_rate = DisplayServer.screen_get_refresh_rate() var refresh_rate = DisplayServer.screen_get_refresh_rate()
@ -864,7 +864,7 @@
- [code]name[/code] is voice name. - [code]name[/code] is voice name.
- [code]id[/code] is voice identifier. - [code]id[/code] is voice identifier.
- [code]language[/code] is language code in [code]lang_Variant[/code] format. [code]lang[/code] part is a 2 or 3-letter code based on the ISO-639 standard, in lowercase. And [code]Variant[/code] part is an engine dependent string describing country, region or/and dialect. - [code]language[/code] is language code in [code]lang_Variant[/code] format. [code]lang[/code] part is a 2 or 3-letter code based on the ISO-639 standard, in lowercase. And [code]Variant[/code] part is an engine dependent string describing country, region or/and dialect.
[b]Note:[/b] This method is implemented on Android, iOS, HTML5, Linux, macOS, and Windows. [b]Note:[/b] This method is implemented on Android, iOS, Web, Linux, macOS, and Windows.
</description> </description>
</method> </method>
<method name="tts_get_voices_for_language" qualifiers="const"> <method name="tts_get_voices_for_language" qualifiers="const">
@ -872,35 +872,35 @@
<param index="0" name="language" type="String" /> <param index="0" name="language" type="String" />
<description> <description>
Returns an [PackedStringArray] of voice identifiers for the [param language]. Returns an [PackedStringArray] of voice identifiers for the [param language].
[b]Note:[/b] This method is implemented on Android, iOS, HTML5, Linux, macOS, and Windows. [b]Note:[/b] This method is implemented on Android, iOS, Web, Linux, macOS, and Windows.
</description> </description>
</method> </method>
<method name="tts_is_paused" qualifiers="const"> <method name="tts_is_paused" qualifiers="const">
<return type="bool" /> <return type="bool" />
<description> <description>
Returns [code]true[/code] if the synthesizer is in a paused state. Returns [code]true[/code] if the synthesizer is in a paused state.
[b]Note:[/b] This method is implemented on Android, iOS, HTML5, Linux, macOS, and Windows. [b]Note:[/b] This method is implemented on Android, iOS, Web, Linux, macOS, and Windows.
</description> </description>
</method> </method>
<method name="tts_is_speaking" qualifiers="const"> <method name="tts_is_speaking" qualifiers="const">
<return type="bool" /> <return type="bool" />
<description> <description>
Returns [code]true[/code] if the synthesizer is generating speech, or have utterance waiting in the queue. Returns [code]true[/code] if the synthesizer is generating speech, or have utterance waiting in the queue.
[b]Note:[/b] This method is implemented on Android, iOS, HTML5, Linux, macOS, and Windows. [b]Note:[/b] This method is implemented on Android, iOS, Web, Linux, macOS, and Windows.
</description> </description>
</method> </method>
<method name="tts_pause"> <method name="tts_pause">
<return type="void" /> <return type="void" />
<description> <description>
Puts the synthesizer into a paused state. Puts the synthesizer into a paused state.
[b]Note:[/b] This method is implemented on Android, iOS, HTML5, Linux, macOS, and Windows. [b]Note:[/b] This method is implemented on Android, iOS, Web, Linux, macOS, and Windows.
</description> </description>
</method> </method>
<method name="tts_resume"> <method name="tts_resume">
<return type="void" /> <return type="void" />
<description> <description>
Resumes the synthesizer if it was paused. Resumes the synthesizer if it was paused.
[b]Note:[/b] This method is implemented on Android, iOS, HTML5, Linux, macOS, and Windows. [b]Note:[/b] This method is implemented on Android, iOS, Web, Linux, macOS, and Windows.
</description> </description>
</method> </method>
<method name="tts_set_utterance_callback"> <method name="tts_set_utterance_callback">
@ -912,7 +912,7 @@
- [code]TTS_UTTERANCE_STARTED[/code], [code]TTS_UTTERANCE_ENDED[/code], and [code]TTS_UTTERANCE_CANCELED[/code] callable's method should take one [int] parameter, the utterance id. - [code]TTS_UTTERANCE_STARTED[/code], [code]TTS_UTTERANCE_ENDED[/code], and [code]TTS_UTTERANCE_CANCELED[/code] callable's method should take one [int] parameter, the utterance id.
- [code]TTS_UTTERANCE_BOUNDARY[/code] callable's method should take two [int] parameters, the index of the character and the utterance id. - [code]TTS_UTTERANCE_BOUNDARY[/code] callable's method should take two [int] parameters, the index of the character and the utterance id.
[b]Note:[/b] The granularity of the boundary callbacks is engine dependent. [b]Note:[/b] The granularity of the boundary callbacks is engine dependent.
[b]Note:[/b] This method is implemented on Android, iOS, HTML5, Linux, macOS, and Windows. [b]Note:[/b] This method is implemented on Android, iOS, Web, Linux, macOS, and Windows.
</description> </description>
</method> </method>
<method name="tts_speak"> <method name="tts_speak">
@ -933,14 +933,14 @@
- [param utterance_id] is passed as a parameter to the callback functions. - [param utterance_id] is passed as a parameter to the callback functions.
[b]Note:[/b] On Windows and Linux, utterance [param text] can use SSML markup. SSML support is engine and voice dependent. If the engine does not support SSML, you should strip out all XML markup before calling [method tts_speak]. [b]Note:[/b] On Windows and Linux, utterance [param text] can use SSML markup. SSML support is engine and voice dependent. If the engine does not support SSML, you should strip out all XML markup before calling [method tts_speak].
[b]Note:[/b] The granularity of pitch, rate, and volume is engine and voice dependent. Values may be truncated. [b]Note:[/b] The granularity of pitch, rate, and volume is engine and voice dependent. Values may be truncated.
[b]Note:[/b] This method is implemented on Android, iOS, HTML5, Linux, macOS, and Windows. [b]Note:[/b] This method is implemented on Android, iOS, Web, Linux, macOS, and Windows.
</description> </description>
</method> </method>
<method name="tts_stop"> <method name="tts_stop">
<return type="void" /> <return type="void" />
<description> <description>
Stops synthesis in progress and removes all utterances from the queue. Stops synthesis in progress and removes all utterances from the queue.
[b]Note:[/b] This method is implemented on Android, iOS, HTML5, Linux, macOS, and Windows. [b]Note:[/b] This method is implemented on Android, iOS, Web, Linux, macOS, and Windows.
</description> </description>
</method> </method>
<method name="virtual_keyboard_get_height" qualifiers="const"> <method name="virtual_keyboard_get_height" qualifiers="const">
@ -971,7 +971,7 @@
[param max_length] limits the number of characters that can be entered if different from [code]-1[/code]. [param max_length] limits the number of characters that can be entered if different from [code]-1[/code].
[param cursor_start] can optionally define the current text cursor position if [param cursor_end] is not set. [param cursor_start] can optionally define the current text cursor position if [param cursor_end] is not set.
[param cursor_start] and [param cursor_end] can optionally define the current text selection. [param cursor_start] and [param cursor_end] can optionally define the current text selection.
[b]Note:[/b] This method is implemented on Android, iOS and HTML5. [b]Note:[/b] This method is implemented on Android, iOS and Web.
</description> </description>
</method> </method>
<method name="warp_mouse"> <method name="warp_mouse">
@ -1396,7 +1396,7 @@
</constant> </constant>
<constant name="KEYBOARD_TYPE_PASSWORD" value="6" enum="VirtualKeyboardType"> <constant name="KEYBOARD_TYPE_PASSWORD" value="6" enum="VirtualKeyboardType">
Virtual keyboard for entering a password. On most platforms, this should disable autocomplete and autocapitalization. Virtual keyboard for entering a password. On most platforms, this should disable autocomplete and autocapitalization.
[b]Note:[/b] This is not supported on HTML5. Instead, this behaves identically to [constant KEYBOARD_TYPE_DEFAULT]. [b]Note:[/b] This is not supported on Web. Instead, this behaves identically to [constant KEYBOARD_TYPE_DEFAULT].
</constant> </constant>
<constant name="KEYBOARD_TYPE_URL" value="7" enum="VirtualKeyboardType"> <constant name="KEYBOARD_TYPE_URL" value="7" enum="VirtualKeyboardType">
Virtual keyboard with additional keys to assist with typing URLs. Virtual keyboard with additional keys to assist with typing URLs.

View File

@ -55,7 +55,7 @@
<members> <members>
<member name="access" type="int" setter="set_access" getter="get_access" enum="FileDialog.Access" default="0"> <member name="access" type="int" setter="set_access" getter="get_access" enum="FileDialog.Access" default="0">
The file system access scope. See enum [code]Access[/code] constants. The file system access scope. See enum [code]Access[/code] constants.
[b]Warning:[/b] Currently, in sandboxed environments such as HTML5 builds or sandboxed macOS apps, FileDialog cannot access the host file system. See [url=https://github.com/godotengine/godot-proposals/issues/1123]godot-proposals#1123[/url]. [b]Warning:[/b] Currently, in sandboxed environments such as Web builds or sandboxed macOS apps, FileDialog cannot access the host file system. See [url=https://github.com/godotengine/godot-proposals/issues/1123]godot-proposals#1123[/url].
</member> </member>
<member name="current_dir" type="String" setter="set_current_dir" getter="get_current_dir"> <member name="current_dir" type="String" setter="set_current_dir" getter="get_current_dir">
The current working directory of the file dialog. The current working directory of the file dialog.

View File

@ -11,7 +11,7 @@
For more information on HTTP, see https://developer.mozilla.org/en-US/docs/Web/HTTP (or read RFC 2616 to get it straight from the source: https://tools.ietf.org/html/rfc2616). For more information on HTTP, see https://developer.mozilla.org/en-US/docs/Web/HTTP (or read RFC 2616 to get it straight from the source: https://tools.ietf.org/html/rfc2616).
[b]Note:[/b] When exporting to Android, make sure to enable the [code]INTERNET[/code] permission in the Android export preset before exporting the project or using one-click deploy. Otherwise, network communication of any kind will be blocked by Android. [b]Note:[/b] When exporting to Android, make sure to enable the [code]INTERNET[/code] permission in the Android export preset before exporting the project or using one-click deploy. Otherwise, network communication of any kind will be blocked by Android.
[b]Note:[/b] It's recommended to use transport encryption (SSL/TLS) and to avoid sending sensitive information (such as login credentials) in HTTP GET URL parameters. Consider using HTTP POST requests or HTTP headers for such information instead. [b]Note:[/b] It's recommended to use transport encryption (SSL/TLS) and to avoid sending sensitive information (such as login credentials) in HTTP GET URL parameters. Consider using HTTP POST requests or HTTP headers for such information instead.
[b]Note:[/b] When performing HTTP requests from a project exported to HTML5, keep in mind the remote server may not allow requests from foreign origins due to [url=https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS]CORS[/url]. If you host the server in question, you should modify its backend to allow requests from foreign origins by adding the [code]Access-Control-Allow-Origin: *[/code] HTTP header. [b]Note:[/b] When performing HTTP requests from a project exported to Web, keep in mind the remote server may not allow requests from foreign origins due to [url=https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS]CORS[/url]. If you host the server in question, you should modify its backend to allow requests from foreign origins by adding the [code]Access-Control-Allow-Origin: *[/code] HTTP header.
[b]Note:[/b] SSL/TLS support is currently limited to TLS 1.0, TLS 1.1, and TLS 1.2. Attempting to connect to a TLS 1.3-only server will return an error. [b]Note:[/b] SSL/TLS support is currently limited to TLS 1.0, TLS 1.1, and TLS 1.2. Attempting to connect to a TLS 1.3-only server will return an error.
[b]Warning:[/b] SSL/TLS certificate revocation and certificate pinning are currently not supported. Revoked certificates are accepted as long as they are otherwise valid. If this is a concern, you may want to use automatically managed certificates with a short validity period. [b]Warning:[/b] SSL/TLS certificate revocation and certificate pinning are currently not supported. Revoked certificates are accepted as long as they are otherwise valid. If this is a concern, you may want to use automatically managed certificates with a short validity period.
</description> </description>

View File

@ -355,7 +355,7 @@
<param index="0" name="duration_ms" type="int" default="500" /> <param index="0" name="duration_ms" type="int" default="500" />
<description> <description>
Vibrate handheld devices. Vibrate handheld devices.
[b]Note:[/b] This method is implemented on Android, iOS, and HTML5. [b]Note:[/b] This method is implemented on Android, iOS, and Web.
[b]Note:[/b] For Android, it requires enabling the [code]VIBRATE[/code] permission in the export preset. [b]Note:[/b] For Android, it requires enabling the [code]VIBRATE[/code] permission in the export preset.
[b]Note:[/b] For iOS, specifying the duration is supported in iOS 13 and later. [b]Note:[/b] For iOS, specifying the duration is supported in iOS 13 and later.
[b]Note:[/b] Some web browsers such as Safari and Firefox for Android do not support this method. [b]Note:[/b] Some web browsers such as Safari and Firefox for Android do not support this method.

View File

@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="JavaScript" inherits="Object" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd"> <class name="JavaScript" inherits="Object" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description> <brief_description>
Singleton that connects the engine with the browser's JavaScript context in HTML5 export. Singleton that connects the engine with the browser's JavaScript context in Web export.
</brief_description> </brief_description>
<description> <description>
The JavaScript singleton is implemented only in the HTML5 export. It's used to access the browser's JavaScript context. This allows interaction with embedding pages or calling third-party JavaScript APIs. The JavaScript singleton is implemented only in the Web export. It's used to access the browser's JavaScript context. This allows interaction with embedding pages or calling third-party JavaScript APIs.
[b]Note:[/b] This singleton can be disabled at build-time to improve security. By default, the JavaScript singleton is enabled. Official export templates also have the JavaScript singleton enabled. See [url=$DOCS_URL/development/compiling/compiling_for_web.html]Compiling for the Web[/url] in the documentation for more information. [b]Note:[/b] This singleton can be disabled at build-time to improve security. By default, the JavaScript singleton is enabled. Official export templates also have the JavaScript singleton enabled. See [url=$DOCS_URL/development/compiling/compiling_for_web.html]Compiling for the Web[/url] in the documentation for more information.
</description> </description>
<tutorials> <tutorials>

View File

@ -31,7 +31,7 @@
# [0, 9, [JavaScriptObject:1180]] # [0, 9, [JavaScriptObject:1180]]
print(args) print(args)
[/codeblock] [/codeblock]
[b]Note:[/b] Only available in the HTML5 platform. [b]Note:[/b] Only available in the Web platform.
</description> </description>
<tutorials> <tutorials>
</tutorials> </tutorials>

View File

@ -379,7 +379,7 @@
</constant> </constant>
<constant name="KEYBOARD_TYPE_PASSWORD" value="6" enum="VirtualKeyboardType"> <constant name="KEYBOARD_TYPE_PASSWORD" value="6" enum="VirtualKeyboardType">
Virtual keyboard for entering a password. On most platforms, this should disable autocomplete and autocapitalization. Virtual keyboard for entering a password. On most platforms, this should disable autocomplete and autocapitalization.
[b]Note:[/b] This is not supported on HTML5. Instead, this behaves identically to [constant KEYBOARD_TYPE_DEFAULT]. [b]Note:[/b] This is not supported on Web. Instead, this behaves identically to [constant KEYBOARD_TYPE_DEFAULT].
</constant> </constant>
<constant name="KEYBOARD_TYPE_URL" value="7" enum="VirtualKeyboardType"> <constant name="KEYBOARD_TYPE_URL" value="7" enum="VirtualKeyboardType">
Virtual keyboard with additional keys to assist with typing URLs. Virtual keyboard with additional keys to assist with typing URLs.

View File

@ -18,7 +18,7 @@
<return type="void" /> <return type="void" />
<param index="0" name="on_thread" type="bool" default="true" /> <param index="0" name="on_thread" type="bool" default="true" />
<description> <description>
Bakes the [NavigationMesh]. If [param on_thread] is set to [code]true[/code] (default), the baking is done on a separate thread. Baking on separate thread is useful because navigation baking is not a cheap operation. When it is completed, it automatically sets the new [NavigationMesh]. Please note that baking on separate thread may be very slow if geometry is parsed from meshes as async access to each mesh involves heavy synchronization. Also, please note that baking on a separate thread is automatically disabled on operating systems that cannot use threads (such as HTML5 with threads disabled). Bakes the [NavigationMesh]. If [param on_thread] is set to [code]true[/code] (default), the baking is done on a separate thread. Baking on separate thread is useful because navigation baking is not a cheap operation. When it is completed, it automatically sets the new [NavigationMesh]. Please note that baking on separate thread may be very slow if geometry is parsed from meshes as async access to each mesh involves heavy synchronization. Also, please note that baking on a separate thread is automatically disabled on operating systems that cannot use threads (such as Web with threads disabled).
</description> </description>
</method> </method>
<method name="get_navigation_layer_value" qualifiers="const"> <method name="get_navigation_layer_value" qualifiers="const">

View File

@ -297,7 +297,7 @@
On BSD-based operating systems, this is [code]"FreeBSD"[/code], [code]"NetBSD"[/code], [code]"OpenBSD"[/code], or [code]"BSD"[/code] as a fallback. On BSD-based operating systems, this is [code]"FreeBSD"[/code], [code]"NetBSD"[/code], [code]"OpenBSD"[/code], or [code]"BSD"[/code] as a fallback.
On Android, this is [code]"Android"[/code]. On Android, this is [code]"Android"[/code].
On iOS, this is [code]"iOS"[/code]. On iOS, this is [code]"iOS"[/code].
On the web, this is [code]"HTML5"[/code]. On the web, this is [code]"Web"[/code].
[b]Note:[/b] Custom builds of the engine may support additional platforms, such as consoles, yielding other return values. [b]Note:[/b] Custom builds of the engine may support additional platforms, such as consoles, yielding other return values.
[codeblocks] [codeblocks]
[gdscript] [gdscript]
@ -312,7 +312,7 @@
print("Android") print("Android")
"iOS": "iOS":
print("iOS") print("iOS")
"HTML5": "Web":
print("Web") print("Web")
[/gdscript] [/gdscript]
[csharp] [csharp]
@ -338,7 +338,7 @@
case "iOS": case "iOS":
GD.Print("iOS"); GD.Print("iOS");
break; break;
case "HTML5": case "Web":
GD.Print("Web"); GD.Print("Web");
break; break;
} }
@ -363,7 +363,7 @@
<return type="String" /> <return type="String" />
<description> <description>
Returns the name of the CPU model on the host machine (e.g. "Intel(R) Core(TM) i7-6700K CPU @ 4.00GHz"). Returns the name of the CPU model on the host machine (e.g. "Intel(R) Core(TM) i7-6700K CPU @ 4.00GHz").
[b]Note:[/b] This method is only implemented on Windows, macOS, Linux and iOS. On Android, HTML5 and UWP, [method get_processor_name] returns an empty string. [b]Note:[/b] This method is only implemented on Windows, macOS, Linux and iOS. On Android, Web and UWP, [method get_processor_name] returns an empty string.
</description> </description>
</method> </method>
<method name="get_restart_on_exit_arguments" qualifiers="const"> <method name="get_restart_on_exit_arguments" qualifiers="const">
@ -423,7 +423,7 @@
<description> <description>
Returns a string that is unique to the device. Returns a string that is unique to the device.
[b]Note:[/b] This string may change without notice if the user reinstalls/upgrades their operating system or changes their hardware. This means it should generally not be used to encrypt persistent data as the data saved before an unexpected ID change would become inaccessible. The returned string may also be falsified using external programs, so do not rely on the string returned by [method get_unique_id] for security purposes. [b]Note:[/b] This string may change without notice if the user reinstalls/upgrades their operating system or changes their hardware. This means it should generally not be used to encrypt persistent data as the data saved before an unexpected ID change would become inaccessible. The returned string may also be falsified using external programs, so do not rely on the string returned by [method get_unique_id] for security purposes.
[b]Note:[/b] Returns an empty string on HTML5 and UWP, as this method isn't implemented on those platforms yet. [b]Note:[/b] Returns an empty string on Web and UWP, as this method isn't implemented on those platforms yet.
</description> </description>
</method> </method>
<method name="get_user_data_dir" qualifiers="const"> <method name="get_user_data_dir" qualifiers="const">
@ -494,7 +494,7 @@
<method name="is_userfs_persistent" qualifiers="const"> <method name="is_userfs_persistent" qualifiers="const">
<return type="bool" /> <return type="bool" />
<description> <description>
If [code]true[/code], the [code]user://[/code] file system is persistent, so that its state is the same after a player quits and starts the game again. Relevant to the HTML5 platform, where this persistence may be unavailable. If [code]true[/code], the [code]user://[/code] file system is persistent, so that its state is the same after a player quits and starts the game again. Relevant to the Web platform, where this persistence may be unavailable.
</description> </description>
</method> </method>
<method name="kill"> <method name="kill">
@ -610,7 +610,7 @@
- [code]OS.shell_open("https://godotengine.org")[/code] opens the default web browser on the official Godot website. - [code]OS.shell_open("https://godotengine.org")[/code] opens the default web browser on the official Godot website.
- [code]OS.shell_open("mailto:example@example.com")[/code] opens the default email client with the "To" field set to [code]example@example.com[/code]. See [url=https://datatracker.ietf.org/doc/html/rfc2368]RFC 2368 - The [code]mailto[/code] URL scheme[/url] for a list of fields that can be added. - [code]OS.shell_open("mailto:example@example.com")[/code] opens the default email client with the "To" field set to [code]example@example.com[/code]. See [url=https://datatracker.ietf.org/doc/html/rfc2368]RFC 2368 - The [code]mailto[/code] URL scheme[/url] for a list of fields that can be added.
Use [method ProjectSettings.globalize_path] to convert a [code]res://[/code] or [code]user://[/code] path into a system path for use with this method. Use [method ProjectSettings.globalize_path] to convert a [code]res://[/code] or [code]user://[/code] path into a system path for use with this method.
[b]Note:[/b] This method is implemented on Android, iOS, HTML5, Linux, macOS and Windows. [b]Note:[/b] This method is implemented on Android, iOS, Web, Linux, macOS and Windows.
</description> </description>
</method> </method>
</methods> </methods>
@ -627,7 +627,7 @@
The Vulkan rendering backend. It requires Vulkan 1.0 support and automatically uses features from Vulkan 1.1 and 1.2 if available. The Vulkan rendering backend. It requires Vulkan 1.0 support and automatically uses features from Vulkan 1.1 and 1.2 if available.
</constant> </constant>
<constant name="VIDEO_DRIVER_OPENGL_3" value="1" enum="VideoDriver"> <constant name="VIDEO_DRIVER_OPENGL_3" value="1" enum="VideoDriver">
The OpenGL 3 rendering backend. It uses OpenGL 3.3 Core Profile on desktop platforms, OpenGL ES 3.0 on mobile devices, and WebGL 2.0 on HTML5. The OpenGL 3 rendering backend. It uses OpenGL 3.3 Core Profile on desktop platforms, OpenGL ES 3.0 on mobile devices, and WebGL 2.0 on Web.
</constant> </constant>
<constant name="DAY_SUNDAY" value="0" enum="Weekday"> <constant name="DAY_SUNDAY" value="0" enum="Weekday">
Sunday. Sunday.

View File

@ -528,7 +528,7 @@
Position offset for tooltips, relative to the mouse cursor's hotspot. Position offset for tooltips, relative to the mouse cursor's hotspot.
</member> </member>
<member name="display/window/dpi/allow_hidpi" type="bool" setter="" getter="" default="true"> <member name="display/window/dpi/allow_hidpi" type="bool" setter="" getter="" default="true">
If [code]true[/code], allows HiDPI display on Windows, macOS, Android, iOS and HTML5. If [code]false[/code], the platform's low-DPI fallback will be used on HiDPI displays, which causes the window to be displayed in a blurry or pixelated manner (and can cause various window management bugs). Therefore, it is recommended to make your project scale to [url=$DOCS_URL/tutorials/viewports/multiple_resolutions.html]multiple resolutions[/url] instead of disabling this setting. If [code]true[/code], allows HiDPI display on Windows, macOS, Android, iOS and Web. If [code]false[/code], the platform's low-DPI fallback will be used on HiDPI displays, which causes the window to be displayed in a blurry or pixelated manner (and can cause various window management bugs). Therefore, it is recommended to make your project scale to [url=$DOCS_URL/tutorials/viewports/multiple_resolutions.html]multiple resolutions[/url] instead of disabling this setting.
[b]Note:[/b] This setting has no effect on Linux as DPI-awareness fallbacks are not supported there. [b]Note:[/b] This setting has no effect on Linux as DPI-awareness fallbacks are not supported there.
</member> </member>
<member name="display/window/energy_saving/keep_screen_on" type="bool" setter="" getter="" default="true"> <member name="display/window/energy_saving/keep_screen_on" type="bool" setter="" getter="" default="true">
@ -546,16 +546,16 @@
</member> </member>
<member name="display/window/size/always_on_top" type="bool" setter="" getter="" default="false"> <member name="display/window/size/always_on_top" type="bool" setter="" getter="" default="false">
Forces the main window to be always on top. Forces the main window to be always on top.
[b]Note:[/b] This setting is ignored on iOS, Android, and HTML5. [b]Note:[/b] This setting is ignored on iOS, Android, and Web.
</member> </member>
<member name="display/window/size/borderless" type="bool" setter="" getter="" default="false"> <member name="display/window/size/borderless" type="bool" setter="" getter="" default="false">
Forces the main window to be borderless. Forces the main window to be borderless.
[b]Note:[/b] This setting is ignored on iOS, Android, and HTML5. [b]Note:[/b] This setting is ignored on iOS, Android, and Web.
</member> </member>
<member name="display/window/size/fullscreen" type="bool" setter="" getter="" default="false"> <member name="display/window/size/fullscreen" type="bool" setter="" getter="" default="false">
Sets the main window to full screen when the project starts. Note that this is not [i]exclusive[/i] fullscreen. On Windows and Linux, a borderless window is used to emulate fullscreen. On macOS, a new desktop is used to display the running project. Sets the main window to full screen when the project starts. Note that this is not [i]exclusive[/i] fullscreen. On Windows and Linux, a borderless window is used to emulate fullscreen. On macOS, a new desktop is used to display the running project.
Regardless of the platform, enabling fullscreen will change the window size to match the monitor's size. Therefore, make sure your project supports [url=$DOCS_URL/tutorials/rendering/multiple_resolutions.html]multiple resolutions[/url] when enabling fullscreen mode. Regardless of the platform, enabling fullscreen will change the window size to match the monitor's size. Therefore, make sure your project supports [url=$DOCS_URL/tutorials/rendering/multiple_resolutions.html]multiple resolutions[/url] when enabling fullscreen mode.
[b]Note:[/b] This setting is ignored on iOS, Android, and HTML5. [b]Note:[/b] This setting is ignored on iOS, Android, and Web.
</member> </member>
<member name="display/window/size/resizable" type="bool" setter="" getter="" default="true"> <member name="display/window/size/resizable" type="bool" setter="" getter="" default="true">
Allows the window to be resizable by default. Allows the window to be resizable by default.
@ -569,11 +569,11 @@
</member> </member>
<member name="display/window/size/window_height_override" type="int" setter="" getter="" default="0"> <member name="display/window/size/window_height_override" type="int" setter="" getter="" default="0">
On desktop platforms, overrides the game's initial window height. See also [member display/window/size/window_width_override], [member display/window/size/viewport_width] and [member display/window/size/viewport_height]. On desktop platforms, overrides the game's initial window height. See also [member display/window/size/window_width_override], [member display/window/size/viewport_width] and [member display/window/size/viewport_height].
[b]Note:[/b] By default, or when set to [code]0[/code], the initial window height is the [member display/window/size/viewport_height]. This setting is ignored on iOS, Android, and HTML5. [b]Note:[/b] By default, or when set to [code]0[/code], the initial window height is the [member display/window/size/viewport_height]. This setting is ignored on iOS, Android, and Web.
</member> </member>
<member name="display/window/size/window_width_override" type="int" setter="" getter="" default="0"> <member name="display/window/size/window_width_override" type="int" setter="" getter="" default="0">
On desktop platforms, overrides the game's initial window width. See also [member display/window/size/window_height_override], [member display/window/size/viewport_width] and [member display/window/size/viewport_height]. On desktop platforms, overrides the game's initial window width. See also [member display/window/size/window_height_override], [member display/window/size/viewport_width] and [member display/window/size/viewport_height].
[b]Note:[/b] By default, or when set to [code]0[/code], the initial window width is the viewport [member display/window/size/viewport_width]. This setting is ignored on iOS, Android, and HTML5. [b]Note:[/b] By default, or when set to [code]0[/code], the initial window width is the viewport [member display/window/size/viewport_width]. This setting is ignored on iOS, Android, and Web.
</member> </member>
<member name="display/window/vsync/vsync_mode" type="int" setter="" getter="" default="1"> <member name="display/window/vsync/vsync_mode" type="int" setter="" getter="" default="1">
Sets the V-Sync mode for the main game window. Sets the V-Sync mode for the main game window.

View File

@ -29,7 +29,7 @@
<param index="3" name="valid_certificate" type="X509Certificate" default="null" /> <param index="3" name="valid_certificate" type="X509Certificate" default="null" />
<description> <description>
Connects to a peer using an underlying [StreamPeer] [param stream]. If [param validate_certs] is [code]true[/code], [StreamPeerSSL] will validate that the certificate presented by the peer matches the [param for_hostname]. Connects to a peer using an underlying [StreamPeer] [param stream]. If [param validate_certs] is [code]true[/code], [StreamPeerSSL] will validate that the certificate presented by the peer matches the [param for_hostname].
[b]Note:[/b] Specifying a custom [param valid_certificate] is not supported in HTML5 exports due to browsers restrictions. [b]Note:[/b] Specifying a custom [param valid_certificate] is not supported in Web exports due to browsers restrictions.
</description> </description>
</method> </method>
<method name="disconnect_from_stream"> <method name="disconnect_from_stream">

View File

@ -7,7 +7,7 @@
Control node for playing video streams using [VideoStream] resources. Control node for playing video streams using [VideoStream] resources.
Supported video formats are [url=https://www.theora.org/]Ogg Theora[/url] ([code].ogv[/code], [VideoStreamTheora]) and any format exposed via a GDExtension plugin. Supported video formats are [url=https://www.theora.org/]Ogg Theora[/url] ([code].ogv[/code], [VideoStreamTheora]) and any format exposed via a GDExtension plugin.
[b]Note:[/b] Due to a bug, VideoStreamPlayer does not support localization remapping yet. [b]Note:[/b] Due to a bug, VideoStreamPlayer does not support localization remapping yet.
[b]Warning:[/b] On HTML5, video playback [i]will[/i] perform poorly due to missing architecture-specific assembly optimizations. [b]Warning:[/b] On Web, video playback [i]will[/i] perform poorly due to missing architecture-specific assembly optimizations.
</description> </description>
<tutorials> <tutorials>
</tutorials> </tutorials>

View File

@ -1022,7 +1022,7 @@ void RasterizerCanvasGLES3::_bind_instance_data_buffer(uint32_t p_max_index) {
} }
glBindBufferBase(GL_UNIFORM_BUFFER, INSTANCE_UNIFORM_LOCATION, state.canvas_instance_data_buffers[state.current_buffer]); glBindBufferBase(GL_UNIFORM_BUFFER, INSTANCE_UNIFORM_LOCATION, state.canvas_instance_data_buffers[state.current_buffer]);
#ifdef JAVASCRIPT_ENABLED #ifdef WEB_ENABLED
//WebGL 2.0 does not support mapping buffers, so use slow glBufferData instead //WebGL 2.0 does not support mapping buffers, so use slow glBufferData instead
glBufferData(GL_UNIFORM_BUFFER, sizeof(InstanceData) * p_max_index, state.instance_data_array, GL_DYNAMIC_DRAW); glBufferData(GL_UNIFORM_BUFFER, sizeof(InstanceData) * p_max_index, state.instance_data_array, GL_DYNAMIC_DRAW);
#else #else

View File

@ -69,7 +69,7 @@
#endif #endif
#endif #endif
#if !defined(IOS_ENABLED) && !defined(JAVASCRIPT_ENABLED) #if !defined(IOS_ENABLED) && !defined(WEB_ENABLED)
// We include EGL below to get debug callback on GLES2 platforms, // We include EGL below to get debug callback on GLES2 platforms,
// but EGL is not available on iOS. // but EGL is not available on iOS.
#define CAN_DEBUG #define CAN_DEBUG

View File

@ -30,7 +30,7 @@ if env["builtin_libpng"]:
thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources] thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]
env_png.Prepend(CPPPATH=[thirdparty_dir]) env_png.Prepend(CPPPATH=[thirdparty_dir])
# Needed for drivers includes and in platform/javascript # Needed for drivers includes and in platform/web.
env.Prepend(CPPPATH=[thirdparty_dir]) env.Prepend(CPPPATH=[thirdparty_dir])
# Currently .ASM filter_neon.S does not compile on NT. # Currently .ASM filter_neon.S does not compile on NT.

View File

@ -50,7 +50,7 @@
#include <netinet/in.h> #include <netinet/in.h>
#include <sys/socket.h> #include <sys/socket.h>
#ifdef JAVASCRIPT_ENABLED #ifdef WEB_ENABLED
#include <arpa/inet.h> #include <arpa/inet.h>
#endif #endif

View File

@ -92,7 +92,7 @@ static void _setup_clock() {
_clock_start = mach_absolute_time() * _clock_scale; _clock_start = mach_absolute_time() * _clock_scale;
} }
#else #else
#if defined(CLOCK_MONOTONIC_RAW) && !defined(JAVASCRIPT_ENABLED) // This is a better clock on Linux. #if defined(CLOCK_MONOTONIC_RAW) && !defined(WEB_ENABLED) // This is a better clock on Linux.
#define GODOT_CLOCK CLOCK_MONOTONIC_RAW #define GODOT_CLOCK CLOCK_MONOTONIC_RAW
#else #else
#define GODOT_CLOCK CLOCK_MONOTONIC #define GODOT_CLOCK CLOCK_MONOTONIC
@ -292,7 +292,7 @@ uint64_t OS_Unix::get_ticks_usec() const {
Error OS_Unix::execute(const String &p_path, const List<String> &p_arguments, String *r_pipe, int *r_exitcode, bool read_stderr, Mutex *p_pipe_mutex, bool p_open_console) { Error OS_Unix::execute(const String &p_path, const List<String> &p_arguments, String *r_pipe, int *r_exitcode, bool read_stderr, Mutex *p_pipe_mutex, bool p_open_console) {
#ifdef __EMSCRIPTEN__ #ifdef __EMSCRIPTEN__
// Don't compile this code at all to avoid undefined references. // Don't compile this code at all to avoid undefined references.
// Actual virtual call goes to OS_JavaScript. // Actual virtual call goes to OS_Web.
ERR_FAIL_V(ERR_BUG); ERR_FAIL_V(ERR_BUG);
#else #else
if (r_pipe) { if (r_pipe) {
@ -366,7 +366,7 @@ Error OS_Unix::execute(const String &p_path, const List<String> &p_arguments, St
Error OS_Unix::create_process(const String &p_path, const List<String> &p_arguments, ProcessID *r_child_id, bool p_open_console) { Error OS_Unix::create_process(const String &p_path, const List<String> &p_arguments, ProcessID *r_child_id, bool p_open_console) {
#ifdef __EMSCRIPTEN__ #ifdef __EMSCRIPTEN__
// Don't compile this code at all to avoid undefined references. // Don't compile this code at all to avoid undefined references.
// Actual virtual call goes to OS_JavaScript. // Actual virtual call goes to OS_Web.
ERR_FAIL_V(ERR_BUG); ERR_FAIL_V(ERR_BUG);
#else #else
pid_t pid = fork(); pid_t pid = fork();

View File

@ -201,7 +201,7 @@ Dictionary DebugAdapterParser::req_launch(const Dictionary &p_params) const {
} }
} else if (platform_string == "web") { } else if (platform_string == "web") {
for (int i = 0; i < EditorExport::get_singleton()->get_export_platform_count(); i++) { for (int i = 0; i < EditorExport::get_singleton()->get_export_platform_count(); i++) {
if (EditorExport::get_singleton()->get_export_platform(i)->get_name() == "HTML5") { if (EditorExport::get_singleton()->get_export_platform(i)->get_name() == "Web") {
idx = i; idx = i;
break; break;
} }

View File

@ -1592,7 +1592,7 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) {
/////// ///////
bool AssetLibraryEditorPlugin::is_available() { bool AssetLibraryEditorPlugin::is_available() {
#ifdef JAVASCRIPT_ENABLED #ifdef WEB_ENABLED
// Asset Library can't work on Web editor for now as most assets are sourced // Asset Library can't work on Web editor for now as most assets are sourced
// directly from GitHub which does not set CORS. // directly from GitHub which does not set CORS.
return false; return false;

View File

@ -2106,7 +2106,7 @@ void ProjectManager::_confirm_update_settings() {
void ProjectManager::_open_selected_projects() { void ProjectManager::_open_selected_projects() {
// Show loading text to tell the user that the project manager is busy loading. // Show loading text to tell the user that the project manager is busy loading.
// This is especially important for the HTML5 project manager. // This is especially important for the Web project manager.
loading_label->show(); loading_label->show();
const HashSet<String> &selected_list = _project_list->get_selected_project_keys(); const HashSet<String> &selected_list = _project_list->get_selected_project_keys();

View File

@ -1903,7 +1903,7 @@ Error Main::setup2(Thread::ID p_main_tid_override) {
MAIN_PRINT("Main: Setup Logo"); MAIN_PRINT("Main: Setup Logo");
#if defined(JAVASCRIPT_ENABLED) || defined(ANDROID_ENABLED) #if defined(WEB_ENABLED) || defined(ANDROID_ENABLED)
bool show_logo = false; bool show_logo = false;
#else #else
bool show_logo = true; bool show_logo = true;

View File

@ -2,7 +2,7 @@ def can_build(env, platform):
# Thirdparty dependency OpenImage Denoise includes oneDNN library # Thirdparty dependency OpenImage Denoise includes oneDNN library
# and the version we use only supports x86_64. # and the version we use only supports x86_64.
# It's also only relevant for tools build and desktop platforms, # It's also only relevant for tools build and desktop platforms,
# as doing lightmap generation and denoising on Android or HTML5 # as doing lightmap generation and denoising on Android or Web
# would be a bit far-fetched. # would be a bit far-fetched.
desktop_platforms = ["linuxbsd", "macos", "windows"] desktop_platforms = ["linuxbsd", "macos", "windows"]
return env["tools"] and platform in desktop_platforms and env["arch"] == "x86_64" return env["tools"] and platform in desktop_platforms and env["arch"] == "x86_64"

View File

@ -99,7 +99,7 @@ if env["builtin_freetype"]:
sfnt = thirdparty_dir + "src/sfnt/sfnt.c" sfnt = thirdparty_dir + "src/sfnt/sfnt.c"
# Must be done after all CPPDEFINES are being set so we can copy them. # Must be done after all CPPDEFINES are being set so we can copy them.
if env["platform"] == "javascript": if env["platform"] == "web":
# Forcibly undefine this macro so SIMD is not used in this file, # Forcibly undefine this macro so SIMD is not used in this file,
# since currently unsupported in WASM # since currently unsupported in WASM
tmp_env = env_freetype.Clone() tmp_env = env_freetype.Clone()

View File

@ -16,7 +16,7 @@ def module_supports_tools_on(platform):
def configure(env, env_mono): def configure(env, env_mono):
# is_android = env["platform"] == "android" # is_android = env["platform"] == "android"
# is_javascript = env["platform"] == "javascript" # is_web = env["platform"] == "web"
# is_ios = env["platform"] == "ios" # is_ios = env["platform"] == "ios"
# is_ios_sim = is_ios and env["arch"] in ["x86_32", "x86_64"] # is_ios_sim = is_ios and env["arch"] in ["x86_32", "x86_64"]

View File

@ -1,4 +1,4 @@
# Prior to .NET Core, we supported these: ["windows", "macos", "linuxbsd", "android", "haiku", "javascript", "ios"] # Prior to .NET Core, we supported these: ["windows", "macos", "linuxbsd", "android", "haiku", "web", "ios"]
# Eventually support for each them should be added back (except Haiku if not supported by .NET Core) # Eventually support for each them should be added back (except Haiku if not supported by .NET Core)
supported_platforms = ["windows", "macos", "linuxbsd"] supported_platforms = ["windows", "macos", "linuxbsd"]
@ -10,8 +10,8 @@ def can_build(env, platform):
def get_opts(platform): def get_opts(platform):
from SCons.Variables import BoolVariable, PathVariable from SCons.Variables import BoolVariable, PathVariable
default_mono_static = platform in ["ios", "javascript"] default_mono_static = platform in ["ios", "web"]
default_mono_bundles_zlib = platform in ["javascript"] default_mono_bundles_zlib = platform in ["web"]
return [ return [
PathVariable( PathVariable(

View File

@ -81,7 +81,7 @@
<GodotPlatformConstants Condition=" '$(GodotTargetPlatform)' == 'haiku' ">GODOT_HAIKU;GODOT_PC</GodotPlatformConstants> <GodotPlatformConstants Condition=" '$(GodotTargetPlatform)' == 'haiku' ">GODOT_HAIKU;GODOT_PC</GodotPlatformConstants>
<GodotPlatformConstants Condition=" '$(GodotTargetPlatform)' == 'android' ">GODOT_ANDROID;GODOT_MOBILE</GodotPlatformConstants> <GodotPlatformConstants Condition=" '$(GodotTargetPlatform)' == 'android' ">GODOT_ANDROID;GODOT_MOBILE</GodotPlatformConstants>
<GodotPlatformConstants Condition=" '$(GodotTargetPlatform)' == 'ios' ">GODOT_IPHONE;GODOT_IOS;GODOT_MOBILE</GodotPlatformConstants> <GodotPlatformConstants Condition=" '$(GodotTargetPlatform)' == 'ios' ">GODOT_IPHONE;GODOT_IOS;GODOT_MOBILE</GodotPlatformConstants>
<GodotPlatformConstants Condition=" '$(GodotTargetPlatform)' == 'javascript' ">GODOT_JAVASCRIPT;GODOT_HTML5;GODOT_WASM;GODOT_WEB</GodotPlatformConstants> <GodotPlatformConstants Condition=" '$(GodotTargetPlatform)' == 'web' ">GODOT_JAVASCRIPT;GODOT_HTML5;GODOT_WASM;GODOT_WEB</GodotPlatformConstants>
<GodotDefineConstants>$(GodotDefineConstants);$(GodotPlatformConstants)</GodotDefineConstants> <GodotDefineConstants>$(GodotDefineConstants);$(GodotPlatformConstants)</GodotDefineConstants>
</PropertyGroup> </PropertyGroup>

View File

@ -30,7 +30,7 @@ namespace GodotTools.Utils
public const string Haiku = "Haiku"; public const string Haiku = "Haiku";
public const string Android = "Android"; public const string Android = "Android";
public const string iOS = "iOS"; public const string iOS = "iOS";
public const string HTML5 = "HTML5"; public const string Web = "Web";
} }
/// <summary> /// <summary>
@ -45,7 +45,7 @@ namespace GodotTools.Utils
public const string Haiku = "haiku"; public const string Haiku = "haiku";
public const string Android = "android"; public const string Android = "android";
public const string iOS = "ios"; public const string iOS = "ios";
public const string HTML5 = "javascript"; public const string Web = "web";
} }
/// <summary> /// <summary>
@ -77,7 +77,7 @@ namespace GodotTools.Utils
["Haiku"] = Platforms.Haiku, ["Haiku"] = Platforms.Haiku,
["Android"] = Platforms.Android, ["Android"] = Platforms.Android,
["iOS"] = Platforms.iOS, ["iOS"] = Platforms.iOS,
["HTML5"] = Platforms.HTML5 ["Web"] = Platforms.Web
}; };
public static readonly Dictionary<string, string> PlatformNameMap = new Dictionary<string, string> public static readonly Dictionary<string, string> PlatformNameMap = new Dictionary<string, string>
@ -92,7 +92,7 @@ namespace GodotTools.Utils
[Names.Haiku] = Platforms.Haiku, [Names.Haiku] = Platforms.Haiku,
[Names.Android] = Platforms.Android, [Names.Android] = Platforms.Android,
[Names.iOS] = Platforms.iOS, [Names.iOS] = Platforms.iOS,
[Names.HTML5] = Platforms.HTML5 [Names.Web] = Platforms.Web
}; };
public static readonly Dictionary<string, string> DotNetOSPlatformMap = new Dictionary<string, string> public static readonly Dictionary<string, string> DotNetOSPlatformMap = new Dictionary<string, string>
@ -107,7 +107,7 @@ namespace GodotTools.Utils
[Platforms.UWP] = DotNetOS.Win10, [Platforms.UWP] = DotNetOS.Win10,
[Platforms.Android] = DotNetOS.Android, [Platforms.Android] = DotNetOS.Android,
[Platforms.iOS] = DotNetOS.iOS, [Platforms.iOS] = DotNetOS.iOS,
[Platforms.HTML5] = DotNetOS.Browser [Platforms.Web] = DotNetOS.Browser
}; };
private static bool IsOS(string name) private static bool IsOS(string name)
@ -144,7 +144,7 @@ namespace GodotTools.Utils
private static readonly Lazy<bool> _isHaiku = new(() => IsOS(Names.Haiku)); private static readonly Lazy<bool> _isHaiku = new(() => IsOS(Names.Haiku));
private static readonly Lazy<bool> _isAndroid = new(() => IsOS(Names.Android)); private static readonly Lazy<bool> _isAndroid = new(() => IsOS(Names.Android));
private static readonly Lazy<bool> _isiOS = new(() => IsOS(Names.iOS)); private static readonly Lazy<bool> _isiOS = new(() => IsOS(Names.iOS));
private static readonly Lazy<bool> _isHTML5 = new(() => IsOS(Names.HTML5)); private static readonly Lazy<bool> _isWeb = new(() => IsOS(Names.Web));
private static readonly Lazy<bool> _isUnixLike = new(() => IsAnyOS(UnixLikePlatforms)); private static readonly Lazy<bool> _isUnixLike = new(() => IsAnyOS(UnixLikePlatforms));
[SupportedOSPlatformGuard("windows")] public static bool IsWindows => _isWindows.Value || IsUWP; [SupportedOSPlatformGuard("windows")] public static bool IsWindows => _isWindows.Value || IsUWP;
@ -161,7 +161,7 @@ namespace GodotTools.Utils
[SupportedOSPlatformGuard("ios")] public static bool IsiOS => _isiOS.Value; [SupportedOSPlatformGuard("ios")] public static bool IsiOS => _isiOS.Value;
[SupportedOSPlatformGuard("browser")] public static bool IsHTML5 => _isHTML5.Value; [SupportedOSPlatformGuard("browser")] public static bool IsWeb => _isWeb.Value;
public static bool IsUnixLike => _isUnixLike.Value; public static bool IsUnixLike => _isUnixLike.Value;
public static char PathSep => IsWindows ? ';' : ':'; public static char PathSep => IsWindows ? ';' : ':';

View File

@ -137,7 +137,7 @@ private:
api_assemblies_base_dir = res_data_dir.plus_file("assemblies"); api_assemblies_base_dir = res_data_dir.plus_file("assemblies");
#ifdef JAVASCRIPT_ENABLED #ifdef WEB_ENABLED
mono_user_dir = "user://"; mono_user_dir = "user://";
#else #else
mono_user_dir = _get_mono_user_dir(); mono_user_dir = _get_mono_user_dir();

View File

@ -143,7 +143,7 @@ if env["builtin_harfbuzz"]:
if env["platform"] == "android" or env["platform"] == "linuxbsd": if env["platform"] == "android" or env["platform"] == "linuxbsd":
env_harfbuzz.Append(CCFLAGS=["-DHAVE_PTHREAD"]) env_harfbuzz.Append(CCFLAGS=["-DHAVE_PTHREAD"])
if env["platform"] == "javascript": if env["platform"] == "web":
if env["threads_enabled"]: if env["threads_enabled"]:
env_harfbuzz.Append(CCFLAGS=["-DHAVE_PTHREAD"]) env_harfbuzz.Append(CCFLAGS=["-DHAVE_PTHREAD"])
else: else:

View File

@ -5,7 +5,7 @@ Import("env_modules")
env_webrtc = env_modules.Clone() env_webrtc = env_modules.Clone()
if env["platform"] == "javascript": if env["platform"] == "web":
# Our JavaScript/C++ interface. # Our JavaScript/C++ interface.
env.AddJSLibraries(["library_godot_webrtc.js"]) env.AddJSLibraries(["library_godot_webrtc.js"])

View File

@ -28,7 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/ /*************************************************************************/
#ifdef JAVASCRIPT_ENABLED #ifdef WEB_ENABLED
#include "webrtc_data_channel_js.h" #include "webrtc_data_channel_js.h"

View File

@ -31,7 +31,7 @@
#ifndef WEBRTC_DATA_CHANNEL_JS_H #ifndef WEBRTC_DATA_CHANNEL_JS_H
#define WEBRTC_DATA_CHANNEL_JS_H #define WEBRTC_DATA_CHANNEL_JS_H
#ifdef JAVASCRIPT_ENABLED #ifdef WEB_ENABLED
#include "webrtc_data_channel.h" #include "webrtc_data_channel.h"
@ -89,6 +89,6 @@ public:
~WebRTCDataChannelJS(); ~WebRTCDataChannelJS();
}; };
#endif // JAVASCRIPT_ENABLED #endif // WEB_ENABLED
#endif // WEBRTC_DATA_CHANNEL_JS_H #endif // WEBRTC_DATA_CHANNEL_JS_H

View File

@ -30,7 +30,7 @@
#include "webrtc_peer_connection.h" #include "webrtc_peer_connection.h"
#ifdef JAVASCRIPT_ENABLED #ifdef WEB_ENABLED
#include "webrtc_peer_connection_js.h" #include "webrtc_peer_connection_js.h"
#endif #endif
@ -44,7 +44,7 @@ void WebRTCPeerConnection::set_default_extension(const StringName &p_extension)
} }
WebRTCPeerConnection *WebRTCPeerConnection::create() { WebRTCPeerConnection *WebRTCPeerConnection::create() {
#ifdef JAVASCRIPT_ENABLED #ifdef WEB_ENABLED
return memnew(WebRTCPeerConnectionJS); return memnew(WebRTCPeerConnectionJS);
#else #else
if (default_extension == String()) { if (default_extension == String()) {

View File

@ -28,7 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/ /*************************************************************************/
#ifdef JAVASCRIPT_ENABLED #ifdef WEB_ENABLED
#include "webrtc_peer_connection_js.h" #include "webrtc_peer_connection_js.h"

View File

@ -31,7 +31,7 @@
#ifndef WEBRTC_PEER_CONNECTION_JS_H #ifndef WEBRTC_PEER_CONNECTION_JS_H
#define WEBRTC_PEER_CONNECTION_JS_H #define WEBRTC_PEER_CONNECTION_JS_H
#ifdef JAVASCRIPT_ENABLED #ifdef WEB_ENABLED
#include "webrtc_peer_connection.h" #include "webrtc_peer_connection.h"

View File

@ -7,7 +7,7 @@ env_ws = env_modules.Clone()
thirdparty_obj = [] thirdparty_obj = []
if env["platform"] == "javascript": if env["platform"] == "web":
# Our JavaScript/C++ interface. # Our JavaScript/C++ interface.
env.AddJSLibraries(["library_godot_websocket.js"]) env.AddJSLibraries(["library_godot_websocket.js"])

View File

@ -24,8 +24,8 @@
If [code]true[/code] is passed as [code]gd_mp_api[/code], the client will behave like a multiplayer peer for the [MultiplayerAPI], connections to non-Godot servers will not work, and [signal data_received] will not be emitted. If [code]true[/code] is passed as [code]gd_mp_api[/code], the client will behave like a multiplayer peer for the [MultiplayerAPI], connections to non-Godot servers will not work, and [signal data_received] will not be emitted.
If [code]false[/code] is passed instead (default), you must call [PacketPeer] functions ([code]put_packet[/code], [code]get_packet[/code], etc.) on the [WebSocketPeer] returned via [code]get_peer(1)[/code] and not on this object directly (e.g. [code]get_peer(1).put_packet(data)[/code]). If [code]false[/code] is passed instead (default), you must call [PacketPeer] functions ([code]put_packet[/code], [code]get_packet[/code], etc.) on the [WebSocketPeer] returned via [code]get_peer(1)[/code] and not on this object directly (e.g. [code]get_peer(1).put_packet(data)[/code]).
You can optionally pass a list of [code]custom_headers[/code] to be added to the handshake HTTP request. You can optionally pass a list of [code]custom_headers[/code] to be added to the handshake HTTP request.
[b]Note:[/b] To avoid mixed content warnings or errors in HTML5, you may have to use a [code]url[/code] that starts with [code]wss://[/code] (secure) instead of [code]ws://[/code]. When doing so, make sure to use the fully qualified domain name that matches the one defined in the server's SSL certificate. Do not connect directly via the IP address for [code]wss://[/code] connections, as it won't match with the SSL certificate. [b]Note:[/b] To avoid mixed content warnings or errors in Web, you may have to use a [code]url[/code] that starts with [code]wss://[/code] (secure) instead of [code]ws://[/code]. When doing so, make sure to use the fully qualified domain name that matches the one defined in the server's SSL certificate. Do not connect directly via the IP address for [code]wss://[/code] connections, as it won't match with the SSL certificate.
[b]Note:[/b] Specifying [code]custom_headers[/code] is not supported in HTML5 exports due to browsers restrictions. [b]Note:[/b] Specifying [code]custom_headers[/code] is not supported in Web exports due to browsers restrictions.
</description> </description>
</method> </method>
<method name="disconnect_from_host"> <method name="disconnect_from_host">
@ -52,7 +52,7 @@
<members> <members>
<member name="trusted_ssl_certificate" type="X509Certificate" setter="set_trusted_ssl_certificate" getter="get_trusted_ssl_certificate"> <member name="trusted_ssl_certificate" type="X509Certificate" setter="set_trusted_ssl_certificate" getter="get_trusted_ssl_certificate">
If specified, this [X509Certificate] will be the only one accepted when connecting to an SSL host. Any other certificate provided by the server will be regarded as invalid. If specified, this [X509Certificate] will be the only one accepted when connecting to an SSL host. Any other certificate provided by the server will be regarded as invalid.
[b]Note:[/b] Specifying a custom [code]trusted_ssl_certificate[/code] is not supported in HTML5 exports due to browsers restrictions. [b]Note:[/b] Specifying a custom [code]trusted_ssl_certificate[/code] is not supported in Web exports due to browsers restrictions.
</member> </member>
<member name="verify_ssl" type="bool" setter="set_verify_ssl_enabled" getter="is_verify_ssl_enabled"> <member name="verify_ssl" type="bool" setter="set_verify_ssl_enabled" getter="is_verify_ssl_enabled">
If [code]true[/code], SSL certificate verification is enabled. If [code]true[/code], SSL certificate verification is enabled.

View File

@ -27,7 +27,7 @@
Configures the buffer sizes for this WebSocket peer. Default values can be specified in the Project Settings under [code]network/limits[/code]. For server, values are meant per connected peer. Configures the buffer sizes for this WebSocket peer. Default values can be specified in the Project Settings under [code]network/limits[/code]. For server, values are meant per connected peer.
The first two parameters define the size and queued packets limits of the input buffer, the last two of the output buffer. The first two parameters define the size and queued packets limits of the input buffer, the last two of the output buffer.
Buffer sizes are expressed in KiB, so [code]4 = 2^12 = 4096 bytes[/code]. All parameters will be rounded up to the nearest power of two. Buffer sizes are expressed in KiB, so [code]4 = 2^12 = 4096 bytes[/code]. All parameters will be rounded up to the nearest power of two.
[b]Note:[/b] HTML5 exports only use the input buffer since the output one is managed by browsers. [b]Note:[/b] Web exports only use the input buffer since the output one is managed by browsers.
</description> </description>
</method> </method>
</methods> </methods>

View File

@ -17,27 +17,27 @@
<description> <description>
Closes this WebSocket connection. [code]code[/code] is the status code for the closure (see RFC 6455 section 7.4 for a list of valid status codes). [code]reason[/code] is the human readable reason for closing the connection (can be any UTF-8 string that's smaller than 123 bytes). Closes this WebSocket connection. [code]code[/code] is the status code for the closure (see RFC 6455 section 7.4 for a list of valid status codes). [code]reason[/code] is the human readable reason for closing the connection (can be any UTF-8 string that's smaller than 123 bytes).
[b]Note:[/b] To achieve a clean close, you will need to keep polling until either [signal WebSocketClient.connection_closed] or [signal WebSocketServer.client_disconnected] is received. [b]Note:[/b] To achieve a clean close, you will need to keep polling until either [signal WebSocketClient.connection_closed] or [signal WebSocketServer.client_disconnected] is received.
[b]Note:[/b] The HTML5 export might not support all status codes. Please refer to browser-specific documentation for more details. [b]Note:[/b] The Web export might not support all status codes. Please refer to browser-specific documentation for more details.
</description> </description>
</method> </method>
<method name="get_connected_host" qualifiers="const"> <method name="get_connected_host" qualifiers="const">
<return type="String" /> <return type="String" />
<description> <description>
Returns the IP address of the connected peer. Returns the IP address of the connected peer.
[b]Note:[/b] Not available in the HTML5 export. [b]Note:[/b] Not available in the Web export.
</description> </description>
</method> </method>
<method name="get_connected_port" qualifiers="const"> <method name="get_connected_port" qualifiers="const">
<return type="int" /> <return type="int" />
<description> <description>
Returns the remote port of the connected peer. Returns the remote port of the connected peer.
[b]Note:[/b] Not available in the HTML5 export. [b]Note:[/b] Not available in the Web export.
</description> </description>
</method> </method>
<method name="get_current_outbound_buffered_amount" qualifiers="const"> <method name="get_current_outbound_buffered_amount" qualifiers="const">
<return type="int" /> <return type="int" />
<description> <description>
Returns the current amount of data in the outbound websocket buffer. [b]Note:[/b] HTML5 exports use WebSocket.bufferedAmount, while other platforms use an internal buffer. Returns the current amount of data in the outbound websocket buffer. [b]Note:[/b] Web exports use WebSocket.bufferedAmount, while other platforms use an internal buffer.
</description> </description>
</method> </method>
<method name="get_write_mode" qualifiers="const"> <method name="get_write_mode" qualifiers="const">
@ -57,7 +57,7 @@
<param index="0" name="enabled" type="bool" /> <param index="0" name="enabled" type="bool" />
<description> <description>
Disable Nagle's algorithm on the underling TCP socket (default). See [method StreamPeerTCP.set_no_delay] for more information. Disable Nagle's algorithm on the underling TCP socket (default). See [method StreamPeerTCP.set_no_delay] for more information.
[b]Note:[/b] Not available in the HTML5 export. [b]Note:[/b] Not available in the Web export.
</description> </description>
</method> </method>
<method name="set_write_mode"> <method name="set_write_mode">

View File

@ -6,7 +6,7 @@
<description> <description>
This class implements a WebSocket server that can also support the high-level multiplayer API. This class implements a WebSocket server that can also support the high-level multiplayer API.
After starting the server ([method listen]), you will need to [method MultiplayerPeer.poll] it at regular intervals (e.g. inside [method Node._process]). When clients connect, disconnect, or send data, you will receive the appropriate signal. After starting the server ([method listen]), you will need to [method MultiplayerPeer.poll] it at regular intervals (e.g. inside [method Node._process]). When clients connect, disconnect, or send data, you will receive the appropriate signal.
[b]Note:[/b] Not available in HTML5 exports. [b]Note:[/b] Not available in Web exports.
[b]Note:[/b] When exporting to Android, make sure to enable the [code]INTERNET[/code] permission in the Android export preset before exporting the project or using one-click deploy. Otherwise, network communication of any kind will be blocked by Android. [b]Note:[/b] When exporting to Android, make sure to enable the [code]INTERNET[/code] permission in the Android export preset before exporting the project or using one-click deploy. Otherwise, network communication of any kind will be blocked by Android.
</description> </description>
<tutorials> <tutorials>

View File

@ -28,7 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/ /*************************************************************************/
#ifdef JAVASCRIPT_ENABLED #ifdef WEB_ENABLED
#include "emws_client.h" #include "emws_client.h"
@ -82,12 +82,12 @@ Error EMWSClient::connect_to_host(String p_host, String p_path, uint16_t p_port,
String str = "ws://"; String str = "ws://";
if (p_custom_headers.size()) { if (p_custom_headers.size()) {
WARN_PRINT_ONCE("Custom headers are not supported in HTML5 platform."); WARN_PRINT_ONCE("Custom headers are not supported in Web platform.");
} }
if (p_ssl) { if (p_ssl) {
str = "wss://"; str = "wss://";
if (ssl_cert.is_valid()) { if (ssl_cert.is_valid()) {
WARN_PRINT_ONCE("Custom SSL certificate is not supported in HTML5 platform."); WARN_PRINT_ONCE("Custom SSL certificate is not supported in Web platform.");
} }
} }
str += p_host + ":" + itos(p_port) + p_path; str += p_host + ":" + itos(p_port) + p_path;
@ -126,11 +126,11 @@ void EMWSClient::disconnect_from_host(int p_code, String p_reason) {
} }
IPAddress EMWSClient::get_connected_host() const { IPAddress EMWSClient::get_connected_host() const {
ERR_FAIL_V_MSG(IPAddress(), "Not supported in HTML5 export."); ERR_FAIL_V_MSG(IPAddress(), "Not supported in Web export.");
} }
uint16_t EMWSClient::get_connected_port() const { uint16_t EMWSClient::get_connected_port() const {
ERR_FAIL_V_MSG(0, "Not supported in HTML5 export."); ERR_FAIL_V_MSG(0, "Not supported in Web export.");
} }
int EMWSClient::get_max_packet_size() const { int EMWSClient::get_max_packet_size() const {
@ -156,4 +156,4 @@ EMWSClient::~EMWSClient() {
} }
} }
#endif // JAVASCRIPT_ENABLED #endif // WEB_ENABLED

View File

@ -31,7 +31,7 @@
#ifndef EMWS_CLIENT_H #ifndef EMWS_CLIENT_H
#define EMWS_CLIENT_H #define EMWS_CLIENT_H
#ifdef JAVASCRIPT_ENABLED #ifdef WEB_ENABLED
#include "core/error/error_list.h" #include "core/error/error_list.h"
#include "emws_peer.h" #include "emws_peer.h"
@ -66,6 +66,6 @@ public:
~EMWSClient(); ~EMWSClient();
}; };
#endif // JAVASCRIPT_ENABLED #endif // WEB_ENABLED
#endif // EMWS_CLIENT_H #endif // EMWS_CLIENT_H

View File

@ -28,7 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/ /*************************************************************************/
#ifdef JAVASCRIPT_ENABLED #ifdef WEB_ENABLED
#include "emws_peer.h" #include "emws_peer.h"
@ -110,15 +110,15 @@ void EMWSPeer::close(int p_code, String p_reason) {
} }
IPAddress EMWSPeer::get_connected_host() const { IPAddress EMWSPeer::get_connected_host() const {
ERR_FAIL_V_MSG(IPAddress(), "Not supported in HTML5 export."); ERR_FAIL_V_MSG(IPAddress(), "Not supported in Web export.");
} }
uint16_t EMWSPeer::get_connected_port() const { uint16_t EMWSPeer::get_connected_port() const {
ERR_FAIL_V_MSG(0, "Not supported in HTML5 export."); ERR_FAIL_V_MSG(0, "Not supported in Web export.");
} }
void EMWSPeer::set_no_delay(bool p_enabled) { void EMWSPeer::set_no_delay(bool p_enabled) {
ERR_FAIL_MSG("'set_no_delay' is not supported in HTML5 export."); ERR_FAIL_MSG("'set_no_delay' is not supported in Web export.");
} }
EMWSPeer::EMWSPeer() { EMWSPeer::EMWSPeer() {
@ -129,4 +129,4 @@ EMWSPeer::~EMWSPeer() {
close(); close();
} }
#endif // JAVASCRIPT_ENABLED #endif // WEB_ENABLED

View File

@ -31,7 +31,7 @@
#ifndef EMWS_PEER_H #ifndef EMWS_PEER_H
#define EMWS_PEER_H #define EMWS_PEER_H
#ifdef JAVASCRIPT_ENABLED #ifdef WEB_ENABLED
#include "core/error/error_list.h" #include "core/error/error_list.h"
#include "core/io/packet_peer.h" #include "core/io/packet_peer.h"
@ -88,6 +88,6 @@ public:
~EMWSPeer(); ~EMWSPeer();
}; };
#endif // JAVASCRIPT_ENABLED #endif // WEB_ENABLED
#endif // EMWS_PEER_H #endif // EMWS_PEER_H

View File

@ -36,7 +36,7 @@
#include "websocket_client.h" #include "websocket_client.h"
#include "websocket_server.h" #include "websocket_server.h"
#ifdef JAVASCRIPT_ENABLED #ifdef WEB_ENABLED
#include "emscripten.h" #include "emscripten.h"
#include "emws_client.h" #include "emws_client.h"
#include "emws_peer.h" #include "emws_peer.h"
@ -59,7 +59,7 @@ static void _editor_init_callback() {
void initialize_websocket_module(ModuleInitializationLevel p_level) { void initialize_websocket_module(ModuleInitializationLevel p_level) {
if (p_level == MODULE_INITIALIZATION_LEVEL_SCENE) { if (p_level == MODULE_INITIALIZATION_LEVEL_SCENE) {
#ifdef JAVASCRIPT_ENABLED #ifdef WEB_ENABLED
EMWSPeer::make_default(); EMWSPeer::make_default();
EMWSClient::make_default(); EMWSClient::make_default();
#else #else

View File

@ -103,7 +103,7 @@ void RemoteDebuggerPeerWebSocket::close() {
} }
bool RemoteDebuggerPeerWebSocket::can_block() const { bool RemoteDebuggerPeerWebSocket::can_block() const {
#ifdef JAVASCRIPT_ENABLED #ifdef WEB_ENABLED
return false; return false;
#else #else
return true; return true;
@ -111,7 +111,7 @@ bool RemoteDebuggerPeerWebSocket::can_block() const {
} }
RemoteDebuggerPeerWebSocket::RemoteDebuggerPeerWebSocket(Ref<WebSocketPeer> p_peer) { RemoteDebuggerPeerWebSocket::RemoteDebuggerPeerWebSocket(Ref<WebSocketPeer> p_peer) {
#ifdef JAVASCRIPT_ENABLED #ifdef WEB_ENABLED
ws_client = Ref<WebSocketClient>(memnew(EMWSClient)); ws_client = Ref<WebSocketClient>(memnew(EMWSClient));
#else #else
ws_client = Ref<WebSocketClient>(memnew(WSLClient)); ws_client = Ref<WebSocketClient>(memnew(WSLClient));

View File

@ -33,7 +33,7 @@
#include "core/debugger/remote_debugger_peer.h" #include "core/debugger/remote_debugger_peer.h"
#ifdef JAVASCRIPT_ENABLED #ifdef WEB_ENABLED
#include "emws_client.h" #include "emws_client.h"
#else #else
#include "wsl_client.h" #include "wsl_client.h"

View File

@ -28,7 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/ /*************************************************************************/
#ifndef JAVASCRIPT_ENABLED #ifndef WEB_ENABLED
#include "wsl_client.h" #include "wsl_client.h"
#include "core/config/project_settings.h" #include "core/config/project_settings.h"
@ -404,4 +404,4 @@ WSLClient::~WSLClient() {
disconnect_from_host(); disconnect_from_host();
} }
#endif // JAVASCRIPT_ENABLED #endif // WEB_ENABLED

View File

@ -31,7 +31,7 @@
#ifndef WSL_CLIENT_H #ifndef WSL_CLIENT_H
#define WSL_CLIENT_H #define WSL_CLIENT_H
#ifndef JAVASCRIPT_ENABLED #ifndef WEB_ENABLED
#include "core/error/error_list.h" #include "core/error/error_list.h"
#include "core/io/stream_peer_ssl.h" #include "core/io/stream_peer_ssl.h"
@ -86,6 +86,6 @@ public:
~WSLClient(); ~WSLClient();
}; };
#endif // JAVASCRIPT_ENABLED #endif // WEB_ENABLED
#endif // WSL_CLIENT_H #endif // WSL_CLIENT_H

View File

@ -28,7 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/ /*************************************************************************/
#ifndef JAVASCRIPT_ENABLED #ifndef WEB_ENABLED
#include "wsl_peer.h" #include "wsl_peer.h"
@ -348,4 +348,4 @@ WSLPeer::~WSLPeer() {
_data = nullptr; _data = nullptr;
} }
#endif // JAVASCRIPT_ENABLED #endif // WEB_ENABLED

View File

@ -31,7 +31,7 @@
#ifndef WSL_PEER_H #ifndef WSL_PEER_H
#define WSL_PEER_H #define WSL_PEER_H
#ifndef JAVASCRIPT_ENABLED #ifndef WEB_ENABLED
#include "core/error/error_list.h" #include "core/error/error_list.h"
#include "core/io/packet_peer.h" #include "core/io/packet_peer.h"
@ -110,6 +110,6 @@ public:
~WSLPeer(); ~WSLPeer();
}; };
#endif // JAVASCRIPT_ENABLED #endif // WEB_ENABLED
#endif // WSL_PEER_H #endif // WSL_PEER_H

View File

@ -28,7 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/ /*************************************************************************/
#ifndef JAVASCRIPT_ENABLED #ifndef WEB_ENABLED
#include "wsl_server.h" #include "wsl_server.h"
#include "core/config/project_settings.h" #include "core/config/project_settings.h"
@ -326,4 +326,4 @@ WSLServer::~WSLServer() {
stop(); stop();
} }
#endif // JAVASCRIPT_ENABLED #endif // WEB_ENABLED

View File

@ -31,7 +31,7 @@
#ifndef WSL_SERVER_H #ifndef WSL_SERVER_H
#define WSL_SERVER_H #define WSL_SERVER_H
#ifndef JAVASCRIPT_ENABLED #ifndef WEB_ENABLED
#include "websocket_server.h" #include "websocket_server.h"
#include "wsl_peer.h" #include "wsl_peer.h"
@ -93,6 +93,6 @@ public:
~WSLServer(); ~WSLServer();
}; };
#endif // JAVASCRIPT_ENABLED #endif // WEB_ENABLED
#endif // WSL_SERVER_H #endif // WSL_SERVER_H

View File

@ -3,7 +3,7 @@
Import("env") Import("env")
Import("env_modules") Import("env_modules")
if env["platform"] == "javascript": if env["platform"] == "web":
env.AddJSLibraries(["native/library_godot_webxr.js"]) env.AddJSLibraries(["native/library_godot_webxr.js"])
env.AddJSExterns(["native/webxr.externs.js"]) env.AddJSExterns(["native/webxr.externs.js"])

View File

@ -5,9 +5,9 @@
</brief_description> </brief_description>
<description> <description>
WebXR is an open standard that allows creating VR and AR applications that run in the web browser. WebXR is an open standard that allows creating VR and AR applications that run in the web browser.
As such, this interface is only available when running in an HTML5 export. As such, this interface is only available when running in Web exports.
WebXR supports a wide range of devices, from the very capable (like Valve Index, HTC Vive, Oculus Rift and Quest) down to the much less capable (like Google Cardboard, Oculus Go, GearVR, or plain smartphones). WebXR supports a wide range of devices, from the very capable (like Valve Index, HTC Vive, Oculus Rift and Quest) down to the much less capable (like Google Cardboard, Oculus Go, GearVR, or plain smartphones).
Since WebXR is based on Javascript, it makes extensive use of callbacks, which means that [WebXRInterface] is forced to use signals, where other AR/VR interfaces would instead use functions that return a result immediately. This makes [WebXRInterface] quite a bit more complicated to initialize than other AR/VR interfaces. Since WebXR is based on JavaScript, it makes extensive use of callbacks, which means that [WebXRInterface] is forced to use signals, where other AR/VR interfaces would instead use functions that return a result immediately. This makes [WebXRInterface] quite a bit more complicated to initialize than other AR/VR interfaces.
Here's the minimum code required to start an immersive VR session: Here's the minimum code required to start an immersive VR session:
[codeblock] [codeblock]
extends Node3D extends Node3D

View File

@ -33,7 +33,7 @@
#include "webxr_interface.h" #include "webxr_interface.h"
#include "webxr_interface_js.h" #include "webxr_interface_js.h"
#ifdef JAVASCRIPT_ENABLED #ifdef WEB_ENABLED
Ref<WebXRInterfaceJS> webxr; Ref<WebXRInterfaceJS> webxr;
#endif #endif
@ -44,7 +44,7 @@ void initialize_webxr_module(ModuleInitializationLevel p_level) {
GDREGISTER_ABSTRACT_CLASS(WebXRInterface); GDREGISTER_ABSTRACT_CLASS(WebXRInterface);
#ifdef JAVASCRIPT_ENABLED #ifdef WEB_ENABLED
webxr.instantiate(); webxr.instantiate();
XRServer::get_singleton()->add_interface(webxr); XRServer::get_singleton()->add_interface(webxr);
#endif #endif
@ -55,7 +55,7 @@ void uninitialize_webxr_module(ModuleInitializationLevel p_level) {
return; return;
} }
#ifdef JAVASCRIPT_ENABLED #ifdef WEB_ENABLED
if (webxr.is_valid()) { if (webxr.is_valid()) {
// uninitialise our interface if it is initialised // uninitialise our interface if it is initialised
if (webxr->is_initialized()) { if (webxr->is_initialized()) {

View File

@ -28,7 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/ /*************************************************************************/
#ifdef JAVASCRIPT_ENABLED #ifdef WEB_ENABLED
#include "webxr_interface_js.h" #include "webxr_interface_js.h"
@ -518,4 +518,4 @@ WebXRInterfaceJS::~WebXRInterfaceJS() {
}; };
}; };
#endif // JAVASCRIPT_ENABLED #endif // WEB_ENABLED

View File

@ -31,7 +31,7 @@
#ifndef WEBXR_INTERFACE_JS_H #ifndef WEBXR_INTERFACE_JS_H
#define WEBXR_INTERFACE_JS_H #define WEBXR_INTERFACE_JS_H
#ifdef JAVASCRIPT_ENABLED #ifdef WEB_ENABLED
#include "webxr_interface.h" #include "webxr_interface.h"
@ -98,6 +98,6 @@ public:
~WebXRInterfaceJS(); ~WebXRInterfaceJS();
}; };
#endif // JAVASCRIPT_ENABLED #endif // WEB_ENABLED
#endif // WEBXR_INTERFACE_JS_H #endif // WEBXR_INTERFACE_JS_H

View File

@ -1,12 +1,12 @@
# HTML5 platform port # Web platform port
This folder contains the C++ and JavaScript code for the HTML5/WebAssembly platform port, This folder contains the C++ and JavaScript code for the Web platform port,
compiled using [Emscripten](https://emscripten.org/). compiled using [Emscripten](https://emscripten.org/).
It also contains a ESLint linting setup (see [`package.json`](package.json)). It also contains a ESLint linting setup (see [`package.json`](package.json)).
See also [`misc/dist/html`](/misc/dist/html) folder for additional files used by See also [`misc/dist/html`](/misc/dist/html) folder for additional files used by
this platform such as the HTML5 shell. this platform such as the html shell (web page).
## Documentation ## Documentation

View File

@ -2,14 +2,14 @@
Import("env") Import("env")
javascript_files = [ web_files = [
"audio_driver_javascript.cpp", "audio_driver_web.cpp",
"display_server_javascript.cpp", "display_server_web.cpp",
"http_client_javascript.cpp", "http_client_web.cpp",
"javascript_singleton.cpp", "javascript_singleton.cpp",
"javascript_main.cpp", "web_main.cpp",
"os_javascript.cpp", "os_web.cpp",
"api/javascript_tools_editor_plugin.cpp", "api/web_tools_editor_plugin.cpp",
] ]
sys_env = env.Clone() sys_env = env.Clone()
@ -52,14 +52,14 @@ if env["gdnative_enabled"]:
# Force exporting the standard library (printf, malloc, etc.) # Force exporting the standard library (printf, malloc, etc.)
sys_env["ENV"]["EMCC_FORCE_STDLIBS"] = "libc,libc++,libc++abi" sys_env["ENV"]["EMCC_FORCE_STDLIBS"] = "libc,libc++,libc++abi"
# The main emscripten runtime, with exported standard libraries. # The main emscripten runtime, with exported standard libraries.
sys = sys_env.Program(build_targets, ["javascript_runtime.cpp"]) sys = sys_env.Program(build_targets, ["web_runtime.cpp"])
# The side library, containing all Godot code. # The side library, containing all Godot code.
wasm_env = env.Clone() wasm_env = env.Clone()
wasm_env.Append(CPPDEFINES=["WASM_GDNATIVE"]) # So that OS knows it can run GDNative libraries. wasm_env.Append(CPPDEFINES=["WASM_GDNATIVE"]) # So that OS knows it can run GDNative libraries.
wasm_env.Append(CCFLAGS=["-s", "SIDE_MODULE=2"]) wasm_env.Append(CCFLAGS=["-s", "SIDE_MODULE=2"])
wasm_env.Append(LINKFLAGS=["-s", "SIDE_MODULE=2"]) wasm_env.Append(LINKFLAGS=["-s", "SIDE_MODULE=2"])
wasm = wasm_env.add_program("#bin/godot.side${PROGSUFFIX}.wasm", javascript_files) wasm = wasm_env.add_program("#bin/godot.side${PROGSUFFIX}.wasm", web_files)
build = sys + [wasm[0]] build = sys + [wasm[0]]
else: else:
build_targets = ["#bin/godot${PROGSUFFIX}.js", "#bin/godot${PROGSUFFIX}.wasm"] build_targets = ["#bin/godot${PROGSUFFIX}.js", "#bin/godot${PROGSUFFIX}.wasm"]
@ -67,7 +67,7 @@ else:
build_targets.append("#bin/godot${PROGSUFFIX}.worker.js") build_targets.append("#bin/godot${PROGSUFFIX}.worker.js")
# We use IDBFS. Since Emscripten 1.39.1 it needs to be linked explicitly. # We use IDBFS. Since Emscripten 1.39.1 it needs to be linked explicitly.
sys_env.Append(LIBS=["idbfs.js"]) sys_env.Append(LIBS=["idbfs.js"])
build = sys_env.Program(build_targets, javascript_files + ["javascript_runtime.cpp"]) build = sys_env.Program(build_targets, web_files + ["web_runtime.cpp"])
sys_env.Depends(build[0], sys_env["JS_LIBS"]) sys_env.Depends(build[0], sys_env["JS_LIBS"])
sys_env.Depends(build[0], sys_env["JS_PRE"]) sys_env.Depends(build[0], sys_env["JS_PRE"])
@ -78,7 +78,7 @@ engine = [
"js/engine/config.js", "js/engine/config.js",
"js/engine/engine.js", "js/engine/engine.js",
] ]
externs = [env.File("#platform/javascript/js/engine/engine.externs.js")] externs = [env.File("#platform/web/js/engine/engine.externs.js")]
js_engine = env.CreateEngineFile("#bin/godot${PROGSUFFIX}.engine.js", engine, externs) js_engine = env.CreateEngineFile("#bin/godot${PROGSUFFIX}.engine.js", engine, externs)
env.Depends(js_engine, externs) env.Depends(js_engine, externs)

View File

@ -31,20 +31,20 @@
#include "api.h" #include "api.h"
#include "core/config/engine.h" #include "core/config/engine.h"
#include "javascript_singleton.h" #include "javascript_singleton.h"
#include "javascript_tools_editor_plugin.h" #include "web_tools_editor_plugin.h"
static JavaScript *javascript_eval; static JavaScript *javascript_singleton;
void register_javascript_api() { void register_web_api() {
JavaScriptToolsEditorPlugin::initialize(); WebToolsEditorPlugin::initialize();
GDREGISTER_ABSTRACT_CLASS(JavaScriptObject); GDREGISTER_ABSTRACT_CLASS(JavaScriptObject);
GDREGISTER_ABSTRACT_CLASS(JavaScript); GDREGISTER_ABSTRACT_CLASS(JavaScript);
javascript_eval = memnew(JavaScript); javascript_singleton = memnew(JavaScript);
Engine::get_singleton()->add_singleton(Engine::Singleton("JavaScript", javascript_eval)); Engine::get_singleton()->add_singleton(Engine::Singleton("JavaScript", javascript_singleton));
} }
void unregister_javascript_api() { void unregister_web_api() {
memdelete(javascript_eval); memdelete(javascript_singleton);
} }
JavaScript *JavaScript::singleton = nullptr; JavaScript *JavaScript::singleton = nullptr;
@ -76,7 +76,7 @@ void JavaScript::_bind_methods() {
ADD_SIGNAL(MethodInfo("pwa_update_available")); ADD_SIGNAL(MethodInfo("pwa_update_available"));
} }
#if !defined(JAVASCRIPT_ENABLED) || !defined(JAVASCRIPT_EVAL_ENABLED) #if !defined(WEB_ENABLED) || !defined(JAVASCRIPT_EVAL_ENABLED)
Variant JavaScript::eval(const String &p_code, bool p_use_global_exec_context) { Variant JavaScript::eval(const String &p_code, bool p_use_global_exec_context) {
return Variant(); return Variant();
} }
@ -104,7 +104,7 @@ Variant JavaScript::_create_object_bind(const Variant **p_args, int p_argcount,
return Ref<JavaScriptObject>(); return Ref<JavaScriptObject>();
} }
#endif #endif
#if !defined(JAVASCRIPT_ENABLED) #if !defined(WEB_ENABLED)
bool JavaScript::pwa_needs_update() const { bool JavaScript::pwa_needs_update() const {
return false; return false;
} }

View File

@ -28,10 +28,10 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/ /*************************************************************************/
#ifndef JAVASCRIPT_API_H #ifndef WEB_API_H
#define JAVASCRIPT_API_H #define WEB_API_H
void register_javascript_api(); void register_web_api();
void unregister_javascript_api(); void unregister_web_api();
#endif // JAVASCRIPT_API_H #endif // WEB_API_H

View File

@ -1,5 +1,5 @@
/*************************************************************************/ /*************************************************************************/
/* javascript_tools_editor_plugin.cpp */ /* web_tools_editor_plugin.cpp */
/*************************************************************************/ /*************************************************************************/
/* This file is part of: */ /* This file is part of: */
/* GODOT ENGINE */ /* GODOT ENGINE */
@ -28,8 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/ /*************************************************************************/
#if defined(TOOLS_ENABLED) && defined(JAVASCRIPT_ENABLED) #if defined(TOOLS_ENABLED) && defined(WEB_ENABLED)
#include "javascript_tools_editor_plugin.h" #include "web_tools_editor_plugin.h"
#include "core/config/engine.h" #include "core/config/engine.h"
#include "core/config/project_settings.h" #include "core/config/project_settings.h"
@ -40,24 +40,24 @@
#include <emscripten/emscripten.h> #include <emscripten/emscripten.h>
// JavaScript functions defined in library_godot_editor_tools.js // Web functions defined in library_godot_editor_tools.js
extern "C" { extern "C" {
extern void godot_js_os_download_buffer(const uint8_t *p_buf, int p_buf_size, const char *p_name, const char *p_mime); extern void godot_js_os_download_buffer(const uint8_t *p_buf, int p_buf_size, const char *p_name, const char *p_mime);
} }
static void _javascript_editor_init_callback() { static void _web_editor_init_callback() {
EditorNode::get_singleton()->add_editor_plugin(memnew(JavaScriptToolsEditorPlugin)); EditorNode::get_singleton()->add_editor_plugin(memnew(WebToolsEditorPlugin));
} }
void JavaScriptToolsEditorPlugin::initialize() { void WebToolsEditorPlugin::initialize() {
EditorNode::add_init_callback(_javascript_editor_init_callback); EditorNode::add_init_callback(_web_editor_init_callback);
} }
JavaScriptToolsEditorPlugin::JavaScriptToolsEditorPlugin() { WebToolsEditorPlugin::WebToolsEditorPlugin() {
add_tool_menu_item("Download Project Source", callable_mp(this, &JavaScriptToolsEditorPlugin::_download_zip)); add_tool_menu_item("Download Project Source", callable_mp(this, &WebToolsEditorPlugin::_download_zip));
} }
void JavaScriptToolsEditorPlugin::_download_zip(Variant p_v) { void WebToolsEditorPlugin::_download_zip(Variant p_v) {
if (!Engine::get_singleton() || !Engine::get_singleton()->is_editor_hint()) { if (!Engine::get_singleton() || !Engine::get_singleton()->is_editor_hint()) {
ERR_PRINT("Downloading the project as a ZIP archive is only available in Editor mode."); ERR_PRINT("Downloading the project as a ZIP archive is only available in Editor mode.");
return; return;
@ -95,7 +95,7 @@ void JavaScriptToolsEditorPlugin::_download_zip(Variant p_v) {
DirAccess::remove_file_or_error(output_path); DirAccess::remove_file_or_error(output_path);
} }
void JavaScriptToolsEditorPlugin::_zip_file(String p_path, String p_base_path, zipFile p_zip) { void WebToolsEditorPlugin::_zip_file(String p_path, String p_base_path, zipFile p_zip) {
Ref<FileAccess> f = FileAccess::open(p_path, FileAccess::READ); Ref<FileAccess> f = FileAccess::open(p_path, FileAccess::READ);
if (f.is_null()) { if (f.is_null()) {
WARN_PRINT("Unable to open file for zipping: " + p_path); WARN_PRINT("Unable to open file for zipping: " + p_path);
@ -121,7 +121,7 @@ void JavaScriptToolsEditorPlugin::_zip_file(String p_path, String p_base_path, z
zipCloseFileInZip(p_zip); zipCloseFileInZip(p_zip);
} }
void JavaScriptToolsEditorPlugin::_zip_recursive(String p_path, String p_base_path, zipFile p_zip) { void WebToolsEditorPlugin::_zip_recursive(String p_path, String p_base_path, zipFile p_zip) {
Ref<DirAccess> dir = DirAccess::open(p_path); Ref<DirAccess> dir = DirAccess::open(p_path);
if (dir.is_null()) { if (dir.is_null()) {
WARN_PRINT("Unable to open directory for zipping: " + p_path); WARN_PRINT("Unable to open directory for zipping: " + p_path);

View File

@ -1,5 +1,5 @@
/*************************************************************************/ /*************************************************************************/
/* javascript_tools_editor_plugin.h */ /* web_tools_editor_plugin.h */
/*************************************************************************/ /*************************************************************************/
/* This file is part of: */ /* This file is part of: */
/* GODOT ENGINE */ /* GODOT ENGINE */
@ -28,15 +28,15 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/ /*************************************************************************/
#ifndef JAVASCRIPT_TOOLS_EDITOR_PLUGIN_H #ifndef WEB_TOOLS_EDITOR_PLUGIN_H
#define JAVASCRIPT_TOOLS_EDITOR_PLUGIN_H #define WEB_TOOLS_EDITOR_PLUGIN_H
#if defined(TOOLS_ENABLED) && defined(JAVASCRIPT_ENABLED) #if defined(TOOLS_ENABLED) && defined(WEB_ENABLED)
#include "core/io/zip_io.h" #include "core/io/zip_io.h"
#include "editor/editor_plugin.h" #include "editor/editor_plugin.h"
class JavaScriptToolsEditorPlugin : public EditorPlugin { class WebToolsEditorPlugin : public EditorPlugin {
GDCLASS(JavaScriptToolsEditorPlugin, EditorPlugin); GDCLASS(WebToolsEditorPlugin, EditorPlugin);
private: private:
void _zip_file(String p_path, String p_base_path, zipFile p_zip); void _zip_file(String p_path, String p_base_path, zipFile p_zip);
@ -46,13 +46,13 @@ private:
public: public:
static void initialize(); static void initialize();
JavaScriptToolsEditorPlugin(); WebToolsEditorPlugin();
}; };
#else #else
class JavaScriptToolsEditorPlugin { class WebToolsEditorPlugin {
public: public:
static void initialize() {} static void initialize() {}
}; };
#endif #endif
#endif // JAVASCRIPT_TOOLS_EDITOR_PLUGIN_H #endif // WEB_TOOLS_EDITOR_PLUGIN_H

View File

@ -1,5 +1,5 @@
/*************************************************************************/ /*************************************************************************/
/* audio_driver_javascript.cpp */ /* audio_driver_web.cpp */
/*************************************************************************/ /*************************************************************************/
/* This file is part of: */ /* This file is part of: */
/* GODOT ENGINE */ /* GODOT ENGINE */
@ -28,27 +28,27 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/ /*************************************************************************/
#include "audio_driver_javascript.h" #include "audio_driver_web.h"
#include "core/config/project_settings.h" #include "core/config/project_settings.h"
#include <emscripten.h> #include <emscripten.h>
AudioDriverJavaScript::AudioContext AudioDriverJavaScript::audio_context; AudioDriverWeb::AudioContext AudioDriverWeb::audio_context;
bool AudioDriverJavaScript::is_available() { bool AudioDriverWeb::is_available() {
return godot_audio_is_available() != 0; return godot_audio_is_available() != 0;
} }
void AudioDriverJavaScript::_state_change_callback(int p_state) { void AudioDriverWeb::_state_change_callback(int p_state) {
AudioDriverJavaScript::audio_context.state = p_state; AudioDriverWeb::audio_context.state = p_state;
} }
void AudioDriverJavaScript::_latency_update_callback(float p_latency) { void AudioDriverWeb::_latency_update_callback(float p_latency) {
AudioDriverJavaScript::audio_context.output_latency = p_latency; AudioDriverWeb::audio_context.output_latency = p_latency;
} }
void AudioDriverJavaScript::_audio_driver_process(int p_from, int p_samples) { void AudioDriverWeb::_audio_driver_process(int p_from, int p_samples) {
int32_t *stream_buffer = reinterpret_cast<int32_t *>(output_rb); int32_t *stream_buffer = reinterpret_cast<int32_t *>(output_rb);
const int max_samples = memarr_len(output_rb); const int max_samples = memarr_len(output_rb);
@ -74,7 +74,7 @@ void AudioDriverJavaScript::_audio_driver_process(int p_from, int p_samples) {
} }
} }
void AudioDriverJavaScript::_audio_driver_capture(int p_from, int p_samples) { void AudioDriverWeb::_audio_driver_capture(int p_from, int p_samples) {
if (get_input_buffer().size() == 0) { if (get_input_buffer().size() == 0) {
return; // Input capture stopped. return; // Input capture stopped.
} }
@ -100,7 +100,7 @@ void AudioDriverJavaScript::_audio_driver_capture(int p_from, int p_samples) {
} }
} }
Error AudioDriverJavaScript::init() { Error AudioDriverWeb::init() {
int latency = GLOBAL_GET("audio/driver/output_latency"); int latency = GLOBAL_GET("audio/driver/output_latency");
if (!audio_context.inited) { if (!audio_context.inited) {
audio_context.mix_rate = GLOBAL_GET("audio/driver/mix_rate"); audio_context.mix_rate = GLOBAL_GET("audio/driver/mix_rate");
@ -132,29 +132,29 @@ Error AudioDriverJavaScript::init() {
return OK; return OK;
} }
void AudioDriverJavaScript::start() { void AudioDriverWeb::start() {
start(output_rb, memarr_len(output_rb), input_rb, memarr_len(input_rb)); start(output_rb, memarr_len(output_rb), input_rb, memarr_len(input_rb));
} }
void AudioDriverJavaScript::resume() { void AudioDriverWeb::resume() {
if (audio_context.state == 0) { // 'suspended' if (audio_context.state == 0) { // 'suspended'
godot_audio_resume(); godot_audio_resume();
} }
} }
float AudioDriverJavaScript::get_latency() { float AudioDriverWeb::get_latency() {
return audio_context.output_latency + (float(buffer_length) / mix_rate); return audio_context.output_latency + (float(buffer_length) / mix_rate);
} }
int AudioDriverJavaScript::get_mix_rate() const { int AudioDriverWeb::get_mix_rate() const {
return mix_rate; return mix_rate;
} }
AudioDriver::SpeakerMode AudioDriverJavaScript::get_speaker_mode() const { AudioDriver::SpeakerMode AudioDriverWeb::get_speaker_mode() const {
return get_speaker_mode_by_total_channels(channel_count); return get_speaker_mode_by_total_channels(channel_count);
} }
void AudioDriverJavaScript::finish() { void AudioDriverWeb::finish() {
finish_driver(); finish_driver();
if (output_rb) { if (output_rb) {
memdelete_arr(output_rb); memdelete_arr(output_rb);
@ -166,7 +166,7 @@ void AudioDriverJavaScript::finish() {
} }
} }
Error AudioDriverJavaScript::capture_start() { Error AudioDriverWeb::capture_start() {
lock(); lock();
input_buffer_init(buffer_length); input_buffer_init(buffer_length);
unlock(); unlock();
@ -176,7 +176,7 @@ Error AudioDriverJavaScript::capture_start() {
return OK; return OK;
} }
Error AudioDriverJavaScript::capture_stop() { Error AudioDriverWeb::capture_stop() {
godot_audio_capture_stop(); godot_audio_capture_stop();
lock(); lock();
input_buffer.clear(); input_buffer.clear();

View File

@ -1,5 +1,5 @@
/*************************************************************************/ /*************************************************************************/
/* audio_driver_javascript.h */ /* audio_driver_web.h */
/*************************************************************************/ /*************************************************************************/
/* This file is part of: */ /* This file is part of: */
/* GODOT ENGINE */ /* GODOT ENGINE */
@ -28,8 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/ /*************************************************************************/
#ifndef AUDIO_DRIVER_JAVASCRIPT_H #ifndef AUDIO_DRIVER_WEB_H
#define AUDIO_DRIVER_JAVASCRIPT_H #define AUDIO_DRIVER_WEB_H
#include "core/os/mutex.h" #include "core/os/mutex.h"
#include "core/os/thread.h" #include "core/os/thread.h"
@ -37,7 +37,7 @@
#include "godot_audio.h" #include "godot_audio.h"
class AudioDriverJavaScript : public AudioDriver { class AudioDriverWeb : public AudioDriver {
private: private:
struct AudioContext { struct AudioContext {
bool inited = false; bool inited = false;
@ -58,7 +58,7 @@ private:
static void _state_change_callback(int p_state); static void _state_change_callback(int p_state);
static void _latency_update_callback(float p_latency); static void _latency_update_callback(float p_latency);
static AudioDriverJavaScript *singleton; static AudioDriverWeb *singleton;
protected: protected:
void _audio_driver_process(int p_from = 0, int p_samples = 0); void _audio_driver_process(int p_from = 0, int p_samples = 0);
@ -86,11 +86,11 @@ public:
static void resume(); static void resume();
AudioDriverJavaScript() {} AudioDriverWeb() {}
}; };
#ifdef NO_THREADS #ifdef NO_THREADS
class AudioDriverScriptProcessor : public AudioDriverJavaScript { class AudioDriverScriptProcessor : public AudioDriverWeb {
private: private:
static void _process_callback(); static void _process_callback();
@ -109,7 +109,7 @@ public:
AudioDriverScriptProcessor() { singleton = this; } AudioDriverScriptProcessor() { singleton = this; }
}; };
class AudioDriverWorklet : public AudioDriverJavaScript { class AudioDriverWorklet : public AudioDriverWeb {
private: private:
static void _process_callback(int p_pos, int p_samples); static void _process_callback(int p_pos, int p_samples);
static void _capture_callback(int p_pos, int p_samples); static void _capture_callback(int p_pos, int p_samples);
@ -129,7 +129,7 @@ public:
AudioDriverWorklet() { singleton = this; } AudioDriverWorklet() { singleton = this; }
}; };
#else #else
class AudioDriverWorklet : public AudioDriverJavaScript { class AudioDriverWorklet : public AudioDriverWeb {
private: private:
enum { enum {
STATE_LOCK, STATE_LOCK,
@ -158,4 +158,4 @@ public:
}; };
#endif #endif
#endif // AUDIO_DRIVER_JAVASCRIPT_H #endif // AUDIO_DRIVER_WEB_H

View File

@ -18,7 +18,7 @@ def is_active():
def get_name(): def get_name():
return "JavaScript" return "Web"
def can_build(): def can_build():
@ -182,8 +182,8 @@ def configure(env):
env["LIBPREFIXES"] = ["$LIBPREFIX"] env["LIBPREFIXES"] = ["$LIBPREFIX"]
env["LIBSUFFIXES"] = ["$LIBSUFFIX"] env["LIBSUFFIXES"] = ["$LIBSUFFIX"]
env.Prepend(CPPPATH=["#platform/javascript"]) env.Prepend(CPPPATH=["#platform/web"])
env.Append(CPPDEFINES=["JAVASCRIPT_ENABLED", "UNIX_ENABLED"]) env.Append(CPPDEFINES=["WEB_ENABLED", "UNIX_ENABLED"])
if env["opengl3"]: if env["opengl3"]:
env.AppendUnique(CPPDEFINES=["GLES3_ENABLED"]) env.AppendUnique(CPPDEFINES=["GLES3_ENABLED"])

View File

@ -1,5 +1,5 @@
/*************************************************************************/ /*************************************************************************/
/* display_server_javascript.cpp */ /* display_server_web.cpp */
/*************************************************************************/ /*************************************************************************/
/* This file is part of: */ /* This file is part of: */
/* GODOT ENGINE */ /* GODOT ENGINE */
@ -28,12 +28,12 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/ /*************************************************************************/
#include "display_server_javascript.h" #include "display_server_web.h"
#ifdef GLES3_ENABLED #ifdef GLES3_ENABLED
#include "drivers/gles3/rasterizer_gles3.h" #include "drivers/gles3/rasterizer_gles3.h"
#endif #endif
#include "platform/javascript/os_javascript.h" #include "platform/web/os_web.h"
#include "servers/rendering/dummy/rasterizer_dummy.h" #include "servers/rendering/dummy/rasterizer_dummy.h"
#include <emscripten.h> #include <emscripten.h>
@ -48,17 +48,17 @@
#define DOM_BUTTON_XBUTTON1 3 #define DOM_BUTTON_XBUTTON1 3
#define DOM_BUTTON_XBUTTON2 4 #define DOM_BUTTON_XBUTTON2 4
DisplayServerJavaScript *DisplayServerJavaScript::get_singleton() { DisplayServerWeb *DisplayServerWeb::get_singleton() {
return static_cast<DisplayServerJavaScript *>(DisplayServer::get_singleton()); return static_cast<DisplayServerWeb *>(DisplayServer::get_singleton());
} }
// Window (canvas) // Window (canvas)
bool DisplayServerJavaScript::check_size_force_redraw() { bool DisplayServerWeb::check_size_force_redraw() {
return godot_js_display_size_update() != 0; return godot_js_display_size_update() != 0;
} }
void DisplayServerJavaScript::fullscreen_change_callback(int p_fullscreen) { void DisplayServerWeb::fullscreen_change_callback(int p_fullscreen) {
DisplayServerJavaScript *display = get_singleton(); DisplayServerWeb *display = get_singleton();
if (p_fullscreen) { if (p_fullscreen) {
display->window_mode = WINDOW_MODE_FULLSCREEN; display->window_mode = WINDOW_MODE_FULLSCREEN;
} else { } else {
@ -67,8 +67,8 @@ void DisplayServerJavaScript::fullscreen_change_callback(int p_fullscreen) {
} }
// Drag and drop callback. // Drag and drop callback.
void DisplayServerJavaScript::drop_files_js_callback(char **p_filev, int p_filec) { void DisplayServerWeb::drop_files_js_callback(char **p_filev, int p_filec) {
DisplayServerJavaScript *ds = get_singleton(); DisplayServerWeb *ds = get_singleton();
if (!ds) { if (!ds) {
ERR_FAIL_MSG("Unable to drop files because the DisplayServer is not active"); ERR_FAIL_MSG("Unable to drop files because the DisplayServer is not active");
} }
@ -86,9 +86,9 @@ void DisplayServerJavaScript::drop_files_js_callback(char **p_filev, int p_filec
ds->drop_files_callback.callp((const Variant **)&vp, 1, ret, ce); ds->drop_files_callback.callp((const Variant **)&vp, 1, ret, ce);
} }
// JavaScript quit request callback. // Web quit request callback.
void DisplayServerJavaScript::request_quit_callback() { void DisplayServerWeb::request_quit_callback() {
DisplayServerJavaScript *ds = get_singleton(); DisplayServerWeb *ds = get_singleton();
if (ds && !ds->window_event_callback.is_null()) { if (ds && !ds->window_event_callback.is_null()) {
Variant event = int(DisplayServer::WINDOW_EVENT_CLOSE_REQUEST); Variant event = int(DisplayServer::WINDOW_EVENT_CLOSE_REQUEST);
Variant *eventp = &event; Variant *eventp = &event;
@ -100,18 +100,18 @@ void DisplayServerJavaScript::request_quit_callback() {
// Keys // Keys
void DisplayServerJavaScript::dom2godot_mod(Ref<InputEventWithModifiers> ev, int p_mod) { void DisplayServerWeb::dom2godot_mod(Ref<InputEventWithModifiers> ev, int p_mod) {
ev->set_shift_pressed(p_mod & 1); ev->set_shift_pressed(p_mod & 1);
ev->set_alt_pressed(p_mod & 2); ev->set_alt_pressed(p_mod & 2);
ev->set_ctrl_pressed(p_mod & 4); ev->set_ctrl_pressed(p_mod & 4);
ev->set_meta_pressed(p_mod & 8); ev->set_meta_pressed(p_mod & 8);
} }
void DisplayServerJavaScript::key_callback(int p_pressed, int p_repeat, int p_modifiers) { void DisplayServerWeb::key_callback(int p_pressed, int p_repeat, int p_modifiers) {
DisplayServerJavaScript *ds = get_singleton(); DisplayServerWeb *ds = get_singleton();
JSKeyEvent &key_event = ds->key_event; JSKeyEvent &key_event = ds->key_event;
// Resume audio context after input in case autoplay was denied. // Resume audio context after input in case autoplay was denied.
OS_JavaScript::get_singleton()->resume_audio(); OS_Web::get_singleton()->resume_audio();
Ref<InputEventKey> ev; Ref<InputEventKey> ev;
ev.instantiate(); ev.instantiate();
@ -133,8 +133,8 @@ void DisplayServerJavaScript::key_callback(int p_pressed, int p_repeat, int p_mo
// Mouse // Mouse
int DisplayServerJavaScript::mouse_button_callback(int p_pressed, int p_button, double p_x, double p_y, int p_modifiers) { int DisplayServerWeb::mouse_button_callback(int p_pressed, int p_button, double p_x, double p_y, int p_modifiers) {
DisplayServerJavaScript *ds = get_singleton(); DisplayServerWeb *ds = get_singleton();
Point2 pos(p_x, p_y); Point2 pos(p_x, p_y);
Ref<InputEventMouseButton> ev; Ref<InputEventMouseButton> ev;
@ -199,7 +199,7 @@ int DisplayServerJavaScript::mouse_button_callback(int p_pressed, int p_button,
Input::get_singleton()->parse_input_event(ev); Input::get_singleton()->parse_input_event(ev);
// Resume audio context after input in case autoplay was denied. // Resume audio context after input in case autoplay was denied.
OS_JavaScript::get_singleton()->resume_audio(); OS_Web::get_singleton()->resume_audio();
// Make sure to flush all events so we can call restricted APIs inside the event. // Make sure to flush all events so we can call restricted APIs inside the event.
Input::get_singleton()->flush_buffered_events(); Input::get_singleton()->flush_buffered_events();
@ -209,7 +209,7 @@ int DisplayServerJavaScript::mouse_button_callback(int p_pressed, int p_button,
return true; return true;
} }
void DisplayServerJavaScript::mouse_move_callback(double p_x, double p_y, double p_rel_x, double p_rel_y, int p_modifiers) { void DisplayServerWeb::mouse_move_callback(double p_x, double p_y, double p_rel_x, double p_rel_y, int p_modifiers) {
MouseButton input_mask = Input::get_singleton()->get_mouse_button_mask(); MouseButton input_mask = Input::get_singleton()->get_mouse_button_mask();
// For motion outside the canvas, only read mouse movement if dragging // For motion outside the canvas, only read mouse movement if dragging
// started inside the canvas; imitating desktop app behaviour. // started inside the canvas; imitating desktop app behaviour.
@ -233,7 +233,7 @@ void DisplayServerJavaScript::mouse_move_callback(double p_x, double p_y, double
} }
// Cursor // Cursor
const char *DisplayServerJavaScript::godot2dom_cursor(DisplayServer::CursorShape p_shape) { const char *DisplayServerWeb::godot2dom_cursor(DisplayServer::CursorShape p_shape) {
switch (p_shape) { switch (p_shape) {
case DisplayServer::CURSOR_ARROW: case DisplayServer::CURSOR_ARROW:
return "default"; return "default";
@ -274,15 +274,15 @@ const char *DisplayServerJavaScript::godot2dom_cursor(DisplayServer::CursorShape
} }
} }
bool DisplayServerJavaScript::tts_is_speaking() const { bool DisplayServerWeb::tts_is_speaking() const {
return godot_js_tts_is_speaking(); return godot_js_tts_is_speaking();
} }
bool DisplayServerJavaScript::tts_is_paused() const { bool DisplayServerWeb::tts_is_paused() const {
return godot_js_tts_is_paused(); return godot_js_tts_is_paused();
} }
void DisplayServerJavaScript::update_voices_callback(int p_size, const char **p_voice) { void DisplayServerWeb::update_voices_callback(int p_size, const char **p_voice) {
get_singleton()->voices.clear(); get_singleton()->voices.clear();
for (int i = 0; i < p_size; i++) { for (int i = 0; i < p_size; i++) {
Vector<String> tokens = String::utf8(p_voice[i]).split(";", true, 2); Vector<String> tokens = String::utf8(p_voice[i]).split(";", true, 2);
@ -296,12 +296,12 @@ void DisplayServerJavaScript::update_voices_callback(int p_size, const char **p_
} }
} }
TypedArray<Dictionary> DisplayServerJavaScript::tts_get_voices() const { TypedArray<Dictionary> DisplayServerWeb::tts_get_voices() const {
godot_js_tts_get_voices(update_voices_callback); godot_js_tts_get_voices(update_voices_callback);
return voices; return voices;
} }
void DisplayServerJavaScript::tts_speak(const String &p_text, const String &p_voice, int p_volume, float p_pitch, float p_rate, int p_utterance_id, bool p_interrupt) { void DisplayServerWeb::tts_speak(const String &p_text, const String &p_voice, int p_volume, float p_pitch, float p_rate, int p_utterance_id, bool p_interrupt) {
if (p_interrupt) { if (p_interrupt) {
tts_stop(); tts_stop();
} }
@ -314,18 +314,18 @@ void DisplayServerJavaScript::tts_speak(const String &p_text, const String &p_vo
CharString string = p_text.utf8(); CharString string = p_text.utf8();
utterance_ids[p_utterance_id] = string; utterance_ids[p_utterance_id] = string;
godot_js_tts_speak(string.get_data(), p_voice.utf8().get_data(), CLAMP(p_volume, 0, 100), CLAMP(p_pitch, 0.f, 2.f), CLAMP(p_rate, 0.1f, 10.f), p_utterance_id, DisplayServerJavaScript::_js_utterance_callback); godot_js_tts_speak(string.get_data(), p_voice.utf8().get_data(), CLAMP(p_volume, 0, 100), CLAMP(p_pitch, 0.f, 2.f), CLAMP(p_rate, 0.1f, 10.f), p_utterance_id, DisplayServerWeb::_js_utterance_callback);
} }
void DisplayServerJavaScript::tts_pause() { void DisplayServerWeb::tts_pause() {
godot_js_tts_pause(); godot_js_tts_pause();
} }
void DisplayServerJavaScript::tts_resume() { void DisplayServerWeb::tts_resume() {
godot_js_tts_resume(); godot_js_tts_resume();
} }
void DisplayServerJavaScript::tts_stop() { void DisplayServerWeb::tts_stop() {
for (const KeyValue<int, CharString> &E : utterance_ids) { for (const KeyValue<int, CharString> &E : utterance_ids) {
tts_post_utterance_event(DisplayServer::TTS_UTTERANCE_CANCELED, E.key); tts_post_utterance_event(DisplayServer::TTS_UTTERANCE_CANCELED, E.key);
} }
@ -333,8 +333,8 @@ void DisplayServerJavaScript::tts_stop() {
godot_js_tts_stop(); godot_js_tts_stop();
} }
void DisplayServerJavaScript::_js_utterance_callback(int p_event, int p_id, int p_pos) { void DisplayServerWeb::_js_utterance_callback(int p_event, int p_id, int p_pos) {
DisplayServerJavaScript *ds = (DisplayServerJavaScript *)DisplayServer::get_singleton(); DisplayServerWeb *ds = (DisplayServerWeb *)DisplayServer::get_singleton();
if (ds->utterance_ids.has(p_id)) { if (ds->utterance_ids.has(p_id)) {
int pos = 0; int pos = 0;
if ((TTSUtteranceEvent)p_event == DisplayServer::TTS_UTTERANCE_BOUNDARY) { if ((TTSUtteranceEvent)p_event == DisplayServer::TTS_UTTERANCE_BOUNDARY) {
@ -358,7 +358,7 @@ void DisplayServerJavaScript::_js_utterance_callback(int p_event, int p_id, int
} }
} }
void DisplayServerJavaScript::cursor_set_shape(CursorShape p_shape) { void DisplayServerWeb::cursor_set_shape(CursorShape p_shape) {
ERR_FAIL_INDEX(p_shape, CURSOR_MAX); ERR_FAIL_INDEX(p_shape, CURSOR_MAX);
if (cursor_shape == p_shape) { if (cursor_shape == p_shape) {
return; return;
@ -367,11 +367,11 @@ void DisplayServerJavaScript::cursor_set_shape(CursorShape p_shape) {
godot_js_display_cursor_set_shape(godot2dom_cursor(cursor_shape)); godot_js_display_cursor_set_shape(godot2dom_cursor(cursor_shape));
} }
DisplayServer::CursorShape DisplayServerJavaScript::cursor_get_shape() const { DisplayServer::CursorShape DisplayServerWeb::cursor_get_shape() const {
return cursor_shape; return cursor_shape;
} }
void DisplayServerJavaScript::cursor_set_custom_image(const Ref<Resource> &p_cursor, CursorShape p_shape, const Vector2 &p_hotspot) { void DisplayServerWeb::cursor_set_custom_image(const Ref<Resource> &p_cursor, CursorShape p_shape, const Vector2 &p_hotspot) {
if (p_cursor.is_valid()) { if (p_cursor.is_valid()) {
Ref<Texture2D> texture = p_cursor; Ref<Texture2D> texture = p_cursor;
Ref<AtlasTexture> atlas_texture = p_cursor; Ref<AtlasTexture> atlas_texture = p_cursor;
@ -446,8 +446,8 @@ void DisplayServerJavaScript::cursor_set_custom_image(const Ref<Resource> &p_cur
} }
// Mouse mode // Mouse mode
void DisplayServerJavaScript::mouse_set_mode(MouseMode p_mode) { void DisplayServerWeb::mouse_set_mode(MouseMode p_mode) {
ERR_FAIL_COND_MSG(p_mode == MOUSE_MODE_CONFINED || p_mode == MOUSE_MODE_CONFINED_HIDDEN, "MOUSE_MODE_CONFINED is not supported for the HTML5 platform."); ERR_FAIL_COND_MSG(p_mode == MOUSE_MODE_CONFINED || p_mode == MOUSE_MODE_CONFINED_HIDDEN, "MOUSE_MODE_CONFINED is not supported for the Web platform.");
if (p_mode == mouse_get_mode()) { if (p_mode == mouse_get_mode()) {
return; return;
} }
@ -466,7 +466,7 @@ void DisplayServerJavaScript::mouse_set_mode(MouseMode p_mode) {
} }
} }
DisplayServer::MouseMode DisplayServerJavaScript::mouse_get_mode() const { DisplayServer::MouseMode DisplayServerWeb::mouse_get_mode() const {
if (godot_js_display_cursor_is_hidden()) { if (godot_js_display_cursor_is_hidden()) {
return MOUSE_MODE_HIDDEN; return MOUSE_MODE_HIDDEN;
} }
@ -477,12 +477,12 @@ DisplayServer::MouseMode DisplayServerJavaScript::mouse_get_mode() const {
return MOUSE_MODE_VISIBLE; return MOUSE_MODE_VISIBLE;
} }
Point2i DisplayServerJavaScript::mouse_get_position() const { Point2i DisplayServerWeb::mouse_get_position() const {
return Input::get_singleton()->get_mouse_position(); return Input::get_singleton()->get_mouse_position();
} }
// Wheel // Wheel
int DisplayServerJavaScript::mouse_wheel_callback(double p_delta_x, double p_delta_y) { int DisplayServerWeb::mouse_wheel_callback(double p_delta_x, double p_delta_y) {
if (!godot_js_display_canvas_is_focused()) { if (!godot_js_display_canvas_is_focused()) {
if (get_singleton()->cursor_inside_canvas) { if (get_singleton()->cursor_inside_canvas) {
godot_js_display_canvas_focus(); godot_js_display_canvas_focus();
@ -532,8 +532,8 @@ int DisplayServerJavaScript::mouse_wheel_callback(double p_delta_x, double p_del
} }
// Touch // Touch
void DisplayServerJavaScript::touch_callback(int p_type, int p_count) { void DisplayServerWeb::touch_callback(int p_type, int p_count) {
DisplayServerJavaScript *ds = get_singleton(); DisplayServerWeb *ds = get_singleton();
const JSTouchEvent &touch_event = ds->touch_event; const JSTouchEvent &touch_event = ds->touch_event;
for (int i = 0; i < p_count; i++) { for (int i = 0; i < p_count; i++) {
@ -555,7 +555,7 @@ void DisplayServerJavaScript::touch_callback(int p_type, int p_count) {
Ref<InputEventScreenTouch> ev; Ref<InputEventScreenTouch> ev;
// Resume audio context after input in case autoplay was denied. // Resume audio context after input in case autoplay was denied.
OS_JavaScript::get_singleton()->resume_audio(); OS_Web::get_singleton()->resume_audio();
ev.instantiate(); ev.instantiate();
ev->set_index(touch_event.identifier[i]); ev->set_index(touch_event.identifier[i]);
@ -571,13 +571,13 @@ void DisplayServerJavaScript::touch_callback(int p_type, int p_count) {
} }
} }
bool DisplayServerJavaScript::screen_is_touchscreen(int p_screen) const { bool DisplayServerWeb::screen_is_touchscreen(int p_screen) const {
return godot_js_display_touchscreen_is_available(); return godot_js_display_touchscreen_is_available();
} }
// Virtual Keyboard // Virtual Keyboard
void DisplayServerJavaScript::vk_input_text_callback(const char *p_text, int p_cursor) { void DisplayServerWeb::vk_input_text_callback(const char *p_text, int p_cursor) {
DisplayServerJavaScript *ds = DisplayServerJavaScript::get_singleton(); DisplayServerWeb *ds = DisplayServerWeb::get_singleton();
if (!ds || ds->input_text_callback.is_null()) { if (!ds || ds->input_text_callback.is_null()) {
return; return;
} }
@ -604,20 +604,20 @@ void DisplayServerJavaScript::vk_input_text_callback(const char *p_text, int p_c
} }
} }
void DisplayServerJavaScript::virtual_keyboard_show(const String &p_existing_text, const Rect2 &p_screen_rect, VirtualKeyboardType p_type, int p_max_input_length, int p_cursor_start, int p_cursor_end) { void DisplayServerWeb::virtual_keyboard_show(const String &p_existing_text, const Rect2 &p_screen_rect, VirtualKeyboardType p_type, int p_max_input_length, int p_cursor_start, int p_cursor_end) {
godot_js_display_vk_show(p_existing_text.utf8().get_data(), p_type, p_cursor_start, p_cursor_end); godot_js_display_vk_show(p_existing_text.utf8().get_data(), p_type, p_cursor_start, p_cursor_end);
} }
void DisplayServerJavaScript::virtual_keyboard_hide() { void DisplayServerWeb::virtual_keyboard_hide() {
godot_js_display_vk_hide(); godot_js_display_vk_hide();
} }
void DisplayServerJavaScript::window_blur_callback() { void DisplayServerWeb::window_blur_callback() {
Input::get_singleton()->release_pressed_events(); Input::get_singleton()->release_pressed_events();
} }
// Gamepad // Gamepad
void DisplayServerJavaScript::gamepad_callback(int p_index, int p_connected, const char *p_id, const char *p_guid) { void DisplayServerWeb::gamepad_callback(int p_index, int p_connected, const char *p_id, const char *p_guid) {
Input *input = Input::get_singleton(); Input *input = Input::get_singleton();
if (p_connected) { if (p_connected) {
input->joy_connection_changed(p_index, true, String::utf8(p_id), String::utf8(p_guid)); input->joy_connection_changed(p_index, true, String::utf8(p_id), String::utf8(p_guid));
@ -626,7 +626,7 @@ void DisplayServerJavaScript::gamepad_callback(int p_index, int p_connected, con
} }
} }
void DisplayServerJavaScript::process_joypads() { void DisplayServerWeb::process_joypads() {
Input *input = Input::get_singleton(); Input *input = Input::get_singleton();
int32_t pads = godot_js_input_gamepad_sample_count(); int32_t pads = godot_js_input_gamepad_sample_count();
int32_t s_btns_num = 0; int32_t s_btns_num = 0;
@ -654,7 +654,7 @@ void DisplayServerJavaScript::process_joypads() {
} }
} }
Vector<String> DisplayServerJavaScript::get_rendering_drivers_func() { Vector<String> DisplayServerWeb::get_rendering_drivers_func() {
Vector<String> drivers; Vector<String> drivers;
#ifdef GLES3_ENABLED #ifdef GLES3_ENABLED
drivers.push_back("opengl3"); drivers.push_back("opengl3");
@ -663,23 +663,23 @@ Vector<String> DisplayServerJavaScript::get_rendering_drivers_func() {
} }
// Clipboard // Clipboard
void DisplayServerJavaScript::update_clipboard_callback(const char *p_text) { void DisplayServerWeb::update_clipboard_callback(const char *p_text) {
get_singleton()->clipboard = String::utf8(p_text); get_singleton()->clipboard = String::utf8(p_text);
} }
void DisplayServerJavaScript::clipboard_set(const String &p_text) { void DisplayServerWeb::clipboard_set(const String &p_text) {
clipboard = p_text; clipboard = p_text;
int err = godot_js_display_clipboard_set(p_text.utf8().get_data()); int err = godot_js_display_clipboard_set(p_text.utf8().get_data());
ERR_FAIL_COND_MSG(err, "Clipboard API is not supported."); ERR_FAIL_COND_MSG(err, "Clipboard API is not supported.");
} }
String DisplayServerJavaScript::clipboard_get() const { String DisplayServerWeb::clipboard_get() const {
godot_js_display_clipboard_get(update_clipboard_callback); godot_js_display_clipboard_get(update_clipboard_callback);
return clipboard; return clipboard;
} }
void DisplayServerJavaScript::send_window_event_callback(int p_notification) { void DisplayServerWeb::send_window_event_callback(int p_notification) {
DisplayServerJavaScript *ds = get_singleton(); DisplayServerWeb *ds = get_singleton();
if (!ds) { if (!ds) {
return; return;
} }
@ -695,7 +695,7 @@ void DisplayServerJavaScript::send_window_event_callback(int p_notification) {
} }
} }
void DisplayServerJavaScript::set_icon(const Ref<Image> &p_icon) { void DisplayServerWeb::set_icon(const Ref<Image> &p_icon) {
ERR_FAIL_COND(p_icon.is_null()); ERR_FAIL_COND(p_icon.is_null());
Ref<Image> icon = p_icon; Ref<Image> icon = p_icon;
if (icon->is_compressed()) { if (icon->is_compressed()) {
@ -727,7 +727,7 @@ void DisplayServerJavaScript::set_icon(const Ref<Image> &p_icon) {
godot_js_display_window_icon_set(png.ptr(), len); godot_js_display_window_icon_set(png.ptr(), len);
} }
void DisplayServerJavaScript::_dispatch_input_event(const Ref<InputEvent> &p_event) { void DisplayServerWeb::_dispatch_input_event(const Ref<InputEvent> &p_event) {
Callable cb = get_singleton()->input_event_callback; Callable cb = get_singleton()->input_event_callback;
if (!cb.is_null()) { if (!cb.is_null()) {
Variant ev = p_event; Variant ev = p_event;
@ -738,11 +738,11 @@ void DisplayServerJavaScript::_dispatch_input_event(const Ref<InputEvent> &p_eve
} }
} }
DisplayServer *DisplayServerJavaScript::create_func(const String &p_rendering_driver, WindowMode p_window_mode, VSyncMode p_vsync_mode, uint32_t p_flags, const Size2i &p_resolution, Error &r_error) { DisplayServer *DisplayServerWeb::create_func(const String &p_rendering_driver, WindowMode p_window_mode, VSyncMode p_vsync_mode, uint32_t p_flags, const Size2i &p_resolution, Error &r_error) {
return memnew(DisplayServerJavaScript(p_rendering_driver, p_window_mode, p_vsync_mode, p_flags, p_resolution, r_error)); return memnew(DisplayServerWeb(p_rendering_driver, p_window_mode, p_vsync_mode, p_flags, p_resolution, r_error));
} }
DisplayServerJavaScript::DisplayServerJavaScript(const String &p_rendering_driver, WindowMode p_window_mode, VSyncMode p_vsync_mode, uint32_t p_flags, const Size2i &p_resolution, Error &r_error) { DisplayServerWeb::DisplayServerWeb(const String &p_rendering_driver, WindowMode p_window_mode, VSyncMode p_vsync_mode, uint32_t p_flags, const Size2i &p_resolution, Error &r_error) {
r_error = OK; // Always succeeds for now. r_error = OK; // Always succeeds for now.
// Ensure the canvas ID. // Ensure the canvas ID.
@ -788,17 +788,17 @@ DisplayServerJavaScript::DisplayServerJavaScript(const String &p_rendering_drive
#endif #endif
// JS Input interface (js/libs/library_godot_input.js) // JS Input interface (js/libs/library_godot_input.js)
godot_js_input_mouse_button_cb(&DisplayServerJavaScript::mouse_button_callback); godot_js_input_mouse_button_cb(&DisplayServerWeb::mouse_button_callback);
godot_js_input_mouse_move_cb(&DisplayServerJavaScript::mouse_move_callback); godot_js_input_mouse_move_cb(&DisplayServerWeb::mouse_move_callback);
godot_js_input_mouse_wheel_cb(&DisplayServerJavaScript::mouse_wheel_callback); godot_js_input_mouse_wheel_cb(&DisplayServerWeb::mouse_wheel_callback);
godot_js_input_touch_cb(&DisplayServerJavaScript::touch_callback, touch_event.identifier, touch_event.coords); godot_js_input_touch_cb(&DisplayServerWeb::touch_callback, touch_event.identifier, touch_event.coords);
godot_js_input_key_cb(&DisplayServerJavaScript::key_callback, key_event.code, key_event.key); godot_js_input_key_cb(&DisplayServerWeb::key_callback, key_event.code, key_event.key);
godot_js_input_paste_cb(update_clipboard_callback); godot_js_input_paste_cb(update_clipboard_callback);
godot_js_input_drop_files_cb(drop_files_js_callback); godot_js_input_drop_files_cb(drop_files_js_callback);
godot_js_input_gamepad_cb(&DisplayServerJavaScript::gamepad_callback); godot_js_input_gamepad_cb(&DisplayServerWeb::gamepad_callback);
// JS Display interface (js/libs/library_godot_display.js) // JS Display interface (js/libs/library_godot_display.js)
godot_js_display_fullscreen_cb(&DisplayServerJavaScript::fullscreen_change_callback); godot_js_display_fullscreen_cb(&DisplayServerWeb::fullscreen_change_callback);
godot_js_display_window_blur_cb(&window_blur_callback); godot_js_display_window_blur_cb(&window_blur_callback);
godot_js_display_notification_cb(&send_window_event_callback, godot_js_display_notification_cb(&send_window_event_callback,
WINDOW_EVENT_MOUSE_ENTER, WINDOW_EVENT_MOUSE_ENTER,
@ -810,7 +810,7 @@ DisplayServerJavaScript::DisplayServerJavaScript(const String &p_rendering_drive
Input::get_singleton()->set_event_dispatch_function(_dispatch_input_event); Input::get_singleton()->set_event_dispatch_function(_dispatch_input_event);
} }
DisplayServerJavaScript::~DisplayServerJavaScript() { DisplayServerWeb::~DisplayServerWeb() {
#ifdef GLES3_ENABLED #ifdef GLES3_ENABLED
if (webgl_ctx) { if (webgl_ctx) {
emscripten_webgl_commit_frame(); emscripten_webgl_commit_frame();
@ -819,7 +819,7 @@ DisplayServerJavaScript::~DisplayServerJavaScript() {
#endif #endif
} }
bool DisplayServerJavaScript::has_feature(Feature p_feature) const { bool DisplayServerWeb::has_feature(Feature p_feature) const {
switch (p_feature) { switch (p_feature) {
//case FEATURE_GLOBAL_MENU: //case FEATURE_GLOBAL_MENU:
//case FEATURE_HIDPI: //case FEATURE_HIDPI:
@ -846,139 +846,139 @@ bool DisplayServerJavaScript::has_feature(Feature p_feature) const {
} }
} }
void DisplayServerJavaScript::register_javascript_driver() { void DisplayServerWeb::register_web_driver() {
register_create_function("javascript", create_func, get_rendering_drivers_func); register_create_function("web", create_func, get_rendering_drivers_func);
} }
String DisplayServerJavaScript::get_name() const { String DisplayServerWeb::get_name() const {
return "javascript"; return "web";
} }
int DisplayServerJavaScript::get_screen_count() const { int DisplayServerWeb::get_screen_count() const {
return 1; return 1;
} }
Point2i DisplayServerJavaScript::screen_get_position(int p_screen) const { Point2i DisplayServerWeb::screen_get_position(int p_screen) const {
return Point2i(); // TODO offsetX/Y? return Point2i(); // TODO offsetX/Y?
} }
Size2i DisplayServerJavaScript::screen_get_size(int p_screen) const { Size2i DisplayServerWeb::screen_get_size(int p_screen) const {
int size[2]; int size[2];
godot_js_display_screen_size_get(size, size + 1); godot_js_display_screen_size_get(size, size + 1);
return Size2(size[0], size[1]); return Size2(size[0], size[1]);
} }
Rect2i DisplayServerJavaScript::screen_get_usable_rect(int p_screen) const { Rect2i DisplayServerWeb::screen_get_usable_rect(int p_screen) const {
int size[2]; int size[2];
godot_js_display_window_size_get(size, size + 1); godot_js_display_window_size_get(size, size + 1);
return Rect2i(0, 0, size[0], size[1]); return Rect2i(0, 0, size[0], size[1]);
} }
int DisplayServerJavaScript::screen_get_dpi(int p_screen) const { int DisplayServerWeb::screen_get_dpi(int p_screen) const {
return godot_js_display_screen_dpi_get(); return godot_js_display_screen_dpi_get();
} }
float DisplayServerJavaScript::screen_get_scale(int p_screen) const { float DisplayServerWeb::screen_get_scale(int p_screen) const {
return godot_js_display_pixel_ratio_get(); return godot_js_display_pixel_ratio_get();
} }
float DisplayServerJavaScript::screen_get_refresh_rate(int p_screen) const { float DisplayServerWeb::screen_get_refresh_rate(int p_screen) const {
return SCREEN_REFRESH_RATE_FALLBACK; // Javascript doesn't have much of a need for the screen refresh rate, and there's no native way to do so. return SCREEN_REFRESH_RATE_FALLBACK; // Web doesn't have much of a need for the screen refresh rate, and there's no native way to do so.
} }
Vector<DisplayServer::WindowID> DisplayServerJavaScript::get_window_list() const { Vector<DisplayServer::WindowID> DisplayServerWeb::get_window_list() const {
Vector<WindowID> ret; Vector<WindowID> ret;
ret.push_back(MAIN_WINDOW_ID); ret.push_back(MAIN_WINDOW_ID);
return ret; return ret;
} }
DisplayServerJavaScript::WindowID DisplayServerJavaScript::get_window_at_screen_position(const Point2i &p_position) const { DisplayServerWeb::WindowID DisplayServerWeb::get_window_at_screen_position(const Point2i &p_position) const {
return MAIN_WINDOW_ID; return MAIN_WINDOW_ID;
} }
void DisplayServerJavaScript::window_attach_instance_id(ObjectID p_instance, WindowID p_window) { void DisplayServerWeb::window_attach_instance_id(ObjectID p_instance, WindowID p_window) {
window_attached_instance_id = p_instance; window_attached_instance_id = p_instance;
} }
ObjectID DisplayServerJavaScript::window_get_attached_instance_id(WindowID p_window) const { ObjectID DisplayServerWeb::window_get_attached_instance_id(WindowID p_window) const {
return window_attached_instance_id; return window_attached_instance_id;
} }
void DisplayServerJavaScript::window_set_rect_changed_callback(const Callable &p_callable, WindowID p_window) { void DisplayServerWeb::window_set_rect_changed_callback(const Callable &p_callable, WindowID p_window) {
// Not supported. // Not supported.
} }
void DisplayServerJavaScript::window_set_window_event_callback(const Callable &p_callable, WindowID p_window) { void DisplayServerWeb::window_set_window_event_callback(const Callable &p_callable, WindowID p_window) {
window_event_callback = p_callable; window_event_callback = p_callable;
} }
void DisplayServerJavaScript::window_set_input_event_callback(const Callable &p_callable, WindowID p_window) { void DisplayServerWeb::window_set_input_event_callback(const Callable &p_callable, WindowID p_window) {
input_event_callback = p_callable; input_event_callback = p_callable;
} }
void DisplayServerJavaScript::window_set_input_text_callback(const Callable &p_callable, WindowID p_window) { void DisplayServerWeb::window_set_input_text_callback(const Callable &p_callable, WindowID p_window) {
input_text_callback = p_callable; input_text_callback = p_callable;
} }
void DisplayServerJavaScript::window_set_drop_files_callback(const Callable &p_callable, WindowID p_window) { void DisplayServerWeb::window_set_drop_files_callback(const Callable &p_callable, WindowID p_window) {
drop_files_callback = p_callable; drop_files_callback = p_callable;
} }
void DisplayServerJavaScript::window_set_title(const String &p_title, WindowID p_window) { void DisplayServerWeb::window_set_title(const String &p_title, WindowID p_window) {
godot_js_display_window_title_set(p_title.utf8().get_data()); godot_js_display_window_title_set(p_title.utf8().get_data());
} }
int DisplayServerJavaScript::window_get_current_screen(WindowID p_window) const { int DisplayServerWeb::window_get_current_screen(WindowID p_window) const {
return 1; return 1;
} }
void DisplayServerJavaScript::window_set_current_screen(int p_screen, WindowID p_window) { void DisplayServerWeb::window_set_current_screen(int p_screen, WindowID p_window) {
// Not implemented. // Not implemented.
} }
Point2i DisplayServerJavaScript::window_get_position(WindowID p_window) const { Point2i DisplayServerWeb::window_get_position(WindowID p_window) const {
return Point2i(); // TODO Does this need implementation? return Point2i(); // TODO Does this need implementation?
} }
void DisplayServerJavaScript::window_set_position(const Point2i &p_position, WindowID p_window) { void DisplayServerWeb::window_set_position(const Point2i &p_position, WindowID p_window) {
// Not supported. // Not supported.
} }
void DisplayServerJavaScript::window_set_transient(WindowID p_window, WindowID p_parent) { void DisplayServerWeb::window_set_transient(WindowID p_window, WindowID p_parent) {
// Not supported. // Not supported.
} }
void DisplayServerJavaScript::window_set_max_size(const Size2i p_size, WindowID p_window) { void DisplayServerWeb::window_set_max_size(const Size2i p_size, WindowID p_window) {
// Not supported. // Not supported.
} }
Size2i DisplayServerJavaScript::window_get_max_size(WindowID p_window) const { Size2i DisplayServerWeb::window_get_max_size(WindowID p_window) const {
return Size2i(); return Size2i();
} }
void DisplayServerJavaScript::window_set_min_size(const Size2i p_size, WindowID p_window) { void DisplayServerWeb::window_set_min_size(const Size2i p_size, WindowID p_window) {
// Not supported. // Not supported.
} }
Size2i DisplayServerJavaScript::window_get_min_size(WindowID p_window) const { Size2i DisplayServerWeb::window_get_min_size(WindowID p_window) const {
return Size2i(); return Size2i();
} }
void DisplayServerJavaScript::window_set_size(const Size2i p_size, WindowID p_window) { void DisplayServerWeb::window_set_size(const Size2i p_size, WindowID p_window) {
godot_js_display_desired_size_set(p_size.x, p_size.y); godot_js_display_desired_size_set(p_size.x, p_size.y);
} }
Size2i DisplayServerJavaScript::window_get_size(WindowID p_window) const { Size2i DisplayServerWeb::window_get_size(WindowID p_window) const {
int size[2]; int size[2];
godot_js_display_window_size_get(size, size + 1); godot_js_display_window_size_get(size, size + 1);
return Size2i(size[0], size[1]); return Size2i(size[0], size[1]);
} }
Size2i DisplayServerJavaScript::window_get_real_size(WindowID p_window) const { Size2i DisplayServerWeb::window_get_real_size(WindowID p_window) const {
return window_get_size(p_window); return window_get_size(p_window);
} }
void DisplayServerJavaScript::window_set_mode(WindowMode p_mode, WindowID p_window) { void DisplayServerWeb::window_set_mode(WindowMode p_mode, WindowID p_window) {
if (window_mode == p_mode) { if (window_mode == p_mode) {
return; return;
} }
@ -993,65 +993,65 @@ void DisplayServerJavaScript::window_set_mode(WindowMode p_mode, WindowID p_wind
case WINDOW_MODE_EXCLUSIVE_FULLSCREEN: case WINDOW_MODE_EXCLUSIVE_FULLSCREEN:
case WINDOW_MODE_FULLSCREEN: { case WINDOW_MODE_FULLSCREEN: {
int result = godot_js_display_fullscreen_request(); int result = godot_js_display_fullscreen_request();
ERR_FAIL_COND_MSG(result, "The request was denied. Remember that enabling fullscreen is only possible from an input callback for the HTML5 platform."); ERR_FAIL_COND_MSG(result, "The request was denied. Remember that enabling fullscreen is only possible from an input callback for the Web platform.");
} break; } break;
case WINDOW_MODE_MAXIMIZED: case WINDOW_MODE_MAXIMIZED:
case WINDOW_MODE_MINIMIZED: case WINDOW_MODE_MINIMIZED:
WARN_PRINT("WindowMode MAXIMIZED and MINIMIZED are not supported in HTML5 platform."); WARN_PRINT("WindowMode MAXIMIZED and MINIMIZED are not supported in Web platform.");
break; break;
default: default:
break; break;
} }
} }
DisplayServerJavaScript::WindowMode DisplayServerJavaScript::window_get_mode(WindowID p_window) const { DisplayServerWeb::WindowMode DisplayServerWeb::window_get_mode(WindowID p_window) const {
return window_mode; return window_mode;
} }
bool DisplayServerJavaScript::window_is_maximize_allowed(WindowID p_window) const { bool DisplayServerWeb::window_is_maximize_allowed(WindowID p_window) const {
return false; return false;
} }
void DisplayServerJavaScript::window_set_flag(WindowFlags p_flag, bool p_enabled, WindowID p_window) { void DisplayServerWeb::window_set_flag(WindowFlags p_flag, bool p_enabled, WindowID p_window) {
// Not supported. // Not supported.
} }
bool DisplayServerJavaScript::window_get_flag(WindowFlags p_flag, WindowID p_window) const { bool DisplayServerWeb::window_get_flag(WindowFlags p_flag, WindowID p_window) const {
return false; return false;
} }
void DisplayServerJavaScript::window_request_attention(WindowID p_window) { void DisplayServerWeb::window_request_attention(WindowID p_window) {
// Not supported. // Not supported.
} }
void DisplayServerJavaScript::window_move_to_foreground(WindowID p_window) { void DisplayServerWeb::window_move_to_foreground(WindowID p_window) {
// Not supported. // Not supported.
} }
bool DisplayServerJavaScript::window_can_draw(WindowID p_window) const { bool DisplayServerWeb::window_can_draw(WindowID p_window) const {
return true; return true;
} }
bool DisplayServerJavaScript::can_any_window_draw() const { bool DisplayServerWeb::can_any_window_draw() const {
return true; return true;
} }
void DisplayServerJavaScript::process_events() { void DisplayServerWeb::process_events() {
Input::get_singleton()->flush_buffered_events(); Input::get_singleton()->flush_buffered_events();
if (godot_js_input_gamepad_sample() == OK) { if (godot_js_input_gamepad_sample() == OK) {
process_joypads(); process_joypads();
} }
} }
int DisplayServerJavaScript::get_current_video_driver() const { int DisplayServerWeb::get_current_video_driver() const {
return 1; return 1;
} }
bool DisplayServerJavaScript::get_swap_cancel_ok() { bool DisplayServerWeb::get_swap_cancel_ok() {
return swap_cancel_ok; return swap_cancel_ok;
} }
void DisplayServerJavaScript::swap_buffers() { void DisplayServerWeb::swap_buffers() {
#ifdef GLES3_ENABLED #ifdef GLES3_ENABLED
if (webgl_ctx) { if (webgl_ctx) {
emscripten_webgl_commit_frame(); emscripten_webgl_commit_frame();

View File

@ -1,5 +1,5 @@
/*************************************************************************/ /*************************************************************************/
/* display_server_javascript.h */ /* display_server_web.h */
/*************************************************************************/ /*************************************************************************/
/* This file is part of: */ /* This file is part of: */
/* GODOT ENGINE */ /* GODOT ENGINE */
@ -28,15 +28,15 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/ /*************************************************************************/
#ifndef DISPLAY_SERVER_JAVASCRIPT_H #ifndef DISPLAY_SERVER_WEB_H
#define DISPLAY_SERVER_JAVASCRIPT_H #define DISPLAY_SERVER_WEB_H
#include "servers/display_server.h" #include "servers/display_server.h"
#include <emscripten.h> #include <emscripten.h>
#include <emscripten/html5.h> #include <emscripten/html5.h>
class DisplayServerJavaScript : public DisplayServer { class DisplayServerWeb : public DisplayServer {
private: private:
struct JSTouchEvent { struct JSTouchEvent {
uint32_t identifier[32] = { 0 }; uint32_t identifier[32] = { 0 };
@ -112,7 +112,7 @@ protected:
public: public:
// Override return type to make writing static callbacks less tedious. // Override return type to make writing static callbacks less tedious.
static DisplayServerJavaScript *get_singleton(); static DisplayServerWeb *get_singleton();
// utilities // utilities
bool check_size_force_redraw(); bool check_size_force_redraw();
@ -220,9 +220,9 @@ public:
virtual bool get_swap_cancel_ok() override; virtual bool get_swap_cancel_ok() override;
virtual void swap_buffers() override; virtual void swap_buffers() override;
static void register_javascript_driver(); static void register_web_driver();
DisplayServerJavaScript(const String &p_rendering_driver, WindowMode p_window_mode, VSyncMode p_vsync_mode, uint32_t p_flags, const Size2i &p_resolution, Error &r_error); DisplayServerWeb(const String &p_rendering_driver, WindowMode p_window_mode, VSyncMode p_vsync_mode, uint32_t p_flags, const Size2i &p_resolution, Error &r_error);
~DisplayServerJavaScript(); ~DisplayServerWeb();
}; };
#endif // DISPLAY_SERVER_JAVASCRIPT_H #endif // DISPLAY_SERVER_WEB_H

View File

@ -39,11 +39,11 @@ def create_engine_file(env, target, source, externs):
def create_template_zip(env, js, wasm, extra): def create_template_zip(env, js, wasm, extra):
binary_name = "godot.tools" if env["tools"] else "godot" binary_name = "godot.tools" if env["tools"] else "godot"
zip_dir = env.Dir("#bin/.javascript_zip") zip_dir = env.Dir("#bin/.web_zip")
in_files = [ in_files = [
js, js,
wasm, wasm,
"#platform/javascript/js/libs/audio.worklet.js", "#platform/web/js/libs/audio.worklet.js",
] ]
out_files = [ out_files = [
zip_dir.File(binary_name + ".js"), zip_dir.File(binary_name + ".js"),

View File

@ -1,5 +1,5 @@
/*************************************************************************/ /*************************************************************************/
/* export_server.h */ /* editor_http_server.h */
/*************************************************************************/ /*************************************************************************/
/* This file is part of: */ /* This file is part of: */
/* GODOT ENGINE */ /* GODOT ENGINE */
@ -28,8 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/ /*************************************************************************/
#ifndef JAVASCRIPT_EXPORT_SERVER_H #ifndef WEB_EDITOR_HTTP_SERVER_H
#define JAVASCRIPT_EXPORT_SERVER_H #define WEB_EDITOR_HTTP_SERVER_H
#include "core/io/image_loader.h" #include "core/io/image_loader.h"
#include "core/io/stream_peer_ssl.h" #include "core/io/stream_peer_ssl.h"
@ -247,4 +247,4 @@ public:
} }
}; };
#endif // JAVASCRIPT_EXPORT_SERVER_H #endif // WEB_EDITOR_HTTP_SERVER_H

View File

@ -33,7 +33,7 @@
#include "editor/editor_settings.h" #include "editor/editor_settings.h"
#include "export_plugin.h" #include "export_plugin.h"
void register_javascript_exporter() { void register_web_exporter() {
EDITOR_DEF("export/web/http_host", "localhost"); EDITOR_DEF("export/web/http_host", "localhost");
EDITOR_DEF("export/web/http_port", 8060); EDITOR_DEF("export/web/http_port", 8060);
EDITOR_DEF("export/web/use_ssl", false); EDITOR_DEF("export/web/use_ssl", false);
@ -43,7 +43,7 @@ void register_javascript_exporter() {
EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING, "export/web/ssl_key", PROPERTY_HINT_GLOBAL_FILE, "*.key")); EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING, "export/web/ssl_key", PROPERTY_HINT_GLOBAL_FILE, "*.key"));
EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING, "export/web/ssl_certificate", PROPERTY_HINT_GLOBAL_FILE, "*.crt,*.pem")); EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING, "export/web/ssl_certificate", PROPERTY_HINT_GLOBAL_FILE, "*.crt,*.pem"));
Ref<EditorExportPlatformJavaScript> platform; Ref<EditorExportPlatformWeb> platform;
platform.instantiate(); platform.instantiate();
EditorExport::get_singleton()->add_export_platform(platform); EditorExport::get_singleton()->add_export_platform(platform);
} }

View File

@ -28,9 +28,9 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/ /*************************************************************************/
#ifndef JAVASCRIPT_EXPORT_H #ifndef WEB_EXPORT_H
#define JAVASCRIPT_EXPORT_H #define WEB_EXPORT_H
void register_javascript_exporter(); void register_web_exporter();
#endif // JAVASCRIPT_EXPORT_H #endif // WEB_EXPORT_H

View File

@ -33,7 +33,7 @@
#include "core/config/project_settings.h" #include "core/config/project_settings.h"
#include "editor/editor_settings.h" #include "editor/editor_settings.h"
Error EditorExportPlatformJavaScript::_extract_template(const String &p_template, const String &p_dir, const String &p_name, bool pwa) { Error EditorExportPlatformWeb::_extract_template(const String &p_template, const String &p_dir, const String &p_name, bool pwa) {
Ref<FileAccess> io_fa; Ref<FileAccess> io_fa;
zlib_filefunc_def io = zipio_create_io(&io_fa); zlib_filefunc_def io = zipio_create_io(&io_fa);
unzFile pkg = unzOpen2(p_template.utf8().get_data(), &io); unzFile pkg = unzOpen2(p_template.utf8().get_data(), &io);
@ -89,7 +89,7 @@ Error EditorExportPlatformJavaScript::_extract_template(const String &p_template
return OK; return OK;
} }
Error EditorExportPlatformJavaScript::_write_or_error(const uint8_t *p_content, int p_size, String p_path) { Error EditorExportPlatformWeb::_write_or_error(const uint8_t *p_content, int p_size, String p_path) {
Ref<FileAccess> f = FileAccess::open(p_path, FileAccess::WRITE); Ref<FileAccess> f = FileAccess::open(p_path, FileAccess::WRITE);
if (f.is_null()) { if (f.is_null()) {
add_message(EXPORT_MESSAGE_ERROR, TTR("Export"), vformat(TTR("Could not write file: \"%s\"."), p_path)); add_message(EXPORT_MESSAGE_ERROR, TTR("Export"), vformat(TTR("Could not write file: \"%s\"."), p_path));
@ -99,7 +99,7 @@ Error EditorExportPlatformJavaScript::_write_or_error(const uint8_t *p_content,
return OK; return OK;
} }
void EditorExportPlatformJavaScript::_replace_strings(HashMap<String, String> p_replaces, Vector<uint8_t> &r_template) { void EditorExportPlatformWeb::_replace_strings(HashMap<String, String> p_replaces, Vector<uint8_t> &r_template) {
String str_template = String::utf8(reinterpret_cast<const char *>(r_template.ptr()), r_template.size()); String str_template = String::utf8(reinterpret_cast<const char *>(r_template.ptr()), r_template.size());
String out; String out;
Vector<String> lines = str_template.split("\n"); Vector<String> lines = str_template.split("\n");
@ -117,7 +117,7 @@ void EditorExportPlatformJavaScript::_replace_strings(HashMap<String, String> p_
} }
} }
void EditorExportPlatformJavaScript::_fix_html(Vector<uint8_t> &p_html, const Ref<EditorExportPreset> &p_preset, const String &p_name, bool p_debug, int p_flags, const Vector<SharedObject> p_shared_objects, const Dictionary &p_file_sizes) { void EditorExportPlatformWeb::_fix_html(Vector<uint8_t> &p_html, const Ref<EditorExportPreset> &p_preset, const String &p_name, bool p_debug, int p_flags, const Vector<SharedObject> p_shared_objects, const Dictionary &p_file_sizes) {
// Engine.js config // Engine.js config
Dictionary config; Dictionary config;
Array libs; Array libs;
@ -159,7 +159,7 @@ void EditorExportPlatformJavaScript::_fix_html(Vector<uint8_t> &p_html, const Re
_replace_strings(replaces, p_html); _replace_strings(replaces, p_html);
} }
Error EditorExportPlatformJavaScript::_add_manifest_icon(const String &p_path, const String &p_icon, int p_size, Array &r_arr) { Error EditorExportPlatformWeb::_add_manifest_icon(const String &p_path, const String &p_icon, int p_size, Array &r_arr) {
const String name = p_path.get_file().get_basename(); const String name = p_path.get_file().get_basename();
const String icon_name = vformat("%s.%dx%d.png", name, p_size, p_size); const String icon_name = vformat("%s.%dx%d.png", name, p_size, p_size);
const String icon_dest = p_path.get_base_dir().plus_file(icon_name); const String icon_dest = p_path.get_base_dir().plus_file(icon_name);
@ -192,7 +192,7 @@ Error EditorExportPlatformJavaScript::_add_manifest_icon(const String &p_path, c
return err; return err;
} }
Error EditorExportPlatformJavaScript::_build_pwa(const Ref<EditorExportPreset> &p_preset, const String p_path, const Vector<SharedObject> &p_shared_objects) { Error EditorExportPlatformWeb::_build_pwa(const Ref<EditorExportPreset> &p_preset, const String p_path, const Vector<SharedObject> &p_shared_objects) {
String proj_name = ProjectSettings::get_singleton()->get_setting("application/config/name"); String proj_name = ProjectSettings::get_singleton()->get_setting("application/config/name");
if (proj_name.is_empty()) { if (proj_name.is_empty()) {
proj_name = "Godot Game"; proj_name = "Godot Game";
@ -303,7 +303,7 @@ Error EditorExportPlatformJavaScript::_build_pwa(const Ref<EditorExportPreset> &
return OK; return OK;
} }
void EditorExportPlatformJavaScript::get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features) const { void EditorExportPlatformWeb::get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features) const {
if (p_preset->get("vram_texture_compression/for_desktop")) { if (p_preset->get("vram_texture_compression/for_desktop")) {
r_features->push_back("s3tc"); r_features->push_back("s3tc");
} }
@ -326,7 +326,7 @@ void EditorExportPlatformJavaScript::get_preset_features(const Ref<EditorExportP
} }
} }
void EditorExportPlatformJavaScript::get_export_options(List<ExportOption> *r_options) { void EditorExportPlatformWeb::get_export_options(List<ExportOption> *r_options) {
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_template/debug", PROPERTY_HINT_GLOBAL_FILE, "*.zip"), "")); r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_template/debug", PROPERTY_HINT_GLOBAL_FILE, "*.zip"), ""));
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_template/release", PROPERTY_HINT_GLOBAL_FILE, "*.zip"), "")); r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_template/release", PROPERTY_HINT_GLOBAL_FILE, "*.zip"), ""));
@ -350,25 +350,25 @@ void EditorExportPlatformJavaScript::get_export_options(List<ExportOption> *r_op
r_options->push_back(ExportOption(PropertyInfo(Variant::COLOR, "progressive_web_app/background_color", PROPERTY_HINT_COLOR_NO_ALPHA), Color())); r_options->push_back(ExportOption(PropertyInfo(Variant::COLOR, "progressive_web_app/background_color", PROPERTY_HINT_COLOR_NO_ALPHA), Color()));
} }
String EditorExportPlatformJavaScript::get_name() const { String EditorExportPlatformWeb::get_name() const {
return "HTML5"; return "Web";
} }
String EditorExportPlatformJavaScript::get_os_name() const { String EditorExportPlatformWeb::get_os_name() const {
return "HTML5"; return "Web";
} }
Ref<Texture2D> EditorExportPlatformJavaScript::get_logo() const { Ref<Texture2D> EditorExportPlatformWeb::get_logo() const {
return logo; return logo;
} }
bool EditorExportPlatformJavaScript::has_valid_export_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const { bool EditorExportPlatformWeb::has_valid_export_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const {
#ifndef DEV_ENABLED #ifndef DEV_ENABLED
// We don't provide export templates for the HTML5 platform currently as there // We don't provide export templates for the Web platform currently as there
// is no suitable renderer to use with them. So we forbid exporting and tell // is no suitable renderer to use with them. So we forbid exporting and tell
// users why. This is skipped in DEV_ENABLED so that contributors can still test // users why. This is skipped in DEV_ENABLED so that contributors can still test
// the pipeline once we start having WebGL or WebGPU support. // the pipeline once we start having WebGL or WebGPU support.
r_error = "The HTML5 platform is currently not supported in Godot 4.0, as there is no suitable renderer for it.\n"; r_error = "The Web platform is currently not supported in Godot 4.0, as there is no suitable renderer for it.\n";
return false; return false;
#endif #endif
@ -403,13 +403,13 @@ bool EditorExportPlatformJavaScript::has_valid_export_configuration(const Ref<Ed
return valid; return valid;
} }
bool EditorExportPlatformJavaScript::has_valid_project_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error) const { bool EditorExportPlatformWeb::has_valid_project_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error) const {
#ifndef DEV_ENABLED #ifndef DEV_ENABLED
// We don't provide export templates for the HTML5 platform currently as there // We don't provide export templates for the Web platform currently as there
// is no suitable renderer to use with them. So we forbid exporting and tell // is no suitable renderer to use with them. So we forbid exporting and tell
// users why. This is skipped in DEV_ENABLED so that contributors can still test // users why. This is skipped in DEV_ENABLED so that contributors can still test
// the pipeline once we start having WebGL or WebGPU support. // the pipeline once we start having WebGL or WebGPU support.
r_error = "The HTML5 platform is currently not supported in Godot 4.0, as there is no suitable renderer for it.\n"; r_error = "The Web platform is currently not supported in Godot 4.0, as there is no suitable renderer for it.\n";
return false; return false;
#endif #endif
@ -433,13 +433,13 @@ bool EditorExportPlatformJavaScript::has_valid_project_configuration(const Ref<E
return valid; return valid;
} }
List<String> EditorExportPlatformJavaScript::get_binary_extensions(const Ref<EditorExportPreset> &p_preset) const { List<String> EditorExportPlatformWeb::get_binary_extensions(const Ref<EditorExportPreset> &p_preset) const {
List<String> list; List<String> list;
list.push_back("html"); list.push_back("html");
return list; return list;
} }
Error EditorExportPlatformJavaScript::export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags) { Error EditorExportPlatformWeb::export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags) {
ExportNotifier notifier(*this, p_preset, p_debug, p_path, p_flags); ExportNotifier notifier(*this, p_preset, p_debug, p_path, p_flags);
const String custom_debug = p_preset->get("custom_template/debug"); const String custom_debug = p_preset->get("custom_template/debug");
@ -562,7 +562,7 @@ Error EditorExportPlatformJavaScript::export_project(const Ref<EditorExportPrese
return OK; return OK;
} }
bool EditorExportPlatformJavaScript::poll_export() { bool EditorExportPlatformWeb::poll_export() {
Ref<EditorExportPreset> preset; Ref<EditorExportPreset> preset;
for (int i = 0; i < EditorExport::get_singleton()->get_export_preset_count(); i++) { for (int i = 0; i < EditorExport::get_singleton()->get_export_preset_count(); i++) {
@ -586,15 +586,15 @@ bool EditorExportPlatformJavaScript::poll_export() {
return menu_options != prev; return menu_options != prev;
} }
Ref<ImageTexture> EditorExportPlatformJavaScript::get_option_icon(int p_index) const { Ref<ImageTexture> EditorExportPlatformWeb::get_option_icon(int p_index) const {
return p_index == 1 ? stop_icon : EditorExportPlatform::get_option_icon(p_index); return p_index == 1 ? stop_icon : EditorExportPlatform::get_option_icon(p_index);
} }
int EditorExportPlatformJavaScript::get_options_count() const { int EditorExportPlatformWeb::get_options_count() const {
return menu_options; return menu_options;
} }
Error EditorExportPlatformJavaScript::run(const Ref<EditorExportPreset> &p_preset, int p_option, int p_debug_flags) { Error EditorExportPlatformWeb::run(const Ref<EditorExportPreset> &p_preset, int p_option, int p_debug_flags) {
if (p_option == 1) { if (p_option == 1) {
MutexLock lock(server_lock); MutexLock lock(server_lock);
server->stop(); server->stop();
@ -663,12 +663,12 @@ Error EditorExportPlatformJavaScript::run(const Ref<EditorExportPreset> &p_prese
return OK; return OK;
} }
Ref<Texture2D> EditorExportPlatformJavaScript::get_run_icon() const { Ref<Texture2D> EditorExportPlatformWeb::get_run_icon() const {
return run_icon; return run_icon;
} }
void EditorExportPlatformJavaScript::_server_thread_poll(void *data) { void EditorExportPlatformWeb::_server_thread_poll(void *data) {
EditorExportPlatformJavaScript *ej = static_cast<EditorExportPlatformJavaScript *>(data); EditorExportPlatformWeb *ej = static_cast<EditorExportPlatformWeb *>(data);
while (!ej->server_quit) { while (!ej->server_quit) {
OS::get_singleton()->delay_usec(6900); OS::get_singleton()->delay_usec(6900);
{ {
@ -678,12 +678,12 @@ void EditorExportPlatformJavaScript::_server_thread_poll(void *data) {
} }
} }
EditorExportPlatformJavaScript::EditorExportPlatformJavaScript() { EditorExportPlatformWeb::EditorExportPlatformWeb() {
server.instantiate(); server.instantiate();
server_thread.start(_server_thread_poll, this); server_thread.start(_server_thread_poll, this);
logo = ImageTexture::create_from_image(memnew(Image(_javascript_logo))); logo = ImageTexture::create_from_image(memnew(Image(_web_logo)));
run_icon = ImageTexture::create_from_image(memnew(Image(_javascript_run_icon))); run_icon = ImageTexture::create_from_image(memnew(Image(_web_run_icon)));
Ref<Theme> theme = EditorNode::get_singleton()->get_editor_theme(); Ref<Theme> theme = EditorNode::get_singleton()->get_editor_theme();
if (theme.is_valid()) { if (theme.is_valid()) {
@ -693,7 +693,7 @@ EditorExportPlatformJavaScript::EditorExportPlatformJavaScript() {
} }
} }
EditorExportPlatformJavaScript::~EditorExportPlatformJavaScript() { EditorExportPlatformWeb::~EditorExportPlatformWeb() {
server->stop(); server->stop();
server_quit = true; server_quit = true;
server_thread.wait_to_finish(); server_thread.wait_to_finish();

View File

@ -28,8 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/ /*************************************************************************/
#ifndef JAVASCRIPT_EXPORT_PLUGIN_H #ifndef WEB_EXPORT_PLUGIN_H
#define JAVASCRIPT_EXPORT_PLUGIN_H #define WEB_EXPORT_PLUGIN_H
#include "core/config/project_settings.h" #include "core/config/project_settings.h"
#include "core/io/image_loader.h" #include "core/io/image_loader.h"
@ -39,13 +39,13 @@
#include "editor/editor_node.h" #include "editor/editor_node.h"
#include "editor/export/editor_export_platform.h" #include "editor/export/editor_export_platform.h"
#include "main/splash.gen.h" #include "main/splash.gen.h"
#include "platform/javascript/logo.gen.h" #include "platform/web/logo.gen.h"
#include "platform/javascript/run_icon.gen.h" #include "platform/web/run_icon.gen.h"
#include "export_server.h" #include "editor_http_server.h"
class EditorExportPlatformJavaScript : public EditorExportPlatform { class EditorExportPlatformWeb : public EditorExportPlatform {
GDCLASS(EditorExportPlatformJavaScript, EditorExportPlatform); GDCLASS(EditorExportPlatformWeb, EditorExportPlatform);
Ref<ImageTexture> logo; Ref<ImageTexture> logo;
Ref<ImageTexture> run_icon; Ref<ImageTexture> run_icon;
@ -141,8 +141,8 @@ public:
String get_debug_protocol() const override { return "ws://"; } String get_debug_protocol() const override { return "ws://"; }
EditorExportPlatformJavaScript(); EditorExportPlatformWeb();
~EditorExportPlatformJavaScript(); ~EditorExportPlatformWeb();
}; };
#endif // JAVASCRIPT_EXPORT_PLUGIN_H #endif // WEB_EXPORT_PLUGIN_H

View File

@ -1,5 +1,5 @@
/*************************************************************************/ /*************************************************************************/
/* http_client_javascript.cpp */ /* http_client_web.cpp */
/*************************************************************************/ /*************************************************************************/
/* This file is part of: */ /* This file is part of: */
/* GODOT ENGINE */ /* GODOT ENGINE */
@ -28,19 +28,19 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/ /*************************************************************************/
#include "http_client_javascript.h" #include "http_client_web.h"
void HTTPClientJavaScript::_parse_headers(int p_len, const char **p_headers, void *p_ref) { void HTTPClientWeb::_parse_headers(int p_len, const char **p_headers, void *p_ref) {
HTTPClientJavaScript *client = static_cast<HTTPClientJavaScript *>(p_ref); HTTPClientWeb *client = static_cast<HTTPClientWeb *>(p_ref);
for (int i = 0; i < p_len; i++) { for (int i = 0; i < p_len; i++) {
client->response_headers.push_back(String::utf8(p_headers[i])); client->response_headers.push_back(String::utf8(p_headers[i]));
} }
} }
Error HTTPClientJavaScript::connect_to_host(const String &p_host, int p_port, bool p_ssl, bool p_verify_host) { Error HTTPClientWeb::connect_to_host(const String &p_host, int p_port, bool p_ssl, bool p_verify_host) {
close(); close();
if (p_ssl && !p_verify_host) { if (p_ssl && !p_verify_host) {
WARN_PRINT("Disabling HTTPClientJavaScript's host verification is not supported for the HTML5 platform, host will be verified"); WARN_PRINT("Disabling HTTPClientWeb's host verification is not supported for the Web platform, host will be verified");
} }
port = p_port; port = p_port;
@ -71,17 +71,17 @@ Error HTTPClientJavaScript::connect_to_host(const String &p_host, int p_port, bo
return OK; return OK;
} }
void HTTPClientJavaScript::set_connection(const Ref<StreamPeer> &p_connection) { void HTTPClientWeb::set_connection(const Ref<StreamPeer> &p_connection) {
ERR_FAIL_MSG("Accessing an HTTPClientJavaScript's StreamPeer is not supported for the HTML5 platform."); ERR_FAIL_MSG("Accessing an HTTPClientWeb's StreamPeer is not supported for the Web platform.");
} }
Ref<StreamPeer> HTTPClientJavaScript::get_connection() const { Ref<StreamPeer> HTTPClientWeb::get_connection() const {
ERR_FAIL_V_MSG(Ref<RefCounted>(), "Accessing an HTTPClientJavaScript's StreamPeer is not supported for the HTML5 platform."); ERR_FAIL_V_MSG(Ref<RefCounted>(), "Accessing an HTTPClientWeb's StreamPeer is not supported for the Web platform.");
} }
Error HTTPClientJavaScript::request(Method p_method, const String &p_url, const Vector<String> &p_headers, const uint8_t *p_body, int p_body_len) { Error HTTPClientWeb::request(Method p_method, const String &p_url, const Vector<String> &p_headers, const uint8_t *p_body, int p_body_len) {
ERR_FAIL_INDEX_V(p_method, METHOD_MAX, ERR_INVALID_PARAMETER); ERR_FAIL_INDEX_V(p_method, METHOD_MAX, ERR_INVALID_PARAMETER);
ERR_FAIL_COND_V_MSG(p_method == METHOD_TRACE || p_method == METHOD_CONNECT, ERR_UNAVAILABLE, "HTTP methods TRACE and CONNECT are not supported for the HTML5 platform."); ERR_FAIL_COND_V_MSG(p_method == METHOD_TRACE || p_method == METHOD_CONNECT, ERR_UNAVAILABLE, "HTTP methods TRACE and CONNECT are not supported for the Web platform.");
ERR_FAIL_COND_V(status != STATUS_CONNECTED, ERR_INVALID_PARAMETER); ERR_FAIL_COND_V(status != STATUS_CONNECTED, ERR_INVALID_PARAMETER);
ERR_FAIL_COND_V(host.is_empty(), ERR_UNCONFIGURED); ERR_FAIL_COND_V(host.is_empty(), ERR_UNCONFIGURED);
ERR_FAIL_COND_V(port < 0, ERR_UNCONFIGURED); ERR_FAIL_COND_V(port < 0, ERR_UNCONFIGURED);
@ -107,7 +107,7 @@ Error HTTPClientJavaScript::request(Method p_method, const String &p_url, const
return OK; return OK;
} }
void HTTPClientJavaScript::close() { void HTTPClientWeb::close() {
host = ""; host = "";
port = -1; port = -1;
use_tls = false; use_tls = false;
@ -121,23 +121,23 @@ void HTTPClientJavaScript::close() {
} }
} }
HTTPClientJavaScript::Status HTTPClientJavaScript::get_status() const { HTTPClientWeb::Status HTTPClientWeb::get_status() const {
return status; return status;
} }
bool HTTPClientJavaScript::has_response() const { bool HTTPClientWeb::has_response() const {
return response_headers.size() > 0; return response_headers.size() > 0;
} }
bool HTTPClientJavaScript::is_response_chunked() const { bool HTTPClientWeb::is_response_chunked() const {
return godot_js_fetch_is_chunked(js_id); return godot_js_fetch_is_chunked(js_id);
} }
int HTTPClientJavaScript::get_response_code() const { int HTTPClientWeb::get_response_code() const {
return polled_response_code; return polled_response_code;
} }
Error HTTPClientJavaScript::get_response_headers(List<String> *r_response) { Error HTTPClientWeb::get_response_headers(List<String> *r_response) {
if (!response_headers.size()) { if (!response_headers.size()) {
return ERR_INVALID_PARAMETER; return ERR_INVALID_PARAMETER;
} }
@ -148,11 +148,11 @@ Error HTTPClientJavaScript::get_response_headers(List<String> *r_response) {
return OK; return OK;
} }
int64_t HTTPClientJavaScript::get_response_body_length() const { int64_t HTTPClientWeb::get_response_body_length() const {
return godot_js_fetch_body_length_get(js_id); return godot_js_fetch_body_length_get(js_id);
} }
PackedByteArray HTTPClientJavaScript::read_response_body_chunk() { PackedByteArray HTTPClientWeb::read_response_body_chunk() {
ERR_FAIL_COND_V(status != STATUS_BODY, PackedByteArray()); ERR_FAIL_COND_V(status != STATUS_BODY, PackedByteArray());
if (response_buffer.size() != read_limit) { if (response_buffer.size() != read_limit) {
@ -177,23 +177,23 @@ PackedByteArray HTTPClientJavaScript::read_response_body_chunk() {
return chunk; return chunk;
} }
void HTTPClientJavaScript::set_blocking_mode(bool p_enable) { void HTTPClientWeb::set_blocking_mode(bool p_enable) {
ERR_FAIL_COND_MSG(p_enable, "HTTPClientJavaScript blocking mode is not supported for the HTML5 platform."); ERR_FAIL_COND_MSG(p_enable, "HTTPClientWeb blocking mode is not supported for the Web platform.");
} }
bool HTTPClientJavaScript::is_blocking_mode_enabled() const { bool HTTPClientWeb::is_blocking_mode_enabled() const {
return false; return false;
} }
void HTTPClientJavaScript::set_read_chunk_size(int p_size) { void HTTPClientWeb::set_read_chunk_size(int p_size) {
read_limit = p_size; read_limit = p_size;
} }
int HTTPClientJavaScript::get_read_chunk_size() const { int HTTPClientWeb::get_read_chunk_size() const {
return read_limit; return read_limit;
} }
Error HTTPClientJavaScript::poll() { Error HTTPClientWeb::poll() {
switch (status) { switch (status) {
case STATUS_DISCONNECTED: case STATUS_DISCONNECTED:
return ERR_UNCONFIGURED; return ERR_UNCONFIGURED;
@ -227,9 +227,9 @@ Error HTTPClientJavaScript::poll() {
#ifdef DEBUG_ENABLED #ifdef DEBUG_ENABLED
// forcing synchronous requests is not possible on the web // forcing synchronous requests is not possible on the web
if (last_polling_frame == Engine::get_singleton()->get_process_frames()) { if (last_polling_frame == Engine::get_singleton()->get_process_frames()) {
WARN_PRINT("HTTPClientJavaScript polled multiple times in one frame, " WARN_PRINT("HTTPClientWeb polled multiple times in one frame, "
"but request cannot progress more than once per " "but request cannot progress more than once per "
"frame on the HTML5 platform."); "frame on the Web platform.");
} }
last_polling_frame = Engine::get_singleton()->get_process_frames(); last_polling_frame = Engine::get_singleton()->get_process_frames();
#endif #endif
@ -258,15 +258,15 @@ Error HTTPClientJavaScript::poll() {
return OK; return OK;
} }
HTTPClient *HTTPClientJavaScript::_create_func() { HTTPClient *HTTPClientWeb::_create_func() {
return memnew(HTTPClientJavaScript); return memnew(HTTPClientWeb);
} }
HTTPClient *(*HTTPClient::_create)() = HTTPClientJavaScript::_create_func; HTTPClient *(*HTTPClient::_create)() = HTTPClientWeb::_create_func;
HTTPClientJavaScript::HTTPClientJavaScript() { HTTPClientWeb::HTTPClientWeb() {
} }
HTTPClientJavaScript::~HTTPClientJavaScript() { HTTPClientWeb::~HTTPClientWeb() {
close(); close();
} }

View File

@ -1,5 +1,5 @@
/*************************************************************************/ /*************************************************************************/
/* http_client_javascript.h */ /* http_client_web.h */
/*************************************************************************/ /*************************************************************************/
/* This file is part of: */ /* This file is part of: */
/* GODOT ENGINE */ /* GODOT ENGINE */
@ -28,8 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/ /*************************************************************************/
#ifndef HTTP_CLIENT_JAVASCRIPT_H #ifndef HTTP_CLIENT_WEB_H
#define HTTP_CLIENT_JAVASCRIPT_H #define HTTP_CLIENT_WEB_H
#include "core/io/http_client.h" #include "core/io/http_client.h"
@ -59,7 +59,7 @@ extern int godot_js_fetch_is_chunked(int p_id);
} }
#endif #endif
class HTTPClientJavaScript : public HTTPClient { class HTTPClientWeb : public HTTPClient {
private: private:
int js_id = 0; int js_id = 0;
Status status = STATUS_DISCONNECTED; Status status = STATUS_DISCONNECTED;
@ -102,8 +102,8 @@ public:
void set_read_chunk_size(int p_size) override; void set_read_chunk_size(int p_size) override;
int get_read_chunk_size() const override; int get_read_chunk_size() const override;
Error poll() override; Error poll() override;
HTTPClientJavaScript(); HTTPClientWeb();
~HTTPClientJavaScript(); ~HTTPClientWeb();
}; };
#endif // HTTP_CLIENT_JAVASCRIPT_H #endif // HTTP_CLIENT_WEB_H

View File

@ -31,7 +31,7 @@
#include "api/javascript_singleton.h" #include "api/javascript_singleton.h"
#include "emscripten.h" #include "emscripten.h"
#include "os_javascript.h" #include "os_web.h"
extern "C" { extern "C" {
extern void godot_js_os_download_buffer(const uint8_t *p_buf, int p_buf_size, const char *p_name, const char *p_mime); extern void godot_js_os_download_buffer(const uint8_t *p_buf, int p_buf_size, const char *p_name, const char *p_mime);
@ -359,8 +359,8 @@ void JavaScript::download_buffer(Vector<uint8_t> p_arr, const String &p_name, co
} }
bool JavaScript::pwa_needs_update() const { bool JavaScript::pwa_needs_update() const {
return OS_JavaScript::get_singleton()->pwa_needs_update(); return OS_Web::get_singleton()->pwa_needs_update();
} }
Error JavaScript::pwa_update() { Error JavaScript::pwa_update() {
return OS_JavaScript::get_singleton()->pwa_update(); return OS_Web::get_singleton()->pwa_update();
} }

View File

@ -6,7 +6,7 @@
* of `Promises <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Using_promises>`__. * of `Promises <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Using_promises>`__.
* *
* @module Engine * @module Engine
* @header HTML5 shell class reference * @header Web export JavaScript reference
*/ */
const Engine = (function () { const Engine = (function () {
const preloader = new Preloader(); const preloader = new Preloader();

Some files were not shown because too many files have changed in this diff Show More