Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
loadRoute(router, config) {
let childContainer = router.container.createChild();
let viewModel;
if (config.moduleId === null) {
viewModel = EmptyClass;
} else if (/\.html/i.test(config.moduleId)) {
viewModel = createDynamicClass(config.moduleId);
} else {
viewModel = relativeToFile(config.moduleId, Origin.get(router.container.viewModel.constructor).moduleId);
}
let instruction = {
viewModel: viewModel,
childContainer: childContainer,
view: config.view || config.viewStrategy,
router: router
};
childContainer.registerSingleton(RouterViewLocator);
childContainer.getChildRouter = function () {
let childRouter;
childContainer.registerHandler(Router, c => {
return childRouter || (childRouter = router.createChild(childContainer));
load(container, target, viewStrategy){
var annotation, options;
configureBehavior(this, container, target);
this.targetShadowDOM = getAnnotation(target, UseShadowDOM) !== null;
this.usesShadowDOM = this.targetShadowDOM && hasShadowDOM;
viewStrategy = viewStrategy || ViewStrategy.getDefault(target);
options = { targetShadowDOM:this.targetShadowDOM };
if(!viewStrategy.moduleId){
viewStrategy.moduleId = Origin.get(target).moduleId;
}
return viewStrategy.loadViewFactory(container.get(ViewEngine), options).then(viewFactory => {
this.viewFactory = viewFactory;
return this;
});
}
function _getViewModel(container, childContainer, compositionEngine, notificationController) {
let compositionContext = {
container: container,
childContainer: childContainer,
model: notificationController.settings.model,
viewModel: notificationController.settings.viewModel
};
if (typeof compositionContext.viewModel === 'function') {
compositionContext.viewModel = Origin.get(compositionContext.viewModel).moduleId;
}
if (typeof compositionContext.viewModel === 'string') {
return compositionEngine.ensureViewModel(compositionContext);
}
return Promise.resolve(compositionContext);
}
importResourcesFromModules(imports, importIds){
var loads = [], i, ii, analysis, type, key, annotation,
j, jj, resources, current,
existing = this.importedModules,
container = this.container,
allAnalysis = new Array(imports.length);
if(!importIds){
importIds = new Array(imports.length);
for(i = 0, ii = imports.length; i < ii; ++i){
current = imports[i];
for(key in current){
type = current[key];
annotation = Origin.get(type);
if(annotation){
importIds[i] = annotation.moduleId;
break;
}
}
}
}
for(i = 0, ii = imports.length; i < ii; ++i){
analysis = existing[importIds[i]];
if(analysis){
allAnalysis[i] = analysis;
continue;
}
private getViewModel(instruction) {
if (typeof instruction.viewModel === 'function') {
instruction.viewModel = Origin.get(instruction.viewModel).moduleId;
}
if (typeof instruction.viewModel === 'string') {
return this.compositionEngine.ensureViewModel(instruction);
}
return Promise.resolve(instruction);
}
load(container) {
const styleStrategy = container.get(StyleLocator)
.getStyleStrategy(this.styleObjectType);
if (!styleStrategy.moduleId) {
styleStrategy.moduleId = Origin.get(this.styleObjectType).moduleId;
}
return styleStrategy.loadStyleFactory(container, this.styleObjectType).then(styleFactory => {
this.factory = styleFactory;
this.hooks.factory = this.factory;
return this;
});
}
}
getViewStrategy(value: any): ViewStrategy {
if (!value) {
return null;
}
if (typeof value === 'object' && 'getViewStrategy' in value) {
let origin = Origin.get(value.constructor);
value = value.getViewStrategy();
if (typeof value === 'string') {
value = new RelativeViewStrategy(value);
}
viewStrategy.assert(value);
if (origin.moduleId) {
value.makeRelativeTo(origin.moduleId);
}
return value;
}
function _getViewModel(container, childContainer, compositionEngine, notificationController) {
let compositionContext = {
container: container,
childContainer: childContainer,
model: notificationController.settings.model,
viewModel: notificationController.settings.viewModel
};
if (typeof compositionContext.viewModel === 'function') {
compositionContext.viewModel = Origin.get(compositionContext.viewModel).moduleId;
}
if (typeof compositionContext.viewModel === 'string') {
return compositionEngine.ensureViewModel(compositionContext);
}
return Promise.resolve(compositionContext);
}