chore: remove obsolete files (#10240)
This commit is contained in:
parent
e34eb4520f
commit
b652a7fc9f
1583
gulpfile.js.old
1583
gulpfile.js.old
File diff suppressed because it is too large
Load Diff
|
@ -1,6 +0,0 @@
|
|||
Angular2
|
||||
=========
|
||||
|
||||
The sources for this package are in the main [Angular2](https://github.com/angular/angular) repo. Please file issues and pull requests against that repo. This is the repository for the upcoming 2.0 version. If you're looking for the current official version of Angular you should go to [angular/angular.js](https://github.com/angular/angular.js)
|
||||
|
||||
License: Apache MIT 2.0
|
|
@ -1 +0,0 @@
|
|||
export 'index.dart';
|
|
@ -1,63 +0,0 @@
|
|||
library angular2.directives.observable_list_iterable_diff;
|
||||
|
||||
import 'package:observe/observe.dart' show ObservableList;
|
||||
import 'package:angular2/core.dart';
|
||||
import 'package:angular2/src/core/change_detection/differs/default_iterable_differ.dart';
|
||||
import 'dart:async';
|
||||
|
||||
class ObservableListDiff extends DefaultIterableDiffer {
|
||||
ChangeDetectorRef _ref;
|
||||
ObservableListDiff(this._ref);
|
||||
|
||||
bool _updated = true;
|
||||
ObservableList _collection;
|
||||
StreamSubscription _subscription;
|
||||
|
||||
onDestroy() {
|
||||
if (this._subscription != null) {
|
||||
this._subscription.cancel();
|
||||
this._subscription = null;
|
||||
this._collection = null;
|
||||
}
|
||||
}
|
||||
|
||||
DefaultIterableDiffer diff(ObservableList collection) {
|
||||
if (collection is! ObservableList) {
|
||||
throw "Cannot change the type of a collection";
|
||||
}
|
||||
|
||||
// A new collection instance is passed in.
|
||||
// - We need to set up a listener.
|
||||
// - We need to diff collection.
|
||||
if (!identical(_collection, collection)) {
|
||||
_collection = collection;
|
||||
|
||||
if (_subscription != null) _subscription.cancel();
|
||||
_subscription = collection.changes.listen((_) {
|
||||
_updated = true;
|
||||
_ref.markForCheck();
|
||||
});
|
||||
_updated = false;
|
||||
return super.diff(collection);
|
||||
|
||||
// An update has been registered since the last change detection check.
|
||||
// - We reset the flag.
|
||||
// - We diff the collection.
|
||||
} else if (_updated) {
|
||||
_updated = false;
|
||||
return super.diff(collection);
|
||||
|
||||
// No updates has been registered.
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ObservableListDiffFactory implements IterableDifferFactory {
|
||||
const ObservableListDiffFactory();
|
||||
bool supports(obj) => obj is ObservableList;
|
||||
IterableDiffer create(ChangeDetectorRef cdRef, [Function trackByFn]) {
|
||||
return new ObservableListDiff(cdRef);
|
||||
}
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
library angular2.core.forms.normalize_validators;
|
||||
|
||||
import 'package:angular2/src/common/forms/directives/validators.dart' show Validator;
|
||||
|
||||
Function normalizeValidator(dynamic validator){
|
||||
if (validator is Validator) {
|
||||
return (c) => validator.validate(c);
|
||||
} else {
|
||||
return validator;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Function normalizeAsyncValidator(dynamic validator){
|
||||
if (validator is Validator) {
|
||||
return (c) => validator.validate(c);
|
||||
} else {
|
||||
return validator;
|
||||
}
|
||||
}
|
|
@ -51,9 +51,6 @@ var defaultLocale: string = 'en-US';
|
|||
*
|
||||
* In javascript, only the components specified will be respected (not the ordering,
|
||||
* punctuations, ...) and details of the formatting will be dependent on the locale.
|
||||
* On the other hand in Dart version, you can also include quoted text as well as some extra
|
||||
* date/time components such as quarter. For more information see:
|
||||
* https://www.dartdocs.org/documentation/intl/0.13.0/intl/DateFormat-class.html
|
||||
*
|
||||
* `format` can also be one of the following predefined formats:
|
||||
*
|
||||
|
|
|
@ -1,102 +0,0 @@
|
|||
library angular2.test.directives.observable_list_iterable_diff_spec;
|
||||
|
||||
import 'package:angular2/testing_internal.dart';
|
||||
import 'package:observe/observe.dart' show ObservableList;
|
||||
import 'package:angular2/core.dart' show ChangeDetectorRef;
|
||||
import 'package:angular2/common.dart' show ObservableListDiffFactory;
|
||||
|
||||
@proxy
|
||||
class SpyChangeDetectorRef extends SpyObject implements ChangeDetectorRef {}
|
||||
|
||||
main() {
|
||||
describe('ObservableListDiff', () {
|
||||
var factory, changeDetectorRef;
|
||||
|
||||
beforeEach(() {
|
||||
factory = const ObservableListDiffFactory();
|
||||
changeDetectorRef = new SpyChangeDetectorRef();
|
||||
});
|
||||
|
||||
describe("supports", () {
|
||||
it("should be true for ObservableList", () {
|
||||
expect(factory.supports(new ObservableList())).toBe(true);
|
||||
});
|
||||
|
||||
it("should be false otherwise", () {
|
||||
expect(factory.supports([1, 2, 3])).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
it("should return itself when called the first time", () {
|
||||
final d = factory.create(changeDetectorRef);
|
||||
final c = new ObservableList.from([1, 2]);
|
||||
expect(d.diff(c)).toBe(d);
|
||||
});
|
||||
|
||||
it("should return itself when no changes between the calls", () {
|
||||
final d = factory.create(changeDetectorRef);
|
||||
|
||||
final c = new ObservableList.from([1, 2]);
|
||||
|
||||
d.diff(c);
|
||||
|
||||
expect(d.diff(c)).toBe(null);
|
||||
});
|
||||
|
||||
it("should return the wrapped value once a change has been triggered",
|
||||
fakeAsync(() {
|
||||
final d = factory.create(changeDetectorRef);
|
||||
|
||||
final c = new ObservableList.from([1, 2]);
|
||||
|
||||
d.diff(c);
|
||||
|
||||
c.add(3);
|
||||
|
||||
// same value, because we have not detected the change yet
|
||||
expect(d.diff(c)).toBe(null);
|
||||
|
||||
// now we detect the change
|
||||
flushMicrotasks();
|
||||
expect(d.diff(c)).toBe(d);
|
||||
}));
|
||||
|
||||
it("should request a change detection check upon receiving a change",
|
||||
fakeAsync(() {
|
||||
final d = factory.create(changeDetectorRef);
|
||||
|
||||
final c = new ObservableList.from([1, 2]);
|
||||
d.diff(c);
|
||||
|
||||
c.add(3);
|
||||
flushMicrotasks();
|
||||
|
||||
expect(changeDetectorRef.spy("markForCheck")).toHaveBeenCalledOnce();
|
||||
}));
|
||||
|
||||
it("should return the wrapped value after changing a collection", () {
|
||||
final d = factory.create(changeDetectorRef);
|
||||
|
||||
final c1 = new ObservableList.from([1, 2]);
|
||||
final c2 = new ObservableList.from([3, 4]);
|
||||
|
||||
expect(d.diff(c1)).toBe(d);
|
||||
expect(d.diff(c2)).toBe(d);
|
||||
});
|
||||
|
||||
it("should not unbsubscribe from the stream of chagnes after changing a collection",
|
||||
() {
|
||||
final d = factory.create(changeDetectorRef);
|
||||
|
||||
final c1 = new ObservableList.from([1, 2]);
|
||||
expect(d.diff(c1)).toBe(d);
|
||||
|
||||
final c2 = new ObservableList.from([3, 4]);
|
||||
expect(d.diff(c2)).toBe(d);
|
||||
|
||||
// pushing into the first collection has no effect, and we do not see the change
|
||||
c1.add(3);
|
||||
expect(d.diff(c2)).toBe(null);
|
||||
});
|
||||
});
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
library core.spies;
|
||||
|
||||
import 'package:angular2/common.dart';
|
||||
import 'package:angular2/src/core/change_detection/change_detection.dart';
|
||||
import 'package:angular2/testing_internal.dart';
|
||||
|
||||
@proxy
|
||||
class SpyNgControl extends SpyObject implements NgControl {}
|
||||
|
||||
@proxy
|
||||
class SpyValueAccessor extends SpyObject implements ControlValueAccessor {}
|
||||
|
||||
@proxy
|
||||
class SpyChangeDetectorRef extends SpyObject implements ChangeDetectorRef {}
|
|
@ -1 +0,0 @@
|
|||
export '../core/private_export.dart';
|
|
@ -1 +0,0 @@
|
|||
export './src/core/change_detection/constants.dart' show SelectorMatcher, CssSelector;
|
|
@ -1,3 +0,0 @@
|
|||
library angular2.core.util.asserions;
|
||||
|
||||
void assertArrayOfStrings(String identifier, Object value) {}
|
|
@ -1,69 +0,0 @@
|
|||
library angular2.src.services.url_resolver;
|
||||
|
||||
import 'package:angular2/src/core/di.dart' show Injectable, Inject, Provider;
|
||||
import 'package:angular2/src/facade/lang.dart' show isPresent, StringWrapper;
|
||||
import 'package:angular2/src/core/application_tokens.dart' show PACKAGE_ROOT_URL;
|
||||
|
||||
const _ASSET_SCHEME = 'asset:';
|
||||
|
||||
UrlResolver createUrlResolverWithoutPackagePrefix() {
|
||||
return new UrlResolver.withUrlPrefix(null);
|
||||
}
|
||||
|
||||
UrlResolver createOfflineCompileUrlResolver() {
|
||||
return new UrlResolver.withUrlPrefix(_ASSET_SCHEME);
|
||||
}
|
||||
|
||||
const DEFAULT_PACKAGE_URL_PROVIDER = const Provider(PACKAGE_ROOT_URL, useValue: "/packages");
|
||||
|
||||
@Injectable()
|
||||
class UrlResolver {
|
||||
/// This will be the location where 'package:' Urls will resolve. Default is
|
||||
/// '/packages'
|
||||
final String _packagePrefix;
|
||||
|
||||
UrlResolver([@Inject(PACKAGE_ROOT_URL) this._packagePrefix]);
|
||||
|
||||
/// Creates a UrlResolver that will resolve 'package:' Urls to a different
|
||||
/// prefixed location.
|
||||
const UrlResolver.withUrlPrefix(this._packagePrefix);
|
||||
|
||||
/**
|
||||
* Resolves the `url` given the `baseUrl`:
|
||||
* - when the `url` is null, the `baseUrl` is returned,
|
||||
* - if `url` is relative ('path/to/here', './path/to/here'), the resolved url is a combination of
|
||||
* `baseUrl` and `url`,
|
||||
* - if `url` is absolute (it has a scheme: 'http://', 'https://' or start with '/'), the `url` is
|
||||
* returned as is (ignoring the `baseUrl`)
|
||||
*
|
||||
* @param {string} baseUrl
|
||||
* @param {string} url
|
||||
* @returns {string} the resolved URL
|
||||
*/
|
||||
String resolve(String baseUrl, String url) {
|
||||
Uri uri = Uri.parse(url);
|
||||
|
||||
if (isPresent(baseUrl) && baseUrl.length > 0) {
|
||||
Uri baseUri = Uri.parse(baseUrl);
|
||||
uri = baseUri.resolveUri(uri);
|
||||
}
|
||||
|
||||
var prefix = this._packagePrefix;
|
||||
if (prefix != null && uri.scheme == 'package') {
|
||||
if (prefix == _ASSET_SCHEME) {
|
||||
var pathSegments = uri.pathSegments.toList()..insert(1, 'lib');
|
||||
return new Uri(scheme: 'asset', pathSegments: pathSegments).toString();
|
||||
} else {
|
||||
prefix = StringWrapper.stripRight(prefix, '/');
|
||||
var path = StringWrapper.stripLeft(uri.path, '/');
|
||||
return '$prefix/$path';
|
||||
}
|
||||
} else {
|
||||
return uri.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String getUrlScheme(String url) {
|
||||
return Uri.parse(url).scheme;
|
||||
}
|
|
@ -1,148 +0,0 @@
|
|||
library angular2.test.core.compiler.directive_lifecycle_spec;
|
||||
|
||||
import 'package:angular2/testing_internal.dart';
|
||||
import 'package:angular2/src/compiler/directive_lifecycle_reflector.dart';
|
||||
import 'package:angular2/src/core/metadata/lifecycle_hooks.dart';
|
||||
|
||||
main() {
|
||||
describe('Create DirectiveMetadata', () {
|
||||
describe('lifecycle', () {
|
||||
describe("ngOnChanges", () {
|
||||
it("should be true when the directive has the ngOnChanges method", () {
|
||||
expect(hasLifecycleHook(
|
||||
LifecycleHooks.OnChanges, DirectiveImplementingOnChanges))
|
||||
.toBe(true);
|
||||
});
|
||||
|
||||
it("should be false otherwise", () {
|
||||
expect(hasLifecycleHook(LifecycleHooks.OnChanges, DirectiveNoHooks))
|
||||
.toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("ngOnDestroy", () {
|
||||
it("should be true when the directive has the ngOnDestroy method", () {
|
||||
expect(hasLifecycleHook(
|
||||
LifecycleHooks.OnDestroy, DirectiveImplementingOnDestroy))
|
||||
.toBe(true);
|
||||
});
|
||||
|
||||
it("should be false otherwise", () {
|
||||
expect(hasLifecycleHook(LifecycleHooks.OnDestroy, DirectiveNoHooks))
|
||||
.toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("ngOnInit", () {
|
||||
it("should be true when the directive has the ngOnInit method", () {
|
||||
expect(hasLifecycleHook(
|
||||
LifecycleHooks.OnInit, DirectiveImplementingOnInit)).toBe(true);
|
||||
});
|
||||
|
||||
it("should be false otherwise", () {
|
||||
expect(hasLifecycleHook(LifecycleHooks.OnInit, DirectiveNoHooks))
|
||||
.toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("ngDoCheck", () {
|
||||
it("should be true when the directive has the ngDoCheck method", () {
|
||||
expect(hasLifecycleHook(
|
||||
LifecycleHooks.DoCheck, DirectiveImplementingOnCheck)).toBe(true);
|
||||
});
|
||||
|
||||
it("should be false otherwise", () {
|
||||
expect(hasLifecycleHook(LifecycleHooks.DoCheck, DirectiveNoHooks))
|
||||
.toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("ngAfterContentInit", () {
|
||||
it("should be true when the directive has the ngAfterContentInit method",
|
||||
() {
|
||||
expect(hasLifecycleHook(LifecycleHooks.AfterContentInit,
|
||||
DirectiveImplementingAfterContentInit)).toBe(true);
|
||||
});
|
||||
|
||||
it("should be false otherwise", () {
|
||||
expect(hasLifecycleHook(
|
||||
LifecycleHooks.AfterContentInit, DirectiveNoHooks)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("ngAfterContentChecked", () {
|
||||
it("should be true when the directive has the ngAfterContentChecked method",
|
||||
() {
|
||||
expect(hasLifecycleHook(LifecycleHooks.AfterContentChecked,
|
||||
DirectiveImplementingAfterContentChecked)).toBe(true);
|
||||
});
|
||||
|
||||
it("should be false otherwise", () {
|
||||
expect(hasLifecycleHook(
|
||||
LifecycleHooks.AfterContentChecked, DirectiveNoHooks))
|
||||
.toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("ngAfterViewInit", () {
|
||||
it("should be true when the directive has the ngAfterViewInit method",
|
||||
() {
|
||||
expect(hasLifecycleHook(LifecycleHooks.AfterViewInit,
|
||||
DirectiveImplementingAfterViewInit)).toBe(true);
|
||||
});
|
||||
|
||||
it("should be false otherwise", () {
|
||||
expect(hasLifecycleHook(
|
||||
LifecycleHooks.AfterViewInit, DirectiveNoHooks)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("ngAfterViewChecked", () {
|
||||
it("should be true when the directive has the ngAfterViewChecked method",
|
||||
() {
|
||||
expect(hasLifecycleHook(LifecycleHooks.AfterViewChecked,
|
||||
DirectiveImplementingAfterViewChecked)).toBe(true);
|
||||
});
|
||||
|
||||
it("should be false otherwise", () {
|
||||
expect(hasLifecycleHook(
|
||||
LifecycleHooks.AfterViewChecked, DirectiveNoHooks)).toBe(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
class DirectiveNoHooks {}
|
||||
|
||||
class DirectiveImplementingOnChanges implements OnChanges {
|
||||
ngOnChanges(_) {}
|
||||
}
|
||||
|
||||
class DirectiveImplementingOnCheck implements DoCheck {
|
||||
ngDoCheck() {}
|
||||
}
|
||||
|
||||
class DirectiveImplementingOnInit implements OnInit {
|
||||
ngOnInit() {}
|
||||
}
|
||||
|
||||
class DirectiveImplementingOnDestroy implements OnDestroy {
|
||||
ngOnDestroy() {}
|
||||
}
|
||||
|
||||
class DirectiveImplementingAfterContentInit implements AfterContentInit {
|
||||
ngAfterContentInit() {}
|
||||
}
|
||||
|
||||
class DirectiveImplementingAfterContentChecked implements AfterContentChecked {
|
||||
ngAfterContentChecked() {}
|
||||
}
|
||||
|
||||
class DirectiveImplementingAfterViewInit implements AfterViewInit {
|
||||
ngAfterViewInit() {}
|
||||
}
|
||||
|
||||
class DirectiveImplementingAfterViewChecked implements AfterViewChecked {
|
||||
ngAfterViewChecked() {}
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
library angular2.test.compiler.metadata_resolver_fixture;
|
||||
|
||||
import "package:angular2/core.dart" show Component;
|
||||
|
||||
// This component is not actually malformed; this fixture is here to
|
||||
// make Dart not complain about a missing import for a test case that only
|
||||
// matters in an JavaScript app.
|
||||
@Component(template: "")
|
||||
class MalformedStylesComponent {}
|
|
@ -1,5 +0,0 @@
|
|||
/**
|
||||
* We don't know how to extract schema in dart, so do nothing.
|
||||
*/
|
||||
extractSchema(fn(List<String> descriptors)) {
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
library compiler.spies;
|
||||
|
||||
import 'package:angular2/src/compiler/xhr.dart';
|
||||
import 'package:angular2/testing_internal.dart';
|
||||
|
||||
@proxy
|
||||
class SpyXHR extends SpyObject implements XHR {}
|
|
@ -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();
|
|
@ -144,8 +144,6 @@ but should use the angular 2 transformer to remove it in your final JS code. Not
|
|||
with running the transformer on your UI code (#3971). You can (and should) pass the file where you call
|
||||
`bootstrap` as an entry point to the transformer, but you should not pass your UI index file
|
||||
to the transformer until that bug is fixed.
|
||||
* In dart we call `asyncApplication` instead of `application` from the render thread because starting an isolate in Dart is asyncronous
|
||||
whereas starting a new WebWorker in JavaScript is a synchronous operation.
|
||||
|
||||
## Writing WebWorker Compatible Components
|
||||
You can do almost everything in a WebWorker component that you can do in a typical Angular 2 Component.
|
||||
|
@ -306,9 +304,6 @@ If you use the MessageBus directly, you are responsible for serializing your mes
|
|||
In JavaScript / TypeScript this means they must be serializable via JavaScript's
|
||||
[structured cloning algorithim](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm).
|
||||
|
||||
In Dart this means they must be valid messages that can be passed through a
|
||||
[SendPort](https://api.dartlang.org/1.12.1/dart-isolate/SendPort/send.html).
|
||||
|
||||
|
||||
### MessageBus and Zones
|
||||
The MessageBus API includes support for [zones](http://www.github.com/angular/zone.js).
|
||||
|
@ -333,36 +328,8 @@ if you do this, you don't need to implement zone or channel support yourself. Yo
|
|||
`MessageBusSink` that extends `GenericMessageBusSink` and a `MessageBusSource` that extends
|
||||
`GenericMessageBusSource`. The `MessageBusSink` must override the `sendMessages` method. This method is
|
||||
given a list of serialized messages that it is required to send through the sink.
|
||||
The `MessageBusSource` needs to provide a [Stream](https://api.dartlang.org/1.12.1/dart-async/Stream-class.html)
|
||||
of incoming messages (either by passing the stream to `GenericMessageBusSource's` constructor or by calling
|
||||
attachTo() with the stream). It also needs to override the abstract `decodeMessages` method. This method is
|
||||
given a List of serialized messages received by the source and should perform any decoding work that needs to be
|
||||
done before the application can read the messages.
|
||||
|
||||
For example, if your MessageBus sends and receives JSON data you would do the following:
|
||||
```Dart
|
||||
import 'package:angular2/src/web_workers/shared/generic_message_bus.dart';
|
||||
import 'dart:convert';
|
||||
|
||||
class JsonMessageBusSink extends GenericMessageBusSink {
|
||||
@override
|
||||
void sendMessages(List<dynamic> messages) {
|
||||
String encodedMessages = JSON.encode(messages);
|
||||
// Send encodedMessages here
|
||||
}
|
||||
}
|
||||
|
||||
class JsonMessageBusSource extends GenericMessageBuSource {
|
||||
JsonMessageBusSource(Stream incomingMessages) : super (incomingMessages);
|
||||
|
||||
@override
|
||||
List<dynamic> decodeMessages(dynamic messages) {
|
||||
return JSON.decode(messages);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Once you've implemented your custom MessageBus in either TypeScript or Dart, you must provide it through DI
|
||||
Once you've implemented your custom MessageBus in either TypeScript, you must provide it through DI
|
||||
during bootstrap like so:
|
||||
|
||||
In TypeScript:
|
||||
|
@ -410,52 +377,6 @@ function initAppThread(zone: NgZone, bus: MyAwesomeMessageBus): void{
|
|||
*/
|
||||
}
|
||||
```
|
||||
In Dart:
|
||||
```Dart
|
||||
// index.dart, running on the UI side
|
||||
import 'package:angular2/core.dart';
|
||||
import 'package:angular2/platform/worker_render.dart';
|
||||
|
||||
main() {
|
||||
var bus = new MyAwesomeMessageBus();
|
||||
platform([WORKER_RENDER_PLATFORM])
|
||||
.application([WORKER_RENDER_APPLICATION_COMMON, new Provider(MessageBus, useValue: bus),
|
||||
new Provider(APP_INITIALIZER,
|
||||
useFactory: (injector) => () => initializeGenericWorkerRenderer(injector),
|
||||
deps: [Injector],
|
||||
multi: true
|
||||
)
|
||||
]);
|
||||
}
|
||||
|
||||
```
|
||||
```Dart
|
||||
// background_index.dart, running on the application side
|
||||
import "package:angular2/platform/worker_app.dart";
|
||||
import "package:angular2/core.dart";
|
||||
import "./app.dart" show MyApp;
|
||||
|
||||
main() {
|
||||
/**
|
||||
* Do initialization work here to set up the app thread and MessageBus;
|
||||
* Once you have a working MessageBus you should bootstrap your app.
|
||||
*/
|
||||
reflector.reflectionCapabilities = new ReflectionCapabilities();
|
||||
platform([WORKER_APP_PLATFORM_PROVIDERS])
|
||||
.application([WORKER_APP_APPLICATION_COMMON, new Provider(MessageBus, useValue: bus),
|
||||
new Provider(APP_INITIALIZER, useFactory: (zone, bus) => () => initAppThread(zone, bus), multi: true, deps: [NgZone, MessageBus])])
|
||||
.bootstrap(MyApp);
|
||||
}
|
||||
|
||||
|
||||
void initAppThread(NgZone zone) {
|
||||
/**
|
||||
* Here you can do any initilization work that requires the app providers to be initialized.
|
||||
* At a minimum, you must attach your bus to the zone and setup a DOM adapter.
|
||||
* Depending on your environment you may choose to do more work here.
|
||||
*/
|
||||
}
|
||||
```
|
||||
Notice how we use the `WORKER_RENDER_APPLICTION_COMMON` providers instead of the `WORKER_RENDER_APPLICATION` providers on the render thread.
|
||||
This is because the `WORKER_RENDER_APPLICATION` providers include an application initializer that starts a new WebWorker/Isolate.
|
||||
The `WORKER_RENDER_APPLICATION_COMMON` providers make no assumption about where your application code lives.
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
library angular2.examples.core.pipes.ts.async_pipe;
|
||||
// TODO(alxhub): Implement an example for Dart.
|
|
@ -1,2 +0,0 @@
|
|||
library angular2.examples.core.pipes.ts.date_pipe;
|
||||
// TODO(alxhub): Implement an example for Dart.
|
|
@ -1,132 +0,0 @@
|
|||
library angular2.core.facade.async;
|
||||
|
||||
import 'dart:async';
|
||||
export 'dart:async' show Stream, StreamController, StreamSubscription;
|
||||
|
||||
export 'promise.dart';
|
||||
|
||||
class TimerWrapper {
|
||||
static Timer setTimeout(fn(), int millis) =>
|
||||
new Timer(new Duration(milliseconds: millis), fn);
|
||||
static void clearTimeout(Timer timer) {
|
||||
timer.cancel();
|
||||
}
|
||||
|
||||
static Timer setInterval(fn(), int millis) {
|
||||
var interval = new Duration(milliseconds: millis);
|
||||
return new Timer.periodic(interval, (Timer timer) {
|
||||
fn();
|
||||
});
|
||||
}
|
||||
|
||||
static void clearInterval(Timer timer) {
|
||||
timer.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
class ObservableWrapper {
|
||||
static StreamSubscription subscribe/*<T>*/(Stream s, onNext(/*=T*/ value),
|
||||
[onError, onComplete]) {
|
||||
return s.listen(onNext,
|
||||
onError: onError, onDone: onComplete, cancelOnError: true);
|
||||
}
|
||||
|
||||
static bool isObservable(obs) {
|
||||
return obs is Stream;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether `emitter` has any subscribers listening to events.
|
||||
*/
|
||||
static bool hasSubscribers(EventEmitter emitter) {
|
||||
return emitter._controller.hasListener;
|
||||
}
|
||||
|
||||
static void dispose(StreamSubscription s) {
|
||||
s.cancel();
|
||||
}
|
||||
|
||||
@Deprecated('Use callEmit() instead')
|
||||
static void callNext(EventEmitter emitter, value) {
|
||||
emitter.add(value);
|
||||
}
|
||||
|
||||
static void callEmit(EventEmitter emitter, value) {
|
||||
emitter.add(value);
|
||||
}
|
||||
|
||||
static void callError(EventEmitter emitter, error) {
|
||||
emitter.addError(error);
|
||||
}
|
||||
|
||||
static void callComplete(EventEmitter emitter) {
|
||||
emitter.close();
|
||||
}
|
||||
|
||||
static Stream fromPromise(Future f) {
|
||||
return new Stream.fromFuture(f);
|
||||
}
|
||||
|
||||
static Future toPromise(Stream s) {
|
||||
return s.single;
|
||||
}
|
||||
}
|
||||
|
||||
class EventEmitter<T> extends Stream<T> {
|
||||
StreamController<T> _controller;
|
||||
|
||||
/// Creates an instance of [EventEmitter], which depending on [isAsync],
|
||||
/// delivers events synchronously or asynchronously.
|
||||
EventEmitter([bool isAsync = true]) {
|
||||
_controller = new StreamController<T>.broadcast(sync: !isAsync);
|
||||
}
|
||||
|
||||
StreamSubscription<T> listen(void onData(T event),
|
||||
{Function onError, void onDone(), bool cancelOnError}) {
|
||||
return _controller.stream.listen(onData,
|
||||
onError: onError, onDone: onDone, cancelOnError: cancelOnError);
|
||||
}
|
||||
|
||||
void add(value) {
|
||||
_controller.add(value);
|
||||
}
|
||||
|
||||
void emit(value) {
|
||||
_controller.add(value);
|
||||
}
|
||||
|
||||
void addError(error) {
|
||||
_controller.addError(error);
|
||||
}
|
||||
|
||||
void close() {
|
||||
_controller.close();
|
||||
}
|
||||
}
|
||||
|
||||
//todo(robwormald): maybe fix in ts2dart?
|
||||
class Subject<T> extends Stream<T> {
|
||||
StreamController<T> _controller;
|
||||
|
||||
Subject([bool isAsync = true]) {
|
||||
_controller = new StreamController<T>.broadcast(sync: !isAsync);
|
||||
}
|
||||
|
||||
StreamSubscription<T> listen(void onData(T data),
|
||||
{Function onError, void onDone(), bool cancelOnError}) {
|
||||
return _controller.stream.listen(onData,
|
||||
onError: onError, onDone: onDone, cancelOnError: cancelOnError);
|
||||
}
|
||||
|
||||
void add(value) {
|
||||
_controller.add(value);
|
||||
}
|
||||
|
||||
void addError(error) {
|
||||
_controller.addError(error);
|
||||
}
|
||||
|
||||
void close() {
|
||||
_controller.close();
|
||||
}
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
library angular.core.facade.base_wrapped_exception;
|
||||
|
||||
/**
|
||||
* A base class for the WrappedException that can be used to identify
|
||||
* a WrappedException from ExceptionHandler without adding circular
|
||||
* dependency.
|
||||
*/
|
||||
class BaseWrappedException extends Error {
|
||||
BaseWrappedException();
|
||||
|
||||
get originalException => null;
|
||||
get originalStack => null;
|
||||
|
||||
String get message => '';
|
||||
String get wrapperMessage => '';
|
||||
dynamic get context => null;
|
||||
}
|
|
@ -1,32 +0,0 @@
|
|||
/**
|
||||
* Dart version of browser APIs. This library depends on 'dart:html' and
|
||||
* therefore can only run in the browser.
|
||||
*/
|
||||
library angular2.src.facade.browser;
|
||||
|
||||
import 'dart:js' show context;
|
||||
import 'dart:html' show Location, window;
|
||||
|
||||
export 'dart:html'
|
||||
show
|
||||
document,
|
||||
window,
|
||||
Element,
|
||||
Node,
|
||||
MouseEvent,
|
||||
KeyboardEvent,
|
||||
Event,
|
||||
EventTarget,
|
||||
History,
|
||||
Location,
|
||||
EventListener;
|
||||
|
||||
Location get location => window.location;
|
||||
|
||||
final _gc = context['gc'];
|
||||
|
||||
void gc() {
|
||||
if (_gc != null) {
|
||||
_gc.apply(const []);
|
||||
}
|
||||
}
|
|
@ -1,287 +0,0 @@
|
|||
library facade.collection;
|
||||
|
||||
import 'dart:collection' show IterableBase;
|
||||
import 'dart:convert' show JsonEncoder;
|
||||
export 'dart:core' show Iterator, Map, List, Set;
|
||||
import 'dart:math' show max, min;
|
||||
|
||||
var jsonEncoder = new JsonEncoder();
|
||||
|
||||
class MapIterator extends Iterator<List> {
|
||||
final Iterator _iterator;
|
||||
final Map _map;
|
||||
|
||||
MapIterator(Map map)
|
||||
: _map = map,
|
||||
_iterator = map.keys.iterator;
|
||||
|
||||
bool moveNext() => _iterator.moveNext();
|
||||
|
||||
List get current {
|
||||
return _iterator.current != null
|
||||
? [_iterator.current, _map[_iterator.current]]
|
||||
: null;
|
||||
}
|
||||
}
|
||||
|
||||
class IterableMap extends IterableBase<List> {
|
||||
final Map _map;
|
||||
|
||||
IterableMap(Map map) : _map = map;
|
||||
|
||||
Iterator<List> get iterator => new MapIterator(_map);
|
||||
}
|
||||
|
||||
class MapWrapper {
|
||||
static Map/*<K,V>*/ clone/*<K,V>*/(Map/*<K,V>*/ m) => new Map.from(m);
|
||||
|
||||
// in opposite to JS, Dart does not create a new map
|
||||
static Map/*<K,V>*/ createFromStringMap/*<K,V>*/(Map/*<K,V>*/ m) => m;
|
||||
|
||||
// in opposite to JS, Dart does not create a new map
|
||||
static Map/*<K,V>*/ toStringMap/*<K,V>*/(Map/*<K,V>*/ m) => m;
|
||||
|
||||
static Map/*<K,V>*/ createFromPairs/*<K,V>*/(List pairs) => pairs.fold(/*<K,V>*/{}, (m, p) {
|
||||
m[p[0]] = p[1];
|
||||
return m;
|
||||
});
|
||||
|
||||
static void clearValues(Map m) {
|
||||
for (var k in m.keys) {
|
||||
m[k] = null;
|
||||
}
|
||||
}
|
||||
|
||||
static Iterable/*<List<dynamic>>*/ iterable/*<K,V>*/(Map/*<K,V>*/ m) => new IterableMap(m);
|
||||
static List/*<K>*/ keys/*<K,V>*/(Map/*<K,V>*/ m) => m.keys.toList();
|
||||
static List/*<V>*/ values/*<K,V>*/(Map/*<K,V>*/ m) => m.values.toList();
|
||||
}
|
||||
|
||||
class StringMapWrapper {
|
||||
static Map/*<String,V>*/ create/*<V>*/() => {};
|
||||
static bool contains/*<V>*/(Map/*<String,V>*/ map, String key) => map.containsKey(key);
|
||||
static get/*<V>*/(Map/*<String,V>*/ map, String key) => map[key];
|
||||
static void set/*<V>*/(Map/*<String,V>*/ map, String key, /*=V*/value) {
|
||||
map[key] = value;
|
||||
}
|
||||
|
||||
static void delete/*<V>*/(Map/*<String,V>*/ m, String k) {
|
||||
m.remove(k);
|
||||
}
|
||||
|
||||
static void forEach/*<V>*/(Map/*<String,V>*/ m, fn(/*=V*/ v, String k)) {
|
||||
m.forEach((k, v) => fn(v, k));
|
||||
}
|
||||
|
||||
static Map/*<String,V>*/ merge/*<V>*/(Map/*<String,V>*/ a, Map/*<String,V>*/ b) {
|
||||
var m = new Map/*<String,V>*/.from(a);
|
||||
if (b != null) {
|
||||
b.forEach((k, v) => m[k] = v);
|
||||
}
|
||||
return m;
|
||||
}
|
||||
|
||||
static List<String> keys(Map<String, dynamic> a) {
|
||||
return a.keys.toList();
|
||||
}
|
||||
|
||||
static List values(Map<String, dynamic> a) {
|
||||
return a.values.toList();
|
||||
}
|
||||
|
||||
static bool isEmpty(Map m) => m.isEmpty;
|
||||
static bool equals/*<V>*/(Map/*<String,V>*/ m1, Map/*<String,V>*/ m2) {
|
||||
if (m1.length != m2.length) {
|
||||
return false;
|
||||
}
|
||||
for (var key in m1.keys) {
|
||||
if (m1[key] != m2[key]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
typedef bool Predicate<T>(T item);
|
||||
|
||||
class ListWrapper {
|
||||
static List/*<T>*/ clone/*<T>*/(Iterable/*<T>*/ l) => new List.from(l);
|
||||
static List/*<T>*/ createFixedSize/*<T>*/(int size) => new List(size);
|
||||
static List/*<T>*/ createGrowableSize/*<T>*/(int size) =>
|
||||
new List.generate(size, (_) => null, growable: true);
|
||||
|
||||
static bool contains(List m, k) => m.contains(k);
|
||||
static int indexOf(List list, value, [int startIndex = 0]) =>
|
||||
list.indexOf(value, startIndex);
|
||||
static int lastIndexOf(List list, value, [int startIndex = null]) =>
|
||||
list.lastIndexOf(value, startIndex == null ? list.length : startIndex);
|
||||
|
||||
static void forEachWithIndex/*<T>*/(List/*<T>*/ list, fn(/*=T*/ item, int index)) {
|
||||
for (var i = 0; i < list.length; ++i) {
|
||||
fn(list[i], i);
|
||||
}
|
||||
}
|
||||
static /*=T*/ first/*<T>*/(List/*<T>*/ list) => list.isEmpty ? null : list.first;
|
||||
static /*=T*/ last/*<T>*/(List/*<T>*/ list) => list.isEmpty ? null : list.last;
|
||||
static List/*<T>*/ reversed/*<T>*/(List/*<T>*/ list) => list.reversed.toList();
|
||||
static List/*<T>*/ concat/*<T>*/(List/*<T>*/ a, List/*<T>*/ b) {
|
||||
return new List()
|
||||
..length = a.length + b.length
|
||||
..setRange(0, a.length, a)
|
||||
..setRange(a.length, a.length + b.length, b);
|
||||
}
|
||||
|
||||
static void insert/*<T>*/(List/*<T>*/ l, int index, /*=T*/ value) {
|
||||
l.insert(index, value);
|
||||
}
|
||||
|
||||
static removeAt(List l, int index) => l.removeAt(index);
|
||||
static void removeAll/*<T>*/(List/*<T>*/ list, List/*<T>*/ items) {
|
||||
for (var i = 0; i < items.length; ++i) {
|
||||
list.remove(items[i]);
|
||||
}
|
||||
}
|
||||
|
||||
static bool remove/*<T>*/(List/*<T>*/ list, /*=T*/ item) => list.remove(item);
|
||||
static void clear(List l) {
|
||||
l.clear();
|
||||
}
|
||||
|
||||
static bool isEmpty(Iterable list) => list.isEmpty;
|
||||
static void fill/*<T>*/(List/*<T>*/ l, /*=T*/ value, [int start = 0, int end]) {
|
||||
l.fillRange(_startOffset(l, start), _endOffset(l, end), value);
|
||||
}
|
||||
|
||||
static bool equals/*<T>*/(List/*<T>*/ a, List/*<T>*/ b) {
|
||||
if (a.length != b.length) return false;
|
||||
for (var i = 0; i < a.length; ++i) {
|
||||
if (a[i] != b[i]) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static List/*<T>*/ slice/*<T>*/(List/*<T>*/ l, [int from = 0, int to]) {
|
||||
from = _startOffset(l, from);
|
||||
to = _endOffset(l, to);
|
||||
//in JS if from > to an empty array is returned
|
||||
if (to != null && from > to) {
|
||||
return [];
|
||||
}
|
||||
return l.sublist(from, to);
|
||||
}
|
||||
|
||||
static List/*<T>*/ splice/*<T>*/(List/*<T>*/ l, int from, int length) {
|
||||
from = _startOffset(l, from);
|
||||
var to = from + length;
|
||||
var sub = l.sublist(from, to);
|
||||
l.removeRange(from, to);
|
||||
return sub;
|
||||
}
|
||||
|
||||
static void sort/*<T>*/(List/*<T>*/ l, [int compareFn(/*=T*/a, /*=T*/b) = null]) {
|
||||
if (compareFn == null) {
|
||||
l.sort();
|
||||
} else {
|
||||
l.sort(compareFn);
|
||||
}
|
||||
}
|
||||
|
||||
static String toJSON(List l) {
|
||||
return jsonEncoder.convert(l);
|
||||
}
|
||||
|
||||
// JS splice, slice, fill functions can take start < 0 which indicates a position relative to
|
||||
// the end of the list
|
||||
static int _startOffset(List l, int start) {
|
||||
int len = l.length;
|
||||
return start < 0 ? max(len + start, 0) : min(start, len);
|
||||
}
|
||||
|
||||
// JS splice, slice, fill functions can take end < 0 which indicates a position relative to
|
||||
// the end of the list
|
||||
static int _endOffset(List l, int end) {
|
||||
int len = l.length;
|
||||
if (end == null) return len;
|
||||
return end < 0 ? max(len + end, 0) : min(end, len);
|
||||
}
|
||||
|
||||
static maximum(List l, fn(item)) {
|
||||
if (l.length == 0) {
|
||||
return null;
|
||||
}
|
||||
var solution = null;
|
||||
var maxValue = double.NEGATIVE_INFINITY;
|
||||
for (var index = 0; index < l.length; index++) {
|
||||
var candidate = l[index];
|
||||
if (candidate == null) {
|
||||
continue;
|
||||
}
|
||||
var candidateValue = fn(candidate);
|
||||
if (candidateValue > maxValue) {
|
||||
solution = candidate;
|
||||
maxValue = candidateValue;
|
||||
}
|
||||
}
|
||||
return solution;
|
||||
}
|
||||
|
||||
static List flatten(List l) {
|
||||
var target = [];
|
||||
_flattenArray(l, target);
|
||||
return target;
|
||||
}
|
||||
|
||||
static addAll(List l, List source) {
|
||||
l.addAll(source);
|
||||
}
|
||||
}
|
||||
|
||||
List _flattenArray(List source, List target) {
|
||||
if (source != null) {
|
||||
for (var i = 0; i < source.length; i++) {
|
||||
var item = source[i];
|
||||
if (item is List) {
|
||||
_flattenArray(item, target);
|
||||
} else {
|
||||
target.add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
return target;
|
||||
}
|
||||
|
||||
|
||||
bool isListLikeIterable(obj) => obj is Iterable;
|
||||
|
||||
bool areIterablesEqual/*<T>*/(
|
||||
Iterable/*<T>*/ a,
|
||||
Iterable/*<T>*/ b,
|
||||
bool comparator(/*=T*/a, /*=T*/b))
|
||||
{
|
||||
var iterator1 = a.iterator;
|
||||
var iterator2 = b.iterator;
|
||||
|
||||
while (true) {
|
||||
var done1 = !iterator1.moveNext();
|
||||
var done2 = !iterator2.moveNext();
|
||||
if (done1 && done2) return true;
|
||||
if (done1 || done2) return false;
|
||||
if (!comparator(iterator1.current, iterator2.current)) return false;
|
||||
}
|
||||
}
|
||||
|
||||
void iterateListLike/*<T>*/(Iterable/*<T>*/ iter, fn(/*=T*/item)) {
|
||||
assert(iter is Iterable);
|
||||
for (var item in iter) {
|
||||
fn(item);
|
||||
}
|
||||
}
|
||||
|
||||
class SetWrapper {
|
||||
static Set/*<T>*/ createFromList/*<T>*/(List/*<T>*/ l) => new Set.from(l);
|
||||
static bool has/*<T>*/(Set/*<T>*/ s, /*=T*/key) => s.contains(key);
|
||||
static void delete/*<T>*/(Set/*<T>*/ m, /*=T*/k) {
|
||||
m.remove(k);
|
||||
}
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
library angular.core.facade.exceptions;
|
||||
|
||||
import 'base_wrapped_exception.dart';
|
||||
import 'exception_handler.dart';
|
||||
export 'exception_handler.dart';
|
||||
|
||||
class BaseException extends Error {
|
||||
final String _message;
|
||||
|
||||
BaseException([this._message]);
|
||||
|
||||
String get message => _message;
|
||||
|
||||
String toString() {
|
||||
return this.message;
|
||||
}
|
||||
}
|
||||
|
||||
class WrappedException extends BaseWrappedException {
|
||||
final dynamic _context;
|
||||
final String _wrapperMessage;
|
||||
final originalException;
|
||||
final originalStack;
|
||||
|
||||
WrappedException(
|
||||
[this._wrapperMessage,
|
||||
this.originalException,
|
||||
this.originalStack,
|
||||
this._context]);
|
||||
|
||||
String get message {
|
||||
return ExceptionHandler.exceptionToString(this);
|
||||
}
|
||||
|
||||
String toString() {
|
||||
return this.message;
|
||||
}
|
||||
|
||||
dynamic get context => _context;
|
||||
|
||||
String get wrapperMessage => _wrapperMessage;
|
||||
}
|
||||
|
||||
Error makeTypeError([String message = ""]) {
|
||||
return new BaseException(message);
|
||||
}
|
||||
|
||||
dynamic unimplemented() {
|
||||
throw new BaseException('unimplemented');
|
||||
}
|
|
@ -1,57 +0,0 @@
|
|||
library facade.intl;
|
||||
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
String _normalizeLocale(String locale) => locale.replaceAll('-', '_');
|
||||
|
||||
enum NumberFormatStyle { Decimal, Percent, Currency }
|
||||
|
||||
class NumberFormatter {
|
||||
static String format(num number, String locale, NumberFormatStyle style,
|
||||
{int minimumIntegerDigits: 1,
|
||||
int minimumFractionDigits: 0,
|
||||
int maximumFractionDigits: 3,
|
||||
String currency,
|
||||
bool currencyAsSymbol: false}) {
|
||||
locale = _normalizeLocale(locale);
|
||||
NumberFormat formatter;
|
||||
switch (style) {
|
||||
case NumberFormatStyle.Decimal:
|
||||
formatter = new NumberFormat.decimalPattern(locale);
|
||||
break;
|
||||
case NumberFormatStyle.Percent:
|
||||
formatter = new NumberFormat.percentPattern(locale);
|
||||
break;
|
||||
case NumberFormatStyle.Currency:
|
||||
if (currencyAsSymbol) {
|
||||
// See https://github.com/dart-lang/intl/issues/59.
|
||||
throw new Exception(
|
||||
'Displaying currency as symbol is not supported.');
|
||||
}
|
||||
formatter = new NumberFormat.currencyPattern(locale, currency);
|
||||
break;
|
||||
}
|
||||
formatter.minimumIntegerDigits = minimumIntegerDigits;
|
||||
formatter.minimumFractionDigits = minimumFractionDigits;
|
||||
formatter.maximumFractionDigits = maximumFractionDigits;
|
||||
return formatter.format(number);
|
||||
}
|
||||
}
|
||||
|
||||
class DateFormatter {
|
||||
static RegExp _multiPartRegExp = new RegExp(r'^([yMdE]+)([Hjms]+)$');
|
||||
|
||||
static String format(DateTime date, String locale, String pattern) {
|
||||
locale = _normalizeLocale(locale);
|
||||
var formatter = new DateFormat(null, locale);
|
||||
var matches = _multiPartRegExp.firstMatch(pattern);
|
||||
if (matches != null) {
|
||||
// Support for patterns which have known date and time components.
|
||||
formatter.addPattern(matches[1]);
|
||||
formatter.addPattern(matches[2], ', ');
|
||||
} else {
|
||||
formatter.addPattern(pattern);
|
||||
}
|
||||
return formatter.format(date);
|
||||
}
|
||||
}
|
|
@ -1,373 +0,0 @@
|
|||
library angular.core.facade.lang;
|
||||
|
||||
export 'dart:core' show Type, RegExp, print, DateTime, Uri;
|
||||
import 'dart:math' as math;
|
||||
import 'dart:convert' as convert;
|
||||
import 'dart:async' show Future, Zone;
|
||||
|
||||
String getTypeNameForDebugging(Object type) => type.toString();
|
||||
|
||||
class Math {
|
||||
static final _random = new math.Random();
|
||||
static int floor(num n) => n.floor();
|
||||
static double random() => _random.nextDouble();
|
||||
static num min(num a, num b) => math.min(a, b);
|
||||
}
|
||||
|
||||
const IS_DART = true;
|
||||
|
||||
scheduleMicroTask(Function fn) {
|
||||
Zone.current.scheduleMicrotask(fn);
|
||||
}
|
||||
|
||||
bool isPresent(Object obj) => obj != null;
|
||||
bool isBlank(Object obj) => obj == null;
|
||||
bool isString(Object obj) => obj is String;
|
||||
bool isFunction(Object obj) => obj is Function;
|
||||
bool isType(Object obj) => obj is Type;
|
||||
bool isStringMap(Object obj) => obj is Map;
|
||||
bool isStrictStringMap(Object obj) => obj is Map;
|
||||
bool isArray(Object obj) => obj is List;
|
||||
bool isPromise(Object obj) => obj is Future;
|
||||
bool isNumber(Object obj) => obj is num;
|
||||
bool isBoolean(Object obj) => obj is bool;
|
||||
bool isDate(Object obj) => obj is DateTime;
|
||||
|
||||
String stringify(obj) {
|
||||
final exp = new RegExp(r"from Function '(\w+)'");
|
||||
final str = obj.toString();
|
||||
if (exp.firstMatch(str) != null) {
|
||||
return exp.firstMatch(str).group(1);
|
||||
} else {
|
||||
return str;
|
||||
}
|
||||
}
|
||||
|
||||
int serializeEnum(val) {
|
||||
return val.index;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deserializes an enum
|
||||
* val should be the indexed value of the enum (sa returned from @link{serializeEnum})
|
||||
* values should be a map from indexes to values for the enum that you want to deserialize.
|
||||
*/
|
||||
dynamic deserializeEnum(num val, Map<num, dynamic> values) {
|
||||
return values[val];
|
||||
}
|
||||
|
||||
String resolveEnumToken(enumValue, val) {
|
||||
// turn Enum.Token -> Token
|
||||
return val.toString().replaceFirst(new RegExp('^.+\\.'),'');
|
||||
}
|
||||
|
||||
class StringWrapper {
|
||||
static String fromCharCode(int code) {
|
||||
return new String.fromCharCode(code);
|
||||
}
|
||||
|
||||
static int charCodeAt(String s, int index) {
|
||||
return s.codeUnitAt(index);
|
||||
}
|
||||
|
||||
static List<String> split(String s, RegExp regExp) {
|
||||
var parts = <String>[];
|
||||
var lastEnd = 0;
|
||||
regExp.allMatches(s).forEach((match) {
|
||||
parts.add(s.substring(lastEnd, match.start));
|
||||
lastEnd = match.end;
|
||||
for (var i = 0; i < match.groupCount; i++) {
|
||||
parts.add(match.group(i + 1));
|
||||
}
|
||||
});
|
||||
parts.add(s.substring(lastEnd));
|
||||
return parts;
|
||||
}
|
||||
|
||||
static bool equals(String s, String s2) {
|
||||
return s == s2;
|
||||
}
|
||||
|
||||
static String stripLeft(String s, String charVal) {
|
||||
if (isPresent(s) && s.length > 0) {
|
||||
var pos = 0;
|
||||
for (var i = 0; i < s.length; i++) {
|
||||
if (s[i] != charVal) break;
|
||||
pos++;
|
||||
}
|
||||
s = s.substring(pos);
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
static String stripRight(String s, String charVal) {
|
||||
if (isPresent(s) && s.length > 0) {
|
||||
var pos = s.length;
|
||||
for (var i = s.length - 1; i >= 0; i--) {
|
||||
if (s[i] != charVal) break;
|
||||
pos--;
|
||||
}
|
||||
s = s.substring(0, pos);
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
static String replace(String s, Pattern from, String replace) {
|
||||
return s.replaceFirst(from, replace);
|
||||
}
|
||||
|
||||
static String replaceAll(String s, RegExp from, String replace) {
|
||||
return s.replaceAll(from, replace);
|
||||
}
|
||||
|
||||
static String slice(String s, [int start = 0, int end]) {
|
||||
start = _startOffset(s, start);
|
||||
end = _endOffset(s, end);
|
||||
//in JS if start > end an empty string is returned
|
||||
if (end != null && start > end) {
|
||||
return "";
|
||||
}
|
||||
return s.substring(start, end);
|
||||
}
|
||||
|
||||
static String replaceAllMapped(String s, RegExp from, Function cb) {
|
||||
return s.replaceAllMapped(from, cb);
|
||||
}
|
||||
|
||||
static bool contains(String s, String substr) {
|
||||
return s.contains(substr);
|
||||
}
|
||||
|
||||
static int compare(String a, String b) => a.compareTo(b);
|
||||
|
||||
// JS slice function can take start < 0 which indicates a position relative to
|
||||
// the end of the string
|
||||
static int _startOffset(String s, int start) {
|
||||
int len = s.length;
|
||||
return start < 0 ? math.max(len + start, 0) : math.min(start, len);
|
||||
}
|
||||
|
||||
// JS slice function can take end < 0 which indicates a position relative to
|
||||
// the end of the string
|
||||
static int _endOffset(String s, int end) {
|
||||
int len = s.length;
|
||||
if (end == null) return len;
|
||||
return end < 0 ? math.max(len + end, 0) : math.min(end, len);
|
||||
}
|
||||
}
|
||||
|
||||
class StringJoiner {
|
||||
final List<String> _parts = <String>[];
|
||||
|
||||
void add(String part) {
|
||||
_parts.add(part);
|
||||
}
|
||||
|
||||
String toString() => _parts.join("");
|
||||
}
|
||||
|
||||
class NumberWrapper {
|
||||
static String toFixed(num n, int fractionDigits) {
|
||||
return n.toStringAsFixed(fractionDigits);
|
||||
}
|
||||
|
||||
static bool equal(num a, num b) {
|
||||
return a == b;
|
||||
}
|
||||
|
||||
static int parseIntAutoRadix(String text) {
|
||||
return int.parse(text);
|
||||
}
|
||||
|
||||
static int parseInt(String text, int radix) {
|
||||
return int.parse(text, radix: radix);
|
||||
}
|
||||
|
||||
static double parseFloat(String text) {
|
||||
return double.parse(text);
|
||||
}
|
||||
|
||||
static double get NaN => double.NAN;
|
||||
|
||||
static bool isNumeric(value) {
|
||||
if(value == null) {
|
||||
return false;
|
||||
}
|
||||
return double.parse(value, (e) => null) != null;
|
||||
}
|
||||
|
||||
static bool isNaN(num value) => value.isNaN;
|
||||
|
||||
static bool isInteger(value) => value is int;
|
||||
}
|
||||
|
||||
class RegExpWrapper {
|
||||
static RegExp create(regExpStr, [String flags = '']) {
|
||||
bool multiLine = flags.contains('m');
|
||||
bool caseSensitive = !flags.contains('i');
|
||||
return new RegExp(regExpStr,
|
||||
multiLine: multiLine, caseSensitive: caseSensitive);
|
||||
}
|
||||
|
||||
static Match firstMatch(RegExp regExp, String input) {
|
||||
return regExp.firstMatch(input);
|
||||
}
|
||||
|
||||
static bool test(RegExp regExp, String input) {
|
||||
return regExp.hasMatch(input);
|
||||
}
|
||||
|
||||
static Iterator<Match> matcher(RegExp regExp, String input) {
|
||||
return regExp.allMatches(input).iterator;
|
||||
}
|
||||
|
||||
static String replaceAll(RegExp regExp, String input, Function replace) {
|
||||
final m = RegExpWrapper.matcher(regExp, input);
|
||||
var res = "";
|
||||
var prev = 0;
|
||||
while(m.moveNext()) {
|
||||
var c = m.current;
|
||||
res += input.substring(prev, c.start);
|
||||
res += replace(c);
|
||||
prev = c.start + c[0].length;
|
||||
}
|
||||
res += input.substring(prev);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
class RegExpMatcherWrapper {
|
||||
static _JSLikeMatch next(Iterator<Match> matcher) {
|
||||
if (matcher.moveNext()) {
|
||||
return new _JSLikeMatch(matcher.current);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
class _JSLikeMatch {
|
||||
Match _m;
|
||||
|
||||
_JSLikeMatch(this._m);
|
||||
|
||||
String operator [](index) => _m[index];
|
||||
int get index => _m.start;
|
||||
int get length => _m.groupCount + 1;
|
||||
}
|
||||
|
||||
class FunctionWrapper {
|
||||
static apply(Function fn, posArgs) {
|
||||
return Function.apply(fn, posArgs);
|
||||
}
|
||||
|
||||
static Function bind(Function fn, dynamic scope) {
|
||||
return fn;
|
||||
}
|
||||
}
|
||||
|
||||
const _NAN_KEY = const Object();
|
||||
|
||||
// Dart VM implements `identical` as true reference identity. JavaScript does
|
||||
// not have this. The closest we have in JS is `===`. However, for strings JS
|
||||
// would actually compare the contents rather than references. `dart2js`
|
||||
// compiles `identical` to `===` and therefore there is a discrepancy between
|
||||
// Dart VM and `dart2js`. The implementation of `looseIdentical` attempts to
|
||||
// bridge the gap between the two while retaining good performance
|
||||
// characteristics. In JS we use simple `identical`, which compiles to `===`,
|
||||
// and in Dart VM we emulate the semantics of `===` by special-casing strings.
|
||||
// Note that the VM check is a compile-time constant. This allows `dart2js` to
|
||||
// evaluate the conditional during compilation and inline the entire function.
|
||||
//
|
||||
// See: dartbug.com/22496, dartbug.com/25270
|
||||
const _IS_DART_VM = !identical(1.0, 1); // a hack
|
||||
bool looseIdentical(a, b) => _IS_DART_VM
|
||||
? _looseIdentical(a, b)
|
||||
: identical(a, b);
|
||||
|
||||
// This function is intentionally separated from `looseIdentical` to keep the
|
||||
// number of AST nodes low enough for `dart2js` to inline the code.
|
||||
bool _looseIdentical(a, b) =>
|
||||
a is String && b is String ? a == b : identical(a, b);
|
||||
|
||||
// Dart compare map keys by equality and we can have NaN != NaN
|
||||
dynamic getMapKey(value) {
|
||||
if (value is! num) return value;
|
||||
return value.isNaN ? _NAN_KEY : value;
|
||||
}
|
||||
|
||||
// TODO: remove with https://github.com/angular/angular/issues/3055
|
||||
dynamic normalizeBlank(obj) => obj;
|
||||
|
||||
bool normalizeBool(bool obj) {
|
||||
return isBlank(obj) ? false : obj;
|
||||
}
|
||||
|
||||
bool isJsObject(o) {
|
||||
return false;
|
||||
}
|
||||
|
||||
warn(o) {
|
||||
print(o);
|
||||
}
|
||||
|
||||
// Can't be all uppercase as our transpiler would think it is a special directive...
|
||||
class Json {
|
||||
static parse(String s) => convert.JSON.decode(s);
|
||||
static String stringify(data) {
|
||||
var encoder = new convert.JsonEncoder.withIndent(" ");
|
||||
return encoder.convert(data);
|
||||
}
|
||||
}
|
||||
|
||||
class DateWrapper {
|
||||
static DateTime create(int year,
|
||||
[int month = 1,
|
||||
int day = 1,
|
||||
int hour = 0,
|
||||
int minutes = 0,
|
||||
int seconds = 0,
|
||||
int milliseconds = 0]) {
|
||||
return new DateTime(year, month, day, hour, minutes, seconds, milliseconds);
|
||||
}
|
||||
|
||||
static DateTime fromISOString(String str) {
|
||||
return DateTime.parse(str);
|
||||
}
|
||||
|
||||
static DateTime fromMillis(int ms) {
|
||||
return new DateTime.fromMillisecondsSinceEpoch(ms, isUtc: true);
|
||||
}
|
||||
|
||||
static int toMillis(DateTime date) {
|
||||
return date.millisecondsSinceEpoch;
|
||||
}
|
||||
|
||||
static DateTime now() {
|
||||
return new DateTime.now();
|
||||
}
|
||||
|
||||
static String toJson(DateTime date) {
|
||||
return date.toUtc().toIso8601String();
|
||||
}
|
||||
}
|
||||
|
||||
bool isPrimitive(Object obj) => obj is num || obj is bool || obj == null || obj is String;
|
||||
|
||||
// needed to match the exports from lang.js
|
||||
var global = null;
|
||||
|
||||
dynamic evalExpression(String sourceUrl, String expr, String declarations, Map<String, String> vars) {
|
||||
throw "Dart does not support evaluating expression during runtime!";
|
||||
}
|
||||
|
||||
bool hasConstructor(Object value, Type type) {
|
||||
return value.runtimeType == type;
|
||||
}
|
||||
|
||||
String escape(String s) {
|
||||
return Uri.encodeComponent(s);
|
||||
}
|
||||
|
||||
String escapeRegExp(String s) {
|
||||
return s.replaceAllMapped(new RegExp(r'([.*+?^=!:${}()|[\]\/\\])'), (Match m) => '\\${m[1]}');
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
library angular.core.facade.math;
|
||||
|
||||
import 'dart:core' show double, num;
|
||||
import 'dart:math' as math;
|
||||
|
||||
const NaN = double.NAN;
|
||||
|
||||
class Math {
|
||||
static num pow(num x, num exponent) {
|
||||
return math.pow(x, exponent);
|
||||
}
|
||||
|
||||
static num max(num a, num b) => math.max(a, b);
|
||||
|
||||
static num min(num a, num b) => math.min(a, b);
|
||||
|
||||
static num floor(num a) => a.floor();
|
||||
|
||||
static num ceil(num a) => a.ceil();
|
||||
|
||||
static num sqrt(num x) => math.sqrt(x);
|
||||
|
||||
static num round(num x) => x.round();
|
||||
}
|
|
@ -1,58 +0,0 @@
|
|||
library angular2.core.facade.promise;
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:async' as async;
|
||||
|
||||
class PromiseWrapper {
|
||||
static Future/*<T>*/ resolve/*<T>*/(dynamic /*=T*/ obj) => new Future.value(obj);
|
||||
|
||||
static Future/*<T>*/ reject/*<T>*/(dynamic /*=T*/ obj, Object stackTrace) => new Future.error(obj,
|
||||
stackTrace != null ? stackTrace : obj is Error ? (obj as Error).stackTrace : null);
|
||||
|
||||
static Future<List/*<T>*/> all/*<T>*/(List<dynamic> promises) {
|
||||
return Future
|
||||
.wait(promises.map((p) => p is Future ? p as Future/*<T>*/ : new Future/*<T>*/.value(p)));
|
||||
}
|
||||
static Future/*<R>*/ then/*<T, R>*/(Future/*<T>*/ promise, dynamic /*=R*/ success(dynamic /*=T*/ value), [Function onError]) {
|
||||
if (success == null) return promise.catchError(onError);
|
||||
return promise.then(success, onError: onError);
|
||||
}
|
||||
|
||||
static Future/*<T>*/ wrap/*<T>*/(dynamic /*=T*/ fn()) {
|
||||
return new Future(fn);
|
||||
}
|
||||
|
||||
// Note: We can't rename this method to `catch`, as this is not a valid
|
||||
// method name in Dart.
|
||||
static Future catchError(Future promise, Function onError) {
|
||||
return promise.catchError(onError);
|
||||
}
|
||||
|
||||
static void scheduleMicrotask(fn) {
|
||||
async.scheduleMicrotask(fn);
|
||||
}
|
||||
|
||||
static bool isPromise(obj) {
|
||||
return obj is Future;
|
||||
}
|
||||
|
||||
static PromiseCompleter/*<T>*/ completer/*<T>*/() =>
|
||||
new PromiseCompleter();
|
||||
}
|
||||
|
||||
class PromiseCompleter<T> {
|
||||
final Completer<T> c = new Completer();
|
||||
|
||||
Future<T> get promise => c.future;
|
||||
|
||||
void resolve(v) {
|
||||
c.complete(v);
|
||||
}
|
||||
|
||||
void reject(error, stack) {
|
||||
if (stack == null && error is Error) {
|
||||
stack = error.stackTrace;
|
||||
}
|
||||
c.completeError(error, stack);
|
||||
}
|
||||
}
|
|
@ -1,106 +0,0 @@
|
|||
/// This file contains tests that make sense only in Dart
|
||||
library angular2.test.facade.async_dart_spec;
|
||||
|
||||
import 'dart:async';
|
||||
import 'package:angular2/testing_internal.dart';
|
||||
import 'package:angular2/src/facade/async.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;
|
||||
}
|
||||
}
|
||||
|
||||
void expectFunctionThatThrowsWithStackTrace(
|
||||
Future future, AsyncTestCompleter async) {
|
||||
PromiseWrapper.catchError(future, (err, StackTrace stack) {
|
||||
expect(stack.toString().split('\n')[0]).toEqual(err.message);
|
||||
async.done();
|
||||
});
|
||||
}
|
||||
|
||||
main() {
|
||||
describe('async facade', () {
|
||||
describe('Completer', () {
|
||||
it(
|
||||
'should preserve Error stack traces',
|
||||
inject([AsyncTestCompleter], (async) {
|
||||
var c = PromiseWrapper.completer();
|
||||
|
||||
expectFunctionThatThrowsWithStackTrace(c.promise, async);
|
||||
|
||||
try {
|
||||
functionThatThrows();
|
||||
} catch (e) {
|
||||
c.reject(e, null);
|
||||
}
|
||||
}));
|
||||
|
||||
it(
|
||||
'should preserve error stack traces for non-Errors',
|
||||
inject([AsyncTestCompleter], (async) {
|
||||
var c = PromiseWrapper.completer();
|
||||
|
||||
expectFunctionThatThrowsWithStackTrace(c.promise, async);
|
||||
|
||||
try {
|
||||
functionThatThrowsNonError();
|
||||
} catch (e, s) {
|
||||
c.reject(e, s);
|
||||
}
|
||||
}));
|
||||
});
|
||||
|
||||
describe('PromiseWrapper', () {
|
||||
describe('reject', () {
|
||||
it(
|
||||
'should preserve Error stack traces',
|
||||
inject([AsyncTestCompleter], (async) {
|
||||
try {
|
||||
functionThatThrows();
|
||||
} catch (e) {
|
||||
var rejectedFuture = PromiseWrapper.reject(e, null);
|
||||
expectFunctionThatThrowsWithStackTrace(rejectedFuture, async);
|
||||
}
|
||||
}));
|
||||
|
||||
it(
|
||||
'should preserve stack traces for non-Errors',
|
||||
inject([AsyncTestCompleter], (async) {
|
||||
try {
|
||||
functionThatThrowsNonError();
|
||||
} catch (e, s) {
|
||||
var rejectedFuture = PromiseWrapper.reject(e, s);
|
||||
expectFunctionThatThrowsWithStackTrace(rejectedFuture, async);
|
||||
}
|
||||
}));
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
export 'index.dart';
|
|
@ -1,20 +0,0 @@
|
|||
library angular2.core.forms.normalize_validators;
|
||||
|
||||
import 'package:angular2/src/common/forms/directives/validators.dart' show Validator;
|
||||
|
||||
Function normalizeValidator(dynamic validator){
|
||||
if (validator is Validator) {
|
||||
return (c) => validator.validate(c);
|
||||
} else {
|
||||
return validator;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Function normalizeAsyncValidator(dynamic validator){
|
||||
if (validator is Validator) {
|
||||
return (c) => validator.validate(c);
|
||||
} else {
|
||||
return validator;
|
||||
}
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
library core.spies;
|
||||
|
||||
import 'package:angular2/common.dart';
|
||||
import 'package:angular2/src/core/change_detection/change_detection.dart';
|
||||
import 'package:angular2/testing_internal.dart';
|
||||
|
||||
@proxy
|
||||
class SpyNgControl extends SpyObject implements NgControl {}
|
||||
|
||||
@proxy
|
||||
class SpyValueAccessor extends SpyObject implements ControlValueAccessor {}
|
||||
|
||||
@proxy
|
||||
class SpyChangeDetectorRef extends SpyObject implements ChangeDetectorRef {}
|
|
@ -1,3 +0,0 @@
|
|||
import 'dart:html' show History;
|
||||
|
||||
bool supportsState() => History.supportsState;
|
|
@ -1,39 +0,0 @@
|
|||
library angular2.src.tools.tools;
|
||||
|
||||
import 'dart:js';
|
||||
import 'package:angular2/src/core/linker/component_factory.dart'
|
||||
show ComponentRef;
|
||||
import 'common_tools.dart' show AngularTools;
|
||||
|
||||
/**
|
||||
* Enabled Angular 2 debug tools that are accessible via your browser's
|
||||
* developer console.
|
||||
*
|
||||
* Usage:
|
||||
*
|
||||
* 1. Open developer console (e.g. in Chrome Ctrl + Shift + j)
|
||||
* 1. Type `ng.` (usually the console will show auto-complete suggestion)
|
||||
* 1. Try the change detection profiler `ng.profiler.timeChangeDetection()`
|
||||
* then hit Enter.
|
||||
*
|
||||
* @experimental All debugging apis are currently experimental.
|
||||
*/
|
||||
void enableDebugTools(ComponentRef<dynamic> ref) {
|
||||
final tools = new AngularTools(ref);
|
||||
context['ng'] = new JsObject.jsify({
|
||||
'profiler': {
|
||||
'timeChangeDetection': ([config]) {
|
||||
tools.profiler.timeChangeDetection(config);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Disables Angular 2 tools.
|
||||
*
|
||||
* @experimental All debugging apis are currently experimental.
|
||||
*/
|
||||
void disableDebugTools() {
|
||||
context.deleteProperty('ng');
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
import 'package:angular2/testing_internal.dart' show SpyObject;
|
||||
import 'package:angular2/core.dart' show Injector, ReflectiveInjector, bind;
|
||||
import 'package:angular2/src/core/application_ref.dart' show ApplicationRef;
|
||||
import 'package:angular2/src/core/linker/component_factory.dart'
|
||||
show ComponentRef;
|
||||
import 'dart:js';
|
||||
|
||||
@proxy
|
||||
class SpyApplicationRef extends SpyObject implements ApplicationRef {
|
||||
tick() {}
|
||||
}
|
||||
|
||||
@proxy
|
||||
class SpyComponentRef extends SpyObject implements ComponentRef<dynamic> {
|
||||
Injector injector;
|
||||
|
||||
SpyComponentRef() {
|
||||
this.injector = ReflectiveInjector
|
||||
.resolveAndCreate([{provide: ApplicationRef, useClass: SpyApplicationRef}]);
|
||||
}
|
||||
}
|
||||
|
||||
void callNgProfilerTimeChangeDetection([config]) {
|
||||
context['ng']['profiler']
|
||||
.callMethod('timeChangeDetection', config != null ? [config] : []);
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
export '../compiler.dart';
|
|
@ -1,2 +0,0 @@
|
|||
// TODO: vsavkin add SERVER_PROVIDERS and SERVER_APPLICATION_PROVIDERS
|
||||
export 'package:angular2/src/platform/server/html_adapter.dart';
|
|
@ -1 +0,0 @@
|
|||
export './index.dart';
|
|
@ -1 +0,0 @@
|
|||
export './platform-browser.dart' show DomAdapter, setRootDomAdapter;
|
|
@ -1,457 +0,0 @@
|
|||
library angular2.dom.abstractHtmlAdapter;
|
||||
|
||||
import 'package:html/parser.dart' as parser;
|
||||
import 'package:html/dom.dart';
|
||||
|
||||
import 'package:angular2/platform/common_dom.dart';
|
||||
import 'package:angular2/src/compiler/xhr.dart';
|
||||
|
||||
import 'package:angular2/src/facade/lang.dart' show isBlank, isPresent;
|
||||
import 'package:angular2/src/platform/dom/animation/dom_animate_player.dart' show DomAnimatePlayer;
|
||||
|
||||
const _attrToPropMap = const {
|
||||
'innerHtml': 'innerHTML',
|
||||
'readonly': 'readOnly',
|
||||
'tabindex': 'tabIndex',
|
||||
};
|
||||
|
||||
abstract class AbstractHtml5LibAdapter implements DomAdapter {
|
||||
hasProperty(element, String name) {
|
||||
// This is needed for serverside compile to generate the right getters/setters.
|
||||
// TODO: change this once we have property schema support.
|
||||
// Attention: Keep this in sync with browser_adapter.dart!
|
||||
return true;
|
||||
}
|
||||
|
||||
void setProperty(Element element, String name, Object value) =>
|
||||
throw 'not implemented';
|
||||
|
||||
getProperty(Element element, String name) => throw 'not implemented';
|
||||
|
||||
invoke(Element element, String methodName, List args) =>
|
||||
throw 'not implemented';
|
||||
|
||||
@override
|
||||
get attrToPropMap => _attrToPropMap;
|
||||
|
||||
@override
|
||||
set attrToPropMap(value) {
|
||||
throw 'readonly';
|
||||
}
|
||||
|
||||
@override
|
||||
getGlobalEventTarget(String target) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
@override
|
||||
getTitle() {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
@override
|
||||
setTitle(String newTitle) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
@override
|
||||
String getEventKey(event) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
@override
|
||||
void replaceChild(el, newNode, oldNode) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
@override
|
||||
dynamic getBoundingClientRect(el) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
@override
|
||||
Type getXHR() => XHR;
|
||||
|
||||
Element parse(String templateHtml) => parser.parse(templateHtml).firstChild;
|
||||
query(selector) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
querySelector(el, String selector) {
|
||||
return el.querySelector(selector);
|
||||
}
|
||||
|
||||
List querySelectorAll(el, String selector) {
|
||||
return el.querySelectorAll(selector);
|
||||
}
|
||||
|
||||
on(el, evt, listener) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
Function onAndCancel(el, evt, listener) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
dispatchEvent(el, evt) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
createMouseEvent(eventType) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
createEvent(eventType) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
preventDefault(evt) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
isPrevented(evt) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
getInnerHTML(el) {
|
||||
return el.innerHtml;
|
||||
}
|
||||
|
||||
getOuterHTML(el) {
|
||||
return el.outerHtml;
|
||||
}
|
||||
|
||||
String nodeName(node) {
|
||||
switch (node.nodeType) {
|
||||
case Node.ELEMENT_NODE:
|
||||
return (node as Element).localName;
|
||||
case Node.TEXT_NODE:
|
||||
return '#text';
|
||||
default:
|
||||
throw 'not implemented for type ${node.nodeType}. '
|
||||
'See http://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-1950641247'
|
||||
' for node types definitions.';
|
||||
}
|
||||
}
|
||||
|
||||
String nodeValue(node) => node.data;
|
||||
String type(node) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
content(node) {
|
||||
return node;
|
||||
}
|
||||
|
||||
firstChild(el) => el is NodeList ? el.first : el.firstChild;
|
||||
|
||||
nextSibling(el) {
|
||||
final parentNode = el.parentNode;
|
||||
if (parentNode == null) return null;
|
||||
final siblings = parentNode.nodes;
|
||||
final index = siblings.indexOf(el);
|
||||
if (index < siblings.length - 1) {
|
||||
return siblings[index + 1];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
parentElement(el) {
|
||||
return el.parent;
|
||||
}
|
||||
|
||||
List childNodes(el) => el.nodes;
|
||||
List childNodesAsList(el) => el.nodes;
|
||||
clearNodes(el) {
|
||||
el.nodes.forEach((e) => e.remove());
|
||||
}
|
||||
|
||||
appendChild(el, node) => el.append(node.remove());
|
||||
removeChild(el, node) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
remove(el) => el.remove();
|
||||
insertBefore(el, node) {
|
||||
if (el.parent == null) throw '$el must have a parent';
|
||||
el.parent.insertBefore(node, el);
|
||||
}
|
||||
|
||||
insertAllBefore(el, nodes) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
insertAfter(el, node) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
setInnerHTML(el, value) {
|
||||
el.innerHtml = value;
|
||||
}
|
||||
|
||||
getText(el) {
|
||||
return el.text;
|
||||
}
|
||||
|
||||
setText(el, String value) => el.text = value;
|
||||
|
||||
getValue(el) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
setValue(el, String value) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
getChecked(el) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
setChecked(el, bool value) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
createComment(String text) => new Comment(text);
|
||||
createTemplate(String html) => createElement('template')..innerHtml = html;
|
||||
createElement(tagName, [doc]) {
|
||||
return new Element.tag(tagName);
|
||||
}
|
||||
|
||||
createElementNS(ns, tagName, [doc]) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
createTextNode(String text, [doc]) => new Text(text);
|
||||
|
||||
createScriptTag(String attrName, String attrValue, [doc]) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
createStyleElement(String css, [doc]) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
createShadowRoot(el) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
getShadowRoot(el) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
getHost(el) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
clone(node) => node.clone(true);
|
||||
getElementsByClassName(element, String name) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
getElementsByTagName(element, String name) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
List classList(element) => element.classes.toList();
|
||||
|
||||
addClass(element, String className) {
|
||||
element.classes.add(className);
|
||||
}
|
||||
|
||||
removeClass(element, String className) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
hasClass(element, String className) => element.classes.contains(className);
|
||||
|
||||
setStyle(element, String styleName, String styleValue) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
bool hasStyle(Element element, String styleName, [String styleValue]) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
removeStyle(element, String styleName) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
getStyle(element, String styleName) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
String tagName(element) => element.localName;
|
||||
|
||||
attributeMap(element) {
|
||||
// `attributes` keys can be {@link AttributeName}s.
|
||||
var map = <String, String>{};
|
||||
element.attributes.forEach((key, value) {
|
||||
map['$key'] = value;
|
||||
});
|
||||
return map;
|
||||
}
|
||||
|
||||
hasAttribute(element, String attribute) {
|
||||
// `attributes` keys can be {@link AttributeName}s.
|
||||
return element.attributes.keys.any((key) => '$key' == attribute);
|
||||
}
|
||||
|
||||
hasAttributeNS(element, String ns, String attribute) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
getAttribute(element, String attribute) {
|
||||
// `attributes` keys can be {@link AttributeName}s.
|
||||
var key = element.attributes.keys.firstWhere((key) => '$key' == attribute,
|
||||
orElse: () {});
|
||||
return element.attributes[key];
|
||||
}
|
||||
|
||||
getAttributeNS(element, String ns, String attribute) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
setAttribute(element, String name, String value) {
|
||||
element.attributes[name] = value;
|
||||
}
|
||||
|
||||
setAttributeNS(element, String ns, String name, String value) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
removeAttribute(element, String attribute) {
|
||||
element.attributes.remove(attribute);
|
||||
}
|
||||
|
||||
removeAttributeNS(element, String ns, String attribute) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
templateAwareRoot(el) => el;
|
||||
|
||||
createHtmlDocument() {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
defaultDoc() {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
bool elementMatches(n, String selector) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
bool isTemplateElement(Element el) {
|
||||
return el != null && el.localName.toLowerCase() == 'template';
|
||||
}
|
||||
|
||||
bool isTextNode(node) => node.nodeType == Node.TEXT_NODE;
|
||||
bool isCommentNode(node) => node.nodeType == Node.COMMENT_NODE;
|
||||
|
||||
bool isElementNode(node) => node.nodeType == Node.ELEMENT_NODE;
|
||||
|
||||
bool hasShadowRoot(node) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
bool isShadowRoot(node) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
importIntoDoc(node) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
adoptNode(node) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
String getHref(element) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
void resolveAndSetHref(element, baseUrl, href) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
List getDistributedNodes(Node) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
bool supportsDOMEvents() {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool supportsNativeShadowDOM() {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool supportsWebAnimation() {
|
||||
return false;
|
||||
}
|
||||
|
||||
getHistory() {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
getLocation() {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
getBaseHref() {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
resetBaseElement() {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
String getUserAgent() {
|
||||
return 'Angular 2 Dart Transformer';
|
||||
}
|
||||
|
||||
void setData(Element element, String name, String value) {
|
||||
this.setAttribute(element, 'data-${name}', value);
|
||||
}
|
||||
|
||||
getComputedStyle(element) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
String getData(Element element, String name) {
|
||||
return this.getAttribute(element, 'data-${name}');
|
||||
}
|
||||
|
||||
// TODO(tbosch): move this into a separate environment class once we have it
|
||||
setGlobalVar(String name, value) {
|
||||
// noop on the server
|
||||
}
|
||||
|
||||
requestAnimationFrame(callback) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
cancelAnimationFrame(id) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
performanceNow() {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
getAnimationPrefix() {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
getTransitionEnd() {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
supportsAnimation() {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
DomAnimatePlayer animate(element, keyframes, options) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
library angular2.dom.htmlAdapter;
|
||||
|
||||
import 'abstract_html_adapter.dart';
|
||||
import 'package:angular2/platform/common_dom.dart';
|
||||
import 'dart:io';
|
||||
|
||||
class Html5LibDomAdapter extends AbstractHtml5LibAdapter {
|
||||
static void makeCurrent() {
|
||||
setRootDomAdapter(new Html5LibDomAdapter());
|
||||
}
|
||||
|
||||
logError(errorMessage) {
|
||||
stderr.writeln('${errorMessage}');
|
||||
}
|
||||
|
||||
log(message) {
|
||||
stdout.writeln('${message}');
|
||||
}
|
||||
|
||||
logGroup(message) {
|
||||
stdout.writeln('${message}');
|
||||
}
|
||||
|
||||
logGroupEnd() {}
|
||||
}
|
|
@ -1,3 +0,0 @@
|
|||
library angular2.src.dom.parse5_adapter;
|
||||
|
||||
// no dart implementation
|
|
@ -1 +0,0 @@
|
|||
// Intentionally blank, the Parse5Adapater bindings for JavaScript don't apply.
|
|
@ -1,35 +0,0 @@
|
|||
name: angular2
|
||||
version: <%= packageJson.version %>
|
||||
authors:
|
||||
<%= Object.keys(packageJson.contributors).map(function(name) {
|
||||
return '- '+name+' <'+packageJson.contributors[name]+'>';
|
||||
}).join('\n') %>
|
||||
description: Angular 2 for Dart - a web framework for modern web apps
|
||||
homepage: <%= packageJson.homepage %>
|
||||
environment:
|
||||
sdk: '>=1.10.0 <2.0.0'
|
||||
dependencies:
|
||||
analyzer: '>=0.24.4 <0.28.0'
|
||||
barback: '^0.15.2+2'
|
||||
dart_style: '>=0.1.8 <0.3.0'
|
||||
glob: '^1.0.0'
|
||||
html: '^0.12.0'
|
||||
intl: '^0.12.4'
|
||||
logging: '>=0.9.0 <0.12.0'
|
||||
observe: '^0.13.1'
|
||||
path: '^1.0.0'
|
||||
protobuf: '0.5.1'
|
||||
source_span: '^1.0.0'
|
||||
stack_trace: '^1.1.1'
|
||||
build: '>=0.0.1'
|
||||
dev_dependencies:
|
||||
transformer_test: '^0.2.0'
|
||||
guinness: '^0.1.18'
|
||||
guinness2: '0.0.5'
|
||||
quiver: '^0.21.4'
|
||||
test: '^0.12.6'
|
||||
transformers:
|
||||
- angular2/transform/codegen
|
||||
- $dart2js:
|
||||
commandLineOptions:
|
||||
- --show-package-warnings
|
|
@ -1 +0,0 @@
|
|||
export '../core/private_export.dart';
|
|
@ -15,7 +15,6 @@ import {ComponentInstruction} from './instruction';
|
|||
// TODO(rado): find a better way to fix this, or remove if likely culprit
|
||||
// https://github.com/systemjs/systemjs/issues/487 gets closed.
|
||||
var __ignore_me = global;
|
||||
var __make_dart_analyzer_happy: Promise<any> = null;
|
||||
|
||||
/**
|
||||
* Defines route lifecycle method `routerOnActivate`, which is called by the router at the end of a
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
/**
|
||||
* This indirection is needed for TS compilation path.
|
||||
* See comment in lifecycle_annotations.ts.
|
||||
*/
|
||||
|
||||
library angular2.router.lifecycle_annotations;
|
||||
|
||||
export "./lifecycle_annotations_impl.dart";
|
|
@ -1,38 +0,0 @@
|
|||
library angular.router.route_lifecycle_reflector;
|
||||
|
||||
import 'package:angular2/src/router/lifecycle/lifecycle_annotations_impl.dart';
|
||||
import 'package:angular2/src/router/interfaces.dart';
|
||||
import 'package:angular2/src/core/reflection/reflection.dart';
|
||||
|
||||
bool hasLifecycleHook(RouteLifecycleHook e, type) {
|
||||
if (type is! Type) return false;
|
||||
|
||||
final List interfaces = reflector.interfaces(type);
|
||||
var interface;
|
||||
|
||||
if (e == routerOnActivate) {
|
||||
interface = OnActivate;
|
||||
} else if (e == routerOnDeactivate) {
|
||||
interface = OnDeactivate;
|
||||
} else if (e == routerOnReuse) {
|
||||
interface = OnReuse;
|
||||
} else if (e == routerCanDeactivate) {
|
||||
interface = CanDeactivate;
|
||||
} else if (e == routerCanReuse) {
|
||||
interface = CanReuse;
|
||||
}
|
||||
|
||||
return interfaces.contains(interface);
|
||||
}
|
||||
|
||||
Function getCanActivateHook(type) {
|
||||
final List annotations = reflector.annotations(type);
|
||||
|
||||
for (var annotation in annotations) {
|
||||
if (annotation is CanActivate) {
|
||||
return annotation.fn;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
|
@ -1,3 +0,0 @@
|
|||
library angular2.router.route_config_decorator;
|
||||
|
||||
export './route_config_impl.dart';
|
|
@ -12,8 +12,6 @@ import {RegexSerializer} from '../rules/route_paths/regex_route_path';
|
|||
|
||||
export {RouteDefinition} from '../route_definition';
|
||||
|
||||
var __make_dart_analyzer_happy: Promise<any> = null;
|
||||
|
||||
/**
|
||||
* The `RouteConfig` decorator defines routes for a given component.
|
||||
*
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
library angular2.src.router.route_config_normalizer;
|
||||
|
||||
import "route_config_decorator.dart";
|
||||
import "../route_definition.dart";
|
||||
import "../route_registry.dart";
|
||||
import "package:angular2/src/facade/lang.dart";
|
||||
import "package:angular2/src/facade/exceptions.dart" show BaseException;
|
||||
|
||||
RouteDefinition normalizeRouteConfig(RouteDefinition config, RouteRegistry registry) {
|
||||
if (config is AsyncRoute) {
|
||||
|
||||
configRegistryAndReturnType(componentType) {
|
||||
registry.configFromComponent(componentType);
|
||||
return componentType;
|
||||
}
|
||||
|
||||
loader() {
|
||||
return config.loader().then(configRegistryAndReturnType);
|
||||
}
|
||||
return new AsyncRoute(path: config.path, loader: loader, name: config.name, data: config.data, useAsDefault: config.useAsDefault);
|
||||
}
|
||||
return config;
|
||||
}
|
||||
|
||||
void assertComponentExists(Type component, String path) {
|
||||
if (component == null) {
|
||||
throw new BaseException(
|
||||
'Component for route "${path}" is not defined, or is not a class.');
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
library angular2.src.router.route_definition;
|
||||
|
||||
abstract class RouteDefinition {
|
||||
final String path;
|
||||
final String name;
|
||||
final bool useAsDefault;
|
||||
final String regex;
|
||||
final List<String> regex_group_names;
|
||||
final Function serializer;
|
||||
const RouteDefinition({this.path, this.name, this.useAsDefault : false, this.regex, this.regex_group_names, this.serializer});
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
library angular2.test.router.route_config_spec;
|
||||
|
||||
/**
|
||||
* This is intentionally left blank. `route_config_spec.ts` contains tests specific
|
||||
* to using untyped objects for users writing idiomatic ES5 or TS.
|
||||
* The rest of the router tests have typed annotations, so there's no need to add
|
||||
* additional tests here for Dart.
|
||||
*/
|
||||
main() {}
|
|
@ -1,20 +0,0 @@
|
|||
library router.spies;
|
||||
|
||||
import 'package:angular2/platform/common.dart' show PlatformLocation, Location;
|
||||
import 'package:angular2/router.dart';
|
||||
import 'package:angular2/testing_internal.dart';
|
||||
|
||||
@proxy
|
||||
class SpyLocation extends SpyObject implements Location {}
|
||||
|
||||
@proxy
|
||||
class SpyRouter extends SpyObject implements Router {}
|
||||
|
||||
@proxy
|
||||
class SpyRouterOutlet extends SpyObject implements RouterOutlet {}
|
||||
|
||||
class SpyPlatformLocation extends SpyObject implements PlatformLocation {
|
||||
String pathname = null;
|
||||
String search = null;
|
||||
String hash = null;
|
||||
}
|
|
@ -1,3 +0,0 @@
|
|||
library benchmarks.e2e_test.compiler_perf;
|
||||
|
||||
main() {}
|
|
@ -1,3 +0,0 @@
|
|||
library benchmarks.e2e_test.costs_perf;
|
||||
|
||||
main() {}
|
|
@ -1,3 +0,0 @@
|
|||
library benchmarks.e2e_test.di_perf;
|
||||
|
||||
main() {}
|
|
@ -1,3 +0,0 @@
|
|||
library benchmarks.e2e_test.largetable_perf;
|
||||
|
||||
main() {}
|
|
@ -1,3 +0,0 @@
|
|||
library benchmarks.e2e_test.naive_infinite_scroll_perf;
|
||||
|
||||
main() {}
|
|
@ -1,3 +0,0 @@
|
|||
library benchmarks.e2e_test.naive_infinite_scroll_spec;
|
||||
|
||||
main() {}
|
|
@ -1,3 +0,0 @@
|
|||
library benchmarks.e2e_test.page_load_perf;
|
||||
|
||||
main() {}
|
|
@ -1,3 +0,0 @@
|
|||
library benchmarks.e2e_test.selector_perf;
|
||||
|
||||
main() {}
|
|
@ -1,3 +0,0 @@
|
|||
library benchmarks.e2e_test.static_tree_perf;
|
||||
|
||||
main() {}
|
|
@ -1,3 +0,0 @@
|
|||
library benchmarks.e2e_test.tree_perf;
|
||||
|
||||
main() {}
|
|
@ -1,38 +0,0 @@
|
|||
name: angular2_benchmarks
|
||||
version: <%= packageJson.version %>
|
||||
authors:
|
||||
<%= Object.keys(packageJson.contributors).map(function(name) {
|
||||
return '- '+name+' <'+packageJson.contributors[name]+'>';
|
||||
}).join('\n') %>
|
||||
description: Angular2 benchmarks
|
||||
homepage: <%= packageJson.homepage %>
|
||||
environment:
|
||||
sdk: '>=1.10.0 <2.0.0'
|
||||
dependencies:
|
||||
angular2: '^<%= packageJson.version %>'
|
||||
browser: '^0.10.0'
|
||||
dependency_overrides:
|
||||
angular2:
|
||||
path: ../angular2
|
||||
transformers:
|
||||
- angular2/transform/codegen
|
||||
- angular2/transform/reflection_remover:
|
||||
$include:
|
||||
- web/src/compiler/compiler_benchmark.dart
|
||||
- web/src/costs/index.dart
|
||||
- web/src/di/di_benchmark.dart
|
||||
- web/src/element_injector/element_injector_benchmark.dart
|
||||
- web/src/largetable/largetable_benchmark.dart
|
||||
- web/src/naive_infinite_scroll/index.dart
|
||||
- web/src/static_tree/tree_benchmark.dart
|
||||
- web/src/tree/tree_benchmark.dart
|
||||
- web/src/page_load/page_load.dart
|
||||
- $dart2js:
|
||||
$include: web/src/**
|
||||
minify: false
|
||||
commandLineOptions:
|
||||
- --dump-info
|
||||
- --trust-type-annotations
|
||||
- --trust-primitives
|
||||
- --show-package-warnings
|
||||
- --fatal-warnings
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue