Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
isHelper(name) {
if (!hasValidHelperName(name)) {
return false;
}
return this.owner.application.hasRegistration('helper:' + name);
},
// for mu support components like src/components/tabs/tab
_scopedComponentNames(name, scope) {
const closestRelativeName = [].concat(this.muScopedComponents, this.currentRouteComponents())
.filter((resolvedName)=>resolvedName.endsWith(name)).pop();
// closestRelativeName can be undefined
if (!scope) {
return [closestRelativeName, name];
}
const normalizedContext = componentNameFromClassName(scope.constructor.name);
const candidate = normalizedContext + '/' + name;
const result = [];
if (typeof closestRelativeName === 'string') {
result.push(closestRelativeName);
}
if (candidate !== 'class/' + name) {
if (!result.includes(candidate)) {
result.push(candidate);
}
}
// todo add hotReloadCUSTOMhlContext... to resolve deep nesting
const namesFromContext = this.extractNamesFromContext(scope).reverse();
for (let i = 1; i <= namesFromContext.length; i++) {
const possibleNamePaths = namesFromContext.slice(0, i);
possibleNamePaths.push(name);
result.push(possibleNamePaths.join('/'));
init() {
this._super(...arguments);
this.routeScopedComponents = getRouteScopedComponents();
this.muScopedComponents = getMUScopedComponents();
this.owner = getOwner(this);
this.componentLookup = this.owner.lookup('component-lookup:main');
this.routerService = this.owner.lookup('service:router') || this.owner.lookup('service:-router');
this.appConfig = this.owner.resolveRegistration('config:environment') || {};
this.modulePrefix = get(this.appConfig, 'modulePrefix') || 'dummy';
this.podModulePrefix = get(this.appConfig, 'podModulePrefix') || this.modulePrefix;
},
normalizeComponentName(name) {
init() {
this._super(...arguments);
this.routeScopedComponents = getRouteScopedComponents();
this.muScopedComponents = getMUScopedComponents();
this.owner = getOwner(this);
this.componentLookup = this.owner.lookup('component-lookup:main');
this.routerService = this.owner.lookup('service:router') || this.owner.lookup('service:-router');
this.appConfig = this.owner.resolveRegistration('config:environment') || {};
this.modulePrefix = get(this.appConfig, 'modulePrefix') || 'dummy';
this.podModulePrefix = get(this.appConfig, 'podModulePrefix') || this.modulePrefix;
},
normalizeComponentName(name) {
forgetComponent(name, isMU = true) {
const cacheKey = this.get('iterationId') + '/' + name + '/' + isMU;
if (FORGET_CACHE.includes(cacheKey)) {
return;
}
if (isMU) {
const muNames = this.getPossibleMUComponentNames(name);
muNames.forEach((possibleMuName)=>{
clearContainerCache(this, possibleMuName);
});
}
clearContainerCache(this, name);
FORGET_CACHE.push(cacheKey);
},
clearRequirejs(name) {
muNames.forEach((possibleMuName)=>{
clearContainerCache(this, possibleMuName);
});
}
muNames.forEach((possibleMuName)=>{
clearRequirejsCache(this, possibleMuName);
});
clearRequirejsCache(this, name);
clearRequirejs(name) {
const cacheKey = this.get('iterationId') + '/' + name;
if (REQUIRE_CLEAR_CACHE.includes(cacheKey)) {
return;
}
const muNames = this.getPossibleMUComponentNames(name);
muNames.forEach((possibleMuName)=>{
clearRequirejsCache(this, possibleMuName);
});
clearRequirejsCache(this, name);
REQUIRE_CLEAR_CACHE.push(cacheKey);
},
addDynamicHelperWrapperComponent(name) {
willLiveReloadRouteTemplate(attrs) {
const meta = getPossibleRouteTemplateMeta(attrs.modulePath);
if (meta.looksLikeRouteTemplate) {
attrs.cancel = true;
this.clearRequirejs(meta.possibleTemplateName);
}
},
__isAlive() {
willHotReloadRouteTemplate(attrs) {
const meta = getPossibleRouteTemplateMeta(attrs);
if (!meta.looksLikeRouteTemplate) {
return;
}
const currentRouteName = this.hasActiveRoute() ? this.currentRouteName() : '';
if (meta.maybeClassicPath) {
this.forgetComponent(meta.possibleTemplateName, false);
const route = this.routeByPath(meta.possibleRouteName);
if (!route) {
return this.reloadWindow();
}
if (shouldRenderTemplate(currentRouteName, meta.possibleRouteName)) {
route.renderTemplate();
}
} else if (meta.isMU) {
let routeName = stripRouteTemplatePrefix(meta.possibleRouteName);
routeName = stripRouteTemplatePostfix(routeName);