-
-
-
+
+
+ DebugEventHandler type
+
+## v3.17.4 - March 30, 2022
+ * In JavaScriptEngineSwitcher.Jurassic added support of Jurassic version of March 12, 2022
+ * In JavaScriptEngineSwitcher.V8 added support of Microsoft ClearScript.V8 version 7.2.4 (support of V8 version 10.0.139.8)
+
+## v3.17.3 - March 6, 2022
+ * In JavaScriptEngineSwitcher.V8 added support of Microsoft ClearScript.V8 version 7.2.3 (support of V8 version 9.9.115.8)
+
+## v3.17.2 - February 7, 2022
+ * In JavaScriptEngineSwitcher.V8 added support of Microsoft ClearScript.V8 version 7.2.2 (support of V8 version 9.8.177.9)
+
+## v3.17.1 - January 11, 2022
+ * In JavaScriptEngineSwitcher.V8 added support of Microsoft ClearScript.V8 version 7.2.1 (support of V8 version 9.7.106.18)
+
+## v3.17.0 - December 27, 2021
+ * In JavaScriptEngineSwitcher.Node:
+ * Jering.Javascript.NodeJS was updated to version 6.3.0
+ * Added support of .NET 6
+
+## v3.16.0 - December 9, 2021
+ * In JavaScriptEngineSwitcher.ChakraCore:
+ * ChakraCore was updated to version of November 11, 2021
+ * No longer supports a .NET Core App 2.1
+ * In JavaScriptEngineSwitcher.Jint added support of Jint version 3.0.0 Beta 2037
+ * In JavaScriptEngineSwitcher.NiL added support of NiL.JS version 2.5.1552
+
+## v3.15.0 - November 28, 2021
+ * In JavaScriptEngineSwitcher.Node:
+ * Jering.Javascript.NodeJS was updated to version 6.2.0
+ * Added support of .NET Core App 3.1 and .NET 5.0
+
+## v3.14.0 - November 23, 2021
+ * In JavaScriptEngineSwitcher.Jint added support of Jint version 3.0.0 Beta 2036
+ * In JavaScriptEngineSwitcher.NiL:
+ * NiL.JS was updated to version 2.5.1541
+ * No longer supports a .NET Framework 4.0 Client and .NET Framework 4.5
+ * Added support of .NET Framework 4.8 and .NET 6.0
+ * In JavaScriptEngineSwitcher.V8 added support of Microsoft ClearScript.V8 version 7.2.0 (support of V8 version 9.6.180.14)
+
+## v3.13.3 - October 21, 2021
+ * In JavaScriptEngineSwitcher.V8 added support of Microsoft ClearScript.V8 version 7.1.7 (support of V8 version 9.5.172.21)
+
+## v3.13.2 - October 6, 2021
+ * In JavaScriptEngineSwitcher.Jint:
+ * Jint was updated to version 3.0.0 Beta 2035
+ * In configuration settings of the Jint JS engine was added one new property - `MaxArraySize` (default `uint.MaxValue`)
+ * In JavaScriptEngineSwitcher.V8 implemented a handling of error “Internal error. Icu error”
+
+## v3.13.1 - September 22, 2021
+ * In JavaScriptEngineSwitcher.Jint added support of Jint version 3.0.0 Beta 2034
+ * In JavaScriptEngineSwitcher.V8 added support of Microsoft ClearScript.V8 version 7.1.6 (support of V8 version 9.4.146.16)
+
+## v3.13.0 - August 19, 2021
+ * In JavaScriptEngineSwitcher.Jurassic:
+ * Jurassic was updated to version of August 18, 2021
+ * Debugging is no longer supported
+
+## v3.12.6 - August 10, 2021
+ * In JavaScriptEngineSwitcher.ChakraCore:
+ * Improved a implementation of the `Dispose` method
+ * MSBuild and PowerShell scripts for installing the native assemblies are made more simple and universal
+ * In JavaScriptEngineSwitcher.Msie added support of MSIE JavaScript Engine version 3.0.8
+
+## v3.12.5 - July 23, 2021
+ * In JavaScriptEngineSwitcher.Jint added support of Jint version 3.0.0 Beta 2033
+ * In JavaScriptEngineSwitcher.V8:
+ * Microsoft ClearScript.V8 was updated to version 7.1.5 (support of V8 version 9.2.230.21)
+ * In configuration settings of the V8 JS engine was added one new property - `MaxArrayBufferAllocation` (default `UInt64.MaxValue`)
+
+## v3.12.4 - June 29, 2021
+ * In JavaScriptEngineSwitcher.NiL:
+ * NiL.JS was updated to version 2.5.1514
+ * Added support of .NET Core App 3.1
+ * In JavaScriptEngineSwitcher.V8:
+ * Microsoft ClearScript.V8 was updated to version 7.1.4 (support of V8 version 9.1.269.36)
+ * Added support of OS X (ARM64)
+
+## v3.12.3 - May 26, 2021
+ * In JavaScriptEngineSwitcher.V8 added support of Microsoft ClearScript.V8 version 7.1.3 (support of V8 version 9.1.269.28)
+
+## v3.12.2 - May 20, 2021
+ * In JavaScriptEngineSwitcher.Jint added support of Jint version 3.0.0 Beta 2032
+
+## v3.12.1 - April 18, 2021
+ * In JavaScriptEngineSwitcher.NiL added support of NiL.JS version 2.5.1493
+ * In JavaScriptEngineSwitcher.V8 added support of Microsoft ClearScript.V8 version 7.1.2 (support of V8 version 9.0.257.19)
+
+## v3.12.0 - March 28, 2021
+ * In JavaScriptEngineSwitcher.Jurassic added support of Jurassic version of March 19, 2021
+
+## v3.11.4 - March 19, 2021
+ * In JavaScriptEngineSwitcher.NiL:
+ * NiL.JS was updated to version 2.5.1486
+ * Added support of .NET 5.0
+
+## v3.11.3 - March 9, 2021
+ * In JavaScriptEngineSwitcher.Jint added support of Jint version 3.0.0 Beta 2031
+
+## v3.11.2 - March 5, 2021
+ * In JavaScriptEngineSwitcher.NiL added support of NiL.JS version 2.5.1475
+ * In JavaScriptEngineSwitcher.V8:
+ * Microsoft ClearScript.V8 was updated to version 7.1.1 (support of V8 version 8.9.255.20)
+ * Added support of .NET Standard 2.1
+ * Added support of Linux (ARM)
+ * In configuration settings of the V8 JS engine was added one new property - `HeapExpansionMultiplier` (default `0`)
+
+## v3.11.1 - February 1, 2021
+ * In JavaScriptEngineSwitcher.Jint:
+ * Runtime exceptions now contain a stack trace
+ * In configuration settings of the Jint JS engine a `AllowDebuggerStatement` property has been returned so as not to break compatibility with previous versions
+
+## v3.11.0 - January 30, 2021
+ * In JavaScriptEngineSwitcher.Jint:
+ * Jint was updated to version 3.0.0 Beta 2002
+ * In configuration settings of the Jint JS engine a `AllowDebuggerStatement` property has been replaced by the `DebuggerStatementHandlingMode` property (default `Ignore`) and was added two new properties: `DebuggerBreakCallback` (default `null`) and `DebuggerStepCallback` (default `null`)
+
+## v3.10.0 - January 22, 2021
+ * In JavaScriptEngineSwitcher.Node added support of Jering.Javascript.NodeJS version 5.4.4
+ * In JavaScriptEngineSwitcher.V8:
+ * Microsoft ClearScript.V8 was updated to version 7.1 (support of V8 version 8.8.278.14)
+ * Added support of Windows (ARM64) and Linux (ARM64)
+
+## v3.9.1 - December 9, 2020
+ * In JavaScriptEngineSwitcher.ChakraCore added support of ChakraCore version 1.11.24 ([Tomáš Deml's patch](https://github.com/microsoft/ChakraCore/issues/5973) applied)
+
+## v3.9.0 - November 19, 2020
+ * In JavaScriptEngineSwitcher.V8:
+ * Microsoft ClearScript.V8 was updated to version 7.0 (support of V8 version 8.7.220.25)
+ * Added support of .NET Framework 4.7.1 and .NET 5.0
+ * Added support of Linux (x64) and OS X (x64)
+ * Own versions of the ClearScript's assemblies are no longer build, because the [official NuGet package](https://www.nuget.org/packages/Microsoft.ClearScript.V8) is now used. Therefore, you should also replace in your projects the `JavaScriptEngineSwitcher.V8.Native.*` packages by the `Microsoft.ClearScript.V8.Native.*` packages.
+
+## v3.8.5 - November 11, 2020
+ * In JavaScriptEngineSwitcher.ChakraCore added support of ChakraCore version 1.11.23 ([Tomáš Deml's patch](https://github.com/microsoft/ChakraCore/issues/5973) applied)
+
+## v3.8.4 - November 7, 2020
+ * In JavaScriptEngineSwitcher.Jint added support of Jint version 3.0.0 Beta 1914
+
+## v3.9.0 Preview 3 - November 6, 2020
+ * In JavaScriptEngineSwitcher.V8:
+ * Microsoft ClearScript.V8 was updated to version 7.0 RC5 (support of V8 version 8.7.220.16)
+ * Own versions of the ClearScript's assemblies are no longer build, because the [official NuGet package](https://www.nuget.org/packages/Microsoft.ClearScript.V8) is now used. Therefore, you should also replace in your projects the `JavaScriptEngineSwitcher.V8.Native.*` packages by the `Microsoft.ClearScript.V8.Native.*` packages.
+
+## v3.9.0 Preview 2 - October 30, 2020
+ * In JavaScriptEngineSwitcher.V8 added support of Microsoft ClearScript.V8 version 7.0 RC4 (support of V8 version 8.7.220.10)
+
+## v3.8.3 - October 29, 2020
+ * In JavaScriptEngineSwitcher.V8 added support of Microsoft ClearScript.V8 version 7.0 RC4 (support of V8 version 8.7.220.10)
+
+## v3.9.0 Preview - October 24, 2020
+ * In JavaScriptEngineSwitcher.V8:
+ * Cross-platform is implemented by using an [unofficial experimental version of the Microsoft ClearScript.V8](https://github.com/Taritsyn/ClearScript-Experimental) library, which is not targeted at any particular operating system or processor architecture, and can work with various native assemblies
+ * Added a packages, that contains a native assemblies for Linux (x64) and OS X (x64)
+
+## v3.8.2 - October 23, 2020
+ * In JavaScriptEngineSwitcher.V8 added support of Microsoft ClearScript.V8 version 7.0 RC3
+
+## v3.8.1 - October 21, 2020
+ * In JavaScriptEngineSwitcher.V8 added support of Microsoft ClearScript.V8 version 7.0 RC2
+
+## v3.8.0 - October 19, 2020
+ * In JavaScriptEngineSwitcher.V8:
+ * Microsoft ClearScript.V8 was updated to version 7.0 RC (support of V8 version 8.6.395.17)
+ * MSVC runtime was embedded into the native assemblies for Windows
+
+## v3.7.2 - September 9, 2020
+ * In JavaScriptEngineSwitcher.ChakraCore:
+ * ChakraCore was updated to version 1.11.22 ([Tomáš Deml's patch](https://github.com/microsoft/ChakraCore/issues/5973) applied)
+ * Added a experimental support of Windows (ARM64)
+ * In JavaScriptEngineSwitcher.Node added support of Jering.Javascript.NodeJS version 5.4.3
+
+## v3.7.1 - August 12, 2020
+ * In JavaScriptEngineSwitcher.ChakraCore added support of ChakraCore version 1.11.21 ([Tomáš Deml's patch](https://github.com/microsoft/ChakraCore/issues/5973) applied)
+
+## v3.7.0 - August 6, 2020
+ * In JavaScriptEngineSwitcher.Jurassic:
+ * Jurassic was updated to version of August 3, 2020
+ * In configuration settings of the Jurassic JS engine was added one new non-standard property - `EnableHostCollectionsEmbeddingByValue` (default `false`)
+
+## v3.6.0 - August 1, 2020
+ * In JavaScriptEngineSwitcher.Jint added a ability to interrupt execution of the script
+ * In JavaScriptEngineSwitcher.NiL added support of NiL.JS version 2.5.1466
+ * In JavaScriptEngineSwitcher.Node added support of Jering.Javascript.NodeJS version 5.4.2
+
+## v3.5.6 - June 11, 2020
+ * In JavaScriptEngineSwitcher.ChakraCore added support of ChakraCore version 1.11.20 ([Tomáš Deml's patch](https://github.com/microsoft/ChakraCore/issues/5973) applied)
+ * In JavaScriptEngineSwitcher.Jint added support of Jint version 3.0.0 Beta 1828
+
+## v3.5.5 - May 29, 2020
+ * In JavaScriptEngineSwitcher.V8 added support of Microsoft ClearScript.V8 version 6.0.2 (support of V8 version 8.3.110.9)
+
+## v3.5.4 - May 13, 2020
+ * In JavaScriptEngineSwitcher.ChakraCore added support of ChakraCore version 1.11.19 ([Tomáš Deml's patch](https://github.com/microsoft/ChakraCore/issues/5973) applied)
+
+## v3.5.3 - May 8, 2020
+ * In JavaScriptEngineSwitcher.V8 fixed a error that caused incorrect generation of error description for an `JsEngineLoadException` exception
+
+## v3.5.2 - April 15, 2020
+ * In JavaScriptEngineSwitcher.ChakraCore added support of ChakraCore version 1.11.18 ([Tomáš Deml's patch](https://github.com/microsoft/ChakraCore/issues/5973) applied)
+
+## v3.5.1 - April 14, 2020
+ * In JavaScriptEngineSwitcher.Jint added support of Jint version 3.0.0 Beta 1778
+ * In JavaScriptEngineSwitcher.V8 added support of Microsoft ClearScript.V8 version 6.0.1 (support of V8 version 8.1.307.28)
+
+## v3.5.0 - April 3, 2020
+ * In JavaScriptEngineSwitcher.Jint:
+ * Jint was updated to version 3.0.0 Beta 1756
+ * No longer supports a .NET Framework 4.5
+ * Added support of .NET Framework 4.6.1 and .NET Standard 2.1
+
+## v3.4.5 - April 1, 2020
+ * In JavaScriptEngineSwitcher.ChakraCore applied the Tomáš Deml's patch to fix the [“Incompatibility in handling of SIGSEGV between ChakraCore and CoreCLR”](https://github.com/microsoft/ChakraCore/issues/5973) error
+ * In JavaScriptEngineSwitcher.NiL added support of NiL.JS version 2.5.1440
+ * In JavaScriptEngineSwitcher.Node added a handling of errors that occur when switching to multi-process mode of the Jering.Javascript.NodeJS library
+
+## v3.4.4 - March 11, 2020
+ * In JavaScriptEngineSwitcher.ChakraCore added support of ChakraCore version 1.11.17
+ * In JavaScriptEngineSwitcher.Node added support of Jering.Javascript.NodeJS version 5.4.0
+
+## v3.4.3 - March 8, 2020
+ * In JavaScriptEngineSwitcher.ChakraCore fixed a [error #82](https://github.com/Taritsyn/JavaScriptEngineSwitcher/issues/82) “Program crash after function call with too much parameters”
+ * In JavaScriptEngineSwitcher.NiL added support of NiL.JS version 2.5.1431
+ * In JavaScriptEngineSwitcher.Msie added support of MSIE JavaScript Engine version 3.0.7
+
+## v3.4.2 - March 2, 2020
+ * In JavaScriptEngineSwitcher.Jint:
+ * Jint was updated to version 3.0.0 Beta 1715
+ * Simplified and improved a handling of JS runtime errors
+
+## v3.4.1 - February 26, 2020
+ * In JavaScriptEngineSwitcher.Node the default Node JS service is now implemented as a wrapper around the StaticNodeJSService class
+
+## v3.4.0 - February 24, 2020
+ * Added a module based on the [Jering.Javascript.NodeJS](https://github.com/JeringTech/Javascript.NodeJS)
+
+## v3.3.3 - February 15, 2020
+ * In JavaScriptEngineSwitcher.NiL:
+ * NiL.JS was updated to version 2.5.1428
+ * NiL.JS.NetCore package is no longer used
+ * Added support of .NET Framework 4.6.1 and .NET Standard 1.6
+
+## v3.3.2 - February 14, 2020
+ * In JavaScriptEngineSwitcher.ChakraCore added support of ChakraCore version 1.11.16
+
+## v3.3.1 - February 1, 2020
+ * In JavaScriptEngineSwitcher.NiL added support of NiL.JS version 2.5.1403
+ * Added a `ClearScript.xml` files to the JavaScriptEngineSwitcher.V8 package
+
+## v3.3.0 - December 27, 2019
+ * Enabled a SourceLink in NuGet packages
+ * In JavaScriptEngineSwitcher.ChakraCore added support of .NET Standard 2.1
+ * In JavaScriptEngineSwitcher.V8:
+ * Microsoft ClearScript.V8 was updated to version 6.0.0 (support of V8 version 7.9.317.32)
+ * Added support of .NET Core 3.1 on Windows
+ * Now the Microsoft ClearScript.V8 requires the [Microsoft Visual C++ Redistributable for Visual Studio 2019](https://visualstudio.microsoft.com/downloads/#microsoft-visual-c-redistributable-for-visual-studio-2019)
+
+## v3.2.4 - December 17, 2019
+ * In JavaScriptEngineSwitcher.ChakraCore fixed a errors leading to null reference exceptions in the `ReflectionHelpers` class. Special thanks to [Vanjoge](https://github.com/vanjoge).
+ * In JavaScriptEngineSwitcher.Msie added support of MSIE JavaScript Engine version 3.0.6
+
+## v3.2.3 - November 15, 2019
+ * In JavaScriptEngineSwitcher.ChakraCore added support of ChakraCore version 1.11.15
+ * In JavaScriptEngineSwitcher.Jint added support of Jint version 3.0.0 Beta 1632
+ * In JavaScriptEngineSwitcher.NiL:
+ * NiL.JS was updated to version 2.5.1388
+ * In configuration settings of the NiL JS engine was added one new property - `LocalTimeZone` (default `TimeZoneInfo.Local`)
+
+## v3.2.2 - October 26, 2019
+ * In JavaScriptEngineSwitcher.Jint added support of Jint version 3.0.0 Beta 1629
+
+## v3.2.1 - October 21, 2019
+ * In JavaScriptEngineSwitcher.ChakraCore:
+ * Fixed a error that caused a crash during finalization
+ * During calling of the `CollectGarbage` method is again not performed blocking
+ * In JavaScriptEngineSwitcher.Msie added support of MSIE JavaScript Engine version 3.0.5
+
+## v3.2.0 - October 12, 2019
+ * In JavaScriptEngineSwitcher.Jint:
+ * Jint was updated to version 3.0.0 Beta 1612. Special thanks to [Marko Lahma](https://github.com/lahma) and [Sébastien Ros](https://github.com/sebastienros)
+ * No longer supports a .NET Framework 4.0 Client and .NET Standard 1.3
+ * In configuration settings of the Jint JS engine was added two new properties: `MemoryLimit` (default `0`) and `RegexTimeoutInterval` (default `null`)
+ * To install this package, the “Include Prerelease” option must be set in the NuGet Package Manager
+
+## v3.1.10 - October 9, 2019
+ * In JavaScriptEngineSwitcher.ChakraCore:
+ * ChakraCore was updated to version 1.11.14
+ * Slightly improved performance
+ * The `CollectGarbage` method is called synchronously again
+ * In JavaScriptEngineSwitcher.Msie added support of MSIE JavaScript Engine version 3.0.4
+
+## v3.1.9 - September 17, 2019
+ * In JavaScriptEngineSwitcher.NiL added support of NiL.JS version 2.5.1372
+
+## v3.1.8 - September 12, 2019
+ * In JavaScriptEngineSwitcher.ChakraCore added support of ChakraCore version 1.11.13
+
+## v3.1.7 - August 14, 2019
+ * In JavaScriptEngineSwitcher.ChakraCore:
+ * ChakraCore was updated to version 1.11.12
+ * MSVC runtime was embedded into the native assemblies for Windows
+
+## v3.1.6 - August 5, 2019
+ * In JavaScriptEngineSwitcher.V8 fixed a [error #73](https://github.com/Taritsyn/JavaScriptEngineSwitcher/issues/73) “Trying to Run this in the GAC”
+
+## v3.1.5 - August 2, 2019
+ * In JavaScriptEngineSwitcher.V8 added support of Microsoft ClearScript.V8 version 5.6.0 (support of V8 version 7.6.303.28)
+
+## v3.1.4 - July 17, 2019
+ * In JavaScriptEngineSwitcher.NiL added support of NiL.JS version 2.5.1339
+
+## v3.1.3 - July 10, 2019
+ * In JavaScriptEngineSwitcher.ChakraCore added support of ChakraCore version 1.11.11
+
+## v3.1.2 - June 13, 2019
+ * In JavaScriptEngineSwitcher.ChakraCore added support of ChakraCore version 1.11.10
+
+## v3.1.1 - May 15, 2019
+ * In JavaScriptEngineSwitcher.ChakraCore added support of ChakraCore version 1.11.9
+
+## v3.1.0 - May 3, 2019
+ * In the `JsEngineFactoryCollection` class was added a `Count` property and `GetRegisteredFactories` method
+ * Removed a deprecated packages: JavaScriptEngineSwitcher.ChakraCore.Native.win8-arm and JavaScriptEngineSwitcher.ChakraCore.Native.debian-x64
+ * In JavaScriptEngineSwitcher.V8 added support of Microsoft ClearScript.V8 version 5.5.6 (support of V8 version 7.4.288.26)
+
+## v3.0.10 - April 29, 2019
+ * In JavaScriptEngineSwitcher.ChakraCore in configuration settings was changed default value of `DisableFatalOnOOM` property from `false` to `true`
+ * In JavaScriptEngineSwitcher.Jint fixed a error that occurred during the recursive execution and evaluation of JS files
+ * In JavaScriptEngineSwitcher.Msie added support of MSIE JavaScript Engine version 3.0.3
+ * In JavaScriptEngineSwitcher.NiL added support of NiL.JS version 2.5.1327
+
+## v3.0.9 - April 10, 2019
+ * In JavaScriptEngineSwitcher.ChakraCore added support of ChakraCore version 1.11.8
+
+## v3.0.8 - April 9, 2019
+ * In JavaScriptEngineSwitcher.ChakraCore fixed a [error #72](https://github.com/Taritsyn/JavaScriptEngineSwitcher/issues/72) “(chakra) recursive evaluation”
+ * In JavaScriptEngineSwitcher.NiL added support of NiL.JS version 2.5.1320
+
+## v3.0.7 - March 13, 2019
+ * In JavaScriptEngineSwitcher.ChakraCore:
+ * ChakraCore was updated to version 1.11.7
+ * Fixed a [error #68](https://github.com/Taritsyn/JavaScriptEngineSwitcher/issues/68) “Embedded delegates are no longer linked with the `Function` prototype”
+ * In JavaScriptEngineSwitcher.Jint fixed a error that occurs in the strict mode when generating an error message
+ * In JavaScriptEngineSwitcher.Msie added support of MSIE JavaScript Engine version 3.0.2
+
+## v3.0.6 - February 15, 2019
+ * In JavaScriptEngineSwitcher.ChakraCore added support of ChakraCore version 1.11.6
+
+## v3.0.5 - February 8, 2019
+ * In JavaScriptEngineSwitcher.V8 added support of Microsoft ClearScript.V8 version 5.5.5 (support of V8 version 7.2.502.25)
+
+## v3.0.4 - February 1, 2019
+ * In JavaScriptEngineSwitcher.ChakraCore in error message fixed a link to the documentation
+
+## v3.0.3 - January 29, 2019
+ * In JavaScriptEngineSwitcher.ChakraCore improved a performance of the `UnicodeToAnsi` method of `EncodingHelpers` class
+ * In JavaScriptEngineSwitcher.NiL added support of NiL.JS version 2.5.1294
+
+## v3.0.2 - January 24, 2019
+ * In JavaScriptEngineSwitcher.ChakraCore:
+ * Reduced a memory consumption in cases, where not used the embedding of objects and types
+ * Fixed a wrong implementation of destruction of the embedded delegates
+ * Accelerated a conversion of script types to host types
+ * In JavaScriptEngineSwitcher.Msie added support of MSIE JavaScript Engine version 3.0.1
+
+## v3.0.1 - January 11, 2019
+ * In JavaScriptEngineSwitcher.ChakraCore:
+ * ChakraCore was updated to version 1.11.5
+ * Fixed a [error #65](https://github.com/Taritsyn/JavaScriptEngineSwitcher/issues/65) “Memory leak using EmbedHostObject”
+
## v3.0.0 - December 25, 2018
* In the `JsEngineSwitcher` class a `Instance` property was renamed to the `Current` property
* Now you can implement your own version of the `JsEngineSwitcher` class
@@ -57,6 +691,16 @@ Change log
* Added a `netcoreapp2.1` target
* In JavaScriptEngineSwitcher.NiL added support of NiL.JS version 2.5.1282
+## v2.4.29 - November 20, 2018
+ * In JavaScriptEngineSwitcher.Msie added support of MSIE JavaScript Engine version 2.2.10
+ * In JavaScriptEngineSwitcher.ChakraCore added support of ChakraCore version 1.11.3
+
+## v2.4.28 - October 13, 2018
+ * In JavaScriptEngineSwitcher.ChakraCore added support of ChakraCore version 1.11.2
+
+## v2.4.27 - September 21, 2018
+ * In JavaScriptEngineSwitcher.ChakraCore was optimized a memory usage in version for Unix
+
## v3.0.0 RC 1 - September 19, 2018
* Fixed a [error #59](https://github.com/Taritsyn/JavaScriptEngineSwitcher/issues/59) “Unhandled exception when JS exception is thrown”
* In JavaScriptEngineSwitcher.Msie:
@@ -69,6 +713,16 @@ Change log
* Optimized a memory usage
* `MaxStackSize` configuration property was removed from the version for .NET Standard 1.3
+## v2.4.26 - September 13, 2018
+ * In JavaScriptEngineSwitcher.ChakraCore added support of ChakraCore version 1.11.1
+
+## v2.4.25 - September 8, 2018
+ * In JavaScriptEngineSwitcher.Jint in configuration settings was added one new property - `LocalTimeZone` (default `TimeZoneInfo.Local`)
+ * In JavaScriptEngineSwitcher.ChakraCore improved a performance in version for Unix
+
+## v2.4.24 - August 30, 2018
+ * In JavaScriptEngineSwitcher.ChakraCore added support of ChakraCore version 1.11.0
+
## v3.0.0 Beta 9 - August 21, 2018
* In JavaScriptEngineSwitcher.V8 added support of Microsoft ClearScript.V8 version 5.5.3 (support of V8 version 6.8.275.28)
* In JavaScriptEngineSwitcher.Jurassic the original library was rolled back to version of February 24, 2018
@@ -77,17 +731,37 @@ Change log
* Added support of NiL.JS version 2.5.1278
* Fixed a [error #57](https://github.com/Taritsyn/JavaScriptEngineSwitcher/issues/57) “Nil - can't locate function name”
+## v2.4.23 - August 20, 2018
+ * In JavaScriptEngineSwitcher.Jurassic the original library was rolled back to version of February 24, 2018
+ * In JavaScriptEngineSwitcher.ChakraCore added support of ChakraCore version 1.10.2
+
+## v2.4.22 - July 11, 2018
+ * In JavaScriptEngineSwitcher.ChakraCore added support of ChakraCore version 1.10.1
+
## v3.0.0 Beta 8 - July 7, 2018
* ChakraCore was updated to version 1.10.0
* In configuration settings of the ChakraCore JS engine was added one new property - `DisableExecutablePageAllocation` (default `false`)
+## v2.4.21 - July 2, 2018
+ * In JavaScriptEngineSwitcher.ChakraCore:
+ * ChakraCore was updated to version 1.10.0
+ * In configuration settings of the ChakraCore JS engine was added one new property - `DisableExecutablePageAllocation` (default `false`)
+
## v3.0.0 Beta 7 - June 18, 2018
* In JavaScriptEngineSwitcher.ChakraCore added support of ChakraCore version 1.8.5
+## v2.4.20 - June 13, 2018
+ * In JavaScriptEngineSwitcher.ChakraCore added support of ChakraCore version 1.8.5
+
## v3.0.0 Beta 6 - June 12, 2018
* In JavaScriptEngineSwitcher.Extensions.MsDependencyInjection added a overloaded versions of the `AddJsEngineSwitcher` extension method, which takes an instance of JS engine switcher
* In JavaScriptEngineSwitcher.Jurassic added support of Jurassic version of June 7, 2018
+## v2.4.19 - June 12, 2018
+ * In JavaScriptEngineSwitcher.Msie added support of MSIE JavaScript Engine version 2.2.9
+ * In JavaScriptEngineSwitcher.Jurassic added support of Jurassic version of June 7, 2018
+ * In JavaScriptEngineSwitcher.ChakraCore changed a implementation of the `Dispose` method
+
## v3.0.0 Beta 5 - June 6, 2018
* In JavaScriptEngineSwitcher.Msie added support of MSIE JavaScript Engine version 3.0.0 Beta 4
* In JavaScriptEngineSwitcher.ChakraCore:
@@ -103,6 +777,10 @@ Change log
* Fixed a implementation of the `JsSerializedLoadScriptCallback` delegate
* Fixed a [error #34](https://github.com/Taritsyn/JavaScriptEngineSwitcher/issues/34) “Finalazier thread is blocked because of JavaScriptEngineSwitcher.ChakraCore.ChakraCoreJsEngine”
+## v2.4.18 - May 24, 2018
+ * In JavaScriptEngineSwitcher.Msie added support of MSIE JavaScript Engine version 2.2.8
+ * In JavaScriptEngineSwitcher.ChakraCore fixed a [error #34](https://github.com/Taritsyn/JavaScriptEngineSwitcher/issues/34) “Finalazier thread is blocked because of JavaScriptEngineSwitcher.ChakraCore.ChakraCoreJsEngine”
+
## v3.0.0 Beta 3 - May 22, 2018
* In `IJsEngine` interface was added `SupportsScriptPrecompilation` property and three new methods: `Precompile`, `PrecompileFile` and `PrecompileResource`
* In JavaScriptEngineSwitcher.Msie, JavaScriptEngineSwitcher.V8, JavaScriptEngineSwitcher.Jurassic, JavaScriptEngineSwitcher.Jint and JavaScriptEngineSwitcher.ChakraCore added a ability to pre-compile scripts
@@ -113,9 +791,22 @@ Change log
* ChakraCore was updated to version 1.8.4
* JavaScriptEngineSwitcher.ChakraCore.Native.win8-arm package has been replaced by the JavaScriptEngineSwitcher.ChakraCore.Native.win-arm package
+## v2.4.17 - May 9, 2018
+ * In JavaScriptEngineSwitcher.ChakraCore:
+ * ChakraCore was updated to version 1.8.4
+ * JavaScriptEngineSwitcher.ChakraCore.Native.win8-arm package has been replaced by the JavaScriptEngineSwitcher.ChakraCore.Native.win-arm package
+
+## v2.4.16 - April 13, 2018
+ * In JavaScriptEngineSwitcher.V8.Native.win-* and JavaScriptEngineSwitcher.ChakraCore.Native.win-* packages the directories with `win7-*` RIDs was renamed to `win-*`
+
## v3.0.0 Beta 2 - April 12, 2018
* In JavaScriptEngineSwitcher.ChakraCore added support of ChakraCore version 1.8.3
+## v2.4.15 - April 11, 2018
+ * In JavaScriptEngineSwitcher.Msie added support of MSIE JavaScript Engine version 2.2.7
+ * In JavaScriptEngineSwitcher.ChakraCore and JavaScriptEngineSwitcher.Vroom fixed a minor errors
+ * In JavaScriptEngineSwitcher.ChakraCore added support of ChakraCore version 1.8.3
+
## v3.0.0 Beta 1 - April 8, 2018
* Format of the error messages was unified
* Created a new exception classes: `JsCompilationException`, `JsEngineException`, `JsFatalException`, `JsTimeoutException` and `JsUsageException`. These exceptions are responsible for handling errors, some of which were previously handled by the `JsRuntimeException` class.
@@ -137,11 +828,37 @@ Change log
* Now the ChakraCore for Windows requires the [Microsoft Visual C++ Redistributable for Visual Studio 2017](https://www.visualstudio.com/downloads/#microsoft-visual-c-redistributable-for-visual-studio-2017)
* In configuration settings of the ChakraCore JS engine was added one new property - `MaxStackSize` (default `492` or `984` KB)
+## v2.4.14 - March 14, 2018
+ * In JavaScriptEngineSwitcher.ChakraCore added support of ChakraCore version 1.8.2
+
+## v2.4.13 - February 24, 2018
+ * In JavaScriptEngineSwitcher.Msie added support of MSIE JavaScript Engine version 2.2.6
+ * In JavaScriptEngineSwitcher.V8:
+ * Microsoft ClearScript.V8 was updated to version 5.4.10
+ * Improved implementation of the `CallFunction` method
+ * Removed unnecessary locks from the `V8JsEngine` class
+ * In configuration settings of the V8 JS engine was added 3 new properties: `HeapSizeSampleInterval` (default `TimeSpan.Zero`), `MaxHeapSize` (default `UIntPtr.Zero`) and `MaxStackUsage` (default `UIntPtr.Zero`)
+ * In JavaScriptEngineSwitcher.Jurassic added support of Jurassic version of February 24, 2018
+ * In JavaScriptEngineSwitcher.Jint added support of Jint version 2.11.58
+
+## v2.4.12 - February 20, 2018
+ * In JavaScriptEngineSwitcher.ChakraCore:
+ * ChakraCore was updated to version 1.8.1
+ * JavaScriptEngineSwitcher.ChakraCore.Native.debian-x64 package has been replaced by the JavaScriptEngineSwitcher.ChakraCore.Native.linux-x64 package
+ * ICU-57 library was embedded into the `libChakraCore.so` and `libChakraCore.dylib` assemblies
+ * Prevented an occurrence of the “Host may not have set any promise continuation callback. Promises may not be executed.” error
+ * In configuration settings of the ChakraCore JS engine was added two new properties - `MemoryLimit` and `DisableFatalOnOOM` (default `false`)
+ * Now during calling of the `CollectGarbage` method is no longer performed blocking
+
## v3.0.0 Alpha 10 - January 3, 2018
* In JavaScriptEngineSwitcher.V8:
* Added support of Microsoft ClearScript.V8 version 5.5.1.1 (support of V8 version 6.3.292.48)
* In configuration settings of the V8 JS engine was added one new property - `AwaitDebuggerAndPauseOnStart` (default `false`)
+## v2.4.11 - December 24, 2017
+ * In JavaScriptEngineSwitcher.Msie added support of MSIE JavaScript Engine version 2.2.5
+ * In JavaScriptEngineSwitcher.ChakraCore fixed a error, that occurred during finding the suitable method overload, that receives numeric values and interfaces as parameters, of the host object
+
## v3.0.0 Alpha 9 - December 22, 2017
* In JavaScriptEngineSwitcher.Msie added support of MSIE JavaScript Engine version 3.0.0 Alpha 3
* In JavaScriptEngineSwitcher.V8 in configuration settings of the V8 JS engine was changed types of `MaxHeapSize` and `MaxStackUsage` properties from `ulong` to `UIntPtr`
diff --git a/Directory.Packages.props b/Directory.Packages.props
new file mode 100644
index 00000000..bbbdb4f8
--- /dev/null
+++ b/Directory.Packages.props
@@ -0,0 +1,18 @@
+
+ Request ID: @Model.RequestId
+
+ Swapping to Development environment will display more detailed information about the error that occurred. +
++ The Development environment shouldn't be enabled for deployed applications. + It can result in displaying sensitive information from exceptions to end users. + For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development + and restarting the app. +
\ No newline at end of file diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/Views/Shared/_JsEvaluationErrorList.cshtml b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore10.Mvc10/Views/Shared/_JsEvaluationErrorList.cshtml similarity index 88% rename from samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/Views/Shared/_JsEvaluationErrorList.cshtml rename to samples/JavaScriptEngineSwitcher.Sample.AspNetCore10.Mvc10/Views/Shared/_JsEvaluationErrorList.cshtml index f4305096..9e0601d6 100644 --- a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/Views/Shared/_JsEvaluationErrorList.cshtml +++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore10.Mvc10/Views/Shared/_JsEvaluationErrorList.cshtml @@ -1,4 +1,4 @@ -@using JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2.Infrastructure.Helpers +@using JavaScriptEngineSwitcher.Sample.AspNetCore.Infrastructure.Helpers @using JavaScriptEngineSwitcher.Sample.Logic.Models @model IList`, ``, and ``.
-@font-family-monospace: Consolas, "Courier New", monospace;
-@font-family-base: @font-family-sans-serif;
-
-@font-size-base: 14px;
-@font-size-large: ceil((@font-size-base * 1.25)); // ~18px
-@font-size-small: ceil((@font-size-base * 0.85)); // ~12px
-
-@font-size-h1: floor(@font-size-base * 3);
-@font-size-h2: @font-size-base * 2.5;
-@font-size-h3: ceil(@font-size-base * 1.75);
-@font-size-h4: ceil(@font-size-base * 1.25);
-@font-size-h5: @font-size-base;
-@font-size-h6: ceil(@font-size-base * 0.85);
-
-//** Unit-less `line-height` for use in components like buttons.
-@line-height-base: 1.428571429; // 20/14
-//** Computed "line-height" (`font-size` * `line-height`) for use with `margin`, `padding`, etc.
-@line-height-computed: floor((@font-size-base * @line-height-base)); // ~20px
-
-//** By default, this inherits from the ``.
-@headings-font-family: "Open Sans", sans-serif;
-@headings-font-weight: normal;
-@headings-line-height: 1.1;
-@headings-color: inherit;
-
-
-//== Iconography
-//
-//## Specify custom location and filename of the included Glyphicons icon font. Useful for those including Bootstrap via Bower.
-
-//** Load fonts from this directory.
-@icon-font-path: "../fonts/";
-//** File name for all font files.
-@icon-font-name: "glyphicons-halflings-regular";
-//** Element ID within SVG icon file.
-@icon-font-svg-id: "glyphicons_halflingsregular";
-
-
-//== Components
-//
-//## Define common padding and border radius sizes and more. Values based on 14px text and 1.428 line-height (~20px to start).
-
-@padding-base-vertical: 4px;
-@padding-base-horizontal: 6px;
-
-@padding-large-vertical: 10px;
-@padding-large-horizontal: 16px;
-
-@padding-small-vertical: 5px;
-@padding-small-horizontal: 10px;
-
-@padding-xs-vertical: 1px;
-@padding-xs-horizontal: 5px;
-
-@line-height-large: 1.33;
-@line-height-small: 1.5;
-
-@border-radius-base: 4px;
-@border-radius-large: 6px;
-@border-radius-small: 3px;
-
-//** Global color for active items (e.g., navs or dropdowns).
-@component-active-color: #fff;
-//** Global background color for active items (e.g., navs or dropdowns).
-@component-active-bg: @brand-primary;
-
-//** Width of the `border` for generating carets that indicator dropdowns.
-@caret-width-base: 4px;
-//** Carets increase slightly in size for larger components.
-@caret-width-large: 5px;
-
-
-//== Tables
-//
-//## Customizes the `.table` component with basic values, each used across all table variations.
-
-//** Padding for ``s and ` `s.
-@table-cell-padding: 8px;
-//** Padding for cells in `.table-condensed`.
-@table-condensed-cell-padding: 5px;
-
-//** Default background color used for all tables.
-@table-bg: transparent;
-//** Background color used for `.table-striped`.
-@table-bg-accent: #f9f9f9;
-//** Background color used for `.table-hover`.
-@table-bg-hover: #f5f5f5;
-@table-bg-active: @table-bg-hover;
-
-//** Border color for table and cell borders.
-@table-border-color: #ddd;
-
-
-//== Buttons
-//
-//## For each of Bootstrap's buttons, define text, background and border color.
-
-@btn-font-weight: normal;
-
-@btn-default-color: #333;
-@btn-default-bg: @gray-lighter;
-@btn-default-border: @gray-lighter;
-
-@btn-primary-color: #fff;
-@btn-primary-bg: @brand-primary;
-@btn-primary-border: darken(@btn-primary-bg, 5%);
-
-@btn-success-color: #fff;
-@btn-success-bg: @brand-success;
-@btn-success-border: darken(@btn-success-bg, 5%);
-
-@btn-info-color: #fff;
-@btn-info-bg: @brand-info;
-@btn-info-border: darken(@btn-info-bg, 5%);
-
-@btn-warning-color: #fff;
-@btn-warning-bg: @brand-warning;
-@btn-warning-border: darken(@btn-warning-bg, 5%);
-
-@btn-danger-color: #fff;
-@btn-danger-bg: @brand-danger;
-@btn-danger-border: darken(@btn-danger-bg, 5%);
-
-@btn-link-disabled-color: @gray-light;
-
-
-//== Forms
-//
-//##
-
-//** `` background color
-@input-bg: #fff;
-//** `` background color
-@input-bg-disabled: @gray-lighter;
-
-//** Text color for ``s
-@input-color: @gray;
-//** `` border color
-@input-border: #b2b2b2;
-
-// TODO: Rename `@input-border-radius` to `@input-border-radius-base` in v4
-//** Default `.form-control` border radius
-@input-border-radius: @border-radius-base;
-//** Large `.form-control` border radius
-@input-border-radius-large: @border-radius-large;
-//** Small `.form-control` border radius
-@input-border-radius-small: @border-radius-small;
-
-//** Border color for inputs on focus
-@input-border-focus: #d4b33a;
-
-//** Placeholder text color
-@input-color-placeholder: #999;
-
-//** Default `.form-control` height
-@input-height-base: (@line-height-computed + (@padding-base-vertical * 2) + 2);
-//** Large `.form-control` height
-@input-height-large: (ceil(@font-size-large * @line-height-large) + (@padding-large-vertical * 2) + 2);
-//** Small `.form-control` height
-@input-height-small: (floor(@font-size-small * @line-height-small) + (@padding-small-vertical * 2) + 2);
-
-@legend-color: @gray-dark;
-@legend-border-color: #e5e5e5;
-
-//** Background color for textual input addons
-@input-group-addon-bg: @gray-lighter;
-//** Border color for textual input addons
-@input-group-addon-border-color: @input-border;
-
-//** Disabled cursor for form controls and buttons.
-@cursor-disabled: not-allowed;
-
-
-//== Dropdowns
-//
-//## Dropdown menu container and contents.
-
-//** Background for the dropdown menu.
-@dropdown-bg: #fff;
-//** Dropdown menu `border-color`.
-@dropdown-border: rgba(0,0,0,.15);
-//** Dropdown menu `border-color` **for IE8**.
-@dropdown-fallback-border: #ccc;
-//** Divider color for between dropdown items.
-@dropdown-divider-bg: #e5e5e5;
-
-//** Dropdown link text color.
-@dropdown-link-color: @gray-dark;
-//** Hover color for dropdown links.
-@dropdown-link-hover-color: darken(@gray-dark, 5%);
-//** Hover background for dropdown links.
-@dropdown-link-hover-bg: #f5f5f5;
-
-//** Active dropdown menu item text color.
-@dropdown-link-active-color: @component-active-color;
-//** Active dropdown menu item background color.
-@dropdown-link-active-bg: @component-active-bg;
-
-//** Disabled dropdown menu item background color.
-@dropdown-link-disabled-color: @gray-light;
-
-//** Text color for headers within dropdown menus.
-@dropdown-header-color: @gray-light;
-
-//** Deprecated `@dropdown-caret-color` as of v3.1.0
-@dropdown-caret-color: #000;
-
-
-//-- Z-index master list
-//
-// Warning: Avoid customizing these values. They're used for a bird's eye view
-// of components dependent on the z-axis and are designed to all work together.
-//
-// Note: These variables are not generated into the Customizer.
-
-@zindex-navbar: 1000;
-@zindex-dropdown: 1000;
-@zindex-popover: 1060;
-@zindex-tooltip: 1070;
-@zindex-navbar-fixed: 1030;
-@zindex-modal: 1040;
-
-
-//== Media queries breakpoints
-//
-//## Define the breakpoints at which your layout will change, adapting to different screen sizes.
-
-// Extra small screen / phone
-//** Deprecated `@screen-xs` as of v3.0.1
-@screen-xs: 480px;
-//** Deprecated `@screen-xs-min` as of v3.2.0
-@screen-xs-min: @screen-xs;
-//** Deprecated `@screen-phone` as of v3.0.1
-@screen-phone: @screen-xs-min;
-
-// Small screen / tablet
-//** Deprecated `@screen-sm` as of v3.0.1
-@screen-sm: 768px;
-@screen-sm-min: @screen-sm;
-//** Deprecated `@screen-tablet` as of v3.0.1
-@screen-tablet: @screen-sm-min;
-
-// Medium screen / desktop
-//** Deprecated `@screen-md` as of v3.0.1
-@screen-md: 992px;
-@screen-md-min: @screen-md;
-//** Deprecated `@screen-desktop` as of v3.0.1
-@screen-desktop: @screen-md-min;
-
-// Large screen / wide desktop
-//** Deprecated `@screen-lg` as of v3.0.1
-@screen-lg: 1200px;
-@screen-lg-min: @screen-lg;
-//** Deprecated `@screen-lg-desktop` as of v3.0.1
-@screen-lg-desktop: @screen-lg-min;
-
-// So media queries don't overlap when required, provide a maximum
-@screen-xs-max: (@screen-sm-min - 1);
-@screen-sm-max: (@screen-md-min - 1);
-@screen-md-max: (@screen-lg-min - 1);
-
-
-//== Grid system
-//
-//## Define your custom responsive grid.
-
-//** Number of columns in the grid.
-@grid-columns: 12;
-//** Padding between columns. Gets divided in half for the left and right.
-@grid-gutter-width: 30px;
-// Navbar collapse
-//** Point at which the navbar becomes uncollapsed.
-@grid-float-breakpoint: @screen-sm-min;
-//** Point at which the navbar begins collapsing.
-@grid-float-breakpoint-max: (@grid-float-breakpoint - 1);
-
-
-//== Container sizes
-//
-//## Define the maximum width of `.container` for different screen sizes.
-
-// Small screen / tablet
-@container-tablet: (720px + @grid-gutter-width);
-//** For `@screen-sm-min` and up.
-@container-sm: @container-tablet;
-
-// Medium screen / desktop
-@container-desktop: (940px + @grid-gutter-width);
-//** For `@screen-md-min` and up.
-@container-md: @container-desktop;
-
-// Large screen / wide desktop
-@container-large-desktop: (1140px + @grid-gutter-width);
-//** For `@screen-lg-min` and up.
-@container-lg: @container-large-desktop;
-
-
-//== Navbar
-//
-//##
-
-// Basics of a navbar
-@navbar-height: 100px;
-@navbar-margin-bottom: 0;
-@navbar-border-radius: @border-radius-base;
-@navbar-padding-horizontal: 0;
-@navbar-padding-vertical: ((@navbar-height - @line-height-computed) / 2);
-@navbar-collapse-max-height: 340px;
-
-@navbar-default-color: @gray-base;
-@navbar-default-bg: #f0db4f;
-@navbar-default-border: #f0db4f;
-
-// Navbar links
-@navbar-default-link-color: @navbar-default-color;
-@navbar-default-link-hover-color: @gray-dark;
-@navbar-default-link-hover-bg: transparent;
-@navbar-default-link-active-color: @navbar-default-color;
-@navbar-default-link-active-bg: transparent;
-@navbar-default-link-disabled-color: #ccc;
-@navbar-default-link-disabled-bg: transparent;
-
-// Navbar brand label
-@navbar-default-brand-color: @navbar-default-link-color;
-@navbar-default-brand-hover-color: darken(@navbar-default-brand-color, 10%);
-@navbar-default-brand-hover-bg: transparent;
-
-// Navbar toggle
-@navbar-default-toggle-hover-bg: #ddd;
-@navbar-default-toggle-icon-bar-bg: @gray-dark;
-@navbar-default-toggle-border-color: #ddd;
-
-
-// Inverted navbar
-// Reset inverted navbar basics
-@navbar-inverse-color: lighten(@gray-light, 15%);
-@navbar-inverse-bg: #222;
-@navbar-inverse-border: darken(@navbar-inverse-bg, 10%);
-
-// Inverted navbar links
-@navbar-inverse-link-color: lighten(@gray-light, 15%);
-@navbar-inverse-link-hover-color: #fff;
-@navbar-inverse-link-hover-bg: transparent;
-@navbar-inverse-link-active-color: @navbar-inverse-link-hover-color;
-@navbar-inverse-link-active-bg: darken(@navbar-inverse-bg, 10%);
-@navbar-inverse-link-disabled-color: #444;
-@navbar-inverse-link-disabled-bg: transparent;
-
-// Inverted navbar brand label
-@navbar-inverse-brand-color: @navbar-inverse-link-color;
-@navbar-inverse-brand-hover-color: #fff;
-@navbar-inverse-brand-hover-bg: transparent;
-
-// Inverted navbar toggle
-@navbar-inverse-toggle-hover-bg: #333;
-@navbar-inverse-toggle-icon-bar-bg: #fff;
-@navbar-inverse-toggle-border-color: #333;
-
-
-//== Navs
-//
-//##
-
-//=== Shared nav styles
-@nav-link-padding: 10px 15px;
-@nav-link-hover-bg: @gray-lighter;
-
-@nav-disabled-link-color: @gray-light;
-@nav-disabled-link-hover-color: @gray-light;
-
-//== Tabs
-@nav-tabs-border-color: #ddd;
-
-@nav-tabs-link-hover-border-color: @gray-lighter;
-
-@nav-tabs-active-link-hover-bg: @body-bg;
-@nav-tabs-active-link-hover-color: @gray;
-@nav-tabs-active-link-hover-border-color: #ddd;
-
-@nav-tabs-justified-link-border-color: #ddd;
-@nav-tabs-justified-active-link-border-color: @body-bg;
-
-//== Pills
-@nav-pills-border-radius: @border-radius-base;
-@nav-pills-active-link-hover-bg: @component-active-bg;
-@nav-pills-active-link-hover-color: @component-active-color;
-
-
-//== Pagination
-//
-//##
-
-@pagination-color: @link-color;
-@pagination-bg: #fff;
-@pagination-border: #ddd;
-
-@pagination-hover-color: @link-hover-color;
-@pagination-hover-bg: @gray-lighter;
-@pagination-hover-border: #ddd;
-
-@pagination-active-color: #fff;
-@pagination-active-bg: @brand-primary;
-@pagination-active-border: @brand-primary;
-
-@pagination-disabled-color: @gray-light;
-@pagination-disabled-bg: #fff;
-@pagination-disabled-border: #ddd;
-
-
-//== Pager
-//
-//##
-
-@pager-bg: @pagination-bg;
-@pager-border: @pagination-border;
-@pager-border-radius: 15px;
-
-@pager-hover-bg: @pagination-hover-bg;
-
-@pager-active-bg: @pagination-active-bg;
-@pager-active-color: @pagination-active-color;
-
-@pager-disabled-color: @pagination-disabled-color;
-
-
-//== Jumbotron
-//
-//##
-
-@jumbotron-padding: 30px;
-@jumbotron-color: inherit;
-@jumbotron-bg: @gray-lighter;
-@jumbotron-heading-color: inherit;
-@jumbotron-font-size: ceil((@font-size-base * 1.5));
-
-
-//== Form states and alerts
-//
-//## Define colors for form feedback states and, by default, alerts.
-
-@state-success-text: #3c763d;
-@state-success-bg: #dff0d8;
-@state-success-border: darken(spin(@state-success-bg, -10), 5%);
-
-@state-info-text: #31708f;
-@state-info-bg: #d9edf7;
-@state-info-border: darken(spin(@state-info-bg, -10), 7%);
-
-@state-warning-text: #8a6d3b;
-@state-warning-bg: #fcf8e3;
-@state-warning-border: darken(spin(@state-warning-bg, -10), 5%);
-
-@state-danger-text: #a94442;
-@state-danger-bg: #f2dede;
-@state-danger-border: darken(spin(@state-danger-bg, -10), 5%);
-
-
-//== Tooltips
-//
-//##
-
-//** Tooltip max width
-@tooltip-max-width: 200px;
-//** Tooltip text color
-@tooltip-color: #fff;
-//** Tooltip background color
-@tooltip-bg: #000;
-@tooltip-opacity: .9;
-
-//** Tooltip arrow width
-@tooltip-arrow-width: 5px;
-//** Tooltip arrow color
-@tooltip-arrow-color: @tooltip-bg;
-
-
-//== Popovers
-//
-//##
-
-//** Popover body background color
-@popover-bg: #fff;
-//** Popover maximum width
-@popover-max-width: 276px;
-//** Popover border color
-@popover-border-color: rgba(0,0,0,.2);
-//** Popover fallback border color
-@popover-fallback-border-color: #ccc;
-
-//** Popover title background color
-@popover-title-bg: darken(@popover-bg, 3%);
-
-//** Popover arrow width
-@popover-arrow-width: 10px;
-//** Popover arrow color
-@popover-arrow-color: @popover-bg;
-
-//** Popover outer arrow width
-@popover-arrow-outer-width: (@popover-arrow-width + 1);
-//** Popover outer arrow color
-@popover-arrow-outer-color: fadein(@popover-border-color, 5%);
-//** Popover outer arrow fallback color
-@popover-arrow-outer-fallback-color: darken(@popover-fallback-border-color, 20%);
-
-
-//== Labels
-//
-//##
-
-//** Default label background color
-@label-default-bg: @gray-light;
-//** Primary label background color
-@label-primary-bg: @brand-primary;
-//** Success label background color
-@label-success-bg: @brand-success;
-//** Info label background color
-@label-info-bg: @brand-info;
-//** Warning label background color
-@label-warning-bg: @brand-warning;
-//** Danger label background color
-@label-danger-bg: @brand-danger;
-
-//** Default label text color
-@label-color: #fff;
-//** Default text color of a linked label
-@label-link-hover-color: #fff;
-
-
-//== Modals
-//
-//##
-
-//** Padding applied to the modal body
-@modal-inner-padding: 15px;
-
-//** Padding applied to the modal title
-@modal-title-padding: 15px;
-//** Modal title line-height
-@modal-title-line-height: @line-height-base;
-
-//** Background color of modal content area
-@modal-content-bg: #fff;
-//** Modal content border color
-@modal-content-border-color: rgba(0,0,0,.2);
-//** Modal content border color **for IE8**
-@modal-content-fallback-border-color: #999;
-
-//** Modal backdrop background color
-@modal-backdrop-bg: #000;
-//** Modal backdrop opacity
-@modal-backdrop-opacity: .5;
-//** Modal header border color
-@modal-header-border-color: #e5e5e5;
-//** Modal footer border color
-@modal-footer-border-color: @modal-header-border-color;
-
-@modal-lg: 900px;
-@modal-md: 600px;
-@modal-sm: 300px;
-
-
-//== Alerts
-//
-//## Define alert colors, border radius, and padding.
-
-@alert-padding: 15px;
-@alert-border-radius: @border-radius-base;
-@alert-link-font-weight: bold;
-
-@alert-success-bg: @state-success-bg;
-@alert-success-text: @state-success-text;
-@alert-success-border: @state-success-border;
-
-@alert-info-bg: @state-info-bg;
-@alert-info-text: @state-info-text;
-@alert-info-border: @state-info-border;
-
-@alert-warning-bg: @state-warning-bg;
-@alert-warning-text: @state-warning-text;
-@alert-warning-border: @state-warning-border;
-
-@alert-danger-bg: @state-danger-bg;
-@alert-danger-text: @state-danger-text;
-@alert-danger-border: @state-danger-border;
-
-
-//== Progress bars
-//
-//##
-
-//** Background color of the whole progress component
-@progress-bg: #f5f5f5;
-//** Progress bar text color
-@progress-bar-color: #fff;
-//** Variable for setting rounded corners on progress bar.
-@progress-border-radius: @border-radius-base;
-
-//** Default progress bar color
-@progress-bar-bg: @brand-primary;
-//** Success progress bar color
-@progress-bar-success-bg: @brand-success;
-//** Warning progress bar color
-@progress-bar-warning-bg: @brand-warning;
-//** Danger progress bar color
-@progress-bar-danger-bg: @brand-danger;
-//** Info progress bar color
-@progress-bar-info-bg: @brand-info;
-
-
-//== List group
-//
-//##
-
-//** Background color on `.list-group-item`
-@list-group-bg: #fff;
-//** `.list-group-item` border color
-@list-group-border: #ddd;
-//** List group border radius
-@list-group-border-radius: @border-radius-base;
-
-//** Background color of single list items on hover
-@list-group-hover-bg: #f5f5f5;
-//** Text color of active list items
-@list-group-active-color: @component-active-color;
-//** Background color of active list items
-@list-group-active-bg: @component-active-bg;
-//** Border color of active list elements
-@list-group-active-border: @list-group-active-bg;
-//** Text color for content within active list items
-@list-group-active-text-color: lighten(@list-group-active-bg, 40%);
-
-//** Text color of disabled list items
-@list-group-disabled-color: @gray-light;
-//** Background color of disabled list items
-@list-group-disabled-bg: @gray-lighter;
-//** Text color for content within disabled list items
-@list-group-disabled-text-color: @list-group-disabled-color;
-
-@list-group-link-color: #555;
-@list-group-link-hover-color: @list-group-link-color;
-@list-group-link-heading-color: #333;
-
-
-//== Panels
-//
-//##
-
-@panel-bg: #fff;
-@panel-body-padding: 15px;
-@panel-heading-padding: 10px 15px;
-@panel-footer-padding: @panel-heading-padding;
-@panel-border-radius: @border-radius-base;
-
-//** Border color for elements within panels
-@panel-inner-border: #ddd;
-@panel-footer-bg: #f5f5f5;
-
-@panel-default-text: @gray-dark;
-@panel-default-border: #ddd;
-@panel-default-heading-bg: #f5f5f5;
-
-@panel-primary-text: #fff;
-@panel-primary-border: @brand-primary;
-@panel-primary-heading-bg: @brand-primary;
-
-@panel-success-text: @state-success-text;
-@panel-success-border: @state-success-border;
-@panel-success-heading-bg: @state-success-bg;
-
-@panel-info-text: @state-info-text;
-@panel-info-border: @state-info-border;
-@panel-info-heading-bg: @state-info-bg;
-
-@panel-warning-text: @state-warning-text;
-@panel-warning-border: @state-warning-border;
-@panel-warning-heading-bg: @state-warning-bg;
-
-@panel-danger-text: @state-danger-text;
-@panel-danger-border: @state-danger-border;
-@panel-danger-heading-bg: @state-danger-bg;
-
-
-//== Thumbnails
-//
-//##
-
-//** Padding around the thumbnail image
-@thumbnail-padding: 4px;
-//** Thumbnail background color
-@thumbnail-bg: @body-bg;
-//** Thumbnail border color
-@thumbnail-border: #ddd;
-//** Thumbnail border radius
-@thumbnail-border-radius: @border-radius-base;
-
-//** Custom text color for thumbnail captions
-@thumbnail-caption-color: @text-color;
-//** Padding around the thumbnail caption
-@thumbnail-caption-padding: 9px;
-
-
-//== Wells
-//
-//##
-
-@well-bg: #f5f5f5;
-@well-border: darken(@well-bg, 7%);
-
-
-//== Badges
-//
-//##
-
-@badge-color: #fff;
-//** Linked badge text color on hover
-@badge-link-hover-color: #fff;
-@badge-bg: @gray-light;
-
-//** Badge text color in active nav link
-@badge-active-color: @link-color;
-//** Badge background color in active nav link
-@badge-active-bg: #fff;
-
-@badge-font-weight: bold;
-@badge-line-height: 1;
-@badge-border-radius: 10px;
-
-
-//== Breadcrumbs
-//
-//##
-
-@breadcrumb-padding-vertical: 8px;
-@breadcrumb-padding-horizontal: 15px;
-//** Breadcrumb background color
-@breadcrumb-bg: #f5f5f5;
-//** Breadcrumb text color
-@breadcrumb-color: #ccc;
-//** Text color of current page in the breadcrumb
-@breadcrumb-active-color: @gray-light;
-//** Textual separator for between breadcrumb elements
-@breadcrumb-separator: "/";
-
-
-//== Carousel
-//
-//##
-
-@carousel-text-shadow: 0 1px 2px rgba(0,0,0,.6);
-
-@carousel-control-color: #fff;
-@carousel-control-width: 15%;
-@carousel-control-opacity: .5;
-@carousel-control-font-size: 20px;
-
-@carousel-indicator-active-bg: #fff;
-@carousel-indicator-border-color: #fff;
-
-@carousel-caption-color: #fff;
-
-
-//== Close
-//
-//##
-
-@close-font-weight: bold;
-@close-color: #000;
-@close-text-shadow: 0 1px 0 #fff;
-
-
-//== Code
-//
-//##
-
-@code-color: #c7254e;
-@code-bg: #f9f2f4;
-
-@kbd-color: #fff;
-@kbd-bg: #333;
-
-@pre-bg: #f5f5f5;
-@pre-color: @gray-dark;
-@pre-border-color: #ccc;
-@pre-scrollable-max-height: 340px;
-
-
-//== Type
-//
-//##
-
-//** Horizontal offset for forms and lists.
-@component-offset-horizontal: 180px;
-//** Text muted color
-@text-muted: @gray-light;
-//** Abbreviations and acronyms border color
-@abbr-border-color: @gray-light;
-//** Headings small color
-@headings-small-color: @gray-light;
-//** Blockquote small color
-@blockquote-small-color: @gray-light;
-//** Blockquote font size
-@blockquote-font-size: (@font-size-base * 1.25);
-//** Blockquote border color
-@blockquote-border-color: @gray-lighter;
-//** Page header border color
-@page-header-border-color: @gray-lighter;
-//** Width of horizontal description list titles
-@dl-horizontal-offset: @component-offset-horizontal;
-//** Horizontal line color.
-@hr-border: #b2b2b2;
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore1Full.Mvc1/wwwroot/styles/buttons.less b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore1Full.Mvc1/wwwroot/styles/buttons.less
deleted file mode 100644
index bbb3c620..00000000
--- a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore1Full.Mvc1/wwwroot/styles/buttons.less
+++ /dev/null
@@ -1,61 +0,0 @@
-//
-// Buttons
-// --------------------------------------------------
-
-
-// Base styles
-// --------------------------------------------------
-
-// Core styles
-.btn {
- display: inline-block;
- padding: 5px 6px 4px 8px;
- margin-top: 0;
- margin-bottom: 0; // For input.btn
- font-family: "Open Sans Condensed", sans-serif;
- font-size: @font-size-base * 1.3;
- font-weight: 700;
- text-transform: uppercase;
- letter-spacing: 1px;
- line-height: @line-height-computed;
- text-align: center;
- vertical-align: middle;
- touch-action: manipulation;
- cursor: pointer;
- background-color: @gray-lighter;
- background-image: none; // Reset unusual Firefox-on-Android default style; see https://github.com/necolas/normalize.css/issues/214
- border: none;
- border-radius: 3px;
- .box-shadow(1px 1px 0 rgba(0, 0, 0, 0.3));
- outline: none !important;
- white-space: nowrap;
- .user-select(none);
-
- &:focus,
- &.focus {
- .tab-focus();
- }
-
- &:hover,
- &:focus,
- &.focus {
- background-color: lighten(@gray-lighter, 5%);
- text-decoration: none;
- .transition(background-color .1s linear);
- }
-
- &:active,
- &.active {
- outline: 0;
- padding: 6px 5px 3px 9px;
- }
-
- &.disabled,
- &[disabled],
- fieldset[disabled] & {
- cursor: @cursor-disabled;
- pointer-events: none; // Future-proof disabling of clicks
- .opacity(65);
- .box-shadow(1px 1px 0 rgba(0, 0, 0, 0.15));
- }
-}
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore1Full.Mvc1/wwwroot/styles/code.less b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore1Full.Mvc1/wwwroot/styles/code.less
deleted file mode 100644
index 33af7555..00000000
--- a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore1Full.Mvc1/wwwroot/styles/code.less
+++ /dev/null
@@ -1,8 +0,0 @@
-code {
- margin: 0 2px;
- padding: 1px 5px;
- border: 1px solid #E1E1E8;
- background-color: #F7F7F9;
- color: @gray-dark;
- font-size: 85%;
-}
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore1Full.Mvc1/wwwroot/styles/evaluation-form.less b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore1Full.Mvc1/wwwroot/styles/evaluation-form.less
deleted file mode 100644
index 6d505d56..00000000
--- a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore1Full.Mvc1/wwwroot/styles/evaluation-form.less
+++ /dev/null
@@ -1,91 +0,0 @@
-//
-// Evaluation form
-// --------------------------------------------------
-
-
-.evaluation-form {
- .clearfix();
-
- textarea {
- height: 200px;
- }
-}
-
-.evaluation-input-output {
- float: left;
- width: 65%;
-}
-
-.evaluation-input-clear-button {
- position: absolute;
- top: 0;
- right: 0;
- width: 15px;
- height: 15px;
- margin: 6px;
- display: inline-block;
- background: transparent url("../images/clear-text.png") no-repeat scroll 0 0;
- opacity: 0.75;
- line-height: 0;
- vertical-align: bottom;
- cursor: pointer;
-
- &:hover {
- opacity: 1;
- }
-}
-
-.evaluation-input-clear-button.with-scrollbar {
- margin-right: 29px;
-}
-
-.evaluation-output {
- margin-top: 1.5em;
-}
-
-.evaluation-input-field,
-.evaluation-output-field {
- margin-bottom: 0.5em;
- .box-sizing(border-box);
- overflow-x: hidden;
- line-height: @line-height-computed;
-}
-
-.evaluation-output-field {
- &[readonly] {
- cursor: auto;
- background-color: @input-bg;
- }
-}
-
-.evaluation-error-header {
- margin-bottom: @line-height-computed;
- padding-left: 52px;
- background: transparent url("../images/icons/48x48/error.png") no-repeat scroll 0 50%;
- color: @black;
- font-family: @font-family-sans-serif;
- font-weight: bold;
- line-height: 48px;
- vertical-align: middle;
-}
-
-ul.evaluation-error-list,
-ul.evaluation-warning-list {
- li {
- margin-bottom: 1em;
-
- pre {
- margin-top: 0.5em;
- white-space: pre;
- overflow: auto;
- }
- }
-}
-
-ul.evaluation-error-list li pre {
- background-color: @state-danger-bg;
-}
-
-ul.evaluation-warning-list li pre {
- background-color: @state-warning-bg;
-}
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore1Full.Mvc1/wwwroot/styles/forms.less b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore1Full.Mvc1/wwwroot/styles/forms.less
deleted file mode 100644
index 2ceb0559..00000000
--- a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore1Full.Mvc1/wwwroot/styles/forms.less
+++ /dev/null
@@ -1,99 +0,0 @@
-//
-// Forms
-// --------------------------------------------------
-
-// GENERAL STYLES
-// --------------
-
-label {
- font-weight: normal;
-}
-
-
-// Form controls
-// -------------------------
-
-// Common form controls
-.form-control {
- line-height: @input-height-base;
-}
-
-.textarea-wrapper {
- position: relative;
-}
-
-// Form groups
-.form-group {
- margin-bottom: 0.5em;
-}
-
-// Info and errors
-// --------------------------
-.message-info {
- border: 1px solid;
- clear: both;
- padding: 10px 20px;
- color: @state-info-text;
-}
-
-.message-error {
- clear: both;
- color: @state-danger-text;
- font-size: 1.1em;
- font-weight: bold;
- margin: 20px 0 10px 0;
-}
-
-.message-success {
- color: @state-success-text;
- font-size: 1.3em;
- font-weight: bold;
- margin: 20px 0 10px 0;
-}
-
-.error {
- color: @state-danger-text;
-}
-
-// Styles for validation helpers
-// --------------------------
-.validators {
- font-style: normal;
- padding-bottom: 0.5em;
-}
-
-.field-validation-error {
- display: block;
- padding-bottom: 0.5em;
- color: @state-danger-text;
- font-weight: bold;
-}
-
-.field-validation-valid {
- display: none;
-}
-
-input.input-validation-error,
-textarea.input-validation-error,
-select.input-validation-error
-{
- border: 1px solid @state-danger-border;
- background-color: @state-danger-bg;
- .box-shadow(inset 0 1px 1px rgba(0,0,0,.075)); // Redeclare so transitions work
-
- &:focus {
- border-color: @state-danger-border;
- @shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 6px lighten(@state-danger-text, 20%);
- .box-shadow(@shadow);
- }
-}
-
-.validation-summary-errors {
- color: @state-danger-text;
- font-weight: bold;
- font-size: 1.1em;
-}
-
-.validation-summary-valid {
- display: none;
-}
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore1Full.Mvc1/wwwroot/styles/layout.less b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore1Full.Mvc1/wwwroot/styles/layout.less
deleted file mode 100644
index 35a7f386..00000000
--- a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore1Full.Mvc1/wwwroot/styles/layout.less
+++ /dev/null
@@ -1,128 +0,0 @@
-html,
-body {
- margin: 0;
- height: 100%;
- /* The html and body elements cannot have any padding or margin */
-}
-
-/* Wrapper for page content to push down footer */
-.l-wrapper {
- min-height: 100%;
- height: auto !important;
- height: 100%;
- /* Negative indent footer by it's height */
- margin: 0 auto (-1 * @footer-height);
-}
-
-.l-constrained {
- margin: 0 auto;
- padding-left: 20px;
- padding-right: 20px;
- max-width: 1200px;
- min-width: 800px;
-}
-
-.l-header {
- border-top: solid 10px @black;
- border-bottom: 1px solid #d4b33a;
- background-color: #f0db4f;
-
- .l-constrained {
- padding-top: 20px;
- padding-bottom: 20px;
- .clearfix();
- }
-}
-
-.l-content {
- .clearfix();
-}
-
-.l-main-content {
- float: left;
- width: 70%;
-}
-
-.l-sidebar {
- float: right;
- width: 30%;
-}
-
-/* Set the fixed height of the footer here */
-.l-push,
-.l-footer {
- height: @footer-height;
-}
-
-.l-footer {
- width: 100%;
- background-color: @black;
- color: @gray-lighter;
- font-size: @font-size-small;
- line-height: 100%;
-
- .l-constrained {
- padding-top: (@footer-height - 32) / 2;
- .clearfix();
- }
-
- a {
- color: @gray-lighter;
- text-decoration: none;
-
- &:hover,
- &:active {
- text-decoration: underline;
- }
- }
-}
-
-
-// Header
-// -------------------------
-
-.logo {
- margin: 0;
-
- a {
- display: block;
- float: left;
- width: 100px;
- height: 100px;
- background: transparent url("../images/jsengineswitcher-logo.png") no-repeat scroll 0 0;
- text-indent: -9999em;
- }
-}
-
-.primary-nav {
- position: relative;
- left: 40px;
- float: left;
-}
-
-
-// Footer
-// -------------------------
-
-.l-copyright {
- float: left;
- p {
- margin: 0;
- padding: 0;
- }
-}
-
-.l-social {
- float: right;
-
- li {
- display: inline;
- list-style: none outside none;
- padding-left: 10px;
-
- a {
- text-indent: -9999px;
- outline: none;
- }
- }
-}
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore1Full.Mvc1/wwwroot/styles/mixins.less b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore1Full.Mvc1/wwwroot/styles/mixins.less
deleted file mode 100644
index d26eee79..00000000
--- a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore1Full.Mvc1/wwwroot/styles/mixins.less
+++ /dev/null
@@ -1,9 +0,0 @@
-//
-// Mixins
-// --------------------------------------------------
-
-// NO Drop shadows
-.no-box-shadow {
- -webkit-box-shadow: none; // iOS <4.3 & Android <4.1
- box-shadow: none;
-}
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore1Full.Mvc1/wwwroot/styles/navbar.less b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore1Full.Mvc1/wwwroot/styles/navbar.less
deleted file mode 100644
index 95edf3c2..00000000
--- a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore1Full.Mvc1/wwwroot/styles/navbar.less
+++ /dev/null
@@ -1,38 +0,0 @@
-//
-// Navbars
-// --------------------------------------------------
-
-
-// Wrapper and base class
-//
-// Provide a static navbar from which we expand to create full-width, fixed, and
-// other navbar variations.
-
-.navbar {
- border: none;
- border-radius: 0;
-}
-
-// Navbar nav links
-//
-// Builds on top of the `.nav` components with it's own modifier class to make
-// the nav the full height of the horizontal nav (above 768px).
-
-.navbar-nav {
- float: left;
- margin: 0 auto;
-
- > li {
- > a {
- float: none;
- // Vertically center the text given @navbar-height
- padding: ((@navbar-height - @line-height-computed) / 2) 15px ((@navbar-height - @line-height-computed) / 2);
- border: 1px solid transparent;
- font-family: "Open Sans", sans-serif;
- font-size: 2.0em;
- text-decoration: none;
- text-transform: uppercase;
- outline: none;
- }
- }
-}
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore1Full.Mvc1/wwwroot/styles/page-socials.less b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore1Full.Mvc1/wwwroot/styles/page-socials.less
deleted file mode 100644
index ea12dc09..00000000
--- a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore1Full.Mvc1/wwwroot/styles/page-socials.less
+++ /dev/null
@@ -1,14 +0,0 @@
-.page-socials {
- min-height: 60px;
- margin-top: 20px;
- padding-top: 15px;
- border-top: 1px solid #b2b2b2;
-}
-
-.share-buttons {
- li {
- margin-right: 15px;
- vertical-align: top;
- line-height: normal;
- }
-}
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore1Full.Mvc1/wwwroot/styles/type.less b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore1Full.Mvc1/wwwroot/styles/type.less
deleted file mode 100644
index 02d69502..00000000
--- a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore1Full.Mvc1/wwwroot/styles/type.less
+++ /dev/null
@@ -1,24 +0,0 @@
-//
-// Typography
-// --------------------------------------------------
-
-// Headings
-// -------------------------
-
-h1, h2, h3 {
- margin-top: 10px;
-}
-
-h1, h2 {
- line-height: 40px;
-}
-
-h2 {
- color: @black;
- font-weight: bold;
-}
-
-h3 {
- color: @gray-dark;
- line-height: @line-height-computed * 1.25;
-}
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore1Full.Mvc1/wwwroot/styles/variables.less b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore1Full.Mvc1/wwwroot/styles/variables.less
deleted file mode 100644
index 498c9796..00000000
--- a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore1Full.Mvc1/wwwroot/styles/variables.less
+++ /dev/null
@@ -1,7 +0,0 @@
-// Colors
-// -------------------------
-@black: #1d0d0d;
-
-// Footer
-// -------------------------
-@footer-height: 55px;
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/.bowerrc b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/.bowerrc
deleted file mode 100644
index 1b0dc29d..00000000
--- a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/.bowerrc
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "registry": "https://registry.bower.io",
- "directory": "wwwroot/lib"
-}
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/Infrastructure/Helpers/CommonExtensions.cs b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/Infrastructure/Helpers/CommonExtensions.cs
deleted file mode 100644
index 55e8938f..00000000
--- a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/Infrastructure/Helpers/CommonExtensions.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-using System.Text.RegularExpressions;
-
-using Microsoft.AspNetCore.Html;
-using Microsoft.AspNetCore.Mvc.Rendering;
-
-namespace JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2.Infrastructure.Helpers
-{
- public static class CommonExtensions
- {
- public static HtmlString EncodedReplace(this IHtmlHelper htmlHelper, string input,
- string pattern, string replacement)
- {
- return new HtmlString(Regex.Replace(htmlHelper.Encode(input), pattern, replacement));
- }
- }
-}
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/Infrastructure/TagHelpers/ConditionalCommentType.cs b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/Infrastructure/TagHelpers/ConditionalCommentType.cs
deleted file mode 100644
index a037ed43..00000000
--- a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/Infrastructure/TagHelpers/ConditionalCommentType.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2.Infrastructure.TagHelpers
-{
- public enum ConditionalCommentType
- {
- Hidden,
- Revealed,
- RevealedValidating,
- RevealedValidatingSimplified
- }
-}
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2.csproj b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2.csproj
deleted file mode 100644
index e4b2feaf..00000000
--- a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2.csproj
+++ /dev/null
@@ -1,56 +0,0 @@
-
-
-
- JS Engine Switcher: Sample ASP.NET Core 2.0 MVC 2 Site
- 3.0.0
- netcoreapp2.0
- Exe
- true
- true
- false
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- PreserveNewest
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/Program.cs b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/Program.cs
deleted file mode 100644
index 3d2de5be..00000000
--- a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/Program.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-using Microsoft.AspNetCore;
-using Microsoft.AspNetCore.Hosting;
-
-namespace JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2
-{
- public class Program
- {
- public static void Main(string[] args)
- {
- BuildWebHost(args).Run();
- }
-
- public static IWebHost BuildWebHost(string[] args) =>
- WebHost.CreateDefaultBuilder(args)
- .UseStartup()
- .Build()
- ;
- }
-}
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/Properties/launchSettings.json b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/Properties/launchSettings.json
deleted file mode 100644
index 41a406f1..00000000
--- a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/Properties/launchSettings.json
+++ /dev/null
@@ -1,27 +0,0 @@
-{
- "iisSettings": {
- "windowsAuthentication": false,
- "anonymousAuthentication": true,
- "iisExpress": {
- "applicationUrl": "http://localhost:1972/",
- "sslPort": 0
- }
- },
- "profiles": {
- "IIS Express": {
- "commandName": "IISExpress",
- "launchBrowser": true,
- "environmentVariables": {
- "ASPNETCORE_ENVIRONMENT": "Development"
- }
- },
- "JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2": {
- "commandName": "Project",
- "launchBrowser": true,
- "environmentVariables": {
- "ASPNETCORE_ENVIRONMENT": "Development"
- },
- "applicationUrl": "http://localhost:1973/"
- }
- }
-}
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/Views/Home/Contact.cshtml b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/Views/Home/Contact.cshtml
deleted file mode 100644
index cd9663df..00000000
--- a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/Views/Home/Contact.cshtml
+++ /dev/null
@@ -1,23 +0,0 @@
-@{
- ViewBag.Title = "Contact";
-}
-
-
- @ViewBag.Title
- @ViewBag.Body
-
-
-@section Scripts {
-
-}
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/Views/_ViewImports.cshtml b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/Views/_ViewImports.cshtml
deleted file mode 100644
index efee5268..00000000
--- a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/Views/_ViewImports.cshtml
+++ /dev/null
@@ -1,2 +0,0 @@
-@addTagHelper "*, Microsoft.AspNetCore.Mvc.TagHelpers"
-@addTagHelper "*, JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2"
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/appsettings.Development.json b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/appsettings.Development.json
deleted file mode 100644
index 5957581f..00000000
--- a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/appsettings.Development.json
+++ /dev/null
@@ -1,10 +0,0 @@
-{
- "Logging": {
- "IncludeScopes": false,
- "LogLevel": {
- "Default": "Debug",
- "System": "Information",
- "Microsoft": "Information"
- }
- }
-}
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/appsettings.json b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/appsettings.json
deleted file mode 100644
index bedc6020..00000000
--- a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/appsettings.json
+++ /dev/null
@@ -1,16 +0,0 @@
-{
- "Logging": {
- "IncludeScopes": false,
- "LogLevel": {
- "Default": "Debug",
- "System": "Information",
- "Microsoft": "Information"
- }
- },
-
- "JsEngineSwitcher": {
- "Samples": {
- "TextContentDirectoryPath": "../SharedData/text-content"
- }
- }
-}
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/bower.json b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/bower.json
deleted file mode 100644
index f78dc7b5..00000000
--- a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/bower.json
+++ /dev/null
@@ -1,11 +0,0 @@
-{
- "name": "jsengineswitcher.sample.aspnetcore2.mvc2",
- "dependencies": {
- "modernizr": "2.8.3",
- "jquery-compat": "jquery#1.10.2",
- "jquery": "jquery#2.0.3",
- "jquery-validation": "1.13.1",
- "jquery-validation-unobtrusive": "3.2.3",
- "bootstrap": "3.3.0"
- }
-}
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/gulpfile.js b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/gulpfile.js
deleted file mode 100644
index e7de9533..00000000
--- a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/gulpfile.js
+++ /dev/null
@@ -1,135 +0,0 @@
-/*global require */
-"use strict";
-
-// include plug-ins
-var gulp = require('gulp');
-var del = require('del');
-var sourcemaps = require('gulp-sourcemaps');
-var rename = require('gulp-rename');
-var concat = require('gulp-concat');
-var less = require('gulp-less');
-var autoprefixer = require('gulp-autoprefixer');
-var cleanCss = require('gulp-clean-css');
-var uglify = require('gulp-uglify');
-
-var webRootPath = "wwwroot";
-var bowerDirPath = webRootPath + "/lib";
-var styleDirPath = webRootPath + '/styles';
-var scriptDirPath = webRootPath + '/scripts';
-
-//#region Clean
-//#region Clean builded assets
-gulp.task('clean-builded-styles', function () {
- del.sync([styleDirPath + '/build/*']);
-});
-
-gulp.task('clean-builded-scripts', function () {
- del.sync([scriptDirPath + '/build/*']);
-});
-
-gulp.task('clean-builded-assets', ['clean-builded-styles', 'clean-builded-scripts'], function () { });
-//#endregion
-//#endregion
-
-//#region Build assets
-//#region Build styles
-var autoprefixerOptions = {
- browsers: ['> 1%', 'last 3 versions', 'Firefox ESR', 'Opera 12.1'],
- cascade: true
-};
-var cssCleanOptions = { keepSpecialComments: '*' };
-var cssRenameOptions = { extname: '.min.css' };
-
-gulp.task('build-common-styles', function () {
- return gulp
- .src([styleDirPath + '/app.less'])
- .pipe(sourcemaps.init())
- .pipe(less({
- relativeUrls: true,
- rootpath: '/styles/'
- }))
- .pipe(autoprefixer(autoprefixerOptions))
- .pipe(sourcemaps.write('./'))
- .pipe(gulp.dest(styleDirPath + '/build'))
- .pipe(sourcemaps.init({ loadMaps: true }))
- .pipe(concat('common-styles.css'))
- .pipe(cleanCss(cssCleanOptions))
- .pipe(rename(cssRenameOptions))
- .pipe(sourcemaps.write('./'))
- .pipe(gulp.dest(styleDirPath + '/build'))
- ;
-});
-
-gulp.task('build-styles', ['build-common-styles'], function () { });
-//#endregion
-
-//#region Build scripts
-var jsConcatOptions = { newLine: ';' };
-var jsUglifyOptions = {
- output: { comments: /^!/ }
-};
-var jsRenameOptions = { extname: '.min.js' };
-
-gulp.task('build-modernizr-scripts', function () {
- return gulp
- .src([bowerDirPath + '/modernizr/modernizr.js'])
- .pipe(sourcemaps.init())
- .pipe(uglify(jsUglifyOptions))
- .pipe(rename(jsRenameOptions))
- .pipe(sourcemaps.write('./'))
- .pipe(gulp.dest(scriptDirPath + '/build'))
- ;
-});
-
-gulp.task('build-common-scripts', function () {
- return gulp
- .src([scriptDirPath + '/common.js'])
- .pipe(sourcemaps.init({ loadMaps: true }))
- .pipe(rename({ basename: 'common-scripts' }))
- .pipe(uglify(jsUglifyOptions))
- .pipe(rename(jsRenameOptions))
- .pipe(sourcemaps.write('./'))
- .pipe(gulp.dest(scriptDirPath + '/build'))
- ;
-});
-
-gulp.task('build-evaluation-form-scripts', function () {
- return gulp
- .src([bowerDirPath + '/jquery-validation/dist/jquery.validate.js',
- bowerDirPath + '/jquery-validation-unobtrusive/jquery.validate.unobtrusive.js',
- bowerDirPath + '/bootstrap/js/button.js',
- scriptDirPath + '/evaluation-form.js'])
- .pipe(sourcemaps.init({ loadMaps: true }))
- .pipe(concat('evaluation-form-scripts.js', jsConcatOptions))
- .pipe(uglify(jsUglifyOptions))
- .pipe(rename(jsRenameOptions))
- .pipe(sourcemaps.write('./'))
- .pipe(gulp.dest(scriptDirPath + '/build'))
- ;
-});
-
-gulp.task('build-scripts', ['build-modernizr-scripts', 'build-common-scripts',
- 'build-evaluation-form-scripts'], function () { });
-//#endregion
-
-gulp.task('build-assets', ['build-styles', 'build-scripts'], function () { });
-//#endregion
-
-//#region Watch assets
-gulp.task('watch-styles', function () {
- return gulp.watch([styleDirPath + '/**/*.{less,css}', '!' + styleDirPath + '/build/**/*.*'],
- ['build-styles']);
-});
-
-gulp.task('watch-scripts', function () {
- return gulp.watch([scriptDirPath + '/**/*.js', '!' + scriptDirPath + '/build/**/*.*'],
- ['build-scripts']);
-});
-
-gulp.task('watch-assets', ['watch-styles', 'watch-scripts']);
-//#endregion
-
-//Set a default tasks
-gulp.task('default', ['clean-builded-assets'], function () {
- return gulp.start('build-assets');
-});
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/package.json b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/package.json
deleted file mode 100644
index 3413eaa2..00000000
--- a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/package.json
+++ /dev/null
@@ -1,16 +0,0 @@
-{
- "name": "jsengineswitcher.sample.aspnetcore2.mvc2",
- "private": true,
- "version": "3.0.0",
- "devDependencies": {
- "gulp": "3.9.1",
- "del": "3.0.0",
- "gulp-sourcemaps": "2.6.1",
- "gulp-rename": "1.2.2",
- "gulp-concat": "2.6.1",
- "gulp-less": "3.3.2",
- "gulp-autoprefixer": "4.0.0",
- "gulp-clean-css": "2.0.6",
- "gulp-uglify": "3.0.0"
- }
-}
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/wwwroot/images/0.gif b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/wwwroot/images/0.gif
deleted file mode 100644
index 35d42e80..00000000
Binary files a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/wwwroot/images/0.gif and /dev/null differ
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/wwwroot/images/clear-text.png b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/wwwroot/images/clear-text.png
deleted file mode 100644
index 9d217b7f..00000000
Binary files a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/wwwroot/images/clear-text.png and /dev/null differ
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/wwwroot/images/icons/32x32/social-media-icons-32.png b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/wwwroot/images/icons/32x32/social-media-icons-32.png
deleted file mode 100644
index 49aa1fe3..00000000
Binary files a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/wwwroot/images/icons/32x32/social-media-icons-32.png and /dev/null differ
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/wwwroot/images/icons/48x48/error.png b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/wwwroot/images/icons/48x48/error.png
deleted file mode 100644
index 3d6185f7..00000000
Binary files a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/wwwroot/images/icons/48x48/error.png and /dev/null differ
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/wwwroot/images/jsengineswitcher-logo.png b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/wwwroot/images/jsengineswitcher-logo.png
deleted file mode 100644
index 12ed97e0..00000000
Binary files a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/wwwroot/images/jsengineswitcher-logo.png and /dev/null differ
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/wwwroot/scripts/_references.js b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/wwwroot/scripts/_references.js
deleted file mode 100644
index 2b54eea8..00000000
Binary files a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/wwwroot/scripts/_references.js and /dev/null differ
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/wwwroot/scripts/common.js b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/wwwroot/scripts/common.js
deleted file mode 100644
index c94bf102..00000000
--- a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/wwwroot/scripts/common.js
+++ /dev/null
@@ -1,29 +0,0 @@
-var jsEngineSwitcher;
-
-(function (jsEngineSwitcher, undefined) {
- "use strict";
-
- jsEngineSwitcher.registerNamespace = function (namespaceString) {
- var parts = namespaceString.split("."),
- parent = jsEngineSwitcher,
- i
- ;
-
- if (parts[0] === "jsEngineSwitcher") {
- parts = parts.slice(1);
- }
-
- for (i = 0; i < parts.length; i += 1) {
- if (typeof parent[parts[i]] === "undefined") {
- parent[parts[i]] = {};
- }
- parent = parent[parts[i]];
- }
-
- return parent;
- };
-
- jsEngineSwitcher.hasScrollbar = function(elem) {
- return (elem.clientHeight < elem.scrollHeight);
- };
-}(jsEngineSwitcher = jsEngineSwitcher || {}));
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/wwwroot/scripts/evaluation-form.js b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/wwwroot/scripts/evaluation-form.js
deleted file mode 100644
index da1f0199..00000000
--- a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/wwwroot/scripts/evaluation-form.js
+++ /dev/null
@@ -1,83 +0,0 @@
-(function (jsEngineSwitcher, $, undefined) {
- "use strict";
-
- var $evaluationForm,
- $evaluationInputField,
- $evaluationInputClearButton,
- $evaluateButton
- ;
-
- $(function () {
- $evaluationForm = $("form[data-form-type='evaluation-form']");
- $evaluationInputField = $(":input[data-control-type='evaluation-input-field']", $evaluationForm);
- $evaluationInputClearButton = $("");
- $evaluateButton = $(":input[data-control-type='evaluate-button']", $evaluationForm);
-
- $evaluationForm.on("submit", onEvaluationFormSubmitHandler);
-
- $evaluationInputClearButton.on("click", onEvaluationInputClearButtonClickHandler);
- $evaluationInputField.parent().append($evaluationInputClearButton);
- refreshEvaluationInputClearButton();
- $evaluationInputField
- .on("input propertychange keydown keyup paste", onEvaluationInputFieldChangeHandler)
- ;
-
- $evaluateButton.removeAttr("disabled");
- });
-
- $(window).unload(function() {
- $evaluationForm.off("submit", onEvaluationFormSubmitHandler);
-
- $evaluationInputClearButton
- .off("click", onEvaluationInputClearButtonClickHandler)
- .remove()
- ;
-
- $evaluationInputField
- .off("input propertychange keydown keyup paste", onEvaluationInputFieldChangeHandler)
- ;
-
- $evaluationForm = null;
- $evaluationInputField = null;
- $evaluationInputClearButton = null;
- $evaluateButton = null;
- });
-
- var refreshEvaluationInputClearButton = function() {
- if ($.trim($evaluationInputField.val()).length > 0) {
- $evaluationInputClearButton.show();
- } else {
- $evaluationInputClearButton.hide();
- }
-
- if (jsEngineSwitcher.hasScrollbar($evaluationInputField.get(0))) {
- $evaluationInputClearButton.addClass("with-scrollbar");
- }
- else {
- $evaluationInputClearButton.removeClass("with-scrollbar");
- }
- };
-
- var onEvaluationFormSubmitHandler = function () {
- var $form = $(this);
- if ($form.valid()) {
- $evaluateButton.attr("disabled", "disabled");
- $("textarea[data-control-type='evaluation-output-field']", $form).val('');
-
- return true;
- }
-
- return false;
- };
-
- var onEvaluationInputFieldChangeHandler = function () {
- refreshEvaluationInputClearButton();
- };
-
- var onEvaluationInputClearButtonClickHandler = function() {
- $evaluationInputField.val("");
-
- var $button = $(this);
- $button.hide();
- };
-}(jsEngineSwitcher, jQuery));
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/wwwroot/styles/app.less b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/wwwroot/styles/app.less
deleted file mode 100644
index c41a9315..00000000
--- a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/wwwroot/styles/app.less
+++ /dev/null
@@ -1,71 +0,0 @@
-/*!
- * Bootstrap v3.3.0 (http://getbootstrap.com)
- * Copyright 2011-2014 Twitter, Inc.
- * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
- */
-
-// Core variables and mixins
-@import "bootstrap-custom-variables.less";
-@import "../lib/bootstrap/less/mixins.less";
-
-// Reset
-@import "../lib/bootstrap/less/normalize.less";
-//@import "../lib/bootstrap/less/print.less";
-//@import "../lib/bootstrap/less/glyphicons.less";
-
-// Core CSS
-@import "../lib/bootstrap/less/scaffolding.less";
-@import "../lib/bootstrap/less/type.less";
-@import "../lib/bootstrap/less/code.less";
-//@import "../lib/bootstrap/less/grid.less";
-//@import "../lib/bootstrap/less/tables.less";
-@import "../lib/bootstrap/less/forms.less";
-//@import "../lib/bootstrap/less/buttons.less";
-
-// Components
-//@import "../lib/bootstrap/less/component-animations.less";
-//@import "../lib/bootstrap/less/dropdowns.less";
-//@import "../lib/bootstrap/less/button-groups.less";
-//@import "../lib/bootstrap/less/input-groups.less";
-@import "../lib/bootstrap/less/navs.less";
-@import "../lib/bootstrap/less/navbar.less";
-//@import "../lib/bootstrap/less/breadcrumbs.less";
-//@import "../lib/bootstrap/less/pagination.less";
-//@import "../lib/bootstrap/less/pager.less";
-//@import "../lib/bootstrap/less/labels.less";
-//@import "../lib/bootstrap/less/badges.less";
-//@import "../lib/bootstrap/less/jumbotron.less";
-//@import "../lib/bootstrap/less/thumbnails.less";
-//@import "../lib/bootstrap/less/alerts.less";
-//@import "../lib/bootstrap/less/progress-bars.less";
-//@import "../lib/bootstrap/less/media.less";
-//@import "../lib/bootstrap/less/list-group.less";
-//@import "../lib/bootstrap/less/panels.less";
-//@import "../lib/bootstrap/less/responsive-embed.less";
-//@import "../lib/bootstrap/less/wells.less";
-//@import "../lib/bootstrap/less/close.less";
-
-// Components w/ JavaScript
-//@import "../lib/bootstrap/less/modals.less";
-//@import "../lib/bootstrap/less/tooltip.less";
-//@import "../lib/bootstrap/less/popovers.less";
-//@import "../lib/bootstrap/less/carousel.less";
-
-// Utility classes
-@import "../lib/bootstrap/less/utilities.less";
-//@import "../lib/bootstrap/less/responsive-utilities.less";
-
-// JavaScriptEngineSwitcher specs
-@import "variables.less";
-@import "mixins.less";
-
-@import "type.less";
-@import "code.less";
-@import "forms.less";
-@import "buttons.less";
-@import "icons.less";
-@import "navbar.less";
-
-@import "layout.less";
-@import "evaluation-form.less";
-@import "page-socials.less";
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/wwwroot/styles/bootstrap-custom-variables.less b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/wwwroot/styles/bootstrap-custom-variables.less
deleted file mode 100644
index 0be2aa6f..00000000
--- a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/wwwroot/styles/bootstrap-custom-variables.less
+++ /dev/null
@@ -1,856 +0,0 @@
-//
-// Variables
-// --------------------------------------------------
-
-
-//== Colors
-//
-//## Gray and brand colors for use across Bootstrap.
-
-@gray-base: #323330;
-@gray-darker: lighten(@gray-base, 13.5%); // #222
-@gray-dark: lighten(@gray-base, 20%); // #333
-@gray: lighten(@gray-base, 33.5%); // #555
-@gray-light: lighten(@gray-base, 46.7%); // #777
-@gray-lighter: #e3e3e3;
-
-@brand-primary: #428bca;
-@brand-success: #5cb85c;
-@brand-info: #5bc0de;
-@brand-warning: #f0ad4e;
-@brand-danger: #d9534f;
-
-
-//== Scaffolding
-//
-//## Settings for some of the most global styles.
-
-//** Background color for ``.
-@body-bg: #fff;
-//** Global text color on ``.
-@text-color: #1d0d0d;
-
-//** Global textual link color.
-@link-color: @brand-primary;
-//** Link hover color set via `darken()` function.
-@link-hover-color: darken(@link-color, 15%);
-//** Link hover decoration.
-@link-hover-decoration: underline;
-
-
-//== Typography
-//
-//## Font, line-height, and color for body text, headings, and more.
-
-@font-family-sans-serif: "Helvetica Neue", Arial, sans-serif;
-@font-family-serif: Georgia, "Times New Roman", Times, serif;
-//** Default monospace fonts for ``, ``, and ``.
-@font-family-monospace: Consolas, "Courier New", monospace;
-@font-family-base: @font-family-sans-serif;
-
-@font-size-base: 14px;
-@font-size-large: ceil((@font-size-base * 1.25)); // ~18px
-@font-size-small: ceil((@font-size-base * 0.85)); // ~12px
-
-@font-size-h1: floor(@font-size-base * 3);
-@font-size-h2: @font-size-base * 2.5;
-@font-size-h3: ceil(@font-size-base * 1.75);
-@font-size-h4: ceil(@font-size-base * 1.25);
-@font-size-h5: @font-size-base;
-@font-size-h6: ceil(@font-size-base * 0.85);
-
-//** Unit-less `line-height` for use in components like buttons.
-@line-height-base: 1.428571429; // 20/14
-//** Computed "line-height" (`font-size` * `line-height`) for use with `margin`, `padding`, etc.
-@line-height-computed: floor((@font-size-base * @line-height-base)); // ~20px
-
-//** By default, this inherits from the ``.
-@headings-font-family: "Open Sans", sans-serif;
-@headings-font-weight: normal;
-@headings-line-height: 1.1;
-@headings-color: inherit;
-
-
-//== Iconography
-//
-//## Specify custom location and filename of the included Glyphicons icon font. Useful for those including Bootstrap via Bower.
-
-//** Load fonts from this directory.
-@icon-font-path: "../fonts/";
-//** File name for all font files.
-@icon-font-name: "glyphicons-halflings-regular";
-//** Element ID within SVG icon file.
-@icon-font-svg-id: "glyphicons_halflingsregular";
-
-
-//== Components
-//
-//## Define common padding and border radius sizes and more. Values based on 14px text and 1.428 line-height (~20px to start).
-
-@padding-base-vertical: 4px;
-@padding-base-horizontal: 6px;
-
-@padding-large-vertical: 10px;
-@padding-large-horizontal: 16px;
-
-@padding-small-vertical: 5px;
-@padding-small-horizontal: 10px;
-
-@padding-xs-vertical: 1px;
-@padding-xs-horizontal: 5px;
-
-@line-height-large: 1.33;
-@line-height-small: 1.5;
-
-@border-radius-base: 4px;
-@border-radius-large: 6px;
-@border-radius-small: 3px;
-
-//** Global color for active items (e.g., navs or dropdowns).
-@component-active-color: #fff;
-//** Global background color for active items (e.g., navs or dropdowns).
-@component-active-bg: @brand-primary;
-
-//** Width of the `border` for generating carets that indicator dropdowns.
-@caret-width-base: 4px;
-//** Carets increase slightly in size for larger components.
-@caret-width-large: 5px;
-
-
-//== Tables
-//
-//## Customizes the `.table` component with basic values, each used across all table variations.
-
-//** Padding for ``s and ` `s.
-@table-cell-padding: 8px;
-//** Padding for cells in `.table-condensed`.
-@table-condensed-cell-padding: 5px;
-
-//** Default background color used for all tables.
-@table-bg: transparent;
-//** Background color used for `.table-striped`.
-@table-bg-accent: #f9f9f9;
-//** Background color used for `.table-hover`.
-@table-bg-hover: #f5f5f5;
-@table-bg-active: @table-bg-hover;
-
-//** Border color for table and cell borders.
-@table-border-color: #ddd;
-
-
-//== Buttons
-//
-//## For each of Bootstrap's buttons, define text, background and border color.
-
-@btn-font-weight: normal;
-
-@btn-default-color: #333;
-@btn-default-bg: @gray-lighter;
-@btn-default-border: @gray-lighter;
-
-@btn-primary-color: #fff;
-@btn-primary-bg: @brand-primary;
-@btn-primary-border: darken(@btn-primary-bg, 5%);
-
-@btn-success-color: #fff;
-@btn-success-bg: @brand-success;
-@btn-success-border: darken(@btn-success-bg, 5%);
-
-@btn-info-color: #fff;
-@btn-info-bg: @brand-info;
-@btn-info-border: darken(@btn-info-bg, 5%);
-
-@btn-warning-color: #fff;
-@btn-warning-bg: @brand-warning;
-@btn-warning-border: darken(@btn-warning-bg, 5%);
-
-@btn-danger-color: #fff;
-@btn-danger-bg: @brand-danger;
-@btn-danger-border: darken(@btn-danger-bg, 5%);
-
-@btn-link-disabled-color: @gray-light;
-
-
-//== Forms
-//
-//##
-
-//** `` background color
-@input-bg: #fff;
-//** `` background color
-@input-bg-disabled: @gray-lighter;
-
-//** Text color for ``s
-@input-color: @gray;
-//** `` border color
-@input-border: #b2b2b2;
-
-// TODO: Rename `@input-border-radius` to `@input-border-radius-base` in v4
-//** Default `.form-control` border radius
-@input-border-radius: @border-radius-base;
-//** Large `.form-control` border radius
-@input-border-radius-large: @border-radius-large;
-//** Small `.form-control` border radius
-@input-border-radius-small: @border-radius-small;
-
-//** Border color for inputs on focus
-@input-border-focus: #d4b33a;
-
-//** Placeholder text color
-@input-color-placeholder: #999;
-
-//** Default `.form-control` height
-@input-height-base: (@line-height-computed + (@padding-base-vertical * 2) + 2);
-//** Large `.form-control` height
-@input-height-large: (ceil(@font-size-large * @line-height-large) + (@padding-large-vertical * 2) + 2);
-//** Small `.form-control` height
-@input-height-small: (floor(@font-size-small * @line-height-small) + (@padding-small-vertical * 2) + 2);
-
-@legend-color: @gray-dark;
-@legend-border-color: #e5e5e5;
-
-//** Background color for textual input addons
-@input-group-addon-bg: @gray-lighter;
-//** Border color for textual input addons
-@input-group-addon-border-color: @input-border;
-
-//** Disabled cursor for form controls and buttons.
-@cursor-disabled: not-allowed;
-
-
-//== Dropdowns
-//
-//## Dropdown menu container and contents.
-
-//** Background for the dropdown menu.
-@dropdown-bg: #fff;
-//** Dropdown menu `border-color`.
-@dropdown-border: rgba(0,0,0,.15);
-//** Dropdown menu `border-color` **for IE8**.
-@dropdown-fallback-border: #ccc;
-//** Divider color for between dropdown items.
-@dropdown-divider-bg: #e5e5e5;
-
-//** Dropdown link text color.
-@dropdown-link-color: @gray-dark;
-//** Hover color for dropdown links.
-@dropdown-link-hover-color: darken(@gray-dark, 5%);
-//** Hover background for dropdown links.
-@dropdown-link-hover-bg: #f5f5f5;
-
-//** Active dropdown menu item text color.
-@dropdown-link-active-color: @component-active-color;
-//** Active dropdown menu item background color.
-@dropdown-link-active-bg: @component-active-bg;
-
-//** Disabled dropdown menu item background color.
-@dropdown-link-disabled-color: @gray-light;
-
-//** Text color for headers within dropdown menus.
-@dropdown-header-color: @gray-light;
-
-//** Deprecated `@dropdown-caret-color` as of v3.1.0
-@dropdown-caret-color: #000;
-
-
-//-- Z-index master list
-//
-// Warning: Avoid customizing these values. They're used for a bird's eye view
-// of components dependent on the z-axis and are designed to all work together.
-//
-// Note: These variables are not generated into the Customizer.
-
-@zindex-navbar: 1000;
-@zindex-dropdown: 1000;
-@zindex-popover: 1060;
-@zindex-tooltip: 1070;
-@zindex-navbar-fixed: 1030;
-@zindex-modal: 1040;
-
-
-//== Media queries breakpoints
-//
-//## Define the breakpoints at which your layout will change, adapting to different screen sizes.
-
-// Extra small screen / phone
-//** Deprecated `@screen-xs` as of v3.0.1
-@screen-xs: 480px;
-//** Deprecated `@screen-xs-min` as of v3.2.0
-@screen-xs-min: @screen-xs;
-//** Deprecated `@screen-phone` as of v3.0.1
-@screen-phone: @screen-xs-min;
-
-// Small screen / tablet
-//** Deprecated `@screen-sm` as of v3.0.1
-@screen-sm: 768px;
-@screen-sm-min: @screen-sm;
-//** Deprecated `@screen-tablet` as of v3.0.1
-@screen-tablet: @screen-sm-min;
-
-// Medium screen / desktop
-//** Deprecated `@screen-md` as of v3.0.1
-@screen-md: 992px;
-@screen-md-min: @screen-md;
-//** Deprecated `@screen-desktop` as of v3.0.1
-@screen-desktop: @screen-md-min;
-
-// Large screen / wide desktop
-//** Deprecated `@screen-lg` as of v3.0.1
-@screen-lg: 1200px;
-@screen-lg-min: @screen-lg;
-//** Deprecated `@screen-lg-desktop` as of v3.0.1
-@screen-lg-desktop: @screen-lg-min;
-
-// So media queries don't overlap when required, provide a maximum
-@screen-xs-max: (@screen-sm-min - 1);
-@screen-sm-max: (@screen-md-min - 1);
-@screen-md-max: (@screen-lg-min - 1);
-
-
-//== Grid system
-//
-//## Define your custom responsive grid.
-
-//** Number of columns in the grid.
-@grid-columns: 12;
-//** Padding between columns. Gets divided in half for the left and right.
-@grid-gutter-width: 30px;
-// Navbar collapse
-//** Point at which the navbar becomes uncollapsed.
-@grid-float-breakpoint: @screen-sm-min;
-//** Point at which the navbar begins collapsing.
-@grid-float-breakpoint-max: (@grid-float-breakpoint - 1);
-
-
-//== Container sizes
-//
-//## Define the maximum width of `.container` for different screen sizes.
-
-// Small screen / tablet
-@container-tablet: (720px + @grid-gutter-width);
-//** For `@screen-sm-min` and up.
-@container-sm: @container-tablet;
-
-// Medium screen / desktop
-@container-desktop: (940px + @grid-gutter-width);
-//** For `@screen-md-min` and up.
-@container-md: @container-desktop;
-
-// Large screen / wide desktop
-@container-large-desktop: (1140px + @grid-gutter-width);
-//** For `@screen-lg-min` and up.
-@container-lg: @container-large-desktop;
-
-
-//== Navbar
-//
-//##
-
-// Basics of a navbar
-@navbar-height: 100px;
-@navbar-margin-bottom: 0;
-@navbar-border-radius: @border-radius-base;
-@navbar-padding-horizontal: 0;
-@navbar-padding-vertical: ((@navbar-height - @line-height-computed) / 2);
-@navbar-collapse-max-height: 340px;
-
-@navbar-default-color: @gray-base;
-@navbar-default-bg: #f0db4f;
-@navbar-default-border: #f0db4f;
-
-// Navbar links
-@navbar-default-link-color: @navbar-default-color;
-@navbar-default-link-hover-color: @gray-dark;
-@navbar-default-link-hover-bg: transparent;
-@navbar-default-link-active-color: @navbar-default-color;
-@navbar-default-link-active-bg: transparent;
-@navbar-default-link-disabled-color: #ccc;
-@navbar-default-link-disabled-bg: transparent;
-
-// Navbar brand label
-@navbar-default-brand-color: @navbar-default-link-color;
-@navbar-default-brand-hover-color: darken(@navbar-default-brand-color, 10%);
-@navbar-default-brand-hover-bg: transparent;
-
-// Navbar toggle
-@navbar-default-toggle-hover-bg: #ddd;
-@navbar-default-toggle-icon-bar-bg: @gray-dark;
-@navbar-default-toggle-border-color: #ddd;
-
-
-// Inverted navbar
-// Reset inverted navbar basics
-@navbar-inverse-color: lighten(@gray-light, 15%);
-@navbar-inverse-bg: #222;
-@navbar-inverse-border: darken(@navbar-inverse-bg, 10%);
-
-// Inverted navbar links
-@navbar-inverse-link-color: lighten(@gray-light, 15%);
-@navbar-inverse-link-hover-color: #fff;
-@navbar-inverse-link-hover-bg: transparent;
-@navbar-inverse-link-active-color: @navbar-inverse-link-hover-color;
-@navbar-inverse-link-active-bg: darken(@navbar-inverse-bg, 10%);
-@navbar-inverse-link-disabled-color: #444;
-@navbar-inverse-link-disabled-bg: transparent;
-
-// Inverted navbar brand label
-@navbar-inverse-brand-color: @navbar-inverse-link-color;
-@navbar-inverse-brand-hover-color: #fff;
-@navbar-inverse-brand-hover-bg: transparent;
-
-// Inverted navbar toggle
-@navbar-inverse-toggle-hover-bg: #333;
-@navbar-inverse-toggle-icon-bar-bg: #fff;
-@navbar-inverse-toggle-border-color: #333;
-
-
-//== Navs
-//
-//##
-
-//=== Shared nav styles
-@nav-link-padding: 10px 15px;
-@nav-link-hover-bg: @gray-lighter;
-
-@nav-disabled-link-color: @gray-light;
-@nav-disabled-link-hover-color: @gray-light;
-
-//== Tabs
-@nav-tabs-border-color: #ddd;
-
-@nav-tabs-link-hover-border-color: @gray-lighter;
-
-@nav-tabs-active-link-hover-bg: @body-bg;
-@nav-tabs-active-link-hover-color: @gray;
-@nav-tabs-active-link-hover-border-color: #ddd;
-
-@nav-tabs-justified-link-border-color: #ddd;
-@nav-tabs-justified-active-link-border-color: @body-bg;
-
-//== Pills
-@nav-pills-border-radius: @border-radius-base;
-@nav-pills-active-link-hover-bg: @component-active-bg;
-@nav-pills-active-link-hover-color: @component-active-color;
-
-
-//== Pagination
-//
-//##
-
-@pagination-color: @link-color;
-@pagination-bg: #fff;
-@pagination-border: #ddd;
-
-@pagination-hover-color: @link-hover-color;
-@pagination-hover-bg: @gray-lighter;
-@pagination-hover-border: #ddd;
-
-@pagination-active-color: #fff;
-@pagination-active-bg: @brand-primary;
-@pagination-active-border: @brand-primary;
-
-@pagination-disabled-color: @gray-light;
-@pagination-disabled-bg: #fff;
-@pagination-disabled-border: #ddd;
-
-
-//== Pager
-//
-//##
-
-@pager-bg: @pagination-bg;
-@pager-border: @pagination-border;
-@pager-border-radius: 15px;
-
-@pager-hover-bg: @pagination-hover-bg;
-
-@pager-active-bg: @pagination-active-bg;
-@pager-active-color: @pagination-active-color;
-
-@pager-disabled-color: @pagination-disabled-color;
-
-
-//== Jumbotron
-//
-//##
-
-@jumbotron-padding: 30px;
-@jumbotron-color: inherit;
-@jumbotron-bg: @gray-lighter;
-@jumbotron-heading-color: inherit;
-@jumbotron-font-size: ceil((@font-size-base * 1.5));
-
-
-//== Form states and alerts
-//
-//## Define colors for form feedback states and, by default, alerts.
-
-@state-success-text: #3c763d;
-@state-success-bg: #dff0d8;
-@state-success-border: darken(spin(@state-success-bg, -10), 5%);
-
-@state-info-text: #31708f;
-@state-info-bg: #d9edf7;
-@state-info-border: darken(spin(@state-info-bg, -10), 7%);
-
-@state-warning-text: #8a6d3b;
-@state-warning-bg: #fcf8e3;
-@state-warning-border: darken(spin(@state-warning-bg, -10), 5%);
-
-@state-danger-text: #a94442;
-@state-danger-bg: #f2dede;
-@state-danger-border: darken(spin(@state-danger-bg, -10), 5%);
-
-
-//== Tooltips
-//
-//##
-
-//** Tooltip max width
-@tooltip-max-width: 200px;
-//** Tooltip text color
-@tooltip-color: #fff;
-//** Tooltip background color
-@tooltip-bg: #000;
-@tooltip-opacity: .9;
-
-//** Tooltip arrow width
-@tooltip-arrow-width: 5px;
-//** Tooltip arrow color
-@tooltip-arrow-color: @tooltip-bg;
-
-
-//== Popovers
-//
-//##
-
-//** Popover body background color
-@popover-bg: #fff;
-//** Popover maximum width
-@popover-max-width: 276px;
-//** Popover border color
-@popover-border-color: rgba(0,0,0,.2);
-//** Popover fallback border color
-@popover-fallback-border-color: #ccc;
-
-//** Popover title background color
-@popover-title-bg: darken(@popover-bg, 3%);
-
-//** Popover arrow width
-@popover-arrow-width: 10px;
-//** Popover arrow color
-@popover-arrow-color: @popover-bg;
-
-//** Popover outer arrow width
-@popover-arrow-outer-width: (@popover-arrow-width + 1);
-//** Popover outer arrow color
-@popover-arrow-outer-color: fadein(@popover-border-color, 5%);
-//** Popover outer arrow fallback color
-@popover-arrow-outer-fallback-color: darken(@popover-fallback-border-color, 20%);
-
-
-//== Labels
-//
-//##
-
-//** Default label background color
-@label-default-bg: @gray-light;
-//** Primary label background color
-@label-primary-bg: @brand-primary;
-//** Success label background color
-@label-success-bg: @brand-success;
-//** Info label background color
-@label-info-bg: @brand-info;
-//** Warning label background color
-@label-warning-bg: @brand-warning;
-//** Danger label background color
-@label-danger-bg: @brand-danger;
-
-//** Default label text color
-@label-color: #fff;
-//** Default text color of a linked label
-@label-link-hover-color: #fff;
-
-
-//== Modals
-//
-//##
-
-//** Padding applied to the modal body
-@modal-inner-padding: 15px;
-
-//** Padding applied to the modal title
-@modal-title-padding: 15px;
-//** Modal title line-height
-@modal-title-line-height: @line-height-base;
-
-//** Background color of modal content area
-@modal-content-bg: #fff;
-//** Modal content border color
-@modal-content-border-color: rgba(0,0,0,.2);
-//** Modal content border color **for IE8**
-@modal-content-fallback-border-color: #999;
-
-//** Modal backdrop background color
-@modal-backdrop-bg: #000;
-//** Modal backdrop opacity
-@modal-backdrop-opacity: .5;
-//** Modal header border color
-@modal-header-border-color: #e5e5e5;
-//** Modal footer border color
-@modal-footer-border-color: @modal-header-border-color;
-
-@modal-lg: 900px;
-@modal-md: 600px;
-@modal-sm: 300px;
-
-
-//== Alerts
-//
-//## Define alert colors, border radius, and padding.
-
-@alert-padding: 15px;
-@alert-border-radius: @border-radius-base;
-@alert-link-font-weight: bold;
-
-@alert-success-bg: @state-success-bg;
-@alert-success-text: @state-success-text;
-@alert-success-border: @state-success-border;
-
-@alert-info-bg: @state-info-bg;
-@alert-info-text: @state-info-text;
-@alert-info-border: @state-info-border;
-
-@alert-warning-bg: @state-warning-bg;
-@alert-warning-text: @state-warning-text;
-@alert-warning-border: @state-warning-border;
-
-@alert-danger-bg: @state-danger-bg;
-@alert-danger-text: @state-danger-text;
-@alert-danger-border: @state-danger-border;
-
-
-//== Progress bars
-//
-//##
-
-//** Background color of the whole progress component
-@progress-bg: #f5f5f5;
-//** Progress bar text color
-@progress-bar-color: #fff;
-//** Variable for setting rounded corners on progress bar.
-@progress-border-radius: @border-radius-base;
-
-//** Default progress bar color
-@progress-bar-bg: @brand-primary;
-//** Success progress bar color
-@progress-bar-success-bg: @brand-success;
-//** Warning progress bar color
-@progress-bar-warning-bg: @brand-warning;
-//** Danger progress bar color
-@progress-bar-danger-bg: @brand-danger;
-//** Info progress bar color
-@progress-bar-info-bg: @brand-info;
-
-
-//== List group
-//
-//##
-
-//** Background color on `.list-group-item`
-@list-group-bg: #fff;
-//** `.list-group-item` border color
-@list-group-border: #ddd;
-//** List group border radius
-@list-group-border-radius: @border-radius-base;
-
-//** Background color of single list items on hover
-@list-group-hover-bg: #f5f5f5;
-//** Text color of active list items
-@list-group-active-color: @component-active-color;
-//** Background color of active list items
-@list-group-active-bg: @component-active-bg;
-//** Border color of active list elements
-@list-group-active-border: @list-group-active-bg;
-//** Text color for content within active list items
-@list-group-active-text-color: lighten(@list-group-active-bg, 40%);
-
-//** Text color of disabled list items
-@list-group-disabled-color: @gray-light;
-//** Background color of disabled list items
-@list-group-disabled-bg: @gray-lighter;
-//** Text color for content within disabled list items
-@list-group-disabled-text-color: @list-group-disabled-color;
-
-@list-group-link-color: #555;
-@list-group-link-hover-color: @list-group-link-color;
-@list-group-link-heading-color: #333;
-
-
-//== Panels
-//
-//##
-
-@panel-bg: #fff;
-@panel-body-padding: 15px;
-@panel-heading-padding: 10px 15px;
-@panel-footer-padding: @panel-heading-padding;
-@panel-border-radius: @border-radius-base;
-
-//** Border color for elements within panels
-@panel-inner-border: #ddd;
-@panel-footer-bg: #f5f5f5;
-
-@panel-default-text: @gray-dark;
-@panel-default-border: #ddd;
-@panel-default-heading-bg: #f5f5f5;
-
-@panel-primary-text: #fff;
-@panel-primary-border: @brand-primary;
-@panel-primary-heading-bg: @brand-primary;
-
-@panel-success-text: @state-success-text;
-@panel-success-border: @state-success-border;
-@panel-success-heading-bg: @state-success-bg;
-
-@panel-info-text: @state-info-text;
-@panel-info-border: @state-info-border;
-@panel-info-heading-bg: @state-info-bg;
-
-@panel-warning-text: @state-warning-text;
-@panel-warning-border: @state-warning-border;
-@panel-warning-heading-bg: @state-warning-bg;
-
-@panel-danger-text: @state-danger-text;
-@panel-danger-border: @state-danger-border;
-@panel-danger-heading-bg: @state-danger-bg;
-
-
-//== Thumbnails
-//
-//##
-
-//** Padding around the thumbnail image
-@thumbnail-padding: 4px;
-//** Thumbnail background color
-@thumbnail-bg: @body-bg;
-//** Thumbnail border color
-@thumbnail-border: #ddd;
-//** Thumbnail border radius
-@thumbnail-border-radius: @border-radius-base;
-
-//** Custom text color for thumbnail captions
-@thumbnail-caption-color: @text-color;
-//** Padding around the thumbnail caption
-@thumbnail-caption-padding: 9px;
-
-
-//== Wells
-//
-//##
-
-@well-bg: #f5f5f5;
-@well-border: darken(@well-bg, 7%);
-
-
-//== Badges
-//
-//##
-
-@badge-color: #fff;
-//** Linked badge text color on hover
-@badge-link-hover-color: #fff;
-@badge-bg: @gray-light;
-
-//** Badge text color in active nav link
-@badge-active-color: @link-color;
-//** Badge background color in active nav link
-@badge-active-bg: #fff;
-
-@badge-font-weight: bold;
-@badge-line-height: 1;
-@badge-border-radius: 10px;
-
-
-//== Breadcrumbs
-//
-//##
-
-@breadcrumb-padding-vertical: 8px;
-@breadcrumb-padding-horizontal: 15px;
-//** Breadcrumb background color
-@breadcrumb-bg: #f5f5f5;
-//** Breadcrumb text color
-@breadcrumb-color: #ccc;
-//** Text color of current page in the breadcrumb
-@breadcrumb-active-color: @gray-light;
-//** Textual separator for between breadcrumb elements
-@breadcrumb-separator: "/";
-
-
-//== Carousel
-//
-//##
-
-@carousel-text-shadow: 0 1px 2px rgba(0,0,0,.6);
-
-@carousel-control-color: #fff;
-@carousel-control-width: 15%;
-@carousel-control-opacity: .5;
-@carousel-control-font-size: 20px;
-
-@carousel-indicator-active-bg: #fff;
-@carousel-indicator-border-color: #fff;
-
-@carousel-caption-color: #fff;
-
-
-//== Close
-//
-//##
-
-@close-font-weight: bold;
-@close-color: #000;
-@close-text-shadow: 0 1px 0 #fff;
-
-
-//== Code
-//
-//##
-
-@code-color: #c7254e;
-@code-bg: #f9f2f4;
-
-@kbd-color: #fff;
-@kbd-bg: #333;
-
-@pre-bg: #f5f5f5;
-@pre-color: @gray-dark;
-@pre-border-color: #ccc;
-@pre-scrollable-max-height: 340px;
-
-
-//== Type
-//
-//##
-
-//** Horizontal offset for forms and lists.
-@component-offset-horizontal: 180px;
-//** Text muted color
-@text-muted: @gray-light;
-//** Abbreviations and acronyms border color
-@abbr-border-color: @gray-light;
-//** Headings small color
-@headings-small-color: @gray-light;
-//** Blockquote small color
-@blockquote-small-color: @gray-light;
-//** Blockquote font size
-@blockquote-font-size: (@font-size-base * 1.25);
-//** Blockquote border color
-@blockquote-border-color: @gray-lighter;
-//** Page header border color
-@page-header-border-color: @gray-lighter;
-//** Width of horizontal description list titles
-@dl-horizontal-offset: @component-offset-horizontal;
-//** Horizontal line color.
-@hr-border: #b2b2b2;
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/wwwroot/styles/buttons.less b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/wwwroot/styles/buttons.less
deleted file mode 100644
index bbb3c620..00000000
--- a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/wwwroot/styles/buttons.less
+++ /dev/null
@@ -1,61 +0,0 @@
-//
-// Buttons
-// --------------------------------------------------
-
-
-// Base styles
-// --------------------------------------------------
-
-// Core styles
-.btn {
- display: inline-block;
- padding: 5px 6px 4px 8px;
- margin-top: 0;
- margin-bottom: 0; // For input.btn
- font-family: "Open Sans Condensed", sans-serif;
- font-size: @font-size-base * 1.3;
- font-weight: 700;
- text-transform: uppercase;
- letter-spacing: 1px;
- line-height: @line-height-computed;
- text-align: center;
- vertical-align: middle;
- touch-action: manipulation;
- cursor: pointer;
- background-color: @gray-lighter;
- background-image: none; // Reset unusual Firefox-on-Android default style; see https://github.com/necolas/normalize.css/issues/214
- border: none;
- border-radius: 3px;
- .box-shadow(1px 1px 0 rgba(0, 0, 0, 0.3));
- outline: none !important;
- white-space: nowrap;
- .user-select(none);
-
- &:focus,
- &.focus {
- .tab-focus();
- }
-
- &:hover,
- &:focus,
- &.focus {
- background-color: lighten(@gray-lighter, 5%);
- text-decoration: none;
- .transition(background-color .1s linear);
- }
-
- &:active,
- &.active {
- outline: 0;
- padding: 6px 5px 3px 9px;
- }
-
- &.disabled,
- &[disabled],
- fieldset[disabled] & {
- cursor: @cursor-disabled;
- pointer-events: none; // Future-proof disabling of clicks
- .opacity(65);
- .box-shadow(1px 1px 0 rgba(0, 0, 0, 0.15));
- }
-}
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/wwwroot/styles/code.less b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/wwwroot/styles/code.less
deleted file mode 100644
index 33af7555..00000000
--- a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/wwwroot/styles/code.less
+++ /dev/null
@@ -1,8 +0,0 @@
-code {
- margin: 0 2px;
- padding: 1px 5px;
- border: 1px solid #E1E1E8;
- background-color: #F7F7F9;
- color: @gray-dark;
- font-size: 85%;
-}
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/wwwroot/styles/evaluation-form.less b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/wwwroot/styles/evaluation-form.less
deleted file mode 100644
index 6d505d56..00000000
--- a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/wwwroot/styles/evaluation-form.less
+++ /dev/null
@@ -1,91 +0,0 @@
-//
-// Evaluation form
-// --------------------------------------------------
-
-
-.evaluation-form {
- .clearfix();
-
- textarea {
- height: 200px;
- }
-}
-
-.evaluation-input-output {
- float: left;
- width: 65%;
-}
-
-.evaluation-input-clear-button {
- position: absolute;
- top: 0;
- right: 0;
- width: 15px;
- height: 15px;
- margin: 6px;
- display: inline-block;
- background: transparent url("../images/clear-text.png") no-repeat scroll 0 0;
- opacity: 0.75;
- line-height: 0;
- vertical-align: bottom;
- cursor: pointer;
-
- &:hover {
- opacity: 1;
- }
-}
-
-.evaluation-input-clear-button.with-scrollbar {
- margin-right: 29px;
-}
-
-.evaluation-output {
- margin-top: 1.5em;
-}
-
-.evaluation-input-field,
-.evaluation-output-field {
- margin-bottom: 0.5em;
- .box-sizing(border-box);
- overflow-x: hidden;
- line-height: @line-height-computed;
-}
-
-.evaluation-output-field {
- &[readonly] {
- cursor: auto;
- background-color: @input-bg;
- }
-}
-
-.evaluation-error-header {
- margin-bottom: @line-height-computed;
- padding-left: 52px;
- background: transparent url("../images/icons/48x48/error.png") no-repeat scroll 0 50%;
- color: @black;
- font-family: @font-family-sans-serif;
- font-weight: bold;
- line-height: 48px;
- vertical-align: middle;
-}
-
-ul.evaluation-error-list,
-ul.evaluation-warning-list {
- li {
- margin-bottom: 1em;
-
- pre {
- margin-top: 0.5em;
- white-space: pre;
- overflow: auto;
- }
- }
-}
-
-ul.evaluation-error-list li pre {
- background-color: @state-danger-bg;
-}
-
-ul.evaluation-warning-list li pre {
- background-color: @state-warning-bg;
-}
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/wwwroot/styles/forms.less b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/wwwroot/styles/forms.less
deleted file mode 100644
index 2ceb0559..00000000
--- a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/wwwroot/styles/forms.less
+++ /dev/null
@@ -1,99 +0,0 @@
-//
-// Forms
-// --------------------------------------------------
-
-// GENERAL STYLES
-// --------------
-
-label {
- font-weight: normal;
-}
-
-
-// Form controls
-// -------------------------
-
-// Common form controls
-.form-control {
- line-height: @input-height-base;
-}
-
-.textarea-wrapper {
- position: relative;
-}
-
-// Form groups
-.form-group {
- margin-bottom: 0.5em;
-}
-
-// Info and errors
-// --------------------------
-.message-info {
- border: 1px solid;
- clear: both;
- padding: 10px 20px;
- color: @state-info-text;
-}
-
-.message-error {
- clear: both;
- color: @state-danger-text;
- font-size: 1.1em;
- font-weight: bold;
- margin: 20px 0 10px 0;
-}
-
-.message-success {
- color: @state-success-text;
- font-size: 1.3em;
- font-weight: bold;
- margin: 20px 0 10px 0;
-}
-
-.error {
- color: @state-danger-text;
-}
-
-// Styles for validation helpers
-// --------------------------
-.validators {
- font-style: normal;
- padding-bottom: 0.5em;
-}
-
-.field-validation-error {
- display: block;
- padding-bottom: 0.5em;
- color: @state-danger-text;
- font-weight: bold;
-}
-
-.field-validation-valid {
- display: none;
-}
-
-input.input-validation-error,
-textarea.input-validation-error,
-select.input-validation-error
-{
- border: 1px solid @state-danger-border;
- background-color: @state-danger-bg;
- .box-shadow(inset 0 1px 1px rgba(0,0,0,.075)); // Redeclare so transitions work
-
- &:focus {
- border-color: @state-danger-border;
- @shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 6px lighten(@state-danger-text, 20%);
- .box-shadow(@shadow);
- }
-}
-
-.validation-summary-errors {
- color: @state-danger-text;
- font-weight: bold;
- font-size: 1.1em;
-}
-
-.validation-summary-valid {
- display: none;
-}
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/wwwroot/styles/icons.less b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/wwwroot/styles/icons.less
deleted file mode 100644
index afc6c7c7..00000000
--- a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/wwwroot/styles/icons.less
+++ /dev/null
@@ -1,36 +0,0 @@
-//
-// Icons
-// --------------------------------------------------
-
-
-.icon {
- background: transparent url(../images/icons/32x32/social-media-icons-32.png) no-repeat scroll;
- display: inline-block;
- line-height: 0;
- vertical-align: bottom;
-}
-
-.icon-32 {
- height: 32px;
- width: 32px;
-}
-
-.icon-facebook {
- background-position: 0 0;
-}
-
-.icon-twitter {
- background-position: 0 -32px;
-}
-
-.icon-linkedin {
- background-position: 0 -64px;
-}
-
-.icon-google-plus {
- background-position: 0 -96px;
-}
-
-.icon-rss {
- background-position: 0 -128px;
-}
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/wwwroot/styles/layout.less b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/wwwroot/styles/layout.less
deleted file mode 100644
index 35a7f386..00000000
--- a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/wwwroot/styles/layout.less
+++ /dev/null
@@ -1,128 +0,0 @@
-html,
-body {
- margin: 0;
- height: 100%;
- /* The html and body elements cannot have any padding or margin */
-}
-
-/* Wrapper for page content to push down footer */
-.l-wrapper {
- min-height: 100%;
- height: auto !important;
- height: 100%;
- /* Negative indent footer by it's height */
- margin: 0 auto (-1 * @footer-height);
-}
-
-.l-constrained {
- margin: 0 auto;
- padding-left: 20px;
- padding-right: 20px;
- max-width: 1200px;
- min-width: 800px;
-}
-
-.l-header {
- border-top: solid 10px @black;
- border-bottom: 1px solid #d4b33a;
- background-color: #f0db4f;
-
- .l-constrained {
- padding-top: 20px;
- padding-bottom: 20px;
- .clearfix();
- }
-}
-
-.l-content {
- .clearfix();
-}
-
-.l-main-content {
- float: left;
- width: 70%;
-}
-
-.l-sidebar {
- float: right;
- width: 30%;
-}
-
-/* Set the fixed height of the footer here */
-.l-push,
-.l-footer {
- height: @footer-height;
-}
-
-.l-footer {
- width: 100%;
- background-color: @black;
- color: @gray-lighter;
- font-size: @font-size-small;
- line-height: 100%;
-
- .l-constrained {
- padding-top: (@footer-height - 32) / 2;
- .clearfix();
- }
-
- a {
- color: @gray-lighter;
- text-decoration: none;
-
- &:hover,
- &:active {
- text-decoration: underline;
- }
- }
-}
-
-
-// Header
-// -------------------------
-
-.logo {
- margin: 0;
-
- a {
- display: block;
- float: left;
- width: 100px;
- height: 100px;
- background: transparent url("../images/jsengineswitcher-logo.png") no-repeat scroll 0 0;
- text-indent: -9999em;
- }
-}
-
-.primary-nav {
- position: relative;
- left: 40px;
- float: left;
-}
-
-
-// Footer
-// -------------------------
-
-.l-copyright {
- float: left;
- p {
- margin: 0;
- padding: 0;
- }
-}
-
-.l-social {
- float: right;
-
- li {
- display: inline;
- list-style: none outside none;
- padding-left: 10px;
-
- a {
- text-indent: -9999px;
- outline: none;
- }
- }
-}
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/wwwroot/styles/mixins.less b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/wwwroot/styles/mixins.less
deleted file mode 100644
index d26eee79..00000000
--- a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/wwwroot/styles/mixins.less
+++ /dev/null
@@ -1,9 +0,0 @@
-//
-// Mixins
-// --------------------------------------------------
-
-// NO Drop shadows
-.no-box-shadow {
- -webkit-box-shadow: none; // iOS <4.3 & Android <4.1
- box-shadow: none;
-}
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/wwwroot/styles/navbar.less b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/wwwroot/styles/navbar.less
deleted file mode 100644
index 95edf3c2..00000000
--- a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/wwwroot/styles/navbar.less
+++ /dev/null
@@ -1,38 +0,0 @@
-//
-// Navbars
-// --------------------------------------------------
-
-
-// Wrapper and base class
-//
-// Provide a static navbar from which we expand to create full-width, fixed, and
-// other navbar variations.
-
-.navbar {
- border: none;
- border-radius: 0;
-}
-
-// Navbar nav links
-//
-// Builds on top of the `.nav` components with it's own modifier class to make
-// the nav the full height of the horizontal nav (above 768px).
-
-.navbar-nav {
- float: left;
- margin: 0 auto;
-
- > li {
- > a {
- float: none;
- // Vertically center the text given @navbar-height
- padding: ((@navbar-height - @line-height-computed) / 2) 15px ((@navbar-height - @line-height-computed) / 2);
- border: 1px solid transparent;
- font-family: "Open Sans", sans-serif;
- font-size: 2.0em;
- text-decoration: none;
- text-transform: uppercase;
- outline: none;
- }
- }
-}
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/wwwroot/styles/page-socials.less b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/wwwroot/styles/page-socials.less
deleted file mode 100644
index ea12dc09..00000000
--- a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/wwwroot/styles/page-socials.less
+++ /dev/null
@@ -1,14 +0,0 @@
-.page-socials {
- min-height: 60px;
- margin-top: 20px;
- padding-top: 15px;
- border-top: 1px solid #b2b2b2;
-}
-
-.share-buttons {
- li {
- margin-right: 15px;
- vertical-align: top;
- line-height: normal;
- }
-}
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/wwwroot/styles/type.less b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/wwwroot/styles/type.less
deleted file mode 100644
index 02d69502..00000000
--- a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/wwwroot/styles/type.less
+++ /dev/null
@@ -1,24 +0,0 @@
-//
-// Typography
-// --------------------------------------------------
-
-// Headings
-// -------------------------
-
-h1, h2, h3 {
- margin-top: 10px;
-}
-
-h1, h2 {
- line-height: 40px;
-}
-
-h2 {
- color: @black;
- font-weight: bold;
-}
-
-h3 {
- color: @gray-dark;
- line-height: @line-height-computed * 1.25;
-}
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/wwwroot/styles/variables.less b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/wwwroot/styles/variables.less
deleted file mode 100644
index 498c9796..00000000
--- a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/wwwroot/styles/variables.less
+++ /dev/null
@@ -1,7 +0,0 @@
-// Colors
-// -------------------------
-@black: #1d0d0d;
-
-// Footer
-// -------------------------
-@footer-height: 55px;
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/Controllers/HomeController.cs b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore21.Mvc21/Controllers/HomeController.cs
similarity index 83%
rename from samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/Controllers/HomeController.cs
rename to samples/JavaScriptEngineSwitcher.Sample.AspNetCore21.Mvc21/Controllers/HomeController.cs
index 22a5c93e..6ed67b43 100644
--- a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/Controllers/HomeController.cs
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore21.Mvc21/Controllers/HomeController.cs
@@ -1,14 +1,16 @@
-using System.Threading.Tasks;
+using System.Diagnostics;
+using System.Threading.Tasks;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Html;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
+using JavaScriptEngineSwitcher.Sample.AspNetCore21.Mvc21.Models;
using JavaScriptEngineSwitcher.Sample.Logic.Models;
using JavaScriptEngineSwitcher.Sample.Logic.Services;
-namespace JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2.Controllers
+namespace JavaScriptEngineSwitcher.Sample.AspNetCore21.Mvc21.Controllers
{
public class HomeController : Controller
{
@@ -72,9 +74,10 @@ public IActionResult Contact()
return View();
}
+ [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public IActionResult Error()
{
- return View();
+ return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
}
}
}
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore21.Mvc21/JavaScriptEngineSwitcher.Sample.AspNetCore21.Mvc21.csproj b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore21.Mvc21/JavaScriptEngineSwitcher.Sample.AspNetCore21.Mvc21.csproj
new file mode 100644
index 00000000..14fe1a2b
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore21.Mvc21/JavaScriptEngineSwitcher.Sample.AspNetCore21.Mvc21.csproj
@@ -0,0 +1,40 @@
+
+
+
+ JS Engine Switcher: Sample ASP.NET Core 2.1 MVC 2.1 Site
+ 3.30.4
+ netcoreapp2.1
+ Exe
+ true
+ $(NoWarn);NU1902;NU1903;NU1904
+ true
+ true
+ true
+ false
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore21.Mvc21/Models/ErrorViewModel.cs b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore21.Mvc21/Models/ErrorViewModel.cs
new file mode 100644
index 00000000..9149c488
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore21.Mvc21/Models/ErrorViewModel.cs
@@ -0,0 +1,11 @@
+using System;
+
+namespace JavaScriptEngineSwitcher.Sample.AspNetCore21.Mvc21.Models
+{
+ public class ErrorViewModel
+ {
+ public string RequestId { get; set; }
+
+ public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
+ }
+}
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore21.Mvc21/Program.cs b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore21.Mvc21/Program.cs
new file mode 100644
index 00000000..3dcfa5fc
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore21.Mvc21/Program.cs
@@ -0,0 +1,24 @@
+using System.IO;
+
+using Microsoft.AspNetCore;
+using Microsoft.AspNetCore.Hosting;
+
+namespace JavaScriptEngineSwitcher.Sample.AspNetCore21.Mvc21
+{
+ public class Program
+ {
+ public static void Main(string[] args)
+ {
+ CreateWebHostBuilder(args).Build().Run();
+ }
+
+ public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
+ WebHost.CreateDefaultBuilder(args)
+ .UseWebRoot(Path.Combine(
+ Directory.GetCurrentDirectory(),
+ "../JavaScriptEngineSwitcher.Sample.AspNetCore.ClientSideAssets/wwwroot"
+ ))
+ .UseStartup()
+ ;
+ }
+}
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore21.Mvc21/Properties/launchSettings.json b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore21.Mvc21/Properties/launchSettings.json
new file mode 100644
index 00000000..def3944c
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore21.Mvc21/Properties/launchSettings.json
@@ -0,0 +1,27 @@
+{
+ "iisSettings": {
+ "windowsAuthentication": false,
+ "anonymousAuthentication": true,
+ "iisExpress": {
+ "applicationUrl": "http://localhost:1972/",
+ "sslPort": 0
+ }
+ },
+ "profiles": {
+ "JavaScriptEngineSwitcher.Sample.AspNetCore21.Mvc21": {
+ "commandName": "Project",
+ "launchBrowser": true,
+ "environmentVariables": {
+ "ASPNETCORE_ENVIRONMENT": "Development"
+ },
+ "applicationUrl": "http://localhost:1973/"
+ },
+ "IIS Express": {
+ "commandName": "IISExpress",
+ "launchBrowser": true,
+ "environmentVariables": {
+ "ASPNETCORE_ENVIRONMENT": "Development"
+ }
+ }
+ }
+}
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/Startup.cs b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore21.Mvc21/Startup.cs
similarity index 83%
rename from samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/Startup.cs
rename to samples/JavaScriptEngineSwitcher.Sample.AspNetCore21.Mvc21/Startup.cs
index 989602f1..5a5b6be7 100644
--- a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/Startup.cs
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore21.Mvc21/Startup.cs
@@ -1,5 +1,6 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
+using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
@@ -10,11 +11,10 @@
using JavaScriptEngineSwitcher.Jint;
using JavaScriptEngineSwitcher.Jurassic;
using JavaScriptEngineSwitcher.Msie;
-using JavaScriptEngineSwitcher.NiL;
using JavaScriptEngineSwitcher.Sample.Logic.Services;
using JavaScriptEngineSwitcher.Vroom;
-namespace JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2
+namespace JavaScriptEngineSwitcher.Sample.AspNetCore21.Mvc21
{
public class Startup
{
@@ -54,8 +54,10 @@ public void ConfigureServices(IServiceCollection services)
// Add JavaScriptEngineSwitcher services to the services container.
services.AddJsEngineSwitcher(options =>
- options.DefaultEngineName = ChakraCoreJsEngine.EngineName
- )
+ {
+ options.AllowCurrentProperty = false;
+ options.DefaultEngineName = ChakraCoreJsEngine.EngineName;
+ })
.AddChakraCore()
.AddJint()
.AddJurassic()
@@ -63,10 +65,16 @@ public void ConfigureServices(IServiceCollection services)
{
options.EngineMode = JsEngineMode.ChakraIeJsRt;
})
- .AddNiL()
.AddVroom()
;
+ services.Configure(options =>
+ {
+ // This lambda determines whether user consent for non-essential cookies is needed for a given request.
+ options.CheckConsentNeeded = context => true;
+ options.MinimumSameSitePolicy = SameSiteMode.None;
+ });
+
// Add framework services.
services.AddMvc(options =>
{
@@ -79,7 +87,7 @@ public void ConfigureServices(IServiceCollection services)
VaryByHeader = "Accept-Encoding"
}
);
- });
+ }).SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
// Add JavaScriptEngineSwitcher sample services to the services container.
services.AddSingleton();
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore21.Mvc21/Views/Home/Contact.cshtml b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore21.Mvc21/Views/Home/Contact.cshtml
new file mode 100644
index 00000000..58785ebe
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore21.Mvc21/Views/Home/Contact.cshtml
@@ -0,0 +1,8 @@
+@{
+ ViewBag.Title = "Contact";
+}
+
+
+ @ViewBag.Title
+ @ViewBag.Body
+
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore21.Mvc21/Views/Home/Demo.cshtml b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore21.Mvc21/Views/Home/Demo.cshtml
new file mode 100644
index 00000000..befb8f43
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore21.Mvc21/Views/Home/Demo.cshtml
@@ -0,0 +1,67 @@
+@using JavaScriptEngineSwitcher.Sample.Logic.Models
+@using JavaScriptEngineSwitcher.Sample.Resources
+
+@model JsEvaluationViewModel
+
+@{
+ ViewBag.Title = "Demo";
+}
+
+@ViewBag.Title
+
+
+
+@section Scripts {
+
+
+
+
+
+
+
+
+
+}
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore21.Mvc21/Views/Home/Index.cshtml b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore21.Mvc21/Views/Home/Index.cshtml
new file mode 100644
index 00000000..a9c2cfb1
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore21.Mvc21/Views/Home/Index.cshtml
@@ -0,0 +1,8 @@
+@{
+ ViewBag.Title = string.Empty;
+}
+
+
+ Project Description
+ @ViewBag.Body
+
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/Views/Shared/Error.cshtml b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore21.Mvc21/Views/Shared/Error.cshtml
similarity index 77%
rename from samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/Views/Shared/Error.cshtml
rename to samples/JavaScriptEngineSwitcher.Sample.AspNetCore21.Mvc21/Views/Shared/Error.cshtml
index d7f29efe..1010fafb 100644
--- a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/Views/Shared/Error.cshtml
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore21.Mvc21/Views/Shared/Error.cshtml
@@ -1,10 +1,21 @@
-@{
+@using JavaScriptEngineSwitcher.Sample.AspNetCore21.Mvc21.Models
+
+@model ErrorViewModel
+
+@{
ViewData["Title"] = "Error";
}
Error.
An error occurred while processing your request.
+@if (Model.ShowRequestId)
+{
+
+ Request ID: @Model.RequestId
+
+}
+
Development Mode
Swapping to Development environment will display more detailed information about the error that occurred.
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore21.Mvc21/Views/Shared/_JsEvaluationErrorList.cshtml b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore21.Mvc21/Views/Shared/_JsEvaluationErrorList.cshtml
new file mode 100644
index 00000000..9e0601d6
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore21.Mvc21/Views/Shared/_JsEvaluationErrorList.cshtml
@@ -0,0 +1,23 @@
+@using JavaScriptEngineSwitcher.Sample.AspNetCore.Infrastructure.Helpers
+@using JavaScriptEngineSwitcher.Sample.Logic.Models
+
+@model IList
+
+Found @Model.Count error(s):
+
+ @foreach (var error in Model)
+ {
+ -
+ @error.EngineFullName
+ @if (error.LineNumber > 0)
+ {
+ Line @error.LineNumber, Column @error.ColumnNumber
+ }
+ @Html.EncodedReplace(@error.Message, "\n\r?", "
")
+ @if (!string.IsNullOrWhiteSpace(error.SourceFragment))
+ {
+ @error.SourceFragment
+ }
+
+ }
+
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/Views/Shared/_Layout.cshtml b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore21.Mvc21/Views/Shared/_Layout.cshtml
similarity index 85%
rename from samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/Views/Shared/_Layout.cshtml
rename to samples/JavaScriptEngineSwitcher.Sample.AspNetCore21.Mvc21/Views/Shared/_Layout.cshtml
index eee73e69..93808b86 100644
--- a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2/Views/Shared/_Layout.cshtml
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore21.Mvc21/Views/Shared/_Layout.cshtml
@@ -1,4 +1,4 @@
-@using JavaScriptEngineSwitcher.Sample.AspNetCore2.Mvc2.Infrastructure.TagHelpers
+@using JavaScriptEngineSwitcher.Sample.AspNetCore.Infrastructure.TagHelpers
@@ -7,7 +7,7 @@
- @if (!string.IsNullOrEmpty(ViewBag.Title)) {@ViewBag.Title | }JavaScriptEngineSwitcher Sample ASP.NET Core 2.0 MVC 2 Site
+ @if (!string.IsNullOrEmpty(ViewBag.Title)) {@ViewBag.Title | }JavaScriptEngineSwitcher Sample ASP.NET Core 2.1 MVC 2.1 Site
@@ -61,10 +61,10 @@
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore21.Mvc21/Views/_ViewImports.cshtml b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore21.Mvc21/Views/_ViewImports.cshtml
new file mode 100644
index 00000000..8fe8384e
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore21.Mvc21/Views/_ViewImports.cshtml
@@ -0,0 +1,2 @@
+@addTagHelper "*, Microsoft.AspNetCore.Mvc.TagHelpers"
+@addTagHelper "*, JavaScriptEngineSwitcher.Sample.AspNetCore.Infrastructure"
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore21.Mvc21/Views/_ViewStart.cshtml b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore21.Mvc21/Views/_ViewStart.cshtml
new file mode 100644
index 00000000..817a9134
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore21.Mvc21/Views/_ViewStart.cshtml
@@ -0,0 +1,3 @@
+@{
+ Layout = "_Layout";
+}
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore21.Mvc21/appsettings.Development.json b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore21.Mvc21/appsettings.Development.json
new file mode 100644
index 00000000..fa8ce71a
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore21.Mvc21/appsettings.Development.json
@@ -0,0 +1,10 @@
+{
+ "Logging": {
+ "IncludeScopes": false,
+ "LogLevel": {
+ "Default": "Debug",
+ "System": "Information",
+ "Microsoft": "Information"
+ }
+ }
+}
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore21.Mvc21/appsettings.json b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore21.Mvc21/appsettings.json
new file mode 100644
index 00000000..7124dec4
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore21.Mvc21/appsettings.json
@@ -0,0 +1,16 @@
+{
+ "Logging": {
+ "IncludeScopes": false,
+ "LogLevel": {
+ "Default": "Debug",
+ "System": "Information",
+ "Microsoft": "Information"
+ }
+ },
+
+ "JsEngineSwitcher": {
+ "Samples": {
+ "TextContentDirectoryPath": "../SharedData/text-content"
+ }
+ }
+}
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore31.Mvc31/Controllers/HomeController.cs b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore31.Mvc31/Controllers/HomeController.cs
new file mode 100644
index 00000000..5922c698
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore31.Mvc31/Controllers/HomeController.cs
@@ -0,0 +1,83 @@
+using System.Diagnostics;
+using System.Threading.Tasks;
+
+using Microsoft.AspNetCore.Hosting;
+using Microsoft.AspNetCore.Html;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.Extensions.Configuration;
+
+using JavaScriptEngineSwitcher.Sample.AspNetCore31.Mvc31.Models;
+using JavaScriptEngineSwitcher.Sample.Logic.Models;
+using JavaScriptEngineSwitcher.Sample.Logic.Services;
+
+namespace JavaScriptEngineSwitcher.Sample.AspNetCore31.Mvc31.Controllers
+{
+ public class HomeController : Controller
+ {
+ private readonly FileContentService _fileContentService;
+ private readonly JsEvaluationService _jsEvaluationService;
+
+
+ public HomeController(
+ IConfigurationRoot configuration,
+ IWebHostEnvironment hostingEnvironment,
+ JsEvaluationService jsEvaluationService)
+ {
+ string textContentDirectoryPath = configuration
+ .GetSection("jsengineswitcher")
+ .GetSection("Samples")["TextContentDirectoryPath"]
+ ;
+
+ _fileContentService = new FileContentService(textContentDirectoryPath, hostingEnvironment);
+ _jsEvaluationService = jsEvaluationService;
+ }
+
+
+ [ResponseCache(CacheProfileName = "CacheCompressedContent5Minutes")]
+ public IActionResult Index()
+ {
+ ViewBag.Body = new HtmlString(_fileContentService.GetFileContent("index.html"));
+
+ return View();
+ }
+
+ [HttpGet]
+ [ResponseCache(CacheProfileName = "CacheCompressedContent5Minutes")]
+ public IActionResult Demo()
+ {
+ var model = _jsEvaluationService.GetInitializationData();
+
+ return View(model);
+ }
+
+ [HttpPost]
+ public async Task Demo(JsEvaluationViewModel editedModel)
+ {
+ var model = _jsEvaluationService.GetInitializationData();
+ await TryUpdateModelAsync(model, string.Empty, m => m.EngineName, m=> m.Expression);
+
+ if (ModelState.IsValid)
+ {
+ model = _jsEvaluationService.Evaluate(model);
+
+ ModelState.Clear();
+ }
+
+ return View(model);
+ }
+
+ [ResponseCache(CacheProfileName = "CacheCompressedContent5Minutes")]
+ public IActionResult Contact()
+ {
+ ViewBag.Body = new HtmlString(_fileContentService.GetFileContent("contact.html"));
+
+ return View();
+ }
+
+ [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
+ public IActionResult Error()
+ {
+ return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
+ }
+ }
+}
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore31.Mvc31/JavaScriptEngineSwitcher.Sample.AspNetCore31.Mvc31.csproj b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore31.Mvc31/JavaScriptEngineSwitcher.Sample.AspNetCore31.Mvc31.csproj
new file mode 100644
index 00000000..e9971df3
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore31.Mvc31/JavaScriptEngineSwitcher.Sample.AspNetCore31.Mvc31.csproj
@@ -0,0 +1,50 @@
+
+
+
+ JS Engine Switcher: Sample ASP.NET Core 3.1 MVC 3.1 Site
+ 3.30.4
+ netcoreapp3.1
+ Exe
+ true
+ true
+ true
+ true
+ false
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore31.Mvc31/Models/ErrorViewModel.cs b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore31.Mvc31/Models/ErrorViewModel.cs
new file mode 100644
index 00000000..c2adb306
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore31.Mvc31/Models/ErrorViewModel.cs
@@ -0,0 +1,11 @@
+using System;
+
+namespace JavaScriptEngineSwitcher.Sample.AspNetCore31.Mvc31.Models
+{
+ public class ErrorViewModel
+ {
+ public string RequestId { get; set; }
+
+ public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
+ }
+}
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore31.Mvc31/Program.cs b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore31.Mvc31/Program.cs
new file mode 100644
index 00000000..889d2a4b
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore31.Mvc31/Program.cs
@@ -0,0 +1,34 @@
+using System.IO;
+
+using Microsoft.AspNetCore.Hosting;
+using Microsoft.Extensions.Hosting;
+using Microsoft.Extensions.Logging;
+
+namespace JavaScriptEngineSwitcher.Sample.AspNetCore31.Mvc31
+{
+ public class Program
+ {
+ public static void Main(string[] args)
+ {
+ CreateHostBuilder(args).Build().Run();
+ }
+
+ public static IHostBuilder CreateHostBuilder(string[] args) =>
+ Host.CreateDefaultBuilder(args)
+ .ConfigureWebHostDefaults(webBuilder =>
+ {
+ webBuilder.UseWebRoot(Path.Combine(
+ Directory.GetCurrentDirectory(),
+ "../JavaScriptEngineSwitcher.Sample.AspNetCore.ClientSideAssets/wwwroot"
+ ));
+ webBuilder.UseStartup();
+ })
+ .ConfigureLogging((hostingContext, logging) =>
+ {
+ logging.AddConfiguration(hostingContext.Configuration.GetSection("Logging"));
+ logging.AddConsole();
+ logging.AddDebug();
+ })
+ ;
+ }
+}
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore31.Mvc31/Properties/launchSettings.json b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore31.Mvc31/Properties/launchSettings.json
new file mode 100644
index 00000000..1b7533c8
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore31.Mvc31/Properties/launchSettings.json
@@ -0,0 +1,28 @@
+{
+ "iisSettings": {
+ "windowsAuthentication": false,
+ "anonymousAuthentication": true,
+ "iisExpress": {
+ "applicationUrl": "http://localhost:55126",
+ "sslPort": 0
+ }
+ },
+ "profiles": {
+ "JavaScriptEngineSwitcher.Sample.AspNetCore31.Mvc31": {
+ "commandName": "Project",
+ "dotnetRunMessages": "true",
+ "launchBrowser": true,
+ "applicationUrl": "http://localhost:5138",
+ "environmentVariables": {
+ "ASPNETCORE_ENVIRONMENT": "Development"
+ }
+ },
+ "IIS Express": {
+ "commandName": "IISExpress",
+ "launchBrowser": true,
+ "environmentVariables": {
+ "ASPNETCORE_ENVIRONMENT": "Development"
+ }
+ }
+ }
+}
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore31.Mvc31/Startup.cs b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore31.Mvc31/Startup.cs
new file mode 100644
index 00000000..b90eb827
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore31.Mvc31/Startup.cs
@@ -0,0 +1,126 @@
+using Jering.Javascript.NodeJS;
+using Microsoft.AspNetCore.Builder;
+using Microsoft.AspNetCore.Hosting;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Hosting;
+
+using JavaScriptEngineSwitcher.ChakraCore;
+using JavaScriptEngineSwitcher.Extensions.MsDependencyInjection;
+using JavaScriptEngineSwitcher.Jint;
+using JavaScriptEngineSwitcher.Jurassic;
+using JavaScriptEngineSwitcher.Msie;
+using JavaScriptEngineSwitcher.NiL;
+using JavaScriptEngineSwitcher.Node;
+using JavaScriptEngineSwitcher.Sample.Logic.Services;
+using JavaScriptEngineSwitcher.V8;
+using JavaScriptEngineSwitcher.Vroom;
+using JavaScriptEngineSwitcher.Yantra;
+
+namespace JavaScriptEngineSwitcher.Sample.AspNetCore31.Mvc31
+{
+ public class Startup
+ {
+ ///
+ /// Gets or sets a instance of hosting environment
+ ///
+ public IWebHostEnvironment HostingEnvironment
+ {
+ get;
+ set;
+ }
+
+ public IConfigurationRoot Configuration
+ {
+ get;
+ set;
+ }
+
+
+ public Startup(IWebHostEnvironment env)
+ {
+ HostingEnvironment = env;
+
+ var builder = new ConfigurationBuilder()
+ .SetBasePath(env.ContentRootPath)
+ .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
+ .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
+ .AddEnvironmentVariables();
+ Configuration = builder.Build();
+ }
+
+
+ // This method gets called by the runtime. Use this method to add services to the container.
+ public void ConfigureServices(IServiceCollection services)
+ {
+ services.AddSingleton(Configuration);
+
+ // Add Jering Node.js service to the services container.
+ services.AddNodeJS();
+
+ // Add JavaScriptEngineSwitcher services to the services container.
+ services.AddJsEngineSwitcher(options =>
+ {
+ options.AllowCurrentProperty = false;
+ options.DefaultEngineName = ChakraCoreJsEngine.EngineName;
+ })
+ .AddChakraCore()
+ .AddJint()
+ .AddJurassic()
+ .AddMsie(options =>
+ {
+ options.EngineMode = JsEngineMode.ChakraIeJsRt;
+ })
+ .AddNiL()
+ .AddNode(services)
+ .AddV8()
+ .AddVroom()
+ .AddYantra()
+ ;
+
+ services.Configure(options =>
+ {
+ options.CacheProfiles.Add("CacheCompressedContent5Minutes",
+ new CacheProfile
+ {
+ NoStore = HostingEnvironment.IsDevelopment(),
+ Duration = 300,
+ Location = ResponseCacheLocation.Client,
+ VaryByHeader = "Accept-Encoding"
+ }
+ );
+ });
+
+ // Add framework services.
+ services.AddControllersWithViews();
+
+ // Add JavaScriptEngineSwitcher sample services to the services container.
+ services.AddSingleton();
+ }
+
+ // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
+ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
+ {
+ if (env.IsDevelopment())
+ {
+ app.UseDeveloperExceptionPage();
+ }
+ else
+ {
+ app.UseExceptionHandler("/Home/Error");
+ }
+
+ app.UseStaticFiles();
+
+ app.UseRouting();
+
+ app.UseEndpoints(endpoints =>
+ {
+ endpoints.MapControllerRoute(
+ name: "default",
+ pattern: "{controller=Home}/{action=Index}/{id?}");
+ });
+ }
+ }
+}
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore31.Mvc31/Views/Home/Contact.cshtml b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore31.Mvc31/Views/Home/Contact.cshtml
new file mode 100644
index 00000000..58785ebe
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore31.Mvc31/Views/Home/Contact.cshtml
@@ -0,0 +1,8 @@
+@{
+ ViewBag.Title = "Contact";
+}
+
+
+ @ViewBag.Title
+ @ViewBag.Body
+
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore31.Mvc31/Views/Home/Demo.cshtml b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore31.Mvc31/Views/Home/Demo.cshtml
new file mode 100644
index 00000000..befb8f43
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore31.Mvc31/Views/Home/Demo.cshtml
@@ -0,0 +1,67 @@
+@using JavaScriptEngineSwitcher.Sample.Logic.Models
+@using JavaScriptEngineSwitcher.Sample.Resources
+
+@model JsEvaluationViewModel
+
+@{
+ ViewBag.Title = "Demo";
+}
+
+@ViewBag.Title
+
+
+
+@section Scripts {
+
+
+
+
+
+
+
+
+
+}
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore31.Mvc31/Views/Home/Index.cshtml b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore31.Mvc31/Views/Home/Index.cshtml
new file mode 100644
index 00000000..a9c2cfb1
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore31.Mvc31/Views/Home/Index.cshtml
@@ -0,0 +1,8 @@
+@{
+ ViewBag.Title = string.Empty;
+}
+
+
+ Project Description
+ @ViewBag.Body
+
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore31.Mvc31/Views/Shared/Error.cshtml b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore31.Mvc31/Views/Shared/Error.cshtml
new file mode 100644
index 00000000..4442769d
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore31.Mvc31/Views/Shared/Error.cshtml
@@ -0,0 +1,28 @@
+@using JavaScriptEngineSwitcher.Sample.AspNetCore31.Mvc31.Models
+
+@model ErrorViewModel
+
+@{
+ ViewData["Title"] = "Error";
+}
+
+Error.
+An error occurred while processing your request.
+
+@if (Model.ShowRequestId)
+{
+
+ Request ID: @Model.RequestId
+
+}
+
+Development Mode
+
+ Swapping to Development environment will display more detailed information about the error that occurred.
+
+
+ The Development environment shouldn't be enabled for deployed applications.
+ It can result in displaying sensitive information from exceptions to end users.
+ For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development
+ and restarting the app.
+
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore31.Mvc31/Views/Shared/_JsEvaluationErrorList.cshtml b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore31.Mvc31/Views/Shared/_JsEvaluationErrorList.cshtml
new file mode 100644
index 00000000..9e0601d6
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore31.Mvc31/Views/Shared/_JsEvaluationErrorList.cshtml
@@ -0,0 +1,23 @@
+@using JavaScriptEngineSwitcher.Sample.AspNetCore.Infrastructure.Helpers
+@using JavaScriptEngineSwitcher.Sample.Logic.Models
+
+@model IList
+
+Found @Model.Count error(s):
+
+ @foreach (var error in Model)
+ {
+ -
+ @error.EngineFullName
+ @if (error.LineNumber > 0)
+ {
+ Line @error.LineNumber, Column @error.ColumnNumber
+ }
+ @Html.EncodedReplace(@error.Message, "\n\r?", "
")
+ @if (!string.IsNullOrWhiteSpace(error.SourceFragment))
+ {
+ @error.SourceFragment
+ }
+
+ }
+
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore31.Mvc31/Views/Shared/_Layout.cshtml b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore31.Mvc31/Views/Shared/_Layout.cshtml
new file mode 100644
index 00000000..e9ffc46f
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore31.Mvc31/Views/Shared/_Layout.cshtml
@@ -0,0 +1,107 @@
+@using JavaScriptEngineSwitcher.Sample.AspNetCore.Infrastructure.TagHelpers
+
+
+
+
+
+
+
+
+ @if (!string.IsNullOrEmpty(ViewBag.Title)) {@ViewBag.Title | }JavaScriptEngineSwitcher Sample ASP.NET Core 3.1 MVC 3.1 Site
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ JavaScript Engine Switcher
+
+
+
+
+
+
+
+
+
+
+
+ @RenderBody()
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ @RenderSection("scripts", required: false)
+
+
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore31.Mvc31/Views/_ViewImports.cshtml b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore31.Mvc31/Views/_ViewImports.cshtml
new file mode 100644
index 00000000..8fe8384e
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore31.Mvc31/Views/_ViewImports.cshtml
@@ -0,0 +1,2 @@
+@addTagHelper "*, Microsoft.AspNetCore.Mvc.TagHelpers"
+@addTagHelper "*, JavaScriptEngineSwitcher.Sample.AspNetCore.Infrastructure"
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore31.Mvc31/Views/_ViewStart.cshtml b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore31.Mvc31/Views/_ViewStart.cshtml
new file mode 100644
index 00000000..817a9134
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore31.Mvc31/Views/_ViewStart.cshtml
@@ -0,0 +1,3 @@
+@{
+ Layout = "_Layout";
+}
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore31.Mvc31/appsettings.Development.json b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore31.Mvc31/appsettings.Development.json
new file mode 100644
index 00000000..b10423ed
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore31.Mvc31/appsettings.Development.json
@@ -0,0 +1,10 @@
+{
+ "Logging": {
+ "IncludeScopes": false,
+ "LogLevel": {
+ "Default": "Information",
+ "Microsoft": "Warning",
+ "Microsoft.Hosting.Lifetime": "Information"
+ }
+ }
+}
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore31.Mvc31/appsettings.json b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore31.Mvc31/appsettings.json
new file mode 100644
index 00000000..81f55403
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore31.Mvc31/appsettings.json
@@ -0,0 +1,17 @@
+{
+ "Logging": {
+ "IncludeScopes": false,
+ "LogLevel": {
+ "Default": "Information",
+ "Microsoft": "Warning",
+ "Microsoft.Hosting.Lifetime": "Information"
+ }
+ },
+ "AllowedHosts": "*",
+
+ "JsEngineSwitcher": {
+ "Samples": {
+ "TextContentDirectoryPath": "../SharedData/text-content"
+ }
+ }
+}
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore5.Mvc5/Controllers/HomeController.cs b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore5.Mvc5/Controllers/HomeController.cs
new file mode 100644
index 00000000..30777c5d
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore5.Mvc5/Controllers/HomeController.cs
@@ -0,0 +1,83 @@
+using System.Diagnostics;
+using System.Threading.Tasks;
+
+using Microsoft.AspNetCore.Hosting;
+using Microsoft.AspNetCore.Html;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.Extensions.Configuration;
+
+using JavaScriptEngineSwitcher.Sample.AspNetCore5.Mvc5.Models;
+using JavaScriptEngineSwitcher.Sample.Logic.Models;
+using JavaScriptEngineSwitcher.Sample.Logic.Services;
+
+namespace JavaScriptEngineSwitcher.Sample.AspNetCore5.Mvc5.Controllers
+{
+ public class HomeController : Controller
+ {
+ private readonly FileContentService _fileContentService;
+ private readonly JsEvaluationService _jsEvaluationService;
+
+
+ public HomeController(
+ IConfigurationRoot configuration,
+ IWebHostEnvironment hostingEnvironment,
+ JsEvaluationService jsEvaluationService)
+ {
+ string textContentDirectoryPath = configuration
+ .GetSection("jsengineswitcher")
+ .GetSection("Samples")["TextContentDirectoryPath"]
+ ;
+
+ _fileContentService = new FileContentService(textContentDirectoryPath, hostingEnvironment);
+ _jsEvaluationService = jsEvaluationService;
+ }
+
+
+ [ResponseCache(CacheProfileName = "CacheCompressedContent5Minutes")]
+ public IActionResult Index()
+ {
+ ViewBag.Body = new HtmlString(_fileContentService.GetFileContent("index.html"));
+
+ return View();
+ }
+
+ [HttpGet]
+ [ResponseCache(CacheProfileName = "CacheCompressedContent5Minutes")]
+ public IActionResult Demo()
+ {
+ var model = _jsEvaluationService.GetInitializationData();
+
+ return View(model);
+ }
+
+ [HttpPost]
+ public async Task Demo(JsEvaluationViewModel editedModel)
+ {
+ var model = _jsEvaluationService.GetInitializationData();
+ await TryUpdateModelAsync(model, string.Empty, m => m.EngineName, m=> m.Expression);
+
+ if (ModelState.IsValid)
+ {
+ model = _jsEvaluationService.Evaluate(model);
+
+ ModelState.Clear();
+ }
+
+ return View(model);
+ }
+
+ [ResponseCache(CacheProfileName = "CacheCompressedContent5Minutes")]
+ public IActionResult Contact()
+ {
+ ViewBag.Body = new HtmlString(_fileContentService.GetFileContent("contact.html"));
+
+ return View();
+ }
+
+ [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
+ public IActionResult Error()
+ {
+ return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
+ }
+ }
+}
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore5.Mvc5/JavaScriptEngineSwitcher.Sample.AspNetCore5.Mvc5.csproj b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore5.Mvc5/JavaScriptEngineSwitcher.Sample.AspNetCore5.Mvc5.csproj
new file mode 100644
index 00000000..b81b1aab
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore5.Mvc5/JavaScriptEngineSwitcher.Sample.AspNetCore5.Mvc5.csproj
@@ -0,0 +1,50 @@
+
+
+
+ JS Engine Switcher: Sample ASP.NET Core 5.0 MVC 5 Site
+ 3.30.4
+ net5.0
+ Exe
+ true
+ true
+ true
+ true
+ false
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore5.Mvc5/Models/ErrorViewModel.cs b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore5.Mvc5/Models/ErrorViewModel.cs
new file mode 100644
index 00000000..81e5e7ae
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore5.Mvc5/Models/ErrorViewModel.cs
@@ -0,0 +1,11 @@
+using System;
+
+namespace JavaScriptEngineSwitcher.Sample.AspNetCore5.Mvc5.Models
+{
+ public class ErrorViewModel
+ {
+ public string RequestId { get; set; }
+
+ public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
+ }
+}
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore5.Mvc5/Program.cs b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore5.Mvc5/Program.cs
new file mode 100644
index 00000000..376442fc
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore5.Mvc5/Program.cs
@@ -0,0 +1,34 @@
+using System.IO;
+
+using Microsoft.AspNetCore.Hosting;
+using Microsoft.Extensions.Hosting;
+using Microsoft.Extensions.Logging;
+
+namespace JavaScriptEngineSwitcher.Sample.AspNetCore5.Mvc5
+{
+ public class Program
+ {
+ public static void Main(string[] args)
+ {
+ CreateHostBuilder(args).Build().Run();
+ }
+
+ public static IHostBuilder CreateHostBuilder(string[] args) =>
+ Host.CreateDefaultBuilder(args)
+ .ConfigureWebHostDefaults(webBuilder =>
+ {
+ webBuilder.UseWebRoot(Path.Combine(
+ Directory.GetCurrentDirectory(),
+ "../JavaScriptEngineSwitcher.Sample.AspNetCore.ClientSideAssets/wwwroot"
+ ));
+ webBuilder.UseStartup();
+ })
+ .ConfigureLogging((hostingContext, logging) =>
+ {
+ logging.AddConfiguration(hostingContext.Configuration.GetSection("Logging"));
+ logging.AddConsole();
+ logging.AddDebug();
+ })
+ ;
+ }
+}
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore5.Mvc5/Properties/launchSettings.json b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore5.Mvc5/Properties/launchSettings.json
new file mode 100644
index 00000000..7b2ce114
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore5.Mvc5/Properties/launchSettings.json
@@ -0,0 +1,28 @@
+{
+ "iisSettings": {
+ "windowsAuthentication": false,
+ "anonymousAuthentication": true,
+ "iisExpress": {
+ "applicationUrl": "http://localhost:19282",
+ "sslPort": 0
+ }
+ },
+ "profiles": {
+ "JavaScriptEngineSwitcher.Sample.AspNetCore5.Mvc5": {
+ "commandName": "Project",
+ "dotnetRunMessages": "true",
+ "launchBrowser": true,
+ "applicationUrl": "http://localhost:5121",
+ "environmentVariables": {
+ "ASPNETCORE_ENVIRONMENT": "Development"
+ }
+ },
+ "IIS Express": {
+ "commandName": "IISExpress",
+ "launchBrowser": true,
+ "environmentVariables": {
+ "ASPNETCORE_ENVIRONMENT": "Development"
+ }
+ }
+ }
+}
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore5.Mvc5/Startup.cs b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore5.Mvc5/Startup.cs
new file mode 100644
index 00000000..2ef8be36
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore5.Mvc5/Startup.cs
@@ -0,0 +1,126 @@
+using Jering.Javascript.NodeJS;
+using Microsoft.AspNetCore.Builder;
+using Microsoft.AspNetCore.Hosting;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Hosting;
+
+using JavaScriptEngineSwitcher.ChakraCore;
+using JavaScriptEngineSwitcher.Extensions.MsDependencyInjection;
+using JavaScriptEngineSwitcher.Jint;
+using JavaScriptEngineSwitcher.Jurassic;
+using JavaScriptEngineSwitcher.Msie;
+using JavaScriptEngineSwitcher.NiL;
+using JavaScriptEngineSwitcher.Node;
+using JavaScriptEngineSwitcher.Sample.Logic.Services;
+using JavaScriptEngineSwitcher.V8;
+using JavaScriptEngineSwitcher.Vroom;
+using JavaScriptEngineSwitcher.Yantra;
+
+namespace JavaScriptEngineSwitcher.Sample.AspNetCore5.Mvc5
+{
+ public class Startup
+ {
+ ///
+ /// Gets or sets a instance of hosting environment
+ ///
+ public IWebHostEnvironment HostingEnvironment
+ {
+ get;
+ set;
+ }
+
+ public IConfigurationRoot Configuration
+ {
+ get;
+ set;
+ }
+
+
+ public Startup(IWebHostEnvironment env)
+ {
+ HostingEnvironment = env;
+
+ var builder = new ConfigurationBuilder()
+ .SetBasePath(env.ContentRootPath)
+ .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
+ .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
+ .AddEnvironmentVariables();
+ Configuration = builder.Build();
+ }
+
+
+ // This method gets called by the runtime. Use this method to add services to the container.
+ public void ConfigureServices(IServiceCollection services)
+ {
+ services.AddSingleton(Configuration);
+
+ // Add Jering Node.js service to the services container.
+ services.AddNodeJS();
+
+ // Add JavaScriptEngineSwitcher services to the services container.
+ services.AddJsEngineSwitcher(options =>
+ {
+ options.AllowCurrentProperty = false;
+ options.DefaultEngineName = ChakraCoreJsEngine.EngineName;
+ })
+ .AddChakraCore()
+ .AddJint()
+ .AddJurassic()
+ .AddMsie(options =>
+ {
+ options.EngineMode = JsEngineMode.ChakraIeJsRt;
+ })
+ .AddNiL()
+ .AddNode(services)
+ .AddV8()
+ .AddVroom()
+ .AddYantra()
+ ;
+
+ services.Configure(options =>
+ {
+ options.CacheProfiles.Add("CacheCompressedContent5Minutes",
+ new CacheProfile
+ {
+ NoStore = HostingEnvironment.IsDevelopment(),
+ Duration = 300,
+ Location = ResponseCacheLocation.Client,
+ VaryByHeader = "Accept-Encoding"
+ }
+ );
+ });
+
+ // Add framework services.
+ services.AddControllersWithViews();
+
+ // Add JavaScriptEngineSwitcher sample services to the services container.
+ services.AddSingleton();
+ }
+
+ // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
+ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
+ {
+ if (env.IsDevelopment())
+ {
+ app.UseDeveloperExceptionPage();
+ }
+ else
+ {
+ app.UseExceptionHandler("/Home/Error");
+ }
+
+ app.UseStaticFiles();
+
+ app.UseRouting();
+
+ app.UseEndpoints(endpoints =>
+ {
+ endpoints.MapControllerRoute(
+ name: "default",
+ pattern: "{controller=Home}/{action=Index}/{id?}");
+ });
+ }
+ }
+}
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore5.Mvc5/Views/Home/Contact.cshtml b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore5.Mvc5/Views/Home/Contact.cshtml
new file mode 100644
index 00000000..58785ebe
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore5.Mvc5/Views/Home/Contact.cshtml
@@ -0,0 +1,8 @@
+@{
+ ViewBag.Title = "Contact";
+}
+
+
+ @ViewBag.Title
+ @ViewBag.Body
+
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore5.Mvc5/Views/Home/Demo.cshtml b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore5.Mvc5/Views/Home/Demo.cshtml
new file mode 100644
index 00000000..befb8f43
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore5.Mvc5/Views/Home/Demo.cshtml
@@ -0,0 +1,67 @@
+@using JavaScriptEngineSwitcher.Sample.Logic.Models
+@using JavaScriptEngineSwitcher.Sample.Resources
+
+@model JsEvaluationViewModel
+
+@{
+ ViewBag.Title = "Demo";
+}
+
+@ViewBag.Title
+
+
+
+@section Scripts {
+
+
+
+
+
+
+
+
+
+}
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore5.Mvc5/Views/Home/Index.cshtml b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore5.Mvc5/Views/Home/Index.cshtml
new file mode 100644
index 00000000..a9c2cfb1
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore5.Mvc5/Views/Home/Index.cshtml
@@ -0,0 +1,8 @@
+@{
+ ViewBag.Title = string.Empty;
+}
+
+
+ Project Description
+ @ViewBag.Body
+
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore5.Mvc5/Views/Shared/Error.cshtml b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore5.Mvc5/Views/Shared/Error.cshtml
new file mode 100644
index 00000000..667a018f
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore5.Mvc5/Views/Shared/Error.cshtml
@@ -0,0 +1,28 @@
+@using JavaScriptEngineSwitcher.Sample.AspNetCore5.Mvc5.Models
+
+@model ErrorViewModel
+
+@{
+ ViewData["Title"] = "Error";
+}
+
+Error.
+An error occurred while processing your request.
+
+@if (Model.ShowRequestId)
+{
+
+ Request ID: @Model.RequestId
+
+}
+
+Development Mode
+
+ Swapping to Development environment will display more detailed information about the error that occurred.
+
+
+ The Development environment shouldn't be enabled for deployed applications.
+ It can result in displaying sensitive information from exceptions to end users.
+ For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development
+ and restarting the app.
+
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore5.Mvc5/Views/Shared/_JsEvaluationErrorList.cshtml b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore5.Mvc5/Views/Shared/_JsEvaluationErrorList.cshtml
new file mode 100644
index 00000000..9e0601d6
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore5.Mvc5/Views/Shared/_JsEvaluationErrorList.cshtml
@@ -0,0 +1,23 @@
+@using JavaScriptEngineSwitcher.Sample.AspNetCore.Infrastructure.Helpers
+@using JavaScriptEngineSwitcher.Sample.Logic.Models
+
+@model IList
+
+Found @Model.Count error(s):
+
+ @foreach (var error in Model)
+ {
+ -
+ @error.EngineFullName
+ @if (error.LineNumber > 0)
+ {
+ Line @error.LineNumber, Column @error.ColumnNumber
+ }
+ @Html.EncodedReplace(@error.Message, "\n\r?", "
")
+ @if (!string.IsNullOrWhiteSpace(error.SourceFragment))
+ {
+ @error.SourceFragment
+ }
+
+ }
+
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore5.Mvc5/Views/Shared/_Layout.cshtml b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore5.Mvc5/Views/Shared/_Layout.cshtml
new file mode 100644
index 00000000..5fe54776
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore5.Mvc5/Views/Shared/_Layout.cshtml
@@ -0,0 +1,107 @@
+@using JavaScriptEngineSwitcher.Sample.AspNetCore.Infrastructure.TagHelpers
+
+
+
+
+
+
+
+
+ @if (!string.IsNullOrEmpty(ViewBag.Title)) {@ViewBag.Title | }JavaScriptEngineSwitcher Sample ASP.NET Core 5.0 MVC 5 Site
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ JavaScript Engine Switcher
+
+
+
+
+
+
+
+
+
+
+
+ @RenderBody()
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ @await RenderSectionAsync("scripts", required: false)
+
+
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore5.Mvc5/Views/_ViewImports.cshtml b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore5.Mvc5/Views/_ViewImports.cshtml
new file mode 100644
index 00000000..8fe8384e
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore5.Mvc5/Views/_ViewImports.cshtml
@@ -0,0 +1,2 @@
+@addTagHelper "*, Microsoft.AspNetCore.Mvc.TagHelpers"
+@addTagHelper "*, JavaScriptEngineSwitcher.Sample.AspNetCore.Infrastructure"
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore5.Mvc5/Views/_ViewStart.cshtml b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore5.Mvc5/Views/_ViewStart.cshtml
new file mode 100644
index 00000000..817a9134
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore5.Mvc5/Views/_ViewStart.cshtml
@@ -0,0 +1,3 @@
+@{
+ Layout = "_Layout";
+}
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore5.Mvc5/appsettings.Development.json b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore5.Mvc5/appsettings.Development.json
new file mode 100644
index 00000000..8983e0fc
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore5.Mvc5/appsettings.Development.json
@@ -0,0 +1,9 @@
+{
+ "Logging": {
+ "LogLevel": {
+ "Default": "Information",
+ "Microsoft": "Warning",
+ "Microsoft.Hosting.Lifetime": "Information"
+ }
+ }
+}
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore5.Mvc5/appsettings.json b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore5.Mvc5/appsettings.json
new file mode 100644
index 00000000..85e9db19
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore5.Mvc5/appsettings.json
@@ -0,0 +1,16 @@
+{
+ "Logging": {
+ "LogLevel": {
+ "Default": "Information",
+ "Microsoft": "Warning",
+ "Microsoft.Hosting.Lifetime": "Information"
+ }
+ },
+ "AllowedHosts": "*",
+
+ "JsEngineSwitcher": {
+ "Samples": {
+ "TextContentDirectoryPath": "../SharedData/text-content"
+ }
+ }
+}
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore6.Mvc6/Controllers/HomeController.cs b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore6.Mvc6/Controllers/HomeController.cs
new file mode 100644
index 00000000..3c8faaeb
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore6.Mvc6/Controllers/HomeController.cs
@@ -0,0 +1,83 @@
+using System.Diagnostics;
+using System.Threading.Tasks;
+
+using Microsoft.AspNetCore.Hosting;
+using Microsoft.AspNetCore.Html;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.Extensions.Configuration;
+
+using JavaScriptEngineSwitcher.Sample.AspNetCore6.Mvc6.Models;
+using JavaScriptEngineSwitcher.Sample.Logic.Models;
+using JavaScriptEngineSwitcher.Sample.Logic.Services;
+
+namespace JavaScriptEngineSwitcher.Sample.AspNetCore6.Mvc6.Controllers
+{
+ public class HomeController : Controller
+ {
+ private readonly FileContentService _fileContentService;
+ private readonly JsEvaluationService _jsEvaluationService;
+
+
+ public HomeController(
+ IConfigurationRoot configuration,
+ IWebHostEnvironment hostingEnvironment,
+ JsEvaluationService jsEvaluationService)
+ {
+ string textContentDirectoryPath = configuration
+ .GetSection("jsengineswitcher")
+ .GetSection("Samples")["TextContentDirectoryPath"]
+ ;
+
+ _fileContentService = new FileContentService(textContentDirectoryPath, hostingEnvironment);
+ _jsEvaluationService = jsEvaluationService;
+ }
+
+
+ [ResponseCache(CacheProfileName = "CacheCompressedContent5Minutes")]
+ public IActionResult Index()
+ {
+ ViewBag.Body = new HtmlString(_fileContentService.GetFileContent("index.html"));
+
+ return View();
+ }
+
+ [HttpGet]
+ [ResponseCache(CacheProfileName = "CacheCompressedContent5Minutes")]
+ public IActionResult Demo()
+ {
+ var model = _jsEvaluationService.GetInitializationData();
+
+ return View(model);
+ }
+
+ [HttpPost]
+ public async Task Demo(JsEvaluationViewModel editedModel)
+ {
+ var model = _jsEvaluationService.GetInitializationData();
+ await TryUpdateModelAsync(model, string.Empty, m => m.EngineName, m=> m.Expression);
+
+ if (ModelState.IsValid)
+ {
+ model = _jsEvaluationService.Evaluate(model);
+
+ ModelState.Clear();
+ }
+
+ return View(model);
+ }
+
+ [ResponseCache(CacheProfileName = "CacheCompressedContent5Minutes")]
+ public IActionResult Contact()
+ {
+ ViewBag.Body = new HtmlString(_fileContentService.GetFileContent("contact.html"));
+
+ return View();
+ }
+
+ [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
+ public IActionResult Error()
+ {
+ return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
+ }
+ }
+}
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore6.Mvc6/JavaScriptEngineSwitcher.Sample.AspNetCore6.Mvc6.csproj b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore6.Mvc6/JavaScriptEngineSwitcher.Sample.AspNetCore6.Mvc6.csproj
new file mode 100644
index 00000000..8b6893eb
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore6.Mvc6/JavaScriptEngineSwitcher.Sample.AspNetCore6.Mvc6.csproj
@@ -0,0 +1,51 @@
+
+
+
+ JS Engine Switcher: Sample ASP.NET Core 6.0 MVC 6 Site
+ 3.30.4
+ net6.0
+ enable
+ Exe
+ true
+ $(NoWarn);NETSDK1138
+ true
+ true
+ true
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore6.Mvc6/Models/ErrorViewModel.cs b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore6.Mvc6/Models/ErrorViewModel.cs
new file mode 100644
index 00000000..8bd1a785
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore6.Mvc6/Models/ErrorViewModel.cs
@@ -0,0 +1,9 @@
+namespace JavaScriptEngineSwitcher.Sample.AspNetCore6.Mvc6.Models
+{
+ public class ErrorViewModel
+ {
+ public string RequestId { get; set; }
+
+ public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
+ }
+}
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore6.Mvc6/Program.cs b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore6.Mvc6/Program.cs
new file mode 100644
index 00000000..2e472860
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore6.Mvc6/Program.cs
@@ -0,0 +1,106 @@
+using Jering.Javascript.NodeJS;
+using Microsoft.AspNetCore.Mvc;
+
+using JavaScriptEngineSwitcher.ChakraCore;
+using JavaScriptEngineSwitcher.Extensions.MsDependencyInjection;
+using JavaScriptEngineSwitcher.Jint;
+using JavaScriptEngineSwitcher.Jurassic;
+using JavaScriptEngineSwitcher.Msie;
+using JavaScriptEngineSwitcher.NiL;
+using JavaScriptEngineSwitcher.Node;
+using JavaScriptEngineSwitcher.Sample.Logic.Services;
+using JavaScriptEngineSwitcher.V8;
+using JavaScriptEngineSwitcher.Vroom;
+using JavaScriptEngineSwitcher.Yantra;
+
+var builder = WebApplication.CreateBuilder(new WebApplicationOptions()
+{
+ WebRootPath = Path.Combine(
+ Directory.GetCurrentDirectory(),
+ "../JavaScriptEngineSwitcher.Sample.AspNetCore.ClientSideAssets/wwwroot"
+ )
+});
+var env = builder.Environment;
+var configuration = new ConfigurationBuilder()
+ .SetBasePath(env.ContentRootPath)
+ .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
+ .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
+ .AddEnvironmentVariables()
+ .Build()
+ ;
+
+#region Configure services
+
+IServiceCollection services = builder.Services;
+
+services.AddSingleton(configuration);
+
+// Add Jering Node.js service to the services container.
+services.AddNodeJS();
+
+// Add JavaScriptEngineSwitcher services to the services container.
+services.AddJsEngineSwitcher(options =>
+{
+ options.AllowCurrentProperty = false;
+ options.DefaultEngineName = ChakraCoreJsEngine.EngineName;
+})
+ .AddChakraCore()
+ .AddJint()
+ .AddJurassic()
+ .AddMsie(options =>
+ {
+ options.EngineMode = JsEngineMode.ChakraIeJsRt;
+ })
+ .AddNiL()
+ .AddNode(services)
+ .AddV8()
+ .AddVroom()
+ .AddYantra()
+ ;
+
+services.Configure(options =>
+{
+ options.CacheProfiles.Add("CacheCompressedContent5Minutes",
+ new CacheProfile
+ {
+ NoStore = builder.Environment.IsDevelopment(),
+ Duration = 300,
+ Location = ResponseCacheLocation.Client,
+ VaryByHeader = "Accept-Encoding"
+ }
+ );
+});
+
+// Add framework services.
+services.AddControllersWithViews();
+
+// Add JavaScriptEngineSwitcher sample services to the services container.
+services.AddSingleton();
+
+#endregion
+
+#region Configure the HTTP request pipeline
+
+var app = builder.Build();
+
+if (app.Environment.IsDevelopment())
+{
+ app.UseDeveloperExceptionPage();
+}
+else
+{
+ app.UseExceptionHandler("/Home/Error");
+}
+
+app.UseStaticFiles();
+
+app.UseRouting();
+
+app.MapControllerRoute(
+ name: "default",
+ pattern: "{controller=Home}/{action=Index}/{id?}"
+);
+
+#endregion
+
+app.Run();
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore6.Mvc6/Properties/launchSettings.json b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore6.Mvc6/Properties/launchSettings.json
new file mode 100644
index 00000000..3410f950
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore6.Mvc6/Properties/launchSettings.json
@@ -0,0 +1,28 @@
+{
+ "iisSettings": {
+ "windowsAuthentication": false,
+ "anonymousAuthentication": true,
+ "iisExpress": {
+ "applicationUrl": "http://localhost:20428",
+ "sslPort": 0
+ }
+ },
+ "profiles": {
+ "JavaScriptEngineSwitcher.Sample.AspNetCore6.Mvc6": {
+ "commandName": "Project",
+ "dotnetRunMessages": true,
+ "launchBrowser": true,
+ "applicationUrl": "http://localhost:5090",
+ "environmentVariables": {
+ "ASPNETCORE_ENVIRONMENT": "Development"
+ }
+ },
+ "IIS Express": {
+ "commandName": "IISExpress",
+ "launchBrowser": true,
+ "environmentVariables": {
+ "ASPNETCORE_ENVIRONMENT": "Development"
+ }
+ }
+ }
+}
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore6.Mvc6/Views/Home/Contact.cshtml b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore6.Mvc6/Views/Home/Contact.cshtml
new file mode 100644
index 00000000..58785ebe
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore6.Mvc6/Views/Home/Contact.cshtml
@@ -0,0 +1,8 @@
+@{
+ ViewBag.Title = "Contact";
+}
+
+
+ @ViewBag.Title
+ @ViewBag.Body
+
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore6.Mvc6/Views/Home/Demo.cshtml b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore6.Mvc6/Views/Home/Demo.cshtml
new file mode 100644
index 00000000..befb8f43
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore6.Mvc6/Views/Home/Demo.cshtml
@@ -0,0 +1,67 @@
+@using JavaScriptEngineSwitcher.Sample.Logic.Models
+@using JavaScriptEngineSwitcher.Sample.Resources
+
+@model JsEvaluationViewModel
+
+@{
+ ViewBag.Title = "Demo";
+}
+
+@ViewBag.Title
+
+
+
+@section Scripts {
+
+
+
+
+
+
+
+
+
+}
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore6.Mvc6/Views/Home/Index.cshtml b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore6.Mvc6/Views/Home/Index.cshtml
new file mode 100644
index 00000000..a9c2cfb1
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore6.Mvc6/Views/Home/Index.cshtml
@@ -0,0 +1,8 @@
+@{
+ ViewBag.Title = string.Empty;
+}
+
+
+ Project Description
+ @ViewBag.Body
+
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore6.Mvc6/Views/Shared/Error.cshtml b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore6.Mvc6/Views/Shared/Error.cshtml
new file mode 100644
index 00000000..4d1b91ca
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore6.Mvc6/Views/Shared/Error.cshtml
@@ -0,0 +1,28 @@
+@using JavaScriptEngineSwitcher.Sample.AspNetCore6.Mvc6.Models
+
+@model ErrorViewModel
+
+@{
+ ViewData["Title"] = "Error";
+}
+
+Error.
+An error occurred while processing your request.
+
+@if (Model?.ShowRequestId ?? false)
+{
+
+ Request ID: @Model?.RequestId
+
+}
+
+Development Mode
+
+ Swapping to Development environment will display more detailed information about the error that occurred.
+
+
+ The Development environment shouldn't be enabled for deployed applications.
+ It can result in displaying sensitive information from exceptions to end users.
+ For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development
+ and restarting the app.
+
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore6.Mvc6/Views/Shared/_JsEvaluationErrorList.cshtml b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore6.Mvc6/Views/Shared/_JsEvaluationErrorList.cshtml
new file mode 100644
index 00000000..9e0601d6
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore6.Mvc6/Views/Shared/_JsEvaluationErrorList.cshtml
@@ -0,0 +1,23 @@
+@using JavaScriptEngineSwitcher.Sample.AspNetCore.Infrastructure.Helpers
+@using JavaScriptEngineSwitcher.Sample.Logic.Models
+
+@model IList
+
+Found @Model.Count error(s):
+
+ @foreach (var error in Model)
+ {
+ -
+ @error.EngineFullName
+ @if (error.LineNumber > 0)
+ {
+ Line @error.LineNumber, Column @error.ColumnNumber
+ }
+ @Html.EncodedReplace(@error.Message, "\n\r?", "
")
+ @if (!string.IsNullOrWhiteSpace(error.SourceFragment))
+ {
+ @error.SourceFragment
+ }
+
+ }
+
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore6.Mvc6/Views/Shared/_Layout.cshtml b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore6.Mvc6/Views/Shared/_Layout.cshtml
new file mode 100644
index 00000000..b1f433fd
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore6.Mvc6/Views/Shared/_Layout.cshtml
@@ -0,0 +1,107 @@
+@using JavaScriptEngineSwitcher.Sample.AspNetCore.Infrastructure.TagHelpers
+
+
+
+
+
+
+
+
+ @if (!string.IsNullOrEmpty(ViewBag.Title)) {@ViewBag.Title | }JavaScriptEngineSwitcher Sample ASP.NET Core 6.0 MVC 6 Site
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ JavaScript Engine Switcher
+
+
+
+
+
+
+
+
+
+
+
+ @RenderBody()
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ @await RenderSectionAsync("scripts", required: false)
+
+
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore6.Mvc6/Views/_ViewImports.cshtml b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore6.Mvc6/Views/_ViewImports.cshtml
new file mode 100644
index 00000000..8fe8384e
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore6.Mvc6/Views/_ViewImports.cshtml
@@ -0,0 +1,2 @@
+@addTagHelper "*, Microsoft.AspNetCore.Mvc.TagHelpers"
+@addTagHelper "*, JavaScriptEngineSwitcher.Sample.AspNetCore.Infrastructure"
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore6.Mvc6/Views/_ViewStart.cshtml b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore6.Mvc6/Views/_ViewStart.cshtml
new file mode 100644
index 00000000..817a9134
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore6.Mvc6/Views/_ViewStart.cshtml
@@ -0,0 +1,3 @@
+@{
+ Layout = "_Layout";
+}
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore6.Mvc6/appsettings.Development.json b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore6.Mvc6/appsettings.Development.json
new file mode 100644
index 00000000..0c208ae9
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore6.Mvc6/appsettings.Development.json
@@ -0,0 +1,8 @@
+{
+ "Logging": {
+ "LogLevel": {
+ "Default": "Information",
+ "Microsoft.AspNetCore": "Warning"
+ }
+ }
+}
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore6.Mvc6/appsettings.json b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore6.Mvc6/appsettings.json
new file mode 100644
index 00000000..ed44b7ae
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore6.Mvc6/appsettings.json
@@ -0,0 +1,15 @@
+{
+ "Logging": {
+ "LogLevel": {
+ "Default": "Information",
+ "Microsoft.AspNetCore": "Warning"
+ }
+ },
+ "AllowedHosts": "*",
+
+ "JsEngineSwitcher": {
+ "Samples": {
+ "TextContentDirectoryPath": "../SharedData/text-content"
+ }
+ }
+}
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore7.Mvc7/Controllers/HomeController.cs b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore7.Mvc7/Controllers/HomeController.cs
new file mode 100644
index 00000000..6f6ed28e
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore7.Mvc7/Controllers/HomeController.cs
@@ -0,0 +1,83 @@
+using System.Diagnostics;
+using System.Threading.Tasks;
+
+using Microsoft.AspNetCore.Hosting;
+using Microsoft.AspNetCore.Html;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.Extensions.Configuration;
+
+using JavaScriptEngineSwitcher.Sample.AspNetCore7.Mvc7.Models;
+using JavaScriptEngineSwitcher.Sample.Logic.Models;
+using JavaScriptEngineSwitcher.Sample.Logic.Services;
+
+namespace JavaScriptEngineSwitcher.Sample.AspNetCore7.Mvc7.Controllers
+{
+ public class HomeController : Controller
+ {
+ private readonly FileContentService _fileContentService;
+ private readonly JsEvaluationService _jsEvaluationService;
+
+
+ public HomeController(
+ IConfigurationRoot configuration,
+ IWebHostEnvironment hostingEnvironment,
+ JsEvaluationService jsEvaluationService)
+ {
+ string textContentDirectoryPath = configuration
+ .GetSection("jsengineswitcher")
+ .GetSection("Samples")["TextContentDirectoryPath"]
+ ;
+
+ _fileContentService = new FileContentService(textContentDirectoryPath, hostingEnvironment);
+ _jsEvaluationService = jsEvaluationService;
+ }
+
+
+ [ResponseCache(CacheProfileName = "CacheCompressedContent5Minutes")]
+ public IActionResult Index()
+ {
+ ViewBag.Body = new HtmlString(_fileContentService.GetFileContent("index.html"));
+
+ return View();
+ }
+
+ [HttpGet]
+ [ResponseCache(CacheProfileName = "CacheCompressedContent5Minutes")]
+ public IActionResult Demo()
+ {
+ var model = _jsEvaluationService.GetInitializationData();
+
+ return View(model);
+ }
+
+ [HttpPost]
+ public async Task Demo(JsEvaluationViewModel editedModel)
+ {
+ var model = _jsEvaluationService.GetInitializationData();
+ await TryUpdateModelAsync(model, string.Empty, m => m.EngineName, m=> m.Expression);
+
+ if (ModelState.IsValid)
+ {
+ model = _jsEvaluationService.Evaluate(model);
+
+ ModelState.Clear();
+ }
+
+ return View(model);
+ }
+
+ [ResponseCache(CacheProfileName = "CacheCompressedContent5Minutes")]
+ public IActionResult Contact()
+ {
+ ViewBag.Body = new HtmlString(_fileContentService.GetFileContent("contact.html"));
+
+ return View();
+ }
+
+ [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
+ public IActionResult Error()
+ {
+ return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
+ }
+ }
+}
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore7.Mvc7/JavaScriptEngineSwitcher.Sample.AspNetCore7.Mvc7.csproj b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore7.Mvc7/JavaScriptEngineSwitcher.Sample.AspNetCore7.Mvc7.csproj
new file mode 100644
index 00000000..3546843c
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore7.Mvc7/JavaScriptEngineSwitcher.Sample.AspNetCore7.Mvc7.csproj
@@ -0,0 +1,51 @@
+
+
+
+ JS Engine Switcher: Sample ASP.NET Core 7.0 MVC 7 Site
+ 3.30.4
+ net7.0
+ enable
+ Exe
+ true
+ true
+ true
+ true
+ false
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore7.Mvc7/Models/ErrorViewModel.cs b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore7.Mvc7/Models/ErrorViewModel.cs
new file mode 100644
index 00000000..cf622ba3
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore7.Mvc7/Models/ErrorViewModel.cs
@@ -0,0 +1,9 @@
+namespace JavaScriptEngineSwitcher.Sample.AspNetCore7.Mvc7.Models
+{
+ public class ErrorViewModel
+ {
+ public string RequestId { get; set; }
+
+ public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
+ }
+}
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore7.Mvc7/Program.cs b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore7.Mvc7/Program.cs
new file mode 100644
index 00000000..2e472860
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore7.Mvc7/Program.cs
@@ -0,0 +1,106 @@
+using Jering.Javascript.NodeJS;
+using Microsoft.AspNetCore.Mvc;
+
+using JavaScriptEngineSwitcher.ChakraCore;
+using JavaScriptEngineSwitcher.Extensions.MsDependencyInjection;
+using JavaScriptEngineSwitcher.Jint;
+using JavaScriptEngineSwitcher.Jurassic;
+using JavaScriptEngineSwitcher.Msie;
+using JavaScriptEngineSwitcher.NiL;
+using JavaScriptEngineSwitcher.Node;
+using JavaScriptEngineSwitcher.Sample.Logic.Services;
+using JavaScriptEngineSwitcher.V8;
+using JavaScriptEngineSwitcher.Vroom;
+using JavaScriptEngineSwitcher.Yantra;
+
+var builder = WebApplication.CreateBuilder(new WebApplicationOptions()
+{
+ WebRootPath = Path.Combine(
+ Directory.GetCurrentDirectory(),
+ "../JavaScriptEngineSwitcher.Sample.AspNetCore.ClientSideAssets/wwwroot"
+ )
+});
+var env = builder.Environment;
+var configuration = new ConfigurationBuilder()
+ .SetBasePath(env.ContentRootPath)
+ .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
+ .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
+ .AddEnvironmentVariables()
+ .Build()
+ ;
+
+#region Configure services
+
+IServiceCollection services = builder.Services;
+
+services.AddSingleton(configuration);
+
+// Add Jering Node.js service to the services container.
+services.AddNodeJS();
+
+// Add JavaScriptEngineSwitcher services to the services container.
+services.AddJsEngineSwitcher(options =>
+{
+ options.AllowCurrentProperty = false;
+ options.DefaultEngineName = ChakraCoreJsEngine.EngineName;
+})
+ .AddChakraCore()
+ .AddJint()
+ .AddJurassic()
+ .AddMsie(options =>
+ {
+ options.EngineMode = JsEngineMode.ChakraIeJsRt;
+ })
+ .AddNiL()
+ .AddNode(services)
+ .AddV8()
+ .AddVroom()
+ .AddYantra()
+ ;
+
+services.Configure(options =>
+{
+ options.CacheProfiles.Add("CacheCompressedContent5Minutes",
+ new CacheProfile
+ {
+ NoStore = builder.Environment.IsDevelopment(),
+ Duration = 300,
+ Location = ResponseCacheLocation.Client,
+ VaryByHeader = "Accept-Encoding"
+ }
+ );
+});
+
+// Add framework services.
+services.AddControllersWithViews();
+
+// Add JavaScriptEngineSwitcher sample services to the services container.
+services.AddSingleton();
+
+#endregion
+
+#region Configure the HTTP request pipeline
+
+var app = builder.Build();
+
+if (app.Environment.IsDevelopment())
+{
+ app.UseDeveloperExceptionPage();
+}
+else
+{
+ app.UseExceptionHandler("/Home/Error");
+}
+
+app.UseStaticFiles();
+
+app.UseRouting();
+
+app.MapControllerRoute(
+ name: "default",
+ pattern: "{controller=Home}/{action=Index}/{id?}"
+);
+
+#endregion
+
+app.Run();
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore7.Mvc7/Properties/launchSettings.json b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore7.Mvc7/Properties/launchSettings.json
new file mode 100644
index 00000000..57ebee9a
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore7.Mvc7/Properties/launchSettings.json
@@ -0,0 +1,28 @@
+{
+ "iisSettings": {
+ "windowsAuthentication": false,
+ "anonymousAuthentication": true,
+ "iisExpress": {
+ "applicationUrl": "http://localhost:32819",
+ "sslPort": 0
+ }
+ },
+ "profiles": {
+ "http": {
+ "commandName": "Project",
+ "dotnetRunMessages": true,
+ "launchBrowser": true,
+ "applicationUrl": "http://localhost:5107",
+ "environmentVariables": {
+ "ASPNETCORE_ENVIRONMENT": "Development"
+ }
+ },
+ "IIS Express": {
+ "commandName": "IISExpress",
+ "launchBrowser": true,
+ "environmentVariables": {
+ "ASPNETCORE_ENVIRONMENT": "Development"
+ }
+ }
+ }
+}
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore7.Mvc7/Views/Home/Contact.cshtml b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore7.Mvc7/Views/Home/Contact.cshtml
new file mode 100644
index 00000000..58785ebe
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore7.Mvc7/Views/Home/Contact.cshtml
@@ -0,0 +1,8 @@
+@{
+ ViewBag.Title = "Contact";
+}
+
+
+ @ViewBag.Title
+ @ViewBag.Body
+
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore7.Mvc7/Views/Home/Demo.cshtml b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore7.Mvc7/Views/Home/Demo.cshtml
new file mode 100644
index 00000000..befb8f43
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore7.Mvc7/Views/Home/Demo.cshtml
@@ -0,0 +1,67 @@
+@using JavaScriptEngineSwitcher.Sample.Logic.Models
+@using JavaScriptEngineSwitcher.Sample.Resources
+
+@model JsEvaluationViewModel
+
+@{
+ ViewBag.Title = "Demo";
+}
+
+@ViewBag.Title
+
+
+
+@section Scripts {
+
+
+
+
+
+
+
+
+
+}
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore7.Mvc7/Views/Home/Index.cshtml b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore7.Mvc7/Views/Home/Index.cshtml
new file mode 100644
index 00000000..a9c2cfb1
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore7.Mvc7/Views/Home/Index.cshtml
@@ -0,0 +1,8 @@
+@{
+ ViewBag.Title = string.Empty;
+}
+
+
+ Project Description
+ @ViewBag.Body
+
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore7.Mvc7/Views/Shared/Error.cshtml b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore7.Mvc7/Views/Shared/Error.cshtml
new file mode 100644
index 00000000..1278d006
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore7.Mvc7/Views/Shared/Error.cshtml
@@ -0,0 +1,28 @@
+@using JavaScriptEngineSwitcher.Sample.AspNetCore7.Mvc7.Models
+
+@model ErrorViewModel
+
+@{
+ ViewData["Title"] = "Error";
+}
+
+Error.
+An error occurred while processing your request.
+
+@if (Model.ShowRequestId)
+{
+
+ Request ID: @Model.RequestId
+
+}
+
+Development Mode
+
+ Swapping to Development environment will display more detailed information about the error that occurred.
+
+
+ The Development environment shouldn't be enabled for deployed applications.
+ It can result in displaying sensitive information from exceptions to end users.
+ For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development
+ and restarting the app.
+
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore7.Mvc7/Views/Shared/_JsEvaluationErrorList.cshtml b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore7.Mvc7/Views/Shared/_JsEvaluationErrorList.cshtml
new file mode 100644
index 00000000..9e0601d6
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore7.Mvc7/Views/Shared/_JsEvaluationErrorList.cshtml
@@ -0,0 +1,23 @@
+@using JavaScriptEngineSwitcher.Sample.AspNetCore.Infrastructure.Helpers
+@using JavaScriptEngineSwitcher.Sample.Logic.Models
+
+@model IList
+
+Found @Model.Count error(s):
+
+ @foreach (var error in Model)
+ {
+ -
+ @error.EngineFullName
+ @if (error.LineNumber > 0)
+ {
+ Line @error.LineNumber, Column @error.ColumnNumber
+ }
+ @Html.EncodedReplace(@error.Message, "\n\r?", "
")
+ @if (!string.IsNullOrWhiteSpace(error.SourceFragment))
+ {
+ @error.SourceFragment
+ }
+
+ }
+
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore7.Mvc7/Views/Shared/_Layout.cshtml b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore7.Mvc7/Views/Shared/_Layout.cshtml
new file mode 100644
index 00000000..fe014242
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore7.Mvc7/Views/Shared/_Layout.cshtml
@@ -0,0 +1,107 @@
+@using JavaScriptEngineSwitcher.Sample.AspNetCore.Infrastructure.TagHelpers
+
+
+
+
+
+
+
+
+ @if (!string.IsNullOrEmpty(ViewBag.Title)) {@ViewBag.Title | }JavaScriptEngineSwitcher Sample ASP.NET Core 7.0 MVC 7 Site
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ JavaScript Engine Switcher
+
+
+
+
+
+
+
+
+
+
+
+ @RenderBody()
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ @await RenderSectionAsync("scripts", required: false)
+
+
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore7.Mvc7/Views/_ViewImports.cshtml b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore7.Mvc7/Views/_ViewImports.cshtml
new file mode 100644
index 00000000..8fe8384e
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore7.Mvc7/Views/_ViewImports.cshtml
@@ -0,0 +1,2 @@
+@addTagHelper "*, Microsoft.AspNetCore.Mvc.TagHelpers"
+@addTagHelper "*, JavaScriptEngineSwitcher.Sample.AspNetCore.Infrastructure"
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore7.Mvc7/Views/_ViewStart.cshtml b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore7.Mvc7/Views/_ViewStart.cshtml
new file mode 100644
index 00000000..817a9134
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore7.Mvc7/Views/_ViewStart.cshtml
@@ -0,0 +1,3 @@
+@{
+ Layout = "_Layout";
+}
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore7.Mvc7/appsettings.Development.json b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore7.Mvc7/appsettings.Development.json
new file mode 100644
index 00000000..0c208ae9
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore7.Mvc7/appsettings.Development.json
@@ -0,0 +1,8 @@
+{
+ "Logging": {
+ "LogLevel": {
+ "Default": "Information",
+ "Microsoft.AspNetCore": "Warning"
+ }
+ }
+}
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore7.Mvc7/appsettings.json b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore7.Mvc7/appsettings.json
new file mode 100644
index 00000000..ed44b7ae
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore7.Mvc7/appsettings.json
@@ -0,0 +1,15 @@
+{
+ "Logging": {
+ "LogLevel": {
+ "Default": "Information",
+ "Microsoft.AspNetCore": "Warning"
+ }
+ },
+ "AllowedHosts": "*",
+
+ "JsEngineSwitcher": {
+ "Samples": {
+ "TextContentDirectoryPath": "../SharedData/text-content"
+ }
+ }
+}
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore8.Mvc8/Controllers/HomeController.cs b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore8.Mvc8/Controllers/HomeController.cs
new file mode 100644
index 00000000..0128dc52
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore8.Mvc8/Controllers/HomeController.cs
@@ -0,0 +1,83 @@
+using System.Diagnostics;
+using System.Threading.Tasks;
+
+using Microsoft.AspNetCore.Hosting;
+using Microsoft.AspNetCore.Html;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.Extensions.Configuration;
+
+using JavaScriptEngineSwitcher.Sample.AspNetCore8.Mvc8.Models;
+using JavaScriptEngineSwitcher.Sample.Logic.Models;
+using JavaScriptEngineSwitcher.Sample.Logic.Services;
+
+namespace JavaScriptEngineSwitcher.Sample.AspNetCore8.Mvc8.Controllers
+{
+ public class HomeController : Controller
+ {
+ private readonly FileContentService _fileContentService;
+ private readonly JsEvaluationService _jsEvaluationService;
+
+
+ public HomeController(
+ IConfigurationRoot configuration,
+ IWebHostEnvironment hostingEnvironment,
+ JsEvaluationService jsEvaluationService)
+ {
+ string textContentDirectoryPath = configuration
+ .GetSection("jsengineswitcher")
+ .GetSection("Samples")["TextContentDirectoryPath"]
+ ;
+
+ _fileContentService = new FileContentService(textContentDirectoryPath, hostingEnvironment);
+ _jsEvaluationService = jsEvaluationService;
+ }
+
+
+ [ResponseCache(CacheProfileName = "CacheCompressedContent5Minutes")]
+ public IActionResult Index()
+ {
+ ViewBag.Body = new HtmlString(_fileContentService.GetFileContent("index.html"));
+
+ return View();
+ }
+
+ [HttpGet]
+ [ResponseCache(CacheProfileName = "CacheCompressedContent5Minutes")]
+ public IActionResult Demo()
+ {
+ var model = _jsEvaluationService.GetInitializationData();
+
+ return View(model);
+ }
+
+ [HttpPost]
+ public async Task Demo(JsEvaluationViewModel editedModel)
+ {
+ var model = _jsEvaluationService.GetInitializationData();
+ await TryUpdateModelAsync(model, string.Empty, m => m.EngineName, m=> m.Expression);
+
+ if (ModelState.IsValid)
+ {
+ model = _jsEvaluationService.Evaluate(model);
+
+ ModelState.Clear();
+ }
+
+ return View(model);
+ }
+
+ [ResponseCache(CacheProfileName = "CacheCompressedContent5Minutes")]
+ public IActionResult Contact()
+ {
+ ViewBag.Body = new HtmlString(_fileContentService.GetFileContent("contact.html"));
+
+ return View();
+ }
+
+ [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
+ public IActionResult Error()
+ {
+ return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
+ }
+ }
+}
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore8.Mvc8/JavaScriptEngineSwitcher.Sample.AspNetCore8.Mvc8.csproj b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore8.Mvc8/JavaScriptEngineSwitcher.Sample.AspNetCore8.Mvc8.csproj
new file mode 100644
index 00000000..b81aaf6e
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore8.Mvc8/JavaScriptEngineSwitcher.Sample.AspNetCore8.Mvc8.csproj
@@ -0,0 +1,49 @@
+
+
+
+ JS Engine Switcher: Sample ASP.NET Core 8.0 MVC 8 Site
+ 3.30.4
+ net8.0
+ enable
+ Exe
+ true
+ true
+ true
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore8.Mvc8/Models/ErrorViewModel.cs b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore8.Mvc8/Models/ErrorViewModel.cs
new file mode 100644
index 00000000..8cf789c5
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore8.Mvc8/Models/ErrorViewModel.cs
@@ -0,0 +1,9 @@
+namespace JavaScriptEngineSwitcher.Sample.AspNetCore8.Mvc8.Models
+{
+ public class ErrorViewModel
+ {
+ public string RequestId { get; set; }
+
+ public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
+ }
+}
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore8.Mvc8/Program.cs b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore8.Mvc8/Program.cs
new file mode 100644
index 00000000..2e472860
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore8.Mvc8/Program.cs
@@ -0,0 +1,106 @@
+using Jering.Javascript.NodeJS;
+using Microsoft.AspNetCore.Mvc;
+
+using JavaScriptEngineSwitcher.ChakraCore;
+using JavaScriptEngineSwitcher.Extensions.MsDependencyInjection;
+using JavaScriptEngineSwitcher.Jint;
+using JavaScriptEngineSwitcher.Jurassic;
+using JavaScriptEngineSwitcher.Msie;
+using JavaScriptEngineSwitcher.NiL;
+using JavaScriptEngineSwitcher.Node;
+using JavaScriptEngineSwitcher.Sample.Logic.Services;
+using JavaScriptEngineSwitcher.V8;
+using JavaScriptEngineSwitcher.Vroom;
+using JavaScriptEngineSwitcher.Yantra;
+
+var builder = WebApplication.CreateBuilder(new WebApplicationOptions()
+{
+ WebRootPath = Path.Combine(
+ Directory.GetCurrentDirectory(),
+ "../JavaScriptEngineSwitcher.Sample.AspNetCore.ClientSideAssets/wwwroot"
+ )
+});
+var env = builder.Environment;
+var configuration = new ConfigurationBuilder()
+ .SetBasePath(env.ContentRootPath)
+ .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
+ .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
+ .AddEnvironmentVariables()
+ .Build()
+ ;
+
+#region Configure services
+
+IServiceCollection services = builder.Services;
+
+services.AddSingleton(configuration);
+
+// Add Jering Node.js service to the services container.
+services.AddNodeJS();
+
+// Add JavaScriptEngineSwitcher services to the services container.
+services.AddJsEngineSwitcher(options =>
+{
+ options.AllowCurrentProperty = false;
+ options.DefaultEngineName = ChakraCoreJsEngine.EngineName;
+})
+ .AddChakraCore()
+ .AddJint()
+ .AddJurassic()
+ .AddMsie(options =>
+ {
+ options.EngineMode = JsEngineMode.ChakraIeJsRt;
+ })
+ .AddNiL()
+ .AddNode(services)
+ .AddV8()
+ .AddVroom()
+ .AddYantra()
+ ;
+
+services.Configure(options =>
+{
+ options.CacheProfiles.Add("CacheCompressedContent5Minutes",
+ new CacheProfile
+ {
+ NoStore = builder.Environment.IsDevelopment(),
+ Duration = 300,
+ Location = ResponseCacheLocation.Client,
+ VaryByHeader = "Accept-Encoding"
+ }
+ );
+});
+
+// Add framework services.
+services.AddControllersWithViews();
+
+// Add JavaScriptEngineSwitcher sample services to the services container.
+services.AddSingleton();
+
+#endregion
+
+#region Configure the HTTP request pipeline
+
+var app = builder.Build();
+
+if (app.Environment.IsDevelopment())
+{
+ app.UseDeveloperExceptionPage();
+}
+else
+{
+ app.UseExceptionHandler("/Home/Error");
+}
+
+app.UseStaticFiles();
+
+app.UseRouting();
+
+app.MapControllerRoute(
+ name: "default",
+ pattern: "{controller=Home}/{action=Index}/{id?}"
+);
+
+#endregion
+
+app.Run();
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore8.Mvc8/Properties/launchSettings.json b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore8.Mvc8/Properties/launchSettings.json
new file mode 100644
index 00000000..dda1c460
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore8.Mvc8/Properties/launchSettings.json
@@ -0,0 +1,29 @@
+{
+ "$schema": "http://json.schemastore.org/launchsettings.json",
+ "iisSettings": {
+ "windowsAuthentication": false,
+ "anonymousAuthentication": true,
+ "iisExpress": {
+ "applicationUrl": "http://localhost:29737",
+ "sslPort": 0
+ }
+ },
+ "profiles": {
+ "http": {
+ "commandName": "Project",
+ "dotnetRunMessages": true,
+ "launchBrowser": true,
+ "applicationUrl": "http://localhost:5282",
+ "environmentVariables": {
+ "ASPNETCORE_ENVIRONMENT": "Development"
+ }
+ },
+ "IIS Express": {
+ "commandName": "IISExpress",
+ "launchBrowser": true,
+ "environmentVariables": {
+ "ASPNETCORE_ENVIRONMENT": "Development"
+ }
+ }
+ }
+}
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore8.Mvc8/Views/Home/Contact.cshtml b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore8.Mvc8/Views/Home/Contact.cshtml
new file mode 100644
index 00000000..58785ebe
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore8.Mvc8/Views/Home/Contact.cshtml
@@ -0,0 +1,8 @@
+@{
+ ViewBag.Title = "Contact";
+}
+
+
+ @ViewBag.Title
+ @ViewBag.Body
+
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore8.Mvc8/Views/Home/Demo.cshtml b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore8.Mvc8/Views/Home/Demo.cshtml
new file mode 100644
index 00000000..befb8f43
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore8.Mvc8/Views/Home/Demo.cshtml
@@ -0,0 +1,67 @@
+@using JavaScriptEngineSwitcher.Sample.Logic.Models
+@using JavaScriptEngineSwitcher.Sample.Resources
+
+@model JsEvaluationViewModel
+
+@{
+ ViewBag.Title = "Demo";
+}
+
+@ViewBag.Title
+
+
+
+@section Scripts {
+
+
+
+
+
+
+
+
+
+}
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore8.Mvc8/Views/Home/Index.cshtml b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore8.Mvc8/Views/Home/Index.cshtml
new file mode 100644
index 00000000..a9c2cfb1
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore8.Mvc8/Views/Home/Index.cshtml
@@ -0,0 +1,8 @@
+@{
+ ViewBag.Title = string.Empty;
+}
+
+
+ Project Description
+ @ViewBag.Body
+
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore8.Mvc8/Views/Shared/Error.cshtml b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore8.Mvc8/Views/Shared/Error.cshtml
new file mode 100644
index 00000000..bfb58107
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore8.Mvc8/Views/Shared/Error.cshtml
@@ -0,0 +1,28 @@
+@using JavaScriptEngineSwitcher.Sample.AspNetCore8.Mvc8.Models
+
+@model ErrorViewModel
+
+@{
+ ViewData["Title"] = "Error";
+}
+
+Error.
+An error occurred while processing your request.
+
+@if (Model.ShowRequestId)
+{
+
+ Request ID: @Model.RequestId
+
+}
+
+Development Mode
+
+ Swapping to Development environment will display more detailed information about the error that occurred.
+
+
+ The Development environment shouldn't be enabled for deployed applications.
+ It can result in displaying sensitive information from exceptions to end users.
+ For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development
+ and restarting the app.
+
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore8.Mvc8/Views/Shared/_JsEvaluationErrorList.cshtml b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore8.Mvc8/Views/Shared/_JsEvaluationErrorList.cshtml
new file mode 100644
index 00000000..9e0601d6
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore8.Mvc8/Views/Shared/_JsEvaluationErrorList.cshtml
@@ -0,0 +1,23 @@
+@using JavaScriptEngineSwitcher.Sample.AspNetCore.Infrastructure.Helpers
+@using JavaScriptEngineSwitcher.Sample.Logic.Models
+
+@model IList
+
+Found @Model.Count error(s):
+
+ @foreach (var error in Model)
+ {
+ -
+ @error.EngineFullName
+ @if (error.LineNumber > 0)
+ {
+ Line @error.LineNumber, Column @error.ColumnNumber
+ }
+ @Html.EncodedReplace(@error.Message, "\n\r?", "
")
+ @if (!string.IsNullOrWhiteSpace(error.SourceFragment))
+ {
+ @error.SourceFragment
+ }
+
+ }
+
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore8.Mvc8/Views/Shared/_Layout.cshtml b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore8.Mvc8/Views/Shared/_Layout.cshtml
new file mode 100644
index 00000000..ebe02bba
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore8.Mvc8/Views/Shared/_Layout.cshtml
@@ -0,0 +1,107 @@
+@using JavaScriptEngineSwitcher.Sample.AspNetCore.Infrastructure.TagHelpers
+
+
+
+
+
+
+
+
+ @if (!string.IsNullOrEmpty(ViewBag.Title)) {@ViewBag.Title | }JavaScriptEngineSwitcher Sample ASP.NET Core 8.0 MVC 8 Site
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ JavaScript Engine Switcher
+
+
+
+
+
+
+
+
+
+
+
+ @RenderBody()
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ @await RenderSectionAsync("scripts", required: false)
+
+
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore8.Mvc8/Views/_ViewImports.cshtml b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore8.Mvc8/Views/_ViewImports.cshtml
new file mode 100644
index 00000000..8fe8384e
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore8.Mvc8/Views/_ViewImports.cshtml
@@ -0,0 +1,2 @@
+@addTagHelper "*, Microsoft.AspNetCore.Mvc.TagHelpers"
+@addTagHelper "*, JavaScriptEngineSwitcher.Sample.AspNetCore.Infrastructure"
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore8.Mvc8/Views/_ViewStart.cshtml b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore8.Mvc8/Views/_ViewStart.cshtml
new file mode 100644
index 00000000..817a9134
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore8.Mvc8/Views/_ViewStart.cshtml
@@ -0,0 +1,3 @@
+@{
+ Layout = "_Layout";
+}
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore8.Mvc8/appsettings.Development.json b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore8.Mvc8/appsettings.Development.json
new file mode 100644
index 00000000..0c208ae9
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore8.Mvc8/appsettings.Development.json
@@ -0,0 +1,8 @@
+{
+ "Logging": {
+ "LogLevel": {
+ "Default": "Information",
+ "Microsoft.AspNetCore": "Warning"
+ }
+ }
+}
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore8.Mvc8/appsettings.json b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore8.Mvc8/appsettings.json
new file mode 100644
index 00000000..ed44b7ae
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore8.Mvc8/appsettings.json
@@ -0,0 +1,15 @@
+{
+ "Logging": {
+ "LogLevel": {
+ "Default": "Information",
+ "Microsoft.AspNetCore": "Warning"
+ }
+ },
+ "AllowedHosts": "*",
+
+ "JsEngineSwitcher": {
+ "Samples": {
+ "TextContentDirectoryPath": "../SharedData/text-content"
+ }
+ }
+}
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore9.Mvc9/Controllers/HomeController.cs b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore9.Mvc9/Controllers/HomeController.cs
new file mode 100644
index 00000000..57f376ff
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore9.Mvc9/Controllers/HomeController.cs
@@ -0,0 +1,83 @@
+using System.Diagnostics;
+using System.Threading.Tasks;
+
+using Microsoft.AspNetCore.Hosting;
+using Microsoft.AspNetCore.Html;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.Extensions.Configuration;
+
+using JavaScriptEngineSwitcher.Sample.AspNetCore9.Mvc9.Models;
+using JavaScriptEngineSwitcher.Sample.Logic.Models;
+using JavaScriptEngineSwitcher.Sample.Logic.Services;
+
+namespace JavaScriptEngineSwitcher.Sample.AspNetCore9.Mvc9.Controllers
+{
+ public class HomeController : Controller
+ {
+ private readonly FileContentService _fileContentService;
+ private readonly JsEvaluationService _jsEvaluationService;
+
+
+ public HomeController(
+ IConfigurationRoot configuration,
+ IWebHostEnvironment hostingEnvironment,
+ JsEvaluationService jsEvaluationService)
+ {
+ string textContentDirectoryPath = configuration
+ .GetSection("jsengineswitcher")
+ .GetSection("Samples")["TextContentDirectoryPath"]
+ ;
+
+ _fileContentService = new FileContentService(textContentDirectoryPath, hostingEnvironment);
+ _jsEvaluationService = jsEvaluationService;
+ }
+
+
+ [ResponseCache(CacheProfileName = "CacheCompressedContent5Minutes")]
+ public IActionResult Index()
+ {
+ ViewBag.Body = new HtmlString(_fileContentService.GetFileContent("index.html"));
+
+ return View();
+ }
+
+ [HttpGet]
+ [ResponseCache(CacheProfileName = "CacheCompressedContent5Minutes")]
+ public IActionResult Demo()
+ {
+ var model = _jsEvaluationService.GetInitializationData();
+
+ return View(model);
+ }
+
+ [HttpPost]
+ public async Task Demo(JsEvaluationViewModel editedModel)
+ {
+ var model = _jsEvaluationService.GetInitializationData();
+ await TryUpdateModelAsync(model, string.Empty, m => m.EngineName, m=> m.Expression);
+
+ if (ModelState.IsValid)
+ {
+ model = _jsEvaluationService.Evaluate(model);
+
+ ModelState.Clear();
+ }
+
+ return View(model);
+ }
+
+ [ResponseCache(CacheProfileName = "CacheCompressedContent5Minutes")]
+ public IActionResult Contact()
+ {
+ ViewBag.Body = new HtmlString(_fileContentService.GetFileContent("contact.html"));
+
+ return View();
+ }
+
+ [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
+ public IActionResult Error()
+ {
+ return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
+ }
+ }
+}
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore9.Mvc9/JavaScriptEngineSwitcher.Sample.AspNetCore9.Mvc9.csproj b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore9.Mvc9/JavaScriptEngineSwitcher.Sample.AspNetCore9.Mvc9.csproj
new file mode 100644
index 00000000..23cf372a
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore9.Mvc9/JavaScriptEngineSwitcher.Sample.AspNetCore9.Mvc9.csproj
@@ -0,0 +1,49 @@
+
+
+
+ JS Engine Switcher: Sample ASP.NET Core 9.0 MVC 9 Site
+ 3.30.4
+ net9.0
+ enable
+ Exe
+ true
+ true
+ true
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore9.Mvc9/Models/ErrorViewModel.cs b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore9.Mvc9/Models/ErrorViewModel.cs
new file mode 100644
index 00000000..20cc9827
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore9.Mvc9/Models/ErrorViewModel.cs
@@ -0,0 +1,9 @@
+namespace JavaScriptEngineSwitcher.Sample.AspNetCore9.Mvc9.Models
+{
+ public class ErrorViewModel
+ {
+ public string RequestId { get; set; }
+
+ public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
+ }
+}
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore9.Mvc9/Program.cs b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore9.Mvc9/Program.cs
new file mode 100644
index 00000000..457ccf63
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore9.Mvc9/Program.cs
@@ -0,0 +1,105 @@
+using Jering.Javascript.NodeJS;
+using Microsoft.AspNetCore.Mvc;
+
+using JavaScriptEngineSwitcher.ChakraCore;
+using JavaScriptEngineSwitcher.Extensions.MsDependencyInjection;
+using JavaScriptEngineSwitcher.Jint;
+using JavaScriptEngineSwitcher.Jurassic;
+using JavaScriptEngineSwitcher.Msie;
+using JavaScriptEngineSwitcher.NiL;
+using JavaScriptEngineSwitcher.Node;
+using JavaScriptEngineSwitcher.Sample.Logic.Services;
+using JavaScriptEngineSwitcher.V8;
+using JavaScriptEngineSwitcher.Vroom;
+using JavaScriptEngineSwitcher.Yantra;
+
+var builder = WebApplication.CreateBuilder(new WebApplicationOptions() {
+ WebRootPath = Path.Combine(
+ Directory.GetCurrentDirectory(),
+ "../JavaScriptEngineSwitcher.Sample.AspNetCore.ClientSideAssets/wwwroot"
+ )
+});
+var env = builder.Environment;
+var configuration = new ConfigurationBuilder()
+ .SetBasePath(env.ContentRootPath)
+ .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
+ .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
+ .AddEnvironmentVariables()
+ .Build()
+ ;
+
+#region Configure services
+
+IServiceCollection services = builder.Services;
+
+services.AddSingleton(configuration);
+
+// Add Jering Node.js service to the services container.
+services.AddNodeJS();
+
+// Add JavaScriptEngineSwitcher services to the services container.
+services.AddJsEngineSwitcher(options =>
+{
+ options.AllowCurrentProperty = false;
+ options.DefaultEngineName = ChakraCoreJsEngine.EngineName;
+})
+ .AddChakraCore()
+ .AddJint()
+ .AddJurassic()
+ .AddMsie(options =>
+ {
+ options.EngineMode = JsEngineMode.ChakraIeJsRt;
+ })
+ .AddNiL()
+ .AddNode(services)
+ .AddV8()
+ .AddVroom()
+ .AddYantra()
+ ;
+
+services.Configure(options =>
+{
+ options.CacheProfiles.Add("CacheCompressedContent5Minutes",
+ new CacheProfile
+ {
+ NoStore = builder.Environment.IsDevelopment(),
+ Duration = 300,
+ Location = ResponseCacheLocation.Client,
+ VaryByHeader = "Accept-Encoding"
+ }
+ );
+});
+
+// Add framework services.
+services.AddControllersWithViews();
+
+// Add JavaScriptEngineSwitcher sample services to the services container.
+services.AddSingleton();
+
+#endregion
+
+#region Configure the HTTP request pipeline
+
+var app = builder.Build();
+
+if (app.Environment.IsDevelopment())
+{
+ app.UseDeveloperExceptionPage();
+}
+else
+{
+ app.UseExceptionHandler("/Home/Error");
+}
+
+app.UseRouting();
+
+app.MapStaticAssets();
+
+app.MapControllerRoute(
+ name: "default",
+ pattern: "{controller=Home}/{action=Index}/{id?}")
+ .WithStaticAssets();
+
+#endregion
+
+app.Run();
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore9.Mvc9/Properties/launchSettings.json b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore9.Mvc9/Properties/launchSettings.json
new file mode 100644
index 00000000..a94e92ed
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore9.Mvc9/Properties/launchSettings.json
@@ -0,0 +1,38 @@
+{
+ "$schema": "https://json.schemastore.org/launchsettings.json",
+ "iisSettings": {
+ "windowsAuthentication": false,
+ "anonymousAuthentication": true,
+ "iisExpress": {
+ "applicationUrl": "http://localhost:53687/",
+ "sslPort": 44308
+ }
+ },
+ "profiles": {
+ "http": {
+ "commandName": "Project",
+ "launchBrowser": true,
+ "environmentVariables": {
+ "ASPNETCORE_ENVIRONMENT": "Development"
+ },
+ "dotnetRunMessages": true,
+ "applicationUrl": "http://localhost:5220"
+ },
+ "https": {
+ "commandName": "Project",
+ "launchBrowser": true,
+ "environmentVariables": {
+ "ASPNETCORE_ENVIRONMENT": "Development"
+ },
+ "dotnetRunMessages": true,
+ "applicationUrl": "https://localhost:7242;http://localhost:5220"
+ },
+ "IIS Express": {
+ "commandName": "IISExpress",
+ "launchBrowser": true,
+ "environmentVariables": {
+ "ASPNETCORE_ENVIRONMENT": "Development"
+ }
+ }
+ }
+}
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore9.Mvc9/Views/Home/Contact.cshtml b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore9.Mvc9/Views/Home/Contact.cshtml
new file mode 100644
index 00000000..58785ebe
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore9.Mvc9/Views/Home/Contact.cshtml
@@ -0,0 +1,8 @@
+@{
+ ViewBag.Title = "Contact";
+}
+
+
+ @ViewBag.Title
+ @ViewBag.Body
+
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore9.Mvc9/Views/Home/Demo.cshtml b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore9.Mvc9/Views/Home/Demo.cshtml
new file mode 100644
index 00000000..befb8f43
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore9.Mvc9/Views/Home/Demo.cshtml
@@ -0,0 +1,67 @@
+@using JavaScriptEngineSwitcher.Sample.Logic.Models
+@using JavaScriptEngineSwitcher.Sample.Resources
+
+@model JsEvaluationViewModel
+
+@{
+ ViewBag.Title = "Demo";
+}
+
+@ViewBag.Title
+
+
+
+@section Scripts {
+
+
+
+
+
+
+
+
+
+}
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore9.Mvc9/Views/Home/Index.cshtml b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore9.Mvc9/Views/Home/Index.cshtml
new file mode 100644
index 00000000..a9c2cfb1
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore9.Mvc9/Views/Home/Index.cshtml
@@ -0,0 +1,8 @@
+@{
+ ViewBag.Title = string.Empty;
+}
+
+
+ Project Description
+ @ViewBag.Body
+
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore9.Mvc9/Views/Shared/Error.cshtml b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore9.Mvc9/Views/Shared/Error.cshtml
new file mode 100644
index 00000000..b568b9f2
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore9.Mvc9/Views/Shared/Error.cshtml
@@ -0,0 +1,28 @@
+@using JavaScriptEngineSwitcher.Sample.AspNetCore9.Mvc9.Models
+
+@model ErrorViewModel
+
+@{
+ ViewData["Title"] = "Error";
+}
+
+Error.
+An error occurred while processing your request.
+
+@if (Model.ShowRequestId)
+{
+
+ Request ID: @Model.RequestId
+
+}
+
+Development Mode
+
+ Swapping to Development environment will display more detailed information about the error that occurred.
+
+
+ The Development environment shouldn't be enabled for deployed applications.
+ It can result in displaying sensitive information from exceptions to end users.
+ For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development
+ and restarting the app.
+
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore9.Mvc9/Views/Shared/_JsEvaluationErrorList.cshtml b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore9.Mvc9/Views/Shared/_JsEvaluationErrorList.cshtml
new file mode 100644
index 00000000..9e0601d6
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore9.Mvc9/Views/Shared/_JsEvaluationErrorList.cshtml
@@ -0,0 +1,23 @@
+@using JavaScriptEngineSwitcher.Sample.AspNetCore.Infrastructure.Helpers
+@using JavaScriptEngineSwitcher.Sample.Logic.Models
+
+@model IList
+
+Found @Model.Count error(s):
+
+ @foreach (var error in Model)
+ {
+ -
+ @error.EngineFullName
+ @if (error.LineNumber > 0)
+ {
+ Line @error.LineNumber, Column @error.ColumnNumber
+ }
+ @Html.EncodedReplace(@error.Message, "\n\r?", "
")
+ @if (!string.IsNullOrWhiteSpace(error.SourceFragment))
+ {
+ @error.SourceFragment
+ }
+
+ }
+
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore9.Mvc9/Views/Shared/_Layout.cshtml b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore9.Mvc9/Views/Shared/_Layout.cshtml
new file mode 100644
index 00000000..b595497f
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore9.Mvc9/Views/Shared/_Layout.cshtml
@@ -0,0 +1,107 @@
+@using JavaScriptEngineSwitcher.Sample.AspNetCore.Infrastructure.TagHelpers
+
+
+
+
+
+
+
+
+ @if (!string.IsNullOrEmpty(ViewBag.Title)) {@ViewBag.Title | }JavaScriptEngineSwitcher Sample ASP.NET Core 9.0 MVC 9 Site
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ JavaScript Engine Switcher
+
+
+
+
+
+
+
+
+
+
+
+ @RenderBody()
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ @await RenderSectionAsync("scripts", required: false)
+
+
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore9.Mvc9/Views/_ViewImports.cshtml b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore9.Mvc9/Views/_ViewImports.cshtml
new file mode 100644
index 00000000..dcad619c
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore9.Mvc9/Views/_ViewImports.cshtml
@@ -0,0 +1,2 @@
+@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
+@addTagHelper *, JavaScriptEngineSwitcher.Sample.AspNetCore.Infrastructure
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore9.Mvc9/Views/_ViewStart.cshtml b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore9.Mvc9/Views/_ViewStart.cshtml
new file mode 100644
index 00000000..817a9134
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore9.Mvc9/Views/_ViewStart.cshtml
@@ -0,0 +1,3 @@
+@{
+ Layout = "_Layout";
+}
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore9.Mvc9/appsettings.Development.json b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore9.Mvc9/appsettings.Development.json
new file mode 100644
index 00000000..0c208ae9
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore9.Mvc9/appsettings.Development.json
@@ -0,0 +1,8 @@
+{
+ "Logging": {
+ "LogLevel": {
+ "Default": "Information",
+ "Microsoft.AspNetCore": "Warning"
+ }
+ }
+}
diff --git a/samples/JavaScriptEngineSwitcher.Sample.AspNetCore9.Mvc9/appsettings.json b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore9.Mvc9/appsettings.json
new file mode 100644
index 00000000..ed44b7ae
--- /dev/null
+++ b/samples/JavaScriptEngineSwitcher.Sample.AspNetCore9.Mvc9/appsettings.json
@@ -0,0 +1,15 @@
+{
+ "Logging": {
+ "LogLevel": {
+ "Default": "Information",
+ "Microsoft.AspNetCore": "Warning"
+ }
+ },
+ "AllowedHosts": "*",
+
+ "JsEngineSwitcher": {
+ "Samples": {
+ "TextContentDirectoryPath": "../SharedData/text-content"
+ }
+ }
+}
diff --git a/samples/JavaScriptEngineSwitcher.Sample.Logic/JavaScriptEngineSwitcher.Sample.Logic.csproj b/samples/JavaScriptEngineSwitcher.Sample.Logic/JavaScriptEngineSwitcher.Sample.Logic.csproj
index de168c11..bc56129b 100644
--- a/samples/JavaScriptEngineSwitcher.Sample.Logic/JavaScriptEngineSwitcher.Sample.Logic.csproj
+++ b/samples/JavaScriptEngineSwitcher.Sample.Logic/JavaScriptEngineSwitcher.Sample.Logic.csproj
@@ -1,37 +1,68 @@
-
- JS Engine Switcher: Logic for Samples
- 3.0.0
- net40;net451;net471;netstandard1.6;netstandard2.0
- 1.6.0
- Library
- true
- false
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+ JS Engine Switcher: Logic for Samples
+ 3.30.4
+ net40;net451;net471;netstandard1.6;netstandard2.0;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0;net9.0;net10.0
+ 1.6.0
+ Library
+ true
+ $(NoWarn);NETSDK1215;NU1902;NU1903;NU1904
+ false
+ false
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/samples/JavaScriptEngineSwitcher.Sample.Logic/Models/JsEvaluationViewModel.cs b/samples/JavaScriptEngineSwitcher.Sample.Logic/Models/JsEvaluationViewModel.cs
index b2c26832..0cca3971 100644
--- a/samples/JavaScriptEngineSwitcher.Sample.Logic/Models/JsEvaluationViewModel.cs
+++ b/samples/JavaScriptEngineSwitcher.Sample.Logic/Models/JsEvaluationViewModel.cs
@@ -1,6 +1,6 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
-#if NET451 || NET471 || NETSTANDARD
+#if NET451_OR_GREATER || NETSTANDARD || NETCOREAPP
using Microsoft.AspNetCore.Mvc.Rendering;
#elif NET40
using System.Web.Mvc;
diff --git a/samples/JavaScriptEngineSwitcher.Sample.Logic/Services/FileContentService.cs b/samples/JavaScriptEngineSwitcher.Sample.Logic/Services/FileContentService.cs
index 226726cd..de909780 100644
--- a/samples/JavaScriptEngineSwitcher.Sample.Logic/Services/FileContentService.cs
+++ b/samples/JavaScriptEngineSwitcher.Sample.Logic/Services/FileContentService.cs
@@ -1,7 +1,9 @@
using System;
using System.IO;
-#if NET451 || NET471 || NETSTANDARD
-using Microsoft.AspNetCore.Hosting;
+#if NET451_OR_GREATER || NETSTANDARD
+using HostingEnvironment = Microsoft.AspNetCore.Hosting.IHostingEnvironment;
+#elif NETCOREAPP3_1_OR_GREATER
+using HostingEnvironment = Microsoft.AspNetCore.Hosting.IWebHostEnvironment;
#elif NET40
using System.Web;
#else
@@ -15,15 +17,15 @@ namespace JavaScriptEngineSwitcher.Sample.Logic.Services
public sealed class FileContentService
{
private readonly string _textContentDirectoryPath;
-#if NET451 || NET471 || NETSTANDARD
- private readonly IHostingEnvironment _hostingEnvironment;
+#if NET451_OR_GREATER || NETSTANDARD || NETCOREAPP
+ private readonly HostingEnvironment _hostingEnvironment;
#endif
-#if NET451 || NET471 || NETSTANDARD
+#if NET451_OR_GREATER || NETSTANDARD || NETCOREAPP
public FileContentService(
string textContentDirectoryPath,
- IHostingEnvironment hostingEnvironment
+ HostingEnvironment hostingEnvironment
)
{
_textContentDirectoryPath = textContentDirectoryPath;
@@ -76,7 +78,7 @@ public string GetFileContent(string filePath)
private string GetPhysicalFilePath(string filePath)
{
-#if NET451 || NET471 || NETSTANDARD
+#if NET451_OR_GREATER || NETSTANDARD || NETCOREAPP
string applicationDirectoryPath = _hostingEnvironment.ContentRootPath;
#elif NET40
HttpContext context = HttpContext.Current;
diff --git a/samples/JavaScriptEngineSwitcher.Sample.Logic/Services/JsEvaluationService.cs b/samples/JavaScriptEngineSwitcher.Sample.Logic/Services/JsEvaluationService.cs
index 82e7c84a..2317ac51 100644
--- a/samples/JavaScriptEngineSwitcher.Sample.Logic/Services/JsEvaluationService.cs
+++ b/samples/JavaScriptEngineSwitcher.Sample.Logic/Services/JsEvaluationService.cs
@@ -1,6 +1,6 @@
using System.Collections.Generic;
using System.Linq;
-#if NET451 || NET471 || NETSTANDARD
+#if NET451_OR_GREATER || NETSTANDARD || NETCOREAPP
using Microsoft.AspNetCore.Mvc.Rendering;
#elif NET40
using System.Web.Mvc;
@@ -25,11 +25,7 @@ static JsEvaluationService()
{
_engineDisplayNameMappings = new Dictionary
{
- { "ChakraCoreJsEngine", "ChakraCore" },
- { "JintJsEngine", "Jint" },
- { "JurassicJsEngine", "Jurassic" },
- { "MsieJsEngine", "MSIE" },
- { "V8JsEngine", "V8" }
+ { "MsieJsEngine", "MSIE" }
};
}
diff --git a/samples/JavaScriptEngineSwitcher.Sample.Resources/CommonStrings.Designer.cs b/samples/JavaScriptEngineSwitcher.Sample.Resources/CommonStrings.Designer.cs
index 131d9cd3..3e6c3446 100644
--- a/samples/JavaScriptEngineSwitcher.Sample.Resources/CommonStrings.Designer.cs
+++ b/samples/JavaScriptEngineSwitcher.Sample.Resources/CommonStrings.Designer.cs
@@ -21,7 +21,7 @@ public class CommonStrings
private static Lazy _resourceManager =
new Lazy(() => new ResourceManager(
"JavaScriptEngineSwitcher.Sample.Resources.CommonStrings",
-#if NET40
+#if NET20 || NET30 || NET35 || NET40
typeof(CommonStrings).Assembly
#else
typeof(CommonStrings).GetTypeInfo().Assembly
diff --git a/samples/JavaScriptEngineSwitcher.Sample.Resources/EvaluationStrings.Designer.cs b/samples/JavaScriptEngineSwitcher.Sample.Resources/EvaluationStrings.Designer.cs
index 7fc38392..14fa940f 100644
--- a/samples/JavaScriptEngineSwitcher.Sample.Resources/EvaluationStrings.Designer.cs
+++ b/samples/JavaScriptEngineSwitcher.Sample.Resources/EvaluationStrings.Designer.cs
@@ -21,7 +21,7 @@ public class EvaluationStrings
private static Lazy _resourceManager =
new Lazy(() => new ResourceManager(
"JavaScriptEngineSwitcher.Sample.Resources.EvaluationStrings",
-#if NET40
+#if NET20 || NET30 || NET35 || NET40
typeof(EvaluationStrings).Assembly
#else
typeof(EvaluationStrings).GetTypeInfo().Assembly
diff --git a/samples/JavaScriptEngineSwitcher.Sample.Resources/JavaScriptEngineSwitcher.Sample.Resources.csproj b/samples/JavaScriptEngineSwitcher.Sample.Resources/JavaScriptEngineSwitcher.Sample.Resources.csproj
index 7b1c05f2..d2da9832 100644
--- a/samples/JavaScriptEngineSwitcher.Sample.Resources/JavaScriptEngineSwitcher.Sample.Resources.csproj
+++ b/samples/JavaScriptEngineSwitcher.Sample.Resources/JavaScriptEngineSwitcher.Sample.Resources.csproj
@@ -1,25 +1,27 @@
-
- JS Engine Switcher: Resources for Samples
- 3.0.0
- net40-client;net45;net471;netstandard1.3;netstandard2.0
- 1.6.0
- Library
- true
- true
- false
-
+
+ JS Engine Switcher: Resources for Samples
+ 3.30.4
+ net40-client;net45;net471;netstandard1.3;netstandard2.0
+ 1.6.0
+ Library
+ true
+ $(NoWarn);NETSDK1215;NU1903
+ false
+ true
+ false
+
-
-
+
+
-
-
-
+
+
+
-
-
-
+
+
+
\ No newline at end of file
diff --git a/samples/SharedData/text-content/contact.html b/samples/SharedData/text-content/contact.html
index 5fef06d5..7b72dd94 100644
--- a/samples/SharedData/text-content/contact.html
+++ b/samples/SharedData/text-content/contact.html
@@ -9,7 +9,5 @@ Email
Personal Site
-Twitter
-
\ No newline at end of file
+Mastodon
+
\ No newline at end of file
diff --git a/samples/SharedData/text-content/index.html b/samples/SharedData/text-content/index.html
index b27871f5..3f876a89 100644
--- a/samples/SharedData/text-content/index.html
+++ b/samples/SharedData/text-content/index.html
@@ -1,2 +1,2 @@
-JavaScript Engine Switcher determines unified interface for access to the basic features of popular JavaScript engines (MSIE JavaScript Engine for .NET, Microsoft ClearScript.V8, Jurassic, Jint, ChakraCore, VroomJs and NiL.JS). This library allows you to quickly and easily switch to using of another JavaScript engine.
+JavaScript Engine Switcher determines unified interface for access to the basic features of popular JavaScript engines (ChakraCore, Jint, Jurassic, MSIE JavaScript Engine for .NET, NiL.JS, Jering.Javascript.NodeJS, Microsoft ClearScript.V8, VroomJs and YantraJS). This library allows you to quickly and easily switch to using of another JavaScript engine.
JavaScript Engine Switcher was created and is maintained by Andrey Taritsyn.
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.ChakraCore.Native.debian-x64/JavaScriptEngineSwitcher.ChakraCore.Native.debian-x64.csproj b/src/JavaScriptEngineSwitcher.ChakraCore.Native.debian-x64/JavaScriptEngineSwitcher.ChakraCore.Native.debian-x64.csproj
deleted file mode 100644
index 7ca79d8d..00000000
--- a/src/JavaScriptEngineSwitcher.ChakraCore.Native.debian-x64/JavaScriptEngineSwitcher.ChakraCore.Native.debian-x64.csproj
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
- netstandard2.0
- false
- $(MSBuildProjectName).nuspec
-
-
-
-
-
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.ChakraCore.Native.debian-x64/JavaScriptEngineSwitcher.ChakraCore.Native.debian-x64.nuspec b/src/JavaScriptEngineSwitcher.ChakraCore.Native.debian-x64/JavaScriptEngineSwitcher.ChakraCore.Native.debian-x64.nuspec
deleted file mode 100644
index ecc0d9e8..00000000
--- a/src/JavaScriptEngineSwitcher.ChakraCore.Native.debian-x64/JavaScriptEngineSwitcher.ChakraCore.Native.debian-x64.nuspec
+++ /dev/null
@@ -1,26 +0,0 @@
-
-
-
- JavaScriptEngineSwitcher.ChakraCore.Native.debian-x64
- 3.0.0
- JS Engine Switcher: ChakraCore for Debian (x64)
- Andrey Taritsyn
- Andrey Taritsyn
- LICENSE.txt
- https://github.com/Taritsyn/JavaScriptEngineSwitcher
- https://raw.githubusercontent.com/Taritsyn/JavaScriptEngineSwitcher/master/Icons/JavaScriptEngineSwitcher_ChakraCore_Logo128x128.png
-
- false
- This package is deprecated. Instead, it is recommended to use a 'JavaScriptEngineSwitcher.ChakraCore.Native.linux-x64' package.
- ChakraCore was updated to version 1.11.4.
- Copyright © 2013-2018 Andrey Taritsyn
- en-US
- JavaScriptEngineSwitcher JavaScript ECMAScript ChakraCore Debian Ubuntu LinuxMint x64
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.ChakraCore.Native.linux-x64/JavaScriptEngineSwitcher.ChakraCore.Native.linux-x64.csproj b/src/JavaScriptEngineSwitcher.ChakraCore.Native.linux-x64/JavaScriptEngineSwitcher.ChakraCore.Native.linux-x64.csproj
index 7ca79d8d..40c96426 100644
--- a/src/JavaScriptEngineSwitcher.ChakraCore.Native.linux-x64/JavaScriptEngineSwitcher.ChakraCore.Native.linux-x64.csproj
+++ b/src/JavaScriptEngineSwitcher.ChakraCore.Native.linux-x64/JavaScriptEngineSwitcher.ChakraCore.Native.linux-x64.csproj
@@ -1,11 +1,21 @@
-
- netstandard2.0
- false
- $(MSBuildProjectName).nuspec
-
+
+ JS Engine Switcher: ChakraCore for Linux (x64)
+ 3.27.3
+ netstandard2.0
+
-
+
+
+
+
+
+ https://raw.githubusercontent.com/Taritsyn/JavaScriptEngineSwitcher/master/Icons/JavaScriptEngineSwitcher_ChakraCore_Logo128x128.png
+ ../../Icons/JavaScriptEngineSwitcher_ChakraCore_Logo128x128.png
+ This package complements the JavaScriptEngineSwitcher.ChakraCore package and contains the native implementation of ChakraCore for Linux (x64).
+ $(PackageCommonTags);ChakraCore;Linux;x64
+ ChakraCore was updated to version of August 1, 2024.
+
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.ChakraCore.Native.linux-x64/JavaScriptEngineSwitcher.ChakraCore.Native.linux-x64.nuspec b/src/JavaScriptEngineSwitcher.ChakraCore.Native.linux-x64/JavaScriptEngineSwitcher.ChakraCore.Native.linux-x64.nuspec
index 4bc93e5b..d5a1567f 100644
--- a/src/JavaScriptEngineSwitcher.ChakraCore.Native.linux-x64/JavaScriptEngineSwitcher.ChakraCore.Native.linux-x64.nuspec
+++ b/src/JavaScriptEngineSwitcher.ChakraCore.Native.linux-x64/JavaScriptEngineSwitcher.ChakraCore.Native.linux-x64.nuspec
@@ -1,28 +1,11 @@
-
-
- JavaScriptEngineSwitcher.ChakraCore.Native.linux-x64
- 3.0.0
- JS Engine Switcher: ChakraCore for Linux (x64)
- Andrey Taritsyn
- Andrey Taritsyn
- LICENSE.txt
- https://github.com/Taritsyn/JavaScriptEngineSwitcher
- https://raw.githubusercontent.com/Taritsyn/JavaScriptEngineSwitcher/master/Icons/JavaScriptEngineSwitcher_ChakraCore_Logo128x128.png
-
- false
- This package complements the JavaScriptEngineSwitcher.ChakraCore package and contains the native implementation of ChakraCore version 1.11.4 for Linux (x64).
-
-This package is only compatible with .NET Core.
- ChakraCore was updated to version 1.11.4.
- Copyright © 2013-2018 Andrey Taritsyn
- en-US
- JavaScriptEngineSwitcher JavaScript ECMAScript ChakraCore Linux x64
-
-
-
-
-
-
-
+
+
+ $CommonMetadataElements$
+
+
+ $CommonFileElements$
+
+
+
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.ChakraCore.Native.linux-x64/PACKAGE-DESCRIPTION.md b/src/JavaScriptEngineSwitcher.ChakraCore.Native.linux-x64/PACKAGE-DESCRIPTION.md
new file mode 100644
index 00000000..202c0c2b
--- /dev/null
+++ b/src/JavaScriptEngineSwitcher.ChakraCore.Native.linux-x64/PACKAGE-DESCRIPTION.md
@@ -0,0 +1,3 @@
+This package complements the [JavaScriptEngineSwitcher.ChakraCore](https://www.nuget.org/packages/JavaScriptEngineSwitcher.ChakraCore) package and contains the native implementation of [ChakraCore](https://github.com/chakra-core/ChakraCore) version of August 1, 2024 for Linux (x64).
+
+This package is only compatible with .NET Core.
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.ChakraCore.Native.linux-x64/readme.txt b/src/JavaScriptEngineSwitcher.ChakraCore.Native.linux-x64/readme.txt
index f5e18e04..fd2f8f3c 100644
--- a/src/JavaScriptEngineSwitcher.ChakraCore.Native.linux-x64/readme.txt
+++ b/src/JavaScriptEngineSwitcher.ChakraCore.Native.linux-x64/readme.txt
@@ -1,25 +1,26 @@
--------------------------------------------------------------------------------
- README file for JS Engine Switcher: ChakraCore for Linux x64 v3.0.0
+ README file for JS Engine Switcher: ChakraCore for Linux x64 v3.27.3
--------------------------------------------------------------------------------
- Copyright (c) 2013-2018 Andrey Taritsyn - http://www.taritsyn.ru
+ Copyright (c) 2013-2024 Andrey Taritsyn - http://www.taritsyn.ru
===========
DESCRIPTION
===========
This package complements the JavaScriptEngineSwitcher.ChakraCore package and
- contains the native implementation of ChakraCore version 1.11.4 for Linux (x64).
+ contains the native implementation of ChakraCore version of August 1, 2024
+ for Linux (x64).
This package is only compatible with .NET Core.
=============
RELEASE NOTES
=============
- ChakraCore was updated to version 1.11.4.
+ ChakraCore was updated to version of August 1, 2024.
=============
DOCUMENTATION
diff --git a/src/JavaScriptEngineSwitcher.ChakraCore.Native.osx-x64/JavaScriptEngineSwitcher.ChakraCore.Native.osx-x64.csproj b/src/JavaScriptEngineSwitcher.ChakraCore.Native.osx-x64/JavaScriptEngineSwitcher.ChakraCore.Native.osx-x64.csproj
index 7ca79d8d..16d5be07 100644
--- a/src/JavaScriptEngineSwitcher.ChakraCore.Native.osx-x64/JavaScriptEngineSwitcher.ChakraCore.Native.osx-x64.csproj
+++ b/src/JavaScriptEngineSwitcher.ChakraCore.Native.osx-x64/JavaScriptEngineSwitcher.ChakraCore.Native.osx-x64.csproj
@@ -1,11 +1,21 @@
-
- netstandard2.0
- false
- $(MSBuildProjectName).nuspec
-
+
+ JS Engine Switcher: ChakraCore for OS X (x64)
+ 3.27.3
+ netstandard2.0
+
-
+
+
+
+
+
+ https://raw.githubusercontent.com/Taritsyn/JavaScriptEngineSwitcher/master/Icons/JavaScriptEngineSwitcher_ChakraCore_Logo128x128.png
+ ../../Icons/JavaScriptEngineSwitcher_ChakraCore_Logo128x128.png
+ This package complements the JavaScriptEngineSwitcher.ChakraCore package and contains the native implementation of ChakraCore for OS X (x64).
+ $(PackageCommonTags);ChakraCore;macOS;OSX;x64
+ ChakraCore was updated to version of August 1, 2024.
+
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.ChakraCore.Native.osx-x64/JavaScriptEngineSwitcher.ChakraCore.Native.osx-x64.nuspec b/src/JavaScriptEngineSwitcher.ChakraCore.Native.osx-x64/JavaScriptEngineSwitcher.ChakraCore.Native.osx-x64.nuspec
index 8fee2f2c..a9105540 100644
--- a/src/JavaScriptEngineSwitcher.ChakraCore.Native.osx-x64/JavaScriptEngineSwitcher.ChakraCore.Native.osx-x64.nuspec
+++ b/src/JavaScriptEngineSwitcher.ChakraCore.Native.osx-x64/JavaScriptEngineSwitcher.ChakraCore.Native.osx-x64.nuspec
@@ -1,28 +1,11 @@
-
-
- JavaScriptEngineSwitcher.ChakraCore.Native.osx-x64
- 3.0.0
- JS Engine Switcher: ChakraCore for OS X (x64)
- Andrey Taritsyn
- Andrey Taritsyn
- LICENSE.txt
- https://github.com/Taritsyn/JavaScriptEngineSwitcher
- https://raw.githubusercontent.com/Taritsyn/JavaScriptEngineSwitcher/master/Icons/JavaScriptEngineSwitcher_ChakraCore_Logo128x128.png
-
- false
- This package complements the JavaScriptEngineSwitcher.ChakraCore package and contains the native implementation of ChakraCore version 1.11.4 for OS X (x64).
-
-This package is only compatible with .NET Core.
- ChakraCore was updated to version 1.11.4.
- Copyright © 2013-2018 Andrey Taritsyn
- en-US
- JavaScriptEngineSwitcher JavaScript ECMAScript ChakraCore macOS OSX x64
-
-
-
-
-
-
-
+
+
+ $CommonMetadataElements$
+
+
+ $CommonFileElements$
+
+
+
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.ChakraCore.Native.osx-x64/PACKAGE-DESCRIPTION.md b/src/JavaScriptEngineSwitcher.ChakraCore.Native.osx-x64/PACKAGE-DESCRIPTION.md
new file mode 100644
index 00000000..910cd8d8
--- /dev/null
+++ b/src/JavaScriptEngineSwitcher.ChakraCore.Native.osx-x64/PACKAGE-DESCRIPTION.md
@@ -0,0 +1,3 @@
+This package complements the [JavaScriptEngineSwitcher.ChakraCore](https://www.nuget.org/packages/JavaScriptEngineSwitcher.ChakraCore) package and contains the native implementation of [ChakraCore](https://github.com/chakra-core/ChakraCore) version of August 1, 2024 for OS X (x64).
+
+This package is only compatible with .NET Core.
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.ChakraCore.Native.osx-x64/readme.txt b/src/JavaScriptEngineSwitcher.ChakraCore.Native.osx-x64/readme.txt
index a8f7604e..2b84ec5b 100644
--- a/src/JavaScriptEngineSwitcher.ChakraCore.Native.osx-x64/readme.txt
+++ b/src/JavaScriptEngineSwitcher.ChakraCore.Native.osx-x64/readme.txt
@@ -1,25 +1,26 @@
--------------------------------------------------------------------------------
- README file for JS Engine Switcher: ChakraCore for OS X x64 v3.0.0
+ README file for JS Engine Switcher: ChakraCore for OS X x64 v3.27.3
--------------------------------------------------------------------------------
- Copyright (c) 2013-2018 Andrey Taritsyn - http://www.taritsyn.ru
+ Copyright (c) 2013-2024 Andrey Taritsyn - http://www.taritsyn.ru
===========
DESCRIPTION
===========
This package complements the JavaScriptEngineSwitcher.ChakraCore package and
- contains the native implementation of ChakraCore version 1.11.4 for OS X (x64).
+ contains the native implementation of ChakraCore version of August 1, 2024
+ for OS X (x64).
This package is only compatible with .NET Core.
=============
RELEASE NOTES
=============
- ChakraCore was updated to version 1.11.4.
+ ChakraCore was updated to version of August 1, 2024.
=============
DOCUMENTATION
diff --git a/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-arm/JavaScriptEngineSwitcher.ChakraCore.Native.win-arm.csproj b/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-arm/JavaScriptEngineSwitcher.ChakraCore.Native.win-arm.csproj
index 7ca79d8d..4c281d94 100644
--- a/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-arm/JavaScriptEngineSwitcher.ChakraCore.Native.win-arm.csproj
+++ b/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-arm/JavaScriptEngineSwitcher.ChakraCore.Native.win-arm.csproj
@@ -1,11 +1,21 @@
-
- netstandard2.0
- false
- $(MSBuildProjectName).nuspec
-
+
+ JS Engine Switcher: ChakraCore for Windows (ARM)
+ 3.27.3
+ netstandard2.0
+
-
+
+
+
+
+
+ https://raw.githubusercontent.com/Taritsyn/JavaScriptEngineSwitcher/master/Icons/JavaScriptEngineSwitcher_ChakraCore_Logo128x128.png
+ ../../Icons/JavaScriptEngineSwitcher_ChakraCore_Logo128x128.png
+ This package complements the JavaScriptEngineSwitcher.ChakraCore package and contains the native implementation of ChakraCore for Windows (ARM).
+ $(PackageCommonTags);ChakraCore;Windows;ARM
+ ChakraCore was updated to version of August 1, 2024.
+
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-arm/JavaScriptEngineSwitcher.ChakraCore.Native.win-arm.nuspec b/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-arm/JavaScriptEngineSwitcher.ChakraCore.Native.win-arm.nuspec
index fce4d46f..bd55ce3c 100644
--- a/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-arm/JavaScriptEngineSwitcher.ChakraCore.Native.win-arm.nuspec
+++ b/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-arm/JavaScriptEngineSwitcher.ChakraCore.Native.win-arm.nuspec
@@ -1,31 +1,14 @@
-
-
- JavaScriptEngineSwitcher.ChakraCore.Native.win-arm
- 3.0.0
- JS Engine Switcher: ChakraCore for Windows (ARM)
- Andrey Taritsyn
- Andrey Taritsyn
- LICENSE.txt
- https://github.com/Taritsyn/JavaScriptEngineSwitcher
- https://raw.githubusercontent.com/Taritsyn/JavaScriptEngineSwitcher/master/Icons/JavaScriptEngineSwitcher_ChakraCore_Logo128x128.png
-
- false
- This package complements the JavaScriptEngineSwitcher.ChakraCore package and contains the native implementation of ChakraCore version 1.11.4 for Windows (ARM).
-
-This package is only compatible with .NET Core and .NET Framework 4.5.
- ChakraCore was updated to version 1.11.4.
- Copyright © 2013-2018 Andrey Taritsyn
- en-US
- JavaScriptEngineSwitcher JavaScript ECMAScript ChakraCore Windows ARM
-
-
-
-
-
-
-
-
-
-
+
+
+ $CommonMetadataElements$
+
+
+ $CommonFileElements$
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-arm/PACKAGE-DESCRIPTION.md b/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-arm/PACKAGE-DESCRIPTION.md
new file mode 100644
index 00000000..0e15d877
--- /dev/null
+++ b/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-arm/PACKAGE-DESCRIPTION.md
@@ -0,0 +1,3 @@
+This package complements the [JavaScriptEngineSwitcher.ChakraCore](https://www.nuget.org/packages/JavaScriptEngineSwitcher.ChakraCore) package and contains the native implementation of [ChakraCore](https://github.com/chakra-core/ChakraCore) version of August 1, 2024 for Windows (ARM).
+
+This package is only compatible with .NET Core and .NET Framework 4.5.
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-arm/build/JavaScriptEngineSwitcher.ChakraCore.Native.win-arm.props b/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-arm/build/JavaScriptEngineSwitcher.ChakraCore.Native.win-arm.props
index cb573475..bedb5851 100644
--- a/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-arm/build/JavaScriptEngineSwitcher.ChakraCore.Native.win-arm.props
+++ b/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-arm/build/JavaScriptEngineSwitcher.ChakraCore.Native.win-arm.props
@@ -1,10 +1,16 @@
-
-
-
- arm\ChakraCore.dll
- PreserveNewest
- False
-
-
+
+
+
+ arm/%(Filename)%(Extension)
+ PreserveNewest
+ False
+
+
+
+ %(Filename)%(Extension)
+ PreserveNewest
+ False
+
+
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-arm/readme.txt b/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-arm/readme.txt
index 848060f4..5f8ec868 100644
--- a/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-arm/readme.txt
+++ b/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-arm/readme.txt
@@ -1,25 +1,26 @@
--------------------------------------------------------------------------------
- README file for JS Engine Switcher: ChakraCore for Windows ARM v3.0.0
+ README file for JS Engine Switcher: ChakraCore for Windows ARM v3.27.3
--------------------------------------------------------------------------------
- Copyright (c) 2013-2018 Andrey Taritsyn - http://www.taritsyn.ru
+ Copyright (c) 2013-2024 Andrey Taritsyn - http://www.taritsyn.ru
===========
DESCRIPTION
===========
This package complements the JavaScriptEngineSwitcher.ChakraCore package and
- contains the native implementation of ChakraCore version 1.11.4 for Windows (ARM).
+ contains the native implementation of ChakraCore version of August 1, 2024
+ for Windows (ARM).
This package is only compatible with .NET Core and .NET Framework 4.5.
=============
RELEASE NOTES
=============
- ChakraCore was updated to version 1.11.4.
+ ChakraCore was updated to version of August 1, 2024.
=============
DOCUMENTATION
diff --git a/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-arm/tools/Install.ps1 b/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-arm/tools/Install.ps1
index 53714e11..9cbe0573 100644
--- a/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-arm/tools/Install.ps1
+++ b/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-arm/tools/Install.ps1
@@ -1,16 +1,13 @@
param($installPath, $toolsPath, $package, $project)
-if ($project.Type -eq "Web Site") {
- $runtimesDirectoryPath = Join-Path $installPath "runtimes"
- $projectDirectoryPath = $project.Properties.Item("FullPath").Value
- $binDirectoryPath = Join-Path $projectDirectoryPath "bin"
- $assemblyFileName = "ChakraCore.dll"
+if ($project.Type -eq 'Web Site') {
+ $projectDir = $project.Properties.Item('FullPath').Value
- $assemblyArmDestDirectoryPath = Join-Path $binDirectoryPath "arm"
- if (!(Test-Path $assemblyArmDestDirectoryPath)) {
- New-Item -ItemType Directory -Force -Path $assemblyArmDestDirectoryPath
- }
+ $assemblyDestDir = Join-Path $projectDir 'bin/arm'
+ if (!(Test-Path $assemblyDestDir)) {
+ New-Item -ItemType Directory -Force -Path $assemblyDestDir
+ }
- $assemblyArmSourceFilePath = Join-Path $runtimesDirectoryPath ("win-arm/native/" + $assemblyFileName)
- Copy-Item $assemblyArmSourceFilePath $assemblyArmDestDirectoryPath -Force
+ $assemblySourceFiles = Join-Path $installPath 'runtimes/win-arm/native/*.*'
+ Copy-Item $assemblySourceFiles $assemblyDestDir -Force
}
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-arm/tools/Uninstall.ps1 b/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-arm/tools/Uninstall.ps1
index 06e4d839..fe5bab11 100644
--- a/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-arm/tools/Uninstall.ps1
+++ b/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-arm/tools/Uninstall.ps1
@@ -1,14 +1,13 @@
param($installPath, $toolsPath, $package, $project)
-if ($project.Type -eq "Web Site") {
- $projectDirectoryPath = $project.Properties.Item("FullPath").Value
- $binDirectoryPath = Join-Path $projectDirectoryPath "bin"
- $assemblyFileName = "ChakraCore.dll"
+if ($project.Type -eq 'Web Site') {
+ $projectDir = $project.Properties.Item('FullPath').Value
+ $assemblySourceFiles = Join-Path $installPath 'runtimes/win-arm/native/*.*'
- $assemblyArmDirectoryPath = Join-Path $binDirectoryPath "arm"
- $assemblyArmFilePath = Join-Path $assemblyArmDirectoryPath $assemblyFileName
-
- if (Test-Path $assemblyArmFilePath) {
- Remove-Item $assemblyArmFilePath -Force
- }
+ foreach ($assemblySourceFileInfo in Get-Item($assemblySourceFiles)) {
+ $assemblyFile = Join-Path $projectDir "bin/arm/$($assemblySourceFileInfo.Name)"
+ if (Test-Path $assemblyFile) {
+ Remove-Item $assemblyFile -Force
+ }
+ }
}
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-arm64/JavaScriptEngineSwitcher.ChakraCore.Native.win-arm64.csproj b/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-arm64/JavaScriptEngineSwitcher.ChakraCore.Native.win-arm64.csproj
new file mode 100644
index 00000000..8e1d3262
--- /dev/null
+++ b/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-arm64/JavaScriptEngineSwitcher.ChakraCore.Native.win-arm64.csproj
@@ -0,0 +1,21 @@
+
+
+
+ JS Engine Switcher: ChakraCore for Windows (ARM64)
+ 3.27.3
+ netstandard2.0
+
+
+
+
+
+
+
+ https://raw.githubusercontent.com/Taritsyn/JavaScriptEngineSwitcher/master/Icons/JavaScriptEngineSwitcher_ChakraCore_Logo128x128.png
+ ../../Icons/JavaScriptEngineSwitcher_ChakraCore_Logo128x128.png
+ This package complements the JavaScriptEngineSwitcher.ChakraCore package and contains the native implementation of ChakraCore for Windows (ARM64).
+ $(PackageCommonTags);ChakraCore;Windows;ARM64
+ ChakraCore was updated to version of August 1, 2024.
+
+
+
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-arm64/JavaScriptEngineSwitcher.ChakraCore.Native.win-arm64.nuspec b/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-arm64/JavaScriptEngineSwitcher.ChakraCore.Native.win-arm64.nuspec
new file mode 100644
index 00000000..be7a9192
--- /dev/null
+++ b/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-arm64/JavaScriptEngineSwitcher.ChakraCore.Native.win-arm64.nuspec
@@ -0,0 +1,14 @@
+
+
+
+ $CommonMetadataElements$
+
+
+ $CommonFileElements$
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-arm64/PACKAGE-DESCRIPTION.md b/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-arm64/PACKAGE-DESCRIPTION.md
new file mode 100644
index 00000000..70ef2878
--- /dev/null
+++ b/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-arm64/PACKAGE-DESCRIPTION.md
@@ -0,0 +1,3 @@
+This package complements the [JavaScriptEngineSwitcher.ChakraCore](https://www.nuget.org/packages/JavaScriptEngineSwitcher.ChakraCore) package and contains the native implementation of [ChakraCore](https://github.com/chakra-core/ChakraCore) version of August 1, 2024 for Windows (ARM64).
+
+This package is only compatible with .NET Core and .NET Framework 4.5.
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-arm64/build/JavaScriptEngineSwitcher.ChakraCore.Native.win-arm64.props b/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-arm64/build/JavaScriptEngineSwitcher.ChakraCore.Native.win-arm64.props
new file mode 100644
index 00000000..f783db92
--- /dev/null
+++ b/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-arm64/build/JavaScriptEngineSwitcher.ChakraCore.Native.win-arm64.props
@@ -0,0 +1,16 @@
+
+
+
+
+ arm64/%(Filename)%(Extension)
+ PreserveNewest
+ False
+
+
+
+ %(Filename)%(Extension)
+ PreserveNewest
+ False
+
+
+
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-arm64/readme.txt b/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-arm64/readme.txt
new file mode 100644
index 00000000..d6809f35
--- /dev/null
+++ b/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-arm64/readme.txt
@@ -0,0 +1,29 @@
+
+
+ --------------------------------------------------------------------------------
+ README file for JS Engine Switcher: ChakraCore for Windows ARM64 v3.27.3
+
+ --------------------------------------------------------------------------------
+
+ Copyright (c) 2013-2024 Andrey Taritsyn - http://www.taritsyn.ru
+
+
+ ===========
+ DESCRIPTION
+ ===========
+ This package complements the JavaScriptEngineSwitcher.ChakraCore package and
+ contains the native implementation of ChakraCore version of August 1, 2024
+ for Windows (ARM64).
+
+ This package is only compatible with .NET Core and .NET Framework 4.5.
+
+ =============
+ RELEASE NOTES
+ =============
+ ChakraCore was updated to version of August 1, 2024.
+
+ =============
+ DOCUMENTATION
+ =============
+ See documentation on GitHub -
+ http://github.com/Taritsyn/JavaScriptEngineSwitcher
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-arm64/tools/Install.ps1 b/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-arm64/tools/Install.ps1
new file mode 100644
index 00000000..b16c3f75
--- /dev/null
+++ b/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-arm64/tools/Install.ps1
@@ -0,0 +1,13 @@
+param($installPath, $toolsPath, $package, $project)
+
+if ($project.Type -eq 'Web Site') {
+ $projectDir = $project.Properties.Item('FullPath').Value
+
+ $assemblyDestDir = Join-Path $projectDir 'bin/arm64'
+ if (!(Test-Path $assemblyDestDir)) {
+ New-Item -ItemType Directory -Force -Path $assemblyDestDir
+ }
+
+ $assemblySourceFiles = Join-Path $installPath 'runtimes/win-arm64/native/*.*'
+ Copy-Item $assemblySourceFiles $assemblyDestDir -Force
+}
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-arm64/tools/Uninstall.ps1 b/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-arm64/tools/Uninstall.ps1
new file mode 100644
index 00000000..f1fa4b6c
--- /dev/null
+++ b/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-arm64/tools/Uninstall.ps1
@@ -0,0 +1,13 @@
+param($installPath, $toolsPath, $package, $project)
+
+if ($project.Type -eq 'Web Site') {
+ $projectDir = $project.Properties.Item('FullPath').Value
+ $assemblySourceFiles = Join-Path $installPath 'runtimes/win-arm64/native/*.*'
+
+ foreach ($assemblySourceFileInfo in Get-Item($assemblySourceFiles)) {
+ $assemblyFile = Join-Path $projectDir "bin/arm64/$($assemblySourceFileInfo.Name)"
+ if (Test-Path $assemblyFile) {
+ Remove-Item $assemblyFile -Force
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-x64/JavaScriptEngineSwitcher.ChakraCore.Native.win-x64.csproj b/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-x64/JavaScriptEngineSwitcher.ChakraCore.Native.win-x64.csproj
index 7ca79d8d..26562fe9 100644
--- a/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-x64/JavaScriptEngineSwitcher.ChakraCore.Native.win-x64.csproj
+++ b/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-x64/JavaScriptEngineSwitcher.ChakraCore.Native.win-x64.csproj
@@ -1,11 +1,21 @@
-
- netstandard2.0
- false
- $(MSBuildProjectName).nuspec
-
+
+ JS Engine Switcher: ChakraCore for Windows (x64)
+ 3.27.3
+ netstandard2.0
+
-
+
+
+
+
+
+ https://raw.githubusercontent.com/Taritsyn/JavaScriptEngineSwitcher/master/Icons/JavaScriptEngineSwitcher_ChakraCore_Logo128x128.png
+ ../../Icons/JavaScriptEngineSwitcher_ChakraCore_Logo128x128.png
+ This package complements the JavaScriptEngineSwitcher.ChakraCore package and contains the native implementation of ChakraCore for Windows (x64).
+ $(PackageCommonTags);ChakraCore;Windows;x64
+ ChakraCore was updated to version of August 1, 2024.
+
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-x64/JavaScriptEngineSwitcher.ChakraCore.Native.win-x64.nuspec b/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-x64/JavaScriptEngineSwitcher.ChakraCore.Native.win-x64.nuspec
index 4c74049a..dd6618a8 100644
--- a/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-x64/JavaScriptEngineSwitcher.ChakraCore.Native.win-x64.nuspec
+++ b/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-x64/JavaScriptEngineSwitcher.ChakraCore.Native.win-x64.nuspec
@@ -1,32 +1,14 @@
-
-
- JavaScriptEngineSwitcher.ChakraCore.Native.win-x64
- 3.0.0
- JS Engine Switcher: ChakraCore for Windows (x64)
- Andrey Taritsyn
- Andrey Taritsyn
- LICENSE.txt
- https://github.com/Taritsyn/JavaScriptEngineSwitcher
- https://raw.githubusercontent.com/Taritsyn/JavaScriptEngineSwitcher/master/Icons/JavaScriptEngineSwitcher_ChakraCore_Logo128x128.png
-
- false
- This package complements the JavaScriptEngineSwitcher.ChakraCore package and contains the native implementation of ChakraCore version 1.11.4 for Windows (x64).
-
-For correct working of the ChakraCore require the Microsoft Visual C++ Redistributable for Visual Studio 2017.
- 1. ChakraCore was updated to version 1.11.4;
-2. Now the ChakraCore for Windows requires the Microsoft Visual C++ Redistributable for Visual Studio 2017.
- Copyright © 2013-2018 Andrey Taritsyn
- en-US
- JavaScriptEngineSwitcher JavaScript ECMAScript ChakraCore Windows x64
-
-
-
-
-
-
-
-
-
-
+
+
+ $CommonMetadataElements$
+
+
+ $CommonFileElements$
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-x64/PACKAGE-DESCRIPTION.md b/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-x64/PACKAGE-DESCRIPTION.md
new file mode 100644
index 00000000..0cd8c83c
--- /dev/null
+++ b/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-x64/PACKAGE-DESCRIPTION.md
@@ -0,0 +1 @@
+This package complements the [JavaScriptEngineSwitcher.ChakraCore](https://www.nuget.org/packages/JavaScriptEngineSwitcher.ChakraCore) package and contains the native implementation of [ChakraCore](https://github.com/chakra-core/ChakraCore) version of August 1, 2024 for Windows (x64).
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-x64/build/JavaScriptEngineSwitcher.ChakraCore.Native.win-x64.props b/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-x64/build/JavaScriptEngineSwitcher.ChakraCore.Native.win-x64.props
index 688cd3c3..5a187768 100644
--- a/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-x64/build/JavaScriptEngineSwitcher.ChakraCore.Native.win-x64.props
+++ b/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-x64/build/JavaScriptEngineSwitcher.ChakraCore.Native.win-x64.props
@@ -1,10 +1,16 @@
-
-
-
- x64\ChakraCore.dll
- PreserveNewest
- False
-
-
+
+
+
+ x64/%(Filename)%(Extension)
+ PreserveNewest
+ False
+
+
+
+ %(Filename)%(Extension)
+ PreserveNewest
+ False
+
+
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-x64/readme.txt b/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-x64/readme.txt
index 09e63f2f..6ac75fb7 100644
--- a/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-x64/readme.txt
+++ b/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-x64/readme.txt
@@ -1,35 +1,24 @@
--------------------------------------------------------------------------------
- README file for JS Engine Switcher: ChakraCore for Windows x64 v3.0.0
+ README file for JS Engine Switcher: ChakraCore for Windows x64 v3.27.3
--------------------------------------------------------------------------------
- Copyright (c) 2013-2018 Andrey Taritsyn - http://www.taritsyn.ru
+ Copyright (c) 2013-2024 Andrey Taritsyn - http://www.taritsyn.ru
===========
DESCRIPTION
===========
This package complements the JavaScriptEngineSwitcher.ChakraCore package and
- contains the native implementation of ChakraCore version 1.11.4 for Windows (x64).
-
- For correct working of the ChakraCore require the Microsoft Visual C++
- Redistributable for Visual Studio 2017.
+ contains the native implementation of ChakraCore version of August 1, 2024
+ for Windows (x64).
=============
RELEASE NOTES
=============
- 1. ChakraCore was updated to version 1.11.4;
- 2. Now the ChakraCore for Windows requires the Microsoft Visual C++
- Redistributable for Visual Studio 2017.
-
- ====================
- POST-INSTALL ACTIONS
- ====================
- If in your system does not `msvcp140.dll` assembly, then download and install
- the Microsoft Visual C++ Redistributable for Visual Studio 2017
- (https://www.visualstudio.com/downloads/#microsoft-visual-c-redistributable-for-visual-studio-2017).
+ ChakraCore was updated to version of August 1, 2024.
=============
DOCUMENTATION
diff --git a/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-x64/tools/Install.ps1 b/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-x64/tools/Install.ps1
index 2cc9d1b5..f44b2b4e 100644
--- a/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-x64/tools/Install.ps1
+++ b/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-x64/tools/Install.ps1
@@ -1,16 +1,13 @@
param($installPath, $toolsPath, $package, $project)
-if ($project.Type -eq "Web Site") {
- $runtimesDirectoryPath = Join-Path $installPath "runtimes"
- $projectDirectoryPath = $project.Properties.Item("FullPath").Value
- $binDirectoryPath = Join-Path $projectDirectoryPath "bin"
- $assemblyFileName = "ChakraCore.dll"
+if ($project.Type -eq 'Web Site') {
+ $projectDir = $project.Properties.Item('FullPath').Value
- $assembly64DestDirectoryPath = Join-Path $binDirectoryPath "x64"
- if (!(Test-Path $assembly64DestDirectoryPath)) {
- New-Item -ItemType Directory -Force -Path $assembly64DestDirectoryPath
- }
+ $assemblyDestDir = Join-Path $projectDir 'bin/x64'
+ if (!(Test-Path $assemblyDestDir)) {
+ New-Item -ItemType Directory -Force -Path $assemblyDestDir
+ }
- $assembly64SourceFilePath = Join-Path $runtimesDirectoryPath ("win-x64/native/" + $assemblyFileName)
- Copy-Item $assembly64SourceFilePath $assembly64DestDirectoryPath -Force
+ $assemblySourceFiles = Join-Path $installPath 'runtimes/win-x64/native/*.*'
+ Copy-Item $assemblySourceFiles $assemblyDestDir -Force
}
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-x64/tools/Uninstall.ps1 b/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-x64/tools/Uninstall.ps1
index 3dd489db..6443ab60 100644
--- a/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-x64/tools/Uninstall.ps1
+++ b/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-x64/tools/Uninstall.ps1
@@ -1,14 +1,13 @@
param($installPath, $toolsPath, $package, $project)
-if ($project.Type -eq "Web Site") {
- $projectDirectoryPath = $project.Properties.Item("FullPath").Value
- $binDirectoryPath = Join-Path $projectDirectoryPath "bin"
- $assemblyFileName = "ChakraCore.dll"
+if ($project.Type -eq 'Web Site') {
+ $projectDir = $project.Properties.Item('FullPath').Value
+ $assemblySourceFiles = Join-Path $installPath 'runtimes/win-x64/native/*.*'
- $assembly64DirectoryPath = Join-Path $binDirectoryPath "x64"
- $assembly64FilePath = Join-Path $assembly64DirectoryPath $assemblyFileName
-
- if (Test-Path $assembly64FilePath) {
- Remove-Item $assembly64FilePath -Force
- }
+ foreach ($assemblySourceFileInfo in Get-Item($assemblySourceFiles)) {
+ $assemblyFile = Join-Path $projectDir "bin/x64/$($assemblySourceFileInfo.Name)"
+ if (Test-Path $assemblyFile) {
+ Remove-Item $assemblyFile -Force
+ }
+ }
}
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-x86/JavaScriptEngineSwitcher.ChakraCore.Native.win-x86.csproj b/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-x86/JavaScriptEngineSwitcher.ChakraCore.Native.win-x86.csproj
index 7ca79d8d..b90cd8f5 100644
--- a/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-x86/JavaScriptEngineSwitcher.ChakraCore.Native.win-x86.csproj
+++ b/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-x86/JavaScriptEngineSwitcher.ChakraCore.Native.win-x86.csproj
@@ -1,11 +1,21 @@
-
- netstandard2.0
- false
- $(MSBuildProjectName).nuspec
-
+
+ JS Engine Switcher: ChakraCore for Windows (x86)
+ 3.27.3
+ netstandard2.0
+
-
+
+
+
+
+
+ https://raw.githubusercontent.com/Taritsyn/JavaScriptEngineSwitcher/master/Icons/JavaScriptEngineSwitcher_ChakraCore_Logo128x128.png
+ ../../Icons/JavaScriptEngineSwitcher_ChakraCore_Logo128x128.png
+ This package complements the JavaScriptEngineSwitcher.ChakraCore package and contains the native implementation of ChakraCore for Windows (x86).
+ $(PackageCommonTags);ChakraCore;Windows;x86
+ ChakraCore was updated to version of August 1, 2024.
+
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-x86/JavaScriptEngineSwitcher.ChakraCore.Native.win-x86.nuspec b/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-x86/JavaScriptEngineSwitcher.ChakraCore.Native.win-x86.nuspec
index c1491298..8b0bc5e3 100644
--- a/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-x86/JavaScriptEngineSwitcher.ChakraCore.Native.win-x86.nuspec
+++ b/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-x86/JavaScriptEngineSwitcher.ChakraCore.Native.win-x86.nuspec
@@ -1,32 +1,14 @@
-
-
- JavaScriptEngineSwitcher.ChakraCore.Native.win-x86
- 3.0.0
- JS Engine Switcher: ChakraCore for Windows (x86)
- Andrey Taritsyn
- Andrey Taritsyn
- LICENSE.txt
- https://github.com/Taritsyn/JavaScriptEngineSwitcher
- https://raw.githubusercontent.com/Taritsyn/JavaScriptEngineSwitcher/master/Icons/JavaScriptEngineSwitcher_ChakraCore_Logo128x128.png
-
- false
- This package complements the JavaScriptEngineSwitcher.ChakraCore package and contains the native implementation of ChakraCore version 1.11.4 for Windows (x86).
-
-For correct working of the ChakraCore require the Microsoft Visual C++ Redistributable for Visual Studio 2017.
- 1. ChakraCore was updated to version 1.11.4;
-2. Now the ChakraCore for Windows requires the Microsoft Visual C++ Redistributable for Visual Studio 2017.
- Copyright © 2013-2018 Andrey Taritsyn
- en-US
- JavaScriptEngineSwitcher JavaScript ECMAScript ChakraCore Windows x86
-
-
-
-
-
-
-
-
-
-
+
+
+ $CommonMetadataElements$
+
+
+ $CommonFileElements$
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-x86/PACKAGE-DESCRIPTION.md b/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-x86/PACKAGE-DESCRIPTION.md
new file mode 100644
index 00000000..b6951ff8
--- /dev/null
+++ b/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-x86/PACKAGE-DESCRIPTION.md
@@ -0,0 +1 @@
+This package complements the [JavaScriptEngineSwitcher.ChakraCore](https://www.nuget.org/packages/JavaScriptEngineSwitcher.ChakraCore) package and contains the native implementation of [ChakraCore](https://github.com/chakra-core/ChakraCore) version of August 1, 2024 for Windows (x86).
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-x86/build/JavaScriptEngineSwitcher.ChakraCore.Native.win-x86.props b/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-x86/build/JavaScriptEngineSwitcher.ChakraCore.Native.win-x86.props
index 9c46dcc4..be3fd380 100644
--- a/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-x86/build/JavaScriptEngineSwitcher.ChakraCore.Native.win-x86.props
+++ b/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-x86/build/JavaScriptEngineSwitcher.ChakraCore.Native.win-x86.props
@@ -1,10 +1,16 @@
-
-
-
- x86\ChakraCore.dll
- PreserveNewest
- False
-
-
+
+
+
+ x86/%(Filename)%(Extension)
+ PreserveNewest
+ False
+
+
+
+ %(Filename)%(Extension)
+ PreserveNewest
+ False
+
+
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-x86/readme.txt b/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-x86/readme.txt
index 26480053..ff0c8d12 100644
--- a/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-x86/readme.txt
+++ b/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-x86/readme.txt
@@ -1,35 +1,24 @@
--------------------------------------------------------------------------------
- README file for JS Engine Switcher: ChakraCore for Windows x86 v3.0.0
+ README file for JS Engine Switcher: ChakraCore for Windows x86 v3.27.3
--------------------------------------------------------------------------------
- Copyright (c) 2013-2018 Andrey Taritsyn - http://www.taritsyn.ru
+ Copyright (c) 2013-2024 Andrey Taritsyn - http://www.taritsyn.ru
===========
DESCRIPTION
===========
This package complements the JavaScriptEngineSwitcher.ChakraCore package and
- contains the native implementation of ChakraCore version 1.11.4 for Windows (x86).
-
- For correct working of the ChakraCore require the Microsoft Visual C++
- Redistributable for Visual Studio 2017.
+ contains the native implementation of ChakraCore version of August 1, 2024
+ for Windows (x86).
=============
RELEASE NOTES
=============
- 1. ChakraCore was updated to version 1.11.4;
- 2. Now the ChakraCore for Windows requires the Microsoft Visual C++
- Redistributable for Visual Studio 2017.
-
- ====================
- POST-INSTALL ACTIONS
- ====================
- If in your system does not `msvcp140.dll` assembly, then download and install
- the Microsoft Visual C++ Redistributable for Visual Studio 2017
- (https://www.visualstudio.com/downloads/#microsoft-visual-c-redistributable-for-visual-studio-2017).
+ ChakraCore was updated to version of August 1, 2024.
=============
DOCUMENTATION
diff --git a/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-x86/tools/Install.ps1 b/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-x86/tools/Install.ps1
index c6b89ebd..4a9e29e9 100644
--- a/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-x86/tools/Install.ps1
+++ b/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-x86/tools/Install.ps1
@@ -1,16 +1,13 @@
param($installPath, $toolsPath, $package, $project)
-if ($project.Type -eq "Web Site") {
- $runtimesDirectoryPath = Join-Path $installPath "runtimes"
- $projectDirectoryPath = $project.Properties.Item("FullPath").Value
- $binDirectoryPath = Join-Path $projectDirectoryPath "bin"
- $assemblyFileName = "ChakraCore.dll"
+if ($project.Type -eq 'Web Site') {
+ $projectDir = $project.Properties.Item('FullPath').Value
- $assembly32DestDirectoryPath = Join-Path $binDirectoryPath "x86"
- if (!(Test-Path $assembly32DestDirectoryPath)) {
- New-Item -ItemType Directory -Force -Path $assembly32DestDirectoryPath
- }
+ $assemblyDestDir = Join-Path $projectDir 'bin/x86'
+ if (!(Test-Path $assemblyDestDir)) {
+ New-Item -ItemType Directory -Force -Path $assemblyDestDir
+ }
- $assembly32SourceFilePath = Join-Path $runtimesDirectoryPath ("win-x86/native/" + $assemblyFileName)
- Copy-Item $assembly32SourceFilePath $assembly32DestDirectoryPath -Force
+ $assemblySourceFiles = Join-Path $installPath 'runtimes/win-x86/native/*.*'
+ Copy-Item $assemblySourceFiles $assemblyDestDir -Force
}
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-x86/tools/Uninstall.ps1 b/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-x86/tools/Uninstall.ps1
index 0838c687..6402ab1d 100644
--- a/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-x86/tools/Uninstall.ps1
+++ b/src/JavaScriptEngineSwitcher.ChakraCore.Native.win-x86/tools/Uninstall.ps1
@@ -1,14 +1,13 @@
param($installPath, $toolsPath, $package, $project)
-if ($project.Type -eq "Web Site") {
- $projectDirectoryPath = $project.Properties.Item("FullPath").Value
- $binDirectoryPath = Join-Path $projectDirectoryPath "bin"
- $assemblyFileName = "ChakraCore.dll"
+if ($project.Type -eq 'Web Site') {
+ $projectDir = $project.Properties.Item('FullPath').Value
+ $assemblySourceFiles = Join-Path $installPath 'runtimes/win-x86/native/*.*'
- $assembly32DirectoryPath = Join-Path $binDirectoryPath "x86"
- $assembly32FilePath = Join-Path $assembly32DirectoryPath $assemblyFileName
-
- if (Test-Path $assembly32FilePath) {
- Remove-Item $assembly32FilePath -Force
- }
+ foreach ($assemblySourceFileInfo in Get-Item($assemblySourceFiles)) {
+ $assemblyFile = Join-Path $projectDir "bin/x86/$($assemblySourceFileInfo.Name)"
+ if (Test-Path $assemblyFile) {
+ Remove-Item $assemblyFile -Force
+ }
+ }
}
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.ChakraCore.Native.win8-arm/JavaScriptEngineSwitcher.ChakraCore.Native.win8-arm.csproj b/src/JavaScriptEngineSwitcher.ChakraCore.Native.win8-arm/JavaScriptEngineSwitcher.ChakraCore.Native.win8-arm.csproj
deleted file mode 100644
index 7ca79d8d..00000000
--- a/src/JavaScriptEngineSwitcher.ChakraCore.Native.win8-arm/JavaScriptEngineSwitcher.ChakraCore.Native.win8-arm.csproj
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
- netstandard2.0
- false
- $(MSBuildProjectName).nuspec
-
-
-
-
-
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.ChakraCore.Native.win8-arm/JavaScriptEngineSwitcher.ChakraCore.Native.win8-arm.nuspec b/src/JavaScriptEngineSwitcher.ChakraCore.Native.win8-arm/JavaScriptEngineSwitcher.ChakraCore.Native.win8-arm.nuspec
deleted file mode 100644
index 5b3d3f0e..00000000
--- a/src/JavaScriptEngineSwitcher.ChakraCore.Native.win8-arm/JavaScriptEngineSwitcher.ChakraCore.Native.win8-arm.nuspec
+++ /dev/null
@@ -1,29 +0,0 @@
-
-
-
- JavaScriptEngineSwitcher.ChakraCore.Native.win8-arm
- 3.0.0
- JS Engine Switcher: ChakraCore for Windows (ARM)
- Andrey Taritsyn
- Andrey Taritsyn
- LICENSE.txt
- https://github.com/Taritsyn/JavaScriptEngineSwitcher
- https://raw.githubusercontent.com/Taritsyn/JavaScriptEngineSwitcher/master/Icons/JavaScriptEngineSwitcher_ChakraCore_Logo128x128.png
-
- false
- This package is deprecated. Instead, it is recommended to use a 'JavaScriptEngineSwitcher.ChakraCore.Native.win-arm' package.
- ChakraCore was updated to version 1.11.4.
- Copyright © 2013-2018 Andrey Taritsyn
- en-US
- JavaScriptEngineSwitcher JavaScript ECMAScript ChakraCore Windows ARM
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.ChakraCore.Native.win8-arm/build/JavaScriptEngineSwitcher.ChakraCore.Native.win8-arm.props b/src/JavaScriptEngineSwitcher.ChakraCore.Native.win8-arm/build/JavaScriptEngineSwitcher.ChakraCore.Native.win8-arm.props
deleted file mode 100644
index f821c0c2..00000000
--- a/src/JavaScriptEngineSwitcher.ChakraCore.Native.win8-arm/build/JavaScriptEngineSwitcher.ChakraCore.Native.win8-arm.props
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-
- arm\ChakraCore.dll
- PreserveNewest
- False
-
-
-
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.ChakraCore.Native.win8-arm/tools/Install.ps1 b/src/JavaScriptEngineSwitcher.ChakraCore.Native.win8-arm/tools/Install.ps1
deleted file mode 100644
index a499482d..00000000
--- a/src/JavaScriptEngineSwitcher.ChakraCore.Native.win8-arm/tools/Install.ps1
+++ /dev/null
@@ -1,16 +0,0 @@
-param($installPath, $toolsPath, $package, $project)
-
-if ($project.Type -eq "Web Site") {
- $runtimesDirectoryPath = Join-Path $installPath "runtimes"
- $projectDirectoryPath = $project.Properties.Item("FullPath").Value
- $binDirectoryPath = Join-Path $projectDirectoryPath "bin"
- $assemblyFileName = "ChakraCore.dll"
-
- $assemblyArmDestDirectoryPath = Join-Path $binDirectoryPath "arm"
- if (!(Test-Path $assemblyArmDestDirectoryPath)) {
- New-Item -ItemType Directory -Force -Path $assemblyArmDestDirectoryPath
- }
-
- $assemblyArmSourceFilePath = Join-Path $runtimesDirectoryPath ("win8-arm/native/" + $assemblyFileName)
- Copy-Item $assemblyArmSourceFilePath $assemblyArmDestDirectoryPath -Force
-}
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.ChakraCore.Native.win8-arm/tools/Uninstall.ps1 b/src/JavaScriptEngineSwitcher.ChakraCore.Native.win8-arm/tools/Uninstall.ps1
deleted file mode 100644
index 06e4d839..00000000
--- a/src/JavaScriptEngineSwitcher.ChakraCore.Native.win8-arm/tools/Uninstall.ps1
+++ /dev/null
@@ -1,14 +0,0 @@
-param($installPath, $toolsPath, $package, $project)
-
-if ($project.Type -eq "Web Site") {
- $projectDirectoryPath = $project.Properties.Item("FullPath").Value
- $binDirectoryPath = Join-Path $projectDirectoryPath "bin"
- $assemblyFileName = "ChakraCore.dll"
-
- $assemblyArmDirectoryPath = Join-Path $binDirectoryPath "arm"
- $assemblyArmFilePath = Join-Path $assemblyArmDirectoryPath $assemblyFileName
-
- if (Test-Path $assemblyArmFilePath) {
- Remove-Item $assemblyArmFilePath -Force
- }
-}
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.ChakraCore/AssemblyResolver.cs b/src/JavaScriptEngineSwitcher.ChakraCore/AssemblyResolver.cs
index 88975046..721caa7a 100644
--- a/src/JavaScriptEngineSwitcher.ChakraCore/AssemblyResolver.cs
+++ b/src/JavaScriptEngineSwitcher.ChakraCore/AssemblyResolver.cs
@@ -1,4 +1,4 @@
-#if NETFULL
+#if NETFRAMEWORK
using System;
using System.IO;
using System.Runtime.InteropServices;
@@ -37,14 +37,20 @@ public static void Initialize()
baseDirectoryPath = currentDomain.BaseDirectory;
}
+ Architecture architecture = RuntimeInformation.OSArchitecture;
string platform;
- if (RuntimeInformation.OSArchitecture == Architecture.Arm)
+
+ if (architecture == Architecture.X64 || architecture == Architecture.X86)
+ {
+ platform = Utils.Is64BitProcess() ? "x64" : "x86";
+ }
+ else if (architecture == Architecture.Arm64 || architecture == Architecture.Arm)
{
- platform = "arm";
+ platform = Utils.Is64BitProcess() ? "arm64" : "arm";
}
else
{
- platform = Utils.Is64BitProcess() ? "x64" : "x86";
+ return;
}
string assemblyFileName = DllName.ForWindows;
diff --git a/src/JavaScriptEngineSwitcher.ChakraCore/ChakraCoreJsEngine.cs b/src/JavaScriptEngineSwitcher.ChakraCore/ChakraCoreJsEngine.cs
index 35367f68..9a545b96 100644
--- a/src/JavaScriptEngineSwitcher.ChakraCore/ChakraCoreJsEngine.cs
+++ b/src/JavaScriptEngineSwitcher.ChakraCore/ChakraCoreJsEngine.cs
@@ -1,8 +1,7 @@
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Reflection;
+#if NET45_OR_GREATER || NETSTANDARD
using System.Runtime.InteropServices;
+#endif
using System.Text;
using AdvancedStringBuilder;
@@ -11,6 +10,7 @@
#endif
using JavaScriptEngineSwitcher.Core;
+using JavaScriptEngineSwitcher.Core.Constants;
using JavaScriptEngineSwitcher.Core.Extensions;
using JavaScriptEngineSwitcher.Core.Utilities;
@@ -29,7 +29,6 @@
using WrapperUsageException = JavaScriptEngineSwitcher.Core.JsUsageException;
using JavaScriptEngineSwitcher.ChakraCore.Constants;
-using JavaScriptEngineSwitcher.ChakraCore.Helpers;
using JavaScriptEngineSwitcher.ChakraCore.JsRt;
using JavaScriptEngineSwitcher.ChakraCore.Resources;
@@ -54,7 +53,7 @@ public sealed class ChakraCoreJsEngine : JsEngineBase
///
/// Version of original JS engine
///
- private const string EngineVersion = "1.11.4";
+ private const string EngineVersion = "Aug 1, 2024";
///
/// Instance of JS runtime
@@ -72,25 +71,15 @@ public sealed class ChakraCoreJsEngine : JsEngineBase
private JsSourceContext _jsSourceContext = JsSourceContext.FromIntPtr(IntPtr.Zero);
///
- /// Set of external objects
- ///
- private HashSet
internal static class ReflectionHelpers
{
+ private static readonly PropertyInfo[] _disallowedProperties =
+ {
+ typeof(Delegate).GetProperty("Method"),
+ typeof(Exception).GetProperty("TargetSite")
+ };
+
+ private static readonly MethodInfo[] _disallowedMethods =
+ {
+ typeof(object).GetMethod("GetType"),
+ typeof(Exception).GetMethod("GetType")
+ };
+
+
public static BindingFlags GetDefaultBindingFlags(bool instance)
{
BindingFlags bindingFlags = BindingFlags.Public;
@@ -27,8 +47,41 @@ public static BindingFlags GetDefaultBindingFlags(bool instance)
return bindingFlags;
}
+ public static bool IsAllowedProperty(PropertyInfo property)
+ {
+ bool isAllowed = !_disallowedProperties.Contains(property, MemberComparer.Instance);
+
+ return isAllowed;
+ }
+
+ public static bool IsAllowedMethod(MethodInfo method)
+ {
+ bool isAllowed = !_disallowedMethods.Contains(method, MemberComparer.Instance);
+
+ return isAllowed;
+ }
+
+ public static bool IsFullyFledgedMethod(MethodInfo method)
+ {
+ if (!method.Attributes.HasFlag(MethodAttributes.SpecialName))
+ {
+ return true;
+ }
+
+ string name = method.Name;
+ bool isFullyFledged = !(name.StartsWith("get_", StringComparison.Ordinal)
+ || name.StartsWith("set_", StringComparison.Ordinal));
+
+ return isFullyFledged;
+ }
+
public static void FixFieldValueType(ref object value, FieldInfo field)
{
+ if (value == null)
+ {
+ return;
+ }
+
Type valueType = value.GetType();
Type fieldType = field.FieldType;
@@ -45,6 +98,11 @@ public static void FixFieldValueType(ref object value, FieldInfo field)
public static void FixPropertyValueType(ref object value, PropertyInfo property)
{
+ if (value == null)
+ {
+ return;
+ }
+
Type valueType = value.GetType();
Type propertyType = property.PropertyType;
@@ -62,10 +120,26 @@ public static void FixPropertyValueType(ref object value, PropertyInfo property)
public static void FixArgumentTypes(ref object[] argValues, ParameterInfo[] parameters)
{
int argCount = argValues.Length;
+ if (argCount == 0)
+ {
+ return;
+ }
+
+ int parameterCount = parameters.Length;
for (int argIndex = 0; argIndex < argCount; argIndex++)
{
+ if (argIndex >= parameterCount)
+ {
+ break;
+ }
+
object argValue = argValues[argIndex];
+ if (argValue == null)
+ {
+ continue;
+ }
+
Type argType = argValue.GetType();
ParameterInfo parameter = parameters[argIndex];
@@ -85,54 +159,72 @@ public static void FixArgumentTypes(ref object[] argValues, ParameterInfo[] para
public static MethodBase GetBestFitMethod(MethodBase[] methods, object[] argValues)
{
- MethodWithMetadata[] methodCandidates = methods
- .Select(m => new MethodWithMetadata
- {
- Method = m,
- ParameterTypes = m.GetParameters()
- .Select(p => p.ParameterType)
- .ToArray()
- })
- .ToArray()
- ;
- int argCount = argValues.Length;
- MethodWithMetadata[] sameArityMethods = methodCandidates
- .Where(m => m.ParameterTypes.Length == argCount)
- .ToArray()
- ;
-
- int sameArityMethodCount = sameArityMethods.Length;
- if (sameArityMethodCount == 0)
+ int methodCount = methods.Length;
+ if (methodCount == 0)
{
return null;
}
- Type[] argTypes = argValues
- .Select(a => a.GetType())
- .ToArray()
- ;
- var compatibleMethods = new List();
-
- for (int methodIndex = 0; methodIndex < sameArityMethodCount; methodIndex++)
+ if (methodCount == 1)
{
- MethodWithMetadata method = sameArityMethods[methodIndex];
- ushort compatibilityScore;
+ MethodBase method = methods[0];
+ ParameterInfo[] parameters = method.GetParameters();
- if (CompareParameterTypes(argValues, argTypes, method.ParameterTypes, out compatibilityScore))
+ MethodBase bestFitMethod = null;
+ if (CompareParameterTypes(argValues, parameters, out _))
{
- method.CompatibilityScore = compatibilityScore;
- compatibleMethods.Add(method);
+ bestFitMethod = method;
}
+
+ return bestFitMethod;
}
- int compatibleMethodCount = compatibleMethods.Count;
- if (compatibleMethodCount > 0)
+ MethodWithMetadata[] compatibleMethods = null;
+ int compatibleMethodCount = 0;
+
+ var methodArrayPool = ArrayPool.Shared;
+ MethodWithMetadata[] buffer = methodArrayPool.Rent(methodCount);
+
+ try
{
- if (compatibleMethodCount == 1)
+ for (int methodIndex = 0; methodIndex < methodCount; methodIndex++)
{
- return compatibleMethods[0].Method;
+ MethodBase method = methods[methodIndex];
+ ParameterInfo[] parameters = method.GetParameters();
+ ushort compatibilityScore;
+
+ if (CompareParameterTypes(argValues, parameters, out compatibilityScore))
+ {
+ compatibleMethodCount++;
+
+ int compatibleMethodIndex = compatibleMethodCount - 1;
+ buffer[compatibleMethodIndex] = new MethodWithMetadata
+ {
+ Method = method,
+ CompatibilityScore = compatibilityScore
+ };
+ }
}
+ if (compatibleMethodCount > 0)
+ {
+ if (compatibleMethodCount == 1)
+ {
+ return buffer[0].Method;
+ }
+
+ compatibleMethods = new MethodWithMetadata[compatibleMethodCount];
+ Array.Copy(buffer, compatibleMethods, compatibleMethodCount);
+ }
+ }
+ finally
+ {
+ bool clearArray = compatibleMethodCount > 0;
+ methodArrayPool.Return(buffer, clearArray);
+ }
+
+ if (compatibleMethods != null)
+ {
MethodWithMetadata bestFitMethod = compatibleMethods
.OrderByDescending(m => m.CompatibilityScore)
.First()
@@ -144,24 +236,29 @@ public static MethodBase GetBestFitMethod(MethodBase[] methods, object[] argValu
return null;
}
- private static bool CompareParameterTypes(object[] argValues, Type[] argTypes, Type[] parameterTypes,
+ private static bool CompareParameterTypes(object[] argValues, ParameterInfo[] parameters,
out ushort compatibilityScore)
{
- int argValueCount = argValues.Length;
- int argTypeCount = argTypes.Length;
- int parameterCount = parameterTypes.Length;
+ int argCount = argValues.Length;
+ int parameterCount = parameters.Length;
compatibilityScore = 0;
- if (argValueCount != argTypeCount || argTypeCount != parameterCount)
+ if (argCount != parameterCount)
{
return false;
}
+ else if (argCount == 0)
+ {
+ compatibilityScore = ushort.MaxValue;
+ return true;
+ }
- for (int argIndex = 0; argIndex < argValueCount; argIndex++)
+ for (int argIndex = 0; argIndex < argCount; argIndex++)
{
object argValue = argValues[argIndex];
- Type argType = argTypes[argIndex];
- Type parameterType = parameterTypes[argIndex];
+ Type argType = argValue != null ? argValue.GetType() : typeof(object);
+ ParameterInfo parameter = parameters[argIndex];
+ Type parameterType = parameter.ParameterType;
if (argType == parameterType)
{
@@ -177,8 +274,6 @@ private static bool CompareParameterTypes(object[] argValues, Type[] argTypes, T
{
return false;
}
-
- continue;
}
}
@@ -186,21 +281,56 @@ private static bool CompareParameterTypes(object[] argValues, Type[] argTypes, T
}
- private sealed class MethodWithMetadata
+ private sealed class MemberComparer : EqualityComparer
+ where T : MemberInfo
{
- public MethodBase Method
+ public static MemberComparer Instance { get; } = new MemberComparer();
+
+
+ private MemberComparer()
+ { }
+
+
+ #region MemberComparer overrides
+
+ public override bool Equals(T x, T y)
{
- get;
- set;
+ if (x == null && y == null)
+ {
+ return true;
+ }
+ else if (x == null || y == null)
+ {
+ return false;
+ }
+
+ return x.Module == y.Module
+#if !NETSTANDARD1_3
+ && x.MetadataToken == y.MetadataToken
+#else
+ && x.DeclaringType == y.DeclaringType
+ && x.Name == y.Name
+#endif
+ ;
+ }
+
+ public override int GetHashCode(T obj)
+ {
+ return obj != null ? obj.GetHashCode() : 0;
}
- public Type[] ParameterTypes
+ #endregion
+ }
+
+ private sealed class MethodWithMetadata
+ {
+ public MethodBase Method
{
get;
set;
}
- /// TODO: In future will need to change type to double
+ /// TODO: In future will need to change type to double
public ushort CompatibilityScore
{
get;
diff --git a/src/JavaScriptEngineSwitcher.ChakraCore/JavaScriptEngineSwitcher.ChakraCore.csproj b/src/JavaScriptEngineSwitcher.ChakraCore/JavaScriptEngineSwitcher.ChakraCore.csproj
index 889919b6..81b05505 100644
--- a/src/JavaScriptEngineSwitcher.ChakraCore/JavaScriptEngineSwitcher.ChakraCore.csproj
+++ b/src/JavaScriptEngineSwitcher.ChakraCore/JavaScriptEngineSwitcher.ChakraCore.csproj
@@ -1,93 +1,68 @@
-
- JS Engine Switcher: ChakraCore
- 3.0.0
- net40-client;net45;net471;netstandard1.3;netstandard2.0;netcoreapp2.1
- 1.6.0
- Library
- true
- true
- $(NoWarn);CS1591;NU5125
- true
- true
- JavaScriptEngineSwitcher.ChakraCore contains adapter `ChakraCoreJsEngine` (wrapper for the ChakraCore (http://github.com/Microsoft/ChakraCore)). Project was based on the code of Chakra-Samples (http://github.com/Microsoft/Chakra-Samples) and jsrt-dotnet (http://github.com/robpaveza/jsrt-dotnet).
+
+ JS Engine Switcher: ChakraCore
+ 3.30.4
+ net40-client;net45;net471;netstandard1.3;netstandard2.0;netstandard2.1
+ 1.6.0
+ Library
+ true
+ true
+ $(NoWarn);CS1591;NETSDK1215;NU1903
+ false
+ true
+ true
+
-This package does not contain the native implementations of ChakraCore. Therefore, you need to choose and install the most appropriate package(s) for your platform. The following packages are available:
+
+
+
+
- * JavaScriptEngineSwitcher.ChakraCore.Native.win-x86
- * JavaScriptEngineSwitcher.ChakraCore.Native.win-x64
- * JavaScriptEngineSwitcher.ChakraCore.Native.win-arm
- * JavaScriptEngineSwitcher.ChakraCore.Native.linux-x64
- * JavaScriptEngineSwitcher.ChakraCore.Native.osx-x64
- https://raw.githubusercontent.com/Taritsyn/JavaScriptEngineSwitcher/master/Icons/JavaScriptEngineSwitcher_ChakraCore_Logo128x128.png
- JavaScriptEngineSwitcher;JavaScript;ECMAScript;ChakraCore
- 1. ChakraCore was updated to version 1.11.4;
-2. No longer used the old ChakraCore API for Windows (Internet Explorer-like API);
-3. Added a ability to interrupt execution of the script;
-4. Added a ability to pre-compile scripts;
-5. In configuration settings of the ChakraCore JS engine was added one new property - `MaxStackSize` (default `492` or `984` KB);
-6. Added support of .NET Framework 4.7.1, .NET Standard 2.0 and .NET Core App 2.1.
-
+
+ https://raw.githubusercontent.com/Taritsyn/JavaScriptEngineSwitcher/master/Icons/JavaScriptEngineSwitcher_ChakraCore_Logo128x128.png
+ ../../Icons/JavaScriptEngineSwitcher_ChakraCore_Logo128x128.png
+ JavaScriptEngineSwitcher.ChakraCore contains a `ChakraCoreJsEngine` adapter (wrapper for the ChakraCore).
+ $(PackageCommonTags);ChakraCore
+ Optimized a memory usage in the `ReflectionHelpers.GetBestFitMethod` method.
+
-
-
-
-
+
+
-
-
-
+
+
-
-
+
+
+
+
-
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
+
-
-
-
-
+
+
+
+
+
-
-
- readme.txt
- true
-
-
- chakra-samples-license.txt
- true
- false
-
-
- dotnet-corefx-license.txt
- true
- false
-
-
- jsrt-dotnet-license.txt
- true
- false
-
-
-
-
-
-
+
+
+
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.ChakraCore/JsEngineFactoryCollectionExtensions.cs b/src/JavaScriptEngineSwitcher.ChakraCore/JsEngineFactoryCollectionExtensions.cs
index 53bdeb70..ad6b2b02 100644
--- a/src/JavaScriptEngineSwitcher.ChakraCore/JsEngineFactoryCollectionExtensions.cs
+++ b/src/JavaScriptEngineSwitcher.ChakraCore/JsEngineFactoryCollectionExtensions.cs
@@ -11,10 +11,10 @@ public static class JsEngineFactoryCollectionExtensions
{
///
/// Adds a instance of to
- /// the specified
+ /// the specified
///
- /// Instance of
- /// Instance of
+ /// Instance of
+ /// Instance of
public static JsEngineFactoryCollection AddChakraCore(this JsEngineFactoryCollection source)
{
if (source == null)
@@ -27,11 +27,11 @@ public static JsEngineFactoryCollection AddChakraCore(this JsEngineFactoryCollec
///
/// Adds a instance of to
- /// the specified
+ /// the specified
///
- /// Instance of
+ /// Instance of
/// The delegate to configure the provided
- /// Instance of
+ /// Instance of
public static JsEngineFactoryCollection AddChakraCore(this JsEngineFactoryCollection source,
Action configure)
{
@@ -53,11 +53,11 @@ public static JsEngineFactoryCollection AddChakraCore(this JsEngineFactoryCollec
///
/// Adds a instance of to
- /// the specified
+ /// the specified
///
- /// Instance of
+ /// Instance of
/// Settings of the ChakraCore JS engine
- /// Instance of
+ /// Instance of
public static JsEngineFactoryCollection AddChakraCore(this JsEngineFactoryCollection source, ChakraCoreSettings settings)
{
if (source == null)
diff --git a/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/DefaultExternalBufferFinalizeCallback.cs b/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/DefaultExternalBufferFinalizeCallback.cs
index 9894faff..b5cda03a 100644
--- a/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/DefaultExternalBufferFinalizeCallback.cs
+++ b/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/DefaultExternalBufferFinalizeCallback.cs
@@ -10,6 +10,6 @@ internal static class DefaultExternalBufferFinalizeCallback
///
/// Gets a instance of default callback for finalization of external buffer
///
- public static readonly JsObjectFinalizeCallback Instance = Marshal.FreeHGlobal;
+ public static readonly JsFinalizeCallback Instance = Marshal.FreeHGlobal;
}
}
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/Embedding/EmbeddedItem.cs b/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/Embedding/EmbeddedItem.cs
new file mode 100644
index 00000000..d9870598
--- /dev/null
+++ b/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/Embedding/EmbeddedItem.cs
@@ -0,0 +1,119 @@
+using System;
+using System.Collections.Generic;
+
+using JavaScriptEngineSwitcher.Core.Utilities;
+
+namespace JavaScriptEngineSwitcher.ChakraCore.JsRt.Embedding
+{
+ ///
+ /// Embedded item
+ ///
+ internal abstract class EmbeddedItem : IDisposable
+ {
+ ///
+ /// Host type
+ ///
+ private Type _hostType;
+
+ ///
+ /// Instance of host type
+ ///
+ private object _hostObject;
+
+ ///
+ /// JavaScript value created from an host item
+ ///
+ private readonly JsValue _scriptValue;
+
+ ///
+ /// List of native functions, that used to access to members of host item
+ ///
+ private IList _nativeFunctions;
+
+ ///
+ /// Flag indicating whether this object is disposed
+ ///
+ private InterlockedStatedFlag _disposedFlag = new InterlockedStatedFlag();
+
+ ///
+ /// Gets a host type
+ ///
+ public Type HostType
+ {
+ get { return _hostType; }
+ }
+
+ ///
+ /// Gets a instance of host type
+ ///
+ public object HostObject
+ {
+ get { return _hostObject; }
+ }
+
+ ///
+ /// Gets a JavaScript value created from an host item
+ ///
+ public JsValue ScriptValue
+ {
+ get { return _scriptValue; }
+ }
+
+ ///
+ /// Gets a list of native functions, that used to access to members of host item
+ ///
+ public IList NativeFunctions
+ {
+ get { return _nativeFunctions; }
+ }
+
+ ///
+ /// Gets a value that indicates if the host item is an instance
+ ///
+ public abstract bool IsInstance
+ {
+ get;
+ }
+
+
+ ///
+ /// Constructs an instance of the embedded item
+ ///
+ /// Host type
+ /// Instance of host type
+ /// JavaScript value created from an host item
+ /// List of native functions, that used to access to members of host item
+ protected EmbeddedItem(Type hostType, object hostObject, JsValue scriptValue,
+ IList nativeFunctions)
+ {
+ _hostType = hostType;
+ _hostObject = hostObject;
+ _scriptValue = scriptValue;
+ _nativeFunctions = nativeFunctions;
+ }
+
+
+ #region IDisposable implementation
+
+ ///
+ /// Disposes the embedded item
+ ///
+ public void Dispose()
+ {
+ if (_disposedFlag.Set())
+ {
+ _hostType = null;
+ _hostObject = null;
+
+ IList nativeFunctions = _nativeFunctions;
+ if (nativeFunctions != null)
+ {
+ nativeFunctions.Clear();
+ _nativeFunctions = null;
+ }
+ }
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/Embedding/EmbeddedObject.cs b/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/Embedding/EmbeddedObject.cs
new file mode 100644
index 00000000..612acfec
--- /dev/null
+++ b/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/Embedding/EmbeddedObject.cs
@@ -0,0 +1,42 @@
+using System.Collections.Generic;
+
+namespace JavaScriptEngineSwitcher.ChakraCore.JsRt.Embedding
+{
+ ///
+ /// Embedded object
+ ///
+ internal sealed class EmbeddedObject : EmbeddedItem
+ {
+ ///
+ /// Constructs an instance of the embedded object
+ ///
+ /// Instance of host type
+ /// JavaScript value created from an host object
+ public EmbeddedObject(object hostObject, JsValue scriptValue)
+ : base(hostObject.GetType(), hostObject, scriptValue, new List())
+ { }
+
+ ///
+ /// Constructs an instance of the embedded object
+ ///
+ /// Instance of host type
+ /// JavaScript value created from an host object
+ /// List of native functions, that used to access to members of host object
+ public EmbeddedObject(object hostObject, JsValue scriptValue,
+ IList nativeFunctions)
+ : base(hostObject.GetType(), hostObject, scriptValue, nativeFunctions)
+ { }
+
+ #region EmbeddedItem overrides
+
+ ///
+ /// Gets a value that indicates if the host item is an instance
+ ///
+ public override bool IsInstance
+ {
+ get { return true; }
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/Embedding/EmbeddedObjectKey.cs b/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/Embedding/EmbeddedObjectKey.cs
new file mode 100644
index 00000000..29033978
--- /dev/null
+++ b/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/Embedding/EmbeddedObjectKey.cs
@@ -0,0 +1,161 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+
+using JavaScriptEngineSwitcher.ChakraCore.Resources;
+
+namespace JavaScriptEngineSwitcher.ChakraCore.JsRt.Embedding
+{
+ ///
+ /// Key for storage of embedded objects
+ ///
+ internal struct EmbeddedObjectKey : IEquatable, IStructuralEquatable,
+ IComparable, IComparable, IStructuralComparable
+ {
+ ///
+ /// Name of host type
+ ///
+ public readonly string HostTypeName;
+
+ ///
+ /// Instance of host type
+ ///
+ public readonly object HostObject;
+
+
+ ///
+ /// Constructs an instance of the key for storage of embedded objects
+ ///
+ /// Instance of host type
+ public EmbeddedObjectKey(object hostObject)
+ {
+ HostTypeName = hostObject.GetType().AssemblyQualifiedName;
+ HostObject = hostObject;
+ }
+
+
+ private static int CombineHashCodes(int h1, int h2)
+ {
+ return ((h1 << 5) + h1) ^ h2;
+ }
+
+ #region IEquatable implementation
+
+ public bool Equals(EmbeddedObjectKey other)
+ {
+ return EqualityComparer.Default.Equals(HostTypeName, other.HostTypeName)
+ && EqualityComparer.Default.Equals(HostObject, other.HostObject);
+ }
+
+ #endregion
+
+ #region IStructuralEquatable implementation
+
+ bool IStructuralEquatable.Equals(object other, IEqualityComparer comparer)
+ {
+ if (other == null || !(other is EmbeddedObjectKey))
+ {
+ return false;
+ }
+
+ var embeddedObjectKey = (EmbeddedObjectKey)other;
+
+ return comparer.Equals(HostTypeName, embeddedObjectKey.HostTypeName)
+ && comparer.Equals(HostObject, embeddedObjectKey.HostObject);
+ }
+
+ int IStructuralEquatable.GetHashCode(IEqualityComparer comparer)
+ {
+ return CombineHashCodes(comparer.GetHashCode(HostTypeName), comparer.GetHashCode(HostObject));
+ }
+
+ #endregion
+
+ #region IComparable implementation
+
+ int IComparable.CompareTo(object other)
+ {
+ if (other == null)
+ {
+ return 1;
+ }
+
+ if (!(other is EmbeddedObjectKey))
+ {
+ throw new ArgumentException(
+ string.Format(Strings.Common_ArgumentHasIncorrectType, nameof(other), other.GetType().Name),
+ nameof(other)
+ );
+ }
+
+ return CompareTo((EmbeddedObjectKey)other);
+ }
+
+ #endregion
+
+ #region IComparable implementation
+
+ public int CompareTo(EmbeddedObjectKey other)
+ {
+ int c = Comparer.Default.Compare(HostTypeName, other.HostTypeName);
+ if (c != 0)
+ {
+ return c;
+ }
+
+ return Comparer.Default.Compare(HostObject, other.HostObject);
+ }
+
+ #endregion
+
+ #region IStructuralComparable implementation
+
+ int IStructuralComparable.CompareTo(object other, IComparer comparer)
+ {
+ if (other == null)
+ {
+ return 1;
+ }
+
+ if (!(other is EmbeddedObjectKey))
+ {
+ throw new ArgumentException(
+ string.Format(Strings.Common_ArgumentHasIncorrectType, nameof(other), other.GetType().Name),
+ nameof(other)
+ );
+ }
+
+ var embeddedObjectKey = (EmbeddedObjectKey)other;
+
+ int c = comparer.Compare(HostTypeName, embeddedObjectKey.HostTypeName);
+ if (c != 0)
+ {
+ return c;
+ }
+
+ return comparer.Compare(HostObject, embeddedObjectKey.HostObject);
+ }
+
+ #endregion
+
+ #region Object overrides
+
+ public override bool Equals(object obj)
+ {
+ return obj is EmbeddedObjectKey && Equals((EmbeddedObjectKey)obj);
+ }
+
+ public override int GetHashCode()
+ {
+ return CombineHashCodes(EqualityComparer.Default.GetHashCode(HostTypeName),
+ EqualityComparer.Default.GetHashCode(HostObject));
+ }
+
+ public override string ToString()
+ {
+ return "(" + HostTypeName?.ToString() + ", " + HostObject?.ToString() + ")";
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/Embedding/EmbeddedType.cs b/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/Embedding/EmbeddedType.cs
new file mode 100644
index 00000000..edeb7893
--- /dev/null
+++ b/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/Embedding/EmbeddedType.cs
@@ -0,0 +1,42 @@
+using System;
+using System.Collections.Generic;
+
+namespace JavaScriptEngineSwitcher.ChakraCore.JsRt.Embedding
+{
+ ///
+ /// Embedded type
+ ///
+ internal sealed class EmbeddedType : EmbeddedItem
+ {
+ ///
+ /// Constructs an instance of the embedded type
+ ///
+ /// Host type
+ /// JavaScript value created from an host type
+ public EmbeddedType(Type hostType, JsValue scriptValue)
+ : base(hostType, null, scriptValue, new List())
+ { }
+
+ ///
+ /// Constructs an instance of the embedded type
+ ///
+ /// Host type
+ /// JavaScript value created from an host type
+ /// List of native functions, that used to access to members of type
+ public EmbeddedType(Type hostType, JsValue scriptValue, IList nativeFunctions)
+ : base(hostType, null, scriptValue, nativeFunctions)
+ { }
+
+ #region EmbeddedItem overrides
+
+ ///
+ /// Gets a value that indicates if the host item is an instance
+ ///
+ public override bool IsInstance
+ {
+ get { return false; }
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/JsContext.cs b/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/JsContext.cs
index 545a4539..57df2c43 100644
--- a/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/JsContext.cs
+++ b/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/JsContext.cs
@@ -112,7 +112,7 @@ internal JsContext(IntPtr reference)
///
- /// Tells the runtime to do any idle processing it need to do
+ /// Tells the runtime to do any idle processing it needs to do
///
///
///
@@ -183,9 +183,13 @@ public static JsValue ParseScript(string script, JsSourceContext sourceContext,
/// Parses a serialized script and returns a function representing the script
///
///
- /// Requires an active script context.
- /// The runtime will hold on to the buffer until all instances of any functions created from
- /// the buffer are garbage collected.
+ ///
+ /// Requires an active script context.
+ ///
+ ///
+ /// The runtime will hold on to the buffer until all instances of any functions created from
+ /// the buffer are garbage collected.
+ ///
///
/// The script to parse
/// The serialized script
@@ -262,9 +266,13 @@ public static JsValue RunScript(string script, JsSourceContext sourceContext, st
/// Runs a serialized script
///
///
- /// Requires an active script context.
- /// The runtime will detach the data from the buffer and hold on to it until all
- /// instances of any functions created from the buffer are garbage collected.
+ ///
+ /// Requires an active script context.
+ ///
+ ///
+ /// The runtime will detach the data from the buffer and hold on to it until all
+ /// instances of any functions created from the buffer are garbage collected.
+ ///
///
/// The source code of the serialized script
/// The serialized script
@@ -414,11 +422,29 @@ public static void SetException(JsValue exception)
JsErrorHelpers.ThrowIfError(NativeMethods.JsSetException(exception));
}
+ ///
+ /// Sets a promise continuation callback function that is called by the context when a task
+ /// needs to be queued for future execution
+ ///
+ ///
+ ///
+ /// Requires an active script context.
+ ///
+ ///
+ /// The callback function being set
+ /// User provided state that will be passed back to the callback
+ public static void SetPromiseContinuationCallback(JsPromiseContinuationCallback promiseContinuationCallback,
+ IntPtr callbackState)
+ {
+ JsErrorHelpers.ThrowIfError(NativeMethods.JsSetPromiseContinuationCallback(promiseContinuationCallback,
+ callbackState));
+ }
+
///
/// Adds a reference to a script context
///
///
- /// Calling AddRef ensures that the context will not be freed until Release is called.
+ /// Calling AddRef ensures that the context will not be freed until Release is called.
///
/// The object's new reference count
public uint AddRef()
@@ -433,7 +459,7 @@ public uint AddRef()
/// Releases a reference to a script context
///
///
- /// Removes a reference to a context that was created by AddRef.
+ /// Removes a reference to a context that was created by AddRef .
///
/// The object's new reference count
public uint Release()
diff --git a/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/JsErrorCode.cs b/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/JsErrorCode.cs
index a043251d..ad9740f4 100644
--- a/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/JsErrorCode.cs
+++ b/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/JsErrorCode.cs
@@ -23,7 +23,7 @@ public enum JsErrorCode : uint
InvalidArgument,
///
- /// An argument to a hosting API was null in a context where null is not allowed
+ /// An argument to a hosting API was null in a context where null is not allowed
///
NullArgument,
@@ -125,19 +125,21 @@ public enum JsErrorCode : uint
InObjectBeforeCollectCallback,
///
- /// Object cannot be unwrapped to IInspectable pointer
+ /// Object cannot be unwrapped to IInspectable pointer
///
ObjectNotInspectable,
///
/// A hosting API that operates on symbol property ids but was called with a non-symbol property id.
- /// The error code is returned by JsGetSymbolFromPropertyId if the function is called with non-symbol property id.
+ /// The error code is returned by JsGetSymbolFromPropertyId if the function is called with non-symbol
+ /// property id.
///
PropertyNotSymbol,
///
/// A hosting API that operates on string property ids but was called with a non-string property id.
- /// The error code is returned by existing JsGetPropertyNamefromId if the function is called with non-string property id.
+ /// The error code is returned by existing JsGetPropertyNamefromId if the function is called with
+ /// non-string property id.
///
PropertyNotString,
@@ -147,17 +149,17 @@ public enum JsErrorCode : uint
InvalidContext,
///
- /// Module evaluation is called in wrong context
+ /// The Module HostInfoKind provided was invalid
///
InvalidModuleHostInfoKind,
///
- /// Module was parsed already when JsParseModuleSource is called
+ /// Module was parsed already when JsParseModuleSource is called
///
ModuleParsed,
///
- /// Argument passed to JsCreateWeakReference is a primitive that is not managed by the GC.
+ /// Argument passed to JsCreateWeakReference is a primitive that is not managed by the GC.
/// No weak reference is required, the value will never be collected.
///
NoWeakRefRequired,
@@ -216,7 +218,7 @@ public enum JsErrorCode : uint
ScriptTerminated,
///
- /// A script was terminated because it tried to use eval or function and eval
+ /// A script was terminated because it tried to use eval or Function and eval
/// was disabled
///
ScriptEvalDisabled,
@@ -277,7 +279,26 @@ public enum JsErrorCode : uint
///
/// VM was unable to perform the request action
///
- DiagUnableToPerformAction
+ DiagUnableToPerformAction,
+
+ #endregion
+
+ #region Serialization
+
+ ///
+ /// Serializer/Deserializer does not support current data
+ ///
+ SerializerNotSupported,
+
+ ///
+ /// Current object is not transferable during serialization
+ ///
+ TransferableNotSupported,
+
+ ///
+ /// Current object is already detached when serialized
+ ///
+ TransferableAlreadyDetached
#endregion
}
diff --git a/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/JsErrorHelpers.cs b/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/JsErrorHelpers.cs
index 80bc876d..66ab83fd 100644
--- a/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/JsErrorHelpers.cs
+++ b/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/JsErrorHelpers.cs
@@ -8,114 +8,114 @@ internal static class JsErrorHelpers
///
/// Throws if a native method returns an error code
///
- /// The error
- public static void ThrowIfError(JsErrorCode error)
+ /// The error code
+ public static void ThrowIfError(JsErrorCode errorCode)
{
- if (error != JsErrorCode.NoError)
+ if (errorCode != JsErrorCode.NoError)
{
- switch (error)
+ switch (errorCode)
{
#region Usage
case JsErrorCode.InvalidArgument:
- throw new JsUsageException(error, "Invalid argument.");
+ throw new JsUsageException(errorCode, "Invalid argument.");
case JsErrorCode.NullArgument:
- throw new JsUsageException(error, "Null argument.");
+ throw new JsUsageException(errorCode, "Null argument.");
case JsErrorCode.NoCurrentContext:
- throw new JsUsageException(error, "No current context.");
+ throw new JsUsageException(errorCode, "No current context.");
case JsErrorCode.InExceptionState:
- throw new JsUsageException(error, "Runtime is in exception state.");
+ throw new JsUsageException(errorCode, "Runtime is in exception state.");
case JsErrorCode.NotImplemented:
- throw new JsUsageException(error, "Method is not implemented.");
+ throw new JsUsageException(errorCode, "Method is not implemented.");
case JsErrorCode.WrongThread:
- throw new JsUsageException(error, "Runtime is active on another thread.");
+ throw new JsUsageException(errorCode, "Runtime is active on another thread.");
case JsErrorCode.RuntimeInUse:
- throw new JsUsageException(error, "Runtime is in use.");
+ throw new JsUsageException(errorCode, "Runtime is in use.");
case JsErrorCode.BadSerializedScript:
- throw new JsUsageException(error, "Bad serialized script.");
+ throw new JsUsageException(errorCode, "Bad serialized script.");
case JsErrorCode.InDisabledState:
- throw new JsUsageException(error, "Runtime is disabled.");
+ throw new JsUsageException(errorCode, "Runtime is disabled.");
case JsErrorCode.CannotDisableExecution:
- throw new JsUsageException(error, "Cannot disable execution.");
+ throw new JsUsageException(errorCode, "Cannot disable execution.");
case JsErrorCode.HeapEnumInProgress:
- throw new JsUsageException(error, "Heap enumeration is in progress.");
+ throw new JsUsageException(errorCode, "Heap enumeration is in progress.");
case JsErrorCode.ArgumentNotObject:
- throw new JsUsageException(error, "Argument is not an object.");
+ throw new JsUsageException(errorCode, "Argument is not an object.");
case JsErrorCode.InProfileCallback:
- throw new JsUsageException(error, "In a profile callback.");
+ throw new JsUsageException(errorCode, "In a profile callback.");
case JsErrorCode.InThreadServiceCallback:
- throw new JsUsageException(error, "In a thread service callback.");
+ throw new JsUsageException(errorCode, "In a thread service callback.");
case JsErrorCode.CannotSerializeDebugScript:
- throw new JsUsageException(error, "Cannot serialize a debug script.");
+ throw new JsUsageException(errorCode, "Cannot serialize a debug script.");
case JsErrorCode.AlreadyDebuggingContext:
- throw new JsUsageException(error, "Context is already in debug mode.");
+ throw new JsUsageException(errorCode, "Context is already in debug mode.");
case JsErrorCode.AlreadyProfilingContext:
- throw new JsUsageException(error, "Already profiling this context.");
+ throw new JsUsageException(errorCode, "Already profiling this context.");
case JsErrorCode.IdleNotEnabled:
- throw new JsUsageException(error, "Idle is not enabled.");
+ throw new JsUsageException(errorCode, "Idle is not enabled.");
case JsErrorCode.CannotSetProjectionEnqueueCallback:
- throw new JsUsageException(error, "Cannot set projection enqueue callback.");
+ throw new JsUsageException(errorCode, "Cannot set projection enqueue callback.");
case JsErrorCode.CannotStartProjection:
- throw new JsUsageException(error, "Cannot start projection.");
+ throw new JsUsageException(errorCode, "Cannot start projection.");
case JsErrorCode.InObjectBeforeCollectCallback:
- throw new JsUsageException(error, "In object before collect callback.");
+ throw new JsUsageException(errorCode, "In object before collect callback.");
case JsErrorCode.ObjectNotInspectable:
- throw new JsUsageException(error, "Object not inspectable.");
+ throw new JsUsageException(errorCode, "Object not inspectable.");
case JsErrorCode.PropertyNotSymbol:
- throw new JsUsageException(error, "Property not symbol.");
+ throw new JsUsageException(errorCode, "Property not symbol.");
case JsErrorCode.PropertyNotString:
- throw new JsUsageException(error, "Property not string.");
+ throw new JsUsageException(errorCode, "Property not string.");
case JsErrorCode.InvalidContext:
- throw new JsUsageException(error, "Invalid context.");
+ throw new JsUsageException(errorCode, "Invalid context.");
case JsErrorCode.InvalidModuleHostInfoKind:
- throw new JsUsageException(error, "Invalid module host info kind.");
+ throw new JsUsageException(errorCode, "Invalid module host info kind.");
case JsErrorCode.ModuleParsed:
- throw new JsUsageException(error, "Module parsed.");
+ throw new JsUsageException(errorCode, "Module parsed.");
case JsErrorCode.NoWeakRefRequired:
- throw new JsUsageException(error, "No weak reference is required, the value will never be collected.");
+ throw new JsUsageException(errorCode, "No weak reference is required, the value will never be collected.");
case JsErrorCode.PromisePending:
- throw new JsUsageException(error, "The `Promise` object is still in the pending state.");
+ throw new JsUsageException(errorCode, "The `Promise` object is still in the pending state.");
case JsErrorCode.ModuleNotEvaluated:
- throw new JsUsageException(error, "Module was not yet evaluated when `JsGetModuleNamespace` was called.");
+ throw new JsUsageException(errorCode, "Module was not yet evaluated when `JsGetModuleNamespace` was called.");
#endregion
#region Engine
case JsErrorCode.OutOfMemory:
- throw new JsEngineException(error, "Out of memory.");
+ throw new JsEngineException(errorCode, "Out of memory.");
case JsErrorCode.BadFPUState:
- throw new JsEngineException(error, "Bad the Floating Point Unit state.");
+ throw new JsEngineException(errorCode, "Bad the Floating Point Unit state.");
#endregion
@@ -125,45 +125,45 @@ public static void ThrowIfError(JsErrorCode error)
case JsErrorCode.ScriptCompile:
{
JsValue errorMetadata;
- JsErrorCode innerError = NativeMethods.JsGetAndClearExceptionWithMetadata(out errorMetadata);
+ JsErrorCode innerErrorCode = NativeMethods.JsGetAndClearExceptionWithMetadata(out errorMetadata);
- if (innerError != JsErrorCode.NoError)
+ if (innerErrorCode != JsErrorCode.NoError)
{
- throw new JsFatalException(innerError);
+ throw new JsFatalException(innerErrorCode);
}
- string message = error == JsErrorCode.ScriptCompile ?
+ string message = errorCode == JsErrorCode.ScriptCompile ?
"Compile error." : "Script threw an exception.";
- throw new JsScriptException(error, errorMetadata, message);
+ throw new JsScriptException(errorCode, errorMetadata, message);
}
case JsErrorCode.ScriptTerminated:
- throw new JsScriptException(error, JsValue.Invalid, "Script was terminated.");
+ throw new JsScriptException(errorCode, JsValue.Invalid, "Script was terminated.");
case JsErrorCode.ScriptEvalDisabled:
- throw new JsScriptException(error, JsValue.Invalid, "Eval of strings is disabled in this runtime.");
+ throw new JsScriptException(errorCode, JsValue.Invalid, "Eval of strings is disabled in this runtime.");
#endregion
#region Fatal
case JsErrorCode.Fatal:
- throw new JsFatalException(error, "Fatal error.");
+ throw new JsFatalException(errorCode, "Fatal error.");
case JsErrorCode.WrongRuntime:
- throw new JsFatalException(error, "Wrong runtime.");
+ throw new JsFatalException(errorCode, "Wrong runtime.");
#endregion
default:
- throw new JsFatalException(error);
+ throw new JsFatalException(errorCode);
}
}
}
///
- /// Creates a new JavaScript error object
+ /// Creates a new JavaScript Error object
///
///
/// Requires an active script context.
@@ -179,7 +179,7 @@ public static JsValue CreateError(string message)
}
///
- /// Creates a new JavaScript RangeError error object
+ /// Creates a new JavaScript RangeError error object
///
///
/// Requires an active script context.
@@ -195,7 +195,7 @@ public static JsValue CreateRangeError(string message)
}
///
- /// Creates a new JavaScript ReferenceError error object
+ /// Creates a new JavaScript ReferenceError error object
///
///
/// Requires an active script context.
@@ -211,7 +211,7 @@ public static JsValue CreateReferenceError(string message)
}
///
- /// Creates a new JavaScript SyntaxError error object
+ /// Creates a new JavaScript SyntaxError error object
///
///
/// Requires an active script context.
@@ -227,7 +227,7 @@ public static JsValue CreateSyntaxError(string message)
}
///
- /// Creates a new JavaScript TypeError error object
+ /// Creates a new JavaScript TypeError error object
///
///
/// Requires an active script context.
@@ -243,7 +243,7 @@ public static JsValue CreateTypeError(string message)
}
///
- /// Creates a new JavaScript URIError error object
+ /// Creates a new JavaScript URIError error object
///
///
/// Requires an active script context.
@@ -257,21 +257,5 @@ public static JsValue CreateUriError(string message)
return errorValue;
}
-
- ///
- /// Sets a exception
- ///
- ///
- /// Requires an active script context.
- ///
- /// The error object
- public static void SetException(JsValue exception)
- {
- JsErrorCode innerError = NativeMethods.JsSetException(exception);
- if (innerError != JsErrorCode.NoError)
- {
- throw new JsFatalException(innerError);
- }
- }
}
}
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/JsObjectFinalizeCallback.cs b/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/JsFinalizeCallback.cs
similarity index 69%
rename from src/JavaScriptEngineSwitcher.ChakraCore/JsRt/JsObjectFinalizeCallback.cs
rename to src/JavaScriptEngineSwitcher.ChakraCore/JsRt/JsFinalizeCallback.cs
index 59a21a19..be7f4cb3 100644
--- a/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/JsObjectFinalizeCallback.cs
+++ b/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/JsFinalizeCallback.cs
@@ -3,8 +3,8 @@
namespace JavaScriptEngineSwitcher.ChakraCore.JsRt
{
///
- /// The finalization callback
+ /// A finalizer callback
///
/// The external data that was passed in when creating the object being finalized
- internal delegate void JsObjectFinalizeCallback(IntPtr data);
+ internal delegate void JsFinalizeCallback(IntPtr data);
}
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/JsMemoryAllocationCallback.cs b/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/JsMemoryAllocationCallback.cs
index a17a14c0..c16505a3 100644
--- a/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/JsMemoryAllocationCallback.cs
+++ b/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/JsMemoryAllocationCallback.cs
@@ -5,11 +5,11 @@ namespace JavaScriptEngineSwitcher.ChakraCore.JsRt
///
/// User implemented callback routine for memory allocation events
///
- /// The state passed to SetRuntimeMemoryAllocationCallback
+ /// The state passed to SetRuntimeMemoryAllocationCallback
/// The type of type allocation event
/// The size of the allocation
- /// For the Allocate event, returning true allows the runtime to continue with
- /// allocation. Returning false indicates the allocation request is rejected. The return value
+ /// For the Allocate event, returning true allows the runtime to continue with
+ /// allocation. Returning false indicates the allocation request is rejected. The return value
/// is ignored for other allocation events.
internal delegate bool JsMemoryAllocationCallback(IntPtr callbackState, JsMemoryEventType allocationEvent, UIntPtr allocationSize);
}
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/JsNativeFunction.cs b/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/JsNativeFunction.cs
index 3c2c2dc5..5ef45d2d 100644
--- a/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/JsNativeFunction.cs
+++ b/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/JsNativeFunction.cs
@@ -7,7 +7,7 @@ namespace JavaScriptEngineSwitcher.ChakraCore.JsRt
/// The function callback
///
/// The Function object that represents the function being invoked
- /// Indicates whether this is a regular call or a 'new' call
+ /// Indicates whether this is a regular call or a new call
/// The arguments to the call
/// The number of arguments
/// Callback data, if any
diff --git a/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/JsParseScriptAttributes.cs b/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/JsParseScriptAttributes.cs
index 34fb8078..426c042f 100644
--- a/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/JsParseScriptAttributes.cs
+++ b/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/JsParseScriptAttributes.cs
@@ -23,6 +23,11 @@ internal enum JsParseScriptAttributes
/// ChakraCore assumes ExternalArrayBuffer is Utf8 by default.
/// This one needs to be set for Utf16.
///
- ArrayBufferIsUtf16Encoded = 0x2
+ ArrayBufferIsUtf16Encoded = 0x2,
+
+ ///
+ /// Script should be parsed in strict mode
+ ///
+ StrictMode = 0x4
}
}
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/JsPropertyId.cs b/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/JsPropertyId.cs
index 2da484b8..9382d237 100644
--- a/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/JsPropertyId.cs
+++ b/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/JsPropertyId.cs
@@ -1,5 +1,5 @@
using System;
-#if NET45 || NET471 || NETSTANDARD || NETCOREAPP2_1
+#if NET45_OR_GREATER || NETSTANDARD
using System.Buffers;
using System.Runtime.InteropServices;
#endif
@@ -40,9 +40,7 @@ public static JsPropertyId Invalid
/// Gets a name associated with the property ID
///
///
- ///
/// Requires an active script context.
- ///
///
public string Name
{
@@ -102,7 +100,8 @@ internal JsPropertyId(IntPtr id)
///
///
/// The name of the property ID to get or create.
- /// The name may consist of only digits.
+ /// The string is expected to be ASCII / utf8 encoded.
+ /// The name can be any JavaScript property identifier, including all digits.
/// The property ID in this runtime for the given name
public static JsPropertyId FromString(string name)
{
diff --git a/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/JsRuntime.cs b/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/JsRuntime.cs
index c55cfa43..367d4f9e 100644
--- a/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/JsRuntime.cs
+++ b/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/JsRuntime.cs
@@ -15,9 +15,9 @@ namespace JavaScriptEngineSwitcher.ChakraCore.JsRt
/// time.
///
///
- /// NOTE: A JavaScriptRuntime, unlike other objects in the Chakra hosting API, is not
+ /// NOTE: A JsRuntime , unlike other objects in the Chakra hosting API, is not
/// garbage collected since it contains the garbage collected heap itself. A runtime will
- /// continue to exist until Dispose is called.
+ /// continue to exist until Dispose is called.
///
///
internal struct JsRuntime : IDisposable
@@ -121,7 +121,7 @@ public static JsRuntime Create(JsRuntimeAttributes attributes)
/// Creates a new runtime
///
/// The attributes of the runtime to be created
- /// The thread service for the runtime. Can be null
+ /// The thread service for the runtime. Can be null
/// The runtime created
public static JsRuntime Create(JsRuntimeAttributes attributes, JsThreadServiceCallback threadServiceCallback)
{
@@ -131,24 +131,6 @@ public static JsRuntime Create(JsRuntimeAttributes attributes, JsThreadServiceCa
return handle;
}
- ///
- /// Sets a promise continuation callback function that is called by the context when a task
- /// needs to be queued for future execution
- ///
- ///
- ///
- /// Requires an active script context.
- ///
- ///
- /// The callback function being set
- /// User provided state that will be passed back to the callback
- public static void SetPromiseContinuationCallback(JsPromiseContinuationCallback promiseContinuationCallback,
- IntPtr callbackState)
- {
- JsErrorHelpers.ThrowIfError(NativeMethods.JsSetPromiseContinuationCallback(promiseContinuationCallback,
- callbackState));
- }
-
///
/// Performs a full garbage collection
///
@@ -165,7 +147,7 @@ public void CollectGarbage()
/// Registering a memory allocation callback will cause the runtime to call back to the host
/// whenever it acquires memory from, or releases memory to, the OS. The callback routine is
/// called before the runtime memory manager allocates a block of memory. The allocation will
- /// be rejected if the callback returns false. The runtime memory manager will also invoke the
+ /// be rejected if the callback returns false . The runtime memory manager will also invoke the
/// callback routine after freeing a block of memory, as well as after allocation failures.
///
///
diff --git a/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/JsRuntimeAttributes.cs b/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/JsRuntimeAttributes.cs
index e7ffa694..92d616e4 100644
--- a/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/JsRuntimeAttributes.cs
+++ b/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/JsRuntimeAttributes.cs
@@ -27,7 +27,7 @@ internal enum JsRuntimeAttributes
AllowScriptInterrupt = 0x00000002,
///
- /// Host will call Idle, so enable idle processing. Otherwise, the runtime will manage
+ /// Host will call Idle , so enable idle processing. Otherwise, the runtime will manage
/// memory slightly more aggressively.
///
EnableIdleProcessing = 0x00000004,
@@ -38,7 +38,7 @@ internal enum JsRuntimeAttributes
DisableNativeCodeGeneration = 0x00000008,
///
- /// Using Eval or Function constructor will throw an exception
+ /// Using eval or Function constructor will throw an exception
///
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1650:ElementDocumentationMustBeSpelledCorrectly", Justification = "Eval is a valid function name.")]
DisableEval = 0x00000010,
diff --git a/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/JsScope.cs b/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/JsScope.cs
index 7957da26..06e7e079 100644
--- a/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/JsScope.cs
+++ b/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/JsScope.cs
@@ -1,7 +1,5 @@
using System;
-using JavaScriptEngineSwitcher.Core.Utilities;
-
namespace JavaScriptEngineSwitcher.ChakraCore.JsRt
{
///
@@ -18,7 +16,7 @@ internal struct JsScope : IDisposable
///
/// Whether the structure has been disposed
///
- private StatedFlag _disposedFlag;
+ private bool _disposed;
///
@@ -27,7 +25,7 @@ internal struct JsScope : IDisposable
/// The context to create the scope for
public JsScope(JsContext context)
{
- _disposedFlag = new StatedFlag();
+ _disposed = false;
_previousContext = JsContext.Current;
JsContext.Current = context;
@@ -41,10 +39,13 @@ public JsScope(JsContext context)
///
public void Dispose()
{
- if (_disposedFlag.Set())
+ if (_disposed)
{
- JsContext.Current = _previousContext;
+ return;
}
+
+ JsContext.Current = _previousContext;
+ _disposed = true;
}
#endregion
diff --git a/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/JsSerializedLoadScriptCallback.cs b/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/JsSerializedLoadScriptCallback.cs
index ff460a3e..62ba351a 100644
--- a/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/JsSerializedLoadScriptCallback.cs
+++ b/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/JsSerializedLoadScriptCallback.cs
@@ -7,7 +7,7 @@
/// by debuggable script contexts
/// The script returned
/// Attribute mask for parsing the script
- /// true if the operation succeeded, false otherwise
+ /// true if the operation succeeded, false otherwise
internal delegate bool JsSerializedLoadScriptCallback(JsSourceContext sourceContext,
out JsValue value, out JsParseScriptAttributes parseAttributes);
}
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/JsSerializedScriptLoadSourceCallback.cs b/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/JsSerializedScriptLoadSourceCallback.cs
index 0e9718a1..90975001 100644
--- a/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/JsSerializedScriptLoadSourceCallback.cs
+++ b/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/JsSerializedScriptLoadSourceCallback.cs
@@ -2,10 +2,10 @@
{
///
/// Called by the runtime to load the source code of the serialized script.
- /// The caller must keep the script buffer valid until the JsSerializedScriptUnloadCallback.
+ /// The caller must keep the script buffer valid until the JsSerializedScriptUnloadCallback .
///
- /// The context passed to Js[Parse|Run]SerializedScriptWithCallback
+ /// The context passed to Js[Parse|Run]SerializedScriptWithCallback
/// The script returned
- /// true if the operation succeeded, false otherwise
+ /// true if the operation succeeded, false otherwise
internal delegate bool JsSerializedScriptLoadSourceCallback(JsSourceContext sourceContext, out string scriptBuffer);
}
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/JsSerializedScriptUnloadCallback.cs b/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/JsSerializedScriptUnloadCallback.cs
index 0dbb10f9..f474f3ec 100644
--- a/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/JsSerializedScriptUnloadCallback.cs
+++ b/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/JsSerializedScriptUnloadCallback.cs
@@ -4,6 +4,6 @@
/// Called by the runtime when it is finished with all resources related to the script execution.
/// The caller should free the source if loaded, the byte code, and the context at this time.
///
- /// The context passed to Js[Parse|Run]SerializedScriptWithCallback
+ /// The context passed to Js[Parse|Run]SerializedScriptWithCallback
internal delegate void JsSerializedScriptUnloadCallback(JsSourceContext sourceContext);
}
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/JsThreadServiceCallback.cs b/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/JsThreadServiceCallback.cs
index d54579b0..7d5e67ad 100644
--- a/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/JsThreadServiceCallback.cs
+++ b/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/JsThreadServiceCallback.cs
@@ -9,7 +9,7 @@ namespace JavaScriptEngineSwitcher.ChakraCore.JsRt
/// The host can specify a background thread service when creating a runtime. If
/// specified, then background work items will be passed to the host using this callback. The
/// host is expected to either begin executing the background work item immediately and return
- /// true or return false and the runtime will handle the work item in-thread.
+ /// true or return false and the runtime will handle the work item in-thread.
///
/// The callback for the background work item
/// The data argument to be passed to the callback
diff --git a/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/JsValue.cs b/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/JsValue.cs
index 2faaf5df..dded5494 100644
--- a/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/JsValue.cs
+++ b/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/JsValue.cs
@@ -1,5 +1,5 @@
using System;
-#if NET45 || NET471 || NETSTANDARD || NETCOREAPP2_1
+#if NET45_OR_GREATER || NETSTANDARD
using System.Buffers;
#endif
using System.Runtime.InteropServices;
@@ -16,8 +16,8 @@ namespace JavaScriptEngineSwitcher.ChakraCore.JsRt
/// The JavaScript value
///
///
- /// The JavaScript value is one of the following types of values: Undefined, Null, Boolean,
- /// String, Number, or Object.
+ /// The JavaScript value is one of the following types of values: undefined , null , Boolean ,
+ /// String , Number , or Object .
///
internal struct JsValue
{
@@ -382,10 +382,10 @@ public static JsValue CreateObject()
///
/// Requires an active script context.
///
- /// External data that the object will represent. May be null
- /// The callback for when the object is finalized. May be null.
+ /// External data that the object will represent. May be null .
+ /// The callback for when the object is finalized. May be null .
/// The new Object
- public static JsValue CreateExternalObject(IntPtr data, JsObjectFinalizeCallback finalizer)
+ public static JsValue CreateExternalObject(IntPtr data, JsFinalizeCallback finalizer)
{
JsValue reference;
JsErrorHelpers.ThrowIfError(NativeMethods.JsCreateExternalObject(data, finalizer, out reference));
@@ -470,7 +470,7 @@ public static JsValue CreateExternalArrayBuffer(byte[] buffer)
}
///
- /// Creates a new JavaScript error object
+ /// Creates a new JavaScript Error object
///
///
/// Requires an active script context.
@@ -486,7 +486,7 @@ public static JsValue CreateError(JsValue message)
}
///
- /// Creates a new JavaScript RangeError error object
+ /// Creates a new JavaScript RangeError error object
///
///
/// Requires an active script context.
@@ -502,7 +502,7 @@ public static JsValue CreateRangeError(JsValue message)
}
///
- /// Creates a new JavaScript ReferenceError error object
+ /// Creates a new JavaScript ReferenceError error object
///
///
/// Requires an active script context.
@@ -518,7 +518,7 @@ public static JsValue CreateReferenceError(JsValue message)
}
///
- /// Creates a new JavaScript SyntaxError error object
+ /// Creates a new JavaScript SyntaxError error object
///
///
/// Requires an active script context.
@@ -534,7 +534,7 @@ public static JsValue CreateSyntaxError(JsValue message)
}
///
- /// Creates a new JavaScript TypeError error object
+ /// Creates a new JavaScript TypeError error object
///
///
/// Requires an active script context.
@@ -550,7 +550,7 @@ public static JsValue CreateTypeError(JsValue message)
}
///
- /// Creates a new JavaScript URIError error object
+ /// Creates a new JavaScript URIError error object
///
///
/// Requires an active script context.
@@ -570,8 +570,8 @@ public static JsValue CreateUriError(JsValue message)
///
///
/// This only needs to be called on objects that are not going to be stored somewhere on
- /// the stack. Calling AddRef ensures that the JavaScript object the value refers to will not be freed
- /// until Release is called
+ /// the stack. Calling AddRef ensures that the JavaScript object the value refers to will not be freed
+ /// until Release is called
///
/// The object's new reference count
public uint AddRef()
@@ -586,7 +586,7 @@ public uint AddRef()
/// Releases a reference to the object
///
///
- /// Removes a reference that was created by AddRef.
+ /// Removes a reference that was created by AddRef .
///
/// The object's new reference count
public uint Release()
@@ -617,7 +617,7 @@ public bool ToBoolean()
///
///
///
- /// This function retrieves the value of a Number value. It will fail with
+ /// This function retrieves the value of a Number value. It will fail with
/// InvalidArgument if the type of the value is not Number .
///
///
@@ -638,7 +638,7 @@ public double ToDouble()
///
///
///
- /// This function retrieves the value of a Number value. It will fail with
+ /// This function retrieves the value of a Number value. It will fail with
/// InvalidArgument if the type of the value is not Number .
///
///
@@ -990,7 +990,7 @@ public void DeleteIndexedProperty(JsValue index)
///
///
///
- /// This function is equivalent to the "==" operator in JavaScript.
+ /// This function is equivalent to the == operator in JavaScript.
///
///
/// Requires an active script context.
@@ -1011,7 +1011,7 @@ public bool Equals(JsValue other)
///
///
///
- /// This function is equivalent to the "===" operator in JavaScript.
+ /// This function is equivalent to the === operator in JavaScript.
///
///
/// Requires an active script context.
@@ -1034,7 +1034,7 @@ public bool StrictEquals(JsValue other)
/// Requires an active script context.
///
/// The arguments to the call
- /// The Value returned from the function invocation, if any
+ /// The JavaScript value returned from the function invocation, if any
public JsValue CallFunction(params JsValue[] arguments)
{
JsValue returnReference;
@@ -1056,7 +1056,7 @@ public JsValue CallFunction(params JsValue[] arguments)
/// Requires an active script context.
///
/// The arguments to the call
- /// The Value returned from the function invocation
+ /// The JavaScript value returned from the function invocation
public JsValue ConstructObject(params JsValue[] arguments)
{
JsValue returnReference;
diff --git a/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/JsValueType.cs b/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/JsValueType.cs
index 913016e7..f541875c 100644
--- a/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/JsValueType.cs
+++ b/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/JsValueType.cs
@@ -1,7 +1,7 @@
namespace JavaScriptEngineSwitcher.ChakraCore.JsRt
{
///
- /// The JavaScript type of a JavaScriptValue
+ /// The JavaScript type of a JavaScript value
///
internal enum JsValueType
{
@@ -16,47 +16,47 @@ internal enum JsValueType
Null = 1,
///
- /// The value is a JavaScript number value
+ /// The value is a JavaScript Number value
///
Number = 2,
///
- /// The value is a JavaScript string value
+ /// The value is a JavaScript String value
///
String = 3,
///
- /// The value is a JavaScript Boolean value
+ /// The value is a JavaScript Boolean value
///
Boolean = 4,
///
- /// The value is a JavaScript object value
+ /// The value is a JavaScript Object value
///
Object = 5,
///
- /// The value is a JavaScript function object value
+ /// The value is a JavaScript Function object value
///
Function = 6,
///
- /// The value is a JavaScript error object value
+ /// The value is a JavaScript Error object value
///
Error = 7,
///
- /// The value is a JavaScript array object value
+ /// The value is a JavaScript Array object value
///
Array = 8,
///
- /// The value is a JavaScript array object value
+ /// The value is a JavaScript Symbol object value
///
Symbol = 9,
///
- /// The value is a JavaScript ArrayBuffer object value
+ /// The value is a JavaScript ArrayBuffer object value
///
ArrayBuffer = 10,
@@ -66,7 +66,7 @@ internal enum JsValueType
TypedArray = 11,
///
- /// The value is a JavaScript DataView object value
+ /// The value is a JavaScript DataView object value
///
DataView = 12
}
diff --git a/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/NativeMethods.cs b/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/NativeMethods.cs
index 5023bbc8..fca07c0a 100644
--- a/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/NativeMethods.cs
+++ b/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/NativeMethods.cs
@@ -146,7 +146,7 @@ internal static extern JsErrorCode JsGetPropertyIdType(JsPropertyId propertyId,
[DllImport(DllName.Universal)]
internal static extern JsErrorCode JsCreateExternalObject(IntPtr data,
- JsObjectFinalizeCallback finalizeCallback, out JsValue obj);
+ JsFinalizeCallback finalizeCallback, out JsValue obj);
[DllImport(DllName.Universal)]
internal static extern JsErrorCode JsConvertValueToObject(JsValue value, out JsValue obj);
@@ -240,7 +240,7 @@ internal static extern JsErrorCode JsSetIndexedPropertiesToExternalData(JsValue
[DllImport(DllName.Universal)]
internal static extern JsErrorCode JsCreateExternalArrayBuffer(IntPtr data, uint byteLength,
- JsObjectFinalizeCallback finalizeCallback, IntPtr callbackState, out JsValue result);
+ JsFinalizeCallback finalizeCallback, IntPtr callbackState, out JsValue result);
[DllImport(DllName.Universal)]
internal static extern JsErrorCode JsCreateTypedArray(JsTypedArrayType arrayType, JsValue arrayBuffer,
diff --git a/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/TypeMapper.cs b/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/TypeMapper.cs
new file mode 100644
index 00000000..3fef5501
--- /dev/null
+++ b/src/JavaScriptEngineSwitcher.ChakraCore/JsRt/TypeMapper.cs
@@ -0,0 +1,1091 @@
+using System;
+using System.Collections.Concurrent;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+using JavaScriptEngineSwitcher.Core;
+using JavaScriptEngineSwitcher.Core.Extensions;
+using JavaScriptEngineSwitcher.Core.Utilities;
+
+using CoreErrorHelpers = JavaScriptEngineSwitcher.Core.Helpers.JsErrorHelpers;
+using WrapperException = JavaScriptEngineSwitcher.Core.JsException;
+using WrapperRuntimeException = JavaScriptEngineSwitcher.Core.JsRuntimeException;
+using WrapperScriptException = JavaScriptEngineSwitcher.Core.JsScriptException;
+
+using JavaScriptEngineSwitcher.ChakraCore.Helpers;
+using JavaScriptEngineSwitcher.ChakraCore.JsRt.Embedding;
+using JavaScriptEngineSwitcher.ChakraCore.Resources;
+
+namespace JavaScriptEngineSwitcher.ChakraCore.JsRt
+{
+ ///
+ /// Type mapper
+ ///
+ internal sealed class TypeMapper : IDisposable
+ {
+ ///
+ /// Name of property to store the external object
+ ///
+ private const string ExternalObjectPropertyName = "_JavaScriptEngineSwitcher_externalObject";
+
+ ///
+ /// Flag for whether to allow the usage of reflection API in the script code
+ ///
+ private readonly bool _allowReflection;
+
+ ///
+ /// Storage for lazy-initialized embedded objects
+ ///
+ private ConcurrentDictionary> _lazyEmbeddedObjects;
+
+ ///
+ /// Callback for finalization of embedded object
+ ///
+ private JsFinalizeCallback _embeddedObjectFinalizeCallback;
+
+ ///
+ /// Synchronizer of embedded object storage's initialization
+ ///
+ private readonly object _embeddedObjectStorageInitializationSynchronizer = new object();
+
+ ///
+ /// Flag indicating whether the embedded object storage is initialized
+ ///
+ private bool _embeddedObjectStorageInitialized;
+
+ ///
+ /// Storage for lazy-initialized embedded types
+ ///
+ private ConcurrentDictionary> _lazyEmbeddedTypes;
+
+ ///
+ /// Callback for finalization of embedded type
+ ///
+ private JsFinalizeCallback _embeddedTypeFinalizeCallback;
+
+ ///
+ /// Synchronizer of embedded type storage's initialization
+ ///
+ private readonly object _embeddedTypeStorageInitializationSynchronizer = new object();
+
+ ///
+ /// Flag indicating whether the embedded type storage is initialized
+ ///
+ private bool _embeddedTypeStorageInitialized;
+
+ ///
+ /// Flag indicating whether this object is disposed
+ ///
+ private InterlockedStatedFlag _disposedFlag = new InterlockedStatedFlag();
+
+
+ ///
+ /// Constructs an instance of type mapper
+ ///
+ /// Flag for whether to allow the usage of reflection API in the script code
+ public TypeMapper(bool allowReflection)
+ {
+ _allowReflection = allowReflection;
+ }
+
+
+ ///
+ /// Creates a JavaScript value from an host object if the it does not already exist
+ ///
+ /// Instance of host type
+ /// JavaScript value created from an host object
+ public JsValue GetOrCreateScriptObject(object obj)
+ {
+ if (!_embeddedObjectStorageInitialized)
+ {
+ lock (_embeddedObjectStorageInitializationSynchronizer)
+ {
+ if (!_embeddedObjectStorageInitialized)
+ {
+ _lazyEmbeddedObjects = new ConcurrentDictionary>();
+ _embeddedObjectFinalizeCallback = EmbeddedObjectFinalizeCallback;
+
+ _embeddedObjectStorageInitialized = true;
+ }
+ }
+ }
+
+ var embeddedObjectKey = new EmbeddedObjectKey(obj);
+ EmbeddedObject embeddedObject = _lazyEmbeddedObjects.GetOrAdd(
+ embeddedObjectKey,
+ key => new Lazy(() => CreateEmbeddedObjectOrFunction(obj))
+ ).Value;
+
+ return embeddedObject.ScriptValue;
+ }
+
+ ///
+ /// Creates a JavaScript value from an host type if the it does not already exist
+ ///
+ /// Host type
+ /// JavaScript value created from an host type
+ public JsValue GetOrCreateScriptType(Type type)
+ {
+ if (!_embeddedTypeStorageInitialized)
+ {
+ lock (_embeddedTypeStorageInitializationSynchronizer)
+ {
+ if (!_embeddedTypeStorageInitialized)
+ {
+ _lazyEmbeddedTypes = new ConcurrentDictionary>();
+ _embeddedTypeFinalizeCallback = EmbeddedTypeFinalizeCallback;
+
+ _embeddedTypeStorageInitialized = true;
+ }
+ }
+ }
+
+ string embeddedTypeKey = type.AssemblyQualifiedName;
+ EmbeddedType embeddedType = _lazyEmbeddedTypes.GetOrAdd(
+ embeddedTypeKey,
+ key => new Lazy(() => CreateEmbeddedType(type))
+ ).Value;
+
+ return embeddedType.ScriptValue;
+ }
+
+ ///
+ /// Makes a mapping of value from the host type to a script type
+ ///
+ /// The source value
+ /// The mapped value
+ public JsValue MapToScriptType(object value)
+ {
+ if (value == null)
+ {
+ return JsValue.Null;
+ }
+
+ if (value is Undefined)
+ {
+ return JsValue.Undefined;
+ }
+
+ TypeCode typeCode = value.GetType().GetTypeCode();
+
+ switch (typeCode)
+ {
+ case TypeCode.Boolean:
+ return (bool)value ? JsValue.True : JsValue.False;
+
+ case TypeCode.SByte:
+ case TypeCode.Byte:
+ case TypeCode.Int16:
+ case TypeCode.UInt16:
+ case TypeCode.Int32:
+ case TypeCode.UInt32:
+ case TypeCode.Int64:
+ case TypeCode.UInt64:
+ return JsValue.FromInt32(Convert.ToInt32(value));
+
+ case TypeCode.Single:
+ case TypeCode.Double:
+ case TypeCode.Decimal:
+ return JsValue.FromDouble(Convert.ToDouble(value));
+
+ case TypeCode.Char:
+ case TypeCode.String:
+ return JsValue.FromString((string)value);
+
+ default:
+ return value is JsValue ? (JsValue)value : GetOrCreateScriptObject(value);
+ }
+ }
+
+ ///
+ /// Makes a mapping of value from the script type to a host type
+ ///
+ /// The source value
+ /// The mapped value
+ public object MapToHostType(JsValue value)
+ {
+ JsValueType valueType = value.ValueType;
+ object result = null;
+
+ switch (valueType)
+ {
+ case JsValueType.Null:
+ result = null;
+ break;
+ case JsValueType.Undefined:
+ result = Undefined.Value;
+ break;
+ case JsValueType.Boolean:
+ result = value.ToBoolean();
+ break;
+ case JsValueType.Number:
+ result = NumericHelpers.CastDoubleValueToCorrectType(value.ToDouble());
+ break;
+ case JsValueType.String:
+ result = value.ToString();
+ break;
+ case JsValueType.Function:
+ JsPropertyId externalObjectPropertyId = JsPropertyId.FromString(ExternalObjectPropertyName);
+ if (value.HasProperty(externalObjectPropertyId))
+ {
+ JsValue externalObjectValue = value.GetProperty(externalObjectPropertyId);
+ result = externalObjectValue.HasExternalData ?
+ GCHandle.FromIntPtr(externalObjectValue.ExternalData).Target : null;
+ }
+
+ result = result ?? value.ConvertToObject();
+ break;
+ case JsValueType.Object:
+ case JsValueType.Error:
+ case JsValueType.Array:
+ case JsValueType.Symbol:
+ case JsValueType.ArrayBuffer:
+ case JsValueType.TypedArray:
+ case JsValueType.DataView:
+ result = value.HasExternalData ?
+ GCHandle.FromIntPtr(value.ExternalData).Target : value.ConvertToObject();
+ break;
+ default:
+ throw new ArgumentOutOfRangeException();
+ }
+
+ return result;
+ }
+
+ private EmbeddedObject CreateEmbeddedObjectOrFunction(object obj)
+ {
+ var del = obj as Delegate;
+ EmbeddedObject embeddedObject = del != null ?
+ CreateEmbeddedFunction(del) : CreateEmbeddedObject(obj);
+
+ return embeddedObject;
+ }
+
+ [MethodImpl((MethodImplOptions)256 /* AggressiveInlining */)]
+ private EmbeddedObject CreateEmbeddedObject(object obj)
+ {
+ GCHandle objHandle = GCHandle.Alloc(obj);
+ IntPtr objPtr = GCHandle.ToIntPtr(objHandle);
+ JsValue objValue = JsValue.CreateExternalObject(objPtr, _embeddedObjectFinalizeCallback);
+
+ var embeddedObject = new EmbeddedObject(obj, objValue);
+
+ ProjectFields(embeddedObject);
+ ProjectProperties(embeddedObject);
+ ProjectMethods(embeddedObject);
+ FreezeObject(objValue);
+
+ return embeddedObject;
+ }
+
+ [MethodImpl((MethodImplOptions)256 /* AggressiveInlining */)]
+ private EmbeddedObject CreateEmbeddedFunction(Delegate del)
+ {
+ JsNativeFunction nativeFunction = (callee, isConstructCall, args, argCount, callbackData) =>
+ {
+#if NET40
+ MethodInfo method = del.Method;
+#else
+ MethodInfo method = del.GetMethodInfo();
+#endif
+ ParameterInfo[] parameters = method.GetParameters();
+ object[] processedArgs = GetHostItemMemberArguments(args, parameters.Length);
+
+ ReflectionHelpers.FixArgumentTypes(ref processedArgs, parameters);
+
+ object result;
+
+ try
+ {
+ result = del.DynamicInvoke(processedArgs);
+ }
+ catch (Exception e)
+ {
+ JsValue undefinedValue = JsValue.Undefined;
+ Exception exception = UnwrapException(e);
+ var wrapperException = exception as WrapperException;
+ JsValue errorValue = wrapperException != null ?
+ CreateErrorFromWrapperException(wrapperException)
+ :
+ JsErrorHelpers.CreateError(string.Format(
+ Strings.Runtime_HostDelegateInvocationFailed, exception.Message))
+ ;
+ JsContext.SetException(errorValue);
+
+ return undefinedValue;
+ }
+
+ JsValue resultValue = MapToScriptType(result);
+
+ return resultValue;
+ };
+
+ GCHandle delHandle = GCHandle.Alloc(del);
+ IntPtr delPtr = GCHandle.ToIntPtr(delHandle);
+ JsValue objValue = JsValue.CreateExternalObject(delPtr, _embeddedObjectFinalizeCallback);
+
+ JsValue functionValue = JsValue.CreateFunction(nativeFunction);
+ SetNonEnumerableProperty(functionValue, ExternalObjectPropertyName, objValue);
+
+ var embeddedObject = new EmbeddedObject(del, functionValue,
+ new List { nativeFunction });
+
+ return embeddedObject;
+ }
+
+ private void EmbeddedObjectFinalizeCallback(IntPtr ptr)
+ {
+ if (ptr == IntPtr.Zero)
+ {
+ return;
+ }
+
+ GCHandle objHandle = GCHandle.FromIntPtr(ptr);
+ object obj = objHandle.Target;
+ var lazyEmbeddedObjects = _lazyEmbeddedObjects;
+
+ if (obj != null && lazyEmbeddedObjects != null)
+ {
+ var embeddedObjectKey = new EmbeddedObjectKey(obj);
+ Lazy lazyEmbeddedObject;
+
+ if (lazyEmbeddedObjects.TryRemove(embeddedObjectKey, out lazyEmbeddedObject))
+ {
+ lazyEmbeddedObject.Value?.Dispose();
+ }
+ }
+
+ objHandle.Free();
+ }
+
+ private EmbeddedType CreateEmbeddedType(Type type)
+ {
+#if NET40
+ Type typeInfo = type;
+#else
+ TypeInfo typeInfo = type.GetTypeInfo();
+#endif
+ string typeName = type.FullName;
+ BindingFlags defaultBindingFlags = ReflectionHelpers.GetDefaultBindingFlags(true);
+ ConstructorInfo[] constructors = type.GetConstructors(defaultBindingFlags);
+
+ JsNativeFunction nativeConstructorFunction = (callee, isConstructCall, args, argCount, callbackData) =>
+ {
+ object result;
+ JsValue resultValue;
+ object[] processedArgs = GetHostItemMemberArguments(args);
+
+ if (processedArgs.Length == 0 && typeInfo.IsValueType)
+ {
+ result = Activator.CreateInstance(type);
+ resultValue = MapToScriptType(result);
+
+ return resultValue;
+ }
+
+ JsValue undefinedValue = JsValue.Undefined;
+
+ if (constructors.Length == 0)
+ {
+ CreateAndSetError(string.Format(Strings.Runtime_HostTypeConstructorNotFound, typeName));
+ return undefinedValue;
+ }
+
+ var bestFitConstructor = (ConstructorInfo)ReflectionHelpers.GetBestFitMethod(
+ constructors, processedArgs);
+ if (bestFitConstructor == null)
+ {
+ CreateAndSetReferenceError(string.Format(
+ Strings.Runtime_SuitableConstructorOfHostTypeNotFound, typeName));
+ return undefinedValue;
+ }
+
+ ReflectionHelpers.FixArgumentTypes(ref processedArgs, bestFitConstructor.GetParameters());
+
+ try
+ {
+ result = bestFitConstructor.Invoke(processedArgs);
+ }
+ catch (Exception e)
+ {
+ Exception exception = UnwrapException(e);
+ var wrapperException = exception as WrapperException;
+ JsValue errorValue = wrapperException != null ?
+ CreateErrorFromWrapperException(wrapperException)
+ :
+ JsErrorHelpers.CreateError(string.Format(
+ Strings.Runtime_HostTypeConstructorInvocationFailed, typeName, exception.Message))
+ ;
+ JsContext.SetException(errorValue);
+
+ return undefinedValue;
+ }
+
+ resultValue = MapToScriptType(result);
+
+ return resultValue;
+ };
+
+ GCHandle embeddedTypeHandle = GCHandle.Alloc(type);
+ IntPtr embeddedTypePtr = GCHandle.ToIntPtr(embeddedTypeHandle);
+ JsValue objValue = JsValue.CreateExternalObject(embeddedTypePtr, _embeddedTypeFinalizeCallback);
+
+ JsValue typeValue = JsValue.CreateFunction(nativeConstructorFunction);
+ SetNonEnumerableProperty(typeValue, ExternalObjectPropertyName, objValue);
+
+ var embeddedType = new EmbeddedType(type, typeValue,
+ new List { nativeConstructorFunction });
+
+ ProjectFields(embeddedType);
+ ProjectProperties(embeddedType);
+ ProjectMethods(embeddedType);
+ FreezeObject(typeValue);
+
+ return embeddedType;
+ }
+
+ private void EmbeddedTypeFinalizeCallback(IntPtr ptr)
+ {
+ if (ptr == IntPtr.Zero)
+ {
+ return;
+ }
+
+ GCHandle embeddedTypeHandle = GCHandle.FromIntPtr(ptr);
+ var type = (Type)embeddedTypeHandle.Target;
+ string embeddedTypeKey = type.AssemblyQualifiedName;
+ var lazyEmbeddedTypes = _lazyEmbeddedTypes;
+
+ if (!string.IsNullOrEmpty(embeddedTypeKey) && lazyEmbeddedTypes != null)
+ {
+ Lazy lazyEmbeddedType;
+
+ if (lazyEmbeddedTypes.TryRemove(embeddedTypeKey, out lazyEmbeddedType))
+ {
+ lazyEmbeddedType.Value?.Dispose();
+ }
+ }
+
+ embeddedTypeHandle.Free();
+ }
+
+ private void ProjectFields(EmbeddedItem externalItem)
+ {
+ Type type = externalItem.HostType;
+ object obj = externalItem.HostObject;
+ JsValue typeValue = externalItem.ScriptValue;
+ bool instance = externalItem.IsInstance;
+ IList nativeFunctions = externalItem.NativeFunctions;
+
+ string typeName = type.FullName;
+ BindingFlags defaultBindingFlags = ReflectionHelpers.GetDefaultBindingFlags(instance);
+ FieldInfo[] fields = type.GetFields(defaultBindingFlags);
+
+ foreach (FieldInfo field in fields)
+ {
+ string fieldName = field.Name;
+
+ JsValue descriptorValue = JsValue.CreateObject();
+ descriptorValue.SetProperty("enumerable", JsValue.True, true);
+
+ JsNativeFunction nativeGetFunction = (callee, isConstructCall, args, argCount, callbackData) =>
+ {
+ JsValue undefinedValue = JsValue.Undefined;
+
+ if (instance && obj == null)
+ {
+ CreateAndSetTypeError(string.Format(
+ Strings.Runtime_InvalidThisContextForHostObjectField, fieldName));
+ return undefinedValue;
+ }
+
+ object result;
+
+ try
+ {
+ result = field.GetValue(obj);
+ }
+ catch (Exception e)
+ {
+ Exception exception = UnwrapException(e);
+ var wrapperException = exception as WrapperException;
+ JsValue errorValue;
+
+ if (wrapperException != null)
+ {
+ errorValue = CreateErrorFromWrapperException(wrapperException);
+ }
+ else
+ {
+ string errorMessage = instance ?
+ string.Format(Strings.Runtime_HostObjectFieldGettingFailed, fieldName,
+ exception.Message)
+ :
+ string.Format(Strings.Runtime_HostTypeFieldGettingFailed, fieldName, typeName,
+ exception.Message)
+ ;
+ errorValue = JsErrorHelpers.CreateError(errorMessage);
+ }
+ JsContext.SetException(errorValue);
+
+ return undefinedValue;
+ }
+
+ JsValue resultValue = MapToScriptType(result);
+
+ return resultValue;
+ };
+ nativeFunctions.Add(nativeGetFunction);
+
+ JsValue getMethodValue = JsValue.CreateFunction(nativeGetFunction);
+ descriptorValue.SetProperty("get", getMethodValue, true);
+
+ JsNativeFunction nativeSetFunction = (callee, isConstructCall, args, argCount, callbackData) =>
+ {
+ JsValue undefinedValue = JsValue.Undefined;
+
+ if (instance && obj == null)
+ {
+ CreateAndSetTypeError(string.Format(
+ Strings.Runtime_InvalidThisContextForHostObjectField, fieldName));
+ return undefinedValue;
+ }
+
+ object value = MapToHostType(args[1]);
+ ReflectionHelpers.FixFieldValueType(ref value, field);
+
+ try
+ {
+ field.SetValue(obj, value);
+ }
+ catch (Exception e)
+ {
+ Exception exception = UnwrapException(e);
+ var wrapperException = exception as WrapperException;
+ JsValue errorValue;
+
+ if (wrapperException != null)
+ {
+ errorValue = CreateErrorFromWrapperException(wrapperException);
+ }
+ else
+ {
+ string errorMessage = instance ?
+ string.Format(Strings.Runtime_HostObjectFieldSettingFailed, fieldName,
+ exception.Message)
+ :
+ string.Format(Strings.Runtime_HostTypeFieldSettingFailed, fieldName, typeName,
+ exception.Message)
+ ;
+ errorValue = JsErrorHelpers.CreateError(errorMessage);
+ }
+ JsContext.SetException(errorValue);
+
+ return undefinedValue;
+ }
+
+ return undefinedValue;
+ };
+ nativeFunctions.Add(nativeSetFunction);
+
+ JsValue setMethodValue = JsValue.CreateFunction(nativeSetFunction);
+ descriptorValue.SetProperty("set", setMethodValue, true);
+
+ typeValue.DefineProperty(fieldName, descriptorValue);
+ }
+ }
+
+ private void ProjectProperties(EmbeddedItem externalItem)
+ {
+ Type type = externalItem.HostType;
+ object obj = externalItem.HostObject;
+ JsValue typeValue = externalItem.ScriptValue;
+ IList nativeFunctions = externalItem.NativeFunctions;
+ bool instance = externalItem.IsInstance;
+
+ string typeName = type.FullName;
+ BindingFlags defaultBindingFlags = ReflectionHelpers.GetDefaultBindingFlags(instance);
+ PropertyInfo[] properties = type.GetProperties(defaultBindingFlags);
+
+ foreach (PropertyInfo property in properties)
+ {
+ if (!IsAvailableProperty(property))
+ {
+ continue;
+ }
+
+ string propertyName = property.Name;
+
+ JsValue descriptorValue = JsValue.CreateObject();
+ descriptorValue.SetProperty("enumerable", JsValue.True, true);
+
+ if (property.GetGetMethod() != null)
+ {
+ JsNativeFunction nativeGetFunction = (callee, isConstructCall, args, argCount, callbackData) =>
+ {
+ JsValue undefinedValue = JsValue.Undefined;
+
+ if (instance && obj == null)
+ {
+ CreateAndSetTypeError(string.Format(
+ Strings.Runtime_InvalidThisContextForHostObjectProperty, propertyName));
+ return undefinedValue;
+ }
+
+ object result;
+
+ try
+ {
+ result = property.GetValue(obj, new object[0]);
+ }
+ catch (Exception e)
+ {
+ Exception exception = UnwrapException(e);
+ var wrapperException = exception as WrapperException;
+ JsValue errorValue;
+
+ if (wrapperException != null)
+ {
+ errorValue = CreateErrorFromWrapperException(wrapperException);
+ }
+ else
+ {
+ string errorMessage = instance ?
+ string.Format(Strings.Runtime_HostObjectPropertyGettingFailed, propertyName,
+ exception.Message)
+ :
+ string.Format(Strings.Runtime_HostTypePropertyGettingFailed, propertyName,
+ typeName, exception.Message)
+ ;
+ errorValue = JsErrorHelpers.CreateError(errorMessage);
+ }
+ JsContext.SetException(errorValue);
+
+ return undefinedValue;
+ }
+
+ JsValue resultValue = MapToScriptType(result);
+
+ return resultValue;
+ };
+ nativeFunctions.Add(nativeGetFunction);
+
+ JsValue getMethodValue = JsValue.CreateFunction(nativeGetFunction);
+ descriptorValue.SetProperty("get", getMethodValue, true);
+ }
+
+ if (property.GetSetMethod() != null)
+ {
+ JsNativeFunction nativeSetFunction = (callee, isConstructCall, args, argCount, callbackData) =>
+ {
+ JsValue undefinedValue = JsValue.Undefined;
+
+ if (instance && obj == null)
+ {
+ CreateAndSetTypeError(string.Format(
+ Strings.Runtime_InvalidThisContextForHostObjectProperty, propertyName));
+ return undefinedValue;
+ }
+
+ object value = MapToHostType(args[1]);
+ ReflectionHelpers.FixPropertyValueType(ref value, property);
+
+ try
+ {
+ property.SetValue(obj, value, new object[0]);
+ }
+ catch (Exception e)
+ {
+ Exception exception = UnwrapException(e);
+ var wrapperException = exception as WrapperException;
+ JsValue errorValue;
+
+ if (wrapperException != null)
+ {
+ errorValue = CreateErrorFromWrapperException(wrapperException);
+ }
+ else
+ {
+ string errorMessage = instance ?
+ string.Format(Strings.Runtime_HostObjectPropertySettingFailed, propertyName,
+ exception.Message)
+ :
+ string.Format(Strings.Runtime_HostTypePropertySettingFailed, propertyName,
+ typeName, exception.Message)
+ ;
+ errorValue = JsErrorHelpers.CreateError(errorMessage);
+ }
+ JsContext.SetException(errorValue);
+
+ return undefinedValue;
+ }
+
+ return undefinedValue;
+ };
+ nativeFunctions.Add(nativeSetFunction);
+
+ JsValue setMethodValue = JsValue.CreateFunction(nativeSetFunction);
+ descriptorValue.SetProperty("set", setMethodValue, true);
+ }
+
+ typeValue.DefineProperty(propertyName, descriptorValue);
+ }
+ }
+
+ private void ProjectMethods(EmbeddedItem externalItem)
+ {
+ Type type = externalItem.HostType;
+ object obj = externalItem.HostObject;
+ JsValue typeValue = externalItem.ScriptValue;
+ IList nativeFunctions = externalItem.NativeFunctions;
+ bool instance = externalItem.IsInstance;
+
+ string typeName = type.FullName;
+ BindingFlags defaultBindingFlags = ReflectionHelpers.GetDefaultBindingFlags(instance);
+ MethodInfo[] methods = type.GetMethods(defaultBindingFlags);
+ Dictionary> availableMethodGroups = GetAvailableMethodGroups(methods);
+
+ foreach (KeyValuePair> methodGroup in availableMethodGroups)
+ {
+ string methodName = methodGroup.Key;
+ MethodInfo[] methodCandidates = methodGroup.Value.ToArray();
+
+ JsNativeFunction nativeFunction = (callee, isConstructCall, args, argCount, callbackData) =>
+ {
+ JsValue undefinedValue = JsValue.Undefined;
+
+ if (instance && obj == null)
+ {
+ CreateAndSetTypeError(string.Format(
+ Strings.Runtime_InvalidThisContextForHostObjectMethod, methodName));
+ return undefinedValue;
+ }
+
+ object[] processedArgs = GetHostItemMemberArguments(args);
+
+ var bestFitMethod = (MethodInfo)ReflectionHelpers.GetBestFitMethod(
+ methodCandidates, processedArgs);
+ if (bestFitMethod == null)
+ {
+ CreateAndSetReferenceError(string.Format(
+ Strings.Runtime_SuitableMethodOfHostObjectNotFound, methodName));
+ return undefinedValue;
+ }
+
+ ReflectionHelpers.FixArgumentTypes(ref processedArgs, bestFitMethod.GetParameters());
+
+ object result;
+
+ try
+ {
+ result = bestFitMethod.Invoke(obj, processedArgs);
+ }
+ catch (Exception e)
+ {
+ Exception exception = UnwrapException(e);
+ var wrapperException = exception as WrapperException;
+ JsValue errorValue;
+
+ if (wrapperException != null)
+ {
+ errorValue = CreateErrorFromWrapperException(wrapperException);
+ }
+ else
+ {
+ string errorMessage = instance ?
+ string.Format(Strings.Runtime_HostObjectMethodInvocationFailed, methodName,
+ exception.Message)
+ :
+ string.Format(Strings.Runtime_HostTypeMethodInvocationFailed, methodName, typeName,
+ exception.Message)
+ ;
+ errorValue = JsErrorHelpers.CreateError(errorMessage);
+ }
+ JsContext.SetException(errorValue);
+
+ return undefinedValue;
+ }
+
+ JsValue resultValue = MapToScriptType(result);
+
+ return resultValue;
+ };
+ nativeFunctions.Add(nativeFunction);
+
+ JsValue methodValue = JsValue.CreateFunction(nativeFunction);
+ typeValue.SetProperty(methodName, methodValue, true);
+ }
+ }
+
+ [MethodImpl((MethodImplOptions)256 /* AggressiveInlining */)]
+ private bool IsAvailableProperty(PropertyInfo property)
+ {
+ if (_allowReflection)
+ {
+ return true;
+ }
+
+ bool isAvailable = ReflectionHelpers.IsAllowedProperty(property);
+
+ return isAvailable;
+ }
+
+ [MethodImpl((MethodImplOptions)256 /* AggressiveInlining */)]
+ private Dictionary> GetAvailableMethodGroups(MethodInfo[] methods)
+ {
+ int methodCount = methods.Length;
+ if (methodCount == 0)
+ {
+ return new Dictionary>();
+ }
+
+ var availableMethodGroups = new Dictionary>(methodCount);
+
+ foreach (MethodInfo method in methods)
+ {
+ if (!ReflectionHelpers.IsFullyFledgedMethod(method)
+ || (!_allowReflection && !ReflectionHelpers.IsAllowedMethod(method)))
+ {
+ continue;
+ }
+
+ string methodName = method.Name;
+ List methodGroup;
+
+ if (availableMethodGroups.TryGetValue(methodName, out methodGroup))
+ {
+ methodGroup.Add(method);
+ }
+ else
+ {
+ methodGroup = new List { method };
+ availableMethodGroups.Add(methodName, methodGroup);
+ }
+ }
+
+ return availableMethodGroups;
+ }
+
+ private object[] GetHostItemMemberArguments(JsValue[] args, int maxArgCount = -1)
+ {
+ if (args == null)
+ {
+ throw new ArgumentNullException(nameof(args));
+ }
+
+ int argCount = args.Length;
+ const int skippedArgCount = 1;
+ int processedArgCount = argCount >= skippedArgCount ? argCount - skippedArgCount : 0;
+ if (maxArgCount >= 0 && processedArgCount > maxArgCount)
+ {
+ processedArgCount = maxArgCount;
+ }
+ object[] processedArgs;
+
+ if (processedArgCount > 0)
+ {
+ processedArgs = args
+ .Skip(skippedArgCount)
+ .Take(processedArgCount)
+ .Select(MapToHostType)
+ .ToArray()
+ ;
+ }
+ else
+ {
+ processedArgs = new object[0];
+ }
+
+ return processedArgs;
+ }
+
+ [MethodImpl((MethodImplOptions)256 /* AggressiveInlining */)]
+ private static void FreezeObject(JsValue objValue)
+ {
+ JsValue freezeMethodValue = JsValue.GlobalObject
+ .GetProperty("Object")
+ .GetProperty("freeze")
+ ;
+ freezeMethodValue.CallFunction(objValue);
+ }
+
+ [MethodImpl((MethodImplOptions)256 /* AggressiveInlining */)]
+ private static void SetNonEnumerableProperty(JsValue objValue, string name, JsValue value)
+ {
+ JsValue descriptorValue = JsValue.CreateObject();
+ descriptorValue.SetProperty("enumerable", JsValue.False, true);
+ descriptorValue.SetProperty("writable", JsValue.True, true);
+
+ JsPropertyId id = JsPropertyId.FromString(name);
+ objValue.DefineProperty(id, descriptorValue);
+ objValue.SetProperty(id, value, true);
+ }
+
+ [MethodImpl((MethodImplOptions)256 /* AggressiveInlining */)]
+ private static void CreateAndSetError(string message)
+ {
+ JsValue errorValue = JsErrorHelpers.CreateError(message);
+ JsContext.SetException(errorValue);
+ }
+
+ [MethodImpl((MethodImplOptions)256 /* AggressiveInlining */)]
+ private static void CreateAndSetReferenceError(string message)
+ {
+ JsValue errorValue = JsErrorHelpers.CreateReferenceError(message);
+ JsContext.SetException(errorValue);
+ }
+
+ [MethodImpl((MethodImplOptions)256 /* AggressiveInlining */)]
+ private static void CreateAndSetTypeError(string message)
+ {
+ JsValue errorValue = JsErrorHelpers.CreateTypeError(message);
+ JsContext.SetException(errorValue);
+ }
+
+ private static Exception UnwrapException(Exception exception)
+ {
+ Exception originalException = exception;
+ var targetInvocationException = exception as TargetInvocationException;
+
+ if (targetInvocationException != null)
+ {
+ Exception innerException = targetInvocationException.InnerException;
+ if (innerException != null)
+ {
+ originalException = innerException;
+ }
+ }
+
+ return originalException;
+ }
+
+ private static JsValue CreateErrorFromWrapperException(WrapperException exception)
+ {
+ var originalException = exception.InnerException as JsException;
+ JsErrorCode errorCode = originalException != null ?
+ originalException.ErrorCode : JsErrorCode.NoError;
+ string description = exception.Description;
+
+ JsValue innerErrorValue = JsErrorHelpers.CreateError(description);
+ innerErrorValue.SetProperty("description", JsValue.FromString(description), true);
+
+ JsValue metadataValue = JsValue.CreateObject();
+
+ var scriptException = exception as WrapperScriptException;
+ if (scriptException != null)
+ {
+ string type = scriptException.Type;
+ string documentName = scriptException.DocumentName;
+ int lineNumber = scriptException.LineNumber;
+ if (lineNumber > 0)
+ {
+ lineNumber--;
+ }
+ int columnNumber = scriptException.ColumnNumber;
+ if (columnNumber > 0)
+ {
+ columnNumber--;
+ }
+ string sourceFragment = scriptException.SourceFragment;
+
+ innerErrorValue.SetProperty("name", JsValue.FromString(type), true);
+
+ var runtimeException = scriptException as WrapperRuntimeException;
+ if (runtimeException != null)
+ {
+ var errorNumber = (int)errorCode;
+ string callStack = runtimeException.CallStack;
+ string messageWithTypeAndCallStack = CoreErrorHelpers.GenerateScriptErrorMessage(type,
+ description, callStack);
+
+ innerErrorValue.SetProperty("number", JsValue.FromInt32(errorNumber), true);
+ if (!string.IsNullOrWhiteSpace(callStack))
+ {
+ innerErrorValue.SetProperty("stack", JsValue.FromString(messageWithTypeAndCallStack), true);
+ }
+ }
+ else
+ {
+ innerErrorValue.SetProperty("url", JsValue.FromString(documentName), true);
+ innerErrorValue.SetProperty("line", JsValue.FromInt32(lineNumber), true);
+ innerErrorValue.SetProperty("column", JsValue.FromInt32(columnNumber), true);
+ innerErrorValue.SetProperty("source", JsValue.FromString(sourceFragment), true);
+ }
+
+ metadataValue.SetProperty("url", JsValue.FromString(documentName), true);
+ metadataValue.SetProperty("line", JsValue.FromInt32(lineNumber), true);
+ metadataValue.SetProperty("column", JsValue.FromInt32(columnNumber), true);
+ metadataValue.SetProperty("source", JsValue.FromString(sourceFragment), true);
+ }
+
+ innerErrorValue.SetProperty("metadata", metadataValue, true);
+
+ JsValue errorValue = JsErrorHelpers.CreateError(description);
+ errorValue.SetProperty("innerException", innerErrorValue, true);
+
+ return errorValue;
+ }
+
+ #region IDisposable implementation
+
+ ///
+ /// Disposes a type mapper
+ ///
+ public void Dispose()
+ {
+ if (_disposedFlag.Set())
+ {
+ var lazyEmbeddedObjects = _lazyEmbeddedObjects;
+ if (lazyEmbeddedObjects != null)
+ {
+ if (lazyEmbeddedObjects.Count > 0)
+ {
+ foreach (EmbeddedObjectKey key in lazyEmbeddedObjects.Keys)
+ {
+ Lazy lazyEmbeddedObject;
+
+ if (lazyEmbeddedObjects.TryGetValue(key, out lazyEmbeddedObject))
+ {
+ lazyEmbeddedObject.Value?.Dispose();
+ }
+ }
+
+ lazyEmbeddedObjects.Clear();
+ }
+
+ _lazyEmbeddedObjects = null;
+ }
+
+ _embeddedObjectFinalizeCallback = null;
+
+ var lazyEmbeddedTypes = _lazyEmbeddedTypes;
+ if (lazyEmbeddedTypes != null)
+ {
+ if (lazyEmbeddedTypes.Count > 0)
+ {
+ foreach (string key in lazyEmbeddedTypes.Keys)
+ {
+ Lazy lazyEmbeddedType;
+
+ if (lazyEmbeddedTypes.TryGetValue(key, out lazyEmbeddedType))
+ {
+ lazyEmbeddedType.Value?.Dispose();
+ }
+ }
+
+ lazyEmbeddedTypes.Clear();
+ }
+
+ _lazyEmbeddedTypes = null;
+ }
+
+ _embeddedTypeFinalizeCallback = null;
+ }
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.ChakraCore/PACKAGE-DESCRIPTION.md b/src/JavaScriptEngineSwitcher.ChakraCore/PACKAGE-DESCRIPTION.md
new file mode 100644
index 00000000..7ba63673
--- /dev/null
+++ b/src/JavaScriptEngineSwitcher.ChakraCore/PACKAGE-DESCRIPTION.md
@@ -0,0 +1,13 @@
+JavaScriptEngineSwitcher.ChakraCore contains a `ChakraCoreJsEngine` adapter (wrapper for the [ChakraCore](https://github.com/chakra-core/ChakraCore)).
+Project was based on the code of [Chakra-Samples](https://github.com/Microsoft/Chakra-Samples) and [jsrt-dotnet](https://github.com/robpaveza/jsrt-dotnet).
+
+This package does not contain the native implementations of ChakraCore.
+Therefore, you need to choose and install the most appropriate package(s) for your platform.
+The following packages are available:
+
+ * [JavaScriptEngineSwitcher.ChakraCore.Native.win-x86](https://www.nuget.org/packages/JavaScriptEngineSwitcher.ChakraCore.Native.win-x86)
+ * [JavaScriptEngineSwitcher.ChakraCore.Native.win-x64](https://www.nuget.org/packages/JavaScriptEngineSwitcher.ChakraCore.Native.win-x64)
+ * [JavaScriptEngineSwitcher.ChakraCore.Native.win-arm](https://www.nuget.org/packages/JavaScriptEngineSwitcher.ChakraCore.Native.win-arm)
+ * [JavaScriptEngineSwitcher.ChakraCore.Native.win-arm64](https://www.nuget.org/packages/JavaScriptEngineSwitcher.ChakraCore.Native.win-arm64)
+ * [JavaScriptEngineSwitcher.ChakraCore.Native.linux-x64](https://www.nuget.org/packages/JavaScriptEngineSwitcher.ChakraCore.Native.linux-x64)
+ * [JavaScriptEngineSwitcher.ChakraCore.Native.osx-x64](https://www.nuget.org/packages/JavaScriptEngineSwitcher.ChakraCore.Native.osx-x64)
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.ChakraCore/Resources/Strings.Designer.cs b/src/JavaScriptEngineSwitcher.ChakraCore/Resources/Strings.Designer.cs
index 7b8176fc..7547d486 100644
--- a/src/JavaScriptEngineSwitcher.ChakraCore/Resources/Strings.Designer.cs
+++ b/src/JavaScriptEngineSwitcher.ChakraCore/Resources/Strings.Designer.cs
@@ -21,7 +21,7 @@ internal class Strings
private static Lazy _resourceManager =
new Lazy(() => new ResourceManager(
"JavaScriptEngineSwitcher.ChakraCore.Resources.Strings",
-#if NET40
+#if NET20 || NET30 || NET35 || NET40
typeof(Strings).Assembly
#else
typeof(Strings).GetTypeInfo().Assembly
@@ -225,14 +225,6 @@ internal static string Engine_BuildNativeAssemblyForCurrentProcessorArchitecture
get { return GetString("Engine_BuildNativeAssemblyForCurrentProcessorArchitecture"); }
}
- ///
- /// Looks up a localized string similar to "In addition, you still need to install the Microsoft Visual C++ Redistributable for Visual Studio..."
- ///
- internal static string Engine_VcRedist2017InstallationRequired
- {
- get { return GetString("Engine_VcRedist2017InstallationRequired"); }
- }
-
///
/// Looks up a localized string similar to "Maximum stack size must be non-negative."
///
@@ -242,11 +234,11 @@ internal static string Engine_MaxStackSizeMustBeNonNegative
}
///
- /// Looks up a localized string similar to "The buffer is not associated with this pool and may not be returned to it."
+ /// Looks up a localized string similar to "The parameter '{0}' must have a `{1}` type."
///
- internal static string Common_BufferNotFromPool
+ internal static string Common_ArgumentHasIncorrectType
{
- get { return GetString("Common_BufferNotFromPool"); }
+ get { return GetString("Common_ArgumentHasIncorrectType"); }
}
private static string GetString(string name)
diff --git a/src/JavaScriptEngineSwitcher.ChakraCore/Resources/Strings.resx b/src/JavaScriptEngineSwitcher.ChakraCore/Resources/Strings.resx
index ed044df1..9b46bfe7 100644
--- a/src/JavaScriptEngineSwitcher.ChakraCore/Resources/Strings.resx
+++ b/src/JavaScriptEngineSwitcher.ChakraCore/Resources/Strings.resx
@@ -180,13 +180,10 @@
You can build the '{0}' assembly for the current processor architecture by using following instructions from official repository - {1}.
-
- In addition, you still need to install the Microsoft Visual C++ Redistributable for Visual Studio 2017 (https://www.visualstudio.com/downloads/#microsoft-visual-c-redistributable-for-visual-studio-2017).
-
Maximum stack size must be non-negative.
-
- The buffer is not associated with this pool and may not be returned to it.
+
+ The parameter '{0}' must have a `{1}` type.
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.ChakraCore/Resources/Strings.ru-ru.Designer.cs b/src/JavaScriptEngineSwitcher.ChakraCore/Resources/Strings.ru-RU.Designer.cs
similarity index 100%
rename from src/JavaScriptEngineSwitcher.ChakraCore/Resources/Strings.ru-ru.Designer.cs
rename to src/JavaScriptEngineSwitcher.ChakraCore/Resources/Strings.ru-RU.Designer.cs
diff --git a/src/JavaScriptEngineSwitcher.ChakraCore/Resources/Strings.ru-ru.resx b/src/JavaScriptEngineSwitcher.ChakraCore/Resources/Strings.ru-RU.resx
similarity index 95%
rename from src/JavaScriptEngineSwitcher.ChakraCore/Resources/Strings.ru-ru.resx
rename to src/JavaScriptEngineSwitcher.ChakraCore/Resources/Strings.ru-RU.resx
index 9fa05a61..3acdd3a0 100644
--- a/src/JavaScriptEngineSwitcher.ChakraCore/Resources/Strings.ru-ru.resx
+++ b/src/JavaScriptEngineSwitcher.ChakraCore/Resources/Strings.ru-RU.resx
@@ -180,13 +180,10 @@
Вы можете собрать "{0}" для текущей архитектуры процессора, используя следующие инструкции из официального репозитория - {1}.
-
- Кроме того, еще требуется установка распространяемого компонента Microsoft Visual C++ для Visual Studio 2017 (https://www.visualstudio.com/downloads/#microsoft-visual-c-redistributable-for-visual-studio-2017).
-
Максимальный размер стека должен быть неотрицательным!
-
- Буфер не связан с этим пулом и не может быть возвращен в него.
+
+ Параметр с именем "{0}" должен иметь тип `{1}`!
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.ChakraCore/ScriptDispatcher.cs b/src/JavaScriptEngineSwitcher.ChakraCore/ScriptDispatcher.cs
index 5ebfdcae..fc19a767 100644
--- a/src/JavaScriptEngineSwitcher.ChakraCore/ScriptDispatcher.cs
+++ b/src/JavaScriptEngineSwitcher.ChakraCore/ScriptDispatcher.cs
@@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
-#if NET45 || NET471 || NETSTANDARD || NETCOREAPP2_1
+#if NET45_OR_GREATER || NETSTANDARD
using System.Runtime.ExceptionServices;
#endif
using System.Threading;
@@ -31,7 +31,7 @@ internal sealed class ScriptDispatcher : IDisposable
///
/// Queue of script tasks
///
- private readonly Queue _taskQueue = new Queue();
+ private Queue _taskQueue = new Queue();
///
/// Synchronizer of script task queue
@@ -56,7 +56,7 @@ public ScriptDispatcher()
/// Constructs an instance of script dispatcher
///
/// The maximum stack size, in bytes, to be used by the thread,
- /// or 0 to use the default maximum stack size specified in the header for the executable.
+ /// or 0 to use the default maximum stack size specified in the header for the executable.
public ScriptDispatcher(int maxStackSize)
{
_thread = new Thread(StartThread, maxStackSize)
@@ -83,7 +83,7 @@ private void VerifyNotDisposed()
///
private void StartThread()
{
- while(true)
+ while (true)
{
ScriptTask task = null;
@@ -102,16 +102,7 @@ private void StartThread()
if (task != null)
{
- try
- {
- task.Result = task.Delegate();
- }
- catch (Exception e)
- {
- task.Exception = e;
- }
-
- task.WaitHandle.Set();
+ task.Run();
}
else
{
@@ -134,28 +125,19 @@ private void EnqueueTask(ScriptTask task)
}
///
- /// Runs a specified delegate on the thread with modified stack size,
- /// and returns its result as an .
- /// Blocks until the invocation of delegate is completed.
+ /// Executes a script task
///
- /// Delegate to invocation
- /// Result of the delegate invocation
- private object InnnerInvoke(Func del)
+ /// Script task
+ [MethodImpl((MethodImplOptions)256 /* AggressiveInlining */)]
+ private void ExecuteTask(ScriptTask task)
{
- ScriptTask task;
-
- using (var waitHandle = new ManualResetEvent(false))
- {
- task = new ScriptTask(del, waitHandle);
- EnqueueTask(task);
-
- waitHandle.WaitOne();
- }
+ EnqueueTask(task);
+ task.Wait();
Exception exception = task.Exception;
if (exception != null)
{
-#if NET45 || NET471 || NETSTANDARD || NETCOREAPP2_1
+#if NET45_OR_GREATER || NETSTANDARD
ExceptionDispatchInfo.Capture(exception).Throw();
#elif NET40
exception.PreserveStackTrace();
@@ -164,13 +146,11 @@ private object InnnerInvoke(Func del)
#error No implementation for this target
#endif
}
-
- return task.Result;
}
///
/// Runs a specified delegate on the thread with modified stack size,
- /// and returns its result as an .
+ /// and returns its result as an .
/// Blocks until the invocation of delegate is completed.
///
/// The type of the return value of the method,
@@ -186,7 +166,16 @@ public T Invoke(Func func)
throw new ArgumentNullException(nameof(func));
}
- return (T)InnnerInvoke(() => func());
+ if (Thread.CurrentThread == _thread)
+ {
+ return func();
+ }
+
+ using (var task = new ScriptTaskWithResult(func))
+ {
+ ExecuteTask(task);
+ return task.Result;
+ }
}
///
@@ -203,17 +192,22 @@ public void Invoke(Action action)
throw new ArgumentNullException(nameof(action));
}
- InnnerInvoke(() =>
+ if (Thread.CurrentThread == _thread)
{
action();
- return null;
- });
+ return;
+ }
+
+ using (var task = new ScriptTaskWithoutResult(action))
+ {
+ ExecuteTask(task);
+ }
}
#region IDisposable implementation
///
- /// Destroys object
+ /// Destroys a script dispatcher
///
public void Dispose()
{
@@ -232,6 +226,8 @@ public void Dispose()
_waitHandle.Dispose();
_waitHandle = null;
}
+
+ _taskQueue = null;
}
}
@@ -242,55 +238,195 @@ public void Dispose()
///
/// Represents a script task, that must be executed on separate thread
///
- private sealed class ScriptTask
+ private abstract class ScriptTask : IDisposable
{
///
- /// Gets a delegate to invocation
+ /// Event to signal when the invocation of delegate has completed
///
- public Func Delegate
+ protected ManualResetEvent _waitHandle = new ManualResetEvent(false);
+
+ ///
+ /// Exception, that occurred during the invocation of delegate
+ ///
+ protected Exception _exception;
+
+ ///
+ /// Flag that object is destroyed
+ ///
+ protected StatedFlag _disposedFlag = new StatedFlag();
+
+ ///
+ /// Gets a exception, that occurred during the invocation of delegate.
+ /// If no exception has occurred, this will be null .
+ ///
+ public Exception Exception
{
- get;
- private set;
+ get { return _exception; }
+ }
+
+
+ [MethodImpl((MethodImplOptions)256 /* AggressiveInlining */)]
+ protected void VerifyNotDisposed()
+ {
+ if (_disposedFlag.IsSet())
+ {
+ throw new ObjectDisposedException(ToString());
+ }
}
///
- /// Gets a event to signal when the invocation of delegate has completed
+ /// Runs a script task
///
- public ManualResetEvent WaitHandle
+ public abstract void Run();
+
+ ///
+ /// Waits for the script task to complete execution
+ ///
+ public void Wait()
{
- get;
- private set;
+ VerifyNotDisposed();
+
+ _waitHandle.WaitOne();
}
+ #region IDisposable implementation
+
///
- /// Gets or sets a result of the delegate invocation
+ /// Destroys a script task
///
- public object Result
+ public virtual void Dispose()
{
- get;
- set;
+ if (_waitHandle != null)
+ {
+ _waitHandle.Dispose();
+ _waitHandle = null;
+ }
+
+ _exception = null;
}
+ #endregion
+ }
+
+ ///
+ /// Represents a script task with result, that must be executed on separate thread
+ ///
+ private sealed class ScriptTaskWithResult : ScriptTask
+ {
///
- /// Gets or sets a exception, that occurred during the invocation of delegate.
- /// If no exception has occurred, this will be null.
+ /// Delegate to invocation
///
- public Exception Exception
+ private Func _func;
+
+ ///
+ /// Result of the delegate invocation
+ ///
+ private TResult _result;
+
+ ///
+ /// Gets a result of the delegate invocation
+ ///
+ public TResult Result
+ {
+ get { return _result; }
+ }
+
+
+ ///
+ /// Constructs an instance of script task with result
+ ///
+ /// Delegate to invocation
+ public ScriptTaskWithResult(Func func)
+ {
+ _func = func;
+ }
+
+
+ ///
+ /// Runs a script task
+ ///
+ public override void Run()
+ {
+ VerifyNotDisposed();
+
+ try
+ {
+ _result = _func();
+ }
+ catch (Exception e)
+ {
+ _exception = e;
+ }
+
+ _waitHandle.Set();
+ }
+
+ ///
+ /// Destroys a script task
+ ///
+ public override void Dispose()
+ {
+ if (_disposedFlag.Set())
+ {
+ base.Dispose();
+
+ _result = default(TResult);
+ _func = null;
+ }
+ }
+ }
+
+ ///
+ /// Represents a script task without result, that must be executed on separate thread
+ ///
+ private sealed class ScriptTaskWithoutResult : ScriptTask
+ {
+ ///
+ /// Delegate to invocation
+ ///
+ private Action _action;
+
+
+ ///
+ /// Constructs an instance of script task without result
+ ///
+ /// Delegate to invocation
+ public ScriptTaskWithoutResult(Action action)
{
- get;
- set;
+ _action = action;
}
///
- /// Constructs an instance of script task
+ /// Runs a script task
///
- /// Delegate to invocation
- /// Event to signal when the invocation of delegate has completed
- public ScriptTask(Func del, ManualResetEvent waitHandle)
+ public override void Run()
{
- Delegate = del;
- WaitHandle = waitHandle;
+ VerifyNotDisposed();
+
+ try
+ {
+ _action();
+ }
+ catch (Exception e)
+ {
+ _exception = e;
+ }
+
+ _waitHandle.Set();
+ }
+
+ ///
+ /// Destroys a script task
+ ///
+ public override void Dispose()
+ {
+ if (_disposedFlag.Set())
+ {
+ base.Dispose();
+
+ _action = null;
+ }
}
}
diff --git a/src/JavaScriptEngineSwitcher.ChakraCore/readme.txt b/src/JavaScriptEngineSwitcher.ChakraCore/readme.txt
index 86554c76..c02d3dca 100644
--- a/src/JavaScriptEngineSwitcher.ChakraCore/readme.txt
+++ b/src/JavaScriptEngineSwitcher.ChakraCore/readme.txt
@@ -1,21 +1,21 @@
--------------------------------------------------------------------------------
- README file for JS Engine Switcher: ChakraCore v3.0.0
+ README file for JS Engine Switcher: ChakraCore v3.30.4
--------------------------------------------------------------------------------
- Copyright (c) 2013-2018 Andrey Taritsyn - http://www.taritsyn.ru
+ Copyright (c) 2013-2026 Andrey Taritsyn - http://www.taritsyn.ru
===========
DESCRIPTION
===========
- JavaScriptEngineSwitcher.ChakraCore contains adapter `ChakraCoreJsEngine`
- (wrapper for the ChakraCore (http://github.com/Microsoft/ChakraCore)).
+ JavaScriptEngineSwitcher.ChakraCore contains a `ChakraCoreJsEngine` adapter
+ (wrapper for the ChakraCore (https://github.com/chakra-core/ChakraCore)).
Project was based on the code of Chakra-Samples
- (http://github.com/Microsoft/Chakra-Samples) and jsrt-dotnet
- (http://github.com/robpaveza/jsrt-dotnet).
+ (https://github.com/Microsoft/Chakra-Samples) and jsrt-dotnet
+ (https://github.com/robpaveza/jsrt-dotnet).
This package does not contain the native implementations of ChakraCore.
Therefore, you need to choose and install the most appropriate package(s) for
@@ -24,21 +24,14 @@
* JavaScriptEngineSwitcher.ChakraCore.Native.win-x86
* JavaScriptEngineSwitcher.ChakraCore.Native.win-x64
* JavaScriptEngineSwitcher.ChakraCore.Native.win-arm
+ * JavaScriptEngineSwitcher.ChakraCore.Native.win-arm64
* JavaScriptEngineSwitcher.ChakraCore.Native.linux-x64
* JavaScriptEngineSwitcher.ChakraCore.Native.osx-x64
=============
RELEASE NOTES
=============
- 1. ChakraCore was updated to version 1.11.4;
- 2. No longer used the old ChakraCore API for Windows (Internet Explorer-like
- API);
- 3. Added a ability to interrupt execution of the script;
- 4. Added a ability to pre-compile scripts;
- 5. In configuration settings of the ChakraCore JS engine was added one new
- property - `MaxStackSize` (default `492` or `984` KB);
- 6. Added support of .NET Framework 4.7.1, .NET Standard 2.0 and .NET Core App
- 2.1.
+ Optimized a memory usage in the `ReflectionHelpers.GetBestFitMethod` method.
=============
DOCUMENTATION
diff --git a/src/JavaScriptEngineSwitcher.Core/Extensions/StringExtensions.cs b/src/JavaScriptEngineSwitcher.Core/Extensions/StringExtensions.cs
index 0cd36afa..747d67c5 100644
--- a/src/JavaScriptEngineSwitcher.Core/Extensions/StringExtensions.cs
+++ b/src/JavaScriptEngineSwitcher.Core/Extensions/StringExtensions.cs
@@ -12,7 +12,7 @@ public static class StringExtensions
///
/// Instance of
/// The string without quotes to seek
- /// true if the quoted value occurs within this string; otherwise, false
+ /// true if the quoted value occurs within this string; otherwise, false
public static bool ContainsQuotedValue(this string source, string value)
{
if (source == null)
@@ -89,7 +89,7 @@ public static string[] SplitToLines(this string source)
/// When this method returns, contains the character from the string,
/// if the receiving succeeded, or null character if the receiving failed.
/// The receiving fails if the index out of bounds.
- /// true if the character was received successfully; otherwise, false
+ /// true if the character was received successfully; otherwise, false
internal static bool TryGetChar(this string source, int index, out char result)
{
if (source == null)
diff --git a/src/JavaScriptEngineSwitcher.Core/Helpers/JsErrorHelpers.cs b/src/JavaScriptEngineSwitcher.Core/Helpers/JsErrorHelpers.cs
index b295c5f3..d7d7969a 100644
--- a/src/JavaScriptEngineSwitcher.Core/Helpers/JsErrorHelpers.cs
+++ b/src/JavaScriptEngineSwitcher.Core/Helpers/JsErrorHelpers.cs
@@ -39,11 +39,6 @@ public static class JsErrorHelpers
@")" +
@"(?: -> (?[^\n\r]+))?$");
- ///
- /// Regular expression for working with a line break
- ///
- private static readonly Regex _lineBreakRegex = new Regex("\r\n|\n|\r");
-
///
/// Parses a string representation of the script error location to produce an array of
/// instances
diff --git a/src/JavaScriptEngineSwitcher.Core/Helpers/ValidationHelpers.cs b/src/JavaScriptEngineSwitcher.Core/Helpers/ValidationHelpers.cs
index e65d0c96..cadeb669 100644
--- a/src/JavaScriptEngineSwitcher.Core/Helpers/ValidationHelpers.cs
+++ b/src/JavaScriptEngineSwitcher.Core/Helpers/ValidationHelpers.cs
@@ -46,7 +46,7 @@ public static class ValidationHelpers
/// Checks whether supports a .NET type
///
/// .NET type
- /// Result of check (true - is supported; false - is not supported)
+ /// Result of check (true - is supported; false - is not supported)
public static bool IsSupportedType(Type type)
{
bool result = _supportedTypes.Contains(type);
@@ -58,7 +58,7 @@ public static bool IsSupportedType(Type type)
/// Checks whether .NET type is primitive
///
/// .NET type
- /// Result of check (true - is primitive; false - is not primitive)
+ /// Result of check (true - is primitive; false - is not primitive)
public static bool IsPrimitiveType(Type type)
{
TypeCode typeCode = type.GetTypeCode();
@@ -71,7 +71,7 @@ public static bool IsPrimitiveType(Type type)
/// Checks a format of the name
///
/// The name
- /// Result of check (true - correct format; false - wrong format)
+ /// Result of check (true - correct format; false - wrong format)
public static bool CheckNameFormat(string name)
{
return _jsNameRegex.IsMatch(name);
@@ -81,7 +81,7 @@ public static bool CheckNameFormat(string name)
/// Checks a format of the document name
///
/// The document name
- /// Result of check (true - correct format; false - wrong format)
+ /// Result of check (true - correct format; false - wrong format)
public static bool CheckDocumentNameFormat(string name)
{
return _documentNameRegex.IsMatch(name);
diff --git a/src/JavaScriptEngineSwitcher.Core/IJsEngine.cs b/src/JavaScriptEngineSwitcher.Core/IJsEngine.cs
index 2485836e..ba656df0 100644
--- a/src/JavaScriptEngineSwitcher.Core/IJsEngine.cs
+++ b/src/JavaScriptEngineSwitcher.Core/IJsEngine.cs
@@ -314,10 +314,10 @@ bool SupportsGarbageCollection
T CallFunction(string functionName, params object[] args);
///
- /// Сhecks for the existence of a variable
+ /// Checks for the existence of a variable
///
/// Variable name
- /// Result of check (true - exists; false - not exists
+ /// Result of check (true - exists; false - not exists
///
///
///
@@ -376,9 +376,11 @@ bool SupportsGarbageCollection
///
/// Embeds a host object to script code
///
+ ///
+ /// Allows to embed instances of simple classes (or structures) and delegates.
+ ///
/// The name for the new global variable or function that will represent the object
/// The object to expose
- /// Allows to embed instances of simple classes (or structures) and delegates.
///
///
///
@@ -388,12 +390,12 @@ bool SupportsGarbageCollection
///
/// Embeds a host type to script code
///
- /// The name for the new global variable that will represent the type
- /// The type to expose
///
/// Host types are exposed to script code in the form of objects whose properties and
/// methods are bound to the type's static members.
///
+ /// The name for the new global variable that will represent the type
+ /// The type to expose
///
///
///
diff --git a/src/JavaScriptEngineSwitcher.Core/JavaScriptEngineSwitcher.Core.csproj b/src/JavaScriptEngineSwitcher.Core/JavaScriptEngineSwitcher.Core.csproj
index 78248f85..911456c6 100644
--- a/src/JavaScriptEngineSwitcher.Core/JavaScriptEngineSwitcher.Core.csproj
+++ b/src/JavaScriptEngineSwitcher.Core/JavaScriptEngineSwitcher.Core.csproj
@@ -1,56 +1,45 @@
-
- JS Engine Switcher: Core
- 3.0.0
- net40-client;net45;netstandard1.3;netstandard2.0
- 1.6.0
- Library
- true
- $(NoWarn);CS1591;NU5125
- true
- true
- JavaScript Engine Switcher determines unified interface for access to the basic features of popular JavaScript engines (MSIE JavaScript Engine for .NET, Microsoft ClearScript.V8, Jurassic, Jint, ChakraCore, VroomJs and NiL.JS). This library allows you to quickly and easily switch to using of another JavaScript engine.
- https://raw.githubusercontent.com/Taritsyn/JavaScriptEngineSwitcher/master/Icons/JavaScriptEngineSwitcher_Core_Logo128x128.png
- JavaScriptEngineSwitcher;JavaScript;ECMAScript
- 1. In the `JsEngineSwitcher` class a `Instance` property was renamed to the `Current` property;
-2. Now you can implement your own version of the `JsEngineSwitcher` class;
-3. Format of the error messages was unified;
-4. Created a new exception classes: `JsCompilationException`, `JsEngineException`, `JsFatalException`, `JsInterruptedException`, `JsTimeoutException`, `JsScriptException` and `JsUsageException`. These exceptions are responsible for handling errors, some of which were previously handled by the `JsRuntimeException` class;
-5. In the `JsException` class was added two new properties: `Category` and `Description`;
-6. From the `JsRuntimeException` class was removed one property - `ErrorCode`;
-7. In the `JsRuntimeException` class was added three new properties: `Type`, `DocumentName` and `CallStack`;
-8. `JsEngineLoadException` class now is inherited from the `JsEngineException` class;
-9. Removed a `EmptyValueException` class;
-10. `Format` method of the `JsErrorHelpers` class was renamed to the `GenerateErrorDetails`;
-11. Part of the auxiliary code was moved to external libraries: PolyfillsForOldDotNet and AdvancedStringBuilder;
-12. In `IJsEngine` interface was added two new properties: `SupportsScriptInterruption` and `SupportsScriptPrecompilation`, and four new methods: `Interrupt`, `Precompile`, `PrecompileFile` and `PrecompileResource`;
-13. Added support of .NET Standard 2.0.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- readme.txt
- true
-
-
-
-
-
-
+
+ JS Engine Switcher: Core
+ 3.24.1
+ net40-client;net45;netstandard1.3;netstandard2.0
+ 1.6.0
+ Library
+ true
+ $(NoWarn);CS1591;NETSDK1215;NU1903
+ false
+ true
+ true
+
+
+
+
+
+
+
+
+ https://raw.githubusercontent.com/Taritsyn/JavaScriptEngineSwitcher/master/Icons/JavaScriptEngineSwitcher_Core_Logo128x128.png
+ ../../Icons/JavaScriptEngineSwitcher_Core_Logo128x128.png
+ JavaScript Engine Switcher determines unified interface for access to the basic features of popular JavaScript engines. This library allows you to quickly and easily switch to using of another JavaScript engine.
+ $(PackageCommonTags)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.Core/JsEngineBase.cs b/src/JavaScriptEngineSwitcher.Core/JsEngineBase.cs
index 3449fa1b..d2efe334 100644
--- a/src/JavaScriptEngineSwitcher.Core/JsEngineBase.cs
+++ b/src/JavaScriptEngineSwitcher.Core/JsEngineBase.cs
@@ -97,16 +97,19 @@ protected virtual void InnerCollectGarbage()
#region IJsEngine implementation
+ ///
public abstract string Name
{
get;
}
+ ///
public abstract string Version
{
get;
}
+ ///
public virtual bool SupportsScriptPrecompilation
{
get
@@ -115,6 +118,7 @@ public virtual bool SupportsScriptPrecompilation
}
}
+ ///
public virtual bool SupportsScriptInterruption
{
get
@@ -123,6 +127,7 @@ public virtual bool SupportsScriptInterruption
}
}
+ ///
public virtual bool SupportsGarbageCollection
{
get
@@ -132,6 +137,7 @@ public virtual bool SupportsGarbageCollection
}
+ ///
public virtual IPrecompiledScript Precompile(string code)
{
VerifyNotDisposed();
@@ -155,6 +161,7 @@ public virtual IPrecompiledScript Precompile(string code)
return InnerPrecompile(code);
}
+ ///
public virtual IPrecompiledScript Precompile(string code, string documentName)
{
VerifyNotDisposed();
@@ -187,6 +194,7 @@ public virtual IPrecompiledScript Precompile(string code, string documentName)
return InnerPrecompile(code, documentName);
}
+ ///
public virtual IPrecompiledScript PrecompileFile(string path, Encoding encoding = null)
{
VerifyNotDisposed();
@@ -227,6 +235,7 @@ public virtual IPrecompiledScript PrecompileFile(string path, Encoding encoding
return InnerPrecompile(code, path);
}
+ ///
public virtual IPrecompiledScript PrecompileResource(string resourceName, Type type)
{
VerifyNotDisposed();
@@ -283,6 +292,7 @@ public virtual IPrecompiledScript PrecompileResource(string resourceName, Type t
return InnerPrecompile(code, resourceName);
}
+ ///
public virtual IPrecompiledScript PrecompileResource(string resourceName, Assembly assembly)
{
VerifyNotDisposed();
@@ -331,6 +341,7 @@ public virtual IPrecompiledScript PrecompileResource(string resourceName, Assemb
return InnerPrecompile(code, resourceName);
}
+ ///
public virtual object Evaluate(string expression)
{
VerifyNotDisposed();
@@ -354,6 +365,7 @@ public virtual object Evaluate(string expression)
return InnerEvaluate(expression);
}
+ ///
public virtual object Evaluate(string expression, string documentName)
{
VerifyNotDisposed();
@@ -386,6 +398,7 @@ public virtual object Evaluate(string expression, string documentName)
return InnerEvaluate(expression, documentName);
}
+ ///
public virtual T Evaluate(string expression)
{
VerifyNotDisposed();
@@ -418,6 +431,7 @@ public virtual T Evaluate(string expression)
return InnerEvaluate(expression);
}
+ ///
public virtual T Evaluate(string expression, string documentName)
{
VerifyNotDisposed();
@@ -459,6 +473,7 @@ public virtual T Evaluate(string expression, string documentName)
return InnerEvaluate(expression, documentName);
}
+ ///
public virtual void Execute(string code)
{
VerifyNotDisposed();
@@ -482,6 +497,7 @@ public virtual void Execute(string code)
InnerExecute(code);
}
+ ///
public virtual void Execute(string code, string documentName)
{
VerifyNotDisposed();
@@ -514,6 +530,7 @@ public virtual void Execute(string code, string documentName)
InnerExecute(code, documentName);
}
+ ///
public virtual void Execute(IPrecompiledScript precompiledScript)
{
VerifyNotDisposed();
@@ -538,6 +555,7 @@ public virtual void Execute(IPrecompiledScript precompiledScript)
InnerExecute(precompiledScript);
}
+ ///
public virtual void ExecuteFile(string path, Encoding encoding = null)
{
VerifyNotDisposed();
@@ -578,6 +596,7 @@ public virtual void ExecuteFile(string path, Encoding encoding = null)
InnerExecute(code, path);
}
+ ///
public virtual void ExecuteResource(string resourceName, Type type)
{
VerifyNotDisposed();
@@ -634,6 +653,7 @@ public virtual void ExecuteResource(string resourceName, Type type)
InnerExecute(code, resourceName);
}
+ ///
public virtual void ExecuteResource(string resourceName, Assembly assembly)
{
VerifyNotDisposed();
@@ -682,6 +702,7 @@ public virtual void ExecuteResource(string resourceName, Assembly assembly)
InnerExecute(code, resourceName);
}
+ ///
public virtual object CallFunction(string functionName, params object[] args)
{
VerifyNotDisposed();
@@ -736,6 +757,7 @@ public virtual object CallFunction(string functionName, params object[] args)
return InnerCallFunction(functionName, args);
}
+ ///
public virtual T CallFunction(string functionName, params object[] args)
{
VerifyNotDisposed();
@@ -799,6 +821,7 @@ public virtual T CallFunction(string functionName, params object[] args)
return InnerCallFunction(functionName, args);
}
+ ///
public virtual bool HasVariable(string variableName)
{
VerifyNotDisposed();
@@ -830,6 +853,7 @@ public virtual bool HasVariable(string variableName)
return InnerHasVariable(variableName);
}
+ ///
public virtual object GetVariableValue(string variableName)
{
VerifyNotDisposed();
@@ -861,6 +885,7 @@ public virtual object GetVariableValue(string variableName)
return InnerGetVariableValue(variableName);
}
+ ///
public virtual T GetVariableValue(string variableName)
{
VerifyNotDisposed();
@@ -901,6 +926,7 @@ public virtual T GetVariableValue(string variableName)
return InnerGetVariableValue(variableName);
}
+ ///
public virtual void SetVariableValue(string variableName, object value)
{
VerifyNotDisposed();
@@ -946,6 +972,7 @@ public virtual void SetVariableValue(string variableName, object value)
InnerSetVariableValue(variableName, value);
}
+ ///
public virtual void RemoveVariable(string variableName)
{
VerifyNotDisposed();
@@ -977,6 +1004,7 @@ public virtual void RemoveVariable(string variableName)
InnerRemoveVariable(variableName);
}
+ ///
public virtual void EmbedHostObject(string itemName, object value)
{
VerifyNotDisposed();
@@ -1028,6 +1056,7 @@ public virtual void EmbedHostObject(string itemName, object value)
InnerEmbedHostObject(itemName, value);
}
+ ///
public virtual void EmbedHostType(string itemName, Type type)
{
VerifyNotDisposed();
@@ -1075,6 +1104,7 @@ public virtual void EmbedHostType(string itemName, Type type)
InnerEmbedHostType(itemName, type);
}
+ ///
public virtual void Interrupt()
{
VerifyNotDisposed();
@@ -1082,6 +1112,7 @@ public virtual void Interrupt()
InnerInterrupt();
}
+ ///
public virtual void CollectGarbage()
{
VerifyNotDisposed();
diff --git a/src/JavaScriptEngineSwitcher.Core/JsEngineFactoryCollection.cs b/src/JavaScriptEngineSwitcher.Core/JsEngineFactoryCollection.cs
index 611c9b7e..632edba2 100644
--- a/src/JavaScriptEngineSwitcher.Core/JsEngineFactoryCollection.cs
+++ b/src/JavaScriptEngineSwitcher.Core/JsEngineFactoryCollection.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
+using System.Collections.ObjectModel;
namespace JavaScriptEngineSwitcher.Core
{
@@ -15,12 +16,29 @@ public sealed class JsEngineFactoryCollection : IEnumerable
private readonly Dictionary _factories =
new Dictionary();
+ ///
+ /// Gets a number of factories in the collection
+ ///
+ public int Count
+ {
+ get { return _factories.Count; }
+ }
+
+
+ ///
+ /// Gets all registered factories
+ ///
+ /// A read-only collection of all factories in the collection
+ public ReadOnlyCollection GetRegisteredFactories()
+ {
+ return new List(_factories.Values).AsReadOnly();
+ }
///
/// Gets a factory by JS engine name
///
/// Name of JS engine
- /// Instance of corresponding JS engine factory or null if factory is not found
+ /// Instance of corresponding JS engine factory or null if factory is not found
public IJsEngineFactory Get(string engineName)
{
if (_factories.ContainsKey(engineName))
@@ -91,25 +109,16 @@ public void Clear()
_factories.Clear();
}
- ///
- /// Gets an enumerator for all factories in the collection
- ///
- /// Enumerator for all factories in the collection
- private IEnumerator InnerGetEnumerator()
- {
- return _factories.Values.GetEnumerator();
- }
-
#region IEnumerable implementation
public IEnumerator GetEnumerator()
{
- return InnerGetEnumerator();
+ return _factories.Values.GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
{
- return InnerGetEnumerator();
+ return _factories.Values.GetEnumerator();
}
#endregion
diff --git a/src/JavaScriptEngineSwitcher.Core/JsEngineSwitcher.cs b/src/JavaScriptEngineSwitcher.Core/JsEngineSwitcher.cs
index 920504dd..6ccf8d9f 100644
--- a/src/JavaScriptEngineSwitcher.Core/JsEngineSwitcher.cs
+++ b/src/JavaScriptEngineSwitcher.Core/JsEngineSwitcher.cs
@@ -9,6 +9,11 @@ namespace JavaScriptEngineSwitcher.Core
///
public sealed class JsEngineSwitcher : IJsEngineSwitcher
{
+ ///
+ /// Flag for whether to allow usage of the property
+ ///
+ private static bool _allowCurrentProperty = true;
+
///
/// Default instance of JS engine switcher
///
@@ -20,6 +25,19 @@ private static readonly Lazy _default
///
private static IJsEngineSwitcher _current;
+ ///
+ /// Gets or sets a flag for whether to allow usage of the property
+ ///
+ ///
+ /// Required to ensure the usage of an instance of the JS engine switcher that is registered by using
+ /// the IServiceCollection interface.
+ ///
+ public static bool AllowCurrentProperty
+ {
+ get { return _allowCurrentProperty; }
+ set { _allowCurrentProperty = value; }
+ }
+
///
/// Gets or sets a instance of JS engine switcher
///
@@ -27,10 +45,22 @@ public static IJsEngineSwitcher Current
{
get
{
+ if (!_allowCurrentProperty)
+ {
+ throw new InvalidOperationException(
+ Strings.Configuration_GettingFromJsEngineSwitcherCurrentPropertyForbidden);
+ }
+
return _current ?? _default.Value;
}
set
{
+ if (!_allowCurrentProperty)
+ {
+ throw new InvalidOperationException(
+ Strings.Configuration_AssigningToJsEngineSwitcherCurrentPropertyForbidden);
+ }
+
_current = value;
}
}
@@ -71,18 +101,14 @@ public JsEngineSwitcher(JsEngineFactoryCollection engineFactories, string defaul
#region IJsEngineSwitcher implementation
- ///
- /// Gets or sets a name of default JS engine
- ///
+ ///
public string DefaultEngineName
{
get;
set;
}
- ///
- /// Gets a collection of JS engine factories
- ///
+ ///
public JsEngineFactoryCollection EngineFactories
{
get;
@@ -90,11 +116,7 @@ public JsEngineFactoryCollection EngineFactories
}
- ///
- /// Creates a instance of JS engine
- ///
- /// JS engine name
- /// JS engine
+ ///
public IJsEngine CreateEngine(string name)
{
IJsEngine engine;
@@ -113,10 +135,7 @@ public IJsEngine CreateEngine(string name)
return engine;
}
- ///
- /// Creates a instance of default JS engine
- ///
- /// JS engine
+ ///
public IJsEngine CreateDefaultEngine()
{
string defaultJsEngineName = DefaultEngineName;
diff --git a/src/JavaScriptEngineSwitcher.Core/PACKAGE-DESCRIPTION.md b/src/JavaScriptEngineSwitcher.Core/PACKAGE-DESCRIPTION.md
new file mode 100644
index 00000000..663374d6
--- /dev/null
+++ b/src/JavaScriptEngineSwitcher.Core/PACKAGE-DESCRIPTION.md
@@ -0,0 +1,2 @@
+JavaScript Engine Switcher determines unified interface for access to the basic features of popular JavaScript engines ([ChakraCore](https://github.com/chakra-core/ChakraCore), [Jint](https://github.com/sebastienros/jint), [Jurassic](https://github.com/paulbartrum/jurassic), [MSIE JavaScript Engine for .NET](https://github.com/Taritsyn/MsieJavaScriptEngine), [NiL.JS](https://github.com/nilproject/NiL.JS), [Jering.Javascript.NodeJS](https://github.com/JeringTech/Javascript.NodeJS), [Microsoft ClearScript.V8](https://github.com/Microsoft/ClearScript), [VroomJs](https://github.com/pauldotknopf/vroomjs-core) and [YantraJS](https://yantrajs.com/)).
+This library allows you to quickly and easily switch to using of another JavaScript engine.
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.Core/Resources/Strings.Designer.cs b/src/JavaScriptEngineSwitcher.Core/Resources/Strings.Designer.cs
index 4abda526..8dc14700 100644
--- a/src/JavaScriptEngineSwitcher.Core/Resources/Strings.Designer.cs
+++ b/src/JavaScriptEngineSwitcher.Core/Resources/Strings.Designer.cs
@@ -21,7 +21,7 @@ public class Strings
private static Lazy _resourceManager =
new Lazy(() => new ResourceManager(
"JavaScriptEngineSwitcher.Core.Resources.Strings",
-#if NET40
+#if NET20 || NET30 || NET35 || NET40
typeof(Strings).Assembly
#else
typeof(Strings).GetTypeInfo().Assembly
@@ -137,6 +137,14 @@ public static string Common_ValueTypeCannotBeNull
get { return GetString("Common_ValueTypeCannotBeNull"); }
}
+ ///
+ /// Looks up a localized string similar to "Assigning an instance of the JS engine switcher to the `Current` property of `JsEngineSwitcher`..."
+ ///
+ public static string Configuration_AssigningToJsEngineSwitcherCurrentPropertyForbidden
+ {
+ get { return GetString("Configuration_AssigningToJsEngineSwitcherCurrentPropertyForbidden"); }
+ }
+
///
/// Looks up a localized string similar to "Name of default JavaScript engine not specified."
///
@@ -145,6 +153,14 @@ public static string Configuration_DefaultJsEngineNameNotSpecified
get { return GetString("Configuration_DefaultJsEngineNameNotSpecified"); }
}
+ ///
+ /// Looks up a localized string similar to "Getting an instance of the JS engine switcher from the `Current` property of `JsEngineSwitcher`..."
+ ///
+ public static string Configuration_GettingFromJsEngineSwitcherCurrentPropertyForbidden
+ {
+ get { return GetString("Configuration_GettingFromJsEngineSwitcherCurrentPropertyForbidden"); }
+ }
+
///
/// Looks up a localized string similar to "Could not find a factory, that creates an instance of the JavaScript engine with name `{0}`."
///
@@ -338,7 +354,7 @@ public static string Usage_CannotConvertPrecompiledScriptToInternalType
}
///
- /// Looks up a localized string similar to "Сannot execute a '{0}' file, because it is empty."
+ /// Looks up a localized string similar to "Cannot execute a '{0}' file, because it is empty."
///
public static string Usage_CannotExecuteEmptyFile
{
@@ -346,7 +362,7 @@ public static string Usage_CannotExecuteEmptyFile
}
///
- /// Looks up a localized string similar to "Сannot execute a '{0}' resource, because it is empty."
+ /// Looks up a localized string similar to "Cannot execute a '{0}' resource, because it is empty."
///
public static string Usage_CannotExecuteEmptyResource
{
@@ -354,7 +370,7 @@ public static string Usage_CannotExecuteEmptyResource
}
///
- /// Looks up a localized string similar to "Сannot execute a pre-compiled script, because it was created for another JS engine with name `{0}`."
+ /// Looks up a localized string similar to "Cannot execute a pre-compiled script, because it was created for another JS engine with name `{0}`."
///
public static string Usage_CannotExecutePrecompiledScriptForAnotherJsEngine
{
@@ -362,7 +378,7 @@ public static string Usage_CannotExecutePrecompiledScriptForAnotherJsEngine
}
///
- /// Looks up a localized string similar to "Сannot pre-compile a '{0}' file, because it is empty."
+ /// Looks up a localized string similar to "Cannot pre-compile a '{0}' file, because it is empty."
///
public static string Usage_CannotPrecompileEmptyFile
{
@@ -370,7 +386,7 @@ public static string Usage_CannotPrecompileEmptyFile
}
///
- /// Looks up a localized string similar to "Сannot pre-compile a '{0}' resource, because it is empty."
+ /// Looks up a localized string similar to "Cannot pre-compile a '{0}' resource, because it is empty."
///
public static string Usage_CannotPrecompileEmptyResource
{
diff --git a/src/JavaScriptEngineSwitcher.Core/Resources/Strings.resx b/src/JavaScriptEngineSwitcher.Core/Resources/Strings.resx
index 85f6dd1b..d72925bf 100644
--- a/src/JavaScriptEngineSwitcher.Core/Resources/Strings.resx
+++ b/src/JavaScriptEngineSwitcher.Core/Resources/Strings.resx
@@ -147,9 +147,15 @@
Cannot convert null to a value type.
+
+ Assigning an instance of the JS engine switcher to the `Current` property of `JsEngineSwitcher` class is forbidden. To register an instance of the JS engine switcher, use the `IServiceCollection` interface or set the `AllowCurrentProperty` property of `JsEngineSwitcher` class to `true`.
+
Name of default JavaScript engine not specified.
+
+ Getting an instance of the JS engine switcher from the `Current` property of `JsEngineSwitcher` class is forbidden. To get an instance of the JS engine switcher, use the `IServiceCollection` interface or set the `AllowCurrentProperty` property of `JsEngineSwitcher` class to `true`.
+
Could not find a factory, that creates an instance of the JavaScript engine with name `{0}`.
@@ -223,19 +229,19 @@
Cannot convert a pre-compiled script to internal type `{0}`.
- Сannot execute a '{0}' file, because it is empty.
+ Cannot execute a '{0}' file, because it is empty.
- Сannot execute a '{0}' resource, because it is empty.
+ Cannot execute a '{0}' resource, because it is empty.
- Сannot execute a pre-compiled script, because it was created for another JS engine with name `{0}`.
+ Cannot execute a pre-compiled script, because it was created for another JS engine with name `{0}`.
- Сannot pre-compile a '{0}' file, because it is empty.
+ Cannot pre-compile a '{0}' file, because it is empty.
- Сannot pre-compile a '{0}' resource, because it is empty.
+ Cannot pre-compile a '{0}' resource, because it is empty.
The embedded host object '{0}' has a type `{1}`, which is not supported.
diff --git a/src/JavaScriptEngineSwitcher.Core/Resources/Strings.ru-ru.Designer.cs b/src/JavaScriptEngineSwitcher.Core/Resources/Strings.ru-RU.Designer.cs
similarity index 100%
rename from src/JavaScriptEngineSwitcher.Core/Resources/Strings.ru-ru.Designer.cs
rename to src/JavaScriptEngineSwitcher.Core/Resources/Strings.ru-RU.Designer.cs
diff --git a/src/JavaScriptEngineSwitcher.Core/Resources/Strings.ru-ru.resx b/src/JavaScriptEngineSwitcher.Core/Resources/Strings.ru-RU.resx
similarity index 91%
rename from src/JavaScriptEngineSwitcher.Core/Resources/Strings.ru-ru.resx
rename to src/JavaScriptEngineSwitcher.Core/Resources/Strings.ru-RU.resx
index 8f1a2f20..a51ccdf8 100644
--- a/src/JavaScriptEngineSwitcher.Core/Resources/Strings.ru-ru.resx
+++ b/src/JavaScriptEngineSwitcher.Core/Resources/Strings.ru-RU.resx
@@ -147,9 +147,15 @@
Невозможно преобразовать null в значимый тип!
+
+ Присвоение экземпляра JS engine switcher свойству `Current` класса `JsEngineSwitcher` запрещено. Для регистрации экземпляра JS engine switcher используйте интерфейс `IServiceCollection` или присвойте свойству `AllowCurrentProperty` класса `JsEngineSwitcher` значение равное `true`.
+
Не указано имя JavaScript-движка, который должен использоваться по умолчанию!
+
+ Присвоение экземпляра JS engine switcher свойству `Current` класса `JsEngineSwitcher` запрещено. Для регистрации экземпляра JS engine switcher используйте интерфейс `IServiceCollection` или присвойте свойству `AllowCurrentProperty` класса `JsEngineSwitcher` значение равное `true`.
+
Не удалось найти фабрику, создающую экземпляр JavaScript-движка с именем `{0}`!
diff --git a/src/JavaScriptEngineSwitcher.Core/Undefined.cs b/src/JavaScriptEngineSwitcher.Core/Undefined.cs
index d9fb7f96..0340b9e8 100644
--- a/src/JavaScriptEngineSwitcher.Core/Undefined.cs
+++ b/src/JavaScriptEngineSwitcher.Core/Undefined.cs
@@ -1,12 +1,12 @@
namespace JavaScriptEngineSwitcher.Core
{
///
- /// Represents an JS undefined type
+ /// Represents an JS undefined type
///
public sealed class Undefined
{
///
- /// Gets a one and only undefined instance
+ /// Gets a one and only undefined instance
///
public static readonly Undefined Value = new Undefined();
diff --git a/src/JavaScriptEngineSwitcher.Core/Utilities/TypeConverter.cs b/src/JavaScriptEngineSwitcher.Core/Utilities/TypeConverter.cs
index 1752ce92..fcd47cd4 100644
--- a/src/JavaScriptEngineSwitcher.Core/Utilities/TypeConverter.cs
+++ b/src/JavaScriptEngineSwitcher.Core/Utilities/TypeConverter.cs
@@ -50,7 +50,7 @@ public static object ConvertToType(object value, Type targetType)
/// The type to convert the value to
/// The value to convert
/// The value that has been converted to the target type
- /// Result of conversion (true - success; false - failure)
+ /// Result of conversion (true - success; false - failure)
public static bool TryConvertToType(object value, out T convertedValue)
{
object resultValue;
@@ -68,7 +68,7 @@ public static bool TryConvertToType(object value, out T convertedValue)
/// The value to convert
/// The type to convert the value to
/// The value that has been converted to the target type
- /// Result of conversion (true - success; false - failure)
+ /// Result of conversion (true - success; false - failure)
public static bool TryConvertToType(object value, Type targetType, out object convertedValue)
{
bool result = ConvertObjectToType(value, targetType, false, out convertedValue);
diff --git a/src/JavaScriptEngineSwitcher.Core/Utilities/Utils.cs b/src/JavaScriptEngineSwitcher.Core/Utilities/Utils.cs
index 60bd2028..f26cd11b 100644
--- a/src/JavaScriptEngineSwitcher.Core/Utilities/Utils.cs
+++ b/src/JavaScriptEngineSwitcher.Core/Utilities/Utils.cs
@@ -31,7 +31,7 @@ static Utils()
///
/// Determines whether the current runtime is Mono
///
- /// true if the runtime is Mono; otherwise, false
+ /// true if the runtime is Mono; otherwise, false
public static bool IsMonoRuntime()
{
return _isMonoRuntime;
@@ -40,7 +40,7 @@ public static bool IsMonoRuntime()
///
/// Determines whether the current process is a 64-bit process
///
- /// true if the process is 64-bit; otherwise, false
+ /// true if the process is 64-bit; otherwise, false
[MethodImpl((MethodImplOptions)256 /* AggressiveInlining */)]
public static bool Is64BitProcess()
{
@@ -59,7 +59,7 @@ public static bool Is64BitProcess()
/// The case-sensitive resource name without the namespace of the specified type
/// The type, that determines the assembly and whose namespace is used to scope
/// the resource name
- /// Сontent of the embedded resource as string
+ /// Content of the embedded resource as string
public static string GetResourceAsString(string resourceName, Type type)
{
if (resourceName == null)
@@ -102,7 +102,7 @@ public static string GetResourceAsString(string resourceName, Type type)
///
/// The case-sensitive resource name
/// The assembly, which contains the embedded resource
- /// Сontent of the embedded resource as string
+ /// Content of the embedded resource as string
public static string GetResourceAsString(string resourceName, Assembly assembly)
{
if (resourceName == null)
diff --git a/src/JavaScriptEngineSwitcher.Core/readme.txt b/src/JavaScriptEngineSwitcher.Core/readme.txt
index f553fa07..cf5e35d8 100644
--- a/src/JavaScriptEngineSwitcher.Core/readme.txt
+++ b/src/JavaScriptEngineSwitcher.Core/readme.txt
@@ -1,51 +1,21 @@
--------------------------------------------------------------------------------
- README file for JS Engine Switcher: Core v3.0.0
+ README file for JS Engine Switcher: Core v3.24.1
--------------------------------------------------------------------------------
- Copyright (c) 2013-2018 Andrey Taritsyn - http://www.taritsyn.ru
+ Copyright (c) 2013-2024 Andrey Taritsyn - http://www.taritsyn.ru
===========
DESCRIPTION
===========
JavaScript Engine Switcher determines unified interface for access to the basic
- features of popular JavaScript engines (MSIE JavaScript Engine for .NET,
- Microsoft ClearScript.V8, Jurassic, Jint, ChakraCore, VroomJs and NiL.JS). This
- library allows you to quickly and easily switch to using of another JavaScript
- engine.
-
- =============
- RELEASE NOTES
- =============
- 1. In the `JsEngineSwitcher` class a `Instance` property was renamed to the
- `Current` property;
- 2. Now you can implement your own version of the `JsEngineSwitcher` class;
- 3. Format of the error messages was unified;
- 4. Created a new exception classes: `JsCompilationException`,
- `JsEngineException`, `JsFatalException`, `JsInterruptedException`,
- `JsTimeoutException`, `JsScriptException` and `JsUsageException`. These
- exceptions are responsible for handling errors, some of which were
- previously handled by the `JsRuntimeException` class;
- 5. In the `JsException` class was added two new properties: `Category` and
- `Description`;
- 6. From the `JsRuntimeException` class was removed one property - `ErrorCode`;
- 7. In the `JsRuntimeException` class was added three new properties: `Type`,
- `DocumentName` and `CallStack`;
- 8. `JsEngineLoadException` class now is inherited from the `JsEngineException`
- class;
- 9. Removed a `EmptyValueException` class;
- 10. `Format` method of the `JsErrorHelpers` class was renamed to the
- `GenerateErrorDetails`;
- 11. Part of the auxiliary code was moved to external libraries:
- PolyfillsForOldDotNet and AdvancedStringBuilder;
- 12. In `IJsEngine` interface was added two new properties:
- `SupportsScriptInterruption` and `SupportsScriptPrecompilation`, and four
- new methods: `Interrupt`, `Precompile`, `PrecompileFile` and
- `PrecompileResource`;
- 13. Added support of .NET Standard 2.0.
+ features of popular JavaScript engines (ChakraCore, Jint, Jurassic, MSIE
+ JavaScript Engine for .NET, NiL.JS, Jering.Javascript.NodeJS, Microsoft
+ ClearScript.V8, VroomJs and YantraJS). This library allows you to quickly and
+ easily switch to using of another JavaScript engine.
=============
DOCUMENTATION
diff --git a/src/JavaScriptEngineSwitcher.Extensions.MsDependencyInjection/JavaScriptEngineSwitcher.Extensions.MsDependencyInjection.csproj b/src/JavaScriptEngineSwitcher.Extensions.MsDependencyInjection/JavaScriptEngineSwitcher.Extensions.MsDependencyInjection.csproj
index f8703a5e..906de85a 100644
--- a/src/JavaScriptEngineSwitcher.Extensions.MsDependencyInjection/JavaScriptEngineSwitcher.Extensions.MsDependencyInjection.csproj
+++ b/src/JavaScriptEngineSwitcher.Extensions.MsDependencyInjection/JavaScriptEngineSwitcher.Extensions.MsDependencyInjection.csproj
@@ -1,42 +1,38 @@
-
- JS Engine Switcher: MS Dependency Injection
- 3.0.0
- net45;netstandard1.3;netstandard2.0
- 1.6.0
- Library
- true
- $(NoWarn);CS1591;NU5125
- true
- JavaScriptEngineSwitcher.Extensions.MsDependencyInjection contains extension methods for adding the JS engine switcher in an `IServiceCollection`.
- https://raw.githubusercontent.com/Taritsyn/JavaScriptEngineSwitcher/master/Icons/JavaScriptEngineSwitcher_Extensions_MsDependencyInjection_Logo128x128.png
- JavaScriptEngineSwitcher;JavaScript;ECMAScript;DI
- 1. Added a overloaded versions of the `AddJsEngineSwitcher` extension method, which takes an instance of JS engine switcher;
-2. Added support of .NET Standard 2.0.
-
+
+ JS Engine Switcher: MS Dependency Injection
+ 3.24.1
+ net45;netstandard1.3;netstandard2.0
+ 1.6.0
+ Library
+ true
+ $(NoWarn);CS1591;NETSDK1215;NU1903
+ false
+ true
+
-
-
-
+
+
+
-
-
-
+
+ https://raw.githubusercontent.com/Taritsyn/JavaScriptEngineSwitcher/master/Icons/JavaScriptEngineSwitcher_Extensions_MsDependencyInjection_Logo128x128.png
+ ../../Icons/JavaScriptEngineSwitcher_Extensions_MsDependencyInjection_Logo128x128.png
+ JavaScriptEngineSwitcher.Extensions.MsDependencyInjection contains extension methods for adding the JS engine switcher in an `IServiceCollection`.
+ $(PackageCommonTags);DI
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
- readme.txt
- true
-
-
+
+
+
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.Extensions.MsDependencyInjection/JsEngineSwitcherOptions.cs b/src/JavaScriptEngineSwitcher.Extensions.MsDependencyInjection/JsEngineSwitcherOptions.cs
new file mode 100644
index 00000000..f22887a3
--- /dev/null
+++ b/src/JavaScriptEngineSwitcher.Extensions.MsDependencyInjection/JsEngineSwitcherOptions.cs
@@ -0,0 +1,42 @@
+using JavaScriptEngineSwitcher.Core;
+
+namespace JavaScriptEngineSwitcher.Extensions.MsDependencyInjection
+{
+ ///
+ /// Options of the JS engine switcher
+ ///
+ public sealed class JsEngineSwitcherOptions
+ {
+ ///
+ /// Gets or sets a flag for whether to allow usage of the property
+ ///
+ ///
+ /// Required to ensure the usage of an instance of the JS engine switcher that is registered by using
+ /// the IServiceCollection interface.
+ ///
+ public bool AllowCurrentProperty
+ {
+ get;
+ set;
+ }
+
+ ///
+ /// Gets or sets a name of default JS engine
+ ///
+ public string DefaultEngineName
+ {
+ get;
+ set;
+ }
+
+
+ ///
+ /// Constructs an instance of the JS engine switcher options
+ ///
+ public JsEngineSwitcherOptions()
+ {
+ AllowCurrentProperty = true;
+ DefaultEngineName = string.Empty;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.Extensions.MsDependencyInjection/JsEngineSwitcherServiceCollectionExtensions.cs b/src/JavaScriptEngineSwitcher.Extensions.MsDependencyInjection/JsEngineSwitcherServiceCollectionExtensions.cs
index 38ec18ff..624b2f76 100644
--- a/src/JavaScriptEngineSwitcher.Extensions.MsDependencyInjection/JsEngineSwitcherServiceCollectionExtensions.cs
+++ b/src/JavaScriptEngineSwitcher.Extensions.MsDependencyInjection/JsEngineSwitcherServiceCollectionExtensions.cs
@@ -7,26 +7,37 @@
namespace JavaScriptEngineSwitcher.Extensions.MsDependencyInjection
{
///
- /// Extension methods for adding the JS engine switcher in an
+ /// Extension methods for adding the JS engine switcher in an
///
public static class JsEngineSwitcherServiceCollectionExtensions
{
///
- /// Adds a default instance of JS engine switcher to
+ /// Adds a default instance of the JS engine switcher to the
///
/// The services available in the application
- /// Instance of
+ /// Instance of the
public static JsEngineFactoryCollection AddJsEngineSwitcher(this IServiceCollection services)
{
- return AddJsEngineSwitcher(services, (IJsEngineSwitcher)null);
+ if (services == null)
+ {
+ throw new ArgumentNullException(nameof(services));
+ }
+
+ var options = new JsEngineSwitcherOptions();
+
+ IJsEngineSwitcher engineSwitcher = CreateJsEngineSwitcher(options);
+ ApplyOptionsToJsEngineSwitcher(engineSwitcher, options);
+ RegisterJsEngineSwitcher(services, engineSwitcher, options);
+
+ return engineSwitcher.EngineFactories;
}
///
- /// Adds a specified instance of JS engine switcher to
+ /// Adds a specified instance of the JS engine switcher to the
///
/// The services available in the application
- /// Instance of JS engine switcher
- /// Instance of
+ /// Instance of the JS engine switcher
+ /// Instance of the
public static JsEngineFactoryCollection AddJsEngineSwitcher(this IServiceCollection services,
IJsEngineSwitcher engineSwitcher)
{
@@ -35,61 +46,149 @@ public static JsEngineFactoryCollection AddJsEngineSwitcher(this IServiceCollect
throw new ArgumentNullException(nameof(services));
}
- // Set the current instance of JS engine switcher
- JsEngineSwitcher.Current = engineSwitcher;
+ if (engineSwitcher == null)
+ {
+ throw new ArgumentNullException(nameof(engineSwitcher));
+ }
- // Get the current instance of JS engine switcher
- IJsEngineSwitcher currentEngineSwitcher = JsEngineSwitcher.Current;
+ var options = new JsEngineSwitcherOptions();
- // Register the current instance of JS engine switcher as a service
- services.AddSingleton(currentEngineSwitcher);
+ IJsEngineSwitcher currentEngineSwitcher = GetJsEngineSwitcher(engineSwitcher, options);
+ ApplyOptionsToJsEngineSwitcher(currentEngineSwitcher, options);
+ RegisterJsEngineSwitcher(services, currentEngineSwitcher, options);
return currentEngineSwitcher.EngineFactories;
}
///
- /// Adds a default instance of JS engine switcher to
+ /// Adds a default instance of the JS engine switcher to the
///
/// The services available in the application
- /// The which need to be configured
- /// Instance of
+ /// The which need to be configured
+ /// Instance of the
public static JsEngineFactoryCollection AddJsEngineSwitcher(this IServiceCollection services,
- Action configure)
+ Action configure)
{
- return AddJsEngineSwitcher(services, null, configure);
+ if (services == null)
+ {
+ throw new ArgumentNullException(nameof(services));
+ }
+
+ if (configure == null)
+ {
+ throw new ArgumentNullException(nameof(configure));
+ }
+
+ var options = new JsEngineSwitcherOptions();
+ configure(options);
+
+ IJsEngineSwitcher engineSwitcher = CreateJsEngineSwitcher(options);
+ ApplyOptionsToJsEngineSwitcher(engineSwitcher, options);
+ RegisterJsEngineSwitcher(services, engineSwitcher, options);
+
+ return engineSwitcher.EngineFactories;
}
///
- /// Adds a specified instance of JS engine switcher to
+ /// Adds a specified instance of the JS engine switcher to
///
/// The services available in the application
- /// Instance of JS engine switcher
- /// The which need to be configured
- /// Instance of
+ /// Instance of the JS engine switcher
+ /// The which need to be configured
+ /// Instance of the
public static JsEngineFactoryCollection AddJsEngineSwitcher(this IServiceCollection services,
- IJsEngineSwitcher engineSwitcher, Action configure)
+ IJsEngineSwitcher engineSwitcher, Action configure)
{
if (services == null)
{
throw new ArgumentNullException(nameof(services));
}
+ if (engineSwitcher == null)
+ {
+ throw new ArgumentNullException(nameof(engineSwitcher));
+ }
+
if (configure == null)
{
throw new ArgumentNullException(nameof(configure));
}
- // Set the current instance of JS engine switcher
- JsEngineSwitcher.Current = engineSwitcher;
+ var options = new JsEngineSwitcherOptions();
+ configure(options);
- // Get and configure the current instance of JS engine switcher
- IJsEngineSwitcher currentEngineSwitcher = JsEngineSwitcher.Current;
- configure(currentEngineSwitcher);
+ IJsEngineSwitcher currentEngineSwitcher = GetJsEngineSwitcher(engineSwitcher, options);
+ ApplyOptionsToJsEngineSwitcher(currentEngineSwitcher, options);
+ RegisterJsEngineSwitcher(services, currentEngineSwitcher, options);
+ return currentEngineSwitcher.EngineFactories;
+ }
+
+ #region Helper methods
+
+ ///
+ /// Creates an instance of the JS engine switcher
+ ///
+ /// Options of the JS engine switcher
+ /// Instance of the JS engine switcher
+ private static IJsEngineSwitcher CreateJsEngineSwitcher(JsEngineSwitcherOptions options)
+ {
+ IJsEngineSwitcher engineSwitcher = options.AllowCurrentProperty ?
+ JsEngineSwitcher.Current
+ :
+ new JsEngineSwitcher()
+ ;
+
+ return engineSwitcher;
+ }
+
+ ///
+ /// Gets a instance of the JS engine switcher
+ ///
+ /// Instance of the JS engine switcher
+ /// Options of the JS engine switcher
+ /// Current instance of the JS engine switcher
+ private static IJsEngineSwitcher GetJsEngineSwitcher(IJsEngineSwitcher engineSwitcher, JsEngineSwitcherOptions options)
+ {
+ IJsEngineSwitcher currentEngineSwitcher = options.AllowCurrentProperty ?
+ JsEngineSwitcher.Current
+ :
+ engineSwitcher
+ ;
+
+ return currentEngineSwitcher;
+ }
+
+ ///
+ /// Applies a options to the JS engine switcher
+ ///
+ /// Instance of the JS engine switcher
+ /// Options of the JS engine switcher
+ private static void ApplyOptionsToJsEngineSwitcher(IJsEngineSwitcher engineSwitcher, JsEngineSwitcherOptions options)
+ {
+ JsEngineSwitcher.AllowCurrentProperty = options.AllowCurrentProperty;
+ engineSwitcher.DefaultEngineName = options.DefaultEngineName;
+ }
+
+ ///
+ /// Registers a instance of the JS engine switcher
+ ///
+ /// The services available in the application
+ /// Instance of the JS engine switcher
+ /// Options of the JS engine switcher
+ private static void RegisterJsEngineSwitcher(IServiceCollection services, IJsEngineSwitcher engineSwitcher,
+ JsEngineSwitcherOptions options)
+ {
// Register the current instance of JS engine switcher as a service
- services.AddSingleton(currentEngineSwitcher);
+ services.AddSingleton(engineSwitcher);
- return currentEngineSwitcher.EngineFactories;
+ // Set the current instance of JS engine switcher
+ if (options.AllowCurrentProperty)
+ {
+ JsEngineSwitcher.Current = engineSwitcher;
+ }
}
+
+ #endregion
}
}
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.Extensions.MsDependencyInjection/PACKAGE-DESCRIPTION.md b/src/JavaScriptEngineSwitcher.Extensions.MsDependencyInjection/PACKAGE-DESCRIPTION.md
new file mode 100644
index 00000000..95b60008
--- /dev/null
+++ b/src/JavaScriptEngineSwitcher.Extensions.MsDependencyInjection/PACKAGE-DESCRIPTION.md
@@ -0,0 +1 @@
+JavaScriptEngineSwitcher.Extensions.MsDependencyInjection contains extension methods for adding the JS engine switcher in an `IServiceCollection`.
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.Extensions.MsDependencyInjection/readme.txt b/src/JavaScriptEngineSwitcher.Extensions.MsDependencyInjection/readme.txt
index b473d738..a4b6267d 100644
--- a/src/JavaScriptEngineSwitcher.Extensions.MsDependencyInjection/readme.txt
+++ b/src/JavaScriptEngineSwitcher.Extensions.MsDependencyInjection/readme.txt
@@ -1,11 +1,11 @@
--------------------------------------------------------------------------------
- README file for JS Engine Switcher: MS Dependency Injection v3.0.0
+ README file for JS Engine Switcher: MS Dependency Injection v3.24.1
--------------------------------------------------------------------------------
- Copyright (c) 2013-2018 Andrey Taritsyn - http://www.taritsyn.ru
+ Copyright (c) 2013-2024 Andrey Taritsyn - http://www.taritsyn.ru
===========
@@ -14,13 +14,6 @@
JavaScriptEngineSwitcher.Extensions.MsDependencyInjection contains extension
methods for adding the JS engine switcher in an `IServiceCollection`.
- =============
- RELEASE NOTES
- =============
- 1. Added a overloaded versions of the `AddJsEngineSwitcher` extension method,
- which takes an instance of JS engine switcher;
- 2. Added support of .NET Standard 2.0.
-
=============
DOCUMENTATION
=============
diff --git a/src/JavaScriptEngineSwitcher.Jint/CustomTypeResolvers.cs b/src/JavaScriptEngineSwitcher.Jint/CustomTypeResolvers.cs
new file mode 100644
index 00000000..4e1dfd8a
--- /dev/null
+++ b/src/JavaScriptEngineSwitcher.Jint/CustomTypeResolvers.cs
@@ -0,0 +1,112 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
+using System.Runtime.CompilerServices;
+
+using OriginalTypeResolver = Jint.Runtime.Interop.TypeResolver;
+
+namespace JavaScriptEngineSwitcher.Jint
+{
+ ///
+ /// Interop strategies for different values of the configuration property
+ ///
+ internal static class CustomTypeResolvers
+ {
+ private static readonly PropertyInfo[] _disallowedProperties =
+ {
+ typeof(Delegate).GetProperty("Method"),
+ typeof(Exception).GetProperty("TargetSite")
+ };
+
+ private static readonly MethodInfo[] _disallowedMethods =
+ {
+ typeof(object).GetMethod("GetType"),
+ typeof(Exception).GetMethod("GetType")
+ };
+
+ private static readonly Lazy _allowingReflection = new Lazy(
+ () => new OriginalTypeResolver() { MemberFilter = _ => true });
+
+ private static readonly Lazy _disallowingReflection = new Lazy(
+ () => new OriginalTypeResolver() { MemberFilter = IsAllowedMember });
+
+ ///
+ /// Gets a interop strategy that allows the usage of reflection API in the script code
+ ///
+ public static OriginalTypeResolver AllowingReflection => _allowingReflection.Value;
+
+ ///
+ /// Gets a interop strategy that disallows the usage of reflection API in the script code
+ ///
+ public static OriginalTypeResolver DisallowingReflection => _disallowingReflection.Value;
+
+
+ private static bool IsAllowedMember(MemberInfo member)
+ {
+ bool isAllowed = true;
+
+ if (member is PropertyInfo)
+ {
+ isAllowed = IsAllowedProperty((PropertyInfo)member);
+ }
+ else if (member is MethodInfo)
+ {
+ isAllowed = IsAllowedMethod((MethodInfo)member);
+ }
+
+ return isAllowed;
+ }
+
+ [MethodImpl((MethodImplOptions)256 /* AggressiveInlining */)]
+ private static bool IsAllowedProperty(PropertyInfo property)
+ {
+ bool isAllowed = !_disallowedProperties.Contains(property, MemberComparer.Instance);
+
+ return isAllowed;
+ }
+
+ [MethodImpl((MethodImplOptions)256 /* AggressiveInlining */)]
+ private static bool IsAllowedMethod(MethodInfo method)
+ {
+ bool isAllowed = !_disallowedMethods.Contains(method, MemberComparer.Instance);
+
+ return isAllowed;
+ }
+
+
+ private sealed class MemberComparer : EqualityComparer
+ where T : MemberInfo
+ {
+ public static MemberComparer Instance { get; } = new MemberComparer();
+
+
+ private MemberComparer()
+ { }
+
+
+ #region MemberComparer overrides
+
+ public override bool Equals(T x, T y)
+ {
+ if (x == null && y == null)
+ {
+ return true;
+ }
+ else if (x == null || y == null)
+ {
+ return false;
+ }
+
+ return x.Module == y.Module && x.MetadataToken == y.MetadataToken;
+ }
+
+ public override int GetHashCode(T obj)
+ {
+ return obj != null ? obj.GetHashCode() : 0;
+ }
+
+ #endregion
+ }
+ }
+}
diff --git a/src/JavaScriptEngineSwitcher.Jint/Helpers/JintJsErrorHelpers.cs b/src/JavaScriptEngineSwitcher.Jint/Helpers/JintJsErrorHelpers.cs
new file mode 100644
index 00000000..af37c9df
--- /dev/null
+++ b/src/JavaScriptEngineSwitcher.Jint/Helpers/JintJsErrorHelpers.cs
@@ -0,0 +1,219 @@
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Text;
+using System.Text.RegularExpressions;
+
+using AdvancedStringBuilder;
+
+using JavaScriptEngineSwitcher.Core.Extensions;
+using JavaScriptEngineSwitcher.Core.Helpers;
+
+using CoreStrings = JavaScriptEngineSwitcher.Core.Resources.Strings;
+
+namespace JavaScriptEngineSwitcher.Jint.Helpers
+{
+ ///
+ /// JS error helpers
+ ///
+ internal static class JintJsErrorHelpers
+ {
+ #region Error location
+
+ private const string OriginalAnonymousFunctionName = "(anonymous)";
+ private const string WrapperAnonymousFunctionName = "Anonymous function";
+ private const string DelegateFunctionName = "delegate";
+
+ ///
+ /// Pattern for working with document names with coordinates
+ ///
+ private static readonly string DocumentNameWithCoordinatesPattern =
+ @"(?" + CommonRegExps.DocumentNamePattern + @"):" +
+ @"(?\d+)(?::(?\d+))?";
+
+ ///
+ /// Regular expression for working with line of the script error location
+ ///
+ private static readonly Regex _errorLocationLineRegex =
+ new Regex(@"^[ ]{4}at " +
+ @"(?:" +
+ @"(?" +
+ @"[\w][\w ]*" +
+ @"|" +
+ CommonRegExps.JsFullNamePattern +
+ @"|" +
+ Regex.Escape(OriginalAnonymousFunctionName) +
+ @") " +
+ @"\(" + DocumentNameWithCoordinatesPattern + @"\)" +
+ @"|" +
+ DocumentNameWithCoordinatesPattern +
+ @")" +
+ "$");
+
+ ///
+ /// Regular expression for working with the syntax error message
+ ///
+ private static readonly Regex _syntaxErrorMessageRegex =
+ new Regex(@"^(?[\s\S]+?) \(" + CommonRegExps.DocumentNamePattern + @":\d+:\d+\)$");
+
+ ///
+ /// Regular expression for working with the script preparation error message
+ ///
+ private static readonly Regex _scriptPreparationErrorMessageRegex =
+ new Regex(@"^Could not prepare script: (?[\s\S]+?) " +
+ @"\((?" + CommonRegExps.DocumentNamePattern + @"):" +
+ @"(?\d+):(?\d+)\)$");
+
+
+ ///
+ /// Parses a string representation of the script error location to produce an array of
+ /// instances
+ ///
+ /// String representation of the script error location
+ /// An array of instances
+ public static ErrorLocationItem[] ParseErrorLocation(string errorLocation)
+ {
+ if (string.IsNullOrWhiteSpace(errorLocation))
+ {
+ return new ErrorLocationItem[0];
+ }
+
+ var errorLocationItems = new List();
+ string[] lines = errorLocation.SplitToLines();
+ int lineCount = lines.Length;
+
+ for (int lineIndex = 0; lineIndex < lineCount; lineIndex++)
+ {
+ string line = lines[lineIndex];
+ Match lineMatch = _errorLocationLineRegex.Match(line);
+
+ if (lineMatch.Success)
+ {
+ GroupCollection lineGroups = lineMatch.Groups;
+
+ var errorLocationItem = new ErrorLocationItem
+ {
+ FunctionName = lineGroups["functionName"].Value,
+ DocumentName = lineGroups["documentName"].Value,
+ LineNumber = int.Parse(lineGroups["lineNumber"].Value),
+ ColumnNumber = lineGroups["columnNumber"].Success ?
+ int.Parse(lineGroups["columnNumber"].Value) : 0
+ };
+ errorLocationItems.Add(errorLocationItem);
+ }
+ else
+ {
+ Debug.WriteLine(string.Format(CoreStrings.Runtime_InvalidErrorLocationLineFormat, line));
+ return new ErrorLocationItem[0];
+ }
+ }
+
+ return errorLocationItems.ToArray();
+ }
+
+ ///
+ /// Fixes a error location items
+ ///
+ /// An array of instances
+ public static void FixErrorLocationItems(ErrorLocationItem[] errorLocationItems)
+ {
+ foreach (ErrorLocationItem errorLocationItem in errorLocationItems)
+ {
+ string functionName = errorLocationItem.FunctionName;
+ if (functionName.Length == 0 || functionName == DelegateFunctionName)
+ {
+ errorLocationItem.FunctionName = "Global code";
+ }
+ else if (functionName == OriginalAnonymousFunctionName)
+ {
+ errorLocationItem.FunctionName = WrapperAnonymousFunctionName;
+ }
+ }
+ }
+
+ ///
+ /// Converts a call chain to stack
+ ///
+ /// Call chain
+ /// Call stack
+ public static string ConvertCallChainToStack(string callChain)
+ {
+ string callStack = string.Empty;
+ string[] callChainItems = callChain
+ .Split(new string[] { "->" }, StringSplitOptions.None)
+ ;
+
+ if (callChainItems.Length > 0)
+ {
+ var stringBuilderPool = StringBuilderPool.Shared;
+ StringBuilder stackBuilder = stringBuilderPool.Rent();
+
+ for (int chainItemIndex = callChainItems.Length - 1; chainItemIndex >= 0; chainItemIndex--)
+ {
+ string chainItem = callChainItems[chainItemIndex];
+ if (chainItem == OriginalAnonymousFunctionName)
+ {
+ chainItem = WrapperAnonymousFunctionName;
+ }
+
+ JsErrorHelpers.WriteErrorLocationLine(stackBuilder, chainItem, string.Empty, 0, 0);
+ if (chainItemIndex > 0)
+ {
+ stackBuilder.AppendLine();
+ }
+ }
+
+ callStack = stackBuilder.ToString();
+ stringBuilderPool.Return(stackBuilder);
+ }
+
+ return callStack;
+ }
+
+ ///
+ /// Gets a description from the syntax error message
+ ///
+ /// Error message
+ /// Description of error
+ public static string GetDescriptionFromSyntaxErrorMessage(string message)
+ {
+ Match messageMatch = _syntaxErrorMessageRegex.Match(message);
+ string description = messageMatch.Success ?
+ messageMatch.Groups["description"].Value : message;
+
+ return description;
+ }
+
+ ///
+ /// Parses a script preparation error message
+ ///
+ /// Error message
+ /// Description of error
+ /// Script error location
+ public static void ParseScriptPreparationErrorMessage(string message, out string description,
+ out ErrorLocationItem errorLocation)
+ {
+ Match messageMatch = _scriptPreparationErrorMessageRegex.Match(message);
+
+ if (messageMatch.Success)
+ {
+ GroupCollection messageGroups = messageMatch.Groups;
+
+ description = messageGroups["description"].Value;
+ errorLocation = new ErrorLocationItem
+ {
+ DocumentName = messageGroups["documentName"].Value,
+ LineNumber = int.Parse(messageGroups["lineNumber"].Value),
+ ColumnNumber = int.Parse(messageGroups["columnNumber"].Value)
+ };
+ }
+ else
+ {
+ description = message;
+ errorLocation = new ErrorLocationItem();
+ }
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.Jint/JavaScriptEngineSwitcher.Jint.csproj b/src/JavaScriptEngineSwitcher.Jint/JavaScriptEngineSwitcher.Jint.csproj
index e4b534ce..9c6413d6 100644
--- a/src/JavaScriptEngineSwitcher.Jint/JavaScriptEngineSwitcher.Jint.csproj
+++ b/src/JavaScriptEngineSwitcher.Jint/JavaScriptEngineSwitcher.Jint.csproj
@@ -1,45 +1,38 @@
-
- JS Engine Switcher: Jint
- 3.0.0
- net40-client;net45;netstandard1.3;netstandard2.0
- Library
- true
- $(NoWarn);CS1591;NU5125
- true
- true
- JavaScriptEngineSwitcher.Jint contains adapter `JintJsEngine` (wrapper for the Jint JavaScript Engine (http://github.com/sebastienros/jint) version 2.11.58).
- https://raw.githubusercontent.com/Taritsyn/JavaScriptEngineSwitcher/master/Icons/JavaScriptEngineSwitcher_Jint_Logo128x128.png
- JavaScriptEngineSwitcher;JavaScript;ECMAScript;Jint
- 1. Jint was updated to version 2.11.58;
-2. Added a ability to pre-compile scripts;
-3. In configuration settings of the Jint JS engine a `Timeout` property has been replaced by the `TimeoutInterval` property (default `TimeSpan.Zero`) and was added one new property - `LocalTimeZone` (default `TimeZoneInfo.Local`);
-4. Added support of .NET Standard 2.0.
-
+
+ JS Engine Switcher: Jint
+ 3.30.4
+ net462;netstandard2.0;netstandard2.1;net8.0
+ Library
+ true
+ $(NoWarn);CS1591;NU5104
+ false
+ true
+ true
+
-
-
-
-
+
+
+
+
-
-
-
+
+ https://raw.githubusercontent.com/Taritsyn/JavaScriptEngineSwitcher/master/Icons/JavaScriptEngineSwitcher_Jint_Logo128x128.png
+ ../../Icons/JavaScriptEngineSwitcher_Jint_Logo128x128.png
+ JavaScriptEngineSwitcher.Jint contains a `JintJsEngine` adapter (wrapper for the Jint).
+ $(PackageCommonTags);Jint
+ Jint was updated to version 4.5.0.
+
-
-
+
+
-
-
- readme.txt
- true
-
-
- jint-license.txt
- true
- false
-
-
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.Jint/JintJsEngine.cs b/src/JavaScriptEngineSwitcher.Jint/JintJsEngine.cs
index 038d3e84..0280efb5 100644
--- a/src/JavaScriptEngineSwitcher.Jint/JintJsEngine.cs
+++ b/src/JavaScriptEngineSwitcher.Jint/JintJsEngine.cs
@@ -1,21 +1,26 @@
using System;
-using System.Text;
+using System.Threading;
-using IOriginalCallable = Jint.Native.ICallable;
+using Jint;
+using IOriginalPrimitive = Jint.Native.IJsPrimitive;
+using OriginalCancellationConstraint = Jint.Constraints.CancellationConstraint;
+using OriginalDebuggerEventHandler = Jint.Runtime.Debugger.DebugHandler.DebugEventHandler;
+using OriginalDebuggerStatementHandlingMode = Jint.Runtime.Debugger.DebuggerStatementHandling;
using OriginalEngine = Jint.Engine;
+using OriginalErrorPosition = Acornima.Position;
+using OriginalExecutionCanceledException = Jint.Runtime.ExecutionCanceledException;
+using OriginalException = Jint.JintException;
using OriginalJavaScriptException = Jint.Runtime.JavaScriptException;
+using OriginalMemoryLimitExceededException = Jint.Runtime.MemoryLimitExceededException;
using OriginalObjectInstance = Jint.Native.Object.ObjectInstance;
-using OriginalParser = Jint.Parser.JavaScriptParser;
-using OriginalParserException = Jint.Parser.ParserException;
-using OriginalParserOptions = Jint.Parser.ParserOptions;
-using OriginalProgram = Jint.Parser.Ast.Program;
+using OriginalParsedScript = Jint.Prepared;
using OriginalRecursionDepthOverflowException = Jint.Runtime.RecursionDepthOverflowException;
+using OriginalScriptPreparationException = Jint.ScriptPreparationException;
using OriginalStatementsCountOverflowException = Jint.Runtime.StatementsCountOverflowException;
using OriginalTypeReference = Jint.Runtime.Interop.TypeReference;
+using OriginalTypes = Jint.Runtime.Types;
using OriginalValue = Jint.Native.JsValue;
-using AdvancedStringBuilder;
-
using JavaScriptEngineSwitcher.Core;
using JavaScriptEngineSwitcher.Core.Constants;
using JavaScriptEngineSwitcher.Core.Helpers;
@@ -23,11 +28,14 @@
using CoreStrings = JavaScriptEngineSwitcher.Core.Resources.Strings;
using WrapperCompilationException = JavaScriptEngineSwitcher.Core.JsCompilationException;
-using WrapperException = JavaScriptEngineSwitcher.Core.JsException;
+using WrapperInterruptedException = JavaScriptEngineSwitcher.Core.JsInterruptedException;
using WrapperRuntimeException = JavaScriptEngineSwitcher.Core.JsRuntimeException;
+using WrapperScriptException = JavaScriptEngineSwitcher.Core.JsScriptException;
using WrapperTimeoutException = JavaScriptEngineSwitcher.Core.JsTimeoutException;
using WrapperUsageException = JavaScriptEngineSwitcher.Core.JsUsageException;
+using JavaScriptEngineSwitcher.Jint.Helpers;
+
namespace JavaScriptEngineSwitcher.Jint
{
///
@@ -43,7 +51,7 @@ public sealed class JintJsEngine : JsEngineBase
///
/// Version of original JS engine
///
- private const string EngineVersion = "2.11.58";
+ private const string EngineVersion = "4.5.0";
///
/// Jint JS engine
@@ -51,7 +59,32 @@ public sealed class JintJsEngine : JsEngineBase
private OriginalEngine _jsEngine;
///
- /// Synchronizer of code execution
+ /// Token source for canceling of script execution
+ ///
+ private CancellationTokenSource _cancellationTokenSource;
+
+ ///
+ /// Constraint for canceling of script execution
+ ///
+ private OriginalCancellationConstraint _cancellationConstraint;
+
+ ///
+ /// Debugger break callback
+ ///
+ private OriginalDebuggerEventHandler _debuggerBreakCallback;
+
+ ///
+ /// Debugger step callback
+ ///
+ private OriginalDebuggerEventHandler _debuggerStepCallback;
+
+ ///
+ /// Flag for whether to allow run the script in strict mode
+ ///
+ private bool _strictMode;
+
+ ///
+ /// Synchronizer of script execution
///
private readonly object _executionSynchronizer = new object();
@@ -75,19 +108,54 @@ public JintJsEngine()
/// Settings of the Jint JS engine
public JintJsEngine(JintSettings settings)
{
+ _cancellationTokenSource = new CancellationTokenSource();
+
JintSettings jintSettings = settings ?? new JintSettings();
+ _debuggerBreakCallback = jintSettings.DebuggerBreakCallback;
+ _debuggerStepCallback = jintSettings.DebuggerStepCallback;
+ var debuggerStatementHandlingMode = Utils.GetEnumFromOtherEnum(
+ jintSettings.DebuggerStatementHandlingMode);
try
{
- _jsEngine = new OriginalEngine(c => c
- .AllowDebuggerStatement(jintSettings.AllowDebuggerStatement)
- .DebugMode(jintSettings.EnableDebugging)
- .LimitRecursion(jintSettings.MaxRecursionDepth)
- .LocalTimeZone(jintSettings.LocalTimeZone ?? TimeZoneInfo.Local)
- .MaxStatements(jintSettings.MaxStatements)
- .Strict(jintSettings.StrictMode)
- .TimeoutInterval(jintSettings.TimeoutInterval)
- );
+ _jsEngine = new OriginalEngine(options => {
+ options.Interop.AllowGetType = true;
+ options.Interop.AllowSystemReflection = true;
+
+ options
+ .CancellationToken(_cancellationTokenSource.Token)
+ .DebuggerStatementHandling(debuggerStatementHandlingMode)
+ .DebugMode(jintSettings.EnableDebugging)
+ .DisableStringCompilation(jintSettings.DisableEval)
+ .LimitMemory(jintSettings.MemoryLimit)
+ .LimitRecursion(jintSettings.MaxRecursionDepth)
+ .LocalTimeZone(jintSettings.LocalTimeZone ?? TimeZoneInfo.Local)
+ .MaxArraySize(jintSettings.MaxArraySize)
+ .MaxJsonParseDepth(jintSettings.MaxJsonParseDepth)
+ .MaxStatements(jintSettings.MaxStatements)
+ .Strict(jintSettings.StrictMode)
+ .TimeoutInterval(jintSettings.TimeoutInterval)
+ ;
+
+ if (jintSettings.RegexTimeoutInterval.HasValue)
+ {
+ options.RegexTimeoutInterval(jintSettings.RegexTimeoutInterval.Value);
+ }
+
+ options.AddObjectConverter(new UndefinedConverter());
+ options.SetTypeResolver(jintSettings.AllowReflection ?
+ CustomTypeResolvers.AllowingReflection : CustomTypeResolvers.DisallowingReflection);
+ });
+ _cancellationConstraint = _jsEngine.Constraints.Find();
+ if (_debuggerBreakCallback != null)
+ {
+ _jsEngine.Debugger.Break += _debuggerBreakCallback;
+ }
+ if (_debuggerStepCallback != null)
+ {
+ _jsEngine.Debugger.Step += _debuggerStepCallback;
+ }
+ _strictMode = settings.StrictMode;
}
catch (Exception e)
{
@@ -105,11 +173,6 @@ public JintJsEngine(JintSettings settings)
/// The mapped value
private OriginalValue MapToScriptType(object value)
{
- if (value is Undefined)
- {
- return OriginalValue.Undefined;
- }
-
return OriginalValue.FromObject(_jsEngine, value);
}
@@ -120,148 +183,164 @@ private OriginalValue MapToScriptType(object value)
/// The mapped value
private object MapToHostType(OriginalValue value)
{
- if (value.IsUndefined())
+ switch (value.Type)
{
- return Undefined.Value;
+ case OriginalTypes.Undefined:
+ return Undefined.Value;
+
+ case OriginalTypes.Object:
+ if (!(value is IOriginalPrimitive))
+ {
+ return value;
+ }
+ else
+ {
+ break;
+ }
}
return value.ToObject();
}
- private static WrapperCompilationException WrapParserException(OriginalParserException originalParserException)
+ private WrapperScriptException WrapException(OriginalException originalException)
{
- string description = originalParserException.Description;
- string type = JsErrorType.Syntax;
- string documentName = originalParserException.Source;
- int lineNumber = originalParserException.LineNumber;
- int columnNumber = originalParserException.Column;
- string message = JsErrorHelpers.GenerateScriptErrorMessage(type, description, documentName, lineNumber,
- columnNumber);
-
- var wrapperCompilationException = new WrapperCompilationException(message, EngineName, EngineVersion,
- originalParserException)
+ WrapperScriptException wrapperScriptException;
+ string message = originalException.Message;
+ if (string.IsNullOrWhiteSpace(message))
{
- Description = description,
- Type = type,
- DocumentName = documentName,
- LineNumber = lineNumber,
- ColumnNumber = columnNumber
- };
-
- return wrapperCompilationException;
- }
-
- private static WrapperException WrapJavaScriptException(
- OriginalJavaScriptException originalJavaScriptException)
- {
- WrapperException wrapperException;
- string message = originalJavaScriptException.Message;
+ message = "An unknown error occurred";
+ }
string description = message;
string type = string.Empty;
- string documentName = originalJavaScriptException.Location.Source;
- int lineNumber = originalJavaScriptException.LineNumber;
- int columnNumber = originalJavaScriptException.Column + 1;
+ string documentName = string.Empty;
+ int lineNumber = 0;
+ int columnNumber = 0;
+ string callStack = string.Empty;
- OriginalValue errorValue = originalJavaScriptException.Error;
- if (errorValue.IsObject())
+ if (originalException is OriginalJavaScriptException)
{
- OriginalObjectInstance errorObject = errorValue.AsObject();
+ var originalJavaScriptException = (OriginalJavaScriptException)originalException;
+ documentName = originalJavaScriptException.Location.SourceFile;
+ OriginalErrorPosition errorPosition = originalJavaScriptException.Location.Start;
+ lineNumber = errorPosition.Line;
+ columnNumber = errorPosition.Column + 1;
- OriginalValue namePropertyValue = errorObject.Get("name");
- if (namePropertyValue.IsString())
+ ErrorLocationItem[] callStackItems = JintJsErrorHelpers.ParseErrorLocation(
+ originalJavaScriptException.JavaScriptStackTrace);
+ if (callStackItems.Length > 0)
{
- type = namePropertyValue.AsString();
+ JintJsErrorHelpers.FixErrorLocationItems(callStackItems);
+ callStack = JsErrorHelpers.StringifyErrorLocationItems(callStackItems, true);
}
- }
- if (!string.IsNullOrEmpty(type))
- {
- message = JsErrorHelpers.GenerateScriptErrorMessage(type, description, documentName, lineNumber,
- columnNumber);
+ OriginalValue errorValue = originalJavaScriptException.Error;
+ if (errorValue.IsObject())
+ {
+ OriginalObjectInstance errorObject = errorValue.AsObject();
+
+ OriginalValue namePropertyValue = errorObject.Get("name");
+ if (namePropertyValue.IsString())
+ {
+ type = namePropertyValue.AsString();
+ }
+ }
- var wrapperRuntimeException = new WrapperRuntimeException(message, EngineName, EngineVersion,
- originalJavaScriptException)
+ if (string.IsNullOrEmpty(type))
{
- Type = type,
- DocumentName = documentName,
- LineNumber = lineNumber,
- ColumnNumber = columnNumber
- };
+ type = JsErrorType.Common;
+ }
- wrapperException = wrapperRuntimeException;
+ if (type == JsErrorType.Syntax)
+ {
+ description = JintJsErrorHelpers.GetDescriptionFromSyntaxErrorMessage(message);
+ message = JsErrorHelpers.GenerateScriptErrorMessage(type, description, documentName, lineNumber,
+ columnNumber);
+ wrapperScriptException = new WrapperCompilationException(message, EngineName, EngineVersion,
+ originalJavaScriptException);
+ }
+ else
+ {
+ message = JsErrorHelpers.GenerateScriptErrorMessage(type, description, callStack);
+ wrapperScriptException = new WrapperRuntimeException(message, EngineName, EngineVersion,
+ originalJavaScriptException)
+ {
+ CallStack = callStack
+ };
+ }
}
- else
+ else if (originalException is OriginalScriptPreparationException)
{
- wrapperException = new WrapperException(message, EngineName, EngineVersion,
- originalJavaScriptException);
- }
+ ErrorLocationItem errorLocation;
+ JintJsErrorHelpers.ParseScriptPreparationErrorMessage(message, out description, out errorLocation);
- wrapperException.Description = description;
-
- return wrapperException;
- }
-
- private static WrapperRuntimeException WrapRecursionDepthOverflowException(
- OriginalRecursionDepthOverflowException originalRecursionException)
- {
- string callStack = string.Empty;
- string[] callChainItems = originalRecursionException.CallChain
- .Split(new string[] { "->" }, StringSplitOptions.None)
- ;
+ type = JsErrorType.Syntax;
+ documentName = errorLocation.DocumentName;
+ lineNumber = errorLocation.LineNumber;
+ columnNumber = errorLocation.ColumnNumber;
+ message = JsErrorHelpers.GenerateScriptErrorMessage(type, description, documentName, lineNumber,
+ columnNumber);
+ wrapperScriptException = new WrapperCompilationException(message, EngineName, EngineVersion,
+ originalException);
+ }
+ else if (originalException is OriginalMemoryLimitExceededException)
+ {
+ type = JsErrorType.Common;
+ message = JsErrorHelpers.GenerateScriptErrorMessage(type, description, string.Empty);
- if (callChainItems.Length > 0)
+ wrapperScriptException = new WrapperRuntimeException(message, EngineName, EngineVersion,
+ originalException);
+ }
+ else if (originalException is OriginalRecursionDepthOverflowException)
{
- var stringBuilderPool = StringBuilderPool.Shared;
- StringBuilder stackBuilder = stringBuilderPool.Rent();
+ var originalRecursionException = (OriginalRecursionDepthOverflowException)originalException;
+ callStack = JintJsErrorHelpers.ConvertCallChainToStack(originalRecursionException.CallChain);
+ type = JsErrorType.Range;
+ message = JsErrorHelpers.GenerateScriptErrorMessage(type, description, callStack);
- for (int chainItemIndex = callChainItems.Length - 1; chainItemIndex >= 0; chainItemIndex--)
+ wrapperScriptException = new WrapperRuntimeException(message, EngineName, EngineVersion,
+ originalRecursionException)
{
- string chainItem = callChainItems[chainItemIndex];
- if (chainItem == "anonymous function")
- {
- chainItem = "Anonymous function";
- }
-
- JsErrorHelpers.WriteErrorLocationLine(stackBuilder, chainItem, string.Empty, 0, 0);
- if (chainItemIndex > 0)
- {
- stackBuilder.AppendLine();
- }
- }
-
- callStack = stackBuilder.ToString();
- stringBuilderPool.Return(stackBuilder);
+ CallStack = callStack
+ };
}
+ else if (originalException is OriginalStatementsCountOverflowException)
+ {
+ type = JsErrorType.Range;
+ message = JsErrorHelpers.GenerateScriptErrorMessage(type, description, string.Empty);
- string description = originalRecursionException.Message;
- string type = JsErrorType.Range;
- string message = JsErrorHelpers.GenerateScriptErrorMessage(type, description, callStack);
-
- var wrapperRuntimeException = new WrapperRuntimeException(message, EngineName, EngineVersion,
- originalRecursionException)
+ wrapperScriptException = new WrapperRuntimeException(message, EngineName, EngineVersion,
+ originalException);
+ }
+ else if (originalException is OriginalExecutionCanceledException)
{
- Description = description,
- Type = type,
- CallStack = callStack
- };
+ _cancellationTokenSource.Dispose();
+ _cancellationTokenSource = new CancellationTokenSource();
- return wrapperRuntimeException;
- }
+ _cancellationConstraint.Reset(_cancellationTokenSource.Token);
- private static WrapperRuntimeException WrapStatementsCountOverflowException(
- OriginalStatementsCountOverflowException originalStatementsException)
- {
- string description = originalStatementsException.Message;
- string type = JsErrorType.Range;
- string message = JsErrorHelpers.GenerateScriptErrorMessage(type, description, string.Empty);
+ type = JsErrorType.Common;
+ message = CoreStrings.Runtime_ScriptInterrupted;
+ description = message;
- var wrapperRuntimeException = new WrapperRuntimeException(message, EngineName, EngineVersion,
- originalStatementsException)
+ wrapperScriptException = new WrapperInterruptedException(message,
+ EngineName, EngineVersion, originalException);
+ }
+ else
{
- Description = description
- };
+ type = JsErrorType.Common;
+ message = JsErrorHelpers.GenerateScriptErrorMessage(type, description, string.Empty);
+
+ wrapperScriptException = new WrapperRuntimeException(message, EngineName, EngineVersion,
+ originalException);
+ }
- return wrapperRuntimeException;
+ wrapperScriptException.Description = description;
+ wrapperScriptException.Type = type;
+ wrapperScriptException.DocumentName = documentName;
+ wrapperScriptException.LineNumber = lineNumber;
+ wrapperScriptException.ColumnNumber = columnNumber;
+
+ return wrapperScriptException;
}
private static WrapperTimeoutException WrapTimeoutException(TimeoutException originalTimeoutException)
@@ -289,27 +368,19 @@ protected override IPrecompiledScript InnerPrecompile(string code)
protected override IPrecompiledScript InnerPrecompile(string code, string documentName)
{
- OriginalProgram program;
+ OriginalParsedScript parsedScript;
string uniqueDocumentName = _documentNameManager.GetUniqueName(documentName);
- lock (_executionSynchronizer)
+ try
{
- try
- {
- var parserOptions = new OriginalParserOptions
- {
- Source = uniqueDocumentName
- };
- var parser = new OriginalParser();
- program = parser.Parse(code, parserOptions);
- }
- catch (OriginalParserException e)
- {
- throw WrapParserException(e);
- }
+ parsedScript = OriginalEngine.PrepareScript(code, uniqueDocumentName, _strictMode);
+ }
+ catch (OriginalException e)
+ {
+ throw WrapException(e);
}
- return new JintPrecompiledScript(program);
+ return new JintPrecompiledScript(parsedScript);
}
protected override object InnerEvaluate(string expression)
@@ -328,27 +399,11 @@ protected override object InnerEvaluate(string expression, string documentName)
try
{
- var parserOptions = new OriginalParserOptions
- {
- Source = uniqueDocumentName
- };
- resultValue = _jsEngine.Execute(expression, parserOptions).GetCompletionValue();
- }
- catch (OriginalParserException e)
- {
- throw WrapParserException(e);
- }
- catch (OriginalJavaScriptException e)
- {
- throw WrapJavaScriptException(e);
- }
- catch (OriginalRecursionDepthOverflowException e)
- {
- throw WrapRecursionDepthOverflowException(e);
+ resultValue = _jsEngine.Evaluate(expression, uniqueDocumentName);
}
- catch (OriginalStatementsCountOverflowException e)
+ catch (OriginalException e)
{
- throw WrapStatementsCountOverflowException(e);
+ throw WrapException(e);
}
catch (TimeoutException e)
{
@@ -386,27 +441,11 @@ protected override void InnerExecute(string code, string documentName)
{
try
{
- var parserOptions = new OriginalParserOptions
- {
- Source = uniqueDocumentName
- };
- _jsEngine.Execute(code, parserOptions);
- }
- catch (OriginalParserException e)
- {
- throw WrapParserException(e);
- }
- catch (OriginalJavaScriptException e)
- {
- throw WrapJavaScriptException(e);
- }
- catch (OriginalRecursionDepthOverflowException e)
- {
- throw WrapRecursionDepthOverflowException(e);
+ _jsEngine.Execute(code, uniqueDocumentName);
}
- catch (OriginalStatementsCountOverflowException e)
+ catch (OriginalException e)
{
- throw WrapStatementsCountOverflowException(e);
+ throw WrapException(e);
}
catch (TimeoutException e)
{
@@ -431,19 +470,11 @@ protected override void InnerExecute(IPrecompiledScript precompiledScript)
{
try
{
- _jsEngine.Execute(jintPrecompiledScript.Program);
- }
- catch (OriginalJavaScriptException e)
- {
- throw WrapJavaScriptException(e);
+ _jsEngine.Execute(jintPrecompiledScript.ParsedScript);
}
- catch (OriginalRecursionDepthOverflowException e)
+ catch (OriginalException e)
{
- throw WrapRecursionDepthOverflowException(e);
- }
- catch (OriginalStatementsCountOverflowException e)
- {
- throw WrapStatementsCountOverflowException(e);
+ throw WrapException(e);
}
catch (TimeoutException e)
{
@@ -464,51 +495,30 @@ protected override object InnerCallFunction(string functionName, params object[]
{
functionValue = _jsEngine.GetValue(functionName);
}
- catch (OriginalJavaScriptException e)
- {
- throw WrapJavaScriptException(e);
- }
-
- var callable = functionValue.TryCast();
- if (callable == null)
- {
- throw new WrapperRuntimeException(
- string.Format(CoreStrings.Runtime_FunctionNotExist, functionName));
- }
-
- int argumentCount = args.Length;
- var processedArgs = new OriginalValue[argumentCount];
-
- if (argumentCount > 0)
+ catch (OriginalException e)
{
- for (int argumentIndex = 0; argumentIndex < argumentCount; argumentIndex++)
- {
- processedArgs[argumentIndex] = MapToScriptType(args[argumentIndex]);
- }
+ throw WrapException(e);
}
OriginalValue resultValue;
try
{
- resultValue = callable.Call(functionValue, processedArgs);
- }
- catch (OriginalJavaScriptException e)
- {
- throw WrapJavaScriptException(e);
+ resultValue = _jsEngine.Invoke(functionValue, args);
}
- catch (OriginalRecursionDepthOverflowException e)
+ catch (OriginalException e)
{
- throw WrapRecursionDepthOverflowException(e);
- }
- catch (OriginalStatementsCountOverflowException e)
- {
- throw WrapStatementsCountOverflowException(e);
+ throw WrapException(e);
}
catch (TimeoutException e)
{
throw WrapTimeoutException(e);
}
+ catch (ArgumentException e) when (e.Message == "Can only invoke functions")
+ {
+ throw new WrapperRuntimeException(
+ string.Format(CoreStrings.Runtime_FunctionNotExist, functionName));
+ }
result = MapToHostType(resultValue);
}
@@ -555,9 +565,9 @@ protected override object InnerGetVariableValue(string variableName)
{
variableValue = _jsEngine.GetValue(variableName);
}
- catch (OriginalJavaScriptException e)
+ catch (OriginalException e)
{
- throw WrapJavaScriptException(e);
+ throw WrapException(e);
}
result = MapToHostType(variableValue);
@@ -583,9 +593,9 @@ protected override void InnerSetVariableValue(string variableName, object value)
{
_jsEngine.SetValue(variableName, processedValue);
}
- catch (OriginalJavaScriptException e)
+ catch (OriginalException e)
{
- throw WrapJavaScriptException(e);
+ throw WrapException(e);
}
}
}
@@ -605,9 +615,9 @@ protected override void InnerEmbedHostObject(string itemName, object value)
{
_jsEngine.SetValue(itemName, processedValue);
}
- catch (OriginalJavaScriptException e)
+ catch (OriginalException e)
{
- throw WrapJavaScriptException(e);
+ throw WrapException(e);
}
}
}
@@ -622,16 +632,16 @@ protected override void InnerEmbedHostType(string itemName, Type type)
{
_jsEngine.SetValue(itemName, typeReference);
}
- catch (OriginalJavaScriptException e)
+ catch (OriginalException e)
{
- throw WrapJavaScriptException(e);
+ throw WrapException(e);
}
}
}
protected override void InnerInterrupt()
{
- throw new NotSupportedException();
+ _cancellationTokenSource.Cancel();
}
protected override void InnerCollectGarbage()
@@ -641,41 +651,26 @@ protected override void InnerCollectGarbage()
#region IJsEngine implementation
- ///
- /// Gets a name of JS engine
- ///
public override string Name
{
get { return EngineName; }
}
- ///
- /// Gets a version of original JS engine
- ///
public override string Version
{
get { return EngineVersion; }
}
- ///
- /// Gets a value that indicates if the JS engine supports script pre-compilation
- ///
public override bool SupportsScriptPrecompilation
{
get { return true; }
}
- ///
- /// Gets a value that indicates if the JS engine supports script interruption
- ///
public override bool SupportsScriptInterruption
{
- get { return false; }
+ get { return true; }
}
- ///
- /// Gets a value that indicates if the JS engine supports garbage collection
- ///
public override bool SupportsGarbageCollection
{
get { return false; }
@@ -691,7 +686,31 @@ public override void Dispose()
{
lock (_executionSynchronizer)
{
- _jsEngine = null;
+ if (_jsEngine != null)
+ {
+ if (_debuggerStepCallback != null)
+ {
+ _jsEngine.Debugger.Step -= _debuggerStepCallback;
+ }
+
+ if (_debuggerBreakCallback != null)
+ {
+ _jsEngine.Debugger.Break -= _debuggerBreakCallback;
+ }
+
+ _jsEngine.Dispose();
+ _jsEngine = null;
+ }
+
+ _debuggerStepCallback = null;
+ _debuggerBreakCallback = null;
+ _cancellationConstraint = null;
+
+ if (_cancellationTokenSource != null)
+ {
+ _cancellationTokenSource.Dispose();
+ _cancellationTokenSource = null;
+ }
}
}
}
diff --git a/src/JavaScriptEngineSwitcher.Jint/JintJsEngineFactory.cs b/src/JavaScriptEngineSwitcher.Jint/JintJsEngineFactory.cs
index 6633ee8b..5d272d8e 100644
--- a/src/JavaScriptEngineSwitcher.Jint/JintJsEngineFactory.cs
+++ b/src/JavaScriptEngineSwitcher.Jint/JintJsEngineFactory.cs
@@ -32,9 +32,7 @@ public JintJsEngineFactory(JintSettings settings)
#region IJsEngineFactory implementation
- ///
- /// Gets a name of JS engine
- ///
+ ///
public string EngineName
{
get { return JintJsEngine.EngineName; }
diff --git a/src/JavaScriptEngineSwitcher.Jint/JintPrecompiledScript.cs b/src/JavaScriptEngineSwitcher.Jint/JintPrecompiledScript.cs
index 4470d759..0d36e5b9 100644
--- a/src/JavaScriptEngineSwitcher.Jint/JintPrecompiledScript.cs
+++ b/src/JavaScriptEngineSwitcher.Jint/JintPrecompiledScript.cs
@@ -1,4 +1,4 @@
-using OriginalProgram = Jint.Parser.Ast.Program;
+using OriginalParsedScript = Jint.Prepared;
using JavaScriptEngineSwitcher.Core;
@@ -10,9 +10,9 @@ namespace JavaScriptEngineSwitcher.Jint
internal sealed class JintPrecompiledScript : IPrecompiledScript
{
///
- /// Gets a program
+ /// Gets a parsed script
///
- public OriginalProgram Program
+ public OriginalParsedScript ParsedScript
{
get;
private set;
@@ -22,18 +22,16 @@ public OriginalProgram Program
///
/// Constructs an instance of pre-compiled script
///
- /// The program
- public JintPrecompiledScript(OriginalProgram program)
+ /// The parsed script
+ public JintPrecompiledScript(OriginalParsedScript parsedScript)
{
- Program = program;
+ ParsedScript = parsedScript;
}
#region IPrecompiledScript implementation
- ///
- /// Gets a name of JS engine for which the pre-compiled script was created
- ///
+ ///
public string EngineName
{
get { return JintJsEngine.EngineName; }
diff --git a/src/JavaScriptEngineSwitcher.Jint/JintSettings.cs b/src/JavaScriptEngineSwitcher.Jint/JintSettings.cs
index 109c3ff8..966360a1 100644
--- a/src/JavaScriptEngineSwitcher.Jint/JintSettings.cs
+++ b/src/JavaScriptEngineSwitcher.Jint/JintSettings.cs
@@ -1,5 +1,7 @@
using System;
+using OriginalDebuggerEventHandler = Jint.Runtime.Debugger.DebugHandler.DebugEventHandler;
+
namespace JavaScriptEngineSwitcher.Jint
{
///
@@ -8,10 +10,61 @@ namespace JavaScriptEngineSwitcher.Jint
public sealed class JintSettings
{
///
- /// Gets or sets a flag for whether to allow the debugger statement
+ /// Gets or sets a flag for whether to allow the usage of reflection API in the script code
+ ///
+ ///
+ /// This affects , Exception.GetType ,
+ /// Exception.TargetSite and Delegate.Method .
+ ///
+ public bool AllowReflection
+ {
+ get;
+ set;
+ }
+
+ ///
+ /// Gets or sets a flag for whether to allow the debugger statement
/// to be called in a script
///
+ [Obsolete("Use a `DebuggerStatementHandlingMode` property")]
public bool AllowDebuggerStatement
+ {
+ get { return DebuggerStatementHandlingMode == JsDebuggerStatementHandlingMode.Clr; }
+ set { DebuggerStatementHandlingMode = value ? JsDebuggerStatementHandlingMode.Clr : JsDebuggerStatementHandlingMode.Ignore; }
+ }
+
+ ///
+ /// Gets or sets a debugger break callback
+ ///
+ public OriginalDebuggerEventHandler DebuggerBreakCallback
+ {
+ get;
+ set;
+ }
+
+ ///
+ /// Gets or sets a handling mode for script debugger statements
+ ///
+ public JsDebuggerStatementHandlingMode DebuggerStatementHandlingMode
+ {
+ get;
+ set;
+ }
+
+ ///
+ /// Gets or sets a debugger step callback
+ ///
+ public OriginalDebuggerEventHandler DebuggerStepCallback
+ {
+ get;
+ set;
+ }
+
+ ///
+ /// Gets or sets a flag for whether to disable calls of eval function with custom code
+ /// and Function constructors taking function code as string
+ ///
+ public bool DisableEval
{
get;
set;
@@ -27,7 +80,7 @@ public bool EnableDebugging
}
///
- /// Gets or sets a local time zone for the Date objects in the script
+ /// Gets or sets a local time zone for the Date objects in the script
///
public TimeZoneInfo LocalTimeZone
{
@@ -35,10 +88,28 @@ public TimeZoneInfo LocalTimeZone
set;
}
+ ///
+ /// Gets or sets a maximum size for JavaScript array
+ ///
+ public uint MaxArraySize
+ {
+ get;
+ set;
+ }
+
+ ///
+ /// Gets or sets a maximum depth allowed when parsing JSON data using the JSON.parse static method
+ ///
+ public int MaxJsonParseDepth
+ {
+ get;
+ set;
+ }
+
///
/// Gets or sets a maximum allowed depth of recursion:
- /// -1 - recursion without limits;
- /// N - one scope function can be called no more than N times.
+ /// -1 - recursion without limits;
+ /// N - one scope function can be called no more than N times.
///
public int MaxRecursionDepth
{
@@ -55,6 +126,28 @@ public int MaxStatements
set;
}
+ ///
+ /// Gets or sets a current memory limit for a engine in bytes
+ ///
+ public long MemoryLimit
+ {
+ get;
+ set;
+ }
+
+ ///
+ /// Gets or sets a timeout interval for regular expressions
+ ///
+ ///
+ /// If the value of this property is null , then the value of regular expression
+ /// timeout interval are taken from the property.
+ ///
+ public TimeSpan? RegexTimeoutInterval
+ {
+ get;
+ set;
+ }
+
///
/// Gets or sets a flag for whether to allow run the script in strict mode
///
@@ -89,11 +182,19 @@ public TimeSpan TimeoutInterval
///
public JintSettings()
{
- AllowDebuggerStatement = false;
+ AllowReflection = false;
+ DebuggerBreakCallback = null;
+ DebuggerStatementHandlingMode = JsDebuggerStatementHandlingMode.Ignore;
+ DebuggerStepCallback = null;
+ DisableEval = false;
EnableDebugging = false;
LocalTimeZone = TimeZoneInfo.Local;
+ MaxArraySize = uint.MaxValue;
+ MaxJsonParseDepth = 64;
MaxRecursionDepth = -1;
MaxStatements = 0;
+ MemoryLimit = 0;
+ RegexTimeoutInterval = null;
StrictMode = false;
TimeoutInterval = TimeSpan.Zero;
}
diff --git a/src/JavaScriptEngineSwitcher.Jint/JsDebuggerStatementHandlingMode.cs b/src/JavaScriptEngineSwitcher.Jint/JsDebuggerStatementHandlingMode.cs
new file mode 100644
index 00000000..463b6fc2
--- /dev/null
+++ b/src/JavaScriptEngineSwitcher.Jint/JsDebuggerStatementHandlingMode.cs
@@ -0,0 +1,26 @@
+namespace JavaScriptEngineSwitcher.Jint
+{
+ ///
+ /// Handling mode for script debugger statements
+ ///
+ public enum JsDebuggerStatementHandlingMode
+ {
+ ///
+ /// No action will be taken when encountering a debugger statement
+ ///
+ Ignore,
+
+ ///
+ /// debugger statements will trigger debugging through
+ ///
+ Clr,
+
+ ///
+ /// debugger statements will trigger a break in Jint's DebugHandler
+ ///
+ ///
+ /// See the configuration property.
+ ///
+ Script
+ }
+}
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.Jint/JsEngineFactoryCollectionExtensions.cs b/src/JavaScriptEngineSwitcher.Jint/JsEngineFactoryCollectionExtensions.cs
index f81fe12f..fd0f6e6a 100644
--- a/src/JavaScriptEngineSwitcher.Jint/JsEngineFactoryCollectionExtensions.cs
+++ b/src/JavaScriptEngineSwitcher.Jint/JsEngineFactoryCollectionExtensions.cs
@@ -11,10 +11,10 @@ public static class JsEngineFactoryCollectionExtensions
{
///
/// Adds a instance of to
- /// the specified
+ /// the specified
///
- /// Instance of
- /// Instance of
+ /// Instance of
+ /// Instance of
public static JsEngineFactoryCollection AddJint(this JsEngineFactoryCollection source)
{
if (source == null)
@@ -27,11 +27,11 @@ public static JsEngineFactoryCollection AddJint(this JsEngineFactoryCollection s
///
/// Adds a instance of to
- /// the specified
+ /// the specified
///
- /// Instance of
+ /// Instance of
/// The delegate to configure the provided
- /// Instance of
+ /// Instance of
public static JsEngineFactoryCollection AddJint(this JsEngineFactoryCollection source,
Action configure)
{
@@ -53,11 +53,11 @@ public static JsEngineFactoryCollection AddJint(this JsEngineFactoryCollection s
///
/// Adds a instance of to
- /// the specified
+ /// the specified
///
- /// Instance of
+ /// Instance of
/// Settings of the Jint JS engine
- /// Instance of
+ /// Instance of
public static JsEngineFactoryCollection AddJint(this JsEngineFactoryCollection source, JintSettings settings)
{
if (source == null)
diff --git a/src/JavaScriptEngineSwitcher.Jint/PACKAGE-DESCRIPTION.md b/src/JavaScriptEngineSwitcher.Jint/PACKAGE-DESCRIPTION.md
new file mode 100644
index 00000000..7abcd85d
--- /dev/null
+++ b/src/JavaScriptEngineSwitcher.Jint/PACKAGE-DESCRIPTION.md
@@ -0,0 +1 @@
+JavaScriptEngineSwitcher.Jint contains a `JintJsEngine` adapter (wrapper for the [Jint](http://github.com/sebastienros/jint) version 4.5.0).
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.Jint/UndefinedConverter.cs b/src/JavaScriptEngineSwitcher.Jint/UndefinedConverter.cs
new file mode 100644
index 00000000..4ee5f399
--- /dev/null
+++ b/src/JavaScriptEngineSwitcher.Jint/UndefinedConverter.cs
@@ -0,0 +1,26 @@
+using IOriginalObjectConverter = Jint.Runtime.Interop.IObjectConverter;
+using OriginalEngine = Jint.Engine;
+using OriginalValue = Jint.Native.JsValue;
+
+using JavaScriptEngineSwitcher.Core;
+
+namespace JavaScriptEngineSwitcher.Jint
+{
+ ///
+ /// Converts a instance to a instance
+ ///
+ internal sealed class UndefinedConverter : IOriginalObjectConverter
+ {
+ public bool TryConvert(OriginalEngine engine, object value, out OriginalValue result)
+ {
+ if (value is Undefined)
+ {
+ result = OriginalValue.Undefined;
+ return true;
+ }
+
+ result = OriginalValue.Null;
+ return false;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.Jint/readme.txt b/src/JavaScriptEngineSwitcher.Jint/readme.txt
index 4ebfd449..74abed43 100644
--- a/src/JavaScriptEngineSwitcher.Jint/readme.txt
+++ b/src/JavaScriptEngineSwitcher.Jint/readme.txt
@@ -1,28 +1,23 @@
--------------------------------------------------------------------------------
- README file for JS Engine Switcher: Jint v3.0.0
+ README file for JS Engine Switcher: Jint v3.30.4
--------------------------------------------------------------------------------
- Copyright (c) 2013-2018 Andrey Taritsyn - http://www.taritsyn.ru
+ Copyright (c) 2013-2026 Andrey Taritsyn - http://www.taritsyn.ru
===========
DESCRIPTION
===========
- JavaScriptEngineSwitcher.Jint contains adapter `JintJsEngine` (wrapper for the
- Jint JavaScript Engine (http://github.com/sebastienros/jint) version 2.11.58).
+ JavaScriptEngineSwitcher.Jint contains a `JintJsEngine` adapter (wrapper for the
+ Jint (http://github.com/sebastienros/jint) version 4.5.0).
=============
RELEASE NOTES
=============
- 1. Jint was updated to version 2.11.58;
- 2. Added a ability to pre-compile scripts;
- 3. In configuration settings of the Jint JS engine a `Timeout` property has been
- replaced by the `TimeoutInterval` property (default `TimeSpan.Zero`) and was
- added one new property - `LocalTimeZone` (default `TimeZoneInfo.Local`);
- 4. Added support of .NET Standard 2.0.
+ Jint was updated to version 4.5.0.
=============
DOCUMENTATION
diff --git a/src/JavaScriptEngineSwitcher.Jurassic/JavaScriptEngineSwitcher.Jurassic.csproj b/src/JavaScriptEngineSwitcher.Jurassic/JavaScriptEngineSwitcher.Jurassic.csproj
index 0653be07..d2bf3a2b 100644
--- a/src/JavaScriptEngineSwitcher.Jurassic/JavaScriptEngineSwitcher.Jurassic.csproj
+++ b/src/JavaScriptEngineSwitcher.Jurassic/JavaScriptEngineSwitcher.Jurassic.csproj
@@ -1,42 +1,37 @@
-
- JS Engine Switcher: Jurassic
- 3.0.0
- net40-client;net45;netstandard2.0
- Library
- true
- $(NoWarn);CS1591;NU5125
- true
- JavaScriptEngineSwitcher.Jurassic contains adapter `JurassicJsEngine` (wrapper for the Jurassic JavaScript Engine (http://github.com/paulbartrum/jurassic) version of February 24, 2018).
- https://raw.githubusercontent.com/Taritsyn/JavaScriptEngineSwitcher/master/Icons/JavaScriptEngineSwitcher_Jurassic_Logo128x128.png
- JavaScriptEngineSwitcher;JavaScript;ECMAScript;Jurassic
- 1. Jurassic was updated to version of February 24, 2018;
-2. Added a ability to pre-compile scripts;
-3. Added support of .NET Standard 2.0.
-
+
+ JS Engine Switcher: Jurassic
+ 3.29.0
+ net40-client;net45;netstandard2.0
+ Library
+ true
+ $(NoWarn);CS1591
+ false
+ true
+
-
-
-
-
+
+
+
+
-
-
+
+ https://raw.githubusercontent.com/Taritsyn/JavaScriptEngineSwitcher/master/Icons/JavaScriptEngineSwitcher_Jurassic_Logo128x128.png
+ ../../Icons/JavaScriptEngineSwitcher_Jurassic_Logo128x128.png
+ JavaScriptEngineSwitcher.Jurassic contains a `JurassicJsEngine` adapter (wrapper for the Jurassic).
+ $(PackageCommonTags);Jurassic
+ Jurassic was updated to version of February 4, 2025.
+
-
-
+
+
-
-
- readme.txt
- true
-
-
- jurassic-license.txt
- true
- false
-
-
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.Jurassic/JsEngineFactoryCollectionExtensions.cs b/src/JavaScriptEngineSwitcher.Jurassic/JsEngineFactoryCollectionExtensions.cs
index 800a0c92..265afab0 100644
--- a/src/JavaScriptEngineSwitcher.Jurassic/JsEngineFactoryCollectionExtensions.cs
+++ b/src/JavaScriptEngineSwitcher.Jurassic/JsEngineFactoryCollectionExtensions.cs
@@ -11,10 +11,10 @@ public static class JsEngineFactoryCollectionExtensions
{
///
/// Adds a instance of to
- /// the specified
+ /// the specified
///
- /// Instance of
- /// Instance of
+ /// Instance of
+ /// Instance of
public static JsEngineFactoryCollection AddJurassic(this JsEngineFactoryCollection source)
{
if (source == null)
@@ -27,11 +27,11 @@ public static JsEngineFactoryCollection AddJurassic(this JsEngineFactoryCollecti
///
/// Adds a instance of to
- /// the specified
+ /// the specified
///
- /// Instance of
+ /// Instance of
/// The delegate to configure the provided
- /// Instance of
+ /// Instance of
public static JsEngineFactoryCollection AddJurassic(this JsEngineFactoryCollection source,
Action configure)
{
@@ -53,11 +53,11 @@ public static JsEngineFactoryCollection AddJurassic(this JsEngineFactoryCollecti
///
/// Adds a instance of to
- /// the specified
+ /// the specified
///
- /// Instance of
+ /// Instance of
/// Settings of the Jurassic JS engine
- /// Instance of
+ /// Instance of
public static JsEngineFactoryCollection AddJurassic(this JsEngineFactoryCollection source,
JurassicSettings settings)
{
diff --git a/src/JavaScriptEngineSwitcher.Jurassic/JurassicJsEngine.cs b/src/JavaScriptEngineSwitcher.Jurassic/JurassicJsEngine.cs
index 7d04897d..57d9976b 100644
--- a/src/JavaScriptEngineSwitcher.Jurassic/JurassicJsEngine.cs
+++ b/src/JavaScriptEngineSwitcher.Jurassic/JurassicJsEngine.cs
@@ -1,6 +1,8 @@
using System;
using System.IO;
+using System.Linq;
using System.Reflection;
+using System.Runtime.CompilerServices;
using System.Text;
using OriginalCompatibilityMode = Jurassic.CompatibilityMode;
@@ -43,7 +45,7 @@ public sealed class JurassicJsEngine : JsEngineBase
///
/// Version of original JS engine
///
- private const string EngineVersion = "Feb 24, 2018";
+ private const string EngineVersion = "Feb 4, 2025";
///
/// Jurassic JS engine
@@ -81,10 +83,8 @@ public JurassicJsEngine(JurassicSettings settings)
{
_jsEngine = new OriginalEngine
{
-#if !NETSTANDARD2_0
- EnableDebugging = jurassicSettings.EnableDebugging,
-#endif
CompatibilityMode = OriginalCompatibilityMode.Latest,
+ DisableClrCollectionsExposingByValue = !jurassicSettings.EnableHostCollectionsEmbeddingByValue,
EnableExposedClrTypes = true,
EnableILAnalysis = jurassicSettings.EnableIlAnalysis,
ForceStrictMode = jurassicSettings.StrictMode
@@ -97,26 +97,6 @@ public JurassicJsEngine(JurassicSettings settings)
}
- private string GetUniqueDocumentName(string documentName, bool isFile)
- {
- string uniqueDocumentName;
-
-#if !NETSTANDARD2_0
- if (_jsEngine.EnableDebugging)
- {
- uniqueDocumentName = isFile ? documentName : null;
- }
- else
- {
-#endif
- uniqueDocumentName = _documentNameManager.GetUniqueName(documentName);
-#if !NETSTANDARD2_0
- }
-#endif
-
- return uniqueDocumentName;
- }
-
#region Mapping
///
@@ -139,6 +119,16 @@ private static object MapToScriptType(object value)
return value;
}
+ ///
+ /// Makes a mapping of array items from the host type to a script type
+ ///
+ /// The source array
+ /// The mapped array
+ private static object[] MapToScriptType(object[] args)
+ {
+ return args.Select(MapToScriptType).ToArray();
+ }
+
///
/// Makes a mapping of value from the script type to a host type
///
@@ -146,22 +136,75 @@ private static object MapToScriptType(object value)
/// The mapped value
private static object MapToHostType(object value)
{
+ if (value is OriginalNull)
+ {
+ return null;
+ }
+
+ if (value is OriginalUndefined)
+ {
+ return Undefined.Value;
+ }
+
if (value is OriginalConcatenatedString)
{
return value.ToString();
}
+ return value;
+ }
+
+ ///
+ /// Makes a mapping of value from the script type to a host type
+ ///
+ /// The type to convert the value to
+ /// Original JS engine
+ /// The source value
+ /// The mapped value
+ private static T MapToHostType(OriginalEngine engine, object value)
+ {
if (value is OriginalNull)
{
- return null;
+ return TypeConverter.ConvertToType(null);
}
- if (value is OriginalUndefined)
+ Type targetType = typeof(T);
+
+ if (targetType == typeof(Undefined))
{
- return Undefined.Value;
+ if (value is OriginalUndefined)
+ {
+ return (T)(object)Undefined.Value;
+ }
+ else
+ {
+ throw new InvalidOperationException(
+ string.Format(CoreStrings.Common_CannotConvertObjectToType, value.GetType(), targetType)
+ );
+ }
}
- return value;
+ T result;
+
+ try
+ {
+ result = OriginalTypeConverter.ConvertTo(engine, value);
+ }
+ catch (OriginalJavaScriptException e)
+ {
+ throw new InvalidOperationException(e.ErrorMessage, e);
+ }
+ catch (ArgumentException e)
+ {
+ if (targetType == typeof(string) && value != null)
+ {
+ return (T)(object)value.ToString();
+ }
+
+ throw new InvalidOperationException(e.Message, e);
+ }
+
+ return result;
}
private static WrapperCompilationException WrapSyntaxException(
@@ -186,24 +229,23 @@ private static WrapperCompilationException WrapSyntaxException(
return wrapperCompilationException;
}
- private static WrapperException WrapJavaScriptException(
+ private static WrapperException WrapJavaScriptException(OriginalEngine engine,
OriginalJavaScriptException originalJavaScriptException)
{
WrapperException wrapperException;
string message = originalJavaScriptException.Message;
string messageWithCallStack = string.Empty;
- string description = message;
- string type = originalJavaScriptException.Name;
- string documentName = originalJavaScriptException.SourcePath;
+ string description = originalJavaScriptException.ErrorMessage;
+ string type = originalJavaScriptException.ErrorType.ToString();
+ string documentName = originalJavaScriptException.SourcePath ?? string.Empty;
int lineNumber = originalJavaScriptException.LineNumber;
string callStack = string.Empty;
- var errorValue = originalJavaScriptException.ErrorObject as OriginalErrorInstance;
+ object errorObject = originalJavaScriptException.GetErrorObject(engine);
+ var errorValue = errorObject as OriginalErrorInstance;
if (errorValue != null)
{
messageWithCallStack = errorValue.Stack;
- description = !string.IsNullOrEmpty(errorValue.Message) ?
- errorValue.Message : description;
}
if (!string.IsNullOrEmpty(type))
@@ -231,6 +273,11 @@ private static WrapperException WrapJavaScriptException(
{
FixCallStackItems(callStackItems);
callStack = JsErrorHelpers.StringifyErrorLocationItems(callStackItems);
+
+ if (string.IsNullOrWhiteSpace(documentName))
+ {
+ documentName = callStackItems[0].DocumentName;
+ }
}
}
@@ -284,6 +331,80 @@ private static void FixCallStackItems(ErrorLocationItem[] callStackItems)
#endregion
+ ///
+ /// Evaluates an expression without converting its result to a host type
+ ///
+ /// Original JS engine
+ /// JS expression
+ /// Unique document name
+ /// Result of the expression not converted to a host type
+ [MethodImpl((MethodImplOptions)256 /* AggressiveInlining */)]
+ private static object InnerEvaluateWithoutResultConversion(OriginalEngine engine, string expression,
+ string uniqueDocumentName)
+ {
+ object result;
+
+ try
+ {
+ var source = new OriginalStringScriptSource(expression, uniqueDocumentName);
+ result = engine.Evaluate(source);
+ }
+ catch (OriginalJavaScriptException e)
+ {
+ throw WrapJavaScriptException(engine, e);
+ }
+
+ return result;
+ }
+
+ ///
+ /// Calls a function without converting its result to a host type
+ ///
+ /// Original JS engine
+ /// Function name
+ /// Function arguments converted to a script type
+ /// Result of the function execution not converted to a host type
+ [MethodImpl((MethodImplOptions)256 /* AggressiveInlining */)]
+ private static object InnerCallFunctionWithoutResultConversion(OriginalEngine engine, string functionName,
+ params object[] args)
+ {
+ object result;
+
+ try
+ {
+ result = engine.CallGlobalFunction(functionName, args);
+ }
+ catch (OriginalJavaScriptException e)
+ {
+ throw WrapJavaScriptException(engine, e);
+ }
+
+ return result;
+ }
+
+ ///
+ /// Gets a value of variable without converting it to a host type
+ ///
+ /// Original JS engine
+ /// Variable name
+ /// Value of variable not converted to a host type
+ [MethodImpl((MethodImplOptions)256 /* AggressiveInlining */)]
+ private static object InnerGetVariableValueWithoutResultConversion(OriginalEngine engine, string variableName)
+ {
+ object result;
+
+ try
+ {
+ result = engine.GetGlobalValue(variableName);
+ }
+ catch (OriginalJavaScriptException e)
+ {
+ throw WrapJavaScriptException(engine, e);
+ }
+
+ return result;
+ }
+
#region JsEngineBase overrides
protected override IPrecompiledScript InnerPrecompile(string code)
@@ -294,14 +415,14 @@ protected override IPrecompiledScript InnerPrecompile(string code)
protected override IPrecompiledScript InnerPrecompile(string code, string documentName)
{
OriginalCompiledScript compiledScript;
- string uniqueDocumentName = GetUniqueDocumentName(documentName, false);
+ string uniqueDocumentName = _documentNameManager.GetUniqueName(documentName);
lock (_executionSynchronizer)
{
try
{
var source = new OriginalStringScriptSource(code, uniqueDocumentName);
- compiledScript = _jsEngine.Compile(source);
+ compiledScript = OriginalCompiledScript.Compile(source);
}
catch (OriginalSyntaxException e)
{
@@ -319,23 +440,15 @@ protected override object InnerEvaluate(string expression)
protected override object InnerEvaluate(string expression, string documentName)
{
- object result;
- string uniqueDocumentName = GetUniqueDocumentName(documentName, false);
+ object resultValue;
+ string uniqueDocumentName = _documentNameManager.GetUniqueName(documentName);
lock (_executionSynchronizer)
{
- try
- {
- var source = new OriginalStringScriptSource(expression, uniqueDocumentName);
- result = _jsEngine.Evaluate(source);
- }
- catch (OriginalJavaScriptException e)
- {
- throw WrapJavaScriptException(e);
- }
+ resultValue = InnerEvaluateWithoutResultConversion(_jsEngine, expression, uniqueDocumentName);
}
- result = MapToHostType(result);
+ object result = MapToHostType(resultValue);
return result;
}
@@ -347,9 +460,16 @@ protected override T InnerEvaluate(string expression)
protected override T InnerEvaluate(string expression, string documentName)
{
- object result = InnerEvaluate(expression, documentName);
+ T result;
+ string uniqueDocumentName = _documentNameManager.GetUniqueName(documentName);
- return OriginalTypeConverter.ConvertTo(_jsEngine, result);
+ lock (_executionSynchronizer)
+ {
+ object resultValue = InnerEvaluateWithoutResultConversion(_jsEngine, expression, uniqueDocumentName);
+ result = MapToHostType(_jsEngine, resultValue);
+ }
+
+ return result;
}
protected override void InnerExecute(string code)
@@ -359,7 +479,7 @@ protected override void InnerExecute(string code)
protected override void InnerExecute(string code, string documentName)
{
- string uniqueDocumentName = GetUniqueDocumentName(documentName, false);
+ string uniqueDocumentName = _documentNameManager.GetUniqueName(documentName);
lock (_executionSynchronizer)
{
@@ -370,7 +490,7 @@ protected override void InnerExecute(string code, string documentName)
}
catch (OriginalJavaScriptException e)
{
- throw WrapJavaScriptException(e);
+ throw WrapJavaScriptException(_jsEngine, e);
}
}
}
@@ -395,48 +515,38 @@ protected override void InnerExecute(IPrecompiledScript precompiledScript)
}
catch (OriginalJavaScriptException e)
{
- throw WrapJavaScriptException(e);
+ throw WrapJavaScriptException(_jsEngine, e);
}
}
}
protected override object InnerCallFunction(string functionName, params object[] args)
{
- int argumentCount = args.Length;
- var processedArgs = new object[argumentCount];
-
- if (argumentCount > 0)
- {
- for (int argumentIndex = 0; argumentIndex < argumentCount; argumentIndex++)
- {
- processedArgs[argumentIndex] = MapToScriptType(args[argumentIndex]);
- }
- }
-
- object result;
+ object resultValue;
+ object[] processedArgs = MapToScriptType(args);
lock (_executionSynchronizer)
{
- try
- {
- result = _jsEngine.CallGlobalFunction(functionName, processedArgs);
- }
- catch (OriginalJavaScriptException e)
- {
- throw WrapJavaScriptException(e);
- }
+ resultValue = InnerCallFunctionWithoutResultConversion(_jsEngine, functionName, processedArgs);
}
- result = MapToHostType(result);
+ object result = MapToHostType(resultValue);
return result;
}
protected override T InnerCallFunction(string functionName, params object[] args)
{
- object result = InnerCallFunction(functionName, args);
+ T result;
+ object[] processedArgs = MapToScriptType(args);
+
+ lock (_executionSynchronizer)
+ {
+ object resultValue = InnerCallFunctionWithoutResultConversion(_jsEngine, functionName, processedArgs);
+ result = MapToHostType(_jsEngine, resultValue);
+ }
- return OriginalTypeConverter.ConvertTo(_jsEngine, result);
+ return result;
}
protected override bool InnerHasVariable(string variableName)
@@ -458,30 +568,29 @@ protected override bool InnerHasVariable(string variableName)
protected override object InnerGetVariableValue(string variableName)
{
- object result;
+ object resultValue;
lock (_executionSynchronizer)
{
- try
- {
- result = _jsEngine.GetGlobalValue(variableName);
- }
- catch (OriginalJavaScriptException e)
- {
- throw WrapJavaScriptException(e);
- }
+ resultValue = InnerGetVariableValueWithoutResultConversion(_jsEngine, variableName);
}
- result = MapToHostType(result);
+ object result = MapToHostType(resultValue);
return result;
}
protected override T InnerGetVariableValue(string variableName)
{
- object result = InnerGetVariableValue(variableName);
+ T result;
+
+ lock (_executionSynchronizer)
+ {
+ object resultValue = InnerGetVariableValueWithoutResultConversion(_jsEngine, variableName);
+ result = MapToHostType(_jsEngine, resultValue);
+ }
- return OriginalTypeConverter.ConvertTo(_jsEngine, result);
+ return result;
}
protected override void InnerSetVariableValue(string variableName, object value)
@@ -496,7 +605,7 @@ protected override void InnerSetVariableValue(string variableName, object value)
}
catch (OriginalJavaScriptException e)
{
- throw WrapJavaScriptException(e);
+ throw WrapJavaScriptException(_jsEngine, e);
}
}
}
@@ -526,7 +635,7 @@ protected override void InnerEmbedHostObject(string itemName, object value)
}
catch (OriginalJavaScriptException e)
{
- throw WrapJavaScriptException(e);
+ throw WrapJavaScriptException(_jsEngine, e);
}
}
}
@@ -541,7 +650,7 @@ protected override void InnerEmbedHostType(string itemName, Type type)
}
catch (OriginalJavaScriptException e)
{
- throw WrapJavaScriptException(e);
+ throw WrapJavaScriptException(_jsEngine, e);
}
}
}
@@ -558,41 +667,26 @@ protected override void InnerCollectGarbage()
#region IJsEngine implementation
- ///
- /// Gets a name of JS engine
- ///
public override string Name
{
get { return EngineName; }
}
- ///
- /// Gets a version of original JS engine
- ///
public override string Version
{
get { return EngineVersion; }
}
- ///
- /// Gets a value that indicates if the JS engine supports script pre-compilation
- ///
public override bool SupportsScriptPrecompilation
{
get { return true; }
}
- ///
- /// Gets a value that indicates if the JS engine supports script interruption
- ///
public override bool SupportsScriptInterruption
{
get { return false; }
}
- ///
- /// Gets a value that indicates if the JS engine supports garbage collection
- ///
public override bool SupportsGarbageCollection
{
get { return false; }
@@ -628,14 +722,14 @@ public override IPrecompiledScript PrecompileFile(string path, Encoding encoding
}
OriginalCompiledScript compiledScript;
- string uniqueDocumentName = GetUniqueDocumentName(path, true);
+ string uniqueDocumentName = _documentNameManager.GetUniqueName(path);
lock (_executionSynchronizer)
{
try
{
var source = new FileScriptSource(uniqueDocumentName, path, encoding);
- compiledScript = _jsEngine.Compile(source);
+ compiledScript = OriginalCompiledScript.Compile(source);
}
catch (OriginalSyntaxException e)
{
@@ -695,14 +789,14 @@ public override IPrecompiledScript PrecompileResource(string resourceName, Type
string resourceFullName = nameSpace != null ? nameSpace + "." + resourceName : resourceName;
OriginalCompiledScript compiledScript;
- string uniqueDocumentName = GetUniqueDocumentName(resourceFullName, false);
+ string uniqueDocumentName = _documentNameManager.GetUniqueName(resourceFullName);
lock (_executionSynchronizer)
{
try
{
var source = new ResourceScriptSource(uniqueDocumentName, resourceFullName, assembly);
- compiledScript = _jsEngine.Compile(source);
+ compiledScript = OriginalCompiledScript.Compile(source);
}
catch (OriginalSyntaxException e)
{
@@ -754,14 +848,14 @@ public override IPrecompiledScript PrecompileResource(string resourceName, Assem
}
OriginalCompiledScript compiledScript;
- string uniqueDocumentName = GetUniqueDocumentName(resourceName, false);
+ string uniqueDocumentName = _documentNameManager.GetUniqueName(resourceName);
lock (_executionSynchronizer)
{
try
{
var source = new ResourceScriptSource(uniqueDocumentName, resourceName, assembly);
- compiledScript = _jsEngine.Compile(source);
+ compiledScript = OriginalCompiledScript.Compile(source);
}
catch (OriginalSyntaxException e)
{
@@ -804,7 +898,7 @@ public override void ExecuteFile(string path, Encoding encoding = null)
);
}
- string uniqueDocumentName = GetUniqueDocumentName(path, true);
+ string uniqueDocumentName = _documentNameManager.GetUniqueName(path);
lock (_executionSynchronizer)
{
@@ -815,7 +909,7 @@ public override void ExecuteFile(string path, Encoding encoding = null)
}
catch (OriginalJavaScriptException e)
{
- throw WrapJavaScriptException(e);
+ throw WrapJavaScriptException(_jsEngine, e);
}
catch (FileNotFoundException)
{
@@ -867,7 +961,7 @@ public override void ExecuteResource(string resourceName, Type type)
#endif
string nameSpace = type.Namespace;
string resourceFullName = nameSpace != null ? nameSpace + "." + resourceName : resourceName;
- string uniqueDocumentName = GetUniqueDocumentName(resourceFullName, false);
+ string uniqueDocumentName = _documentNameManager.GetUniqueName(resourceFullName);
lock (_executionSynchronizer)
{
@@ -878,7 +972,7 @@ public override void ExecuteResource(string resourceName, Type type)
}
catch (OriginalJavaScriptException e)
{
- throw WrapJavaScriptException(e);
+ throw WrapJavaScriptException(_jsEngine, e);
}
catch (NullReferenceException)
{
@@ -923,7 +1017,7 @@ public override void ExecuteResource(string resourceName, Assembly assembly)
);
}
- string uniqueDocumentName = GetUniqueDocumentName(resourceName, false);
+ string uniqueDocumentName = _documentNameManager.GetUniqueName(resourceName);
lock (_executionSynchronizer)
{
@@ -934,7 +1028,7 @@ public override void ExecuteResource(string resourceName, Assembly assembly)
}
catch (OriginalJavaScriptException e)
{
- throw WrapJavaScriptException(e);
+ throw WrapJavaScriptException(_jsEngine, e);
}
catch (NullReferenceException)
{
diff --git a/src/JavaScriptEngineSwitcher.Jurassic/JurassicJsEngineFactory.cs b/src/JavaScriptEngineSwitcher.Jurassic/JurassicJsEngineFactory.cs
index 276eb6c8..dc4053c2 100644
--- a/src/JavaScriptEngineSwitcher.Jurassic/JurassicJsEngineFactory.cs
+++ b/src/JavaScriptEngineSwitcher.Jurassic/JurassicJsEngineFactory.cs
@@ -32,9 +32,7 @@ public JurassicJsEngineFactory(JurassicSettings settings)
#region IJsEngineFactory implementation
- ///
- /// Gets a name of JS engine
- ///
+ ///
public string EngineName
{
get { return JurassicJsEngine.EngineName; }
diff --git a/src/JavaScriptEngineSwitcher.Jurassic/JurassicPrecompiledScript.cs b/src/JavaScriptEngineSwitcher.Jurassic/JurassicPrecompiledScript.cs
index 82e431ac..0983ae64 100644
--- a/src/JavaScriptEngineSwitcher.Jurassic/JurassicPrecompiledScript.cs
+++ b/src/JavaScriptEngineSwitcher.Jurassic/JurassicPrecompiledScript.cs
@@ -31,9 +31,7 @@ public JurassicPrecompiledScript(OriginalCompiledScript compiledScript)
#region IPrecompiledScript implementation
- ///
- /// Gets a name of JS engine for which the pre-compiled script was created
- ///
+ ///
public string EngineName
{
get { return JurassicJsEngine.EngineName; }
diff --git a/src/JavaScriptEngineSwitcher.Jurassic/JurassicSettings.cs b/src/JavaScriptEngineSwitcher.Jurassic/JurassicSettings.cs
index 8244a0b6..a2964472 100644
--- a/src/JavaScriptEngineSwitcher.Jurassic/JurassicSettings.cs
+++ b/src/JavaScriptEngineSwitcher.Jurassic/JurassicSettings.cs
@@ -1,22 +1,40 @@
-namespace JavaScriptEngineSwitcher.Jurassic
+using System;
+
+namespace JavaScriptEngineSwitcher.Jurassic
{
///
/// Settings of the Jurassic JS engine
///
public sealed class JurassicSettings
{
+ ///
+ /// Gets or sets a flag for whether to enable conversion of host collections,
+ /// that are passed or returned to script code, to script arrays
+ ///
+ ///
+ /// This property does not allow the embedding of host collections by
+ /// using a
+ /// method, it only affects the internal mechanisms of the Jurassic library.
+ ///
+ public bool EnableHostCollectionsEmbeddingByValue
+ {
+ get;
+ set;
+ }
#if !NETSTANDARD2_0
+
///
/// Gets or sets a flag for whether to enable script debugging features
/// (allows a generation of debug information)
///
+ [Obsolete("Since the Jurassic version 3.2.1, debugging is no longer supported.")]
public bool EnableDebugging
{
get;
set;
}
-
#endif
+
///
/// Gets or sets a flag for whether to disassemble any generated IL
/// and store it in the associated function
@@ -42,9 +60,7 @@ public bool StrictMode
///
public JurassicSettings()
{
-#if !NETSTANDARD2_0
- EnableDebugging = false;
-#endif
+ EnableHostCollectionsEmbeddingByValue = false;
EnableIlAnalysis = false;
StrictMode = false;
}
diff --git a/src/JavaScriptEngineSwitcher.Jurassic/PACKAGE-DESCRIPTION.md b/src/JavaScriptEngineSwitcher.Jurassic/PACKAGE-DESCRIPTION.md
new file mode 100644
index 00000000..ad182c32
--- /dev/null
+++ b/src/JavaScriptEngineSwitcher.Jurassic/PACKAGE-DESCRIPTION.md
@@ -0,0 +1 @@
+JavaScriptEngineSwitcher.Jurassic contains a `JurassicJsEngine` adapter (wrapper for the [Jurassic](http://github.com/paulbartrum/jurassic) version of February 4, 2025).
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.Jurassic/readme.txt b/src/JavaScriptEngineSwitcher.Jurassic/readme.txt
index 624679a4..88a9730b 100644
--- a/src/JavaScriptEngineSwitcher.Jurassic/readme.txt
+++ b/src/JavaScriptEngineSwitcher.Jurassic/readme.txt
@@ -1,26 +1,24 @@
--------------------------------------------------------------------------------
- README file for JS Engine Switcher: Jurassic v3.0.0
+ README file for JS Engine Switcher: Jurassic v3.29.0
--------------------------------------------------------------------------------
- Copyright (c) 2013-2018 Andrey Taritsyn - http://www.taritsyn.ru
+ Copyright (c) 2013-2025 Andrey Taritsyn - http://www.taritsyn.ru
===========
DESCRIPTION
===========
- JavaScriptEngineSwitcher.Jurassic contains adapter `JurassicJsEngine` (wrapper
- for the Jurassic JavaScript Engine (http://github.com/paulbartrum/jurassic)
- version of February 24, 2018).
+ JavaScriptEngineSwitcher.Jurassic contains a `JurassicJsEngine` adapter (wrapper
+ for the Jurassic (http://github.com/paulbartrum/jurassic) version of
+ February 4, 2025).
=============
RELEASE NOTES
=============
- 1. Jurassic was updated to version of February 24, 2018;
- 2. Added a ability to pre-compile scripts;
- 3. Added support of .NET Standard 2.0.
+ Jurassic was updated to version of February 4, 2025.
=============
DOCUMENTATION
diff --git a/src/JavaScriptEngineSwitcher.Msie/JavaScriptEngineSwitcher.Msie.csproj b/src/JavaScriptEngineSwitcher.Msie/JavaScriptEngineSwitcher.Msie.csproj
index 4b111100..bfe69608 100644
--- a/src/JavaScriptEngineSwitcher.Msie/JavaScriptEngineSwitcher.Msie.csproj
+++ b/src/JavaScriptEngineSwitcher.Msie/JavaScriptEngineSwitcher.Msie.csproj
@@ -1,51 +1,44 @@
-
- JS Engine Switcher: MSIE
- 3.0.0
- net40-client;net45;netstandard1.3;netstandard2.0
- 1.6.0
- Library
- true
- $(NoWarn);CS1591;NU5125
- true
- true
- JavaScriptEngineSwitcher.Msie contains adapter `MsieJsEngine` (wrapper for the MSIE JavaScript Engine for .Net (http://github.com/Taritsyn/MsieJavaScriptEngine)). For correct working of the MSIE JavaScript Engine it is recommended to install Internet Explorer 9+ or Microsoft Edge on the machine.
- https://raw.githubusercontent.com/Taritsyn/JavaScriptEngineSwitcher/master/Icons/JavaScriptEngineSwitcher_Msie_Logo128x128.png
- JavaScriptEngineSwitcher;JavaScript;ECMAScript;MSIE;IE;Chakra
- 1. MSIE JavaScript Engine was updated to version 3.0.0;
-2. Added a ability to interrupt execution of the script;
-3. Added a ability to pre-compile scripts;
-4. In configuration settings of the MSIE JS engine was added one new property - `MaxStackSize` (default `492` or `984` KB);
-5. Added support of .NET Standard 2.0.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- readme.txt
- true
-
-
- msie-javascript-engine-license.txt
- true
- false
-
-
-
-
-
-
+
+ JS Engine Switcher: MSIE
+ 3.24.1
+ net40-client;net45;netstandard1.3;netstandard2.0
+ 1.6.0
+ Library
+ true
+ $(NoWarn);CS1591;NETSDK1215;NU1903
+ false
+ true
+ true
+
+
+
+
+
+
+
+
+ https://raw.githubusercontent.com/Taritsyn/JavaScriptEngineSwitcher/master/Icons/JavaScriptEngineSwitcher_Msie_Logo128x128.png
+ ../../Icons/JavaScriptEngineSwitcher_Msie_Logo128x128.png
+ JavaScriptEngineSwitcher.Msie contains a `MsieJsEngine` adapter (wrapper for the MSIE JavaScript Engine for .NET).
+ $(PackageCommonTags);MSIE;IE;Chakra
+ MSIE JavaScript Engine was updated to version 3.2.5.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.Msie/JsEngineFactoryCollectionExtensions.cs b/src/JavaScriptEngineSwitcher.Msie/JsEngineFactoryCollectionExtensions.cs
index f27d2574..dd5d4910 100644
--- a/src/JavaScriptEngineSwitcher.Msie/JsEngineFactoryCollectionExtensions.cs
+++ b/src/JavaScriptEngineSwitcher.Msie/JsEngineFactoryCollectionExtensions.cs
@@ -11,10 +11,10 @@ public static class JsEngineFactoryCollectionExtensions
{
///
/// Adds a instance of to
- /// the specified
+ /// the specified
///
- /// Instance of
- /// Instance of
+ /// Instance of
+ /// Instance of
public static JsEngineFactoryCollection AddMsie(this JsEngineFactoryCollection source)
{
if (source == null)
@@ -27,11 +27,11 @@ public static JsEngineFactoryCollection AddMsie(this JsEngineFactoryCollection s
///
/// Adds a instance of to
- /// the specified
+ /// the specified
///
- /// Instance of
+ /// Instance of
/// The delegate to configure the provided
- /// Instance of
+ /// Instance of
public static JsEngineFactoryCollection AddMsie(this JsEngineFactoryCollection source,
Action configure)
{
@@ -53,11 +53,11 @@ public static JsEngineFactoryCollection AddMsie(this JsEngineFactoryCollection s
///
/// Adds a instance of to
- /// the specified
+ /// the specified
///
- /// Instance of
+ /// Instance of
/// Settings of the MSIE JS engine
- /// Instance of
+ /// Instance of
public static JsEngineFactoryCollection AddMsie(this JsEngineFactoryCollection source,
MsieSettings settings)
{
diff --git a/src/JavaScriptEngineSwitcher.Msie/JsEngineMode.cs b/src/JavaScriptEngineSwitcher.Msie/JsEngineMode.cs
index 63791a90..11d38f0d 100644
--- a/src/JavaScriptEngineSwitcher.Msie/JsEngineMode.cs
+++ b/src/JavaScriptEngineSwitcher.Msie/JsEngineMode.cs
@@ -27,13 +27,13 @@ public enum JsEngineMode
///
/// “IE” JsRT version of Chakra JS engine (supports ECMAScript 5).
- /// Requires Internet Explorer 11 or Microsoft Edge on the machine.
+ /// Requires Internet Explorer 11 or Microsoft Edge Legacy on the machine.
///
ChakraIeJsRt,
///
/// “Edge” JsRT version of Chakra JS engine (supports ECMAScript 5).
- /// Requires Microsoft Edge on the machine.
+ /// Requires Microsoft Edge Legacy on the machine.
///
ChakraEdgeJsRt
}
diff --git a/src/JavaScriptEngineSwitcher.Msie/MsieJsEngine.cs b/src/JavaScriptEngineSwitcher.Msie/MsieJsEngine.cs
index 5da9eb00..0e438370 100644
--- a/src/JavaScriptEngineSwitcher.Msie/MsieJsEngine.cs
+++ b/src/JavaScriptEngineSwitcher.Msie/MsieJsEngine.cs
@@ -76,6 +76,7 @@ public MsieJsEngine(MsieSettings settings)
{
_jsEngine = new OriginalEngine(new OriginalEngineSettings
{
+ AllowReflection = msieSettings.AllowReflection,
EnableDebugging = msieSettings.EnableDebugging,
EngineMode = Utils.GetEnumFromOtherEnum(
msieSettings.EngineMode),
@@ -452,41 +453,26 @@ protected override void InnerCollectGarbage()
#region IJsEngine implementation
- ///
- /// Gets a name of JS engine
- ///
public override string Name
{
get { return EngineName; }
}
- ///
- /// Gets a version of original JS engine
- ///
public override string Version
{
get { return _engineVersion; }
}
- ///
- /// Gets a value that indicates if the JS engine supports script pre-сompilation
- ///
public override bool SupportsScriptPrecompilation
{
get { return _jsEngine.SupportsScriptPrecompilation; }
}
- ///
- /// Gets a value that indicates if the JS engine supports script interruption
- ///
public override bool SupportsScriptInterruption
{
get { return true; }
}
- ///
- /// Gets a value that indicates if the JS engine supports garbage collection
- ///
public override bool SupportsGarbageCollection
{
get { return true; }
diff --git a/src/JavaScriptEngineSwitcher.Msie/MsieJsEngineFactory.cs b/src/JavaScriptEngineSwitcher.Msie/MsieJsEngineFactory.cs
index 78e535f2..15b32429 100644
--- a/src/JavaScriptEngineSwitcher.Msie/MsieJsEngineFactory.cs
+++ b/src/JavaScriptEngineSwitcher.Msie/MsieJsEngineFactory.cs
@@ -32,9 +32,7 @@ public MsieJsEngineFactory(MsieSettings settings)
#region IJsEngineFactory implementation
- ///
- /// Gets a name of JS engine
- ///
+ ///
public string EngineName
{
get { return MsieJsEngine.EngineName; }
diff --git a/src/JavaScriptEngineSwitcher.Msie/MsiePrecompiledScript.cs b/src/JavaScriptEngineSwitcher.Msie/MsiePrecompiledScript.cs
index 53f2e77d..5004f43e 100644
--- a/src/JavaScriptEngineSwitcher.Msie/MsiePrecompiledScript.cs
+++ b/src/JavaScriptEngineSwitcher.Msie/MsiePrecompiledScript.cs
@@ -31,9 +31,7 @@ public MsiePrecompiledScript(OriginalPrecompiledScript precompiledScript)
#region IPrecompiledScript implementation
- ///
- /// Gets a name of JS engine for which the pre-compiled script was created
- ///
+ ///
public string EngineName
{
get { return MsieJsEngine.EngineName; }
diff --git a/src/JavaScriptEngineSwitcher.Msie/MsieSettings.cs b/src/JavaScriptEngineSwitcher.Msie/MsieSettings.cs
index 66f8c7ce..a5e85290 100644
--- a/src/JavaScriptEngineSwitcher.Msie/MsieSettings.cs
+++ b/src/JavaScriptEngineSwitcher.Msie/MsieSettings.cs
@@ -28,6 +28,19 @@ public sealed class MsieSettings
private int _maxStackSize;
#endif
+ ///
+ /// Gets or sets a flag for whether to allow the usage of reflection API in the script code
+ ///
+ ///
+ /// This affects , Exception.GetType ,
+ /// Exception.TargetSite and Delegate.Method .
+ ///
+ public bool AllowReflection
+ {
+ get;
+ set;
+ }
+
///
/// Gets or sets a flag for whether to enable script debugging features
///
@@ -51,9 +64,8 @@ public JsEngineMode EngineMode
/// Gets or sets a maximum stack size in bytes
///
///
- /// Set a 0 to use the default maximum stack size specified in the header
+ /// Set a 0 to use the default maximum stack size specified in the header
/// for the executable.
- ///
///
public int MaxStackSize
{
@@ -97,6 +109,7 @@ public bool UseJson2Library
///
public MsieSettings()
{
+ AllowReflection = false;
EnableDebugging = false;
EngineMode = JsEngineMode.Auto;
#if !NETSTANDARD1_3
diff --git a/src/JavaScriptEngineSwitcher.Msie/PACKAGE-DESCRIPTION.md b/src/JavaScriptEngineSwitcher.Msie/PACKAGE-DESCRIPTION.md
new file mode 100644
index 00000000..c0017681
--- /dev/null
+++ b/src/JavaScriptEngineSwitcher.Msie/PACKAGE-DESCRIPTION.md
@@ -0,0 +1,3 @@
+JavaScriptEngineSwitcher.Msie contains a `MsieJsEngine` adapter (wrapper for the [MSIE JavaScript Engine for .NET](http://github.com/Taritsyn/MsieJavaScriptEngine)).
+
+For correct working of the MSIE JavaScript Engine it is recommended to install Internet Explorer 9+ or Microsoft Edge Legacy on the machine.
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.Msie/Resources/Strings.Designer.cs b/src/JavaScriptEngineSwitcher.Msie/Resources/Strings.Designer.cs
index 9eca28b2..50649830 100644
--- a/src/JavaScriptEngineSwitcher.Msie/Resources/Strings.Designer.cs
+++ b/src/JavaScriptEngineSwitcher.Msie/Resources/Strings.Designer.cs
@@ -21,7 +21,7 @@ internal class Strings
private static Lazy _resourceManager =
new Lazy(() => new ResourceManager(
"JavaScriptEngineSwitcher.Msie.Resources.Strings",
-#if NET40
+#if NET20 || NET30 || NET35 || NET40
typeof(Strings).Assembly
#else
typeof(Strings).GetTypeInfo().Assembly
diff --git a/src/JavaScriptEngineSwitcher.Msie/Resources/Strings.ru-ru.Designer.cs b/src/JavaScriptEngineSwitcher.Msie/Resources/Strings.ru-RU.Designer.cs
similarity index 100%
rename from src/JavaScriptEngineSwitcher.Msie/Resources/Strings.ru-ru.Designer.cs
rename to src/JavaScriptEngineSwitcher.Msie/Resources/Strings.ru-RU.Designer.cs
diff --git a/src/JavaScriptEngineSwitcher.Msie/Resources/Strings.ru-ru.resx b/src/JavaScriptEngineSwitcher.Msie/Resources/Strings.ru-RU.resx
similarity index 100%
rename from src/JavaScriptEngineSwitcher.Msie/Resources/Strings.ru-ru.resx
rename to src/JavaScriptEngineSwitcher.Msie/Resources/Strings.ru-RU.resx
diff --git a/src/JavaScriptEngineSwitcher.Msie/readme.txt b/src/JavaScriptEngineSwitcher.Msie/readme.txt
index 2148dd6d..2f82f48b 100644
--- a/src/JavaScriptEngineSwitcher.Msie/readme.txt
+++ b/src/JavaScriptEngineSwitcher.Msie/readme.txt
@@ -1,30 +1,25 @@
--------------------------------------------------------------------------------
- README file for JS Engine Switcher: MSIE v3.0.0
+ README file for JS Engine Switcher: MSIE v3.24.1
--------------------------------------------------------------------------------
- Copyright (c) 2013-2018 Andrey Taritsyn - http://www.taritsyn.ru
+ Copyright (c) 2013-2024 Andrey Taritsyn - http://www.taritsyn.ru
===========
DESCRIPTION
===========
- JavaScriptEngineSwitcher.Msie contains adapter `MsieJsEngine` (wrapper for the
- MSIE JavaScript Engine for .Net (http://github.com/Taritsyn/MsieJavaScriptEngine)).
+ JavaScriptEngineSwitcher.Msie contains a `MsieJsEngine` adapter (wrapper for the
+ MSIE JavaScript Engine for .NET (http://github.com/Taritsyn/MsieJavaScriptEngine)).
For correct working of the MSIE JavaScript Engine it is recommended to install
- Internet Explorer 9+ or Microsoft Edge on the machine.
+ Internet Explorer 9+ or Microsoft Edge Legacy on the machine.
=============
RELEASE NOTES
=============
- 1. MSIE JavaScript Engine was updated to version 3.0.0;
- 2. Added a ability to interrupt execution of the script;
- 3. Added a ability to pre-compile scripts;
- 4. In configuration settings of the MSIE JS engine was added one new property -
- `MaxStackSize` (default `492` or `984` KB);
- 5. Added support of .NET Standard 2.0.
+ MSIE JavaScript Engine was updated to version 3.2.5.
=============
DOCUMENTATION
diff --git a/src/JavaScriptEngineSwitcher.NiL/Helpers/NiLJsErrorHelpers.cs b/src/JavaScriptEngineSwitcher.NiL/Helpers/NiLJsErrorHelpers.cs
new file mode 100644
index 00000000..91474ef0
--- /dev/null
+++ b/src/JavaScriptEngineSwitcher.NiL/Helpers/NiLJsErrorHelpers.cs
@@ -0,0 +1,122 @@
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Text.RegularExpressions;
+
+using JavaScriptEngineSwitcher.Core.Extensions;
+using JavaScriptEngineSwitcher.Core.Helpers;
+
+using CoreStrings = JavaScriptEngineSwitcher.Core.Resources.Strings;
+
+namespace JavaScriptEngineSwitcher.NiL.Helpers
+{
+ ///
+ /// JS error helpers
+ ///
+ internal static class NiLJsErrorHelpers
+ {
+ #region Error location
+
+ private const string AtLinePrefix = " at ";
+ private const string DotNetStackTraceLinePrefix = AtLinePrefix + "NiL.JS.";
+
+ private const string OriginalGlobalCode = "anonymous";
+ private const string OriginalAnonymousFunctionName = "";
+ private const string WrapperGlobalCode = "Global code";
+ private const string WrapperAnonymousFunctionName = "Anonymous function";
+
+ ///
+ /// Regular expression for working with line of the script error location
+ ///
+ private static readonly Regex _errorLocationLineRegex =
+ new Regex(@"^" + AtLinePrefix +
+ @"(?" +
+ @"[\w][\w ]*" +
+ @"|" +
+ CommonRegExps.JsFullNamePattern +
+ @"|" +
+ Regex.Escape(OriginalAnonymousFunctionName) +
+ @")" +
+ @"(?::line (?\d+):(?\d+))?$");
+
+
+ ///
+ /// Parses a string representation of the script error location to produce an array of
+ /// instances
+ ///
+ /// String representation of the script error location
+ /// An array of instances
+ public static ErrorLocationItem[] ParseErrorLocation(string errorLocation)
+ {
+ if (string.IsNullOrWhiteSpace(errorLocation))
+ {
+ return new ErrorLocationItem[0];
+ }
+
+ var errorLocationItems = new List();
+ string[] lines = errorLocation.SplitToLines();
+ int lineCount = lines.Length;
+
+ for (int lineIndex = 0; lineIndex < lineCount; lineIndex++)
+ {
+ string line = lines[lineIndex];
+
+ if (line.Length == 0)
+ {
+ continue;
+ }
+
+ // Completing parsing when a .NET stack trace is found
+ if (line.StartsWith(DotNetStackTraceLinePrefix, StringComparison.Ordinal))
+ {
+ break;
+ }
+
+ Match lineMatch = _errorLocationLineRegex.Match(line);
+ if (lineMatch.Success)
+ {
+ GroupCollection lineGroups = lineMatch.Groups;
+ Group lineNumberGroup = lineGroups["lineNumber"];
+ Group columnNumberGroup = lineGroups["columnNumber"];
+
+ var errorLocationItem = new ErrorLocationItem
+ {
+ FunctionName = lineGroups["functionName"].Value,
+ LineNumber = lineNumberGroup.Success ? int.Parse(lineNumberGroup.Value) : 0,
+ ColumnNumber = columnNumberGroup.Success ? int.Parse(columnNumberGroup.Value) : 0,
+ };
+ errorLocationItems.Add(errorLocationItem);
+ }
+ else
+ {
+ Debug.WriteLine(string.Format(CoreStrings.Runtime_InvalidErrorLocationLineFormat, line));
+ return new ErrorLocationItem[0];
+ }
+ }
+
+ return errorLocationItems.ToArray();
+ }
+
+ ///
+ /// Fixes a error location items
+ ///
+ /// An array of instances
+ public static void FixErrorLocationItems(ErrorLocationItem[] errorLocationItems)
+ {
+ foreach (ErrorLocationItem errorLocationItem in errorLocationItems)
+ {
+ string functionName = errorLocationItem.FunctionName;
+ if (functionName.Length == 0 || functionName == OriginalGlobalCode)
+ {
+ errorLocationItem.FunctionName = WrapperGlobalCode;
+ }
+ else if (functionName == OriginalAnonymousFunctionName)
+ {
+ errorLocationItem.FunctionName = WrapperAnonymousFunctionName;
+ }
+ }
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.NiL/JavaScriptEngineSwitcher.NiL.csproj b/src/JavaScriptEngineSwitcher.NiL/JavaScriptEngineSwitcher.NiL.csproj
index f4e3f7bc..388f33ab 100644
--- a/src/JavaScriptEngineSwitcher.NiL/JavaScriptEngineSwitcher.NiL.csproj
+++ b/src/JavaScriptEngineSwitcher.NiL/JavaScriptEngineSwitcher.NiL.csproj
@@ -1,45 +1,37 @@
-
- JS Engine Switcher: NiL
- 3.0.0
- net40-client;net45;netstandard1.3;netstandard2.0
- Library
- true
- $(NoWarn);CS1591;NU5125
- true
- JavaScriptEngineSwitcher.NiL contains adapter `NiLJsEngine` (wrapper for the NiL JavaScript Engine (https://github.com/nilproject/NiL.JS) version 2.5.1282).
- https://raw.githubusercontent.com/Taritsyn/JavaScriptEngineSwitcher/master/Icons/JavaScriptEngineSwitcher_NiL_Logo128x128.png
- JavaScriptEngineSwitcher;JavaScript;ECMAScript;NiL
-
+
+ JS Engine Switcher: NiL
+ 3.30.3
+ net461;net48;netcoreapp3.1;net6.0;net8.0;net9.0
+ Library
+ true
+ $(NoWarn);CS1591
+ false
+ true
+ false
+
-
-
-
-
+
+
+
+
-
-
-
+
+ https://raw.githubusercontent.com/Taritsyn/JavaScriptEngineSwitcher/master/Icons/JavaScriptEngineSwitcher_NiL_Logo128x128.png
+ ../../Icons/JavaScriptEngineSwitcher_NiL_Logo128x128.png
+ JavaScriptEngineSwitcher.NiL contains a `NiLJsEngine` adapter (wrapper for the NiL.JS).
+ $(PackageCommonTags);NiL
+ NiL.JS was updated to version 2.6.1712.
+
-
-
-
+
+
+
+
-
-
-
-
-
-
- readme.txt
- true
-
-
- nil-license.txt
- true
- false
-
-
+
+
+
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.NiL/JsEngineFactoryCollectionExtensions.cs b/src/JavaScriptEngineSwitcher.NiL/JsEngineFactoryCollectionExtensions.cs
index 9cb2b816..985d6ef5 100644
--- a/src/JavaScriptEngineSwitcher.NiL/JsEngineFactoryCollectionExtensions.cs
+++ b/src/JavaScriptEngineSwitcher.NiL/JsEngineFactoryCollectionExtensions.cs
@@ -11,10 +11,10 @@ public static class JsEngineFactoryCollectionExtensions
{
///
/// Adds a instance of to
- /// the specified
+ /// the specified
///
- /// Instance of
- /// Instance of
+ /// Instance of
+ /// Instance of
public static JsEngineFactoryCollection AddNiL(this JsEngineFactoryCollection source)
{
if (source == null)
@@ -27,11 +27,11 @@ public static JsEngineFactoryCollection AddNiL(this JsEngineFactoryCollection so
///
/// Adds a instance of to
- /// the specified
+ /// the specified
///
- /// Instance of
+ /// Instance of
/// The delegate to configure the provided
- /// Instance of
+ /// Instance of
public static JsEngineFactoryCollection AddNiL(this JsEngineFactoryCollection source,
Action configure)
{
@@ -53,11 +53,11 @@ public static JsEngineFactoryCollection AddNiL(this JsEngineFactoryCollection so
///
/// Adds a instance of to
- /// the specified
+ /// the specified
///
- /// Instance of
+ /// Instance of
/// Settings of the NiL JS engine
- /// Instance of
+ /// Instance of
public static JsEngineFactoryCollection AddNiL(this JsEngineFactoryCollection source, NiLSettings settings)
{
if (source == null)
diff --git a/src/JavaScriptEngineSwitcher.NiL/NiLJsEngine.cs b/src/JavaScriptEngineSwitcher.NiL/NiLJsEngine.cs
index 19ad3fab..90405344 100644
--- a/src/JavaScriptEngineSwitcher.NiL/NiLJsEngine.cs
+++ b/src/JavaScriptEngineSwitcher.NiL/NiLJsEngine.cs
@@ -24,6 +24,8 @@
using WrapperRuntimeException = JavaScriptEngineSwitcher.Core.JsRuntimeException;
using WrapperScriptException = JavaScriptEngineSwitcher.Core.JsScriptException;
+using JavaScriptEngineSwitcher.NiL.Helpers;
+
namespace JavaScriptEngineSwitcher.NiL
{
///
@@ -39,7 +41,7 @@ public sealed class NiLJsEngine : JsEngineBase
///
/// Version of original JS engine
///
- private const string EngineVersion = "2.5.1282";
+ private const string EngineVersion = "2.6.1712";
///
/// Regular expression for working with the syntax error message
@@ -87,6 +89,7 @@ public NiLJsEngine(NiLSettings settings)
{
_jsContext.DebuggerCallback += _debuggerCallback;
}
+ _jsContext.GlobalContext.CurrentTimeZone = niLSettings.LocalTimeZone;
}
catch (Exception e)
{
@@ -113,7 +116,7 @@ private static OriginalValue MapToScriptType(object value)
return OriginalValue.Undefined;
}
- return OriginalValue.Marshal(value);
+ return OriginalContext.CurrentGlobalContext.ProxyValue(value);
}
///
@@ -198,19 +201,42 @@ private static WrapperException WrapJsException(OriginalException originalExcept
}
else
{
- string sourceCode = originalException.Code;
+ string sourceCode = originalException.SourceCode;
OriginalCodeCoordinates codeCoordinates = originalException.CodeCoordinates;
if (codeCoordinates != null)
{
lineNumber = codeCoordinates.Line;
columnNumber = codeCoordinates.Column;
}
+
sourceFragment = TextHelpers.GetTextFragment(sourceCode, lineNumber, columnNumber);
- message = JsErrorHelpers.GenerateScriptErrorMessage(type, description, string.Empty,
- lineNumber, columnNumber, sourceFragment);
+ string callStack = string.Empty;
+ ErrorLocationItem[] callStackItems = NiLJsErrorHelpers.ParseErrorLocation(
+ originalException.StackTrace);
+ if (callStackItems.Length > 0)
+ {
+ NiLJsErrorHelpers.FixErrorLocationItems(callStackItems);
+
+ ErrorLocationItem firstCallStackItem = callStackItems[0];
+ firstCallStackItem.SourceFragment = sourceFragment;
- wrapperScriptException = new WrapperRuntimeException(message, EngineName, EngineVersion,
+ callStack = JsErrorHelpers.StringifyErrorLocationItems(callStackItems, true);
+ string callStackWithSourceFragment = JsErrorHelpers.StringifyErrorLocationItems(
+ callStackItems);
+ message = JsErrorHelpers.GenerateScriptErrorMessage(type, description,
+ callStackWithSourceFragment);
+ }
+ else
+ {
+ message = JsErrorHelpers.GenerateScriptErrorMessage(type, description, string.Empty,
+ lineNumber, columnNumber, sourceFragment);
+ }
+
+ var wrapperRuntimeException = new WrapperRuntimeException(message, EngineName, EngineVersion,
originalException);
+ wrapperRuntimeException.CallStack = callStack;
+
+ wrapperScriptException = wrapperRuntimeException;
}
wrapperScriptException.Type = type;
wrapperScriptException.LineNumber = lineNumber;
@@ -452,7 +478,7 @@ protected override void InnerRemoveVariable(string variableName)
protected override void InnerEmbedHostObject(string itemName, object value)
{
- OriginalValue processedValue = OriginalValue.Marshal(value);
+ OriginalValue processedValue = _jsContext.GlobalContext.ProxyValue(value);
try
{
@@ -506,41 +532,26 @@ protected override void InnerCollectGarbage()
#region IJsEngine implementation
- ///
- /// Gets a name of JS engine
- ///
public override string Name
{
get { return EngineName; }
}
- ///
- /// Gets a version of original JS engine
- ///
public override string Version
{
get { return EngineVersion; }
}
- ///
- /// Gets a value that indicates if the JS engine supports script pre-сompilation
- ///
public override bool SupportsScriptPrecompilation
{
get { return false; }
}
- ///
- /// Gets a value that indicates if the JS engine supports script interruption
- ///
public override bool SupportsScriptInterruption
{
get { return false; }
}
- ///
- /// Gets a value that indicates if the JS engine supports garbage collection
- ///
public override bool SupportsGarbageCollection
{
get { return false; }
diff --git a/src/JavaScriptEngineSwitcher.NiL/NiLJsEngineFactory.cs b/src/JavaScriptEngineSwitcher.NiL/NiLJsEngineFactory.cs
index 8b42e84f..d4c51f48 100644
--- a/src/JavaScriptEngineSwitcher.NiL/NiLJsEngineFactory.cs
+++ b/src/JavaScriptEngineSwitcher.NiL/NiLJsEngineFactory.cs
@@ -32,9 +32,7 @@ public NiLJsEngineFactory(NiLSettings settings)
#region IJsEngineFactory implementation
- ///
- /// Gets a name of JS engine
- ///
+ ///
public string EngineName
{
get { return NiLJsEngine.EngineName; }
diff --git a/src/JavaScriptEngineSwitcher.NiL/NiLSettings.cs b/src/JavaScriptEngineSwitcher.NiL/NiLSettings.cs
index b650b9c4..9fdd7142 100644
--- a/src/JavaScriptEngineSwitcher.NiL/NiLSettings.cs
+++ b/src/JavaScriptEngineSwitcher.NiL/NiLSettings.cs
@@ -1,4 +1,6 @@
-using OriginalDebuggerCallback = NiL.JS.Core.DebuggerCallback;
+using System;
+
+using OriginalDebuggerCallback = NiL.JS.Core.DebuggerCallback;
namespace JavaScriptEngineSwitcher.NiL
{
@@ -25,6 +27,15 @@ public bool EnableDebugging
set;
}
+ ///
+ /// Gets or sets a local time zone for the Date objects in the script
+ ///
+ public TimeZoneInfo LocalTimeZone
+ {
+ get;
+ set;
+ }
+
///
/// Gets or sets a flag for whether to allow run the script in strict mode
///
@@ -42,6 +53,7 @@ public NiLSettings()
{
DebuggerCallback = null;
EnableDebugging = false;
+ LocalTimeZone = TimeZoneInfo.Local;
StrictMode = false;
}
}
diff --git a/src/JavaScriptEngineSwitcher.NiL/PACKAGE-DESCRIPTION.md b/src/JavaScriptEngineSwitcher.NiL/PACKAGE-DESCRIPTION.md
new file mode 100644
index 00000000..23fa1c6d
--- /dev/null
+++ b/src/JavaScriptEngineSwitcher.NiL/PACKAGE-DESCRIPTION.md
@@ -0,0 +1 @@
+JavaScriptEngineSwitcher.NiL contains a `NiLJsEngine` adapter (wrapper for the [NiL.JS](https://github.com/nilproject/NiL.JS) version 2.6.1712).
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.NiL/readme.txt b/src/JavaScriptEngineSwitcher.NiL/readme.txt
index 15972511..032ce973 100644
--- a/src/JavaScriptEngineSwitcher.NiL/readme.txt
+++ b/src/JavaScriptEngineSwitcher.NiL/readme.txt
@@ -1,18 +1,23 @@
--------------------------------------------------------------------------------
- README file for JS Engine Switcher: NiL v3.0.0
+ README file for JS Engine Switcher: NiL v3.30.3
--------------------------------------------------------------------------------
- Copyright (c) 2013-2018 Andrey Taritsyn - http://www.taritsyn.ru
+ Copyright (c) 2013-2025 Andrey Taritsyn - http://www.taritsyn.ru
===========
DESCRIPTION
===========
- JavaScriptEngineSwitcher.NiL contains adapter `NiLJsEngine` (wrapper for the
- NiL JavaScript Engine (https://github.com/nilproject/NiL.JS) version 2.5.1282).
+ JavaScriptEngineSwitcher.NiL contains a `NiLJsEngine` adapter (wrapper for the
+ NiL.JS (https://github.com/nilproject/NiL.JS) version 2.6.1712).
+
+ =============
+ RELEASE NOTES
+ =============
+ NiL.JS was updated to version 2.6.1712.
=============
DOCUMENTATION
diff --git a/src/JavaScriptEngineSwitcher.Node/DefaultNodeJsService.cs b/src/JavaScriptEngineSwitcher.Node/DefaultNodeJsService.cs
new file mode 100644
index 00000000..75efc139
--- /dev/null
+++ b/src/JavaScriptEngineSwitcher.Node/DefaultNodeJsService.cs
@@ -0,0 +1,117 @@
+using System;
+using System.IO;
+using System.Threading;
+using System.Threading.Tasks;
+
+using Jering.Javascript.NodeJS;
+
+namespace JavaScriptEngineSwitcher.Node
+{
+ ///
+ /// Default Node JS service
+ ///
+ ///
+ /// Wrapper around the class.
+ ///
+ public sealed class DefaultNodeJsService : INodeJSService
+ {
+ ///
+ /// Instance of default Node JS service
+ ///
+ private static readonly DefaultNodeJsService _instance = new DefaultNodeJsService();
+
+ ///
+ /// Gets a instance of default Node JS service
+ ///
+ public static INodeJSService Instance
+ {
+ get { return _instance; }
+ }
+
+
+ ///
+ /// Private constructor for implementation Singleton pattern
+ ///
+ private DefaultNodeJsService()
+ { }
+
+
+ #region INodeJSService implementation
+
+ public Task InvokeFromFileAsync(string modulePath, string exportName = null, object[] args = null, CancellationToken cancellationToken = default)
+ {
+ return StaticNodeJSService.InvokeFromFileAsync(modulePath, exportName, args, cancellationToken);
+ }
+
+ public Task InvokeFromFileAsync(string modulePath, string exportName = null, object[] args = null, CancellationToken cancellationToken = default)
+ {
+ return StaticNodeJSService.InvokeFromFileAsync(modulePath, exportName, args, cancellationToken);
+ }
+
+ public Task InvokeFromStringAsync(string moduleString, string cacheIdentifier = null, string exportName = null, object[] args = null, CancellationToken cancellationToken = default)
+ {
+ return StaticNodeJSService.InvokeFromStringAsync(moduleString, cacheIdentifier, exportName, args, cancellationToken);
+ }
+
+ public Task InvokeFromStringAsync(string moduleString, string cacheIdentifier = null, string exportName = null, object[] args = null, CancellationToken cancellationToken = default)
+ {
+ return StaticNodeJSService.InvokeFromStringAsync(moduleString, cacheIdentifier, exportName, args, cancellationToken);
+ }
+
+ public Task InvokeFromStringAsync(Func moduleFactory, string cacheIdentifier, string exportName = null, object[] args = null, CancellationToken cancellationToken = default)
+ {
+ return StaticNodeJSService.InvokeFromStringAsync(moduleFactory, cacheIdentifier, exportName, args, cancellationToken);
+ }
+
+ public Task InvokeFromStringAsync(Func moduleFactory, string cacheIdentifier, string exportName = null, object[] args = null, CancellationToken cancellationToken = default)
+ {
+ return StaticNodeJSService.InvokeFromStringAsync(moduleFactory, cacheIdentifier, exportName, args, cancellationToken);
+ }
+
+ public Task InvokeFromStreamAsync(Stream moduleStream, string cacheIdentifier = null, string exportName = null, object[] args = null, CancellationToken cancellationToken = default)
+ {
+ return StaticNodeJSService.InvokeFromStreamAsync(moduleStream, cacheIdentifier, exportName, args, cancellationToken);
+ }
+
+ public Task InvokeFromStreamAsync(Stream moduleStream, string cacheIdentifier = null, string exportName = null, object[] args = null, CancellationToken cancellationToken = default)
+ {
+ return StaticNodeJSService.InvokeFromStreamAsync(moduleStream, cacheIdentifier, exportName, args, cancellationToken);
+ }
+
+ public Task InvokeFromStreamAsync(Func moduleFactory, string cacheIdentifier, string exportName = null, object[] args = null, CancellationToken cancellationToken = default)
+ {
+ return StaticNodeJSService.InvokeFromStreamAsync(moduleFactory, cacheIdentifier, exportName, args, cancellationToken);
+ }
+
+ public Task InvokeFromStreamAsync(Func moduleFactory, string cacheIdentifier, string exportName = null, object[] args = null, CancellationToken cancellationToken = default)
+ {
+ return StaticNodeJSService.InvokeFromStreamAsync(moduleFactory, cacheIdentifier, exportName, args, cancellationToken);
+ }
+
+ public Task<(bool, T)> TryInvokeFromCacheAsync(string moduleCacheIdentifier, string exportName = null, object[] args = null, CancellationToken cancellationToken = default)
+ {
+ return StaticNodeJSService.TryInvokeFromCacheAsync(moduleCacheIdentifier, exportName, args, cancellationToken);
+ }
+
+ public Task TryInvokeFromCacheAsync(string moduleCacheIdentifier, string exportName = null, object[] args = null, CancellationToken cancellationToken = default)
+ {
+ return StaticNodeJSService.TryInvokeFromCacheAsync(moduleCacheIdentifier, exportName, args, cancellationToken);
+ }
+
+ public ValueTask MoveToNewProcessAsync()
+ {
+ throw new NotSupportedException();
+ }
+
+ #region IDisposable implementation
+
+ public void Dispose()
+ {
+ throw new NotSupportedException();
+ }
+
+ #endregion
+
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.Node/Helpers/NodeJsErrorHelpers.cs b/src/JavaScriptEngineSwitcher.Node/Helpers/NodeJsErrorHelpers.cs
new file mode 100644
index 00000000..4322ad75
--- /dev/null
+++ b/src/JavaScriptEngineSwitcher.Node/Helpers/NodeJsErrorHelpers.cs
@@ -0,0 +1,180 @@
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Text.RegularExpressions;
+
+using JavaScriptEngineSwitcher.Core.Extensions;
+using JavaScriptEngineSwitcher.Core.Helpers;
+
+using CoreStrings = JavaScriptEngineSwitcher.Core.Resources.Strings;
+
+namespace JavaScriptEngineSwitcher.Node.Helpers
+{
+ ///
+ /// JS error helpers
+ ///
+ internal static class NodeJsErrorHelpers
+ {
+ #region Error location
+
+ ///
+ /// Name of file, which identifies the generated function call
+ ///
+ private const string GeneratedFunctionCallDocumentName = "JavaScriptEngineSwitcher.Node.Resources.generated-function-call.js";
+
+ ///
+ /// Pattern for working with document names with coordinates
+ ///
+ private static readonly string DocumentNameWithCoordinatesPattern =
+ @"(?" + CommonRegExps.DocumentNamePattern + @"||\[eval\])" +
+ @"(?::(?\d+)(?::(?\d+))?)?";
+
+ ///
+ /// Pattern for working with JS function names
+ ///
+ private static readonly string JsFunctionNamePattern = CommonRegExps.JsNamePattern +
+ @"(?:\.(?:" + CommonRegExps.JsNamePattern + @"|))*";
+
+ ///
+ /// Regular expression for working with line of the script error location
+ ///
+ private static readonly Regex _errorLocationLineRegex =
+ new Regex(@"^[ ]{3,4}at " +
+ @"(?:" +
+ @"(?[\w][\w ]*|" + JsFunctionNamePattern + @") " +
+ @"\(" + DocumentNameWithCoordinatesPattern + @"\)" +
+ @"|" +
+ DocumentNameWithCoordinatesPattern +
+ @")" +
+ @"(?: -> (?[^\n\r]+))?$");
+
+
+ ///
+ /// Parses a string representation of the script error location to produce an array of
+ /// instances
+ ///
+ /// String representation of the script error location
+ /// An array of instances
+ public static ErrorLocationItem[] ParseErrorLocation(string errorLocation)
+ {
+ if (string.IsNullOrWhiteSpace(errorLocation))
+ {
+ return new ErrorLocationItem[0];
+ }
+
+ var errorLocationItems = new List();
+ string[] lines = errorLocation.SplitToLines();
+ int lineCount = lines.Length;
+
+ for (int lineIndex = 0; lineIndex < lineCount; lineIndex++)
+ {
+ string line = lines[lineIndex];
+ if (line.Length == 0)
+ {
+ continue;
+ }
+
+ Match lineMatch = _errorLocationLineRegex.Match(line);
+
+ if (lineMatch.Success)
+ {
+ GroupCollection lineGroups = lineMatch.Groups;
+ Group lineNumberGroup = lineGroups["lineNumber"];
+ Group columnNumberGroup = lineGroups["columnNumber"];
+
+ var errorLocationItem = new ErrorLocationItem
+ {
+ FunctionName = lineGroups["functionName"].Value,
+ DocumentName = lineGroups["documentName"].Value,
+ LineNumber = lineNumberGroup.Success ? int.Parse(lineNumberGroup.Value) : 0,
+ ColumnNumber = columnNumberGroup.Success ? int.Parse(columnNumberGroup.Value) : 0,
+ SourceFragment = lineGroups["sourceFragment"].Value
+ };
+ errorLocationItems.Add(errorLocationItem);
+ }
+ else
+ {
+ Debug.WriteLine(string.Format(CoreStrings.Runtime_InvalidErrorLocationLineFormat, line));
+ return new ErrorLocationItem[0];
+ }
+ }
+
+ return errorLocationItems.ToArray();
+ }
+
+ ///
+ /// Gets a column count from the text line
+ ///
+ /// Content of the text line
+ /// Column count from the text line
+ public static int GetColumnCountFromLine(string textLine)
+ {
+ if (string.IsNullOrEmpty(textLine))
+ {
+ return 0;
+ }
+
+ if (textLine.IndexOf('\t') == -1)
+ {
+ return textLine.Length;
+ }
+
+ int charCount = textLine.Length;
+ int columnCount = 0;
+
+ for (int charIndex = 0; charIndex < charCount; charIndex++)
+ {
+ char charValue = textLine[charIndex];
+ int increment = charValue == '\t' ? 4 : 1;
+
+ columnCount += increment;
+ }
+
+ return columnCount;
+ }
+
+ ///
+ /// Filters a error location items
+ ///
+ /// An array of instances
+ public static ErrorLocationItem[] FilterErrorLocationItems(ErrorLocationItem[] errorLocationItems)
+ {
+ int itemCount = errorLocationItems.Length;
+ if (itemCount == 0)
+ {
+ return errorLocationItems;
+ }
+
+ int itemIndex = 0;
+
+ while (itemIndex < itemCount)
+ {
+ ErrorLocationItem item = errorLocationItems[itemIndex];
+ string documentName = item.DocumentName;
+ string functionName = item.FunctionName;
+
+ if (documentName == "node:vm"
+ || documentName == "vm.js"
+ || documentName == GeneratedFunctionCallDocumentName
+ || (documentName == "anonymous" && functionName == "callFunction"))
+ {
+ break;
+ }
+
+ itemIndex++;
+ }
+
+ if (itemIndex == itemCount)
+ {
+ return errorLocationItems;
+ }
+
+ var processedErrorLocationItems = new ErrorLocationItem[itemIndex];
+ Array.Copy(errorLocationItems, processedErrorLocationItems, itemIndex);
+
+ return processedErrorLocationItems;
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.Node/JavaScriptEngineSwitcher.Node.csproj b/src/JavaScriptEngineSwitcher.Node/JavaScriptEngineSwitcher.Node.csproj
new file mode 100644
index 00000000..c8d22b0a
--- /dev/null
+++ b/src/JavaScriptEngineSwitcher.Node/JavaScriptEngineSwitcher.Node.csproj
@@ -0,0 +1,44 @@
+
+
+
+ JS Engine Switcher: Node
+ 3.24.1
+ net461;netstandard2.0;netcoreapp3.1;net5.0;net6.0;net7.0
+ Library
+ true
+ true
+ true
+ $(NoWarn);CS1591;NU1903
+ false
+ true
+ true
+ false
+
+
+
+
+
+
+
+ https://raw.githubusercontent.com/Taritsyn/JavaScriptEngineSwitcher/master/Icons/JavaScriptEngineSwitcher_Node_Logo128x128.png
+ ../../Icons/JavaScriptEngineSwitcher_Node_Logo128x128.png
+ JavaScriptEngineSwitcher.Node contains a `NodeJsEngine` adapter (wrapper for the Jering.Javascript.NodeJS).
+ $(PackageCommonTags);Node.js;Jering.Javascript.NodeJS
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.Node/JsEngineFactoryCollectionExtensions.cs b/src/JavaScriptEngineSwitcher.Node/JsEngineFactoryCollectionExtensions.cs
new file mode 100644
index 00000000..81d1b4be
--- /dev/null
+++ b/src/JavaScriptEngineSwitcher.Node/JsEngineFactoryCollectionExtensions.cs
@@ -0,0 +1,266 @@
+using System;
+
+using Jering.Javascript.NodeJS;
+using Microsoft.Extensions.DependencyInjection;
+
+using JavaScriptEngineSwitcher.Core;
+
+namespace JavaScriptEngineSwitcher.Node
+{
+ ///
+ /// JS engine factory collection extensions
+ ///
+ public static class JsEngineFactoryCollectionExtensions
+ {
+ ///
+ /// Adds a instance of to
+ /// the specified
+ ///
+ /// Instance of
+ /// Instance of
+ public static JsEngineFactoryCollection AddNode(this JsEngineFactoryCollection source)
+ {
+ if (source == null)
+ {
+ throw new ArgumentNullException(nameof(source));
+ }
+
+ source.Add(new NodeJsEngineFactory());
+
+ return source;
+ }
+
+ ///
+ /// Adds a instance of to
+ /// the specified
+ ///
+ /// Instance of
+ /// Node JS service
+ /// Instance of
+ public static JsEngineFactoryCollection AddNode(this JsEngineFactoryCollection source,
+ INodeJSService service)
+ {
+ if (source == null)
+ {
+ throw new ArgumentNullException(nameof(source));
+ }
+
+ if (service == null)
+ {
+ throw new ArgumentNullException(nameof(service));
+ }
+
+ source.Add(new NodeJsEngineFactory(service));
+
+ return source;
+ }
+
+ ///
+ /// Adds a instance of to
+ /// the specified
+ ///
+ /// Instance of
+ /// The services available in the application
+ /// Instance of
+ public static JsEngineFactoryCollection AddNode(this JsEngineFactoryCollection source,
+ IServiceCollection services)
+ {
+ if (source == null)
+ {
+ throw new ArgumentNullException(nameof(source));
+ }
+
+ if (services == null)
+ {
+ throw new ArgumentNullException(nameof(services));
+ }
+
+ source.Add(new NodeJsEngineFactory(services));
+
+ return source;
+ }
+
+ ///
+ /// Adds a instance of to
+ /// the specified
+ ///
+ /// Instance of
+ /// The delegate to configure the provided
+ /// Instance of
+ public static JsEngineFactoryCollection AddNode(this JsEngineFactoryCollection source,
+ Action configure)
+ {
+ if (source == null)
+ {
+ throw new ArgumentNullException(nameof(source));
+ }
+
+ if (configure == null)
+ {
+ throw new ArgumentNullException(nameof(configure));
+ }
+
+ var settings = new NodeSettings();
+ configure(settings);
+
+ source.Add(new NodeJsEngineFactory(settings));
+
+ return source;
+ }
+
+ ///
+ /// Adds a instance of to
+ /// the specified
+ ///
+ /// Instance of
+ /// Settings of the Node JS engine
+ /// Instance of
+ public static JsEngineFactoryCollection AddNode(this JsEngineFactoryCollection source,
+ NodeSettings settings)
+ {
+ if (source == null)
+ {
+ throw new ArgumentNullException(nameof(source));
+ }
+
+ if (settings == null)
+ {
+ throw new ArgumentNullException(nameof(settings));
+ }
+
+ source.Add(new NodeJsEngineFactory(settings));
+
+ return source;
+ }
+
+ ///
+ /// Adds a instance of to
+ /// the specified
+ ///
+ /// Instance of
+ /// Node JS service
+ /// The delegate to configure the provided
+ /// Instance of
+ public static JsEngineFactoryCollection AddNode(this JsEngineFactoryCollection source,
+ INodeJSService service, Action configure)
+ {
+ if (source == null)
+ {
+ throw new ArgumentNullException(nameof(source));
+ }
+
+ if (service == null)
+ {
+ throw new ArgumentNullException(nameof(service));
+ }
+
+ if (configure == null)
+ {
+ throw new ArgumentNullException(nameof(configure));
+ }
+
+ var settings = new NodeSettings();
+ configure(settings);
+
+ source.Add(new NodeJsEngineFactory(service, settings));
+
+ return source;
+ }
+
+ ///
+ /// Adds a instance of to
+ /// the specified
+ ///
+ /// Instance of
+ /// Node JS service
+ /// Settings of the Node JS engine
+ /// Instance of
+ public static JsEngineFactoryCollection AddNode(this JsEngineFactoryCollection source,
+ INodeJSService service, NodeSettings settings)
+ {
+ if (source == null)
+ {
+ throw new ArgumentNullException(nameof(source));
+ }
+
+ if (service == null)
+ {
+ throw new ArgumentNullException(nameof(service));
+ }
+
+ if (settings == null)
+ {
+ throw new ArgumentNullException(nameof(settings));
+ }
+
+ source.Add(new NodeJsEngineFactory(service, settings));
+
+ return source;
+ }
+
+ ///
+ /// Adds a instance of to
+ /// the specified
+ ///
+ /// Instance of
+ /// The services available in the application
+ /// The delegate to configure the provided
+ /// Instance of
+ public static JsEngineFactoryCollection AddNode(this JsEngineFactoryCollection source,
+ IServiceCollection services, Action configure)
+ {
+ if (source == null)
+ {
+ throw new ArgumentNullException(nameof(source));
+ }
+
+ if (services == null)
+ {
+ throw new ArgumentNullException(nameof(services));
+ }
+
+ if (configure == null)
+ {
+ throw new ArgumentNullException(nameof(configure));
+ }
+
+ var settings = new NodeSettings();
+ configure(settings);
+
+ source.Add(new NodeJsEngineFactory(services, settings));
+
+ return source;
+ }
+
+ ///
+ /// Adds a instance of to
+ /// the specified
+ ///
+ /// Instance of
+ /// The services available in the application
+ /// Settings of the Node JS engine
+ /// Instance of
+ public static JsEngineFactoryCollection AddNode(this JsEngineFactoryCollection source,
+ IServiceCollection services, NodeSettings settings)
+ {
+ if (source == null)
+ {
+ throw new ArgumentNullException(nameof(source));
+ }
+
+ if (services == null)
+ {
+ throw new ArgumentNullException(nameof(services));
+ }
+
+ if (settings == null)
+ {
+ throw new ArgumentNullException(nameof(settings));
+ }
+
+ source.Add(new NodeJsEngineFactory(services, settings));
+
+ return source;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.Node/JsEngineIdGenerator.cs b/src/JavaScriptEngineSwitcher.Node/JsEngineIdGenerator.cs
new file mode 100644
index 00000000..3cb37a31
--- /dev/null
+++ b/src/JavaScriptEngineSwitcher.Node/JsEngineIdGenerator.cs
@@ -0,0 +1,44 @@
+using System;
+using System.Threading;
+
+namespace JavaScriptEngineSwitcher.Node
+{
+ internal static class JsEngineIdGenerator
+ {
+ // Base32 encoding - in ascii sort order for easy text based sorting
+ private static readonly char[] _encode32Chars = "0123456789ABCDEFGHIJKLMNOPQRSTUV".ToCharArray();
+
+ // Seed the `_lastId` for this application instance with
+ // the number of 100-nanosecond intervals that have elapsed since 12:00:00 midnight, January 1, 0001
+ // for a roughly increasing `_lastId` over restarts
+ private static long _lastId = DateTime.UtcNow.Ticks;
+
+
+ public static string GetNextId() => GenerateId(Interlocked.Increment(ref _lastId));
+
+ private static unsafe string GenerateId(long id)
+ {
+ char[] encode32Chars = _encode32Chars;
+
+ // stackalloc to allocate array on stack rather than heap
+ char* buffer = stackalloc char[13];
+
+ buffer[12] = encode32Chars[id & 31];
+ buffer[11] = encode32Chars[(id >> 5) & 31];
+ buffer[10] = encode32Chars[(id >> 10) & 31];
+ buffer[9] = encode32Chars[(id >> 15) & 31];
+ buffer[8] = encode32Chars[(id >> 20) & 31];
+ buffer[7] = encode32Chars[(id >> 25) & 31];
+ buffer[6] = encode32Chars[(id >> 30) & 31];
+ buffer[5] = encode32Chars[(id >> 35) & 31];
+ buffer[4] = encode32Chars[(id >> 40) & 31];
+ buffer[3] = encode32Chars[(id >> 45) & 31];
+ buffer[2] = encode32Chars[(id >> 50) & 31];
+ buffer[1] = encode32Chars[(id >> 55) & 31];
+ buffer[0] = encode32Chars[(id >> 60) & 31];
+
+ // string `ctor` overload that takes `char*`
+ return new string(buffer, 0, 13);
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.Node/NodeJsEngine.cs b/src/JavaScriptEngineSwitcher.Node/NodeJsEngine.cs
new file mode 100644
index 00000000..b3c0b8ea
--- /dev/null
+++ b/src/JavaScriptEngineSwitcher.Node/NodeJsEngine.cs
@@ -0,0 +1,560 @@
+using System;
+using System.IO;
+using System.Linq;
+using System.Reflection;
+using System.Text.RegularExpressions;
+using System.Threading.Tasks;
+
+using Jering.Javascript.NodeJS;
+
+using JavaScriptEngineSwitcher.Core;
+using JavaScriptEngineSwitcher.Core.Constants;
+using JavaScriptEngineSwitcher.Core.Helpers;
+using JavaScriptEngineSwitcher.Core.Utilities;
+
+using CoreStrings = JavaScriptEngineSwitcher.Core.Resources.Strings;
+using WrapperCompilationException = JavaScriptEngineSwitcher.Core.JsCompilationException;
+using WrapperException = JavaScriptEngineSwitcher.Core.JsException;
+using WrapperRuntimeException = JavaScriptEngineSwitcher.Core.JsRuntimeException;
+using WrapperScriptException = JavaScriptEngineSwitcher.Core.JsScriptException;
+using WrapperTimeoutException = JavaScriptEngineSwitcher.Core.JsTimeoutException;
+using WrapperUsageException = JavaScriptEngineSwitcher.Core.JsUsageException;
+
+using JavaScriptEngineSwitcher.Node.Helpers;
+
+namespace JavaScriptEngineSwitcher.Node
+{
+ ///
+ /// Adapter for the Node JS engine
+ ///
+ public sealed class NodeJsEngine : JsEngineBase
+ {
+ ///
+ /// Name of resource, which contains a JS engine helpers
+ ///
+ private const string ENGINE_HELPERS_RESOURCE_NAME = "JavaScriptEngineSwitcher.Node.Resources.engine-helpers.js";
+
+ ///
+ /// Name of JS engine
+ ///
+ public const string EngineName = "NodeJsEngine";
+
+ ///
+ /// Node JS service
+ ///
+ private INodeJSService _jsService;
+
+ ///
+ /// Version of original JS engine
+ ///
+ private string _engineVersion = "0.0.0";
+
+ ///
+ /// JS engine identifier
+ ///
+ private string _engineId;
+
+ ///
+ /// Number of milliseconds to wait before the script execution times out
+ ///
+ private int _executionTimeout = -1;
+
+ ///
+ /// Unique document name manager
+ ///
+ private UniqueDocumentNameManager _documentNameManager = new UniqueDocumentNameManager(DefaultDocumentName);
+
+ ///
+ /// Regular expression for working with the timeout error message
+ ///
+ private static readonly Regex _timeoutErrorMessage = new Regex(@"^(?:Script execution|The Node invocation) " +
+ @"timed out after \d+ms");
+
+ ///
+ /// Regular expression for working with the error details
+ ///
+ private static readonly Regex _errorDetailsRegex = new Regex(@"^(?[^\r\n]+)(?:\r\n|\n|\r)" +
+ @"(?:" +
+ @"(?" + CommonRegExps.DocumentNamePattern + @")?:(?\d+)(?:\r\n|\n|\r)" +
+ @"(?[^\r\n]+)(?:\r\n|\n|\r)" +
+ @"(?[ \t]*\^)(?:\r\n|\n|\r){2}" +
+ @")?");
+
+ ///
+ /// Regular expression for working with the error message with type
+ ///
+ private static readonly Regex _errorMessageWithTypeRegex =
+ new Regex(@"^(?" + CommonRegExps.JsFullNamePattern + @"): (?[^\r\n]+)");
+
+
+ ///
+ /// Constructs an instance of adapter for the Node JS engine
+ ///
+ public NodeJsEngine()
+ : this(DefaultNodeJsService.Instance, new NodeSettings())
+ { }
+
+ ///
+ /// Constructs an instance of adapter for the Node JS engine
+ ///
+ /// Node JS service
+ public NodeJsEngine(INodeJSService nodeJsService)
+ : this(nodeJsService, new NodeSettings())
+ { }
+
+ ///
+ /// Constructs an instance of adapter for the Node JS engine
+ ///
+ /// Settings of the Node JS engine
+ public NodeJsEngine(NodeSettings settings)
+ : this(DefaultNodeJsService.Instance, settings)
+ { }
+
+ ///
+ /// Constructs an instance of adapter for the Node JS engine
+ ///
+ /// Node JS service
+ /// Settings of the Node JS engine
+ public NodeJsEngine(INodeJSService service, NodeSettings settings)
+ {
+ if (service == null)
+ {
+ throw new ArgumentNullException(nameof(service));
+ }
+
+ _jsService = service;
+
+ try
+ {
+ Task versionTask = _jsService.InvokeFromStringAsync(
+ @"module.exports = (callback) => {
+ let version = process.versions.node;
+ callback(null , version);
+};"
+ );
+ _engineVersion = versionTask.ConfigureAwait(false).GetAwaiter().GetResult();
+ }
+ catch (Exception e)
+ {
+ throw JsErrorHelpers.WrapEngineLoadException(e, EngineName, _engineVersion, true);
+ }
+
+ NodeSettings nodeSettings = settings ?? new NodeSettings();
+ _executionTimeout = (int)nodeSettings.TimeoutInterval.TotalMilliseconds;
+ _engineId = JsEngineIdGenerator.GetNextId();
+
+ InvokeEngineHelper("addContext", new object[] { _engineId, nodeSettings.UseBuiltinLibrary });
+ }
+
+
+ private void InvokeEngineHelper(string exportName = null, object[] args = null)
+ {
+ Task cachedTask = _jsService.TryInvokeFromCacheAsync(ENGINE_HELPERS_RESOURCE_NAME,
+ exportName, args);
+ bool success = cachedTask.ConfigureAwait(false).GetAwaiter().GetResult();
+
+ if (!success)
+ {
+ Type type = typeof(NodeJsEngine);
+ Assembly assembly = type.Assembly;
+
+ using (Stream resourceStream = assembly.GetManifestResourceStream(ENGINE_HELPERS_RESOURCE_NAME))
+ {
+ Task task = _jsService.InvokeFromStreamAsync(resourceStream, ENGINE_HELPERS_RESOURCE_NAME,
+ exportName, args);
+ task.ConfigureAwait(false).GetAwaiter().GetResult();
+ }
+ }
+ }
+
+ private T InvokeEngineHelper(string exportName = null, object[] args = null)
+ {
+ Task<(bool, T)> cachedTask = _jsService.TryInvokeFromCacheAsync(ENGINE_HELPERS_RESOURCE_NAME,
+ exportName, args);
+ (bool success, T result) = cachedTask.ConfigureAwait(false).GetAwaiter().GetResult();
+
+ if (success)
+ {
+ return result;
+ }
+ else
+ {
+ Type type = typeof(NodeJsEngine);
+ Assembly assembly = type.Assembly;
+
+ using (Stream resourceStream = assembly.GetManifestResourceStream(ENGINE_HELPERS_RESOURCE_NAME))
+ {
+ Task task = _jsService.InvokeFromStreamAsync(resourceStream, ENGINE_HELPERS_RESOURCE_NAME,
+ exportName, args);
+
+ return task.ConfigureAwait(false).GetAwaiter().GetResult();
+ }
+ }
+ }
+
+ #region Mapping
+
+ ///
+ /// Makes a mapping of value from the host type to a script type
+ ///
+ /// The source value
+ /// The mapped value
+ private static object MapToScriptType(object value)
+ {
+ if (value is Undefined)
+ {
+ return null;
+ }
+
+ return value;
+ }
+
+ ///
+ /// Makes a mapping of array items from the host type to a script type
+ ///
+ /// The source array
+ /// The mapped array
+ public static object[] MapToScriptType(object[] args)
+ {
+ return args.Select(arg => MapToScriptType(arg)).ToArray();
+ }
+
+ #region Mapping
+
+ private WrapperException WrapInvocationException(InvocationException originalException)
+ {
+ WrapperException wrapperException;
+ string message = originalException.Message;
+ string description = string.Empty;
+
+ if (_timeoutErrorMessage.IsMatch(message))
+ {
+ message = CoreStrings.Runtime_ScriptTimeoutExceeded;
+ description = message;
+
+ var wrapperTimeoutException = new WrapperTimeoutException(message, EngineName, _engineVersion,
+ originalException)
+ {
+ Description = description
+ };
+
+ return wrapperTimeoutException;
+ }
+
+ string documentName = string.Empty;
+ int lineNumber = 0;
+ int columnNumber = 0;
+ string sourceLine = string.Empty;
+
+ Match detailsMatch = _errorDetailsRegex.Match(message);
+ int detailsLength = 0;
+
+ if (detailsMatch.Success)
+ {
+ GroupCollection detailsGroups = detailsMatch.Groups;
+ description = detailsGroups["description"].Value;
+ documentName = detailsGroups["documentName"].Success ?
+ detailsGroups["documentName"].Value : string.Empty;
+ lineNumber = detailsGroups["lineNumber"].Success ?
+ int.Parse(detailsGroups["lineNumber"].Value) : 0;
+ columnNumber = NodeJsErrorHelpers.GetColumnCountFromLine(detailsGroups["pointer"].Value);
+ sourceLine = detailsGroups["sourceLine"].Value;
+
+ detailsLength = detailsMatch.Length;
+ }
+
+ message = detailsLength > 0 ? message.Substring(detailsLength) : message;
+
+ Match messageWithTypeMatch = _errorMessageWithTypeRegex.Match(message);
+ if (messageWithTypeMatch.Success)
+ {
+ GroupCollection messageWithTypeGroups = messageWithTypeMatch.Groups;
+ string type = messageWithTypeGroups["type"].Value;
+ description = messageWithTypeGroups["description"].Value;
+ string sourceFragment = TextHelpers.GetTextFragmentFromLine(sourceLine, columnNumber);
+
+ WrapperScriptException wrapperScriptException;
+ if (type == JsErrorType.Syntax)
+ {
+ message = JsErrorHelpers.GenerateScriptErrorMessage(type, description, documentName,
+ lineNumber, columnNumber, sourceFragment);
+
+ wrapperScriptException = new WrapperCompilationException(message, EngineName, _engineVersion,
+ originalException);
+ }
+ else if (type == "UsageError")
+ {
+ wrapperException = new WrapperUsageException(description, EngineName, _engineVersion,
+ originalException);
+ wrapperException.Description = description;
+
+ return wrapperException;
+ }
+ else
+ {
+ var errorLocationItems = new ErrorLocationItem[0];
+ int messageLength = message.Length;
+ int messageWithTypeLength = messageWithTypeMatch.Length;
+
+ if (messageWithTypeLength < messageLength)
+ {
+ string errorLocation = message.Substring(messageWithTypeLength);
+ errorLocationItems = NodeJsErrorHelpers.ParseErrorLocation(errorLocation);
+ errorLocationItems = NodeJsErrorHelpers.FilterErrorLocationItems(errorLocationItems);
+
+ if (errorLocationItems.Length > 0)
+ {
+ ErrorLocationItem firstErrorLocationItem = errorLocationItems[0];
+ documentName = firstErrorLocationItem.DocumentName;
+ lineNumber = firstErrorLocationItem.LineNumber;
+ columnNumber = firstErrorLocationItem.ColumnNumber;
+
+ firstErrorLocationItem.SourceFragment = sourceFragment;
+ }
+ }
+
+ string callStack = JsErrorHelpers.StringifyErrorLocationItems(errorLocationItems, true);
+ string callStackWithSourceFragment = JsErrorHelpers.StringifyErrorLocationItems(
+ errorLocationItems);
+ message = JsErrorHelpers.GenerateScriptErrorMessage(type, description,
+ callStackWithSourceFragment);
+
+ wrapperScriptException = new WrapperRuntimeException(message, EngineName, _engineVersion,
+ originalException)
+ {
+ CallStack = callStack
+ };
+ }
+
+ wrapperScriptException.Type = type;
+ wrapperScriptException.DocumentName = documentName;
+ wrapperScriptException.LineNumber = lineNumber;
+ wrapperScriptException.ColumnNumber = columnNumber;
+ wrapperScriptException.SourceFragment = sourceFragment;
+
+ wrapperException = wrapperScriptException;
+ }
+ else
+ {
+ wrapperException = new WrapperException(message, EngineName, _engineVersion,
+ originalException);
+ }
+
+ wrapperException.Description = description;
+
+ return wrapperException;
+ }
+
+ #endregion
+
+ #endregion
+
+ #region JsEngineBase overrides
+
+ protected override IPrecompiledScript InnerPrecompile(string code)
+ {
+ throw new NotSupportedException();
+ }
+
+ protected override IPrecompiledScript InnerPrecompile(string code, string documentName)
+ {
+ throw new NotSupportedException();
+ }
+
+ protected override object InnerEvaluate(string expression)
+ {
+ throw new NotSupportedException();
+ }
+
+ protected override object InnerEvaluate(string expression, string documentName)
+ {
+ throw new NotSupportedException();
+ }
+
+ protected override T InnerEvaluate(string expression)
+ {
+ return InnerEvaluate(expression, null);
+ }
+
+ protected override T InnerEvaluate(string expression, string documentName)
+ {
+ string uniqueDocumentName = _documentNameManager.GetUniqueName(documentName);
+ T result;
+
+ try
+ {
+ result = InvokeEngineHelper("evaluate", new object[] { _engineId, expression, uniqueDocumentName,
+ _executionTimeout });
+ }
+ catch (InvocationException e)
+ {
+ throw WrapInvocationException(e);
+ }
+
+ return result;
+ }
+
+ protected override void InnerExecute(string code)
+ {
+ InnerExecute(code, null);
+ }
+
+ protected override void InnerExecute(string code, string documentName)
+ {
+ string uniqueDocumentName = _documentNameManager.GetUniqueName(documentName);
+
+ try
+ {
+ InvokeEngineHelper("execute", new object[] { _engineId, code, uniqueDocumentName, _executionTimeout });
+ }
+ catch (InvocationException e)
+ {
+ throw WrapInvocationException(e);
+ }
+ }
+
+ protected override void InnerExecute(IPrecompiledScript precompiledScript)
+ {
+ throw new NotSupportedException();
+ }
+
+ protected override object InnerCallFunction(string functionName, params object[] args)
+ {
+ throw new NotSupportedException();
+ }
+
+ protected override T InnerCallFunction(string functionName, params object[] args)
+ {
+ T result;
+ object[] processedArgs = MapToScriptType(args);
+
+ try
+ {
+ result = InvokeEngineHelper("callFunction", new object[] { _engineId, functionName, processedArgs,
+ _executionTimeout });
+ }
+ catch (InvocationException e)
+ {
+ throw WrapInvocationException(e);
+ }
+
+ return result;
+ }
+
+ protected override bool InnerHasVariable(string variableName)
+ {
+ return InvokeEngineHelper("hasVariable", new [] { _engineId, variableName });
+ }
+
+ protected override object InnerGetVariableValue(string variableName)
+ {
+ throw new NotSupportedException();
+ }
+
+ protected override T InnerGetVariableValue(string variableName)
+ {
+ T result;
+
+ try
+ {
+ result = InvokeEngineHelper("getVariableValue", new[] { _engineId, variableName });
+ }
+ catch (InvocationException e)
+ {
+ throw WrapInvocationException(e);
+ }
+
+ return result;
+ }
+
+ protected override void InnerSetVariableValue(string variableName, object value)
+ {
+ object processedValue = MapToScriptType(value);
+
+ try
+ {
+ InvokeEngineHelper("setVariableValue", new[] { _engineId, variableName, processedValue });
+ }
+ catch (InvocationException e)
+ {
+ throw WrapInvocationException(e);
+ }
+ }
+
+ protected override void InnerRemoveVariable(string variableName)
+ {
+ try
+ {
+ InvokeEngineHelper("removeVariable", new[] { _engineId, variableName });
+ }
+ catch (InvocationException e)
+ {
+ throw WrapInvocationException(e);
+ }
+ }
+
+ protected override void InnerEmbedHostObject(string itemName, object value)
+ {
+ throw new NotSupportedException();
+ }
+
+ protected override void InnerEmbedHostType(string itemName, Type type)
+ {
+ throw new NotSupportedException();
+ }
+
+ protected override void InnerInterrupt()
+ {
+ throw new NotSupportedException();
+ }
+
+ protected override void InnerCollectGarbage()
+ {
+ throw new NotSupportedException();
+ }
+
+ #region IJsEngine implementation
+
+ public override string Name
+ {
+ get { return EngineName; }
+ }
+
+ public override string Version
+ {
+ get { return _engineVersion; }
+ }
+
+ public override bool SupportsScriptPrecompilation
+ {
+ get { return false; }
+ }
+
+ public override bool SupportsScriptInterruption
+ {
+ get { return false; }
+ }
+
+ public override bool SupportsGarbageCollection
+ {
+ get { return false; }
+ }
+
+ #endregion
+
+ #region IDisposable implementation
+
+ public override void Dispose()
+ {
+ if (_disposedFlag.Set())
+ {
+ InvokeEngineHelper("removeContext", new[] { _engineId });
+ _jsService = null;
+ }
+ }
+
+ #endregion
+
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.Node/NodeJsEngineFactory.cs b/src/JavaScriptEngineSwitcher.Node/NodeJsEngineFactory.cs
new file mode 100644
index 00000000..b805872a
--- /dev/null
+++ b/src/JavaScriptEngineSwitcher.Node/NodeJsEngineFactory.cs
@@ -0,0 +1,124 @@
+using Jering.Javascript.NodeJS;
+using Microsoft.Extensions.DependencyInjection;
+
+using JavaScriptEngineSwitcher.Core;
+
+namespace JavaScriptEngineSwitcher.Node
+{
+ ///
+ /// Node JS engine factory
+ ///
+ public sealed class NodeJsEngineFactory : IJsEngineFactory
+ {
+ ///
+ /// The services available in the application
+ ///
+ private IServiceCollection _services;
+
+ ///
+ /// Node JS service
+ ///
+ private INodeJSService _jsService;
+
+ ///
+ /// Settings of the Node JS engine
+ ///
+ private readonly NodeSettings _settings;
+
+ ///
+ /// Synchronizer of Node JS service creation
+ ///
+ private readonly object _creationSynchronizer = new object();
+
+
+ ///
+ /// Constructs an instance of the Node JS engine factory
+ ///
+ public NodeJsEngineFactory()
+ : this(new NodeSettings())
+ { }
+
+ ///
+ /// Constructs an instance of the Node JS engine factory
+ ///
+ /// Node JS service
+ public NodeJsEngineFactory(INodeJSService service)
+ : this(service, new NodeSettings())
+ { }
+
+ ///
+ /// Constructs an instance of the Node JS engine factory
+ ///
+ /// The services available in the application
+ public NodeJsEngineFactory(IServiceCollection services)
+ : this(services, new NodeSettings())
+ { }
+
+ ///
+ /// Constructs an instance of the Node JS engine factory
+ ///
+ /// Settings of the Node JS engine
+ public NodeJsEngineFactory(NodeSettings settings)
+ {
+ _settings = settings;
+ }
+
+ ///
+ /// Constructs an instance of the Node JS engine factory
+ ///
+ /// Node JS service
+ /// Settings of the Node JS engine
+ public NodeJsEngineFactory(INodeJSService service, NodeSettings settings)
+ {
+ _jsService = service;
+ _settings = settings;
+ }
+
+ ///
+ /// Constructs an instance of the Node JS engine factory
+ ///
+ /// The services available in the application
+ /// Settings of the Node JS engine
+ public NodeJsEngineFactory(IServiceCollection services, NodeSettings settings)
+ {
+ _services = services;
+ _settings = settings;
+ }
+
+
+ #region IJsEngineFactory implementation
+
+ ///
+ public string EngineName
+ {
+ get { return NodeJsEngine.EngineName; }
+ }
+
+
+ ///
+ /// Creates a instance of the Node JS engine
+ ///
+ /// Instance of the Node JS engine
+ public IJsEngine CreateEngine()
+ {
+ if (_services != null && _jsService == null)
+ {
+ lock (_creationSynchronizer)
+ {
+ if (_jsService == null)
+ {
+ ServiceProvider serviceProvider = _services.BuildServiceProvider();
+ _jsService = serviceProvider.GetRequiredService();
+ }
+ }
+ }
+
+ IJsEngine engine = _jsService != null ?
+ new NodeJsEngine(_jsService, _settings) : new NodeJsEngine(_settings);
+
+ return engine;
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.Node/NodeSettings.cs b/src/JavaScriptEngineSwitcher.Node/NodeSettings.cs
new file mode 100644
index 00000000..271936fb
--- /dev/null
+++ b/src/JavaScriptEngineSwitcher.Node/NodeSettings.cs
@@ -0,0 +1,38 @@
+using System;
+
+namespace JavaScriptEngineSwitcher.Node
+{
+ ///
+ /// Settings of the Node JS engine
+ ///
+ public sealed class NodeSettings
+ {
+ ///
+ /// Gets or sets a interval to wait before the script execution times out
+ ///
+ public TimeSpan TimeoutInterval
+ {
+ get;
+ set;
+ }
+
+ ///
+ /// Gets or sets a flag for whether to use the Node.js built-in library
+ ///
+ public bool UseBuiltinLibrary
+ {
+ get;
+ set;
+ }
+
+
+ ///
+ /// Constructs an instance of the Node settings
+ ///
+ public NodeSettings()
+ {
+ TimeoutInterval = TimeSpan.Zero;
+ UseBuiltinLibrary = false;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.Node/PACKAGE-DESCRIPTION.md b/src/JavaScriptEngineSwitcher.Node/PACKAGE-DESCRIPTION.md
new file mode 100644
index 00000000..76c940f9
--- /dev/null
+++ b/src/JavaScriptEngineSwitcher.Node/PACKAGE-DESCRIPTION.md
@@ -0,0 +1,4 @@
+JavaScriptEngineSwitcher.Node contains a `NodeJsEngine` adapter (wrapper for the [Jering.Javascript.NodeJS](https://github.com/JeringTech/Javascript.NodeJS) version 7.0.0).
+
+This package does not contain the `node.exe`.
+Therefore, you need to install the [Node.js](https://nodejs.org) and add the `node.exe`'s directory to the `Path` environment variable (automatically done by the official installer).
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.Node/Resources/engine-helpers.js b/src/JavaScriptEngineSwitcher.Node/Resources/engine-helpers.js
new file mode 100644
index 00000000..d0c10831
--- /dev/null
+++ b/src/JavaScriptEngineSwitcher.Node/Resources/engine-helpers.js
@@ -0,0 +1,144 @@
+/*jshint esversion: 6*/
+/*globals global, module, require*/
+const GENERATED_FUNCTION_CALL_FILE_NAME = "JavaScriptEngineSwitcher.Node.Resources.generated-function-call.js";
+let vm = require('vm');
+let contexts = new Map();
+
+class UsageError extends Error {
+ constructor(...args) {
+ super(...args);
+ this.name = 'UsageError';
+
+ Error.captureStackTrace(this, UsageError);
+ }
+}
+
+function getContext(engineId) {
+ if (!contexts.has(engineId)) {
+ throw new UsageError("JavaScriptEngineSwitcher.Node module cannot work correctly " +
+ "when the Node JS service is configured to work in the multi-process mode of " +
+ "Jering.Javascript.NodeJS library (https://github.com/JeringTech/Javascript.NodeJS#enabling-multi-process-concurrency), " +
+ "because in this mode it is not possible to store a state of JS engine."
+ );
+ }
+
+ return contexts.get(engineId);
+}
+
+module.exports = {
+ addContext: (callback, engineId, useBuiltinLibrary) => {
+ let sandbox;
+ if (useBuiltinLibrary) {
+ sandbox = Object.create(global);
+ if (typeof sandbox['require'] === 'undefined') {
+ sandbox['require'] = require;
+ }
+ }
+ else {
+ sandbox = Object.create(null);
+ }
+
+ let context = vm.createContext(sandbox);
+ contexts.set(engineId, context);
+
+ callback(null);
+ },
+
+ removeContext: (callback, engineId) => {
+ contexts.delete(engineId);
+ callback(null);
+ },
+
+ evaluate: (callback, engineId, expression, documentName, timeout) => {
+ let context = getContext(engineId);
+ let options = { filename: documentName };
+ if (timeout > 0) {
+ options.timeout = timeout;
+ }
+ let result = vm.runInContext(expression, context, options);
+
+ callback(null, result);
+ },
+
+ execute: (callback, engineId, code, documentName, timeout) => {
+ let context = getContext(engineId);
+ let options = { filename: documentName };
+ if (timeout > 0) {
+ options.timeout = timeout;
+ }
+
+ vm.runInContext(code, context, options);
+
+ callback(null);
+ },
+
+ callFunction: (callback, engineId, functionName, args, timeout) => {
+ let context = getContext(engineId);
+ let result;
+
+ if (timeout <= 0) {
+ let functionValue = context[functionName];
+ result = functionValue.apply(null, args);
+ }
+ else {
+ let options = {
+ filename: GENERATED_FUNCTION_CALL_FILE_NAME,
+ timeout: timeout
+ };
+ let argCount = args.length;
+ let expression;
+
+ if (argCount > 0) {
+ expression = functionName;
+ expression += '(';
+
+ for (let argIndex = 0; argIndex < argCount; argIndex++) {
+ if (argIndex > 0) {
+ expression += ', ';
+ }
+
+ expression += JSON.stringify(args[argIndex]);
+ }
+
+ expression += ');';
+ }
+ else {
+ expression = `${functionName}();`;
+ }
+
+ result = vm.runInContext(expression, context, options);
+ }
+
+ callback(null, result);
+ },
+
+ hasVariable: (callback, engineId, variableName) => {
+ let context = getContext(engineId);
+ let result = typeof context[variableName] !== 'undefined';
+
+ callback(null, result);
+ },
+
+ getVariableValue: (callback, engineId, variableName) => {
+ let context = getContext(engineId);
+ let result = context[variableName];
+
+ callback(null, result);
+ },
+
+ setVariableValue: (callback, engineId, variableName, value) => {
+ let context = getContext(engineId);
+ context[variableName] = value;
+
+ callback(null);
+ },
+
+ removeVariable: (callback, engineId, variableName) => {
+ let context = getContext(engineId);
+ if (typeof context[variableName] !== 'undefined') {
+ delete context[variableName];
+ }
+
+ callback(null);
+ }
+};
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.Node/readme.txt b/src/JavaScriptEngineSwitcher.Node/readme.txt
new file mode 100644
index 00000000..4f89b068
--- /dev/null
+++ b/src/JavaScriptEngineSwitcher.Node/readme.txt
@@ -0,0 +1,26 @@
+
+
+ --------------------------------------------------------------------------------
+ README file for JS Engine Switcher: Node v3.24.1
+
+ --------------------------------------------------------------------------------
+
+ Copyright (c) 2013-2024 Andrey Taritsyn - http://www.taritsyn.ru
+
+
+ ===========
+ DESCRIPTION
+ ===========
+ JavaScriptEngineSwitcher.Node contains a `NodeJsEngine` adapter (wrapper for the
+ Jering.Javascript.NodeJS (https://github.com/JeringTech/Javascript.NodeJS)
+ version 7.0.0).
+
+ This package does not contain the `node.exe`. Therefore, you need to install the
+ Node.js (https://nodejs.org) and add the `node.exe`'s directory to the `Path`
+ environment variable (automatically done by the official installer).
+
+ =============
+ DOCUMENTATION
+ =============
+ See documentation on GitHub -
+ http://github.com/Taritsyn/JavaScriptEngineSwitcher
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.V8.Native.linux-x64/JavaScriptEngineSwitcher.V8.Native.linux-x64.csproj b/src/JavaScriptEngineSwitcher.V8.Native.linux-x64/JavaScriptEngineSwitcher.V8.Native.linux-x64.csproj
new file mode 100644
index 00000000..e761c1b1
--- /dev/null
+++ b/src/JavaScriptEngineSwitcher.V8.Native.linux-x64/JavaScriptEngineSwitcher.V8.Native.linux-x64.csproj
@@ -0,0 +1,21 @@
+
+
+
+ JS Engine Switcher: V8 for Linux (x64)
+ 3.29.0
+ netstandard2.0
+
+
+
+
+
+
+
+ https://raw.githubusercontent.com/Taritsyn/JavaScriptEngineSwitcher/master/Icons/JavaScriptEngineSwitcher_V8_Logo128x128.png
+ ../../Icons/JavaScriptEngineSwitcher_V8_Logo128x128.png
+ This package is deprecated. Instead, it is recommended to use a Microsoft.ClearScript.V8.Native.linux-x64 package.
+ $(PackageCommonTags);V8;ClearScript;Linux;x64
+ Microsoft ClearScript.V8 was updated to version 7.5 (support of the V8 version 13.3.415.23).
+
+
+
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.V8.Native.linux-x64/JavaScriptEngineSwitcher.V8.Native.linux-x64.nuspec b/src/JavaScriptEngineSwitcher.V8.Native.linux-x64/JavaScriptEngineSwitcher.V8.Native.linux-x64.nuspec
new file mode 100644
index 00000000..bf4bfdc0
--- /dev/null
+++ b/src/JavaScriptEngineSwitcher.V8.Native.linux-x64/JavaScriptEngineSwitcher.V8.Native.linux-x64.nuspec
@@ -0,0 +1,14 @@
+
+
+
+ $CommonMetadataElements$
+
+
+
+
+
+ $CommonFileElements$
+
+
+
+
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.V8.Native.linux-x64/PACKAGE-DESCRIPTION.md b/src/JavaScriptEngineSwitcher.V8.Native.linux-x64/PACKAGE-DESCRIPTION.md
new file mode 100644
index 00000000..3bb23eb4
--- /dev/null
+++ b/src/JavaScriptEngineSwitcher.V8.Native.linux-x64/PACKAGE-DESCRIPTION.md
@@ -0,0 +1,2 @@
+This package is deprecated.
+Instead, it is recommended to use a [Microsoft.ClearScript.V8.Native.linux-x64](https://www.nuget.org/packages/Microsoft.ClearScript.V8.Native.linux-x64) package.
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.ChakraCore.Native.debian-x64/readme.txt b/src/JavaScriptEngineSwitcher.V8.Native.linux-x64/readme.txt
similarity index 62%
rename from src/JavaScriptEngineSwitcher.ChakraCore.Native.debian-x64/readme.txt
rename to src/JavaScriptEngineSwitcher.V8.Native.linux-x64/readme.txt
index 2e27358f..9859dd74 100644
--- a/src/JavaScriptEngineSwitcher.ChakraCore.Native.debian-x64/readme.txt
+++ b/src/JavaScriptEngineSwitcher.V8.Native.linux-x64/readme.txt
@@ -1,23 +1,24 @@
--------------------------------------------------------------------------------
- README file for JS Engine Switcher: ChakraCore for Debian x64 v3.0.0
+ README file for JS Engine Switcher: V8 for Linux x64 v3.29.0
--------------------------------------------------------------------------------
- Copyright (c) 2013-2018 Andrey Taritsyn - http://www.taritsyn.ru
+ Copyright (c) 2013-2025 Andrey Taritsyn - http://www.taritsyn.ru
===========
DESCRIPTION
===========
This package is deprecated. Instead, it is recommended to use a
- 'JavaScriptEngineSwitcher.ChakraCore.Native.linux-x64' package.
+ Microsoft.ClearScript.V8.Native.linux-x64 package.
=============
RELEASE NOTES
=============
- ChakraCore was updated to version 1.11.4.
+ Microsoft ClearScript.V8 was updated to version 7.5 (support of the V8
+ version 13.3.415.23).
=============
DOCUMENTATION
diff --git a/src/JavaScriptEngineSwitcher.V8.Native.osx-x64/JavaScriptEngineSwitcher.V8.Native.osx-x64.csproj b/src/JavaScriptEngineSwitcher.V8.Native.osx-x64/JavaScriptEngineSwitcher.V8.Native.osx-x64.csproj
new file mode 100644
index 00000000..060da60d
--- /dev/null
+++ b/src/JavaScriptEngineSwitcher.V8.Native.osx-x64/JavaScriptEngineSwitcher.V8.Native.osx-x64.csproj
@@ -0,0 +1,21 @@
+
+
+
+ JS Engine Switcher: V8 for OS X (x64)
+ 3.29.0
+ netstandard2.0
+
+
+
+
+
+
+
+ https://raw.githubusercontent.com/Taritsyn/JavaScriptEngineSwitcher/master/Icons/JavaScriptEngineSwitcher_V8_Logo128x128.png
+ ../../Icons/JavaScriptEngineSwitcher_V8_Logo128x128.png
+ This package is deprecated. Instead, it is recommended to use a Microsoft.ClearScript.V8.Native.osx-x64 package.
+ $(PackageCommonTags);V8;ClearScript;macOS;OSX;x64
+ Microsoft ClearScript.V8 was updated to version 7.5 (support of the V8 version 13.3.415.23).
+
+
+
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.V8.Native.osx-x64/JavaScriptEngineSwitcher.V8.Native.osx-x64.nuspec b/src/JavaScriptEngineSwitcher.V8.Native.osx-x64/JavaScriptEngineSwitcher.V8.Native.osx-x64.nuspec
new file mode 100644
index 00000000..10bede4f
--- /dev/null
+++ b/src/JavaScriptEngineSwitcher.V8.Native.osx-x64/JavaScriptEngineSwitcher.V8.Native.osx-x64.nuspec
@@ -0,0 +1,14 @@
+
+
+
+ $CommonMetadataElements$
+
+
+
+
+
+ $CommonFileElements$
+
+
+
+
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.V8.Native.osx-x64/PACKAGE-DESCRIPTION.md b/src/JavaScriptEngineSwitcher.V8.Native.osx-x64/PACKAGE-DESCRIPTION.md
new file mode 100644
index 00000000..2455eca2
--- /dev/null
+++ b/src/JavaScriptEngineSwitcher.V8.Native.osx-x64/PACKAGE-DESCRIPTION.md
@@ -0,0 +1,2 @@
+This package is deprecated.
+Instead, it is recommended to use a [Microsoft.ClearScript.V8.Native.osx-x64](https://www.nuget.org/packages/Microsoft.ClearScript.V8.Native.osx-x64) package.
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.ChakraCore.Native.win8-arm/readme.txt b/src/JavaScriptEngineSwitcher.V8.Native.osx-x64/readme.txt
similarity index 63%
rename from src/JavaScriptEngineSwitcher.ChakraCore.Native.win8-arm/readme.txt
rename to src/JavaScriptEngineSwitcher.V8.Native.osx-x64/readme.txt
index 6e01989e..da4e5d5a 100644
--- a/src/JavaScriptEngineSwitcher.ChakraCore.Native.win8-arm/readme.txt
+++ b/src/JavaScriptEngineSwitcher.V8.Native.osx-x64/readme.txt
@@ -1,23 +1,24 @@
--------------------------------------------------------------------------------
- README file for JS Engine Switcher: ChakraCore for Windows ARM v3.0.0
+ README file for JS Engine Switcher: V8 for OS X x64 v3.29.0
--------------------------------------------------------------------------------
- Copyright (c) 2013-2018 Andrey Taritsyn - http://www.taritsyn.ru
+ Copyright (c) 2013-2025 Andrey Taritsyn - http://www.taritsyn.ru
===========
DESCRIPTION
===========
This package is deprecated. Instead, it is recommended to use a
- 'JavaScriptEngineSwitcher.ChakraCore.Native.win-arm' package.
+ Microsoft.ClearScript.V8.Native.osx-x64 package.
=============
RELEASE NOTES
=============
- ChakraCore was updated to version 1.11.4.
+ Microsoft ClearScript.V8 was updated to version 7.5 (support of the V8
+ version 13.3.415.23).
=============
DOCUMENTATION
diff --git a/src/JavaScriptEngineSwitcher.V8.Native.win-x64/JavaScriptEngineSwitcher.V8.Native.win-x64.csproj b/src/JavaScriptEngineSwitcher.V8.Native.win-x64/JavaScriptEngineSwitcher.V8.Native.win-x64.csproj
index 7ca79d8d..848e4af8 100644
--- a/src/JavaScriptEngineSwitcher.V8.Native.win-x64/JavaScriptEngineSwitcher.V8.Native.win-x64.csproj
+++ b/src/JavaScriptEngineSwitcher.V8.Native.win-x64/JavaScriptEngineSwitcher.V8.Native.win-x64.csproj
@@ -1,11 +1,21 @@
-
- netstandard2.0
- false
- $(MSBuildProjectName).nuspec
-
+
+ JS Engine Switcher: V8 for Windows (x64)
+ 3.29.0
+ netstandard2.0
+
-
+
+
+
+
+
+ https://raw.githubusercontent.com/Taritsyn/JavaScriptEngineSwitcher/master/Icons/JavaScriptEngineSwitcher_V8_Logo128x128.png
+ ../../Icons/JavaScriptEngineSwitcher_V8_Logo128x128.png
+ This package is deprecated. Instead, it is recommended to use a Microsoft.ClearScript.V8.Native.win-x64 package.
+ $(PackageCommonTags);V8;ClearScript;Windows;x64
+ Microsoft ClearScript.V8 was updated to version 7.5 (support of the V8 version 13.3.415.23).
+
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.V8.Native.win-x64/JavaScriptEngineSwitcher.V8.Native.win-x64.nuspec b/src/JavaScriptEngineSwitcher.V8.Native.win-x64/JavaScriptEngineSwitcher.V8.Native.win-x64.nuspec
index 28438f61..7b52ae54 100644
--- a/src/JavaScriptEngineSwitcher.V8.Native.win-x64/JavaScriptEngineSwitcher.V8.Native.win-x64.nuspec
+++ b/src/JavaScriptEngineSwitcher.V8.Native.win-x64/JavaScriptEngineSwitcher.V8.Native.win-x64.nuspec
@@ -1,35 +1,14 @@
-
-
- JavaScriptEngineSwitcher.V8.Native.win-x64
- 3.0.0
- JS Engine Switcher: V8 for Windows (x64)
- Andrey Taritsyn
- Andrey Taritsyn
- LICENSE.txt
- https://github.com/Taritsyn/JavaScriptEngineSwitcher
- https://raw.githubusercontent.com/Taritsyn/JavaScriptEngineSwitcher/master/Icons/JavaScriptEngineSwitcher_V8_Logo128x128.png
-
- false
- This package complements the JavaScriptEngineSwitcher.V8 package and contains the native implementation of V8 version 7.0.276.42 for Windows (x64).
-
-For correct working of the Microsoft ClearScript.V8 require the Microsoft Visual C++ Redistributable for Visual Studio 2017.
- 1. Microsoft ClearScript.V8 was updated to version 5.5.4 (support of V8 version 7.0.276.42);
-2. Now the Microsoft ClearScript.V8 requires the Microsoft Visual C++ Redistributable for Visual Studio 2017.
- Copyright © 2013-2018 Andrey Taritsyn
- en-US
- JavaScriptEngineSwitcher JavaScript ECMAScript V8 ClearScript Windows x64
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+ $CommonMetadataElements$
+
+
+
+
+
+ $CommonFileElements$
+
+
+
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.V8.Native.win-x64/PACKAGE-DESCRIPTION.md b/src/JavaScriptEngineSwitcher.V8.Native.win-x64/PACKAGE-DESCRIPTION.md
new file mode 100644
index 00000000..2efc6700
--- /dev/null
+++ b/src/JavaScriptEngineSwitcher.V8.Native.win-x64/PACKAGE-DESCRIPTION.md
@@ -0,0 +1,2 @@
+This package is deprecated.
+Instead, it is recommended to use a [Microsoft.ClearScript.V8.Native.win-x64](https://www.nuget.org/packages/Microsoft.ClearScript.V8.Native.win-x64) package.
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.V8.Native.win-x64/build/JavaScriptEngineSwitcher.V8.Native.win-x64.props b/src/JavaScriptEngineSwitcher.V8.Native.win-x64/build/JavaScriptEngineSwitcher.V8.Native.win-x64.props
deleted file mode 100644
index 52f6fbb0..00000000
--- a/src/JavaScriptEngineSwitcher.V8.Native.win-x64/build/JavaScriptEngineSwitcher.V8.Native.win-x64.props
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
-
- x64\ClearScriptV8-64.dll
- PreserveNewest
- False
-
-
- x64\v8-base-x64.dll
- PreserveNewest
- False
-
-
- x64\v8-x64.dll
- PreserveNewest
- False
-
-
-
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.V8.Native.win-x64/readme.txt b/src/JavaScriptEngineSwitcher.V8.Native.win-x64/readme.txt
index eb05b4f3..408c9a2c 100644
--- a/src/JavaScriptEngineSwitcher.V8.Native.win-x64/readme.txt
+++ b/src/JavaScriptEngineSwitcher.V8.Native.win-x64/readme.txt
@@ -1,37 +1,24 @@
--------------------------------------------------------------------------------
- README file for JS Engine Switcher: V8 for Windows x64 v3.0.0
+ README file for JS Engine Switcher: V8 for Windows x64 v3.29.0
--------------------------------------------------------------------------------
- Copyright (c) 2013-2018 Andrey Taritsyn - http://www.taritsyn.ru
+ Copyright (c) 2013-2025 Andrey Taritsyn - http://www.taritsyn.ru
===========
DESCRIPTION
===========
- This package complements the JavaScriptEngineSwitcher.V8 package and contains
- the native implementation of V8 version 7.0.276.42 for Windows (x64).
-
- For correct working of the Microsoft ClearScript.V8 require the Microsoft Visual
- C++ Redistributable for Visual Studio 2017.
-
+ This package is deprecated. Instead, it is recommended to use a
+ Microsoft.ClearScript.V8.Native.win-x64 package.
=============
RELEASE NOTES
=============
- 1. Microsoft ClearScript.V8 was updated to version 5.5.4 (support of V8 version
- 7.0.276.42);
- 2. Now the Microsoft ClearScript.V8 requires the Microsoft Visual C++
- Redistributable for Visual Studio 2017.
-
- ====================
- POST-INSTALL ACTIONS
- ====================
- If in your system does not `msvcp140.dll` assembly, then download and install
- the Microsoft Visual C++ Redistributable for Visual Studio 2017
- (https://www.visualstudio.com/downloads/#microsoft-visual-c-redistributable-for-visual-studio-2017).
+ Microsoft ClearScript.V8 was updated to version 7.5 (support of the V8
+ version 13.3.415.23).
=============
DOCUMENTATION
diff --git a/src/JavaScriptEngineSwitcher.V8.Native.win-x64/tools/Install.ps1 b/src/JavaScriptEngineSwitcher.V8.Native.win-x64/tools/Install.ps1
deleted file mode 100644
index f7897244..00000000
--- a/src/JavaScriptEngineSwitcher.V8.Native.win-x64/tools/Install.ps1
+++ /dev/null
@@ -1,18 +0,0 @@
-param($installPath, $toolsPath, $package, $project)
-
-if ($project.Type -eq "Web Site") {
- $runtimesDirectoryPath = Join-Path $installPath "runtimes"
- $projectDirectoryPath = $project.Properties.Item("FullPath").Value
- $binDirectoryPath = Join-Path $projectDirectoryPath "bin"
- $assembly64FileNames = "ClearScriptV8-64.dll", "v8-base-x64.dll", "v8-x64.dll"
-
- $assembly64DestDirectoryPath = Join-Path $binDirectoryPath "x64"
- if (!(Test-Path $assembly64DestDirectoryPath)) {
- New-Item -ItemType Directory -Force -Path $assembly64DestDirectoryPath
- }
-
- foreach ($assembly64FileName in $assembly64FileNames) {
- $assembly64SourceFilePath = Join-Path $runtimesDirectoryPath ("win-x64/native/" + $assembly64FileName)
- Copy-Item $assembly64SourceFilePath $assembly64DestDirectoryPath -Force
- }
-}
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.V8.Native.win-x64/tools/Uninstall.ps1 b/src/JavaScriptEngineSwitcher.V8.Native.win-x64/tools/Uninstall.ps1
deleted file mode 100644
index 90a31f2a..00000000
--- a/src/JavaScriptEngineSwitcher.V8.Native.win-x64/tools/Uninstall.ps1
+++ /dev/null
@@ -1,16 +0,0 @@
-param($installPath, $toolsPath, $package, $project)
-
-if ($project.Type -eq "Web Site") {
- $projectDirectoryPath = $project.Properties.Item("FullPath").Value
- $binDirectoryPath = Join-Path $projectDirectoryPath "bin"
- $assembly64FileNames = "ClearScriptV8-64.dll", "v8-base-x64.dll", "v8-x64.dll"
-
- $assembly64DirectoryPath = Join-Path $binDirectoryPath "x64"
-
- foreach ($assembly64FileName in $assembly64FileNames) {
- $assembly64FilePath = Join-Path $assembly64DirectoryPath $assembly64FileName
- if (Test-Path $assembly64FilePath) {
- Remove-Item $assembly64FilePath -Force
- }
- }
-}
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.V8.Native.win-x86/JavaScriptEngineSwitcher.V8.Native.win-x86.csproj b/src/JavaScriptEngineSwitcher.V8.Native.win-x86/JavaScriptEngineSwitcher.V8.Native.win-x86.csproj
index 7ca79d8d..d4261f95 100644
--- a/src/JavaScriptEngineSwitcher.V8.Native.win-x86/JavaScriptEngineSwitcher.V8.Native.win-x86.csproj
+++ b/src/JavaScriptEngineSwitcher.V8.Native.win-x86/JavaScriptEngineSwitcher.V8.Native.win-x86.csproj
@@ -1,11 +1,21 @@
-
- netstandard2.0
- false
- $(MSBuildProjectName).nuspec
-
+
+ JS Engine Switcher: V8 for Windows (x86)
+ 3.29.0
+ netstandard2.0
+
-
+
+
+
+
+
+ https://raw.githubusercontent.com/Taritsyn/JavaScriptEngineSwitcher/master/Icons/JavaScriptEngineSwitcher_V8_Logo128x128.png
+ ../../Icons/JavaScriptEngineSwitcher_V8_Logo128x128.png
+ This package is deprecated. Instead, it is recommended to use a Microsoft.ClearScript.V8.Native.win-x86 package.
+ $(PackageCommonTags);V8;ClearScript;Windows;x86
+ Microsoft ClearScript.V8 was updated to version 7.5 (support of the V8 version 13.3.415.23).
+
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.V8.Native.win-x86/JavaScriptEngineSwitcher.V8.Native.win-x86.nuspec b/src/JavaScriptEngineSwitcher.V8.Native.win-x86/JavaScriptEngineSwitcher.V8.Native.win-x86.nuspec
index 0f55f63d..4c5670eb 100644
--- a/src/JavaScriptEngineSwitcher.V8.Native.win-x86/JavaScriptEngineSwitcher.V8.Native.win-x86.nuspec
+++ b/src/JavaScriptEngineSwitcher.V8.Native.win-x86/JavaScriptEngineSwitcher.V8.Native.win-x86.nuspec
@@ -1,35 +1,14 @@
-
-
- JavaScriptEngineSwitcher.V8.Native.win-x86
- 3.0.0
- JS Engine Switcher: V8 for Windows (x86)
- Andrey Taritsyn
- Andrey Taritsyn
- LICENSE.txt
- https://github.com/Taritsyn/JavaScriptEngineSwitcher
- https://raw.githubusercontent.com/Taritsyn/JavaScriptEngineSwitcher/master/Icons/JavaScriptEngineSwitcher_V8_Logo128x128.png
-
- false
- This package complements the JavaScriptEngineSwitcher.V8 package and contains the native implementation of V8 version 7.0.276.42 for Windows (x86).
-
-For correct working of the Microsoft ClearScript.V8 require the Microsoft Visual C++ Redistributable for Visual Studio 2017.
- 1. Microsoft ClearScript.V8 was updated to version 5.5.4 (support of V8 version 7.0.276.42);
-2. Now the Microsoft ClearScript.V8 requires the Microsoft Visual C++ Redistributable for Visual Studio 2017.
- Copyright © 2013-2018 Andrey Taritsyn
- en-US
- JavaScriptEngineSwitcher JavaScript ECMAScript V8 ClearScript Windows x86
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+ $CommonMetadataElements$
+
+
+
+
+
+ $CommonFileElements$
+
+
+
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.V8.Native.win-x86/PACKAGE-DESCRIPTION.md b/src/JavaScriptEngineSwitcher.V8.Native.win-x86/PACKAGE-DESCRIPTION.md
new file mode 100644
index 00000000..44bc9064
--- /dev/null
+++ b/src/JavaScriptEngineSwitcher.V8.Native.win-x86/PACKAGE-DESCRIPTION.md
@@ -0,0 +1,2 @@
+This package is deprecated.
+Instead, it is recommended to use a [Microsoft.ClearScript.V8.Native.win-x86](https://www.nuget.org/packages/Microsoft.ClearScript.V8.Native.win-x86) package.
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.V8.Native.win-x86/build/JavaScriptEngineSwitcher.V8.Native.win-x86.props b/src/JavaScriptEngineSwitcher.V8.Native.win-x86/build/JavaScriptEngineSwitcher.V8.Native.win-x86.props
deleted file mode 100644
index 4d09c74f..00000000
--- a/src/JavaScriptEngineSwitcher.V8.Native.win-x86/build/JavaScriptEngineSwitcher.V8.Native.win-x86.props
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
-
- x86\ClearScriptV8-32.dll
- PreserveNewest
- False
-
-
- x86\v8-base-ia32.dll
- PreserveNewest
- False
-
-
- x86\v8-ia32.dll
- PreserveNewest
- False
-
-
-
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.V8.Native.win-x86/readme.txt b/src/JavaScriptEngineSwitcher.V8.Native.win-x86/readme.txt
index 93d95d01..d874dc4a 100644
--- a/src/JavaScriptEngineSwitcher.V8.Native.win-x86/readme.txt
+++ b/src/JavaScriptEngineSwitcher.V8.Native.win-x86/readme.txt
@@ -1,36 +1,24 @@
--------------------------------------------------------------------------------
- README file for JS Engine Switcher: V8 for Windows x86 v3.0.0
+ README file for JS Engine Switcher: V8 for Windows x86 v3.29.0
--------------------------------------------------------------------------------
- Copyright (c) 2013-2018 Andrey Taritsyn - http://www.taritsyn.ru
+ Copyright (c) 2013-2025 Andrey Taritsyn - http://www.taritsyn.ru
===========
DESCRIPTION
===========
- This package complements the JavaScriptEngineSwitcher.V8 package and contains
- the native implementation of V8 version 7.0.276.42 for Windows (x86).
-
- For correct working of the Microsoft ClearScript.V8 require the Microsoft Visual
- C++ Redistributable for Visual Studio 2017.
+ This package is deprecated. Instead, it is recommended to use a
+ Microsoft.ClearScript.V8.Native.win-x86 package.
=============
RELEASE NOTES
=============
- 1. Microsoft ClearScript.V8 was updated to version 5.5.4 (support of V8 version
- 7.0.276.42);
- 2. Now the Microsoft ClearScript.V8 requires the Microsoft Visual C++
- Redistributable for Visual Studio 2017.
-
- ====================
- POST-INSTALL ACTIONS
- ====================
- If in your system does not `msvcp140.dll` assembly, then download and install
- the Microsoft Visual C++ Redistributable for Visual Studio 2017
- (https://www.visualstudio.com/downloads/#microsoft-visual-c-redistributable-for-visual-studio-2017).
+ Microsoft ClearScript.V8 was updated to version 7.5 (support of the V8
+ version 13.3.415.23).
=============
DOCUMENTATION
diff --git a/src/JavaScriptEngineSwitcher.V8.Native.win-x86/tools/Install.ps1 b/src/JavaScriptEngineSwitcher.V8.Native.win-x86/tools/Install.ps1
deleted file mode 100644
index 5deda777..00000000
--- a/src/JavaScriptEngineSwitcher.V8.Native.win-x86/tools/Install.ps1
+++ /dev/null
@@ -1,18 +0,0 @@
-param($installPath, $toolsPath, $package, $project)
-
-if ($project.Type -eq "Web Site") {
- $runtimesDirectoryPath = Join-Path $installPath "runtimes"
- $projectDirectoryPath = $project.Properties.Item("FullPath").Value
- $binDirectoryPath = Join-Path $projectDirectoryPath "bin"
- $assembly32FileNames = "ClearScriptV8-32.dll", "v8-base-ia32.dll", "v8-ia32.dll"
-
- $assembly32DestDirectoryPath = Join-Path $binDirectoryPath "x86"
- if (!(Test-Path $assembly32DestDirectoryPath)) {
- New-Item -ItemType Directory -Force -Path $assembly32DestDirectoryPath
- }
-
- foreach ($assembly32FileName in $assembly32FileNames) {
- $assembly32SourceFilePath = Join-Path $runtimesDirectoryPath ("win-x86/native/" + $assembly32FileName)
- Copy-Item $assembly32SourceFilePath $assembly32DestDirectoryPath -Force
- }
-}
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.V8.Native.win-x86/tools/Uninstall.ps1 b/src/JavaScriptEngineSwitcher.V8.Native.win-x86/tools/Uninstall.ps1
deleted file mode 100644
index cf88a341..00000000
--- a/src/JavaScriptEngineSwitcher.V8.Native.win-x86/tools/Uninstall.ps1
+++ /dev/null
@@ -1,16 +0,0 @@
-param($installPath, $toolsPath, $package, $project)
-
-if ($project.Type -eq "Web Site") {
- $projectDirectoryPath = $project.Properties.Item("FullPath").Value
- $binDirectoryPath = Join-Path $projectDirectoryPath "bin"
- $assembly32FileNames = "ClearScriptV8-32.dll", "v8-base-ia32.dll", "v8-ia32.dll"
-
- $assembly32DirectoryPath = Join-Path $binDirectoryPath "x86"
-
- foreach ($assembly32FileName in $assembly32FileNames) {
- $assembly32FilePath = Join-Path $assembly32DirectoryPath $assembly32FileName
- if (Test-Path $assembly32FilePath) {
- Remove-Item $assembly32FilePath -Force
- }
- }
-}
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.V8/AssemblyResolver.cs b/src/JavaScriptEngineSwitcher.V8/AssemblyResolver.cs
deleted file mode 100644
index 54f27c13..00000000
--- a/src/JavaScriptEngineSwitcher.V8/AssemblyResolver.cs
+++ /dev/null
@@ -1,64 +0,0 @@
-using System;
-using System.IO;
-using System.Reflection;
-
-using JavaScriptEngineSwitcher.V8.Constants;
-
-namespace JavaScriptEngineSwitcher.V8
-{
- ///
- /// Assembly resolver
- ///
- internal static class AssemblyResolver
- {
- ///
- /// Initialize a assembly resolver
- ///
- public static void Initialize()
- {
- AppDomain.CurrentDomain.AssemblyResolve += AssemblyResolveHandler;
- }
-
- private static Assembly AssemblyResolveHandler(object sender, ResolveEventArgs args)
- {
- if (args.Name == DllName.ClearScriptV8Universal)
- {
- var currentDomain = (AppDomain)sender;
- string baseDirectoryPath = currentDomain.SetupInformation.PrivateBinPath;
- if (string.IsNullOrEmpty(baseDirectoryPath))
- {
- // `PrivateBinPath` property is empty in test scenarios, so
- // need to use the `BaseDirectory` property
- baseDirectoryPath = currentDomain.BaseDirectory;
- }
-
- string platformName;
- int platformBitness;
- if (Environment.Is64BitProcess)
- {
- platformName = "x64";
- platformBitness = 64;
- }
- else
- {
- platformName = "x86";
- platformBitness = 32;
- }
-
- string assemblyDirectoryPath = Path.Combine(baseDirectoryPath, platformName);
- string assemblyFileName = DllName.ClearScriptV8Universal + "-" + platformBitness + ".dll";
- string assemblyFilePath = Path.Combine(assemblyDirectoryPath, assemblyFileName);
- bool assemblyFileExists = File.Exists(assemblyFilePath);
-
- if (!assemblyFileExists)
- {
- return null;
- }
-
- return Assembly.LoadFile(assemblyFilePath);
- }
-
- return null;
- }
- }
-}
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.V8/Constants/DllName.cs b/src/JavaScriptEngineSwitcher.V8/Constants/DllName.cs
deleted file mode 100644
index 878b8ee1..00000000
--- a/src/JavaScriptEngineSwitcher.V8/Constants/DllName.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-namespace JavaScriptEngineSwitcher.V8.Constants
-{
- ///
- /// DLL names
- ///
- internal static class DllName
- {
- public const string ClearScriptV8Universal = "ClearScriptV8";
- public const string V8Base32Bit = "v8-base-ia32.dll";
- public const string V8Base64Bit = "v8-base-x64.dll";
- }
-}
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.V8/JavaScriptEngineSwitcher.V8.csproj b/src/JavaScriptEngineSwitcher.V8/JavaScriptEngineSwitcher.V8.csproj
index 1f6d246c..3ccf3374 100644
--- a/src/JavaScriptEngineSwitcher.V8/JavaScriptEngineSwitcher.V8.csproj
+++ b/src/JavaScriptEngineSwitcher.V8/JavaScriptEngineSwitcher.V8.csproj
@@ -1,73 +1,46 @@
-
- JS Engine Switcher: V8
- 3.0.0
- net45
- Library
- true
- $(NoWarn);CS1591;NU5125
- true
- true
- JavaScriptEngineSwitcher.V8 contains adapter `V8JsEngine` (wrapper for the Microsoft ClearScript.V8 (http://github.com/Microsoft/ClearScript) version 5.5.4).
-
-This package does not contain the native ClearScript and V8 assemblies. Therefore, you need to choose and install the most appropriate package(s) for your platform. The following packages are available:
-
- * JavaScriptEngineSwitcher.V8.Native.win-x86
- * JavaScriptEngineSwitcher.V8.Native.win-x64
- https://raw.githubusercontent.com/Taritsyn/JavaScriptEngineSwitcher/master/Icons/JavaScriptEngineSwitcher_V8_Logo128x128.png
- JavaScriptEngineSwitcher;JavaScript;ECMAScript;V8;ClearScript
- 1. Microsoft ClearScript.V8 was updated to version 5.5.4;
-2. Now requires .NET Framework 4.5 or higher;
-3. Added a ability to interrupt execution of the script;
-4. Added a ability to pre-compile scripts;
-5. In configuration settings of the V8 JS engine became obsolete the `MaxExecutableSize` property and added two new properties: `AwaitDebuggerAndPauseOnStart` (default `false`) and `EnableRemoteDebugging` (default `false`).
-
-
-
-
-
-
-
-
-
- ../../lib/ClearScript/lib/net45/ClearScript.dll
-
-
-
-
-
-
-
-
-
-
- readme.txt
- true
-
-
- clearscript-license.txt
- true
- false
-
-
- v8-license.txt
- true
- false
-
-
-
-
-
-
-
-
- <_PackageFiles Include="bin/$(Configuration)/*/ClearScript.dll">
- lib/%(RecursiveDir)
- false
- None
-
-
-
+
+ JS Engine Switcher: V8
+ 3.29.1
+ net462;net471;netstandard2.1;netcoreapp3.1;net5.0
+ Library
+ true
+ $(NoWarn);CS1591;NU1903
+ false
+ true
+ true
+ false
+
+
+
+
+
+
+
+ https://raw.githubusercontent.com/Taritsyn/JavaScriptEngineSwitcher/master/Icons/JavaScriptEngineSwitcher_V8_Logo128x128.png
+ ../../Icons/JavaScriptEngineSwitcher_V8_Logo128x128.png
+ JavaScriptEngineSwitcher.V8 contains a `V8JsEngine` adapter (wrapper for the Microsoft ClearScript.V8).
+ $(PackageCommonTags);V8;ClearScript
+ Performed a migration to a modern API for pre-compilation of scripts.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.V8/JsEngineFactoryCollectionExtensions.cs b/src/JavaScriptEngineSwitcher.V8/JsEngineFactoryCollectionExtensions.cs
index a2c68ab2..0e2a95e3 100644
--- a/src/JavaScriptEngineSwitcher.V8/JsEngineFactoryCollectionExtensions.cs
+++ b/src/JavaScriptEngineSwitcher.V8/JsEngineFactoryCollectionExtensions.cs
@@ -11,10 +11,10 @@ public static class JsEngineFactoryCollectionExtensions
{
///
/// Adds a instance of to
- /// the specified
+ /// the specified
///
- /// Instance of
- /// Instance of
+ /// Instance of
+ /// Instance of
public static JsEngineFactoryCollection AddV8(this JsEngineFactoryCollection source)
{
if (source == null)
@@ -27,11 +27,11 @@ public static JsEngineFactoryCollection AddV8(this JsEngineFactoryCollection sou
///
/// Adds a instance of to
- /// the specified
+ /// the specified
///
- /// Instance of
+ /// Instance of
/// The delegate to configure the provided
- /// Instance of
+ /// Instance of
public static JsEngineFactoryCollection AddV8(this JsEngineFactoryCollection source,
Action configure)
{
@@ -53,11 +53,11 @@ public static JsEngineFactoryCollection AddV8(this JsEngineFactoryCollection sou
///
/// Adds a instance of to
- /// the specified
+ /// the specified
///
- /// Instance of
+ /// Instance of
/// Settings of the V8 JS engine
- /// Instance of
+ /// Instance of
public static JsEngineFactoryCollection AddV8(this JsEngineFactoryCollection source,
V8Settings settings)
{
diff --git a/src/JavaScriptEngineSwitcher.V8/PACKAGE-DESCRIPTION.md b/src/JavaScriptEngineSwitcher.V8/PACKAGE-DESCRIPTION.md
new file mode 100644
index 00000000..5c20ea92
--- /dev/null
+++ b/src/JavaScriptEngineSwitcher.V8/PACKAGE-DESCRIPTION.md
@@ -0,0 +1,14 @@
+JavaScriptEngineSwitcher.V8 contains a `V8JsEngine` adapter (wrapper for the [Microsoft ClearScript.V8](http://github.com/Microsoft/ClearScript) version 7.5).
+
+This package does not contain the native ClearScript.V8 assemblies.
+Therefore, you need to choose and install the most appropriate package(s) for your platform.
+The following packages are available:
+
+ * [Microsoft.ClearScript.V8.Native.win-x86](https://www.nuget.org/packages/Microsoft.ClearScript.V8.Native.win-x86)
+ * [Microsoft.ClearScript.V8.Native.win-x64](https://www.nuget.org/packages/Microsoft.ClearScript.V8.Native.win-x64)
+ * [Microsoft.ClearScript.V8.Native.win-arm64](https://www.nuget.org/packages/Microsoft.ClearScript.V8.Native.win-arm64)
+ * [Microsoft.ClearScript.V8.Native.linux-x64](https://www.nuget.org/packages/Microsoft.ClearScript.V8.Native.linux-x64)
+ * [Microsoft.ClearScript.V8.Native.linux-arm](https://www.nuget.org/packages/Microsoft.ClearScript.V8.Native.linux-arm)
+ * [Microsoft.ClearScript.V8.Native.linux-arm64](https://www.nuget.org/packages/Microsoft.ClearScript.V8.Native.linux-arm64)
+ * [Microsoft.ClearScript.V8.Native.osx-x64](https://www.nuget.org/packages/Microsoft.ClearScript.V8.Native.osx-x64)
+ * [Microsoft.ClearScript.V8.Native.osx-arm64](https://www.nuget.org/packages/Microsoft.ClearScript.V8.Native.osx-arm64)
\ No newline at end of file
diff --git a/src/JavaScriptEngineSwitcher.V8/Resources/Strings.Designer.cs b/src/JavaScriptEngineSwitcher.V8/Resources/Strings.Designer.cs
index fb3260cb..f4759a72 100644
--- a/src/JavaScriptEngineSwitcher.V8/Resources/Strings.Designer.cs
+++ b/src/JavaScriptEngineSwitcher.V8/Resources/Strings.Designer.cs
@@ -21,7 +21,7 @@ internal class Strings
private static Lazy _resourceManager =
new Lazy(() => new ResourceManager(
"JavaScriptEngineSwitcher.V8.Resources.Strings",
-#if NET40
+#if NET20 || NET30 || NET35 || NET40
typeof(Strings).Assembly
#else
typeof(Strings).GetTypeInfo().Assembly
@@ -57,22 +57,6 @@ internal static CultureInfo Culture
}
}
- ///
- /// Looks up a localized string similar to "Failed to load the ClearScript `undefined` value."
- ///
- internal static string Engines_ClearScriptUndefinedValueNotLoaded
- {
- get { return GetString("Engines_ClearScriptUndefinedValueNotLoaded"); }
- }
-
- ///
- /// Looks up a localized string similar to "In addition, you still need to install the Microsoft Visual C++ Redistributable for Visual Studio..."
- ///
- internal static string Engine_VcRedist2017InstallationRequired
- {
- get { return GetString("Engine_VcRedist2017InstallationRequired"); }
- }
-
///
/// Looks up a localized string similar to "Pre-compiled script is not accepted. To be accepted, the pre-compiled script must have been created..."
///
diff --git a/src/JavaScriptEngineSwitcher.V8/Resources/Strings.resx b/src/JavaScriptEngineSwitcher.V8/Resources/Strings.resx
index bef5831e..91d19a75 100644
--- a/src/JavaScriptEngineSwitcher.V8/Resources/Strings.resx
+++ b/src/JavaScriptEngineSwitcher.V8/Resources/Strings.resx
@@ -1,17 +1,17 @@
-
@@ -117,12 +117,6 @@
System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
- Failed to load the ClearScript `undefined` value.
-
-
- In addition, you still need to install the Microsoft Visual C++ Redistributable for Visual Studio 2017 (https://www.visualstudio.com/downloads/#microsoft-visual-c-redistributable-for-visual-studio-2017).
-
Pre-compiled script is not accepted. To be accepted, the pre-compiled script must have been created by the same V8 build.
diff --git a/src/JavaScriptEngineSwitcher.V8/Resources/Strings.ru-ru.Designer.cs b/src/JavaScriptEngineSwitcher.V8/Resources/Strings.ru-RU.Designer.cs
similarity index 100%
rename from src/JavaScriptEngineSwitcher.V8/Resources/Strings.ru-ru.Designer.cs
rename to src/JavaScriptEngineSwitcher.V8/Resources/Strings.ru-RU.Designer.cs
diff --git a/src/JavaScriptEngineSwitcher.V8/Resources/Strings.ru-ru.resx b/src/JavaScriptEngineSwitcher.V8/Resources/Strings.ru-RU.resx
similarity index 91%
rename from src/JavaScriptEngineSwitcher.V8/Resources/Strings.ru-ru.resx
rename to src/JavaScriptEngineSwitcher.V8/Resources/Strings.ru-RU.resx
index e6ae5836..816526ea 100644
--- a/src/JavaScriptEngineSwitcher.V8/Resources/Strings.ru-ru.resx
+++ b/src/JavaScriptEngineSwitcher.V8/Resources/Strings.ru-RU.resx
@@ -117,12 +117,6 @@
System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
- Не удалось загрузить значение `undefined` для ClearScript.
-
-
- Кроме того, еще требуется установка распространяемого компонента Microsoft Visual C++ для Visual Studio 2017 (https://www.visualstudio.com/downloads/#microsoft-visual-c-redistributable-for-visual-studio-2017).
-
Предварительно скомпилированный сценарий не принят! Чтобы быть принятым, предварительно скомпилированный сценарий должен быть создан той же сборкой V8.
diff --git a/src/JavaScriptEngineSwitcher.V8/V8JsEngine.cs b/src/JavaScriptEngineSwitcher.V8/V8JsEngine.cs
index c394b985..6b5f74db 100644
--- a/src/JavaScriptEngineSwitcher.V8/V8JsEngine.cs
+++ b/src/JavaScriptEngineSwitcher.V8/V8JsEngine.cs
@@ -1,9 +1,12 @@
using System;
-using System.Reflection;
+using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using OriginalCacheKind = Microsoft.ClearScript.V8.V8CacheKind;
+using OriginalCacheResult = Microsoft.ClearScript.V8.V8CacheResult;
+using OriginalDocumentFlags = Microsoft.ClearScript.DocumentFlags;
+using OriginalDocumentInfo = Microsoft.ClearScript.DocumentInfo;
using OriginalEngine = Microsoft.ClearScript.V8.V8ScriptEngine;
using OriginalEngineFlags = Microsoft.ClearScript.V8.V8ScriptEngineFlags;
using OriginalException = Microsoft.ClearScript.ScriptEngineException;
@@ -30,7 +33,6 @@
using WrapperScriptException = JavaScriptEngineSwitcher.Core.JsScriptException;
using WrapperUsageException = JavaScriptEngineSwitcher.Core.JsUsageException;
-using JavaScriptEngineSwitcher.V8.Constants;
using JavaScriptEngineSwitcher.V8.Resources;
namespace JavaScriptEngineSwitcher.V8
@@ -48,18 +50,13 @@ public sealed class V8JsEngine : JsEngineBase
///
/// Version of original JS engine
///
- private const string EngineVersion = "7.0.276.42";
+ private const string EngineVersion = "13.3.415.23";
///
/// V8 JS engine
///
private OriginalEngine _jsEngine;
- ///
- /// ClearScript undefined value
- ///
- private static OriginalUndefined _originalUndefinedValue;
-
///
/// Regular expression for working with the error message with type
///
@@ -67,21 +64,26 @@ public sealed class V8JsEngine : JsEngineBase
new Regex(@"^(?" + CommonRegExps.JsFullNamePattern + @"):\s+(?[\s\S]+?)$");
///
- /// Regular expression for working with the interface assembly load error message
+ /// Regular expression for working with the library load error message
///
- private static readonly Regex _interfaceAssemblyLoadErrorMessage =
- new Regex(@"^Cannot load V8 interface assembly. " +
+ private static readonly Regex _libraryLoadErrorMessage =
+ new Regex(@"^Cannot load ClearScript V8 library. " +
"Load failure information for (?" + CommonRegExps.DocumentNamePattern + "):");
///
- /// Synchronizer of JS engine initialization
- ///
- private static readonly object _initializationSynchronizer = new object();
-
- ///
- /// Flag indicating whether the JS engine is initialized
+ /// Mapping of native assemblies and NuGet packages
///
- private static bool _initialized;
+ private static readonly Dictionary _nativeAssemblyPackageMap = new Dictionary
+ {
+ { "ClearScriptV8.win-x86.dll", "Microsoft.ClearScript.V8.Native.win-x86" },
+ { "ClearScriptV8.win-x64.dll", "Microsoft.ClearScript.V8.Native.win-x64" },
+ { "ClearScriptV8.win-arm64.dll", "Microsoft.ClearScript.V8.Native.win-arm64" },
+ { "ClearScriptV8.linux-x64.so", "Microsoft.ClearScript.V8.Native.linux-x64" },
+ { "ClearScriptV8.linux-arm.so", "Microsoft.ClearScript.V8.Native.linux-arm" },
+ { "ClearScriptV8.linux-arm64.so", "Microsoft.ClearScript.V8.Native.linux-arm64" },
+ { "ClearScriptV8.osx-x64.dylib", "Microsoft.ClearScript.V8.Native.osx-x64" },
+ { "ClearScriptV8.osx-arm64.dylib", "Microsoft.ClearScript.V8.Native.osx-arm64" }
+ };
///
@@ -97,17 +99,21 @@ public V8JsEngine()
/// Settings of the V8 JS engine
public V8JsEngine(V8Settings settings)
{
- Initialize();
-
V8Settings v8Settings = settings ?? new V8Settings();
var constraints = new OriginalRuntimeConstraints
{
+ HeapExpansionMultiplier = v8Settings.HeapExpansionMultiplier,
+ MaxArrayBufferAllocation = v8Settings.MaxArrayBufferAllocation,
MaxNewSpaceSize = v8Settings.MaxNewSpaceSize,
- MaxOldSpaceSize = v8Settings.MaxOldSpaceSize,
+ MaxOldSpaceSize = v8Settings.MaxOldSpaceSize
};
OriginalEngineFlags flags = OriginalEngineFlags.None;
+ if (v8Settings.AddPerformanceObject)
+ {
+ flags |= OriginalEngineFlags.AddPerformanceObject;
+ }
if (v8Settings.AwaitDebuggerAndPauseOnStart)
{
flags |= OriginalEngineFlags.AwaitDebuggerAndPauseOnStart;
@@ -124,15 +130,23 @@ public V8JsEngine(V8Settings settings)
{
flags |= OriginalEngineFlags.DisableGlobalMembers;
}
+ if (v8Settings.SetTimerResolution)
+ {
+ flags |= OriginalEngineFlags.SetTimerResolution;
+ }
int debugPort = v8Settings.DebugPort;
try
{
- _jsEngine = new OriginalEngine(constraints, flags, debugPort);
- _jsEngine.MaxRuntimeHeapSize = v8Settings.MaxHeapSize;
- _jsEngine.RuntimeHeapSizeSampleInterval = v8Settings.HeapSizeSampleInterval;
- _jsEngine.MaxRuntimeStackUsage = v8Settings.MaxStackUsage;
+ _jsEngine = new OriginalEngine(constraints, flags, debugPort)
+ {
+ AllowReflection = v8Settings.AllowReflection,
+ DisableDynamicBinding = v8Settings.DisableDynamicBinding,
+ MaxRuntimeHeapSize = v8Settings.MaxHeapSize,
+ RuntimeHeapSizeSampleInterval = v8Settings.HeapSizeSampleInterval,
+ MaxRuntimeStackUsage = v8Settings.MaxStackUsage
+ };
}
catch (TypeLoadException e)
{
@@ -145,62 +159,6 @@ public V8JsEngine(V8Settings settings)
}
- ///
- /// Initializes a JS engine
- ///
- private static void Initialize()
- {
- if (_initialized)
- {
- return;
- }
-
- lock (_initializationSynchronizer)
- {
- if (_initialized)
- {
- return;
- }
-
- AssemblyResolver.Initialize();
-
- try
- {
- LoadUndefinedValue();
- }
- catch (InvalidOperationException e)
- {
- throw JsErrorHelpers.WrapEngineLoadException(e, EngineName, EngineVersion);
- }
-
- _initialized = true;
- }
- }
-
- ///
- /// Loads a ClearScript undefined value
- ///
- private static void LoadUndefinedValue()
- {
- FieldInfo undefinedValueFieldInfo = typeof(OriginalUndefined).GetField("Value",
- BindingFlags.NonPublic | BindingFlags.Static);
- OriginalUndefined originalUndefinedValue = null;
-
- if (undefinedValueFieldInfo != null)
- {
- originalUndefinedValue = undefinedValueFieldInfo.GetValue(null) as OriginalUndefined;
- }
-
- if (originalUndefinedValue != null)
- {
- _originalUndefinedValue = originalUndefinedValue;
- }
- else
- {
- throw new InvalidOperationException(Strings.Engines_ClearScriptUndefinedValueNotLoaded);
- }
- }
-
#region Mapping
///
@@ -212,7 +170,7 @@ private static object MapToScriptType(object value)
{
if (value is Undefined)
{
- return _originalUndefinedValue;
+ return OriginalUndefined.Value;
}
return value;
@@ -358,7 +316,7 @@ private static WrapperEngineLoadException WrapTypeLoadException(
string description;
string message;
- Match errorMessageMatch = _interfaceAssemblyLoadErrorMessage.Match(originalMessage);
+ Match errorMessageMatch = _libraryLoadErrorMessage.Match(originalMessage);
if (errorMessageMatch.Success)
{
string assemblyFileName = errorMessageMatch.Groups["assemblyFileName"].Value;
@@ -367,16 +325,11 @@ private static WrapperEngineLoadException WrapTypeLoadException(
StringBuilder descriptionBuilder = stringBuilderPool.Rent();
descriptionBuilder.AppendFormat(CoreStrings.Engine_AssemblyNotFound, assemblyFileName);
descriptionBuilder.Append(" ");
- if (assemblyFileName == DllName.V8Base64Bit || assemblyFileName == DllName.V8Base32Bit)
+
+ string packageName;
+ if (_nativeAssemblyPackageMap.TryGetValue(assemblyFileName, out packageName))
{
- descriptionBuilder.AppendFormat(CoreStrings.Engine_NuGetPackageInstallationRequired,
- assemblyFileName == DllName.V8Base64Bit ?
- "JavaScriptEngineSwitcher.V8.Native.win-x64"
- :
- "JavaScriptEngineSwitcher.V8.Native.win-x86"
- );
- descriptionBuilder.Append(" ");
- descriptionBuilder.Append(Strings.Engine_VcRedist2017InstallationRequired);
+ descriptionBuilder.AppendFormat(CoreStrings.Engine_NuGetPackageInstallationRequired, packageName);
}
else
{
@@ -414,12 +367,13 @@ protected override IPrecompiledScript InnerPrecompile(string code)
protected override IPrecompiledScript InnerPrecompile(string code, string documentName)
{
+ var documentInfo = new OriginalDocumentInfo(documentName);
var cacheKind = OriginalCacheKind.Code;
byte[] cachedBytes;
try
{
- using (OriginalScript generalScript = _jsEngine.Compile(documentName, code, cacheKind,
+ using (OriginalScript generalScript = _jsEngine.Compile(documentInfo, code, cacheKind,
out cachedBytes))
{ }
}
@@ -428,7 +382,7 @@ protected override IPrecompiledScript InnerPrecompile(string code, string docume
throw WrapScriptEngineException(e);
}
- return new V8PrecompiledScript(code, cacheKind, cachedBytes, documentName);
+ return new V8PrecompiledScript(code, cacheKind, cachedBytes, documentInfo);
}
protected override object InnerEvaluate(string expression)
@@ -438,11 +392,15 @@ protected override object InnerEvaluate(string expression)
protected override object InnerEvaluate(string expression, string documentName)
{
+ var documentInfo = new OriginalDocumentInfo(documentName)
+ {
+ Flags = OriginalDocumentFlags.None
+ };
object result;
try
{
- result = _jsEngine.Evaluate(documentName, false, expression);
+ result = _jsEngine.Evaluate(documentInfo, expression);
}
catch (OriginalException e)
{
@@ -477,9 +435,14 @@ protected override void InnerExecute(string code)
protected override void InnerExecute(string code, string documentName)
{
+ var documentInfo = new OriginalDocumentInfo(documentName)
+ {
+ Flags = OriginalDocumentFlags.None
+ };
+
try
{
- _jsEngine.Execute(documentName, false, code);
+ _jsEngine.Execute(documentInfo, code);
}
catch (OriginalException e)
{
@@ -503,15 +466,15 @@ protected override void InnerExecute(IPrecompiledScript precompiledScript)
);
}
- bool cacheAccepted;
+ byte[] cachedBytes = v8PrecompiledScript.CachedBytes;
try
{
- using (OriginalScript script = _jsEngine.Compile(v8PrecompiledScript.DocumentName,
- v8PrecompiledScript.Code, v8PrecompiledScript.CacheKind, v8PrecompiledScript.CachedBytes,
- out cacheAccepted))
+ using (OriginalScript script = _jsEngine.Compile(v8PrecompiledScript.DocumentInfo,
+ v8PrecompiledScript.Code, v8PrecompiledScript.CacheKind, ref cachedBytes,
+ out var cacheResult))
{
- if (!cacheAccepted)
+ if (cacheResult != OriginalCacheResult.Accepted && cacheResult != OriginalCacheResult.Verified)
{
throw new WrapperUsageException(Strings.Usage_PrecompiledScriptNotAccepted, Name, Version);
}
@@ -570,8 +533,21 @@ protected override T InnerCallFunction(string functionName, params object[] a
protected override bool InnerHasVariable(string variableName)
{
- string expression = string.Format("(typeof {0} !== 'undefined');", variableName);
- var result = InnerEvaluate(expression);
+ bool result;
+
+ try
+ {
+ object variableValue = _jsEngine.Global.GetProperty(variableName);
+ result = variableValue != OriginalUndefined.Value;
+ }
+ catch (OriginalException e)
+ {
+ throw WrapScriptEngineException(e);
+ }
+ catch (OriginalInterruptedException e)
+ {
+ throw WrapScriptInterruptedException(e);
+ }
return result;
}
@@ -582,7 +558,7 @@ protected override object InnerGetVariableValue(string variableName)
try
{
- result = _jsEngine.Script[variableName];
+ result = _jsEngine.Global.GetProperty(variableName);
}
catch (OriginalException e)
{
@@ -611,7 +587,7 @@ protected override void InnerSetVariableValue(string variableName, object value)
try
{
- _jsEngine.Script[variableName] = processedValue;
+ _jsEngine.Global.SetProperty(variableName, processedValue);
}
catch (OriginalException e)
{
@@ -625,7 +601,18 @@ protected override void InnerSetVariableValue(string variableName, object value)
protected override void InnerRemoveVariable(string variableName)
{
- InnerSetVariableValue(variableName, Undefined.Value);
+ try
+ {
+ _jsEngine.Global.DeleteProperty(variableName);
+ }
+ catch (OriginalException e)
+ {
+ throw WrapScriptEngineException(e);
+ }
+ catch (OriginalInterruptedException e)
+ {
+ throw WrapScriptInterruptedException(e);
+ }
}
protected override void InnerEmbedHostObject(string itemName, object value)
@@ -674,41 +661,26 @@ protected override void InnerCollectGarbage()
#region IJsEngine implementation
- ///
- /// Gets a name of JS engine
- ///
public override string Name
{
get { return EngineName; }
}
- ///
- /// Gets a version of original JS engine
- ///
public override string Version
{
get { return EngineVersion; }
}
- ///
- /// Gets a value that indicates if the JS engine supports script pre-compilation
- ///
public override bool SupportsScriptPrecompilation
{
get { return true; }
}
- ///
- /// Gets a value that indicates if the JS engine supports script interruption
- ///
public override bool SupportsScriptInterruption
{
get { return true; }
}
- ///
- /// Gets a value that indicates if the JS engine supports garbage collection
- ///
public override bool SupportsGarbageCollection
{
get { return true; }
diff --git a/src/JavaScriptEngineSwitcher.V8/V8JsEngineFactory.cs b/src/JavaScriptEngineSwitcher.V8/V8JsEngineFactory.cs
index 5c96f33a..2bfdbe03 100644
--- a/src/JavaScriptEngineSwitcher.V8/V8JsEngineFactory.cs
+++ b/src/JavaScriptEngineSwitcher.V8/V8JsEngineFactory.cs
@@ -32,9 +32,7 @@ public V8JsEngineFactory(V8Settings settings)
#region IJsEngineFactory implementation
- ///
- /// Gets a name of JS engine
- ///
+ ///
public string EngineName
{
get { return V8JsEngine.EngineName; }
diff --git a/src/JavaScriptEngineSwitcher.V8/V8PrecompiledScript.cs b/src/JavaScriptEngineSwitcher.V8/V8PrecompiledScript.cs
index a3753083..16464dd5 100644
--- a/src/JavaScriptEngineSwitcher.V8/V8PrecompiledScript.cs
+++ b/src/JavaScriptEngineSwitcher.V8/V8PrecompiledScript.cs
@@ -1,4 +1,5 @@
using OriginalCacheKind = Microsoft.ClearScript.V8.V8CacheKind;
+using OriginalDocumentInfo = Microsoft.ClearScript.DocumentInfo;
using JavaScriptEngineSwitcher.Core;
@@ -37,9 +38,9 @@ public byte[] CachedBytes
}
///
- /// Gets a document name
+ /// Gets a meta-information for the document
///
- public string DocumentName
+ public OriginalDocumentInfo DocumentInfo
{
get;
private set;
@@ -52,22 +53,20 @@ public string DocumentName
/// The source code of the script
/// The kind of cache data to be generated
/// Cached data for accelerated recompilation
- /// Document name
+ /// Meta-information for the document
public V8PrecompiledScript(string code, OriginalCacheKind cacheKind, byte[] cachedBytes,
- string documentName)
+ OriginalDocumentInfo documentInfo)
{
Code = code;
CacheKind = cacheKind;
CachedBytes = cachedBytes;
- DocumentName = documentName;
+ DocumentInfo = documentInfo;
}
#region IPrecompiledScript implementation
- ///
- /// Gets a name of JS engine for which the pre-compiled script was created
- ///
+ ///
public string EngineName
{
get { return V8JsEngine.EngineName; }
diff --git a/src/JavaScriptEngineSwitcher.V8/V8Settings.cs b/src/JavaScriptEngineSwitcher.V8/V8Settings.cs
index 6cc4be76..7d2810f1 100644
--- a/src/JavaScriptEngineSwitcher.V8/V8Settings.cs
+++ b/src/JavaScriptEngineSwitcher.V8/V8Settings.cs
@@ -8,32 +8,41 @@ namespace JavaScriptEngineSwitcher.V8
public sealed class V8Settings
{
///
- /// Gets or sets a flag for whether to the script engine is to wait for a debugger connection
- /// and schedule a pause before executing the first line of application script code.
- /// This property is ignored if value of the property is false.
+ /// Gets or sets a flag for whether to add the
+ ///