Revert "feat(core): extract platforms out of core"
This reverts commit 3f4628c0b0.
This commit is contained in:
@@ -8,7 +8,7 @@ export {
|
||||
export {SourceModule, SourceWithImports} from './source_module';
|
||||
export {PLATFORM_DIRECTIVES, PLATFORM_PIPES} from 'angular2/src/core/platform_directives_and_pipes';
|
||||
|
||||
import {assertionsEnabled, Type, CONST_EXPR} from 'angular2/src/facade/lang';
|
||||
import {assertionsEnabled, Type} from 'angular2/src/facade/lang';
|
||||
import {provide, Provider} from 'angular2/src/core/di';
|
||||
import {TemplateParser} from 'angular2/src/compiler/template_parser';
|
||||
import {HtmlParser} from 'angular2/src/compiler/html_parser';
|
||||
@@ -28,27 +28,26 @@ import {AppRootUrl} from 'angular2/src/compiler/app_root_url';
|
||||
import {AnchorBasedAppRootUrl} from 'angular2/src/compiler/anchor_based_app_root_url';
|
||||
import {Parser, Lexer} from 'angular2/src/core/change_detection/change_detection';
|
||||
|
||||
function _createChangeDetectorGenConfig() {
|
||||
return new ChangeDetectorGenConfig(assertionsEnabled(), false, true);
|
||||
export function compilerProviders(): Array<Type | Provider | any[]> {
|
||||
return [
|
||||
Lexer,
|
||||
Parser,
|
||||
HtmlParser,
|
||||
TemplateParser,
|
||||
TemplateNormalizer,
|
||||
RuntimeMetadataResolver,
|
||||
StyleCompiler,
|
||||
CommandCompiler,
|
||||
ChangeDetectionCompiler,
|
||||
provide(ChangeDetectorGenConfig,
|
||||
{useValue: new ChangeDetectorGenConfig(assertionsEnabled(), false, true)}),
|
||||
TemplateCompiler,
|
||||
provide(RuntimeCompiler, {useClass: RuntimeCompiler_}),
|
||||
provide(Compiler, {useExisting: RuntimeCompiler}),
|
||||
DomElementSchemaRegistry,
|
||||
provide(ElementSchemaRegistry, {useExisting: DomElementSchemaRegistry}),
|
||||
AnchorBasedAppRootUrl,
|
||||
provide(AppRootUrl, {useExisting: AnchorBasedAppRootUrl}),
|
||||
UrlResolver
|
||||
];
|
||||
}
|
||||
|
||||
export const COMPILER_PROVIDERS: Array<Type | Provider | any[]> = CONST_EXPR([
|
||||
Lexer,
|
||||
Parser,
|
||||
HtmlParser,
|
||||
TemplateParser,
|
||||
TemplateNormalizer,
|
||||
RuntimeMetadataResolver,
|
||||
StyleCompiler,
|
||||
CommandCompiler,
|
||||
ChangeDetectionCompiler,
|
||||
new Provider(ChangeDetectorGenConfig, {useFactory: _createChangeDetectorGenConfig, deps: []}),
|
||||
TemplateCompiler,
|
||||
new Provider(RuntimeCompiler, {useClass: RuntimeCompiler_}),
|
||||
new Provider(Compiler, {useExisting: RuntimeCompiler}),
|
||||
DomElementSchemaRegistry,
|
||||
new Provider(ElementSchemaRegistry, {useExisting: DomElementSchemaRegistry}),
|
||||
AnchorBasedAppRootUrl,
|
||||
new Provider(AppRootUrl, {useExisting: AnchorBasedAppRootUrl}),
|
||||
UrlResolver
|
||||
]);
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
library angular2.src.services.xhr_impl;
|
||||
|
||||
import 'dart:async' show Future;
|
||||
import 'dart:html' show HttpRequest;
|
||||
import 'package:angular2/core.dart';
|
||||
import './xhr.dart' show XHR;
|
||||
|
||||
@Injectable()
|
||||
class XHRImpl extends XHR {
|
||||
Future<String> get(String url) {
|
||||
return HttpRequest.request(url).then((HttpRequest req) => req.responseText,
|
||||
onError: (_) => new Future.error('Failed to load $url'));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
import {Promise, PromiseWrapper, PromiseCompleter} from 'angular2/src/facade/promise';
|
||||
import {isPresent} from 'angular2/src/facade/lang';
|
||||
import {XHR} from './xhr';
|
||||
|
||||
export class XHRImpl extends XHR {
|
||||
get(url: string): Promise<string> {
|
||||
var completer: PromiseCompleter < string >= PromiseWrapper.completer();
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open('GET', url, true);
|
||||
xhr.responseType = 'text';
|
||||
|
||||
xhr.onload = function() {
|
||||
// responseText is the old-school way of retrieving response (supported by IE8 & 9)
|
||||
// response/responseType properties were introduced in XHR Level2 spec (supported by IE10)
|
||||
var response = isPresent(xhr.response) ? xhr.response : xhr.responseText;
|
||||
|
||||
// normalize IE9 bug (http://bugs.jquery.com/ticket/1450)
|
||||
var status = xhr.status === 1223 ? 204 : xhr.status;
|
||||
|
||||
// fix status code when it is 0 (0 status is undocumented).
|
||||
// Occurs when accessing file resources or on Android 4.1 stock browser
|
||||
// while retrieving files from application cache.
|
||||
if (status === 0) {
|
||||
status = response ? 200 : 0;
|
||||
}
|
||||
|
||||
if (200 <= status && status <= 300) {
|
||||
completer.resolve(response);
|
||||
} else {
|
||||
completer.reject(`Failed to load ${url}`, null);
|
||||
}
|
||||
};
|
||||
|
||||
xhr.onerror = function() { completer.reject(`Failed to load ${url}`, null); };
|
||||
|
||||
xhr.send();
|
||||
return completer.promise;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user