Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function Compilable(source: any) {
// console.log('In Compilable: ' + source);
const precompiled = precompile(source);
// console.log('Precompiled');
const component = Component(precompiled);
// console.log(`Compiled Component: ${component}`);
return component;
}
import compileModule from '../../../utils/compileModule';
import pkg from '@glimmer/compiler/package.json';
const ID = 'glimmer-compiler';
export default {
id: ID,
displayName: ID,
version: pkg.version,
homepage: pkg.homepage || 'https://github.com/glimmerjs/glimmer-vm',
defaultParserID: 'glimmer',
loadTransformer(callback) {
require(
['../../../transpilers/babel', '@glimmer/compiler'],
(transpile, glimmer) => callback({ transpile: transpile.default, glimmer }),
);
},
transform({ transpile, glimmer }, transformCode, code) {
transformCode = transpile(transformCode);
const transformModule = compileModule(transformCode);
// allow "export default" instead of "module.exports = "
const transform = transformModule.__esModule ?
import compileModule from '../../../utils/compileModule';
import pkg from '@glimmer/compiler/package.json';
const ID = 'glimmer-compiler';
export default {
id: ID,
displayName: ID,
version: pkg.version,
homepage: pkg.homepage || 'https://github.com/glimmerjs/glimmer-vm',
defaultParserID: 'glimmer',
loadTransformer(callback) {
require(
['../../../transpilers/babel', '@glimmer/compiler'],
(transpile, glimmer) => callback({ transpile: transpile.default, glimmer }),
);
},
transform({ transpile, glimmer }, transformCode, code) {
transformCode = transpile(transformCode);
const transformModule = compileModule(transformCode);
// allow "export default" instead of "module.exports = "
compile(template: string, meta: TemplateMeta = {}): Template {
let wrapper = JSON.parse(precompile(template, { meta }));
let factory = templateFactory(wrapper);
return factory.create(this.compileOptions);
}
preprocess(
template: string,
meta?: AnnotatedModuleLocator
): Template> {
let wrapper = JSON.parse(precompile(template));
let factory = templateFactory(wrapper);
return factory.create(templateMeta(meta || DEFAULT_TEST_META));
}
export function createTemplate(
templateSource: string,
options?: PrecompileOptions
): TemplateFactory {
let wrapper: SerializedTemplateWithLazyBlock = JSON.parse(
rawPrecompile(templateSource, options)
);
return templateFactory(wrapper);
}
export function createTemplate(templateSource: string, meta: TemplateMeta = {}): ParsedLayout {
let wrapper: SerializedTemplateWithLazyBlock = JSON.parse(precompile(templateSource, { meta }));
let block: SerializedTemplateBlock = JSON.parse(wrapper.block);
return { block, referer: meta };
}
'generates id in node'() {
let template = precompile('hello');
let obj = JSON.parse(template);
this.assert.equal(obj.id, '14+n+4pQ', 'short sha of template source');
template = precompile('hello', { meta: { moduleName: 'template/hello' } });
obj = JSON.parse(template);
this.assert.equal(obj.id, 'Ohs2KKrA', 'short sha of template source and meta');
}
}
registerNativeComponent(name, value) {
this.registerNativeElement(name, value);
const handle = Application.resolver.registerTemplateOnlyComponent(name);
Application.resolverDelegate.registerComponent(name, handle, precompile(`<${name.toLowerCase()} ...attributes> {{yield}} `), TEMPLATE_ONLY_COMPONENT);
}
registerHelper(name, func) {
processString(content, relativePath) {
let specifier = getTemplateSpecifier(this.options.rootName, relativePath);
return 'export default ' + precompile(content, { meta: { specifier, '': true } }) + ';';
}
}