From ed5699117e05856e0672a0bd18125845ecc5ac85 Mon Sep 17 00:00:00 2001 From: Daniel Gaeta Date: Fri, 9 Sep 2016 12:03:23 -0700 Subject: [PATCH] Adding angular2-prototype --- samples/angular2-prototype/README.md | 13 ++- .../typings/es6-promise/es6-promise.d.ts | 84 +++++++++++++++++++ samples/angular2-prototype/typings/tsd.d.ts | 1 + 3 files changed, 94 insertions(+), 4 deletions(-) create mode 100644 samples/angular2-prototype/typings/es6-promise/es6-promise.d.ts diff --git a/samples/angular2-prototype/README.md b/samples/angular2-prototype/README.md index 445086ca1..3b4224747 100644 --- a/samples/angular2-prototype/README.md +++ b/samples/angular2-prototype/README.md @@ -1,6 +1,7 @@ -## ang-2-webparts +## angular2-prototype + +This is expirimental project on boostrapping multiple identical angular2 applications with the same root class component. -This is where you include your web part docs. ### Building the code @@ -8,14 +9,18 @@ This is where you include your web part docs. git clone the repo npm i npm i -g gulp -gulp +tsd install +gulp serve ``` This package produces the following: * lib/* commonjs components - this allows this package to be reused from other packages. * dist/* - a single bundle containing the components used for uploading to a cdn pointing a registered Sharepoint webpart library to. -* example/* a test page that hosts all components in this package. +* src/* - all files for the expiriemental angular2 todo webpart. + +* src/webparts/todo/core - am abstract base class that we created for angular2 applications. +* src/webparts/todo/TodoWebPart.ts - a class to create unique instance of the root class component and return other metadata for the NgModule decorator funciton. ### Build options diff --git a/samples/angular2-prototype/typings/es6-promise/es6-promise.d.ts b/samples/angular2-prototype/typings/es6-promise/es6-promise.d.ts new file mode 100644 index 000000000..4af46edfa --- /dev/null +++ b/samples/angular2-prototype/typings/es6-promise/es6-promise.d.ts @@ -0,0 +1,84 @@ +// Type definitions for es6-promise +// Project: https://github.com/jakearchibald/ES6-Promise +// Definitions by: François de Campredon , vvakame +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +interface Thenable { + then(onFulfilled?: (value: T) => U | Thenable, onRejected?: (error: any) => U | Thenable): Thenable; + then(onFulfilled?: (value: T) => U | Thenable, onRejected?: (error: any) => void): Thenable; +} + +declare class Promise implements Thenable { + /** + * 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) => 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(onFulfilled?: (value: T) => U | Thenable, onRejected?: (error: any) => U | Thenable): Promise; + then(onFulfilled?: (value: T) => U | Thenable, onRejected?: (error: any) => void): Promise; + + /** + * Sugar for promise.then(undefined, onRejected) + * + * @param onRejected called when/if "promise" rejects + */ + catch(onRejected?: (error: any) => U | Thenable): Promise; +} + +declare namespace Promise { + /** + * Make a new promise from the thenable. + * A thenable is promise-like in as far as it has a "then" method. + */ + function resolve(value?: T | Thenable): Promise; + + /** + * 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; + function reject(error: T): Promise; + + /** + * 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(values: [T1 | Thenable, T2 | Thenable, T3 | Thenable, T4 | Thenable , T5 | Thenable, T6 | Thenable, T7 | Thenable, T8 | Thenable, T9 | Thenable, T10 | Thenable]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>; + function all(values: [T1 | Thenable, T2 | Thenable, T3 | Thenable, T4 | Thenable , T5 | Thenable, T6 | Thenable, T7 | Thenable, T8 | Thenable, T9 | Thenable]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>; + function all(values: [T1 | Thenable, T2 | Thenable, T3 | Thenable, T4 | Thenable , T5 | Thenable, T6 | Thenable, T7 | Thenable, T8 | Thenable]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8]>; + function all(values: [T1 | Thenable, T2 | Thenable, T3 | Thenable, T4 | Thenable , T5 | Thenable, T6 | Thenable, T7 | Thenable]): Promise<[T1, T2, T3, T4, T5, T6, T7]>; + function all(values: [T1 | Thenable, T2 | Thenable, T3 | Thenable, T4 | Thenable , T5 | Thenable, T6 | Thenable]): Promise<[T1, T2, T3, T4, T5, T6]>; + function all(values: [T1 | Thenable, T2 | Thenable, T3 | Thenable, T4 | Thenable , T5 | Thenable]): Promise<[T1, T2, T3, T4, T5]>; + function all(values: [T1 | Thenable, T2 | Thenable, T3 | Thenable, T4 | Thenable ]): Promise<[T1, T2, T3, T4]>; + function all(values: [T1 | Thenable, T2 | Thenable, T3 | Thenable]): Promise<[T1, T2, T3]>; + function all(values: [T1 | Thenable, T2 | Thenable]): Promise<[T1, T2]>; + function all(values: (T | Thenable)[]): Promise; + + /** + * Make a Promise that fulfills when any item fulfills, and rejects if any item rejects. + */ + function race(promises: (T | Thenable)[]): Promise; +} + +declare module 'es6-promise' { + var foo: typeof Promise; // Temp variable to reference Promise in local context + namespace rsvp { + export var Promise: typeof foo; + export function polyfill(): void; + } + export = rsvp; +} diff --git a/samples/angular2-prototype/typings/tsd.d.ts b/samples/angular2-prototype/typings/tsd.d.ts index fb5a27fcd..8b129c5ce 100644 --- a/samples/angular2-prototype/typings/tsd.d.ts +++ b/samples/angular2-prototype/typings/tsd.d.ts @@ -16,3 +16,4 @@ /// /// /// +///