Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/reactjs/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
AntoineGa committed Nov 20, 2015
2 parents 97592b6 + 8521630 commit 4a8a3b6
Show file tree
Hide file tree
Showing 15 changed files with 45 additions and 14 deletions.
4 changes: 2 additions & 2 deletions build.proj
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ of patent rights can be found in the PATENTS file in the same directory.
<Project ToolsVersion="4.0" DefaultTargets="Build;Test;Package" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Major>2</Major>
<Minor>0</Minor>
<Build>2</Build>
<Minor>1</Minor>
<Build>1</Build>
<Revision>0</Revision>
<DevNuGetServer>http://reactjs.net/packages/</DevNuGetServer>
<MSBuildCommunityTasksPath>$(MSBuildProjectDirectory)\tools\MSBuildTasks</MSBuildCommunityTasksPath>
Expand Down
18 changes: 18 additions & 0 deletions site/jekyll/_posts/2015-11-16-2.1.0-release.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
title: "ReactJS.NET 2.1"
layout: post
author: Daniel Lo Nigro
---

I'm happy to announce the release of ReactJS.NET 2.1! This is a minor release, and includes a number of changes and fixes since 2.0:

- [#189](https://github.com/reactjs/React.NET/issues/189) - If errors occur while loading a JS file, don't throw an exception until we actually try to **use** the script. This ensures that a syntax error in a file loaded with `AddScriptWithoutTransform` will not crash IIS.
- [#186](https://github.com/reactjs/React.NET/issues/186) - Expose `ReactDOM` just in case it's used in some script.
- [#182](https://github.com/reactjs/React.NET/issues/182) - Use SHA1 rather than MD5 for cache hashing so that it can be used in a [FIPS-compliant environment](https://support.microsoft.com/en-us/kb/811833). *Thanks to [Ruaidhri Primrose](https://github.com/RPrimrose)*
- Added [a console sample](https://github.com/reactjs/React.NET/blob/master/src/React.Sample.ConsoleApp/Program.cs) to show how ReactJS.NET can be used outside of a web context.
- [#195](https://github.com/reactjs/React.NET/issues/195) - Add `ReactEnvironment.Current` property as a shortcut to get the current React environment. This replaces the old method of directly using the DI container (`React.AssemblyRegistration.Container.Resolve<IReactEnvironment>()`).

Have fun, and as always, please feel free to send feedback or bug reports
[on GitHub](https://github.com/reactjs/React.NET).

— Daniel
3 changes: 1 addition & 2 deletions src/React.AspNet/BabelFileMiddleware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ public async Task Invoke(HttpContext context)
return;
}

var reactEnvironment = React.AssemblyRegistration.Container.Resolve<IReactEnvironment>();
var internalStaticMiddleware = CreateFileMiddleware(reactEnvironment.Babel);
var internalStaticMiddleware = CreateFileMiddleware(ReactEnvironment.Current.Babel);
await internalStaticMiddleware.Invoke(context);
}

Expand Down
2 changes: 1 addition & 1 deletion src/React.AspNet/HtmlHelperExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ private static IReactEnvironment Environment
{
try
{
return global::React.AssemblyRegistration.Container.Resolve<IReactEnvironment>();
return ReactEnvironment.Current;
}
catch (TinyIoCResolutionException ex)
{
Expand Down
2 changes: 1 addition & 1 deletion src/React.AspNet/project.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "2.0.2-*",
"version": "2.1.1-*",
"configurations": {
"Debug": {
"compilationOptions": {
Expand Down
2 changes: 2 additions & 0 deletions src/React.Core/JavaScriptEngineFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ protected virtual void InitialiseEngine(IJsEngine engine)
{
engine.ExecuteResource("React.Resources.react-with-addons.js", thisAssembly);
engine.Execute("React = global.React");
// Expose ReactDOM as some scripts may be using it. #yolo
engine.Execute("ReactDOM = React.__SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED");
}

LoadUserScripts(engine);
Expand Down
9 changes: 9 additions & 0 deletions src/React.Core/ReactEnvironment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,15 @@ public class ReactEnvironment : IReactEnvironment, IDisposable
/// </summary>
protected readonly IList<IReactComponent> _components = new List<IReactComponent>();

/// <summary>
/// Gets the <see cref="IReactEnvironment"/> for the current request. If no environment
/// has been created for the current request, creates a new one.
/// </summary>
public static IReactEnvironment Current
{
get { return AssemblyRegistration.Container.Resolve<IReactEnvironment>(); }
}

/// <summary>
/// Initializes a new instance of the <see cref="ReactEnvironment"/> class.
/// </summary>
Expand Down
3 changes: 3 additions & 0 deletions src/React.Core/Resources/shims.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

var global = global || {};
var React;
var ReactDOM;

// Basic console shim. Caches all calls to console methods.
function MockConsole() {
Expand Down Expand Up @@ -58,11 +59,13 @@ function ReactNET_initReact() {
}
if (global.React) {
React = global.React;
ReactDOM = React.__SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; // YOLO
return true;
}
if (typeof require === 'function') {
// CommonJS-like environment (eg. Browserify)
React = require('react');
ReactDOM = React.__SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; // YOLO
return true;
}
// :'(
Expand Down
2 changes: 1 addition & 1 deletion src/React.MSBuild/TransformBabel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public override bool Execute()
config
.SetReuseJavaScriptEngines(false);

_environment = React.AssemblyRegistration.Container.Resolve<IReactEnvironment>();
_environment = ReactEnvironment.Current;

Log.LogMessage("Starting Babel transform");
var stopwatch = Stopwatch.StartNew();
Expand Down
2 changes: 1 addition & 1 deletion src/React.Owin/BabelFileMiddleware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public BabelFileMiddleware(Func<IDictionary<string, object>, Task> next, BabelFi
public async Task Invoke(IDictionary<string, object> environment)
{
// Create all "per request" instances
var reactEnvironment = React.AssemblyRegistration.Container.Resolve<IReactEnvironment>();
var reactEnvironment = ReactEnvironment.Current;

var internalStaticMiddleware = CreateFileMiddleware(reactEnvironment.Babel);
await internalStaticMiddleware.Invoke(environment);
Expand Down
2 changes: 1 addition & 1 deletion src/React.Sample.ConsoleApp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ static void Main(string[] args)
.SetReuseJavaScriptEngines(false)
.AddScript("Sample.jsx");

var environment = React.AssemblyRegistration.Container.Resolve<IReactEnvironment>();
var environment = ReactEnvironment.Current;
var component = environment.CreateComponent("HelloWorld", new { name = "Daniel" });
// renderServerOnly omits the data-reactid attributes
var html = component.RenderHtml(renderServerOnly: true);
Expand Down
2 changes: 1 addition & 1 deletion src/React.Sample.Mvc6/project.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"webroot": "wwwroot",
"version": "2.0.2-*",
"version": "2.1.1-*",
"dependencies": {
"Microsoft.AspNet.Mvc": "6.0.0-beta8",
"Microsoft.AspNet.Diagnostics": "1.0.0-beta8",
Expand Down
2 changes: 1 addition & 1 deletion src/System.Web.Optimization.React/BabelTransform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class BabelTransform : IBundleTransform
/// <param name="response">The bundle response.</param>
public void Process(BundleContext context, BundleResponse response)
{
var environment = AssemblyRegistration.Container.Resolve<IReactEnvironment>();
var environment = ReactEnvironment.Current;
response.Content = environment.Babel.Transform(response.Content);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/wrap/React.Core/project.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "2.0.2-*",
"version": "2.1.1-*",
"frameworks": {
"net40": {
"wrappedProject": "../../React.Core/React.Core.csproj",
Expand All @@ -14,7 +14,7 @@
"JSPool": "0.3.1",
"MsieJavaScriptEngine": "1.5.1",
"Newtonsoft.Json": "6.0.8",
"VroomJs": "2.0.2-*"
"VroomJs": "2.1.0-*"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/wrap/VroomJs/project.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "2.0.2-*",
"version": "2.1.1-*",
"frameworks": {
"net40": {
"bin": {
Expand Down

0 comments on commit 4a8a3b6

Please sign in to comment.