Skip to content

Commit de5b09d

Browse files
committed
Initial commit
0 parents  commit de5b09d

File tree

460 files changed

+78079
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

460 files changed

+78079
-0
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
*.js
2+
.idea
3+
node_modules
4+
client/bower_components

angular2/angular2.d.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/**
2+
* Define public API for Angular here.
3+
*/
4+
5+
export * from './change_detection';
6+
export * from './core';
7+
export * from './directives';

angular2/change_detection.d.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
export { AST } from './src/change_detection/parser/ast';
2+
export { Lexer } from './src/change_detection/parser/lexer';
3+
export { Parser } from './src/change_detection/parser/parser';
4+
export { ContextWithVariableBindings } from './src/change_detection/parser/context_with_variable_bindings';
5+
export { ExpressionChangedAfterItHasBeenChecked, ChangeDetectionError } from './src/change_detection/exceptions';
6+
export { ChangeRecord, ChangeDispatcher, ChangeDetector, CHECK_ONCE, CHECK_ALWAYS, DETACHED, CHECKED } from './src/change_detection/interfaces';
7+
export { ProtoChangeDetector, DynamicProtoChangeDetector, JitProtoChangeDetector } from './src/change_detection/proto_change_detector';
8+
export { DynamicChangeDetector } from './src/change_detection/dynamic_change_detector';
9+
import { ProtoChangeDetector } from './src/change_detection/proto_change_detector';
10+
export declare class ChangeDetection {
11+
createProtoChangeDetector(name: string): ProtoChangeDetector;
12+
}
13+
export declare class DynamicChangeDetection extends ChangeDetection {
14+
createProtoChangeDetector(name: string): ProtoChangeDetector;
15+
}
16+
export declare class JitChangeDetection extends ChangeDetection {
17+
createProtoChangeDetector(name: string): ProtoChangeDetector;
18+
}
19+
export declare var dynamicChangeDetection: DynamicChangeDetection;
20+
export declare var jitChangeDetection: JitChangeDetection;

angular2/core.d.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/// <reference path='globals.d.ts'/>
2+
3+
export * from './src/core/annotations/annotations';
4+
export * from './src/core/annotations/visibility';
5+
export * from './src/core/compiler/interfaces';
6+
export * from './src/core/annotations/template';
7+
export * from './src/core/application';
8+
export * from './src/core/compiler/compiler';
9+
export * from './src/core/compiler/template_loader';
10+
export * from './src/core/compiler/view';
11+
export * from './src/core/compiler/view_container';
12+
export * from './src/core/compiler/binding_propagation_config';
13+
export * from './src/core/dom/element';

angular2/di.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export { Inject, InjectPromise, InjectLazy, DependencyAnnotation } from './src/di/annotations';
2+
export { Injector } from './src/di/injector';
3+
export { Binding, Dependency, bind } from './src/di/binding';
4+
export { Key, KeyRegistry } from './src/di/key';
5+
export { KeyMetadataError, NoProviderError, ProviderError, AsyncBindingError, CyclicDependencyError, InstantiationError, InvalidBindingError, NoAnnotationError } from './src/di/exceptions';
6+
export { OpaqueToken } from './src/di/opaque_token';

angular2/directives.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export * from './src/directives/foreach';
2+
export * from './src/directives/if';
3+
export * from './src/directives/non_bindable';
4+
export * from './src/directives/switch';

angular2/e2e_test/perf_util.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
declare var testUtil: any;
2+
declare var benchpress: any;
3+
declare function runClickBenchmark(config: any): any;
4+
declare function runBenchmark(config: any): any;
5+
declare function getScaleFactor(possibleScalings: any): any;
6+
declare function applyScaleFactor(value: any, scaleFactor: any, method: any): any;

angular2/e2e_test/test_util.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/// <reference path="../../../../../forks/angular2/typings/selenium-webdriver/selenium-webdriver.d.ts" />
2+
declare var webdriver: any;
3+
declare function clickAll(buttonSelectors: any): void;
4+
declare function verifyNoBrowserErrors(): void;

angular2/forms.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from './src/forms/model';
2+
export * from './src/forms/directives';

