Compare commits

..

1 Commits

Author SHA1 Message Date
SteveSandersonMS
cff75c6893 Example of using PrimeNG 2016-09-28 11:30:34 +01:00
158 changed files with 35186 additions and 768 deletions

View File

@@ -33,7 +33,7 @@ cd $PSScriptRoot
$repoFolder = $PSScriptRoot $repoFolder = $PSScriptRoot
$env:REPO_FOLDER = $repoFolder $env:REPO_FOLDER = $repoFolder
$koreBuildZip="https://codeload.github.com/aspnet/KoreBuild/zip/stevesa/npm-in-series" $koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip"
if ($env:KOREBUILD_ZIP) if ($env:KOREBUILD_ZIP)
{ {
$koreBuildZip=$env:KOREBUILD_ZIP $koreBuildZip=$env:KOREBUILD_ZIP

View File

@@ -2,7 +2,7 @@
repoFolder="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" repoFolder="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $repoFolder cd $repoFolder
koreBuildZip="https://codeload.github.com/aspnet/KoreBuild/zip/stevesa/npm-in-series" koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip"
if [ ! -z $KOREBUILD_ZIP ]; then if [ ! -z $KOREBUILD_ZIP ]; then
koreBuildZip=$KOREBUILD_ZIP koreBuildZip=$KOREBUILD_ZIP
fi fi

View File

@@ -2,7 +2,6 @@
var VERSION='0.1' var VERSION='0.1'
var FULL_VERSION='0.1' var FULL_VERSION='0.1'
var AUTHORS='Microsoft Open Technologies, Inc.' var AUTHORS='Microsoft Open Technologies, Inc.'
var SAMPLES_PROJECT_GLOB='templates/*/project.json'
use-standard-lifecycle use-standard-lifecycle
k-standard-goals k-standard-goals

View File

@@ -37,8 +37,7 @@ namespace Webpack.ActionResults
_moduleExport, _moduleExport,
request.GetEncodedUrl(), request.GetEncodedUrl(),
request.Path + request.QueryString.Value, request.Path + request.QueryString.Value,
_dataToSupply, _dataToSupply
/* timeoutMilliseconds */ 30000
); );
response.ContentType = "text/html"; response.ContentType = "text/html";

View File

@@ -5,7 +5,7 @@
"main": "./dist/Exports", "main": "./dist/Exports",
"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 1", "test": "echo \"Error: no test specified\" && exit 1",
"prepublish": "rimraf *.d.ts dist/*.d.ts && tsc && node build.js" "prepublish": "rimraf *.d.ts dist/*.d.ts && tsd install && tsc && node build.js"
}, },
"typings": "dist/Exports", "typings": "dist/Exports",
"author": "Microsoft", "author": "Microsoft",
@@ -26,7 +26,7 @@
"reflect-metadata": "^0.1.2", "reflect-metadata": "^0.1.2",
"rimraf": "^2.5.4", "rimraf": "^2.5.4",
"systemjs-builder": "^0.14.11", "systemjs-builder": "^0.14.11",
"typescript": "^2.0.0", "typescript": "^1.8.10",
"zone.js": "^0.6.10" "zone.js": "^0.6.10"
} }
} }

View File

