UNPKG

@steambrew/api

Version:

This sub-project is responsible for transpiling and assembling @steambrew/client and @steambrew/webkit into a bundle that is injectable into the Steam Client. `StartPreloader` is the main function that is called from the backend of Millennium in C++ with

3 lines (2 loc) 6.13 kB
!function(){const n={MILLENNIUM_FRONTEND_LIB_VERSION:"5.8.4",MILLENNIUM_BROWSER_LIB_VERSION:"5.8.4",MILLENNIUM_LOADER_BUILD_DATE:"2025-12-31T18:00:19.834Z"};try{if(process)return process.env=Object.assign({},process.env),void Object.assign(process.env,n)}catch(n){}globalThis.process={env:n}}();var n,e=function(){return e=Object.assign||function(n){for(var e,t=1,r=arguments.length;t<r;t++)for(var o in e=arguments[t])Object.prototype.hasOwnProperty.call(e,o)&&(n[o]=e[o]);return n},e.apply(this,arguments)};function t(n,e,t,r){return new(t||(t=Promise))(function(o,i){function c(n){try{u(r.next(n))}catch(n){i(n)}}function s(n){try{u(r.throw(n))}catch(n){i(n)}}function u(n){var e;n.done?o(n.value):(e=n.value,e instanceof t?e:new t(function(n){n(e)})).then(c,s)}u((r=r.apply(n,e||[])).next())})}function r(n,e){var t,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},c=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return c.next=s(0),c.throw=s(1),c.return=s(2),"function"==typeof Symbol&&(c[Symbol.iterator]=function(){return this}),c;function s(s){return function(u){return function(s){if(t)throw new TypeError("Generator is already executing.");for(;c&&(c=0,s[0]&&(i=0)),i;)try{if(t=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,r=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){i.label=s[1];break}if(6===s[0]&&i.label<o[1]){i.label=o[1],o=s;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(s);break}o[2]&&i.ops.pop(),i.trys.pop();continue}s=e.call(n,i)}catch(n){s=[6,n],r=0}finally{t=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}}function o(n,e,t){if(t||2===arguments.length)for(var r,o=0,i=e.length;o<i;o++)!r&&o in e||(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return n.concat(r||Array.prototype.slice.call(e))}!function(n){n[n.Client=0]="Client",n[n.Browser=1]="Browser"}(n||(n={}));var i=function(){function o(){this.millenniumAuthToken=void 0}return o.prototype.init=function(){return t(this,void 0,void 0,function(){var e;return r(this,function(t){switch(t.label){case 0:return[4,import("./chunks/chunk-logger.js")];case 1:return e=t.sent(),this.logger=new e.default("Bootstrap"),this.ctx="steamloopback.host"===window.location.hostname?n.Client:n.Browser,this.startTime=performance.now(),[2]}})})},o.prototype.injectLegacyReactGlobals=function(){return t(this,void 0,void 0,function(){var n,t,o,i,c,s;return r(this,function(r){switch(r.label){case 0:return this.logger.log("Injecting Millennium API..."),window.SP_REACT?[3,2]:(this.logger.log("Injecting legacy React globals..."),[4,import("./chunks/chunk-webpack.js")]);case 1:n=r.sent(),window.SP_REACT=n.findModule(function(n){return n.Component&&n.PureComponent&&n.useLayoutEffect}),window.SP_REACTDOM=n.findModule(function(n){return n.createPortal&&n.createRoot})||e(e({},n.findModule(function(n){return n.createPortal&&n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE})),n.findModule(function(n){return n.createRoot})),(t=null===(c=n.findModule(function(n){return n.jsx&&1==Object.keys(n).length}))||void 0===c?void 0:c.jsx)&&(window.SP_JSX_FACTORY={Fragment:window.SP_REACT.Fragment,jsx:t,jsxs:t}),r.label=2;case 2:return this.logger.log("Injecting Millennium frontend library..."),[4,import("./chunks/chunk-index.js")];case 3:return o=r.sent(),[4,import("./chunks/chunk-millennium-api.js")];case 4:return(i=r.sent()).setMillenniumAuthToken(this.millenniumAuthToken),Object.assign(null!==(s=window.MILLENNIUM_API)&&void 0!==s?s:window.MILLENNIUM_API={},o,i),this.logger.log("Millennium API injected successfully.",window.MILLENNIUM_API),[2]}})})},o.prototype.waitForClientReady=function(){var n=this;return new Promise(function(e){var o=setInterval(function(){return function(e,o){return t(n,void 0,void 0,function(){var n;return r(this,function(t){switch(t.label){case 0:return(null===(n=window.App)||void 0===n?void 0:n.BFinishedInitStageOne())?(clearInterval(o),[4,this.injectLegacyReactGlobals()]):[2];case 1:return t.sent(),e(),[2]}})})}(e,o)},0)})},o.prototype.StartPreloader=function(e,o,i){return t(this,void 0,void 0,function(){var t,c,s,u;return r(this,function(r){switch(r.label){case 0:return[4,this.init()];case 1:switch(r.sent(),this.millenniumAuthToken=e,window.MILLENNIUM_FRONTEND_LIB_VERSION=process.env.MILLENNIUM_FRONTEND_LIB_VERSION||"unknown",window.MILLENNIUM_BROWSER_LIB_VERSION=process.env.MILLENNIUM_FRONTEND_LIB_VERSION||"unknown",window.MILLENNIUM_LOADER_BUILD_DATE=process.env.MILLENNIUM_LOADER_BUILD_DATE||"unknown",this.ctx){case n.Client:return[3,2];case n.Browser:return[3,4]}return[3,11];case 2:return this.logger.log("Running in client context..."),[4,this.waitForClientReady()];case 3:case 10:return r.sent(),[3,12];case 4:return this.logger.log("Running in browser context..."),[4,import("./chunks/chunk-millennium-api.js")];case 5:return(t=r.sent()).setMillenniumAuthToken(this.millenniumAuthToken),window.MILLENNIUM_API=t,[4,import("./chunks/chunk-browser-init.js")];case 6:return[4,(c=r.sent()).appendRootColors()];case 7:return r.sent(),[4,c.appendAccentColor()];case 8:return r.sent(),[4,c.appendQuickCss()];case 9:return r.sent(),[4,c.addPluginDOMBreadCrumbs(i)];case 11:return this.logger.error("Unknown context, can't load Millennium:",this.ctx),[2];case 12:return this.logger.log("Loading user plugins..."),null==o||o.forEach(function(n){return!document.querySelector('script[src="'.concat(n,'"][type="module"]'))&&document.head.appendChild(Object.assign(document.createElement("script"),{src:n,type:"module",id:"millennium-injected"}))}),s=performance.now(),u=s-this.startTime,this.logger.log("Successfully injected shims into the DOM in ".concat(u.toFixed(2)," ms.")),[2]}})})},o}();export{t as _,r as a,e as b,o as c,i as default}; //# sourceMappingURL=millennium.js.map