diff --git a/gulpfile.js b/gulpfile.js index 97f47c2a14..f7ef9661b4 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -43,7 +43,9 @@ const entrypoints = [ 'dist/packages-dist/platform-server/index.d.ts', 'dist/packages-dist/platform-server/testing.d.ts', 'dist/packages-dist/http/index.d.ts', - 'dist/packages-dist/http/testing.d.ts' + 'dist/packages-dist/http/testing.d.ts', + 'dist/packages-dist/forms/index.d.ts', + 'dist/packages-dist/router/index.d.ts' ]; const publicApiDir = 'tools/public_api_guard'; const publicApiArgs = [ diff --git a/modules/@angular/common/src/forms-deprecated/form_builder.ts b/modules/@angular/common/src/forms-deprecated/form_builder.ts index a6da145f35..c724626785 100644 --- a/modules/@angular/common/src/forms-deprecated/form_builder.ts +++ b/modules/@angular/common/src/forms-deprecated/form_builder.ts @@ -12,7 +12,7 @@ import {StringMapWrapper} from '../facade/collection'; import {isArray, isPresent} from '../facade/lang'; import {AsyncValidatorFn, ValidatorFn} from './directives/validators'; -import * as modelModule from './model'; +import {AbstractControl, Control, ControlArray, ControlGroup} from './model'; @@ -67,22 +67,21 @@ export class FormBuilder { * * See the {@link ControlGroup} constructor for more details. */ - group(controlsConfig: {[key: string]: any}, extra: {[key: string]: any} = null): - modelModule.ControlGroup { + group(controlsConfig: {[key: string]: any}, extra: {[key: string]: any} = null): ControlGroup { var controls = this._reduceControls(controlsConfig); var optionals = <{[key: string]: boolean}>( isPresent(extra) ? StringMapWrapper.get(extra, 'optionals') : null); var validator: ValidatorFn = isPresent(extra) ? StringMapWrapper.get(extra, 'validator') : null; var asyncValidator: AsyncValidatorFn = isPresent(extra) ? StringMapWrapper.get(extra, 'asyncValidator') : null; - return new modelModule.ControlGroup(controls, optionals, validator, asyncValidator); + return new ControlGroup(controls, optionals, validator, asyncValidator); } /** * Construct a new {@link Control} with the given `value`,`validator`, and `asyncValidator`. */ control(value: Object, validator: ValidatorFn = null, asyncValidator: AsyncValidatorFn = null): - modelModule.Control { - return new modelModule.Control(value, validator, asyncValidator); + Control { + return new Control(value, validator, asyncValidator); } /** @@ -91,15 +90,14 @@ export class FormBuilder { */ array( controlsConfig: any[], validator: ValidatorFn = null, - asyncValidator: AsyncValidatorFn = null): modelModule.ControlArray { + asyncValidator: AsyncValidatorFn = null): ControlArray { var controls = controlsConfig.map(c => this._createControl(c)); - return new modelModule.ControlArray(controls, validator, asyncValidator); + return new ControlArray(controls, validator, asyncValidator); } /** @internal */ - _reduceControls(controlsConfig: {[k: string]: any}): - {[key: string]: modelModule.AbstractControl} { - var controls: {[key: string]: modelModule.AbstractControl} = {}; + _reduceControls(controlsConfig: {[k: string]: any}): {[key: string]: AbstractControl} { + var controls: {[key: string]: AbstractControl} = {}; StringMapWrapper.forEach(controlsConfig, (controlConfig: any, controlName: string) => { controls[controlName] = this._createControl(controlConfig); }); @@ -107,10 +105,9 @@ export class FormBuilder { } /** @internal */ - _createControl(controlConfig: any): modelModule.AbstractControl { - if (controlConfig instanceof modelModule.Control || - controlConfig instanceof modelModule.ControlGroup || - controlConfig instanceof modelModule.ControlArray) { + _createControl(controlConfig: any): AbstractControl { + if (controlConfig instanceof Control || controlConfig instanceof ControlGroup || + controlConfig instanceof ControlArray) { return controlConfig; } else if (isArray(controlConfig)) { diff --git a/modules/@angular/common/src/forms-deprecated/validators.ts b/modules/@angular/common/src/forms-deprecated/validators.ts index fc97be0b85..803f7ec2fb 100644 --- a/modules/@angular/common/src/forms-deprecated/validators.ts +++ b/modules/@angular/common/src/forms-deprecated/validators.ts @@ -12,7 +12,7 @@ import {StringMapWrapper} from '../facade/collection'; import {isBlank, isPresent, isPromise, isString} from '../facade/lang'; import {PromiseWrapper} from '../facade/promise'; import {AsyncValidatorFn, ValidatorFn} from './directives/validators'; -import * as modelModule from './model'; +import {AbstractControl} from './model'; /** * Providers for validators to be used for {@link Control}s in a form. @@ -57,7 +57,7 @@ export class Validators { /** * Validator that requires controls to have a non-empty value. */ - static required(control: modelModule.AbstractControl): {[key: string]: boolean} { + static required(control: AbstractControl): {[key: string]: boolean} { return isBlank(control.value) || (isString(control.value) && control.value == '') ? {'required': true} : null; @@ -67,7 +67,7 @@ export class Validators { * Validator that requires controls to have a value of a minimum length. */ static minLength(minLength: number): ValidatorFn { - return (control: modelModule.AbstractControl): {[key: string]: any} => { + return (control: AbstractControl): {[key: string]: any} => { if (isPresent(Validators.required(control))) return null; var v: string = control.value; return v.length < minLength ? @@ -80,7 +80,7 @@ export class Validators { * Validator that requires controls to have a value of a maximum length. */ static maxLength(maxLength: number): ValidatorFn { - return (control: modelModule.AbstractControl): {[key: string]: any} => { + return (control: AbstractControl): {[key: string]: any} => { if (isPresent(Validators.required(control))) return null; var v: string = control.value; return v.length > maxLength ? @@ -93,7 +93,7 @@ export class Validators { * Validator that requires a control to match a regex to its value. */ static pattern(pattern: string): ValidatorFn { - return (control: modelModule.AbstractControl): {[key: string]: any} => { + return (control: AbstractControl): {[key: string]: any} => { if (isPresent(Validators.required(control))) return null; let regex = new RegExp(`^${pattern}$`); let v: string = control.value; @@ -105,7 +105,7 @@ export class Validators { /** * No-op validator. */ - static nullValidator(c: modelModule.AbstractControl): {[key: string]: boolean} { return null; } + static nullValidator(c: AbstractControl): {[key: string]: boolean} { return null; } /** * Compose multiple validators into a single function that returns the union @@ -116,7 +116,7 @@ export class Validators { var presentValidators = validators.filter(isPresent); if (presentValidators.length == 0) return null; - return function(control: modelModule.AbstractControl) { + return function(control: AbstractControl) { return _mergeErrors(_executeValidators(control, presentValidators)); }; } @@ -126,7 +126,7 @@ export class Validators { var presentValidators = validators.filter(isPresent); if (presentValidators.length == 0) return null; - return function(control: modelModule.AbstractControl) { + return function(control: AbstractControl) { let promises = _executeAsyncValidators(control, presentValidators).map(_convertToPromise); return PromiseWrapper.all(promises).then(_mergeErrors); }; @@ -137,13 +137,11 @@ function _convertToPromise(obj: any): Promise { return isPromise(obj) ? obj : ObservableWrapper.toPromise(obj); } -function _executeValidators( - control: modelModule.AbstractControl, validators: ValidatorFn[]): any[] { +function _executeValidators(control: AbstractControl, validators: ValidatorFn[]): any[] { return validators.map(v => v(control)); } -function _executeAsyncValidators( - control: modelModule.AbstractControl, validators: AsyncValidatorFn[]): any[] { +function _executeAsyncValidators(control: AbstractControl, validators: AsyncValidatorFn[]): any[] { return validators.map(v => v(control)); } diff --git a/modules/@angular/core/src/profile/profile.ts b/modules/@angular/core/src/profile/profile.ts index ce4f80d878..d9d04c73a1 100644 --- a/modules/@angular/core/src/profile/profile.ts +++ b/modules/@angular/core/src/profile/profile.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import * as impl from './wtf_impl'; +import {WtfScopeFn, createScope, detectWTF, endTimeRange, leave, startTimeRange} from './wtf_impl'; export {WtfScopeFn} from './wtf_impl'; @@ -16,7 +16,7 @@ export {WtfScopeFn} from './wtf_impl'; /** * True if WTF is enabled. */ -export var wtfEnabled = impl.detectWTF(); +export var wtfEnabled = detectWTF(); function noopScope(arg0?: any, arg1?: any): any { return null; @@ -52,8 +52,8 @@ function noopScope(arg0?: any, arg1?: any): any { * * @experimental */ -export var wtfCreateScope: (signature: string, flags?: any) => impl.WtfScopeFn = - wtfEnabled ? impl.createScope : (signature: string, flags?: any) => noopScope; +export var wtfCreateScope: (signature: string, flags?: any) => WtfScopeFn = + wtfEnabled ? createScope : (signature: string, flags?: any) => noopScope; /** * Used to mark end of Scope. @@ -65,7 +65,7 @@ export var wtfCreateScope: (signature: string, flags?: any) => impl.WtfScopeFn = * @experimental */ export var wtfLeave: (scope: any, returnValue?: T) => T = - wtfEnabled ? impl.leave : (s: any, r?: any) => r; + wtfEnabled ? leave : (s: any, r?: any) => r; /** * Used to mark Async start. Async are similar to scope but they don't have to be strictly nested. @@ -81,7 +81,7 @@ export var wtfLeave: (scope: any, returnValue?: T) => T = * @experimental */ export var wtfStartTimeRange: (rangeType: string, action: string) => any = - wtfEnabled ? impl.startTimeRange : (rangeType: string, action: string) => null; + wtfEnabled ? startTimeRange : (rangeType: string, action: string) => null; /** * Ends a async time range operation. @@ -89,5 +89,4 @@ export var wtfStartTimeRange: (rangeType: string, action: string) => any = * enabled. * @experimental */ -export var wtfEndTimeRange: (range: any) => void = - wtfEnabled ? impl.endTimeRange : (r: any) => null; +export var wtfEndTimeRange: (range: any) => void = wtfEnabled ? endTimeRange : (r: any) => null; diff --git a/modules/@angular/forms/src/form_builder.ts b/modules/@angular/forms/src/form_builder.ts index c396d0bb63..6b70f808c4 100644 --- a/modules/@angular/forms/src/form_builder.ts +++ b/modules/@angular/forms/src/form_builder.ts @@ -11,7 +11,7 @@ import {Injectable} from '@angular/core'; import {AsyncValidatorFn, ValidatorFn} from './directives/validators'; import {StringMapWrapper} from './facade/collection'; import {isArray, isPresent} from './facade/lang'; -import * as modelModule from './model'; +import {AbstractControl, FormArray, FormControl, FormGroup} from './model'; @@ -63,23 +63,22 @@ export class FormBuilder { * * See the {@link FormGroup} constructor for more details. */ - group(controlsConfig: {[key: string]: any}, extra: {[key: string]: any} = null): - modelModule.FormGroup { + group(controlsConfig: {[key: string]: any}, extra: {[key: string]: any} = null): FormGroup { var controls = this._reduceControls(controlsConfig); var optionals = <{[key: string]: boolean}>( isPresent(extra) ? StringMapWrapper.get(extra, 'optionals') : null); var validator: ValidatorFn = isPresent(extra) ? StringMapWrapper.get(extra, 'validator') : null; var asyncValidator: AsyncValidatorFn = isPresent(extra) ? StringMapWrapper.get(extra, 'asyncValidator') : null; - return new modelModule.FormGroup(controls, optionals, validator, asyncValidator); + return new FormGroup(controls, optionals, validator, asyncValidator); } /** * Construct a new {@link FormControl} with the given `value`,`validator`, and `asyncValidator`. */ control( value: Object, validator: ValidatorFn|ValidatorFn[] = null, - asyncValidator: AsyncValidatorFn|AsyncValidatorFn[] = null): modelModule.FormControl { - return new modelModule.FormControl(value, validator, asyncValidator); + asyncValidator: AsyncValidatorFn|AsyncValidatorFn[] = null): FormControl { + return new FormControl(value, validator, asyncValidator); } /** @@ -88,15 +87,14 @@ export class FormBuilder { */ array( controlsConfig: any[], validator: ValidatorFn = null, - asyncValidator: AsyncValidatorFn = null): modelModule.FormArray { + asyncValidator: AsyncValidatorFn = null): FormArray { var controls = controlsConfig.map(c => this._createControl(c)); - return new modelModule.FormArray(controls, validator, asyncValidator); + return new FormArray(controls, validator, asyncValidator); } /** @internal */ - _reduceControls(controlsConfig: {[k: string]: any}): - {[key: string]: modelModule.AbstractControl} { - var controls: {[key: string]: modelModule.AbstractControl} = {}; + _reduceControls(controlsConfig: {[k: string]: any}): {[key: string]: AbstractControl} { + var controls: {[key: string]: AbstractControl} = {}; StringMapWrapper.forEach(controlsConfig, (controlConfig: any, controlName: string) => { controls[controlName] = this._createControl(controlConfig); }); @@ -104,10 +102,9 @@ export class FormBuilder { } /** @internal */ - _createControl(controlConfig: any): modelModule.AbstractControl { - if (controlConfig instanceof modelModule.FormControl || - controlConfig instanceof modelModule.FormGroup || - controlConfig instanceof modelModule.FormArray) { + _createControl(controlConfig: any): AbstractControl { + if (controlConfig instanceof FormControl || controlConfig instanceof FormGroup || + controlConfig instanceof FormArray) { return controlConfig; } else if (isArray(controlConfig)) { diff --git a/modules/@angular/forms/src/validators.ts b/modules/@angular/forms/src/validators.ts index 4515efda40..b6f5ca443a 100644 --- a/modules/@angular/forms/src/validators.ts +++ b/modules/@angular/forms/src/validators.ts @@ -12,7 +12,7 @@ import {ObservableWrapper} from './facade/async'; import {StringMapWrapper} from './facade/collection'; import {isBlank, isPresent, isPromise, isString} from './facade/lang'; import {PromiseWrapper} from './facade/promise'; -import * as modelModule from './model'; +import {AbstractControl} from './model'; /** * Providers for validators to be used for {@link FormControl}s in a form. @@ -57,7 +57,7 @@ export class Validators { /** * Validator that requires controls to have a non-empty value. */ - static required(control: modelModule.AbstractControl): {[key: string]: boolean} { + static required(control: AbstractControl): {[key: string]: boolean} { return isBlank(control.value) || (isString(control.value) && control.value == '') ? {'required': true} : null; @@ -67,7 +67,7 @@ export class Validators { * Validator that requires controls to have a value of a minimum length. */ static minLength(minLength: number): ValidatorFn { - return (control: modelModule.AbstractControl): {[key: string]: any} => { + return (control: AbstractControl): {[key: string]: any} => { if (isPresent(Validators.required(control))) return null; var v: string = control.value; return v.length < minLength ? @@ -80,7 +80,7 @@ export class Validators { * Validator that requires controls to have a value of a maximum length. */ static maxLength(maxLength: number): ValidatorFn { - return (control: modelModule.AbstractControl): {[key: string]: any} => { + return (control: AbstractControl): {[key: string]: any} => { if (isPresent(Validators.required(control))) return null; var v: string = control.value; return v.length > maxLength ? @@ -93,7 +93,7 @@ export class Validators { * Validator that requires a control to match a regex to its value. */ static pattern(pattern: string): ValidatorFn { - return (control: modelModule.AbstractControl): {[key: string]: any} => { + return (control: AbstractControl): {[key: string]: any} => { if (isPresent(Validators.required(control))) return null; let regex = new RegExp(`^${pattern}$`); let v: string = control.value; @@ -105,7 +105,7 @@ export class Validators { /** * No-op validator. */ - static nullValidator(c: modelModule.AbstractControl): {[key: string]: boolean} { return null; } + static nullValidator(c: AbstractControl): {[key: string]: boolean} { return null; } /** * Compose multiple validators into a single function that returns the union @@ -116,7 +116,7 @@ export class Validators { var presentValidators = validators.filter(isPresent); if (presentValidators.length == 0) return null; - return function(control: modelModule.AbstractControl) { + return function(control: AbstractControl) { return _mergeErrors(_executeValidators(control, presentValidators)); }; } @@ -126,7 +126,7 @@ export class Validators { var presentValidators = validators.filter(isPresent); if (presentValidators.length == 0) return null; - return function(control: modelModule.AbstractControl) { + return function(control: AbstractControl) { let promises = _executeAsyncValidators(control, presentValidators).map(_convertToPromise); return PromiseWrapper.all(promises).then(_mergeErrors); }; @@ -137,13 +137,11 @@ function _convertToPromise(obj: any): Promise { return isPromise(obj) ? obj : ObservableWrapper.toPromise(obj); } -function _executeValidators( - control: modelModule.AbstractControl, validators: ValidatorFn[]): any[] { +function _executeValidators(control: AbstractControl, validators: ValidatorFn[]): any[] { return validators.map(v => v(control)); } -function _executeAsyncValidators( - control: modelModule.AbstractControl, validators: AsyncValidatorFn[]): any[] { +function _executeAsyncValidators(control: AbstractControl, validators: AsyncValidatorFn[]): any[] { return validators.map(v => v(control)); } diff --git a/modules/@angular/router/src/router_providers.ts b/modules/@angular/router/src/router_providers.ts index 2706af1393..3d43e0921e 100644 --- a/modules/@angular/router/src/router_providers.ts +++ b/modules/@angular/router/src/router_providers.ts @@ -9,7 +9,7 @@ import {PlatformLocation} from '@angular/common'; import {BrowserPlatformLocation} from '@angular/platform-browser'; -import * as common from './common_router_providers'; +import {ExtraOptions, provideRouter as provideRouter_} from './common_router_providers'; import {RouterConfig} from './config'; @@ -31,9 +31,8 @@ import {RouterConfig} from './config'; * bootstrap(AppCmp, [provideRouter(router)]); * ``` */ -export function provideRouter(config: RouterConfig, opts: common.ExtraOptions = {}): any[] { +export function provideRouter(config: RouterConfig, opts: ExtraOptions = {}): any[] { return [ - {provide: PlatformLocation, useClass: BrowserPlatformLocation}, - ...common.provideRouter(config, opts) + {provide: PlatformLocation, useClass: BrowserPlatformLocation}, ...provideRouter_(config, opts) ]; } diff --git a/tools/public_api_guard/common/index.d.ts b/tools/public_api_guard/common/index.d.ts new file mode 100644 index 0000000000..75cad3000e --- /dev/null +++ b/tools/public_api_guard/common/index.d.ts @@ -0,0 +1,531 @@ +export declare abstract class AbstractControl { + validator: ValidatorFn; + asyncValidator: AsyncValidatorFn; + constructor(validator: ValidatorFn, asyncValidator: AsyncValidatorFn); + value: any; + status: string; + valid: boolean; + errors: { + [key: string]: any; + }; + pristine: boolean; + dirty: boolean; + touched: boolean; + untouched: boolean; + valueChanges: Observable; + statusChanges: Observable; + pending: boolean; + markAsTouched(): void; + markAsDirty({onlySelf}?: { + onlySelf?: boolean; + }): void; + markAsPending({onlySelf}?: { + onlySelf?: boolean; + }): void; + setParent(parent: ControlGroup | ControlArray): void; + updateValueAndValidity({onlySelf, emitEvent}?: { + onlySelf?: boolean; + emitEvent?: boolean; + }): void; + setErrors(errors: { + [key: string]: any; + }, {emitEvent}?: { + emitEvent?: boolean; + }): void; + find(path: Array | string): AbstractControl; + getError(errorCode: string, path?: string[]): any; + hasError(errorCode: string, path?: string[]): boolean; + root: AbstractControl; +} + +export declare abstract class AbstractControlDirective { + control: AbstractControl; + value: any; + valid: boolean; + errors: { + [key: string]: any; + }; + pristine: boolean; + dirty: boolean; + touched: boolean; + untouched: boolean; + path: string[]; +} + +export declare const APP_BASE_HREF: OpaqueToken; + +export declare class AsyncPipe implements OnDestroy { + constructor(_ref: ChangeDetectorRef); + ngOnDestroy(): void; + transform(obj: Observable | Promise | EventEmitter): any; +} + +export declare class CheckboxControlValueAccessor implements ControlValueAccessor { + onChange: (_: any) => void; + onTouched: () => void; + constructor(_renderer: Renderer, _elementRef: ElementRef); + writeValue(value: any): void; + registerOnChange(fn: (_: any) => {}): void; + registerOnTouched(fn: () => {}): void; +} + +export declare const COMMON_DIRECTIVES: Type[][]; + +export declare const COMMON_PIPES: (typeof AsyncPipe | typeof SlicePipe | typeof ReplacePipe | typeof I18nPluralPipe | typeof I18nSelectPipe)[]; + +export declare class Control extends AbstractControl { + constructor(value?: any, validator?: ValidatorFn, asyncValidator?: AsyncValidatorFn); + updateValue(value: any, {onlySelf, emitEvent, emitModelToViewChange}?: { + onlySelf?: boolean; + emitEvent?: boolean; + emitModelToViewChange?: boolean; + }): void; + registerOnChange(fn: Function): void; +} + +export declare class ControlArray extends AbstractControl { + controls: AbstractControl[]; + constructor(controls: AbstractControl[], validator?: ValidatorFn, asyncValidator?: AsyncValidatorFn); + at(index: number): AbstractControl; + push(control: AbstractControl): void; + insert(index: number, control: AbstractControl): void; + removeAt(index: number): void; + length: number; +} + +export declare class ControlContainer extends AbstractControlDirective { + name: string; + formDirective: Form; + path: string[]; +} + +export declare class ControlGroup extends AbstractControl { + controls: { + [key: string]: AbstractControl; + }; + constructor(controls: { + [key: string]: AbstractControl; + }, optionals?: { + [key: string]: boolean; + }, validator?: ValidatorFn, asyncValidator?: AsyncValidatorFn); + registerControl(name: string, control: AbstractControl): void; + addControl(name: string, control: AbstractControl): void; + removeControl(name: string): void; + include(controlName: string): void; + exclude(controlName: string): void; + contains(controlName: string): boolean; +} + +export interface ControlValueAccessor { + writeValue(obj: any): void; + registerOnChange(fn: any): void; + registerOnTouched(fn: any): void; +} + +export declare const CORE_DIRECTIVES: Type[]; + +export declare class CurrencyPipe implements PipeTransform { + transform(value: any, currencyCode?: string, symbolDisplay?: boolean, digits?: string): string; +} + +export declare class DatePipe implements PipeTransform { + transform(value: any, pattern?: string): string; +} + +export declare class DecimalPipe implements PipeTransform { + transform(value: any, digits?: string): string; +} + +export declare class DefaultValueAccessor implements ControlValueAccessor { + onChange: (_: any) => void; + onTouched: () => void; + constructor(_renderer: Renderer, _elementRef: ElementRef); + writeValue(value: any): void; + registerOnChange(fn: (_: any) => void): void; + registerOnTouched(fn: () => void): void; +} + +export interface Form { + addControl(dir: NgControl): void; + removeControl(dir: NgControl): void; + getControl(dir: NgControl): Control; + addControlGroup(dir: NgControlGroup): void; + removeControlGroup(dir: NgControlGroup): void; + getControlGroup(dir: NgControlGroup): ControlGroup; + updateModel(dir: NgControl, value: any): void; +} + +export declare const FORM_DIRECTIVES: Type[]; + +export declare const FORM_PROVIDERS: Type[]; + +export declare class FormBuilder { + group(controlsConfig: { + [key: string]: any; + }, extra?: { + [key: string]: any; + }): ControlGroup; + control(value: Object, validator?: ValidatorFn, asyncValidator?: AsyncValidatorFn): Control; + array(controlsConfig: any[], validator?: ValidatorFn, asyncValidator?: AsyncValidatorFn): ControlArray; +} + +export declare class HashLocationStrategy extends LocationStrategy { + constructor(_platformLocation: PlatformLocation, _baseHref?: string); + onPopState(fn: UrlChangeListener): void; + getBaseHref(): string; + path(): string; + prepareExternalUrl(internal: string): string; + pushState(state: any, title: string, path: string, queryParams: string): void; + replaceState(state: any, title: string, path: string, queryParams: string): void; + forward(): void; + back(): void; +} + +export declare class I18nPluralPipe implements PipeTransform { + constructor(_localization: NgLocalization); + transform(value: number, pluralMap: { + [count: string]: string; + }): string; +} + +export declare class I18nSelectPipe implements PipeTransform { + transform(value: string, mapping: { + [key: string]: string; + }): string; +} + +export declare class JsonPipe implements PipeTransform { + transform(value: any): string; +} + +export declare class Location { + constructor(platformStrategy: LocationStrategy); + path(): string; + isCurrentPathEqualTo(path: string, query?: string): boolean; + normalize(url: string): string; + prepareExternalUrl(url: string): string; + go(path: string, query?: string): void; + replaceState(path: string, query?: string): void; + forward(): void; + back(): void; + subscribe(onNext: (value: any) => void, onThrow?: (exception: any) => void, onReturn?: () => void): Object; + static normalizeQueryParams(params: string): string; + static joinWithSlash(start: string, end: string): string; + static stripTrailingSlash(url: string): string; +} + +export declare abstract class LocationStrategy { + abstract path(): string; + abstract prepareExternalUrl(internal: string): string; + abstract pushState(state: any, title: string, url: string, queryParams: string): void; + abstract replaceState(state: any, title: string, url: string, queryParams: string): void; + abstract forward(): void; + abstract back(): void; + abstract onPopState(fn: UrlChangeListener): void; + abstract getBaseHref(): string; +} + +export declare class LowerCasePipe implements PipeTransform { + transform(value: string): string; +} + +export declare class MaxLengthValidator implements Validator { + constructor(maxLength: string); + validate(c: AbstractControl): { + [key: string]: any; + }; +} + +export declare class MinLengthValidator implements Validator { + constructor(minLength: string); + validate(c: AbstractControl): { + [key: string]: any; + }; +} + +export declare const NG_ASYNC_VALIDATORS: OpaqueToken; + +export declare const NG_VALIDATORS: OpaqueToken; + +export declare const NG_VALUE_ACCESSOR: OpaqueToken; + +export declare class NgClass implements DoCheck, OnDestroy { + constructor(_iterableDiffers: IterableDiffers, _keyValueDiffers: KeyValueDiffers, _ngEl: ElementRef, _renderer: Renderer); + initialClasses: string; + rawClass: string | string[] | Set | { + [key: string]: any; + }; + ngDoCheck(): void; + ngOnDestroy(): void; +} + +export declare abstract class NgControl extends AbstractControlDirective { + name: string; + valueAccessor: ControlValueAccessor; + validator: ValidatorFn; + asyncValidator: AsyncValidatorFn; + abstract viewToModelUpdate(newValue: any): void; +} + +export declare class NgControlGroup extends ControlContainer implements OnInit, OnDestroy { + constructor(parent: ControlContainer, _validators: any[], _asyncValidators: any[]); + ngOnInit(): void; + ngOnDestroy(): void; + control: ControlGroup; + path: string[]; + formDirective: Form; + validator: ValidatorFn; + asyncValidator: AsyncValidatorFn; +} + +export declare class NgControlName extends NgControl implements OnChanges, OnDestroy { + model: any; + viewModel: any; + constructor(_parent: ControlContainer, _validators: any[], _asyncValidators: any[], valueAccessors: ControlValueAccessor[]); + ngOnChanges(changes: SimpleChanges): void; + ngOnDestroy(): void; + viewToModelUpdate(newValue: any): void; + path: string[]; + formDirective: any; + validator: ValidatorFn; + asyncValidator: AsyncValidatorFn; + control: Control; +} + +export declare class NgControlStatus { + constructor(cd: NgControl); + ngClassUntouched: boolean; + ngClassTouched: boolean; + ngClassPristine: boolean; + ngClassDirty: boolean; + ngClassValid: boolean; + ngClassInvalid: boolean; +} + +export declare class NgFor implements DoCheck { + constructor(_viewContainer: ViewContainerRef, _templateRef: TemplateRef, _iterableDiffers: IterableDiffers, _cdr: ChangeDetectorRef); + ngForOf: any; + ngForTemplate: TemplateRef; + ngForTrackBy: TrackByFn; + ngDoCheck(): void; +} + +export declare class NgForm extends ControlContainer implements Form { + form: ControlGroup; + ngSubmit: EventEmitter<{}>; + constructor(validators: any[], asyncValidators: any[]); + submitted: boolean; + formDirective: Form; + control: ControlGroup; + path: string[]; + controls: { + [key: string]: AbstractControl; + }; + addControl(dir: NgControl): void; + getControl(dir: NgControl): Control; + removeControl(dir: NgControl): void; + addControlGroup(dir: NgControlGroup): void; + removeControlGroup(dir: NgControlGroup): void; + getControlGroup(dir: NgControlGroup): ControlGroup; + updateModel(dir: NgControl, value: any): void; + onSubmit(): boolean; +} + +export declare class NgFormControl extends NgControl implements OnChanges { + form: Control; + update: EventEmitter<{}>; + model: any; + viewModel: any; + constructor(_validators: any[], _asyncValidators: any[], valueAccessors: ControlValueAccessor[]); + ngOnChanges(changes: SimpleChanges): void; + path: string[]; + validator: ValidatorFn; + asyncValidator: AsyncValidatorFn; + control: Control; + viewToModelUpdate(newValue: any): void; +} + +export declare class NgFormModel extends ControlContainer implements Form, OnChanges { + form: ControlGroup; + directives: NgControl[]; + ngSubmit: EventEmitter<{}>; + constructor(_validators: any[], _asyncValidators: any[]); + ngOnChanges(changes: SimpleChanges): void; + submitted: boolean; + formDirective: Form; + control: ControlGroup; + path: string[]; + addControl(dir: NgControl): void; + getControl(dir: NgControl): Control; + removeControl(dir: NgControl): void; + addControlGroup(dir: NgControlGroup): void; + removeControlGroup(dir: NgControlGroup): void; + getControlGroup(dir: NgControlGroup): ControlGroup; + updateModel(dir: NgControl, value: any): void; + onSubmit(): boolean; +} + +export declare class NgIf { + constructor(_viewContainer: ViewContainerRef, _templateRef: TemplateRef); + ngIf: any; +} + +export declare abstract class NgLocalization { + abstract getPluralCategory(value: any): string; +} + +export declare class NgModel extends NgControl implements OnChanges { + update: EventEmitter<{}>; + model: any; + viewModel: any; + constructor(_validators: any[], _asyncValidators: any[], valueAccessors: ControlValueAccessor[]); + ngOnChanges(changes: SimpleChanges): void; + control: Control; + path: string[]; + validator: ValidatorFn; + asyncValidator: AsyncValidatorFn; + viewToModelUpdate(newValue: any): void; +} + +export declare class NgPlural implements AfterContentInit { + cases: QueryList; + constructor(_localization: NgLocalization); + ngPlural: number; + ngAfterContentInit(): void; +} + +export declare class NgPluralCase { + value: string; + constructor(value: string, template: TemplateRef, viewContainer: ViewContainerRef); +} + +export declare class NgSelectOption implements OnDestroy { + id: string; + constructor(_element: ElementRef, _renderer: Renderer, _select: SelectControlValueAccessor); + ngValue: any; + value: any; + ngOnDestroy(): void; +} + +export declare class NgStyle implements DoCheck { + constructor(_differs: KeyValueDiffers, _ngEl: ElementRef, _renderer: Renderer); + rawStyle: { + [key: string]: string; + }; + ngDoCheck(): void; +} + +export declare class NgSwitch { + ngSwitch: any; +} + +export declare class NgSwitchCase { + constructor(viewContainer: ViewContainerRef, templateRef: TemplateRef, ngSwitch: NgSwitch); + ngSwitchCase: any; + ngSwitchWhen: any; +} + +export declare class NgSwitchDefault { + constructor(viewContainer: ViewContainerRef, templateRef: TemplateRef, sswitch: NgSwitch); +} + +export declare class NgTemplateOutlet { + constructor(_viewContainerRef: ViewContainerRef); + ngOutletContext: Object; + ngTemplateOutlet: TemplateRef; +} + +export declare class PathLocationStrategy extends LocationStrategy { + constructor(_platformLocation: PlatformLocation, href?: string); + onPopState(fn: UrlChangeListener): void; + getBaseHref(): string; + prepareExternalUrl(internal: string): string; + path(): string; + pushState(state: any, title: string, url: string, queryParams: string): void; + replaceState(state: any, title: string, url: string, queryParams: string): void; + forward(): void; + back(): void; +} + +export declare class PatternValidator implements Validator { + constructor(pattern: string); + validate(c: AbstractControl): { + [key: string]: any; + }; +} + +export declare class PercentPipe implements PipeTransform { + transform(value: any, digits?: string): string; +} + +export declare abstract class PlatformLocation { + abstract getBaseHrefFromDOM(): string; + abstract onPopState(fn: UrlChangeListener): void; + abstract onHashChange(fn: UrlChangeListener): void; + pathname: string; + search: string; + hash: string; + abstract replaceState(state: any, title: string, url: string): void; + abstract pushState(state: any, title: string, url: string): void; + abstract forward(): void; + abstract back(): void; +} + +export declare class RadioButtonState { + checked: boolean; + value: string; + constructor(checked: boolean, value: string); +} + +export declare class ReplacePipe implements PipeTransform { + transform(value: any, pattern: string | RegExp, replacement: Function | string): any; +} + +export declare class RequiredValidator { +} + +export declare class SelectControlValueAccessor implements ControlValueAccessor { + value: any; + onChange: (_: any) => void; + onTouched: () => void; + constructor(_renderer: Renderer, _elementRef: ElementRef); + writeValue(value: any): void; + registerOnChange(fn: (value: any) => any): void; + registerOnTouched(fn: () => any): void; +} + +export declare class SlicePipe implements PipeTransform { + transform(value: any, start: number, end?: number): any; +} + +export declare class UpperCasePipe implements PipeTransform { + transform(value: string): string; +} + +export interface UrlChangeEvent { + type: string; +} + +export interface UrlChangeListener { + (e: UrlChangeEvent): any; +} + +export interface Validator { + validate(c: AbstractControl): { + [key: string]: any; + }; +} + +export declare class Validators { + static required(control: AbstractControl): { + [key: string]: boolean; + }; + static minLength(minLength: number): ValidatorFn; + static maxLength(maxLength: number): ValidatorFn; + static pattern(pattern: string): ValidatorFn; + static nullValidator(c: AbstractControl): { + [key: string]: boolean; + }; + static compose(validators: ValidatorFn[]): ValidatorFn; + static composeAsync(validators: AsyncValidatorFn[]): AsyncValidatorFn; +} diff --git a/tools/public_api_guard/common/testing.d.ts b/tools/public_api_guard/common/testing.d.ts new file mode 100644 index 0000000000..69086846df --- /dev/null +++ b/tools/public_api_guard/common/testing.d.ts @@ -0,0 +1,33 @@ +export declare class MockLocationStrategy extends LocationStrategy { + internalBaseHref: string; + internalPath: string; + internalTitle: string; + urlChanges: string[]; + constructor(); + simulatePopState(url: string): void; + path(): string; + prepareExternalUrl(internal: string): string; + pushState(ctx: any, title: string, path: string, query: string): void; + replaceState(ctx: any, title: string, path: string, query: string): void; + onPopState(fn: (value: any) => void): void; + getBaseHref(): string; + back(): void; + forward(): void; +} + +export declare class SpyLocation implements Location { + urlChanges: string[]; + setInitialPath(url: string): void; + setBaseHref(url: string): void; + path(): string; + isCurrentPathEqualTo(path: string, query?: string): boolean; + simulateUrlPop(pathname: string): void; + simulateHashChange(pathname: string): void; + prepareExternalUrl(url: string): string; + go(path: string, query?: string): void; + replaceState(path: string, query?: string): void; + forward(): void; + back(): void; + subscribe(onNext: (value: any) => void, onThrow?: (error: any) => void, onReturn?: () => void): Object; + normalize(url: string): string; +} diff --git a/tools/public_api_guard/compiler/index.d.ts b/tools/public_api_guard/compiler/index.d.ts new file mode 100644 index 0000000000..d4415f7311 --- /dev/null +++ b/tools/public_api_guard/compiler/index.d.ts @@ -0,0 +1,582 @@ +export declare class AttrAst implements TemplateAst { + name: string; + value: string; + sourceSpan: ParseSourceSpan; + constructor(name: string, value: string, sourceSpan: ParseSourceSpan); + visit(visitor: TemplateAstVisitor, context: any): any; +} + +export declare class BoundDirectivePropertyAst implements TemplateAst { + directiveName: string; + templateName: string; + value: AST; + sourceSpan: ParseSourceSpan; + constructor(directiveName: string, templateName: string, value: AST, sourceSpan: ParseSourceSpan); + visit(visitor: TemplateAstVisitor, context: any): any; +} + +export declare class BoundElementPropertyAst implements TemplateAst { + name: string; + type: PropertyBindingType; + securityContext: SecurityContext; + value: AST; + unit: string; + sourceSpan: ParseSourceSpan; + constructor(name: string, type: PropertyBindingType, securityContext: SecurityContext, value: AST, unit: string, sourceSpan: ParseSourceSpan); + visit(visitor: TemplateAstVisitor, context: any): any; +} + +export declare class BoundEventAst implements TemplateAst { + name: string; + target: string; + handler: AST; + sourceSpan: ParseSourceSpan; + constructor(name: string, target: string, handler: AST, sourceSpan: ParseSourceSpan); + visit(visitor: TemplateAstVisitor, context: any): any; + fullName: string; +} + +export declare class BoundTextAst implements TemplateAst { + value: AST; + ngContentIndex: number; + sourceSpan: ParseSourceSpan; + constructor(value: AST, ngContentIndex: number, sourceSpan: ParseSourceSpan); + visit(visitor: TemplateAstVisitor, context: any): any; +} + +export declare class CompileDiDependencyMetadata { + isAttribute: boolean; + isSelf: boolean; + isHost: boolean; + isSkipSelf: boolean; + isOptional: boolean; + isValue: boolean; + query: CompileQueryMetadata; + viewQuery: CompileQueryMetadata; + token: CompileTokenMetadata; + value: any; + constructor({isAttribute, isSelf, isHost, isSkipSelf, isOptional, isValue, query, viewQuery, token, value}?: { + isAttribute?: boolean; + isSelf?: boolean; + isHost?: boolean; + isSkipSelf?: boolean; + isOptional?: boolean; + isValue?: boolean; + query?: CompileQueryMetadata; + viewQuery?: CompileQueryMetadata; + token?: CompileTokenMetadata; + value?: any; + }); + static fromJson(data: { + [key: string]: any; + }): CompileDiDependencyMetadata; + toJson(): { + [key: string]: any; + }; +} + +export declare class CompileDirectiveMetadata implements CompileMetadataWithType { + static create({type, isComponent, selector, exportAs, changeDetection, inputs, outputs, host, lifecycleHooks, providers, viewProviders, queries, viewQueries, precompile, template}?: { + type?: CompileTypeMetadata; + isComponent?: boolean; + selector?: string; + exportAs?: string; + changeDetection?: ChangeDetectionStrategy; + inputs?: string[]; + outputs?: string[]; + host?: { + [key: string]: string; + }; + lifecycleHooks?: LifecycleHooks[]; + providers?: Array; + viewProviders?: Array; + queries?: CompileQueryMetadata[]; + viewQueries?: CompileQueryMetadata[]; + precompile?: CompileTypeMetadata[]; + template?: CompileTemplateMetadata; + }): CompileDirectiveMetadata; + type: CompileTypeMetadata; + isComponent: boolean; + selector: string; + exportAs: string; + changeDetection: ChangeDetectionStrategy; + inputs: { + [key: string]: string; + }; + outputs: { + [key: string]: string; + }; + hostListeners: { + [key: string]: string; + }; + hostProperties: { + [key: string]: string; + }; + hostAttributes: { + [key: string]: string; + }; + lifecycleHooks: LifecycleHooks[]; + providers: CompileProviderMetadata[]; + viewProviders: CompileProviderMetadata[]; + queries: CompileQueryMetadata[]; + viewQueries: CompileQueryMetadata[]; + precompile: CompileTypeMetadata[]; + template: CompileTemplateMetadata; + constructor({type, isComponent, selector, exportAs, changeDetection, inputs, outputs, hostListeners, hostProperties, hostAttributes, lifecycleHooks, providers, viewProviders, queries, viewQueries, precompile, template}?: { + type?: CompileTypeMetadata; + isComponent?: boolean; + selector?: string; + exportAs?: string; + changeDetection?: ChangeDetectionStrategy; + inputs?: { + [key: string]: string; + }; + outputs?: { + [key: string]: string; + }; + hostListeners?: { + [key: string]: string; + }; + hostProperties?: { + [key: string]: string; + }; + hostAttributes?: { + [key: string]: string; + }; + lifecycleHooks?: LifecycleHooks[]; + providers?: Array; + viewProviders?: Array; + queries?: CompileQueryMetadata[]; + viewQueries?: CompileQueryMetadata[]; + precompile?: CompileTypeMetadata[]; + template?: CompileTemplateMetadata; + }); + identifier: CompileIdentifierMetadata; + static fromJson(data: { + [key: string]: any; + }): CompileDirectiveMetadata; + toJson(): { + [key: string]: any; + }; +} + +export declare class CompileFactoryMetadata implements CompileIdentifierMetadata, CompileMetadataWithIdentifier { + runtime: Function; + name: string; + prefix: string; + moduleUrl: string; + value: any; + diDeps: CompileDiDependencyMetadata[]; + constructor({runtime, name, moduleUrl, prefix, diDeps, value}: { + runtime?: Function; + name?: string; + prefix?: string; + moduleUrl?: string; + value?: boolean; + diDeps?: CompileDiDependencyMetadata[]; + }); + identifier: CompileIdentifierMetadata; + static fromJson(data: { + [key: string]: any; + }): CompileFactoryMetadata; + toJson(): { + [key: string]: any; + }; +} + +export declare class CompileIdentifierMetadata implements CompileMetadataWithIdentifier { + runtime: any; + name: string; + prefix: string; + moduleUrl: string; + value: any; + constructor({runtime, name, moduleUrl, prefix, value}?: { + runtime?: any; + name?: string; + moduleUrl?: string; + prefix?: string; + value?: any; + }); + static fromJson(data: { + [key: string]: any; + }): CompileIdentifierMetadata; + toJson(): { + [key: string]: any; + }; + identifier: CompileIdentifierMetadata; +} + +export declare abstract class CompileMetadataWithIdentifier { + abstract toJson(): { + [key: string]: any; + }; + identifier: CompileIdentifierMetadata; +} + +export declare abstract class CompileMetadataWithType extends CompileMetadataWithIdentifier { + abstract toJson(): { + [key: string]: any; + }; + type: CompileTypeMetadata; + identifier: CompileIdentifierMetadata; +} + +export declare class CompilePipeMetadata implements CompileMetadataWithType { + type: CompileTypeMetadata; + name: string; + pure: boolean; + lifecycleHooks: LifecycleHooks[]; + constructor({type, name, pure, lifecycleHooks}?: { + type?: CompileTypeMetadata; + name?: string; + pure?: boolean; + lifecycleHooks?: LifecycleHooks[]; + }); + identifier: CompileIdentifierMetadata; + static fromJson(data: { + [key: string]: any; + }): CompilePipeMetadata; + toJson(): { + [key: string]: any; + }; +} + +export declare class CompileProviderMetadata { + token: CompileTokenMetadata; + useClass: CompileTypeMetadata; + useValue: any; + useExisting: CompileTokenMetadata; + useFactory: CompileFactoryMetadata; + deps: CompileDiDependencyMetadata[]; + multi: boolean; + constructor({token, useClass, useValue, useExisting, useFactory, deps, multi}: { + token?: CompileTokenMetadata; + useClass?: CompileTypeMetadata; + useValue?: any; + useExisting?: CompileTokenMetadata; + useFactory?: CompileFactoryMetadata; + deps?: CompileDiDependencyMetadata[]; + multi?: boolean; + }); + static fromJson(data: { + [key: string]: any; + }): CompileProviderMetadata; + toJson(): { + [key: string]: any; + }; +} + +export declare class CompileQueryMetadata { + selectors: Array; + descendants: boolean; + first: boolean; + propertyName: string; + read: CompileTokenMetadata; + constructor({selectors, descendants, first, propertyName, read}?: { + selectors?: Array; + descendants?: boolean; + first?: boolean; + propertyName?: string; + read?: CompileTokenMetadata; + }); + static fromJson(data: { + [key: string]: any; + }): CompileQueryMetadata; + toJson(): { + [key: string]: any; + }; +} + +export declare const COMPILER_PROVIDERS: Array; + +export declare class CompilerConfig { + renderTypes: RenderTypes; + defaultEncapsulation: ViewEncapsulation; + useJit: boolean; + platformDirectives: any[]; + platformPipes: any[]; + constructor({renderTypes, defaultEncapsulation, genDebugInfo, logBindingUpdate, useJit, platformDirectives, platformPipes}?: { + renderTypes?: RenderTypes; + defaultEncapsulation?: ViewEncapsulation; + genDebugInfo?: boolean; + logBindingUpdate?: boolean; + useJit?: boolean; + platformDirectives?: any[]; + platformPipes?: any[]; + }); + genDebugInfo: boolean; + logBindingUpdate: boolean; +} + +export declare class CompileTemplateMetadata { + encapsulation: ViewEncapsulation; + template: string; + templateUrl: string; + styles: string[]; + styleUrls: string[]; + animations: CompileAnimationEntryMetadata[]; + ngContentSelectors: string[]; + interpolation: [string, string]; + constructor({encapsulation, template, templateUrl, styles, styleUrls, animations, ngContentSelectors, interpolation}?: { + encapsulation?: ViewEncapsulation; + template?: string; + templateUrl?: string; + styles?: string[]; + styleUrls?: string[]; + ngContentSelectors?: string[]; + animations?: CompileAnimationEntryMetadata[]; + interpolation?: [string, string]; + }); + static fromJson(data: { + [key: string]: any; + }): CompileTemplateMetadata; + toJson(): { + [key: string]: any; + }; +} + +export declare class CompileTokenMetadata implements CompileMetadataWithIdentifier { + value: any; + identifier: CompileIdentifierMetadata; + identifierIsInstance: boolean; + constructor({value, identifier, identifierIsInstance}: { + value?: any; + identifier?: CompileIdentifierMetadata; + identifierIsInstance?: boolean; + }); + static fromJson(data: { + [key: string]: any; + }): CompileTokenMetadata; + toJson(): { + [key: string]: any; + }; + runtimeCacheKey: any; + assetCacheKey: any; + equalsTo(token2: CompileTokenMetadata): boolean; + name: string; +} + +export declare class CompileTypeMetadata implements CompileIdentifierMetadata, CompileMetadataWithType { + runtime: Type; + name: string; + prefix: string; + moduleUrl: string; + isHost: boolean; + value: any; + diDeps: CompileDiDependencyMetadata[]; + constructor({runtime, name, moduleUrl, prefix, isHost, value, diDeps}?: { + runtime?: Type; + name?: string; + moduleUrl?: string; + prefix?: string; + isHost?: boolean; + value?: any; + diDeps?: CompileDiDependencyMetadata[]; + }); + static fromJson(data: { + [key: string]: any; + }): CompileTypeMetadata; + identifier: CompileIdentifierMetadata; + type: CompileTypeMetadata; + toJson(): { + [key: string]: any; + }; +} + +export declare function createOfflineCompileUrlResolver(): UrlResolver; + +export declare var DEFAULT_PACKAGE_URL_PROVIDER: { + provide: any; + useValue: string; +}; + +export declare class DirectiveAst implements TemplateAst { + directive: CompileDirectiveMetadata; + inputs: BoundDirectivePropertyAst[]; + hostProperties: BoundElementPropertyAst[]; + hostEvents: BoundEventAst[]; + sourceSpan: ParseSourceSpan; + constructor(directive: CompileDirectiveMetadata, inputs: BoundDirectivePropertyAst[], hostProperties: BoundElementPropertyAst[], hostEvents: BoundEventAst[], sourceSpan: ParseSourceSpan); + visit(visitor: TemplateAstVisitor, context: any): any; +} + +export declare class DirectiveResolver { + constructor(_reflector?: ReflectorReader); + resolve(type: Type): DirectiveMetadata; +} + +export declare class ElementAst implements TemplateAst { + name: string; + attrs: AttrAst[]; + inputs: BoundElementPropertyAst[]; + outputs: BoundEventAst[]; + references: ReferenceAst[]; + directives: DirectiveAst[]; + providers: ProviderAst[]; + hasViewContainer: boolean; + children: TemplateAst[]; + ngContentIndex: number; + sourceSpan: ParseSourceSpan; + constructor(name: string, attrs: AttrAst[], inputs: BoundElementPropertyAst[], outputs: BoundEventAst[], references: ReferenceAst[], directives: DirectiveAst[], providers: ProviderAst[], hasViewContainer: boolean, children: TemplateAst[], ngContentIndex: number, sourceSpan: ParseSourceSpan); + visit(visitor: TemplateAstVisitor, context: any): any; +} + +export declare abstract class ElementSchemaRegistry { + abstract hasProperty(tagName: string, propName: string): boolean; + abstract securityContext(tagName: string, propName: string): any; + abstract getMappedPropName(propName: string): string; +} + +export declare class EmbeddedTemplateAst implements TemplateAst { + attrs: AttrAst[]; + outputs: BoundEventAst[]; + references: ReferenceAst[]; + variables: VariableAst[]; + directives: DirectiveAst[]; + providers: ProviderAst[]; + hasViewContainer: boolean; + children: TemplateAst[]; + ngContentIndex: number; + sourceSpan: ParseSourceSpan; + constructor(attrs: AttrAst[], outputs: BoundEventAst[], references: ReferenceAst[], variables: VariableAst[], directives: DirectiveAst[], providers: ProviderAst[], hasViewContainer: boolean, children: TemplateAst[], ngContentIndex: number, sourceSpan: ParseSourceSpan); + visit(visitor: TemplateAstVisitor, context: any): any; +} + +export declare class NgContentAst implements TemplateAst { + index: number; + ngContentIndex: number; + sourceSpan: ParseSourceSpan; + constructor(index: number, ngContentIndex: number, sourceSpan: ParseSourceSpan); + visit(visitor: TemplateAstVisitor, context: any): any; +} + +export declare class NormalizedComponentWithViewDirectives { + component: CompileDirectiveMetadata; + directives: CompileDirectiveMetadata[]; + pipes: CompilePipeMetadata[]; + constructor(component: CompileDirectiveMetadata, directives: CompileDirectiveMetadata[], pipes: CompilePipeMetadata[]); +} + +export declare class OfflineCompiler { + constructor(_directiveNormalizer: DirectiveNormalizer, _templateParser: TemplateParser, _styleCompiler: StyleCompiler, _viewCompiler: ViewCompiler, _outputEmitter: OutputEmitter, _xhr: XHR); + normalizeDirectiveMetadata(directive: CompileDirectiveMetadata): Promise; + compileTemplates(components: NormalizedComponentWithViewDirectives[]): SourceModule; + loadAndCompileStylesheet(stylesheetUrl: string, shim: boolean, suffix: string): Promise; +} + +export declare class PipeResolver { + constructor(_reflector?: ReflectorReader); + resolve(type: Type): PipeMetadata; +} + +export declare enum PropertyBindingType { + Property = 0, + Attribute = 1, + Class = 2, + Style = 3, + Animation = 4, +} + +export declare class ProviderAst implements TemplateAst { + token: CompileTokenMetadata; + multiProvider: boolean; + eager: boolean; + providers: CompileProviderMetadata[]; + providerType: ProviderAstType; + sourceSpan: ParseSourceSpan; + constructor(token: CompileTokenMetadata, multiProvider: boolean, eager: boolean, providers: CompileProviderMetadata[], providerType: ProviderAstType, sourceSpan: ParseSourceSpan); + visit(visitor: TemplateAstVisitor, context: any): any; +} + +export declare enum ProviderAstType { + PublicService = 0, + PrivateService = 1, + Component = 2, + Directive = 3, + Builtin = 4, +} + +export declare class ReferenceAst implements TemplateAst { + name: string; + value: CompileTokenMetadata; + sourceSpan: ParseSourceSpan; + constructor(name: string, value: CompileTokenMetadata, sourceSpan: ParseSourceSpan); + visit(visitor: TemplateAstVisitor, context: any): any; +} + +export declare abstract class RenderTypes { + renderer: CompileIdentifierMetadata; + renderText: CompileIdentifierMetadata; + renderElement: CompileIdentifierMetadata; + renderComment: CompileIdentifierMetadata; + renderNode: CompileIdentifierMetadata; + renderEvent: CompileIdentifierMetadata; +} + +export declare class RuntimeCompiler implements ComponentResolver { + constructor(_metadataResolver: CompileMetadataResolver, _templateNormalizer: DirectiveNormalizer, _templateParser: TemplateParser, _styleCompiler: StyleCompiler, _viewCompiler: ViewCompiler, _xhr: XHR, _genConfig: CompilerConfig); + resolveComponent(component: Type | string): Promise>; + clearCache(): void; +} + +export declare class SourceModule { + moduleUrl: string; + source: string; + constructor(moduleUrl: string, source: string); +} + +export declare const TEMPLATE_TRANSFORMS: any; + +export interface TemplateAst { + sourceSpan: ParseSourceSpan; + visit(visitor: TemplateAstVisitor, context: any): any; +} + +export interface TemplateAstVisitor { + visitNgContent(ast: NgContentAst, context: any): any; + visitEmbeddedTemplate(ast: EmbeddedTemplateAst, context: any): any; + visitElement(ast: ElementAst, context: any): any; + visitReference(ast: ReferenceAst, context: any): any; + visitVariable(ast: VariableAst, context: any): any; + visitEvent(ast: BoundEventAst, context: any): any; + visitElementProperty(ast: BoundElementPropertyAst, context: any): any; + visitAttr(ast: AttrAst, context: any): any; + visitBoundText(ast: BoundTextAst, context: any): any; + visitText(ast: TextAst, context: any): any; + visitDirective(ast: DirectiveAst, context: any): any; + visitDirectiveProperty(ast: BoundDirectivePropertyAst, context: any): any; +} + +export declare function templateVisitAll(visitor: TemplateAstVisitor, asts: TemplateAst[], context?: any): any[]; + +export declare class TextAst implements TemplateAst { + value: string; + ngContentIndex: number; + sourceSpan: ParseSourceSpan; + constructor(value: string, ngContentIndex: number, sourceSpan: ParseSourceSpan); + visit(visitor: TemplateAstVisitor, context: any): any; +} + +export declare class UrlResolver { + constructor(_packagePrefix?: string); + resolve(baseUrl: string, url: string): string; +} + +export declare class VariableAst implements TemplateAst { + name: string; + value: string; + sourceSpan: ParseSourceSpan; + constructor(name: string, value: string, sourceSpan: ParseSourceSpan); + visit(visitor: TemplateAstVisitor, context: any): any; +} + +export declare class ViewResolver { + constructor(_reflector?: ReflectorReader); + resolve(component: Type): ViewMetadata; +} + +export declare class XHR { + get(url: string): Promise; +} diff --git a/tools/public_api_guard/compiler/testing.d.ts b/tools/public_api_guard/compiler/testing.d.ts new file mode 100644 index 0000000000..5a5d26728e --- /dev/null +++ b/tools/public_api_guard/compiler/testing.d.ts @@ -0,0 +1,79 @@ +export declare class ComponentFixture { + debugElement: DebugElement; + componentInstance: any; + nativeElement: any; + elementRef: ElementRef; + componentRef: ComponentRef; + changeDetectorRef: ChangeDetectorRef; + ngZone: NgZone; + constructor(componentRef: ComponentRef, ngZone: NgZone, autoDetect: boolean); + detectChanges(checkNoChanges?: boolean): void; + checkNoChanges(): void; + autoDetectChanges(autoDetect?: boolean): void; + isStable(): boolean; + whenStable(): Promise; + destroy(): void; +} + +export declare var ComponentFixtureAutoDetect: OpaqueToken; + +export declare var ComponentFixtureNoNgZone: OpaqueToken; + +export declare class MockDirectiveResolver extends DirectiveResolver { + resolve(type: Type): DirectiveMetadata; + setProvidersOverride(type: Type, providers: any[]): void; + setViewProvidersOverride(type: Type, viewProviders: any[]): void; +} + +export declare class MockSchemaRegistry implements ElementSchemaRegistry { + existingProperties: { + [key: string]: boolean; + }; + attrPropMapping: { + [key: string]: string; + }; + constructor(existingProperties: { + [key: string]: boolean; + }, attrPropMapping: { + [key: string]: string; + }); + hasProperty(tagName: string, property: string): boolean; + securityContext(tagName: string, property: string): SecurityContext; + getMappedPropName(attrName: string): string; +} + +export declare class MockViewResolver extends ViewResolver { + constructor(); + setView(component: Type, view: ViewMetadata): void; + setInlineTemplate(component: Type, template: string): void; + setAnimations(component: Type, animations: AnimationEntryMetadata[]): void; + overrideViewDirective(component: Type, from: Type, to: Type): void; + resolve(component: Type): ViewMetadata; +} + +export declare class MockXHR extends XHR { + get(url: string): Promise; + expect(url: string, response: string): void; + when(url: string, response: string): void; + flush(): void; + verifyNoOutstandingExpectations(): void; +} + +export declare class TestComponentBuilder { + constructor(_injector: Injector); + overrideTemplate(componentType: Type, template: string): TestComponentBuilder; + overrideAnimations(componentType: Type, animations: AnimationEntryMetadata[]): TestComponentBuilder; + overrideView(componentType: Type, view: ViewMetadata): TestComponentBuilder; + overrideDirective(componentType: Type, from: Type, to: Type): TestComponentBuilder; + overrideProviders(type: Type, providers: any[]): TestComponentBuilder; + overrideBindings(type: Type, providers: any[]): TestComponentBuilder; + overrideViewProviders(type: Type, providers: any[]): TestComponentBuilder; + overrideViewBindings(type: Type, providers: any[]): TestComponentBuilder; + createAsync(rootComponentType: Type): Promise>; + createFakeAsync(rootComponentType: Type): ComponentFixture; + createSync(componentFactory: ComponentFactory): ComponentFixture; +} + +export declare class TestComponentRenderer { + insertRootElement(rootElementId: string): void; +} diff --git a/tools/public_api_guard/core/index.d.ts b/tools/public_api_guard/core/index.d.ts new file mode 100644 index 0000000000..4f8b142f0b --- /dev/null +++ b/tools/public_api_guard/core/index.d.ts @@ -0,0 +1,1266 @@ +export declare class AbstractProviderError extends BaseException { + constructor(injector: ReflectiveInjector, key: ReflectiveKey, constructResolvingMessage: Function); + addKey(injector: ReflectiveInjector, key: ReflectiveKey): void; + context: any; +} + +export declare abstract class AfterContentChecked { + abstract ngAfterContentChecked(): any; +} + +export declare abstract class AfterContentInit { + abstract ngAfterContentInit(): any; +} + +export declare abstract class AfterViewChecked { + abstract ngAfterViewChecked(): any; +} + +export declare abstract class AfterViewInit { + abstract ngAfterViewInit(): any; +} + +export declare function animate(timing: string | number, styles?: AnimationStyleMetadata | AnimationKeyframesSequenceMetadata): AnimationAnimateMetadata; + +export declare class AnimationAnimateMetadata extends AnimationMetadata { + timings: string | number; + styles: AnimationStyleMetadata | AnimationKeyframesSequenceMetadata; + constructor(timings: string | number, styles: AnimationStyleMetadata | AnimationKeyframesSequenceMetadata); +} + +export declare class AnimationEntryMetadata { + name: string; + definitions: AnimationStateMetadata[]; + constructor(name: string, definitions: AnimationStateMetadata[]); +} + +export declare class AnimationGroupMetadata extends AnimationWithStepsMetadata { + constructor(_steps: AnimationMetadata[]); + steps: AnimationMetadata[]; +} + +export declare class AnimationKeyframesSequenceMetadata extends AnimationMetadata { + steps: AnimationStyleMetadata[]; + constructor(steps: AnimationStyleMetadata[]); +} + +export declare abstract class AnimationMetadata { +} + +export declare abstract class AnimationPlayer { + abstract onDone(fn: Function): void; + abstract play(): void; + abstract pause(): void; + abstract restart(): void; + abstract finish(): void; + abstract destroy(): void; + abstract reset(): void; + abstract setPosition(p: any): void; + abstract getPosition(): number; + parentPlayer: AnimationPlayer; +} + +export declare class AnimationSequenceMetadata extends AnimationWithStepsMetadata { + constructor(_steps: AnimationMetadata[]); + steps: AnimationMetadata[]; +} + +export declare class AnimationStateDeclarationMetadata extends AnimationStateMetadata { + stateNameExpr: string; + styles: AnimationStyleMetadata; + constructor(stateNameExpr: string, styles: AnimationStyleMetadata); +} + +export declare abstract class AnimationStateMetadata { +} + +export declare class AnimationStateTransitionMetadata extends AnimationStateMetadata { + stateChangeExpr: string; + steps: AnimationMetadata; + constructor(stateChangeExpr: string, steps: AnimationMetadata); +} + +export declare class AnimationStyleMetadata extends AnimationMetadata { + styles: Array; + offset: number; + constructor(styles: Array, offset?: number); +} + +export declare abstract class AnimationWithStepsMetadata extends AnimationMetadata { + constructor(); + steps: AnimationMetadata[]; +} + +export declare const APP_ID: any; + +export declare const APP_INITIALIZER: any; + +export declare const APPLICATION_COMMON_PROVIDERS: Array; + +export declare abstract class ApplicationRef { + abstract registerBootstrapListener(listener: (ref: ComponentRef) => void): void; + abstract registerDisposeListener(dispose: () => void): void; + abstract waitForAsyncInitializers(): Promise; + abstract run(callback: Function): any; + abstract bootstrap(componentFactory: ComponentFactory): ComponentRef; + injector: Injector; + zone: NgZone; + abstract dispose(): void; + abstract tick(): void; + componentTypes: Type[]; +} + +export declare function asNativeElements(debugEls: DebugElement[]): any; + +export declare function assertPlatform(requiredToken: any): PlatformRef; + +export declare var Attribute: AttributeMetadataFactory; + +export declare class AttributeMetadata extends DependencyMetadata { + attributeName: string; + constructor(attributeName: string); + token: AttributeMetadata; + toString(): string; +} + +export interface AttributeMetadataFactory { + (name: string): TypeDecorator; + new (name: string): AttributeMetadata; +} + +export declare const AUTO_STYLE: string; + +export declare class BaseException extends Error { + message: string; + stack: any; + constructor(message?: string); + toString(): string; +} + +export declare function bind(token: any): ProviderBuilder; + +export declare class Binding extends Provider { + constructor(token: any, {toClass, toValue, toAlias, toFactory, deps, multi}: { + toClass?: Type; + toValue?: any; + toAlias?: any; + toFactory: Function; + deps?: Object[]; + multi?: boolean; + }); + toClass: Type; + toAlias: any; + toFactory: Function; + toValue: any; +} + +export declare enum ChangeDetectionStrategy { + CheckOnce = 0, + Checked = 1, + CheckAlways = 2, + Detached = 3, + OnPush = 4, + Default = 5, +} + +export declare abstract class ChangeDetectorRef { + abstract markForCheck(): void; + abstract detach(): void; + abstract detectChanges(): void; + abstract checkNoChanges(): void; + abstract reattach(): void; +} + +export declare function Class(clsDef: ClassDefinition): ConcreteType; + +export interface ClassDefinition { + extends?: Type; + constructor: Function | any[]; + [x: string]: Type | Function | any[]; +} + +export declare class CollectionChangeRecord { + item: any; + trackById: any; + currentIndex: number; + previousIndex: number; + constructor(item: any, trackById: any); + toString(): string; +} + +export declare var Component: ComponentMetadataFactory; + +export interface ComponentDecorator extends TypeDecorator { + View(obj: { + templateUrl?: string; + template?: string; + directives?: Array; + pipes?: Array; + renderer?: string; + styles?: string[]; + styleUrls?: string[]; + animations?: AnimationEntryMetadata[]; + interpolation?: [string, string]; + }): ViewDecorator; +} + +export declare class ComponentFactory { + selector: string; + constructor(selector: string, _viewFactory: Function, _componentType: Type); + componentType: Type; + create(injector: Injector, projectableNodes?: any[][], rootSelectorOrNode?: string | any): ComponentRef; +} + +export declare abstract class ComponentFactoryResolver { + static NULL: ComponentFactoryResolver; + abstract resolveComponentFactory(component: ClassWithConstructor): ComponentFactory; +} + +export declare class ComponentMetadata extends DirectiveMetadata { + changeDetection: ChangeDetectionStrategy; + viewProviders: any[]; + moduleId: string; + templateUrl: string; + template: string; + styleUrls: string[]; + styles: string[]; + animations: AnimationEntryMetadata[]; + directives: Array; + pipes: Array; + encapsulation: ViewEncapsulation; + interpolation: [string, string]; + precompile: Array; + constructor({selector, inputs, outputs, properties, events, host, exportAs, moduleId, providers, viewProviders, changeDetection, queries, templateUrl, template, styleUrls, styles, animations, directives, pipes, encapsulation, interpolation, precompile}?: { + selector?: string; + inputs?: string[]; + outputs?: string[]; properties?: string[]; events?: string[]; + host?: { + [key: string]: string; + }; + providers?: any[]; + exportAs?: string; + moduleId?: string; + viewProviders?: any[]; + queries?: { + [key: string]: any; + }; + changeDetection?: ChangeDetectionStrategy; + templateUrl?: string; + template?: string; + styleUrls?: string[]; + styles?: string[]; + animations?: AnimationEntryMetadata[]; + directives?: Array; + pipes?: Array; + encapsulation?: ViewEncapsulation; + interpolation?: [string, string]; + precompile?: Array; + }); +} + +export interface ComponentMetadataFactory { + (obj: { + selector?: string; + inputs?: string[]; + outputs?: string[]; + properties?: string[]; + events?: string[]; + host?: { + [key: string]: string; + }; + providers?: any[]; + exportAs?: string; + moduleId?: string; + queries?: { + [key: string]: any; + }; + viewProviders?: any[]; + changeDetection?: ChangeDetectionStrategy; + templateUrl?: string; + template?: string; + styleUrls?: string[]; + styles?: string[]; + animations?: AnimationEntryMetadata[]; + directives?: Array; + pipes?: Array; + encapsulation?: ViewEncapsulation; + interpolation?: [string, string]; + precompile?: Array; + }): ComponentDecorator; + new (obj: { + selector?: string; + inputs?: string[]; + outputs?: string[]; + properties?: string[]; + events?: string[]; + host?: { + [key: string]: string; + }; + providers?: any[]; + exportAs?: string; + moduleId?: string; + queries?: { + [key: string]: any; + }; + viewProviders?: any[]; + changeDetection?: ChangeDetectionStrategy; + templateUrl?: string; + template?: string; + styleUrls?: string[]; + styles?: string[]; + animations?: AnimationEntryMetadata[]; + directives?: Array; + pipes?: Array; + encapsulation?: ViewEncapsulation; + interpolation?: [string, string]; + precompile?: Array; + }): ComponentMetadata; +} + +export declare abstract class ComponentRef { + location: ElementRef; + injector: Injector; + instance: C; + hostView: ViewRef; + changeDetectorRef: ChangeDetectorRef; + componentType: Type; + abstract destroy(): void; + abstract onDestroy(callback: Function): void; +} + +export declare abstract class ComponentResolver { + abstract resolveComponent(component: Type | string): Promise>; + abstract clearCache(): void; +} + +export declare var ContentChild: ContentChildMetadataFactory; + +export declare class ContentChildMetadata extends QueryMetadata { + constructor(_selector: Type | string, {read}?: { + read?: any; + }); +} + +export interface ContentChildMetadataFactory { + (selector: Type | string, {read}?: { + read?: any; + }): any; + new (selector: Type | string, {read}?: { + read?: any; + }): ContentChildMetadataFactory; +} + +export declare var ContentChildren: ContentChildrenMetadataFactory; + +export declare class ContentChildrenMetadata extends QueryMetadata { + constructor(_selector: Type | string, {descendants, read}?: { + descendants?: boolean; + read?: any; + }); +} + +export interface ContentChildrenMetadataFactory { + (selector: Type | string, {descendants, read}?: { + descendants?: boolean; + read?: any; + }): any; + new (selector: Type | string, {descendants, read}?: { + descendants?: boolean; + read?: any; + }): ContentChildrenMetadata; +} + +export declare function coreBootstrap(componentFactory: ComponentFactory, injector: Injector): ComponentRef; + +export declare function coreLoadAndBootstrap(componentType: Type, injector: Injector): Promise>; + +export declare function createNgZone(): NgZone; + +export declare function createPlatform(injector: Injector): PlatformRef; + +export declare class CyclicDependencyError extends AbstractProviderError { + constructor(injector: ReflectiveInjector, key: ReflectiveKey); +} + +export declare class DebugElement extends DebugNode { + name: string; + properties: { + [key: string]: any; + }; + attributes: { + [key: string]: string; + }; + classes: { + [key: string]: boolean; + }; + styles: { + [key: string]: string; + }; + childNodes: DebugNode[]; + nativeElement: any; + constructor(nativeNode: any, parent: any, _debugInfo: RenderDebugInfo); + addChild(child: DebugNode): void; + removeChild(child: DebugNode): void; + insertChildrenAfter(child: DebugNode, newChildren: DebugNode[]): void; + query(predicate: Predicate): DebugElement; + queryAll(predicate: Predicate): DebugElement[]; + queryAllNodes(predicate: Predicate): DebugNode[]; + children: DebugElement[]; + triggerEventHandler(eventName: string, eventObj: any): void; +} + +export declare class DebugNode { + nativeNode: any; + listeners: EventListener[]; + parent: DebugElement; + constructor(nativeNode: any, parent: DebugNode, _debugInfo: RenderDebugInfo); + injector: Injector; + componentInstance: any; + context: any; + references: { + [key: string]: any; + }; + providerTokens: any[]; + source: string; + inject(token: any): any; +} + +export declare class DefaultIterableDiffer implements IterableDiffer { + constructor(_trackByFn?: TrackByFn); + collection: any; + length: number; + forEachItem(fn: Function): void; + forEachPreviousItem(fn: Function): void; + forEachAddedItem(fn: Function): void; + forEachMovedItem(fn: Function): void; + forEachRemovedItem(fn: Function): void; + forEachIdentityChange(fn: Function): void; + diff(collection: any): DefaultIterableDiffer; + onDestroy(): void; + check(collection: any): boolean; + isDirty: boolean; + toString(): string; +} + +export declare var Directive: DirectiveMetadataFactory; + +export interface DirectiveDecorator extends TypeDecorator { +} + +export declare class DirectiveMetadata extends InjectableMetadata { + selector: string; + inputs: string[]; + properties: string[]; + outputs: string[]; + events: string[]; + host: { + [key: string]: string; + }; + providers: any[]; + exportAs: string; + queries: { + [key: string]: any; + }; + constructor({selector, inputs, outputs, properties, events, host, providers, exportAs, queries}?: { + selector?: string; + inputs?: string[]; + outputs?: string[]; properties?: string[]; events?: string[]; + host?: { + [key: string]: string; + }; + providers?: any[]; + exportAs?: string; + queries?: { + [key: string]: any; + }; + }); +} + +export interface DirectiveMetadataFactory { + (obj: { + selector?: string; + inputs?: string[]; + outputs?: string[]; + properties?: string[]; + events?: string[]; + host?: { + [key: string]: string; + }; + providers?: any[]; + exportAs?: string; + queries?: { + [key: string]: any; + }; + }): DirectiveDecorator; + new (obj: { + selector?: string; + inputs?: string[]; + outputs?: string[]; + properties?: string[]; + events?: string[]; + host?: { + [key: string]: string; + }; + providers?: any[]; + exportAs?: string; + queries?: { + [key: string]: any; + }; + }): DirectiveMetadata; +} + +export declare function disposePlatform(): void; + +export declare abstract class DoCheck { + abstract ngDoCheck(): any; +} + +export declare abstract class DynamicComponentLoader { + abstract loadAsRoot(type: Type, overrideSelectorOrNode: string | any, injector: Injector, onDispose?: () => void, projectableNodes?: any[][]): Promise>; + abstract loadNextToLocation(type: Type, location: ViewContainerRef, providers?: ResolvedReflectiveProvider[], projectableNodes?: any[][]): Promise>; +} + +export declare class ElementRef { + nativeElement: any; + constructor(nativeElement: any); +} + +export declare abstract class EmbeddedViewRef extends ViewRef { + context: C; + rootNodes: any[]; + abstract destroy(): any; +} + +export declare function enableProdMode(): void; + +export declare class EventEmitter extends Subject { + __isAsync: boolean; + constructor(isAsync?: boolean); + emit(value: T): void; + next(value: any): void; + subscribe(generatorOrNext?: any, error?: any, complete?: any): any; +} + +export declare class ExceptionHandler { + constructor(_logger: any, _rethrowException?: boolean); + static exceptionToString(exception: any, stackTrace?: any, reason?: string): string; + call(exception: any, stackTrace?: any, reason?: string): void; +} + +export declare class ExpressionChangedAfterItHasBeenCheckedException extends BaseException { + constructor(oldValue: any, currValue: any, context: any); +} + +export declare function forwardRef(forwardRefFn: ForwardRefFn): Type; + +export interface ForwardRefFn { + (): any; +} + +export declare function getDebugNode(nativeNode: any): DebugNode; + +export declare function getPlatform(): PlatformRef; + +export interface GetTestability { + addToWindow(registry: TestabilityRegistry): void; + findTestabilityInTree(registry: TestabilityRegistry, elem: any, findInAncestors: boolean): Testability; +} + +export declare function group(steps: AnimationMetadata[]): AnimationGroupMetadata; + +export declare var Host: HostMetadataFactory; + +export declare var HostBinding: HostBindingMetadataFactory; + +export declare class HostBindingMetadata { + hostPropertyName: string; + constructor(hostPropertyName?: string); +} + +export interface HostBindingMetadataFactory { + (hostPropertyName?: string): any; + new (hostPropertyName?: string): any; +} + +export declare var HostListener: HostListenerMetadataFactory; + +export declare class HostListenerMetadata { + eventName: string; + args: string[]; + constructor(eventName: string, args?: string[]); +} + +export interface HostListenerMetadataFactory { + (eventName: string, args?: string[]): any; + new (eventName: string, args?: string[]): any; +} + +export declare class HostMetadata { + toString(): string; +} + +export interface HostMetadataFactory { + (): any; + new (): HostMetadata; +} + +export declare var Inject: InjectMetadataFactory; + +export declare var Injectable: InjectableMetadataFactory; + +export declare class InjectableMetadata { + constructor(); +} + +export interface InjectableMetadataFactory { + (): any; + new (): InjectableMetadata; +} + +export declare class InjectMetadata { + token: any; + constructor(token: any); + toString(): string; +} + +export interface InjectMetadataFactory { + (token: any): any; + new (token: any): InjectMetadata; +} + +export declare abstract class Injector { + static THROW_IF_NOT_FOUND: Object; + get(token: any, notFoundValue?: any): any; +} + +export declare var Input: InputMetadataFactory; + +export declare class InputMetadata { + bindingPropertyName: string; + constructor( + bindingPropertyName?: string); +} + +export interface InputMetadataFactory { + (bindingPropertyName?: string): any; + new (bindingPropertyName?: string): any; +} + +export declare class InstantiationError extends WrappedException { + constructor(injector: ReflectiveInjector, originalException: any, originalStack: any, key: ReflectiveKey); + addKey(injector: ReflectiveInjector, key: ReflectiveKey): void; + wrapperMessage: string; + causeKey: ReflectiveKey; + context: any; +} + +export declare class InvalidProviderError extends BaseException { + constructor(provider: any); +} + +export declare function isDevMode(): boolean; + +export interface IterableDiffer { + diff(object: any): any; + onDestroy(): any; +} + +export interface IterableDifferFactory { + supports(objects: any): boolean; + create(cdRef: ChangeDetectorRef, trackByFn?: TrackByFn): IterableDiffer; +} + +export declare class IterableDiffers { + factories: IterableDifferFactory[]; + constructor(factories: IterableDifferFactory[]); + static create(factories: IterableDifferFactory[], parent?: IterableDiffers): IterableDiffers; + static extend(factories: IterableDifferFactory[]): Provider; + find(iterable: any): IterableDifferFactory; +} + +export declare function keyframes(steps: AnimationStyleMetadata[]): AnimationKeyframesSequenceMetadata; + +export declare class KeyValueChangeRecord { + key: any; + previousValue: any; + currentValue: any; + constructor(key: any); + toString(): string; +} + +export interface KeyValueDiffer { + diff(object: any): any; + onDestroy(): any; +} + +export interface KeyValueDifferFactory { + supports(objects: any): boolean; + create(cdRef: ChangeDetectorRef): KeyValueDiffer; +} + +export declare class KeyValueDiffers { + factories: KeyValueDifferFactory[]; + constructor(factories: KeyValueDifferFactory[]); + static create(factories: KeyValueDifferFactory[], parent?: KeyValueDiffers): KeyValueDiffers; + static extend(factories: KeyValueDifferFactory[]): Provider; + find(kv: Object): KeyValueDifferFactory; +} + +export declare function lockRunMode(): void; + +export declare class NgZone { + static isInAngularZone(): boolean; + static assertInAngularZone(): void; + static assertNotInAngularZone(): void; + constructor({enableLongStackTrace}: { + enableLongStackTrace?: boolean; + }); + onUnstable: EventEmitter; + onMicrotaskEmpty: EventEmitter; + onStable: EventEmitter; + onError: EventEmitter; + isStable: boolean; + hasPendingMicrotasks: boolean; + hasPendingMacrotasks: boolean; + run(fn: () => any): any; + runGuarded(fn: () => any): any; + runOutsideAngular(fn: () => any): any; +} + +export declare class NgZoneError { + error: any; + stackTrace: any; + constructor(error: any, stackTrace: any); +} + +export declare class NoAnnotationError extends BaseException { + constructor(typeOrFunc: any, params: any[][]); +} + +export declare class NoComponentFactoryError extends BaseException { + component: Function; + constructor(component: Function); +} + +export declare class NoProviderError extends AbstractProviderError { + constructor(injector: ReflectiveInjector, key: ReflectiveKey); +} + +export declare abstract class OnChanges { + abstract ngOnChanges(changes: SimpleChanges): any; +} + +export declare abstract class OnDestroy { + abstract ngOnDestroy(): any; +} + +export declare abstract class OnInit { + abstract ngOnInit(): any; +} + +export declare class OpaqueToken { + constructor(_desc: string); + toString(): string; +} + +export declare var Optional: OptionalMetadataFactory; + +export declare class OptionalMetadata { + toString(): string; +} + +export interface OptionalMetadataFactory { + (): any; + new (): OptionalMetadata; +} + +export declare class OutOfBoundsError extends BaseException { + constructor(index: any); +} + +export declare var Output: OutputMetadataFactory; + +export declare class OutputMetadata { + bindingPropertyName: string; + constructor(bindingPropertyName?: string); +} + +export interface OutputMetadataFactory { + (bindingPropertyName?: string): any; + new (bindingPropertyName?: string): any; +} + +export declare const PACKAGE_ROOT_URL: any; + +export declare var Pipe: PipeMetadataFactory; + +export declare class PipeMetadata extends InjectableMetadata { + name: string; + constructor({name, pure}: { + name: string; + pure?: boolean; + }); + pure: boolean; +} + +export interface PipeMetadataFactory { + (obj: { + name: string; + pure?: boolean; + }): any; + new (obj: { + name: string; + pure?: boolean; + }): any; +} + +export interface PipeTransform { + transform(value: any, ...args: any[]): any; +} + +export declare const PLATFORM_COMMON_PROVIDERS: Array; + +export declare const PLATFORM_DIRECTIVES: OpaqueToken; + +export declare const PLATFORM_INITIALIZER: any; + +export declare const PLATFORM_PIPES: OpaqueToken; + +export declare abstract class PlatformRef { + abstract registerDisposeListener(dispose: () => void): void; + injector: Injector; + abstract dispose(): void; + disposed: boolean; +} + +export declare function provide(token: any, {useClass, useValue, useExisting, useFactory, deps, multi}: { + useClass?: Type; + useValue?: any; + useExisting?: any; + useFactory?: Function; + deps?: Object[]; + multi?: boolean; +}): Provider; + +export declare class Provider { + token: any; + useClass: Type; + useValue: any; + useExisting: any; + useFactory: Function; + dependencies: Object[]; + constructor(token: any, {useClass, useValue, useExisting, useFactory, deps, multi}: { + useClass?: Type; + useValue?: any; + useExisting?: any; + useFactory?: Function; + deps?: Object[]; + multi?: boolean; + }); + multi: boolean; +} + +export declare class ProviderBuilder { + token: any; + constructor(token: any); + toClass(type: Type): Provider; + toValue(value: any): Provider; + toAlias(aliasToken: any): Provider; + toFactory(factory: Function, dependencies?: any[]): Provider; +} + +export declare var Query: QueryMetadataFactory; + +export declare class QueryList { + changes: Observable; + length: number; + first: T; + last: T; + map(fn: (item: T, index: number, array: T[]) => U): U[]; + filter(fn: (item: T, index: number, array: T[]) => boolean): T[]; + reduce(fn: (prevValue: U, curValue: T, curIndex: number, array: T[]) => U, init: U): U; + forEach(fn: (item: T, index: number, array: T[]) => void): void; + some(fn: (value: T, index: number, array: T[]) => boolean): boolean; + toArray(): T[]; + toString(): string; + reset(res: Array): void; + notifyOnChanges(): void; + setDirty(): void; + dirty: boolean; +} + +export declare class QueryMetadata extends DependencyMetadata { + descendants: boolean; + first: boolean; + read: any; + constructor(_selector: Type | string, {descendants, first, read}?: { + descendants?: boolean; + first?: boolean; + read?: any; + }); + isViewQuery: boolean; + selector: any; + isVarBindingQuery: boolean; + varBindings: string[]; + toString(): string; +} + +export interface QueryMetadataFactory { + (selector: Type | string, {descendants, read}?: { + descendants?: boolean; + read?: any; + }): ParameterDecorator; + new (selector: Type | string, {descendants, read}?: { + descendants?: boolean; + read?: any; + }): QueryMetadata; +} + +export declare abstract class ReflectiveInjector implements Injector { + static resolve(providers: Array): ResolvedReflectiveProvider[]; + static resolveAndCreate(providers: Array, parent?: Injector): ReflectiveInjector; + static fromResolvedProviders(providers: ResolvedReflectiveProvider[], parent?: Injector): ReflectiveInjector; + static fromResolvedBindings(providers: ResolvedReflectiveProvider[]): ReflectiveInjector; + parent: Injector; + resolveAndCreateChild(providers: Array): ReflectiveInjector; + createChildFromResolved(providers: ResolvedReflectiveProvider[]): ReflectiveInjector; + resolveAndInstantiate(provider: Type | Provider): any; + instantiateResolved(provider: ResolvedReflectiveProvider): any; + abstract get(token: any, notFoundValue?: any): any; +} + +export declare class ReflectiveKey { + token: Object; + id: number; + constructor(token: Object, id: number); + displayName: string; + static get(token: Object): ReflectiveKey; + static numberOfKeys: number; +} + +export declare class RenderComponentType { + id: string; + templateUrl: string; + slotCount: number; + encapsulation: ViewEncapsulation; + styles: Array; + constructor(id: string, templateUrl: string, slotCount: number, encapsulation: ViewEncapsulation, styles: Array); +} + +export declare abstract class Renderer { + abstract selectRootElement(selectorOrNode: string | any, debugInfo?: RenderDebugInfo): any; + abstract createElement(parentElement: any, name: string, debugInfo?: RenderDebugInfo): any; + abstract createViewRoot(hostElement: any): any; + abstract createTemplateAnchor(parentElement: any, debugInfo?: RenderDebugInfo): any; + abstract createText(parentElement: any, value: string, debugInfo?: RenderDebugInfo): any; + abstract projectNodes(parentElement: any, nodes: any[]): void; + abstract attachViewAfter(node: any, viewRootNodes: any[]): void; + abstract detachView(viewRootNodes: any[]): void; + abstract destroyView(hostElement: any, viewAllNodes: any[]): void; + abstract listen(renderElement: any, name: string, callback: Function): Function; + abstract listenGlobal(target: string, name: string, callback: Function): Function; + abstract setElementProperty(renderElement: any, propertyName: string, propertyValue: any): void; + abstract setElementAttribute(renderElement: any, attributeName: string, attributeValue: string): void; + abstract setBindingDebugInfo(renderElement: any, propertyName: string, propertyValue: string): void; + abstract setElementClass(renderElement: any, className: string, isAdd: boolean): any; + abstract setElementStyle(renderElement: any, styleName: string, styleValue: string): any; + abstract invokeElementMethod(renderElement: any, methodName: string, args?: any[]): any; + abstract setText(renderNode: any, text: string): any; + abstract animate(element: any, startingStyles: AnimationStyles, keyframes: AnimationKeyframe[], duration: number, delay: number, easing: string): AnimationPlayer; +} + +export interface ResolvedReflectiveBinding extends ResolvedReflectiveProvider { +} + +export declare class ResolvedReflectiveFactory { + factory: Function; + dependencies: ReflectiveDependency[]; + constructor( + factory: Function, + dependencies: ReflectiveDependency[]); +} + +export interface ResolvedReflectiveProvider { + key: ReflectiveKey; + resolvedFactories: ResolvedReflectiveFactory[]; + multiProvider: boolean; +} + +export declare function resolveForwardRef(type: any): any; + +export declare abstract class RootRenderer { + abstract renderComponent(componentType: RenderComponentType): Renderer; +} + +export declare var Self: SelfMetadataFactory; + +export declare class SelfMetadata { + toString(): string; +} + +export interface SelfMetadataFactory { + (): any; + new (): SelfMetadata; +} + +export declare function sequence(steps: AnimationMetadata[]): AnimationSequenceMetadata; + +export declare function setTestabilityGetter(getter: GetTestability): void; + +export declare class SimpleChange { + previousValue: any; + currentValue: any; + constructor(previousValue: any, currentValue: any); + isFirstChange(): boolean; +} + +export interface SimpleChanges { + [propName: string]: SimpleChange; +} + +export declare var SkipSelf: SkipSelfMetadataFactory; + +export declare class SkipSelfMetadata { + toString(): string; +} + +export interface SkipSelfMetadataFactory { + (): any; + new (): SkipSelfMetadata; +} + +export declare function state(stateNameExpr: string, styles: AnimationStyleMetadata): AnimationStateDeclarationMetadata; + +export declare function style(tokens: string | { + [key: string]: string | number; +} | Array): AnimationStyleMetadata; + +export declare class SystemJsCmpFactoryResolver implements ComponentResolver { + resolveComponent(componentType: string | Type): Promise>; + clearCache(): void; +} + +export declare class SystemJsComponentResolver implements ComponentResolver { + constructor(_resolver: ComponentResolver); + resolveComponent(componentType: string | Type): Promise>; + clearCache(): void; +} + +export declare abstract class TemplateRef { + elementRef: ElementRef; + abstract createEmbeddedView(context: C): EmbeddedViewRef; +} + +export declare class Testability { + constructor(_ngZone: NgZone); + increasePendingRequestCount(): number; + decreasePendingRequestCount(): number; + isStable(): boolean; + whenStable(callback: Function): void; + getPendingRequestCount(): number; + findBindings(using: any, provider: string, exactMatch: boolean): any[]; + findProviders(using: any, provider: string, exactMatch: boolean): any[]; +} + +export declare class TestabilityRegistry { + constructor(); + registerApplication(token: any, testability: Testability): void; + getTestability(elem: any): Testability; + getAllTestabilities(): Testability[]; + getAllRootElements(): any[]; + findTestabilityInTree(elem: Node, findInAncestors?: boolean): Testability; +} + +export interface TrackByFn { + (index: number, item: any): any; +} + +export declare function transition(stateChangeExpr: string, steps: AnimationMetadata | AnimationMetadata[]): AnimationStateTransitionMetadata; + +export declare function trigger(name: string, animation: AnimationMetadata[]): AnimationEntryMetadata; + +export declare var Type: FunctionConstructor; + +export interface TypeDecorator { + (type: T): T; + (target: Object, propertyKey?: string | symbol, parameterIndex?: number): void; + annotations: any[]; + Class(obj: ClassDefinition): ConcreteType; +} + +export declare var ViewChild: ViewChildMetadataFactory; + +export declare class ViewChildMetadata extends ViewQueryMetadata { + constructor(_selector: Type | string, {read}?: { + read?: any; + }); +} + +export interface ViewChildMetadataFactory { + (selector: Type | string, {read}?: { + read?: any; + }): any; + new (selector: Type | string, {read}?: { + read?: any; + }): ViewChildMetadataFactory; +} + +export declare var ViewChildren: ViewChildrenMetadataFactory; + +export declare class ViewChildrenMetadata extends ViewQueryMetadata { + constructor(_selector: Type | string, {read}?: { + read?: any; + }); +} + +export interface ViewChildrenMetadataFactory { + (selector: Type | string, {read}?: { + read?: any; + }): any; + new (selector: Type | string, {read}?: { + read?: any; + }): ViewChildrenMetadata; +} + +export declare abstract class ViewContainerRef { + element: ElementRef; + injector: Injector; + parentInjector: Injector; + abstract clear(): void; + abstract get(index: number): ViewRef; + length: number; + abstract createEmbeddedView(templateRef: TemplateRef, context?: C, index?: number): EmbeddedViewRef; + abstract createComponent(componentFactory: ComponentFactory, index?: number, injector?: Injector, projectableNodes?: any[][]): ComponentRef; + abstract insert(viewRef: ViewRef, index?: number): ViewRef; + abstract indexOf(viewRef: ViewRef): number; + abstract remove(index?: number): void; + abstract detach(index?: number): ViewRef; +} + +export interface ViewDecorator extends TypeDecorator { + View(obj: { + templateUrl?: string; + template?: string; + directives?: Array; + pipes?: Array; + renderer?: string; + styles?: string[]; + styleUrls?: string[]; + animations?: AnimationEntryMetadata[]; + interpolation?: [string, string]; + }): ViewDecorator; +} + +export declare enum ViewEncapsulation { + Emulated = 0, + Native = 1, + None = 2, +} + +export declare class ViewMetadata { + templateUrl: string; + template: string; + styleUrls: string[]; + styles: string[]; + directives: Array; + pipes: Array; + encapsulation: ViewEncapsulation; + animations: AnimationEntryMetadata[]; + interpolation: [string, string]; + constructor({templateUrl, template, directives, pipes, encapsulation, styles, styleUrls, animations, interpolation}?: { + templateUrl?: string; + template?: string; + directives?: Array; + pipes?: Array; + encapsulation?: ViewEncapsulation; + styles?: string[]; + styleUrls?: string[]; + animations?: AnimationEntryMetadata[]; + interpolation?: [string, string]; + }); +} + +export interface ViewMetadataFactory { + (obj: { + templateUrl?: string; + template?: string; + directives?: Array; + pipes?: Array; + encapsulation?: ViewEncapsulation; + styles?: string[]; + styleUrls?: string[]; + animations?: AnimationEntryMetadata[]; + interpolation?: [string, string]; + }): ViewDecorator; + new (obj: { + templateUrl?: string; + template?: string; + directives?: Array; + pipes?: Array; + encapsulation?: ViewEncapsulation; + styles?: string[]; + styleUrls?: string[]; + animations?: AnimationEntryMetadata[]; + interpolation?: [string, string]; + }): ViewMetadata; +} + +export declare var ViewQuery: QueryMetadataFactory; + +export declare class ViewQueryMetadata extends QueryMetadata { + constructor(_selector: Type | string, {descendants, first, read}?: { + descendants?: boolean; + first?: boolean; + read?: any; + }); + isViewQuery: boolean; + toString(): string; +} + +export declare abstract class ViewRef { + destroyed: boolean; + abstract onDestroy(callback: Function): any; +} + +export declare class WrappedException extends BaseWrappedException { + constructor(_wrapperMessage: string, _originalException: any, _originalStack?: any, _context?: any); + wrapperMessage: string; + wrapperStack: any; + originalException: any; + originalStack: any; + context: any; + message: string; + toString(): string; +} + +export declare class WrappedValue { + wrapped: any; + constructor(wrapped: any); + static wrap(value: any): WrappedValue; +} + +export declare var wtfCreateScope: (signature: string, flags?: any) => WtfScopeFn; + +export declare var wtfEndTimeRange: (range: any) => void; + +export declare var wtfLeave: (scope: any, returnValue?: T) => T; + +export interface WtfScopeFn { + (arg0?: any, arg1?: any): any; +} + +export declare var wtfStartTimeRange: (rangeType: string, action: string) => any; diff --git a/tools/public_api_guard/core/testing.d.ts b/tools/public_api_guard/core/testing.d.ts new file mode 100644 index 0000000000..02971274f5 --- /dev/null +++ b/tools/public_api_guard/core/testing.d.ts @@ -0,0 +1,97 @@ +export declare var afterEach: Function; + +export declare function async(fn: Function): Function; + +export declare function beforeEach(fn: Function): void; + +export declare function beforeEachProviders(fn: () => Array): void; + +export declare function clearPendingTimers(): void; + +export declare var ddescribe: Function; + +export declare var describe: Function; + +export declare function discardPeriodicTasks(): void; + +export declare var expect: Function; + +export declare function fakeAsync(fn: Function): Function; + +export declare var fdescribe: Function; + +export declare function fit(name: string, fn: Function, timeOut?: number): void; + +export declare function flushMicrotasks(): void; + +export declare function getTestInjector(): TestInjector; + +export declare function getTypeOf(instance: any): any; + +export declare function iit(name: string, fn: Function, timeOut?: number): void; + +export declare function inject(tokens: any[], fn: Function): Function; + +export declare function injectAsync(tokens: any[], fn: Function): Function; + +export declare class InjectSetupWrapper { + constructor(_providers: () => any); + inject(tokens: any[], fn: Function): Function; + injectAsync(tokens: any[], fn: Function): Function; +} + +export declare function instantiateType(type: Function, params?: any[]): any; + +export declare function it(name: string, fn: Function, timeOut?: number): void; + +export declare class Log { + logItems: any[]; + constructor(); + add(value: any): void; + fn(value: any): (a1?: any, a2?: any, a3?: any, a4?: any, a5?: any) => void; + clear(): void; + result(): string; +} + +export declare class MockApplicationRef extends ApplicationRef { + registerBootstrapListener(listener: (ref: ComponentRef) => void): void; + registerDisposeListener(dispose: () => void): void; + bootstrap(componentFactory: ComponentFactory): ComponentRef; + injector: Injector; + zone: NgZone; + run(callback: Function): any; + waitForAsyncInitializers(): Promise; + dispose(): void; + tick(): void; + componentTypes: Type[]; +} + +export declare class MockNgZone extends NgZone { + constructor(); + onStable: EventEmitter; + run(fn: Function): any; + runOutsideAngular(fn: Function): any; + simulateZoneExit(): void; +} + +export declare function resetBaseTestProviders(): void; + +export declare function setBaseTestProviders(platformProviders: Array, applicationProviders: Array): void; + +export declare class TestInjector { + reset(): void; + platformProviders: Array; + applicationProviders: Array; + addProviders(providers: Array): void; + createInjector(): ReflectiveInjector; + get(token: any): any; + execute(tokens: any[], fn: Function): any; +} + +export declare function tick(millis?: number): void; + +export declare function withProviders(providers: () => any): InjectSetupWrapper; + +export declare var xdescribe: Function; + +export declare function xit(name: string, fn: Function, timeOut?: number): void; diff --git a/tools/public_api_guard/forms/index.d.ts b/tools/public_api_guard/forms/index.d.ts new file mode 100644 index 0000000000..e91368802a --- /dev/null +++ b/tools/public_api_guard/forms/index.d.ts @@ -0,0 +1,340 @@ +export declare abstract class AbstractControl { + validator: ValidatorFn; + asyncValidator: AsyncValidatorFn; + constructor(validator: ValidatorFn, asyncValidator: AsyncValidatorFn); + value: any; + status: string; + valid: boolean; + errors: { + [key: string]: any; + }; + pristine: boolean; + dirty: boolean; + touched: boolean; + untouched: boolean; + valueChanges: Observable; + statusChanges: Observable; + pending: boolean; + setAsyncValidators(newValidator: AsyncValidatorFn | AsyncValidatorFn[]): void; + clearAsyncValidators(): void; + setValidators(newValidator: ValidatorFn | ValidatorFn[]): void; + clearValidators(): void; + markAsTouched(): void; + markAsDirty({onlySelf}?: { + onlySelf?: boolean; + }): void; + markAsPending({onlySelf}?: { + onlySelf?: boolean; + }): void; + setParent(parent: FormGroup | FormArray): void; + updateValueAndValidity({onlySelf, emitEvent}?: { + onlySelf?: boolean; + emitEvent?: boolean; + }): void; + setErrors(errors: { + [key: string]: any; + }, {emitEvent}?: { + emitEvent?: boolean; + }): void; + find(path: Array | string): AbstractControl; + getError(errorCode: string, path?: string[]): any; + hasError(errorCode: string, path?: string[]): boolean; + root: AbstractControl; +} + +export declare abstract class AbstractControlDirective { + control: AbstractControl; + value: any; + valid: boolean; + errors: { + [key: string]: any; + }; + pristine: boolean; + dirty: boolean; + touched: boolean; + untouched: boolean; + path: string[]; +} + +export declare class CheckboxControlValueAccessor implements ControlValueAccessor { + onChange: (_: any) => void; + onTouched: () => void; + constructor(_renderer: Renderer, _elementRef: ElementRef); + writeValue(value: any): void; + registerOnChange(fn: (_: any) => {}): void; + registerOnTouched(fn: () => {}): void; +} + +export declare class ControlContainer extends AbstractControlDirective { + name: string; + formDirective: Form; + path: string[]; +} + +export interface ControlValueAccessor { + writeValue(obj: any): void; + registerOnChange(fn: any): void; + registerOnTouched(fn: any): void; +} + +export declare class DefaultValueAccessor implements ControlValueAccessor { + onChange: (_: any) => void; + onTouched: () => void; + constructor(_renderer: Renderer, _elementRef: ElementRef); + writeValue(value: any): void; + registerOnChange(fn: (_: any) => void): void; + registerOnTouched(fn: () => void): void; +} + +export declare function disableDeprecatedForms(): any[]; + +export interface Form { + addControl(dir: NgControl): void; + removeControl(dir: NgControl): void; + getControl(dir: NgControl): FormControl; + addFormGroup(dir: AbstractFormGroupDirective): void; + removeFormGroup(dir: AbstractFormGroupDirective): void; + getFormGroup(dir: AbstractFormGroupDirective): FormGroup; + updateModel(dir: NgControl, value: any): void; +} + +export declare const FORM_DIRECTIVES: Type[]; + +export declare const FORM_PROVIDERS: Type[]; + +export declare class FormArray extends AbstractControl { + controls: AbstractControl[]; + constructor(controls: AbstractControl[], validator?: ValidatorFn, asyncValidator?: AsyncValidatorFn); + at(index: number): AbstractControl; + push(control: AbstractControl): void; + insert(index: number, control: AbstractControl): void; + removeAt(index: number): void; + length: number; +} + +export declare class FormBuilder { + group(controlsConfig: { + [key: string]: any; + }, extra?: { + [key: string]: any; + }): FormGroup; + control(value: Object, validator?: ValidatorFn | ValidatorFn[], asyncValidator?: AsyncValidatorFn | AsyncValidatorFn[]): FormControl; + array(controlsConfig: any[], validator?: ValidatorFn, asyncValidator?: AsyncValidatorFn): FormArray; +} + +export declare class FormControl extends AbstractControl { + constructor(value?: any, validator?: ValidatorFn | ValidatorFn[], asyncValidator?: AsyncValidatorFn | AsyncValidatorFn[]); + updateValue(value: any, {onlySelf, emitEvent, emitModelToViewChange}?: { + onlySelf?: boolean; + emitEvent?: boolean; + emitModelToViewChange?: boolean; + }): void; + registerOnChange(fn: Function): void; +} + +export declare class FormControlDirective extends NgControl implements OnChanges { + viewModel: any; + form: FormControl; + model: any; + update: EventEmitter<{}>; + constructor(_validators: any[], _asyncValidators: any[], valueAccessors: ControlValueAccessor[]); + ngOnChanges(changes: SimpleChanges): void; + path: string[]; + validator: ValidatorFn; + asyncValidator: AsyncValidatorFn; + control: FormControl; + viewToModelUpdate(newValue: any): void; +} + +export declare class FormControlName extends NgControl implements OnChanges, OnDestroy { + name: string; + model: any; + update: EventEmitter<{}>; + constructor(_parent: ControlContainer, _validators: any[], _asyncValidators: any[], valueAccessors: ControlValueAccessor[]); + ngOnChanges(changes: SimpleChanges): void; + ngOnDestroy(): void; + viewToModelUpdate(newValue: any): void; + path: string[]; + formDirective: any; + validator: ValidatorFn; + asyncValidator: AsyncValidatorFn; + control: FormControl; +} + +export declare class FormGroup extends AbstractControl { + controls: { + [key: string]: AbstractControl; + }; + constructor(controls: { + [key: string]: AbstractControl; + }, optionals?: { + [key: string]: boolean; + }, validator?: ValidatorFn, asyncValidator?: AsyncValidatorFn); + registerControl(name: string, control: AbstractControl): AbstractControl; + addControl(name: string, control: AbstractControl): void; + removeControl(name: string): void; + include(controlName: string): void; + exclude(controlName: string): void; + contains(controlName: string): boolean; +} + +export declare class FormGroupDirective extends ControlContainer implements Form, OnChanges { + directives: NgControl[]; + form: FormGroup; + ngSubmit: EventEmitter<{}>; + constructor(_validators: any[], _asyncValidators: any[]); + ngOnChanges(changes: SimpleChanges): void; + submitted: boolean; + formDirective: Form; + control: FormGroup; + path: string[]; + addControl(dir: NgControl): void; + getControl(dir: NgControl): FormControl; + removeControl(dir: NgControl): void; + addFormGroup(dir: FormGroupName): void; + removeFormGroup(dir: FormGroupName): void; + getFormGroup(dir: FormGroupName): FormGroup; + updateModel(dir: NgControl, value: any): void; + onSubmit(): boolean; +} + +export declare class FormGroupName extends AbstractFormGroupDirective implements OnInit, OnDestroy { + name: string; + constructor(parent: ControlContainer, validators: any[], asyncValidators: any[]); +} + +export declare class MaxLengthValidator implements Validator { + constructor(maxLength: string); + validate(c: AbstractControl): { + [key: string]: any; + }; +} + +export declare class MinLengthValidator implements Validator { + constructor(minLength: string); + validate(c: AbstractControl): { + [key: string]: any; + }; +} + +export declare const NG_ASYNC_VALIDATORS: OpaqueToken; + +export declare const NG_VALIDATORS: OpaqueToken; + +export declare const NG_VALUE_ACCESSOR: OpaqueToken; + +export declare abstract class NgControl extends AbstractControlDirective { + name: string; + valueAccessor: ControlValueAccessor; + validator: ValidatorFn; + asyncValidator: AsyncValidatorFn; + abstract viewToModelUpdate(newValue: any): void; +} + +export declare class NgControlStatus { + constructor(cd: NgControl); + ngClassUntouched: boolean; + ngClassTouched: boolean; + ngClassPristine: boolean; + ngClassDirty: boolean; + ngClassValid: boolean; + ngClassInvalid: boolean; +} + +export declare class NgForm extends ControlContainer implements Form { + form: FormGroup; + ngSubmit: EventEmitter<{}>; + constructor(validators: any[], asyncValidators: any[]); + submitted: boolean; + formDirective: Form; + control: FormGroup; + path: string[]; + controls: { + [key: string]: AbstractControl; + }; + addControl(dir: NgModel): void; + getControl(dir: NgModel): FormControl; + removeControl(dir: NgModel): void; + addFormGroup(dir: NgModelGroup): void; + removeFormGroup(dir: NgModelGroup): void; + getFormGroup(dir: NgModelGroup): FormGroup; + updateModel(dir: NgControl, value: any): void; + onSubmit(): boolean; +} + +export declare class NgModel extends NgControl implements OnChanges, OnDestroy { + viewModel: any; + model: any; + name: string; + options: { + name?: string; + standalone?: boolean; + }; + update: EventEmitter<{}>; + constructor(_parent: ControlContainer, _validators: any[], _asyncValidators: any[], valueAccessors: ControlValueAccessor[]); + ngOnChanges(changes: SimpleChanges): void; + ngOnDestroy(): void; + control: FormControl; + path: string[]; + formDirective: any; + validator: ValidatorFn; + asyncValidator: AsyncValidatorFn; + viewToModelUpdate(newValue: any): void; +} + +export declare class NgModelGroup extends AbstractFormGroupDirective implements OnInit, OnDestroy { + name: string; + constructor(parent: ControlContainer, validators: any[], asyncValidators: any[]); +} + +export declare class NgSelectOption implements OnDestroy { + id: string; + constructor(_element: ElementRef, _renderer: Renderer, _select: SelectControlValueAccessor); + ngValue: any; + value: any; + ngOnDestroy(): void; +} + +export declare class PatternValidator implements Validator { + constructor(pattern: string); + validate(c: AbstractControl): { + [key: string]: any; + }; +} + +export declare function provideForms(): any[]; + +export declare const REACTIVE_FORM_DIRECTIVES: Type[]; + +export declare class RequiredValidator { +} + +export declare class SelectControlValueAccessor implements ControlValueAccessor { + value: any; + onChange: (_: any) => void; + onTouched: () => void; + constructor(_renderer: Renderer, _elementRef: ElementRef); + writeValue(value: any): void; + registerOnChange(fn: (value: any) => any): void; + registerOnTouched(fn: () => any): void; +} + +export interface Validator { + validate(c: AbstractControl): { + [key: string]: any; + }; +} + +export declare class Validators { + static required(control: AbstractControl): { + [key: string]: boolean; + }; + static minLength(minLength: number): ValidatorFn; + static maxLength(maxLength: number): ValidatorFn; + static pattern(pattern: string): ValidatorFn; + static nullValidator(c: AbstractControl): { + [key: string]: boolean; + }; + static compose(validators: ValidatorFn[]): ValidatorFn; + static composeAsync(validators: AsyncValidatorFn[]): AsyncValidatorFn; +} diff --git a/tools/public_api_guard/http/index.d.ts b/tools/public_api_guard/http/index.d.ts new file mode 100644 index 0000000000..f6e175a2ff --- /dev/null +++ b/tools/public_api_guard/http/index.d.ts @@ -0,0 +1,215 @@ +export declare class BaseRequestOptions extends RequestOptions { + constructor(); +} + +export declare class BaseResponseOptions extends ResponseOptions { + constructor(); +} + +export declare class BrowserXhr { + constructor(); + build(): any; +} + +export declare abstract class Connection { + readyState: ReadyState; + request: Request; + response: any; +} + +export declare abstract class ConnectionBackend { + abstract createConnection(request: any): Connection; +} + +export declare class CookieXSRFStrategy implements XSRFStrategy { + constructor(_cookieName?: string, _headerName?: string); + configureRequest(req: Request): void; +} + +export declare class Headers { + constructor(headers?: Headers | { + [key: string]: any; + }); + static fromResponseHeaderString(headersString: string): Headers; + append(name: string, value: string): void; + delete(name: string): void; + forEach(fn: (values: string[], name: string, headers: Map) => void): void; + get(header: string): string; + has(header: string): boolean; + keys(): string[]; + set(header: string, value: string | string[]): void; + values(): string[][]; + toJSON(): { + [key: string]: any; + }; + getAll(header: string): string[]; + entries(): void; +} + +export declare class Http { + protected _backend: ConnectionBackend; + protected _defaultOptions: RequestOptions; + constructor(_backend: ConnectionBackend, _defaultOptions: RequestOptions); + request(url: string | Request, options?: RequestOptionsArgs): Observable; + get(url: string, options?: RequestOptionsArgs): Observable; + post(url: string, body: any, options?: RequestOptionsArgs): Observable; + put(url: string, body: any, options?: RequestOptionsArgs): Observable; + delete(url: string, options?: RequestOptionsArgs): Observable; + patch(url: string, body: any, options?: RequestOptionsArgs): Observable; + head(url: string, options?: RequestOptionsArgs): Observable; +} + +export declare const HTTP_BINDINGS: any[]; + +export declare const HTTP_PROVIDERS: any[]; + +export declare function httpFactory(xhrBackend: XHRBackend, requestOptions: RequestOptions): Http; + +export declare const JSON_BINDINGS: any[]; + +export declare class Jsonp extends Http { + constructor(backend: ConnectionBackend, defaultOptions: RequestOptions); + request(url: string | Request, options?: RequestOptionsArgs): Observable; +} + +export declare const JSONP_PROVIDERS: any[]; + +export declare abstract class JSONPBackend extends ConnectionBackend { +} + +export declare abstract class JSONPConnection implements Connection { + readyState: ReadyState; + request: Request; + response: Observable; + abstract finished(data?: any): void; +} + +export declare enum ReadyState { + Unsent = 0, + Open = 1, + HeadersReceived = 2, + Loading = 3, + Done = 4, + Cancelled = 5, +} + +export declare class Request { + method: RequestMethod; + headers: Headers; + url: string; + withCredentials: boolean; + constructor(requestOptions: RequestArgs); + text(): string; + json(): string; + arrayBuffer(): ArrayBuffer; + blob(): Blob; + detectContentType(): ContentType; + getBody(): any; +} + +export declare enum RequestMethod { + Get = 0, + Post = 1, + Put = 2, + Delete = 3, + Options = 4, + Head = 5, + Patch = 6, +} + +export declare class RequestOptions { + method: RequestMethod | string; + headers: Headers; + body: any; + url: string; + search: URLSearchParams; + withCredentials: boolean; + constructor({method, headers, body, url, search, withCredentials}?: RequestOptionsArgs); + merge(options?: RequestOptionsArgs): RequestOptions; +} + +export interface RequestOptionsArgs { + url?: string; + method?: string | RequestMethod; + search?: string | URLSearchParams; + headers?: Headers; + body?: any; + withCredentials?: boolean; +} + +export declare class Response { + type: ResponseType; + ok: boolean; + url: string; + status: number; + statusText: string; + bytesLoaded: number; + totalBytes: number; + headers: Headers; + constructor(responseOptions: ResponseOptions); + blob(): any; + json(): any; + text(): string; + arrayBuffer(): any; + toString(): string; +} + +export declare class ResponseOptions { + body: string | Object; + status: number; + headers: Headers; + url: string; + constructor({body, status, headers, statusText, type, url}?: ResponseOptionsArgs); + merge(options?: ResponseOptionsArgs): ResponseOptions; +} + +export declare type ResponseOptionsArgs = { + body?: string | Object | FormData; + status?: number; + statusText?: string; + headers?: Headers; + type?: ResponseType; + url?: string; +}; + +export declare enum ResponseType { + Basic = 0, + Cors = 1, + Default = 2, + Error = 3, + Opaque = 4, +} + +export declare class URLSearchParams { + rawParams: string; + paramsMap: Map; + constructor(rawParams?: string); + clone(): URLSearchParams; + has(param: string): boolean; + get(param: string): string; + getAll(param: string): string[]; + set(param: string, val: string): void; + setAll(searchParams: URLSearchParams): void; + append(param: string, val: string): void; + appendAll(searchParams: URLSearchParams): void; + replaceAll(searchParams: URLSearchParams): void; + toString(): string; + delete(param: string): void; +} + +export declare class XHRBackend implements ConnectionBackend { + constructor(_browserXHR: BrowserXhr, _baseResponseOptions: ResponseOptions, _xsrfStrategy: XSRFStrategy); + createConnection(request: Request): XHRConnection; +} + +export declare class XHRConnection implements Connection { + request: Request; + response: Observable; + readyState: ReadyState; + constructor(req: Request, browserXHR: BrowserXhr, baseResponseOptions?: ResponseOptions); + setDetectedContentType(req: any, _xhr: any): void; +} + +export declare abstract class XSRFStrategy { + abstract configureRequest(req: Request): void; +} diff --git a/tools/public_api_guard/http/testing.d.ts b/tools/public_api_guard/http/testing.d.ts new file mode 100644 index 0000000000..2591d42ede --- /dev/null +++ b/tools/public_api_guard/http/testing.d.ts @@ -0,0 +1,19 @@ +export declare class MockBackend implements ConnectionBackend { + connections: any; + connectionsArray: MockConnection[]; + pendingConnections: any; + constructor(); + verifyNoPendingRequests(): void; + resolveAllConnections(): void; + createConnection(req: Request): MockConnection; +} + +export declare class MockConnection implements Connection { + readyState: ReadyState; + request: Request; + response: ReplaySubject; + constructor(req: Request); + mockRespond(res: Response): void; + mockDownload(res: Response): void; + mockError(err?: Error): void; +} diff --git a/tools/public_api_guard/platform-browser-dynamic/index.d.ts b/tools/public_api_guard/platform-browser-dynamic/index.d.ts new file mode 100644 index 0000000000..ab3ec26b67 --- /dev/null +++ b/tools/public_api_guard/platform-browser-dynamic/index.d.ts @@ -0,0 +1,9 @@ +export declare function bootstrap(appComponentType: Type, customProviders?: Array): Promise>; + +export declare function bootstrapWorkerApp(appComponentType: Type, customProviders?: Array): Promise>; + +export declare function bootstrapWorkerUi(workerScriptUri: string, customProviders?: Array): Promise; + +export declare const BROWSER_APP_COMPILER_PROVIDERS: Array; + +export declare const CACHED_TEMPLATE_PROVIDER: Array; diff --git a/tools/public_api_guard/platform-browser-dynamic/testing.d.ts b/tools/public_api_guard/platform-browser-dynamic/testing.d.ts new file mode 100644 index 0000000000..f6aaf2cefa --- /dev/null +++ b/tools/public_api_guard/platform-browser-dynamic/testing.d.ts @@ -0,0 +1,3 @@ +export declare const TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS: Array; + +export declare const TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS: Array; diff --git a/tools/public_api_guard/platform-browser/index.d.ts b/tools/public_api_guard/platform-browser/index.d.ts new file mode 100644 index 0000000000..c828c90086 --- /dev/null +++ b/tools/public_api_guard/platform-browser/index.d.ts @@ -0,0 +1,201 @@ +export declare const BROWSER_APP_PROVIDERS: Array; + +export declare const BROWSER_PLATFORM_PROVIDERS: Array; + +export declare const BROWSER_PROVIDERS: any[]; + +export declare const BROWSER_SANITIZATION_PROVIDERS: Array; + +export declare function browserPlatform(): PlatformRef; + +export declare class BrowserPlatformLocation extends PlatformLocation { + constructor(); + getBaseHrefFromDOM(): string; + onPopState(fn: UrlChangeListener): void; + onHashChange(fn: UrlChangeListener): void; + pathname: string; + search: string; + hash: string; + pushState(state: any, title: string, url: string): void; + replaceState(state: any, title: string, url: string): void; + forward(): void; + back(): void; +} + +export declare class By { + static all(): Predicate; + static css(selector: string): Predicate; + static directive(type: Type): Predicate; +} + +export declare abstract class ClientMessageBroker { + abstract runOnService(args: UiArguments, returnType: Type): Promise; +} + +export declare abstract class ClientMessageBrokerFactory { + abstract createMessageBroker(channel: string, runInZone?: boolean): ClientMessageBroker; +} + +export declare function disableDebugTools(): void; + +export declare const DOCUMENT: OpaqueToken; + +export declare class DomEventsPlugin extends EventManagerPlugin { + supports(eventName: string): boolean; + addEventListener(element: HTMLElement, eventName: string, handler: Function): Function; + addGlobalEventListener(target: string, eventName: string, handler: Function): Function; +} + +export declare abstract class DomSanitizationService implements SanitizationService { + abstract sanitize(context: SecurityContext, value: any): string; + abstract bypassSecurityTrustHtml(value: string): SafeHtml; + abstract bypassSecurityTrustStyle(value: string): SafeStyle; + abstract bypassSecurityTrustScript(value: string): SafeScript; + abstract bypassSecurityTrustUrl(value: string): SafeUrl; + abstract bypassSecurityTrustResourceUrl(value: string): SafeResourceUrl; +} + +export declare const ELEMENT_PROBE_PROVIDERS: any[]; + +export declare function enableDebugTools(ref: ComponentRef): ComponentRef; + +export declare const EVENT_MANAGER_PLUGINS: OpaqueToken; + +export declare class EventManager { + constructor(plugins: EventManagerPlugin[], _zone: NgZone); + addEventListener(element: HTMLElement, eventName: string, handler: Function): Function; + addGlobalEventListener(target: string, eventName: string, handler: Function): Function; + getZone(): NgZone; +} + +export declare class FnArg { + value: any; + type: Type; + constructor(value: any, type: Type); +} + +export declare const HAMMER_GESTURE_CONFIG: OpaqueToken; + +export declare class HammerGestureConfig { + events: string[]; + overrides: { + [key: string]: Object; + }; + buildHammer(element: HTMLElement): HammerInstance; +} + +export declare class KeyEventsPlugin extends EventManagerPlugin { + constructor(); + supports(eventName: string): boolean; + addEventListener(element: HTMLElement, eventName: string, handler: Function): Function; + static parseEventName(eventName: string): { + [key: string]: string; + }; + static getEventFullKey(event: KeyboardEvent): string; + static eventCallback(element: HTMLElement, fullKey: any, handler: Function, zone: NgZone): Function; +} + +export declare abstract class MessageBus implements MessageBusSource, MessageBusSink { + abstract initChannel(channel: string, runInZone?: boolean): void; + abstract attachToZone(zone: NgZone): void; + abstract from(channel: string): EventEmitter; + abstract to(channel: string): EventEmitter; +} + +export interface MessageBusSink { + initChannel(channel: string, runInZone: boolean): void; + attachToZone(zone: NgZone): void; + to(channel: string): EventEmitter; +} + +export interface MessageBusSource { + initChannel(channel: string, runInZone: boolean): void; + attachToZone(zone: NgZone): void; + from(channel: string): EventEmitter; +} + +export declare const PRIMITIVE: Type; + +export declare class ReceivedMessage { + method: string; + args: any[]; + id: string; + type: string; + constructor(data: { + [key: string]: any; + }); +} + +export interface SafeHtml extends SafeValue { +} + +export interface SafeResourceUrl extends SafeValue { +} + +export interface SafeScript extends SafeValue { +} + +export interface SafeStyle extends SafeValue { +} + +export interface SafeUrl extends SafeValue { +} + +export declare var SecurityContext: typeof t.SecurityContext; + +export declare abstract class ServiceMessageBroker { + abstract registerMethod(methodName: string, signature: Type[], method: Function, returnType?: Type): void; +} + +export declare abstract class ServiceMessageBrokerFactory { + abstract createMessageBroker(channel: string, runInZone?: boolean): ServiceMessageBroker; +} + +export declare class Title { + getTitle(): string; + setTitle(newTitle: string): void; +} + +export declare class UiArguments { + method: string; + args: FnArg[]; + constructor(method: string, args?: FnArg[]); +} + +export declare class WebWorkerInstance { + worker: Worker; + bus: MessageBus; +} + +export declare const WORKER_APP_APPLICATION_PROVIDERS: Array; + +export declare const WORKER_APP_LOCATION_PROVIDERS: ({ + provide: typeof PlatformLocation; + useClass: typeof WebWorkerPlatformLocation; +} | { + provide: any; + useFactory: (platformLocation: WebWorkerPlatformLocation, zone: NgZone) => () => Promise; + multi: boolean; + deps: (typeof PlatformLocation | typeof NgZone)[]; +})[]; + +export declare const WORKER_APP_PLATFORM_PROVIDERS: Array; + +export declare const WORKER_SCRIPT: OpaqueToken; + +export declare const WORKER_UI_APPLICATION_PROVIDERS: Array; + +export declare const WORKER_UI_LOCATION_PROVIDERS: (typeof MessageBasedPlatformLocation | typeof BrowserPlatformLocation | { + provide: any; + useFactory: (injector: Injector) => () => void; + multi: boolean; + deps: typeof Injector[]; +})[]; + +export declare const WORKER_UI_PLATFORM_PROVIDERS: Array; + +export declare const WORKER_UI_STARTABLE_MESSAGING_SERVICE: OpaqueToken; + +export declare function workerAppPlatform(): PlatformRef; + +export declare function workerUiPlatform(): PlatformRef; diff --git a/tools/public_api_guard/platform-browser/testing.d.ts b/tools/public_api_guard/platform-browser/testing.d.ts new file mode 100644 index 0000000000..79efbc9892 --- /dev/null +++ b/tools/public_api_guard/platform-browser/testing.d.ts @@ -0,0 +1,40 @@ +export declare var browserDetection: BrowserDetection; + +export declare class BrowserDetection { + static setup(): void; + constructor(ua: string); + isFirefox: boolean; + isAndroid: boolean; + isEdge: boolean; + isIE: boolean; + isWebkit: boolean; + isIOS7: boolean; + isSlow: boolean; + supportsIntlApi: boolean; + isChromeDesktop: boolean; +} + +export declare function dispatchEvent(element: any, eventType: any): void; + +export declare function el(html: string): HTMLElement; + +export declare var expect: (actual: any) => NgMatchers; + +export interface NgMatchers extends jasmine.Matchers { + toBePromise(): boolean; + toBeAnInstanceOf(expected: any): boolean; + toHaveText(expected: any): boolean; + toHaveCssClass(expected: any): boolean; + toHaveCssStyle(expected: any): boolean; + toImplement(expected: any): boolean; + toContainError(expected: any): boolean; + not: NgMatchers; +} + +export declare function normalizeCSS(css: string): string; + +export declare function stringifyElement(el: any): string; + +export declare const TEST_BROWSER_APPLICATION_PROVIDERS: Array; + +export declare const TEST_BROWSER_PLATFORM_PROVIDERS: Array; diff --git a/tools/public_api_guard/platform-browser/testing_e2e.d.ts b/tools/public_api_guard/platform-browser/testing_e2e.d.ts new file mode 100644 index 0000000000..f80979f382 --- /dev/null +++ b/tools/public_api_guard/platform-browser/testing_e2e.d.ts @@ -0,0 +1,7 @@ +export declare var $: cssSelectorHelper; + +export declare var browser: protractor.IBrowser; + +export declare function clickAll(buttonSelectors: any): void; + +export declare function verifyNoBrowserErrors(): void; diff --git a/tools/public_api_guard/platform-server/index.d.ts b/tools/public_api_guard/platform-server/index.d.ts new file mode 100644 index 0000000000..cb19fbe693 --- /dev/null +++ b/tools/public_api_guard/platform-server/index.d.ts @@ -0,0 +1,5 @@ +export declare const SERVER_PLATFORM_PROVIDERS: Array; + +export declare function serverBootstrap(appComponentType: Type, providers: Array): Promise>; + +export declare function serverPlatform(): PlatformRef; diff --git a/tools/public_api_guard/platform-server/testing.d.ts b/tools/public_api_guard/platform-server/testing.d.ts new file mode 100644 index 0000000000..83926fae53 --- /dev/null +++ b/tools/public_api_guard/platform-server/testing.d.ts @@ -0,0 +1,3 @@ +export declare const TEST_SERVER_APPLICATION_PROVIDERS: Array; + +export declare const TEST_SERVER_PLATFORM_PROVIDERS: Array; diff --git a/tools/public_api_guard/router/index.d.ts b/tools/public_api_guard/router/index.d.ts new file mode 100644 index 0000000000..11a87de264 --- /dev/null +++ b/tools/public_api_guard/router/index.d.ts @@ -0,0 +1,152 @@ +export declare class ActivatedRoute { + url: Observable; + params: Observable; + outlet: string; + component: Type | string; + snapshot: ActivatedRouteSnapshot; + toString(): string; +} + +export declare class ActivatedRouteSnapshot { + url: UrlPathWithParams[]; + params: Params; + outlet: string; + component: Type | string; + toString(): string; +} + +export interface CanActivate { + canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable | boolean; +} + +export interface CanDeactivate { + canDeactivate(component: T, route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable | boolean; +} + +export declare class DefaultUrlSerializer implements UrlSerializer { + parse(url: string): UrlTree; + serialize(tree: UrlTree): string; +} + +export declare type Event = NavigationStart | NavigationEnd | NavigationCancel | NavigationError; + +export interface ExtraOptions { + enableTracing?: boolean; +} + +export declare class NavigationCancel { + id: number; + url: string; + constructor(id: number, url: string); + toString(): string; +} + +export declare class NavigationEnd { + id: number; + url: string; + urlAfterRedirects: string; + constructor(id: number, url: string, urlAfterRedirects: string); + toString(): string; +} + +export declare class NavigationError { + id: number; + url: string; + error: any; + constructor(id: number, url: string, error: any); + toString(): string; +} + +export declare class NavigationStart { + id: number; + url: string; + constructor(id: number, url: string); + toString(): string; +} + +export declare type Params = { + [key: string]: any; +}; + +export declare const PRIMARY_OUTLET: string; + +export declare function provideRouter(config: RouterConfig, opts?: ExtraOptions): any[]; + +export interface Route { + path?: string; + terminal?: boolean; + component?: Type | string; + outlet?: string; + canActivate?: any[]; + canDeactivate?: any[]; + redirectTo?: string; + children?: Route[]; +} + +export declare class Router { + routerState: RouterState; + url: string; + events: Observable; + resetConfig(config: RouterConfig): void; + createUrlTree(commands: any[], {relativeTo, queryParams, fragment}?: NavigationExtras): UrlTree; + navigateByUrl(url: string | UrlTree): Promise; + navigate(commands: any[], extras?: NavigationExtras): Promise; + serializeUrl(url: UrlTree): string; + parseUrl(url: string): UrlTree; +} + +export declare const ROUTER_DIRECTIVES: (typeof RouterOutlet | typeof RouterLink | typeof RouterLinkActive)[]; + +export declare type RouterConfig = Route[]; + +export declare class RouterOutletMap { + registerOutlet(name: string, outlet: RouterOutlet): void; +} + +export declare class RouterState extends Tree { + queryParams: Observable; + fragment: Observable; + snapshot: RouterStateSnapshot; + toString(): string; +} + +export declare class RouterStateSnapshot extends Tree { + url: string; + queryParams: Params; + fragment: string; + toString(): string; +} + +export declare class RoutesRecognized { + id: number; + url: string; + urlAfterRedirects: string; + state: RouterStateSnapshot; + constructor(id: number, url: string, urlAfterRedirects: string, state: RouterStateSnapshot); + toString(): string; +} + +export declare class UrlPathWithParams { + path: string; + parameters: { + [key: string]: string; + }; + constructor(path: string, parameters: { + [key: string]: string; + }); + toString(): string; +} + +export declare abstract class UrlSerializer { + abstract parse(url: string): UrlTree; + abstract serialize(tree: UrlTree): string; +} + +export declare class UrlTree { + root: UrlSegment; + queryParams: { + [key: string]: string; + }; + fragment: string; + toString(): string; +} diff --git a/tools/public_api_guard/upgrade/index.d.ts b/tools/public_api_guard/upgrade/index.d.ts new file mode 100644 index 0000000000..fdf6e4f390 --- /dev/null +++ b/tools/public_api_guard/upgrade/index.d.ts @@ -0,0 +1,19 @@ +export declare class UpgradeAdapter { + downgradeNg2Component(type: Type): Function; + upgradeNg1Component(name: string): Type; + bootstrap(element: Element, modules?: any[], config?: angular.IAngularBootstrapConfig): UpgradeAdapterRef; + addProvider(provider: Type | Provider | any[] | any): void; + upgradeNg1Provider(name: string, options?: { + asToken: any; + }): void; + downgradeNg2Provider(token: any): Function; +} + +export declare class UpgradeAdapterRef { + ng1RootScope: angular.IRootScopeService; + ng1Injector: angular.IInjectorService; + ng2ApplicationRef: ApplicationRef; + ng2Injector: Injector; + ready(fn: (upgradeAdapterRef?: UpgradeAdapterRef) => void): void; + dispose(): void; +}