diff --git a/.github/ISSUE_TEMPLATE/issue_report.yml b/.github/ISSUE_TEMPLATE/issue_report.yml index e9f49de5..9b37b2f1 100644 --- a/.github/ISSUE_TEMPLATE/issue_report.yml +++ b/.github/ISSUE_TEMPLATE/issue_report.yml @@ -8,38 +8,26 @@ body: value: | Hello, and thank you for reporting an issue with Unity Web Browser (UWB)! When filling out the information below, please try to provide as much details as you can, the more you provide, the more likely we can help and fix something. + + **Questions and features should be asked via [Discussions](https://github.com/Voltstro-Studios/UnityWebBrowser/discussions)** - type: dropdown id: platform attributes: label: What platform are you experiencing this issue on? options: - - Windows - - Linux - - MacOS - - Other - validations: - required: true - - - type: dropdown - id: architecture - attributes: - label: What architecture is your platform? - options: - - 64-Bit - - 32-Bit - - Other + - Windows x64 + - Linux x64 + - MacOS x64 + - MacOS arm64 validations: required: true - - type: dropdown + - type: input id: version attributes: label: What version of UWB are you using? - options: - - Latest VoltstroUPM Release - - Github Master Branch - - Other (Please provide) + placeholder: '2.2.0' validations: required: true @@ -66,11 +54,10 @@ body: label: Provide reproducible steps for this issue. description: Providing reproducible steps always helps. You could also provide a project with the issue here. If its a Unity project please delete the cache folder (`/Library`) and other unnecessary files from it (Such as `/Temp`, `/obj`, `*.csproj` files and builds). placeholder: Please provide reproducible steps - value: "1. I did this. - -2. I then did that. - -3. Boom! Issue." + value: | + 1. I did this. + 2. I then did that. + 3. Boom! Issue. validations: required: true diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5f453789..fad49ed4 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,121 +1,134 @@ name: Build on: - push + push: + branches: + - master + - release jobs: - #This job builds the Unity project - build-core: - name: 'Build-UWB-Core' - runs-on: ubuntu-22.04 - steps: - - #Restore - - uses: actions/checkout@v3 - with: - path: 'UnityWebBrowserSource/' - - #Setup the Environment - - uses: actions/setup-dotnet@v2 - name: Setup .NET - with: - dotnet-version: '8.0.x' - - #Build shared - - name: Build Shared - shell: pwsh - run: '& ./publish-shared.ps1' - working-directory: UnityWebBrowserSource/src/DevScripts/ - - #Restore Unity's cache - - name: Unity Cache - uses: actions/cache@v3 - with: - path: UnityWebBrowserSource/src/UnityWebBrowser.UnityProject/Library - key: Cache-Unity - - #Build the Unity project - - name: Build Unity Project - uses: game-ci/unity-builder@v4 - env: - UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }} - UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }} - UNITY_SERIAL: ${{ secrets.UNITY_SERIAL }} - with: - projectPath: 'UnityWebBrowserSource/src/UnityWebBrowser.UnityProject/' - targetPlatform: StandaloneLinux64 - buildsPath: 'UnityWebBrowserSource/src/UnityWebBrowser.UnityProject/Builds' - versioning: Tag - - #Create an output directory for artifacts - - name: Create Artifacts Staging Directory - shell: pwsh - run: mkdir ~/UWBStaging/ - - #Pack UWB Core - - name: Pack Core Package - shell: pwsh - run: npm pack --pack-destination ~/UWBStaging/ - working-directory: UnityWebBrowserSource/src/Packages/UnityWebBrowser - - #Pack UWB Communication Pipes - - name: Pack Communication Pipes Package - shell: pwsh - run: npm pack --pack-destination ~/UWBStaging/ - working-directory: UnityWebBrowserSource/src/Packages/UnityWebBrowser.Communication.Pipes - - #Pack UWB UNIX Support - - name: Pack Unix Support Package - shell: pwsh - run: npm pack --pack-destination ~/UWBStaging/ - working-directory: UnityWebBrowserSource/src/Packages/UnityWebBrowser.Unix-Support - - # Upload Packed Packages - - name: Upload Artifacts - uses: actions/upload-artifact@v4 - with: - name: UWB-Core - path: ~/UWBStaging/*.tgz - - #Builds the CEF Engine - build-engine-cef: - name: 'Build-Engine-Cef' - runs-on: ubuntu-22.04 - steps: - - #Checkout - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - submodules: 'recursive' - path: 'UnityWebBrowserSource/' - - #Setup the Environment - - uses: actions/setup-dotnet@v2 - name: Setup .NET - with: - dotnet-version: '8.0.x' - - #Download CEF (Linux) - - name: Download CEF (Linux) - shell: pwsh - run: '& ./download-cef-linux.ps1' - working-directory: UnityWebBrowserSource/src/DevScripts/ - - #Download CEF (Windows) - - name: Download CEF (Windows) - shell: pwsh - run: '& ./download-cef-windows.ps1' - working-directory: UnityWebBrowserSource/src/DevScripts/ - - #Build CEF Engine (Linux) - - name: Build CEF Engine (Linux) - shell: pwsh - run: '& ./publish-cef-engine-linux.ps1' - working-directory: UnityWebBrowserSource/src/DevScripts/ - - #Build CEF Engine (Linux) - - name: Build CEF Engine (Windows) - shell: pwsh - run: '& ./publish-cef-engine-windows.ps1' - working-directory: UnityWebBrowserSource/src/DevScripts/ + #This job builds the main non-platform depent packages + build-core: + name: "Build-UWB-Main" + runs-on: ubuntu-22.04 + steps: + # Checkout Repo + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + #Setup the Environment + - uses: actions/setup-dotnet@v4 + name: Setup .NET + with: + dotnet-version: "8.0.x" + + # Build shared + - name: Build Shared + run: python build_shared.py + working-directory: src/DevScripts/ + + # Restore Unity's cache + - name: Unity Cache + uses: actions/cache@v4 + with: + path: src/UnityWebBrowser.UnityProject/Library + key: Cache-Unity + + # Build the Unity project + - name: Build Unity Project + uses: game-ci/unity-builder@v4 + env: + UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }} + UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }} + UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }} + with: + projectPath: src/UnityWebBrowser.UnityProject/ + targetPlatform: StandaloneLinux64 + buildsPath: src/UnityWebBrowser.UnityProject/Builds + versioning: Tag + + # Create an output directory for artifacts + - name: Create Artifacts Staging Directory + shell: pwsh + run: mkdir ${{ github.workspace }}/UWBStaging/ + + # Pack UWB Core + - name: Pack Core Package + shell: pwsh + run: npm pack --pack-destination ${{ github.workspace }}/UWBStaging/ + working-directory: src/Packages/UnityWebBrowser + + # Pack UWB Pipes Communication + - name: Pack Pipes Communication Package + shell: pwsh + run: npm pack --pack-destination ${{ github.workspace }}/UWBStaging/ + working-directory: src/Packages/UnityWebBrowser.Communication.Pipes + + # Upload Packed Packages + - name: Upload Artifacts + uses: actions/upload-artifact@v4 + with: + name: UWB-Core + path: ${{ github.workspace }}/UWBStaging/*.tgz + + build-engine-cef: + strategy: + matrix: + os: [windows-2022, ubuntu-22.04] + include: + - os: windows-2022 + build: windows64 + package: Win-x64 + - os: ubuntu-22.04 + build: linux64 + package: Linux-x64 + - os: macos-14 + build: macosx64 + package: MacOS-x64 + - os: macos-14 + build: macosarm64 + package: MacOS-arm64 + + runs-on: ${{ matrix.os }} + name: Build-UWB-Engine-CEF-${{ matrix.package }} + steps: + # Checkout Repo + - uses: actions/checkout@v4 + with: + submodules: true + fetch-depth: 0 + + # Setup the Environment + - uses: actions/setup-dotnet@v4 + name: Setup .NET + with: + dotnet-version: "8.0.x" + + # Download CEF + - name: Download CEF ${{ matrix.build }} + run: python download_cef_${{ matrix.build }}.py + working-directory: src/DevScripts/ + + # Build CEF Engine + - name: Build CEF Engine ${{ matrix.build }} + run: python build_cef_${{ matrix.build }}.py + working-directory: src/DevScripts/ + + # Create an output directory for artifacts + - name: Create Artifacts Staging Directory + shell: pwsh + run: mkdir ${{ github.workspace }}/UWBStaging/ + + # Pack UWB Core + - name: Pack CEF Engine ${{ matrix.package }} Package + shell: pwsh + run: npm pack --pack-destination ${{ github.workspace }}/UWBStaging/ + working-directory: src/Packages/UnityWebBrowser.Engine.Cef.${{ matrix.package }} + + # Upload Packed Packages + - name: Upload Artifacts + uses: actions/upload-artifact@v4 + with: + name: UWB-Engine-CEF-${{ matrix.package }} + path: ${{ github.workspace }}/UWBStaging/*.tgz diff --git a/.gitignore b/.gitignore index 6f775040..8274175f 100644 --- a/.gitignore +++ b/.gitignore @@ -385,4 +385,5 @@ FodyWeavers.xsd *.sln.iml # MacOS -*.DS_Store \ No newline at end of file +*.DS_Store + diff --git a/.gitmodules b/.gitmodules index 70ea1a0e..f2277f96 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "ThirdParty/CefGlue"] path = src/ThirdParty/CefGlue - url = https://gitlab.com/Voltstro-Studios/WebBrowser/cefglue.git + url = https://github.com/Voltstro-Studios/CefGlue.git diff --git a/CHANGELOG.md b/CHANGELOG.md index 497c327d..7fce0c66 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,49 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [2.2.0] - 2024-09-20 + +### Added + +- Added MacOS support (x64, arm64) +- Added CEF engine sandboxing (Windows, MacOS) +- Added remote debugging allowed origins +- Added CEF Event flags support (allows dragging) +- Added `UWB_DISABLE_POSTPROCESSOR` define to UWB's postprocessor + +### Changed + +- Bump deps +- Updated CEF to 128.4.9 +- CEF engine gets compiled using .NET Native AOT +- Updated logging tags +- Communication layers are loaded by name instead of assemblies +- Update pipes package to use VoltRpc.Communication.Pipes package, instead of embedding +- Mouse click events will always send `clickCount` with at least a value of 1 +- Changed control of engine pathing from being fixed (hardcoded) to being controlled by the `Engine` scriptable object +- Improve copying in engine build post-processor +- Change TCP timeouts to max allowed (#300) +- (Dev) Build all projects in CI +- (Dev) Change builds scripts to Python + +### Deprecated + +- Unix Support Package (`dev.voltstro.unitywebbrowser.unix-support`) - Packages should include the right execute permission from the get-go +- `CommunicationLayer.connectionTimeout` - Timeouts are now set to max +- `Engine.engineFileLocation` - Replaced with `Engine.engineEditorLocation` +- `Engine.EngineFilesNotFoundError` - No longer needed +- `EngineManager.GetEngineDirectory` - Fetching of engine paths is now handled by the engine class +- `EngineManager.GetEngineDirectory` - Fetching of engine paths is now handled by the engine class +- `EngineManager.GetEngineProcessFullPath` - Fetching of engine paths is now handled by the engine class +- `EngineManager.GetEngineProcessFullPath` - Fetching of engine paths is now handled by the engine class +- `WebBrowserUtils.GetBrowserEnginePath` - Fetching of engine paths is now handled by the engine class +- `WebBrowserUtils.GetBrowserEngineProcessPath` - Fetching of engine paths is now handled by the engine class + +### Fixed + +- Fixed select popups not working (#314) +- Fixed keyboard events not firing (#335) + ## [2.1.1] - 2024-03-22 ### Added diff --git a/README.md b/README.md index 5a9598d9..e872149a 100644 --- a/README.md +++ b/README.md @@ -3,9 +3,8 @@ # Unity Web Browser [![License](https://img.shields.io/github/license/Voltstro-Studios/UnityWebBrowser.svg)](/LICENSE.md) -[![Build](https://github.com/Voltstro-Studios/UnityWebBrowser/actions/workflows/main.yml/badge.svg)](https://github.com/Voltstro-Studios/UnityWebBrowser/actions/workflows/main.yml) -[![Discord](https://img.shields.io/badge/Discord-Voltstro-7289da.svg?logo=discord)](https://discord.voltstro.dev) -[![YouTube](https://img.shields.io/badge/Youtube-Voltstro-red.svg?logo=youtube)](https://www.youtube.com/Voltstro) +[![Build Status](https://github.com/Voltstro-Studios/UnityWebBrowser/actions/workflows/main.yml/badge.svg)](https://github.com/Voltstro-Studios/UnityWebBrowser/actions/workflows/main.yml) +[![Docs Status](https://img.shields.io/uptimerobot/status/m794227043-7e2bf837661fcd75d2af6804?label=Docs)](https://projects.voltstro.dev/UnityWebBrowser/latest/) Unity Web Browser (UWB) is a Unity package that allows displaying and interacting with the web from within Unity. @@ -14,8 +13,9 @@ This project is capable of using any desired web engine you want, however for no ## Features - Easy Installation with UPM -- Multi-Platform Desktop Support +- Multi-Platform Desktop Support (Windows, Linux & MacOS) - API to interact with the web engine +- JS Interop - Extendable - 100% Open-Source @@ -29,18 +29,15 @@ Unity 2021.3.x ### Install -1. Setup [VoltstroUPM](https://github.com/Voltstro/VoltstroUPM#setup) -2. Define the additional scopes `org.nuget` and `com.cysharp.unitask` with VoltstroUPM -3. Install the required packages! - - UnityWebBrowser -4. Install an engine: - - E.G.: UnityWebBrowser CEF Engine with Windows natives +1. Setup [VoltUPM](https://github.com/Voltstro/VoltstroUPM#setup) +2. Define the additional scopes `org.nuget` and `com.cysharp.unitask` with VoltUPM +3. Install UnityWebBrowser packages -For a more in-depth installation guide, check out the [setup article](https://projects.voltstro.dev/UnityWebBrowser/articles/user/setup/). +For a more in-depth installation guide, check out the [setup article](https://projects.voltstro.dev/UnityWebBrowser/latest/articles/user/setup/). ## Documentation -For further documentation, see [UWB's project site](https://projects.voltstro.dev/UnityWebBrowser/articles/). +For further documentation, see [UWB's project site](https://projects.voltstro.dev/UnityWebBrowser/latest/articles/). The project site covers information such as Engines, Platform support, advance setup, plus more. @@ -56,7 +53,11 @@ PLEASE DO NOT USE DISCORD FOR SUPPORT! ## Contributing -For learning how to setup UWB repo for development, please see the [developer guide article](https://projects.voltstro.dev/UnityWebBrowser/articles/dev/dev-guide/) on the project's site. +We will gladly accept contributions from anyone! + +Contributions don't just have to be code, contributions can be good [bug reports](https://github.com/Voltstro-Studios/UnityWebBrowser/issues), good [questions/feature requests](https://github.com/Voltstro-Studios/UnityWebBrowser/discussions), or even simple updates to our docs. + +But, if you do wish to contribute code wise to project, please see the [dev docs](https://projects.voltstro.dev/UnityWebBrowser/latest/articles/dev/dev-guide/) for setting up the project. Pickup a feature request or bug report, do the required changes then submit a PR to the `master` branch for review. ## Screenshots @@ -91,6 +92,16 @@ For learning how to setup UWB repo for development, please see the [developer gu This project is licensed under the MIT License - see the [LICENSE.md](/LICENSE.md) file for details. +## Socials + +Here are our socials, please don't use these for support! + +[![Discord](https://img.shields.io/discord/424080906232266753)](https://discord.voltstro.dev) + +[![Twitter Follow](https://img.shields.io/twitter/follow/Voltstro?style=social)](https://twitter.com/Voltstro) + +[![Twitter Follow](https://img.shields.io/twitter/follow/VoltstroStudios?style=social)](https://twitter.com/VoltstroStudios) + ## Thanks Thank you to many different projects and people that have made this project possible. diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 00000000..e13f90d3 --- /dev/null +++ b/docs/README.md @@ -0,0 +1,22 @@ +# UnityWebBrowser Docs + +UnityWebBrowser's docs are built from here. + +UWB docs are generated using [DocFx](https://dotnet.github.io/docfx/). See the DocFx site for setup of the tool. + +## Building Locally + +``` +docfx metadata +docfx build +``` + +To preview locally, use: + +``` +docfx serve _site/ +``` + +## Publishing + +The [publicly hosted docs](https://projects.voltstro.dev/UnityWebBrowser/latest/) are automatically published using [VoltProjects](https://github.com/Voltstro/VoltProjects). diff --git a/docs/articles/contributing.md b/docs/articles/contributing.md new file mode 100644 index 00000000..1ed071e2 --- /dev/null +++ b/docs/articles/contributing.md @@ -0,0 +1,7 @@ +# Contributing + +We will gladly accept contributions from anyone! + +Contributions don't just have to be code, contributions can be good [bug reports](https://github.com/Voltstro-Studios/UnityWebBrowser/issues), good [questions/feature requests](https://github.com/Voltstro-Studios/UnityWebBrowser/discussions), or even simple updates to our docs. + +But, if you do wish to contribute code wise to project, please see the [dev docs](dev/dev-guide.md) for setting up the project. Pickup a feature request or bug report, do the required changes then submit a PR to the `master` branch for review. diff --git a/docs/articles/dev/branches.md b/docs/articles/dev/branches.md new file mode 100644 index 00000000..30a461d0 --- /dev/null +++ b/docs/articles/dev/branches.md @@ -0,0 +1,13 @@ +# Branches + +Quick info on our branching strategy. + +## Master Branch + +We use the `master` branch as our main development branch. If needed, branch of this while working on features. + +## Release Branch + +The `release` branch is where release builds will be created. It also where [VoltProjects](https://github.com/Voltstro/VoltProjects) generates the docs from. + +`master` will be merged to here when a release is ready. See [publishing for more info](publishing.md). diff --git a/docs/articles/dev/dev-guide.md b/docs/articles/dev/dev-guide.md index 2f881983..d8b1f12a 100644 --- a/docs/articles/dev/dev-guide.md +++ b/docs/articles/dev/dev-guide.md @@ -7,6 +7,14 @@ This section contains docs useful for developers who want to work on UWB's code. > - Advance Unity Knowledge > - Advance C# & .NET Knowledge -To get going, see the [setup section](setup.md). +## Repo Setup -When developing for UWB, it is highly recommended to develop using `UnityWebBrowser.UnityProject` provided in the repo. Other means of development will **NOT** be supported! Even if you are creating an external separate package for UWB, it is still recommended to develop using the provided project in the repo! We recommend this approach as the Unity project has all dependencies ready to go, all the tools, and proper projects setup for the code (both Engine and Core). +To setup UWB's git repo, see the [setup section](setup.md). + +## Developing + +When developing for UWB, it is highly recommended to develop using the `src/UnityWebBrowser.UnityProject` project provided in the repo. Other means of development will **NOT** be supported! Even if you are creating an external separate package for UWB, it is still recommended to develop using the provided project in the repo! We recommend this approach as the Unity project has all dependencies ready to go, all the tools, and proper projects setup for the code (both Engine and Core). + +## Packaging + +TODO diff --git a/docs/articles/dev/dev-scripts.md b/docs/articles/dev/dev-scripts.md new file mode 100644 index 00000000..92ab3148 --- /dev/null +++ b/docs/articles/dev/dev-scripts.md @@ -0,0 +1,24 @@ +# Dev Scripts + +UWB contains all of its dev scripts in `src/DevScripts/`. Dev scripts are used for automating tasks like downloading external files or building projects. + +## Usage + +There are three main scripts you will want to use. + +1. `download_cef_.py` + - Used for downloading the required version of CEF and extracting it. +2. `build_cef_.py` + - Builds the `UnityWebBrowser.Engine.Cef` project in publish mode and outputs the built files into `src/Packages/UnityWebBrowser.Engine.Cef./Engine~/`. Needs to be ran if the CEF engine project has any changes made to it. +3. `build_shared.py` + - Builds the `VoltstroStudios.UnityWebBrowser.Shared` project in `ReleaseUnity` configuration mode, which will place the built files into `src/Packages/UnityWebBrowser/Plugins`. Needs to be ran if the shared project has any changes made to it. +4. `sync_info.py` + - Syncs version and license info across packages. + +## Base Scripts + +There are a couple of scripts with `_base` in it's name. These scripts are shared modules that are used by the scripts that the user executes. + +## Why Python + +In older versions of UWB, we used PowerShell as the language of choice for our dev scripts. PowerShell has one main advantage, it is cross-platform. But so is Python. Python's built-in libraries also includes a lot of useful utilities like archive extraction. While in PowerShell technically this is possible (you can call .NET methods), its a bit of a pain to do. diff --git a/docs/articles/dev/project-layout.md b/docs/articles/dev/project-layout.md index 8063d987..e75cc228 100644 --- a/docs/articles/dev/project-layout.md +++ b/docs/articles/dev/project-layout.md @@ -27,7 +27,7 @@ src/ - `docs/`, `media/` and `src/` are all fairly explanatory. -- `DevScripts/` and `DevTools/` provide developer scripts and other external applications that are needed. +- `DevScripts/` provide developer scripts that are used for automating certain tasks while developing UWB. - `Imports/` contains shared `.targets` and `.props` files that are used by the .NET projects. @@ -43,11 +43,11 @@ Quick description of all the individual projects. ### UnityWebBrowser.UnityProject -This is the provided Unity project that can be used for UWB development. It has all of UWB's packages included locally. +This is the provided Unity project that can be used for UWB development. It has all of UWB's packages included locally. It uses the lowest Unity version that UWB supports (Unity 2021.3.x). ### UnityWebBrowser.Pages -NodeJs/Yarn project that used to build out HTML that engines use for internal pages. +NodeJs/Yarn project that is used to build out HTML files that engines use for internal pages. ### VoltstroStudios.UnityWebBrowser.Shared @@ -59,4 +59,4 @@ NodeJs/Yarn project that used to build out HTML that engines use for internal pa ### UnityWebBrowser.Engine.Cef -UWB's CEF Engine. .NET project that is built out as an application. In publish mode it will build the app into a single file. +UWB's CEF Engine. .NET project that is built out as an application. Is compiled using .NET's [NativeAOT deployment](https://learn.microsoft.com/en-us/dotnet/core/deploying/native-aot/) mode. diff --git a/docs/articles/dev/publishing.md b/docs/articles/dev/publishing.md new file mode 100644 index 00000000..f371226f --- /dev/null +++ b/docs/articles/dev/publishing.md @@ -0,0 +1,39 @@ +# Publishing + +This doc will cover the standard release process that UWB follows. + +The steps are listed in order. + +## Versioning + +The UWB project follows semantic versioning. The general version number should be MAJOR.MINOR.PATCH. For preview builds, attach `-preview.x` to the end. + +Engine packages have an additional version number attached as well. This version number is the version of the browser engine they are using (E.G: CEF engine has CEF's version attached, so might end up looking like `2.0.0-106.1.0`). + +The packages and assemblies will need to have their version numbers bumped depending on what has been done to them. + +## Changelog + +The `CHANGELOG.md` file should generally be maintained as dev work is done, but most of the time it is not (because we are lazy), so fill out what has been done. This generally isn't too much of an issue if git commits are descriptive enough. + +The date of the release should be attached next to the version number. + +## Merge to Release Branch + +A PR to the `release` branch should be created. Follow standard PR review process to potentially catch any last minute changes that need to be done. + +## Release Build + +Once merged to the `release` branch, wait for CI to complete build. The CI will output the different packages compiled as artifacts. Downloads the artifacts as they will need to be pushed. + +## Push to VoltUPM + +Use npm to push to VoltUPM. + +> [!NOTE] +> +> Cloudflare does not allow uploads of 100MB or larger. Some packages are larger. Add VoltUPM's server ip to `/etc/hosts`, then push. Ensure VoltUPM's server firewall has whitelisted IP from where push will be done. + +## Git Tagging + +Tag the commit in the `release` branch with the version number. Create GitHub release targeting this tag. diff --git a/docs/articles/dev/setup.md b/docs/articles/dev/setup.md index a2292f9c..390bcd7d 100644 --- a/docs/articles/dev/setup.md +++ b/docs/articles/dev/setup.md @@ -8,12 +8,12 @@ These prerequisites are **mandatory** to compile UWB. ``` Unity 2021.3.x -.NET 8 SDK -PowerShell (formally PowerShell Core)* +.NET 8 SDK (With NativeAOT) +Python 3 Git ``` -*[Modern PowerShell](https://github.com/powershell/powershell#get-powershell) is required! The one built into Windows does **NOT** work. +UWB compiles engines using .NET's [NativeAOT deployment mode](https://learn.microsoft.com/en-us/dotnet/core/deploying/native-aot/). NativeAOT it self has some prerequisites, please [see the docs for what you will need](https://learn.microsoft.com/en-us/dotnet/core/deploying/native-aot/?tabs=net8plus%2Cwindows#prerequisites). ### Additional Optional Prerequisites @@ -42,20 +42,15 @@ git clone --recursive https://github.com/Voltstro-Studios/UnityWebBrowser.git > git submodule update > ``` -Once you have the repo cloned with the submodules, you must now run the `src/setup-all.ps1` script with PowerShell. +Once you have the repo cloned with submodules, you can run the inital setup script. -You can go into PowerShell with the command: - -```shell -pwsh ``` - -Once in PowerShell, go to the `src/` directory, and run the `setup-all.ps1` script: - -```powershell -./setup-all.ps1 +python src/DevScripts/setup_all.py ``` +> [!NOTE] +> On some platforms, you may need to run python using `python3` instead of just `python`. + Depending on your system, and your download speeds, this script could take upto a minute or even longer. You only need to run the setup script once. You can now open up the `src/UnityWebBrowser.UnityProject` project with Unity. @@ -88,7 +83,4 @@ You can open `src/UnityWebBrowser.sln` with your preferred IDE. The rest of the ## Dev Scripts -There a many dev scripts in the `src/DevScripts` directory. The main ones that you will most likely use are: - -- `download-cef-.ps1` -- `publish-
-.ps1` +There are many DevScripts which you may need to use. For details on what dev scripts does what, see [Dev Scripts](dev-scripts.md). diff --git a/docs/articles/faq.md b/docs/articles/faq.md index ed436efc..b14e38d3 100644 --- a/docs/articles/faq.md +++ b/docs/articles/faq.md @@ -24,4 +24,4 @@ Here are some common questions we get. As time goes on, and we get asked more co **Q**: Does UWB support mobile or WebGl? -**A**: UWB does not support any other platform that is not a desktop platform (Windows, Linux). +**A**: UWB does not support any other platform that is not a desktop platform (Windows, Linux & MacOS). diff --git a/docs/articles/toc.yml b/docs/articles/toc.yml index 07ca0e4a..0dbdb144 100644 --- a/docs/articles/toc.yml +++ b/docs/articles/toc.yml @@ -4,6 +4,9 @@ - name: FAQ href: faq.md +- name: Contributing + href: contributing.md + - name: User items: - name: Setup @@ -20,6 +23,8 @@ href: user/javascript.md - name: Client Events href: user/events.md + - name: Player Build + href: user/player-build.md - name: Developer items: @@ -27,7 +32,11 @@ href: dev/dev-guide.md - name: Setup href: dev/setup.md + - name: Dev Scripts + href: dev/dev-scripts.md - name: How Things Work href: dev/how-things-work.md - name: Project Layout - href: dev/project-layout.md \ No newline at end of file + href: dev/project-layout.md + - name: Publishing + href: dev/publishing.md \ No newline at end of file diff --git a/docs/articles/user/engines.md b/docs/articles/user/engines.md index fee01c2b..46052b4e 100644 --- a/docs/articles/user/engines.md +++ b/docs/articles/user/engines.md @@ -8,40 +8,40 @@ UWB can support using many different types of web engines using this approach. To change what engine you are using, goto the Web Browser component, and change the 'Engine' value to the new engine configuration you want to use. -## Cef Engine +## Engine List -The Cef engine uses [CEF](https://bitbucket.org/chromiumembedded/cef/src/master/) as it's web engine. CEF is built using [Chromium](https://www.chromium.org/) (the engine that powers many different browsers including Chrome, Edge, Opera and Brave). +### CEF Engine -The downsides of using CEF come from the downside of Chromium, it's a memory hog (~400 MB at idle), and has quite large binaries. +The CEF engine uses [CEF](https://bitbucket.org/chromiumembedded/cef/src/master/) as it's web engine. CEF is built using [Chromium](https://www.chromium.org/) (the engine that powers most web browsers including Chrome, Edge, etc). -### Platform Support +#### Platform Support -|OS |Supported |Notes | -|-------------|---------------------------|----------------------------------------------| -|Windows |✔ |Works natively | -|Linux |✔ (Tested on Ubuntu 22.04)|Works natively | -|MacOS (Intel)|✖ |Planned | -|MacOS (M1) |✖ |No physical hardware to test or develop on | +|Platform |Supported |Notes | +|-------------|---------------------------|--------------------------------------------------| +|Windows |✔ |Works natively | +|Linux |✔ (Tested on Ubuntu 22.04)|Works natively | +|MacOS (Intel)|✔ |Works natively | +|MacOS (Arm) |✔ |While we provide ARM builds, they are not tested | -### Packages +#### Packages - 'Unity Web Browser CEF Engine' (`unitywebbrowser.engine.cef`) -#### Natives +##### Natives - 'Unity Web Browser CEF Engine (Windows x64)' (`unitywebbrowser.engine.cef.win.x64`) - 'Unity Web Browser CEF Engine (Linux x64)' (`unitywebbrowser.engine.cef.linux.x64`) +- 'Unity Web Browser CEF Engine (MacOS x64)' (`unitywebbrowser.engine.cef.macos.x64`) +- 'Unity Web Browser CEF Engine (MacOS arm64)' (`unitywebbrowser.engine.cef.macos.arm64`) -## WebView2 Engine +#### MacOS Support -The WebView2 Engine is a planned engine. No development has been done on it yet, and no promises have been made on developing it! +Builds of CEF engine are provided for MacOs (both x64 and ARM). However the builds are not code signed! You will need to sign the UnityWebBrowser.Engine.Cef app your self. -[WebView2](https://developer.microsoft.com/en-us/microsoft-edge/webview2/) is Microsoft's embedded version of Edge. +## Engine Communication -### Platform Support +By default, communication between the engine and core is done using TCP. If the optional pipes communication layer package is installed, pipes may be used instead. -WebView2 will be Windows only. +You can change what communication system is used in the client settings. -### Packages - -Is only a planned engine, nothing has been done yet. +![Packages](~/assets/images/articles/user/engines/CommunicationLayer.webp) diff --git a/docs/articles/user/events.md b/docs/articles/user/events.md index b7a6683c..fee57ed4 100644 --- a/docs/articles/user/events.md +++ b/docs/articles/user/events.md @@ -2,7 +2,7 @@ The includes a fair number of [events](https://learn.microsoft.com/en-us/dotnet/standard/events/). You can use these events to listen to certain actions and perform an action. All events are fired on the main Unity thread. -You can subscribe to an even like so: +You can subscribe to an event like so: ```csharp public class UWBPrjDemo : MonoBehaviour diff --git a/docs/articles/user/javascript.md b/docs/articles/user/javascript.md index 0db6f415..162949fd 100644 --- a/docs/articles/user/javascript.md +++ b/docs/articles/user/javascript.md @@ -1,5 +1,7 @@ # JavaScript +UWB supports JS interop, allowing both the core (Unity) to call JS, as well the JS side to invoke .NET methods using a system in UWB called "JS Methods". + ## Executing JS You can execute JS in the browser using the method. The method takes in a string containing your full JS code, and executes it on the current page loaded in the browser. @@ -14,7 +16,7 @@ Which will result in the log message being logged out: ## JS Methods -JS methods are a way of calling .NET methods from JS code. JS methods are invoked on the JS side by calling `uwb.ExecuteJsMethod(, arguments);`. The `ExecuteJsMethod` function, on success, will immediately return `true`. +JS methods are a way of calling .NET methods from JS code. JS methods are invoked on the JS side by calling the `uwb.ExecuteJsMethod(, arguments);` function. The `ExecuteJsMethod` function, on success, will immediately return `true`. ### Argument Data Types diff --git a/docs/articles/user/packages.md b/docs/articles/user/packages.md index aecc7b76..80fa3f2e 100644 --- a/docs/articles/user/packages.md +++ b/docs/articles/user/packages.md @@ -7,23 +7,25 @@ UWB is designed to be modular and extended, and as such is split into multiple p |Core |✔ |Core UWB package, provides the heart of UWB | |Engine |✔ |Provides an Engine | |Engine Native |✔ (System)|Provides the native binaries used by an Engine. What ones you install depend on your platform targets| -|Helper |✖ |Provides additional helper/extensions to UWB | -Most developers will probably only need the 'Core' package, and a single Engine with the Native Windows binaries, like so: +## Package List -![Packages](~/assets/images/articles/user/packages/StandardPackages.webp) +Once you have the registry setup, you should be able to see the packages in the package manager. If not try refreshing, or add the packages you need by their ID. -If you plan on targeting Linux (or are developing on Linux), install the Engine's Linux binaries. +|Package |Package Type |Package ID | +|----------------------------------------------- |------------- |----------------------------------------------------- | +|Unity Web Browser |Core |`dev.voltstro.unitywebbrowser` | +|Unity Web Browser CEF Engine |Engine |`dev.voltstro.unitywebbrowser.engine.cef` | +|Unity Web Browser CEF Engine (Linux x64) |Engine Native |`dev.voltstro.unitywebbrowser.engine.cef.linux.x64` | +|Unity Web Browser CEF Engine (Windows x64) |Engine Native |`dev.voltstro.unitywebbrowser.engine.cef.win.x64` | +|Unity Web Browser CEF Engine (MacOS x64) |Engine Native |`dev.voltstro.unitywebbrowser.engine.cef.macos.x64` | +|Unity Web Browser CEF Engine (MacOS arm64) |Engine Native |`dev.voltstro.unitywebbrowser.engine.cef.macos.arm64` | +|Unity Web Browser Pipes Communication |Helper |`dev.voltstro.unitywebbrowser.communication.pipes` | -## Package List +## Deprecated Packages -Once you have the registry setup, you should be able to see the packages in the package manager. If not try refreshing, or add the packages you need by their ID. +These packages are no longer needed. |Package |Package Type |Package ID | |----------------------------------------------- |------------- |-------------------------------------------------- | -|Unity Web Browser |Core |`dev.voltstro.unitywebbrowser` | -|Unity Web Browser CEF Engine |Engine |`dev.voltstro.unitywebbrowser.engine.cef` | -|Unity Web Browser CEF Engine (Linux x64) |Engine Native |`dev.voltstro.unitywebbrowser.engine.cef.linux.x64`| -|Unity Web Browser CEF Engine (Windows x64) |Engine Native |`dev.voltstro.unitywebbrowser.engine.cef.win.x64` | -|Unity Web Browser Pipes Communication |Helper |`dev.voltstro.unitywebbrowser.communication.pipes` | |Unity Web Browser Unix Support |Helper |`dev.voltstro.unitywebbrowser.unix-support` | diff --git a/docs/articles/user/player-build.md b/docs/articles/user/player-build.md new file mode 100644 index 00000000..95fb2d08 --- /dev/null +++ b/docs/articles/user/player-build.md @@ -0,0 +1,26 @@ +# Player Build + +When creating a player build in Unity, UWB will automatically copy engine files from the native packages to the output folder. This is done using Unity's build pipeline postprocess feature, using the [IPostprocessBuildWithReport](https://docs.unity3d.com/2021.3/Documentation/ScriptReference/Build.IPostprocessBuildWithReport.html) interface. + +## Paths + +By default, the engines files will be placed in a certain directory in your build folder. The path changes slightly depending what platform you are building for. + +|Platform |Path | +|---------- |-------------------------------- | +|Windows x64|`/_Data/UWB/` | +|Linux x64 |`/_Data/UWB/` | +|MacOS x64 |`.app/Contents/Frameworks/`| +|MacOS arm64|`.app/Contents/Frameworks/`| + +## MacOS + +UWB does not provide signed builds of any of its engines. You will need to create the entitlements, sign and notarize the engine app. [Unity has some docs on signing](https://docs.unity3d.com/2021.3/Documentation/Manual/macos-building-notarization.html), a similar process should apply to signing the engine app. + +## Disable + +To disable UWB's built-in postprocessor, define `UWB_DISABLE_POSTPROCESSOR` in your project's player settings. + +![Player Settings](~/assets/images/articles/user/player-build/player-settings.webp) + +You may wish to do this if you have customized your engine's pathing, but you will need to copy the engine files from the packages your self diff --git a/docs/articles/user/setup.md b/docs/articles/user/setup.md index ac733702..91ee67a5 100644 --- a/docs/articles/user/setup.md +++ b/docs/articles/user/setup.md @@ -1,6 +1,6 @@ # Setup -We first need to setup your project for UWB. +Welcome! To start using UWB in your project, there is first some initial setup that needs to be done first. ## Prerequisites @@ -10,39 +10,53 @@ Unity 2021.3.x Newer Unity versions should work, but are untested! -## Registry Setup +## Platform Support -To install UWB, the Voltstro UPM registry needs to be added to your project. +At a base level, UWB supports all major desktop platforms (Windows, Linux and MacOS). However, different engines may have different platform support. Platform different engines support are listed in the [engines section](engines.md). -To setup the registry with your project, [see here](https://github.com/Voltstro/VoltstroUPM#setup). The Voltstro UPM page also lists some other info that you may be interested in. +> [!WARNING] +> UWB does **NOT** support [IL2CPP](https://docs.unity3d.com/Manual/IL2CPP.html). This is because UWB requires launching a separate process, which uses System.Diagnostics.Process API that [IL2CPP doesn't support](https://docs.unity3d.com/2021.3/Documentation/Manual/ScriptingRestrictions.html). +> +> UWB does however support being code trimmed. + +## VoltUPM Setup + +VoltUPM is a Unity registry that we provide for hosting some of our packages, including all of UWB's packages. To use it, your project needs to be configured to use the VoltUPM registry. + +To setup the registry with your project, [see here](https://github.com/Voltstro/VoltstroUPM#setup). The VoltUPM page also lists some other info that you may be interested in. **HOWEVER**, an additional scope needs to be added. You need to make sure `com.cysharp.unitask` is added (more details are provided in the [UniTask part](#unitask)). Once you are done configuring your projects registries, your configuration should look like: ![Registry](~/assets/images/articles/user/setup/Registry.webp) > [!NOTE] -> If are using [UnityNuGet](https://github.com/xoofx/UnityNuGet), and you choose not to use the Voltstro UPM as a `org.nuget.*` scope mirror, then don't have the `org.nuget` scope defined for the Voltstro UPM. +> If you are using [UnityNuGet](https://github.com/xoofx/UnityNuGet), and you choose not to use VoltUPM as a `org.nuget.*` scope mirror, then don't have the `org.nuget` scope defined for VoltUPM. ### UniTask -> [!TIP] -> You are not already using UniTask, you can [skip this part](#installation). - -The reason why we need to add the additional `com.cysharp.unitask` scope to VoltstroUPM is because UWB depends on [UniTask](https://github.com/Cysharp/UniTask). VoltstroUPM does provide a mirror copy (from OpenUPM) of UniTask, -however you may already have UniTask installed via [OpenUPM](https://openupm.com/packages/com.cysharp.unitask/), or via [Git](https://github.com/Cysharp/UniTask#install-via-git-url). If you do have it installed already, -and you don't want to use VoltstroUPM's mirror of it, then DO NOT define the additional scope as apart of VoltstroUPM. +The reason why we need to add the additional `com.cysharp.unitask` scope to VoltUPM is because UWB depends on [UniTask](https://github.com/Cysharp/UniTask). VoltUPM does provide a mirror copy of UniTask (from OpenUPM), +however you may already have UniTask installed either via [OpenUPM](https://openupm.com/packages/com.cysharp.unitask/), or via [Git](https://github.com/Cysharp/UniTask#install-via-git-url). If you do have it installed already, +and you don't want to use VoltUPM's mirror of it, then DO NOT define the additional scope as apart of VoltUPM. > [!WARNING] > If you already have UniTask installed via Git, please make sure it is the latest version! -## Installation +## Packages Installation -Once you have your registries setup, you can install the packages via UPM GUI. +Once you have VoltUPM registry added to your project, you can install the packages via the Unity package manager GUI. ![Packages](~/assets/images/articles/user/setup/Packages.webp) -You will need the core "Unity Web Browser" package (`dev.voltstro.unitywebbrowser`). An engine package (and it's engine native package) is also required. For more details on what engines are available and their packages, see the [engines section](engines.md). +To know what packages you need, checkout the [packages section](packages.md). + +### Standard Loadout + +Most developers will probably only need the 'Core' package, and a single engine with it's native Windows binaries. A basic installation might look like this. + +![Packages](~/assets/images/articles/user/packages/StandardPackages.webp) + +If you plan on providing builds of your game for Linux and MacOS, install their native engine packages as well. -For more information on the different packages, see the [packages section](packages.md). +## Usage -Once you are ready, you can move onto the [usage section](usage.md). +Once you have all the required packages that you might need, you can move onto the [usage section](usage.md). diff --git a/docs/articles/user/usage.md b/docs/articles/user/usage.md index 2388610d..6f75e9d0 100644 --- a/docs/articles/user/usage.md +++ b/docs/articles/user/usage.md @@ -2,15 +2,6 @@ Alright, lets get to actually using UWB. -## Platform Support - -UWB aims to support all desktop platforms (Windows, Linux, MacOS). The core currently does support all desktop platforms, however you will have to factor in what engine you want to use. Each engine has their own different platform support. See the [engine page](engines.md) for each engine's platform support. - -> [!WARNING] -> UWB does **NOT** support [IL2CPP](https://docs.unity3d.com/Manual/IL2CPP.html). This is because UWB requires launching a separate process, which uses System.Diagnostics.Process API that [IL2CPP doesn't support](https://docs.unity3d.com/2021.3/Documentation/Manual/ScriptingRestrictions.html). -> -> UWB does however support being code trimmed. - ## Components By default, UWB provides two different components for handling web viewing from a [Raw Image](https://docs.unity3d.com/2021.3/Documentation/Manual/script-RawImage.html): @@ -22,13 +13,23 @@ While both of these components are fundamentally the same (they both inherit fro A component is also provided, to wrap around some methods provided in and expose them to Unity's UI system. +## Basic Setup + +At a bare minimum, you will need a gameobject with a raw image component and either a or component attached. Both components need to live on the same game object. + +Once added, configure options with an engine, a communication layer and an input handler, and you should be ready to go. + +![Basic Setup](~/assets/images/articles/user/usage/BasicSetup.webp) + +If you are still having difficulties setting up the components, [take a look at the sample](#samples). + ## Options Most options that you will ever need is in the , which is the core class for interfacing with UWB. -A lot options are exposed in the editor. +A lot of options are exposed in the editor. -![Web Browser Basic](~/assets/images/articles/user/usage/UWBOptions.webp) +![Options](~/assets/images/articles/user/usage/UWBOptions.webp) The options are all very self-explanatory. If you need more info about one, hover over it for it's tooltip. Some options are explained in more details further along in the docs. diff --git a/docs/assets/images/articles/user/engines/CommunicationLayer.webp b/docs/assets/images/articles/user/engines/CommunicationLayer.webp new file mode 100644 index 00000000..98a7c652 Binary files /dev/null and b/docs/assets/images/articles/user/engines/CommunicationLayer.webp differ diff --git a/docs/assets/images/articles/user/packages/StandardPackages.webp b/docs/assets/images/articles/user/packages/StandardPackages.webp deleted file mode 100644 index 67c2daf4..00000000 Binary files a/docs/assets/images/articles/user/packages/StandardPackages.webp and /dev/null differ diff --git a/docs/assets/images/articles/user/player-build/player-settings.webp b/docs/assets/images/articles/user/player-build/player-settings.webp new file mode 100644 index 00000000..a3d9901b Binary files /dev/null and b/docs/assets/images/articles/user/player-build/player-settings.webp differ diff --git a/docs/assets/images/articles/user/setup/Packages.webp b/docs/assets/images/articles/user/setup/Packages.webp index b5520814..29b1b412 100644 Binary files a/docs/assets/images/articles/user/setup/Packages.webp and b/docs/assets/images/articles/user/setup/Packages.webp differ diff --git a/docs/assets/images/articles/user/setup/StandardPackages.webp b/docs/assets/images/articles/user/setup/StandardPackages.webp new file mode 100644 index 00000000..29171f6a Binary files /dev/null and b/docs/assets/images/articles/user/setup/StandardPackages.webp differ diff --git a/docs/assets/images/articles/user/usage/BasicSetup.webp b/docs/assets/images/articles/user/usage/BasicSetup.webp new file mode 100644 index 00000000..fb0baf1d Binary files /dev/null and b/docs/assets/images/articles/user/usage/BasicSetup.webp differ diff --git a/docs/assets/images/articles/user/usage/UWBOptions.webp b/docs/assets/images/articles/user/usage/UWBOptions.webp index 7952b702..9a0c572b 100644 Binary files a/docs/assets/images/articles/user/usage/UWBOptions.webp and b/docs/assets/images/articles/user/usage/UWBOptions.webp differ diff --git a/docs/docfx.json b/docs/docfx.json index 849f308a..b9a385d7 100644 --- a/docs/docfx.json +++ b/docs/docfx.json @@ -7,6 +7,9 @@ "src": "../src/Packages/UnityWebBrowser", "files": [ "**/*.cs" + ], + "exclude": [ + "Samples~/**" ] }, { @@ -67,7 +70,8 @@ ], "xref": [ "https://github.com/dotnet/docfx/raw/main/.xrefmap.json", - "https://normanderwan.github.io/UnityXrefMaps/2021.3/xrefmap.yml" + "https://voltstro-studios.gitlab.io/UnityDocs/UnityXrefMaps/2021.3/xrefmap.yml", + "https://voltstro-studios.gitlab.io/UnityDocs/UnityXrefMaps/pkgs/com.unity.ugui@1.0/xrefmap.yml" ], "dest": "_site" } diff --git a/docs/index.md b/docs/index.md index 0ed72a22..389d305d 100644 --- a/docs/index.md +++ b/docs/index.md @@ -16,13 +16,13 @@

Easy installation with UPM

-

Add the custom registry to your Unity project, and then install like any other Unity package.

+

Add the custom registry to your Unity project, and then install and manage like any other Unity package

Multi-Platform Desktop Support

-

Supports Windows and Linux Natively

+

Supports Windows, Linux and MacOS natively

@@ -31,6 +31,12 @@

The provided UWB API allows for easily interacting with the engine

+
+

JS Interop

+
+

Both be able to call JS from Unity, or have JS call your .NET methods

+
+

Extendable

diff --git a/src/.editorconfig b/src/.editorconfig index 25041bbb..25363588 100644 --- a/src/.editorconfig +++ b/src/.editorconfig @@ -1,2 +1,2 @@ [*] -file_header_template=UnityWebBrowser (UWB)\nCopyright (c) 2021-2024 Voltstro-Studios\n\nThis project is under the MIT license. See the LICENSE.md file for more details. +file_header_template = UnityWebBrowser (UWB)\nCopyright (c) 2021-2024 Voltstro-Studios\n\nThis project is under the MIT license.See the LICENSE.md file for more details. diff --git a/src/DevScripts/build-pages.ps1 b/src/DevScripts/build-pages.ps1 deleted file mode 100644 index 28a7f1d1..00000000 --- a/src/DevScripts/build-pages.ps1 +++ /dev/null @@ -1,6 +0,0 @@ -Push-Location "$PSScriptRoot/../UnityWebBrowser.Pages/" - -& yarn -& yarn run build - -Pop-Location diff --git a/src/DevScripts/build_base.py b/src/DevScripts/build_base.py new file mode 100644 index 00000000..c6f0d48d --- /dev/null +++ b/src/DevScripts/build_base.py @@ -0,0 +1,30 @@ +import subprocess +import os + +package_rid_mapping = { + 'win-x64': 'Win-x64', + 'linux-x64': 'Linux-x64' +} + +def build_cef_engine(platform: str) -> None: + """ + Base CEF engine build for Windows and Linux + """ + if platform not in package_rid_mapping: + raise Exception('Platform {0} is not valid!'.format(platform)) + + platform_folder = package_rid_mapping[platform] + + cef_project_path = os.path.abspath(os.path.join(__file__, '../../UnityWebBrowser.Engine.Cef/Main/UnityWebBrowser.Engine.Cef.csproj')) + cef_publish_path = os.path.abspath(os.path.join(__file__, '../../Packages/UnityWebBrowser.Engine.Cef.{0}/Engine~'.format(platform_folder))) + + print('Build CEF project \'{0}\' to \'{1}\''.format(cef_project_path, cef_publish_path)) + + subprocess.run(['dotnet', 'publish', cef_project_path, '-r=' + platform, '-p:PublishDir=' + cef_publish_path, '--nologo']) + + +def build_project(project: str) -> None: + project_path = os.path.abspath(os.path.join(__file__, '../../{0}/{0}.csproj'.format(project))) + + subprocess.run(['dotnet', 'build', project_path, '-c=ReleaseUnity']) + diff --git a/src/DevScripts/build_base_macos.py b/src/DevScripts/build_base_macos.py new file mode 100644 index 00000000..c14f650e --- /dev/null +++ b/src/DevScripts/build_base_macos.py @@ -0,0 +1,79 @@ +import subprocess +import shutil +import os + +def build_cef_engine_macos(arch) -> None: + """ + MacOS custom build script. + + MacOS needs a custom build process because of the .plist files and specific folder layout the build needs to be in + """ + + # Project path + cef_engine_path = os.path.abspath(os.path.join(__file__, '../../UnityWebBrowser.Engine.Cef/Main')) + cef_engine_subprocess_path = os.path.abspath(os.path.join(__file__, '../../UnityWebBrowser.Engine.Cef/SubProcess')) + cef_engine_macos_path = os.path.abspath(os.path.join(__file__, '../../Packages/UnityWebBrowser.Engine.Cef.MacOS-{0}/Engine~/'.format(arch))) + + # Delete build dir + cef_engine_build_path = os.path.abspath(os.path.join(__file__, '../../UnityWebBrowser.Engine.Cef/bin/Release/publish/osx-{0}/'.format(arch))) + if os.path.exists(cef_engine_build_path): + shutil.rmtree(cef_engine_build_path) + + # First, build main CEF engine project + print('Building CEF Engine from {0}'.format(cef_engine_path)) + subprocess.run(['dotnet', 'publish', '-r=osx-{0}'.format(arch), '-c=Release'], cwd=cef_engine_path) + + # Build SubProcess + print('Building CEF Engine SubProcess from {0}'.format(cef_engine_subprocess_path)) + subprocess.run(['dotnet', 'publish', '-r=osx-{0}'.format(arch), '-c=Release'], cwd=cef_engine_subprocess_path) + + cef_framework_path = os.path.abspath(os.path.join(__file__, '../../ThirdParty/Libs/cef/macos{0}/Release/Chromium Embedded Framework.framework'.format(arch))) + + cef_engine_app_path = os.path.join(cef_engine_build_path, 'UnityWebBrowser.Engine.Cef.app') + cef_engine_app_contents_path = os.path.join(cef_engine_app_path, 'Contents') + cef_engine_app_macos_path = os.path.join(cef_engine_app_contents_path, 'MacOS') + cef_engine_app_resources_path = os.path.join(cef_engine_app_contents_path, 'Resources') + cef_engine_app_frameworks_path = os.path.join(cef_engine_app_contents_path, 'Frameworks/') + + os.makedirs(cef_engine_app_macos_path, exist_ok=True) + os.makedirs(cef_engine_app_resources_path, exist_ok=True) + os.makedirs(cef_engine_app_frameworks_path, exist_ok=True) + + shutil.copy(os.path.join(cef_engine_build_path, 'UnityWebBrowser.Engine.Cef'), cef_engine_app_macos_path) + shutil.copy(os.path.join(cef_engine_build_path, 'info.plist'), cef_engine_app_contents_path) + shutil.copy(os.path.join(cef_engine_build_path, 'icon.icns'), cef_engine_app_resources_path) + shutil.copytree(cef_framework_path, os.path.join(cef_engine_app_frameworks_path, 'Chromium Embedded Framework.framework')) + + # Copy the many different helper apps needed + subprocess_types = [ + None, + 'GPU', + 'Plugin', + 'Renderer' + ] + + for type in subprocess_types: + if not type: + name = '' + plist_file = 'info-subprocess.plist' + else: + name = ' ({0})'.format(type) + plist_file = 'info-subprocess-{0}.plist'.format(type.lower()) + + bundle_name = 'UnityWebBrowser.Engine.Cef.SubProcess{0}.app/Contents'.format(name) + cef_engine_subprocess_app_path = os.path.join(cef_engine_app_frameworks_path, bundle_name) + cef_engine_subprocess_macos_path = os.path.join(cef_engine_subprocess_app_path, 'MacOS') + + os.makedirs(cef_engine_subprocess_macos_path, exist_ok=True) + shutil.copy(os.path.join(cef_engine_build_path, plist_file), os.path.join(cef_engine_subprocess_app_path, 'info.plist')) + shutil.copy(os.path.join(cef_engine_build_path, 'UnityWebBrowser.Engine.Cef.SubProcess'), os.path.join(cef_engine_subprocess_macos_path, 'UnityWebBrowser.Engine.Cef.SubProcess{0}'.format(name))) + + # Copy final app bundle to MacOS package + if not os.path.exists(cef_engine_macos_path): + os.makedirs(cef_engine_macos_path, exist_ok=True) + + cef_app_final_path = os.path.join(cef_engine_macos_path, 'UnityWebBrowser.Engine.Cef.app') + if os.path.exists(cef_app_final_path): + shutil.rmtree(cef_app_final_path) + + shutil.copytree(cef_engine_app_path, cef_app_final_path) diff --git a/src/DevScripts/build_cef_linux64.py b/src/DevScripts/build_cef_linux64.py new file mode 100644 index 00000000..f75f1d54 --- /dev/null +++ b/src/DevScripts/build_cef_linux64.py @@ -0,0 +1,3 @@ +from build_base import build_cef_engine + +build_cef_engine('linux-x64') diff --git a/src/DevScripts/build_cef_macosarm64.py b/src/DevScripts/build_cef_macosarm64.py new file mode 100644 index 00000000..d47a2102 --- /dev/null +++ b/src/DevScripts/build_cef_macosarm64.py @@ -0,0 +1,3 @@ +from build_base_macos import build_cef_engine_macos + +build_cef_engine_macos('arm64') diff --git a/src/DevScripts/build_cef_macosx64.py b/src/DevScripts/build_cef_macosx64.py new file mode 100644 index 00000000..65c51b90 --- /dev/null +++ b/src/DevScripts/build_cef_macosx64.py @@ -0,0 +1,3 @@ +from build_base_macos import build_cef_engine_macos + +build_cef_engine_macos('x64') diff --git a/src/DevScripts/build_cef_windows64.py b/src/DevScripts/build_cef_windows64.py new file mode 100644 index 00000000..d7548487 --- /dev/null +++ b/src/DevScripts/build_cef_windows64.py @@ -0,0 +1,3 @@ +from build_base import build_cef_engine + +build_cef_engine('win-x64') diff --git a/src/DevScripts/build_shared.py b/src/DevScripts/build_shared.py new file mode 100644 index 00000000..23342045 --- /dev/null +++ b/src/DevScripts/build_shared.py @@ -0,0 +1,4 @@ + +from build_base import build_project + +build_project('VoltstroStudios.UnityWebBrowser.Shared') diff --git a/src/DevScripts/download-all.ps1 b/src/DevScripts/download-all.ps1 deleted file mode 100644 index 150c2cf4..00000000 --- a/src/DevScripts/download-all.ps1 +++ /dev/null @@ -1,3 +0,0 @@ -& "$PSScriptRoot/download-cef-windows.ps1" -& "$PSScriptRoot/download-cef-linux.ps1" -& "$PSScriptRoot/download-cef-macosx64.ps1" \ No newline at end of file diff --git a/src/DevScripts/download-cef-base.ps1 b/src/DevScripts/download-cef-base.ps1 deleted file mode 100644 index ad808034..00000000 --- a/src/DevScripts/download-cef-base.ps1 +++ /dev/null @@ -1,171 +0,0 @@ -#This script downloads the CEF binaries, since we can't include them in the repo (They are bigger then your mum surprisingly) -#CefGlue wants the EXACT correct CEF version, so we look at what CEF version CefGlue is targeting and download the right tar.bz2 -#file off from the CEF build server - -param -( - [Parameter(Mandatory=$true)] - [string] $OperatingSystem, - - [Parameter(Mandatory=$false)] - [bool] $Cleanup = $true, - - [Parameter(Mandatory=$false)] - [bool] $IncludeResources = $true -) - -function Reset -{ - #Reset our location - Pop-Location -} - -function CheckProcess -{ - param( - [Parameter (Mandatory = $true)] [String]$ErrorMessage, - [Parameter (Mandatory = $true)] [System.Diagnostics.Process]$Process - ) - - if($Process.ExitCode -ne 0) - { - Reset - throw $ErrorMessage - } -} - -# Version Check -if ($PSVersionTable.PSVersion.Major -lt 7) -{ - throw "You need to use the NEW PowerShell version! You can get it here: https://github.com/powershell/powershell#get-powershell" -} - -#Set location -Push-Location $PSScriptRoot - -#Find what version CefGlue wants -$CefGlueVersionFile = "../ThirdParty/CefGlue/CefGlue/Interop/version.g.cs" - -#Check if the version.g.cs file exists, if it doesn't then there is a good chance the user didn't clone the repo recursively, -#and didn't init the submodules. -if(-not (Test-Path -Path $CefGlueVersionFile)) -{ - Write-Warning "The CefGlue version file doesn't exist! Initalizing the submodules for you..." - Push-Location "$($PSScriptRoot)../../" - - #Run git submodule init and update - $p = Start-Process git -ArgumentList 'submodule init' -Wait -NoNewWindow -PassThru - CheckProcess "Error running git submodule init!" $p - - $p = Start-Process git -ArgumentList 'submodule update' -Wait -NoNewWindow -PassThru - CheckProcess "Error running git submodule update!" $p - - #Return location - Reset -} - -$CefGlueVersionfileContent = Get-Content $CefGlueVersionFile -$CefGlueVersionRegex = [regex] 'CEF_VERSION = \"(.*)\"' - -if(!$CefGlueVersionfileContent) -{ - Reset - throw "Failed to read version info!" -} - -$CefVersion = "" -foreach($Content in $CefGlueVersionfileContent) -{ - $Match = [System.Text.RegularExpressions.Regex]::Match($Content, $CefGlueVersionRegex) - if($Match.Success) - { - $CefVersion = $Match.groups[1].value - } -} - -#Create a temp directory -#NOTE: We have [void] at the start here so it doens't spew out the logs -[void](New-Item -Path "../ThirdParty/Libs/cef/" -Name "temp" -ItemType "directory" -Force) - -#Lots of variables we gonna use -$TempDirectory = (Resolve-Path -Path ../ThirdParty/Libs/cef/temp/).Path -$CefBinName = "cef_binary_$($cefVersion)_$($OperatingSystem)_minimal" -$CefBinTarFileName = "$($CefBinName).tar" -$CefBinTarFileLocation = "$($TempDirectory)$($CefBinTarFileName)" -$CefBinTarBz2FileName = "$($CefBinTarFileName).bz2" -$CefBinTarBz2FileLocation = "$($TempDirectory)$($CefBinTarBz2FileName)" - -Write-Output "Downloading CEF version $($CefVersion) for $($OperatingSystem)..." - -#We download the CEF builds off from Spotify's CEF build server -#The URL look like this: -# https://cef-builds.spotifycdn.com/cef_binary_[CEF-VERSION]_[OPERATING-SYSTEM]_minimal.tar.bz2 -# Example: https://cef-builds.spotifycdn.com/cef_binary_85.3.12+g3e94ebf+chromium-85.0.4183.121_linux64_minimal.tar.bz2 - -$progressPreference = 'silentlyContinue' -Invoke-WebRequest -Uri "https://cef-builds.spotifycdn.com/$($CefBinTarBz2FileName)" -OutFile $CefBinTarBz2FileLocation -$progressPreference = 'Continue' - -#Check to make sure the file downloaded -if(-not (Test-Path -Path $CefBinTarBz2FileLocation)) -{ - Reset - throw "CEF build failed to download!" -} - -Write-Output "Downloaded CEF build to '$($CefBinTarBz2FileLocation)'." -Write-Output "Exracting CEF build..." - -#Get 7Zip -$7zipApp = "" -if($IsLinux) -{ - $7zipApp = "../DevTools/7zip/linux-x64/7zz" -} -elseif($ISMacOs) -{ - $7zipApp = "../DevTools/7zip/macos-x64-intel/7zz" -} -else -{ - $7zipApp = "../DevTools/7zip/win-x64/7za.exe" -} - -$7zipApp = (Resolve-Path -Path $7zipApp).Path - -#Extract our files -$p = Start-Process $7zipApp -ArgumentList "x $($CefBinTarBz2FileLocation) -o$($TempDirectory) *.tar -r -y" -Wait -NoNewWindow -PassThru -CheckProcess "Extracting failed!" $p - -$p = Start-Process $7zipApp -ArgumentList "x $($CefBinTarFileLocation) -o$($TempDirectory) $($CefBinName)/ -r -y" -Wait -NoNewWindow -PassThru -CheckProcess "Extracting failed!" $p - -#Setup some variables to using the copying phase -$CefExtractedLocation = (Resolve-Path -Path "$($TempDirectory)/$($CefBinName)/").Path -$CefExtractedReleaseLocation = "$($CefExtractedLocation)Release/" - -$CefLibsLocation = (Resolve-Path -Path ../ThirdParty/Libs/cef/$($OperatingSystem)).Path - -#Copy files -Write-Output "Copying files..." -Copy-Item -Path "$($CefExtractedReleaseLocation)/*" -Destination $CefLibsLocation -Force -PassThru -Recurse - -if($IncludeResources) -{ - $CefExtractedResourcesLocation = "$($CefExtractedLocation)Resources/" - Copy-Item -Path "$($CefExtractedResourcesLocation)/*" -Destination $CefLibsLocation -Force -PassThru -Recurse -} - -Copy-Item -Path "$($CefExtractedLocation)/README.txt" -Destination $CefLibsLocation -Force -PassThru -Copy-Item -Path "$($CefExtractedLocation)/LICENSE.txt" -Destination $CefLibsLocation -Force -PassThru - -#Cleanup -if($Cleanup) -{ - Write-Output "Cleaning up..." - Remove-Item -Path $CefBinTarFileLocation -Force - Remove-Item -Path $CefBinTarBz2FileLocation -Force - Remove-Item -Path $CefExtractedLocation -Force -Recurse -} - -Reset \ No newline at end of file diff --git a/src/DevScripts/download-cef-linux.ps1 b/src/DevScripts/download-cef-linux.ps1 deleted file mode 100644 index 74e8332c..00000000 --- a/src/DevScripts/download-cef-linux.ps1 +++ /dev/null @@ -1,15 +0,0 @@ -#Run the base script first -& "$PSScriptRoot/download-cef-base.ps1" linux64 - -#"strip" libs of their debug symbols -if($IsLinux) -{ - Write-Output "Stipping Linux CEF libs from their debug symbols..." - Get-ChildItem -Path "../ThirdParty/Libs/cef/linux64/*.so" -Recurse | % { & strip "$($_.FullName)" } -} -else -{ - Write-Warning "Not striping Linux CEF libs. You need to be running under Linux for that." -} - -Write-Output "Done!" \ No newline at end of file diff --git a/src/DevScripts/download-cef-macosx64.ps1 b/src/DevScripts/download-cef-macosx64.ps1 deleted file mode 100644 index 0af20b8b..00000000 --- a/src/DevScripts/download-cef-macosx64.ps1 +++ /dev/null @@ -1,5 +0,0 @@ -& "$PSScriptRoot/download-cef-base.ps1" macosx64 -IncludeResources $false - -Move-Item "../ThirdParty/Libs/cef/macosx64/Chromium Embedded Framework.framework/Chromium Embedded Framework" "../ThirdParty/Libs/cef/macosx64/Chromium Embedded Framework.framework/libcef.dylib" -Force - -Write-Output "Done!" \ No newline at end of file diff --git a/src/DevScripts/download-cef-windows.ps1 b/src/DevScripts/download-cef-windows.ps1 deleted file mode 100644 index 7e59ecbe..00000000 --- a/src/DevScripts/download-cef-windows.ps1 +++ /dev/null @@ -1,3 +0,0 @@ -& "$PSScriptRoot/download-cef-base.ps1" windows64 - -Write-Output "Done!" \ No newline at end of file diff --git a/src/DevScripts/download_cef_base.py b/src/DevScripts/download_cef_base.py new file mode 100644 index 00000000..3ac830ce --- /dev/null +++ b/src/DevScripts/download_cef_base.py @@ -0,0 +1,60 @@ +import os +import re +import shutil + +from urllib.request import urlretrieve +from tarfile import open as taropen + +def download_cef(os_platform: str) -> str: + """ + Downloads and extracts CEF binaries + + Returns where the extract tar contents are + """ + + # Get and read version file + cef_version_file = os.path.abspath(os.path.join(__file__, '../../ThirdParty/CefGlue/CefGlue/Interop/version.g.cs')) + if not os.path.exists(cef_version_file): + raise Exception('Cef version file does not exist!') + + with open(cef_version_file, 'r') as version_file: + version_file = version_file.read() + + # Find version in file + matches = re.search(r'CEF_VERSION = \"(.*)\"', version_file) + version_match = matches.group(1) + + # Get temp path + temp_path = os.path.abspath(os.path.join(__file__, '../../ThirdParty/Libs/cef/temp/')) + if not os.path.exists(temp_path): + os.makedirs(temp_path, exist_ok=True) + + # Download compiled cef tar.bz2 + cef_tar_name = 'cef_binary_{0}_{1}_minimal'.format(version_match, os_platform) + cef_tar_download_url = 'https://cef-builds.spotifycdn.com/{0}.tar.bz2'.format(cef_tar_name) + cef_tar_path = os.path.join(temp_path, '{0}.tar.bz2'.format(cef_tar_name)) + + print('Downloading cef tar.gz from \'{0}\' to \'{1}\''.format(cef_tar_download_url, cef_tar_path)) + urlretrieve(cef_tar_download_url, cef_tar_path) + if not os.path.exists(cef_tar_path): + raise Exception('Cef tar download filed!') + + # Extract tar.bz2 + cef_extracted_tar_path = os.path.abspath(os.path.join(__file__, '../../ThirdParty/Libs/cef/{0}'.format(os_platform))) + if os.path.exists(cef_extracted_tar_path): + shutil.rmtree(cef_extracted_tar_path) + os.makedirs(cef_extracted_tar_path, exist_ok=True) + + print('Extracting \'{0}\' to \'{1}\'...'.format(cef_tar_path, cef_extracted_tar_path)) + + cef_tar_name_length = len(cef_tar_name) + 1 + + with taropen(cef_tar_path) as tar_file: + cef_subdir_files = [] + for member in tar_file.getmembers(): + member.path = member.path[cef_tar_name_length:] + cef_subdir_files.append(member) + + tar_file.extractall(cef_extracted_tar_path, members=cef_subdir_files) + + return cef_extracted_tar_path diff --git a/src/DevScripts/download_cef_linux64.py b/src/DevScripts/download_cef_linux64.py new file mode 100644 index 00000000..a5e264d3 --- /dev/null +++ b/src/DevScripts/download_cef_linux64.py @@ -0,0 +1,13 @@ +import subprocess + +from os.path import join +from glob import glob + +from download_cef_base import download_cef + +cef_extracted_tar_path = download_cef('linux64') + +print('Stripping binaries with sstrip') +dynamic_binaries = glob(join(cef_extracted_tar_path, 'Release', '*.so*')) +for binary in dynamic_binaries: + subprocess.run(['strip', binary]) diff --git a/src/DevScripts/download_cef_macosarm64.py b/src/DevScripts/download_cef_macosarm64.py new file mode 100644 index 00000000..635b21bd --- /dev/null +++ b/src/DevScripts/download_cef_macosarm64.py @@ -0,0 +1,3 @@ +from download_cef_base import download_cef + +download_cef('macosarm64') diff --git a/src/DevScripts/download_cef_macosx64.py b/src/DevScripts/download_cef_macosx64.py new file mode 100644 index 00000000..405cc761 --- /dev/null +++ b/src/DevScripts/download_cef_macosx64.py @@ -0,0 +1,3 @@ +from download_cef_base import download_cef + +download_cef('macosx64') diff --git a/src/DevScripts/download_cef_windows64.py b/src/DevScripts/download_cef_windows64.py new file mode 100644 index 00000000..80896726 --- /dev/null +++ b/src/DevScripts/download_cef_windows64.py @@ -0,0 +1,3 @@ +from download_cef_base import download_cef + +download_cef('windows64') diff --git a/src/DevScripts/publish-all.ps1 b/src/DevScripts/publish-all.ps1 deleted file mode 100644 index bb9cedae..00000000 --- a/src/DevScripts/publish-all.ps1 +++ /dev/null @@ -1,4 +0,0 @@ -& "$PSScriptRoot/publish-shared.ps1" -& "$PSScriptRoot/publish-cef-engine-windows.ps1" -& "$PSScriptRoot/publish-cef-engine-linux.ps1" -& "$PSScriptRoot/publish-cef-engine-macos64.ps1" \ No newline at end of file diff --git a/src/DevScripts/publish-cef-engine-linux.ps1 b/src/DevScripts/publish-cef-engine-linux.ps1 deleted file mode 100644 index d6ada8a8..00000000 --- a/src/DevScripts/publish-cef-engine-linux.ps1 +++ /dev/null @@ -1,12 +0,0 @@ -# Any platform can compile Linux Ready to Run -# https://docs.microsoft.com/en-us/dotnet/core/deploying/ready-to-run#cross-platformarchitecture-restrictions - -dotnet publish ../UnityWebBrowser.Engine.Cef/UnityWebBrowser.Engine.Cef.csproj -c ReleaseUnity -r linux-x64 -p:PublishReadyToRun=true --self-contained true --nologo - -#Create Engine~/ directory if it doesn't exist -if (-Not (Test-Path "../Packages/UnityWebBrowser.Engine.Cef.Linux-x64/Engine~/")) { - New-Item -Path "../Packages/UnityWebBrowser.Engine.Cef.Linux-x64/Engine~/" -ItemType Directory - New-Item -Path "../Packages/UnityWebBrowser.Engine.Cef.Linux-x64/Engine~/swiftshader/" -ItemType Directory -} - -Copy-Item -Path "../UnityWebBrowser.Engine.Cef/bin/ReleaseUnity/linux-x64/publish/*" -Destination "../Packages/UnityWebBrowser.Engine.Cef.Linux-x64/Engine~/" -Recurse -Force -PassThru \ No newline at end of file diff --git a/src/DevScripts/publish-cef-engine-macos64.ps1 b/src/DevScripts/publish-cef-engine-macos64.ps1 deleted file mode 100644 index 0aa1a9a3..00000000 --- a/src/DevScripts/publish-cef-engine-macos64.ps1 +++ /dev/null @@ -1,12 +0,0 @@ -# Any platform can compile MacOS Ready to Run -# https://docs.microsoft.com/en-us/dotnet/core/deploying/ready-to-run#cross-platformarchitecture-restrictions - -dotnet publish ../UnityWebBrowser.Engine.Cef/UnityWebBrowser.Engine.Cef.csproj -c ReleaseUnity -r osx-x64 -p:PublishReadyToRun=true --self-contained true --nologo - -#Create Engine~/ directory if it doesn't exist -if (-Not (Test-Path "../Packages/UnityWebBrowser.Engine.Cef.MacOS-x64/Engine~/")) { - New-Item -Path "../Packages/UnityWebBrowser.Engine.Cef.MacOS-x64/Engine~/" -ItemType Directory - New-Item -Path "../Packages/UnityWebBrowser.Engine.Cef.MacOS-x64/Engine~/swiftshader/" -ItemType Directory -} - -Copy-Item -Path "../UnityWebBrowser.Engine.Cef/bin/ReleaseUnity/osx-x64/publish/*" -Destination "../Packages/UnityWebBrowser.Engine.Cef.MacOS-x64/Engine~/" -Recurse -Force -PassThru \ No newline at end of file diff --git a/src/DevScripts/publish-cef-engine-windows.ps1 b/src/DevScripts/publish-cef-engine-windows.ps1 deleted file mode 100644 index e90018f6..00000000 --- a/src/DevScripts/publish-cef-engine-windows.ps1 +++ /dev/null @@ -1,19 +0,0 @@ -# Only Windows can compile Windows Ready to Run -# https://docs.microsoft.com/en-us/dotnet/core/deploying/ready-to-run#cross-platformarchitecture-restrictions - -if($IsWindows) -{ - dotnet publish ../UnityWebBrowser.Engine.Cef/UnityWebBrowser.Engine.Cef.csproj -c ReleaseUnity -r win-x64 -p:PublishReadyToRun=true --self-contained true --nologo -} -else -{ - dotnet publish ../UnityWebBrowser.Engine.Cef/UnityWebBrowser.Engine.Cef.csproj -c ReleaseUnity -r win-x64 --self-contained true --nologo -} - -#Create Engine~/ directory if it doesn't exist -if (-Not (Test-Path "../Packages/UnityWebBrowser.Engine.Cef.Win-x64/Engine~/")) { - New-Item -Path "../Packages/UnityWebBrowser.Engine.Cef.Win-x64/Engine~/" -ItemType Directory - New-Item -Path "../Packages/UnityWebBrowser.Engine.Cef.Win-x64/Engine~/swiftshader/" -ItemType Directory -} - -Copy-Item -Path "../UnityWebBrowser.Engine.Cef/bin/ReleaseUnity/win-x64/publish/*" -Destination "../Packages/UnityWebBrowser.Engine.Cef.Win-x64/Engine~/" -Recurse -Force -PassThru \ No newline at end of file diff --git a/src/DevScripts/publish-shared.ps1 b/src/DevScripts/publish-shared.ps1 deleted file mode 100644 index 4adeb069..00000000 --- a/src/DevScripts/publish-shared.ps1 +++ /dev/null @@ -1 +0,0 @@ -dotnet build ../VoltstroStudios.UnityWebBrowser.Shared/VoltstroStudios.UnityWebBrowser.Shared.csproj -c ReleaseUnity --nologo \ No newline at end of file diff --git a/src/DevScripts/setup_all.py b/src/DevScripts/setup_all.py new file mode 100644 index 00000000..91014111 --- /dev/null +++ b/src/DevScripts/setup_all.py @@ -0,0 +1,39 @@ +from os import path +from subprocess import run +from platform import system + +from download_cef_base import download_cef +from build_base import build_cef_engine, build_project +from build_base_macos import build_cef_engine_macos + +# Setup All. Configure UWB repo on the current running platform + +# Make sure CefGlue git module exists +cefglue_path = path.abspath(path.join(__file__, '../../ThirdParty/CefGlue/')) +if not path.exists(cefglue_path): + print('CefGlue git submodule does not exist! Assuming user has not cloned repo recursively and will attempt to init and update submodules...') + run(['git', 'submodule', 'init']) + run(['git', 'submodule', 'update']) + +# Build shared first, needed by everything +build_project('VoltstroStudios.UnityWebBrowser.Shared') + +running_system = system() + +# Windows +if running_system == 'Windows': + download_cef('windows64') + build_cef_engine('win-x64') + +# Linux +if running_system == 'Linux': + download_cef('linux64') + build_cef_engine('linux-x64') + +# MacOS +if running_system == 'Darwin': + download_cef('macosx64') + download_cef('macosarm64') + + build_cef_engine_macos('x64') + build_cef_engine_macos('arm64') diff --git a/src/DevScripts/sync-package-all.ps1 b/src/DevScripts/sync-package-all.ps1 deleted file mode 100644 index 70a88b27..00000000 --- a/src/DevScripts/sync-package-all.ps1 +++ /dev/null @@ -1,2 +0,0 @@ -& "$PSScriptRoot/sync-package-main.ps1" -& "$PSScriptRoot/sync-package-cef-engine.ps1" \ No newline at end of file diff --git a/src/DevScripts/sync-package-cef-engine.ps1 b/src/DevScripts/sync-package-cef-engine.ps1 deleted file mode 100644 index eac4b7a4..00000000 --- a/src/DevScripts/sync-package-cef-engine.ps1 +++ /dev/null @@ -1,48 +0,0 @@ -# Version Check -if ($PSVersionTable.PSVersion.Major -lt 7) -{ - throw "You need to use the NEW PowerShell version! You can get it here: https://github.com/powershell/powershell#get-powershell" -} - -$LicensePath = "../../LICENSE.md" -Copy-Item -Path $LicensePath -Destination "../Packages/UnityWebBrowser.Engine.Cef/LICENSE.md" -Force -PassThru -Copy-Item -Path $LicensePath -Destination "../Packages/UnityWebBrowser.Engine.Cef.Linux-x64/LICENSE.md" -Force -PassThru -Copy-Item -Path $LicensePath -Destination "../Packages/UnityWebBrowser.Engine.Cef.Win-x64/LICENSE.md" -Force -PassThru - -#Find what version of CefGlue we are using -$CefGlueVersionFile = "../ThirdParty/CefGlue/CefGlue/Interop/version.g.cs" -$CefGlueVersionfileContent = Get-Content $CefGlueVersionFile -$CefGlueVersionRegex = [regex] 'CEF_VERSION = \"(\d+.\d+.\d+)' - -$CefVersion = "" -foreach($Content in $CefGlueVersionfileContent) -{ - $Match = [System.Text.RegularExpressions.Regex]::Match($Content, $CefGlueVersionRegex) - if($Match.Success) - { - $CefVersion = $Match.groups[1].value - } -} - -$CorePackagePath = "../Packages/UnityWebBrowser/package.json" -$CorePackageJson = Get-Content $CorePackagePath | ConvertFrom-Json -AsHashtable -$CorePackageVersion = $CorePackageJson["version"] - -$CefPackagesVersion = "$($CorePackageVersion)-$($CefVersion)" - -$EngineCefJsonPath = "../Packages/UnityWebBrowser.Engine.Cef/package.json" -$EngineCefJson = Get-Content $EngineCefJsonPath | ConvertFrom-Json -AsHashtable -$EngineCefJson["version"] = $CefPackagesVersion -$EngineCefJson | ConvertTo-Json | Out-File -FilePath $EngineCefJsonPath - -$EngineCefLinuxJsonPath = "../Packages/UnityWebBrowser.Engine.Cef.Linux-x64/package.json" -$EngineCefLinuxJson = Get-Content $EngineCefLinuxJsonPath | ConvertFrom-Json -AsHashtable -$EngineCefLinuxJson["version"] = $CefPackagesVersion -$EngineCefLinuxJson["dependencies"]["dev.voltstro.unitywebbrowser.engine.cef"] = $CefPackagesVersion -$EngineCefLinuxJson | ConvertTo-Json | Out-File -FilePath $EngineCefLinuxJsonPath - -$EngineCefWinJsonPath = "../Packages/UnityWebBrowser.Engine.Cef.Win-x64/package.json" -$EngineCefWinJson = Get-Content $EngineCefWinJsonPath | ConvertFrom-Json -AsHashtable -$EngineCefWinJson["version"] = $CefPackagesVersion -$EngineCefWinJson["dependencies"]["dev.voltstro.unitywebbrowser.engine.cef"] = $CefPackagesVersion -$EngineCefWinJson | ConvertTo-Json | Out-File -FilePath $EngineCefWinJsonPath \ No newline at end of file diff --git a/src/DevScripts/sync-package-main.ps1 b/src/DevScripts/sync-package-main.ps1 deleted file mode 100644 index 1bdf715a..00000000 --- a/src/DevScripts/sync-package-main.ps1 +++ /dev/null @@ -1,3 +0,0 @@ -Copy-Item -Path "../../LICENSE.md" -Destination "../Packages/UnityWebBrowser/LICENSE.md" -Force -PassThru -Copy-Item -Path "../../LICENSE.md" -Destination "../Packages/UnityWebBrowser.Communication.Pipes/LICENSE.md" -Force -PassThru -Copy-Item -Path "../../LICENSE.md" -Destination "../Packages/UnityWebBrowser.Unix-Support/LICENSE.md" -Force -PassThru \ No newline at end of file diff --git a/src/DevScripts/sync_info.py b/src/DevScripts/sync_info.py new file mode 100644 index 00000000..4a789662 --- /dev/null +++ b/src/DevScripts/sync_info.py @@ -0,0 +1,104 @@ +# Script that syncs info such as versions + +import json +from os import path +from shutil import copy, move +from typing import Any + +def read_json_from_file(file_path: str) -> Any: + with open(file_path, 'r') as f: + json_content = json.load(f) + return json_content + +def write_json_to_file(content: Any, file_path: str) -> None: + with open(file_path, 'w', encoding='utf-8') as f: + json.dump(content, f, ensure_ascii=False, indent=2) + +def sync_package(package: str, version: str, sub_version: str, license_path: str) -> None: + package_path = path.abspath(path.join(__file__, '../../Packages/{0}/'.format(package))) + package_json_path = path.join(package_path, 'package.json') + + package_json = read_json_from_file(package_json_path) + + new_package_version = version + if sub_version: + new_package_version += '-{0}'.format(sub_version) + + # Set new package version + package_json['version'] = new_package_version + + # Deal with package dependencies + dependencies = package_json.get('dependencies') + if dependencies: + for dep in dependencies: + if not dep.startswith('dev.voltstro.unitywebbrowser'): + continue + + # Main dependencies will just be main version + dep_version = version + + # Engine dependencies will have sub version + if dep.find('engine') != -1: + dep_version = new_package_version + + dependencies[dep] = dep_version + package_json['dependencies'] = dependencies + + write_json_to_file(package_json, package_json_path) + copy(license_path, package_path) + + +# Get main version.json version +version_json_path = path.abspath(path.join(__file__, '../../version.json')) +version_json = read_json_from_file(version_json_path) + +version = version_json['version'] +license_path = path.abspath(path.join(__file__, '../../../LICENSE.md')) + +# Sync CEF Engine version.json +cef_engine_version_json_path = path.abspath(path.join(__file__, '../../UnityWebBrowser.Engine.Cef/version.json')) +cef_engine_version_json = read_json_from_file(cef_engine_version_json_path) +cef_engine_versions = cef_engine_version_json['version'].split('-') + +cef_engine_versions[0] = version + +cef_engine_version = '-'.join(cef_engine_versions) +cef_engine_version_json['version'] = cef_engine_version +write_json_to_file(cef_engine_version_json, cef_engine_version_json_path) + +cef_version = cef_engine_versions[1] + +# Package Name - Sub Version +packages = { + 'UnityWebBrowser': None, + 'UnityWebBrowser.Communication.Pipes': None, + 'UnityWebBrowser.Engine.Cef': cef_version, + 'UnityWebBrowser.Engine.Cef.Win-x64': cef_version, + 'UnityWebBrowser.Engine.Cef.Linux-x64': cef_version, + 'UnityWebBrowser.Engine.Cef.MacOS-x64': cef_version, + 'UnityWebBrowser.Engine.Cef.MacOS-arm64': cef_version, +} + +for package in packages: + sub_version = packages[package] + sync_package(package, version, sub_version, license_path) + +# Update assembly info +assembly_info_path = path.abspath(path.join(__file__, '../../Packages/UnityWebBrowser/Runtime/AssemblyInfo.cs')) +new_assembly_info_path = assembly_info_path + '.new' + +file_attributes = [ + '[assembly: AssemblyVersion("', + '[assembly: AssemblyFileVersion("' +] + +with open(assembly_info_path) as old, open(new_assembly_info_path, 'w') as new: + for line in old: + line = line.rstrip() + for attribute in file_attributes: + if(line.startswith(attribute)): + line = line[:len(attribute)] + version + '")]' + + new.write(line + '\n') + +move(new_assembly_info_path, assembly_info_path) diff --git a/src/DevTools/7zip/license.txt b/src/DevTools/7zip/license.txt deleted file mode 100644 index 83595661..00000000 --- a/src/DevTools/7zip/license.txt +++ /dev/null @@ -1,88 +0,0 @@ - 7-Zip - ~~~~~ - License for use and distribution - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - 7-Zip Copyright (C) 1999-2021 Igor Pavlov. - - The licenses for 7zz file are: - - - The "GNU LGPL" as main license for most of the code - - The "GNU LGPL" with "unRAR license restriction" for some code - - The "BSD 3-clause License" for some code - - Redistributions in binary form must reproduce related license information from this file. - - Note: - You can use 7-Zip on any computer, including a computer in a commercial - organization. You don't need to register or pay for 7-Zip. - - - GNU LGPL information - -------------------- - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You can receive a copy of the GNU Lesser General Public License from - http://www.gnu.org/ - - - - - BSD 3-clause License - -------------------- - - The "BSD 3-clause License" is used for the code in 7z.dll that implements LZFSE data decompression. - That code was derived from the code in the "LZFSE compression library" developed by Apple Inc, - that also uses the "BSD 3-clause License": - - ---- - Copyright (c) 2015-2016, Apple Inc. All rights reserved. - - Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer - in the documentation and/or other materials provided with the distribution. - - 3. Neither the name of the copyright holder(s) nor the names of any contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ---- - - - - - unRAR license restriction - ------------------------- - - The decompression engine for RAR archives was developed using source - code of unRAR program. - All copyrights to original unRAR code are owned by Alexander Roshal. - - The license for original unRAR code has the following restriction: - - The unRAR sources cannot be used to re-create the RAR compression algorithm, - which is proprietary. Distribution of modified unRAR sources in separate form - or as a part of other software is permitted, provided that it is clearly - stated in the documentation and source comments that the code may - not be used to develop a RAR (WinRAR) compatible archiver. - - - -- - Igor Pavlov diff --git a/src/DevTools/7zip/linux-x64/7zz b/src/DevTools/7zip/linux-x64/7zz deleted file mode 100755 index e44905e7..00000000 Binary files a/src/DevTools/7zip/linux-x64/7zz and /dev/null differ diff --git a/src/DevTools/7zip/macos-x64-intel/7zz b/src/DevTools/7zip/macos-x64-intel/7zz deleted file mode 100755 index 2f28ba30..00000000 Binary files a/src/DevTools/7zip/macos-x64-intel/7zz and /dev/null differ diff --git a/src/DevTools/7zip/win-x64/7za.dll b/src/DevTools/7zip/win-x64/7za.dll deleted file mode 100644 index e8d01c2f..00000000 Binary files a/src/DevTools/7zip/win-x64/7za.dll and /dev/null differ diff --git a/src/DevTools/7zip/win-x64/7za.exe b/src/DevTools/7zip/win-x64/7za.exe deleted file mode 100644 index 9544a638..00000000 Binary files a/src/DevTools/7zip/win-x64/7za.exe and /dev/null differ diff --git a/src/DevTools/7zip/win-x64/7zxa.dll b/src/DevTools/7zip/win-x64/7zxa.dll deleted file mode 100644 index 03e24691..00000000 Binary files a/src/DevTools/7zip/win-x64/7zxa.dll and /dev/null differ diff --git a/src/Directory.Build.props b/src/Directory.Build.props new file mode 100644 index 00000000..26f60945 --- /dev/null +++ b/src/Directory.Build.props @@ -0,0 +1,9 @@ + + + + + all + 3.6.143 + + + \ No newline at end of file diff --git a/src/Packages/UnityWebBrowser.Communication.Pipes/Runtime/Base.meta b/src/Packages/UnityWebBrowser.Communication.Pipes/Runtime/Base.meta deleted file mode 100644 index 43b52c25..00000000 --- a/src/Packages/UnityWebBrowser.Communication.Pipes/Runtime/Base.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: a42be527e113dd7c5bde8268ca5bd98b -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/src/Packages/UnityWebBrowser.Communication.Pipes/Runtime/Base/EnginePipesCommunicationLayer.cs b/src/Packages/UnityWebBrowser.Communication.Pipes/Runtime/Base/EnginePipesCommunicationLayer.cs deleted file mode 100644 index c69be2ae..00000000 --- a/src/Packages/UnityWebBrowser.Communication.Pipes/Runtime/Base/EnginePipesCommunicationLayer.cs +++ /dev/null @@ -1,23 +0,0 @@ -// UnityWebBrowser (UWB) -// Copyright (c) 2021-2022 Voltstro-Studios -// -// This project is under the MIT license. See the LICENSE.md file for more details. - -using VoltRpc.Communication; -using VoltstroStudios.UnityWebBrowser.Shared.Communications; - -namespace VoltstroStudios.UnityWebBrowser.Communication.Pipes.Base -{ - public class EnginePipesCommunicationLayer : ICommunicationLayer - { - public Client CreateClient(string location) - { - return new PipesClient(location); - } - - public Host CreateHost(string location) - { - return new PipesHost(location); - } - } -} \ No newline at end of file diff --git a/src/Packages/UnityWebBrowser.Communication.Pipes/Runtime/Base/EnginePipesCommunicationLayer.cs.meta b/src/Packages/UnityWebBrowser.Communication.Pipes/Runtime/Base/EnginePipesCommunicationLayer.cs.meta deleted file mode 100644 index 1f394340..00000000 --- a/src/Packages/UnityWebBrowser.Communication.Pipes/Runtime/Base/EnginePipesCommunicationLayer.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: c2ee1bb4bc4498a6aa96f7c634c62c53 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/src/Packages/UnityWebBrowser.Communication.Pipes/Runtime/Base/PipesClient.cs b/src/Packages/UnityWebBrowser.Communication.Pipes/Runtime/Base/PipesClient.cs deleted file mode 100644 index e7275498..00000000 --- a/src/Packages/UnityWebBrowser.Communication.Pipes/Runtime/Base/PipesClient.cs +++ /dev/null @@ -1,92 +0,0 @@ -// UnityWebBrowser (UWB) -// Copyright (c) 2021-2022 Voltstro-Studios -// -// This project is under the MIT license. See the LICENSE.md file for more details. - -using System.IO.Pipes; -using VoltRpc.Communication; - -namespace VoltstroStudios.UnityWebBrowser.Communication.Pipes.Base -{ - /// - /// using named pipes - /// - public sealed class PipesClient : Client - { - /// - /// Default connection timeout time - /// - public const int DefaultConnectionTimeout = 7000; - - private readonly int connectionTimeout; - - private readonly NamedPipeClientStream namedPipeClientStream; - - /// - /// Creates a new instance - /// - /// The server to connect to - /// The name of the pipe - /// The timeout for connection - /// The size of the buffers - public PipesClient(string server, string pipeName, int connectionTimeout, int bufferSize = DefaultBufferSize) - : base(bufferSize) - { - this.connectionTimeout = connectionTimeout; - namedPipeClientStream = new NamedPipeClientStream(server, pipeName, PipeDirection.InOut); - } - - /// - /// Creates a new instance - /// - /// The server to connect to - /// The name of the pipe - /// The size of the buffers - public PipesClient(string server, string pipeName, int bufferSize = DefaultBufferSize) - : this(server, pipeName, DefaultConnectionTimeout, bufferSize) - { - } - - /// - /// Creates a new instance - /// - /// The name of the pipe - /// The timeout for connection - /// The size of the buffers - public PipesClient(string pipeName, int connectionTimeout, int bufferSize = DefaultBufferSize) - : this(".", pipeName, connectionTimeout, bufferSize) - { - } - - /// - /// Creates a new instance - /// - /// The name of the pipe - /// The size of the buffers - public PipesClient(string pipeName, int bufferSize = DefaultBufferSize) - : this(".", pipeName, bufferSize) - { - } - - /// - /// Thrown if an error occurs while connecting. - public override void Connect() - { - CheckDispose(); - - namedPipeClientStream.Connect(connectionTimeout); - - if (!namedPipeClientStream.IsConnected) - throw new ConnectionFailedException("Failed to connect to a pipes host!"); - - Initialize(namedPipeClientStream, namedPipeClientStream); - } - - /// - public override void Dispose() - { - base.Dispose(); - namedPipeClientStream.Dispose(); - } - } -} \ No newline at end of file diff --git a/src/Packages/UnityWebBrowser.Communication.Pipes/Runtime/Base/PipesClient.cs.meta b/src/Packages/UnityWebBrowser.Communication.Pipes/Runtime/Base/PipesClient.cs.meta deleted file mode 100644 index a2245d5d..00000000 --- a/src/Packages/UnityWebBrowser.Communication.Pipes/Runtime/Base/PipesClient.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: a7a6b05075dec7847a5daba2a4d84021 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/src/Packages/UnityWebBrowser.Communication.Pipes/Runtime/Base/PipesHost.cs b/src/Packages/UnityWebBrowser.Communication.Pipes/Runtime/Base/PipesHost.cs deleted file mode 100644 index 540f983e..00000000 --- a/src/Packages/UnityWebBrowser.Communication.Pipes/Runtime/Base/PipesHost.cs +++ /dev/null @@ -1,78 +0,0 @@ -// UnityWebBrowser (UWB) -// Copyright (c) 2021-2022 Voltstro-Studios -// -// This project is under the MIT license. See the LICENSE.md file for more details. - -using System; -using System.IO.Pipes; -using System.Threading.Tasks; -using VoltRpc.Communication; -using VoltRpc.Logging; - -namespace VoltstroStudios.UnityWebBrowser.Communication.Pipes.Base -{ - /// - /// using named pipes - /// - public sealed class PipesHost : Host - { - private readonly string pipeName; - - /// - /// Creates a new instance - /// - /// The name of the pipe - /// The size of the buffers - public PipesHost(string pipeName, int bufferSize) - : this(pipeName, null, bufferSize) - { - } - - /// - /// Creates a new instance - /// - /// The name of the pipe - /// The to use - /// The size of the buffers - public PipesHost(string pipeName, ILogger logger = null, int bufferSize = DefaultBufferSize) - : base(logger, bufferSize) - { - this.pipeName = pipeName; - } - - /// - public override void StartListening() - { - CheckDispose(); - - Logger.Debug("Named Pipes host now listening..."); - - IsRunning = true; - while (IsRunning) - try - { - if (ConnectionCount >= MaxConnectionsCount) - continue; - - NamedPipeServerStream serverStream = new(pipeName, PipeDirection.InOut); - serverStream.WaitForConnection(); - ConnectionCount++; - _ = Task.Run(() => HandleClient(serverStream)); - } - catch (Exception ex) - { - Logger.Error($"An error occured while handling incoming pipes connections! {ex}"); - } - } - - private Task HandleClient(NamedPipeServerStream stream) - { - Logger.Debug("Accepted client..."); - ProcessRequest(stream, stream); - stream.Dispose(); - Logger.Debug("Client disconnected."); - ConnectionCount--; - return Task.CompletedTask; - } - } -} \ No newline at end of file diff --git a/src/Packages/UnityWebBrowser.Communication.Pipes/Runtime/Base/PipesHost.cs.meta b/src/Packages/UnityWebBrowser.Communication.Pipes/Runtime/Base/PipesHost.cs.meta deleted file mode 100644 index 8ebf1e4f..00000000 --- a/src/Packages/UnityWebBrowser.Communication.Pipes/Runtime/Base/PipesHost.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 46ab6963925d426699e590a0887bfe78 -timeCreated: 1641654117 \ No newline at end of file diff --git a/src/Packages/UnityWebBrowser.Communication.Pipes/Runtime/Base/VoltstroStudios.UnityWebBrowser.Communication.Pipes.Base.asmdef b/src/Packages/UnityWebBrowser.Communication.Pipes/Runtime/Base/VoltstroStudios.UnityWebBrowser.Communication.Pipes.Base.asmdef deleted file mode 100644 index 05ed8ffc..00000000 --- a/src/Packages/UnityWebBrowser.Communication.Pipes/Runtime/Base/VoltstroStudios.UnityWebBrowser.Communication.Pipes.Base.asmdef +++ /dev/null @@ -1,20 +0,0 @@ -{ - "name": "VoltstroStudios.UnityWebBrowser.Communication.Pipes.Base", - "rootNamespace": "VoltstroStudios.UnityWebBrowser.Communication.Pipes.Base", - "references": [], - "includePlatforms": [ - "Editor", - "WindowsStandalone64" - ], - "excludePlatforms": [], - "allowUnsafeCode": false, - "overrideReferences": true, - "precompiledReferences": [ - "VoltRpc.dll", - "VoltstroStudios.UnityWebBrowser.Shared.dll" - ], - "autoReferenced": false, - "defineConstraints": [], - "versionDefines": [], - "noEngineReferences": true -} \ No newline at end of file diff --git a/src/Packages/UnityWebBrowser.Communication.Pipes/Runtime/PipesCommunicationLayer.cs b/src/Packages/UnityWebBrowser.Communication.Pipes/Runtime/PipesCommunicationLayer.cs index 4737e6c0..bc603a1a 100644 --- a/src/Packages/UnityWebBrowser.Communication.Pipes/Runtime/PipesCommunicationLayer.cs +++ b/src/Packages/UnityWebBrowser.Communication.Pipes/Runtime/PipesCommunicationLayer.cs @@ -5,7 +5,7 @@ using UnityEngine; using VoltRpc.Communication; -using VoltstroStudios.UnityWebBrowser.Communication.Pipes.Base; +using VoltRpc.Communication.Pipes; namespace VoltstroStudios.UnityWebBrowser.Communication.Pipes { @@ -27,7 +27,7 @@ public sealed class PipesCommunicationLayer : CommunicationLayer public override Client CreateClient() { - return new PipesClient(inPipeName, connectionTimeout, Client.DefaultBufferSize); + return new PipesClient(inPipeName); } public override Host CreateHost() @@ -35,11 +35,11 @@ public override Host CreateHost() return new PipesHost(outPipeName); } - public override void GetIpcSettings(out object outLocation, out object inLocation, out string assemblyLocation) + public override void GetIpcSettings(out object outLocation, out object inLocation, out string layerName) { outLocation = outPipeName; inLocation = inPipeName; - assemblyLocation = typeof(EnginePipesCommunicationLayer).Assembly.Location; + layerName = "Pipes"; } } } \ No newline at end of file diff --git a/src/Packages/UnityWebBrowser.Communication.Pipes/Runtime/VoltstroStudios.UnityWebBrowser.Communication.Pipes.asmdef b/src/Packages/UnityWebBrowser.Communication.Pipes/Runtime/VoltstroStudios.UnityWebBrowser.Communication.Pipes.asmdef index c9e24d6c..380ce8ee 100644 --- a/src/Packages/UnityWebBrowser.Communication.Pipes/Runtime/VoltstroStudios.UnityWebBrowser.Communication.Pipes.asmdef +++ b/src/Packages/UnityWebBrowser.Communication.Pipes/Runtime/VoltstroStudios.UnityWebBrowser.Communication.Pipes.asmdef @@ -1,23 +1,23 @@ { - "name": "VoltstroStudios.UnityWebBrowser.Communication.Pipes", - "rootNamespace": "VoltstroStudios.UnityWebBrowser.Communication.Pipes", - "references": [ - "VoltstroStudios.UnityWebBrowser", - "VoltstroStudios.UnityWebBrowser.Communication.Pipes.Base" - ], - "includePlatforms": [ - "Editor", - "WindowsStandalone64" - ], - "excludePlatforms": [], - "allowUnsafeCode": false, - "overrideReferences": true, - "precompiledReferences": [ - "VoltRpc.dll", - "VoltstroStudios.UnityWebBrowser.Shared.dll" - ], - "autoReferenced": true, - "defineConstraints": [], - "versionDefines": [], - "noEngineReferences": false + "name": "VoltstroStudios.UnityWebBrowser.Communication.Pipes", + "rootNamespace": "VoltstroStudios.UnityWebBrowser.Communication.Pipes", + "references": [ + "VoltstroStudios.UnityWebBrowser" + ], + "includePlatforms": [ + "Editor", + "WindowsStandalone64" + ], + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": true, + "precompiledReferences": [ + "VoltRpc.dll", + "VoltRpc.Communication.Pipes.dll", + "VoltstroStudios.UnityWebBrowser.Shared.dll" + ], + "autoReferenced": true, + "defineConstraints": [], + "versionDefines": [], + "noEngineReferences": false } \ No newline at end of file diff --git a/src/Packages/UnityWebBrowser.Communication.Pipes/package.json b/src/Packages/UnityWebBrowser.Communication.Pipes/package.json index 57e9b43d..0dcc2825 100644 --- a/src/Packages/UnityWebBrowser.Communication.Pipes/package.json +++ b/src/Packages/UnityWebBrowser.Communication.Pipes/package.json @@ -1,9 +1,9 @@ { "name": "dev.voltstro.unitywebbrowser.communication.pipes", "displayName": "Unity Web Browser Pipes Communication", - "version": "1.0.1", - "unity": "2021.3", "description": "Adds support to use pipes in UWB.", + "version": "2.2.0", + "unity": "2021.3", "author": { "name": "Voltstro", "email": "me@voltstro.dev", @@ -13,11 +13,12 @@ "type": "git", "url": "https://github.com/Voltstro-Studios/UnityWebBrowser.git" }, - "dependencies": { - "dev.voltstro.unitywebbrowser": "2.0.0" - }, "hideInEditor": false, - "changelogUrl": "https://projects.voltstro.dev/UnityWebBrowser/changelog/", - "documentationUrl": "https://projects.voltstro.dev/UnityWebBrowser/", - "licensesUrl": "https://github.com/Voltstro-Studios/UnityWebBrowser/blob/master/LICENSE.md" + "changelogUrl": "https://projects.voltstro.dev/UnityWebBrowser/latest/changelog/", + "documentationUrl": "https://projects.voltstro.dev/UnityWebBrowser/latest/", + "licensesUrl": "https://github.com/Voltstro-Studios/UnityWebBrowser/blob/master/LICENSE.md", + "dependencies": { + "dev.voltstro.unitywebbrowser": "2.2.0", + "org.nuget.voltrpc.communication.pipes": "3.1.0" + } } \ No newline at end of file diff --git a/src/Packages/UnityWebBrowser.Engine.Cef.Linux-x64/package.json b/src/Packages/UnityWebBrowser.Engine.Cef.Linux-x64/package.json index 0f822dc7..76d02f53 100644 --- a/src/Packages/UnityWebBrowser.Engine.Cef.Linux-x64/package.json +++ b/src/Packages/UnityWebBrowser.Engine.Cef.Linux-x64/package.json @@ -1,23 +1,22 @@ { - "licensesUrl": "https://github.com/Voltstro-Studios/UnityWebBrowser/blob/master/LICENSE.md", "name": "dev.voltstro.unitywebbrowser.engine.cef.linux.x64", + "displayName": "Unity Web Browser CEF Engine (Linux x64)", + "description": "CEF engine for Unity Web Browser (Linux x64).", + "version": "2.2.0-128.4.9", + "unity": "2021.3", + "author": { + "name": "Voltstro", + "email": "me@voltstro.dev", + "url": "https://voltstro.dev" + }, "repository": { "type": "git", "url": "https://github.com/Voltstro-Studios/UnityWebBrowser.git" }, - "author": { - "email": "me@voltstro.dev", - "url": "https://voltstro.dev", - "name": "Voltstro" - }, - "changelogUrl": "https://projects.voltstro.dev/UnityWebBrowser/changelog/", - "unity": "2021.2", + "changelogUrl": "https://projects.voltstro.dev/UnityWebBrowser/latest/changelog/", + "documentationUrl": "https://projects.voltstro.dev/UnityWebBrowser/latest/articles/user/engines/#cef-engine", + "licensesUrl": "https://github.com/Voltstro-Studios/UnityWebBrowser/blob/master/LICENSE.md", "dependencies": { - "dev.voltstro.unitywebbrowser.engine.cef": "2.1.1-122.1.13", - "dev.voltstro.unitywebbrowser.unix-support": "1.0.0" - }, - "documentationUrl": "https://projects.voltstro.dev/UnityWebBrowser/", - "description": "CEF Engine for Unity Web Browser (Linux x64)", - "displayName": "Unity Web Browser CEF Engine (Linux x64)", - "version": "2.1.1-122.1.13" -} + "dev.voltstro.unitywebbrowser.engine.cef": "2.2.0-128.4.9" + } +} \ No newline at end of file diff --git a/src/Packages/UnityWebBrowser.Engine.Cef.MacOS-arm64/LICENSE.md b/src/Packages/UnityWebBrowser.Engine.Cef.MacOS-arm64/LICENSE.md new file mode 100644 index 00000000..5b7f48cd --- /dev/null +++ b/src/Packages/UnityWebBrowser.Engine.Cef.MacOS-arm64/LICENSE.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2021-2024 Voltstro-Studios + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/src/Packages/UnityWebBrowser.Unix-Support/Runtime/VoltstroStudios.UnityWebBrowser.UnixSupport.asmdef.meta b/src/Packages/UnityWebBrowser.Engine.Cef.MacOS-arm64/LICENSE.md.meta similarity index 59% rename from src/Packages/UnityWebBrowser.Unix-Support/Runtime/VoltstroStudios.UnityWebBrowser.UnixSupport.asmdef.meta rename to src/Packages/UnityWebBrowser.Engine.Cef.MacOS-arm64/LICENSE.md.meta index fe59893a..6cd72849 100644 --- a/src/Packages/UnityWebBrowser.Unix-Support/Runtime/VoltstroStudios.UnityWebBrowser.UnixSupport.asmdef.meta +++ b/src/Packages/UnityWebBrowser.Engine.Cef.MacOS-arm64/LICENSE.md.meta @@ -1,6 +1,6 @@ fileFormatVersion: 2 -guid: 67e0fa2abfd4a1033acb5f16e1a179b3 -AssemblyDefinitionImporter: +guid: fe09333555055432dad68641e2d31312 +TextScriptImporter: externalObjects: {} userData: assetBundleName: diff --git a/src/Packages/UnityWebBrowser.Engine.Cef.MacOS-arm64/package.json b/src/Packages/UnityWebBrowser.Engine.Cef.MacOS-arm64/package.json new file mode 100644 index 00000000..07a72cb8 --- /dev/null +++ b/src/Packages/UnityWebBrowser.Engine.Cef.MacOS-arm64/package.json @@ -0,0 +1,22 @@ +{ + "name": "dev.voltstro.unitywebbrowser.engine.cef.macos.arm64", + "displayName": "Unity Web Browser CEF Engine (MacOS arm64)", + "description": "CEF engine for Unity Web Browser (MacOS arm64).", + "version": "2.2.0-128.4.9", + "unity": "2021.2", + "author": { + "name": "Voltstro", + "email": "me@voltstro.dev", + "url": "https://voltstro.dev" + }, + "repository": { + "type": "git", + "url": "https://github.com/Voltstro-Studios/UnityWebBrowser.git" + }, + "changelogUrl": "https://projects.voltstro.dev/UnityWebBrowser/latest/changelog/", + "documentationUrl": "https://projects.voltstro.dev/UnityWebBrowser/latest/articles/user/engines/#cef-engine", + "licensesUrl": "https://github.com/Voltstro-Studios/UnityWebBrowser/blob/master/LICENSE.md", + "dependencies": { + "dev.voltstro.unitywebbrowser.engine.cef": "2.2.0-128.4.9" + } +} \ No newline at end of file diff --git a/src/Packages/UnityWebBrowser.Communication.Pipes/Runtime/Base/VoltstroStudios.UnityWebBrowser.Communication.Pipes.Base.asmdef.meta b/src/Packages/UnityWebBrowser.Engine.Cef.MacOS-arm64/package.json.meta similarity index 59% rename from src/Packages/UnityWebBrowser.Communication.Pipes/Runtime/Base/VoltstroStudios.UnityWebBrowser.Communication.Pipes.Base.asmdef.meta rename to src/Packages/UnityWebBrowser.Engine.Cef.MacOS-arm64/package.json.meta index e6073ff6..75157295 100644 --- a/src/Packages/UnityWebBrowser.Communication.Pipes/Runtime/Base/VoltstroStudios.UnityWebBrowser.Communication.Pipes.Base.asmdef.meta +++ b/src/Packages/UnityWebBrowser.Engine.Cef.MacOS-arm64/package.json.meta @@ -1,6 +1,6 @@ fileFormatVersion: 2 -guid: 85cf6ddc6ef19c663a2412b4f210d1a6 -AssemblyDefinitionImporter: +guid: 25f2f9846ae244e6891f567c8d08ab2d +PackageManifestImporter: externalObjects: {} userData: assetBundleName: diff --git a/src/Packages/UnityWebBrowser.Engine.Cef.MacOS-x64/LICENSE.md b/src/Packages/UnityWebBrowser.Engine.Cef.MacOS-x64/LICENSE.md index c96133a4..5b7f48cd 100644 --- a/src/Packages/UnityWebBrowser.Engine.Cef.MacOS-x64/LICENSE.md +++ b/src/Packages/UnityWebBrowser.Engine.Cef.MacOS-x64/LICENSE.md @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2021-2022 Voltstro-Studios +Copyright (c) 2021-2024 Voltstro-Studios Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Packages/UnityWebBrowser.Engine.Cef.MacOS-x64/package.json b/src/Packages/UnityWebBrowser.Engine.Cef.MacOS-x64/package.json index 8bf7bdf5..b7599f1b 100644 --- a/src/Packages/UnityWebBrowser.Engine.Cef.MacOS-x64/package.json +++ b/src/Packages/UnityWebBrowser.Engine.Cef.MacOS-x64/package.json @@ -1,6 +1,9 @@ { - "version": "2.0.0-preview.3-99.2.6", - "description": "CEF Engine for Unity Web Browser (MacOS x64)", + "name": "dev.voltstro.unitywebbrowser.engine.cef.macos.x64", + "displayName": "Unity Web Browser CEF Engine (MacOS x64)", + "description": "CEF engine for Unity Web Browser (MacOS x64).", + "version": "2.2.0-128.4.9", + "unity": "2021.2", "author": { "name": "Voltstro", "email": "me@voltstro.dev", @@ -10,14 +13,10 @@ "type": "git", "url": "https://github.com/Voltstro-Studios/UnityWebBrowser.git" }, - "name": "dev.voltstro.unitywebbrowser.engine.cef.macos.x64", - "displayName": "Unity Web Browser CEF Engine (MacOS x64)", - "changelogUrl": "https://projects.voltstro.dev/UnityWebBrowser/changelog/", - "documentationUrl": "https://projects.voltstro.dev/UnityWebBrowser/", + "changelogUrl": "https://projects.voltstro.dev/UnityWebBrowser/latest/changelog/", + "documentationUrl": "https://projects.voltstro.dev/UnityWebBrowser/latest/articles/user/engines/#cef-engine", "licensesUrl": "https://github.com/Voltstro-Studios/UnityWebBrowser/blob/master/LICENSE.md", "dependencies": { - "dev.voltstro.unitywebbrowser.engine.cef": "2.0.0-preview.3-99.2.6", - "dev.voltstro.unitywebbrowser.unix-support": "1.0.0" - }, - "unity": "2021.2" + "dev.voltstro.unitywebbrowser.engine.cef": "2.2.0-128.4.9" + } } \ No newline at end of file diff --git a/src/Packages/UnityWebBrowser.Engine.Cef.Win-x64/package.json b/src/Packages/UnityWebBrowser.Engine.Cef.Win-x64/package.json index d0947da5..24a1238e 100644 --- a/src/Packages/UnityWebBrowser.Engine.Cef.Win-x64/package.json +++ b/src/Packages/UnityWebBrowser.Engine.Cef.Win-x64/package.json @@ -1,22 +1,22 @@ { - "licensesUrl": "https://github.com/Voltstro-Studios/UnityWebBrowser/blob/master/LICENSE.md", "name": "dev.voltstro.unitywebbrowser.engine.cef.win.x64", + "displayName": "Unity Web Browser CEF Engine (Win x64)", + "description": "CEF engine for Unity Web Browser (Win x64).", + "version": "2.2.0-128.4.9", + "unity": "2021.2", + "author": { + "name": "Voltstro", + "email": "me@voltstro.dev", + "url": "https://voltstro.dev" + }, "repository": { "type": "git", "url": "https://github.com/Voltstro-Studios/UnityWebBrowser.git" }, - "author": { - "email": "me@voltstro.dev", - "url": "https://voltstro.dev", - "name": "Voltstro" - }, - "changelogUrl": "https://projects.voltstro.dev/UnityWebBrowser/changelog/", - "unity": "2021.2", + "changelogUrl": "https://projects.voltstro.dev/UnityWebBrowser/latest/changelog/", + "documentationUrl": "https://projects.voltstro.dev/UnityWebBrowser/latest/articles/user/engines/#cef-engine", + "licensesUrl": "https://github.com/Voltstro-Studios/UnityWebBrowser/blob/master/LICENSE.md", "dependencies": { - "dev.voltstro.unitywebbrowser.engine.cef": "2.1.1-122.1.13" - }, - "documentationUrl": "https://projects.voltstro.dev/UnityWebBrowser/", - "description": "CEF Engine for Unity Web Browser (Windows x64)", - "displayName": "Unity Web Browser CEF Engine (Windows x64)", - "version": "2.1.1-122.1.13" -} + "dev.voltstro.unitywebbrowser.engine.cef": "2.2.0-128.4.9" + } +} \ No newline at end of file diff --git a/src/Packages/UnityWebBrowser.Engine.Cef/Resources/Cef Engine Configuration.asset b/src/Packages/UnityWebBrowser.Engine.Cef/Resources/Cef Engine Configuration.asset index 7d766ce0..ae593fe6 100644 --- a/src/Packages/UnityWebBrowser.Engine.Cef/Resources/Cef Engine Configuration.asset +++ b/src/Packages/UnityWebBrowser.Engine.Cef/Resources/Cef Engine Configuration.asset @@ -12,13 +12,27 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 9692e60c1a314ca98f6bb7656e12aa54, type: 3} m_Name: Cef Engine Configuration m_EditorClassIdentifier: - engineAppName: UnityWebBrowser.Engine.Cef - engineFilesNotFoundError: The engine files for this platform were not found! You - may need to install a dedicated platform package. engineFiles: - platform: 0 + engineBaseAppLocation: + engineRuntimeLocation: UWB/ + engineEditorLocation: Packages/dev.voltstro.unitywebbrowser.engine.cef.win.x64/Engine~/ engineFileLocation: Packages/dev.voltstro.unitywebbrowser.engine.cef.win.x64/Engine~/ - platform: 1 + engineBaseAppLocation: + engineRuntimeLocation: UWB/ + engineEditorLocation: Packages/dev.voltstro.unitywebbrowser.engine.cef.linux.x64/Engine~/ engineFileLocation: Packages/dev.voltstro.unitywebbrowser.engine.cef.linux.x64/Engine~/ - platform: 2 + engineBaseAppLocation: UnityWebBrowser.Engine.Cef.app/Contents/MacOS/ + engineRuntimeLocation: Frameworks/ + engineEditorLocation: Packages/dev.voltstro.unitywebbrowser.engine.cef.macos.x64/Engine~/ + engineFileLocation: Packages/dev.voltstro.unitywebbrowser.engine.cef.macos.x64/Engine~/ + - platform: 3 + engineBaseAppLocation: UnityWebBrowser.Engine.Cef.app/Contents/MacOS/ + engineRuntimeLocation: Frameworks/ + engineEditorLocation: Packages/dev.voltstro.unitywebbrowser.engine.cef.macos.arm64/Engine~/ engineFileLocation: Packages/dev.voltstro.unitywebbrowser.engine.cef.macos.x64/Engine~/ + engineAppName: UnityWebBrowser.Engine.Cef + engineFilesNotFoundError: The engine files for this platform were not found! You + may need to install a dedicated platform package. diff --git a/src/Packages/UnityWebBrowser.Engine.Cef/package.json b/src/Packages/UnityWebBrowser.Engine.Cef/package.json index 5ab94f3a..48c77968 100644 --- a/src/Packages/UnityWebBrowser.Engine.Cef/package.json +++ b/src/Packages/UnityWebBrowser.Engine.Cef/package.json @@ -1,23 +1,23 @@ { - "hideInEditor": false, - "changelogUrl": "https://projects.voltstro.dev/UnityWebBrowser/changelog/", - "description": "CEF Engine for Unity Web Browser", - "documentationUrl": "https://projects.voltstro.dev/UnityWebBrowser/", - "version": "2.1.1-122.1.13", + "name": "dev.voltstro.unitywebbrowser.engine.cef", + "displayName": "Unity Web Browser CEF Engine", + "description": "CEF engine for Unity Web Browser.", + "version": "2.2.0-128.4.9", + "unity": "2021.3", "author": { + "name": "Voltstro", "email": "me@voltstro.dev", - "url": "https://voltstro.dev", - "name": "Voltstro" - }, - "unity": "2021.3", - "dependencies": { - "dev.voltstro.unitywebbrowser": "2.1.1" + "url": "https://voltstro.dev" }, - "licensesUrl": "https://github.com/Voltstro-Studios/UnityWebBrowser/blob/master/LICENSE.md", "repository": { "type": "git", "url": "https://github.com/Voltstro-Studios/UnityWebBrowser.git" }, - "name": "dev.voltstro.unitywebbrowser.engine.cef", - "displayName": "Unity Web Browser CEF Engine" -} + "hideInEditor": false, + "changelogUrl": "https://projects.voltstro.dev/UnityWebBrowser/latest/changelog/", + "documentationUrl": "https://projects.voltstro.dev/UnityWebBrowser/latest/articles/user/engines/#cef-engine", + "licensesUrl": "https://github.com/Voltstro-Studios/UnityWebBrowser/blob/master/LICENSE.md", + "dependencies": { + "dev.voltstro.unitywebbrowser": "2.2.0" + } +} \ No newline at end of file diff --git a/src/Packages/UnityWebBrowser.Unix-Support/Runtime.meta b/src/Packages/UnityWebBrowser.Unix-Support/Runtime.meta deleted file mode 100644 index 2a3acfe0..00000000 --- a/src/Packages/UnityWebBrowser.Unix-Support/Runtime.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: e6f07ac3cc134166eb968b952d086652 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/src/Packages/UnityWebBrowser.Unix-Support/Runtime/AssemblyInfo.cs b/src/Packages/UnityWebBrowser.Unix-Support/Runtime/AssemblyInfo.cs deleted file mode 100644 index 88814766..00000000 --- a/src/Packages/UnityWebBrowser.Unix-Support/Runtime/AssemblyInfo.cs +++ /dev/null @@ -1,21 +0,0 @@ -// UnityWebBrowser (UWB) -// Copyright (c) 2021-2022 Voltstro-Studios -// -// This project is under the MIT license. See the LICENSE.md file for more details. - -using System.Reflection; -using System.Runtime.CompilerServices; - -[assembly: AssemblyTitle("Unity Web Browser Unix Support")] -[assembly: AssemblyDescription("Additional library for support of Unix-like OSes")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Voltstro-Studios")] -[assembly: AssemblyProduct("Unity Web Browser Unix Support")] -[assembly: AssemblyCopyright("Copyright (c) 2021-2024 Voltstro-Studios")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -[assembly: AssemblyVersion("1.0.0")] -[assembly: AssemblyFileVersion("1.0.0")] - -[assembly: InternalsVisibleTo("VoltstroStudios.UnityWebBrowser")] \ No newline at end of file diff --git a/src/Packages/UnityWebBrowser.Unix-Support/Runtime/AssemblyInfo.cs.meta b/src/Packages/UnityWebBrowser.Unix-Support/Runtime/AssemblyInfo.cs.meta deleted file mode 100644 index b36d3e0b..00000000 --- a/src/Packages/UnityWebBrowser.Unix-Support/Runtime/AssemblyInfo.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 45b2f4b4b09d41868f3f2d452019708d -timeCreated: 1642074755 \ No newline at end of file diff --git a/src/Packages/UnityWebBrowser.Unix-Support/Runtime/PermissionsManager.cs b/src/Packages/UnityWebBrowser.Unix-Support/Runtime/PermissionsManager.cs deleted file mode 100644 index fe356bdc..00000000 --- a/src/Packages/UnityWebBrowser.Unix-Support/Runtime/PermissionsManager.cs +++ /dev/null @@ -1,40 +0,0 @@ -// UnityWebBrowser (UWB) -// Copyright (c) 2021-2022 Voltstro-Studios -// -// This project is under the MIT license. See the LICENSE.md file for more details. - -#if UNITY_EDITOR_LINUX || UNITY_STANDALONE_LINUX - -using System.IO; -using Mono.Unix; - -namespace VoltstroStudios.UnityWebBrowser.UnixSupport -{ - /// - /// Unix support file permissions - /// - internal static class PermissionsManager - { - /// - /// Checks and sets (if needed) a file permission with UserReadWriteExecute - /// - /// - /// - public static bool CheckAndSetIfNeededFileExecutablePermission(string fileLocation) - { - UnixFileInfo fileInfo = new(fileLocation); - if (!fileInfo.Exists) - throw new FileNotFoundException("File was not found!", fileLocation); - - if (fileInfo.FileAccessPermissions.HasFlag(FileAccessPermissions.UserReadWriteExecute)) - return false; - - fileInfo.FileAccessPermissions |= - fileInfo.FileAccessPermissions | FileAccessPermissions.UserReadWriteExecute; - fileInfo.Refresh(); - return true; - } - } -} - -#endif \ No newline at end of file diff --git a/src/Packages/UnityWebBrowser.Unix-Support/Runtime/PermissionsManager.cs.meta b/src/Packages/UnityWebBrowser.Unix-Support/Runtime/PermissionsManager.cs.meta deleted file mode 100644 index 676730b8..00000000 --- a/src/Packages/UnityWebBrowser.Unix-Support/Runtime/PermissionsManager.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 3d8c63148a1c79c899f464d67461be35 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/src/Packages/UnityWebBrowser.Unix-Support/Runtime/VoltstroStudios.UnityWebBrowser.UnixSupport.asmdef b/src/Packages/UnityWebBrowser.Unix-Support/Runtime/VoltstroStudios.UnityWebBrowser.UnixSupport.asmdef deleted file mode 100644 index 04d60aca..00000000 --- a/src/Packages/UnityWebBrowser.Unix-Support/Runtime/VoltstroStudios.UnityWebBrowser.UnixSupport.asmdef +++ /dev/null @@ -1,19 +0,0 @@ -{ - "name": "VoltstroStudios.UnityWebBrowser.UnixSupport", - "rootNamespace": "VoltstroStudios.UnityWebBrowser.UnixSupport", - "references": [], - "includePlatforms": [ - "Editor", - "LinuxStandalone64" - ], - "excludePlatforms": [], - "allowUnsafeCode": false, - "overrideReferences": true, - "precompiledReferences": [ - "Mono.Unix.dll" - ], - "autoReferenced": true, - "defineConstraints": [], - "versionDefines": [], - "noEngineReferences": false -} \ No newline at end of file diff --git a/src/Packages/UnityWebBrowser.Unix-Support/package.json b/src/Packages/UnityWebBrowser.Unix-Support/package.json index 2315841b..5379f5a2 100644 --- a/src/Packages/UnityWebBrowser.Unix-Support/package.json +++ b/src/Packages/UnityWebBrowser.Unix-Support/package.json @@ -1,9 +1,9 @@ { "name": "dev.voltstro.unitywebbrowser.unix-support", "displayName": "Unity Web Browser Unix Support", - "version": "1.0.1", + "version": "1.1.0", "unity": "2021.3", - "description": "Additional requirement for UWB on Unix systems (Linux & MacOS).", + "description": "Unix Support package is no longer needed and is now deprecated.", "author": { "name": "Voltstro", "email": "me@voltstro.dev", @@ -13,9 +13,6 @@ "type": "git", "url": "https://github.com/Voltstro-Studios/UnityWebBrowser.git" }, - "dependencies": { - "dev.voltstro.nuget.mono.unix": "1.0.0" - }, "changelogUrl": "https://projects.voltstro.dev/UnityWebBrowser/changelog/", "documentationUrl": "https://projects.voltstro.dev/UnityWebBrowser/", "licensesUrl": "https://github.com/Voltstro-Studios/UnityWebBrowser/blob/master/LICENSE.md" diff --git a/src/Packages/UnityWebBrowser/README.md b/src/Packages/UnityWebBrowser/README.md index 7467e847..39f7ff8f 100644 --- a/src/Packages/UnityWebBrowser/README.md +++ b/src/Packages/UnityWebBrowser/README.md @@ -1,9 +1,8 @@ # Unity Web Browser -[![License](https://img.shields.io/github/license/Voltstro-Studios/UnityWebBrowser.svg)](/LICENSE) -[![Build](https://github.com/Voltstro-Studios/UnityWebBrowser/actions/workflows/main.yml/badge.svg)](https://github.com/Voltstro-Studios/UnityWebBrowser/actions/workflows/main.yml) -[![Discord](https://img.shields.io/badge/Discord-Voltstro-7289da.svg?logo=discord)](https://discord.voltstro.dev) -[![YouTube](https://img.shields.io/badge/Youtube-Voltstro-red.svg?logo=youtube)](https://www.youtube.com/Voltstro) +[![License](https://img.shields.io/github/license/Voltstro-Studios/UnityWebBrowser.svg)](/LICENSE.md) +[![Build Status](https://github.com/Voltstro-Studios/UnityWebBrowser/actions/workflows/main.yml/badge.svg)](https://github.com/Voltstro-Studios/UnityWebBrowser/actions/workflows/main.yml) +[![Docs Status](https://img.shields.io/uptimerobot/status/m794227043-7e2bf837661fcd75d2af6804?label=Docs)](https://projects.voltstro.dev/UnityWebBrowser/latest/) Unity Web Browser (UWB) is a Unity package that allows displaying and interacting with the web from within Unity. @@ -12,8 +11,9 @@ This project is capable of using any desired web engine you want, however for no ## Features - Easy Installation with UPM -- Multi-Platform Desktop Support +- Multi-Platform Desktop Support (Windows, Linux & MacOS) - API to interact with the web engine +- JS Interop - Extendable - 100% Open-Source @@ -27,11 +27,8 @@ Unity 2021.3.x ### Install -1. Setup [VoltstroUPM](https://github.com/Voltstro/VoltstroUPM#setup) -2. Define the additional scopes `org.nuget` and `com.cysharp.unitask` with VoltstroUPM -3. Install the required packages! - - UnityWebBrowser -4. Install an engine: - - E.G.: UnityWebBrowser CEF Engine with Windows natives +1. Setup [VoltUPM](https://github.com/Voltstro/VoltstroUPM#setup) +2. Define the additional scopes `org.nuget` and `com.cysharp.unitask` with VoltUPM +3. Install UnityWebBrowser packages -For a more in-depth installation guide, check out the [setup article](https://projects.voltstro.dev/UnityWebBrowser/articles/user/setup/). +For a more in-depth installation guide, check out the [setup article](https://projects.voltstro.dev/UnityWebBrowser/latest/articles/user/setup/). diff --git a/src/Packages/UnityWebBrowser/Runtime/AssemblyInfo.cs b/src/Packages/UnityWebBrowser/Runtime/AssemblyInfo.cs index 19b6b2ec..0e6818d1 100644 --- a/src/Packages/UnityWebBrowser/Runtime/AssemblyInfo.cs +++ b/src/Packages/UnityWebBrowser/Runtime/AssemblyInfo.cs @@ -1,6 +1,6 @@ // UnityWebBrowser (UWB) // Copyright (c) 2021-2022 Voltstro-Studios -// +// // This project is under the MIT license. See the LICENSE.md file for more details. using System.Reflection; @@ -34,9 +34,9 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.1.1")] -[assembly: AssemblyFileVersion("2.1.1")] +[assembly: AssemblyVersion("2.2.0")] +[assembly: AssemblyFileVersion("2.2.0")] [assembly: InternalsVisibleTo("VoltstroStudios.UnityWebBrowser.Prj")] [assembly: InternalsVisibleTo("VoltstroStudios.UnityWebBrowser.Editor")] -[assembly: InternalsVisibleTo("VoltstroStudios.UnityWebBrowser.Tests")] \ No newline at end of file +[assembly: InternalsVisibleTo("VoltstroStudios.UnityWebBrowser.Tests")] diff --git a/src/Packages/UnityWebBrowser/Runtime/Communication/CommunicationLayer.cs b/src/Packages/UnityWebBrowser/Runtime/Communication/CommunicationLayer.cs index 58f3cc59..f0439bb1 100644 --- a/src/Packages/UnityWebBrowser/Runtime/Communication/CommunicationLayer.cs +++ b/src/Packages/UnityWebBrowser/Runtime/Communication/CommunicationLayer.cs @@ -3,6 +3,7 @@ // // This project is under the MIT license. See the LICENSE.md file for more details. +using System; using JetBrains.Annotations; using UnityEngine; using VoltRpc.Communication; @@ -21,6 +22,8 @@ public abstract class CommunicationLayer : ScriptableObject /// /// Timeout time for connection /// + [Obsolete] + [HideInInspector] public int connectionTimeout = 7000; /// @@ -51,12 +54,10 @@ public abstract class CommunicationLayer : ScriptableObject /// The "location" (whether that be a pipe name or port) that will allow the client to /// communication to the engine. /// - /// - /// The location of the assembly that the engine needs to load. - /// To provide the location of an assembly can be used. - /// This can be null to say that no additional assembly is needed. + /// + /// The name of comms layer /// public abstract void GetIpcSettings(out object outLocation, out object inLocation, - [CanBeNull] out string assemblyLocation); + [CanBeNull] out string layerName); } } \ No newline at end of file diff --git a/src/Packages/UnityWebBrowser/Runtime/Communication/TCPCommunicationLayer.cs b/src/Packages/UnityWebBrowser/Runtime/Communication/TCPCommunicationLayer.cs index d481a0a9..a36eb695 100644 --- a/src/Packages/UnityWebBrowser/Runtime/Communication/TCPCommunicationLayer.cs +++ b/src/Packages/UnityWebBrowser/Runtime/Communication/TCPCommunicationLayer.cs @@ -31,20 +31,20 @@ public sealed class TCPCommunicationLayer : CommunicationLayer public override Client CreateClient() { IPEndPoint ipEndPoint = new(IPAddress.Loopback, inPort); - return new TCPClient(ipEndPoint, connectionTimeout); + return new TCPClient(ipEndPoint, int.MaxValue); } public override Host CreateHost() { IPEndPoint ipEndPoint = new(IPAddress.Loopback, outPort); - return new TCPHost(ipEndPoint); + return new TCPHost(ipEndPoint, int.MaxValue, int.MaxValue); } - public override void GetIpcSettings(out object outLocation, out object inLocation, out string assemblyLocation) + public override void GetIpcSettings(out object outLocation, out object inLocation, out string layerName) { outLocation = outPort; inLocation = inPort; - assemblyLocation = null; + layerName = "TCP"; } } } \ No newline at end of file diff --git a/src/Packages/UnityWebBrowser/Runtime/Core/Engines/Engine.cs b/src/Packages/UnityWebBrowser/Runtime/Core/Engines/Engine.cs index 5680fa73..a9e197b6 100644 --- a/src/Packages/UnityWebBrowser/Runtime/Core/Engines/Engine.cs +++ b/src/Packages/UnityWebBrowser/Runtime/Core/Engines/Engine.cs @@ -5,26 +5,80 @@ using System; using System.Collections.Generic; +using System.IO; +using System.Linq; using UnityEngine; +using UnityEngine.Serialization; using VoltstroStudios.UnityWebBrowser.Shared.Core; +#nullable enable namespace VoltstroStudios.UnityWebBrowser.Core.Engines { public abstract class Engine : ScriptableObject { public abstract string GetEngineExecutableName(); + public virtual string GetEngineWorkingPath(Platform platform) + { + return Path.GetFullPath(GetEngineBasePath(platform)); + } + + public virtual string GetEngineAppPath(Platform platform) + { + return Path.GetFullPath(Path.Combine(GetEngineBasePath(platform), GetEngineExecutableName())); + } + + public string GetEngineBasePath(Platform platform) + { + EnginePlatformFiles? engineFiles = EngineFiles.FirstOrDefault(x => x.platform == platform); + if (engineFiles == null) + throw new PlatformNotSupportedException(); + #if UNITY_EDITOR - public abstract string EngineFilesNotFoundError { get; } + return Path.Combine(engineFiles.Value.engineEditorLocation, engineFiles.Value.engineBaseAppLocation); +#else + return Path.Combine(Application.dataPath, engineFiles.Value.engineRuntimeLocation, engineFiles.Value.engineBaseAppLocation); +#endif + + } + public abstract IEnumerable EngineFiles { get; } [Serializable] public struct EnginePlatformFiles { + /// + /// this set of files are for + /// public Platform platform; + /// + /// Location of the app itself actually lives. + /// Builds on top off of or (in editor mode) + /// + public string engineBaseAppLocation; + + /// + /// Runtime location for the engine files + /// + public string engineRuntimeLocation; + +#if UNITY_EDITOR + + /// + /// Editor location for the engine files + /// + [FormerlySerializedAs("engineFileLocation")] + public string engineEditorLocation; + + [HideInInspector] + [Obsolete("This field is no longer used, it has been renamed to engineEditorLocation to better describe what this field is now used for.")] public string engineFileLocation; - } + #endif + } + + [Obsolete] + public abstract string EngineFilesNotFoundError { get; } } } \ No newline at end of file diff --git a/src/Packages/UnityWebBrowser/Runtime/Core/Engines/EngineConfiguration.cs b/src/Packages/UnityWebBrowser/Runtime/Core/Engines/EngineConfiguration.cs index 8cb2ffa5..fc207b0c 100644 --- a/src/Packages/UnityWebBrowser/Runtime/Core/Engines/EngineConfiguration.cs +++ b/src/Packages/UnityWebBrowser/Runtime/Core/Engines/EngineConfiguration.cs @@ -3,9 +3,11 @@ // // This project is under the MIT license. See the LICENSE.md file for more details. +using System; using System.Collections.Generic; using System.IO; using UnityEngine; +using VoltstroStudios.UnityWebBrowser.Shared.Core; #if UNITY_EDITOR using VoltstroStudios.UnityWebBrowser.Editor.EngineManagement; #endif @@ -15,38 +17,33 @@ namespace VoltstroStudios.UnityWebBrowser.Core.Engines [CreateAssetMenu(menuName = "UWB/UWB Engine Configuration", fileName = "New UWB Engine Configuration")] public class EngineConfiguration : Engine { + /// + /// Array of + /// + public EnginePlatformFiles[] engineFiles; + + /// + /// Main application app name + /// public string engineAppName; public override string GetEngineExecutableName() { +#if UNITY_STANDALONE_WIN + return engineAppName + ".exe"; +#else return engineAppName; +#endif } - -#if UNITY_EDITOR - + + [Obsolete] + [HideInInspector] public string engineFilesNotFoundError = "The engine files for this platform were not found! You may need to install a dedicated platform package."; - public EnginePlatformFiles[] engineFiles; - - public override string EngineFilesNotFoundError => engineFilesNotFoundError; + [Obsolete] + public override string EngineFilesNotFoundError => null; + public override IEnumerable EngineFiles => engineFiles; - -#if UWB_ENGINE_PRJ - public void OnValidate() - { - if(Application.isBatchMode) //CI - return; - - foreach (EnginePlatformFiles engineFile in engineFiles) - { - string path = EngineManager.GetEngineProcessFullPath(this, engineFile.platform); - if (path == null || !File.Exists(path)) - Debug.LogError($"Error with engines files for {name} on platform {engineFile.platform}!"); - } - } -#endif - -#endif } } \ No newline at end of file diff --git a/src/Packages/UnityWebBrowser/Runtime/Core/Engines/EngineProcess.cs b/src/Packages/UnityWebBrowser/Runtime/Core/Engines/EngineProcess.cs index 79ac4690..e2f0cbe6 100644 --- a/src/Packages/UnityWebBrowser/Runtime/Core/Engines/EngineProcess.cs +++ b/src/Packages/UnityWebBrowser/Runtime/Core/Engines/EngineProcess.cs @@ -5,9 +5,11 @@ using System; using System.Diagnostics; +using System.IO; using VoltstroStudios.UnityWebBrowser.Core.Engines.Process; using VoltstroStudios.UnityWebBrowser.Helper; using VoltstroStudios.UnityWebBrowser.Logging; +using VoltstroStudios.UnityWebBrowser.Shared.Core; namespace VoltstroStudios.UnityWebBrowser.Core.Engines { @@ -31,6 +33,8 @@ public EngineProcess(Engine engine, IWebBrowserLogger logger) processHandle = new WindowProcess(); #elif UNITY_STANDALONE_LINUX processHandle = new LinuxProcess(logger); +#elif UNITY_STANDALONE_OSX + processHandle = new MacOsProcess(); #endif this.engine = engine; @@ -55,8 +59,9 @@ public EngineProcess(Engine engine, IWebBrowserLogger logger) /// public void StartProcess(string arguments, DataReceivedEventHandler onLogEvent, DataReceivedEventHandler onErrorLogEvent) { - string engineFullProcessPath = WebBrowserUtils.GetBrowserEngineProcessPath(engine); - string engineDirectory = WebBrowserUtils.GetBrowserEnginePath(engine); + Platform platform = WebBrowserUtils.GetRunningPlatform(); + string engineFullProcessPath = engine.GetEngineAppPath(platform); + string engineDirectory = engine.GetEngineWorkingPath(platform); logger.Debug($"Process Path: '{engineFullProcessPath}'\nWorking: '{engineDirectory}'"); logger.Debug($"Arguments: '{arguments}'"); diff --git a/src/Packages/UnityWebBrowser/Runtime/Core/Engines/Process/LinuxProcess.cs b/src/Packages/UnityWebBrowser/Runtime/Core/Engines/Process/LinuxProcess.cs index 9d4ec3e7..702de1f4 100644 --- a/src/Packages/UnityWebBrowser/Runtime/Core/Engines/Process/LinuxProcess.cs +++ b/src/Packages/UnityWebBrowser/Runtime/Core/Engines/Process/LinuxProcess.cs @@ -10,7 +10,6 @@ using System.Diagnostics; using System.IO; using VoltstroStudios.UnityWebBrowser.Logging; -using VoltstroStudios.UnityWebBrowser.UnixSupport; namespace VoltstroStudios.UnityWebBrowser.Core.Engines.Process { @@ -24,17 +23,13 @@ public LinuxProcess(IWebBrowserLogger logger) process = new System.Diagnostics.Process(); this.logger = logger; } - - public bool HasExited { get; } - public int ExitCode { get; } + + public bool HasExited => process.HasExited; + public int ExitCode => process.ExitCode; public void StartProcess(string executable, string workingDir, string arguments, DataReceivedEventHandler onLogEvent, DataReceivedEventHandler onErrorLogEvent) { - if (PermissionsManager.CheckAndSetIfNeededFileExecutablePermission(executable)) - logger.Warn( - "UWB engine process did not have +rwx permissions! Engine process permission's were updated for the user."); - ProcessStartInfo startInfo = new(executable, arguments) { CreateNoWindow = true, diff --git a/src/Packages/UnityWebBrowser/Runtime/Core/Engines/Process/MacOsProcess.cs b/src/Packages/UnityWebBrowser/Runtime/Core/Engines/Process/MacOsProcess.cs new file mode 100644 index 00000000..18e1297d --- /dev/null +++ b/src/Packages/UnityWebBrowser/Runtime/Core/Engines/Process/MacOsProcess.cs @@ -0,0 +1,57 @@ +// UnityWebBrowser (UWB) +// Copyright (c) 2021-2024 Voltstro-Studios +// +// This project is under the MIT license.See the LICENSE.md file for more details. + +using System.Diagnostics; +using VoltstroStudios.UnityWebBrowser.Helper; + +#if UNITY_STANDALONE_OSX + +namespace VoltstroStudios.UnityWebBrowser.Core.Engines.Process +{ + internal sealed class MacOsProcess : IProcess + { + private readonly System.Diagnostics.Process process; + + public MacOsProcess() + { + process = new System.Diagnostics.Process(); + } + + public void StartProcess(string executable, string workingDir, string arguments, DataReceivedEventHandler onLogEvent, + DataReceivedEventHandler onErrorLogEvent) + { + ProcessStartInfo startInfo = new(executable, arguments) + { + CreateNoWindow = true, + UseShellExecute = false, + RedirectStandardOutput = true, + RedirectStandardError = true, + WorkingDirectory = workingDir + }; + + process.StartInfo = startInfo; + process.OutputDataReceived += onLogEvent; + process.ErrorDataReceived += onErrorLogEvent; + process.Start(); + process.BeginOutputReadLine(); + process.BeginErrorReadLine(); + } + + public void KillProcess() + { + process.KillTree(); + } + + public bool HasExited => process.HasExited; + public int ExitCode => process.ExitCode; + + public void Dispose() + { + process.Dispose(); + } + } +} + +#endif diff --git a/src/Packages/UnityWebBrowser/Runtime/Core/Engines/Process/MacOsProcess.cs.meta b/src/Packages/UnityWebBrowser/Runtime/Core/Engines/Process/MacOsProcess.cs.meta new file mode 100644 index 00000000..7b9a7a3c --- /dev/null +++ b/src/Packages/UnityWebBrowser/Runtime/Core/Engines/Process/MacOsProcess.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 4f1ec1cdc1b241e282724920557089cc +timeCreated: 1720361400 \ No newline at end of file diff --git a/src/Packages/UnityWebBrowser/Runtime/Core/RawImageUwbClientInputHandler.cs b/src/Packages/UnityWebBrowser/Runtime/Core/RawImageUwbClientInputHandler.cs index 4b65fb01..aa596a5b 100644 --- a/src/Packages/UnityWebBrowser/Runtime/Core/RawImageUwbClientInputHandler.cs +++ b/src/Packages/UnityWebBrowser/Runtime/Core/RawImageUwbClientInputHandler.cs @@ -56,9 +56,11 @@ public void OnPointerDown(PointerEventData eventData) PointerEventData.InputButton.Middle => MouseClickType.Middle, _ => throw new ArgumentOutOfRangeException() }; + + int clickCount = eventData.clickCount > 0 ? eventData.clickCount : 1; if (GetMousePosition(out Vector2 pos)) - browserClient.SendMouseClick(pos, eventData.clickCount, clickType, MouseEventType.Down); + browserClient.SendMouseClick(pos, clickCount, clickType, MouseEventType.Down); } public void OnPointerEnter(PointerEventData eventData) @@ -89,9 +91,11 @@ public void OnPointerUp(PointerEventData eventData) PointerEventData.InputButton.Middle => MouseClickType.Middle, _ => throw new ArgumentOutOfRangeException() }; + + int clickCount = eventData.clickCount > 0 ? eventData.clickCount : 1; if (GetMousePosition(out Vector2 pos)) - browserClient.SendMouseClick(pos, eventData.clickCount, clickType, MouseEventType.Up); + browserClient.SendMouseClick(pos, clickCount, clickType, MouseEventType.Up); } protected override void OnStart() diff --git a/src/Packages/UnityWebBrowser/Runtime/Core/WebBrowserClient.cs b/src/Packages/UnityWebBrowser/Runtime/Core/WebBrowserClient.cs index 3fe0a0f9..815faba9 100644 --- a/src/Packages/UnityWebBrowser/Runtime/Core/WebBrowserClient.cs +++ b/src/Packages/UnityWebBrowser/Runtime/Core/WebBrowserClient.cs @@ -137,6 +137,12 @@ public Resolution Resolution /// [Tooltip("The port to use for remote debugging")] [Range(1024, 65353)] public uint remoteDebuggingPort = 9022; + + /// + /// Origins that are allowed to access remote debugging when is enabled + /// + [Tooltip("Origins that are allowed to access remote debugging when remoteDeubgging is enabled")] + public string[] remoteDebuggingAllowedOrigins = new[] { "http://127.0.0.1:9022" }; /// /// Manager for JS methods @@ -286,7 +292,7 @@ internal void Init() } //Get the path to the UWB process we are using and make sure it exists - string browserEnginePath = WebBrowserUtils.GetBrowserEngineProcessPath(engine); + string browserEnginePath = engine.GetEngineAppPath(WebBrowserUtils.GetRunningPlatform()); logger.Debug($"Starting browser engine process from '{browserEnginePath}'..."); if (!File.Exists(browserEnginePath)) @@ -337,14 +343,8 @@ internal void Init() out string assemblyLocation); if (assemblyLocation != null) { - if (!File.Exists(assemblyLocation)) - { - logger.Error("Failed to find provided communication layer assembly!"); - throw new FileNotFoundException("Failed to find provided communication layer assembly!"); - } - - argsBuilder.AppendArgument("comms-layer-path", assemblyLocation, true); - logger.Debug($"Using communication layer assembly at '{assemblyLocation}'."); + argsBuilder.AppendArgument("comms-layer-name", assemblyLocation, true); + logger.Debug($"Using communication layer of '{assemblyLocation}'."); } argsBuilder.AppendArgument("in-location", inLocation, true); @@ -368,7 +368,10 @@ internal void Init() //Setup remote debugging if (remoteDebugging) + { argsBuilder.AppendArgument("remote-debugging", remoteDebuggingPort); + argsBuilder.AppendArgument("remote-debugging-allowed-origins", string.Join(",", remoteDebuggingAllowedOrigins)); + } //Setup proxy argsBuilder.AppendArgument("proxy-server", proxySettings.ProxyServer); diff --git a/src/Packages/UnityWebBrowser/Runtime/Editor/EditorHelper.cs b/src/Packages/UnityWebBrowser/Runtime/Editor/EditorHelper.cs index 7bb32a21..d8b07623 100644 --- a/src/Packages/UnityWebBrowser/Runtime/Editor/EditorHelper.cs +++ b/src/Packages/UnityWebBrowser/Runtime/Editor/EditorHelper.cs @@ -38,7 +38,15 @@ public static Platform UnityBuildTargetToPlatform(this BuildTarget buildTarget) case BuildTarget.StandaloneWindows64: return Platform.Windows64; case BuildTarget.StandaloneOSX: - return Platform.MacOS; + //Need to check if target is Arm or x64 + string architecture = EditorUserBuildSettings.GetPlatformSettings("Standalone", "OSXUniversal", "Architecture"); + return architecture switch + { + "ARM64" => Platform.MacOSArm64, + "x64" => Platform.MacOS, + _ => throw new ArgumentOutOfRangeException() + }; + default: throw new ArgumentOutOfRangeException(); } diff --git a/src/Packages/UnityWebBrowser/Runtime/Editor/EngineManagement/EngineManager.cs b/src/Packages/UnityWebBrowser/Runtime/Editor/EngineManagement/EngineManager.cs index d67f6ada..b70a93a9 100644 --- a/src/Packages/UnityWebBrowser/Runtime/Editor/EngineManagement/EngineManager.cs +++ b/src/Packages/UnityWebBrowser/Runtime/Editor/EngineManagement/EngineManager.cs @@ -5,6 +5,7 @@ #if UNITY_EDITOR +using System; using System.IO; using System.Linq; using UnityEngine; @@ -15,6 +16,7 @@ namespace VoltstroStudios.UnityWebBrowser.Editor.EngineManagement { public static class EngineManager { + [Obsolete("Fetching of engine paths is now handled by the Engine class.")] public static string GetEngineDirectory(Engine engine, Platform platform) { Engine.EnginePlatformFiles files = engine.EngineFiles.FirstOrDefault(x => x.platform == platform); @@ -27,20 +29,23 @@ public static string GetEngineDirectory(Engine engine, Platform platform) return Path.GetFullPath(files.engineFileLocation); } + [Obsolete("Fetching of engine paths is now handled by the Engine class.")] public static string GetEngineDirectory(Engine engine) { return GetEngineDirectory(engine, GetCurrentEditorPlatform()); } + [Obsolete("Fetching of engine paths is now handled by the Engine class.")] public static string GetEngineProcessFullPath(Engine engine, Platform platform) { - string appPath = $"{GetEngineDirectory(engine, platform)}{engine.GetEngineExecutableName()}"; + string appPath = Path.Combine(GetEngineDirectory(engine, platform), engine.GetEngineExecutableName()); if (platform == Platform.Windows64) appPath += ".exe"; return Path.GetFullPath(appPath); } + [Obsolete("Fetching of engine paths is now handled by the Engine class.")] public static string GetEngineProcessFullPath(Engine engine) { return GetEngineProcessFullPath(engine, GetCurrentEditorPlatform()); @@ -56,9 +61,7 @@ public static Platform GetCurrentEditorPlatform() Platform platform = Platform.MacOS; #else #error Unsupported platform! - #endif - return platform; } } diff --git a/src/Packages/UnityWebBrowser/Runtime/Editor/EngineManagement/EngineManagerPostprocess.cs b/src/Packages/UnityWebBrowser/Runtime/Editor/EngineManagement/EngineManagerPostprocess.cs index d1202538..969c81e4 100644 --- a/src/Packages/UnityWebBrowser/Runtime/Editor/EngineManagement/EngineManagerPostprocess.cs +++ b/src/Packages/UnityWebBrowser/Runtime/Editor/EngineManagement/EngineManagerPostprocess.cs @@ -3,7 +3,7 @@ // // This project is under the MIT license. See the LICENSE.md file for more details. -#if UNITY_EDITOR +#if UNITY_EDITOR && !UWB_DISABLE_POSTPROCESSOR using System; using System.Collections.Generic; @@ -46,10 +46,8 @@ public void OnPostprocessBuild(BuildReport report) string buildFullOutputPath = report.summary.outputPath; string buildAppName = Path.GetFileNameWithoutExtension(buildFullOutputPath); - string buildOutputPath = Path.GetDirectoryName(buildFullOutputPath); - - Debug.Log("Copying engine process files..."); - + string buildOutputPath = Path.GetDirectoryName(buildFullOutputPath)!; + List engines = EditorHelper.FindAssetsByType(); if (engines.Count == 0) @@ -58,40 +56,32 @@ public void OnPostprocessBuild(BuildReport report) return; } - //We need to get the build's data folder - string buildDataPath = Path.GetFullPath($"{buildOutputPath}/{buildAppName}_Data/"); - if (buildTarget == BuildTarget.StandaloneOSX) - buildDataPath = - Path.GetFullPath($"{buildOutputPath}/{buildAppName}.app/Contents/Resources/Data/"); - - //Make sure the data folder exists - if (!Directory.Exists(buildDataPath)) + string builtAppFolder = Path.GetFullPath(buildTarget == BuildTarget.StandaloneOSX + ? Path.Combine(buildOutputPath, $"{buildAppName}.app", "Contents/Frameworks/") + : buildOutputPath); + + //Make sure the build folder exists + if (!Directory.Exists(builtAppFolder)) { Debug.LogError( - "Failed to get the build's data folder! Make sure your build is the same name as your product name (In your project settings)."); + "Failed to get the build's folder! Make sure your build is the same name as your product name (In your project settings)."); return; } - //UWB folder in the data folder - string buildUwbPath = $"{buildDataPath}/UWB/"; + //We need to get folder where UWB will live + string buildDataPath = + Path.GetFullPath( + buildTarget == BuildTarget.StandaloneOSX + ? Path.Combine(buildOutputPath, $"{buildAppName}.app", "Contents/Frameworks/") + : Path.Combine(buildOutputPath, $"{buildAppName}_Data/UWB/")); - //Make sure it exists - DirectoryInfo buildUwbInfo = new(buildUwbPath); - if (!buildUwbInfo.Exists) + //MacOS has a more customized way of deleting + if (buildTarget != BuildTarget.StandaloneOSX) { - Directory.CreateDirectory(buildUwbPath); - } - else //If the directory exists, clear it - { - foreach (FileInfo fileInfo in buildUwbInfo.EnumerateFiles()) - fileInfo.Delete(); - - foreach (DirectoryInfo directoryInfo in buildUwbInfo.EnumerateDirectories()) - directoryInfo.Delete(true); + if (Directory.Exists(buildDataPath)) + Directory.Delete(buildDataPath, true); } - buildUwbPath = Path.GetFullPath(buildUwbPath); - foreach (Engine engine in engines) if (engine.EngineFiles.Any(x => x.platform == buildPlatform)) { @@ -101,47 +91,29 @@ public void OnPostprocessBuild(BuildReport report) engine.EngineFiles.First(x => x.platform == buildPlatform); //Get the location where we are copying all the files - string engineFilesDir = Path.GetFullPath(engineFiles.engineFileLocation); + string engineFilesDir = Path.GetFullPath(engineFiles.engineEditorLocation); if (!Directory.Exists(engineFilesDir)) { Debug.LogError("The engine files directory doesn't exist!"); continue; } - string engineFilesParentDir = Directory.GetParent(engineFilesDir)?.Name; - - //Get all files that aren't Unity .meta files - //NOTE: UWB 2.0 stores it's engine files in '~' folder, which is excluded by Unity, so we shouldn't need this anymore, but we will keep it anyway - string[] files = Directory.EnumerateFiles(engineFilesDir, "*.*", SearchOption.AllDirectories) - .Where(fileType => !fileType.EndsWith(".meta")) - .ToArray(); - - int size = files.Length; - Debug.Log($"Found {size} number of files to copy..."); - - //Now to copy all the files. - //We need to keep the structure of the process - for (int i = 0; i < size; i++) + //Delete app path first on MacOS (if it exists) + string engineBuildPath = buildDataPath; + if (buildTarget == BuildTarget.StandaloneOSX) { - string file = files[i]; - string destFileName = Path.GetFileName(file); - EditorUtility.DisplayProgressBar("Copying UWB Engine Files", - $"Copying {destFileName}", i / size); - - //If the file is not at the parent directory, then we need to create the directory in the UWB folder - string parentDirectory = ""; - if (Directory.GetParent(file)?.Name != engineFilesParentDir) - { - parentDirectory = $"{Directory.GetParent(file)?.Name}/"; - - if (!Directory.Exists($"{buildUwbPath}{parentDirectory}")) - Directory.CreateDirectory($"{buildUwbPath}{parentDirectory}"); - } - - //Copy the file - File.Copy(file, $"{buildUwbPath}{parentDirectory}{destFileName}", true); + engineBuildPath = Path.Combine(buildDataPath, $"{engine.GetEngineExecutableName()}.app"); + if(Directory.Exists(engineBuildPath)) + Directory.Delete(engineBuildPath, true); + + engineFilesDir = Path.Combine(engineFilesDir, $"{engine.GetEngineExecutableName()}.app"); } - + + Debug.Log($"Copying engine files from {engineFilesDir} to {buildDataPath}..."); + EditorUtility.DisplayProgressBar("Copying UWB Engine Files", $"Copying engine files from {engineFilesDir} to {buildDataPath}...", 0); + + FileUtil.CopyFileOrDirectory(engineFilesDir, engineBuildPath); + EditorUtility.ClearProgressBar(); } diff --git a/src/Packages/UnityWebBrowser/Runtime/Helper/WebBrowserUtils.cs b/src/Packages/UnityWebBrowser/Runtime/Helper/WebBrowserUtils.cs index 78986b4f..5c178f86 100644 --- a/src/Packages/UnityWebBrowser/Runtime/Helper/WebBrowserUtils.cs +++ b/src/Packages/UnityWebBrowser/Runtime/Helper/WebBrowserUtils.cs @@ -3,33 +3,15 @@ // // This project is under the MIT license. See the LICENSE.md file for more details. -//Defines -#if UNITY_EDITOR_LINUX || UNITY_STANDALONE_LINUX && !UWB_DOCS - -//We need the Unix support package installed on UNIX systems -#if !UNIX_SUPPORT -#error Need UNIX support package! -#else -#define UWB_NEED_UNIX -#endif - -#endif - using System; -using System.Diagnostics; using System.IO; using System.Linq; -using System.Runtime.CompilerServices; -using System.Threading; -using Unity.Collections; using UnityEngine; using UnityEngine.Scripting; using UnityEngine.UI; using VoltstroStudios.UnityWebBrowser.Core.Engines; -using VoltstroStudios.UnityWebBrowser.Logging; -#if UWB_NEED_UNIX -using VoltstroStudios.UnityWebBrowser.UnixSupport; -#endif +using VoltstroStudios.UnityWebBrowser.Shared.Core; + #if UNITY_EDITOR using VoltstroStudios.UnityWebBrowser.Editor.EngineManagement; #endif @@ -42,13 +24,13 @@ namespace VoltstroStudios.UnityWebBrowser.Helper [Preserve] public static class WebBrowserUtils { - private static RuntimePlatform[] supportedPlatforms = new[] - { + private static readonly RuntimePlatform[] SupportedPlatforms = { RuntimePlatform.WindowsPlayer, RuntimePlatform.WindowsEditor, RuntimePlatform.LinuxPlayer, RuntimePlatform.LinuxEditor, - RuntimePlatform.OSXEditor + RuntimePlatform.OSXEditor, + RuntimePlatform.OSXPlayer }; /// @@ -70,6 +52,7 @@ public static string GetAdditionFilesDirectory() /// Gets the folder that the UWB process application lives in /// /// + [Obsolete("Fetching of engine paths is now handled by the Engine class.")] public static string GetBrowserEnginePath(Engine engine) { //Editor @@ -90,6 +73,7 @@ public static string GetBrowserEnginePath(Engine engine) /// Get a direct path to the UWB process application /// /// + [Obsolete("Fetching of engine paths is now handled by the Engine class.")] public static string GetBrowserEngineProcessPath(Engine engine) { #if UNITY_EDITOR @@ -149,6 +133,21 @@ public static bool GetScreenPointToLocalPositionDeltaOnImage(Graphic graphic, Ve return true; } + + /// + /// Gets the current running platform + /// + /// + public static Platform GetRunningPlatform() + { +#if UNITY_STANDALONE_WIN + return Platform.Windows64; +#elif UNITY_STANDALONE_LINUX + return Platform.Linux64; +#elif UNITY_STANDALONE_OSX + return RuntimeInformation.ProcessArchitecture == Architecture.Arm64 ? Platform.MacOSArm64 : Platform.MacOS; +#endif + } /// /// Checks if UWB is running on a supported platform @@ -156,7 +155,7 @@ public static bool GetScreenPointToLocalPositionDeltaOnImage(Graphic graphic, Ve /// public static bool IsRunningOnSupportedPlatform() { - return supportedPlatforms.Any(x => x == UnityEngine.Device.Application.platform); + return SupportedPlatforms.Any(x => x == UnityEngine.Device.Application.platform); } /// @@ -167,51 +166,7 @@ internal static string ColorToHex(Color32 color) { return ColorUtility.ToHtmlStringRGBA(color); } - - /// - /// Creates a for an engine - /// - /// - /// - /// - /// - /// - /// - internal static Process CreateEngineProcess(IWebBrowserLogger logger, Engine engine, string arguments, - DataReceivedEventHandler onLogEvent, DataReceivedEventHandler onErrorLogEvent) - { - string engineFullProcessPath = GetBrowserEngineProcessPath(engine); - string engineDirectory = GetBrowserEnginePath(engine); - - logger.Debug($"Process Path: '{engineFullProcessPath}'\nWorking: '{engineDirectory}'"); - logger.Debug($"Arguments: '{arguments}'"); - -#if UWB_NEED_UNIX - if (PermissionsManager.CheckAndSetIfNeededFileExecutablePermission(engineFullProcessPath)) - logger.Warn( - "UWB engine process did not have +rwx permissions! Engine process permission's were updated for the user."); -#endif - - Process process = new() - { - StartInfo = new ProcessStartInfo(engineFullProcessPath, arguments) - { - CreateNoWindow = true, - UseShellExecute = false, - RedirectStandardOutput = true, - RedirectStandardError = true, - WorkingDirectory = engineDirectory - }, - EnableRaisingEvents = true - }; - process.OutputDataReceived += onLogEvent; - process.ErrorDataReceived += onErrorLogEvent; - process.Start(); - process.BeginOutputReadLine(); - process.BeginErrorReadLine(); - return process; - } - + /// /// Sets every single pixel in a to one /// diff --git a/src/Packages/UnityWebBrowser/Runtime/Input/WebBrowserInputHelper.cs b/src/Packages/UnityWebBrowser/Runtime/Input/WebBrowserInputHelper.cs index 1c0bac9a..71e89710 100644 --- a/src/Packages/UnityWebBrowser/Runtime/Input/WebBrowserInputHelper.cs +++ b/src/Packages/UnityWebBrowser/Runtime/Input/WebBrowserInputHelper.cs @@ -30,6 +30,7 @@ public static WindowsKey UnityKeyCodeToWindowKey(this KeyCode key) return WindowsKey.None; case KeyCode.Backspace: return WindowsKey.Back; + case KeyCode.Delete: return WindowsKey.Delete; case KeyCode.Tab: @@ -42,8 +43,10 @@ public static WindowsKey UnityKeyCodeToWindowKey(this KeyCode key) return WindowsKey.Pause; case KeyCode.Escape: return WindowsKey.Escape; + case KeyCode.Space: return WindowsKey.Space; + case KeyCode.KeypadPeriod: return WindowsKey.OemPeriod; case KeyCode.KeypadDivide: @@ -56,6 +59,7 @@ public static WindowsKey UnityKeyCodeToWindowKey(this KeyCode key) return WindowsKey.Oemplus; case KeyCode.KeypadEnter: return WindowsKey.Enter; + case KeyCode.UpArrow: return WindowsKey.Up; case KeyCode.DownArrow: @@ -74,6 +78,7 @@ public static WindowsKey UnityKeyCodeToWindowKey(this KeyCode key) return WindowsKey.PageUp; case KeyCode.PageDown: return WindowsKey.PageDown; + case KeyCode.F1: return WindowsKey.F1; case KeyCode.F2: @@ -104,6 +109,7 @@ public static WindowsKey UnityKeyCodeToWindowKey(this KeyCode key) return WindowsKey.F14; case KeyCode.F15: return WindowsKey.F15; + case KeyCode.DoubleQuote: return WindowsKey.OemQuotes; case KeyCode.Quote: @@ -139,9 +145,84 @@ public static WindowsKey UnityKeyCodeToWindowKey(this KeyCode key) case KeyCode.Backslash: return WindowsKey.OemBackslash; case KeyCode.Slash: - return WindowsKey.Oem2; + return WindowsKey.OemQuestion; case KeyCode.Tilde: - return WindowsKey.Oem3; + return WindowsKey.Oemtilde; + + case KeyCode.Alpha1: + return WindowsKey.D1; + case KeyCode.Alpha2: + return WindowsKey.D2; + case KeyCode.Alpha3: + return WindowsKey.D3; + case KeyCode.Alpha4: + return WindowsKey.D4; + case KeyCode.Alpha5: + return WindowsKey.D5; + case KeyCode.Alpha6: + return WindowsKey.D6; + case KeyCode.Alpha7: + return WindowsKey.D7; + case KeyCode.Alpha8: + return WindowsKey.D8; + case KeyCode.Alpha9: + return WindowsKey.D9; + case KeyCode.Alpha0: + return WindowsKey.D0; + + case KeyCode.A: + return WindowsKey.A; + case KeyCode.B: + return WindowsKey.B; + case KeyCode.C: + return WindowsKey.C; + case KeyCode.D: + return WindowsKey.D; + case KeyCode.E: + return WindowsKey.E; + case KeyCode.F: + return WindowsKey.F; + case KeyCode.G: + return WindowsKey.G; + case KeyCode.H: + return WindowsKey.H; + case KeyCode.I: + return WindowsKey.I; + case KeyCode.J: + return WindowsKey.J; + case KeyCode.K: + return WindowsKey.K; + case KeyCode.L: + return WindowsKey.L; + case KeyCode.M: + return WindowsKey.M; + case KeyCode.N: + return WindowsKey.N; + case KeyCode.O: + return WindowsKey.O; + case KeyCode.P: + return WindowsKey.P; + case KeyCode.Q: + return WindowsKey.Q; + case KeyCode.R: + return WindowsKey.R; + case KeyCode.S: + return WindowsKey.S; + case KeyCode.T: + return WindowsKey.T; + case KeyCode.U: + return WindowsKey.U; + case KeyCode.V: + return WindowsKey.V; + case KeyCode.W: + return WindowsKey.W; + case KeyCode.Y: + return WindowsKey.Y; + case KeyCode.X: + return WindowsKey.X; + case KeyCode.Z: + return WindowsKey.Z; + default: throw new ArgumentOutOfRangeException(nameof(key), key, null); } @@ -165,6 +246,7 @@ public static WindowsKey UnityKeyToWindowKey(this Key key) return WindowsKey.Enter; case Key.Tab: return WindowsKey.Tab; + case Key.Quote: return WindowsKey.OemQuotes; case Key.Semicolon: @@ -179,6 +261,9 @@ public static WindowsKey UnityKeyToWindowKey(this Key key) return WindowsKey.OemCloseBrackets; case Key.Minus: return WindowsKey.OemMinus; + case Key.Equals: + return WindowsKey.Oemplus; + case Key.LeftShift: return WindowsKey.LShiftKey; case Key.RightShift: @@ -190,8 +275,10 @@ public static WindowsKey UnityKeyToWindowKey(this Key key) return WindowsKey.LControlKey; case Key.RightCtrl: return WindowsKey.RControlKey; + case Key.Escape: return WindowsKey.Escape; + case Key.LeftArrow: return WindowsKey.Left; case Key.RightArrow: @@ -200,6 +287,8 @@ public static WindowsKey UnityKeyToWindowKey(this Key key) return WindowsKey.Up; case Key.DownArrow: return WindowsKey.Down; + + case Key.Backspace: return WindowsKey.Back; case Key.PageDown: @@ -218,6 +307,12 @@ public static WindowsKey UnityKeyToWindowKey(this Key key) return WindowsKey.PrintScreen; case Key.Pause: return WindowsKey.Pause; + + case Key.Backslash: + return WindowsKey.OemBackslash; + case Key.Slash: + return WindowsKey.OemQuestion; + case Key.NumpadEnter: return WindowsKey.Enter; case Key.NumpadDivide: @@ -250,6 +345,9 @@ public static WindowsKey UnityKeyToWindowKey(this Key key) return WindowsKey.NumPad8; case Key.Numpad9: return WindowsKey.NumPad9; + + case Key.Backquote: + return WindowsKey.Oemtilde; case Key.F1: return WindowsKey.F1; case Key.F2: @@ -274,6 +372,81 @@ public static WindowsKey UnityKeyToWindowKey(this Key key) return WindowsKey.F11; case Key.F12: return WindowsKey.F12; + + case Key.Digit1: + return WindowsKey.D1; + case Key.Digit2: + return WindowsKey.D2; + case Key.Digit3: + return WindowsKey.D3; + case Key.Digit4: + return WindowsKey.D4; + case Key.Digit5: + return WindowsKey.D5; + case Key.Digit6: + return WindowsKey.D6; + case Key.Digit7: + return WindowsKey.D7; + case Key.Digit8: + return WindowsKey.D8; + case Key.Digit9: + return WindowsKey.D9; + case Key.Digit0: + return WindowsKey.D0; + + case Key.A: + return WindowsKey.A; + case Key.B: + return WindowsKey.B; + case Key.C: + return WindowsKey.C; + case Key.D: + return WindowsKey.D; + case Key.E: + return WindowsKey.E; + case Key.F: + return WindowsKey.F; + case Key.G: + return WindowsKey.G; + case Key.H: + return WindowsKey.H; + case Key.I: + return WindowsKey.I; + case Key.J: + return WindowsKey.J; + case Key.K: + return WindowsKey.K; + case Key.L: + return WindowsKey.L; + case Key.M: + return WindowsKey.M; + case Key.N: + return WindowsKey.N; + case Key.O: + return WindowsKey.O; + case Key.P: + return WindowsKey.P; + case Key.Q: + return WindowsKey.Q; + case Key.R: + return WindowsKey.R; + case Key.S: + return WindowsKey.S; + case Key.T: + return WindowsKey.T; + case Key.U: + return WindowsKey.U; + case Key.V: + return WindowsKey.V; + case Key.W: + return WindowsKey.W; + case Key.Y: + return WindowsKey.Y; + case Key.X: + return WindowsKey.X; + case Key.Z: + return WindowsKey.Z; + default: throw new ArgumentOutOfRangeException(nameof(key), key, null); } diff --git a/src/Packages/UnityWebBrowser/Runtime/Logging/DefaultUnityWebBrowserLogger.cs b/src/Packages/UnityWebBrowser/Runtime/Logging/DefaultUnityWebBrowserLogger.cs index dd4d9204..77e262ce 100644 --- a/src/Packages/UnityWebBrowser/Runtime/Logging/DefaultUnityWebBrowserLogger.cs +++ b/src/Packages/UnityWebBrowser/Runtime/Logging/DefaultUnityWebBrowserLogger.cs @@ -12,7 +12,7 @@ namespace VoltstroStudios.UnityWebBrowser.Logging /// public sealed class DefaultUnityWebBrowserLogger : IWebBrowserLogger { - private const string LoggingTag = "[Web Browser]"; + private const string LoggingTag = "[UWB]"; private readonly ILogger logger; diff --git a/src/Packages/UnityWebBrowser/Runtime/Logging/JsonLogSeverityConverter.cs b/src/Packages/UnityWebBrowser/Runtime/Logging/JsonLogSeverityConverter.cs index 0aba6786..d97d0b7d 100644 --- a/src/Packages/UnityWebBrowser/Runtime/Logging/JsonLogSeverityConverter.cs +++ b/src/Packages/UnityWebBrowser/Runtime/Logging/JsonLogSeverityConverter.cs @@ -27,6 +27,8 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist { if (reader.Value is string value) { + if (value == "Fatal") + return LogSeverity.Fatal; if (value == "Error") return LogSeverity.Error; if (value == "Warning") diff --git a/src/Packages/UnityWebBrowser/Runtime/Logging/JsonLogStructure.cs b/src/Packages/UnityWebBrowser/Runtime/Logging/JsonLogStructure.cs index 7e3d3562..ca1cbd40 100644 --- a/src/Packages/UnityWebBrowser/Runtime/Logging/JsonLogStructure.cs +++ b/src/Packages/UnityWebBrowser/Runtime/Logging/JsonLogStructure.cs @@ -13,16 +13,23 @@ namespace VoltstroStudios.UnityWebBrowser.Logging [Preserve] internal class JsonLogStructure { - [JsonProperty("@t")] public DateTime Timestamp { get; set; } + [JsonProperty("@t")] + public DateTime Timestamp { get; set; } - [JsonProperty("@m")] public string Message { get; set; } + [JsonProperty("@m")] + public string Message { get; set; } [JsonConverter(typeof(JsonLogSeverityConverter))] [JsonProperty("@l")] public LogSeverity Level { get; set; } = LogSeverity.Info; - [JsonProperty("@x")] public string Exception { get; set; } + [JsonProperty("@x")] + public string Exception { get; set; } - [JsonProperty("@i")] public string EventId { get; set; } + [JsonProperty("@i")] + public string EventId { get; set; } + + [JsonProperty("SourceContext")] + public string Category { get; set; } } } \ No newline at end of file diff --git a/src/Packages/UnityWebBrowser/Runtime/Logging/ProcessLogHandler.cs b/src/Packages/UnityWebBrowser/Runtime/Logging/ProcessLogHandler.cs index 4624b90d..760617a2 100644 --- a/src/Packages/UnityWebBrowser/Runtime/Logging/ProcessLogHandler.cs +++ b/src/Packages/UnityWebBrowser/Runtime/Logging/ProcessLogHandler.cs @@ -47,13 +47,13 @@ internal void HandleOutputProcessLog(object sender, DataReceivedEventArgs e) JsonLogStructure logStructure = ReadJsonLog(e.Data); if (logStructure.Level is LogSeverity.Debug or LogSeverity.Info) - logger.Debug(logStructure.Message); + logger.Debug($"[{logStructure.Category}]: {logStructure.Message}"); else if (logStructure.Level == LogSeverity.Warn) - logger.Warn(logStructure.Message); + logger.Warn($"[{logStructure.Category}]: {logStructure.Message}"); else if (logStructure.Level == LogSeverity.Error) - logger.Error($"{logStructure.Message}\n{logStructure.Exception}"); + logger.Error($"[{logStructure.Category}]: {logStructure.Message}\n{logStructure.Exception}"); else if (logStructure.Level == LogSeverity.Fatal) - logger.Error($"{logStructure.Message}\n{logStructure.Exception}"); + logger.Error($"[{logStructure.Category}]: {logStructure.Message}\n{logStructure.Exception}"); } catch (Exception ex) { diff --git a/src/Packages/UnityWebBrowser/Runtime/VoltstroStudios.UnityWebBrowser.asmdef b/src/Packages/UnityWebBrowser/Runtime/VoltstroStudios.UnityWebBrowser.asmdef index 3eefdc7c..1bd51095 100644 --- a/src/Packages/UnityWebBrowser/Runtime/VoltstroStudios.UnityWebBrowser.asmdef +++ b/src/Packages/UnityWebBrowser/Runtime/VoltstroStudios.UnityWebBrowser.asmdef @@ -3,7 +3,6 @@ "rootNamespace": "VoltstroStudios.UnityWebBrowser", "references": [ "VoltstroStudios.NativeArraySpanExtensions", - "VoltstroStudios.UnityWebBrowser.UnixSupport", "Unity.TextMeshPro", "Unity.InputSystem", "UniTask" @@ -36,7 +35,6 @@ "precompiledReferences": [ "VoltstroStudios.UnityWebBrowser.Shared.dll", "VoltRpc.dll", - "VoltRpc.Extension.Memory.dll", "Newtonsoft.Json.dll" ], "autoReferenced": true, diff --git a/src/Packages/UnityWebBrowser/Samples~/Runtime/Scripts/UWBRuntime.cs b/src/Packages/UnityWebBrowser/Samples~/Runtime/Scripts/UWBRuntime.cs index 2178b57a..2eb01ad5 100644 --- a/src/Packages/UnityWebBrowser/Samples~/Runtime/Scripts/UWBRuntime.cs +++ b/src/Packages/UnityWebBrowser/Samples~/Runtime/Scripts/UWBRuntime.cs @@ -68,12 +68,16 @@ private void Start() new Engine.EnginePlatformFiles { platform = Platform.Windows64, - engineFileLocation = "Packages/dev.voltstro.unitywebbrowser.engine.cef.win.x64/Engine~/" + engineBaseAppLocation = string.Empty, + engineEditorLocation = "Packages/dev.voltstro.unitywebbrowser.engine.cef.win.x64/Engine~/", + engineRuntimeLocation = "UWB/" }, new Engine.EnginePlatformFiles { platform = Platform.Linux64, - engineFileLocation = "Packages/dev.voltstro.unitywebbrowser.engine.cef.linux.x64/Engine~/" + engineBaseAppLocation = string.Empty, + engineEditorLocation = "Packages/dev.voltstro.unitywebbrowser.engine.cef.linux.x64/Engine~/", + engineRuntimeLocation = "UWB/" } }; #endif diff --git a/src/Packages/UnityWebBrowser/Tests/Runtime/LoggerTests.cs b/src/Packages/UnityWebBrowser/Tests/Runtime/LoggerTests.cs index 7292635b..57743a6c 100644 --- a/src/Packages/UnityWebBrowser/Tests/Runtime/LoggerTests.cs +++ b/src/Packages/UnityWebBrowser/Tests/Runtime/LoggerTests.cs @@ -20,7 +20,7 @@ public void DebugLogTest() Assert.AreEqual(LogSeverity.Debug, logStructure.Level); Assert.AreEqual(null, logStructure.Exception); StringAssert.IsMatch("Some message...", logStructure.Message); - StringAssert.IsMatch("82d21ca4", logStructure.EventId); + //StringAssert.IsMatch("82d21ca4", logStructure.EventId); } [Test] @@ -32,7 +32,7 @@ public void InfoLogTest() Assert.AreEqual(LogSeverity.Info, logStructure.Level); Assert.AreEqual(null, logStructure.Exception); StringAssert.IsMatch("Some message...", logStructure.Message); - StringAssert.IsMatch("82d21ca4", logStructure.EventId); + //StringAssert.IsMatch("82d21ca4", logStructure.EventId); } [Test] @@ -44,7 +44,7 @@ public void WarnLogTest() Assert.AreEqual(LogSeverity.Warn, logStructure.Level); Assert.AreEqual(null, logStructure.Exception); StringAssert.IsMatch("Some message...", logStructure.Message); - StringAssert.IsMatch("82d21ca4", logStructure.EventId); + //StringAssert.IsMatch("82d21ca4", logStructure.EventId); } [Test] @@ -56,7 +56,7 @@ public void ErrorLogTest() Assert.AreEqual(LogSeverity.Error, logStructure.Level); Assert.AreEqual(null, logStructure.Exception); StringAssert.IsMatch("Some message...", logStructure.Message); - StringAssert.IsMatch("82d21ca4", logStructure.EventId); + //StringAssert.IsMatch("82d21ca4", logStructure.EventId); } [Test] @@ -67,7 +67,7 @@ public void ExceptionLogTest() JsonLogStructure logStructure = ProcessLogHandler.ReadJsonLog(json); Assert.AreEqual(LogSeverity.Error, logStructure.Level); StringAssert.IsMatch("Error setting up IPC!", logStructure.Message); - StringAssert.IsMatch("3418fa09", logStructure.EventId); + //StringAssert.IsMatch("3418fa09", logStructure.EventId); } } } \ No newline at end of file diff --git a/src/Packages/UnityWebBrowser/package.json b/src/Packages/UnityWebBrowser/package.json index 0d566fef..180705df 100644 --- a/src/Packages/UnityWebBrowser/package.json +++ b/src/Packages/UnityWebBrowser/package.json @@ -1,9 +1,9 @@ { "name": "dev.voltstro.unitywebbrowser", "displayName": "Unity Web Browser", - "version": "2.1.1", - "unity": "2021.3", "description": "Unity Web Browser (UWB) is a Unity package that allows displaying and interacting with the web from within Unity.", + "version": "2.2.0", + "unity": "2021.3", "author": { "name": "Voltstro", "email": "me@voltstro.dev", @@ -14,13 +14,13 @@ "url": "https://github.com/Voltstro-Studios/UnityWebBrowser.git" }, "hideInEditor": false, - "changelogUrl": "https://projects.voltstro.dev/UnityWebBrowser/changelog/", - "documentationUrl": "https://projects.voltstro.dev/UnityWebBrowser/", + "changelogUrl": "https://projects.voltstro.dev/UnityWebBrowser/latest/changelog/", + "documentationUrl": "https://projects.voltstro.dev/UnityWebBrowser/latest/", "licensesUrl": "https://github.com/Voltstro-Studios/UnityWebBrowser/blob/master/LICENSE.md", "dependencies": { "dev.voltstro.nativearrayspanextensions": "1.0.1", "com.unity.nuget.newtonsoft-json": "3.2.1", - "com.cysharp.unitask": "2.5.3", + "com.cysharp.unitask": "2.5.5", "org.nuget.voltrpc": "3.2.0" }, "samples": [ diff --git a/src/ThirdParty/CefGlue b/src/ThirdParty/CefGlue index 1f5a4fa3..8746fecd 160000 --- a/src/ThirdParty/CefGlue +++ b/src/ThirdParty/CefGlue @@ -1 +1 @@ -Subproject commit 1f5a4fa3799900b574706c87c954bf1f68f0da51 +Subproject commit 8746fecdddba6a993f3e3c19401d487c99d33599 diff --git a/src/ThirdParty/Libs/cef/.gitignore b/src/ThirdParty/Libs/cef/.gitignore new file mode 100644 index 00000000..d311c298 --- /dev/null +++ b/src/ThirdParty/Libs/cef/.gitignore @@ -0,0 +1,6 @@ +temp/ +linux64/ +macosarm64/ +macosx64/ +windows64/ + diff --git a/src/ThirdParty/Libs/cef/linux64/.gitignore b/src/ThirdParty/Libs/cef/linux64/.gitignore deleted file mode 100644 index 1a677b51..00000000 --- a/src/ThirdParty/Libs/cef/linux64/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -**.pak -**.dat -**.bin -**.txt -**.so -**.so.1 -**.json -chrome-sandbox \ No newline at end of file diff --git a/src/ThirdParty/Libs/cef/macosx64/.gitignore b/src/ThirdParty/Libs/cef/macosx64/.gitignore deleted file mode 100644 index 54aa23b6..00000000 --- a/src/ThirdParty/Libs/cef/macosx64/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -/Chromium Embedded Framework.framework/** -**.a -**.txt -chrome-sandbox \ No newline at end of file diff --git a/src/ThirdParty/Libs/cef/windows64/.gitignore b/src/ThirdParty/Libs/cef/windows64/.gitignore deleted file mode 100644 index d79a0e66..00000000 --- a/src/ThirdParty/Libs/cef/windows64/.gitignore +++ /dev/null @@ -1,7 +0,0 @@ -**.pak -**.dat -**.bin -**.txt -**.dll -**.lib -**.json \ No newline at end of file diff --git a/src/UnityWebBrowser.Engine.Cef/Core/CefSafeBuffer.cs b/src/UnityWebBrowser.Engine.Cef/Core/CefSafeBuffer.cs deleted file mode 100644 index ad114ca3..00000000 --- a/src/UnityWebBrowser.Engine.Cef/Core/CefSafeBuffer.cs +++ /dev/null @@ -1,24 +0,0 @@ -// UnityWebBrowser (UWB) -// Copyright (c) 2021-2022 Voltstro-Studios -// -// This project is under the MIT license. See the LICENSE.md file for more details. - -using System; -using System.Runtime.InteropServices; - -//From: https://github.com/chromelyapps/Chromely/blob/989d74141aabb8d874b2ad9b75757f56f3e6fdba/src_5.2/Chromely/Browser/Handlers/CefSafeBuffer.cs -namespace UnityWebBrowser.Engine.Cef.Core; - -public class CefSafeBuffer : SafeBuffer -{ - public CefSafeBuffer(IntPtr data, ulong noOfBytes) : base(false) - { - SetHandle(data); - Initialize(noOfBytes); - } - - protected override bool ReleaseHandle() - { - return true; - } -} \ No newline at end of file diff --git a/src/UnityWebBrowser.Engine.Cef/Core/CefEngineControlsManager.cs b/src/UnityWebBrowser.Engine.Cef/Main/Core/CefEngineControlsManager.cs similarity index 73% rename from src/UnityWebBrowser.Engine.Cef/Core/CefEngineControlsManager.cs rename to src/UnityWebBrowser.Engine.Cef/Main/Core/CefEngineControlsManager.cs index 29b124ae..fc00fc24 100644 --- a/src/UnityWebBrowser.Engine.Cef/Core/CefEngineControlsManager.cs +++ b/src/UnityWebBrowser.Engine.Cef/Main/Core/CefEngineControlsManager.cs @@ -8,10 +8,11 @@ using System.Linq; using System.Numerics; using System.Runtime.CompilerServices; -using UnityWebBrowser.Engine.Cef.Browser; +using Microsoft.Extensions.Logging; +using UnityWebBrowser.Engine.Cef.Shared.Browser; +using UnityWebBrowser.Engine.Cef.Shared.Core; using VoltstroStudios.UnityWebBrowser.Engine.Shared; using VoltstroStudios.UnityWebBrowser.Engine.Shared.Core; -using VoltstroStudios.UnityWebBrowser.Engine.Shared.Core.Logging; using VoltstroStudios.UnityWebBrowser.Engine.Shared.Popups; using VoltstroStudios.UnityWebBrowser.Shared; using VoltstroStudios.UnityWebBrowser.Shared.Core; @@ -25,6 +26,9 @@ namespace UnityWebBrowser.Engine.Cef.Core; /// internal class CefEngineControlsManager : IEngineControls, IDisposable { + private readonly ILogger mainLogger; + private readonly ILogger browserConsoleLogger; + private string[] args; private UwbCefApp cefApp; @@ -32,16 +36,29 @@ internal class CefEngineControlsManager : IEngineControls, IDisposable private CefMainArgs cefMainArgs; private LaunchArguments launchArguments; + private IntPtr sandboxInfo; + /// /// Creates a new instance /// /// /// /// - public CefEngineControlsManager() + public CefEngineControlsManager(LoggerManager loggerManagerManager) { +#if MACOS + CefMacOsFrameworkLoader.AddFrameworkLoader(); +#endif + //Setup CEF CefRuntime.Load(); + + mainLogger = loggerManagerManager.CreateLogger("CEF Engine"); + browserConsoleLogger = loggerManagerManager.CreateLogger("CEF Engine Browser Console"); + + CefLoggerWrapper.Init(mainLogger); + + sandboxInfo = IntPtr.Zero; } /// @@ -63,12 +80,22 @@ public void EarlyInit(LaunchArguments arguments, string[] rawArguments) argv[0] = "-"; #endif +#if LINUX + //Linux we force sandbox to be disabled + arguments.NoSandbox = true; +#endif + //Set up CEF args and the CEF app cefMainArgs = new CefMainArgs(argv); cefApp = new UwbCefApp(launchArguments); +#if WINDOWS + if(!launchArguments.NoSandbox) + sandboxInfo = CefSandbox.cef_sandbox_info_create(); +#endif + //Run our sub-processes - int exitCode = CefRuntime.ExecuteProcess(cefMainArgs, cefApp, IntPtr.Zero); + int exitCode = CefRuntime.ExecuteProcess(cefMainArgs, cefApp, sandboxInfo); if (exitCode != -1) { CefLoggerWrapper.Debug("Sub-Process exit: {ExitCode}", exitCode); @@ -108,10 +135,29 @@ public void Init(ClientControlsActions clientControlsActions, EnginePopupManager }; //Setup the CEF settings +#if WINDOWS || LINUX + string baseCefPath = Path.GetFullPath(Environment.CurrentDirectory); + string resourcesPath = baseCefPath; + string localesPath = Path.Combine(baseCefPath, "locales"); + const string subprocessPath = null; + +#else + string frameworksPath = Path.GetFullPath(Path.Join(Environment.CurrentDirectory, "../Frameworks/")); + string baseCefPath = Path.Join(frameworksPath, "Chromium Embedded Framework.framework"); + string resourcesPath = Path.Combine(baseCefPath, "Resources"); + string localesPath = null; + + string subprocessPath = Path.Combine(frameworksPath, "UnityWebBrowser.Engine.Cef.SubProcess.app/Contents/MacOS/UnityWebBrowser.Engine.Cef.SubProcess"); + + if (!File.Exists(subprocessPath)) + throw new FileNotFoundException($"Failed to find subprocess app at '{subprocessPath}'!"); +#endif + + CefSettings cefSettings = new() { WindowlessRenderingEnabled = true, - NoSandbox = true, + NoSandbox = launchArguments.NoSandbox, LogFile = launchArguments.LogPath.FullName, CachePath = cachePathArgument, MultiThreadedMessageLoop = false, @@ -120,17 +166,22 @@ public void Init(ClientControlsActions clientControlsActions, EnginePopupManager ExternalMessagePump = false, RemoteDebuggingPort = launchArguments.RemoteDebugging, PersistSessionCookies = true, - PersistUserPreferences = true, -#if LINUX || MACOS - //On Linux we need to tell CEF where everything is, this will assume that the working directory is where everything is! - ResourcesDirPath = Path.Combine(Environment.CurrentDirectory), - LocalesDirPath = Path.Combine(Environment.CurrentDirectory, "locales"), - BrowserSubprocessPath = Environment.ProcessPath + //PersistUserPreferences = true, + ResourcesDirPath = resourcesPath, + LocalesDirPath = localesPath, + BrowserSubprocessPath = subprocessPath, +#if MACOS + FrameworkDirPath = baseCefPath #endif }; //Init CEF - CefRuntime.Initialize(cefMainArgs, cefSettings, cefApp, IntPtr.Zero); + CefRuntime.Initialize(cefMainArgs, cefSettings, cefApp, sandboxInfo); + +#if WINDOWS + if(!launchArguments.NoSandbox) + CefSandbox.cef_sandbox_info_destroy(sandboxInfo); +#endif //Create a CEF window and set it to windowless CefWindowInfo cefWindowInfo = CefWindowInfo.Create(); @@ -146,7 +197,7 @@ public void Init(ClientControlsActions clientControlsActions, EnginePopupManager LocalStorage = launchArguments.LocalStorage ? CefState.Enabled : CefState.Disabled }; - Logger.Debug($"{CefLoggerWrapper.FullCefMessageTag} Starting CEF with these options:" + + mainLogger.LogDebug($"Starting CEF with these options:" + $"\nProcess Path: {Environment.ProcessPath}" + $"\nJS: {launchArguments.JavaScript}" + $"\nLocal Storage: {launchArguments.LocalStorage}" + @@ -155,21 +206,20 @@ public void Init(ClientControlsActions clientControlsActions, EnginePopupManager $"\nPopup Action: {launchArguments.PopupAction}" + $"\nLog Path: {launchArguments.LogPath.FullName}" + $"\nLog Severity: {launchArguments.LogSeverity}"); - Logger.Info($"{CefLoggerWrapper.FullCefMessageTag} Starting CEF client..."); + mainLogger.LogInformation($"Starting CEF client..."); //Create cef browser - cefClient = new UwbCefClient(new CefSize(launchArguments.Width, launchArguments.Height), - launchArguments.PopupAction, popupManager, - new ProxySettings(launchArguments.ProxyUsername, launchArguments.ProxyPassword, - launchArguments.ProxyEnabled), clientControlsActions); + cefClient = new UwbCefClient( + new CefSize(launchArguments.Width, launchArguments.Height), + launchArguments.PopupAction, + popupManager, + new ProxySettings(launchArguments.ProxyUsername, launchArguments.ProxyPassword, launchArguments.ProxyEnabled), + clientControlsActions, + mainLogger, + browserConsoleLogger); CefBrowserHost.CreateBrowser(cefWindowInfo, cefClient, cefBrowserSettings, launchArguments.InitialUrl); } - public static void PostTask(CefThreadId threadId, Action action) - { - CefRuntime.PostTask(threadId, new CefActionTask(action)); - } - #region Engine Actions [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -186,11 +236,11 @@ public void Shutdown() //We can only quit the message loop on the UI (main) thread if (!CefRuntime.CurrentlyOn(CefThreadId.UI)) { - PostTask(CefThreadId.UI, Shutdown); + CefActionTask.PostTask(CefThreadId.UI, Shutdown); return; } - Logger.Debug("Quitting message loop..."); + mainLogger.LogDebug($"Quitting message loop..."); CefRuntime.QuitMessageLoop(); } diff --git a/src/UnityWebBrowser.Engine.Cef/Core/UwbCefEngineEntry.cs b/src/UnityWebBrowser.Engine.Cef/Main/Core/UwbCefEngineEntry.cs similarity index 81% rename from src/UnityWebBrowser.Engine.Cef/Core/UwbCefEngineEntry.cs rename to src/UnityWebBrowser.Engine.Cef/Main/Core/UwbCefEngineEntry.cs index 196b4f1c..4ad3daaf 100644 --- a/src/UnityWebBrowser.Engine.Cef/Core/UwbCefEngineEntry.cs +++ b/src/UnityWebBrowser.Engine.Cef/Main/Core/UwbCefEngineEntry.cs @@ -5,8 +5,8 @@ using System; using System.Linq; +using Microsoft.Extensions.Logging; using VoltstroStudios.UnityWebBrowser.Engine.Shared.Core; -using VoltstroStudios.UnityWebBrowser.Engine.Shared.Core.Logging; using Xilium.CefGlue; namespace UnityWebBrowser.Engine.Cef.Core; @@ -18,19 +18,15 @@ internal class UwbCefEngineEntry : EngineEntryPoint { private CefEngineControlsManager cefEngineControlsManager; - protected override bool ShouldInitLogger(LaunchArguments launchArguments, string[] args) - { - return !args.Any(arg => arg.StartsWith("--type=")); - } - protected override void EarlyInit(LaunchArguments launchArguments, string[] args) { - cefEngineControlsManager = new CefEngineControlsManager(); + cefEngineControlsManager = new CefEngineControlsManager(LoggerManagerFactory); cefEngineControlsManager.EarlyInit(launchArguments, args); } protected override void EntryPoint(LaunchArguments launchArguments, string[] args) { + cefEngineControlsManager.Init(ClientControlsActions, PopupManager); SetupIpc(cefEngineControlsManager, launchArguments); @@ -40,7 +36,6 @@ protected override void EntryPoint(LaunchArguments launchArguments, string[] arg CefRuntime.RunMessageLoop(); //If the message loop quits - Logger.Debug($"{CefLoggerWrapper.FullCefMessageTag} Message loop quit."); Dispose(); Environment.Exit(0); } diff --git a/src/UnityWebBrowser.Engine.Cef/Program.cs b/src/UnityWebBrowser.Engine.Cef/Main/Program.cs similarity index 100% rename from src/UnityWebBrowser.Engine.Cef/Program.cs rename to src/UnityWebBrowser.Engine.Cef/Main/Program.cs diff --git a/src/UnityWebBrowser.Engine.Cef/Main/UnityWebBrowser.Engine.Cef.csproj b/src/UnityWebBrowser.Engine.Cef/Main/UnityWebBrowser.Engine.Cef.csproj new file mode 100644 index 00000000..51ee7399 --- /dev/null +++ b/src/UnityWebBrowser.Engine.Cef/Main/UnityWebBrowser.Engine.Cef.csproj @@ -0,0 +1,90 @@ + + + + + + + Exe + net8.0 + ../Shared/chromium-logo.ico + win-x64;linux-x64;osx-x64 + + false + ../bin/$(Configuration)/ + ../bin/$(Configuration)/publish/$(RuntimeIdentifier) + + true + true + true + false + true + true + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + PreserveNewest + + + PreserveNewest + + + + + + + + + + + .allowedextension + + + + + true + + + + true + + + + diff --git a/src/UnityWebBrowser.Engine.Cef/Main/icon.icns b/src/UnityWebBrowser.Engine.Cef/Main/icon.icns new file mode 100644 index 00000000..4ff0f570 Binary files /dev/null and b/src/UnityWebBrowser.Engine.Cef/Main/icon.icns differ diff --git a/src/UnityWebBrowser.Engine.Cef/Main/info.plist b/src/UnityWebBrowser.Engine.Cef/Main/info.plist new file mode 100644 index 00000000..85e40416 --- /dev/null +++ b/src/UnityWebBrowser.Engine.Cef/Main/info.plist @@ -0,0 +1,32 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + UnityWebBrowser.Engine.Cef + CFBundleIconFile + icon.icns + CFBundleIdentifier + dev.voltstro.uwb.engine.cef + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + UnityWebBrowser.Engine.Cef + CFBundlePackageType + APPL + CFBundleVersion + 1.0 + LSMinimumSystemVersion + 10.13.0 + NSMainNibFile + MainMenu + NSPrincipalClass + NSApplication + NSSupportAutomaticGraphicsSwitching + + LSUIElement + 1 + + diff --git a/src/UnityWebBrowser.Engine.Cef/Roots.xml b/src/UnityWebBrowser.Engine.Cef/Roots.xml deleted file mode 100644 index e9f1f3cc..00000000 --- a/src/UnityWebBrowser.Engine.Cef/Roots.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/UnityWebBrowser.Engine.Cef/Shared/AssemblyInfo.cs b/src/UnityWebBrowser.Engine.Cef/Shared/AssemblyInfo.cs new file mode 100644 index 00000000..c25f89f3 --- /dev/null +++ b/src/UnityWebBrowser.Engine.Cef/Shared/AssemblyInfo.cs @@ -0,0 +1,8 @@ +// UnityWebBrowser (UWB) +// Copyright (c) 2021-2024 Voltstro-Studios +// +// This project is under the MIT license. See the LICENSE.md file for more details. + +using System.Runtime.CompilerServices; + +[assembly: InternalsVisibleTo("UnityWebBrowser.Engine.Cef")] \ No newline at end of file diff --git a/src/UnityWebBrowser.Engine.Cef/Browser/Js/ExecuteJsMethodMessage.cs b/src/UnityWebBrowser.Engine.Cef/Shared/Browser/Js/ExecuteJsMethodMessage.cs similarity index 84% rename from src/UnityWebBrowser.Engine.Cef/Browser/Js/ExecuteJsMethodMessage.cs rename to src/UnityWebBrowser.Engine.Cef/Shared/Browser/Js/ExecuteJsMethodMessage.cs index 6e3c4057..ebda9fe7 100644 --- a/src/UnityWebBrowser.Engine.Cef/Browser/Js/ExecuteJsMethodMessage.cs +++ b/src/UnityWebBrowser.Engine.Cef/Shared/Browser/Js/ExecuteJsMethodMessage.cs @@ -6,26 +6,22 @@ using System; using System.Text.Json; using System.Text.Json.Serialization; -using UnityWebBrowser.Engine.Cef.Browser.Messages; +using UnityWebBrowser.Engine.Cef.Shared.Browser.Messages; using VoltstroStudios.UnityWebBrowser.Engine.Shared.Core; using VoltstroStudios.UnityWebBrowser.Shared.Js; -namespace UnityWebBrowser.Engine.Cef.Browser.Js; +namespace UnityWebBrowser.Engine.Cef.Shared.Browser.Js; internal class ExecuteJsMethodMessage : MessageBase { public const string ExecuteJsMethodName = "UWBEXECUTEJSMETHOD"; - - [JsonIgnore] - public override string MessageName => ExecuteJsMethodName; - - [JsonIgnore] - private readonly ClientControlsActions clientControlsActions; + + [JsonIgnore] private readonly ClientControlsActions clientControlsActions; public ExecuteJsMethodMessage() { } - + public ExecuteJsMethodMessage(ClientControlsActions clientControlsActions) { this.clientControlsActions = clientControlsActions; @@ -37,9 +33,11 @@ public ExecuteJsMethodMessage(string methodName, JsValue[] arguments) Arguments = arguments; } + [JsonIgnore] public override string MessageName => ExecuteJsMethodName; + protected override void Execute(ExecuteJsMethodMessage value) { - ExecuteJsMethod executeJsMethod = new ExecuteJsMethod(value.MethodName, value.Arguments); + ExecuteJsMethod executeJsMethod = new(value.MethodName, value.Arguments); //Since JSValue.Value is an object, System.Text.Json will deserialize as a JsonElement //Pain in the ass, but we can fix it @@ -55,9 +53,9 @@ protected override void Execute(ExecuteJsMethodMessage value) clientControlsActions.ExecuteJsMethod(executeJsMethod); } - + /// - /// Converts a to a + /// Converts a to a /// /// /// @@ -65,14 +63,14 @@ protected override void Execute(ExecuteJsMethodMessage value) /// private static void JsonElementToJsValue(ref JsValue jsValue, JsonElement element) { - switch(jsValue.Type) + switch (jsValue.Type) { case JsValueType.Null: break; case JsValueType.Object: //Objects use type JsObjectHolder JsObjectHolder objectHolder = - (JsObjectHolder) element.Deserialize(typeof(JsObjectHolder), SourceGenerationContext.Default)!; + (JsObjectHolder)element.Deserialize(typeof(JsObjectHolder), SourceGenerationContext.Default)!; foreach (JsObjectKeyValue jsKey in objectHolder.Keys) { JsValue value = jsKey.Value; @@ -82,6 +80,7 @@ private static void JsonElementToJsValue(ref JsValue jsValue, JsonElement elemen jsKey.Value = value; } } + jsValue.Value = objectHolder; break; case JsValueType.Bool: @@ -108,12 +107,12 @@ private static void JsonElementToJsValue(ref JsValue jsValue, JsonElement elemen } #region Message - + /// /// Name of the method to execute /// public string MethodName { get; set; } - + /// /// All provided arguments /// diff --git a/src/UnityWebBrowser.Engine.Cef/Browser/Js/UwbCefJsMethodHandler.cs b/src/UnityWebBrowser.Engine.Cef/Shared/Browser/Js/UwbCefJsMethodHandler.cs similarity index 95% rename from src/UnityWebBrowser.Engine.Cef/Browser/Js/UwbCefJsMethodHandler.cs rename to src/UnityWebBrowser.Engine.Cef/Shared/Browser/Js/UwbCefJsMethodHandler.cs index 4477576b..88caedb6 100644 --- a/src/UnityWebBrowser.Engine.Cef/Browser/Js/UwbCefJsMethodHandler.cs +++ b/src/UnityWebBrowser.Engine.Cef/Shared/Browser/Js/UwbCefJsMethodHandler.cs @@ -7,16 +7,17 @@ using VoltstroStudios.UnityWebBrowser.Shared.Js; using Xilium.CefGlue; -namespace UnityWebBrowser.Engine.Cef.Browser.Js; +namespace UnityWebBrowser.Engine.Cef.Shared.Browser.Js; /// -/// for uwbExecuteMethod +/// for uwbExecuteMethod /// internal class UwbCefJsMethodHandler : CefV8Handler { public const string ExecuteJsMethodsFunctionName = "ExecuteJsMethod"; - - protected override bool Execute(string name, CefV8Value obj, CefV8Value[] arguments, out CefV8Value returnValue, out string exception) + + protected override bool Execute(string name, CefV8Value obj, CefV8Value[] arguments, out CefV8Value returnValue, + out string exception) { if (name == ExecuteJsMethodsFunctionName && arguments.Length > 0) { @@ -64,7 +65,7 @@ protected override bool Execute(string name, CefV8Value obj, CefV8Value[] argume return true; } } - + returnValue = null; exception = null; return false; @@ -74,14 +75,12 @@ private static JsValue ReadCefValueToJsValue(CefV8Value cefValue) { object value = null; JsValueType type = JsValueType.Null; - + //Ensure value is not a promise, function, array buffer. //TODO: Support arrays? if (cefValue.IsPromise || cefValue.IsFunction || cefValue.IsArrayBuffer || cefValue.IsArray) - { throw new InvalidValueTypeException("Value cannot be a promise, function, an array or an array buffer!"); - } - + if (cefValue.IsNull || cefValue.IsUndefined) { value = null; @@ -97,7 +96,7 @@ private static JsValue ReadCefValueToJsValue(CefV8Value cefValue) string key = keys[i]; values[i] = new JsObjectKeyValue(key, ReadCefValueToJsValue(cefValue.GetValue(key))); } - + //Custom objects are held by a JsObjectHolder JsObjectHolder objectHolder = new(values); @@ -132,7 +131,7 @@ private static JsValue ReadCefValueToJsValue(CefV8Value cefValue) else if (cefValue.IsDate) { CefBaseTime time = cefValue.GetDateValue(); - + //Time logic from CefSharp: //https://github.com/cefsharp/CefSharp/blob/bbe7260fe8d0fa4507cf0e36dea36ffe63b35f91/CefSharp/Internals/BaseTimeConverter.cs const long maxFileTime = 2650467743999999999; @@ -156,7 +155,7 @@ private static JsValue ReadCefValueToJsValue(CefV8Value cefValue) value = DateTime.FromFileTimeUtc(fileTime); } } - + type = JsValueType.Date; } diff --git a/src/UnityWebBrowser.Engine.Cef/Browser/Messages/IMessageBase.cs b/src/UnityWebBrowser.Engine.Cef/Shared/Browser/Messages/IMessageBase.cs similarity index 71% rename from src/UnityWebBrowser.Engine.Cef/Browser/Messages/IMessageBase.cs rename to src/UnityWebBrowser.Engine.Cef/Shared/Browser/Messages/IMessageBase.cs index 9a4b65ab..0f6827eb 100644 --- a/src/UnityWebBrowser.Engine.Cef/Browser/Messages/IMessageBase.cs +++ b/src/UnityWebBrowser.Engine.Cef/Shared/Browser/Messages/IMessageBase.cs @@ -3,14 +3,14 @@ // // This project is under the MIT license. See the LICENSE.md file for more details. -namespace UnityWebBrowser.Engine.Cef.Browser.Messages; +namespace UnityWebBrowser.Engine.Cef.Shared.Browser.Messages; /// -/// Base interface for +/// Base interface for /// public interface IMessageBase { public object Deserialize(string value); - + public void Execute(object value); } \ No newline at end of file diff --git a/src/UnityWebBrowser.Engine.Cef/Browser/Messages/MessageBase.cs b/src/UnityWebBrowser.Engine.Cef/Shared/Browser/Messages/MessageBase.cs similarity index 83% rename from src/UnityWebBrowser.Engine.Cef/Browser/Messages/MessageBase.cs rename to src/UnityWebBrowser.Engine.Cef/Shared/Browser/Messages/MessageBase.cs index 251f5178..f0e75990 100644 --- a/src/UnityWebBrowser.Engine.Cef/Browser/Messages/MessageBase.cs +++ b/src/UnityWebBrowser.Engine.Cef/Shared/Browser/Messages/MessageBase.cs @@ -7,20 +7,14 @@ using System.Text.Json.Serialization; using Xilium.CefGlue; -namespace UnityWebBrowser.Engine.Cef.Browser.Messages; +namespace UnityWebBrowser.Engine.Cef.Shared.Browser.Messages; /// /// Base class for a message that needs to be transmitted /// public abstract class MessageBase : IMessageBase { - [JsonIgnore] - public abstract string MessageName { get; } - - public string Serialize(object obj) - { - return JsonSerializer.Serialize(obj, typeof(T), SourceGenerationContext.Default); - } + [JsonIgnore] public abstract string MessageName { get; } public object Deserialize(string value) { @@ -32,13 +26,19 @@ public void Execute(object value) Execute((T)value); } + public string Serialize(object obj) + { + return JsonSerializer.Serialize(obj, typeof(T), SourceGenerationContext.Default); + } + /// /// Sends the message to the browser process /// public void SendMessage() { CefBrowser browser = CefV8Context.GetCurrentContext().GetBrowser(); - browser!.GetMainFrame()!.SendProcessMessage(CefProcessId.Browser, CefProcessMessage.Create($"{MessageName}: {Serialize(this)}")); + browser!.GetMainFrame()!.SendProcessMessage(CefProcessId.Browser, + CefProcessMessage.Create($"{MessageName}: {Serialize(this)}")); } protected abstract void Execute(T value); diff --git a/src/UnityWebBrowser.Engine.Cef/Browser/Messages/SourceGenerationContext.cs b/src/UnityWebBrowser.Engine.Cef/Shared/Browser/Messages/SourceGenerationContext.cs similarity index 87% rename from src/UnityWebBrowser.Engine.Cef/Browser/Messages/SourceGenerationContext.cs rename to src/UnityWebBrowser.Engine.Cef/Shared/Browser/Messages/SourceGenerationContext.cs index 8ecfbd2a..59cef233 100644 --- a/src/UnityWebBrowser.Engine.Cef/Browser/Messages/SourceGenerationContext.cs +++ b/src/UnityWebBrowser.Engine.Cef/Shared/Browser/Messages/SourceGenerationContext.cs @@ -5,10 +5,10 @@ using System; using System.Text.Json.Serialization; -using UnityWebBrowser.Engine.Cef.Browser.Js; +using UnityWebBrowser.Engine.Cef.Shared.Browser.Js; using VoltstroStudios.UnityWebBrowser.Shared.Js; -namespace UnityWebBrowser.Engine.Cef.Browser.Messages; +namespace UnityWebBrowser.Engine.Cef.Shared.Browser.Messages; [JsonSourceGenerationOptions(WriteIndented = false)] [JsonSerializable(typeof(ExecuteJsMethodMessage))] diff --git a/src/UnityWebBrowser.Engine.Cef/Browser/Popups/UwbCefEnginePopupInfo.cs b/src/UnityWebBrowser.Engine.Cef/Shared/Browser/Popups/UwbCefEnginePopupInfo.cs similarity index 84% rename from src/UnityWebBrowser.Engine.Cef/Browser/Popups/UwbCefEnginePopupInfo.cs rename to src/UnityWebBrowser.Engine.Cef/Shared/Browser/Popups/UwbCefEnginePopupInfo.cs index 549c7a56..10abad5c 100644 --- a/src/UnityWebBrowser.Engine.Cef/Browser/Popups/UwbCefEnginePopupInfo.cs +++ b/src/UnityWebBrowser.Engine.Cef/Shared/Browser/Popups/UwbCefEnginePopupInfo.cs @@ -9,18 +9,18 @@ using VoltstroStudios.UnityWebBrowser.Shared.Popups; using Xilium.CefGlue; -namespace UnityWebBrowser.Engine.Cef.Browser.Popups; +namespace UnityWebBrowser.Engine.Cef.Shared.Browser.Popups; /// -/// Cef implementation of +/// Cef implementation of /// public class UwbCefEnginePopupInfo : EnginePopupInfo { - private readonly EnginePopupManager popupManager; private readonly UwbCefPopupClient popupClient; - + private readonly EnginePopupManager popupManager; + /// - /// Creates a new + /// Creates a new /// /// /// @@ -32,7 +32,7 @@ public UwbCefEnginePopupInfo(EnginePopupManager popupManager, ProxySettings prox popupClient = new UwbCefPopupClient(proxySettings, DisposeNoClose); client = popupClient; } - + public override void ExecuteJs(string js) { popupClient.ExecuteJs(js); @@ -42,7 +42,7 @@ public override void Dispose() { if (!CefRuntime.CurrentlyOn(CefThreadId.UI)) { - CefEngineControlsManager.PostTask(CefThreadId.UI, Dispose); + CefActionTask.PostTask(CefThreadId.UI, Dispose); return; } diff --git a/src/UnityWebBrowser.Engine.Cef/Browser/Popups/UwbCefPopupClient.cs b/src/UnityWebBrowser.Engine.Cef/Shared/Browser/Popups/UwbCefPopupClient.cs similarity index 80% rename from src/UnityWebBrowser.Engine.Cef/Browser/Popups/UwbCefPopupClient.cs rename to src/UnityWebBrowser.Engine.Cef/Shared/Browser/Popups/UwbCefPopupClient.cs index bef426ed..c0c2b552 100644 --- a/src/UnityWebBrowser.Engine.Cef/Browser/Popups/UwbCefPopupClient.cs +++ b/src/UnityWebBrowser.Engine.Cef/Shared/Browser/Popups/UwbCefPopupClient.cs @@ -7,18 +7,18 @@ using VoltstroStudios.UnityWebBrowser.Shared; using Xilium.CefGlue; -namespace UnityWebBrowser.Engine.Cef.Browser.Popups; +namespace UnityWebBrowser.Engine.Cef.Shared.Browser.Popups; /// -/// A that is for popups +/// A that is for popups /// public class UwbCefPopupClient : CefClient { - private readonly UwbCefRequestHandler requestHandler; private readonly UwbCefPopupLifeSpanHandler lifeSpanHandler; + private readonly UwbCefRequestHandler requestHandler; /// - /// Creates a new instance + /// Creates a new instance /// /// /// @@ -29,7 +29,7 @@ public UwbCefPopupClient(ProxySettings proxySettings, Action onShutdown) } /// - /// Closes this + /// Closes this /// public void Close() { @@ -37,13 +37,13 @@ public void Close() } /// - /// Executes js in this + /// Executes js in this /// public void ExecuteJs(string js) { lifeSpanHandler.ExecuteJs(js); } - + protected override CefRequestHandler GetRequestHandler() { return requestHandler; diff --git a/src/UnityWebBrowser.Engine.Cef/Browser/Popups/UwbCefPopupLifeSpanHandler.cs b/src/UnityWebBrowser.Engine.Cef/Shared/Browser/Popups/UwbCefPopupLifeSpanHandler.cs similarity index 90% rename from src/UnityWebBrowser.Engine.Cef/Browser/Popups/UwbCefPopupLifeSpanHandler.cs rename to src/UnityWebBrowser.Engine.Cef/Shared/Browser/Popups/UwbCefPopupLifeSpanHandler.cs index 98bfcbf9..c6dd8498 100644 --- a/src/UnityWebBrowser.Engine.Cef/Browser/Popups/UwbCefPopupLifeSpanHandler.cs +++ b/src/UnityWebBrowser.Engine.Cef/Shared/Browser/Popups/UwbCefPopupLifeSpanHandler.cs @@ -7,15 +7,18 @@ using UnityWebBrowser.Engine.Cef.Core; using Xilium.CefGlue; -namespace UnityWebBrowser.Engine.Cef.Browser.Popups; +namespace UnityWebBrowser.Engine.Cef.Shared.Browser.Popups; /// -/// for a popup +/// for a popup /// public class UwbCefPopupLifeSpanHandler : CefLifeSpanHandler { + private readonly Action onShutdown; + private CefBrowser cefBrowser; + /// - /// Creates a new instance + /// Creates a new instance /// /// public UwbCefPopupLifeSpanHandler(Action onShutdown) @@ -23,9 +26,6 @@ public UwbCefPopupLifeSpanHandler(Action onShutdown) this.onShutdown = onShutdown; } - private readonly Action onShutdown; - private CefBrowser cefBrowser; - /// /// Closes the popup /// @@ -42,14 +42,14 @@ public void ExecuteJs(string js) { cefBrowser?.GetMainFrame()?.ExecuteJavaScript(js, "", 0); } - + protected override void OnAfterCreated(CefBrowser browser) { cefBrowser = browser; } protected override void OnBeforeClose(CefBrowser browser) - { + { CefLoggerWrapper.Debug("Closing popup..."); onShutdown.Invoke(); } diff --git a/src/UnityWebBrowser.Engine.Cef/Browser/Schemes/PageResourceScheme.cs b/src/UnityWebBrowser.Engine.Cef/Shared/Browser/Schemes/PageResourceScheme.cs similarity index 93% rename from src/UnityWebBrowser.Engine.Cef/Browser/Schemes/PageResourceScheme.cs rename to src/UnityWebBrowser.Engine.Cef/Shared/Browser/Schemes/PageResourceScheme.cs index 248f5f99..053de5f5 100644 --- a/src/UnityWebBrowser.Engine.Cef/Browser/Schemes/PageResourceScheme.cs +++ b/src/UnityWebBrowser.Engine.Cef/Shared/Browser/Schemes/PageResourceScheme.cs @@ -7,7 +7,7 @@ using System.IO; using Xilium.CefGlue; -namespace UnityWebBrowser.Engine.Cef.Browser.Schemes; +namespace UnityWebBrowser.Engine.Cef.Shared.Browser.Schemes; public sealed class PageResourceScheme : CefSchemeHandlerFactory, IDisposable { diff --git a/src/UnityWebBrowser.Engine.Cef/Browser/StreamCefResourceHandler.cs b/src/UnityWebBrowser.Engine.Cef/Shared/Browser/StreamCefResourceHandler.cs similarity index 93% rename from src/UnityWebBrowser.Engine.Cef/Browser/StreamCefResourceHandler.cs rename to src/UnityWebBrowser.Engine.Cef/Shared/Browser/StreamCefResourceHandler.cs index 642a705b..64255267 100644 --- a/src/UnityWebBrowser.Engine.Cef/Browser/StreamCefResourceHandler.cs +++ b/src/UnityWebBrowser.Engine.Cef/Shared/Browser/StreamCefResourceHandler.cs @@ -12,7 +12,7 @@ //From: https://github.com/chromelyapps/Chromely/blob/989d74141aabb8d874b2ad9b75757f56f3e6fdba/src_5.2/Chromely/Browser/Handlers/ResourceHandler.cs #nullable enable -namespace UnityWebBrowser.Engine.Cef.Browser; +namespace UnityWebBrowser.Engine.Cef.Shared.Browser; /// /// Default implementation of . This latest implementation provides some @@ -150,7 +150,7 @@ public static byte[] GetByteArray(string text, Encoding encoding, bool includePr byte[] preamble = encoding.GetPreamble(); byte[] bytes = encoding.GetBytes(text); - MemoryStream memoryStream = new MemoryStream(preamble.Length + bytes.Length); + MemoryStream memoryStream = new(preamble.Length + bytes.Length); memoryStream.Write(preamble, 0, preamble.Length); memoryStream.Write(bytes, 0, bytes.Length); @@ -176,7 +176,7 @@ public virtual void Dispose() protected override bool Open(CefRequest request, out bool handleRequest, CefCallback callback) { - CefLoggerWrapper.Debug($"{CefLoggerWrapper.FullCefMessageTag} Stream Cef Resource Handler Open() called."); + CefLoggerWrapper.Debug("Stream Cef Resource Handler Open() called."); CefReturnValue processRequest = ProcessRequestAsync(request, callback); //Process the request in an async fashion @@ -202,8 +202,7 @@ protected override bool Open(CefRequest request, out bool handleRequest, CefCall protected override void GetResponseHeaders(CefResponse response, out long responseLength, out string redirectUrl) { - CefLoggerWrapper.Debug( - $"{CefLoggerWrapper.FullCefMessageTag} Stream Cef Resource Handler GetResponseHeaders() called."); + CefLoggerWrapper.Debug("Stream Cef Resource Handler GetResponseHeaders() called."); redirectUrl = string.Empty; responseLength = -1; @@ -231,7 +230,7 @@ protected override void GetResponseHeaders(CefResponse response, out long respon protected override bool Skip(long bytesToSkip, out long bytesSkipped, CefResourceSkipCallback callback) { - CefLoggerWrapper.Debug($"{CefLoggerWrapper.FullCefMessageTag} Stream Cef Resource Handler Skip() called."); + CefLoggerWrapper.Debug("Stream Cef Resource Handler Skip() called."); //No Stream or Stream cannot seek then we indicate failure if (Stream is null || !Stream.CanSeek) { @@ -249,9 +248,10 @@ protected override bool Skip(long bytesToSkip, out long bytesSkipped, CefResourc return true; } - protected override bool Read(Stream dataStream, int bytesToRead, out int bytesRead, CefResourceReadCallback callback) + protected override bool Read(Stream dataStream, int bytesToRead, out int bytesRead, + CefResourceReadCallback callback) { - CefLoggerWrapper.Debug($"{CefLoggerWrapper.FullCefMessageTag} Stream Cef Resource Handler Read() called."); + CefLoggerWrapper.Debug(" Stream Cef Resource Handler Read() called."); bytesRead = 0; //We don't need the callback, as it's an unmanaged resource we should dispose it (could wrap it in a using statement). @@ -268,7 +268,7 @@ protected override bool Read(Stream dataStream, int bytesToRead, out int bytesRe // To indicate response completion set bytesRead to 0 and return false if (bytesRead == 0) return false; - + dataStream.Write(tempBuffer, 0, bytesRead); return bytesRead > 0; diff --git a/src/UnityWebBrowser.Engine.Cef/Browser/UwbCefApp.cs b/src/UnityWebBrowser.Engine.Cef/Shared/Browser/UwbCefApp.cs similarity index 69% rename from src/UnityWebBrowser.Engine.Cef/Browser/UwbCefApp.cs rename to src/UnityWebBrowser.Engine.Cef/Shared/Browser/UwbCefApp.cs index 2a3b8875..48f54086 100644 --- a/src/UnityWebBrowser.Engine.Cef/Browser/UwbCefApp.cs +++ b/src/UnityWebBrowser.Engine.Cef/Shared/Browser/UwbCefApp.cs @@ -3,26 +3,29 @@ // // This project is under the MIT license. See the LICENSE.md file for more details. -using UnityWebBrowser.Engine.Cef.Core; using VoltstroStudios.UnityWebBrowser.Engine.Shared.Core; using Xilium.CefGlue; -namespace UnityWebBrowser.Engine.Cef.Browser; +namespace UnityWebBrowser.Engine.Cef.Shared.Browser; /// /// for CefBrowserProcess /// -internal class UwbCefApp : CefApp +public class UwbCefApp : CefApp { private readonly bool mediaStreamingEnabled; private readonly bool noProxyServer; - + private readonly bool remoteDebugging; + private readonly string[] remoteDebuggingOrigins; + private UwbCefBrowserProcessHandler browserProcessHandler; - internal UwbCefApp(LaunchArguments launchArguments) + public UwbCefApp(LaunchArguments launchArguments) { mediaStreamingEnabled = launchArguments.WebRtc; noProxyServer = !launchArguments.ProxyEnabled; + remoteDebugging = launchArguments.RemoteDebugging != 0; + remoteDebuggingOrigins = launchArguments.RemoteDebuggingAllowedOrigins; } protected override void OnBeforeCommandLineProcessing(string processType, CefCommandLine commandLine) @@ -33,9 +36,16 @@ protected override void OnBeforeCommandLineProcessing(string processType, CefCom if (mediaStreamingEnabled && !commandLine.HasSwitch("--enable-media-stream")) commandLine.AppendSwitch("--enable-media-stream"); + if (remoteDebugging && !commandLine.HasSwitch("--remote-allow-origins")) + commandLine.AppendSwitch("--remote-allow-origins", string.Join(',', remoteDebuggingOrigins)); + #if LINUX || MACOS if (!commandLine.HasSwitch("--no-zygote")) commandLine.AppendSwitch("--no-zygote"); #endif + +#if MACOS + if (!commandLine.HasSwitch("--use-mock-keychain")) commandLine.AppendSwitch("--use-mock-keychain"); +#endif } protected override CefBrowserProcessHandler GetBrowserProcessHandler() diff --git a/src/UnityWebBrowser.Engine.Cef/Browser/UwbCefBrowserProcessHandler.cs b/src/UnityWebBrowser.Engine.Cef/Shared/Browser/UwbCefBrowserProcessHandler.cs similarity index 87% rename from src/UnityWebBrowser.Engine.Cef/Browser/UwbCefBrowserProcessHandler.cs rename to src/UnityWebBrowser.Engine.Cef/Shared/Browser/UwbCefBrowserProcessHandler.cs index 4dd843fd..519e4a30 100644 --- a/src/UnityWebBrowser.Engine.Cef/Browser/UwbCefBrowserProcessHandler.cs +++ b/src/UnityWebBrowser.Engine.Cef/Shared/Browser/UwbCefBrowserProcessHandler.cs @@ -4,11 +4,11 @@ // This project is under the MIT license. See the LICENSE.md file for more details. using System; -using UnityWebBrowser.Engine.Cef.Browser.Schemes; +using UnityWebBrowser.Engine.Cef.Shared.Browser.Schemes; using VoltstroStudios.UnityWebBrowser.Engine.Shared.Pages; using Xilium.CefGlue; -namespace UnityWebBrowser.Engine.Cef.Browser; +namespace UnityWebBrowser.Engine.Cef.Shared.Browser; public class UwbCefBrowserProcessHandler : CefBrowserProcessHandler, IDisposable { diff --git a/src/UnityWebBrowser.Engine.Cef/Browser/UwbCefClient.cs b/src/UnityWebBrowser.Engine.Cef/Shared/Browser/UwbCefClient.cs similarity index 57% rename from src/UnityWebBrowser.Engine.Cef/Browser/UwbCefClient.cs rename to src/UnityWebBrowser.Engine.Cef/Shared/Browser/UwbCefClient.cs index 16d4bf21..e4df2402 100644 --- a/src/UnityWebBrowser.Engine.Cef/Browser/UwbCefClient.cs +++ b/src/UnityWebBrowser.Engine.Cef/Shared/Browser/UwbCefClient.cs @@ -7,18 +7,18 @@ using System.Collections.Generic; using System.Numerics; using System.Runtime.CompilerServices; -using UnityWebBrowser.Engine.Cef.Browser.Js; -using UnityWebBrowser.Engine.Cef.Browser.Messages; -using UnityWebBrowser.Engine.Cef.Browser.Popups; +using Microsoft.Extensions.Logging; +using UnityWebBrowser.Engine.Cef.Shared.Browser.Js; +using UnityWebBrowser.Engine.Cef.Shared.Browser.Messages; +using UnityWebBrowser.Engine.Cef.Shared.Browser.Popups; using VoltstroStudios.UnityWebBrowser.Engine.Shared.Core; -using VoltstroStudios.UnityWebBrowser.Engine.Shared.Core.Logging; using VoltstroStudios.UnityWebBrowser.Engine.Shared.Popups; using VoltstroStudios.UnityWebBrowser.Shared; using VoltstroStudios.UnityWebBrowser.Shared.Events; using VoltstroStudios.UnityWebBrowser.Shared.Popups; using Xilium.CefGlue; -namespace UnityWebBrowser.Engine.Cef.Browser; +namespace UnityWebBrowser.Engine.Cef.Shared.Browser; /// /// Offscreen CEF @@ -32,28 +32,42 @@ internal class UwbCefClient : CefClient, IDisposable private readonly UwbCefLifespanHandler lifespanHandler; private readonly UwbCefLoadHandler loadHandler; - private readonly UwbCefRenderHandler renderHandler; - private readonly UwbCefRequestHandler requestHandler; + + private readonly ILogger mainLogger; private readonly ProxySettings proxySettings; + private readonly UwbCefRenderHandler renderHandler; + private readonly UwbCefRequestHandler requestHandler; private CefBrowser browser; private CefBrowserHost browserHost; + private CefBrowserSettings devToolsBrowserSettings; + private UwbCefPopupClient devToolsClient; //Dev Tools private CefWindowInfo devToolsWindowInfo; - private UwbCefPopupClient devToolsClient; - private CefBrowserSettings devToolsBrowserSettings; + + //State of mouse click events that needs to be persisted for dragging + private CefEventFlags modifiers = CefEventFlags.None; /// /// Creates a new instance /// - public UwbCefClient(CefSize size, PopupAction popupAction, EnginePopupManager popupManager, ProxySettings proxySettings, ClientControlsActions clientControlsActions) + public UwbCefClient( + CefSize size, + PopupAction popupAction, + EnginePopupManager popupManager, + ProxySettings proxySettings, + ClientControlsActions clientControlsActions, + ILogger mainLogger, + ILogger browserConsoleLogger) { ClientControls = clientControlsActions; this.proxySettings = proxySettings; + this.mainLogger = mainLogger; + //Setup our handlers loadHandler = new UwbCefLoadHandler(this); renderHandler = new UwbCefRenderHandler(this, size); @@ -63,7 +77,7 @@ public UwbCefClient(CefSize size, PopupAction popupAction, EnginePopupManager po browser = cefBrowser; browserHost = cefBrowser.GetHost(); }; - displayHandler = new UwbCefDisplayHandler(this); + displayHandler = new UwbCefDisplayHandler(this, mainLogger, browserConsoleLogger); requestHandler = new UwbCefRequestHandler(proxySettings); contextMenuHandler = new UwbCefContextMenuHandler(); @@ -132,46 +146,103 @@ protected override CefContextMenuHandler GetContextMenuHandler() /// public void ProcessKeyboardEvent(KeyboardEvent keyboardEvent) { + UpdateModifiersWithKeyboard(keyboardEvent); + //Keys down - foreach (WindowsKey i in keyboardEvent.KeysDown) - KeyEvent(new CefKeyEvent + foreach (WindowsKey key in keyboardEvent.KeysDown) + { + CefKeyEvent keyEvent = new() { - WindowsKeyCode = (int) i, - EventType = CefKeyEventType.KeyDown - }); + WindowsKeyCode = (int)key, + EventType = CefKeyEventType.KeyDown, + Modifiers = modifiers | UwbCefClientUtils.GetKeyDirection(key) + }; + + browserHost.SendKeyEvent(keyEvent); + } //Keys up - foreach (WindowsKey i in keyboardEvent.KeysUp) - KeyEvent(new CefKeyEvent + foreach (WindowsKey key in keyboardEvent.KeysUp) + { + CefKeyEvent keyEvent = new() { - WindowsKeyCode = (int) i, - EventType = CefKeyEventType.KeyUp - }); + WindowsKeyCode = (int)key, + EventType = CefKeyEventType.KeyUp, + Modifiers = modifiers | UwbCefClientUtils.GetKeyDirection(key) + }; + + browserHost.SendKeyEvent(keyEvent); + } //Chars foreach (char c in keyboardEvent.Chars) - KeyEvent(new CefKeyEvent + { + CefKeyEvent keyEvent = new() { -#if WINDOWS WindowsKeyCode = c, -#else Character = c, -#endif - EventType = CefKeyEventType.Char - }); + EventType = CefKeyEventType.Char, + Modifiers = modifiers + }; + + browserHost.SendKeyEvent(keyEvent); + } + } + + private void UpdateModifiersWithMouse(MouseClickEvent mouseClickEvent) + { + CefEventFlags flag = mouseClickEvent.MouseClickType switch + { + MouseClickType.Left => CefEventFlags.LeftMouseButton, + MouseClickType.Right => CefEventFlags.RightMouseButton, + MouseClickType.Middle => CefEventFlags.MiddleMouseButton, + _ => throw new ArgumentException("Click event must be one of 3 states") + }; + + if (mouseClickEvent.MouseEventType == MouseEventType.Up) + modifiers &= ~flag; + else + modifiers |= flag; + } + + private void UpdateModifiersWithKeyboard(KeyboardEvent keyboardEvent) + { + foreach (WindowsKey key in keyboardEvent.KeysDown) + { + CefEventFlags flag = UwbCefClientUtils.KeyToFlag(key); + + if ((key is WindowsKey.CapsLock && (modifiers & CefEventFlags.CapsLockOn) != CefEventFlags.None) + || (key is WindowsKey.NumLock && (modifiers & CefEventFlags.NumLockOn) != CefEventFlags.None)) + modifiers &= ~flag; + else + modifiers |= flag; + } + + foreach (WindowsKey key in keyboardEvent.KeysUp) + { + CefEventFlags flag = UwbCefClientUtils.KeyToFlag(key); + + if (key is WindowsKey.CapsLock or WindowsKey.NumLock) + return; + + modifiers &= ~flag; + } } /// /// Process a /// - /// - public void ProcessMouseMoveEvent(MouseMoveEvent mouseEvent) + /// + public void ProcessMouseMoveEvent(MouseMoveEvent mouseMoveEvent) { - MouseMoveEvent(new CefMouseEvent + CefMouseEvent mouseEvent = new CefMouseEvent { - X = mouseEvent.MouseX, - Y = mouseEvent.MouseY - }); + X = mouseMoveEvent.MouseX, + Y = mouseMoveEvent.MouseY, + Modifiers = modifiers + }; + + browserHost.SendMouseMoveEvent(mouseEvent, false); } /// @@ -180,13 +251,20 @@ public void ProcessMouseMoveEvent(MouseMoveEvent mouseEvent) /// public void ProcessMouseClickEvent(MouseClickEvent mouseClickEvent) { - MouseClickEvent(new CefMouseEvent - { - X = mouseClickEvent.MouseX, - Y = mouseClickEvent.MouseY - }, mouseClickEvent.MouseClickCount, - (CefMouseButtonType) mouseClickEvent.MouseClickType, - mouseClickEvent.MouseEventType == MouseEventType.Up); + UpdateModifiersWithMouse(mouseClickEvent); + + CefMouseEvent mouseEvent = new() + { + X = mouseClickEvent.MouseX, + Y = mouseClickEvent.MouseY, + Modifiers = modifiers + }; + + browserHost.SendMouseClickEvent( + mouseEvent, + (CefMouseButtonType)mouseClickEvent.MouseClickType, + mouseClickEvent.MouseEventType == MouseEventType.Up, + mouseClickEvent.MouseClickCount); } /// @@ -195,63 +273,73 @@ public void ProcessMouseClickEvent(MouseClickEvent mouseClickEvent) /// public void ProcessMouseScrollEvent(MouseScrollEvent mouseScrollEvent) { - MouseScrollEvent(new CefMouseEvent + CefMouseEvent mouseEvent = new() { X = mouseScrollEvent.MouseX, - Y = mouseScrollEvent.MouseY - }, mouseScrollEvent.MouseScroll); - } - - private void KeyEvent(CefKeyEvent keyEvent) - { - browserHost.SendKeyEvent(keyEvent); - } - - private void MouseMoveEvent(CefMouseEvent mouseEvent) - { - browserHost.SendMouseMoveEvent(mouseEvent, false); - } - - private void MouseClickEvent(CefMouseEvent mouseEvent, int clickCount, CefMouseButtonType button, bool mouseUp) - { - browserHost.SendMouseClickEvent(mouseEvent, button, mouseUp, clickCount); - } - - private void MouseScrollEvent(CefMouseEvent mouseEvent, int scroll) - { - browserHost.SendMouseWheelEvent(mouseEvent, 0, scroll); + Y = mouseScrollEvent.MouseY, + Modifiers = modifiers + }; + + browserHost.SendMouseWheelEvent(mouseEvent, 0, mouseScrollEvent.MouseScroll); } - + + /// + /// Load a URL + /// + /// public void LoadUrl(string url) { browser.GetMainFrame()?.LoadUrl(url); } + /// + /// Gets current mouse scroll position + /// + /// public Vector2 GetMouseScrollPosition() { return renderHandler.MouseScrollPosition; } + /// + /// Loads HTML content + /// + /// public void LoadHtml(string html) { browser.GetMainFrame()?.LoadUrl($"data:text/html,{html}"); } + /// + /// Executes JS + /// + /// public void ExecuteJs(string js) { browser.GetMainFrame()?.ExecuteJavaScript(js, "", 0); } + /// + /// Sets a zoom level + /// + /// public void SetZoomLevel(double zoomLevel) { browserHost.SetZoomLevel(zoomLevel); } + /// + /// Gets current zoom level + /// + /// public double GetZoomLevel() { return browserHost.GetZoomLevel(); } + /// + /// Opens DevTools window + /// public void OpenDevTools() { try @@ -272,30 +360,43 @@ public void OpenDevTools() } catch (Exception ex) { - Logger.Error(ex, "An error occured while trying to open the dev tools!"); + mainLogger.LogError(ex, "An error occured while trying to open the dev tools!"); } } + /// + /// Goes back a page + /// public void GoBack() { if (browser.CanGoBack) browser.GoBack(); } + /// + /// Goes forward a page + /// public void GoForward() { if (browser.CanGoForward) browser.GoForward(); } + /// + /// Refreshes current page + /// public void Refresh() { browser.Reload(); } + /// + /// Resizes render window to a new resolution + /// + /// public void Resize(Resolution resolution) { - renderHandler.Resize(new CefSize((int) resolution.Width, (int) resolution.Height)); + renderHandler.Resize(new CefSize((int)resolution.Width, (int)resolution.Height)); browserHost.WasResized(); } @@ -304,7 +405,7 @@ public void Resize(Resolution resolution) #region Messages private readonly Dictionary messageTypes; - + protected override bool OnProcessMessageReceived(CefBrowser browser, CefFrame frame, CefProcessId sourceProcess, CefProcessMessage message) { @@ -316,23 +417,21 @@ protected override bool OnProcessMessageReceived(CefBrowser browser, CefFrame fr string messageType = message.Name[..index]; string messageValue = message.Name[(index + 2)..]; - - Logger.Debug($"Received message of type {messageType}: {messageValue}"); + + mainLogger.LogDebug($"Received message of type {messageType}: {messageValue}"); foreach (KeyValuePair messageBase in messageTypes) - { if (messageBase.Key == messageType) { object value = messageBase.Value.Deserialize(messageValue); messageBase.Value.Execute(value); } - } } catch (Exception ex) { - Logger.Error(ex, "Error handling message received!"); + mainLogger.LogError(ex, "Error handling message received!"); } - + return false; } diff --git a/src/UnityWebBrowser.Engine.Cef/Shared/Browser/UwbCefClientUtils.cs b/src/UnityWebBrowser.Engine.Cef/Shared/Browser/UwbCefClientUtils.cs new file mode 100644 index 00000000..06dd3c15 --- /dev/null +++ b/src/UnityWebBrowser.Engine.Cef/Shared/Browser/UwbCefClientUtils.cs @@ -0,0 +1,44 @@ +// UnityWebBrowser (UWB) +// Copyright (c) 2021-2024 Voltstro-Studios +// +// This project is under the MIT license.See the LICENSE.md file for more details. + +using VoltstroStudios.UnityWebBrowser.Shared; +using Xilium.CefGlue; + +namespace UnityWebBrowser.Engine.Cef.Shared.Browser; + +internal static class UwbCefClientUtils +{ + public static CefEventFlags GetKeyDirection(WindowsKey key) => key switch + { + WindowsKey.LShiftKey | WindowsKey.LControlKey | WindowsKey.LMenu => CefEventFlags.IsLeft, + WindowsKey.RShiftKey | WindowsKey.RControlKey | WindowsKey.RMenu => CefEventFlags.ShiftDown, + _ => CefEventFlags.None + }; + + public static CefEventFlags KeyToFlag(WindowsKey key) => key switch + { + // Stateful keys + WindowsKey.CapsLock => CefEventFlags.CapsLockOn, + WindowsKey.NumLock => CefEventFlags.NumLockOn, + + WindowsKey.Shift => CefEventFlags.ShiftDown, + WindowsKey.ShiftKey => CefEventFlags.ShiftDown, + WindowsKey.LShiftKey => CefEventFlags.ShiftDown, + WindowsKey.RShiftKey => CefEventFlags.ShiftDown, + + WindowsKey.Control => CefEventFlags.ControlDown, + WindowsKey.ControlKey => CefEventFlags.ControlDown, + WindowsKey.LControlKey => CefEventFlags.ControlDown, + WindowsKey.RControlKey => CefEventFlags.ControlDown, + + WindowsKey.Alt => CefEventFlags.AltGrDown, + WindowsKey.Menu => CefEventFlags.AltDown, + WindowsKey.LMenu => CefEventFlags.AltDown, + WindowsKey.RMenu => CefEventFlags.AltDown, + // No support for command + + _ => CefEventFlags.None + }; +} \ No newline at end of file diff --git a/src/UnityWebBrowser.Engine.Cef/Browser/UwbCefContextMenuHandler.cs b/src/UnityWebBrowser.Engine.Cef/Shared/Browser/UwbCefContextMenuHandler.cs similarity index 89% rename from src/UnityWebBrowser.Engine.Cef/Browser/UwbCefContextMenuHandler.cs rename to src/UnityWebBrowser.Engine.Cef/Shared/Browser/UwbCefContextMenuHandler.cs index 1a172766..42122caa 100644 --- a/src/UnityWebBrowser.Engine.Cef/Browser/UwbCefContextMenuHandler.cs +++ b/src/UnityWebBrowser.Engine.Cef/Shared/Browser/UwbCefContextMenuHandler.cs @@ -5,7 +5,7 @@ using Xilium.CefGlue; -namespace UnityWebBrowser.Engine.Cef.Browser; +namespace UnityWebBrowser.Engine.Cef.Shared.Browser; public class UwbCefContextMenuHandler : CefContextMenuHandler { diff --git a/src/UnityWebBrowser.Engine.Cef/Browser/UwbCefDisplayHandler.cs b/src/UnityWebBrowser.Engine.Cef/Shared/Browser/UwbCefDisplayHandler.cs similarity index 59% rename from src/UnityWebBrowser.Engine.Cef/Browser/UwbCefDisplayHandler.cs rename to src/UnityWebBrowser.Engine.Cef/Shared/Browser/UwbCefDisplayHandler.cs index bb838939..0e34daae 100644 --- a/src/UnityWebBrowser.Engine.Cef/Browser/UwbCefDisplayHandler.cs +++ b/src/UnityWebBrowser.Engine.Cef/Shared/Browser/UwbCefDisplayHandler.cs @@ -4,51 +4,54 @@ // This project is under the MIT license. See the LICENSE.md file for more details. using System; -using UnityWebBrowser.Engine.Cef.Core; +using Microsoft.Extensions.Logging; using VoltstroStudios.UnityWebBrowser.Engine.Shared.Core; -using VoltstroStudios.UnityWebBrowser.Shared.Core; using Xilium.CefGlue; -namespace UnityWebBrowser.Engine.Cef.Browser; +namespace UnityWebBrowser.Engine.Cef.Shared.Browser; /// /// implementation /// internal class UwbCefDisplayHandler : CefDisplayHandler { + private readonly ILogger browserConsoleLogger; private readonly ClientControlsActions clientControls; + private readonly ILogger mainLogger; - public UwbCefDisplayHandler(UwbCefClient client) + public UwbCefDisplayHandler(UwbCefClient client, ILogger mainLogger, ILogger browserConsoleLogger) { - this.clientControls = client.ClientControls; + clientControls = client.ClientControls; + this.mainLogger = mainLogger; + this.browserConsoleLogger = browserConsoleLogger; } protected override void OnAddressChange(CefBrowser browser, CefFrame frame, string url) { - CefLoggerWrapper.Debug($"{CefLoggerWrapper.FullCefMessageTag} URL change: {url}"); + mainLogger.LogDebug($"URL change: {url}"); clientControls.UrlChange(url); } protected override void OnFullscreenModeChange(CefBrowser browser, bool fullscreen) { - CefLoggerWrapper.Debug($"{CefLoggerWrapper.FullCefMessageTag} Fullscreen change: {fullscreen}"); + mainLogger.LogDebug($"Fullscreen change: {fullscreen}"); clientControls.Fullscreen(fullscreen); } protected override void OnTitleChange(CefBrowser browser, string title) { - CefLoggerWrapper.Debug($"{CefLoggerWrapper.FullCefMessageTag} Title change: {title}"); + mainLogger.LogDebug($"Title change: {title}"); clientControls.TitleChange(title); } protected override void OnLoadingProgressChange(CefBrowser browser, double progress) { - CefLoggerWrapper.Debug($"{CefLoggerWrapper.FullCefMessageTag} Progress change: {progress}"); + mainLogger.LogDebug($"Progress change: {progress}"); clientControls.ProgressChange(progress); } - protected override bool OnConsoleMessage(CefBrowser browser, CefLogSeverity level, string message, - string source, int line) + protected override bool OnConsoleMessage(CefBrowser browser, CefLogSeverity level, string message, string source, + int line) { switch (level) { @@ -56,17 +59,19 @@ protected override bool OnConsoleMessage(CefBrowser browser, CefLogSeverity leve break; case CefLogSeverity.Default: case CefLogSeverity.Info: - CefLoggerWrapper.Info($"{CefLoggerWrapper.ConsoleMessageTag} {message}"); + browserConsoleLogger.LogInformation($"[{source}:{line}]: {message}"); break; case CefLogSeverity.Warning: - CefLoggerWrapper.Warn($"{CefLoggerWrapper.ConsoleMessageTag} {message}"); + browserConsoleLogger.LogWarning($"[{source}:{line}]: {message}"); break; case CefLogSeverity.Error: + browserConsoleLogger.LogError($"[{source}:{line}]: {message}"); + break; case CefLogSeverity.Fatal: - CefLoggerWrapper.Error($"{CefLoggerWrapper.ConsoleMessageTag} {message}"); + browserConsoleLogger.LogCritical($"[{source}:{line}]: {message}"); break; case CefLogSeverity.Verbose: - CefLoggerWrapper.Debug($"{CefLoggerWrapper.ConsoleMessageTag} {message}"); + //browserConsoleLogger.ZLogDebug($"[{source}:{line}]: {message}"); break; default: throw new ArgumentOutOfRangeException(nameof(level), level, null); diff --git a/src/UnityWebBrowser.Engine.Cef/Browser/UwbCefLifespanHandler.cs b/src/UnityWebBrowser.Engine.Cef/Shared/Browser/UwbCefLifespanHandler.cs similarity index 92% rename from src/UnityWebBrowser.Engine.Cef/Browser/UwbCefLifespanHandler.cs rename to src/UnityWebBrowser.Engine.Cef/Shared/Browser/UwbCefLifespanHandler.cs index 029a1088..f4fe4ea7 100644 --- a/src/UnityWebBrowser.Engine.Cef/Browser/UwbCefLifespanHandler.cs +++ b/src/UnityWebBrowser.Engine.Cef/Shared/Browser/UwbCefLifespanHandler.cs @@ -4,34 +4,35 @@ // This project is under the MIT license. See the LICENSE.md file for more details. using System; -using UnityWebBrowser.Engine.Cef.Browser.Popups; using UnityWebBrowser.Engine.Cef.Core; +using UnityWebBrowser.Engine.Cef.Shared.Browser.Popups; using VoltstroStudios.UnityWebBrowser.Engine.Shared.Popups; using VoltstroStudios.UnityWebBrowser.Shared; using VoltstroStudios.UnityWebBrowser.Shared.Popups; using Xilium.CefGlue; -namespace UnityWebBrowser.Engine.Cef.Browser; +namespace UnityWebBrowser.Engine.Cef.Shared.Browser; /// /// implementation /// public class UwbCefLifespanHandler : CefLifeSpanHandler { - public event Action AfterCreated; + private readonly PopupAction popupAction; private readonly EnginePopupManager popupManager; private readonly ProxySettings proxySettings; - - private readonly PopupAction popupAction; - public UwbCefLifespanHandler(PopupAction popupAction, EnginePopupManager enginePopupManager, ProxySettings proxySettings) + public UwbCefLifespanHandler(PopupAction popupAction, EnginePopupManager enginePopupManager, + ProxySettings proxySettings) { this.proxySettings = proxySettings; this.popupAction = popupAction; popupManager = enginePopupManager; } + public event Action AfterCreated; + protected override void OnAfterCreated(CefBrowser browser) { AfterCreated?.Invoke(browser); @@ -59,7 +60,7 @@ protected override bool OnBeforePopup(CefBrowser browser, CefFrame frame, string default: throw new ArgumentOutOfRangeException(); } - + return true; } diff --git a/src/UnityWebBrowser.Engine.Cef/Browser/UwbCefLoadHandler.cs b/src/UnityWebBrowser.Engine.Cef/Shared/Browser/UwbCefLoadHandler.cs similarity index 78% rename from src/UnityWebBrowser.Engine.Cef/Browser/UwbCefLoadHandler.cs rename to src/UnityWebBrowser.Engine.Cef/Shared/Browser/UwbCefLoadHandler.cs index af2f0dd1..bd3930a9 100644 --- a/src/UnityWebBrowser.Engine.Cef/Browser/UwbCefLoadHandler.cs +++ b/src/UnityWebBrowser.Engine.Cef/Shared/Browser/UwbCefLoadHandler.cs @@ -7,7 +7,7 @@ using UnityWebBrowser.Engine.Cef.Core; using Xilium.CefGlue; -namespace UnityWebBrowser.Engine.Cef.Browser; +namespace UnityWebBrowser.Engine.Cef.Shared.Browser; /// /// implementation @@ -15,7 +15,7 @@ namespace UnityWebBrowser.Engine.Cef.Browser; public class UwbCefLoadHandler : CefLoadHandler { private readonly UwbCefClient client; - private readonly string[] ignoredLoadUrls = {"about:blank"}; + private readonly string[] ignoredLoadUrls = { "about:blank" }; internal UwbCefLoadHandler(UwbCefClient client) { @@ -28,7 +28,7 @@ protected override void OnLoadStart(CefBrowser browser, CefFrame frame, CefTrans if (ignoredLoadUrls.Contains(url)) return; - CefLoggerWrapper.Debug($"{CefLoggerWrapper.FullCefMessageTag} Load start: {url}"); + CefLoggerWrapper.Debug($"Load start: {url}"); if (frame.IsMain) client.ClientControls.LoadStart(url); } @@ -39,7 +39,7 @@ protected override void OnLoadEnd(CefBrowser browser, CefFrame frame, int httpSt if (ignoredLoadUrls.Contains(url)) return; - CefLoggerWrapper.Debug($"{CefLoggerWrapper.FullCefMessageTag} Load end: {url}"); + CefLoggerWrapper.Debug($"Load end: {url}"); if (frame.IsMain) client.ClientControls.LoadFinish(url); } @@ -48,7 +48,7 @@ protected override void OnLoadError(CefBrowser browser, CefFrame frame, CefError string errorText, string failedUrl) { CefLoggerWrapper.Error( - $"{CefLoggerWrapper.ConsoleMessageTag} An error occurred while trying to load '{failedUrl}'! Error details: {errorText} (Code: {errorCode})"); + $"An error occurred while trying to load '{failedUrl}'! Error details: {errorText} (Code: {errorCode})"); if (errorCode is CefErrorCode.Aborted or CefErrorCode.BLOCKED_BY_RESPONSE @@ -65,7 +65,7 @@ or CefErrorCode.BLOCKED_BY_CLIENT }}

An error occurred while trying to load '{failedUrl}'!

-

Error: {errorText}
(Code: {(int) errorCode})

"; +

Error: {errorText}
(Code: {(int)errorCode})

"; client.LoadHtml(html); } } \ No newline at end of file diff --git a/src/UnityWebBrowser.Engine.Cef/Browser/UwbCefRenderHandler.cs b/src/UnityWebBrowser.Engine.Cef/Shared/Browser/UwbCefRenderHandler.cs similarity index 58% rename from src/UnityWebBrowser.Engine.Cef/Browser/UwbCefRenderHandler.cs rename to src/UnityWebBrowser.Engine.Cef/Shared/Browser/UwbCefRenderHandler.cs index 13e1df62..8df204af 100644 --- a/src/UnityWebBrowser.Engine.Cef/Browser/UwbCefRenderHandler.cs +++ b/src/UnityWebBrowser.Engine.Cef/Shared/Browser/UwbCefRenderHandler.cs @@ -12,26 +12,23 @@ using VoltstroStudios.UnityWebBrowser.Engine.Shared.Core; using Xilium.CefGlue; -namespace UnityWebBrowser.Engine.Cef.Browser; +namespace UnityWebBrowser.Engine.Cef.Shared.Browser; /// /// implementation /// internal class UwbCefRenderHandler : CefRenderHandler { - private CefSize cefSize; + private readonly ClientControlsActions clientControls; private readonly object pixelsLock; - private Memory userPixelsBuffer; + private CefSize cefSize; private byte[] pixelsBuffer; private int pixelsLength; + private Memory userPixelsBuffer; + private int viewHeight; - private readonly ClientControlsActions clientControls; - - /// - /// Tracked mouse scroll position - /// - public Vector2 MouseScrollPosition { get; private set; } + private int viewWidth; public UwbCefRenderHandler(UwbCefClient client, CefSize size) { @@ -39,7 +36,12 @@ public UwbCefRenderHandler(UwbCefClient client, CefSize size) Resize(size); clientControls = client.ClientControls; } - + + /// + /// Tracked mouse scroll position + /// + public Vector2 MouseScrollPosition { get; private set; } + public ReadOnlyMemory Pixels { [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -57,13 +59,13 @@ public ReadOnlyMemory Pixels public void Resize(CefSize size) { pixelsLength = size.Width * size.Height * 4; - + lock (pixelsLock) { pixelsBuffer = new byte[pixelsLength]; userPixelsBuffer = new Memory(new byte[pixelsLength]); } - + cefSize = size; } @@ -94,35 +96,60 @@ protected override void GetViewRect(CefBrowser browser, out CefRectangle rect) [SecurityCritical] protected override void OnPaint(CefBrowser browser, CefPaintElementType type, CefRectangle[] dirtyRects, - IntPtr buffer, int width, - int height) + IntPtr buffer, int width, int height) { + if (type == CefPaintElementType.Popup && showPopup) + { + Marshal.Copy(buffer, popupDataBuffer, 0, popupDataBufferSize); + DrawPopupToMainBuffer(); + return; + } + //Ensure buffer sizes are the same int myBufferSize = width * height * 4; - if(myBufferSize != pixelsLength) + if (myBufferSize != pixelsLength) return; - + + viewHeight = height; + viewWidth = width; + //Copy our pixel buffer to our pixels lock (pixelsLock) { Marshal.Copy(buffer, pixelsBuffer, 0, pixelsLength); + + //Redraw popup if one is ment to be showing + if (showPopup) + DrawPopupToMainBuffer(); } } - protected override bool GetScreenInfo(CefBrowser browser, CefScreenInfo screenInfo) + protected override void OnAcceleratedPaint(CefBrowser browser, CefPaintElementType type, CefRectangle[] dirtyRects, + CefAcceleratedPaintInfo acceleratedPaintInfo) { - return false; } - protected override void OnPopupSize(CefBrowser browser, CefRectangle rect) + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private void DrawPopupToMainBuffer() { + int popupDataIndex = 0; + int startIndex = popupX + (popupY * viewWidth); + + for (int y = startIndex; y < popupHeight * viewWidth + startIndex; y += 4 * viewWidth) + { + for (int x = 0; x < popupWidth; x++) + { + pixelsBuffer[y + x] = popupDataBuffer[popupDataIndex]; + popupDataIndex++; + } + } } - protected override void OnAcceleratedPaint(CefBrowser browser, CefPaintElementType type, - CefRectangle[] dirtyRects, IntPtr sharedHandle) + protected override bool GetScreenInfo(CefBrowser browser, CefScreenInfo screenInfo) { + return false; } - + protected override void OnScrollOffsetChanged(CefBrowser browser, double x, double y) { MouseScrollPosition = new Vector2((float)x, (float)y); @@ -138,4 +165,68 @@ protected override void OnVirtualKeyboardRequested(CefBrowser browser, CefTextIn CefLoggerWrapper.Debug($"Input mode changed to: {inputMode}"); clientControls.InputFocusChange(inputMode == CefTextInputMode.Default); } + + #region Popups + + //Popups are widgets, like the select element + + private int popupDataBufferSize; + private byte[] popupDataBuffer; + + private bool showPopup; + + private int popupX; + private int popupY; + + private int popupWidth; + private int popupHeight; + + protected override void OnPopupSize(CefBrowser browser, CefRectangle rect) + { + rect = GetPopupRectInWebView(rect); + + int popupDataLength = rect.Width * rect.Height * 4; + if (popupDataBufferSize == popupDataLength || !showPopup) + return; + + popupDataBuffer = new byte[popupDataLength]; + popupDataBufferSize = popupDataLength; + + popupWidth = rect.Width * 4; + popupHeight = rect.Height * 4; + popupX = rect.X * 4; + + popupY = rect.Y * 4; + } + + private CefRectangle GetPopupRectInWebView(CefRectangle rc) + { + // if x or y are negative, move them to 0. + if (rc.X < 0) + rc.X = 0; + + if (rc.Y < 0) + rc.Y = 0; + + // if popup goes outside the view, try to reposition origin + if (rc.X + rc.Width > viewWidth) + rc.X = viewWidth - rc.Width; + if (rc.Y + rc.Height > viewHeight) + rc.Y = viewHeight - rc.Height; + + // if x or y became negative, move them to 0 again. + if (rc.X < 0) + rc.X = 0; + if (rc.Y < 0) + rc.Y = 0; + + return rc; + } + + protected override void OnPopupShow(CefBrowser browser, bool show) + { + showPopup = show; + } + + #endregion } \ No newline at end of file diff --git a/src/UnityWebBrowser.Engine.Cef/Browser/UwbCefRenderProcessHandler.cs b/src/UnityWebBrowser.Engine.Cef/Shared/Browser/UwbCefRenderProcessHandler.cs similarity index 84% rename from src/UnityWebBrowser.Engine.Cef/Browser/UwbCefRenderProcessHandler.cs rename to src/UnityWebBrowser.Engine.Cef/Shared/Browser/UwbCefRenderProcessHandler.cs index d367380e..68ea4a2a 100644 --- a/src/UnityWebBrowser.Engine.Cef/Browser/UwbCefRenderProcessHandler.cs +++ b/src/UnityWebBrowser.Engine.Cef/Shared/Browser/UwbCefRenderProcessHandler.cs @@ -3,14 +3,13 @@ // // This project is under the MIT license. See the LICENSE.md file for more details. -using UnityWebBrowser.Engine.Cef.Browser.Js; +using UnityWebBrowser.Engine.Cef.Shared.Browser.Js; using Xilium.CefGlue; -namespace UnityWebBrowser.Engine.Cef.Browser; +namespace UnityWebBrowser.Engine.Cef.Shared.Browser; /// -/// UWB's custom -/// +/// UWB's custom /// The render process handles JS callbacks. So custom JS stuff is done here /// public class UwbCefRenderProcessHandler : CefRenderProcessHandler @@ -25,7 +24,7 @@ protected override void OnContextCreated(CefBrowser browser, CefFrame frame, Cef //Version info CefV8Value versionValue = CefV8Value.CreateString(ThisAssembly.AssemblyFileVersion); uwbObject.SetValue("EngineVersion", versionValue); - + CefV8Value engineName = CefV8Value.CreateString("CEF (Chromium Embedded Framework)"); uwbObject.SetValue("EngineName", engineName); @@ -33,7 +32,8 @@ protected override void OnContextCreated(CefBrowser browser, CefFrame frame, Cef uwbObject.SetValue("CefVersion", cefVersion); //UWB's uwbExecuteJsMethod function - CefV8Value executeMethod = CefV8Value.CreateFunction(UwbCefJsMethodHandler.ExecuteJsMethodsFunctionName, new UwbCefJsMethodHandler()); + CefV8Value executeMethod = CefV8Value.CreateFunction(UwbCefJsMethodHandler.ExecuteJsMethodsFunctionName, + new UwbCefJsMethodHandler()); uwbObject.SetValue(UwbCefJsMethodHandler.ExecuteJsMethodsFunctionName, executeMethod); //Add uwb to global value diff --git a/src/UnityWebBrowser.Engine.Cef/Browser/UwbCefRequestHandler.cs b/src/UnityWebBrowser.Engine.Cef/Shared/Browser/UwbCefRequestHandler.cs similarity index 95% rename from src/UnityWebBrowser.Engine.Cef/Browser/UwbCefRequestHandler.cs rename to src/UnityWebBrowser.Engine.Cef/Shared/Browser/UwbCefRequestHandler.cs index 0d5033b7..7956b207 100644 --- a/src/UnityWebBrowser.Engine.Cef/Browser/UwbCefRequestHandler.cs +++ b/src/UnityWebBrowser.Engine.Cef/Shared/Browser/UwbCefRequestHandler.cs @@ -6,7 +6,7 @@ using VoltstroStudios.UnityWebBrowser.Shared; using Xilium.CefGlue; -namespace UnityWebBrowser.Engine.Cef.Browser; +namespace UnityWebBrowser.Engine.Cef.Shared.Browser; /// /// implementation diff --git a/src/UnityWebBrowser.Engine.Cef/Core/CefActionTask.cs b/src/UnityWebBrowser.Engine.Cef/Shared/Core/CefActionTask.cs similarity index 76% rename from src/UnityWebBrowser.Engine.Cef/Core/CefActionTask.cs rename to src/UnityWebBrowser.Engine.Cef/Shared/Core/CefActionTask.cs index b104fc6b..6fe17bd0 100644 --- a/src/UnityWebBrowser.Engine.Cef/Core/CefActionTask.cs +++ b/src/UnityWebBrowser.Engine.Cef/Shared/Core/CefActionTask.cs @@ -22,4 +22,9 @@ protected override void Execute() action(); action = null; } + + public static void PostTask(CefThreadId threadId, Action action) + { + CefRuntime.PostTask(threadId, new CefActionTask(action)); + } } \ No newline at end of file diff --git a/src/UnityWebBrowser.Engine.Cef/Core/CefLoggerWrapper.cs b/src/UnityWebBrowser.Engine.Cef/Shared/Core/CefLoggerWrapper.cs similarity index 69% rename from src/UnityWebBrowser.Engine.Cef/Core/CefLoggerWrapper.cs rename to src/UnityWebBrowser.Engine.Cef/Shared/Core/CefLoggerWrapper.cs index 53f27453..5b375d98 100644 --- a/src/UnityWebBrowser.Engine.Cef/Core/CefLoggerWrapper.cs +++ b/src/UnityWebBrowser.Engine.Cef/Shared/Core/CefLoggerWrapper.cs @@ -4,7 +4,7 @@ // This project is under the MIT license. See the LICENSE.md file for more details. using System; -using VoltstroStudios.UnityWebBrowser.Engine.Shared.Core.Logging; +using Microsoft.Extensions.Logging; using Xilium.CefGlue; namespace UnityWebBrowser.Engine.Cef.Core; @@ -14,9 +14,12 @@ namespace UnityWebBrowser.Engine.Cef.Core; /// public static class CefLoggerWrapper { - private const string CefMessageTag = "CEF Engine"; - public const string FullCefMessageTag = $"[{CefMessageTag}]:"; - public const string ConsoleMessageTag = $"[{CefMessageTag} Console]:"; + private static ILogger logger; + + internal static void Init(ILogger mainLogger) + { + logger = mainLogger; + } #region Debug Log @@ -28,11 +31,11 @@ public static void Debug(string message) { if (!CefRuntime.CurrentlyOn(CefThreadId.UI)) { - CefEngineControlsManager.PostTask(CefThreadId.UI, () => Debug(message)); + CefActionTask.PostTask(CefThreadId.UI, () => Debug(message)); return; } - Logger.Debug(message); + logger.LogDebug(message); } /// @@ -44,11 +47,11 @@ public static void Debug(string message, params object[] values) { if (!CefRuntime.CurrentlyOn(CefThreadId.UI)) { - CefEngineControlsManager.PostTask(CefThreadId.UI, () => Debug(message, values)); + CefActionTask.PostTask(CefThreadId.UI, () => Debug(message, values)); return; } - Logger.Debug(message, values); + logger.LogDebug(message, values); } #endregion @@ -63,11 +66,11 @@ public static void Info(string message) { if (!CefRuntime.CurrentlyOn(CefThreadId.UI)) { - CefEngineControlsManager.PostTask(CefThreadId.UI, () => Info(message)); + CefActionTask.PostTask(CefThreadId.UI, () => Info(message)); return; } - Logger.Info(message); + logger.LogInformation(message); } /// @@ -79,11 +82,11 @@ public static void Info(string message, params object[] values) { if (!CefRuntime.CurrentlyOn(CefThreadId.UI)) { - CefEngineControlsManager.PostTask(CefThreadId.UI, () => Info(message, values)); + CefActionTask.PostTask(CefThreadId.UI, () => Info(message, values)); return; } - Logger.Info(message, values); + logger.LogInformation(message, values); } #endregion @@ -98,11 +101,11 @@ public static void Warn(string message) { if (!CefRuntime.CurrentlyOn(CefThreadId.UI)) { - CefEngineControlsManager.PostTask(CefThreadId.UI, () => Warn(message)); + CefActionTask.PostTask(CefThreadId.UI, () => Warn(message)); return; } - Logger.Warn(message); + logger.LogWarning(message); } /// @@ -114,11 +117,11 @@ public static void Warn(string message, params object[] values) { if (!CefRuntime.CurrentlyOn(CefThreadId.UI)) { - CefEngineControlsManager.PostTask(CefThreadId.UI, () => Warn(message, values)); + CefActionTask.PostTask(CefThreadId.UI, () => Warn(message, values)); return; } - Logger.Warn(message, values); + logger.LogWarning(message, values); } #endregion @@ -133,11 +136,11 @@ public static void Error(string message) { if (!CefRuntime.CurrentlyOn(CefThreadId.UI)) { - CefEngineControlsManager.PostTask(CefThreadId.UI, () => Error(message)); + CefActionTask.PostTask(CefThreadId.UI, () => Error(message)); return; } - Logger.Error(message); + logger.LogError(message); } /// @@ -149,11 +152,11 @@ public static void Error(string message, params object[] values) { if (!CefRuntime.CurrentlyOn(CefThreadId.UI)) { - CefEngineControlsManager.PostTask(CefThreadId.UI, () => Error(message, values)); + CefActionTask.PostTask(CefThreadId.UI, () => Error(message, values)); return; } - Logger.Error(message, values); + logger.LogError(message, values); } /// @@ -165,11 +168,11 @@ public static void Error(Exception exception, string message) { if (!CefRuntime.CurrentlyOn(CefThreadId.UI)) { - CefEngineControlsManager.PostTask(CefThreadId.UI, () => Error(exception, message)); + CefActionTask.PostTask(CefThreadId.UI, () => Error(exception, message)); return; } - Logger.Error(exception, message); + logger.LogError(exception, message); } /// @@ -182,11 +185,11 @@ public static void Error(Exception exception, string message, params object[] va { if (!CefRuntime.CurrentlyOn(CefThreadId.UI)) { - CefEngineControlsManager.PostTask(CefThreadId.UI, () => Error(exception, message, values)); + CefActionTask.PostTask(CefThreadId.UI, () => Error(exception, message, values)); return; } - Logger.Error(exception, message, values); + logger.LogError(exception, message, values); } #endregion diff --git a/src/UnityWebBrowser.Engine.Cef/Shared/Core/CefMacOsFrameworkLoader.cs b/src/UnityWebBrowser.Engine.Cef/Shared/Core/CefMacOsFrameworkLoader.cs new file mode 100644 index 00000000..660b61f2 --- /dev/null +++ b/src/UnityWebBrowser.Engine.Cef/Shared/Core/CefMacOsFrameworkLoader.cs @@ -0,0 +1,44 @@ +// UnityWebBrowser (UWB) +// Copyright (c) 2021-2024 Voltstro-Studios +// +// This project is under the MIT license.See the LICENSE.md file for more details. + +using System; +using System.IO; +using System.Runtime.InteropServices; +using System.Runtime.Loader; + +namespace UnityWebBrowser.Engine.Cef.Shared.Core; + +#if MACOS + +public static class CefMacOsFrameworkLoader +{ + public static void AddFrameworkLoader() + { + AssemblyLoadContext.Default.ResolvingUnmanagedDll += (_, libName) => + { + string basePath = Environment.CurrentDirectory; + bool includeExt = true; + + if(libName == "libcef") + { + basePath = Path.Combine(basePath, "../Frameworks/", "Chromium Embedded Framework.framework"); + libName = "Chromium Embedded Framework"; + includeExt = false; + } + else + { + basePath = Path.Combine(basePath, "../Frameworks/", "Chromium Embedded Framework.framework/Libraries"); + } + + string fullPath = Path.GetFullPath(Path.Combine(basePath, libName)); + if (includeExt) + fullPath += ".dylib"; + + return NativeLibrary.Load(fullPath); + }; + } +} + +#endif \ No newline at end of file diff --git a/src/UnityWebBrowser.Engine.Cef/Shared/Core/CefSandbox.cs b/src/UnityWebBrowser.Engine.Cef/Shared/Core/CefSandbox.cs new file mode 100644 index 00000000..4f1f7404 --- /dev/null +++ b/src/UnityWebBrowser.Engine.Cef/Shared/Core/CefSandbox.cs @@ -0,0 +1,43 @@ +// UnityWebBrowser (UWB) +// Copyright (c) 2021-2024 Voltstro-Studios +// +// This project is under the MIT license.See the LICENSE.md file for more details. + +using System; +using System.Runtime.InteropServices; + +namespace UnityWebBrowser.Engine.Cef.Shared.Core; + +/// +/// CEF Sandbox methods +/// +public static class CefSandbox +{ +#if WINDOWS + /// + /// Create the sandbox information object for this process. It is safe to create + /// multiple of this object and to destroy the object immediately after passing + /// into the CefExecuteProcess() and/or CefInitialize() functions. + /// + /// + [DllImport("cef_sandbox", EntryPoint = "cef_sandbox_info_create", CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr cef_sandbox_info_create(); + + /// + /// Destroy the specified sandbox information object. + /// + /// + /// + [DllImport("cef_sandbox", EntryPoint = "cef_sandbox_info_destroy", CallingConvention = CallingConvention.Cdecl)] + public static extern void cef_sandbox_info_destroy(IntPtr sandbox_info); +#endif + +#if MACOS + [DllImport("cef_sandbox", EntryPoint = "cef_sandbox_initialize", CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr cef_sandbox_initialize(int argc, [In] string[] argv); + + [DllImport("cef_sandbox", EntryPoint = "cef_sandbox_destroy", CallingConvention = CallingConvention.Cdecl)] + public static extern void cef_sandbox_destroy(IntPtr sandbox_context); + +#endif +} \ No newline at end of file diff --git a/src/UnityWebBrowser.Engine.Cef/Shared/UnityWebBrowser.Engine.Cef.Shared.csproj b/src/UnityWebBrowser.Engine.Cef/Shared/UnityWebBrowser.Engine.Cef.Shared.csproj new file mode 100644 index 00000000..2c7118c8 --- /dev/null +++ b/src/UnityWebBrowser.Engine.Cef/Shared/UnityWebBrowser.Engine.Cef.Shared.csproj @@ -0,0 +1,130 @@ + + + + + + + net8.0 + false + ../bin/$(Configuration)/ + + true + + + + + + + + + + + + PreserveNewest + %(Filename)%(Extension) + true + + + + PreserveNewest + %(Filename)%(Extension) + true + + + + PreserveNewest + %(Filename)%(Extension) + true + + + + PreserveNewest + %(Filename)%(Extension) + true + + + + PreserveNewest + %(Filename)%(Extension) + true + + + + PreserveNewest + LICENSE.CEF.txt + true + + + + PreserveNewest + README.CEF.txt + true + + + + PreserveNewest + locales/%(Filename)%(Extension) + true + + + + + + + PreserveNewest + %(Filename)%(Extension) + true + + + + PreserveNewest + %(Filename)%(Extension) + true + + + + PreserveNewest + %(Filename)%(Extension) + true + + + + PreserveNewest + %(Filename)%(Extension) + true + + + + PreserveNewest + %(Filename)%(Extension) + true + + + + PreserveNewest + %(Filename)%(Extension) + true + + + + PreserveNewest + LICENSE.CEF.txt + true + + + + PreserveNewest + README.CEF.txt + true + + + + PreserveNewest + locales/%(Filename)%(Extension) + true + + + + + + diff --git a/src/UnityWebBrowser.Engine.Cef/chromium-logo.ico b/src/UnityWebBrowser.Engine.Cef/Shared/chromium-logo.ico similarity index 100% rename from src/UnityWebBrowser.Engine.Cef/chromium-logo.ico rename to src/UnityWebBrowser.Engine.Cef/Shared/chromium-logo.ico diff --git a/src/UnityWebBrowser.Engine.Cef/SubProcess/Program.cs b/src/UnityWebBrowser.Engine.Cef/SubProcess/Program.cs new file mode 100644 index 00000000..dd31f9e8 --- /dev/null +++ b/src/UnityWebBrowser.Engine.Cef/SubProcess/Program.cs @@ -0,0 +1,53 @@ +// UnityWebBrowser (UWB) +// Copyright (c) 2021-2024 Voltstro-Studios +// +// This project is under the MIT license. See the LICENSE.md file for more details. + +using System; +using UnityWebBrowser.Engine.Cef.Shared.Browser; +using UnityWebBrowser.Engine.Cef.Shared.Core; +using VoltstroStudios.UnityWebBrowser.Engine.Shared.Core; +using Xilium.CefGlue; + +namespace UnityWebBrowser.Engine.Cef.SubProcess; + +public static class Program +{ + public static int Main(string[] args) + { +#if MACOS + var sandboxContext = CefSandbox.cef_sandbox_initialize(args.Length, args); + CefMacOsFrameworkLoader.AddFrameworkLoader(); +#endif + + //Setup CEF + CefRuntime.Load(); + + LaunchArgumentsParser argumentsParser = new(); + int subProcessExitCode = 0; + argumentsParser.Run(args, launchArguments => + { +// ReSharper disable once RedundantAssignment + string[] argv = args; +#if LINUX || MACOS + //On Linux we need to do this, otherwise it will just crash, no idea why tho + argv = new string[args.Length + 1]; + Array.Copy(args, 0, argv, 1, args.Length); + argv[0] = "-"; +#endif + + //Set up CEF args and the CEF app + CefMainArgs cefMainArgs = new CefMainArgs(argv); + UwbCefApp cefApp = new UwbCefApp(launchArguments); + + //Run our sub-processes + subProcessExitCode = CefRuntime.ExecuteProcess(cefMainArgs, cefApp, IntPtr.Zero); + }); + +#if MACOS + CefSandbox.cef_sandbox_destroy(sandboxContext); +#endif + + return subProcessExitCode; + } +} \ No newline at end of file diff --git a/src/UnityWebBrowser.Engine.Cef/SubProcess/UnityWebBrowser.Engine.Cef.SubProcess.csproj b/src/UnityWebBrowser.Engine.Cef/SubProcess/UnityWebBrowser.Engine.Cef.SubProcess.csproj new file mode 100644 index 00000000..0b84e034 --- /dev/null +++ b/src/UnityWebBrowser.Engine.Cef/SubProcess/UnityWebBrowser.Engine.Cef.SubProcess.csproj @@ -0,0 +1,72 @@ + + + + + + + Exe + net8.0 + ../Shared/chromium-logo.ico + osx-x64;osx-arm64 + + false + ../bin/$(Configuration)/ + ../bin/$(Configuration)/publish/$(RuntimeIdentifier) + + true + true + true + false + true + true + + + + + + + + + + + + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + + + + + + + + + + + + + .allowedextension + + + + + true + + + + true + + + + diff --git a/src/UnityWebBrowser.Engine.Cef/SubProcess/info-subprocess-gpu.plist b/src/UnityWebBrowser.Engine.Cef/SubProcess/info-subprocess-gpu.plist new file mode 100644 index 00000000..a72c2923 --- /dev/null +++ b/src/UnityWebBrowser.Engine.Cef/SubProcess/info-subprocess-gpu.plist @@ -0,0 +1,35 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleDisplayName + UnityWebBrowser.Engine.Cef.SubProcess (GPU) + CFBundleExecutable + UnityWebBrowser.Engine.Cef.SubProcess (GPU) + CFBundleIdentifier + dev.voltstro.uwb.engine.cef.subprocess.gpu + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + UnityWebBrowser.Engine.Cef.SubProcess (GPU) + CFBundlePackageType + APPL + CFBundleSignature + ???? + LSEnvironment + + MallocNanoZone + 0 + + LSFileQuarantineEnabled + + LSMinimumSystemVersion + 10.15.0 + LSUIElement + 1 + NSSupportsAutomaticGraphicsSwitching + + + \ No newline at end of file diff --git a/src/UnityWebBrowser.Engine.Cef/SubProcess/info-subprocess-plugin.plist b/src/UnityWebBrowser.Engine.Cef/SubProcess/info-subprocess-plugin.plist new file mode 100644 index 00000000..4eb2fd45 --- /dev/null +++ b/src/UnityWebBrowser.Engine.Cef/SubProcess/info-subprocess-plugin.plist @@ -0,0 +1,35 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleDisplayName + UnityWebBrowser.Engine.Cef.SubProcess (Plugin) + CFBundleExecutable + UnityWebBrowser.Engine.Cef.SubProcess (Plugin) + CFBundleIdentifier + dev.voltstro.uwb.engine.cef.subprocess.plugin + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + UnityWebBrowser.Engine.Cef.SubProcess (Plugin) + CFBundlePackageType + APPL + CFBundleSignature + ???? + LSEnvironment + + MallocNanoZone + 0 + + LSFileQuarantineEnabled + + LSMinimumSystemVersion + 10.15.0 + LSUIElement + 1 + NSSupportsAutomaticGraphicsSwitching + + + \ No newline at end of file diff --git a/src/UnityWebBrowser.Engine.Cef/SubProcess/info-subprocess-renderer.plist b/src/UnityWebBrowser.Engine.Cef/SubProcess/info-subprocess-renderer.plist new file mode 100644 index 00000000..256a98a5 --- /dev/null +++ b/src/UnityWebBrowser.Engine.Cef/SubProcess/info-subprocess-renderer.plist @@ -0,0 +1,35 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleDisplayName + UnityWebBrowser.Engine.Cef.SubProcess (Renderer) + CFBundleExecutable + UnityWebBrowser.Engine.Cef.SubProcess (Renderer) + CFBundleIdentifier + dev.voltstro.uwb.engine.cef.subprocess.renderer + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + UnityWebBrowser.Engine.Cef.SubProcess (Renderer) + CFBundlePackageType + APPL + CFBundleSignature + ???? + LSEnvironment + + MallocNanoZone + 0 + + LSFileQuarantineEnabled + + LSMinimumSystemVersion + 10.15.0 + LSUIElement + 1 + NSSupportsAutomaticGraphicsSwitching + + + \ No newline at end of file diff --git a/src/UnityWebBrowser.Engine.Cef/SubProcess/info-subprocess.plist b/src/UnityWebBrowser.Engine.Cef/SubProcess/info-subprocess.plist new file mode 100644 index 00000000..fb8e2d21 --- /dev/null +++ b/src/UnityWebBrowser.Engine.Cef/SubProcess/info-subprocess.plist @@ -0,0 +1,35 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleDisplayName + UnityWebBrowser.Engine.Cef.SubProcess + CFBundleExecutable + UnityWebBrowser.Engine.Cef.SubProcess + CFBundleIdentifier + dev.voltstro.uwb.engine.cef.subprocess + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + UnityWebBrowser.Engine.Cef.SubProcess + CFBundlePackageType + APPL + CFBundleSignature + ???? + LSEnvironment + + MallocNanoZone + 0 + + LSFileQuarantineEnabled + + LSMinimumSystemVersion + 10.15.0 + LSUIElement + 1 + NSSupportsAutomaticGraphicsSwitching + + + \ No newline at end of file diff --git a/src/UnityWebBrowser.Engine.Cef/UnityWebBrowser.Engine.Cef.csproj b/src/UnityWebBrowser.Engine.Cef/UnityWebBrowser.Engine.Cef.csproj deleted file mode 100644 index ce4edc71..00000000 --- a/src/UnityWebBrowser.Engine.Cef/UnityWebBrowser.Engine.Cef.csproj +++ /dev/null @@ -1,191 +0,0 @@ - - - - - - - Exe - net8.0 - false - chromium-logo.ico - External process to handel rendering with CEF - win-x64;linux-x64;osx-x64 - 2.1.1-122.1.13 - BROWSER_PROCESS - - - - - - .allowedextension - - - - - true - true - true - false - true - false - true - false - false - false - false - - - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - - - - - PreserveNewest - %(Filename)%(Extension) - true - - - - PreserveNewest - %(Filename)%(Extension) - true - - - - PreserveNewest - %(Filename)%(Extension) - true - - - - PreserveNewest - %(Filename)%(Extension) - true - - - - PreserveNewest - %(Filename)%(Extension) - true - - - - PreserveNewest - LICENSE.CEF.txt - true - - - - PreserveNewest - README.CEF.txt - true - - - - PreserveNewest - locales/%(Filename)%(Extension) - true - - - - - - - - PreserveNewest - %(Filename)%(Extension) - true - - - - PreserveNewest - %(Filename)%(Extension) - true - - - - PreserveNewest - %(Filename)%(Extension) - true - - - - PreserveNewest - %(Filename)%(Extension) - true - - - - PreserveNewest - %(Filename)%(Extension) - true - - - - PreserveNewest - %(Filename)%(Extension) - true - - - - PreserveNewest - LICENSE.CEF.txt - true - - - - PreserveNewest - README.CEF.txt - true - - - - PreserveNewest - locales/%(Filename)%(Extension) - true - - - - - - - PreserveNewest - %(Filename)%(Extension) - true - - - - PreserveNewest - %(Filename)%(Extension) - true - - - - PreserveNewest - %(RecursiveDir)%(Filename)%(Extension) - true - - - - PreserveNewest - %(Filename)%(Extension) - true - - - - - - - diff --git a/src/UnityWebBrowser.Engine.Cef/version.json b/src/UnityWebBrowser.Engine.Cef/version.json new file mode 100644 index 00000000..8c2ba93a --- /dev/null +++ b/src/UnityWebBrowser.Engine.Cef/version.json @@ -0,0 +1,12 @@ +{ + "$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json", + "version": "2.2.0-128.4.9", + "publicReleaseRefSpec": [ + "^refs/heads/master$" + ], + "cloudBuild": { + "buildNumber": { + "enabled": true + } + } +} \ No newline at end of file diff --git a/src/UnityWebBrowser.Pages/package.json b/src/UnityWebBrowser.Pages/package.json index 7cd97e3b..71575e8d 100644 --- a/src/UnityWebBrowser.Pages/package.json +++ b/src/UnityWebBrowser.Pages/package.json @@ -9,10 +9,10 @@ "preview": "vite preview" }, "devDependencies": { - "@types/node": "^20.11.24", - "typescript": "^5.1.6", - "vite": "^5.1.4", + "@types/node": "^18.0.0", + "typescript": "^5.5.4", + "vite": "^5.4.6", "vite-plugin-html": "^3.2.0", - "vite-plugin-singlefile": "^2.0.0" + "vite-plugin-singlefile": "^2.0.2" } } diff --git a/src/UnityWebBrowser.Pages/yarn.lock b/src/UnityWebBrowser.Pages/yarn.lock index b66e0de4..06913f58 100644 --- a/src/UnityWebBrowser.Pages/yarn.lock +++ b/src/UnityWebBrowser.Pages/yarn.lock @@ -2,157 +2,157 @@ # yarn lockfile v1 -"@esbuild/aix-ppc64@0.19.12": - version "0.19.12" - resolved "https://registry.yarnpkg.com/@esbuild/aix-ppc64/-/aix-ppc64-0.19.12.tgz#d1bc06aedb6936b3b6d313bf809a5a40387d2b7f" - integrity sha512-bmoCYyWdEL3wDQIVbcyzRyeKLgk2WtWLTWz1ZIAZF/EGbNOwSA6ew3PftJ1PqMiOOGu0OyFMzG53L0zqIpPeNA== - -"@esbuild/android-arm64@0.19.12": - version "0.19.12" - resolved "https://registry.yarnpkg.com/@esbuild/android-arm64/-/android-arm64-0.19.12.tgz#7ad65a36cfdb7e0d429c353e00f680d737c2aed4" - integrity sha512-P0UVNGIienjZv3f5zq0DP3Nt2IE/3plFzuaS96vihvD0Hd6H/q4WXUGpCxD/E8YrSXfNyRPbpTq+T8ZQioSuPA== - -"@esbuild/android-arm@0.19.12": - version "0.19.12" - resolved "https://registry.yarnpkg.com/@esbuild/android-arm/-/android-arm-0.19.12.tgz#b0c26536f37776162ca8bde25e42040c203f2824" - integrity sha512-qg/Lj1mu3CdQlDEEiWrlC4eaPZ1KztwGJ9B6J+/6G+/4ewxJg7gqj8eVYWvao1bXrqGiW2rsBZFSX3q2lcW05w== - -"@esbuild/android-x64@0.19.12": - version "0.19.12" - resolved "https://registry.yarnpkg.com/@esbuild/android-x64/-/android-x64-0.19.12.tgz#cb13e2211282012194d89bf3bfe7721273473b3d" - integrity sha512-3k7ZoUW6Q6YqhdhIaq/WZ7HwBpnFBlW905Fa4s4qWJyiNOgT1dOqDiVAQFwBH7gBRZr17gLrlFCRzF6jFh7Kew== - -"@esbuild/darwin-arm64@0.19.12": - version "0.19.12" - resolved "https://registry.yarnpkg.com/@esbuild/darwin-arm64/-/darwin-arm64-0.19.12.tgz#cbee41e988020d4b516e9d9e44dd29200996275e" - integrity sha512-B6IeSgZgtEzGC42jsI+YYu9Z3HKRxp8ZT3cqhvliEHovq8HSX2YX8lNocDn79gCKJXOSaEot9MVYky7AKjCs8g== - -"@esbuild/darwin-x64@0.19.12": - version "0.19.12" - resolved "https://registry.yarnpkg.com/@esbuild/darwin-x64/-/darwin-x64-0.19.12.tgz#e37d9633246d52aecf491ee916ece709f9d5f4cd" - integrity sha512-hKoVkKzFiToTgn+41qGhsUJXFlIjxI/jSYeZf3ugemDYZldIXIxhvwN6erJGlX4t5h417iFuheZ7l+YVn05N3A== - -"@esbuild/freebsd-arm64@0.19.12": - version "0.19.12" - resolved "https://registry.yarnpkg.com/@esbuild/freebsd-arm64/-/freebsd-arm64-0.19.12.tgz#1ee4d8b682ed363b08af74d1ea2b2b4dbba76487" - integrity sha512-4aRvFIXmwAcDBw9AueDQ2YnGmz5L6obe5kmPT8Vd+/+x/JMVKCgdcRwH6APrbpNXsPz+K653Qg8HB/oXvXVukA== - -"@esbuild/freebsd-x64@0.19.12": - version "0.19.12" - resolved "https://registry.yarnpkg.com/@esbuild/freebsd-x64/-/freebsd-x64-0.19.12.tgz#37a693553d42ff77cd7126764b535fb6cc28a11c" - integrity sha512-EYoXZ4d8xtBoVN7CEwWY2IN4ho76xjYXqSXMNccFSx2lgqOG/1TBPW0yPx1bJZk94qu3tX0fycJeeQsKovA8gg== - -"@esbuild/linux-arm64@0.19.12": - version "0.19.12" - resolved "https://registry.yarnpkg.com/@esbuild/linux-arm64/-/linux-arm64-0.19.12.tgz#be9b145985ec6c57470e0e051d887b09dddb2d4b" - integrity sha512-EoTjyYyLuVPfdPLsGVVVC8a0p1BFFvtpQDB/YLEhaXyf/5bczaGeN15QkR+O4S5LeJ92Tqotve7i1jn35qwvdA== - -"@esbuild/linux-arm@0.19.12": - version "0.19.12" - resolved "https://registry.yarnpkg.com/@esbuild/linux-arm/-/linux-arm-0.19.12.tgz#207ecd982a8db95f7b5279207d0ff2331acf5eef" - integrity sha512-J5jPms//KhSNv+LO1S1TX1UWp1ucM6N6XuL6ITdKWElCu8wXP72l9MM0zDTzzeikVyqFE6U8YAV9/tFyj0ti+w== - -"@esbuild/linux-ia32@0.19.12": - version "0.19.12" - resolved "https://registry.yarnpkg.com/@esbuild/linux-ia32/-/linux-ia32-0.19.12.tgz#d0d86b5ca1562523dc284a6723293a52d5860601" - integrity sha512-Thsa42rrP1+UIGaWz47uydHSBOgTUnwBwNq59khgIwktK6x60Hivfbux9iNR0eHCHzOLjLMLfUMLCypBkZXMHA== - -"@esbuild/linux-loong64@0.19.12": - version "0.19.12" - resolved "https://registry.yarnpkg.com/@esbuild/linux-loong64/-/linux-loong64-0.19.12.tgz#9a37f87fec4b8408e682b528391fa22afd952299" - integrity sha512-LiXdXA0s3IqRRjm6rV6XaWATScKAXjI4R4LoDlvO7+yQqFdlr1Bax62sRwkVvRIrwXxvtYEHHI4dm50jAXkuAA== - -"@esbuild/linux-mips64el@0.19.12": - version "0.19.12" - resolved "https://registry.yarnpkg.com/@esbuild/linux-mips64el/-/linux-mips64el-0.19.12.tgz#4ddebd4e6eeba20b509d8e74c8e30d8ace0b89ec" - integrity sha512-fEnAuj5VGTanfJ07ff0gOA6IPsvrVHLVb6Lyd1g2/ed67oU1eFzL0r9WL7ZzscD+/N6i3dWumGE1Un4f7Amf+w== - -"@esbuild/linux-ppc64@0.19.12": - version "0.19.12" - resolved "https://registry.yarnpkg.com/@esbuild/linux-ppc64/-/linux-ppc64-0.19.12.tgz#adb67dadb73656849f63cd522f5ecb351dd8dee8" - integrity sha512-nYJA2/QPimDQOh1rKWedNOe3Gfc8PabU7HT3iXWtNUbRzXS9+vgB0Fjaqr//XNbd82mCxHzik2qotuI89cfixg== - -"@esbuild/linux-riscv64@0.19.12": - version "0.19.12" - resolved "https://registry.yarnpkg.com/@esbuild/linux-riscv64/-/linux-riscv64-0.19.12.tgz#11bc0698bf0a2abf8727f1c7ace2112612c15adf" - integrity sha512-2MueBrlPQCw5dVJJpQdUYgeqIzDQgw3QtiAHUC4RBz9FXPrskyyU3VI1hw7C0BSKB9OduwSJ79FTCqtGMWqJHg== - -"@esbuild/linux-s390x@0.19.12": - version "0.19.12" - resolved "https://registry.yarnpkg.com/@esbuild/linux-s390x/-/linux-s390x-0.19.12.tgz#e86fb8ffba7c5c92ba91fc3b27ed5a70196c3cc8" - integrity sha512-+Pil1Nv3Umes4m3AZKqA2anfhJiVmNCYkPchwFJNEJN5QxmTs1uzyy4TvmDrCRNT2ApwSari7ZIgrPeUx4UZDg== - -"@esbuild/linux-x64@0.19.12": - version "0.19.12" - resolved "https://registry.yarnpkg.com/@esbuild/linux-x64/-/linux-x64-0.19.12.tgz#5f37cfdc705aea687dfe5dfbec086a05acfe9c78" - integrity sha512-B71g1QpxfwBvNrfyJdVDexenDIt1CiDN1TIXLbhOw0KhJzE78KIFGX6OJ9MrtC0oOqMWf+0xop4qEU8JrJTwCg== - -"@esbuild/netbsd-x64@0.19.12": - version "0.19.12" - resolved "https://registry.yarnpkg.com/@esbuild/netbsd-x64/-/netbsd-x64-0.19.12.tgz#29da566a75324e0d0dd7e47519ba2f7ef168657b" - integrity sha512-3ltjQ7n1owJgFbuC61Oj++XhtzmymoCihNFgT84UAmJnxJfm4sYCiSLTXZtE00VWYpPMYc+ZQmB6xbSdVh0JWA== - -"@esbuild/openbsd-x64@0.19.12": - version "0.19.12" - resolved "https://registry.yarnpkg.com/@esbuild/openbsd-x64/-/openbsd-x64-0.19.12.tgz#306c0acbdb5a99c95be98bdd1d47c916e7dc3ff0" - integrity sha512-RbrfTB9SWsr0kWmb9srfF+L933uMDdu9BIzdA7os2t0TXhCRjrQyCeOt6wVxr79CKD4c+p+YhCj31HBkYcXebw== - -"@esbuild/sunos-x64@0.19.12": - version "0.19.12" - resolved "https://registry.yarnpkg.com/@esbuild/sunos-x64/-/sunos-x64-0.19.12.tgz#0933eaab9af8b9b2c930236f62aae3fc593faf30" - integrity sha512-HKjJwRrW8uWtCQnQOz9qcU3mUZhTUQvi56Q8DPTLLB+DawoiQdjsYq+j+D3s9I8VFtDr+F9CjgXKKC4ss89IeA== - -"@esbuild/win32-arm64@0.19.12": - version "0.19.12" - resolved "https://registry.yarnpkg.com/@esbuild/win32-arm64/-/win32-arm64-0.19.12.tgz#773bdbaa1971b36db2f6560088639ccd1e6773ae" - integrity sha512-URgtR1dJnmGvX864pn1B2YUYNzjmXkuJOIqG2HdU62MVS4EHpU2946OZoTMnRUHklGtJdJZ33QfzdjGACXhn1A== - -"@esbuild/win32-ia32@0.19.12": - version "0.19.12" - resolved "https://registry.yarnpkg.com/@esbuild/win32-ia32/-/win32-ia32-0.19.12.tgz#000516cad06354cc84a73f0943a4aa690ef6fd67" - integrity sha512-+ZOE6pUkMOJfmxmBZElNOx72NKpIa/HFOMGzu8fqzQJ5kgf6aTGrcJaFsNiVMH4JKpMipyK+7k0n2UXN7a8YKQ== - -"@esbuild/win32-x64@0.19.12": - version "0.19.12" - resolved "https://registry.yarnpkg.com/@esbuild/win32-x64/-/win32-x64-0.19.12.tgz#c57c8afbb4054a3ab8317591a0b7320360b444ae" - integrity sha512-T1QyPSDCyMXaO3pzBkF96E8xMkiRYbUEZADd29SyPGabqxMViNoii+NcK7eWJAEoU6RZyEm5lVSIjTmcdoB9HA== - -"@jridgewell/gen-mapping@^0.3.0": - version "0.3.3" - resolved "https://registry.yarnpkg.com/@jridgewell/gen-mapping/-/gen-mapping-0.3.3.tgz#7e02e6eb5df901aaedb08514203b096614024098" - integrity sha512-HLhSWOLRi875zjjMG/r+Nv0oCW8umGb0BgEhyX3dDX3egwZtB8PqLnjz3yedt8R5StBrzcg4aBpnh8UA9D1BoQ== - dependencies: - "@jridgewell/set-array" "^1.0.1" +"@esbuild/aix-ppc64@0.21.5": + version "0.21.5" + resolved "https://registry.yarnpkg.com/@esbuild/aix-ppc64/-/aix-ppc64-0.21.5.tgz#c7184a326533fcdf1b8ee0733e21c713b975575f" + integrity sha512-1SDgH6ZSPTlggy1yI6+Dbkiz8xzpHJEVAlF/AM1tHPLsf5STom9rwtjE4hKAF20FfXXNTFqEYXyJNWh1GiZedQ== + +"@esbuild/android-arm64@0.21.5": + version "0.21.5" + resolved "https://registry.yarnpkg.com/@esbuild/android-arm64/-/android-arm64-0.21.5.tgz#09d9b4357780da9ea3a7dfb833a1f1ff439b4052" + integrity sha512-c0uX9VAUBQ7dTDCjq+wdyGLowMdtR/GoC2U5IYk/7D1H1JYC0qseD7+11iMP2mRLN9RcCMRcjC4YMclCzGwS/A== + +"@esbuild/android-arm@0.21.5": + version "0.21.5" + resolved "https://registry.yarnpkg.com/@esbuild/android-arm/-/android-arm-0.21.5.tgz#9b04384fb771926dfa6d7ad04324ecb2ab9b2e28" + integrity sha512-vCPvzSjpPHEi1siZdlvAlsPxXl7WbOVUBBAowWug4rJHb68Ox8KualB+1ocNvT5fjv6wpkX6o/iEpbDrf68zcg== + +"@esbuild/android-x64@0.21.5": + version "0.21.5" + resolved "https://registry.yarnpkg.com/@esbuild/android-x64/-/android-x64-0.21.5.tgz#29918ec2db754cedcb6c1b04de8cd6547af6461e" + integrity sha512-D7aPRUUNHRBwHxzxRvp856rjUHRFW1SdQATKXH2hqA0kAZb1hKmi02OpYRacl0TxIGz/ZmXWlbZgjwWYaCakTA== + +"@esbuild/darwin-arm64@0.21.5": + version "0.21.5" + resolved "https://registry.yarnpkg.com/@esbuild/darwin-arm64/-/darwin-arm64-0.21.5.tgz#e495b539660e51690f3928af50a76fb0a6ccff2a" + integrity sha512-DwqXqZyuk5AiWWf3UfLiRDJ5EDd49zg6O9wclZ7kUMv2WRFr4HKjXp/5t8JZ11QbQfUS6/cRCKGwYhtNAY88kQ== + +"@esbuild/darwin-x64@0.21.5": + version "0.21.5" + resolved "https://registry.yarnpkg.com/@esbuild/darwin-x64/-/darwin-x64-0.21.5.tgz#c13838fa57372839abdddc91d71542ceea2e1e22" + integrity sha512-se/JjF8NlmKVG4kNIuyWMV/22ZaerB+qaSi5MdrXtd6R08kvs2qCN4C09miupktDitvh8jRFflwGFBQcxZRjbw== + +"@esbuild/freebsd-arm64@0.21.5": + version "0.21.5" + resolved "https://registry.yarnpkg.com/@esbuild/freebsd-arm64/-/freebsd-arm64-0.21.5.tgz#646b989aa20bf89fd071dd5dbfad69a3542e550e" + integrity sha512-5JcRxxRDUJLX8JXp/wcBCy3pENnCgBR9bN6JsY4OmhfUtIHe3ZW0mawA7+RDAcMLrMIZaf03NlQiX9DGyB8h4g== + +"@esbuild/freebsd-x64@0.21.5": + version "0.21.5" + resolved "https://registry.yarnpkg.com/@esbuild/freebsd-x64/-/freebsd-x64-0.21.5.tgz#aa615cfc80af954d3458906e38ca22c18cf5c261" + integrity sha512-J95kNBj1zkbMXtHVH29bBriQygMXqoVQOQYA+ISs0/2l3T9/kj42ow2mpqerRBxDJnmkUDCaQT/dfNXWX/ZZCQ== + +"@esbuild/linux-arm64@0.21.5": + version "0.21.5" + resolved "https://registry.yarnpkg.com/@esbuild/linux-arm64/-/linux-arm64-0.21.5.tgz#70ac6fa14f5cb7e1f7f887bcffb680ad09922b5b" + integrity sha512-ibKvmyYzKsBeX8d8I7MH/TMfWDXBF3db4qM6sy+7re0YXya+K1cem3on9XgdT2EQGMu4hQyZhan7TeQ8XkGp4Q== + +"@esbuild/linux-arm@0.21.5": + version "0.21.5" + resolved "https://registry.yarnpkg.com/@esbuild/linux-arm/-/linux-arm-0.21.5.tgz#fc6fd11a8aca56c1f6f3894f2bea0479f8f626b9" + integrity sha512-bPb5AHZtbeNGjCKVZ9UGqGwo8EUu4cLq68E95A53KlxAPRmUyYv2D6F0uUI65XisGOL1hBP5mTronbgo+0bFcA== + +"@esbuild/linux-ia32@0.21.5": + version "0.21.5" + resolved "https://registry.yarnpkg.com/@esbuild/linux-ia32/-/linux-ia32-0.21.5.tgz#3271f53b3f93e3d093d518d1649d6d68d346ede2" + integrity sha512-YvjXDqLRqPDl2dvRODYmmhz4rPeVKYvppfGYKSNGdyZkA01046pLWyRKKI3ax8fbJoK5QbxblURkwK/MWY18Tg== + +"@esbuild/linux-loong64@0.21.5": + version "0.21.5" + resolved "https://registry.yarnpkg.com/@esbuild/linux-loong64/-/linux-loong64-0.21.5.tgz#ed62e04238c57026aea831c5a130b73c0f9f26df" + integrity sha512-uHf1BmMG8qEvzdrzAqg2SIG/02+4/DHB6a9Kbya0XDvwDEKCoC8ZRWI5JJvNdUjtciBGFQ5PuBlpEOXQj+JQSg== + +"@esbuild/linux-mips64el@0.21.5": + version "0.21.5" + resolved "https://registry.yarnpkg.com/@esbuild/linux-mips64el/-/linux-mips64el-0.21.5.tgz#e79b8eb48bf3b106fadec1ac8240fb97b4e64cbe" + integrity sha512-IajOmO+KJK23bj52dFSNCMsz1QP1DqM6cwLUv3W1QwyxkyIWecfafnI555fvSGqEKwjMXVLokcV5ygHW5b3Jbg== + +"@esbuild/linux-ppc64@0.21.5": + version "0.21.5" + resolved "https://registry.yarnpkg.com/@esbuild/linux-ppc64/-/linux-ppc64-0.21.5.tgz#5f2203860a143b9919d383ef7573521fb154c3e4" + integrity sha512-1hHV/Z4OEfMwpLO8rp7CvlhBDnjsC3CttJXIhBi+5Aj5r+MBvy4egg7wCbe//hSsT+RvDAG7s81tAvpL2XAE4w== + +"@esbuild/linux-riscv64@0.21.5": + version "0.21.5" + resolved "https://registry.yarnpkg.com/@esbuild/linux-riscv64/-/linux-riscv64-0.21.5.tgz#07bcafd99322d5af62f618cb9e6a9b7f4bb825dc" + integrity sha512-2HdXDMd9GMgTGrPWnJzP2ALSokE/0O5HhTUvWIbD3YdjME8JwvSCnNGBnTThKGEB91OZhzrJ4qIIxk/SBmyDDA== + +"@esbuild/linux-s390x@0.21.5": + version "0.21.5" + resolved "https://registry.yarnpkg.com/@esbuild/linux-s390x/-/linux-s390x-0.21.5.tgz#b7ccf686751d6a3e44b8627ababc8be3ef62d8de" + integrity sha512-zus5sxzqBJD3eXxwvjN1yQkRepANgxE9lgOW2qLnmr8ikMTphkjgXu1HR01K4FJg8h1kEEDAqDcZQtbrRnB41A== + +"@esbuild/linux-x64@0.21.5": + version "0.21.5" + resolved "https://registry.yarnpkg.com/@esbuild/linux-x64/-/linux-x64-0.21.5.tgz#6d8f0c768e070e64309af8004bb94e68ab2bb3b0" + integrity sha512-1rYdTpyv03iycF1+BhzrzQJCdOuAOtaqHTWJZCWvijKD2N5Xu0TtVC8/+1faWqcP9iBCWOmjmhoH94dH82BxPQ== + +"@esbuild/netbsd-x64@0.21.5": + version "0.21.5" + resolved "https://registry.yarnpkg.com/@esbuild/netbsd-x64/-/netbsd-x64-0.21.5.tgz#bbe430f60d378ecb88decb219c602667387a6047" + integrity sha512-Woi2MXzXjMULccIwMnLciyZH4nCIMpWQAs049KEeMvOcNADVxo0UBIQPfSmxB3CWKedngg7sWZdLvLczpe0tLg== + +"@esbuild/openbsd-x64@0.21.5": + version "0.21.5" + resolved "https://registry.yarnpkg.com/@esbuild/openbsd-x64/-/openbsd-x64-0.21.5.tgz#99d1cf2937279560d2104821f5ccce220cb2af70" + integrity sha512-HLNNw99xsvx12lFBUwoT8EVCsSvRNDVxNpjZ7bPn947b8gJPzeHWyNVhFsaerc0n3TsbOINvRP2byTZ5LKezow== + +"@esbuild/sunos-x64@0.21.5": + version "0.21.5" + resolved "https://registry.yarnpkg.com/@esbuild/sunos-x64/-/sunos-x64-0.21.5.tgz#08741512c10d529566baba837b4fe052c8f3487b" + integrity sha512-6+gjmFpfy0BHU5Tpptkuh8+uw3mnrvgs+dSPQXQOv3ekbordwnzTVEb4qnIvQcYXq6gzkyTnoZ9dZG+D4garKg== + +"@esbuild/win32-arm64@0.21.5": + version "0.21.5" + resolved "https://registry.yarnpkg.com/@esbuild/win32-arm64/-/win32-arm64-0.21.5.tgz#675b7385398411240735016144ab2e99a60fc75d" + integrity sha512-Z0gOTd75VvXqyq7nsl93zwahcTROgqvuAcYDUr+vOv8uHhNSKROyU961kgtCD1e95IqPKSQKH7tBTslnS3tA8A== + +"@esbuild/win32-ia32@0.21.5": + version "0.21.5" + resolved "https://registry.yarnpkg.com/@esbuild/win32-ia32/-/win32-ia32-0.21.5.tgz#1bfc3ce98aa6ca9a0969e4d2af72144c59c1193b" + integrity sha512-SWXFF1CL2RVNMaVs+BBClwtfZSvDgtL//G/smwAc5oVK/UPu2Gu9tIaRgFmYFFKrmg3SyAjSrElf0TiJ1v8fYA== + +"@esbuild/win32-x64@0.21.5": + version "0.21.5" + resolved "https://registry.yarnpkg.com/@esbuild/win32-x64/-/win32-x64-0.21.5.tgz#acad351d582d157bb145535db2a6ff53dd514b5c" + integrity sha512-tQd/1efJuzPC6rCFwEvLtci/xNFcTZknmXs98FYDfGE4wP9ClFV98nyKrzJKVPMhdDnjzLhdUyMX4PsQAPjwIw== + +"@jridgewell/gen-mapping@^0.3.5": + version "0.3.5" + resolved "https://registry.yarnpkg.com/@jridgewell/gen-mapping/-/gen-mapping-0.3.5.tgz#dcce6aff74bdf6dad1a95802b69b04a2fcb1fb36" + integrity sha512-IzL8ZoEDIBRWEzlCcRhOaCupYyN5gdIK+Q6fbFdPDg6HqX6jpkItn7DFIpW9LQzXG6Df9sA7+OKnq0qlz/GaQg== + dependencies: + "@jridgewell/set-array" "^1.2.1" "@jridgewell/sourcemap-codec" "^1.4.10" - "@jridgewell/trace-mapping" "^0.3.9" + "@jridgewell/trace-mapping" "^0.3.24" "@jridgewell/resolve-uri@^3.1.0": version "3.1.2" resolved "https://registry.yarnpkg.com/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz#7a0ee601f60f99a20c7c7c5ff0c80388c1189bd6" integrity sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw== -"@jridgewell/set-array@^1.0.1": - version "1.1.2" - resolved "https://registry.yarnpkg.com/@jridgewell/set-array/-/set-array-1.1.2.tgz#7c6cf998d6d20b914c0a55a91ae928ff25965e72" - integrity sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw== +"@jridgewell/set-array@^1.2.1": + version "1.2.1" + resolved "https://registry.yarnpkg.com/@jridgewell/set-array/-/set-array-1.2.1.tgz#558fb6472ed16a4c850b889530e6b36438c49280" + integrity sha512-R8gLRTZeyp03ymzP/6Lil/28tGeGEzhx1q2k703KGWRAI1VdvPIXdG70VJc2pAMw3NA6JKL5hhFu1sJX0Mnn/A== "@jridgewell/source-map@^0.3.3": - version "0.3.5" - resolved "https://registry.yarnpkg.com/@jridgewell/source-map/-/source-map-0.3.5.tgz#a3bb4d5c6825aab0d281268f47f6ad5853431e91" - integrity sha512-UTYAUj/wviwdsMfzoSJspJxbkH5o1snzwX0//0ENX1u/55kkZZkcTZP6u9bwKGkv+dkk9at4m1Cpt0uY80kcpQ== + version "0.3.6" + resolved "https://registry.yarnpkg.com/@jridgewell/source-map/-/source-map-0.3.6.tgz#9d71ca886e32502eb9362c9a74a46787c36df81a" + integrity sha512-1ZJTZebgqllO79ue2bm3rIGud/bOe0pP5BjSRCRxxYkEZS8STV7zN84UBbiYu7jy+eCKSnVIUgoWWE/tt+shMQ== dependencies: - "@jridgewell/gen-mapping" "^0.3.0" - "@jridgewell/trace-mapping" "^0.3.9" + "@jridgewell/gen-mapping" "^0.3.5" + "@jridgewell/trace-mapping" "^0.3.25" "@jridgewell/sourcemap-codec@^1.4.10", "@jridgewell/sourcemap-codec@^1.4.14": - version "1.4.15" - resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz#d7c6e6755c78567a951e04ab52ef0fd26de59f32" - integrity sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg== + version "1.5.0" + resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.0.tgz#3188bcb273a414b0d215fd22a58540b989b9409a" + integrity sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ== -"@jridgewell/trace-mapping@^0.3.9": - version "0.3.22" - resolved "https://registry.yarnpkg.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.22.tgz#72a621e5de59f5f1ef792d0793a82ee20f645e4c" - integrity sha512-Wf963MzWtA2sjrNt+g18IAln9lKnlRp+K2eH4jjIoF1wYeq3aMREpG09xhlhdzS0EjwU7qmUJYangWa+151vZw== +"@jridgewell/trace-mapping@^0.3.24", "@jridgewell/trace-mapping@^0.3.25": + version "0.3.25" + resolved "https://registry.yarnpkg.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.25.tgz#15f190e98895f3fc23276ee14bc76b675c2e50f0" + integrity sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ== dependencies: "@jridgewell/resolve-uri" "^3.1.0" "@jridgewell/sourcemap-codec" "^1.4.14" @@ -186,87 +186,102 @@ estree-walker "^2.0.1" picomatch "^2.2.2" -"@rollup/rollup-android-arm-eabi@4.12.0": - version "4.12.0" - resolved "https://registry.yarnpkg.com/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.12.0.tgz#38c3abd1955a3c21d492af6b1a1dca4bb1d894d6" - integrity sha512-+ac02NL/2TCKRrJu2wffk1kZ+RyqxVUlbjSagNgPm94frxtr+XDL12E5Ll1enWskLrtrZ2r8L3wED1orIibV/w== - -"@rollup/rollup-android-arm64@4.12.0": - version "4.12.0" - resolved "https://registry.yarnpkg.com/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.12.0.tgz#3822e929f415627609e53b11cec9a4be806de0e2" - integrity sha512-OBqcX2BMe6nvjQ0Nyp7cC90cnumt8PXmO7Dp3gfAju/6YwG0Tj74z1vKrfRz7qAv23nBcYM8BCbhrsWqO7PzQQ== - -"@rollup/rollup-darwin-arm64@4.12.0": - version "4.12.0" - resolved "https://registry.yarnpkg.com/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.12.0.tgz#6c082de71f481f57df6cfa3701ab2a7afde96f69" - integrity sha512-X64tZd8dRE/QTrBIEs63kaOBG0b5GVEd3ccoLtyf6IdXtHdh8h+I56C2yC3PtC9Ucnv0CpNFJLqKFVgCYe0lOQ== - -"@rollup/rollup-darwin-x64@4.12.0": - version "4.12.0" - resolved "https://registry.yarnpkg.com/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.12.0.tgz#c34ca0d31f3c46a22c9afa0e944403eea0edcfd8" - integrity sha512-cc71KUZoVbUJmGP2cOuiZ9HSOP14AzBAThn3OU+9LcA1+IUqswJyR1cAJj3Mg55HbjZP6OLAIscbQsQLrpgTOg== - -"@rollup/rollup-linux-arm-gnueabihf@4.12.0": - version "4.12.0" - resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.12.0.tgz#48e899c1e438629c072889b824a98787a7c2362d" - integrity sha512-a6w/Y3hyyO6GlpKL2xJ4IOh/7d+APaqLYdMf86xnczU3nurFTaVN9s9jOXQg97BE4nYm/7Ga51rjec5nfRdrvA== - -"@rollup/rollup-linux-arm64-gnu@4.12.0": - version "4.12.0" - resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.12.0.tgz#788c2698a119dc229062d40da6ada8a090a73a68" - integrity sha512-0fZBq27b+D7Ar5CQMofVN8sggOVhEtzFUwOwPppQt0k+VR+7UHMZZY4y+64WJ06XOhBTKXtQB/Sv0NwQMXyNAA== - -"@rollup/rollup-linux-arm64-musl@4.12.0": - version "4.12.0" - resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.12.0.tgz#3882a4e3a564af9e55804beeb67076857b035ab7" - integrity sha512-eTvzUS3hhhlgeAv6bfigekzWZjaEX9xP9HhxB0Dvrdbkk5w/b+1Sxct2ZuDxNJKzsRStSq1EaEkVSEe7A7ipgQ== - -"@rollup/rollup-linux-riscv64-gnu@4.12.0": - version "4.12.0" - resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.12.0.tgz#0c6ad792e1195c12bfae634425a3d2aa0fe93ab7" - integrity sha512-ix+qAB9qmrCRiaO71VFfY8rkiAZJL8zQRXveS27HS+pKdjwUfEhqo2+YF2oI+H/22Xsiski+qqwIBxVewLK7sw== - -"@rollup/rollup-linux-x64-gnu@4.12.0": - version "4.12.0" - resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.12.0.tgz#9d62485ea0f18d8674033b57aa14fb758f6ec6e3" - integrity sha512-TenQhZVOtw/3qKOPa7d+QgkeM6xY0LtwzR8OplmyL5LrgTWIXpTQg2Q2ycBf8jm+SFW2Wt/DTn1gf7nFp3ssVA== - -"@rollup/rollup-linux-x64-musl@4.12.0": - version "4.12.0" - resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.12.0.tgz#50e8167e28b33c977c1f813def2b2074d1435e05" - integrity sha512-LfFdRhNnW0zdMvdCb5FNuWlls2WbbSridJvxOvYWgSBOYZtgBfW9UGNJG//rwMqTX1xQE9BAodvMH9tAusKDUw== - -"@rollup/rollup-win32-arm64-msvc@4.12.0": - version "4.12.0" - resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.12.0.tgz#68d233272a2004429124494121a42c4aebdc5b8e" - integrity sha512-JPDxovheWNp6d7AHCgsUlkuCKvtu3RB55iNEkaQcf0ttsDU/JZF+iQnYcQJSk/7PtT4mjjVG8N1kpwnI9SLYaw== - -"@rollup/rollup-win32-ia32-msvc@4.12.0": - version "4.12.0" - resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.12.0.tgz#366ca62221d1689e3b55a03f4ae12ae9ba595d40" - integrity sha512-fjtuvMWRGJn1oZacG8IPnzIV6GF2/XG+h71FKn76OYFqySXInJtseAqdprVTDTyqPxQOG9Exak5/E9Z3+EJ8ZA== - -"@rollup/rollup-win32-x64-msvc@4.12.0": - version "4.12.0" - resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.12.0.tgz#9ffdf9ed133a7464f4ae187eb9e1294413fab235" - integrity sha512-ZYmr5mS2wd4Dew/JjT0Fqi2NPB/ZhZ2VvPp7SmvPZb4Y1CG/LRcS6tcRo2cYU7zLK5A7cdbhWnnWmUjoI4qapg== +"@rollup/rollup-android-arm-eabi@4.21.2": + version "4.21.2" + resolved "https://registry.yarnpkg.com/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.21.2.tgz#0412834dc423d1ff7be4cb1fc13a86a0cd262c11" + integrity sha512-fSuPrt0ZO8uXeS+xP3b+yYTCBUd05MoSp2N/MFOgjhhUhMmchXlpTQrTpI8T+YAwAQuK7MafsCOxW7VrPMrJcg== + +"@rollup/rollup-android-arm64@4.21.2": + version "4.21.2" + resolved "https://registry.yarnpkg.com/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.21.2.tgz#baf1a014b13654f3b9e835388df9caf8c35389cb" + integrity sha512-xGU5ZQmPlsjQS6tzTTGwMsnKUtu0WVbl0hYpTPauvbRAnmIvpInhJtgjj3mcuJpEiuUw4v1s4BimkdfDWlh7gA== + +"@rollup/rollup-darwin-arm64@4.21.2": + version "4.21.2" + resolved "https://registry.yarnpkg.com/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.21.2.tgz#0a2c364e775acdf1172fe3327662eec7c46e55b1" + integrity sha512-99AhQ3/ZMxU7jw34Sq8brzXqWH/bMnf7ZVhvLk9QU2cOepbQSVTns6qoErJmSiAvU3InRqC2RRZ5ovh1KN0d0Q== + +"@rollup/rollup-darwin-x64@4.21.2": + version "4.21.2" + resolved "https://registry.yarnpkg.com/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.21.2.tgz#a972db75890dfab8df0da228c28993220a468c42" + integrity sha512-ZbRaUvw2iN/y37x6dY50D8m2BnDbBjlnMPotDi/qITMJ4sIxNY33HArjikDyakhSv0+ybdUxhWxE6kTI4oX26w== + +"@rollup/rollup-linux-arm-gnueabihf@4.21.2": + version "4.21.2" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.21.2.tgz#1609d0630ef61109dd19a278353e5176d92e30a1" + integrity sha512-ztRJJMiE8nnU1YFcdbd9BcH6bGWG1z+jP+IPW2oDUAPxPjo9dverIOyXz76m6IPA6udEL12reYeLojzW2cYL7w== + +"@rollup/rollup-linux-arm-musleabihf@4.21.2": + version "4.21.2" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.21.2.tgz#3c1dca5f160aa2e79e4b20ff6395eab21804f266" + integrity sha512-flOcGHDZajGKYpLV0JNc0VFH361M7rnV1ee+NTeC/BQQ1/0pllYcFmxpagltANYt8FYf9+kL6RSk80Ziwyhr7w== + +"@rollup/rollup-linux-arm64-gnu@4.21.2": + version "4.21.2" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.21.2.tgz#c2fe376e8b04eafb52a286668a8df7c761470ac7" + integrity sha512-69CF19Kp3TdMopyteO/LJbWufOzqqXzkrv4L2sP8kfMaAQ6iwky7NoXTp7bD6/irKgknDKM0P9E/1l5XxVQAhw== + +"@rollup/rollup-linux-arm64-musl@4.21.2": + version "4.21.2" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.21.2.tgz#e62a4235f01e0f66dbba587c087ca6db8008ec80" + integrity sha512-48pD/fJkTiHAZTnZwR0VzHrao70/4MlzJrq0ZsILjLW/Ab/1XlVUStYyGt7tdyIiVSlGZbnliqmult/QGA2O2w== + +"@rollup/rollup-linux-powerpc64le-gnu@4.21.2": + version "4.21.2" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.21.2.tgz#24b3457e75ee9ae5b1c198bd39eea53222a74e54" + integrity sha512-cZdyuInj0ofc7mAQpKcPR2a2iu4YM4FQfuUzCVA2u4HI95lCwzjoPtdWjdpDKyHxI0UO82bLDoOaLfpZ/wviyQ== + +"@rollup/rollup-linux-riscv64-gnu@4.21.2": + version "4.21.2" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.21.2.tgz#38edfba9620fe2ca8116c97e02bd9f2d606bde09" + integrity sha512-RL56JMT6NwQ0lXIQmMIWr1SW28z4E4pOhRRNqwWZeXpRlykRIlEpSWdsgNWJbYBEWD84eocjSGDu/XxbYeCmwg== + +"@rollup/rollup-linux-s390x-gnu@4.21.2": + version "4.21.2" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.21.2.tgz#a3bfb8bc5f1e802f8c76cff4a4be2e9f9ac36a18" + integrity sha512-PMxkrWS9z38bCr3rWvDFVGD6sFeZJw4iQlhrup7ReGmfn7Oukrr/zweLhYX6v2/8J6Cep9IEA/SmjXjCmSbrMQ== + +"@rollup/rollup-linux-x64-gnu@4.21.2": + version "4.21.2" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.21.2.tgz#0dadf34be9199fcdda44b5985a086326344f30ad" + integrity sha512-B90tYAUoLhU22olrafY3JQCFLnT3NglazdwkHyxNDYF/zAxJt5fJUB/yBoWFoIQ7SQj+KLe3iL4BhOMa9fzgpw== + +"@rollup/rollup-linux-x64-musl@4.21.2": + version "4.21.2" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.21.2.tgz#7b7deddce240400eb87f2406a445061b4fed99a8" + integrity sha512-7twFizNXudESmC9oneLGIUmoHiiLppz/Xs5uJQ4ShvE6234K0VB1/aJYU3f/4g7PhssLGKBVCC37uRkkOi8wjg== + +"@rollup/rollup-win32-arm64-msvc@4.21.2": + version "4.21.2" + resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.21.2.tgz#a0ca0c5149c2cfb26fab32e6ba3f16996fbdb504" + integrity sha512-9rRero0E7qTeYf6+rFh3AErTNU1VCQg2mn7CQcI44vNUWM9Ze7MSRS/9RFuSsox+vstRt97+x3sOhEey024FRQ== + +"@rollup/rollup-win32-ia32-msvc@4.21.2": + version "4.21.2" + resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.21.2.tgz#aae2886beec3024203dbb5569db3a137bc385f8e" + integrity sha512-5rA4vjlqgrpbFVVHX3qkrCo/fZTj1q0Xxpg+Z7yIo3J2AilW7t2+n6Q8Jrx+4MrYpAnjttTYF8rr7bP46BPzRw== + +"@rollup/rollup-win32-x64-msvc@4.21.2": + version "4.21.2" + resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.21.2.tgz#e4291e3c1bc637083f87936c333cdbcad22af63b" + integrity sha512-6UUxd0+SKomjdzuAcp+HAmxw1FlGBnl1v2yEPSabtx4lBfdXHDVsW7+lQkgz9cNFJGY3AWR7+V8P5BqkD9L9nA== "@types/estree@1.0.5": version "1.0.5" resolved "https://registry.yarnpkg.com/@types/estree/-/estree-1.0.5.tgz#a6ce3e556e00fd9895dd872dd172ad0d4bd687f4" integrity sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw== -"@types/node@^20.11.24": - version "20.11.24" - resolved "https://registry.yarnpkg.com/@types/node/-/node-20.11.24.tgz#cc207511104694e84e9fb17f9a0c4c42d4517792" - integrity sha512-Kza43ewS3xoLgCEpQrsT+xRo/EJej1y0kVYGiLFE1NEODXGzTfwiC6tXTLMQskn1X4/Rjlh0MQUvx9W+L9long== +"@types/node@^18.0.0": + version "18.19.50" + resolved "https://registry.yarnpkg.com/@types/node/-/node-18.19.50.tgz#8652b34ee7c0e7e2004b3f08192281808d41bf5a" + integrity sha512-xonK+NRrMBRtkL1hVCc3G+uXtjh1Al4opBLjqVmipe5ZAaBYWW6cNAiBVZ1BvmkBhep698rP3UM3aRAdSALuhg== dependencies: undici-types "~5.26.4" acorn@^8.8.2: - version "8.11.3" - resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.11.3.tgz#71e0b14e13a4ec160724b38fb7b0f233b1b81d7a" - integrity sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg== + version "8.12.1" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.12.1.tgz#71616bdccbe25e27a54439e0046e89ca76df2248" + integrity sha512-tcpGyI9zbizT9JbV6oYE477V6mTlXvvi0T0G3SNIYE2apm/G5huBa1+K89VGeovbg+jycCrfhl3ADxErOuO6Jg== ansi-styles@^4.1.0: version "4.3.0" @@ -276,9 +291,9 @@ ansi-styles@^4.1.0: color-convert "^2.0.1" async@^3.2.3: - version "3.2.5" - resolved "https://registry.yarnpkg.com/async/-/async-3.2.5.tgz#ebd52a8fdaf7a2289a24df399f8d8485c8a46b66" - integrity sha512-baNZyqaaLhyLVKm/DlvdW051MSgO6b8eVfIezl9E5PqWxFgzLm/wQntEW4zOytVburDEr0JlALEpdOFwvErLsg== + version "3.2.6" + resolved "https://registry.yarnpkg.com/async/-/async-3.2.6.tgz#1b0728e14929d51b85b449b7f06e27c1145e38ce" + integrity sha512-htCUDlxyyCLMgaM3xXg0C0LW2xqfuQ6p05pCEIsXuyQ+a1koYKTuBMzRNwmybfLgvJDMd0r1LTn4+E0Ti6C2AA== balanced-match@^1.0.0: version "1.0.2" @@ -305,12 +320,12 @@ brace-expansion@^2.0.1: dependencies: balanced-match "^1.0.0" -braces@^3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107" - integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A== +braces@^3.0.3: + version "3.0.3" + resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.3.tgz#490332f40919452272d55a8480adc0c441358789" + integrity sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA== dependencies: - fill-range "^7.0.1" + fill-range "^7.1.1" buffer-from@^1.0.0: version "1.1.2" @@ -442,14 +457,14 @@ dotenv-expand@^8.0.2: integrity sha512-SErOMvge0ZUyWd5B0NXMQlDkN+8r+HhVUsxgOO7IoPDOdDRD2JjExpN6y3KnFR66jsJMwSn1pqIivhU5rcJiNg== dotenv@^16.0.0: - version "16.4.4" - resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-16.4.4.tgz#a26e7bb95ebd36272ebb56edb80b826aecf224c1" - integrity sha512-XvPXc8XAQThSjAbY6cQ/9PcBXmFoWuw1sQ3b8HqUCR6ziGXjkTi//kB9SWa2UwqlgdAIuRqAa/9hVljzPehbYg== + version "16.4.5" + resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-16.4.5.tgz#cdd3b3b604cb327e286b4762e13502f717cb099f" + integrity sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg== ejs@^3.1.6: - version "3.1.9" - resolved "https://registry.yarnpkg.com/ejs/-/ejs-3.1.9.tgz#03c9e8777fe12686a9effcef22303ca3d8eeb361" - integrity sha512-rC+QVNMJWv+MtPgkt0y+0rVEIdbtxVADApW9JXrUVlzHetgcyczP/E7DJmWJ4fJCZF2cPcBk0laWO9ZHMG3DmQ== + version "3.1.10" + resolved "https://registry.yarnpkg.com/ejs/-/ejs-3.1.10.tgz#69ab8358b14e896f80cc39e62087b88500c3ac3b" + integrity sha512-UeJmFfOrAQS8OJWPZ4qtgHyWExa088/MtK5UEyoJGFH67cDEXkZSviOiKRCZ4Xij0zxI3JECgYs3oKx+AizQBA== dependencies: jake "^10.8.5" @@ -458,34 +473,34 @@ entities@^2.0.0: resolved "https://registry.yarnpkg.com/entities/-/entities-2.2.0.tgz#098dc90ebb83d8dffa089d55256b351d34c4da55" integrity sha512-p92if5Nz619I0w+akJrLZH0MX0Pb5DX39XOwQTtXSdQQOaYH03S1uIQp4mhOZtAXrxq4ViO67YTiLBo2638o9A== -esbuild@^0.19.3: - version "0.19.12" - resolved "https://registry.yarnpkg.com/esbuild/-/esbuild-0.19.12.tgz#dc82ee5dc79e82f5a5c3b4323a2a641827db3e04" - integrity sha512-aARqgq8roFBj054KvQr5f1sFu0D65G+miZRCuJyJ0G13Zwx7vRar5Zhn2tkQNzIXcBrNVsv/8stehpj+GAjgbg== +esbuild@^0.21.3: + version "0.21.5" + resolved "https://registry.yarnpkg.com/esbuild/-/esbuild-0.21.5.tgz#9ca301b120922959b766360d8ac830da0d02997d" + integrity sha512-mg3OPMV4hXywwpoDxu3Qda5xCKQi+vCTZq8S9J/EpkhB2HzKXq4SNFZE3+NK93JYxc8VMSep+lOUSC/RVKaBqw== optionalDependencies: - "@esbuild/aix-ppc64" "0.19.12" - "@esbuild/android-arm" "0.19.12" - "@esbuild/android-arm64" "0.19.12" - "@esbuild/android-x64" "0.19.12" - "@esbuild/darwin-arm64" "0.19.12" - "@esbuild/darwin-x64" "0.19.12" - "@esbuild/freebsd-arm64" "0.19.12" - "@esbuild/freebsd-x64" "0.19.12" - "@esbuild/linux-arm" "0.19.12" - "@esbuild/linux-arm64" "0.19.12" - "@esbuild/linux-ia32" "0.19.12" - "@esbuild/linux-loong64" "0.19.12" - "@esbuild/linux-mips64el" "0.19.12" - "@esbuild/linux-ppc64" "0.19.12" - "@esbuild/linux-riscv64" "0.19.12" - "@esbuild/linux-s390x" "0.19.12" - "@esbuild/linux-x64" "0.19.12" - "@esbuild/netbsd-x64" "0.19.12" - "@esbuild/openbsd-x64" "0.19.12" - "@esbuild/sunos-x64" "0.19.12" - "@esbuild/win32-arm64" "0.19.12" - "@esbuild/win32-ia32" "0.19.12" - "@esbuild/win32-x64" "0.19.12" + "@esbuild/aix-ppc64" "0.21.5" + "@esbuild/android-arm" "0.21.5" + "@esbuild/android-arm64" "0.21.5" + "@esbuild/android-x64" "0.21.5" + "@esbuild/darwin-arm64" "0.21.5" + "@esbuild/darwin-x64" "0.21.5" + "@esbuild/freebsd-arm64" "0.21.5" + "@esbuild/freebsd-x64" "0.21.5" + "@esbuild/linux-arm" "0.21.5" + "@esbuild/linux-arm64" "0.21.5" + "@esbuild/linux-ia32" "0.21.5" + "@esbuild/linux-loong64" "0.21.5" + "@esbuild/linux-mips64el" "0.21.5" + "@esbuild/linux-ppc64" "0.21.5" + "@esbuild/linux-riscv64" "0.21.5" + "@esbuild/linux-s390x" "0.21.5" + "@esbuild/linux-x64" "0.21.5" + "@esbuild/netbsd-x64" "0.21.5" + "@esbuild/openbsd-x64" "0.21.5" + "@esbuild/sunos-x64" "0.21.5" + "@esbuild/win32-arm64" "0.21.5" + "@esbuild/win32-ia32" "0.21.5" + "@esbuild/win32-x64" "0.21.5" estree-walker@^2.0.1: version "2.0.2" @@ -517,10 +532,10 @@ filelist@^1.0.4: dependencies: minimatch "^5.0.1" -fill-range@^7.0.1: - version "7.0.1" - resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.0.1.tgz#1919a6a7c75fe38b2c7c77e5198535da9acdda40" - integrity sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ== +fill-range@^7.1.1: + version "7.1.1" + resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.1.1.tgz#44265d3cac07e3ea7dc247516380643754a05292" + integrity sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg== dependencies: to-regex-range "^5.0.1" @@ -591,9 +606,9 @@ is-number@^7.0.0: integrity sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng== jake@^10.8.5: - version "10.8.7" - resolved "https://registry.yarnpkg.com/jake/-/jake-10.8.7.tgz#63a32821177940c33f356e0ba44ff9d34e1c7d8f" - integrity sha512-ZDi3aP+fG/LchyBzUM804VjddnwfSfsdeYkwt8NcbKRvo4rFkjhs456iLFn3k2ZUWvNe4i48WACDbza8fhq2+w== + version "10.9.2" + resolved "https://registry.yarnpkg.com/jake/-/jake-10.9.2.tgz#6ae487e6a69afec3a5e167628996b59f35ae2b7f" + integrity sha512-2P4SQ0HrLQ+fw6llpLnOaGAvN2Zu6778SJMrCUwns4fOoG9ayrTiZk3VV8sCPkVZF8ab0zksVpS8FDY5pRCNBA== dependencies: async "^3.2.3" chalk "^4.0.2" @@ -621,12 +636,12 @@ merge2@^1.3.0: resolved "https://registry.yarnpkg.com/merge2/-/merge2-1.4.1.tgz#4368892f885e907455a6fd7dc55c0c9d404990ae" integrity sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg== -micromatch@^4.0.4, micromatch@^4.0.5: - version "4.0.5" - resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.5.tgz#bc8999a7cbbf77cdc89f132f6e467051b49090c6" - integrity sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA== +micromatch@^4.0.4, micromatch@^4.0.7: + version "4.0.8" + resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.8.tgz#d66fa18f3a47076789320b9b1af32bd86d9fa202" + integrity sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA== dependencies: - braces "^3.0.2" + braces "^3.0.3" picomatch "^2.3.1" minimatch@^3.1.2: @@ -692,24 +707,24 @@ pathe@^0.2.0: resolved "https://registry.yarnpkg.com/pathe/-/pathe-0.2.0.tgz#30fd7bbe0a0d91f0e60bae621f5d19e9e225c339" integrity sha512-sTitTPYnn23esFR3RlqYBWn4c45WGeLcsKzQiUpXJAyfcWkolvlYpV8FLo7JishK946oQwMFUCHXQ9AjGPKExw== -picocolors@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/picocolors/-/picocolors-1.0.0.tgz#cb5bdc74ff3f51892236eaf79d68bc44564ab81c" - integrity sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ== +picocolors@^1.0.1: + version "1.1.0" + resolved "https://registry.yarnpkg.com/picocolors/-/picocolors-1.1.0.tgz#5358b76a78cde483ba5cef6a9dc9671440b27d59" + integrity sha512-TQ92mBOW0l3LeMeyLV6mzy/kWr8lkd/hp3mTg7wYK7zJhuBStmGMBG0BdeDZS/dZx1IukaX6Bk11zcln25o1Aw== picomatch@^2.2.2, picomatch@^2.3.1: version "2.3.1" resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42" integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA== -postcss@^8.4.35: - version "8.4.35" - resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.4.35.tgz#60997775689ce09011edf083a549cea44aabe2f7" - integrity sha512-u5U8qYpBCpN13BsiEB0CbR1Hhh4Gc0zLFuedrHJKMctHCHAGrMdG0PRM/KErzAL3CU6/eckEtmHNB3x6e3c0vA== +postcss@^8.4.43: + version "8.4.45" + resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.4.45.tgz#538d13d89a16ef71edbf75d895284ae06b79e603" + integrity sha512-7KTLTdzdZZYscUc65XmjFiB73vBhBfbPztCYdUNvlaso9PrzjzcmjqBPR0lNGkcVlcO4BjiO5rK/qNz+XAen1Q== dependencies: nanoid "^3.3.7" - picocolors "^1.0.0" - source-map-js "^1.0.2" + picocolors "^1.0.1" + source-map-js "^1.2.0" queue-microtask@^1.2.2: version "1.2.3" @@ -726,26 +741,29 @@ reusify@^1.0.4: resolved "https://registry.yarnpkg.com/reusify/-/reusify-1.0.4.tgz#90da382b1e126efc02146e90845a88db12925d76" integrity sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw== -rollup@^4.2.0: - version "4.12.0" - resolved "https://registry.yarnpkg.com/rollup/-/rollup-4.12.0.tgz#0b6d1e5f3d46bbcf244deec41a7421dc54cc45b5" - integrity sha512-wz66wn4t1OHIJw3+XU7mJJQV/2NAfw5OAk6G6Hoo3zcvz/XOfQ52Vgi+AN4Uxoxi0KBBwk2g8zPrTDA4btSB/Q== +rollup@^4.20.0: + version "4.21.2" + resolved "https://registry.yarnpkg.com/rollup/-/rollup-4.21.2.tgz#f41f277a448d6264e923dd1ea179f0a926aaf9b7" + integrity sha512-e3TapAgYf9xjdLvKQCkQTnbTKd4a6jwlpQSJJFokHGaX2IVjoEqkIIhiQfqsi0cdwlOD+tQGuOd5AJkc5RngBw== dependencies: "@types/estree" "1.0.5" optionalDependencies: - "@rollup/rollup-android-arm-eabi" "4.12.0" - "@rollup/rollup-android-arm64" "4.12.0" - "@rollup/rollup-darwin-arm64" "4.12.0" - "@rollup/rollup-darwin-x64" "4.12.0" - "@rollup/rollup-linux-arm-gnueabihf" "4.12.0" - "@rollup/rollup-linux-arm64-gnu" "4.12.0" - "@rollup/rollup-linux-arm64-musl" "4.12.0" - "@rollup/rollup-linux-riscv64-gnu" "4.12.0" - "@rollup/rollup-linux-x64-gnu" "4.12.0" - "@rollup/rollup-linux-x64-musl" "4.12.0" - "@rollup/rollup-win32-arm64-msvc" "4.12.0" - "@rollup/rollup-win32-ia32-msvc" "4.12.0" - "@rollup/rollup-win32-x64-msvc" "4.12.0" + "@rollup/rollup-android-arm-eabi" "4.21.2" + "@rollup/rollup-android-arm64" "4.21.2" + "@rollup/rollup-darwin-arm64" "4.21.2" + "@rollup/rollup-darwin-x64" "4.21.2" + "@rollup/rollup-linux-arm-gnueabihf" "4.21.2" + "@rollup/rollup-linux-arm-musleabihf" "4.21.2" + "@rollup/rollup-linux-arm64-gnu" "4.21.2" + "@rollup/rollup-linux-arm64-musl" "4.21.2" + "@rollup/rollup-linux-powerpc64le-gnu" "4.21.2" + "@rollup/rollup-linux-riscv64-gnu" "4.21.2" + "@rollup/rollup-linux-s390x-gnu" "4.21.2" + "@rollup/rollup-linux-x64-gnu" "4.21.2" + "@rollup/rollup-linux-x64-musl" "4.21.2" + "@rollup/rollup-win32-arm64-msvc" "4.21.2" + "@rollup/rollup-win32-ia32-msvc" "4.21.2" + "@rollup/rollup-win32-x64-msvc" "4.21.2" fsevents "~2.3.2" run-parallel@^1.1.9: @@ -755,10 +773,10 @@ run-parallel@^1.1.9: dependencies: queue-microtask "^1.2.2" -source-map-js@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/source-map-js/-/source-map-js-1.0.2.tgz#adbc361d9c62df380125e7f161f71c826f1e490c" - integrity sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw== +source-map-js@^1.2.0: + version "1.2.1" + resolved "https://registry.yarnpkg.com/source-map-js/-/source-map-js-1.2.1.tgz#1ce5650fddd87abc099eda37dcff024c2667ae46" + integrity sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA== source-map-support@~0.5.20: version "0.5.21" @@ -781,9 +799,9 @@ supports-color@^7.1.0: has-flag "^4.0.0" terser@^5.10.0: - version "5.27.1" - resolved "https://registry.yarnpkg.com/terser/-/terser-5.27.1.tgz#b0092975ea1b379d166088a1a57e32f0839d84a2" - integrity sha512-29wAr6UU/oQpnTw5HoadwjUZnFQXGdOfj0LjZ4sVxzqwHh/QVkvr7m8y9WoR4iN3FRitVduTc6KdjcW38Npsug== + version "5.31.6" + resolved "https://registry.yarnpkg.com/terser/-/terser-5.31.6.tgz#c63858a0f0703988d0266a82fcbf2d7ba76422b1" + integrity sha512-PQ4DAriWzKj+qgehQ7LK5bQqCFNMmlhjR2PFFLuqGCpuCAauxemVBWwWOxo3UIwWQx8+Pr61Df++r76wDmkQBg== dependencies: "@jridgewell/source-map" "^0.3.3" acorn "^8.8.2" @@ -798,14 +816,14 @@ to-regex-range@^5.0.1: is-number "^7.0.0" tslib@^2.0.3: - version "2.6.2" - resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.6.2.tgz#703ac29425e7b37cd6fd456e92404d46d1f3e4ae" - integrity sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q== + version "2.7.0" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.7.0.tgz#d9b40c5c40ab59e8738f297df3087bf1a2690c01" + integrity sha512-gLXCKdN1/j47AiHiOkJN69hJmcbGTHI0ImLmbYLHykhgeN0jVGola9yVjFgzCUklsZQMW55o+dW7IXv3RCXDzA== -typescript@^5.1.6: - version "5.3.3" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.3.3.tgz#b3ce6ba258e72e6305ba66f5c9b452aaee3ffe37" - integrity sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw== +typescript@^5.5.4: + version "5.5.4" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.5.4.tgz#d9852d6c82bad2d2eda4fd74a5762a8f5909e9ba" + integrity sha512-Mtq29sKDAEYP7aljRgtPOpTvOfbwRWlS6dPRzwjdE+C0R4brX/GUyhHSecbHMFLNBLcJIPt9nl9yG5TZ1weH+Q== undici-types@~5.26.4: version "5.26.5" @@ -835,20 +853,20 @@ vite-plugin-html@^3.2.0: node-html-parser "^5.3.3" pathe "^0.2.0" -vite-plugin-singlefile@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/vite-plugin-singlefile/-/vite-plugin-singlefile-2.0.0.tgz#b25a8cdb90def1c602d63f795f10d321abb0e7d0" - integrity sha512-0ADuhM0nLSTJAm/KhRLCHiAIhlmR70MajcLfJlIflbsPj02sKEQErzsiPhuSg/jt1nKBi7oLmuX718tYI2Fjdg== +vite-plugin-singlefile@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/vite-plugin-singlefile/-/vite-plugin-singlefile-2.0.2.tgz#af2c95e0182bd363dbe29b80bea5c5a78209f649" + integrity sha512-Z2ou6HcvED5CF0hM+vcFSaFa+klyS8RyyLxW0PbMRLnMbvzTI6ueWyxdYNFhpuXZgz/aj6+E/dHFTdEcw6gb9w== dependencies: - micromatch "^4.0.5" + micromatch "^4.0.7" -vite@^5.1.4: - version "5.1.4" - resolved "https://registry.yarnpkg.com/vite/-/vite-5.1.4.tgz#14e9d3e7a6e488f36284ef13cebe149f060bcfb6" - integrity sha512-n+MPqzq+d9nMVTKyewqw6kSt+R3CkvF9QAKY8obiQn8g1fwTscKxyfaYnC632HtBXAQGc1Yjomphwn1dtwGAHg== +vite@^5.4.6: + version "5.4.6" + resolved "https://registry.yarnpkg.com/vite/-/vite-5.4.6.tgz#85a93a1228a7fb5a723ca1743e337a2588ed008f" + integrity sha512-IeL5f8OO5nylsgzd9tq4qD2QqI0k2CQLGrWD0rCN0EQJZpBK5vJAx0I+GDkMOXxQX/OfFHMuLIx6ddAxGX/k+Q== dependencies: - esbuild "^0.19.3" - postcss "^8.4.35" - rollup "^4.2.0" + esbuild "^0.21.3" + postcss "^8.4.43" + rollup "^4.20.0" optionalDependencies: fsevents "~2.3.3" diff --git a/src/UnityWebBrowser.UnityProject/Assets/Scripts/UWBRuntime.cs b/src/UnityWebBrowser.UnityProject/Assets/Scripts/UWBRuntime.cs index 2178b57a..2eb01ad5 100644 --- a/src/UnityWebBrowser.UnityProject/Assets/Scripts/UWBRuntime.cs +++ b/src/UnityWebBrowser.UnityProject/Assets/Scripts/UWBRuntime.cs @@ -68,12 +68,16 @@ private void Start() new Engine.EnginePlatformFiles { platform = Platform.Windows64, - engineFileLocation = "Packages/dev.voltstro.unitywebbrowser.engine.cef.win.x64/Engine~/" + engineBaseAppLocation = string.Empty, + engineEditorLocation = "Packages/dev.voltstro.unitywebbrowser.engine.cef.win.x64/Engine~/", + engineRuntimeLocation = "UWB/" }, new Engine.EnginePlatformFiles { platform = Platform.Linux64, - engineFileLocation = "Packages/dev.voltstro.unitywebbrowser.engine.cef.linux.x64/Engine~/" + engineBaseAppLocation = string.Empty, + engineEditorLocation = "Packages/dev.voltstro.unitywebbrowser.engine.cef.linux.x64/Engine~/", + engineRuntimeLocation = "UWB/" } }; #endif diff --git a/src/UnityWebBrowser.UnityProject/Packages/manifest.json b/src/UnityWebBrowser.UnityProject/Packages/manifest.json index c2e228ed..5ec4606f 100644 --- a/src/UnityWebBrowser.UnityProject/Packages/manifest.json +++ b/src/UnityWebBrowser.UnityProject/Packages/manifest.json @@ -1,12 +1,12 @@ { "dependencies": { - "com.unity.ide.rider": "3.0.27", + "com.unity.ide.rider": "3.0.31", "com.unity.ide.visualstudio": "2.0.22", "com.unity.ide.vscode": "1.2.5", "com.unity.inputsystem": "1.7.0", "com.unity.test-framework": "1.1.33", - "com.unity.textmeshpro": "3.0.8", - "com.unity.toolchain.linux-x86_64": "2.0.6", + "com.unity.textmeshpro": "3.0.9", + "com.unity.toolchain.linux-x86_64": "2.0.9", "com.unity.ugui": "1.0.0", "dev.voltstro.unityimgui": "5.0.1", "dev.voltstro.unityvoltbuilder": "4.1.2", @@ -14,10 +14,11 @@ "dev.voltstro.unitywebbrowser.communication.pipes": "file:../../Packages/UnityWebBrowser.Communication.Pipes", "dev.voltstro.unitywebbrowser.engine.cef": "file:../../Packages/UnityWebBrowser.Engine.Cef", "dev.voltstro.unitywebbrowser.engine.cef.linux.x64": "file:../../Packages/UnityWebBrowser.Engine.Cef.Linux-x64", + "dev.voltstro.unitywebbrowser.engine.cef.macos.arm64": "file:../../Packages/UnityWebBrowser.Engine.Cef.MacOS-arm64", "dev.voltstro.unitywebbrowser.engine.cef.macos.x64": "file:../../Packages/UnityWebBrowser.Engine.Cef.MacOS-x64", "dev.voltstro.unitywebbrowser.engine.cef.win.x64": "file:../../Packages/UnityWebBrowser.Engine.Cef.Win-x64", "dev.voltstro.unitywebbrowser.unix-support": "file:../../Packages/UnityWebBrowser.Unix-Support", - "org.nuget.microsoft.unity.analyzers": "1.18.0", + "org.nuget.microsoft.unity.analyzers": "1.20.0", "com.unity.modules.imgui": "1.0.0", "com.unity.modules.jsonserialize": "1.0.0", "com.unity.modules.ui": "1.0.0", diff --git a/src/UnityWebBrowser.UnityProject/Packages/packages-lock.json b/src/UnityWebBrowser.UnityProject/Packages/packages-lock.json index 1ff7b3fe..a65e5451 100644 --- a/src/UnityWebBrowser.UnityProject/Packages/packages-lock.json +++ b/src/UnityWebBrowser.UnityProject/Packages/packages-lock.json @@ -1,7 +1,7 @@ { "dependencies": { "com.cysharp.unitask": { - "version": "2.5.3", + "version": "2.5.5", "depth": 1, "source": "registry", "dependencies": {}, @@ -15,7 +15,7 @@ "url": "https://packages.unity.com" }, "com.unity.ide.rider": { - "version": "3.0.27", + "version": "3.0.31", "depth": 0, "source": "registry", "dependencies": { @@ -63,18 +63,18 @@ "url": "https://packages.unity.com" }, "com.unity.sysroot": { - "version": "2.0.7", + "version": "2.0.10", "depth": 1, "source": "registry", "dependencies": {}, "url": "https://packages.unity.com" }, "com.unity.sysroot.linux-x86_64": { - "version": "2.0.6", + "version": "2.0.9", "depth": 1, "source": "registry", "dependencies": { - "com.unity.sysroot": "2.0.7" + "com.unity.sysroot": "2.0.10" }, "url": "https://packages.unity.com" }, @@ -90,7 +90,7 @@ "url": "https://packages.unity.com" }, "com.unity.textmeshpro": { - "version": "3.0.8", + "version": "3.0.9", "depth": 0, "source": "registry", "dependencies": { @@ -99,12 +99,12 @@ "url": "https://packages.unity.com" }, "com.unity.toolchain.linux-x86_64": { - "version": "2.0.6", + "version": "2.0.9", "depth": 0, "source": "registry", "dependencies": { - "com.unity.sysroot": "2.0.7", - "com.unity.sysroot.linux-x86_64": "2.0.6" + "com.unity.sysroot": "2.0.10", + "com.unity.sysroot.linux-x86_64": "2.0.9" }, "url": "https://packages.unity.com" }, @@ -124,13 +124,6 @@ "dependencies": {}, "url": "https://upm-pkgs.voltstro.dev" }, - "dev.voltstro.nuget.mono.unix": { - "version": "1.0.0", - "depth": 1, - "source": "registry", - "dependencies": {}, - "url": "https://upm-pkgs.voltstro.dev" - }, "dev.voltstro.unityimgui": { "version": "5.0.1", "depth": 0, @@ -156,7 +149,7 @@ "dependencies": { "dev.voltstro.nativearrayspanextensions": "1.0.1", "com.unity.nuget.newtonsoft-json": "3.2.1", - "com.cysharp.unitask": "2.5.3", + "com.cysharp.unitask": "2.5.5", "org.nuget.voltrpc": "3.2.0" } }, @@ -165,7 +158,8 @@ "depth": 0, "source": "local", "dependencies": { - "dev.voltstro.unitywebbrowser": "2.0.0" + "dev.voltstro.unitywebbrowser": "2.2.0", + "org.nuget.voltrpc.communication.pipes": "3.1.0" } }, "dev.voltstro.unitywebbrowser.engine.cef": { @@ -173,7 +167,7 @@ "depth": 0, "source": "local", "dependencies": { - "dev.voltstro.unitywebbrowser": "2.1.1" + "dev.voltstro.unitywebbrowser": "2.2.0" } }, "dev.voltstro.unitywebbrowser.engine.cef.linux.x64": { @@ -181,8 +175,15 @@ "depth": 0, "source": "local", "dependencies": { - "dev.voltstro.unitywebbrowser.engine.cef": "2.1.1-122.1.13", - "dev.voltstro.unitywebbrowser.unix-support": "1.0.0" + "dev.voltstro.unitywebbrowser.engine.cef": "2.2.0-128.4.9" + } + }, + "dev.voltstro.unitywebbrowser.engine.cef.macos.arm64": { + "version": "file:../../Packages/UnityWebBrowser.Engine.Cef.MacOS-arm64", + "depth": 0, + "source": "local", + "dependencies": { + "dev.voltstro.unitywebbrowser.engine.cef": "2.2.0-128.4.9" } }, "dev.voltstro.unitywebbrowser.engine.cef.macos.x64": { @@ -190,8 +191,7 @@ "depth": 0, "source": "local", "dependencies": { - "dev.voltstro.unitywebbrowser.engine.cef": "2.0.0-preview.3-99.2.6", - "dev.voltstro.unitywebbrowser.unix-support": "1.0.0" + "dev.voltstro.unitywebbrowser.engine.cef": "2.2.0-128.4.9" } }, "dev.voltstro.unitywebbrowser.engine.cef.win.x64": { @@ -199,19 +199,17 @@ "depth": 0, "source": "local", "dependencies": { - "dev.voltstro.unitywebbrowser.engine.cef": "2.1.1-122.1.13" + "dev.voltstro.unitywebbrowser.engine.cef": "2.2.0-128.4.9" } }, "dev.voltstro.unitywebbrowser.unix-support": { "version": "file:../../Packages/UnityWebBrowser.Unix-Support", "depth": 0, "source": "local", - "dependencies": { - "dev.voltstro.nuget.mono.unix": "1.0.0" - } + "dependencies": {} }, "org.nuget.microsoft.unity.analyzers": { - "version": "1.18.0", + "version": "1.20.0", "depth": 0, "source": "registry", "dependencies": {}, @@ -231,6 +229,15 @@ "dependencies": {}, "url": "https://upm-pkgs.voltstro.dev" }, + "org.nuget.voltrpc.communication.pipes": { + "version": "3.1.0", + "depth": 1, + "source": "registry", + "dependencies": { + "org.nuget.voltrpc": "3.2.0" + }, + "url": "https://upm-pkgs.voltstro.dev" + }, "com.unity.modules.imgui": { "version": "1.0.0", "depth": 0, diff --git a/src/UnityWebBrowser.UnityProject/ProjectSettings/ProjectVersion.txt b/src/UnityWebBrowser.UnityProject/ProjectSettings/ProjectVersion.txt index 26d0e2da..9ba13fdc 100644 --- a/src/UnityWebBrowser.UnityProject/ProjectSettings/ProjectVersion.txt +++ b/src/UnityWebBrowser.UnityProject/ProjectSettings/ProjectVersion.txt @@ -1,2 +1,2 @@ -m_EditorVersion: 2021.3.36f1 -m_EditorVersionWithRevision: 2021.3.36f1 (7a0645017be0) +m_EditorVersion: 2021.3.42f1 +m_EditorVersionWithRevision: 2021.3.42f1 (f1197811e8ce) diff --git a/src/UnityWebBrowser.UnityProject/UnityWebBrowser.UnityProject.sln.DotSettings b/src/UnityWebBrowser.UnityProject/UnityWebBrowser.UnityProject.sln.DotSettings index 0d49ac17..fd11b871 100644 --- a/src/UnityWebBrowser.UnityProject/UnityWebBrowser.UnityProject.sln.DotSettings +++ b/src/UnityWebBrowser.UnityProject/UnityWebBrowser.UnityProject.sln.DotSettings @@ -72,4 +72,10 @@ <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> + <Policy><Descriptor Staticness="Instance" AccessRightKinds="Private" Description="Instance fields (private)"><ElementKinds><Kind Name="FIELD" /><Kind Name="READONLY_FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /></Policy> + <Policy><Descriptor Staticness="Instance" AccessRightKinds="Protected, ProtectedInternal, Internal, Public, PrivateProtected" Description="Instance fields (not private)"><ElementKinds><Kind Name="FIELD" /><Kind Name="READONLY_FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /></Policy> + <Policy><Descriptor Staticness="Any" AccessRightKinds="Any" Description="Local variables"><ElementKinds><Kind Name="LOCAL_VARIABLE" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /></Policy> + <Policy><Descriptor Staticness="Static" AccessRightKinds="Protected, ProtectedInternal, Internal, Public, PrivateProtected" Description="Static fields (not private)"><ElementKinds><Kind Name="FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /></Policy> + <Policy><Descriptor Staticness="Any" AccessRightKinds="Any" Description="Types and namespaces"><ElementKinds><Kind Name="NAMESPACE" /><Kind Name="CLASS" /><Kind Name="STRUCT" /><Kind Name="ENUM" /><Kind Name="DELEGATE" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /></Policy> + True True \ No newline at end of file diff --git a/src/UnityWebBrowser.sln b/src/UnityWebBrowser.sln index 0eded3a0..b503fba4 100644 --- a/src/UnityWebBrowser.sln +++ b/src/UnityWebBrowser.sln @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 16 VisualStudioVersion = 16.0.31005.135 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnityWebBrowser.Engine.Cef", "UnityWebBrowser.Engine.Cef\UnityWebBrowser.Engine.Cef.csproj", "{6CBD8A48-C470-4C2E-8CE6-A48A75C64A46}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnityWebBrowser.Engine.Cef", "UnityWebBrowser.Engine.Cef\Main\UnityWebBrowser.Engine.Cef.csproj", "{6CBD8A48-C470-4C2E-8CE6-A48A75C64A46}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CefGlue", "ThirdParty\CefGlue\CefGlue\CefGlue.csproj", "{703FF300-34B9-48D4-A5D6-E741F48D5F95}" EndProject @@ -26,6 +26,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VoltstroStudios.UnityWebBro EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VoltstroStudios.UnityWebBrowser.Tests", "VoltstroStudios.UnityWebBrowser.Tests\VoltstroStudios.UnityWebBrowser.Tests.csproj", "{A96CD9A3-9F63-4BDB-91DA-227759EABE99}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnityWebBrowser.Engine.Cef.SubProcess", "UnityWebBrowser.Engine.Cef\SubProcess\UnityWebBrowser.Engine.Cef.SubProcess.csproj", "{6C27FD7F-FD3A-4846-8705-ABFA1AB179EE}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnityWebBrowser.Engine.Cef.Shared", "UnityWebBrowser.Engine.Cef\Shared\UnityWebBrowser.Engine.Cef.Shared.csproj", "{BC675B69-6047-4300-85A7-EA96364D11B9}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -63,6 +67,18 @@ Global {A96CD9A3-9F63-4BDB-91DA-227759EABE99}.Release|Any CPU.Build.0 = Release|Any CPU {A96CD9A3-9F63-4BDB-91DA-227759EABE99}.ReleaseUnity|Any CPU.ActiveCfg = Release|Any CPU {A96CD9A3-9F63-4BDB-91DA-227759EABE99}.ReleaseUnity|Any CPU.Build.0 = Release|Any CPU + {6C27FD7F-FD3A-4846-8705-ABFA1AB179EE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6C27FD7F-FD3A-4846-8705-ABFA1AB179EE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6C27FD7F-FD3A-4846-8705-ABFA1AB179EE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6C27FD7F-FD3A-4846-8705-ABFA1AB179EE}.Release|Any CPU.Build.0 = Release|Any CPU + {6C27FD7F-FD3A-4846-8705-ABFA1AB179EE}.ReleaseUnity|Any CPU.ActiveCfg = Debug|Any CPU + {6C27FD7F-FD3A-4846-8705-ABFA1AB179EE}.ReleaseUnity|Any CPU.Build.0 = Debug|Any CPU + {BC675B69-6047-4300-85A7-EA96364D11B9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BC675B69-6047-4300-85A7-EA96364D11B9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BC675B69-6047-4300-85A7-EA96364D11B9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BC675B69-6047-4300-85A7-EA96364D11B9}.Release|Any CPU.Build.0 = Release|Any CPU + {BC675B69-6047-4300-85A7-EA96364D11B9}.ReleaseUnity|Any CPU.ActiveCfg = Debug|Any CPU + {BC675B69-6047-4300-85A7-EA96364D11B9}.ReleaseUnity|Any CPU.Build.0 = Debug|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -75,5 +91,7 @@ Global {703FF300-34B9-48D4-A5D6-E741F48D5F95} = {E02545D4-75BA-47FA-A075-7D43750FA7A7} {6CBD8A48-C470-4C2E-8CE6-A48A75C64A46} = {E02545D4-75BA-47FA-A075-7D43750FA7A7} {2AC661BC-6119-49AF-876C-52F756B10E42} = {EED92CF1-3876-4F9B-BC3C-531156F5FA37} + {6C27FD7F-FD3A-4846-8705-ABFA1AB179EE} = {E02545D4-75BA-47FA-A075-7D43750FA7A7} + {BC675B69-6047-4300-85A7-EA96364D11B9} = {E02545D4-75BA-47FA-A075-7D43750FA7A7} EndGlobalSection EndGlobal diff --git a/src/UnityWebBrowser.sln.DotSettings b/src/UnityWebBrowser.sln.DotSettings index 0b461e52..88a6958f 100644 --- a/src/UnityWebBrowser.sln.DotSettings +++ b/src/UnityWebBrowser.sln.DotSettings @@ -71,4 +71,7 @@ UWB <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> + <Policy><Descriptor Staticness="Instance" AccessRightKinds="Private" Description="Instance fields (private)"><ElementKinds><Kind Name="FIELD" /><Kind Name="READONLY_FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /></Policy> + <Policy><Descriptor Staticness="Any" AccessRightKinds="Any" Description="Types and namespaces"><ElementKinds><Kind Name="NAMESPACE" /><Kind Name="CLASS" /><Kind Name="STRUCT" /><Kind Name="ENUM" /><Kind Name="DELEGATE" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /></Policy> + True True \ No newline at end of file diff --git a/src/VoltstroStudios.UnityWebBrowser.Engine.Shared/AssemblyInfo.cs b/src/VoltstroStudios.UnityWebBrowser.Engine.Shared/AssemblyInfo.cs index 37493b62..691c766b 100644 --- a/src/VoltstroStudios.UnityWebBrowser.Engine.Shared/AssemblyInfo.cs +++ b/src/VoltstroStudios.UnityWebBrowser.Engine.Shared/AssemblyInfo.cs @@ -5,4 +5,5 @@ using System.Runtime.CompilerServices; -[assembly: InternalsVisibleTo("UnityWebBrowser.Engine.Cef")] \ No newline at end of file +[assembly: InternalsVisibleTo("UnityWebBrowser.Engine.Cef")] +[assembly: InternalsVisibleTo("UnityWebBrowser.Engine.Cef.Shared")] \ No newline at end of file diff --git a/src/VoltstroStudios.UnityWebBrowser.Engine.Shared/Communications/CommunicationLayerLoadContext.cs b/src/VoltstroStudios.UnityWebBrowser.Engine.Shared/Communications/CommunicationLayerLoadContext.cs deleted file mode 100644 index 79182d81..00000000 --- a/src/VoltstroStudios.UnityWebBrowser.Engine.Shared/Communications/CommunicationLayerLoadContext.cs +++ /dev/null @@ -1,25 +0,0 @@ -// UnityWebBrowser (UWB) -// Copyright (c) 2021-2022 Voltstro-Studios -// -// This project is under the MIT license. See the LICENSE.md file for more details. - -using System.Reflection; -using System.Runtime.Loader; - -namespace VoltstroStudios.UnityWebBrowser.Engine.Shared.Communications; - -internal class CommunicationLayerLoadContext : AssemblyLoadContext -{ - private readonly AssemblyDependencyResolver resolver; - - public CommunicationLayerLoadContext(string dllPath) - { - resolver = new AssemblyDependencyResolver(dllPath); - } - - protected override Assembly Load(AssemblyName assemblyName) - { - string assemblyPath = resolver.ResolveAssemblyToPath(assemblyName); - return assemblyPath != null ? LoadFromAssemblyPath(assemblyPath) : null; - } -} \ No newline at end of file diff --git a/src/VoltstroStudios.UnityWebBrowser.Engine.Shared/Communications/CommunicationLayerLoader.cs b/src/VoltstroStudios.UnityWebBrowser.Engine.Shared/Communications/CommunicationLayerLoader.cs deleted file mode 100644 index 53790285..00000000 --- a/src/VoltstroStudios.UnityWebBrowser.Engine.Shared/Communications/CommunicationLayerLoader.cs +++ /dev/null @@ -1,37 +0,0 @@ -// UnityWebBrowser (UWB) -// Copyright (c) 2021-2022 Voltstro-Studios -// -// This project is under the MIT license. See the LICENSE.md file for more details. - -using System; -using System.IO; -using System.Reflection; -using VoltstroStudios.UnityWebBrowser.Shared.Communications; - -namespace VoltstroStudios.UnityWebBrowser.Engine.Shared.Communications; - -internal static class CommunicationLayerLoader -{ - public static ICommunicationLayer GetCommunicationLayerFromAssembly(string assemblyPath) - { - Assembly loadedAssembly = LoadAssembly(assemblyPath); - foreach (Type type in loadedAssembly.GetTypes()) - if (typeof(ICommunicationLayer).IsAssignableFrom(type)) - { - ICommunicationLayer communicationLayer = Activator.CreateInstance(type) as ICommunicationLayer; - return communicationLayer; - } - - //If we get here then no communication layer fround - throw new DllNotFoundException("Failed to find communication layer in provided assembly!"); - } - - private static Assembly LoadAssembly(string assemblyPath) - { - if (!File.Exists(assemblyPath)) - throw new FileNotFoundException("Communication Layer Assembly not found!"); - - CommunicationLayerLoadContext loadContext = new(assemblyPath); - return loadContext.LoadFromAssemblyName(new AssemblyName(Path.GetFileNameWithoutExtension(assemblyPath))); - } -} \ No newline at end of file diff --git a/src/VoltstroStudios.UnityWebBrowser.Engine.Shared/Communications/PipesCommunicationLayer.cs b/src/VoltstroStudios.UnityWebBrowser.Engine.Shared/Communications/PipesCommunicationLayer.cs new file mode 100644 index 00000000..bff4a21f --- /dev/null +++ b/src/VoltstroStudios.UnityWebBrowser.Engine.Shared/Communications/PipesCommunicationLayer.cs @@ -0,0 +1,23 @@ +// UnityWebBrowser (UWB) +// Copyright (c) 2021-2024 Voltstro-Studios +// +// This project is under the MIT license.See the LICENSE.md file for more details. + +using VoltRpc.Communication; +using VoltRpc.Communication.Pipes; +using VoltstroStudios.UnityWebBrowser.Shared.Communications; + +namespace VoltstroStudios.UnityWebBrowser.Engine.Shared.Communications; + +internal class PipesCommunicationLayer : ICommunicationLayer +{ + public Client CreateClient(string location) + { + return new PipesClient(location); + } + + public Host CreateHost(string location) + { + return new PipesHost(location); + } +} \ No newline at end of file diff --git a/src/VoltstroStudios.UnityWebBrowser.Engine.Shared/Communications/TCPCommunicationLayer.cs b/src/VoltstroStudios.UnityWebBrowser.Engine.Shared/Communications/TCPCommunicationLayer.cs index ca1dd793..11edadcc 100644 --- a/src/VoltstroStudios.UnityWebBrowser.Engine.Shared/Communications/TCPCommunicationLayer.cs +++ b/src/VoltstroStudios.UnityWebBrowser.Engine.Shared/Communications/TCPCommunicationLayer.cs @@ -38,7 +38,7 @@ public Host CreateHost(string location) public Client CreateTCPClient(int port) { IPEndPoint ipEndPoint = new(IPAddress.Loopback, port); - return new TCPClient(ipEndPoint); + return new TCPClient(ipEndPoint, int.MaxValue); } /// @@ -49,6 +49,6 @@ public Client CreateTCPClient(int port) public Host CreateTCPHost(int port) { IPEndPoint ipEndPoint = new(IPAddress.Loopback, port); - return new TCPHost(ipEndPoint); + return new TCPHost(ipEndPoint, int.MaxValue, int.MaxValue); } } \ No newline at end of file diff --git a/src/VoltstroStudios.UnityWebBrowser.Engine.Shared/Core/EngineEntryPoint.cs b/src/VoltstroStudios.UnityWebBrowser.Engine.Shared/Core/EngineEntryPoint.cs index 655c9551..949420b8 100644 --- a/src/VoltstroStudios.UnityWebBrowser.Engine.Shared/Core/EngineEntryPoint.cs +++ b/src/VoltstroStudios.UnityWebBrowser.Engine.Shared/Core/EngineEntryPoint.cs @@ -4,17 +4,14 @@ // This project is under the MIT license. See the LICENSE.md file for more details. using System; -using System.CommandLine; -using System.IO; using System.Threading; using System.Threading.Tasks; -using VoltstroStudios.UnityWebBrowser.Shared; +using Microsoft.Extensions.Logging; using VoltstroStudios.UnityWebBrowser.Shared.Communications; using VoltstroStudios.UnityWebBrowser.Shared.Core; using VoltstroStudios.UnityWebBrowser.Shared.Popups; using VoltRpc.Communication; using VoltstroStudios.UnityWebBrowser.Engine.Shared.Communications; -using VoltstroStudios.UnityWebBrowser.Engine.Shared.Core.Logging; using VoltstroStudios.UnityWebBrowser.Engine.Shared.Popups; using VoltstroStudios.UnityWebBrowser.Engine.Shared.ReadWriters; @@ -42,16 +39,6 @@ internal abstract class EngineEntryPoint : IDisposable /// protected EnginePopupManager PopupManager { get; private set; } - /// - /// Is the side of the connection connected - /// - protected bool IsConnected => ipcClient.IsConnected; - - protected abstract bool ShouldInitLogger(LaunchArguments launchArguments, string[] args); - - /// - /// Do your early init stuff here - /// protected abstract void EarlyInit(LaunchArguments launchArguments, string[] args); /// @@ -67,6 +54,12 @@ internal abstract class EngineEntryPoint : IDisposable /// protected abstract void EntryPoint(LaunchArguments launchArguments, string[] args); + /// + /// for creating s + /// + protected LoggerManager LoggerManagerFactory; + private ILogger engineLogger; + /// /// Call this in your engine's Program.Main method. /// @@ -80,148 +73,32 @@ public int Main(string[] args) //Arg2: 9 -> SIGKILL (arch/x86/include/uapi/asm/signal.h) SysPrctl.prctl(1, 9); #endif - - //We got a lot of arguments - - //Url to start with - Option initialUrl = new("-initial-url", - () => "https://voltstro.dev", - "The initial URL that the browser will first load to"); - - //Resolution - Option width = new("-width", - () => 1920, - "The width of the window"); - Option height = new("-height", - () => 1080, - "The height of the window"); - //General browser settings - Option javaScript = new("-javascript", - () => true, - "Enable or disable javascript"); - Option webRtc = new("-web-rtc", - () => false, - "Enable or disable web RTC"); - Option localStorage = new("-local-storage", - () => true, - "Enable or disable local storage"); - Option remoteDebugging = new("-remote-debugging", - () => 0, - "If the engine has remote debugging, what port to use (0 for disable)"); - Option cachePath = new("-cache-path", - () => null, - "The path to the cache (null for no cache)"); - Option popupAction = new("-popup-action", - () => PopupAction.Ignore, - "What action to take when dealing with a popup"); - - //Background color - Option backgroundColor = new("-background-color", - () => "ffffffff", - "The color to use for the background"); - - //Proxy settings - Option proxyServer = new("-proxy-server", - () => true, - "Use a proxy server or direct connect"); - Option proxyUsername = new("-proxy-username", - () => null, - "The username to use in the proxy auth"); - Option proxyPassword = new("-proxy-password", - () => null, - "The password to use in the proxy auth"); - - //Logging - Option logPath = new("-log-path", - () => new FileInfo("engine.log"), - "The path to where the log file will be"); - Option logSeverity = new("-log-severity", - () => LogSeverity.Info, - "The severity of the logs"); - - //IPC settings - Option communicationLayerPath = new("-comms-layer-path", - () => null, - "The location of where the dll for the communication layer is. If none is provided then the in-built TCP layer will be used."); - Option inLocation = new("-in-location", - () => "5555", - "In location for IPC (Pipes location or TCP port in TCP mode)"); - Option outLocation = new("-out-location", - () => "5556", - "Out location for IPC (Pipes location or TCP port in TCP mode)"); - - //Debugging - Option startDelay = new("-start-delay", - () => 0, - "Delays the starting process. Used for testing reasons."); - - RootCommand rootCommand = new() + LaunchArgumentsParser launchArgumentsParser = new(); + return launchArgumentsParser.Run(args, parsedArgs => { - initialUrl, - width, height, - javaScript, webRtc, localStorage, remoteDebugging, cachePath, popupAction, - backgroundColor, - proxyServer, proxyUsername, proxyPassword, - logPath, logSeverity, - communicationLayerPath, inLocation, outLocation, - startDelay - }; - rootCommand.Description = - "Unity Web Browser (UWB) Engine - Dedicated process for rendering with a browser engine."; - //Some browser engines will launch multiple processes from the same process, they will most likely use custom arguments - rootCommand.TreatUnmatchedTokensAsErrors = false; - - //The new version of System.CommandLine is very boiler platey - LaunchArgumentsBinder launchArgumentBinder = new( - initialUrl, - width, height, - javaScript, webRtc, localStorage, remoteDebugging, cachePath, popupAction, - backgroundColor, - proxyServer, proxyUsername, proxyPassword, - logPath, logSeverity, - communicationLayerPath, inLocation, outLocation, - startDelay); - rootCommand.SetHandler(parsedArgs => - { - if(parsedArgs.StartDelay != 0) - Thread.Sleep((int)parsedArgs.StartDelay); - - if (ShouldInitLogger(parsedArgs, args)) - Logger.Init(parsedArgs.LogSeverity); - - ClientControlsActions = new ClientControlsActions(); - PopupManager = new EnginePopupManager(); - - //Run early init try { + //Start logging services + LoggerManagerFactory = new LoggerManager(parsedArgs.LogSeverity); + engineLogger = LoggerManagerFactory.CreateLogger("Engine"); + + if(parsedArgs.StartDelay != 0) + Thread.Sleep((int)parsedArgs.StartDelay); + + ClientControlsActions = new ClientControlsActions(); + PopupManager = new EnginePopupManager(); + EarlyInit(parsedArgs, args); - } - catch (Exception ex) - { - Logger.Error(ex, $"{Logger.BaseLoggingTag}: Uncaught exception occured in early init!"); - ShutdownAndExitWithError(); - return; - } - - //Run the entry point - try - { + EntryPoint(parsedArgs, args); } catch (Exception ex) { - Logger.Error(ex, $"{Logger.BaseLoggingTag}: Uncaught exception occured in the entry point!"); + engineLogger.LogCritical(ex, "Uncaught exception occured in the entry point!"); ShutdownAndExitWithError(); - return; } - - Logger.Shutdown(); - }, launchArgumentBinder); - - //Invoke the command line parser and start the handler (the stuff above) - return rootCommand.Invoke(args); + }); } /// @@ -233,23 +110,17 @@ internal void SetupIpc(IEngineControls engineControls, LaunchArguments arguments { try { - Logger.Debug($"{Logger.BaseLoggingTag}: SetupIcp."); - - ICommunicationLayer communicationLayer; - if (arguments.CommunicationLayerPath == null) - { - //Use TCP - Logger.Debug($"{Logger.BaseLoggingTag}: No communication layer provided, using default TCP..."); - communicationLayer = new TCPCommunicationLayer(); - Logger.Debug($"{Logger.BaseLoggingTag}: Created default TCP communication layer."); - } - else + engineLogger.LogDebug("Doing IPC Setup..."); + + //Create communication layer + ICommunicationLayer communicationLayer = arguments.CommunicationLayerName switch { - communicationLayer = CommunicationLayerLoader.GetCommunicationLayerFromAssembly( - arguments.CommunicationLayerPath.FullName); - } - - Logger.Debug($"{Logger.BaseLoggingTag}: Created communication layer of type '{communicationLayer.GetType().FullName}'..."); + "TCP" => new TCPCommunicationLayer(), + "Pipes" => new PipesCommunicationLayer(), + _ => throw new NullReferenceException("Unknown communication layer!") + }; + + engineLogger.LogDebug("Created communication layer of type '{communicationLayerName}'...", communicationLayer.GetType().FullName); try { @@ -258,18 +129,18 @@ internal void SetupIpc(IEngineControls engineControls, LaunchArguments arguments } catch (Exception ex) { - Logger.Error(ex, $"{Logger.BaseLoggingTag}: An error occured setting up the communication layer!"); + engineLogger.LogError(ex, "An error occured setting up the communication layer!"); ShutdownAndExitWithError(); return; } - Logger.Debug($"{Logger.BaseLoggingTag}: Created host and client from communication layer."); + engineLogger.LogDebug($"Created host and client from communication layer."); //Add type readers EngineReadWritersManager.AddTypeReadWriters(ipcHost.TypeReaderWriterManager); ipcHost.AddService(typeof(IEngineControls), engineControls); ipcHost.AddService(typeof(IPopupClientControls), PopupManager); - Logger.Debug($"{Logger.BaseLoggingTag}: Installed services on host."); + engineLogger.LogDebug("Installed services on host."); Task.Run(() => { @@ -279,42 +150,41 @@ internal void SetupIpc(IEngineControls engineControls, LaunchArguments arguments } catch (Exception ex) { - Logger.Error(ex, $"{Logger.BaseLoggingTag}: An error occured listening on host!"); + engineLogger.LogError(ex, "An error occured listening on host!"); ShutdownAndExitWithError(); } }); - Logger.Debug($"{Logger.BaseLoggingTag}: Host has started listening."); + engineLogger.LogDebug("Host has started listening."); EngineReadWritersManager.AddTypeReadWriters(ipcClient.TypeReaderWriterManager); ipcClient.AddService(typeof(IClientControls)); ipcClient.AddService(typeof(IPopupEngineControls)); - Logger.Debug($"{Logger.BaseLoggingTag}: Installed services on client."); + engineLogger.LogDebug("Installed services on client."); //Connect the engine (us) back to Unity try { ipcClient.Connect(); - Logger.Debug($"{Logger.BaseLoggingTag}: Client has connected back to Unity."); + engineLogger.LogDebug("Client has connected back to Unity."); ClientControlsActions.SetIpcClient(ipcClient); PopupManager.SetIpcClient(ipcClient); } catch (ConnectionFailedException) { - Logger.Error( - $"{Logger.BaseLoggingTag}: The engine failed to connect back to the Unity client! Client events will not fire!"); + engineLogger.LogWarning("The engine failed to connect back to the Unity client! Client events will not fire!"); ipcClient.Dispose(); ipcClient = null; } - Logger.Debug($"{Logger.BaseLoggingTag}: IPC Setup done."); + engineLogger.LogDebug("IPC Setup done."); } catch (Exception ex) { - Logger.Error(ex, $"{Logger.BaseLoggingTag}: Error setting up IPC!"); + engineLogger.LogError(ex, "Error setting up IPC!"); } } @@ -329,7 +199,6 @@ protected void Ready() private void ShutdownAndExitWithError() { Dispose(); - Logger.Shutdown(); Environment.Exit(-1); } diff --git a/src/VoltstroStudios.UnityWebBrowser.Engine.Shared/Core/LaunchArguments.cs b/src/VoltstroStudios.UnityWebBrowser.Engine.Shared/Core/LaunchArguments.cs index ede0a429..6577a195 100644 --- a/src/VoltstroStudios.UnityWebBrowser.Engine.Shared/Core/LaunchArguments.cs +++ b/src/VoltstroStudios.UnityWebBrowser.Engine.Shared/Core/LaunchArguments.cs @@ -48,11 +48,21 @@ public class LaunchArguments /// How to handle popups /// public PopupAction PopupAction { get; init; } + + /// + /// Disables sandbox + /// + internal bool NoSandbox { get; set; } /// /// The port to use for remote debugging /// public int RemoteDebugging { get; init; } + + /// + /// Remote debugging allowed origins + /// + public string[] RemoteDebuggingAllowedOrigins { get; init; } /// /// The to use for the background @@ -88,11 +98,11 @@ public class LaunchArguments /// What is the log severity /// public LogSeverity LogSeverity { get; init; } - + /// - /// Path for the assembly containing the communication layer + /// Communication layer name /// - internal FileInfo CommunicationLayerPath { get; init; } + public string CommunicationLayerName { get; init; } /// /// In location (Either the pipe name or port) diff --git a/src/VoltstroStudios.UnityWebBrowser.Engine.Shared/Core/LaunchArgumentsBinder.cs b/src/VoltstroStudios.UnityWebBrowser.Engine.Shared/Core/LaunchArgumentsBinder.cs index 91ea1f06..e1513611 100644 --- a/src/VoltstroStudios.UnityWebBrowser.Engine.Shared/Core/LaunchArgumentsBinder.cs +++ b/src/VoltstroStudios.UnityWebBrowser.Engine.Shared/Core/LaunchArgumentsBinder.cs @@ -28,8 +28,10 @@ internal class LaunchArgumentsBinder : BinderBase private readonly Option webRtc; private readonly Option localStorage; private readonly Option remoteDebugging; + private readonly Option remoteDebuggingAllowedOrigins; private readonly Option cachePath; private readonly Option popupAction; + private readonly Option noSandbox; //Background color private readonly Option backgroundColor; @@ -44,7 +46,7 @@ internal class LaunchArgumentsBinder : BinderBase private readonly Option logSeverity; //IPC settings - private readonly Option communicationLayerPath; + private readonly Option communicationLayerName; private readonly Option inLocation; private readonly Option outLocation; @@ -53,12 +55,25 @@ internal class LaunchArgumentsBinder : BinderBase public LaunchArgumentsBinder( Option initialUrl, - Option width, Option height, - Option javaScript, Option webRtc, Option localStorage, Option remoteDebugging, Option cachePath, Option popupAction, + Option width, + Option height, + Option javaScript, + Option webRtc, + Option localStorage, + Option remoteDebugging, + Option remoteDebuggingAllowedOrigins, + Option cachePath, + Option popupAction, + Option noSandbox, Option backgroundColor, - Option proxyServer, Option proxyUsername, Option proxyPassword, - Option logPath, Option logSeverity, - Option communicationLayerPath, Option inLocation, Option outLocation, + Option proxyServer, + Option proxyUsername, + Option proxyPassword, + Option logPath, + Option logSeverity, + Option communicationLayerName, + Option inLocation, + Option outLocation, Option startDelay) { this.initialUrl = initialUrl; @@ -69,8 +84,10 @@ public LaunchArgumentsBinder( this.webRtc = webRtc; this.localStorage = localStorage; this.remoteDebugging = remoteDebugging; + this.remoteDebuggingAllowedOrigins = remoteDebuggingAllowedOrigins; this.cachePath = cachePath; this.popupAction = popupAction; + this.noSandbox = noSandbox; this.backgroundColor = backgroundColor; @@ -81,7 +98,7 @@ public LaunchArgumentsBinder( this.logPath = logPath; this.logSeverity = logSeverity; - this.communicationLayerPath = communicationLayerPath; + this.communicationLayerName = communicationLayerName; this.inLocation = inLocation; this.outLocation = outLocation; @@ -100,9 +117,11 @@ protected override LaunchArguments GetBoundValue(BindingContext bindingContext) JavaScript = bindingContext.ParseResult.GetValueForOption(javaScript), WebRtc = bindingContext.ParseResult.GetValueForOption(webRtc), LocalStorage = bindingContext.ParseResult.GetValueForOption(localStorage), + RemoteDebuggingAllowedOrigins = bindingContext.ParseResult.GetValueForOption(remoteDebuggingAllowedOrigins), RemoteDebugging = bindingContext.ParseResult.GetValueForOption(remoteDebugging), CachePath = bindingContext.ParseResult.GetValueForOption(cachePath), PopupAction = bindingContext.ParseResult.GetValueForOption(popupAction), + NoSandbox = bindingContext.ParseResult.GetValueForOption(noSandbox), BackgroundColor = new Color(bindingContext.ParseResult.GetValueForOption(backgroundColor)), @@ -113,7 +132,7 @@ protected override LaunchArguments GetBoundValue(BindingContext bindingContext) LogPath = bindingContext.ParseResult.GetValueForOption(logPath), LogSeverity = bindingContext.ParseResult.GetValueForOption(logSeverity), - CommunicationLayerPath = bindingContext.ParseResult.GetValueForOption(communicationLayerPath), + CommunicationLayerName = bindingContext.ParseResult.GetValueForOption(communicationLayerName), InLocation = bindingContext.ParseResult.GetValueForOption(inLocation), OutLocation = bindingContext.ParseResult.GetValueForOption(outLocation), diff --git a/src/VoltstroStudios.UnityWebBrowser.Engine.Shared/Core/LaunchArgumentsParser.cs b/src/VoltstroStudios.UnityWebBrowser.Engine.Shared/Core/LaunchArgumentsParser.cs new file mode 100644 index 00000000..3f905974 --- /dev/null +++ b/src/VoltstroStudios.UnityWebBrowser.Engine.Shared/Core/LaunchArgumentsParser.cs @@ -0,0 +1,160 @@ +// UnityWebBrowser (UWB) +// Copyright (c) 2021-2024 Voltstro-Studios +// +// This project is under the MIT license. See the LICENSE.md file for more details. + +using System; +using System.CommandLine; +using System.IO; +using VoltstroStudios.UnityWebBrowser.Shared; +using VoltstroStudios.UnityWebBrowser.Shared.Popups; + +namespace VoltstroStudios.UnityWebBrowser.Engine.Shared.Core; + +/// +/// Parses arguments from the command line +/// +public sealed class LaunchArgumentsParser +{ + private readonly RootCommand rootCommand; + private readonly LaunchArgumentsBinder launchArgumentsBinder; + + public LaunchArgumentsParser() + { + //Url to start with + Option initialUrl = new("-initial-url", + () => "https://voltstro.dev", + "The initial URL that the browser will first load to"); + + //Resolution + Option width = new("-width", + () => 1920, + "The width of the window"); + Option height = new("-height", + () => 1080, + "The height of the window"); + + //General browser settings + Option javaScript = new("-javascript", + () => true, + "Enable or disable javascript"); + Option webRtc = new("-web-rtc", + () => false, + "Enable or disable web RTC"); + Option localStorage = new("-local-storage", + () => true, + "Enable or disable local storage"); + Option remoteDebugging = new("-remote-debugging", + () => 0, + "If the engine has remote debugging, what port to use (0 for disable)"); + Option remoteDebuggingAllowedOrigins = new("-remote-debugging-allowed-origins", + () => new []{"http://127.0.0.1:9022"}, + "Allowed origins for remote debugging."); + Option cachePath = new("-cache-path", + () => null, + "The path to the cache (null for no cache)"); + Option popupAction = new("-popup-action", + () => PopupAction.Ignore, + "What action to take when dealing with a popup"); + Option noSandbox = new("-no-sandbox", + () => false, + "Disables browser engine sandboxing"); + + //Background color + Option backgroundColor = new("-background-color", + () => "ffffffff", + "The color to use for the background"); + + //Proxy settings + Option proxyServer = new("-proxy-server", + () => true, + "Use a proxy server or direct connect"); + Option proxyUsername = new("-proxy-username", + () => null, + "The username to use in the proxy auth"); + Option proxyPassword = new("-proxy-password", + () => null, + "The password to use in the proxy auth"); + + //Logging + Option logPath = new("-log-path", + () => new FileInfo("engine.log"), + "The path to where the log file will be"); + Option logSeverity = new("-log-severity", + () => LogSeverity.Info, + "The severity of the logs"); + + //IPC settings + Option communicationLayerName = new("-comms-layer-name", + () => "TCP", + "The name of the communication layer to use."); + Option inLocation = new("-in-location", + () => "5555", + "In location for IPC (Pipes location or TCP port in TCP mode)"); + Option outLocation = new("-out-location", + () => "5556", + "Out location for IPC (Pipes location or TCP port in TCP mode)"); + + //Debugging + Option startDelay = new("-start-delay", + () => 0, + "Delays the starting process. Used for testing reasons."); + + rootCommand = new RootCommand() + { + initialUrl, + width, + height, + javaScript, + webRtc, + localStorage, + remoteDebugging, + remoteDebuggingAllowedOrigins, + cachePath, + popupAction, + backgroundColor, + proxyServer, + proxyUsername, + proxyPassword, + logPath, + logSeverity, + communicationLayerName, + inLocation, + outLocation, + startDelay + }; + rootCommand.Description = + "Unity Web Browser (UWB) Engine - Dedicated process for rendering with a browser engine."; + //Some browser engines will launch multiple processes from the same process, they will most likely use custom arguments + rootCommand.TreatUnmatchedTokensAsErrors = false; + + launchArgumentsBinder = new LaunchArgumentsBinder( + initialUrl, + width, + height, + javaScript, + webRtc, + localStorage, + remoteDebugging, + remoteDebuggingAllowedOrigins, + cachePath, + popupAction, + noSandbox, + backgroundColor, + proxyServer, + proxyUsername, + proxyPassword, + logPath, + logSeverity, + communicationLayerName, + inLocation, + outLocation, + startDelay); + } + + public int Run(string[] args, Action onRun) + { + rootCommand.SetHandler(onRun, launchArgumentsBinder); + return rootCommand.Invoke(args); + } +} \ No newline at end of file diff --git a/src/VoltstroStudios.UnityWebBrowser.Engine.Shared/Core/LoggerManager.cs b/src/VoltstroStudios.UnityWebBrowser.Engine.Shared/Core/LoggerManager.cs new file mode 100644 index 00000000..aeba4914 --- /dev/null +++ b/src/VoltstroStudios.UnityWebBrowser.Engine.Shared/Core/LoggerManager.cs @@ -0,0 +1,55 @@ +// UnityWebBrowser (UWB) +// Copyright (c) 2021-2024 Voltstro-Studios +// +// This project is under the MIT license. See the LICENSE.md file for more details. + +using System; +using Microsoft.Extensions.Logging; +using Serilog; +using Serilog.Formatting.Compact; +using VoltstroStudios.UnityWebBrowser.Shared; +using ILogger = Microsoft.Extensions.Logging.ILogger; + +namespace VoltstroStudios.UnityWebBrowser.Engine.Shared.Core; + +/// +/// Manager for creating s +/// +public sealed class LoggerManager +{ + private readonly ILoggerFactory loggerFactory; + + public LoggerManager(LogSeverity logSeverity) + { + Log.Logger = new LoggerConfiguration() + .Enrich.FromLogContext() + .WriteTo.Console(new RenderedCompactJsonFormatter()) + .CreateLogger(); + + loggerFactory = LoggerFactory.Create(logging => + { + LogLevel level = logSeverity switch + { + LogSeverity.Debug => LogLevel.Debug, + LogSeverity.Info => LogLevel.Information, + LogSeverity.Warn => LogLevel.Warning, + LogSeverity.Error => LogLevel.Error, + LogSeverity.Fatal => LogLevel.Critical, + _ => throw new ArgumentOutOfRangeException(nameof(logSeverity), logSeverity, null) + }; + + logging.SetMinimumLevel(level); + logging.AddSerilog(dispose: true); + }); + } + + /// + /// Creates a new instance + /// + /// + /// + public ILogger CreateLogger(string name) + { + return loggerFactory.CreateLogger(name); + } +} \ No newline at end of file diff --git a/src/VoltstroStudios.UnityWebBrowser.Engine.Shared/Core/Logging/Logger.cs b/src/VoltstroStudios.UnityWebBrowser.Engine.Shared/Core/Logging/Logger.cs deleted file mode 100644 index 46f0ee57..00000000 --- a/src/VoltstroStudios.UnityWebBrowser.Engine.Shared/Core/Logging/Logger.cs +++ /dev/null @@ -1,249 +0,0 @@ -// UnityWebBrowser (UWB) -// Copyright (c) 2021-2022 Voltstro-Studios -// -// This project is under the MIT license. See the LICENSE.md file for more details. - -using System; -using Serilog; -using Serilog.Core; -using Serilog.Events; -using Serilog.Formatting.Compact; -using VoltstroStudios.UnityWebBrowser.Shared; - -namespace VoltstroStudios.UnityWebBrowser.Engine.Shared.Core.Logging; - -public static class Logger -{ - public const string BaseLoggingTag = "[Engine]"; - - private static Serilog.Core.Logger log; - - private static LoggerConfig loggerConfig; - - private static LoggingLevelSwitch level; - - /// - /// The logger's config, can only be set while the logger isn't running - /// - public static LoggerConfig LoggerConfig - { - internal set - { - if (IsLoggerInitialized) - throw new InitializationException("The logger is already initialized!"); - - loggerConfig = value; - } - get => loggerConfig; - } - - /// - /// Is the logger initialized? - /// Returns true if it is - /// - public static bool IsLoggerInitialized => log != null; - - /// - /// Initializes the logger - /// - /// - internal static void Init(LogSeverity logSeverity) - { - if (IsLoggerInitialized) - throw new InitializationException("The logger is already initialized!"); - - LoggerConfig ??= new LoggerConfig(); - - LogEventLevel logEventLevel; - switch (logSeverity) - { - case LogSeverity.Debug: - logEventLevel = LogEventLevel.Debug; - break; - case LogSeverity.Info: - logEventLevel = LogEventLevel.Information; - break; - case LogSeverity.Warn: - logEventLevel = LogEventLevel.Warning; - break; - case LogSeverity.Error: - logEventLevel = LogEventLevel.Error; - break; - case LogSeverity.Fatal: - logEventLevel = LogEventLevel.Fatal; - break; - default: - throw new ArgumentOutOfRangeException(nameof(logSeverity), logSeverity, null); - } - - //Setup logging level - level = new LoggingLevelSwitch - { - MinimumLevel = logEventLevel - }; - - log = new LoggerConfiguration() - .MinimumLevel.ControlledBy(level) - .WriteTo.Console(new RenderedCompactJsonFormatter(), logEventLevel) - .CreateLogger(); - - log.Debug("Logger initialized at {Date}", DateTime.Now.ToString("dd/MM/yyyy hh:mm tt")); - } - - /// - /// Shuts down the logger - /// - /// - internal static void Shutdown() - { - if (!IsLoggerInitialized) - throw new InitializationException("The logger isn't initialized!"); - - log.Debug("Logger shutting down at {Date}", DateTime.Now.ToString("dd/MM/yyyy hh:mm tt")); - log.Dispose(); - log = null; - - loggerConfig = null; - } - - private static void CheckInitialization() - { - if (!IsLoggerInitialized) - throw new InitializationException("The logger isn't initialized!"); - } - - #region Debug Logging - - /// - /// Writes a debug log - /// - /// - public static void Debug(string message) - { - CheckInitialization(); - - if (level.MinimumLevel == LogEventLevel.Debug) - log.Debug(message); - } - - /// - /// Writes a debug log - /// - /// - /// - public static void Debug(string message, params object[] values) - { - CheckInitialization(); - - if (level.MinimumLevel == LogEventLevel.Debug) - log.Debug(message, values); - } - - #endregion - - #region Information Logging - - /// - /// Writes an information log - /// - /// - public static void Info(string message) - { - CheckInitialization(); - - log.Information(message); - } - - /// - /// Writes an information log - /// - /// - /// - public static void Info(string message, params object[] values) - { - CheckInitialization(); - - log.Information(message, values); - } - - #endregion - - #region Warning Logging - - /// - /// Writes a warning log - /// - /// - public static void Warn(string message) - { - CheckInitialization(); - - log.Warning(message); - } - - /// - /// Writes a warning log - /// - /// - /// - public static void Warn(string message, params object[] values) - { - CheckInitialization(); - - log.Warning(message, values); - } - - #endregion - - #region Error Logging - - /// - /// Writes an error log - /// - /// - public static void Error(string message) - { - CheckInitialization(); - - log.Error(message); - } - - /// - /// Writes an error log - /// - /// - /// - public static void Error(string message, params object[] values) - { - CheckInitialization(); - - log.Error(message, values); - } - - /// - /// Writes an error log - /// - /// - /// - public static void Error(Exception exception, string message) - { - CheckInitialization(); - - log.Error(exception, message); - } - - /// - /// Writes an error log - /// - /// - /// - /// - public static void Error(Exception exception, string message, params object[] values) - { - CheckInitialization(); - - log.Error(exception, message, values); - } - - #endregion -} \ No newline at end of file diff --git a/src/VoltstroStudios.UnityWebBrowser.Engine.Shared/Core/Logging/LoggerConfig.cs b/src/VoltstroStudios.UnityWebBrowser.Engine.Shared/Core/Logging/LoggerConfig.cs deleted file mode 100644 index 73846b5b..00000000 --- a/src/VoltstroStudios.UnityWebBrowser.Engine.Shared/Core/Logging/LoggerConfig.cs +++ /dev/null @@ -1,27 +0,0 @@ -// UnityWebBrowser (UWB) -// Copyright (c) 2021-2022 Voltstro-Studios -// -// This project is under the MIT license. See the LICENSE.md file for more details. - -namespace VoltstroStudios.UnityWebBrowser.Engine.Shared.Core.Logging; - -/// -/// The config for -/// -public sealed class LoggerConfig -{ - /// - /// The underlying stream will be permit to do buffered writes - /// - public bool BufferedFileWrite = true; - - /// - /// The directory to log files to - /// - public string LogDirectory = "/Logs/"; - - /// - /// The format the the files will use - /// - public string LogFileDateTimeFormat = "yyyy-MM-dd-HH-mm-ss"; -} \ No newline at end of file diff --git a/src/VoltstroStudios.UnityWebBrowser.Engine.Shared/VoltstroStudios.UnityWebBrowser.Engine.Shared.csproj b/src/VoltstroStudios.UnityWebBrowser.Engine.Shared/VoltstroStudios.UnityWebBrowser.Engine.Shared.csproj index 445dffd1..ec512943 100644 --- a/src/VoltstroStudios.UnityWebBrowser.Engine.Shared/VoltstroStudios.UnityWebBrowser.Engine.Shared.csproj +++ b/src/VoltstroStudios.UnityWebBrowser.Engine.Shared/VoltstroStudios.UnityWebBrowser.Engine.Shared.csproj @@ -9,11 +9,12 @@ - - - - + + + + + diff --git a/src/VoltstroStudios.UnityWebBrowser.Shared/AssemblyInfo.cs b/src/VoltstroStudios.UnityWebBrowser.Shared/AssemblyInfo.cs index 2c66c146..f568d350 100644 --- a/src/VoltstroStudios.UnityWebBrowser.Shared/AssemblyInfo.cs +++ b/src/VoltstroStudios.UnityWebBrowser.Shared/AssemblyInfo.cs @@ -6,6 +6,7 @@ using System.Runtime.CompilerServices; [assembly: InternalsVisibleTo("UnityWebBrowser.Engine.Cef")] +[assembly: InternalsVisibleTo("UnityWebBrowser.Engine.Cef.Shared")] [assembly: InternalsVisibleTo("VoltstroStudios.UnityWebBrowser")] [assembly: InternalsVisibleTo("VoltstroStudios.UnityWebBrowser.Engine.Shared")] diff --git a/src/VoltstroStudios.UnityWebBrowser.Shared/Core/Platform.cs b/src/VoltstroStudios.UnityWebBrowser.Shared/Core/Platform.cs index f96da6ad..3a589dbb 100644 --- a/src/VoltstroStudios.UnityWebBrowser.Shared/Core/Platform.cs +++ b/src/VoltstroStudios.UnityWebBrowser.Shared/Core/Platform.cs @@ -23,5 +23,10 @@ public enum Platform /// /// MacOS 64-bit (Intel) /// - MacOS + MacOS, + + /// + /// MacOS Arm64 + /// + MacOSArm64, } \ No newline at end of file diff --git a/src/VoltstroStudios.UnityWebBrowser.Shared/VoltstroStudios.UnityWebBrowser.Shared.csproj b/src/VoltstroStudios.UnityWebBrowser.Shared/VoltstroStudios.UnityWebBrowser.Shared.csproj index 9794675e..a50df0dd 100644 --- a/src/VoltstroStudios.UnityWebBrowser.Shared/VoltstroStudios.UnityWebBrowser.Shared.csproj +++ b/src/VoltstroStudios.UnityWebBrowser.Shared/VoltstroStudios.UnityWebBrowser.Shared.csproj @@ -16,6 +16,8 @@ + + @@ -40,4 +42,8 @@ + + true + + diff --git a/src/VoltstroStudios.UnityWebBrowser.Tests/VoltstroStudios.UnityWebBrowser.Tests.csproj b/src/VoltstroStudios.UnityWebBrowser.Tests/VoltstroStudios.UnityWebBrowser.Tests.csproj index 329916eb..efa2ee25 100644 --- a/src/VoltstroStudios.UnityWebBrowser.Tests/VoltstroStudios.UnityWebBrowser.Tests.csproj +++ b/src/VoltstroStudios.UnityWebBrowser.Tests/VoltstroStudios.UnityWebBrowser.Tests.csproj @@ -8,10 +8,10 @@ - - - - + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/setup-all.ps1 b/src/setup-all.ps1 deleted file mode 100644 index 68225e33..00000000 --- a/src/setup-all.ps1 +++ /dev/null @@ -1,14 +0,0 @@ -# Version Check -if ($PSVersionTable.PSVersion.Major -lt 7) -{ - throw "You need to use the NEW PowerShell version! You can get it here: https://github.com/powershell/powershell#get-powershell" -} - -# Run Scripts -Push-Location "$PSScriptRoot/DevScripts/" - -& "$PSScriptRoot/DevScripts/download-all.ps1" -& "$PSScriptRoot/DevScripts/publish-all.ps1" -& "$PSScriptRoot/DevScripts/sync-package-all.ps1" - -Pop-Location \ No newline at end of file diff --git a/src/version.json b/src/version.json index e12be7a5..ce136901 100644 --- a/src/version.json +++ b/src/version.json @@ -1,9 +1,8 @@ { "$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json", - "version": "2.1.1", + "version": "2.2.0", "publicReleaseRefSpec": [ - "^refs/heads/master$", - "^refs/heads/v\\d+(?:\\.\\d+)?$" + "^refs/heads/release$" ], "cloudBuild": { "buildNumber": {