chore: remove obsolete files (#10240)
This commit is contained in:
@@ -1,26 +0,0 @@
|
||||
library angular2.core;
|
||||
|
||||
export './src/core/angular_entrypoint.dart' show AngularEntrypoint;
|
||||
export './src/core/metadata.dart';
|
||||
export './src/core/util.dart';
|
||||
export './src/core/di.dart' hide ForwardRefFn, resolveForwardRef, forwardRef;
|
||||
export './src/facade/facade.dart';
|
||||
export './src/core/application_ref.dart' show createPlatform, assertPlatform,
|
||||
disposePlatform, getPlatform,
|
||||
coreLoadAndBootstrap, coreBootstrap, PlatformRef, ApplicationRef;
|
||||
export './src/core/application_tokens.dart' show APP_ID,
|
||||
APP_INITIALIZER,
|
||||
PACKAGE_ROOT_URL,
|
||||
PLATFORM_INITIALIZER;
|
||||
export './src/core/zone.dart';
|
||||
export './src/core/render.dart';
|
||||
export './src/core/linker.dart';
|
||||
export './src/core/debug/debug_node.dart' show DebugElement,
|
||||
DebugNode,
|
||||
asNativeElements;
|
||||
export './src/core/testability/testability.dart';
|
||||
export './src/core/change_detection.dart';
|
||||
export './src/core/platform_directives_and_pipes.dart';
|
||||
export './src/core/platform_common_providers.dart';
|
||||
export './src/core/application_common_providers.dart';
|
||||
export './src/core/reflection/reflection.dart';
|
||||
@@ -1,17 +0,0 @@
|
||||
export './src/core/change_detection/constants.dart' show isDefaultChangeDetectionStrategy, CHANGE_DETECTION_STRATEGY_VALUES;
|
||||
export './src/core/di/reflective_provider.dart' show constructDependencies;
|
||||
export './src/core/metadata/lifecycle_hooks.dart' show LifecycleHooks, LIFECYCLE_HOOKS_VALUES;
|
||||
export './src/core/reflection/reflector_reader.dart' show ReflectorReader;
|
||||
export './src/core/linker/component_resolver.dart' show ReflectorComponentResolver;
|
||||
export './src/core/linker/element.dart' show AppElement;
|
||||
export './src/core/linker/view.dart' show AppView;
|
||||
export './src/core/linker/view_type.dart' show ViewType;
|
||||
export './src/core/linker/view_utils.dart' show MAX_INTERPOLATION_VALUES, checkBinding, flattenNestedViewRenderNodes, interpolate, ViewUtils;
|
||||
export './src/core/metadata/view.dart' show VIEW_ENCAPSULATION_VALUES;
|
||||
export './src/core/linker/debug_context.dart' show DebugContext, StaticNodeDebugInfo;
|
||||
export './src/core/change_detection/change_detection_util.dart' show devModeEqual, uninitialized, ValueUnwrapper;
|
||||
export './src/core/render/api.dart' show RenderDebugInfo;
|
||||
export './src/core/linker/template_ref.dart' show TemplateRef_;
|
||||
export './src/core/profile/wtf_init.dart' show wtfInit;
|
||||
export './src/core/reflection/reflection_capabilities.dart' show ReflectionCapabilities;
|
||||
export './src/util/decorators' show makeDecorator;
|
||||
@@ -1,33 +0,0 @@
|
||||
/**
|
||||
* To create a Pipe, you must implement this interface.
|
||||
*
|
||||
* Angular invokes the `transform` method with the value of a binding
|
||||
* as the first argument, and any parameters as the second argument in list form.
|
||||
*
|
||||
* ## Syntax
|
||||
*
|
||||
* `value | pipeName[:arg0[:arg1...]]`
|
||||
*
|
||||
* ### Example ([live demo](http://plnkr.co/edit/f5oyIked9M2cKzvZNKHV?p=preview))
|
||||
*
|
||||
* The `RepeatPipe` below repeats the value as many times as indicated by the first argument:
|
||||
*
|
||||
* ```
|
||||
* import {Pipe, PipeTransform} from 'angular2/core';
|
||||
*
|
||||
* @Pipe({name: 'repeat'})
|
||||
* export class RepeatPipe implements PipeTransform {
|
||||
* transform(value: any, times: number) {
|
||||
* return value.repeat(times);
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* Invoking `{{ 'ok' | repeat:3 }}` in a template produces `okokok`.
|
||||
*
|
||||
*/
|
||||
abstract class PipeTransform {
|
||||
// Note: Dart does not support varargs,
|
||||
// so we can't type the `transform` method...
|
||||
// dynamic transform(dynamic value, List<dynamic> ...args): any;
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
library angular2.di.decorators;
|
||||
|
||||
import 'metadata.dart';
|
||||
export 'metadata.dart';
|
||||
|
||||
/**
|
||||
* {@link InjectMetadata}.
|
||||
* @stable
|
||||
*/
|
||||
class Inject extends InjectMetadata {
|
||||
const Inject(dynamic token) : super(token);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link OptionalMetadata}.
|
||||
* @stable
|
||||
*/
|
||||
class Optional extends OptionalMetadata {
|
||||
const Optional() : super();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link InjectableMetadata}.
|
||||
* @stable
|
||||
*/
|
||||
class Injectable extends InjectableMetadata {
|
||||
const Injectable() : super();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link SelfMetadata}.
|
||||
* @stable
|
||||
*/
|
||||
class Self extends SelfMetadata {
|
||||
const Self() : super();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link HostMetadata}.
|
||||
* @stable
|
||||
*/
|
||||
class Host extends HostMetadata {
|
||||
const Host() : super();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link SkipSelfMetadata}.
|
||||
* @stable
|
||||
*/
|
||||
class SkipSelf extends SkipSelfMetadata {
|
||||
const SkipSelf() : super();
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
library angular2.di.forward_ref;
|
||||
|
||||
typedef dynamic ForwardRefFn();
|
||||
|
||||
/**
|
||||
* Dart does not have the forward ref problem, so this function is a noop.
|
||||
*/
|
||||
forwardRef(ForwardRefFn forwardRefFn) => forwardRefFn();
|
||||
|
||||
/**
|
||||
* Lazily retrieve the reference value.
|
||||
*
|
||||
* See: {@link forwardRef}
|
||||
*/
|
||||
resolveForwardRef(type) => type;
|
||||
@@ -1,20 +0,0 @@
|
||||
import './provider.dart' show Provider;
|
||||
|
||||
bool isProviderLiteral(dynamic obj) {
|
||||
if (obj is Map) {
|
||||
Map map = obj as Map;
|
||||
return map.containsKey('provide');
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Provider createProvider(dynamic obj) {
|
||||
Map map = obj as Map;
|
||||
return new Provider(map['provide'], useClass: map['useClass'],
|
||||
useValue: map['useValue'],
|
||||
useExisting: map['useExisting'],
|
||||
useFactory: map['useFactory'],
|
||||
deps: map['deps'],
|
||||
multi: map['multi']);
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
library angular2.src.core.compiler.query_list;
|
||||
|
||||
import 'dart:collection';
|
||||
import 'package:angular2/src/facade/collection.dart';
|
||||
import 'package:angular2/src/facade/async.dart';
|
||||
|
||||
/**
|
||||
* See query_list.ts
|
||||
*/
|
||||
class QueryList<T> extends Object with IterableMixin<T> {
|
||||
bool _dirty = true;
|
||||
List<T> _results = [];
|
||||
EventEmitter _emitter = new EventEmitter();
|
||||
|
||||
Iterator<T> get iterator => _results.iterator;
|
||||
|
||||
Stream<Iterable<T>> get changes => _emitter;
|
||||
|
||||
int get length => _results.length;
|
||||
T get first => _results.length > 0 ? _results.first : null;
|
||||
T get last => _results.length > 0 ? _results.last : null;
|
||||
String toString() {
|
||||
return _results.toString();
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
void reset(List<T> newList) {
|
||||
_results = ListWrapper.flatten(newList);
|
||||
_dirty = false;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
void notifyOnChanges() {
|
||||
_emitter.add(this);
|
||||
}
|
||||
|
||||
/** @internal **/
|
||||
bool get dirty => _dirty;
|
||||
|
||||
/** @internal **/
|
||||
void setDirty() {
|
||||
_dirty = true;
|
||||
}
|
||||
}
|
||||
@@ -1,228 +0,0 @@
|
||||
library angular2.src.core.metadata;
|
||||
|
||||
import 'package:angular2/src/facade/collection.dart' show List;
|
||||
import 'package:angular2/src/core/change_detection/change_detection.dart';
|
||||
import './metadata/di.dart';
|
||||
import './metadata/directives.dart';
|
||||
import './metadata/view.dart';
|
||||
import './metadata/animations.dart' show AnimationEntryMetadata;
|
||||
|
||||
export './metadata/di.dart';
|
||||
export './metadata/directives.dart';
|
||||
export './metadata/view.dart' hide VIEW_ENCAPSULATION_VALUES;
|
||||
export './metadata/lifecycle_hooks.dart' show
|
||||
AfterContentInit,
|
||||
AfterContentChecked,
|
||||
AfterViewInit,
|
||||
AfterViewChecked,
|
||||
OnChanges,
|
||||
OnDestroy,
|
||||
OnInit,
|
||||
DoCheck;
|
||||
|
||||
/**
|
||||
* See: [DirectiveMetadata] for docs.
|
||||
* @stable
|
||||
*/
|
||||
class Directive extends DirectiveMetadata {
|
||||
const Directive(
|
||||
{String selector,
|
||||
List<String> inputs,
|
||||
List<String> outputs,
|
||||
@Deprecated('Use `inputs` or `@Input` instead')
|
||||
List<String> properties,
|
||||
@Deprecated('Use `outputs` or `@Output` instead')
|
||||
List<String> events,
|
||||
Map<String, String> host,
|
||||
List providers,
|
||||
String exportAs,
|
||||
Map<String, dynamic> queries})
|
||||
: super(
|
||||
selector: selector,
|
||||
inputs: inputs,
|
||||
outputs: outputs,
|
||||
properties: properties,
|
||||
events: events,
|
||||
host: host,
|
||||
providers: providers,
|
||||
exportAs: exportAs,
|
||||
queries: queries);
|
||||
}
|
||||
|
||||
/**
|
||||
* See: [ComponentMetadata] for docs.
|
||||
* @stable
|
||||
*/
|
||||
class Component extends ComponentMetadata {
|
||||
const Component(
|
||||
{String selector,
|
||||
List<String> inputs,
|
||||
List<String> outputs,
|
||||
@Deprecated('Use `inputs` or `@Input` instead')
|
||||
List<String> properties,
|
||||
@Deprecated('Use `outputs` or `@Output` instead')
|
||||
List<String> events,
|
||||
Map<String, String> host,
|
||||
List providers,
|
||||
String exportAs,
|
||||
String moduleId,
|
||||
Map<String, dynamic> queries,
|
||||
List viewProviders,
|
||||
ChangeDetectionStrategy changeDetection,
|
||||
String templateUrl,
|
||||
String template,
|
||||
dynamic directives,
|
||||
dynamic pipes,
|
||||
ViewEncapsulation encapsulation,
|
||||
List<String> styles,
|
||||
List<String> styleUrls,
|
||||
List<AnimationEntryMetadata> animations})
|
||||
: super(
|
||||
selector: selector,
|
||||
inputs: inputs,
|
||||
outputs: outputs,
|
||||
properties: properties,
|
||||
events: events,
|
||||
host: host,
|
||||
providers: providers,
|
||||
exportAs: exportAs,
|
||||
moduleId: moduleId,
|
||||
viewProviders: viewProviders,
|
||||
queries: queries,
|
||||
changeDetection: changeDetection,
|
||||
templateUrl: templateUrl,
|
||||
template: template,
|
||||
directives: directives,
|
||||
pipes: pipes,
|
||||
encapsulation: encapsulation,
|
||||
styles: styles,
|
||||
styleUrls: styleUrls,
|
||||
animations: animations);
|
||||
}
|
||||
|
||||
/**
|
||||
* See: [ViewMetadata] for docs.
|
||||
* @deprecated
|
||||
*/
|
||||
class View extends ViewMetadata {
|
||||
const View(
|
||||
{String templateUrl,
|
||||
String template,
|
||||
dynamic directives,
|
||||
dynamic pipes,
|
||||
ViewEncapsulation encapsulation,
|
||||
List<String> styles,
|
||||
List<String> styleUrls,
|
||||
List<AnimationEntryMetadata> animations})
|
||||
: super(
|
||||
templateUrl: templateUrl,
|
||||
template: template,
|
||||
directives: directives,
|
||||
pipes: pipes,
|
||||
encapsulation: encapsulation,
|
||||
styles: styles,
|
||||
styleUrls: styleUrls,
|
||||
animations: animations);
|
||||
}
|
||||
|
||||
/**
|
||||
* See: [PipeMetadata] for docs.
|
||||
* @stable
|
||||
*/
|
||||
class Pipe extends PipeMetadata {
|
||||
const Pipe({name, pure}) : super(name: name, pure: pure);
|
||||
}
|
||||
|
||||
/**
|
||||
* See: [AttributeMetadata] for docs.
|
||||
* @stable
|
||||
*/
|
||||
class Attribute extends AttributeMetadata {
|
||||
const Attribute(String attributeName) : super(attributeName);
|
||||
}
|
||||
|
||||
/**
|
||||
* See: [QueryMetadata] for docs.
|
||||
* @deprecated Use ContentChildren/ContentChild instead
|
||||
*/
|
||||
class Query extends QueryMetadata {
|
||||
const Query(dynamic /*Type | string*/ selector,
|
||||
{bool descendants: false, dynamic read: null})
|
||||
: super(selector, descendants: descendants, read: read);
|
||||
}
|
||||
|
||||
/**
|
||||
* See: [ContentChildrenMetadata] for docs.
|
||||
* @stable
|
||||
*/
|
||||
class ContentChildren extends ContentChildrenMetadata {
|
||||
const ContentChildren(dynamic /*Type | string*/ selector,
|
||||
{bool descendants: false, dynamic read: null})
|
||||
: super(selector, descendants: descendants, read: read);
|
||||
}
|
||||
|
||||
/**
|
||||
* See: [ContentChildMetadata] for docs.
|
||||
* @stable
|
||||
*/
|
||||
class ContentChild extends ContentChildMetadata {
|
||||
const ContentChild(dynamic /*Type | string*/ selector, {dynamic read: null}) : super(selector, read: read);
|
||||
}
|
||||
|
||||
/**
|
||||
* See: [ViewQueryMetadata] for docs.
|
||||
* @deprecated Use ViewChildren/ViewChild instead
|
||||
*/
|
||||
class ViewQuery extends ViewQueryMetadata {
|
||||
const ViewQuery(dynamic /*Type | string*/ selector, {dynamic read: null})
|
||||
: super(selector, descendants: true, read: read);
|
||||
}
|
||||
|
||||
/**
|
||||
* See: [ViewChildrenMetadata] for docs.
|
||||
* @stable
|
||||
*/
|
||||
class ViewChildren extends ViewChildrenMetadata {
|
||||
const ViewChildren(dynamic /*Type | string*/ selector, {dynamic read: null}) : super(selector, read: read);
|
||||
}
|
||||
|
||||
/**
|
||||
* See: [ViewChildMetadata] for docs.
|
||||
* @stable
|
||||
*/
|
||||
class ViewChild extends ViewChildMetadata {
|
||||
const ViewChild(dynamic /*Type | string*/ selector, {dynamic read: null}) : super(selector, read: read);
|
||||
}
|
||||
|
||||
/**
|
||||
* See: [InputMetadata] for docs.
|
||||
* @stable
|
||||
*/
|
||||
class Input extends InputMetadata {
|
||||
const Input([String bindingPropertyName]) : super(bindingPropertyName);
|
||||
}
|
||||
|
||||
/**
|
||||
* See: [OutputMetadata] for docs.
|
||||
* @stable
|
||||
*/
|
||||
class Output extends OutputMetadata {
|
||||
const Output([String bindingPropertyName]) : super(bindingPropertyName);
|
||||
}
|
||||
|
||||
/**
|
||||
* See: [HostBindingMetadata] for docs.
|
||||
* @stable
|
||||
*/
|
||||
class HostBinding extends HostBindingMetadata {
|
||||
const HostBinding([String hostPropertyName]) : super(hostPropertyName);
|
||||
}
|
||||
|
||||
/**
|
||||
* See: [HostListenerMetadata] for docs.
|
||||
* @stable
|
||||
*/
|
||||
class HostListener extends HostListenerMetadata {
|
||||
const HostListener(String eventName, [List<String> args])
|
||||
: super(eventName, args);
|
||||
}
|
||||
@@ -1,96 +0,0 @@
|
||||
/**
|
||||
* Tracing for Dart applications.
|
||||
*
|
||||
* The tracing API hooks up to either [WTF](http://google.github.io/tracing-framework/) or
|
||||
* [Dart Observatory](https://www.dartlang.org/tools/observatory/).
|
||||
*/
|
||||
library angular2.src.core.wtf_impl;
|
||||
|
||||
typedef dynamic WtfScopeFn([arg0, arg1]);
|
||||
|
||||
var context = null;
|
||||
var _trace;
|
||||
var _events;
|
||||
var _createScope;
|
||||
var _leaveScope;
|
||||
var _beginTimeRange;
|
||||
var _endTimeRange;
|
||||
final List _arg1 = [null];
|
||||
final List _arg2 = [null, null];
|
||||
|
||||
bool detectWTF() {
|
||||
if (context != null && context.hasProperty('wtf')) {
|
||||
var wtf = context['wtf'];
|
||||
if (wtf.hasProperty('trace')) {
|
||||
_trace = wtf['trace'];
|
||||
_events = _trace['events'];
|
||||
_createScope = _events['createScope'];
|
||||
_leaveScope = _trace['leaveScope'];
|
||||
_beginTimeRange = _trace['beginTimeRange'];
|
||||
_endTimeRange = _trace['endTimeRange'];
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int getArgSize(String signature) {
|
||||
int start = signature.indexOf('(') + 1;
|
||||
int end = signature.indexOf(')', start);
|
||||
bool found = false;
|
||||
int count = 0;
|
||||
for (var i = start; i < end; i++) {
|
||||
var ch = signature[i];
|
||||
if (identical(ch, ',')) {
|
||||
found = false;
|
||||
}
|
||||
if (!found) {
|
||||
found = true;
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
dynamic createScope(String signature, [flags]) {
|
||||
_arg2[0] = signature;
|
||||
_arg2[1] = flags;
|
||||
var jsScope = _createScope.apply(_arg2, thisArg: _events);
|
||||
switch (getArgSize(signature)) {
|
||||
case 0:
|
||||
return ([arg0, arg1]) {
|
||||
return jsScope.apply(const []);
|
||||
};
|
||||
case 1:
|
||||
return ([arg0, arg1]) {
|
||||
_arg1[0] = arg0;
|
||||
return jsScope.apply(_arg1);
|
||||
};
|
||||
case 2:
|
||||
return ([arg0, arg1]) {
|
||||
_arg2[0] = arg0;
|
||||
_arg2[1] = arg1;
|
||||
return jsScope.apply(_arg2);
|
||||
};
|
||||
default:
|
||||
throw "Max 2 arguments are supported.";
|
||||
}
|
||||
}
|
||||
|
||||
void leave(scope, [returnValue]) {
|
||||
_arg2[0] = scope;
|
||||
_arg2[1] = returnValue;
|
||||
_leaveScope.apply(_arg2, thisArg: _trace);
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
dynamic startTimeRange(String rangeType, String action) {
|
||||
_arg2[0] = rangeType;
|
||||
_arg2[1] = action;
|
||||
return _beginTimeRange.apply(_arg2, thisArg: _trace);
|
||||
}
|
||||
|
||||
void endTimeRange(dynamic range) {
|
||||
_arg1[0] = range;
|
||||
_endTimeRange.apply(_arg1, thisArg: _trace);
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
library angular2.src.core.wtf_init;
|
||||
|
||||
import 'dart:js' as js;
|
||||
import 'wtf_impl.dart' as impl;
|
||||
|
||||
/**
|
||||
* Must be executed explicitly in Dart to set the JS Context.
|
||||
*
|
||||
* NOTE: this is done explicitly to allow WTF api not to depend on
|
||||
* JS context and possible to run the noop WTF stubs outside the browser.
|
||||
*/
|
||||
wtfInit() {
|
||||
impl.context = js.context;
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
library reflection.debug_reflection_capabilities;
|
||||
|
||||
import 'dart:mirrors';
|
||||
import 'package:logging/logging.dart' as log;
|
||||
import 'package:stack_trace/stack_trace.dart';
|
||||
import 'types.dart';
|
||||
import 'reflection_capabilities.dart' as standard;
|
||||
|
||||
class ReflectionCapabilities extends standard.ReflectionCapabilities {
|
||||
final bool _verbose;
|
||||
final log.Logger _log = new log.Logger('ReflectionCapabilities');
|
||||
|
||||
ReflectionCapabilities({bool verbose: false})
|
||||
: _verbose = verbose,
|
||||
super() {
|
||||
log.hierarchicalLoggingEnabled = true;
|
||||
_log.level = _verbose ? log.Level.ALL : log.Level.INFO;
|
||||
_log.onRecord.listen((log.LogRecord rec) {
|
||||
print('[${rec.loggerName}(${rec.level.name})]: ${rec.message}');
|
||||
});
|
||||
}
|
||||
|
||||
void _notify(String methodName, param) {
|
||||
var trace = _verbose ? ' ${Trace.format(new Trace.current())}' : '';
|
||||
_log.info('"$methodName" requested for "$param".$trace');
|
||||
}
|
||||
|
||||
Function factory(Type type) {
|
||||
ClassMirror classMirror = reflectType(type);
|
||||
_notify('factory', '${classMirror.qualifiedName}');
|
||||
return super.factory(type);
|
||||
}
|
||||
|
||||
List<List> parameters(typeOrFunc) {
|
||||
_notify('parameters', typeOrFunc);
|
||||
return super.parameters(typeOrFunc);
|
||||
}
|
||||
|
||||
List annotations(typeOrFunc) {
|
||||
_notify('annotations', typeOrFunc);
|
||||
return super.annotations(typeOrFunc);
|
||||
}
|
||||
|
||||
Map propMetadata(typeOrFunc) {
|
||||
_notify('propMetadata', typeOrFunc);
|
||||
return super.propMetadata(typeOrFunc);
|
||||
}
|
||||
|
||||
GetterFn getter(String name) {
|
||||
_notify('getter', name);
|
||||
return super.getter(name);
|
||||
}
|
||||
|
||||
SetterFn setter(String name) {
|
||||
_notify('setter', name);
|
||||
return super.setter(name);
|
||||
}
|
||||
|
||||
MethodFn method(String name) {
|
||||
_notify('method', name);
|
||||
return super.method(name);
|
||||
}
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
library reflection.reflection;
|
||||
|
||||
import 'reflector.dart';
|
||||
import 'types.dart';
|
||||
export 'reflector.dart';
|
||||
import 'platform_reflection_capabilities.dart';
|
||||
import 'package:angular2/src/facade/lang.dart';
|
||||
|
||||
class NoReflectionCapabilities implements PlatformReflectionCapabilities {
|
||||
@override
|
||||
bool isReflectionEnabled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@override
|
||||
Function factory(Type type) {
|
||||
throw "Cannot find reflection information on ${stringify(type)}";
|
||||
}
|
||||
|
||||
@override
|
||||
List interfaces(Type type) {
|
||||
throw "Cannot find reflection information on ${stringify(type)}";
|
||||
}
|
||||
|
||||
@override
|
||||
List<List> parameters(dynamic type) {
|
||||
throw "Cannot find reflection information on ${stringify(type)}";
|
||||
}
|
||||
|
||||
@override
|
||||
List annotations(dynamic type) {
|
||||
throw "Cannot find reflection information on ${stringify(type)}";
|
||||
}
|
||||
|
||||
@override
|
||||
Map<String, List> propMetadata(dynamic type) {
|
||||
throw "Cannot find reflection information on ${stringify(type)}";
|
||||
}
|
||||
|
||||
@override
|
||||
GetterFn getter(String name) {
|
||||
throw "Cannot find getter ${name}";
|
||||
}
|
||||
|
||||
@override
|
||||
SetterFn setter(String name) {
|
||||
throw "Cannot find setter ${name}";
|
||||
}
|
||||
|
||||
@override
|
||||
MethodFn method(String name) {
|
||||
throw "Cannot find method ${name}";
|
||||
}
|
||||
|
||||
@override
|
||||
String importUri(Type type) => './';
|
||||
}
|
||||
|
||||
final Reflector reflector = new Reflector(new NoReflectionCapabilities());
|
||||
@@ -1,458 +0,0 @@
|
||||
library reflection.reflection_capabilities;
|
||||
|
||||
import 'dart:mirrors';
|
||||
|
||||
import 'package:angular2/src/core/metadata/lifecycle_hooks.dart';
|
||||
import 'package:angular2/src/facade/lang.dart';
|
||||
|
||||
import 'platform_reflection_capabilities.dart';
|
||||
import 'types.dart';
|
||||
|
||||
import '../linker/template_ref.dart';
|
||||
|
||||
var DOT_REGEX = new RegExp('\\.');
|
||||
|
||||
class ReflectionCapabilities implements PlatformReflectionCapabilities {
|
||||
Map<Symbol, Type> parameterizedTypeMapping = new Map<Symbol, Type>();
|
||||
|
||||
ReflectionCapabilities([metadataReader]) {
|
||||
// In Dart, there is no way of getting from a parameterized Type to
|
||||
// the underlying non parameterized type.
|
||||
// So we need to have a separate Map for the types that are generic
|
||||
// and used in our DI...
|
||||
parameterizedTypeMapping[reflectType(TemplateRef).qualifiedName] = TemplateRef;
|
||||
}
|
||||
|
||||
_typeFromMirror(TypeMirror typeMirror) {
|
||||
var result = parameterizedTypeMapping[typeMirror.qualifiedName];
|
||||
if (result == null && typeMirror.hasReflectedType && typeMirror.reflectedType != dynamic) {
|
||||
result = typeMirror.reflectedType;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool isReflectionEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
Function factory(Type type) {
|
||||
ClassMirror classMirror = reflectType(type);
|
||||
MethodMirror ctor = classMirror.declarations[classMirror.simpleName];
|
||||
Function create = classMirror.newInstance;
|
||||
Symbol name = ctor.constructorName;
|
||||
int length = ctor.parameters.length;
|
||||
|
||||
switch (length) {
|
||||
case 0:
|
||||
return () => create(name, []).reflectee;
|
||||
case 1:
|
||||
return (a1) => create(name, [a1]).reflectee;
|
||||
case 2:
|
||||
return (a1, a2) => create(name, [a1, a2]).reflectee;
|
||||
case 3:
|
||||
return (a1, a2, a3) => create(name, [a1, a2, a3]).reflectee;
|
||||
case 4:
|
||||
return (a1, a2, a3, a4) => create(name, [a1, a2, a3, a4]).reflectee;
|
||||
case 5:
|
||||
return (a1, a2, a3, a4, a5) =>
|
||||
create(name, [a1, a2, a3, a4, a5]).reflectee;
|
||||
case 6:
|
||||
return (a1, a2, a3, a4, a5, a6) =>
|
||||
create(name, [a1, a2, a3, a4, a5, a6]).reflectee;
|
||||
case 7:
|
||||
return (a1, a2, a3, a4, a5, a6, a7) =>
|
||||
create(name, [a1, a2, a3, a4, a5, a6, a7]).reflectee;
|
||||
case 8:
|
||||
return (a1, a2, a3, a4, a5, a6, a7, a8) =>
|
||||
create(name, [a1, a2, a3, a4, a5, a6, a7, a8]).reflectee;
|
||||
case 9:
|
||||
return (a1, a2, a3, a4, a5, a6, a7, a8, a9) =>
|
||||
create(name, [a1, a2, a3, a4, a5, a6, a7, a8, a9]).reflectee;
|
||||
case 10:
|
||||
return (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) =>
|
||||
create(name, [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10]).reflectee;
|
||||
case 11:
|
||||
return (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11) =>
|
||||
create(name, [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11])
|
||||
.reflectee;
|
||||
case 12:
|
||||
return (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12) =>
|
||||
create(name, [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12])
|
||||
.reflectee;
|
||||
case 13:
|
||||
return (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13) =>
|
||||
create(name, [
|
||||
a1,
|
||||
a2,
|
||||
a3,
|
||||
a4,
|
||||
a5,
|
||||
a6,
|
||||
a7,
|
||||
a8,
|
||||
a9,
|
||||
a10,
|
||||
a11,
|
||||
a12,
|
||||
a13
|
||||
]).reflectee;
|
||||
case 14:
|
||||
return (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14) =>
|
||||
create(name, [
|
||||
a1,
|
||||
a2,
|
||||
a3,
|
||||
a4,
|
||||
a5,
|
||||
a6,
|
||||
a7,
|
||||
a8,
|
||||
a9,
|
||||
a10,
|
||||
a11,
|
||||
a12,
|
||||
a13,
|
||||
a14
|
||||
]).reflectee;
|
||||
case 15:
|
||||
return (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14,
|
||||
a15) =>
|
||||
create(name, [
|
||||
a1,
|
||||
a2,
|
||||
a3,
|
||||
a4,
|
||||
a5,
|
||||
a6,
|
||||
a7,
|
||||
a8,
|
||||
a9,
|
||||
a10,
|
||||
a11,
|
||||
a12,
|
||||
a13,
|
||||
a14,
|
||||
a15
|
||||
]).reflectee;
|
||||
case 16:
|
||||
return (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14,
|
||||
a15, a16) =>
|
||||
create(name, [
|
||||
a1,
|
||||
a2,
|
||||
a3,
|
||||
a4,
|
||||
a5,
|
||||
a6,
|
||||
a7,
|
||||
a8,
|
||||
a9,
|
||||
a10,
|
||||
a11,
|
||||
a12,
|
||||
a13,
|
||||
a14,
|
||||
a15,
|
||||
a16
|
||||
]).reflectee;
|
||||
case 17:
|
||||
return (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14,
|
||||
a15, a16, a17) =>
|
||||
create(name, [
|
||||
a1,
|
||||
a2,
|
||||
a3,
|
||||
a4,
|
||||
a5,
|
||||
a6,
|
||||
a7,
|
||||
a8,
|
||||
a9,
|
||||
a10,
|
||||
a11,
|
||||
a12,
|
||||
a13,
|
||||
a14,
|
||||
a15,
|
||||
a16,
|
||||
a17
|
||||
]).reflectee;
|
||||
case 18:
|
||||
return (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14,
|
||||
a15, a16, a17, a18) =>
|
||||
create(name, [
|
||||
a1,
|
||||
a2,
|
||||
a3,
|
||||
a4,
|
||||
a5,
|
||||
a6,
|
||||
a7,
|
||||
a8,
|
||||
a9,
|
||||
a10,
|
||||
a11,
|
||||
a12,
|
||||
a13,
|
||||
a14,
|
||||
a15,
|
||||
a16,
|
||||
a17,
|
||||
a18
|
||||
]).reflectee;
|
||||
case 19:
|
||||
return (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14,
|
||||
a15, a16, a17, a18, a19) =>
|
||||
create(name, [
|
||||
a1,
|
||||
a2,
|
||||
a3,
|
||||
a4,
|
||||
a5,
|
||||
a6,
|
||||
a7,
|
||||
a8,
|
||||
a9,
|
||||
a10,
|
||||
a11,
|
||||
a12,
|
||||
a13,
|
||||
a14,
|
||||
a15,
|
||||
a16,
|
||||
a17,
|
||||
a18,
|
||||
a19
|
||||
]).reflectee;
|
||||
case 20:
|
||||
return (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14,
|
||||
a15, a16, a17, a18, a19, a20) =>
|
||||
create(name, [
|
||||
a1,
|
||||
a2,
|
||||
a3,
|
||||
a4,
|
||||
a5,
|
||||
a6,
|
||||
a7,
|
||||
a8,
|
||||
a9,
|
||||
a10,
|
||||
a11,
|
||||
a12,
|
||||
a13,
|
||||
a14,
|
||||
a15,
|
||||
a16,
|
||||
a17,
|
||||
a18,
|
||||
a19,
|
||||
a20
|
||||
]).reflectee;
|
||||
}
|
||||
|
||||
throw "Cannot create a factory for '${stringify(type)}' because its constructor has more than 20 arguments";
|
||||
}
|
||||
|
||||
List<List> parameters(typeOrFunc) {
|
||||
final parameters = typeOrFunc is Type
|
||||
? _constructorParameters(typeOrFunc)
|
||||
: _functionParameters(typeOrFunc);
|
||||
return parameters.map(_convertParameter).toList();
|
||||
}
|
||||
|
||||
List _convertParameter(ParameterMirror p) {
|
||||
var t = p.type;
|
||||
var type = _typeFromMirror(t);
|
||||
var res = type != null ? [type] : [];
|
||||
res.addAll(p.metadata.map((m) => m.reflectee));
|
||||
return res;
|
||||
}
|
||||
|
||||
List annotations(typeOrFunc) {
|
||||
final meta = typeOrFunc is Type
|
||||
? _constructorMetadata(typeOrFunc)
|
||||
: _functionMetadata(typeOrFunc);
|
||||
|
||||
return meta.map((m) => m.reflectee).toList();
|
||||
}
|
||||
|
||||
Map propMetadata(typeOrFunc) {
|
||||
final res = {};
|
||||
reflectClass(typeOrFunc).declarations.forEach((k, v) {
|
||||
var name = _normalizeName(MirrorSystem.getName(k));
|
||||
if (res[name] == null) res[name] = [];
|
||||
res[name].addAll(v.metadata.map((fm) => fm.reflectee));
|
||||
});
|
||||
return res;
|
||||
}
|
||||
|
||||
String _normalizeName(String name) {
|
||||
return name.endsWith("=") ? name.substring(0, name.length - 1) : name;
|
||||
}
|
||||
|
||||
bool hasLifecycleHook(dynamic type, Type lcInterface, String lcProperty) {
|
||||
if (type is! Type) return false;
|
||||
return this.interfaces(type).contains(lcInterface);
|
||||
}
|
||||
|
||||
List interfaces(type) {
|
||||
final clazz = reflectType(type);
|
||||
_assertDeclaresLifecycleHooks(clazz);
|
||||
return _interfacesFromMirror(clazz);
|
||||
}
|
||||
|
||||
List _interfacesFromMirror(classMirror) {
|
||||
return classMirror.superinterfaces.map((si) => si.reflectedType).toList()
|
||||
..addAll(classMirror.superclass == null
|
||||
? []
|
||||
: _interfacesFromMirror(classMirror.superclass));
|
||||
}
|
||||
|
||||
GetterFn getter(String name) {
|
||||
var symbol = new Symbol(name);
|
||||
return (receiver) => reflect(receiver).getField(symbol).reflectee;
|
||||
}
|
||||
|
||||
SetterFn setter(String name) {
|
||||
var symbol = new Symbol(name);
|
||||
return (receiver, value) =>
|
||||
reflect(receiver).setField(symbol, value).reflectee;
|
||||
}
|
||||
|
||||
MethodFn method(String name) {
|
||||
var symbol = new Symbol(name);
|
||||
return (receiver, posArgs) =>
|
||||
reflect(receiver).invoke(symbol, posArgs).reflectee;
|
||||
}
|
||||
|
||||
List _functionParameters(Function func) {
|
||||
var closureMirror = reflect(func);
|
||||
return closureMirror.function.parameters;
|
||||
}
|
||||
|
||||
List _constructorParameters(Type type) {
|
||||
ClassMirror classMirror = reflectType(type);
|
||||
MethodMirror ctor = classMirror.declarations[classMirror.simpleName];
|
||||
return ctor.parameters;
|
||||
}
|
||||
|
||||
List _functionMetadata(Function func) {
|
||||
var closureMirror = reflect(func);
|
||||
return closureMirror.function.metadata;
|
||||
}
|
||||
|
||||
List _constructorMetadata(Type type) {
|
||||
ClassMirror classMirror = reflectType(type);
|
||||
return classMirror.metadata;
|
||||
}
|
||||
|
||||
String importUri(dynamic type) {
|
||||
// StaticSymbol
|
||||
if (type is Map && type['filePath'] != null) {
|
||||
return type['filePath'];
|
||||
}
|
||||
// Runtime type
|
||||
return '${(reflectClass(type).owner as LibraryMirror).uri}';
|
||||
}
|
||||
}
|
||||
|
||||
final _lifecycleHookMirrors = <ClassMirror>[
|
||||
reflectType(AfterContentChecked),
|
||||
reflectType(AfterContentInit),
|
||||
reflectType(AfterViewChecked),
|
||||
reflectType(AfterViewInit),
|
||||
reflectType(DoCheck),
|
||||
reflectType(OnChanges),
|
||||
reflectType(OnDestroy),
|
||||
reflectType(OnInit),
|
||||
];
|
||||
|
||||
/// Checks whether [clazz] implements lifecycle ifaces without declaring them.
|
||||
///
|
||||
/// Due to Dart implementation details, lifecycle hooks are only called when a
|
||||
/// class explicitly declares that it implements the associated interface.
|
||||
/// See https://goo.gl/b07Kii for details.
|
||||
void _assertDeclaresLifecycleHooks(ClassMirror clazz) {
|
||||
final missingDeclarations = <ClassMirror>[];
|
||||
for (var iface in _lifecycleHookMirrors) {
|
||||
if (!_checkDeclares(clazz, iface: iface) &&
|
||||
_checkImplements(clazz, iface: iface)) {
|
||||
missingDeclarations.add(iface);
|
||||
}
|
||||
}
|
||||
if (missingDeclarations.isNotEmpty) {
|
||||
throw new MissingInterfaceError(clazz, missingDeclarations);
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns whether [clazz] declares that it implements [iface].
|
||||
///
|
||||
/// Returns `false` if [clazz] implements [iface] but does not declare it.
|
||||
/// Returns `false` if [clazz]'s superclass declares that it
|
||||
/// implements [iface].
|
||||
bool _checkDeclares(ClassMirror clazz, {ClassMirror iface: null}) {
|
||||
if (iface == null) {
|
||||
throw new ArgumentError.notNull('iface');
|
||||
}
|
||||
return clazz.superinterfaces.contains(iface);
|
||||
}
|
||||
|
||||
/// Returns whether [clazz] implements [iface].
|
||||
///
|
||||
/// Returns `true` if [clazz] implements [iface] and does not declare it.
|
||||
/// Returns `true` if [clazz]'s superclass implements [iface].
|
||||
///
|
||||
/// This is an approximation of a JavaScript feature check:
|
||||
/// ```js
|
||||
/// var matches = true;
|
||||
/// for (var prop in iface) {
|
||||
/// if (iface.hasOwnProperty(prop)) {
|
||||
/// matches = matches && clazz.hasOwnProperty(prop);
|
||||
/// }
|
||||
/// }
|
||||
/// return matches;
|
||||
/// ```
|
||||
bool _checkImplements(ClassMirror clazz, {ClassMirror iface: null}) {
|
||||
if (iface == null) {
|
||||
throw new ArgumentError.notNull('iface');
|
||||
}
|
||||
|
||||
var matches = true;
|
||||
iface.declarations.forEach((symbol, declarationMirror) {
|
||||
if (!matches) return;
|
||||
if (declarationMirror.isConstructor || declarationMirror.isPrivate) return;
|
||||
matches = clazz.declarations.keys.contains(symbol);
|
||||
});
|
||||
if (!matches && clazz.superclass != null) {
|
||||
matches = _checkImplements(clazz.superclass, iface: iface);
|
||||
}
|
||||
if (!matches && clazz.mixin != clazz) {
|
||||
matches = _checkImplements(clazz.mixin, iface: iface);
|
||||
}
|
||||
|
||||
return matches;
|
||||
}
|
||||
|
||||
/// Error thrown when a class implements a lifecycle iface it does not declare.
|
||||
class MissingInterfaceError extends Error {
|
||||
final ClassMirror clazz;
|
||||
final List<ClassMirror> missingDeclarations;
|
||||
|
||||
MissingInterfaceError(this.clazz, this.missingDeclarations);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
final buf = new StringBuffer();
|
||||
buf.write('${clazz.simpleName} implements ');
|
||||
if (missingDeclarations.length == 1) {
|
||||
buf.write('an interface but does not declare it: ');
|
||||
} else {
|
||||
buf.write('interfaces but does not declare them: ');
|
||||
}
|
||||
buf.write(
|
||||
missingDeclarations.map((d) => d.simpleName.toString()).join(', '));
|
||||
buf.write('. See https://goo.gl/b07Kii for more info.');
|
||||
return buf.toString();
|
||||
}
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
library reflection.types;
|
||||
|
||||
typedef SetterFn(obj, value);
|
||||
typedef GetterFn(obj);
|
||||
typedef MethodFn(obj, List args);
|
||||
@@ -1,4 +0,0 @@
|
||||
library angular2.src.core.util;
|
||||
|
||||
// the ts version is needed only for TS, we don't need a Dart implementation
|
||||
// because there are no decorators in Dart.
|
||||
@@ -1 +0,0 @@
|
||||
library angular2.core.util.decorators;
|
||||
@@ -1,226 +0,0 @@
|
||||
library angular.zone;
|
||||
|
||||
import 'dart:async';
|
||||
import 'package:stack_trace/stack_trace.dart' show Chain;
|
||||
|
||||
typedef void ZeroArgFunction();
|
||||
typedef void ErrorHandlingFn(error, stackTrace);
|
||||
|
||||
/**
|
||||
* A `Timer` wrapper that lets you specify additional functions to call when it
|
||||
* is cancelled.
|
||||
*/
|
||||
class WrappedTimer implements Timer {
|
||||
Timer _timer;
|
||||
ZeroArgFunction _onCancelCb;
|
||||
|
||||
WrappedTimer(Timer timer) {
|
||||
_timer = timer;
|
||||
}
|
||||
|
||||
void addOnCancelCb(ZeroArgFunction onCancelCb) {
|
||||
if (this._onCancelCb != null) {
|
||||
throw "On cancel cb already registered";
|
||||
}
|
||||
this._onCancelCb = onCancelCb;
|
||||
}
|
||||
|
||||
void cancel() {
|
||||
if (this._onCancelCb != null) {
|
||||
this._onCancelCb();
|
||||
}
|
||||
_timer.cancel();
|
||||
}
|
||||
|
||||
bool get isActive => _timer.isActive;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores error information; delivered via [NgZone.onError] stream.
|
||||
*/
|
||||
class NgZoneError {
|
||||
/// Error object thrown.
|
||||
final error;
|
||||
/// Either long or short chain of stack traces.
|
||||
final List stackTrace;
|
||||
NgZoneError(this.error, this.stackTrace);
|
||||
}
|
||||
|
||||
/**
|
||||
* A `Zone` wrapper that lets you schedule tasks after its private microtask queue is exhausted but
|
||||
* before the next "VM turn", i.e. event loop iteration.
|
||||
*
|
||||
* This lets you freely schedule microtasks that prepare data, and set an {@link onMicrotaskEmpty} handler that
|
||||
* will consume that data after it's ready but before the browser has a chance to re-render.
|
||||
*
|
||||
* A VM turn consist of a single macrotask followed 0 to many microtasks.
|
||||
*
|
||||
* The wrapper maintains an "inner" and "mount" `Zone`. The application code will executes
|
||||
* in the "inner" zone unless `runOutsideAngular` is explicitely called.
|
||||
*
|
||||
* A typical application will create a singleton `NgZone`. The mount zone is the `Zone` where the singleton has been
|
||||
* instantiated. The default `onMicrotaskEmpty` runs the Angular change detection.
|
||||
*/
|
||||
class NgZoneImpl {
|
||||
static bool isInAngularZone() {
|
||||
return Zone.current['isAngularZone'] == true;
|
||||
}
|
||||
|
||||
// Number of microtasks pending from _innerZone (& descendants)
|
||||
int _pendingMicrotasks = 0;
|
||||
List<Timer> _pendingTimers = [];
|
||||
Function onEnter;
|
||||
Function onLeave;
|
||||
Function setMicrotask;
|
||||
Function setMacrotask;
|
||||
Function onError;
|
||||
|
||||
Zone _outerZone;
|
||||
Zone _innerZone;
|
||||
/**
|
||||
* Associates with this
|
||||
*
|
||||
* - a "mount" [Zone], which is a the one that instantiated this.
|
||||
* - an "inner" [Zone], which is a child of the mount [Zone].
|
||||
*
|
||||
* @param {bool} trace whether to enable long stack trace. They should only be
|
||||
* enabled in development mode as they significantly impact perf.
|
||||
*/
|
||||
NgZoneImpl({
|
||||
bool trace,
|
||||
Function this.onEnter,
|
||||
Function this.onLeave,
|
||||
Function this.setMicrotask,
|
||||
Function this.setMacrotask,
|
||||
Function this.onError
|
||||
}) {
|
||||
_outerZone = Zone.current;
|
||||
|
||||
if (trace) {
|
||||
_innerZone = Chain.capture(
|
||||
() => _createInnerZone(Zone.current),
|
||||
onError: _onErrorWithLongStackTrace
|
||||
);
|
||||
} else {
|
||||
_innerZone = _createInnerZone(
|
||||
Zone.current,
|
||||
handleUncaughtError: _onErrorWithoutLongStackTrace
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Zone _createInnerZone(Zone zone, {handleUncaughtError}) {
|
||||
return zone.fork(
|
||||
specification: new ZoneSpecification(
|
||||
scheduleMicrotask: _scheduleMicrotask,
|
||||
run: _run,
|
||||
runUnary: _runUnary,
|
||||
runBinary: _runBinary,
|
||||
handleUncaughtError: handleUncaughtError,
|
||||
createTimer: _createTimer),
|
||||
zoneValues: {'isAngularZone': true}
|
||||
);
|
||||
}
|
||||
|
||||
dynamic runInnerGuarded(fn()) {
|
||||
return _innerZone.runGuarded(fn);
|
||||
}
|
||||
|
||||
dynamic runInner(fn()) {
|
||||
return _innerZone.run(fn);
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs `fn` in the mount zone and returns whatever it returns.
|
||||
*
|
||||
* In a typical app where the inner zone is the Angular zone, this allows one to escape Angular's
|
||||
* auto-digest mechanism.
|
||||
*
|
||||
* ```
|
||||
* void myFunction(NgZone zone, Element element) {
|
||||
* element.onClick.listen(() {
|
||||
* // auto-digest will run after element click.
|
||||
* });
|
||||
* zone.runOutsideAngular(() {
|
||||
* element.onMouseMove.listen(() {
|
||||
* // auto-digest will NOT run after mouse move
|
||||
* });
|
||||
* });
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
dynamic runOuter(fn()) {
|
||||
return _outerZone.run(fn);
|
||||
}
|
||||
|
||||
dynamic _run(Zone self, ZoneDelegate parent, Zone zone, fn()) {
|
||||
try {
|
||||
onEnter();
|
||||
return parent.run(zone, fn);
|
||||
} finally {
|
||||
onLeave();
|
||||
}
|
||||
}
|
||||
|
||||
dynamic _runUnary(Zone self, ZoneDelegate parent, Zone zone, fn(arg), arg) =>
|
||||
_run(self, parent, zone, () => fn(arg));
|
||||
|
||||
dynamic _runBinary(Zone self, ZoneDelegate parent, Zone zone, fn(arg1, arg2),
|
||||
arg1, arg2) =>
|
||||
_run(self, parent, zone, () => fn(arg1, arg2));
|
||||
|
||||
void _scheduleMicrotask(Zone self, ZoneDelegate parent, Zone zone, fn) {
|
||||
if (_pendingMicrotasks == 0) {
|
||||
setMicrotask(true);
|
||||
}
|
||||
_pendingMicrotasks++;
|
||||
var microtask = () {
|
||||
try {
|
||||
fn();
|
||||
} finally {
|
||||
_pendingMicrotasks--;
|
||||
if (_pendingMicrotasks == 0) {
|
||||
setMicrotask(false);
|
||||
}
|
||||
}
|
||||
};
|
||||
parent.scheduleMicrotask(zone, microtask);
|
||||
}
|
||||
|
||||
// Called by Chain.capture() on errors when long stack traces are enabled
|
||||
void _onErrorWithLongStackTrace(error, Chain chain) {
|
||||
final traces = chain.terse.traces.map((t) => t.toString()).toList();
|
||||
onError(new NgZoneError(error, traces));
|
||||
}
|
||||
|
||||
// Outer zone handleUnchaughtError when long stack traces are not used
|
||||
void _onErrorWithoutLongStackTrace(Zone self, ZoneDelegate parent, Zone zone,
|
||||
error, StackTrace trace)
|
||||
{
|
||||
onError(new NgZoneError(error, [trace.toString()]));
|
||||
}
|
||||
|
||||
Timer _createTimer(
|
||||
Zone self, ZoneDelegate parent, Zone zone, Duration duration, fn()) {
|
||||
WrappedTimer wrappedTimer;
|
||||
var cb = () {
|
||||
try {
|
||||
fn();
|
||||
} finally {
|
||||
_pendingTimers.remove(wrappedTimer);
|
||||
setMacrotask(_pendingTimers.isNotEmpty);
|
||||
}
|
||||
};
|
||||
Timer timer = parent.createTimer(zone, duration, cb);
|
||||
wrappedTimer = new WrappedTimer(timer);
|
||||
wrappedTimer.addOnCancelCb(() {
|
||||
_pendingTimers.remove(wrappedTimer);
|
||||
setMacrotask(_pendingTimers.isNotEmpty);
|
||||
});
|
||||
|
||||
_pendingTimers.add(wrappedTimer);
|
||||
setMacrotask(true);
|
||||
return wrappedTimer;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
import 'dart:collection';
|
||||
|
||||
class TestIterable extends IterableBase<int> {
|
||||
List<int> list = [];
|
||||
Iterator<int> get iterator => list.iterator;
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
/// This file contains tests that make sense only in Dart world, such as
|
||||
/// verifying that things are valid constants.
|
||||
library angular2.test.di.binding_dart_spec;
|
||||
|
||||
import 'dart:mirrors';
|
||||
import 'package:@angular/core/testing/testing_internal.dart';
|
||||
import 'package:angular2/core.dart';
|
||||
|
||||
main() {
|
||||
describe('Binding', () {
|
||||
it('can create constant from token', () {
|
||||
expect(const Binding(Foo).token).toBe(Foo);
|
||||
});
|
||||
|
||||
it('can create constant from class', () {
|
||||
expect(const Binding(Foo, toClass: Bar).toClass).toBe(Bar);
|
||||
});
|
||||
|
||||
it('can create constant from value', () {
|
||||
expect(const Binding(Foo, toValue: 5).toValue).toBe(5);
|
||||
});
|
||||
|
||||
it('can create constant from alias', () {
|
||||
expect(const Binding(Foo, toAlias: Bar).toAlias).toBe(Bar);
|
||||
});
|
||||
|
||||
it('can create constant from factory', () {
|
||||
expect(const Binding(Foo, toFactory: fn).toFactory).toBe(fn);
|
||||
});
|
||||
|
||||
it('can be used in annotation', () {
|
||||
ClassMirror mirror = reflectType(Annotated);
|
||||
var bindings = mirror.metadata[0].reflectee.bindings;
|
||||
expect(bindings.length).toBe(5);
|
||||
bindings.forEach((b) {
|
||||
expect(b).toBeA(Binding);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
class Foo {}
|
||||
|
||||
class Bar extends Foo {}
|
||||
|
||||
fn() => null;
|
||||
|
||||
class Annotation {
|
||||
final List bindings;
|
||||
const Annotation(this.bindings);
|
||||
}
|
||||
|
||||
@Annotation(const [
|
||||
const Binding(Foo),
|
||||
const Binding(Foo, toClass: Bar),
|
||||
const Binding(Foo, toValue: 5),
|
||||
const Binding(Foo, toAlias: Bar),
|
||||
const Binding(Foo, toFactory: fn)
|
||||
])
|
||||
class Annotated {}
|
||||
@@ -1,34 +0,0 @@
|
||||
library angular2.dom.html5lib_adapter.test;
|
||||
|
||||
import 'package:guinness2/guinness2.dart';
|
||||
import 'package:test/test.dart' hide expect;
|
||||
import 'package:angular2/src/platform/server/html_adapter.dart';
|
||||
|
||||
// A smoke-test of the adapter. It is primarily tested by the compiler.
|
||||
main() {
|
||||
describe('Html5Lib DOM Adapter', () {
|
||||
Html5LibDomAdapter subject;
|
||||
|
||||
beforeEach(() {
|
||||
subject = new Html5LibDomAdapter();
|
||||
});
|
||||
|
||||
it('should parse HTML', () {
|
||||
expect(subject.parse('<div>hi</div>'), isNotNull);
|
||||
});
|
||||
|
||||
it('implements hasAttribute', () {
|
||||
var div = subject.querySelector(
|
||||
subject.parse('<div foo="bar"></div>'), ('div'));
|
||||
expect(subject.hasAttribute(div, 'foo')).toBeTrue();
|
||||
expect(subject.hasAttribute(div, 'bar')).toBeFalse();
|
||||
});
|
||||
|
||||
it('implements getAttribute', () {
|
||||
var div = subject.querySelector(
|
||||
subject.parse('<div foo="bar"></div>'), ('div'));
|
||||
expect(subject.getAttribute(div, 'foo')).toEqual('bar');
|
||||
expect(subject.getAttribute(div, 'bar')).toBe(null);
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
library angular2.test.core.dom.shim_spec;
|
||||
|
||||
main() {
|
||||
// not relevant for dart.
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
library angular2.test.facade.observable_spec;
|
||||
|
||||
main() {
|
||||
//stub to ignore JS Observable specific tests
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
/// This file contains tests that make sense only in Dart
|
||||
library angular2.test.core.forward_ref_integration_spec;
|
||||
|
||||
main() {
|
||||
// Don't run in Dart as it is not relevant, and Dart const rules prevent us from expressing it.
|
||||
}
|
||||
@@ -1,275 +0,0 @@
|
||||
/// This file contains tests that make sense only in Dart
|
||||
library angular2.test.di.integration_dart_spec;
|
||||
|
||||
import 'package:angular2/angular2.dart';
|
||||
import 'package:angular2/core.dart';
|
||||
import 'package:angular2/src/core/debug/debug_node.dart';
|
||||
import 'package:@angular/core/testing/testing_internal.dart';
|
||||
import 'package:observe/observe.dart';
|
||||
import 'package:angular2/src/core/change_detection/differs/default_iterable_differ.dart';
|
||||
import 'package:angular2/src/core/change_detection/change_detection.dart';
|
||||
|
||||
class MockException implements Error {
|
||||
var message;
|
||||
var stackTrace;
|
||||
}
|
||||
|
||||
class NonError {
|
||||
var message;
|
||||
}
|
||||
|
||||
void functionThatThrows() {
|
||||
try {
|
||||
throw new MockException();
|
||||
} catch (e, stack) {
|
||||
// If we lose the stack trace the message will no longer match
|
||||
// the first line in the stack
|
||||
e.message = stack.toString().split('\n')[0];
|
||||
e.stackTrace = stack;
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
void functionThatThrowsNonError() {
|
||||
try {
|
||||
throw new NonError();
|
||||
} catch (e, stack) {
|
||||
// If we lose the stack trace the message will no longer match
|
||||
// the first line in the stack
|
||||
e.message = stack.toString().split('\n')[0];
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
main() {
|
||||
describe('Error handling', () {
|
||||
it(
|
||||
'should preserve Error stack traces thrown from components',
|
||||
inject([TestComponentBuilder, AsyncTestCompleter], (tb, async) {
|
||||
tb
|
||||
.overrideView(
|
||||
Dummy,
|
||||
new ViewMetadata(
|
||||
template: '<throwing-component></throwing-component>',
|
||||
directives: [ThrowingComponent]))
|
||||
.createAsync(Dummy)
|
||||
.catchError((e, stack) {
|
||||
expect(e).toContainError("MockException");
|
||||
expect(e).toContainError("functionThatThrows");
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
||||
it(
|
||||
'should preserve non-Error stack traces thrown from components',
|
||||
inject([TestComponentBuilder, AsyncTestCompleter], (tb, async) {
|
||||
tb
|
||||
.overrideView(
|
||||
Dummy,
|
||||
new ViewMetadata(
|
||||
template: '<throwing-component2></throwing-component2>',
|
||||
directives: [ThrowingComponent2]))
|
||||
.createAsync(Dummy)
|
||||
.catchError((e, stack) {
|
||||
expect(e).toContainError("NonError");
|
||||
expect(e).toContainError("functionThatThrows");
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
});
|
||||
|
||||
describe('Property access', () {
|
||||
it(
|
||||
'should distinguish between map and property access',
|
||||
inject([TestComponentBuilder, AsyncTestCompleter], (tb, async) {
|
||||
tb
|
||||
.overrideView(
|
||||
Dummy,
|
||||
new ViewMetadata(
|
||||
template: '<property-access></property-access>',
|
||||
directives: [PropertyAccess]))
|
||||
.createAsync(Dummy)
|
||||
.then((tc) {
|
||||
tc.detectChanges();
|
||||
expect(asNativeElements(tc.debugElement.children))
|
||||
.toHaveText('prop:foo-prop;map:foo-map');
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
||||
it(
|
||||
'should not fallback on map access if property missing',
|
||||
inject([TestComponentBuilder, AsyncTestCompleter], (tb, async) {
|
||||
tb
|
||||
.overrideView(
|
||||
Dummy,
|
||||
new ViewMetadata(
|
||||
template: '<no-property-access></no-property-access>',
|
||||
directives: [NoPropertyAccess]))
|
||||
.createAsync(Dummy)
|
||||
.then((tc) {
|
||||
expect(() => tc.detectChanges())
|
||||
.toThrowError(new RegExp('property not found'));
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
});
|
||||
|
||||
describe('OnChange', () {
|
||||
it(
|
||||
'should be notified of changes',
|
||||
inject([TestComponentBuilder, AsyncTestCompleter], (tb, async) {
|
||||
tb
|
||||
.overrideView(
|
||||
Dummy,
|
||||
new ViewMetadata(
|
||||
template: '''<on-change [prop]="'hello'"></on-change>''',
|
||||
directives: [OnChangeComponent]))
|
||||
.createAsync(Dummy)
|
||||
.then((tc) {
|
||||
tc.detectChanges();
|
||||
var cmp = tc.debugElement.children[0]
|
||||
.inject(OnChangeComponent);
|
||||
expect(cmp.prop).toEqual('hello');
|
||||
expect(cmp.changes.containsKey('prop')).toEqual(true);
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
});
|
||||
|
||||
describe("ObservableListDiff", () {
|
||||
it(
|
||||
'should be notified of changes',
|
||||
fakeAsync(inject([TestComponentBuilder, Log],
|
||||
(TestComponentBuilder tcb, Log log) {
|
||||
tcb
|
||||
.overrideView(
|
||||
Dummy,
|
||||
new ViewMetadata(
|
||||
template:
|
||||
'''<component-with-observable-list [list]="value"></component-with-observable-list>''',
|
||||
directives: [ComponentWithObservableList]))
|
||||
.createAsync(Dummy)
|
||||
.then((tc) {
|
||||
tc.debugElement.componentInstance.value =
|
||||
new ObservableList.from([1, 2]);
|
||||
|
||||
tc.detectChanges();
|
||||
|
||||
expect(log.result()).toEqual("check");
|
||||
expect(asNativeElements(tc.debugElement.children))
|
||||
.toHaveText('12');
|
||||
|
||||
tc.detectChanges();
|
||||
|
||||
// we did not change the list => no checks
|
||||
expect(log.result()).toEqual("check");
|
||||
|
||||
tc.debugElement.componentInstance.value.add(3);
|
||||
|
||||
flushMicrotasks();
|
||||
|
||||
tc.detectChanges();
|
||||
|
||||
// we changed the list => a check
|
||||
expect(log.result()).toEqual("check; check");
|
||||
expect(asNativeElements(tc.debugElement.children))
|
||||
.toHaveText('123');
|
||||
|
||||
// we replaced the list => a check
|
||||
tc.debugElement.componentInstance.value =
|
||||
new ObservableList.from([5, 6, 7]);
|
||||
|
||||
tc.detectChanges();
|
||||
|
||||
expect(log.result()).toEqual("check; check; check");
|
||||
expect(asNativeElements(tc.debugElement.children))
|
||||
.toHaveText('567');
|
||||
});
|
||||
})));
|
||||
});
|
||||
}
|
||||
|
||||
@Component(selector: 'dummy')
|
||||
class Dummy {
|
||||
dynamic value;
|
||||
}
|
||||
|
||||
@Component(selector: 'throwing-component')
|
||||
@View(template: '')
|
||||
class ThrowingComponent {
|
||||
ThrowingComponent() {
|
||||
functionThatThrows();
|
||||
}
|
||||
}
|
||||
|
||||
@Component(selector: 'throwing-component2')
|
||||
@View(template: '')
|
||||
class ThrowingComponent2 {
|
||||
ThrowingComponent2() {
|
||||
functionThatThrowsNonError();
|
||||
}
|
||||
}
|
||||
|
||||
@proxy
|
||||
class PropModel implements Map {
|
||||
final String foo = 'foo-prop';
|
||||
|
||||
operator [](_) => 'foo-map';
|
||||
|
||||
noSuchMethod(_) {
|
||||
throw 'property not found';
|
||||
}
|
||||
}
|
||||
|
||||
@Component(selector: 'property-access')
|
||||
@View(template: '''prop:{{model.foo}};map:{{model['foo']}}''')
|
||||
class PropertyAccess {
|
||||
final model = new PropModel();
|
||||
}
|
||||
|
||||
@Component(selector: 'no-property-access')
|
||||
@View(template: '''{{model.doesNotExist}}''')
|
||||
class NoPropertyAccess {
|
||||
final model = new PropModel();
|
||||
}
|
||||
|
||||
@Component(selector: 'on-change', inputs: const ['prop'])
|
||||
@View(template: '')
|
||||
class OnChangeComponent implements OnChanges {
|
||||
Map changes;
|
||||
String prop;
|
||||
|
||||
@override
|
||||
void ngOnChanges(Map changes) {
|
||||
this.changes = changes;
|
||||
}
|
||||
}
|
||||
|
||||
@Component(
|
||||
selector: 'component-with-observable-list',
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
inputs: const ['list'],
|
||||
providers: const [
|
||||
const Binding(IterableDiffers,
|
||||
toValue: const IterableDiffers(const [
|
||||
const ObservableListDiffFactory(),
|
||||
const DefaultIterableDifferFactory()
|
||||
]))
|
||||
])
|
||||
@View(
|
||||
template:
|
||||
'<span *ngFor="let item of list">{{item}}</span><directive-logging-checks></directive-logging-checks>',
|
||||
directives: const [NgFor, DirectiveLoggingChecks])
|
||||
class ComponentWithObservableList {
|
||||
Iterable list;
|
||||
}
|
||||
|
||||
@Directive(selector: 'directive-logging-checks')
|
||||
class DirectiveLoggingChecks implements DoCheck {
|
||||
Log log;
|
||||
|
||||
DirectiveLoggingChecks(this.log);
|
||||
|
||||
ngDoCheck() => log.add("check");
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
library angular2.test.core.annotations.decorators_dart_spec;
|
||||
|
||||
main() {
|
||||
// not relavant for dart.
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
/// This file contains tests that make sense only in Dart
|
||||
library angular2.test.core.wtf_impl;
|
||||
|
||||
import 'package:@angular/core/testing/testing_internal.dart';
|
||||
import 'package:angular2/src/core/profile/wtf_impl.dart' as impl;
|
||||
|
||||
main() {
|
||||
describe('WTF', () {
|
||||
describe('getArgSize', () {
|
||||
it("should parse args", () {
|
||||
expect(impl.getArgSize('foo#bar')).toBe(0);
|
||||
expect(impl.getArgSize('foo#bar()')).toBe(0);
|
||||
expect(impl.getArgSize('foo#bar(foo bar)')).toBe(1);
|
||||
expect(impl.getArgSize('foo#bar(foo bar, baz q)')).toBe(2);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
class ClassDecorator {
|
||||
final dynamic value;
|
||||
|
||||
const ClassDecorator(this.value);
|
||||
}
|
||||
|
||||
class ParamDecorator {
|
||||
final dynamic value;
|
||||
|
||||
const ParamDecorator(this.value);
|
||||
}
|
||||
|
||||
class PropDecorator {
|
||||
final dynamic value;
|
||||
|
||||
const PropDecorator(this.value);
|
||||
}
|
||||
|
||||
ClassDecorator classDecorator(value) {
|
||||
return new ClassDecorator(value);
|
||||
}
|
||||
|
||||
ParamDecorator paramDecorator(value) {
|
||||
return new ParamDecorator(value);
|
||||
}
|
||||
|
||||
PropDecorator propDecorator(value) {
|
||||
return new PropDecorator(value);
|
||||
}
|
||||
|
||||
class HasGetterAndSetterDecorators {
|
||||
@PropDecorator("get") get a {}
|
||||
@PropDecorator("set") set a(v) {}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
library core.spies;
|
||||
|
||||
import 'package:angular2/core.dart';
|
||||
import 'package:angular2/src/core/change_detection/change_detection.dart';
|
||||
import 'package:angular2/src/platform/dom/dom_adapter.dart';
|
||||
import 'package:@angular/core/testing/testing_internal.dart';
|
||||
|
||||
@proxy
|
||||
class SpyChangeDetectorRef extends SpyObject implements ChangeDetectorRef {}
|
||||
|
||||
@proxy
|
||||
class SpyIterableDifferFactory extends SpyObject
|
||||
implements IterableDifferFactory {}
|
||||
|
||||
@proxy
|
||||
class SpyElementRef extends SpyObject implements ElementRef {}
|
||||
|
||||
@proxy
|
||||
class SpyDomAdapter extends SpyObject implements DomAdapter {}
|
||||
@@ -1,5 +0,0 @@
|
||||
library angular2.test.util.decorators_dart_spec;
|
||||
|
||||
main() {
|
||||
// not relavant for dart.
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
// This symbol is not used on the Dart side. This exists just as a stub.
|
||||
async(Function fn) {
|
||||
throw 'async() test wrapper not available for Dart.';
|
||||
}
|
||||
@@ -1,103 +0,0 @@
|
||||
library testing.fake_async;
|
||||
|
||||
import 'dart:async' show runZoned, ZoneSpecification;
|
||||
import 'package:quiver/testing/async.dart' as quiver;
|
||||
import 'package:angular2/src/facade/exceptions.dart' show BaseException;
|
||||
|
||||
const _u = const Object();
|
||||
|
||||
quiver.FakeAsync _fakeAsync = null;
|
||||
|
||||
/**
|
||||
* Wraps the [fn] to be executed in the fakeAsync zone:
|
||||
* - microtasks are manually executed by calling [flushMicrotasks],
|
||||
* - timers are synchronous, [tick] simulates the asynchronous passage of time.
|
||||
*
|
||||
* If there are any pending timers at the end of the function, an exception
|
||||
* will be thrown.
|
||||
*
|
||||
* Can be used to wrap inject() calls.
|
||||
*
|
||||
* Returns a `Function` that wraps [fn].
|
||||
*/
|
||||
Function fakeAsync(Function fn) {
|
||||
if (_fakeAsync != null) {
|
||||
throw 'fakeAsync() calls can not be nested';
|
||||
}
|
||||
|
||||
return ([a0 = _u,
|
||||
a1 = _u,
|
||||
a2 = _u,
|
||||
a3 = _u,
|
||||
a4 = _u,
|
||||
a5 = _u,
|
||||
a6 = _u,
|
||||
a7 = _u,
|
||||
a8 = _u,
|
||||
a9 = _u]) {
|
||||
// runZoned() to install a custom exception handler that re-throws
|
||||
return runZoned(() {
|
||||
return new quiver.FakeAsync().run((quiver.FakeAsync async) {
|
||||
try {
|
||||
_fakeAsync = async;
|
||||
List args = [a0, a1, a2, a3, a4, a5, a6, a7, a8, a9]
|
||||
.takeWhile((a) => a != _u)
|
||||
.toList();
|
||||
var res = Function.apply(fn, args);
|
||||
_fakeAsync.flushMicrotasks();
|
||||
|
||||
if (async.periodicTimerCount > 0) {
|
||||
throw new BaseException('${async.periodicTimerCount} periodic '
|
||||
'timer(s) still in the queue.');
|
||||
}
|
||||
|
||||
if (async.nonPeriodicTimerCount > 0) {
|
||||
throw new BaseException('${async.nonPeriodicTimerCount} timer(s) '
|
||||
'still in the queue.');
|
||||
}
|
||||
|
||||
return res;
|
||||
} finally {
|
||||
_fakeAsync = null;
|
||||
}
|
||||
});
|
||||
},
|
||||
zoneSpecification: new ZoneSpecification(
|
||||
handleUncaughtError: (self, parent, zone, error, stackTrace) =>
|
||||
throw error));
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Simulates the asynchronous passage of [millis] milliseconds for the timers
|
||||
* in the fakeAsync zone.
|
||||
*
|
||||
* The microtasks queue is drained at the very start of this function and after
|
||||
* any timer callback has been executed.
|
||||
*/
|
||||
void tick([int millis = 0]) {
|
||||
_assertInFakeAsyncZone();
|
||||
var duration = new Duration(milliseconds: millis);
|
||||
_fakeAsync.elapse(duration);
|
||||
}
|
||||
|
||||
/**
|
||||
* This is not needed in Dart. Because quiver correctly removes a timer when
|
||||
* it throws an exception.
|
||||
*/
|
||||
void clearPendingTimers() {}
|
||||
|
||||
/**
|
||||
* Flush any pending microtasks.
|
||||
*/
|
||||
void flushMicrotasks() {
|
||||
_assertInFakeAsyncZone();
|
||||
_fakeAsync.flushMicrotasks();
|
||||
}
|
||||
|
||||
void _assertInFakeAsyncZone() {
|
||||
if (_fakeAsync == null) {
|
||||
throw new BaseException('The code should be running in the fakeAsync zone '
|
||||
'to call this function');
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
library testing.lang_utils;
|
||||
|
||||
import 'dart:mirrors';
|
||||
|
||||
Type getTypeOf(instance) => instance.runtimeType;
|
||||
|
||||
dynamic instantiateType(Type type, [List params = const []]) {
|
||||
var cm = reflectClass(type);
|
||||
return cm.newInstance(new Symbol(''), params).reflectee;
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
library angular2.src.testing.testing;
|
||||
|
||||
// empty as this file is for external TS/js users and should not be transpiled to dart
|
||||
@@ -1,69 +0,0 @@
|
||||
library angular2.src.testing.testing_internal;
|
||||
|
||||
import 'testing_internal_core.dart' as core;
|
||||
export 'testing_internal_core.dart'
|
||||
hide
|
||||
beforeEachProviders,
|
||||
beforeEachBindings,
|
||||
beforeEach,
|
||||
it,
|
||||
iit,
|
||||
xit,
|
||||
testSetup,
|
||||
describe,
|
||||
ddescribe,
|
||||
xdescribe;
|
||||
|
||||
import 'package:angular2/platform/testing/browser.dart';
|
||||
import 'package:angular2/src/facade/collection.dart' show StringMapWrapper;
|
||||
import "package:angular2/src/core/zone/ng_zone.dart" show NgZone;
|
||||
|
||||
export 'test_injector.dart' show inject;
|
||||
|
||||
void testSetup() {
|
||||
core.setDartBaseTestProviders(TEST_BROWSER_PLATFORM_PROVIDERS, TEST_BROWSER_APPLICATION_PROVIDERS);
|
||||
}
|
||||
|
||||
void beforeEachProviders(Function fn) {
|
||||
testSetup();
|
||||
core.beforeEachProviders(fn);
|
||||
}
|
||||
|
||||
@Deprecated('using beforeEachProviders instead')
|
||||
void beforeEachBindings(Function fn) {
|
||||
beforeEachProviders(fn);
|
||||
}
|
||||
|
||||
void beforeEach(fn) {
|
||||
testSetup();
|
||||
core.beforeEach(fn);
|
||||
}
|
||||
|
||||
void it(name, fn, [timeOut = null]) {
|
||||
core.it(name, fn, timeOut);
|
||||
}
|
||||
|
||||
void iit(name, fn, [timeOut = null]) {
|
||||
core.iit(name, fn, timeOut);
|
||||
}
|
||||
|
||||
void xit(name, fn, [timeOut = null]) {
|
||||
core.xit(name, fn, timeOut);
|
||||
}
|
||||
|
||||
void describe(name, fn) {
|
||||
testSetup();
|
||||
core.describe(name, fn);
|
||||
}
|
||||
|
||||
void ddescribe(name, fn) {
|
||||
testSetup();
|
||||
core.ddescribe(name, fn);
|
||||
}
|
||||
|
||||
void xdescribe(name, fn) {
|
||||
testSetup();
|
||||
core.xdescribe(name, fn);
|
||||
}
|
||||
|
||||
bool isInInnerZone() => NgZone.isInAngularZone();
|
||||
Reference in New Issue
Block a user