nexusframework 0.3.0-beta.73 → 0.3.0-beta.74

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/LICENSE.md +55 -55
  2. package/README.md +12 -12
  3. package/about/index.json +5 -5
  4. package/about/index.nhp +4 -4
  5. package/icon.png +0 -0
  6. package/index.d.ts +0 -2
  7. package/index.js +0 -0
  8. package/index.js.map +1 -1
  9. package/index.ts +101 -101
  10. package/indexOfSkeleton.nhp +133 -133
  11. package/legacySkeleton.nhp +22 -22
  12. package/loader/overlay.css +1 -1
  13. package/loader/overlay.html +25 -25
  14. package/loader/overlay.scss +152 -152
  15. package/package.json +102 -90
  16. package/scripts/es5/compat.js +100 -100
  17. package/scripts/es5/compat.min.js +1 -1
  18. package/scripts/es5/loader.js +0 -0
  19. package/scripts/es5/loader.js.map +0 -0
  20. package/scripts/es5/loader.min.js +1 -1
  21. package/scripts/es5/loader.min.js.map +0 -0
  22. package/scripts/es5/nexusframeworkclient.js +1224 -1224
  23. package/scripts/es5/nexusframeworkclient.js.map +0 -0
  24. package/scripts/es5/nexusframeworkclient.min.js +1 -1
  25. package/scripts/es5/nexusframeworkclient.min.js.map +0 -0
  26. package/scripts/es6/compat.js +64 -64
  27. package/scripts/es6/compat.min.js +1 -1
  28. package/scripts/es6/loader.js +0 -0
  29. package/scripts/es6/loader.js.map +0 -0
  30. package/scripts/es6/loader.min.js +1 -1
  31. package/scripts/es6/loader.min.js.map +0 -0
  32. package/scripts/es6/nexusframeworkclient.js +1146 -1146
  33. package/scripts/es6/nexusframeworkclient.js.map +0 -0
  34. package/scripts/es6/nexusframeworkclient.min.js +1 -1
  35. package/scripts/es6/nexusframeworkclient.min.js.map +0 -0
  36. package/scripts/index.d.ts +259 -259
  37. package/scripts/src/compat.ts +62 -62
  38. package/scripts/src/loader.ts +385 -385
  39. package/scripts/src/nexusframeworkclient.ts +1163 -1163
  40. package/scripts/tsconfig.json +11 -11
  41. package/src/cli.d.ts +1 -0
  42. package/src/cli.js +102 -102
  43. package/src/cli.js.map +1 -1
  44. package/src/cli.ts +101 -101
  45. package/src/compileScripts.d.ts +0 -0
  46. package/src/compileScripts.js +0 -0
  47. package/src/compileScripts.js.map +1 -1
  48. package/src/compileScripts.ts +153 -153
  49. package/src/nexusframework.d.ts +5 -5
  50. package/src/nexusframework.js +44 -37
  51. package/src/nexusframework.js.map +1 -1
  52. package/src/nexusframework.ts +3631 -3622
  53. package/templates/basic/package.json +3 -3
  54. package/templates/basic/www/skeleton.nhp +1 -1
  55. package/templates/bootstrap/package.json +2 -2
  56. package/templates/bootstrap/www/skeleton.nhp +1 -1
  57. package/templates/bootstrap-material-design/package.json +2 -2
  58. package/templates/bootstrap-material-design/www/skeleton.nhp +1 -1
  59. package/tsconfig.json +25 -22
  60. package/types.d.ts +612 -612