@@ -6,8 +6,7 @@
"declaration": true, "declaration": true,
"experimentalDecorators": true, "experimentalDecorators": true,
"noLib": false, "noLib": false,
"outDir": "./dist", "outDir": "./dist"
"lib": ["es2015", "dom"]
}, },
"exclude": [ "exclude": [
"node_modules" "node_modules"

View File

@@ -0,0 +1,12 @@
{
"version": "v4",
"repo": "borisyankov/DefinitelyTyped",
"ref": "master",
"path": "typings",
"bundle": "typings/tsd.d.ts",
"installed": {
"es6-shim/es6-shim.d.ts": {
"commit": "ec9eb4b28c74665a602c22db3457f0a76fa0fa23"
}
}
}

View File

@@ -0,0 +1,668 @@
// Type definitions for es6-shim v0.31.2
// Project: https://github.com/paulmillr/es6-shim
// Definitions by: Ron Buckton <http://github.com/rbuckton>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare type PropertyKey = string | number | symbol;
interface IteratorResult<T> {
done: boolean;
value?: T;
}
interface IterableShim<T> {
/**
* Shim for an ES6 iterable. Not intended for direct use by user code.
*/
"_es6-shim iterator_"(): Iterator<T>;
}
interface Iterator<T> {
next(value?: any): IteratorResult<T>;
return?(value?: any): IteratorResult<T>;
throw?(e?: any): IteratorResult<T>;
}
interface IterableIteratorShim<T> extends IterableShim<T>, Iterator<T> {
/**
* Shim for an ES6 iterable iterator. Not intended for direct use by user code.
*/
"_es6-shim iterator_"(): IterableIteratorShim<T>;
}
interface StringConstructor {
/**
* Return the String value whose elements are, in order, the elements in the List elements.
* If length is 0, the empty string is returned.
*/
fromCodePoint(...codePoints: number[]): string;
/**
* String.raw is intended for use as a tag function of a Tagged Template String. When called
* as such the first argument will be a well formed template call site object and the rest
* parameter will contain the substitution values.
* @param template A well-formed template string call site representation.
* @param substitutions A set of substitution values.
*/
raw(template: TemplateStringsArray, ...substitutions: any[]): string;
}
interface String {
/**
* Returns a nonnegative integer Number less than 1114112 (0x110000) that is the code point
* value of the UTF-16 encoded code point starting at the string element at position pos in
* the String resulting from converting this object to a String.
* If there is no element at that position, the result is undefined.
* If a valid UTF-16 surrogate pair does not begin at pos, the result is the code unit at pos.
*/
codePointAt(pos: number): number;
/**
* Returns true if searchString appears as a substring of the result of converting this
* object to a String, at one or more positions that are
* greater than or equal to position; otherwise, returns false.
* @param searchString search string
* @param position If position is undefined, 0 is assumed, so as to search all of the String.
*/
includes(searchString: string, position?: number): boolean;
/**
* Returns true if the sequence of elements of searchString converted to a String is the
* same as the corresponding elements of this object (converted to a String) starting at
* endPosition length(this). Otherwise returns false.
*/
endsWith(searchString: string, endPosition?: number): boolean;
/**
* Returns a String value that is made from count copies appended together. If count is 0,
* T is the empty String is returned.
* @param count number of copies to append
*/
repeat(count: number): string;
/**
* Returns true if the sequence of elements of searchString converted to a String is the
* same as the corresponding elements of this object (converted to a String) starting at
* position. Otherwise returns false.
*/
startsWith(searchString: string, position?: number): boolean;
/**
* Returns an <a> HTML anchor element and sets the name attribute to the text value
* @param name
*/
anchor(name: string): string;
/** Returns a <big> HTML element */
big(): string;
/** Returns a <blink> HTML element */
blink(): string;
/** Returns a <b> HTML element */
bold(): string;
/** Returns a <tt> HTML element */
fixed(): string
/** Returns a <font> HTML element and sets the color attribute value */
fontcolor(color: string): string
/** Returns a <font> HTML element and sets the size attribute value */
fontsize(size: number): string;
/** Returns a <font> HTML element and sets the size attribute value */
fontsize(size: string): string;
/** Returns an <i> HTML element */
italics(): string;
/** Returns an <a> HTML element and sets the href attribute value */
link(url: string): string;
/** Returns a <small> HTML element */
small(): string;
/** Returns a <strike> HTML element */
strike(): string;
/** Returns a <sub> HTML element */
sub(): string;
/** Returns a <sup> HTML element */
sup(): string;
/**
* Shim for an ES6 iterable. Not intended for direct use by user code.
*/
"_es6-shim iterator_"(): IterableIteratorShim<string>;
}
interface ArrayConstructor {
/**
* Creates an array from an array-like object.
* @param arrayLike An array-like object to convert to an array.
* @param mapfn A mapping function to call on every element of the array.
* @param thisArg Value of 'this' used to invoke the mapfn.
*/
from<T, U>(arrayLike: ArrayLike<T>, mapfn: (v: T, k: number) => U, thisArg?: any): Array<U>;
/**
* Creates an array from an iterable object.
* @param iterable An iterable object to convert to an array.
* @param mapfn A mapping function to call on every element of the array.
* @param thisArg Value of 'this' used to invoke the mapfn.
*/
from<T, U>(iterable: IterableShim<T>, mapfn: (v: T, k: number) => U, thisArg?: any): Array<U>;
/**
* Creates an array from an array-like object.
* @param arrayLike An array-like object to convert to an array.
*/
from<T>(arrayLike: ArrayLike<T>): Array<T>;
/**
* Creates an array from an iterable object.
* @param iterable An iterable object to convert to an array.
*/
from<T>(iterable: IterableShim<T>): Array<T>;
/**
* Returns a new array from a set of elements.
* @param items A set of elements to include in the new array object.
*/
of<T>(...items: T[]): Array<T>;
}
interface Array<T> {
/**
* Returns the value of the first element in the array where predicate is true, and undefined
* otherwise.
* @param predicate find calls predicate once for each element of the array, in ascending
* order, until it finds one where predicate returns true. If such an element is found, find
* immediately returns that element value. Otherwise, find returns undefined.
* @param thisArg If provided, it will be used as the this value for each invocation of
* predicate. If it is not provided, undefined is used instead.
*/
find(predicate: (value: T, index: number, obj: Array<T>) => boolean, thisArg?: any): T;
/**
* Returns the index of the first element in the array where predicate is true, and undefined
* otherwise.
* @param predicate find calls predicate once for each element of the array, in ascending
* order, until it finds one where predicate returns true. If such an element is found, find
* immediately returns that element value. Otherwise, find returns undefined.
* @param thisArg If provided, it will be used as the this value for each invocation of
* predicate. If it is not provided, undefined is used instead.
*/
findIndex(predicate: (value: T) => boolean, thisArg?: any): number;
/**
* Returns the this object after filling the section identified by start and end with value
* @param value value to fill array section with
* @param start index to start filling the array at. If start is negative, it is treated as
* length+start where length is the length of the array.
* @param end index to stop filling the array at. If end is negative, it is treated as
* length+end.
*/
fill(value: T, start?: number, end?: number): T[];
/**
* Returns the this object after copying a section of the array identified by start and end
* to the same array starting at position target
* @param target If target is negative, it is treated as length+target where length is the
* length of the array.
* @param start If start is negative, it is treated as length+start. If end is negative, it
* is treated as length+end.
* @param end If not specified, length of the this object is used as its default value.
*/
copyWithin(target: number, start: number, end?: number): T[];
/**
* Returns an array of key, value pairs for every entry in the array
*/
entries(): IterableIteratorShim<[number, T]>;
/**
* Returns an list of keys in the array
*/
keys(): IterableIteratorShim<number>;
/**
* Returns an list of values in the array
*/
values(): IterableIteratorShim<T>;
/**
* Shim for an ES6 iterable. Not intended for direct use by user code.
*/
"_es6-shim iterator_"(): IterableIteratorShim<T>;
}
interface NumberConstructor {
/**
* The value of Number.EPSILON is the difference between 1 and the smallest value greater than 1
* that is representable as a Number value, which is approximately:
* 2.2204460492503130808472633361816 x 1016.
*/
EPSILON: number;
/**
* Returns true if passed value is finite.
* Unlike the global isFininte, Number.isFinite doesn't forcibly convert the parameter to a
* number. Only finite values of the type number, result in true.
* @param number A numeric value.
*/
isFinite(number: number): boolean;
/**
* Returns true if the value passed is an integer, false otherwise.
* @param number A numeric value.
*/
isInteger(number: number): boolean;
/**
* Returns a Boolean value that indicates whether a value is the reserved value NaN (not a
* number). Unlike the global isNaN(), Number.isNaN() doesn't forcefully convert the parameter
* to a number. Only values of the type number, that are also NaN, result in true.
* @param number A numeric value.
*/
isNaN(number: number): boolean;
/**
* Returns true if the value passed is a safe integer.
* @param number A numeric value.
*/
isSafeInteger(number: number): boolean;
/**
* The value of the largest integer n such that n and n + 1 are both exactly representable as
* a Number value.
* The value of Number.MIN_SAFE_INTEGER is 9007199254740991 2^53 1.
*/
MAX_SAFE_INTEGER: number;
/**
* The value of the smallest integer n such that n and n 1 are both exactly representable as
* a Number value.
* The value of Number.MIN_SAFE_INTEGER is 9007199254740991 ((2^53 1)).
*/
MIN_SAFE_INTEGER: number;
/**
* Converts a string to a floating-point number.
* @param string A string that contains a floating-point number.
*/
parseFloat(string: string): number;
/**
* Converts A string to an integer.
* @param s A string to convert into a number.
* @param radix A value between 2 and 36 that specifies the base of the number in numString.
* If this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal.
* All other strings are considered decimal.
*/
parseInt(string: string, radix?: number): number;
}
interface ObjectConstructor {
/**
* Copy the values of all of the enumerable own properties from one or more source objects to a
* target object. Returns the target object.
* @param target The target object to copy to.
* @param sources One or more source objects to copy properties from.
*/
assign(target: any, ...sources: any[]): any;
/**
* Returns true if the values are the same value, false otherwise.
* @param value1 The first value.
* @param value2 The second value.
*/
is(value1: any, value2: any): boolean;
/**
* Sets the prototype of a specified object o to object proto or null. Returns the object o.
* @param o The object to change its prototype.
* @param proto The value of the new prototype or null.
* @remarks Requires `__proto__` support.
*/
setPrototypeOf(o: any, proto: any): any;
}
interface RegExp {
/**
* Returns a string indicating the flags of the regular expression in question. This field is read-only.
* The characters in this string are sequenced and concatenated in the following order:
*
* - "g" for global
* - "i" for ignoreCase
* - "m" for multiline
* - "u" for unicode
* - "y" for sticky
*
* If no flags are set, the value is the empty string.
*/
flags: string;
}
interface Math {
/**
* Returns the number of leading zero bits in the 32-bit binary representation of a number.
* @param x A numeric expression.
*/
clz32(x: number): number;
/**
* Returns the result of 32-bit multiplication of two numbers.
* @param x First number
* @param y Second number
*/
imul(x: number, y: number): number;
/**
* Returns the sign of the x, indicating whether x is positive, negative or zero.
* @param x The numeric expression to test
*/
sign(x: number): number;
/**
* Returns the base 10 logarithm of a number.
* @param x A numeric expression.
*/
log10(x: number): number;
/**
* Returns the base 2 logarithm of a number.
* @param x A numeric expression.
*/
log2(x: number): number;
/**
* Returns the natural logarithm of 1 + x.
* @param x A numeric expression.
*/
log1p(x: number): number;
/**
* Returns the result of (e^x - 1) of x (e raised to the power of x, where e is the base of
* the natural logarithms).
* @param x A numeric expression.
*/
expm1(x: number): number;
/**
* Returns the hyperbolic cosine of a number.
* @param x A numeric expression that contains an angle measured in radians.
*/
cosh(x: number): number;
/**
* Returns the hyperbolic sine of a number.
* @param x A numeric expression that contains an angle measured in radians.
*/
sinh(x: number): number;
/**
* Returns the hyperbolic tangent of a number.
* @param x A numeric expression that contains an angle measured in radians.
*/
tanh(x: number): number;
/**
* Returns the inverse hyperbolic cosine of a number.
* @param x A numeric expression that contains an angle measured in radians.
*/
acosh(x: number): number;
/**
* Returns the inverse hyperbolic sine of a number.
* @param x A numeric expression that contains an angle measured in radians.
*/
asinh(x: number): number;
/**
* Returns the inverse hyperbolic tangent of a number.
* @param x A numeric expression that contains an angle measured in radians.
*/
atanh(x: number): number;
/**
* Returns the square root of the sum of squares of its arguments.
* @param values Values to compute the square root for.
* If no arguments are passed, the result is +0.
* If there is only one argument, the result is the absolute value.
* If any argument is +Infinity or -Infinity, the result is +Infinity.
* If any argument is NaN, the result is NaN.
* If all arguments are either +0 or 0, the result is +0.
*/
hypot(...values: number[]): number;
/**
* Returns the integral part of the a numeric expression, x, removing any fractional digits.
* If x is already an integer, the result is x.
* @param x A numeric expression.
*/
trunc(x: number): number;
/**
* Returns the nearest single precision float representation of a number.
* @param x A numeric expression.
*/
fround(x: number): number;
/**
* Returns an implementation-dependent approximation to the cube root of number.
* @param x A numeric expression.
*/
cbrt(x: number): number;
}
interface PromiseLike<T> {
/**
* Attaches callbacks for the resolution and/or rejection of the Promise.
* @param onfulfilled The callback to execute when the Promise is resolved.
* @param onrejected The callback to execute when the Promise is rejected.
* @returns A Promise for the completion of which ever callback is executed.
*/
then<TResult>(onfulfilled?: (value: T) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): PromiseLike<TResult>;
then<TResult>(onfulfilled?: (value: T) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => void): PromiseLike<TResult>;
}
/**
* Represents the completion of an asynchronous operation
*/
interface Promise<T> {
/**
* Attaches callbacks for the resolution and/or rejection of the Promise.
* @param onfulfilled The callback to execute when the Promise is resolved.
* @param onrejected The callback to execute when the Promise is rejected.
* @returns A Promise for the completion of which ever callback is executed.
*/
then<TResult>(onfulfilled?: (value: T) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>;
then<TResult>(onfulfilled?: (value: T) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => void): Promise<TResult>;
/**
* Attaches a callback for only the rejection of the Promise.
* @param onrejected The callback to execute when the Promise is rejected.
* @returns A Promise for the completion of the callback.
*/
catch(onrejected?: (reason: any) => T | PromiseLike<T>): Promise<T>;
catch(onrejected?: (reason: any) => void): Promise<T>;
}
interface PromiseConstructor {
/**
* A reference to the prototype.
*/
prototype: Promise<any>;
/**
* Creates a new Promise.
* @param executor A callback used to initialize the promise. This callback is passed two arguments:
* a resolve callback used resolve the promise with a value or the result of another promise,
* and a reject callback used to reject the promise with a provided reason or error.
*/
new <T>(executor: (resolve: (value?: T | PromiseLike<T>) => void, reject: (reason?: any) => void) => void): Promise<T>;
/**
* Creates a Promise that is resolved with an array of results when all of the provided Promises
* resolve, or rejected when any Promise is rejected.
* @param values An array of Promises.
* @returns A new Promise.
*/
all<T>(values: IterableShim<T | PromiseLike<T>>): Promise<T[]>;
/**
* Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
* or rejected.
* @param values An array of Promises.
* @returns A new Promise.
*/
race<T>(values: IterableShim<T | PromiseLike<T>>): Promise<T>;
/**
* Creates a new rejected promise for the provided reason.
* @param reason The reason the promise was rejected.
* @returns A new rejected Promise.
*/
reject(reason: any): Promise<void>;
/**
* Creates a new rejected promise for the provided reason.
* @param reason The reason the promise was rejected.
* @returns A new rejected Promise.
*/
reject<T>(reason: any): Promise<T>;
/**
* Creates a new resolved promise for the provided value.
* @param value A promise.
* @returns A promise whose internal state matches the provided promise.
*/
resolve<T>(value: T | PromiseLike<T>): Promise<T>;
/**
* Creates a new resolved promise .
* @returns A resolved promise.
*/
resolve(): Promise<void>;
}
declare var Promise: PromiseConstructor;
interface Map<K, V> {
clear(): void;
delete(key: K): boolean;
forEach(callbackfn: (value: V, index: K, map: Map<K, V>) => void, thisArg?: any): void;
get(key: K): V;
has(key: K): boolean;
set(key: K, value?: V): Map<K, V>;
size: number;
entries(): IterableIteratorShim<[K, V]>;
keys(): IterableIteratorShim<K>;
values(): IterableIteratorShim<V>;
}
interface MapConstructor {
new <K, V>(): Map<K, V>;
new <K, V>(iterable: IterableShim<[K, V]>): Map<K, V>;
prototype: Map<any, any>;
}
declare var Map: MapConstructor;
interface Set<T> {
add(value: T): Set<T>;
clear(): void;
delete(value: T): boolean;
forEach(callbackfn: (value: T, index: T, set: Set<T>) => void, thisArg?: any): void;
has(value: T): boolean;
size: number;
entries(): IterableIteratorShim<[T, T]>;
keys(): IterableIteratorShim<T>;
values(): IterableIteratorShim<T>;
}
interface SetConstructor {
new <T>(): Set<T>;
new <T>(iterable: IterableShim<T>): Set<T>;
prototype: Set<any>;
}
declare var Set: SetConstructor;
interface WeakMap<K, V> {
delete(key: K): boolean;
get(key: K): V;
has(key: K): boolean;
set(key: K, value?: V): WeakMap<K, V>;
}
interface WeakMapConstructor {
new <K, V>(): WeakMap<K, V>;
new <K, V>(iterable: IterableShim<[K, V]>): WeakMap<K, V>;
prototype: WeakMap<any, any>;
}
declare var WeakMap: WeakMapConstructor;
interface WeakSet<T> {
add(value: T): WeakSet<T>;
delete(value: T): boolean;
has(value: T): boolean;
}
interface WeakSetConstructor {
new <T>(): WeakSet<T>;
new <T>(iterable: IterableShim<T>): WeakSet<T>;
prototype: WeakSet<any>;
}
declare var WeakSet: WeakSetConstructor;
declare namespace Reflect {
function apply(target: Function, thisArgument: any, argumentsList: ArrayLike<any>): any;
function construct(target: Function, argumentsList: ArrayLike<any>): any;
function defineProperty(target: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): boolean;
function deleteProperty(target: any, propertyKey: PropertyKey): boolean;
function enumerate(target: any): IterableIteratorShim<any>;
function get(target: any, propertyKey: PropertyKey, receiver?: any): any;
function getOwnPropertyDescriptor(target: any, propertyKey: PropertyKey): PropertyDescriptor;
function getPrototypeOf(target: any): any;
function has(target: any, propertyKey: PropertyKey): boolean;
function isExtensible(target: any): boolean;
function ownKeys(target: any): Array<PropertyKey>;
function preventExtensions(target: any): boolean;
function set(target: any, propertyKey: PropertyKey, value: any, receiver?: any): boolean;
function setPrototypeOf(target: any, proto: any): boolean;
}
declare module "es6-shim" {
var String: StringConstructor;
var Array: ArrayConstructor;
var Number: NumberConstructor;
var Math: Math;
var Object: ObjectConstructor;
var Map: MapConstructor;
var Set: SetConstructor;
var WeakMap: WeakMapConstructor;
var WeakSet: WeakSetConstructor;
var Promise: PromiseConstructor;
namespace Reflect {
function apply(target: Function, thisArgument: any, argumentsList: ArrayLike<any>): any;
function construct(target: Function, argumentsList: ArrayLike<any>): any;
function defineProperty(target: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): boolean;
function deleteProperty(target: any, propertyKey: PropertyKey): boolean;
function enumerate(target: any): Iterator<any>;
function get(target: any, propertyKey: PropertyKey, receiver?: any): any;
function getOwnPropertyDescriptor(target: any, propertyKey: PropertyKey): PropertyDescriptor;
function getPrototypeOf(target: any): any;
function has(target: any, propertyKey: PropertyKey): boolean;
function isExtensible(target: any): boolean;
function ownKeys(target: any): Array<PropertyKey>;
function preventExtensions(target: any): boolean;
function set(target: any, propertyKey: PropertyKey, value: any, receiver?: any): boolean;
function setPrototypeOf(target: any, proto: any): boolean;
}
}

View File

@@ -0,0 +1,2 @@
/// <reference path="es6-shim/es6-shim.d.ts" />

View File

@@ -33,9 +33,6 @@ namespace Microsoft.AspNetCore.NodeServices.HostingModels
TypeNameHandling = TypeNameHandling.None TypeNameHandling = TypeNameHandling.None
}; };
private readonly static int streamBufferSize = 16 * 1024;
private readonly static UTF8Encoding utf8EncodingWithoutBom = new UTF8Encoding(false);
private readonly SemaphoreSlim _connectionCreationSemaphore = new SemaphoreSlim(1); private readonly SemaphoreSlim _connectionCreationSemaphore = new SemaphoreSlim(1);
private bool _connectionHasFailed; private bool _connectionHasFailed;
private StreamConnection _physicalConnection; private StreamConnection _physicalConnection;
@@ -92,7 +89,7 @@ namespace Microsoft.AspNetCore.NodeServices.HostingModels
virtualConnection = _virtualConnectionClient.OpenVirtualConnection(); virtualConnection = _virtualConnectionClient.OpenVirtualConnection();
// Send request // Send request
WriteJsonLine(virtualConnection, invocationInfo); await WriteJsonLineAsync(virtualConnection, invocationInfo, cancellationToken);
// Determine what kind of response format is expected // Determine what kind of response format is expected
if (typeof(T) == typeof(Stream)) if (typeof(T) == typeof(Stream))
@@ -172,20 +169,11 @@ namespace Microsoft.AspNetCore.NodeServices.HostingModels
base.Dispose(disposing); base.Dispose(disposing);
} }
private static void WriteJsonLine(Stream stream, object serializableObject) private static async Task WriteJsonLineAsync(Stream stream, object serializableObject, CancellationToken cancellationToken)
{ {
using (var streamWriter = new StreamWriter(stream, utf8EncodingWithoutBom, streamBufferSize, true)) var json = JsonConvert.SerializeObject(serializableObject, jsonSerializerSettings);
using (var jsonWriter = new JsonTextWriter(streamWriter)) var bytes = Encoding.UTF8.GetBytes(json + '\n');
{ await stream.WriteAsync(bytes, 0, bytes.Length, cancellationToken);
jsonWriter.CloseOutput = false;
var serializer = JsonSerializer.Create(jsonSerializerSettings);
serializer.Serialize(jsonWriter, serializableObject);
jsonWriter.Flush();
streamWriter.WriteLine();
streamWriter.Flush();
}
} }
private static async Task<T> ReadJsonAsync<T>(Stream stream, CancellationToken cancellationToken) private static async Task<T> ReadJsonAsync<T>(Stream stream, CancellationToken cancellationToken)
@@ -196,7 +184,7 @@ namespace Microsoft.AspNetCore.NodeServices.HostingModels
private static async Task<byte[]> ReadAllBytesAsync(Stream input, CancellationToken cancellationToken) private static async Task<byte[]> ReadAllBytesAsync(Stream input, CancellationToken cancellationToken)
{ {
byte[] buffer = new byte[streamBufferSize]; byte[] buffer = new byte[16 * 1024];
using (var ms = new MemoryStream()) using (var ms = new MemoryStream())
{ {

View File

@@ -1,9 +1,8 @@
{ {
"compilerOptions": { "compilerOptions": {
"target": "es3", "target": "es5",
"module": "commonjs", "module": "commonjs",
"moduleResolution": "node", "moduleResolution": "node"
"types": ["node"]
}, },
"exclude": [ "exclude": [
"node_modules" "node_modules"

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1 @@
/// <reference path="node/node.d.ts" />

View File

@@ -10,9 +10,8 @@
"author": "Microsoft", "author": "Microsoft",
"license": "Apache-2.0", "license": "Apache-2.0",
"devDependencies": { "devDependencies": {
"@types/node": "^6.0.42",
"ts-loader": "^0.8.2", "ts-loader": "^0.8.2",
"typescript": "^2.0.0", "typescript": "^1.8.10",
"webpack": "^1.13.1" "webpack": "^1.13.1"
} }
} }

View File

@@ -0,0 +1,12 @@
{
"version": "v4",
"repo": "borisyankov/DefinitelyTyped",
"ref": "master",
"path": "TypeScript/typings",
"bundle": "TypeScript/typings/tsd.d.ts",
"installed": {
"node/node.d.ts": {
"commit": "edb64e4a35896510ce02b93c0bca5ec3878db738"
}
}
}

View File

@@ -1,3 +1,4 @@
/typings/
/node_modules/ /node_modules/
/*.js /*.js
/*.d.ts /*.d.ts

View File

@@ -1,11 +1,11 @@
{ {
"name": "redux-typed", "name": "redux-typed",
"version": "2.0.0", "version": "1.0.0",
"description": "Helpers for building React+Redux apps with strong TypeScript type checking everywhere", "description": "Helpers for building React+Redux apps with strong TypeScript type checking everywhere",
"main": "main.js", "main": "main.js",
"typings": "main.d.ts", "typings": "main.d.ts",
"scripts": { "scripts": {
"prepublish": "rimraf *.d.ts && tsc && echo 'Finished building NPM package \"redux-typed\"'", "prepublish": "rimraf *.d.ts && tsd update && tsc && echo 'Finished building NPM package \"redux-typed\"'",
"test": "echo \"Error: no test specified\" && exit 1" "test": "echo \"Error: no test specified\" && exit 1"
}, },
"author": "Microsoft", "author": "Microsoft",
@@ -18,10 +18,7 @@
"url": "https://github.com/aspnet/JavaScriptServices.git" "url": "https://github.com/aspnet/JavaScriptServices.git"
}, },
"devDependencies": { "devDependencies": {
"@types/react": "^0.14.38",
"@types/react-redux": "^4.4.32",
"@types/redux": "^3.5.30",
"rimraf": "^2.5.4", "rimraf": "^2.5.4",
"typescript": "^2.0.0" "typescript": "^1.8.10"
} }
} }

View File

@@ -4,12 +4,8 @@
"module": "commonjs", "module": "commonjs",
"target": "es5", "target": "es5",
"declaration": true, "declaration": true,
"outDir": ".", "outDir": "."
"lib": ["es2015", "dom"]
}, },
"files": [
"src/main.ts"
],
"exclude": [ "exclude": [
"node_modules" "node_modules"
] ]

View File

@@ -0,0 +1,18 @@
{
"version": "v4",
"repo": "borisyankov/DefinitelyTyped",
"ref": "master",
"path": "typings",
"bundle": "typings/tsd.d.ts",
"installed": {
"react/react.d.ts": {
"commit": "f4b1797c1201b6c575668f5d7ea12d9b1ab21846"
},
"react-redux/react-redux.d.ts": {
"commit": "f4b1797c1201b6c575668f5d7ea12d9b1ab21846"
},
"redux/redux.d.ts": {
"commit": "f4b1797c1201b6c575668f5d7ea12d9b1ab21846"
}
}
}

View File

@@ -4,7 +4,7 @@
"description": "Helpers for server-side rendering of JavaScript applications in ASP.NET Core projects. Works in conjunction with the Microsoft.AspNetCore.SpaServices NuGet package.", "description": "Helpers for server-side rendering of JavaScript applications in ASP.NET Core projects. Works in conjunction with the Microsoft.AspNetCore.SpaServices NuGet package.",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"prepublish": "rimraf *.d.ts && tsc && echo 'Finished building NPM package \"aspnet-prerendering\"'", "prepublish": "rimraf *.d.ts && tsd update && tsc && echo 'Finished building NPM package \"aspnet-prerendering\"'",
"test": "echo \"Error: no test specified\" && exit 1" "test": "echo \"Error: no test specified\" && exit 1"
}, },
"author": "Microsoft", "author": "Microsoft",
@@ -21,9 +21,7 @@
"es6-promise": "^3.1.2" "es6-promise": "^3.1.2"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "^6.0.42",
"@types/whatwg-fetch": "0.0.31",
"rimraf": "^2.5.4", "rimraf": "^2.5.4",
"typescript": "^2.0.0" "typescript": "^1.8.10"
} }
} }

View File

@@ -174,7 +174,7 @@ function findBootFunc(applicationBasePath: string, bootModule: BootModuleInfo, c
function bindPromiseContinuationsToDomain(promise: Promise<any>, domainInstance: domain.Domain) { function bindPromiseContinuationsToDomain(promise: Promise<any>, domainInstance: domain.Domain) {
const originalThen = promise.then; const originalThen = promise.then;
promise.then = (function then(resolve, reject) { promise.then = function then(resolve, reject) {
if (typeof resolve === 'function') { if (typeof resolve === 'function') {
resolve = domainInstance.bind(resolve); resolve = domainInstance.bind(resolve);
} }
@@ -184,5 +184,5 @@ function bindPromiseContinuationsToDomain(promise: Promise<any>, domainInstance:
} }
return originalThen.call(this, resolve, reject); return originalThen.call(this, resolve, reject);
}) as any; };
} }

View File

@@ -4,12 +4,8 @@
"module": "commonjs", "module": "commonjs",
"target": "es5", "target": "es5",
"declaration": true, "declaration": true,
"outDir": ".", "outDir": "."
"lib": ["es2015", "dom"]
}, },
"files": [
"src/index.ts"
],
"exclude": [ "exclude": [
"node_modules" "node_modules"
] ]

View File

@@ -0,0 +1,18 @@
{
"version": "v4",
"repo": "borisyankov/DefinitelyTyped",
"ref": "master",
"path": "typings",
"bundle": "typings/tsd.d.ts",
"installed": {
"node/node.d.ts": {
"commit": "0144ad5a74053f2292424847259c4c8e1d0fecaa"
},
"es6-promise/es6-promise.d.ts": {
"commit": "0144ad5a74053f2292424847259c4c8e1d0fecaa"
},
"whatwg-fetch/whatwg-fetch.d.ts": {
"commit": "dade4414712ce84e3c63393f1aae407e9e7e6af7"
}
}
}

View File

@@ -1,3 +1,4 @@
/typings/
/node_modules/ /node_modules/
/*.js /*.js
/*.d.ts /*.d.ts

View File

@@ -4,7 +4,7 @@
"description": "Helpers for using Webpack with React in ASP.NET Core projects. Works in conjunction with the Microsoft.AspNetCore.SpaServices NuGet package.", "description": "Helpers for using Webpack with React in ASP.NET Core projects. Works in conjunction with the Microsoft.AspNetCore.SpaServices NuGet package.",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"prepublish": "rimraf *.d.ts && tsc && echo 'Finished building NPM package \"aspnet-webpack-react\"'", "prepublish": "rimraf *.d.ts && tsd update && tsc && echo 'Finished building NPM package \"aspnet-webpack-react\"'",
"test": "echo \"Error: no test specified\" && exit 1" "test": "echo \"Error: no test specified\" && exit 1"
}, },
"author": "Microsoft", "author": "Microsoft",
@@ -23,15 +23,11 @@
"babel-preset-es2015": "^6.6.0", "babel-preset-es2015": "^6.6.0",
"babel-preset-react": "^6.5.0", "babel-preset-react": "^6.5.0",
"react": "^15.0.0", "react": "^15.0.0",
"react-transform-hmr": "^1.0.4" "react-transform-hmr": "^1.0.4",
"webpack": "^1.12.14"
}, },
"devDependencies": { "devDependencies": {
"@types/webpack": "^1.12.34",
"rimraf": "^2.5.4", "rimraf": "^2.5.4",
"typescript": "^2.0.0", "typescript": "^1.8.10"
"webpack": "^1.12.14"
},
"peerDependencies": {
"webpack": "^1.12.14"
} }
} }

View File

@@ -4,12 +4,8 @@
"module": "commonjs", "module": "commonjs",
"target": "es5", "target": "es5",
"declaration": true, "declaration": true,
"outDir": ".", "outDir": "."
"lib": ["es2015"]
}, },
"files": [
"src/index.ts"
],
"exclude": [ "exclude": [
"node_modules" "node_modules"
] ]

View File

@@ -0,0 +1,18 @@
{
"version": "v4",
"repo": "borisyankov/DefinitelyTyped",
"ref": "master",
"path": "typings",
"bundle": "typings/tsd.d.ts",
"installed": {
"source-map/source-map.d.ts": {
"commit": "0144ad5a74053f2292424847259c4c8e1d0fecaa"
},
"webpack/webpack.d.ts": {
"commit": "0144ad5a74053f2292424847259c4c8e1d0fecaa"
},
"uglify-js/uglify-js.d.ts": {
"commit": "0144ad5a74053f2292424847259c4c8e1d0fecaa"
}
}
}

View File

@@ -1,3 +1,4 @@
/typings/
/node_modules/ /node_modules/
/*.js /*.js
/*.d.ts /*.d.ts

View File

@@ -1,6 +1,6 @@
{ {
"name": "aspnet-webpack", "name": "aspnet-webpack",
"version": "1.0.21", "version": "1.0.16",
"description": "Helpers for using Webpack in ASP.NET Core projects. Works in conjunction with the Microsoft.AspNetCore.SpaServices NuGet package.", "description": "Helpers for using Webpack in ASP.NET Core projects. Works in conjunction with the Microsoft.AspNetCore.SpaServices NuGet package.",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
@@ -25,12 +25,9 @@
"webpack-node-externals": "^1.4.3" "webpack-node-externals": "^1.4.3"
}, },
"devDependencies": { "devDependencies": {
"@types/connect": "^3.4.30", "tsd": "0.6.5",
"@types/node": "^6.0.42",
"@types/webpack": "^1.12.34",
"rimraf": "^2.5.4", "rimraf": "^2.5.4",
"typescript": "^2.0.0", "typescript": "^1.8.10"
"webpack": "^1.13.2"
}, },
"peerDependencies": { "peerDependencies": {
"webpack": "^1.13.2" "webpack": "^1.13.2"

View File

@@ -1,8 +1,6 @@
import * as connect from 'connect'; import * as connect from 'connect';
import * as webpack from 'webpack'; import * as webpack from 'webpack';
import * as url from 'url'; import * as url from 'url';
import * as fs from 'fs';
import * as path from 'path';
import { requireNewCopy } from './RequireNewCopy'; import { requireNewCopy } from './RequireNewCopy';
export type CreateDevServerResult = { export type CreateDevServerResult = {
@@ -28,7 +26,7 @@ interface DevServerOptions {
ReactHotModuleReplacement: boolean; ReactHotModuleReplacement: boolean;
} }
function attachWebpackDevMiddleware(app: any, webpackConfig: webpack.Configuration, enableHotModuleReplacement: boolean, enableReactHotModuleReplacement: boolean, hmrEndpoint: string) { function attachWebpackDevMiddleware(app: any, webpackConfig: webpack.Configuration, enableHotModuleReplacement: boolean, enableReactHotModuleReplacement: boolean) {
// Build the final Webpack config based on supplied options // Build the final Webpack config based on supplied options
if (enableHotModuleReplacement) { if (enableHotModuleReplacement) {
// For this, we only support the key/value config format, not string or string[], since // For this, we only support the key/value config format, not string or string[], since
@@ -41,35 +39,12 @@ function attachWebpackDevMiddleware(app: any, webpackConfig: webpack.Configurati
throw new Error('To use HotModuleReplacement, your webpack config must specify an \'entry\' value as a key-value object (e.g., "entry: { main: \'ClientApp/boot-client.ts\' }")'); throw new Error('To use HotModuleReplacement, your webpack config must specify an \'entry\' value as a key-value object (e.g., "entry: { main: \'ClientApp/boot-client.ts\' }")');
} }
// Augment all entry points so they support HMR (unless they already do) // Augment all entry points so they support HMR
Object.getOwnPropertyNames(entryPoints).forEach(entryPointName => { Object.getOwnPropertyNames(entryPoints).forEach(entryPointName => {
const webpackHotMiddlewareEntryPoint = 'webpack-hot-middleware/client';
const webpackHotMiddlewareOptions = `?path=` + encodeURIComponent(hmrEndpoint);
if (typeof entryPoints[entryPointName] === 'string') { if (typeof entryPoints[entryPointName] === 'string') {
entryPoints[entryPointName] = [webpackHotMiddlewareEntryPoint + webpackHotMiddlewareOptions, entryPoints[entryPointName]]; entryPoints[entryPointName] = ['webpack-hot-middleware/client', entryPoints[entryPointName]];
} else if (firstIndexOfStringStartingWith(entryPoints[entryPointName], webpackHotMiddlewareEntryPoint) < 0) { } else {
entryPoints[entryPointName].unshift(webpackHotMiddlewareEntryPoint + webpackHotMiddlewareOptions); entryPoints[entryPointName].unshift('webpack-hot-middleware/client');
}
// Now also inject eventsource polyfill so this can work on IE/Edge (unless it's already there)
// To avoid this being a breaking change for everyone who uses aspnet-webpack, we only do this if you've
// referenced event-source-polyfill in your package.json. Note that having event-source-polyfill available
// on the server in node_modules doesn't imply that you've also included it in your client-side bundle,
// but the converse is true (if it's not in node_modules, then you obviously aren't trying to use it at
// all, so it would definitely not work to take a dependency on it).
const eventSourcePolyfillEntryPoint = 'event-source-polyfill';
if (npmModuleIsPresent(eventSourcePolyfillEntryPoint)) {
const entryPointsArray: string[] = entryPoints[entryPointName]; // We know by now that it's an array, because if it wasn't, we already wrapped it in one
if (entryPointsArray.indexOf(eventSourcePolyfillEntryPoint) < 0) {
const webpackHmrIndex = firstIndexOfStringStartingWith(entryPointsArray, webpackHotMiddlewareEntryPoint);
if (webpackHmrIndex < 0) {
// This should not be possible, since we just added it if it was missing
throw new Error('Cannot find ' + webpackHotMiddlewareEntryPoint + ' in entry points array: ' + entryPointsArray);
}
// Insert the polyfill just before the HMR entrypoint
entryPointsArray.splice(webpackHmrIndex, 0, eventSourcePolyfillEntryPoint);
}
} }
}); });
@@ -93,24 +68,11 @@ function attachWebpackDevMiddleware(app: any, webpackConfig: webpack.Configurati
// Attach Webpack dev middleware and optional 'hot' middleware // Attach Webpack dev middleware and optional 'hot' middleware
const compiler = webpack(webpackConfig); const compiler = webpack(webpackConfig);
const originalFileSystem = compiler.outputFileSystem;
app.use(require('webpack-dev-middleware')(compiler, { app.use(require('webpack-dev-middleware')(compiler, {
noInfo: true, noInfo: true,
publicPath: webpackConfig.output.publicPath publicPath: webpackConfig.output.publicPath
})); }));
// After each compilation completes, copy the in-memory filesystem to disk.
// This is needed because the debuggers in both VS and VS Code assume that they'll be able to find
// the compiled files on the local disk (though it would be better if they got the source file from
// the browser they are debugging, which would be more correct and make this workaround unnecessary).
// Without this, Webpack plugins like HMR that dynamically modify the compiled output in the dev
// middleware's in-memory filesystem only (and not on disk) would confuse the debugger, because the
// file on disk wouldn't match the file served to the browser, and the source map line numbers wouldn't
// match up. Breakpoints would either not be hit, or would hit the wrong lines.
(compiler as any).plugin('done', stats => {
copyRecursiveSync(compiler.outputFileSystem, originalFileSystem, '/', [/\.hot-update\.(js|json)$/]);
});
if (enableHotModuleReplacement) { if (enableHotModuleReplacement) {
let webpackHotMiddlewareModule; let webpackHotMiddlewareModule;
try { try {
@@ -122,33 +84,6 @@ function attachWebpackDevMiddleware(app: any, webpackConfig: webpack.Configurati
} }
} }
function copyRecursiveSync(from: typeof fs, to: typeof fs, rootDir: string, exclude: RegExp[]) {
from.readdirSync(rootDir).forEach(filename => {
const fullPath = pathJoinSafe(rootDir, filename);
const shouldExclude = exclude.filter(re => re.test(fullPath)).length > 0;
if (!shouldExclude) {
const fileStat = from.statSync(fullPath);
if (fileStat.isFile()) {
const fileBuf = from.readFileSync(fullPath);
to.writeFile(fullPath, fileBuf);
} else if (fileStat.isDirectory()) {
copyRecursiveSync(from, to, fullPath, exclude);
}
}
});
}
function pathJoinSafe(rootPath: string, filePath: string) {
// On Windows, MemoryFileSystem's readdirSync output produces directory entries like 'C:'
// which then trigger errors if you call statSync for them. Avoid this by detecting drive
// names at the root, and adding a backslash (so 'C:' becomes 'C:\', which works).
if (rootPath === '/' && path.sep === '\\' && filePath.match(/^[a-z0-9]+\:$/i)) {
return filePath + '\\';
} else {
return path.join(rootPath, filePath);
}
}
function beginWebpackWatcher(webpackConfig: webpack.Configuration) { function beginWebpackWatcher(webpackConfig: webpack.Configuration) {
const compiler = webpack(webpackConfig); const compiler = webpack(webpackConfig);
compiler.watch({ /* watchOptions */ }, (err, stats) => { compiler.watch({ /* watchOptions */ }, (err, stats) => {
@@ -195,9 +130,7 @@ export function createWebpackDevServer(callback: CreateDevServerCallback, option
throw new Error('To use the Webpack dev server, you must specify a value for \'publicPath\' on the \'output\' section of your webpack config (for any configuration that targets browsers)'); throw new Error('To use the Webpack dev server, you must specify a value for \'publicPath\' on the \'output\' section of your webpack config (for any configuration that targets browsers)');
} }
normalizedPublicPaths.push(removeTrailingSlash(publicPath)); normalizedPublicPaths.push(removeTrailingSlash(publicPath));
attachWebpackDevMiddleware(app, webpackConfig, enableHotModuleReplacement, enableReactHotModuleReplacement);
const hmrEndpoint = `http://localhost:${listener.address().port}/__webpack_hmr`;
attachWebpackDevMiddleware(app, webpackConfig, enableHotModuleReplacement, enableReactHotModuleReplacement, hmrEndpoint);
} }
}); });
@@ -227,23 +160,3 @@ function removeTrailingSlash(str: string) {
function getPath(publicPath: string) { function getPath(publicPath: string) {
return url.parse(publicPath).path; return url.parse(publicPath).path;
} }
function firstIndexOfStringStartingWith(array: string[], prefixToFind: string) {
for (let index = 0; index < array.length; index++) {
const candidate = array[index];
if ((typeof candidate === 'string') && (candidate.substring(0, prefixToFind.length) === prefixToFind)) {
return index;
}
}
return -1; // Not found
}
function npmModuleIsPresent(moduleName: string) {
try {
require.resolve(moduleName);
return true;
} catch (ex) {
return false;
}
}

View File

@@ -4,12 +4,8 @@
"module": "commonjs", "module": "commonjs",
"target": "es5", "target": "es5",
"declaration": true, "declaration": true,
"outDir": ".", "outDir": "."
"lib": ["es2015"]
}, },
"files": [
"src/index.ts"
],
"exclude": [ "exclude": [
"node_modules" "node_modules"
] ]

