chore(typings): mark underscore methods @internal.

This allows TypeScript to produce an API surface which matches the Dart semantics.
I found these with:
gulp build.js.dev && find dist/js/dev/es5/angular2/src -name "*.d.ts" -exec grep -H -n '^ *_' {} \;

Closes #4638
This commit is contained in:
Alex Eagle
2015-10-10 02:18:33 +00:00
committed by Alex Eagle
parent 95f984615b
commit 867c08ac84
69 changed files with 369 additions and 31 deletions
@@ -204,6 +204,7 @@ export abstract class PlatformRef {
}
export class PlatformRef_ extends PlatformRef {
/** @internal */
_applications: ApplicationRef[] = [];
constructor(private _injector: Injector, private _dispose: () => void) { super(); }
@@ -256,6 +257,7 @@ export class PlatformRef_ extends PlatformRef {
this._dispose();
}
/** @internal */
_applicationDisposed(app: ApplicationRef): void { ListWrapper.remove(this._applications, app); }
}
@@ -178,6 +178,7 @@ export class AbstractChangeDetector<T> implements ChangeDetector {
afterViewLifecycleCallbacksInternal(): void {}
/** @internal */
_detectChangesInLightDomChildren(throwOnChange: boolean): void {
var c = this.lightDomChildren;
for (var i = 0; i < c.length; ++i) {
@@ -185,6 +186,7 @@ export class AbstractChangeDetector<T> implements ChangeDetector {
}
}
/** @internal */
_detectChangesInShadowDomChildren(throwOnChange: boolean): void {
var c = this.shadowDomChildren;
for (var i = 0; i < c.length; ++i) {
@@ -109,17 +109,20 @@ export class ChangeDetectorJITGenerator {
`;
}
/** @internal */
_genPropertyBindingTargets(): string {
var targets = this._logic.genPropertyBindingTargets(this.propertyBindingTargets,
this.genConfig.genDebugInfo);
return `${this.typeName}.gen_propertyBindingTargets = ${targets};`;
}
/** @internal */
_genDirectiveIndices(): string {
var indices = this._logic.genDirectiveIndices(this.directiveRecords);
return `${this.typeName}.gen_directiveIndices = ${indices};`;
}
/** @internal */
_maybeGenHandleEventInternal(): string {
if (this.eventBindings.length > 0) {
var handlers = this.eventBindings.map(eb => this._genEventBinding(eb)).join("\n");
@@ -136,6 +139,7 @@ export class ChangeDetectorJITGenerator {
}
}
/** @internal */
_genEventBinding(eb: EventBinding): string {
var recs = eb.records.map(r => this._genEventBindingEval(eb, r)).join("\n");
return `
@@ -144,6 +148,7 @@ export class ChangeDetectorJITGenerator {
}`;
}
/** @internal */
_genEventBindingEval(eb: EventBinding, r: ProtoRecord): string {
if (r.lastInBinding) {
var evalRecord = this._logic.genEventBindingEvalValue(eb, r);
@@ -155,6 +160,7 @@ export class ChangeDetectorJITGenerator {
}
}
/** @internal */
_genMarkPathToRootAsCheckOnce(r: ProtoRecord): string {
var br = r.bindingRecord;
if (br.isDefaultChangeDetection()) {
@@ -164,11 +170,13 @@ export class ChangeDetectorJITGenerator {
}
}
/** @internal */
_genUpdatePreventDefault(eb: EventBinding, r: ProtoRecord): string {
var local = this._names.getEventLocalName(eb, r.selfIndex);
return `if (${local} === false) { ${this._names.getPreventDefaultAccesor()} = true};`;
}
/** @internal */
_maybeGenDehydrateDirectives(): string {
var destroyPipesCode = this._names.genPipeOnDestroy();
if (destroyPipesCode) {
@@ -182,6 +190,7 @@ export class ChangeDetectorJITGenerator {
}`;
}
/** @internal */
_maybeGenHydrateDirectives(): string {
var hydrateDirectivesCode = this._logic.genHydrateDirectives(this.directiveRecords);
var hydrateDetectorsCode = this._logic.genHydrateDetectors(this.directiveRecords);
@@ -192,6 +201,7 @@ export class ChangeDetectorJITGenerator {
}`;
}
/** @internal */
_maybeGenAfterContentLifecycleCallbacks(): string {
var notifications = this._logic.genContentLifecycleCallbacks(this.directiveRecords);
if (notifications.length > 0) {
@@ -206,6 +216,7 @@ export class ChangeDetectorJITGenerator {
}
}
/** @internal */
_maybeGenAfterViewLifecycleCallbacks(): string {
var notifications = this._logic.genViewLifecycleCallbacks(this.directiveRecords);
if (notifications.length > 0) {
@@ -220,6 +231,7 @@ export class ChangeDetectorJITGenerator {
}
}
/** @internal */
_genRecord(r: ProtoRecord): string {
var rec;
if (r.isLifeCycleRecord()) {
@@ -236,6 +248,7 @@ export class ChangeDetectorJITGenerator {
`;
}
/** @internal */
_genDirectiveLifecycle(r: ProtoRecord): string {
if (r.name === "DoCheck") {
return this._genOnCheck(r);
@@ -248,6 +261,7 @@ export class ChangeDetectorJITGenerator {
}
}
/** @internal */
_genPipeCheck(r: ProtoRecord): string {
var context = this._names.getLocalName(r.contextIndex);
var argString = r.args.map((arg) => this._names.getLocalName(arg)).join(", ");
@@ -288,6 +302,7 @@ export class ChangeDetectorJITGenerator {
}
}
/** @internal */
_genReferenceCheck(r: ProtoRecord): string {
var oldValue = this._names.getFieldName(r.selfIndex);
var newValue = this._names.getLocalName(r.selfIndex);
@@ -318,10 +333,12 @@ export class ChangeDetectorJITGenerator {
}
}
/** @internal */
_genChangeMarker(r: ProtoRecord): string {
return r.argumentToPureFunction ? `${this._names.getChangeName(r.selfIndex)} = true` : ``;
}
/** @internal */
_genUpdateDirectiveOrElement(r: ProtoRecord): string {
if (!r.lastInBinding) return "";
@@ -348,6 +365,7 @@ export class ChangeDetectorJITGenerator {
}
}
/** @internal */
_genThrowOnChangeCheck(oldValue: string, newValue: string): string {
if (this.genConfig.genCheckNoChanges) {
return `
@@ -360,6 +378,7 @@ export class ChangeDetectorJITGenerator {
}
}
/** @internal */
_genCheckNoChanges(): string {
if (this.genConfig.genCheckNoChanges) {
return `${this.typeName}.prototype.checkNoChanges = function() { this.runDetectChanges(true); }`;
@@ -368,6 +387,7 @@ export class ChangeDetectorJITGenerator {
}
}
/** @internal */
_genAddToChanges(r: ProtoRecord): string {
var newValue = this._names.getLocalName(r.selfIndex);
var oldValue = this._names.getFieldName(r.selfIndex);
@@ -375,6 +395,7 @@ export class ChangeDetectorJITGenerator {
return `${CHANGES_LOCAL} = this.addChange(${CHANGES_LOCAL}, ${oldValue}, ${newValue});`;
}
/** @internal */
_maybeFirstInBinding(r: ProtoRecord): string {
var prev = ChangeDetectionUtil.protoByIndex(this.records, r.selfIndex - 1);
var firstInBindng = isBlank(prev) || prev.bindingRecord !== r.bindingRecord;
@@ -383,6 +404,7 @@ export class ChangeDetectorJITGenerator {
'';
}
/** @internal */
_maybeGenLastInDirective(r: ProtoRecord): string {
if (!r.lastInDirective) return "";
return `
@@ -392,21 +414,25 @@ export class ChangeDetectorJITGenerator {
`;
}
/** @internal */
_genOnCheck(r: ProtoRecord): string {
var br = r.bindingRecord;
return `if (!throwOnChange) ${this._names.getDirectiveName(br.directiveRecord.directiveIndex)}.doCheck();`;
}
/** @internal */
_genOnInit(r: ProtoRecord): string {
var br = r.bindingRecord;
return `if (!throwOnChange && !${this._names.getAlreadyCheckedName()}) ${this._names.getDirectiveName(br.directiveRecord.directiveIndex)}.onInit();`;
}
/** @internal */
_genOnChange(r: ProtoRecord): string {
var br = r.bindingRecord;
return `if (!throwOnChange && ${CHANGES_LOCAL}) ${this._names.getDirectiveName(br.directiveRecord.directiveIndex)}.onChanges(${CHANGES_LOCAL});`;
}
/** @internal */
_genNotifyOnPushDetectors(r: ProtoRecord): string {
var br = r.bindingRecord;
if (!r.lastInDirective || br.isDefaultChangeDetection()) return "";
@@ -111,6 +111,7 @@ export class CodegenLogicUtil {
return `${getLocalName(protoRec.selfIndex)} = ${rhs};`;
}
/** @internal */
_observe(exp: string, rec: ProtoRecord): string {
// This is an experimental feature. Works only in Dart.
if (this._changeDetection === ChangeDetectionStrategy.OnPushObserve) {
@@ -138,6 +139,7 @@ export class CodegenLogicUtil {
return `[${bs.join(", ")}]`;
}
/** @internal */
_genInterpolation(protoRec: ProtoRecord): string {
var iVals = [];
for (var i = 0; i < protoRec.args.length; ++i) {
@@ -40,8 +40,10 @@ export class CodegenNameUtil {
/**
* Record names sanitized for use as fields.
* See [sanitizeName] for details.
* @internal
*/
_sanitizedNames: string[];
/** @internal */
_sanitizedEventNames = new Map<EventBinding, string[]>();
constructor(private _records: ProtoRecord[], private _eventBindings: EventBinding[],
@@ -62,6 +64,7 @@ export class CodegenNameUtil {
}
}
/** @internal */
_addFieldPrefix(name: string): string { return `${_FIELD_PREFIX}${name}`; }
getDispatcherName(): string { return this._addFieldPrefix(_DISPATCHER_ACCESSOR); }
@@ -151,6 +151,8 @@ export class DefaultIterableDiffer implements IterableDiffer {
* currentKey, and clear all of the queues (additions, moves, removals).
* Set the previousIndexes of moved and added items to their currentIndexes
* Reset the list of additions, moves and removals
*
* @internal
*/
_reset() {
if (this.isDirty) {
@@ -185,6 +187,8 @@ export class DefaultIterableDiffer implements IterableDiffer {
* item.
* - `item` is the current item in the collection
* - `index` is the position of the item in the collection
*
* @internal
*/
_mismatch(record: CollectionChangeRecord, item, index: number): CollectionChangeRecord {
// The previous record after which we will append the current one.
@@ -241,6 +245,8 @@ export class DefaultIterableDiffer implements IterableDiffer {
* at the end. Which will show up as the two 'a's switching position. This is incorrect, since a
* better way to think of it is as insert of 'b' rather then switch 'a' with 'b' and then add 'a'
* at the end.
*
* @internal
*/
_verifyReinsertion(record: CollectionChangeRecord, item, index: number): CollectionChangeRecord {
var reinsertRecord: CollectionChangeRecord =
@@ -258,6 +264,8 @@ export class DefaultIterableDiffer implements IterableDiffer {
* Get rid of any excess {@link CollectionChangeRecord}s from the previous collection
*
* - `record` The first excess {@link CollectionChangeRecord}.
*
* @internal
*/
_truncate(record: CollectionChangeRecord) {
// Anything after that needs to be removed;
@@ -284,6 +292,7 @@ export class DefaultIterableDiffer implements IterableDiffer {
}
}
/** @internal */
_reinsertAfter(record: CollectionChangeRecord, prevRecord: CollectionChangeRecord,
index: number): CollectionChangeRecord {
if (this._unlinkedRecords !== null) {
@@ -308,6 +317,7 @@ export class DefaultIterableDiffer implements IterableDiffer {
return record;
}
/** @internal */
_moveAfter(record: CollectionChangeRecord, prevRecord: CollectionChangeRecord,
index: number): CollectionChangeRecord {
this._unlink(record);
@@ -316,6 +326,7 @@ export class DefaultIterableDiffer implements IterableDiffer {
return record;
}
/** @internal */
_addAfter(record: CollectionChangeRecord, prevRecord: CollectionChangeRecord,
index: number): CollectionChangeRecord {
this._insertAfter(record, prevRecord, index);
@@ -333,6 +344,7 @@ export class DefaultIterableDiffer implements IterableDiffer {
return record;
}
/** @internal */
_insertAfter(record: CollectionChangeRecord, prevRecord: CollectionChangeRecord,
index: number): CollectionChangeRecord {
// todo(vicb)
@@ -366,10 +378,12 @@ export class DefaultIterableDiffer implements IterableDiffer {
return record;
}
/** @internal */
_remove(record: CollectionChangeRecord): CollectionChangeRecord {
return this._addToRemovals(this._unlink(record));
}
/** @internal */
_unlink(record: CollectionChangeRecord): CollectionChangeRecord {
if (this._linkedRecords !== null) {
this._linkedRecords.remove(record);
@@ -396,6 +410,7 @@ export class DefaultIterableDiffer implements IterableDiffer {
return record;
}
/** @internal */
_addToMoves(record: CollectionChangeRecord, toIndex: number): CollectionChangeRecord {
// todo(vicb)
// assert(record._nextMoved === null);
@@ -417,6 +432,7 @@ export class DefaultIterableDiffer implements IterableDiffer {
return record;
}
/** @internal */
_addToRemovals(record: CollectionChangeRecord): CollectionChangeRecord {
if (this._unlinkedRecords === null) {
this._unlinkedRecords = new _DuplicateMap();
@@ -477,14 +493,23 @@ export class CollectionChangeRecord {
currentIndex: number = null;
previousIndex: number = null;
/** @internal */
_nextPrevious: CollectionChangeRecord = null;
/** @internal */
_prev: CollectionChangeRecord = null;
/** @internal */
_next: CollectionChangeRecord = null;
/** @internal */
_prevDup: CollectionChangeRecord = null;
/** @internal */
_nextDup: CollectionChangeRecord = null;
/** @internal */
_prevRemoved: CollectionChangeRecord = null;
/** @internal */
_nextRemoved: CollectionChangeRecord = null;
/** @internal */
_nextAdded: CollectionChangeRecord = null;
/** @internal */
_nextMoved: CollectionChangeRecord = null;
constructor(public item: any) {}
@@ -499,7 +524,9 @@ export class CollectionChangeRecord {
// A linked list of CollectionChangeRecords with the same CollectionChangeRecord.item
class _DuplicateItemRecordList {
/** @internal */
_head: CollectionChangeRecord = null;
/** @internal */
_tail: CollectionChangeRecord = null;
/**
@@ -129,6 +129,7 @@ export class DefaultKeyValueDiffer implements KeyValueDiffer {
return this.isDirty;
}
/** @internal */
_reset() {
if (this.isDirty) {
var record: KVChangeRecord;
@@ -176,6 +177,7 @@ export class DefaultKeyValueDiffer implements KeyValueDiffer {
}
}
/** @internal */
_truncate(lastRecord: KVChangeRecord, record: KVChangeRecord) {
while (record !== null) {
if (lastRecord === null) {
@@ -201,11 +203,13 @@ export class DefaultKeyValueDiffer implements KeyValueDiffer {
}
}
/** @internal */
_isInRemovals(record: KVChangeRecord) {
return record === this._removalsHead || record._nextRemoved !== null ||
record._prevRemoved !== null;
}
/** @internal */
_addToRemovals(record: KVChangeRecord) {
// todo(vicb) assert
// assert(record._next == null);
@@ -222,6 +226,7 @@ export class DefaultKeyValueDiffer implements KeyValueDiffer {
}
}
/** @internal */
_removeFromSeq(prev: KVChangeRecord, record: KVChangeRecord) {
var next = record._next;
if (prev === null) {
@@ -236,6 +241,7 @@ export class DefaultKeyValueDiffer implements KeyValueDiffer {
//})());
}
/** @internal */
_removeFromRemovals(record: KVChangeRecord) {
// todo(vicb) assert
// assert(record._next == null);
@@ -257,6 +263,7 @@ export class DefaultKeyValueDiffer implements KeyValueDiffer {
record._prevRemoved = record._nextRemoved = null;
}
/** @internal */
_addToAdditions(record: KVChangeRecord) {
// todo(vicb): assert
// assert(record._next == null);
@@ -272,6 +279,7 @@ export class DefaultKeyValueDiffer implements KeyValueDiffer {
}
}
/** @internal */
_addToChanges(record: KVChangeRecord) {
// todo(vicb) assert
// assert(record._nextAdded == null);
@@ -315,6 +323,7 @@ export class DefaultKeyValueDiffer implements KeyValueDiffer {
"removals: " + removals.join(', ') + "\n";
}
/** @internal */
_forEach(obj, fn: Function) {
if (obj instanceof Map) {
(<Map<any, any>>obj).forEach(<any>fn);
@@ -329,11 +338,17 @@ export class KVChangeRecord {
previousValue: any = null;
currentValue: any = null;
/** @internal */
_nextPrevious: KVChangeRecord = null;
/** @internal */
_next: KVChangeRecord = null;
/** @internal */
_nextAdded: KVChangeRecord = null;
/** @internal */
_nextRemoved: KVChangeRecord = null;
/** @internal */
_prevRemoved: KVChangeRecord = null;
/** @internal */
_nextChanged: KVChangeRecord = null;
constructor(public key: any) {}
@@ -49,6 +49,7 @@ export class DynamicChangeDetector extends AbstractChangeDetector<any> {
return preventDefault;
}
/** @internal */
_processEventBinding(eb: EventBinding, locals: Locals): any {
var values = ListWrapper.createFixedSize(eb.records.length);
values[0] = this.values[0];
@@ -67,6 +68,7 @@ export class DynamicChangeDetector extends AbstractChangeDetector<any> {
throw new BaseException("Cannot be reached");
}
/** @internal */
_markPathAsCheckOnce(proto: ProtoRecord): void {
if (!proto.bindingRecord.isDefaultChangeDetection()) {
var dir = proto.bindingRecord.directiveRecord;
@@ -74,6 +76,7 @@ export class DynamicChangeDetector extends AbstractChangeDetector<any> {
}
}
/** @internal */
_matchingEventBindings(eventName: string, elIndex: number): EventBinding[] {
return ListWrapper.filter(this._eventBindings,
eb => eb.eventName == eventName && eb.elIndex === elIndex);
@@ -103,6 +106,7 @@ export class DynamicChangeDetector extends AbstractChangeDetector<any> {
ListWrapper.fill(this.prevContexts, ChangeDetectionUtil.uninitialized);
}
/** @internal */
_destroyPipes() {
for (var i = 0; i < this.localPipes.length; ++i) {
if (isPresent(this.localPipes[i])) {
@@ -156,6 +160,7 @@ export class DynamicChangeDetector extends AbstractChangeDetector<any> {
}
}
/** @internal */
_firstInBinding(r: ProtoRecord): boolean {
var prev = ChangeDetectionUtil.protoByIndex(this._records, r.selfIndex - 1);
return isBlank(prev) || prev.bindingRecord !== r.bindingRecord;
@@ -188,6 +193,7 @@ export class DynamicChangeDetector extends AbstractChangeDetector<any> {
}
}
/** @internal */
_updateDirectiveOrElement(change, bindingRecord) {
if (isBlank(bindingRecord.directiveRecord)) {
super.notifyDispatcher(change.currentValue);
@@ -201,6 +207,7 @@ export class DynamicChangeDetector extends AbstractChangeDetector<any> {
}
}
/** @internal */
_addChange(bindingRecord: BindingRecord, change, changes) {
if (bindingRecord.callOnChanges()) {
return super.addChange(changes, change.previousValue, change.currentValue);
@@ -209,10 +216,13 @@ export class DynamicChangeDetector extends AbstractChangeDetector<any> {
}
}
/** @internal */
_getDirectiveFor(directiveIndex) { return this.directives.getDirectiveFor(directiveIndex); }
/** @internal */
_getDetectorFor(directiveIndex) { return this.directives.getDetectorFor(directiveIndex); }
/** @internal */
_check(proto: ProtoRecord, throwOnChange: boolean, values: any[], locals: Locals): SimpleChange {
if (proto.isPipeRecord()) {
return this._pipeCheck(proto, throwOnChange, values);
@@ -221,6 +231,7 @@ export class DynamicChangeDetector extends AbstractChangeDetector<any> {
}
}
/** @internal */
_referenceCheck(proto: ProtoRecord, throwOnChange: boolean, values: any[], locals: Locals) {
if (this._pureFuncAndArgsDidNotChange(proto)) {
this._setChanged(proto, false);
@@ -259,6 +270,7 @@ export class DynamicChangeDetector extends AbstractChangeDetector<any> {
}
}
/** @internal */
_calculateCurrValue(proto: ProtoRecord, values: any[], locals: Locals) {
switch (proto.mode) {
case RecordType.Self:
@@ -326,6 +338,7 @@ export class DynamicChangeDetector extends AbstractChangeDetector<any> {
}
}
/** @internal */
_pipeCheck(proto: ProtoRecord, throwOnChange: boolean, values: any[]) {
var context = this._readContext(proto, values);
var selectedPipe = this._pipeFor(proto, context);
@@ -364,6 +377,7 @@ export class DynamicChangeDetector extends AbstractChangeDetector<any> {
}
}
/** @internal */
_pipeFor(proto: ProtoRecord, context) {
var storedPipe = this._readPipe(proto);
if (isPresent(storedPipe)) return storedPipe;
@@ -373,6 +387,7 @@ export class DynamicChangeDetector extends AbstractChangeDetector<any> {
return pipe;
}
/** @internal */
_readContext(proto: ProtoRecord, values: any[]) {
if (proto.contextIndex == -1) {
return this._getDirectiveFor(proto.directiveIndex);
@@ -383,22 +398,29 @@ export class DynamicChangeDetector extends AbstractChangeDetector<any> {
return values[proto.contextIndex];
}
/** @internal */
_readSelf(proto: ProtoRecord, values: any[]) { return values[proto.selfIndex]; }
/** @internal */
_writeSelf(proto: ProtoRecord, value, values: any[]) { values[proto.selfIndex] = value; }
/** @internal */
_readPipe(proto: ProtoRecord) { return this.localPipes[proto.selfIndex]; }
/** @internal */
_writePipe(proto: ProtoRecord, value) { this.localPipes[proto.selfIndex] = value; }
/** @internal */
_setChanged(proto: ProtoRecord, value: boolean) {
if (proto.argumentToPureFunction) this.changes[proto.selfIndex] = value;
}
/** @internal */
_pureFuncAndArgsDidNotChange(proto: ProtoRecord): boolean {
return proto.isPureFunction() && !this._argsChanged(proto);
}
/** @internal */
_argsChanged(proto: ProtoRecord): boolean {
var args = proto.args;
for (var i = 0; i < args.length; ++i) {
@@ -409,10 +431,12 @@ export class DynamicChangeDetector extends AbstractChangeDetector<any> {
return false;
}
/** @internal */
_argsOrContextChanged(proto: ProtoRecord): boolean {
return this._argsChanged(proto) || this.changes[proto.contextIndex];
}
/** @internal */
_readArgs(proto: ProtoRecord, values: any[]) {
var res = ListWrapper.createFixedSize(proto.args.length);
var args = proto.args;
@@ -5,6 +5,7 @@ import {ProtoChangeDetector, ChangeDetector, ChangeDetectorDefinition} from './i
import {ChangeDetectorJITGenerator} from './change_detection_jit_generator';
export class JitProtoChangeDetector implements ProtoChangeDetector {
/** @internal */
_factory: Function;
constructor(private definition: ChangeDetectorDefinition) {
@@ -15,6 +16,7 @@ export class JitProtoChangeDetector implements ProtoChangeDetector {
instantiate(dispatcher: any): ChangeDetector { return this._factory(dispatcher); }
/** @internal */
_createFactory(definition: ChangeDetectorDefinition) {
return new ChangeDetectorJITGenerator(definition, 'util', 'AbstractChangeDetector').generate();
}
@@ -58,9 +58,11 @@ class ParseException extends BaseException {
@Injectable()
export class Parser {
/** @internal */
_reflector: Reflector;
constructor(public _lexer: Lexer, providedReflector: Reflector = null) {
constructor(/** @internal */
public _lexer: Lexer, providedReflector: Reflector = null) {
this._reflector = isPresent(providedReflector) ? providedReflector : reflector;
}
@@ -38,9 +38,13 @@ import {coalesce} from './coalesce';
import {ProtoRecord, RecordType} from './proto_record';
export class DynamicProtoChangeDetector implements ProtoChangeDetector {
/** @internal */
_propertyBindingRecords: ProtoRecord[];
/** @internal */
_propertyBindingTargets: BindingTarget[];
/** @internal */
_eventBindingRecords: EventBinding[];
/** @internal */
_directiveIndices: DirectiveIndex[];
constructor(private _definition: ChangeDetectorDefinition) {
@@ -96,6 +100,7 @@ export class ProtoRecordBuilder {
}
}
/** @internal */
_setArgumentToPureFunction(startIndex: number): void {
for (var i = startIndex; i < this.records.length; ++i) {
var rec = this.records[i];
@@ -111,6 +116,7 @@ export class ProtoRecordBuilder {
}
}
/** @internal */
_appendRecords(b: BindingRecord, variableNames: string[], bindingIndex: number) {
if (b.isDirectiveLifecycle()) {
this.records.push(new ProtoRecord(RecordType.DirectiveLifecycle, b.lifecycleEvent, null, [],
@@ -312,6 +312,7 @@ export class SelectorMatcher {
return result;
}
/** @internal */
_matchTerminal(map: Map<string, SelectorContext[]>, name, cssSelector: CssSelector,
matchedCallback: (c: CssSelector, a: any) => void): boolean {
if (isBlank(map) || isBlank(name)) {
@@ -335,6 +336,7 @@ export class SelectorMatcher {
return result;
}
/** @internal */
_matchPartial(map: Map<string, SelectorMatcher>, name, cssSelector: CssSelector,
matchedCallback /*: (c: CssSelector, a: any) => void*/): boolean {
if (isBlank(map) || isBlank(name)) {
@@ -162,6 +162,7 @@ export class ShadowCss {
return this._scopeCssText(cssText, selector, hostSelector);
}
/** @internal */
_insertDirectives(cssText: string): string {
cssText = this._insertPolyfillDirectivesInCssText(cssText);
return this._insertPolyfillRulesInCssText(cssText);
@@ -181,6 +182,7 @@ export class ShadowCss {
* scopeName menu-item {
*
**/
/** @internal */
_insertPolyfillDirectivesInCssText(cssText: string): string {
// Difference with webcomponents.js: does not handle comments
return StringWrapper.replaceAllMapped(cssText, _cssContentNextSelectorRe,
@@ -202,6 +204,7 @@ export class ShadowCss {
* scopeName menu-item {...}
*
**/
/** @internal */
_insertPolyfillRulesInCssText(cssText: string): string {
// Difference with webcomponents.js: does not handle comments
return StringWrapper.replaceAllMapped(cssText, _cssContentRuleRe, function(m) {
@@ -220,6 +223,7 @@ export class ShadowCss {
*
* scopeName .foo { ... }
*/
/** @internal */
_scopeCssText(cssText: string, scopeSelector: string, hostSelector: string): string {
var unscoped = this._extractUnscopedRulesFromCssText(cssText);
cssText = this._insertPolyfillHostInCssText(cssText);
@@ -249,6 +253,7 @@ export class ShadowCss {
* menu-item {...}
*
**/
/** @internal */
_extractUnscopedRulesFromCssText(cssText: string): string {
// Difference with webcomponents.js: does not handle comments
var r = '', m;
@@ -269,6 +274,7 @@ export class ShadowCss {
*
* scopeName.foo > .bar
*/
/** @internal */
_convertColonHost(cssText: string): string {
return this._convertColonRule(cssText, _cssColonHostRe, this._colonHostPartReplacer);
}
@@ -288,11 +294,13 @@ export class ShadowCss {
*
* scopeName.foo .bar { ... }
*/
/** @internal */
_convertColonHostContext(cssText: string): string {
return this._convertColonRule(cssText, _cssColonHostContextRe,
this._colonHostContextPartReplacer);
}
/** @internal */
_convertColonRule(cssText: string, regExp: RegExp, partReplacer: Function): string {
// p1 = :host, p2 = contents of (), p3 rest of rule
return StringWrapper.replaceAllMapped(cssText, regExp, function(m) {
@@ -311,6 +319,7 @@ export class ShadowCss {
});
}
/** @internal */
_colonHostContextPartReplacer(host: string, part: string, suffix: string): string {
if (StringWrapper.contains(part, _polyfillHost)) {
return this._colonHostPartReplacer(host, part, suffix);
@@ -319,6 +328,7 @@ export class ShadowCss {
}
}
/** @internal */
_colonHostPartReplacer(host: string, part: string, suffix: string): string {
return host + StringWrapper.replace(part, _polyfillHost, '') + suffix;
}
@@ -327,6 +337,7 @@ export class ShadowCss {
* Convert combinators like ::shadow and pseudo-elements like ::content
* by replacing with space.
*/
/** @internal */
_convertShadowDOMSelectors(cssText: string): string {
for (var i = 0; i < _shadowDOMSelectorsRe.length; i++) {
cssText = StringWrapper.replaceAll(cssText, _shadowDOMSelectorsRe[i], ' ');
@@ -335,6 +346,7 @@ export class ShadowCss {
}
// change a selector like 'div' to 'name div'
/** @internal */
_scopeRules(cssRules, scopeSelector: string, hostSelector: string): string {
var cssText = '';
if (isPresent(cssRules)) {
@@ -370,6 +382,7 @@ export class ShadowCss {
return cssText;
}
/** @internal */
_ieSafeCssTextFromKeyFrameRule(rule): string {
var cssText = '@keyframes ' + rule.name + ' {';
for (var i = 0; i < rule.cssRules.length; i++) {
@@ -380,6 +393,7 @@ export class ShadowCss {
return cssText;
}
/** @internal */
_scopeSelector(selector: string, scopeSelector: string, hostSelector: string,
strict: boolean): string {
var r = [], parts = selector.split(',');
@@ -396,11 +410,13 @@ export class ShadowCss {
return r.join(', ');
}
/** @internal */
_selectorNeedsScoping(selector: string, scopeSelector: string): boolean {
var re = this._makeScopeMatcher(scopeSelector);
return !isPresent(RegExpWrapper.firstMatch(re, selector));
}
/** @internal */
_makeScopeMatcher(scopeSelector: string): RegExp {
var lre = /\[/g;
var rre = /\]/g;
@@ -409,12 +425,14 @@ export class ShadowCss {
return RegExpWrapper.create('^(' + scopeSelector + ')' + _selectorReSuffix, 'm');
}
/** @internal */
_applySelectorScope(selector: string, scopeSelector: string, hostSelector: string): string {
// Difference from webcomponentsjs: scopeSelector could not be an array
return this._applySimpleSelectorScope(selector, scopeSelector, hostSelector);
}
// scope via name and [is=name]
/** @internal */
_applySimpleSelectorScope(selector: string, scopeSelector: string, hostSelector: string): string {
if (isPresent(RegExpWrapper.firstMatch(_polyfillHostRe, selector))) {
var replaceBy = this.strictStyling ? `[${hostSelector}]` : scopeSelector;
@@ -427,6 +445,7 @@ export class ShadowCss {
// return a selector with [name] suffix on each simple selector
// e.g. .foo.bar > .zot becomes .foo[name].bar[name] > .zot[name]
/** @internal */
_applyStrictSelectorScope(selector: string, scopeSelector: string): string {
var isRe = /\[is=([^\]]*)\]/g;
scopeSelector = StringWrapper.replaceAllMapped(scopeSelector, isRe, (m) => m[1]);
@@ -452,12 +471,14 @@ export class ShadowCss {
return scoped;
}
/** @internal */
_insertPolyfillHostInCssText(selector: string): string {
selector = StringWrapper.replaceAll(selector, _colonHostContextRe, _polyfillHostContext);
selector = StringWrapper.replaceAll(selector, _colonHostRe, _polyfillHost);
return selector;
}
/** @internal */
_propertiesFromRule(rule): string {
var cssText = rule.style.cssText;
// TODO(sorvell): Safari cssom incorrectly removes quotes from the content
@@ -77,6 +77,7 @@ export abstract class DebugElement {
}
export class DebugElement_ extends DebugElement {
/** @internal */
_elementInjector: ElementInjector;
constructor(private _parentView: AppView, private _boundElementIndex: number) {
@@ -134,6 +135,7 @@ export class DebugElement_ extends DebugElement {
getLocal(name: string): any { return this._parentView.locals.get(name); }
/** @internal */
_getChildElements(view: AppView, parentBoundElementIndex: number): DebugElement[] {
var els = [];
var parentElementBinder = null;
+1
View File
@@ -183,6 +183,7 @@ export class Binding {
*/
dependencies: Object[];
/** @internal */
_multi: boolean;
constructor(token, {toClass, toValue, toAlias, toFactory, deps, multi}: {
+17 -2
View File
@@ -196,6 +196,7 @@ export class ProtoInjectorDynamicStrategy implements ProtoInjectorStrategy {
}
export class ProtoInjector {
/** @internal */
_strategy: ProtoInjectorStrategy;
numberOfBindings: number;
@@ -522,16 +523,24 @@ export class Injector {
return new Injector(proto, null, null);
}
/** @internal */
_strategy: InjectorStrategy;
/** @internal */
_isHost: boolean = false;
/** @internal */
_constructionCounter: number = 0;
/** @internal */
public _proto: any /* ProtoInjector */;
/** @internal */
public _parent: Injector;
/**
* Private
*/
constructor(public _proto: any /* ProtoInjector */, public _parent: Injector = null,
constructor(_proto: any /* ProtoInjector */, _parent: Injector = null,
private _depProvider: any /* DependencyProvider */ = null,
private _debugContext: Function = null) {
this._proto = _proto;
this._parent = _parent;
this._strategy = _proto._strategy.createInjectorStrategy(this);
}
@@ -739,6 +748,7 @@ export class Injector {
return this._instantiateBinding(binding, Visibility.PublicAndPrivate);
}
/** @internal */
_new(binding: ResolvedBinding, visibility: Visibility): any {
if (this._constructionCounter++ > this._strategy.getMaxNumberOfObjects()) {
throw new CyclicDependencyError(this, binding.key);
@@ -899,6 +909,7 @@ export class Injector {
}
}
/** @internal */
_throwOrNull(key: Key, optional: boolean): any {
if (optional) {
return null;
@@ -907,11 +918,13 @@ export class Injector {
}
}
/** @internal */
_getByKeySelf(key: Key, optional: boolean, bindingVisibility: Visibility): any {
var obj = this._strategy.getObjByKeyId(key.id, bindingVisibility);
return (obj !== UNDEFINED) ? obj : this._throwOrNull(key, optional);
}
/** @internal */
_getByKeyHost(key: Key, optional: boolean, bindingVisibility: Visibility,
lowerBoundVisibility: Object): any {
var inj = this;
@@ -938,11 +951,13 @@ export class Injector {
return this._throwOrNull(key, optional);
}
/** @internal */
_getPrivateDependency(key: Key, optional: boolean, inj: Injector): any {
var obj = inj._parent._strategy.getObjByKeyId(key.id, Visibility.Private);
return (obj !== UNDEFINED) ? obj : this._throwOrNull(key, optional);
}
/** @internal */
_getByKeyDefault(key: Key, optional: boolean, bindingVisibility: Visibility,
lowerBoundVisibility: Object): any {
var inj = this;
@@ -41,6 +41,7 @@ import {isPresent, isBlank} from 'angular2/src/core/facade/lang';
*/
@Directive({selector: '[ng-for][ng-for-of]', inputs: ['ngForOf', 'ngForTemplate']})
export class NgFor implements DoCheck {
/** @internal */
_ngForOf: any;
private _differ: IterableDiffer;
@@ -62,7 +62,9 @@ import {isPresent, isBlank, print} from 'angular2/src/core/facade/lang';
*/
@Directive({selector: '[ng-style]', inputs: ['rawStyle: ng-style']})
export class NgStyle implements DoCheck {
/** @internal */
_rawStyle;
/** @internal */
_differ: KeyValueDiffer;
constructor(private _differs: KeyValueDiffers, private _ngEl: ElementRef,
@@ -62,6 +62,7 @@ export class NgSwitch {
this._switchValue = value;
}
/** @internal */
_onWhenValueChanged(oldWhen, newWhen, view: SwitchView): void {
this._deregisterView(oldWhen, view);
this._registerView(newWhen, view);
@@ -85,6 +86,7 @@ export class NgSwitch {
}
}
/** @internal */
_emptyAllActiveViews(): void {
var activeContainers = this._activeViews;
for (var i = 0; i < activeContainers.length; i++) {
@@ -93,6 +95,7 @@ export class NgSwitch {
this._activeViews = [];
}
/** @internal */
_activateViews(views: SwitchView[]): void {
// TODO(vicb): assert(this._activeViews.length === 0);
if (isPresent(views)) {
@@ -103,6 +106,7 @@ export class NgSwitch {
}
}
/** @internal */
_registerView(value, view: SwitchView): void {
var views = this._valueViews.get(value);
if (isBlank(views)) {
@@ -112,6 +116,7 @@ export class NgSwitch {
views.push(view);
}
/** @internal */
_deregisterView(value, view: SwitchView): void {
// `_WHEN_DEFAULT` is used a marker for non-registered whens
if (value === _WHEN_DEFAULT) return;
@@ -142,7 +147,9 @@ export class NgSwitch {
@Directive({selector: '[ng-switch-when]', inputs: ['ngSwitchWhen']})
export class NgSwitchWhen {
// `_WHEN_DEFAULT` is used as a marker for a not yet initialized value
/** @internal */
_value: any = _WHEN_DEFAULT;
/** @internal */
_view: SwitchView;
constructor(viewContainer: ViewContainerRef, templateRef: TemplateRef,
@@ -368,6 +368,7 @@ export class Parse5DomAdapter extends DomAdapter {
hasClass(element, classname: string): boolean {
return ListWrapper.contains(this.classList(element), classname);
}
/** @internal */
_readStyleAttribute(element) {
var styleMap = {};
var attributes = element.attribs;
@@ -383,6 +384,7 @@ export class Parse5DomAdapter extends DomAdapter {
}
return styleMap;
}
/** @internal */
_writeStyleAttribute(element, styleMap) {
var styleAttrValue = "";
for (var key in styleMap) {
@@ -486,6 +488,7 @@ export class Parse5DomAdapter extends DomAdapter {
el.href = baseUrl + '/../' + href;
}
}
/** @internal */
_buildRules(parsedRules, css?) {
var rules = [];
for (var i = 0; i < parsedRules.length; i++) {
+4 -1
View File
@@ -60,7 +60,9 @@ export namespace NodeJS {
}
export class TimerWrapper {
static setTimeout(fn: (...args: any[]) => void, millis: number): NodeJS.Timer { return global.setTimeout(fn, millis); }
static setTimeout(fn: (...args: any[]) => void, millis: number): NodeJS.Timer {
return global.setTimeout(fn, millis);
}
static clearTimeout(id: NodeJS.Timer): void { global.clearTimeout(id); }
static setInterval(fn: (...args: any[]) => void, millis: number): NodeJS.Timer {
@@ -132,6 +134,7 @@ export class Observable {
* Once a reference implementation of the spec is available, switch to it.
*/
export class EventEmitter extends Observable {
/** @internal */
_subject = new Subject();
observer(generator: any): any {
@@ -78,15 +78,18 @@ export class ExceptionHandler {
if (this._rethrowException) throw exception;
}
/** @internal */
_extractMessage(exception: any): string {
return exception instanceof WrappedException ? exception.wrapperMessage : exception.toString();
}
/** @internal */
_longStackTrace(stackTrace: any): any {
return isListLikeIterable(stackTrace) ? (<any[]>stackTrace).join("\n\n-----async gap-----\n") :
stackTrace.toString();
}
/** @internal */
_findContext(exception: any): any {
try {
if (!(exception instanceof WrappedException)) return null;
@@ -98,6 +101,7 @@ export class ExceptionHandler {
}
}
/** @internal */
_findOriginalException(exception: any): any {
if (!(exception instanceof WrappedException)) return null;
@@ -109,6 +113,7 @@ export class ExceptionHandler {
return e;
}
/** @internal */
_findOriginalStack(exception: any): any {
if (!(exception instanceof WrappedException)) return null;
@@ -58,6 +58,7 @@ const controlGroupBinding =
})
export class NgControlGroup extends ControlContainer implements OnInit,
OnDestroy {
/** @internal */
_parent: ControlContainer;
constructor(@Host() @SkipSelf() _parent: ControlContainer) {
super();
@@ -80,11 +80,13 @@ const controlNameBinding =
})
export class NgControlName extends NgControl implements OnChanges,
OnDestroy {
/** @internal */
_parent: ControlContainer;
update = new EventEmitter();
model: any;
viewModel: any;
validators: Function[];
/** @internal */
_added = false;
constructor(@Host() @SkipSelf() parent: ControlContainer,
@@ -157,10 +157,12 @@ export class NgForm extends ControlContainer implements Form {
return false;
}
/** @internal */
_findContainer(path: string[]): ControlGroup {
path.pop();
return ListWrapper.isEmpty(path) ? this.form : <ControlGroup>this.form.find(path);
}
/** @internal */
_later(fn): void { PromiseWrapper.then(PromiseWrapper.resolve(null), fn, (_) => {}); }
}
@@ -72,6 +72,7 @@ const formControlBinding =
export class NgFormControl extends NgControl implements OnChanges {
form: Control;
update = new EventEmitter();
/** @internal */
_added = false;
model: any;
viewModel: any;
@@ -140,6 +140,7 @@ export class NgFormModel extends ControlContainer implements Form,
return false;
}
/** @internal */
_updateDomValue() {
this.directives.forEach(dir => {
var ctrl: any = this.form.find(dir.path);
@@ -41,7 +41,9 @@ const formControlBinding = CONST_EXPR(new Binding(NgControl, {toAlias: forwardRe
exportAs: 'form'
})
export class NgModel extends NgControl implements OnChanges {
/** @internal */
_control = new Control();
/** @internal */
_added = false;
update = new EventEmitter();
model: any;
@@ -96,6 +96,7 @@ export class FormBuilder {
}
}
/** @internal */
_reduceControls(controlsConfig: any): {[key: string]: modelModule.AbstractControl} {
var controls: {[key: string]: modelModule.AbstractControl} = {};
StringMapWrapper.forEach(controlsConfig, (controlConfig, controlName) => {
@@ -104,6 +105,7 @@ export class FormBuilder {
return controls;
}
/** @internal */
_createControl(controlConfig: any): modelModule.AbstractControl {
if (controlConfig instanceof modelModule.Control ||
controlConfig instanceof modelModule.ControlGroup ||
+16 -1
View File
@@ -41,13 +41,19 @@ function _find(control: AbstractControl, path: Array<string | number>| string) {
* Omitting from external API doc as this is really an abstract internal concept.
*/
export class AbstractControl {
/** @internal */
_value: any;
/** @internal */
_status: string;
/** @internal */
_errors: {[key: string]: any};
/** @internal */
_pristine: boolean = true;
/** @internal */
_touched: boolean = false;
/** @internal */
_parent: ControlGroup | ControlArray;
/** @internal */
_valueChanges: EventEmitter;
constructor(public validator: Function) {}
@@ -128,6 +134,7 @@ export class AbstractControl {
return isPresent(this.getError(errorCode, path));
}
/** @internal */
_updateValue(): void {}
}
@@ -148,6 +155,7 @@ export class AbstractControl {
* ### Example ([live demo](http://plnkr.co/edit/23DESOpbNnBpBHZt1BR4?p=preview))
*/
export class Control extends AbstractControl {
/** @internal */
_onChange: Function;
constructor(value: any = null, validator: Function = Validators.nullValidator) {
@@ -234,12 +242,15 @@ export class ControlGroup extends AbstractControl {
return c && this._included(controlName);
}
/** @internal */
_setParentForControls() {
StringMapWrapper.forEach(this.controls, (control, name) => { control.setParent(this); });
}
/** @internal */
_updateValue() { this._value = this._reduceValue(); }
/** @internal */
_reduceValue() {
return this._reduceChildren({}, (acc, control, name) => {
acc[name] = control.value;
@@ -247,6 +258,7 @@ export class ControlGroup extends AbstractControl {
});
}
/** @internal */
_reduceChildren(initValue: any, fn: Function) {
var res = initValue;
StringMapWrapper.forEach(this.controls, (control, name) => {
@@ -257,6 +269,7 @@ export class ControlGroup extends AbstractControl {
return res;
}
/** @internal */
_included(controlName: string): boolean {
var isOptional = StringMapWrapper.contains(this._optionals, controlName);
return !isOptional || StringMapWrapper.get(this._optionals, controlName);
@@ -331,8 +344,10 @@ export class ControlArray extends AbstractControl {
*/
get length(): number { return this.controls.length; }
/** @internal */
_updateValue(): void { this._value = this.controls.map((control) => control.value); }
/** @internal */
_setParentForControls(): void {
this.controls.forEach((control) => { control.setParent(this); });
}

Some files were not shown because too many files have changed in this diff Show More