Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

includejs

Package Overview
Dependencies
Maintainers
1
Versions
160
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

includejs - npm Package Compare versions

Comparing version 0.9.11 to 0.9.12

2

bower.json
{
"name": "includejs",
"version": "0.9.11",
"version": "0.9.12",
"homepage": "https://github.com/atmajs/IncludeJS",

@@ -5,0 +5,0 @@ "authors": [

@@ -11,3 +11,3 @@

.instance()
.embed('/socket.io/socket.io.js')
.embed(window.location.origin + '/socket.io/socket.io.js')
.done(SocketIOReady);

@@ -14,0 +14,0 @@ }

@@ -1,2 +0,2 @@

function __eval(e,t){"use strict";t&&t.route.params;return eval.call(window,e)}!function(e,t){"use strict";var n,r;return"undefined"==typeof exports||e!==exports&&null!=e||(n=r=global),null==n&&(n="undefined"==typeof window?global:window),null==r&&(r=e||n),"undefined"!=typeof include&&"function"==typeof include.js?(r.include=include,void(r.includeLib=include.Lib||n.includeLib)):void t(n,r,n.document)}(this,function(global,exports,document){"use strict";function fn_proxy(e,t){return function(){e.apply(t,arguments)}}function fn_doNothing(e){"function"==typeof e&&e()}function arr_invoke(e,t,n){if(null!=e&&e instanceof Array!=!1)for(var r=0,o=e.length;o>r;r++)"function"==typeof e[r]&&(null==t?e[r].call(n):e[r].apply(n,t))}function arr_ensure(e,t){if(!t)return e;for(var n,r=t.split("."),o=r.length-1,s=0;o>s;s++)n=r[s],e=e[n]||(e[n]={});return n=r[o],e[n]||(e[n]=[])}var bin={js:{},css:{},load:{}},isWeb=!!(global.location&&global.location.protocol&&/^https?:/.test(global.location.protocol)),reg_subFolder=/([^\/]+\/)?\.\.\//,reg_hasProtocol=/^(file|https?):/i,cfg={path:null,loader:null,version:null,lockedToFolder:null,sync:null,eval:null==document},handler={},hasOwnProp={}.hasOwnProperty,emptyResponse={load:{}},__array_slice=Array.prototype.slice,XMLHttpRequest=global.XMLHttpRequest,Helper={reportError:function(e){console.error("IncludeJS Error:",e,e.message,e.url),"function"==typeof handler.onerror&&handler.onerror(e)}},XHR=function(e,t){var n=new XMLHttpRequest;n.onreadystatechange=function(){4===n.readyState&&t&&t(e,n.responseText)},n.open("GET","object"==typeof e?e.url:e,!0),n.send()},obj_inherit,obj_getProperty,obj_setProperty;!function(){obj_inherit=function(e){"function"==typeof e&&(e=e.prototype);for(var t,n,r=1,o=arguments.length;o>r;r++){t="function"==typeof arguments[r]?arguments[r].prototype:arguments[r];for(n in t)e[n]=t[n]}return e},obj_getProperty=function(e,t){for(var n=t.split("."),r=n.length,o=0;r>o;o++){if(null==e)return null;e=e[n[o]]}return e},obj_setProperty=function(e,t,n){for(var r,o=t.split("."),s=o.length-1,i=-1;++i<s;)r=o[i],null==e[r]&&(e[r]={}),e=e[r];e[o[i]]=n}}();var path_getDir,path_getFile,path_getExtension,path_resolveCurrent,path_normalize,path_win32Normalize,path_resolveUrl,path_combine,path_isRelative;!function(){function e(e){for(;-1!==e.indexOf("../");)e=e.replace(reg_subFolder,"");return e.replace(/\/\.\//g,"/")}path_getDir=function(e){return e.substring(0,e.lastIndexOf("/")+1)},path_getFile=function(e){return e=e.replace("file://","").replace(/\\/g,"/").replace(/\?[^\n]+$/,""),/^\/\w+:\/[^\/]/i.test(e)?e.substring(1):e},path_getExtension=function(e){var t=e.indexOf("?");return-1===t?e.substring(e.lastIndexOf(".")+1):e.substring(e.lastIndexOf(".",t)+1,t)},path_resolveCurrent=function(){if(null==document)return"undefined"==typeof module?"":path_win32Normalize(module.parent.filename);var e=document.getElementsByTagName("script"),t=e[e.length-1],n=t&&t.getAttribute("src")||"";if("/"===n[0])return n;var r=window.location.pathname.replace(/\/[^\/]+\.\w+$/,"");return"/"!==r[r.length-1]&&(r+="/"),r+n},path_normalize=function(e){return e.replace(/\\/g,"/").replace(/([^:\/])\/{2,}/g,"$1/")},path_win32Normalize=function(e){return e=path_normalize(e),"file:"===e.substring(0,5)?e:"file:///"+e},path_resolveUrl=function(t,n){return reg_hasProtocol.test(t)?e(t):("./"===t.substring(0,2)&&(t=t.substring(2)),"/"===t[0]&&null!=n&&null!=n.base&&(t=path_combine(n.base,t),reg_hasProtocol.test(t))?e(t):"/"===t[0]&&cfg.path&&(t=cfg.path+t.substring(1),reg_hasProtocol.test(t))?e(t):("/"===t[0]?(isWeb===!1||cfg.lockedToFolder===!0)&&(t=t.substring(1)):null!=n&&null!=n.location&&(t=n.location+t),e(t)))},path_isRelative=function(e){var t=e.charCodeAt(0);switch(t){case 47:return!1;case 102:case 104:return reg_hasProtocol.test(e)===!1}return!0},path_combine=function(){for(var e,t="",n=arguments.length,r=-1;++r<n;)e=arguments[r],e&&(e=path_normalize(e),""!==t?("/"!==t[t.length-1]&&(t+="/"),"/"===e[0]&&(e=e.substring(1)),t+=e):t=e);return t}}();var tree_resolveUsage;!function(){function e(t,n,r){if(null==n){console.warn("<include> Usage Not Found:",t),console.warn("- Ensure to have it included before with the correct alias"),console.warn("- Initiator Stacktrace:");for(var o=[],s=r;null!=s;)o.push(s.url),s=s.parent;return console.warn(o.join("\n")),null}for(var i,a,l=n.includes,u=-1,c=l.length;++u<c;)if(i=l[u],a=i.route.alias||Routes.parseAlias(i.route),a===t)return i.resource;return e(t,n.parent,r)}tree_resolveUsage=function(t,n,r){for(var o,s,i,a,l,u=[],c=n.length,f=-1;++f<c;){if(i=s=n[f],a=s.indexOf("."),-1!==a&&(i=s.substring(0,a),s=s.substring(a+1)),l=e(i,t.parent,t),null==l)return null;if(4!==l.state)return t.state=3,l.on(4,r,l,"push"),null;o=l.exports,i!==s&&(o=obj_getProperty(o,s)),"object"==typeof o&&null==o&&console.warn("<include:use> Used resource has no exports",i,t.url),u[f]=o}return u}}();var RoutesLib=function(){var e={},t=/([^\\\/]+)\.\w+$/;return{register:function(t,n,r){if("string"==typeof n&&path_isRelative(n)){var o=r||include,s=o.location||path_getDir(o.url||path_resolveCurrent());path_isRelative(s)&&(s="/"+s),n=s+n}e[t]=n instanceof Array?n:n.split(/[\{\}]/g)},resolve:function(t,n){var r,o,s,i,a,l,u,c,f=n.indexOf("?"),h=n.indexOf("::");if(-1!==h&&(r=n.substring(h+2),n=n.substring(0,h)),-1!==f){for(c=n.substring(f+1).split("&"),s={},a=0,u=c.length;u>a;a++)l=c[a].split("="),s[l[0]]=l[1];n=n.substring(0,f)}if(n=n.split("/"),i=e[t],null==i)return{path:n.join("/"),params:s,alias:r};for(o=i[0],a=1;a<i.length;a++)if(a%2===0)o+=i[a];else{var d=i[a]<<0;if(d>n.length-1&&(d=n.length-1),o+=n[d],a===i.length-2)for(d++;d<n.length;d++)o+="/"+n[d]}return{path:o,params:s,alias:r}},each:function(e,t,n,r,o){var s;if(null!=t)if("lazy"!==e||null!=o)if(t instanceof Array)for(var i=0;i<t.length;i++)this.each(e,t[i],n,r,o);else if("object"!=typeof t){if("string"==typeof t){var a=this.resolve(r,t);return r&&(r+="."+t),void n(r,a,o)}console.error("Include Package is invalid",arguments)}else for(s in t)hasOwnProp.call(t,s)&&this.each(e,t[s],n,s,o);else for(s in t)this.each(e,t[s],n,null,s)},getRoutes:function(){return e},parseAlias:function(e){var n=e.path,r=t.exec(n);return r&&r[1]}}},Routes=RoutesLib(),Events=function(e){function t(){Events.ready=fn_doNothing,null!=n&&(arr_invoke(n),n=null)}if(null==e)return{ready:fn_doNothing,load:fn_doNothing};var n=[];return"onreadystatechange"in e?e.onreadystatechange=function(){/complete|interactive/g.test(e.readyState)!==!1&&t()}:e.addEventListener?e.addEventListener("DOMContentLoaded",t):window.onload=t,{ready:function(e){n.unshift(e)}}}(document),ScriptStack=function(){function e(e,t){var n=document.createElement("script");n.type="text/javascript",n.src=e,"onreadystatechange"in n?n.onreadystatechange=function(){("complete"===this.readyState||"loaded"===this.readyState)&&t()}:n.onload=n.onerror=t,(o||(o=document.getElementsByTagName("head")[0])).appendChild(n)}function t(){function n(e){e&&"error"===e.type&&console.log("Script Loaded Error",o.url);for(var n=0,r=a.length;r>n;n++)if(a[n]===o){a.splice(n,1);break}return n===r?void console.error("Loaded Resource not found in stack",o):(2.5!==o.state&&o.readystatechanged(3),s=null,void t())}if(!i){if(0===a.length)return void r();if(null==s){var o=s=a[0];if(1!==o.state)return o.state=1,global.include=o,global.iparams=o.route.params,o.source?(__eval(o.source,o),void n()):void e(o.url,n)}}}function n(){if(!i){if(0===a.length)return void r();if(null==s){var e=a[0];if(!(e.state<2)){s=e,e.state=1,global.include=e,__eval(e.source,e);for(var t,o=0,l=a.length;l>o;o++)if(t=a[o],t===e){a.splice(o,1);break}2.5!==e.state&&e.readystatechanged(3),s=null,n()}}}}function r(){for(var e=-1,t=l.length;++e<t;)l[e]();l.length=0}var o,s,i,a=[],l=[];return{load:function(e,r,o){return this.add(e,r),!cfg.eval||o?void t():e.source?(e.state=2,void n()):void XHR(e,function(e,t){t||(console.error("Not Loaded:",e.url),console.error("- Initiator:",e.parent&&e.parent.url||"<root resource>")),e.source=t,e.state=2,n()})},add:function(e,t){if(1===e.priority)return a.unshift(e);if(null==t)return a.push(e);for(var n=a.length,r=-1;++r<n;)if(a[r]===t)return a.splice(r,0,e);a.push(e)},moveToParent:function(e,t){var n,r=a.length,o=-1,s=-1;for(n=0;r>n;n++)if(a[n]===e){s=n;break}if(-1!==s){for(n=0;r>n;n++)if(a[n]===t){o=n;break}-1!==o&&(o>s||(a.splice(s,1),a.splice(o,0,e)))}},pause:function(){i=!0},resume:function(){i=!1,null==s&&this.touch()},touch:function(){var e=cfg.eval?n:t;e()},complete:function(e){return i!==!0&&0===a.length?void e():void l.push(e)}}}(),IncludeDeferred=function(){this.callbacks=[],this.state=-1};IncludeDeferred.prototype={on:function(e,t,n,r){return this===n&&-1===this.state?(t(this),this):(null==r&&(r=this.state<3||this===n?"unshift":"push"),e<=this.state?t(this):this.callbacks[r]({state:e,callback:t}),this)},readystatechanged:function(e){var t,n,r,o;if(e>this.state&&(this.state=e),3===this.state){var s=this.includes;if(null!=s&&s.length)for(t=0;t<s.length;t++)if(4!==s[t].resource.state)return;this.state=4}if(t=0,n=this.callbacks.length,0!==n){for("js"===this.type&&4===this.state&&(o=global.include,global.include=this);n>t&&(r=this.callbacks[t],null==r||r.state>this.state||(this.callbacks.splice(t,1),n--,t--,r.callback(this),!(this.state<4)));t++);null!=o&&(global.include=o)}},ready:function(e){var t=this;return this.on(4,function(){Events.ready(function(){t.resolve(e)})},this)},done:function(e){var t=this;return this.on(4,function(){t.resolve(e)},this)},resolve:function(e){var t=this.includes,n=null==t?0:t.length;if(n>0&&null==this.response){this.response={};for(var r,o,s,i=0;n>i;i++)if(s=t[i],r=s.resource,o=s.route,"undefined"!=typeof r.exports){var a=r.type;switch(a){case"js":case"load":case"ajax":var l=o.alias||Routes.parseAlias(o),u="js"===a?this.response:this.response[a]||(this.response[a]={});if(null!=l){obj_setProperty(u,l,r.exports);break}console.warn("<includejs> Alias is undefined",r)}}}var c=this.response||emptyResponse,f=this;return null==this._use&&null!=this._usage&&(this._use=tree_resolveUsage(this,this._usage,function(){f.state=4,f.resolve(e),f.readystatechanged(4)}),this.state<4)?void 0:this._use?void e.apply(null,[c].concat(this._use)):void e(c)}};var Include,IncludeLib={};!function(IncludeDeferred){function incl_getResource(e,t){var n=e;if(path_isRelative(e)===!0&&(n="/"+n),null!=t)return bin[t][n];for(var r in bin)if(bin[r].hasOwnProperty(n))return bin[r][n];return null}function embedPlugin(source){eval(source)}function enableModules(){return"undefined"==typeof Object.defineProperty?void console.warn("Browser do not support Object.defineProperty"):(Object.defineProperty(global,"module",{get:function(){return global.include}}),void Object.defineProperty(global,"exports",{get:function(){var e=global.include;return e.exports||(e.exports={})},set:function(e){global.include.exports=e}}))}function includePackage(e,t,n){var r=1===n.length?n[0]:__array_slice.call(n);return e instanceof Resource?e.include(t,r):new Resource("js").include(t,r)}function createIncluder(e){return function(){return includePackage(this,e,arguments)}}function doNothing(){return this}function stub_freeze(e){e.js=e.css=e.load=e.ajax=e.embed=e.lazy=e.inject=doNothing}function stub_release(e){for(var t=["js","css","load","ajax","embed","lazy"],n=t.length;-1!==--n;)e[t[n]]=createIncluder(t[n]);e.inject=e.js}Include=function(){IncludeDeferred.call(this)},stub_release(Include.prototype),obj_inherit(Include,IncludeDeferred,{_use:null,_usage:null,isBrowser:!0,isNode:!1,setCurrent:function(e){var t=e.url,n=this.getResourceById(t,"js");if(null==n){"/"===t[0]&&this.base&&(t=this.base+t.substring(1));var n=new Resource("js",{path:t},e.namespace,null,null,t)}n.state<3&&console.error("<include> Resource should be loaded",e),n.state=3,global.include=n},cfg:function(e){switch(typeof e){case"object":var t,n;for(t in e)switch(n=e[t],t){case"loader":for(var r in n)CustomLoader.register(r,n[r]);break;case"modules":n===!0&&enableModules();break;default:cfg[t]=n}break;case"string":if(1===arguments.length)return cfg[e];2===arguments.length&&(cfg[e]=arguments[1]);break;case"undefined":return cfg}return this},routes:function(e){if(null==e)return Routes.getRoutes();if(2===arguments.length)return Routes.register(e,arguments[1],this),this;for(var t in e)Routes.register(t,e[t],this);return this},promise:function(e){for(var t=e.split("."),n=global;t.length;){var r=t.shift();n=n[r]||(n[r]={})}return n},register:function(e){function t(e){return null==l?e:("/"===e.url[0]&&(e.url=l+e.url.substring(1)),"/"===e.parent[0]&&(e.parent=l+e.parent.substring(1)),e.id=e.url,e)}function n(e,t){e.exports=t,e.readystatechanged(4)}var r,o,s,i,a,l=this.base;for(r in e)for(s=e[r],i=s.length,a=-1;++a<i;){o=t(s[a]);var u=o.id,c=o.url,f=o.namespace,h=o.parent&&incl_getResource(o.parent,"js"),d=new Resource,p=o.state;if(u||c){switch(c&&("/"===c[0]&&(c=c.substring(1)),d.location=path_getDir(c)),d.state=null==p?"js"===r?3:4:p,d.namespace=f,d.type=r,d.url=c||u,d.parent=h,d.base=h&&h.base||l,r){case"load":case"lazy":var g=document.querySelector("#includejs-"+u.replace(/\W/g,""));if(null==g){console.error('"%s" Data was not embedded into html',u);break}d.exports=g.innerHTML,CustomLoader.exists(d)&&(d.state=3,CustomLoader.load(d,n))}(bin[r]||(bin[r]={}))[u]=d}}},instance:function(e,t){var n;return null==e?(n=new Include,n.state=4,n):(n=new Resource,n.state=4,n.location=path_getDir(path_normalize(e)),n.parent=t,n)},getResource:function(e,t){return this.base&&"/"===e[0]&&(e=this.base+e.substring(1)),incl_getResource(e,t)},getResourceById:function(e,t){var n=bin[t],r=n[e];return null!=r?r:this.base&&"/"===e[0]&&(r=n[path_combine(this.base,e)],null!=r)?r:this.base&&this.location&&(r=n[path_combine(this.base,this.location,e)],null!=r)?r:this.location&&(r=n[path_combine(this.location,e)],null!=r)?r:null},getResources:function(){return bin},plugin:function(e,t){var n=[],r=0,o=0,s=0,i=function(e,n){o++,embedPlugin(n),o===r-1&&t&&(t(),t=null)};for(Routes.each("",e,function(e,t){n.push("/"===t.path[0]?t.path.substring(1):t.path)}),r=n.length;r>s;s++)XHR(n[s],i);return this},client:function(){return cfg.server===!0&&stub_freeze(this),this},server:function(){return cfg.server!==!0&&stub_freeze(this),this},use:function(){return null==this.parent?(console.error("<include.use> Parent resource is undefined"),this):(this._usage=arguments,this)},pauseStack:fn_proxy(ScriptStack.pause,ScriptStack),resumeStack:fn_proxy(ScriptStack.resume,ScriptStack),allDone:function(e){ScriptStack.complete(function(){function t(){--r<1&&e()}var n=include.getPending(),r=n.length;if(0===r)return void e();for(var o=-1,s=r;++o<s;)n[o].on(4,t,null,"push")})},getPending:function(e){var t,n,r,o=[];for(n in bin)if(null==e||e===n)for(r in bin[n])t=bin[n][r],t.state<4&&o.push(t);return o},Lib:IncludeLib})}(IncludeDeferred);var CustomLoader=function(){function e(e){return"string"==typeof e?!1:"function"==typeof e.ready||"function"==typeof e.process}function t(t){var n=path_getExtension(t),r=cfg.loader[n];if(e(r))return r;var o,s=r;if("object"==typeof s)for(var i in s){o=i,s=s[i];break}return cfg.loader[n]=new Resource("js",Routes.resolve(o,s),o,null,null,null,1)}function n(e,t){return function(n){e(t,n)}}function r(e,t,r,o){if(null==r.process)return void o(t,e);var s=n(o,t),i=r.process(e,t,s);"undefined"!=typeof i&&o(t,i)}function o(e,t,n){function o(e,o){r(o,e,t,n)}return"string"==typeof e.exports?void r(e.exports,e,t,n):t.load?t.load(e,o):void XHR(e,o)}var s={process:function(e){try{return JSON.parse(e)}catch(t){return console.error(t,e),null}}};return cfg.loader={json:s},{load:function(e,n){var r=t(e.url);return r.process?void o(e,r,n):void r.on(4,function(){o(e,r.exports,n)},null,"push")},exists:function(e){if(!e.url)return!1;var t=path_getExtension(e.url);return cfg.loader.hasOwnProperty(t)},register:function(e,t){if("string"==typeof t){var n=include;null==n.location&&(n={location:path_getDir(path_resolveCurrent())}),t=path_resolveUrl(t,n)}cfg.loader[e]=t}}}(),LazyModule={create:function(e,t){for(var n=e.split("."),r=global,o=n[n.length-1];n.length>1;){var s=n.shift();r=r[s]||(r[s]={})}n=null,Object.defineProperty(r,o,{get:function(){delete r[o];try{var n=__eval(t,global.include);null==n||n instanceof Resource||(r[o]=n)}catch(s){s.xpath=e,Helper.reportError(s)}finally{return t=null,e=null,r[o]}}})}},Resource;!function(e,t,n,r){function o(e){var t=e.type,o=e.parent,i=e.url;if(null==document&&"css"===t)return e.state=4,e;if(r.exists(e)===!1)switch(t){case"js":case"embed":n.load(e,o,"embed"===t);break;case"ajax":case"load":case"lazy":XHR(e,s);break;case"css":e.state=4;var a=document.createElement("link");a.href=i,a.rel="stylesheet",a.type="text/css",document.getElementsByTagName("head")[0].appendChild(a)}else("js"===t||"embed"===t)&&n.add(e,e.parent),r.load(e,s);return e}function s(e,t){switch(t||console.warn("Resource cannt be loaded",e.url),e.type){case"js":case"embed":return e.source=t,e.state=2,void n.touch();case"load":case"ajax":e.exports=t;break;case"lazy":LazyModule.create(e.xpath,t);break;case"css":var r=document.createElement("style");r.type="text/css",r.innerHTML=t,document.getElementsByTagName("head")[0].appendChild(r)}e.readystatechanged(4)}function i(e,t,n){if(null==e)return null;null==n&&(n=[]);for(var r,o=e.length,s=-1;++s<o;)r=e[s].resource,t===r.type&&n.push(r),null!=r.includes&&i(r.includes,t,n);return n}Resource=function(t,r,s,i,a,l,u){e.call(this),this.childLoaded=fn_proxy(this.childLoaded,this);var c=r&&r.path;null!=c&&(this.url=c=path_resolveUrl(c,a)),this.type=t,this.xpath=i,this.route=r,this.parent=a,this.priority=u,this.namespace=s,this.base=a&&a.base,null==l&&c&&(l=(path_isRelative(c)?"/":"")+c);var f=bin[t]&&bin[t][l];return f?(f.state<4&&"js"===t&&n.moveToParent(f,a),f):null==c?(this.state=3,this.location=path_getDir(path_resolveCurrent()),this):(this.state=0,this.location=path_getDir(c),(bin[t]||(bin[t]={}))[l]=this,cfg.version&&(this.url+=(-1===this.url.indexOf("?")?"?":"&")+"v="+cfg.version),o(this))},Resource.prototype=obj_inherit(Resource,e,{state:null,location:null,includes:null,response:null,url:null,base:null,type:null,xpath:null,route:null,parent:null,priority:null,namespace:null,setBase:function(e){return this.base=e,this},childLoaded:function(){var e=this,t=e.includes;if(t&&t.length){if(e.state<3)return;for(var n=0;n<t.length;n++)if(4!==t[n].resource.state)return}e.readystatechanged(4)},create:function(e,t,n,r,o){var s;return this.state=this.state>=3?3:2,this.response=null,null==this.includes&&(this.includes=[]),s=new Resource(e,t,n,r,this,o),this.includes.push({resource:s,route:t}),s},include:function(e,n){var r,o=this,s=[];t.each(e,n,function(t,n,i){(null==o.route||o.route.path!==n.path)&&(r=o.create(e,n,t,i),s.push(r))});for(var i=-1,a=s.length;++i<a;)s[i].on(4,this.childLoaded);return this},pause:function(){this.state=2.5;var e=this;return function(t){1===arguments.length&&(e.exports=t),e.readystatechanged(3)}},getNestedOfType:function(e){return i(this.includes,e)}})}(Include,Routes,ScriptStack,CustomLoader),IncludeLib.Routes=RoutesLib,IncludeLib.Resource=Resource,IncludeLib.ScriptStack=ScriptStack,IncludeLib.registerLoader=CustomLoader.register,exports.include=new Include,exports.includeLib=IncludeLib});
function __eval(e,t){"use strict";t&&t.route.params;return eval.call(window,e)}!function(e,t){"use strict";var n,r;return"undefined"==typeof exports||e!==exports&&null!=e||(n=r=global),null==n&&(n="undefined"==typeof window?global:window),null==r&&(r=e||n),"undefined"!=typeof include&&"function"==typeof include.js?(r.include=include,void(r.includeLib=include.Lib||n.includeLib)):void t(n,r,n.document)}(this,function(global,exports,document){"use strict";function fn_proxy(e,t){return function(){e.apply(t,arguments)}}function fn_doNothing(e){"function"==typeof e&&e()}function arr_invoke(e,t,n){if(null!=e&&e instanceof Array!=!1)for(var r=0,o=e.length;o>r;r++)"function"==typeof e[r]&&(null==t?e[r].call(n):e[r].apply(n,t))}function arr_ensure(e,t){if(!t)return e;for(var n,r=t.split("."),o=r.length-1,s=0;o>s;s++)n=r[s],e=e[n]||(e[n]={});return n=r[o],e[n]||(e[n]=[])}var bin={js:{},css:{},load:{}},isWeb=!!(global.location&&global.location.protocol&&/^https?:/.test(global.location.protocol)),reg_subFolder=/([^\/]+\/)?\.\.\//,reg_hasProtocol=/^(file|https?):/i,cfg={path:null,loader:null,version:null,lockedToFolder:null,sync:null,eval:null==document},handler={},hasOwnProp={}.hasOwnProperty,emptyResponse={load:{}},__array_slice=Array.prototype.slice,XMLHttpRequest=global.XMLHttpRequest,Helper={reportError:function(e){console.error("IncludeJS Error:",e,e.message,e.url),"function"==typeof handler.onerror&&handler.onerror(e)}},XHR=function(e,t){var n=new XMLHttpRequest;n.onreadystatechange=function(){4===n.readyState&&t&&t(e,n.responseText)},n.open("GET","object"==typeof e?e.url:e,!0),n.send()},obj_inherit,obj_getProperty,obj_setProperty;!function(){obj_inherit=function(e){"function"==typeof e&&(e=e.prototype);for(var t,n,r=1,o=arguments.length;o>r;r++){t="function"==typeof arguments[r]?arguments[r].prototype:arguments[r];for(n in t)e[n]=t[n]}return e},obj_getProperty=function(e,t){for(var n=t.split("."),r=n.length,o=0;r>o;o++){if(null==e)return null;e=e[n[o]]}return e},obj_setProperty=function(e,t,n){for(var r,o=t.split("."),s=o.length-1,i=-1;++i<s;)r=o[i],null==e[r]&&(e[r]={}),e=e[r];e[o[i]]=n}}();var path_getDir,path_getFile,path_getExtension,path_resolveCurrent,path_normalize,path_win32Normalize,path_resolveUrl,path_combine,path_isRelative;!function(){function e(e){for(;-1!==e.indexOf("../");)e=e.replace(reg_subFolder,"");return e.replace(/\/\.\//g,"/")}path_getDir=function(e){return e.substring(0,e.lastIndexOf("/")+1)},path_getFile=function(e){return e=e.replace("file://","").replace(/\\/g,"/").replace(/\?[^\n]+$/,""),/^\/\w+:\/[^\/]/i.test(e)?e.substring(1):e},path_getExtension=function(e){var t=e.indexOf("?");return-1===t?e.substring(e.lastIndexOf(".")+1):e.substring(e.lastIndexOf(".",t)+1,t)},path_resolveCurrent=function(){if(null==document)return"undefined"==typeof module?"":path_win32Normalize(module.parent.filename);var e=document.getElementsByTagName("script"),t=e[e.length-1],n=t&&t.getAttribute("src")||"";if("/"===n[0])return n;var r=window.location.pathname.replace(/\/[^\/]+\.\w+$/,"");return"/"!==r[r.length-1]&&(r+="/"),r+n},path_normalize=function(e){return e.replace(/\\/g,"/").replace(/([^:\/])\/{2,}/g,"$1/")},path_win32Normalize=function(e){return e=path_normalize(e),"file:"===e.substring(0,5)?e:"file:///"+e},path_resolveUrl=function(t,n){return reg_hasProtocol.test(t)?e(t):("./"===t.substring(0,2)&&(t=t.substring(2)),"/"===t[0]&&null!=n&&null!=n.base&&(t=path_combine(n.base,t),reg_hasProtocol.test(t))?e(t):"/"===t[0]&&cfg.path&&(t=cfg.path+t.substring(1),reg_hasProtocol.test(t))?e(t):("/"===t[0]?(isWeb===!1||cfg.lockedToFolder===!0)&&(t=t.substring(1)):null!=n&&null!=n.location&&(t=n.location+t),e(t)))},path_isRelative=function(e){var t=e.charCodeAt(0);switch(t){case 47:return!1;case 102:case 104:return reg_hasProtocol.test(e)===!1}return!0},path_combine=function(){for(var e,t="",n=arguments.length,r=-1;++r<n;)e=arguments[r],e&&(e=path_normalize(e),""!==t?("/"!==t[t.length-1]&&(t+="/"),"/"===e[0]&&(e=e.substring(1)),t+=e):t=e);return t}}();var tree_resolveUsage;!function(){function e(t,n,r){if(null==n){console.warn("<include> Usage Not Found:",t),console.warn("- Ensure to have it included before with the correct alias"),console.warn("- Initiator Stacktrace:");for(var o=[],s=r;null!=s;)o.push(s.url),s=s.parent;return console.warn(o.join("\n")),null}for(var i,a,l=n.includes,u=-1,c=l.length;++u<c;)if(i=l[u],a=i.route.alias||Routes.parseAlias(i.route),a===t)return i.resource;return e(t,n.parent,r)}tree_resolveUsage=function(t,n,r){for(var o,s,i,a,l,u=[],c=n.length,f=-1;++f<c;){if(i=s=n[f],a=s.indexOf("."),-1!==a&&(i=s.substring(0,a),s=s.substring(a+1)),l=e(i,t.parent,t),null==l)return null;if(4!==l.state)return t.state=3,l.on(4,r,l,"push"),null;o=l.exports,i!==s&&(o=obj_getProperty(o,s)),"object"==typeof o&&null==o&&console.warn("<include:use> Used resource has no exports",i,t.url),u[f]=o}return u}}();var RoutesLib=function(){var e={},t=/([^\\\/]+)\.\w+$/;return{register:function(t,n,r){if("string"==typeof n&&path_isRelative(n)){var o=r||include,s=o.location||path_getDir(o.url||path_resolveCurrent());path_isRelative(s)&&(s="/"+s),n=s+n}e[t]=n instanceof Array?n:n.split(/[\{\}]/g)},resolve:function(t,n){var r,o,s,i,a,l,u,c,f=n.indexOf("?"),h=n.indexOf("::");if(-1!==h&&(r=n.substring(h+2),n=n.substring(0,h)),-1!==f){for(c=n.substring(f+1).split("&"),s={},a=0,u=c.length;u>a;a++)l=c[a].split("="),s[l[0]]=l[1];n=n.substring(0,f)}if(n=n.split("/"),i=e[t],null==i)return{path:n.join("/"),params:s,alias:r};for(o=i[0],a=1;a<i.length;a++)if(a%2===0)o+=i[a];else{var d=i[a]<<0;if(d>n.length-1&&(d=n.length-1),o+=n[d],a===i.length-2)for(d++;d<n.length;d++)o+="/"+n[d]}return{path:o,params:s,alias:r}},each:function(e,t,n,r,o){var s;if(null!=t)if("lazy"!==e||null!=o)if(t instanceof Array)for(var i=0;i<t.length;i++)this.each(e,t[i],n,r,o);else if("object"!=typeof t){if("string"==typeof t){var a=this.resolve(r,t);return r&&(r+="."+t),void n(r,a,o)}console.error("Include Package is invalid",arguments)}else for(s in t)hasOwnProp.call(t,s)&&this.each(e,t[s],n,s,o);else for(s in t)this.each(e,t[s],n,null,s)},getRoutes:function(){return e},parseAlias:function(e){var n=e.path,r=t.exec(n);return r&&r[1]}}},Routes=RoutesLib(),Events=function(e){function t(){Events.ready=fn_doNothing,null!=n&&(arr_invoke(n),n=null)}if(null==e)return{ready:fn_doNothing,load:fn_doNothing};var n=[];return"onreadystatechange"in e?e.onreadystatechange=function(){/complete|interactive/g.test(e.readyState)!==!1&&t()}:e.addEventListener?e.addEventListener("DOMContentLoaded",t):window.onload=t,{ready:function(e){n.unshift(e)}}}(document),ScriptStack=function(){function e(e,t){var n=document.createElement("script");n.type="text/javascript",n.src=e,"onreadystatechange"in n?n.onreadystatechange=function(){("complete"===this.readyState||"loaded"===this.readyState)&&t()}:n.onload=n.onerror=t,(o||(o=document.getElementsByTagName("head")[0])).appendChild(n)}function t(){function n(e){e&&"error"===e.type&&console.log("Script Loaded Error",o.url);for(var n=0,r=a.length;r>n;n++)if(a[n]===o){a.splice(n,1);break}return n===r?void console.error("Loaded Resource not found in stack",o):(2.5!==o.state&&o.readystatechanged(3),s=null,void t())}if(!i){if(0===a.length)return void r();if(null==s){var o=s=a[0];if(1!==o.state)return o.state=1,global.include=o,global.iparams=o.route.params,o.source?(__eval(o.source,o),void n()):void e(o.url,n)}}}function n(){if(!i){if(0===a.length)return void r();if(null==s){var e=a[0];if(!(e.state<2)){s=e,e.state=1,global.include=e,__eval(e.source,e);for(var t,o=0,l=a.length;l>o;o++)if(t=a[o],t===e){a.splice(o,1);break}2.5!==e.state&&e.readystatechanged(3),s=null,n()}}}}function r(){for(var e=-1,t=l.length;++e<t;)l[e]();l.length=0}var o,s,i,a=[],l=[];return{load:function(e,r,o){return this.add(e,r),!cfg.eval||o?void t():e.source?(e.state=2,void n()):void XHR(e,function(e,t){t||(console.error("Not Loaded:",e.url),console.error("- Initiator:",e.parent&&e.parent.url||"<root resource>")),e.source=t,e.state=2,n()})},add:function(e,t){if(1===e.priority)return a.unshift(e);if(null==t)return a.push(e);for(var n=a.length,r=-1;++r<n;)if(a[r]===t)return a.splice(r,0,e);a.push(e)},moveToParent:function(e,t){var n,r=a.length,o=-1,s=-1;for(n=0;r>n;n++)if(a[n]===e){s=n;break}if(-1!==s){for(n=0;r>n;n++)if(a[n]===t){o=n;break}-1!==o&&(o>s||(a.splice(s,1),a.splice(o,0,e)))}},pause:function(){i=!0},resume:function(){i=!1,null==s&&this.touch()},touch:function(){var e=cfg.eval?n:t;e()},complete:function(e){return i!==!0&&0===a.length?void e():void l.push(e)}}}(),IncludeDeferred=function(){this.callbacks=[],this.state=-1};IncludeDeferred.prototype={on:function(e,t,n,r){return this===n&&-1===this.state?(t(this),this):(null==r&&(r=this.state<3||this===n?"unshift":"push"),e<=this.state?t(this):this.callbacks[r]({state:e,callback:t}),this)},readystatechanged:function(e){var t,n,r,o;if(e>this.state&&(this.state=e),3===this.state){var s=this.includes;if(null!=s&&s.length)for(t=0;t<s.length;t++)if(4!==s[t].resource.state)return;this.state=4}if(t=0,n=this.callbacks.length,0!==n){for("js"===this.type&&4===this.state&&(o=global.include,global.include=this);n>t&&(r=this.callbacks[t],null==r||r.state>this.state||(this.callbacks.splice(t,1),n--,t--,r.callback(this),!(this.state<4)));t++);null!=o&&(global.include=o)}},ready:function(e){var t=this;return this.on(4,function(){Events.ready(function(){t.resolve(e)})},this)},done:function(e){var t=this;return this.on(4,function(){t.resolve(e)},this)},resolve:function(e){var t=this.includes,n=null==t?0:t.length;if(n>0&&null==this.response){this.response={};for(var r,o,s,i=0;n>i;i++)if(s=t[i],r=s.resource,o=s.route,"undefined"!=typeof r.exports){var a=r.type;switch(a){case"js":case"load":case"ajax":var l=o.alias||Routes.parseAlias(o),u="js"===a?this.response:this.response[a]||(this.response[a]={});if(null!=l){obj_setProperty(u,l,r.exports);break}console.warn("<includejs> Alias is undefined",r)}}}var c=this.response||emptyResponse,f=this;return null==this._use&&null!=this._usage&&(this._use=tree_resolveUsage(this,this._usage,function(){f.state=4,f.resolve(e),f.readystatechanged(4)}),this.state<4)?void 0:this._use?void e.apply(null,[c].concat(this._use)):void e(c)}};var Include,IncludeLib={};!function(IncludeDeferred){function incl_getResource(e,t){var n=e;if(path_isRelative(e)===!0&&(n="/"+n),null!=t)return bin[t][n];for(var r in bin)if(bin[r].hasOwnProperty(n))return bin[r][n];return null}function embedPlugin(source){eval(source)}function enableModules(){return"undefined"==typeof Object.defineProperty?void console.warn("Browser do not support Object.defineProperty"):(Object.defineProperty(global,"module",{get:function(){return global.include}}),void Object.defineProperty(global,"exports",{get:function(){var e=global.include;return e.exports||(e.exports={})},set:function(e){global.include.exports=e}}))}function includePackage(e,t,n){var r=1===n.length?n[0]:__array_slice.call(n);return e instanceof Resource?e.include(t,r):new Resource("js").include(t,r)}function createIncluder(e){return function(){return includePackage(this,e,arguments)}}function doNothing(){return this}function stub_freeze(e){e.js=e.css=e.load=e.ajax=e.embed=e.lazy=e.inject=doNothing}function stub_release(e){for(var t=["js","css","load","ajax","embed","lazy"],n=t.length;-1!==--n;)e[t[n]]=createIncluder(t[n]);e.inject=e.js}Include=function(){IncludeDeferred.call(this)},stub_release(Include.prototype),obj_inherit(Include,IncludeDeferred,{_use:null,_usage:null,isBrowser:!0,isNode:!1,setCurrent:function(e){var t=e.url,n=this.getResourceById(t,"js");if(null==n){"/"===t[0]&&this.base&&(t=this.base+t.substring(1));var n=new Resource("js",{path:t},e.namespace,null,null,t)}n.state<3&&console.error("<include> Resource should be loaded",e),n.state=3,global.include=n},cfg:function(e){switch(typeof e){case"object":var t,n;for(t in e)switch(n=e[t],t){case"loader":for(var r in n)CustomLoader.register(r,n[r]);break;case"modules":n===!0&&enableModules();break;default:cfg[t]=n}break;case"string":if(1===arguments.length)return cfg[e];2===arguments.length&&(cfg[e]=arguments[1]);break;case"undefined":return cfg}return this},routes:function(e){if(null==e)return Routes.getRoutes();if(2===arguments.length)return Routes.register(e,arguments[1],this),this;for(var t in e)Routes.register(t,e[t],this);return this},promise:function(e){for(var t=e.split("."),n=global;t.length;){var r=t.shift();n=n[r]||(n[r]={})}return n},register:function(e){function t(e){return null==l?e:("/"===e.url[0]&&(e.url=l+e.url.substring(1)),"/"===e.parent[0]&&(e.parent=l+e.parent.substring(1)),e.id=e.url,e)}function n(e,t){e.exports=t,e.readystatechanged(4)}var r,o,s,i,a,l=this.base;for(r in e)for(s=e[r],i=s.length,a=-1;++a<i;){o=t(s[a]);var u=o.id,c=o.url,f=o.namespace,h=o.parent&&incl_getResource(o.parent,"js"),d=new Resource,p=o.state;if(u||c){switch(c&&("/"===c[0]&&(c=c.substring(1)),d.location=path_getDir(c)),d.state=null==p?"js"===r?3:4:p,d.namespace=f,d.type=r,d.url=c||u,d.parent=h,d.base=h&&h.base||l,r){case"load":case"lazy":var g=document.querySelector("#includejs-"+u.replace(/\W/g,""));if(null==g){console.error('"%s" Data was not embedded into html',u);break}d.exports=g.innerHTML,CustomLoader.exists(d)&&(d.state=3,CustomLoader.load(d,n))}(bin[r]||(bin[r]={}))[u]=d}}},instance:function(e,t){var n;return null==e?(n=new Include,n.state=4,n):(n=new Resource,n.state=4,n.location=path_getDir(path_normalize(e)),n.parent=t,n)},getResource:function(e,t){return this.base&&"/"===e[0]&&(e=this.base+e.substring(1)),incl_getResource(e,t)},getResourceById:function(e,t){var n=bin[t],r=n[e];return null!=r?r:this.base&&"/"===e[0]&&(r=n[path_combine(this.base,e)],null!=r)?r:this.base&&this.location&&(r=n[path_combine(this.base,this.location,e)],null!=r)?r:this.location&&(r=n[path_combine(this.location,e)],null!=r)?r:null},getResources:function(){return bin},plugin:function(e,t){var n=[],r=0,o=0,s=0,i=function(e,n){o++,embedPlugin(n),o===r-1&&t&&(t(),t=null)};for(Routes.each("",e,function(e,t){n.push("/"===t.path[0]?t.path.substring(1):t.path)}),r=n.length;r>s;s++)XHR(n[s],i);return this},client:function(){return cfg.server===!0&&stub_freeze(this),this},server:function(){return cfg.server!==!0&&stub_freeze(this),this},use:function(){return null==this.parent?(console.error("<include.use> Parent resource is undefined"),this):(this._usage=arguments,this)},pauseStack:fn_proxy(ScriptStack.pause,ScriptStack),resumeStack:fn_proxy(ScriptStack.resume,ScriptStack),allDone:function(e){ScriptStack.complete(function(){function t(){--r<1&&e()}var n=include.getPending(),r=n.length;if(0===r)return void e();for(var o=-1,s=r;++o<s;)n[o].on(4,t,null,"push")})},getPending:function(e){var t,n,r,o=[];for(n in bin)if(null==e||e===n)for(r in bin[n])t=bin[n][r],t.state<4&&o.push(t);return o},Lib:IncludeLib})}(IncludeDeferred);var CustomLoader=function(){function e(e){return"string"==typeof e?!1:"function"==typeof e.ready||"function"==typeof e.process}function t(t){var n=path_getExtension(t),r=cfg.loader[n];if(e(r))return r;var o,s=r;if("object"==typeof s)for(var i in s){o=i,s=s[i];break}return cfg.loader[n]=new Resource("js",Routes.resolve(o,s),o,null,null,null,1)}function n(e,t){return function(n){e(t,n)}}function r(e,t,r,o){if(null==r.process)return void o(t,e);var s=n(o,t),i=r.process(e,t,s);"undefined"!=typeof i&&o(t,i)}function o(e,t,n){function o(e,o){r(o,e,t,n)}return"string"==typeof e.exports?void r(e.exports,e,t,n):t.load?t.load(e,o):void XHR(e,o)}var s={process:function(e,t){try{return JSON.parse(e)}catch(n){return console.error(n,e),null}}};return cfg.loader={json:s},{load:function(e,n){var r=t(e.url);return r.process?void o(e,r,n):void r.on(4,function(){o(e,r.exports,n)},null,"push")},exists:function(e){if(!e.url)return!1;var t=path_getExtension(e.url);return cfg.loader.hasOwnProperty(t)},register:function(e,t){if("string"==typeof t){var n=include;null==n.location&&(n={location:path_getDir(path_resolveCurrent())}),t=path_resolveUrl(t,n)}cfg.loader[e]=t}}}(),LazyModule={create:function(e,t){for(var n=e.split("."),r=global,o=n[n.length-1];n.length>1;){var s=n.shift();r=r[s]||(r[s]={})}n=null,Object.defineProperty(r,o,{get:function(){delete r[o];try{var n=__eval(t,global.include);null==n||n instanceof Resource||(r[o]=n)}catch(s){s.xpath=e,Helper.reportError(s)}finally{return t=null,e=null,r[o]}}})}},Resource;!function(e,t,n,r){function o(e){var t=e.type,o=e.parent,i=e.url;if(null==document&&"css"===t)return e.state=4,e;if(r.exists(e)===!1)switch(t){case"js":case"embed":n.load(e,o,"embed"===t);break;case"ajax":case"load":case"lazy":XHR(e,s);break;case"css":e.state=4;var a=document.createElement("link");a.href=i,a.rel="stylesheet",a.type="text/css",document.getElementsByTagName("head")[0].appendChild(a)}else("js"===t||"embed"===t)&&n.add(e,e.parent),r.load(e,s);return e}function s(e,t){switch(t||console.warn("Resource cannt be loaded",e.url),e.type){case"js":case"embed":return e.source=t,e.state=2,void n.touch();case"load":case"ajax":e.exports=t;break;case"lazy":LazyModule.create(e.xpath,t);break;case"css":var r=document.createElement("style");r.type="text/css",r.innerHTML=t,document.getElementsByTagName("head")[0].appendChild(r)}e.readystatechanged(4)}function i(e,t,n){if(null==e)return null;null==n&&(n=[]);for(var r,o=e.length,s=-1;++s<o;)r=e[s].resource,t===r.type&&n.push(r),null!=r.includes&&i(r.includes,t,n);return n}Resource=function(t,r,s,i,a,l,u){e.call(this),this.childLoaded=fn_proxy(this.childLoaded,this);var c=r&&r.path;null!=c&&(this.url=c=path_resolveUrl(c,a)),this.type=t,this.xpath=i,this.route=r,this.parent=a,this.priority=u,this.namespace=s,this.base=a&&a.base,null==l&&c&&(l=(path_isRelative(c)?"/":"")+c);var f=bin[t]&&bin[t][l];return f?(f.state<4&&"js"===t&&n.moveToParent(f,a),f):null==c?(this.state=3,this.location=path_getDir(path_resolveCurrent()),this):(this.state=0,this.location=path_getDir(c),(bin[t]||(bin[t]={}))[l]=this,cfg.version&&(this.url+=(-1===this.url.indexOf("?")?"?":"&")+"v="+cfg.version),o(this))},Resource.prototype=obj_inherit(Resource,e,{state:null,location:null,includes:null,response:null,url:null,base:null,type:null,xpath:null,route:null,parent:null,priority:null,namespace:null,setBase:function(e){return this.base=e,this},childLoaded:function(e){var t=this,n=t.includes;if(n&&n.length){if(t.state<3)return;for(var r=0;r<n.length;r++)if(4!==n[r].resource.state)return}t.readystatechanged(4)},create:function(e,t,n,r,o){var s;return this.state=this.state>=3?3:2,this.response=null,null==this.includes&&(this.includes=[]),s=new Resource(e,t,n,r,this,o),this.includes.push({resource:s,route:t}),s},include:function(e,n){var r,o=this,s=[];t.each(e,n,function(t,n,i){(null==o.route||o.route.path!==n.path)&&(r=o.create(e,n,t,i),s.push(r))});for(var i=-1,a=s.length;++i<a;)s[i].on(4,this.childLoaded);return this},pause:function(){this.state=2.5;var e=this;return function(t){1===arguments.length&&(e.exports=t),e.readystatechanged(3)}},getNestedOfType:function(e){return i(this.includes,e)}})}(Include,Routes,ScriptStack,CustomLoader),IncludeLib.Routes=RoutesLib,IncludeLib.Resource=Resource,IncludeLib.ScriptStack=ScriptStack,IncludeLib.registerLoader=CustomLoader.register,exports.include=new Include,exports.includeLib=IncludeLib});
//# sourceMappingURL=include.min.js.map
{
"name": "includejs",
"description": "Resource Loader",
"version": "0.9.11",
"version": "0.9.12",
"homepage": "http://atmajs.com/include",

@@ -6,0 +6,0 @@ "contributors": [],

@@ -9,3 +9,3 @@ (function(global) {

.instance()
.embed('/socket.io/socket.io.js')
.embed(window.location.origin + '/socket.io/socket.io.js')
.done(SocketIOReady);

@@ -12,0 +12,0 @@ }

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc