UNPKG

17.8 kBSource Map (JSON)View Raw
1{"version":3,"file":"reflection_capabilities.js","sourceRoot":"","sources":["../../lib/reflection/reflection_capabilities.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;;AAEH,OAAO,EAAE,MAAM,EAAa,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAK9C;;GAEG;AACH,MAAM,CAAC,IAAM,aAAa,GAAG,4DAA4D,CAAC;AAE1F;IAGE,gCAAY,OAAa;QACvB,IAAI,CAAC,QAAQ,GAAG,OAAO,IAAI,MAAM,CAAC,SAAS,CAAC,CAAC;IAC/C,CAAC;IAED,oDAAmB,GAAnB;QACE,OAAO,IAAI,CAAC;IACd,CAAC;IAED,wCAAO,GAAP,UAAW,CAAU;QACnB,OAAO;YAAC,cAAc;iBAAd,UAAc,EAAd,qBAAc,EAAd,IAAc;gBAAd,yBAAc;;YAAK,YAAI,CAAC,YAAD,CAAC,2BAAI,IAAI;QAAb,CAAc,CAAC;IAC5C,CAAC;IAED,gBAAgB;IAChB,wDAAuB,GAAvB,UAAwB,UAAiB,EAAE,gBAAuB;QAChE,IAAI,MAAe,CAAC;QAEpB,IAAI,OAAO,UAAU,KAAK,WAAW,EAAE;YACrC,MAAM,GAAG,IAAI,KAAK,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC;SAC7C;aAAM;YACL,MAAM,GAAG,IAAI,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;SACvC;QAED,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACtC,sEAAsE;YACtE,mEAAmE;YACnE,wCAAwC;YACxC,IAAI,OAAO,UAAU,KAAK,WAAW,EAAE;gBACrC,MAAM,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;gBACf,yCAAyC;aAC1C;iBAAM,IAAI,UAAU,CAAC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AS,CAAC,CAAC;IAC1D,IAAM,UAAU,GAAG,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC;IAChE,iDAAiD;IACjD,iCAAiC;IACjC,OAAO,UAAU,IAAI,MAAM,CAAC;AAC9B,CAAC","sourcesContent":["/**\n * @license\n * Copyright Google Inc. All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nimport { global, isPresent, stringify } from '../facade/lang';\nimport { Type, isType } from '../facade/type';\n\nimport { PlatformReflectionCapabilities } from './platform_reflection_capabilities';\nimport { GetterFn, MethodFn, SetterFn } from './types';\n\n/**\n * Attention: This regex has to hold even if the code is minified!\n */\nexport const DELEGATE_CTOR = /^function\\s+\\S+\\(\\)\\s*{[\\s\\S]+\\.apply\\(this,\\s*arguments\\)/;\n\nexport class ReflectionCapabilities implements PlatformReflectionCapabilities {\n private _reflect: any;\n\n constructor(reflect?: any) {\n this._reflect = reflect || global['Reflect'];\n }\n\n isReflectionEnabled(): boolean {\n return true;\n }\n\n factory<T>(t: Type<T>): (args: any[]) => T {\n return (...args: any[]) => new t(...args);\n }\n\n /** @internal */\n _zipTypesAndAnnotations(paramTypes: any[], paramAnnotations: any[]): any[][] {\n let result: any[][];\n\n if (typeof paramTypes === 'undefined') {\n result = new Array(paramAnnotations.length);\n } else {\n result = new Array(paramTypes.length);\n }\n\n for (let i = 0; i < result.length; i++) {\n // TS outputs Object for parameters without types, while Traceur omits\n // the annotations. For now we preserve the Traceur behavior to aid\n // migration, but this can be revisited.\n if (typeof paramTypes === 'undefined') {\n result[i] = [];\n // tslint:disable-next-line:triple-equals\n } else if (paramTypes[i] != Object) {\n result[i] = [paramTypes[i]];\n } else {\n result[i] = [];\n }\n if (paramAnnotations && paramAnnotations[i] != null) {\n result[i] = result[i].concat(paramAnnotations[i]);\n }\n }\n return result;\n }\n\n private _ownParameters(type: Type<any>, parentCtor: any): any[][] | null {\n // If we have no decorators, we only have function.length as metadata.\n // In that case, to detect whether a child class declared an own constructor or not,\n // we need to look inside of that constructor to check whether it is\n // just calling the parent.\n // This also helps to work around for https://github.com/Microsoft/TypeScript/issues/12439\n // that sets 'design:paramtypes' to []\n // if a class inherits from another class but has no ctor declared itself.\n if (DELEGATE_CTOR.exec(type.toString())) {\n return null;\n }\n\n // Prefer the direct API.\n if ((<any>type).parameters && (<any>type).parameters !== parentCtor.parameters) {\n return (<any>type).parameters;\n }\n\n // API of tsickle for lowering decorators to properties on the class.\n const tsickleCtorParams = (<any>type).ctorParameters;\n if (tsickleCtorParams && tsickleCtorParams !== parentCtor.ctorParameters) {\n // Newer tsickle uses a function closure\n // Retain the non-function case for compatibility with older tsickle\n const ctorParameters = typeof tsickleCtorParams === 'function' ? tsickleCtorParams() : tsickleCtorParams;\n const paramTypes = ctorParameters.map((ctorParam: any) => ctorParam && ctorParam.type);\n const paramAnnotations = ctorParameters.map(\n (ctorParam: any) => ctorParam && convertTsickleDecoratorIntoMetadata(ctorParam.decorators)\n );\n return this._zipTypesAndAnnotations(paramTypes, paramAnnotations);\n }\n\n // API for metadata created by invoking the decorators.\n if (this._reflect != null && this._reflect.getOwnMetadata != null) {\n const paramAnnotations = this._reflect.getOwnMetadata('parameters', type);\n const paramTypes = this._reflect.getOwnMetadata('design:paramtypes', type);\n if (paramTypes || paramAnnotations) {\n return this._zipTypesAndAnnotations(paramTypes, paramAnnotations);\n }\n }\n\n // If a class has no decorators, at least create metadata\n // based on function.length.\n // Note: We know that this is a real constructor as we checked\n // the content of the constructor above.\n return new Array(<any>type.length).fill(undefined);\n }\n\n parameters(type: Type<any>): any[][] {\n // Note: only report metadata if we have at least one class decorator\n // to stay in sync with the static reflector.\n if (!isType(type)) {\n return [];\n }\n const parentCtor = getParentCtor(type);\n let parameters = this._ownParameters(type, parentCtor);\n if (!parameters && parentCtor !== Object) {\n parameters = this.parameters(parentCtor);\n }\n return parameters || [];\n }\n\n private _ownAnnotations(typeOrFunc: Type<any>, parentCtor: any): any[] | null {\n // Prefer the direct API.\n if ((<any>typeOrFunc).annotations && (<any>typeOrFunc).annotations !== parentCtor.annotations) {\n let annotations = (<any>typeOrFunc).annotations;\n if (typeof annotations === 'function' && annotations.annotations) {\n annotations = annotations.annotations;\n }\n return annotations;\n }\n\n // API of tsickle for lowering decorators to properties on the class.\n if ((<any>typeOrFunc).decorators && (<any>typeOrFunc).decorators !== parentCtor.decorators) {\n return convertTsickleDecoratorIntoMetadata((<any>typeOrFunc).decorators);\n }\n\n // API for metadata created by invoking the decorators.\n if (this._reflect && this._reflect.getOwnMetadata) {\n return this._reflect.getOwnMetadata('annotations', typeOrFunc);\n }\n return null;\n }\n\n annotations(typeOrFunc: Type<any>): any[] {\n if (!isType(typeOrFunc)) {\n return [];\n }\n const parentCtor = getParentCtor(typeOrFunc);\n const ownAnnotations = this._ownAnnotations(typeOrFunc, parentCtor) || [];\n const parentAnnotations = parentCtor !== Object ? this.annotations(parentCtor) : [];\n return parentAnnotations.concat(ownAnnotations);\n }\n\n private _ownPropMetadata(typeOrFunc: any, parentCtor: any): { [key: string]: any[] } | null {\n // Prefer the direct API.\n if ((<any>typeOrFunc).propMetadata && (<any>typeOrFunc).propMetadata !== parentCtor.propMetadata) {\n let propMetadata = (<any>typeOrFunc).propMetadata;\n if (typeof propMetadata === 'function' && propMetadata.propMetadata) {\n propMetadata = propMetadata.propMetadata;\n }\n return propMetadata;\n }\n\n // API of tsickle for lowering decorators to properties on the class.\n if ((<any>typeOrFunc).propDecorators && (<any>typeOrFunc).propDecorators !== parentCtor.propDecorators) {\n const propDecorators = (<any>typeOrFunc).propDecorators;\n const propMetadata = <{ [key: string]: any[] }>{};\n Object.keys(propDecorators).forEach(prop => {\n propMetadata[prop] = convertTsickleDecoratorIntoMetadata(propDecorators[prop]);\n });\n return propMetadata;\n }\n\n // API for metadata created by invoking the decorators.\n if (this._reflect && this._reflect.getOwnMetadata) {\n return this._reflect.getOwnMetadata('propMetadata', typeOrFunc);\n }\n return null;\n }\n\n propMetadata(typeOrFunc: any): { [key: string]: any[] } {\n if (!isType(typeOrFunc)) {\n return {};\n }\n const parentCtor = getParentCtor(typeOrFunc);\n const propMetadata: { [key: string]: any[] } = {};\n if (parentCtor !== Object) {\n const parentPropMetadata = this.propMetadata(parentCtor);\n Object.keys(parentPropMetadata).forEach(propName => {\n propMetadata[propName] = parentPropMetadata[propName];\n });\n }\n const ownPropMetadata = this._ownPropMetadata(typeOrFunc, parentCtor);\n if (ownPropMetadata) {\n Object.keys(ownPropMetadata).forEach(propName => {\n const decorators: any[] = [];\n if (propMetadata.hasOwnProperty(propName)) {\n decorators.push(...propMetadata[propName]);\n }\n decorators.push(...ownPropMetadata[propName]);\n propMetadata[propName] = decorators;\n });\n }\n return propMetadata;\n }\n\n hasLifecycleHook(type: any, lcProperty: string): boolean {\n return type instanceof Type && lcProperty in type.prototype;\n }\n\n getter(name: string): GetterFn {\n return <GetterFn>new Function('o', 'return o.' + name + ';');\n }\n\n setter(name: string): SetterFn {\n return <SetterFn>new Function('o', 'v', 'return o.' + name + ' = v;');\n }\n\n method(name: string): MethodFn {\n const functionBody = `if (!o.${name}) throw new Error('\"${name}\" is undefined');\n return o.${name}.apply(o, args);`;\n return <MethodFn>new Function('o', 'args', functionBody);\n }\n\n // There is not a concept of import uri in Js, but this is useful in developing Dart applications.\n importUri(type: any): string {\n // StaticSymbol\n if (typeof type === 'object' && type['filePath']) {\n return type['filePath'];\n }\n // Runtime type\n return `./${stringify(type)}`;\n }\n\n resourceUri(type: any): string {\n return `./${stringify(type)}`;\n }\n\n resolveIdentifier(name: string, moduleUrl: string, members: string[], runtime: any): any {\n return runtime;\n }\n resolveEnum(enumIdentifier: any, name: string): any {\n return enumIdentifier[name];\n }\n}\n\nfunction convertTsickleDecoratorIntoMetadata(decoratorInvocations: any[]): any[] {\n if (!decoratorInvocations) {\n return [];\n }\n return decoratorInvocations.map(decoratorInvocation => {\n const decoratorType = decoratorInvocation.type;\n const annotationCls = decoratorType.annotationCls;\n const annotationArgs = decoratorInvocation.args ? decoratorInvocation.args : [];\n return new annotationCls(...annotationArgs);\n });\n}\n\nfunction getParentCtor(ctor: Function): Type<any> {\n if (!ctor.prototype) {\n return Object;\n }\n const parentProto = Object.getPrototypeOf(ctor.prototype);\n const parentCtor = parentProto ? parentProto.constructor : null;\n // Note: We always use `Object` as the null value\n // to simplify checking later on.\n return parentCtor || Object;\n}\n"]}
\No newline at end of file