From 93c3d8f9fd79014bf700a1447503f5ee6f170bf9 Mon Sep 17 00:00:00 2001 From: Joey Perrott Date: Mon, 14 Sep 2020 15:48:03 -0700 Subject: [PATCH] fix(platform-webworker): remove platform-webworker and platform-webworker-dynamic (#38846) Remove @angular/platform-webworker and @angular/platform-webworker-dynamic as they were deprecated in v8 BREAKING CHANGE: @angular/platform-webworker and @angular/platform-webworker-dynamic have been removed as they were deprecated in v8 PR Close #38846 --- .gitmessage | 6 +- .pullapprove.yml | 2 - CONTRIBUTING.md | 8 +- aio/content/guide/deprecations.md | 37 -- .../transforms/authors-package/api-package.js | 2 - docs/PUBLIC_API.md | 6 +- integration/angular_integration_test.bzl | 2 - integration/ng_update/package.json | 2 - integration/typings_test_ts39/include-all.ts | 4 - integration/typings_test_ts39/package.json | 2 - integration/typings_test_ts40/include-all.ts | 4 - integration/typings_test_ts40/package.json | 2 - .../web_workers/animations/BUILD.bazel | 7 - .../web_workers/animations/animations_spec.ts | 79 ---- .../e2e_test/web_workers/input/BUILD.bazel | 7 - .../e2e_test/web_workers/input/input_spec.ts | 75 ---- .../web_workers/kitchen_sink/BUILD.bazel | 7 - .../kitchen_sink/kitchen_sink_spec.ts | 58 --- .../web_workers/message_broker/BUILD.bazel | 7 - .../message_broker/message_broker_spec.ts | 47 --- .../e2e_test/web_workers/router/BUILD.bazel | 7 - .../web_workers/router/router_spec.ts | 88 ---- .../e2e_test/web_workers/todo/BUILD.bazel | 7 - .../e2e_test/web_workers/todo/todo_spec.ts | 33 -- .../playground/src/web_workers/BUILD.bazel | 13 - .../src/web_workers/animations/BUILD.bazel | 31 -- .../animations/background_index.ts | 19 - .../src/web_workers/animations/index.html | 11 - .../src/web_workers/animations/index.ts | 11 - .../web_workers/animations/index_common.ts | 43 -- .../src/web_workers/animations/loader.js | 14 - .../src/web_workers/images/BUILD.bazel | 41 -- .../web_workers/images/background_index.ts | 19 - .../src/web_workers/images/image_demo.css | 30 -- .../src/web_workers/images/image_demo.html | 36 -- .../src/web_workers/images/index.html | 13 - .../src/web_workers/images/index.ts | 11 - .../src/web_workers/images/index_common.ts | 56 --- .../src/web_workers/images/loader.css | 71 ---- .../src/web_workers/images/loader.js | 19 - .../src/web_workers/images/services/bitmap.ts | 179 -------- .../src/web_workers/images/single_thread.html | 17 - .../src/web_workers/images/single_thread.ts | 21 - .../src/web_workers/input/BUILD.bazel | 38 -- .../src/web_workers/input/background_index.ts | 19 - .../src/web_workers/input/index.html | 14 - .../playground/src/web_workers/input/index.ts | 11 - .../src/web_workers/input/index_common.ts | 36 -- .../src/web_workers/input/loader.js | 14 - .../src/web_workers/kitchen_sink/BUILD.bazel | 38 -- .../kitchen_sink/background_index.ts | 23 -- .../src/web_workers/kitchen_sink/index.html | 27 -- .../src/web_workers/kitchen_sink/index.ts | 11 - .../web_workers/kitchen_sink/index_common.ts | 63 --- .../src/web_workers/kitchen_sink/loader.js | 14 - .../web_workers/message_broker/BUILD.bazel | 38 -- .../message_broker/background_index.ts | 19 - .../src/web_workers/message_broker/index.html | 14 - .../src/web_workers/message_broker/index.ts | 32 -- .../message_broker/index_common.ts | 25 -- .../src/web_workers/message_broker/loader.js | 14 - .../src/web_workers/router/BUILD.bazel | 41 -- .../src/web_workers/router/app.html | 11 - .../web_workers/router/background_index.ts | 12 - .../web_workers/router/components/about.ts | 12 - .../web_workers/router/components/contact.ts | 12 - .../web_workers/router/components/start.ts | 12 - .../src/web_workers/router/index.html | 10 - .../src/web_workers/router/index.ts | 11 - .../src/web_workers/router/index_common.ts | 35 -- .../src/web_workers/router/loader.js | 14 - .../src/web_workers/todo/BUILD.bazel | 41 -- .../src/web_workers/todo/background_index.ts | 20 - .../src/web_workers/todo/css/bg.png | Bin 2126 -> 0 bytes .../src/web_workers/todo/css/main.css | 386 ------------------ .../src/web_workers/todo/index.html | 13 - .../playground/src/web_workers/todo/index.ts | 11 - .../src/web_workers/todo/index_common.ts | 80 ---- .../web_workers/todo/index_web_socket.html | 10 - .../playground/src/web_workers/todo/loader.js | 14 - .../web_workers/todo/services/TodoStore.ts | 53 --- .../playground/src/web_workers/todo/todo.html | 68 --- .../src/web_workers/worker-configure.js | 14 - modules/playground/systemjs-config.js | 2 - packages/bazel/src/ng_package/ng_package.bzl | 2 - packages/circular-deps-test.conf.js | 3 +- packages/common/src/viewport_scroller.ts | 3 +- .../platform-webworker-dynamic/BUILD.bazel | 43 -- packages/platform-webworker-dynamic/index.ts | 14 - .../platform-webworker-dynamic/package.json | 29 -- .../platform-webworker-dynamic/public_api.ts | 15 - .../src/platform-webworker-dynamic.ts | 30 -- .../platform-webworker-dynamic/src/version.ts | 22 - packages/platform-webworker/BUILD.bazel | 49 --- packages/platform-webworker/PACKAGE.md | 2 - packages/platform-webworker/index.ts | 14 - packages/platform-webworker/package.json | 27 -- packages/platform-webworker/public_api.ts | 15 - .../src/platform-webworker.ts | 39 -- packages/platform-webworker/src/version.ts | 22 - .../src/web_workers/shared/api.ts | 11 - .../shared/client_message_broker.ts | 166 -------- .../src/web_workers/shared/message_bus.ts | 109 ----- .../src/web_workers/shared/messaging_api.ts | 16 - .../web_workers/shared/post_message_bus.ts | 169 -------- .../src/web_workers/shared/render_store.ts | 42 -- .../src/web_workers/shared/serializer.ts | 114 ------ .../shared/service_message_broker.ts | 106 ----- .../src/web_workers/ui/event_dispatcher.ts | 120 ------ .../src/web_workers/ui/event_serializer.ts | 70 ---- .../src/web_workers/ui/location_providers.ts | 42 -- .../src/web_workers/ui/platform_location.ts | 62 --- .../src/web_workers/ui/renderer.ts | 166 -------- .../web_workers/worker/location_providers.ts | 40 -- .../web_workers/worker/platform_location.ts | 153 ------- .../src/web_workers/worker/renderer.ts | 327 --------------- .../src/web_workers/worker/worker_adapter.ts | 106 ----- packages/platform-webworker/src/worker_app.ts | 86 ---- .../platform-webworker/src/worker_render.ts | 193 --------- packages/platform-webworker/test/BUILD.bazel | 35 -- .../web_workers/shared/message_bus_spec.ts | 172 -------- .../web_workers/shared/message_bus_util.ts | 38 -- .../web_workers/shared/mock_event_emitter.ts | 31 -- .../web_workers/shared/render_store_spec.ts | 37 -- .../shared/service_message_broker_spec.ts | 73 ---- .../shared/web_worker_test_util.ts | 150 ------- .../worker/platform_location_spec.ts | 97 ----- .../worker/renderer_v2_integration_spec.ts | 225 ---------- .../test/web_workers/worker/spies.ts | 16 - packages/tsconfig.json | 4 - scripts/release/post-check | 2 +- scripts/release/post-check-next | 2 +- test-main.js | 2 - tools/defaults.bzl | 2 - 134 files changed, 12 insertions(+), 5787 deletions(-) delete mode 100644 modules/playground/e2e_test/web_workers/animations/BUILD.bazel delete mode 100644 modules/playground/e2e_test/web_workers/animations/animations_spec.ts delete mode 100644 modules/playground/e2e_test/web_workers/input/BUILD.bazel delete mode 100644 modules/playground/e2e_test/web_workers/input/input_spec.ts delete mode 100644 modules/playground/e2e_test/web_workers/kitchen_sink/BUILD.bazel delete mode 100644 modules/playground/e2e_test/web_workers/kitchen_sink/kitchen_sink_spec.ts delete mode 100644 modules/playground/e2e_test/web_workers/message_broker/BUILD.bazel delete mode 100644 modules/playground/e2e_test/web_workers/message_broker/message_broker_spec.ts delete mode 100644 modules/playground/e2e_test/web_workers/router/BUILD.bazel delete mode 100644 modules/playground/e2e_test/web_workers/router/router_spec.ts delete mode 100644 modules/playground/e2e_test/web_workers/todo/BUILD.bazel delete mode 100644 modules/playground/e2e_test/web_workers/todo/todo_spec.ts delete mode 100644 modules/playground/src/web_workers/BUILD.bazel delete mode 100644 modules/playground/src/web_workers/animations/BUILD.bazel delete mode 100644 modules/playground/src/web_workers/animations/background_index.ts delete mode 100644 modules/playground/src/web_workers/animations/index.html delete mode 100644 modules/playground/src/web_workers/animations/index.ts delete mode 100644 modules/playground/src/web_workers/animations/index_common.ts delete mode 100644 modules/playground/src/web_workers/animations/loader.js delete mode 100644 modules/playground/src/web_workers/images/BUILD.bazel delete mode 100644 modules/playground/src/web_workers/images/background_index.ts delete mode 100644 modules/playground/src/web_workers/images/image_demo.css delete mode 100644 modules/playground/src/web_workers/images/image_demo.html delete mode 100644 modules/playground/src/web_workers/images/index.html delete mode 100644 modules/playground/src/web_workers/images/index.ts delete mode 100644 modules/playground/src/web_workers/images/index_common.ts delete mode 100644 modules/playground/src/web_workers/images/loader.css delete mode 100644 modules/playground/src/web_workers/images/loader.js delete mode 100644 modules/playground/src/web_workers/images/services/bitmap.ts delete mode 100644 modules/playground/src/web_workers/images/single_thread.html delete mode 100644 modules/playground/src/web_workers/images/single_thread.ts delete mode 100644 modules/playground/src/web_workers/input/BUILD.bazel delete mode 100644 modules/playground/src/web_workers/input/background_index.ts delete mode 100644 modules/playground/src/web_workers/input/index.html delete mode 100644 modules/playground/src/web_workers/input/index.ts delete mode 100644 modules/playground/src/web_workers/input/index_common.ts delete mode 100644 modules/playground/src/web_workers/input/loader.js delete mode 100644 modules/playground/src/web_workers/kitchen_sink/BUILD.bazel delete mode 100644 modules/playground/src/web_workers/kitchen_sink/background_index.ts delete mode 100644 modules/playground/src/web_workers/kitchen_sink/index.html delete mode 100644 modules/playground/src/web_workers/kitchen_sink/index.ts delete mode 100644 modules/playground/src/web_workers/kitchen_sink/index_common.ts delete mode 100644 modules/playground/src/web_workers/kitchen_sink/loader.js delete mode 100644 modules/playground/src/web_workers/message_broker/BUILD.bazel delete mode 100644 modules/playground/src/web_workers/message_broker/background_index.ts delete mode 100644 modules/playground/src/web_workers/message_broker/index.html delete mode 100644 modules/playground/src/web_workers/message_broker/index.ts delete mode 100644 modules/playground/src/web_workers/message_broker/index_common.ts delete mode 100644 modules/playground/src/web_workers/message_broker/loader.js delete mode 100644 modules/playground/src/web_workers/router/BUILD.bazel delete mode 100644 modules/playground/src/web_workers/router/app.html delete mode 100644 modules/playground/src/web_workers/router/background_index.ts delete mode 100644 modules/playground/src/web_workers/router/components/about.ts delete mode 100644 modules/playground/src/web_workers/router/components/contact.ts delete mode 100644 modules/playground/src/web_workers/router/components/start.ts delete mode 100644 modules/playground/src/web_workers/router/index.html delete mode 100644 modules/playground/src/web_workers/router/index.ts delete mode 100644 modules/playground/src/web_workers/router/index_common.ts delete mode 100644 modules/playground/src/web_workers/router/loader.js delete mode 100644 modules/playground/src/web_workers/todo/BUILD.bazel delete mode 100644 modules/playground/src/web_workers/todo/background_index.ts delete mode 100644 modules/playground/src/web_workers/todo/css/bg.png delete mode 100644 modules/playground/src/web_workers/todo/css/main.css delete mode 100644 modules/playground/src/web_workers/todo/index.html delete mode 100644 modules/playground/src/web_workers/todo/index.ts delete mode 100644 modules/playground/src/web_workers/todo/index_common.ts delete mode 100644 modules/playground/src/web_workers/todo/index_web_socket.html delete mode 100644 modules/playground/src/web_workers/todo/loader.js delete mode 100644 modules/playground/src/web_workers/todo/services/TodoStore.ts delete mode 100644 modules/playground/src/web_workers/todo/todo.html delete mode 100644 modules/playground/src/web_workers/worker-configure.js delete mode 100644 packages/platform-webworker-dynamic/BUILD.bazel delete mode 100644 packages/platform-webworker-dynamic/index.ts delete mode 100644 packages/platform-webworker-dynamic/package.json delete mode 100644 packages/platform-webworker-dynamic/public_api.ts delete mode 100644 packages/platform-webworker-dynamic/src/platform-webworker-dynamic.ts delete mode 100644 packages/platform-webworker-dynamic/src/version.ts delete mode 100644 packages/platform-webworker/BUILD.bazel delete mode 100644 packages/platform-webworker/PACKAGE.md delete mode 100644 packages/platform-webworker/index.ts delete mode 100644 packages/platform-webworker/package.json delete mode 100644 packages/platform-webworker/public_api.ts delete mode 100644 packages/platform-webworker/src/platform-webworker.ts delete mode 100644 packages/platform-webworker/src/version.ts delete mode 100644 packages/platform-webworker/src/web_workers/shared/api.ts delete mode 100644 packages/platform-webworker/src/web_workers/shared/client_message_broker.ts delete mode 100644 packages/platform-webworker/src/web_workers/shared/message_bus.ts delete mode 100644 packages/platform-webworker/src/web_workers/shared/messaging_api.ts delete mode 100644 packages/platform-webworker/src/web_workers/shared/post_message_bus.ts delete mode 100644 packages/platform-webworker/src/web_workers/shared/render_store.ts delete mode 100644 packages/platform-webworker/src/web_workers/shared/serializer.ts delete mode 100644 packages/platform-webworker/src/web_workers/shared/service_message_broker.ts delete mode 100644 packages/platform-webworker/src/web_workers/ui/event_dispatcher.ts delete mode 100644 packages/platform-webworker/src/web_workers/ui/event_serializer.ts delete mode 100644 packages/platform-webworker/src/web_workers/ui/location_providers.ts delete mode 100644 packages/platform-webworker/src/web_workers/ui/platform_location.ts delete mode 100644 packages/platform-webworker/src/web_workers/ui/renderer.ts delete mode 100644 packages/platform-webworker/src/web_workers/worker/location_providers.ts delete mode 100644 packages/platform-webworker/src/web_workers/worker/platform_location.ts delete mode 100644 packages/platform-webworker/src/web_workers/worker/renderer.ts delete mode 100644 packages/platform-webworker/src/web_workers/worker/worker_adapter.ts delete mode 100644 packages/platform-webworker/src/worker_app.ts delete mode 100644 packages/platform-webworker/src/worker_render.ts delete mode 100644 packages/platform-webworker/test/BUILD.bazel delete mode 100644 packages/platform-webworker/test/web_workers/shared/message_bus_spec.ts delete mode 100644 packages/platform-webworker/test/web_workers/shared/message_bus_util.ts delete mode 100644 packages/platform-webworker/test/web_workers/shared/mock_event_emitter.ts delete mode 100644 packages/platform-webworker/test/web_workers/shared/render_store_spec.ts delete mode 100644 packages/platform-webworker/test/web_workers/shared/service_message_broker_spec.ts delete mode 100644 packages/platform-webworker/test/web_workers/shared/web_worker_test_util.ts delete mode 100644 packages/platform-webworker/test/web_workers/worker/platform_location_spec.ts delete mode 100644 packages/platform-webworker/test/web_workers/worker/renderer_v2_integration_spec.ts delete mode 100644 packages/platform-webworker/test/web_workers/worker/spies.ts diff --git a/.gitmessage b/.gitmessage index 46b6ffbd5c..536045e1d9 100644 --- a/.gitmessage +++ b/.gitmessage @@ -105,9 +105,9 @@ Fixes # # │ │ # │ └─⫸ Commit Scope: animations|bazel|benchpress|common|compiler|compiler-cli|core| # │ elements|forms|http|language-service|localize|platform-browser| -# │ platform-browser-dynamic|platform-server|platform-webworker| -# │ platform-webworker-dynamic|router|service-worker|upgrade|zone.js| -# │ packaging|changelog|dev-infra|docs-infra|migrations|ngcc|ve +# │ platform-browser-dynamic|platform-server|router|service-worker| +# │ upgrade|zone.js|packaging|changelog|dev-infra|docs-infra|migrations| +# │ ngcc|ve # │ https://github.com/angular/angular/blob/master/CONTRIBUTING.md#scope # │ # └─⫸ Commit Type: build|ci|docs|feat|fix|perf|refactor|style|test diff --git a/.pullapprove.yml b/.pullapprove.yml index d521cea358..11e5274bde 100644 --- a/.pullapprove.yml +++ b/.pullapprove.yml @@ -303,8 +303,6 @@ groups: 'packages/platform-browser/**', 'packages/examples/platform-browser/**', 'packages/platform-browser-dynamic/**', - 'packages/platform-webworker/**', - 'packages/platform-webworker-dynamic/**', 'packages/examples/common/**', 'packages/docs/**', 'aio/content/guide/accessibility.md', diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a9023101bf..47347ad4f2 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -209,9 +209,9 @@ Any line of the commit message cannot be longer than 100 characters. │ │ │ └─⫸ Commit Scope: animations|bazel|benchpress|common|compiler|compiler-cli|core| │ elements|forms|http|language-service|localize|platform-browser| - │ platform-browser-dynamic|platform-server|platform-webworker| - │ platform-webworker-dynamic|router|service-worker|upgrade|zone.js| - │ packaging|changelog|dev-infra|docs-infra|migrations|ngcc|ve + │ platform-browser-dynamic|platform-server|router|service-worker| + │ upgrade|zone.js|packaging|changelog|dev-infra|docs-infra|migrations| + │ ngcc|ve │ └─⫸ Commit Type: build|ci|docs|feat|fix|perf|refactor|style|test ``` @@ -253,8 +253,6 @@ The following is the list of supported scopes: * `platform-browser` * `platform-browser-dynamic` * `platform-server` -* `platform-webworker` -* `platform-webworker-dynamic` * `router` * `service-worker` * `upgrade` diff --git a/aio/content/guide/deprecations.md b/aio/content/guide/deprecations.md index 7e44f6ddf3..20205263e3 100644 --- a/aio/content/guide/deprecations.md +++ b/aio/content/guide/deprecations.md @@ -48,7 +48,6 @@ v9 - v12 | `@angular/upgrade` | [`@angular/upgrade`](#upgrade) | v11 | | `@angular/upgrade` | [`getAngularLib`](#upgrade-static) | v11 | | `@angular/upgrade` | [`setAngularLib`](#upgrade-static) | v11 | -| `@angular/platform-webworker` | [All entry points](api/platform-webworker) | v11 | | template syntax | [`](#template-tag) | v11 | | polyfills | [reflect-metadata](#reflect-metadata) | v11 | | npm package format | [`esm5` and `fesm5` entry-points in @angular/* npm packages](guide/deprecations#esm5-fesm5) | v11 | @@ -123,20 +122,6 @@ Tip: In the [API reference section](api) of this doc site, deprecated APIs are i | --- | ----------- | --------------------- | ----- | | [`preserveQueryParams`](api/router/UrlCreationOptions#preserveQueryParams) | [`queryParamsHandling`](api/router/UrlCreationOptions#queryParamsHandling) | v4 | none | -{@a platform-webworker} -### @angular/platform-webworker - -| API | Replacement | Deprecation announced | Notes | -| --- | ----------- | --------------------- | ----- | -| [All entry points](api/platform-webworker) | none | v8 | See [platform-webworker](#webworker-apps). | - -{@a platform-webworker-dynamic} -### @angular/platform-webworker-dynamic - -| API | Replacement | Deprecation announced | Notes | -| --- | ----------- | --------------------- | ----- | -| [All entry points](api/platform-webworker-dynamic) | none | v8 | See [platform-webworker](#webworker-apps). | - {@a upgrade} ### @angular/upgrade @@ -391,28 +376,6 @@ These two properties have subtle differences, so switching to `textContent` unde All of the `wtf*` APIs are deprecated and will be removed in a future version. -{@a webworker-apps} -### Running Angular applications in platform-webworker - -The `@angular/platform-*` packages enable Angular to be run in different contexts. For examples, -`@angular/platform-server` enables Angular to be run on the server, and `@angular/platform-browser` -enables Angular to be run in a web browser. - -`@angular/platform-webworker` was introduced in Angular version 2 as an experiment in leveraging -Angular's rendering architecture to run an entire web application in a -[web worker](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API). We've learned a lot -from this experiment and have come to the conclusion that running the entire application in a web -worker is not the best strategy for most applications. - -Going forward, we will focus our efforts related to web workers around their primary use case of -offloading CPU-intensive, non-critical work needed for initial rendering (such as in-memory search -and image processing). Learn more in the -[guide to Using Web Workers with the Angular CLI](guide/web-worker). - -As of Angular version 8, all `platform-webworker` APIs are deprecated. -This includes both packages: `@angular/platform-webworker` and -`@angular/platform-webworker-dynamic`. - {@a entryComponents} ### `entryComponents` and `ANALYZE_FOR_ENTRY_COMPONENTS` no longer required Previously, the `entryComponents` array in the `NgModule` definition was used to tell the compiler which components would be created and inserted dynamically. With Ivy, this isn't a requirement anymore and the `entryComponents` array can be removed from existing module declarations. The same applies to the `ANALYZE_FOR_ENTRY_COMPONENTS` injection token. diff --git a/aio/tools/transforms/authors-package/api-package.js b/aio/tools/transforms/authors-package/api-package.js index 77698753c0..d8d34a2412 100644 --- a/aio/tools/transforms/authors-package/api-package.js +++ b/aio/tools/transforms/authors-package/api-package.js @@ -20,8 +20,6 @@ const packageMap = { 'platform-browser': ['platform-browser/index.ts', 'platform-browser/animations/index.ts', 'platform-browser/testing/index.ts'], 'platform-browser-dynamic': ['platform-browser-dynamic/index.ts', 'platform-browser-dynamic/testing/index.ts'], 'platform-server': ['platform-server/index.ts', 'platform-server/testing/index.ts'], - 'platform-webworker': ['platform-webworker/index.ts'], - 'platform-webworker-dynamic': ['platform-webworker-dynamic/index.ts'], router: ['router/index.ts', 'router/testing/index.ts', 'router/upgrade/index.ts'], 'service-worker': ['service-worker/index.ts'], upgrade: ['upgrade/index.ts', 'upgrade/static/index.ts', 'upgrade/static/testing/index.ts'] diff --git a/docs/PUBLIC_API.md b/docs/PUBLIC_API.md index dc592c3788..d4f96a44d0 100644 --- a/docs/PUBLIC_API.md +++ b/docs/PUBLIC_API.md @@ -10,8 +10,6 @@ Our semver, timed-release cycle and deprecation policy currently applies to thes - `@angular/platform-browser` - `@angular/platform-browser-dynamic` - `@angular/platform-server` -- `@angular/platform-webworker` -- `@angular/platform-webworker-dynamic` - `@angular/upgrade` - `@angular/router` - `@angular/service-worker` @@ -79,10 +77,10 @@ INFO: From Testing //packages/core:core_api: ngModule: Type; providers?: Provider[]; } - + -export declare type NgIterable = Array | Iterable; +export declare type NgIterable = Iterable; - + export declare interface NgModule { bootstrap?: Array | any[]>; declarations?: Array | any[]>; diff --git a/integration/angular_integration_test.bzl b/integration/angular_integration_test.bzl index b331062191..1335d42c47 100644 --- a/integration/angular_integration_test.bzl +++ b/integration/angular_integration_test.bzl @@ -50,8 +50,6 @@ GENERATED_NPM_PACKAGES = [ "@angular/platform-browser", "@angular/platform-browser-dynamic", "@angular/platform-server", - "@angular/platform-webworker", - "@angular/platform-webworker-dynamic", "@angular/router", "@angular/service-worker", "@angular/upgrade", diff --git a/integration/ng_update/package.json b/integration/ng_update/package.json index a1f977c81b..5b85ef275f 100644 --- a/integration/ng_update/package.json +++ b/integration/ng_update/package.json @@ -17,8 +17,6 @@ "@angular/platform-browser": "file:../../dist/packages-dist/platform-browser", "@angular/platform-browser-dynamic": "file:../../dist/packages-dist/platform-browser-dynamic", "@angular/platform-server": "file:../../dist/packages-dist/platform-server", - "@angular/platform-webworker": "file:../../dist/packages-dist/platform-webworker", - "@angular/platform-webworker-dynamic": "file:../../dist/packages-dist/platform-webworker-dynamic", "@angular/router": "file:../../dist/packages-dist/router", "@angular/service-worker": "file:../../dist/packages-dist/service-worker", "@angular/upgrade": "file:../../dist/packages-dist/upgrade", diff --git a/integration/typings_test_ts39/include-all.ts b/integration/typings_test_ts39/include-all.ts index 81d94b0a01..7bf19f646c 100644 --- a/integration/typings_test_ts39/include-all.ts +++ b/integration/typings_test_ts39/include-all.ts @@ -28,8 +28,6 @@ import * as platformBrowserAnimations from '@angular/platform-browser/animations import * as platformBrowserTesting from '@angular/platform-browser/testing'; import * as platformServer from '@angular/platform-server'; import * as platformServerTesting from '@angular/platform-server/testing'; -import * as platformWebworker from '@angular/platform-webworker'; -import * as platformWebworkerDynamic from '@angular/platform-webworker-dynamic'; import * as router from '@angular/router'; import * as routerTesting from '@angular/router/testing'; import * as routerUpgrade from '@angular/router/upgrade'; @@ -59,8 +57,6 @@ export default { platformBrowserAnimations, platformServer, platformServerTesting, - platformWebworker, - platformWebworkerDynamic, router, routerTesting, routerUpgrade, diff --git a/integration/typings_test_ts39/package.json b/integration/typings_test_ts39/package.json index c3d79ae043..b0e7847020 100644 --- a/integration/typings_test_ts39/package.json +++ b/integration/typings_test_ts39/package.json @@ -14,8 +14,6 @@ "@angular/platform-browser": "file:../../dist/packages-dist/platform-browser", "@angular/platform-browser-dynamic": "file:../../dist/packages-dist/platform-browser-dynamic", "@angular/platform-server": "file:../../dist/packages-dist/platform-server", - "@angular/platform-webworker": "file:../../dist/packages-dist/platform-webworker", - "@angular/platform-webworker-dynamic": "file:../../dist/packages-dist/platform-webworker-dynamic", "@angular/router": "file:../../dist/packages-dist/router", "@angular/service-worker": "file:../../dist/packages-dist/service-worker", "@angular/upgrade": "file:../../dist/packages-dist/upgrade", diff --git a/integration/typings_test_ts40/include-all.ts b/integration/typings_test_ts40/include-all.ts index 81d94b0a01..7bf19f646c 100644 --- a/integration/typings_test_ts40/include-all.ts +++ b/integration/typings_test_ts40/include-all.ts @@ -28,8 +28,6 @@ import * as platformBrowserAnimations from '@angular/platform-browser/animations import * as platformBrowserTesting from '@angular/platform-browser/testing'; import * as platformServer from '@angular/platform-server'; import * as platformServerTesting from '@angular/platform-server/testing'; -import * as platformWebworker from '@angular/platform-webworker'; -import * as platformWebworkerDynamic from '@angular/platform-webworker-dynamic'; import * as router from '@angular/router'; import * as routerTesting from '@angular/router/testing'; import * as routerUpgrade from '@angular/router/upgrade'; @@ -59,8 +57,6 @@ export default { platformBrowserAnimations, platformServer, platformServerTesting, - platformWebworker, - platformWebworkerDynamic, router, routerTesting, routerUpgrade, diff --git a/integration/typings_test_ts40/package.json b/integration/typings_test_ts40/package.json index c184501a81..30cf4c7664 100644 --- a/integration/typings_test_ts40/package.json +++ b/integration/typings_test_ts40/package.json @@ -14,8 +14,6 @@ "@angular/platform-browser": "file:../../dist/packages-dist/platform-browser", "@angular/platform-browser-dynamic": "file:../../dist/packages-dist/platform-browser-dynamic", "@angular/platform-server": "file:../../dist/packages-dist/platform-server", - "@angular/platform-webworker": "file:../../dist/packages-dist/platform-webworker", - "@angular/platform-webworker-dynamic": "file:../../dist/packages-dist/platform-webworker-dynamic", "@angular/router": "file:../../dist/packages-dist/router", "@angular/service-worker": "file:../../dist/packages-dist/service-worker", "@angular/upgrade": "file:../../dist/packages-dist/upgrade", diff --git a/modules/playground/e2e_test/web_workers/animations/BUILD.bazel b/modules/playground/e2e_test/web_workers/animations/BUILD.bazel deleted file mode 100644 index 2bd6e176d7..0000000000 --- a/modules/playground/e2e_test/web_workers/animations/BUILD.bazel +++ /dev/null @@ -1,7 +0,0 @@ -load("//modules/playground/e2e_test:example_test.bzl", "example_test") - -example_test( - name = "animations", - srcs = glob(["**/*.ts"]), - server = "//modules/playground/src/web_workers/animations:devserver", -) diff --git a/modules/playground/e2e_test/web_workers/animations/animations_spec.ts b/modules/playground/e2e_test/web_workers/animations/animations_spec.ts deleted file mode 100644 index e000861711..0000000000 --- a/modules/playground/e2e_test/web_workers/animations/animations_spec.ts +++ /dev/null @@ -1,79 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -import {browser, by, element, protractor} from 'protractor'; - -import {verifyNoBrowserErrors} from '../../../../../dev-infra/benchmark/driver-utilities'; - - -// Disabled because with ViewEngine animations within webworkers is not supported. -// See: https://github.com/angular/angular/issues/18610 -xdescribe('WebWorkers Animations', function() { - afterEach(() => { - verifyNoBrowserErrors(); - browser.ignoreSynchronization = false; - }); - - const selector = 'animation-app'; - const URL = 'all/playground/src/web_workers/animations/index.html'; - - it('should bootstrap', () => { - // This test can't wait for Angular as Testability is not available when using WebWorker - browser.ignoreSynchronization = true; - browser.get(URL); - - waitForBootstrap(); - const elem = element(by.css(selector + ' .box')); - expect(elem.getText()).toEqual('...'); - }); - - it('should animate to open', () => { - // This test can't wait for Angular as Testability is not available when using WebWorker - browser.ignoreSynchronization = true; - browser.get(URL); - - waitForBootstrap(); - element(by.css(selector + ' button')).click(); - - const boxElm = element(by.css(selector + ' .box')); - browser.wait(() => boxElm.getSize().then(sizes => sizes['width'] > 750), 1000); - }); - - it('should cancel the animation midway and continue from where it left off', () => { - browser.ignoreSynchronization = true; - browser.get(URL); - - waitForBootstrap(); - - const elem = element(by.css(selector + ' .box')); - const btn = element(by.css(selector + ' button')); - const getWidth = () => elem.getSize().then((sizes: any) => sizes['width']); - - btn.click(); - - browser.sleep(250); - - btn.click(); - - expect(getWidth()).toBeLessThan(600); - - browser.sleep(500); - - expect(getWidth()).toBeLessThan(50); - }); - - function waitForBootstrap() { - browser.wait(protractor.until.elementLocated(by.css(selector + ' .box')), 5000) - .then(() => {}, () => { - // jasmine will timeout if this gets called too many times - console.error('>> unexpected timeout -> browser.refresh()'); - browser.refresh(); - waitForBootstrap(); - }); - } -}); diff --git a/modules/playground/e2e_test/web_workers/input/BUILD.bazel b/modules/playground/e2e_test/web_workers/input/BUILD.bazel deleted file mode 100644 index ae90a5daa4..0000000000 --- a/modules/playground/e2e_test/web_workers/input/BUILD.bazel +++ /dev/null @@ -1,7 +0,0 @@ -load("//modules/playground/e2e_test:example_test.bzl", "example_test") - -example_test( - name = "input", - srcs = glob(["**/*.ts"]), - server = "//modules/playground/src/web_workers/input:devserver", -) diff --git a/modules/playground/e2e_test/web_workers/input/input_spec.ts b/modules/playground/e2e_test/web_workers/input/input_spec.ts deleted file mode 100644 index 541baf99ad..0000000000 --- a/modules/playground/e2e_test/web_workers/input/input_spec.ts +++ /dev/null @@ -1,75 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -import {browser, by, element, ExpectedConditions, protractor} from 'protractor'; - -import {verifyNoBrowserErrors} from '../../../../../dev-infra/benchmark/driver-utilities'; - -describe('WebWorkers Input', function() { - afterEach(() => { - verifyNoBrowserErrors(); - browser.ignoreSynchronization = false; - }); - const selector = 'input-app'; - const URL = '/'; - const VALUE = 'test val'; - - it('should bootstrap', () => { - // This test can't wait for Angular as Testability is not available when using WebWorker - browser.ignoreSynchronization = true; - browser.get(URL); - - waitForBootstrap(); - const elem = element(by.css(selector + ' h2')); - expect(elem.getText()).toEqual('Input App'); - }); - - it('should bind to input value', () => { - // This test can't wait for Angular as Testability is not available when using WebWorker - browser.ignoreSynchronization = true; - browser.get(URL); - - waitForBootstrap(); - const input = element(by.css(selector + ' input')); - input.sendKeys(VALUE); - const displayElem = element(by.css(selector + ' .input-val')); - const expectedVal = `Input val is ${VALUE}.`; - browser.wait(ExpectedConditions.textToBePresentInElement(displayElem, expectedVal), 5000); - expect(displayElem.getText()).toEqual(expectedVal); - }); - - it('should bind to textarea value', () => { - // This test can't wait for Angular as Testability is not available when using WebWorker - browser.ignoreSynchronization = true; - browser.get(URL); - - waitForBootstrap(); - const input = element(by.css(selector + ' textarea')); - input.sendKeys(VALUE); - const displayElem = element(by.css(selector + ' .textarea-val')); - const expectedVal = `Textarea val is ${VALUE}.`; - browser.wait(ExpectedConditions.textToBePresentInElement(displayElem, expectedVal), 5000); - expect(displayElem.getText()).toEqual(expectedVal); - }); - - function waitForBootstrap() { - browser.wait(protractor.until.elementLocated(by.css(selector + ' h2')), 5000) - .then( - () => { - const elem = element(by.css(selector + ' h2')); - browser.wait( - protractor.ExpectedConditions.textToBePresentInElement(elem, 'Input App'), 5000); - }, - () => { - // jasmine will timeout if this gets called too many times - console.error('>> unexpected timeout -> browser.refresh()'); - browser.refresh(); - waitForBootstrap(); - }); - } -}); diff --git a/modules/playground/e2e_test/web_workers/kitchen_sink/BUILD.bazel b/modules/playground/e2e_test/web_workers/kitchen_sink/BUILD.bazel deleted file mode 100644 index a764d7b479..0000000000 --- a/modules/playground/e2e_test/web_workers/kitchen_sink/BUILD.bazel +++ /dev/null @@ -1,7 +0,0 @@ -load("//modules/playground/e2e_test:example_test.bzl", "example_test") - -example_test( - name = "kitchen_sink", - srcs = glob(["**/*.ts"]), - server = "//modules/playground/src/web_workers/kitchen_sink:devserver", -) diff --git a/modules/playground/e2e_test/web_workers/kitchen_sink/kitchen_sink_spec.ts b/modules/playground/e2e_test/web_workers/kitchen_sink/kitchen_sink_spec.ts deleted file mode 100644 index cb019f6697..0000000000 --- a/modules/playground/e2e_test/web_workers/kitchen_sink/kitchen_sink_spec.ts +++ /dev/null @@ -1,58 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -import {browser, by, element, ExpectedConditions, protractor} from 'protractor'; - -import {verifyNoBrowserErrors} from '../../../../../dev-infra/benchmark/driver-utilities'; - -describe('WebWorkers Kitchen Sink', function() { - afterEach(() => { - verifyNoBrowserErrors(); - browser.ignoreSynchronization = false; - }); - const selector = 'hello-app .greeting'; - const URL = '/'; - - it('should greet', () => { - // This test can't wait for Angular as Testability is not available when using WebWorker - browser.ignoreSynchronization = true; - browser.get(URL); - - browser.wait(protractor.until.elementLocated(by.css(selector)), 15000); - const elem = element(by.css(selector)); - browser.wait(ExpectedConditions.textToBePresentInElement(elem, 'hello world!'), 5000); - expect(elem.getText()).toEqual('hello world!'); - }); - - it('should change greeting', () => { - // This test can't wait for Angular as Testability is not available when using WebWorker - browser.ignoreSynchronization = true; - browser.get(URL); - const changeButtonSelector = 'hello-app .changeButton'; - - browser.wait(protractor.until.elementLocated(by.css(changeButtonSelector)), 15000); - element(by.css(changeButtonSelector)).click(); - const elem = element(by.css(selector)); - browser.wait(ExpectedConditions.textToBePresentInElement(elem, 'howdy world!'), 5000); - expect(elem.getText()).toEqual('howdy world!'); - }); - - it('should display correct key names', () => { - // This test can't wait for Angular as Testability is not available when using WebWorker - browser.ignoreSynchronization = true; - browser.get(URL); - browser.wait(protractor.until.elementLocated(by.css('.sample-area')), 15000); - - const area = element.all(by.css('.sample-area')).first(); - expect(area.getText()).toEqual('(none)'); - - area.sendKeys('u'); - browser.wait(ExpectedConditions.textToBePresentInElement(area, 'U'), 5000); - expect(area.getText()).toEqual('U'); - }); -}); diff --git a/modules/playground/e2e_test/web_workers/message_broker/BUILD.bazel b/modules/playground/e2e_test/web_workers/message_broker/BUILD.bazel deleted file mode 100644 index 74b19d9060..0000000000 --- a/modules/playground/e2e_test/web_workers/message_broker/BUILD.bazel +++ /dev/null @@ -1,7 +0,0 @@ -load("//modules/playground/e2e_test:example_test.bzl", "example_test") - -example_test( - name = "message_broker", - srcs = glob(["**/*.ts"]), - server = "//modules/playground/src/web_workers/message_broker:devserver", -) diff --git a/modules/playground/e2e_test/web_workers/message_broker/message_broker_spec.ts b/modules/playground/e2e_test/web_workers/message_broker/message_broker_spec.ts deleted file mode 100644 index 9ab6572208..0000000000 --- a/modules/playground/e2e_test/web_workers/message_broker/message_broker_spec.ts +++ /dev/null @@ -1,47 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -import {browser, by, element, ExpectedConditions, protractor} from 'protractor'; - -import {verifyNoBrowserErrors} from '../../../../../dev-infra/benchmark/driver-utilities'; - -const URL = '/'; - -describe('MessageBroker', function() { - afterEach(() => { - verifyNoBrowserErrors(); - browser.ignoreSynchronization = false; - }); - - it('should bootstrap', () => { - // This test can't wait for Angular as Testability is not available when using WebWorker - browser.ignoreSynchronization = true; - browser.get(URL); - waitForBootstrap(); - expect(element(by.css('app h1')).getText()).toEqual('WebWorker MessageBroker Test'); - }); - - it('should echo messages', () => { - const VALUE = 'Hi There'; - // This test can't wait for Angular as Testability is not available when using WebWorker - browser.ignoreSynchronization = true; - browser.get(URL); - waitForBootstrap(); - - const input = element.all(by.css('#echo_input')).first(); - input.sendKeys(VALUE); - element(by.css('#send_echo')).click(); - const area = element(by.css('#echo_result')); - browser.wait(ExpectedConditions.textToBePresentInElement(area, VALUE), 5000); - expect(area.getText()).toEqual(VALUE); - }); -}); - -function waitForBootstrap(): void { - browser.wait(protractor.until.elementLocated(by.css('app h1')), 15000); -} diff --git a/modules/playground/e2e_test/web_workers/router/BUILD.bazel b/modules/playground/e2e_test/web_workers/router/BUILD.bazel deleted file mode 100644 index e6c55fae25..0000000000 --- a/modules/playground/e2e_test/web_workers/router/BUILD.bazel +++ /dev/null @@ -1,7 +0,0 @@ -load("//modules/playground/e2e_test:example_test.bzl", "example_test") - -example_test( - name = "router", - srcs = glob(["**/*.ts"]), - server = "//modules/playground/src/web_workers/router:devserver", -) diff --git a/modules/playground/e2e_test/web_workers/router/router_spec.ts b/modules/playground/e2e_test/web_workers/router/router_spec.ts deleted file mode 100644 index 01773e947f..0000000000 --- a/modules/playground/e2e_test/web_workers/router/router_spec.ts +++ /dev/null @@ -1,88 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -import {browser, by, element, protractor} from 'protractor'; - -import {verifyNoBrowserErrors} from '../../../../../dev-infra/benchmark/driver-utilities'; - -describe('WebWorker Router', () => { - beforeEach(() => { - // This test can't wait for Angular as Testability is not available when using WebWorker - browser.ignoreSynchronization = true; - browser.get('/'); - }); - - afterEach(() => { - verifyNoBrowserErrors(); - browser.ignoreSynchronization = false; - }); - - const contentSelector = 'app main h1'; - const navSelector = 'app nav ul'; - const baseUrl = '/'; - - it('should route on click', () => { - browser.get(baseUrl); - - waitForElement(contentSelector); - let content = element(by.css(contentSelector)); - expect(content.getText()).toEqual('Start'); - - const aboutBtn = element(by.css(navSelector + ' .about')); - aboutBtn.click(); - waitForUrl(/\/about/); - waitForElement(contentSelector); - waitForElementText(contentSelector, 'About'); - content = element(by.css(contentSelector)); - expect(content.getText()).toEqual('About'); - expect(browser.getCurrentUrl()).toMatch(/\/about/); - - const contactBtn = element(by.css(navSelector + ' .contact')); - contactBtn.click(); - waitForUrl(/\/contact/); - waitForElement(contentSelector); - waitForElementText(contentSelector, 'Contact'); - content = element(by.css(contentSelector)); - expect(content.getText()).toEqual('Contact'); - expect(browser.getCurrentUrl()).toMatch(/\/contact/); - }); - - it('should load the correct route from the URL', () => { - browser.get(baseUrl + '#/about'); - - waitForElement(contentSelector); - waitForElementText(contentSelector, 'About'); - const content = element(by.css(contentSelector)); - expect(content.getText()).toEqual('About'); - }); - - function waitForElement(selector: string): void { - browser.wait(protractor.until.elementLocated(by.css(selector)), 15000); - } - - function waitForElementText(contentSelector: string, expected: string): void { - browser.wait(() => { - const deferred = protractor.promise.defer(); - const elem = element(by.css(contentSelector)); - elem.getText().then((text: string) => { - return deferred.fulfill(text === expected); - }); - return deferred.promise; - }, 5000); - } - - function waitForUrl(regex: RegExp): void { - browser.wait(() => { - const deferred = protractor.promise.defer(); - browser.getCurrentUrl().then((url: string) => { - return deferred.fulfill(url.match(regex) !== null); - }); - return deferred.promise; - }, 5000); - } -}); diff --git a/modules/playground/e2e_test/web_workers/todo/BUILD.bazel b/modules/playground/e2e_test/web_workers/todo/BUILD.bazel deleted file mode 100644 index 907933a699..0000000000 --- a/modules/playground/e2e_test/web_workers/todo/BUILD.bazel +++ /dev/null @@ -1,7 +0,0 @@ -load("//modules/playground/e2e_test:example_test.bzl", "example_test") - -example_test( - name = "todo", - srcs = glob(["**/*.ts"]), - server = "//modules/playground/src/web_workers/todo:devserver", -) diff --git a/modules/playground/e2e_test/web_workers/todo/todo_spec.ts b/modules/playground/e2e_test/web_workers/todo/todo_spec.ts deleted file mode 100644 index d8caffdd36..0000000000 --- a/modules/playground/e2e_test/web_workers/todo/todo_spec.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -import {browser, by, element, protractor} from 'protractor'; - -import {verifyNoBrowserErrors} from '../../../../../dev-infra/benchmark/driver-utilities'; - -describe('WebWorkers Todo', function() { - afterEach(() => { - verifyNoBrowserErrors(); - browser.ignoreSynchronization = false; - }); - - const URL = '/'; - - it('should bootstrap', () => { - // This test can't wait for Angular as Testability is not available when using WebWorker - browser.ignoreSynchronization = true; - browser.get(URL); - - waitForBootstrap(); - expect(element(by.css('#todoapp header')).getText()).toEqual('todos'); - }); -}); - -function waitForBootstrap(): void { - browser.wait(protractor.until.elementLocated(by.css('todo-app #todoapp')), 15000); -} diff --git a/modules/playground/src/web_workers/BUILD.bazel b/modules/playground/src/web_workers/BUILD.bazel deleted file mode 100644 index 101d5649d7..0000000000 --- a/modules/playground/src/web_workers/BUILD.bazel +++ /dev/null @@ -1,13 +0,0 @@ -package(default_visibility = ["//visibility:public"]) - -filegroup( - name = "worker-config", - srcs = ["worker-configure.js"], - data = [ - "//modules/playground:systemjs-config.js", - "//modules/playground:systemjs-rxjs-operators.js", - "//packages/zone.js/bundles:zone.umd.js", - "@npm//reflect-metadata", - "@npm//systemjs", - ], -) diff --git a/modules/playground/src/web_workers/animations/BUILD.bazel b/modules/playground/src/web_workers/animations/BUILD.bazel deleted file mode 100644 index 9b6cf7012e..0000000000 --- a/modules/playground/src/web_workers/animations/BUILD.bazel +++ /dev/null @@ -1,31 +0,0 @@ -load("//tools:defaults.bzl", "ng_module", "ts_devserver") - -package(default_visibility = ["//modules/playground:__subpackages__"]) - -ng_module( - name = "animations", - srcs = glob(["**/*.ts"]), - tsconfig = "//modules/playground:tsconfig-build.json", - deps = [ - "//packages/animations", - "//packages/core", - "//packages/platform-webworker", - "//packages/platform-webworker-dynamic", - ], -) - -ts_devserver( - name = "devserver", - entry_module = "angular/modules/playground/src/web_workers/animations/index", - port = 4200, - scripts = ["@npm//:node_modules/tslib/tslib.js"], - static_files = [ - "loader.js", - "//modules/playground/src/web_workers:worker-config", - "@npm//:node_modules/rxjs/bundles/rxjs.umd.js", - "@npm//:node_modules/tslib/tslib.js", - "index.html", - "//packages/zone.js/bundles:zone.umd.js", - ], - deps = [":animations"], -) diff --git a/modules/playground/src/web_workers/animations/background_index.ts b/modules/playground/src/web_workers/animations/background_index.ts deleted file mode 100644 index b73cc3ac27..0000000000 --- a/modules/playground/src/web_workers/animations/background_index.ts +++ /dev/null @@ -1,19 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -import {NgModule} from '@angular/core'; -import {WorkerAppModule} from '@angular/platform-webworker'; -import {platformWorkerAppDynamic} from '@angular/platform-webworker-dynamic'; - -import {AnimationCmp} from './index_common'; - -@NgModule({imports: [WorkerAppModule], bootstrap: [AnimationCmp], declarations: [AnimationCmp]}) -export class ExampleModule { -} - -platformWorkerAppDynamic().bootstrapModule(ExampleModule); diff --git a/modules/playground/src/web_workers/animations/index.html b/modules/playground/src/web_workers/animations/index.html deleted file mode 100644 index c4c0c25eb1..0000000000 --- a/modules/playground/src/web_workers/animations/index.html +++ /dev/null @@ -1,11 +0,0 @@ - - - WebWorker Animation Tests - - - - Loading... - - - diff --git a/modules/playground/src/web_workers/animations/index.ts b/modules/playground/src/web_workers/animations/index.ts deleted file mode 100644 index f3791aca91..0000000000 --- a/modules/playground/src/web_workers/animations/index.ts +++ /dev/null @@ -1,11 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -import {bootstrapWorkerUi} from '@angular/platform-webworker'; - -bootstrapWorkerUi('loader.js'); diff --git a/modules/playground/src/web_workers/animations/index_common.ts b/modules/playground/src/web_workers/animations/index_common.ts deleted file mode 100644 index d38fd32498..0000000000 --- a/modules/playground/src/web_workers/animations/index_common.ts +++ /dev/null @@ -1,43 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -import {animate, state, style, transition, trigger} from '@angular/animations'; -import {Component} from '@angular/core'; - -@Component({ - selector: 'animation-app', - styles: [` - .box { - border:10px solid black; - text-align:center; - overflow:hidden; - background:red; - color:white; - font-size:100px; - line-height:200px; - } - `], - animations: [trigger( - 'animate', - [ - state('off', style({width: '0px'})), state('on', style({width: '750px'})), - transition('off <=> on', animate(500)) - ])], - template: ` - - -
- ... -
- ` -}) -export class AnimationCmp { - animate = false; -} diff --git a/modules/playground/src/web_workers/animations/loader.js b/modules/playground/src/web_workers/animations/loader.js deleted file mode 100644 index 9dd1900c0b..0000000000 --- a/modules/playground/src/web_workers/animations/loader.js +++ /dev/null @@ -1,14 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -importScripts('angular/modules/playground/src/web_workers/worker-configure.js'); - -System.config({packages: {'angular/modules/playground/src/web_workers': {defaultExtension: 'js'}}}); - -System.import('./background_index.js') - .catch(error => console.error('error loading background', error)); diff --git a/modules/playground/src/web_workers/images/BUILD.bazel b/modules/playground/src/web_workers/images/BUILD.bazel deleted file mode 100644 index e55c51a651..0000000000 --- a/modules/playground/src/web_workers/images/BUILD.bazel +++ /dev/null @@ -1,41 +0,0 @@ -load("//tools:defaults.bzl", "ng_module", "ts_devserver") - -package(default_visibility = ["//modules/playground:__subpackages__"]) - -ng_module( - name = "images", - srcs = glob(["**/*.ts"]), - assets = ["image_demo.html"], - tsconfig = "//modules/playground:tsconfig-build.json", - deps = [ - "//packages/core", - "//packages/platform-webworker", - "//packages/platform-webworker-dynamic", - "@npm//@types/base64-js", - ], -) - -ts_devserver( - name = "devserver", - # Workaround for: https://github.com/bazelbuild/rules_typescript/issues/409 - additional_root_paths = ["angular"], - bootstrap = [ - "//packages/zone.js/bundles:zone.umd.js", - "@npm//:node_modules/jquery/dist/jquery.min.js", - "@npm//:node_modules/materialize-css/dist/js/materialize.min.js", - ], - entry_module = "angular/modules/playground/src/web_workers/images/index", - port = 4200, - scripts = ["@npm//:node_modules/tslib/tslib.js"], - static_files = [ - "@npm//:node_modules/base64-js/base64js.min.js", - "@npm//:node_modules/rxjs/bundles/rxjs.umd.js", - "@npm//:node_modules/tslib/tslib.js", - "@npm//:node_modules/materialize-css/dist/css/materialize.min.css", - "loader.js", - "index.html", - "//modules/playground/src/web_workers:worker-config", - "//third_party/github.com/google/material-design-icons", - ] + glob(["**/*.css"]), - deps = [":images"], -) diff --git a/modules/playground/src/web_workers/images/background_index.ts b/modules/playground/src/web_workers/images/background_index.ts deleted file mode 100644 index 5dc345cfb4..0000000000 --- a/modules/playground/src/web_workers/images/background_index.ts +++ /dev/null @@ -1,19 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -import {NgModule} from '@angular/core'; -import {WorkerAppModule} from '@angular/platform-webworker'; -import {platformWorkerAppDynamic} from '@angular/platform-webworker-dynamic'; - -import {ImageDemo} from './index_common'; - -@NgModule({imports: [WorkerAppModule], bootstrap: [ImageDemo], declarations: [ImageDemo]}) -export class ExampleModule { -} - -platformWorkerAppDynamic().bootstrapModule(ExampleModule); diff --git a/modules/playground/src/web_workers/images/image_demo.css b/modules/playground/src/web_workers/images/image_demo.css deleted file mode 100644 index bf19e97801..0000000000 --- a/modules/playground/src/web_workers/images/image_demo.css +++ /dev/null @@ -1,30 +0,0 @@ -.hidden{ - display: none !important; -} -#images { - width: 600px; - margin: 0 auto; -} -ul li { - list-style-type: none; - float: left; - margin-left: 20px; - width: 200px; -} -#main ul { - width: 700px; -} -.card-image .image-loader{ - position: absolute; - bottom: 0; - margin: auto; -} - -.card-image img.grey { - opacity: 0.4; -} - -.fixed-action-btn.bottom { - bottom: 45px; - right: 24px; -} diff --git a/modules/playground/src/web_workers/images/image_demo.html b/modules/playground/src/web_workers/images/image_demo.html deleted file mode 100644 index e1ae692b98..0000000000 --- a/modules/playground/src/web_workers/images/image_demo.html +++ /dev/null @@ -1,36 +0,0 @@ - -
-
-
-
-
- -
-
-
-
-
-
-
- - -
-
- Select Images - -
-
- -
-
-
diff --git a/modules/playground/src/web_workers/images/index.html b/modules/playground/src/web_workers/images/index.html deleted file mode 100644 index fde85836fa..0000000000 --- a/modules/playground/src/web_workers/images/index.html +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/modules/playground/src/web_workers/images/index.ts b/modules/playground/src/web_workers/images/index.ts deleted file mode 100644 index f3791aca91..0000000000 --- a/modules/playground/src/web_workers/images/index.ts +++ /dev/null @@ -1,11 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -import {bootstrapWorkerUi} from '@angular/platform-webworker'; - -bootstrapWorkerUi('loader.js'); diff --git a/modules/playground/src/web_workers/images/index_common.ts b/modules/playground/src/web_workers/images/index_common.ts deleted file mode 100644 index b17efba38b..0000000000 --- a/modules/playground/src/web_workers/images/index_common.ts +++ /dev/null @@ -1,56 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -import {Component} from '@angular/core'; - -import {BitmapService} from './services/bitmap'; - - -@Component({selector: 'image-demo', viewProviders: [BitmapService], templateUrl: 'image_demo.html'}) -export class ImageDemo { - images: {src: string, buffer: ArrayBuffer, filtering: boolean}[] = []; - fileInput: String; - - constructor(private _bitmapService: BitmapService) {} - - uploadFiles(files: FileList) { - for (let i = 0; i < files.length; i++) { - const reader = new FileReader(); - reader.addEventListener('load', this.handleReaderLoad(reader)); - reader.readAsArrayBuffer(files[i]); - } - } - - handleReaderLoad(reader: FileReader): EventListener { - return (e) => { - const buffer = reader.result as ArrayBuffer; - this.images.push({ - src: this._bitmapService.arrayBufferToDataUri(new Uint8Array(buffer)), - buffer: buffer, - filtering: false - }); - }; - } - - applyFilters() { - for (let i = 0; i < this.images.length; i++) { - this.images[i].filtering = true; - - setTimeout(this._filter(i), 0); - } - } - - private _filter(i: number): () => void { - return () => { - let imageData = this._bitmapService.convertToImageData(this.images[i].buffer); - imageData = this._bitmapService.applySepia(imageData); - this.images[i].src = this._bitmapService.toDataUri(imageData); - this.images[i].filtering = false; - }; - } -} diff --git a/modules/playground/src/web_workers/images/loader.css b/modules/playground/src/web_workers/images/loader.css deleted file mode 100644 index 30e38fef8b..0000000000 --- a/modules/playground/src/web_workers/images/loader.css +++ /dev/null @@ -1,71 +0,0 @@ -body { - background: #eaecfa; -} - -.loader { - width: 250px; - height: 50px; - line-height: 50px; - text-align: center; - position: absolute; - top: 50%; - left: 50%; - -webkit-transform: translate(-50%, -50%); - -ms-transform: translate(-50%, -50%); - transform: translate(-50%, -50%); - font-family: helvetica, arial, sans-serif; - text-transform: uppercase; - font-weight: 900; - color: #ce4233; - letter-spacing: 0.2em; -} -.loader::before, .loader::after { - content: ""; - display: block; - width: 15px; - height: 15px; - background: #ce4233; - position: absolute; - -webkit-animation: load .7s infinite alternate ease-in-out; - animation: load .7s infinite alternate ease-in-out; -} -.loader::before { - top: 0; -} -.loader::after { - bottom: 0; -} - -@-webkit-keyframes load { - 0% { - left: 0; - height: 30px; - width: 15px; - } - 50% { - height: 8px; - width: 40px; - } - 100% { - left: 235px; - height: 30px; - width: 15px; - } -} - -@keyframes load { - 0% { - left: 0; - height: 30px; - width: 15px; - } - 50% { - height: 8px; - width: 40px; - } - 100% { - left: 235px; - height: 30px; - width: 15px; - } -} diff --git a/modules/playground/src/web_workers/images/loader.js b/modules/playground/src/web_workers/images/loader.js deleted file mode 100644 index dc68d1ea03..0000000000 --- a/modules/playground/src/web_workers/images/loader.js +++ /dev/null @@ -1,19 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -importScripts('angular/modules/playground/src/web_workers/worker-configure.js'); - -System.config({ - map: { - 'base64-js': 'npm/node_modules/base64-js/base64js.min.js', - }, - packages: {'angular/modules/playground/src/web_workers': {defaultExtension: 'js'}} -}); - -System.import('./background_index.js') - .catch(error => console.error('error loading background', error)); diff --git a/modules/playground/src/web_workers/images/services/bitmap.ts b/modules/playground/src/web_workers/images/services/bitmap.ts deleted file mode 100644 index 31c0897393..0000000000 --- a/modules/playground/src/web_workers/images/services/bitmap.ts +++ /dev/null @@ -1,179 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -import {Injectable} from '@angular/core'; -import {fromByteArray} from 'base64-js'; - -// This class is based on the Bitmap examples at: -// http://www.i-programmer.info/projects/36-web/6234-reading-a-bmp-file-in-javascript.html -// and http://www.worldwidewhat.net/2012/07/how-to-draw-bitmaps-using-javascript/ -@Injectable() -export class BitmapService { - convertToImageData(buffer: ArrayBuffer): ImageData { - const bmp = this._getBMP(buffer); - return this._BMPToImageData(bmp); - } - - applySepia(imageData: ImageData): ImageData { - const buffer = imageData.data; - for (let i = 0; i < buffer.length; i += 4) { - const r = buffer[i]; - const g = buffer[i + 1]; - const b = buffer[i + 2]; - buffer[i] = (r * .393) + (g * .769) + (b * .189); - buffer[i + 1] = (r * .349) + (g * .686) + (b * .168); - buffer[i + 2] = (r * .272) + (g * .534) + (b * .131); - } - return imageData; - } - - toDataUri(imageData: ImageData): string { - const header = this._createBMPHeader(imageData); - imageData = this._imageDataToBMP(imageData); - return 'data:image/bmp;base64,' + btoa(header) + fromByteArray(Uint8Array.from(imageData.data)); - } - - // converts a .bmp file ArrayBuffer to a dataURI - arrayBufferToDataUri(data: Uint8Array): string { - return 'data:image/bmp;base64,' + fromByteArray(data); - } - - // returns a UInt8Array in BMP order (starting from the bottom) - private _imageDataToBMP(imageData: ImageData): ImageData { - const width = imageData.width; - const height = imageData.height; - - const data = imageData.data; - for (let y = 0; y < height / 2; ++y) { - let topIndex = y * width * 4; - let bottomIndex = (height - y) * width * 4; - for (let i = 0; i < width * 4; i++) { - this._swap(data, topIndex, bottomIndex); - topIndex++; - bottomIndex++; - } - } - - return imageData; - } - - private _swap(data: Uint8Array|Uint8ClampedArray|number[], index1: number, index2: number) { - const temp = data[index1]; - data[index1] = data[index2]; - data[index2] = temp; - } - - // Based on example from - // http://www.worldwidewhat.net/2012/07/how-to-draw-bitmaps-using-javascript/ - private _createBMPHeader(imageData: ImageData): string { - const numFileBytes = this._getLittleEndianHex(imageData.width * imageData.height); - const w = this._getLittleEndianHex(imageData.width); - const h = this._getLittleEndianHex(imageData.height); - return 'BM' + // Signature - numFileBytes + // size of the file (bytes)* - '\x00\x00' + // reserved - '\x00\x00' + // reserved - '\x36\x00\x00\x00' + // offset of where BMP data lives (54 bytes) - '\x28\x00\x00\x00' + // number of remaining bytes in header from here (40 bytes) - w + // the width of the bitmap in pixels* - h + // the height of the bitmap in pixels* - '\x01\x00' + // the number of color planes (1) - '\x20\x00' + // 32 bits / pixel - '\x00\x00\x00\x00' + // No compression (0) - '\x00\x00\x00\x00' + // size of the BMP data (bytes)* - '\x13\x0B\x00\x00' + // 2835 pixels/meter - horizontal resolution - '\x13\x0B\x00\x00' + // 2835 pixels/meter - the vertical resolution - '\x00\x00\x00\x00' + // Number of colors in the palette (keep 0 for 32-bit) - '\x00\x00\x00\x00'; // 0 important colors (means all colors are important) - } - - private _BMPToImageData(bmp: BitmapFile): ImageData { - const width = bmp.infoHeader.biWidth; - const height = bmp.infoHeader.biHeight; - const imageData = new ImageData(width, height); - - const data = imageData.data; - const bmpData = bmp.pixels; - const stride = bmp.stride; - - for (let y = 0; y < height; ++y) { - for (let x = 0; x < width; ++x) { - const index1 = (x + width * (height - y)) * 4; - const index2 = x * 3 + stride * y; - data[index1] = bmpData[index2 + 2]; - data[index1 + 1] = bmpData[index2 + 1]; - data[index1 + 2] = bmpData[index2]; - data[index1 + 3] = 255; - } - } - return imageData; - } - - private _getBMP(buffer: ArrayBuffer): BitmapFile { - const datav = new DataView(buffer); - const bitmap: BitmapFile = { - fileHeader: { - bfType: datav.getUint16(0, true), - bfSize: datav.getUint32(2, true), - bfReserved1: datav.getUint16(6, true), - bfReserved2: datav.getUint16(8, true), - bfOffBits: datav.getUint32(10, true), - }, - infoHeader: { - biSize: datav.getUint32(14, true), - biWidth: datav.getUint32(18, true), - biHeight: datav.getUint32(22, true), - biPlanes: datav.getUint16(26, true), - biBitCount: datav.getUint16(28, true), - biCompression: datav.getUint32(30, true), - biSizeImage: datav.getUint32(34, true), - biXPelsPerMeter: datav.getUint32(38, true), - biYPelsPerMeter: datav.getUint32(42, true), - biClrUsed: datav.getUint32(46, true), - biClrImportant: datav.getUint32(50, true) - }, - stride: null, - pixels: null - }; - const start = bitmap.fileHeader.bfOffBits; - bitmap.stride = - Math.floor((bitmap.infoHeader.biBitCount * bitmap.infoHeader.biWidth + 31) / 32) * 4; - bitmap.pixels = new Uint8Array(datav.buffer, start); - return bitmap; - } - - // Based on example from - // http://www.worldwidewhat.net/2012/07/how-to-draw-bitmaps-using-javascript/ - private _getLittleEndianHex(value: number): string { - const result: string[] = []; - - for (let bytes = 4; bytes > 0; bytes--) { - result.push(String.fromCharCode(value & 255)); - value >>= 8; - } - - return result.join(''); - } -} - -interface BitmapFile { - fileHeader: { - bfType: number; bfSize: number; bfReserved1: number; bfReserved2: number; bfOffBits: number; - }; - infoHeader: { - biSize: number; biWidth: number; biHeight: number; biPlanes: number; biBitCount: number; - biCompression: number; - biSizeImage: number; - biXPelsPerMeter: number; - biYPelsPerMeter: number; - biClrUsed: number; - biClrImportant: number - }; - stride: number; - pixels: Uint8Array; -} diff --git a/modules/playground/src/web_workers/images/single_thread.html b/modules/playground/src/web_workers/images/single_thread.html deleted file mode 100644 index ec3da632a5..0000000000 --- a/modules/playground/src/web_workers/images/single_thread.html +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/modules/playground/src/web_workers/images/single_thread.ts b/modules/playground/src/web_workers/images/single_thread.ts deleted file mode 100644 index 6891b04c1d..0000000000 --- a/modules/playground/src/web_workers/images/single_thread.ts +++ /dev/null @@ -1,21 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -import {NgModule} from '@angular/core'; -import {BrowserModule} from '@angular/platform-browser'; -import {platformBrowserDynamic} from '@angular/platform-browser-dynamic'; - -import {ImageDemo} from './index_common'; - -@NgModule({bootstrap: [ImageDemo], imports: [BrowserModule]}) -class ExampleModule { -} - -export function main() { - platformBrowserDynamic().bootstrapModule(ExampleModule); -} diff --git a/modules/playground/src/web_workers/input/BUILD.bazel b/modules/playground/src/web_workers/input/BUILD.bazel deleted file mode 100644 index ab49918324..0000000000 --- a/modules/playground/src/web_workers/input/BUILD.bazel +++ /dev/null @@ -1,38 +0,0 @@ -load("//tools:defaults.bzl", "ng_module", "ts_devserver") - -package(default_visibility = ["//modules/playground:__subpackages__"]) - -ng_module( - name = "input", - srcs = glob(["**/*.ts"]), - tsconfig = "//modules/playground:tsconfig-build.json", - deps = [ - "//packages/core", - "//packages/platform-webworker", - "//packages/platform-webworker-dynamic", - ], -) - -ts_devserver( - name = "devserver", - bootstrap = [ - "@npm//:node_modules/systemjs/dist/system.js", - "//packages/zone.js/bundles:zone.umd.js", - "//packages/zone.js/bundles:long-stack-trace-zone.umd.js", - "@npm//:node_modules/reflect-metadata/Reflect.js", - ], - entry_module = "angular/modules/playground/src/web_workers/input/index", - port = 4200, - scripts = [ - "@npm//:node_modules/tslib/tslib.js", - "//tools/rxjs:rxjs_umd_modules", - ], - static_files = [ - "index.html", - "loader.js", - "//modules/playground/src/web_workers:worker-config", - "//modules/playground:systemjs-config.js", - "//modules/playground:systemjs-rxjs-operators.js", - ], - deps = [":input"], -) diff --git a/modules/playground/src/web_workers/input/background_index.ts b/modules/playground/src/web_workers/input/background_index.ts deleted file mode 100644 index 3e889dbd95..0000000000 --- a/modules/playground/src/web_workers/input/background_index.ts +++ /dev/null @@ -1,19 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -import {NgModule} from '@angular/core'; -import {WorkerAppModule} from '@angular/platform-webworker'; -import {platformWorkerAppDynamic} from '@angular/platform-webworker-dynamic'; - -import {InputCmp} from './index_common'; - -@NgModule({imports: [WorkerAppModule], bootstrap: [InputCmp], declarations: [InputCmp]}) -export class ExampleModule { -} - -platformWorkerAppDynamic().bootstrapModule(ExampleModule); diff --git a/modules/playground/src/web_workers/input/index.html b/modules/playground/src/web_workers/input/index.html deleted file mode 100644 index 7f026e4e32..0000000000 --- a/modules/playground/src/web_workers/input/index.html +++ /dev/null @@ -1,14 +0,0 @@ - - - WebWorker Input Tests - - - - Loading... - - - - - - diff --git a/modules/playground/src/web_workers/input/index.ts b/modules/playground/src/web_workers/input/index.ts deleted file mode 100644 index f3791aca91..0000000000 --- a/modules/playground/src/web_workers/input/index.ts +++ /dev/null @@ -1,11 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -import {bootstrapWorkerUi} from '@angular/platform-webworker'; - -bootstrapWorkerUi('loader.js'); diff --git a/modules/playground/src/web_workers/input/index_common.ts b/modules/playground/src/web_workers/input/index_common.ts deleted file mode 100644 index 8be97e9c18..0000000000 --- a/modules/playground/src/web_workers/input/index_common.ts +++ /dev/null @@ -1,36 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -import {Component} from '@angular/core'; - -@Component({ - selector: 'input-app', - template: ` -

Input App

-
- - -
Input val is {{inputVal}}.
-
Textarea val is {{textareaVal}}.
-
-
-
- ` -}) -export class InputCmp { - inputVal = ''; - textareaVal = ''; - - inputChanged(e: Event) { - this.inputVal = (e.target as HTMLInputElement).value; - } - - textAreaChanged(e: Event) { - this.textareaVal = (e.target as HTMLTextAreaElement).value; - } -} diff --git a/modules/playground/src/web_workers/input/loader.js b/modules/playground/src/web_workers/input/loader.js deleted file mode 100644 index 9dd1900c0b..0000000000 --- a/modules/playground/src/web_workers/input/loader.js +++ /dev/null @@ -1,14 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -importScripts('angular/modules/playground/src/web_workers/worker-configure.js'); - -System.config({packages: {'angular/modules/playground/src/web_workers': {defaultExtension: 'js'}}}); - -System.import('./background_index.js') - .catch(error => console.error('error loading background', error)); diff --git a/modules/playground/src/web_workers/kitchen_sink/BUILD.bazel b/modules/playground/src/web_workers/kitchen_sink/BUILD.bazel deleted file mode 100644 index 686ef0468b..0000000000 --- a/modules/playground/src/web_workers/kitchen_sink/BUILD.bazel +++ /dev/null @@ -1,38 +0,0 @@ -load("//tools:defaults.bzl", "ng_module", "ts_devserver") - -package(default_visibility = ["//modules/playground:__subpackages__"]) - -ng_module( - name = "kitchen_sink", - srcs = glob(["**/*.ts"]), - tsconfig = "//modules/playground:tsconfig-build.json", - deps = [ - "//packages/core", - "//packages/platform-webworker", - "//packages/platform-webworker-dynamic", - ], -) - -ts_devserver( - name = "devserver", - bootstrap = [ - "@npm//:node_modules/systemjs/dist/system.js", - "//packages/zone.js/bundles:zone.umd.js", - "//packages/zone.js/bundles:long-stack-trace-zone.umd.js", - "@npm//:node_modules/reflect-metadata/Reflect.js", - ], - entry_module = "angular/modules/playground/src/web_workers/kitchen_sink/index", - port = 4200, - scripts = [ - "@npm//:node_modules/tslib/tslib.js", - "//tools/rxjs:rxjs_umd_modules", - ], - static_files = [ - "index.html", - "loader.js", - "//modules/playground/src/web_workers:worker-config", - "//modules/playground:systemjs-config.js", - "//modules/playground:systemjs-rxjs-operators.js", - ], - deps = [":kitchen_sink"], -) diff --git a/modules/playground/src/web_workers/kitchen_sink/background_index.ts b/modules/playground/src/web_workers/kitchen_sink/background_index.ts deleted file mode 100644 index dfea405834..0000000000 --- a/modules/playground/src/web_workers/kitchen_sink/background_index.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -import {NgModule} from '@angular/core'; -import {WorkerAppModule} from '@angular/platform-webworker'; -import {platformWorkerAppDynamic} from '@angular/platform-webworker-dynamic'; - -import {HelloCmp, RedDec} from './index_common'; - -@NgModule({ - imports: [WorkerAppModule], - bootstrap: [HelloCmp], - declarations: [HelloCmp, RedDec], -}) -export class ExampleModule { -} - -platformWorkerAppDynamic().bootstrapModule(ExampleModule); diff --git a/modules/playground/src/web_workers/kitchen_sink/index.html b/modules/playground/src/web_workers/kitchen_sink/index.html deleted file mode 100644 index 72a835e48a..0000000000 --- a/modules/playground/src/web_workers/kitchen_sink/index.html +++ /dev/null @@ -1,27 +0,0 @@ - - - Hello Angular - - - - Loading... - - - - - - diff --git a/modules/playground/src/web_workers/kitchen_sink/index.ts b/modules/playground/src/web_workers/kitchen_sink/index.ts deleted file mode 100644 index f3791aca91..0000000000 --- a/modules/playground/src/web_workers/kitchen_sink/index.ts +++ /dev/null @@ -1,11 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -import {bootstrapWorkerUi} from '@angular/platform-webworker'; - -bootstrapWorkerUi('loader.js'); diff --git a/modules/playground/src/web_workers/kitchen_sink/index_common.ts b/modules/playground/src/web_workers/kitchen_sink/index_common.ts deleted file mode 100644 index 90939de9ba..0000000000 --- a/modules/playground/src/web_workers/kitchen_sink/index_common.ts +++ /dev/null @@ -1,63 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -import {Component, Directive, ElementRef, Injectable, Renderer2} from '@angular/core'; - -// A service available to the Injector, used by the HelloCmp component. -@Injectable() -export class GreetingService { - greeting: string = 'hello'; -} - -// Directives are light-weight. They don't allow new -// expression contexts (use @Component for those needs). -@Directive({selector: '[red]'}) -export class RedDec { - // ElementRef is always injectable and it wraps the element on which the - // directive was found by the compiler. - constructor(el: ElementRef, renderer: Renderer2) { - renderer.setStyle(el.nativeElement, 'color', 'red'); - } -} - -// Angular supports 2 basic types of directives: -// - Component - the basic building blocks of Angular apps. Backed by -// ShadowDom.(http://www.html5rocks.com/en/tutorials/webcomponents/shadowdom/) -// - Directive - add behavior to existing elements. - -@Component({ - // The Selector prop tells Angular on which elements to instantiate this - // class. The syntax supported is a basic subset of CSS selectors, for example - // 'element', '[attr]', [attr=foo]', etc. - selector: 'hello-app', - // These are services that would be created if a class in the component's - // template tries to inject them. - viewProviders: [GreetingService], - // The template for the component. - // Expressions in the template (like {{greeting}}) are evaluated in the - // context of the HelloCmp class below. - template: `
{{greeting}} world!
- -
{{lastKey}}

` -}) -export class HelloCmp { - greeting: string; - lastKey: string = '(none)'; - - constructor(service: GreetingService) { - this.greeting = service.greeting; - } - - changeGreeting(): void { - this.greeting = 'howdy'; - } - - onKeyDown(event: KeyboardEvent): void { - this.lastKey = String.fromCharCode(event.keyCode); - } -} diff --git a/modules/playground/src/web_workers/kitchen_sink/loader.js b/modules/playground/src/web_workers/kitchen_sink/loader.js deleted file mode 100644 index 9dd1900c0b..0000000000 --- a/modules/playground/src/web_workers/kitchen_sink/loader.js +++ /dev/null @@ -1,14 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -importScripts('angular/modules/playground/src/web_workers/worker-configure.js'); - -System.config({packages: {'angular/modules/playground/src/web_workers': {defaultExtension: 'js'}}}); - -System.import('./background_index.js') - .catch(error => console.error('error loading background', error)); diff --git a/modules/playground/src/web_workers/message_broker/BUILD.bazel b/modules/playground/src/web_workers/message_broker/BUILD.bazel deleted file mode 100644 index 9dd6417a30..0000000000 --- a/modules/playground/src/web_workers/message_broker/BUILD.bazel +++ /dev/null @@ -1,38 +0,0 @@ -load("//tools:defaults.bzl", "ng_module", "ts_devserver") - -package(default_visibility = ["//modules/playground:__subpackages__"]) - -ng_module( - name = "message_broker", - srcs = glob(["**/*.ts"]), - tsconfig = "//modules/playground:tsconfig-build.json", - deps = [ - "//packages/core", - "//packages/platform-webworker", - "//packages/platform-webworker-dynamic", - ], -) - -ts_devserver( - name = "devserver", - bootstrap = [ - "@npm//:node_modules/systemjs/dist/system.js", - "//packages/zone.js/bundles:zone.umd.js", - "//packages/zone.js/bundles:long-stack-trace-zone.umd.js", - "@npm//:node_modules/reflect-metadata/Reflect.js", - ], - entry_module = "angular/modules/playground/src/web_workers/message_broker/index", - port = 4200, - scripts = [ - "@npm//:node_modules/tslib/tslib.js", - "//tools/rxjs:rxjs_umd_modules", - ], - static_files = [ - "index.html", - "loader.js", - "//modules/playground/src/web_workers:worker-config", - "//modules/playground:systemjs-config.js", - "//modules/playground:systemjs-rxjs-operators.js", - ], - deps = [":message_broker"], -) diff --git a/modules/playground/src/web_workers/message_broker/background_index.ts b/modules/playground/src/web_workers/message_broker/background_index.ts deleted file mode 100644 index f9f8e033c7..0000000000 --- a/modules/playground/src/web_workers/message_broker/background_index.ts +++ /dev/null @@ -1,19 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -import {NgModule} from '@angular/core'; -import {WorkerAppModule} from '@angular/platform-webworker'; -import {platformWorkerAppDynamic} from '@angular/platform-webworker-dynamic'; - -import {App} from './index_common'; - -@NgModule({imports: [WorkerAppModule], bootstrap: [App], declarations: [App]}) -export class ExampleModule { -} - -platformWorkerAppDynamic().bootstrapModule(ExampleModule); diff --git a/modules/playground/src/web_workers/message_broker/index.html b/modules/playground/src/web_workers/message_broker/index.html deleted file mode 100644 index f1aab56501..0000000000 --- a/modules/playground/src/web_workers/message_broker/index.html +++ /dev/null @@ -1,14 +0,0 @@ - - - Message Broker Example - - - - -

-

- - - - - diff --git a/modules/playground/src/web_workers/message_broker/index.ts b/modules/playground/src/web_workers/message_broker/index.ts deleted file mode 100644 index 592ff5bd77..0000000000 --- a/modules/playground/src/web_workers/message_broker/index.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -import {PlatformRef} from '@angular/core'; -import {bootstrapWorkerUi, ClientMessageBrokerFactory, FnArg, SerializerTypes, UiArguments} from '@angular/platform-webworker'; - -const ECHO_CHANNEL = 'ECHO'; - -function afterBootstrap(ref: PlatformRef) { - const brokerFactory: ClientMessageBrokerFactory = ref.injector.get(ClientMessageBrokerFactory); - const broker = brokerFactory.createMessageBroker(ECHO_CHANNEL, false); - - document.getElementById('send_echo').addEventListener('click', (e) => { - const val = (document.getElementById('echo_input')).value; - // TODO(jteplitz602): Replace default constructors with real constructors - // once they're in the .d.ts file (#3926) - const fnArg = new FnArg(val); - const args = new UiArguments('echo', [fnArg]); - - broker.runOnService(args, SerializerTypes.PRIMITIVE).then((echo_result: string) => { - document.getElementById('echo_result').innerHTML = - `${echo_result}`; - }); - }); -} - -bootstrapWorkerUi('loader.js').then(afterBootstrap); diff --git a/modules/playground/src/web_workers/message_broker/index_common.ts b/modules/playground/src/web_workers/message_broker/index_common.ts deleted file mode 100644 index 193964bdba..0000000000 --- a/modules/playground/src/web_workers/message_broker/index_common.ts +++ /dev/null @@ -1,25 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -import {Component} from '@angular/core'; -import {SerializerTypes, ServiceMessageBrokerFactory} from '@angular/platform-webworker'; - -const ECHO_CHANNEL = 'ECHO'; - -@Component({selector: 'app', template: '

WebWorker MessageBroker Test

'}) -export class App { - constructor(private _serviceBrokerFactory: ServiceMessageBrokerFactory) { - const broker = _serviceBrokerFactory.createMessageBroker(ECHO_CHANNEL, false); - broker.registerMethod( - 'echo', [SerializerTypes.PRIMITIVE], this._echo, SerializerTypes.PRIMITIVE); - } - - private _echo(val: string) { - return new Promise((res) => res(val)); - } -} diff --git a/modules/playground/src/web_workers/message_broker/loader.js b/modules/playground/src/web_workers/message_broker/loader.js deleted file mode 100644 index 9dd1900c0b..0000000000 --- a/modules/playground/src/web_workers/message_broker/loader.js +++ /dev/null @@ -1,14 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -importScripts('angular/modules/playground/src/web_workers/worker-configure.js'); - -System.config({packages: {'angular/modules/playground/src/web_workers': {defaultExtension: 'js'}}}); - -System.import('./background_index.js') - .catch(error => console.error('error loading background', error)); diff --git a/modules/playground/src/web_workers/router/BUILD.bazel b/modules/playground/src/web_workers/router/BUILD.bazel deleted file mode 100644 index e771007426..0000000000 --- a/modules/playground/src/web_workers/router/BUILD.bazel +++ /dev/null @@ -1,41 +0,0 @@ -load("//tools:defaults.bzl", "ng_module", "ts_devserver") - -package(default_visibility = ["//modules/playground:__subpackages__"]) - -ng_module( - name = "router", - srcs = glob(["**/*.ts"]), - assets = ["app.html"], - tsconfig = "//modules/playground:tsconfig-build.json", - deps = [ - "//packages/core", - "//packages/platform-webworker", - "//packages/platform-webworker-dynamic", - "//packages/router", - "@npm//rxjs", - ], -) - -ts_devserver( - name = "devserver", - bootstrap = [ - "@npm//:node_modules/systemjs/dist/system.js", - "//packages/zone.js/bundles:zone.umd.js", - "//packages/zone.js/bundles:long-stack-trace-zone.umd.js", - "@npm//:node_modules/reflect-metadata/Reflect.js", - ], - entry_module = "angular/modules/playground/src/web_workers/router/index", - port = 4200, - scripts = [ - "@npm//:node_modules/tslib/tslib.js", - "//tools/rxjs:rxjs_umd_modules", - ], - static_files = [ - "index.html", - "loader.js", - "//modules/playground/src/web_workers:worker-config", - "//modules/playground:systemjs-config.js", - "//modules/playground:systemjs-rxjs-operators.js", - ], - deps = [":router"], -) diff --git a/modules/playground/src/web_workers/router/app.html b/modules/playground/src/web_workers/router/app.html deleted file mode 100644 index d79243c194..0000000000 --- a/modules/playground/src/web_workers/router/app.html +++ /dev/null @@ -1,11 +0,0 @@ - -
- -
- diff --git a/modules/playground/src/web_workers/router/background_index.ts b/modules/playground/src/web_workers/router/background_index.ts deleted file mode 100644 index d8240a05a1..0000000000 --- a/modules/playground/src/web_workers/router/background_index.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -import {platformWorkerAppDynamic} from '@angular/platform-webworker-dynamic'; -import {AppModule} from './index_common'; - -platformWorkerAppDynamic().bootstrapModule(AppModule); diff --git a/modules/playground/src/web_workers/router/components/about.ts b/modules/playground/src/web_workers/router/components/about.ts deleted file mode 100644 index 272a2404b2..0000000000 --- a/modules/playground/src/web_workers/router/components/about.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -import {Component} from '@angular/core'; -@Component({selector: 'about', template: '

About

'}) -export class About { -} diff --git a/modules/playground/src/web_workers/router/components/contact.ts b/modules/playground/src/web_workers/router/components/contact.ts deleted file mode 100644 index 46ba8e7cdc..0000000000 --- a/modules/playground/src/web_workers/router/components/contact.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -import {Component} from '@angular/core'; -@Component({selector: 'contact', template: '

Contact

'}) -export class Contact { -} diff --git a/modules/playground/src/web_workers/router/components/start.ts b/modules/playground/src/web_workers/router/components/start.ts deleted file mode 100644 index d80dab1618..0000000000 --- a/modules/playground/src/web_workers/router/components/start.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -import {Component} from '@angular/core'; -@Component({selector: 'start', template: '

Start

'}) -export class Start { -} diff --git a/modules/playground/src/web_workers/router/index.html b/modules/playground/src/web_workers/router/index.html deleted file mode 100644 index 90ce028dae..0000000000 --- a/modules/playground/src/web_workers/router/index.html +++ /dev/null @@ -1,10 +0,0 @@ - - - Web Worker Router Example - - - - - - - diff --git a/modules/playground/src/web_workers/router/index.ts b/modules/playground/src/web_workers/router/index.ts deleted file mode 100644 index 72034f8c65..0000000000 --- a/modules/playground/src/web_workers/router/index.ts +++ /dev/null @@ -1,11 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -import {bootstrapWorkerUi, WORKER_UI_LOCATION_PROVIDERS} from '@angular/platform-webworker'; - -bootstrapWorkerUi('loader.js', WORKER_UI_LOCATION_PROVIDERS); diff --git a/modules/playground/src/web_workers/router/index_common.ts b/modules/playground/src/web_workers/router/index_common.ts deleted file mode 100644 index 9aa0ce01c0..0000000000 --- a/modules/playground/src/web_workers/router/index_common.ts +++ /dev/null @@ -1,35 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -import {Component, NgModule} from '@angular/core'; -import {WORKER_APP_LOCATION_PROVIDERS, WorkerAppModule} from '@angular/platform-webworker'; -import {RouterModule} from '@angular/router'; - -import {About} from './components/about'; -import {Contact} from './components/contact'; -import {Start} from './components/start'; - -@Component({selector: 'app', templateUrl: 'app.html'}) -export class App { -} - -export const ROUTES = [ - {path: '', component: Start}, {path: 'contact', component: Contact}, - {path: 'about', component: About} -]; - -@NgModule({ - imports: [WorkerAppModule, RouterModule.forRoot(ROUTES, {useHash: true})], - providers: [ - WORKER_APP_LOCATION_PROVIDERS, - ], - bootstrap: [App], - declarations: [App, Start, Contact, About] -}) -export class AppModule { -} diff --git a/modules/playground/src/web_workers/router/loader.js b/modules/playground/src/web_workers/router/loader.js deleted file mode 100644 index 9dd1900c0b..0000000000 --- a/modules/playground/src/web_workers/router/loader.js +++ /dev/null @@ -1,14 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -importScripts('angular/modules/playground/src/web_workers/worker-configure.js'); - -System.config({packages: {'angular/modules/playground/src/web_workers': {defaultExtension: 'js'}}}); - -System.import('./background_index.js') - .catch(error => console.error('error loading background', error)); diff --git a/modules/playground/src/web_workers/todo/BUILD.bazel b/modules/playground/src/web_workers/todo/BUILD.bazel deleted file mode 100644 index ab7d016886..0000000000 --- a/modules/playground/src/web_workers/todo/BUILD.bazel +++ /dev/null @@ -1,41 +0,0 @@ -load("//tools:defaults.bzl", "ng_module", "ts_devserver") - -package(default_visibility = ["//modules/playground:__subpackages__"]) - -ng_module( - name = "todo", - srcs = glob(["**/*.ts"]), - assets = ["todo.html"], - tsconfig = "//modules/playground:tsconfig-build.json", - deps = [ - "//packages/core", - "//packages/forms", - "//packages/platform-webworker", - "//packages/platform-webworker-dynamic", - ], -) - -ts_devserver( - name = "devserver", - bootstrap = [ - "@npm//:node_modules/systemjs/dist/system.js", - "//packages/zone.js/bundles:zone.umd.js", - "//packages/zone.js/bundles:long-stack-trace-zone.umd.js", - "@npm//:node_modules/reflect-metadata/Reflect.js", - ], - entry_module = "angular/modules/playground/src/web_workers/todo/index", - port = 4200, - scripts = [ - "@npm//:node_modules/tslib/tslib.js", - "//tools/rxjs:rxjs_umd_modules", - ], - static_files = [ - "index.html", - "css/main.css", - "loader.js", - "//modules/playground/src/web_workers:worker-config", - "//modules/playground:systemjs-config.js", - "//modules/playground:systemjs-rxjs-operators.js", - ], - deps = [":todo"], -) diff --git a/modules/playground/src/web_workers/todo/background_index.ts b/modules/playground/src/web_workers/todo/background_index.ts deleted file mode 100644 index f54e747f42..0000000000 --- a/modules/playground/src/web_workers/todo/background_index.ts +++ /dev/null @@ -1,20 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -import {NgModule} from '@angular/core'; -import {FormsModule} from '@angular/forms'; -import {WorkerAppModule} from '@angular/platform-webworker'; -import {platformWorkerAppDynamic} from '@angular/platform-webworker-dynamic'; - -import {TodoApp} from './index_common'; - -@NgModule({imports: [WorkerAppModule, FormsModule], bootstrap: [TodoApp], declarations: [TodoApp]}) -export class ExampleModule { -} - -platformWorkerAppDynamic().bootstrapModule(ExampleModule); diff --git a/modules/playground/src/web_workers/todo/css/bg.png b/modules/playground/src/web_workers/todo/css/bg.png deleted file mode 100644 index b2a7600825ee11f21849ed475499c7d1ecbcc870..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2126 zcmV-U2(kBxP)+9y`=HK7nt=~3t000O5Nklm=04hVa_lXl_bm=+M;=eI<%$rO2ta`suh*Sr#POw*?adq!O!CV z*0&b)rkCCEV)1nIuiLBntUH-MJI;&qYgz|d@Nhnn_abi2g`pu4NAMVid3hS%?quz~ zjlJf(x8cj{VS zUVEP1msg9`^OFUhSO5rtXHhRlyU2i>6$BT=glG`{JlctGHrwRIm)6Buu65jLQn^H8 zvl9lZqUBA+%qvM5XC+yY@mfA(YB~XP=e|6<{%$^eU8nrK?v2ccb@Jom5CG>rKAL7J zplHEIavVp|0p1&m!G`Ti?<7iZ;}@G7#Z)}Km%2!FHnQ0*&?PLR)G!HAaHgU#c|$dz zpj#0HmeadIe>`#)=Jjkb{B=FKnU3pc-&Y@j_j6(h4Y~+Uq!^J=LHunx1xi4QXK-Y{&MoT8ky6Vb9c|WhnOwF~c=3zOy8agktliS6# z`#8F`9H)D=bmk9B5MnW&_r#)f$c+;$LSr-@^An8dhc~Iquuv>jOK7pw7LJ;&X0i1C zGMsHdP1Os@ny$$j!>XAii%7bp5k>`pyNA!~epb)()p9zR4Yl6z=U}{CIdh1z(FpAo zQIW!;0zpCyC4*7YLkZCO@cul0R_&zghsA8Ek)z%jNpKa92{@NH+SstX%@}xB*Jk!l}PZ1cClIns~}5^!RncUk*rmA z%SIVgt58EQxLJ+OiFqKkBuwquyZLUp|gr zPUbUbFbBrPd1xO`^C*r-i3p9*F#(OBh!4Wy@aC&*!|O|GXcjDA&YhF{;cD7*o(GS^ z@pQSE7)x_81=Qyje6*LQ#TXu-7(o;S8u3tpDA0_ddj%hmCspeXdhYR}-i9A=C`EoChUYuH~^x!9+|&(Pgb*>Ck<=9j|)*@xyfT zpP#+Kt<}39b|3Wl4fxT(+G?aH>gG^d@MEaUOJRfy55TtFI7^Y)VuMU=7Pp0y55jS~ z+TJ)igMyrqkX;wU8j68iIDtqJYhS_D3_Oem-@g6me_RfiQ}uT_K-A-9qG%}gk3E9c z!8`KgsMNXm)beloPfMql*|&$M>1q`i!cY)RFYnjNYu*gSv@8XebV7%}xYL>6)GJPJ zJpA7K31lcJuIFKSw-{x4FX0K2Az)~Xg<`sOu$4|^-(^XJX4YzoiNRvL zyuY7~26w-P^Zw%6F}shBwV2$02c8RsSUy6dM92diCAxiX3IUqsq5ig6>U_!Vy*q5$ zjm}16tJr+QZ&T?HkkpeIwVX-r1EI=@%Zlt;6g*mj&E!A))%gXJ=x6u#l zcKEP>bx4rqV*k`BBrZ$Mqjt{TsHcxUH>;)iAK}B(Kila&VD%b?6m&^0WK4^&EZNAI z8AMYs_%$D%|M+@+cQqL-hi4yG>h*jwdii!W1{}p>ZhwFYt_4Su1kjY9<-5`!$VNOI1y(EDSH4WpCijE_>al!Nt=^eVER#uJ1=b z;BWF2IgyF5LexV+yec$Kin;Ai@myo;G>zJ&jrdW#ecXhIZph5OYqw_PEfcF56Z5Zu_ZZE#q3Mc+N&1O^7hoh9QR7`+L$cBP5pqG=fqA0uh zUBukaxTFmH)<|Xbvp2c=HSbNkpXw73a5lv7V$jb92#yZ141@$X?F}Jt8gIU7Wm6m9 z?e_;;zsnm6`LZeP>T=$)Kr>Z?kr*UmFqR7zx0C6^bmcsc@1AGtw_rNH>-Xm$d*|Q< zn&1Ln0u7=l&ILs>%CkJp`DiG9F18x4Ne+lg<#i?e7jL%x;4ZnRkN^Mx07*qoM6N<$ Ef(>0N!2kdN diff --git a/modules/playground/src/web_workers/todo/css/main.css b/modules/playground/src/web_workers/todo/css/main.css deleted file mode 100644 index 2b3220292b..0000000000 --- a/modules/playground/src/web_workers/todo/css/main.css +++ /dev/null @@ -1,386 +0,0 @@ -@charset "utf-8"; - -html, -body { - margin: 0; - padding: 0; -} - -body { - font: 14px 'Helvetica Neue', Helvetica, Arial, sans-serif; - line-height: 1.4em; - background: #eaeaea; - color: #4d4d4d; - width: 550px; - margin: 0 auto; -} - -button { - margin: 0; - padding: 0; - border: 0; - background: none; - font-size: 100%; - vertical-align: baseline; - font-family: inherit; - font-weight: inherit; - color: inherit; - -webkit-appearance: none; - -ms-appearance: none; - appearance: none; -} - -button, -input[type="checkbox"] { - outline: none; -} - -.hidden { - display: none; -} - -.visible { - display: block !important; -} - -#todoapp { - background: #fff; - margin: 130px 0 40px 0; - position: relative; - box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.2), - 0 25px 50px 0 rgba(0, 0, 0, 0.1); -} - -#todoapp input::-webkit-input-placeholder { - font-style: italic; - font-weight: 300; - color: #e6e6e6; -} - -#todoapp input::-moz-placeholder { - font-style: italic; - font-weight: 300; - color: #e6e6e6; -} - -#todoapp input::input-placeholder { - font-style: italic; - font-weight: 300; - color: #e6e6e6; -} - -#todoapp h1 { - position: absolute; - top: -155px; - width: 100%; - font-size: 100px; - font-weight: 100; - text-align: center; - color: rgba(175, 47, 47, 0.15); - -webkit-text-rendering: optimizeLegibility; - -moz-text-rendering: optimizeLegibility; - -ms-text-rendering: optimizeLegibility; - text-rendering: optimizeLegibility; -} - -#new-todo, -.edit { - position: relative; - margin: 0; - width: 100%; - font-size: 24px; - font-family: inherit; - font-weight: inherit; - line-height: 1.4em; - border: 0; - outline: none; - color: inherit; - padding: 6px; - border: 1px solid #999; - box-shadow: inset 0 -1px 5px 0 rgba(0, 0, 0, 0.2); - -ms-box-sizing: border-box; - box-sizing: border-box; -} - -#new-todo { - padding: 16px 16px 16px 60px; - border: none; - background: rgba(0, 0, 0, 0.003); - box-shadow: inset 0 -2px 1px rgba(0,0,0,0.03); -} - -#main { - position: relative; - z-index: 2; - border-top: 1px solid #e6e6e6; -} - -label[for='toggle-all'] { - display: none; -} - -#toggle-all { - position: absolute; - top: -55px; - left: -12px; - width: 60px; - height: 34px; - text-align: center; - border: none; /* Mobile Safari */ -} - -#toggle-all:before { - content: '❯'; - font-size: 22px; - color: #e6e6e6; - padding: 10px 27px 10px 27px; -} - -#toggle-all:checked:before { - color: #737373; -} - -#todo-list { - margin: 0; - padding: 0; - list-style: none; -} - -#todo-list li { - position: relative; - font-size: 24px; - border-bottom: 1px solid #ededed; -} - -#todo-list li:last-child { - border-bottom: none; -} - -#todo-list li.editing { - border-bottom: none; - padding: 0; -} - -#todo-list li.editing .edit { - display: block; - width: 506px; - padding: 13px 17px 12px 17px; - margin: 0 0 0 43px; -} - -#todo-list li.editing .view { - display: none; -} - -#todo-list li .toggle { - text-align: center; - width: 40px; - /* auto, since non-WebKit browsers doesn't support input styling */ - height: auto; - position: absolute; - top: 0; - bottom: 0; - margin: auto 0; - border: none; /* Mobile Safari */ - -webkit-appearance: none; - -ms-appearance: none; - appearance: none; -} - -#todo-list li .toggle:after { - content: url('data:image/svg+xml;charset=utf8,'); -} - -#todo-list li .toggle:checked:after { - content: url('data:image/svg+xml;charset=utf8,'); -} - -#todo-list li label { - white-space: pre; - word-break: break-word; - padding: 15px 60px 15px 15px; - margin-left: 45px; - display: block; - line-height: 1.2; - transition: color 0.4s; -} - -#todo-list li.completed label { - color: #d9d9d9; - text-decoration: line-through; -} - -#todo-list li .destroy { - display: none; - position: absolute; - top: 0; - right: 10px; - bottom: 0; - width: 40px; - height: 40px; - margin: auto 0; - font-size: 30px; - color: #cc9a9a; - margin-bottom: 11px; - transition: color 0.2s ease-out; -} - -#todo-list li .destroy:hover { - color: #af5b5e; -} - -#todo-list li .destroy:after { - content: '×'; -} - -#todo-list li:hover .destroy { - display: block; -} - -#todo-list li .edit { - display: none; -} - -#todo-list li.editing:last-child { - margin-bottom: -1px; -} - -#footer { - color: #777; - padding: 10px 15px; - height: 20px; - text-align: center; - border-top: 1px solid #e6e6e6; -} - -#footer:before { - content: ''; - position: absolute; - right: 0; - bottom: 0; - left: 0; - height: 50px; - overflow: hidden; - box-shadow: 0 1px 1px rgba(0, 0, 0, 0.2), - 0 8px 0 -3px #f6f6f6, - 0 9px 1px -3px rgba(0, 0, 0, 0.2), - 0 16px 0 -6px #f6f6f6, - 0 17px 2px -6px rgba(0, 0, 0, 0.2); -} - -#todo-count { - float: left; - text-align: left; -} - -#todo-count strong { - font-weight: 300; -} - -#filters { - margin: 0; - padding: 0; - list-style: none; - position: absolute; - right: 0; - left: 0; -} - -#filters li { - display: inline; -} - -#filters li a { - color: inherit; - margin: 3px; - padding: 3px 7px; - text-decoration: none; - border: 1px solid transparent; - border-radius: 3px; -} - -#filters li a.selected, -#filters li a:hover { - border-color: rgba(175, 47, 47, 0.1); -} - -#filters li a.selected { - border-color: rgba(175, 47, 47, 0.2); -} - -#clear-completed, -html #clear-completed:active { - float: right; - position: relative; - line-height: 20px; - text-decoration: none; - cursor: pointer; - visibility: hidden; - position: relative; -} - -#clear-completed::after { - visibility: visible; - content: 'Clear completed'; - position: absolute; - right: 0; - white-space: nowrap; -} - -#clear-completed:hover::after { - text-decoration: underline; -} - -#info { - margin: 65px auto 0; - color: #bfbfbf; - font-size: 10px; - text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5); - text-align: center; -} - -#info p { - line-height: 1; -} - -#info a { - color: inherit; - text-decoration: none; - font-weight: 400; -} - -#info a:hover { - text-decoration: underline; -} - -/* -Hack to remove background from Mobile Safari. -Can't use it globally since it destroys checkboxes in Firefox -*/ -@media screen and (-webkit-min-device-pixel-ratio:0) { - #toggle-all, - #todo-list li .toggle { - background: none; - } - - #todo-list li .toggle { - height: 40px; - } - - #toggle-all { - -webkit-transform: rotate(90deg); - transform: rotate(90deg); - -webkit-appearance: none; - appearance: none; - } -} - -@media (max-width: 430px) { - #footer { - height: 50px; - } - - #filters { - bottom: 10px; - } -} diff --git a/modules/playground/src/web_workers/todo/index.html b/modules/playground/src/web_workers/todo/index.html deleted file mode 100644 index 329bf4c6a0..0000000000 --- a/modules/playground/src/web_workers/todo/index.html +++ /dev/null @@ -1,13 +0,0 @@ - - - Todo Angular - WebWorker - - - - Loading... - - - - - - diff --git a/modules/playground/src/web_workers/todo/index.ts b/modules/playground/src/web_workers/todo/index.ts deleted file mode 100644 index f3791aca91..0000000000 --- a/modules/playground/src/web_workers/todo/index.ts +++ /dev/null @@ -1,11 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -import {bootstrapWorkerUi} from '@angular/platform-webworker'; - -bootstrapWorkerUi('loader.js'); diff --git a/modules/playground/src/web_workers/todo/index_common.ts b/modules/playground/src/web_workers/todo/index_common.ts deleted file mode 100644 index 9630d45927..0000000000 --- a/modules/playground/src/web_workers/todo/index_common.ts +++ /dev/null @@ -1,80 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -import {Component} from '@angular/core'; - -import {Store, Todo, TodoFactory} from './services/TodoStore'; - -@Component({selector: 'todo-app', viewProviders: [Store, TodoFactory], templateUrl: 'todo.html'}) -export class TodoApp { - todoEdit: Todo = null; - inputValue: string; - hideActive: boolean = false; - hideCompleted: boolean = false; - isComplete: boolean = false; - - constructor(public todoStore: Store, public factory: TodoFactory) {} - - enterTodo(): void { - this.addTodo(this.inputValue); - this.inputValue = ''; - } - - doneEditing($event: KeyboardEvent, todo: Todo): void { - const which = $event.keyCode; - if (which === 13) { - todo.title = todo.editTitle; - this.todoEdit = null; - } else if (which === 27) { - this.todoEdit = null; - todo.editTitle = todo.title; - } - } - - editTodo(todo: Todo): void { - this.todoEdit = todo; - } - - addTodo(newTitle: string): void { - this.todoStore.add(this.factory.create(newTitle, false)); - } - - completeMe(todo: Todo): void { - todo.completed = !todo.completed; - } - - toggleCompleted(): void { - this.hideActive = !this.hideActive; - this.hideCompleted = false; - } - - toggleActive(): void { - this.hideCompleted = !this.hideCompleted; - this.hideActive = false; - } - - showAll(): void { - this.hideCompleted = false; - this.hideActive = false; - } - - deleteMe(todo: Todo): void { - this.todoStore.remove(todo); - } - - toggleAll($event: MouseEvent): void { - this.isComplete = !this.isComplete; - this.todoStore.list.forEach((todo: Todo) => { - todo.completed = this.isComplete; - }); - } - - clearCompleted(): void { - this.todoStore.removeBy((todo: Todo) => todo.completed); - } -} diff --git a/modules/playground/src/web_workers/todo/index_web_socket.html b/modules/playground/src/web_workers/todo/index_web_socket.html deleted file mode 100644 index e4fac7623f..0000000000 --- a/modules/playground/src/web_workers/todo/index_web_socket.html +++ /dev/null @@ -1,10 +0,0 @@ - - - Todo Angular - WebWorker - - - - Loading... - - - diff --git a/modules/playground/src/web_workers/todo/loader.js b/modules/playground/src/web_workers/todo/loader.js deleted file mode 100644 index 9dd1900c0b..0000000000 --- a/modules/playground/src/web_workers/todo/loader.js +++ /dev/null @@ -1,14 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -importScripts('angular/modules/playground/src/web_workers/worker-configure.js'); - -System.config({packages: {'angular/modules/playground/src/web_workers': {defaultExtension: 'js'}}}); - -System.import('./background_index.js') - .catch(error => console.error('error loading background', error)); diff --git a/modules/playground/src/web_workers/todo/services/TodoStore.ts b/modules/playground/src/web_workers/todo/services/TodoStore.ts deleted file mode 100644 index 34896ca7c8..0000000000 --- a/modules/playground/src/web_workers/todo/services/TodoStore.ts +++ /dev/null @@ -1,53 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -import {Injectable} from '@angular/core'; - -// base model for RecordStore -export class KeyModel { - constructor(public key: number) {} -} - -export class Todo extends KeyModel { - editTitle: string; - constructor(key: number, public title: string, public completed: boolean) { - super(key); - this.editTitle = title; - } -} - -@Injectable() -export class TodoFactory { - private _uid: number = 0; - - nextUid(): number { - return ++this._uid; - } - - create(title: string, isCompleted: boolean): Todo { - return new Todo(this.nextUid(), title, isCompleted); - } -} - -// Store manages any generic item that inherits from KeyModel -@Injectable() -export class Store { - list: T[] = []; - - add(record: T): void { - this.list.push(record); - } - - remove(record: T): void { - this.removeBy((item) => item === record); - } - - removeBy(callback: (record: T) => boolean): void { - this.list = this.list.filter((record) => !callback(record)); - } -} diff --git a/modules/playground/src/web_workers/todo/todo.html b/modules/playground/src/web_workers/todo/todo.html deleted file mode 100644 index d65042c440..0000000000 --- a/modules/playground/src/web_workers/todo/todo.html +++ /dev/null @@ -1,68 +0,0 @@ -
- - - -
- - - -
    - -
  • -
    - - - - - - -
    - -
    - - - -
    -
  • -
- -
- - - -
- - diff --git a/modules/playground/src/web_workers/worker-configure.js b/modules/playground/src/web_workers/worker-configure.js deleted file mode 100644 index 8aba8ffcfa..0000000000 --- a/modules/playground/src/web_workers/worker-configure.js +++ /dev/null @@ -1,14 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -importScripts('npm/node_modules/reflect-metadata/Reflect.js'); -importScripts('angular/packages/zone.js/bundles/zone.umd.js'); -importScripts('angular/packages/zone.js/bundles/long-stack-trace-zone.umd.js'); -importScripts('npm/node_modules/systemjs/dist/system.js'); - -importScripts('angular/modules/playground/systemjs-config.js'); diff --git a/modules/playground/systemjs-config.js b/modules/playground/systemjs-config.js index e30ed5878b..cc0f8b95b9 100644 --- a/modules/playground/systemjs-config.js +++ b/modules/playground/systemjs-config.js @@ -21,8 +21,6 @@ const angularPackages = [ 'http', 'platform-browser', 'platform-browser-dynamic', - 'platform-webworker', - 'platform-webworker-dynamic', 'router', 'upgrade', 'upgrade/static', diff --git a/packages/bazel/src/ng_package/ng_package.bzl b/packages/bazel/src/ng_package/ng_package.bzl index 6619799dc5..a2d3cc4f8b 100644 --- a/packages/bazel/src/ng_package/ng_package.bzl +++ b/packages/bazel/src/ng_package/ng_package.bzl @@ -102,8 +102,6 @@ WELL_KNOWN_GLOBALS = {p: _global_name(p) for p in [ "@angular/core", "@angular/platform-server/testing", "@angular/platform-server", - "@angular/platform-webworker-dynamic", - "@angular/platform-webworker", "@angular/common/testing", "@angular/common", "@angular/common/http/testing", diff --git a/packages/circular-deps-test.conf.js b/packages/circular-deps-test.conf.js index 0820b1907e..33fe4c7d4e 100644 --- a/packages/circular-deps-test.conf.js +++ b/packages/circular-deps-test.conf.js @@ -11,8 +11,7 @@ const path = require('path'); module.exports = { baseDir: '../', goldenFile: '../goldens/circular-deps/packages.json', - // The test should not capture deprecated packages such as `http`, or the `webworker` platform. - glob: `./!(http|platform-webworker|platform-webworker-dynamic)/**/*.ts`, + glob: `./**/*.ts`, // Command that will be displayed if the golden needs to be updated. approveCommand: 'yarn ts-circular-deps:approve', resolveModule: resolveModule diff --git a/packages/common/src/viewport_scroller.ts b/packages/common/src/viewport_scroller.ts index a7c9093426..bbcf53ebbc 100644 --- a/packages/common/src/viewport_scroller.ts +++ b/packages/common/src/viewport_scroller.ts @@ -178,8 +178,7 @@ function getScrollRestorationProperty(obj: any): PropertyDescriptor|undefined { } /** - * Provides an empty implementation of the viewport scroller. This will - * live in @angular/common as it will be used by both platform-server and platform-webworker. + * Provides an empty implementation of the viewport scroller. */ export class NullViewportScroller implements ViewportScroller { /** diff --git a/packages/platform-webworker-dynamic/BUILD.bazel b/packages/platform-webworker-dynamic/BUILD.bazel deleted file mode 100644 index 1103cdf08b..0000000000 --- a/packages/platform-webworker-dynamic/BUILD.bazel +++ /dev/null @@ -1,43 +0,0 @@ -load("//tools:defaults.bzl", "ng_module", "ng_package", "ts_api_guardian_test_npm_package") - -package(default_visibility = ["//visibility:public"]) - -ng_module( - name = "platform-webworker-dynamic", - srcs = glob( - [ - "*.ts", - "src/**/*.ts", - ], - ), - deps = [ - "//packages:types", - "//packages/common", - "//packages/compiler", - "//packages/core", - "//packages/platform-browser-dynamic", - ], -) - -ng_package( - name = "npm_package", - srcs = ["package.json"], - entry_point = ":index.ts", - tags = [ - "release-with-framework", - ], - # Do not add more to this list. - # Dependencies on the full npm_package cause long re-builds. - visibility = ["//integration:__pkg__"], - deps = [":platform-webworker-dynamic"], -) - -ts_api_guardian_test_npm_package( - name = "platform-webworker-dynamic_api", - actualDir = "angular/packages/platform-webworker-dynamic/npm_package", - data = [ - ":npm_package", - "//goldens:public-api", - ], - goldenDir = "angular/goldens/public-api/platform-webworker-dynamic", -) diff --git a/packages/platform-webworker-dynamic/index.ts b/packages/platform-webworker-dynamic/index.ts deleted file mode 100644 index 7ef6571cd5..0000000000 --- a/packages/platform-webworker-dynamic/index.ts +++ /dev/null @@ -1,14 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -// This file is not used to build this module. It is only used during editing -// by the TypeScript language service and during build for verification. `ngc` -// replaces this file with production index.ts when it rewrites private symbol -// names. - -export * from './public_api'; diff --git a/packages/platform-webworker-dynamic/package.json b/packages/platform-webworker-dynamic/package.json deleted file mode 100644 index 5c7baced1a..0000000000 --- a/packages/platform-webworker-dynamic/package.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "name": "@angular/platform-webworker-dynamic", - "version": "0.0.0-PLACEHOLDER", - "description": "Angular - library for using Angular in a web browser with web workers", - "author": "angular", - "license": "MIT", - "dependencies": { - "tslib": "^2.0.0" - }, - "peerDependencies": { - "@angular/common": "0.0.0-PLACEHOLDER", - "@angular/core": "0.0.0-PLACEHOLDER", - "@angular/compiler": "0.0.0-PLACEHOLDER", - "@angular/platform-browser": "0.0.0-PLACEHOLDER", - "@angular/platform-webworker": "0.0.0-PLACEHOLDER" - }, - "repository": { - "type": "git", - "url": "https://github.com/angular/angular.git", - "directory": "packages/platform-webworker-dynamic" - }, - "ng-update": { - "packageGroup": "NG_UPDATE_PACKAGE_GROUP" - }, - "sideEffects": false, - "publishConfig":{ - "registry":"https://wombat-dressing-room.appspot.com" - } -} diff --git a/packages/platform-webworker-dynamic/public_api.ts b/packages/platform-webworker-dynamic/public_api.ts deleted file mode 100644 index f6ddc07fc9..0000000000 --- a/packages/platform-webworker-dynamic/public_api.ts +++ /dev/null @@ -1,15 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -/** - * @module - * @description - * Entry point for all public APIs of this package. - */ -export * from './src/platform-webworker-dynamic'; -// This file only reexports content of the `src` folder. Keep it that way. diff --git a/packages/platform-webworker-dynamic/src/platform-webworker-dynamic.ts b/packages/platform-webworker-dynamic/src/platform-webworker-dynamic.ts deleted file mode 100644 index f82a60f2b6..0000000000 --- a/packages/platform-webworker-dynamic/src/platform-webworker-dynamic.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -import {ɵPLATFORM_WORKER_UI_ID as PLATFORM_WORKER_UI_ID} from '@angular/common'; -import {ResourceLoader} from '@angular/compiler'; -import {COMPILER_OPTIONS, createPlatformFactory, PLATFORM_ID, PlatformRef, StaticProvider} from '@angular/core'; -import {ɵplatformCoreDynamic as platformCoreDynamic, ɵResourceLoaderImpl as ResourceLoaderImpl} from '@angular/platform-browser-dynamic'; - -export {VERSION} from './version'; - - -/** - * @publicApi - * @deprecated platform-webworker is deprecated in Angular and will be removed in a future version - * of Angular - */ -export const platformWorkerAppDynamic = - createPlatformFactory(platformCoreDynamic, 'workerAppDynamic', [ - { - provide: COMPILER_OPTIONS, - useValue: {providers: [{provide: ResourceLoader, useClass: ResourceLoaderImpl, deps: []}]}, - multi: true - }, - {provide: PLATFORM_ID, useValue: PLATFORM_WORKER_UI_ID} - ]); diff --git a/packages/platform-webworker-dynamic/src/version.ts b/packages/platform-webworker-dynamic/src/version.ts deleted file mode 100644 index 59d0e9ac66..0000000000 --- a/packages/platform-webworker-dynamic/src/version.ts +++ /dev/null @@ -1,22 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -/** - * @module - * @description - * Entry point for all public APIs of the common package. - */ - -import {Version} from '@angular/core'; - -/** - * @publicApi - * @deprecated platform-webworker is deprecated in Angular and will be removed in a future version - * of Angular - */ -export const VERSION = new Version('0.0.0-PLACEHOLDER'); diff --git a/packages/platform-webworker/BUILD.bazel b/packages/platform-webworker/BUILD.bazel deleted file mode 100644 index 1237f7af7b..0000000000 --- a/packages/platform-webworker/BUILD.bazel +++ /dev/null @@ -1,49 +0,0 @@ -load("//tools:defaults.bzl", "ng_module", "ng_package", "ts_api_guardian_test_npm_package") - -package(default_visibility = ["//visibility:public"]) - -ng_module( - name = "platform-webworker", - srcs = glob( - [ - "*.ts", - "src/**/*.ts", - ], - ), - # Disable building with strict compatibility as the platform-webworker package is - # deprecated and therefore it is not needed to make it compatible with --strict. - tsconfig = "//packages:tsconfig-build-no-strict", - deps = [ - "//packages:types", - "//packages/common", - "//packages/compiler", - "//packages/core", - "//packages/platform-browser", - "@npm//rxjs", - ], -) - -ng_package( - name = "npm_package", - srcs = ["package.json"], - entry_point = ":index.ts", - tags = [ - "release-with-framework", - ], - # Do not add more to this list. - # Dependencies on the full npm_package cause long re-builds. - visibility = ["//integration:__pkg__"], - deps = [ - ":platform-webworker", - ], -) - -ts_api_guardian_test_npm_package( - name = "platform-webworker_api", - actualDir = "angular/packages/platform-webworker/npm_package", - data = [ - ":npm_package", - "//goldens:public-api", - ], - goldenDir = "angular/goldens/public-api/platform-webworker", -) diff --git a/packages/platform-webworker/PACKAGE.md b/packages/platform-webworker/PACKAGE.md deleted file mode 100644 index 7d52fca357..0000000000 --- a/packages/platform-webworker/PACKAGE.md +++ /dev/null @@ -1,2 +0,0 @@ -**Deprecated** This package is deprecated and will be removed in a future version of Angular. -See [Angular deprecations policy](guide/deprecations). \ No newline at end of file diff --git a/packages/platform-webworker/index.ts b/packages/platform-webworker/index.ts deleted file mode 100644 index 7ef6571cd5..0000000000 --- a/packages/platform-webworker/index.ts +++ /dev/null @@ -1,14 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -// This file is not used to build this module. It is only used during editing -// by the TypeScript language service and during build for verification. `ngc` -// replaces this file with production index.ts when it rewrites private symbol -// names. - -export * from './public_api'; diff --git a/packages/platform-webworker/package.json b/packages/platform-webworker/package.json deleted file mode 100644 index ac0cd34e20..0000000000 --- a/packages/platform-webworker/package.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "name": "@angular/platform-webworker", - "version": "0.0.0-PLACEHOLDER", - "description": "Angular - library for using Angular in a web browser with web workers", - "author": "angular", - "license": "MIT", - "dependencies": { - "tslib": "^2.0.0" - }, - "peerDependencies": { - "@angular/common": "0.0.0-PLACEHOLDER", - "@angular/core": "0.0.0-PLACEHOLDER", - "@angular/platform-browser": "0.0.0-PLACEHOLDER" - }, - "repository": { - "type": "git", - "url": "https://github.com/angular/angular.git", - "directory": "packages/platform-webworker" - }, - "ng-update": { - "packageGroup": "NG_UPDATE_PACKAGE_GROUP" - }, - "sideEffects": false, - "publishConfig":{ - "registry":"https://wombat-dressing-room.appspot.com" - } -} diff --git a/packages/platform-webworker/public_api.ts b/packages/platform-webworker/public_api.ts deleted file mode 100644 index 8146e52b46..0000000000 --- a/packages/platform-webworker/public_api.ts +++ /dev/null @@ -1,15 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -/** - * @module - * @description - * Entry point for all public APIs of this package. - */ -export * from './src/platform-webworker'; -// This file only reexports content of the `src` folder. Keep it that way. diff --git a/packages/platform-webworker/src/platform-webworker.ts b/packages/platform-webworker/src/platform-webworker.ts deleted file mode 100644 index 9846e80d31..0000000000 --- a/packages/platform-webworker/src/platform-webworker.ts +++ /dev/null @@ -1,39 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -import {PlatformRef, StaticProvider} from '@angular/core'; - -import {platformWorkerUi, WORKER_SCRIPT} from './worker_render'; - -export {VERSION} from './version'; -export {ClientMessageBroker, ClientMessageBrokerFactory, FnArg, UiArguments} from './web_workers/shared/client_message_broker'; -export {MessageBus, MessageBusSink, MessageBusSource} from './web_workers/shared/message_bus'; -export {SerializerTypes} from './web_workers/shared/serializer'; -export {ReceivedMessage, ServiceMessageBroker, ServiceMessageBrokerFactory} from './web_workers/shared/service_message_broker'; -export {WORKER_UI_LOCATION_PROVIDERS} from './web_workers/ui/location_providers'; -export {WORKER_APP_LOCATION_PROVIDERS} from './web_workers/worker/location_providers'; -export {platformWorkerApp, WorkerAppModule} from './worker_app'; -export {platformWorkerUi} from './worker_render'; - -/** - * Bootstraps the worker ui. - * - * @publicApi - * @deprecated platform-webworker is deprecated in Angular and will be removed in a future version - * of Angular - */ -export function bootstrapWorkerUi( - workerScriptUri: string, customProviders: StaticProvider[] = []): Promise { - // For now, just creates the worker ui platform... - const platform = platformWorkerUi([ - {provide: WORKER_SCRIPT, useValue: workerScriptUri}, - ...customProviders, - ]); - - return Promise.resolve(platform); -} diff --git a/packages/platform-webworker/src/version.ts b/packages/platform-webworker/src/version.ts deleted file mode 100644 index 59d0e9ac66..0000000000 --- a/packages/platform-webworker/src/version.ts +++ /dev/null @@ -1,22 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -/** - * @module - * @description - * Entry point for all public APIs of the common package. - */ - -import {Version} from '@angular/core'; - -/** - * @publicApi - * @deprecated platform-webworker is deprecated in Angular and will be removed in a future version - * of Angular - */ -export const VERSION = new Version('0.0.0-PLACEHOLDER'); diff --git a/packages/platform-webworker/src/web_workers/shared/api.ts b/packages/platform-webworker/src/web_workers/shared/api.ts deleted file mode 100644 index 5becf7e1ca..0000000000 --- a/packages/platform-webworker/src/web_workers/shared/api.ts +++ /dev/null @@ -1,11 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -import {InjectionToken} from '@angular/core'; - -export const ON_WEB_WORKER = new InjectionToken('WebWorker.onWebWorker'); diff --git a/packages/platform-webworker/src/web_workers/shared/client_message_broker.ts b/packages/platform-webworker/src/web_workers/shared/client_message_broker.ts deleted file mode 100644 index fdd321cda1..0000000000 --- a/packages/platform-webworker/src/web_workers/shared/client_message_broker.ts +++ /dev/null @@ -1,166 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -import {EventEmitter, Injectable, Type, ɵstringify as stringify} from '@angular/core'; -import {MessageBus} from './message_bus'; -import {Serializer, SerializerTypes} from './serializer'; - -/** - * @publicApi - * @deprecated platform-webworker is deprecated in Angular and will be removed in a future version - * of Angular - */ -@Injectable() -export class ClientMessageBrokerFactory { - /** @internal */ - _serializer: Serializer; - - /** @internal */ - constructor(private _messageBus: MessageBus, _serializer: Serializer) { - this._serializer = _serializer; - } - - /** - * Initializes the given channel and attaches a new {@link ClientMessageBroker} to it. - */ - createMessageBroker(channel: string, runInZone: boolean = true): ClientMessageBroker { - this._messageBus.initChannel(channel, runInZone); - return new ClientMessageBroker(this._messageBus, this._serializer, channel); - } -} - -interface PromiseCompleter { - resolve: (result: any) => void; - reject: (err: any) => void; -} - -/** - * @publicApi - * @deprecated platform-webworker is deprecated in Angular and will be removed in a future version - * of Angular - */ -export class ClientMessageBroker { - private _pending = new Map(); - private _sink: EventEmitter; - /** @internal */ - public _serializer: Serializer; - - /** @internal */ - constructor(messageBus: MessageBus, _serializer: Serializer, private channel: any) { - this._sink = messageBus.to(channel); - this._serializer = _serializer; - const source = messageBus.from(channel); - - source.subscribe({next: (message: ResponseMessageData) => this._handleMessage(message)}); - } - - private _generateMessageId(name: string): string { - const time: string = stringify(new Date().getTime()); - let iteration: number = 0; - let id: string = name + time + stringify(iteration); - while (this._pending.has(id)) { - id = `${name}${time}${iteration}`; - iteration++; - } - return id; - } - - runOnService(args: UiArguments, returnType: Type|SerializerTypes|null): Promise|null { - const fnArgs: any[] = []; - if (args.args) { - args.args.forEach(argument => { - if (argument.type != null) { - fnArgs.push(this._serializer.serialize(argument.value, argument.type)); - } else { - fnArgs.push(argument.value); - } - }); - } - - let promise: Promise|null; - let id: string|null = null; - if (returnType != null) { - let completer: PromiseCompleter = undefined!; - promise = new Promise((resolve, reject) => { - completer = {resolve, reject}; - }); - id = this._generateMessageId(args.method); - this._pending.set(id, completer); - - promise.catch((err) => { - if (console && console.error) { - // tslint:disable-next-line:no-console - console.error(err); - } - - completer.reject(err); - }); - - promise = promise.then( - (v: any) => this._serializer ? this._serializer.deserialize(v, returnType) : v); - } else { - promise = null; - } - - const message: RequestMessageData = { - 'method': args.method, - 'args': fnArgs, - }; - if (id != null) { - message['id'] = id; - } - this._sink.emit(message); - - return promise; - } - - private _handleMessage(message: ResponseMessageData): void { - if (message.type === 'result' || message.type === 'error') { - const id = message.id!; - if (this._pending.has(id)) { - if (message.type === 'result') { - this._pending.get(id)!.resolve(message.value); - } else { - this._pending.get(id)!.reject(message.value); - } - this._pending.delete(id); - } - } - } -} - -interface RequestMessageData { - method: string; - args?: any[]; - id?: string; -} - -interface ResponseMessageData { - type: 'result'|'error'; - value?: any; - id?: string; -} - -/** - * @publicApi - * @deprecated platform-webworker is deprecated in Angular and will be removed in a future version - * of Angular - */ -export class FnArg { - constructor( - public value: any, public type: Type|SerializerTypes = SerializerTypes.PRIMITIVE) {} -} - -/** - * @publicApi - * @deprecated platform-webworker is deprecated in Angular and will be removed in a future version - * of Angular - */ -export class UiArguments { - constructor(public method: string, public args?: FnArg[]) {} -} diff --git a/packages/platform-webworker/src/web_workers/shared/message_bus.ts b/packages/platform-webworker/src/web_workers/shared/message_bus.ts deleted file mode 100644 index 4b864cceac..0000000000 --- a/packages/platform-webworker/src/web_workers/shared/message_bus.ts +++ /dev/null @@ -1,109 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -import {EventEmitter, NgZone} from '@angular/core'; - - - -/** - * Message Bus is a low level API used to communicate between the UI and the background. - * Communication is based on a channel abstraction. Messages published in a - * given channel to one MessageBusSink are received on the same channel - * by the corresponding MessageBusSource. - * - * @publicApi - * @deprecated platform-webworker is deprecated in Angular and will be removed in a future version - * of Angular - */ -export abstract class MessageBus implements MessageBusSource, MessageBusSink { - /** - * Sets up a new channel on the MessageBus. - * MUST be called before calling from or to on the channel. - * If runInZone is true then the source will emit events inside the angular zone - * and the sink will buffer messages and send only once the zone exits. - * if runInZone is false then the source will emit events inside the global zone - * and the sink will send messages immediately. - */ - abstract initChannel(channel: string, runInZone?: boolean): void; - - /** - * Assigns this bus to the given zone. - * Any callbacks attached to channels where runInZone was set to true on initialization - * will be executed in the given zone. - */ - abstract attachToZone(zone: NgZone): void; - - /** - * Returns an {@link EventEmitter} that emits every time a message - * is received on the given channel. - */ - abstract from(channel: string): EventEmitter; - - - /** - * Returns an {@link EventEmitter} for the given channel - * To publish methods to that channel just call next on the returned emitter - */ - abstract to(channel: string): EventEmitter; -} - -/** - * @publicApi - * @deprecated platform-webworker is deprecated in Angular and will be removed in a future version - * of Angular - */ -export interface MessageBusSource { - /** - * Sets up a new channel on the MessageBusSource. - * MUST be called before calling from on the channel. - * If runInZone is true then the source will emit events inside the angular zone. - * if runInZone is false then the source will emit events inside the global zone. - */ - initChannel(channel: string, runInZone: boolean): void; - - /** - * Assigns this source to the given zone. - * Any channels which are initialized with runInZone set to true will emit events that will be - * executed within the given zone. - */ - attachToZone(zone: NgZone): void; - - /** - * Returns an {@link EventEmitter} that emits every time a message - * is received on the given channel. - */ - from(channel: string): EventEmitter; -} - -/** - * @publicApi - * @deprecated platform-webworker is deprecated in Angular and will be removed in a future version - * of Angular - */ -export interface MessageBusSink { - /** - * Sets up a new channel on the MessageBusSink. - * MUST be called before calling to on the channel. - * If runInZone is true the sink will buffer messages and send only once the zone exits. - * if runInZone is false the sink will send messages immediately. - */ - initChannel(channel: string, runInZone: boolean): void; - - /** - * Assigns this sink to the given zone. - * Any channels which are initialized with runInZone set to true will wait for the given zone - * to exit before sending messages. - */ - attachToZone(zone: NgZone): void; - - /** - * Returns an {@link EventEmitter} for the given channel - * To publish methods to that channel just call next on the returned emitter - */ - to(channel: string): EventEmitter; -} diff --git a/packages/platform-webworker/src/web_workers/shared/messaging_api.ts b/packages/platform-webworker/src/web_workers/shared/messaging_api.ts deleted file mode 100644 index 7449657fc9..0000000000 --- a/packages/platform-webworker/src/web_workers/shared/messaging_api.ts +++ /dev/null @@ -1,16 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -/** - * All channels used by angular's WebWorker components are listed here. - * You should not use these channels in your application code. - */ -export const RENDERER_2_CHANNEL = 'v2.ng-Renderer'; -export const EVENT_2_CHANNEL = 'v2.ng-Events'; - -export const ROUTER_CHANNEL = 'ng-Router'; diff --git a/packages/platform-webworker/src/web_workers/shared/post_message_bus.ts b/packages/platform-webworker/src/web_workers/shared/post_message_bus.ts deleted file mode 100644 index f8465db492..0000000000 --- a/packages/platform-webworker/src/web_workers/shared/post_message_bus.ts +++ /dev/null @@ -1,169 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -import {EventEmitter, Injectable, NgZone} from '@angular/core'; - -import {MessageBus, MessageBusSink, MessageBusSource} from './message_bus'; - - - -// TODO(jteplitz602): Replace this with the definition in lib.webworker.d.ts(#3492) -export interface PostMessageTarget { - postMessage: (message: any, transfer?: [Transferable]) => void; -} - -export class PostMessageBusSink implements MessageBusSink { - // TODO(issue/24571): remove '!'. - private _zone!: NgZone; - private _channels: {[key: string]: _Channel} = {}; - private _messageBuffer: Array = []; - - constructor(private _postMessageTarget: PostMessageTarget) {} - - attachToZone(zone: NgZone): void { - this._zone = zone; - this._zone.runOutsideAngular(() => { - this._zone.onStable.subscribe({ - next: () => { - this._handleOnEventDone(); - } - }); - }); - } - - initChannel(channel: string, runInZone: boolean = true): void { - if (this._channels.hasOwnProperty(channel)) { - throw new Error(`${channel} has already been initialized`); - } - - const emitter = new EventEmitter(false); - const channelInfo = new _Channel(emitter, runInZone); - this._channels[channel] = channelInfo; - emitter.subscribe((data: Object) => { - const message = {channel: channel, message: data}; - if (runInZone) { - this._messageBuffer.push(message); - } else { - this._sendMessages([message]); - } - }); - } - - to(channel: string): EventEmitter { - if (this._channels.hasOwnProperty(channel)) { - return this._channels[channel].emitter; - } else { - throw new Error(`${channel} is not set up. Did you forget to call initChannel?`); - } - } - - private _handleOnEventDone() { - if (this._messageBuffer.length > 0) { - this._sendMessages(this._messageBuffer); - this._messageBuffer = []; - } - } - - private _sendMessages(messages: Array) { - this._postMessageTarget.postMessage(messages); - } -} - -export class PostMessageBusSource implements MessageBusSource { - // TODO(issue/24571): remove '!'. - private _zone!: NgZone; - private _channels: {[key: string]: _Channel} = {}; - - constructor(eventTarget?: EventTarget) { - if (eventTarget) { - eventTarget.addEventListener('message', (ev: MessageEvent) => this._handleMessages(ev)); - } else { - // if no eventTarget is given we assume we're in a WebWorker and listen on the global scope - const workerScope = self; - workerScope.addEventListener('message', (ev: MessageEvent) => this._handleMessages(ev)); - } - } - - attachToZone(zone: NgZone) { - this._zone = zone; - } - - initChannel(channel: string, runInZone: boolean = true) { - if (this._channels.hasOwnProperty(channel)) { - throw new Error(`${channel} has already been initialized`); - } - - const emitter = new EventEmitter(false); - const channelInfo = new _Channel(emitter, runInZone); - this._channels[channel] = channelInfo; - } - - from(channel: string): EventEmitter { - if (this._channels.hasOwnProperty(channel)) { - return this._channels[channel].emitter; - } else { - throw new Error(`${channel} is not set up. Did you forget to call initChannel?`); - } - } - - private _handleMessages(ev: MessageEvent): void { - const messages = ev.data; - for (let i = 0; i < messages.length; i++) { - this._handleMessage(messages[i]); - } - } - - private _handleMessage(data: any): void { - const channel = data.channel; - if (this._channels.hasOwnProperty(channel)) { - const channelInfo = this._channels[channel]; - if (channelInfo.runInZone) { - this._zone.run(() => { - channelInfo.emitter.emit(data.message); - }); - } else { - channelInfo.emitter.emit(data.message); - } - } - } -} - -/** - * A TypeScript implementation of {@link MessageBus} for communicating via JavaScript's - * postMessage API. - */ -@Injectable() -export class PostMessageBus implements MessageBus { - constructor(public sink: PostMessageBusSink, public source: PostMessageBusSource) {} - - attachToZone(zone: NgZone): void { - this.source.attachToZone(zone); - this.sink.attachToZone(zone); - } - - initChannel(channel: string, runInZone: boolean = true): void { - this.source.initChannel(channel, runInZone); - this.sink.initChannel(channel, runInZone); - } - - from(channel: string): EventEmitter { - return this.source.from(channel); - } - - to(channel: string): EventEmitter { - return this.sink.to(channel); - } -} - -/** - * Helper class that wraps a channel's {@link EventEmitter} and - * keeps track of if it should run in the zone. - */ -class _Channel { - constructor(public emitter: EventEmitter, public runInZone: boolean) {} -} diff --git a/packages/platform-webworker/src/web_workers/shared/render_store.ts b/packages/platform-webworker/src/web_workers/shared/render_store.ts deleted file mode 100644 index b4d77105f5..0000000000 --- a/packages/platform-webworker/src/web_workers/shared/render_store.ts +++ /dev/null @@ -1,42 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -import {Injectable} from '@angular/core'; - -@Injectable() -export class RenderStore { - private _nextIndex = 0; - private _lookupById = new Map(); - private _lookupByObject = new Map(); - - allocateId(): number { - return this._nextIndex++; - } - - store(obj: any, id: number): void { - if (id == null) return; - this._lookupById.set(id, obj); - this._lookupByObject.set(obj, id); - } - - remove(obj: any): void { - const index = this._lookupByObject.get(obj); - if (index != null) { - this._lookupByObject.delete(obj); - this._lookupById.delete(index); - } - } - - deserialize(id: number): any { - return this._lookupById.has(id) ? this._lookupById.get(id) : null; - } - - serialize(obj: any): number|null|undefined { - return obj == null ? null : this._lookupByObject.get(obj); - } -} diff --git a/packages/platform-webworker/src/web_workers/shared/serializer.ts b/packages/platform-webworker/src/web_workers/shared/serializer.ts deleted file mode 100644 index d460db3266..0000000000 --- a/packages/platform-webworker/src/web_workers/shared/serializer.ts +++ /dev/null @@ -1,114 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -import {Injectable, RendererType2, Type, ɵstringify as stringify} from '@angular/core'; -import {RenderStore} from './render_store'; - - -/** - * @publicApi - * @deprecated platform-webworker is deprecated in Angular and will be removed in a future version - * of Angular - */ -export const enum SerializerTypes { - // RendererType2 - RENDERER_TYPE_2, - // Primitive types - PRIMITIVE, - // An object stored in a RenderStore - RENDER_STORE_OBJECT, -} - -export class LocationType { - constructor( - public href: string, public protocol: string, public host: string, public hostname: string, - public port: string, public pathname: string|null, public search: string, public hash: string, - public origin: string) {} -} - -@Injectable() -export class Serializer { - constructor(private _renderStore: RenderStore) {} - - serialize(obj: any, type: Type|SerializerTypes = SerializerTypes.PRIMITIVE): Object { - if (obj == null || type === SerializerTypes.PRIMITIVE) { - return obj; - } - if (Array.isArray(obj)) { - return obj.map(v => this.serialize(v, type)); - } - if (type === SerializerTypes.RENDER_STORE_OBJECT) { - return this._renderStore.serialize(obj)!; - } - if (type === SerializerTypes.RENDERER_TYPE_2) { - return this._serializeRendererType2(obj); - } - if (type === LocationType) { - return this._serializeLocation(obj); - } - throw new Error(`No serializer for type ${stringify(type)}`); - } - - deserialize(map: any, type: Type|SerializerTypes = SerializerTypes.PRIMITIVE, data?: any): - any { - if (map == null || type === SerializerTypes.PRIMITIVE) { - return map; - } - if (Array.isArray(map)) { - return map.map(val => this.deserialize(val, type, data)); - } - if (type === SerializerTypes.RENDER_STORE_OBJECT) { - return this._renderStore.deserialize(map); - } - if (type === SerializerTypes.RENDERER_TYPE_2) { - return this._deserializeRendererType2(map); - } - if (type === LocationType) { - return this._deserializeLocation(map); - } - throw new Error(`No deserializer for type ${stringify(type)}`); - } - - private _serializeLocation(loc: LocationType): Object { - return { - 'href': loc.href, - 'protocol': loc.protocol, - 'host': loc.host, - 'hostname': loc.hostname, - 'port': loc.port, - 'pathname': loc.pathname, - 'search': loc.search, - 'hash': loc.hash, - 'origin': loc.origin, - }; - } - - private _deserializeLocation(loc: {[key: string]: any}): LocationType { - return new LocationType( - loc['href'], loc['protocol'], loc['host'], loc['hostname'], loc['port'], loc['pathname'], - loc['search'], loc['hash'], loc['origin']); - } - - private _serializeRendererType2(type: RendererType2): {[key: string]: any} { - return { - 'id': type.id, - 'encapsulation': this.serialize(type.encapsulation), - 'styles': this.serialize(type.styles), - 'data': this.serialize(type.data), - }; - } - - private _deserializeRendererType2(props: {[key: string]: any}): RendererType2 { - return { - id: props['id'], - encapsulation: props['encapsulation'], - styles: this.deserialize(props['styles']), - data: this.deserialize(props['data']) - }; - } -} diff --git a/packages/platform-webworker/src/web_workers/shared/service_message_broker.ts b/packages/platform-webworker/src/web_workers/shared/service_message_broker.ts deleted file mode 100644 index 2eafcf4e07..0000000000 --- a/packages/platform-webworker/src/web_workers/shared/service_message_broker.ts +++ /dev/null @@ -1,106 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -import {EventEmitter, Injectable, Type} from '@angular/core'; -import {MessageBus} from '../shared/message_bus'; -import {Serializer, SerializerTypes} from '../shared/serializer'; - - -/** - * @publicApi - * @deprecated platform-webworker is deprecated in Angular and will be removed in a future version - * of Angular - */ -@Injectable() -export class ServiceMessageBrokerFactory { - /** @internal */ - _serializer: Serializer; - - /** @internal */ - constructor(private _messageBus: MessageBus, _serializer: Serializer) { - this._serializer = _serializer; - } - - /** - * Initializes the given channel and attaches a new {@link ServiceMessageBroker} to it. - */ - createMessageBroker(channel: string, runInZone: boolean = true): ServiceMessageBroker { - this._messageBus.initChannel(channel, runInZone); - return new ServiceMessageBroker(this._messageBus, this._serializer, channel); - } -} - -/** - * Helper class for UIComponents that allows components to register methods. - * If a registered method message is received from the broker on the worker, - * the UIMessageBroker deserializes its arguments and calls the registered method. - * If that method returns a promise, the UIMessageBroker returns the result to the worker. - * - * @publicApi - * @deprecated platform-webworker is deprecated in Angular and will be removed in a future version - * of Angular - */ -export class ServiceMessageBroker { - private _sink: EventEmitter; - private _methods = new Map(); - - /** @internal */ - constructor(messageBus: MessageBus, private _serializer: Serializer, private channel: string) { - this._sink = messageBus.to(channel); - const source = messageBus.from(channel); - source.subscribe({next: (message: any) => this._handleMessage(message)}); - } - - registerMethod( - methodName: string, signature: Array|SerializerTypes>|null, - method: (..._: any[]) => Promise| void, returnType?: Type|SerializerTypes): void { - this._methods.set(methodName, (message: ReceivedMessage) => { - const serializedArgs = message.args; - const numArgs = signature ? signature.length : 0; - const deserializedArgs = []; - for (let i = 0; i < numArgs; i++) { - const serializedArg = serializedArgs[i]; - deserializedArgs[i] = this._serializer.deserialize(serializedArg, signature![i]); - } - - const promise = method(...deserializedArgs); - if (returnType && promise) { - this._wrapWebWorkerPromise(message.id, promise, returnType); - } - }); - } - - private _handleMessage(message: ReceivedMessage): void { - if (this._methods.has(message.method)) { - this._methods.get(message.method)!(message); - } - } - - private _wrapWebWorkerPromise(id: string, promise: Promise, type: Type|SerializerTypes): - void { - promise.then((result: any) => { - this._sink.emit({ - 'type': 'result', - 'value': this._serializer.serialize(result, type), - 'id': id, - }); - }); - } -} - -/** - * @publicApi - * @deprecated platform-webworker is deprecated in Angular and will be removed in a future version - * of Angular - */ -export interface ReceivedMessage { - method: string; - args: any[]; - id: string; - type: string; -} diff --git a/packages/platform-webworker/src/web_workers/ui/event_dispatcher.ts b/packages/platform-webworker/src/web_workers/ui/event_dispatcher.ts deleted file mode 100644 index 7e68a8ae92..0000000000 --- a/packages/platform-webworker/src/web_workers/ui/event_dispatcher.ts +++ /dev/null @@ -1,120 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ -import {EventEmitter} from '@angular/core'; -import {Serializer, SerializerTypes} from '../shared/serializer'; - -import {serializeEventWithTarget, serializeGenericEvent, serializeKeyboardEvent, serializeMouseEvent, serializeTransitionEvent} from './event_serializer'; - -export class EventDispatcher { - constructor(private _sink: EventEmitter, private _serializer: Serializer) {} - - dispatchAnimationEvent(player: any, phaseName: string, element: any): boolean { - this._sink.emit({ - 'element': this._serializer.serialize(element, SerializerTypes.RENDER_STORE_OBJECT), - 'animationPlayer': this._serializer.serialize(player, SerializerTypes.RENDER_STORE_OBJECT), - 'phaseName': phaseName, - }); - return true; - } - - dispatchRenderEvent(element: any, eventTarget: string, eventName: string, event: any): boolean { - let serializedEvent: any; - // TODO (jteplitz602): support custom events #3350 - switch (event.type) { - case 'click': - case 'mouseup': - case 'mousedown': - case 'dblclick': - case 'contextmenu': - case 'mouseenter': - case 'mouseleave': - case 'mousemove': - case 'mouseout': - case 'mouseover': - case 'show': - serializedEvent = serializeMouseEvent(event); - break; - case 'keydown': - case 'keypress': - case 'keyup': - serializedEvent = serializeKeyboardEvent(event); - break; - case 'input': - case 'change': - case 'blur': - serializedEvent = serializeEventWithTarget(event); - break; - case 'abort': - case 'afterprint': - case 'beforeprint': - case 'cached': - case 'canplay': - case 'canplaythrough': - case 'chargingchange': - case 'chargingtimechange': - case 'close': - case 'dischargingtimechange': - case 'DOMContentLoaded': - case 'downloading': - case 'durationchange': - case 'emptied': - case 'ended': - case 'error': - case 'fullscreenchange': - case 'fullscreenerror': - case 'invalid': - case 'languagechange': - case 'levelfchange': - case 'loadeddata': - case 'loadedmetadata': - case 'obsolete': - case 'offline': - case 'online': - case 'open': - case 'orientatoinchange': - case 'pause': - case 'pointerlockchange': - case 'pointerlockerror': - case 'play': - case 'playing': - case 'ratechange': - case 'readystatechange': - case 'reset': - case 'scroll': - case 'seeked': - case 'seeking': - case 'stalled': - case 'submit': - case 'success': - case 'suspend': - case 'timeupdate': - case 'updateready': - case 'visibilitychange': - case 'volumechange': - case 'waiting': - serializedEvent = serializeGenericEvent(event); - break; - case 'transitionend': - serializedEvent = serializeTransitionEvent(event); - break; - default: - throw new Error(eventName + ' not supported on WebWorkers'); - } - - this._sink.emit({ - 'element': this._serializer.serialize(element, SerializerTypes.RENDER_STORE_OBJECT), - 'eventName': eventName, - 'eventTarget': eventTarget, - 'event': serializedEvent, - }); - - // TODO(kegluneq): Eventually, we want the user to indicate from the UI side whether the event - // should be canceled, but for now just call `preventDefault` on the original DOM event. - return false; - } -} diff --git a/packages/platform-webworker/src/web_workers/ui/event_serializer.ts b/packages/platform-webworker/src/web_workers/ui/event_serializer.ts deleted file mode 100644 index 74bb03944d..0000000000 --- a/packages/platform-webworker/src/web_workers/ui/event_serializer.ts +++ /dev/null @@ -1,70 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -const MOUSE_EVENT_PROPERTIES = [ - 'altKey', 'button', 'clientX', 'clientY', 'metaKey', 'movementX', 'movementY', 'offsetX', - 'offsetY', 'region', 'screenX', 'screenY', 'shiftKey' -]; - -const KEYBOARD_EVENT_PROPERTIES = [ - 'altkey', 'charCode', 'code', 'ctrlKey', 'isComposing', 'key', 'keyCode', 'location', 'metaKey', - 'repeat', 'shiftKey', 'which' -]; - -const TRANSITION_EVENT_PROPERTIES = ['propertyName', 'elapsedTime', 'pseudoElement']; - -const EVENT_PROPERTIES = ['type', 'bubbles', 'cancelable']; - -const NODES_WITH_VALUE = new Set( - ['input', 'select', 'option', 'button', 'li', 'meter', 'progress', 'param', 'textarea']); - -export function serializeGenericEvent(e: Event): {[key: string]: any} { - return serializeEvent(e, EVENT_PROPERTIES); -} - -// TODO(jteplitz602): Allow users to specify the properties they need rather than always -// adding value and files #3374 -export function serializeEventWithTarget(e: Event): {[key: string]: any} { - const serializedEvent = serializeEvent(e, EVENT_PROPERTIES); - return addTarget(e, serializedEvent); -} - -export function serializeMouseEvent(e: MouseEvent): {[key: string]: any} { - return serializeEvent(e, MOUSE_EVENT_PROPERTIES); -} - -export function serializeKeyboardEvent(e: KeyboardEvent): {[key: string]: any} { - const serializedEvent = serializeEvent(e, KEYBOARD_EVENT_PROPERTIES); - return addTarget(e, serializedEvent); -} - -export function serializeTransitionEvent(e: TransitionEvent): {[key: string]: any} { - const serializedEvent = serializeEvent(e, TRANSITION_EVENT_PROPERTIES); - return addTarget(e, serializedEvent); -} - -// TODO(jteplitz602): #3374. See above. -function addTarget(e: Event, serializedEvent: {[key: string]: any}): {[key: string]: any} { - if (NODES_WITH_VALUE.has((e.target).tagName.toLowerCase())) { - const target = e.target; - serializedEvent['target'] = {'value': target.value}; - if (target.files) { - serializedEvent['target']['files'] = target.files; - } - } - return serializedEvent; -} - -function serializeEvent(e: any, properties: string[]): {[key: string]: any} { - const serialized: {[k: string]: any} = {}; - for (let i = 0; i < properties.length; i++) { - const prop = properties[i]; - serialized[prop] = e[prop]; - } - return serialized; -} diff --git a/packages/platform-webworker/src/web_workers/ui/location_providers.ts b/packages/platform-webworker/src/web_workers/ui/location_providers.ts deleted file mode 100644 index f3e41e1dd5..0000000000 --- a/packages/platform-webworker/src/web_workers/ui/location_providers.ts +++ /dev/null @@ -1,42 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -import {DOCUMENT, ɵBrowserPlatformLocation as BrowserPlatformLocation} from '@angular/common'; -import {Injector, NgZone, PLATFORM_INITIALIZER, StaticProvider} from '@angular/core'; - -import {MessageBus} from '../shared/message_bus'; -import {Serializer} from '../shared/serializer'; -import {ServiceMessageBrokerFactory} from '../shared/service_message_broker'; - -import {MessageBasedPlatformLocation} from './platform_location'; - - - -/** - * A list of {@link Provider}s. To use the router in a Worker enabled application you must - * include these providers when setting up the render thread. - * @publicApi - * @deprecated platform-webworker is deprecated in Angular and will be removed in a future version - * of Angular - */ -export const WORKER_UI_LOCATION_PROVIDERS = [ - { - provide: MessageBasedPlatformLocation, - deps: [ServiceMessageBrokerFactory, BrowserPlatformLocation, MessageBus, Serializer] - }, - {provide: BrowserPlatformLocation, deps: [DOCUMENT]}, - {provide: PLATFORM_INITIALIZER, useFactory: initUiLocation, multi: true, deps: [Injector]} -]; - -function initUiLocation(injector: Injector): () => void { - return () => { - const zone = injector.get(NgZone); - - zone.runGuarded(() => injector.get(MessageBasedPlatformLocation).start()); - }; -} diff --git a/packages/platform-webworker/src/web_workers/ui/platform_location.ts b/packages/platform-webworker/src/web_workers/ui/platform_location.ts deleted file mode 100644 index 07d9eb6041..0000000000 --- a/packages/platform-webworker/src/web_workers/ui/platform_location.ts +++ /dev/null @@ -1,62 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -import {LocationChangeListener, ɵBrowserPlatformLocation as BrowserPlatformLocation} from '@angular/common'; -import {EventEmitter, Injectable} from '@angular/core'; -import {MessageBus} from '../shared/message_bus'; -import {ROUTER_CHANNEL} from '../shared/messaging_api'; -import {LocationType, Serializer, SerializerTypes} from '../shared/serializer'; -import {ServiceMessageBroker, ServiceMessageBrokerFactory} from '../shared/service_message_broker'; - -@Injectable() -export class MessageBasedPlatformLocation { - private _channelSink: EventEmitter; - private _broker: ServiceMessageBroker; - - constructor( - private _brokerFactory: ServiceMessageBrokerFactory, - private _platformLocation: BrowserPlatformLocation, bus: MessageBus, - private _serializer: Serializer) { - this._platformLocation.onPopState(this._sendUrlChangeEvent.bind(this)); - this._platformLocation.onHashChange( - this._sendUrlChangeEvent.bind(this)); - this._broker = this._brokerFactory.createMessageBroker(ROUTER_CHANNEL); - this._channelSink = bus.to(ROUTER_CHANNEL); - } - - start(): void { - const P = SerializerTypes.PRIMITIVE; - - this._broker.registerMethod('getLocation', null, this._getLocation.bind(this), LocationType); - this._broker.registerMethod('setPathname', [P], this._setPathname.bind(this)); - this._broker.registerMethod( - 'pushState', [P, P, P], this._platformLocation.pushState.bind(this._platformLocation)); - this._broker.registerMethod( - 'replaceState', [P, P, P], - this._platformLocation.replaceState.bind(this._platformLocation)); - this._broker.registerMethod( - 'forward', null, this._platformLocation.forward.bind(this._platformLocation)); - this._broker.registerMethod( - 'back', null, this._platformLocation.back.bind(this._platformLocation)); - } - - private _getLocation(): Promise { - return Promise.resolve(this._platformLocation.location); - } - - private _sendUrlChangeEvent(e: Event): void { - this._channelSink.emit({ - 'event': {'type': e.type}, - 'location': this._serializer.serialize(this._platformLocation.location, LocationType), - }); - } - - private _setPathname(pathname: string): void { - this._platformLocation.pathname = pathname; - } -} diff --git a/packages/platform-webworker/src/web_workers/ui/renderer.ts b/packages/platform-webworker/src/web_workers/ui/renderer.ts deleted file mode 100644 index 9dd7870e05..0000000000 --- a/packages/platform-webworker/src/web_workers/ui/renderer.ts +++ /dev/null @@ -1,166 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -import {Injectable, Renderer2, RendererFactory2, RendererStyleFlags2, RendererType2} from '@angular/core'; - -import {MessageBus} from '../shared/message_bus'; -import {EVENT_2_CHANNEL, RENDERER_2_CHANNEL} from '../shared/messaging_api'; -import {RenderStore} from '../shared/render_store'; -import {Serializer, SerializerTypes} from '../shared/serializer'; -import {ServiceMessageBroker, ServiceMessageBrokerFactory} from '../shared/service_message_broker'; -import {EventDispatcher} from '../ui/event_dispatcher'; - -@Injectable() -export class MessageBasedRenderer2 { - // TODO(issue/24571): remove '!'. - private _eventDispatcher!: EventDispatcher; - - constructor( - private _brokerFactory: ServiceMessageBrokerFactory, private _bus: MessageBus, - private _serializer: Serializer, private _renderStore: RenderStore, - private _rendererFactory: RendererFactory2) {} - - start(): void { - const broker = this._brokerFactory.createMessageBroker(RENDERER_2_CHANNEL); - - this._bus.initChannel(EVENT_2_CHANNEL); - this._eventDispatcher = new EventDispatcher(this._bus.to(EVENT_2_CHANNEL), this._serializer); - - const [RSO, P, CRT] = [ - SerializerTypes.RENDER_STORE_OBJECT, - SerializerTypes.PRIMITIVE, - SerializerTypes.RENDERER_TYPE_2, - ]; - - const methods: any[][] = [ - ['createRenderer', this.createRenderer, RSO, CRT, P], - ['createElement', this.createElement, RSO, P, P, P], - ['createComment', this.createComment, RSO, P, P], - ['createText', this.createText, RSO, P, P], - ['appendChild', this.appendChild, RSO, RSO, RSO], - ['insertBefore', this.insertBefore, RSO, RSO, RSO, RSO], - ['removeChild', this.removeChild, RSO, RSO, RSO], - ['selectRootElement', this.selectRootElement, RSO, P, P], - ['parentNode', this.parentNode, RSO, RSO, P], - ['nextSibling', this.nextSibling, RSO, RSO, P], - ['setAttribute', this.setAttribute, RSO, RSO, P, P, P], - ['removeAttribute', this.removeAttribute, RSO, RSO, P, P], - ['addClass', this.addClass, RSO, RSO, P], - ['removeClass', this.removeClass, RSO, RSO, P], - ['setStyle', this.setStyle, RSO, RSO, P, P, P], - ['removeStyle', this.removeStyle, RSO, RSO, P, P], - ['setProperty', this.setProperty, RSO, RSO, P, P], - ['setValue', this.setValue, RSO, RSO, P], - ['listen', this.listen, RSO, RSO, P, P, P], - ['unlisten', this.unlisten, RSO, RSO], - ['destroy', this.destroy, RSO], - ['destroyNode', this.destroyNode, RSO, P] - - ]; - - methods.forEach(([name, method, ...argTypes]: any[]) => { - broker.registerMethod(name, argTypes, method.bind(this)); - }); - } - - private destroy(r: Renderer2) { - r.destroy(); - } - - private destroyNode(r: Renderer2, node: any) { - if (r.destroyNode) { - r.destroyNode(node); - } - this._renderStore.remove(node); - } - - private createRenderer(el: any, type: RendererType2, id: number) { - this._renderStore.store(this._rendererFactory.createRenderer(el, type), id); - } - - private createElement(r: Renderer2, name: string, namespace: string, id: number) { - this._renderStore.store(r.createElement(name, namespace), id); - } - - private createComment(r: Renderer2, value: string, id: number) { - this._renderStore.store(r.createComment(value), id); - } - - private createText(r: Renderer2, value: string, id: number) { - this._renderStore.store(r.createText(value), id); - } - - private appendChild(r: Renderer2, parent: any, child: any) { - r.appendChild(parent, child); - } - - private insertBefore(r: Renderer2, parent: any, child: any, ref: any) { - r.insertBefore(parent, child, ref); - } - - private removeChild(r: Renderer2, parent: any, child: any) { - r.removeChild(parent, child); - } - - private selectRootElement(r: Renderer2, selector: string, id: number) { - this._renderStore.store(r.selectRootElement(selector), id); - } - - private parentNode(r: Renderer2, node: any, id: number) { - this._renderStore.store(r.parentNode(node), id); - } - - private nextSibling(r: Renderer2, node: any, id: number) { - this._renderStore.store(r.nextSibling(node), id); - } - - private setAttribute(r: Renderer2, el: any, name: string, value: string, namespace: string) { - r.setAttribute(el, name, value, namespace); - } - - private removeAttribute(r: Renderer2, el: any, name: string, namespace: string) { - r.removeAttribute(el, name, namespace); - } - - private addClass(r: Renderer2, el: any, name: string) { - r.addClass(el, name); - } - - private removeClass(r: Renderer2, el: any, name: string) { - r.removeClass(el, name); - } - - private setStyle(r: Renderer2, el: any, style: string, value: any, flags: RendererStyleFlags2) { - r.setStyle(el, style, value, flags); - } - - private removeStyle(r: Renderer2, el: any, style: string, flags: RendererStyleFlags2) { - r.removeStyle(el, style, flags); - } - - private setProperty(r: Renderer2, el: any, name: string, value: any) { - r.setProperty(el, name, value); - } - - private setValue(r: Renderer2, node: any, value: string) { - r.setValue(node, value); - } - - private listen(r: Renderer2, el: any, elName: string, eventName: string, unlistenId: number) { - const listener = (event: any) => { - return this._eventDispatcher.dispatchRenderEvent(el, elName, eventName, event); - }; - - const unlisten = r.listen(el || elName, eventName, listener); - this._renderStore.store(unlisten, unlistenId); - } - - private unlisten(r: Renderer2, unlisten: () => boolean) { - unlisten(); - } -} diff --git a/packages/platform-webworker/src/web_workers/worker/location_providers.ts b/packages/platform-webworker/src/web_workers/worker/location_providers.ts deleted file mode 100644 index 0002fe067a..0000000000 --- a/packages/platform-webworker/src/web_workers/worker/location_providers.ts +++ /dev/null @@ -1,40 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -import {LOCATION_INITIALIZED, PlatformLocation} from '@angular/common'; -import {APP_INITIALIZER, NgZone, StaticProvider} from '@angular/core'; - -import {WebWorkerPlatformLocation} from './platform_location'; - - -/** - * The {@link PlatformLocation} providers that should be added when the {@link Location} is used in - * a worker context. - * - * @publicApi - * @deprecated platform-webworker is deprecated in Angular and will be removed in a future version - * of Angular - */ -export const WORKER_APP_LOCATION_PROVIDERS: StaticProvider[] = [ - {provide: PlatformLocation, useClass: WebWorkerPlatformLocation} as any as StaticProvider, { - provide: APP_INITIALIZER, - useFactory: appInitFnFactory, - multi: true, - deps: [PlatformLocation, NgZone] - }, - {provide: LOCATION_INITIALIZED, useFactory: locationInitialized, deps: [PlatformLocation]} -]; - -export function locationInitialized(platformLocation: WebWorkerPlatformLocation) { - return platformLocation.initialized; -} - -export function appInitFnFactory(platformLocation: WebWorkerPlatformLocation, zone: NgZone): () => - Promise { - return () => zone.runGuarded(() => platformLocation.init()); -} diff --git a/packages/platform-webworker/src/web_workers/worker/platform_location.ts b/packages/platform-webworker/src/web_workers/worker/platform_location.ts deleted file mode 100644 index 89ea3efcea..0000000000 --- a/packages/platform-webworker/src/web_workers/worker/platform_location.ts +++ /dev/null @@ -1,153 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -import {LocationChangeListener, PlatformLocation} from '@angular/common'; -import {EventEmitter, Injectable} from '@angular/core'; -import {ClientMessageBroker, ClientMessageBrokerFactory, FnArg, UiArguments} from '../shared/client_message_broker'; -import {MessageBus} from '../shared/message_bus'; -import {ROUTER_CHANNEL} from '../shared/messaging_api'; -import {LocationType, Serializer, SerializerTypes} from '../shared/serializer'; - -@Injectable() -export class WebWorkerPlatformLocation extends PlatformLocation { - private _broker: ClientMessageBroker; - private _popStateListeners: Array = []; - private _hashChangeListeners: Array = []; - private _location: LocationType = null!; - private _channelSource: EventEmitter; - public initialized: Promise; - // TODO(issue/24571): remove '!'. - private initializedResolve!: () => void; - - constructor( - brokerFactory: ClientMessageBrokerFactory, bus: MessageBus, private _serializer: Serializer) { - super(); - this._broker = brokerFactory.createMessageBroker(ROUTER_CHANNEL); - this._channelSource = bus.from(ROUTER_CHANNEL); - - this._channelSource.subscribe({ - next: (msg: {[key: string]: any}) => { - let listeners: Array|null = null; - if (msg.hasOwnProperty('event')) { - const type: string = msg['event']['type']; - if (type === 'popstate') { - listeners = this._popStateListeners; - } else if (type === 'hashchange') { - listeners = this._hashChangeListeners; - } - - if (listeners) { - // There was a popState or hashChange event, so the location object thas been updated - this._location = this._serializer.deserialize(msg['location'], LocationType); - listeners.forEach((fn: Function) => fn(msg['event'])); - } - } - } - }); - this.initialized = new Promise(res => this.initializedResolve = res); - } - - /** @internal **/ - init(): Promise { - const args: UiArguments = new UiArguments('getLocation'); - - return this._broker.runOnService(args, LocationType)!.then( - (val: LocationType) => { - this._location = val; - this.initializedResolve(); - return true; - }, - err => { - throw new Error(err); - }); - } - - getBaseHrefFromDOM(): string { - throw new Error( - 'Attempt to get base href from DOM from WebWorker. You must either provide a value for the APP_BASE_HREF token through DI or use the hash location strategy.'); - } - - onPopState(fn: LocationChangeListener): void { - this._popStateListeners.push(fn); - } - - onHashChange(fn: LocationChangeListener): void { - this._hashChangeListeners.push(fn); - } - - get href(): string { - return this._location ? this._location.href! : ''; - } - - get hostname(): string { - return this._location ? this._location.host! : ''; - } - - get port(): string { - return this._location ? this._location.port! : ''; - } - - get protocol(): string { - return this._location ? this._location.protocol! : ''; - } - - get search(): string { - return this._location ? this._location.search : ''; - } - - get hash(): string { - return this._location ? this._location.hash : ''; - } - - set pathname(newPath: string) { - if (this._location === null) { - throw new Error('Attempt to set pathname before value is obtained from UI'); - } - - this._location.pathname = newPath; - - const fnArgs = [new FnArg(newPath, SerializerTypes.PRIMITIVE)]; - const args = new UiArguments('setPathname', fnArgs); - this._broker.runOnService(args, null); - } - - pushState(state: any, title: string, url: string): void { - const fnArgs = [ - new FnArg(state, SerializerTypes.PRIMITIVE), - new FnArg(title, SerializerTypes.PRIMITIVE), - new FnArg(url, SerializerTypes.PRIMITIVE), - ]; - const args = new UiArguments('pushState', fnArgs); - this._broker.runOnService(args, null); - } - - replaceState(state: any, title: string, url: string): void { - const fnArgs = [ - new FnArg(state, SerializerTypes.PRIMITIVE), - new FnArg(title, SerializerTypes.PRIMITIVE), - new FnArg(url, SerializerTypes.PRIMITIVE), - ]; - const args = new UiArguments('replaceState', fnArgs); - this._broker.runOnService(args, null); - } - - forward(): void { - const args = new UiArguments('forward'); - this._broker.runOnService(args, null); - } - - back(): void { - const args = new UiArguments('back'); - this._broker.runOnService(args, null); - } - - // History API isn't available on WebWorkers, therefore return undefined - getState(): unknown { - return undefined; - } -} diff --git a/packages/platform-webworker/src/web_workers/worker/renderer.ts b/packages/platform-webworker/src/web_workers/worker/renderer.ts deleted file mode 100644 index e95ae57304..0000000000 --- a/packages/platform-webworker/src/web_workers/worker/renderer.ts +++ /dev/null @@ -1,327 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -import {Injectable, Renderer2, RendererFactory2, RendererStyleFlags2, RendererType2} from '@angular/core'; - -import {ClientMessageBroker, ClientMessageBrokerFactory, FnArg, UiArguments} from '../shared/client_message_broker'; -import {MessageBus} from '../shared/message_bus'; -import {EVENT_2_CHANNEL, RENDERER_2_CHANNEL} from '../shared/messaging_api'; -import {RenderStore} from '../shared/render_store'; -import {Serializer, SerializerTypes} from '../shared/serializer'; - -export class NamedEventEmitter { - // TODO(issue/24571): remove '!'. - private _listeners!: Map; - - listen(eventName: string, callback: Function) { - this._getListeners(eventName).push(callback); - } - - unlisten(eventName: string, listener: Function) { - const listeners = this._getListeners(eventName); - const index = listeners.indexOf(listener); - if (index > -1) { - listeners.splice(index, 1); - } - } - - dispatchEvent(eventName: string, event: any) { - const listeners = this._getListeners(eventName); - for (let i = 0; i < listeners.length; i++) { - listeners[i](event); - } - } - - private _getListeners(eventName: string): Function[] { - if (!this._listeners) { - this._listeners = new Map(); - } - let listeners = this._listeners.get(eventName); - if (!listeners) { - listeners = []; - this._listeners.set(eventName, listeners); - } - return listeners; - } -} - - -function eventNameWithTarget(target: string, eventName: string): string { - return `${target}:${eventName}`; -} - -@Injectable() -export class WebWorkerRendererFactory2 implements RendererFactory2 { - globalEvents = new NamedEventEmitter(); - - private _messageBroker: ClientMessageBroker; - - constructor( - messageBrokerFactory: ClientMessageBrokerFactory, bus: MessageBus, - private _serializer: Serializer, public renderStore: RenderStore) { - this._messageBroker = messageBrokerFactory.createMessageBroker(RENDERER_2_CHANNEL); - bus.initChannel(EVENT_2_CHANNEL); - const source = bus.from(EVENT_2_CHANNEL); - source.subscribe({next: (message: any) => this._dispatchEvent(message)}); - } - - createRenderer(element: any, type: RendererType2|null): Renderer2 { - const renderer = new WebWorkerRenderer2(this); - - const id = this.renderStore.allocateId(); - this.renderStore.store(renderer, id); - this.callUI('createRenderer', [ - new FnArg(element, SerializerTypes.RENDER_STORE_OBJECT), - new FnArg(type, SerializerTypes.RENDERER_TYPE_2), - new FnArg(renderer, SerializerTypes.RENDER_STORE_OBJECT), - ]); - - return renderer; - } - - begin() {} - end() {} - - callUI(fnName: string, fnArgs: FnArg[]) { - const args = new UiArguments(fnName, fnArgs); - this._messageBroker.runOnService(args, null); - } - - allocateNode(): WebWorkerRenderNode { - const result = new WebWorkerRenderNode(); - const id = this.renderStore.allocateId(); - this.renderStore.store(result, id); - return result; - } - - freeNode(node: any) { - this.renderStore.remove(node); - } - - allocateId(): number { - return this.renderStore.allocateId(); - } - - private _dispatchEvent(message: {[key: string]: any}): void { - const element: WebWorkerRenderNode = - this._serializer.deserialize(message['element'], SerializerTypes.RENDER_STORE_OBJECT); - - const eventName = message['eventName']; - const target = message['eventTarget']; - const event = message['event']; - - if (target) { - this.globalEvents.dispatchEvent(eventNameWithTarget(target, eventName), event); - } else { - element.events.dispatchEvent(eventName, event); - } - } -} - - -export class WebWorkerRenderer2 implements Renderer2 { - data: {[key: string]: any} = Object.create(null); - - constructor(private _rendererFactory: WebWorkerRendererFactory2) {} - - private asFnArg = new FnArg(this, SerializerTypes.RENDER_STORE_OBJECT); - - destroy(): void { - this.callUIWithRenderer('destroy'); - } - - destroyNode(node: any) { - this.callUIWithRenderer('destroyNode', [new FnArg(node, SerializerTypes.RENDER_STORE_OBJECT)]); - this._rendererFactory.freeNode(node); - } - - createElement(name: string, namespace?: string): any { - const node = this._rendererFactory.allocateNode(); - this.callUIWithRenderer('createElement', [ - new FnArg(name), - new FnArg(namespace), - new FnArg(node, SerializerTypes.RENDER_STORE_OBJECT), - ]); - return node; - } - - createComment(value: string): any { - const node = this._rendererFactory.allocateNode(); - this.callUIWithRenderer('createComment', [ - new FnArg(value), - new FnArg(node, SerializerTypes.RENDER_STORE_OBJECT), - ]); - return node; - } - - createText(value: string): any { - const node = this._rendererFactory.allocateNode(); - this.callUIWithRenderer('createText', [ - new FnArg(value), - new FnArg(node, SerializerTypes.RENDER_STORE_OBJECT), - ]); - return node; - } - - appendChild(parent: any, newChild: any): void { - this.callUIWithRenderer('appendChild', [ - new FnArg(parent, SerializerTypes.RENDER_STORE_OBJECT), - new FnArg(newChild, SerializerTypes.RENDER_STORE_OBJECT), - ]); - } - - insertBefore(parent: any, newChild: any, refChild: any): void { - if (!parent) { - return; - } - - this.callUIWithRenderer('insertBefore', [ - new FnArg(parent, SerializerTypes.RENDER_STORE_OBJECT), - new FnArg(newChild, SerializerTypes.RENDER_STORE_OBJECT), - new FnArg(refChild, SerializerTypes.RENDER_STORE_OBJECT), - ]); - } - - removeChild(parent: any, oldChild: any): void { - this.callUIWithRenderer('removeChild', [ - new FnArg(parent, SerializerTypes.RENDER_STORE_OBJECT), - new FnArg(oldChild, SerializerTypes.RENDER_STORE_OBJECT), - ]); - } - - selectRootElement(selectorOrNode: string|any): any { - const node = this._rendererFactory.allocateNode(); - this.callUIWithRenderer('selectRootElement', [ - new FnArg(selectorOrNode), - new FnArg(node, SerializerTypes.RENDER_STORE_OBJECT), - ]); - return node; - } - - parentNode(node: any): any { - const res = this._rendererFactory.allocateNode(); - this.callUIWithRenderer('parentNode', [ - new FnArg(node, SerializerTypes.RENDER_STORE_OBJECT), - new FnArg(res, SerializerTypes.RENDER_STORE_OBJECT), - ]); - return res; - } - - nextSibling(node: any): any { - const res = this._rendererFactory.allocateNode(); - this.callUIWithRenderer('nextSibling', [ - new FnArg(node, SerializerTypes.RENDER_STORE_OBJECT), - new FnArg(res, SerializerTypes.RENDER_STORE_OBJECT), - ]); - return res; - } - - setAttribute(el: any, name: string, value: string, namespace?: string): void { - this.callUIWithRenderer('setAttribute', [ - new FnArg(el, SerializerTypes.RENDER_STORE_OBJECT), - new FnArg(name), - new FnArg(value), - new FnArg(namespace), - ]); - } - - removeAttribute(el: any, name: string, namespace?: string): void { - this.callUIWithRenderer('removeAttribute', [ - new FnArg(el, SerializerTypes.RENDER_STORE_OBJECT), - new FnArg(name), - new FnArg(namespace), - ]); - } - - addClass(el: any, name: string): void { - this.callUIWithRenderer('addClass', [ - new FnArg(el, SerializerTypes.RENDER_STORE_OBJECT), - new FnArg(name), - ]); - } - - removeClass(el: any, name: string): void { - this.callUIWithRenderer('removeClass', [ - new FnArg(el, SerializerTypes.RENDER_STORE_OBJECT), - new FnArg(name), - ]); - } - - setStyle(el: any, style: string, value: any, flags: RendererStyleFlags2): void { - this.callUIWithRenderer('setStyle', [ - new FnArg(el, SerializerTypes.RENDER_STORE_OBJECT), - new FnArg(style), - new FnArg(value), - new FnArg(flags), - ]); - } - - removeStyle(el: any, style: string, flags: RendererStyleFlags2): void { - this.callUIWithRenderer('removeStyle', [ - new FnArg(el, SerializerTypes.RENDER_STORE_OBJECT), - new FnArg(style), - new FnArg(flags), - ]); - } - - setProperty(el: any, name: string, value: any): void { - this.callUIWithRenderer('setProperty', [ - new FnArg(el, SerializerTypes.RENDER_STORE_OBJECT), - new FnArg(name), - new FnArg(value), - ]); - } - - setValue(node: any, value: string): void { - this.callUIWithRenderer('setValue', [ - new FnArg(node, SerializerTypes.RENDER_STORE_OBJECT), - new FnArg(value), - ]); - } - - listen( - target: 'window'|'document'|'body'|any, eventName: string, - listener: (event: any) => boolean): () => void { - const unlistenId = this._rendererFactory.allocateId(); - - const [targetEl, targetName, fullName]: [any, string|null, string|null] = - typeof target === 'string' ? [null, target, `${target}:${eventName}`] : - [target, null, null]; - - if (fullName) { - this._rendererFactory.globalEvents.listen(fullName, listener); - } else { - targetEl.events.listen(eventName, listener); - } - - this.callUIWithRenderer('listen', [ - new FnArg(targetEl, SerializerTypes.RENDER_STORE_OBJECT), - new FnArg(targetName), - new FnArg(eventName), - new FnArg(unlistenId), - ]); - - return () => { - if (fullName) { - this._rendererFactory.globalEvents.unlisten(fullName, listener); - } else { - targetEl.events.unlisten(eventName, listener); - } - this.callUIWithRenderer('unlisten', [new FnArg(unlistenId)]); - }; - } - - private callUIWithRenderer(fnName: string, fnArgs: FnArg[] = []) { - // always pass the renderer as the first arg - this._rendererFactory.callUI(fnName, [this.asFnArg, ...fnArgs]); - } -} - -export class WebWorkerRenderNode { - events = new NamedEventEmitter(); -} diff --git a/packages/platform-webworker/src/web_workers/worker/worker_adapter.ts b/packages/platform-webworker/src/web_workers/worker/worker_adapter.ts deleted file mode 100644 index f864110dc5..0000000000 --- a/packages/platform-webworker/src/web_workers/worker/worker_adapter.ts +++ /dev/null @@ -1,106 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -import {ɵDomAdapter as DomAdapter, ɵsetRootDomAdapter as setRootDomAdapter} from '@angular/common'; - -/** - * This adapter is required to log error messages. - * - * Note: other methods all throw as the DOM is not accessible directly in web worker context. - */ -export class WorkerDomAdapter extends DomAdapter { - static makeCurrent() { - setRootDomAdapter(new WorkerDomAdapter()); - } - - log(error: any) { - // tslint:disable-next-line:no-console - console.log(error); - } - - logGroup(error: any) { - if (console.group) { - console.group(error); - if (console.error) { - console.error(error); - } else { - // tslint:disable-next-line:no-console - console.log(error); - } - } else { - // tslint:disable-next-line:no-console - console.log(error); - } - } - - logGroupEnd() { - if (console.groupEnd) { - console.groupEnd(); - } - } - - getProperty(el: Element, name: string): any { - throw 'not implemented'; - } - - onAndCancel(el: any, evt: any, listener: any): Function { - throw 'not implemented'; - } - dispatchEvent(el: any, evt: any) { - throw 'not implemented'; - } - remove(el: any): Node { - throw 'not implemented'; - } - createElement(tagName: any, doc?: any): HTMLElement { - throw 'not implemented'; - } - createHtmlDocument(): HTMLDocument { - throw 'not implemented'; - } - getDefaultDocument(): Document { - throw 'not implemented'; - } - isElementNode(node: any): boolean { - throw 'not implemented'; - } - isShadowRoot(node: any): boolean { - throw 'not implemented'; - } - supportsDOMEvents(): boolean { - throw 'not implemented'; - } - getGlobalEventTarget(doc: Document, target: string): any { - throw 'not implemented'; - } - getHistory(): History { - throw 'not implemented'; - } - getLocation(): Location { - throw 'not implemented'; - } - getBaseHref(doc: Document): string { - throw 'not implemented'; - } - resetBaseElement(): void { - throw 'not implemented'; - } - getUserAgent(): string { - return 'Fake user agent'; - } - performanceNow(): number { - throw 'not implemented'; - } - - supportsCookies(): boolean { - return false; - } - getCookie(name: string): string { - throw 'not implemented'; - } -} diff --git a/packages/platform-webworker/src/worker_app.ts b/packages/platform-webworker/src/worker_app.ts deleted file mode 100644 index b913c915d2..0000000000 --- a/packages/platform-webworker/src/worker_app.ts +++ /dev/null @@ -1,86 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -import {CommonModule, DOCUMENT, ViewportScroller, ɵNullViewportScroller as NullViewportScroller, ɵPLATFORM_WORKER_APP_ID as PLATFORM_WORKER_APP_ID} from '@angular/common'; -import {APP_INITIALIZER, ApplicationModule, createPlatformFactory, ErrorHandler, NgModule, NgZone, PLATFORM_ID, platformCore, PlatformRef, RendererFactory2, StaticProvider, ɵINJECTOR_SCOPE as INJECTOR_SCOPE} from '@angular/core'; -import {ɵBROWSER_SANITIZATION_PROVIDERS as BROWSER_SANITIZATION_PROVIDERS} from '@angular/platform-browser'; - -import {ON_WEB_WORKER} from './web_workers/shared/api'; -import {ClientMessageBrokerFactory} from './web_workers/shared/client_message_broker'; -import {MessageBus} from './web_workers/shared/message_bus'; -import {PostMessageBus, PostMessageBusSink, PostMessageBusSource} from './web_workers/shared/post_message_bus'; -import {RenderStore} from './web_workers/shared/render_store'; -import {Serializer} from './web_workers/shared/serializer'; -import {ServiceMessageBrokerFactory} from './web_workers/shared/service_message_broker'; -import {WebWorkerRendererFactory2} from './web_workers/worker/renderer'; -import {WorkerDomAdapter} from './web_workers/worker/worker_adapter'; - -/** - * @publicApi - * @deprecated platform-webworker is deprecated in Angular and will be removed in a future version - * of Angular - */ -export const platformWorkerApp: (extraProviders?: StaticProvider[]|undefined) => PlatformRef = - createPlatformFactory( - platformCore, 'workerApp', [{provide: PLATFORM_ID, useValue: PLATFORM_WORKER_APP_ID}]); - -export function errorHandler(): ErrorHandler { - return new ErrorHandler(); -} - - -// TODO(jteplitz602): remove this and compile with lib.webworker.d.ts (#3492) -const _postMessage = { - postMessage: (message: any, transferrables: [Transferable]) => { - (postMessage)(message, transferrables); - } -}; - -export function createMessageBus(zone: NgZone): MessageBus { - const sink = new PostMessageBusSink(_postMessage); - const source = new PostMessageBusSource(); - const bus = new PostMessageBus(sink, source); - bus.attachToZone(zone); - return bus; -} - -export function setupWebWorker(): void { - WorkerDomAdapter.makeCurrent(); -} - -/** - * The ng module for the worker app side. - * - * @publicApi - * @deprecated platform-webworker is deprecated in Angular and will be removed in a future version - * of Angular - */ -@NgModule({ - providers: [ - BROWSER_SANITIZATION_PROVIDERS, - {provide: INJECTOR_SCOPE, useValue: 'root'}, - Serializer, - {provide: DOCUMENT, useValue: null}, - ClientMessageBrokerFactory, - ServiceMessageBrokerFactory, - WebWorkerRendererFactory2, - {provide: RendererFactory2, useExisting: WebWorkerRendererFactory2}, - {provide: ON_WEB_WORKER, useValue: true}, - RenderStore, - {provide: ErrorHandler, useFactory: errorHandler, deps: []}, - {provide: MessageBus, useFactory: createMessageBus, deps: [NgZone]}, - {provide: APP_INITIALIZER, useValue: setupWebWorker, multi: true}, - {provide: ViewportScroller, useClass: NullViewportScroller, deps: []}, - ], - exports: [ - CommonModule, - ApplicationModule, - ] -}) -export class WorkerAppModule { -} diff --git a/packages/platform-webworker/src/worker_render.ts b/packages/platform-webworker/src/worker_render.ts deleted file mode 100644 index fe69043ebf..0000000000 --- a/packages/platform-webworker/src/worker_render.ts +++ /dev/null @@ -1,193 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -import {DOCUMENT, ɵPLATFORM_WORKER_UI_ID as PLATFORM_WORKER_UI_ID} from '@angular/common'; -import {createPlatformFactory, ErrorHandler, Injectable, InjectionToken, Injector, isDevMode, NgZone, PLATFORM_ID, PLATFORM_INITIALIZER, platformCore, RendererFactory2, StaticProvider, Testability, ɵAPP_ID_RANDOM_PROVIDER as APP_ID_RANDOM_PROVIDER, ɵsetDocument} from '@angular/core'; -import {EVENT_MANAGER_PLUGINS, EventManager, HAMMER_GESTURE_CONFIG, HammerGestureConfig, ɵBROWSER_SANITIZATION_PROVIDERS as BROWSER_SANITIZATION_PROVIDERS, ɵBrowserDomAdapter as BrowserDomAdapter, ɵBrowserGetTestability as BrowserGetTestability, ɵDomEventsPlugin as DomEventsPlugin, ɵDomRendererFactory2 as DomRendererFactory2, ɵDomSharedStylesHost as DomSharedStylesHost, ɵHammerGesturesPlugin as HammerGesturesPlugin, ɵKeyEventsPlugin as KeyEventsPlugin, ɵSharedStylesHost as SharedStylesHost} from '@angular/platform-browser'; - -import {ON_WEB_WORKER} from './web_workers/shared/api'; -import {ClientMessageBrokerFactory} from './web_workers/shared/client_message_broker'; -import {MessageBus} from './web_workers/shared/message_bus'; -import {PostMessageBus, PostMessageBusSink, PostMessageBusSource} from './web_workers/shared/post_message_bus'; -import {RenderStore} from './web_workers/shared/render_store'; -import {Serializer} from './web_workers/shared/serializer'; -import {ServiceMessageBrokerFactory} from './web_workers/shared/service_message_broker'; -import {MessageBasedRenderer2} from './web_workers/ui/renderer'; - - - -/** - * Wrapper class that exposes the Worker - * and underlying {@link MessageBus} for lower level message passing. - * - * @publicApi - * @deprecated platform-webworker is deprecated in Angular and will be removed in a future version - * of Angular - */ -@Injectable() -export class WebWorkerInstance { - // TODO(issue/24571): remove '!'. - public worker!: Worker; - // TODO(issue/24571): remove '!'. - public bus!: MessageBus; - - /** @internal */ - public init(worker: Worker, bus: MessageBus) { - this.worker = worker; - this.bus = bus; - } -} - -/** - * @publicApi - * @deprecated platform-webworker is deprecated in Angular and will be removed in a future version - * of Angular - */ -export const WORKER_SCRIPT = new InjectionToken('WebWorkerScript'); - -/** - * A multi-provider used to automatically call the `start()` method after the service is - * created. - * - * @publicApi - * @deprecated platform-webworker is deprecated in Angular and will be removed in a future version - * of Angular - */ -export const WORKER_UI_STARTABLE_MESSAGING_SERVICE = - new InjectionToken<({start: () => void})[]>('WorkerRenderStartableMsgService'); - -export const _WORKER_UI_PLATFORM_PROVIDERS: StaticProvider[] = [ - {provide: NgZone, useFactory: createNgZone, deps: []}, - { - provide: MessageBasedRenderer2, - deps: [ServiceMessageBrokerFactory, MessageBus, Serializer, RenderStore, RendererFactory2] - }, - {provide: WORKER_UI_STARTABLE_MESSAGING_SERVICE, useExisting: MessageBasedRenderer2, multi: true}, - BROWSER_SANITIZATION_PROVIDERS, - {provide: ErrorHandler, useFactory: _exceptionHandler, deps: []}, - {provide: DOCUMENT, useFactory: _document, deps: []}, - // TODO(jteplitz602): Investigate if we definitely need EVENT_MANAGER on the render thread - // #5298 - { - provide: EVENT_MANAGER_PLUGINS, - useClass: DomEventsPlugin, - deps: [DOCUMENT, NgZone], - multi: true - }, - {provide: EVENT_MANAGER_PLUGINS, useClass: KeyEventsPlugin, deps: [DOCUMENT], multi: true}, - { - provide: EVENT_MANAGER_PLUGINS, - useClass: HammerGesturesPlugin, - deps: [DOCUMENT, HAMMER_GESTURE_CONFIG], - multi: true - }, - {provide: HAMMER_GESTURE_CONFIG, useClass: HammerGestureConfig, deps: []}, - APP_ID_RANDOM_PROVIDER, - {provide: DomRendererFactory2, deps: [EventManager, DomSharedStylesHost]}, - {provide: RendererFactory2, useExisting: DomRendererFactory2}, - {provide: SharedStylesHost, useExisting: DomSharedStylesHost}, - { - provide: ServiceMessageBrokerFactory, - useClass: ServiceMessageBrokerFactory, - deps: [MessageBus, Serializer] - }, - { - provide: ClientMessageBrokerFactory, - useClass: ClientMessageBrokerFactory, - deps: [MessageBus, Serializer] - }, - {provide: Serializer, deps: [RenderStore]}, - {provide: ON_WEB_WORKER, useValue: false}, - {provide: RenderStore, deps: []}, - {provide: DomSharedStylesHost, deps: [DOCUMENT]}, - {provide: Testability, deps: [NgZone]}, - {provide: EventManager, deps: [EVENT_MANAGER_PLUGINS, NgZone]}, - {provide: WebWorkerInstance, deps: []}, - { - provide: PLATFORM_INITIALIZER, - useFactory: initWebWorkerRenderPlatform, - multi: true, - deps: [Injector] - }, - {provide: PLATFORM_ID, useValue: PLATFORM_WORKER_UI_ID}, - {provide: MessageBus, useFactory: messageBusFactory, deps: [WebWorkerInstance]}, -]; - -function initializeGenericWorkerRenderer(injector: Injector) { - const bus = injector.get(MessageBus); - const zone = injector.get(NgZone); - bus.attachToZone(zone); - - // initialize message services after the bus has been created - const services = injector.get(WORKER_UI_STARTABLE_MESSAGING_SERVICE); - zone.runGuarded(() => { - services.forEach((svc: any) => { - svc.start(); - }); - }); -} - -function messageBusFactory(instance: WebWorkerInstance): MessageBus { - return instance.bus; -} - -function initWebWorkerRenderPlatform(injector: Injector): () => void { - return () => { - BrowserDomAdapter.makeCurrent(); - BrowserGetTestability.init(); - let scriptUri: string; - try { - scriptUri = injector.get(WORKER_SCRIPT); - } catch { - throw new Error( - 'You must provide your WebWorker\'s initialization script with the WORKER_SCRIPT token'); - } - - const instance = injector.get(WebWorkerInstance); - spawnWebWorker(scriptUri, instance); - - initializeGenericWorkerRenderer(injector); - }; -} - -/** - * @publicApi - * @deprecated platform-webworker is deprecated in Angular and will be removed in a future version - * of Angular - */ -export const platformWorkerUi = - createPlatformFactory(platformCore, 'workerUi', _WORKER_UI_PLATFORM_PROVIDERS); - -function _exceptionHandler(): ErrorHandler { - return new ErrorHandler(); -} - -function _document(): any { - // Tell ivy about the global document - ɵsetDocument(document); - return document; -} - -function createNgZone(): NgZone { - return new NgZone({enableLongStackTrace: isDevMode()}); -} - -/** - * Spawns a new class and initializes the WebWorkerInstance - */ -function spawnWebWorker(uri: string, instance: WebWorkerInstance): void { - const webWorker: Worker = new Worker(uri); - // webWorker is casted to any because the lib.d.ts signature changed in TS3.5 to require the - // transfer argument in postMessage method. - // this seems wrong but since all of this code is deprecated it shouldn't matter that much. - const sink = new PostMessageBusSink(webWorker as any); - const source = new PostMessageBusSource(webWorker); - const bus = new PostMessageBus(sink, source); - - instance.init(webWorker, bus); -} diff --git a/packages/platform-webworker/test/BUILD.bazel b/packages/platform-webworker/test/BUILD.bazel deleted file mode 100644 index 21b87b2f08..0000000000 --- a/packages/platform-webworker/test/BUILD.bazel +++ /dev/null @@ -1,35 +0,0 @@ -load("//tools:defaults.bzl", "jasmine_node_test", "karma_web_test_suite", "ts_library") - -ts_library( - name = "test_lib", - testonly = True, - srcs = glob(["**/*.ts"]), - deps = [ - "//packages:types", - "//packages/common", - "//packages/compiler", - "//packages/core", - "//packages/core/testing", - "//packages/platform-browser", - "//packages/platform-browser-dynamic", - "//packages/platform-browser-dynamic/testing", - "//packages/platform-browser/testing", - "//packages/platform-webworker", - "//packages/private/testing", - ], -) - -jasmine_node_test( - name = "test", - bootstrap = ["//tools/testing:node_es5"], - deps = [ - ":test_lib", - ], -) - -karma_web_test_suite( - name = "test_web", - deps = [ - ":test_lib", - ], -) diff --git a/packages/platform-webworker/test/web_workers/shared/message_bus_spec.ts b/packages/platform-webworker/test/web_workers/shared/message_bus_spec.ts deleted file mode 100644 index c101661182..0000000000 --- a/packages/platform-webworker/test/web_workers/shared/message_bus_spec.ts +++ /dev/null @@ -1,172 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -import {NgZone} from '@angular/core'; -import {withModule} from '@angular/core/testing/src/test_bed'; -import {AsyncTestCompleter, beforeEach, describe, expect, inject, it, MockNgZone} from '@angular/core/testing/src/testing_internal'; -import {MessageBus} from '@angular/platform-webworker/src/web_workers/shared/message_bus'; - -import {createConnectedMessageBus} from './message_bus_util'; - -{ - /** - * Tests the PostMessageBus - */ - describe('MessageBus', () => { - let bus: MessageBus; - - beforeEach(() => { - bus = createConnectedMessageBus(); - }); - - it('should pass messages in the same channel from sink to source', - inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { - const CHANNEL = 'CHANNEL 1'; - const MESSAGE = 'Test message'; - bus.initChannel(CHANNEL, false); - - const fromEmitter = bus.from(CHANNEL); - fromEmitter.subscribe({ - next: (message: any) => { - expect(message).toEqual(MESSAGE); - async.done(); - } - }); - const toEmitter = bus.to(CHANNEL); - toEmitter.emit(MESSAGE); - })); - - it('should broadcast', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { - const CHANNEL = 'CHANNEL 1'; - const MESSAGE = 'TESTING'; - const NUM_LISTENERS = 2; - bus.initChannel(CHANNEL, false); - - let callCount = 0; - const emitHandler = (message: any) => { - expect(message).toEqual(MESSAGE); - callCount++; - if (callCount == NUM_LISTENERS) { - async.done(); - } - }; - - for (let i = 0; i < NUM_LISTENERS; i++) { - const emitter = bus.from(CHANNEL); - emitter.subscribe({next: emitHandler}); - } - - const toEmitter = bus.to(CHANNEL); - toEmitter.emit(MESSAGE); - })); - - it('should keep channels independent', - inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { - const CHANNEL_ONE = 'CHANNEL 1'; - const CHANNEL_TWO = 'CHANNEL 2'; - const MESSAGE_ONE = 'This is a message on CHANNEL 1'; - const MESSAGE_TWO = 'This is a message on CHANNEL 2'; - let callCount = 0; - bus.initChannel(CHANNEL_ONE, false); - bus.initChannel(CHANNEL_TWO, false); - - const firstFromEmitter = bus.from(CHANNEL_ONE); - firstFromEmitter.subscribe({ - next: (message: any) => { - expect(message).toEqual(MESSAGE_ONE); - callCount++; - if (callCount == 2) { - async.done(); - } - } - }); - const secondFromEmitter = bus.from(CHANNEL_TWO); - secondFromEmitter.subscribe({ - next: (message: any) => { - expect(message).toEqual(MESSAGE_TWO); - callCount++; - if (callCount == 2) { - async.done(); - } - } - }); - - const firstToEmitter = bus.to(CHANNEL_ONE); - firstToEmitter.emit(MESSAGE_ONE); - - const secondToEmitter = bus.to(CHANNEL_TWO); - secondToEmitter.emit(MESSAGE_TWO); - })); - }); - - describe('PostMessageBusSink', () => { - let bus: MessageBus; - const CHANNEL = 'Test Channel'; - - function setup(runInZone: boolean, zone: NgZone) { - bus.attachToZone(zone); - bus.initChannel(CHANNEL, runInZone); - } - - /** - * Flushes pending messages and then runs the given function. - */ - // TODO(mlaval): timeout is fragile, test to be rewritten - function flushMessages(fn: () => void) { - setTimeout(fn, 50); - } - - it('should buffer messages and wait for the zone to exit before sending', - withModule({providers: [{provide: NgZone, useClass: MockNgZone}]}) - .inject( - [AsyncTestCompleter, NgZone], - (async: AsyncTestCompleter, zone: MockNgZone) => { - bus = createConnectedMessageBus(); - setup(true, zone); - - let wasCalled = false; - bus.from(CHANNEL).subscribe({ - next: (message: any) => { - wasCalled = true; - } - }); - bus.to(CHANNEL).emit('hi'); - - - flushMessages(() => { - expect(wasCalled).toBeFalsy(); - - zone.simulateZoneExit(); - flushMessages(() => { - expect(wasCalled).toBeTruthy(); - async.done(); - }); - }); - }), - 500); - - it('should send messages immediately when run outside the zone', - inject([AsyncTestCompleter, NgZone], (async: AsyncTestCompleter, zone: MockNgZone) => { - bus = createConnectedMessageBus(); - setup(false, zone); - - let wasCalled = false; - bus.from(CHANNEL).subscribe({ - next: (message: any) => { - wasCalled = true; - } - }); - bus.to(CHANNEL).emit('hi'); - - flushMessages(() => { - expect(wasCalled).toBeTruthy(); - async.done(); - }); - }), 10000); - }); -} diff --git a/packages/platform-webworker/test/web_workers/shared/message_bus_util.ts b/packages/platform-webworker/test/web_workers/shared/message_bus_util.ts deleted file mode 100644 index 99b886a2a5..0000000000 --- a/packages/platform-webworker/test/web_workers/shared/message_bus_util.ts +++ /dev/null @@ -1,38 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -import {MessageBus} from '@angular/platform-webworker/src/web_workers/shared/message_bus'; -import {PostMessageBus, PostMessageBusSink, PostMessageBusSource} from '@angular/platform-webworker/src/web_workers/shared/post_message_bus'; - - -/* - * Returns a PostMessageBus that's sink is connected to its own source. - * Useful for testing the sink and source. - */ -export function createConnectedMessageBus(): MessageBus { - const mockPostMessage = new MockPostMessage(); - const source = new PostMessageBusSource(mockPostMessage); - const sink = new PostMessageBusSink(mockPostMessage); - - return new PostMessageBus(sink, source); -} - -class MockPostMessage { - // TODO(issue/24571): remove '!'. - private _listener!: EventListener; - - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void { - if (type === 'message') { - this._listener = listener; - } - } - - postMessage(data: any, transfer?: [Transferable]): void { - this._listener({data: data}); - } -} diff --git a/packages/platform-webworker/test/web_workers/shared/mock_event_emitter.ts b/packages/platform-webworker/test/web_workers/shared/mock_event_emitter.ts deleted file mode 100644 index 48640d8df5..0000000000 --- a/packages/platform-webworker/test/web_workers/shared/mock_event_emitter.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -import {EventEmitter} from '@angular/core'; - -export class MockEventEmitter extends EventEmitter { - private _nextFns: Function[] = []; - - constructor() { - super(); - } - - subscribe(generator: any): any { - this._nextFns.push(generator.next); - return new MockDisposable(); - } - - emit(value: any) { - this._nextFns.forEach(fn => fn(value)); - } -} - -class MockDisposable { - isUnsubscribed: boolean = false; - unsubscribe(): void {} -} diff --git a/packages/platform-webworker/test/web_workers/shared/render_store_spec.ts b/packages/platform-webworker/test/web_workers/shared/render_store_spec.ts deleted file mode 100644 index 190704a3ee..0000000000 --- a/packages/platform-webworker/test/web_workers/shared/render_store_spec.ts +++ /dev/null @@ -1,37 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -import {RenderStore} from '@angular/platform-webworker/src/web_workers/shared/render_store'; - -{ - describe('RenderStoreSpec', () => { - let store: RenderStore; - beforeEach(() => { - store = new RenderStore(); - }); - - it('should allocate ids', () => { - expect(store.allocateId()).toBe(0); - expect(store.allocateId()).toBe(1); - }); - - it('should serialize objects', () => { - const id = store.allocateId(); - const obj = 'testObject'; - store.store(obj, id); - expect(store.serialize(obj)).toBe(id); - }); - - it('should deserialize objects', () => { - const id = store.allocateId(); - const obj = 'testObject'; - store.store(obj, id); - expect(store.deserialize(id)).toBe(obj); - }); - }); -} diff --git a/packages/platform-webworker/test/web_workers/shared/service_message_broker_spec.ts b/packages/platform-webworker/test/web_workers/shared/service_message_broker_spec.ts deleted file mode 100644 index f3fcfe1970..0000000000 --- a/packages/platform-webworker/test/web_workers/shared/service_message_broker_spec.ts +++ /dev/null @@ -1,73 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -import {beforeEach, beforeEachProviders, describe, expect, inject, it} from '@angular/core/testing/src/testing_internal'; -import {ON_WEB_WORKER} from '@angular/platform-webworker/src/web_workers/shared/api'; -import {RenderStore} from '@angular/platform-webworker/src/web_workers/shared/render_store'; -import {Serializer, SerializerTypes} from '@angular/platform-webworker/src/web_workers/shared/serializer'; -import {ServiceMessageBroker} from '@angular/platform-webworker/src/web_workers/shared/service_message_broker'; - -import {createPairedMessageBuses} from './web_worker_test_util'; - -{ - const CHANNEL = 'UIMessageBroker Test Channel'; - const TEST_METHOD = 'TEST_METHOD'; - const PASSED_ARG_1 = 5; - const PASSED_ARG_2 = 'TEST'; - const RESULT = 20; - const ID = 'methodId'; - - beforeEachProviders(() => [Serializer, {provide: ON_WEB_WORKER, useValue: true}, RenderStore]); - - describe('UIMessageBroker', () => { - let messageBuses: any /** TODO #9100 */; - - beforeEach(() => { - messageBuses = createPairedMessageBuses(); - messageBuses.ui.initChannel(CHANNEL); - messageBuses.worker.initChannel(CHANNEL); - }); - it('should call registered method with correct arguments', - inject([Serializer], (serializer: Serializer) => { - const broker = new (ServiceMessageBroker as any)(messageBuses.ui, serializer, CHANNEL); - broker.registerMethod( - TEST_METHOD, [SerializerTypes.PRIMITIVE, SerializerTypes.PRIMITIVE], - (arg1: any, arg2: any) => { - expect(arg1).toEqual(PASSED_ARG_1); - expect(arg2).toEqual(PASSED_ARG_2); - }); - messageBuses.worker.to(CHANNEL).emit({ - 'method': TEST_METHOD, - 'args': [PASSED_ARG_1, PASSED_ARG_2], - }); - })); - - it('should return promises to the worker', inject([Serializer], (serializer: Serializer) => { - const broker = new (ServiceMessageBroker as any)(messageBuses.ui, serializer, CHANNEL); - broker.registerMethod(TEST_METHOD, [SerializerTypes.PRIMITIVE], (arg1: any) => { - expect(arg1).toEqual(PASSED_ARG_1); - return new Promise((res, rej) => { - try { - res(RESULT); - } catch (e) { - rej(e); - } - }); - }); - messageBuses.worker.to(CHANNEL).emit( - {'method': TEST_METHOD, 'id': ID, 'args': [PASSED_ARG_1]}); - messageBuses.worker.from(CHANNEL).subscribe({ - next: (data: any) => { - expect(data.type).toEqual('result'); - expect(data.id).toEqual(ID); - expect(data.value).toEqual(RESULT); - }, - }); - })); - }); -} diff --git a/packages/platform-webworker/test/web_workers/shared/web_worker_test_util.ts b/packages/platform-webworker/test/web_workers/shared/web_worker_test_util.ts deleted file mode 100644 index 3fd3f7f97c..0000000000 --- a/packages/platform-webworker/test/web_workers/shared/web_worker_test_util.ts +++ /dev/null @@ -1,150 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -import {Type} from '@angular/core'; -import {NgZone} from '@angular/core/src/zone/ng_zone'; -import {ClientMessageBroker, ClientMessageBrokerFactory, UiArguments} from '@angular/platform-webworker/src/web_workers/shared/client_message_broker'; -import {MessageBus, MessageBusSink, MessageBusSource} from '@angular/platform-webworker/src/web_workers/shared/message_bus'; -import {SpyMessageBroker} from '../worker/spies'; - -import {MockEventEmitter} from './mock_event_emitter'; - -/** - * Returns two MessageBus instances that are attached to each other. - * Such that whatever goes into one's sink comes out the others source. - */ -export function createPairedMessageBuses(): PairedMessageBuses { - const firstChannels: {[key: string]: MockEventEmitter} = {}; - const workerMessageBusSink = new MockMessageBusSink(firstChannels); - const uiMessageBusSource = new MockMessageBusSource(firstChannels); - - const secondChannels: {[key: string]: MockEventEmitter} = {}; - const uiMessageBusSink = new MockMessageBusSink(secondChannels); - const workerMessageBusSource = new MockMessageBusSource(secondChannels); - - return new PairedMessageBuses( - new MockMessageBus(uiMessageBusSink, uiMessageBusSource), - new MockMessageBus(workerMessageBusSink, workerMessageBusSource)); -} - -/** - * Spies on the given {@link SpyMessageBroker} and expects a call with the given methodName - * andvalues. - * If a handler is provided it will be called to handle the request. - * Only intended to be called on a given broker instance once. - */ -export function expectBrokerCall( - broker: SpyMessageBroker, methodName: string, vals?: Array, - handler?: (..._: any[]) => Promise| void): void { - broker.spy('runOnService').and.callFake((args: UiArguments, returnType: Type) => { - expect(args.method).toEqual(methodName); - if (vals != null) { - expect(args.args!.length).toEqual(vals.length); - vals.forEach((v, i) => { - expect(v).toEqual(args.args![i].value); - }); - } - let promise: Promise|void = null!; - if (handler != null) { - const givenValues = args.args!.map((arg) => arg.value); - if (givenValues.length > 0) { - promise = handler(givenValues); - } else { - promise = handler(); - } - } - if (promise == null) { - promise = new Promise((res, rej) => { - try { - res(); - } catch (e) { - rej(e); - } - }); - } - return promise; - }); -} - -export class PairedMessageBuses { - constructor(public ui: MessageBus, public worker: MessageBus) {} -} - -export class MockMessageBusSource implements MessageBusSource { - constructor(private _channels: {[key: string]: MockEventEmitter}) {} - - initChannel(channel: string, runInZone = true) { - if (!this._channels.hasOwnProperty(channel)) { - this._channels[channel] = new MockEventEmitter(); - } - } - - from(channel: string): MockEventEmitter { - if (!this._channels.hasOwnProperty(channel)) { - throw new Error(`${channel} is not set up. Did you forget to call initChannel?`); - } - return this._channels[channel]; - } - - attachToZone(zone: NgZone) {} -} - -export class MockMessageBusSink implements MessageBusSink { - constructor(private _channels: {[key: string]: MockEventEmitter}) {} - - initChannel(channel: string, runInZone = true) { - if (!this._channels.hasOwnProperty(channel)) { - this._channels[channel] = new MockEventEmitter(); - } - } - - to(channel: string): MockEventEmitter { - if (!this._channels.hasOwnProperty(channel)) { - this._channels[channel] = new MockEventEmitter(); - } - return this._channels[channel]; - } - - attachToZone(zone: NgZone) {} -} - -/** - * Mock implementation of the {@link MessageBus} for tests. - * Runs syncronously, and does not support running within the zone. - */ -export class MockMessageBus extends MessageBus { - constructor(public sink: MockMessageBusSink, public source: MockMessageBusSource) { - super(); - } - - initChannel(channel: string, runInZone = true) { - this.sink.initChannel(channel, runInZone); - this.source.initChannel(channel, runInZone); - } - - to(channel: string): MockEventEmitter { - return this.sink.to(channel); - } - - from(channel: string): MockEventEmitter { - return this.source.from(channel); - } - - attachToZone(zone: NgZone) {} -} - -export const _ClientMessageBrokerFactory: {new (a: any, b: any): ClientMessageBrokerFactory} = - ClientMessageBrokerFactory; -export class MockMessageBrokerFactory extends _ClientMessageBrokerFactory { - constructor(private _messageBroker: ClientMessageBroker) { - super(null!, null!); - } - createMessageBroker(channel: string, runInZone = true) { - return this._messageBroker; - } -} diff --git a/packages/platform-webworker/test/web_workers/worker/platform_location_spec.ts b/packages/platform-webworker/test/web_workers/worker/platform_location_spec.ts deleted file mode 100644 index 3350b90995..0000000000 --- a/packages/platform-webworker/test/web_workers/worker/platform_location_spec.ts +++ /dev/null @@ -1,97 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -import {Type} from '@angular/core'; -import {UiArguments} from '@angular/platform-webworker/src/web_workers/shared/client_message_broker'; -import {MessageBus} from '@angular/platform-webworker/src/web_workers/shared/message_bus'; -import {LocationType, SerializerTypes} from '@angular/platform-webworker/src/web_workers/shared/serializer'; -import {WebWorkerPlatformLocation} from '@angular/platform-webworker/src/web_workers/worker/platform_location'; - -import {createPairedMessageBuses, expectBrokerCall, MockMessageBrokerFactory} from '../shared/web_worker_test_util'; - -import {SpyMessageBroker} from './spies'; - -{ - describe('WebWorkerPlatformLocation', () => { - let uiBus: MessageBus = null!; - let workerBus: MessageBus = null!; - let broker: any = null; - - const TEST_LOCATION = new LocationType( - 'http://www.example.com', 'http', 'example.com', 'example.com', '80', '/', '', '', - 'http://www.example.com'); - - - function createWebWorkerPlatformLocation(loc: LocationType): WebWorkerPlatformLocation { - broker.spy('runOnService') - .and.callFake((args: UiArguments, returnType: Type|SerializerTypes) => { - if (args.method === 'getLocation') { - return Promise.resolve(loc); - } - }); - const factory = new MockMessageBrokerFactory(broker); - return new WebWorkerPlatformLocation(factory, workerBus, null!); - } - - function testPushOrReplaceState(pushState: boolean) { - const platformLocation = createWebWorkerPlatformLocation(null!); - const TITLE = 'foo'; - const URL = 'http://www.example.com/foo'; - expectBrokerCall(broker, pushState ? 'pushState' : 'replaceState', [null, TITLE, URL]); - if (pushState) { - platformLocation.pushState(null, TITLE, URL); - } else { - platformLocation.replaceState(null, TITLE, URL); - } - } - - beforeEach(() => { - const buses = createPairedMessageBuses(); - uiBus = buses.ui; - workerBus = buses.worker; - workerBus.initChannel('ng-Router'); - uiBus.initChannel('ng-Router'); - broker = new SpyMessageBroker(); - }); - - it('should throw if getBaseHrefFromDOM is called', () => { - const platformLocation = createWebWorkerPlatformLocation(null!); - expect(() => platformLocation.getBaseHrefFromDOM()).toThrowError(); - }); - - it('should get location on init', () => { - const platformLocation = createWebWorkerPlatformLocation(null!); - expectBrokerCall(broker, 'getLocation'); - (platformLocation as any).init(); - }); - - it('should throw if set pathname is called before init finishes', () => { - const platformLocation = createWebWorkerPlatformLocation(null!); - (platformLocation as any).init(); - expect(() => platformLocation.pathname = 'TEST').toThrowError(); - }); - - it('should send pathname to render thread', done => { - const platformLocation = createWebWorkerPlatformLocation(TEST_LOCATION); - (platformLocation as any).init().then((_: any) => { - const PATHNAME = '/test'; - expectBrokerCall(broker, 'setPathname', [PATHNAME]); - platformLocation.pathname = PATHNAME; - done(); - }); - }); - - it('should send pushState to render thread', () => { - testPushOrReplaceState(true); - }); - - it('should send replaceState to render thread', () => { - testPushOrReplaceState(false); - }); - }); -} diff --git a/packages/platform-webworker/test/web_workers/worker/renderer_v2_integration_spec.ts b/packages/platform-webworker/test/web_workers/worker/renderer_v2_integration_spec.ts deleted file mode 100644 index 9acb36a787..0000000000 --- a/packages/platform-webworker/test/web_workers/worker/renderer_v2_integration_spec.ts +++ /dev/null @@ -1,225 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -import {ɵgetDOM as getDOM} from '@angular/common'; -import {Component, ComponentRef, destroyPlatform, Renderer2, RendererFactory2, RendererType2} from '@angular/core'; -import {TestBed} from '@angular/core/testing'; -import {platformBrowserDynamicTesting} from '@angular/platform-browser-dynamic/testing'; -import {DomRendererFactory2} from '@angular/platform-browser/src/dom/dom_renderer'; -import {BrowserTestingModule} from '@angular/platform-browser/testing'; -import {browserDetection, dispatchEvent, hasClass} from '@angular/platform-browser/testing/src/browser_util'; -import {expect} from '@angular/platform-browser/testing/src/matchers'; -import {ClientMessageBrokerFactory} from '@angular/platform-webworker/src/web_workers/shared/client_message_broker'; -import {RenderStore} from '@angular/platform-webworker/src/web_workers/shared/render_store'; -import {Serializer} from '@angular/platform-webworker/src/web_workers/shared/serializer'; -import {ServiceMessageBrokerFactory} from '@angular/platform-webworker/src/web_workers/shared/service_message_broker'; -import {MessageBasedRenderer2} from '@angular/platform-webworker/src/web_workers/ui/renderer'; -import {WebWorkerRendererFactory2} from '@angular/platform-webworker/src/web_workers/worker/renderer'; -import {modifiedInIvy} from '@angular/private/testing'; - -import {createPairedMessageBuses, PairedMessageBuses} from '../shared/web_worker_test_util'; - -let lastCreatedRenderer: Renderer2; - -{ - describe('Web Worker Renderer v2', () => { - // Don't run on server... - if (!getDOM().supportsDOMEvents()) return; - // TODO(tbosch): investigate why this is failing on iOS7 for unrelated reasons - // Note: it's hard to debug this as SauceLabs starts with iOS8. Maybe drop - // iOS7 altogether? - if (browserDetection.isIOS7) return; - - let uiRenderStore: RenderStore; - let wwRenderStore: RenderStore; - - beforeEach(() => destroyPlatform()); - afterEach(() => destroyPlatform()); - - beforeEach(() => { - // UI side - uiRenderStore = new RenderStore(); - const uiInjector = new TestBed(); - uiInjector.initTestEnvironment(BrowserTestingModule, platformBrowserDynamicTesting()); - uiInjector.configureTestingModule({ - providers: [ - Serializer, - {provide: RenderStore, useValue: uiRenderStore}, - DomRendererFactory2, - {provide: RendererFactory2, useExisting: DomRendererFactory2}, - ] - }); - const uiSerializer = uiInjector.get(Serializer); - const domRendererFactory = uiInjector.get(RendererFactory2); - - // Worker side - lastCreatedRenderer = null!; - - wwRenderStore = new RenderStore(); - - TestBed.configureTestingModule({ - declarations: [MyComp2], - providers: [ - Serializer, - {provide: RenderStore, useValue: wwRenderStore}, - { - provide: RendererFactory2, - useFactory: (wwSerializer: Serializer) => createWebWorkerRendererFactory2( - wwSerializer, uiSerializer, domRendererFactory, uiRenderStore, wwRenderStore), - deps: [Serializer], - }, - ], - }); - }); - - function getRenderElement(workerEl: any): any { - const id = wwRenderStore.serialize(workerEl)!; - return uiRenderStore.deserialize(id); - } - - it('should update text nodes', () => { - const fixture = - TestBed.overrideTemplate(MyComp2, '
{{ctxProp}}
').createComponent(MyComp2); - const renderEl = getRenderElement(fixture.nativeElement); - expect(renderEl).toHaveText(''); - - fixture.componentInstance.ctxProp = 'Hello World!'; - fixture.detectChanges(); - expect(renderEl).toHaveText('Hello World!'); - }); - - modifiedInIvy('DebugElements are not supported on web-worker') - .it('should update any element property/attributes/class/style(s) independent of the compilation on the root element and other elements', - () => { - const fixture = - TestBed.overrideTemplate(MyComp2, '') - .createComponent(MyComp2); - - const checkSetters = (componentRef: ComponentRef, workerEl: any) => { - expect(lastCreatedRenderer).not.toBeNull(); - - const el = getRenderElement(workerEl); - lastCreatedRenderer.setProperty(workerEl, 'tabIndex', 1); - expect(el.tabIndex).toEqual(1); - - lastCreatedRenderer.addClass(workerEl, 'a'); - expect(hasClass(el, 'a')).toBe(true); - - lastCreatedRenderer.removeClass(workerEl, 'a'); - expect(hasClass(el, 'a')).toBe(false); - - lastCreatedRenderer.setStyle(workerEl, 'width', '10px'); - expect(el.style['width']).toEqual('10px'); - - lastCreatedRenderer.removeStyle(workerEl, 'width'); - expect(el.style['width']).toEqual(''); - - lastCreatedRenderer.setAttribute(workerEl, 'someattr', 'someValue'); - expect(el.getAttribute('someattr')).toEqual('someValue'); - }; - - // root element - checkSetters(fixture.componentRef, fixture.nativeElement); - // nested elements - checkSetters(fixture.componentRef, fixture.debugElement.children[0].nativeElement); - }); - - it('should update any template comment property/attributes', () => { - const fixture = - TestBed.overrideTemplate(MyComp2, '') - .createComponent(MyComp2); - fixture.componentInstance.ctxBoolProp = true; - fixture.detectChanges(); - const el = getRenderElement(fixture.nativeElement); - expect(el.innerHTML).toContain('"ng-reflect-ng-if": "true"'); - }); - - it('should add and remove fragments', () => { - const fixture = - TestBed - .overrideTemplate(MyComp2, 'hello') - .createComponent(MyComp2); - - const rootEl = getRenderElement(fixture.nativeElement); - expect(rootEl).toHaveText(''); - - fixture.componentInstance.ctxBoolProp = true; - fixture.detectChanges(); - expect(rootEl).toHaveText('hello'); - - fixture.componentInstance.ctxBoolProp = false; - fixture.detectChanges(); - expect(rootEl).toHaveText(''); - }); - - if (getDOM().supportsDOMEvents()) { - modifiedInIvy('DebugElements are not supported on web-worker') - .it('should listen to events', () => { - const fixture = TestBed.overrideTemplate(MyComp2, '') - .createComponent(MyComp2); - - const el = fixture.debugElement.children[0]; - dispatchEvent(getRenderElement(el.nativeElement), 'change'); - expect(fixture.componentInstance.ctxNumProp).toBe(1); - - fixture.destroy(); - }); - } - }); -} - -@Component({selector: 'my-comp'}) -class MyComp2 { - ctxProp = 'initial value'; - ctxNumProp = 0; - ctxBoolProp = false; -} - -function createWebWorkerBrokerFactory( - messageBuses: PairedMessageBuses, wwSerializer: Serializer, uiSerializer: Serializer, - domRendererFactory: DomRendererFactory2, - uiRenderStore: RenderStore): ClientMessageBrokerFactory { - const uiMessageBus = messageBuses.ui; - const wwMessageBus = messageBuses.worker; - - // set up the worker side - const wwBrokerFactory = new (ClientMessageBrokerFactory as any)(wwMessageBus, wwSerializer); - - // set up the ui side - const uiBrokerFactory = new (ServiceMessageBrokerFactory as any)(uiMessageBus, uiSerializer); - const renderer = new MessageBasedRenderer2( - uiBrokerFactory, uiMessageBus, uiSerializer, uiRenderStore, domRendererFactory); - renderer.start(); - - return wwBrokerFactory; -} - -function createWebWorkerRendererFactory2( - workerSerializer: Serializer, uiSerializer: Serializer, domRendererFactory: DomRendererFactory2, - uiRenderStore: RenderStore, workerRenderStore: RenderStore): RendererFactory2 { - const messageBuses = createPairedMessageBuses(); - const brokerFactory = createWebWorkerBrokerFactory( - messageBuses, workerSerializer, uiSerializer, domRendererFactory, uiRenderStore); - - const rendererFactory = - new RenderFactory(brokerFactory, messageBuses.worker, workerSerializer, workerRenderStore); - - return rendererFactory; -} - -class RenderFactory extends WebWorkerRendererFactory2 { - createRenderer(element: any, type: RendererType2|null): Renderer2 { - lastCreatedRenderer = super.createRenderer(element, type); - return lastCreatedRenderer; - } -} - -function isOldIE() { - // note that this only applies to older IEs (not edge) - return (window as any).document['documentMode'] ? true : false; -} diff --git a/packages/platform-webworker/test/web_workers/worker/spies.ts b/packages/platform-webworker/test/web_workers/worker/spies.ts deleted file mode 100644 index c2b6b27f51..0000000000 --- a/packages/platform-webworker/test/web_workers/worker/spies.ts +++ /dev/null @@ -1,16 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -import {SpyObject} from '@angular/core/testing/src/testing_internal'; -import {ClientMessageBroker} from '@angular/platform-webworker/src/web_workers/shared/client_message_broker'; - -export class SpyMessageBroker extends SpyObject { - constructor() { - super(ClientMessageBroker); - } -} diff --git a/packages/tsconfig.json b/packages/tsconfig.json index 82b7c712a7..36e81fb949 100644 --- a/packages/tsconfig.json +++ b/packages/tsconfig.json @@ -47,10 +47,6 @@ "http/**", "language-service/test/project", "platform-server/integrationtest", - // The webworker packages have deprecated and are not made compatible with the - // strict flag. Until these packages are removed, we exclude them here. - "platform-webworker/**", - "platform-webworker-dynamic/**", "router/test/aot_ngsummary_test" ] } diff --git a/scripts/release/post-check b/scripts/release/post-check index 7fdcf415e9..226b98c1da 100755 --- a/scripts/release/post-check +++ b/scripts/release/post-check @@ -7,7 +7,7 @@ mkdir tmp cd tmp npm init -y -npm install typescript@~3.8.3 rxjs@^6.5.3 zone.js@~0.10.3 @bazel/typescript@^1.0.0 rollup@^1.20.0 rollup-plugin-commonjs@^9.0.0 rollup-plugin-node-resolve@^4.2.0 rollup-plugin-sourcemaps@0.4.0 @angular/{animations,bazel,common,compiler,compiler-cli,core,elements,forms,language-service,localize,platform-browser,platform-browser-dynamic,platform-server,platform-webworker,platform-webworker-dynamic,router,service-worker,upgrade} --save +npm install typescript@~3.8.3 rxjs@^6.5.3 zone.js@~0.10.3 @bazel/typescript@^1.0.0 rollup@^1.20.0 rollup-plugin-commonjs@^9.0.0 rollup-plugin-node-resolve@^4.2.0 rollup-plugin-sourcemaps@0.4.0 @angular/{animations,bazel,common,compiler,compiler-cli,core,elements,forms,language-service,localize,platform-browser,platform-browser-dynamic,platform-server,router,service-worker,upgrade} --save cd .. rm -rf tmp diff --git a/scripts/release/post-check-next b/scripts/release/post-check-next index 42b830965f..a0cde053e8 100755 --- a/scripts/release/post-check-next +++ b/scripts/release/post-check-next @@ -7,7 +7,7 @@ mkdir tmp cd tmp npm init -y -npm install typescript@~3.8.3 rxjs@^6.5.3 zone.js@~0.10.3 @bazel/typescript@^1.0.0 rollup@^1.20.0 rollup-plugin-commonjs@^9.0.0 rollup-plugin-node-resolve@^4.2.0 rollup-plugin-sourcemaps@0.4.0 @angular/{animations,bazel,common,compiler,compiler-cli,core,elements,forms,language-service,localize,platform-browser,platform-browser-dynamic,platform-server,platform-webworker,platform-webworker-dynamic,router,service-worker,upgrade}@next --save +npm install typescript@~3.8.3 rxjs@^6.5.3 zone.js@~0.10.3 @bazel/typescript@^1.0.0 rollup@^1.20.0 rollup-plugin-commonjs@^9.0.0 rollup-plugin-node-resolve@^4.2.0 rollup-plugin-sourcemaps@0.4.0 @angular/{animations,bazel,common,compiler,compiler-cli,core,elements,forms,language-service,localize,platform-browser,platform-browser-dynamic,platform-server,router,service-worker,upgrade}@next --save cd .. rm -rf tmp diff --git a/test-main.js b/test-main.js index 4321c86442..7cc5f3323d 100644 --- a/test-main.js +++ b/test-main.js @@ -66,8 +66,6 @@ System.config({ '@angular/platform-browser-dynamic': {main: 'index.js', defaultExtension: 'js'}, '@angular/platform-server/testing': {main: 'index.js', defaultExtension: 'js'}, '@angular/platform-server': {main: 'index.js', defaultExtension: 'js'}, - '@angular/platform-webworker': {main: 'index.js', defaultExtension: 'js'}, - '@angular/platform-webworker-dynamic': {main: 'index.js', defaultExtension: 'js'}, '@angular/private/testing': {main: 'index.js', defaultExtension: 'js'}, '@angular/elements': {main: 'index.js', defaultExtension: 'js'}, 'rxjs/ajax': {main: 'index.js', defaultExtension: 'js'}, diff --git a/tools/defaults.bzl b/tools/defaults.bzl index b99e371f4f..f52af51875 100644 --- a/tools/defaults.bzl +++ b/tools/defaults.bzl @@ -41,8 +41,6 @@ ANGULAR_SCOPED_PACKAGES = ["@angular/%s" % p for p in [ # Current plan for Angular v8 is to not include @angular/http in ng update # "http", "platform-server", - "platform-webworker", - "platform-webworker-dynamic", "upgrade", "router", "language-service",