tools: added experimentalDecorators flag to tsconfig
This commit is contained in:
@ -52,7 +52,7 @@ export class AbstractChangeDetector implements ChangeDetector {
|
||||
|
||||
detectChangesInRecords(throwOnChange: boolean): void {}
|
||||
|
||||
hydrate(context: any, locals: Locals, directives: any): void {}
|
||||
hydrate(context: any, locals: Locals, directives: any, pipes: any): void {}
|
||||
|
||||
dehydrate(): void {}
|
||||
|
||||
|
@ -107,11 +107,10 @@ export class PreGeneratedChangeDetection extends ChangeDetection {
|
||||
_dynamicChangeDetection: ChangeDetection;
|
||||
_protoChangeDetectorFactories: StringMap<string, Function>;
|
||||
|
||||
constructor(private registry: PipeRegistry,
|
||||
@Inject(PROTO_CHANGE_DETECTOR_KEY) @Optional()
|
||||
constructor(@Inject(PROTO_CHANGE_DETECTOR_KEY) @Optional()
|
||||
protoChangeDetectorsForTest?: StringMap<string, Function>) {
|
||||
super();
|
||||
this._dynamicChangeDetection = new DynamicChangeDetection(registry);
|
||||
this._dynamicChangeDetection = new DynamicChangeDetection();
|
||||
this._protoChangeDetectorFactories = isPresent(protoChangeDetectorsForTest) ?
|
||||
protoChangeDetectorsForTest :
|
||||
preGeneratedProtoDetectors;
|
||||
@ -122,8 +121,7 @@ export class PreGeneratedChangeDetection extends ChangeDetection {
|
||||
createProtoChangeDetector(definition: ChangeDetectorDefinition): ProtoChangeDetector {
|
||||
var id = definition.id;
|
||||
if (StringMapWrapper.contains(this._protoChangeDetectorFactories, id)) {
|
||||
return StringMapWrapper.get(this._protoChangeDetectorFactories, id)(this.registry,
|
||||
definition);
|
||||
return StringMapWrapper.get(this._protoChangeDetectorFactories, id)(definition);
|
||||
}
|
||||
return this._dynamicChangeDetection.createProtoChangeDetector(definition);
|
||||
}
|
||||
@ -139,10 +137,8 @@ export class PreGeneratedChangeDetection extends ChangeDetection {
|
||||
*/
|
||||
@Injectable()
|
||||
export class DynamicChangeDetection extends ChangeDetection {
|
||||
constructor(private registry: PipeRegistry) { super(); }
|
||||
|
||||
createProtoChangeDetector(definition: ChangeDetectorDefinition): ProtoChangeDetector {
|
||||
return new DynamicProtoChangeDetector(this.registry, definition);
|
||||
return new DynamicProtoChangeDetector(definition);
|
||||
}
|
||||
}
|
||||
|
||||
@ -157,12 +153,10 @@ export class DynamicChangeDetection extends ChangeDetection {
|
||||
@Injectable()
|
||||
@CONST()
|
||||
export class JitChangeDetection extends ChangeDetection {
|
||||
constructor(public registry: PipeRegistry) { super(); }
|
||||
|
||||
static isSupported(): boolean { return JitProtoChangeDetector.isSupported(); }
|
||||
|
||||
createProtoChangeDetector(definition: ChangeDetectorDefinition): ProtoChangeDetector {
|
||||
return new JitProtoChangeDetector(this.registry, definition);
|
||||
return new JitProtoChangeDetector(definition);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -67,14 +67,14 @@ export class ChangeDetectorJITGenerator {
|
||||
generate(): Function {
|
||||
var typeName = _sanitizeName(`ChangeDetector_${this.id}`);
|
||||
var classDefinition = `
|
||||
var ${typeName} = function ${typeName}(dispatcher, pipeRegistry, protos, directiveRecords) {
|
||||
var ${typeName} = function ${typeName}(dispatcher, protos, directiveRecords) {
|
||||
${ABSTRACT_CHANGE_DETECTOR}.call(this, ${JSON.stringify(this.id)});
|
||||
${DISPATCHER_ACCESSOR} = dispatcher;
|
||||
${PIPE_REGISTRY_ACCESSOR} = pipeRegistry;
|
||||
${PROTOS_ACCESSOR} = protos;
|
||||
${DIRECTIVES_ACCESSOR} = directiveRecords;
|
||||
${LOCALS_ACCESSOR} = null;
|
||||
${CURRENT_PROTO} = null;
|
||||
${CURRENT_PROTO} = null;
|
||||
${PIPE_REGISTRY_ACCESSOR} = null;
|
||||
${ALREADY_CHECKED_ACCESSOR} = false;
|
||||
${this._genFieldDefinitions()}
|
||||
}
|
||||
@ -91,32 +91,33 @@ export class ChangeDetectorJITGenerator {
|
||||
this.throwError(${CURRENT_PROTO}, e, e.stack);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
${typeName}.prototype.__detectChangesInRecords = function(throwOnChange) {
|
||||
${CURRENT_PROTO} = null;
|
||||
|
||||
|
||||
${this._genLocalDefinitions()}
|
||||
${this._genChangeDefinitions()}
|
||||
var ${IS_CHANGED_LOCAL} = false;
|
||||
var ${CHANGES_LOCAL} = null;
|
||||
|
||||
|
||||
context = ${CONTEXT_ACCESSOR};
|
||||
|
||||
|
||||
${this.records.map((r) => this._genRecord(r)).join("\n")}
|
||||
|
||||
|
||||
${ALREADY_CHECKED_ACCESSOR} = true;
|
||||
}
|
||||
|
||||
|
||||
${typeName}.prototype.callOnAllChangesDone = function() {
|
||||
${this._genCallOnAllChangesDoneBody()}
|
||||
}
|
||||
|
||||
${typeName}.prototype.hydrate = function(context, locals, directives) {
|
||||
${typeName}.prototype.hydrate = function(context, locals, directives, pipeRegistry) {
|
||||
${MODE_ACCESSOR} = "${ChangeDetectionUtil.changeDetectionMode(this.changeDetectionStrategy)}";
|
||||
${CONTEXT_ACCESSOR} = context;
|
||||
${LOCALS_ACCESSOR} = locals;
|
||||
${this._genHydrateDirectives()}
|
||||
${this._genHydrateDetectors()}
|
||||
${PIPE_REGISTRY_ACCESSOR} = pipeRegistry;
|
||||
${ALREADY_CHECKED_ACCESSOR} = false;
|
||||
}
|
||||
|
||||
@ -124,14 +125,15 @@ export class ChangeDetectorJITGenerator {
|
||||
${this._genPipeOnDestroy()}
|
||||
${this._genFieldDefinitions()}
|
||||
${LOCALS_ACCESSOR} = null;
|
||||
${PIPE_REGISTRY_ACCESSOR} = null;
|
||||
}
|
||||
|
||||
${typeName}.prototype.hydrated = function() {
|
||||
return ${CONTEXT_ACCESSOR} !== null;
|
||||
}
|
||||
|
||||
return function(dispatcher, pipeRegistry) {
|
||||
return new ${typeName}(dispatcher, pipeRegistry, protos, directiveRecords);
|
||||
return function(dispatcher) {
|
||||
return new ${typeName}(dispatcher, protos, directiveRecords);
|
||||
}
|
||||
`;
|
||||
return new Function('AbstractChangeDetector', 'ChangeDetectionUtil', 'protos',
|
||||
|
@ -18,10 +18,10 @@ export class DynamicChangeDetector extends AbstractChangeDetector {
|
||||
prevContexts: List<any>;
|
||||
directives: any = null;
|
||||
alreadyChecked: boolean = false;
|
||||
private pipeRegistry: PipeRegistry = null;
|
||||
|
||||
constructor(id: string, private changeControlStrategy: string, private dispatcher: any,
|
||||
private pipeRegistry: PipeRegistry, private protos: List<ProtoRecord>,
|
||||
private directiveRecords: List<any>) {
|
||||
private protos: List<ProtoRecord>, private directiveRecords: List<any>) {
|
||||
super(id);
|
||||
this.values = ListWrapper.createFixedSize(protos.length + 1);
|
||||
this.pipes = ListWrapper.createFixedSize(protos.length + 1);
|
||||
@ -35,12 +35,13 @@ export class DynamicChangeDetector extends AbstractChangeDetector {
|
||||
ListWrapper.fill(this.changes, false);
|
||||
}
|
||||
|
||||
hydrate(context: any, locals: Locals, directives: any) {
|
||||
hydrate(context: any, locals: Locals, directives: any, pipeRegistry: PipeRegistry): void {
|
||||
this.mode = ChangeDetectionUtil.changeDetectionMode(this.changeControlStrategy);
|
||||
this.values[0] = context;
|
||||
this.locals = locals;
|
||||
this.directives = directives;
|
||||
this.alreadyChecked = false;
|
||||
this.pipeRegistry = pipeRegistry;
|
||||
}
|
||||
|
||||
dehydrate() {
|
||||
@ -51,6 +52,7 @@ export class DynamicChangeDetector extends AbstractChangeDetector {
|
||||
ListWrapper.fill(this.pipes, null);
|
||||
ListWrapper.fill(this.prevContexts, uninitialized);
|
||||
this.locals = null;
|
||||
this.pipeRegistry = null;
|
||||
}
|
||||
|
||||
_destroyPipes() {
|
||||
|
@ -51,7 +51,7 @@ export interface ChangeDetector {
|
||||
removeChild(cd: ChangeDetector): void;
|
||||
removeShadowDomChild(cd: ChangeDetector): void;
|
||||
remove(): void;
|
||||
hydrate(context: any, locals: Locals, directives: any): void;
|
||||
hydrate(context: any, locals: Locals, directives: any, pipeRegistry: any): void;
|
||||
dehydrate(): void;
|
||||
markPathToRootAsCheckOnce(): void;
|
||||
|
||||
|
@ -3,7 +3,7 @@ library change_detection.jit_proto_change_detector;
|
||||
import 'interfaces.dart' show ChangeDetector, ProtoChangeDetector;
|
||||
|
||||
class JitProtoChangeDetector implements ProtoChangeDetector {
|
||||
JitProtoChangeDetector(registry, definition) : super();
|
||||
JitProtoChangeDetector(definition) : super();
|
||||
|
||||
static bool isSupported() => false;
|
||||
|
||||
|
@ -9,15 +9,13 @@ import {ProtoRecordBuilder} from './proto_change_detector';
|
||||
export class JitProtoChangeDetector implements ProtoChangeDetector {
|
||||
_factory: Function;
|
||||
|
||||
constructor(private _pipeRegistry, private definition: ChangeDetectorDefinition) {
|
||||
constructor(private definition: ChangeDetectorDefinition) {
|
||||
this._factory = this._createFactory(definition);
|
||||
}
|
||||
|
||||
static isSupported(): boolean { return true; }
|
||||
|
||||
instantiate(dispatcher: any): ChangeDetector {
|
||||
return this._factory(dispatcher, this._pipeRegistry);
|
||||
}
|
||||
instantiate(dispatcher: any): ChangeDetector { return this._factory(dispatcher); }
|
||||
|
||||
_createFactory(definition: ChangeDetectorDefinition) {
|
||||
var recordBuilder = new ProtoRecordBuilder();
|
||||
|
@ -3,7 +3,6 @@ library angular2.src.change_detection.pregen_proto_change_detector;
|
||||
import 'package:angular2/src/change_detection/coalesce.dart';
|
||||
import 'package:angular2/src/change_detection/directive_record.dart';
|
||||
import 'package:angular2/src/change_detection/interfaces.dart';
|
||||
import 'package:angular2/src/change_detection/pipes/pipe_registry.dart';
|
||||
import 'package:angular2/src/change_detection/proto_change_detector.dart';
|
||||
import 'package:angular2/src/change_detection/proto_record.dart';
|
||||
|
||||
@ -25,10 +24,10 @@ export 'package:angular2/src/change_detection/change_detection_util.dart'
|
||||
export 'package:angular2/src/facade/lang.dart' show looseIdentical;
|
||||
|
||||
typedef ProtoChangeDetector PregenProtoChangeDetectorFactory(
|
||||
PipeRegistry registry, ChangeDetectorDefinition definition);
|
||||
ChangeDetectorDefinition definition);
|
||||
|
||||
typedef ChangeDetector InstantiateMethod(dynamic dispatcher,
|
||||
PipeRegistry registry, List<ProtoRecord> protoRecords,
|
||||
List<ProtoRecord> protoRecords,
|
||||
List<DirectiveRecord> directiveRecords);
|
||||
|
||||
/// Implementation of [ProtoChangeDetector] for use by pre-generated change
|
||||
@ -44,29 +43,28 @@ class PregenProtoChangeDetector extends ProtoChangeDetector {
|
||||
final InstantiateMethod _instantiateMethod;
|
||||
|
||||
// [ChangeDetector] dependencies.
|
||||
final PipeRegistry _pipeRegistry;
|
||||
final List<ProtoRecord> _protoRecords;
|
||||
final List<DirectiveRecord> _directiveRecords;
|
||||
|
||||
/// Internal ctor.
|
||||
PregenProtoChangeDetector._(this.id, this._instantiateMethod,
|
||||
this._pipeRegistry, this._protoRecords, this._directiveRecords);
|
||||
this._protoRecords, this._directiveRecords);
|
||||
|
||||
static bool isSupported() => true;
|
||||
|
||||
factory PregenProtoChangeDetector(InstantiateMethod instantiateMethod,
|
||||
PipeRegistry registry, ChangeDetectorDefinition def) {
|
||||
ChangeDetectorDefinition def) {
|
||||
// TODO(kegluneq): Pre-generate these (#2067).
|
||||
var recordBuilder = new ProtoRecordBuilder();
|
||||
def.bindingRecords.forEach((b) {
|
||||
recordBuilder.add(b, def.variableNames);
|
||||
});
|
||||
var protoRecords = coalesce(recordBuilder.records);
|
||||
return new PregenProtoChangeDetector._(def.id, instantiateMethod, registry,
|
||||
return new PregenProtoChangeDetector._(def.id, instantiateMethod,
|
||||
protoRecords, def.directiveRecords);
|
||||
}
|
||||
|
||||
@override
|
||||
instantiate(dynamic dispatcher) => _instantiateMethod(
|
||||
dispatcher, _pipeRegistry, _protoRecords, _directiveRecords);
|
||||
dispatcher, _protoRecords, _directiveRecords);
|
||||
}
|
||||
|
@ -28,7 +28,6 @@ import {
|
||||
import {ChangeDetector, ProtoChangeDetector, ChangeDetectorDefinition} from './interfaces';
|
||||
import {ChangeDetectionUtil} from './change_detection_util';
|
||||
import {DynamicChangeDetector} from './dynamic_change_detector';
|
||||
import {PipeRegistry} from './pipes/pipe_registry';
|
||||
import {BindingRecord} from './binding_record';
|
||||
import {DirectiveRecord, DirectiveIndex} from './directive_record';
|
||||
|
||||
@ -39,14 +38,13 @@ import {ProtoRecord, RecordType} from './proto_record';
|
||||
export class DynamicProtoChangeDetector implements ProtoChangeDetector {
|
||||
_records: List<ProtoRecord>;
|
||||
|
||||
constructor(private _pipeRegistry: PipeRegistry, private definition: ChangeDetectorDefinition) {
|
||||
constructor(private definition: ChangeDetectorDefinition) {
|
||||
this._records = this._createRecords(definition);
|
||||
}
|
||||
|
||||
instantiate(dispatcher: any): ChangeDetector {
|
||||
return new DynamicChangeDetector(this.definition.id, this.definition.strategy, dispatcher,
|
||||
this._pipeRegistry, this._records,
|
||||
this.definition.directiveRecords);
|
||||
this._records, this.definition.directiveRecords);
|
||||
}
|
||||
|
||||
_createRecords(definition: ChangeDetectorDefinition) {
|
||||
|
Reference in New Issue
Block a user