fix(webworkers): rename all web worker apis with "render" to "ui"

"render" is gramatically incorrect and confusing to developers who used this api.

Since webworker apis were exposed only in master, renaming these before the rc2 release
is not a breaking change
This commit is contained in:
Igor Minar 2016-06-15 08:25:31 -07:00
parent 2fd1e88199
commit 4fc37aeabd
17 changed files with 47 additions and 54 deletions

View File

@ -1,7 +1,7 @@
import {COMMON_DIRECTIVES, COMMON_PIPES} from '@angular/common'; import {COMMON_DIRECTIVES, COMMON_PIPES} from '@angular/common';
import {COMPILER_PROVIDERS, CompilerConfig, XHR} from '@angular/compiler'; import {COMPILER_PROVIDERS, CompilerConfig, XHR} from '@angular/compiler';
import {ApplicationRef, ComponentRef, PLATFORM_DIRECTIVES, PLATFORM_PIPES, ReflectiveInjector, Type, coreLoadAndBootstrap} from '@angular/core'; import {ApplicationRef, ComponentRef, PLATFORM_DIRECTIVES, PLATFORM_PIPES, ReflectiveInjector, Type, coreLoadAndBootstrap} from '@angular/core';
import {BROWSER_APP_PROVIDERS, WORKER_APP_APPLICATION_PROVIDERS, WORKER_RENDER_APPLICATION_PROVIDERS, WORKER_SCRIPT, browserPlatform, workerAppPlatform, workerRenderPlatform} from '@angular/platform-browser'; import {BROWSER_APP_PROVIDERS, WORKER_APP_APPLICATION_PROVIDERS, WORKER_SCRIPT, WORKER_UI_APPLICATION_PROVIDERS, browserPlatform, workerAppPlatform, workerUiPlatform} from '@angular/platform-browser';
import {ReflectionCapabilities, reflector} from './core_private'; import {ReflectionCapabilities, reflector} from './core_private';
import {PromiseWrapper} from './src/facade/async'; import {PromiseWrapper} from './src/facade/async';
@ -110,16 +110,16 @@ export function bootstrap(
} }
export function bootstrapRender( export function bootstrapWorkerUi(
workerScriptUri: string, workerScriptUri: string,
customProviders?: Array<any /*Type | Provider | any[]*/>): Promise<ApplicationRef> { customProviders?: Array<any /*Type | Provider | any[]*/>): Promise<ApplicationRef> {
var app = ReflectiveInjector.resolveAndCreate( var app = ReflectiveInjector.resolveAndCreate(
[ [
WORKER_RENDER_APPLICATION_PROVIDERS, BROWSER_APP_COMPILER_PROVIDERS, WORKER_UI_APPLICATION_PROVIDERS, BROWSER_APP_COMPILER_PROVIDERS,
{provide: WORKER_SCRIPT, useValue: workerScriptUri}, {provide: WORKER_SCRIPT, useValue: workerScriptUri},
isPresent(customProviders) ? customProviders : [] isPresent(customProviders) ? customProviders : []
], ],
workerRenderPlatform().injector); workerUiPlatform().injector);
// Return a promise so that we keep the same semantics as Dart, // Return a promise so that we keep the same semantics as Dart,
// and we might want to wait for the app side to come up // and we might want to wait for the app side to come up
// in the future... // in the future...
@ -141,7 +141,7 @@ const WORKER_APP_COMPILER_PROVIDERS: Array<any /*Type | Provider | any[]*/> = [
]; ];
export function bootstrapApp( export function bootstrapWorkerApp(
appComponentType: Type, appComponentType: Type,
customProviders?: Array<any /*Type | Provider | any[]*/>): Promise<ComponentRef<any>> { customProviders?: Array<any /*Type | Provider | any[]*/>): Promise<ComponentRef<any>> {
var appInjector = ReflectiveInjector.resolveAndCreate( var appInjector = ReflectiveInjector.resolveAndCreate(

View File

@ -18,7 +18,7 @@ export {ReceivedMessage, ServiceMessageBroker, ServiceMessageBrokerFactory} from
export {PRIMITIVE} from './src/web_workers/shared/serializer'; export {PRIMITIVE} from './src/web_workers/shared/serializer';
export * from './src/web_workers/shared/message_bus'; export * from './src/web_workers/shared/message_bus';
export {WORKER_APP_LOCATION_PROVIDERS} from './src/web_workers/worker/location_providers'; export {WORKER_APP_LOCATION_PROVIDERS} from './src/web_workers/worker/location_providers';
export {WORKER_RENDER_LOCATION_PROVIDERS} from './src/web_workers/ui/location_providers'; export {WORKER_UI_LOCATION_PROVIDERS} from './src/web_workers/ui/location_providers';
export * from './src/worker_render'; export * from './src/worker_render';
export * from './src/worker_app'; export * from './src/worker_app';

View File

@ -9,7 +9,7 @@ import {MessageBasedPlatformLocation} from './platform_location';
* A list of {@link Provider}s. To use the router in a Worker enabled application you must * 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. * include these providers when setting up the render thread.
*/ */
export const WORKER_RENDER_LOCATION_PROVIDERS = [ export const WORKER_UI_LOCATION_PROVIDERS = [
MessageBasedPlatformLocation, BrowserPlatformLocation, MessageBasedPlatformLocation, BrowserPlatformLocation,
{provide: APP_INITIALIZER, useFactory: initUiLocation, multi: true, deps: [Injector]} {provide: APP_INITIALIZER, useFactory: initUiLocation, multi: true, deps: [Injector]}
]; ];

View File

@ -50,22 +50,18 @@ export const WORKER_SCRIPT: OpaqueToken = new OpaqueToken('WebWorkerScript');
* *
* TODO(vicb): create an interface for startable services to implement * TODO(vicb): create an interface for startable services to implement
*/ */
export const WORKER_RENDER_STARTABLE_MESSAGING_SERVICE = export const WORKER_UI_STARTABLE_MESSAGING_SERVICE =
new OpaqueToken('WorkerRenderStartableMsgService'); new OpaqueToken('WorkerRenderStartableMsgService');
export const WORKER_RENDER_PLATFORM_PROVIDERS: Array<any /*Type | Provider | any[]*/> = [ export const WORKER_UI_PLATFORM_PROVIDERS: Array<any /*Type | Provider | any[]*/> = [
PLATFORM_COMMON_PROVIDERS, {provide: WORKER_RENDER_PLATFORM_MARKER, useValue: true}, PLATFORM_COMMON_PROVIDERS, {provide: WORKER_RENDER_PLATFORM_MARKER, useValue: true},
{provide: PLATFORM_INITIALIZER, useValue: initWebWorkerRenderPlatform, multi: true} {provide: PLATFORM_INITIALIZER, useValue: initWebWorkerRenderPlatform, multi: true}
]; ];
export const WORKER_RENDER_APPLICATION_PROVIDERS: Array<any /*Type | Provider | any[]*/> = [ export const WORKER_UI_APPLICATION_PROVIDERS: Array<any /*Type | Provider | any[]*/> = [
APPLICATION_COMMON_PROVIDERS, APPLICATION_COMMON_PROVIDERS,
MessageBasedRenderer, MessageBasedRenderer,
{ {provide: WORKER_UI_STARTABLE_MESSAGING_SERVICE, useExisting: MessageBasedRenderer, multi: true},
provide: WORKER_RENDER_STARTABLE_MESSAGING_SERVICE,
useExisting: MessageBasedRenderer,
multi: true
},
BROWSER_SANITIZATION_PROVIDERS, BROWSER_SANITIZATION_PROVIDERS,
{provide: ExceptionHandler, useFactory: _exceptionHandler, deps: []}, {provide: ExceptionHandler, useFactory: _exceptionHandler, deps: []},
{provide: DOCUMENT, useFactory: _document, deps: []}, {provide: DOCUMENT, useFactory: _document, deps: []},
@ -92,13 +88,13 @@ export const WORKER_RENDER_APPLICATION_PROVIDERS: Array<any /*Type | Provider |
{provide: MessageBus, useFactory: messageBusFactory, deps: [WebWorkerInstance]} {provide: MessageBus, useFactory: messageBusFactory, deps: [WebWorkerInstance]}
]; ];
export function initializeGenericWorkerRenderer(injector: Injector) { function initializeGenericWorkerRenderer(injector: Injector) {
var bus = injector.get(MessageBus); var bus = injector.get(MessageBus);
let zone = injector.get(NgZone); let zone = injector.get(NgZone);
bus.attachToZone(zone); bus.attachToZone(zone);
// initialize message services after the bus has been created // initialize message services after the bus has been created
let services = injector.get(WORKER_RENDER_STARTABLE_MESSAGING_SERVICE); let services = injector.get(WORKER_UI_STARTABLE_MESSAGING_SERVICE);
zone.runGuarded(() => { services.forEach((svc: any /** TODO #9100 */) => { svc.start(); }); }); zone.runGuarded(() => { services.forEach((svc: any /** TODO #9100 */) => { svc.start(); }); });
} }
@ -112,9 +108,9 @@ function initWebWorkerRenderPlatform(): void {
BrowserGetTestability.init(); BrowserGetTestability.init();
} }
export function workerRenderPlatform(): PlatformRef { export function workerUiPlatform(): PlatformRef {
if (isBlank(getPlatform())) { if (isBlank(getPlatform())) {
createPlatform(ReflectiveInjector.resolveAndCreate(WORKER_RENDER_PLATFORM_PROVIDERS)); createPlatform(ReflectiveInjector.resolveAndCreate(WORKER_UI_PLATFORM_PROVIDERS));
} }
return assertPlatform(WORKER_RENDER_PLATFORM_MARKER); return assertPlatform(WORKER_RENDER_PLATFORM_MARKER);
} }

