feat(decorators): adds decorators to be used by TS and Babel transpiled apps.
This commit is contained in:
8
modules/angular2/src/core/annotations/annotations.dart
Normal file
8
modules/angular2/src/core/annotations/annotations.dart
Normal file
@ -0,0 +1,8 @@
|
||||
/**
|
||||
* This indirection is needed for TS compilation path.
|
||||
* See comment in annotations.es6.
|
||||
*/
|
||||
|
||||
library angular2.core.annotations.annotations;
|
||||
|
||||
export "../annotations_impl/annotations.dart";
|
13
modules/angular2/src/core/annotations/annotations.es6
Normal file
13
modules/angular2/src/core/annotations/annotations.es6
Normal file
@ -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 {
|
||||
Component as ComponentAnnotation,
|
||||
Decorator as DecoratorAnnotation,
|
||||
Directive as DirectiveAnnotation,
|
||||
DynamicComponent as DynamicComponentAnnotation,
|
||||
Viewport as ViewportAnnotation,
|
||||
onDestroy, onChange, onAllChangesDone
|
||||
} from '../annotations_impl/annotations';
|
3
modules/angular2/src/core/annotations/di.dart
Normal file
3
modules/angular2/src/core/annotations/di.dart
Normal file
@ -0,0 +1,3 @@
|
||||
library angular2.core.annotations.di;
|
||||
|
||||
export "../annotations_impl/di.dart";
|
4
modules/angular2/src/core/annotations/di.es6
Normal file
4
modules/angular2/src/core/annotations/di.es6
Normal file
@ -0,0 +1,4 @@
|
||||
export {
|
||||
Query as QueryAnnotation,
|
||||
Attribute as AttributeAnnotation,
|
||||
} from '../annotations_impl/di';
|
3
modules/angular2/src/core/annotations/view.dart
Normal file
3
modules/angular2/src/core/annotations/view.dart
Normal file
@ -0,0 +1,3 @@
|
||||
library angular2.core.annotations.view;
|
||||
|
||||
export "../annotations_impl/view.dart";
|
3
modules/angular2/src/core/annotations/view.es6
Normal file
3
modules/angular2/src/core/annotations/view.es6
Normal file
@ -0,0 +1,3 @@
|
||||
export {
|
||||
View as ViewAnnotation,
|
||||
} from '../annotations_impl/view';
|
3
modules/angular2/src/core/annotations/visibility.dart
Normal file
3
modules/angular2/src/core/annotations/visibility.dart
Normal file
@ -0,0 +1,3 @@
|
||||
library angular2.core.annotations.visibility;
|
||||
|
||||
export "../annotations_impl/visibility.dart";
|
4
modules/angular2/src/core/annotations/visibility.es6
Normal file
4
modules/angular2/src/core/annotations/visibility.es6
Normal file
@ -0,0 +1,4 @@
|
||||
export {
|
||||
Ancestor as AncestorAnnotation,
|
||||
Parent as ParentAnnotation,
|
||||
} from '../annotations_impl/visibility';
|
@ -1,6 +1,6 @@
|
||||
library angular2.src.core.compiler.base_query_list;
|
||||
|
||||
import 'package:angular2/src/core/annotations/annotations.dart';
|
||||
import 'package:angular2/src/core/annotations_impl/annotations.dart';
|
||||
import 'dart:collection';
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
import {List, MapWrapper, ListWrapper} from 'angular2/src/facade/collection';
|
||||
import {Directive} from 'angular2/src/core/annotations/annotations';
|
||||
import {Directive} from 'angular2/src/core/annotations_impl/annotations';
|
||||
|
||||
/**
|
||||
* Injectable Objects that contains a live list of child directives in the light Dom of a directive.
|
||||
|
@ -4,12 +4,12 @@ import {Promise, PromiseWrapper} from 'angular2/src/facade/async';
|
||||
import {List, ListWrapper, Map, MapWrapper} from 'angular2/src/facade/collection';
|
||||
|
||||
import {DirectiveMetadataReader} from './directive_metadata_reader';
|
||||
import {Component, Viewport, DynamicComponent, Decorator} from '../annotations/annotations';
|
||||
import {Component, Viewport, DynamicComponent, Decorator} from '../annotations_impl/annotations';
|
||||
import {AppProtoView} from './view';
|
||||
import {ProtoViewRef} from './view_ref';
|
||||
import {DirectiveBinding} from './element_injector';
|
||||
import {TemplateResolver} from './template_resolver';
|
||||
import {View} from '../annotations/view';
|
||||
import {View} from '../annotations_impl/view';
|
||||
import {ComponentUrlMapper} from './component_url_mapper';
|
||||
import {ProtoViewFactory} from './proto_view_factory';
|
||||
import {UrlResolver} from 'angular2/src/services/url_resolver';
|
||||
|
@ -1,6 +1,6 @@
|
||||
import {Type} from 'angular2/src/facade/lang';
|
||||
import {List} from 'angular2/src/facade/collection';
|
||||
import {Directive} from 'angular2/src/core/annotations/annotations'
|
||||
import {Directive} from 'angular2/src/core/annotations_impl/annotations'
|
||||
import {ResolvedBinding} from 'angular2/di';
|
||||
|
||||
/**
|
||||
|
@ -1,6 +1,6 @@
|
||||
import {Injectable, Injector} from 'angular2/di';
|
||||
import {Type, isPresent, BaseException, stringify} from 'angular2/src/facade/lang';
|
||||
import {Directive, Component} from '../annotations/annotations';
|
||||
import {Directive, Component} from '../annotations_impl/annotations';
|
||||
import {DirectiveMetadata} from './directive_metadata';
|
||||
import {reflector} from 'angular2/src/reflection/reflection';
|
||||
|
||||
|
@ -4,14 +4,14 @@ import {Math} from 'angular2/src/facade/math';
|
||||
import {List, ListWrapper, MapWrapper} from 'angular2/src/facade/collection';
|
||||
import {Injector, Key, Dependency, bind, Binding, ResolvedBinding, NoBindingError,
|
||||
AbstractBindingError, CyclicDependencyError} from 'angular2/di';
|
||||
import {Parent, Ancestor} from 'angular2/src/core/annotations/visibility';
|
||||
import {Attribute, Query} from 'angular2/src/core/annotations/di';
|
||||
import {Parent, Ancestor} from 'angular2/src/core/annotations_impl/visibility';
|
||||
import {Attribute, Query} from 'angular2/src/core/annotations_impl/di';
|
||||
import * as viewModule from './view';
|
||||
import * as avmModule from './view_manager';
|
||||
import {ViewContainerRef} from './view_container_ref';
|
||||
import {ElementRef} from './element_ref';
|
||||
import {ProtoViewRef, ViewRef} from './view_ref';
|
||||
import {Directive, Component, onChange, onDestroy, onAllChangesDone} from 'angular2/src/core/annotations/annotations';
|
||||
import {Directive, Component, onChange, onDestroy, onAllChangesDone} from 'angular2/src/core/annotations_impl/annotations';
|
||||
import {ChangeDetector, ChangeDetectorRef} from 'angular2/change_detection';
|
||||
import {QueryList} from './query_list';
|
||||
import {reflector} from 'angular2/src/reflection/reflection';
|
||||
|
@ -4,7 +4,7 @@ import {isPresent, isBlank} from 'angular2/src/facade/lang';
|
||||
import {reflector} from 'angular2/src/reflection/reflection';
|
||||
|
||||
import {ChangeDetection, DirectiveIndex} from 'angular2/change_detection';
|
||||
import {Component, Viewport, DynamicComponent} from '../annotations/annotations';
|
||||
import {Component, Viewport, DynamicComponent} from '../annotations_impl/annotations';
|
||||
|
||||
import * as renderApi from 'angular2/src/render/api';
|
||||
import {AppProtoView} from './view';
|
||||
|
@ -1,5 +1,5 @@
|
||||
import {Injectable} from 'angular2/di';
|
||||
import {View} from 'angular2/src/core/annotations/view';
|
||||
import {View} from 'angular2/src/core/annotations_impl/view';
|
||||
|
||||
import {Type, stringify, isBlank, BaseException} from 'angular2/src/facade/lang';
|
||||
import {Map, MapWrapper, List, ListWrapper} from 'angular2/src/facade/collection';
|
||||
|
3
modules/angular2/src/core/decorators/decorators.dart
Normal file
3
modules/angular2/src/core/decorators/decorators.dart
Normal file
@ -0,0 +1,3 @@
|
||||
library angular2.core.decorators;
|
||||
|
||||
/* This file is empty because, Dart does not have decorators. */
|
40
modules/angular2/src/core/decorators/decorators.es6
Normal file
40
modules/angular2/src/core/decorators/decorators.es6
Normal file
@ -0,0 +1,40 @@
|
||||
import {
|
||||
ComponentAnnotation,
|
||||
DecoratorAnnotation,
|
||||
DynamicComponentAnnotation,
|
||||
ViewportAnnotation} from '../annotations/annotations';
|
||||
import {ViewAnnotation} from '../annotations/view';
|
||||
import {AncestorAnnotation, ParentAnnotation} from '../annotations/visibility';
|
||||
import {AttributeAnnotation, QueryAnnotation} from '../annotations/di';
|
||||
|
||||
function makeDecorator(annotationCls) {
|
||||
return function(...args) {
|
||||
if (!(window.Reflect && !window.Reflect.getMetadata)) throw 'reflect-metadata shim is required';
|
||||
var annotationInstance = new annotationCls(...args);
|
||||
var Reflect = window.Reflect;
|
||||
return function(cls) {
|
||||
var annotations = Reflect.getMetadata('annotations', cls);
|
||||
annotations = annotations || [];
|
||||
annotations.push(annotationInstance);
|
||||
Reflect.defineMetadata('annotations', annotations, cls);
|
||||
return cls;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* from annotations */
|
||||
export var Component = makeDecorator(ComponentAnnotation);
|
||||
export var Decorator = makeDecorator(DecoratorAnnotation);
|
||||
export var DynamicComponent = makeDecorator(DynamicComponentAnnotation);
|
||||
export var Viewport = makeDecorator(ViewportAnnotation);
|
||||
|
||||
/* from di */
|
||||
export var Attribute = makeDecorator(AttributeAnnotation);
|
||||
export var Query = makeDecorator(QueryAnnotation);
|
||||
|
||||
/* from view */
|
||||
export var View = makeDecorator(ViewAnnotation);
|
||||
|
||||
/* from visiblity */
|
||||
export var Ancestor = makeDecorator(AncestorAnnotation);
|
||||
export var Parent = makeDecorator(ParentAnnotation);
|
Reference in New Issue
Block a user