initial commit of the V8 wrapper project
This commit is contained in:
Родитель
ead556d5b7
Коммит
d426afba20
|
@ -0,0 +1,24 @@
|
|||
# Don't add google V8 source code #
|
||||
####################################
|
||||
v8/
|
||||
|
||||
V8_Native/.vs/
|
||||
V8_Native/v8.dll.so
|
||||
V8_Native/x64/
|
||||
V8_Native/ARM64/
|
||||
|
||||
V8_Managed_Library/.vs/
|
||||
V8_Managed_Library/Tests/bin/
|
||||
V8_Managed_Library/Tests/obj/
|
||||
V8_Managed_Library/Tests/obdj/
|
||||
V8_Managed_Library/Tests/lib/
|
||||
V8_Managed_Library/V8Host/bin/
|
||||
V8_Managed_Library/V8Host/obj/
|
||||
V8_Managed_Library/V8Host/obdj/
|
||||
|
||||
V8.CoreUXPlugin.Private/x64/
|
||||
V8.CoreUXPlugin.Private/runtimes/
|
||||
|
||||
include/
|
||||
bin/
|
||||
lib/
|
35
LICENSE
35
LICENSE
|
@ -1,21 +1,22 @@
|
|||
MIT License
|
||||
MIT License
|
||||
|
||||
Copyright (c) Microsoft Corporation.
|
||||
Copyright (c) Microsoft Corporation
|
||||
All rights reserved.
|
||||
|
||||
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:
|
||||
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 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
|
||||
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.
|
78
README.md
78
README.md
|
@ -1,33 +1,63 @@
|
|||
# Project
|
||||
# **V8 Managed Library for Embedding Application** #
|
||||
|
||||
> This repo has been populated by an initial template to help get you started. Please
|
||||
> make sure to update the content to build a great experience for community-building.
|
||||
[V8](https://github.com/v8/v8) is Google’s open source high-performance JavaScript engine, written in C++. It is used in Google Chrome, the open source browser from Google, and in Node.js, among others. It implements ECMAScript as specified in ECMA-262, and runs on Windows 7 or later, macOS 10.12+, and Linux systems that use x64, IA-32, ARM, or MIPS processors. V8 can run standalone, or can be embedded into any C++ application.
|
||||
|
||||
As the maintainer of this project, please make a few updates:
|
||||
This wrapper project will expose some of V8 functionalities to managed (e.g: C#) world to execute JavaScript. Bing UX platform is using this v8.dll in their Aspnet application to execute JavaScript on server.
|
||||
|
||||
- Improving this README.MD file to provide a great experience
|
||||
- Updating SUPPORT.MD with content about this project's support experience
|
||||
- Understanding the security reporting process in SECURITY.MD
|
||||
- Remove this section from the README
|
||||
## **How to Build V8 with Wrapper Code** ##
|
||||
V8Build.cmd is a small batch file which will download V8 source code and build. V8_Native.sln is a C project which expose V8 api for P/Invoke. If you interest to get more information about V8 build please visit [Here](https://github.com/v8/v8/wiki/Building-with-GN).
|
||||
|
||||
## Contributing
|
||||
Please make sure you install all [prerequisite](https://chromium.googlesource.com/chromium/src/+/master/docs/windows_build_instructions.md#Setting-up-Windows) in your machine(install Visual Studio, Debugging tools for Windows). Here is the stuff to install in your machine :
|
||||
|
||||
This project welcomes contributions and suggestions. Most contributions require you to agree to a
|
||||
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
|
||||
the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.
|
||||
1. Visual Studio with Microsoft.VisualStudio.Workload.NativeDesktop and Microsoft.VisualStudio.Component.VC.ATLMFC
|
||||
2. Windows SDK
|
||||
3. Debugging Tools For Windows
|
||||
|
||||
When you submit a pull request, a CLA bot will automatically determine whether you need to provide
|
||||
a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions
|
||||
provided by the bot. You will only need to do this once across all repos using our CLA.
|
||||
Please follow **Setting up Windows [Visual Studio]** section in the [wiki](https://chromium.googlesource.com/chromium/src/+/master/docs/windows_build_instructions.md#Setting-up-Windows). You don't need to install depot_tools, V8Build.cmd will take care of all the V8 dependency.
|
||||
|
||||
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
|
||||
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
|
||||
contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
|
||||
# **Build Instruction ** #
|
||||
|
||||
## Trademarks
|
||||
V8Build.cmd will initialize **Visual Studio 2019 Developer Command Prompt** and setup proper environment variable. Then It'll download depot_tools and V8 source code and build it.
|
||||
|
||||
```
|
||||
**Command** for V8Build.cmd
|
||||
|
||||
**Arguments :**
|
||||
init = It will download V8 source code and dependency(depot_tools). If you already have the V8 source code then don't pass this flag.
|
||||
|
||||
[mode] = debug/release. This will build V8 in debug mode. Default mode is "release"
|
||||
|
||||
[revision] = Optional. You can specify any specific version of V8. e.g: Examples: "master", "8.9.4".
|
||||
```
|
||||
|
||||
1. Build V8 without having v8 source code.
|
||||
```
|
||||
>> V8Build.cmd init debug/release(default) x64(default) / arm64
|
||||
```
|
||||
|
||||
2. Build V8 (if you have downloaded the V8 code via init command)
|
||||
```
|
||||
>> V8Build.cmd debug/release(default)
|
||||
```
|
||||
**Output Folder Structure**
|
||||
```
|
||||
lib\
|
||||
---v8_monolith.lib
|
||||
---include
|
||||
---- .h files
|
||||
```
|
||||
3. Open V8_Native\V8_Native.sln file and build it.
|
||||
```
|
||||
cd V8_Native
|
||||
msbuild V8_Native.vcxproj /p:configuration=release /p:platform=x64
|
||||
```
|
||||
|
||||
4. Open and build V8_Managed_Library. V8_Managed_Library\JsRT.V8 is the managed wrapper library which do P/Invoke V8.dll.
|
||||
```
|
||||
cd V8_Managed_Library
|
||||
dotnet build
|
||||
; running test project
|
||||
cd Tests
|
||||
dotnet run
|
||||
```
|
||||
|
||||
This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft
|
||||
trademarks or logos is subject to and must follow
|
||||
[Microsoft's Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general).
|
||||
Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.
|
||||
Any use of third-party trademarks or logos are subject to those third-party's policies.
|
||||
|
|
41
SECURITY.md
41
SECURITY.md
|
@ -1,41 +0,0 @@
|
|||
<!-- BEGIN MICROSOFT SECURITY.MD V0.0.5 BLOCK -->
|
||||
|
||||
## Security
|
||||
|
||||
Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/Microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet), [Xamarin](https://github.com/xamarin), and [our GitHub organizations](https://opensource.microsoft.com/).
|
||||
|
||||
If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://docs.microsoft.com/en-us/previous-versions/tn-archive/cc751383(v=technet.10)), please report it to us as described below.
|
||||
|
||||
## Reporting Security Issues
|
||||
|
||||
**Please do not report security vulnerabilities through public GitHub issues.**
|
||||
|
||||
Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://msrc.microsoft.com/create-report).
|
||||
|
||||
If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://www.microsoft.com/en-us/msrc/pgp-key-msrc).
|
||||
|
||||
You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://www.microsoft.com/msrc).
|
||||
|
||||
Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue:
|
||||
|
||||
* Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.)
|
||||
* Full paths of source file(s) related to the manifestation of the issue
|
||||
* The location of the affected source code (tag/branch/commit or direct URL)
|
||||
* Any special configuration required to reproduce the issue
|
||||
* Step-by-step instructions to reproduce the issue
|
||||
* Proof-of-concept or exploit code (if possible)
|
||||
* Impact of the issue, including how an attacker might exploit the issue
|
||||
|
||||
This information will help us triage your report more quickly.
|
||||
|
||||
If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://microsoft.com/msrc/bounty) page for more details about our active programs.
|
||||
|
||||
## Preferred Languages
|
||||
|
||||
We prefer all communications to be in English.
|
||||
|
||||
## Policy
|
||||
|
||||
Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://www.microsoft.com/en-us/msrc/cvd).
|
||||
|
||||
<!-- END MICROSOFT SECURITY.MD BLOCK -->
|
25
SUPPORT.md
25
SUPPORT.md
|
@ -1,25 +0,0 @@
|
|||
# TODO: The maintainer of this repo has not yet edited this file
|
||||
|
||||
**REPO OWNER**: Do you want Customer Service & Support (CSS) support for this product/project?
|
||||
|
||||
- **No CSS support:** Fill out this template with information about how to file issues and get help.
|
||||
- **Yes CSS support:** Fill out an intake form at [aka.ms/spot](https://aka.ms/spot). CSS will work with/help you to determine next steps. More details also available at [aka.ms/onboardsupport](https://aka.ms/onboardsupport).
|
||||
- **Not sure?** Fill out a SPOT intake as though the answer were "Yes". CSS will help you decide.
|
||||
|
||||
*Then remove this first heading from this SUPPORT.MD file before publishing your repo.*
|
||||
|
||||
# Support
|
||||
|
||||
## How to file issues and get help
|
||||
|
||||
This project uses GitHub Issues to track bugs and feature requests. Please search the existing
|
||||
issues before filing new issues to avoid duplicates. For new issues, file your bug or
|
||||
feature request as a new Issue.
|
||||
|
||||
For help and questions about using this project, please **REPO MAINTAINER: INSERT INSTRUCTIONS HERE
|
||||
FOR HOW TO ENGAGE REPO OWNERS OR COMMUNITY FOR HELP. COULD BE A STACK OVERFLOW TAG OR OTHER
|
||||
CHANNEL. WHERE WILL YOU HELP PEOPLE?**.
|
||||
|
||||
## Microsoft Support Policy
|
||||
|
||||
Support for this **PROJECT or PRODUCT** is limited to the resources listed above.
|
|
@ -0,0 +1,265 @@
|
|||
@echo off
|
||||
:: Starts localization of environment variables in a batch file and continues until a matching endlocal
|
||||
setlocal
|
||||
|
||||
set vs2019=C:\Program Files (x86)\Microsoft Visual Studio\2019
|
||||
set vs2022=C:\Program Files\Microsoft Visual Studio\2022
|
||||
|
||||
:Argument_Parser
|
||||
|
||||
:: if you update v8_tested_revision then also update build/Dockerfile
|
||||
:: https://chromium.googlesource.com/v8/v8.git/+refs
|
||||
set v8_tested_revision=9.8.170
|
||||
set v8_revision=%v8_tested_revision%
|
||||
|
||||
:Default_Values
|
||||
set download=false
|
||||
set mode=Release
|
||||
set isdebug=false
|
||||
set isofficial=false
|
||||
set outputDir=lib
|
||||
set target_cpu=x64
|
||||
set VC_TargetMode=x64
|
||||
|
||||
:Process_Arguments
|
||||
if "%1"=="" goto ProcessArgument_Done
|
||||
if "%1"=="-help" goto EchoUsage
|
||||
if "%1"=="-h" goto EchoUsage
|
||||
if /i "%1"=="init" goto SetDownloadTrue
|
||||
if /i "%1"=="debug" goto SetDebugMode
|
||||
if /i "%1"=="release" goto SetReleaseMode
|
||||
if /i "%1"=="x64" goto SetTargetX64CPU
|
||||
if /i "%1"=="arm64" goto SetTargetArm64CPU
|
||||
goto Set_V8_Revision
|
||||
|
||||
|
||||
:EchoUsage
|
||||
echo Downloads, builds, and imports V8 for Bing CoreUX use.
|
||||
echo.
|
||||
echo V8UPDATE [-n] [mode] [revision]
|
||||
echo.
|
||||
echo init download the source V8 source code. If you already have it then don't pass this flag.
|
||||
echo mode Build mode: "Debug" or "Release" (default).
|
||||
echo revision V8 revision: "Latest", "Tested" (default) or branch/commit/tag.
|
||||
echo * Examples: "master", "8.9.4".
|
||||
echo * View history at https://github.com/v8/v8.git.
|
||||
goto Exit
|
||||
|
||||
:SetDownloadTrue
|
||||
set download=true
|
||||
goto Process_Next_Argument
|
||||
|
||||
:SetDebugMode
|
||||
set mode=Debug
|
||||
set isdebug=true
|
||||
set isofficial=false
|
||||
goto Process_Next_Argument
|
||||
|
||||
:SetReleaseMode
|
||||
set mode=Release
|
||||
set isdebug=false
|
||||
set isofficial=false
|
||||
goto Process_Next_Argument
|
||||
|
||||
:Set_V8_Revision
|
||||
set v8_revision=%1
|
||||
goto Process_Next_Argument
|
||||
|
||||
:SetTargetX64CPU
|
||||
set target_cpu=x64
|
||||
set VC_TargetMode=x64
|
||||
goto Process_Next_Argument
|
||||
|
||||
:SetTargetArm64CPU
|
||||
set target_cpu=arm64
|
||||
set VC_TargetMode=x64_arm64
|
||||
goto Process_Next_Argument
|
||||
|
||||
:Process_Next_Argument
|
||||
shift
|
||||
goto Process_Arguments
|
||||
|
||||
:ProcessArgument_Done
|
||||
|
||||
:Initialize_VS_CMD
|
||||
set stepname=Initializing Visual Studio VC++ CMD
|
||||
if exist "%vs2019%\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" goto InitializeCMD2019
|
||||
if exist "%vs2022%\Enterprise\Common7\Tools\VsDevCmd.bat" goto InitializeCMD2022
|
||||
goto Error
|
||||
|
||||
:InitializeCMD2019
|
||||
call "%vs2019%\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" %VC_TargetMode%
|
||||
set GYP_MSVS_VERSION=2019
|
||||
goto Check_OS
|
||||
|
||||
:InitializeCMD2022
|
||||
|
||||
call "%vs2022%\Enterprise\Common7\Tools\VsDevCmd.bat" %VC_TargetMode%
|
||||
set GYP_MSVS_VERSION=2022
|
||||
goto Check_OS
|
||||
|
||||
:Check_OS
|
||||
if /i "%PROCESSOR_ARCHITECTURE%"=="AMD64" goto CheckOSDone
|
||||
if defined PROCESSOR_ARCHITEW6432 goto CheckOSDone
|
||||
echo Error: This script requires a 64-bit operating system.
|
||||
goto Exit
|
||||
:CheckOSDone
|
||||
|
||||
:Check_VisualStudio_Version
|
||||
if "%VisualStudioVersion%"=="16.0" goto CheckVisualStudio_Version_Done
|
||||
if "%VisualStudioVersion%"=="17.0" goto CheckVisualStudio_Version_Done
|
||||
|
||||
echo Error: This script requires a Visual Studio 2017 Developer Command Prompt.
|
||||
echo Browse to http://www.visualstudio.com for more information.
|
||||
goto Exit
|
||||
:CheckVisualStudio_Version_Done
|
||||
|
||||
:Resolving_Revision
|
||||
if "%v8_revision%"=="" goto Use_Tested_Revision
|
||||
if /i "%v8_revision%"=="latest" goto Use_Latest_Revision
|
||||
goto Resolved_Revision
|
||||
|
||||
:Use_Latest_Revision
|
||||
set v8_revision=master
|
||||
goto Resolved_Revision
|
||||
|
||||
:Use_Tested_Revision
|
||||
set v8_revision=%v8_tested_revision%
|
||||
goto Resolved_Revision
|
||||
:Resolved_Revision
|
||||
|
||||
echo V8 revision = %v8_revision%
|
||||
|
||||
:: ---------------------------------------
|
||||
:: Download V8 source code and dependency
|
||||
:: ---------------------------------------
|
||||
|
||||
:Download_Start
|
||||
|
||||
if /i %download%==false goto Setup_Env_Path
|
||||
|
||||
if not exist v8\ goto Create_V8_Dir
|
||||
rd /s /q v8
|
||||
|
||||
:Create_V8_Dir
|
||||
set stepname=Creating V8 directory
|
||||
echo %stepname% ....
|
||||
md v8
|
||||
if errorlevel 1 goto Error
|
||||
|
||||
:Download_DepotTools
|
||||
cd v8
|
||||
set stepname=Downloading Depot Tools
|
||||
echo %stepname% ....
|
||||
powershell -Command "Invoke-WebRequest https://storage.googleapis.com/chrome-infra/depot_tools.zip -OutFile DepotTools.zip"
|
||||
if errorlevel 1 goto Error
|
||||
:Download_DepotTools_Done
|
||||
|
||||
:ExpandDepotTools
|
||||
set stepname=Expanding Depot Tools
|
||||
echo %stepname% ....
|
||||
powershell -Command "Expand-Archive -Path DepotTools.zip -DestinationPath DepotTools"
|
||||
if errorlevel 1 goto Error
|
||||
cd ..
|
||||
:ExpandDepotToolsDone
|
||||
|
||||
:Setup_Env_Path
|
||||
echo setting the environment path for depot tool ....
|
||||
set DEPOT_TOOLS_WIN_TOOLCHAIN=0
|
||||
path %cd%\v8\DepotTools;%path%
|
||||
if /i %download%==false goto Download_Completed
|
||||
:Setup_Env_Path_Completed
|
||||
|
||||
:Client_Sync
|
||||
cd v8
|
||||
set stepname=Downloading V8 and dependencies
|
||||
echo %stepname% ....
|
||||
call gclient config https://chromium.googlesource.com/v8/v8
|
||||
if errorlevel 1 goto Error
|
||||
call gclient sync -r %v8_revision% >sync.log
|
||||
if errorlevel 1 goto Error
|
||||
:Client_Sync_Done
|
||||
echo "download complete" %cd%
|
||||
cd ..
|
||||
:Download_Completed
|
||||
|
||||
:: --------------------------------
|
||||
:: Building V8 with BingUX plugin
|
||||
:: --------------------------------
|
||||
:Build_V8
|
||||
|
||||
:: remove if old build exist
|
||||
IF EXIST v8\v8\out (
|
||||
echo "Deleting old Build"
|
||||
rd /s /q v8\v8\out
|
||||
) ELSE (
|
||||
md v8\v8\out
|
||||
)
|
||||
|
||||
|
||||
echo Build mode: %mode%
|
||||
|
||||
:Build64Bit
|
||||
set stepname=Building 64-bit V8
|
||||
echo %stepname% %cd%...
|
||||
cd v8\v8
|
||||
::call "%VSINSTALLDIR%\VC\Auxiliary\Build\vcvarsall" %VC_TargetMode%
|
||||
if errorlevel 1 goto Error
|
||||
call gn gen out\%target_cpu%\%mode% --args="fatal_linker_warnings=false is_clang=false is_component_build=false use_custom_libcxx=false v8_monolithic=true is_debug=%isdebug% is_official_build=%isofficial% target_cpu=\"%target_cpu%\" v8_enable_i18n_support=false v8_target_cpu=\"%target_cpu%\" v8_use_external_startup_data=false v8_win64_unwinding_info=true enable_precompiled_headers=false v8_enable_31bit_smis_on_64bit_arch=false chrome_pgo_phase=0 use_thin_lto=false enable_precompiled_headers=false v8_enable_31bit_smis_on_64bit_arch=false chrome_pgo_phase=0 use_thin_lto=false"
|
||||
if errorlevel 1 goto Error
|
||||
|
||||
echo "Invoking v8_monolith system..."
|
||||
ninja -C out\%target_cpu%\%mode% v8_monolith
|
||||
if errorlevel 1 goto Error
|
||||
cd ..\..
|
||||
:Build64Bit_Done
|
||||
|
||||
::-------------------------------------
|
||||
:: import v8_monolith.lib file
|
||||
::-------------------------------------
|
||||
|
||||
:Import_Files
|
||||
|
||||
:EnsureLibDir
|
||||
set stepname=Creating Lib Directory
|
||||
if not exist %outputDir% goto Create_Lib_Dir
|
||||
echo Removing old lib directory ...
|
||||
rd /s /q %outputDir%\%target_cpu%
|
||||
rd /s /q %outputDir%\include
|
||||
rd /s /q V8.CoreUXPlugin.Private\runtimes\
|
||||
:Create_Lib_Dir
|
||||
echo Creating lib directory ...
|
||||
md %outputDir%\%target_cpu%
|
||||
if errorlevel 1 goto Error
|
||||
:EnsureLibDirDone
|
||||
|
||||
:ImportLibs
|
||||
set stepname=Importing V8 libraries
|
||||
echo %stepname% ...
|
||||
copy v8\v8\out\%target_cpu%\%mode%\obj\v8_monolith.lib %outputDir%\%target_cpu%\
|
||||
copy v8\v8\out\%target_cpu%\%mode%\obj\*.pdb %outputDir%\%target_cpu%\
|
||||
copy v8\v8\out\%target_cpu%\%mode%\obj\third_party\zlib\*.pdb %outputDir%\%target_cpu%\
|
||||
copy v8\v8\out\%target_cpu%\%mode%\obj\third_party\zlib\google\*.pdb %outputDir%\%target_cpu%\
|
||||
if errorlevel 1 goto Error
|
||||
|
||||
:ImportHeaders
|
||||
set stepname=Importing V8 header files
|
||||
echo %stepname% ...
|
||||
xcopy /S /I /E v8\v8\include %outputDir%\include
|
||||
if errorlevel 1 goto Error
|
||||
:ImportHeadersDone
|
||||
|
||||
:ImportLibsDone
|
||||
|
||||
::----------------------
|
||||
:: Building V8 done
|
||||
::----------------------
|
||||
|
||||
echo ********* Succeeded ! ******************
|
||||
goto Exit
|
||||
|
||||
:Error
|
||||
echo *** THE PREVIOUS (%stepname%) STEP FAILED ***
|
||||
|
||||
:Exit
|
||||
endlocal
|
|
@ -0,0 +1,28 @@
|
|||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright file="JavaScriptUsageException.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// </copyright>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
namespace JsRT.V8
|
||||
{
|
||||
using System;
|
||||
|
||||
public class JavaScriptUsageException : Exception
|
||||
{
|
||||
private const string DefaultErrorMessage = "V8 Runtime is throwing exception. Please check stack trace.";
|
||||
|
||||
public JavaScriptUsageException(string message, string stackTrace, V8JsErrorType errorType)
|
||||
{
|
||||
this.Message = string.IsNullOrEmpty(message) ? DefaultErrorMessage : message;
|
||||
this.StackTrace = string.IsNullOrEmpty(stackTrace) ? string.Empty : stackTrace;
|
||||
this.ErrorType = errorType;
|
||||
}
|
||||
|
||||
public override string StackTrace { get; }
|
||||
|
||||
public override string Message { get; }
|
||||
|
||||
public V8JsErrorType ErrorType { get; private set; }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<OutputType>Library</OutputType>
|
||||
<RootNamespace>JsRT.V8</RootNamespace>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<TargetFrameworkIdentifier></TargetFrameworkIdentifier>
|
||||
<Platforms>x64</Platforms>
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\..\V8.CoreUXPlugin.Private\runtimes\x64\v8.dll" PackagePath="lib/native" Pack="true"/>
|
||||
<None Include="..\..\V8.CoreUXPlugin.Private\runtimes\x64\v8.pdb" PackagePath="lib/native" Pack="true"/>
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -0,0 +1,133 @@
|
|||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright file="V8Engine.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// </copyright>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
namespace JsRT.V8
|
||||
{
|
||||
using System;
|
||||
using System.Globalization;
|
||||
|
||||
public class V8Engine :IDisposable
|
||||
{
|
||||
private bool disposed;
|
||||
private readonly V8Runtime runtime;
|
||||
private object executionContext;
|
||||
internal bool hasException;
|
||||
|
||||
public V8Engine()
|
||||
{
|
||||
var v8MaxOldSpaceInMB = 0;
|
||||
var v8MaxSemiSpaceInMB = 0;
|
||||
|
||||
this.runtime = V8Runtime.CreateRuntime(v8MaxOldSpaceInMB, v8MaxSemiSpaceInMB);
|
||||
|
||||
this.disposed = false;
|
||||
this.executionContext = new object();
|
||||
this.hasException = false;
|
||||
}
|
||||
|
||||
~V8Engine()
|
||||
{
|
||||
this.Dispose(false);
|
||||
}
|
||||
|
||||
|
||||
public void Execute(string script)
|
||||
{
|
||||
if (string.IsNullOrEmpty(script))
|
||||
{
|
||||
throw new ArgumentNullException(nameof(script));
|
||||
}
|
||||
|
||||
lock (this.executionContext)
|
||||
{
|
||||
try
|
||||
{
|
||||
this.runtime.RunScript(script, false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
hasException = true;
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string Evaluate(string script)
|
||||
{
|
||||
if (string.IsNullOrEmpty(script))
|
||||
{
|
||||
throw new ArgumentNullException(nameof(script));
|
||||
}
|
||||
|
||||
var output = string.Empty;
|
||||
|
||||
lock (this.executionContext)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = this.runtime.RunScript(script, true);
|
||||
if (result.ValueType() == V8ValueType.String)
|
||||
{
|
||||
output = result.ToString();
|
||||
}
|
||||
|
||||
result.Dispose();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
hasException = true;
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
public V8JsValue EvaluateAndGetNativeObject(string script)
|
||||
{
|
||||
if (string.IsNullOrEmpty(script))
|
||||
{
|
||||
throw new ArgumentNullException(nameof(script));
|
||||
}
|
||||
|
||||
lock (this.executionContext)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = this.runtime.RunScript(script, true);
|
||||
return result;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
hasException = true;
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public virtual void Dispose()
|
||||
{
|
||||
this.Dispose(true);
|
||||
|
||||
// This object will be cleaned up by the Dispose method.
|
||||
// Therefore, you should call GC.SupressFinalize to
|
||||
// take this object off the finalization queue
|
||||
// and prevent finalization code for this object
|
||||
// from executing a second time.
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
private void Dispose(bool disposing)
|
||||
{
|
||||
if (!disposed && disposing)
|
||||
{
|
||||
this.runtime.Dispose();
|
||||
this.disposed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright file="V8JsErrorType.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// </copyright>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
namespace JsRT.V8
|
||||
{
|
||||
using System;
|
||||
|
||||
[Flags]
|
||||
public enum V8JsErrorType
|
||||
{
|
||||
JsNoError = 0,
|
||||
Exception = 1,
|
||||
NullArgument = 2,
|
||||
NullReference = 3,
|
||||
ScriptCompilationError = 4,
|
||||
ScriptExecutionException = 5,
|
||||
InvalidOperation = 6,
|
||||
InvalidRuntime = 7
|
||||
}
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright file="V8JsException.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// </copyright>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
namespace JsRT.V8
|
||||
{
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
public struct V8JsException
|
||||
{
|
||||
/* this will hold the native V8Exception object */
|
||||
private IntPtr handle;
|
||||
|
||||
public string GetExceptionMessage()
|
||||
{
|
||||
IntPtr buffer;
|
||||
int length = 0;
|
||||
if (V8Native.GetExceptionMessage(this, out buffer, out length) == V8JsErrorType.JsNoError)
|
||||
{
|
||||
return Marshal.PtrToStringUni(buffer, length);
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
public string GetStackTrace()
|
||||
{
|
||||
IntPtr buffer;
|
||||
int length = 0;
|
||||
if (V8Native.GetStackTrace(this, out buffer, out length) == V8JsErrorType.JsNoError)
|
||||
{
|
||||
return Marshal.PtrToStringUni(buffer, length);
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
/* Don't need to dispose native object explicitly.
|
||||
Native exception object will be free when current runtime will be disposed. */
|
||||
}
|
||||
|
||||
public JavaScriptUsageException GetException(V8JsErrorType errorType)
|
||||
{
|
||||
var message = this.GetExceptionMessage();
|
||||
var stacktrace = this.GetStackTrace();
|
||||
|
||||
return new JavaScriptUsageException(message, stacktrace, errorType);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,185 @@
|
|||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright file="V8JsValue.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// </copyright>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
namespace JsRT.V8
|
||||
{
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
public struct V8JsValue
|
||||
{
|
||||
private IntPtr reference;
|
||||
|
||||
public V8JsValue(IntPtr reference)
|
||||
{
|
||||
this.reference = reference;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets an invalid value.
|
||||
/// </summary>
|
||||
public static V8JsValue Invalid
|
||||
{
|
||||
get { return new V8JsValue(IntPtr.Zero); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the value is valid.
|
||||
/// </summary>
|
||||
public bool IsValid
|
||||
{
|
||||
get { return reference != IntPtr.Zero; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// return the current V8JsValue object's Type (e.g: int, double, string etc)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public V8ValueType ValueType()
|
||||
{
|
||||
if (!this.IsValid)
|
||||
{
|
||||
return V8ValueType.UnknownType;
|
||||
}
|
||||
|
||||
V8ValueType type = V8Native.GetV8ValueType(this);
|
||||
return type;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// convert this V8JsValue object to bool if the type is bool
|
||||
/// </summary>
|
||||
public bool ToBool()
|
||||
{
|
||||
if (!this.IsValid)
|
||||
{
|
||||
throw new JavaScriptUsageException("Current V8JsValue doesn't have valid value to do this Operation [ToBool]", string.Empty, V8JsErrorType.InvalidOperation);
|
||||
}
|
||||
|
||||
bool result;
|
||||
V8Native.ThrowIfError(V8Native.GetV8ValueAsBool(this, out result));
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// convert this V8JsValue object to long if the type is a number (int or uint)
|
||||
/// </summary>
|
||||
public long ToInt()
|
||||
{
|
||||
if (!this.IsValid)
|
||||
{
|
||||
throw new JavaScriptUsageException("Current V8JsValue doesn't have valid value to do this Operation [ToInt]", string.Empty, V8JsErrorType.InvalidOperation);
|
||||
}
|
||||
|
||||
long result;
|
||||
V8Native.ThrowIfError(V8Native.GetV8ValueAsInt(this, out result));
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// convert this V8JsValue object to double if the type is double
|
||||
/// </summary>
|
||||
public double ToDouble()
|
||||
{
|
||||
if (!this.IsValid)
|
||||
{
|
||||
throw new JavaScriptUsageException("Current V8JsValue doesn't have valid value to do this Operation [ToDouble]", string.Empty, V8JsErrorType.InvalidOperation);
|
||||
}
|
||||
|
||||
double result;
|
||||
V8Native.ThrowIfError(V8Native.GetV8ValueAsDouble(this, out result));
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// convert this V8JsValue object to string if the type is string
|
||||
/// </summary>
|
||||
public new string ToString()
|
||||
{
|
||||
if (!this.IsValid)
|
||||
{
|
||||
throw new JavaScriptUsageException("Current V8JsValue doesn't have valid value to do this Operation [ToString]", string.Empty, V8JsErrorType.InvalidOperation);
|
||||
}
|
||||
|
||||
IntPtr buffer;
|
||||
int length;
|
||||
V8Native.ThrowIfError(V8Native.GetV8ValueAsString(this, out buffer, out length));
|
||||
return Marshal.PtrToStringUni(buffer);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the length of current Javascript(V8JsValue) object
|
||||
/// </summary>
|
||||
public int GetPropertyLength()
|
||||
{
|
||||
if (!this.IsValid)
|
||||
{
|
||||
throw new JavaScriptUsageException("Current V8JsValue doesn't have valid value to do this Operation [GetPropertyLength]", string.Empty, V8JsErrorType.InvalidOperation);
|
||||
}
|
||||
|
||||
int length;
|
||||
V8Native.ThrowIfError(V8Native.GetLength(this, out length));
|
||||
return length;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the length of current Javascript(V8JsValue) Array
|
||||
/// </summary>
|
||||
public int GetArrayLength()
|
||||
{
|
||||
if (!this.IsValid)
|
||||
{
|
||||
throw new JavaScriptUsageException("Current V8JsValue doesn't have valid value to do this Operation [GetArrayLength]", string.Empty, V8JsErrorType.InvalidOperation);
|
||||
}
|
||||
|
||||
int length;
|
||||
V8Native.ThrowIfError(V8Native.GetLength(this, out length));
|
||||
return length;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// if current object has any property name then it will return the name.
|
||||
/// e.g {'name' : value}. this method will return 'name'.
|
||||
/// </summary>
|
||||
public string GetPropertyName()
|
||||
{
|
||||
if (!this.IsValid)
|
||||
{
|
||||
throw new JavaScriptUsageException("Current V8JsValue doesn't have valid value to do this Operation [GetPropertyName]", string.Empty, V8JsErrorType.InvalidOperation);
|
||||
}
|
||||
|
||||
IntPtr buffer;
|
||||
int length;
|
||||
V8Native.ThrowIfError(V8Native.GetOwnPropertyName(this, out buffer, out length));
|
||||
return Marshal.PtrToStringUni(buffer, length);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// if current object has any property name then it will return the name.
|
||||
/// e.g {'name' : value}. this method will return 'name'.
|
||||
/// </summary>
|
||||
public V8JsValue GetProperty(int index)
|
||||
{
|
||||
if (!this.IsValid)
|
||||
{
|
||||
throw new JavaScriptUsageException("Current V8JsValue doesn't have valid value to do this Operation [GetProperty]", string.Empty, V8JsErrorType.InvalidOperation);
|
||||
}
|
||||
|
||||
V8JsValue prop;
|
||||
V8Native.ThrowIfError(V8Native.GetObjectByIndex(this, index, out prop));
|
||||
return prop;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (this.IsValid)
|
||||
{
|
||||
V8Native.ThrowIfError(V8Native.DisposeV8Value(this));
|
||||
this.reference = IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,92 @@
|
|||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright file="V8Native.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// </copyright>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
namespace JsRT.V8
|
||||
{
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
public class V8Native
|
||||
{
|
||||
private const string DllName = "v8.dll";
|
||||
|
||||
public static void ThrowIfError(V8JsErrorType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case V8JsErrorType.JsNoError:
|
||||
return;
|
||||
case V8JsErrorType.InvalidRuntime:
|
||||
throw new JavaScriptUsageException("Invalid V8 Runtime", string.Empty, type);
|
||||
case V8JsErrorType.InvalidOperation:
|
||||
throw new JavaScriptUsageException("Invalid operation for current object", string.Empty, type);
|
||||
case V8JsErrorType.NullArgument:
|
||||
throw new JavaScriptUsageException("Argument is Null", string.Empty, type);
|
||||
case V8JsErrorType.NullReference:
|
||||
throw new JavaScriptUsageException("Reference is Null", string.Empty, type);
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern V8JsErrorType InitializeV8(int threadpoolSize, bool idleTaskSupport);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern V8JsErrorType DisposeV8Platform();
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern V8JsErrorType CreateV8RunTime(int maxOldSpaceInMB, int maxSemiSpaceInMB, out V8Runtime runtime);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern V8JsErrorType DisposeV8Runtime(V8Runtime runtime);
|
||||
|
||||
[DllImport(DllName, CharSet = CharSet.Unicode)]
|
||||
public static extern V8JsErrorType RunScript(V8Runtime runtime, string script, bool evalute, out V8JsValue result);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern V8JsErrorType Idle(V8Runtime handle);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern V8JsErrorType CollectGarbage(V8Runtime handle);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern V8JsErrorType GetException(V8Runtime handle, out V8JsException v8JsException);
|
||||
|
||||
[DllImport(DllName, CharSet = CharSet.Unicode)]
|
||||
public static extern V8JsErrorType GetExceptionMessage(V8JsException v8JsException, out IntPtr message, out int length);
|
||||
|
||||
[DllImport(DllName, CharSet = CharSet.Unicode)]
|
||||
public static extern V8JsErrorType GetStackTrace(V8JsException v8JsException, out IntPtr message, out int length);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern V8ValueType GetV8ValueType(V8JsValue value);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern V8JsErrorType GetV8ValueAsBool(V8JsValue value, out bool result);
|
||||
|
||||
[DllImport(DllName, CharSet = CharSet.Unicode)]
|
||||
public static extern V8JsErrorType GetV8ValueAsString(V8JsValue value, out IntPtr result, out int length);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern V8JsErrorType GetV8ValueAsInt(V8JsValue value, out long result);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern V8JsErrorType GetV8ValueAsDouble(V8JsValue value, out double result);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern V8JsErrorType GetLength(V8JsValue value, out int length);
|
||||
|
||||
// need to change method name
|
||||
|
||||
[DllImport(DllName, CharSet = CharSet.Unicode)]
|
||||
public static extern V8JsErrorType GetOwnPropertyName(V8JsValue value, out IntPtr name, out int length);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern V8JsErrorType GetObjectByIndex(V8JsValue value, int index, out V8JsValue result);
|
||||
|
||||
[DllImport(DllName)]
|
||||
public static extern V8JsErrorType DisposeV8Value(V8JsValue value);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,78 @@
|
|||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright file="V8Runtime.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// </copyright>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
namespace JsRT.V8
|
||||
{
|
||||
using System;
|
||||
|
||||
public struct V8Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// This will hold the Native runtime Object
|
||||
/// </summary>
|
||||
private IntPtr handle;
|
||||
|
||||
public static V8Runtime CreateRuntime(int maxOldSpaceInMB, int maxSemiSpaceInMB)
|
||||
{
|
||||
V8Runtime runtime;
|
||||
V8Native.ThrowIfError(V8Native.CreateV8RunTime(maxOldSpaceInMB, maxSemiSpaceInMB, out runtime));
|
||||
return runtime;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="script">javascript as a plain string</param>
|
||||
/// <param name="evalute">if true then convert javascript output to V8Native object</param>
|
||||
/// <returns></returns>
|
||||
public V8JsValue RunScript(string script, bool evalute)
|
||||
{
|
||||
V8JsValue result;
|
||||
var errorCode = V8Native.RunScript(this, script, evalute, out result);
|
||||
if (errorCode == V8JsErrorType.JsNoError)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
else if (errorCode == V8JsErrorType.ScriptCompilationError || errorCode == V8JsErrorType.ScriptExecutionException)
|
||||
{
|
||||
V8JsException exception;
|
||||
V8Native.ThrowIfError(V8Native.GetException(this, out exception));
|
||||
throw exception.GetException(errorCode);
|
||||
}
|
||||
else
|
||||
{
|
||||
V8Native.ThrowIfError(errorCode);
|
||||
}
|
||||
|
||||
return V8JsValue.Invalid;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This will tell V8Runtime to go Idle.
|
||||
/// </summary>
|
||||
public void Idle()
|
||||
{
|
||||
V8Native.ThrowIfError(V8Native.Idle(this));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Performs a full garbage collection.
|
||||
/// </summary>
|
||||
public void CollectGarbage()
|
||||
{
|
||||
V8Native.ThrowIfError(V8Native.CollectGarbage(this));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Dispose native V8RuntimeHandler object.
|
||||
/// During freeing V8RuntimeHandler, it will also free current context and exception object
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
V8Native.ThrowIfError(V8Native.DisposeV8Runtime(this));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright file="V8ValueType.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// </copyright>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
namespace JsRT.V8
|
||||
{
|
||||
using System;
|
||||
|
||||
[Flags]
|
||||
public enum V8ValueType
|
||||
{
|
||||
Null = 0,
|
||||
Undefined = 1,
|
||||
Boolean = 2,
|
||||
Integer = 3,
|
||||
Double = 4,
|
||||
String = 5,
|
||||
Object = 6,
|
||||
Array = 7,
|
||||
UnknownType = 8
|
||||
}
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
// <autogenerated />
|
||||
using System;
|
||||
using System.Reflection;
|
||||
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v3.1", FrameworkDisplayName = "")]
|
|
@ -0,0 +1,23 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
[assembly: System.Reflection.AssemblyCompanyAttribute("JsRT.V8")]
|
||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
|
||||
[assembly: System.Reflection.AssemblyProductAttribute("JsRT.V8")]
|
||||
[assembly: System.Reflection.AssemblyTitleAttribute("JsRT.V8")]
|
||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||
|
||||
// Generated by the MSBuild WriteCodeFragment class.
|
||||
|
|
@ -0,0 +1 @@
|
|||
aca931baa8bf633565fabd19542a42b131bc7911
|
|
@ -0,0 +1,3 @@
|
|||
is_global = true
|
||||
build_property.RootNamespace = JsRT.V8
|
||||
build_property.ProjectDir = e:\V8ManagedWrapper\V8_Managed_Library\JsRT.V8\
|
Двоичный файл не отображается.
Двоичные данные
V8_Managed_Library/JsRT.V8/obj/Debug/netcoreapp3.1/JsRT.V8.csproj.AssemblyReference.cache
Normal file
Двоичные данные
V8_Managed_Library/JsRT.V8/obj/Debug/netcoreapp3.1/JsRT.V8.csproj.AssemblyReference.cache
Normal file
Двоичный файл не отображается.
|
@ -0,0 +1,68 @@
|
|||
{
|
||||
"format": 1,
|
||||
"restore": {
|
||||
"D:\\Serp_V8\\V8_Managed_Library\\JsRT.V8\\JsRT.V8.csproj": {}
|
||||
},
|
||||
"projects": {
|
||||
"D:\\Serp_V8\\V8_Managed_Library\\JsRT.V8\\JsRT.V8.csproj": {
|
||||
"version": "1.0.0",
|
||||
"restore": {
|
||||
"projectUniqueName": "D:\\Serp_V8\\V8_Managed_Library\\JsRT.V8\\JsRT.V8.csproj",
|
||||
"projectName": "JsRT.V8",
|
||||
"projectPath": "D:\\Serp_V8\\V8_Managed_Library\\JsRT.V8\\JsRT.V8.csproj",
|
||||
"packagesPath": "D:\\NugetCache",
|
||||
"outputPath": "D:\\Serp_V8\\V8_Managed_Library\\JsRT.V8\\obj\\",
|
||||
"projectStyle": "PackageReference",
|
||||
"fallbackFolders": [
|
||||
"C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages"
|
||||
],
|
||||
"configFilePaths": [
|
||||
"D:\\Serp_V8\\NuGet.Config",
|
||||
"C:\\Users\\saabdull.REDMOND\\AppData\\Roaming\\NuGet\\NuGet.Config",
|
||||
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.FallbackLocation.config",
|
||||
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config"
|
||||
],
|
||||
"originalTargetFrameworks": [
|
||||
"netcoreapp3.1"
|
||||
],
|
||||
"sources": {
|
||||
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
|
||||
"https://api.nuget.org/v3/index.json": {},
|
||||
"https://msasg.pkgs.visualstudio.com/_packaging/snrcode/nuget/v3/index.json": {}
|
||||
},
|
||||
"frameworks": {
|
||||
"netcoreapp3.1": {
|
||||
"targetAlias": "netcoreapp3.1",
|
||||
"projectReferences": {}
|
||||
}
|
||||
},
|
||||
"warningProperties": {
|
||||
"warnAsError": [
|
||||
"NU1605"
|
||||
]
|
||||
}
|
||||
},
|
||||
"frameworks": {
|
||||
"netcoreapp3.1": {
|
||||
"targetAlias": "netcoreapp3.1",
|
||||
"imports": [
|
||||
"net461",
|
||||
"net462",
|
||||
"net47",
|
||||
"net471",
|
||||
"net472",
|
||||
"net48"
|
||||
],
|
||||
"assetTargetFallback": true,
|
||||
"warn": true,
|
||||
"frameworkReferences": {
|
||||
"Microsoft.NETCore.App": {
|
||||
"privateAssets": "all"
|
||||
}
|
||||
},
|
||||
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\6.0.101\\RuntimeIdentifierGraph.json"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
||||
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
|
||||
<RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess>
|
||||
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
|
||||
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile>
|
||||
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">D:\NugetCache</NuGetPackageRoot>
|
||||
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">D:\NugetCache;C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages</NuGetPackageFolders>
|
||||
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
|
||||
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">6.0.1</NuGetToolVersion>
|
||||
</PropertyGroup>
|
||||
<ItemGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
|
||||
<SourceRoot Include="D:\NugetCache\" />
|
||||
<SourceRoot Include="C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages\" />
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -0,0 +1,2 @@
|
|||
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
||||
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" />
|
|
@ -0,0 +1,74 @@
|
|||
{
|
||||
"version": 3,
|
||||
"targets": {
|
||||
".NETCoreApp,Version=v3.1": {}
|
||||
},
|
||||
"libraries": {},
|
||||
"projectFileDependencyGroups": {
|
||||
".NETCoreApp,Version=v3.1": []
|
||||
},
|
||||
"packageFolders": {
|
||||
"D:\\NugetCache": {},
|
||||
"C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages": {}
|
||||
},
|
||||
"project": {
|
||||
"version": "1.0.0",
|
||||
"restore": {
|
||||
"projectUniqueName": "D:\\Serp_V8\\V8_Managed_Library\\JsRT.V8\\JsRT.V8.csproj",
|
||||
"projectName": "JsRT.V8",
|
||||
"projectPath": "D:\\Serp_V8\\V8_Managed_Library\\JsRT.V8\\JsRT.V8.csproj",
|
||||
"packagesPath": "D:\\NugetCache",
|
||||
"outputPath": "D:\\Serp_V8\\V8_Managed_Library\\JsRT.V8\\obj\\",
|
||||
"projectStyle": "PackageReference",
|
||||
"fallbackFolders": [
|
||||
"C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages"
|
||||
],
|
||||
"configFilePaths": [
|
||||
"D:\\Serp_V8\\NuGet.Config",
|
||||
"C:\\Users\\saabdull.REDMOND\\AppData\\Roaming\\NuGet\\NuGet.Config",
|
||||
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.FallbackLocation.config",
|
||||
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config"
|
||||
],
|
||||
"originalTargetFrameworks": [
|
||||
"netcoreapp3.1"
|
||||
],
|
||||
"sources": {
|
||||
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
|
||||
"https://api.nuget.org/v3/index.json": {},
|
||||
"https://msasg.pkgs.visualstudio.com/_packaging/snrcode/nuget/v3/index.json": {}
|
||||
},
|
||||
"frameworks": {
|
||||
"netcoreapp3.1": {
|
||||
"targetAlias": "netcoreapp3.1",
|
||||
"projectReferences": {}
|
||||
}
|
||||
},
|
||||
"warningProperties": {
|
||||
"warnAsError": [
|
||||
"NU1605"
|
||||
]
|
||||
}
|
||||
},
|
||||
"frameworks": {
|
||||
"netcoreapp3.1": {
|
||||
"targetAlias": "netcoreapp3.1",
|
||||
"imports": [
|
||||
"net461",
|
||||
"net462",
|
||||
"net47",
|
||||
"net471",
|
||||
"net472",
|
||||
"net48"
|
||||
],
|
||||
"assetTargetFallback": true,
|
||||
"warn": true,
|
||||
"frameworkReferences": {
|
||||
"Microsoft.NETCore.App": {
|
||||
"privateAssets": "all"
|
||||
}
|
||||
},
|
||||
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\6.0.101\\RuntimeIdentifierGraph.json"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"version": 2,
|
||||
"dgSpecHash": "dNHU+xXmkto6ZSY6f0fVEH4qeiOcbazMjHNXI4135UqSKbN4BIHIc6cN3XbDz8Hj2zfaNfqqYC3bcLMRgWEkIg==",
|
||||
"success": true,
|
||||
"projectFilePath": "D:\\Serp_V8\\V8_Managed_Library\\JsRT.V8\\JsRT.V8.csproj",
|
||||
"expectedPackageFiles": [],
|
||||
"logs": []
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
// <autogenerated />
|
||||
using System;
|
||||
using System.Reflection;
|
||||
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v3.1", FrameworkDisplayName = "")]
|
|
@ -0,0 +1,23 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
[assembly: System.Reflection.AssemblyCompanyAttribute("JsRT.V8")]
|
||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
|
||||
[assembly: System.Reflection.AssemblyProductAttribute("JsRT.V8")]
|
||||
[assembly: System.Reflection.AssemblyTitleAttribute("JsRT.V8")]
|
||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||
|
||||
// Generated by the MSBuild WriteCodeFragment class.
|
||||
|
|
@ -0,0 +1 @@
|
|||
aca931baa8bf633565fabd19542a42b131bc7911
|
|
@ -0,0 +1,3 @@
|
|||
is_global = true
|
||||
build_property.RootNamespace = JsRT.V8
|
||||
build_property.ProjectDir = D:\Serp_V8\V8_Managed_Library\JsRT.V8\
|
Двоичные данные
V8_Managed_Library/JsRT.V8/obj/x64/Debug/netcoreapp3.1/JsRT.V8.assets.cache
Normal file
Двоичные данные
V8_Managed_Library/JsRT.V8/obj/x64/Debug/netcoreapp3.1/JsRT.V8.assets.cache
Normal file
Двоичный файл не отображается.
Двоичные данные
V8_Managed_Library/JsRT.V8/obj/x64/Debug/netcoreapp3.1/JsRT.V8.csproj.AssemblyReference.cache
Normal file
Двоичные данные
V8_Managed_Library/JsRT.V8/obj/x64/Debug/netcoreapp3.1/JsRT.V8.csproj.AssemblyReference.cache
Normal file
Двоичный файл не отображается.
|
@ -0,0 +1,64 @@
|
|||
namespace Microsoft.Search.Frontend.V8
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
|
||||
public static class Helper
|
||||
{
|
||||
public static readonly string[] Library = new string[]
|
||||
{
|
||||
"ServerSideRenderingDataManager.js",
|
||||
"ServerSideRendering.LayoutWriter.js",
|
||||
"ServerSideRendering.Instrumentation.js",
|
||||
"react.production16.1.1.min.js",
|
||||
"react-dom-server.browser.production16.1.1.min.js",
|
||||
"redux.min.js",
|
||||
"Region.js",
|
||||
"InstLink.js",
|
||||
"InstForm.js",
|
||||
"CommentBox.js",
|
||||
"CommentBoxServerRendering.js"
|
||||
};
|
||||
|
||||
public static readonly string DataScript;
|
||||
|
||||
public static readonly string RenderScript = "ServerSideRenderingCommentBoxEample.render();";
|
||||
public static readonly string RenderSaveBox = "ServerSideRenderingCommentBoxEample.renderMySave();";
|
||||
public static readonly string InstrumentationScript = "HostInstrumentation.getInstrumentationObject();ServerSideRenderingDataManager.clear();LayoutWriter.clear();";
|
||||
|
||||
public static readonly Dictionary<string, string> JavascriptLibary = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
static Helper()
|
||||
{
|
||||
foreach (var fileName in Library)
|
||||
{
|
||||
JavascriptLibary[fileName] = LoadFile(fileName);
|
||||
}
|
||||
|
||||
DataScript = LoadFile("Data.txt");
|
||||
}
|
||||
|
||||
public static string LoadFile(string filename)
|
||||
{
|
||||
var path = Path.Combine("Scripts", filename);
|
||||
if (File.Exists(path))
|
||||
{
|
||||
return File.ReadAllText(path);
|
||||
}
|
||||
|
||||
throw new Exception("File doesn't exit " + path);
|
||||
}
|
||||
|
||||
public static long ExecuteAction(Stopwatch stopwatch, Action action, string eventName = "")
|
||||
{
|
||||
stopwatch.Restart();
|
||||
action.Invoke();
|
||||
stopwatch.Stop();
|
||||
var time = stopwatch.ElapsedMilliseconds;
|
||||
// Console.WriteLine(eventName + " Execution time : " + time);
|
||||
return time;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright file="Program.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// </copyright>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
namespace Microsoft.Search.Frontend.V8
|
||||
{
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using JsRT.V8;
|
||||
|
||||
|
||||
public class Program
|
||||
{
|
||||
static int Main(string[] args)
|
||||
{
|
||||
Directory.SetCurrentDirectory(Path.GetDirectoryName(Assembly.GetAssembly(typeof(Program)).Location));
|
||||
|
||||
try
|
||||
{
|
||||
var errorType = V8Native.InitializeV8(Environment.ProcessorCount, false);
|
||||
if (errorType == V8JsErrorType.JsNoError)
|
||||
{
|
||||
Console.WriteLine("Loaded V8");
|
||||
|
||||
Tests.StringReturnAfterJavaScriptExecution();
|
||||
Tests.NumberReturnAfterJavaScriptExecution();
|
||||
Tests.TestsWebAppPageWithReact();
|
||||
|
||||
// generated perf result
|
||||
Tests.RecordPerfResults(3);
|
||||
Tests.RecordPerfResults(100);
|
||||
|
||||
errorType = V8Native.DisposeV8Platform();
|
||||
if (errorType == V8JsErrorType.JsNoError)
|
||||
{
|
||||
Console.WriteLine("Disposed V8");
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"Exception. {ex.Message}. stacktrace {ex.StackTrace}");
|
||||
return -1;
|
||||
}
|
||||
|
||||
Console.WriteLine("Ending Console App");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
# **Bing CoreUX V8 plugin Test Project** #
|
||||
|
||||
In order to run the Tests project you need to build V8 source code with plugin code. First Open Visual Studio 2017 Developer Command Prompt then execute following command
|
||||
|
||||
**Command:**
|
||||
```
|
||||
>> V8Build.cmd init debug/release
|
||||
or
|
||||
>> V8Build.cmd debug/release (if you have the V8 source code)
|
||||
```
|
||||
|
||||
After build is complete V8_monolith.lib and header files will be copied to lib folder. Then you need to build V8_Native project to generate v8.dll files.
|
|
@ -0,0 +1,126 @@
|
|||
// A '.tsx' file enables JSX support in the TypeScript compiler,
|
||||
// for more information see the following page on the TypeScript wiki:
|
||||
// https://github.com/Microsoft/TypeScript/wiki/JSX
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
||||
return function (d, b) {
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
/// <reference path="React\react.d.ts" />
|
||||
/// <reference path="Declarations\InstLink.d.ts" />
|
||||
var BingComment = /** @class */ (function (_super) {
|
||||
__extends(BingComment, _super);
|
||||
function BingComment() {
|
||||
return _super !== null && _super.apply(this, arguments) || this;
|
||||
}
|
||||
BingComment.prototype.render = function () {
|
||||
if (this.props !== null) {
|
||||
return (React.createElement("div", { className: "comment" },
|
||||
React.createElement("h3", { className: "commentAuthor" }, this.props.Author),
|
||||
React.createElement("div", { className: "commentText" }, this.props.Message)));
|
||||
}
|
||||
};
|
||||
return BingComment;
|
||||
}(React.Component));
|
||||
var CommentList = /** @class */ (function (_super) {
|
||||
__extends(CommentList, _super);
|
||||
function CommentList(props) {
|
||||
var _this = _super.call(this, props) || this;
|
||||
_this.state = { comments: _this.props.comments };
|
||||
return _this;
|
||||
}
|
||||
CommentList.prototype.render = function () {
|
||||
return (React.createElement("div", null,
|
||||
React.createElement("div", { className: "commentList" }, this.state.comments.map(function (comment) { return React.createElement(BingComment, { Author: comment.Author, Message: comment.Message, key: comment.Message }); }))));
|
||||
};
|
||||
return CommentList;
|
||||
}(React.Component));
|
||||
var CommentForm = /** @class */ (function (_super) {
|
||||
__extends(CommentForm, _super);
|
||||
function CommentForm() {
|
||||
return _super !== null && _super.apply(this, arguments) || this;
|
||||
}
|
||||
CommentForm.prototype.handleSubmit = function (e) {
|
||||
e && e.preventDefault();
|
||||
var ref = this.refs;
|
||||
var author = ref.author.value.trim();
|
||||
var text = ref.text.value.trim();
|
||||
console.log(author);
|
||||
console.log(text);
|
||||
this.props.addComment(author, text);
|
||||
};
|
||||
CommentForm.prototype.render = function () {
|
||||
var link = { UrlWithFormCode: null, UniqueId: { Namespace: 'SERP', KValue: 200, k: 200 }, CurrentUseCount: 0 };
|
||||
return (React.createElement(InstForm, { className: "commentForm", onSubmit: this.handleSubmit.bind(this), Link: link, InstParentNodeName: "region_root" },
|
||||
React.createElement("input", { type: "text", placeholder: "Your name", ref: "author" }),
|
||||
React.createElement("input", { type: "text", placeholder: "Say something...", ref: "text" }),
|
||||
React.createElement("input", { type: "submit", value: "Post" })));
|
||||
};
|
||||
return CommentForm;
|
||||
}(React.Component));
|
||||
var Footer = /** @class */ (function (_super) {
|
||||
__extends(Footer, _super);
|
||||
function Footer() {
|
||||
return _super !== null && _super.apply(this, arguments) || this;
|
||||
}
|
||||
Footer.prototype.render = function () {
|
||||
return (React.createElement("div", null));
|
||||
};
|
||||
return Footer;
|
||||
}(React.Component));
|
||||
var CommentBox = /** @class */ (function (_super) {
|
||||
__extends(CommentBox, _super);
|
||||
function CommentBox(props) {
|
||||
var _this = _super.call(this, props) || this;
|
||||
_this.state = { title: _this.props.Title, comments: _this.props.Comments, link: _this.props.Link };
|
||||
return _this;
|
||||
}
|
||||
CommentBox.prototype.updateCommentList = function (author, message) {
|
||||
this.setState({
|
||||
comments: this.state.comments.push({ Author: author, Message: message })
|
||||
});
|
||||
};
|
||||
CommentBox.prototype.render = function () {
|
||||
return (React.createElement(Region, { Type: "L.Box", DisplayRegion: "ServerSideRenderingReact", InstNodeName: "region_root" },
|
||||
React.createElement("div", { className: "commentBox" },
|
||||
React.createElement("h1", null, this.props.Title),
|
||||
React.createElement("h2", null, "Comments"),
|
||||
React.createElement(CommentList, { comments: this.state.comments }),
|
||||
React.createElement(CommentForm, { addComment: this.updateCommentList.bind(this) }),
|
||||
React.createElement(InstLink, { InstItem: this.state.link, "data-partnertag": "serversiderendering", Content: "Bing @", InstParentNodeName: "region_root" }),
|
||||
React.createElement(InstLink, { InstItem: this.state.link, "data-partnertag": "serversiderendering", Content: " Microsoft", InstParentNodeName: "region_root" }),
|
||||
React.createElement(Region, { Type: "L.Empty", DisplayRegion: "EmptyRegion", IsEmptyChild: true, InstParentNodeName: "region_root" }))));
|
||||
};
|
||||
return CommentBox;
|
||||
}(React.Component));
|
||||
var MySaveBox = /** @class */ (function (_super) {
|
||||
__extends(MySaveBox, _super);
|
||||
function MySaveBox(props) {
|
||||
return _super.call(this, props) || this;
|
||||
}
|
||||
MySaveBox.prototype.render = function () {
|
||||
var title = this.props.Title.indexOf("siam") <= 0 ? this.props.Title : this.props.Title + " _bing";
|
||||
var body = this.props.Body.length > 0 ? this.props.Body : " default body";
|
||||
return (React.createElement("div", { "class": "mysaveBox" },
|
||||
React.createElement("h5", null, title),
|
||||
React.createElement("p", null, body),
|
||||
React.createElement("img", { src: this.props.Url })));
|
||||
};
|
||||
return MySaveBox;
|
||||
}(React.Component));
|
||||
var unique = 0;
|
||||
var MySave = /** @class */ (function (_super) {
|
||||
__extends(MySave, _super);
|
||||
function MySave(props) {
|
||||
return _super.call(this, props) || this;
|
||||
}
|
||||
MySave.prototype.render = function () {
|
||||
return (React.createElement(Region, { Type: "L.Box", DisplayRegion: "mysave", InstNodeName: "mysave" }, this.props.Data.map(function (mysaveData) { return React.createElement(MySaveBox, { Title: mysaveData.Title, Body: mysaveData.Body, Url: mysaveData.Url, key: unique++ }); })));
|
||||
};
|
||||
return MySave;
|
||||
}(React.Component));
|
|
@ -0,0 +1,31 @@
|
|||
///<reference path="..\..\..\..\..\..\Serp\AppResources\Scripts\ServerSideRendering\ServerSideRenderingDataManager.d.ts" />
|
||||
///<reference path="..\..\..\..\..\..\Serp\AppResources\Scripts\ServerSideRendering\ServerSideRendering.Instrumentation.d.ts" />
|
||||
///<reference path="React\React-server-dom16.d.ts" />
|
||||
// Gettign the data that we register using ServerSideRendering:Data view
|
||||
var ServerSideRenderingCommentBoxEample;
|
||||
(function (ServerSideRenderingCommentBoxEample) {
|
||||
function render() {
|
||||
var commentBoxData = ServerSideRenderingDataManager.get("CommentBoxData");
|
||||
var link = ServerSideRenderingDataManager.get("link");
|
||||
ServerSideLayoutInstrumentation.setPageInfo("ServerSideReact", 101);
|
||||
// ReactDOMServer.renderToString executes on serverside and return the html output as string.
|
||||
return ReactDOMServer.renderToString(React.createElement(CommentBox, { Title: commentBoxData.Title, Comments: commentBoxData.Comments, Link: link }));
|
||||
}
|
||||
ServerSideRenderingCommentBoxEample.render = render;
|
||||
function renderMySave() {
|
||||
var data = ServerSideRenderingDataManager.get("mysaveData");
|
||||
return ReactDOMServer.renderToString(React.createElement(MySave, { Data: data.Data }));
|
||||
}
|
||||
ServerSideRenderingCommentBoxEample.renderMySave = renderMySave;
|
||||
function renderFibonacci() {
|
||||
getFibonnaci(1000);
|
||||
return "Fibonnaci Done";
|
||||
}
|
||||
ServerSideRenderingCommentBoxEample.renderFibonacci = renderFibonacci;
|
||||
function getFibonnaci(num) {
|
||||
if (num <= 1)
|
||||
return 1;
|
||||
return getFibonnaci(num - 1) + getFibonnaci(num - 2);
|
||||
}
|
||||
})(ServerSideRenderingCommentBoxEample || (ServerSideRenderingCommentBoxEample = {}));
|
||||
//# sourceMappingURL=CommentBoxServerRendering.js.map
|
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
|
@ -0,0 +1,143 @@
|
|||
/// <reference path="..\React\react.d.ts" />
|
||||
/// <reference path="..\Declarations\InstLink.d.ts" />
|
||||
///<reference path="..\..\..\..\..\..\..\Serp\AppResources\Scripts\ServerSideRendering\ServerSideRendering.Instrumentation.d.ts" />
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
||||
return function (d, b) {
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
var __assign = (this && this.__assign) || Object.assign || function(t) {
|
||||
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
||||
s = arguments[i];
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
||||
t[p] = s[p];
|
||||
}
|
||||
return t;
|
||||
};
|
||||
var InstForm = /** @class */ (function (_super) {
|
||||
__extends(InstForm, _super);
|
||||
function InstForm(props) {
|
||||
var _this = _super.call(this, props) || this;
|
||||
_this.state = _this.getState(_this.props);
|
||||
return _this;
|
||||
}
|
||||
InstForm.prototype.componentWillMount = function () {
|
||||
if (!this.state.isStartRegionLogging && !this.state.isCloseRegionLogging) {
|
||||
this.state.isStartRegionLogging = true;
|
||||
ServerSideLayoutInstrumentation.startForm(this.state.appNS, this.state.k, this.state.nodeName, this.state.parentNodeName);
|
||||
// If parent node is provide then close the region.
|
||||
// Child component under this region has to use ParentNodeName to be instrumented under this region.
|
||||
if (this.state.parentNodeName) {
|
||||
this.closeInstrumentationNode(this.state);
|
||||
}
|
||||
}
|
||||
};
|
||||
InstForm.prototype.closeInstrumentationNode = function (state) {
|
||||
if (state.isStartRegionLogging && !state.isCloseRegionLogging) {
|
||||
state.isCloseRegionLogging = true;
|
||||
ServerSideLayoutInstrumentation.closeForm();
|
||||
}
|
||||
};
|
||||
InstForm.prototype.componentDidMount = function () {
|
||||
this.closeInstrumentationNode(this.state);
|
||||
};
|
||||
InstForm.prototype.getItemFromProperty = function (props, propertyName, defaultValue) {
|
||||
if (props.hasOwnProperty(propertyName) && props[propertyName]) {
|
||||
return props[propertyName];
|
||||
}
|
||||
else
|
||||
return defaultValue;
|
||||
};
|
||||
InstForm.prototype.handleSubmit = function (event) {
|
||||
if (this.state.onSubmit) {
|
||||
this.state.onSubmit(event);
|
||||
}
|
||||
};
|
||||
InstForm.prototype.callGPing = function (event) {
|
||||
return si_ct && si_ct(this, 1);
|
||||
};
|
||||
InstForm.prototype.getState = function (props) {
|
||||
var instNodeName = "InstNodeName", nodeName = props.hasOwnProperty(instNodeName) && props[instNodeName] ? props[instNodeName] : null;
|
||||
var instParentNodeName = "InstParentNodeName", parentNodeName = props.hasOwnProperty(instParentNodeName) && props[instParentNodeName] ? props[instParentNodeName] : null;
|
||||
var onsubmitPropertyName = "onSubmit";
|
||||
var actionPropertyName = "action";
|
||||
var linkPropertyName = "Link";
|
||||
var suppressGPingPropertyName = "SuppressGPing";
|
||||
var renderableProperties = {};
|
||||
var appNS = "SERP";
|
||||
var k = "";
|
||||
var link = this.getItemFromProperty(props, linkPropertyName, null);
|
||||
if (link == null) {
|
||||
throw "Link parameter is required for InstForm";
|
||||
}
|
||||
var suppressGPing = this.getItemFromProperty(props, suppressGPingPropertyName, false);
|
||||
var url = link != null ? link.UrlWithFormCode : null;
|
||||
if (url != null) {
|
||||
renderableProperties["action"] = url;
|
||||
}
|
||||
var instrumentedItem = link;
|
||||
if (instrumentedItem != null) {
|
||||
instrumentedItem.CurrentUseCount++;
|
||||
appNS = instrumentedItem.UniqueId.Namespace;
|
||||
k = instrumentedItem.UniqueId.KValue.toString();
|
||||
if (instrumentedItem.CurrentUseCount > 0) {
|
||||
k += "." + instrumentedItem.CurrentUseCount.toString();
|
||||
}
|
||||
}
|
||||
var onSubmit = props.hasOwnProperty(onsubmitPropertyName) && props[onsubmitPropertyName] ? props[onsubmitPropertyName] : null;
|
||||
var hasGPing = !suppressGPing;
|
||||
if (hasGPing) {
|
||||
renderableProperties["data-h"] = "ID=" + appNS + "," + k;
|
||||
}
|
||||
for (var property in props) {
|
||||
if (props.hasOwnProperty(property)) {
|
||||
// Skip "action", "onsubmit", "Link" and "SuppressGPing" properties
|
||||
if (property === onsubmitPropertyName ||
|
||||
property === actionPropertyName ||
|
||||
property === linkPropertyName ||
|
||||
property === instNodeName ||
|
||||
property === instParentNodeName ||
|
||||
property === suppressGPingPropertyName)
|
||||
continue;
|
||||
// copy all other attributes as is
|
||||
renderableProperties[property] = props[property];
|
||||
}
|
||||
}
|
||||
return {
|
||||
renderableProperties: renderableProperties,
|
||||
isStartRegionLogging: false,
|
||||
isCloseRegionLogging: false,
|
||||
appNS: appNS,
|
||||
k: k,
|
||||
hasGPing: hasGPing,
|
||||
onSubmit: onSubmit,
|
||||
nodeName: nodeName,
|
||||
parentNodeName: parentNodeName
|
||||
};
|
||||
};
|
||||
InstForm.prototype.render = function () {
|
||||
// Add "onsubmit" attribute, which is rendered differently based on the following cases:
|
||||
// 1. GPing only
|
||||
// 2. Caller-provided handler only
|
||||
// 3. Both GPing and caller-provided handler
|
||||
var hasOnSubmit = this.state.hasGPing || this.state.onSubmit !== null;
|
||||
if (!hasOnSubmit) {
|
||||
return (React.createElement("form", __assign({}, this.state.renderableProperties), this.props.children));
|
||||
}
|
||||
else if (this.state.hasGPing && !this.state.onSubmit) {
|
||||
return (React.createElement("form", __assign({}, this.state.renderableProperties, { onSubmit: this.callGPing.bind(this) }), this.props.children));
|
||||
}
|
||||
else if (!this.state.hasGPing && this.state.onSubmit) {
|
||||
return (React.createElement("form", __assign({}, this.state.renderableProperties, { onSubmit: this.handleSubmit.bind(this) }), this.props.children));
|
||||
}
|
||||
else {
|
||||
return (React.createElement("form", __assign({}, this.state.renderableProperties, { onSubmit: this.callGPing.bind(this) && this.handleSubmit.bind(this) }), this.props.children));
|
||||
}
|
||||
};
|
||||
return InstForm;
|
||||
}(React.Component));
|
|
@ -0,0 +1,106 @@
|
|||
/// <reference path="..\React\react.d.ts" />
|
||||
/// <reference path="..\Declarations\InstLink.d.ts" />
|
||||
///<reference path="..\..\..\..\..\..\..\Serp\AppResources\Scripts\ServerSideRendering\ServerSideRendering.Instrumentation.d.ts" />
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
||||
return function (d, b) {
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
var __assign = (this && this.__assign) || Object.assign || function(t) {
|
||||
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
||||
s = arguments[i];
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
||||
t[p] = s[p];
|
||||
}
|
||||
return t;
|
||||
};
|
||||
var InstLink = /** @class */ (function (_super) {
|
||||
__extends(InstLink, _super);
|
||||
function InstLink(props) {
|
||||
var _this = _super.call(this, props) || this;
|
||||
_this.state = _this.getNewState(_this.props);
|
||||
return _this;
|
||||
}
|
||||
InstLink.prototype.componentWillMount = function () {
|
||||
var instItem = this.state.instItem;
|
||||
if (instItem && !this.state.isInstrumented) {
|
||||
this.state.isInstrumented.isStartLink = true;
|
||||
instItem.CurrentUseCount++;
|
||||
var k = instItem.UniqueId.K + "";
|
||||
if (instItem.CurrentUseCount && instItem.CurrentUseCount > 0) {
|
||||
k = k + "." + instItem.CurrentUseCount;
|
||||
}
|
||||
ServerSideLayoutInstrumentation.startLink(instItem.UniqueId.Namespace, k, this.state.nodeName, this.state.parentNodeName);
|
||||
//InstLink can't have children so close the instrumentation node.
|
||||
ServerSideLayoutInstrumentation.closeLink();
|
||||
}
|
||||
};
|
||||
InstLink.prototype.componentWillReceiveProps = function (nextProps) {
|
||||
this.setState(this.getNewState(nextProps));
|
||||
};
|
||||
InstLink.prototype.getNewState = function (props) {
|
||||
var instNodeName = "InstNodeName", nodeName = props.hasOwnProperty(instNodeName) && props[instNodeName] ? props[instNodeName] : null;
|
||||
var instParentNodeName = "InstParentNodeName", parentNodeName = props.hasOwnProperty(instParentNodeName) && props[instParentNodeName] ? props[instParentNodeName] : null;
|
||||
// InstLink property
|
||||
var instItemPropertyName = "InstItem", instItem = props[instItemPropertyName];
|
||||
// TestHooks
|
||||
var testHooksEnablePropName = "TestHooksEnabled", testHooksEnabled = props[testHooksEnablePropName] === true, partnerTestHookPropertyName = "PartnerTestHook", dataPartnerTagAttributeName = "data-partnertag";
|
||||
var contentPropertyName = "Content";
|
||||
// Get all properties passed as attributes.
|
||||
// Then copy all of them except serialized objects as Link:ILink and Content:ReactComponent
|
||||
var allProperties = {};
|
||||
for (var property in props) {
|
||||
if (props.hasOwnProperty(property)) {
|
||||
// Skip "Link" and "Content" properties
|
||||
if (property === instItemPropertyName ||
|
||||
property === contentPropertyName ||
|
||||
property === instParentNodeName ||
|
||||
property === instNodeName ||
|
||||
property === testHooksEnablePropName)
|
||||
continue;
|
||||
// Translate PartnerTestHooks to data-partnertag if testhooks are enabled
|
||||
if (property === partnerTestHookPropertyName) {
|
||||
if (testHooksEnabled) {
|
||||
allProperties[dataPartnerTagAttributeName] = props[property];
|
||||
}
|
||||
// If TestHooksEnabled is not set to true explicitly - just skip this attribute
|
||||
continue;
|
||||
}
|
||||
// copy all other attributes as is
|
||||
allProperties[property] = props[property];
|
||||
}
|
||||
}
|
||||
// Prevent links from being draggable.
|
||||
allProperties["draggable"] = false;
|
||||
if (instItem) {
|
||||
// If href attribute is passed as a property - replace the one defined in ILink
|
||||
var hrefAttributeName = "href";
|
||||
if (!allProperties[hrefAttributeName]) {
|
||||
allProperties[hrefAttributeName] = instItem.UrlWithFormCode;
|
||||
}
|
||||
// Generate KValue + namespace to enable standard GPingClick instrumentation on the element. Add 1 to current use count
|
||||
// because it should be 1-based
|
||||
allProperties["data-h"] = "ID=" + instItem.UniqueId.Namespace + "," + instItem.UniqueId.K + "." + (instItem.CurrentUseCount + 1);
|
||||
}
|
||||
return {
|
||||
content: this.props[contentPropertyName] ? this.props[contentPropertyName] : this.props.children,
|
||||
properties: allProperties,
|
||||
isInstrumented: false,
|
||||
instItem: instItem,
|
||||
nodeName: nodeName,
|
||||
parentNodeName: parentNodeName
|
||||
};
|
||||
};
|
||||
InstLink.prototype.render = function () {
|
||||
return (React.createElement("a", __assign({}, this.state.properties),
|
||||
" ",
|
||||
this.state.content,
|
||||
" "));
|
||||
};
|
||||
return InstLink;
|
||||
}(React.Component));
|
|
@ -0,0 +1,100 @@
|
|||
/// <reference path="..\React\react.d.ts" />
|
||||
///<reference path="..\..\..\..\..\..\..\Serp\AppResources\Scripts\ServerSideRendering\ServerSideRendering.Instrumentation.d.ts" />
|
||||
///<reference path="..\..\..\..\..\..\..\Serp\AppResources\Scripts\ServerSideRendering\ServerSideRendering.RegionInstrumentation.d.ts" />
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
||||
return function (d, b) {
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
var Region = /** @class */ (function (_super) {
|
||||
__extends(Region, _super);
|
||||
function Region(props) {
|
||||
var _this = _super.call(this, props) || this;
|
||||
_this.state = _this.getState(_this.props);
|
||||
return _this;
|
||||
}
|
||||
Region.prototype.componentWillMount = function () {
|
||||
if (!this.state.isStartRegionLogging && !this.state.isCloseRegionLogging) {
|
||||
this.state.isStartRegionLogging = true;
|
||||
ServerSideLayoutInstrumentation.startRegion(this.state.regionInstrumentation, this.state.nodeName, this.state.parentNodeName);
|
||||
// If node name or parent node name is provided then close the region.
|
||||
// Child component under this region has to use ParentNodeName to be instrumented under this region.
|
||||
if (this.state.nodeName || this.state.parentNodeName) {
|
||||
this.closeInstrumentationNode(this.state);
|
||||
}
|
||||
}
|
||||
};
|
||||
Region.prototype.closeInstrumentationNode = function (state) {
|
||||
if (state.isStartRegionLogging && !state.isCloseRegionLogging) {
|
||||
state.isCloseRegionLogging = true;
|
||||
ServerSideLayoutInstrumentation.closeRegion();
|
||||
}
|
||||
};
|
||||
Region.prototype.componentDidMount = function () {
|
||||
this.closeInstrumentationNode(this.state);
|
||||
};
|
||||
Region.prototype.addPropertyIfExist = function (props, property, instrumentation, instProperty) {
|
||||
if (props.hasOwnProperty(property) && props[property]) {
|
||||
instrumentation[instProperty] = props[property];
|
||||
}
|
||||
};
|
||||
Region.prototype.getState = function (props) {
|
||||
var instNodeName = "InstNodeName", nodeName = props.hasOwnProperty(instNodeName) && props[instNodeName] ? props[instNodeName] : null;
|
||||
var instParentNodeName = "InstParentNodeName", parentNodeName = props.hasOwnProperty(instParentNodeName) && props[instParentNodeName] ? props[instParentNodeName] : null;
|
||||
var regionInstrumentation = { type: "L.BOX", appNS: "SERP" };
|
||||
var instrumentedItem = this.props.hasOwnProperty("InstrumentedItem") && this.props["InstrumentedItem"] ? this.props["InstrumentedItem"] : null;
|
||||
var isLogged = this.props.hasOwnProperty("IsLogged") && this.props["IsLogged"] ? this.props["IsLogged"] : true;
|
||||
var isEmptyChild = this.props.hasOwnProperty("IsEmptyChild") && this.props["IsEmptyChild"] ? this.props["IsEmptyChild"] : false;
|
||||
this.addPropertyIfExist(props, "Type", regionInstrumentation, "type");
|
||||
this.addPropertyIfExist(props, "NS", regionInstrumentation, "appNS");
|
||||
this.addPropertyIfExist(props, "K", regionInstrumentation, "k");
|
||||
this.addPropertyIfExist(props, "DisplayRegion", regionInstrumentation, "displayRegion");
|
||||
this.addPropertyIfExist(props, "DynamicContentIndex", regionInstrumentation, "dynamicContentIndex");
|
||||
this.addPropertyIfExist(props, "InsertRef", regionInstrumentation, "insertRef");
|
||||
this.addPropertyIfExist(props, "InsertId", regionInstrumentation, "insertId");
|
||||
this.addPropertyIfExist(props, "N", regionInstrumentation, "n");
|
||||
this.addPropertyIfExist(props, "ST", regionInstrumentation, "stringTruncated");
|
||||
this.addPropertyIfExist(props, "Position", regionInstrumentation, "position");
|
||||
this.addPropertyIfExist(props, "Size", regionInstrumentation, "size");
|
||||
this.addPropertyIfExist(props, "EntityCat", regionInstrumentation, "entityCat");
|
||||
this.addPropertyIfExist(props, "EntityId", regionInstrumentation, "entityId");
|
||||
this.addPropertyIfExist(props, "EntityId", regionInstrumentation, "orientation");
|
||||
this.addPropertyIfExist(props, "ForcedTo", regionInstrumentation, "forcedTo");
|
||||
this.addPropertyIfExist(props, "Height", regionInstrumentation, "height");
|
||||
this.addPropertyIfExist(props, "TitleWidth", regionInstrumentation, "titleWidth");
|
||||
this.addPropertyIfExist(props, "HeightInRows", regionInstrumentation, "heightInRows");
|
||||
this.addPropertyIfExist(props, "SnapHeight", regionInstrumentation, "snapHeight");
|
||||
this.addPropertyIfExist(props, "SnapHeightInRows", regionInstrumentation, "snapHeightInRows");
|
||||
this.addPropertyIfExist(props, "SnippetWidthAfterTruncation", regionInstrumentation, "snippetWidthAfterTruncation");
|
||||
this.addPropertyIfExist(props, "SnippetWidth", regionInstrumentation, "snippetWidth");
|
||||
this.addPropertyIfExist(props, "TitleWidthAfterTruncation", regionInstrumentation, "titleWidthAfterTruncation");
|
||||
this.addPropertyIfExist(props, "IsTitleTruncated", regionInstrumentation, "isTitleTruncated");
|
||||
this.addPropertyIfExist(props, "IsLogged", regionInstrumentation, "isLogged");
|
||||
if (isLogged && instrumentedItem && instrumentedItem.UniqueId) {
|
||||
regionInstrumentation.appNS = instrumentedItem.UniqueId.Namespace;
|
||||
instrumentedItem.CurrentUseCount++;
|
||||
regionInstrumentation.k = instrumentedItem.UniqueId.KValue.toString();
|
||||
if (instrumentedItem.CurrentUseCount > 0) {
|
||||
regionInstrumentation.k += "." + instrumentedItem.CurrentUseCount.toString();
|
||||
}
|
||||
}
|
||||
return {
|
||||
regionInstrumentation: regionInstrumentation,
|
||||
isStartRegionLogging: false,
|
||||
isCloseRegionLogging: false,
|
||||
isLogged: isLogged,
|
||||
isEmptyChild: isEmptyChild,
|
||||
nodeName: nodeName,
|
||||
parentNodeName: parentNodeName
|
||||
};
|
||||
};
|
||||
Region.prototype.render = function () {
|
||||
return !this.state.isEmptyChild ? this.props.children : null;
|
||||
};
|
||||
return Region;
|
||||
}(React.Component));
|
|
@ -0,0 +1 @@
|
|||
var ServerSideLayoutInstrumentation;(function(n){function t(n){return!(typeof n=="undefined"||n===null||n.length===0)}function u(n){return!(typeof n=="undefined"||n===null)}function f(n,t){HostInstrumentation.setPageInfo(n,t)}function e(n,r,u,f){var e=i.beginObject(u,f);e.write("T","L.Form");t(r)&&e.write("AppNS",r);t(n)&&e.write("K",n);e.beginArray("L")}function o(){i.closeObject()}function s(n,r,u,f){var e=i.beginObject(u,f);e.write("T","L.Url");t(n)&&e.write("AppNS",n);t(r)&&e.write("K",r)}function h(){i.closeObject()}function c(n,f,e){var o=i.beginObject(f,e),s=n.hasOwnProperty("appNS")&&t(n.appNS)?n.appNS:"SERP";t(n.type)&&o.write("T",n.type);s!==r[r.length-1]&&o.write("AppNS",s);t(n.k)&&o.write("K",n.k);t(n.displayRegion)&&o.write("Region",n.displayRegion);t(n.insertId)?o.write("InsertId",n.insertId):t(n.dynamicContentIndex)&&o.write("InsertId",n.appNS+"."+n.insertId);t(n.results)&&o.write("Results",!0);t(n.stringTruncated)&&o.write("ST",1);u(n.insertRef)&&n.insertRef>0&&o.write("InsertRef",n.appNS+"."+n.insertRef);t(n.n)&&o.write("N",n.n);t(n.position)&&o.write("Position",n.position);u(n.size)&&n.size>0&&o.write("Size",n.size);t(n.entityCat)&&o.write("EntityCat",n.entityCat);t(n.entityId)&&o.write("EntityId",n.entityId);t(n.orientation)&&o.write("Orientation",n.orientation);t(n.forcedTo)&&o.write("ForcedTo",n.forcedTo);u(n.height)&&n.height>0&&o.write("Height",n.height);u(n.titleWidth)&&n.titleWidth>0&&o.write("TitleWidth",n.titleWidth);u(n.width)&&n.width>0&&o.write("Width",n.width);u(n.heightInRows)&&n.heightInRows>0&&o.write("HeightInRows",n.heightInRows);u(n.snapHeight)&&n.snapHeight>0&&o.write("SnapHeight",n.snapHeight);u(n.snapHeightInRows)&&n.snapHeightInRows>0&&o.write("SnapHeightInRows",n.snapHeightInRows);u(n.snippetWidthAfterTruncation)&&n.snippetWidthAfterTruncation>0&&o.write("SnipTrunWidth",n.snippetWidthAfterTruncation);u(n.snipWidth)&&n.snipWidth>0&&o.write("SnipWidth",n.snipWidth);u(n.titleWidthAfterTruncation)&&n.titleWidthAfterTruncation>0&&o.write("TitleTrunWidth",n.titleWidthAfterTruncation);n.isTitleTruncated&&o.write("TT",1);n.isSnippetTruncated&&o.write("ST",1);r.push(s);o.beginArray("L")}function l(){r.pop();i.closeObject()}function a(n,f,e,o,s){var h=i.beginObject(o,s),c;h.write("T","L.DynamicContainer");c=t(n)?n:"SERP";c!==r[r.length-1]&&h.write("AppNS",c);u(f)&&f!==0&&h.write("InsertId",n+"."+f);t(e)&&h.write("InitialState",e);h.beginArray("L");r.push(c)}function v(){r.pop();i.closeObject()}function y(n,u,f,e){var o=i.beginObject(f,e),s;o.write("T","L.DynamicBlock");s=t(u)?u:"SERP";s!==r[r.length-1]&&o.write("AppNS",s);t(n)&&o.write("BlockId",n);o.beginArray("L");r.push(s)}function p(){r.pop();i.closeObject()}function w(n,r,u,f,e,o,s){var h=i.beginObject(o,s);h.write("T","L.MI");t(n)&&h.write("Action",n);t(r)&&h.write("SrcAppNS",r);t(u)&&h.write("SrcK",u);t(f)&&h.write("DestAppNS",f);t(e)&&h.write("DestK",e)}function b(){i.closeObject()}var i=LayoutWriter,r=[""];n.setPageInfo=f;n.startForm=e;n.closeForm=o;n.startLink=s;n.closeLink=h;n.startRegion=c;n.closeRegion=l;n.startDynamicContainer=a;n.closeDynamicContainer=v;n.startDynamicBlock=y;n.closeDynamicBlock=p;n.startMergeInstructionBlock=w;n.closeMergeInstructionBlock=b})(ServerSideLayoutInstrumentation||(ServerSideLayoutInstrumentation={}))
|
|
@ -0,0 +1 @@
|
|||
var LayoutNode=function(){function n(n){this.instrumentation={};this.parent=n;this.isOpened=!0}return n.prototype.closeNode=function(){this.isOpened=!1},n.prototype.isLayOutNodeOpen=function(){return this.isOpened},n.prototype.getParentNode=function(){return this.parent},n.prototype.write=function(n,t){this.instrumentation[n]=t},n.prototype.beginArray=function(n){this.instrumentation[n]=[]},n.prototype.addItemInArray=function(n,t){this.instrumentation.hasOwnProperty(n)&&this.instrumentation[n]&&this.instrumentation[n].push(t)},n.prototype.getInstrumentationObject=function(){return this.instrumentation},n}(),LayoutWriter,HostInstrumentation;(function(n){function e(n,u){var f=new LayoutNode(t);if(typeof u!="undefined"&&u){if(!i.hasOwnProperty(u))throw"Parent (name) "+u+" instrumentation node is not found.";f=new LayoutNode(i[u]);i[u].addItemInArray("L",f)}else t===null?r.push(f):t.addItemInArray("L",f);if(typeof n!="undefined"&&n){if(i.hasOwnProperty(n))throw n+" node is already exist.";i[n]=f}return t=f}function o(){if(t===null)throw"There is no opened Object. Make sure you don't called close object more than once for one object.";var n=t;t=n.getParentNode();n.closeNode()}function f(n){var i="L",t=n.getInstrumentationObject(),u,r;if(t.hasOwnProperty(i)&&t[i])for(u=t[i],t[i]=[],r=0;r<u.length;r++)t[i].push(f(u[r]));return t}function s(){var i,e,t,n;if(r.length===0)return null;for(i=r,r=[],e=new Array(i.length),t=0;t<i.length;t++)e[t]=f(i[t]);return n=JSON.stringify(e),u?(n=n.substring(1,n.length-1),u=!1):n=","+n.substring(1,n.length-1),n}function h(){i=[];r=[];u=!0;t=null}var i=[],r=[],u=!0,t=null;n.beginObject=e;n.closeObject=o;n.writeInstrumentation=s;n.clear=h})(LayoutWriter||(LayoutWriter={})),function(n){function r(n,r){t=n;i=r}function u(){var n=LayoutWriter.writeInstrumentation();return{name:t,number:i,layoutInstrumentation:n}}var t=null,i;n.setPageInfo=r;n.getInstrumentationObject=u}(HostInstrumentation||(HostInstrumentation={}))
|
|
@ -0,0 +1 @@
|
|||
var ServerSideRenderingDataManager;(function(n){function i(n){return typeof n=="undefined"||n===null?!1:!0}function r(n,r){return i(n)?(t[n]=r,!1):!1}function u(n){return i(n)?t[n]:null}function f(){t=[]}var t=[];n.set=r;n.get=u;n.clear=f})(ServerSideRenderingDataManager||(ServerSideRenderingDataManager={}))
|
35
V8_Managed_Library/Tests/Scripts/react-dom-server.browser.production16.1.1.min.js
поставляемый
Normal file
35
V8_Managed_Library/Tests/Scripts/react-dom-server.browser.production16.1.1.min.js
поставляемый
Normal file
|
@ -0,0 +1,35 @@
|
|||
/** @license React v16.1.1
|
||||
* react-dom-server.browser.production.min.js
|
||||
*
|
||||
* Copyright (c) 2013-present, Facebook, Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
'use strict';(function(p,n){"object"===typeof exports&&"undefined"!==typeof module?module.exports=n(require("react")):"function"===typeof define&&define.amd?define(["react"],n):p.ReactDOMServer=n(p.React)})(this,function(p){function n(a){for(var b=arguments.length-1,f="Minified React error #"+a+"; visit http://facebook.github.io/react/docs/error-decoder.html?invariant\x3d"+a,c=0;c<b;c++)f+="\x26args[]\x3d"+encodeURIComponent(arguments[c+1]);b=Error(f+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings.");
|
||||
b.name="Invariant Violation";b.framesToPop=1;throw b;}function y(a,b){return(a&b)===b}function Y(a,b){if(H.hasOwnProperty(a)||2<a.length&&("o"===a[0]||"O"===a[0])&&("n"===a[1]||"N"===a[1]))return!1;if(null===b)return!0;switch(typeof b){case "boolean":return I(a);case "undefined":case "number":case "string":case "object":return!0;default:return!1}}function J(a){return B.hasOwnProperty(a)?B[a]:null}function I(a){if(H.hasOwnProperty(a))return!0;var b=J(a);if(b)return b.hasBooleanValue||b.hasStringBooleanValue||
|
||||
b.hasOverloadedBooleanValue;a=a.toLowerCase().slice(0,5);return"data-"===a||"aria-"===a}function C(a){return function(){return a}}function x(a){if("boolean"===typeof a||"number"===typeof a)return""+a;a=""+a;var b=Z.exec(a);if(b){var f="",c,l=0;for(c=b.index;c<a.length;c++){switch(a.charCodeAt(c)){case 34:b="\x26quot;";break;case 38:b="\x26amp;";break;case 39:b="\x26#x27;";break;case 60:b="\x26lt;";break;case 62:b="\x26gt;";break;default:continue}l!==c&&(f+=a.substring(l,c));l=c+1;f+=b}a=l!==c?f+a.substring(l,
|
||||
c):f}return a}function aa(a){if(K.hasOwnProperty(a))return!0;if(L.hasOwnProperty(a))return!1;if(ba.test(a))return K[a]=!0;L[a]=!0;return!1}function ca(a,b){var f=J(a);if(f){if(null==b||f.hasBooleanValue&&!b||f.hasNumericValue&&isNaN(b)||f.hasPositiveNumericValue&&1>b||f.hasOverloadedBooleanValue&&!1===b)return"";var c=f.attributeName;if(f.hasBooleanValue||f.hasOverloadedBooleanValue&&!0===b)return c+'\x3d""';if("boolean"!==typeof b||I(a))return c+"\x3d"+('"'+x(b)+'"')}else if(Y(a,b))return null==
|
||||
b?"":a+"\x3d"+('"'+x(b)+'"');return null}function M(a){switch(a){case "svg":return"http://www.w3.org/2000/svg";case "math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function F(a){return"string"===typeof a?a:"function"===typeof a?a.displayName||a.name:null}function da(a){var b="";p.Children.forEach(a,function(a){null==a||"string"!==typeof a&&"number"!==typeof a||(b+=a)});return b}function ea(a,b){if(a=a.contextTypes){var f={},c;for(c in a)f[c]=b[c];b=
|
||||
f}else b=N;return b}function O(a,b){void 0===a&&n("152",F(b)||"Component")}function fa(a,b){for(;p.isValidElement(a);){var f=a,c=f.type;if("function"!==typeof c)break;a=ea(c,b);var l=[],g=!1,e={isMounted:function(a){return!1},enqueueForceUpdate:function(a){if(null===l)return null},enqueueReplaceState:function(a,b){g=!0;l=[b]},enqueueSetState:function(a,b){if(null===l)return null;l.push(b)}};if(c.prototype&&c.prototype.isReactComponent)var d=new c(f.props,a,e);else if(d=c(f.props,a,e),null==d||null==
|
||||
d.render){a=d;O(a,c);continue}d.props=f.props;d.context=a;d.updater=e;e=d.state;void 0===e&&(d.state=e=null);if(d.componentWillMount)if(d.componentWillMount(),l.length){e=l;var h=g;l=null;g=!1;if(h&&1===e.length)d.state=e[0];else{var k=h?e[0]:d.state,m=!0;for(h=h?1:0;h<e.length;h++){var r=e[h];if(r="function"===typeof r?r.call(d,k,f.props,a):r)m?(m=!1,k=w({},k,r)):w(k,r)}d.state=k}}else l=null;a=d.render();O(a,c);if("function"===typeof d.getChildContext){f=c.childContextTypes;"object"!==typeof f?
|
||||
n("107",F(c)||"Unknown"):void 0;var q=d.getChildContext();for(var P in q)P in f?void 0:n("108",F(c)||"Unknown",P)}q&&(b=w({},b,q))}return{child:a,context:b}}var H={children:!0,dangerouslySetInnerHTML:!0,defaultValue:!0,defaultChecked:!0,innerHTML:!0,suppressContentEditableWarning:!0,suppressHydrationWarning:!0,style:!0},Q={MUST_USE_PROPERTY:1,HAS_BOOLEAN_VALUE:4,HAS_NUMERIC_VALUE:8,HAS_POSITIVE_NUMERIC_VALUE:24,HAS_OVERLOADED_BOOLEAN_VALUE:32,HAS_STRING_BOOLEAN_VALUE:64,injectDOMPropertyConfig:function(a){var b=
|
||||
Q,f=a.Properties||{},c=a.DOMAttributeNamespaces||{},l=a.DOMAttributeNames||{};a=a.DOMMutationMethods||{};for(var g in f){B.hasOwnProperty(g)?n("48",g):void 0;var e=g.toLowerCase(),d=f[g];e={attributeName:e,attributeNamespace:null,propertyName:g,mutationMethod:null,mustUseProperty:y(d,b.MUST_USE_PROPERTY),hasBooleanValue:y(d,b.HAS_BOOLEAN_VALUE),hasNumericValue:y(d,b.HAS_NUMERIC_VALUE),hasPositiveNumericValue:y(d,b.HAS_POSITIVE_NUMERIC_VALUE),hasOverloadedBooleanValue:y(d,b.HAS_OVERLOADED_BOOLEAN_VALUE),
|
||||
hasStringBooleanValue:y(d,b.HAS_STRING_BOOLEAN_VALUE)};1>=e.hasBooleanValue+e.hasNumericValue+e.hasOverloadedBooleanValue?void 0:n("50",g);l.hasOwnProperty(g)&&(e.attributeName=l[g]);c.hasOwnProperty(g)&&(e.attributeNamespace=c[g]);a.hasOwnProperty(g)&&(e.mutationMethod=a[g]);B[g]=e}}},B={},k=Q,q=k.MUST_USE_PROPERTY,h=k.HAS_BOOLEAN_VALUE,R=k.HAS_NUMERIC_VALUE,D=k.HAS_POSITIVE_NUMERIC_VALUE,S=k.HAS_OVERLOADED_BOOLEAN_VALUE,E=k.HAS_STRING_BOOLEAN_VALUE;q={Properties:{allowFullScreen:h,async:h,autoFocus:h,
|
||||
autoPlay:h,capture:S,checked:q|h,cols:D,contentEditable:E,controls:h,"default":h,defer:h,disabled:h,download:S,draggable:E,formNoValidate:h,hidden:h,loop:h,multiple:q|h,muted:q|h,noValidate:h,open:h,playsInline:h,readOnly:h,required:h,reversed:h,rows:D,rowSpan:R,scoped:h,seamless:h,selected:q|h,size:D,start:R,span:D,spellCheck:E,style:0,tabIndex:0,itemScope:h,acceptCharset:0,className:0,htmlFor:0,httpEquiv:0,value:E},DOMAttributeNames:{acceptCharset:"accept-charset",className:"class",htmlFor:"for",
|
||||
httpEquiv:"http-equiv"},DOMMutationMethods:{value:function(a,b){if(null==b)return a.removeAttribute("value");"number"!==a.type||!1===a.hasAttribute("value")?a.setAttribute("value",""+b):a.validity&&!a.validity.badInput&&a.ownerDocument.activeElement!==a&&a.setAttribute("value",""+b)}}};h=k.HAS_STRING_BOOLEAN_VALUE;var G={Properties:{autoReverse:h,externalResourcesRequired:h,preserveAlpha:h},DOMAttributeNames:{autoReverse:"autoReverse",externalResourcesRequired:"externalResourcesRequired",preserveAlpha:"preserveAlpha"},
|
||||
DOMAttributeNamespaces:{xlinkActuate:"http://www.w3.org/1999/xlink",xlinkArcrole:"http://www.w3.org/1999/xlink",xlinkHref:"http://www.w3.org/1999/xlink",xlinkRole:"http://www.w3.org/1999/xlink",xlinkShow:"http://www.w3.org/1999/xlink",xlinkTitle:"http://www.w3.org/1999/xlink",xlinkType:"http://www.w3.org/1999/xlink",xmlBase:"http://www.w3.org/XML/1998/namespace",xmlLang:"http://www.w3.org/XML/1998/namespace",xmlSpace:"http://www.w3.org/XML/1998/namespace"}},ha=/[\-\:]([a-z])/g,ia=function(a){return a[1].toUpperCase()};
|
||||
"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode x-height xlink:actuate xlink:arcrole xlink:href xlink:role xlink:show xlink:title xlink:type xml:base xmlns:xlink xml:lang xml:space".split(" ").forEach(function(a){var b=
|
||||
a.replace(ha,ia);G.Properties[b]=0;G.DOMAttributeNames[b]=a});k.injectDOMPropertyConfig(q);k.injectDOMPropertyConfig(G);var w=p.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.assign;k=function(){};k.thatReturns=C;k.thatReturnsFalse=C(!1);k.thatReturnsTrue=C(!0);k.thatReturnsNull=C(null);k.thatReturnsThis=function(){return this};k.thatReturnsArgument=function(a){return a};var N={},ja=/([A-Z])/g,ka=/^ms-/,Z=/["'&<>]/,ba=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,
|
||||
L={},K={},T={area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0},la=w({menuitem:!0},T),z={animationIterationCount:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,
|
||||
gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},ma=["Webkit","ms","Moz","O"];Object.keys(z).forEach(function(a){ma.forEach(function(b){b=b+a.charAt(0).toUpperCase()+a.substring(1);z[b]=z[a]})});var U="function"===typeof Symbol&&Symbol["for"]&&Symbol["for"]("react.fragment")||60107,
|
||||
A=p.Children.toArray,V=k.thatReturns(""),na={listing:!0,pre:!0,textarea:!0},oa=/^[a-zA-Z][a-zA-Z:_\.\-\d]*$/,W={},pa=function(a){var b={};return function(f){b.hasOwnProperty(f)||(b[f]=a.call(this,f));return b[f]}}(function(a){return a.replace(ja,"-$1").toLowerCase().replace(ka,"-ms-")}),qa={children:null,dangerouslySetInnerHTML:null,suppressContentEditableWarning:null,suppressHydrationWarning:null},X=function(){function a(b,f){if(!(this instanceof a))throw new TypeError("Cannot call a class as a function");
|
||||
p.isValidElement(b)?b.type!==U?b=[b]:(b=b.props.children,b=p.isValidElement(b)?[b]:A(b)):b=A(b);this.stack=[{domNamespace:"http://www.w3.org/1999/xhtml",children:b,childIndex:0,context:N,footer:""}];this.exhausted=!1;this.currentSelectValue=null;this.previousWasTextNode=!1;this.makeStaticMarkup=f}a.prototype.read=function(a){if(this.exhausted)return null;for(var b="";b.length<a;){if(0===this.stack.length){this.exhausted=!0;break}var c=this.stack[this.stack.length-1];if(c.childIndex>=c.children.length){var l=
|
||||
c.footer;b+=l;""!==l&&(this.previousWasTextNode=!1);this.stack.pop();"select"===c.tag&&(this.currentSelectValue=null)}else l=c.children[c.childIndex++],b+=this.render(l,c.context,c.domNamespace)}return b};a.prototype.render=function(a,f,c){if("string"===typeof a||"number"===typeof a){c=""+a;if(""===c)return"";if(this.makeStaticMarkup)return x(c);if(this.previousWasTextNode)return"\x3c!-- --\x3e"+x(c);this.previousWasTextNode=!0;return x(c)}f=fa(a,f);a=f.child;f=f.context;if(null===a||!1===a)return"";
|
||||
if(p.isValidElement(a))return a.type===U?(a=A(a.props.children),this.stack.push({domNamespace:c,children:a,childIndex:0,context:f,footer:""}),""):this.renderDOM(a,f,c);a=A(a);this.stack.push({domNamespace:c,children:a,childIndex:0,context:f,footer:""});return""};a.prototype.renderDOM=function(a,f,c){var b=a.type.toLowerCase();"http://www.w3.org/1999/xhtml"===c&&M(b);W.hasOwnProperty(b)||(oa.test(b)?void 0:n("65",b),W[b]=!0);var g=a.props;if("input"===b)g=w({type:void 0},g,{defaultChecked:void 0,defaultValue:void 0,
|
||||
value:null!=g.value?g.value:g.defaultValue,checked:null!=g.checked?g.checked:g.defaultChecked});else if("textarea"===b){var e=g.value;if(null==e){e=g.defaultValue;var d=g.children;null!=d&&(null!=e?n("92"):void 0,Array.isArray(d)&&(1>=d.length?void 0:n("93"),d=d[0]),e=""+d);null==e&&(e="")}g=w({},g,{value:void 0,children:""+e})}else if("select"===b)this.currentSelectValue=null!=g.value?g.value:g.defaultValue,g=w({},g,{value:void 0});else if("option"===b){d=this.currentSelectValue;var h=da(g.children);
|
||||
if(null!=d){var k=null!=g.value?g.value+"":h;e=!1;if(Array.isArray(d))for(var m=0;m<d.length;m++){if(""+d[m]===k){e=!0;break}}else e=""+d===k;g=w({selected:void 0,children:void 0},g,{selected:e,children:h})}}if(e=g)la[b]&&(null!=e.children||null!=e.dangerouslySetInnerHTML?n("137",b,V()):void 0),null!=e.dangerouslySetInnerHTML&&(null!=e.children?n("60"):void 0,"object"===typeof e.dangerouslySetInnerHTML&&"__html"in e.dangerouslySetInnerHTML?void 0:n("61")),null!=e.style&&"object"!==typeof e.style?
|
||||
n("62",V()):void 0;e=g;d=this.makeStaticMarkup;h=1===this.stack.length;k="\x3c"+a.type;for(t in e)if(e.hasOwnProperty(t)){var r=e[t];if(null!=r){if("style"===t){m=void 0;var q="",p="";for(m in r)if(r.hasOwnProperty(m)){var u=0===m.indexOf("--"),v=r[m];null!=v&&(q+=p+pa(m)+":",p=m,u=null==v||"boolean"===typeof v||""===v?"":u||"number"!==typeof v||0===v||z.hasOwnProperty(p)&&z[p]?(""+v).trim():v+"px",q+=u,p=";")}r=q||null}m=null;b:if(u=b,v=e,-1===u.indexOf("-"))u="string"===typeof v.is;else switch(u){case "annotation-xml":case "color-profile":case "font-face":case "font-face-src":case "font-face-uri":case "font-face-format":case "font-face-name":case "missing-glyph":u=
|
||||
!1;break b;default:u=!0}u?qa.hasOwnProperty(t)||(m=t,m=aa(m)&&null!=r?m+"\x3d"+('"'+x(r)+'"'):""):m=ca(t,r);m&&(k+=" "+m)}}d||h&&(k+=' data-reactroot\x3d""');var t=k;e="";T.hasOwnProperty(b)?t+="/\x3e":(t+="\x3e",e="\x3c/"+a.type+"\x3e");a:{d=g.dangerouslySetInnerHTML;if(null!=d){if(null!=d.__html){d=d.__html;break a}}else if(d=g.children,"string"===typeof d||"number"===typeof d){d=x(d);break a}d=null}null!=d?(g=[],na[b]&&"\n"===d.charAt(0)&&(t+="\n"),t+=d):g=A(g.children);a=a.type;c=null==c||"http://www.w3.org/1999/xhtml"===
|
||||
c?M(a):"http://www.w3.org/2000/svg"===c&&"foreignObject"===a?"http://www.w3.org/1999/xhtml":c;this.stack.push({domNamespace:c,tag:b,children:g,childIndex:0,context:f,footer:e});this.previousWasTextNode=!1;return t};return a}();k={renderToString:function(a){return(new X(a,!1)).read(Infinity)},renderToStaticMarkup:function(a){return(new X(a,!0)).read(Infinity)},renderToNodeStream:function(){n("207")},renderToStaticNodeStream:function(){n("208")},version:"16.1.1"};k=(q=Object.freeze({default:k}))&&k||
|
||||
q;return k["default"]?k["default"]:k});
|
|
@ -0,0 +1,21 @@
|
|||
/** @license React v16.1.1
|
||||
* react.production.min.js
|
||||
*
|
||||
* Copyright (c) 2013-present, Facebook, Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
'use strict';(function(p,l){"object"===typeof exports&&"undefined"!==typeof module?module.exports=l():"function"===typeof define&&define.amd?define(l):p.React=l()})(this,function(){function p(a){for(var b=arguments.length-1,c="Minified React error #"+a+"; visit http://facebook.github.io/react/docs/error-decoder.html?invariant\x3d"+a,e=0;e<b;e++)c+="\x26args[]\x3d"+encodeURIComponent(arguments[e+1]);b=Error(c+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings.");
|
||||
b.name="Invariant Violation";b.framesToPop=1;throw b;}function l(a){return function(){return a}}function n(a,b,c){this.props=a;this.context=b;this.refs=v;this.updater=c||w}function x(a,b,c){this.props=a;this.context=b;this.refs=v;this.updater=c||w}function y(){}function z(a,b,c){this.props=a;this.context=b;this.refs=v;this.updater=c||w}function F(a,b,c){var e,f={},d=null,h=null;if(null!=b)for(e in void 0!==b.ref&&(h=b.ref),void 0!==b.key&&(d=""+b.key),b)G.call(b,e)&&!H.hasOwnProperty(e)&&(f[e]=b[e]);
|
||||
var g=arguments.length-2;if(1===g)f.children=c;else if(1<g){for(var k=Array(g),m=0;m<g;m++)k[m]=arguments[m+2];f.children=k}if(a&&a.defaultProps)for(e in g=a.defaultProps,g)void 0===f[e]&&(f[e]=g[e]);return{$$typeof:r,type:a,key:d,ref:h,props:f,_owner:A.current}}function B(a){return"object"===typeof a&&null!==a&&a.$$typeof===r}function O(a){var b={"\x3d":"\x3d0",":":"\x3d2"};return"$"+(""+a).replace(/[=:]/g,function(a){return b[a]})}function I(a,b,c,e){if(t.length){var f=t.pop();f.result=a;f.keyPrefix=
|
||||
b;f.func=c;f.context=e;f.count=0;return f}return{result:a,keyPrefix:b,func:c,context:e,count:0}}function J(a){a.result=null;a.keyPrefix=null;a.func=null;a.context=null;a.count=0;10>t.length&&t.push(a)}function q(a,b,c,e){var f=typeof a;if("undefined"===f||"boolean"===f)a=null;if(null===a||"string"===f||"number"===f||"object"===f&&a.$$typeof===P||"object"===f&&a.$$typeof===Q)return c(e,a,""===b?"."+C(a,0):b),1;var d=0;b=""===b?".":b+":";if(Array.isArray(a))for(var h=0;h<a.length;h++){f=a[h];var g=
|
||||
b+C(f,h);d+=q(f,g,c,e)}else if(g=K&&a[K]||a["@@iterator"],"function"===typeof g)for(a=g.call(a),h=0;!(f=a.next()).done;)f=f.value,g=b+C(f,h++),d+=q(f,g,c,e);else"object"===f&&(c=""+a,p("31","[object Object]"===c?"object with keys {"+Object.keys(a).join(", ")+"}":c,""));return d}function C(a,b){return"object"===typeof a&&null!==a&&null!=a.key?O(a.key):b.toString(36)}function R(a,b,c){a.func.call(a.context,b,a.count++)}function S(a,b,c){var e=a.result,f=a.keyPrefix;a=a.func.call(a.context,b,a.count++);
|
||||
Array.isArray(a)?D(a,e,c,E.thatReturnsArgument):null!=a&&(B(a)&&(b=f+(!a.key||b&&b.key===a.key?"":(""+a.key).replace(L,"$\x26/")+"/")+c,a={$$typeof:r,type:a.type,key:b,ref:a.ref,props:a.props,_owner:a._owner}),e.push(a))}function D(a,b,c,e,f){var d="";null!=c&&(d=(""+c).replace(L,"$\x26/")+"/");b=I(b,d,e,f);null==a||q(a,"",S,b);J(b)}var M=Object.getOwnPropertySymbols,T=Object.prototype.hasOwnProperty,U=Object.prototype.propertyIsEnumerable,u=function(){try{if(!Object.assign)return!1;var a=new String("abc");
|
||||
a[5]="de";if("5"===Object.getOwnPropertyNames(a)[0])return!1;var b={};for(a=0;10>a;a++)b["_"+String.fromCharCode(a)]=a;if("0123456789"!==Object.getOwnPropertyNames(b).map(function(a){return b[a]}).join(""))return!1;var c={};"abcdefghijklmnopqrst".split("").forEach(function(a){c[a]=a});return"abcdefghijklmnopqrst"!==Object.keys(Object.assign({},c)).join("")?!1:!0}catch(e){return!1}}()?Object.assign:function(a,b){if(null===a||void 0===a)throw new TypeError("Object.assign cannot be called with null or undefined");
|
||||
var c=Object(a);for(var e,f=1;f<arguments.length;f++){var d=Object(arguments[f]);for(var h in d)T.call(d,h)&&(c[h]=d[h]);if(M){e=M(d);for(var g=0;g<e.length;g++)U.call(d,e[g])&&(c[e[g]]=d[e[g]])}}return c},v={},d=function(){};d.thatReturns=l;d.thatReturnsFalse=l(!1);d.thatReturnsTrue=l(!0);d.thatReturnsNull=l(null);d.thatReturnsThis=function(){return this};d.thatReturnsArgument=function(a){return a};var E=d,w={isMounted:function(a){return!1},enqueueForceUpdate:function(a,b,c){},enqueueReplaceState:function(a,
|
||||
b,c,e){},enqueueSetState:function(a,b,c,e){}};n.prototype.isReactComponent={};n.prototype.setState=function(a,b){"object"!==typeof a&&"function"!==typeof a&&null!=a?p("85"):void 0;this.updater.enqueueSetState(this,a,b,"setState")};n.prototype.forceUpdate=function(a){this.updater.enqueueForceUpdate(this,a,"forceUpdate")};y.prototype=n.prototype;d=x.prototype=new y;d.constructor=x;u(d,n.prototype);d.isPureReactComponent=!0;d=z.prototype=new y;d.constructor=z;u(d,n.prototype);d.unstable_isAsyncReactComponent=
|
||||
!0;d.render=function(){return this.props.children};var A={current:null},G=Object.prototype.hasOwnProperty,r="function"===typeof Symbol&&Symbol["for"]&&Symbol["for"]("react.element")||60103,H={key:!0,ref:!0,__self:!0,__source:!0},K="function"===typeof Symbol&&Symbol.iterator,P="function"===typeof Symbol&&Symbol["for"]&&Symbol["for"]("react.element")||60103,Q="function"===typeof Symbol&&Symbol["for"]&&Symbol["for"]("react.portal")||60106,L=/\/+/g,t=[];"function"===typeof Symbol&&Symbol["for"]&&Symbol["for"]("react.fragment");
|
||||
d={Children:{map:function(a,b,c){if(null==a)return a;var e=[];D(a,e,null,b,c);return e},forEach:function(a,b,c){if(null==a)return a;b=I(null,null,b,c);null==a||q(a,"",R,b);J(b)},count:function(a,b){return null==a?0:q(a,"",E.thatReturnsNull,null)},toArray:function(a){var b=[];D(a,b,null,E.thatReturnsArgument);return b},only:function(a){B(a)?void 0:p("143");return a}},Component:n,PureComponent:x,unstable_AsyncComponent:z,createElement:F,cloneElement:function(a,b,c){var e=u({},a.props),d=a.key,l=a.ref,
|
||||
h=a._owner;if(null!=b){void 0!==b.ref&&(l=b.ref,h=A.current);void 0!==b.key&&(d=""+b.key);if(a.type&&a.type.defaultProps)var g=a.type.defaultProps;for(k in b)G.call(b,k)&&!H.hasOwnProperty(k)&&(e[k]=void 0===b[k]&&void 0!==g?g[k]:b[k])}var k=arguments.length-2;if(1===k)e.children=c;else if(1<k){g=Array(k);for(var m=0;m<k;m++)g[m]=arguments[m+2];e.children=g}return{$$typeof:r,type:a.type,key:d,ref:l,props:e,_owner:h}},createFactory:function(a){var b=F.bind(null,a);b.type=a;return b},isValidElement:B,
|
||||
version:"16.1.1",__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:{ReactCurrentOwner:A,assign:u}};var N=Object.freeze({default:d});d=N&&d||N;return d["default"]?d["default"]:d});
|
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
|
@ -0,0 +1,126 @@
|
|||
|
||||
|
||||
namespace Microsoft.Search.Frontend.V8
|
||||
{
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using JsRT.V8;
|
||||
|
||||
public class Tests
|
||||
{
|
||||
public static void StringReturnAfterJavaScriptExecution()
|
||||
{
|
||||
using (var runtime = new V8Engine())
|
||||
{
|
||||
runtime.Execute("function A() {return 'Hello Bing'};");
|
||||
var output = runtime.Evaluate("A();");
|
||||
|
||||
if (!String.Equals(output, "Hello Bing"))
|
||||
{
|
||||
Console.WriteLine("[Failing] StringReturnAfterJavaScriptExecution. Output String : " + output);
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("[Passed] StringReturnAfterJavaScriptExecution");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void NumberReturnAfterJavaScriptExecution()
|
||||
{
|
||||
using (var runtime = new V8Engine())
|
||||
{
|
||||
var output = runtime.EvaluateAndGetNativeObject("function A() {return 3.5 + 10;}; A();");
|
||||
if (output.IsValid)
|
||||
{
|
||||
if (output.ValueType() == V8ValueType.Double)
|
||||
{
|
||||
var value = output.ToDouble();
|
||||
Console.WriteLine("[Passed] NumberReturnAfterJavaScriptExecution. Output {0}, Expected {1}", value, 13.5);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("[Failing] NumberReturnAfterJavaScriptExecution. Output is not valid");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void TestsWebAppPageWithReact()
|
||||
{
|
||||
using (var runtime = new V8Engine())
|
||||
{
|
||||
foreach (var scriptName in Helper.Library)
|
||||
{
|
||||
runtime.Execute(Helper.JavascriptLibary[scriptName]);
|
||||
}
|
||||
|
||||
runtime.Execute(Helper.DataScript);
|
||||
var res = runtime.Evaluate(Helper.RenderScript);
|
||||
|
||||
if (!string.IsNullOrEmpty(res))
|
||||
{
|
||||
Console.WriteLine("[Passed] TestsWebAppPageWithReact.");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("[Failed] TestsWebAppPageWithReact.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void RecordPerfResults(int maxIterationLimit = 1)
|
||||
{
|
||||
|
||||
var stopwatch = new Stopwatch();
|
||||
var logMessage = new StringBuilder(5058);
|
||||
logMessage.Append("Runtime Creation,").Append(string.Join(",", Helper.Library))
|
||||
.AppendLine(",DataScript,RenderScript, conversion");
|
||||
|
||||
|
||||
// each iteration simulate a new request
|
||||
for (var j = 0; j < maxIterationLimit; j++)
|
||||
{
|
||||
string result;
|
||||
stopwatch.Restart();
|
||||
using (var runtime = new V8Engine())
|
||||
{
|
||||
stopwatch.Stop();
|
||||
logMessage.Append(stopwatch.ElapsedMilliseconds).Append(",");
|
||||
|
||||
long time = 0;
|
||||
foreach (var scriptName in Helper.Library)
|
||||
{
|
||||
time = Helper.ExecuteAction(
|
||||
stopwatch,
|
||||
() => { runtime.Execute(Helper.JavascriptLibary[scriptName]); },
|
||||
scriptName);
|
||||
|
||||
logMessage.Append(time).Append(",");
|
||||
}
|
||||
|
||||
time = Helper.ExecuteAction(stopwatch, () => { runtime.Execute(Helper.DataScript); }, "DataScript");
|
||||
logMessage.Append(time).Append(",");
|
||||
|
||||
stopwatch.Restart();
|
||||
var res = runtime.Evaluate(Helper.RenderScript);
|
||||
|
||||
var res1 = runtime.Evaluate(Helper.RenderSaveBox);
|
||||
runtime.Execute("HostInstrumentation.getInstrumentationObject();");
|
||||
runtime.Execute("ServerSideRenderingDataManager.clear();ServerSideRenderingDataManager.clear();");
|
||||
result = res + res1;
|
||||
stopwatch.Stop();
|
||||
logMessage.AppendLine(stopwatch.ElapsedMilliseconds + "");
|
||||
}
|
||||
|
||||
File.WriteAllText("v8_plainscript.html", result);
|
||||
}
|
||||
|
||||
File.WriteAllText("v8_plainscript.csv", logMessage.ToString());
|
||||
Console.WriteLine("[Succeed] Generated Perf result. check v8_plainscript.csv file.");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>Microsoft.Search.Frontend.V8</RootNamespace>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<TargetFrameworkIdentifier></TargetFrameworkIdentifier>
|
||||
<Platforms>x64</Platforms>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\V8Host\JsRT.V8.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="Scripts\CommentBox.js">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="Scripts\CommentBoxServerRendering.js">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="Scripts\Data.txt">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="Scripts\InstForm.js">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="Scripts\InstLink.js">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="Scripts\react-dom-server.browser.production16.1.1.min.js">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="Scripts\react.production16.1.1.min.js">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="Scripts\redux.min.js">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="Scripts\Region.js">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="Scripts\ServerSideRendering.Instrumentation.js">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="Scripts\ServerSideRendering.LayoutWriter.js">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="Scripts\ServerSideRenderingDataManager.js">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="..\V8.CoreUXPlugin.Private\runtimes\x64\v8.dll">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="..\V8.CoreUXPlugin.Private\runtimes\x64\v8.pdb">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="CopyV8Dll" AfterTargets="AfterBuild">
|
||||
<Message Text="Copying v8 native dll in output directory" />
|
||||
<Copy SourceFiles="..\..\V8.CoreUXPlugin.Private\runtimes\x64\v8.dll" DestinationFolder="$(OutDir)" />
|
||||
<Copy SourceFiles="..\..\V8.CoreUXPlugin.Private\runtimes\x64\v8.pdb" DestinationFolder="$(OutDir)" />
|
||||
</Target>
|
||||
</Project>
|
|
@ -0,0 +1,37 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.30204.135
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JsRT.V8", "JsRT.V8\JsRT.V8.csproj", "{17D0E9DA-4E1D-4D32-8131-DB1E48A2B354}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "V8PTests", "Tests\V8PTests.csproj", "{17D0E9DA-4E1D-4D32-8131-DB1E48A2B294}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Debug|x64 = Debug|x64
|
||||
Release|Any CPU = Release|Any CPU
|
||||
Release|x64 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{17D0E9DA-4E1D-4D32-8131-DB1E48A2B354}.Debug|Any CPU.ActiveCfg = Debug|x64
|
||||
{17D0E9DA-4E1D-4D32-8131-DB1E48A2B354}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{17D0E9DA-4E1D-4D32-8131-DB1E48A2B354}.Debug|x64.Build.0 = Debug|x64
|
||||
{17D0E9DA-4E1D-4D32-8131-DB1E48A2B354}.Release|Any CPU.ActiveCfg = Release|x64
|
||||
{17D0E9DA-4E1D-4D32-8131-DB1E48A2B354}.Release|x64.ActiveCfg = Release|x64
|
||||
{17D0E9DA-4E1D-4D32-8131-DB1E48A2B354}.Release|x64.Build.0 = Release|x64
|
||||
{17D0E9DA-4E1D-4D32-8131-DB1E48A2B294}.Debug|Any CPU.ActiveCfg = Debug|x64
|
||||
{17D0E9DA-4E1D-4D32-8131-DB1E48A2B294}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{17D0E9DA-4E1D-4D32-8131-DB1E48A2B294}.Debug|x64.Build.0 = Debug|x64
|
||||
{17D0E9DA-4E1D-4D32-8131-DB1E48A2B294}.Release|Any CPU.ActiveCfg = Release|x64
|
||||
{17D0E9DA-4E1D-4D32-8131-DB1E48A2B294}.Release|x64.ActiveCfg = Release|x64
|
||||
{17D0E9DA-4E1D-4D32-8131-DB1E48A2B294}.Release|x64.Build.0 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {28B8AFED-B34B-4A31-AAA2-3286E94480F9}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
|
@ -0,0 +1,20 @@
|
|||
default: PluginMain.cpp
|
||||
g++ -I. -I$(V8DIR) -I$(V8DIR)/include/ PluginMain.cpp -shared -fPIC -o v8.dll.so -lv8_monolith -L$(V8DIR)/out.gn/x64.release.sample/obj/ -pthread -std=c++14 -DV8_COMPRESS_POINTERS
|
||||
|
||||
install: default
|
||||
sudo mkdir -p $(INSTALLDIR)
|
||||
sudo cp -a v8.dll.so $(INSTALLDIR)/
|
||||
sudo cp -a $(V8DIR)/out.gn/x64.release.sample/icudtl.dat $(INSTALLDIR)/
|
||||
|
||||
.PHONY: v8 v8-deps
|
||||
v8-deps:
|
||||
ln -fs /usr/share/zoneinfo/Europe/Dublin /etc/localtime && apt-get install -y tzdata sudo && DEBIAN_FRONTEND=noninteractive dpkg-reconfigure -f noninteractive tzdata
|
||||
(cd $(V8DIR) && ./build/install-build-deps.sh --no-nacl --no-arm)
|
||||
|
||||
|
||||
$(V8DIR)/out.gn/x64.release.sample/icudtl.dat:
|
||||
(cd $(V8DIR) && ./tools/dev/v8gen.py x64.release.sample && ninja -C out.gn/x64.release.sample v8_monolith)
|
||||
|
||||
|
||||
v8: $(V8DIR)/out.gn/x64.release.sample/icudtl.dat
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
|
||||
#include "stdafx.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
#include <windows.h>
|
||||
extern "C" {
|
||||
BOOL WINAPI DllMain(HANDLE hinstDLL, DWORD dwReason, LPVOID lpvReserved) {
|
||||
// Do nothing.
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,17 @@
|
|||
# **Bing CoreUX V8 plugin Development** #
|
||||
|
||||
In order to add more functionalities in the plugin you need to build V8 source code without any BingUX plugin code. First Open Visual Studio 2017 Developer Command Prompt then execute following command
|
||||
|
||||
**Command:**
|
||||
```
|
||||
>> V8Build.cmd init -np debug
|
||||
or
|
||||
>> V8Build.cmd -np debug (if you have the V8 source code)
|
||||
```
|
||||
|
||||
After build is complete then copy the following header and library to run this C++ project perfectly.
|
||||
|
||||
1. copy the lib\debug\native folder to V8_Native_Plugin\native.
|
||||
2. copy include folder to V8_Native_Plugin\plugin\include.
|
||||
3. Open the project via Visual studio and fix any build error(could be header path) then build it.
|
||||
4. copy v8.dll, v8_libbase.dll and v8_libplatform.dll to the V8_Native_Plugin\x64\Debug directory to the run the exe properly
|
|
@ -0,0 +1,313 @@
|
|||
#pragma once
|
||||
|
||||
#ifndef _V8_COREUX_EXPORT_
|
||||
#define _V8_COREUX_EXPORT_
|
||||
|
||||
#include "V8RuntimeImp-plugin.h"
|
||||
|
||||
/*
|
||||
Initializes V8. This function needs to be called before the first Isolate.
|
||||
This needs to call only once for a single app
|
||||
*/
|
||||
|
||||
V8_API V8JsErrorType InitializeV8(_In_ int thread_pool_size, _In_ bool idleTaskSupport) {
|
||||
|
||||
V8Platform::Initialize(thread_pool_size, idleTaskSupport);
|
||||
return V8JsErrorType::JsNoError;
|
||||
}
|
||||
|
||||
/**
|
||||
* Releases any resources used by v8 and stops any utility threads
|
||||
* that may be running. Note that disposing v8 is permanent, it
|
||||
* cannot be reinitialized.
|
||||
*
|
||||
* It should generally not be necessary to dispose v8 before exiting
|
||||
* a process, this should happen automatically. It is only necessary
|
||||
* to use if the process needs the resources taken up by v8.
|
||||
*/
|
||||
V8_API V8JsErrorType DisposeV8Platform() {
|
||||
|
||||
V8Platform::Dispose();
|
||||
return V8JsErrorType::JsNoError;
|
||||
}
|
||||
|
||||
/**
|
||||
This method will create a isolate, context object and wrapped by V8RuntimeImp class.
|
||||
V8RuntimeImp class will allow to run script and dispose isolate object
|
||||
*/
|
||||
V8_API V8JsErrorType CreateV8RunTime(_In_ int max_old_space_in_MB, _In_ int max_semi_space_in_MB, _Out_ V8RuntimeHandler *runtimeHandler)
|
||||
{
|
||||
PARAM_NOT_NULL(runtimeHandler);
|
||||
V8RuntimeImp* runtime = new V8RuntimeImp(max_old_space_in_MB, max_semi_space_in_MB);
|
||||
*runtimeHandler = runtime->ToHandle();
|
||||
return V8JsErrorType::JsNoError;
|
||||
}
|
||||
|
||||
/**
|
||||
Disposing V8RuntimeImp will dipose isolate and context object related to this V8RuntimeHandler.
|
||||
During end of the request this method needs to call and release the memory that associate v8 isolate object.
|
||||
*/
|
||||
V8_API V8JsErrorType DisposeV8Runtime(_In_ V8RuntimeHandler runtimeHandler)
|
||||
{
|
||||
VALIDATE_INCOMING_RUNTIME_HANDLE(runtimeHandler);
|
||||
V8RuntimeImp *runtime = V8RuntimeImp::FromHandle(runtimeHandler);
|
||||
delete runtime;
|
||||
return V8JsErrorType::JsNoError;
|
||||
}
|
||||
|
||||
/**
|
||||
Run javascript under current V8RuntimeHandler.
|
||||
If *evalute* is "True" then it'll process the Script output object so managed code can access the output result by "result" reference.
|
||||
*/
|
||||
V8_API V8JsErrorType RunScript(_In_ V8RuntimeHandler runtimeHandler, _In_ const wchar_t *script, _In_ bool evalute, _Out_ V8JsValueRef *result) {
|
||||
|
||||
VALIDATE_INCOMING_RUNTIME_HANDLE(runtimeHandler);
|
||||
if (script == nullptr)
|
||||
{
|
||||
*result = JS_INVALID_REFERENCE;
|
||||
return V8JsErrorType::NullArgument;
|
||||
}
|
||||
|
||||
V8RuntimeImp *runtime = V8RuntimeImp::FromHandle(runtimeHandler);
|
||||
|
||||
V8Value *value = nullptr;
|
||||
V8JsErrorType error = runtime->RunScript(script, evalute, value);
|
||||
if (error == V8JsErrorType::JsNoError) {
|
||||
*result = value->ToHandle();
|
||||
}
|
||||
else
|
||||
{
|
||||
*result = JS_INVALID_REFERENCE;
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
/**
|
||||
* Optional notification that the embedder is idle.
|
||||
* V8 uses the notification to perform garbage collection.
|
||||
* This call can be used repeatedly if the embedder remains idle.
|
||||
* Returns true if the embedder should stop calling IdleNotificationDeadline
|
||||
* until real work has been done. This indicates that V8 has done
|
||||
* as much cleanup as it will be able to do.
|
||||
*
|
||||
* The deadline_in_seconds argument specifies the deadline V8 has to finish
|
||||
* garbage collection work. deadline_in_seconds is compared with
|
||||
* MonotonicallyIncreasingTime() and should be based on the same timebase as
|
||||
* that function. There is no guarantee that the actual work will be done
|
||||
* within the time limit.
|
||||
*/
|
||||
V8_API V8JsErrorType Idle(_In_ V8RuntimeHandler runtimeHandler) {
|
||||
|
||||
VALIDATE_INCOMING_RUNTIME_HANDLE(runtimeHandler);
|
||||
V8RuntimeImp *runtime = V8RuntimeImp::FromHandle(runtimeHandler);
|
||||
|
||||
if (runtime != nullptr)
|
||||
{
|
||||
runtime->IdleNotification();
|
||||
return V8JsErrorType::JsNoError;
|
||||
}
|
||||
else
|
||||
{
|
||||
return V8JsErrorType::InvalidRuntime;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Optional notification that the system is running low on memory.
|
||||
* V8 uses these notifications to attempt to free memory.
|
||||
*/
|
||||
V8_API V8JsErrorType CollectGarbage(_In_ V8RuntimeHandler runtimeHandler) {
|
||||
|
||||
VALIDATE_INCOMING_RUNTIME_HANDLE(runtimeHandler);
|
||||
V8RuntimeImp *runtime = V8RuntimeImp::FromHandle(runtimeHandler);
|
||||
|
||||
if (runtime != nullptr)
|
||||
{
|
||||
runtime->CollectGarbage();
|
||||
return V8JsErrorType::JsNoError;
|
||||
}
|
||||
|
||||
return V8JsErrorType::InvalidRuntime;
|
||||
}
|
||||
|
||||
/**
|
||||
* It'll return the last exception that happened during executing the script.
|
||||
*/
|
||||
V8_API V8JsErrorType GetException(_In_ V8RuntimeHandler runtimeHandler, _Out_ V8JsException *v8JsException) {
|
||||
VALIDATE_INCOMING_RUNTIME_HANDLE(runtimeHandler);
|
||||
V8RuntimeImp *runtime = V8RuntimeImp::FromHandle(runtimeHandler);
|
||||
|
||||
if (runtime != nullptr)
|
||||
{
|
||||
V8Exception *exception = runtime->GetLastException();
|
||||
*v8JsException = exception->ToHandle();
|
||||
return V8JsErrorType::JsNoError;
|
||||
}
|
||||
|
||||
return V8JsErrorType::InvalidRuntime;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the Exception Message from V8JsException object
|
||||
*/
|
||||
V8_API V8JsErrorType GetExceptionMessage(_In_ V8JsException exception, _Out_ const wchar_t **message, _Out_ int& length) {
|
||||
VALIDATE_INCOMING_EXCEPTIONREF(exception);
|
||||
V8Exception *v8Exception = V8Exception::FromHandle(exception);
|
||||
|
||||
if (v8Exception != nullptr && v8Exception->GetMessage(*message, length)) {
|
||||
return V8JsErrorType::JsNoError;
|
||||
}
|
||||
|
||||
return V8JsErrorType::NullReference;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the StackTrace from V8JsException object
|
||||
*/
|
||||
V8_API V8JsErrorType GetStackTrace(_In_ V8JsException exception, _Out_ const wchar_t **message, _Out_ int& length) {
|
||||
VALIDATE_INCOMING_EXCEPTIONREF(exception);
|
||||
V8Exception *v8Exception = V8Exception::FromHandle(exception);
|
||||
|
||||
if (v8Exception != nullptr && v8Exception->GetStackTrace(*message, length)) {
|
||||
return V8JsErrorType::JsNoError;
|
||||
}
|
||||
|
||||
return V8JsErrorType::NullReference;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the value type of V8Value Object
|
||||
* e.g: V8Value could be Null, Undefined, int, bool, string, arrary or object
|
||||
*/
|
||||
V8_API V8ValueType GetV8ValueType(_In_ V8JsValueRef v8JsValue)
|
||||
{
|
||||
if (v8JsValue != JS_INVALID_REFERENCE)
|
||||
{
|
||||
V8Value *value = V8Value::FromHandle(v8JsValue);
|
||||
return value != nullptr ? value->GetType() : V8ValueType::UnknownType;
|
||||
}
|
||||
|
||||
return V8ValueType::UnknownType;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the V8JsValueRef value as bool if the ValueType=V8ValueType::Boolean
|
||||
*/
|
||||
V8_API V8JsErrorType GetV8ValueAsBool(_In_ V8JsValueRef v8JsValue, _Out_ bool& output) {
|
||||
VALIDATE_INCOMING_V8JSVALUEREF(v8JsValue);
|
||||
V8Value *value = V8Value::FromHandle(v8JsValue);
|
||||
|
||||
if (value != nullptr && value->AsBool(output)) {
|
||||
return V8JsErrorType::JsNoError;
|
||||
}
|
||||
|
||||
return V8JsErrorType::InvalidOperation;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the V8JsValueRef value as string if the ValueType=V8ValueType::String
|
||||
*/
|
||||
V8_API V8JsErrorType GetV8ValueAsString(_In_ V8JsValueRef v8JsValue, _Out_ const wchar_t **output, _Out_ int& length) {
|
||||
VALIDATE_INCOMING_V8JSVALUEREF(v8JsValue);
|
||||
V8Value *value = V8Value::FromHandle(v8JsValue);
|
||||
|
||||
if (value != nullptr && value->AsString(*output, length)) {
|
||||
return V8JsErrorType::JsNoError;
|
||||
}
|
||||
|
||||
return V8JsErrorType::InvalidOperation;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the V8JsValueRef value as int if the ValueType=V8ValueType::Integer
|
||||
*/
|
||||
V8_API V8JsErrorType GetV8ValueAsInt(_In_ V8JsValueRef v8JsValue, _Out_ long& output) {
|
||||
VALIDATE_INCOMING_V8JSVALUEREF(v8JsValue);
|
||||
V8Value *value = V8Value::FromHandle(v8JsValue);
|
||||
|
||||
if (value != nullptr && value->AsInteger(output)) {
|
||||
return V8JsErrorType::JsNoError;
|
||||
}
|
||||
|
||||
return V8JsErrorType::InvalidOperation;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the V8JsValueRef value as double if the ValueType=V8ValueType::Double
|
||||
*/
|
||||
V8_API V8JsErrorType GetV8ValueAsDouble(_In_ V8JsValueRef v8JsValue, _Out_ double& output) {
|
||||
VALIDATE_INCOMING_V8JSVALUEREF(v8JsValue);
|
||||
V8Value *value = V8Value::FromHandle(v8JsValue);
|
||||
|
||||
if (value != nullptr && value->AsDouble(output)) {
|
||||
return V8JsErrorType::JsNoError;
|
||||
}
|
||||
|
||||
return V8JsErrorType::InvalidOperation;
|
||||
}
|
||||
|
||||
/*
|
||||
* Dispose the V8JsValueRef object and release all the memory
|
||||
*/
|
||||
V8_API V8JsErrorType DisposeV8Value(_In_ V8JsValueRef v8JsValue) {
|
||||
VALIDATE_INCOMING_V8JSVALUEREF(v8JsValue);
|
||||
V8Value *value = V8Value::FromHandle(v8JsValue);
|
||||
|
||||
if (value != nullptr) {
|
||||
delete value;
|
||||
}
|
||||
|
||||
return V8JsErrorType::JsNoError;
|
||||
}
|
||||
|
||||
/*
|
||||
* if V8JsValueRef is an array then it will return the length
|
||||
* else if V8JsValueRef is an object then it will return number of property it has
|
||||
*/
|
||||
V8_API V8JsErrorType GetLength(_In_ V8JsValueRef v8JsValue, _Out_ int& length) {
|
||||
VALIDATE_INCOMING_V8JSVALUEREF(v8JsValue);
|
||||
V8Value *value = V8Value::FromHandle(v8JsValue);
|
||||
|
||||
if (value != nullptr) {
|
||||
length = value->GetLength();
|
||||
return V8JsErrorType::JsNoError;
|
||||
}
|
||||
|
||||
return V8JsErrorType::InvalidOperation;
|
||||
}
|
||||
|
||||
/*
|
||||
* if V8JsValueRef is an object element then it will return the propery name
|
||||
* e.g: {name: 'foo'} then it will return 'name';
|
||||
*/
|
||||
V8_API V8JsErrorType GetOwnPropertyName(_In_ V8JsValueRef v8JsValue, _Out_ const wchar_t **output, _Out_ int& length) {
|
||||
VALIDATE_INCOMING_V8JSVALUEREF(v8JsValue);
|
||||
V8Value *value = V8Value::FromHandle(v8JsValue);
|
||||
|
||||
if (value != nullptr && value->GetPropertyName(*output, length)) {
|
||||
return V8JsErrorType::JsNoError;
|
||||
}
|
||||
|
||||
return V8JsErrorType::InvalidOperation;
|
||||
}
|
||||
|
||||
/*
|
||||
* if V8JsValueRef is an Array then it will return the element of that index
|
||||
* else if V8JsValueRef is an object then it will return the property element (which contains [key as propertyname, value]) of that index
|
||||
*/
|
||||
V8_API V8JsErrorType GetObjectByIndex(_In_ V8JsValueRef v8JsValue, _In_ int index, _Out_ V8JsValueRef *outPtr) {
|
||||
VALIDATE_INCOMING_V8JSVALUEREF(v8JsValue);
|
||||
V8Value *value = V8Value::FromHandle(v8JsValue);
|
||||
|
||||
if (value != nullptr) {
|
||||
V8Value *object = value->Get(index);
|
||||
*outPtr = object->ToHandle();
|
||||
return V8JsErrorType::JsNoError;
|
||||
}
|
||||
|
||||
return V8JsErrorType::InvalidOperation;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
|
@ -0,0 +1,387 @@
|
|||
#pragma once
|
||||
|
||||
#ifndef _V8_COREUX_PLUGIN_
|
||||
#define _V8_COREUX_PLUGIN_
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "libplatform/libplatform.h"
|
||||
#include "v8.h"
|
||||
|
||||
#ifdef _In_
|
||||
#undef _In_
|
||||
#endif
|
||||
|
||||
#ifdef _Out_
|
||||
#undef _Out_
|
||||
#endif
|
||||
|
||||
#define _In_
|
||||
#define _Out_
|
||||
|
||||
#ifndef _EXPORT_TO_MANAGEWORLD_
|
||||
#define _EXPORT_TO_MANAGEWORLD_
|
||||
#endif
|
||||
|
||||
#ifdef PrintLog
|
||||
#define Log(msg) printf(msg);
|
||||
#else
|
||||
#define Log(msg)
|
||||
#endif
|
||||
#ifdef __linux
|
||||
#define V8_API extern "C"
|
||||
#elif _WIN32
|
||||
#define V8_API extern "C" __declspec(dllexport)
|
||||
#endif
|
||||
|
||||
#define PARAM_NOT_NULL(p) \
|
||||
if (p == nullptr) \
|
||||
{ \
|
||||
return V8JsErrorType::NullArgument; \
|
||||
}
|
||||
|
||||
#define VALIDATE_INCOMING_RUNTIME_HANDLE(p) \
|
||||
{ \
|
||||
if (p == JS_INVALID_RUNTIME_HANDLE) \
|
||||
{ \
|
||||
return V8JsErrorType::NullArgument; \
|
||||
} \
|
||||
}
|
||||
|
||||
#define VALIDATE_INCOMING_V8JSVALUEREF(p) \
|
||||
{ \
|
||||
if (p == JS_INVALID_REFERENCE) \
|
||||
{ \
|
||||
return V8JsErrorType::NullArgument; \
|
||||
} \
|
||||
}
|
||||
|
||||
#define VALIDATE_INCOMING_EXCEPTIONREF(p) \
|
||||
{ \
|
||||
if (p == JS_INVALID_EXCEPTION_REFERENCE) \
|
||||
{ \
|
||||
return V8JsErrorType::NullArgument; \
|
||||
} \
|
||||
}
|
||||
|
||||
#define OneMBSizeInByte 1000000
|
||||
|
||||
typedef void * V8RuntimeHandler;
|
||||
|
||||
/// <summary>
|
||||
/// An invalid runtime handle.
|
||||
/// </summary>
|
||||
const V8RuntimeHandler JS_INVALID_RUNTIME_HANDLE = 0;
|
||||
|
||||
typedef void * V8JsValueRef;
|
||||
|
||||
/// <summary>
|
||||
/// An invalid V8JsValue reference.
|
||||
/// </summary>
|
||||
const V8JsValueRef JS_INVALID_REFERENCE = 0;
|
||||
|
||||
typedef void * V8JsException;
|
||||
/// <summary>
|
||||
/// An invalid V8JsValue reference.
|
||||
/// </summary>
|
||||
const V8JsException JS_INVALID_EXCEPTION_REFERENCE = 0;
|
||||
|
||||
_EXPORT_TO_MANAGEWORLD_ typedef enum _JsErrorType {
|
||||
JsNoError = 0,
|
||||
Exception = 1,
|
||||
NullArgument = 2,
|
||||
NullReference = 3,
|
||||
ScriptCompilationError = 4,
|
||||
ScriptExecutionException = 5,
|
||||
InvalidOperation = 6,
|
||||
InvalidRuntime = 7
|
||||
|
||||
}V8JsErrorType;
|
||||
|
||||
|
||||
_EXPORT_TO_MANAGEWORLD_ typedef enum _V8ValueType {
|
||||
Null = 0,
|
||||
Undefined = 1,
|
||||
Boolean = 2,
|
||||
Integer = 3,
|
||||
Double = 4,
|
||||
String = 5,
|
||||
Object = 6,
|
||||
Array = 7,
|
||||
UnknownType = 8
|
||||
} V8ValueType;
|
||||
|
||||
union Data
|
||||
{
|
||||
bool bValue;
|
||||
long lValue;
|
||||
double dValue;
|
||||
v8::String::Value* sValue;
|
||||
};
|
||||
|
||||
/*
|
||||
* V8Value will represent JavaScript Object for V8 engine. If Javascript value type is native value then
|
||||
* GetType() will return the Type and Data will contain the native value;
|
||||
* If Javascript value is an array or Object then GetType() will return the proper type and
|
||||
* Array Index/ Object Property value can be accessed by Get(int index) method.
|
||||
* GetLength() will return the Array Size or object Property size
|
||||
*/
|
||||
class V8Value {
|
||||
public:
|
||||
V8Value()
|
||||
{
|
||||
this->type = V8ValueType::UnknownType;
|
||||
}
|
||||
|
||||
V8Value(v8::Isolate* isolate, v8::Local<v8::Context>& context, v8::Local<v8::Value>& propertyVal, v8::Local<v8::Value>& val)
|
||||
: V8Value(isolate, context, val)
|
||||
{
|
||||
this->propertyName = new v8::String::Value(isolate, propertyVal);
|
||||
}
|
||||
|
||||
V8Value(v8::Isolate* isolate, v8::Local<v8::Context>& context, v8::Local<v8::Value>& val) {
|
||||
this->valuesLength = 0;
|
||||
|
||||
if (val.IsEmpty() || val->IsNull()) {
|
||||
this->type = V8ValueType::Null;
|
||||
}
|
||||
else if (val->IsUndefined()) {
|
||||
this->type = V8ValueType::Undefined;
|
||||
}
|
||||
else if (val->IsBoolean()) {
|
||||
this->type = V8ValueType::Boolean;
|
||||
this->value.bValue = val->BooleanValue(isolate);
|
||||
}
|
||||
else if (val->IsInt32()) {
|
||||
this->type = V8ValueType::Integer;
|
||||
this->value.lValue = val->Int32Value(context).FromMaybe(defaultIntegerValue);
|
||||
}
|
||||
else if (val->IsUint32()) {
|
||||
this->type = V8ValueType::Integer;
|
||||
this->value.lValue = val->Uint32Value(context).FromMaybe(defaultIntegerValue);
|
||||
}
|
||||
else if (val->IsNumber()) {
|
||||
this->type = V8ValueType::Double;
|
||||
this->value.dValue = val->NumberValue(context).FromMaybe(defaultIntegerValue);
|
||||
}
|
||||
else if (val->IsString()) {
|
||||
this->type = V8ValueType::String;
|
||||
this->value.sValue = new v8::String::Value(isolate, val);
|
||||
}
|
||||
else if (val->IsArray()) {
|
||||
this->type = V8ValueType::Array;
|
||||
v8::HandleScope handle_scope(isolate);
|
||||
{
|
||||
v8::Local<v8::Array> t_array = val.As<v8::Array>();
|
||||
if (!t_array.IsEmpty()) {
|
||||
this->valuesLength = t_array->Length();
|
||||
if (this->valuesLength > 0)
|
||||
{
|
||||
this->values = new V8Value*[this->valuesLength];
|
||||
for (int index = 0; index < this->valuesLength; index++) {
|
||||
v8::Local<v8::Value> tempValue = t_array->Get(context, index).ToLocalChecked();
|
||||
this->values[index] = new V8Value(isolate, context, tempValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (val->IsObject()) {
|
||||
this->type = V8ValueType::Object;
|
||||
v8::HandleScope handle_scope(isolate);
|
||||
{
|
||||
v8::Local<v8::Object> t_object = val.As<v8::Object>();
|
||||
if (!t_object.IsEmpty()) {
|
||||
v8::Local<v8::Array> properties = t_object->GetPropertyNames(context).ToLocalChecked();
|
||||
this->valuesLength = properties->Length();
|
||||
if (this->valuesLength > 0)
|
||||
{
|
||||
this->values = new V8Value*[this->valuesLength];
|
||||
for (int index = 0; index < this->valuesLength; index++) {
|
||||
v8::Local<v8::Value> key = properties->Get(context, index).ToLocalChecked();
|
||||
v8::Local<v8::Value> tempValue = t_object->Get(context, key).ToLocalChecked();
|
||||
this->values[index] = new V8Value(isolate, context, key, tempValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
this->type = V8ValueType::UnknownType;
|
||||
}
|
||||
};
|
||||
|
||||
~V8Value() {
|
||||
if (this->type == V8ValueType::String) {
|
||||
delete this->value.sValue;
|
||||
}
|
||||
else if (this->type == V8ValueType::Array || this->type == V8ValueType::Object)
|
||||
{
|
||||
for (int index = 0; index < this->valuesLength; index++) {
|
||||
delete this->values[index];
|
||||
}
|
||||
|
||||
if(this->valuesLength > 0 && this->values != nullptr )
|
||||
{
|
||||
delete[] this->values;
|
||||
}
|
||||
}
|
||||
|
||||
if (this->propertyName != nullptr) {
|
||||
delete this->propertyName;
|
||||
}
|
||||
|
||||
Log(" -- destroying V8Value --\n");
|
||||
}
|
||||
|
||||
bool AsInteger(long& result) const
|
||||
{
|
||||
if (this->type == V8ValueType::Integer) {
|
||||
result = value.lValue;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool AsDouble(double& result) const
|
||||
{
|
||||
if (this->type == V8ValueType::Double) {
|
||||
result = value.dValue;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool AsBool(bool& result) const
|
||||
{
|
||||
if (this->type == V8ValueType::Boolean) {
|
||||
result = value.bValue;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool AsString(const wchar_t*& result, int& length) const
|
||||
{
|
||||
if (this->type == V8ValueType::String) {
|
||||
result = reinterpret_cast<const wchar_t*>(**this->value.sValue);
|
||||
length = this->value.sValue->length();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
V8Value* Get(int index)
|
||||
{
|
||||
if ((this->type == V8ValueType::Array || this->type == V8ValueType::Object) && index < this->valuesLength) {
|
||||
return this->values[index];
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool GetPropertyName(const wchar_t*& result, int& length) {
|
||||
if (this->propertyName == nullptr) return false;
|
||||
|
||||
result = reinterpret_cast<const wchar_t*>(**this->propertyName);
|
||||
length = this->propertyName->length();
|
||||
return true;
|
||||
}
|
||||
|
||||
int GetLength() {
|
||||
return this->valuesLength;
|
||||
}
|
||||
|
||||
V8ValueType GetType() {
|
||||
return this->type;
|
||||
}
|
||||
|
||||
V8JsValueRef ToHandle() { return static_cast<V8JsValueRef>(this); }
|
||||
|
||||
static V8Value* FromHandle(V8JsValueRef v8JsValue)
|
||||
{
|
||||
V8Value *v8Value = static_cast<V8Value *>(v8JsValue);
|
||||
return v8Value;
|
||||
}
|
||||
|
||||
private:
|
||||
V8ValueType type;
|
||||
Data value;
|
||||
v8::String::Value* propertyName = nullptr;
|
||||
V8Value **values;
|
||||
int valuesLength;
|
||||
const int defaultIntegerValue = 0;
|
||||
};
|
||||
|
||||
/*
|
||||
* This will represent the V8 Exception. The Exception can be happened during compile the script or executing the script.
|
||||
* Currently Exception class expose couple of property - 1) Message & 2) StackTrace
|
||||
*/
|
||||
class V8Exception
|
||||
{
|
||||
public:
|
||||
V8Exception(v8::Isolate* pIsolate, v8::Local<v8::Context>& context, const v8::TryCatch& exception)
|
||||
{
|
||||
v8::HandleScope handle_scope(pIsolate);
|
||||
{
|
||||
this->message = new v8::String::Value(pIsolate, exception.Exception());
|
||||
this->stackTrace = nullptr;
|
||||
|
||||
v8::MaybeLocal<v8::Value> m_stackTrack = exception.StackTrace(context);
|
||||
if (!m_stackTrack.IsEmpty())
|
||||
{
|
||||
v8::Local<v8::Value> l_stacktrace;
|
||||
if (m_stackTrack.ToLocal(&l_stacktrace)) {
|
||||
this->stackTrace = new v8::String::Value(pIsolate, l_stacktrace);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
~V8Exception() {
|
||||
delete this->message;
|
||||
|
||||
if (this->stackTrace != nullptr)
|
||||
{
|
||||
delete this->stackTrace;
|
||||
}
|
||||
|
||||
Log(" __ destroying exception __\n");
|
||||
}
|
||||
|
||||
bool GetMessage(const wchar_t*& i_message, int& length) {
|
||||
if (this->message == nullptr || this->message->length() == 0) return false;
|
||||
|
||||
i_message = reinterpret_cast<const wchar_t*>(**this->message);
|
||||
length = this->message->length();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GetStackTrace(const wchar_t*& i_stackTrace, int& length) {
|
||||
if (this->stackTrace == nullptr || this->stackTrace->length() == 0) return false;
|
||||
|
||||
i_stackTrace = reinterpret_cast<const wchar_t*>(**this->stackTrace);
|
||||
length = this->stackTrace->length();
|
||||
return true;
|
||||
}
|
||||
|
||||
V8JsException ToHandle() { return static_cast<V8JsException>(this); }
|
||||
|
||||
static V8Exception* FromHandle(V8JsException v8JsException)
|
||||
{
|
||||
V8Exception *exception = static_cast<V8Exception *>(v8JsException);
|
||||
return exception;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
v8::String::Value* message;
|
||||
v8::String::Value* stackTrace;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,100 @@
|
|||
#pragma once
|
||||
|
||||
#ifndef _V8_COREUX_PLATFORM_
|
||||
#define _V8_COREUX_PLATFORM_
|
||||
|
||||
#include "V8-plugin.h"
|
||||
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic ignored "-Wexit-time-destructors"
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
const auto V8ArrayBufferAllocatorInstance = v8::ArrayBuffer::Allocator::NewDefaultAllocator();
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
/*
|
||||
* V8Platform is a small wrapper class that maintain V8 Initialization and shut down.
|
||||
* It has be called only once per Application. Embedder needs to make sure to call initialize Method only one time.
|
||||
* If the apps shut down and restart than it needs to be call again.
|
||||
*/
|
||||
|
||||
class V8Platform {
|
||||
|
||||
public:
|
||||
static void Initialize(int thread_pool_size, bool idleTaskSupport)
|
||||
{
|
||||
if (!isInitizied) {
|
||||
// Initialize V8
|
||||
enginePlatform = new V8Platform();
|
||||
enginePlatform->v8NativePlatform = v8::platform::NewDefaultPlatform(
|
||||
thread_pool_size,
|
||||
idleTaskSupport
|
||||
? v8::platform::IdleTaskSupport::kEnabled
|
||||
: v8::platform::IdleTaskSupport::kDisabled);
|
||||
|
||||
v8::V8::InitializePlatform(enginePlatform->v8NativePlatform.get());
|
||||
isInitizied = v8::V8::Initialize();
|
||||
|
||||
/**
|
||||
* On Win64, by default V8 does not emit unwinding data for jitted code,
|
||||
* which means the OS cannot walk the stack frames and the system Structured
|
||||
* Exception Handling (SEH) cannot unwind through V8-generated code:
|
||||
*/
|
||||
#if defined(V8_OS_WIN)
|
||||
v8::V8::SetUnhandledExceptionCallback(CatchUnhandledExceptionCallback);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
static void Dispose()
|
||||
{
|
||||
if (isInitizied) {
|
||||
delete enginePlatform;
|
||||
enginePlatform = nullptr;
|
||||
isInitizied = false;
|
||||
}
|
||||
}
|
||||
|
||||
static double MonotonicallyIncreasingTime() {
|
||||
return isInitizied ? enginePlatform->v8NativePlatform->MonotonicallyIncreasingTime() : 0.025;
|
||||
}
|
||||
#if defined(V8_OS_WIN)
|
||||
/*
|
||||
* Consume exception for V8 unwinding data for jitted code
|
||||
*/
|
||||
static int CatchUnhandledExceptionCallback (_EXCEPTION_POINTERS* exception_pointers)
|
||||
{
|
||||
// 0 = ExceptionContinueExecution
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
private:
|
||||
V8Platform() { isInitizied = false; }
|
||||
~V8Platform() {
|
||||
if (isInitizied) {
|
||||
v8::V8::Dispose();
|
||||
v8::V8::ShutdownPlatform();
|
||||
|
||||
v8::Platform *tempPlatform = this->v8NativePlatform.get();
|
||||
this->v8NativePlatform.release();
|
||||
delete tempPlatform;
|
||||
isInitizied = false;
|
||||
|
||||
Log("ShutdownPlatform V8 \n");
|
||||
}
|
||||
}
|
||||
|
||||
std::unique_ptr<v8::Platform> v8NativePlatform = nullptr;
|
||||
|
||||
static bool isInitizied;
|
||||
static V8Platform *enginePlatform;
|
||||
};
|
||||
|
||||
V8Platform* V8Platform::enginePlatform;
|
||||
bool V8Platform::isInitizied;
|
||||
|
||||
#endif
|
|
@ -0,0 +1,163 @@
|
|||
#pragma once
|
||||
|
||||
#ifndef _V8_COREUX_RUNTIME_
|
||||
#define _V8_COREUX_RUNTIME_
|
||||
|
||||
#include "V8Platform-plugin.h"
|
||||
#include "V8-plugin.h"
|
||||
|
||||
/*
|
||||
* V8RuntimeImp is wrapper of V8 Isolate and Context.
|
||||
* This will allow to create V8 Isolate object for embedded Application and execute script.
|
||||
* An Isolate can create multiple context but this wrapper will always create one context under
|
||||
* one Isolate object. That means all code that execute under this isolate object can access previous
|
||||
* executed variable or state.
|
||||
*/
|
||||
|
||||
class V8RuntimeImp
|
||||
{
|
||||
public:
|
||||
V8RuntimeImp() : V8RuntimeImp(0, 0) {}
|
||||
V8RuntimeImp(size_t max_old_space, size_t max_semi_space);
|
||||
~V8RuntimeImp();
|
||||
|
||||
V8JsErrorType RunScript(const wchar_t *script, bool evaluate, V8Value*& result);
|
||||
|
||||
V8Exception* GetLastException();
|
||||
|
||||
void CollectGarbage();
|
||||
|
||||
bool IdleNotification();
|
||||
|
||||
V8RuntimeHandler ToHandle() { return static_cast<V8RuntimeHandler>(this); }
|
||||
|
||||
static V8RuntimeImp * FromHandle(V8RuntimeHandler runtimeHandle)
|
||||
{
|
||||
V8RuntimeImp *runtime = static_cast<V8RuntimeImp *>(runtimeHandle);
|
||||
return runtime;
|
||||
}
|
||||
|
||||
private:
|
||||
void SetException(V8Exception* exception);
|
||||
|
||||
v8::Isolate* isolate;
|
||||
v8::Persistent<v8::Context> globalContext;
|
||||
V8Exception *lastException = nullptr;
|
||||
};
|
||||
|
||||
V8RuntimeImp::V8RuntimeImp(size_t max_old_space_in_MB, size_t max_semi_space_in_MB)
|
||||
{
|
||||
v8::Isolate::CreateParams create_params;
|
||||
create_params.array_buffer_allocator = V8ArrayBufferAllocatorInstance;
|
||||
if (max_old_space_in_MB > 0)
|
||||
{
|
||||
create_params.constraints.set_max_old_generation_size_in_bytes(max_old_space_in_MB * OneMBSizeInByte);
|
||||
}
|
||||
|
||||
if (max_semi_space_in_MB > 0)
|
||||
{
|
||||
create_params.constraints.set_max_young_generation_size_in_bytes(max_semi_space_in_MB * OneMBSizeInByte);
|
||||
}
|
||||
|
||||
// An Isolate is an independant copy of the V8 runtime which includes its own heap.
|
||||
// Two different Isolates can run in parallel and can be seen as entierly different
|
||||
// sandboxed instances of a V8 runtime.
|
||||
this->isolate = v8::Isolate::New(create_params);
|
||||
{
|
||||
v8::Locker locker(this->isolate);
|
||||
v8::Isolate::Scope isolate_scope(this->isolate);
|
||||
{
|
||||
// Create a stack-allocated handle scope.
|
||||
v8::HandleScope handle_scope(this->isolate);
|
||||
{
|
||||
v8::Local<v8::Context> context = v8::Context::New(this->isolate);
|
||||
this->globalContext.Reset(this->isolate, context);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
V8RuntimeImp::~V8RuntimeImp()
|
||||
{
|
||||
if (this->lastException != nullptr) {
|
||||
delete this->lastException;
|
||||
}
|
||||
|
||||
this->globalContext.Reset();
|
||||
this->isolate->Dispose();
|
||||
this->isolate = nullptr;
|
||||
Log("destroying V8RuntimeImp \n");
|
||||
}
|
||||
|
||||
V8JsErrorType V8RuntimeImp::RunScript(const wchar_t *script_st, bool evaluate, V8Value*& result)
|
||||
{
|
||||
v8::Locker locker(this->isolate);
|
||||
v8::Isolate::Scope isolate_scope(this->isolate);
|
||||
{
|
||||
// Create a stack-allocated handle scope
|
||||
v8::HandleScope handle_scope(this->isolate);
|
||||
{
|
||||
v8::Local<v8::Context> context = v8::Local<v8::Context>::New(this->isolate, this->globalContext);
|
||||
// Enter the context for compiling and running the script.
|
||||
v8::Context::Scope context_scope(context);
|
||||
{
|
||||
v8::TryCatch try_catch(this->isolate);
|
||||
|
||||
v8::Local<v8::String> source = v8::String::NewFromTwoByte(this->isolate, reinterpret_cast<const uint16_t*>(script_st), v8::NewStringType::kNormal, -1)
|
||||
.ToLocalChecked();
|
||||
|
||||
// Compile the source code.
|
||||
v8::Local<v8::Script> script;
|
||||
if (!v8::Script::Compile(context, source).ToLocal(&script))
|
||||
{
|
||||
this->SetException(new V8Exception(this->isolate, context, try_catch));
|
||||
return V8JsErrorType::ScriptCompilationError;
|
||||
}
|
||||
|
||||
// Run the script to get the result.
|
||||
v8::MaybeLocal<v8::Value> maybeResult = script->Run(context);
|
||||
|
||||
if (evaluate)
|
||||
{
|
||||
if (maybeResult.IsEmpty()) {
|
||||
this->SetException(new V8Exception(this->isolate, context, try_catch));
|
||||
return V8JsErrorType::ScriptExecutionException;
|
||||
}
|
||||
else
|
||||
{
|
||||
v8::Local<v8::Value> tempResult = maybeResult.ToLocalChecked();
|
||||
result = new V8Value(this->isolate, context, tempResult);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return V8JsErrorType::JsNoError;
|
||||
}
|
||||
|
||||
bool V8RuntimeImp::IdleNotification()
|
||||
{
|
||||
return this->isolate->IdleNotificationDeadline(V8Platform::MonotonicallyIncreasingTime());
|
||||
}
|
||||
|
||||
void V8RuntimeImp::CollectGarbage()
|
||||
{
|
||||
this->isolate->LowMemoryNotification();
|
||||
}
|
||||
|
||||
V8Exception* V8RuntimeImp::GetLastException()
|
||||
{
|
||||
return this->lastException;
|
||||
}
|
||||
|
||||
void V8RuntimeImp::SetException(V8Exception* exception)
|
||||
{
|
||||
if (this->lastException != nullptr) {
|
||||
delete this->lastException;
|
||||
}
|
||||
|
||||
this->lastException = exception;
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,35 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.30204.135
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "V8_Native", "V8_Native.vcxproj", "{D611F010-C8B7-4CF5-BBE4-77435A52C140}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|ARM64 = Debug|ARM64
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
Release|ARM64 = Release|ARM64
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{D611F010-C8B7-4CF5-BBE4-77435A52C140}.Debug|ARM64.ActiveCfg = Debug|ARM64
|
||||
{D611F010-C8B7-4CF5-BBE4-77435A52C140}.Debug|ARM64.Build.0 = Debug|ARM64
|
||||
{D611F010-C8B7-4CF5-BBE4-77435A52C140}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{D611F010-C8B7-4CF5-BBE4-77435A52C140}.Debug|x64.Build.0 = Debug|x64
|
||||
{D611F010-C8B7-4CF5-BBE4-77435A52C140}.Debug|x86.ActiveCfg = Debug|x64
|
||||
{D611F010-C8B7-4CF5-BBE4-77435A52C140}.Release|ARM64.ActiveCfg = Release|ARM64
|
||||
{D611F010-C8B7-4CF5-BBE4-77435A52C140}.Release|ARM64.Build.0 = Release|ARM64
|
||||
{D611F010-C8B7-4CF5-BBE4-77435A52C140}.Release|x64.ActiveCfg = Release|x64
|
||||
{D611F010-C8B7-4CF5-BBE4-77435A52C140}.Release|x64.Build.0 = Release|x64
|
||||
{D611F010-C8B7-4CF5-BBE4-77435A52C140}.Release|x86.ActiveCfg = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {8BFE7494-1C46-4AFC-9140-493CC8CA8254}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
|
@ -0,0 +1,183 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|ARM64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>ARM64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|ARM64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>ARM64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>16.0</VCProjectVersion>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<ProjectGuid>{d611f010-c8b7-4cf5-bbe4-77435a52c140}</ProjectGuid>
|
||||
<RootNamespace>V8Serp</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
<ProjectName>V8_Native</ProjectName>
|
||||
<TargetName>v8</TargetName>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);..\lib\include</IncludePath>
|
||||
<LibraryPath>$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64);..\lib\x64</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);..\lib\include</IncludePath>
|
||||
<LibraryPath>$(VC_LibraryPath_arm64);$(WindowsSDK_LibraryPath_arm64);..\lib\arm64</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);..\lib\include</IncludePath>
|
||||
<LibraryPath>$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64);..\lib\x64</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);..\lib\include</IncludePath>
|
||||
<LibraryPath>$(VC_LibraryPath_arm64);$(WindowsSDK_LibraryPath_arm64);..\lib\arm64</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;V8_COMPRESS_POINTERS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;V8_COMPRESS_POINTERS;%(PreprocessorDefinitions);</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
<PostBuildEvent>
|
||||
<Message>Copying v8.dll in the nuget package directory</Message>
|
||||
<Command>mkdir $(ProjectDir)..\V8.CoreUXPlugin.Private\runtimes\$(Platform)\ |copy /Y "$(ProjectDir)$(Platform)\$(Configuration)\v8.dll" "$(ProjectDir)..\V8.CoreUXPlugin.Private\runtimes\$(Platform)\v8.dll" | copy /Y "$(ProjectDir)$(Platform)\$(Configuration)\v8.pdb" "$(ProjectDir)..\V8.CoreUXPlugin.Private\runtimes\$(Platform)\v8.pdb"</Command>
|
||||
</PostBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;V8_COMPRESS_POINTERS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalOptions>/MACHINE:I364 %(AdditionalOptions)</AdditionalOptions>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;V8_COMPRESS_POINTERS;MAXAPI_USE_MSCRT;%(PreprocessorDefinitions);</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
|
||||
<AdditionalOptions>/MACHINE:I364 %(AdditionalOptions)</AdditionalOptions>
|
||||
</Link>
|
||||
<PostBuildEvent>
|
||||
<Message>Copying v8.dll in the nuget package directory</Message>
|
||||
<Command>mkdir $(ProjectDir)..\V8.CoreUXPlugin.Private\runtimes\$(Platform)\ |copy /Y "$(ProjectDir)$(Platform)\$(Configuration)\v8.dll" "$(ProjectDir)..\V8.CoreUXPlugin.Private\runtimes\$(Platform)\v8.dll" | copy /Y "$(ProjectDir)$(Platform)\$(Configuration)\v8.pdb" "$(ProjectDir)..\V8.CoreUXPlugin.Private\runtimes\$(Platform)\v8.pdb"</Command>
|
||||
</PostBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="PluginMain.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="stdafx.h" />
|
||||
<ClInclude Include="V8-Export-Plugin.h" />
|
||||
<ClInclude Include="V8-plugin.h" />
|
||||
<ClInclude Include="V8Platform-plugin.h" />
|
||||
<ClInclude Include="V8RuntimeImp-plugin.h" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
|
@ -0,0 +1,39 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;c++;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="PluginMain.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="stdafx.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="V8-Export-Plugin.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="V8Platform-plugin.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="V8-plugin.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="V8RuntimeImp-plugin.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup />
|
||||
</Project>
|
|
@ -0,0 +1,18 @@
|
|||
#pragma once
|
||||
// stdafx.h : include file for standard system include files,
|
||||
// or project specific include files that are used frequently, but
|
||||
// are changed infrequently
|
||||
//
|
||||
|
||||
#include<iostream>
|
||||
#include "V8-Export-Plugin.h"
|
||||
|
||||
#define PrintLog
|
||||
|
||||
#pragma comment(lib, "v8_monolith.lib")
|
||||
|
||||
#pragma comment(lib, "winmm.lib")
|
||||
#pragma comment(lib, "dbghelp.lib")
|
||||
#pragma comment(lib, "shlwapi.lib")
|
||||
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
|
||||
<configuration>
|
||||
<config>
|
||||
<add key="dependencyVersion" value="Highest" />
|
||||
</config>
|
||||
<packageRestore>
|
||||
<add key="enabled" value="True" />
|
||||
<add key="automatic" value="True" />
|
||||
</packageRestore>
|
||||
<packageSources>
|
||||
</packageSources>
|
||||
</configuration>
|
Загрузка…
Ссылка в новой задаче