Revert "feat(core): extract platforms out of core"
This reverts commit 3f4628c0b0
.
This commit is contained in:
parent
f80321fd26
commit
78280a48af
|
@ -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;
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
library angular2.bootstrap_static;
|
||||
|
||||
export 'src/core/application_static.dart';
|
|
@ -1,5 +0,0 @@
|
|||
/**
|
||||
* See {@link bootstrap} for more information.
|
||||
* @deprecated
|
||||
*/
|
||||
export {bootstrapStatic} from 'angular2/platform/browser_static';
|
|
@ -5,4 +5,3 @@
|
|||
*/
|
||||
export * from './src/compiler/url_resolver';
|
||||
export * from './src/compiler/xhr';
|
||||
export * from './src/compiler/compiler';
|
|
@ -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';
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// #docregion enableDevMode
|
||||
import {bootstrap, enableDevMode} from 'angular2/angular2';
|
||||
import {bootstrap, enableDevMode} from 'angular2/core';
|
||||
import {MyComponent} from 'my_component';
|
||||
|
||||
enableDevMode();
|
||||
|
|
|
@ -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<any /*Type | Provider | any[]*/> =
|
||||
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
|
||||
* <html>
|
||||
* <!-- load Angular script tags here. -->
|
||||
* <body>
|
||||
* <my-app>loading...</my-app>
|
||||
* </body>
|
||||
* </html>
|
||||
* ```
|
||||
*
|
||||
* 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<any /*Type | Provider | any[]*/>): Promise<ComponentRef> {
|
||||
reflector.reflectionCapabilities = new ReflectionCapabilities();
|
||||
initBrowser();
|
||||
|
||||
let appProviders =
|
||||
isPresent(customProviders) ? [BROWSER_APP_PROVIDERS, customProviders] : BROWSER_APP_PROVIDERS;
|
||||
return platform(BROWSER_PROVIDERS).application(appProviders).bootstrap(appComponentType);
|
||||
}
|
|
@ -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<any /*Type | Provider | any[]*/> =
|
||||
BROWSER_APP_COMMON_PROVIDERS;
|
||||
|
||||
/**
|
||||
* See {@link bootstrap} for more information.
|
||||
*/
|
||||
export function bootstrapStatic(appComponentType: Type,
|
||||
customProviders?: Array<any /*Type | Provider | any[]*/>,
|
||||
initReflector?: Function): Promise<ComponentRef> {
|
||||
initBrowser();
|
||||
if (isPresent(initReflector)) {
|
||||
initReflector();
|
||||
}
|
||||
|
||||
let appProviders =
|
||||
isPresent(customProviders) ? [BROWSER_APP_PROVIDERS, customProviders] : BROWSER_APP_PROVIDERS;
|
||||
return platform(BROWSER_PROVIDERS).application(appProviders).bootstrap(appComponentType);
|
||||
}
|
|
@ -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<Type | Provider | any[]> {
|
||||
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<Type | Provider | any[]> = 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
|
||||
]);
|
||||
|
|
|
@ -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 {
|
|
@ -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<string> {
|
|
@ -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<ComponentRef> bootstrap(Type appComponentType,
|
||||
[List componentInjectableProviders]) {
|
||||
reflector.reflectionCapabilities = new ReflectionCapabilities();
|
||||
var providers = [compilerProviders()];
|
||||
if (componentInjectableProviders != null) {
|
||||
providers.add(componentInjectableProviders);
|
||||
}
|
||||
return commonBootstrap(appComponentType, providers);
|
||||
}
|
|
@ -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<Type | Provider | any[]> = null): Promise<ComponentRef> {
|
||||
var providers = [compilerProviders()];
|
||||
if (isPresent(appProviders)) {
|
||||
providers.push(appProviders);
|
||||
}
|
||||
return commonBootstrap(appComponentType, providers);
|
||||
}
|
|
@ -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<Type | Provider | any[]> {
|
||||
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<Type | Provider | any[]>): 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
|
||||
* <html>
|
||||
* <!-- load Angular script tags here. -->
|
||||
* <body>
|
||||
* <my-app>loading...</my-app>
|
||||
* </body>
|
||||
* </html>
|
||||
* ```
|
||||
*
|
||||
* 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<Type | Provider | any[]> = null): Promise<ComponentRef> {
|
||||
var p = platform();
|
||||
var bindings = [applicationCommonProviders(), applicationDomProviders()];
|
||||
if (isPresent(appProviders)) {
|
||||
bindings.push(appProviders);
|
||||
}
|
||||
return p.application(bindings).bootstrap(appComponentType);
|
||||
}
|
|
@ -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<Type | Provider | any[]> = 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
|
||||
]);
|
|
@ -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<Type | Provider | any[]> {
|
||||
return [provide(Reflector, {useValue: reflector}), TestabilityRegistry];
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct providers specific to an individual root component.
|
||||
|
@ -66,6 +96,31 @@ function _componentProviders(appComponentType: Type): Array<Type | Provider | an
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a default set of providers which should be included in any Angular
|
||||
* application, regardless of whether it runs on the UI thread or in a web worker.
|
||||
*/
|
||||
export function applicationCommonProviders(): Array<Type | Provider | any[]> {
|
||||
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<Type | Provider | any[]>): PlatformRef {
|
||||
export function platformCommon(providers?: Array<Type | Provider | any[]>,
|
||||
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<Type | Provider | any[]>): 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})]);
|
||||
* ```
|
||||
|
|
|
@ -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<ComponentRef> bootstrapStatic(Type appComponentType,
|
||||
[List componentInjectableBindings, void initReflector()]) {
|
||||
if (initReflector != null) {
|
||||
initReflector();
|
||||
}
|
||||
return commonBootstrap(appComponentType, componentInjectableBindings);
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
library angular2.src.core.bootstrap;
|
||||
|
||||
export './application.dart' show bootstrap;
|
|
@ -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';
|
|
@ -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';
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -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;
|
|
@ -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;
|
|
@ -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<Type | Provider | any[]> =
|
||||
CONST_EXPR([new Provider(Reflector, {useFactory: _reflector, deps: []}), TestabilityRegistry]);
|
|
@ -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<any /*Type | Provider | any[]*/> =
|
||||
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<any /*Type | Provider | any[]*/> = 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();
|
||||
}
|
|
@ -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_}),
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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<Type | Provider | any[]>): PlatformRef {
|
||||
let platformProviders =
|
||||
isPresent(providers) ? [PLATFORM_COMMON_PROVIDERS, providers] : PLATFORM_COMMON_PROVIDERS;
|
||||
return core.platform(platformProviders);
|
||||
export function platform(bindings?: Array<Type | Provider | any[]>): PlatformRef {
|
||||
return platformCommon(bindings);
|
||||
}
|
||||
|
||||
class PrintLogger {
|
||||
|
@ -97,7 +94,7 @@ class PrintLogger {
|
|||
function webWorkerProviders(appComponentType, bus: MessageBus,
|
||||
initData: {[key: string]: any}): Array<Type | Provider | any[]> {
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -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() {
|
|
@ -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();
|
|
@ -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 = [
|
||||
|
|
|
@ -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.
|
||||
|
||||
|
|
|
@ -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'},
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -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'},
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -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/**',
|
||||
|
|
Loading…
Reference in New Issue