diff --git a/modules/angular2/angular2.dart b/modules/angular2/angular2.dart new file mode 100644 index 0000000000..9743f18b29 --- /dev/null +++ b/modules/angular2/angular2.dart @@ -0,0 +1,8 @@ +library angular2; + +/** + * An all-in-one place to import Angular 2 stuff. + * + * This library does not include `bootstrap`. Import `bootstrap.dart` instead. + */ +export 'package:angular2/angular2_exports.dart'; diff --git a/modules/angular2/angular2.ts b/modules/angular2/angular2.ts index e1b961307e..7cf9d64925 100644 --- a/modules/angular2/angular2.ts +++ b/modules/angular2/angular2.ts @@ -1,6 +1,12 @@ /** * The `angular2` is the single place to import all of the individual types. */ +export {commonBootstrap as bootstrap} from 'angular2/src/core/application_common'; + +// TODO(someone familiar with systemjs): the exports below are copied from +// angular2_exports.ts. Re-exporting from angular2_exports.ts causes systemjs +// to resolve imports very very very slowly. See also a similar notice in +// bootstrap.ts export * from 'angular2/annotations'; export * from 'angular2/core'; @@ -28,34 +34,7 @@ export { export * from './di'; export * from './forms'; - export * from './directives'; - -export { - AbstractControl, - AbstractControlDirective, - Control, - ControlGroup, - ControlArray, - NgControlName, - NgFormControl, - NgModel, - NgControl, - NgControlGroup, - NgFormModel, - NgForm, - ControlValueAccessor, - DefaultValueAccessor, - CheckboxControlValueAccessor, - SelectControlValueAccessor, - formDirectives, - Validators, - NgValidator, - NgRequiredValidator, - FormBuilder, - formInjectables -} from './forms'; - export * from './http'; export { RenderEventDispatcher, diff --git a/modules/angular2/angular2_exports.ts b/modules/angular2/angular2_exports.ts new file mode 100644 index 0000000000..bb7318c005 --- /dev/null +++ b/modules/angular2/angular2_exports.ts @@ -0,0 +1,43 @@ +export * from 'angular2/annotations'; +export * from 'angular2/core'; + +export { + DehydratedException, + ExpressionChangedAfterItHasBeenChecked, + ChangeDetectionError, + + ON_PUSH, + DEFAULT, + + ChangeDetectorRef, + + Pipes, + WrappedValue, + Pipe, + PipeFactory, + NullPipe, + NullPipeFactory, + defaultPipes, + BasePipe, + + Locals +} from './change_detection'; + +export * from './di'; +export * from './forms'; +export * from './directives'; +export * from './http'; +export { + RenderEventDispatcher, + Renderer, + RenderElementRef, + RenderViewRef, + RenderProtoViewRef, + RenderFragmentRef, + RenderViewWithFragments +} from 'angular2/src/render/api'; +export { + DomRenderer, + DOCUMENT_TOKEN, + DOM_REFLECT_PROPERTIES_AS_ATTRIBUTES +} from 'angular2/src/render/dom/dom_renderer'; diff --git a/modules/angular2/bootstrap.ts b/modules/angular2/bootstrap.ts new file mode 100644 index 0000000000..8aaae9ba47 --- /dev/null +++ b/modules/angular2/bootstrap.ts @@ -0,0 +1,52 @@ +/** + * Contains everything you need to bootstrap your application. + */ +export {bootstrap} from 'angular2/src/core/application'; + +// TODO(someone familiar with systemjs): the exports below are copied from +// angular2_exports.ts. Re-exporting from angular2_exports.ts causes systemjs +// to resolve imports very very very slowly. See also a similar notice in +// angular2.ts +export * from 'angular2/annotations'; +export * from 'angular2/core'; + +export { + DehydratedException, + ExpressionChangedAfterItHasBeenChecked, + ChangeDetectionError, + + ON_PUSH, + DEFAULT, + + ChangeDetectorRef, + + Pipes, + WrappedValue, + Pipe, + PipeFactory, + NullPipe, + NullPipeFactory, + defaultPipes, + BasePipe, + + Locals +} from './change_detection'; + +export * from './di'; +export * from './forms'; +export * from './directives'; +export * from './http'; +export { + RenderEventDispatcher, + Renderer, + RenderElementRef, + RenderViewRef, + RenderProtoViewRef, + RenderFragmentRef, + RenderViewWithFragments +} from 'angular2/src/render/api'; +export { + DomRenderer, + DOCUMENT_TOKEN, + DOM_REFLECT_PROPERTIES_AS_ATTRIBUTES +} from 'angular2/src/render/dom/dom_renderer'; diff --git a/modules/angular2/bootstrap_static.dart b/modules/angular2/bootstrap_static.dart new file mode 100644 index 0000000000..dee16ac0a7 --- /dev/null +++ b/modules/angular2/bootstrap_static.dart @@ -0,0 +1,4 @@ +library angular2.bootstrap_static; + +export 'angular2_exports.dart'; +export 'src/core/application_static.dart'; diff --git a/modules/angular2/core.ts b/modules/angular2/core.ts index 896d674a91..b6dd109055 100644 --- a/modules/angular2/core.ts +++ b/modules/angular2/core.ts @@ -3,8 +3,8 @@ * @description * Define angular core API here. */ -export {bootstrap, ApplicationRef} from 'angular2/src/core/application'; export {appComponentTypeToken} from 'angular2/src/core/application_tokens'; +export {ApplicationRef} from 'angular2/src/core/application_common'; // Compiler Related Dependencies. diff --git a/modules/angular2/src/core/application.dart b/modules/angular2/src/core/application.dart new file mode 100644 index 0000000000..cee336add1 --- /dev/null +++ b/modules/angular2/src/core/application.dart @@ -0,0 +1,21 @@ +library angular2.application; + +import 'dart:async'; + +import 'package:angular2/src/reflection/reflection.dart' show reflector; +import 'package:angular2/src/reflection/reflection_capabilities.dart' show ReflectionCapabilities; +import 'application_common.dart'; + +export 'application_common.dart' show ApplicationRef; + +/// Starts an application from a root component. This implementation uses +/// mirrors. Angular 2 transformer automatically replaces this method with a +/// static implementation (see `application_static.dart`) that does not use +/// mirrors and produces a faster and more compact JS code. +/// +/// See [commonBootstrap] for detailed documentation. +Future bootstrap(Type appComponentType, + [List componentInjectableBindings, Function errorReporter]) { + reflector.reflectionCapabilities = new ReflectionCapabilities(); + return commonBootstrap(appComponentType, componentInjectableBindings, errorReporter); +} diff --git a/modules/angular2/src/core/application.ts b/modules/angular2/src/core/application.ts index 0d2d9f2768..17eba2e993 100644 --- a/modules/angular2/src/core/application.ts +++ b/modules/angular2/src/core/application.ts @@ -1,372 +1 @@ -import {Injector, bind, OpaqueToken, Binding} from 'angular2/di'; -import { - NumberWrapper, - Type, - isBlank, - isPresent, - BaseException, - assertionsEnabled, - print, - stringify -} from 'angular2/src/facade/lang'; -import {BrowserDomAdapter} from 'angular2/src/dom/browser_adapter'; -import {DOM} from 'angular2/src/dom/dom_adapter'; -import {Compiler, CompilerCache} from './compiler/compiler'; -import {Reflector, reflector} from 'angular2/src/reflection/reflection'; -import { - Parser, - Lexer, - ChangeDetection, - DynamicChangeDetection, - JitChangeDetection, - PreGeneratedChangeDetection, - Pipes, - defaultPipes -} from 'angular2/change_detection'; -import {ExceptionHandler} from './exception_handler'; -import {ViewLoader} from 'angular2/src/render/dom/compiler/view_loader'; -import {StyleUrlResolver} from 'angular2/src/render/dom/compiler/style_url_resolver'; -import {StyleInliner} from 'angular2/src/render/dom/compiler/style_inliner'; -import {ViewResolver} from './compiler/view_resolver'; -import {DirectiveResolver} from './compiler/directive_resolver'; -import {List, ListWrapper} from 'angular2/src/facade/collection'; -import {Promise, PromiseWrapper} from 'angular2/src/facade/async'; -import {NgZone} from 'angular2/src/core/zone/ng_zone'; -import {LifeCycle} from 'angular2/src/core/life_cycle/life_cycle'; -import {ShadowDomStrategy} from 'angular2/src/render/dom/shadow_dom/shadow_dom_strategy'; -import { - EmulatedUnscopedShadowDomStrategy -} from 'angular2/src/render/dom/shadow_dom/emulated_unscoped_shadow_dom_strategy'; -import {XHR} from 'angular2/src/render/xhr'; -import {XHRImpl} from 'angular2/src/render/xhr_impl'; -import {EventManager, DomEventsPlugin} from 'angular2/src/render/dom/events/event_manager'; -import {KeyEventsPlugin} from 'angular2/src/render/dom/events/key_events'; -import {HammerGesturesPlugin} from 'angular2/src/render/dom/events/hammer_gestures'; -import {ComponentUrlMapper} from 'angular2/src/core/compiler/component_url_mapper'; -import {UrlResolver} from 'angular2/src/services/url_resolver'; -import {AppRootUrl} from 'angular2/src/services/app_root_url'; -import { - ComponentRef, - DynamicComponentLoader -} from 'angular2/src/core/compiler/dynamic_component_loader'; -import {TestabilityRegistry, Testability} from 'angular2/src/core/testability/testability'; -import {AppViewPool, APP_VIEW_POOL_CAPACITY} from 'angular2/src/core/compiler/view_pool'; -import {AppViewManager} from 'angular2/src/core/compiler/view_manager'; -import {AppViewManagerUtils} from 'angular2/src/core/compiler/view_manager_utils'; -import {AppViewListener} from 'angular2/src/core/compiler/view_listener'; -import {ProtoViewFactory} from 'angular2/src/core/compiler/proto_view_factory'; -import {Renderer, RenderCompiler} from 'angular2/src/render/api'; -import { - DomRenderer, - DOCUMENT_TOKEN, - DOM_REFLECT_PROPERTIES_AS_ATTRIBUTES -} from 'angular2/src/render/dom/dom_renderer'; -import {DefaultDomCompiler} from 'angular2/src/render/dom/compiler/compiler'; -import {internalView} from 'angular2/src/core/compiler/view_ref'; - -import {appComponentRefPromiseToken, appComponentTypeToken} from './application_tokens'; - -var _rootInjector: Injector; - -// Contains everything that is safe to share between applications. -var _rootBindings = [bind(Reflector).toValue(reflector), TestabilityRegistry]; - -function _injectorBindings(appComponentType): List> { - var bestChangeDetection: Type = DynamicChangeDetection; - if (PreGeneratedChangeDetection.isSupported()) { - bestChangeDetection = PreGeneratedChangeDetection; - } else if (JitChangeDetection.isSupported()) { - bestChangeDetection = JitChangeDetection; - } - return [ - bind(DOCUMENT_TOKEN) - .toValue(DOM.defaultDoc()), - bind(DOM_REFLECT_PROPERTIES_AS_ATTRIBUTES).toValue(false), - bind(appComponentTypeToken).toValue(appComponentType), - bind(appComponentRefPromiseToken) - .toFactory( - (dynamicComponentLoader, injector, testability, registry) => { - // TODO(rado): investigate whether to support bindings on root component. - return dynamicComponentLoader.loadAsRoot(appComponentType, null, injector) - .then((componentRef) => { - registry.registerApplication(componentRef.location.nativeElement, testability); - return componentRef; - }); - }, - [DynamicComponentLoader, Injector, Testability, TestabilityRegistry]), - - bind(appComponentType) - .toFactory((p: Promise) => p.then(ref => ref.instance), [appComponentRefPromiseToken]), - bind(LifeCycle) - .toFactory((exceptionHandler) => new LifeCycle(exceptionHandler, null, assertionsEnabled()), - [ExceptionHandler]), - bind(EventManager) - .toFactory( - (ngZone) => { - var plugins = - [new HammerGesturesPlugin(), new KeyEventsPlugin(), new DomEventsPlugin()]; - return new EventManager(plugins, ngZone); - }, - [NgZone]), - bind(ShadowDomStrategy) - .toFactory((doc) => new EmulatedUnscopedShadowDomStrategy(doc.head), [DOCUMENT_TOKEN]), - DomRenderer, - DefaultDomCompiler, - bind(Renderer).toAlias(DomRenderer), - bind(RenderCompiler).toAlias(DefaultDomCompiler), - ProtoViewFactory, - AppViewPool, - bind(APP_VIEW_POOL_CAPACITY).toValue(10000), - AppViewManager, - AppViewManagerUtils, - AppViewListener, - Compiler, - CompilerCache, - ViewResolver, - bind(Pipes).toValue(defaultPipes), - bind(ChangeDetection).toClass(bestChangeDetection), - ViewLoader, - DirectiveResolver, - Parser, - Lexer, - ExceptionHandler, - bind(XHR).toValue(new XHRImpl()), - ComponentUrlMapper, - UrlResolver, - StyleUrlResolver, - StyleInliner, - DynamicComponentLoader, - Testability, - AppRootUrl - ]; -} - -function _createNgZone(givenReporter: Function): NgZone { - var defaultErrorReporter = (exception, stackTrace) => { - var longStackTrace = ListWrapper.join(stackTrace, "\n\n-----async gap-----\n"); - DOM.logError(`${exception}\n\n${longStackTrace}`); - - if (exception instanceof BaseException && isPresent(exception.context)) { - print("Error Context:"); - print(exception.context); - } - throw exception; - }; - - var reporter = isPresent(givenReporter) ? givenReporter : defaultErrorReporter; - - var zone = new NgZone({enableLongStackTrace: assertionsEnabled()}); - zone.overrideOnErrorHandler(reporter); - return zone; -} - -/** - * Bootstrapping for Angular applications. - * - * You instantiate an Angular application by explicitly specifying a component to use as the root - * component for your - * application via the `bootstrap()` method. - * - * ## Simple Example - * - * Assuming this `index.html`: - * - * ```html - * - * - * - * loading... - * - * - * ``` - * - * An application is bootstrapped inside an existing browser DOM, typically `index.html`. Unlike - * Angular 1, Angular 2 - * does not compile/process bindings in `index.html`. This is mainly for security reasons, as well - * as architectural - * changes in Angular 2. This means that `index.html` can safely be processed using server-side - * technologies such as - * bindings. Bindings can thus use double-curly `{{ syntax }}` without collision from Angular 2 - * component double-curly - * `{{ syntax }}`. - * - * We can use this script code: - * - * ``` - * @Component({ - * selector: 'my-app' - * }) - * @View({ - * template: 'Hello {{ name }}!' - * }) - * class MyApp { - * name:string; - * - * constructor() { - * this.name = 'World'; - * } - * } - * - * main() { - * return bootstrap(MyApp); - * } - * ``` - * - * When the app developer invokes `bootstrap()` with the root component `MyApp` as its argument, - * Angular performs the - * following tasks: - * - * 1. It uses the component's `selector` property to locate the DOM element which needs to be - * upgraded into - * the angular component. - * 2. It creates a new child injector (from the platform injector). Optionally, you can also - * override the injector configuration for an app by - * invoking `bootstrap` with the `componentInjectableBindings` argument. - * 3. It creates a new `Zone` and connects it to the angular application's change detection domain - * instance. - * 4. It creates a shadow DOM on the selected component's host element and loads the template into - * it. - * 5. It instantiates the specified component. - * 6. Finally, Angular performs change detection to apply the initial data bindings for the - * application. - * - * - * ## Instantiating Multiple Applications on a Single Page - * - * There are two ways to do this. - * - * - * ### Isolated Applications - * - * Angular creates a new application each time that the `bootstrap()` method is invoked. When - * multiple applications - * are created for a page, Angular treats each application as independent within an isolated change - * detection and - * `Zone` domain. If you need to share data between applications, use the strategy described in the - * next - * section, "Applications That Share Change Detection." - * - * - * ### Applications That Share Change Detection - * - * If you need to bootstrap multiple applications that share common data, the applications must - * share a common - * change detection and zone. To do that, create a meta-component that lists the application - * components in its template. - * By only invoking the `bootstrap()` method once, with the meta-component as its argument, you - * ensure that only a - * single change detection zone is created and therefore data can be shared across the applications. - * - * - * ## Platform Injector - * - * When working within a browser window, there are many singleton resources: cookies, title, - * location, and others. - * Angular services that represent these resources must likewise be shared across all Angular - * applications that - * occupy the same browser window. For this reason, Angular creates exactly one global platform - * injector which stores - * all shared services, and each angular application injector has the platform injector as its - * parent. - * - * Each application has its own private injector as well. When there are multiple applications on a - * page, Angular treats - * each application injector's services as private to that application. - * - * - * # API - * - `appComponentType`: The root component which should act as the application. This is a reference - * to a `Type` - * which is annotated with `@Component(...)`. - * - `componentInjectableBindings`: An additional set of bindings that can be added to the app - * injector - * to override default injection behavior. - * - `errorReporter`: `function(exception:any, stackTrace:string)` a default error reporter for - * unhandled exceptions. - * - * Returns a `Promise` of {@link ApplicationRef}. - */ -export function bootstrap(appComponentType: Type, - componentInjectableBindings: List> = null, - errorReporter: Function = null): Promise { - BrowserDomAdapter.makeCurrent(); - var bootstrapProcess = PromiseWrapper.completer(); - - var zone = _createNgZone(errorReporter); - zone.run(() => { - // TODO(rado): prepopulate template cache, so applications with only - // index.html and main.js are possible. - - var appInjector = _createAppInjector(appComponentType, componentInjectableBindings, zone); - var compRefToken: Promise = - PromiseWrapper.wrap(() => appInjector.get(appComponentRefPromiseToken)); - var tick = (componentRef) => { - var appChangeDetector = internalView(componentRef.hostView).changeDetector; - // retrieve life cycle: may have already been created if injected in root component - var lc = appInjector.get(LifeCycle); - lc.registerWith(zone, appChangeDetector); - lc.tick(); // the first tick that will bootstrap the app - - bootstrapProcess.resolve(new ApplicationRef(componentRef, appComponentType, appInjector)); - }; - PromiseWrapper.then(compRefToken, tick, - (err, stackTrace) => bootstrapProcess.reject(err, stackTrace)); - }); - - return bootstrapProcess.promise; -} - -/** - * Represents a Angular's representation of an Application. - * - * `ApplicationRef` represents a running application instance. Use it to retrieve the host - * component, injector, - * or dispose of an application. - */ -export class ApplicationRef { - _hostComponent: ComponentRef; - _injector: Injector; - _hostComponentType: Type; - - /** - * @private - */ - constructor(hostComponent: ComponentRef, hostComponentType: Type, injector: Injector) { - this._hostComponent = hostComponent; - this._injector = injector; - this._hostComponentType = hostComponentType; - } - - /** - * Returns the current {@link Component} type. - */ - get hostComponentType(): Type { return this._hostComponentType; } - - /** - * Returns the current {@link Component} instance. - */ - get hostComponent(): any { return this._hostComponent.instance; } - - /** - * Dispose (un-load) the application. - */ - dispose(): void { - // TODO: We also need to clean up the Zone, ... here! - this._hostComponent.dispose(); - } - - /** - * Returns the root application {@link Injector}. - */ - get injector(): Injector { return this._injector; } -} - -function _createAppInjector(appComponentType: Type, bindings: List>, - zone: NgZone): Injector { - if (isBlank(_rootInjector)) _rootInjector = Injector.resolveAndCreate(_rootBindings); - var mergedBindings: any[] = - isPresent(bindings) ? ListWrapper.concat(_injectorBindings(appComponentType), bindings) : - _injectorBindings(appComponentType); - mergedBindings.push(bind(NgZone).toValue(zone)); - return _rootInjector.resolveAndCreateChild(mergedBindings); -} +export {ApplicationRef, commonBootstrap as bootstrap} from './application_common'; diff --git a/modules/angular2/src/core/application_common.ts b/modules/angular2/src/core/application_common.ts new file mode 100644 index 0000000000..77f51b0441 --- /dev/null +++ b/modules/angular2/src/core/application_common.ts @@ -0,0 +1,372 @@ +import {Injector, bind, OpaqueToken, Binding} from 'angular2/di'; +import { + NumberWrapper, + Type, + isBlank, + isPresent, + BaseException, + assertionsEnabled, + print, + stringify +} from 'angular2/src/facade/lang'; +import {BrowserDomAdapter} from 'angular2/src/dom/browser_adapter'; +import {DOM} from 'angular2/src/dom/dom_adapter'; +import {Compiler, CompilerCache} from './compiler/compiler'; +import {Reflector, reflector} from 'angular2/src/reflection/reflection'; +import { + Parser, + Lexer, + ChangeDetection, + DynamicChangeDetection, + JitChangeDetection, + PreGeneratedChangeDetection, + Pipes, + defaultPipes +} from 'angular2/change_detection'; +import {ExceptionHandler} from './exception_handler'; +import {ViewLoader} from 'angular2/src/render/dom/compiler/view_loader'; +import {StyleUrlResolver} from 'angular2/src/render/dom/compiler/style_url_resolver'; +import {StyleInliner} from 'angular2/src/render/dom/compiler/style_inliner'; +import {ViewResolver} from './compiler/view_resolver'; +import {DirectiveResolver} from './compiler/directive_resolver'; +import {List, ListWrapper} from 'angular2/src/facade/collection'; +import {Promise, PromiseWrapper} from 'angular2/src/facade/async'; +import {NgZone} from 'angular2/src/core/zone/ng_zone'; +import {LifeCycle} from 'angular2/src/core/life_cycle/life_cycle'; +import {ShadowDomStrategy} from 'angular2/src/render/dom/shadow_dom/shadow_dom_strategy'; +import { + EmulatedUnscopedShadowDomStrategy +} from 'angular2/src/render/dom/shadow_dom/emulated_unscoped_shadow_dom_strategy'; +import {XHR} from 'angular2/src/render/xhr'; +import {XHRImpl} from 'angular2/src/render/xhr_impl'; +import {EventManager, DomEventsPlugin} from 'angular2/src/render/dom/events/event_manager'; +import {KeyEventsPlugin} from 'angular2/src/render/dom/events/key_events'; +import {HammerGesturesPlugin} from 'angular2/src/render/dom/events/hammer_gestures'; +import {ComponentUrlMapper} from 'angular2/src/core/compiler/component_url_mapper'; +import {UrlResolver} from 'angular2/src/services/url_resolver'; +import {AppRootUrl} from 'angular2/src/services/app_root_url'; +import { + ComponentRef, + DynamicComponentLoader +} from 'angular2/src/core/compiler/dynamic_component_loader'; +import {TestabilityRegistry, Testability} from 'angular2/src/core/testability/testability'; +import {AppViewPool, APP_VIEW_POOL_CAPACITY} from 'angular2/src/core/compiler/view_pool'; +import {AppViewManager} from 'angular2/src/core/compiler/view_manager'; +import {AppViewManagerUtils} from 'angular2/src/core/compiler/view_manager_utils'; +import {AppViewListener} from 'angular2/src/core/compiler/view_listener'; +import {ProtoViewFactory} from 'angular2/src/core/compiler/proto_view_factory'; +import {Renderer, RenderCompiler} from 'angular2/src/render/api'; +import { + DomRenderer, + DOCUMENT_TOKEN, + DOM_REFLECT_PROPERTIES_AS_ATTRIBUTES +} from 'angular2/src/render/dom/dom_renderer'; +import {DefaultDomCompiler} from 'angular2/src/render/dom/compiler/compiler'; +import {internalView} from 'angular2/src/core/compiler/view_ref'; + +import {appComponentRefPromiseToken, appComponentTypeToken} from './application_tokens'; + +var _rootInjector: Injector; + +// Contains everything that is safe to share between applications. +var _rootBindings = [bind(Reflector).toValue(reflector), TestabilityRegistry]; + +function _injectorBindings(appComponentType): List> { + var bestChangeDetection: Type = DynamicChangeDetection; + if (PreGeneratedChangeDetection.isSupported()) { + bestChangeDetection = PreGeneratedChangeDetection; + } else if (JitChangeDetection.isSupported()) { + bestChangeDetection = JitChangeDetection; + } + return [ + bind(DOCUMENT_TOKEN) + .toValue(DOM.defaultDoc()), + bind(DOM_REFLECT_PROPERTIES_AS_ATTRIBUTES).toValue(false), + bind(appComponentTypeToken).toValue(appComponentType), + bind(appComponentRefPromiseToken) + .toFactory( + (dynamicComponentLoader, injector, testability, registry) => { + // TODO(rado): investigate whether to support bindings on root component. + return dynamicComponentLoader.loadAsRoot(appComponentType, null, injector) + .then((componentRef) => { + registry.registerApplication(componentRef.location.nativeElement, testability); + return componentRef; + }); + }, + [DynamicComponentLoader, Injector, Testability, TestabilityRegistry]), + + bind(appComponentType) + .toFactory((p: Promise) => p.then(ref => ref.instance), [appComponentRefPromiseToken]), + bind(LifeCycle) + .toFactory((exceptionHandler) => new LifeCycle(exceptionHandler, null, assertionsEnabled()), + [ExceptionHandler]), + bind(EventManager) + .toFactory( + (ngZone) => { + var plugins = + [new HammerGesturesPlugin(), new KeyEventsPlugin(), new DomEventsPlugin()]; + return new EventManager(plugins, ngZone); + }, + [NgZone]), + bind(ShadowDomStrategy) + .toFactory((doc) => new EmulatedUnscopedShadowDomStrategy(doc.head), [DOCUMENT_TOKEN]), + DomRenderer, + DefaultDomCompiler, + bind(Renderer).toAlias(DomRenderer), + bind(RenderCompiler).toAlias(DefaultDomCompiler), + ProtoViewFactory, + AppViewPool, + bind(APP_VIEW_POOL_CAPACITY).toValue(10000), + AppViewManager, + AppViewManagerUtils, + AppViewListener, + Compiler, + CompilerCache, + ViewResolver, + bind(Pipes).toValue(defaultPipes), + bind(ChangeDetection).toClass(bestChangeDetection), + ViewLoader, + DirectiveResolver, + Parser, + Lexer, + ExceptionHandler, + bind(XHR).toValue(new XHRImpl()), + ComponentUrlMapper, + UrlResolver, + StyleUrlResolver, + StyleInliner, + DynamicComponentLoader, + Testability, + AppRootUrl + ]; +} + +function _createNgZone(givenReporter: Function): NgZone { + var defaultErrorReporter = (exception, stackTrace) => { + var longStackTrace = ListWrapper.join(stackTrace, "\n\n-----async gap-----\n"); + DOM.logError(`${exception}\n\n${longStackTrace}`); + + if (exception instanceof BaseException && isPresent(exception.context)) { + print("Error Context:"); + print(exception.context); + } + throw exception; + }; + + var reporter = isPresent(givenReporter) ? givenReporter : defaultErrorReporter; + + var zone = new NgZone({enableLongStackTrace: assertionsEnabled()}); + zone.overrideOnErrorHandler(reporter); + return zone; +} + +/** + * Bootstrapping for Angular applications. + * + * You instantiate an Angular application by explicitly specifying a component to use as the root + * component for your + * application via the `bootstrap()` method. + * + * ## Simple Example + * + * Assuming this `index.html`: + * + * ```html + * + * + * + * loading... + * + * + * ``` + * + * An application is bootstrapped inside an existing browser DOM, typically `index.html`. Unlike + * Angular 1, Angular 2 + * does not compile/process bindings in `index.html`. This is mainly for security reasons, as well + * as architectural + * changes in Angular 2. This means that `index.html` can safely be processed using server-side + * technologies such as + * bindings. Bindings can thus use double-curly `{{ syntax }}` without collision from Angular 2 + * component double-curly + * `{{ syntax }}`. + * + * We can use this script code: + * + * ``` + * @Component({ + * selector: 'my-app' + * }) + * @View({ + * template: 'Hello {{ name }}!' + * }) + * class MyApp { + * name:string; + * + * constructor() { + * this.name = 'World'; + * } + * } + * + * main() { + * return bootstrap(MyApp); + * } + * ``` + * + * When the app developer invokes `bootstrap()` with the root component `MyApp` as its argument, + * Angular performs the + * following tasks: + * + * 1. It uses the component's `selector` property to locate the DOM element which needs to be + * upgraded into + * the angular component. + * 2. It creates a new child injector (from the platform injector). Optionally, you can also + * override the injector configuration for an app by + * invoking `bootstrap` with the `componentInjectableBindings` argument. + * 3. It creates a new `Zone` and connects it to the angular application's change detection domain + * instance. + * 4. It creates a shadow DOM on the selected component's host element and loads the template into + * it. + * 5. It instantiates the specified component. + * 6. Finally, Angular performs change detection to apply the initial data bindings for the + * application. + * + * + * ## Instantiating Multiple Applications on a Single Page + * + * There are two ways to do this. + * + * + * ### Isolated Applications + * + * Angular creates a new application each time that the `bootstrap()` method is invoked. When + * multiple applications + * are created for a page, Angular treats each application as independent within an isolated change + * detection and + * `Zone` domain. If you need to share data between applications, use the strategy described in the + * next + * section, "Applications That Share Change Detection." + * + * + * ### Applications That Share Change Detection + * + * If you need to bootstrap multiple applications that share common data, the applications must + * share a common + * change detection and zone. To do that, create a meta-component that lists the application + * components in its template. + * By only invoking the `bootstrap()` method once, with the meta-component as its argument, you + * ensure that only a + * single change detection zone is created and therefore data can be shared across the applications. + * + * + * ## Platform Injector + * + * When working within a browser window, there are many singleton resources: cookies, title, + * location, and others. + * Angular services that represent these resources must likewise be shared across all Angular + * applications that + * occupy the same browser window. For this reason, Angular creates exactly one global platform + * injector which stores + * all shared services, and each angular application injector has the platform injector as its + * parent. + * + * Each application has its own private injector as well. When there are multiple applications on a + * page, Angular treats + * each application injector's services as private to that application. + * + * + * # API + * - `appComponentType`: The root component which should act as the application. This is a reference + * to a `Type` + * which is annotated with `@Component(...)`. + * - `componentInjectableBindings`: An additional set of bindings that can be added to the app + * injector + * to override default injection behavior. + * - `errorReporter`: `function(exception:any, stackTrace:string)` a default error reporter for + * unhandled exceptions. + * + * Returns a `Promise` of {@link ApplicationRef}. + */ +export function commonBootstrap( + appComponentType: Type, componentInjectableBindings: List> = null, + errorReporter: Function = null): Promise { + BrowserDomAdapter.makeCurrent(); + var bootstrapProcess = PromiseWrapper.completer(); + + var zone = _createNgZone(errorReporter); + zone.run(() => { + // TODO(rado): prepopulate template cache, so applications with only + // index.html and main.js are possible. + + var appInjector = _createAppInjector(appComponentType, componentInjectableBindings, zone); + var compRefToken: Promise = + PromiseWrapper.wrap(() => appInjector.get(appComponentRefPromiseToken)); + var tick = (componentRef) => { + var appChangeDetector = internalView(componentRef.hostView).changeDetector; + // retrieve life cycle: may have already been created if injected in root component + var lc = appInjector.get(LifeCycle); + lc.registerWith(zone, appChangeDetector); + lc.tick(); // the first tick that will bootstrap the app + + bootstrapProcess.resolve(new ApplicationRef(componentRef, appComponentType, appInjector)); + }; + PromiseWrapper.then(compRefToken, tick, + (err, stackTrace) => bootstrapProcess.reject(err, stackTrace)); + }); + + return bootstrapProcess.promise; +} + +/** + * Represents a Angular's representation of an Application. + * + * `ApplicationRef` represents a running application instance. Use it to retrieve the host + * component, injector, + * or dispose of an application. + */ +export class ApplicationRef { + _hostComponent: ComponentRef; + _injector: Injector; + _hostComponentType: Type; + + /** + * @private + */ + constructor(hostComponent: ComponentRef, hostComponentType: Type, injector: Injector) { + this._hostComponent = hostComponent; + this._injector = injector; + this._hostComponentType = hostComponentType; + } + + /** + * Returns the current {@link Component} type. + */ + get hostComponentType(): Type { return this._hostComponentType; } + + /** + * Returns the current {@link Component} instance. + */ + get hostComponent(): any { return this._hostComponent.instance; } + + /** + * Dispose (un-load) the application. + */ + dispose(): void { + // TODO: We also need to clean up the Zone, ... here! + this._hostComponent.dispose(); + } + + /** + * Returns the root application {@link Injector}. + */ + get injector(): Injector { return this._injector; } +} + +function _createAppInjector(appComponentType: Type, bindings: List>, + zone: NgZone): Injector { + if (isBlank(_rootInjector)) _rootInjector = Injector.resolveAndCreate(_rootBindings); + var mergedBindings: any[] = + isPresent(bindings) ? ListWrapper.concat(_injectorBindings(appComponentType), bindings) : + _injectorBindings(appComponentType); + mergedBindings.push(bind(NgZone).toValue(zone)); + return _rootInjector.resolveAndCreateChild(mergedBindings); +} diff --git a/modules/angular2/src/core/application_static.dart b/modules/angular2/src/core/application_static.dart new file mode 100644 index 0000000000..ef2b8f57a9 --- /dev/null +++ b/modules/angular2/src/core/application_static.dart @@ -0,0 +1,14 @@ +library angular2.application_static; + +import 'dart:async'; +import 'application_common.dart'; + +/// Starts an application from a root component. +/// +/// See [commonBootstrap] for detailed documentation. +Future bootstrapStatic( + Type appComponentType, + [List componentInjectableBindings, + Function errorReporter]) { + return commonBootstrap(appComponentType, componentInjectableBindings, errorReporter); +} diff --git a/modules/angular2/src/directives/ng_for.ts b/modules/angular2/src/directives/ng_for.ts index 3c20634547..035c511099 100644 --- a/modules/angular2/src/directives/ng_for.ts +++ b/modules/angular2/src/directives/ng_for.ts @@ -1,13 +1,6 @@ -import {Directive} from 'angular2/annotations'; -import { - ViewContainerRef, - ViewRef, - TemplateRef, - Pipes, - LifecycleEvent, - Pipe, - ChangeDetectorRef -} from 'angular2/angular2'; +import {Directive, LifecycleEvent} from 'angular2/annotations'; +import {ViewContainerRef, ViewRef, TemplateRef} from 'angular2/core'; +import {ChangeDetectorRef, Pipe, Pipes} from 'angular2/change_detection'; import {isPresent, isBlank} from 'angular2/src/facade/lang'; /** diff --git a/modules/angular2/src/forms/directives/ng_control_group.ts b/modules/angular2/src/forms/directives/ng_control_group.ts index 6ee7f10c30..338613867c 100644 --- a/modules/angular2/src/forms/directives/ng_control_group.ts +++ b/modules/angular2/src/forms/directives/ng_control_group.ts @@ -1,4 +1,4 @@ -import {Directive, LifecycleEvent} from 'angular2/angular2'; +import {Directive, LifecycleEvent} from 'angular2/annotations'; import {Inject, Ancestor, forwardRef, Binding} from 'angular2/di'; import {List, ListWrapper} from 'angular2/src/facade/collection'; import {CONST_EXPR} from 'angular2/src/facade/lang'; diff --git a/modules/angular2/src/forms/directives/ng_control_name.ts b/modules/angular2/src/forms/directives/ng_control_name.ts index d7f63b28f1..3dd20efb74 100644 --- a/modules/angular2/src/forms/directives/ng_control_name.ts +++ b/modules/angular2/src/forms/directives/ng_control_name.ts @@ -2,7 +2,8 @@ import {CONST_EXPR} from 'angular2/src/facade/lang'; import {EventEmitter, ObservableWrapper} from 'angular2/src/facade/async'; import {List, StringMap} from 'angular2/src/facade/collection'; -import {Directive, LifecycleEvent, Query, QueryList} from 'angular2/angular2'; +import {QueryList} from 'angular2/core'; +import {Query, Directive, LifecycleEvent} from 'angular2/annotations'; import {forwardRef, Ancestor, Binding, Inject} from 'angular2/di'; import {ControlContainer} from './control_container'; diff --git a/modules/angular2/src/forms/directives/ng_form_control.ts b/modules/angular2/src/forms/directives/ng_form_control.ts index 36937f2938..a5b579d775 100644 --- a/modules/angular2/src/forms/directives/ng_form_control.ts +++ b/modules/angular2/src/forms/directives/ng_form_control.ts @@ -1,7 +1,8 @@ import {CONST_EXPR} from 'angular2/src/facade/lang'; import {EventEmitter, ObservableWrapper} from 'angular2/src/facade/async'; -import {Directive, LifecycleEvent, Query, QueryList} from 'angular2/angular2'; +import {QueryList} from 'angular2/core'; +import {Query, Directive, LifecycleEvent} from 'angular2/annotations'; import {forwardRef, Ancestor, Binding} from 'angular2/di'; import {NgControl} from './ng_control'; diff --git a/modules/angular2/src/forms/directives/ng_form_model.ts b/modules/angular2/src/forms/directives/ng_form_model.ts index 8abfcbfcfa..4f00ecf84b 100644 --- a/modules/angular2/src/forms/directives/ng_form_model.ts +++ b/modules/angular2/src/forms/directives/ng_form_model.ts @@ -2,7 +2,7 @@ import {CONST_EXPR} from 'angular2/src/facade/lang'; import {List, ListWrapper} from 'angular2/src/facade/collection'; import {ObservableWrapper, EventEmitter} from 'angular2/src/facade/async'; -import {Directive, LifecycleEvent} from 'angular2/angular2'; +import {Directive, LifecycleEvent} from 'angular2/annotations'; import {forwardRef, Binding} from 'angular2/di'; import {NgControl} from './ng_control'; import {NgControlGroup} from './ng_control_group'; diff --git a/modules/angular2/src/forms/directives/ng_model.ts b/modules/angular2/src/forms/directives/ng_model.ts index f856949d70..7e444c0501 100644 --- a/modules/angular2/src/forms/directives/ng_model.ts +++ b/modules/angular2/src/forms/directives/ng_model.ts @@ -1,7 +1,8 @@ import {CONST_EXPR} from 'angular2/src/facade/lang'; import {EventEmitter, ObservableWrapper} from 'angular2/src/facade/async'; -import {Directive, LifecycleEvent, QueryList, Query} from 'angular2/angular2'; +import {QueryList} from 'angular2/core'; +import {Query, Directive, LifecycleEvent} from 'angular2/annotations'; import {forwardRef, Ancestor, Binding} from 'angular2/di'; import {NgControl} from './ng_control'; diff --git a/modules/angular2/src/forms/directives/select_control_value_accessor.ts b/modules/angular2/src/forms/directives/select_control_value_accessor.ts index 72b28bd0b8..c05c54d11e 100644 --- a/modules/angular2/src/forms/directives/select_control_value_accessor.ts +++ b/modules/angular2/src/forms/directives/select_control_value_accessor.ts @@ -1,5 +1,6 @@ import {Renderer} from 'angular2/render'; -import {ElementRef, QueryList, Directive, Query} from 'angular2/angular2'; +import {ElementRef, QueryList} from 'angular2/core'; +import {Query, Directive} from 'angular2/annotations'; import {NgControl} from './ng_control'; import {ControlValueAccessor} from './control_value_accessor'; diff --git a/modules/angular2/src/test_lib/test_injector.ts b/modules/angular2/src/test_lib/test_injector.ts index b364229566..2b41534f14 100644 --- a/modules/angular2/src/test_lib/test_injector.ts +++ b/modules/angular2/src/test_lib/test_injector.ts @@ -84,7 +84,7 @@ function _getAppBindings() { // The document is only available in browser environment try { - appDoc = DOM.defaultDoc(); + appDoc = DOM.createHtmlDocument(); } catch (e) { appDoc = null; } diff --git a/modules/angular2/src/transform/common/annotation_matcher.dart b/modules/angular2/src/transform/common/annotation_matcher.dart index 5c5f16c11e..84c047e180 100644 --- a/modules/angular2/src/transform/common/annotation_matcher.dart +++ b/modules/angular2/src/transform/common/annotation_matcher.dart @@ -14,6 +14,7 @@ const INJECTABLES = const [ 'Injectable', 'package:angular2/src/di/decorators.dart'), const ClassDescriptor('Injectable', 'package:angular2/di.dart'), const ClassDescriptor('Injectable', 'package:angular2/angular2.dart'), + const ClassDescriptor('Injectable', 'package:angular2/bootstrap_static.dart'), ]; const DIRECTIVES = const [ @@ -32,6 +33,8 @@ const DIRECTIVES = const [ superClass: 'Injectable'), const ClassDescriptor('Directive', 'package:angular2/core.dart', superClass: 'Injectable'), + const ClassDescriptor('Directive', 'package:angular2/bootstrap_static.dart', + superClass: 'Injectable'), ]; const COMPONENTS = const [ @@ -48,6 +51,8 @@ const COMPONENTS = const [ superClass: 'Directive'), const ClassDescriptor('Component', 'package:angular2/angular2.dart', superClass: 'Directive'), + const ClassDescriptor('Component', 'package:angular2/bootstrap_static.dart', + superClass: 'Directive'), const ClassDescriptor('Component', 'package:angular2/core.dart', superClass: 'Directive'), ]; @@ -55,6 +60,7 @@ const COMPONENTS = const [ const VIEWS = const [ const ClassDescriptor('View', 'package:angular2/view.dart'), const ClassDescriptor('View', 'package:angular2/angular2.dart'), + const ClassDescriptor('View', 'package:angular2/bootstrap_static.dart'), const ClassDescriptor('View', 'package:angular2/core.dart'), const ClassDescriptor( 'View', 'package:angular2/src/core/annotations/view.dart'), @@ -75,24 +81,29 @@ class AnnotationMatcher extends ClassMatcherBase { ..addAll(VIEWS)); } - bool _implementsWithWarning( - ClassDescriptor descriptor, List interfaces) => - implements(descriptor, interfaces, + bool _implementsWithWarning(Annotation annotation, AssetId assetId, + List interfaces) { + ClassDescriptor descriptor = firstMatch(annotation.name, assetId); + if (descriptor == null) { + throw 'Unable to locate descriptor for ${annotation.name} in ${assetId}'; + } + return implements(descriptor, interfaces, missingSuperClassWarning: 'Missing `custom_annotation` entry for `${descriptor.superClass}`.'); + } /// Checks if an [Annotation] node implements [Injectable]. bool isInjectable(Annotation annotation, AssetId assetId) => - _implementsWithWarning(firstMatch(annotation.name, assetId), INJECTABLES); + _implementsWithWarning(annotation, assetId, INJECTABLES); /// Checks if an [Annotation] node implements [Directive]. bool isDirective(Annotation annotation, AssetId assetId) => - _implementsWithWarning(firstMatch(annotation.name, assetId), DIRECTIVES); + _implementsWithWarning(annotation, assetId, DIRECTIVES); /// Checks if an [Annotation] node implements [Component]. bool isComponent(Annotation annotation, AssetId assetId) => - _implementsWithWarning(firstMatch(annotation.name, assetId), COMPONENTS); + _implementsWithWarning(annotation, assetId, COMPONENTS); /// Checks if an [Annotation] node implements [View]. bool isView(Annotation annotation, AssetId assetId) => - _implementsWithWarning(firstMatch(annotation.name, assetId), VIEWS); + _implementsWithWarning(annotation, assetId, VIEWS); } diff --git a/modules/angular2/src/transform/common/names.dart b/modules/angular2/src/transform/common/names.dart index ebd83ccfb2..2386031b18 100644 --- a/modules/angular2/src/transform/common/names.dart +++ b/modules/angular2/src/transform/common/names.dart @@ -1,5 +1,6 @@ library angular2.transform.common.names; +const BOOTSTRAP_NAME = 'bootstrap'; const SETUP_METHOD_NAME = 'initReflector'; const REFLECTOR_VAR_NAME = 'reflector'; const TRANSFORM_DYNAMIC_MODE = 'transform_dynamic'; diff --git a/modules/angular2/src/transform/reflection_remover/ast_tester.dart b/modules/angular2/src/transform/reflection_remover/ast_tester.dart index 7c274f1e8b..f264316444 100644 --- a/modules/angular2/src/transform/reflection_remover/ast_tester.dart +++ b/modules/angular2/src/transform/reflection_remover/ast_tester.dart @@ -15,6 +15,10 @@ class AstTester { bool isReflectionCapabilitiesImport(ImportDirective node) { return node.uri.stringValue.endsWith("reflection_capabilities.dart"); } + + bool isBootstrapImport(ImportDirective node) { + return node.uri.stringValue.endsWith("/bootstrap.dart"); + } } /// An object that checks for {@link ReflectionCapabilities} using a fully resolved @@ -32,4 +36,8 @@ class ResolvedTester implements AstTester { bool isReflectionCapabilitiesImport(ImportDirective node) { return node.uriElement == _forbiddenClass.library; } + + bool isBootstrapImport(ImportDirective node) { + throw 'Not implemented'; + } } diff --git a/modules/angular2/src/transform/reflection_remover/codegen.dart b/modules/angular2/src/transform/reflection_remover/codegen.dart index 3c1b700352..83edf5bfa9 100644 --- a/modules/angular2/src/transform/reflection_remover/codegen.dart +++ b/modules/angular2/src/transform/reflection_remover/codegen.dart @@ -1,6 +1,5 @@ library angular2.transform.reflection_remover.codegen; -import 'package:analyzer/src/generated/ast.dart'; import 'package:path/path.dart' as path; import 'package:angular2/src/transform/common/names.dart'; @@ -36,45 +35,10 @@ class Codegen { /// Generates code to call the method which sets up Angular2 reflection /// statically. - /// - /// If `reflectorAssignment` is provided, it is expected to be the node - /// representing the {@link ReflectionCapabilities} assignment, and we will - /// attempt to parse the access of `reflector` from it so that `reflector` is - /// properly prefixed if necessary. - String codegenSetupReflectionCall( - {AssignmentExpression reflectorAssignment}) { - var reflectorExpression = null; - if (reflectorAssignment != null) { - reflectorExpression = reflectorAssignment.accept(new _ReflectorVisitor()); - } - if (reflectorExpression == null) { - reflectorExpression = 'reflector'; - } - + String codegenSetupReflectionCall() { var count = 0; return importUris .map((_) => '${prefix}${count++}.${SETUP_METHOD_NAME}();') .join(''); } } - -/// A visitor whose job it is to find the access of `reflector`. -class _ReflectorVisitor extends Object with SimpleAstVisitor { - @override - Expression visitAssignmentExpression(AssignmentExpression node) { - if (node == null || node.leftHandSide == null) return null; - return node.leftHandSide.accept(this); - } - - @override - Expression visitPropertyAccess(PropertyAccess node) { - if (node == null || node.target == null) return null; - return node.target; - } - - @override - Expression visitPrefixedIdentifier(PrefixedIdentifier node) { - if (node == null || node.prefix == null) return null; - return node.prefix; - } -} diff --git a/modules/angular2/src/transform/reflection_remover/rewriter.dart b/modules/angular2/src/transform/reflection_remover/rewriter.dart index 800f1e3104..b46b9d631d 100644 --- a/modules/angular2/src/transform/reflection_remover/rewriter.dart +++ b/modules/angular2/src/transform/reflection_remover/rewriter.dart @@ -32,96 +32,11 @@ class Rewriter { String rewrite(CompilationUnit node) { if (node == null) throw new ArgumentError.notNull('node'); - var visitor = new _FindReflectionCapabilitiesVisitor(_tester); + var visitor = new _RewriterVisitor(this); + node.accept(visitor); - if (visitor.reflectionCapabilityImports.isEmpty) { - logger.error('Failed to find ${REFLECTION_CAPABILITIES_NAME} import.'); - return _code; - } - if (visitor.reflectionCapabilityAssignments.isEmpty) { - logger.error('Failed to find ${REFLECTION_CAPABILITIES_NAME} ' - 'instantiation.'); - return _code; - } - var compare = (AstNode a, AstNode b) => a.offset - b.offset; - visitor.reflectionCapabilityImports.sort(compare); - visitor.reflectionCapabilityAssignments.sort(compare); - - var importAdded = false; - var buf = new StringBuffer(); - var idx = visitor.reflectionCapabilityImports.fold(0, - (int lastIdx, ImportDirective node) { - buf.write(_code.substring(lastIdx, node.offset)); - if ('${node.prefix}' == _codegen.prefix) { - logger.warning( - 'Found import prefix "${_codegen.prefix}" in source file.' - ' Transform may not succeed.'); - } - if (_mirrorMode != MirrorMode.none) { - buf.write(_importDebugReflectionCapabilities(node)); - } else { - buf.write(_commentedNode(node)); - } - if (!importAdded && _writeStaticInit) { - buf.write(_codegen.codegenImport()); - importAdded = true; - } - return node.end; - }); - - var setupAdded = false; - idx = visitor.reflectionCapabilityAssignments.fold(idx, - (int lastIdx, AssignmentExpression assignNode) { - var node = assignNode; - while (node.parent is ExpressionStatement) { - node = node.parent; - } - buf.write(_code.substring(lastIdx, node.offset)); - switch (_mirrorMode) { - case MirrorMode.debug: - buf.write(node); - break; - case MirrorMode.verbose: - buf.write(_instantiateVerboseReflectionCapabilities(assignNode)); - break; - case MirrorMode.none: - default: - buf.write(_commentedNode(node)); - break; - } - if (!setupAdded && _writeStaticInit) { - buf.write(_codegen.codegenSetupReflectionCall( - reflectorAssignment: assignNode)); - setupAdded = true; - } - return node.end; - }); - if (idx < _code.length) buf.write(_code.substring(idx)); - return buf.toString(); - } - - String _instantiateVerboseReflectionCapabilities( - AssignmentExpression assignNode) { - if (assignNode.rightHandSide is! InstanceCreationExpression) { - return '$assignNode;'; - } - var rhs = (assignNode.rightHandSide as InstanceCreationExpression); - return '${assignNode.leftHandSide} ${assignNode.operator} ' - 'new ${rhs.constructorName}(verbose: true);'; - } - - String _importDebugReflectionCapabilities(ImportDirective node) { - var uri = '${node.uri}'; - uri = path - .join(path.dirname(uri), 'debug_${path.basename(uri)}') - .replaceAll('\\', '/'); - var asClause = node.prefix != null ? ' as ${node.prefix}' : ''; - return 'import $uri$asClause;'; - } - - String _commentedNode(AstNode node) { - return '/*${_code.substring(node.offset, node.end)}*/'; + return visitor.outputRewrittenCode(); } } @@ -130,18 +45,31 @@ class Rewriter { /// /// This breaks our dependency on dart:mirrors, which enables smaller code /// size and better performance. -class _FindReflectionCapabilitiesVisitor extends Object +class _RewriterVisitor extends Object with RecursiveAstVisitor { - final reflectionCapabilityImports = new List(); - final reflectionCapabilityAssignments = new List(); - final AstTester _tester; + final Rewriter _rewriter; + final buf = new StringBuffer(); + final reflectionCapabilityAssignments = []; - _FindReflectionCapabilitiesVisitor(this._tester); + int _currentIndex = 0; + bool _setupAdded = false; + bool _importAdded = false; + + _RewriterVisitor(this._rewriter); @override Object visitImportDirective(ImportDirective node) { - if (_tester.isReflectionCapabilitiesImport(node)) { - reflectionCapabilityImports.add(node); + buf.write(_rewriter._code.substring(_currentIndex, node.offset)); + _currentIndex = node.offset; + if (_rewriter._tester.isReflectionCapabilitiesImport(node)) { + _rewriteReflectionCapabilitiesImport(node); + } else if (_rewriter._tester.isBootstrapImport(node)) { + _rewriteBootstrapImportToStatic(node); + } + if (!_importAdded && _rewriter._writeStaticInit) { + // Add imports for ng_deps (once) + buf.write(_rewriter._codegen.codegenImport()); + _importAdded = true; } return null; } @@ -149,19 +77,130 @@ class _FindReflectionCapabilitiesVisitor extends Object @override Object visitAssignmentExpression(AssignmentExpression node) { if (node.rightHandSide is InstanceCreationExpression && - _tester.isNewReflectionCapabilities(node.rightHandSide)) { + _rewriter._tester.isNewReflectionCapabilities(node.rightHandSide)) { reflectionCapabilityAssignments.add(node); + _rewriteReflectionCapabilitiesAssignment(node); } return super.visitAssignmentExpression(node); } @override Object visitInstanceCreationExpression(InstanceCreationExpression node) { - if (_tester.isNewReflectionCapabilities(node) && + if (_rewriter._tester.isNewReflectionCapabilities(node) && !reflectionCapabilityAssignments.contains(node.parent)) { logger.error('Unexpected format in creation of ' '${REFLECTION_CAPABILITIES_NAME}'); } return super.visitInstanceCreationExpression(node); } + + @override + Object visitMethodInvocation(MethodInvocation node) { + if (node.methodName.toString() == BOOTSTRAP_NAME) { + _rewriteBootstrapCallToStatic(node); + } + return super.visitMethodInvocation(node); + } + + String outputRewrittenCode() { + if (_currentIndex < _rewriter._code.length) { + buf.write(_rewriter._code.substring(_currentIndex)); + } + return '$buf'; + } + + _rewriteBootstrapImportToStatic(ImportDirective node) { + if (_rewriter._writeStaticInit) { + // rewrite `bootstrap.dart` to `bootstrap_static.dart` + buf.write(_rewriter._code.substring(_currentIndex, node.offset)); + // TODO(yjbanov): handle import "..." show/hide ... + buf.write("import 'package:angular2/bootstrap_static.dart';"); + } else { + // leave it as is + buf.write(_rewriter._code.substring(_currentIndex, node.end)); + } + _currentIndex = node.end; + } + + _rewriteBootstrapCallToStatic(MethodInvocation node) { + if (_rewriter._writeStaticInit) { + buf.write(_rewriter._code.substring(_currentIndex, node.offset)); + _writeStaticReflectorInitOnce(); + // rewrite `bootstrap(...)` to `bootstrapStatic(...)` + buf.write('bootstrapStatic${node.argumentList}'); + } else { + // leave it as is + buf.write(_rewriter._code.substring(_currentIndex, node.end)); + } + _currentIndex = node.end; + } + + _writeStaticReflectorInitOnce() { + if (!_setupAdded) { + buf.write(_rewriter._codegen.codegenSetupReflectionCall()); + _setupAdded = true; + } + } + + _rewriteReflectionCapabilitiesImport(ImportDirective node) { + buf.write(_rewriter._code.substring(_currentIndex, node.offset)); + if ('${node.prefix}' == _rewriter._codegen.prefix) { + logger.warning( + 'Found import prefix "${_rewriter._codegen.prefix}" in source file.' + ' Transform may not succeed.'); + } + if (_rewriter._mirrorMode != MirrorMode.none) { + buf.write(_importDebugReflectionCapabilities(node)); + } else { + buf.write(_commentedNode(node)); + } + _currentIndex = node.end; + } + + _rewriteReflectionCapabilitiesAssignment(AssignmentExpression assignNode) { + var node = assignNode; + while (node.parent is ExpressionStatement) { + node = node.parent; + } + buf.write(_rewriter._code.substring(_currentIndex, node.offset)); + if (_rewriter._writeStaticInit) { + _writeStaticReflectorInitOnce(); + } + switch (_rewriter._mirrorMode) { + case MirrorMode.debug: + buf.write(node); + break; + case MirrorMode.verbose: + buf.write(_instantiateVerboseReflectionCapabilities(assignNode)); + break; + case MirrorMode.none: + default: + buf.write(_commentedNode(node)); + break; + } + _currentIndex = node.end; + } + + String _commentedNode(AstNode node) { + return '/*${_rewriter._code.substring(node.offset, node.end)}*/'; + } +} + +String _importDebugReflectionCapabilities(ImportDirective node) { + var uri = '${node.uri}'; + uri = path + .join(path.dirname(uri), 'debug_${path.basename(uri)}') + .replaceAll('\\', '/'); + var asClause = node.prefix != null ? ' as ${node.prefix}' : ''; + return 'import $uri$asClause;'; +} + +String _instantiateVerboseReflectionCapabilities( + AssignmentExpression assignNode) { + if (assignNode.rightHandSide is! InstanceCreationExpression) { + return '$assignNode;'; + } + var rhs = (assignNode.rightHandSide as InstanceCreationExpression); + return '${assignNode.leftHandSide} ${assignNode.operator} ' + 'new ${rhs.constructorName}(verbose: true);'; } diff --git a/modules/angular2/test/benchmark/transform/integration/hello_world.dart b/modules/angular2/test/benchmark/transform/integration/hello_world.dart index 4cc3122f8c..e7d51fe90e 100644 --- a/modules/angular2/test/benchmark/transform/integration/hello_world.dart +++ b/modules/angular2/test/benchmark/transform/integration/hello_world.dart @@ -40,13 +40,13 @@ main() { const indexCommonContents = ''' library examples.src.hello_world.index_common; -import "package:angular2/angular2.dart" - show bootstrap, Component, Decorator, Template, NgElement; +import "package:angular2/bootstrap.dart" + show bootstrap, Component, Directive, View, ElementRef; import "package:angular2/di.dart" show Injectable; @Component(selector: "hello-app", services: const [GreetingService]) -@Template( - inline: '
{{greeting}} world!
' +@View( + template: '
{{greeting}} world!
' '', directives: const [RedDec]) @@ -60,10 +60,10 @@ class HelloCmp { } } -@Decorator(selector: "[red]") +@Directive(selector: "[red]") class RedDec { - RedDec(NgElement el) { - el.domElement.style.color = "red"; + RedDec(ElementRef el) { + el.nativeElement.style.color = "red"; } } diff --git a/modules/angular2/test/benchmark/transform/reflection_remover/simple.dart b/modules/angular2/test/benchmark/transform/reflection_remover/simple.dart index 661bce5ad7..f34414f060 100644 --- a/modules/angular2/test/benchmark/transform/reflection_remover/simple.dart +++ b/modules/angular2/test/benchmark/transform/reflection_remover/simple.dart @@ -23,7 +23,7 @@ Future runBenchmark() async { const indexContents = ''' library web_foo; -import 'package:angular2/src/core/application.dart'; +import 'package:angular2/bootstrap.dart'; import 'package:angular2/src/reflection/reflection.dart'; import 'package:angular2/src/reflection/reflection_capabilities.dart'; diff --git a/modules/angular2/test/router/route_config_spec.ts b/modules/angular2/test/router/route_config_spec.ts index 091f9614a9..34dc7af0e4 100644 --- a/modules/angular2/test/router/route_config_spec.ts +++ b/modules/angular2/test/router/route_config_spec.ts @@ -11,7 +11,7 @@ import { xit, } from 'angular2/test_lib'; -import {bootstrap} from 'angular2/core'; +import {bootstrap} from 'angular2/bootstrap'; import {Component, Directive, View} from 'angular2/annotations'; import {DOM} from 'angular2/src/dom/dom_adapter'; import {bind} from 'angular2/di'; diff --git a/modules/angular2/test/transform/directive_linker/simple_export_files/expected/index.ng_deps.dart b/modules/angular2/test/transform/directive_linker/simple_export_files/expected/index.ng_deps.dart index 90ed3366a1..43bed972c8 100644 --- a/modules/angular2/test/transform/directive_linker/simple_export_files/expected/index.ng_deps.dart +++ b/modules/angular2/test/transform/directive_linker/simple_export_files/expected/index.ng_deps.dart @@ -1,7 +1,7 @@ library web_foo.ng_deps.dart; import 'package:angular2/src/reflection/reflection.dart' as _ngRef; -import 'package:angular2/src/core/application.dart'; +import 'package:angular2/bootstrap_static.dart'; import 'package:angular2/src/reflection/reflection_capabilities.dart'; import 'bar.dart'; import 'bar.ng_deps.dart' as i0; diff --git a/modules/angular2/test/transform/directive_linker/simple_export_files/index.ng_deps.dart b/modules/angular2/test/transform/directive_linker/simple_export_files/index.ng_deps.dart index 65fe6009b7..949838af34 100644 --- a/modules/angular2/test/transform/directive_linker/simple_export_files/index.ng_deps.dart +++ b/modules/angular2/test/transform/directive_linker/simple_export_files/index.ng_deps.dart @@ -1,7 +1,7 @@ library web_foo.ng_deps.dart; import 'package:angular2/src/reflection/reflection.dart' as _ngRef; -import 'package:angular2/src/core/application.dart'; +import 'package:angular2/bootstrap_static.dart'; import 'package:angular2/src/reflection/reflection_capabilities.dart'; import 'bar.dart'; diff --git a/modules/angular2/test/transform/directive_linker/simple_files/expected/index.ng_deps.dart b/modules/angular2/test/transform/directive_linker/simple_files/expected/index.ng_deps.dart index 90ed3366a1..43bed972c8 100644 --- a/modules/angular2/test/transform/directive_linker/simple_files/expected/index.ng_deps.dart +++ b/modules/angular2/test/transform/directive_linker/simple_files/expected/index.ng_deps.dart @@ -1,7 +1,7 @@ library web_foo.ng_deps.dart; import 'package:angular2/src/reflection/reflection.dart' as _ngRef; -import 'package:angular2/src/core/application.dart'; +import 'package:angular2/bootstrap_static.dart'; import 'package:angular2/src/reflection/reflection_capabilities.dart'; import 'bar.dart'; import 'bar.ng_deps.dart' as i0; diff --git a/modules/angular2/test/transform/directive_linker/simple_files/index.ng_deps.dart b/modules/angular2/test/transform/directive_linker/simple_files/index.ng_deps.dart index 65fe6009b7..949838af34 100644 --- a/modules/angular2/test/transform/directive_linker/simple_files/index.ng_deps.dart +++ b/modules/angular2/test/transform/directive_linker/simple_files/index.ng_deps.dart @@ -1,7 +1,7 @@ library web_foo.ng_deps.dart; import 'package:angular2/src/reflection/reflection.dart' as _ngRef; -import 'package:angular2/src/core/application.dart'; +import 'package:angular2/bootstrap_static.dart'; import 'package:angular2/src/reflection/reflection_capabilities.dart'; import 'bar.dart'; diff --git a/modules/angular2/test/transform/directive_metadata_extractor/directive_metadata_files/changeDetection.ng_deps.dart b/modules/angular2/test/transform/directive_metadata_extractor/directive_metadata_files/changeDetection.ng_deps.dart index f6fa1925a1..b7115d7140 100644 --- a/modules/angular2/test/transform/directive_metadata_extractor/directive_metadata_files/changeDetection.ng_deps.dart +++ b/modules/angular2/test/transform/directive_metadata_extractor/directive_metadata_files/changeDetection.ng_deps.dart @@ -3,7 +3,6 @@ library examples.hello_world.index_common_dart.ng_deps.dart; import 'hello.dart'; import 'package:angular2/angular2.dart' show - bootstrap, Component, Directive, View, diff --git a/modules/angular2/test/transform/directive_metadata_extractor/directive_metadata_files/directive_export_as.ng_deps.dart b/modules/angular2/test/transform/directive_metadata_extractor/directive_metadata_files/directive_export_as.ng_deps.dart index bedeff7381..a33978fd4e 100644 --- a/modules/angular2/test/transform/directive_metadata_extractor/directive_metadata_files/directive_export_as.ng_deps.dart +++ b/modules/angular2/test/transform/directive_metadata_extractor/directive_metadata_files/directive_export_as.ng_deps.dart @@ -3,7 +3,6 @@ library examples.hello_world.index_common_dart.ng_deps.dart; import 'hello.dart'; import 'package:angular2/angular2.dart' show - bootstrap, Component, Directive, View, diff --git a/modules/angular2/test/transform/directive_metadata_extractor/directive_metadata_files/events.ng_deps.dart b/modules/angular2/test/transform/directive_metadata_extractor/directive_metadata_files/events.ng_deps.dart index 689f71830c..6219dd82f0 100644 --- a/modules/angular2/test/transform/directive_metadata_extractor/directive_metadata_files/events.ng_deps.dart +++ b/modules/angular2/test/transform/directive_metadata_extractor/directive_metadata_files/events.ng_deps.dart @@ -3,7 +3,6 @@ library examples.hello_world.index_common_dart.ng_deps.dart; import 'hello.dart'; import 'package:angular2/angular2.dart' show - bootstrap, Component, Directive, View, diff --git a/modules/angular2/test/transform/directive_metadata_extractor/directive_metadata_files/host_listeners.ng_deps.dart b/modules/angular2/test/transform/directive_metadata_extractor/directive_metadata_files/host_listeners.ng_deps.dart index 6f86384db0..bd1aba9ed1 100644 --- a/modules/angular2/test/transform/directive_metadata_extractor/directive_metadata_files/host_listeners.ng_deps.dart +++ b/modules/angular2/test/transform/directive_metadata_extractor/directive_metadata_files/host_listeners.ng_deps.dart @@ -2,7 +2,7 @@ library examples.hello_world.index_common_dart.ng_deps.dart; import 'hello.dart'; import 'package:angular2/angular2.dart' - show bootstrap, Component, Directive, View, NgElement; + show Component, Directive, View, NgElement; var _visited = false; void initReflector(reflector) { diff --git a/modules/angular2/test/transform/directive_metadata_extractor/directive_metadata_files/lifecycle.ng_deps.dart b/modules/angular2/test/transform/directive_metadata_extractor/directive_metadata_files/lifecycle.ng_deps.dart index 287cee4f9f..908c1a4d98 100644 --- a/modules/angular2/test/transform/directive_metadata_extractor/directive_metadata_files/lifecycle.ng_deps.dart +++ b/modules/angular2/test/transform/directive_metadata_extractor/directive_metadata_files/lifecycle.ng_deps.dart @@ -3,7 +3,6 @@ library examples.hello_world.index_common_dart.ng_deps.dart; import 'hello.dart'; import 'package:angular2/angular2.dart' show - bootstrap, Component, Directive, View, diff --git a/modules/angular2/test/transform/directive_metadata_extractor/directive_metadata_files/properties.ng_deps.dart b/modules/angular2/test/transform/directive_metadata_extractor/directive_metadata_files/properties.ng_deps.dart index 1d552bd94d..5a0ba314cf 100644 --- a/modules/angular2/test/transform/directive_metadata_extractor/directive_metadata_files/properties.ng_deps.dart +++ b/modules/angular2/test/transform/directive_metadata_extractor/directive_metadata_files/properties.ng_deps.dart @@ -2,7 +2,7 @@ library examples.hello_world.index_common_dart.ng_deps.dart; import 'hello.dart'; import 'package:angular2/angular2.dart' - show bootstrap, Component, Directive, View, NgElement; + show Component, Directive, View, NgElement; var _visited = false; void initReflector(reflector) { diff --git a/modules/angular2/test/transform/directive_metadata_extractor/directive_metadata_files/selector.ng_deps.dart b/modules/angular2/test/transform/directive_metadata_extractor/directive_metadata_files/selector.ng_deps.dart index a47d5e3971..5717c1333f 100644 --- a/modules/angular2/test/transform/directive_metadata_extractor/directive_metadata_files/selector.ng_deps.dart +++ b/modules/angular2/test/transform/directive_metadata_extractor/directive_metadata_files/selector.ng_deps.dart @@ -2,7 +2,7 @@ library examples.hello_world.index_common_dart.ng_deps.dart; import 'hello.dart'; import 'package:angular2/angular2.dart' - show bootstrap, Component, Directive, View, NgElement; + show Component, Directive, View, NgElement; var _visited = false; void initReflector(reflector) { diff --git a/modules/angular2/test/transform/directive_metadata_extractor/directive_metadata_files/too_many_directives.ng_deps.dart b/modules/angular2/test/transform/directive_metadata_extractor/directive_metadata_files/too_many_directives.ng_deps.dart index 48df7a8985..af276618c2 100644 --- a/modules/angular2/test/transform/directive_metadata_extractor/directive_metadata_files/too_many_directives.ng_deps.dart +++ b/modules/angular2/test/transform/directive_metadata_extractor/directive_metadata_files/too_many_directives.ng_deps.dart @@ -2,7 +2,7 @@ library examples.hello_world.index_common_dart.ng_deps.dart; import 'hello.dart'; import 'package:angular2/angular2.dart' - show bootstrap, Component, Directive, View, NgElement; + show Component, Directive, View, NgElement; var _visited = false; void initReflector(reflector) { diff --git a/modules/angular2/test/transform/directive_processor/absolute_url_expression_files/expected/hello.ng_deps.dart b/modules/angular2/test/transform/directive_processor/absolute_url_expression_files/expected/hello.ng_deps.dart index 0dd6b31ae4..f5157bcfbc 100644 --- a/modules/angular2/test/transform/directive_processor/absolute_url_expression_files/expected/hello.ng_deps.dart +++ b/modules/angular2/test/transform/directive_processor/absolute_url_expression_files/expected/hello.ng_deps.dart @@ -4,7 +4,7 @@ import 'hello.dart'; export 'hello.dart'; import 'package:angular2/src/reflection/reflection.dart' as _ngRef; import 'package:angular2/angular2.dart' - show bootstrap, Component, Directive, View, NgElement; + show Component, Directive, View, NgElement; var _visited = false; void initReflector() { diff --git a/modules/angular2/test/transform/directive_processor/absolute_url_expression_files/hello.dart b/modules/angular2/test/transform/directive_processor/absolute_url_expression_files/hello.dart index ed490b8b87..466222be57 100644 --- a/modules/angular2/test/transform/directive_processor/absolute_url_expression_files/hello.dart +++ b/modules/angular2/test/transform/directive_processor/absolute_url_expression_files/hello.dart @@ -1,7 +1,7 @@ library examples.src.hello_world.absolute_url_expression_files; import 'package:angular2/angular2.dart' - show bootstrap, Component, Directive, View, NgElement; + show Component, Directive, View, NgElement; @Component(selector: 'hello-app') @View( diff --git a/modules/angular2/test/transform/directive_processor/all_tests.dart b/modules/angular2/test/transform/directive_processor/all_tests.dart index 8e33d24b7b..78f01ce236 100644 --- a/modules/angular2/test/transform/directive_processor/all_tests.dart +++ b/modules/angular2/test/transform/directive_processor/all_tests.dart @@ -116,8 +116,10 @@ void allTests() { void _testNgDeps(String name, String inputPath, {List customDescriptors: const [], AssetId assetId, - AssetReader reader, List expectedLogs, bool inlineViews: true}) { - it(name, () async { + AssetReader reader, List expectedLogs, bool inlineViews: true, + bool isolate: false}) { + var testFn = isolate ? iit : it; + testFn(name, () async { if (expectedLogs != null) { log.setLogger(new RecordingLogger()); } diff --git a/modules/angular2/test/transform/directive_processor/expected/hello.ng_deps.dart b/modules/angular2/test/transform/directive_processor/expected/hello.ng_deps.dart index e73727dfa5..4a5fd9ebe9 100644 --- a/modules/angular2/test/transform/directive_processor/expected/hello.ng_deps.dart +++ b/modules/angular2/test/transform/directive_processor/expected/hello.ng_deps.dart @@ -4,7 +4,7 @@ import 'hello.dart'; export 'hello.dart'; import 'package:angular2/src/reflection/reflection.dart' as _ngRef; import 'package:angular2/angular2.dart' - show bootstrap, Component, Directive, View, NgElement; + show Component, Directive, View, NgElement; var _visited = false; void initReflector() { diff --git a/modules/angular2/test/transform/directive_processor/invalid_url_files/expected/hello.ng_deps.dart b/modules/angular2/test/transform/directive_processor/invalid_url_files/expected/hello.ng_deps.dart index b0d4f7c7ec..94d4bd04ca 100644 --- a/modules/angular2/test/transform/directive_processor/invalid_url_files/expected/hello.ng_deps.dart +++ b/modules/angular2/test/transform/directive_processor/invalid_url_files/expected/hello.ng_deps.dart @@ -4,7 +4,7 @@ import 'hello.dart'; export 'hello.dart'; import 'package:angular2/src/reflection/reflection.dart' as _ngRef; import 'package:angular2/angular2.dart' - show bootstrap, Component, Directive, View, NgElement; + show Component, Directive, View, NgElement; var _visited = false; void initReflector() { diff --git a/modules/angular2/test/transform/directive_processor/invalid_url_files/hello.dart b/modules/angular2/test/transform/directive_processor/invalid_url_files/hello.dart index 2932497410..bfa8563643 100644 --- a/modules/angular2/test/transform/directive_processor/invalid_url_files/hello.dart +++ b/modules/angular2/test/transform/directive_processor/invalid_url_files/hello.dart @@ -1,7 +1,7 @@ library test.transform.directive_processor.invalid_url_files.hello; import 'package:angular2/angular2.dart' - show bootstrap, Component, Directive, View, NgElement; + show Component, Directive, View, NgElement; @Component(selector: 'hello-app') @View( diff --git a/modules/angular2/test/transform/directive_processor/multiple_style_urls_files/expected/hello.ng_deps.dart b/modules/angular2/test/transform/directive_processor/multiple_style_urls_files/expected/hello.ng_deps.dart index ec7b151bb8..54b6102f9b 100644 --- a/modules/angular2/test/transform/directive_processor/multiple_style_urls_files/expected/hello.ng_deps.dart +++ b/modules/angular2/test/transform/directive_processor/multiple_style_urls_files/expected/hello.ng_deps.dart @@ -4,7 +4,7 @@ import 'hello.dart'; export 'hello.dart'; import 'package:angular2/src/reflection/reflection.dart' as _ngRef; import 'package:angular2/angular2.dart' - show bootstrap, Component, Directive, View, NgElement; + show Component, Directive, View, NgElement; var _visited = false; void initReflector() { diff --git a/modules/angular2/test/transform/directive_processor/multiple_style_urls_files/hello.dart b/modules/angular2/test/transform/directive_processor/multiple_style_urls_files/hello.dart index 11ae606866..69613f04ef 100644 --- a/modules/angular2/test/transform/directive_processor/multiple_style_urls_files/hello.dart +++ b/modules/angular2/test/transform/directive_processor/multiple_style_urls_files/hello.dart @@ -1,7 +1,7 @@ library examples.src.hello_world.multiple_style_urls_files; import 'package:angular2/angular2.dart' - show bootstrap, Component, Directive, View, NgElement; + show Component, Directive, View, NgElement; @Component(selector: 'hello-app') @View( diff --git a/modules/angular2/test/transform/directive_processor/multiple_style_urls_not_inlined_files/expected/hello.ng_deps.dart b/modules/angular2/test/transform/directive_processor/multiple_style_urls_not_inlined_files/expected/hello.ng_deps.dart index 6425491be9..5b0c4ea86c 100644 --- a/modules/angular2/test/transform/directive_processor/multiple_style_urls_not_inlined_files/expected/hello.ng_deps.dart +++ b/modules/angular2/test/transform/directive_processor/multiple_style_urls_not_inlined_files/expected/hello.ng_deps.dart @@ -4,7 +4,7 @@ import 'hello.dart'; export 'hello.dart'; import 'package:angular2/src/reflection/reflection.dart' as _ngRef; import 'package:angular2/angular2.dart' - show bootstrap, Component, Directive, View, NgElement; + show Component, Directive, View, NgElement; var _visited = false; void initReflector() { diff --git a/modules/angular2/test/transform/directive_processor/multiple_style_urls_not_inlined_files/hello.dart b/modules/angular2/test/transform/directive_processor/multiple_style_urls_not_inlined_files/hello.dart index 97cc1d9847..24dec9f18e 100644 --- a/modules/angular2/test/transform/directive_processor/multiple_style_urls_not_inlined_files/hello.dart +++ b/modules/angular2/test/transform/directive_processor/multiple_style_urls_not_inlined_files/hello.dart @@ -1,7 +1,7 @@ library examples.src.hello_world.multiple_style_urls_not_inlined_files; import 'package:angular2/angular2.dart' - show bootstrap, Component, Directive, View, NgElement; + show Component, Directive, View, NgElement; @Component(selector: 'hello-app') @View( diff --git a/modules/angular2/test/transform/directive_processor/split_url_expression_files/expected/hello.ng_deps.dart b/modules/angular2/test/transform/directive_processor/split_url_expression_files/expected/hello.ng_deps.dart index b53047cc3b..b89a7b60db 100644 --- a/modules/angular2/test/transform/directive_processor/split_url_expression_files/expected/hello.ng_deps.dart +++ b/modules/angular2/test/transform/directive_processor/split_url_expression_files/expected/hello.ng_deps.dart @@ -4,7 +4,7 @@ import 'hello.dart'; export 'hello.dart'; import 'package:angular2/src/reflection/reflection.dart' as _ngRef; import 'package:angular2/angular2.dart' - show bootstrap, Component, Directive, View, NgElement; + show Component, Directive, View, NgElement; var _visited = false; void initReflector() { diff --git a/modules/angular2/test/transform/directive_processor/split_url_expression_files/hello.dart b/modules/angular2/test/transform/directive_processor/split_url_expression_files/hello.dart index 89b7f60809..f5befb4e24 100644 --- a/modules/angular2/test/transform/directive_processor/split_url_expression_files/hello.dart +++ b/modules/angular2/test/transform/directive_processor/split_url_expression_files/hello.dart @@ -1,7 +1,7 @@ library examples.src.hello_world.split_url_expression_files; import 'package:angular2/angular2.dart' - show bootstrap, Component, Directive, View, NgElement; + show Component, Directive, View, NgElement; @Component(selector: 'hello-app') @View(templateUrl: 'templ' 'ate.html') diff --git a/modules/angular2/test/transform/directive_processor/url_expression_files/expected/hello.ng_deps.dart b/modules/angular2/test/transform/directive_processor/url_expression_files/expected/hello.ng_deps.dart index 2b1234d04c..3bd5020f7a 100644 --- a/modules/angular2/test/transform/directive_processor/url_expression_files/expected/hello.ng_deps.dart +++ b/modules/angular2/test/transform/directive_processor/url_expression_files/expected/hello.ng_deps.dart @@ -4,7 +4,7 @@ import 'hello.dart'; export 'hello.dart'; import 'package:angular2/src/reflection/reflection.dart' as _ngRef; import 'package:angular2/angular2.dart' - show bootstrap, Component, Directive, View, NgElement; + show Component, Directive, View, NgElement; var _visited = false; void initReflector() { diff --git a/modules/angular2/test/transform/directive_processor/url_expression_files/hello.dart b/modules/angular2/test/transform/directive_processor/url_expression_files/hello.dart index 2c35e6d460..cd259765d1 100644 --- a/modules/angular2/test/transform/directive_processor/url_expression_files/hello.dart +++ b/modules/angular2/test/transform/directive_processor/url_expression_files/hello.dart @@ -1,7 +1,7 @@ library examples.src.hello_world.url_expression_files; import 'package:angular2/angular2.dart' - show bootstrap, Component, Directive, View, NgElement; + show Component, Directive, View, NgElement; @Component(selector: 'hello-app') @View(templateUrl: 'template.html') diff --git a/modules/angular2/test/transform/integration/list_of_types_files/index.dart b/modules/angular2/test/transform/integration/list_of_types_files/index.dart index 505e371e0e..e95dce6c25 100644 --- a/modules/angular2/test/transform/integration/list_of_types_files/index.dart +++ b/modules/angular2/test/transform/integration/list_of_types_files/index.dart @@ -1,6 +1,6 @@ library web_foo; -import 'package:angular2/src/core/application.dart'; +import 'package:angular2/bootstrap.dart'; import 'package:angular2/src/reflection/reflection_capabilities.dart'; import 'bar.dart'; diff --git a/modules/angular2/test/transform/integration/simple_annotation_files/expected/index.ng_deps.dart b/modules/angular2/test/transform/integration/simple_annotation_files/expected/index.ng_deps.dart index 4788b6c8f5..54b422fdf8 100644 --- a/modules/angular2/test/transform/integration/simple_annotation_files/expected/index.ng_deps.dart +++ b/modules/angular2/test/transform/integration/simple_annotation_files/expected/index.ng_deps.dart @@ -3,9 +3,9 @@ library web_foo.ng_deps.dart; import 'index.dart'; export 'index.dart'; import 'package:angular2/src/reflection/reflection.dart' as _ngRef; -import 'package:angular2/src/core/application.dart'; -import 'package:angular2/src/reflection/reflection.dart'; +import 'package:angular2/bootstrap_static.dart'; import 'index.ng_deps.dart' as ngStaticInit0; +import 'package:angular2/src/reflection/reflection.dart'; import 'bar.dart'; import 'bar.ng_deps.dart' as i0; diff --git a/modules/angular2/test/transform/integration/simple_annotation_files/index.dart b/modules/angular2/test/transform/integration/simple_annotation_files/index.dart index 9a72bcf857..86dd24b7f3 100644 --- a/modules/angular2/test/transform/integration/simple_annotation_files/index.dart +++ b/modules/angular2/test/transform/integration/simple_annotation_files/index.dart @@ -1,6 +1,6 @@ library web_foo; -import 'package:angular2/src/core/application.dart'; +import 'package:angular2/bootstrap.dart'; import 'package:angular2/src/reflection/reflection.dart'; import 'package:angular2/src/reflection/reflection_capabilities.dart'; import 'bar.dart'; diff --git a/modules/angular2/test/transform/integration/synthetic_ctor_files/index.dart b/modules/angular2/test/transform/integration/synthetic_ctor_files/index.dart index 505e371e0e..e95dce6c25 100644 --- a/modules/angular2/test/transform/integration/synthetic_ctor_files/index.dart +++ b/modules/angular2/test/transform/integration/synthetic_ctor_files/index.dart @@ -1,6 +1,6 @@ library web_foo; -import 'package:angular2/src/core/application.dart'; +import 'package:angular2/bootstrap.dart'; import 'package:angular2/src/reflection/reflection_capabilities.dart'; import 'bar.dart'; diff --git a/modules/angular2/test/transform/integration/two_annotations_files/index.dart b/modules/angular2/test/transform/integration/two_annotations_files/index.dart index 505e371e0e..e95dce6c25 100644 --- a/modules/angular2/test/transform/integration/two_annotations_files/index.dart +++ b/modules/angular2/test/transform/integration/two_annotations_files/index.dart @@ -1,6 +1,6 @@ library web_foo; -import 'package:angular2/src/core/application.dart'; +import 'package:angular2/bootstrap.dart'; import 'package:angular2/src/reflection/reflection_capabilities.dart'; import 'bar.dart'; diff --git a/modules/angular2/test/transform/integration/two_deps_files/index.dart b/modules/angular2/test/transform/integration/two_deps_files/index.dart index 505e371e0e..e95dce6c25 100644 --- a/modules/angular2/test/transform/integration/two_deps_files/index.dart +++ b/modules/angular2/test/transform/integration/two_deps_files/index.dart @@ -1,6 +1,6 @@ library web_foo; -import 'package:angular2/src/core/application.dart'; +import 'package:angular2/bootstrap.dart'; import 'package:angular2/src/reflection/reflection_capabilities.dart'; import 'bar.dart'; diff --git a/modules/angular2/test/transform/reflection_remover/debug_files/README.md b/modules/angular2/test/transform/reflection_remover/debug_files/README.md index db2313dfb0..b277f0c237 100644 --- a/modules/angular2/test/transform/reflection_remover/debug_files/README.md +++ b/modules/angular2/test/transform/reflection_remover/debug_files/README.md @@ -1,7 +1,5 @@ Tests that the reflection removal step: - 1. Comments out the import of reflection_capabilities.dart - 2. Comments out the instantiation of `ReflectionCapabilities` - 3. Adds the appropriate import. - 4. Adds the call to `initReflector` - 5. Does not change line numbers in the source. - 6. Makes minimal changes to source offsets. \ No newline at end of file + * Adds the appropriate ng_deps import. + * Adds the call to `initReflector` + * Does not change line numbers in the source. + * Makes minimal changes to source offsets. diff --git a/modules/angular2/test/transform/reflection_remover/debug_files/expected/index.dart b/modules/angular2/test/transform/reflection_remover/debug_files/expected/index.dart index 4d1bc48d6a..b489cd1cfd 100644 --- a/modules/angular2/test/transform/reflection_remover/debug_files/expected/index.dart +++ b/modules/angular2/test/transform/reflection_remover/debug_files/expected/index.dart @@ -11,12 +11,12 @@ library angular2.test.transform.debug_reflection_remover_files; var code = """ library web_foo; -import 'package:angular2/src/core/application.dart'; +import 'package:angular2/bootstrap.dart';import 'index.ng_deps.dart' as ngStaticInit0; import 'package:angular2/src/reflection/reflection.dart'; -import 'package:angular2/src/reflection/debug_reflection_capabilities.dart';import 'index.ng_deps.dart' as ngStaticInit0; +import 'package:angular2/src/reflection/debug_reflection_capabilities.dart'; void main() { - reflector.reflectionCapabilities = new ReflectionCapabilities();ngStaticInit0.initReflector(); - bootstrap(MyComponent); + reflector.reflectionCapabilities = new ReflectionCapabilities(); + ngStaticInit0.initReflector();bootstrap(MyComponent); } """; diff --git a/modules/angular2/test/transform/reflection_remover/debug_files/index.dart b/modules/angular2/test/transform/reflection_remover/debug_files/index.dart index 45363b8a19..b44a42089c 100644 --- a/modules/angular2/test/transform/reflection_remover/debug_files/index.dart +++ b/modules/angular2/test/transform/reflection_remover/debug_files/index.dart @@ -1,6 +1,6 @@ library web_foo; -import 'package:angular2/src/core/application.dart'; +import 'package:angular2/bootstrap.dart'; import 'package:angular2/src/reflection/reflection.dart'; import 'package:angular2/src/reflection/reflection_capabilities.dart'; diff --git a/modules/angular2/test/transform/reflection_remover/debug_mirrors_files/expected/index.dart b/modules/angular2/test/transform/reflection_remover/debug_mirrors_files/expected/index.dart index 50b4897b7a..ab2f6f72e7 100644 --- a/modules/angular2/test/transform/reflection_remover/debug_mirrors_files/expected/index.dart +++ b/modules/angular2/test/transform/reflection_remover/debug_mirrors_files/expected/index.dart @@ -11,12 +11,12 @@ library angular2.test.transform.reflection_remover.debug_mirrors_files.expected; var code = """ library web_foo; -import 'package:angular2/src/core/application.dart'; +import 'package:angular2/bootstrap_static.dart';import 'index.ng_deps.dart' as ngStaticInit0; import 'package:angular2/src/reflection/reflection.dart'; -import 'package:angular2/src/reflection/debug_reflection_capabilities.dart';import 'index.ng_deps.dart' as ngStaticInit0; +import 'package:angular2/src/reflection/debug_reflection_capabilities.dart'; void main() { - reflector.reflectionCapabilities = new ReflectionCapabilities();ngStaticInit0.initReflector(); - bootstrap(MyComponent); + ngStaticInit0.initReflector();reflector.reflectionCapabilities = new ReflectionCapabilities(); + bootstrapStatic(MyComponent); } """; diff --git a/modules/angular2/test/transform/reflection_remover/debug_mirrors_files/index.dart b/modules/angular2/test/transform/reflection_remover/debug_mirrors_files/index.dart index 45363b8a19..b44a42089c 100644 --- a/modules/angular2/test/transform/reflection_remover/debug_mirrors_files/index.dart +++ b/modules/angular2/test/transform/reflection_remover/debug_mirrors_files/index.dart @@ -1,6 +1,6 @@ library web_foo; -import 'package:angular2/src/core/application.dart'; +import 'package:angular2/bootstrap.dart'; import 'package:angular2/src/reflection/reflection.dart'; import 'package:angular2/src/reflection/reflection_capabilities.dart'; diff --git a/modules/angular2/test/transform/reflection_remover/index.dart b/modules/angular2/test/transform/reflection_remover/index.dart index 45363b8a19..b44a42089c 100644 --- a/modules/angular2/test/transform/reflection_remover/index.dart +++ b/modules/angular2/test/transform/reflection_remover/index.dart @@ -1,6 +1,6 @@ library web_foo; -import 'package:angular2/src/core/application.dart'; +import 'package:angular2/bootstrap.dart'; import 'package:angular2/src/reflection/reflection.dart'; import 'package:angular2/src/reflection/reflection_capabilities.dart'; diff --git a/modules/angular2/test/transform/reflection_remover/log_mirrors_files/expected/index.dart b/modules/angular2/test/transform/reflection_remover/log_mirrors_files/expected/index.dart index fc19f1c9f6..b463d28e1b 100644 --- a/modules/angular2/test/transform/reflection_remover/log_mirrors_files/expected/index.dart +++ b/modules/angular2/test/transform/reflection_remover/log_mirrors_files/expected/index.dart @@ -11,7 +11,7 @@ library angular2.test.transform.log_mirrors_files.expected; var code = """ library web_foo; -import 'package:angular2/src/core/application.dart'; +import 'package:angular2/bootstrap.dart'; import 'package:angular2/src/reflection/reflection.dart'; /*import 'package:angular2/src/reflection/reflection_capabilities.dart';*/ diff --git a/modules/angular2/test/transform/reflection_remover/log_mirrors_files/index.dart b/modules/angular2/test/transform/reflection_remover/log_mirrors_files/index.dart index 45363b8a19..b44a42089c 100644 --- a/modules/angular2/test/transform/reflection_remover/log_mirrors_files/index.dart +++ b/modules/angular2/test/transform/reflection_remover/log_mirrors_files/index.dart @@ -1,6 +1,6 @@ library web_foo; -import 'package:angular2/src/core/application.dart'; +import 'package:angular2/bootstrap.dart'; import 'package:angular2/src/reflection/reflection.dart'; import 'package:angular2/src/reflection/reflection_capabilities.dart'; diff --git a/modules/angular2/test/transform/reflection_remover/reflection_remover_files/expected/index.dart b/modules/angular2/test/transform/reflection_remover/reflection_remover_files/expected/index.dart index a42c075df1..dec140d9d0 100644 --- a/modules/angular2/test/transform/reflection_remover/reflection_remover_files/expected/index.dart +++ b/modules/angular2/test/transform/reflection_remover/reflection_remover_files/expected/index.dart @@ -11,12 +11,12 @@ library angular2.test.transform.reflection_remover.reflection_remover_files; var code = """ library web_foo; -import 'package:angular2/src/core/application.dart'; +import 'package:angular2/bootstrap_static.dart';import 'index.ng_deps.dart' as ngStaticInit0; import 'package:angular2/src/reflection/reflection.dart'; -/*import 'package:angular2/src/reflection/reflection_capabilities.dart';*/import 'index.ng_deps.dart' as ngStaticInit0; +/*import 'package:angular2/src/reflection/reflection_capabilities.dart';*/ void main() { - /*reflector.reflectionCapabilities = new ReflectionCapabilities();*/ngStaticInit0.initReflector(); - bootstrap(MyComponent); + ngStaticInit0.initReflector();/*reflector.reflectionCapabilities = new ReflectionCapabilities();*/ + bootstrapStatic(MyComponent); } """; diff --git a/modules/angular2/test/transform/reflection_remover/reflection_remover_files/index.dart b/modules/angular2/test/transform/reflection_remover/reflection_remover_files/index.dart index 45363b8a19..b44a42089c 100644 --- a/modules/angular2/test/transform/reflection_remover/reflection_remover_files/index.dart +++ b/modules/angular2/test/transform/reflection_remover/reflection_remover_files/index.dart @@ -1,6 +1,6 @@ library web_foo; -import 'package:angular2/src/core/application.dart'; +import 'package:angular2/bootstrap.dart'; import 'package:angular2/src/reflection/reflection.dart'; import 'package:angular2/src/reflection/reflection_capabilities.dart'; diff --git a/modules/angular2/test/transform/reflection_remover/verbose_files/expected/index.dart b/modules/angular2/test/transform/reflection_remover/verbose_files/expected/index.dart index 5e9b74325b..e08af4f0a3 100644 --- a/modules/angular2/test/transform/reflection_remover/verbose_files/expected/index.dart +++ b/modules/angular2/test/transform/reflection_remover/verbose_files/expected/index.dart @@ -11,12 +11,12 @@ library angular2.test.transform.reflection_remover.verbose_files.expected; var code = """ library web_foo; -import 'package:angular2/src/core/application.dart'; +import 'package:angular2/bootstrap_static.dart';import 'index.ng_deps.dart' as ngStaticInit0; import 'package:angular2/src/reflection/reflection.dart'; -import 'package:angular2/src/reflection/debug_reflection_capabilities.dart';import 'index.ng_deps.dart' as ngStaticInit0; +import 'package:angular2/src/reflection/debug_reflection_capabilities.dart'; void main() { - reflector.reflectionCapabilities = new ReflectionCapabilities(verbose: true);ngStaticInit0.initReflector(); - bootstrap(MyComponent); + ngStaticInit0.initReflector();reflector.reflectionCapabilities = new ReflectionCapabilities(verbose: true); + bootstrapStatic(MyComponent); } """; diff --git a/modules/angular2/test/transform/template_compiler/duplicate_files/expected/hello.ng_deps.dart b/modules/angular2/test/transform/template_compiler/duplicate_files/expected/hello.ng_deps.dart index 30c08f8983..d25e1967c8 100644 --- a/modules/angular2/test/transform/template_compiler/duplicate_files/expected/hello.ng_deps.dart +++ b/modules/angular2/test/transform/template_compiler/duplicate_files/expected/hello.ng_deps.dart @@ -2,7 +2,7 @@ library examples.hello_world.index_common_dart.ng_deps.dart; import 'hello.dart'; import 'package:angular2/angular2.dart' - show bootstrap, Component, Directive, View, NgElement; + show Component, Directive, View, NgElement; var _visited = false; void initReflector(reflector) { diff --git a/modules/angular2/test/transform/template_compiler/duplicate_files/hello.ng_deps.dart b/modules/angular2/test/transform/template_compiler/duplicate_files/hello.ng_deps.dart index 8afdf99b9e..84c5d26437 100644 --- a/modules/angular2/test/transform/template_compiler/duplicate_files/hello.ng_deps.dart +++ b/modules/angular2/test/transform/template_compiler/duplicate_files/hello.ng_deps.dart @@ -2,7 +2,7 @@ library examples.hello_world.index_common_dart.ng_deps.dart; import 'hello.dart'; import 'package:angular2/angular2.dart' - show bootstrap, Component, Directive, View, NgElement; + show Component, Directive, View, NgElement; var _visited = false; void initReflector(reflector) { diff --git a/modules/angular2/test/transform/template_compiler/inline_expression_files/expected/hello.ng_deps.dart b/modules/angular2/test/transform/template_compiler/inline_expression_files/expected/hello.ng_deps.dart index 1fc79e64aa..b658094f60 100644 --- a/modules/angular2/test/transform/template_compiler/inline_expression_files/expected/hello.ng_deps.dart +++ b/modules/angular2/test/transform/template_compiler/inline_expression_files/expected/hello.ng_deps.dart @@ -2,7 +2,7 @@ library examples.hello_world.index_common_dart.ng_deps.dart; import 'hello.dart'; import 'package:angular2/angular2.dart' - show bootstrap, Component, Directive, View, NgElement; + show Component, Directive, View, NgElement; var _visited = false; void initReflector(reflector) { diff --git a/modules/angular2/test/transform/template_compiler/inline_expression_files/hello.ng_deps.dart b/modules/angular2/test/transform/template_compiler/inline_expression_files/hello.ng_deps.dart index d87b0ac7db..b8bb3009ec 100644 --- a/modules/angular2/test/transform/template_compiler/inline_expression_files/hello.ng_deps.dart +++ b/modules/angular2/test/transform/template_compiler/inline_expression_files/hello.ng_deps.dart @@ -2,7 +2,7 @@ library examples.hello_world.index_common_dart.ng_deps.dart; import 'hello.dart'; import 'package:angular2/angular2.dart' - show bootstrap, Component, Directive, View, NgElement; + show Component, Directive, View, NgElement; var _visited = false; void initReflector(reflector) { diff --git a/modules/angular2/test/transform/template_compiler/inline_method_files/expected/hello.ng_deps.dart b/modules/angular2/test/transform/template_compiler/inline_method_files/expected/hello.ng_deps.dart index cd24c02b03..4198ed1bec 100644 --- a/modules/angular2/test/transform/template_compiler/inline_method_files/expected/hello.ng_deps.dart +++ b/modules/angular2/test/transform/template_compiler/inline_method_files/expected/hello.ng_deps.dart @@ -2,7 +2,7 @@ library examples.hello_world.index_common_dart.ng_deps.dart; import 'hello.dart'; import 'package:angular2/angular2.dart' - show bootstrap, Component, Directive, View, NgElement; + show Component, Directive, View, NgElement; var _visited = false; void initReflector(reflector) { diff --git a/modules/angular2/test/transform/template_compiler/inline_method_files/hello.ng_deps.dart b/modules/angular2/test/transform/template_compiler/inline_method_files/hello.ng_deps.dart index 947b517b03..d01ea1f4bf 100644 --- a/modules/angular2/test/transform/template_compiler/inline_method_files/hello.ng_deps.dart +++ b/modules/angular2/test/transform/template_compiler/inline_method_files/hello.ng_deps.dart @@ -2,7 +2,7 @@ library examples.hello_world.index_common_dart.ng_deps.dart; import 'hello.dart'; import 'package:angular2/angular2.dart' - show bootstrap, Component, Directive, View, NgElement; + show Component, Directive, View, NgElement; var _visited = false; void initReflector(reflector) { diff --git a/modules/angular2/test/transform/template_compiler/ng_for_files/hello.ng_deps.dart b/modules/angular2/test/transform/template_compiler/ng_for_files/hello.ng_deps.dart index ff7e8990d0..8a2bbe0443 100644 --- a/modules/angular2/test/transform/template_compiler/ng_for_files/hello.ng_deps.dart +++ b/modules/angular2/test/transform/template_compiler/ng_for_files/hello.ng_deps.dart @@ -2,7 +2,7 @@ library test.src.transform.template_compiler.ng_for_files.hello.ng_deps.dart; import 'hello.dart'; import 'package:angular2/angular2.dart' - show bootstrap, Component, Directive, View, NgElement; + show Component, Directive, View, NgElement; var _visited = false; void initReflector(reflector) { diff --git a/modules/angular2/test/transform/template_compiler/one_directive_files/expected/hello.ng_deps.dart b/modules/angular2/test/transform/template_compiler/one_directive_files/expected/hello.ng_deps.dart index 4b53eab40b..60dff279e1 100644 --- a/modules/angular2/test/transform/template_compiler/one_directive_files/expected/hello.ng_deps.dart +++ b/modules/angular2/test/transform/template_compiler/one_directive_files/expected/hello.ng_deps.dart @@ -2,7 +2,7 @@ library examples.hello_world.index_common_dart.ng_deps.dart; import 'hello.dart'; import 'package:angular2/angular2.dart' - show bootstrap, Component, Directive, View, NgElement; + show Component, Directive, View, NgElement; var _visited = false; void initReflector(reflector) { diff --git a/modules/angular2/test/transform/template_compiler/one_directive_files/hello.ng_deps.dart b/modules/angular2/test/transform/template_compiler/one_directive_files/hello.ng_deps.dart index 4b53eab40b..60dff279e1 100644 --- a/modules/angular2/test/transform/template_compiler/one_directive_files/hello.ng_deps.dart +++ b/modules/angular2/test/transform/template_compiler/one_directive_files/hello.ng_deps.dart @@ -2,7 +2,7 @@ library examples.hello_world.index_common_dart.ng_deps.dart; import 'hello.dart'; import 'package:angular2/angular2.dart' - show bootstrap, Component, Directive, View, NgElement; + show Component, Directive, View, NgElement; var _visited = false; void initReflector(reflector) { diff --git a/modules/angular2/test/transform/template_compiler/url_expression_files/expected/hello.ng_deps.dart b/modules/angular2/test/transform/template_compiler/url_expression_files/expected/hello.ng_deps.dart index 8fd3e9125c..446954cbcf 100644 --- a/modules/angular2/test/transform/template_compiler/url_expression_files/expected/hello.ng_deps.dart +++ b/modules/angular2/test/transform/template_compiler/url_expression_files/expected/hello.ng_deps.dart @@ -2,7 +2,7 @@ library examples.src.hello_world.index_common_dart; import 'hello.dart'; import 'package:angular2/angular2.dart' - show bootstrap, Component, Directive, View, NgElement; + show Component, Directive, View, NgElement; var _visited = false; void initReflector(reflector) { diff --git a/modules/angular2/test/transform/template_compiler/url_expression_files/hello.ng_deps.dart b/modules/angular2/test/transform/template_compiler/url_expression_files/hello.ng_deps.dart index 82fc706104..306f3bc732 100644 --- a/modules/angular2/test/transform/template_compiler/url_expression_files/hello.ng_deps.dart +++ b/modules/angular2/test/transform/template_compiler/url_expression_files/hello.ng_deps.dart @@ -2,7 +2,7 @@ library examples.src.hello_world.index_common_dart; import 'hello.dart'; import 'package:angular2/angular2.dart' - show bootstrap, Component, Directive, View, NgElement; + show Component, Directive, View, NgElement; var _visited = false; void initReflector(reflector) { diff --git a/modules/angular2/test/transform/template_compiler/url_method_files/expected/hello.ng_deps.dart b/modules/angular2/test/transform/template_compiler/url_method_files/expected/hello.ng_deps.dart index e9a6cc2fa1..16fbd53c07 100644 --- a/modules/angular2/test/transform/template_compiler/url_method_files/expected/hello.ng_deps.dart +++ b/modules/angular2/test/transform/template_compiler/url_method_files/expected/hello.ng_deps.dart @@ -2,7 +2,7 @@ library examples.src.hello_world.index_common_dart; import 'hello.dart'; import 'package:angular2/angular2.dart' - show bootstrap, Component, Directive, View, NgElement; + show Component, Directive, View, NgElement; var _visited = false; void initReflector(reflector) { diff --git a/modules/angular2/test/transform/template_compiler/url_method_files/hello.ng_deps.dart b/modules/angular2/test/transform/template_compiler/url_method_files/hello.ng_deps.dart index 82fc706104..306f3bc732 100644 --- a/modules/angular2/test/transform/template_compiler/url_method_files/hello.ng_deps.dart +++ b/modules/angular2/test/transform/template_compiler/url_method_files/hello.ng_deps.dart @@ -2,7 +2,7 @@ library examples.src.hello_world.index_common_dart; import 'hello.dart'; import 'package:angular2/angular2.dart' - show bootstrap, Component, Directive, View, NgElement; + show Component, Directive, View, NgElement; var _visited = false; void initReflector(reflector) { diff --git a/modules/angular2/test/transform/template_compiler/with_prefix_files/expected/goodbye.ng_deps.dart b/modules/angular2/test/transform/template_compiler/with_prefix_files/expected/goodbye.ng_deps.dart index 297b26e0c5..f8c8fea025 100644 --- a/modules/angular2/test/transform/template_compiler/with_prefix_files/expected/goodbye.ng_deps.dart +++ b/modules/angular2/test/transform/template_compiler/with_prefix_files/expected/goodbye.ng_deps.dart @@ -2,7 +2,7 @@ library examples.hello_world.index_common_dart.ng_deps.dart; import 'goodbye.dart'; import 'package:angular2/angular2.dart' - show bootstrap, Component, Directive, View, NgElement; + show Component, Directive, View, NgElement; var _visited = false; void initReflector(reflector) { diff --git a/modules/angular2/test/transform/template_compiler/with_prefix_files/expected/hello.ng_deps.dart b/modules/angular2/test/transform/template_compiler/with_prefix_files/expected/hello.ng_deps.dart index 6dd69eb21c..836f2a4aa3 100644 --- a/modules/angular2/test/transform/template_compiler/with_prefix_files/expected/hello.ng_deps.dart +++ b/modules/angular2/test/transform/template_compiler/with_prefix_files/expected/hello.ng_deps.dart @@ -4,7 +4,7 @@ import 'hello.dart'; import 'goodbye.dart' as prefix; import 'goodbye.ng_deps.dart' as i0; import 'package:angular2/angular2.dart' - show bootstrap, Component, Directive, View, NgElement; + show Component, Directive, View, NgElement; var _visited = false; void initReflector(reflector) { diff --git a/modules/angular2/test/transform/template_compiler/with_prefix_files/expected/ng2_prefix.ng_deps.dart b/modules/angular2/test/transform/template_compiler/with_prefix_files/expected/ng2_prefix.ng_deps.dart index bfa02da9be..67b0c7ad31 100644 --- a/modules/angular2/test/transform/template_compiler/with_prefix_files/expected/ng2_prefix.ng_deps.dart +++ b/modules/angular2/test/transform/template_compiler/with_prefix_files/expected/ng2_prefix.ng_deps.dart @@ -2,7 +2,7 @@ library angular2.test.transform.template_compiler.with_prefix_files.ng2_prefix.n import 'ng2_prefix.dart'; import 'package:angular2/angular2.dart' as ng2 - show bootstrap, Component, Directive, View, NgElement; + show Component, Directive, View, NgElement; var _visited = false; void initReflector(reflector) { diff --git a/modules/angular2/test/transform/template_compiler/with_prefix_files/goodbye.ng_deps.dart b/modules/angular2/test/transform/template_compiler/with_prefix_files/goodbye.ng_deps.dart index 4e17a6d062..8818fa072c 100644 --- a/modules/angular2/test/transform/template_compiler/with_prefix_files/goodbye.ng_deps.dart +++ b/modules/angular2/test/transform/template_compiler/with_prefix_files/goodbye.ng_deps.dart @@ -2,7 +2,7 @@ library examples.hello_world.index_common_dart.ng_deps.dart; import 'goodbye.dart'; import 'package:angular2/angular2.dart' - show bootstrap, Component, Directive, View, NgElement; + show Component, Directive, View, NgElement; var _visited = false; void initReflector(reflector) { diff --git a/modules/angular2/test/transform/template_compiler/with_prefix_files/hello.ng_deps.dart b/modules/angular2/test/transform/template_compiler/with_prefix_files/hello.ng_deps.dart index 6dd69eb21c..836f2a4aa3 100644 --- a/modules/angular2/test/transform/template_compiler/with_prefix_files/hello.ng_deps.dart +++ b/modules/angular2/test/transform/template_compiler/with_prefix_files/hello.ng_deps.dart @@ -4,7 +4,7 @@ import 'hello.dart'; import 'goodbye.dart' as prefix; import 'goodbye.ng_deps.dart' as i0; import 'package:angular2/angular2.dart' - show bootstrap, Component, Directive, View, NgElement; + show Component, Directive, View, NgElement; var _visited = false; void initReflector(reflector) { diff --git a/modules/angular2/test/transform/template_compiler/with_prefix_files/ng2_prefix.ng_deps.dart b/modules/angular2/test/transform/template_compiler/with_prefix_files/ng2_prefix.ng_deps.dart index 2fc86c0132..25a7bf7e4c 100644 --- a/modules/angular2/test/transform/template_compiler/with_prefix_files/ng2_prefix.ng_deps.dart +++ b/modules/angular2/test/transform/template_compiler/with_prefix_files/ng2_prefix.ng_deps.dart @@ -2,7 +2,7 @@ library angular2.test.transform.template_compiler.with_prefix_files.ng2_prefix.n import 'ng2_prefix.dart'; import 'package:angular2/angular2.dart' as ng2 - show bootstrap, Component, Directive, View, NgElement; + show Component, Directive, View, NgElement; var _visited = false; void initReflector(reflector) { diff --git a/modules/benchmarks/src/costs/index.ts b/modules/benchmarks/src/costs/index.ts index c5ab478316..7829928ab6 100644 --- a/modules/benchmarks/src/costs/index.ts +++ b/modules/benchmarks/src/costs/index.ts @@ -5,18 +5,15 @@ import { DynamicComponentLoader, ElementRef, View -} from 'angular2/angular2'; +} from 'angular2/bootstrap'; import {LifeCycle} from 'angular2/src/core/life_cycle/life_cycle'; import {List, ListWrapper} from 'angular2/src/facade/collection'; -import {reflector} from 'angular2/src/reflection/reflection'; -import {ReflectionCapabilities} from 'angular2/src/reflection/reflection_capabilities'; import {getIntParameter, bindAction} from 'angular2/src/test_lib/benchmark_util'; import {NgIf, NgFor} from 'angular2/directives'; var testList = null; export function main() { - reflector.reflectionCapabilities = new ReflectionCapabilities(); var size = getIntParameter('size'); testList = ListWrapper.createFixedSize(size); diff --git a/modules/benchmarks/src/di/di_benchmark.ts b/modules/benchmarks/src/di/di_benchmark.ts index b8bcdace26..8e2491a790 100644 --- a/modules/benchmarks/src/di/di_benchmark.ts +++ b/modules/benchmarks/src/di/di_benchmark.ts @@ -14,6 +14,7 @@ export function main() { BrowserDomAdapter.makeCurrent(); var iterations = getIntParameter('iterations'); + // This benchmark does not use bootstrap and needs to create a reflector setupReflector(); var bindings = [A, B, C, D, E]; var injector = Injector.resolveAndCreate(bindings); diff --git a/modules/benchmarks/src/largetable/largetable_benchmark.ts b/modules/benchmarks/src/largetable/largetable_benchmark.ts index 8e65706e6d..16fa6028e4 100644 --- a/modules/benchmarks/src/largetable/largetable_benchmark.ts +++ b/modules/benchmarks/src/largetable/largetable_benchmark.ts @@ -1,9 +1,7 @@ -import {bootstrap, Component, Directive, View} from 'angular2/angular2'; +import {bootstrap, Component, Directive, View} from 'angular2/bootstrap'; import {LifeCycle} from 'angular2/src/core/life_cycle/life_cycle'; -import {reflector} from 'angular2/src/reflection/reflection'; -import {ReflectionCapabilities} from 'angular2/src/reflection/reflection_capabilities'; import {DOM} from 'angular2/src/dom/dom_adapter'; import {window, document, gc} from 'angular2/src/facade/browser'; import { @@ -22,6 +20,7 @@ import {ListWrapper} from 'angular2/src/facade/collection'; import {bind} from 'angular2/di'; import {Inject} from 'angular2/src/di/decorators'; +import {reflector} from 'angular2/src/reflection/reflection'; export const BENCHMARK_TYPE = 'LargetableComponent.benchmarkType'; export const LARGETABLE_ROWS = 'LargetableComponent.rows'; @@ -41,8 +40,6 @@ function _createBindings() { var BASELINE_LARGETABLE_TEMPLATE; function setupReflector() { - reflector.reflectionCapabilities = new ReflectionCapabilities(); - // TODO(kegluneq): Generate these. reflector.registerGetters({ 'benchmarktype': (o) => o.benchmarktype, @@ -62,8 +59,6 @@ export function main() { var totalColumns = getIntParameter('columns'); BASELINE_LARGETABLE_TEMPLATE = DOM.createTemplate('
'); - setupReflector(); - var app; var lifecycle; var baselineRootLargetableComponent; @@ -132,6 +127,7 @@ export function main() { bindAction('#ng2UpdateDomProfile', profile(ng2CreateDom, noop, 'ng2-update')); bindAction('#ng2CreateDomProfile', profile(ng2CreateDom, ng2DestroyDom, 'ng2-create')); }); + setupReflector(); } function baselineDestroyDom() { baselineRootLargetableComponent.update(buildTable(0, 0)); } diff --git a/modules/benchmarks/src/naive_infinite_scroll/index.ts b/modules/benchmarks/src/naive_infinite_scroll/index.ts index 58df2ef0ad..c216646384 100644 --- a/modules/benchmarks/src/naive_infinite_scroll/index.ts +++ b/modules/benchmarks/src/naive_infinite_scroll/index.ts @@ -1,8 +1,7 @@ import {MapWrapper} from 'angular2/src/facade/collection'; -import {bootstrap} from 'angular2/angular2'; +import {bootstrap} from 'angular2/bootstrap'; import {reflector} from 'angular2/src/reflection/reflection'; -import {ReflectionCapabilities} from 'angular2/src/reflection/reflection_capabilities'; import {App} from './app'; @@ -10,8 +9,8 @@ import {APP_VIEW_POOL_CAPACITY} from 'angular2/src/core/compiler/view_pool'; import {bind} from 'angular2/di'; export function main() { - setupReflector(); bootstrap(App, createBindings()); + setupReflector(); } function createBindings(): List { @@ -19,8 +18,6 @@ function createBindings(): List { } export function setupReflector() { - reflector.reflectionCapabilities = new ReflectionCapabilities(); - // TODO(kegluneq): Generate this. reflector.registerSetters({ 'style': (o, m) => { diff --git a/modules/benchmarks/src/static_tree/tree_benchmark.ts b/modules/benchmarks/src/static_tree/tree_benchmark.ts index 5584453222..a6a3dced4f 100644 --- a/modules/benchmarks/src/static_tree/tree_benchmark.ts +++ b/modules/benchmarks/src/static_tree/tree_benchmark.ts @@ -1,4 +1,11 @@ -import {bootstrap, Compiler, Component, Directive, View, ViewContainerRef} from 'angular2/angular2'; +import { + bootstrap, + Compiler, + Component, + Directive, + View, + ViewContainerRef +} from 'angular2/bootstrap'; import {LifeCycle} from 'angular2/src/core/life_cycle/life_cycle'; import {reflector} from 'angular2/src/reflection/reflection'; diff --git a/modules/benchmarks/src/tree/tree_benchmark.ts b/modules/benchmarks/src/tree/tree_benchmark.ts index e95f805847..61a21abb91 100644 --- a/modules/benchmarks/src/tree/tree_benchmark.ts +++ b/modules/benchmarks/src/tree/tree_benchmark.ts @@ -1,8 +1,13 @@ -import {bootstrap, Compiler, Component, Directive, View, ViewContainerRef} from 'angular2/angular2'; +import { + bootstrap, + Compiler, + Component, + Directive, + View, + ViewContainerRef +} from 'angular2/bootstrap'; import {LifeCycle} from 'angular2/src/core/life_cycle/life_cycle'; -import {reflector} from 'angular2/src/reflection/reflection'; -import {ReflectionCapabilities} from 'angular2/src/reflection/reflection_capabilities'; import {DOM} from 'angular2/src/dom/dom_adapter'; import {isPresent} from 'angular2/src/facade/lang'; import {List} from 'angular2/src/facade/collection'; @@ -24,10 +29,6 @@ function createBindings(): List { return [bind(APP_VIEW_POOL_CAPACITY).toValue(viewCacheCapacity)]; } -function setupReflector() { - reflector.reflectionCapabilities = new ReflectionCapabilities(); -} - var BASELINE_TREE_TEMPLATE; var BASELINE_IF_TEMPLATE; @@ -35,8 +36,6 @@ export function main() { BrowserDomAdapter.makeCurrent(); var maxDepth = getIntParameter('depth'); - setupReflector(); - BASELINE_TREE_TEMPLATE = DOM.createTemplate( '_'); BASELINE_IF_TEMPLATE = DOM.createTemplate(''); diff --git a/modules/examples/src/gestures/index.ts b/modules/examples/src/gestures/index.ts index f63307b332..3ac14ccd3b 100644 --- a/modules/examples/src/gestures/index.ts +++ b/modules/examples/src/gestures/index.ts @@ -1,6 +1,4 @@ -import {bootstrap, Component, View} from 'angular2/angular2'; -import {reflector} from 'angular2/src/reflection/reflection'; -import {ReflectionCapabilities} from 'angular2/src/reflection/reflection_capabilities'; +import {bootstrap, Component, View} from 'angular2/bootstrap'; @Component({selector: 'gestures-app'}) @View({templateUrl: 'template.html'}) @@ -17,6 +15,5 @@ class GesturesCmp { } export function main() { - reflector.reflectionCapabilities = new ReflectionCapabilities(); bootstrap(GesturesCmp); } diff --git a/modules/examples/src/hello_world/index.ts b/modules/examples/src/hello_world/index.ts index c7802178f9..c760b32c47 100644 --- a/modules/examples/src/hello_world/index.ts +++ b/modules/examples/src/hello_world/index.ts @@ -1,18 +1,7 @@ import {HelloCmp} from './index_common'; -import {bootstrap} from 'angular2/angular2'; -import {reflector} from 'angular2/src/reflection/reflection'; -import {ReflectionCapabilities} from 'angular2/src/reflection/reflection_capabilities'; +import {bootstrap} from 'angular2/bootstrap'; export function main() { - // For Dart users: Initializing the reflector is only required for the Dart version of the - // application. When using Dart, the reflection information is not embedded by default in the - // source code to keep the size of the generated file small. Importing ReflectionCapabilities and - // initializing the reflector is required to use the reflection information from Dart mirrors. - // Dart mirrors are not intended to be use in production code. - // Angular 2 provides a transformer which generates static code rather than rely on reflection. - // For an example, run `pub serve` on the Dart application and inspect this file in your browser. - reflector.reflectionCapabilities = new ReflectionCapabilities(); - // Bootstrapping only requires specifying a root component. // The boundary between the Angular application and the rest of the page is // the shadowDom of this root component. diff --git a/modules/examples/src/hello_world/index_dynamic.ts b/modules/examples/src/hello_world/index_dynamic.ts index fcc9b7120c..70cf114109 100644 --- a/modules/examples/src/hello_world/index_dynamic.ts +++ b/modules/examples/src/hello_world/index_dynamic.ts @@ -1,11 +1,8 @@ import {HelloCmp} from './index_common'; -import {bootstrap} from 'angular2/angular2'; -import {reflector} from 'angular2/src/reflection/reflection'; -import {ReflectionCapabilities} from 'angular2/src/reflection/reflection_capabilities'; +import {bootstrap} from 'angular2/bootstrap'; +// This entry point is not transformed and exists for testing dynamic runtime +// mode. export function main() { - // This entry point is not transformed and exists for testing purposes. - // See index.js for an explanation. - reflector.reflectionCapabilities = new ReflectionCapabilities(); bootstrap(HelloCmp); } diff --git a/modules/examples/src/http/index.ts b/modules/examples/src/http/index.ts index d00a1ff537..fa6758a86d 100644 --- a/modules/examples/src/http/index.ts +++ b/modules/examples/src/http/index.ts @@ -1,12 +1,9 @@ /// -import {bootstrap} from 'angular2/angular2'; -import {reflector} from 'angular2/src/reflection/reflection'; -import {ReflectionCapabilities} from 'angular2/src/reflection/reflection_capabilities'; +import {bootstrap} from 'angular2/bootstrap'; import {httpInjectables} from 'angular2/http'; import {HttpCmp} from './http_comp'; export function main() { - reflector.reflectionCapabilities = new ReflectionCapabilities(); bootstrap(HttpCmp, [httpInjectables]); } diff --git a/modules/examples/src/http/index_dynamic.ts b/modules/examples/src/http/index_dynamic.ts index 1599ef841d..bcc800b1a1 100644 --- a/modules/examples/src/http/index_dynamic.ts +++ b/modules/examples/src/http/index_dynamic.ts @@ -1,13 +1,8 @@ import {HttpCmp} from './http_comp'; -import {bootstrap} from 'angular2/angular2'; -import {reflector} from 'angular2/src/reflection/reflection'; -import {ReflectionCapabilities} from 'angular2/src/reflection/reflection_capabilities'; +import {bootstrap} from 'angular2/bootstrap'; import {httpInjectables} from 'angular2/http'; - export function main() { - // This entry point is not transformed and exists for testing purposes. - // See index.js for an explanation. - reflector.reflectionCapabilities = new ReflectionCapabilities(); + // This entry point is not transformed and exists for testing dynamic mode. bootstrap(HttpCmp, [httpInjectables]); } diff --git a/modules/examples/src/jsonp/index.ts b/modules/examples/src/jsonp/index.ts index 9bbdb31b5e..b57cd3d517 100644 --- a/modules/examples/src/jsonp/index.ts +++ b/modules/examples/src/jsonp/index.ts @@ -1,12 +1,9 @@ /// -import {bootstrap} from 'angular2/angular2'; -import {reflector} from 'angular2/src/reflection/reflection'; -import {ReflectionCapabilities} from 'angular2/src/reflection/reflection_capabilities'; +import {bootstrap} from 'angular2/bootstrap'; import {jsonpInjectables} from 'angular2/http'; import {JsonpCmp} from './jsonp_comp'; export function main() { - reflector.reflectionCapabilities = new ReflectionCapabilities(); bootstrap(JsonpCmp, [jsonpInjectables]); } diff --git a/modules/examples/src/jsonp/index_dynamic.ts b/modules/examples/src/jsonp/index_dynamic.ts index b09e5da4d4..8e64e3c286 100644 --- a/modules/examples/src/jsonp/index_dynamic.ts +++ b/modules/examples/src/jsonp/index_dynamic.ts @@ -1,13 +1,7 @@ import {JsonpCmp} from './jsonp_comp'; -import {bootstrap} from 'angular2/angular2'; -import {reflector} from 'angular2/src/reflection/reflection'; -import {ReflectionCapabilities} from 'angular2/src/reflection/reflection_capabilities'; +import {bootstrap} from 'angular2/bootstrap'; import {jsonpInjectables} from 'angular2/http'; - export function main() { - // This entry point is not transformed and exists for testing purposes. - // See index.js for an explanation. - reflector.reflectionCapabilities = new ReflectionCapabilities(); bootstrap(JsonpCmp, [jsonpInjectables]); } diff --git a/modules/examples/src/key_events/index.ts b/modules/examples/src/key_events/index.ts index f30229e4bd..a7ecad450a 100644 --- a/modules/examples/src/key_events/index.ts +++ b/modules/examples/src/key_events/index.ts @@ -1,9 +1,6 @@ -import {bootstrap, Component, View} from 'angular2/angular2'; +import {bootstrap, Component, View} from 'angular2/bootstrap'; import {KeyEventsPlugin} from 'angular2/src/render/dom/events/key_events'; -import {reflector} from 'angular2/src/reflection/reflection'; -import {ReflectionCapabilities} from 'angular2/src/reflection/reflection_capabilities'; - @Component({selector: 'key-events-app'}) @View({ template: `Click in the following area and press a key to display its name:
@@ -34,6 +31,5 @@ class KeyEventsApp { } export function main() { - reflector.reflectionCapabilities = new ReflectionCapabilities(); // for the Dart version bootstrap(KeyEventsApp); } diff --git a/modules/examples/src/material/button/index.ts b/modules/examples/src/material/button/index.ts index fb51584bd0..4066a43056 100644 --- a/modules/examples/src/material/button/index.ts +++ b/modules/examples/src/material/button/index.ts @@ -1,4 +1,4 @@ -import {bootstrap, Component, View, NgFor} from 'angular2/angular2'; +import {bootstrap, Component, View, NgFor} from 'angular2/bootstrap'; import {MdButton, MdAnchor} from 'angular2_material/src/components/button/button'; import {UrlResolver} from 'angular2/src/services/url_resolver'; import {commonDemoSetup, DemoUrlResolver} from '../demo_common'; diff --git a/modules/examples/src/material/checkbox/index.ts b/modules/examples/src/material/checkbox/index.ts index 1be5a93266..d34a8a4363 100644 --- a/modules/examples/src/material/checkbox/index.ts +++ b/modules/examples/src/material/checkbox/index.ts @@ -1,4 +1,4 @@ -import {bootstrap, Component, Directive, View} from 'angular2/angular2'; +import {bootstrap, Component, Directive, View} from 'angular2/bootstrap'; import {MdCheckbox} from 'angular2_material/src/components/checkbox/checkbox'; import {UrlResolver} from 'angular2/src/services/url_resolver'; import {commonDemoSetup, DemoUrlResolver} from '../demo_common'; diff --git a/modules/examples/src/material/demo_common.ts b/modules/examples/src/material/demo_common.ts index d5c8c363d6..46a9c13faa 100644 --- a/modules/examples/src/material/demo_common.ts +++ b/modules/examples/src/material/demo_common.ts @@ -9,14 +9,11 @@ import { } from 'angular2/src/facade/lang'; import {DOM} from 'angular2/src/dom/dom_adapter'; import {Injectable} from 'angular2/di'; -import {ReflectionCapabilities} from 'angular2/src/reflection/reflection_capabilities'; -import {reflector} from 'angular2/src/reflection/reflection'; import {BrowserDomAdapter} from 'angular2/src/dom/browser_adapter'; export function commonDemoSetup(): void { BrowserDomAdapter.makeCurrent(); - reflector.reflectionCapabilities = new ReflectionCapabilities(); } @Injectable() diff --git a/modules/examples/src/material/dialog/index.ts b/modules/examples/src/material/dialog/index.ts index cf55f5c477..2f098324c7 100644 --- a/modules/examples/src/material/dialog/index.ts +++ b/modules/examples/src/material/dialog/index.ts @@ -1,4 +1,4 @@ -import {bootstrap, ElementRef, ComponentRef, Component, View} from 'angular2/angular2'; +import {bootstrap, ElementRef, ComponentRef, Component, View} from 'angular2/bootstrap'; import { MdDialog, MdDialogRef, diff --git a/modules/examples/src/material/grid_list/index.ts b/modules/examples/src/material/grid_list/index.ts index ae7bd807d3..0d87985d68 100644 --- a/modules/examples/src/material/grid_list/index.ts +++ b/modules/examples/src/material/grid_list/index.ts @@ -1,4 +1,4 @@ -import {bootstrap, Component, View} from 'angular2/angular2'; +import {bootstrap, Component, View} from 'angular2/bootstrap'; import {MdGridList, MdGridTile} from 'angular2_material/src/components/grid_list/grid_list'; import {UrlResolver} from 'angular2/src/services/url_resolver'; import {commonDemoSetup, DemoUrlResolver} from '../demo_common'; diff --git a/modules/examples/src/material/input/index.ts b/modules/examples/src/material/input/index.ts index 9fdc1fd917..683a5a3605 100644 --- a/modules/examples/src/material/input/index.ts +++ b/modules/examples/src/material/input/index.ts @@ -1,4 +1,4 @@ -import {bootstrap, Component, View} from 'angular2/angular2'; +import {bootstrap, Component, View} from 'angular2/bootstrap'; import {MdInputContainer, MdInput} from 'angular2_material/src/components/input/input'; import {UrlResolver} from 'angular2/src/services/url_resolver'; import {commonDemoSetup, DemoUrlResolver} from '../demo_common'; diff --git a/modules/examples/src/material/progress-linear/index.ts b/modules/examples/src/material/progress-linear/index.ts index e6a94a4d41..7c5a08b1d6 100644 --- a/modules/examples/src/material/progress-linear/index.ts +++ b/modules/examples/src/material/progress-linear/index.ts @@ -1,4 +1,4 @@ -import {bootstrap, Component, View} from 'angular2/angular2'; +import {bootstrap, Component, View} from 'angular2/bootstrap'; import {MdProgressLinear} from 'angular2_material/src/components/progress-linear/progress_linear'; import {UrlResolver} from 'angular2/src/services/url_resolver'; import {commonDemoSetup, DemoUrlResolver} from '../demo_common'; diff --git a/modules/examples/src/material/radio/index.ts b/modules/examples/src/material/radio/index.ts index 82b113bcd0..b08b5e76b1 100644 --- a/modules/examples/src/material/radio/index.ts +++ b/modules/examples/src/material/radio/index.ts @@ -1,4 +1,4 @@ -import {bootstrap, Component, View} from 'angular2/angular2'; +import {bootstrap, Component, View} from 'angular2/bootstrap'; import {MdRadioButton, MdRadioGroup} from 'angular2_material/src/components/radio/radio_button'; import {MdRadioDispatcher} from 'angular2_material/src/components/radio/radio_dispatcher'; import {UrlResolver} from 'angular2/src/services/url_resolver'; diff --git a/modules/examples/src/material/switcher/index.ts b/modules/examples/src/material/switcher/index.ts index 88a8ed6e29..a45395a57f 100644 --- a/modules/examples/src/material/switcher/index.ts +++ b/modules/examples/src/material/switcher/index.ts @@ -1,4 +1,4 @@ -import {bootstrap, Component, View} from 'angular2/angular2'; +import {bootstrap, Component, View} from 'angular2/bootstrap'; import {MdSwitch} from 'angular2_material/src/components/switcher/switch'; import {UrlResolver} from 'angular2/src/services/url_resolver'; import {commonDemoSetup, DemoUrlResolver} from '../demo_common'; diff --git a/modules/examples/src/model_driven_forms/index.ts b/modules/examples/src/model_driven_forms/index.ts index 047ad6d367..71b2887420 100644 --- a/modules/examples/src/model_driven_forms/index.ts +++ b/modules/examples/src/model_driven_forms/index.ts @@ -7,14 +7,11 @@ import { Directive, View, Ancestor -} from 'angular2/angular2'; +} from 'angular2/bootstrap'; import {formDirectives, NgControl, Validators, NgFormModel, FormBuilder} from 'angular2/forms'; import {RegExpWrapper, print, isPresent} from 'angular2/src/facade/lang'; -import {reflector} from 'angular2/src/reflection/reflection'; -import {ReflectionCapabilities} from 'angular2/src/reflection/reflection_capabilities'; - /** * Custom validator. */ @@ -155,6 +152,5 @@ class ModelDrivenForms { } export function main() { - reflector.reflectionCapabilities = new ReflectionCapabilities(); bootstrap(ModelDrivenForms); } diff --git a/modules/examples/src/order_management/index.ts b/modules/examples/src/order_management/index.ts index fd7b8732d6..9e7ff89d1f 100644 --- a/modules/examples/src/order_management/index.ts +++ b/modules/examples/src/order_management/index.ts @@ -11,15 +11,12 @@ import { forwardRef, Binding, EventEmitter -} from 'angular2/angular2'; +} from 'angular2/bootstrap'; import {formDirectives} from 'angular2/forms'; import {ListWrapper} from 'angular2/src/facade/collection'; -import {reflector} from 'angular2/src/reflection/reflection'; -import {ReflectionCapabilities} from 'angular2/src/reflection/reflection_capabilities'; - /** * You can find the Angular 1 implementation of this example here: * https://github.com/wardbell/ng1DataBinding @@ -86,29 +83,29 @@ class DataService { @Component({selector: 'order-list-cmp'}) @View({ template: ` -

Orders

+

Orders

- + {{order.customerName}}
- +
- +
- +
- + {{order.items.length}}
- +
- + {{order.total}}
- + -
+ `, directives: [formDirectives, NgFor] }) @@ -123,24 +120,24 @@ class OrderListComponent { @Component({selector: 'order-item-cmp', properties: ['item'], events: ['delete']}) @View({ template: ` -
+
- +
- +
- +
- +
- +
- +
- + {{item.total}}
- +
`, @@ -157,25 +154,25 @@ class OrderItemComponent { @View({ template: `
-

Selected Order

+

Selected Order

- +
- +
- +
- +
- + {{order.items.length}}
- +
- + {{order.total}}
- +

Items

@@ -205,6 +202,5 @@ class OrderManagementApplication { } export function main() { - reflector.reflectionCapabilities = new ReflectionCapabilities(); bootstrap(OrderManagementApplication); } diff --git a/modules/examples/src/person_management/index.ts b/modules/examples/src/person_management/index.ts index 2c9e87ac3b..7d7eedbdff 100644 --- a/modules/examples/src/person_management/index.ts +++ b/modules/examples/src/person_management/index.ts @@ -10,15 +10,12 @@ import { NgValidator, forwardRef, Binding -} from 'angular2/angular2'; +} from 'angular2/bootstrap'; import {formDirectives} from 'angular2/forms'; import {RegExpWrapper, print, isPresent, CONST_EXPR} from 'angular2/src/facade/lang'; -import {reflector} from 'angular2/src/reflection/reflection'; -import {ReflectionCapabilities} from 'angular2/src/reflection/reflection_capabilities'; - /** * You can find the Angular 1 implementation of this example here: @@ -93,25 +90,25 @@ class DataService { @Component({selector: 'full-name-cmp'}) @View({ template: ` -

Edit Full Name

+

Edit Full Name

+
- +
+
- +
-
+
`, directives: [formDirectives] @@ -125,38 +122,38 @@ class FullNameComponent { @View({ template: `

{{person.fullName}}

- +
-
- -
- -
- +
+
- -
- + +
+ +
+ +
+ Age: {{person.age}}
\ - -
- + +
+ - {{person.mom.fullName}} + {{person.mom.fullName}}
- -
- + +
+ - {{person.dad.fullName}} + {{person.dad.fullName}}
- -
- + +
+ {{person.friendNames}}
@@ -172,14 +169,14 @@ class PersonsDetailComponent { @Component({selector: 'persons-cmp'}) @View({ template: ` -

FullName Demo

+

FullName Demo

    -
  • +
  • -
  • +
- +
`, @@ -199,7 +196,7 @@ class PersonsComponent { template: ` - + `, @@ -213,6 +210,5 @@ class PersonManagementApplication { } export function main() { - reflector.reflectionCapabilities = new ReflectionCapabilities(); bootstrap(PersonManagementApplication); } diff --git a/modules/examples/src/sourcemap/index.ts b/modules/examples/src/sourcemap/index.ts index 5ea8902678..baf9fb96f5 100644 --- a/modules/examples/src/sourcemap/index.ts +++ b/modules/examples/src/sourcemap/index.ts @@ -1,7 +1,5 @@ import {BaseException} from 'angular2/src/facade/lang'; -import {bootstrap, Component, View} from 'angular2/angular2'; -import {reflector} from 'angular2/src/reflection/reflection'; -import {ReflectionCapabilities} from 'angular2/src/reflection/reflection_capabilities'; +import {bootstrap, Component, View} from 'angular2/bootstrap'; @Component({ selector: 'error-app', @@ -15,6 +13,5 @@ export class ErrorComponent { } export function main() { - reflector.reflectionCapabilities = new ReflectionCapabilities(); // for the Dart version bootstrap(ErrorComponent); } diff --git a/modules/examples/src/template_driven_forms/index.ts b/modules/examples/src/template_driven_forms/index.ts index fb6c571f4e..4fd3e0bd98 100644 --- a/modules/examples/src/template_driven_forms/index.ts +++ b/modules/examples/src/template_driven_forms/index.ts @@ -10,14 +10,11 @@ import { NgValidator, forwardRef, Binding -} from 'angular2/angular2'; +} from 'angular2/bootstrap'; import {formDirectives, NgControl, Validators, NgForm} from 'angular2/forms'; import {RegExpWrapper, print, isPresent, CONST_EXPR} from 'angular2/src/facade/lang'; -import {reflector} from 'angular2/src/reflection/reflection'; -import {ReflectionCapabilities} from 'angular2/src/reflection/reflection_capabilities'; - /** * A domain model we are binding the form controls to. */ @@ -168,6 +165,5 @@ class TemplateDrivenForms { } export function main() { - reflector.reflectionCapabilities = new ReflectionCapabilities(); bootstrap(TemplateDrivenForms); } diff --git a/modules/examples/src/todo/index.ts b/modules/examples/src/todo/index.ts index 19d46e790b..0f5b82c005 100644 --- a/modules/examples/src/todo/index.ts +++ b/modules/examples/src/todo/index.ts @@ -1,7 +1,5 @@ -import {bootstrap, NgFor, Component, View} from 'angular2/angular2'; +import {bootstrap, NgFor, Component, View} from 'angular2/bootstrap'; import {Store, Todo, TodoFactory} from './services/TodoStore'; -import {reflector} from 'angular2/src/reflection/reflection'; -import {ReflectionCapabilities} from 'angular2/src/reflection/reflection_capabilities'; @Component({selector: 'todo-app', viewInjector: [Store, TodoFactory]}) @View({templateUrl: 'todo.html', directives: [NgFor]}) @@ -44,6 +42,5 @@ class TodoApp { } export function main() { - reflector.reflectionCapabilities = new ReflectionCapabilities(); // for the Dart version bootstrap(TodoApp); } diff --git a/modules/examples/src/zippy_component/index.ts b/modules/examples/src/zippy_component/index.ts index f03c4a5f79..f9e457ca75 100644 --- a/modules/examples/src/zippy_component/index.ts +++ b/modules/examples/src/zippy_component/index.ts @@ -1,6 +1,4 @@ -import {bootstrap, Component, View, NgFor} from 'angular2/angular2'; -import {reflector} from 'angular2/src/reflection/reflection'; -import {ReflectionCapabilities} from 'angular2/src/reflection/reflection_capabilities'; +import {bootstrap, Component, View, NgFor} from 'angular2/bootstrap'; import {Zippy} from './zippy'; @Component({selector: 'zippy-app'}) @@ -22,6 +20,5 @@ class ZippyApp { } export function main() { - reflector.reflectionCapabilities = new ReflectionCapabilities(); bootstrap(ZippyApp); } diff --git a/protractor-shared.js b/protractor-shared.js index 69ec626ec3..093d943f8c 100644 --- a/protractor-shared.js +++ b/protractor-shared.js @@ -189,7 +189,7 @@ var config = exports.config = { function patchProtractorWait(browser) { browser.ignoreSynchronization = true; var _get = browser.get; - var sleepInterval = process.env.TRAVIS || process.env.JENKINS_URL ? 7000 : 3000; + var sleepInterval = process.env.TRAVIS || process.env.JENKINS_URL ? 14000 : 8000; browser.get = function() { var result = _get.apply(this, arguments); browser.sleep(sleepInterval);