Example #1
0
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;
}
Example #2
0
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;
};
Example #3
0
	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);
				});
		});
	}
Example #4
0
 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);
         });
     });
 };
Example #5
0
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);
			}
		});
	};
Example #6
0
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);
        });
    
    });
}
Example #7
0
		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);
					});
			});
		},
Example #8
0
	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);
				});
		});
	}