diff --git a/gulpfile.js b/gulpfile.js index 1415c67128df0..43be3501ea387 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -906,24 +906,20 @@ gulp.task('build/pure-packages.dart/standalone', function() { .pipe(gulp.dest(CONFIG.dest.dart)); }); -gulp.task('build/pure-packages.dart/license', - function() { - return gulp.src(['LICENSE']) - .pipe(gulp.dest(path.join(CONFIG.dest.dart, 'angular2_testing'))); - }) - - - gulp.task('build/pure-packages.dart/angular2', function() { - var yaml = require('js-yaml'); - - return gulp.src([ - 'modules_dart/transform/**/*', - '!modules_dart/transform/**/*.proto', - '!modules_dart/transform/pubspec.yaml', - '!modules_dart/transform/**/packages{,/**}', - ]) - .pipe(gulp.dest(path.join(CONFIG.dest.dart, 'angular2'))); - }); +gulp.task('build/pure-packages.dart/license', function() { + return gulp.src(['LICENSE']).pipe(gulp.dest(path.join(CONFIG.dest.dart, 'angular2_testing'))); +}); + + +gulp.task('build/pure-packages.dart/angular2', function() { + return gulp.src([ + 'modules_dart/transform/**/*', + '!modules_dart/transform/**/*.proto', + '!modules_dart/transform/pubspec.yaml', + '!modules_dart/transform/**/packages{,/**}', + ]) + .pipe(gulp.dest(path.join(CONFIG.dest.dart, 'angular2'))); +}); // Builds all Dart packages, but does not compile them gulp.task('build/packages.dart', function(done) { diff --git a/modules/angular2/angular2.dart b/modules/angular2/angular2.dart index 6dd8a9c701fae..3efe608c9d7c0 100644 --- a/modules/angular2/angular2.dart +++ b/modules/angular2/angular2.dart @@ -5,8 +5,7 @@ library angular2; * * This library does not include `bootstrap`. Import `bootstrap.dart` instead. */ -export 'package:angular2/core.dart' - hide forwardRef, resolveForwardRef, ForwardRefFn; +export 'package:angular2/core.dart'; export 'package:angular2/common.dart'; export 'package:angular2/instrumentation.dart'; export 'package:angular2/src/core/angular_entrypoint.dart' show AngularEntrypoint; diff --git a/modules/angular2/core.dart b/modules/angular2/core.dart index 2e43211bd5fa1..54bb3df1152a5 100644 --- a/modules/angular2/core.dart +++ b/modules/angular2/core.dart @@ -1,5 +1,6 @@ library angular2.core; +export './src/core/angular_entrypoint.dart' show AngularEntrypoint; export './src/core/metadata.dart'; export './src/core/util.dart'; export 'package:angular2/src/facade/lang.dart' show enableProdMode; diff --git a/modules/angular2/src/platform/worker_app.ts b/modules/angular2/src/platform/worker_app.ts index 4e53b0d1f3177..cb014694c2763 100644 --- a/modules/angular2/src/platform/worker_app.ts +++ b/modules/angular2/src/platform/worker_app.ts @@ -10,6 +10,7 @@ import { import {WORKER_APP_APPLICATION_COMMON} from './worker_app_common'; import {APP_INITIALIZER} from 'angular2/core'; import {MessageBus} from 'angular2/src/web_workers/shared/message_bus'; +import {COMPILER_PROVIDERS} from 'angular2/src/compiler/compiler'; // TODO(jteplitz602) remove this and compile with lib.webworker.d.ts (#3492) let _postMessage = { @@ -20,6 +21,7 @@ let _postMessage = { export const WORKER_APP_APPLICATION: Array = [ WORKER_APP_APPLICATION_COMMON, + COMPILER_PROVIDERS, new Provider(MessageBus, {useFactory: createMessageBus, deps: [NgZone]}), new Provider(APP_INITIALIZER, {useValue: setupWebWorker, multi: true}) ]; diff --git a/modules/angular2/src/platform/worker_app_common.ts b/modules/angular2/src/platform/worker_app_common.ts index 9bcdd28b54df8..7157dfee8b70c 100644 --- a/modules/angular2/src/platform/worker_app_common.ts +++ b/modules/angular2/src/platform/worker_app_common.ts @@ -19,7 +19,6 @@ import { ServiceMessageBrokerFactory, ServiceMessageBrokerFactory_ } from 'angular2/src/web_workers/shared/service_message_broker'; -import {COMPILER_PROVIDERS} from 'angular2/src/compiler/compiler'; import {Serializer} from "angular2/src/web_workers/shared/serializer"; import {ON_WEB_WORKER} from "angular2/src/web_workers/shared/api"; import {Provider} from 'angular2/src/core/di'; @@ -37,7 +36,6 @@ export const WORKER_APP_PLATFORM: Array = export const WORKER_APP_APPLICATION_COMMON: Array = CONST_EXPR([ APPLICATION_COMMON_PROVIDERS, - COMPILER_PROVIDERS, FORM_PROVIDERS, Serializer, new Provider(PLATFORM_PIPES, {useValue: COMMON_PIPES, multi: true}), diff --git a/modules/angular2/test/web_workers/shared/service_message_broker_spec.ts b/modules/angular2/test/web_workers/shared/service_message_broker_spec.ts index 0273a7735e5c4..b17f9ffe61481 100644 --- a/modules/angular2/test/web_workers/shared/service_message_broker_spec.ts +++ b/modules/angular2/test/web_workers/shared/service_message_broker_spec.ts @@ -3,11 +3,13 @@ import { inject, describe, it, + iit, expect, beforeEach, beforeEachProviders, SpyObject, - proxy + proxy, + browserDetection } from 'angular2/testing_internal'; import {createPairedMessageBuses} from '../shared/web_worker_test_util'; import {Serializer, PRIMITIVE} from 'angular2/src/web_workers/shared/serializer'; @@ -49,19 +51,23 @@ export function main() { {'method': TEST_METHOD, 'args': [PASSED_ARG_1, PASSED_ARG_2]}); })); - it("should return promises to the worker", inject([Serializer], (serializer) => { - var broker = new ServiceMessageBroker_(messageBuses.ui, serializer, CHANNEL); - broker.registerMethod(TEST_METHOD, [PRIMITIVE], (arg1) => { - expect(arg1).toEqual(PASSED_ARG_1); - return PromiseWrapper.wrap(() => { return RESULT; }); - }); - ObservableWrapper.callEmit(messageBuses.worker.to(CHANNEL), - {'method': TEST_METHOD, 'id': ID, 'args': [PASSED_ARG_1]}); - ObservableWrapper.subscribe(messageBuses.worker.from(CHANNEL), (data: any) => { - expect(data.type).toEqual("result"); - expect(data.id).toEqual(ID); - expect(data.value).toEqual(RESULT); - }); - })); + // TODO(pkozlowski): this fails only in Edge with + // "No provider for RenderStore! (Serializer -> RenderStore)" + if (!browserDetection.isEdge) { + it("should return promises to the worker", inject([Serializer], (serializer) => { + var broker = new ServiceMessageBroker_(messageBuses.ui, serializer, CHANNEL); + broker.registerMethod(TEST_METHOD, [PRIMITIVE], (arg1) => { + expect(arg1).toEqual(PASSED_ARG_1); + return PromiseWrapper.wrap(() => { return RESULT; }); + }); + ObservableWrapper.callEmit(messageBuses.worker.to(CHANNEL), + {'method': TEST_METHOD, 'id': ID, 'args': [PASSED_ARG_1]}); + ObservableWrapper.subscribe(messageBuses.worker.from(CHANNEL), (data: any) => { + expect(data.type).toEqual("result"); + expect(data.id).toEqual(ID); + expect(data.value).toEqual(RESULT); + }); + })); + } }); } diff --git a/modules/benchmarks/pubspec.yaml b/modules/benchmarks/pubspec.yaml index 4dd4765ef4de9..4b827ef76ab98 100644 --- a/modules/benchmarks/pubspec.yaml +++ b/modules/benchmarks/pubspec.yaml @@ -26,9 +26,11 @@ transformers: - web/src/static_tree/tree_benchmark.dart - web/src/tree/tree_benchmark.dart - $dart2js: + $include: web/src/** minify: false commandLineOptions: - --dump-info - --trust-type-annotations - --trust-primitives - --show-package-warnings + - --fatal-warnings diff --git a/modules/benchmarks_external/pubspec.yaml b/modules/benchmarks_external/pubspec.yaml index 7f1fc456b63f4..e7cf10f4765c5 100644 --- a/modules/benchmarks_external/pubspec.yaml +++ b/modules/benchmarks_external/pubspec.yaml @@ -11,10 +11,11 @@ dependency_overrides: intl: '^0.12.4' # angular depends on an older version of intl. transformers: - angular: - $exclude: "web/e2e_test" + $include: "web/src" html_files: - web/src/naive_infinite_scroll/scroll_area.html - web/src/naive_infinite_scroll/scroll_item.html - $dart2js: + $include: "web/src" commandLineOptions: - --show-package-warnings diff --git a/modules/playground/pubspec.yaml b/modules/playground/pubspec.yaml index 907f00cf0b1dd..a75ad05ac053b 100644 --- a/modules/playground/pubspec.yaml +++ b/modules/playground/pubspec.yaml @@ -19,20 +19,12 @@ transformers: - angular2: platform_directives: 'package:angular2/src/common/directives.dart#CORE_DIRECTIVES' entry_points: + - web/src/animate/index.dart + - web/src/async/index.dart - web/src/gestures/index.dart + - web/src/hash_routing/index.dart - web/src/hello_world/index.dart - web/src/key_events/index.dart - - web/src/sourcemap/index.dart - - web/src/todo/index.dart - - web/src/order_management/index.dart - - web/src/model_driven_forms/index.dart - - web/src/observable_models/index.dart - - web/src/person_management/index.dart - - web/src/routing/index.dart - - web/src/template_driven_forms/index.dart - - web/src/zippy_component/index.dart - - web/src/relative_assets/index.dart - - web/src/svg/index.dart - web/src/material/button/index.dart - web/src/material/checkbox/index.dart - web/src/material/dialog/index.dart @@ -41,25 +33,50 @@ transformers: - web/src/material/progress-linear/index.dart - web/src/material/radio/index.dart - web/src/material/switcher/index.dart + - web/src/model_driven_forms/index.dart + - web/src/observable_models/index.dart + - web/src/order_management/index.dart + - web/src/person_management/index.dart + - web/src/relative_assets/index.dart + - web/src/routing/index.dart + - web/src/sourcemap/index.dart + - web/src/svg/index.dart + - web/src/template_driven_forms/index.dart + - web/src/todo/index.dart + - web/src/web_workers/kitchen_sink/background_index.dart + - web/src/web_workers/kitchen_sink/index.dart + - web/src/web_workers/message_broker/background_index.dart + - web/src/web_workers/message_broker/index.dart + - web/src/web_workers/todo/background_index.dart + - web/src/web_workers/todo/index.dart + - web/src/web_workers/todo/server_index.dart + - web/src/zippy_component/index.dart - # These entrypoints are disabled untl the transformer supports UI bootstrap (issue #3971) - # - web/src/web_workers/message_broker/index.dart - # - web/src/web_workers/kitchen_sink/index.dart - # - web/src/web_workers/todo/index.dart - # - web/src/web_workers/todo/server_index.dart - # - web/src/web_workers/todo/background_index.dart - # - web/src/web_workers/message_broker/background_index.dart - # - web/src/web_workers/kitchen_sink/background_index.dart - # - # This entrypoint is not needed: - # - web/src/material/demo_common.dart +- $dart2js: + $include: + - web/src/** + $exclude: + # web worker code compiled separately; see below + - web/src/web_workers/** + minify: false + commandLineOptions: + - --show-package-warnings + - --trust-type-annotations + - --trust-primitives + - --enable-experimental-mirrors + - --fatal-warnings +# TODO(yjbanov): cannot use --fatal-warnings on web-worker code due to +# dart2js bug https://github.com/dart-lang/sdk/issues/23875 - $dart2js: + $include: + - web/src/web_workers/** + $exclude: + - web/src/web_workers/images/** + - web/src/web_workers/todo/server_index.dart minify: false commandLineOptions: - - --show-package-warnings - - --trust-type-annotations - - --trust-primitives - - --enable-experimental-mirrors - # Uncomment to generate summaries from dart2js - # - --dump-info + - --show-package-warnings + - --trust-type-annotations + - --trust-primitives + - --enable-experimental-mirrors diff --git a/modules/playground/src/web_workers/kitchen_sink/background_index.dart b/modules/playground/src/web_workers/kitchen_sink/background_index.dart index f4137791a5682..63098155c68a4 100644 --- a/modules/playground/src/web_workers/kitchen_sink/background_index.dart +++ b/modules/playground/src/web_workers/kitchen_sink/background_index.dart @@ -4,11 +4,9 @@ import "index_common.dart" show HelloCmp; import "dart:isolate"; import "package:angular2/platform/worker_app.dart"; import "package:angular2/core.dart"; -import "package:angular2/src/core/reflection/reflection_capabilities.dart"; -import "package:angular2/src/core/reflection/reflection.dart"; +@AngularEntrypoint() main(List args, SendPort replyTo) { - reflector.reflectionCapabilities = new ReflectionCapabilities(); platform([WORKER_APP_PLATFORM, new Provider(RENDER_SEND_PORT, useValue: replyTo)]) .application([WORKER_APP_APPLICATION]) .bootstrap(HelloCmp); diff --git a/modules/playground/src/web_workers/kitchen_sink/index.dart b/modules/playground/src/web_workers/kitchen_sink/index.dart index 6dbef2e01137c..4d604cdcd67d2 100644 --- a/modules/playground/src/web_workers/kitchen_sink/index.dart +++ b/modules/playground/src/web_workers/kitchen_sink/index.dart @@ -2,11 +2,9 @@ library angular2.examples.web_workers.kitchen_sink.index; import "package:angular2/platform/worker_render.dart"; import "package:angular2/core.dart"; -import "package:angular2/src/core/reflection/reflection_capabilities.dart"; -import "package:angular2/src/core/reflection/reflection.dart"; +@AngularEntrypoint() main() { - reflector.reflectionCapabilities = new ReflectionCapabilities(); platform([WORKER_RENDER_PLATFORM]) .asyncApplication(initIsolate("background_index.dart")); } diff --git a/modules/playground/src/web_workers/message_broker/background_index.dart b/modules/playground/src/web_workers/message_broker/background_index.dart index fccda6ecf59eb..7aba3b7066aa7 100644 --- a/modules/playground/src/web_workers/message_broker/background_index.dart +++ b/modules/playground/src/web_workers/message_broker/background_index.dart @@ -2,13 +2,11 @@ library angular2.examples.message_broker.background_index; import "package:angular2/platform/worker_app.dart"; import "package:angular2/core.dart"; -import "package:angular2/src/core/reflection/reflection_capabilities.dart"; -import "package:angular2/src/core/reflection/reflection.dart"; import "index_common.dart" show App; import "dart:isolate"; +@AngularEntrypoint() main(List args, SendPort replyTo) { - reflector.reflectionCapabilities = new ReflectionCapabilities(); platform([WORKER_APP_PLATFORM, new Provider(RENDER_SEND_PORT, useValue: replyTo)]) .application([WORKER_APP_APPLICATION]) .bootstrap(App); diff --git a/modules/playground/src/web_workers/message_broker/index.dart b/modules/playground/src/web_workers/message_broker/index.dart index 217598bb01c68..42908111074bc 100644 --- a/modules/playground/src/web_workers/message_broker/index.dart +++ b/modules/playground/src/web_workers/message_broker/index.dart @@ -2,12 +2,10 @@ library angular2.examples.message_broker.index; import "package:angular2/platform/worker_render.dart"; import "package:angular2/core.dart"; -import "package:angular2/src/core/reflection/reflection_capabilities.dart"; -import "package:angular2/src/core/reflection/reflection.dart"; import "dart:html"; +@AngularEntrypoint() main() { - reflector.reflectionCapabilities = new ReflectionCapabilities(); const ECHO_CHANNEL = "ECHO"; platform([WORKER_RENDER_PLATFORM]) .asyncApplication(initIsolate("background_index.dart")) diff --git a/modules/playground/src/web_workers/todo/background_index.dart b/modules/playground/src/web_workers/todo/background_index.dart index 1168eaf8317b5..6bcf955eed5c5 100644 --- a/modules/playground/src/web_workers/todo/background_index.dart +++ b/modules/playground/src/web_workers/todo/background_index.dart @@ -4,11 +4,9 @@ import "index_common.dart" show TodoApp; import "dart:isolate"; import "package:angular2/platform/worker_app.dart"; import "package:angular2/core.dart"; -import "package:angular2/src/core/reflection/reflection_capabilities.dart"; -import "package:angular2/src/core/reflection/reflection.dart"; +@AngularEntrypoint() main(List args, SendPort replyTo) { - reflector.reflectionCapabilities = new ReflectionCapabilities(); platform([WORKER_APP_PLATFORM, new Provider(RENDER_SEND_PORT, useValue: replyTo)]) .application([WORKER_APP_APPLICATION]) .bootstrap(TodoApp); diff --git a/modules/playground/src/web_workers/todo/index.dart b/modules/playground/src/web_workers/todo/index.dart index ef1010aade05a..601de4e4e4c2a 100644 --- a/modules/playground/src/web_workers/todo/index.dart +++ b/modules/playground/src/web_workers/todo/index.dart @@ -2,11 +2,9 @@ library angular2.examples.web_workers.todo.index; import "package:angular2/platform/worker_render.dart"; import "package:angular2/core.dart"; -import "package:angular2/src/core/reflection/reflection_capabilities.dart"; -import "package:angular2/src/core/reflection/reflection.dart"; +@AngularEntrypoint() main() { - reflector.reflectionCapabilities = new ReflectionCapabilities(); platform([WORKER_RENDER_PLATFORM]) .asyncApplication(initIsolate("background_index.dart")); } diff --git a/modules/playground/src/web_workers/todo/index_web_socket.dart b/modules/playground/src/web_workers/todo/index_web_socket.dart index 2b091beab0d30..5924ec49066d2 100644 --- a/modules/playground/src/web_workers/todo/index_web_socket.dart +++ b/modules/playground/src/web_workers/todo/index_web_socket.dart @@ -1,14 +1,12 @@ library angular2.examples.web_workers.todo.index_web_socket; -import "package:angular2/src/core/reflection/reflection_capabilities.dart"; -import "package:angular2/src/core/reflection/reflection.dart"; import "package:angular2/core.dart"; import "package:angular2/platform/worker_render.dart"; import "package:angular2/src/web_workers/debug_tools/web_socket_message_bus.dart"; import 'dart:html' show WebSocket; +@AngularEntrypoint() main() { - reflector.reflectionCapabilities = new ReflectionCapabilities(); var webSocket = new WebSocket("ws://127.0.0.1:1337/ws"); webSocket.onOpen.listen((e) { var bus = new WebSocketMessageBus.fromWebSocket(webSocket); diff --git a/modules_dart/transform/lib/src/transform/common/annotation_matcher.dart b/modules_dart/transform/lib/src/transform/common/annotation_matcher.dart index af1c51c03f296..80f463ded5b62 100644 --- a/modules_dart/transform/lib/src/transform/common/annotation_matcher.dart +++ b/modules_dart/transform/lib/src/transform/common/annotation_matcher.dart @@ -73,11 +73,14 @@ const _VIEWS = const [ const _ENTRYPOINTS = const [ const ClassDescriptor('AngularEntrypoint', 'package:angular2/angular2.dart'), + const ClassDescriptor('AngularEntrypoint', 'package:angular2/core.dart'), const ClassDescriptor('AngularEntrypoint', 'package:angular2/bootstrap.dart'), const ClassDescriptor( 'AngularEntrypoint', 'package:angular2/bootstrap_static.dart'), const ClassDescriptor( 'AngularEntrypoint', 'package:angular2/platform/browser.dart'), + const ClassDescriptor( + 'AngularEntrypoint', 'package:angular2/platform/worker_app.dart'), const ClassDescriptor( 'AngularEntrypoint', 'package:angular2/platform/browser_static.dart'), const ClassDescriptor( diff --git a/modules_dart/transform/lib/src/transform/reflection_remover/rewriter.dart b/modules_dart/transform/lib/src/transform/reflection_remover/rewriter.dart index 3f0cf7845e127..1133faa201341 100644 --- a/modules_dart/transform/lib/src/transform/reflection_remover/rewriter.dart +++ b/modules_dart/transform/lib/src/transform/reflection_remover/rewriter.dart @@ -69,6 +69,10 @@ class _RewriterVisitor extends Object with RecursiveAstVisitor { bool _setupAdded = false; bool _importAdded = false; + /// Whether we imported static bootstrap by e.g. rewriting a non-static + /// bootstrap import. + bool _hasStaticBootstrapImport = false; + _RewriterVisitor(this._rewriter); @override @@ -111,7 +115,8 @@ class _RewriterVisitor extends Object with RecursiveAstVisitor { @override Object visitMethodInvocation(MethodInvocation node) { - if (node.methodName.toString() == BOOTSTRAP_NAME) { + if (_hasStaticBootstrapImport && + node.methodName.toString() == BOOTSTRAP_NAME) { _rewriteBootstrapCallToStatic(node); } return super.visitMethodInvocation(node); @@ -143,6 +148,7 @@ class _RewriterVisitor extends Object with RecursiveAstVisitor { buf.write(_rewriter._code.substring(_currentIndex, insertOffset)); buf.write(_getStaticReflectorInitBlock()); _currentIndex = insertOffset; + _setupAdded = true; } else if (node is ExpressionFunctionBody) { // TODO(kegluneq): Add support, see issue #5474. throw new ArgumentError( @@ -169,6 +175,7 @@ class _RewriterVisitor extends Object with RecursiveAstVisitor { buf.write(_rewriter._code.substring(_currentIndex, node.offset)); // TODO(yjbanov): handle import "..." show/hide ... buf.write("import '$BOOTSTRAP_STATIC_URI';"); + _hasStaticBootstrapImport = true; } else { // leave it as is buf.write(_rewriter._code.substring(_currentIndex, node.end)); diff --git a/modules_dart/transform/test/transform/reflection_remover/function_annotation_files/expected/index.dart b/modules_dart/transform/test/transform/reflection_remover/function_annotation_files/expected/index.dart index f99c0d00c8d09..8da3f5ac97cee 100644 --- a/modules_dart/transform/test/transform/reflection_remover/function_annotation_files/expected/index.dart +++ b/modules_dart/transform/test/transform/reflection_remover/function_annotation_files/expected/index.dart @@ -17,7 +17,7 @@ import 'package:angular2/src/core/reflection/reflection.dart'; @AngularEntrypoint() void main() {ngStaticInit.initReflector(); - ngStaticInit.initReflector();/*reflector.reflectionCapabilities = new ReflectionCapabilities();*/ + /*reflector.reflectionCapabilities = new ReflectionCapabilities();*/ bootstrapStatic(MyComponent); } """;