Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Object.keys(components).forEach(key => {
assert(key.indexOf('ui/components') !== -1, `Expected component key to start with ui/components, got ${key}.`);
let component = components[key];
let spec = specifierFor(key, 'default');
let block;
let symbolTable;
if (component.type === "Curly" || component.type === "Dynamic") {
let block = compiler.preprocess(spec, component.template);
let options = compiler.compileOptions(spec);
let parsedLayout = { block, referrer: spec };
let wrapped = new WrappedBuilder(options, parsedLayout, EMBERISH_CURLY_CAPABILITIES);
compiler.addCustom(spec, wrapped);
compileTimeModules.register(key, 'other', {
default: wrapped.symbolTable
});
symbolTable = wrapped.symbolTable;
resolveComponentSpecifier(componentName: string, referrer: Specifier): Specifier {
return specifierFor(this.modules.resolve(componentName, referrer, 'ui/components')!, 'default');
}
resolveHelperSpecifier(helperName: string, referrer: Specifier): Specifier {
let path = this.modules.resolve(helperName, referrer);
return specifierFor(path!, 'default');
}
constructor(protected projectPath: string, public outputFiles: OutputFiles, envBuiltIns: Builtins = {}) {
debug('initialized MU compiler delegate; project=%s', projectPath);
this.project = new Project(projectPath);
let builtins = {
main: specifierFor('main', 'mainTemplate'),
if: specifierFor('@glimmer/application', 'ifHelper'),
action: specifierFor('@glimmer/application', 'actionHelper'),
...envBuiltIns
};
let byName = new Map();
let byModulePath = new Map();
let byIdentifier = new Map();
Object.keys(builtins).forEach(builtin => {
let specifier = builtins[builtin];
byName.set(specifier.name, specifier.module);
byModulePath.set(specifier.module, specifier.name);
byIdentifier.set(builtin, specifier);
});
constructor(protected projectPath: string, public outputFiles: OutputFiles, envBuiltIns: Builtins = {}) {
debug('initialized MU compiler delegate; project=%s', projectPath);
this.project = new Project(projectPath);
let builtins = {
main: specifierFor('main', 'mainTemplate'),
if: specifierFor('@glimmer/application', 'ifHelper'),
action: specifierFor('@glimmer/application', 'actionHelper'),
...envBuiltIns
};
let byName = new Map();
let byModulePath = new Map();
let byIdentifier = new Map();
Object.keys(builtins).forEach(builtin => {
let specifier = builtins[builtin];
byName.set(specifier.name, specifier.module);
byModulePath.set(specifier.module, specifier.name);
byIdentifier.set(builtin, specifier);
});
this.builtinsMap = {
byModulePath,
protected getCompilerSpecifier(specifier: string): Specifier {
let modulePath = expect(this.project.pathForSpecifier(specifier), `couldn't find module with specifier '${specifier}'`);
return specifierFor(modulePath, 'default');
}
function getComponentImport(referrer: string): Specifier | null {
let componentSpec = project.resolver.identify('component:', referrer);
if (componentSpec) {
let componentPath = project.pathForSpecifier(componentSpec)!;
componentPath = relative(dataSegmentPath, componentPath);
debug('found corresponding component; referrer=%s; path=%s; dataSegment=%s', referrer, componentPath, dataSegmentPath);
componentPath = componentPath.replace(extname(componentPath), '');
return specifierFor(componentPath, 'default');
}
debug('no component for template; referrer=%s', referrer);
return null;
}
}
specifierFor(relativePath: string) {
return specifierFor(relativePath, 'default');
}