perf: switch angular to use StaticInjector instead of ReflectiveInjector
This change allows ReflectiveInjector to be tree shaken resulting in not needed Reflect polyfil and smaller bundles. Code savings for HelloWorld using Closure: Reflective: bundle.js: 105,864(34,190 gzip) Static: bundle.js: 154,889(33,555 gzip) 645( 2%) BREAKING CHANGE: `platformXXXX()` no longer accepts providers which depend on reflection. Specifically the method signature when from `Provider[]` to `StaticProvider[]`. Example: Before: ``` [ MyClass, {provide: ClassA, useClass: SubClassA} ] ``` After: ``` [ {provide: MyClass, deps: [Dep1,...]}, {provide: ClassA, useClass: SubClassA, deps: [Dep1,...]} ] ``` NOTE: This only applies to platform creation and providers for the JIT compiler. It does not apply to `@Compotent` or `@NgModule` provides declarations. Benchpress note: Previously Benchpress also supported reflective provides, which now require static providers. DEPRECATION: - `ReflectiveInjector` is now deprecated as it will be remove. Use `Injector.create` as a replacement. closes #18496
This commit is contained in:
parent
d9d00bd9b5
commit
fcadbf4bf6
@ -11,7 +11,7 @@ const yargs = require('yargs');
|
|||||||
const nodeUuid = require('node-uuid');
|
const nodeUuid = require('node-uuid');
|
||||||
import * as fs from 'fs-extra';
|
import * as fs from 'fs-extra';
|
||||||
|
|
||||||
import {SeleniumWebDriverAdapter, Options, JsonFileReporter, Validator, RegressionSlopeValidator, ConsoleReporter, SizeValidator, MultiReporter, MultiMetric, Runner, Provider} from '@angular/benchpress';
|
import {SeleniumWebDriverAdapter, Options, JsonFileReporter, Validator, RegressionSlopeValidator, ConsoleReporter, SizeValidator, MultiReporter, MultiMetric, Runner, StaticProvider} from '@angular/benchpress';
|
||||||
import {readCommandLine as readE2eCommandLine, openBrowser} from './e2e_util';
|
import {readCommandLine as readE2eCommandLine, openBrowser} from './e2e_util';
|
||||||
|
|
||||||
let cmdArgs: {'sample-size': number, 'force-gc': boolean, 'dryrun': boolean, 'bundles': boolean};
|
let cmdArgs: {'sample-size': number, 'force-gc': boolean, 'dryrun': boolean, 'bundles': boolean};
|
||||||
@ -59,7 +59,7 @@ function createBenchpressRunner(): Runner {
|
|||||||
}
|
}
|
||||||
const resultsFolder = './dist/benchmark_results';
|
const resultsFolder = './dist/benchmark_results';
|
||||||
fs.ensureDirSync(resultsFolder);
|
fs.ensureDirSync(resultsFolder);
|
||||||
const providers: Provider[] = [
|
const providers: StaticProvider[] = [
|
||||||
SeleniumWebDriverAdapter.PROTRACTOR_PROVIDERS,
|
SeleniumWebDriverAdapter.PROTRACTOR_PROVIDERS,
|
||||||
{provide: Options.FORCE_GC, useValue: cmdArgs['force-gc']},
|
{provide: Options.FORCE_GC, useValue: cmdArgs['force-gc']},
|
||||||
{provide: Options.DEFAULT_DESCRIPTION, useValue: {'runId': runId}}, JsonFileReporter.PROVIDERS,
|
{provide: Options.DEFAULT_DESCRIPTION, useValue: {'runId': runId}}, JsonFileReporter.PROVIDERS,
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
# How to run the examples locally
|
# How to run the examples locally
|
||||||
|
|
||||||
|
```
|
||||||
$ cp -r ./modules/playground ./dist/all/
|
$ cp -r ./modules/playground ./dist/all/
|
||||||
$ ./node_modules/.bin/tsc -p modules --emitDecoratorMetadata -w
|
$ ./node_modules/.bin/tsc -p modules --emitDecoratorMetadata -w
|
||||||
$ gulp serve
|
$ gulp serve
|
||||||
$ open http://localhost:8000/all/playground/src/hello_world/index.html?bundles=false
|
$ open http://localhost:8000/all/playground/src/hello_world/index.html?bundles=false
|
||||||
|
```
|
@ -9,7 +9,7 @@
|
|||||||
// Must be imported first, because Angular decorators throw on load.
|
// Must be imported first, because Angular decorators throw on load.
|
||||||
import 'reflect-metadata';
|
import 'reflect-metadata';
|
||||||
|
|
||||||
export {InjectionToken, Injector, Provider, ReflectiveInjector} from '@angular/core';
|
export {InjectionToken, Injector, Provider, ReflectiveInjector, StaticProvider} from '@angular/core';
|
||||||
export {Options} from './src/common_options';
|
export {Options} from './src/common_options';
|
||||||
export {MeasureValues} from './src/measure_values';
|
export {MeasureValues} from './src/measure_values';
|
||||||
export {Metric} from './src/metric';
|
export {Metric} from './src/metric';
|
||||||
|
@ -20,7 +20,14 @@ import {PerfLogEvent, PerfLogFeatures, WebDriverExtension} from '../web_driver_e
|
|||||||
export class PerflogMetric extends Metric {
|
export class PerflogMetric extends Metric {
|
||||||
static SET_TIMEOUT = new InjectionToken('PerflogMetric.setTimeout');
|
static SET_TIMEOUT = new InjectionToken('PerflogMetric.setTimeout');
|
||||||
static PROVIDERS = [
|
static PROVIDERS = [
|
||||||
PerflogMetric, {
|
{
|
||||||
|
provide: PerflogMetric,
|
||||||
|
deps: [
|
||||||
|
WebDriverExtension, PerflogMetric.SET_TIMEOUT, Options.MICRO_METRICS, Options.FORCE_GC,
|
||||||
|
Options.CAPTURE_FRAMES, Options.RECEIVED_DATA, Options.REQUEST_COUNT
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
provide: PerflogMetric.SET_TIMEOUT,
|
provide: PerflogMetric.SET_TIMEOUT,
|
||||||
useValue: (fn: Function, millis: number) => <any>setTimeout(fn, millis)
|
useValue: (fn: Function, millis: number) => <any>setTimeout(fn, millis)
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
* found in the LICENSE file at https://angular.io/license
|
* found in the LICENSE file at https://angular.io/license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {Inject, Injectable} from '@angular/core';
|
import {Inject, Injectable, StaticProvider} from '@angular/core';
|
||||||
|
|
||||||
import {Options} from '../common_options';
|
import {Options} from '../common_options';
|
||||||
import {Metric} from '../metric';
|
import {Metric} from '../metric';
|
||||||
@ -14,7 +14,8 @@ import {WebDriverAdapter} from '../web_driver_adapter';
|
|||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class UserMetric extends Metric {
|
export class UserMetric extends Metric {
|
||||||
static PROVIDERS = [UserMetric];
|
static PROVIDERS =
|
||||||
|
<StaticProvider[]>[{provide: UserMetric, deps: [Options.USER_METRICS, WebDriverAdapter]}];
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@Inject(Options.USER_METRICS) private _userMetrics: {[key: string]: string},
|
@Inject(Options.USER_METRICS) private _userMetrics: {[key: string]: string},
|
||||||
|
@ -22,7 +22,11 @@ export class ConsoleReporter extends Reporter {
|
|||||||
static PRINT = new InjectionToken('ConsoleReporter.print');
|
static PRINT = new InjectionToken('ConsoleReporter.print');
|
||||||
static COLUMN_WIDTH = new InjectionToken('ConsoleReporter.columnWidth');
|
static COLUMN_WIDTH = new InjectionToken('ConsoleReporter.columnWidth');
|
||||||
static PROVIDERS = [
|
static PROVIDERS = [
|
||||||
ConsoleReporter, {provide: ConsoleReporter.COLUMN_WIDTH, useValue: 18}, {
|
{
|
||||||
|
provide: ConsoleReporter,
|
||||||
|
deps: [ConsoleReporter.COLUMN_WIDTH, SampleDescription, ConsoleReporter.PRINT]
|
||||||
|
},
|
||||||
|
{provide: ConsoleReporter.COLUMN_WIDTH, useValue: 18}, {
|
||||||
provide: ConsoleReporter.PRINT,
|
provide: ConsoleReporter.PRINT,
|
||||||
useValue: function(v: any) {
|
useValue: function(v: any) {
|
||||||
// tslint:disable-next-line:no-console
|
// tslint:disable-next-line:no-console
|
||||||
|
@ -22,7 +22,13 @@ import {formatStats, sortedProps} from './util';
|
|||||||
@Injectable()
|
@Injectable()
|
||||||
export class JsonFileReporter extends Reporter {
|
export class JsonFileReporter extends Reporter {
|
||||||
static PATH = new InjectionToken('JsonFileReporter.path');
|
static PATH = new InjectionToken('JsonFileReporter.path');
|
||||||
static PROVIDERS = [JsonFileReporter, {provide: JsonFileReporter.PATH, useValue: '.'}];
|
static PROVIDERS = [
|
||||||
|
{
|
||||||
|
provide: JsonFileReporter,
|
||||||
|
deps: [SampleDescription, JsonFileReporter.PATH, Options.WRITE_FILE, Options.NOW]
|
||||||
|
},
|
||||||
|
{provide: JsonFileReporter.PATH, useValue: '.'}
|
||||||
|
];
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private _description: SampleDescription, @Inject(JsonFileReporter.PATH) private _path: string,
|
private _description: SampleDescription, @Inject(JsonFileReporter.PATH) private _path: string,
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
* found in the LICENSE file at https://angular.io/license
|
* found in the LICENSE file at https://angular.io/license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {Provider, ReflectiveInjector} from '@angular/core';
|
import {Injector, StaticProvider} from '@angular/core';
|
||||||
|
|
||||||
import {Options} from './common_options';
|
import {Options} from './common_options';
|
||||||
import {Metric} from './metric';
|
import {Metric} from './metric';
|
||||||
@ -34,17 +34,17 @@ import {IOsDriverExtension} from './webdriver/ios_driver_extension';
|
|||||||
* It provides defaults, creates the injector and calls the sampler.
|
* It provides defaults, creates the injector and calls the sampler.
|
||||||
*/
|
*/
|
||||||
export class Runner {
|
export class Runner {
|
||||||
constructor(private _defaultProviders: Provider[] = []) {}
|
constructor(private _defaultProviders: StaticProvider[] = []) {}
|
||||||
|
|
||||||
sample({id, execute, prepare, microMetrics, providers, userMetrics}: {
|
sample({id, execute, prepare, microMetrics, providers, userMetrics}: {
|
||||||
id: string,
|
id: string,
|
||||||
execute?: Function,
|
execute?: Function,
|
||||||
prepare?: Function,
|
prepare?: Function,
|
||||||
microMetrics?: {[key: string]: string},
|
microMetrics?: {[key: string]: string},
|
||||||
providers?: Provider[],
|
providers?: StaticProvider[],
|
||||||
userMetrics?: {[key: string]: string}
|
userMetrics?: {[key: string]: string}
|
||||||
}): Promise<SampleState> {
|
}): Promise<SampleState> {
|
||||||
const sampleProviders: Provider[] = [
|
const sampleProviders: StaticProvider[] = [
|
||||||
_DEFAULT_PROVIDERS, this._defaultProviders, {provide: Options.SAMPLE_ID, useValue: id},
|
_DEFAULT_PROVIDERS, this._defaultProviders, {provide: Options.SAMPLE_ID, useValue: id},
|
||||||
{provide: Options.EXECUTE, useValue: execute}
|
{provide: Options.EXECUTE, useValue: execute}
|
||||||
];
|
];
|
||||||
@ -61,7 +61,7 @@ export class Runner {
|
|||||||
sampleProviders.push(providers);
|
sampleProviders.push(providers);
|
||||||
}
|
}
|
||||||
|
|
||||||
const inj = ReflectiveInjector.resolveAndCreate(sampleProviders);
|
const inj = Injector.create(sampleProviders);
|
||||||
const adapter: WebDriverAdapter = inj.get(WebDriverAdapter);
|
const adapter: WebDriverAdapter = inj.get(WebDriverAdapter);
|
||||||
|
|
||||||
return Promise
|
return Promise
|
||||||
@ -75,7 +75,7 @@ export class Runner {
|
|||||||
// Only WebDriverAdapter is reused.
|
// Only WebDriverAdapter is reused.
|
||||||
// TODO vsavkin consider changing it when toAsyncFactory is added back or when child
|
// TODO vsavkin consider changing it when toAsyncFactory is added back or when child
|
||||||
// injectors are handled better.
|
// injectors are handled better.
|
||||||
const injector = ReflectiveInjector.resolveAndCreate([
|
const injector = Injector.create([
|
||||||
sampleProviders, {provide: Options.CAPABILITIES, useValue: capabilities},
|
sampleProviders, {provide: Options.CAPABILITIES, useValue: capabilities},
|
||||||
{provide: Options.USER_AGENT, useValue: userAgent},
|
{provide: Options.USER_AGENT, useValue: userAgent},
|
||||||
{provide: WebDriverAdapter, useValue: adapter}
|
{provide: WebDriverAdapter, useValue: adapter}
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
* found in the LICENSE file at https://angular.io/license
|
* found in the LICENSE file at https://angular.io/license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {Inject, Injectable} from '@angular/core';
|
import {Inject, Injectable, StaticProvider} from '@angular/core';
|
||||||
|
|
||||||
import {Options} from './common_options';
|
import {Options} from './common_options';
|
||||||
import {MeasureValues} from './measure_values';
|
import {MeasureValues} from './measure_values';
|
||||||
@ -26,8 +26,12 @@ import {WebDriverAdapter} from './web_driver_adapter';
|
|||||||
*/
|
*/
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class Sampler {
|
export class Sampler {
|
||||||
static PROVIDERS = [Sampler];
|
static PROVIDERS = <StaticProvider[]>[{
|
||||||
|
provide: Sampler,
|
||||||
|
deps: [
|
||||||
|
WebDriverAdapter, Metric, Reporter, Validator, Options.PREPARE, Options.EXECUTE, Options.NOW
|
||||||
|
]
|
||||||
|
}];
|
||||||
constructor(
|
constructor(
|
||||||
private _driver: WebDriverAdapter, private _metric: Metric, private _reporter: Reporter,
|
private _driver: WebDriverAdapter, private _metric: Metric, private _reporter: Reporter,
|
||||||
private _validator: Validator, @Inject(Options.PREPARE) private _prepare: Function,
|
private _validator: Validator, @Inject(Options.PREPARE) private _prepare: Function,
|
||||||
|
@ -21,7 +21,11 @@ export class RegressionSlopeValidator extends Validator {
|
|||||||
static SAMPLE_SIZE = new InjectionToken('RegressionSlopeValidator.sampleSize');
|
static SAMPLE_SIZE = new InjectionToken('RegressionSlopeValidator.sampleSize');
|
||||||
static METRIC = new InjectionToken('RegressionSlopeValidator.metric');
|
static METRIC = new InjectionToken('RegressionSlopeValidator.metric');
|
||||||
static PROVIDERS = [
|
static PROVIDERS = [
|
||||||
RegressionSlopeValidator, {provide: RegressionSlopeValidator.SAMPLE_SIZE, useValue: 10},
|
{
|
||||||
|
provide: RegressionSlopeValidator,
|
||||||
|
deps: [RegressionSlopeValidator.SAMPLE_SIZE, RegressionSlopeValidator.METRIC]
|
||||||
|
},
|
||||||
|
{provide: RegressionSlopeValidator.SAMPLE_SIZE, useValue: 10},
|
||||||
{provide: RegressionSlopeValidator.METRIC, useValue: 'scriptTime'}
|
{provide: RegressionSlopeValidator.METRIC, useValue: 'scriptTime'}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -17,7 +17,10 @@ import {Validator} from '../validator';
|
|||||||
@Injectable()
|
@Injectable()
|
||||||
export class SizeValidator extends Validator {
|
export class SizeValidator extends Validator {
|
||||||
static SAMPLE_SIZE = new InjectionToken('SizeValidator.sampleSize');
|
static SAMPLE_SIZE = new InjectionToken('SizeValidator.sampleSize');
|
||||||
static PROVIDERS = [SizeValidator, {provide: SizeValidator.SAMPLE_SIZE, useValue: 10}];
|
static PROVIDERS = [
|
||||||
|
{provide: SizeValidator, deps: [SizeValidator.SAMPLE_SIZE]},
|
||||||
|
{provide: SizeValidator.SAMPLE_SIZE, useValue: 10}
|
||||||
|
];
|
||||||
|
|
||||||
constructor(@Inject(SizeValidator.SAMPLE_SIZE) private _sampleSize: number) { super(); }
|
constructor(@Inject(SizeValidator.SAMPLE_SIZE) private _sampleSize: number) { super(); }
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
* found in the LICENSE file at https://angular.io/license
|
* found in the LICENSE file at https://angular.io/license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {Inject, Injectable} from '@angular/core';
|
import {Inject, Injectable, StaticProvider} from '@angular/core';
|
||||||
|
|
||||||
import {Options} from '../common_options';
|
import {Options} from '../common_options';
|
||||||
import {WebDriverAdapter} from '../web_driver_adapter';
|
import {WebDriverAdapter} from '../web_driver_adapter';
|
||||||
@ -21,7 +21,10 @@ import {PerfLogEvent, PerfLogFeatures, WebDriverExtension} from '../web_driver_e
|
|||||||
*/
|
*/
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class ChromeDriverExtension extends WebDriverExtension {
|
export class ChromeDriverExtension extends WebDriverExtension {
|
||||||
static PROVIDERS = [ChromeDriverExtension];
|
static PROVIDERS = <StaticProvider>[{
|
||||||
|
provide: ChromeDriverExtension,
|
||||||
|
deps: [WebDriverAdapter, Options.USER_AGENT]
|
||||||
|
}];
|
||||||
|
|
||||||
private _majorChromeVersion: number;
|
private _majorChromeVersion: number;
|
||||||
private _firstRun = true;
|
private _firstRun = true;
|
||||||
|
@ -13,7 +13,7 @@ import {PerfLogEvent, PerfLogFeatures, WebDriverExtension} from '../web_driver_e
|
|||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class FirefoxDriverExtension extends WebDriverExtension {
|
export class FirefoxDriverExtension extends WebDriverExtension {
|
||||||
static PROVIDERS = [FirefoxDriverExtension];
|
static PROVIDERS = [{provide: FirefoxDriverExtension, deps: [WebDriverAdapter]}];
|
||||||
|
|
||||||
private _profilerStarted: boolean;
|
private _profilerStarted: boolean;
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ import {PerfLogEvent, PerfLogFeatures, WebDriverExtension} from '../web_driver_e
|
|||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class IOsDriverExtension extends WebDriverExtension {
|
export class IOsDriverExtension extends WebDriverExtension {
|
||||||
static PROVIDERS = [IOsDriverExtension];
|
static PROVIDERS = [{provide: IOsDriverExtension, deps: [WebDriverAdapter]}];
|
||||||
|
|
||||||
constructor(private _driver: WebDriverAdapter) { super(); }
|
constructor(private _driver: WebDriverAdapter) { super(); }
|
||||||
|
|
||||||
|
@ -6,15 +6,19 @@
|
|||||||
* found in the LICENSE file at https://angular.io/license
|
* found in the LICENSE file at https://angular.io/license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import {StaticProvider} from '@angular/core';
|
||||||
|
|
||||||
import {WebDriverAdapter} from '../web_driver_adapter';
|
import {WebDriverAdapter} from '../web_driver_adapter';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adapter for the selenium-webdriver.
|
* Adapter for the selenium-webdriver.
|
||||||
*/
|
*/
|
||||||
export class SeleniumWebDriverAdapter extends WebDriverAdapter {
|
export class SeleniumWebDriverAdapter extends WebDriverAdapter {
|
||||||
static PROTRACTOR_PROVIDERS = [{
|
static PROTRACTOR_PROVIDERS = <StaticProvider[]>[{
|
||||||
provide: WebDriverAdapter,
|
provide: WebDriverAdapter,
|
||||||
useFactory: () => new SeleniumWebDriverAdapter((<any>global).browser)
|
useFactory: () => new SeleniumWebDriverAdapter((<any>global).browser),
|
||||||
|
deps: []
|
||||||
}];
|
}];
|
||||||
|
|
||||||
constructor(private _driver: any) { super(); }
|
constructor(private _driver: any) { super(); }
|
||||||
|
@ -7,12 +7,13 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import {AsyncTestCompleter, describe, expect, inject, it} from '@angular/core/testing/src/testing_internal';
|
import {AsyncTestCompleter, describe, expect, inject, it} from '@angular/core/testing/src/testing_internal';
|
||||||
import {Metric, MultiMetric, ReflectiveInjector} from '../../index';
|
|
||||||
|
import {Injector, Metric, MultiMetric} from '../../index';
|
||||||
|
|
||||||
export function main() {
|
export function main() {
|
||||||
function createMetric(ids: any[]) {
|
function createMetric(ids: any[]) {
|
||||||
const m = ReflectiveInjector
|
const m = Injector
|
||||||
.resolveAndCreate([
|
.create([
|
||||||
ids.map(id => ({provide: id, useValue: new MockMetric(id)})),
|
ids.map(id => ({provide: id, useValue: new MockMetric(id)})),
|
||||||
MultiMetric.provideWith(ids)
|
MultiMetric.provideWith(ids)
|
||||||
])
|
])
|
||||||
|
@ -6,10 +6,10 @@
|
|||||||
* found in the LICENSE file at https://angular.io/license
|
* found in the LICENSE file at https://angular.io/license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {Provider} from '@angular/core';
|
import {StaticProvider} from '@angular/core';
|
||||||
import {AsyncTestCompleter, beforeEach, describe, expect, inject, it} from '@angular/core/testing/src/testing_internal';
|
import {AsyncTestCompleter, beforeEach, describe, expect, inject, it} from '@angular/core/testing/src/testing_internal';
|
||||||
|
|
||||||
import {Metric, Options, PerfLogEvent, PerfLogFeatures, PerflogMetric, ReflectiveInjector, WebDriverExtension} from '../../index';
|
import {Injector, Metric, Options, PerfLogEvent, PerfLogFeatures, PerflogMetric, WebDriverExtension} from '../../index';
|
||||||
import {TraceEventFactory} from '../trace_event_factory';
|
import {TraceEventFactory} from '../trace_event_factory';
|
||||||
|
|
||||||
export function main() {
|
export function main() {
|
||||||
@ -33,7 +33,7 @@ export function main() {
|
|||||||
if (!microMetrics) {
|
if (!microMetrics) {
|
||||||
microMetrics = {};
|
microMetrics = {};
|
||||||
}
|
}
|
||||||
const providers: Provider[] = [
|
const providers: StaticProvider[] = [
|
||||||
Options.DEFAULT_PROVIDERS, PerflogMetric.PROVIDERS,
|
Options.DEFAULT_PROVIDERS, PerflogMetric.PROVIDERS,
|
||||||
{provide: Options.MICRO_METRICS, useValue: microMetrics}, {
|
{provide: Options.MICRO_METRICS, useValue: microMetrics}, {
|
||||||
provide: PerflogMetric.SET_TIMEOUT,
|
provide: PerflogMetric.SET_TIMEOUT,
|
||||||
@ -59,7 +59,7 @@ export function main() {
|
|||||||
if (requestCount != null) {
|
if (requestCount != null) {
|
||||||
providers.push({provide: Options.REQUEST_COUNT, useValue: requestCount});
|
providers.push({provide: Options.REQUEST_COUNT, useValue: requestCount});
|
||||||
}
|
}
|
||||||
return ReflectiveInjector.resolveAndCreate(providers).get(PerflogMetric);
|
return Injector.create(providers).get(PerflogMetric);
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('perflog metric', () => {
|
describe('perflog metric', () => {
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
* found in the LICENSE file at https://angular.io/license
|
* found in the LICENSE file at https://angular.io/license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {Provider, ReflectiveInjector} from '@angular/core';
|
import {Injector, StaticProvider} from '@angular/core';
|
||||||
import {AsyncTestCompleter, describe, expect, inject, it} from '@angular/core/testing/src/testing_internal';
|
import {AsyncTestCompleter, describe, expect, inject, it} from '@angular/core/testing/src/testing_internal';
|
||||||
|
|
||||||
import {Options, PerfLogEvent, PerfLogFeatures, UserMetric, WebDriverAdapter} from '../../index';
|
import {Options, PerfLogEvent, PerfLogFeatures, UserMetric, WebDriverAdapter} from '../../index';
|
||||||
@ -25,12 +25,12 @@ export function main() {
|
|||||||
userMetrics = {};
|
userMetrics = {};
|
||||||
}
|
}
|
||||||
wdAdapter = new MockDriverAdapter();
|
wdAdapter = new MockDriverAdapter();
|
||||||
const providers: Provider[] = [
|
const providers: StaticProvider[] = [
|
||||||
Options.DEFAULT_PROVIDERS, UserMetric.PROVIDERS,
|
Options.DEFAULT_PROVIDERS, UserMetric.PROVIDERS,
|
||||||
{provide: Options.USER_METRICS, useValue: userMetrics},
|
{provide: Options.USER_METRICS, useValue: userMetrics},
|
||||||
{provide: WebDriverAdapter, useValue: wdAdapter}
|
{provide: WebDriverAdapter, useValue: wdAdapter}
|
||||||
];
|
];
|
||||||
return ReflectiveInjector.resolveAndCreate(providers).get(UserMetric);
|
return Injector.create(providers).get(UserMetric);
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('user metric', () => {
|
describe('user metric', () => {
|
||||||
|
@ -6,10 +6,10 @@
|
|||||||
* found in the LICENSE file at https://angular.io/license
|
* found in the LICENSE file at https://angular.io/license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {Provider} from '@angular/core';
|
import {StaticProvider} from '@angular/core';
|
||||||
import {describe, expect, it} from '@angular/core/testing/src/testing_internal';
|
import {describe, expect, it} from '@angular/core/testing/src/testing_internal';
|
||||||
|
|
||||||
import {ConsoleReporter, MeasureValues, ReflectiveInjector, SampleDescription} from '../../index';
|
import {ConsoleReporter, Injector, MeasureValues, SampleDescription} from '../../index';
|
||||||
|
|
||||||
export function main() {
|
export function main() {
|
||||||
describe('console reporter', () => {
|
describe('console reporter', () => {
|
||||||
@ -30,7 +30,7 @@ export function main() {
|
|||||||
if (sampleId == null) {
|
if (sampleId == null) {
|
||||||
sampleId = 'null';
|
sampleId = 'null';
|
||||||
}
|
}
|
||||||
const providers: Provider[] = [
|
const providers: StaticProvider[] = [
|
||||||
ConsoleReporter.PROVIDERS, {
|
ConsoleReporter.PROVIDERS, {
|
||||||
provide: SampleDescription,
|
provide: SampleDescription,
|
||||||
useValue: new SampleDescription(sampleId, descriptions, metrics !)
|
useValue: new SampleDescription(sampleId, descriptions, metrics !)
|
||||||
@ -40,7 +40,7 @@ export function main() {
|
|||||||
if (columnWidth != null) {
|
if (columnWidth != null) {
|
||||||
providers.push({provide: ConsoleReporter.COLUMN_WIDTH, useValue: columnWidth});
|
providers.push({provide: ConsoleReporter.COLUMN_WIDTH, useValue: columnWidth});
|
||||||
}
|
}
|
||||||
reporter = ReflectiveInjector.resolveAndCreate(providers).get(ConsoleReporter);
|
reporter = Injector.create(providers).get(ConsoleReporter);
|
||||||
}
|
}
|
||||||
|
|
||||||
it('should print the sample id, description and table header', () => {
|
it('should print the sample id, description and table header', () => {
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
import {AsyncTestCompleter, describe, expect, inject, it} from '@angular/core/testing/src/testing_internal';
|
import {AsyncTestCompleter, describe, expect, inject, it} from '@angular/core/testing/src/testing_internal';
|
||||||
|
|
||||||
import {JsonFileReporter, MeasureValues, Options, ReflectiveInjector, SampleDescription} from '../../index';
|
import {Injector, JsonFileReporter, MeasureValues, Options, SampleDescription} from '../../index';
|
||||||
|
|
||||||
export function main() {
|
export function main() {
|
||||||
describe('file reporter', () => {
|
describe('file reporter', () => {
|
||||||
@ -34,7 +34,7 @@ export function main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
return ReflectiveInjector.resolveAndCreate(providers).get(JsonFileReporter);
|
return Injector.create(providers).get(JsonFileReporter);
|
||||||
}
|
}
|
||||||
|
|
||||||
it('should write all data into a file',
|
it('should write all data into a file',
|
||||||
|
@ -8,12 +8,12 @@
|
|||||||
|
|
||||||
import {AsyncTestCompleter, describe, expect, inject, it} from '@angular/core/testing/src/testing_internal';
|
import {AsyncTestCompleter, describe, expect, inject, it} from '@angular/core/testing/src/testing_internal';
|
||||||
|
|
||||||
import {MeasureValues, MultiReporter, ReflectiveInjector, Reporter} from '../../index';
|
import {Injector, MeasureValues, MultiReporter, Reporter} from '../../index';
|
||||||
|
|
||||||
export function main() {
|
export function main() {
|
||||||
function createReporters(ids: any[]) {
|
function createReporters(ids: any[]) {
|
||||||
const r = ReflectiveInjector
|
const r = Injector
|
||||||
.resolveAndCreate([
|
.create([
|
||||||
ids.map(id => ({provide: id, useValue: new MockReporter(id)})),
|
ids.map(id => ({provide: id, useValue: new MockReporter(id)})),
|
||||||
MultiReporter.provideWith(ids)
|
MultiReporter.provideWith(ids)
|
||||||
])
|
])
|
||||||
|
@ -8,11 +8,11 @@
|
|||||||
|
|
||||||
import {AsyncTestCompleter, describe, expect, inject, it} from '@angular/core/testing/src/testing_internal';
|
import {AsyncTestCompleter, describe, expect, inject, it} from '@angular/core/testing/src/testing_internal';
|
||||||
|
|
||||||
import {Injector, Metric, Options, ReflectiveInjector, Runner, SampleDescription, SampleState, Sampler, Validator, WebDriverAdapter} from '../index';
|
import {Injector, Metric, Options, Runner, SampleDescription, SampleState, Sampler, Validator, WebDriverAdapter} from '../index';
|
||||||
|
|
||||||
export function main() {
|
export function main() {
|
||||||
describe('runner', () => {
|
describe('runner', () => {
|
||||||
let injector: ReflectiveInjector;
|
let injector: Injector;
|
||||||
let runner: Runner;
|
let runner: Runner;
|
||||||
|
|
||||||
function createRunner(defaultProviders?: any[]): Runner {
|
function createRunner(defaultProviders?: any[]): Runner {
|
||||||
@ -22,7 +22,7 @@ export function main() {
|
|||||||
runner = new Runner([
|
runner = new Runner([
|
||||||
defaultProviders, {
|
defaultProviders, {
|
||||||
provide: Sampler,
|
provide: Sampler,
|
||||||
useFactory: (_injector: ReflectiveInjector) => {
|
useFactory: (_injector: Injector) => {
|
||||||
injector = _injector;
|
injector = _injector;
|
||||||
return new MockSampler();
|
return new MockSampler();
|
||||||
},
|
},
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
import {AsyncTestCompleter, describe, expect, inject, it} from '@angular/core/testing/src/testing_internal';
|
import {AsyncTestCompleter, describe, expect, inject, it} from '@angular/core/testing/src/testing_internal';
|
||||||
|
|
||||||
import {MeasureValues, Metric, Options, ReflectiveInjector, Reporter, Sampler, Validator, WebDriverAdapter} from '../index';
|
import {Injector, MeasureValues, Metric, Options, Reporter, Sampler, Validator, WebDriverAdapter} from '../index';
|
||||||
|
|
||||||
export function main() {
|
export function main() {
|
||||||
const EMPTY_EXECUTE = () => {};
|
const EMPTY_EXECUTE = () => {};
|
||||||
@ -44,7 +44,7 @@ export function main() {
|
|||||||
providers.push({provide: Options.PREPARE, useValue: prepare});
|
providers.push({provide: Options.PREPARE, useValue: prepare});
|
||||||
}
|
}
|
||||||
|
|
||||||
sampler = ReflectiveInjector.resolveAndCreate(providers).get(Sampler);
|
sampler = Injector.create(providers).get(Sampler);
|
||||||
}
|
}
|
||||||
|
|
||||||
it('should call the prepare and execute callbacks using WebDriverAdapter.waitFor',
|
it('should call the prepare and execute callbacks using WebDriverAdapter.waitFor',
|
||||||
|
@ -8,15 +8,15 @@
|
|||||||
|
|
||||||
import {describe, expect, it} from '@angular/core/testing/src/testing_internal';
|
import {describe, expect, it} from '@angular/core/testing/src/testing_internal';
|
||||||
|
|
||||||
import {MeasureValues, ReflectiveInjector, RegressionSlopeValidator} from '../../index';
|
import {Injector, MeasureValues, RegressionSlopeValidator} from '../../index';
|
||||||
|
|
||||||
export function main() {
|
export function main() {
|
||||||
describe('regression slope validator', () => {
|
describe('regression slope validator', () => {
|
||||||
let validator: RegressionSlopeValidator;
|
let validator: RegressionSlopeValidator;
|
||||||
|
|
||||||
function createValidator({size, metric}: {size: number, metric: string}) {
|
function createValidator({size, metric}: {size: number, metric: string}) {
|
||||||
validator = ReflectiveInjector
|
validator = Injector
|
||||||
.resolveAndCreate([
|
.create([
|
||||||
RegressionSlopeValidator.PROVIDERS,
|
RegressionSlopeValidator.PROVIDERS,
|
||||||
{provide: RegressionSlopeValidator.METRIC, useValue: metric},
|
{provide: RegressionSlopeValidator.METRIC, useValue: metric},
|
||||||
{provide: RegressionSlopeValidator.SAMPLE_SIZE, useValue: size}
|
{provide: RegressionSlopeValidator.SAMPLE_SIZE, useValue: size}
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
import {describe, expect, it} from '@angular/core/testing/src/testing_internal';
|
import {describe, expect, it} from '@angular/core/testing/src/testing_internal';
|
||||||
|
|
||||||
import {MeasureValues, ReflectiveInjector, SizeValidator} from '../../index';
|
import {Injector, MeasureValues, SizeValidator} from '../../index';
|
||||||
|
|
||||||
export function main() {
|
export function main() {
|
||||||
describe('size validator', () => {
|
describe('size validator', () => {
|
||||||
@ -16,8 +16,8 @@ export function main() {
|
|||||||
|
|
||||||
function createValidator(size: number) {
|
function createValidator(size: number) {
|
||||||
validator =
|
validator =
|
||||||
ReflectiveInjector
|
Injector
|
||||||
.resolveAndCreate(
|
.create(
|
||||||
[SizeValidator.PROVIDERS, {provide: SizeValidator.SAMPLE_SIZE, useValue: size}])
|
[SizeValidator.PROVIDERS, {provide: SizeValidator.SAMPLE_SIZE, useValue: size}])
|
||||||
.get(SizeValidator);
|
.get(SizeValidator);
|
||||||
}
|
}
|
||||||
|
@ -8,14 +8,14 @@
|
|||||||
|
|
||||||
import {AsyncTestCompleter, describe, expect, inject, it} from '@angular/core/testing/src/testing_internal';
|
import {AsyncTestCompleter, describe, expect, inject, it} from '@angular/core/testing/src/testing_internal';
|
||||||
|
|
||||||
import {Options, ReflectiveInjector, WebDriverExtension} from '../index';
|
import {Injector, Options, WebDriverExtension} from '../index';
|
||||||
|
|
||||||
export function main() {
|
export function main() {
|
||||||
function createExtension(ids: any[], caps: any) {
|
function createExtension(ids: any[], caps: any) {
|
||||||
return new Promise<any>((res, rej) => {
|
return new Promise<any>((res, rej) => {
|
||||||
try {
|
try {
|
||||||
res(ReflectiveInjector
|
res(Injector
|
||||||
.resolveAndCreate([
|
.create([
|
||||||
ids.map((id) => ({provide: id, useValue: new MockExtension(id)})),
|
ids.map((id) => ({provide: id, useValue: new MockExtension(id)})),
|
||||||
{provide: Options.CAPABILITIES, useValue: caps},
|
{provide: Options.CAPABILITIES, useValue: caps},
|
||||||
WebDriverExtension.provideFirstSupported(ids)
|
WebDriverExtension.provideFirstSupported(ids)
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
import {AsyncTestCompleter, describe, expect, iit, inject, it} from '@angular/core/testing/src/testing_internal';
|
import {AsyncTestCompleter, describe, expect, iit, inject, it} from '@angular/core/testing/src/testing_internal';
|
||||||
|
|
||||||
import {ChromeDriverExtension, Options, ReflectiveInjector, WebDriverAdapter, WebDriverExtension} from '../../index';
|
import {ChromeDriverExtension, Injector, Options, WebDriverAdapter, WebDriverExtension} from '../../index';
|
||||||
import {TraceEventFactory} from '../trace_event_factory';
|
import {TraceEventFactory} from '../trace_event_factory';
|
||||||
|
|
||||||
export function main() {
|
export function main() {
|
||||||
@ -41,8 +41,8 @@ export function main() {
|
|||||||
userAgent = CHROME45_USER_AGENT;
|
userAgent = CHROME45_USER_AGENT;
|
||||||
}
|
}
|
||||||
log = [];
|
log = [];
|
||||||
extension = ReflectiveInjector
|
extension = Injector
|
||||||
.resolveAndCreate([
|
.create([
|
||||||
ChromeDriverExtension.PROVIDERS, {
|
ChromeDriverExtension.PROVIDERS, {
|
||||||
provide: WebDriverAdapter,
|
provide: WebDriverAdapter,
|
||||||
useValue: new MockDriverAdapter(log, perfRecords, messageMethod)
|
useValue: new MockDriverAdapter(log, perfRecords, messageMethod)
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
import {AsyncTestCompleter, describe, expect, inject, it} from '@angular/core/testing/src/testing_internal';
|
import {AsyncTestCompleter, describe, expect, inject, it} from '@angular/core/testing/src/testing_internal';
|
||||||
|
|
||||||
import {IOsDriverExtension, ReflectiveInjector, WebDriverAdapter, WebDriverExtension} from '../../index';
|
import {IOsDriverExtension, Injector, WebDriverAdapter, WebDriverExtension} from '../../index';
|
||||||
import {TraceEventFactory} from '../trace_event_factory';
|
import {TraceEventFactory} from '../trace_event_factory';
|
||||||
|
|
||||||
export function main() {
|
export function main() {
|
||||||
@ -24,8 +24,8 @@ export function main() {
|
|||||||
}
|
}
|
||||||
log = [];
|
log = [];
|
||||||
extension =
|
extension =
|
||||||
ReflectiveInjector
|
Injector
|
||||||
.resolveAndCreate([
|
.create([
|
||||||
IOsDriverExtension.PROVIDERS,
|
IOsDriverExtension.PROVIDERS,
|
||||||
{provide: WebDriverAdapter, useValue: new MockDriverAdapter(log, perfRecords)}
|
{provide: WebDriverAdapter, useValue: new MockDriverAdapter(log, perfRecords)}
|
||||||
])
|
])
|
||||||
|
@ -6,7 +6,8 @@
|
|||||||
* found in the LICENSE file at https://angular.io/license
|
* found in the LICENSE file at https://angular.io/license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {ComponentFactoryResolver, ComponentRef, Directive, Injector, Input, NgModuleFactory, NgModuleRef, OnChanges, OnDestroy, Provider, SimpleChanges, Type, ViewContainerRef} from '@angular/core';
|
import {ComponentFactoryResolver, ComponentRef, Directive, Injector, Input, NgModuleFactory, NgModuleRef, OnChanges, OnDestroy, SimpleChanges, StaticProvider, Type, ViewContainerRef} from '@angular/core';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a single {@link Component} type and inserts its Host View into current View.
|
* Instantiates a single {@link Component} type and inserts its Host View into current View.
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
import {CommonModule} from '@angular/common';
|
import {CommonModule} from '@angular/common';
|
||||||
import {NgComponentOutlet} from '@angular/common/src/directives/ng_component_outlet';
|
import {NgComponentOutlet} from '@angular/common/src/directives/ng_component_outlet';
|
||||||
import {Compiler, Component, ComponentRef, Inject, InjectionToken, Injector, NO_ERRORS_SCHEMA, NgModule, NgModuleFactory, Optional, Provider, QueryList, ReflectiveInjector, TemplateRef, Type, ViewChild, ViewChildren, ViewContainerRef} from '@angular/core';
|
import {Compiler, Component, ComponentRef, Inject, InjectionToken, Injector, NO_ERRORS_SCHEMA, NgModule, NgModuleFactory, Optional, QueryList, StaticProvider, TemplateRef, Type, ViewChild, ViewChildren, ViewContainerRef} from '@angular/core';
|
||||||
import {TestBed, async, fakeAsync} from '@angular/core/testing';
|
import {TestBed, async, fakeAsync} from '@angular/core/testing';
|
||||||
import {expect} from '@angular/platform-browser/testing/src/matchers';
|
import {expect} from '@angular/platform-browser/testing/src/matchers';
|
||||||
|
|
||||||
@ -96,7 +96,7 @@ export function main() {
|
|||||||
|
|
||||||
const uniqueValue = {};
|
const uniqueValue = {};
|
||||||
fixture.componentInstance.currentComponent = InjectedComponent;
|
fixture.componentInstance.currentComponent = InjectedComponent;
|
||||||
fixture.componentInstance.injector = ReflectiveInjector.resolveAndCreate(
|
fixture.componentInstance.injector = Injector.create(
|
||||||
[{provide: TEST_TOKEN, useValue: uniqueValue}], fixture.componentRef.injector);
|
[{provide: TEST_TOKEN, useValue: uniqueValue}], fixture.componentRef.injector);
|
||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
@ -345,4 +345,4 @@ class FromJsonDeserializer extends ValueTransformer {
|
|||||||
return super.visitStringMap(map, context);
|
return super.visitStringMap(map, context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,8 +6,9 @@
|
|||||||
* found in the LICENSE file at https://angular.io/license
|
* found in the LICENSE file at https://angular.io/license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {COMPILER_OPTIONS, Compiler, CompilerFactory, CompilerOptions, Inject, InjectionToken, MissingTranslationStrategy, Optional, PlatformRef, Provider, ReflectiveInjector, TRANSLATIONS, TRANSLATIONS_FORMAT, Type, ViewEncapsulation, createPlatformFactory, isDevMode, platformCore, ɵConsole as Console} from '@angular/core';
|
import {COMPILER_OPTIONS, Compiler, CompilerFactory, CompilerOptions, Inject, InjectionToken, Injector, MissingTranslationStrategy, Optional, PACKAGE_ROOT_URL, PlatformRef, StaticProvider, TRANSLATIONS, TRANSLATIONS_FORMAT, Type, ViewEncapsulation, createPlatformFactory, isDevMode, platformCore, ɵConsole as Console} from '@angular/core';
|
||||||
|
|
||||||
|
import {StaticSymbolCache} from '../aot/static_symbol';
|
||||||
import {CompileReflector} from '../compile_reflector';
|
import {CompileReflector} from '../compile_reflector';
|
||||||
import {CompilerConfig} from '../config';
|
import {CompilerConfig} from '../config';
|
||||||
import {DirectiveNormalizer} from '../directive_normalizer';
|
import {DirectiveNormalizer} from '../directive_normalizer';
|
||||||
@ -16,7 +17,7 @@ import {Lexer} from '../expression_parser/lexer';
|
|||||||
import {Parser} from '../expression_parser/parser';
|
import {Parser} from '../expression_parser/parser';
|
||||||
import * as i18n from '../i18n/index';
|
import * as i18n from '../i18n/index';
|
||||||
import {CompilerInjectable} from '../injectable';
|
import {CompilerInjectable} from '../injectable';
|
||||||
import {CompileMetadataResolver} from '../metadata_resolver';
|
import {CompileMetadataResolver, ERROR_COLLECTOR_TOKEN} from '../metadata_resolver';
|
||||||
import {HtmlParser} from '../ml_parser/html_parser';
|
import {HtmlParser} from '../ml_parser/html_parser';
|
||||||
import {NgModuleCompiler} from '../ng_module_compiler';
|
import {NgModuleCompiler} from '../ng_module_compiler';
|
||||||
import {NgModuleResolver} from '../ng_module_resolver';
|
import {NgModuleResolver} from '../ng_module_resolver';
|
||||||
@ -26,7 +27,7 @@ import {DomElementSchemaRegistry} from '../schema/dom_element_schema_registry';
|
|||||||
import {ElementSchemaRegistry} from '../schema/element_schema_registry';
|
import {ElementSchemaRegistry} from '../schema/element_schema_registry';
|
||||||
import {StyleCompiler} from '../style_compiler';
|
import {StyleCompiler} from '../style_compiler';
|
||||||
import {JitSummaryResolver, SummaryResolver} from '../summary_resolver';
|
import {JitSummaryResolver, SummaryResolver} from '../summary_resolver';
|
||||||
import {TemplateParser} from '../template_parser/template_parser';
|
import {TEMPLATE_TRANSFORMS, TemplateParser} from '../template_parser/template_parser';
|
||||||
import {DEFAULT_PACKAGE_URL_PROVIDER, UrlResolver} from '../url_resolver';
|
import {DEFAULT_PACKAGE_URL_PROVIDER, UrlResolver} from '../url_resolver';
|
||||||
import {ViewCompiler} from '../view_compiler/view_compiler';
|
import {ViewCompiler} from '../view_compiler/view_compiler';
|
||||||
|
|
||||||
@ -45,17 +46,18 @@ const baseHtmlParser = new InjectionToken('HtmlParser');
|
|||||||
* A set of providers that provide `JitCompiler` and its dependencies to use for
|
* A set of providers that provide `JitCompiler` and its dependencies to use for
|
||||||
* template compilation.
|
* template compilation.
|
||||||
*/
|
*/
|
||||||
export const COMPILER_PROVIDERS: Array<any|Type<any>|{[k: string]: any}|any[]> = [
|
export const COMPILER_PROVIDERS = <StaticProvider[]>[
|
||||||
{provide: CompileReflector, useValue: new JitReflector()},
|
{provide: CompileReflector, useValue: new JitReflector()},
|
||||||
{provide: ResourceLoader, useValue: _NO_RESOURCE_LOADER},
|
{provide: ResourceLoader, useValue: _NO_RESOURCE_LOADER},
|
||||||
JitSummaryResolver,
|
{provide: JitSummaryResolver, deps: []},
|
||||||
{provide: SummaryResolver, useExisting: JitSummaryResolver},
|
{provide: SummaryResolver, useExisting: JitSummaryResolver},
|
||||||
Console,
|
{provide: Console, deps: []},
|
||||||
Lexer,
|
{provide: Lexer, deps: []},
|
||||||
Parser,
|
{provide: Parser, deps: [Lexer]},
|
||||||
{
|
{
|
||||||
provide: baseHtmlParser,
|
provide: baseHtmlParser,
|
||||||
useClass: HtmlParser,
|
useClass: HtmlParser,
|
||||||
|
deps: [],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
provide: i18n.I18NHtmlParser,
|
provide: i18n.I18NHtmlParser,
|
||||||
@ -78,22 +80,37 @@ export const COMPILER_PROVIDERS: Array<any|Type<any>|{[k: string]: any}|any[]> =
|
|||||||
provide: HtmlParser,
|
provide: HtmlParser,
|
||||||
useExisting: i18n.I18NHtmlParser,
|
useExisting: i18n.I18NHtmlParser,
|
||||||
},
|
},
|
||||||
TemplateParser,
|
{
|
||||||
DirectiveNormalizer,
|
provide: TemplateParser, deps: [CompilerConfig, CompileReflector,
|
||||||
CompileMetadataResolver,
|
Parser, ElementSchemaRegistry,
|
||||||
|
i18n.I18NHtmlParser, Console, [Optional, TEMPLATE_TRANSFORMS]]
|
||||||
|
},
|
||||||
|
{ provide: DirectiveNormalizer, deps: [ResourceLoader, UrlResolver, HtmlParser, CompilerConfig]},
|
||||||
|
{ provide: CompileMetadataResolver, deps: [CompilerConfig, NgModuleResolver,
|
||||||
|
DirectiveResolver, PipeResolver,
|
||||||
|
SummaryResolver,
|
||||||
|
ElementSchemaRegistry,
|
||||||
|
DirectiveNormalizer, Console,
|
||||||
|
[Optional, StaticSymbolCache],
|
||||||
|
CompileReflector,
|
||||||
|
[Optional, ERROR_COLLECTOR_TOKEN]]},
|
||||||
DEFAULT_PACKAGE_URL_PROVIDER,
|
DEFAULT_PACKAGE_URL_PROVIDER,
|
||||||
StyleCompiler,
|
{ provide: StyleCompiler, deps: [UrlResolver]},
|
||||||
ViewCompiler,
|
{ provide: ViewCompiler, deps: [CompilerConfig, CompileReflector, ElementSchemaRegistry]},
|
||||||
NgModuleCompiler,
|
{ provide: NgModuleCompiler, deps: [CompileReflector] },
|
||||||
{provide: CompilerConfig, useValue: new CompilerConfig()},
|
{ provide: CompilerConfig, useValue: new CompilerConfig()},
|
||||||
JitCompiler,
|
{ provide: JitCompiler, deps: [Injector, CompileMetadataResolver,
|
||||||
{provide: Compiler, useExisting: JitCompiler},
|
TemplateParser, StyleCompiler,
|
||||||
DomElementSchemaRegistry,
|
ViewCompiler, NgModuleCompiler,
|
||||||
{provide: ElementSchemaRegistry, useExisting: DomElementSchemaRegistry},
|
SummaryResolver, CompilerConfig,
|
||||||
UrlResolver,
|
Console]},
|
||||||
DirectiveResolver,
|
{ provide: Compiler, useExisting: JitCompiler},
|
||||||
PipeResolver,
|
{ provide: DomElementSchemaRegistry, deps: []},
|
||||||
NgModuleResolver,
|
{ provide: ElementSchemaRegistry, useExisting: DomElementSchemaRegistry},
|
||||||
|
{ provide: UrlResolver, deps: [PACKAGE_ROOT_URL]},
|
||||||
|
{ provide: DirectiveResolver, deps: [CompileReflector]},
|
||||||
|
{ provide: PipeResolver, deps: [CompileReflector]},
|
||||||
|
{ provide: NgModuleResolver, deps: [CompileReflector]},
|
||||||
];
|
];
|
||||||
|
|
||||||
@CompilerInjectable()
|
@CompilerInjectable()
|
||||||
@ -112,7 +129,7 @@ export class JitCompilerFactory implements CompilerFactory {
|
|||||||
}
|
}
|
||||||
createCompiler(options: CompilerOptions[] = []): Compiler {
|
createCompiler(options: CompilerOptions[] = []): Compiler {
|
||||||
const opts = _mergeOptions(this._defaultOptions.concat(options));
|
const opts = _mergeOptions(this._defaultOptions.concat(options));
|
||||||
const injector = ReflectiveInjector.resolveAndCreate([
|
const injector = Injector.create([
|
||||||
COMPILER_PROVIDERS, {
|
COMPILER_PROVIDERS, {
|
||||||
provide: CompilerConfig,
|
provide: CompilerConfig,
|
||||||
useFactory: () => {
|
useFactory: () => {
|
||||||
@ -142,7 +159,7 @@ export class JitCompilerFactory implements CompilerFactory {
|
|||||||
*/
|
*/
|
||||||
export const platformCoreDynamic = createPlatformFactory(platformCore, 'coreDynamic', [
|
export const platformCoreDynamic = createPlatformFactory(platformCore, 'coreDynamic', [
|
||||||
{provide: COMPILER_OPTIONS, useValue: {}, multi: true},
|
{provide: COMPILER_OPTIONS, useValue: {}, multi: true},
|
||||||
{provide: CompilerFactory, useClass: JitCompilerFactory},
|
{provide: CompilerFactory, useClass: JitCompilerFactory, deps: [COMPILER_OPTIONS]},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
function _mergeOptions(optionsArr: CompilerOptions[]): CompilerOptions {
|
function _mergeOptions(optionsArr: CompilerOptions[]): CompilerOptions {
|
||||||
|
@ -1071,4 +1071,4 @@ function calcStaticDynamicQueryFlags(
|
|||||||
flags |= NodeFlags.DynamicQuery;
|
flags |= NodeFlags.DynamicQuery;
|
||||||
}
|
}
|
||||||
return flags;
|
return flags;
|
||||||
}
|
}
|
||||||
|
@ -328,10 +328,7 @@ export function main() {
|
|||||||
|
|
||||||
describe('normalizeExternalStylesheets', () => {
|
describe('normalizeExternalStylesheets', () => {
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => { TestBed.configureCompiler({providers: [SpyResourceLoader.PROVIDE]}); });
|
||||||
TestBed.configureCompiler(
|
|
||||||
{providers: [{provide: ResourceLoader, useClass: SpyResourceLoader}]});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should load an external stylesheet',
|
it('should load an external stylesheet',
|
||||||
inject(
|
inject(
|
||||||
|
@ -26,6 +26,7 @@ export class I18nComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class FrLocalization extends NgLocalization {
|
export class FrLocalization extends NgLocalization {
|
||||||
|
public static PROVIDE = {provide: NgLocalization, useClass: FrLocalization, deps: []};
|
||||||
getPluralCategory(value: number): string {
|
getPluralCategory(value: number): string {
|
||||||
switch (value) {
|
switch (value) {
|
||||||
case 0:
|
case 0:
|
||||||
|
@ -26,8 +26,8 @@ export function main() {
|
|||||||
beforeEach(async(() => {
|
beforeEach(async(() => {
|
||||||
TestBed.configureCompiler({
|
TestBed.configureCompiler({
|
||||||
providers: [
|
providers: [
|
||||||
{provide: ResourceLoader, useClass: SpyResourceLoader},
|
SpyResourceLoader.PROVIDE,
|
||||||
{provide: NgLocalization, useClass: FrLocalization},
|
FrLocalization.PROVIDE,
|
||||||
{provide: TRANSLATIONS, useValue: XLIFF2_TOMERGE},
|
{provide: TRANSLATIONS, useValue: XLIFF2_TOMERGE},
|
||||||
{provide: TRANSLATIONS_FORMAT, useValue: 'xlf2'},
|
{provide: TRANSLATIONS_FORMAT, useValue: 'xlf2'},
|
||||||
]
|
]
|
||||||
|
@ -26,8 +26,8 @@ export function main() {
|
|||||||
beforeEach(async(() => {
|
beforeEach(async(() => {
|
||||||
TestBed.configureCompiler({
|
TestBed.configureCompiler({
|
||||||
providers: [
|
providers: [
|
||||||
{provide: ResourceLoader, useClass: SpyResourceLoader},
|
SpyResourceLoader.PROVIDE,
|
||||||
{provide: NgLocalization, useClass: FrLocalization},
|
FrLocalization.PROVIDE,
|
||||||
{provide: TRANSLATIONS, useValue: XLIFF_TOMERGE},
|
{provide: TRANSLATIONS, useValue: XLIFF_TOMERGE},
|
||||||
{provide: TRANSLATIONS_FORMAT, useValue: 'xliff'},
|
{provide: TRANSLATIONS_FORMAT, useValue: 'xliff'},
|
||||||
]
|
]
|
||||||
|
@ -26,8 +26,8 @@ export function main() {
|
|||||||
beforeEach(async(() => {
|
beforeEach(async(() => {
|
||||||
TestBed.configureCompiler({
|
TestBed.configureCompiler({
|
||||||
providers: [
|
providers: [
|
||||||
{provide: ResourceLoader, useClass: SpyResourceLoader},
|
SpyResourceLoader.PROVIDE,
|
||||||
{provide: NgLocalization, useClass: FrLocalization},
|
FrLocalization.PROVIDE,
|
||||||
{provide: TRANSLATIONS, useValue: XTB},
|
{provide: TRANSLATIONS, useValue: XTB},
|
||||||
{provide: TRANSLATIONS_FORMAT, useValue: 'xtb'},
|
{provide: TRANSLATIONS_FORMAT, useValue: 'xtb'},
|
||||||
]
|
]
|
||||||
|
@ -36,7 +36,7 @@ export function main() {
|
|||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
TestBed.configureCompiler(
|
TestBed.configureCompiler(
|
||||||
{providers: [{provide: ResourceLoader, useClass: StubResourceLoader}]});
|
{providers: [{provide: ResourceLoader, useClass: StubResourceLoader, deps: []}]});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw when using a templateUrl that has not been compiled before', async(() => {
|
it('should throw when using a templateUrl that has not been compiled before', async(() => {
|
||||||
@ -68,7 +68,7 @@ export function main() {
|
|||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
TestBed.configureCompiler(
|
TestBed.configureCompiler(
|
||||||
{providers: [{provide: ResourceLoader, useClass: StubResourceLoader}]});
|
{providers: [{provide: ResourceLoader, useClass: StubResourceLoader, deps: []}]});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should allow to use templateUrl components that have been loaded before', async(() => {
|
it('should allow to use templateUrl components that have been loaded before', async(() => {
|
||||||
@ -88,10 +88,7 @@ export function main() {
|
|||||||
let dirResolver: MockDirectiveResolver;
|
let dirResolver: MockDirectiveResolver;
|
||||||
let injector: Injector;
|
let injector: Injector;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => { TestBed.configureCompiler({providers: [SpyResourceLoader.PROVIDE]}); });
|
||||||
TestBed.configureCompiler(
|
|
||||||
{providers: [{provide: ResourceLoader, useClass: SpyResourceLoader}]});
|
|
||||||
});
|
|
||||||
|
|
||||||
beforeEach(fakeAsync(inject(
|
beforeEach(fakeAsync(inject(
|
||||||
[Compiler, ResourceLoader, DirectiveResolver, Injector],
|
[Compiler, ResourceLoader, DirectiveResolver, Injector],
|
||||||
|
@ -11,5 +11,6 @@ import {ResourceLoader} from '@angular/compiler/src/resource_loader';
|
|||||||
import {SpyObject} from '@angular/core/testing/src/testing_internal';
|
import {SpyObject} from '@angular/core/testing/src/testing_internal';
|
||||||
|
|
||||||
export class SpyResourceLoader extends SpyObject {
|
export class SpyResourceLoader extends SpyObject {
|
||||||
|
public static PROVIDE = {provide: ResourceLoader, useClass: SpyResourceLoader, deps: []};
|
||||||
constructor() { super(ResourceLoader); }
|
constructor() { super(ResourceLoader); }
|
||||||
}
|
}
|
||||||
|
@ -308,7 +308,7 @@ export function main() {
|
|||||||
TestBed.configureCompiler({
|
TestBed.configureCompiler({
|
||||||
providers: [
|
providers: [
|
||||||
TEST_COMPILER_PROVIDERS,
|
TEST_COMPILER_PROVIDERS,
|
||||||
{provide: ElementSchemaRegistry, useClass: DomElementSchemaRegistry}
|
{provide: ElementSchemaRegistry, useClass: DomElementSchemaRegistry, deps: []}
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -20,6 +20,6 @@ export function createUrlResolverWithoutPackagePrefix(): UrlResolver {
|
|||||||
// TODO: get rid of it or move to a separate @angular/internal_testing package
|
// TODO: get rid of it or move to a separate @angular/internal_testing package
|
||||||
export const TEST_COMPILER_PROVIDERS: Provider[] = [
|
export const TEST_COMPILER_PROVIDERS: Provider[] = [
|
||||||
{provide: ElementSchemaRegistry, useValue: new MockSchemaRegistry({}, {}, {}, [], [])},
|
{provide: ElementSchemaRegistry, useValue: new MockSchemaRegistry({}, {}, {}, [], [])},
|
||||||
{provide: ResourceLoader, useClass: MockResourceLoader},
|
{provide: ResourceLoader, useClass: MockResourceLoader, deps: []},
|
||||||
{provide: UrlResolver, useFactory: createUrlResolverWithoutPackagePrefix}
|
{provide: UrlResolver, useFactory: createUrlResolverWithoutPackagePrefix, deps: []}
|
||||||
];
|
];
|
||||||
|
@ -28,7 +28,7 @@ export * from './pipe_resolver_mock';
|
|||||||
|
|
||||||
import {createPlatformFactory, ModuleWithComponentFactories, Injectable, CompilerOptions, COMPILER_OPTIONS, CompilerFactory, ComponentFactory, NgModuleFactory, Injector, NgModule, Component, Directive, Pipe, Type, PlatformRef, ɵstringify} from '@angular/core';
|
import {createPlatformFactory, ModuleWithComponentFactories, Injectable, CompilerOptions, COMPILER_OPTIONS, CompilerFactory, ComponentFactory, NgModuleFactory, Injector, NgModule, Component, Directive, Pipe, Type, PlatformRef, ɵstringify} from '@angular/core';
|
||||||
import {MetadataOverride, ɵTestingCompilerFactory as TestingCompilerFactory, ɵTestingCompiler as TestingCompiler} from '@angular/core/testing';
|
import {MetadataOverride, ɵTestingCompilerFactory as TestingCompilerFactory, ɵTestingCompiler as TestingCompiler} from '@angular/core/testing';
|
||||||
import {platformCoreDynamic, JitCompiler, DirectiveResolver, NgModuleResolver, PipeResolver, CompileMetadataResolver} from '@angular/compiler';
|
import {platformCoreDynamic, JitCompiler, DirectiveResolver, NgModuleResolver, PipeResolver, CompileMetadataResolver, CompileReflector} from '@angular/compiler';
|
||||||
import {MockDirectiveResolver} from './directive_resolver_mock';
|
import {MockDirectiveResolver} from './directive_resolver_mock';
|
||||||
import {MockNgModuleResolver} from './ng_module_resolver_mock';
|
import {MockNgModuleResolver} from './ng_module_resolver_mock';
|
||||||
import {MockPipeResolver} from './pipe_resolver_mock';
|
import {MockPipeResolver} from './pipe_resolver_mock';
|
||||||
@ -124,15 +124,19 @@ export const platformCoreDynamicTesting: (extraProviders?: any[]) => PlatformRef
|
|||||||
provide: COMPILER_OPTIONS,
|
provide: COMPILER_OPTIONS,
|
||||||
useValue: {
|
useValue: {
|
||||||
providers: [
|
providers: [
|
||||||
MockPipeResolver,
|
{provide: MockPipeResolver, deps: [Injector, CompileReflector]},
|
||||||
{provide: PipeResolver, useExisting: MockPipeResolver},
|
{provide: PipeResolver, useExisting: MockPipeResolver},
|
||||||
MockDirectiveResolver,
|
{provide: MockDirectiveResolver, deps: [Injector, CompileReflector]},
|
||||||
{provide: DirectiveResolver, useExisting: MockDirectiveResolver},
|
{provide: DirectiveResolver, useExisting: MockDirectiveResolver},
|
||||||
MockNgModuleResolver,
|
{provide: MockNgModuleResolver, deps: [Injector, CompileReflector]},
|
||||||
{provide: NgModuleResolver, useExisting: MockNgModuleResolver},
|
{provide: NgModuleResolver, useExisting: MockNgModuleResolver},
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
multi: true
|
multi: true
|
||||||
},
|
},
|
||||||
{provide: TestingCompilerFactory, useClass: TestingCompilerFactoryImpl}
|
{
|
||||||
|
provide: TestingCompilerFactory,
|
||||||
|
useClass: TestingCompilerFactoryImpl,
|
||||||
|
deps: [CompilerFactory]
|
||||||
|
}
|
||||||
]);
|
]);
|
||||||
|
@ -19,7 +19,7 @@ import {isPromise} from '../src/util/lang';
|
|||||||
import {ApplicationInitStatus} from './application_init';
|
import {ApplicationInitStatus} from './application_init';
|
||||||
import {APP_BOOTSTRAP_LISTENER, PLATFORM_INITIALIZER} from './application_tokens';
|
import {APP_BOOTSTRAP_LISTENER, PLATFORM_INITIALIZER} from './application_tokens';
|
||||||
import {Console} from './console';
|
import {Console} from './console';
|
||||||
import {Injectable, InjectionToken, Injector, Provider, ReflectiveInjector} from './di';
|
import {Injectable, InjectionToken, Injector, StaticProvider} from './di';
|
||||||
import {CompilerFactory, CompilerOptions} from './linker/compiler';
|
import {CompilerFactory, CompilerOptions} from './linker/compiler';
|
||||||
import {ComponentFactory, ComponentRef} from './linker/component_factory';
|
import {ComponentFactory, ComponentRef} from './linker/component_factory';
|
||||||
import {ComponentFactoryBoundToModule, ComponentFactoryResolver} from './linker/component_factory_resolver';
|
import {ComponentFactoryBoundToModule, ComponentFactoryResolver} from './linker/component_factory_resolver';
|
||||||
@ -99,17 +99,18 @@ export function createPlatform(injector: Injector): PlatformRef {
|
|||||||
* @experimental APIs related to application bootstrap are currently under review.
|
* @experimental APIs related to application bootstrap are currently under review.
|
||||||
*/
|
*/
|
||||||
export function createPlatformFactory(
|
export function createPlatformFactory(
|
||||||
parentPlatformFactory: ((extraProviders?: Provider[]) => PlatformRef) | null, name: string,
|
parentPlatformFactory: ((extraProviders?: StaticProvider[]) => PlatformRef) | null,
|
||||||
providers: Provider[] = []): (extraProviders?: Provider[]) => PlatformRef {
|
name: string, providers: StaticProvider[] = []): (extraProviders?: StaticProvider[]) =>
|
||||||
|
PlatformRef {
|
||||||
const marker = new InjectionToken(`Platform: ${name}`);
|
const marker = new InjectionToken(`Platform: ${name}`);
|
||||||
return (extraProviders: Provider[] = []) => {
|
return (extraProviders: StaticProvider[] = []) => {
|
||||||
let platform = getPlatform();
|
let platform = getPlatform();
|
||||||
if (!platform || platform.injector.get(ALLOW_MULTIPLE_PLATFORMS, false)) {
|
if (!platform || platform.injector.get(ALLOW_MULTIPLE_PLATFORMS, false)) {
|
||||||
if (parentPlatformFactory) {
|
if (parentPlatformFactory) {
|
||||||
parentPlatformFactory(
|
parentPlatformFactory(
|
||||||
providers.concat(extraProviders).concat({provide: marker, useValue: true}));
|
providers.concat(extraProviders).concat({provide: marker, useValue: true}));
|
||||||
} else {
|
} else {
|
||||||
createPlatform(ReflectiveInjector.resolveAndCreate(
|
createPlatform(Injector.create(
|
||||||
providers.concat(extraProviders).concat({provide: marker, useValue: true})));
|
providers.concat(extraProviders).concat({provide: marker, useValue: true})));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -292,8 +293,7 @@ export class PlatformRef_ extends PlatformRef {
|
|||||||
// Attention: Don't use ApplicationRef.run here,
|
// Attention: Don't use ApplicationRef.run here,
|
||||||
// as we want to be sure that all possible constructor calls are inside `ngZone.run`!
|
// as we want to be sure that all possible constructor calls are inside `ngZone.run`!
|
||||||
return ngZone.run(() => {
|
return ngZone.run(() => {
|
||||||
const ngZoneInjector =
|
const ngZoneInjector = Injector.create([{provide: NgZone, useValue: ngZone}], this.injector);
|
||||||
ReflectiveInjector.resolveAndCreate([{provide: NgZone, useValue: ngZone}], this.injector);
|
|
||||||
const moduleRef = <InternalNgModuleRef<M>>moduleFactory.create(ngZoneInjector);
|
const moduleRef = <InternalNgModuleRef<M>>moduleFactory.create(ngZoneInjector);
|
||||||
const exceptionHandler: ErrorHandler = moduleRef.injector.get(ErrorHandler, null);
|
const exceptionHandler: ErrorHandler = moduleRef.injector.get(ErrorHandler, null);
|
||||||
if (!exceptionHandler) {
|
if (!exceptionHandler) {
|
||||||
|
@ -6,9 +6,10 @@
|
|||||||
* found in the LICENSE file at https://angular.io/license
|
* found in the LICENSE file at https://angular.io/license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {Optional, Provider, SkipSelf} from '../../di';
|
import {Optional, SkipSelf, StaticProvider} from '../../di';
|
||||||
import {ChangeDetectorRef} from '../change_detector_ref';
|
import {ChangeDetectorRef} from '../change_detector_ref';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A type describing supported iterable types.
|
* A type describing supported iterable types.
|
||||||
*
|
*
|
||||||
@ -181,7 +182,7 @@ export class IterableDiffers {
|
|||||||
* })
|
* })
|
||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
static extend(factories: IterableDifferFactory[]): Provider {
|
static extend(factories: IterableDifferFactory[]): StaticProvider {
|
||||||
return {
|
return {
|
||||||
provide: IterableDiffers,
|
provide: IterableDiffers,
|
||||||
useFactory: (parent: IterableDiffers) => {
|
useFactory: (parent: IterableDiffers) => {
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
* found in the LICENSE file at https://angular.io/license
|
* found in the LICENSE file at https://angular.io/license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {Optional, Provider, SkipSelf} from '../../di';
|
import {Optional, SkipSelf, StaticProvider} from '../../di';
|
||||||
import {ChangeDetectorRef} from '../change_detector_ref';
|
import {ChangeDetectorRef} from '../change_detector_ref';
|
||||||
|
|
||||||
|
|
||||||
@ -156,7 +156,7 @@ export class KeyValueDiffers {
|
|||||||
* })
|
* })
|
||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
static extend<S>(factories: KeyValueDifferFactory[]): Provider {
|
static extend<S>(factories: KeyValueDifferFactory[]): StaticProvider {
|
||||||
return {
|
return {
|
||||||
provide: KeyValueDiffers,
|
provide: KeyValueDiffers,
|
||||||
useFactory: (parent: KeyValueDiffers) => {
|
useFactory: (parent: KeyValueDiffers) => {
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
* found in the LICENSE file at https://angular.io/license
|
* found in the LICENSE file at https://angular.io/license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {Injectable, InjectionToken} from '../di';
|
import {Injectable, InjectionToken, StaticProvider} from '../di';
|
||||||
import {MissingTranslationStrategy} from '../i18n/tokens';
|
import {MissingTranslationStrategy} from '../i18n/tokens';
|
||||||
import {ViewEncapsulation} from '../metadata';
|
import {ViewEncapsulation} from '../metadata';
|
||||||
import {Type} from '../type';
|
import {Type} from '../type';
|
||||||
@ -14,6 +14,7 @@ import {Type} from '../type';
|
|||||||
import {ComponentFactory} from './component_factory';
|
import {ComponentFactory} from './component_factory';
|
||||||
import {NgModuleFactory} from './ng_module_factory';
|
import {NgModuleFactory} from './ng_module_factory';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Combination of NgModuleFactory and ComponentFactorys.
|
* Combination of NgModuleFactory and ComponentFactorys.
|
||||||
*
|
*
|
||||||
@ -101,7 +102,7 @@ export type CompilerOptions = {
|
|||||||
useDebug?: boolean,
|
useDebug?: boolean,
|
||||||
useJit?: boolean,
|
useJit?: boolean,
|
||||||
defaultEncapsulation?: ViewEncapsulation,
|
defaultEncapsulation?: ViewEncapsulation,
|
||||||
providers?: any[],
|
providers?: StaticProvider[],
|
||||||
missingTranslation?: MissingTranslationStrategy,
|
missingTranslation?: MissingTranslationStrategy,
|
||||||
// Whether to support the `<template>` tag and the `template` attribute to define angular
|
// Whether to support the `<template>` tag and the `template` attribute to define angular
|
||||||
// templates. They have been deprecated in 4.x, `<ng-template>` should be used instead.
|
// templates. They have been deprecated in 4.x, `<ng-template>` should be used instead.
|
||||||
|
@ -9,22 +9,16 @@
|
|||||||
import {PlatformRef, PlatformRef_, createPlatformFactory} from './application_ref';
|
import {PlatformRef, PlatformRef_, createPlatformFactory} from './application_ref';
|
||||||
import {PLATFORM_ID} from './application_tokens';
|
import {PLATFORM_ID} from './application_tokens';
|
||||||
import {Console} from './console';
|
import {Console} from './console';
|
||||||
import {Provider} from './di';
|
import {Injector, StaticProvider} from './di';
|
||||||
import {Reflector, reflector} from './reflection/reflection';
|
|
||||||
import {TestabilityRegistry} from './testability/testability';
|
import {TestabilityRegistry} from './testability/testability';
|
||||||
|
|
||||||
function _reflector(): Reflector {
|
const _CORE_PLATFORM_PROVIDERS: StaticProvider[] = [
|
||||||
return reflector;
|
|
||||||
}
|
|
||||||
|
|
||||||
const _CORE_PLATFORM_PROVIDERS: Provider[] = [
|
|
||||||
// Set a default platform name for platforms that don't set it explicitly.
|
// Set a default platform name for platforms that don't set it explicitly.
|
||||||
{provide: PLATFORM_ID, useValue: 'unknown'},
|
{provide: PLATFORM_ID, useValue: 'unknown'},
|
||||||
PlatformRef_,
|
{provide: PlatformRef_, deps: [Injector]},
|
||||||
{provide: PlatformRef, useExisting: PlatformRef_},
|
{provide: PlatformRef, useExisting: PlatformRef_},
|
||||||
{provide: Reflector, useFactory: _reflector, deps: []},
|
{provide: TestabilityRegistry, deps: []},
|
||||||
TestabilityRegistry,
|
{provide: Console, deps: []},
|
||||||
Console,
|
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -190,4 +190,4 @@ export function getQueryValue(
|
|||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -161,7 +161,7 @@ function validateNode(parent: NodeDef | null, node: NodeDef, nodeCount: number)
|
|||||||
const parentFlags = parent ? parent.flags : 0;
|
const parentFlags = parent ? parent.flags : 0;
|
||||||
if ((parentFlags & NodeFlags.TypeElement) === 0) {
|
if ((parentFlags & NodeFlags.TypeElement) === 0) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Illegal State: Provider/Directive nodes need to be children of elements or anchors, at index ${node.index}!`);
|
`Illegal State: StaticProvider/Directive nodes need to be children of elements or anchors, at index ${node.index}!`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (node.query) {
|
if (node.query) {
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
* found in the LICENSE file at https://angular.io/license
|
* found in the LICENSE file at https://angular.io/license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {ReflectiveInjector} from '@angular/core';
|
import {Injector} from '@angular/core';
|
||||||
import {IterableDiffers} from '@angular/core/src/change_detection/differs/iterable_differs';
|
import {IterableDiffers} from '@angular/core/src/change_detection/differs/iterable_differs';
|
||||||
|
|
||||||
import {SpyIterableDifferFactory} from '../../spies';
|
import {SpyIterableDifferFactory} from '../../spies';
|
||||||
@ -50,7 +50,7 @@ export function main() {
|
|||||||
|
|
||||||
describe('.extend()', () => {
|
describe('.extend()', () => {
|
||||||
it('should throw if calling extend when creating root injector', () => {
|
it('should throw if calling extend when creating root injector', () => {
|
||||||
const injector = ReflectiveInjector.resolveAndCreate([IterableDiffers.extend([])]);
|
const injector = Injector.create([IterableDiffers.extend([])]);
|
||||||
|
|
||||||
expect(() => injector.get(IterableDiffers))
|
expect(() => injector.get(IterableDiffers))
|
||||||
.toThrowError(/Cannot extend IterableDiffers without a parent injector/);
|
.toThrowError(/Cannot extend IterableDiffers without a parent injector/);
|
||||||
@ -58,9 +58,8 @@ export function main() {
|
|||||||
|
|
||||||
it('should extend di-inherited differs', () => {
|
it('should extend di-inherited differs', () => {
|
||||||
const parent = new IterableDiffers([factory1]);
|
const parent = new IterableDiffers([factory1]);
|
||||||
const injector =
|
const injector = Injector.create([{provide: IterableDiffers, useValue: parent}]);
|
||||||
ReflectiveInjector.resolveAndCreate([{provide: IterableDiffers, useValue: parent}]);
|
const childInjector = Injector.create([IterableDiffers.extend([factory2])], injector);
|
||||||
const childInjector = injector.resolveAndCreateChild([IterableDiffers.extend([factory2])]);
|
|
||||||
|
|
||||||
expect(injector.get(IterableDiffers).factories).toEqual([factory1]);
|
expect(injector.get(IterableDiffers).factories).toEqual([factory1]);
|
||||||
expect(childInjector.get(IterableDiffers).factories).toEqual([factory2, factory1]);
|
expect(childInjector.get(IterableDiffers).factories).toEqual([factory2, factory1]);
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import {CommonModule} from '@angular/common';
|
import {CommonModule} from '@angular/common';
|
||||||
import {Compiler, ComponentFactory, ErrorHandler, EventEmitter, Host, Inject, Injectable, InjectionToken, Injector, NO_ERRORS_SCHEMA, NgModule, NgModuleRef, OnDestroy, ReflectiveInjector, SkipSelf} from '@angular/core';
|
import {Compiler, ComponentFactory, ErrorHandler, EventEmitter, Host, Inject, Injectable, InjectionToken, Injector, NO_ERRORS_SCHEMA, NgModule, NgModuleRef, OnDestroy, SkipSelf} from '@angular/core';
|
||||||
import {ChangeDetectionStrategy, ChangeDetectorRef, PipeTransform} from '@angular/core/src/change_detection/change_detection';
|
import {ChangeDetectionStrategy, ChangeDetectorRef, PipeTransform} from '@angular/core/src/change_detection/change_detection';
|
||||||
import {getDebugContext} from '@angular/core/src/errors';
|
import {getDebugContext} from '@angular/core/src/errors';
|
||||||
import {ComponentFactoryResolver} from '@angular/core/src/linker/component_factory_resolver';
|
import {ComponentFactoryResolver} from '@angular/core/src/linker/component_factory_resolver';
|
||||||
@ -1850,8 +1850,7 @@ class DynamicViewport {
|
|||||||
const myService = new MyService();
|
const myService = new MyService();
|
||||||
myService.greeting = 'dynamic greet';
|
myService.greeting = 'dynamic greet';
|
||||||
|
|
||||||
this.injector = ReflectiveInjector.resolveAndCreate(
|
this.injector = Injector.create([{provide: MyService, useValue: myService}], vc.injector);
|
||||||
[{provide: MyService, useValue: myService}], vc.injector);
|
|
||||||
this.componentFactory =
|
this.componentFactory =
|
||||||
componentFactoryResolver.resolveComponentFactory(ChildCompUsingService) !;
|
componentFactoryResolver.resolveComponentFactory(ChildCompUsingService) !;
|
||||||
}
|
}
|
||||||
|
@ -163,13 +163,19 @@ export function main() {
|
|||||||
|
|
||||||
// root elements
|
// root elements
|
||||||
expect(() => createAndGetRootNodes(compViewDef(nodes)))
|
expect(() => createAndGetRootNodes(compViewDef(nodes)))
|
||||||
.toThrowError('No provider for Dep!');
|
.toThrowError(
|
||||||
|
'StaticInjectorError[Dep]: \n' +
|
||||||
|
' StaticInjectorError[Dep]: \n' +
|
||||||
|
' NullInjectorError: No provider for Dep!');
|
||||||
|
|
||||||
// non root elements
|
// non root elements
|
||||||
expect(
|
expect(
|
||||||
() => createAndGetRootNodes(compViewDef(
|
() => createAndGetRootNodes(compViewDef(
|
||||||
[elementDef(NodeFlags.None, null !, null !, 4, 'span')].concat(nodes))))
|
[elementDef(NodeFlags.None, null !, null !, 4, 'span')].concat(nodes))))
|
||||||
.toThrowError('No provider for Dep!');
|
.toThrowError(
|
||||||
|
'StaticInjectorError[Dep]: \n' +
|
||||||
|
' StaticInjectorError[Dep]: \n' +
|
||||||
|
' NullInjectorError: No provider for Dep!');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should inject from a parent element in a parent view', () => {
|
it('should inject from a parent element in a parent view', () => {
|
||||||
@ -191,7 +197,10 @@ export function main() {
|
|||||||
elementDef(NodeFlags.None, null !, null !, 1, 'span'),
|
elementDef(NodeFlags.None, null !, null !, 1, 'span'),
|
||||||
directiveDef(NodeFlags.None, null !, 0, SomeService, ['nonExistingDep'])
|
directiveDef(NodeFlags.None, null !, 0, SomeService, ['nonExistingDep'])
|
||||||
])))
|
])))
|
||||||
.toThrowError('No provider for nonExistingDep!');
|
.toThrowError(
|
||||||
|
'StaticInjectorError[nonExistingDep]: \n' +
|
||||||
|
' StaticInjectorError[nonExistingDep]: \n' +
|
||||||
|
' NullInjectorError: No provider for nonExistingDep!');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should use null for optional missing dependencies', () => {
|
it('should use null for optional missing dependencies', () => {
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
* found in the LICENSE file at https://angular.io/license
|
* found in the LICENSE file at https://angular.io/license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {ApplicationInitStatus, CompilerOptions, Component, Directive, InjectionToken, Injector, ModuleWithComponentFactories, NgModule, NgModuleFactory, NgModuleRef, NgZone, Optional, Pipe, PlatformRef, Provider, ReflectiveInjector, SchemaMetadata, SkipSelf, Type, ɵDepFlags as DepFlags, ɵERROR_COMPONENT_TYPE, ɵNodeFlags as NodeFlags, ɵclearProviderOverrides as clearProviderOverrides, ɵoverrideProvider as overrideProvider, ɵstringify as stringify} from '@angular/core';
|
import {ApplicationInitStatus, CompilerOptions, Component, Directive, InjectionToken, Injector, ModuleWithComponentFactories, NgModule, NgModuleFactory, NgModuleRef, NgZone, Optional, Pipe, PlatformRef, Provider, SchemaMetadata, SkipSelf, Type, ɵDepFlags as DepFlags, ɵERROR_COMPONENT_TYPE, ɵNodeFlags as NodeFlags, ɵclearProviderOverrides as clearProviderOverrides, ɵoverrideProvider as overrideProvider, ɵstringify as stringify} from '@angular/core';
|
||||||
|
|
||||||
import {AsyncTestCompleter} from './async_test_completer';
|
import {AsyncTestCompleter} from './async_test_completer';
|
||||||
import {ComponentFixture} from './component_fixture';
|
import {ComponentFixture} from './component_fixture';
|
||||||
@ -308,8 +308,8 @@ export class TestBed implements Injector {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
const ngZone = new NgZone({enableLongStackTrace: true});
|
const ngZone = new NgZone({enableLongStackTrace: true});
|
||||||
const ngZoneInjector = ReflectiveInjector.resolveAndCreate(
|
const ngZoneInjector =
|
||||||
[{provide: NgZone, useValue: ngZone}], this.platform.injector);
|
Injector.create([{provide: NgZone, useValue: ngZone}], this.platform.injector);
|
||||||
this._moduleRef = this._moduleFactory.create(ngZoneInjector);
|
this._moduleRef = this._moduleFactory.create(ngZoneInjector);
|
||||||
// ApplicationInitStatus.runInitializers() is marked @internal to core. So casting to any
|
// ApplicationInitStatus.runInitializers() is marked @internal to core. So casting to any
|
||||||
// before accessing it.
|
// before accessing it.
|
||||||
|
@ -6,11 +6,11 @@
|
|||||||
* found in the LICENSE file at https://angular.io/license
|
* found in the LICENSE file at https://angular.io/license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {Directive, ElementRef, Provider, Renderer2, forwardRef} from '@angular/core';
|
import {Directive, ElementRef, Renderer2, StaticProvider, forwardRef} from '@angular/core';
|
||||||
|
|
||||||
import {ControlValueAccessor, NG_VALUE_ACCESSOR} from './control_value_accessor';
|
import {ControlValueAccessor, NG_VALUE_ACCESSOR} from './control_value_accessor';
|
||||||
|
|
||||||
export const RANGE_VALUE_ACCESSOR: Provider = {
|
export const RANGE_VALUE_ACCESSOR: StaticProvider = {
|
||||||
provide: NG_VALUE_ACCESSOR,
|
provide: NG_VALUE_ACCESSOR,
|
||||||
useExisting: forwardRef(() => RangeValueAccessor),
|
useExisting: forwardRef(() => RangeValueAccessor),
|
||||||
multi: true
|
multi: true
|
||||||
|
@ -6,10 +6,11 @@
|
|||||||
* found in the LICENSE file at https://angular.io/license
|
* found in the LICENSE file at https://angular.io/license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {Directive, ElementRef, Host, Input, OnDestroy, Optional, Provider, Renderer2, forwardRef, ɵlooseIdentical as looseIdentical} from '@angular/core';
|
import {Directive, ElementRef, Host, Input, OnDestroy, Optional, Renderer2, StaticProvider, forwardRef, ɵlooseIdentical as looseIdentical} from '@angular/core';
|
||||||
|
|
||||||
import {ControlValueAccessor, NG_VALUE_ACCESSOR} from './control_value_accessor';
|
import {ControlValueAccessor, NG_VALUE_ACCESSOR} from './control_value_accessor';
|
||||||
|
|
||||||
export const SELECT_VALUE_ACCESSOR: Provider = {
|
export const SELECT_VALUE_ACCESSOR: StaticProvider = {
|
||||||
provide: NG_VALUE_ACCESSOR,
|
provide: NG_VALUE_ACCESSOR,
|
||||||
useExisting: forwardRef(() => SelectControlValueAccessor),
|
useExisting: forwardRef(() => SelectControlValueAccessor),
|
||||||
multi: true
|
multi: true
|
||||||
|
@ -6,10 +6,11 @@
|
|||||||
* found in the LICENSE file at https://angular.io/license
|
* found in the LICENSE file at https://angular.io/license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {Directive, ElementRef, Host, Input, OnDestroy, Optional, Provider, Renderer2, forwardRef, ɵlooseIdentical as looseIdentical} from '@angular/core';
|
import {Directive, ElementRef, Host, Input, OnDestroy, Optional, Renderer2, StaticProvider, forwardRef, ɵlooseIdentical as looseIdentical} from '@angular/core';
|
||||||
|
|
||||||
import {ControlValueAccessor, NG_VALUE_ACCESSOR} from './control_value_accessor';
|
import {ControlValueAccessor, NG_VALUE_ACCESSOR} from './control_value_accessor';
|
||||||
|
|
||||||
export const SELECT_MULTIPLE_VALUE_ACCESSOR: Provider = {
|
export const SELECT_MULTIPLE_VALUE_ACCESSOR: StaticProvider = {
|
||||||
provide: NG_VALUE_ACCESSOR,
|
provide: NG_VALUE_ACCESSOR,
|
||||||
useExisting: forwardRef(() => SelectMultipleControlValueAccessor),
|
useExisting: forwardRef(() => SelectMultipleControlValueAccessor),
|
||||||
multi: true
|
multi: true
|
||||||
|
@ -6,11 +6,13 @@
|
|||||||
* found in the LICENSE file at https://angular.io/license
|
* found in the LICENSE file at https://angular.io/license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {Directive, Input, OnChanges, Provider, SimpleChanges, forwardRef} from '@angular/core';
|
import {Directive, Input, OnChanges, SimpleChanges, StaticProvider, forwardRef} from '@angular/core';
|
||||||
import {Observable} from 'rxjs/Observable';
|
import {Observable} from 'rxjs/Observable';
|
||||||
|
|
||||||
import {AbstractControl} from '../model';
|
import {AbstractControl} from '../model';
|
||||||
import {NG_VALIDATORS, Validators} from '../validators';
|
import {NG_VALIDATORS, Validators} from '../validators';
|
||||||
|
|
||||||
|
|
||||||
/** @experimental */
|
/** @experimental */
|
||||||
export type ValidationErrors = {
|
export type ValidationErrors = {
|
||||||
[key: string]: any
|
[key: string]: any
|
||||||
@ -45,13 +47,13 @@ export interface AsyncValidator extends Validator {
|
|||||||
validate(c: AbstractControl): Promise<ValidationErrors|null>|Observable<ValidationErrors|null>;
|
validate(c: AbstractControl): Promise<ValidationErrors|null>|Observable<ValidationErrors|null>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const REQUIRED_VALIDATOR: Provider = {
|
export const REQUIRED_VALIDATOR: StaticProvider = {
|
||||||
provide: NG_VALIDATORS,
|
provide: NG_VALIDATORS,
|
||||||
useExisting: forwardRef(() => RequiredValidator),
|
useExisting: forwardRef(() => RequiredValidator),
|
||||||
multi: true
|
multi: true
|
||||||
};
|
};
|
||||||
|
|
||||||
export const CHECKBOX_REQUIRED_VALIDATOR: Provider = {
|
export const CHECKBOX_REQUIRED_VALIDATOR: StaticProvider = {
|
||||||
provide: NG_VALIDATORS,
|
provide: NG_VALIDATORS,
|
||||||
useExisting: forwardRef(() => CheckboxRequiredValidator),
|
useExisting: forwardRef(() => CheckboxRequiredValidator),
|
||||||
multi: true
|
multi: true
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
* found in the LICENSE file at https://angular.io/license
|
* found in the LICENSE file at https://angular.io/license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {ReflectiveInjector} from '@angular/core';
|
import {Injector} from '@angular/core';
|
||||||
import {AsyncTestCompleter, SpyObject, afterEach, beforeEach, describe, inject, it} from '@angular/core/testing/src/testing_internal';
|
import {AsyncTestCompleter, SpyObject, afterEach, beforeEach, describe, inject, it} from '@angular/core/testing/src/testing_internal';
|
||||||
import {expect} from '@angular/platform-browser/testing/src/matchers';
|
import {expect} from '@angular/platform-browser/testing/src/matchers';
|
||||||
import {BrowserJsonp} from '../../src/backends/browser_jsonp';
|
import {BrowserJsonp} from '../../src/backends/browser_jsonp';
|
||||||
@ -52,10 +52,10 @@ export function main() {
|
|||||||
let sampleRequest: Request;
|
let sampleRequest: Request;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
const injector = ReflectiveInjector.resolveAndCreate([
|
const injector = Injector.create([
|
||||||
{provide: ResponseOptions, useClass: BaseResponseOptions},
|
{provide: ResponseOptions, useClass: BaseResponseOptions, deps: []},
|
||||||
{provide: BrowserJsonp, useClass: MockBrowserJsonp},
|
{provide: BrowserJsonp, useClass: MockBrowserJsonp, deps: []},
|
||||||
{provide: JSONPBackend, useClass: JSONPBackend_}
|
{provide: JSONPBackend, useClass: JSONPBackend_, deps: [BrowserJsonp, ResponseOptions]}
|
||||||
]);
|
]);
|
||||||
backend = injector.get(JSONPBackend);
|
backend = injector.get(JSONPBackend);
|
||||||
const base = new BaseRequestOptions();
|
const base = new BaseRequestOptions();
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
* found in the LICENSE file at https://angular.io/license
|
* found in the LICENSE file at https://angular.io/license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {ReflectiveInjector} from '@angular/core';
|
import {Injector} from '@angular/core';
|
||||||
import {AsyncTestCompleter, beforeEach, describe, inject, it, xit} from '@angular/core/testing/src/testing_internal';
|
import {AsyncTestCompleter, beforeEach, describe, inject, it, xit} from '@angular/core/testing/src/testing_internal';
|
||||||
import {expect} from '@angular/platform-browser/testing/src/matchers';
|
import {expect} from '@angular/platform-browser/testing/src/matchers';
|
||||||
import {ReplaySubject} from 'rxjs/ReplaySubject';
|
import {ReplaySubject} from 'rxjs/ReplaySubject';
|
||||||
@ -27,8 +27,10 @@ export function main() {
|
|||||||
let sampleResponse2: Response;
|
let sampleResponse2: Response;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
const injector = ReflectiveInjector.resolveAndCreate(
|
const injector = Injector.create([
|
||||||
[{provide: ResponseOptions, useClass: BaseResponseOptions}, MockBackend]);
|
{provide: ResponseOptions, useClass: BaseResponseOptions, deps: []},
|
||||||
|
{provide: MockBackend, deps: []}
|
||||||
|
]);
|
||||||
backend = injector.get(MockBackend);
|
backend = injector.get(MockBackend);
|
||||||
const base = new BaseRequestOptions();
|
const base = new BaseRequestOptions();
|
||||||
sampleRequest1 =
|
sampleRequest1 =
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
* found in the LICENSE file at https://angular.io/license
|
* found in the LICENSE file at https://angular.io/license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {Injector, ReflectiveInjector} from '@angular/core';
|
import {Injector} from '@angular/core';
|
||||||
import {TestBed, getTestBed} from '@angular/core/testing';
|
import {TestBed, getTestBed} from '@angular/core/testing';
|
||||||
import {AsyncTestCompleter, afterEach, beforeEach, describe, inject, it} from '@angular/core/testing/src/testing_internal';
|
import {AsyncTestCompleter, afterEach, beforeEach, describe, inject, it} from '@angular/core/testing/src/testing_internal';
|
||||||
import {expect} from '@angular/platform-browser/testing/src/matchers';
|
import {expect} from '@angular/platform-browser/testing/src/matchers';
|
||||||
@ -79,8 +79,8 @@ export function main() {
|
|||||||
let jsonp: Jsonp;
|
let jsonp: Jsonp;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
injector = ReflectiveInjector.resolveAndCreate([
|
injector = Injector.create([
|
||||||
BaseRequestOptions, MockBackend, {
|
{provide: BaseRequestOptions, deps: []}, {provide: MockBackend, deps: []}, {
|
||||||
provide: Http,
|
provide: Http,
|
||||||
useFactory: function(backend: ConnectionBackend, defaultOptions: BaseRequestOptions) {
|
useFactory: function(backend: ConnectionBackend, defaultOptions: BaseRequestOptions) {
|
||||||
return new Http(backend, defaultOptions);
|
return new Http(backend, defaultOptions);
|
||||||
|
@ -114,7 +114,7 @@ export class MockConnection implements Connection {
|
|||||||
* ### Example
|
* ### Example
|
||||||
*
|
*
|
||||||
* ```
|
* ```
|
||||||
* import {Injectable, ReflectiveInjector} from '@angular/core';
|
* import {Injectable, Injector} from '@angular/core';
|
||||||
* import {async, fakeAsync, tick} from '@angular/core/testing';
|
* import {async, fakeAsync, tick} from '@angular/core/testing';
|
||||||
* import {BaseRequestOptions, ConnectionBackend, Http, RequestOptions} from '@angular/http';
|
* import {BaseRequestOptions, ConnectionBackend, Http, RequestOptions} from '@angular/http';
|
||||||
* import {Response, ResponseOptions} from '@angular/http';
|
* import {Response, ResponseOptions} from '@angular/http';
|
||||||
@ -142,7 +142,7 @@ export class MockConnection implements Connection {
|
|||||||
*
|
*
|
||||||
* describe('MockBackend HeroService Example', () => {
|
* describe('MockBackend HeroService Example', () => {
|
||||||
* beforeEach(() => {
|
* beforeEach(() => {
|
||||||
* this.injector = ReflectiveInjector.resolveAndCreate([
|
* this.injector = Injector.create([
|
||||||
* {provide: ConnectionBackend, useClass: MockBackend},
|
* {provide: ConnectionBackend, useClass: MockBackend},
|
||||||
* {provide: RequestOptions, useClass: BaseRequestOptions},
|
* {provide: RequestOptions, useClass: BaseRequestOptions},
|
||||||
* Http,
|
* Http,
|
||||||
@ -202,7 +202,7 @@ export class MockBackend implements ConnectionBackend {
|
|||||||
* ### Example
|
* ### Example
|
||||||
*
|
*
|
||||||
* ```
|
* ```
|
||||||
* import {ReflectiveInjector} from '@angular/core';
|
* import {Injector} from '@angular/core';
|
||||||
* import {fakeAsync, tick} from '@angular/core/testing';
|
* import {fakeAsync, tick} from '@angular/core/testing';
|
||||||
* import {BaseRequestOptions, ConnectionBackend, Http, RequestOptions} from '@angular/http';
|
* import {BaseRequestOptions, ConnectionBackend, Http, RequestOptions} from '@angular/http';
|
||||||
* import {Response, ResponseOptions} from '@angular/http';
|
* import {Response, ResponseOptions} from '@angular/http';
|
||||||
@ -213,7 +213,7 @@ export class MockBackend implements ConnectionBackend {
|
|||||||
* MockConnection; // this will be set when a new connection is emitted from the
|
* MockConnection; // this will be set when a new connection is emitted from the
|
||||||
* // backend.
|
* // backend.
|
||||||
* let text: string; // this will be set from mock response
|
* let text: string; // this will be set from mock response
|
||||||
* let injector = ReflectiveInjector.resolveAndCreate([
|
* let injector = Injector.create([
|
||||||
* {provide: ConnectionBackend, useClass: MockBackend},
|
* {provide: ConnectionBackend, useClass: MockBackend},
|
||||||
* {provide: RequestOptions, useClass: BaseRequestOptions},
|
* {provide: RequestOptions, useClass: BaseRequestOptions},
|
||||||
* Http,
|
* Http,
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import {ResourceLoader, platformCoreDynamic} from '@angular/compiler';
|
import {ResourceLoader, platformCoreDynamic} from '@angular/compiler';
|
||||||
import {PlatformRef, Provider, createPlatformFactory} from '@angular/core';
|
import {PlatformRef, Provider, StaticProvider, createPlatformFactory} from '@angular/core';
|
||||||
|
|
||||||
import {INTERNAL_BROWSER_DYNAMIC_PLATFORM_PROVIDERS} from './platform_providers';
|
import {INTERNAL_BROWSER_DYNAMIC_PLATFORM_PROVIDERS} from './platform_providers';
|
||||||
import {CachedResourceLoader} from './resource_loader/resource_loader_cache';
|
import {CachedResourceLoader} from './resource_loader/resource_loader_cache';
|
||||||
|
@ -8,17 +8,17 @@
|
|||||||
|
|
||||||
import {ɵPLATFORM_BROWSER_ID as PLATFORM_BROWSER_ID} from '@angular/common';
|
import {ɵPLATFORM_BROWSER_ID as PLATFORM_BROWSER_ID} from '@angular/common';
|
||||||
import {ResourceLoader} from '@angular/compiler';
|
import {ResourceLoader} from '@angular/compiler';
|
||||||
import {COMPILER_OPTIONS, PLATFORM_ID, Provider} from '@angular/core';
|
import {COMPILER_OPTIONS, PLATFORM_ID, StaticProvider} from '@angular/core';
|
||||||
|
|
||||||
import {ɵINTERNAL_BROWSER_PLATFORM_PROVIDERS as INTERNAL_BROWSER_PLATFORM_PROVIDERS} from '@angular/platform-browser';
|
import {ɵINTERNAL_BROWSER_PLATFORM_PROVIDERS as INTERNAL_BROWSER_PLATFORM_PROVIDERS} from '@angular/platform-browser';
|
||||||
|
|
||||||
import {ResourceLoaderImpl} from './resource_loader/resource_loader_impl';
|
import {ResourceLoaderImpl} from './resource_loader/resource_loader_impl';
|
||||||
|
|
||||||
export const INTERNAL_BROWSER_DYNAMIC_PLATFORM_PROVIDERS: Provider[] = [
|
export const INTERNAL_BROWSER_DYNAMIC_PLATFORM_PROVIDERS: StaticProvider[] = [
|
||||||
INTERNAL_BROWSER_PLATFORM_PROVIDERS,
|
INTERNAL_BROWSER_PLATFORM_PROVIDERS,
|
||||||
{
|
{
|
||||||
provide: COMPILER_OPTIONS,
|
provide: COMPILER_OPTIONS,
|
||||||
useValue: {providers: [{provide: ResourceLoader, useClass: ResourceLoaderImpl}]},
|
useValue: {providers: [{provide: ResourceLoader, useClass: ResourceLoaderImpl, deps: []}]},
|
||||||
multi: true
|
multi: true
|
||||||
},
|
},
|
||||||
{provide: PLATFORM_ID, useValue: PLATFORM_BROWSER_ID},
|
{provide: PLATFORM_ID, useValue: PLATFORM_BROWSER_ID},
|
||||||
|
@ -26,8 +26,8 @@ export function main() {
|
|||||||
beforeEach(fakeAsync(() => {
|
beforeEach(fakeAsync(() => {
|
||||||
TestBed.configureCompiler({
|
TestBed.configureCompiler({
|
||||||
providers: [
|
providers: [
|
||||||
{provide: UrlResolver, useClass: TestUrlResolver},
|
{provide: UrlResolver, useClass: TestUrlResolver, deps: []},
|
||||||
{provide: ResourceLoader, useFactory: createCachedResourceLoader}
|
{provide: ResourceLoader, useFactory: createCachedResourceLoader, deps: []}
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import {platformCoreDynamicTesting} from '@angular/compiler/testing';
|
import {platformCoreDynamicTesting} from '@angular/compiler/testing';
|
||||||
import {NgModule, PlatformRef, Provider, createPlatformFactory} from '@angular/core';
|
import {NgModule, PlatformRef, StaticProvider, createPlatformFactory} from '@angular/core';
|
||||||
import {TestComponentRenderer} from '@angular/core/testing';
|
import {TestComponentRenderer} from '@angular/core/testing';
|
||||||
import {ɵINTERNAL_BROWSER_DYNAMIC_PLATFORM_PROVIDERS as INTERNAL_BROWSER_DYNAMIC_PLATFORM_PROVIDERS} from '@angular/platform-browser-dynamic';
|
import {ɵINTERNAL_BROWSER_DYNAMIC_PLATFORM_PROVIDERS as INTERNAL_BROWSER_DYNAMIC_PLATFORM_PROVIDERS} from '@angular/platform-browser-dynamic';
|
||||||
import {BrowserTestingModule} from '@angular/platform-browser/testing';
|
import {BrowserTestingModule} from '@angular/platform-browser/testing';
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import {CommonModule, PlatformLocation, ɵPLATFORM_BROWSER_ID as PLATFORM_BROWSER_ID} from '@angular/common';
|
import {CommonModule, PlatformLocation, ɵPLATFORM_BROWSER_ID as PLATFORM_BROWSER_ID} from '@angular/common';
|
||||||
import {APP_ID, ApplicationModule, ErrorHandler, ModuleWithProviders, NgModule, Optional, PLATFORM_ID, PLATFORM_INITIALIZER, PlatformRef, Provider, RendererFactory2, RootRenderer, Sanitizer, SkipSelf, Testability, createPlatformFactory, platformCore} from '@angular/core';
|
import {APP_ID, ApplicationModule, ErrorHandler, ModuleWithProviders, NgModule, Optional, PLATFORM_ID, PLATFORM_INITIALIZER, PlatformRef, RendererFactory2, RootRenderer, Sanitizer, SkipSelf, StaticProvider, Testability, createPlatformFactory, platformCore} from '@angular/core';
|
||||||
|
|
||||||
import {BrowserDomAdapter} from './browser/browser_adapter';
|
import {BrowserDomAdapter} from './browser/browser_adapter';
|
||||||
import {BrowserPlatformLocation} from './browser/location/browser_platform_location';
|
import {BrowserPlatformLocation} from './browser/location/browser_platform_location';
|
||||||
@ -26,10 +26,10 @@ import {KeyEventsPlugin} from './dom/events/key_events';
|
|||||||
import {DomSharedStylesHost, SharedStylesHost} from './dom/shared_styles_host';
|
import {DomSharedStylesHost, SharedStylesHost} from './dom/shared_styles_host';
|
||||||
import {DomSanitizer, DomSanitizerImpl} from './security/dom_sanitization_service';
|
import {DomSanitizer, DomSanitizerImpl} from './security/dom_sanitization_service';
|
||||||
|
|
||||||
export const INTERNAL_BROWSER_PLATFORM_PROVIDERS: Provider[] = [
|
export const INTERNAL_BROWSER_PLATFORM_PROVIDERS: StaticProvider[] = [
|
||||||
{provide: PLATFORM_ID, useValue: PLATFORM_BROWSER_ID},
|
{provide: PLATFORM_ID, useValue: PLATFORM_BROWSER_ID},
|
||||||
{provide: PLATFORM_INITIALIZER, useValue: initDomAdapter, multi: true},
|
{provide: PLATFORM_INITIALIZER, useValue: initDomAdapter, multi: true},
|
||||||
{provide: PlatformLocation, useClass: BrowserPlatformLocation},
|
{provide: PlatformLocation, useClass: BrowserPlatformLocation, deps: [DOCUMENT]},
|
||||||
{provide: DOCUMENT, useFactory: _document, deps: []},
|
{provide: DOCUMENT, useFactory: _document, deps: []},
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -39,15 +39,15 @@ export const INTERNAL_BROWSER_PLATFORM_PROVIDERS: Provider[] = [
|
|||||||
* application to XSS risks. For more detail, see the [Security Guide](http://g.co/ng/security).
|
* application to XSS risks. For more detail, see the [Security Guide](http://g.co/ng/security).
|
||||||
* @experimental
|
* @experimental
|
||||||
*/
|
*/
|
||||||
export const BROWSER_SANITIZATION_PROVIDERS: Array<any> = [
|
export const BROWSER_SANITIZATION_PROVIDERS: StaticProvider[] = [
|
||||||
{provide: Sanitizer, useExisting: DomSanitizer},
|
{provide: Sanitizer, useExisting: DomSanitizer},
|
||||||
{provide: DomSanitizer, useClass: DomSanitizerImpl},
|
{provide: DomSanitizer, useClass: DomSanitizerImpl, deps: [DOCUMENT]},
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @stable
|
* @stable
|
||||||
*/
|
*/
|
||||||
export const platformBrowser: (extraProviders?: Provider[]) => PlatformRef =
|
export const platformBrowser: (extraProviders?: StaticProvider[]) => PlatformRef =
|
||||||
createPlatformFactory(platformCore, 'browser', INTERNAL_BROWSER_PLATFORM_PROVIDERS);
|
createPlatformFactory(platformCore, 'browser', INTERNAL_BROWSER_PLATFORM_PROVIDERS);
|
||||||
|
|
||||||
export function initDomAdapter() {
|
export function initDomAdapter() {
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
* found in the LICENSE file at https://angular.io/license
|
* found in the LICENSE file at https://angular.io/license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {APP_INITIALIZER, ApplicationInitStatus, Inject, InjectionToken, Injector, Provider} from '@angular/core';
|
import {APP_INITIALIZER, ApplicationInitStatus, Inject, InjectionToken, Injector, StaticProvider} from '@angular/core';
|
||||||
|
|
||||||
import {getDOM} from '../dom/dom_adapter';
|
import {getDOM} from '../dom/dom_adapter';
|
||||||
import {DOCUMENT} from '../dom/dom_tokens';
|
import {DOCUMENT} from '../dom/dom_tokens';
|
||||||
@ -31,7 +31,7 @@ export function appInitializerFactory(transitionId: string, document: any, injec
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export const SERVER_TRANSITION_PROVIDERS: Provider[] = [
|
export const SERVER_TRANSITION_PROVIDERS: StaticProvider[] = [
|
||||||
{
|
{
|
||||||
provide: APP_INITIALIZER,
|
provide: APP_INITIALIZER,
|
||||||
useFactory: appInitializerFactory,
|
useFactory: appInitializerFactory,
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import {isPlatformBrowser} from '@angular/common';
|
import {isPlatformBrowser} from '@angular/common';
|
||||||
import {APP_INITIALIZER, CUSTOM_ELEMENTS_SCHEMA, Compiler, Component, Directive, ErrorHandler, Inject, Input, LOCALE_ID, NgModule, OnDestroy, PLATFORM_ID, PLATFORM_INITIALIZER, Pipe, Provider, VERSION, createPlatformFactory, ɵstringify as stringify} from '@angular/core';
|
import {APP_INITIALIZER, CUSTOM_ELEMENTS_SCHEMA, Compiler, Component, Directive, ErrorHandler, Inject, Input, LOCALE_ID, NgModule, OnDestroy, PLATFORM_ID, PLATFORM_INITIALIZER, Pipe, Provider, StaticProvider, VERSION, createPlatformFactory, ɵstringify as stringify} from '@angular/core';
|
||||||
import {ApplicationRef, destroyPlatform} from '@angular/core/src/application_ref';
|
import {ApplicationRef, destroyPlatform} from '@angular/core/src/application_ref';
|
||||||
import {Console} from '@angular/core/src/console';
|
import {Console} from '@angular/core/src/console';
|
||||||
import {ComponentRef} from '@angular/core/src/linker/component_factory';
|
import {ComponentRef} from '@angular/core/src/linker/component_factory';
|
||||||
@ -112,8 +112,8 @@ class DummyConsole implements Console {
|
|||||||
|
|
||||||
|
|
||||||
class TestModule {}
|
class TestModule {}
|
||||||
function bootstrap(
|
function bootstrap(cmpType: any, providers: Provider[] = [], platformProviders: StaticProvider[] = [
|
||||||
cmpType: any, providers: Provider[] = [], platformProviders: Provider[] = []): Promise<any> {
|
]): Promise<any> {
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [BrowserModule],
|
imports: [BrowserModule],
|
||||||
declarations: [cmpType],
|
declarations: [cmpType],
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
* found in the LICENSE file at https://angular.io/license
|
* found in the LICENSE file at https://angular.io/license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {ReflectiveInjector, ɵglobal as global} from '@angular/core';
|
import {Injector, ɵglobal as global} from '@angular/core';
|
||||||
import {ApplicationRef, ApplicationRef_} from '@angular/core/src/application_ref';
|
import {ApplicationRef, ApplicationRef_} from '@angular/core/src/application_ref';
|
||||||
import {SpyObject} from '@angular/core/testing/src/testing_internal';
|
import {SpyObject} from '@angular/core/testing/src/testing_internal';
|
||||||
|
|
||||||
@ -18,8 +18,8 @@ export class SpyComponentRef extends SpyObject {
|
|||||||
injector: any /** TODO #9100 */;
|
injector: any /** TODO #9100 */;
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
this.injector = ReflectiveInjector.resolveAndCreate(
|
this.injector =
|
||||||
[{provide: ApplicationRef, useClass: SpyApplicationRef}]);
|
Injector.create([{provide: ApplicationRef, useClass: SpyApplicationRef, deps: []}]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
* Use of this source code is governed by an MIT-style license that can be
|
* 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
|
* found in the LICENSE file at https://angular.io/license
|
||||||
*/
|
*/
|
||||||
import {APP_ID, NgModule, NgZone, PLATFORM_INITIALIZER, PlatformRef, Provider, createPlatformFactory, platformCore} from '@angular/core';
|
import {APP_ID, NgModule, NgZone, PLATFORM_INITIALIZER, PlatformRef, StaticProvider, createPlatformFactory, platformCore} from '@angular/core';
|
||||||
import {BrowserModule, ɵBrowserDomAdapter as BrowserDomAdapter, ɵELEMENT_PROBE_PROVIDERS as ELEMENT_PROBE_PROVIDERS} from '@angular/platform-browser';
|
import {BrowserModule, ɵBrowserDomAdapter as BrowserDomAdapter, ɵELEMENT_PROBE_PROVIDERS as ELEMENT_PROBE_PROVIDERS} from '@angular/platform-browser';
|
||||||
import {BrowserDetection, createNgZone} from './browser_util';
|
import {BrowserDetection, createNgZone} from './browser_util';
|
||||||
|
|
||||||
@ -14,7 +14,7 @@ function initBrowserTests() {
|
|||||||
BrowserDetection.setup();
|
BrowserDetection.setup();
|
||||||
}
|
}
|
||||||
|
|
||||||
const _TEST_BROWSER_PLATFORM_PROVIDERS: Provider[] =
|
const _TEST_BROWSER_PLATFORM_PROVIDERS: StaticProvider[] =
|
||||||
[{provide: PLATFORM_INITIALIZER, useValue: initBrowserTests, multi: true}];
|
[{provide: PLATFORM_INITIALIZER, useValue: initBrowserTests, multi: true}];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -10,9 +10,9 @@ import {ɵAnimationEngine} from '@angular/animations/browser';
|
|||||||
import {PlatformLocation, ɵPLATFORM_SERVER_ID as PLATFORM_SERVER_ID} from '@angular/common';
|
import {PlatformLocation, ɵPLATFORM_SERVER_ID as PLATFORM_SERVER_ID} from '@angular/common';
|
||||||
import {HttpClientModule} from '@angular/common/http';
|
import {HttpClientModule} from '@angular/common/http';
|
||||||
import {platformCoreDynamic} from '@angular/compiler';
|
import {platformCoreDynamic} from '@angular/compiler';
|
||||||
import {Injectable, InjectionToken, Injector, NgModule, NgZone, PLATFORM_ID, PLATFORM_INITIALIZER, PlatformRef, Provider, RendererFactory2, RootRenderer, Testability, createPlatformFactory, isDevMode, platformCore, ɵALLOW_MULTIPLE_PLATFORMS as ALLOW_MULTIPLE_PLATFORMS} from '@angular/core';
|
import {Injectable, InjectionToken, Injector, NgModule, NgZone, Optional, PLATFORM_ID, PLATFORM_INITIALIZER, PlatformRef, Provider, RendererFactory2, RootRenderer, StaticProvider, Testability, createPlatformFactory, isDevMode, platformCore, ɵALLOW_MULTIPLE_PLATFORMS as ALLOW_MULTIPLE_PLATFORMS} from '@angular/core';
|
||||||
import {HttpModule} from '@angular/http';
|
import {HttpModule} from '@angular/http';
|
||||||
import {BrowserModule, DOCUMENT, ɵSharedStylesHost as SharedStylesHost, ɵgetDOM as getDOM} from '@angular/platform-browser';
|
import {BrowserModule, DOCUMENT, ɵSharedStylesHost as SharedStylesHost, ɵTRANSITION_ID, ɵgetDOM as getDOM} from '@angular/platform-browser';
|
||||||
import {NoopAnimationsModule, ɵAnimationRendererFactory} from '@angular/platform-browser/animations';
|
import {NoopAnimationsModule, ɵAnimationRendererFactory} from '@angular/platform-browser/animations';
|
||||||
|
|
||||||
import {SERVER_HTTP_PROVIDERS} from './http';
|
import {SERVER_HTTP_PROVIDERS} from './http';
|
||||||
@ -27,11 +27,15 @@ function notSupported(feature: string): Error {
|
|||||||
throw new Error(`platform-server does not support '${feature}'.`);
|
throw new Error(`platform-server does not support '${feature}'.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
export const INTERNAL_SERVER_PLATFORM_PROVIDERS: Array<any /*Type | Provider | any[]*/> = [
|
export const INTERNAL_SERVER_PLATFORM_PROVIDERS: StaticProvider[] = [
|
||||||
{provide: DOCUMENT, useFactory: _document, deps: [Injector]},
|
{provide: DOCUMENT, useFactory: _document, deps: [Injector]},
|
||||||
{provide: PLATFORM_ID, useValue: PLATFORM_SERVER_ID},
|
{provide: PLATFORM_ID, useValue: PLATFORM_SERVER_ID},
|
||||||
{provide: PLATFORM_INITIALIZER, useFactory: initParse5Adapter, multi: true, deps: [Injector]},
|
{provide: PLATFORM_INITIALIZER, useFactory: initParse5Adapter, multi: true, deps: [Injector]}, {
|
||||||
{provide: PlatformLocation, useClass: ServerPlatformLocation}, PlatformState,
|
provide: PlatformLocation,
|
||||||
|
useClass: ServerPlatformLocation,
|
||||||
|
deps: [DOCUMENT, [Optional, INITIAL_CONFIG]]
|
||||||
|
},
|
||||||
|
{provide: PlatformState, deps: [DOCUMENT]},
|
||||||
// Add special provider that allows multiple instances of platformServer* to be created.
|
// Add special provider that allows multiple instances of platformServer* to be created.
|
||||||
{provide: ALLOW_MULTIPLE_PLATFORMS, useValue: true}
|
{provide: ALLOW_MULTIPLE_PLATFORMS, useValue: true}
|
||||||
];
|
];
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
* found in the LICENSE file at https://angular.io/license
|
* found in the LICENSE file at https://angular.io/license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {ApplicationRef, NgModuleFactory, NgModuleRef, PlatformRef, Provider, Type} from '@angular/core';
|
import {ApplicationRef, NgModuleFactory, NgModuleRef, PlatformRef, StaticProvider, Type} from '@angular/core';
|
||||||
import {ɵTRANSITION_ID} from '@angular/platform-browser';
|
import {ɵTRANSITION_ID} from '@angular/platform-browser';
|
||||||
import {filter} from 'rxjs/operator/filter';
|
import {filter} from 'rxjs/operator/filter';
|
||||||
import {first} from 'rxjs/operator/first';
|
import {first} from 'rxjs/operator/first';
|
||||||
@ -21,11 +21,11 @@ const parse5 = require('parse5');
|
|||||||
interface PlatformOptions {
|
interface PlatformOptions {
|
||||||
document?: string;
|
document?: string;
|
||||||
url?: string;
|
url?: string;
|
||||||
extraProviders?: Provider[];
|
extraProviders?: StaticProvider[];
|
||||||
}
|
}
|
||||||
|
|
||||||
function _getPlatform(
|
function _getPlatform(
|
||||||
platformFactory: (extraProviders: Provider[]) => PlatformRef,
|
platformFactory: (extraProviders: StaticProvider[]) => PlatformRef,
|
||||||
options: PlatformOptions): PlatformRef {
|
options: PlatformOptions): PlatformRef {
|
||||||
const extraProviders = options.extraProviders ? options.extraProviders : [];
|
const extraProviders = options.extraProviders ? options.extraProviders : [];
|
||||||
return platformFactory([
|
return platformFactory([
|
||||||
@ -67,8 +67,8 @@ the server-rendered app can be properly bootstrapped into a client app.`);
|
|||||||
* @experimental
|
* @experimental
|
||||||
*/
|
*/
|
||||||
export function renderModule<T>(
|
export function renderModule<T>(
|
||||||
module: Type<T>,
|
module: Type<T>, options: {document?: string, url?: string, extraProviders?: StaticProvider[]}):
|
||||||
options: {document?: string, url?: string, extraProviders?: Provider[]}): Promise<string> {
|
Promise<string> {
|
||||||
const platform = _getPlatform(platformDynamicServer, options);
|
const platform = _getPlatform(platformDynamicServer, options);
|
||||||
return _render(platform, platform.bootstrapModule(module));
|
return _render(platform, platform.bootstrapModule(module));
|
||||||
}
|
}
|
||||||
@ -84,7 +84,8 @@ export function renderModule<T>(
|
|||||||
*/
|
*/
|
||||||
export function renderModuleFactory<T>(
|
export function renderModuleFactory<T>(
|
||||||
moduleFactory: NgModuleFactory<T>,
|
moduleFactory: NgModuleFactory<T>,
|
||||||
options: {document?: string, url?: string, extraProviders?: Provider[]}): Promise<string> {
|
options: {document?: string, url?: string, extraProviders?: StaticProvider[]}):
|
||||||
|
Promise<string> {
|
||||||
const platform = _getPlatform(platformServer, options);
|
const platform = _getPlatform(platformServer, options);
|
||||||
return _render(platform, platform.bootstrapModuleFactory(moduleFactory));
|
return _render(platform, platform.bootstrapModuleFactory(moduleFactory));
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import {platformCoreDynamicTesting} from '@angular/compiler/testing';
|
import {platformCoreDynamicTesting} from '@angular/compiler/testing';
|
||||||
import {NgModule, PlatformRef, Provider, createPlatformFactory} from '@angular/core';
|
import {NgModule, PlatformRef, StaticProvider, createPlatformFactory} from '@angular/core';
|
||||||
import {BrowserDynamicTestingModule} from '@angular/platform-browser-dynamic/testing';
|
import {BrowserDynamicTestingModule} from '@angular/platform-browser-dynamic/testing';
|
||||||
import {NoopAnimationsModule} from '@angular/platform-browser/animations';
|
import {NoopAnimationsModule} from '@angular/platform-browser/animations';
|
||||||
import {ɵINTERNAL_SERVER_PLATFORM_PROVIDERS as INTERNAL_SERVER_PLATFORM_PROVIDERS, ɵSERVER_RENDER_PROVIDERS as SERVER_RENDER_PROVIDERS} from '@angular/platform-server';
|
import {ɵINTERNAL_SERVER_PLATFORM_PROVIDERS as INTERNAL_SERVER_PLATFORM_PROVIDERS, ɵSERVER_RENDER_PROVIDERS as SERVER_RENDER_PROVIDERS} from '@angular/platform-server';
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
import {ɵPLATFORM_WORKER_UI_ID as PLATFORM_WORKER_UI_ID} from '@angular/common';
|
import {ɵPLATFORM_WORKER_UI_ID as PLATFORM_WORKER_UI_ID} from '@angular/common';
|
||||||
import {ResourceLoader, platformCoreDynamic} from '@angular/compiler';
|
import {ResourceLoader, platformCoreDynamic} from '@angular/compiler';
|
||||||
import {COMPILER_OPTIONS, PLATFORM_ID, PlatformRef, Provider, createPlatformFactory} from '@angular/core';
|
import {COMPILER_OPTIONS, PLATFORM_ID, PlatformRef, StaticProvider, createPlatformFactory} from '@angular/core';
|
||||||
import {ɵResourceLoaderImpl as ResourceLoaderImpl} from '@angular/platform-browser-dynamic';
|
import {ɵResourceLoaderImpl as ResourceLoaderImpl} from '@angular/platform-browser-dynamic';
|
||||||
export {VERSION} from './version';
|
export {VERSION} from './version';
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
* found in the LICENSE file at https://angular.io/license
|
* found in the LICENSE file at https://angular.io/license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {PlatformRef, Provider} from '@angular/core';
|
import {PlatformRef, StaticProvider} from '@angular/core';
|
||||||
|
|
||||||
import {WORKER_SCRIPT, platformWorkerUi} from './worker_render';
|
import {WORKER_SCRIPT, platformWorkerUi} from './worker_render';
|
||||||
|
|
||||||
@ -26,7 +26,7 @@ export {platformWorkerUi} from './worker_render';
|
|||||||
* @experimental
|
* @experimental
|
||||||
*/
|
*/
|
||||||
export function bootstrapWorkerUi(
|
export function bootstrapWorkerUi(
|
||||||
workerScriptUri: string, customProviders: Provider[] = []): Promise<PlatformRef> {
|
workerScriptUri: string, customProviders: StaticProvider[] = []): Promise<PlatformRef> {
|
||||||
// For now, just creates the worker ui platform...
|
// For now, just creates the worker ui platform...
|
||||||
const platform = platformWorkerUi([
|
const platform = platformWorkerUi([
|
||||||
{provide: WORKER_SCRIPT, useValue: workerScriptUri},
|
{provide: WORKER_SCRIPT, useValue: workerScriptUri},
|
||||||
|
@ -6,9 +6,14 @@
|
|||||||
* found in the LICENSE file at https://angular.io/license
|
* found in the LICENSE file at https://angular.io/license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {Injector, NgZone, PLATFORM_INITIALIZER, Provider} from '@angular/core';
|
import {DOCUMENT} from '@angular/common';
|
||||||
|
import {Injector, NgZone, PLATFORM_INITIALIZER, StaticProvider} from '@angular/core';
|
||||||
import {ɵBrowserPlatformLocation as BrowserPlatformLocation} from '@angular/platform-browser';
|
import {ɵBrowserPlatformLocation as BrowserPlatformLocation} from '@angular/platform-browser';
|
||||||
|
|
||||||
|
import {MessageBus} from '../shared/message_bus';
|
||||||
|
import {Serializer} from '../shared/serializer';
|
||||||
|
import {ServiceMessageBrokerFactory} from '../shared/service_message_broker';
|
||||||
|
|
||||||
import {MessageBasedPlatformLocation} from './platform_location';
|
import {MessageBasedPlatformLocation} from './platform_location';
|
||||||
|
|
||||||
|
|
||||||
@ -18,8 +23,10 @@ import {MessageBasedPlatformLocation} from './platform_location';
|
|||||||
* include these providers when setting up the render thread.
|
* include these providers when setting up the render thread.
|
||||||
* @experimental
|
* @experimental
|
||||||
*/
|
*/
|
||||||
export const WORKER_UI_LOCATION_PROVIDERS: Provider[] = [
|
export const WORKER_UI_LOCATION_PROVIDERS = <StaticProvider[]>[
|
||||||
MessageBasedPlatformLocation, BrowserPlatformLocation,
|
{provide: MessageBasedPlatformLocation, deps: [ServiceMessageBrokerFactory,
|
||||||
|
BrowserPlatformLocation, MessageBus, Serializer]},
|
||||||
|
{provide: BrowserPlatformLocation, deps: [DOCUMENT]},
|
||||||
{provide: PLATFORM_INITIALIZER, useFactory: initUiLocation, multi: true, deps: [Injector]}
|
{provide: PLATFORM_INITIALIZER, useFactory: initUiLocation, multi: true, deps: [Injector]}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -7,8 +7,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import {CommonModule, ɵPLATFORM_WORKER_APP_ID as PLATFORM_WORKER_APP_ID} from '@angular/common';
|
import {CommonModule, ɵPLATFORM_WORKER_APP_ID as PLATFORM_WORKER_APP_ID} from '@angular/common';
|
||||||
import {APP_INITIALIZER, ApplicationModule, ErrorHandler, NgModule, NgZone, PLATFORM_ID, PlatformRef, Provider, RendererFactory2, RootRenderer, createPlatformFactory, platformCore} from '@angular/core';
|
import {APP_INITIALIZER, ApplicationModule, ErrorHandler, NgModule, NgZone, PLATFORM_ID, PlatformRef, RendererFactory2, RootRenderer, StaticProvider, createPlatformFactory, platformCore} from '@angular/core';
|
||||||
import {DOCUMENT, ɵBROWSER_SANITIZATION_PROVIDERS as BROWSER_SANITIZATION_PROVIDERS} from '@angular/platform-browser';
|
import {DOCUMENT, ɵBROWSER_SANITIZATION_PROVIDERS as BROWSER_SANITIZATION_PROVIDERS} from '@angular/platform-browser';
|
||||||
|
|
||||||
import {ON_WEB_WORKER} from './web_workers/shared/api';
|
import {ON_WEB_WORKER} from './web_workers/shared/api';
|
||||||
import {ClientMessageBrokerFactory, ClientMessageBrokerFactory_} from './web_workers/shared/client_message_broker';
|
import {ClientMessageBrokerFactory, ClientMessageBrokerFactory_} from './web_workers/shared/client_message_broker';
|
||||||
import {MessageBus} from './web_workers/shared/message_bus';
|
import {MessageBus} from './web_workers/shared/message_bus';
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import {CommonModule, ɵPLATFORM_WORKER_UI_ID as PLATFORM_WORKER_UI_ID} from '@angular/common';
|
import {CommonModule, ɵPLATFORM_WORKER_UI_ID as PLATFORM_WORKER_UI_ID} from '@angular/common';
|
||||||
import {ErrorHandler, Injectable, InjectionToken, Injector, NgZone, PLATFORM_ID, PLATFORM_INITIALIZER, PlatformRef, Provider, RendererFactory2, RootRenderer, Testability, createPlatformFactory, isDevMode, platformCore, ɵAPP_ID_RANDOM_PROVIDER as APP_ID_RANDOM_PROVIDER} from '@angular/core';
|
import {ErrorHandler, Injectable, InjectionToken, Injector, NgZone, PLATFORM_ID, PLATFORM_INITIALIZER, PlatformRef, RendererFactory2, RootRenderer, StaticProvider, Testability, createPlatformFactory, isDevMode, platformCore, ɵAPP_ID_RANDOM_PROVIDER as APP_ID_RANDOM_PROVIDER} from '@angular/core';
|
||||||
import {DOCUMENT, 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, ɵgetDOM as getDOM} from '@angular/platform-browser';
|
import {DOCUMENT, 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, ɵgetDOM as getDOM} from '@angular/platform-browser';
|
||||||
|
|
||||||
import {ON_WEB_WORKER} from './web_workers/shared/api';
|
import {ON_WEB_WORKER} from './web_workers/shared/api';
|
||||||
@ -20,6 +20,7 @@ import {ServiceMessageBrokerFactory, ServiceMessageBrokerFactory_} from './web_w
|
|||||||
import {MessageBasedRenderer2} from './web_workers/ui/renderer';
|
import {MessageBasedRenderer2} from './web_workers/ui/renderer';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrapper class that exposes the Worker
|
* Wrapper class that exposes the Worker
|
||||||
* and underlying {@link MessageBus} for lower level message passing.
|
* and underlying {@link MessageBus} for lower level message passing.
|
||||||
@ -52,32 +53,53 @@ export const WORKER_SCRIPT = new InjectionToken<string>('WebWorkerScript');
|
|||||||
export const WORKER_UI_STARTABLE_MESSAGING_SERVICE =
|
export const WORKER_UI_STARTABLE_MESSAGING_SERVICE =
|
||||||
new InjectionToken<({start: () => void})[]>('WorkerRenderStartableMsgService');
|
new InjectionToken<({start: () => void})[]>('WorkerRenderStartableMsgService');
|
||||||
|
|
||||||
export const _WORKER_UI_PLATFORM_PROVIDERS: Provider[] = [
|
export const _WORKER_UI_PLATFORM_PROVIDERS: StaticProvider[] = [
|
||||||
{provide: NgZone, useFactory: createNgZone, deps: []},
|
{provide: NgZone, useFactory: createNgZone, deps: []},
|
||||||
MessageBasedRenderer2,
|
{
|
||||||
|
provide: MessageBasedRenderer2,
|
||||||
|
deps: [ServiceMessageBrokerFactory, MessageBus, Serializer, RenderStore, RendererFactory2]
|
||||||
|
},
|
||||||
{provide: WORKER_UI_STARTABLE_MESSAGING_SERVICE, useExisting: MessageBasedRenderer2, multi: true},
|
{provide: WORKER_UI_STARTABLE_MESSAGING_SERVICE, useExisting: MessageBasedRenderer2, multi: true},
|
||||||
BROWSER_SANITIZATION_PROVIDERS,
|
BROWSER_SANITIZATION_PROVIDERS,
|
||||||
{provide: ErrorHandler, useFactory: _exceptionHandler, deps: []},
|
{provide: ErrorHandler, useFactory: _exceptionHandler, deps: []},
|
||||||
{provide: DOCUMENT, useFactory: _document, deps: []},
|
{provide: DOCUMENT, useFactory: _document, deps: []},
|
||||||
// TODO(jteplitz602): Investigate if we definitely need EVENT_MANAGER on the render thread
|
// TODO(jteplitz602): Investigate if we definitely need EVENT_MANAGER on the render thread
|
||||||
// #5298
|
// #5298
|
||||||
{provide: EVENT_MANAGER_PLUGINS, useClass: DomEventsPlugin, multi: true},
|
{
|
||||||
{provide: EVENT_MANAGER_PLUGINS, useClass: KeyEventsPlugin, multi: true},
|
provide: EVENT_MANAGER_PLUGINS,
|
||||||
{provide: EVENT_MANAGER_PLUGINS, useClass: HammerGesturesPlugin, multi: true},
|
useClass: DomEventsPlugin,
|
||||||
{provide: HAMMER_GESTURE_CONFIG, useClass: HammerGestureConfig},
|
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,
|
APP_ID_RANDOM_PROVIDER,
|
||||||
DomRendererFactory2,
|
{provide: DomRendererFactory2, deps: [EventManager, DomSharedStylesHost]},
|
||||||
{provide: RendererFactory2, useExisting: DomRendererFactory2},
|
{provide: RendererFactory2, useExisting: DomRendererFactory2},
|
||||||
{provide: SharedStylesHost, useExisting: DomSharedStylesHost},
|
{provide: SharedStylesHost, useExisting: DomSharedStylesHost},
|
||||||
{provide: ServiceMessageBrokerFactory, useClass: ServiceMessageBrokerFactory_},
|
{
|
||||||
{provide: ClientMessageBrokerFactory, useClass: ClientMessageBrokerFactory_},
|
provide: ServiceMessageBrokerFactory,
|
||||||
Serializer,
|
useClass: ServiceMessageBrokerFactory_,
|
||||||
|
deps: [MessageBus, Serializer]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
provide: ClientMessageBrokerFactory,
|
||||||
|
useClass: ClientMessageBrokerFactory_,
|
||||||
|
deps: [MessageBus, Serializer]
|
||||||
|
},
|
||||||
|
{provide: Serializer, deps: [RenderStore]},
|
||||||
{provide: ON_WEB_WORKER, useValue: false},
|
{provide: ON_WEB_WORKER, useValue: false},
|
||||||
RenderStore,
|
{provide: RenderStore, deps: []},
|
||||||
DomSharedStylesHost,
|
{provide: DomSharedStylesHost, deps: [DOCUMENT]},
|
||||||
Testability,
|
{provide: Testability, deps: [NgZone]},
|
||||||
EventManager,
|
{provide: EventManager, deps: [EVENT_MANAGER_PLUGINS, NgZone]},
|
||||||
WebWorkerInstance,
|
{provide: WebWorkerInstance, deps: []},
|
||||||
{
|
{
|
||||||
provide: PLATFORM_INITIALIZER,
|
provide: PLATFORM_INITIALIZER,
|
||||||
useFactory: initWebWorkerRenderPlatform,
|
useFactory: initWebWorkerRenderPlatform,
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
* found in the LICENSE file at https://angular.io/license
|
* found in the LICENSE file at https://angular.io/license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {ApplicationRef, ChangeDetectorRef, ComponentFactory, ComponentRef, EventEmitter, Injector, OnChanges, ReflectiveInjector, SimpleChange, SimpleChanges, Type} from '@angular/core';
|
import {ApplicationRef, ChangeDetectorRef, ComponentFactory, ComponentRef, EventEmitter, Injector, OnChanges, SimpleChange, SimpleChanges, Type} from '@angular/core';
|
||||||
|
|
||||||
import * as angular from './angular1';
|
import * as angular from './angular1';
|
||||||
import {PropertyBinding} from './component_info';
|
import {PropertyBinding} from './component_info';
|
||||||
@ -57,8 +57,8 @@ export class DowngradeComponentAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
createComponent(projectableNodes: Node[][]) {
|
createComponent(projectableNodes: Node[][]) {
|
||||||
const childInjector = ReflectiveInjector.resolveAndCreate(
|
const childInjector =
|
||||||
[{provide: $SCOPE, useValue: this.componentScope}], this.parentInjector);
|
Injector.create([{provide: $SCOPE, useValue: this.componentScope}], this.parentInjector);
|
||||||
|
|
||||||
this.componentRef =
|
this.componentRef =
|
||||||
this.componentFactory.create(childInjector, projectableNodes, this.element[0]);
|
this.componentFactory.create(childInjector, projectableNodes, this.element[0]);
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
* found in the LICENSE file at https://angular.io/license
|
* found in the LICENSE file at https://angular.io/license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {Compiler, CompilerOptions, Directive, Injector, NgModule, NgModuleRef, NgZone, Provider, Testability, Type} from '@angular/core';
|
import {Compiler, CompilerOptions, Directive, Injector, NgModule, NgModuleRef, NgZone, StaticProvider, Testability, Type} from '@angular/core';
|
||||||
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
|
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
|
||||||
|
|
||||||
import * as angular from '../common/angular1';
|
import * as angular from '../common/angular1';
|
||||||
@ -110,7 +110,7 @@ export class UpgradeAdapter {
|
|||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
private ng1ComponentsToBeUpgraded: {[name: string]: UpgradeNg1ComponentAdapterBuilder} = {};
|
private ng1ComponentsToBeUpgraded: {[name: string]: UpgradeNg1ComponentAdapterBuilder} = {};
|
||||||
private upgradedProviders: Provider[] = [];
|
private upgradedProviders: StaticProvider[] = [];
|
||||||
private ngZone: NgZone;
|
private ngZone: NgZone;
|
||||||
private ng1Module: angular.IModule;
|
private ng1Module: angular.IModule;
|
||||||
private moduleRef: NgModuleRef<any>|null = null;
|
private moduleRef: NgModuleRef<any>|null = null;
|
||||||
|
@ -43,7 +43,7 @@ export const angular1Providers = [
|
|||||||
// > Metadata collected contains an error that will be reported at runtime:
|
// > Metadata collected contains an error that will be reported at runtime:
|
||||||
// > Function calls are not supported.
|
// > Function calls are not supported.
|
||||||
// > Consider replacing the function or lambda with a reference to an exported function
|
// > Consider replacing the function or lambda with a reference to an exported function
|
||||||
{provide: '$injector', useFactory: injectorFactory},
|
{provide: '$injector', useFactory: injectorFactory, deps: []},
|
||||||
{provide: '$rootScope', useFactory: rootScopeFactory, deps: ['$injector']},
|
{provide: '$rootScope', useFactory: rootScopeFactory, deps: ['$injector']},
|
||||||
{provide: '$compile', useFactory: compileFactory, deps: ['$injector']},
|
{provide: '$compile', useFactory: compileFactory, deps: ['$injector']},
|
||||||
{provide: '$parse', useFactory: parseFactory, deps: ['$injector']}
|
{provide: '$parse', useFactory: parseFactory, deps: ['$injector']}
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
* found in the LICENSE file at https://angular.io/license
|
* found in the LICENSE file at https://angular.io/license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {Injector, NgModuleFactory, NgModuleRef, Provider} from '@angular/core';
|
import {Injector, NgModuleFactory, NgModuleRef, StaticProvider} from '@angular/core';
|
||||||
import {platformBrowser} from '@angular/platform-browser';
|
import {platformBrowser} from '@angular/platform-browser';
|
||||||
|
|
||||||
import * as angular from '../common/angular1';
|
import * as angular from '../common/angular1';
|
||||||
@ -20,11 +20,11 @@ import {NgAdapterInjector} from './util';
|
|||||||
/** @experimental */
|
/** @experimental */
|
||||||
export function downgradeModule<T>(
|
export function downgradeModule<T>(
|
||||||
moduleFactoryOrBootstrapFn: NgModuleFactory<T>|
|
moduleFactoryOrBootstrapFn: NgModuleFactory<T>|
|
||||||
((extraProviders: Provider[]) => Promise<NgModuleRef<T>>)): string {
|
((extraProviders: StaticProvider[]) => Promise<NgModuleRef<T>>)): string {
|
||||||
const LAZY_MODULE_NAME = UPGRADE_MODULE_NAME + '.lazy';
|
const LAZY_MODULE_NAME = UPGRADE_MODULE_NAME + '.lazy';
|
||||||
const bootstrapFn = isFunction(moduleFactoryOrBootstrapFn) ?
|
const bootstrapFn = isFunction(moduleFactoryOrBootstrapFn) ?
|
||||||
moduleFactoryOrBootstrapFn :
|
moduleFactoryOrBootstrapFn :
|
||||||
(extraProviders: Provider[]) =>
|
(extraProviders: StaticProvider[]) =>
|
||||||
platformBrowser(extraProviders).bootstrapModuleFactory(moduleFactoryOrBootstrapFn);
|
platformBrowser(extraProviders).bootstrapModuleFactory(moduleFactoryOrBootstrapFn);
|
||||||
|
|
||||||
let injector: Injector;
|
let injector: Injector;
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
* found in the LICENSE file at https://angular.io/license
|
* found in the LICENSE file at https://angular.io/license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {Component, Inject, Injector, Input, NgModule, NgZone, OnChanges, Provider, destroyPlatform} from '@angular/core';
|
import {Component, Inject, Injector, Input, NgModule, NgZone, OnChanges, StaticProvider, destroyPlatform} from '@angular/core';
|
||||||
import {async, fakeAsync, tick} from '@angular/core/testing';
|
import {async, fakeAsync, tick} from '@angular/core/testing';
|
||||||
import {BrowserModule} from '@angular/platform-browser';
|
import {BrowserModule} from '@angular/platform-browser';
|
||||||
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
|
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
|
||||||
@ -46,7 +46,7 @@ export function main() {
|
|||||||
ngDoBootstrap() {}
|
ngDoBootstrap() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
const bootstrapFn = (extraProviders: Provider[]) =>
|
const bootstrapFn = (extraProviders: StaticProvider[]) =>
|
||||||
platformBrowserDynamic(extraProviders).bootstrapModule(Ng2Module);
|
platformBrowserDynamic(extraProviders).bootstrapModule(Ng2Module);
|
||||||
const lazyModuleName = downgradeModule<Ng2Module>(bootstrapFn);
|
const lazyModuleName = downgradeModule<Ng2Module>(bootstrapFn);
|
||||||
const ng1Module =
|
const ng1Module =
|
||||||
@ -108,7 +108,7 @@ export function main() {
|
|||||||
ngDoBootstrap() {}
|
ngDoBootstrap() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
const bootstrapFn = (extraProviders: Provider[]) =>
|
const bootstrapFn = (extraProviders: StaticProvider[]) =>
|
||||||
platformBrowserDynamic(extraProviders).bootstrapModule(Ng2Module);
|
platformBrowserDynamic(extraProviders).bootstrapModule(Ng2Module);
|
||||||
const lazyModuleName = downgradeModule<Ng2Module>(bootstrapFn);
|
const lazyModuleName = downgradeModule<Ng2Module>(bootstrapFn);
|
||||||
const ng1Module =
|
const ng1Module =
|
||||||
@ -152,7 +152,7 @@ export function main() {
|
|||||||
ngDoBootstrap() {}
|
ngDoBootstrap() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
const bootstrapFn = (extraProviders: Provider[]) =>
|
const bootstrapFn = (extraProviders: StaticProvider[]) =>
|
||||||
platformBrowserDynamic(extraProviders).bootstrapModule(Ng2Module);
|
platformBrowserDynamic(extraProviders).bootstrapModule(Ng2Module);
|
||||||
const lazyModuleName = downgradeModule<Ng2Module>(bootstrapFn);
|
const lazyModuleName = downgradeModule<Ng2Module>(bootstrapFn);
|
||||||
const ng1Module =
|
const ng1Module =
|
||||||
@ -191,7 +191,7 @@ export function main() {
|
|||||||
ngDoBootstrap() {}
|
ngDoBootstrap() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
const bootstrapFn = (extraProviders: Provider[]) =>
|
const bootstrapFn = (extraProviders: StaticProvider[]) =>
|
||||||
platformBrowserDynamic(extraProviders).bootstrapModule(Ng2Module);
|
platformBrowserDynamic(extraProviders).bootstrapModule(Ng2Module);
|
||||||
const lazyModuleName = downgradeModule<Ng2Module>(bootstrapFn);
|
const lazyModuleName = downgradeModule<Ng2Module>(bootstrapFn);
|
||||||
const ng1Module =
|
const ng1Module =
|
||||||
@ -245,7 +245,7 @@ export function main() {
|
|||||||
ngDoBootstrap() {}
|
ngDoBootstrap() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
const bootstrapFn = (extraProviders: Provider[]) =>
|
const bootstrapFn = (extraProviders: StaticProvider[]) =>
|
||||||
platformBrowserDynamic(extraProviders).bootstrapModule(Ng2Module);
|
platformBrowserDynamic(extraProviders).bootstrapModule(Ng2Module);
|
||||||
const lazyModuleName = downgradeModule<Ng2Module>(bootstrapFn);
|
const lazyModuleName = downgradeModule<Ng2Module>(bootstrapFn);
|
||||||
const ng1Module =
|
const ng1Module =
|
||||||
@ -300,7 +300,7 @@ export function main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const tickDelay = browserDetection.isIE ? 100 : 0;
|
const tickDelay = browserDetection.isIE ? 100 : 0;
|
||||||
const bootstrapFn = (extraProviders: Provider[]) =>
|
const bootstrapFn = (extraProviders: StaticProvider[]) =>
|
||||||
platformBrowserDynamic(extraProviders).bootstrapModule(Ng2Module);
|
platformBrowserDynamic(extraProviders).bootstrapModule(Ng2Module);
|
||||||
const lazyModuleName = downgradeModule<Ng2Module>(bootstrapFn);
|
const lazyModuleName = downgradeModule<Ng2Module>(bootstrapFn);
|
||||||
const ng1Module =
|
const ng1Module =
|
||||||
@ -355,7 +355,7 @@ export function main() {
|
|||||||
ngDoBootstrap() {}
|
ngDoBootstrap() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
const bootstrapFn = (extraProviders: Provider[]) =>
|
const bootstrapFn = (extraProviders: StaticProvider[]) =>
|
||||||
platformBrowserDynamic(extraProviders).bootstrapModule(Ng2Module);
|
platformBrowserDynamic(extraProviders).bootstrapModule(Ng2Module);
|
||||||
const lazyModuleName = downgradeModule<Ng2Module>(bootstrapFn);
|
const lazyModuleName = downgradeModule<Ng2Module>(bootstrapFn);
|
||||||
const ng1Module =
|
const ng1Module =
|
||||||
|
12
tools/public_api_guard/core/core.d.ts
vendored
12
tools/public_api_guard/core/core.d.ts
vendored
@ -209,7 +209,7 @@ export declare type CompilerOptions = {
|
|||||||
/** @deprecated */ useDebug?: boolean;
|
/** @deprecated */ useDebug?: boolean;
|
||||||
useJit?: boolean;
|
useJit?: boolean;
|
||||||
defaultEncapsulation?: ViewEncapsulation;
|
defaultEncapsulation?: ViewEncapsulation;
|
||||||
providers?: any[];
|
providers?: StaticProvider[];
|
||||||
missingTranslation?: MissingTranslationStrategy;
|
missingTranslation?: MissingTranslationStrategy;
|
||||||
enableLegacyTemplate?: boolean;
|
enableLegacyTemplate?: boolean;
|
||||||
};
|
};
|
||||||
@ -289,7 +289,7 @@ export interface ContentChildrenDecorator {
|
|||||||
export declare function createPlatform(injector: Injector): PlatformRef;
|
export declare function createPlatform(injector: Injector): PlatformRef;
|
||||||
|
|
||||||
/** @experimental */
|
/** @experimental */
|
||||||
export declare function createPlatformFactory(parentPlatformFactory: ((extraProviders?: Provider[]) => PlatformRef) | null, name: string, providers?: Provider[]): (extraProviders?: Provider[]) => PlatformRef;
|
export declare function createPlatformFactory(parentPlatformFactory: ((extraProviders?: StaticProvider[]) => PlatformRef) | null, name: string, providers?: StaticProvider[]): (extraProviders?: StaticProvider[]) => PlatformRef;
|
||||||
|
|
||||||
/** @stable */
|
/** @stable */
|
||||||
export declare const CUSTOM_ELEMENTS_SCHEMA: SchemaMetadata;
|
export declare const CUSTOM_ELEMENTS_SCHEMA: SchemaMetadata;
|
||||||
@ -537,7 +537,7 @@ export declare class IterableDiffers {
|
|||||||
constructor(factories: IterableDifferFactory[]);
|
constructor(factories: IterableDifferFactory[]);
|
||||||
find(iterable: any): IterableDifferFactory;
|
find(iterable: any): IterableDifferFactory;
|
||||||
static create(factories: IterableDifferFactory[], parent?: IterableDiffers): IterableDiffers;
|
static create(factories: IterableDifferFactory[], parent?: IterableDiffers): IterableDiffers;
|
||||||
static extend(factories: IterableDifferFactory[]): Provider;
|
static extend(factories: IterableDifferFactory[]): StaticProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @deprecated */
|
/** @deprecated */
|
||||||
@ -580,7 +580,7 @@ export declare class KeyValueDiffers {
|
|||||||
constructor(factories: KeyValueDifferFactory[]);
|
constructor(factories: KeyValueDifferFactory[]);
|
||||||
find(kv: any): KeyValueDifferFactory;
|
find(kv: any): KeyValueDifferFactory;
|
||||||
static create<S>(factories: KeyValueDifferFactory[], parent?: KeyValueDiffers): KeyValueDiffers;
|
static create<S>(factories: KeyValueDifferFactory[], parent?: KeyValueDiffers): KeyValueDiffers;
|
||||||
static extend<S>(factories: KeyValueDifferFactory[]): Provider;
|
static extend<S>(factories: KeyValueDifferFactory[]): StaticProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @experimental */
|
/** @experimental */
|
||||||
@ -715,7 +715,7 @@ export declare const PLATFORM_ID: InjectionToken<Object>;
|
|||||||
export declare const PLATFORM_INITIALIZER: InjectionToken<(() => void)[]>;
|
export declare const PLATFORM_INITIALIZER: InjectionToken<(() => void)[]>;
|
||||||
|
|
||||||
/** @experimental */
|
/** @experimental */
|
||||||
export declare const platformCore: (extraProviders?: Provider[] | undefined) => PlatformRef;
|
export declare const platformCore: (extraProviders?: StaticProvider[] | undefined) => PlatformRef;
|
||||||
|
|
||||||
/** @stable */
|
/** @stable */
|
||||||
export declare abstract class PlatformRef {
|
export declare abstract class PlatformRef {
|
||||||
@ -772,7 +772,7 @@ export declare abstract class ReflectiveInjector implements Injector {
|
|||||||
static resolveAndCreate(providers: Provider[], parent?: Injector): ReflectiveInjector;
|
static resolveAndCreate(providers: Provider[], parent?: Injector): ReflectiveInjector;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @experimental */
|
/** @deprecated */
|
||||||
export declare class ReflectiveKey {
|
export declare class ReflectiveKey {
|
||||||
readonly displayName: string;
|
readonly displayName: string;
|
||||||
id: number;
|
id: number;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/** @stable */
|
/** @stable */
|
||||||
export declare const platformBrowserDynamic: (extraProviders?: Provider[] | undefined) => PlatformRef;
|
export declare const platformBrowserDynamic: (extraProviders?: StaticProvider[] | undefined) => PlatformRef;
|
||||||
|
|
||||||
/** @experimental */
|
/** @experimental */
|
||||||
export declare const RESOURCE_CACHE_PROVIDER: Provider[];
|
export declare const RESOURCE_CACHE_PROVIDER: Provider[];
|
||||||
|
@ -3,4 +3,4 @@ export declare class BrowserDynamicTestingModule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** @stable */
|
/** @stable */
|
||||||
export declare const platformBrowserDynamicTesting: (extraProviders?: Provider[] | undefined) => PlatformRef;
|
export declare const platformBrowserDynamicTesting: (extraProviders?: StaticProvider[] | undefined) => PlatformRef;
|
||||||
|
@ -90,7 +90,7 @@ export declare class NgProbeToken {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** @stable */
|
/** @stable */
|
||||||
export declare const platformBrowser: (extraProviders?: Provider[]) => PlatformRef;
|
export declare const platformBrowser: (extraProviders?: StaticProvider[]) => PlatformRef;
|
||||||
|
|
||||||
/** @stable */
|
/** @stable */
|
||||||
export interface SafeHtml extends SafeValue {
|
export interface SafeHtml extends SafeValue {
|
||||||
|
@ -3,4 +3,4 @@ export declare class BrowserTestingModule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** @stable */
|
/** @stable */
|
||||||
export declare const platformBrowserTesting: (extraProviders?: Provider[] | undefined) => PlatformRef;
|
export declare const platformBrowserTesting: (extraProviders?: StaticProvider[] | undefined) => PlatformRef;
|
||||||
|
@ -8,10 +8,10 @@ export interface PlatformConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** @experimental */
|
/** @experimental */
|
||||||
export declare const platformDynamicServer: (extraProviders?: Provider[] | undefined) => PlatformRef;
|
export declare const platformDynamicServer: (extraProviders?: StaticProvider[] | undefined) => PlatformRef;
|
||||||
|
|
||||||
/** @experimental */
|
/** @experimental */
|
||||||
export declare const platformServer: (extraProviders?: Provider[] | undefined) => PlatformRef;
|
export declare const platformServer: (extraProviders?: StaticProvider[] | undefined) => PlatformRef;
|
||||||
|
|
||||||
/** @experimental */
|
/** @experimental */
|
||||||
export declare class PlatformState {
|
export declare class PlatformState {
|
||||||
@ -24,14 +24,14 @@ export declare class PlatformState {
|
|||||||
export declare function renderModule<T>(module: Type<T>, options: {
|
export declare function renderModule<T>(module: Type<T>, options: {
|
||||||
document?: string;
|
document?: string;
|
||||||
url?: string;
|
url?: string;
|
||||||
extraProviders?: Provider[];
|
extraProviders?: StaticProvider[];
|
||||||
}): Promise<string>;
|
}): Promise<string>;
|
||||||
|
|
||||||
/** @experimental */
|
/** @experimental */
|
||||||
export declare function renderModuleFactory<T>(moduleFactory: NgModuleFactory<T>, options: {
|
export declare function renderModuleFactory<T>(moduleFactory: NgModuleFactory<T>, options: {
|
||||||
document?: string;
|
document?: string;
|
||||||
url?: string;
|
url?: string;
|
||||||
extraProviders?: Provider[];
|
extraProviders?: StaticProvider[];
|
||||||
}): Promise<string>;
|
}): Promise<string>;
|
||||||
|
|
||||||
/** @experimental */
|
/** @experimental */
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/** @experimental */
|
/** @experimental */
|
||||||
export declare const platformServerTesting: (extraProviders?: Provider[] | undefined) => PlatformRef;
|
export declare const platformServerTesting: (extraProviders?: StaticProvider[] | undefined) => PlatformRef;
|
||||||
|
|
||||||
/** @experimental */
|
/** @experimental */
|
||||||
export declare class ServerTestingModule {
|
export declare class ServerTestingModule {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/** @experimental */
|
/** @experimental */
|
||||||
export declare const platformWorkerAppDynamic: (extraProviders?: Provider[] | undefined) => PlatformRef;
|
export declare const platformWorkerAppDynamic: (extraProviders?: StaticProvider[] | undefined) => PlatformRef;
|
||||||
|
|
||||||
/** @stable */
|
/** @stable */
|
||||||
export declare const VERSION: Version;
|
export declare const VERSION: Version;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/** @experimental */
|
/** @experimental */
|
||||||
export declare function bootstrapWorkerUi(workerScriptUri: string, customProviders?: Provider[]): Promise<PlatformRef>;
|
export declare function bootstrapWorkerUi(workerScriptUri: string, customProviders?: StaticProvider[]): Promise<PlatformRef>;
|
||||||
|
|
||||||
/** @experimental */
|
/** @experimental */
|
||||||
export declare abstract class ClientMessageBroker {
|
export declare abstract class ClientMessageBroker {
|
||||||
@ -41,10 +41,10 @@ export interface MessageBusSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** @experimental */
|
/** @experimental */
|
||||||
export declare const platformWorkerApp: (extraProviders?: Provider[] | undefined) => PlatformRef;
|
export declare const platformWorkerApp: (extraProviders?: StaticProvider[] | undefined) => PlatformRef;
|
||||||
|
|
||||||
/** @experimental */
|
/** @experimental */
|
||||||
export declare const platformWorkerUi: (extraProviders?: Provider[] | undefined) => PlatformRef;
|
export declare const platformWorkerUi: (extraProviders?: StaticProvider[] | undefined) => PlatformRef;
|
||||||
|
|
||||||
/** @experimental */
|
/** @experimental */
|
||||||
export declare const PRIMITIVE: SerializerTypes;
|
export declare const PRIMITIVE: SerializerTypes;
|
||||||
@ -100,7 +100,7 @@ export declare const WORKER_APP_LOCATION_PROVIDERS: ({
|
|||||||
})[];
|
})[];
|
||||||
|
|
||||||
/** @experimental */
|
/** @experimental */
|
||||||
export declare const WORKER_UI_LOCATION_PROVIDERS: Provider[];
|
export declare const WORKER_UI_LOCATION_PROVIDERS: StaticProvider[];
|
||||||
|
|
||||||
/** @experimental */
|
/** @experimental */
|
||||||
export declare class WorkerAppModule {
|
export declare class WorkerAppModule {
|
||||||
|
2
tools/public_api_guard/upgrade/static.d.ts
vendored
2
tools/public_api_guard/upgrade/static.d.ts
vendored
@ -11,7 +11,7 @@ export declare function downgradeComponent(info: {
|
|||||||
export declare function downgradeInjectable(token: any): Function;
|
export declare function downgradeInjectable(token: any): Function;
|
||||||
|
|
||||||
/** @experimental */
|
/** @experimental */
|
||||||
export declare function downgradeModule<T>(moduleFactoryOrBootstrapFn: NgModuleFactory<T> | ((extraProviders: Provider[]) => Promise<NgModuleRef<T>>)): string;
|
export declare function downgradeModule<T>(moduleFactoryOrBootstrapFn: NgModuleFactory<T> | ((extraProviders: StaticProvider[]) => Promise<NgModuleRef<T>>)): string;
|
||||||
|
|
||||||
/** @stable */
|
/** @stable */
|
||||||
export declare function getAngularLib(): any;
|
export declare function getAngularLib(): any;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user