diff --git a/aio/content/guide/deprecations.md b/aio/content/guide/deprecations.md index c056238c3f..ce4ab4314a 100644 --- a/aio/content/guide/deprecations.md +++ b/aio/content/guide/deprecations.md @@ -122,6 +122,19 @@ Tip: In the [API reference section](api) of this doc site, deprecated APIs are i | --- | ----------- | --------------------- | ----- | | [`preserveQueryParams`](api/router/NavigationExtras#preserveQueryParams) | [`queryParamsHandling`](api/router/NavigationExtras#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 @@ -380,6 +393,21 @@ Instead, use web workers primarily for offloading CPU intensive, but functionall +{@a webworker-apps} +### platform-webworker Angular applications + + +platform-webworker has been around since the initial release of Angular version 2. It began as an experiment to leverage Angular's rendering architecture and try something different: to run an entire web application in a web worker. + +We've learned a lot from this experiment, and have come to the conclusion that pushing entire applications to run in a web worker is not a recipe for success for most applications. This is due to a number of unresolved issues, including: + +* Poor or non-existent support for web worker APIs in web crawlers/indexers. +* Poor support in build and bundling tooling. + +As a result, as of Angular version 8, we are deprecating the `platform-webworker` APIs in Angular. This consists of both NPM packages, `@angular/platform-webworker` and `@angular/platform-webworker-dynamic`. + +Going forward, we will focus our efforts related to web workers around their primary use case of offloading CPU-intensive but not critical work. + {@a removed} ## Removed APIs diff --git a/packages/platform-webworker-dynamic/src/platform-webworker-dynamic.ts b/packages/platform-webworker-dynamic/src/platform-webworker-dynamic.ts index 08f100e41d..68180cfd67 100644 --- a/packages/platform-webworker-dynamic/src/platform-webworker-dynamic.ts +++ b/packages/platform-webworker-dynamic/src/platform-webworker-dynamic.ts @@ -16,6 +16,7 @@ export {VERSION} from './version'; /** * @publicApi + * @deprecated platform-webworker is deprecated in Angular and will be removed in version 10 */ export const platformWorkerAppDynamic = createPlatformFactory(platformCoreDynamic, 'workerAppDynamic', [ diff --git a/packages/platform-webworker-dynamic/src/version.ts b/packages/platform-webworker-dynamic/src/version.ts index 9469ebe5e5..91b55934de 100644 --- a/packages/platform-webworker-dynamic/src/version.ts +++ b/packages/platform-webworker-dynamic/src/version.ts @@ -16,5 +16,6 @@ import {Version} from '@angular/core'; /** * @publicApi + * @deprecated platform-webworker is deprecated in Angular and will be removed in version 10 */ export const VERSION = new Version('0.0.0-PLACEHOLDER'); diff --git a/packages/platform-webworker/src/platform-webworker.ts b/packages/platform-webworker/src/platform-webworker.ts index 7dab62437f..ed593eb65b 100644 --- a/packages/platform-webworker/src/platform-webworker.ts +++ b/packages/platform-webworker/src/platform-webworker.ts @@ -24,6 +24,7 @@ export {platformWorkerUi} from './worker_render'; * Bootstraps the worker ui. * * @publicApi + * @deprecated platform-webworker is deprecated in Angular and will be removed in version 10 */ export function bootstrapWorkerUi( workerScriptUri: string, customProviders: StaticProvider[] = []): Promise { diff --git a/packages/platform-webworker/src/version.ts b/packages/platform-webworker/src/version.ts index 9469ebe5e5..91b55934de 100644 --- a/packages/platform-webworker/src/version.ts +++ b/packages/platform-webworker/src/version.ts @@ -16,5 +16,6 @@ import {Version} from '@angular/core'; /** * @publicApi + * @deprecated platform-webworker is deprecated in Angular and will be removed in version 10 */ export const VERSION = new Version('0.0.0-PLACEHOLDER'); 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 index dc974b65e7..0a79ccd883 100644 --- a/packages/platform-webworker/src/web_workers/shared/client_message_broker.ts +++ b/packages/platform-webworker/src/web_workers/shared/client_message_broker.ts @@ -12,6 +12,7 @@ import {Serializer, SerializerTypes} from './serializer'; /** * @publicApi + * @deprecated platform-webworker is deprecated in Angular and will be removed in version 10 */ @Injectable() export class ClientMessageBrokerFactory { @@ -39,6 +40,7 @@ interface PromiseCompleter { /** * @publicApi + * @deprecated platform-webworker is deprecated in Angular and will be removed in version 10 */ export class ClientMessageBroker { private _pending = new Map(); diff --git a/packages/platform-webworker/src/web_workers/shared/message_bus.ts b/packages/platform-webworker/src/web_workers/shared/message_bus.ts index 51cd04e87f..3afa95f327 100644 --- a/packages/platform-webworker/src/web_workers/shared/message_bus.ts +++ b/packages/platform-webworker/src/web_workers/shared/message_bus.ts @@ -17,6 +17,7 @@ import {EventEmitter, NgZone} from '@angular/core'; * by the corresponding MessageBusSource. * * @publicApi + * @deprecated platform-webworker is deprecated in Angular and will be removed in version 10 */ export abstract class MessageBus implements MessageBusSource, MessageBusSink { /** diff --git a/packages/platform-webworker/src/web_workers/shared/serializer.ts b/packages/platform-webworker/src/web_workers/shared/serializer.ts index 2a47cf7458..7b2d16631f 100644 --- a/packages/platform-webworker/src/web_workers/shared/serializer.ts +++ b/packages/platform-webworker/src/web_workers/shared/serializer.ts @@ -12,6 +12,7 @@ import {RenderStore} from './render_store'; /** * @publicApi + * @deprecated platform-webworker is deprecated in Angular and will be removed in version 10 */ export const enum SerializerTypes { // RendererType2 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 index ba97a1124f..f18d7feaa6 100644 --- a/packages/platform-webworker/src/web_workers/shared/service_message_broker.ts +++ b/packages/platform-webworker/src/web_workers/shared/service_message_broker.ts @@ -13,6 +13,7 @@ import {Serializer, SerializerTypes} from '../shared/serializer'; /** * @publicApi + * @deprecated platform-webworker is deprecated in Angular and will be removed in version 10 */ @Injectable() export class ServiceMessageBrokerFactory { @@ -40,6 +41,7 @@ export class ServiceMessageBrokerFactory { * 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 version 10 */ export class ServiceMessageBroker { private _sink: EventEmitter; @@ -91,6 +93,7 @@ export class ServiceMessageBroker { /** * @publicApi + * @deprecated platform-webworker is deprecated in Angular and will be removed in version 10 */ export interface ReceivedMessage { method: string; diff --git a/packages/platform-webworker/src/web_workers/ui/location_providers.ts b/packages/platform-webworker/src/web_workers/ui/location_providers.ts index ac91a2025d..ac35c15f4a 100644 --- a/packages/platform-webworker/src/web_workers/ui/location_providers.ts +++ b/packages/platform-webworker/src/web_workers/ui/location_providers.ts @@ -22,6 +22,7 @@ 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 version 10 */ export const WORKER_UI_LOCATION_PROVIDERS = [ {provide: MessageBasedPlatformLocation, deps: [ServiceMessageBrokerFactory, diff --git a/packages/platform-webworker/src/web_workers/worker/location_providers.ts b/packages/platform-webworker/src/web_workers/worker/location_providers.ts index 5438cd1bbe..e61ce5cf5b 100644 --- a/packages/platform-webworker/src/web_workers/worker/location_providers.ts +++ b/packages/platform-webworker/src/web_workers/worker/location_providers.ts @@ -17,6 +17,7 @@ import {WebWorkerPlatformLocation} from './platform_location'; * a worker context. * * @publicApi + * @deprecated platform-webworker is deprecated in Angular and will be removed in version 10 */ export const WORKER_APP_LOCATION_PROVIDERS = [ {provide: PlatformLocation, useClass: WebWorkerPlatformLocation}, { diff --git a/packages/platform-webworker/src/worker_app.ts b/packages/platform-webworker/src/worker_app.ts index 061ca060ee..987e613586 100644 --- a/packages/platform-webworker/src/worker_app.ts +++ b/packages/platform-webworker/src/worker_app.ts @@ -24,6 +24,7 @@ import {WorkerDomAdapter} from './web_workers/worker/worker_adapter'; /** * @publicApi + * @deprecated platform-webworker is deprecated in Angular and will be removed in version 10 */ export const platformWorkerApp = createPlatformFactory( platformCore, 'workerApp', [{provide: PLATFORM_ID, useValue: PLATFORM_WORKER_APP_ID}]); @@ -56,6 +57,7 @@ export function setupWebWorker(): void { * The ng module for the worker app side. * * @publicApi + * @deprecated platform-webworker is deprecated in Angular and will be removed in version 10 */ @NgModule({ providers: [ diff --git a/packages/platform-webworker/src/worker_render.ts b/packages/platform-webworker/src/worker_render.ts index f5b3ea5e27..b03dbb7776 100644 --- a/packages/platform-webworker/src/worker_render.ts +++ b/packages/platform-webworker/src/worker_render.ts @@ -26,6 +26,7 @@ import {MessageBasedRenderer2} from './web_workers/ui/renderer'; * and underlying {@link MessageBus} for lower level message passing. * * @publicApi + * @deprecated platform-webworker is deprecated in Angular and will be removed in version 10 */ @Injectable() export class WebWorkerInstance { @@ -43,6 +44,7 @@ export class WebWorkerInstance { /** * @publicApi + * @deprecated platform-webworker is deprecated in Angular and will be removed in version 10 */ export const WORKER_SCRIPT = new InjectionToken('WebWorkerScript'); @@ -51,6 +53,7 @@ export const WORKER_SCRIPT = new InjectionToken('WebWorkerScript'); * created. * * @publicApi + * @deprecated platform-webworker is deprecated in Angular and will be removed in version 10 */ export const WORKER_UI_STARTABLE_MESSAGING_SERVICE = new InjectionToken<({start: () => void})[]>('WorkerRenderStartableMsgService'); diff --git a/tools/public_api_guard/platform-webworker-dynamic/platform-webworker-dynamic.d.ts b/tools/public_api_guard/platform-webworker-dynamic/platform-webworker-dynamic.d.ts index 8b8e2110a5..f2abbd6e3b 100644 --- a/tools/public_api_guard/platform-webworker-dynamic/platform-webworker-dynamic.d.ts +++ b/tools/public_api_guard/platform-webworker-dynamic/platform-webworker-dynamic.d.ts @@ -1,3 +1,5 @@ +/** @deprecated */ export declare const platformWorkerAppDynamic: (extraProviders?: StaticProvider[] | undefined) => PlatformRef; +/** @deprecated */ export declare const VERSION: Version; diff --git a/tools/public_api_guard/platform-webworker/platform-webworker.d.ts b/tools/public_api_guard/platform-webworker/platform-webworker.d.ts index d9d000f23b..8293c24d7a 100644 --- a/tools/public_api_guard/platform-webworker/platform-webworker.d.ts +++ b/tools/public_api_guard/platform-webworker/platform-webworker.d.ts @@ -1,9 +1,12 @@ +/** @deprecated */ export declare function bootstrapWorkerUi(workerScriptUri: string, customProviders?: StaticProvider[]): Promise; +/** @deprecated */ export declare class ClientMessageBroker { runOnService(args: UiArguments, returnType: Type | SerializerTypes | null): Promise | null; } +/** @deprecated */ export declare class ClientMessageBrokerFactory { createMessageBroker(channel: string, runInZone?: boolean): ClientMessageBroker; } @@ -14,6 +17,7 @@ export declare class FnArg { constructor(value: any, type?: Type | SerializerTypes); } +/** @deprecated */ export declare abstract class MessageBus implements MessageBusSource, MessageBusSink { abstract attachToZone(zone: NgZone): void; abstract from(channel: string): EventEmitter; @@ -33,10 +37,12 @@ export interface MessageBusSource { initChannel(channel: string, runInZone: boolean): void; } +/** @deprecated */ export declare const platformWorkerApp: (extraProviders?: StaticProvider[] | undefined) => PlatformRef; export declare const platformWorkerUi: (extraProviders?: StaticProvider[] | undefined) => PlatformRef; +/** @deprecated */ export interface ReceivedMessage { args: any[]; id: string; @@ -44,16 +50,19 @@ export interface ReceivedMessage { type: string; } +/** @deprecated */ export declare const enum SerializerTypes { RENDERER_TYPE_2 = 0, PRIMITIVE = 1, RENDER_STORE_OBJECT = 2 } +/** @deprecated */ export declare class ServiceMessageBroker { registerMethod(methodName: string, signature: Array | SerializerTypes> | null, method: (..._: any[]) => Promise | void, returnType?: Type | SerializerTypes): void; } +/** @deprecated */ export declare class ServiceMessageBrokerFactory { createMessageBroker(channel: string, runInZone?: boolean): ServiceMessageBroker; } @@ -64,8 +73,10 @@ export declare class UiArguments { constructor(method: string, args?: FnArg[] | undefined); } +/** @deprecated */ export declare const VERSION: Version; +/** @deprecated */ export declare const WORKER_APP_LOCATION_PROVIDERS: ({ provide: typeof PlatformLocation; useClass: typeof WebWorkerPlatformLocation; @@ -86,7 +97,9 @@ export declare const WORKER_APP_LOCATION_PROVIDERS: ({ multi?: undefined; })[]; +/** @deprecated */ export declare const WORKER_UI_LOCATION_PROVIDERS: StaticProvider[]; +/** @deprecated */ export declare class WorkerAppModule { }