2016-06-23 09:47:54 -07:00
|
|
|
/**
|
|
|
|
|
* @license
|
|
|
|
|
* Copyright Google Inc. 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
|
|
|
|
|
*/
|
|
|
|
|
|
2016-08-23 15:41:05 -07:00
|
|
|
import {ResourceLoader, platformCoreDynamic} from '@angular/compiler';
|
2016-08-24 13:39:44 -07:00
|
|
|
import {COMPILER_OPTIONS, ClassProvider, ExistingProvider, FactoryProvider, PlatformRef, Provider, TypeProvider, ValueProvider, createPlatformFactory} from '@angular/core';
|
2016-08-23 15:41:05 -07:00
|
|
|
import {WORKER_SCRIPT, platformWorkerUi} from '@angular/platform-browser';
|
2016-06-08 16:38:52 -07:00
|
|
|
|
2016-07-18 03:50:31 -07:00
|
|
|
import {INTERNAL_BROWSER_DYNAMIC_PLATFORM_PROVIDERS} from './src/platform_providers';
|
2016-08-17 09:24:44 -07:00
|
|
|
import {CachedResourceLoader} from './src/resource_loader/resource_loader_cache';
|
|
|
|
|
import {ResourceLoaderImpl} from './src/resource_loader/resource_loader_impl';
|
2016-05-24 16:13:17 -07:00
|
|
|
|
2016-08-15 19:37:42 -07:00
|
|
|
|
|
|
|
|
|
2016-06-27 12:27:23 -07:00
|
|
|
/**
|
|
|
|
|
* @experimental
|
|
|
|
|
*/
|
2016-08-17 09:24:44 -07:00
|
|
|
export const RESOURCE_CACHE_PROVIDER: Provider[] =
|
|
|
|
|
[{provide: ResourceLoader, useClass: CachedResourceLoader}];
|
2016-06-10 10:21:53 -07:00
|
|
|
|
2016-07-08 10:47:17 -07:00
|
|
|
/**
|
2016-08-23 15:41:05 -07:00
|
|
|
* @stable
|
2016-07-08 10:47:17 -07:00
|
|
|
*/
|
2016-07-26 05:21:19 -07:00
|
|
|
export const platformBrowserDynamic = createPlatformFactory(
|
|
|
|
|
platformCoreDynamic, 'browserDynamic', INTERNAL_BROWSER_DYNAMIC_PLATFORM_PROVIDERS);
|
|
|
|
|
|
2016-06-15 17:12:22 -07:00
|
|
|
/**
|
2016-07-18 03:50:31 -07:00
|
|
|
* Bootstraps the worker ui.
|
|
|
|
|
*
|
2016-08-23 15:41:05 -07:00
|
|
|
* @experimental WebWorker support is currently experimental
|
2016-06-15 17:12:22 -07:00
|
|
|
*/
|
2016-06-15 08:25:31 -07:00
|
|
|
export function bootstrapWorkerUi(
|
2016-08-15 19:37:42 -07:00
|
|
|
workerScriptUri: string, customProviders: Provider[] = []): Promise<PlatformRef> {
|
2016-07-18 03:50:31 -07:00
|
|
|
// For now, just creates the worker ui platform...
|
2016-08-15 19:37:42 -07:00
|
|
|
return Promise.resolve(platformWorkerUi(([{
|
2016-07-18 03:50:31 -07:00
|
|
|
provide: WORKER_SCRIPT,
|
|
|
|
|
useValue: workerScriptUri,
|
2016-08-15 19:37:42 -07:00
|
|
|
}] as Provider[])
|
|
|
|
|
.concat(customProviders)));
|
2016-06-10 10:21:53 -07:00
|
|
|
}
|
|
|
|
|
|
2016-06-15 17:12:22 -07:00
|
|
|
/**
|
2016-08-23 15:41:05 -07:00
|
|
|
* @experimental WebWorker support is currently experimental
|
2016-06-15 17:12:22 -07:00
|
|
|
*/
|
2016-08-17 09:24:44 -07:00
|
|
|
export const platformWorkerAppDynamic = createPlatformFactory(
|
|
|
|
|
platformCoreDynamic, 'workerAppDynamic', [{
|
|
|
|
|
provide: COMPILER_OPTIONS,
|
|
|
|
|
useValue: {providers: [{provide: ResourceLoader, useClass: ResourceLoaderImpl}]},
|
|
|
|
|
multi: true
|
|
|
|
|
}]);
|
2016-06-10 10:21:53 -07:00
|
|
|
|
2016-06-30 13:07:17 -07:00
|
|
|
function normalizeArray(arr: any[]): any[] {
|
|
|
|
|
return arr ? arr : [];
|
2016-07-18 03:50:31 -07:00
|
|
|
}
|