function get(fn, path, ctr) { path = path_resolveUrl(path, Module.resolveLocation(ctr)); var dfr = Cache[path]; if (dfr !== void 0) { return dfr; } dfr = new class_Dfr(); fn(path, dfr.pipeCallback()); return dfr; }
export function renderer_renderAsync (template, model?, ctx?, container?, ctr?): PromiseLike<HTMLElement> { if (ctx == null || ctx.constructor !== builder_Ctx) ctx = new builder_Ctx(ctx); if (ctr == null) ctr = new Component(); var dom = renderer_render(template, model, ctx, container, ctr), dfr = new class_Dfr(); if (ctx.async === true) { ctx.done(function() { dfr.resolve(dom, ctr); }); } else { dfr.resolve(dom, ctr); } return dfr; };
function build_script(path, opts, done) { return class_Dfr.run(function(resolve, reject){ _file_get(path) .fail(reject) .done(function(str){ var script = 'var module = { exports: null }\n'; script += str + ';\n'; script += 'mask.Module.registerModule(module.exports, new mask.Module.Endpoint("' + path + '", "script"))'; resolve(script); }); }); }
return function(path){ return class_Dfr.run(function(resolve, reject){ lib.instance('/')[name](path + '::Module').done(function(resp){ if ('css' === name) { return resolve(); } if ('js' === name) { return resolve(resp.Module); } resolve(resp[name].Module); }); }); };
export function tools_build (template, path, opts_?){ var opts = obj_extendDefaults(opts_, optionsDefault); return class_Dfr.run(function(resolve, reject){ tools_getDependencies(template, path, { flattern: true }) .fail(reject) .done(function(deps){ build(deps, opts, complete, reject); }); function complete (out) { out.mask += '\n' + template; resolve(out); } }); };
ModuleMidd.parseMaskContent = function (mix: string | any, path: string): PromiseLike<{ [key: string]: any }> { return class_Dfr.run((resolve, reject) => { new ModuleMask(path || '').preprocess_(mix, function( error, exports ) { if (error) { reject(error); return; } resolve(exports); }); }); }
mask: function(path, opts, done){ return class_Dfr.run(function(resolve, reject) { _file_get(path) .fail(reject) .done(function(str) { // remove all remote styles var ast = mask_TreeWalker.walk(str, function(node){ if (node.tagName === 'link' && node.attr.href) { return { remove: true }; } }); ast = jMask('module') .attr('path', path) .append(ast); var str = mask_stringify(ast[0], { indent: opts.minify ? 0 : 4 }); resolve(str); }); }); },
function build_data(path, opts, done) { return class_Dfr.run(function(resolve, reject){ _file_get(path) .fail(reject) .done(function(mix){ var json; try { json = typeof mix === 'string' ? JSON.parse(mix) : mix; } catch (error) { reject(error); return; } var str = JSON.stringify(json, null, opts.minify ? 4 : void 0); var script = 'module = { exports: ' + str + ' }\n' + 'mask.Module.registerModule(module.exports, new mask.Module.Endpoint("' + path + '", "json"))'; resolve(script); }); }); }