View File

@ -1,6 +1,6 @@
import {ImageDemo} from './index_common'; import {ImageDemo} from './index_common';
import {bootstrapApp} from '@angular/platform-browser-dynamic'; import {bootstrapWorkerApp} from '@angular/platform-browser-dynamic';
export function main() { export function main() {
bootstrapApp(ImageDemo); bootstrapWorkerApp(ImageDemo);
} }

View File

@ -1,5 +1,5 @@
import {bootstrapRender} from '@angular/platform-browser-dynamic'; import {bootstrapWorkerUi} from '@angular/platform-browser-dynamic';
export function main() { export function main() {
bootstrapRender("loader.js"); bootstrapWorkerUi("loader.js");
} }

View File

@ -1,6 +1,6 @@
import {InputCmp} from './index_common'; import {InputCmp} from './index_common';
import {bootstrapApp} from '@angular/platform-browser-dynamic'; import {bootstrapWorkerApp} from '@angular/platform-browser-dynamic';
export function main() { export function main() {
bootstrapApp(InputCmp); bootstrapWorkerApp(InputCmp);
} }

View File

@ -1,5 +1,5 @@
import {bootstrapRender} from '@angular/platform-browser-dynamic'; import {bootstrapWorkerUi} from '@angular/platform-browser-dynamic';
export function main() { export function main() {
bootstrapRender("loader.js"); bootstrapWorkerUi("loader.js");
} }