View File

@@ -0,0 +1,27 @@
{
"version": "v4",
"repo": "borisyankov/DefinitelyTyped",
"ref": "master",
"path": "typings",
"bundle": "typings/tsd.d.ts",
"installed": {
"webpack/webpack.d.ts": {
"commit": "0144ad5a74053f2292424847259c4c8e1d0fecaa"
},
"node/node.d.ts": {
"commit": "e937b3e64af586d19f2ea29fdf771e9dc4feecc8"
},
"source-map/source-map.d.ts": {
"commit": "0144ad5a74053f2292424847259c4c8e1d0fecaa"
},
"uglify-js/uglify-js.d.ts": {
"commit": "0144ad5a74053f2292424847259c4c8e1d0fecaa"
},
"es6-promise/es6-promise.d.ts": {
"commit": "0144ad5a74053f2292424847259c4c8e1d0fecaa"
},
"connect/connect.d.ts": {
"commit": "e937b3e64af586d19f2ea29fdf771e9dc4feecc8"
}
}
}

View File

@@ -1,3 +1,4 @@
/typings/
/node_modules/ /node_modules/
/*.js /*.js
/*.d.ts /*.d.ts

View File

@@ -4,7 +4,7 @@
"description": "Tracks outstanding operations for a logical thread of execution", "description": "Tracks outstanding operations for a logical thread of execution",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"prepublish": "rimraf *.d.ts && tsc && echo 'Finished building NPM package \"domain-task\"'", "prepublish": "rimraf *.d.ts && tsd update && tsc && echo 'Finished building NPM package \"domain-task\"'",
"test": "echo \"Error: no test specified\" && exit 1" "test": "echo \"Error: no test specified\" && exit 1"
}, },
"author": "Microsoft", "author": "Microsoft",
@@ -21,9 +21,7 @@
"isomorphic-fetch": "^2.2.1" "isomorphic-fetch": "^2.2.1"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "^6.0.42",
"@types/whatwg-fetch": "0.0.31",
"rimraf": "^2.5.4", "rimraf": "^2.5.4",
"typescript": "^2.0.0" "typescript": "^1.8.10"
} }
} }

View File

@@ -0,0 +1,4 @@
declare module 'isomorphic-fetch' {
var fetch: (url: string | Request, init?: RequestInit) => Promise<any>;
export default fetch;
}

View File

@@ -4,13 +4,8 @@
"module": "commonjs", "module": "commonjs",
"target": "es5", "target": "es5",
"declaration": true, "declaration": true,
"outDir": ".", "outDir": "."
"lib": ["es2015", "dom"]
}, },
"files": [
"src/index.ts",
"src/domain-context.d.ts"
],
"exclude": [ "exclude": [
"node_modules" "node_modules"
] ]

View File

@@ -0,0 +1,18 @@
{
"version": "v4",
"repo": "borisyankov/DefinitelyTyped",
"ref": "master",
"path": "typings",
"bundle": "typings/tsd.d.ts",
"installed": {
"node/node.d.ts": {
"commit": "3030a4be536b6530c06b80081f1333dc0de4d703"
},
"es6-promise/es6-promise.d.ts": {
"commit": "3030a4be536b6530c06b80081f1333dc0de4d703"
},
"whatwg-fetch/whatwg-fetch.d.ts": {
"commit": "3030a4be536b6530c06b80081f1333dc0de4d703"
}
}
}

View File

@@ -1,17 +1,17 @@
import { NgModule } from '@angular/core'; import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router'; import { RouterModule } from '@angular/router';
import { FormsModule } from '@angular/forms';
import { UniversalModule } from 'angular2-universal'; import { UniversalModule } from 'angular2-universal';
import { AppComponent } from './components/app/app.component' import { AppComponent } from './components/app/app.component'
import { NavMenuComponent } from './components/navmenu/navmenu.component'; import { NavMenuComponent } from './components/navmenu/navmenu.component';
import { HomeComponent } from './components/home/home.component'; import { HomeComponent } from './components/home/home.component';
import { FetchDataComponent } from './components/fetchdata/fetchdata.component'; import { FetchDataComponent } from './components/fetchdata/fetchdata.component';
import { CounterComponent } from './components/counter/counter.component'; import { CounterComponent } from './components/counter/counter.component';
import { MaterializeDirective } from 'angular2-materialize'; import { RatingModule } from 'primeng/primeng';
@NgModule({ @NgModule({
bootstrap: [ AppComponent ], bootstrap: [ AppComponent ],
declarations: [ declarations: [
MaterializeDirective,
AppComponent, AppComponent,
NavMenuComponent, NavMenuComponent,
CounterComponent, CounterComponent,
@@ -26,7 +26,9 @@ import { MaterializeDirective } from 'angular2-materialize';
{ path: 'counter', component: CounterComponent }, { path: 'counter', component: CounterComponent },
{ path: 'fetch-data', component: FetchDataComponent }, { path: 'fetch-data', component: FetchDataComponent },
{ path: '**', redirectTo: 'home' } { path: '**', redirectTo: 'home' }
]) ]),
FormsModule,
RatingModule
] ]
}) })
export class AppModule { export class AppModule {

View File

@@ -1,20 +1,4 @@
<h1>Hello, world!</h1> <h1>Hello, world!</h1>
<ul materialize="collapsible" class="collapsible" data-collapsible="accordion">
<li>
<div class="collapsible-header"><i class="material-icons">filter_drama</i>First</div>
<div class="collapsible-body"><p>Lorem ipsum dolor sit amet.</p></div>
</li>
<li>
<div class="collapsible-header"><i class="material-icons">place</i>Second</div>
<div class="collapsible-body"><p>Lorem ipsum dolor sit amet.</p></div>
</li>
<li>
<div class="collapsible-header"><i class="material-icons">whatshot</i>Third</div>
<div class="collapsible-body"><p>Lorem ipsum dolor sit amet.</p></div>
</li>
</ul>
<p>Welcome to your new single-page application, built with:</p> <p>Welcome to your new single-page application, built with:</p>
<ul> <ul>
<li><a href='https://get.asp.net/'>ASP.NET Core</a> and <a href='https://msdn.microsoft.com/en-us/library/67ef8sbd.aspx'>C#</a> for cross-platform server-side code</li> <li><a href='https://get.asp.net/'>ASP.NET Core</a> and <a href='https://msdn.microsoft.com/en-us/library/67ef8sbd.aspx'>C#</a> for cross-platform server-side code</li>
@@ -30,3 +14,7 @@
<li><strong>Hot module replacement</strong>. In development mode, you don't even need to reload the page after making most changes. Within seconds of saving changes to files, your Angular 2 app will be rebuilt and a new instance injected is into the page.</li> <li><strong>Hot module replacement</strong>. In development mode, you don't even need to reload the page after making most changes. Within seconds of saving changes to files, your Angular 2 app will be rebuilt and a new instance injected is into the page.</li>
<li><strong>Efficient production builds</strong>. In production mode, development-time features are disabled, and the <code>webpack</code> build tool produces minified static CSS and JavaScript files.</li> <li><strong>Efficient production builds</strong>. In production mode, development-time features are disabled, and the <code>webpack</code> build tool produces minified static CSS and JavaScript files.</li>
</ul> </ul>
<h1>PrimeNG example</h1>
Rating: {{ ratingValue }}
<p-rating [(ngModel)]="ratingValue"></p-rating>

View File

@@ -5,4 +5,5 @@ import { Component } from '@angular/core';
template: require('./home.component.html') template: require('./home.component.html')
}) })
export class HomeComponent { export class HomeComponent {
public ratingValue: number;
} }

View File

@@ -1,6 +1,4 @@
import 'angular2-universal-polyfills/browser'; import 'angular2-universal-polyfills/browser';
import 'materialize-css';
import 'angular2-materialize';
import { enableProdMode } from '@angular/core'; import { enableProdMode } from '@angular/core';
import { platformUniversalDynamic } from 'angular2-universal'; import { platformUniversalDynamic } from 'angular2-universal';
import { AppModule } from './app/app.module'; import { AppModule } from './app/app.module';

View File

@@ -1,9 +0,0 @@
------------------------------------------------------------------
Don't delete this file. Do include it in your source control repo.
------------------------------------------------------------------
This file exists as a workaround for https://github.com/dotnet/cli/issues/1396
('dotnet publish' does not publish any directories that didn't exist or were
empty before the publish script started).
Hopefully, this can be removed after the move to the new MSBuild.

View File

@@ -36,7 +36,7 @@ namespace WebApplicationBasic.Controllers
{ {
get get
{ {
return 32 + (int)(TemperatureC / 0.5556); return 32 + (int)(this.TemperatureC / 0.5556);
} }
} }
} }

View File

@@ -1,8 +1,7 @@
FROM microsoft/dotnet:1.0.0-preview2-onbuild FROM microsoft/dotnet:latest
RUN apt-get update RUN apt-get update
RUN wget -qO- https://deb.nodesource.com/setup_4.x | bash - RUN apt-get install -y build-essential nodejs nodejs-legacy
RUN apt-get install -y build-essential nodejs
WORKDIR /app WORKDIR /app

View File

@@ -1,39 +1,40 @@
# Welcome to ASP.NET Core # Welcome to ASP.NET 5
We've made some big updates in this release, so its **important** that you spend a few minutes to learn whats new. We've made some big updates in this release, so its **important** that you spend a few minutes to learn whats new.
You've created a new ASP.NET Core project. [Learn what's new](https://go.microsoft.com/fwlink/?LinkId=518016) You've created a new ASP.NET 5 project. [Learn what's new](http://go.microsoft.com/fwlink/?LinkId=518016)
## This application consists of: ## This application consists of:
* Sample pages using ASP.NET Core MVC * Sample pages using ASP.NET MVC 6
* [Gulp](https://go.microsoft.com/fwlink/?LinkId=518007) and [Bower](https://go.microsoft.com/fwlink/?LinkId=518004) for managing client-side libraries * [Gulp](http://go.microsoft.com/fwlink/?LinkId=518007) and [Bower](http://go.microsoft.com/fwlink/?LinkId=518004) for managing client-side libraries
* Theming using [Bootstrap](https://go.microsoft.com/fwlink/?LinkID=398939) * Theming using [Bootstrap](http://go.microsoft.com/fwlink/?LinkID=398939)
## How to ## How to
* [Add a Controller and View](https://go.microsoft.com/fwlink/?LinkID=398600) * [Add a Controller and View](http://go.microsoft.com/fwlink/?LinkID=398600)
* [Add an appsetting in config and access it in app.](https://go.microsoft.com/fwlink/?LinkID=699562) * [Add an appsetting in config and access it in app.](http://go.microsoft.com/fwlink/?LinkID=699562)
* [Manage User Secrets using Secret Manager.](https://go.microsoft.com/fwlink/?LinkId=699315) * [Manage User Secrets using Secret Manager.](http://go.microsoft.com/fwlink/?LinkId=699315)
* [Use logging to log a message.](https://go.microsoft.com/fwlink/?LinkId=699316) * [Use logging to log a message.](http://go.microsoft.com/fwlink/?LinkId=699316)
* [Add packages using NuGet.](https://go.microsoft.com/fwlink/?LinkId=699317) * [Add packages using NuGet.](http://go.microsoft.com/fwlink/?LinkId=699317)
* [Add client packages using Bower.](https://go.microsoft.com/fwlink/?LinkId=699318) * [Add client packages using Bower.](http://go.microsoft.com/fwlink/?LinkId=699318)
* [Target development, staging or production environment.](https://go.microsoft.com/fwlink/?LinkId=699319) * [Target development, staging or production environment.](http://go.microsoft.com/fwlink/?LinkId=699319)
## Overview ## Overview
* [Conceptual overview of what is ASP.NET Core](https://go.microsoft.com/fwlink/?LinkId=518008) * [Conceptual overview of what is ASP.NET 5](http://go.microsoft.com/fwlink/?LinkId=518008)
* [Fundamentals of ASP.NET Core such as Startup and middleware.](https://go.microsoft.com/fwlink/?LinkId=699320) * [Fundamentals of ASP.NET 5 such as Startup and middleware.](http://go.microsoft.com/fwlink/?LinkId=699320)
* [Working with Data](https://go.microsoft.com/fwlink/?LinkId=398602) * [Working with Data](http://go.microsoft.com/fwlink/?LinkId=398602)
* [Security](https://go.microsoft.com/fwlink/?LinkId=398603) * [Security](http://go.microsoft.com/fwlink/?LinkId=398603)
* [Client side development](https://go.microsoft.com/fwlink/?LinkID=699321) * [Client side development](http://go.microsoft.com/fwlink/?LinkID=699321)
* [Develop on different platforms](https://go.microsoft.com/fwlink/?LinkID=699322) * [Develop on different platforms](http://go.microsoft.com/fwlink/?LinkID=699322)
* [Read more on the documentation site](https://go.microsoft.com/fwlink/?LinkID=699323) * [Read more on the documentation site](http://go.microsoft.com/fwlink/?LinkID=699323)
## Run & Deploy ## Run & Deploy
* [Run your app](https://go.microsoft.com/fwlink/?LinkID=517851) * [Run your app](http://go.microsoft.com/fwlink/?LinkID=517851)
* [Run tools such as EF migrations and more](https://go.microsoft.com/fwlink/?LinkID=517853) * [Run your app on .NET Core](http://go.microsoft.com/fwlink/?LinkID=517852)
* [Publish to Microsoft Azure Web Apps](https://go.microsoft.com/fwlink/?LinkID=398609) * [Run commands in your project.json](http://go.microsoft.com/fwlink/?LinkID=517853)
* [Publish to Microsoft Azure Web Apps](http://go.microsoft.com/fwlink/?LinkID=398609)
We would love to hear your [feedback](https://go.microsoft.com/fwlink/?LinkId=518015) We would love to hear your [feedback](http://go.microsoft.com/fwlink/?LinkId=518015)

View File

@@ -2,7 +2,7 @@
ViewData["Title"] = "Home Page"; ViewData["Title"] = "Home Page";
} }
<app>Loading...</app> <app asp-prerender-module="ClientApp/dist/main-server">Loading...</app>
<script src="~/dist/vendor.js" asp-append-version="true"></script> <script src="~/dist/vendor.js" asp-append-version="true"></script>
@section scripts { @section scripts {

View File

@@ -6,8 +6,6 @@
<title>@ViewData["Title"] - WebApplicationBasic</title> <title>@ViewData["Title"] - WebApplicationBasic</title>
<base href="/" /> <base href="/" />
<link rel="stylesheet" href="~/dist/vendor.css" asp-append-version="true" /> <link rel="stylesheet" href="~/dist/vendor.css" asp-append-version="true" />
<link href="http://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.7/css/materialize.min.css">
</head> </head>
<body> <body>
@RenderBody() @RenderBody()

View File

@@ -1,46 +1,47 @@
{ {
"name": "Angular2Spa", "name": "Angular2Spa",
"version": "0.0.0", "version": "0.0.0",
"dependencies": { "devDependencies": {
"@angular/common": "2.0.2", "aspnet-webpack": "^1.0.11",
"@angular/compiler": "2.0.2",
"@angular/core": "2.0.2",
"@angular/forms": "2.0.2",
"@angular/http": "2.0.2",
"@angular/platform-browser": "2.0.2",
"@angular/platform-browser-dynamic": "2.0.2",
"@angular/platform-server": "2.0.2",
"@angular/router": "3.0.2",
"@types/node": "^6.0.42",
"angular2-materialize": "^5.2.1",
"angular2-platform-node": "~2.0.11",
"angular2-universal": "~2.0.11",
"angular2-universal-polyfills": "~2.0.11",
"aspnet-prerendering": "^1.0.7",
"aspnet-webpack": "^1.0.17",
"bootstrap": "^3.3.7",
"css": "^2.2.1", "css": "^2.2.1",
"css-loader": "^0.25.0", "css-loader": "^0.25.0",
"es6-shim": "^0.35.1",
"event-source-polyfill": "^0.0.7",
"expose-loader": "^0.7.1", "expose-loader": "^0.7.1",
"extract-text-webpack-plugin": "^1.0.1", "extract-text-webpack-plugin": "^1.0.1",
"file-loader": "^0.9.0", "file-loader": "^0.9.0",
"isomorphic-fetch": "^2.2.1",
"jquery": "^2.2.1",
"materialize-css": "^0.97.7",
"preboot": "^4.5.2",
"raw-loader": "^0.5.1", "raw-loader": "^0.5.1",
"rxjs": "5.0.0-beta.12", "style-loader": "^0.13.0",
"style-loader": "^0.13.1",
"to-string-loader": "^1.1.5", "to-string-loader": "^1.1.5",
"ts-loader": "^0.8.2", "ts-loader": "^0.8.2",
"typescript": "^2.0.3", "typescript": "^2.0.0",
"url-loader": "^0.5.7", "url-loader": "^0.5.7",
"webpack": "^1.13.2", "webpack": "^1.12.14",
"webpack-hot-middleware": "^2.12.2", "webpack-externals-plugin": "^1.0.0",
"webpack-merge": "^0.14.1", "webpack-hot-middleware": "^2.10.0",
"webpack-node-externals": "^1.4.3", "webpack-merge": "^0.14.1"
"zone.js": "^0.6.25" },
"dependencies": {
"@angular/common": "2.0.0",
"@angular/compiler": "2.0.0",
"@angular/core": "2.0.0",
"@angular/forms": "2.0.0",
"@angular/http": "2.0.0",
"@angular/platform-browser": "2.0.0",
"@angular/platform-browser-dynamic": "2.0.0",
"@angular/platform-server": "2.0.0",
"@angular/router": "3.0.0",
"@types/node": "^6.0.38",
"angular2-platform-node": "~2.0.10",
"angular2-universal": "~2.0.10",
"angular2-universal-polyfills": "~2.0.10",
"aspnet-prerendering": "^1.0.6",
"bootstrap": "^3.3.7",
"es6-shim": "^0.35.1",
"font-awesome": "^4.6.3",
"isomorphic-fetch": "^2.2.1",
"jquery": "^2.2.1",
"preboot": "^4.5.2",
"primeng": "^1.0.0-beta.16",
"rxjs": "5.0.0-beta.12",
"zone.js": "^0.6.21"
} }
} }

View File

@@ -40,10 +40,7 @@
"buildOptions": { "buildOptions": {
"emitEntryPoint": true, "emitEntryPoint": true,
"preserveCompilationContext": true, "preserveCompilationContext": true
"compile": {
"exclude": ["node_modules"]
}
}, },
"runtimeOptions": { "runtimeOptions": {
@@ -60,9 +57,6 @@
"Views", "Views",
"web.config", "web.config",
"wwwroot" "wwwroot"
],
"exclude": [
"wwwroot/dist/*.map"
] ]
}, },

View File

@@ -28,13 +28,8 @@ Obj/
# Visual Studio 2015 cache/options directory # Visual Studio 2015 cache/options directory
.vs/ .vs/
/wwwroot/dist/** /wwwroot/dist/
/ClientApp/dist/** /ClientApp/dist/
# Workaround for https://github.com/aspnet/JavaScriptServices/issues/235
!/wwwroot/dist/_placeholder.txt
!/ClientApp/dist/_placeholder.txt
# MSTest test Results # MSTest test Results
[Tt]est[Rr]esult*/ [Tt]est[Rr]esult*/

View File

