@haxtheweb/haxcms-nodejs
Version:
HAXcms single and multisite nodejs server, api, and administration
14 lines • 4.71 kB
JavaScript
/**
* @license
* Copyright (c) 2018 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at
* http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at
* http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at
* http://polymer.github.io/CONTRIBUTORS.txt
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at
* http://polymer.github.io/PATENTS.txt
*/
!function(){if(!window.define){var e=Object.create(null),t=void 0,n=0,r=void 0,i=getBaseUrl();window.define=function(e,o){var a=!1;t=function(){return a=!0,t=void 0,[e,o]};var u=function getDocumentUrl(){var e=document.currentScript;if(!e)return i;if(window.HTMLImports){var t=window.HTMLImports.importForElement(e);return t?t.href:i}var n=e.ownerDocument.createElement("a");return n.href="",n.href}(),s=document.currentScript&&document.currentScript.getAttribute("crossorigin")||"anonymous";setTimeout((function(){if(!1===a){t=void 0;var i=u+"#"+n++,d=getModule(i,s);d.isTopLevel=!0;var c=beginWaitingForTurn(d,e,o);void 0!==r?whenModuleTerminated(getModule(r),(function(){beginWaitingOnDeps(c)})):beginWaitingOnDeps(c),r=i}}),0)},window.define._reset=function(){for(var o in e)delete e[o];t=void 0,n=0,r=void 0,i=getBaseUrl()};var o=document.createElement("a")}function stateTransition(e,t,n){var r=e;if(r.state=t,r.stateData=n,r.onNextStateChange.length>0){var i=r.onNextStateChange.slice();r.onNextStateChange.length=0;for(var o=0,a=i;o<a.length;o++){(0,a[o])()}}return r}function load(e){var n=stateTransition(e,"Loading",void 0),r=document.createElement("script");function removeScript(){try{document.head.removeChild(r)}catch(e){}}return r.src=e.url,null!==e.crossorigin&&r.setAttribute("crossorigin",e.crossorigin),r.onload=function(){var e,r,i;void 0!==t?(r=(e=t())[0],i=e[1]):(r=[],i=void 0),beginWaitingForTurn(n,r,i),removeScript()},r.onerror=function(){fail(e,new TypeError("Failed to fetch "+e.url)),removeScript()},document.head.appendChild(r),n}function beginWaitingForTurn(e,t,n){var r=loadDeps(e,t);return stateTransition(e,"WaitingForTurn",{args:r[0],deps:r[1],moduleBody:n})}function loadDeps(e,t){for(var n=[],r=[],i=0,o=t;i<o.length;i++){var a=o[i];if("exports"!==a)if("require"!==a)if("meta"!==a){var u=getModule(resolveUrl(e.urlBase,a),e.crossorigin);n.push(u.exports),r.push(u),"Initialized"===u.state&&load(u)}else n.push({url:!0===e.isTopLevel?e.url.substring(0,e.url.lastIndexOf("#")):e.url});else n.push((function(t,n,r){var i=loadDeps(e,t),o=i[0];executeDependenciesInOrder(i[1],(function(){n&&n.apply(null,o)}),r)}));else n.push(e.exports)}return[n,r]}function beginWaitingOnDeps(e){var t=stateTransition(e,"WaitingOnDeps",e.stateData);return executeDependenciesInOrder(e.stateData.deps,(function(){return function execute(e){var t=e.stateData;if(null!=t.moduleBody)try{t.moduleBody.apply(null,t.args)}catch(t){return fail(e,t)}return stateTransition(e,"Executed",void 0)}(t)}),(function(e){return fail(t,e)})),t}function fail(e,t){return!0===e.isTopLevel&&setTimeout((function(){throw t})),stateTransition(e,"Failed",t)}function executeDependenciesInOrder(e,t,n){var r=e.shift();void 0!==r?"WaitingOnDeps"!==r.state?waitForModuleWhoseTurnHasCome(r,(function(){executeDependenciesInOrder(e,t,n)}),n):executeDependenciesInOrder(e,t,n):t&&t()}function waitForModuleWhoseTurnHasCome(e,t,n){switch(e.state){case"WaitingForTurn":return beginWaitingOnDeps(e),void waitForModuleWhoseTurnHasCome(e,t,n);case"Failed":return void(n&&n(e.stateData));case"Executed":return void t();case"Loading":case"WaitingOnDeps":return void e.onNextStateChange.push((function(){return waitForModuleWhoseTurnHasCome(e,t,n)}));case"Initialized":throw new Error("All dependencies should be loading already before pressureDependencyToExecute is called.");default:throw new Error("Impossible module state: "+e.state)}}function whenModuleTerminated(e,t){switch(e.state){case"Executed":case"Failed":return void t();default:e.onNextStateChange.push((function(){return whenModuleTerminated(e,t)}))}}function getModule(t,n){void 0===n&&(n="anonymous");var r=e[t];return void 0===r&&(r=e[t]={url:t,urlBase:getUrlBase(t),exports:Object.create(null),state:"Initialized",stateData:void 0,isTopLevel:!1,crossorigin:n,onNextStateChange:[]}),r}function getUrlBase(e){return(e=(e=e.split("?")[0]).split("#")[0]).substring(0,e.lastIndexOf("/")+1)}function resolveUrl(e,t){return-1!==t.indexOf("://")?t:function normalizeUrl(e){return o.href=e,o.href}("/"===t[0]?t:e+t)}function getBaseUrl(){return document.baseURI||(document.querySelector("base")||window.location).href}}();