View File

@ -1,6 +1,6 @@
import {HelloCmp} from './index_common'; import {HelloCmp} from './index_common';
import {bootstrapApp} from '@angular/platform-browser-dynamic'; import {bootstrapWorkerApp} from '@angular/platform-browser-dynamic';
export function main() { export function main() {
bootstrapApp(HelloCmp); bootstrapWorkerApp(HelloCmp);
} }

View File

@ -1,5 +1,5 @@
import {bootstrapRender} from '@angular/platform-browser-dynamic'; import {bootstrapWorkerUi} from '@angular/platform-browser-dynamic';
export function main() { export function main() {
bootstrapRender("loader.js"); bootstrapWorkerUi("loader.js");
} }

View File

@ -1,6 +1,6 @@
import {bootstrapApp} from '@angular/platform-browser-dynamic'; import {bootstrapWorkerApp} from '@angular/platform-browser-dynamic';
import {App} from './index_common'; import {App} from './index_common';
export function main() { export function main() {
bootstrapApp(App); bootstrapWorkerApp(App);
} }

View File

@ -1,11 +1,11 @@
import {ApplicationRef} from '@angular/core'; import {ApplicationRef} from '@angular/core';
import {UiArguments, FnArg, PRIMITIVE, ClientMessageBrokerFactory} from '@angular/platform-browser'; import {UiArguments, FnArg, PRIMITIVE, ClientMessageBrokerFactory} from '@angular/platform-browser';
import {bootstrapRender} from "@angular/platform-browser-dynamic"; import {bootstrapWorkerUi} from "@angular/platform-browser-dynamic";
const ECHO_CHANNEL = "ECHO"; const ECHO_CHANNEL = "ECHO";
export function main() { export function main() {
bootstrapRender("loader.js").then((ref) => afterBootstrap(ref)); bootstrapWorkerUi("loader.js").then((ref) => afterBootstrap(ref));
} }
function afterBootstrap(ref: ApplicationRef) { function afterBootstrap(ref: ApplicationRef) {

View File

@ -1,12 +1,12 @@
import {ROUTER_PROVIDERS} from '@angular/router-deprecated'; import {ROUTER_PROVIDERS} from '@angular/router-deprecated';
import {WORKER_APP_LOCATION_PROVIDERS} from '@angular/platform-browser'; import {WORKER_APP_LOCATION_PROVIDERS} from '@angular/platform-browser';
import {bootstrapApp} from '@angular/platform-browser-dynamic'; import {bootstrapWorkerApp} from '@angular/platform-browser-dynamic';
import {HashLocationStrategy, LocationStrategy} from '@angular/common'; import {HashLocationStrategy, LocationStrategy} from '@angular/common';
import {App} from './index_common'; import {App} from './index_common';
export function main() { export function main() {
bootstrapApp(App, [ bootstrapWorkerApp(App, [
ROUTER_PROVIDERS, ROUTER_PROVIDERS,
WORKER_APP_LOCATION_PROVIDERS, WORKER_APP_LOCATION_PROVIDERS,
{provide: LocationStrategy, useClass: HashLocationStrategy} {provide: LocationStrategy, useClass: HashLocationStrategy}

View File

@ -1,6 +1,6 @@
import {WORKER_RENDER_LOCATION_PROVIDERS} from '@angular/platform-browser'; import {WORKER_UI_LOCATION_PROVIDERS} from '@angular/platform-browser';
import {bootstrapRender} from "@angular/platform-browser-dynamic"; import {bootstrapWorkerUi} from "@angular/platform-browser-dynamic";
export function main() { export function main() {
bootstrapRender("loader.js", WORKER_RENDER_LOCATION_PROVIDERS); bootstrapWorkerUi("loader.js", WORKER_UI_LOCATION_PROVIDERS);
} }

View File

@ -1,6 +1,6 @@
import {TodoApp} from './index_common'; import {TodoApp} from './index_common';
import {bootstrapApp} from '@angular/platform-browser-dynamic'; import {bootstrapWorkerApp} from '@angular/platform-browser-dynamic';
export function main() { export function main() {
bootstrapApp(TodoApp); bootstrapWorkerApp(TodoApp);
} }

View File

@ -1,5 +1,5 @@
import {bootstrapRender} from '@angular/platform-browser-dynamic'; import {bootstrapWorkerUi} from '@angular/platform-browser-dynamic';
export function main() { export function main() {
bootstrapRender("loader.js"); bootstrapWorkerUi("loader.js");
} }

View File

@ -1051,8 +1051,6 @@ const COMMON = [
'Validators.nullValidator(c:AbstractControl):{[key:string]:boolean}', 'Validators.nullValidator(c:AbstractControl):{[key:string]:boolean}',
'Validators.pattern(pattern:string):ValidatorFn', 'Validators.pattern(pattern:string):ValidatorFn',
'Validators.required(control:AbstractControl):{[key:string]:boolean}', 'Validators.required(control:AbstractControl):{[key:string]:boolean}',
// TODO: rename to LocationChangeEvent
// TODO: rename to LocationChangeListener
]; ];
const COMMON_TESTING = [ const COMMON_TESTING = [
@ -1520,11 +1518,11 @@ const PLATFORM_BROWSER = [
'const WORKER_APP_APPLICATION_PROVIDERS:Array<any>', 'const WORKER_APP_APPLICATION_PROVIDERS:Array<any>',
'const WORKER_APP_LOCATION_PROVIDERS:any', 'const WORKER_APP_LOCATION_PROVIDERS:any',
'const WORKER_APP_PLATFORM_PROVIDERS:Array<any>', 'const WORKER_APP_PLATFORM_PROVIDERS:Array<any>',
'const WORKER_RENDER_APPLICATION_PROVIDERS:Array<any>',
'const WORKER_RENDER_LOCATION_PROVIDERS:any',
'const WORKER_RENDER_PLATFORM_PROVIDERS:Array<any>',
'const WORKER_RENDER_STARTABLE_MESSAGING_SERVICE:any',
'const WORKER_SCRIPT:OpaqueToken', 'const WORKER_SCRIPT:OpaqueToken',
'const WORKER_UI_APPLICATION_PROVIDERS:Array<any>',
'const WORKER_UI_LOCATION_PROVIDERS:any',
'const WORKER_UI_PLATFORM_PROVIDERS:Array<any>',
'const WORKER_UI_STARTABLE_MESSAGING_SERVICE:any',
'disableDebugTools():void', 'disableDebugTools():void',
'DomEventsPlugin', 'DomEventsPlugin',
'DomEventsPlugin.addEventListener(element:HTMLElement, eventName:string, handler:Function):Function', 'DomEventsPlugin.addEventListener(element:HTMLElement, eventName:string, handler:Function):Function',
@ -1551,7 +1549,6 @@ const PLATFORM_BROWSER = [
'HammerGestureConfig.buildHammer(element:HTMLElement):HammerInstance', 'HammerGestureConfig.buildHammer(element:HTMLElement):HammerInstance',
'HammerGestureConfig.events:string[]', 'HammerGestureConfig.events:string[]',
'HammerGestureConfig.overrides:{[key:string]:Object}', 'HammerGestureConfig.overrides:{[key:string]:Object}',
'initializeGenericWorkerRenderer(injector:Injector):any',
'KeyEventsPlugin', 'KeyEventsPlugin',
'KeyEventsPlugin.addEventListener(element:HTMLElement, eventName:string, handler:Function):Function', 'KeyEventsPlugin.addEventListener(element:HTMLElement, eventName:string, handler:Function):Function',
'KeyEventsPlugin.constructor()', 'KeyEventsPlugin.constructor()',
@ -1601,7 +1598,7 @@ const PLATFORM_BROWSER = [
'WebWorkerInstance.init(worker:Worker, bus:MessageBus):any', 'WebWorkerInstance.init(worker:Worker, bus:MessageBus):any',
'WebWorkerInstance.worker:Worker', 'WebWorkerInstance.worker:Worker',
'workerAppPlatform():PlatformRef', 'workerAppPlatform():PlatformRef',
'workerRenderPlatform():PlatformRef', 'workerUiPlatform():PlatformRef',
]; ];
const PLATFORM_BROWSER_TESTING = [ const PLATFORM_BROWSER_TESTING = [
@ -1648,8 +1645,8 @@ const PLATFORM_BROWSER_TESTING_E2E = [
const PLATFORM_BROWSER_DYNAMIC = [ const PLATFORM_BROWSER_DYNAMIC = [
'bootstrap(appComponentType:Type, customProviders?:Array<any>):Promise<ComponentRef<any>>', 'bootstrap(appComponentType:Type, customProviders?:Array<any>):Promise<ComponentRef<any>>',
'bootstrapApp(appComponentType:Type, customProviders?:Array<any>):Promise<ComponentRef<any>>', 'bootstrapWorkerApp(appComponentType:Type, customProviders?:Array<any>):Promise<ComponentRef<any>>',
'bootstrapRender(workerScriptUri:string, customProviders?:Array<any>):Promise<ApplicationRef>', 'bootstrapWorkerUi(workerScriptUri:string, customProviders?:Array<any>):Promise<ApplicationRef>',
'const BROWSER_APP_COMPILER_PROVIDERS:Array<any>', 'const BROWSER_APP_COMPILER_PROVIDERS:Array<any>',
'const CACHED_TEMPLATE_PROVIDER:Array<any>', 'const CACHED_TEMPLATE_PROVIDER:Array<any>',
]; ];