diff --git a/modules/angular2/angular2.dart b/modules/angular2/angular2.dart
index affb09c27c..d0c2e10178 100644
--- a/modules/angular2/angular2.dart
+++ b/modules/angular2/angular2.dart
@@ -13,4 +13,3 @@ export 'package:angular2/lifecycle_hooks.dart';
export 'package:angular2/src/core/application_tokens.dart'
hide APP_COMPONENT_REF_PROMISE, APP_ID_RANDOM_PROVIDER;
export 'package:angular2/src/core/render/dom/dom_tokens.dart';
-export 'package:angular2/platform/browser_static.dart' hide bootstrapStatic;
diff --git a/modules/angular2/angular2.ts b/modules/angular2/angular2.ts
index 54d0f5f37a..c4358d1b21 100644
--- a/modules/angular2/angular2.ts
+++ b/modules/angular2/angular2.ts
@@ -2,5 +2,5 @@ export * from './common';
export * from './core';
export * from './profile';
export * from './lifecycle_hooks';
-export * from './platform/browser';
+export * from './bootstrap';
export * from './upgrade';
diff --git a/modules/angular2/bootstrap.ts b/modules/angular2/bootstrap.ts
index d7c24b6848..8a9456270b 100644
--- a/modules/angular2/bootstrap.ts
+++ b/modules/angular2/bootstrap.ts
@@ -1,5 +1,5 @@
/**
- * See {@link bootstrap} for more information.
- * @deprecated
+ * This file is only used for dart applications and for internal examples
+ * that compile with both JavaScript and Dart.
*/
-export {bootstrap} from 'angular2/platform/browser';
+export {bootstrap} from 'angular2/src/core/bootstrap';
diff --git a/modules/angular2/bootstrap_static.dart b/modules/angular2/bootstrap_static.dart
new file mode 100644
index 0000000000..5297bb9bd6
--- /dev/null
+++ b/modules/angular2/bootstrap_static.dart
@@ -0,0 +1,3 @@
+library angular2.bootstrap_static;
+
+export 'src/core/application_static.dart';
diff --git a/modules/angular2/bootstrap_static.ts b/modules/angular2/bootstrap_static.ts
deleted file mode 100644
index a3a242aff7..0000000000
--- a/modules/angular2/bootstrap_static.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-/**
- * See {@link bootstrap} for more information.
- * @deprecated
- */
-export {bootstrapStatic} from 'angular2/platform/browser_static';
diff --git a/modules/angular2/compiler.ts b/modules/angular2/compiler.ts
index 57856c054b..1d4eb68690 100644
--- a/modules/angular2/compiler.ts
+++ b/modules/angular2/compiler.ts
@@ -4,5 +4,4 @@
* Starting point to import all compiler APIs.
*/
export * from './src/compiler/url_resolver';
-export * from './src/compiler/xhr';
-export * from './src/compiler/compiler';
\ No newline at end of file
+export * from './src/compiler/xhr';
\ No newline at end of file
diff --git a/modules/angular2/core.dart b/modules/angular2/core.dart
index 164a4bc129..7bc88ba7d8 100644
--- a/modules/angular2/core.dart
+++ b/modules/angular2/core.dart
@@ -7,6 +7,8 @@ export 'package:angular2/src/core/dev_mode.dart';
export 'package:angular2/src/core/di.dart';
export 'package:angular2/src/common/pipes.dart';
export 'package:angular2/src/facade/facade.dart';
+// Do not export application for dart. Must import from angular2/bootstrap
+//export 'package:angular2/src/core/application.dart';
export 'package:angular2/src/core/application_ref.dart'
hide ApplicationRef_, PlatformRef_;
export 'package:angular2/src/core/services.dart';
@@ -18,6 +20,3 @@ export 'package:angular2/src/common/forms.dart';
export 'package:angular2/src/core/debug.dart';
export 'package:angular2/src/core/change_detection.dart';
export 'package:angular2/src/core/platform_directives_and_pipes.dart';
-export 'package:angular2/src/core/platform_common_providers.dart';
-export 'package:angular2/src/core/application_common_providers.dart';
-export 'package:angular2/src/core/reflection/reflection.dart';
diff --git a/modules/angular2/core.ts b/modules/angular2/core.ts
index 93286a4768..55ea21dd9b 100644
--- a/modules/angular2/core.ts
+++ b/modules/angular2/core.ts
@@ -8,10 +8,11 @@ export * from './src/core/util';
export * from './src/core/di';
export * from './src/common/pipes';
export * from './src/facade/facade';
+export * from './src/core/application';
+export * from './src/core/bootstrap';
export * from './src/core/services';
export * from './src/core/linker';
-export {platform, createNgZone, PlatformRef, ApplicationRef} from './src/core/application_ref';
-export {APP_ID, APP_COMPONENT} from './src/core/application_tokens';
+export {ApplicationRef} from './src/core/application_ref';
export * from './src/core/zone';
export * from './src/core/render';
export * from './src/common/directives';
@@ -20,6 +21,3 @@ export * from './src/core/debug';
export * from './src/core/change_detection';
export * from './src/core/platform_directives_and_pipes';
export * from './src/core/dev_mode';
-export * from './src/core/reflection/reflection';
-export * from './src/core/application_common_providers';
-export * from './src/core/platform_common_providers';
diff --git a/modules/angular2/examples/core/ts/dev_mode/dev_mode_example.ts b/modules/angular2/examples/core/ts/dev_mode/dev_mode_example.ts
index 95dbf56cd2..d3ec8bcbdc 100644
--- a/modules/angular2/examples/core/ts/dev_mode/dev_mode_example.ts
+++ b/modules/angular2/examples/core/ts/dev_mode/dev_mode_example.ts
@@ -1,5 +1,5 @@
// #docregion enableDevMode
-import {bootstrap, enableDevMode} from 'angular2/angular2';
+import {bootstrap, enableDevMode} from 'angular2/core';
import {MyComponent} from 'my_component';
enableDevMode();
diff --git a/modules/angular2/platform/browser.ts b/modules/angular2/platform/browser.ts
deleted file mode 100644
index 06028fa382..0000000000
--- a/modules/angular2/platform/browser.ts
+++ /dev/null
@@ -1,113 +0,0 @@
-export {BROWSER_PROVIDERS} from 'angular2/src/platform/browser_common';
-
-import {Type, isPresent, CONST_EXPR} from 'angular2/src/facade/lang';
-import {Promise} from 'angular2/src/facade/promise';
-import {
- BROWSER_PROVIDERS,
- BROWSER_APP_COMMON_PROVIDERS,
- initBrowser
-} from 'angular2/src/platform/browser_common';
-import {COMPILER_PROVIDERS} from 'angular2/compiler';
-import {ComponentRef, platform, reflector} from 'angular2/core';
-import {ReflectionCapabilities} from 'angular2/src/core/reflection/reflection_capabilities';
-
-/**
- * An array of providers that should be passed into `application()` when bootstrapping a component.
- */
-export const BROWSER_APP_PROVIDERS: Array =
- CONST_EXPR([BROWSER_APP_COMMON_PROVIDERS, COMPILER_PROVIDERS]);
-
-/**
- * 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 providers 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
- * providers. 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',
- * 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 an emulated or 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 providers for the
- * application.
- *
- *
- * ## Bootstrapping Multiple Applications
- *
- * 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 object 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(...)`.
- * - `customProviders`: An additional set of providers that can be added to the
- * app injector to override default injection behavior.
- *
- * Returns a `Promise` of {@link ComponentRef}.
- */
-export function bootstrap(
- appComponentType: Type,
- customProviders?: Array): Promise {
- reflector.reflectionCapabilities = new ReflectionCapabilities();
- initBrowser();
-
- let appProviders =
- isPresent(customProviders) ? [BROWSER_APP_PROVIDERS, customProviders] : BROWSER_APP_PROVIDERS;
- return platform(BROWSER_PROVIDERS).application(appProviders).bootstrap(appComponentType);
-}
\ No newline at end of file
diff --git a/modules/angular2/platform/browser_static.ts b/modules/angular2/platform/browser_static.ts
deleted file mode 100644
index 98ed515e7e..0000000000
--- a/modules/angular2/platform/browser_static.ts
+++ /dev/null
@@ -1,34 +0,0 @@
-export {BROWSER_PROVIDERS} from 'angular2/src/platform/browser_common';
-
-import {Type, isPresent, CONST_EXPR} from 'angular2/src/facade/lang';
-import {Promise} from 'angular2/src/facade/promise';
-import {
- BROWSER_PROVIDERS,
- BROWSER_APP_COMMON_PROVIDERS,
- initBrowser
-} from 'angular2/src/platform/browser_common';
-import {ComponentRef, platform, reflector} from 'angular2/core';
-
-/**
- * An array of providers that should be passed into `application()` when bootstrapping a component
- * when all templates
- * have been precompiled offline.
- */
-export const BROWSER_APP_PROVIDERS: Array =
- BROWSER_APP_COMMON_PROVIDERS;
-
-/**
- * See {@link bootstrap} for more information.
- */
-export function bootstrapStatic(appComponentType: Type,
- customProviders?: Array,
- initReflector?: Function): Promise {
- initBrowser();
- if (isPresent(initReflector)) {
- initReflector();
- }
-
- let appProviders =
- isPresent(customProviders) ? [BROWSER_APP_PROVIDERS, customProviders] : BROWSER_APP_PROVIDERS;
- return platform(BROWSER_PROVIDERS).application(appProviders).bootstrap(appComponentType);
-}
\ No newline at end of file
diff --git a/modules/angular2/src/compiler/compiler.ts b/modules/angular2/src/compiler/compiler.ts
index a64ea755f8..e1b34c891b 100644
--- a/modules/angular2/src/compiler/compiler.ts
+++ b/modules/angular2/src/compiler/compiler.ts
@@ -8,7 +8,7 @@ export {
export {SourceModule, SourceWithImports} from './source_module';
export {PLATFORM_DIRECTIVES, PLATFORM_PIPES} from 'angular2/src/core/platform_directives_and_pipes';
-import {assertionsEnabled, Type, CONST_EXPR} from 'angular2/src/facade/lang';
+import {assertionsEnabled, Type} from 'angular2/src/facade/lang';
import {provide, Provider} from 'angular2/src/core/di';
import {TemplateParser} from 'angular2/src/compiler/template_parser';
import {HtmlParser} from 'angular2/src/compiler/html_parser';
@@ -28,27 +28,26 @@ import {AppRootUrl} from 'angular2/src/compiler/app_root_url';
import {AnchorBasedAppRootUrl} from 'angular2/src/compiler/anchor_based_app_root_url';
import {Parser, Lexer} from 'angular2/src/core/change_detection/change_detection';
-function _createChangeDetectorGenConfig() {
- return new ChangeDetectorGenConfig(assertionsEnabled(), false, true);
+export function compilerProviders(): Array {
+ return [
+ Lexer,
+ Parser,
+ HtmlParser,
+ TemplateParser,
+ TemplateNormalizer,
+ RuntimeMetadataResolver,
+ StyleCompiler,
+ CommandCompiler,
+ ChangeDetectionCompiler,
+ provide(ChangeDetectorGenConfig,
+ {useValue: new ChangeDetectorGenConfig(assertionsEnabled(), false, true)}),
+ TemplateCompiler,
+ provide(RuntimeCompiler, {useClass: RuntimeCompiler_}),
+ provide(Compiler, {useExisting: RuntimeCompiler}),
+ DomElementSchemaRegistry,
+ provide(ElementSchemaRegistry, {useExisting: DomElementSchemaRegistry}),
+ AnchorBasedAppRootUrl,
+ provide(AppRootUrl, {useExisting: AnchorBasedAppRootUrl}),
+ UrlResolver
+ ];
}
-
-export const COMPILER_PROVIDERS: Array = CONST_EXPR([
- Lexer,
- Parser,
- HtmlParser,
- TemplateParser,
- TemplateNormalizer,
- RuntimeMetadataResolver,
- StyleCompiler,
- CommandCompiler,
- ChangeDetectionCompiler,
- new Provider(ChangeDetectorGenConfig, {useFactory: _createChangeDetectorGenConfig, deps: []}),
- TemplateCompiler,
- new Provider(RuntimeCompiler, {useClass: RuntimeCompiler_}),
- new Provider(Compiler, {useExisting: RuntimeCompiler}),
- DomElementSchemaRegistry,
- new Provider(ElementSchemaRegistry, {useExisting: DomElementSchemaRegistry}),
- AnchorBasedAppRootUrl,
- new Provider(AppRootUrl, {useExisting: AnchorBasedAppRootUrl}),
- UrlResolver
-]);
diff --git a/modules/angular2/src/platform/browser/xhr_impl.dart b/modules/angular2/src/compiler/xhr_impl.dart
similarity index 88%
rename from modules/angular2/src/platform/browser/xhr_impl.dart
rename to modules/angular2/src/compiler/xhr_impl.dart
index 988e331973..078c730b40 100644
--- a/modules/angular2/src/platform/browser/xhr_impl.dart
+++ b/modules/angular2/src/compiler/xhr_impl.dart
@@ -3,7 +3,7 @@ library angular2.src.services.xhr_impl;
import 'dart:async' show Future;
import 'dart:html' show HttpRequest;
import 'package:angular2/core.dart';
-import 'package:angular2/compiler.dart' show XHR;
+import './xhr.dart' show XHR;
@Injectable()
class XHRImpl extends XHR {
diff --git a/modules/angular2/src/platform/browser/xhr_impl.ts b/modules/angular2/src/compiler/xhr_impl.ts
similarity index 96%
rename from modules/angular2/src/platform/browser/xhr_impl.ts
rename to modules/angular2/src/compiler/xhr_impl.ts
index c54d4c76f1..f6f2c576f5 100644
--- a/modules/angular2/src/platform/browser/xhr_impl.ts
+++ b/modules/angular2/src/compiler/xhr_impl.ts
@@ -1,6 +1,6 @@
import {Promise, PromiseWrapper, PromiseCompleter} from 'angular2/src/facade/promise';
import {isPresent} from 'angular2/src/facade/lang';
-import {XHR} from 'angular2/src/compiler/xhr';
+import {XHR} from './xhr';
export class XHRImpl extends XHR {
get(url: string): Promise {
diff --git a/modules/angular2/src/core/application.dart b/modules/angular2/src/core/application.dart
new file mode 100644
index 0000000000..3cee988d86
--- /dev/null
+++ b/modules/angular2/src/core/application.dart
@@ -0,0 +1,29 @@
+library angular2.src.core.application;
+
+import 'dart:async';
+
+import 'package:angular2/src/core/reflection/reflection.dart' show reflector;
+import 'package:angular2/src/core/reflection/reflection_capabilities.dart'
+ show ReflectionCapabilities;
+import 'application_common.dart';
+
+import 'package:angular2/src/compiler/compiler.dart';
+import 'package:angular2/src/core/linker/dynamic_component_loader.dart';
+export 'package:angular2/src/core/linker/dynamic_component_loader.dart'
+ show ComponentRef;
+
+/// 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 componentInjectableProviders]) {
+ reflector.reflectionCapabilities = new ReflectionCapabilities();
+ var providers = [compilerProviders()];
+ if (componentInjectableProviders != null) {
+ providers.add(componentInjectableProviders);
+ }
+ return commonBootstrap(appComponentType, providers);
+}
diff --git a/modules/angular2/src/core/application.ts b/modules/angular2/src/core/application.ts
new file mode 100644
index 0000000000..b275f2210b
--- /dev/null
+++ b/modules/angular2/src/core/application.ts
@@ -0,0 +1,29 @@
+// Public API for Application
+import {Provider} from './di';
+import {Type, isPresent} from 'angular2/src/facade/lang';
+import {Promise} from 'angular2/src/facade/async';
+import {compilerProviders} from 'angular2/src/compiler/compiler';
+import {commonBootstrap} from './application_common';
+import {ComponentRef} from './linker/dynamic_component_loader';
+
+export {APP_COMPONENT, APP_ID} from './application_tokens';
+export {platform} from './application_common';
+export {
+ PlatformRef,
+ ApplicationRef,
+ applicationCommonProviders,
+ createNgZone,
+ platformCommon,
+ platformProviders
+} from './application_ref';
+
+/// See [commonBootstrap] for detailed documentation.
+export function bootstrap(
+ appComponentType: /*Type*/ any,
+ appProviders: Array = null): Promise {
+ var providers = [compilerProviders()];
+ if (isPresent(appProviders)) {
+ providers.push(appProviders);
+ }
+ return commonBootstrap(appComponentType, providers);
+}
diff --git a/modules/angular2/src/core/application_common.ts b/modules/angular2/src/core/application_common.ts
new file mode 100644
index 0000000000..8552ed5dfc
--- /dev/null
+++ b/modules/angular2/src/core/application_common.ts
@@ -0,0 +1,219 @@
+import {FORM_PROVIDERS} from 'angular2/src/common/forms';
+import {provide, Provider} from 'angular2/src/core/di';
+import {Type, isBlank, isPresent, stringify} from 'angular2/src/facade/lang';
+import {BrowserDomAdapter} from 'angular2/src/core/dom/browser_adapter';
+import {BrowserGetTestability} from 'angular2/src/core/testability/browser_testability';
+import {DOM} from 'angular2/src/core/dom/dom_adapter';
+import {Promise} from 'angular2/src/facade/async';
+import {XHR} from 'angular2/src/compiler/xhr';
+import {XHRImpl} from 'angular2/src/compiler/xhr_impl';
+
+import {
+ EventManager,
+ DomEventsPlugin,
+ EVENT_MANAGER_PLUGINS
+} from 'angular2/src/core/render/dom/events/event_manager';
+import {KeyEventsPlugin} from 'angular2/src/core/render/dom/events/key_events';
+import {HammerGesturesPlugin} from 'angular2/src/core/render/dom/events/hammer_gestures';
+import {ComponentRef} from 'angular2/src/core/linker/dynamic_component_loader';
+import {Testability} from 'angular2/src/core/testability/testability';
+import {Renderer} from 'angular2/src/core/render/api';
+import {DomRenderer, DomRenderer_, DOCUMENT} from 'angular2/src/core/render/render';
+import {
+ SharedStylesHost,
+ DomSharedStylesHost
+} from 'angular2/src/core/render/dom/shared_styles_host';
+import {EXCEPTION_PROVIDER} from './platform_bindings';
+import {AnimationBuilder} from 'angular2/src/animate/animation_builder';
+import {BrowserDetails} from 'angular2/src/animate/browser_details';
+import {wtfInit} from './profile/wtf_init';
+import {platformCommon, PlatformRef, applicationCommonProviders} from './application_ref';
+
+/**
+ * A default set of providers which apply only to an Angular application running on
+ * the UI thread.
+ */
+export function applicationDomProviders(): Array {
+ if (isBlank(DOM)) {
+ throw "Must set a root DOM adapter first.";
+ }
+ return [
+ provide(DOCUMENT, {useValue: DOM.defaultDoc()}),
+ EventManager,
+ new Provider(EVENT_MANAGER_PLUGINS, {useClass: DomEventsPlugin, multi: true}),
+ new Provider(EVENT_MANAGER_PLUGINS, {useClass: KeyEventsPlugin, multi: true}),
+ new Provider(EVENT_MANAGER_PLUGINS, {useClass: HammerGesturesPlugin, multi: true}),
+ provide(DomRenderer, {useClass: DomRenderer_}),
+ provide(Renderer, {useExisting: DomRenderer}),
+ DomSharedStylesHost,
+ provide(SharedStylesHost, {useExisting: DomSharedStylesHost}),
+ EXCEPTION_PROVIDER,
+ provide(XHR, {useValue: new XHRImpl()}),
+ Testability,
+ BrowserDetails,
+ AnimationBuilder,
+ FORM_PROVIDERS
+ ];
+}
+
+/**
+ * Initialize the Angular 'platform' on the page.
+ *
+ * See {@link PlatformRef} for details on the Angular platform.
+ *
+ *##Without specified providers
+ *
+ * If no providers are specified, `platform`'s behavior depends on whether an existing
+ * platform exists:
+ *
+ * If no platform exists, a new one will be created with the default {@link platformProviders}.
+ *
+ * If a platform already exists, it will be returned (regardless of what providers it
+ * was created with). This is a convenience feature, allowing for multiple applications
+ * to be loaded into the same platform without awareness of each other.
+ *
+ *##With specified providers
+ *
+ * It is also possible to specify providers to be made in the new platform. These providers
+ * will be shared between all applications on the page. For example, an abstraction for
+ * the browser cookie jar should be bound at the platform level, because there is only one
+ * cookie jar regardless of how many applications on the page will be accessing it.
+ *
+ * If providers are specified directly, `platform` will create the Angular platform with
+ * them if a platform did not exist already. If it did exist, however, an error will be
+ * thrown.
+ *
+ *##DOM Applications
+ *
+ * This version of `platform` initializes Angular to run in the UI thread, with direct
+ * DOM access. Web-worker applications should call `platform` from
+ * `src/web_workers/worker/application_common` instead.
+ */
+export function platform(providers?: Array): PlatformRef {
+ return platformCommon(providers, () => {
+ BrowserDomAdapter.makeCurrent();
+ wtfInit();
+ BrowserGetTestability.init();
+ });
+}
+
+/**
+ * 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 providers 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
+ * providers. 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',
+ * 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 an emulated or 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 providers 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 providers 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 ComponentRef}.
+ */
+export function commonBootstrap(
+ appComponentType: /*Type*/ any,
+ appProviders: Array = null): Promise {
+ var p = platform();
+ var bindings = [applicationCommonProviders(), applicationDomProviders()];
+ if (isPresent(appProviders)) {
+ bindings.push(appProviders);
+ }
+ return p.application(bindings).bootstrap(appComponentType);
+}
diff --git a/modules/angular2/src/core/application_common_providers.ts b/modules/angular2/src/core/application_common_providers.ts
deleted file mode 100644
index f766c2ee9d..0000000000
--- a/modules/angular2/src/core/application_common_providers.ts
+++ /dev/null
@@ -1,49 +0,0 @@
-import {Type, CONST_EXPR} from 'angular2/src/facade/lang';
-import {provide, Provider, Injector, OpaqueToken} from 'angular2/src/core/di';
-import {
- APP_COMPONENT_REF_PROMISE,
- APP_COMPONENT,
- APP_ID_RANDOM_PROVIDER
-} from './application_tokens';
-import {
- IterableDiffers,
- defaultIterableDiffers,
- KeyValueDiffers,
- defaultKeyValueDiffers
-} from './change_detection/change_detection';
-import {AppViewPool, APP_VIEW_POOL_CAPACITY} from './linker/view_pool';
-import {AppViewManager} from './linker/view_manager';
-import {AppViewManager_} from "./linker/view_manager";
-import {AppViewManagerUtils} from './linker/view_manager_utils';
-import {ViewResolver} from './linker/view_resolver';
-import {AppViewListener} from './linker/view_listener';
-import {ProtoViewFactory} from './linker/proto_view_factory';
-import {DirectiveResolver} from './linker/directive_resolver';
-import {PipeResolver} from './linker/pipe_resolver';
-import {Compiler} from './linker/compiler';
-import {Compiler_} from "./linker/compiler";
-import {DynamicComponentLoader} from './linker/dynamic_component_loader';
-import {DynamicComponentLoader_} from "./linker/dynamic_component_loader";
-import {EventManager} from './render/dom/events/event_manager';
-
-/**
- * A default set of providers which should be included in any Angular
- * application, regardless of the platform it runs onto.
- */
-export const APPLICATION_COMMON_PROVIDERS: Array = CONST_EXPR([
- new Provider(Compiler, {useClass: Compiler_}),
- APP_ID_RANDOM_PROVIDER,
- AppViewPool,
- new Provider(APP_VIEW_POOL_CAPACITY, {useValue: 10000}),
- new Provider(AppViewManager, {useClass: AppViewManager_}),
- AppViewManagerUtils,
- AppViewListener,
- ProtoViewFactory,
- ViewResolver,
- new Provider(IterableDiffers, {useValue: defaultIterableDiffers}),
- new Provider(KeyValueDiffers, {useValue: defaultKeyValueDiffers}),
- DirectiveResolver,
- PipeResolver,
- new Provider(DynamicComponentLoader, {useClass: DynamicComponentLoader_}),
- EventManager
-]);
\ No newline at end of file
diff --git a/modules/angular2/src/core/application_ref.ts b/modules/angular2/src/core/application_ref.ts
index 5b8b057ac7..aa7514b9a1 100644
--- a/modules/angular2/src/core/application_ref.ts
+++ b/modules/angular2/src/core/application_ref.ts
@@ -13,6 +13,7 @@ import {
ObservableWrapper
} from 'angular2/src/facade/async';
import {ListWrapper} from 'angular2/src/facade/collection';
+import {Reflector, reflector} from 'angular2/src/core/reflection/reflection';
import {TestabilityRegistry, Testability} from 'angular2/src/core/testability/testability';
import {
ComponentRef,
@@ -26,10 +27,39 @@ import {
} from 'angular2/src/facade/exceptions';
import {DOM} from 'angular2/src/core/dom/dom_adapter';
import {internalView} from 'angular2/src/core/linker/view_ref';
+import {
+ IterableDiffers,
+ defaultIterableDiffers,
+ KeyValueDiffers,
+ defaultKeyValueDiffers
+} from 'angular2/src/core/change_detection/change_detection';
+import {AppViewPool, APP_VIEW_POOL_CAPACITY} from 'angular2/src/core/linker/view_pool';
+import {AppViewManager} from 'angular2/src/core/linker/view_manager';
+import {AppViewManagerUtils} from 'angular2/src/core/linker/view_manager_utils';
+import {AppViewListener} from 'angular2/src/core/linker/view_listener';
+import {ProtoViewFactory} from './linker/proto_view_factory';
+import {ViewResolver} from './linker/view_resolver';
+import {DirectiveResolver} from './linker/directive_resolver';
+import {PipeResolver} from './linker/pipe_resolver';
+import {Compiler} from 'angular2/src/core/linker/compiler';
+import {DynamicComponentLoader_} from "./linker/dynamic_component_loader";
+import {AppViewManager_} from "./linker/view_manager";
+import {Compiler_} from "./linker/compiler";
import {wtfLeave, wtfCreateScope, WtfScopeFn} from './profile/profile';
import {ChangeDetectorRef} from 'angular2/src/core/change_detection/change_detector_ref';
+import {PLATFORM_DIRECTIVES, PLATFORM_PIPES} from "angular2/src/core/platform_directives_and_pipes";
import {lockDevMode} from 'angular2/src/facade/lang';
+import {COMMON_DIRECTIVES, COMMON_PIPES} from "angular2/common";
+/**
+ * Constructs the set of providers meant for use at the platform level.
+ *
+ * These are providers that should be singletons shared among all Angular applications
+ * running on the page.
+ */
+export function platformProviders(): Array {
+ return [provide(Reflector, {useValue: reflector}), TestabilityRegistry];
+}
/**
* Construct providers specific to an individual root component.
@@ -66,6 +96,31 @@ function _componentProviders(appComponentType: Type): Array {
+ return [
+ provide(Compiler, {useClass: Compiler_}),
+ APP_ID_RANDOM_PROVIDER,
+ AppViewPool,
+ provide(APP_VIEW_POOL_CAPACITY, {useValue: 10000}),
+ provide(AppViewManager, {useClass: AppViewManager_}),
+ AppViewManagerUtils,
+ AppViewListener,
+ ProtoViewFactory,
+ ViewResolver,
+ provide(IterableDiffers, {useValue: defaultIterableDiffers}),
+ provide(KeyValueDiffers, {useValue: defaultKeyValueDiffers}),
+ DirectiveResolver,
+ PipeResolver,
+ provide(PLATFORM_PIPES, {useValue: COMMON_PIPES, multi: true}),
+ provide(PLATFORM_DIRECTIVES, {useValue: COMMON_DIRECTIVES, multi: true}),
+ provide(DynamicComponentLoader, {useClass: DynamicComponentLoader_})
+ ];
+}
+
/**
* Create an Angular zone.
*/
@@ -74,41 +129,25 @@ export function createNgZone(): NgZone {
}
var _platform: PlatformRef;
-var _platformProviders: any[];
-/**
- * Initialize the Angular 'platform' on the page.
- *
- * See {@link PlatformRef} for details on the Angular platform.
- *
- * It is also possible to specify providers to be made in the new platform. These providers
- * will be shared between all applications on the page. For example, an abstraction for
- * the browser cookie jar should be bound at the platform level, because there is only one
- * cookie jar regardless of how many applications on the page will be accessing it.
- *
- * The platform function can be called multiple times as long as the same list of providers
- * is passed into each call. If the platform function is called with a different set of
- * provides, Angular will throw an exception.
- */
-export function platform(providers?: Array): PlatformRef {
+export function platformCommon(providers?: Array,
+ initializer?: () => void): PlatformRef {
lockDevMode();
if (isPresent(_platform)) {
- if (ListWrapper.equals(_platformProviders, providers)) {
+ if (isBlank(providers)) {
return _platform;
- } else {
- throw new BaseException("platform cannot be initialized with different sets of providers.");
}
- } else {
- return _createPlatform(providers);
+ throw "platform() can only be called once per page";
}
-}
-function _createPlatform(providers?: Array): PlatformRef {
- _platformProviders = providers;
- _platform = new PlatformRef_(Injector.resolveAndCreate(providers), () => {
- _platform = null;
- _platformProviders = null;
- });
+ if (isPresent(initializer)) {
+ initializer();
+ }
+
+ if (isBlank(providers)) {
+ providers = platformProviders();
+ }
+ _platform = new PlatformRef_(Injector.resolveAndCreate(providers), () => { _platform = null; });
return _platform;
}
@@ -153,7 +192,7 @@ export abstract class PlatformRef {
* var myAppProviders = [MyAppService];
*
* platform()
- * .application([myAppProviders])
+ * .application([applicationCommonProviders(), applicationDomProviders(), myAppProviders])
* .bootstrap(MyTopLevelComponent);
* ```
*##See Also
@@ -216,10 +255,8 @@ export class PlatformRef_ extends PlatformRef {
var injector: Injector;
var app: ApplicationRef;
zone.run(() => {
- providers = ListWrapper.concat(providers, [
- provide(NgZone, {useValue: zone}),
- provide(ApplicationRef, {useFactory: (): ApplicationRef => app, deps: []})
- ]);
+ providers.push(provide(NgZone, {useValue: zone}));
+ providers.push(provide(ApplicationRef, {useFactory: (): ApplicationRef => app, deps: []}));
var exceptionHandler;
try {
@@ -283,7 +320,7 @@ export abstract class ApplicationRef {
*
* ### Example
* ```
- * var app = platform.application([appProviders];
+ * var app = platform.application([applicationCommonProviders(), applicationDomProviders()];
* app.bootstrap(FirstRootComponent);
* app.bootstrap(SecondRootComponent, [provide(OverrideBinding, {useClass: OverriddenBinding})]);
* ```
diff --git a/modules/angular2/src/core/application_static.dart b/modules/angular2/src/core/application_static.dart
new file mode 100644
index 0000000000..fac49ccf1c
--- /dev/null
+++ b/modules/angular2/src/core/application_static.dart
@@ -0,0 +1,17 @@
+library angular2.src.core.application_static;
+
+import 'dart:async';
+import 'application_common.dart';
+import 'package:angular2/src/core/linker/dynamic_component_loader.dart'
+ show ComponentRef;
+
+/// Starts an application from a root component.
+///
+/// See [commonBootstrap] for detailed documentation.
+Future bootstrapStatic(Type appComponentType,
+ [List componentInjectableBindings, void initReflector()]) {
+ if (initReflector != null) {
+ initReflector();
+ }
+ return commonBootstrap(appComponentType, componentInjectableBindings);
+}
diff --git a/modules/angular2/src/core/bootstrap.dart b/modules/angular2/src/core/bootstrap.dart
new file mode 100644
index 0000000000..92eea16693
--- /dev/null
+++ b/modules/angular2/src/core/bootstrap.dart
@@ -0,0 +1,3 @@
+library angular2.src.core.bootstrap;
+
+export './application.dart' show bootstrap;
diff --git a/modules/angular2/src/core/bootstrap.ts b/modules/angular2/src/core/bootstrap.ts
new file mode 100644
index 0000000000..aec7fd2afe
--- /dev/null
+++ b/modules/angular2/src/core/bootstrap.ts
@@ -0,0 +1,4 @@
+// Note: This file only exists so that Dart users can import
+// bootstrap from angular2/bootstrap. JS users should import
+// from angular2/core.
+export {bootstrap} from './application';
diff --git a/modules/angular2/src/core/dom/generic_browser_adapter.ts b/modules/angular2/src/core/dom/generic_browser_adapter.ts
index 878c2a63d7..9460390b7f 100644
--- a/modules/angular2/src/core/dom/generic_browser_adapter.ts
+++ b/modules/angular2/src/core/dom/generic_browser_adapter.ts
@@ -1,7 +1,7 @@
import {ListWrapper, StringMapWrapper} from 'angular2/src/facade/collection';
import {isPresent, isFunction, Type} from 'angular2/src/facade/lang';
import {DomAdapter} from './dom_adapter';
-import {XHRImpl} from 'angular2/src/platform/browser/xhr_impl';
+import {XHRImpl} from 'angular2/src/compiler/xhr_impl';
/**
diff --git a/modules/angular2/src/core/platform_bindings.dart b/modules/angular2/src/core/platform_bindings.dart
new file mode 100644
index 0000000000..ff33b34fad
--- /dev/null
+++ b/modules/angular2/src/core/platform_bindings.dart
@@ -0,0 +1,12 @@
+library angular2.src.core.platform_bindings;
+
+import 'package:angular2/core.dart';
+import 'package:angular2/src/facade/exceptions.dart';
+import 'package:angular2/src/core/dom/dom_adapter.dart';
+
+exceptionFactory() => new ExceptionHandler(DOM, true);
+
+const EXCEPTION_PROVIDER = const Binding(ExceptionHandler,
+ toFactory: exceptionFactory, deps: const []);
+
+const EXCEPTION_BINDING = EXCEPTION_PROVIDER;
diff --git a/modules/angular2/src/core/platform_bindings.ts b/modules/angular2/src/core/platform_bindings.ts
new file mode 100644
index 0000000000..059df5a2bb
--- /dev/null
+++ b/modules/angular2/src/core/platform_bindings.ts
@@ -0,0 +1,8 @@
+import {provide} from 'angular2/src/core/di';
+import {ExceptionHandler} from 'angular2/src/facade/exceptions';
+import {DOM} from 'angular2/src/core/dom/dom_adapter';
+
+export const EXCEPTION_PROVIDER =
+ provide(ExceptionHandler, {useFactory: () => new ExceptionHandler(DOM, false), deps: []});
+
+export const EXCEPTION_BINDING = EXCEPTION_PROVIDER;
\ No newline at end of file
diff --git a/modules/angular2/src/core/platform_common_providers.ts b/modules/angular2/src/core/platform_common_providers.ts
deleted file mode 100644
index 14a84c1603..0000000000
--- a/modules/angular2/src/core/platform_common_providers.ts
+++ /dev/null
@@ -1,14 +0,0 @@
-import {Type, isBlank, isPresent, assertionsEnabled, CONST_EXPR} from 'angular2/src/facade/lang';
-import {provide, Provider, Injector, OpaqueToken} from 'angular2/src/core/di';
-import {Reflector, reflector} from './reflection/reflection';
-import {TestabilityRegistry} from 'angular2/src/core/testability/testability';
-
-function _reflector(): Reflector {
- return reflector;
-}
-
-/**
- * A default set of providers which should be included in any Angular platform.
- */
-export const PLATFORM_COMMON_PROVIDERS: Array =
- CONST_EXPR([new Provider(Reflector, {useFactory: _reflector, deps: []}), TestabilityRegistry]);
diff --git a/modules/angular2/src/platform/browser_common.ts b/modules/angular2/src/platform/browser_common.ts
deleted file mode 100644
index 2bccddf9ee..0000000000
--- a/modules/angular2/src/platform/browser_common.ts
+++ /dev/null
@@ -1,75 +0,0 @@
-import {CONST_EXPR} from 'angular2/src/facade/lang';
-import {provide, Provider, Injector, OpaqueToken} from 'angular2/src/core/di';
-
-import {XHR} from 'angular2/compiler';
-import {
- PLATFORM_DIRECTIVES,
- PLATFORM_PIPES,
- ComponentRef,
- platform,
- ExceptionHandler,
- Reflector,
- reflector,
- APPLICATION_COMMON_PROVIDERS,
- PLATFORM_COMMON_PROVIDERS
-} from "angular2/core";
-import {COMMON_DIRECTIVES, COMMON_PIPES, FORM_PROVIDERS} from "angular2/common";
-import {Renderer} from 'angular2/render';
-import {XHRImpl} from "angular2/src/platform/browser/xhr_impl";
-import {Testability} from 'angular2/src/core/testability/testability';
-
-// TODO change these imports once dom_adapter is moved out of core
-import {DOM} from 'angular2/src/core/dom/dom_adapter';
-import {
- DomEventsPlugin,
- EVENT_MANAGER_PLUGINS
-} from 'angular2/src/core/render/dom/events/event_manager';
-import {KeyEventsPlugin} from 'angular2/src/core/render/dom/events/key_events';
-import {HammerGesturesPlugin} from 'angular2/src/core/render/dom/events/hammer_gestures';
-import {DOCUMENT} from 'angular2/src/core/render/dom/dom_tokens';
-import {DomRenderer, DomRenderer_} from 'angular2/src/core/render/dom/dom_renderer';
-import {DomSharedStylesHost} from 'angular2/src/core/render/dom/shared_styles_host';
-import {SharedStylesHost} from "angular2/src/core/render/dom/shared_styles_host";
-import {BrowserDetails} from "angular2/src/animate/browser_details";
-import {AnimationBuilder} from "angular2/src/animate/animation_builder";
-import {BrowserDomAdapter} from 'angular2/src/core/dom/browser_adapter';
-import {BrowserGetTestability} from 'angular2/src/core/testability/browser_testability';
-import {wtfInit} from 'angular2/src/core/profile/wtf_init';
-
-export const BROWSER_PROVIDERS: Array =
- CONST_EXPR([PLATFORM_COMMON_PROVIDERS]);
-
-function _exceptionHandler(): ExceptionHandler {
- return new ExceptionHandler(DOM, false);
-}
-
-function _document(): any {
- return DOM.defaultDoc();
-}
-
-export const BROWSER_APP_COMMON_PROVIDERS: Array = CONST_EXPR([
- APPLICATION_COMMON_PROVIDERS,
- FORM_PROVIDERS,
- new Provider(PLATFORM_PIPES, {useValue: COMMON_PIPES, multi: true}),
- new Provider(PLATFORM_DIRECTIVES, {useValue: COMMON_DIRECTIVES, multi: true}),
- new Provider(ExceptionHandler, {useFactory: _exceptionHandler, deps: []}),
- new Provider(DOCUMENT, {useFactory: _document, deps: []}),
- new Provider(EVENT_MANAGER_PLUGINS, {useClass: DomEventsPlugin, multi: true}),
- new Provider(EVENT_MANAGER_PLUGINS, {useClass: KeyEventsPlugin, multi: true}),
- new Provider(EVENT_MANAGER_PLUGINS, {useClass: HammerGesturesPlugin, multi: true}),
- new Provider(DomRenderer, {useClass: DomRenderer_}),
- new Provider(Renderer, {useExisting: DomRenderer}),
- new Provider(SharedStylesHost, {useExisting: DomSharedStylesHost}),
- new Provider(XHR, {useClass: XHRImpl}),
- DomSharedStylesHost,
- Testability,
- BrowserDetails,
- AnimationBuilder
-]);
-
-export function initBrowser() {
- // TODO: refactor into a generic init function
- BrowserDomAdapter.makeCurrent();
- wtfInit();
- BrowserGetTestability.init();
-}
\ No newline at end of file
diff --git a/modules/angular2/src/testing/test_injector.ts b/modules/angular2/src/testing/test_injector.ts
index 1a05c952f1..2362cab53a 100644
--- a/modules/angular2/src/testing/test_injector.ts
+++ b/modules/angular2/src/testing/test_injector.ts
@@ -54,7 +54,7 @@ import {
import {APP_ID} from 'angular2/src/core/application_tokens';
import {Serializer} from "angular2/src/web_workers/shared/serializer";
import {Log} from './utils';
-import {COMPILER_PROVIDERS} from 'angular2/src/compiler/compiler';
+import {compilerProviders} from 'angular2/src/compiler/compiler';
import {DomRenderer_} from "angular2/src/core/render/dom/dom_renderer";
import {DynamicComponentLoader_} from "angular2/src/core/linker/dynamic_component_loader";
import {AppViewManager_} from "angular2/src/core/linker/view_manager";
@@ -88,7 +88,7 @@ function _getAppBindings() {
}
return [
- COMPILER_PROVIDERS,
+ compilerProviders(),
provide(ChangeDetectorGenConfig, {useValue: new ChangeDetectorGenConfig(true, false, true)}),
provide(DOCUMENT, {useValue: appDoc}),
provide(DomRenderer, {useClass: DomRenderer_}),
diff --git a/modules/angular2/src/upgrade/upgrade_adapter.ts b/modules/angular2/src/upgrade/upgrade_adapter.ts
index 59e9195339..ba20e1a35f 100644
--- a/modules/angular2/src/upgrade/upgrade_adapter.ts
+++ b/modules/angular2/src/upgrade/upgrade_adapter.ts
@@ -13,10 +13,10 @@ import {
Provider,
Type
} from 'angular2/angular2';
-import {APPLICATION_COMMON_PROVIDERS} from 'angular2/core';
-import {COMPILER_PROVIDERS} from 'angular2/src/compiler/compiler';
+import {applicationDomProviders} from 'angular2/src/core/application_common';
+import {applicationCommonProviders} from 'angular2/src/core/application_ref';
+import {compilerProviders} from 'angular2/src/compiler/compiler';
import {ObservableWrapper} from 'angular2/src/facade/async';
-import {BROWSER_PROVIDERS, BROWSER_APP_PROVIDERS} from 'angular2/platform/browser';
import {getComponentInfo, ComponentInfo} from './metadata';
import {onError, controllerKey} from './util';
@@ -296,9 +296,11 @@ export class UpgradeAdapter {
config?: angular.IAngularBootstrapConfig): UpgradeAdapterRef {
var upgrade = new UpgradeAdapterRef();
var ng1Injector: angular.IInjectorService = null;
- var platformRef: PlatformRef = platform(BROWSER_PROVIDERS);
+ var platformRef: PlatformRef = platform();
var applicationRef: ApplicationRef = platformRef.application([
- BROWSER_APP_PROVIDERS,
+ applicationCommonProviders(),
+ applicationDomProviders(),
+ compilerProviders(),
provide(NG1_INJECTOR, {useFactory: () => ng1Injector}),
provide(NG1_COMPILE, {useFactory: () => ng1Injector.get(NG1_COMPILE)}),
this.providers
diff --git a/modules/angular2/src/web_workers/ui/di_bindings.ts b/modules/angular2/src/web_workers/ui/di_bindings.ts
index abfee91c4c..801a7d284f 100644
--- a/modules/angular2/src/web_workers/ui/di_bindings.ts
+++ b/modules/angular2/src/web_workers/ui/di_bindings.ts
@@ -40,7 +40,7 @@ import {
import {UrlResolver} from 'angular2/src/compiler/url_resolver';
import {Testability} from 'angular2/src/core/testability/testability';
import {XHR} from 'angular2/src/compiler/xhr';
-import {XHRImpl} from 'angular2/src/platform/browser/xhr_impl';
+import {XHRImpl} from 'angular2/src/compiler/xhr_impl';
import {Serializer} from 'angular2/src/web_workers/shared/serializer';
import {ON_WEB_WORKER} from 'angular2/src/web_workers/shared/api';
import {RenderProtoViewRefStore} from 'angular2/src/web_workers/shared/render_proto_view_ref_store';
diff --git a/modules/angular2/src/web_workers/worker/application_common.ts b/modules/angular2/src/web_workers/worker/application_common.ts
index f6cdac9aa4..30b15f1ec9 100644
--- a/modules/angular2/src/web_workers/worker/application_common.ts
+++ b/modules/angular2/src/web_workers/worker/application_common.ts
@@ -26,12 +26,11 @@ import {
} from 'angular2/src/web_workers/shared/service_message_broker';
import {MessageBus} from 'angular2/src/web_workers/shared/message_bus';
import {
+ platformCommon,
PlatformRef,
ApplicationRef,
- APPLICATION_COMMON_PROVIDERS,
- PLATFORM_COMMON_PROVIDERS
-} from 'angular2/core';
-import * as core from 'angular2/core';
+ applicationCommonProviders
+} from 'angular2/src/core/application_ref';
import {Serializer} from "angular2/src/web_workers/shared/serializer";
import {ON_WEB_WORKER} from "angular2/src/web_workers/shared/api";
import {RenderProtoViewRefStore} from 'angular2/src/web_workers/shared/render_proto_view_ref_store';
@@ -43,7 +42,7 @@ import {SETUP_CHANNEL} from 'angular2/src/web_workers/shared/messaging_api';
import {WebWorkerEventDispatcher} from 'angular2/src/web_workers/worker/event_dispatcher';
import {ComponentRef} from 'angular2/src/core/linker/dynamic_component_loader';
import {NgZone} from 'angular2/src/core/zone/ng_zone';
-import {COMPILER_PROVIDERS} from 'angular2/src/compiler/compiler';
+import {compilerProviders} from 'angular2/src/compiler/compiler';
/**
* Initialize the Angular 'platform' on the page in a manner suitable for applications
@@ -74,17 +73,15 @@ import {COMPILER_PROVIDERS} from 'angular2/src/compiler/compiler';
* them if a platform did not exist already. If it did exist, however, an error will be
* thrown.
*
- *##For Web Worker Applications
+ *##For Web Worker Appplications
*
* This version of `platform` initializes Angular for use with applications
* that do not directly touch the DOM, such as applications which run in a
* web worker context. Applications that need direct access to the DOM should
* use `platform` from `core/application_common` instead.
*/
-export function platform(providers?: Array): PlatformRef {
- let platformProviders =
- isPresent(providers) ? [PLATFORM_COMMON_PROVIDERS, providers] : PLATFORM_COMMON_PROVIDERS;
- return core.platform(platformProviders);
+export function platform(bindings?: Array): PlatformRef {
+ return platformCommon(bindings);
}
class PrintLogger {
@@ -97,7 +94,7 @@ class PrintLogger {
function webWorkerProviders(appComponentType, bus: MessageBus,
initData: {[key: string]: any}): Array {
return [
- COMPILER_PROVIDERS,
+ compilerProviders(),
Serializer,
provide(MessageBus, {useValue: bus}),
provide(ClientMessageBrokerFactory, {useClass: ClientMessageBrokerFactory_}),
@@ -132,7 +129,7 @@ export function bootstrapWebWorkerCommon(
var emitter = bus.from(SETUP_CHANNEL);
subscription = ObservableWrapper.subscribe(emitter, (message: {[key: string]: any}) => {
var bindings =
- [APPLICATION_COMMON_PROVIDERS, webWorkerProviders(appComponentType, bus, message)];
+ [applicationCommonProviders(), webWorkerProviders(appComponentType, bus, message)];
if (isPresent(appProviders)) {
bindings.push(appProviders);
}
diff --git a/modules/angular2/test/platform/xhr_impl_spec.ts b/modules/angular2/test/compiler/xhr_impl_spec.ts
similarity index 94%
rename from modules/angular2/test/platform/xhr_impl_spec.ts
rename to modules/angular2/test/compiler/xhr_impl_spec.ts
index 91906410c0..3ac4283645 100644
--- a/modules/angular2/test/platform/xhr_impl_spec.ts
+++ b/modules/angular2/test/compiler/xhr_impl_spec.ts
@@ -10,7 +10,7 @@ import {
xit
} from 'angular2/testing_internal';
-import {XHRImpl} from 'angular2/src/platform/browser/xhr_impl';
+import {XHRImpl} from 'angular2/src/compiler/xhr_impl';
import {PromiseWrapper} from 'angular2/src/facade/async';
export function main() {
diff --git a/modules/angular2/test/platform/bootstrap_spec.ts b/modules/angular2/test/core/application_spec.ts
similarity index 93%
rename from modules/angular2/test/platform/bootstrap_spec.ts
rename to modules/angular2/test/core/application_spec.ts
index 09b01f2401..1ed6f3a5db 100644
--- a/modules/angular2/test/platform/bootstrap_spec.ts
+++ b/modules/angular2/test/core/application_spec.ts
@@ -11,10 +11,10 @@ import {
xit
} from 'angular2/testing_internal';
import {IS_DART, isPresent, stringify} from 'angular2/src/facade/lang';
-import {bootstrap} from 'angular2/platform/browser';
-import {ApplicationRef} from 'angular2/src/core/application_ref';
-import {Component, Directive, View, platform} from 'angular2/core';
-import {BROWSER_PROVIDERS, BROWSER_APP_PROVIDERS} from 'angular2/platform/browser';
+import {bootstrap} from 'angular2/bootstrap';
+import {platform, applicationDomProviders} from 'angular2/src/core/application_common';
+import {applicationCommonProviders, ApplicationRef} from 'angular2/src/core/application_ref';
+import {Component, Directive, View} from 'angular2/core';
import {DOM} from 'angular2/src/core/dom/dom_adapter';
import {DOCUMENT} from 'angular2/render';
import {PromiseWrapper} from 'angular2/src/facade/async';
@@ -22,6 +22,7 @@ import {provide, Inject, Injector} from 'angular2/core';
import {ExceptionHandler} from 'angular2/src/facade/exceptions';
import {Testability, TestabilityRegistry} from 'angular2/src/core/testability/testability';
import {ComponentRef_} from "angular2/src/core/linker/dynamic_component_loader";
+import {compilerProviders} from 'angular2/src/compiler/compiler';
@Component({selector: 'hello-app'})
@View({template: '{{greeting}} world!'})
@@ -162,10 +163,14 @@ export function main() {
async.done();
});
}));
-
it('should unregister change detectors when components are disposed',
inject([AsyncTestCompleter], (async) => {
- var app = platform(BROWSER_PROVIDERS).application([BROWSER_APP_PROVIDERS, testProviders]);
+ var app = platform().application([
+ applicationCommonProviders(),
+ applicationDomProviders(),
+ compilerProviders(),
+ testProviders
+ ]);
app.bootstrap(HelloRootCmp)
.then((ref) => {
ref.dispose();
diff --git a/modules/angular2/test/public_api_spec.ts b/modules/angular2/test/public_api_spec.ts
index 7b80767e6c..7b53f8df29 100644
--- a/modules/angular2/test/public_api_spec.ts
+++ b/modules/angular2/test/public_api_spec.ts
@@ -97,7 +97,6 @@ var NG_ALL = [
'ApplicationRef.injector:js',
'ApplicationRef.zone:js',
'ApplicationRef.componentTypes:js',
- 'APPLICATION_COMMON_PROVIDERS',
/*
Abstract methods
'ApplicationRef.bootstrap()',
@@ -127,8 +126,6 @@ var NG_ALL = [
'Binding.toClass',
'Binding.toFactory',
'Binding.toValue',
- 'BROWSER_APP_PROVIDERS',
- 'BROWSER_PROVIDERS',
'Provider',
'Provider.dependencies',
'Provider.multi',
@@ -1235,6 +1232,7 @@ var NG_ALL = [
'WrappedValue.wrapped=',
'WtfScopeFn:dart',
'ZeroArgFunction:dart',
+ 'applicationCommonProviders()',
'asNativeElements()',
'bind()',
'provide()',
@@ -1244,9 +1242,10 @@ var NG_ALL = [
'inspectElement()',
'inspectNativeElement()',
'platform():js',
+ 'platformProviders()',
+ 'platformCommon()',
'resolveForwardRef():js',
'wtfCreateScope():js',
- 'PLATFORM_COMMON_PROVIDERS',
'wtfCreateScope:dart',
'wtfEndTimeRange():js',
'wtfEndTimeRange:dart',
@@ -1273,7 +1272,6 @@ var NG_ALL = [
'OnInit:dart',
'PipeOnDestroy:dart',
'PipeTransform:dart',
- 'reflector',
'RenderBeginCmd:dart',
'RenderBeginCmd.isBound',
'RenderBeginCmd.ngContentIndex',
@@ -1349,54 +1347,6 @@ var NG_ALL = [
'Stream.toSet():dart',
'Stream.transform():dart',
'Stream.where():dart',
-
- "GetterFn:dart",
- "MethodFn:dart",
- "NoReflectionCapabilities:dart",
- "NoReflectionCapabilities.annotations():dart",
- "NoReflectionCapabilities.factory():dart",
- "NoReflectionCapabilities.getter():dart",
- "NoReflectionCapabilities.importUri():dart",
- "NoReflectionCapabilities.interfaces():dart",
- "NoReflectionCapabilities.isReflectionEnabled():dart",
- "NoReflectionCapabilities.method():dart",
- "NoReflectionCapabilities.moduleId():dart",
- "NoReflectionCapabilities.parameters():dart",
- "NoReflectionCapabilities.propMetadata():dart",
- "NoReflectionCapabilities.setter():dart",
- "PlatformReflectionCapabilities:dart",
- "ReflectionInfo:dart",
- "ReflectionInfo.annotations:dart",
- "ReflectionInfo.annotations=:dart",
- "ReflectionInfo.factory:dart",
- "ReflectionInfo.factory=:dart",
- "ReflectionInfo.interfaces:dart",
- "ReflectionInfo.interfaces=:dart",
- "ReflectionInfo.parameters:dart",
- "ReflectionInfo.parameters=:dart",
- "ReflectionInfo.propMetadata:dart",
- "ReflectionInfo.propMetadata=:dart",
- "Reflector:dart",
- "Reflector.annotations():dart",
- "Reflector.factory():dart",
- "Reflector.getter():dart",
- "Reflector.importUri():dart",
- "Reflector.interfaces():dart",
- "Reflector.isReflectionEnabled():dart",
- "Reflector.listUnusedKeys():dart",
- "Reflector.method():dart",
- "Reflector.parameters():dart",
- "Reflector.propMetadata():dart",
- "Reflector.reflectionCapabilities:dart",
- "Reflector.reflectionCapabilities=:dart",
- "Reflector.registerFunction():dart",
- "Reflector.registerGetters():dart",
- "Reflector.registerMethods():dart",
- "Reflector.registerSetters():dart",
- "Reflector.registerType():dart",
- "Reflector.setter():dart",
- "Reflector.trackUsage():dart",
- "SetterFn:dart"
];
var NG_UPGRADE = [
diff --git a/modules/angular2/test/testing/testing_public_spec.ts b/modules/angular2/test/testing/testing_public_spec.ts
index c517187faa..3d5ca49552 100644
--- a/modules/angular2/test/testing/testing_public_spec.ts
+++ b/modules/angular2/test/testing/testing_public_spec.ts
@@ -17,7 +17,7 @@ import {
import {Injectable, NgIf, bind} from 'angular2/core';
import {Directive, Component, View, ViewMetadata} from 'angular2/angular2';
import {XHR} from 'angular2/src/compiler/xhr';
-import {XHRImpl} from 'angular2/src/platform/browser/xhr_impl';
+import {XHRImpl} from 'angular2/src/compiler/xhr_impl';
// Services, and components for the tests.
diff --git a/tools/broccoli/html-replace/SCRIPTS.html b/tools/broccoli/html-replace/SCRIPTS.html
index 296b260221..6434c63eca 100644
--- a/tools/broccoli/html-replace/SCRIPTS.html
+++ b/tools/broccoli/html-replace/SCRIPTS.html
@@ -11,7 +11,6 @@
// not even be in src/*. Move them!
'angular2/src/testing/benchmark_util': {defaultExtension: 'js'},
'angular2/src/facade/browser': {defaultExtension: 'js'},
- 'angular2/bootstrap': {defaultExtension: 'js'},
}
});
diff --git a/tools/broccoli/html-replace/SCRIPTS_benchmarks.html b/tools/broccoli/html-replace/SCRIPTS_benchmarks.html
index a62d620412..66c7ebdd28 100644
--- a/tools/broccoli/html-replace/SCRIPTS_benchmarks.html
+++ b/tools/broccoli/html-replace/SCRIPTS_benchmarks.html
@@ -12,7 +12,6 @@
// not even be in src/*. Move them!
'angular2/src/testing/benchmark_util': {defaultExtension: 'js'},
'angular2/src/facade/browser': {defaultExtension: 'js'},
- 'angular2/bootstrap': {defaultExtension: 'js'},
}
});
diff --git a/tools/broccoli/trees/node_tree.ts b/tools/broccoli/trees/node_tree.ts
index 3ff5f7c1f8..5932608acb 100644
--- a/tools/broccoli/trees/node_tree.ts
+++ b/tools/broccoli/trees/node_tree.ts
@@ -24,7 +24,7 @@ module.exports = function makeNodeTree(destinationPath) {
'angular2/test/core/zone/**',
'angular2/test/testing/fake_async_spec.ts',
'angular2/test/testing/testing_public_spec.ts',
- 'angular2/test/platform/xhr_impl_spec.ts',
+ 'angular2/test/compiler/xhr_impl_spec.ts',
'angular2/test/common/forms/**',
'angular2/test/tools/tools_spec.ts',
'angular1_router/**',