Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed reference discovery order

  • Loading branch information...
commit 495e9358650628cca9f92be986ff11ea0b2012f5 1 parent b1ef625
@xcambar authored
Showing with 89 additions and 72 deletions.
  1. +52 −54 build/shepherd.dev.js
  2. +1 −1  build/shepherd.min.js
  3. +36 −17 src/shepherd.js
View
106 build/shepherd.dev.js
@@ -1048,14 +1048,9 @@
http.send();
return deferred.promise;
}
- function _handleExports(module, moduleConf, callback) {
+ function _handleExports(module, moduleConf) {
moduleConf._internals.src && (modules[moduleConf._internals.src] = module);
- if (moduleConf.hasOwnProperty("name")) {
- moduleConf.name && (modules[moduleConf.name] = module);
- }
- if (is(callback, "function")) {
- callback(module || {});
- }
+ moduleConf.name && (modules[moduleConf.name] = module);
}
function loadClientSideModule(moduleConf, contents) {
var conf = moduleConf.imports || {};
@@ -1109,11 +1104,8 @@
fn = Function.apply({}, argsName.concat([ contents + ";\nreturn " + returns ]));
}
module = fn.apply({}, moduleArgs);
- var defer = when.defer();
- _handleExports(module, moduleConf, function(module) {
- defer.resolve(module);
- });
- return defer.promise;
+ _handleExports(module, moduleConf);
+ return module;
}
}
function loadServerSideModule(moduleConf, contents, callback) {
@@ -1161,15 +1153,7 @@
function loadModule(moduleConf, contents) {
!moduleConf && (moduleConf = {});
if (!_isServer) {
- var defer = when.defer();
- when(loadClientSideModule(moduleConf, contents)).then(function(module) {
- console.log("loadModule done", moduleConf._internals.src, module);
- defer.resolve(module);
- return module;
- }, function() {
- defer.reject();
- });
- return defer;
+ return loadClientSideModule(moduleConf, contents);
} else {
loadServerSideModule(moduleConf, contents, callback);
}
@@ -1182,17 +1166,26 @@
moduleConf.imports = moduleConf.imports || {};
var _dep = modules[declaration.from.path];
if (_dep) {
- for (var i = 0, _l = declaration.vars.length; i < _l; i++) {
- var _importName = declaration.vars[i];
- moduleConf.imports[_importName] = _dep[_importName];
+ if (when.isPromise(_dep)) {
+ _dep.then(function(module) {
+ moduleConf.imports[_importName] = module;
+ });
+ confPromises.push(_dep);
+ } else {
+ for (var i = 0, _l = declaration.vars.length; i < _l; i++) {
+ var _importName = declaration.vars[i];
+ moduleConf.imports[_importName] = _dep[_importName];
+ }
}
} else {
- confPromises.push(_module(declaration.from.path, function(module) {
+ var _p = _module(declaration.from.path, function(module) {
for (var i = 0, _l = declaration.vars.length; i < _l; i++) {
var _importName = declaration.vars[i];
moduleConf.imports[_importName] = module[_importName];
}
- }, errorFn));
+ }, errorFn);
+ modules[declaration.from.path] = _p;
+ confPromises.push(_p);
}
}
function exportLoader(declaration) {
@@ -1219,14 +1212,24 @@
}
} else {
moduleConf.imports = moduleConf.imports || {};
- var ref = declaration.path || declaration.src;
- if (modules[ref]) {
- moduleConf.imports[declaration.id] = modules[declaration.src];
+ var ref = declaration.path || declaration.src || declaration.id;
+ var _mod = modules[ref];
+ if (_mod) {
+ if (when.isPromise(_mod)) {
+ _mod.then(function(module) {
+ moduleConf.imports[declaration.id] = module;
+ return module;
+ });
+ confPromises.push(_mod);
+ } else {
+ moduleConf.imports[declaration.id] = _mod;
+ }
} else if (declaration.path) {
- confPromises.push(_module(declaration.path, function(module) {
+ var _p = _module(declaration.path, function(module) {
moduleConf.imports[declaration.id] = module;
return moduleConf;
- }));
+ });
+ confPromises.push(_p);
} else {
if (_isServer) {
var _dep;
@@ -1262,15 +1265,12 @@
moduleConf = conf || {}, rawText = conf.contents ? conf.contents : "", declaration = "";
var comments = rawText.match(/(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg);
if (!comments) {
- when(loadModule({
+ var module = loadModule({
_internals: {
src: conf.src
}
- }, rawText).then(function(module) {
- defer.resolve(module);
- return module;
- }));
- return defer.promise;
+ }, rawText);
+ return defer.resolve(module);
}
var split = comments[0].split("\n");
for (var j = 0, _l2 = split.length; j < _l2; j++) {
@@ -1286,30 +1286,24 @@
src: conf.src,
contents: rawText
};
- when(applyConfiguration(usedConf)).then(function(parsedConf) {
- return parsedConf;
+ when(applyConfiguration(usedConf)).then(function(moduleConf) {
+ return moduleConf;
}, function(e) {
defer.reject(e);
- }).then(function(parsedConf) {
- when(loadModule(parsedConf, parsedConf._internals.contents)).then(function(module) {
- defer.resolve(module);
- return module;
- }, function(e) {
- defer.reject(e);
- });
+ }).then(function(moduleConf) {
+ var module = loadModule(moduleConf, moduleConf._internals.contents);
+ defer.resolve(module);
+ return module;
});
}
} else {
- when(loadModule({
+ var module = loadModule({
_internals: {
src: conf.src
}
- }, rawText)).then(function(module) {
- defer.resolve(module);
- return module;
- }, function() {
- defer.reject();
- });
+ }, rawText);
+ defer.resolve(module);
+ return module;
}
return defer.promise;
}
@@ -1474,7 +1468,11 @@
}, cb, _errCb);
};
me.s6d.get = function(moduleName) {
- return modules[moduleName];
+ if (moduleName) {
+ return modules[moduleName];
+ } else {
+ return modules;
+ }
};
me.s6d.error = function(cb) {
if (arguments.length === 0) {
View
2  build/shepherd.min.js
@@ -1 +1 @@
-(function(a,b,c,d){function e(a,b){return Object.prototype.toString.call(a).toLowerCase()=="[object "+b.toLowerCase()+"]"}function l(a){var b=a.format;if(b==="commonJS")return{fn:function(c){return a.deps&&a.deps.hasOwnProperty(c)?a.deps[c]:require(c)},name:"require"};if(b==="amd"){var c="define";return{name:c,fn:function(c,d,e){var f,g,h;switch(arguments.length){case 1:f=a.name,h=c;break;case 2:g=c,h=d;break;default:f=c,g=d,h=e}if(g){var i={};for(var j=0,k=g.length;j<k;j++)i[g[j]]={format:"amd",ref:g[j]};g=i}var l={};g&&(l.import=g),f&&(l.name=f),h&&(l.fn=h),l.src=a.src,s(l,function(b){throw new Error("AMD not handled yet")})}}}}function m(a,c){function d(a){var b=a.split(";"),c=/^\s*([a-zA-Z_$][0-9a-zA-Z_$]*)\!([a-zA-Z_$][0-9a-zA-Z_$]*)\s*$/;for(var d=0;d<b.length;d++){if(!b[d])continue;var f=b[d],g=f.match(c);if(!g)return!1;var h=g[1];argument=g[2];if(!k[h])return'Unknown plugin "'+h+'"';var i=k[h](argument);if(e(i,"string")||!i)return i}return!0}var f=c||{},g=d(a);if(e(g,"string"))return g;if(g)return f;try{var h=b.parse(a);return typeof true=="undefined"&&console.log(h),h}catch(i){return"Invalid declaration \n"+i.message+"\nDeclaration: "+a}}function n(b){var d=c.defer(),e="XMLHttpRequest"in a?new XMLHttpRequest:new ActiveXObject("Microsoft.XMLHTTP");return e.open("GET",b,!0),e.setRequestHeader("Accept","application/javascript, text/javascript"),e.onreadystatechange=function(){this.readyState==4&&(/^20\d$/.test(this.status)?d.resolve(e):d.reject(this.status))},e.send(),d.promise}function o(a,b,c){b._internals.src&&(f[b._internals.src]=a),b.hasOwnProperty("name")&&b.name&&(f[b.name]=a),e(c,"function")&&c(a||{})}function p(b,d){var e=b.imports||{},f,g;e.window={};for(var h in window)e.window[h]=window[h];var k=b.exports?"{"+b.exports.map(function(a){return a.dest+":("+["window."+a.src,"this."+a.src,a.src].join("||")+")"}).join(",")+"}":"{}",m=[],n=[];for(var h in e)e.hasOwnProperty(h)&&(n.push(h),m.push(e[h]));b.format&&b.format.length&&(g=l(b),n.push(g.name),m.push(g.fn));if(!j){var s;d.apply&&d.call?s=d:s=Function.apply({},n.concat([d+";\nreturn "+k])),f=s.apply({},m);var t=c.defer();return o(f,b,function(a){t.resolve(a)}),t.promise}var p=document.createElement("script"),q=document.getElementsByTagName("head")[0];p.type="text/javascript";var r=i++;p.innerHTML="(function runner ("+n.join(", ")+") {\n"+d+"\n;s6d["+r+"]("+k+");\n}).apply({}, s6d["+r+"]())",b.src&&p.setAttribute("data-src",b.src),b.name&&p.setAttribute("name",b.name),a.s6d[r]=function(d){if(d){delete a.s6d[r];var e=c.defer();return o(f,b,function(a){return e.resolve(a),a}),e.promise}return m},q.appendChild(p)}function q(a,b,d){var e,f,g=require("vm"),h=a.imports||{};a.format&&a.format.length&&(f=l(a),h[f.name]=f.fn),h.returns={},h.console=console,h.exports={},h.module={exports:{}},h.require=function(a){return h[a]?h[a]:require(a)};var i=a.exports?a.exports.map(function(a){return"returns."+a.dest+" = "+a.src}).join(";\n"):"";g.runInNewContext(b+";\n"+i,h,a._internals.src+".vm"),e=h.returns;for(var j in h.exports)h.exports.hasOwnProperty(j)&&(e[j]=h.exports[j]);for(var j in h.module.exports)h.module.exports.hasOwnProperty(j)&&(e[j]=h.module.exports[j]);var k=c.defer();return o(e,a,function(){k.resolve()}),k}function r(a,b){!a&&(a={});if(!h){var d=c.defer();return c(p(a,b)).then(function(b){return console.log("loadModule done",a._internals.src,b),d.resolve(b),b},function(){d.reject()}),d}q(a,b,callback)}function s(a){function e(a){b.imports=b.imports||{};var c=f[a.from.path];if(c)for(var e=0,g=a.vars.length;e<g;e++){var h=a.vars[e];b.imports[h]=c[h]}else d.push(v(a.from.path,function(c){for(var d=0,e=a.vars.length;d<e;d++){var f=a.vars[d];b.imports[f]=c[f]}},errorFn))}function g(a){for(var c=0,d=a.length;c<d;c++)b.exports=b.exports||[],b.exports.push({src:a[c],dest:a[c]})}function i(c){b.name=a.decl.id;if(c.expressions)for(var j=0,k=c.expressions.length;j<k;j++){var l=c.expressions[j];l.type==="export"?g(l.decl):l.type==="import"?e(l.decl):l.type==="module"&&i(l.decl)}else{b.imports=b.imports||{};var m=c.path||c.src;if(f[m])b.imports[c.id]=f[c.src];else if(c.path)d.push(v(c.path,function(a){return b.imports[c.id]=a,b}));else{if(!h)throw new Error("The required module %1 doesn't exist".replace("%1",c.src));var n;try{n=require(c.src)}catch(o){throw new Error("The required module %1 doesn't exist".replace("%1",c.src))}b.imports[c.id]=n}}}var b={},d=[];b._internals=a._internals,a.type==="module"?(b.name=a.decl.id,i(a.decl)):a.type==="export"?g(a.decl):a.type==="import"&&e(a.decl);var j=c.all(d).then(function(){return b},function(){throw new Error("Error while loading "+b._internals.src)});return j}function t(a){var b=c.defer();moduleConf=a||{},rawText=a.contents?a.contents:"",declaration="";var d=rawText.match(/(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg);if(!d)return c(r({_internals:{src:a.src}},rawText).then(function(a){return b.resolve(a),a})),b.promise;var f=d[0].split("\n");for(var g=0,h=f.length;g<h;g++)declaration+=f[g].trim().replace(/(^\/\*+)|(\*+\/?)/,"");if(declaration.length){moduleConf=m(declaration,moduleConf);if(e(moduleConf,"string"))b.reject(moduleConf);else{var i=moduleConf[0];i._internals={src:a.src,contents:rawText},c(s(i)).then(function(a){return a},function(a){b.reject(a)}).then(function(a){c(r(a,a._internals.contents)).then(function(a){return b.resolve(a),a},function(a){b.reject(a)})})}}else c(r({_internals:{src:a.src}},rawText)).then(function(a){return b.resolve(a),a},function(){b.reject()});return b.promise}function u(a){var b;try{b=require.resolve(a)}catch(c){}try{b=b?b:require("fs").statSync(__dirname+"/"+a).isFile()&&__dirname+"/"+a}catch(c){}try{b=b?b:require("fs").statSync(process.cwd()+"/"+a).isFile()&&process.cwd()+"/"+a}catch(c){}return b}function v(a,b,d){function i(b){g=g||[],g.indexOf(a)===-1&&g.push(a);if(!e(d,"function"))throw new Error("("+a+") "+b);d()}if(f.hasOwnProperty(a))return b(f[a]);i.origFn=d;var j=c.defer();j.then(b,i);var k=e(a,"string")?{src:a}:a;!k.format&&h&&(k.format="commonJS");var l=e(a,"string")?a:a.name;if(!l)return e(a,"object")&&t(a,function(a){return j.resolve(a),a},function(a){j.reject(a)}),j;if(!h)return c(n(l)).then(function(b){var d=b.responseText;k.contents=d,c(t(k)).then(function(a){return j.resolve(a),a},function(a){j.reject(a)})},function(c){i('Unable to fetch the module "'+a+'" (status code: '+c+")")}),j.promise;var m,o=require("url"),p=o.parse(l);if(p.host){var q=require(p.protocol.indexOf("https")!==-1?"https":"http").get,r={host:p.host,path:p.pathname};p.port&&(r.port=p.port),q(r,function(a){var c="";a.on("data",function(a){c+=a}),a.on("end",function(){k.contents=c,t(k,b,i)}),a.on("error",i)})}else{m=u(l);if(!m){i("Unable to locate file "+l);return}if(e(m,"object"))k.deps=k.deps||{},k.deps[m.uri]=m.node_module;else try{k.contents=require("fs").readFileSync(m,"utf-8")}catch(s){i(s.message);return}t(k,b,i)}}function w(a){for(var b=0;b<a.length;b++){var c=a[b],d;if(e(JSON,"object"))d=JSON.parse(c);else{var f=new Function("return "+c);d=f()}for(var g in d){if(!d.hasOwnProperty(g))continue;g in k?k[g](d[g]):g=="debug"&&(j=d[g])}}}function x(a){for(var b=0;b<a.length;b++){var c=a[b],d=c.getAttribute("data-src");d&&!a.hasOwnProperty(d)&&v(d),!d&&c.innerHTML&&t({contents:c.innerHTML})}}if(typeof b.parse!="function")throw"No parser provided.";var f={},g=null,h=typeof window=="undefined",i=0,j,k={modularize:function(c){function d(b){return a.hasOwnProperty(b)?(f[b]=a[b],!0):'No global "'+b+'"'}if(e(c,"array"))for(var g=0;g<c.length;g++)d(c[g]);else d(c)},noGlobal:function(c){var d=function(b){return a.hasOwnProperty(b)?(delete a[b],!0):'No global "'+b+'"'};if(e(c,"array"))for(var f=0;f<c.length;f++)d(c[f]);else d(c)}};!h&&a.addEventListener&&a.addEventListener("load",function(){var b=[],c=[];for(var d=0;d<document.scripts.length;d++){var e=document.scripts[d],f=e.getAttribute("type");f=="text/shepherd-js"?c.push(e):f=="text/shepherd-js/config"&&b.push(e.innerHTML.trim())}w(b),x(c)});if(typeof true=="undefined"){var y;a.s6d=function(a,b){e(a,"object")?w([a]):v(a,b,y)},a.s6d.src=function(a,b){t({contents:a},b,y)},a.s6d.get=function(a){return f[a]},a.s6d.error=function(a){if(arguments.length===0)return g;y=a},a.s6d.reset=function(){y=d,f={},g=null},h&&(exports=module.exports=a.s6d)}})(this,(function(){var a,b=function(){var a={trace:function(){},yy:{},symbols_:{error:2,Program:3,ProgramNext:4,ProgramElement:5,ModuleDeclaration:6,ImportDeclaration:7,ExportDeclaration:8,EOF:9,ModuleSpecifier:10,Path:11,String:12,module:13,Id:14,at:15,SEMICOLON:16,IS:17,ImportSource:18,OPEN_BRACE:19,ModuleBody:20,CLOSE_BRACE:21,from:22,"import":23,ImportSpecifierSet:24,WILDCARD:25,ImportSpecifier:26,ImportSpecifierNext:27,COMMA:28,COLON:29,"export":30,ExportSpecifierSet:31,ExportSpecifierSetNext:32,ExportSpecifier:33,ExportSpecifierNext:34,ModuleElement:35,PERIOD:36,$accept:0,$end:1},terminals_:{2:"error",9:"EOF",12:"String",13:"module",14:"Id",15:"at",16:"SEMICOLON",17:"IS",19:"OPEN_BRACE",21:"CLOSE_BRACE",22:"from",23:"import",25:"WILDCARD",28:"COMMA",29:"COLON",30:"export",36:"PERIOD"},productions_:[0,[3,1],[4,1],[4,2],[5,1],[5,1],[5,1],[5,1],[10,1],[10,1],[6,5],[6,5],[6,5],[18,1],[18,3],[7,5],[24,1],[24,1],[24,4],[27,3],[27,0],[26,1],[26,3],[8,4],[32,3],[32,0],[31,4],[31,1],[31,1],[31,3],[33,1],[33,3],[34,3],[34,0],[20,2],[20,2],[20,2],[20,0],[35,1],[35,1],[11,1],[11,3]],performAction:function(b,c,d,e,f,g,h){var i=g.length-1;switch(f){case 1:return g[i];case 2:this.$=g[i];break;case 3:this.$=g[i].length?g[i-1].concat(g[i]):g[i-1];break;case 4:this.$=[{type:"module",decl:g[i]}];break;case 5:this.$=[{type:"import",decl:g[i]}];break;case 6:this.$=[{type:"export",decl:g[i]}];break;case 7:this.$=[];break;case 8:this.$={type:"module",path:g[i]};break;case 9:this.$={type:"uri",path:g[i].trim().replace(/^(['"])(.*)\1$/,function(a,b,c,d){return c})};break;case 10:this.$={id:g[i-3],path:g[i-1].trim().replace(/^(['"])(.*)\1$/,function(a,b,c,d){return c})};break;case 11:this.$={id:g[i-3],src:g[i-1]};break;case 12:this.$={id:g[i-3],expressions:g[i-1]};break;case 13:this.$=g[i];break;case 14:var j={id:g[i-2]};j[g[i].type]=g[i].path,this.$=j;break;case 15:this.$={from:g[i-1],vars:g[i-3]};break;case 16:this.$=[g[i]];break;case 17:this.$=[g[i]];break;case 18:this.$=[g[i-2]].concat(g[i-1]);break;case 19:this.$=typeof g[i]!="undefined"?[g[i-1]].concat(g[i]):g[i-1];break;case 21:this.$=g[i];break;case 22:this.$={remote:g[i-2],local:g[i]};break;case 23:this.$=typeof g[i-1]!="undefined"?g[i-2].concat(g[i-1]):g[i-2];break;case 24:this.$=typeof g[i]!="undefined"?g[i-1].concat(g[i]):g[i-1];break;case 26:this.$=typeof g[i-1]!="undefined"?[g[i-2]].concat(g[i-1]):[g[i-2]];break;case 27:this.$=[g[i]];break;case 28:this.$=[g[i]];break;case 29:this.$=[{from:g[i]}];break;case 30:this.$=g[i];break;case 31:this.$={local:g[i-2],remote:g[i]};break;case 32:this.$=typeof g[i]!="undefined"?[g[i-1]].concat(g[i]):[g[i-1]];break;case 34:this.$=[{type:"module",decl:g[i-1]}].concat(g[i]);break;case 35:this.$=[{type:"import",decl:g[i-1]}].concat(g[i]);break;case 36:this.$=[{type:"export",decl:g[i-1]}].concat(g[i]);break;case 37:this.$=[];break;case 38:this.$=g[i];break;case 39:this.$=g[i];break;case 40:this.$=g[i];break;case 41:this.$=g[i-2]+"."+g[i]}},table:[{3:1,4:2,5:3,6:4,7:5,8:6,9:[1,7],13:[1,8],23:[1,9],30:[1,10]},{1:[3]},{1:[2,1]},{1:[2,2],4:11,5:3,6:4,7:5,8:6,9:[1,7],13:[1,8],23:[1,9],30:[1,10]},{1:[2,4],9:[2,4],13:[2,4],23:[2,4],30:[2,4]},{1:[2,5],9:[2,5],13:[2,5],23:[2,5],30:[2,5]},{1:[2,6],9:[2,6],13:[2,6],23:[2,6],30:[2,6]},{1:[2,7],9:[2,7],13:[2,7],23:[2,7],30:[2,7]},{14:[1,12]},{14:[1,14],19:[1,16],24:13,25:[1,15]},{14:[1,19],19:[1,18],25:[1,20],31:17},{1:[2,3]},{15:[1,21],17:[1,22],19:[1,23]},{22:[1,24]},{22:[2,16]},{22:[2,17]},{14:[1,26],26:25},{16:[2,25],28:[1,28],32:27},{14:[1,30],33:29},{16:[2,27],28:[2,27]},{16:[2,28],22:[1,31],28:[2,28]},{12:[1,32]},{14:[1,34],18:33},{6:36,7:37,8:38,13:[1,8],20:35,21:[2,37],23:[1,9],30:[1,10]},{10:39,11:40,12:[1,41],14:[1,42]},{21:[2,20],27:43,28:[1,44]},{21:[2,21],28:[2,21],29:[1,45]},{16:[1,46]},{14:[1,19],19:[1,18],25:[1,20],31:47},{21:[2,33],28:[1,49],34:48},{21:[2,30],28:[2,30],29:[1,50]},{11:51,14:[1,42]},{16:[1,52]},{16:[1,53]},{16:[2,13],22:[1,54]},{21:[1,55]},{6:36,7:37,8:38,13:[1,8],20:56,21:[2,37],23:[1,9],30:[1,10]},{6:36,7:37,8:38,13:[1,8],20:57,21:[2,37],23:[1,9],30:[1,10]},{6:36,7:37,8:38,13:[1,8],20:58,21:[2,37],23:[1,9],30:[1,10]},{16:[1,59]},{16:[2,8]},{16:[2,9]},{16:[2,40],21:[2,40],28:[2,40],36:[1,60]},{21:[1,61]},{14:[1,26],26:62},{11:63,14:[1,42]},{1:[2,23],9:[2,23],13:[2,23],21:[2,23],23:[2,23],30:[2,23]},{16:[2,25],28:[1,28],32:64},{21:[1,65]},{14:[1,30],33:66},{11:67,14:[1,42]},{16:[2,29],28:[2,29]},{1:[2,10],9:[2,10],13:[2,10],21:[2,10],23:[2,10],30:[2,10]},{1:[2,11],9:[2,11],13:[2,11],21:[2,11],23:[2,11],30:[2,11]},{10:68,11:40,12:[1,41],14:[1,42]},{1:[2,12],9:[2,12],13:[2,12],21:[2,12],23:[2,12],30:[2,12]},{21:[2,34]},{21:[2,35]},{21:[2,36]},{1:[2,15],9:[2,15],13:[2,15],21:[2,15],23:[2,15],30:[2,15]},{11:69,14:[1,42]},{22:[2,18]},{21:[2,20],27:70,28:[1,44]},{21:[2,22],28:[2,22]},{16:[2,24]},{16:[2,26],28:[2,26]},{21:[2,33],28:[1,49],34:71},{21:[2,31],28:[2,31]},{16:[2,14]},{16:[2,41],21:[2,41],28:[2,41]},{21:[2,19]},{21:[2,32]}],defaultActions:{2:[2,1],11:[2,3],14:[2,16],15:[2,17],40:[2,8],41:[2,9],56:[2,34],57:[2,35],58:[2,36],61:[2,18],64:[2,24],68:[2,14],70:[2,19],71:[2,32]},parseError:function(b,c){throw new Error(b)},parse:function(b){function o(a){d.length=d.length-2*a,e.length=e.length-a,f.length=f.length-a}function p(){var a;return a=c.lexer.lex()||1,typeof a!="number"&&(a=c.symbols_[a]||a),a}var c=this,d=[0],e=[null],f=[],g=this.table,h="",i=0,j=0,k=0,l=2,m=1;this.lexer.setInput(b),this.lexer.yy=this.yy,this.yy.lexer=this.lexer,typeof this.lexer.yylloc=="undefined"&&(this.lexer.yylloc={});var n=this.lexer.yylloc;f.push(n),typeof this.yy.parseError=="function"&&(this.parseError=this.yy.parseError);var q,r,s,t,u,v,w={},x,y,z,A;for(;;){s=d[d.length-1],this.defaultActions[s]?t=this.defaultActions[s]:(q==null&&(q=p()),t=g[s]&&g[s][q]);if(typeof t=="undefined"||!t.length||!t[0]){if(!k){A=[];for(x in g[s])this.terminals_[x]&&x>2&&A.push("'"+this.terminals_[x]+"'");var B="";this.lexer.showPosition?B="Parse error on line "+(i+1)+":\n"+this.lexer.showPosition()+"\nExpecting "+A.join(", ")+", got '"+this.terminals_[q]+"'":B="Parse error on line "+(i+1)+": Unexpected "+(q==1?"end of input":"'"+(this.terminals_[q]||q)+"'"),this.parseError(B,{text:this.lexer.match,token:this.terminals_[q]||q,line:this.lexer.yylineno,loc:n,expected:A})}if(k==3){if(q==m)throw new Error(B||"Parsing halted.");j=this.lexer.yyleng,h=this.lexer.yytext,i=this.lexer.yylineno,n=this.lexer.yylloc,q=p()}for(;;){if(l.toString()in g[s])break;if(s==0)throw new Error(B||"Parsing halted.");o(1),s=d[d.length-1]}r=q,q=l,s=d[d.length-1],t=g[s]&&g[s][l],k=3}if(t[0]instanceof Array&&t.length>1)throw new Error("Parse Error: multiple actions possible at state: "+s+", token: "+q);switch(t[0]){case 1:d.push(q),e.push(this.lexer.yytext),f.push(this.lexer.yylloc),d.push(t[1]),q=null,r?(q=r,r=null):(j=this.lexer.yyleng,h=this.lexer.yytext,i=this.lexer.yylineno,n=this.lexer.yylloc,k>0&&k--);break;case 2:y=this.productions_[t[1]][1],w.$=e[e.length-y],w._$={first_line:f[f.length-(y||1)].first_line,last_line:f[f.length-1].last_line,first_column:f[f.length-(y||1)].first_column,last_column:f[f.length-1].last_column},v=this.performAction.call(w,h,j,i,this.yy,t[1],e,f);if(typeof v!="undefined")return v;y&&(d=d.slice(0,-1*y*2),e=e.slice(0,-1*y),f=f.slice(0,-1*y)),d.push(this.productions_[t[1]][0]),e.push(w.$),f.push(w._$),z=g[d[d.length-2]][d[d.length-1]],d.push(z);break;case 3:return!0}}return!0}},b=function(){var a={EOF:1,parseError:function(b,c){if(!this.yy.parseError)throw new Error(b);this.yy.parseError(b,c)},setInput:function(a){return this._input=a,this._more=this._less=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this},input:function(){var a=this._input[0];this.yytext+=a,this.yyleng++,this.match+=a,this.matched+=a;var b=a.match(/\n/);return b&&this.yylineno++,this._input=this._input.slice(1),a},unput:function(a){return this._input=a+this._input,this},more:function(){return this._more=!0,this},pastInput:function(){var a=this.matched.substr(0,this.matched.length-this.match.length);return(a.length>20?"...":"")+a.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var a=this.match;return a.length<20&&(a+=this._input.substr(0,20-a.length)),(a.substr(0,20)+(a.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var a=this.pastInput(),b=(new Array(a.length+1)).join("-");return a+this.upcomingInput()+"\n"+b+"^"},next:function(){if(this.done)return this.EOF;this._input||(this.done=!0);var a,b,c,d,e,f;this._more||(this.yytext="",this.match="");var g=this._currentRules();for(var h=0;h<g.length;h++){c=this._input.match(this.rules[g[h]]);if(c&&(!b||c[0].length>b[0].length)){b=c,d=h;if(!this.options.flex)break}}if(b){f=b[0].match(/\n.*/g),f&&(this.yylineno+=f.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:f?f[f.length-1].length-1:this.yylloc.last_column+b[0].length},this.yytext+=b[0],this.match+=b[0],this.yyleng=this.yytext.length,this._more=!1,this._input=this._input.slice(b[0].length),this.matched+=b[0],a=this.performAction.call(this,this.yy,this,g[d],this.conditionStack[this.conditionStack.length-1]);if(a)return a;return}if(this._input==="")return this.EOF;this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){var b=this.next();return typeof b!="undefined"?b:this.lex()},begin:function(b){this.conditionStack.push(b)},popState:function(){return this.conditionStack.pop()},_currentRules:function(){return this.conditions[this.conditionStack[this.conditionStack.length-1]].rules},topState:function(){return this.conditionStack[this.conditionStack.length-2]},pushState:function(b){this.begin(b)}};return a.options={},a.performAction=function(b,c,d,e){var f=e;switch(d){case 0:break;case 1:break;case 2:break;case 3:return"SEMICOLON";case 4:return"COLON";case 5:return"OPEN_BRACE";case 6:return"CLOSE_BRACE";case 7:return"module";case 8:return"import";case 9:return"export";case 10:return 15;case 11:return 17;case 12:return 22;case 13:return"WILDCARD";case 14:return 28;case 15:return 36;case 16:return"Id";case 17:return"String";case 18:return"String";case 19:return 9}},a.rules=[/^\n+/,/^\s+/,/^\t+/,/^;/,/^:/,/^\{/,/^\}/,/^module\b/,/^import\b/,/^export\b/,/^at\b/,/^is\b/,/^from\b/,/^\*/,/^,/,/^\./,/^[a-zA-Z_$][0-9a-zA-Z_$]*/,/^'[^\']+'/,/^"[^\"]+"/,/^$/],a.conditions={INITIAL:{rules:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19],inclusive:!0}},a}();return a.lexer=b,a}();return typeof undefined!="undefined"&&typeof a!="undefined"&&(a.parser=b,a.parse=function(){return b.parse.apply(b,arguments)},a.main=function(c){if(!c[1])throw new Error("Usage: "+c[0]+" FILE");if(typeof process!="undefined")var d=undefined("fs").readFileSync(undefined("path").join(process.cwd(),c[1]),"utf8");else var e=undefined("file").path(undefined("file").cwd()),d=e.join(c[1]).read({charset:"utf-8"});return a.parser.parse(d)},typeof module!="undefined"&&undefined.main===module&&a.main(typeof process!="undefined"?process.argv.slice(1):undefined("system").args)),b})(),when)
+(function(a,b,c,d){function e(a,b){return Object.prototype.toString.call(a).toLowerCase()=="[object "+b.toLowerCase()+"]"}function l(a){var b=a.format;if(b==="commonJS")return{fn:function(c){return a.deps&&a.deps.hasOwnProperty(c)?a.deps[c]:require(c)},name:"require"};if(b==="amd"){var c="define";return{name:c,fn:function(c,d,e){var f,g,h;switch(arguments.length){case 1:f=a.name,h=c;break;case 2:g=c,h=d;break;default:f=c,g=d,h=e}if(g){var i={};for(var j=0,k=g.length;j<k;j++)i[g[j]]={format:"amd",ref:g[j]};g=i}var l={};g&&(l.import=g),f&&(l.name=f),h&&(l.fn=h),l.src=a.src,s(l,function(b){throw new Error("AMD not handled yet")})}}}}function m(a,c){function d(a){var b=a.split(";"),c=/^\s*([a-zA-Z_$][0-9a-zA-Z_$]*)\!([a-zA-Z_$][0-9a-zA-Z_$]*)\s*$/;for(var d=0;d<b.length;d++){if(!b[d])continue;var f=b[d],g=f.match(c);if(!g)return!1;var h=g[1];argument=g[2];if(!k[h])return'Unknown plugin "'+h+'"';var i=k[h](argument);if(e(i,"string")||!i)return i}return!0}var f=c||{},g=d(a);if(e(g,"string"))return g;if(g)return f;try{var h=b.parse(a);return typeof true=="undefined"&&console.log(h),h}catch(i){return"Invalid declaration \n"+i.message+"\nDeclaration: "+a}}function n(b){var d=c.defer(),e="XMLHttpRequest"in a?new XMLHttpRequest:new ActiveXObject("Microsoft.XMLHTTP");return e.open("GET",b,!0),e.setRequestHeader("Accept","application/javascript, text/javascript"),e.onreadystatechange=function(){this.readyState==4&&(/^20\d$/.test(this.status)?d.resolve(e):d.reject(this.status))},e.send(),d.promise}function o(a,b){b._internals.src&&(f[b._internals.src]=a),b.name&&(f[b.name]=a)}function p(b,d){var e=b.imports||{},f,g;e.window={};for(var h in window)e.window[h]=window[h];var k=b.exports?"{"+b.exports.map(function(a){return a.dest+":("+["window."+a.src,"this."+a.src,a.src].join("||")+")"}).join(",")+"}":"{}",m=[],n=[];for(var h in e)e.hasOwnProperty(h)&&(n.push(h),m.push(e[h]));b.format&&b.format.length&&(g=l(b),n.push(g.name),m.push(g.fn));if(!j){var s;return d.apply&&d.call?s=d:s=Function.apply({},n.concat([d+";\nreturn "+k])),f=s.apply({},m),o(f,b),f}var p=document.createElement("script"),q=document.getElementsByTagName("head")[0];p.type="text/javascript";var r=i++;p.innerHTML="(function runner ("+n.join(", ")+") {\n"+d+"\n;s6d["+r+"]("+k+");\n}).apply({}, s6d["+r+"]())",b.src&&p.setAttribute("data-src",b.src),b.name&&p.setAttribute("name",b.name),a.s6d[r]=function(d){if(d){delete a.s6d[r];var e=c.defer();return o(f,b,function(a){return e.resolve(a),a}),e.promise}return m},q.appendChild(p)}function q(a,b,d){var e,f,g=require("vm"),h=a.imports||{};a.format&&a.format.length&&(f=l(a),h[f.name]=f.fn),h.returns={},h.console=console,h.exports={},h.module={exports:{}},h.require=function(a){return h[a]?h[a]:require(a)};var i=a.exports?a.exports.map(function(a){return"returns."+a.dest+" = "+a.src}).join(";\n"):"";g.runInNewContext(b+";\n"+i,h,a._internals.src+".vm"),e=h.returns;for(var j in h.exports)h.exports.hasOwnProperty(j)&&(e[j]=h.exports[j]);for(var j in h.module.exports)h.module.exports.hasOwnProperty(j)&&(e[j]=h.module.exports[j]);var k=c.defer();return o(e,a,function(){k.resolve()}),k}function r(a,b){!a&&(a={});if(!h)return p(a,b);q(a,b,callback)}function s(a){function e(a){b.imports=b.imports||{};var e=f[a.from.path];if(e)if(c.isPromise(e))e.then(function(a){b.imports[i]=a}),d.push(e);else for(var g=0,h=a.vars.length;g<h;g++){var i=a.vars[g];b.imports[i]=e[i]}else{var j=v(a.from.path,function(c){for(var d=0,e=a.vars.length;d<e;d++){var f=a.vars[d];b.imports[f]=c[f]}},errorFn);f[a.from.path]=j,d.push(j)}}function g(a){for(var c=0,d=a.length;c<d;c++)b.exports=b.exports||[],b.exports.push({src:a[c],dest:a[c]})}function i(j){b.name=a.decl.id;if(j.expressions)for(var k=0,l=j.expressions.length;k<l;k++){var m=j.expressions[k];m.type==="export"?g(m.decl):m.type==="import"?e(m.decl):m.type==="module"&&i(m.decl)}else{b.imports=b.imports||{};var n=j.path||j.src||j.id,o=f[n];if(o)c.isPromise(o)?(o.then(function(a){return b.imports[j.id]=a,a}),d.push(o)):b.imports[j.id]=o;else if(j.path){var p=v(j.path,function(a){return b.imports[j.id]=a,b});d.push(p)}else{if(!h)throw new Error("The required module %1 doesn't exist".replace("%1",j.src));var q;try{q=require(j.src)}catch(r){throw new Error("The required module %1 doesn't exist".replace("%1",j.src))}b.imports[j.id]=q}}}var b={},d=[];b._internals=a._internals,a.type==="module"?(b.name=a.decl.id,i(a.decl)):a.type==="export"?g(a.decl):a.type==="import"&&e(a.decl);var j=c.all(d).then(function(){return b},function(){throw new Error("Error while loading "+b._internals.src)});return j}function t(a){var b=c.defer();moduleConf=a||{},rawText=a.contents?a.contents:"",declaration="";var d=rawText.match(/(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg);if(!d){var f=r({_internals:{src:a.src}},rawText);return b.resolve(f)}var g=d[0].split("\n");for(var h=0,i=g.length;h<i;h++)declaration+=g[h].trim().replace(/(^\/\*+)|(\*+\/?)/,"");if(!declaration.length){var f=r({_internals:{src:a.src}},rawText);return b.resolve(f),f}moduleConf=m(declaration,moduleConf);if(e(moduleConf,"string"))b.reject(moduleConf);else{var j=moduleConf[0];j._internals={src:a.src,contents:rawText},c(s(j)).then(function(a){return a},function(a){b.reject(a)}).then(function(a){var c=r(a,a._internals.contents);return b.resolve(c),c})}return b.promise}function u(a){var b;try{b=require.resolve(a)}catch(c){}try{b=b?b:require("fs").statSync(__dirname+"/"+a).isFile()&&__dirname+"/"+a}catch(c){}try{b=b?b:require("fs").statSync(process.cwd()+"/"+a).isFile()&&process.cwd()+"/"+a}catch(c){}return b}function v(a,b,d){function i(b){g=g||[],g.indexOf(a)===-1&&g.push(a);if(!e(d,"function"))throw new Error("("+a+") "+b);d()}if(f.hasOwnProperty(a))return b(f[a]);i.origFn=d;var j=c.defer();j.then(b,i);var k=e(a,"string")?{src:a}:a;!k.format&&h&&(k.format="commonJS");var l=e(a,"string")?a:a.name;if(!l)return e(a,"object")&&t(a,function(a){return j.resolve(a),a},function(a){j.reject(a)}),j;if(!h)return c(n(l)).then(function(b){var d=b.responseText;k.contents=d,c(t(k)).then(function(a){return j.resolve(a),a},function(a){j.reject(a)})},function(c){i('Unable to fetch the module "'+a+'" (status code: '+c+")")}),j.promise;var m,o=require("url"),p=o.parse(l);if(p.host){var q=require(p.protocol.indexOf("https")!==-1?"https":"http").get,r={host:p.host,path:p.pathname};p.port&&(r.port=p.port),q(r,function(a){var c="";a.on("data",function(a){c+=a}),a.on("end",function(){k.contents=c,t(k,b,i)}),a.on("error",i)})}else{m=u(l);if(!m){i("Unable to locate file "+l);return}if(e(m,"object"))k.deps=k.deps||{},k.deps[m.uri]=m.node_module;else try{k.contents=require("fs").readFileSync(m,"utf-8")}catch(s){i(s.message);return}t(k,b,i)}}function w(a){for(var b=0;b<a.length;b++){var c=a[b],d;if(e(JSON,"object"))d=JSON.parse(c);else{var f=new Function("return "+c);d=f()}for(var g in d){if(!d.hasOwnProperty(g))continue;g in k?k[g](d[g]):g=="debug"&&(j=d[g])}}}function x(a){for(var b=0;b<a.length;b++){var c=a[b],d=c.getAttribute("data-src");d&&!a.hasOwnProperty(d)&&v(d),!d&&c.innerHTML&&t({contents:c.innerHTML})}}if(typeof b.parse!="function")throw"No parser provided.";var f={},g=null,h=typeof window=="undefined",i=0,j,k={modularize:function(c){function d(b){return a.hasOwnProperty(b)?(f[b]=a[b],!0):'No global "'+b+'"'}if(e(c,"array"))for(var g=0;g<c.length;g++)d(c[g]);else d(c)},noGlobal:function(c){var d=function(b){return a.hasOwnProperty(b)?(delete a[b],!0):'No global "'+b+'"'};if(e(c,"array"))for(var f=0;f<c.length;f++)d(c[f]);else d(c)}};!h&&a.addEventListener&&a.addEventListener("load",function(){var b=[],c=[];for(var d=0;d<document.scripts.length;d++){var e=document.scripts[d],f=e.getAttribute("type");f=="text/shepherd-js"?c.push(e):f=="text/shepherd-js/config"&&b.push(e.innerHTML.trim())}w(b),x(c)});if(typeof true=="undefined"){var y;a.s6d=function(a,b){e(a,"object")?w([a]):v(a,b,y)},a.s6d.src=function(a,b){t({contents:a},b,y)},a.s6d.get=function(a){return a?f[a]:f},a.s6d.error=function(a){if(arguments.length===0)return g;y=a},a.s6d.reset=function(){y=d,f={},g=null},h&&(exports=module.exports=a.s6d)}})(this,(function(){var a,b=function(){var a={trace:function(){},yy:{},symbols_:{error:2,Program:3,ProgramNext:4,ProgramElement:5,ModuleDeclaration:6,ImportDeclaration:7,ExportDeclaration:8,EOF:9,ModuleSpecifier:10,Path:11,String:12,module:13,Id:14,at:15,SEMICOLON:16,IS:17,ImportSource:18,OPEN_BRACE:19,ModuleBody:20,CLOSE_BRACE:21,from:22,"import":23,ImportSpecifierSet:24,WILDCARD:25,ImportSpecifier:26,ImportSpecifierNext:27,COMMA:28,COLON:29,"export":30,ExportSpecifierSet:31,ExportSpecifierSetNext:32,ExportSpecifier:33,ExportSpecifierNext:34,ModuleElement:35,PERIOD:36,$accept:0,$end:1},terminals_:{2:"error",9:"EOF",12:"String",13:"module",14:"Id",15:"at",16:"SEMICOLON",17:"IS",19:"OPEN_BRACE",21:"CLOSE_BRACE",22:"from",23:"import",25:"WILDCARD",28:"COMMA",29:"COLON",30:"export",36:"PERIOD"},productions_:[0,[3,1],[4,1],[4,2],[5,1],[5,1],[5,1],[5,1],[10,1],[10,1],[6,5],[6,5],[6,5],[18,1],[18,3],[7,5],[24,1],[24,1],[24,4],[27,3],[27,0],[26,1],[26,3],[8,4],[32,3],[32,0],[31,4],[31,1],[31,1],[31,3],[33,1],[33,3],[34,3],[34,0],[20,2],[20,2],[20,2],[20,0],[35,1],[35,1],[11,1],[11,3]],performAction:function(b,c,d,e,f,g,h){var i=g.length-1;switch(f){case 1:return g[i];case 2:this.$=g[i];break;case 3:this.$=g[i].length?g[i-1].concat(g[i]):g[i-1];break;case 4:this.$=[{type:"module",decl:g[i]}];break;case 5:this.$=[{type:"import",decl:g[i]}];break;case 6:this.$=[{type:"export",decl:g[i]}];break;case 7:this.$=[];break;case 8:this.$={type:"module",path:g[i]};break;case 9:this.$={type:"uri",path:g[i].trim().replace(/^(['"])(.*)\1$/,function(a,b,c,d){return c})};break;case 10:this.$={id:g[i-3],path:g[i-1].trim().replace(/^(['"])(.*)\1$/,function(a,b,c,d){return c})};break;case 11:this.$={id:g[i-3],src:g[i-1]};break;case 12:this.$={id:g[i-3],expressions:g[i-1]};break;case 13:this.$=g[i];break;case 14:var j={id:g[i-2]};j[g[i].type]=g[i].path,this.$=j;break;case 15:this.$={from:g[i-1],vars:g[i-3]};break;case 16:this.$=[g[i]];break;case 17:this.$=[g[i]];break;case 18:this.$=[g[i-2]].concat(g[i-1]);break;case 19:this.$=typeof g[i]!="undefined"?[g[i-1]].concat(g[i]):g[i-1];break;case 21:this.$=g[i];break;case 22:this.$={remote:g[i-2],local:g[i]};break;case 23:this.$=typeof g[i-1]!="undefined"?g[i-2].concat(g[i-1]):g[i-2];break;case 24:this.$=typeof g[i]!="undefined"?g[i-1].concat(g[i]):g[i-1];break;case 26:this.$=typeof g[i-1]!="undefined"?[g[i-2]].concat(g[i-1]):[g[i-2]];break;case 27:this.$=[g[i]];break;case 28:this.$=[g[i]];break;case 29:this.$=[{from:g[i]}];break;case 30:this.$=g[i];break;case 31:this.$={local:g[i-2],remote:g[i]};break;case 32:this.$=typeof g[i]!="undefined"?[g[i-1]].concat(g[i]):[g[i-1]];break;case 34:this.$=[{type:"module",decl:g[i-1]}].concat(g[i]);break;case 35:this.$=[{type:"import",decl:g[i-1]}].concat(g[i]);break;case 36:this.$=[{type:"export",decl:g[i-1]}].concat(g[i]);break;case 37:this.$=[];break;case 38:this.$=g[i];break;case 39:this.$=g[i];break;case 40:this.$=g[i];break;case 41:this.$=g[i-2]+"."+g[i]}},table:[{3:1,4:2,5:3,6:4,7:5,8:6,9:[1,7],13:[1,8],23:[1,9],30:[1,10]},{1:[3]},{1:[2,1]},{1:[2,2],4:11,5:3,6:4,7:5,8:6,9:[1,7],13:[1,8],23:[1,9],30:[1,10]},{1:[2,4],9:[2,4],13:[2,4],23:[2,4],30:[2,4]},{1:[2,5],9:[2,5],13:[2,5],23:[2,5],30:[2,5]},{1:[2,6],9:[2,6],13:[2,6],23:[2,6],30:[2,6]},{1:[2,7],9:[2,7],13:[2,7],23:[2,7],30:[2,7]},{14:[1,12]},{14:[1,14],19:[1,16],24:13,25:[1,15]},{14:[1,19],19:[1,18],25:[1,20],31:17},{1:[2,3]},{15:[1,21],17:[1,22],19:[1,23]},{22:[1,24]},{22:[2,16]},{22:[2,17]},{14:[1,26],26:25},{16:[2,25],28:[1,28],32:27},{14:[1,30],33:29},{16:[2,27],28:[2,27]},{16:[2,28],22:[1,31],28:[2,28]},{12:[1,32]},{14:[1,34],18:33},{6:36,7:37,8:38,13:[1,8],20:35,21:[2,37],23:[1,9],30:[1,10]},{10:39,11:40,12:[1,41],14:[1,42]},{21:[2,20],27:43,28:[1,44]},{21:[2,21],28:[2,21],29:[1,45]},{16:[1,46]},{14:[1,19],19:[1,18],25:[1,20],31:47},{21:[2,33],28:[1,49],34:48},{21:[2,30],28:[2,30],29:[1,50]},{11:51,14:[1,42]},{16:[1,52]},{16:[1,53]},{16:[2,13],22:[1,54]},{21:[1,55]},{6:36,7:37,8:38,13:[1,8],20:56,21:[2,37],23:[1,9],30:[1,10]},{6:36,7:37,8:38,13:[1,8],20:57,21:[2,37],23:[1,9],30:[1,10]},{6:36,7:37,8:38,13:[1,8],20:58,21:[2,37],23:[1,9],30:[1,10]},{16:[1,59]},{16:[2,8]},{16:[2,9]},{16:[2,40],21:[2,40],28:[2,40],36:[1,60]},{21:[1,61]},{14:[1,26],26:62},{11:63,14:[1,42]},{1:[2,23],9:[2,23],13:[2,23],21:[2,23],23:[2,23],30:[2,23]},{16:[2,25],28:[1,28],32:64},{21:[1,65]},{14:[1,30],33:66},{11:67,14:[1,42]},{16:[2,29],28:[2,29]},{1:[2,10],9:[2,10],13:[2,10],21:[2,10],23:[2,10],30:[2,10]},{1:[2,11],9:[2,11],13:[2,11],21:[2,11],23:[2,11],30:[2,11]},{10:68,11:40,12:[1,41],14:[1,42]},{1:[2,12],9:[2,12],13:[2,12],21:[2,12],23:[2,12],30:[2,12]},{21:[2,34]},{21:[2,35]},{21:[2,36]},{1:[2,15],9:[2,15],13:[2,15],21:[2,15],23:[2,15],30:[2,15]},{11:69,14:[1,42]},{22:[2,18]},{21:[2,20],27:70,28:[1,44]},{21:[2,22],28:[2,22]},{16:[2,24]},{16:[2,26],28:[2,26]},{21:[2,33],28:[1,49],34:71},{21:[2,31],28:[2,31]},{16:[2,14]},{16:[2,41],21:[2,41],28:[2,41]},{21:[2,19]},{21:[2,32]}],defaultActions:{2:[2,1],11:[2,3],14:[2,16],15:[2,17],40:[2,8],41:[2,9],56:[2,34],57:[2,35],58:[2,36],61:[2,18],64:[2,24],68:[2,14],70:[2,19],71:[2,32]},parseError:function(b,c){throw new Error(b)},parse:function(b){function o(a){d.length=d.length-2*a,e.length=e.length-a,f.length=f.length-a}function p(){var a;return a=c.lexer.lex()||1,typeof a!="number"&&(a=c.symbols_[a]||a),a}var c=this,d=[0],e=[null],f=[],g=this.table,h="",i=0,j=0,k=0,l=2,m=1;this.lexer.setInput(b),this.lexer.yy=this.yy,this.yy.lexer=this.lexer,typeof this.lexer.yylloc=="undefined"&&(this.lexer.yylloc={});var n=this.lexer.yylloc;f.push(n),typeof this.yy.parseError=="function"&&(this.parseError=this.yy.parseError);var q,r,s,t,u,v,w={},x,y,z,A;for(;;){s=d[d.length-1],this.defaultActions[s]?t=this.defaultActions[s]:(q==null&&(q=p()),t=g[s]&&g[s][q]);if(typeof t=="undefined"||!t.length||!t[0]){if(!k){A=[];for(x in g[s])this.terminals_[x]&&x>2&&A.push("'"+this.terminals_[x]+"'");var B="";this.lexer.showPosition?B="Parse error on line "+(i+1)+":\n"+this.lexer.showPosition()+"\nExpecting "+A.join(", ")+", got '"+this.terminals_[q]+"'":B="Parse error on line "+(i+1)+": Unexpected "+(q==1?"end of input":"'"+(this.terminals_[q]||q)+"'"),this.parseError(B,{text:this.lexer.match,token:this.terminals_[q]||q,line:this.lexer.yylineno,loc:n,expected:A})}if(k==3){if(q==m)throw new Error(B||"Parsing halted.");j=this.lexer.yyleng,h=this.lexer.yytext,i=this.lexer.yylineno,n=this.lexer.yylloc,q=p()}for(;;){if(l.toString()in g[s])break;if(s==0)throw new Error(B||"Parsing halted.");o(1),s=d[d.length-1]}r=q,q=l,s=d[d.length-1],t=g[s]&&g[s][l],k=3}if(t[0]instanceof Array&&t.length>1)throw new Error("Parse Error: multiple actions possible at state: "+s+", token: "+q);switch(t[0]){case 1:d.push(q),e.push(this.lexer.yytext),f.push(this.lexer.yylloc),d.push(t[1]),q=null,r?(q=r,r=null):(j=this.lexer.yyleng,h=this.lexer.yytext,i=this.lexer.yylineno,n=this.lexer.yylloc,k>0&&k--);break;case 2:y=this.productions_[t[1]][1],w.$=e[e.length-y],w._$={first_line:f[f.length-(y||1)].first_line,last_line:f[f.length-1].last_line,first_column:f[f.length-(y||1)].first_column,last_column:f[f.length-1].last_column},v=this.performAction.call(w,h,j,i,this.yy,t[1],e,f);if(typeof v!="undefined")return v;y&&(d=d.slice(0,-1*y*2),e=e.slice(0,-1*y),f=f.slice(0,-1*y)),d.push(this.productions_[t[1]][0]),e.push(w.$),f.push(w._$),z=g[d[d.length-2]][d[d.length-1]],d.push(z);break;case 3:return!0}}return!0}},b=function(){var a={EOF:1,parseError:function(b,c){if(!this.yy.parseError)throw new Error(b);this.yy.parseError(b,c)},setInput:function(a){return this._input=a,this._more=this._less=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this},input:function(){var a=this._input[0];this.yytext+=a,this.yyleng++,this.match+=a,this.matched+=a;var b=a.match(/\n/);return b&&this.yylineno++,this._input=this._input.slice(1),a},unput:function(a){return this._input=a+this._input,this},more:function(){return this._more=!0,this},pastInput:function(){var a=this.matched.substr(0,this.matched.length-this.match.length);return(a.length>20?"...":"")+a.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var a=this.match;return a.length<20&&(a+=this._input.substr(0,20-a.length)),(a.substr(0,20)+(a.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var a=this.pastInput(),b=(new Array(a.length+1)).join("-");return a+this.upcomingInput()+"\n"+b+"^"},next:function(){if(this.done)return this.EOF;this._input||(this.done=!0);var a,b,c,d,e,f;this._more||(this.yytext="",this.match="");var g=this._currentRules();for(var h=0;h<g.length;h++){c=this._input.match(this.rules[g[h]]);if(c&&(!b||c[0].length>b[0].length)){b=c,d=h;if(!this.options.flex)break}}if(b){f=b[0].match(/\n.*/g),f&&(this.yylineno+=f.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:f?f[f.length-1].length-1:this.yylloc.last_column+b[0].length},this.yytext+=b[0],this.match+=b[0],this.yyleng=this.yytext.length,this._more=!1,this._input=this._input.slice(b[0].length),this.matched+=b[0],a=this.performAction.call(this,this.yy,this,g[d],this.conditionStack[this.conditionStack.length-1]);if(a)return a;return}if(this._input==="")return this.EOF;this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){var b=this.next();return typeof b!="undefined"?b:this.lex()},begin:function(b){this.conditionStack.push(b)},popState:function(){return this.conditionStack.pop()},_currentRules:function(){return this.conditions[this.conditionStack[this.conditionStack.length-1]].rules},topState:function(){return this.conditionStack[this.conditionStack.length-2]},pushState:function(b){this.begin(b)}};return a.options={},a.performAction=function(b,c,d,e){var f=e;switch(d){case 0:break;case 1:break;case 2:break;case 3:return"SEMICOLON";case 4:return"COLON";case 5:return"OPEN_BRACE";case 6:return"CLOSE_BRACE";case 7:return"module";case 8:return"import";case 9:return"export";case 10:return 15;case 11:return 17;case 12:return 22;case 13:return"WILDCARD";case 14:return 28;case 15:return 36;case 16:return"Id";case 17:return"String";case 18:return"String";case 19:return 9}},a.rules=[/^\n+/,/^\s+/,/^\t+/,/^;/,/^:/,/^\{/,/^\}/,/^module\b/,/^import\b/,/^export\b/,/^at\b/,/^is\b/,/^from\b/,/^\*/,/^,/,/^\./,/^[a-zA-Z_$][0-9a-zA-Z_$]*/,/^'[^\']+'/,/^"[^\"]+"/,/^$/],a.conditions={INITIAL:{rules:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19],inclusive:!0}},a}();return a.lexer=b,a}();return typeof undefined!="undefined"&&typeof a!="undefined"&&(a.parser=b,a.parse=function(){return b.parse.apply(b,arguments)},a.main=function(c){if(!c[1])throw new Error("Usage: "+c[0]+" FILE");if(typeof process!="undefined")var d=undefined("fs").readFileSync(undefined("path").join(process.cwd(),c[1]),"utf8");else var e=undefined("file").path(undefined("file").cwd()),d=e.join(c[1]).read({charset:"utf-8"});return a.parser.parse(d)},typeof module!="undefined"&&undefined.main===module&&a.main(typeof process!="undefined"?process.argv.slice(1):undefined("system").args)),b})(),when)
View
53 src/shepherd.js
@@ -203,14 +203,9 @@
* @param {Object} moduleConf The result of the parsing of the module configuration
* @param {Function} callback The callback function to be called after the successful export
*/
- function _handleExports (module, moduleConf, callback) {
+ function _handleExports (module, moduleConf) {
moduleConf._internals.src && (modules[moduleConf._internals.src] = module);
- if (moduleConf.hasOwnProperty('name')) {
- moduleConf.name && (modules[moduleConf.name] = module); // Modules are accessible either via their name or their URI
- }
- if (is(callback, 'function')) {
- callback(module || {} );
- }
+ moduleConf.name && (modules[moduleConf.name] = module); // Modules are accessible either via their name or their URI
}
function loadClientSideModule (moduleConf, contents) {
@@ -351,12 +346,20 @@
moduleConf.imports = moduleConf.imports || {};
var _dep = modules[declaration.from.path];
if (_dep) {
- for (var i = 0, _l = declaration.vars.length; i < _l; i++) {
- var _importName = declaration.vars[i];
- moduleConf.imports[_importName] = _dep[_importName];
+
+ if (when.isPromise(_dep)) {
+ _dep.then(function (module) {
+ moduleConf.imports[_importName] = module;
+ });
+ confPromises.push(_dep);
+ } else {
+ for (var i = 0, _l = declaration.vars.length; i < _l; i++) {
+ var _importName = declaration.vars[i];
+ moduleConf.imports[_importName] = _dep[_importName];
+ }
}
} else {
- confPromises.push(_module(
+ var _p = _module(
declaration.from.path,
function (module) {
for (var i = 0, _l = declaration.vars.length; i < _l; i++) {
@@ -365,7 +368,9 @@
}
},
errorFn
- ));
+ );
+ modules[declaration.from.path] = _p;
+ confPromises.push(_p);
}
}
@@ -397,17 +402,31 @@
}
} else { //This is a module reference
moduleConf.imports = moduleConf.imports || {};
- var ref = declaration.path || declaration.src;
- if (modules[ref]) { //The module has already been loaded
- moduleConf.imports[declaration.id] = modules[declaration.src];
+ var ref = declaration.path || declaration.src || declaration.id;
+ var _mod = modules[ref];
+
+
+ //@FIX WTF means this if/else ???????
+ if (_mod) { //The module has already been loaded
+ if (when.isPromise(_mod)) {
+ _mod.then(function (module) {
+ moduleConf.imports[declaration.id] = module;
+ return module;
+ });
+ confPromises.push(_mod);
+ } else {
+ moduleConf.imports[declaration.id] = _mod;
+ }
} else if (declaration.path) {
- confPromises.push(_module(
+ var _p = _module(
declaration.path,
function (module) {
moduleConf.imports[declaration.id] = module;
return moduleConf;
}
- ));
+ );
+ //modules[declaration.path] = _p;
+ confPromises.push(_p);
} else {
if (_isServer) {
var _dep;
Please sign in to comment.
Something went wrong with that request. Please try again.