@@ -1,7 +1,3 @@
------------------------------------------------------------------
Don't delete this file. Do include it in your source control repo.
------------------------------------------------------------------
This file exists as a workaround for https://github.com/dotnet/cli/issues/1396 This file exists as a workaround for https://github.com/dotnet/cli/issues/1396
('dotnet publish' does not publish any directories that didn't exist or were ('dotnet publish' does not publish any directories that didn't exist or were
empty before the publish script started, which means it's not enough just to empty before the publish script started, which means it's not enough just to

View File

@@ -23,22 +23,16 @@ var sharedConfig = {
}; };
// Configuration for client-side bundle suitable for running in browsers // Configuration for client-side bundle suitable for running in browsers
var clientBundleOutputDir = './wwwroot/dist';
var clientBundleConfig = merge(sharedConfig, { var clientBundleConfig = merge(sharedConfig, {
entry: { 'main-client': './ClientApp/boot-client.ts' }, entry: { 'main-client': './ClientApp/boot-client.ts' },
output: { path: path.join(__dirname, clientBundleOutputDir) }, output: { path: path.join(__dirname, './wwwroot/dist') },
devtool: isDevBuild ? 'inline-source-map' : null,
plugins: [ plugins: [
new webpack.DllReferencePlugin({ new webpack.DllReferencePlugin({
context: __dirname, context: __dirname,
manifest: require('./wwwroot/dist/vendor-manifest.json') manifest: require('./wwwroot/dist/vendor-manifest.json')
}) })
].concat(isDevBuild ? [ ].concat(isDevBuild ? [] : [
// Plugins that apply in development builds only
new webpack.SourceMapDevToolPlugin({
filename: '[name].js.map', // Remove this line if you prefer inline source maps
moduleFilenameTemplate: path.relative(clientBundleOutputDir, '[resourcePath]') // Point sourcemap entries to the original file locations on disk
})
] : [
// Plugins that apply in production builds only // Plugins that apply in production builds only
new webpack.optimize.OccurenceOrderPlugin(), new webpack.optimize.OccurenceOrderPlugin(),
new webpack.optimize.UglifyJsPlugin() new webpack.optimize.UglifyJsPlugin()

View File

@@ -10,7 +10,7 @@ module.exports = {
}, },
module: { module: {
loaders: [ loaders: [
{ test: /\.(png|woff|woff2|eot|ttf|svg)(\?|$)/, loader: 'url-loader?limit=100000' }, { test: /\.(png|gif|woff|woff2|eot|ttf|svg)(\?|$)/, loader: 'url-loader?limit=100000' },
{ test: /\.css(\?|$)/, loader: extractCSS.extract(['css']) } { test: /\.css(\?|$)/, loader: extractCSS.extract(['css']) }
] ]
}, },
@@ -24,16 +24,17 @@ module.exports = {
'@angular/platform-browser-dynamic', '@angular/platform-browser-dynamic',
'@angular/router', '@angular/router',
'@angular/platform-server', '@angular/platform-server',
'angular2-materialize',
'angular2-universal', 'angular2-universal',
'angular2-universal-polyfills', 'angular2-universal-polyfills',
'bootstrap', 'bootstrap',
'bootstrap/dist/css/bootstrap.css', 'bootstrap/dist/css/bootstrap.css',
'es6-shim', 'es6-shim',
'es6-promise', 'es6-promise',
'event-source-polyfill', 'font-awesome/css/font-awesome.css',
'jquery', 'jquery',
'materialize-css', 'primeng/primeng',
'primeng/resources/themes/omega/theme.css',
'primeng/resources/primeng.min.css',
'zone.js', 'zone.js',
] ]
}, },
@@ -44,12 +45,7 @@ module.exports = {
}, },
plugins: [ plugins: [
extractCSS, extractCSS,
new webpack.ProvidePlugin({ new webpack.ProvidePlugin({ $: 'jquery', jQuery: 'jquery' }), // Maps these identifiers to the jQuery package (because Bootstrap expects it to be a global variable)
$: 'jquery',
jQuery: 'jquery',
'window.jQuery': 'jquery',
Hammer: 'hammerjs/hammer'
}), // Maps these identifiers to the jQuery/Hammer packages (because Materialize/Bootstrap expects them to be global variables)
new webpack.optimize.OccurenceOrderPlugin(), new webpack.optimize.OccurenceOrderPlugin(),
new webpack.DllPlugin({ new webpack.DllPlugin({
path: path.join(__dirname, 'wwwroot', 'dist', '[name]-manifest.json'), path: path.join(__dirname, 'wwwroot', 'dist', '[name]-manifest.json'),

View File

@@ -1,9 +0,0 @@
------------------------------------------------------------------
Don't delete this file. Do include it in your source control repo.
------------------------------------------------------------------
This file exists as a workaround for https://github.com/dotnet/cli/issues/1396
('dotnet publish' does not publish any directories that didn't exist or were
empty before the publish script started).
Hopefully, this can be removed after the move to the new MSBuild.

View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified"/>
</handlers>
<httpPlatform processPath="%DNX_PATH%" arguments="%DNX_ARGS%" stdoutLogEnabled="false"/>
</system.webServer>
</configuration>

View File

@@ -1,11 +1,12 @@
import 'bootstrap';
import 'bootstrap/dist/css/bootstrap.css';
import './css/site.css'; import './css/site.css';
import * as ko from 'knockout'; import * as ko from 'knockout';
import { createHistory } from 'history';
import './webpack-component-loader'; import './webpack-component-loader';
import AppRootComponent from './components/app-root/app-root';
const createHistory = require('history').createBrowserHistory;
// Load and register the <app-root> component // Load and register the <app-root> component
ko.components.register('app-root', AppRootComponent); ko.components.register('app-root', require('./components/app-root/app-root').default);
// Tell Knockout to start up an instance of your application // Tell Knockout to start up an instance of your application
ko.applyBindings({ history: createHistory() }); ko.applyBindings({ history: createHistory() });

View File

@@ -13,7 +13,7 @@ class AppRootViewModel {
public route: KnockoutObservable<Route>; public route: KnockoutObservable<Route>;
private _router: Router; private _router: Router;
constructor(params: { history: History.History }) { constructor(params: { history: HistoryModule.History }) {
// Activate the client-side router // Activate the client-side router
this._router = new Router(params.history, routes) this._router = new Router(params.history, routes)
this.route = this._router.currentRoute; this.route = this._router.currentRoute;

View File

@@ -1,5 +1,4 @@
import * as ko from 'knockout'; import * as ko from 'knockout';
import * as $ from 'jquery';
import crossroads = require('crossroads'); import crossroads = require('crossroads');
// This module configures crossroads.js, a routing library. If you prefer, you // This module configures crossroads.js, a routing library. If you prefer, you
@@ -15,7 +14,7 @@ export class Router {
private disposeHistory: () => void; private disposeHistory: () => void;
private clickEventListener: EventListener; private clickEventListener: EventListener;
constructor(history: History.History, routes: Route[]) { constructor(history: HistoryModule.History, routes: Route[]) {
// Reset and configure Crossroads so it matches routes and updates this.currentRoute // Reset and configure Crossroads so it matches routes and updates this.currentRoute
crossroads.removeAllRoutes(); crossroads.removeAllRoutes();
crossroads.resetState(); crossroads.resetState();
@@ -29,7 +28,7 @@ export class Router {
// Make history.js watch for navigation and notify Crossroads // Make history.js watch for navigation and notify Crossroads
this.disposeHistory = history.listen(location => crossroads.parse(location.pathname)); this.disposeHistory = history.listen(location => crossroads.parse(location.pathname));
this.clickEventListener = evt => { this.clickEventListener = evt => {
let target: any = evt.currentTarget; let target: any = evt.target;
if (target && target.tagName === 'A') { if (target && target.tagName === 'A') {
let href = target.getAttribute('href'); let href = target.getAttribute('href');
if (href && href.charAt(0) == '/') { if (href && href.charAt(0) == '/') {
@@ -38,16 +37,13 @@ export class Router {
} }
} }
}; };
$(document).on('click', 'a', this.clickEventListener);
// Initialize Crossroads with starting location document.addEventListener('click', this.clickEventListener);
// Need to cast history to 'any' because @types/history is out-of-date
crossroads.parse((history as any).location.pathname);
} }
public dispose() { public dispose() {
this.disposeHistory(); this.disposeHistory();
$(document).off('click', 'a', this.clickEventListener); document.removeEventListener('click', this.clickEventListener);
} }
} }

View File

@@ -36,7 +36,7 @@ namespace WebApplicationBasic.Controllers
{ {
get get
{ {
return 32 + (int)(TemperatureC / 0.5556); return 32 + (int)(this.TemperatureC / 0.5556);
} }
} }
} }

View File

@@ -1,8 +1,7 @@
FROM microsoft/dotnet:latest FROM microsoft/dotnet:latest
RUN apt-get update RUN apt-get update
RUN wget -qO- https://deb.nodesource.com/setup_4.x | bash - RUN apt-get install -y build-essential nodejs nodejs-legacy
RUN apt-get install -y build-essential nodejs
WORKDIR /app WORKDIR /app

View File

@@ -1,39 +1,40 @@
# Welcome to ASP.NET Core # Welcome to ASP.NET 5
We've made some big updates in this release, so its **important** that you spend a few minutes to learn whats new. We've made some big updates in this release, so its **important** that you spend a few minutes to learn whats new.
You've created a new ASP.NET Core project. [Learn what's new](https://go.microsoft.com/fwlink/?LinkId=518016) You've created a new ASP.NET 5 project. [Learn what's new](http://go.microsoft.com/fwlink/?LinkId=518016)
## This application consists of: ## This application consists of:
* Sample pages using ASP.NET Core MVC * Sample pages using ASP.NET MVC 6
* [Gulp](https://go.microsoft.com/fwlink/?LinkId=518007) and [Bower](https://go.microsoft.com/fwlink/?LinkId=518004) for managing client-side libraries * [Gulp](http://go.microsoft.com/fwlink/?LinkId=518007) and [Bower](http://go.microsoft.com/fwlink/?LinkId=518004) for managing client-side libraries
* Theming using [Bootstrap](https://go.microsoft.com/fwlink/?LinkID=398939) * Theming using [Bootstrap](http://go.microsoft.com/fwlink/?LinkID=398939)
## How to ## How to
* [Add a Controller and View](https://go.microsoft.com/fwlink/?LinkID=398600) * [Add a Controller and View](http://go.microsoft.com/fwlink/?LinkID=398600)
* [Add an appsetting in config and access it in app.](https://go.microsoft.com/fwlink/?LinkID=699562) * [Add an appsetting in config and access it in app.](http://go.microsoft.com/fwlink/?LinkID=699562)
* [Manage User Secrets using Secret Manager.](https://go.microsoft.com/fwlink/?LinkId=699315) * [Manage User Secrets using Secret Manager.](http://go.microsoft.com/fwlink/?LinkId=699315)
* [Use logging to log a message.](https://go.microsoft.com/fwlink/?LinkId=699316) * [Use logging to log a message.](http://go.microsoft.com/fwlink/?LinkId=699316)
* [Add packages using NuGet.](https://go.microsoft.com/fwlink/?LinkId=699317) * [Add packages using NuGet.](http://go.microsoft.com/fwlink/?LinkId=699317)
* [Add client packages using Bower.](https://go.microsoft.com/fwlink/?LinkId=699318) * [Add client packages using Bower.](http://go.microsoft.com/fwlink/?LinkId=699318)
* [Target development, staging or production environment.](https://go.microsoft.com/fwlink/?LinkId=699319) * [Target development, staging or production environment.](http://go.microsoft.com/fwlink/?LinkId=699319)
## Overview ## Overview
* [Conceptual overview of what is ASP.NET Core](https://go.microsoft.com/fwlink/?LinkId=518008) * [Conceptual overview of what is ASP.NET 5](http://go.microsoft.com/fwlink/?LinkId=518008)
* [Fundamentals of ASP.NET Core such as Startup and middleware.](https://go.microsoft.com/fwlink/?LinkId=699320) * [Fundamentals of ASP.NET 5 such as Startup and middleware.](http://go.microsoft.com/fwlink/?LinkId=699320)
* [Working with Data](https://go.microsoft.com/fwlink/?LinkId=398602) * [Working with Data](http://go.microsoft.com/fwlink/?LinkId=398602)
* [Security](https://go.microsoft.com/fwlink/?LinkId=398603) * [Security](http://go.microsoft.com/fwlink/?LinkId=398603)
* [Client side development](https://go.microsoft.com/fwlink/?LinkID=699321) * [Client side development](http://go.microsoft.com/fwlink/?LinkID=699321)
* [Develop on different platforms](https://go.microsoft.com/fwlink/?LinkID=699322) * [Develop on different platforms](http://go.microsoft.com/fwlink/?LinkID=699322)
* [Read more on the documentation site](https://go.microsoft.com/fwlink/?LinkID=699323) * [Read more on the documentation site](http://go.microsoft.com/fwlink/?LinkID=699323)
## Run & Deploy ## Run & Deploy
* [Run your app](https://go.microsoft.com/fwlink/?LinkID=517851) * [Run your app](http://go.microsoft.com/fwlink/?LinkID=517851)
* [Run tools such as EF migrations and more](https://go.microsoft.com/fwlink/?LinkID=517853) * [Run your app on .NET Core](http://go.microsoft.com/fwlink/?LinkID=517852)
* [Publish to Microsoft Azure Web Apps](https://go.microsoft.com/fwlink/?LinkID=398609) * [Run commands in your project.json](http://go.microsoft.com/fwlink/?LinkID=517853)
* [Publish to Microsoft Azure Web Apps](http://go.microsoft.com/fwlink/?LinkID=398609)
We would love to hear your [feedback](https://go.microsoft.com/fwlink/?LinkId=518015) We would love to hear your [feedback](http://go.microsoft.com/fwlink/?LinkId=518015)

View File

@@ -2,33 +2,24 @@
"name": "WebApplicationBasic", "name": "WebApplicationBasic",
"version": "0.0.0", "version": "0.0.0",
"devDependencies": { "devDependencies": {
"@types/core-js": "^0.9.34", "aspnet-webpack": "^1.0.6",
"@types/crossroads": "0.0.29",
"@types/history": "^2.0.38",
"@types/jquery": "^2.0.32",
"@types/knockout": "^3.4.35",
"@types/react-router": "^2.0.37",
"@types/requirejs": "^2.1.26",
"@types/signals": "0.0.16",
"@types/whatwg-fetch": "0.0.30",
"aspnet-webpack": "^1.0.17",
"bootstrap": "^3.3.6", "bootstrap": "^3.3.6",
"bundle-loader": "^0.5.4", "bundle-loader": "^0.5.4",
"crossroads": "^0.12.2", "crossroads": "^0.12.2",
"css-loader": "^0.25.0", "css-loader": "^0.23.1",
"event-source-polyfill": "^0.0.7", "extendify": "^1.0.0",
"extract-text-webpack-plugin": "^1.0.1", "extract-text-webpack-plugin": "^1.0.1",
"file-loader": "^0.9.0", "file-loader": "^0.8.5",
"history": "^4.3.0", "history": "^2.0.1",
"isomorphic-fetch": "^2.2.1", "isomorphic-fetch": "^2.2.1",
"jquery": "^2.2.1", "jquery": "^2.2.1",
"knockout": "^3.4.0", "knockout": "^3.4.0",
"raw-loader": "^0.5.1", "raw-loader": "^0.5.1",
"style-loader": "^0.13.1", "style-loader": "^0.13.0",
"ts-loader": "^0.8.2", "ts-loader": "^0.8.1",
"typescript": "^2.0.3", "typescript": "^1.8.2",
"url-loader": "^0.5.7", "url-loader": "^0.5.7",
"webpack": "^1.13.2", "webpack": "^1.12.14",
"webpack-hot-middleware": "^2.12.2" "webpack-hot-middleware": "^2.10.0"
} }
} }

View File

@@ -40,10 +40,7 @@
"buildOptions": { "buildOptions": {
"emitEntryPoint": true, "emitEntryPoint": true,
"preserveCompilationContext": true, "preserveCompilationContext": true
"compile": {
"exclude": ["node_modules"]
}
}, },
"runtimeOptions": { "runtimeOptions": {
@@ -55,21 +52,23 @@
"publishOptions": { "publishOptions": {
"include": [ "include": [
"appsettings.json", "appsettings.json",
"ClientApp",
"node_modules", "node_modules",
"typings",
"Views", "Views",
"tsconfig.json",
"tsd.json",
"web.config", "web.config",
"webpack.*.js",
"wwwroot" "wwwroot"
],
"exclude": [
"wwwroot/dist/*.map"
] ]
}, },
"scripts": { "scripts": {
"prepublish": [ "prepublish": [
"npm install", "npm install",
"node node_modules/webpack/bin/webpack.js --config webpack.config.vendor.js --env.prod", "node node_modules/webpack/bin/webpack.js --config webpack.config.vendor.js",
"node node_modules/webpack/bin/webpack.js --env.prod" "node node_modules/webpack/bin/webpack.js"
], ],
"postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ] "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
}, },

View File

@@ -28,10 +28,7 @@ Obj/
# Visual Studio 2015 cache/options directory # Visual Studio 2015 cache/options directory
.vs/ .vs/
/wwwroot/dist/** /wwwroot/dist/
# Workaround for https://github.com/aspnet/JavaScriptServices/issues/235
!/wwwroot/dist/_placeholder.txt
# MSTest test Results # MSTest test Results
[Tt]est[Rr]esult*/ [Tt]est[Rr]esult*/

View File

@@ -0,0 +1,33 @@
{
"version": "v4",
"repo": "borisyankov/DefinitelyTyped",
"ref": "master",
"path": "typings",
"bundle": "typings/tsd.d.ts",
"installed": {
"knockout/knockout.d.ts": {
"commit": "9f0f926a12026287b5a4a229e5672c01e7549313"
},
"requirejs/require.d.ts": {
"commit": "9f0f926a12026287b5a4a229e5672c01e7549313"
},
"es6-promise/es6-promise.d.ts": {
"commit": "9f0f926a12026287b5a4a229e5672c01e7549313"
},
"history/history.d.ts": {
"commit": "9f0f926a12026287b5a4a229e5672c01e7549313"
},
"react-router/history.d.ts": {
"commit": "9f0f926a12026287b5a4a229e5672c01e7549313"
},
"crossroads/crossroads.d.ts": {
"commit": "9f0f926a12026287b5a4a229e5672c01e7549313"
},
"js-signals/js-signals.d.ts": {
"commit": "9f0f926a12026287b5a4a229e5672c01e7549313"
},
"isomorphic-fetch/isomorphic-fetch.d.ts": {
"commit": "57ec5fbb76060329c10959d449eb1d4e70b15a65"
}
}
}

View File

@@ -0,0 +1,159 @@
// Type definitions for Crossroads.js
// Project: http://millermedeiros.github.io/crossroads.js/
// Definitions by: Diullei Gomes <https://github.com/diullei>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../js-signals/js-signals.d.ts" />
declare module CrossroadsJs {
export interface Route {
matched: Signal;
/**
* Signal dispatched every time a request "leaves" the route.
*/
switched: Signal;
/**
* Object used to configure parameters/segments validation rules.
*/
rules: any;
/**
* If crossroads should try to match this Route even after matching another Route.
*/
greedy: boolean;
/**
* Remove route from crossroads and destroy it, releasing memory.
*/
dispose(): void;
/**
* Test if Route matches against request. Return true if request validate against route rules and pattern.
*/
match(request: any): boolean;
/**
* Return a string that matches the route replacing the capturing groups with the values provided in the replacements object.
*/
interpolate(replacements: any): string;
/**
* Add a listener to the signal.
*
* @param listener Signal handler function.
* @param listenercontext Context on which listener will be executed (object that should represent the `this` variable inside listener function).
* @param priority The priority level of the event listener. Listeners with higher priority will be executed before listeners with lower priority. Listeners with same priority level will be executed at the same order as they were added. (default = 0)
*/
add(listener: Function, listenerContext?: any, priority?: Number): SignalBinding;
}
export interface CrossRoadsStatic {
NORM_AS_ARRAY: Function;
NORM_AS_OBJECT: Function;
/**
* Creates a new route pattern listener and add it to crossroads routes collection.
*
* @param pattern String pattern or Regular Expression that should be used to match against requests.
* @param handler Function that should be executed when a request matches the Route pattern.
* @param priority Route execution priority.
*/
addRoute(pattern: any, handler?: Function, priority?: number): Route;
/**
* Remove a single route from crossroads collection.
*
* @param route Reference to the Route object returned by crossroads.addRoute().
*/
removeRoute(route: Route): void;
/**
* Remove all routes from crossroads collection.
*/
removeAllRoutes(): void;
/**
* Parse a string input and dispatch matched Signal of the first Route that matches the request.
*
* @param request String that should be evaluated and matched against Routes to define which Route handlers should be executed and which parameters should be passed to the handlers.
* @param defaultargs Array containing values passed to matched/routed/bypassed signals as first arguments. Useful for node.js in case you need to access the request and response objects.
*/
parse(request: string, ...defaultArgs: any[]): void;
/**
* Get number of Routes contained on the crossroads collection.
*/
getNumRoutes(): number;
/**
* Signal dispatched every time that crossroads.parse can't find a Route that matches the request. Useful for debuging and error handling.
*/
bypassed: Signal;
/**
* Signal dispatched every time that crossroads.parse find a Route that matches the request. Useful for debuging and for executing tasks that should happen at each routing.
*/
routed: Signal;
/**
* Create a new independent Router instance.
*/
create(): CrossRoadsStatic;
/**
* Sets a default function that should be used to normalize parameters before passing them to the Route.matched, works similarly to Route.rules.normalize_.
*/
normalizeFn: Function;
/**
* Set if crossroads should typecast route paths. Default value is false (IMPORTANT: on v0.5.0 it was true by default).
*/
shouldTypecast: boolean;
/**
* String representation of the crossroads version number (e.g. "0.6.0").
*/
VERSION: string;
/**
* Sets global route matching behavior to greedy so crossroads will try to match every single route with the supplied request (if true it won't stop at first match).
*/
greedy: boolean;
/**
* Sets if the greedy routes feature is enabled. If false it won't try to match multiple routes (faster).
*/
greedyEnabled: boolean;
/**
* Resets the Router internal state. Will clear reference to previously matched routes (so they won't dispatch switched signal when matching a new route) and reset last request.
*/
resetState(): void;
/**
* Sets if Router should care about previous state, so multiple crossroads.parse() calls passing same argument would not trigger the routed, matched and bypassed signals.
*/
ignoreState: boolean;
/**
* Pipe routers, so all crossroads.parse() calls will be forwarded to the other router as well.
*/
pipe(router: CrossRoadsStatic): void;
/**
* "Ceci n'est pas une pipe"
*/
unpipe(router: CrossRoadsStatic): void;
}
}
declare var crossroads: CrossroadsJs.CrossRoadsStatic;
declare module 'crossroads'{
export = crossroads;
}

View File

@@ -0,0 +1,75 @@
// Type definitions for es6-promise
// Project: https://github.com/jakearchibald/ES6-Promise
// Definitions by: François de Campredon <https://github.com/fdecampredon/>, vvakame <https://github.com/vvakame>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
interface Thenable<T> {
then<U>(onFulfilled?: (value: T) => U | Thenable<U>, onRejected?: (error: any) => U | Thenable<U>): Thenable<U>;
then<U>(onFulfilled?: (value: T) => U | Thenable<U>, onRejected?: (error: any) => void): Thenable<U>;
catch<U>(onRejected?: (error: any) => U | Thenable<U>): Thenable<U>;
}
declare class Promise<T> implements Thenable<T> {
/**
* If you call resolve in the body of the callback passed to the constructor,
* your promise is fulfilled with result object passed to resolve.
* If you call reject your promise is rejected with the object passed to reject.
* For consistency and debugging (eg stack traces), obj should be an instanceof Error.
* Any errors thrown in the constructor callback will be implicitly passed to reject().
*/
constructor(callback: (resolve : (value?: T | Thenable<T>) => void, reject: (error?: any) => void) => void);
/**
* onFulfilled is called when/if "promise" resolves. onRejected is called when/if "promise" rejects.
* Both are optional, if either/both are omitted the next onFulfilled/onRejected in the chain is called.
* Both callbacks have a single parameter , the fulfillment value or rejection reason.
* "then" returns a new promise equivalent to the value you return from onFulfilled/onRejected after being passed through Promise.resolve.
* If an error is thrown in the callback, the returned promise rejects with that error.
*
* @param onFulfilled called when/if "promise" resolves
* @param onRejected called when/if "promise" rejects
*/
then<U>(onFulfilled?: (value: T) => U | Thenable<U>, onRejected?: (error: any) => U | Thenable<U>): Promise<U>;
then<U>(onFulfilled?: (value: T) => U | Thenable<U>, onRejected?: (error: any) => void): Promise<U>;
/**
* Sugar for promise.then(undefined, onRejected)
*
* @param onRejected called when/if "promise" rejects
*/
catch<U>(onRejected?: (error: any) => U | Thenable<U>): Promise<U>;
}
declare module Promise {
/**
* Make a new promise from the thenable.
* A thenable is promise-like in as far as it has a "then" method.
*/
function resolve<T>(value?: T | Thenable<T>): Promise<T>;
/**
* Make a promise that rejects to obj. For consistency and debugging (eg stack traces), obj should be an instanceof Error
*/
function reject(error: any): Promise<any>;
function reject<T>(error: T): Promise<T>;
/**
* Make a promise that fulfills when every item in the array fulfills, and rejects if (and when) any item rejects.
* the array passed to all can be a mixture of promise-like objects and other objects.
* The fulfillment value is an array (in order) of fulfillment values. The rejection value is the first rejection value.
*/
function all<T>(promises: (T | Thenable<T>)[]): Promise<T[]>;
/**
* Make a Promise that fulfills when any item fulfills, and rejects if any item rejects.
*/
function race<T>(promises: (T | Thenable<T>)[]): Promise<T>;
}
declare module 'es6-promise' {
var foo: typeof Promise; // Temp variable to reference Promise in local context
module rsvp {
export var Promise: typeof foo;
}
export = rsvp;
}

View File

@@ -0,0 +1,61 @@
// Type definitions for History.js 1.8.0
// Project: https://github.com/browserstate/history.js
// Definitions by: Boris Yankov <https://github.com/borisyankov/>, Gidon Junge <https://github.com/gjunge/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
interface HistoryAdapter {
bind(element: any, event: string, callback: () => void): void;
trigger(element: any, event: string): void;
onDomLoad(callback: () => void): void;
}
// Since History is defined in lib.d.ts as well
// the name for our interfaces was chosen to be Historyjs
// However at runtime you would need to do
// https://github.com/borisyankov/DefinitelyTyped/issues/277
// var Historyjs: Historyjs = <any>History;
interface Historyjs {
enabled: boolean;
pushState(data: any, title: string, url: string): void;
replaceState(data: any, title: string, url: string): void;
getState(): HistoryState;
getStateByIndex(index: number): HistoryState;
getCurrentIndex(): number;
getHash(): string;
Adapter: HistoryAdapter;
back(): void;
forward(): void;
go(x: Number): void;
log(...messages: any[]): void;
debug(...messages: any[]): void;
options: HistoryOptions;
}
interface HistoryState {
data?: any;
title?: string;
url: string;
}
interface HistoryOptions {
hashChangeInterval?: number;
safariPollInterval?: number;
doubleCheckInterval?: number;
disableSuid?: boolean;
storeInterval?: number;
busyDelay?: number;
debug?: boolean;
initialTitle?: string;
html4Mode?: boolean;
delayInit?: number;
}

View File

@@ -0,0 +1,119 @@
// Type definitions for isomorphic-fetch
// Project: https://github.com/matthew-andrews/isomorphic-fetch
// Definitions by: Todd Lucas <https://github.com/toddlucas>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare enum RequestContext {
"audio", "beacon", "cspreport", "download", "embed", "eventsource",
"favicon", "fetch", "font", "form", "frame", "hyperlink", "iframe",
"image", "imageset", "import", "internal", "location", "manifest",
"object", "ping", "plugin", "prefetch", "script", "serviceworker",
"sharedworker", "subresource", "style", "track", "video", "worker",
"xmlhttprequest", "xslt"
}
declare enum RequestMode { "same-origin", "no-cors", "cors" }
declare enum RequestCredentials { "omit", "same-origin", "include" }
declare enum RequestCache {
"default", "no-store", "reload", "no-cache", "force-cache",
"only-if-cached"
}
declare enum ResponseType { "basic", "cors", "default", "error", "opaque" }
declare type HeaderInit = Headers | Array<string>;
declare type BodyInit = ArrayBuffer | ArrayBufferView | Blob | FormData | string;
declare type RequestInfo = Request | string;
interface RequestInit {
method?: string;
headers?: HeaderInit | { [index: string]: string };
body?: BodyInit;
mode?: string | RequestMode;
credentials?: string | RequestCredentials;
cache?: string | RequestCache;
}
interface IHeaders {
get(name: string): string;
getAll(name: string): Array<string>;
has(name: string): boolean;
}
declare class Headers implements IHeaders {
append(name: string, value: string): void;
delete(name: string):void;
get(name: string): string;
getAll(name: string): Array<string>;
has(name: string): boolean;
set(name: string, value: string): void;
}
interface IBody {
bodyUsed: boolean;
arrayBuffer(): Promise<ArrayBuffer>;
blob(): Promise<Blob>;
formData(): Promise<FormData>;
json(): Promise<any>;
json<T>(): Promise<T>;
text(): Promise<string>;
}
declare class Body implements IBody {
bodyUsed: boolean;
arrayBuffer(): Promise<ArrayBuffer>;
blob(): Promise<Blob>;
formData(): Promise<FormData>;
json(): Promise<any>;
json<T>(): Promise<T>;
text(): Promise<string>;
}
interface IRequest extends IBody {
method: string;
url: string;
headers: Headers;
context: string | RequestContext;
referrer: string;
mode: string | RequestMode;
credentials: string | RequestCredentials;
cache: string | RequestCache;
}
declare class Request extends Body implements IRequest {
constructor(input: string | Request, init?: RequestInit);
method: string;
url: string;
headers: Headers;
context: string | RequestContext;
referrer: string;
mode: string | RequestMode;
credentials: string | RequestCredentials;
cache: string | RequestCache;
}
interface IResponse extends IBody {
url: string;
status: number;
statusText: string;
ok: boolean;
headers: IHeaders;
type: string | ResponseType;
size: number;
timeout: number;
redirect(url: string, status: number): IResponse;
error(): IResponse;
clone(): IResponse;
}
interface IFetchStatic {
Promise: any;
Headers: IHeaders
Request: IRequest;
Response: IResponse;
(url: string | IRequest, init?: RequestInit): Promise<IResponse>;
}
declare var fetch: IFetchStatic;
declare module "isomorphic-fetch" {
export = fetch;
}

View File

@@ -0,0 +1,110 @@
// Type definitions for JS-Signals
// Project: http://millermedeiros.github.io/js-signals/
// Definitions by: Diullei Gomes <https://github.com/diullei>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare var signals: SignalWrapper;
declare module "signals" {
export = signals;
}
interface SignalWrapper {
Signal: Signal
}
interface SignalBinding {
active: boolean;
context: any;
params: any;
detach(): Function;
execute(paramsArr?:any[]): any;
getListener(): Function;
getSignal(): Signal;
isBound(): boolean;
isOnce(): boolean;
}
interface Signal {
/**
* Custom event broadcaster
* <br />- inspired by Robert Penner's AS3 Signals.
* @name Signal
* @author Miller Medeiros
* @constructor
*/
new(): Signal;
/**
* If Signal is active and should broadcast events.
*/
active: boolean;
/**
* If Signal should keep record of previously dispatched parameters and automatically
* execute listener during add()/addOnce() if Signal was already dispatched before.
*/
memorize: boolean;
/**
* Signals Version Number
*/
VERSION: string;
/**
* Add a listener to the signal.
*
* @param listener Signal handler function.
* @param listenercontext Context on which listener will be executed (object that should represent the `this` variable inside listener function).
* @param priority The priority level of the event listener. Listeners with higher priority will be executed before listeners with lower priority. Listeners with same priority level will be executed at the same order as they were added. (default = 0)
*/
add(listener: Function, listenerContext?: any, priority?: Number): SignalBinding;
/**
* Add listener to the signal that should be removed after first execution (will be executed only once).
*
* @param listener Signal handler function.
* @param listenercontext Context on which listener will be executed (object that should represent the `this` variable inside listener function).
* @param priority The priority level of the event listener. Listeners with higher priority will be executed before listeners with lower priority. Listeners with same priority level will be executed at the same order as they were added. (default = 0)
*/
addOnce(listener: Function, listenerContext?: any, priority?: Number): SignalBinding;
/**
* Dispatch/Broadcast Signal to all listeners added to the queue.
*
* @param params Parameters that should be passed to each handler.
*/
dispatch(...params: any[]): void;
/**
* Remove all bindings from signal and destroy any reference to external objects (destroy Signal object).
*/
dispose(): void;
/**
* Forget memorized arguments.
*/
forget(): void;
/**
* Returns a number of listeners attached to the Signal.
*/
getNumListeners(): number;
/**
* Stop propagation of the event, blocking the dispatch to next listeners on the queue.
*/
halt(): void;
/**
* Check if listener was attached to Signal.
*/
has(listener: Function, context?: any): boolean;
/**
* Remove a single listener from the dispatch queue.
*/
remove(listener: Function, context?: any): Function;
removeAll(): void;
}

View File

@@ -0,0 +1,631 @@
// Type definitions for Knockout v3.2.0
// Project: http://knockoutjs.com
// Definitions by: Boris Yankov <https://github.com/borisyankov/>, Igor Oleinikov <https://github.com/Igorbek/>, Clément Bourgeois <https://github.com/moonpyk/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
interface KnockoutSubscribableFunctions<T> {
[key: string]: KnockoutBindingHandler;
notifySubscribers(valueToWrite?: T, event?: string): void;
}
interface KnockoutComputedFunctions<T> {
[key: string]: KnockoutBindingHandler;
}
interface KnockoutObservableFunctions<T> {
[key: string]: KnockoutBindingHandler;
equalityComparer(a: any, b: any): boolean;
}
interface KnockoutObservableArrayFunctions<T> {
// General Array functions
indexOf(searchElement: T, fromIndex?: number): number;
slice(start: number, end?: number): T[];
splice(start: number): T[];
splice(start: number, deleteCount: number, ...items: T[]): T[];
pop(): T;
push(...items: T[]): void;
shift(): T;
unshift(...items: T[]): number;
reverse(): KnockoutObservableArray<T>;
sort(): KnockoutObservableArray<T>;
sort(compareFunction: (left: T, right: T) => number): KnockoutObservableArray<T>;
// Ko specific
[key: string]: KnockoutBindingHandler;
replace(oldItem: T, newItem: T): void;
remove(item: T): T[];
remove(removeFunction: (item: T) => boolean): T[];
removeAll(items: T[]): T[];
removeAll(): T[];
destroy(item: T): void;
destroy(destroyFunction: (item: T) => boolean): void;
destroyAll(items: T[]): void;
destroyAll(): void;
}
interface KnockoutSubscribableStatic {
fn: KnockoutSubscribableFunctions<any>;
new <T>(): KnockoutSubscribable<T>;
}
interface KnockoutSubscription {
dispose(): void;
}
interface KnockoutSubscribable<T> extends KnockoutSubscribableFunctions<T> {
subscribe(callback: (newValue: T) => void, target?: any, event?: string): KnockoutSubscription;
subscribe<TEvent>(callback: (newValue: TEvent) => void, target: any, event: string): KnockoutSubscription;
extend(requestedExtenders: { [key: string]: any; }): KnockoutSubscribable<T>;
getSubscriptionsCount(): number;
}
interface KnockoutComputedStatic {
fn: KnockoutComputedFunctions<any>;
<T>(): KnockoutComputed<T>;
<T>(func: () => T, context?: any, options?: any): KnockoutComputed<T>;
<T>(def: KnockoutComputedDefine<T>, context?: any): KnockoutComputed<T>;
}
interface KnockoutComputed<T> extends KnockoutObservable<T>, KnockoutComputedFunctions<T> {
fn: KnockoutComputedFunctions<any>;
dispose(): void;
isActive(): boolean;
getDependenciesCount(): number;
extend(requestedExtenders: { [key: string]: any; }): KnockoutComputed<T>;
}
interface KnockoutObservableArrayStatic {
fn: KnockoutObservableArrayFunctions<any>;
<T>(value?: T[]): KnockoutObservableArray<T>;
}
interface KnockoutObservableArray<T> extends KnockoutObservable<T[]>, KnockoutObservableArrayFunctions<T> {
extend(requestedExtenders: { [key: string]: any; }): KnockoutObservableArray<T>;
}
interface KnockoutObservableStatic {
fn: KnockoutObservableFunctions<any>;
<T>(value?: T): KnockoutObservable<T>;
}
interface KnockoutObservable<T> extends KnockoutSubscribable<T>, KnockoutObservableFunctions<T> {
(): T;
(value: T): void;
peek(): T;
valueHasMutated?:{(): void;};
valueWillMutate?:{(): void;};
extend(requestedExtenders: { [key: string]: any; }): KnockoutObservable<T>;
}
interface KnockoutComputedDefine<T> {
read(): T;
write? (value: T): void;
disposeWhenNodeIsRemoved?: Node;
disposeWhen? (): boolean;
owner?: any;
deferEvaluation?: boolean;
pure?: boolean;
}
interface KnockoutBindingContext {
$parent: any;
$parents: any[];
$root: any;
$data: any;
$rawData: any | KnockoutObservable<any>;
$index?: KnockoutObservable<number>;
$parentContext?: KnockoutBindingContext;
$component: any;
$componentTemplateNodes: Node[];
extend(properties: any): any;
createChildContext(dataItemOrAccessor: any, dataItemAlias?: any, extendCallback?: Function): any;
}
interface KnockoutAllBindingsAccessor {
(): any;
get(name: string): any;
has(name: string): boolean;
}
interface KnockoutBindingHandler {
after?: Array<string>;
init?: (element: any, valueAccessor: () => any, allBindingsAccessor?: KnockoutAllBindingsAccessor, viewModel?: any, bindingContext?: KnockoutBindingContext) => void | { controlsDescendantBindings: boolean; };
update?: (element: any, valueAccessor: () => any, allBindingsAccessor?: KnockoutAllBindingsAccessor, viewModel?: any, bindingContext?: KnockoutBindingContext) => void;
options?: any;
preprocess?: (value: string, name: string, addBindingCallback?: (name: string, value: string) => void) => string;
}
interface KnockoutBindingHandlers {
[bindingHandler: string]: KnockoutBindingHandler;
// Controlling text and appearance
visible: KnockoutBindingHandler;
text: KnockoutBindingHandler;
html: KnockoutBindingHandler;
css: KnockoutBindingHandler;
style: KnockoutBindingHandler;
attr: KnockoutBindingHandler;
// Control Flow
foreach: KnockoutBindingHandler;
if: KnockoutBindingHandler;
ifnot: KnockoutBindingHandler;
with: KnockoutBindingHandler;
// Working with form fields
click: KnockoutBindingHandler;
event: KnockoutBindingHandler;
submit: KnockoutBindingHandler;
enable: KnockoutBindingHandler;
disable: KnockoutBindingHandler;
value: KnockoutBindingHandler;
textInput: KnockoutBindingHandler;
hasfocus: KnockoutBindingHandler;
checked: KnockoutBindingHandler;
options: KnockoutBindingHandler;
selectedOptions: KnockoutBindingHandler;
uniqueName: KnockoutBindingHandler;
// Rendering templates
template: KnockoutBindingHandler;
// Components (new for v3.2)
component: KnockoutBindingHandler;
}
interface KnockoutMemoization {
memoize(callback: () => string): string;
unmemoize(memoId: string, callbackParams: any[]): boolean;
unmemoizeDomNodeAndDescendants(domNode: any, extraCallbackParamsArray: any[]): boolean;
parseMemoText(memoText: string): string;
}
interface KnockoutVirtualElement {}
interface KnockoutVirtualElements {
allowedBindings: { [bindingName: string]: boolean; };
emptyNode(node: KnockoutVirtualElement ): void;
firstChild(node: KnockoutVirtualElement ): KnockoutVirtualElement;
insertAfter( container: KnockoutVirtualElement, nodeToInsert: Node, insertAfter: Node ): void;
nextSibling(node: KnockoutVirtualElement): Node;
prepend(node: KnockoutVirtualElement, toInsert: Node ): void;
setDomNodeChildren(node: KnockoutVirtualElement, newChildren: { length: number;[index: number]: Node; } ): void;
childNodes(node: KnockoutVirtualElement ): Node[];
}
interface KnockoutExtenders {
throttle(target: any, timeout: number): KnockoutComputed<any>;
notify(target: any, notifyWhen: string): any;
rateLimit(target: any, timeout: number): any;
rateLimit(target: any, options: { timeout: number; method?: string; }): any;
trackArrayChanges(target: any): any;
}
//
// NOTE TO MAINTAINERS AND CONTRIBUTORS : pay attention to only include symbols that are
// publicly exported in the minified version of ko, without that you can give the false
// impression that some functions will be available in production builds.
//
interface KnockoutUtils {
//////////////////////////////////
// utils.domData.js
//////////////////////////////////
domData: {
get (node: Element, key: string): any;
set (node: Element, key: string, value: any): void;
getAll(node: Element, createIfNotFound: boolean): any;
clear(node: Element): boolean;
};
//////////////////////////////////
// utils.domNodeDisposal.js
//////////////////////////////////
domNodeDisposal: {
addDisposeCallback(node: Element, callback: Function): void;
removeDisposeCallback(node: Element, callback: Function): void;
cleanNode(node: Node): Element;
removeNode(node: Node): void;
};
addOrRemoveItem<T>(array: T[] | KnockoutObservable<T>, value: T, included: T): void;
arrayFilter<T>(array: T[], predicate: (item: T) => boolean): T[];
arrayFirst<T>(array: T[], predicate: (item: T) => boolean, predicateOwner?: any): T;
arrayForEach<T>(array: T[], action: (item: T, index: number) => void): void;
arrayGetDistinctValues<T>(array: T[]): T[];
arrayIndexOf<T>(array: T[], item: T): number;
arrayMap<T, U>(array: T[], mapping: (item: T) => U): U[];
arrayPushAll<T>(array: T[] | KnockoutObservableArray<T>, valuesToPush: T[]): T[];
arrayRemoveItem(array: any[], itemToRemove: any): void;
compareArrays<T>(a: T[], b: T[]): Array<KnockoutArrayChange<T>>;
extend(target: Object, source: Object): Object;
fieldsIncludedWithJsonPost: any[];
getFormFields(form: any, fieldName: string): any[];
objectForEach(obj: any, action: (key: any, value: any) => void): void;
parseHtmlFragment(html: string): any[];
parseJson(jsonString: string): any;
postJson(urlOrForm: any, data: any, options: any): void;
peekObservable<T>(value: KnockoutObservable<T>): T;
range(min: any, max: any): any;
registerEventHandler(element: any, eventType: any, handler: Function): void;
setHtml(node: Element, html: () => string): void;
setHtml(node: Element, html: string): void;
setTextContent(element: any, textContent: string | KnockoutObservable<string>): void;
stringifyJson(data: any, replacer?: Function, space?: string): string;
toggleDomNodeCssClass(node: any, className: string, shouldHaveClass: boolean): void;
triggerEvent(element: any, eventType: any): void;
unwrapObservable<T>(value: KnockoutObservable<T> | T): T;
// NOT PART OF THE MINIFIED API SURFACE (ONLY IN knockout-{version}.debug.js) https://github.com/SteveSanderson/knockout/issues/670
// forceRefresh(node: any): void;
// ieVersion: number;
// isIe6: boolean;
// isIe7: boolean;
// jQueryHtmlParse(html: string): any[];
// makeArray(arrayLikeObject: any): any[];
// moveCleanedNodesToContainerElement(nodes: any[]): HTMLElement;
// replaceDomNodes(nodeToReplaceOrNodeArray: any, newNodesArray: any[]): void;
// setDomNodeChildren(domNode: any, childNodes: any[]): void;
// setElementName(element: any, name: string): void;
// setOptionNodeSelectionState(optionNode: any, isSelected: boolean): void;
// simpleHtmlParse(html: string): any[];
// stringStartsWith(str: string, startsWith: string): boolean;
// stringTokenize(str: string, delimiter: string): string[];
// stringTrim(str: string): string;
// tagNameLower(element: any): string;
}
interface KnockoutArrayChange<T> {
status: string;
value: T;
index: number;
moved?: number;
}
//////////////////////////////////
// templateSources.js
//////////////////////////////////
interface KnockoutTemplateSourcesDomElement {
text(): any;
text(value: any): void;
data(key: string): any;
data(key: string, value: any): any;
}
interface KnockoutTemplateAnonymous extends KnockoutTemplateSourcesDomElement {
nodes(): any;
nodes(value: any): void;
}
interface KnockoutTemplateSources {
domElement: {
prototype: KnockoutTemplateSourcesDomElement
new (element: Element): KnockoutTemplateSourcesDomElement
};
anonymousTemplate: {
prototype: KnockoutTemplateAnonymous;
new (element: Element): KnockoutTemplateAnonymous;
};
}
//////////////////////////////////
// nativeTemplateEngine.js
//////////////////////////////////
interface KnockoutNativeTemplateEngine {
renderTemplateSource(templateSource: Object, bindingContext?: KnockoutBindingContext, options?: Object): any[];
}
//////////////////////////////////
// templateEngine.js
//////////////////////////////////
interface KnockoutTemplateEngine extends KnockoutNativeTemplateEngine {
createJavaScriptEvaluatorBlock(script: string): string;
makeTemplateSource(template: any, templateDocument?: Document): any;
renderTemplate(template: any, bindingContext: KnockoutBindingContext, options: Object, templateDocument: Document): any;
isTemplateRewritten(template: any, templateDocument: Document): boolean;
rewriteTemplate(template: any, rewriterCallback: Function, templateDocument: Document): void;
}
/////////////////////////////////
interface KnockoutStatic {
utils: KnockoutUtils;
memoization: KnockoutMemoization;
bindingHandlers: KnockoutBindingHandlers;
getBindingHandler(handler: string): KnockoutBindingHandler;
virtualElements: KnockoutVirtualElements;
extenders: KnockoutExtenders;
applyBindings(viewModelOrBindingContext?: any, rootNode?: any): void;
applyBindingsToDescendants(viewModelOrBindingContext: any, rootNode: any): void;
applyBindingAccessorsToNode(node: Node, bindings: (bindingContext: KnockoutBindingContext, node: Node) => {}, bindingContext: KnockoutBindingContext): void;
applyBindingAccessorsToNode(node: Node, bindings: {}, bindingContext: KnockoutBindingContext): void;
applyBindingAccessorsToNode(node: Node, bindings: (bindingContext: KnockoutBindingContext, node: Node) => {}, viewModel: any): void;
applyBindingAccessorsToNode(node: Node, bindings: {}, viewModel: any): void;
applyBindingsToNode(node: Node, bindings: any, viewModelOrBindingContext?: any): any;
subscribable: KnockoutSubscribableStatic;
observable: KnockoutObservableStatic;
computed: KnockoutComputedStatic;
pureComputed<T>(evaluatorFunction: () => T, context?: any): KnockoutComputed<T>;
pureComputed<T>(options: KnockoutComputedDefine<T>, context?: any): KnockoutComputed<T>;
observableArray: KnockoutObservableArrayStatic;
contextFor(node: any): any;
isSubscribable(instance: any): boolean;
toJSON(viewModel: any, replacer?: Function, space?: any): string;
toJS(viewModel: any): any;
isObservable(instance: any): boolean;
isWriteableObservable(instance: any): boolean;
isComputed(instance: any): boolean;
dataFor(node: any): any;
removeNode(node: Element): void;
cleanNode(node: Element): Element;
renderTemplate(template: Function, viewModel: any, options?: any, target?: any, renderMode?: any): any;
renderTemplate(template: string, viewModel: any, options?: any, target?: any, renderMode?: any): any;
unwrap<T>(value: KnockoutObservable<T> | T): T;
computedContext: KnockoutComputedContext;
//////////////////////////////////
// templateSources.js
//////////////////////////////////
templateSources: KnockoutTemplateSources;
//////////////////////////////////
// templateEngine.js
//////////////////////////////////
templateEngine: {
prototype: KnockoutTemplateEngine;
new (): KnockoutTemplateEngine;
};
//////////////////////////////////
// templateRewriting.js
//////////////////////////////////
templateRewriting: {
ensureTemplateIsRewritten(template: Node, templateEngine: KnockoutTemplateEngine, templateDocument: Document): any;
ensureTemplateIsRewritten(template: string, templateEngine: KnockoutTemplateEngine, templateDocument: Document): any;
memoizeBindingAttributeSyntax(htmlString: string, templateEngine: KnockoutTemplateEngine): any;
applyMemoizedBindingsToNextSibling(bindings: any, nodeName: string): string;
};
//////////////////////////////////
// nativeTemplateEngine.js
//////////////////////////////////
nativeTemplateEngine: {
prototype: KnockoutNativeTemplateEngine;
new (): KnockoutNativeTemplateEngine;
instance: KnockoutNativeTemplateEngine;
};
//////////////////////////////////
// jqueryTmplTemplateEngine.js
//////////////////////////////////
jqueryTmplTemplateEngine: {
prototype: KnockoutTemplateEngine;
renderTemplateSource(templateSource: Object, bindingContext: KnockoutBindingContext, options: Object): Node[];
createJavaScriptEvaluatorBlock(script: string): string;
addTemplate(templateName: string, templateMarkup: string): void;
};
//////////////////////////////////
// templating.js
//////////////////////////////////
setTemplateEngine(templateEngine: KnockoutNativeTemplateEngine): void;
renderTemplate(template: Function, dataOrBindingContext: KnockoutBindingContext, options: Object, targetNodeOrNodeArray: Node, renderMode: string): any;
renderTemplate(template: any, dataOrBindingContext: KnockoutBindingContext, options: Object, targetNodeOrNodeArray: Node, renderMode: string): any;
renderTemplate(template: Function, dataOrBindingContext: any, options: Object, targetNodeOrNodeArray: Node, renderMode: string): any;
renderTemplate(template: any, dataOrBindingContext: any, options: Object, targetNodeOrNodeArray: Node, renderMode: string): any;
renderTemplate(template: Function, dataOrBindingContext: KnockoutBindingContext, options: Object, targetNodeOrNodeArray: Node[], renderMode: string): any;
renderTemplate(template: any, dataOrBindingContext: KnockoutBindingContext, options: Object, targetNodeOrNodeArray: Node[], renderMode: string): any;
renderTemplate(template: Function, dataOrBindingContext: any, options: Object, targetNodeOrNodeArray: Node[], renderMode: string): any;
renderTemplate(template: any, dataOrBindingContext: any, options: Object, targetNodeOrNodeArray: Node[], renderMode: string): any;
renderTemplateForEach(template: Function, arrayOrObservableArray: any[], options: Object, targetNode: Node, parentBindingContext: KnockoutBindingContext): any;
renderTemplateForEach(template: any, arrayOrObservableArray: any[], options: Object, targetNode: Node, parentBindingContext: KnockoutBindingContext): any;
renderTemplateForEach(template: Function, arrayOrObservableArray: KnockoutObservable<any>, options: Object, targetNode: Node, parentBindingContext: KnockoutBindingContext): any;
renderTemplateForEach(template: any, arrayOrObservableArray: KnockoutObservable<any>, options: Object, targetNode: Node, parentBindingContext: KnockoutBindingContext): any;
expressionRewriting: {
bindingRewriteValidators: any;
parseObjectLiteral: { (objectLiteralString: string): any[] }
};
/////////////////////////////////
bindingProvider: {
instance: KnockoutBindingProvider;
new (): KnockoutBindingProvider;
}
/////////////////////////////////
// selectExtensions.js
/////////////////////////////////
selectExtensions: {
readValue(element: HTMLElement): any;
writeValue(element: HTMLElement, value: any): void;
};
components: KnockoutComponents;
}
interface KnockoutBindingProvider {
nodeHasBindings(node: Node): boolean;
getBindings(node: Node, bindingContext: KnockoutBindingContext): {};
getBindingAccessors?(node: Node, bindingContext: KnockoutBindingContext): { [key: string]: string; };
}
interface KnockoutComputedContext {
getDependenciesCount(): number;
isInitial: () => boolean;
isSleeping: boolean;
}
//
// refactored types into a namespace to reduce global pollution
// and used Union Types to simplify overloads (requires TypeScript 1.4)
//
declare module KnockoutComponentTypes {
interface Config {
viewModel?: ViewModelFunction | ViewModelSharedInstance | ViewModelFactoryFunction | AMDModule;
template: string | Node[]| DocumentFragment | TemplateElement | AMDModule;
synchronous?: boolean;
}
interface ComponentConfig {
viewModel?: ViewModelFunction | ViewModelSharedInstance | ViewModelFactoryFunction | AMDModule;
template: any;
createViewModel?: any;
}
interface EmptyConfig {
}
// common AMD type
interface AMDModule {
require: string;
}
// viewmodel types
interface ViewModelFunction {
(params?: any): any;
}
interface ViewModelSharedInstance {
instance: any;
}
interface ViewModelFactoryFunction {
createViewModel: (params?: any, componentInfo?: ComponentInfo) => any;
}
interface ComponentInfo {
element: Node;
templateNodes: Node[];
}
interface TemplateElement {
element: string | Node;
}
interface Loader {
getConfig? (componentName: string, callback: (result: ComponentConfig) => void): void;
loadComponent? (componentName: string, config: ComponentConfig, callback: (result: Definition) => void): void;
loadTemplate? (componentName: string, templateConfig: any, callback: (result: Node[]) => void): void;
loadViewModel? (componentName: string, viewModelConfig: any, callback: (result: any) => void): void;
suppressLoaderExceptions?: boolean;
}
interface Definition {
template: Node[];
createViewModel? (params: any, options: { element: Node; }): any;
}
}
interface KnockoutComponents {
// overloads for register method:
register(componentName: string, config: KnockoutComponentTypes.Config | KnockoutComponentTypes.EmptyConfig): void;
isRegistered(componentName: string): boolean;
unregister(componentName: string): void;
get(componentName: string, callback: (definition: KnockoutComponentTypes.Definition) => void): void;
clearCachedDefinition(componentName: string): void
defaultLoader: KnockoutComponentTypes.Loader;
loaders: KnockoutComponentTypes.Loader[];
getComponentNameForNode(node: Node): string;
}
declare var ko: KnockoutStatic;
declare module "knockout" {
export = ko;
}

View File

@@ -0,0 +1,233 @@
// Type definitions for history v2.0.0
// Project: https://github.com/rackt/history
// Definitions by: Sergey Buturlakin <https://github.com/sergey-buturlakin>, Nathan Brown <https://github.com/ngbrown>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare namespace HistoryModule {
// types based on https://github.com/rackt/history/blob/master/docs/Terms.md
type Action = string
type BeforeUnloadHook = () => string | boolean
type CreateHistory<T> = (options?: HistoryOptions) => T
type CreateHistoryEnhancer<T, E> = (createHistory: CreateHistory<T>) => CreateHistory<T & E>
interface History {
listenBefore(hook: TransitionHook): () => void
listen(listener: LocationListener): () => void
transitionTo(location: Location): void
push(path: LocationDescriptor): void
replace(path: LocationDescriptor): void
go(n: number): void
goBack(): void
goForward(): void
createKey(): LocationKey
createPath(path: LocationDescriptor): Path
createHref(path: LocationDescriptor): Href
createLocation(path?: LocationDescriptor, action?: Action, key?: LocationKey): Location
/** @deprecated use a location descriptor instead */
createLocation(path?: Path, state?: LocationState, action?: Action, key?: LocationKey): Location
/** @deprecated use location.key to save state instead */
pushState(state: LocationState, path: Path): void
/** @deprecated use location.key to save state instead */
replaceState(state: LocationState, path: Path): void
/** @deprecated use location.key to save state instead */
setState(state: LocationState): void
/** @deprecated use listenBefore instead */
registerTransitionHook(hook: TransitionHook): void
/** @deprecated use the callback returned from listenBefore instead */
unregisterTransitionHook(hook: TransitionHook): void
}
type HistoryOptions = {
getCurrentLocation?: () => Location
finishTransition?: (nextLocation: Location) => boolean
saveState?: (key: LocationKey, state: LocationState) => void
go?: (n: number) => void
getUserConfirmation?: (message: string, callback: (result: boolean) => void) => void
keyLength?: number
queryKey?: string | boolean
stringifyQuery?: (obj: any) => string
parseQueryString?: (str: string) => any
basename?: string
entries?: string | [any]
current?: number
}
type Href = string
type Location = {
pathname: Pathname
search: Search
query: Query
state: LocationState
action: Action
key: LocationKey
basename?: string
}
type LocationDescriptorObject = {
pathname?: Pathname
search?: Search
query?: Query
state?: LocationState
}
type LocationDescriptor = LocationDescriptorObject | Path
type LocationKey = string
type LocationListener = (location: Location) => void
type LocationState = Object
type Path = string // Pathname + QueryString
type Pathname = string
type Query = Object
type QueryString = string
type Search = string
type TransitionHook = (location: Location, callback: (result: any) => void) => any
interface HistoryBeforeUnload {
listenBeforeUnload(hook: BeforeUnloadHook): () => void
}
interface HistoryQueries {
pushState(state: LocationState, pathname: Pathname | Path, query?: Query): void
replaceState(state: LocationState, pathname: Pathname | Path, query?: Query): void
createPath(path: Path, query?: Query): Path
createHref(path: Path, query?: Query): Href
}
// Global usage, without modules, needs the small trick, because lib.d.ts
// already has `history` and `History` global definitions:
// var createHistory = ((window as any).History as HistoryModule.Module).createHistory;
interface Module {
createHistory: CreateHistory<History>
createHashHistory: CreateHistory<History>
createMemoryHistory: CreateHistory<History>
createLocation(path?: Path, state?: LocationState, action?: Action, key?: LocationKey): Location
useBasename<T>(createHistory: CreateHistory<T>): CreateHistory<T>
useBeforeUnload<T>(createHistory: CreateHistory<T>): CreateHistory<T & HistoryBeforeUnload>
useQueries<T>(createHistory: CreateHistory<T>): CreateHistory<T & HistoryQueries>
actions: {
PUSH: string
REPLACE: string
POP: string
}
}
}
declare module "history/lib/createBrowserHistory" {
export default function createBrowserHistory(options?: HistoryModule.HistoryOptions): HistoryModule.History
}
declare module "history/lib/createHashHistory" {
export default function createHashHistory(options?: HistoryModule.HistoryOptions): HistoryModule.History
}
declare module "history/lib/createMemoryHistory" {
export default function createMemoryHistory(options?: HistoryModule.HistoryOptions): HistoryModule.History
}
declare module "history/lib/createLocation" {
export default function createLocation(path?: HistoryModule.Path, state?: HistoryModule.LocationState, action?: HistoryModule.Action, key?: HistoryModule.LocationKey): HistoryModule.Location
}
declare module "history/lib/useBasename" {
export default function useBasename<T>(createHistory: HistoryModule.CreateHistory<T>): HistoryModule.CreateHistory<T>
}
declare module "history/lib/useBeforeUnload" {
export default function useBeforeUnload<T>(createHistory: HistoryModule.CreateHistory<T>): HistoryModule.CreateHistory<T & HistoryModule.HistoryBeforeUnload>
}
declare module "history/lib/useQueries" {
export default function useQueries<T>(createHistory: HistoryModule.CreateHistory<T>): HistoryModule.CreateHistory<T & HistoryModule.HistoryQueries>
}
declare module "history/lib/actions" {
export const PUSH: string
export const REPLACE: string
export const POP: string
export default {
PUSH,
REPLACE,
POP
}
}
declare module "history/lib/DOMUtils" {
export function addEventListener(node: EventTarget, event: string, listener: EventListenerOrEventListenerObject): void;
export function removeEventListener(node: EventTarget, event: string, listener: EventListenerOrEventListenerObject): void;
export function getHashPath(): string;
export function replaceHashPath(path: string): void;
export function getWindowPath(): string;
export function go(n: number): void;
export function getUserConfirmation(message: string, callback: (result: boolean) => void): void;
export function supportsHistory(): boolean;
export function supportsGoWithoutReloadUsingHash(): boolean;
}
declare module "history" {
export { default as createHistory } from "history/lib/createBrowserHistory"
export { default as createHashHistory } from "history/lib/createHashHistory"
export { default as createMemoryHistory } from "history/lib/createMemoryHistory"
export { default as createLocation } from "history/lib/createLocation"
export { default as useBasename } from "history/lib/useBasename"
export { default as useBeforeUnload } from "history/lib/useBeforeUnload"
export { default as useQueries } from "history/lib/useQueries"
import * as Actions from "history/lib/actions"
export { Actions }
}

View File

@@ -0,0 +1,397 @@
// Type definitions for RequireJS 2.1.20
// Project: http://requirejs.org/
// Definitions by: Josh Baldwin <https://github.com/jbaldwin/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/*
require-2.1.8.d.ts may be freely distributed under the MIT license.
Copyright (c) 2013 Josh Baldwin https://github.com/jbaldwin/require.d.ts
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
*/
declare module 'module' {
var mod: {
config: () => any;
id: string;
uri: string;
}
export = mod;
}
interface RequireError extends Error {
/**
* The error ID that maps to an ID on a web page.
**/
requireType: string;
/**
* Required modules.
**/
requireModules: string[];
/**
* The original error, if there is one (might be null).
**/
originalError: Error;
}
interface RequireShim {
/**
* List of dependencies.
**/
deps?: string[];
/**
* Name the module will be exported as.
**/
exports?: string;
/**
* Initialize function with all dependcies passed in,
* if the function returns a value then that value is used
* as the module export value instead of the object
* found via the 'exports' string.
* @param dependencies
* @return
**/
init?: (...dependencies: any[]) => any;
}
interface RequireConfig {
// The root path to use for all module lookups.
baseUrl?: string;
// Path mappings for module names not found directly under
// baseUrl.
paths?: { [key: string]: any; };
// Dictionary of Shim's.
// does not cover case of key->string[]
shim?: { [key: string]: RequireShim; };
/**
* For the given module prefix, instead of loading the
* module with the given ID, substitude a different
* module ID.
*
* @example
* requirejs.config({
* map: {
* 'some/newmodule': {
* 'foo': 'foo1.2'
* },
* 'some/oldmodule': {
* 'foo': 'foo1.0'
* }
* }
* });
**/
map?: {
[id: string]: {
[id: string]: string;
};
};
/**
* Allows pointing multiple module IDs to a module ID that contains a bundle of modules.
*
* @example
* requirejs.config({
* bundles: {
* 'primary': ['main', 'util', 'text', 'text!template.html'],
* 'secondary': ['text!secondary.html']
* }
* });
**/
bundles?: { [key: string]: string[]; };
/**
* AMD configurations, use module.config() to access in
* define() functions
**/
config?: { [id: string]: {}; };
/**
* Configures loading modules from CommonJS packages.
**/
packages?: {};
/**
* The number of seconds to wait before giving up on loading
* a script. The default is 7 seconds.
**/
waitSeconds?: number;
/**
* A name to give to a loading context. This allows require.js
* to load multiple versions of modules in a page, as long as
* each top-level require call specifies a unique context string.
**/
context?: string;
/**
* An array of dependencies to load.
**/
deps?: string[];
/**
* A function to pass to require that should be require after
* deps have been loaded.
* @param modules
**/
callback?: (...modules: any[]) => void;
/**
* If set to true, an error will be thrown if a script loads
* that does not call define() or have shim exports string
* value that can be checked.
**/
enforceDefine?: boolean;
/**
* If set to true, document.createElementNS() will be used
* to create script elements.
**/
xhtml?: boolean;
/**
* Extra query string arguments appended to URLs that RequireJS
* uses to fetch resources. Most useful to cache bust when
* the browser or server is not configured correctly.
*
* @example
* urlArgs: "bust= + (new Date()).getTime()
**/
urlArgs?: string;
/**
* Specify the value for the type="" attribute used for script
* tags inserted into the document by RequireJS. Default is
* "text/javascript". To use Firefox's JavasScript 1.8
* features, use "text/javascript;version=1.8".
**/
scriptType?: string;
/**
* If set to true, skips the data-main attribute scanning done
* to start module loading. Useful if RequireJS is embedded in
* a utility library that may interact with other RequireJS
* library on the page, and the embedded version should not do
* data-main loading.
**/
skipDataMain?: boolean;
/**
* Allow extending requirejs to support Subresource Integrity
* (SRI).
**/
onNodeCreated?: (node: HTMLScriptElement, config: RequireConfig, moduleName: string, url: string) => void;
}
// todo: not sure what to do with this guy
interface RequireModule {
/**
*
**/
config(): {};
}
/**
*
**/
interface RequireMap {
/**
*
**/
prefix: string;
/**
*
**/
name: string;
/**
*
**/
parentMap: RequireMap;
/**
*
**/
url: string;
/**
*
**/
originalName: string;
/**
*
**/
fullName: string;
}
interface Require {
/**
* Configure require.js
**/
config(config: RequireConfig): Require;
/**
* CommonJS require call
* @param module Module to load
* @return The loaded module
*/
(module: string): any;
/**
* Start the main app logic.
* Callback is optional.
* Can alternatively use deps and callback.
* @param modules Required modules to load.
**/
(modules: string[]): void;
/**
* @see Require()
* @param ready Called when required modules are ready.
**/
(modules: string[], ready: Function): void;
/**
* @see http://requirejs.org/docs/api.html#errbacks
* @param ready Called when required modules are ready.
**/
(modules: string[], ready: Function, errback: Function): void;
/**
* Generate URLs from require module
* @param module Module to URL
* @return URL string
**/
toUrl(module: string): string;
/**
* Returns true if the module has already been loaded and defined.
* @param module Module to check
**/
defined(module: string): boolean;
/**
* Returns true if the module has already been requested or is in the process of loading and should be available at some point.
* @param module Module to check
**/
specified(module: string): boolean;
/**
* On Error override
* @param err
**/
onError(err: RequireError, errback?: (err: RequireError) => void): void;
/**
* Undefine a module
* @param module Module to undefine.
**/
undef(module: string): void;
/**
* Semi-private function, overload in special instance of undef()
**/
onResourceLoad(context: Object, map: RequireMap, depArray: RequireMap[]): void;
}
interface RequireDefine {
/**
* Define Simple Name/Value Pairs
* @param config Dictionary of Named/Value pairs for the config.
**/
(config: { [key: string]: any; }): void;
/**
* Define function.
* @param func: The function module.
**/
(func: () => any): void;
/**
* Define function with dependencies.
* @param deps List of dependencies module IDs.
* @param ready Callback function when the dependencies are loaded.
* callback param deps module dependencies
* callback return module definition
**/
(deps: string[], ready: Function): void;
/**
* Define module with simplified CommonJS wrapper.
* @param ready
* callback require requirejs instance
* callback exports exports object
* callback module module
* callback return module definition
**/
(ready: (require: Require, exports: { [key: string]: any; }, module: RequireModule) => any): void;
/**
* Define a module with a name and dependencies.
* @param name The name of the module.
* @param deps List of dependencies module IDs.
* @param ready Callback function when the dependencies are loaded.
* callback deps module dependencies
* callback return module definition
**/
(name: string, deps: string[], ready: Function): void;
/**
* Define a module with a name.
* @param name The name of the module.
* @param ready Callback function when the dependencies are loaded.
* callback return module definition
**/
(name: string, ready: Function): void;
/**
* Used to allow a clear indicator that a global define function (as needed for script src browser loading) conforms
* to the AMD API, any global define function SHOULD have a property called "amd" whose value is an object.
* This helps avoid conflict with any other existing JavaScript code that could have defined a define() function
* that does not conform to the AMD API.
* define.amd.jQuery is specific to jQuery and indicates that the loader is able to account for multiple version
* of jQuery being loaded simultaneously.
*/
amd: Object;
}
// Ambient declarations for 'require' and 'define'
declare var requirejs: Require;
declare var require: Require;
declare var define: RequireDefine;

View File

@@ -0,0 +1,8 @@
/// <reference path="es6-promise/es6-promise.d.ts" />
/// <reference path="knockout/knockout.d.ts" />
/// <reference path="requirejs/require.d.ts" />
/// <reference path="history/history.d.ts" />
/// <reference path="react-router/history.d.ts" />
/// <reference path="crossroads/crossroads.d.ts" />
/// <reference path="js-signals/js-signals.d.ts" />
/// <reference path="isomorphic-fetch/isomorphic-fetch.d.ts" />

View File

@@ -0,0 +1,8 @@
module.exports = {
devtool: 'inline-source-map',
module: {
loaders: [
{ test: /\.css/, loader: 'style!css' }
]
}
};

View File

@@ -1,40 +1,32 @@
var isDevBuild = process.argv.indexOf('--env.prod') < 0;
var path = require('path'); var path = require('path');
var webpack = require('webpack'); var webpack = require('webpack');
var ExtractTextPlugin = require('extract-text-webpack-plugin'); var merge = require('extendify')({ isDeep: true, arrays: 'concat' });
var devConfig = require('./webpack.config.dev');
var prodConfig = require('./webpack.config.prod');
var isDevelopment = process.env.ASPNETCORE_ENVIRONMENT === 'Development';
var bundleOutputDir = './wwwroot/dist'; module.exports = merge({
module.exports = { resolve: {
entry: { 'main': './ClientApp/boot.ts' }, extensions: [ '', '.js', '.ts' ]
resolve: { extensions: [ '', '.js', '.ts' ] },
output: {
path: path.join(__dirname, bundleOutputDir),
filename: '[name].js',
publicPath: '/dist/'
}, },
module: { module: {
loaders: [ loaders: [
{ test: /\.ts$/, include: /ClientApp/, loader: 'ts', query: { silent: true } }, { test: /\.ts(x?)$/, include: /ClientApp/, loader: 'ts-loader?silent=true' },
{ test: /\.html$/, loader: 'raw' }, { test: /\.html$/, loader: 'raw-loader' }
{ test: /\.css$/, loader: isDevBuild ? 'style!css' : ExtractTextPlugin.extract(['css']) },
{ test: /\.(png|jpg|jpeg|gif|svg)$/, loader: 'url', query: { limit: 25000 } }
] ]
}, },
entry: {
main: ['./ClientApp/boot.ts'],
},
output: {
path: path.join(__dirname, 'wwwroot', 'dist'),
filename: '[name].js',
publicPath: '/dist/'
},
plugins: [ plugins: [
new webpack.DllReferencePlugin({ new webpack.DllReferencePlugin({
context: __dirname, context: __dirname,
manifest: require('./wwwroot/dist/vendor-manifest.json') manifest: require('./wwwroot/dist/vendor-manifest.json')
}) })
].concat(isDevBuild ? [ ]
// Plugins that apply in development builds only }, isDevelopment ? devConfig : prodConfig);
new webpack.SourceMapDevToolPlugin({
filename: '[name].js.map', // Remove this line if you prefer inline source maps
moduleFilenameTemplate: path.relative(bundleOutputDir, '[resourcePath]') // Point sourcemap entries to the original file locations on disk
})
] : [
// Plugins that apply in production builds only
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.optimize.UglifyJsPlugin({ compress: { warnings: false } }),
new ExtractTextPlugin('site.css')
])
};

View File

@@ -0,0 +1,16 @@
var webpack = require('webpack');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var extractCSS = new ExtractTextPlugin('site.css');
module.exports = {
module: {
loaders: [
{ test: /\.css/, loader: extractCSS.extract(['css']) },
]
},
plugins: [
extractCSS,
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.optimize.UglifyJsPlugin({ compress: { warnings: false } })
]
};

View File

@@ -1,8 +1,8 @@
var isDevBuild = process.argv.indexOf('--env.prod') < 0;
var path = require('path'); var path = require('path');
var webpack = require('webpack'); var webpack = require('webpack');
var ExtractTextPlugin = require('extract-text-webpack-plugin'); var ExtractTextPlugin = require('extract-text-webpack-plugin');
var extractCSS = new ExtractTextPlugin('vendor.css'); var extractCSS = new ExtractTextPlugin('vendor.css');
var isDevelopment = process.env.ASPNETCORE_ENVIRONMENT === 'Development';
module.exports = { module.exports = {
resolve: { resolve: {
@@ -10,12 +10,12 @@ module.exports = {
}, },
module: { module: {
loaders: [ loaders: [
{ test: /\.(png|woff|woff2|eot|ttf|svg)(\?|$)/, loader: 'url-loader?limit=100000' }, { test: /\.(png|woff|woff2|eot|ttf|svg)$/, loader: 'url-loader?limit=100000' },
{ test: /\.css(\?|$)/, loader: extractCSS.extract(['css']) } { test: /\.css/, loader: extractCSS.extract(['css']) }
] ]
}, },
entry: { entry: {
vendor: ['bootstrap', 'bootstrap/dist/css/bootstrap.css', 'knockout', 'crossroads', 'event-source-polyfill', 'history', 'isomorphic-fetch', 'style-loader', 'jquery'], vendor: ['bootstrap', 'bootstrap/dist/css/bootstrap.css', 'knockout', 'crossroads', 'history', 'isomorphic-fetch', 'style-loader', 'jquery'],
}, },
output: { output: {
path: path.join(__dirname, 'wwwroot', 'dist'), path: path.join(__dirname, 'wwwroot', 'dist'),
@@ -30,7 +30,7 @@ module.exports = {
path: path.join(__dirname, 'wwwroot', 'dist', '[name]-manifest.json'), path: path.join(__dirname, 'wwwroot', 'dist', '[name]-manifest.json'),
name: '[name]_[hash]' name: '[name]_[hash]'
}) })
].concat(isDevBuild ? [] : [ ].concat(isDevelopment ? [] : [
new webpack.optimize.UglifyJsPlugin({ compress: { warnings: false } }) new webpack.optimize.UglifyJsPlugin({ compress: { warnings: false } })
]) ])
}; };

View File

@@ -1,9 +0,0 @@
------------------------------------------------------------------
Don't delete this file. Do include it in your source control repo.
------------------------------------------------------------------
This file exists as a workaround for https://github.com/dotnet/cli/issues/1396
('dotnet publish' does not publish any directories that didn't exist or were
empty before the publish script started).
Hopefully, this can be removed after the move to the new MSBuild.

View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified"/>
</handlers>
<httpPlatform processPath="%DNX_PATH%" arguments="%DNX_ARGS%" stdoutLogEnabled="false"/>
</system.webServer>
</configuration>

View File

@@ -1,14 +1,14 @@
import { createStore, applyMiddleware, compose, combineReducers, GenericStoreEnhancer } from 'redux'; import { createStore, applyMiddleware, compose, combineReducers } from 'redux';
import thunk from 'redux-thunk'; import * as thunkModule from 'redux-thunk';
import { routerReducer } from 'react-router-redux'; import { routerReducer } from 'react-router-redux';
import * as Store from './store'; import * as Store from './store';
import { typedToPlain } from 'redux-typed'; import { typedToPlain } from 'redux-typed';
export default function configureStore(initialState?: Store.ApplicationState) { export default function configureStore(initialState?: Store.ApplicationState) {
// Build middleware. These are functions that can process the actions before they reach the store. // Build middleware. These are functions that can process the actions before they reach the store.
const thunk = (thunkModule as any).default; // Workaround for TypeScript not importing thunk module as expected
const windowIfDefined = typeof window === 'undefined' ? null : window as any; const windowIfDefined = typeof window === 'undefined' ? null : window as any;
// If devTools is installed, connect to it const devToolsExtension = windowIfDefined && windowIfDefined.devToolsExtension; // If devTools is installed, connect to it
const devToolsExtension = windowIfDefined && windowIfDefined.devToolsExtension as () => GenericStoreEnhancer;
const createStoreWithMiddleware = compose( const createStoreWithMiddleware = compose(
applyMiddleware(thunk, typedToPlain), applyMiddleware(thunk, typedToPlain),
devToolsExtension ? devToolsExtension() : f => f devToolsExtension ? devToolsExtension() : f => f
@@ -16,7 +16,7 @@ export default function configureStore(initialState?: Store.ApplicationState) {
// Combine all reducers and instantiate the app-wide store instance // Combine all reducers and instantiate the app-wide store instance
const allReducers = buildRootReducer(Store.reducers); const allReducers = buildRootReducer(Store.reducers);
const store = createStoreWithMiddleware(allReducers, initialState) as Redux.Store<Store.ApplicationState>; const store = createStoreWithMiddleware(allReducers, initialState) as Redux.Store;
// Enable Webpack hot module replacement for reducers // Enable Webpack hot module replacement for reducers
if (module.hot) { if (module.hot) {
@@ -30,5 +30,5 @@ export default function configureStore(initialState?: Store.ApplicationState) {
} }
function buildRootReducer(allReducers) { function buildRootReducer(allReducers) {
return combineReducers<Store.ApplicationState>(Object.assign({}, allReducers, { routing: routerReducer })); return combineReducers(Object.assign({}, allReducers, { routing: routerReducer })) as Redux.Reducer;
} }

View File

@@ -1,9 +0,0 @@
------------------------------------------------------------------
Don't delete this file. Do include it in your source control repo.
------------------------------------------------------------------
This file exists as a workaround for https://github.com/dotnet/cli/issues/1396
('dotnet publish' does not publish any directories that didn't exist or were
empty before the publish script started).
Hopefully, this can be removed after the move to the new MSBuild.

View File

@@ -12,8 +12,3 @@ export default <Route component={ Layout }>
<Route path='(:startDateIndex)' /> { /* Optional route segment that does not affect NavMenu highlighting */ } <Route path='(:startDateIndex)' /> { /* Optional route segment that does not affect NavMenu highlighting */ }
</Route> </Route>
</Route>; </Route>;
// Enable Hot Module Replacement (HMR)
if (module.hot) {
module.hot.accept();
}

View File

@@ -33,7 +33,7 @@ export const reducer: Reducer<CounterState> = (state, action) => {
if (isActionType(action, IncrementCount)) { if (isActionType(action, IncrementCount)) {
return { count: state.count + 1 }; return { count: state.count + 1 };
} }
// For unrecognized actions (or in cases where actions have no effect), must return the existing state // For unrecognized actions (or in cases where actions have no effect), must return the existing state
// (or default initial state if none was supplied) // (or default initial state if none was supplied)
return state || { count: 0 }; return state || { count: 0 };

View File

@@ -36,7 +36,7 @@ namespace WebApplicationBasic.Controllers
{ {
get get
{ {
return 32 + (int)(TemperatureC / 0.5556); return 32 + (int)(this.TemperatureC / 0.5556);
} }
} }
} }

View File

@@ -1,8 +1,7 @@
FROM microsoft/dotnet:latest FROM microsoft/dotnet:latest
RUN apt-get update RUN apt-get update
RUN wget -qO- https://deb.nodesource.com/setup_4.x | bash - RUN apt-get install -y build-essential nodejs nodejs-legacy
RUN apt-get install -y build-essential nodejs
WORKDIR /app WORKDIR /app

View File

@@ -1,39 +1,40 @@
# Welcome to ASP.NET Core # Welcome to ASP.NET 5
We've made some big updates in this release, so its **important** that you spend a few minutes to learn whats new. We've made some big updates in this release, so its **important** that you spend a few minutes to learn whats new.
You've created a new ASP.NET Core project. [Learn what's new](https://go.microsoft.com/fwlink/?LinkId=518016) You've created a new ASP.NET 5 project. [Learn what's new](http://go.microsoft.com/fwlink/?LinkId=518016)
## This application consists of: ## This application consists of:
* Sample pages using ASP.NET Core MVC * Sample pages using ASP.NET MVC 6
* [Gulp](https://go.microsoft.com/fwlink/?LinkId=518007) and [Bower](https://go.microsoft.com/fwlink/?LinkId=518004) for managing client-side libraries * [Gulp](http://go.microsoft.com/fwlink/?LinkId=518007) and [Bower](http://go.microsoft.com/fwlink/?LinkId=518004) for managing client-side libraries
* Theming using [Bootstrap](https://go.microsoft.com/fwlink/?LinkID=398939) * Theming using [Bootstrap](http://go.microsoft.com/fwlink/?LinkID=398939)
## How to ## How to
* [Add a Controller and View](https://go.microsoft.com/fwlink/?LinkID=398600) * [Add a Controller and View](http://go.microsoft.com/fwlink/?LinkID=398600)
* [Add an appsetting in config and access it in app.](https://go.microsoft.com/fwlink/?LinkID=699562) * [Add an appsetting in config and access it in app.](http://go.microsoft.com/fwlink/?LinkID=699562)
* [Manage User Secrets using Secret Manager.](https://go.microsoft.com/fwlink/?LinkId=699315) * [Manage User Secrets using Secret Manager.](http://go.microsoft.com/fwlink/?LinkId=699315)
* [Use logging to log a message.](https://go.microsoft.com/fwlink/?LinkId=699316) * [Use logging to log a message.](http://go.microsoft.com/fwlink/?LinkId=699316)
* [Add packages using NuGet.](https://go.microsoft.com/fwlink/?LinkId=699317) * [Add packages using NuGet.](http://go.microsoft.com/fwlink/?LinkId=699317)
* [Add client packages using Bower.](https://go.microsoft.com/fwlink/?LinkId=699318) * [Add client packages using Bower.](http://go.microsoft.com/fwlink/?LinkId=699318)
* [Target development, staging or production environment.](https://go.microsoft.com/fwlink/?LinkId=699319) * [Target development, staging or production environment.](http://go.microsoft.com/fwlink/?LinkId=699319)
## Overview ## Overview
* [Conceptual overview of what is ASP.NET Core](https://go.microsoft.com/fwlink/?LinkId=518008) * [Conceptual overview of what is ASP.NET 5](http://go.microsoft.com/fwlink/?LinkId=518008)
* [Fundamentals of ASP.NET Core such as Startup and middleware.](https://go.microsoft.com/fwlink/?LinkId=699320) * [Fundamentals of ASP.NET 5 such as Startup and middleware.](http://go.microsoft.com/fwlink/?LinkId=699320)
* [Working with Data](https://go.microsoft.com/fwlink/?LinkId=398602) * [Working with Data](http://go.microsoft.com/fwlink/?LinkId=398602)
* [Security](https://go.microsoft.com/fwlink/?LinkId=398603) * [Security](http://go.microsoft.com/fwlink/?LinkId=398603)
* [Client side development](https://go.microsoft.com/fwlink/?LinkID=699321) * [Client side development](http://go.microsoft.com/fwlink/?LinkID=699321)
* [Develop on different platforms](https://go.microsoft.com/fwlink/?LinkID=699322) * [Develop on different platforms](http://go.microsoft.com/fwlink/?LinkID=699322)
* [Read more on the documentation site](https://go.microsoft.com/fwlink/?LinkID=699323) * [Read more on the documentation site](http://go.microsoft.com/fwlink/?LinkID=699323)
## Run & Deploy ## Run & Deploy
* [Run your app](https://go.microsoft.com/fwlink/?LinkID=517851) * [Run your app](http://go.microsoft.com/fwlink/?LinkID=517851)
* [Run tools such as EF migrations and more](https://go.microsoft.com/fwlink/?LinkID=517853) * [Run your app on .NET Core](http://go.microsoft.com/fwlink/?LinkID=517852)
* [Publish to Microsoft Azure Web Apps](https://go.microsoft.com/fwlink/?LinkID=398609) * [Run commands in your project.json](http://go.microsoft.com/fwlink/?LinkID=517853)
* [Publish to Microsoft Azure Web Apps](http://go.microsoft.com/fwlink/?LinkID=398609)
We would love to hear your [feedback](https://go.microsoft.com/fwlink/?LinkId=518015) We would love to hear your [feedback](http://go.microsoft.com/fwlink/?LinkId=518015)

View File

@@ -2,8 +2,9 @@
ViewData["Title"] = "Home Page"; ViewData["Title"] = "Home Page";
} }
<div id="react-app" asp-prerender-module="ClientApp/dist/main-server">Loading...</div> <div id="react-app" asp-prerender-module="ClientApp/boot-server"
asp-prerender-webpack-config="webpack.config.js">Loading...</div>
@section scripts { @section scripts {
<script src="~/dist/main-client.js" asp-append-version="true"></script> <script src="~/dist/main.js" asp-append-version="true"></script>
} }

View File

@@ -2,20 +2,8 @@
"name": "WebApplicationBasic", "name": "WebApplicationBasic",
"version": "0.0.0", "version": "0.0.0",
"dependencies": { "dependencies": {
"@types/react": "^0.14.29", "aspnet-prerendering": "^1.0.2",
"@types/react-dom": "^0.14.14", "aspnet-webpack": "^1.0.6",
"@types/react-redux": "^4.4.29",
"@types/react-router": "^2.0.30",
"@types/react-router-redux": "^4.0.30",
"@types/redux": "3.5.27",
"@types/redux-thunk": "^2.1.28",
"@types/source-map": "^0.1.28",
"@types/uglify-js": "^2.0.27",
"@types/webpack": "^1.12.35",
"@types/webpack-env": "^1.12.1",
"@types/whatwg-fetch": "0.0.28",
"aspnet-prerendering": "^1.0.7",
"aspnet-webpack": "^1.0.17",
"aspnet-webpack-react": "^1.0.2", "aspnet-webpack-react": "^1.0.2",
"babel-core": "^6.5.2", "babel-core": "^6.5.2",
"babel-loader": "^6.2.3", "babel-loader": "^6.2.3",
@@ -23,26 +11,25 @@
"babel-preset-react": "^6.5.0", "babel-preset-react": "^6.5.0",
"bootstrap": "^3.3.6", "bootstrap": "^3.3.6",
"css-loader": "^0.23.1", "css-loader": "^0.23.1",
"domain-task": "^2.0.1", "domain-task": "^2.0.0",
"event-source-polyfill": "^0.0.7", "extendify": "^1.0.0",
"extract-text-webpack-plugin": "^1.0.1", "extract-text-webpack-plugin": "^1.0.1",
"file-loader": "^0.8.5", "file-loader": "^0.8.5",
"jquery": "^2.2.1", "jquery": "^2.2.1",
"react": "^15.3.2", "react": "^15.0.1",
"react-dom": "^15.3.2", "react-dom": "^15.0.1",
"react-redux": "^4.4.5", "react-redux": "^4.4.4",
"react-router": "^2.8.1", "react-router": "^2.1.1",
"react-router-redux": "^4.0.6", "react-router-redux": "^4.0.2",
"redux": "^3.6.0", "redux": "^3.4.0",
"redux-thunk": "^2.1.0", "redux-thunk": "^2.0.1",
"redux-typed": "^2.0.0", "redux-typed": "^1.0.0",
"style-loader": "^0.13.0", "style-loader": "^0.13.0",
"ts-loader": "^0.8.1", "ts-loader": "^0.8.1",
"typescript": "2.0.3", "typescript": "^1.8.2",
"url-loader": "^0.5.7", "url-loader": "^0.5.7",
"webpack": "^1.13.2", "webpack-externals-plugin": "^1.0.0",
"webpack-node-externals": "^1.4.3", "webpack": "^1.12.14",
"webpack-hot-middleware": "^2.12.2", "webpack-hot-middleware": "^2.10.0"
"webpack-merge": "^0.14.1"
} }
} }

View File

@@ -40,10 +40,7 @@
"buildOptions": { "buildOptions": {
"emitEntryPoint": true, "emitEntryPoint": true,
"preserveCompilationContext": true, "preserveCompilationContext": true
"compile": {
"exclude": ["node_modules"]
}
}, },
"runtimeOptions": { "runtimeOptions": {
@@ -54,23 +51,25 @@
"publishOptions": { "publishOptions": {
"include": [ "include": [
".babelrc",
"appsettings.json", "appsettings.json",
"ClientApp/dist", "ClientApp",
"node_modules", "node_modules",
"typings",
"Views", "Views",
"tsconfig.json",
"tsd.json",
"web.config", "web.config",
"webpack.*.js",
"wwwroot" "wwwroot"
],
"exclude": [
"wwwroot/dist/*.map"
] ]
}, },
"scripts": { "scripts": {
"prepublish": [ "prepublish": [
"npm install", "npm install",
"node node_modules/webpack/bin/webpack.js --config webpack.config.vendor.js --env.prod", "node node_modules/webpack/bin/webpack.js --config webpack.config.vendor.js",
"node node_modules/webpack/bin/webpack.js --env.prod" "node node_modules/webpack/bin/webpack.js"
], ],
"postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ] "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
}, },

View File

@@ -28,13 +28,7 @@ Obj/
# Visual Studio 2015 cache/options directory # Visual Studio 2015 cache/options directory
.vs/ .vs/
/wwwroot/dist/** /wwwroot/dist/
/ClientApp/dist/**
# Workaround for https://github.com/aspnet/JavaScriptServices/issues/235
!/wwwroot/dist/_placeholder.txt
!/ClientApp/dist/_placeholder.txt
# MSTest test Results # MSTest test Results
[Tt]est[Rr]esult*/ [Tt]est[Rr]esult*/

View File

@@ -5,9 +5,7 @@
"jsx": "preserve", "jsx": "preserve",
"experimentalDecorators": true, "experimentalDecorators": true,
"sourceMap": true, "sourceMap": true,
"skipDefaultLibCheck": true, "skipDefaultLibCheck": true
"lib": ["es6", "dom"],
"types": [ "webpack-env", "whatwg-fetch" ]
}, },
"exclude": [ "exclude": [
"bin", "bin",

View File

@@ -0,0 +1,45 @@
{
"version": "v4",
"repo": "borisyankov/DefinitelyTyped",
"ref": "master",
"path": "typings",
"bundle": "typings/tsd.d.ts",
"installed": {
"react/react.d.ts": {
"commit": "9f0f926a12026287b5a4a229e5672c01e7549313"
},
"react-router/react-router.d.ts": {
"commit": "9f0f926a12026287b5a4a229e5672c01e7549313"
},
"react/react-dom.d.ts": {
"commit": "dade4414712ce84e3c63393f1aae407e9e7e6af7"
},
"react-router/history.d.ts": {
"commit": "9f0f926a12026287b5a4a229e5672c01e7549313"
},
"whatwg-fetch/whatwg-fetch.d.ts": {
"commit": "dade4414712ce84e3c63393f1aae407e9e7e6af7"
},
"react-redux/react-redux.d.ts": {
"commit": "9f0f926a12026287b5a4a229e5672c01e7549313"
},
"redux/redux.d.ts": {
"commit": "9f0f926a12026287b5a4a229e5672c01e7549313"
},
"react-router-redux/react-router-redux.d.ts": {
"commit": "9f0f926a12026287b5a4a229e5672c01e7549313"
},
"redux-thunk/redux-thunk.d.ts": {
"commit": "9f0f926a12026287b5a4a229e5672c01e7549313"
},
"uglify-js/uglify-js.d.ts": {
"commit": "9f0f926a12026287b5a4a229e5672c01e7549313"
},
"source-map/source-map.d.ts": {
"commit": "9f0f926a12026287b5a4a229e5672c01e7549313"
},
"webpack/webpack-env.d.ts": {
"commit": "9f0f926a12026287b5a4a229e5672c01e7549313"
}
}
}

View File

@@ -0,0 +1,68 @@
// Type definitions for react-redux 4.4.0
// Project: https://github.com/rackt/react-redux
// Definitions by: Qubo <https://github.com/tkqubo>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../react/react.d.ts" />
/// <reference path="../redux/redux.d.ts" />
declare module "react-redux" {
import { ComponentClass, Component, StatelessComponent } from 'react';
import { Store, Dispatch, ActionCreator } from 'redux';
export interface ComponentConstructDecorator<P> {
<TComponentConstruct extends (ComponentClass<P>|StatelessComponent<P>)>(component: TComponentConstruct): TComponentConstruct
}
/**
* Connects a React component to a Redux store.
* @param mapStateToProps
* @param mapDispatchToProps
* @param mergeProps
* @param options
*/
export function connect<P>(mapStateToProps?: MapStateToProps,
mapDispatchToProps?: MapDispatchToPropsFunction|MapDispatchToPropsObject,
mergeProps?: MergeProps,
options?: Options): ComponentConstructDecorator<P>;
interface MapStateToProps {
(state: any, ownProps?: any): any;
}
interface MapDispatchToPropsFunction {
(dispatch: Dispatch, ownProps?: any): any;
}
interface MapDispatchToPropsObject {
[name: string]: ActionCreator;
}
interface MergeProps {
(stateProps: any, dispatchProps: any, ownProps: any): any;
}
interface Options {
/**
* If true, implements shouldComponentUpdate and shallowly compares the result of mergeProps,
* preventing unnecessary updates, assuming that the component is a “pure” component
* and does not rely on any input or state other than its props and the selected Redux stores state.
* Defaults to true.
* @default true
*/
pure: boolean;
}
export interface Property {
/**
* The single Redux store in your application.
*/
store?: Store;
children?: Function;
}
/**
* Makes the Redux store available to the connect() calls in the component hierarchy below.
*/
export class Provider extends Component<Property, {}> { }
}

View File

@@ -0,0 +1,62 @@
// Type definitions for react-router-redux v4.0.0
// Project: https://github.com/rackt/react-router-redux
// Definitions by: Isman Usoh <http://github.com/isman-usoh>, Noah Shipley <https://github.com/noah79>, Dimitri Rosenberg <https://github.com/rosendi>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../redux/redux.d.ts" />
/// <reference path="../react-router/react-router.d.ts"/>
declare namespace ReactRouterRedux {
import R = Redux;
import H = HistoryModule;
const CALL_HISTORY_METHOD: string;
const LOCATION_CHANGE: string;
const push: PushAction;
const replace: ReplaceAction;
const go: GoAction;
const goBack: GoForwardAction;
const goForward: GoBackAction;
const routerActions: RouteActions;
type LocationDescriptor = H.Location | H.Path;
type PushAction = (nextLocation: LocationDescriptor) => RouterAction;
type ReplaceAction = (nextLocation: LocationDescriptor) => RouterAction;
type GoAction = (n: number) => RouterAction;
type GoForwardAction = () => RouterAction;
type GoBackAction = () => RouterAction;
type RouterAction = {
type: string
payload?: any
}
interface RouteActions {
push: PushAction;
replace: ReplaceAction;
go: GoAction;
goForward: GoForwardAction;
goBack: GoBackAction;
}
interface ReactRouterReduxHistory extends H.History {
unsubscribe(): void;
}
interface DefaultSelectLocationState extends Function {
(state: any): any;
}
interface SyncHistoryWithStoreOptions {
selectLocationState?: DefaultSelectLocationState;
adjustUrlOnReplay?: boolean;
}
function routerReducer(state?: any, options?: any): R.Reducer;
function syncHistoryWithStore(history: H.History, store: R.Store, options?: SyncHistoryWithStoreOptions): ReactRouterReduxHistory;
function routerMiddleware(history: H.History): R.Middleware;
}
declare module "react-router-redux" {
export = ReactRouterRedux;
}

View File

@@ -0,0 +1,233 @@
// Type definitions for history v2.0.0
// Project: https://github.com/rackt/history
// Definitions by: Sergey Buturlakin <https://github.com/sergey-buturlakin>, Nathan Brown <https://github.com/ngbrown>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare namespace HistoryModule {
// types based on https://github.com/rackt/history/blob/master/docs/Terms.md
type Action = string
type BeforeUnloadHook = () => string | boolean
type CreateHistory<T> = (options?: HistoryOptions) => T
type CreateHistoryEnhancer<T, E> = (createHistory: CreateHistory<T>) => CreateHistory<T & E>
interface History {
listenBefore(hook: TransitionHook): () => void
listen(listener: LocationListener): () => void
transitionTo(location: Location): void
push(path: LocationDescriptor): void
replace(path: LocationDescriptor): void
go(n: number): void
goBack(): void
goForward(): void
createKey(): LocationKey
createPath(path: LocationDescriptor): Path
createHref(path: LocationDescriptor): Href
createLocation(path?: LocationDescriptor, action?: Action, key?: LocationKey): Location
/** @deprecated use a location descriptor instead */
createLocation(path?: Path, state?: LocationState, action?: Action, key?: LocationKey): Location
/** @deprecated use location.key to save state instead */
pushState(state: LocationState, path: Path): void
/** @deprecated use location.key to save state instead */
replaceState(state: LocationState, path: Path): void
/** @deprecated use location.key to save state instead */
setState(state: LocationState): void
/** @deprecated use listenBefore instead */
registerTransitionHook(hook: TransitionHook): void
/** @deprecated use the callback returned from listenBefore instead */
unregisterTransitionHook(hook: TransitionHook): void
}
type HistoryOptions = {
getCurrentLocation?: () => Location
finishTransition?: (nextLocation: Location) => boolean
saveState?: (key: LocationKey, state: LocationState) => void
go?: (n: number) => void
getUserConfirmation?: (message: string, callback: (result: boolean) => void) => void
keyLength?: number
queryKey?: string | boolean
stringifyQuery?: (obj: any) => string
parseQueryString?: (str: string) => any
basename?: string
entries?: string | [any]
current?: number
}
type Href = string
type Location = {
pathname: Pathname
search: Search
query: Query
state: LocationState
action: Action
key: LocationKey
basename?: string
}
type LocationDescriptorObject = {
pathname?: Pathname
search?: Search
query?: Query
state?: LocationState
}
type LocationDescriptor = LocationDescriptorObject | Path
type LocationKey = string
type LocationListener = (location: Location) => void
type LocationState = Object
type Path = string // Pathname + QueryString
type Pathname = string
type Query = Object
type QueryString = string
type Search = string
type TransitionHook = (location: Location, callback: (result: any) => void) => any
interface HistoryBeforeUnload {
listenBeforeUnload(hook: BeforeUnloadHook): () => void
}
interface HistoryQueries {
pushState(state: LocationState, pathname: Pathname | Path, query?: Query): void
replaceState(state: LocationState, pathname: Pathname | Path, query?: Query): void
createPath(path: Path, query?: Query): Path
createHref(path: Path, query?: Query): Href
}
// Global usage, without modules, needs the small trick, because lib.d.ts
// already has `history` and `History` global definitions:
// var createHistory = ((window as any).History as HistoryModule.Module).createHistory;
interface Module {
createHistory: CreateHistory<History>
createHashHistory: CreateHistory<History>
createMemoryHistory: CreateHistory<History>
createLocation(path?: Path, state?: LocationState, action?: Action, key?: LocationKey): Location
useBasename<T>(createHistory: CreateHistory<T>): CreateHistory<T>
useBeforeUnload<T>(createHistory: CreateHistory<T>): CreateHistory<T & HistoryBeforeUnload>
useQueries<T>(createHistory: CreateHistory<T>): CreateHistory<T & HistoryQueries>
actions: {
PUSH: string
REPLACE: string
POP: string
}
}
}
declare module "history/lib/createBrowserHistory" {
export default function createBrowserHistory(options?: HistoryModule.HistoryOptions): HistoryModule.History
}
declare module "history/lib/createHashHistory" {
export default function createHashHistory(options?: HistoryModule.HistoryOptions): HistoryModule.History
}
declare module "history/lib/createMemoryHistory" {
export default function createMemoryHistory(options?: HistoryModule.HistoryOptions): HistoryModule.History
}
declare module "history/lib/createLocation" {
export default function createLocation(path?: HistoryModule.Path, state?: HistoryModule.LocationState, action?: HistoryModule.Action, key?: HistoryModule.LocationKey): HistoryModule.Location
}
declare module "history/lib/useBasename" {
export default function useBasename<T>(createHistory: HistoryModule.CreateHistory<T>): HistoryModule.CreateHistory<T>
}
declare module "history/lib/useBeforeUnload" {
export default function useBeforeUnload<T>(createHistory: HistoryModule.CreateHistory<T>): HistoryModule.CreateHistory<T & HistoryModule.HistoryBeforeUnload>
}
declare module "history/lib/useQueries" {
export default function useQueries<T>(createHistory: HistoryModule.CreateHistory<T>): HistoryModule.CreateHistory<T & HistoryModule.HistoryQueries>
}
declare module "history/lib/actions" {
export const PUSH: string
export const REPLACE: string
export const POP: string
export default {
PUSH,
REPLACE,
POP
}
}
declare module "history/lib/DOMUtils" {
export function addEventListener(node: EventTarget, event: string, listener: EventListenerOrEventListenerObject): void;
export function removeEventListener(node: EventTarget, event: string, listener: EventListenerOrEventListenerObject): void;
export function getHashPath(): string;
export function replaceHashPath(path: string): void;
export function getWindowPath(): string;
export function go(n: number): void;
export function getUserConfirmation(message: string, callback: (result: boolean) => void): void;
export function supportsHistory(): boolean;
export function supportsGoWithoutReloadUsingHash(): boolean;
}
declare module "history" {
export { default as createHistory } from "history/lib/createBrowserHistory"
export { default as createHashHistory } from "history/lib/createHashHistory"
export { default as createMemoryHistory } from "history/lib/createMemoryHistory"
export { default as createLocation } from "history/lib/createLocation"
export { default as useBasename } from "history/lib/useBasename"
export { default as useBeforeUnload } from "history/lib/useBeforeUnload"
export { default as useQueries } from "history/lib/useQueries"
import * as Actions from "history/lib/actions"
export { Actions }
}

View File

@@ -0,0 +1,480 @@
// Type definitions for react-router v2.0.0
// Project: https://github.com/rackt/react-router
// Definitions by: Sergey Buturlakin <https://github.com/sergey-buturlakin>, Yuichi Murata <https://github.com/mrk21>, Václav Ostrožlík <https://github.com/vasek17>, Nathan Brown <https://github.com/ngbrown>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../react/react.d.ts" />
/// <reference path="./history.d.ts"/>
declare namespace ReactRouter {
import React = __React
import H = HistoryModule
// types based on https://github.com/rackt/react-router/blob/master/docs/Glossary.md
type Component = React.ReactType
type EnterHook = (nextState: RouterState, replaceState: RedirectFunction, callback?: Function) => any
type LeaveHook = () => any
type Params = Object
type ParseQueryString = (queryString: H.QueryString) => H.Query
type RedirectFunction = (state: H.LocationState, pathname: H.Pathname | H.Path, query?: H.Query) => void
type RouteComponent = Component
// use the following interface in an app code to get access to route param values, history, location...
// interface MyComponentProps extends ReactRouter.RouteComponentProps<{}, { id: number }> {}
// somewhere in MyComponent
// ...
// let id = this.props.routeParams.id
// ...
// this.props.history. ...
// ...
interface RouteComponentProps<P, R> {
history?: History
location?: H.Location
params?: P
route?: PlainRoute
routeParams?: R
routes?: PlainRoute[]
children?: React.ReactElement<any>
}
type RouteComponents = { [key: string]: RouteComponent }
type RouteConfig = React.ReactNode | PlainRoute | PlainRoute[]
type RouteHook = (nextLocation?: H.Location) => any
type RoutePattern = string
type StringifyQuery = (queryObject: H.Query) => H.QueryString
type RouterListener = (error: Error, nextState: RouterState) => void
interface RouterState {
location: H.Location
routes: PlainRoute[]
params: Params
components: RouteComponent[]
}
interface HistoryBase extends H.History {
routes: PlainRoute[]
parseQueryString?: ParseQueryString
stringifyQuery?: StringifyQuery
}
type History = HistoryBase & H.HistoryQueries & HistoryRoutes
const browserHistory: History;
const hashHistory: History;
/* components */
interface RouterProps extends React.Props<Router> {
history?: H.History
routes?: RouteConfig // alias for children
createElement?: (component: RouteComponent, props: Object) => any
onError?: (error: any) => any
onUpdate?: () => any
parseQueryString?: ParseQueryString
stringifyQuery?: StringifyQuery
}
interface Router extends React.ComponentClass<RouterProps> {}
interface RouterElement extends React.ReactElement<RouterProps> {}
const Router: Router
interface LinkProps extends React.HTMLAttributes, React.Props<Link> {
activeStyle?: React.CSSProperties
activeClassName?: string
onlyActiveOnIndex?: boolean
to: RoutePattern
query?: H.Query
state?: H.LocationState
}
interface Link extends React.ComponentClass<LinkProps> {}
interface LinkElement extends React.ReactElement<LinkProps> {}
const Link: Link
const IndexLink: Link
interface RouterContextProps extends React.Props<RouterContext> {
history?: H.History
router: Router
createElement: (component: RouteComponent, props: Object) => any
location: H.Location
routes: RouteConfig
params: Params
components?: RouteComponent[]
}
interface RouterContext extends React.ComponentClass<RouterContextProps> {}
interface RouterContextElement extends React.ReactElement<RouterContextProps> {
history?: H.History
location: H.Location
router?: Router
}
const RouterContext: RouterContext
/* components (configuration) */
interface RouteProps extends React.Props<Route> {
path?: RoutePattern
component?: RouteComponent
components?: RouteComponents
getComponent?: (location: H.Location, cb: (error: any, component?: RouteComponent) => void) => void
getComponents?: (location: H.Location, cb: (error: any, components?: RouteComponents) => void) => void
onEnter?: EnterHook
onLeave?: LeaveHook
getIndexRoute?: (location: H.Location, cb: (error: any, indexRoute: RouteConfig) => void) => void
getChildRoutes?: (location: H.Location, cb: (error: any, childRoutes: RouteConfig) => void) => void
}
interface Route extends React.ComponentClass<RouteProps> {}
interface RouteElement extends React.ReactElement<RouteProps> {}
const Route: Route
interface PlainRoute {
path?: RoutePattern
component?: RouteComponent
components?: RouteComponents
getComponent?: (location: H.Location, cb: (error: any, component?: RouteComponent) => void) => void
getComponents?: (location: H.Location, cb: (error: any, components?: RouteComponents) => void) => void
onEnter?: EnterHook
onLeave?: LeaveHook
indexRoute?: PlainRoute
getIndexRoute?: (location: H.Location, cb: (error: any, indexRoute: RouteConfig) => void) => void
childRoutes?: PlainRoute[]
getChildRoutes?: (location: H.Location, cb: (error: any, childRoutes: RouteConfig) => void) => void
}
interface RedirectProps extends React.Props<Redirect> {
path?: RoutePattern
from?: RoutePattern // alias for path
to: RoutePattern
query?: H.Query
state?: H.LocationState
}
interface Redirect extends React.ComponentClass<RedirectProps> {}
interface RedirectElement extends React.ReactElement<RedirectProps> {}
const Redirect: Redirect
interface IndexRouteProps extends React.Props<IndexRoute> {
component?: RouteComponent
components?: RouteComponents
getComponent?: (location: H.Location, cb: (error: any, component?: RouteComponent) => void) => void
getComponents?: (location: H.Location, cb: (error: any, components?: RouteComponents) => void) => void
onEnter?: EnterHook
onLeave?: LeaveHook
}
interface IndexRoute extends React.ComponentClass<IndexRouteProps> {}
interface IndexRouteElement extends React.ReactElement<IndexRouteProps> {}
const IndexRoute: IndexRoute
interface IndexRedirectProps extends React.Props<IndexRedirect> {
to: RoutePattern
query?: H.Query
state?: H.LocationState
}
interface IndexRedirect extends React.ComponentClass<IndexRedirectProps> {}
interface IndexRedirectElement extends React.ReactElement<IndexRedirectProps> {}
const IndexRedirect: IndexRedirect
interface RouterOnContext extends H.History {
setRouteLeaveHook(route: PlainRoute, hook?: RouteHook): () => void;
isActive(pathOrLoc: H.LocationDescriptor, indexOnly?: boolean): boolean;
}
/* mixins */
interface HistoryMixin {
history: History
}
const History: React.Mixin<any, any>
interface LifecycleMixin {
routerWillLeave(nextLocation: H.Location): string | boolean
}
const Lifecycle: React.Mixin<any, any>
const RouteContext: React.Mixin<any, any>
/* utils */
interface HistoryRoutes {
listen(listener: RouterListener): Function
listenBeforeLeavingRoute(route: PlainRoute, hook: RouteHook): void
match(location: H.Location, callback: (error: any, nextState: RouterState, nextLocation: H.Location) => void): void
isActive(pathname: H.Pathname, query?: H.Query, indexOnly?: boolean): boolean
setRouteLeaveHook(route: PlainRoute, callback: RouteHook): void
}
function useRoutes<T>(createHistory: HistoryModule.CreateHistory<T>): HistoryModule.CreateHistory<T & HistoryRoutes>
function createRoutes(routes: RouteConfig): PlainRoute[]
interface MatchArgs {
routes?: RouteConfig
history?: H.History
location?: H.Location
parseQueryString?: ParseQueryString
stringifyQuery?: StringifyQuery
}
interface MatchState extends RouterState {
history: History
}
function match(args: MatchArgs, cb: (error: any, nextLocation: H.Location, nextState: MatchState) => void): void
}
declare module "react-router/lib/Router" {
export default ReactRouter.Router
}
declare module "react-router/lib/Link" {
export default ReactRouter.Link
}
declare module "react-router/lib/IndexLink" {
export default ReactRouter.IndexLink
}
declare module "react-router/lib/IndexRedirect" {
export default ReactRouter.IndexRedirect
}
declare module "react-router/lib/IndexRoute" {
export default ReactRouter.IndexRoute
}
declare module "react-router/lib/Redirect" {
export default ReactRouter.Redirect
}
declare module "react-router/lib/Route" {
export default ReactRouter.Route
}
declare module "react-router/lib/History" {
export default ReactRouter.History
}
declare module "react-router/lib/Lifecycle" {
export default ReactRouter.Lifecycle
}
declare module "react-router/lib/RouteContext" {
export default ReactRouter.RouteContext
}
declare module "react-router/lib/useRoutes" {
export default ReactRouter.useRoutes
}
declare module "react-router/lib/PatternUtils" {
export function formatPattern(pattern: string, params: {}): string;
}
declare module "react-router/lib/RouteUtils" {
type E = __React.ReactElement<any>
export function isReactChildren(object: E | E[]): boolean
export function createRouteFromReactElement(element: E): ReactRouter.PlainRoute
export function createRoutesFromReactChildren(children: E | E[], parentRoute: ReactRouter.PlainRoute): ReactRouter.PlainRoute[]
export import createRoutes = ReactRouter.createRoutes
}
declare module "react-router/lib/RouterContext" {
export default ReactRouter.RouterContext
}
declare module "react-router/lib/PropTypes" {
import React = __React
export function falsy(props: any, propName: string, componentName: string): Error;
export const history: React.Requireable<any>
export const location: React.Requireable<any>
export const component: React.Requireable<any>
export const components: React.Requireable<any>
export const route: React.Requireable<any>
export const routes: React.Requireable<any>
export default {
falsy,
history,
location,
component,
components,
route
}
}
declare module "react-router/lib/browserHistory" {
export default ReactRouter.browserHistory;
}
declare module "react-router/lib/hashHistory" {
export default ReactRouter.hashHistory;
}
declare module "react-router/lib/match" {
export default ReactRouter.match
}
declare module "react-router" {
import Router from "react-router/lib/Router"
import Link from "react-router/lib/Link"
import IndexLink from "react-router/lib/IndexLink"
import IndexRedirect from "react-router/lib/IndexRedirect"
import IndexRoute from "react-router/lib/IndexRoute"
import Redirect from "react-router/lib/Redirect"
import Route from "react-router/lib/Route"
import History from "react-router/lib/History"
import Lifecycle from "react-router/lib/Lifecycle"
import RouteContext from "react-router/lib/RouteContext"
import browserHistory from "react-router/lib/browserHistory"
import hashHistory from "react-router/lib/hashHistory"
import useRoutes from "react-router/lib/useRoutes"
import { createRoutes } from "react-router/lib/RouteUtils"
import { formatPattern } from "react-router/lib/PatternUtils"
import RouterContext from "react-router/lib/RouterContext"
import PropTypes from "react-router/lib/PropTypes"
import match from "react-router/lib/match"
// PlainRoute is defined in the API documented at:
// https://github.com/rackt/react-router/blob/master/docs/API.md
// but not included in any of the .../lib modules above.
export type PlainRoute = ReactRouter.PlainRoute
// The following definitions are also very useful to export
// because by using these types lots of potential type errors
// can be exposed:
export type EnterHook = ReactRouter.EnterHook
export type LeaveHook = ReactRouter.LeaveHook
export type ParseQueryString = ReactRouter.ParseQueryString
export type RedirectFunction = ReactRouter.RedirectFunction
export type RouteComponentProps<P,R> = ReactRouter.RouteComponentProps<P,R>;
export type RouteHook = ReactRouter.RouteHook
export type StringifyQuery = ReactRouter.StringifyQuery
export type RouterListener = ReactRouter.RouterListener
export type RouterState = ReactRouter.RouterState
export type HistoryBase = ReactRouter.HistoryBase
export type RouterOnContext = ReactRouter.RouterOnContext
export {
Router,
Link,
IndexLink,
IndexRedirect,
IndexRoute,
Redirect,
Route,
History,
browserHistory,
hashHistory,
Lifecycle,
RouteContext,
useRoutes,
createRoutes,
formatPattern,
RouterContext,
PropTypes,
match
}
export default Router
}

View File

@@ -0,0 +1,66 @@
// Type definitions for React v0.14 (react-dom)
// Project: http://facebook.github.io/react/
// Definitions by: Asana <https://asana.com>, AssureSign <http://www.assuresign.com>, Microsoft <https://microsoft.com>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="react.d.ts" />
declare namespace __React {
namespace __DOM {
function findDOMNode<E extends Element>(instance: ReactInstance): E;
function findDOMNode(instance: ReactInstance): Element;
function render<P>(
element: DOMElement<P>,
container: Element,
callback?: (element: Element) => any): Element;
function render<P, S>(
element: ClassicElement<P>,
container: Element,
callback?: (component: ClassicComponent<P, S>) => any): ClassicComponent<P, S>;
function render<P, S>(
element: ReactElement<P>,
container: Element,
callback?: (component: Component<P, S>) => any): Component<P, S>;
function unmountComponentAtNode(container: Element): boolean;
var version: string;
function unstable_batchedUpdates<A, B>(callback: (a: A, b: B) => any, a: A, b: B): void;
function unstable_batchedUpdates<A>(callback: (a: A) => any, a: A): void;
function unstable_batchedUpdates(callback: () => any): void;
function unstable_renderSubtreeIntoContainer<P>(
parentComponent: Component<any, any>,
nextElement: DOMElement<P>,
container: Element,
callback?: (element: Element) => any): Element;
function unstable_renderSubtreeIntoContainer<P, S>(
parentComponent: Component<any, any>,
nextElement: ClassicElement<P>,
container: Element,
callback?: (component: ClassicComponent<P, S>) => any): ClassicComponent<P, S>;
function unstable_renderSubtreeIntoContainer<P, S>(
parentComponent: Component<any, any>,
nextElement: ReactElement<P>,
container: Element,
callback?: (component: Component<P, S>) => any): Component<P, S>;
}
namespace __DOMServer {
function renderToString(element: ReactElement<any>): string;
function renderToStaticMarkup(element: ReactElement<any>): string;
var version: string;
}
}
declare module "react-dom" {
import DOM = __React.__DOM;
export = DOM;
}
declare module "react-dom/server" {
import DOMServer = __React.__DOMServer;
export = DOMServer;
}

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More