angular2/globals.d.ts

Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
/// <reference path="../jasmine/jasmine.d.ts" />
2+
/// <reference path="../zone/zone.d.ts" />
3+
/// <reference path="../hammerjs/hammerjs.d.ts" />
4+
declare var assert: any;
5+
declare var module: any;
6+
declare var $traceurRuntime: any;
7+
declare var global: Window;
8+
declare var $: any;
9+
declare var angular: any;
10+
declare var _resolve: any;
11+
declare var require: any;
12+
declare var browser: any;
13+
declare var benchpressRunner: any;
14+
declare type int = number;
15+
declare type Type = {
16+
new (...args: any[]): any;
17+
};
18+
interface List<T> extends Array<T> {
19+
}
20+
declare type TemplateElement = HTMLTemplateElement;
21+
declare type StyleElement = HTMLStyleElement;
22+
declare type SetterFn = Function;
23+
declare type GetterFn = Function;
24+
declare type MethodFn = Function;
25+
declare type _globalRegExp = RegExp;
26+
interface HTMLElement {
27+
createShadowRoot(): HTMLElement;
28+
}
29+
interface HTMLTemplateElement extends HTMLElement {
30+
content: DocumentFragment;
31+
}
32+
interface Window {
33+
Array: typeof Array;
34+
List: typeof Array;
35+
Map: typeof Map;
36+
Set: typeof Set;
37+
RegExp: typeof RegExp;
38+
JSON: typeof JSON;
39+
Math: typeof Math;
40+
assert: typeof assert;
41+
NaN: typeof NaN;
42+
setTimeout: typeof setTimeout;
43+
Promise: typeof Promise;
44+
zone: Zone;
45+
Hammer: HammerStatic;
46+
DocumentFragment: DocumentFragment;
47+
Node: Node;
48+
NodeList: NodeList;
49+
Text: Text;
50+
HTMLElement: HTMLElement;
51+
HTMLTemplateElement: TemplateElement;
52+
HTMLStyleElement: StyleElement;
53+
gc(): void;
54+
}
55+
interface Window extends jasmine.GlobalPolluter {
56+
print(msg: string): void;
57+
dump(msg: string): void;
58+
describe(description: string, specDefinitions: () => void): jasmine.Suite;
59+
ddescribe(description: string, specDefinitions: () => void): jasmine.Suite;
60+
beforeEach(beforeEachFunction: () => void): void;
61+
beforeAll(beforeAllFunction: () => void): void;
62+
afterEach(afterEachFunction: () => void): void;
63+
afterAll(afterAllFunction: () => void): void;
64+
xdescribe(desc: string, specDefinitions: () => void): jasmine.XSuite;
65+
it(description: string, func: (done?: () => void) => void): jasmine.Spec;
66+
iit(description: string, func: () => void): jasmine.Spec;
67+
xit(desc: string, func: () => void): jasmine.XSpec;
68+
}
69+
declare module jasmine {
70+
interface Matchers {
71+
toHaveText(text: string): void;
72+
toBeAnInstanceOf(obj: any): void;
73+
toBePromise(): void;
74+
toBe(value: any): void;
75+
}
76+
}
77+
interface Map<K, V> {
78+
jasmineToString?(): void;
79+
}
80+
interface Console {
81+
profileEnd(str: string): any;
82+
}
83+
84+
/**
85+
* Represents the completion of an asynchronous operation
86+
*/
87+
interface Promise<T> {
88+
/**
89+
* Attaches callbacks for the resolution and/or rejection of the Promise.
90+
* @param onfulfilled The callback to execute when the Promise is resolved.
91+
* @param onrejected The callback to execute when the Promise is rejected.
92+
* @returns A Promise for the completion of which ever callback is executed.
93+
*/
94+
then<TResult>(onfulfilled?: (value: T) => TResult | Promise<TResult>, onrejected?: (reason: any) => TResult | Promise<TResult>): Promise<TResult>;
95+
96+
/**
97+
* Attaches a callback for only the rejection of the Promise.
98+
* @param onrejected The callback to execute when the Promise is rejected.
99+
* @returns A Promise for the completion of the callback.
100+
*/
101+
catch(onrejected?: (reason: any) => T | Promise<T>): Promise<T>;
102+
}
103+
104+
interface PromiseConstructor {
105+
/**
106+
* A reference to the prototype.
107+
*/
108+
prototype: Promise<any>;
109+
110+
/**
111+
* Creates a new Promise.
112+
* @param init A callback used to initialize the promise. This callback is passed two arguments:
113+
* a resolve callback used resolve the promise with a value or the result of another promise,
114+
* and a reject callback used to reject the promise with a provided reason or error.
115+
*/
116+
new <T>(init: (resolve: (value?: T | Promise<T>) => void, reject: (reason?: any) => void) => void): Promise<T>;
117+
118+
<T>(init: (resolve: (value?: T | Promise<T>) => void, reject: (reason?: any) => void) => void): Promise<T>;
119+
120+
/**
121+
* Creates a Promise that is resolved with an array of results when all of the provided Promises
122+
* resolve, or rejected when any Promise is rejected.
123+
* @param values An array of Promises.
124+
* @returns A new Promise.
125+
*/
126+
all<T>(values: (T | Promise<T>)[]): Promise<T[]>;
127+
128+
/**
129+
* Creates a Promise that is resolved with an array of results when all of the provided Promises
130+
* resolve, or rejected when any Promise is rejected.
131+
* @param values An array of values.
132+
* @returns A new Promise.
133+
*/
134+
all(values: Promise<void>[]): Promise<void>;
135+
136+
/**
137+
* Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
138+
* or rejected.
139+
* @param values An array of Promises.
140+
* @returns A new Promise.
141+
*/
142+
race<T>(values: (T | Promise<T>)[]): Promise<T>;
143+
144+
/**
145+
* Creates a new rejected promise for the provided reason.
146+
* @param reason The reason the promise was rejected.
147+
* @returns A new rejected Promise.
148+
*/
149+
reject(reason: any): Promise<void>;
150+
151+
/**
152+
* Creates a new rejected promise for the provided reason.
153+
* @param reason The reason the promise was rejected.
154+
* @returns A new rejected Promise.
155+
*/
156+
reject<T>(reason: any): Promise<T>;
157+
158+
/**
159+
* Creates a new resolved promise for the provided value.
160+
* @param value A promise.
161+
* @returns A promise whose internal state matches the provided promise.
162+
*/
163+
resolve<T>(value: T | Promise<T>): Promise<T>;
164+
165+
/**
166+
* Creates a new resolved promise .
167+
* @returns A resolved promise.
168+
*/
169+
resolve(): Promise<void>;
170+
}
171+
172+
declare var Promise: PromiseConstructor;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { ChangeDetector } from './interfaces';
2+
export declare class AbstractChangeDetector extends ChangeDetector {
3+
children: List<any>;
4+
parent: ChangeDetector;
5+
mode: string;
6+
constructor();
7+
addChild(cd: ChangeDetector): void;
8+
removeChild(cd: ChangeDetector): void;
9+
remove(): void;
10+
detectChanges(): void;
11+
checkNoChanges(): void;
12+
_detectChanges(throwOnChange: boolean): void;
13+
detectChangesInRecords(throwOnChange: boolean): void;
14+
_detectChangesInChildren(throwOnChange: boolean): void;
15+
markPathToRootAsCheckOnce(): void;
16+
}
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
export declare class ArrayChanges {
2+
_collection: any;
3+
_length: int;
4+
_linkedRecords: _DuplicateMap;
5+
_unlinkedRecords: _DuplicateMap;
6+
_previousItHead: CollectionChangeRecord;
7+
_itHead: CollectionChangeRecord;
8+
_itTail: CollectionChangeRecord;
9+
_additionsHead: CollectionChangeRecord;
10+
_additionsTail: CollectionChangeRecord;
11+
_movesHead: CollectionChangeRecord;
12+
_movesTail: CollectionChangeRecord;
13+
_removalsHead: CollectionChangeRecord;
14+
_removalsTail: CollectionChangeRecord;
15+
constructor();
16+
static supports(obj: any): boolean;
17+
supportsObj(obj: any): boolean;
18+
collection: any;
19+
length: int;
20+
forEachItem(fn: Function): void;
21+
forEachPreviousItem(fn: Function): void;
22+
forEachAddedItem(fn: Function): void;
23+
forEachMovedItem(fn: Function): void;
24+
forEachRemovedItem(fn: Function): void;
25+
check(collection: any): boolean;
26+
isDirty: boolean;
27+
/**
28+
* Reset the state of the change objects to show no changes. This means set previousKey to
29+
* currentKey, and clear all of the queues (additions, moves, removals).
30+
* Set the previousIndexes of moved and added items to their currentIndexes
31+
* Reset the list of additions, moves and removals
32+
*/
33+
_reset(): void;
34+
/**
35+
* This is the core function which handles differences between collections.
36+
*
37+
* - [record] is the record which we saw at this position last time. If null then it is a new
38+
* item.
39+
* - [item] is the current item in the collection
40+
* - [index] is the position of the item in the collection
41+
*/
42+
_mismatch(record: CollectionChangeRecord, item: any, index: int): CollectionChangeRecord;
43+
/**
44+
* This check is only needed if an array contains duplicates. (Short circuit of nothing dirty)
45+
*
46+
* Use case: `[a, a]` => `[b, a, a]`
47+
*
48+
* If we did not have this check then the insertion of `b` would:
49+
* 1) evict first `a`
50+
* 2) insert `b` at `0` index.
51+
* 3) leave `a` at index `1` as is. <-- this is wrong!
52+
* 3) reinsert `a` at index 2. <-- this is wrong!
53+
*
54+
* The correct behavior is:
55+
* 1) evict first `a`
56+
* 2) insert `b` at `0` index.
57+
* 3) reinsert `a` at index 1.
58+
* 3) move `a` at from `1` to `2`.
59+
*
60+
*
61+
* Double check that we have not evicted a duplicate item. We need to check if the item type may
62+
* have already been removed:
63+
* The insertion of b will evict the first 'a'. If we don't reinsert it now it will be reinserted
64+
* at the end. Which will show up as the two 'a's switching position. This is incorrect, since a
65+
* better way to think of it is as insert of 'b' rather then switch 'a' with 'b' and then add 'a'
66+
* at the end.
67+
*/
68+
_verifyReinsertion(record: CollectionChangeRecord, item: any, index: int): CollectionChangeRecord;
69+
/**
70+
* Get rid of any excess [CollectionChangeRecord]s from the previous collection
71+
*
72+
* - [record] The first excess [CollectionChangeRecord].
73+
*/
74+
_truncate(record: CollectionChangeRecord): void;
75+
_reinsertAfter(record: CollectionChangeRecord, prevRecord: CollectionChangeRecord, index: int): CollectionChangeRecord;
76+
_moveAfter(record: CollectionChangeRecord, prevRecord: CollectionChangeRecord, index: int): CollectionChangeRecord;
77+
_addAfter(record: CollectionChangeRecord, prevRecord: CollectionChangeRecord, index: int): CollectionChangeRecord;
78+
_insertAfter(record: CollectionChangeRecord, prevRecord: CollectionChangeRecord, index: int): CollectionChangeRecord;
79+
_remove(record: CollectionChangeRecord): CollectionChangeRecord;
80+
_unlink(record: CollectionChangeRecord): CollectionChangeRecord;
81+
_addToMoves(record: CollectionChangeRecord, toIndex: int): CollectionChangeRecord;
82+
_addToRemovals(record: CollectionChangeRecord): CollectionChangeRecord;
83+
toString(): string;
84+
}
85+
export declare class CollectionChangeRecord {
86+
currentIndex: int;
87+
previousIndex: int;
88+
item: any;
89+
_nextPrevious: CollectionChangeRecord;
90+
_prev: CollectionChangeRecord;
91+
_next: CollectionChangeRecord;
92+
_prevDup: CollectionChangeRecord;
93+
_nextDup: CollectionChangeRecord;
94+
_prevRemoved: CollectionChangeRecord;
95+
_nextRemoved: CollectionChangeRecord;
96+
_nextAdded: CollectionChangeRecord;
97+
_nextMoved: CollectionChangeRecord;
98+
constructor(item: any);
99+
toString(): string;
100+
}
101+
export declare class _DuplicateMap {
102+
map: Map<any, any>;
103+
constructor();
104+
put(record: CollectionChangeRecord): void;
105+
/**
106+
* Retrieve the `value` using key. Because the CollectionChangeRecord value maybe one which we
107+
* have already iterated over, we use the afterIndex to pretend it is not there.
108+
*
109+
* Use case: `[a, b, c, a, a]` if we are at index `3` which is the second `a` then asking if we
110+
* have any more `a`s needs to return the last `a` not the first or second.
111+
*/
112+
get(value: any, afterIndex?: any): CollectionChangeRecord;
113+
/**
114+
* Removes an [CollectionChangeRecord] from the list of duplicates.
115+
*
116+
* The list of duplicates also is removed from the map if it gets empty.
117+
*/
118+
remove(record: CollectionChangeRecord): CollectionChangeRecord;
119+
isEmpty: boolean;
120+
clear(): void;
121+
toString(): string;
122+
}

0 commit comments

Comments
 (0)