From 457c15cd6c941c996d79feb8256829cded9b2fc4 Mon Sep 17 00:00:00 2001 From: Rado Kirov Date: Mon, 4 May 2015 11:11:22 -0700 Subject: [PATCH] feat(decorators): adds decorator versions of DI annotations. In 'angular2/di' the symbol: - Inject is a decorator - InjectAnnotation is an annotation Internally one an get a hold of annotations without *Annotations appened (to make ts2dart work without workarounds) by importing from 'angular2/src/di/annotations_impl' instead of 'angular2/di'. This is needed only for users that transpile through TS and through ts2dart. --- modules/angular2/annotations.js | 2 +- modules/angular2/di.js | 3 ++- .../src/change_detection/change_detection.js | 3 +-- .../src/change_detection/parser/lexer.js | 2 +- .../src/change_detection/parser/parser.js | 2 +- .../change_detection/pipes/pipe_registry.js | 2 +- .../decorators.dart | 0 .../src/core/annotations/decorators.es6 | 23 ++++++++++++++++ .../src/core/annotations_impl/annotations.js | 2 +- .../angular2/src/core/annotations_impl/di.js | 2 +- .../src/core/annotations_impl/visibility.js | 2 +- modules/angular2/src/core/application.js | 2 +- .../angular2/src/core/compiler/compiler.js | 3 ++- .../src/core/compiler/component_url_mapper.js | 2 +- .../compiler/directive_metadata_reader.js | 3 ++- .../core/compiler/dynamic_component_loader.js | 3 ++- .../src/core/compiler/proto_view_factory.js | 5 ++-- .../src/core/compiler/template_resolver.js | 2 +- .../src/core/compiler/view_manager.js | 5 ++-- .../src/core/compiler/view_manager_utils.js | 5 ++-- .../angular2/src/core/compiler/view_pool.js | 5 ++-- .../angular2/src/core/exception_handler.js | 2 +- .../src/core/life_cycle/life_cycle.js | 2 +- .../src/core/testability/testability.js | 2 +- modules/angular2/src/di/annotations.dart | 3 +++ modules/angular2/src/di/annotations.es6 | 13 ++++++++++ .../{annotations.js => annotations_impl.js} | 0 modules/angular2/src/di/binding.js | 2 +- modules/angular2/src/di/decorators.dart | 3 +++ modules/angular2/src/di/decorators.es6 | 13 ++++++++++ modules/angular2/src/forms/directives.js | 2 +- .../src/render/dom/compiler/compiler.js | 2 +- .../render/dom/compiler/template_loader.js | 2 +- .../src/render/dom/direct_dom_renderer.js | 3 ++- .../render/dom/shadow_dom/style_inliner.js | 2 +- .../dom/shadow_dom/style_url_resolver.js | 2 +- .../src/render/dom/view/view_factory.js | 2 +- .../src/render/dom/view/view_hydrator.js | 2 +- modules/angular2/src/services/url_resolver.js | 2 +- modules/angular2/src/services/xhr_impl.es6 | 2 +- .../{core/decorators => util}/decorators.es6 | 26 ++----------------- .../angular2/test/core/application_spec.js | 3 ++- .../core/compiler/element_injector_spec.js | 3 ++- modules/angular2/test/di/async_spec.js | 3 ++- modules/angular2/test/di/injector_spec.js | 4 ++- .../angular2/test/forms/integration_spec.js | 2 +- .../test/transform/integration/all_tests.dart | 4 +-- .../src/components/radio/radio_button.js | 2 +- .../src/largetable/largetable_benchmark.js | 3 ++- .../examples/src/hello_world/index_common.js | 2 +- modules/examples/src/material/demo_common.js | 2 +- .../examples/src/todo/services/TodoStore.js | 2 +- 52 files changed, 121 insertions(+), 74 deletions(-) rename modules/angular2/src/core/{decorators => annotations}/decorators.dart (100%) create mode 100644 modules/angular2/src/core/annotations/decorators.es6 create mode 100644 modules/angular2/src/di/annotations.dart create mode 100644 modules/angular2/src/di/annotations.es6 rename modules/angular2/src/di/{annotations.js => annotations_impl.js} (100%) create mode 100644 modules/angular2/src/di/decorators.dart create mode 100644 modules/angular2/src/di/decorators.es6 rename modules/angular2/src/{core/decorators => util}/decorators.es6 (59%) diff --git a/modules/angular2/annotations.js b/modules/angular2/annotations.js index 5ac5df5b82..8b28ec370e 100644 --- a/modules/angular2/annotations.js +++ b/modules/angular2/annotations.js @@ -9,4 +9,4 @@ * */ export * from './src/core/annotations/annotations'; -export * from './src/core/decorators/decorators'; +export * from './src/core/annotations/decorators'; diff --git a/modules/angular2/di.js b/modules/angular2/di.js index 63a7eea84d..430a9e2f1a 100644 --- a/modules/angular2/di.js +++ b/modules/angular2/di.js @@ -5,7 +5,8 @@ * The `di` module provides dependency injection container services. */ -export {Inject, InjectPromise, InjectLazy, Injectable, Optional, DependencyAnnotation} from './src/di/annotations'; +export * from './src/di/annotations'; +export * from './src/di/decorators'; export {Injector} from './src/di/injector'; export {Binding, ResolvedBinding, Dependency, bind} from './src/di/binding'; export {Key, KeyRegistry} from './src/di/key'; diff --git a/modules/angular2/src/change_detection/change_detection.js b/modules/angular2/src/change_detection/change_detection.js index ae2562222b..e54a0b7301 100644 --- a/modules/angular2/src/change_detection/change_detection.js +++ b/modules/angular2/src/change_detection/change_detection.js @@ -8,10 +8,9 @@ import {BindingRecord} from './binding_record'; import {DirectiveRecord} from './directive_record'; import {DEFAULT} from './constants'; import {ChangeDetection, ProtoChangeDetector} from './interfaces'; -import {Injectable} from 'angular2/di'; +import {Injectable} from 'angular2/src/di/annotations_impl'; import {List} from 'angular2/src/facade/collection'; - /** * Structural diffing for `Object`s and `Map`s. * diff --git a/modules/angular2/src/change_detection/parser/lexer.js b/modules/angular2/src/change_detection/parser/lexer.js index 94ab81de44..f445a7210e 100644 --- a/modules/angular2/src/change_detection/parser/lexer.js +++ b/modules/angular2/src/change_detection/parser/lexer.js @@ -1,4 +1,4 @@ -import {Injectable} from 'angular2/di'; +import {Injectable} from 'angular2/src/di/annotations_impl'; import {List, ListWrapper, SetWrapper} from "angular2/src/facade/collection"; import {int, NumberWrapper, StringJoiner, StringWrapper} from "angular2/src/facade/lang"; diff --git a/modules/angular2/src/change_detection/parser/parser.js b/modules/angular2/src/change_detection/parser/parser.js index a64382d4d6..41693f78a8 100644 --- a/modules/angular2/src/change_detection/parser/parser.js +++ b/modules/angular2/src/change_detection/parser/parser.js @@ -1,4 +1,4 @@ -import {Injectable} from 'angular2/di'; +import {Injectable} from 'angular2/src/di/annotations_impl'; import {int, isBlank, isPresent, BaseException, StringWrapper, RegExpWrapper} from 'angular2/src/facade/lang'; import {ListWrapper, List} from 'angular2/src/facade/collection'; import {Lexer, EOF, Token, $PERIOD, $COLON, $SEMICOLON, $LBRACKET, $RBRACKET, diff --git a/modules/angular2/src/change_detection/pipes/pipe_registry.js b/modules/angular2/src/change_detection/pipes/pipe_registry.js index e64da907f6..f0f5a6df0d 100644 --- a/modules/angular2/src/change_detection/pipes/pipe_registry.js +++ b/modules/angular2/src/change_detection/pipes/pipe_registry.js @@ -1,7 +1,7 @@ import {List, ListWrapper} from 'angular2/src/facade/collection'; import {isBlank, isPresent, BaseException, CONST} from 'angular2/src/facade/lang'; import {Pipe} from './pipe'; -import {Injectable} from 'angular2/di'; +import {Injectable} from 'angular2/src/di/annotations_impl'; import {ChangeDetectorRef} from '../change_detector_ref'; @Injectable() diff --git a/modules/angular2/src/core/decorators/decorators.dart b/modules/angular2/src/core/annotations/decorators.dart similarity index 100% rename from modules/angular2/src/core/decorators/decorators.dart rename to modules/angular2/src/core/annotations/decorators.dart diff --git a/modules/angular2/src/core/annotations/decorators.es6 b/modules/angular2/src/core/annotations/decorators.es6 new file mode 100644 index 0000000000..d27e337257 --- /dev/null +++ b/modules/angular2/src/core/annotations/decorators.es6 @@ -0,0 +1,23 @@ +import { + ComponentAnnotation, + DirectiveAnnotation +} from './annotations'; +import {ViewAnnotation} from './view'; +import {AncestorAnnotation, ParentAnnotation} from './visibility'; +import {AttributeAnnotation, QueryAnnotation} from './di'; +import {makeDecorator, makeParamDecorator} from '../../util/decorators'; + +/* from annotations */ +export var Component = makeDecorator(ComponentAnnotation); +export var Decorator = makeDecorator(DirectiveAnnotation); + +/* from view */ +export var View = makeDecorator(ViewAnnotation); + +/* from visibility */ +export var Ancestor = makeParamDecorator(AncestorAnnotation); +export var Parent = makeParamDecorator(ParentAnnotation); + +/* from di */ +export var Attribute = makeParamDecorator(AttributeAnnotation); +export var Query = makeParamDecorator(QueryAnnotation); diff --git a/modules/angular2/src/core/annotations_impl/annotations.js b/modules/angular2/src/core/annotations_impl/annotations.js index 8f9423b968..c944a682bd 100644 --- a/modules/angular2/src/core/annotations_impl/annotations.js +++ b/modules/angular2/src/core/annotations_impl/annotations.js @@ -1,6 +1,6 @@ import {CONST, normalizeBlank, isPresent} from 'angular2/src/facade/lang'; import {ListWrapper, List} from 'angular2/src/facade/collection'; -import {Injectable} from 'angular2/di'; +import {Injectable} from 'angular2/src/di/annotations_impl'; import {DEFAULT} from 'angular2/change_detection'; // type StringMap = {[idx: string]: string}; diff --git a/modules/angular2/src/core/annotations_impl/di.js b/modules/angular2/src/core/annotations_impl/di.js index 0b06ffe79d..14925b9c02 100644 --- a/modules/angular2/src/core/annotations_impl/di.js +++ b/modules/angular2/src/core/annotations_impl/di.js @@ -1,5 +1,5 @@ import {CONST} from 'angular2/src/facade/lang'; -import {DependencyAnnotation} from 'angular2/di'; +import {DependencyAnnotation} from 'angular2/src/di/annotations_impl'; /** * Specifies that a constant attribute value should be injected. diff --git a/modules/angular2/src/core/annotations_impl/visibility.js b/modules/angular2/src/core/annotations_impl/visibility.js index d807ece07a..10f47a5233 100644 --- a/modules/angular2/src/core/annotations_impl/visibility.js +++ b/modules/angular2/src/core/annotations_impl/visibility.js @@ -1,5 +1,5 @@ import {CONST} from 'angular2/src/facade/lang'; -import {DependencyAnnotation} from 'angular2/di'; +import {DependencyAnnotation} from 'angular2/src/di/annotations_impl'; /** * Specifies that an injector should retrieve a dependency from the direct parent. diff --git a/modules/angular2/src/core/application.js b/modules/angular2/src/core/application.js index af4c949068..499854525f 100644 --- a/modules/angular2/src/core/application.js +++ b/modules/angular2/src/core/application.js @@ -1,4 +1,4 @@ -import {Injector, bind, OpaqueToken, Optional} from 'angular2/di'; +import {Injector, bind, OpaqueToken} from 'angular2/di'; import {NumberWrapper, Type, isBlank, isPresent, BaseException, assertionsEnabled, print, stringify} from 'angular2/src/facade/lang'; import {BrowserDomAdapter} from 'angular2/src/dom/browser_adapter'; diff --git a/modules/angular2/src/core/compiler/compiler.js b/modules/angular2/src/core/compiler/compiler.js index 117808f42b..c8eb4f8ac1 100644 --- a/modules/angular2/src/core/compiler/compiler.js +++ b/modules/angular2/src/core/compiler/compiler.js @@ -1,4 +1,5 @@ -import {Injectable, Binding} from 'angular2/di'; +import {Binding} from 'angular2/di'; +import {Injectable} from 'angular2/src/di/annotations_impl'; import {Type, isBlank, isPresent, BaseException, normalizeBlank, stringify} from 'angular2/src/facade/lang'; import {Promise, PromiseWrapper} from 'angular2/src/facade/async'; import {List, ListWrapper, Map, MapWrapper} from 'angular2/src/facade/collection'; diff --git a/modules/angular2/src/core/compiler/component_url_mapper.js b/modules/angular2/src/core/compiler/component_url_mapper.js index 445cdff489..b0b282a3ea 100644 --- a/modules/angular2/src/core/compiler/component_url_mapper.js +++ b/modules/angular2/src/core/compiler/component_url_mapper.js @@ -1,4 +1,4 @@ -import {Injectable} from 'angular2/di'; +import {Injectable} from 'angular2/src/di/annotations_impl'; import {Type, isPresent} from 'angular2/src/facade/lang'; import {Map, MapWrapper} from 'angular2/src/facade/collection'; diff --git a/modules/angular2/src/core/compiler/directive_metadata_reader.js b/modules/angular2/src/core/compiler/directive_metadata_reader.js index e3d166dfef..807429d4e0 100644 --- a/modules/angular2/src/core/compiler/directive_metadata_reader.js +++ b/modules/angular2/src/core/compiler/directive_metadata_reader.js @@ -1,4 +1,5 @@ -import {Injectable, Injector} from 'angular2/di'; +import {Injector} from 'angular2/di'; +import {Injectable} from 'angular2/src/di/annotations_impl'; import {Type, isPresent, BaseException, stringify} from 'angular2/src/facade/lang'; import {Directive, Component} from '../annotations_impl/annotations'; import {DirectiveMetadata} from './directive_metadata'; diff --git a/modules/angular2/src/core/compiler/dynamic_component_loader.js b/modules/angular2/src/core/compiler/dynamic_component_loader.js index 879bca8665..0fa7c8aaa6 100644 --- a/modules/angular2/src/core/compiler/dynamic_component_loader.js +++ b/modules/angular2/src/core/compiler/dynamic_component_loader.js @@ -1,4 +1,5 @@ -import {Key, Injector, Injectable, ResolvedBinding, Binding, bind} from 'angular2/di' +import {Key, Injector, ResolvedBinding, Binding, bind} from 'angular2/di' +import {Injectable} from 'angular2/src/di/annotations_impl'; import {Compiler} from './compiler'; import {Type, BaseException, stringify, isPresent} from 'angular2/src/facade/lang'; import {Promise} from 'angular2/src/facade/async'; diff --git a/modules/angular2/src/core/compiler/proto_view_factory.js b/modules/angular2/src/core/compiler/proto_view_factory.js index b39560cbfe..506fd0c194 100644 --- a/modules/angular2/src/core/compiler/proto_view_factory.js +++ b/modules/angular2/src/core/compiler/proto_view_factory.js @@ -1,4 +1,5 @@ -import {Injectable} from 'angular2/di'; +import {Injectable} from 'angular2/src/di/annotations_impl'; + import {List, ListWrapper, MapWrapper} from 'angular2/src/facade/collection'; import {isPresent, isBlank} from 'angular2/src/facade/lang'; import {reflector} from 'angular2/src/reflection/reflection'; @@ -29,7 +30,7 @@ class BindingRecordsCreator { bindings = ListWrapper.concat(bindings, this._createElementPropertyRecords(boundElementIndex, renderElementBinder)); bindings = ListWrapper.concat(bindings, this._createDirectiveRecords(boundElementIndex, sortedDirectives[boundElementIndex])); } - + return bindings; } diff --git a/modules/angular2/src/core/compiler/template_resolver.js b/modules/angular2/src/core/compiler/template_resolver.js index d0a055d7ee..c7f38faedf 100644 --- a/modules/angular2/src/core/compiler/template_resolver.js +++ b/modules/angular2/src/core/compiler/template_resolver.js @@ -1,4 +1,4 @@ -import {Injectable} from 'angular2/di'; +import {Injectable} from 'angular2/src/di/annotations_impl'; import {View} from 'angular2/src/core/annotations_impl/view'; import {Type, stringify, isBlank, BaseException} from 'angular2/src/facade/lang'; diff --git a/modules/angular2/src/core/compiler/view_manager.js b/modules/angular2/src/core/compiler/view_manager.js index 787d51b1b0..bf7b05df0f 100644 --- a/modules/angular2/src/core/compiler/view_manager.js +++ b/modules/angular2/src/core/compiler/view_manager.js @@ -1,4 +1,5 @@ -import {Injector, Injectable, Binding} from 'angular2/di'; +import {Injector, Binding} from 'angular2/di'; +import {Injectable} from 'angular2/src/di/annotations_impl'; import {ListWrapper, MapWrapper, Map, StringMapWrapper, List} from 'angular2/src/facade/collection'; import {isPresent, isBlank, BaseException} from 'angular2/src/facade/lang'; import * as viewModule from './view'; @@ -216,4 +217,4 @@ export class AppViewManager { } view.render = null; } -} \ No newline at end of file +} diff --git a/modules/angular2/src/core/compiler/view_manager_utils.js b/modules/angular2/src/core/compiler/view_manager_utils.js index e421130b35..7e64b7af8d 100644 --- a/modules/angular2/src/core/compiler/view_manager_utils.js +++ b/modules/angular2/src/core/compiler/view_manager_utils.js @@ -1,4 +1,5 @@ -import {Injectable, Injector, Binding} from 'angular2/di'; +import {Injector, Binding} from 'angular2/di'; +import {Injectable} from 'angular2/src/di/annotations_impl'; import {ListWrapper, MapWrapper, Map, StringMapWrapper, List} from 'angular2/src/facade/collection'; import * as eli from './element_injector'; import {isPresent, isBlank, BaseException} from 'angular2/src/facade/lang'; @@ -241,4 +242,4 @@ export class AppViewManagerUtils { view.changeDetector.dehydrate(); } -} \ No newline at end of file +} diff --git a/modules/angular2/src/core/compiler/view_pool.js b/modules/angular2/src/core/compiler/view_pool.js index df21776cd4..a6850e90c4 100644 --- a/modules/angular2/src/core/compiler/view_pool.js +++ b/modules/angular2/src/core/compiler/view_pool.js @@ -1,4 +1,5 @@ -import {Inject, OpaqueToken} from 'angular2/di'; +import {Inject} from 'angular2/src/di/annotations_impl'; + import {ListWrapper, MapWrapper, Map, List} from 'angular2/src/facade/collection'; import {isPresent, isBlank} from 'angular2/src/facade/lang'; @@ -37,4 +38,4 @@ export class AppViewPool { } } -} \ No newline at end of file +} diff --git a/modules/angular2/src/core/exception_handler.js b/modules/angular2/src/core/exception_handler.js index 9b5b61c953..06c5a49658 100644 --- a/modules/angular2/src/core/exception_handler.js +++ b/modules/angular2/src/core/exception_handler.js @@ -1,4 +1,4 @@ -import {Injectable} from 'angular2/di'; +import {Injectable} from 'angular2/src/di/annotations_impl'; import {isPresent, print} from 'angular2/src/facade/lang'; import {ListWrapper, isListLikeIterable} from 'angular2/src/facade/collection'; import {DOM} from 'angular2/src/dom/dom_adapter'; diff --git a/modules/angular2/src/core/life_cycle/life_cycle.js b/modules/angular2/src/core/life_cycle/life_cycle.js index bb67652643..982a1ea01d 100644 --- a/modules/angular2/src/core/life_cycle/life_cycle.js +++ b/modules/angular2/src/core/life_cycle/life_cycle.js @@ -1,4 +1,4 @@ -import {Injectable} from 'angular2/di'; +import {Injectable} from 'angular2/src/di/annotations_impl'; import {ChangeDetector} from 'angular2/change_detection'; import {VmTurnZone} from 'angular2/src/core/zone/vm_turn_zone'; import {ExceptionHandler} from 'angular2/src/core/exception_handler'; diff --git a/modules/angular2/src/core/testability/testability.js b/modules/angular2/src/core/testability/testability.js index f04f154e6a..d919feac40 100644 --- a/modules/angular2/src/core/testability/testability.js +++ b/modules/angular2/src/core/testability/testability.js @@ -1,4 +1,4 @@ -import {Injectable} from 'angular2/di'; +import {Injectable} from 'angular2/src/di/annotations_impl'; import {DOM} from 'angular2/src/dom/dom_adapter'; import {Map, MapWrapper, List, ListWrapper} from 'angular2/src/facade/collection'; import {StringWrapper, isBlank, BaseException} from 'angular2/src/facade/lang'; diff --git a/modules/angular2/src/di/annotations.dart b/modules/angular2/src/di/annotations.dart new file mode 100644 index 0000000000..b019ea5ff3 --- /dev/null +++ b/modules/angular2/src/di/annotations.dart @@ -0,0 +1,3 @@ +library angular2.di.annotations; + +export './annotations_impl.dart'; diff --git a/modules/angular2/src/di/annotations.es6 b/modules/angular2/src/di/annotations.es6 new file mode 100644 index 0000000000..f91285082a --- /dev/null +++ b/modules/angular2/src/di/annotations.es6 @@ -0,0 +1,13 @@ +/** + * This indirection is needed to free up Component, etc symbols in the public API + * to be used by the decorator versions of these annotations. + */ + +export { + Inject as InjectAnnotation, + InjectPromise as InjectPromiseAnnotation, + InjectLazy as InjectLazyAnnotation, + Optional as OptionalAnnotation, + Injectable as InjectableAnnotation, + DependencyAnnotation, // abstract base class, does not need a decorator + } from './annotations_impl'; diff --git a/modules/angular2/src/di/annotations.js b/modules/angular2/src/di/annotations_impl.js similarity index 100% rename from modules/angular2/src/di/annotations.js rename to modules/angular2/src/di/annotations_impl.js diff --git a/modules/angular2/src/di/binding.js b/modules/angular2/src/di/binding.js index cc77857803..8478fd9736 100644 --- a/modules/angular2/src/di/binding.js +++ b/modules/angular2/src/di/binding.js @@ -2,7 +2,7 @@ import {Type, isBlank, isPresent, CONST} from 'angular2/src/facade/lang'; import {List, MapWrapper, ListWrapper} from 'angular2/src/facade/collection'; import {reflector} from 'angular2/src/reflection/reflection'; import {Key} from './key'; -import {Inject, InjectLazy, InjectPromise, Optional, DependencyAnnotation} from './annotations'; +import {Inject, InjectLazy, InjectPromise, Optional, DependencyAnnotation} from './annotations_impl'; import {NoAnnotationError} from './exceptions'; /** diff --git a/modules/angular2/src/di/decorators.dart b/modules/angular2/src/di/decorators.dart new file mode 100644 index 0000000000..d3de503bf6 --- /dev/null +++ b/modules/angular2/src/di/decorators.dart @@ -0,0 +1,3 @@ +library angular2.di.decorators; + +/* This file is empty because, Dart does not have decorators. */ diff --git a/modules/angular2/src/di/decorators.es6 b/modules/angular2/src/di/decorators.es6 new file mode 100644 index 0000000000..87bef2f5d9 --- /dev/null +++ b/modules/angular2/src/di/decorators.es6 @@ -0,0 +1,13 @@ +import { + InjectAnnotation, + InjectPromiseAnnotation, + InjectLazyAnnotation, + OptionalAnnotation, + InjectableAnnotation} from './annotations'; +import {makeDecorator, makeParamDecorator} from '../util/decorators'; + +export var Inject = makeParamDecorator(InjectAnnotation); +export var InjectPromise = makeParamDecorator(InjectPromiseAnnotation); +export var InjectLazy = makeParamDecorator(InjectLazyAnnotation); +export var Optional = makeParamDecorator(OptionalAnnotation); +export var Injectable = makeDecorator(InjectableAnnotation); diff --git a/modules/angular2/src/forms/directives.js b/modules/angular2/src/forms/directives.js index e71fb5f0ff..fd58ad527e 100644 --- a/modules/angular2/src/forms/directives.js +++ b/modules/angular2/src/forms/directives.js @@ -1,7 +1,7 @@ import {Directive, onChange} from 'angular2/src/core/annotations_impl/annotations'; import {Ancestor} from 'angular2/src/core/annotations_impl/visibility'; import {ElementRef} from 'angular2/src/core/compiler/element_ref'; -import {Optional} from 'angular2/di'; +import {Optional} from 'angular2/src/di/annotations_impl'; import {Renderer} from 'angular2/src/render/api'; import {isPresent, isString} from 'angular2/src/facade/lang'; import {ListWrapper} from 'angular2/src/facade/collection'; diff --git a/modules/angular2/src/render/dom/compiler/compiler.js b/modules/angular2/src/render/dom/compiler/compiler.js index dc09b9e048..c33daebf75 100644 --- a/modules/angular2/src/render/dom/compiler/compiler.js +++ b/modules/angular2/src/render/dom/compiler/compiler.js @@ -1,4 +1,4 @@ -import {Injectable} from 'angular2/di'; +import {Injectable} from 'angular2/src/di/annotations_impl'; import {PromiseWrapper, Promise} from 'angular2/src/facade/async'; import {BaseException} from 'angular2/src/facade/lang'; diff --git a/modules/angular2/src/render/dom/compiler/template_loader.js b/modules/angular2/src/render/dom/compiler/template_loader.js index 5a57615b07..1894c31956 100644 --- a/modules/angular2/src/render/dom/compiler/template_loader.js +++ b/modules/angular2/src/render/dom/compiler/template_loader.js @@ -1,4 +1,4 @@ -import {Injectable} from 'angular2/di'; +import {Injectable} from 'angular2/src/di/annotations_impl'; import {isBlank, isPresent, BaseException, stringify} from 'angular2/src/facade/lang'; import {Map, MapWrapper, StringMapWrapper, StringMap} from 'angular2/src/facade/collection'; import {PromiseWrapper, Promise} from 'angular2/src/facade/async'; diff --git a/modules/angular2/src/render/dom/direct_dom_renderer.js b/modules/angular2/src/render/dom/direct_dom_renderer.js index 132a147d0c..3bb680342c 100644 --- a/modules/angular2/src/render/dom/direct_dom_renderer.js +++ b/modules/angular2/src/render/dom/direct_dom_renderer.js @@ -1,4 +1,5 @@ -import {Injectable} from 'angular2/di'; +import {Injectable} from 'angular2/src/di/annotations_impl'; + import {Promise, PromiseWrapper} from 'angular2/src/facade/async'; import {List, ListWrapper} from 'angular2/src/facade/collection'; import {isBlank, isPresent, BaseException} from 'angular2/src/facade/lang'; diff --git a/modules/angular2/src/render/dom/shadow_dom/style_inliner.js b/modules/angular2/src/render/dom/shadow_dom/style_inliner.js index 24b7faf3be..015bdedbbc 100644 --- a/modules/angular2/src/render/dom/shadow_dom/style_inliner.js +++ b/modules/angular2/src/render/dom/shadow_dom/style_inliner.js @@ -1,4 +1,4 @@ -import {Injectable} from 'angular2/di'; +import {Injectable} from 'angular2/src/di/annotations_impl'; import {XHR} from 'angular2/src/services/xhr'; import {ListWrapper} from 'angular2/src/facade/collection'; diff --git a/modules/angular2/src/render/dom/shadow_dom/style_url_resolver.js b/modules/angular2/src/render/dom/shadow_dom/style_url_resolver.js index 93a1ad4891..33328d0afa 100644 --- a/modules/angular2/src/render/dom/shadow_dom/style_url_resolver.js +++ b/modules/angular2/src/render/dom/shadow_dom/style_url_resolver.js @@ -1,7 +1,7 @@ // Some of the code comes from WebComponents.JS // https://github.com/webcomponents/webcomponentsjs/blob/master/src/HTMLImports/path.js -import {Injectable} from 'angular2/di'; +import {Injectable} from 'angular2/src/di/annotations_impl'; import {RegExp, RegExpWrapper, StringWrapper} from 'angular2/src/facade/lang'; import {UrlResolver} from 'angular2/src/services/url_resolver'; diff --git a/modules/angular2/src/render/dom/view/view_factory.js b/modules/angular2/src/render/dom/view/view_factory.js index 2fc92a4d3c..cbedd877d3 100644 --- a/modules/angular2/src/render/dom/view/view_factory.js +++ b/modules/angular2/src/render/dom/view/view_factory.js @@ -1,4 +1,4 @@ -import {OpaqueToken, Inject, Injectable} from 'angular2/di'; +import {Inject, Injectable} from 'angular2/src/di/annotations_impl'; import {int, isPresent, isBlank, BaseException} from 'angular2/src/facade/lang'; import {ListWrapper, MapWrapper, Map, StringMapWrapper, List} from 'angular2/src/facade/collection'; diff --git a/modules/angular2/src/render/dom/view/view_hydrator.js b/modules/angular2/src/render/dom/view/view_hydrator.js index c9beb84131..45cad95bb7 100644 --- a/modules/angular2/src/render/dom/view/view_hydrator.js +++ b/modules/angular2/src/render/dom/view/view_hydrator.js @@ -1,4 +1,4 @@ -import {Injectable} from 'angular2/di'; +import {Injectable} from 'angular2/src/di/annotations_impl'; import {int, isPresent, isBlank, BaseException} from 'angular2/src/facade/lang'; import {ListWrapper, MapWrapper, Map, StringMapWrapper, List} from 'angular2/src/facade/collection'; diff --git a/modules/angular2/src/services/url_resolver.js b/modules/angular2/src/services/url_resolver.js index b93640a349..2726df7fda 100644 --- a/modules/angular2/src/services/url_resolver.js +++ b/modules/angular2/src/services/url_resolver.js @@ -1,4 +1,4 @@ -import {Injectable} from 'angular2/di'; +import {Injectable} from 'angular2/src/di/annotations_impl'; import {isPresent, isBlank, RegExpWrapper, BaseException} from 'angular2/src/facade/lang'; import {DOM} from 'angular2/src/dom/dom_adapter'; diff --git a/modules/angular2/src/services/xhr_impl.es6 b/modules/angular2/src/services/xhr_impl.es6 index ca82eb1c6d..bbc756e661 100644 --- a/modules/angular2/src/services/xhr_impl.es6 +++ b/modules/angular2/src/services/xhr_impl.es6 @@ -1,4 +1,4 @@ -import {Injectable} from 'angular2/di'; +import {Injectable} from 'angular2/src/di/annotations_impl'; import {Promise, PromiseWrapper} from 'angular2/src/facade/async'; import {XHR} from './xhr'; diff --git a/modules/angular2/src/core/decorators/decorators.es6 b/modules/angular2/src/util/decorators.es6 similarity index 59% rename from modules/angular2/src/core/decorators/decorators.es6 rename to modules/angular2/src/util/decorators.es6 index e049c3e90c..cd161762d6 100644 --- a/modules/angular2/src/core/decorators/decorators.es6 +++ b/modules/angular2/src/util/decorators.es6 @@ -1,13 +1,6 @@ -import { - ComponentAnnotation, - DirectiveAnnotation -} from '../annotations/annotations'; -import {ViewAnnotation} from '../annotations/view'; -import {AncestorAnnotation, ParentAnnotation} from '../annotations/visibility'; -import {AttributeAnnotation, QueryAnnotation} from '../annotations/di'; import {global} from 'angular2/src/facade/lang'; -function makeDecorator(annotationCls) { +export function makeDecorator(annotationCls) { return function(...args) { var Reflect = global.Reflect; if (!(Reflect && Reflect.getMetadata)) { @@ -24,7 +17,7 @@ function makeDecorator(annotationCls) { } } -function makeParamDecorator(annotationCls) { +export function makeParamDecorator(annotationCls) { return function(...args) { var Reflect = global.Reflect; if (!(Reflect && Reflect.getMetadata)) { @@ -45,18 +38,3 @@ function makeParamDecorator(annotationCls) { } } } - -/* from annotations */ -export var Component = makeDecorator(ComponentAnnotation); -export var Decorator = makeDecorator(DirectiveAnnotation); - -/* from view */ -export var View = makeDecorator(ViewAnnotation); - -/* from visibility */ -export var Ancestor = makeParamDecorator(AncestorAnnotation); -export var Parent = makeParamDecorator(ParentAnnotation); - -/* from di */ -export var Attribute = makeParamDecorator(AttributeAnnotation); -export var Query = makeParamDecorator(QueryAnnotation); diff --git a/modules/angular2/test/core/application_spec.js b/modules/angular2/test/core/application_spec.js index f8d92b46f8..7ebf90996b 100644 --- a/modules/angular2/test/core/application_spec.js +++ b/modules/angular2/test/core/application_spec.js @@ -16,7 +16,8 @@ import {Component, Directive} from 'angular2/src/core/annotations_impl/annotatio import {DOM} from 'angular2/src/dom/dom_adapter'; import {ListWrapper} from 'angular2/src/facade/collection'; import {PromiseWrapper} from 'angular2/src/facade/async'; -import {bind, Inject} from 'angular2/di'; +import {bind} from 'angular2/di'; +import {Inject} from 'angular2/src/di/annotations_impl'; import {View} from 'angular2/src/core/annotations_impl/view'; import {LifeCycle} from 'angular2/src/core/life_cycle/life_cycle'; import {Testability, TestabilityRegistry} from 'angular2/src/core/testability/testability'; diff --git a/modules/angular2/test/core/compiler/element_injector_spec.js b/modules/angular2/test/core/compiler/element_injector_spec.js index 259ebb4d14..cac9aca9b2 100644 --- a/modules/angular2/test/core/compiler/element_injector_spec.js +++ b/modules/angular2/test/core/compiler/element_injector_spec.js @@ -6,7 +6,8 @@ import {ProtoElementInjector, PreBuiltObjects, DirectiveBinding, TreeNode} import {Parent, Ancestor} from 'angular2/src/core/annotations_impl/visibility'; import {Attribute, Query} from 'angular2/src/core/annotations_impl/di'; import {Directive, onDestroy} from 'angular2/src/core/annotations_impl/annotations'; -import {Optional, Injector, Inject, bind} from 'angular2/di'; +import {bind, Injector} from 'angular2/di'; +import {Optional, Inject} from 'angular2/src/di/annotations_impl'; import {AppProtoView, AppView} from 'angular2/src/core/compiler/view'; import {ViewContainerRef} from 'angular2/src/core/compiler/view_container_ref'; import {ProtoViewRef} from 'angular2/src/core/compiler/view_ref'; diff --git a/modules/angular2/test/di/async_spec.js b/modules/angular2/test/di/async_spec.js index 841fe32013..11533438ba 100644 --- a/modules/angular2/test/di/async_spec.js +++ b/modules/angular2/test/di/async_spec.js @@ -9,7 +9,8 @@ import { it, xit, } from 'angular2/test_lib'; -import {Injector, Inject, InjectPromise, bind, Key} from 'angular2/di'; +import {Injector, bind, Key} from 'angular2/di'; +import {Inject, InjectPromise} from 'angular2/src/di/annotations_impl'; import {Promise, PromiseWrapper} from 'angular2/src/facade/async'; class UserList { diff --git a/modules/angular2/test/di/injector_spec.js b/modules/angular2/test/di/injector_spec.js index cb2aa85375..01d043af09 100644 --- a/modules/angular2/test/di/injector_spec.js +++ b/modules/angular2/test/di/injector_spec.js @@ -1,6 +1,8 @@ import {isBlank, BaseException} from 'angular2/src/facade/lang'; import {describe, ddescribe, it, iit, expect, beforeEach} from 'angular2/test_lib'; -import {Injector, Inject, InjectLazy, Optional, bind, ResolvedBinding} from 'angular2/di'; +import {Injector, bind, ResolvedBinding} from 'angular2/di'; +import {Optional, Inject, InjectLazy} from 'angular2/src/di/annotations_impl'; + class Engine { } diff --git a/modules/angular2/test/forms/integration_spec.js b/modules/angular2/test/forms/integration_spec.js index 87851d3b3c..7418727aeb 100644 --- a/modules/angular2/test/forms/integration_spec.js +++ b/modules/angular2/test/forms/integration_spec.js @@ -14,7 +14,7 @@ import { } from 'angular2/test_lib'; import {DOM} from 'angular2/src/dom/dom_adapter'; -import {Inject} from 'angular2/di'; +import {Inject} from 'angular2/src/di/annotations_impl'; import {Component, Directive} from 'angular2/src/core/annotations_impl/annotations'; import {View} from 'angular2/src/core/annotations_impl/view'; diff --git a/modules/angular2/test/transform/integration/all_tests.dart b/modules/angular2/test/transform/integration/all_tests.dart index 4de3646bcc..6f6c2e4207 100644 --- a/modules/angular2/test/transform/integration/all_tests.dart +++ b/modules/angular2/test/transform/integration/all_tests.dart @@ -44,8 +44,8 @@ void allTests() { 'angular2|lib/src/reflection/reflection_capabilities.dart': '../common/reflection_capabilities.dart', 'angular2|lib/di.dart': '../../../lib/di.dart', - 'angular2|lib/src/di/annotations.dart': - '../../../lib/src/di/annotations.dart', + 'angular2|lib/src/di/annotations_impl.dart': + '../../../lib/src/di/annotations_impl.dart', }; var tests = [ diff --git a/modules/angular2_material/src/components/radio/radio_button.js b/modules/angular2_material/src/components/radio/radio_button.js index 613abe2ed0..12b74935ec 100644 --- a/modules/angular2_material/src/components/radio/radio_button.js +++ b/modules/angular2_material/src/components/radio/radio_button.js @@ -2,7 +2,7 @@ import {Component, onChange} from 'angular2/src/core/annotations_impl/annotation import {View} from 'angular2/src/core/annotations_impl/view'; import {Parent, Ancestor} from 'angular2/src/core/annotations_impl/visibility'; import {Attribute} from 'angular2/src/core/annotations_impl/di'; -import {Optional} from 'angular2/src/di/annotations'; +import {Optional} from 'angular2/src/di/annotations_impl'; import {MdRadioDispatcher} from 'angular2_material/src/components/radio/radio_dispatcher' import {isPresent, StringWrapper, NumberWrapper} from 'angular2/src/facade/lang'; import {ObservableWrapper, EventEmitter} from 'angular2/src/facade/async'; diff --git a/modules/benchmarks/src/largetable/largetable_benchmark.js b/modules/benchmarks/src/largetable/largetable_benchmark.js index 2a96e2bb24..69a057e1fc 100644 --- a/modules/benchmarks/src/largetable/largetable_benchmark.js +++ b/modules/benchmarks/src/largetable/largetable_benchmark.js @@ -18,7 +18,8 @@ import {BrowserDomAdapter} from 'angular2/src/dom/browser_adapter'; import {ListWrapper} from 'angular2/src/facade/collection'; -import {Inject, bind} from 'angular2/di'; +import {bind} from 'angular2/di'; +import {Inject} from 'angular2/src/di/annotations_impl'; export const BENCHMARK_TYPE = 'LargetableComponent.benchmarkType'; export const LARGETABLE_ROWS = 'LargetableComponent.rows'; diff --git a/modules/examples/src/hello_world/index_common.js b/modules/examples/src/hello_world/index_common.js index 745466c3f4..c977781297 100644 --- a/modules/examples/src/hello_world/index_common.js +++ b/modules/examples/src/hello_world/index_common.js @@ -1,5 +1,5 @@ import {ElementRef} from 'angular2/angular2'; -import {Injectable} from 'angular2/di'; +import {Injectable} from 'angular2/src/di/annotations_impl'; // TODO(radokirov): Once the application is transpiled by TS instead of Traceur, // add those imports back into 'angular2/angular2'; diff --git a/modules/examples/src/material/demo_common.js b/modules/examples/src/material/demo_common.js index f90a0cb4af..1987bcd343 100644 --- a/modules/examples/src/material/demo_common.js +++ b/modules/examples/src/material/demo_common.js @@ -2,7 +2,7 @@ import {IMPLEMENTS, print} from 'angular2/src/facade/lang'; import {UrlResolver} from 'angular2/src/services/url_resolver'; import {isPresent, isBlank, RegExpWrapper, StringWrapper, BaseException} from 'angular2/src/facade/lang'; import {DOM} from 'angular2/src/dom/dom_adapter'; -import {Injectable} from 'angular2/di'; +import {Injectable} from 'angular2/src/di/annotations_impl'; import {ReflectionCapabilities} from 'angular2/src/reflection/reflection_capabilities'; import {reflector} from 'angular2/src/reflection/reflection'; import {BrowserDomAdapter} from 'angular2/src/dom/browser_adapter'; diff --git a/modules/examples/src/todo/services/TodoStore.js b/modules/examples/src/todo/services/TodoStore.js index 598635b83b..98237e342f 100644 --- a/modules/examples/src/todo/services/TodoStore.js +++ b/modules/examples/src/todo/services/TodoStore.js @@ -1,4 +1,4 @@ -import {Injectable} from 'angular2/di'; +import {Injectable} from 'angular2/src/di/annotations_impl'; import {ListWrapper} from 'angular2/src/facade/collection'; // base model for RecordStore