From 51cad25703786f4edfaa5e08db2ef2c8bf5fc126 Mon Sep 17 00:00:00 2001 From: Rob Eisenberg Date: Wed, 15 Jul 2015 17:29:44 -0400 Subject: [PATCH] fix(all): improve several d.ts definitions with better type info Fixes #132 --- dist/amd/aurelia-templating.d.ts | 78 +++++++++++++-------------- dist/amd/index.js | 4 +- dist/commonjs/aurelia-templating.d.ts | 78 +++++++++++++-------------- dist/commonjs/index.js | 6 +-- dist/es6/aurelia-templating.d.ts | 78 +++++++++++++-------------- dist/es6/index.js | 78 +++++++++++++-------------- dist/index.d.ts | 78 +++++++++++++-------------- dist/index.js | 78 +++++++++++++-------------- dist/system/aurelia-templating.d.ts | 78 +++++++++++++-------------- dist/system/index.js | 14 ++--- src/html-behavior.js | 21 ++++---- src/module-analyzer.js | 24 +++++---- src/view-engine.js | 13 ++--- src/view-strategy.js | 28 +++++----- 14 files changed, 333 insertions(+), 323 deletions(-) diff --git a/dist/amd/aurelia-templating.d.ts b/dist/amd/aurelia-templating.d.ts index 83a558a7..85ad24c7 100644 --- a/dist/amd/aurelia-templating.d.ts +++ b/dist/amd/aurelia-templating.d.ts @@ -2,9 +2,9 @@ declare module 'aurelia-templating' { import core from 'core-js'; import { Metadata, Origin, Decorators } from 'aurelia-metadata'; import { relativeToFile } from 'aurelia-path'; + import { TemplateRegistryEntry, Loader } from 'aurelia-loader'; import { Container } from 'aurelia-dependency-injection'; - import { Loader, TemplateRegistryEntry } from 'aurelia-loader'; - import { bindingMode, ObserverLocator, ValueConverterResource, EventManager } from 'aurelia-binding'; + import { bindingMode, ObserverLocator, BindingExpression, Binding, ValueConverterResource, EventManager } from 'aurelia-binding'; import { TaskQueue } from 'aurelia-task-queue'; import * as LogManager from 'aurelia-logging'; export const animationEvent: any; @@ -92,27 +92,27 @@ declare module 'aurelia-templating' { export function hyphenate(name: any): any; export function nextElementSibling(element: any): any; export class ViewStrategy { - static metadataKey: any; - makeRelativeTo(baseUrl: any): any; - static normalize(value: any): any; - static getDefault(target: any): any; + static metadataKey: string; + makeRelativeTo(baseUrl: string): any; + static normalize(value: string | ViewStrategy): any; + static getDefault(target: any): ViewStrategy; } export class UseViewStrategy extends ViewStrategy { - constructor(path: any); - loadViewFactory(viewEngine: any, options: any, loadContext: any): any; - makeRelativeTo(file: any): any; + constructor(path: string); + loadViewFactory(viewEngine: ViewEngine, options: Object, loadContext?: string[]): Promise; + makeRelativeTo(file: string): any; } export class ConventionalViewStrategy extends ViewStrategy { - constructor(moduleId: any); - loadViewFactory(viewEngine: any, options: any, loadContext: any): any; - static convertModuleIdToViewUrl(moduleId: any): any; + constructor(moduleId: string); + loadViewFactory(viewEngine: ViewEngine, options: Object, loadContext?: string[]): Promise; + static convertModuleIdToViewUrl(moduleId: string): string; } export class NoViewStrategy extends ViewStrategy { - loadViewFactory(): any; + loadViewFactory(viewEngine: ViewEngine, options: Object, loadContext?: string[]): Promise; } export class TemplateRegistryViewStrategy extends ViewStrategy { - constructor(moduleId: any, registryEntry: any); - loadViewFactory(viewEngine: any, options: any, loadContext: any): any; + constructor(moduleId: string, registryEntry: TemplateRegistryEntry); + loadViewFactory(viewEngine: ViewEngine, options: Object, loadContext?: string[]): Promise; } export class BindingLanguage { inspectAttribute(resources: any, attrName: any, attrValue: any): any; @@ -202,11 +202,11 @@ declare module 'aurelia-templating' { } export class ViewEngine { static inject(): any; - constructor(loader: any, container: any, viewCompiler: any, moduleAnalyzer: any, appResources: any); - loadViewFactory(urlOrRegistryEntry: any, compileOptions: any, associatedModuleId: any, loadContext: any): any; - loadTemplateResources(viewRegistryEntry: any, associatedModuleId: any, loadContext: any): any; - importViewModelResource(moduleImport: any, moduleMember: any): any; - importViewResources(moduleIds: any, names: any, resources: any, associatedModuleId: any, loadContext: any): any; + constructor(loader: Loader, container: Container, viewCompiler: ViewCompiler, moduleAnalyzer: ModuleAnalyzer, appResources: ResourceRegistry); + loadViewFactory(urlOrRegistryEntry: string | TemplateRegistryEntry, compileOptions?: Object, associatedModuleId?: string, loadContext?: string[]): Promise; + loadTemplateResources(viewRegistryEntry: TemplateRegistryEntry, associatedModuleId?: string, loadContext?: string[]): Promise; + importViewModelResource(moduleImport: string, moduleMember: string): Promise; + importViewResources(moduleIds: string[], names: string[], resources: ResourceRegistry, associatedModuleId?: string, loadContext?: string[]): Promise; } export class BehaviorInstance { constructor(behavior: any, executionContext: any, instruction: any); @@ -235,32 +235,32 @@ declare module 'aurelia-templating' { } export class HtmlBehaviorResource { constructor(); - static convention(name: any, existing: any): any; - addChildBinding(behavior: any): any; - analyze(container: any, target: any): any; - load(container: any, target: any, viewStrategy: any, transientView: any, loadContext: any): any; - register(registry: any, name: any): any; - compile(compiler: any, resources: any, node: any, instruction: any, parentNode: any): any; - create(container: any, instruction?: any, element?: any, bindings?: any): any; - ensurePropertiesDefined(instance: any, lookup: any): any; + static convention(name: string, existing?: HtmlBehaviorResource): any; + addChildBinding(behavior: BindingExpression): any; + analyze(container: Container, target: Function): any; + load(container: Container, target: Function, viewStrategy?: ViewStrategy, transientView?: boolean, loadContext?: string[]): Promise; + register(registry: ResourceRegistry, name?: string): any; + compile(compiler: ViewCompiler, resources: ResourceRegistry, node?: Node, instruction?: Object, parentNode?: Node): Node; + create(container: Container, instruction?: Object, element?: Element, bindings?: Binding[]): BehaviorInstance; + ensurePropertiesDefined(instance: Object, lookup: Object): any; } export class ResourceModule { - constructor(moduleId: any); - analyze(container: any): any; - register(registry: any, name: any): any; - load(container: any, loadContext: any): any; + constructor(moduleId: string); + analyze(container: Container): any; + register(registry: ResourceRegistry, name?: string): any; + load(container: Container, loadContext?: string[]): Promise; } export class ResourceDescription { - constructor(key: any, exportedValue: any, resourceTypeMeta: any); - analyze(container: any): any; - register(registry: any, name: any): any; - load(container: any, loadContext: any): any; - static get(resource: any, key?: any): any; + constructor(key: string, exportedValue: any, resourceTypeMeta: Object); + analyze(container: Container): any; + register(registry: ResourceRegistry, name?: string): any; + load(container: Container, loadContext?: string[]): Promise | void; + static get(resource: any, key?: string): ResourceDescription; } export class ModuleAnalyzer { constructor(); - getAnalysis(moduleId: any): any; - analyze(moduleId: any, moduleInstance: any, viewModelMember: any): any; + getAnalysis(moduleId: string): ResourceModule; + analyze(moduleId: string, moduleInstance: any, viewModelMember?: string): ResourceModule; } export class ChildObserver { constructor(config: any); diff --git a/dist/amd/index.js b/dist/amd/index.js index 674f9b28..a3baa90e 100644 --- a/dist/amd/index.js +++ b/dist/amd/index.js @@ -1,4 +1,4 @@ -define(['exports', 'core-js', 'aurelia-metadata', 'aurelia-path', 'aurelia-dependency-injection', 'aurelia-loader', 'aurelia-binding', 'aurelia-task-queue', 'aurelia-logging'], function (exports, _coreJs, _aureliaMetadata, _aureliaPath, _aureliaDependencyInjection, _aureliaLoader, _aureliaBinding, _aureliaTaskQueue, _aureliaLogging) { +define(['exports', 'core-js', 'aurelia-metadata', 'aurelia-path', 'aurelia-loader', 'aurelia-dependency-injection', 'aurelia-binding', 'aurelia-task-queue', 'aurelia-logging'], function (exports, _coreJs, _aureliaMetadata, _aureliaPath, _aureliaLoader, _aureliaDependencyInjection, _aureliaBinding, _aureliaTaskQueue, _aureliaLogging) { 'use strict'; exports.__esModule = true; @@ -242,7 +242,7 @@ define(['exports', 'core-js', 'aurelia-metadata', 'aurelia-path', 'aurelia-depen _inherits(NoViewStrategy, _ViewStrategy3); - NoViewStrategy.prototype.loadViewFactory = function loadViewFactory() { + NoViewStrategy.prototype.loadViewFactory = function loadViewFactory(viewEngine, options, loadContext) { return Promise.resolve(null); }; diff --git a/dist/commonjs/aurelia-templating.d.ts b/dist/commonjs/aurelia-templating.d.ts index 83a558a7..85ad24c7 100644 --- a/dist/commonjs/aurelia-templating.d.ts +++ b/dist/commonjs/aurelia-templating.d.ts @@ -2,9 +2,9 @@ declare module 'aurelia-templating' { import core from 'core-js'; import { Metadata, Origin, Decorators } from 'aurelia-metadata'; import { relativeToFile } from 'aurelia-path'; + import { TemplateRegistryEntry, Loader } from 'aurelia-loader'; import { Container } from 'aurelia-dependency-injection'; - import { Loader, TemplateRegistryEntry } from 'aurelia-loader'; - import { bindingMode, ObserverLocator, ValueConverterResource, EventManager } from 'aurelia-binding'; + import { bindingMode, ObserverLocator, BindingExpression, Binding, ValueConverterResource, EventManager } from 'aurelia-binding'; import { TaskQueue } from 'aurelia-task-queue'; import * as LogManager from 'aurelia-logging'; export const animationEvent: any; @@ -92,27 +92,27 @@ declare module 'aurelia-templating' { export function hyphenate(name: any): any; export function nextElementSibling(element: any): any; export class ViewStrategy { - static metadataKey: any; - makeRelativeTo(baseUrl: any): any; - static normalize(value: any): any; - static getDefault(target: any): any; + static metadataKey: string; + makeRelativeTo(baseUrl: string): any; + static normalize(value: string | ViewStrategy): any; + static getDefault(target: any): ViewStrategy; } export class UseViewStrategy extends ViewStrategy { - constructor(path: any); - loadViewFactory(viewEngine: any, options: any, loadContext: any): any; - makeRelativeTo(file: any): any; + constructor(path: string); + loadViewFactory(viewEngine: ViewEngine, options: Object, loadContext?: string[]): Promise; + makeRelativeTo(file: string): any; } export class ConventionalViewStrategy extends ViewStrategy { - constructor(moduleId: any); - loadViewFactory(viewEngine: any, options: any, loadContext: any): any; - static convertModuleIdToViewUrl(moduleId: any): any; + constructor(moduleId: string); + loadViewFactory(viewEngine: ViewEngine, options: Object, loadContext?: string[]): Promise; + static convertModuleIdToViewUrl(moduleId: string): string; } export class NoViewStrategy extends ViewStrategy { - loadViewFactory(): any; + loadViewFactory(viewEngine: ViewEngine, options: Object, loadContext?: string[]): Promise; } export class TemplateRegistryViewStrategy extends ViewStrategy { - constructor(moduleId: any, registryEntry: any); - loadViewFactory(viewEngine: any, options: any, loadContext: any): any; + constructor(moduleId: string, registryEntry: TemplateRegistryEntry); + loadViewFactory(viewEngine: ViewEngine, options: Object, loadContext?: string[]): Promise; } export class BindingLanguage { inspectAttribute(resources: any, attrName: any, attrValue: any): any; @@ -202,11 +202,11 @@ declare module 'aurelia-templating' { } export class ViewEngine { static inject(): any; - constructor(loader: any, container: any, viewCompiler: any, moduleAnalyzer: any, appResources: any); - loadViewFactory(urlOrRegistryEntry: any, compileOptions: any, associatedModuleId: any, loadContext: any): any; - loadTemplateResources(viewRegistryEntry: any, associatedModuleId: any, loadContext: any): any; - importViewModelResource(moduleImport: any, moduleMember: any): any; - importViewResources(moduleIds: any, names: any, resources: any, associatedModuleId: any, loadContext: any): any; + constructor(loader: Loader, container: Container, viewCompiler: ViewCompiler, moduleAnalyzer: ModuleAnalyzer, appResources: ResourceRegistry); + loadViewFactory(urlOrRegistryEntry: string | TemplateRegistryEntry, compileOptions?: Object, associatedModuleId?: string, loadContext?: string[]): Promise; + loadTemplateResources(viewRegistryEntry: TemplateRegistryEntry, associatedModuleId?: string, loadContext?: string[]): Promise; + importViewModelResource(moduleImport: string, moduleMember: string): Promise; + importViewResources(moduleIds: string[], names: string[], resources: ResourceRegistry, associatedModuleId?: string, loadContext?: string[]): Promise; } export class BehaviorInstance { constructor(behavior: any, executionContext: any, instruction: any); @@ -235,32 +235,32 @@ declare module 'aurelia-templating' { } export class HtmlBehaviorResource { constructor(); - static convention(name: any, existing: any): any; - addChildBinding(behavior: any): any; - analyze(container: any, target: any): any; - load(container: any, target: any, viewStrategy: any, transientView: any, loadContext: any): any; - register(registry: any, name: any): any; - compile(compiler: any, resources: any, node: any, instruction: any, parentNode: any): any; - create(container: any, instruction?: any, element?: any, bindings?: any): any; - ensurePropertiesDefined(instance: any, lookup: any): any; + static convention(name: string, existing?: HtmlBehaviorResource): any; + addChildBinding(behavior: BindingExpression): any; + analyze(container: Container, target: Function): any; + load(container: Container, target: Function, viewStrategy?: ViewStrategy, transientView?: boolean, loadContext?: string[]): Promise; + register(registry: ResourceRegistry, name?: string): any; + compile(compiler: ViewCompiler, resources: ResourceRegistry, node?: Node, instruction?: Object, parentNode?: Node): Node; + create(container: Container, instruction?: Object, element?: Element, bindings?: Binding[]): BehaviorInstance; + ensurePropertiesDefined(instance: Object, lookup: Object): any; } export class ResourceModule { - constructor(moduleId: any); - analyze(container: any): any; - register(registry: any, name: any): any; - load(container: any, loadContext: any): any; + constructor(moduleId: string); + analyze(container: Container): any; + register(registry: ResourceRegistry, name?: string): any; + load(container: Container, loadContext?: string[]): Promise; } export class ResourceDescription { - constructor(key: any, exportedValue: any, resourceTypeMeta: any); - analyze(container: any): any; - register(registry: any, name: any): any; - load(container: any, loadContext: any): any; - static get(resource: any, key?: any): any; + constructor(key: string, exportedValue: any, resourceTypeMeta: Object); + analyze(container: Container): any; + register(registry: ResourceRegistry, name?: string): any; + load(container: Container, loadContext?: string[]): Promise | void; + static get(resource: any, key?: string): ResourceDescription; } export class ModuleAnalyzer { constructor(); - getAnalysis(moduleId: any): any; - analyze(moduleId: any, moduleInstance: any, viewModelMember: any): any; + getAnalysis(moduleId: string): ResourceModule; + analyze(moduleId: string, moduleInstance: any, viewModelMember?: string): ResourceModule; } export class ChildObserver { constructor(config: any); diff --git a/dist/commonjs/index.js b/dist/commonjs/index.js index 372db505..39f1dbb7 100644 --- a/dist/commonjs/index.js +++ b/dist/commonjs/index.js @@ -37,10 +37,10 @@ var _aureliaMetadata = require('aurelia-metadata'); var _aureliaPath = require('aurelia-path'); -var _aureliaDependencyInjection = require('aurelia-dependency-injection'); - var _aureliaLoader = require('aurelia-loader'); +var _aureliaDependencyInjection = require('aurelia-dependency-injection'); + var _aureliaBinding = require('aurelia-binding'); var _aureliaTaskQueue = require('aurelia-task-queue'); @@ -261,7 +261,7 @@ var NoViewStrategy = (function (_ViewStrategy3) { _inherits(NoViewStrategy, _ViewStrategy3); - NoViewStrategy.prototype.loadViewFactory = function loadViewFactory() { + NoViewStrategy.prototype.loadViewFactory = function loadViewFactory(viewEngine, options, loadContext) { return Promise.resolve(null); }; diff --git a/dist/es6/aurelia-templating.d.ts b/dist/es6/aurelia-templating.d.ts index 83a558a7..85ad24c7 100644 --- a/dist/es6/aurelia-templating.d.ts +++ b/dist/es6/aurelia-templating.d.ts @@ -2,9 +2,9 @@ declare module 'aurelia-templating' { import core from 'core-js'; import { Metadata, Origin, Decorators } from 'aurelia-metadata'; import { relativeToFile } from 'aurelia-path'; + import { TemplateRegistryEntry, Loader } from 'aurelia-loader'; import { Container } from 'aurelia-dependency-injection'; - import { Loader, TemplateRegistryEntry } from 'aurelia-loader'; - import { bindingMode, ObserverLocator, ValueConverterResource, EventManager } from 'aurelia-binding'; + import { bindingMode, ObserverLocator, BindingExpression, Binding, ValueConverterResource, EventManager } from 'aurelia-binding'; import { TaskQueue } from 'aurelia-task-queue'; import * as LogManager from 'aurelia-logging'; export const animationEvent: any; @@ -92,27 +92,27 @@ declare module 'aurelia-templating' { export function hyphenate(name: any): any; export function nextElementSibling(element: any): any; export class ViewStrategy { - static metadataKey: any; - makeRelativeTo(baseUrl: any): any; - static normalize(value: any): any; - static getDefault(target: any): any; + static metadataKey: string; + makeRelativeTo(baseUrl: string): any; + static normalize(value: string | ViewStrategy): any; + static getDefault(target: any): ViewStrategy; } export class UseViewStrategy extends ViewStrategy { - constructor(path: any); - loadViewFactory(viewEngine: any, options: any, loadContext: any): any; - makeRelativeTo(file: any): any; + constructor(path: string); + loadViewFactory(viewEngine: ViewEngine, options: Object, loadContext?: string[]): Promise; + makeRelativeTo(file: string): any; } export class ConventionalViewStrategy extends ViewStrategy { - constructor(moduleId: any); - loadViewFactory(viewEngine: any, options: any, loadContext: any): any; - static convertModuleIdToViewUrl(moduleId: any): any; + constructor(moduleId: string); + loadViewFactory(viewEngine: ViewEngine, options: Object, loadContext?: string[]): Promise; + static convertModuleIdToViewUrl(moduleId: string): string; } export class NoViewStrategy extends ViewStrategy { - loadViewFactory(): any; + loadViewFactory(viewEngine: ViewEngine, options: Object, loadContext?: string[]): Promise; } export class TemplateRegistryViewStrategy extends ViewStrategy { - constructor(moduleId: any, registryEntry: any); - loadViewFactory(viewEngine: any, options: any, loadContext: any): any; + constructor(moduleId: string, registryEntry: TemplateRegistryEntry); + loadViewFactory(viewEngine: ViewEngine, options: Object, loadContext?: string[]): Promise; } export class BindingLanguage { inspectAttribute(resources: any, attrName: any, attrValue: any): any; @@ -202,11 +202,11 @@ declare module 'aurelia-templating' { } export class ViewEngine { static inject(): any; - constructor(loader: any, container: any, viewCompiler: any, moduleAnalyzer: any, appResources: any); - loadViewFactory(urlOrRegistryEntry: any, compileOptions: any, associatedModuleId: any, loadContext: any): any; - loadTemplateResources(viewRegistryEntry: any, associatedModuleId: any, loadContext: any): any; - importViewModelResource(moduleImport: any, moduleMember: any): any; - importViewResources(moduleIds: any, names: any, resources: any, associatedModuleId: any, loadContext: any): any; + constructor(loader: Loader, container: Container, viewCompiler: ViewCompiler, moduleAnalyzer: ModuleAnalyzer, appResources: ResourceRegistry); + loadViewFactory(urlOrRegistryEntry: string | TemplateRegistryEntry, compileOptions?: Object, associatedModuleId?: string, loadContext?: string[]): Promise; + loadTemplateResources(viewRegistryEntry: TemplateRegistryEntry, associatedModuleId?: string, loadContext?: string[]): Promise; + importViewModelResource(moduleImport: string, moduleMember: string): Promise; + importViewResources(moduleIds: string[], names: string[], resources: ResourceRegistry, associatedModuleId?: string, loadContext?: string[]): Promise; } export class BehaviorInstance { constructor(behavior: any, executionContext: any, instruction: any); @@ -235,32 +235,32 @@ declare module 'aurelia-templating' { } export class HtmlBehaviorResource { constructor(); - static convention(name: any, existing: any): any; - addChildBinding(behavior: any): any; - analyze(container: any, target: any): any; - load(container: any, target: any, viewStrategy: any, transientView: any, loadContext: any): any; - register(registry: any, name: any): any; - compile(compiler: any, resources: any, node: any, instruction: any, parentNode: any): any; - create(container: any, instruction?: any, element?: any, bindings?: any): any; - ensurePropertiesDefined(instance: any, lookup: any): any; + static convention(name: string, existing?: HtmlBehaviorResource): any; + addChildBinding(behavior: BindingExpression): any; + analyze(container: Container, target: Function): any; + load(container: Container, target: Function, viewStrategy?: ViewStrategy, transientView?: boolean, loadContext?: string[]): Promise; + register(registry: ResourceRegistry, name?: string): any; + compile(compiler: ViewCompiler, resources: ResourceRegistry, node?: Node, instruction?: Object, parentNode?: Node): Node; + create(container: Container, instruction?: Object, element?: Element, bindings?: Binding[]): BehaviorInstance; + ensurePropertiesDefined(instance: Object, lookup: Object): any; } export class ResourceModule { - constructor(moduleId: any); - analyze(container: any): any; - register(registry: any, name: any): any; - load(container: any, loadContext: any): any; + constructor(moduleId: string); + analyze(container: Container): any; + register(registry: ResourceRegistry, name?: string): any; + load(container: Container, loadContext?: string[]): Promise; } export class ResourceDescription { - constructor(key: any, exportedValue: any, resourceTypeMeta: any); - analyze(container: any): any; - register(registry: any, name: any): any; - load(container: any, loadContext: any): any; - static get(resource: any, key?: any): any; + constructor(key: string, exportedValue: any, resourceTypeMeta: Object); + analyze(container: Container): any; + register(registry: ResourceRegistry, name?: string): any; + load(container: Container, loadContext?: string[]): Promise | void; + static get(resource: any, key?: string): ResourceDescription; } export class ModuleAnalyzer { constructor(); - getAnalysis(moduleId: any): any; - analyze(moduleId: any, moduleInstance: any, viewModelMember: any): any; + getAnalysis(moduleId: string): ResourceModule; + analyze(moduleId: string, moduleInstance: any, viewModelMember?: string): ResourceModule; } export class ChildObserver { constructor(config: any); diff --git a/dist/es6/index.js b/dist/es6/index.js index 849b1634..a423bac5 100644 --- a/dist/es6/index.js +++ b/dist/es6/index.js @@ -1,9 +1,9 @@ import core from 'core-js'; import {Metadata,Origin,Decorators} from 'aurelia-metadata'; import {relativeToFile} from 'aurelia-path'; +import {TemplateRegistryEntry,Loader} from 'aurelia-loader'; import {Container} from 'aurelia-dependency-injection'; -import {Loader,TemplateRegistryEntry} from 'aurelia-loader'; -import {bindingMode,ObserverLocator,ValueConverterResource,EventManager} from 'aurelia-binding'; +import {bindingMode,ObserverLocator,BindingExpression,Binding,ValueConverterResource,EventManager} from 'aurelia-binding'; import {TaskQueue} from 'aurelia-task-queue'; export const animationEvent = { @@ -153,11 +153,11 @@ export function nextElementSibling(element) { } export class ViewStrategy { - static metadataKey = 'aurelia:view-strategy'; + static metadataKey:string = 'aurelia:view-strategy'; - makeRelativeTo(baseUrl){} + makeRelativeTo(baseUrl:string){} - static normalize(value){ + static normalize(value:string|ViewStrategy){ if(typeof value === 'string'){ value = new UseViewStrategy(value); } @@ -169,7 +169,7 @@ export class ViewStrategy { return value; } - static getDefault(target){ + static getDefault(target:any):ViewStrategy{ var strategy, annotation; if(typeof target !== 'function'){ @@ -194,12 +194,12 @@ export class ViewStrategy { } export class UseViewStrategy extends ViewStrategy { - constructor(path){ + constructor(path:string){ super(); this.path = path; } - loadViewFactory(viewEngine, options, loadContext){ + loadViewFactory(viewEngine:ViewEngine, options:Object, loadContext?:string[]):Promise{ if(!this.absolutePath && this.moduleId){ this.absolutePath = relativeToFile(this.path, this.moduleId); } @@ -207,42 +207,42 @@ export class UseViewStrategy extends ViewStrategy { return viewEngine.loadViewFactory(this.absolutePath || this.path, options, this.moduleId, loadContext); } - makeRelativeTo(file){ + makeRelativeTo(file:string){ this.absolutePath = relativeToFile(this.path, file); } } export class ConventionalViewStrategy extends ViewStrategy { - constructor(moduleId){ + constructor(moduleId:string){ super(); this.moduleId = moduleId; this.viewUrl = ConventionalViewStrategy.convertModuleIdToViewUrl(moduleId); } - loadViewFactory(viewEngine, options, loadContext){ + loadViewFactory(viewEngine:ViewEngine, options:Object, loadContext?:string[]):Promise{ return viewEngine.loadViewFactory(this.viewUrl, options, this.moduleId, loadContext); } - static convertModuleIdToViewUrl(moduleId){ + static convertModuleIdToViewUrl(moduleId:string):string{ var id = (moduleId.endsWith('.js') || moduleId.endsWith('.ts')) ? moduleId.substring(0, moduleId.length - 3) : moduleId; return id + '.html'; } } export class NoViewStrategy extends ViewStrategy { - loadViewFactory(){ + loadViewFactory(viewEngine:ViewEngine, options:Object, loadContext?:string[]):Promise{ return Promise.resolve(null); } } export class TemplateRegistryViewStrategy extends ViewStrategy { - constructor(moduleId, registryEntry){ + constructor(moduleId:string, registryEntry:TemplateRegistryEntry){ super(); this.moduleId = moduleId; this.registryEntry = registryEntry; } - loadViewFactory(viewEngine, options, loadContext){ + loadViewFactory(viewEngine:ViewEngine, options:Object, loadContext?:string[]):Promise{ if(this.registryEntry.isReady){ return Promise.resolve(this.registryEntry.factory); } @@ -1656,7 +1656,7 @@ class ProxyViewFactory { export class ViewEngine { static inject() { return [Loader, Container, ViewCompiler, ModuleAnalyzer, ResourceRegistry]; } - constructor(loader, container, viewCompiler, moduleAnalyzer, appResources){ + constructor(loader:Loader, container:Container, viewCompiler:ViewCompiler, moduleAnalyzer:ModuleAnalyzer, appResources:ResourceRegistry){ this.loader = loader; this.container = container; this.viewCompiler = viewCompiler; @@ -1664,7 +1664,7 @@ export class ViewEngine { this.appResources = appResources; } - loadViewFactory(urlOrRegistryEntry, compileOptions, associatedModuleId, loadContext){ + loadViewFactory(urlOrRegistryEntry:string|TemplateRegistryEntry, compileOptions?:Object, associatedModuleId?:string, loadContext?:string[]):Promise{ loadContext = loadContext || []; return ensureRegistryEntry(this.loader, urlOrRegistryEntry).then(viewRegistryEntry => { @@ -1688,7 +1688,7 @@ export class ViewEngine { }); } - loadTemplateResources(viewRegistryEntry, associatedModuleId, loadContext){ + loadTemplateResources(viewRegistryEntry:TemplateRegistryEntry, associatedModuleId?:string, loadContext?:string[]):Promise{ var resources = new ViewResources(this.appResources, viewRegistryEntry.id), dependencies = viewRegistryEntry.dependencies, importIds, names; @@ -1704,7 +1704,7 @@ export class ViewEngine { return this.importViewResources(importIds, names, resources, associatedModuleId, loadContext); } - importViewModelResource(moduleImport, moduleMember){ + importViewModelResource(moduleImport:string, moduleMember:string):Promise{ return this.loader.loadModule(moduleImport).then(viewModelModule => { var normalizedId = Origin.get(viewModelModule).moduleId, resourceModule = this.moduleAnalyzer.analyze(normalizedId, viewModelModule, moduleMember); @@ -1719,7 +1719,7 @@ export class ViewEngine { }); } - importViewResources(moduleIds, names, resources, associatedModuleId, loadContext){ + importViewResources(moduleIds:string[], names:string[], resources:ResourceRegistry, associatedModuleId?:string, loadContext?:string[]):Promise{ loadContext = loadContext || []; return this.loader.loadAllModules(moduleIds).then(imports => { @@ -2158,7 +2158,7 @@ export class HtmlBehaviorResource { this.attributes = {}; } - static convention(name, existing){ + static convention(name:string, existing?:HtmlBehaviorResource){ var behavior; if(name.endsWith('CustomAttribute')){ @@ -2174,7 +2174,7 @@ export class HtmlBehaviorResource { return behavior; } - addChildBinding(behavior){ + addChildBinding(behavior:BindingExpression){ if(this.childBindings === null){ this.childBindings = []; } @@ -2182,7 +2182,7 @@ export class HtmlBehaviorResource { this.childBindings.push(behavior); } - analyze(container, target){ + analyze(container:Container, target:Function){ var proto = target.prototype, properties = this.properties, attributeName = this.attributeName, @@ -2239,7 +2239,7 @@ export class HtmlBehaviorResource { } } - load(container, target, viewStrategy, transientView, loadContext){ + load(container:Container, target:Function, viewStrategy?:ViewStrategy, transientView?:boolean, loadContext?:string[]):Promise{ var options; if(this.elementName !== null){ @@ -2265,7 +2265,7 @@ export class HtmlBehaviorResource { return Promise.resolve(this); } - register(registry, name){ + register(registry:ResourceRegistry, name?:string){ if(this.attributeName !== null) { registry.registerAttribute(name || this.attributeName, this, this.attributeName); } @@ -2275,7 +2275,7 @@ export class HtmlBehaviorResource { } } - compile(compiler, resources, node, instruction, parentNode){ + compile(compiler:ViewCompiler, resources:ResourceRegistry, node?:Node, instruction?:Object, parentNode?:Node):Node{ if(this.liftsContent){ if(!instruction.viewFactory){ var template = document.createElement('template'), @@ -2349,7 +2349,7 @@ export class HtmlBehaviorResource { return node; } - create(container, instruction=defaultInstruction, element=null, bindings=null){ + create(container:Container, instruction?:Object=defaultInstruction, element?:Element=null, bindings?:Binding[]=null):BehaviorInstance{ var executionContext = instruction.executionContext || container.get(this.target), behaviorInstance = new BehaviorInstance(this, executionContext, instruction), childBindings = this.childBindings, @@ -2441,7 +2441,7 @@ export class HtmlBehaviorResource { return behaviorInstance; } - ensurePropertiesDefined(instance, lookup){ + ensurePropertiesDefined(instance:Object, lookup:Object){ var properties, i, ii, observer; if('__propertiesDefined__' in lookup){ @@ -2462,7 +2462,7 @@ export class HtmlBehaviorResource { } export class ResourceModule { - constructor(moduleId){ + constructor(moduleId:string){ this.id = moduleId; this.moduleInstance = null; this.mainResource = null; @@ -2471,7 +2471,7 @@ export class ResourceModule { this.isAnalyzed = false; } - analyze(container){ + analyze(container:Container){ var current = this.mainResource, resources = this.resources, viewStrategy = this.viewStrategy, @@ -2495,7 +2495,7 @@ export class ResourceModule { } } - register(registry, name){ + register(registry:ResourceRegistry, name?:string){ var i, ii, resources = this.resources; if(this.mainResource){ @@ -2509,7 +2509,7 @@ export class ResourceModule { } } - load(container, loadContext){ + load(container:Container, loadContext?:string[]):Promise{ if(this.onLoaded){ return this.onLoaded; } @@ -2532,7 +2532,7 @@ export class ResourceModule { } export class ResourceDescription { - constructor(key, exportedValue, resourceTypeMeta){ + constructor(key:string, exportedValue:any, resourceTypeMeta:Object){ if(!resourceTypeMeta){ resourceTypeMeta = Metadata.get(Metadata.resource, exportedValue); @@ -2562,7 +2562,7 @@ export class ResourceDescription { this.value = exportedValue; } - analyze(container){ + analyze(container:Container){ let metadata = this.metadata, value = this.value; @@ -2571,11 +2571,11 @@ export class ResourceDescription { } } - register(registry, name){ + register(registry:ResourceRegistry, name?:string){ this.metadata.register(registry, name); } - load(container, loadContext){ + load(container:Container, loadContext?:string[]):Promise|void{ let metadata = this.metadata, value = this.value; @@ -2584,7 +2584,7 @@ export class ResourceDescription { } } - static get(resource, key='custom-resource'){ + static get(resource:any, key?:string='custom-resource'):ResourceDescription{ var resourceTypeMeta = Metadata.get(Metadata.resource, resource), resourceDescription; @@ -2619,11 +2619,11 @@ export class ModuleAnalyzer { this.cache = {}; } - getAnalysis(moduleId){ + getAnalysis(moduleId:string):ResourceModule{ return this.cache[moduleId]; } - analyze(moduleId, moduleInstance, viewModelMember){ + analyze(moduleId:string, moduleInstance:any, viewModelMember?:string):ResourceModule{ var mainResource, fallbackValue, fallbackKey, resourceTypeMeta, key, exportedValue, resources = [], conventional, viewStrategy, resourceModule; diff --git a/dist/index.d.ts b/dist/index.d.ts index 83a558a7..85ad24c7 100644 --- a/dist/index.d.ts +++ b/dist/index.d.ts @@ -2,9 +2,9 @@ declare module 'aurelia-templating' { import core from 'core-js'; import { Metadata, Origin, Decorators } from 'aurelia-metadata'; import { relativeToFile } from 'aurelia-path'; + import { TemplateRegistryEntry, Loader } from 'aurelia-loader'; import { Container } from 'aurelia-dependency-injection'; - import { Loader, TemplateRegistryEntry } from 'aurelia-loader'; - import { bindingMode, ObserverLocator, ValueConverterResource, EventManager } from 'aurelia-binding'; + import { bindingMode, ObserverLocator, BindingExpression, Binding, ValueConverterResource, EventManager } from 'aurelia-binding'; import { TaskQueue } from 'aurelia-task-queue'; import * as LogManager from 'aurelia-logging'; export const animationEvent: any; @@ -92,27 +92,27 @@ declare module 'aurelia-templating' { export function hyphenate(name: any): any; export function nextElementSibling(element: any): any; export class ViewStrategy { - static metadataKey: any; - makeRelativeTo(baseUrl: any): any; - static normalize(value: any): any; - static getDefault(target: any): any; + static metadataKey: string; + makeRelativeTo(baseUrl: string): any; + static normalize(value: string | ViewStrategy): any; + static getDefault(target: any): ViewStrategy; } export class UseViewStrategy extends ViewStrategy { - constructor(path: any); - loadViewFactory(viewEngine: any, options: any, loadContext: any): any; - makeRelativeTo(file: any): any; + constructor(path: string); + loadViewFactory(viewEngine: ViewEngine, options: Object, loadContext?: string[]): Promise; + makeRelativeTo(file: string): any; } export class ConventionalViewStrategy extends ViewStrategy { - constructor(moduleId: any); - loadViewFactory(viewEngine: any, options: any, loadContext: any): any; - static convertModuleIdToViewUrl(moduleId: any): any; + constructor(moduleId: string); + loadViewFactory(viewEngine: ViewEngine, options: Object, loadContext?: string[]): Promise; + static convertModuleIdToViewUrl(moduleId: string): string; } export class NoViewStrategy extends ViewStrategy { - loadViewFactory(): any; + loadViewFactory(viewEngine: ViewEngine, options: Object, loadContext?: string[]): Promise; } export class TemplateRegistryViewStrategy extends ViewStrategy { - constructor(moduleId: any, registryEntry: any); - loadViewFactory(viewEngine: any, options: any, loadContext: any): any; + constructor(moduleId: string, registryEntry: TemplateRegistryEntry); + loadViewFactory(viewEngine: ViewEngine, options: Object, loadContext?: string[]): Promise; } export class BindingLanguage { inspectAttribute(resources: any, attrName: any, attrValue: any): any; @@ -202,11 +202,11 @@ declare module 'aurelia-templating' { } export class ViewEngine { static inject(): any; - constructor(loader: any, container: any, viewCompiler: any, moduleAnalyzer: any, appResources: any); - loadViewFactory(urlOrRegistryEntry: any, compileOptions: any, associatedModuleId: any, loadContext: any): any; - loadTemplateResources(viewRegistryEntry: any, associatedModuleId: any, loadContext: any): any; - importViewModelResource(moduleImport: any, moduleMember: any): any; - importViewResources(moduleIds: any, names: any, resources: any, associatedModuleId: any, loadContext: any): any; + constructor(loader: Loader, container: Container, viewCompiler: ViewCompiler, moduleAnalyzer: ModuleAnalyzer, appResources: ResourceRegistry); + loadViewFactory(urlOrRegistryEntry: string | TemplateRegistryEntry, compileOptions?: Object, associatedModuleId?: string, loadContext?: string[]): Promise; + loadTemplateResources(viewRegistryEntry: TemplateRegistryEntry, associatedModuleId?: string, loadContext?: string[]): Promise; + importViewModelResource(moduleImport: string, moduleMember: string): Promise; + importViewResources(moduleIds: string[], names: string[], resources: ResourceRegistry, associatedModuleId?: string, loadContext?: string[]): Promise; } export class BehaviorInstance { constructor(behavior: any, executionContext: any, instruction: any); @@ -235,32 +235,32 @@ declare module 'aurelia-templating' { } export class HtmlBehaviorResource { constructor(); - static convention(name: any, existing: any): any; - addChildBinding(behavior: any): any; - analyze(container: any, target: any): any; - load(container: any, target: any, viewStrategy: any, transientView: any, loadContext: any): any; - register(registry: any, name: any): any; - compile(compiler: any, resources: any, node: any, instruction: any, parentNode: any): any; - create(container: any, instruction?: any, element?: any, bindings?: any): any; - ensurePropertiesDefined(instance: any, lookup: any): any; + static convention(name: string, existing?: HtmlBehaviorResource): any; + addChildBinding(behavior: BindingExpression): any; + analyze(container: Container, target: Function): any; + load(container: Container, target: Function, viewStrategy?: ViewStrategy, transientView?: boolean, loadContext?: string[]): Promise; + register(registry: ResourceRegistry, name?: string): any; + compile(compiler: ViewCompiler, resources: ResourceRegistry, node?: Node, instruction?: Object, parentNode?: Node): Node; + create(container: Container, instruction?: Object, element?: Element, bindings?: Binding[]): BehaviorInstance; + ensurePropertiesDefined(instance: Object, lookup: Object): any; } export class ResourceModule { - constructor(moduleId: any); - analyze(container: any): any; - register(registry: any, name: any): any; - load(container: any, loadContext: any): any; + constructor(moduleId: string); + analyze(container: Container): any; + register(registry: ResourceRegistry, name?: string): any; + load(container: Container, loadContext?: string[]): Promise; } export class ResourceDescription { - constructor(key: any, exportedValue: any, resourceTypeMeta: any); - analyze(container: any): any; - register(registry: any, name: any): any; - load(container: any, loadContext: any): any; - static get(resource: any, key?: any): any; + constructor(key: string, exportedValue: any, resourceTypeMeta: Object); + analyze(container: Container): any; + register(registry: ResourceRegistry, name?: string): any; + load(container: Container, loadContext?: string[]): Promise | void; + static get(resource: any, key?: string): ResourceDescription; } export class ModuleAnalyzer { constructor(); - getAnalysis(moduleId: any): any; - analyze(moduleId: any, moduleInstance: any, viewModelMember: any): any; + getAnalysis(moduleId: string): ResourceModule; + analyze(moduleId: string, moduleInstance: any, viewModelMember?: string): ResourceModule; } export class ChildObserver { constructor(config: any); diff --git a/dist/index.js b/dist/index.js index 849b1634..a423bac5 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1,9 +1,9 @@ import core from 'core-js'; import {Metadata,Origin,Decorators} from 'aurelia-metadata'; import {relativeToFile} from 'aurelia-path'; +import {TemplateRegistryEntry,Loader} from 'aurelia-loader'; import {Container} from 'aurelia-dependency-injection'; -import {Loader,TemplateRegistryEntry} from 'aurelia-loader'; -import {bindingMode,ObserverLocator,ValueConverterResource,EventManager} from 'aurelia-binding'; +import {bindingMode,ObserverLocator,BindingExpression,Binding,ValueConverterResource,EventManager} from 'aurelia-binding'; import {TaskQueue} from 'aurelia-task-queue'; export const animationEvent = { @@ -153,11 +153,11 @@ export function nextElementSibling(element) { } export class ViewStrategy { - static metadataKey = 'aurelia:view-strategy'; + static metadataKey:string = 'aurelia:view-strategy'; - makeRelativeTo(baseUrl){} + makeRelativeTo(baseUrl:string){} - static normalize(value){ + static normalize(value:string|ViewStrategy){ if(typeof value === 'string'){ value = new UseViewStrategy(value); } @@ -169,7 +169,7 @@ export class ViewStrategy { return value; } - static getDefault(target){ + static getDefault(target:any):ViewStrategy{ var strategy, annotation; if(typeof target !== 'function'){ @@ -194,12 +194,12 @@ export class ViewStrategy { } export class UseViewStrategy extends ViewStrategy { - constructor(path){ + constructor(path:string){ super(); this.path = path; } - loadViewFactory(viewEngine, options, loadContext){ + loadViewFactory(viewEngine:ViewEngine, options:Object, loadContext?:string[]):Promise{ if(!this.absolutePath && this.moduleId){ this.absolutePath = relativeToFile(this.path, this.moduleId); } @@ -207,42 +207,42 @@ export class UseViewStrategy extends ViewStrategy { return viewEngine.loadViewFactory(this.absolutePath || this.path, options, this.moduleId, loadContext); } - makeRelativeTo(file){ + makeRelativeTo(file:string){ this.absolutePath = relativeToFile(this.path, file); } } export class ConventionalViewStrategy extends ViewStrategy { - constructor(moduleId){ + constructor(moduleId:string){ super(); this.moduleId = moduleId; this.viewUrl = ConventionalViewStrategy.convertModuleIdToViewUrl(moduleId); } - loadViewFactory(viewEngine, options, loadContext){ + loadViewFactory(viewEngine:ViewEngine, options:Object, loadContext?:string[]):Promise{ return viewEngine.loadViewFactory(this.viewUrl, options, this.moduleId, loadContext); } - static convertModuleIdToViewUrl(moduleId){ + static convertModuleIdToViewUrl(moduleId:string):string{ var id = (moduleId.endsWith('.js') || moduleId.endsWith('.ts')) ? moduleId.substring(0, moduleId.length - 3) : moduleId; return id + '.html'; } } export class NoViewStrategy extends ViewStrategy { - loadViewFactory(){ + loadViewFactory(viewEngine:ViewEngine, options:Object, loadContext?:string[]):Promise{ return Promise.resolve(null); } } export class TemplateRegistryViewStrategy extends ViewStrategy { - constructor(moduleId, registryEntry){ + constructor(moduleId:string, registryEntry:TemplateRegistryEntry){ super(); this.moduleId = moduleId; this.registryEntry = registryEntry; } - loadViewFactory(viewEngine, options, loadContext){ + loadViewFactory(viewEngine:ViewEngine, options:Object, loadContext?:string[]):Promise{ if(this.registryEntry.isReady){ return Promise.resolve(this.registryEntry.factory); } @@ -1656,7 +1656,7 @@ class ProxyViewFactory { export class ViewEngine { static inject() { return [Loader, Container, ViewCompiler, ModuleAnalyzer, ResourceRegistry]; } - constructor(loader, container, viewCompiler, moduleAnalyzer, appResources){ + constructor(loader:Loader, container:Container, viewCompiler:ViewCompiler, moduleAnalyzer:ModuleAnalyzer, appResources:ResourceRegistry){ this.loader = loader; this.container = container; this.viewCompiler = viewCompiler; @@ -1664,7 +1664,7 @@ export class ViewEngine { this.appResources = appResources; } - loadViewFactory(urlOrRegistryEntry, compileOptions, associatedModuleId, loadContext){ + loadViewFactory(urlOrRegistryEntry:string|TemplateRegistryEntry, compileOptions?:Object, associatedModuleId?:string, loadContext?:string[]):Promise{ loadContext = loadContext || []; return ensureRegistryEntry(this.loader, urlOrRegistryEntry).then(viewRegistryEntry => { @@ -1688,7 +1688,7 @@ export class ViewEngine { }); } - loadTemplateResources(viewRegistryEntry, associatedModuleId, loadContext){ + loadTemplateResources(viewRegistryEntry:TemplateRegistryEntry, associatedModuleId?:string, loadContext?:string[]):Promise{ var resources = new ViewResources(this.appResources, viewRegistryEntry.id), dependencies = viewRegistryEntry.dependencies, importIds, names; @@ -1704,7 +1704,7 @@ export class ViewEngine { return this.importViewResources(importIds, names, resources, associatedModuleId, loadContext); } - importViewModelResource(moduleImport, moduleMember){ + importViewModelResource(moduleImport:string, moduleMember:string):Promise{ return this.loader.loadModule(moduleImport).then(viewModelModule => { var normalizedId = Origin.get(viewModelModule).moduleId, resourceModule = this.moduleAnalyzer.analyze(normalizedId, viewModelModule, moduleMember); @@ -1719,7 +1719,7 @@ export class ViewEngine { }); } - importViewResources(moduleIds, names, resources, associatedModuleId, loadContext){ + importViewResources(moduleIds:string[], names:string[], resources:ResourceRegistry, associatedModuleId?:string, loadContext?:string[]):Promise{ loadContext = loadContext || []; return this.loader.loadAllModules(moduleIds).then(imports => { @@ -2158,7 +2158,7 @@ export class HtmlBehaviorResource { this.attributes = {}; } - static convention(name, existing){ + static convention(name:string, existing?:HtmlBehaviorResource){ var behavior; if(name.endsWith('CustomAttribute')){ @@ -2174,7 +2174,7 @@ export class HtmlBehaviorResource { return behavior; } - addChildBinding(behavior){ + addChildBinding(behavior:BindingExpression){ if(this.childBindings === null){ this.childBindings = []; } @@ -2182,7 +2182,7 @@ export class HtmlBehaviorResource { this.childBindings.push(behavior); } - analyze(container, target){ + analyze(container:Container, target:Function){ var proto = target.prototype, properties = this.properties, attributeName = this.attributeName, @@ -2239,7 +2239,7 @@ export class HtmlBehaviorResource { } } - load(container, target, viewStrategy, transientView, loadContext){ + load(container:Container, target:Function, viewStrategy?:ViewStrategy, transientView?:boolean, loadContext?:string[]):Promise{ var options; if(this.elementName !== null){ @@ -2265,7 +2265,7 @@ export class HtmlBehaviorResource { return Promise.resolve(this); } - register(registry, name){ + register(registry:ResourceRegistry, name?:string){ if(this.attributeName !== null) { registry.registerAttribute(name || this.attributeName, this, this.attributeName); } @@ -2275,7 +2275,7 @@ export class HtmlBehaviorResource { } } - compile(compiler, resources, node, instruction, parentNode){ + compile(compiler:ViewCompiler, resources:ResourceRegistry, node?:Node, instruction?:Object, parentNode?:Node):Node{ if(this.liftsContent){ if(!instruction.viewFactory){ var template = document.createElement('template'), @@ -2349,7 +2349,7 @@ export class HtmlBehaviorResource { return node; } - create(container, instruction=defaultInstruction, element=null, bindings=null){ + create(container:Container, instruction?:Object=defaultInstruction, element?:Element=null, bindings?:Binding[]=null):BehaviorInstance{ var executionContext = instruction.executionContext || container.get(this.target), behaviorInstance = new BehaviorInstance(this, executionContext, instruction), childBindings = this.childBindings, @@ -2441,7 +2441,7 @@ export class HtmlBehaviorResource { return behaviorInstance; } - ensurePropertiesDefined(instance, lookup){ + ensurePropertiesDefined(instance:Object, lookup:Object){ var properties, i, ii, observer; if('__propertiesDefined__' in lookup){ @@ -2462,7 +2462,7 @@ export class HtmlBehaviorResource { } export class ResourceModule { - constructor(moduleId){ + constructor(moduleId:string){ this.id = moduleId; this.moduleInstance = null; this.mainResource = null; @@ -2471,7 +2471,7 @@ export class ResourceModule { this.isAnalyzed = false; } - analyze(container){ + analyze(container:Container){ var current = this.mainResource, resources = this.resources, viewStrategy = this.viewStrategy, @@ -2495,7 +2495,7 @@ export class ResourceModule { } } - register(registry, name){ + register(registry:ResourceRegistry, name?:string){ var i, ii, resources = this.resources; if(this.mainResource){ @@ -2509,7 +2509,7 @@ export class ResourceModule { } } - load(container, loadContext){ + load(container:Container, loadContext?:string[]):Promise{ if(this.onLoaded){ return this.onLoaded; } @@ -2532,7 +2532,7 @@ export class ResourceModule { } export class ResourceDescription { - constructor(key, exportedValue, resourceTypeMeta){ + constructor(key:string, exportedValue:any, resourceTypeMeta:Object){ if(!resourceTypeMeta){ resourceTypeMeta = Metadata.get(Metadata.resource, exportedValue); @@ -2562,7 +2562,7 @@ export class ResourceDescription { this.value = exportedValue; } - analyze(container){ + analyze(container:Container){ let metadata = this.metadata, value = this.value; @@ -2571,11 +2571,11 @@ export class ResourceDescription { } } - register(registry, name){ + register(registry:ResourceRegistry, name?:string){ this.metadata.register(registry, name); } - load(container, loadContext){ + load(container:Container, loadContext?:string[]):Promise|void{ let metadata = this.metadata, value = this.value; @@ -2584,7 +2584,7 @@ export class ResourceDescription { } } - static get(resource, key='custom-resource'){ + static get(resource:any, key?:string='custom-resource'):ResourceDescription{ var resourceTypeMeta = Metadata.get(Metadata.resource, resource), resourceDescription; @@ -2619,11 +2619,11 @@ export class ModuleAnalyzer { this.cache = {}; } - getAnalysis(moduleId){ + getAnalysis(moduleId:string):ResourceModule{ return this.cache[moduleId]; } - analyze(moduleId, moduleInstance, viewModelMember){ + analyze(moduleId:string, moduleInstance:any, viewModelMember?:string):ResourceModule{ var mainResource, fallbackValue, fallbackKey, resourceTypeMeta, key, exportedValue, resources = [], conventional, viewStrategy, resourceModule; diff --git a/dist/system/aurelia-templating.d.ts b/dist/system/aurelia-templating.d.ts index 83a558a7..85ad24c7 100644 --- a/dist/system/aurelia-templating.d.ts +++ b/dist/system/aurelia-templating.d.ts @@ -2,9 +2,9 @@ declare module 'aurelia-templating' { import core from 'core-js'; import { Metadata, Origin, Decorators } from 'aurelia-metadata'; import { relativeToFile } from 'aurelia-path'; + import { TemplateRegistryEntry, Loader } from 'aurelia-loader'; import { Container } from 'aurelia-dependency-injection'; - import { Loader, TemplateRegistryEntry } from 'aurelia-loader'; - import { bindingMode, ObserverLocator, ValueConverterResource, EventManager } from 'aurelia-binding'; + import { bindingMode, ObserverLocator, BindingExpression, Binding, ValueConverterResource, EventManager } from 'aurelia-binding'; import { TaskQueue } from 'aurelia-task-queue'; import * as LogManager from 'aurelia-logging'; export const animationEvent: any; @@ -92,27 +92,27 @@ declare module 'aurelia-templating' { export function hyphenate(name: any): any; export function nextElementSibling(element: any): any; export class ViewStrategy { - static metadataKey: any; - makeRelativeTo(baseUrl: any): any; - static normalize(value: any): any; - static getDefault(target: any): any; + static metadataKey: string; + makeRelativeTo(baseUrl: string): any; + static normalize(value: string | ViewStrategy): any; + static getDefault(target: any): ViewStrategy; } export class UseViewStrategy extends ViewStrategy { - constructor(path: any); - loadViewFactory(viewEngine: any, options: any, loadContext: any): any; - makeRelativeTo(file: any): any; + constructor(path: string); + loadViewFactory(viewEngine: ViewEngine, options: Object, loadContext?: string[]): Promise; + makeRelativeTo(file: string): any; } export class ConventionalViewStrategy extends ViewStrategy { - constructor(moduleId: any); - loadViewFactory(viewEngine: any, options: any, loadContext: any): any; - static convertModuleIdToViewUrl(moduleId: any): any; + constructor(moduleId: string); + loadViewFactory(viewEngine: ViewEngine, options: Object, loadContext?: string[]): Promise; + static convertModuleIdToViewUrl(moduleId: string): string; } export class NoViewStrategy extends ViewStrategy { - loadViewFactory(): any; + loadViewFactory(viewEngine: ViewEngine, options: Object, loadContext?: string[]): Promise; } export class TemplateRegistryViewStrategy extends ViewStrategy { - constructor(moduleId: any, registryEntry: any); - loadViewFactory(viewEngine: any, options: any, loadContext: any): any; + constructor(moduleId: string, registryEntry: TemplateRegistryEntry); + loadViewFactory(viewEngine: ViewEngine, options: Object, loadContext?: string[]): Promise; } export class BindingLanguage { inspectAttribute(resources: any, attrName: any, attrValue: any): any; @@ -202,11 +202,11 @@ declare module 'aurelia-templating' { } export class ViewEngine { static inject(): any; - constructor(loader: any, container: any, viewCompiler: any, moduleAnalyzer: any, appResources: any); - loadViewFactory(urlOrRegistryEntry: any, compileOptions: any, associatedModuleId: any, loadContext: any): any; - loadTemplateResources(viewRegistryEntry: any, associatedModuleId: any, loadContext: any): any; - importViewModelResource(moduleImport: any, moduleMember: any): any; - importViewResources(moduleIds: any, names: any, resources: any, associatedModuleId: any, loadContext: any): any; + constructor(loader: Loader, container: Container, viewCompiler: ViewCompiler, moduleAnalyzer: ModuleAnalyzer, appResources: ResourceRegistry); + loadViewFactory(urlOrRegistryEntry: string | TemplateRegistryEntry, compileOptions?: Object, associatedModuleId?: string, loadContext?: string[]): Promise; + loadTemplateResources(viewRegistryEntry: TemplateRegistryEntry, associatedModuleId?: string, loadContext?: string[]): Promise; + importViewModelResource(moduleImport: string, moduleMember: string): Promise; + importViewResources(moduleIds: string[], names: string[], resources: ResourceRegistry, associatedModuleId?: string, loadContext?: string[]): Promise; } export class BehaviorInstance { constructor(behavior: any, executionContext: any, instruction: any); @@ -235,32 +235,32 @@ declare module 'aurelia-templating' { } export class HtmlBehaviorResource { constructor(); - static convention(name: any, existing: any): any; - addChildBinding(behavior: any): any; - analyze(container: any, target: any): any; - load(container: any, target: any, viewStrategy: any, transientView: any, loadContext: any): any; - register(registry: any, name: any): any; - compile(compiler: any, resources: any, node: any, instruction: any, parentNode: any): any; - create(container: any, instruction?: any, element?: any, bindings?: any): any; - ensurePropertiesDefined(instance: any, lookup: any): any; + static convention(name: string, existing?: HtmlBehaviorResource): any; + addChildBinding(behavior: BindingExpression): any; + analyze(container: Container, target: Function): any; + load(container: Container, target: Function, viewStrategy?: ViewStrategy, transientView?: boolean, loadContext?: string[]): Promise; + register(registry: ResourceRegistry, name?: string): any; + compile(compiler: ViewCompiler, resources: ResourceRegistry, node?: Node, instruction?: Object, parentNode?: Node): Node; + create(container: Container, instruction?: Object, element?: Element, bindings?: Binding[]): BehaviorInstance; + ensurePropertiesDefined(instance: Object, lookup: Object): any; } export class ResourceModule { - constructor(moduleId: any); - analyze(container: any): any; - register(registry: any, name: any): any; - load(container: any, loadContext: any): any; + constructor(moduleId: string); + analyze(container: Container): any; + register(registry: ResourceRegistry, name?: string): any; + load(container: Container, loadContext?: string[]): Promise; } export class ResourceDescription { - constructor(key: any, exportedValue: any, resourceTypeMeta: any); - analyze(container: any): any; - register(registry: any, name: any): any; - load(container: any, loadContext: any): any; - static get(resource: any, key?: any): any; + constructor(key: string, exportedValue: any, resourceTypeMeta: Object); + analyze(container: Container): any; + register(registry: ResourceRegistry, name?: string): any; + load(container: Container, loadContext?: string[]): Promise | void; + static get(resource: any, key?: string): ResourceDescription; } export class ModuleAnalyzer { constructor(); - getAnalysis(moduleId: any): any; - analyze(moduleId: any, moduleInstance: any, viewModelMember: any): any; + getAnalysis(moduleId: string): ResourceModule; + analyze(moduleId: string, moduleInstance: any, viewModelMember?: string): ResourceModule; } export class ChildObserver { constructor(config: any); diff --git a/dist/system/index.js b/dist/system/index.js index 8c80d856..12663c7a 100644 --- a/dist/system/index.js +++ b/dist/system/index.js @@ -1,7 +1,7 @@ -System.register(['core-js', 'aurelia-metadata', 'aurelia-path', 'aurelia-dependency-injection', 'aurelia-loader', 'aurelia-binding', 'aurelia-task-queue', 'aurelia-logging'], function (_export) { +System.register(['core-js', 'aurelia-metadata', 'aurelia-path', 'aurelia-loader', 'aurelia-dependency-injection', 'aurelia-binding', 'aurelia-task-queue', 'aurelia-logging'], function (_export) { 'use strict'; - var core, Metadata, Origin, Decorators, relativeToFile, Container, Loader, TemplateRegistryEntry, bindingMode, ObserverLocator, ValueConverterResource, EventManager, TaskQueue, LogManager, animationEvent, Animator, capitalMatcher, ViewStrategy, UseViewStrategy, ConventionalViewStrategy, NoViewStrategy, TemplateRegistryViewStrategy, BindingLanguage, ResourceRegistry, ViewResources, View, proto, placeholder, ContentSelector, ViewSlot, BoundViewFactory, defaultFactoryOptions, ViewFactory, nextInjectorId, defaultCompileOptions, hasShadowDOM, needsTemplateFixup, ViewCompiler, logger, ProxyViewFactory, ViewEngine, BehaviorInstance, BindableProperty, BehaviorPropertyObserver, defaultInstruction, contentSelectorFactoryOptions, hasShadowDOM, HtmlBehaviorResource, ResourceModule, ResourceDescription, ModuleAnalyzer, noMutations, ChildObserver, ChildObserverBinder, CompositionEngine, ElementConfigResource; + var core, Metadata, Origin, Decorators, relativeToFile, TemplateRegistryEntry, Loader, Container, bindingMode, ObserverLocator, BindingExpression, Binding, ValueConverterResource, EventManager, TaskQueue, LogManager, animationEvent, Animator, capitalMatcher, ViewStrategy, UseViewStrategy, ConventionalViewStrategy, NoViewStrategy, TemplateRegistryViewStrategy, BindingLanguage, ResourceRegistry, ViewResources, View, proto, placeholder, ContentSelector, ViewSlot, BoundViewFactory, defaultFactoryOptions, ViewFactory, nextInjectorId, defaultCompileOptions, hasShadowDOM, needsTemplateFixup, ViewCompiler, logger, ProxyViewFactory, ViewEngine, BehaviorInstance, BindableProperty, BehaviorPropertyObserver, defaultInstruction, contentSelectorFactoryOptions, hasShadowDOM, HtmlBehaviorResource, ResourceModule, ResourceDescription, ModuleAnalyzer, noMutations, ChildObserver, ChildObserverBinder, CompositionEngine, ElementConfigResource; var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); @@ -515,14 +515,16 @@ System.register(['core-js', 'aurelia-metadata', 'aurelia-path', 'aurelia-depende Decorators = _aureliaMetadata.Decorators; }, function (_aureliaPath) { relativeToFile = _aureliaPath.relativeToFile; - }, function (_aureliaDependencyInjection) { - Container = _aureliaDependencyInjection.Container; }, function (_aureliaLoader) { - Loader = _aureliaLoader.Loader; TemplateRegistryEntry = _aureliaLoader.TemplateRegistryEntry; + Loader = _aureliaLoader.Loader; + }, function (_aureliaDependencyInjection) { + Container = _aureliaDependencyInjection.Container; }, function (_aureliaBinding) { bindingMode = _aureliaBinding.bindingMode; ObserverLocator = _aureliaBinding.ObserverLocator; + BindingExpression = _aureliaBinding.BindingExpression; + Binding = _aureliaBinding.Binding; ValueConverterResource = _aureliaBinding.ValueConverterResource; EventManager = _aureliaBinding.EventManager; }, function (_aureliaTaskQueue) { @@ -725,7 +727,7 @@ System.register(['core-js', 'aurelia-metadata', 'aurelia-path', 'aurelia-depende _inherits(NoViewStrategy, _ViewStrategy3); - NoViewStrategy.prototype.loadViewFactory = function loadViewFactory() { + NoViewStrategy.prototype.loadViewFactory = function loadViewFactory(viewEngine, options, loadContext) { return Promise.resolve(null); }; diff --git a/src/html-behavior.js b/src/html-behavior.js index c5e10210..46d983ca 100644 --- a/src/html-behavior.js +++ b/src/html-behavior.js @@ -1,12 +1,15 @@ import {Origin} from 'aurelia-metadata'; -import {ObserverLocator} from 'aurelia-binding'; +import {ObserverLocator, BindingExpression, Binding} from 'aurelia-binding'; import {TaskQueue} from 'aurelia-task-queue'; +import {Container} from 'aurelia-dependency-injection'; import {ViewStrategy} from './view-strategy'; import {ViewEngine} from './view-engine'; +import {ViewCompiler} from './view-compiler'; import {ContentSelector} from './content-selector'; import {hyphenate} from './util'; import {BindableProperty} from './bindable-property'; import {BehaviorInstance} from './behavior-instance'; +import {ResourceRegistry} from './resource-registry'; var defaultInstruction = { suppressBind:false }, contentSelectorFactoryOptions = { suppressBind:true }, @@ -28,7 +31,7 @@ export class HtmlBehaviorResource { this.attributes = {}; } - static convention(name, existing){ + static convention(name:string, existing?:HtmlBehaviorResource){ var behavior; if(name.endsWith('CustomAttribute')){ @@ -44,7 +47,7 @@ export class HtmlBehaviorResource { return behavior; } - addChildBinding(behavior){ + addChildBinding(behavior:BindingExpression){ if(this.childBindings === null){ this.childBindings = []; } @@ -52,7 +55,7 @@ export class HtmlBehaviorResource { this.childBindings.push(behavior); } - analyze(container, target){ + analyze(container:Container, target:Function){ var proto = target.prototype, properties = this.properties, attributeName = this.attributeName, @@ -109,7 +112,7 @@ export class HtmlBehaviorResource { } } - load(container, target, viewStrategy, transientView, loadContext){ + load(container:Container, target:Function, viewStrategy?:ViewStrategy, transientView?:boolean, loadContext?:string[]):Promise{ var options; if(this.elementName !== null){ @@ -135,7 +138,7 @@ export class HtmlBehaviorResource { return Promise.resolve(this); } - register(registry, name){ + register(registry:ResourceRegistry, name?:string){ if(this.attributeName !== null) { registry.registerAttribute(name || this.attributeName, this, this.attributeName); } @@ -145,7 +148,7 @@ export class HtmlBehaviorResource { } } - compile(compiler, resources, node, instruction, parentNode){ + compile(compiler:ViewCompiler, resources:ResourceRegistry, node?:Node, instruction?:Object, parentNode?:Node):Node{ if(this.liftsContent){ if(!instruction.viewFactory){ var template = document.createElement('template'), @@ -219,7 +222,7 @@ export class HtmlBehaviorResource { return node; } - create(container, instruction=defaultInstruction, element=null, bindings=null){ + create(container:Container, instruction?:Object=defaultInstruction, element?:Element=null, bindings?:Binding[]=null):BehaviorInstance{ var executionContext = instruction.executionContext || container.get(this.target), behaviorInstance = new BehaviorInstance(this, executionContext, instruction), childBindings = this.childBindings, @@ -311,7 +314,7 @@ export class HtmlBehaviorResource { return behaviorInstance; } - ensurePropertiesDefined(instance, lookup){ + ensurePropertiesDefined(instance:Object, lookup:Object){ var properties, i, ii, observer; if('__propertiesDefined__' in lookup){ diff --git a/src/module-analyzer.js b/src/module-analyzer.js index 3e610700..237d2af3 100644 --- a/src/module-analyzer.js +++ b/src/module-analyzer.js @@ -1,12 +1,14 @@ import {Metadata} from 'aurelia-metadata'; +import {Container} from 'aurelia-dependency-injection'; import {TemplateRegistryEntry} from 'aurelia-loader'; import {ValueConverterResource} from 'aurelia-binding'; import {HtmlBehaviorResource} from './html-behavior'; import {ViewStrategy,TemplateRegistryViewStrategy} from './view-strategy'; +import {ResourceRegistry} from './resource-registry'; import {hyphenate} from './util'; export class ResourceModule { - constructor(moduleId){ + constructor(moduleId:string){ this.id = moduleId; this.moduleInstance = null; this.mainResource = null; @@ -15,7 +17,7 @@ export class ResourceModule { this.isAnalyzed = false; } - analyze(container){ + analyze(container:Container){ var current = this.mainResource, resources = this.resources, viewStrategy = this.viewStrategy, @@ -39,7 +41,7 @@ export class ResourceModule { } } - register(registry, name){ + register(registry:ResourceRegistry, name?:string){ var i, ii, resources = this.resources; if(this.mainResource){ @@ -53,7 +55,7 @@ export class ResourceModule { } } - load(container, loadContext){ + load(container:Container, loadContext?:string[]):Promise{ if(this.onLoaded){ return this.onLoaded; } @@ -76,7 +78,7 @@ export class ResourceModule { } export class ResourceDescription { - constructor(key, exportedValue, resourceTypeMeta){ + constructor(key:string, exportedValue:any, resourceTypeMeta:Object){ if(!resourceTypeMeta){ resourceTypeMeta = Metadata.get(Metadata.resource, exportedValue); @@ -106,7 +108,7 @@ export class ResourceDescription { this.value = exportedValue; } - analyze(container){ + analyze(container:Container){ let metadata = this.metadata, value = this.value; @@ -115,11 +117,11 @@ export class ResourceDescription { } } - register(registry, name){ + register(registry:ResourceRegistry, name?:string){ this.metadata.register(registry, name); } - load(container, loadContext){ + load(container:Container, loadContext?:string[]):Promise|void{ let metadata = this.metadata, value = this.value; @@ -128,7 +130,7 @@ export class ResourceDescription { } } - static get(resource, key='custom-resource'){ + static get(resource:any, key?:string='custom-resource'):ResourceDescription{ var resourceTypeMeta = Metadata.get(Metadata.resource, resource), resourceDescription; @@ -163,11 +165,11 @@ export class ModuleAnalyzer { this.cache = {}; } - getAnalysis(moduleId){ + getAnalysis(moduleId:string):ResourceModule{ return this.cache[moduleId]; } - analyze(moduleId, moduleInstance, viewModelMember){ + analyze(moduleId:string, moduleInstance:any, viewModelMember?:string):ResourceModule{ var mainResource, fallbackValue, fallbackKey, resourceTypeMeta, key, exportedValue, resources = [], conventional, viewStrategy, resourceModule; diff --git a/src/view-engine.js b/src/view-engine.js index 74cb64be..9404b4f0 100644 --- a/src/view-engine.js +++ b/src/view-engine.js @@ -5,7 +5,8 @@ import {Loader,TemplateRegistryEntry} from 'aurelia-loader'; import {Container} from 'aurelia-dependency-injection'; import {ViewCompiler} from './view-compiler'; import {ResourceRegistry, ViewResources} from './resource-registry'; -import {ModuleAnalyzer} from './module-analyzer'; +import {ModuleAnalyzer, ResourceDescription} from './module-analyzer'; +import {ViewFactory} from './view-factory'; var logger = LogManager.getLogger('templating'); @@ -29,7 +30,7 @@ class ProxyViewFactory { export class ViewEngine { static inject() { return [Loader, Container, ViewCompiler, ModuleAnalyzer, ResourceRegistry]; } - constructor(loader, container, viewCompiler, moduleAnalyzer, appResources){ + constructor(loader:Loader, container:Container, viewCompiler:ViewCompiler, moduleAnalyzer:ModuleAnalyzer, appResources:ResourceRegistry){ this.loader = loader; this.container = container; this.viewCompiler = viewCompiler; @@ -37,7 +38,7 @@ export class ViewEngine { this.appResources = appResources; } - loadViewFactory(urlOrRegistryEntry, compileOptions, associatedModuleId, loadContext){ + loadViewFactory(urlOrRegistryEntry:string|TemplateRegistryEntry, compileOptions?:Object, associatedModuleId?:string, loadContext?:string[]):Promise{ loadContext = loadContext || []; return ensureRegistryEntry(this.loader, urlOrRegistryEntry).then(viewRegistryEntry => { @@ -61,7 +62,7 @@ export class ViewEngine { }); } - loadTemplateResources(viewRegistryEntry, associatedModuleId, loadContext){ + loadTemplateResources(viewRegistryEntry:TemplateRegistryEntry, associatedModuleId?:string, loadContext?:string[]):Promise{ var resources = new ViewResources(this.appResources, viewRegistryEntry.id), dependencies = viewRegistryEntry.dependencies, importIds, names; @@ -77,7 +78,7 @@ export class ViewEngine { return this.importViewResources(importIds, names, resources, associatedModuleId, loadContext); } - importViewModelResource(moduleImport, moduleMember){ + importViewModelResource(moduleImport:string, moduleMember:string):Promise{ return this.loader.loadModule(moduleImport).then(viewModelModule => { var normalizedId = Origin.get(viewModelModule).moduleId, resourceModule = this.moduleAnalyzer.analyze(normalizedId, viewModelModule, moduleMember); @@ -92,7 +93,7 @@ export class ViewEngine { }); } - importViewResources(moduleIds, names, resources, associatedModuleId, loadContext){ + importViewResources(moduleIds:string[], names:string[], resources:ResourceRegistry, associatedModuleId?:string, loadContext?:string[]):Promise{ loadContext = loadContext || []; return this.loader.loadAllModules(moduleIds).then(imports => { diff --git a/src/view-strategy.js b/src/view-strategy.js index 12eb0358..e20f378d 100644 --- a/src/view-strategy.js +++ b/src/view-strategy.js @@ -1,12 +1,14 @@ import {Metadata, Origin} from 'aurelia-metadata'; import {relativeToFile} from 'aurelia-path'; +import {TemplateRegistryEntry} from 'aurelia-loader'; +import {ViewEngine} from './view-engine'; export class ViewStrategy { - static metadataKey = 'aurelia:view-strategy'; + static metadataKey:string = 'aurelia:view-strategy'; - makeRelativeTo(baseUrl){} + makeRelativeTo(baseUrl:string){} - static normalize(value){ + static normalize(value:string|ViewStrategy){ if(typeof value === 'string'){ value = new UseViewStrategy(value); } @@ -18,7 +20,7 @@ export class ViewStrategy { return value; } - static getDefault(target){ + static getDefault(target:any):ViewStrategy{ var strategy, annotation; if(typeof target !== 'function'){ @@ -43,12 +45,12 @@ export class ViewStrategy { } export class UseViewStrategy extends ViewStrategy { - constructor(path){ + constructor(path:string){ super(); this.path = path; } - loadViewFactory(viewEngine, options, loadContext){ + loadViewFactory(viewEngine:ViewEngine, options:Object, loadContext?:string[]):Promise{ if(!this.absolutePath && this.moduleId){ this.absolutePath = relativeToFile(this.path, this.moduleId); } @@ -56,42 +58,42 @@ export class UseViewStrategy extends ViewStrategy { return viewEngine.loadViewFactory(this.absolutePath || this.path, options, this.moduleId, loadContext); } - makeRelativeTo(file){ + makeRelativeTo(file:string){ this.absolutePath = relativeToFile(this.path, file); } } export class ConventionalViewStrategy extends ViewStrategy { - constructor(moduleId){ + constructor(moduleId:string){ super(); this.moduleId = moduleId; this.viewUrl = ConventionalViewStrategy.convertModuleIdToViewUrl(moduleId); } - loadViewFactory(viewEngine, options, loadContext){ + loadViewFactory(viewEngine:ViewEngine, options:Object, loadContext?:string[]):Promise{ return viewEngine.loadViewFactory(this.viewUrl, options, this.moduleId, loadContext); } - static convertModuleIdToViewUrl(moduleId){ + static convertModuleIdToViewUrl(moduleId:string):string{ var id = (moduleId.endsWith('.js') || moduleId.endsWith('.ts')) ? moduleId.substring(0, moduleId.length - 3) : moduleId; return id + '.html'; } } export class NoViewStrategy extends ViewStrategy { - loadViewFactory(){ + loadViewFactory(viewEngine:ViewEngine, options:Object, loadContext?:string[]):Promise{ return Promise.resolve(null); } } export class TemplateRegistryViewStrategy extends ViewStrategy { - constructor(moduleId, registryEntry){ + constructor(moduleId:string, registryEntry:TemplateRegistryEntry){ super(); this.moduleId = moduleId; this.registryEntry = registryEntry; } - loadViewFactory(viewEngine, options, loadContext){ + loadViewFactory(viewEngine:ViewEngine, options:Object, loadContext?:string[]):Promise{ if(this.registryEntry.isReady){ return Promise.resolve(this.registryEntry.factory); }