Normalise trailing whitespace and line endings everywhere

This commit is contained in:
SteveSandersonMS
2016-03-01 01:10:43 +00:00
parent c425137423
commit 74cac774f8
174 changed files with 782 additions and 783 deletions

View File

@@ -26,7 +26,7 @@ function loadViaWebpackNoCache(webpackConfigPath, modulePath) {
webpackConfig.plugins = webpackConfig.plugins || [];
webpackConfig.plugins.push(new ExternalsPlugin({ type: 'commonjs', include: /node_modules/ }));
// The CommonsChunkPlugin is not compatible with a CommonJS environment like Node, nor is it needed in that case
// The CommonsChunkPlugin is not compatible with a CommonJS environment like Node, nor is it needed in that case
webpackConfig.plugins = webpackConfig.plugins.filter(function(plugin) {
return !(plugin instanceof webpack.optimize.CommonsChunkPlugin);
});
@@ -70,7 +70,7 @@ var domainTask = require('domain-task');
var baseUrl = require('domain-task/fetch').baseUrl;
function findBootModule(bootModule, callback) {
var bootModuleNameFullPath = path.resolve(process.cwd(), bootModule.moduleName);
var bootModuleNameFullPath = path.resolve(process.cwd(), bootModule.moduleName);
if (bootModule.webpackConfig) {
var webpackConfigFullPath = path.resolve(process.cwd(), bootModule.webpackConfig);
loadViaWebpack(webpackConfigFullPath, bootModuleNameFullPath, callback);
@@ -86,7 +86,7 @@ function findBootFunc(bootModule, callback) {
callback(findBootModuleError);
return;
}
// Now try to pick out the function they want us to invoke
var bootFunc;
if (bootModule.exportName) {
@@ -99,7 +99,7 @@ function findBootFunc(bootModule, callback) {
// Native default export
bootFunc = foundBootModule;
}
// Validate the result
if (typeof bootFunc !== 'function') {
if (bootModule.exportName) {
@@ -119,7 +119,7 @@ function renderToString(callback, bootModule, absoluteRequestUrl, requestPathAnd
callback(findBootFuncError);
return;
}
// Prepare a promise that will represent the completion of all domain tasks in this execution context.
// The boot code will wait for this before performing its final render.
var domainTaskCompletionPromiseResolve;
@@ -138,10 +138,10 @@ function renderToString(callback, bootModule, absoluteRequestUrl, requestPathAnd
// Workaround for Node bug where native Promise continuations lose their domain context
// (https://github.com/nodejs/node-v0.x-archive/issues/8648)
bindPromiseContinuationsToDomain(domainTaskCompletionPromise, domain.active);
// Make the base URL available to the 'domain-tasks/fetch' helper within this execution context
baseUrl(absoluteRequestUrl);
// Actually perform the rendering
bootFunc(params).then(function(successResult) {
callback(null, { html: successResult.html, globals: successResult.globals });
@@ -156,12 +156,12 @@ function renderToString(callback, bootModule, absoluteRequestUrl, requestPathAnd
} else {
domainTaskCompletionPromiseResolve();
}
});
});
});
}
function bindPromiseContinuationsToDomain(promise, domainInstance) {
var originalThen = promise.then;
var originalThen = promise.then;
promise.then = function then(resolve, reject) {
if (typeof resolve === 'function') { resolve = domainInstance.bind(resolve); }
if (typeof reject === 'function') { reject = domainInstance.bind(reject); }

View File

@@ -10,10 +10,10 @@ module.exports = {
if (!publicPath) {
throw new Error('To use the Webpack dev server, you must specify a value for \'publicPath\' on the \'output\' section of your webpack.config.');
}
var enableHotModuleReplacement = options.suppliedOptions.HotModuleReplacement;
var enableReactHotModuleReplacement = options.suppliedOptions.ReactHotModuleReplacement;
var app = new express();
var listener = app.listen(defaultPort, function() {
// Build the final Webpack config based on supplied options
@@ -22,9 +22,9 @@ module.exports = {
webpackConfig.plugins.push(
new webpack.HotModuleReplacementPlugin()
);
if (enableReactHotModuleReplacement) {
addReactHotModuleReplacementBabelTransform(webpackConfig);
addReactHotModuleReplacementBabelTransform(webpackConfig);
}
}
@@ -53,7 +53,7 @@ function addReactHotModuleReplacementBabelTransform(webpackConfig) {
if (loaderConfig.loader && loaderConfig.loader.match(/\bbabel-loader\b/)) {
// Ensure the babel-loader options includes a 'query'
var query = loaderConfig.query = loaderConfig.query || {};
// Ensure Babel plugins includes 'react-transform'
var plugins = query.plugins = query.plugins || [];
if (!plugins.some(function(pluginConfig) {
@@ -61,7 +61,7 @@ function addReactHotModuleReplacementBabelTransform(webpackConfig) {
})) {
plugins.push(['react-transform', {}]);
}
// Ensure 'react-transform' plugin is configured to use 'react-transform-hmr'
plugins.forEach(function(pluginConfig) {
if (pluginConfig && pluginConfig[0] === 'react-transform') {
@@ -86,6 +86,6 @@ function removeTrailingSlash(str) {
if (str.lastIndexOf('/') === str.length - 1) {
str = str.substring(0, str.length - 1);
}
return str;
}

View File

@@ -16,4 +16,4 @@
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>
</Project>

View File

@@ -14,17 +14,17 @@ namespace Microsoft.AspNet.SpaServices.Prerendering
public class PrerenderTagHelper : TagHelper
{
static INodeServices fallbackNodeServices; // Used only if no INodeServices was registered with DI
const string PrerenderModuleAttributeName = "asp-prerender-module";
const string PrerenderExportAttributeName = "asp-prerender-export";
const string PrerenderWebpackConfigAttributeName = "asp-prerender-webpack-config";
[HtmlAttributeName(PrerenderModuleAttributeName)]
public string ModuleName { get; set; }
[HtmlAttributeName(PrerenderExportAttributeName)]
public string ExportName { get; set; }
[HtmlAttributeName(PrerenderWebpackConfigAttributeName)]
public string WebpackConfigPath { get; set; }
@@ -35,7 +35,7 @@ namespace Microsoft.AspNet.SpaServices.Prerendering
{
this.contextAccessor = contextAccessor;
this.nodeServices = (INodeServices)serviceProvider.GetService(typeof (INodeServices)) ?? fallbackNodeServices;
// Consider removing the following. Having it means you can get away with not putting app.AddNodeServices()
// in your startup file, but then again it might be confusing that you don't need to.
if (this.nodeServices == null) {
@@ -59,7 +59,7 @@ namespace Microsoft.AspNet.SpaServices.Prerendering
requestAbsoluteUrl: UriHelper.GetEncodedUrl(this.contextAccessor.HttpContext.Request),
requestPathAndQuery: request.Path + request.QueryString.Value);
output.Content.SetHtmlContent(result.Html);
// Also attach any specified globals to the 'window' object. This is useful for transferring
// general state between server and client.
if (result.Globals != null) {

View File

@@ -8,32 +8,32 @@ namespace Microsoft.AspNet.SpaServices.Prerendering
public static class Prerenderer
{
private static Lazy<StringAsTempFile> nodeScript;
static Prerenderer() {
nodeScript = new Lazy<StringAsTempFile>(() => {
var script = EmbeddedResourceReader.Read(typeof(Prerenderer), "/Content/Node/prerenderer.js");
return new StringAsTempFile(script); // Will be cleaned up on process exit
});
}
public static async Task<RenderToStringResult> RenderToString(INodeServices nodeServices, JavaScriptModuleExport bootModule, string requestAbsoluteUrl, string requestPathAndQuery) {
return await nodeServices.InvokeExport<RenderToStringResult>(nodeScript.Value.FileName, "renderToString",
return await nodeServices.InvokeExport<RenderToStringResult>(nodeScript.Value.FileName, "renderToString",
bootModule,
requestAbsoluteUrl,
requestPathAndQuery);
}
}
public class JavaScriptModuleExport {
public string moduleName { get; private set; }
public string exportName { get; set; }
public string webpackConfig { get; set; }
public JavaScriptModuleExport(string moduleName) {
this.moduleName = moduleName;
}
}
public class RenderToStringResult {
public string Html;
public JObject Globals;

View File

@@ -8,21 +8,21 @@ namespace Microsoft.AspNet.SpaServices
internal class SpaRouteConstraint : IRouteConstraint
{
private readonly string clientRouteTokenName;
public SpaRouteConstraint(string clientRouteTokenName) {
if (string.IsNullOrEmpty(clientRouteTokenName)) {
throw new ArgumentException("Value cannot be null or empty", "clientRouteTokenName");
}
this.clientRouteTokenName = clientRouteTokenName;
}
public bool Match(HttpContext httpContext, IRouter route, string routeKey, IDictionary<string, object> values, RouteDirection routeDirection)
{
var clientRouteValue = (values[this.clientRouteTokenName] as string) ?? string.Empty;
return !HasDotInLastSegment(clientRouteValue);
}
private bool HasDotInLastSegment(string uri)
{
var lastSegmentStartPos = uri.LastIndexOf('/');

View File

@@ -33,18 +33,18 @@ namespace Microsoft.AspNet.Builder
// TODO: Consider supporting this. The {*clientRoute} part should be added immediately before the '?'
throw new ArgumentException("SPA fallback route templates don't support querystrings");
}
if (templatePrefix.Contains("#")) {
throw new ArgumentException("SPA fallback route templates should not include # characters. The hash part of a URI does not get sent to the server.");
}
if (templatePrefix != string.Empty && !templatePrefix.EndsWith("/")) {
templatePrefix += "/";
}
return templatePrefix + $"{{*{ ClientRouteTokenName }}}";
}
private static IDictionary<string, object> ObjectToDictionary(object value)
{
return value as IDictionary<string, object> ?? new RouteValueDictionary(value);

View File

@@ -22,7 +22,7 @@ namespace Microsoft.AspNet.Builder
throw new ArgumentException("To enable ReactHotModuleReplacement, you must also enable HotModuleReplacement.");
}
}
// Unlike other consumers of NodeServices, WebpackDevMiddleware dosen't share Node instances, nor does it
// use your DI configuration. It's important for WebpackDevMiddleware to have its own private Node instance
// because it must *not* restart when files change (if it did, you'd lose all the benefits of Webpack
@@ -46,14 +46,14 @@ namespace Microsoft.AspNet.Builder
};
var devServerInfo = nodeServices.InvokeExport<WebpackDevServerInfo>(nodeScript.FileName, "createWebpackDevServer", JsonConvert.SerializeObject(devServerOptions)).Result;
// Proxy the corresponding requests through ASP.NET and into the Node listener
// Proxy the corresponding requests through ASP.NET and into the Node listener
appBuilder.Map(devServerInfo.PublicPath, builder => {
builder.RunProxy(new ProxyOptions {
Host = WebpackDevMiddlewareHostname,
Port = devServerInfo.Port.ToString()
});
});
// While it would be nice to proxy the /__webpack_hmr requests too, these return an EventStream,
// and the Microsoft.Aspnet.Proxy code doesn't handle that entirely - it throws an exception after
// a while. So, just serve a 302 for those.
@@ -64,7 +64,7 @@ namespace Microsoft.AspNet.Builder
});
});
}
#pragma warning disable CS0649
class WebpackDevServerInfo {
public int Port;

View File

@@ -1,5 +1,5 @@
import * as url from 'url';
import * as domain from 'domain';
import * as domain from 'domain';
import * as domainContext from 'domain-context';
import { addTask } from './main';
const isomorphicFetch = require('isomorphic-fetch');
@@ -37,7 +37,7 @@ function issueRequest(baseUrl: string, req: string | Request, init?: RequestInit
if (!init.headers['Connection']) {
init.headers['Connection'] = 'keep-alive';
}
return isomorphicFetch(req, init);
}
@@ -57,6 +57,6 @@ export function baseUrl(url?: string): string {
noDomainBaseUrl = url;
}
}
return domain.active ? domainContext.get(domainTaskStateKey) : noDomainBaseUrl;
}

View File

@@ -38,7 +38,7 @@ export function run<T>(codeToRun: () => T, completionCallback: (error: any) => v
try {
domainContext.set(domainTasksStateKey, state);
synchronousResult = codeToRun();
// If no tasks were registered synchronously, then we're done already
if (state.numRemainingTasks === 0 && !state.hasIssuedSuccessCallback) {
state.hasIssuedSuccessCallback = true;
@@ -48,7 +48,7 @@ export function run<T>(codeToRun: () => T, completionCallback: (error: any) => v
state.completionCallback(ex);
}
});
return synchronousResult;
}