File without changes
@@ -1,2 +1,2 @@
1
- !function(e){const t=new e.bson;Object.defineProperties(e,{NexusFrameworkTransport:{configurable:!0,set:function(t){Object.defineProperty(e,"NexusFrameworkTransport",{value:t})},get:function(){var r;if(!("XMLHttpRequest"in e))throw new Error("No transport implementations");{class e{constructor(e,t,r,o){this._url=t,this.request=e,this.hadData=r,this.abResponse=o}get url(){return this.request.responseURL||this._url}get code(){return this.request.status}get contentLength(){return parseInt(this.request.getResponseHeader("content-length"))||this.request.responseText.length}get contentFromJSON(){return this.parsedJson||(this.parsedJson=JSON.parse(this.request.responseText)),this.parsedJson}get contentFromBSON(){if(!this.parsedBson){var e=this.request.response;e="string"==typeof e?Buffer.from(e,"utf8"):new Buffer(e),this.parsedBson=t.deserialize(e,{promoteValues:!0})}return this.parsedBson}get contentAsString(){return this.request.responseText}get contentAsArrayBuffer(){return this.request.response}get headers(){if(!this.processedHeaders){const e=this.processedHeaders={};this.request.getAllResponseHeaders().split(/\r?\n/g).forEach(function(t){const r=t.indexOf(":");var o,n;r>0?(o=t.substring(0,r).trim().toLowerCase(),n=t.substring(r+1).trim()):o=t.trim().toLowerCase();var s=e[o];s||(s=e[o]=[]),n&&s.push(n)})}return this.processedHeaders}}const o=function(r,o,n,s,a,i,c){const l=new XMLHttpRequest;var d;try{if(!c)throw!1;if(l.responseType="arraybuffer","arraybuffer"!==l.responseType)throw console.error("Could not request arraybuffer"),!1;d=!0}catch(e){d=!1}l.open(r,o,!0),a&&Object.keys(a).forEach(function(e){l.setRequestHeader(e,a[e])}),i&&(l.onprogress=function(e){e.lengthComputable&&e.total&&i(e.loaded,e.total)}),l.onreadystatechange=function(t){l.readyState===XMLHttpRequest.DONE&&s(new e(l,o,!!n,d))};const u=n&&n.type;if(u)switch(u){case"":case"text/urlencoded":var h="";for(var p of n.data)h&&(h+="&"),h+=encodeURIComponent(p[0]),h+="=",h+=encodeURIComponent(p[1]);l.setRequestHeader("Content-Type","text/urlencoded"),l.send(h);break;case"text/json":l.setRequestHeader("Content-Type","text/json"),l.send(JSON.stringify(n.data));break;case"application/bson":l.setRequestHeader("Content-Type","application/bson"),l.send(t.serialize(n.data));break;case"multipart/form-data":l.send(n.data);break;default:l.send(n)}else l.send(n)};r={get:function(e,t,r,n,s){o("GET",e,void 0,t,r,n,s)},head:function(e,t,r,n,s){o("HEAD",e,void 0,t,r,n,s)},post:function(e,t,r,n,s,a){o("POST",e,t,r,n,s,a)},put:function(e,t,r,n,s,a){o("PUT",e,t,r,n,s,a)},execute:o,del:function(e,t,r,n,s){o("DELETE",e,void 0,t,r,n,s)}}}return Object.defineProperty(e,"NexusFrameworkTransport",{value:r}),r}},NexusFrameworkImpl:{configurable:!0,set:function(t){Object.defineProperty(e,"NexusFrameworkImpl",{value:t})},get:function(){const t=e.NexusFrameworkLoader,r=t.showError,o=console.log.bind(console),n={reportError:function(t,r){if(e.ga)try{e.ga("send","exception",{exDescription:(t.stack||""+t).replace(/\n/g,"\n\t"),exFatal:r})}catch(e){console.warn(e)}},reportEvent:function(t,r,o,n){if(e.ga)try{e.ga("send","event",t,r,o,n)}catch(e){console.warn(e)}},reportPage:function(t){if(e.ga)try{t||(t=location.pathname),e.ga("set","page",t),e.ga("send","pageview")}catch(e){console.warn(e)}}},s=document.createElement("a"),a=location.href.match(/^\w+:/)[0],i=function(e){s.setAttribute("href",e);var t=s.href;return/^\/\//.test(t)&&(t=a+t),t},c=function(e,t=location.href){var r;return"string"==typeof e.data?{url:t,code:e.code,contentAsString:e.data,get contentLength(){return parseInt(e.headers["content-length"]&&e.headers["content-length"][0])||e.data.length},get contentAsArrayBuffer(){throw new Error("Not implemented")},get contentFromBSON(){return r||(r=JSON.parse(e.data)),r},get contentFromJSON(){return r||(r=JSON.parse(e.data)),r},headers:e.headers}:{url:t,code:e.code,get contentAsString(){return r||(r=JSON.stringify(e.data)),r},get contentAsArrayBuffer(){throw new Error("Not implemented")},contentFromJSON:e.data,contentFromBSON:e.data,headers:e.headers,get contentLength(){var t=parseInt(e.headers["content-length"]&&e.headers["content-length"][0]);return t||(r||(r=JSON.stringify(e.data)),r.length)}}},l=/(^|\s)loader\-(progress|error)\-container(\s|$)/;class d{constructor(e="/",t){this.activerid=0,this.components={},this.currentUserID=void 0,this.progressVisible=!1,this.animationTiming=500,this.requestPage=this.defaultRequestPage,this._listeners={},e=i(e),/\/$/.test(e)||(e+="/"),Object.defineProperties(this,{io:{value:t},url:{value:e}}),this._analytics=n}resolveUrl(e){return/^\w+\:/.test(e)?e:i(this.url+e)}disableAll(e=document.body){const t=e.querySelectorAll("a, input, select, textarea, iframe, button, *[focusable], *[tabindex]");for(var r=0;r<t.length;r++){const e=t[r],o=e.getAttribute("tabindex");if("-1"==o)return;e.setAttribute("data-tabindex",o||""),e.setAttribute("data-tabindex","-1")}}enableAll(e=document.body){const t=e.querySelectorAll("*[data-tabindex]");for(var r=0;r<t.length;r++){const e=t[r];e.setAttribute("tabindex",e.getAttribute("data-tabindex")),e.removeAttribute("data-tabindex")}}get analytics(){return this._analytics}set analytics(e){this._analytics=e||n}reportError(e,t){console[t?"error":"warn"](e.stack),this.errorreporter&&this.errorreporter(e,t)}installErrorReporter(e){this.errorreporter=e}registerComponent(e,t){if(t)this.components[e]=t,this.createComponents(document.head),this.createComponents(document.body);else{delete this.components[e];var r=t=>{const r=t.querySelectorAll(e);if(r.length)for(var o=0;o<r.length;o++){const t=r[o];var n=t.__nf_cmapping__;n||(n=t.__nf_cmapping__={});const s=n[e];if(s)try{s.destroy()}catch(e){this.reportError(e)}}};r(document.head),r(document.body)}}unregisterComponent(e,t){}createComponents(e){Object.keys(this.components).forEach(t=>{const r=e.querySelectorAll(t);if(r.length)for(var o=0;o<r.length;o++){const e=r[o];var n=e.__nf_cmapping__;if(n||(n=e.__nf_cmapping__={}),n[t])continue;const s=this.components[t];try{(n[t]=new s).create(e)}catch(e){this.reportError(e)}}})}destroyComponents(e){Object.keys(this.components).forEach(t=>{const r=e.querySelectorAll(t);if(r.length)for(var o=0;o<r.length;o++){const e=r[o];var n=e.__nf_cmapping__;n||(n=e.__nf_cmapping__={});const s=n[t];if(s)try{s.destroy()}catch(e){this.reportError(e)}}})}restoreComponents(e,t){Object.keys(this.components).forEach(r=>{const o=t[r];if(!o)return;const n=e.querySelectorAll(r);if(n.length)for(var s=0;s<n.length;s++){const e=n[s];if(!o.length)break;{const t=o.shift();if(t){var a=e.__nf_cmapping__;a||(a=e.__nf_cmapping__={});var i=a[r];if(!i){const t=this.components[r];try{(i=a[r]=new t).create(e)}catch(e){this.reportError(e),console.warn(e);continue}}try{i.restore(t)}catch(e){this.reportError(e),console.warn(e)}}}}})}saveComponents(e){var t={};return Object.keys(this.components).forEach(r=>{const o=t[r]=[],n=e.querySelectorAll(r);if(n.length)for(var s=0;s<n.length;s++){const e=n[s];var a=e.__nf_cmapping__;a||(a=e.__nf_cmapping__={});var i=a[r];if(!i){const t=this.components[r];try{(i=a[r]=new t).create(e)}catch(e){o.push(void 0),this.reportError(e),console.warn(e);continue}}try{o.push(i.save())}catch(e){o.push(void 0),this.reportError(e),console.warn(e)}}}),t}initPageSystem(n){if(!t)return console.error("The NexusFramework Loader is required for the dynamic Page System to work correctly.");if(!history.pushState||!history.replaceState)return console.warn("This browser is missing an essential feature required for the dynamic Page System.");if(this.pagesyshandler)return console.warn("Page System already initialized, ignoring additional requests to initialize.");n=n||{};const s=this;var a=0;const d=[];this.animationTiming=n.animationTiming||500;const u=n.pageHistoryCacheSize||25e6,h=e=>t=>{const r=t.headers["x-logged-user"];s.currentUserID=r?r[0]:void 0,o("Current UID",s.currentUserID),e(t),200===t.code&&setTimeout(()=>{s._analytics.reportPage()})};t.showError=function(e){const t=location.href.match(m),o=t&&t[1]||location.href,n=e.stack.length,s=u<=n;try{const t=d.length;for(var i=0;i<t;i++){const t=d[i];if(t.url===o)throw s?(d.splice(i,1),a-=t.size):(t.data={error:e},t.updated=+new Date,a+=n-t.size),!0}if(s)throw!0;d.push({url:o,data:{error:e},updated:+new Date,size:n}),a+=n}catch(e){if(!0!==e)throw e}return r(e)};const p={requestPage(r,o,a,i){if(s.pagesysprerequest&&!s.pagesysprerequest(r))return void s.defaultRequestPage(r,a);n.noprogress||(s.disableAll(),t.showProgress());const c=s.resolveUrl(":pagesys/"+r),l=n.noprogress?o:function(e){n.noprogress?o(e):t.showProgress(()=>{o(e),s.enableAll()})};a?e.NexusFrameworkTransport.post(c,a,h(l),void 0,void 0,!0):e.NexusFrameworkTransport.get(c,h(l),void 0,void 0,!0)}};if(!n.noio&&this.io){const e=this.io;this.pagesysimpl={requestPage(r,o,a,i){if(e.connected){if(s.pagesysprerequest&&!s.pagesysprerequest(r))return void s.defaultRequestPage(r,a);n.noprogress||(s.disableAll(),t.showProgress());const d={referrer:location.href};var l=document.cookie;l&&(d.cookie=l),e.emit("page",a?"POST":"GET",r,a,d,function(e){if(i!=s.activerid)return;const a=e.headers["set-cookie"];a&&a.forEach(function(e){document.cookie=e});const l=n.noprogress?o:function(e){n.noprogress?t.showProgress(()=>{o(e),s.enableAll()}):o(e)};h(l)(c(e,s.resolveUrl(r)))})}else p.requestPage(r,o,a,i)}}}else this.pagesysimpl=p;var f,g=document.getElementsByTagName("base");g=g&&g[0],this.pagesysprerequest=n.prerequest,this.pagesyshandler=n.handler||((e,r)=>{try{const t=e.headers["content-type"][0];if(!/\/html(;.+)?$/.test(t.toLowerCase()))throw new Error("Content type is not html")}catch(e){}const o=e.contentAsString,n=o.indexOf("<body");if(-1==n)throw new Error("Could not find start of body tag");const a=o.indexOf("</body>")||o.indexOf("</ body>");if(-1==a)throw new Error("Could not find end of body tag");const i=o.match(/<title>([^<]+)<\/\s*title>/);document.title=i&&i[1]||"Title Not Set";const c=document.createElement("html");var d;c.innerHTML=o.substring(n,a)+"</body>";var u=c.children;const h=[];for(var p=0;p<u.length;p++){const e=u[p];switch(e.nodeName.toUpperCase()){case"HEAD":break;case"BODY":p=-1,u=e.children;break;case"SCRIPT":const t=e.innerHTML.match(/^NexusFrameworkLoader\.load\((.+)\);?$/);t&&(d=JSON.parse(t[1]));break;default:if(l.test(e.className))break;h.push(e)}}if(!h.length)throw new Error("Nothing found in response to add to page");if(!d)throw new Error("NexusFrameworkLoader script not found...");for(p=(u=document.body.children).length-1;p>=0;p--){const e=u[p];switch(e.nodeName.toUpperCase()){case"LINK":case"SCRIPT":break;default:if(l.test(e.className))break;document.body.removeChild(e)}}const f=document.createDocumentFragment();return h.forEach(e=>{f.appendChild(e),this.createComponents(e)}),document.body.appendChild(f),t.load(d,function(){s.progressVisible=!0,t.resetProgress(),r()}),!0});const m=/^([^#]+)(#.*)?$/;var y=location.href.match(m)[1];const v=new RegExp("^"+this.url.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")+"(.*)$","i");const b=this.requestPage=((r,n,c=!1)=>{const l=r.match(/\.([^\/]+)([\?#].*)?$/);if(l&&"htm"!==l[0]&&"html"!==l[0])this.defaultRequestPage(r,n),o("Ignoring navigation",r,l);else{o("requestPage",r);const h=++s.activerid,p=this.resolveUrl(r),w=p+(l&&l[2]||"");c?history.replaceState(!!n,"Loading...",w):(history.pushState(!!n,"Loading...",w),y=w.match(m)[1],e.scrollTo(0,0)),t.resetError(),t.resetProgress(),this.pagesysimpl.requestPage(r,l=>{try{if(h!==s.activerid)return;if(!l.code)return t.showProgress(void 0,"Connection Issue","Check your network and try again"),document.title="Connection Issue",history.replaceState(l.hadData,"Connection Issue",w),void setTimeout(function(){h===s.activerid&&b(r,n,!0)},9e5);if(502===l.code||503===l.code)return t.showProgress(void 0,"Scheduled Maintenance","Sorry but this website is undergoing scheduled maintenance"),document.title="Scheduled Maintenance",history.replaceState(l.hadData,"Scheduled Maintenance",w),void setTimeout(function(){h===s.activerid&&b(r,n,!0)},9e5);const m=l.headers["x-location"]||l.headers.location;if(m){const t=i(m[0]);return v.test(t)?void this.requestPage(t.substring(this.url.length),void 0,!0):(console.warn("Requested redirect to external url:",t),void(e.location.href=t))}const _=l.headers["content-disposition"];if(_&&"attachment"==_[0].toLowerCase())throw new Error("Attachment disposition");this.pagesyshandler(l,function(){if(h===s.activerid)try{const h=document.title,m=l.contentLength,v=u<=m,b=v?void 0:{title:h,user:s.currentUserID,scroll:[e.scrollX,e.scrollY],body:s.saveComponents(document.body),basehref:g?g.href:void 0,response:l};var t;const _=d.length;try{for(t=0;t<_;t++){const e=d[t];if(e.url===p)throw v?(d.splice(t,1),a-=e.size):(e.data=b,e.updated=+new Date,a+=m-e.size),!0}if(!v)throw d.push({url:p,data:b,updated:+new Date,size:m}),a+=m,!0;o("Response too big to store",p,m)}catch(e){if(!0!==e)throw e;{const e=a-u;if(e>0){d.sort(function(e,t){return e.updated-t.updated});var i=0;for(t=0;t<_&&!((i+=d[t].size)>=e);t++);t++,d.splice(0,t),o("Trimmed",t,"items...")}}}history.replaceState(l.hadData,document.title,w),s.emit("page",p,r)}catch(t){if(o(t),c)e.location.reload(!0);else try{y=void 0,f=[r,n],o("Going backwards"),history.go(-1)}catch(e){}}})}catch(t){if(o(t),c)e.location.reload(!0);else try{y=void 0,f=[r,n],o("Going backwards"),history.go(-1)}catch(e){}}},n,h)}});return this.registerComponent("a",class{constructor(){this.handler=(e=>{if(this.element.hasAttribute("data-nopagesys")||this.element.hasAttribute("data-nodynamic"))return;const t=this.element.getAttribute("href");if(!t||!t.length)return;var r=this.element.href;const n=r.match(m);if(!n[2]||y!==n[1])if(v.test(r))try{const t=r.match(/^(.+)#.*$/);t&&(r=t[1]),s.requestPage(r.substring(s.url.length));try{e.stopPropagation()}catch(e){}try{e.preventDefault()}catch(e){}}catch(e){console.warn(e)}else o("Navigating",r)})}create(e){e.addEventListener("click",this.handler),this.element=e}destroy(){this.element.removeEventListener("click",this.handler)}restore(e){}save(){}}),this.registerComponent("form",class{constructor(){this.handler=(e=>{if(this.element.hasAttribute("data-nopagesys")||this.element.hasAttribute("data-nodynamic"))return;const r=this.element.getAttribute("method")||"get",n=this.element.getAttribute("enctype")||"text/urlencoded",a=this.element.getAttribute("action")||"";var c=i(a);if(v.test(c))try{const a=c.match(/^(.+)#.*$/);a&&(c=a[1]);const i=new FormData(this.element);if(t.showProgress(void 0,"Submitting Form","Your form data is being processed"),"post"===r.trim().toLowerCase())s.requestPage(c.substring(s.url.length),{type:n,data:i});else{var l=!0,d=c.substring(s.url.length)+"?";for(var u of i)l?l=!1:d+="&",d+=encodeURIComponent(u[0]),d+="=",d+=encodeURIComponent(u[1]);s.requestPage(d)}try{e.stopPropagation()}catch(e){}try{e.preventDefault()}catch(e){}return Array.prototype.forEach.call(this.element.querySelectorAll("a, input, select, textarea, iframe, button, *[name]"),function(e){e.setAttribute("disabled","disabled"),e.className+=" disabled"}),Array.prototype.forEach.call(this.element.querySelectorAll("button:not([type]), button[type=submit]"),function(e){e.innerHTML="Processing Request"}),void Array.prototype.forEach.call(this.element.querySelectorAll("input[type=submit]"),function(e){e.value="Processing Request"})}catch(e){o(e)}o("Submitting",c)})}create(e){e.addEventListener("submit",this.handler),this.element=e}destroy(){this.element.removeEventListener("submit",this.handler)}restore(e){}save(){}}),e.addEventListener("popstate",n=>{try{var a;const l=location.href.match(m),u=d.length,h=l[1];for(var i=0;i<u;i++){const e=d[i];if(e.url===h){a=e;break}}const p=!!a,g=++s.activerid,b=p&&a.data.error;if(b)return void r(b);if(f){o("forwardPopState",f);const e=f;return setTimeout(()=>{g===s.activerid&&s.defaultRequestPage(e[0],e[1])}),void(f=void 0)}if(y===h)return void o("Only hash has changed...",h);if(y=l[1],n.state&&alert("You submitted data to this page, which cannot be re-sent. Because of this, what you're viewing may not be the same now."),!p)throw new Error("No state for: "+h+", reloading...");if(a.data.user!=s.currentUserID)throw new Error("User has changed since state was created, reloading...");document.title=a.data.title,t.resetProgress(),t.resetError(),s.pagesyshandler(a.data.response,function(t){if(g===s.activerid)try{if(t)throw t;a.data.body&&s.restoreComponents(document.body,a.data.body),a.data.scroll&&e.scrollTo.apply(e,a.data.scroll),o("Used stored page state!",a)}catch(t){o(t);var r=location.href;if(v.test(r))try{if(/reloading\.\.\.$/.test(t.message))return void s.requestPage(r.substring(s.url.length),void 0,!0);console.error("Unknown error occured, actually navigating to page...")}catch(e){console.error(e)}location.reload(!0)}})}catch(e){o(e);var c=location.href;if(v.test(c))try{if(/reloading\.\.\.$/.test(e.message))return void s.requestPage(c.substring(s.url.length),void 0,!0);console.error("Unknown error occured, actually navigating to page...")}catch(n){console.error(n)}location.reload(!0)}}),!0}get currentUser(){return this.currentUserID}defaultRequestPage(e,t){if(t)throw new Error("Posting is not supported without an initialized page system, yet");location.href=this.resolveUrl(e)}on(e,t){var r=this._listeners[e];r?r.push(t):this._listeners[e]=r=[t]}off(e,t){var r,o=this._listeners[e];o&&(r=o.indexOf(t))>-1&&o.splice(r,1)}emit(e,...t){const r=this,o=this._listeners[e];o&&o.forEach(function(e){e.apply(r,t)})}}var u;return u=e.io?class extends d{constructor(r){super(r,e.io({path:"/:io"}));const o=this.io;o.on("connect",function(){o.emit("init",t.requestedResources())})}}:class extends d{constructor(e){super(e)}},Object.defineProperty(e,"NexusFrameworkImpl",{value:u}),u}},NexusFrameworkClient:{configurable:!0,set:function(t){Object.defineProperty(e,"NexusFrameworkClient",{value:t})},get:function(){const t=new e.NexusFrameworkImpl;return Object.defineProperty(e,"NexusFrameworkClient",{value:t}),t}}})}(window);
1
+ !function(e){const t=new e.bson;Object.defineProperties(e,{NexusFrameworkTransport:{configurable:!0,set:function(t){Object.defineProperty(e,"NexusFrameworkTransport",{value:t})},get:function(){var r;if(!("XMLHttpRequest"in e))throw new Error("No transport implementations");{class e{constructor(e,t,r,o){this._url=t,this.request=e,this.hadData=r,this.abResponse=o}get url(){return this.request.responseURL||this._url}get code(){return this.request.status}get contentLength(){return parseInt(this.request.getResponseHeader("content-length"))||this.request.responseText.length}get contentFromJSON(){return this.parsedJson||(this.parsedJson=JSON.parse(this.request.responseText)),this.parsedJson}get contentFromBSON(){if(!this.parsedBson){var e=this.request.response;e="string"==typeof e?Buffer.from(e,"utf8"):new Buffer(e),this.parsedBson=t.deserialize(e,{promoteValues:!0})}return this.parsedBson}get contentAsString(){return this.request.responseText}get contentAsArrayBuffer(){return this.request.response}get headers(){if(!this.processedHeaders){const e=this.processedHeaders={};this.request.getAllResponseHeaders().split(/\r?\n/g).forEach(function(t){const r=t.indexOf(":");var o,n;r>0?(o=t.substring(0,r).trim().toLowerCase(),n=t.substring(r+1).trim()):o=t.trim().toLowerCase();var s=e[o];s||(s=e[o]=[]),n&&s.push(n)})}return this.processedHeaders}}const o=function(r,o,n,s,a,i,c){const l=new XMLHttpRequest;var d;try{if(!c)throw!1;if(l.responseType="arraybuffer","arraybuffer"!==l.responseType)throw console.error("Could not request arraybuffer"),!1;d=!0}catch(e){d=!1}l.open(r,o,!0),a&&Object.keys(a).forEach(function(e){l.setRequestHeader(e,a[e])}),i&&(l.onprogress=function(e){e.lengthComputable&&e.total&&i(e.loaded,e.total)}),l.onreadystatechange=function(t){l.readyState===XMLHttpRequest.DONE&&s(new e(l,o,!!n,d))};const u=n&&n.type;if(u)switch(u){case"":case"text/urlencoded":var h="";for(var p of n.data)h&&(h+="&"),h+=encodeURIComponent(p[0]),h+="=",h+=encodeURIComponent(p[1]);l.setRequestHeader("Content-Type","text/urlencoded"),l.send(h);break;case"text/json":l.setRequestHeader("Content-Type","text/json"),l.send(JSON.stringify(n.data));break;case"application/bson":l.setRequestHeader("Content-Type","application/bson"),l.send(t.serialize(n.data));break;case"multipart/form-data":l.send(n.data);break;default:l.send(n)}else l.send(n)};r={get:function(e,t,r,n,s){o("GET",e,void 0,t,r,n,s)},head:function(e,t,r,n,s){o("HEAD",e,void 0,t,r,n,s)},post:function(e,t,r,n,s,a){o("POST",e,t,r,n,s,a)},put:function(e,t,r,n,s,a){o("PUT",e,t,r,n,s,a)},execute:o,del:function(e,t,r,n,s){o("DELETE",e,void 0,t,r,n,s)}}}return Object.defineProperty(e,"NexusFrameworkTransport",{value:r}),r}},NexusFrameworkImpl:{configurable:!0,set:function(t){Object.defineProperty(e,"NexusFrameworkImpl",{value:t})},get:function(){const t=e.NexusFrameworkLoader,r=t.showError,o=console.log.bind(console),n={reportError:function(t,r){if(e.ga)try{e.ga("send","exception",{exDescription:(t.stack||""+t).replace(/\n/g,"\n\t"),exFatal:r})}catch(e){console.warn(e)}},reportEvent:function(t,r,o,n){if(e.ga)try{e.ga("send","event",t,r,o,n)}catch(e){console.warn(e)}},reportPage:function(t){if(e.ga)try{t||(t=location.pathname),e.ga("set","page",t),e.ga("send","pageview")}catch(e){console.warn(e)}}},s=document.createElement("a"),a=location.href.match(/^\w+:/)[0],i=function(e){s.setAttribute("href",e);var t=s.href;return/^\/\//.test(t)&&(t=a+t),t},c=function(e,t=location.href){var r;return"string"==typeof e.data?{url:t,code:e.code,contentAsString:e.data,get contentLength(){return parseInt(e.headers["content-length"]&&e.headers["content-length"][0])||e.data.length},get contentAsArrayBuffer(){throw new Error("Not implemented")},get contentFromBSON(){return r||(r=JSON.parse(e.data)),r},get contentFromJSON(){return r||(r=JSON.parse(e.data)),r},headers:e.headers}:{url:t,code:e.code,get contentAsString(){return r||(r=JSON.stringify(e.data)),r},get contentAsArrayBuffer(){throw new Error("Not implemented")},contentFromJSON:e.data,contentFromBSON:e.data,headers:e.headers,get contentLength(){var t=parseInt(e.headers["content-length"]&&e.headers["content-length"][0]);return t||(r||(r=JSON.stringify(e.data)),r.length)}}},l=/(^|\s)loader\-(progress|error)\-container(\s|$)/;class d{constructor(e="/",t){this.activerid=0,this.components={},this.currentUserID=void 0,this.progressVisible=!1,this.animationTiming=500,this.requestPage=this.defaultRequestPage,this._listeners={},e=i(e),/\/$/.test(e)||(e+="/"),Object.defineProperties(this,{io:{value:t},url:{value:e}}),this._analytics=n}resolveUrl(e){return/^\w+\:/.test(e)?e:i(this.url+e)}disableAll(e=document.body){const t=e.querySelectorAll("a, input, select, textarea, iframe, button, *[focusable], *[tabindex]");for(var r=0;r<t.length;r++){const e=t[r],o=e.getAttribute("tabindex");if("-1"==o)return;e.setAttribute("data-tabindex",o||""),e.setAttribute("data-tabindex","-1")}}enableAll(e=document.body){const t=e.querySelectorAll("*[data-tabindex]");for(var r=0;r<t.length;r++){const e=t[r];e.setAttribute("tabindex",e.getAttribute("data-tabindex")),e.removeAttribute("data-tabindex")}}get analytics(){return this._analytics}set analytics(e){this._analytics=e||n}reportError(e,t){console[t?"error":"warn"](e.stack),this.errorreporter&&this.errorreporter(e,t)}installErrorReporter(e){this.errorreporter=e}registerComponent(e,t){if(t)this.components[e]=t,this.createComponents(document.head),this.createComponents(document.body);else{delete this.components[e];var r=t=>{const r=t.querySelectorAll(e);if(r.length)for(var o=0;o<r.length;o++){const t=r[o];var n=t.__nf_cmapping__;n||(n=t.__nf_cmapping__={});const s=n[e];if(s)try{s.destroy()}catch(e){this.reportError(e)}}};r(document.head),r(document.body)}}unregisterComponent(e,t){}createComponents(e){Object.keys(this.components).forEach(t=>{const r=e.querySelectorAll(t);if(r.length)for(var o=0;o<r.length;o++){const e=r[o];var n=e.__nf_cmapping__;if(n||(n=e.__nf_cmapping__={}),n[t])continue;const s=this.components[t];try{(n[t]=new s).create(e)}catch(e){this.reportError(e)}}})}destroyComponents(e){Object.keys(this.components).forEach(t=>{const r=e.querySelectorAll(t);if(r.length)for(var o=0;o<r.length;o++){const e=r[o];var n=e.__nf_cmapping__;n||(n=e.__nf_cmapping__={});const s=n[t];if(s)try{s.destroy()}catch(e){this.reportError(e)}}})}restoreComponents(e,t){Object.keys(this.components).forEach(r=>{const o=t[r];if(!o)return;const n=e.querySelectorAll(r);if(n.length)for(var s=0;s<n.length;s++){const e=n[s];if(!o.length)break;{const t=o.shift();if(t){var a=e.__nf_cmapping__;a||(a=e.__nf_cmapping__={});var i=a[r];if(!i){const t=this.components[r];try{(i=a[r]=new t).create(e)}catch(e){this.reportError(e),console.warn(e);continue}}try{i.restore(t)}catch(e){this.reportError(e),console.warn(e)}}}}})}saveComponents(e){var t={};return Object.keys(this.components).forEach(r=>{const o=t[r]=[],n=e.querySelectorAll(r);if(n.length)for(var s=0;s<n.length;s++){const e=n[s];var a=e.__nf_cmapping__;a||(a=e.__nf_cmapping__={});var i=a[r];if(!i){const t=this.components[r];try{(i=a[r]=new t).create(e)}catch(e){o.push(void 0),this.reportError(e),console.warn(e);continue}}try{o.push(i.save())}catch(e){o.push(void 0),this.reportError(e),console.warn(e)}}}),t}initPageSystem(n){if(!t)return console.error("The NexusFramework Loader is required for the dynamic Page System to work correctly.");if(!history.pushState||!history.replaceState)return console.warn("This browser is missing an essential feature required for the dynamic Page System.");if(this.pagesyshandler)return console.warn("Page System already initialized, ignoring additional requests to initialize.");n=n||{};const s=this;var a=0;const d=[];this.animationTiming=n.animationTiming||500;const u=n.pageHistoryCacheSize||25e6,h=e=>t=>{const r=t.headers["x-logged-user"];s.currentUserID=r?r[0]:void 0,o("Current UID",s.currentUserID),e(t),200===t.code&&setTimeout(()=>{s._analytics.reportPage()})};t.showError=function(e){const t=location.href.match(m),o=t&&t[1]||location.href,n=e.stack.length,s=u<=n;try{const t=d.length;for(var i=0;i<t;i++){const t=d[i];if(t.url===o)throw s?(d.splice(i,1),a-=t.size):(t.data={error:e},t.updated=+new Date,a+=n-t.size),!0}if(s)throw!0;d.push({url:o,data:{error:e},updated:+new Date,size:n}),a+=n}catch(e){if(!0!==e)throw e}return r(e)};const p={requestPage(r,o,a,i){if(s.pagesysprerequest&&!s.pagesysprerequest(r))return void s.defaultRequestPage(r,a);n.noprogress||(s.disableAll(),t.showProgress());const c=s.resolveUrl(":pagesys/"+r),l=n.noprogress?o:function(e){n.noprogress?o(e):t.showProgress(()=>{o(e),s.enableAll()})};a?e.NexusFrameworkTransport.post(c,a,h(l),void 0,void 0,!0):e.NexusFrameworkTransport.get(c,h(l),void 0,void 0,!0)}};if(!n.noio&&this.io){const e=this.io;this.pagesysimpl={requestPage(r,o,a,i){if(e.connected){if(s.pagesysprerequest&&!s.pagesysprerequest(r))return void s.defaultRequestPage(r,a);n.noprogress||(s.disableAll(),t.showProgress());const d={referrer:location.href};var l=document.cookie;l&&(d.cookie=l),e.emit("page",a?"POST":"GET",r,a,d,function(e){if(i!=s.activerid)return;const a=e.headers["set-cookie"];a&&a.forEach(function(e){document.cookie=e});const l=n.noprogress?o:function(e){n.noprogress?t.showProgress(()=>{o(e),s.enableAll()}):o(e)};h(l)(c(e,s.resolveUrl(r)))})}else p.requestPage(r,o,a,i)}}}else this.pagesysimpl=p;var f,g=document.getElementsByTagName("base");g=g&&g[0],this.pagesysprerequest=n.prerequest,this.pagesyshandler=n.handler||((e,r)=>{try{const t=e.headers["content-type"][0];if(!/\/html(;.+)?$/.test(t.toLowerCase()))throw new Error("Content type is not html")}catch(e){}const o=e.contentAsString,n=o.indexOf("<body");if(-1==n)throw new Error("Could not find start of body tag");const a=o.indexOf("</body>")||o.indexOf("</ body>");if(-1==a)throw new Error("Could not find end of body tag");const i=o.match(/<title>([^<]+)<\/\s*title>/);document.title=i&&i[1]||"Title Not Set";const c=document.createElement("html");var d;c.innerHTML=o.substring(n,a)+"</body>";var u=c.children;const h=[];for(var p=0;p<u.length;p++){const e=u[p];switch(e.nodeName.toUpperCase()){case"HEAD":break;case"BODY":p=-1,u=e.children;break;case"SCRIPT":const t=e.innerHTML.match(/^NexusFrameworkLoader\.load\((.+)\);?$/);t&&(d=JSON.parse(t[1]));break;default:if(l.test(e.className))break;h.push(e)}}if(!h.length)throw new Error("Nothing found in response to add to page");if(!d)throw new Error("NexusFrameworkLoader script not found...");for(p=(u=document.body.children).length-1;p>=0;p--){const e=u[p];switch(e.nodeName.toUpperCase()){case"LINK":case"SCRIPT":break;default:if(l.test(e.className))break;document.body.removeChild(e)}}const f=document.createDocumentFragment();return h.forEach(e=>{f.appendChild(e),this.createComponents(e)}),document.body.appendChild(f),t.load(d,function(){s.progressVisible=!0,t.resetProgress(),r()}),!0});const m=/^([^#]+)(#.*)?$/;var y=location.href.match(m)[1];const v=new RegExp("^"+this.url.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")+"(.*)$","i");const b=this.requestPage=((r,n,c=!1)=>{const l=r.match(/\.([^\/]+)([\?#].*)?$/);if(l&&"htm"!==l[0]&&"html"!==l[0])this.defaultRequestPage(r,n),o("Ignoring navigation",r,l);else{o("requestPage",r);const h=++s.activerid,p=this.resolveUrl(r),w=p+(l&&l[2]||"");c?history.replaceState(!!n,"Loading...",w):(history.pushState(!!n,"Loading...",w),y=w.match(m)[1],e.scrollTo(0,0)),t.resetError(),t.resetProgress(),this.pagesysimpl.requestPage(r,l=>{try{if(h!==s.activerid)return;if(!l.code)return t.showProgress(void 0,"Connection Issue","Check your network and try again"),document.title="Connection Issue",history.replaceState(l.hadData,"Connection Issue",w),void setTimeout(function(){h===s.activerid&&b(r,n,!0)},9e5);if(502===l.code||503===l.code)return t.showProgress(void 0,"Scheduled Maintenance","Sorry but this website is undergoing scheduled maintenance"),document.title="Scheduled Maintenance",history.replaceState(l.hadData,"Scheduled Maintenance",w),void setTimeout(function(){h===s.activerid&&b(r,n,!0)},9e5);const m=l.headers["x-location"]||l.headers.location;if(m){const t=i(m[0]);return v.test(t)?void this.requestPage(t.substring(this.url.length),void 0,!0):(console.warn("Requested redirect to external url:",t),void(e.location.href=t))}const _=l.headers["content-disposition"];if(_&&"attachment"==_[0].toLowerCase())throw new Error("Attachment disposition");this.pagesyshandler(l,function(){if(h===s.activerid)try{const h=document.title,m=l.contentLength,v=u<=m,b=v?void 0:{title:h,user:s.currentUserID,scroll:[e.scrollX,e.scrollY],body:s.saveComponents(document.body),basehref:g?g.href:void 0,response:l};var t;const _=d.length;try{for(t=0;t<_;t++){const e=d[t];if(e.url===p)throw v?(d.splice(t,1),a-=e.size):(e.data=b,e.updated=+new Date,a+=m-e.size),!0}if(!v)throw d.push({url:p,data:b,updated:+new Date,size:m}),a+=m,!0;o("Response too big to store",p,m)}catch(e){if(!0!==e)throw e;{const e=a-u;if(e>0){d.sort(function(e,t){return e.updated-t.updated});var i=0;for(t=0;t<_&&!((i+=d[t].size)>=e);t++);t++,d.splice(0,t),o("Trimmed",t,"items...")}}}history.replaceState(l.hadData,document.title,w),s.emit("page",p,r)}catch(t){if(o(t),c)e.location.reload(!0);else try{y=void 0,f=[r,n],o("Going backwards"),history.go(-1)}catch(e){}}})}catch(t){if(o(t),c)e.location.reload(!0);else try{y=void 0,f=[r,n],o("Going backwards"),history.go(-1)}catch(e){}}},n,h)}});return this.registerComponent("a",class{constructor(){this.handler=(e=>{if(this.element.hasAttribute("data-nopagesys")||this.element.hasAttribute("data-nodynamic"))return;const t=this.element.getAttribute("href");if(!t||!t.length)return;var r=this.element.href;const n=r.match(m);if(!n[2]||y!==n[1])if(v.test(r))try{const t=r.match(/^(.+)#.*$/);t&&(r=t[1]),s.requestPage(r.substring(s.url.length));try{e.stopPropagation()}catch(e){}try{e.preventDefault()}catch(e){}}catch(e){console.warn(e)}else o("Navigating",r)})}create(e){e.addEventListener("click",this.handler),this.element=e}destroy(){this.element.removeEventListener("click",this.handler)}restore(e){}save(){}}),this.registerComponent("form",class{constructor(){this.handler=(e=>{if(this.element.hasAttribute("data-nopagesys")||this.element.hasAttribute("data-nodynamic"))return;const r=this.element.getAttribute("method")||"get",n=this.element.getAttribute("enctype")||"text/urlencoded",a=this.element.getAttribute("action")||"";var c=i(a);if(v.test(c))try{const a=c.match(/^(.+)#.*$/);a&&(c=a[1]);const i=new FormData(this.element);if(t.showProgress(void 0,"Submitting Form","Your form data is being processed"),"post"===r.trim().toLowerCase())s.requestPage(c.substring(s.url.length),{type:n,data:i});else{var l=!0,d=c.substring(s.url.length)+"?";for(var u of i)l?l=!1:d+="&",d+=encodeURIComponent(u[0]),d+="=",d+=encodeURIComponent(u[1]);s.requestPage(d)}try{e.stopPropagation()}catch(e){}try{e.preventDefault()}catch(e){}return Array.prototype.forEach.call(this.element.querySelectorAll("a, input, select, textarea, iframe, button, *[name]"),function(e){e.setAttribute("disabled","disabled"),e.className+=" disabled"}),Array.prototype.forEach.call(this.element.querySelectorAll("button:not([type]), button[type=submit]"),function(e){e.innerHTML="Processing Request"}),void Array.prototype.forEach.call(this.element.querySelectorAll("input[type=submit]"),function(e){e.value="Processing Request"})}catch(e){o(e)}o("Submitting",c)})}create(e){e.addEventListener("submit",this.handler),this.element=e}destroy(){this.element.removeEventListener("submit",this.handler)}restore(e){}save(){}}),e.addEventListener("popstate",n=>{try{var a;const l=location.href.match(m),u=d.length,h=l[1];for(var i=0;i<u;i++){const e=d[i];if(e.url===h){a=e;break}}const p=!!a,g=++s.activerid,b=p&&a.data.error;if(b)return void r(b);if(f){o("forwardPopState",f);const e=f;return setTimeout(()=>{g===s.activerid&&s.defaultRequestPage(e[0],e[1])}),void(f=void 0)}if(y===h)return void o("Only hash has changed...",h);if(y=l[1],n.state&&alert("You submitted data to this page, which cannot be re-sent. Because of this, what you're viewing may not be the same now."),!p)throw new Error("No state for: "+h+", reloading...");if(a.data.user!=s.currentUserID)throw new Error("User has changed since state was created, reloading...");document.title=a.data.title,t.resetProgress(),t.resetError(),s.pagesyshandler(a.data.response,function(t){if(g===s.activerid)try{if(t)throw t;a.data.body&&s.restoreComponents(document.body,a.data.body),a.data.scroll&&e.scrollTo.apply(e,a.data.scroll),o("Used stored page state!",a)}catch(t){o(t);var r=location.href;if(v.test(r))try{if(/reloading\.\.\.$/.test(t.message))return void s.requestPage(r.substring(s.url.length),void 0,!0);console.error("Unknown error occured, actually navigating to page...")}catch(e){console.error(e)}location.reload(!0)}})}catch(e){o(e);var c=location.href;if(v.test(c))try{if(/reloading\.\.\.$/.test(e.message))return void s.requestPage(c.substring(s.url.length),void 0,!0);console.error("Unknown error occured, actually navigating to page...")}catch(n){console.error(n)}location.reload(!0)}}),!0}get currentUser(){return this.currentUserID}defaultRequestPage(e,t){if(t)throw new Error("Posting is not supported without an initialized page system, yet");location.href=this.resolveUrl(e)}on(e,t){var r=this._listeners[e];r?r.push(t):this._listeners[e]=r=[t]}off(e,t){var r,o=this._listeners[e];o&&(r=o.indexOf(t))>-1&&o.splice(r,1)}emit(e,...t){const r=this,o=this._listeners[e];o&&o.forEach(function(e){e.apply(r,t)})}}var u;return u=e.io?class extends d{constructor(r){super(r,e.io({path:"/:io"}));const o=this.io;o.on("connect",function(){o.emit("init",t.requestedResources())})}}:class extends d{constructor(e){super(e)}},Object.defineProperty(e,"NexusFrameworkImpl",{value:u}),u}},NexusFrameworkClient:{configurable:!0,set:function(t){Object.defineProperty(e,"NexusFrameworkClient",{value:t})},get:function(){const t=new e.NexusFrameworkImpl;return Object.defineProperty(e,"NexusFrameworkClient",{value:t}),t}}})}(window);
2
2
  //# sourceMappingURL=nexusframeworkclient.min.js.map
File without changes
@@ -1,259 +1,259 @@
1
- /// <reference types="socket.io-client" />
2
- /// <reference types="jquery" />
3
-
4
- declare interface NexusFrameworkResource {
5
- name: string;
6
- type: string;
7
- source: string;
8
- inline?: boolean;
9
- integrity?: string;
10
- dependencies: string[];
11
- }
12
- declare interface NexusFrameworkLoaderData {
13
- [0]: string[];
14
- [1]: NexusFrameworkResource[];
15
- }
16
- declare interface NexusFrameworkLoader {
17
- load(data: NexusFrameworkLoaderData, onsuccess?: () => void): void;
18
- /**
19
- * Loads a resource.
20
- * Downloads the file asynchroniously and reads any header for @ tags.
21
- * After that, queues it for download, and returns an info object for the script when complete.
22
- *
23
- * @param type The type, script or style
24
- * @param name The name of the resource
25
- * @param source The source of the resource
26
- * @param cb The callback
27
- * @param deps The dependencies
28
- * @param inlineOrVersion True or String, inline or version.
29
- */
30
- loadResource(type: string, script: string, cb?: (err?: Error) => void, deps?: string[], inlineOrIntegrity?: boolean | string, name?: string): void;
31
- /**
32
- * Queries the list of requested resources.
33
- * Each resource is listed as `type:name`.
34
- */
35
- requestedResources(): string[];
36
- /**
37
- * Get the source for a given resource.
38
- */
39
- resourceSource(key: string): string;
40
- /**
41
- * Show the specified error to the user.
42
- */
43
- showError(err: Error): HTMLElement | HTMLCollection;
44
- /**
45
- * Clear the error screen.
46
- */
47
- resetError(): void;
48
- /**
49
- * Show the specified error to the user.
50
- */
51
- showProgress(cb?: () => void, title?: string, message?: string): HTMLElement | HTMLCollection;
52
- /**
53
- * Clear the error screen.
54
- */
55
- resetProgress(): void;
56
- }
57
- declare interface NexusFrameworkTransportResponse {
58
- /**
59
- * The response url.
60
- */
61
- readonly url: string;
62
- /**
63
- * The response code;
64
- */
65
- readonly code: number;
66
- /**
67
- * Parses a JSON representation from the response string or throws an error.
68
- */
69
- readonly contentFromJSON: any;
70
- /**
71
- * Parses a BSON representation from the response string or throws an error.
72
- */
73
- readonly contentFromBSON: any;
74
- /**
75
- * The content as a String.
76
- */
77
- readonly contentAsString: string;
78
- /**
79
- * The content as an ArrayBuffer.
80
- */
81
- readonly contentAsArrayBuffer: ArrayBuffer;
82
- /**
83
- * The length in bytes of
84
- */
85
- readonly contentLength: number;
86
- /**
87
- * A map of response headers, each header can occur more than once.
88
- */
89
- readonly headers: {[index: string]: string[]};
90
- /**
91
- * Whether or not this request posted data.
92
- */
93
- readonly hadData?: boolean;
94
- }
95
- declare interface NexusFrameworkPageSystemResponse {
96
- data: any;
97
- code: number;
98
- headers: {[index: string]: string[]};
99
- }
100
- declare interface NexusFrameworkPageSystemOptions {
101
- /**
102
- * Override the built in way of handling page responses.
103
- *
104
- * @returns True when handled correctly, false to reload the page to the request url.
105
- */
106
- handler?: (res: NexusFrameworkTransportResponse, contentReady: (err?: Error) => void) => void;
107
- /**
108
- * Method to call before attempting to make a page request.
109
- *
110
- * @returns True to continue, False to abort.
111
- */
112
- prerequest?: (path: string) => boolean;
113
- /**
114
- * Disables using the loader-progress elements.
115
- */
116
- noprogress?: boolean;
117
- /**
118
- * The timing in milliseconds the page transition animation will take.
119
- * Defaults to 500.
120
- */
121
- animationTiming?: number;
122
- /**
123
- * The size in bytes worth of data to allow storing for caching page history.
124
- * Defaults to 25000000 (25mb)
125
- */
126
- pageHistoryCacheSize?: number;
127
- /**
128
- * Disables using SocketIO for the Page System.
129
- * The Page System over SocketIO cannot pass some HttpOnly cookies,
130
- * as such this might be required for some websites.
131
- */
132
- noio?: boolean;
133
- }
134
- declare interface NexusFrameworkEvents {
135
- /**
136
- * Add an event listener for when pages are loaded via the dynamic page system.
137
- */
138
- on(event: "page", cb: (baseurl: string, path: string) => void): void;
139
- /**
140
- * Add an event listener for a specific event.
141
- */
142
- on(event: string, cb: (...args: any[]) => void): void;
143
- /**
144
- * Remove a event listener for when pages are loaded via the dynamic page system.
145
- */
146
- off(event: "page", cb: (baseurl: string, path: string) => void): void;
147
- /**
148
- * Remove n event listener for a specific event.
149
- */
150
- off(event: string, cb: (...args: any[]) => void): void;
151
- }
152
- /*declare interface NexusFrameworkComponentHelper extends NexusFrameworkEvents {
153
-
154
- }*/
155
- declare interface NexusFrameworkComponent {
156
- create(element: HTMLElement/*, createHelper: () => NexusFrameworkComponentHelper*/): void;
157
- destroy(): void;
158
-
159
- restore(data: any): void;
160
- save(): any;
161
- }
162
- declare interface NexusFrameworkComponentFactory {
163
- new (): NexusFrameworkComponent;
164
- }
165
- declare interface NexusFrameworkAnalyticsAdapter {
166
- reportError(err: Error): void;
167
- reportPage(path?: string): void;
168
- reportEvent(category: string, action: string, label?: string, value?: number): void;
169
- }
170
- declare interface NexusFrameworkClient extends NexusFrameworkEvents {
171
- /**
172
- * The Socket.IO instance, if enabled and available.
173
- */
174
- readonly io: SocketIOClient.Socket;
175
- /**
176
- * The base URL for this client.
177
- */
178
- readonly url: string;
179
- /**
180
- * The ID of the current user, if any.
181
- */
182
- readonly currentUser: string | undefined;
183
- /**
184
- * The analytics adapter.
185
- */
186
- analytics: NexusFrameworkAnalyticsAdapter;
187
-
188
- /**
189
- * Initialize the page system.
190
- */
191
- initPageSystem(opts?: NexusFrameworkPageSystemOptions): void;
192
- /**
193
- * Loads a page, relative to the root URL for the website.
194
- */
195
- requestPage(path: string, post?: any): void;
196
-
197
- /**
198
- * Register a component by selector.
199
- */
200
- registerComponent(selector: string, impl: NexusFrameworkComponentFactory): void;
201
- /**
202
- * Unregister a component by selector.
203
- */
204
- unregisterComponent(selector: string, impl: NexusFrameworkComponentFactory): void;
205
- /**
206
- * Initialize and create all components within root
207
- */
208
- createComponents(root: HTMLElement): void;
209
- /**
210
- * Destroy all components within root
211
- */
212
- destroyComponents(root: HTMLElement): void;
213
- /**
214
- * Save components in root into a state object
215
- */
216
- saveComponents(root: HTMLElement): Object;
217
- /**
218
- * Restore components in root from a state object
219
- */
220
- restoreComponents(root: HTMLElement, state: Object): void;
221
-
222
- /**
223
- * Disable an element and its children.
224
- *
225
- * @param root The root element, by default document.body
226
- */
227
- disableAll(root?: HTMLElement): void;
228
- /**
229
- * Enable an element and its children.
230
- *
231
- * @param root The root element, by default document.body
232
- */
233
- enableAll(root?: HTMLElement): void;
234
-
235
- /**
236
- * Remove a event listener for when pages are loaded via the dynamic page system.
237
- */
238
- emit(event: string, ...args: any[]): void;
239
- }
240
- declare interface NexusFrameworkTransport {
241
- get(url: string, cb: (res: NexusFrameworkTransportResponse) => void, extraHeaders?: {[index: string]: string}, progcb?: (complete: number, total: number) => void, wantsBinary?: boolean): void;
242
- head(url: string, cb: (res: NexusFrameworkTransportResponse) => void, extraHeaders?: {[index: string]: string}, progcb?: (complete: number, total: number) => void, wantsBinary?: boolean): void;
243
- put(url: string, data: any, cb: (res: NexusFrameworkTransportResponse) => void, extraHeaders?: {[index: string]: string}, progcb?: (complete: number, total: number) => void, wantsBinary?: boolean): void;
244
- post(url: string, data: any, cb: (res: NexusFrameworkTransportResponse) => void, extraHeaders?: {[index: string]: string}, progcb?: (complete: number, total: number) => void, wantsBinary?: boolean): void;
245
- execute(method: string, url: string, data: any, cb: (res: NexusFrameworkTransportResponse) => void, extraHeaders?: {[index: string]: string}, progcb?: (complete: number, total: number, wantsBinary?: boolean) => void): void;
246
- del(url: string, cb: (res: NexusFrameworkTransportResponse) => void, extraHeaders?: {[index: string]: string}, progcb?: (complete: number, total: number, wantsBinary?: boolean) => void): void;
247
- }
248
- declare interface GoogleAnalytics {
249
- (cmd: string, ...args: any[]): void;
250
- }
251
- declare interface Window {
252
- NexusFrameworkImpl?: any;
253
- NexusFrameworkLoader?: NexusFrameworkLoader;
254
- NexusFrameworkTransport?: NexusFrameworkTransport;
255
- NexusFrameworkClient?: NexusFrameworkClient;
256
- io?: SocketIOClientStatic;
257
- jQuery?: JQueryStatic;
258
- ga?: GoogleAnalytics;
259
- }
1
+ /// <reference types="socket.io-client" />
2
+ /// <reference types="jquery" />
3
+
4
+ declare interface NexusFrameworkResource {
5
+ name: string;
6
+ type: string;
7
+ source: string;
8
+ inline?: boolean;
9
+ integrity?: string;
10
+ dependencies: string[];
11
+ }
12
+ declare interface NexusFrameworkLoaderData {
13
+ [0]: string[];
14
+ [1]: NexusFrameworkResource[];
15
+ }
16
+ declare interface NexusFrameworkLoader {
17
+ load(data: NexusFrameworkLoaderData, onsuccess?: () => void): void;
18
+ /**
19
+ * Loads a resource.
20
+ * Downloads the file asynchroniously and reads any header for @ tags.
21
+ * After that, queues it for download, and returns an info object for the script when complete.
22
+ *
23
+ * @param type The type, script or style
24
+ * @param name The name of the resource
25
+ * @param source The source of the resource
26
+ * @param cb The callback
27
+ * @param deps The dependencies
28
+ * @param inlineOrVersion True or String, inline or version.
29
+ */
30
+ loadResource(type: string, script: string, cb?: (err?: Error) => void, deps?: string[], inlineOrIntegrity?: boolean | string, name?: string): void;
31
+ /**
32
+ * Queries the list of requested resources.
33
+ * Each resource is listed as `type:name`.
34
+ */
35
+ requestedResources(): string[];
36
+ /**
37
+ * Get the source for a given resource.
38
+ */
39
+ resourceSource(key: string): string;
40
+ /**
41
+ * Show the specified error to the user.
42
+ */
43
+ showError(err: Error): HTMLElement | HTMLCollection;
44
+ /**
45
+ * Clear the error screen.
46
+ */
47
+ resetError(): void;
48
+ /**
49
+ * Show the specified error to the user.
50
+ */
51
+ showProgress(cb?: () => void, title?: string, message?: string): HTMLElement | HTMLCollection;
52
+ /**
53
+ * Clear the error screen.
54
+ */
55
+ resetProgress(): void;
56
+ }
57
+ declare interface NexusFrameworkTransportResponse {
58
+ /**
59
+ * The response url.
60
+ */
61
+ readonly url: string;
62
+ /**
63
+ * The response code;
64
+ */
65
+ readonly code: number;
66
+ /**
67
+ * Parses a JSON representation from the response string or throws an error.
68
+ */
69
+ readonly contentFromJSON: any;
70
+ /**
71
+ * Parses a BSON representation from the response string or throws an error.
72
+ */
73
+ readonly contentFromBSON: any;
74
+ /**
75
+ * The content as a String.
76
+ */
77
+ readonly contentAsString: string;
78
+ /**
79
+ * The content as an ArrayBuffer.
80
+ */
81
+ readonly contentAsArrayBuffer: ArrayBuffer;
82
+ /**
83
+ * The length in bytes of
84
+ */
85
+ readonly contentLength: number;
86
+ /**
87
+ * A map of response headers, each header can occur more than once.
88
+ */
89
+ readonly headers: {[index: string]: string[]};
90
+ /**
91
+ * Whether or not this request posted data.
92
+ */
93
+ readonly hadData?: boolean;
94
+ }
95
+ declare interface NexusFrameworkPageSystemResponse {
96
+ data: any;
97
+ code: number;
98
+ headers: {[index: string]: string[]};
99
+ }
100
+ declare interface NexusFrameworkPageSystemOptions {
101
+ /**
102
+ * Override the built in way of handling page responses.
103
+ *
104
+ * @returns True when handled correctly, false to reload the page to the request url.
105
+ */
106
+ handler?: (res: NexusFrameworkTransportResponse, contentReady: (err?: Error) => void) => void;
107
+ /**
108
+ * Method to call before attempting to make a page request.
109
+ *
110
+ * @returns True to continue, False to abort.
111
+ */
112
+ prerequest?: (path: string) => boolean;
113
+ /**
114
+ * Disables using the loader-progress elements.
115
+ */
116
+ noprogress?: boolean;
117
+ /**
118
+ * The timing in milliseconds the page transition animation will take.
119
+ * Defaults to 500.
120
+ */
121
+ animationTiming?: number;
122
+ /**
123
+ * The size in bytes worth of data to allow storing for caching page history.
124
+ * Defaults to 25000000 (25mb)
125
+ */
126
+ pageHistoryCacheSize?: number;
127
+ /**
128
+ * Disables using SocketIO for the Page System.
129
+ * The Page System over SocketIO cannot pass some HttpOnly cookies,
130
+ * as such this might be required for some websites.
131
+ */
132
+ noio?: boolean;
133
+ }
134
+ declare interface NexusFrameworkEvents {
135
+ /**
136
+ * Add an event listener for when pages are loaded via the dynamic page system.
137
+ */
138
+ on(event: "page", cb: (baseurl: string, path: string) => void): void;
139
+ /**
140
+ * Add an event listener for a specific event.
141
+ */
142
+ on(event: string, cb: (...args: any[]) => void): void;
143
+ /**
144
+ * Remove a event listener for when pages are loaded via the dynamic page system.
145
+ */
146
+ off(event: "page", cb: (baseurl: string, path: string) => void): void;
147
+ /**
148
+ * Remove n event listener for a specific event.
149
+ */
150
+ off(event: string, cb: (...args: any[]) => void): void;
151
+ }
152
+ /*declare interface NexusFrameworkComponentHelper extends NexusFrameworkEvents {
153
+
154
+ }*/
155
+ declare interface NexusFrameworkComponent {
156
+ create(element: HTMLElement/*, createHelper: () => NexusFrameworkComponentHelper*/): void;
157
+ destroy(): void;
158
+
159
+ restore(data: any): void;
160
+ save(): any;
161
+ }
162
+ declare interface NexusFrameworkComponentFactory {
163
+ new (): NexusFrameworkComponent;
164
+ }
165
+ declare interface NexusFrameworkAnalyticsAdapter {
166
+ reportError(err: Error): void;
167
+ reportPage(path?: string): void;
168
+ reportEvent(category: string, action: string, label?: string, value?: number): void;
169
+ }
170
+ declare interface NexusFrameworkClient extends NexusFrameworkEvents {
171
+ /**
172
+ * The Socket.IO instance, if enabled and available.
173
+ */
174
+ readonly io: SocketIOClient.Socket;
175
+ /**
176
+ * The base URL for this client.
177
+ */
178
+ readonly url: string;
179
+ /**
180
+ * The ID of the current user, if any.
181
+ */
182
+ readonly currentUser: string | undefined;
183
+ /**
184
+ * The analytics adapter.
185
+ */
186
+ analytics: NexusFrameworkAnalyticsAdapter;
187
+
188
+ /**
189
+ * Initialize the page system.
190
+ */
191
+ initPageSystem(opts?: NexusFrameworkPageSystemOptions): void;
192
+ /**
193
+ * Loads a page, relative to the root URL for the website.
194
+ */
195
+ requestPage(path: string, post?: any): void;
196
+
197
+ /**
198
+ * Register a component by selector.
199
+ */
200
+ registerComponent(selector: string, impl: NexusFrameworkComponentFactory): void;
201
+ /**
202
+ * Unregister a component by selector.
203
+ */
204
+ unregisterComponent(selector: string, impl: NexusFrameworkComponentFactory): void;
205
+ /**
206
+ * Initialize and create all components within root
207
+ */
208
+ createComponents(root: HTMLElement): void;
209
+ /**
210
+ * Destroy all components within root
211
+ */
212
+ destroyComponents(root: HTMLElement): void;
213
+ /**
214
+ * Save components in root into a state object
215
+ */
216
+ saveComponents(root: HTMLElement): Object;
217
+ /**
218
+ * Restore components in root from a state object
219
+ */
220
+ restoreComponents(root: HTMLElement, state: Object): void;
221
+
222
+ /**
223
+ * Disable an element and its children.
224
+ *
225
+ * @param root The root element, by default document.body
226
+ */
227
+ disableAll(root?: HTMLElement): void;
228
+ /**
229
+ * Enable an element and its children.
230
+ *
231
+ * @param root The root element, by default document.body
232
+ */
233
+ enableAll(root?: HTMLElement): void;
234
+
235
+ /**
236
+ * Remove a event listener for when pages are loaded via the dynamic page system.
237
+ */
238
+ emit(event: string, ...args: any[]): void;
239
+ }
240
+ declare interface NexusFrameworkTransport {
241
+ get(url: string, cb: (res: NexusFrameworkTransportResponse) => void, extraHeaders?: {[index: string]: string}, progcb?: (complete: number, total: number) => void, wantsBinary?: boolean): void;
242
+ head(url: string, cb: (res: NexusFrameworkTransportResponse) => void, extraHeaders?: {[index: string]: string}, progcb?: (complete: number, total: number) => void, wantsBinary?: boolean): void;
243
+ put(url: string, data: any, cb: (res: NexusFrameworkTransportResponse) => void, extraHeaders?: {[index: string]: string}, progcb?: (complete: number, total: number) => void, wantsBinary?: boolean): void;
244
+ post(url: string, data: any, cb: (res: NexusFrameworkTransportResponse) => void, extraHeaders?: {[index: string]: string}, progcb?: (complete: number, total: number) => void, wantsBinary?: boolean): void;
245
+ execute(method: string, url: string, data: any, cb: (res: NexusFrameworkTransportResponse) => void, extraHeaders?: {[index: string]: string}, progcb?: (complete: number, total: number, wantsBinary?: boolean) => void): void;
246
+ del(url: string, cb: (res: NexusFrameworkTransportResponse) => void, extraHeaders?: {[index: string]: string}, progcb?: (complete: number, total: number, wantsBinary?: boolean) => void): void;
247
+ }
248
+ declare interface GoogleAnalytics {
249
+ (cmd: string, ...args: any[]): void;
250
+ }
251
+ declare interface Window {
252
+ NexusFrameworkImpl?: any;
253
+ NexusFrameworkLoader?: NexusFrameworkLoader;
254
+ NexusFrameworkTransport?: NexusFrameworkTransport;
255
+ NexusFrameworkClient?: NexusFrameworkClient;
256
+ io?: SocketIOClientStatic;
257
+ jQuery?: JQueryStatic;
258
+ ga?: GoogleAnalytics;
259
+ }