@idosgames/app-shell 0.2.0 → 0.3.0
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.
- package/dist/index.cjs +3 -3
- package/dist/index.d.cts +22 -3
- package/dist/index.d.ts +22 -3
- package/dist/index.js +3 -3
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
'use strict';var client=require('react-dom/client'),react$1=require('@idosgames/react'),moduleSdk=require('@idosgames/module-sdk'),react=require('react'),core=require('@idosgames/core'),jsxRuntime=require('react/jsx-runtime');var we=50,U="host",Z=e=>typeof e=="string"?e:e.name,ee=e=>typeof e=="string"?null:e.shape,te=e=>e.replace(/@\d+$/,"");function T(){let e=new Map,o=new Map,t=[],l=new Set,n=r=>{t.push(r),t.length>we&&t.shift();},a=(r,s)=>{l.has(r)||(l.add(r),console.warn(s));},c=(r,s,p)=>{console.error(`[idos events] ${p}`),n({topic:s,from:r,at:Date.now(),delivered:0,rejected:p});},g=(r,s,p,f)=>{if(!moduleSdk.isTopicName(s)){c(r,s,`"${r}" emitted "${s}", which is not a topic name \u2014 use defineTopic("<module-id>:<event>@<major>", shape({\u2026})). Not delivered.`);return}let d=moduleSdk.topicNamespace(s);if(r!==U&&d===U){c(r,s,`"${r}" emitted "${s}", but the "host:" namespace belongs to the host. Not delivered.`);return}if(r!==U&&d!==r){c(r,s,`"${r}" emitted "${s}" into the "${d}" namespace \u2014 a module may only emit its own topics ("${r}:\u2026"). Not delivered.`);return}if(p){let S=p.check(f);S&&a(`emit|${r}|${s}`,`[idos events] "${r}" emitted "${s}" with a payload that does not match its own shape: ${S}. Fix the emit or the topic's shape (and module.meta.json).`);}let y=o.get(s);y||o.set(s,y=new Set),y.add(r);let b=0;for(let S of [...e.get(s)??[]]){if(S.shape){let v=S.shape.check(f);if(v){a(`on|${S.moduleId}|${s}`,`[idos events] "${S.moduleId}" skipped "${s}" from "${r}": ${v}. Its copy of the topic's shape no longer matches the emitter \u2014 re-copy it from the catalog.`);continue}}try{S.handler(f),b+=1;}catch(v){console.error(`[idos events] a "${s}" handler in "${S.moduleId}" threw \u2014 other listeners still received the event.`,v);}}n({topic:s,from:r,at:Date.now(),delivered:b});},u=(r,s,p)=>{let f=e.get(s);return f||e.set(s,f=new Set),f.add(p),()=>{let d=e.get(s);d&&(d.delete(p),d.size===0&&e.delete(s));}};return {forModule(r){let s=new Set,p=false;return {emit(d,y){p||g(r,Z(d),ee(d),y);},on(d,y){if(p)return ()=>{};let b=Z(d);moduleSdk.isTopicName(b)||console.warn(`[idos events] "${r}" subscribed to "${b}", which is not a topic name \u2014 nothing can ever be emitted to it.`);let S=u(r,b,{moduleId:r,shape:ee(d),handler:y});return s.add(S),()=>{S(),s.delete(S);}},dispose(){p=true;for(let d of s)d();s.clear();}}},emitAsHost(r,s){g(U,r.name,r.shape,s);},describe(){let r={};for(let[f,d]of e)r[f]=[...new Set([...d].map(y=>y.moduleId))];let s={};for(let[f,d]of o)s[f]=[...d];let p=[];for(let[f,d]of Object.entries(r)){if(o.has(f))continue;let y=[...o.keys()].filter(b=>b!==f&&te(b)===te(f));y.length>0&&p.push(`${d.join(", ")} listen${d.length===1?"s":""} to "${f}", but only ${y.map(b=>`"${b}"`).join(", ")} ${y.length===1?"has":"have"} been emitted \u2014 the major versions differ, so these never meet.`);}return {log:t.slice(),listeners:r,emitted:s,mismatches:p}}}}function xe(){let e=new Map;return {emit(o,t){let l=e.get(o);if(l)for(let n of [...l])n(t);},on(o,t){let l=t,n=e.get(o);return n||(n=new Set,e.set(o,n)),n.add(l),()=>{n.delete(l),n.size===0&&e.delete(o);}}}}function re(){return Object.fromEntries(moduleSdk.SHARED_UI_ROLES.map(e=>[e,null]))}function I(e){let o=re(),t=[],l=moduleSdk.SHARED_UI_ROLES.join(", ");for(let n of e)for(let a of n.sharedUi?.provides??[]){if(!moduleSdk.isSharedUiRole(a)){t.push(`module "${n.id}" provides unknown shared UI role "${String(a)}" (known: ${l}) \u2014 ignored.`);continue}let c=o[a];c===null?o[a]=n.id:c!==n.id&&t.push(`shared UI role "${a}" is provided by both "${c}" and "${n.id}" \u2014 "${c}" wins (it comes first in src/modules.ts), "${n.id}" hides its copy.`);}for(let n of e)for(let a of n.sharedUi?.requires??[]){if(!moduleSdk.isSharedUiRole(a)){t.push(`module "${n.id}" requires unknown shared UI role "${String(a)}" (known: ${l}).`);continue}o[a]===null&&t.push(`module "${n.id}" requires shared UI role "${a}", but no installed module provides it \u2014 install game-hud (or another module that provides "${a}").`);}return {owners:o,warnings:t}}function D(e,o){let t=l=>e[l]??null;return {ownerOf:t,shouldDraw:l=>{let n=t(l);return n===null||n===o}}}var Re={position:"absolute",inset:"0"};function B(e){return {request(o){let t=document.createElement("div");return t.dataset.surface=o,Object.assign(t.style,Re),t.style.pointerEvents=o==="fullbleed-canvas"?"auto":"none",e.appendChild(t),{host:t,release(){t.remove();}}}}}var Ee="__IDOS_AGENT__",se={},ie,le;function ke(){try{return typeof window<"u"&&window.self!==window.top}catch{return true}}function z(e,o){se[e]=o,_();}function G(e){ie=e,_();}function N(e){le=e,_();}function _(){if(!ke())return;let e={version:1,modules:se,host:ie,events:le};globalThis[Ee]=e;}function j(e,o){let t=o.sharedUi??I(e).owners,l=[];try{for(let n of e){let a=o.events.forModule(n.id),c={module:n,scenes:[],panels:[],routes:[],dispose:()=>a.dispose()};l.push(c);let g={client:o.client,titleId:o.client.titleID,events:a,sharedUi:D(t,n.id),surface:o.surface,registerScene:u=>c.scenes.push(u),registerPanel:u=>c.panels.push(u),registerRoute:u=>c.routes.push(u),exposeToAgent:u=>z(n.id,u)};n.setup(g);}}catch(n){for(let a of l)a.dispose();throw n}return l}var C=class{constructor(o){this.container=o;}container;hosts=new Map;active=new Set;ensureMounted(o){let t=this.hosts.get(o);return t||(t=document.createElement("div"),Object.assign(t.style,{position:"absolute",inset:"0"}),this.container.appendChild(t),this.hosts.set(o,t),o.mount({host:t})),t}setActive(o){let t=new Set(o);for(let l of this.active){if(t.has(l))continue;l.suspend?.();let n=this.hosts.get(l);n&&(n.style.display="none");}for(let l of t){if(this.active.has(l))continue;let n=this.ensureMounted(l);n.style.display="block",l.activate?.();}this.active=t;}destroy(){for(let[o,t]of this.hosts)o.destroy(),t.remove();this.hosts.clear(),this.active.clear();}};function K({registrations:e,sharedUi:o,events:t,onLogout:l,userID:n}){let a=react.useRef(null),c=react.useRef(null),g=react.useMemo(()=>e.flatMap(i=>i.routes.map(m=>({id:m.id,label:m.label,icon:m.icon,order:m.order??0,moduleId:i.module.id}))).sort((i,m)=>i.order-m.order),[e]),[u,r]=react.useState(()=>g[0]?.id??null);react.useEffect(()=>{u!==null&&g.some(i=>i.id===u)||r(g[0]?.id??null);},[g,u]);let s=react.useMemo(()=>g.find(i=>i.id===u)?.moduleId??null,[g,u]),p=react.useRef(null);react.useEffect(()=>{if(u===null||u===p.current)return;let i=p.current;p.current=u,t?.emitAsHost(moduleSdk.hostTopics.modeChanged,i===null?{to:u}:{from:i,to:u});},[u,t]),react.useEffect(()=>{let i=a.current;if(!i)return;let m=c.current??=new C(i),M=e.find(L=>L.module.id===s)?.scenes??[];m.setActive(M);},[e,s]),react.useEffect(()=>()=>{c.current?.destroy(),c.current=null;},[]);let f=react.useMemo(()=>e.flatMap(i=>i.panels.filter(m=>m.activeOnly===false||i.module.id===s).map(m=>{let M=m.component;return {key:`${i.module.id}:${m.id}`,slot:m.slot,order:m.order??0,moduleId:i.module.id,component:jsxRuntime.jsx(M,{})}})).sort((i,m)=>i.order-m.order),[e,s]),d=i=>f.filter(m=>m.slot===i),y=e.length>0,b=d("hud").length,S=g.length>1,v=!o?.account,x=react.useRef(null),E=react.useRef(null),[k,ye]=react.useState({top:0,bottom:0});react.useLayoutEffect(()=>{let i=()=>{let M=b>0&&x.current?Math.ceil(x.current.getBoundingClientRect().height):0,L=S&&E.current?Math.ceil(E.current.getBoundingClientRect().height)+de:0;ye(O=>O.top===M&&O.bottom===L?O:{top:M,bottom:L});};if(i(),typeof ResizeObserver>"u")return;let m=new ResizeObserver(i);return x.current&&m.observe(x.current),E.current&&m.observe(E.current),()=>m.disconnect()},[b,S]);let Se={...He,"--idos-safe-top":`${k.top}px`,"--idos-safe-bottom":`${k.bottom}px`};return jsxRuntime.jsxs("div",{style:Se,children:[jsxRuntime.jsx("div",{ref:a,style:Le}),jsxRuntime.jsx("div",{style:{...Ue,top:k.top,bottom:k.bottom},children:d("overlay").map(i=>jsxRuntime.jsx("div",{style:V,children:i.component},i.key))}),jsxRuntime.jsx("div",{ref:x,style:Pe,children:d("hud").map(i=>jsxRuntime.jsx("div",{style:$e,children:i.component},i.key))}),jsxRuntime.jsx("div",{style:{...Oe,top:k.top,bottom:k.bottom},children:d("sidebar").map(i=>jsxRuntime.jsx("div",{style:V,children:i.component},i.key))}),S&&jsxRuntime.jsx("nav",{ref:E,style:Te,children:g.map(i=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>r(i.id),style:i.id===u?De:ce,children:[i.icon?`${i.icon} `:"",i.label]},i.id))}),v&&(l||n)&&jsxRuntime.jsxs("div",{style:Be,children:[l&&jsxRuntime.jsx("button",{type:"button",style:ue,onClick:l,title:"Log out",children:"\u{1F6AA} Log out"}),n&&jsxRuntime.jsx(Ie,{userID:n})]}),d("modal").length>0&&jsxRuntime.jsx("div",{style:Ge,children:d("modal").map(i=>jsxRuntime.jsx("div",{style:V,children:i.component},i.key))}),!y&&jsxRuntime.jsx(Ce,{})]})}function Ie({userID:e}){let[o,t]=react.useState(false),l=()=>{(async()=>{try{await navigator.clipboard.writeText(e);}catch{let a=document.createElement("textarea");a.value=e,document.body.appendChild(a),a.select(),document.execCommand("copy"),a.remove();}t(true),window.setTimeout(()=>t(false),1500);})();},n=e.length>12?`${e.slice(0,5)}\u2026${e.slice(-5)}`:e;return jsxRuntime.jsx("button",{type:"button",style:ze,onClick:l,title:`Copy your player ID: ${e}`,children:o?"\u2713 Copied":`ID: ${n} \u29C9`})}function Ce(){return jsxRuntime.jsxs("div",{style:Ne,children:[jsxRuntime.jsx("style",{children:`
|
|
1
|
+
'use strict';var client=require('react-dom/client'),react$1=require('@idosgames/react'),moduleSdk=require('@idosgames/module-sdk'),react=require('react'),core=require('@idosgames/core'),jsxRuntime=require('react/jsx-runtime');var Ee=50,T="host",ne=e=>typeof e=="string"?e:e.name,re=e=>typeof e=="string"?null:e.shape,se=e=>e.replace(/@\d+$/,"");function D(){let e=new Map,o=new Map,t=[],s=new Set,i=r=>{t.push(r),t.length>Ee&&t.shift();},l=(r,n)=>{s.has(r)||(s.add(r),console.warn(n));},d=(r,n,c)=>{console.error(`[idos events] ${c}`),i({topic:n,from:r,at:Date.now(),delivered:0,rejected:c});},y=(r,n,c,p)=>{if(!moduleSdk.isTopicName(n)){d(r,n,`"${r}" emitted "${n}", which is not a topic name \u2014 use defineTopic("<module-id>:<event>@<major>", shape({\u2026})). Not delivered.`);return}let u=moduleSdk.topicNamespace(n);if(r!==T&&u===T){d(r,n,`"${r}" emitted "${n}", but the "host:" namespace belongs to the host. Not delivered.`);return}if(r!==T&&u!==r){d(r,n,`"${r}" emitted "${n}" into the "${u}" namespace \u2014 a module may only emit its own topics ("${r}:\u2026"). Not delivered.`);return}if(c){let v=c.check(p);v&&l(`emit|${r}|${n}`,`[idos events] "${r}" emitted "${n}" with a payload that does not match its own shape: ${v}. Fix the emit or the topic's shape (and module.meta.json).`);}let m=o.get(n);m||o.set(n,m=new Set),m.add(r);let S=0;for(let v of [...e.get(n)??[]]){if(v.shape){let x=v.shape.check(p);if(x){l(`on|${v.moduleId}|${n}`,`[idos events] "${v.moduleId}" skipped "${n}" from "${r}": ${x}. Its copy of the topic's shape no longer matches the emitter \u2014 re-copy it from the catalog.`);continue}}try{v.handler(p),S+=1;}catch(x){console.error(`[idos events] a "${n}" handler in "${v.moduleId}" threw \u2014 other listeners still received the event.`,x);}}i({topic:n,from:r,at:Date.now(),delivered:S});},g=(r,n,c)=>{let p=e.get(n);return p||e.set(n,p=new Set),p.add(c),()=>{let u=e.get(n);u&&(u.delete(c),u.size===0&&e.delete(n));}};return {forModule(r){let n=new Set,c=false;return {emit(u,m){c||y(r,ne(u),re(u),m);},on(u,m){if(c)return ()=>{};let S=ne(u);moduleSdk.isTopicName(S)||console.warn(`[idos events] "${r}" subscribed to "${S}", which is not a topic name \u2014 nothing can ever be emitted to it.`);let v=g(r,S,{moduleId:r,shape:re(u),handler:m});return n.add(v),()=>{v(),n.delete(v);}},dispose(){c=true;for(let u of n)u();n.clear();}}},emitAsHost(r,n){y(T,r.name,r.shape,n);},describe(){let r={};for(let[p,u]of e)r[p]=[...new Set([...u].map(m=>m.moduleId))];let n={};for(let[p,u]of o)n[p]=[...u];let c=[];for(let[p,u]of Object.entries(r)){if(o.has(p))continue;let m=[...o.keys()].filter(S=>S!==p&&se(S)===se(p));m.length>0&&c.push(`${u.join(", ")} listen${u.length===1?"s":""} to "${p}", but only ${m.map(S=>`"${S}"`).join(", ")} ${m.length===1?"has":"have"} been emitted \u2014 the major versions differ, so these never meet.`);}return {log:t.slice(),listeners:r,emitted:n,mismatches:c}}}}function ke(){let e=new Map;return {emit(o,t){let s=e.get(o);if(s)for(let i of [...s])i(t);},on(o,t){let s=t,i=e.get(o);return i||(i=new Set,e.set(o,i)),i.add(s),()=>{i.delete(s),i.size===0&&e.delete(o);}}}}function le(){return Object.fromEntries(moduleSdk.SHARED_UI_ROLES.map(e=>[e,null]))}function A(e){let o=le(),t=[],s=moduleSdk.SHARED_UI_ROLES.join(", ");for(let i of e)for(let l of i.sharedUi?.provides??[]){if(!moduleSdk.isSharedUiRole(l)){t.push(`module "${i.id}" provides unknown shared UI role "${String(l)}" (known: ${s}) \u2014 ignored.`);continue}let d=o[l];d===null?o[l]=i.id:d!==i.id&&t.push(`shared UI role "${l}" is provided by both "${d}" and "${i.id}" \u2014 "${d}" wins (it comes first in src/modules.ts), "${i.id}" hides its copy.`);}for(let i of e)for(let l of i.sharedUi?.requires??[]){if(!moduleSdk.isSharedUiRole(l)){t.push(`module "${i.id}" requires unknown shared UI role "${String(l)}" (known: ${s}).`);continue}o[l]===null&&t.push(`module "${i.id}" requires shared UI role "${l}", but no installed module provides it \u2014 install game-hud (or another module that provides "${l}").`);}return {owners:o,warnings:t}}function B(e,o){let t=s=>e[s]??null;return {ownerOf:t,shouldDraw:s=>{let i=t(s);return i===null||i===o}}}var Me={position:"absolute",inset:"0"};function N(e){return {request(o){let t=document.createElement("div");return t.dataset.surface=o,Object.assign(t.style,Me),t.style.pointerEvents=o==="fullbleed-canvas"?"auto":"none",e.appendChild(t),{host:t,release(){t.remove();}}}}}var Ce="__IDOS_AGENT__",de={},ce,ue;function He(){try{return typeof window<"u"&&window.self!==window.top}catch{return true}}function z(e,o){de[e]=o,j();}function G(e){ce=e,j();}function _(e){ue=e,j();}function j(){if(!He())return;let e={version:1,modules:de,host:ce,events:ue};globalThis[Ce]=e;}function W(){let e=new Map,o=new Set,t=()=>{for(let s of o)s();};return {registerType(s){if(!s?.type)throw new Error("ctx.content.registerType(): handler.type is required");return e.set(s.type,s),t(),()=>{e.get(s.type)===s&&(e.delete(s.type),t());}},getType:s=>e.get(s),listTypes:()=>[...e.values()],subscribe(s){return o.add(s),()=>{o.delete(s);}}}}function V(){let e=null,o=null;return {navigate(t){t&&(e?e(t):o=t);},bind(t){if(e=t,o!==null){let s=o;o=null,t(s);}return ()=>{e===t&&(e=null);}}}}function F(e,o){let t=o.sharedUi??A(e).owners,s=o.content??W(),i=[];try{for(let l of e){let d=o.events.forModule(l.id),y=[],g={module:l,scenes:[],panels:[],routes:[],dispose:()=>{d.dispose();for(let n of y.splice(0))n();}};i.push(g);let r={client:o.client,titleId:o.client.titleID,events:d,sharedUi:B(t,l.id),surface:o.surface,registerScene:n=>g.scenes.push(n),registerPanel:n=>g.panels.push(n),registerRoute:n=>g.routes.push(n),content:{registerType:n=>{let c=s.registerType(n);return y.push(c),c},getType:n=>s.getType(n),listTypes:()=>s.listTypes(),subscribe:n=>s.subscribe(n)},navigate:n=>o.navigator?.navigate(n),exposeToAgent:n=>z(l.id,n)};l.setup(r);}}catch(l){for(let d of i)d.dispose();throw l}return i}var I=class{constructor(o){this.container=o;}container;hosts=new Map;active=new Set;ensureMounted(o){let t=this.hosts.get(o);return t||(t=document.createElement("div"),Object.assign(t.style,{position:"absolute",inset:"0"}),this.container.appendChild(t),this.hosts.set(o,t),o.mount({host:t})),t}setActive(o){let t=new Set(o);for(let s of this.active){if(t.has(s))continue;s.suspend?.();let i=this.hosts.get(s);i&&(i.style.display="none");}for(let s of t){if(this.active.has(s))continue;let i=this.ensureMounted(s);i.style.display="block",s.activate?.();}this.active=t;}destroy(){for(let[o,t]of this.hosts)o.destroy(),t.remove();this.hosts.clear(),this.active.clear();}};function X({registrations:e,sharedUi:o,events:t,onLogout:s,userID:i,navigator:l}){let d=react.useRef(null),y=react.useRef(null),g=react.useMemo(()=>e.flatMap(a=>a.routes.map(f=>({id:f.id,label:f.label,icon:f.icon,order:f.order??0,moduleId:a.module.id}))).sort((a,f)=>a.order-f.order),[e]),[r,n]=react.useState(()=>g[0]?.id??null);react.useEffect(()=>{r!==null&&g.some(a=>a.id===r)||n(g[0]?.id??null);},[g,r]),react.useEffect(()=>l?.bind(a=>{g.some(f=>f.id===a)&&n(a);}),[l,g]);let c=react.useMemo(()=>g.find(a=>a.id===r)?.moduleId??null,[g,r]),p=react.useRef(null);react.useEffect(()=>{if(r===null||r===p.current)return;let a=p.current;p.current=r,t?.emitAsHost(moduleSdk.hostTopics.modeChanged,a===null?{to:r}:{from:a,to:r});},[r,t]),react.useEffect(()=>{let a=d.current;if(!a)return;let f=y.current??=new I(a),C=e.find(U=>U.module.id===c)?.scenes??[];f.setActive(C);},[e,c]),react.useEffect(()=>()=>{y.current?.destroy(),y.current=null;},[]);let u=react.useMemo(()=>e.flatMap(a=>a.panels.filter(f=>f.activeOnly===false||a.module.id===c).map(f=>{let C=f.component;return {key:`${a.module.id}:${f.id}`,slot:f.slot,order:f.order??0,moduleId:a.module.id,component:jsxRuntime.jsx(C,{})}})).sort((a,f)=>a.order-f.order),[e,c]),m=a=>u.filter(f=>f.slot===a),S=e.length>0,v=m("hud").length,x=g.length>1,b=!o?.account,R=react.useRef(null),k=react.useRef(null),[M,we]=react.useState({top:0,bottom:0});react.useLayoutEffect(()=>{let a=()=>{let C=v>0&&R.current?Math.ceil(R.current.getBoundingClientRect().height):0,U=x&&k.current?Math.ceil(k.current.getBoundingClientRect().height)+fe:0;we(O=>O.top===C&&O.bottom===U?O:{top:C,bottom:U});};if(a(),typeof ResizeObserver>"u")return;let f=new ResizeObserver(a);return R.current&&f.observe(R.current),k.current&&f.observe(k.current),()=>f.disconnect()},[v,x]);let xe={...Ue,"--idos-safe-top":`${M.top}px`,"--idos-safe-bottom":`${M.bottom}px`};return jsxRuntime.jsxs("div",{style:xe,children:[jsxRuntime.jsx("div",{ref:d,style:Te}),jsxRuntime.jsx("div",{style:{...Pe,top:M.top,bottom:M.bottom},children:m("overlay").map(a=>jsxRuntime.jsx("div",{style:K,children:a.component},a.key))}),jsxRuntime.jsx("div",{ref:R,style:De,children:m("hud").map(a=>jsxRuntime.jsx("div",{style:Oe,children:a.component},a.key))}),jsxRuntime.jsx("div",{style:{...Be,top:M.top,bottom:M.bottom},children:m("sidebar").map(a=>jsxRuntime.jsx("div",{style:K,children:a.component},a.key))}),x&&jsxRuntime.jsx("nav",{ref:k,style:Ne,children:g.map(a=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>n(a.id),style:a.id===r?ze:ge,children:[a.icon?`${a.icon} `:"",a.label]},a.id))}),b&&(s||i)&&jsxRuntime.jsxs("div",{style:Ge,children:[s&&jsxRuntime.jsx("button",{type:"button",style:me,onClick:s,title:"Log out",children:"\u{1F6AA} Log out"}),i&&jsxRuntime.jsx(Le,{userID:i})]}),m("modal").length>0&&jsxRuntime.jsx("div",{style:je,children:m("modal").map(a=>jsxRuntime.jsx("div",{style:K,children:a.component},a.key))}),!S&&jsxRuntime.jsx($e,{})]})}function Le({userID:e}){let[o,t]=react.useState(false),s=()=>{(async()=>{try{await navigator.clipboard.writeText(e);}catch{let l=document.createElement("textarea");l.value=e,document.body.appendChild(l),l.select(),document.execCommand("copy"),l.remove();}t(true),window.setTimeout(()=>t(false),1500);})();},i=e.length>12?`${e.slice(0,5)}\u2026${e.slice(-5)}`:e;return jsxRuntime.jsx("button",{type:"button",style:_e,onClick:s,title:`Copy your player ID: ${e}`,children:o?"\u2713 Copied":`ID: ${i} \u29C9`})}function $e(){return jsxRuntime.jsxs("div",{style:We,children:[jsxRuntime.jsx("style",{children:`
|
|
2
2
|
@keyframes idos-empty-float {
|
|
3
3
|
0%, 100% { transform: translateY(0) rotate(-6deg); }
|
|
4
4
|
50% { transform: translateY(-16px) rotate(6deg); }
|
|
@@ -7,5 +7,5 @@
|
|
|
7
7
|
0% { transform: scale(0.55); opacity: 0.55; }
|
|
8
8
|
100% { transform: scale(1.7); opacity: 0; }
|
|
9
9
|
}
|
|
10
|
-
`}),jsxRuntime.jsxs("div",{style:_e,children:[jsxRuntime.jsx("span",{style:{...ae,animationDelay:"0s"}}),jsxRuntime.jsx("span",{style:{...ae,animationDelay:"1.1s"}}),jsxRuntime.jsx("span",{style:je,children:"\u{1F9E9}"})]}),jsxRuntime.jsx("div",{style:{fontWeight:700,fontSize:18,marginBottom:6},children:"No modules installed"}),jsxRuntime.jsxs("div",{style:{opacity:.85,maxWidth:380,lineHeight:1.5},children:["Add a module under ",jsxRuntime.jsx("code",{children:"src/modules/"})," and register it in"," ",jsxRuntime.jsx("code",{children:"src/modules.ts"}),". The host shell will pick it up here."]})]})}var He={position:"absolute",inset:0,overflow:"hidden",background:"#0d66fe",color:"#fff",fontFamily:"system-ui, sans-serif"},Le={position:"absolute",inset:0,zIndex:0},de=16,Ue={position:"absolute",top:0,right:0,bottom:0,left:0,zIndex:1,pointerEvents:"none"},$e={display:"contents",pointerEvents:"auto"},Pe={position:"absolute",top:0,left:0,right:0,zIndex:2,display:"flex",gap:12,padding:16,pointerEvents:"none"},Oe={position:"absolute",top:0,right:0,bottom:0,width:340,maxWidth:"40vw",zIndex:2,display:"flex",flexDirection:"column",gap:12,padding:16,overflowY:"auto",pointerEvents:"none"},Te={position:"absolute",bottom:de,left:"50%",transform:"translateX(-50%)",zIndex:3,display:"flex",gap:8,padding:6,borderRadius:14,background:"rgba(4,32,90,0.72)",backdropFilter:"blur(6px)",pointerEvents:"auto"},ce={border:"none",borderRadius:10,padding:"8px 16px",fontWeight:700,fontSize:14,color:"#cfe0ff",background:"transparent",cursor:"pointer"},De={...ce,color:"#0d66fe",background:"#fff"},Be={position:"absolute",bottom:16,left:16,zIndex:3,display:"flex",gap:8,alignItems:"center",pointerEvents:"auto"},ue={border:"none",borderRadius:12,padding:"8px 14px",fontWeight:700,fontSize:13,color:"#cfe0ff",background:"rgba(4,32,90,0.72)",backdropFilter:"blur(6px)",cursor:"pointer"},ze={...ue,fontWeight:600,fontFamily:"ui-monospace, Consolas, monospace"},Ge={position:"absolute",inset:0,zIndex:4,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0,0,0,0.5)",pointerEvents:"none"},V={pointerEvents:"auto"},Ne={position:"absolute",inset:0,zIndex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",textAlign:"center",padding:24},_e={position:"relative",width:110,height:110,marginBottom:16,display:"grid",placeItems:"center"},ae={position:"absolute",inset:0,borderRadius:"50%",border:"2px solid rgba(255,255,255,0.55)",animation:"idos-empty-ripple 2.2s ease-out infinite"},je={fontSize:46,animation:"idos-empty-float 3s ease-in-out infinite",filter:"drop-shadow(0 8px 12px rgba(0,0,0,0.25))"};function q(e){let{client:o,modules:t,events:l,sharedUi:n,surface:a,renderLogin:c}=e,[g,u]=react.useState(true),[r,s]=react.useState(null),p=react.useRef(null),f=()=>{for(let v of p.current??[])v.dispose();p.current=null;},d=()=>{f();let v=j(t,{client:o,events:l,surface:a,sharedUi:n});p.current=v,s(v);};react.useEffect(()=>()=>f(),[]);let y=react.useRef(false);react.useEffect(()=>{if(y.current)return;y.current=true;let v=core.readSsoCodeFromUrl();if(v){(async()=>((await o.auth.loginWithSsoCode(v.code)).ok&&d(),u(false)))();return}if(o.auth.lastAuthType===core.AuthType.None){u(false);return}(async()=>((await o.auth.autoLogin()).ok&&d(),u(false)))();},[o]),react.useEffect(()=>{let v=()=>{f(),s(null);},x=o.on("auth:unauthorized",v),E=o.on("auth:loggedOut",v);return ()=>{x(),E();}},[o]);let b=r?"game":g?"loading":"login";return react.useEffect(()=>{G({screen:b,loggedIn:r!==null,userId:o.auth.context?.userID??null,titleId:o.titleID??null,modules:t.map(v=>v.id),sharedUi:n});},[b,r,o,t,n]),r?jsxRuntime.jsx(K,{registrations:r,sharedUi:n,events:l,onLogout:()=>o.auth.logout(),userID:o.auth.context?.userID??null}):g?null:jsxRuntime.jsx(c,{client:o,onAuthenticated:d})}var Fe='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 860 690" fill="#fff"><g transform="translate(243 -2)"><path d="M147.333 12.333c-13.6 2.534-12.533 1.2-12.933 15.067l-.4 12.267-4.533-11.067c-2.534-6-5.067-10.933-5.734-10.933-2.666 0-27.866 8.666-36.533 12.666-11.733 5.334-26.667 14.8-36.133 22.934l-6.934 5.866L51.6 69.267c8.133 11.066 7.333 11.466-5.067 2.933-7.6-5.067-8.4-5.333-11.466-3.733-3.467 1.866-18.4 17.333-20.4 21.2-.8 1.6 7.066 8.8 33.733 30.933l34.667 28.933 8.8-8.266c14.666-13.867 28.666-22 48.133-28.267 9.067-2.933 14.8-3.733 28.533-4.4 34.267-1.333 60 7.467 81.6 28.133 21.6 20.4 34.934 49.6 37.467 81.734l.8 11.2 14.8 4.533c8.133 2.533 23.733 7.333 34.667 10.8 10.933 3.333 20.4 5.6 21.066 4.933 1.6-1.6 6.134-20.533 7.734-32.666.8-6 1.333-17.6 1.066-25.6l-.4-14.667-8-1.067c-4.4-.533-10.133-1.466-12.666-1.866l-4.667-.8 4.667-1.2c16.933-4.534 18.666-5.2 18.666-8 0-5.467-9.6-31.334-16.666-44.8-4-7.6-10.667-18.667-14.934-24.667-9.866-13.867-31.333-35.467-45.2-45.2-10.4-7.467-34.4-20.933-37.2-21.067-.8 0-4 4-7.333 8.8-3.2 4.8-6.133 8.134-6.4 7.334s.4-5.6 1.6-10.667c1.2-5.2 2.133-9.6 2.133-9.867 0-.933-19.866-6.133-34.4-9.066-14.8-2.934-49.333-4.4-59.6-2.534"/><path d="M157.867 125.533c-21.067 3.334-42.134 14.8-57.467 31.334-13.333 14.133-13.733 12.8 5.6 22 9.2 4.4 16.667 8.266 16.667 8.533s-1.334.4-2.934.133c-13.866-2.133-41.6-5.866-41.733-5.6-.267.267-7.467 28.534-16.267 63.067l-16 62.667 7.334.4c4 .266 7.466.266 7.6 0 .266-.267 3.866-13.867 8.133-30.4 4.267-16.534 8.267-30.8 8.933-31.734.934-1.2 11.067-1.6 42.4-1.6 32.134 0 41.2.4 41.2 1.6 0 .934-1.733 4.667-3.866 8.4L153.733 261l-35.066 6.933c-19.334 3.867-35.2 7.2-35.467 7.467-.667.667-29.867 113.467-29.467 113.867.267.133 23.734-3.6 52.4-8.534l52-8.8 20.4-39.866c11.2-22 20.667-39.734 20.934-39.467.4.533-1.334 26.8-2.8 40.8l-.667 6.933 6.267-3.2c21.2-10.666 52.4-13.466 86.933-8l5.867.934-5.6-7.334C286.4 318.6 281.2 310.6 278 304.867c-5.867-10.134-6-10.8-6-21.867 0-6.267 1.467-20 3.333-30.667 1.867-10.666 3.334-19.466 3.334-19.466 0-.134-9.067-4.267-20.134-9.334s-19.466-9.333-18.8-9.6c.8-.266 7.734.8 15.6 2.267 7.734 1.6 14.4 2.8 14.8 2.8 1.2 0 .4-10.533-1.466-18-7.2-27.733-28-53.467-53.734-66-16.4-8-40.8-12-57.066-9.467"/><path d="M235.6 346.333c-24 4.534-44.133 13.867-68.267 31.467-14 10.267-28.533 18.133-47.733 25.867-23.467 9.466-52.8 32.666-64.4 50.666l-2.533 4L58 454.2c9.333-7.333 30.133-19.467 49.333-28.667C173.733 393.667 246.4 382.2 312.8 393c11.2 1.733 39.2 8.533 45.067 10.8 2.266.8 2.266.667.8-2.267-4-7.6-15.6-21.866-25.867-31.466-12-11.467-24.667-18.934-37.6-22.4-11.467-3.067-46.267-3.867-59.6-1.334"/></g><g transform="translate(-460 467)"><path d="M721.533 34.467c-14.933 5.466-22 17.466-22.933 38.666-.933 24.134 3.467 32.8 30.267 59.867 19.6 19.867 22.933 25.2 22.933 37.867.133 13.466-6.133 20.133-16.933 18.4-9.067-1.467-12.534-7.867-12.534-22.667V159H696.6l.667 13.333c.533 11.467 1.2 14.4 4.933 22 7.067 14.267 16.8 19.6 36.4 19.734 10.667.133 12.267-.134 20.667-4.4 7.6-3.867 9.733-5.867 13.2-11.734 7.6-12.533 9.066-32 3.733-47.6-3.733-11.066-10.667-20.4-27.867-37.2-19.866-19.6-22.533-24.133-22.666-38.4 0-8.933.4-10.533 3.2-13.6 6.266-6.666 18.266-5.6 22.133 2 1.067 2 2 7.067 2 11.2v7.334h27.067l-.934-9.2c-1.6-18.267-8.266-30.267-20-36.4-7.2-3.867-29.2-4.8-37.6-1.6M630.067 34.867c-11.734 4.666-18 11.6-21.734 24.4-1.866 6.4-2 15.333-1.733 67.2l.4 59.866 3.733 7.6c6.8 13.867 18.534 20.267 36.934 20.267 13.733 0 22.933-3.333 30.666-11.067 10.934-11.066 11.2-12.533 11.734-74.666.266-35.734-.134-56.934-1.067-62.8-2.667-16.134-11.6-27.467-24.8-31.467-8.933-2.667-26.4-2.267-34.133.667m28.666 26.8 3.6 4v56.666c0 40.934-.4 57.467-1.6 60-3.6 8-15.6 9.734-22.666 3.467l-4.4-3.867-.4-56.533c-.267-51.733-.134-56.8 2-61.067 3.066-5.866 7.6-8.266 14.4-7.466 3.733.4 6.4 1.866 9.066 4.8M511.667 123.133v89.334l29.066-.4c28.8-.4 28.934-.4 36.667-4.267 9.467-4.533 14.4-10.933 17.467-22.4 2-7.333 2.266-15.467 1.866-65.733l-.4-57.334-4.266-8.8c-8.267-16.666-17.2-19.866-55.334-19.866h-25.066zm53.6-60.266 4.4 3.866.4 52.8c.266 35.067-.134 54.4-1.067 58-2 7.467-5.733 9.6-18.667 10.4l-10.666.8V59h10.666c9.867 0 10.934.267 14.934 3.867M471.667 145v67.333h26.666V77.667h-26.666zM471.667 48.333V63h26.666V33.667h-26.666z"/></g><g transform="translate(-106 244)"><path d="M893.4 259.733c-6.8 3.467-9.2 5.6-12.667 11.467-10.666 17.733-9.2 42.933 3.467 62.267 2.8 4.266 12.267 14.8 20.933 23.333 9.867 9.467 17.067 17.733 18.934 21.6 5.6 11.333 5.2 25.333-.934 30.8-3.466 3.067-11.333 4.133-16.133 2.133-5.867-2.4-8-7.466-8-19.333v-10h-27.067l.8 11.6c1.2 15.867 3.867 24.133 10.267 31.333 7.467 8.534 16.4 12.134 30 12.267 19.067.133 30.133-5.733 37.333-19.867 3.734-7.466 4-8.666 4-24 0-16 0-16.133-5.2-26.666-4.4-9.2-7.733-13.2-23.066-28.534-21.067-21.066-24.8-27.066-24.934-40.4-.133-10.4 2.8-15.6 9.734-17.6 10.133-2.933 17.2 3.334 18.4 16.267l.8 8.267H955.4l-.8-10.8c-.533-8.4-1.6-12.667-4.8-19.2-7.067-14.134-16.667-19.334-36.133-19.334-10.667 0-12.534.4-20.267 4.4M791 346v89.333h76v-24h-48v-54.666h37.333v-24H819V282h48v-25.333h-76zM661.667 346v89.333h22.666l.134-63.066c0-34.534.533-61.734 1.066-60.267.534 1.467 5.467 29.867 10.8 62.933l9.867 60.4h13.067c7.2 0 13.066-.4 13.066-1.066 0-3.067 18.8-124.8 19.334-125.334.4-.4.666 27.867.666 62.8v63.6h25.334V256.667h-38l-9.2 61.6c-5.067 34-9.6 62.133-10 62.666-.534.534-5.334-26.4-10.667-60-5.467-33.466-10.133-61.733-10.533-62.666-.4-1.2-5.467-1.6-19.067-1.6h-18.533zM586.467 258.267c-.8 2.666-27.467 172.4-27.467 174.933 0 1.867 1.733 2.133 12 2.133h11.867l.8-4.4c.533-2.266 1.6-9.333 2.4-15.6l1.6-11.333 17.6-.4 17.466-.4 1.467 8.4c.8 4.667 1.733 11.867 2.267 16l.933 7.733h13.733c7.6 0 13.867-.266 13.867-.666 0-.8-26.533-168.134-27.467-173.734l-.8-4.266h-19.866c-14.8 0-20.134.4-20.4 1.6M613 336.533c3.333 23.067 5.867 42.134 5.6 42.4-.4.267-6.533.267-13.867.134l-13.2-.4 4.934-33.334c2.8-18.4 5.733-38.4 6.666-44.666C604.2 292.533 605 290.133 605.8 292c.533 1.467 3.867 21.467 7.2 44.533M497.267 257.2c-10.134 3.733-15.2 8.267-19.867 17.733L473 284l-.4 59.067c-.4 51.2-.133 60.133 1.733 66.533 5.6 19.333 17.067 27.333 39.467 27.467 10.267.133 12.267-.267 20.133-4.134 9.334-4.533 13.867-9.733 17.867-20.266 2-4.934 2.4-12 2.933-41.067l.534-34.933h-38.934v23.866l6.4.4 6.267.4v19.334c0 13.466-.533 20.666-1.867 23.733-5.066 12-23.333 10.4-26.8-2.4-.933-3.6-1.333-23.2-1.066-59.067.4-48.533.666-54.133 2.666-57.333 3.334-4.8 11.2-7.067 17.6-4.933 6.934 2.266 9.067 7.2 9.867 22.933l.667 13.067H555.4l-.8-15.734c-.8-18-3.067-25.6-9.867-33.466-7.466-8.8-13.466-11.2-29.066-11.734-9.067-.266-14.934.134-18.4 1.467"/></g></svg>',he=`data:image/svg+xml;utf8,${encodeURIComponent(Fe)}`;var qe=["https://cloud.idosgames.com","https://idosgames.com","https://www.idosgames.com"];function ge(){return typeof window<"u"&&qe.includes(window.location.origin)}function X({client:e,onAuthenticated:o}){let[t,l]=react.useState(false),[n,a]=react.useState(null),[c,g]=react.useState(true),u=async()=>{l(true),a(null),e.auth.setRememberSession(c);let r=await e.auth.loginWithDeviceID();if(r.ok){o();return}a(r.error),l(false);};return jsxRuntime.jsx("div",{style:w.root,children:jsxRuntime.jsxs("div",{style:w.card,children:[jsxRuntime.jsx("img",{src:he,alt:"iDos Games",style:w.logo}),jsxRuntime.jsx("h1",{style:w.title,children:"Sign in"}),ge()&&jsxRuntime.jsx("button",{type:"button",onClick:()=>core.beginSsoRedirect({titleID:e.titleID}),disabled:t,style:{...w.primary,opacity:t?.6:1,cursor:t?"default":"pointer"},children:"Continue with iDos Games"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>{u();},disabled:t,style:{...ge()?w.ghost:w.primary,opacity:t?.6:1,cursor:t?"default":"pointer"},children:t?"Signing in\u2026":"Play as guest"}),jsxRuntime.jsxs("label",{style:{...w.remember,opacity:t?.6:1},children:[jsxRuntime.jsx("input",{type:"checkbox",checked:c,disabled:t,onChange:r=>g(r.target.checked),style:w.switchInput}),jsxRuntime.jsx("span",{style:{...w.switchTrack,background:c?"#fff":"rgba(255, 255, 255, 0.3)"},children:jsxRuntime.jsx("span",{style:{...w.switchKnob,left:c?"21px":"3px",background:c?"#0d66fe":"#fff"}})}),"Remember me"]}),n&&jsxRuntime.jsx("span",{style:w.error,children:n})]})})}var w={root:{position:"absolute",inset:0,display:"grid",placeItems:"center",background:"#0d66fe",color:"#fff",font:"14px system-ui, sans-serif"},card:{width:"min(340px, 88vw)",display:"grid",gap:"18px",justifyItems:"center"},logo:{width:"180px",userSelect:"none",pointerEvents:"none"},title:{margin:0,fontSize:"22px",fontWeight:600,textAlign:"center"},primary:{width:"100%",padding:"11px 16px",borderRadius:"8px",border:"none",background:"#fff",color:"#0d66fe",fontWeight:600,font:"inherit"},ghost:{width:"100%",padding:"11px 16px",borderRadius:"8px",border:"1px solid rgba(255, 255, 255, 0.45)",background:"transparent",color:"#fff",fontWeight:600,font:"inherit"},remember:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",color:"rgba(255, 255, 255, 0.85)"},switchInput:{position:"absolute",opacity:0,width:0,height:0},switchTrack:{position:"relative",width:"42px",height:"24px",borderRadius:"12px",transition:"background 0.15s",flexShrink:0},switchKnob:{position:"absolute",top:"3px",width:"18px",height:"18px",borderRadius:"50%",transition:"left 0.15s, background 0.15s"},error:{color:"#ffd7d7",textAlign:"center"}};function Qe(e){let{container:o,client:t,modules:l,renderLogin:n}=e;o.style.position="relative";let a=document.createElement("div");Object.assign(a.style,{position:"absolute",inset:"0",zIndex:"0",pointerEvents:"none"});let c=document.createElement("div");Object.assign(c.style,{position:"absolute",inset:"0",zIndex:"1"}),o.append(a,c);let g=T(),u=B(a);N(()=>g.describe());let r=I(l);for(let p of r.warnings)console.warn(`[idos shared-ui] ${p}`);let s=client.createRoot(c);return s.render(jsxRuntime.jsx(react$1.IDosGamesProvider,{client:t,children:jsxRuntime.jsx(react$1.StatusProvider,{children:jsxRuntime.jsx(q,{client:t,modules:l,events:g,sharedUi:r.owners,surface:u,renderLogin:n??X})})})),{unmount(){s.unmount(),a.remove(),c.remove();}}}
|
|
11
|
-
exports.AuthGate=
|
|
10
|
+
`}),jsxRuntime.jsxs("div",{style:Ve,children:[jsxRuntime.jsx("span",{style:{...pe,animationDelay:"0s"}}),jsxRuntime.jsx("span",{style:{...pe,animationDelay:"1.1s"}}),jsxRuntime.jsx("span",{style:Fe,children:"\u{1F9E9}"})]}),jsxRuntime.jsx("div",{style:{fontWeight:700,fontSize:18,marginBottom:6},children:"No modules installed"}),jsxRuntime.jsxs("div",{style:{opacity:.85,maxWidth:380,lineHeight:1.5},children:["Add a module under ",jsxRuntime.jsx("code",{children:"src/modules/"})," and register it in"," ",jsxRuntime.jsx("code",{children:"src/modules.ts"}),". The host shell will pick it up here."]})]})}var Ue={position:"absolute",inset:0,overflow:"hidden",background:"#0d66fe",color:"#fff",fontFamily:"system-ui, sans-serif"},Te={position:"absolute",inset:0,zIndex:0},fe=16,Pe={position:"absolute",top:0,right:0,bottom:0,left:0,zIndex:1,pointerEvents:"none"},Oe={display:"contents",pointerEvents:"auto"},De={position:"absolute",top:0,left:0,right:0,zIndex:2,display:"flex",gap:12,padding:16,pointerEvents:"none"},Be={position:"absolute",top:0,right:0,bottom:0,width:340,maxWidth:"40vw",zIndex:2,display:"flex",flexDirection:"column",gap:12,padding:16,overflowY:"auto",pointerEvents:"none"},Ne={position:"absolute",bottom:fe,left:"50%",transform:"translateX(-50%)",zIndex:3,display:"flex",gap:8,padding:6,borderRadius:14,background:"rgba(4,32,90,0.72)",backdropFilter:"blur(6px)",pointerEvents:"auto"},ge={border:"none",borderRadius:10,padding:"8px 16px",fontWeight:700,fontSize:14,color:"#cfe0ff",background:"transparent",cursor:"pointer"},ze={...ge,color:"#0d66fe",background:"#fff"},Ge={position:"absolute",bottom:16,left:16,zIndex:3,display:"flex",gap:8,alignItems:"center",pointerEvents:"auto"},me={border:"none",borderRadius:12,padding:"8px 14px",fontWeight:700,fontSize:13,color:"#cfe0ff",background:"rgba(4,32,90,0.72)",backdropFilter:"blur(6px)",cursor:"pointer"},_e={...me,fontWeight:600,fontFamily:"ui-monospace, Consolas, monospace"},je={position:"absolute",inset:0,zIndex:4,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0,0,0,0.5)",pointerEvents:"none"},K={pointerEvents:"auto"},We={position:"absolute",inset:0,zIndex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",textAlign:"center",padding:24},Ve={position:"relative",width:110,height:110,marginBottom:16,display:"grid",placeItems:"center"},pe={position:"absolute",inset:0,borderRadius:"50%",border:"2px solid rgba(255,255,255,0.55)",animation:"idos-empty-ripple 2.2s ease-out infinite"},Fe={fontSize:46,animation:"idos-empty-float 3s ease-in-out infinite",filter:"drop-shadow(0 8px 12px rgba(0,0,0,0.25))"};function Q(e){let{client:o,modules:t,events:s,sharedUi:i,surface:l,renderLogin:d}=e,[y]=react.useState(V),[g,r]=react.useState(true),[n,c]=react.useState(null),p=react.useRef(null),u=()=>{for(let b of p.current??[])b.dispose();p.current=null;},m=()=>{u();let b=F(t,{client:o,events:s,surface:l,sharedUi:i,navigator:y});p.current=b,c(b);};react.useEffect(()=>()=>u(),[]);let S=react.useRef(false);react.useEffect(()=>{if(S.current)return;S.current=true;let b=core.readSsoCodeFromUrl();if(b){(async()=>((await o.auth.loginWithSsoCode(b.code)).ok&&m(),r(false)))();return}if(o.auth.lastAuthType===core.AuthType.None){r(false);return}(async()=>((await o.auth.autoLogin()).ok&&m(),r(false)))();},[o]),react.useEffect(()=>{let b=()=>{u(),c(null);},R=o.on("auth:unauthorized",b),k=o.on("auth:loggedOut",b);return ()=>{R(),k();}},[o]);let v=n?"game":g?"loading":"login";return react.useEffect(()=>{G({screen:v,loggedIn:n!==null,userId:o.auth.context?.userID??null,titleId:o.titleID??null,modules:t.map(b=>b.id),sharedUi:i});},[v,n,o,t,i]),n?jsxRuntime.jsx(X,{registrations:n,sharedUi:i,events:s,navigator:y,onLogout:()=>o.auth.logout(),userID:o.auth.context?.userID??null}):g?null:jsxRuntime.jsx(d,{client:o,onAuthenticated:m})}var Ye='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 860 690" fill="#fff"><g transform="translate(243 -2)"><path d="M147.333 12.333c-13.6 2.534-12.533 1.2-12.933 15.067l-.4 12.267-4.533-11.067c-2.534-6-5.067-10.933-5.734-10.933-2.666 0-27.866 8.666-36.533 12.666-11.733 5.334-26.667 14.8-36.133 22.934l-6.934 5.866L51.6 69.267c8.133 11.066 7.333 11.466-5.067 2.933-7.6-5.067-8.4-5.333-11.466-3.733-3.467 1.866-18.4 17.333-20.4 21.2-.8 1.6 7.066 8.8 33.733 30.933l34.667 28.933 8.8-8.266c14.666-13.867 28.666-22 48.133-28.267 9.067-2.933 14.8-3.733 28.533-4.4 34.267-1.333 60 7.467 81.6 28.133 21.6 20.4 34.934 49.6 37.467 81.734l.8 11.2 14.8 4.533c8.133 2.533 23.733 7.333 34.667 10.8 10.933 3.333 20.4 5.6 21.066 4.933 1.6-1.6 6.134-20.533 7.734-32.666.8-6 1.333-17.6 1.066-25.6l-.4-14.667-8-1.067c-4.4-.533-10.133-1.466-12.666-1.866l-4.667-.8 4.667-1.2c16.933-4.534 18.666-5.2 18.666-8 0-5.467-9.6-31.334-16.666-44.8-4-7.6-10.667-18.667-14.934-24.667-9.866-13.867-31.333-35.467-45.2-45.2-10.4-7.467-34.4-20.933-37.2-21.067-.8 0-4 4-7.333 8.8-3.2 4.8-6.133 8.134-6.4 7.334s.4-5.6 1.6-10.667c1.2-5.2 2.133-9.6 2.133-9.867 0-.933-19.866-6.133-34.4-9.066-14.8-2.934-49.333-4.4-59.6-2.534"/><path d="M157.867 125.533c-21.067 3.334-42.134 14.8-57.467 31.334-13.333 14.133-13.733 12.8 5.6 22 9.2 4.4 16.667 8.266 16.667 8.533s-1.334.4-2.934.133c-13.866-2.133-41.6-5.866-41.733-5.6-.267.267-7.467 28.534-16.267 63.067l-16 62.667 7.334.4c4 .266 7.466.266 7.6 0 .266-.267 3.866-13.867 8.133-30.4 4.267-16.534 8.267-30.8 8.933-31.734.934-1.2 11.067-1.6 42.4-1.6 32.134 0 41.2.4 41.2 1.6 0 .934-1.733 4.667-3.866 8.4L153.733 261l-35.066 6.933c-19.334 3.867-35.2 7.2-35.467 7.467-.667.667-29.867 113.467-29.467 113.867.267.133 23.734-3.6 52.4-8.534l52-8.8 20.4-39.866c11.2-22 20.667-39.734 20.934-39.467.4.533-1.334 26.8-2.8 40.8l-.667 6.933 6.267-3.2c21.2-10.666 52.4-13.466 86.933-8l5.867.934-5.6-7.334C286.4 318.6 281.2 310.6 278 304.867c-5.867-10.134-6-10.8-6-21.867 0-6.267 1.467-20 3.333-30.667 1.867-10.666 3.334-19.466 3.334-19.466 0-.134-9.067-4.267-20.134-9.334s-19.466-9.333-18.8-9.6c.8-.266 7.734.8 15.6 2.267 7.734 1.6 14.4 2.8 14.8 2.8 1.2 0 .4-10.533-1.466-18-7.2-27.733-28-53.467-53.734-66-16.4-8-40.8-12-57.066-9.467"/><path d="M235.6 346.333c-24 4.534-44.133 13.867-68.267 31.467-14 10.267-28.533 18.133-47.733 25.867-23.467 9.466-52.8 32.666-64.4 50.666l-2.533 4L58 454.2c9.333-7.333 30.133-19.467 49.333-28.667C173.733 393.667 246.4 382.2 312.8 393c11.2 1.733 39.2 8.533 45.067 10.8 2.266.8 2.266.667.8-2.267-4-7.6-15.6-21.866-25.867-31.466-12-11.467-24.667-18.934-37.6-22.4-11.467-3.067-46.267-3.867-59.6-1.334"/></g><g transform="translate(-460 467)"><path d="M721.533 34.467c-14.933 5.466-22 17.466-22.933 38.666-.933 24.134 3.467 32.8 30.267 59.867 19.6 19.867 22.933 25.2 22.933 37.867.133 13.466-6.133 20.133-16.933 18.4-9.067-1.467-12.534-7.867-12.534-22.667V159H696.6l.667 13.333c.533 11.467 1.2 14.4 4.933 22 7.067 14.267 16.8 19.6 36.4 19.734 10.667.133 12.267-.134 20.667-4.4 7.6-3.867 9.733-5.867 13.2-11.734 7.6-12.533 9.066-32 3.733-47.6-3.733-11.066-10.667-20.4-27.867-37.2-19.866-19.6-22.533-24.133-22.666-38.4 0-8.933.4-10.533 3.2-13.6 6.266-6.666 18.266-5.6 22.133 2 1.067 2 2 7.067 2 11.2v7.334h27.067l-.934-9.2c-1.6-18.267-8.266-30.267-20-36.4-7.2-3.867-29.2-4.8-37.6-1.6M630.067 34.867c-11.734 4.666-18 11.6-21.734 24.4-1.866 6.4-2 15.333-1.733 67.2l.4 59.866 3.733 7.6c6.8 13.867 18.534 20.267 36.934 20.267 13.733 0 22.933-3.333 30.666-11.067 10.934-11.066 11.2-12.533 11.734-74.666.266-35.734-.134-56.934-1.067-62.8-2.667-16.134-11.6-27.467-24.8-31.467-8.933-2.667-26.4-2.267-34.133.667m28.666 26.8 3.6 4v56.666c0 40.934-.4 57.467-1.6 60-3.6 8-15.6 9.734-22.666 3.467l-4.4-3.867-.4-56.533c-.267-51.733-.134-56.8 2-61.067 3.066-5.866 7.6-8.266 14.4-7.466 3.733.4 6.4 1.866 9.066 4.8M511.667 123.133v89.334l29.066-.4c28.8-.4 28.934-.4 36.667-4.267 9.467-4.533 14.4-10.933 17.467-22.4 2-7.333 2.266-15.467 1.866-65.733l-.4-57.334-4.266-8.8c-8.267-16.666-17.2-19.866-55.334-19.866h-25.066zm53.6-60.266 4.4 3.866.4 52.8c.266 35.067-.134 54.4-1.067 58-2 7.467-5.733 9.6-18.667 10.4l-10.666.8V59h10.666c9.867 0 10.934.267 14.934 3.867M471.667 145v67.333h26.666V77.667h-26.666zM471.667 48.333V63h26.666V33.667h-26.666z"/></g><g transform="translate(-106 244)"><path d="M893.4 259.733c-6.8 3.467-9.2 5.6-12.667 11.467-10.666 17.733-9.2 42.933 3.467 62.267 2.8 4.266 12.267 14.8 20.933 23.333 9.867 9.467 17.067 17.733 18.934 21.6 5.6 11.333 5.2 25.333-.934 30.8-3.466 3.067-11.333 4.133-16.133 2.133-5.867-2.4-8-7.466-8-19.333v-10h-27.067l.8 11.6c1.2 15.867 3.867 24.133 10.267 31.333 7.467 8.534 16.4 12.134 30 12.267 19.067.133 30.133-5.733 37.333-19.867 3.734-7.466 4-8.666 4-24 0-16 0-16.133-5.2-26.666-4.4-9.2-7.733-13.2-23.066-28.534-21.067-21.066-24.8-27.066-24.934-40.4-.133-10.4 2.8-15.6 9.734-17.6 10.133-2.933 17.2 3.334 18.4 16.267l.8 8.267H955.4l-.8-10.8c-.533-8.4-1.6-12.667-4.8-19.2-7.067-14.134-16.667-19.334-36.133-19.334-10.667 0-12.534.4-20.267 4.4M791 346v89.333h76v-24h-48v-54.666h37.333v-24H819V282h48v-25.333h-76zM661.667 346v89.333h22.666l.134-63.066c0-34.534.533-61.734 1.066-60.267.534 1.467 5.467 29.867 10.8 62.933l9.867 60.4h13.067c7.2 0 13.066-.4 13.066-1.066 0-3.067 18.8-124.8 19.334-125.334.4-.4.666 27.867.666 62.8v63.6h25.334V256.667h-38l-9.2 61.6c-5.067 34-9.6 62.133-10 62.666-.534.534-5.334-26.4-10.667-60-5.467-33.466-10.133-61.733-10.533-62.666-.4-1.2-5.467-1.6-19.067-1.6h-18.533zM586.467 258.267c-.8 2.666-27.467 172.4-27.467 174.933 0 1.867 1.733 2.133 12 2.133h11.867l.8-4.4c.533-2.266 1.6-9.333 2.4-15.6l1.6-11.333 17.6-.4 17.466-.4 1.467 8.4c.8 4.667 1.733 11.867 2.267 16l.933 7.733h13.733c7.6 0 13.867-.266 13.867-.666 0-.8-26.533-168.134-27.467-173.734l-.8-4.266h-19.866c-14.8 0-20.134.4-20.4 1.6M613 336.533c3.333 23.067 5.867 42.134 5.6 42.4-.4.267-6.533.267-13.867.134l-13.2-.4 4.934-33.334c2.8-18.4 5.733-38.4 6.666-44.666C604.2 292.533 605 290.133 605.8 292c.533 1.467 3.867 21.467 7.2 44.533M497.267 257.2c-10.134 3.733-15.2 8.267-19.867 17.733L473 284l-.4 59.067c-.4 51.2-.133 60.133 1.733 66.533 5.6 19.333 17.067 27.333 39.467 27.467 10.267.133 12.267-.267 20.133-4.134 9.334-4.533 13.867-9.733 17.867-20.266 2-4.934 2.4-12 2.933-41.067l.534-34.933h-38.934v23.866l6.4.4 6.267.4v19.334c0 13.466-.533 20.666-1.867 23.733-5.066 12-23.333 10.4-26.8-2.4-.933-3.6-1.333-23.2-1.066-59.067.4-48.533.666-54.133 2.666-57.333 3.334-4.8 11.2-7.067 17.6-4.933 6.934 2.266 9.067 7.2 9.867 22.933l.667 13.067H555.4l-.8-15.734c-.8-18-3.067-25.6-9.867-33.466-7.466-8.8-13.466-11.2-29.066-11.734-9.067-.266-14.934.134-18.4 1.467"/></g></svg>',ye=`data:image/svg+xml;utf8,${encodeURIComponent(Ye)}`;var Je=["https://cloud.idosgames.com","https://idosgames.com","https://www.idosgames.com"],Qe=/^https:\/\/[a-z0-9]{8}\.idos\.games$/;function Se(){if(typeof window>"u")return false;let{origin:e}=window.location;return Je.includes(e)||Qe.test(e)?true:typeof document<"u"&&document.querySelector('meta[name="idos-game-host"]')!==null}function ee({client:e,onAuthenticated:o}){let[t,s]=react.useState(false),[i,l]=react.useState(null),[d,y]=react.useState(true),g=async()=>{s(true),l(null),e.auth.setRememberSession(d);let r=await e.auth.loginWithDeviceID();if(r.ok){o();return}l(r.error),s(false);};return jsxRuntime.jsx("div",{style:w.root,children:jsxRuntime.jsxs("div",{style:w.card,children:[jsxRuntime.jsx("img",{src:ye,alt:"iDos Games",style:w.logo}),jsxRuntime.jsx("h1",{style:w.title,children:"Sign in"}),Se()&&jsxRuntime.jsx("button",{type:"button",onClick:()=>core.beginSsoRedirect({titleID:e.titleID}),disabled:t,style:{...w.primary,opacity:t?.6:1,cursor:t?"default":"pointer"},children:"Continue with iDos Games"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>{g();},disabled:t,style:{...Se()?w.ghost:w.primary,opacity:t?.6:1,cursor:t?"default":"pointer"},children:t?"Signing in\u2026":"Play as guest"}),jsxRuntime.jsxs("label",{style:{...w.remember,opacity:t?.6:1},children:[jsxRuntime.jsx("input",{type:"checkbox",checked:d,disabled:t,onChange:r=>y(r.target.checked),style:w.switchInput}),jsxRuntime.jsx("span",{style:{...w.switchTrack,background:d?"#fff":"rgba(255, 255, 255, 0.3)"},children:jsxRuntime.jsx("span",{style:{...w.switchKnob,left:d?"21px":"3px",background:d?"#0d66fe":"#fff"}})}),"Remember me"]}),i&&jsxRuntime.jsx("span",{style:w.error,children:i})]})})}var w={root:{position:"absolute",inset:0,display:"grid",placeItems:"center",background:"#0d66fe",color:"#fff",font:"14px system-ui, sans-serif"},card:{width:"min(340px, 88vw)",display:"grid",gap:"18px",justifyItems:"center"},logo:{width:"180px",userSelect:"none",pointerEvents:"none"},title:{margin:0,fontSize:"22px",fontWeight:600,textAlign:"center"},primary:{width:"100%",padding:"11px 16px",borderRadius:"8px",border:"none",background:"#fff",color:"#0d66fe",fontWeight:600,font:"inherit"},ghost:{width:"100%",padding:"11px 16px",borderRadius:"8px",border:"1px solid rgba(255, 255, 255, 0.45)",background:"transparent",color:"#fff",fontWeight:600,font:"inherit"},remember:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",color:"rgba(255, 255, 255, 0.85)"},switchInput:{position:"absolute",opacity:0,width:0,height:0},switchTrack:{position:"relative",width:"42px",height:"24px",borderRadius:"12px",transition:"background 0.15s",flexShrink:0},switchKnob:{position:"absolute",top:"3px",width:"18px",height:"18px",borderRadius:"50%",transition:"left 0.15s, background 0.15s"},error:{color:"#ffd7d7",textAlign:"center"}};function ot(e){let{container:o,client:t,modules:s,renderLogin:i}=e;o.style.position="relative";let l=document.createElement("div");Object.assign(l.style,{position:"absolute",inset:"0",zIndex:"0",pointerEvents:"none"});let d=document.createElement("div");Object.assign(d.style,{position:"absolute",inset:"0",zIndex:"1"}),o.append(l,d);let y=D(),g=N(l);_(()=>y.describe());let r=A(s);for(let c of r.warnings)console.warn(`[idos shared-ui] ${c}`);let n=client.createRoot(d);return n.render(jsxRuntime.jsx(react$1.IDosGamesProvider,{client:t,children:jsxRuntime.jsx(react$1.StatusProvider,{children:jsxRuntime.jsx(Q,{client:t,modules:s,events:y,sharedUi:r.owners,surface:g,renderLogin:i??ee})})})),{unmount(){n.unmount(),l.remove(),d.remove();}}}
|
|
11
|
+
exports.AuthGate=Q;exports.DefaultLoginScreen=ee;exports.HostShell=X;exports.SceneStage=I;exports.createContentRegistry=W;exports.createHostEventBus=D;exports.createHostNavigator=V;exports.createSharedEventBus=ke;exports.createSurfaceAllocator=N;exports.emptySharedUiOwners=le;exports.mountHost=ot;exports.publishEventsProvider=_;exports.publishHostState=G;exports.registerAgentApi=z;exports.resolveSharedUi=A;exports.runModules=F;exports.sharedUiFor=B;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ModuleEvents, Topic, SharedEventBus, SharedUiRole, Module, SharedUiContext, IDosGamesClient, SurfaceAllocator, EngineScene, UiPanel, RouteEntry, ModuleAgentApi } from '@idosgames/module-sdk';
|
|
1
|
+
import { ModuleEvents, Topic, SharedEventBus, SharedUiRole, Module, SharedUiContext, IDosGamesClient, SurfaceAllocator, ContentRegistry, EngineScene, UiPanel, RouteEntry, ModuleAgentApi } from '@idosgames/module-sdk';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
3
|
|
|
4
4
|
/** One delivered (or refused) event, as the agent sees it. */
|
|
@@ -124,6 +124,19 @@ declare function mountHost(options: {
|
|
|
124
124
|
*/
|
|
125
125
|
declare function DefaultLoginScreen({ client, onAuthenticated, }: LoginScreenProps): ReactNode;
|
|
126
126
|
|
|
127
|
+
declare function createContentRegistry(): ContentRegistry;
|
|
128
|
+
/**
|
|
129
|
+
* Mode switching requested by a module. Created once per host session (AuthGate), handed to modules
|
|
130
|
+
* as `ctx.navigate` and bound by the shell to its mode state. A request made before the shell mounted
|
|
131
|
+
* is kept and applied on bind — setup() runs before the first render.
|
|
132
|
+
*/
|
|
133
|
+
interface HostNavigator {
|
|
134
|
+
navigate(modeId: string): void;
|
|
135
|
+
/** The shell binds its mode setter; returns the unbind function. */
|
|
136
|
+
bind(target: (modeId: string) => void): () => void;
|
|
137
|
+
}
|
|
138
|
+
declare function createHostNavigator(): HostNavigator;
|
|
139
|
+
|
|
127
140
|
interface ModuleRegistration {
|
|
128
141
|
module: Module;
|
|
129
142
|
scenes: EngineScene[];
|
|
@@ -143,11 +156,17 @@ interface SharedServices {
|
|
|
143
156
|
surface: SurfaceAllocator;
|
|
144
157
|
/** Resolved shared-UI owners. Resolved here from the modules when omitted. */
|
|
145
158
|
sharedUi?: SharedUiOwners;
|
|
159
|
+
/** Content-type registry shared by the modules. A fresh one per install when omitted. */
|
|
160
|
+
content?: ContentRegistry;
|
|
161
|
+
/** Mode switching for `ctx.navigate`. Without it navigation requests are ignored (tests, headless). */
|
|
162
|
+
navigator?: HostNavigator;
|
|
146
163
|
}
|
|
147
164
|
/** Install every module and return their collected registrations, in declaration order. */
|
|
148
165
|
declare function runModules(modules: readonly Module[], shared: SharedServices): ModuleRegistration[];
|
|
149
166
|
|
|
150
|
-
declare function HostShell({ registrations, sharedUi, events, onLogout, userID, }: {
|
|
167
|
+
declare function HostShell({ registrations, sharedUi, events, onLogout, userID, navigator, }: {
|
|
168
|
+
/** Binds `ctx.navigate` of the modules to this shell's mode state. */
|
|
169
|
+
navigator?: HostNavigator;
|
|
151
170
|
registrations: readonly ModuleRegistration[];
|
|
152
171
|
/** Shared-UI owners. When a module owns "account", the host does not draw its own logout/ID row. */
|
|
153
172
|
sharedUi?: SharedUiOwners;
|
|
@@ -222,4 +241,4 @@ declare class SceneStage {
|
|
|
222
241
|
/** Creates an allocator whose surfaces are appended to `layer`. */
|
|
223
242
|
declare function createSurfaceAllocator(layer: HTMLElement): SurfaceAllocator;
|
|
224
243
|
|
|
225
|
-
export { type AgentBridgeGlobal, type AgentHostState, AuthGate, DefaultLoginScreen, type EventLogEntry, type HostEventBus, type HostEventBusDescription, type HostHandle, HostShell, type LoginScreenProps, type ModuleEventHandle, type ModuleRegistration, type RenderLogin, SceneStage, type SharedServices, type SharedUiOwners, type SharedUiResolution, createHostEventBus, createSharedEventBus, createSurfaceAllocator, emptySharedUiOwners, mountHost, publishEventsProvider, publishHostState, registerAgentApi, resolveSharedUi, runModules, sharedUiFor };
|
|
244
|
+
export { type AgentBridgeGlobal, type AgentHostState, AuthGate, DefaultLoginScreen, type EventLogEntry, type HostEventBus, type HostEventBusDescription, type HostHandle, type HostNavigator, HostShell, type LoginScreenProps, type ModuleEventHandle, type ModuleRegistration, type RenderLogin, SceneStage, type SharedServices, type SharedUiOwners, type SharedUiResolution, createContentRegistry, createHostEventBus, createHostNavigator, createSharedEventBus, createSurfaceAllocator, emptySharedUiOwners, mountHost, publishEventsProvider, publishHostState, registerAgentApi, resolveSharedUi, runModules, sharedUiFor };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ModuleEvents, Topic, SharedEventBus, SharedUiRole, Module, SharedUiContext, IDosGamesClient, SurfaceAllocator, EngineScene, UiPanel, RouteEntry, ModuleAgentApi } from '@idosgames/module-sdk';
|
|
1
|
+
import { ModuleEvents, Topic, SharedEventBus, SharedUiRole, Module, SharedUiContext, IDosGamesClient, SurfaceAllocator, ContentRegistry, EngineScene, UiPanel, RouteEntry, ModuleAgentApi } from '@idosgames/module-sdk';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
3
|
|
|
4
4
|
/** One delivered (or refused) event, as the agent sees it. */
|
|
@@ -124,6 +124,19 @@ declare function mountHost(options: {
|
|
|
124
124
|
*/
|
|
125
125
|
declare function DefaultLoginScreen({ client, onAuthenticated, }: LoginScreenProps): ReactNode;
|
|
126
126
|
|
|
127
|
+
declare function createContentRegistry(): ContentRegistry;
|
|
128
|
+
/**
|
|
129
|
+
* Mode switching requested by a module. Created once per host session (AuthGate), handed to modules
|
|
130
|
+
* as `ctx.navigate` and bound by the shell to its mode state. A request made before the shell mounted
|
|
131
|
+
* is kept and applied on bind — setup() runs before the first render.
|
|
132
|
+
*/
|
|
133
|
+
interface HostNavigator {
|
|
134
|
+
navigate(modeId: string): void;
|
|
135
|
+
/** The shell binds its mode setter; returns the unbind function. */
|
|
136
|
+
bind(target: (modeId: string) => void): () => void;
|
|
137
|
+
}
|
|
138
|
+
declare function createHostNavigator(): HostNavigator;
|
|
139
|
+
|
|
127
140
|
interface ModuleRegistration {
|
|
128
141
|
module: Module;
|
|
129
142
|
scenes: EngineScene[];
|
|
@@ -143,11 +156,17 @@ interface SharedServices {
|
|
|
143
156
|
surface: SurfaceAllocator;
|
|
144
157
|
/** Resolved shared-UI owners. Resolved here from the modules when omitted. */
|
|
145
158
|
sharedUi?: SharedUiOwners;
|
|
159
|
+
/** Content-type registry shared by the modules. A fresh one per install when omitted. */
|
|
160
|
+
content?: ContentRegistry;
|
|
161
|
+
/** Mode switching for `ctx.navigate`. Without it navigation requests are ignored (tests, headless). */
|
|
162
|
+
navigator?: HostNavigator;
|
|
146
163
|
}
|
|
147
164
|
/** Install every module and return their collected registrations, in declaration order. */
|
|
148
165
|
declare function runModules(modules: readonly Module[], shared: SharedServices): ModuleRegistration[];
|
|
149
166
|
|
|
150
|
-
declare function HostShell({ registrations, sharedUi, events, onLogout, userID, }: {
|
|
167
|
+
declare function HostShell({ registrations, sharedUi, events, onLogout, userID, navigator, }: {
|
|
168
|
+
/** Binds `ctx.navigate` of the modules to this shell's mode state. */
|
|
169
|
+
navigator?: HostNavigator;
|
|
151
170
|
registrations: readonly ModuleRegistration[];
|
|
152
171
|
/** Shared-UI owners. When a module owns "account", the host does not draw its own logout/ID row. */
|
|
153
172
|
sharedUi?: SharedUiOwners;
|
|
@@ -222,4 +241,4 @@ declare class SceneStage {
|
|
|
222
241
|
/** Creates an allocator whose surfaces are appended to `layer`. */
|
|
223
242
|
declare function createSurfaceAllocator(layer: HTMLElement): SurfaceAllocator;
|
|
224
243
|
|
|
225
|
-
export { type AgentBridgeGlobal, type AgentHostState, AuthGate, DefaultLoginScreen, type EventLogEntry, type HostEventBus, type HostEventBusDescription, type HostHandle, HostShell, type LoginScreenProps, type ModuleEventHandle, type ModuleRegistration, type RenderLogin, SceneStage, type SharedServices, type SharedUiOwners, type SharedUiResolution, createHostEventBus, createSharedEventBus, createSurfaceAllocator, emptySharedUiOwners, mountHost, publishEventsProvider, publishHostState, registerAgentApi, resolveSharedUi, runModules, sharedUiFor };
|
|
244
|
+
export { type AgentBridgeGlobal, type AgentHostState, AuthGate, DefaultLoginScreen, type EventLogEntry, type HostEventBus, type HostEventBusDescription, type HostHandle, type HostNavigator, HostShell, type LoginScreenProps, type ModuleEventHandle, type ModuleRegistration, type RenderLogin, SceneStage, type SharedServices, type SharedUiOwners, type SharedUiResolution, createContentRegistry, createHostEventBus, createHostNavigator, createSharedEventBus, createSurfaceAllocator, emptySharedUiOwners, mountHost, publishEventsProvider, publishHostState, registerAgentApi, resolveSharedUi, runModules, sharedUiFor };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {createRoot}from'react-dom/client';import {IDosGamesProvider,StatusProvider}from'@idosgames/react';import {isTopicName,SHARED_UI_ROLES,isSharedUiRole,hostTopics,topicNamespace}from'@idosgames/module-sdk';import {useRef,useMemo,useState,useEffect,useLayoutEffect}from'react';import {readSsoCodeFromUrl,AuthType,beginSsoRedirect}from'@idosgames/core';import {jsx,jsxs}from'react/jsx-runtime';var
|
|
1
|
+
import {createRoot}from'react-dom/client';import {IDosGamesProvider,StatusProvider}from'@idosgames/react';import {isTopicName,SHARED_UI_ROLES,isSharedUiRole,hostTopics,topicNamespace}from'@idosgames/module-sdk';import {useRef,useMemo,useState,useEffect,useLayoutEffect}from'react';import {readSsoCodeFromUrl,AuthType,beginSsoRedirect}from'@idosgames/core';import {jsx,jsxs}from'react/jsx-runtime';var Ee=50,T="host",ne=e=>typeof e=="string"?e:e.name,re=e=>typeof e=="string"?null:e.shape,se=e=>e.replace(/@\d+$/,"");function D(){let e=new Map,o=new Map,t=[],s=new Set,i=r=>{t.push(r),t.length>Ee&&t.shift();},l=(r,n)=>{s.has(r)||(s.add(r),console.warn(n));},d=(r,n,c)=>{console.error(`[idos events] ${c}`),i({topic:n,from:r,at:Date.now(),delivered:0,rejected:c});},y=(r,n,c,p)=>{if(!isTopicName(n)){d(r,n,`"${r}" emitted "${n}", which is not a topic name \u2014 use defineTopic("<module-id>:<event>@<major>", shape({\u2026})). Not delivered.`);return}let u=topicNamespace(n);if(r!==T&&u===T){d(r,n,`"${r}" emitted "${n}", but the "host:" namespace belongs to the host. Not delivered.`);return}if(r!==T&&u!==r){d(r,n,`"${r}" emitted "${n}" into the "${u}" namespace \u2014 a module may only emit its own topics ("${r}:\u2026"). Not delivered.`);return}if(c){let v=c.check(p);v&&l(`emit|${r}|${n}`,`[idos events] "${r}" emitted "${n}" with a payload that does not match its own shape: ${v}. Fix the emit or the topic's shape (and module.meta.json).`);}let m=o.get(n);m||o.set(n,m=new Set),m.add(r);let S=0;for(let v of [...e.get(n)??[]]){if(v.shape){let x=v.shape.check(p);if(x){l(`on|${v.moduleId}|${n}`,`[idos events] "${v.moduleId}" skipped "${n}" from "${r}": ${x}. Its copy of the topic's shape no longer matches the emitter \u2014 re-copy it from the catalog.`);continue}}try{v.handler(p),S+=1;}catch(x){console.error(`[idos events] a "${n}" handler in "${v.moduleId}" threw \u2014 other listeners still received the event.`,x);}}i({topic:n,from:r,at:Date.now(),delivered:S});},g=(r,n,c)=>{let p=e.get(n);return p||e.set(n,p=new Set),p.add(c),()=>{let u=e.get(n);u&&(u.delete(c),u.size===0&&e.delete(n));}};return {forModule(r){let n=new Set,c=false;return {emit(u,m){c||y(r,ne(u),re(u),m);},on(u,m){if(c)return ()=>{};let S=ne(u);isTopicName(S)||console.warn(`[idos events] "${r}" subscribed to "${S}", which is not a topic name \u2014 nothing can ever be emitted to it.`);let v=g(r,S,{moduleId:r,shape:re(u),handler:m});return n.add(v),()=>{v(),n.delete(v);}},dispose(){c=true;for(let u of n)u();n.clear();}}},emitAsHost(r,n){y(T,r.name,r.shape,n);},describe(){let r={};for(let[p,u]of e)r[p]=[...new Set([...u].map(m=>m.moduleId))];let n={};for(let[p,u]of o)n[p]=[...u];let c=[];for(let[p,u]of Object.entries(r)){if(o.has(p))continue;let m=[...o.keys()].filter(S=>S!==p&&se(S)===se(p));m.length>0&&c.push(`${u.join(", ")} listen${u.length===1?"s":""} to "${p}", but only ${m.map(S=>`"${S}"`).join(", ")} ${m.length===1?"has":"have"} been emitted \u2014 the major versions differ, so these never meet.`);}return {log:t.slice(),listeners:r,emitted:n,mismatches:c}}}}function ke(){let e=new Map;return {emit(o,t){let s=e.get(o);if(s)for(let i of [...s])i(t);},on(o,t){let s=t,i=e.get(o);return i||(i=new Set,e.set(o,i)),i.add(s),()=>{i.delete(s),i.size===0&&e.delete(o);}}}}function le(){return Object.fromEntries(SHARED_UI_ROLES.map(e=>[e,null]))}function A(e){let o=le(),t=[],s=SHARED_UI_ROLES.join(", ");for(let i of e)for(let l of i.sharedUi?.provides??[]){if(!isSharedUiRole(l)){t.push(`module "${i.id}" provides unknown shared UI role "${String(l)}" (known: ${s}) \u2014 ignored.`);continue}let d=o[l];d===null?o[l]=i.id:d!==i.id&&t.push(`shared UI role "${l}" is provided by both "${d}" and "${i.id}" \u2014 "${d}" wins (it comes first in src/modules.ts), "${i.id}" hides its copy.`);}for(let i of e)for(let l of i.sharedUi?.requires??[]){if(!isSharedUiRole(l)){t.push(`module "${i.id}" requires unknown shared UI role "${String(l)}" (known: ${s}).`);continue}o[l]===null&&t.push(`module "${i.id}" requires shared UI role "${l}", but no installed module provides it \u2014 install game-hud (or another module that provides "${l}").`);}return {owners:o,warnings:t}}function B(e,o){let t=s=>e[s]??null;return {ownerOf:t,shouldDraw:s=>{let i=t(s);return i===null||i===o}}}var Me={position:"absolute",inset:"0"};function N(e){return {request(o){let t=document.createElement("div");return t.dataset.surface=o,Object.assign(t.style,Me),t.style.pointerEvents=o==="fullbleed-canvas"?"auto":"none",e.appendChild(t),{host:t,release(){t.remove();}}}}}var Ce="__IDOS_AGENT__",de={},ce,ue;function He(){try{return typeof window<"u"&&window.self!==window.top}catch{return true}}function z(e,o){de[e]=o,j();}function G(e){ce=e,j();}function _(e){ue=e,j();}function j(){if(!He())return;let e={version:1,modules:de,host:ce,events:ue};globalThis[Ce]=e;}function W(){let e=new Map,o=new Set,t=()=>{for(let s of o)s();};return {registerType(s){if(!s?.type)throw new Error("ctx.content.registerType(): handler.type is required");return e.set(s.type,s),t(),()=>{e.get(s.type)===s&&(e.delete(s.type),t());}},getType:s=>e.get(s),listTypes:()=>[...e.values()],subscribe(s){return o.add(s),()=>{o.delete(s);}}}}function V(){let e=null,o=null;return {navigate(t){t&&(e?e(t):o=t);},bind(t){if(e=t,o!==null){let s=o;o=null,t(s);}return ()=>{e===t&&(e=null);}}}}function F(e,o){let t=o.sharedUi??A(e).owners,s=o.content??W(),i=[];try{for(let l of e){let d=o.events.forModule(l.id),y=[],g={module:l,scenes:[],panels:[],routes:[],dispose:()=>{d.dispose();for(let n of y.splice(0))n();}};i.push(g);let r={client:o.client,titleId:o.client.titleID,events:d,sharedUi:B(t,l.id),surface:o.surface,registerScene:n=>g.scenes.push(n),registerPanel:n=>g.panels.push(n),registerRoute:n=>g.routes.push(n),content:{registerType:n=>{let c=s.registerType(n);return y.push(c),c},getType:n=>s.getType(n),listTypes:()=>s.listTypes(),subscribe:n=>s.subscribe(n)},navigate:n=>o.navigator?.navigate(n),exposeToAgent:n=>z(l.id,n)};l.setup(r);}}catch(l){for(let d of i)d.dispose();throw l}return i}var I=class{constructor(o){this.container=o;}container;hosts=new Map;active=new Set;ensureMounted(o){let t=this.hosts.get(o);return t||(t=document.createElement("div"),Object.assign(t.style,{position:"absolute",inset:"0"}),this.container.appendChild(t),this.hosts.set(o,t),o.mount({host:t})),t}setActive(o){let t=new Set(o);for(let s of this.active){if(t.has(s))continue;s.suspend?.();let i=this.hosts.get(s);i&&(i.style.display="none");}for(let s of t){if(this.active.has(s))continue;let i=this.ensureMounted(s);i.style.display="block",s.activate?.();}this.active=t;}destroy(){for(let[o,t]of this.hosts)o.destroy(),t.remove();this.hosts.clear(),this.active.clear();}};function X({registrations:e,sharedUi:o,events:t,onLogout:s,userID:i,navigator:l}){let d=useRef(null),y=useRef(null),g=useMemo(()=>e.flatMap(a=>a.routes.map(f=>({id:f.id,label:f.label,icon:f.icon,order:f.order??0,moduleId:a.module.id}))).sort((a,f)=>a.order-f.order),[e]),[r,n]=useState(()=>g[0]?.id??null);useEffect(()=>{r!==null&&g.some(a=>a.id===r)||n(g[0]?.id??null);},[g,r]),useEffect(()=>l?.bind(a=>{g.some(f=>f.id===a)&&n(a);}),[l,g]);let c=useMemo(()=>g.find(a=>a.id===r)?.moduleId??null,[g,r]),p=useRef(null);useEffect(()=>{if(r===null||r===p.current)return;let a=p.current;p.current=r,t?.emitAsHost(hostTopics.modeChanged,a===null?{to:r}:{from:a,to:r});},[r,t]),useEffect(()=>{let a=d.current;if(!a)return;let f=y.current??=new I(a),C=e.find(U=>U.module.id===c)?.scenes??[];f.setActive(C);},[e,c]),useEffect(()=>()=>{y.current?.destroy(),y.current=null;},[]);let u=useMemo(()=>e.flatMap(a=>a.panels.filter(f=>f.activeOnly===false||a.module.id===c).map(f=>{let C=f.component;return {key:`${a.module.id}:${f.id}`,slot:f.slot,order:f.order??0,moduleId:a.module.id,component:jsx(C,{})}})).sort((a,f)=>a.order-f.order),[e,c]),m=a=>u.filter(f=>f.slot===a),S=e.length>0,v=m("hud").length,x=g.length>1,b=!o?.account,R=useRef(null),k=useRef(null),[M,we]=useState({top:0,bottom:0});useLayoutEffect(()=>{let a=()=>{let C=v>0&&R.current?Math.ceil(R.current.getBoundingClientRect().height):0,U=x&&k.current?Math.ceil(k.current.getBoundingClientRect().height)+fe:0;we(O=>O.top===C&&O.bottom===U?O:{top:C,bottom:U});};if(a(),typeof ResizeObserver>"u")return;let f=new ResizeObserver(a);return R.current&&f.observe(R.current),k.current&&f.observe(k.current),()=>f.disconnect()},[v,x]);let xe={...Ue,"--idos-safe-top":`${M.top}px`,"--idos-safe-bottom":`${M.bottom}px`};return jsxs("div",{style:xe,children:[jsx("div",{ref:d,style:Te}),jsx("div",{style:{...Pe,top:M.top,bottom:M.bottom},children:m("overlay").map(a=>jsx("div",{style:K,children:a.component},a.key))}),jsx("div",{ref:R,style:De,children:m("hud").map(a=>jsx("div",{style:Oe,children:a.component},a.key))}),jsx("div",{style:{...Be,top:M.top,bottom:M.bottom},children:m("sidebar").map(a=>jsx("div",{style:K,children:a.component},a.key))}),x&&jsx("nav",{ref:k,style:Ne,children:g.map(a=>jsxs("button",{type:"button",onClick:()=>n(a.id),style:a.id===r?ze:ge,children:[a.icon?`${a.icon} `:"",a.label]},a.id))}),b&&(s||i)&&jsxs("div",{style:Ge,children:[s&&jsx("button",{type:"button",style:me,onClick:s,title:"Log out",children:"\u{1F6AA} Log out"}),i&&jsx(Le,{userID:i})]}),m("modal").length>0&&jsx("div",{style:je,children:m("modal").map(a=>jsx("div",{style:K,children:a.component},a.key))}),!S&&jsx($e,{})]})}function Le({userID:e}){let[o,t]=useState(false),s=()=>{(async()=>{try{await navigator.clipboard.writeText(e);}catch{let l=document.createElement("textarea");l.value=e,document.body.appendChild(l),l.select(),document.execCommand("copy"),l.remove();}t(true),window.setTimeout(()=>t(false),1500);})();},i=e.length>12?`${e.slice(0,5)}\u2026${e.slice(-5)}`:e;return jsx("button",{type:"button",style:_e,onClick:s,title:`Copy your player ID: ${e}`,children:o?"\u2713 Copied":`ID: ${i} \u29C9`})}function $e(){return jsxs("div",{style:We,children:[jsx("style",{children:`
|
|
2
2
|
@keyframes idos-empty-float {
|
|
3
3
|
0%, 100% { transform: translateY(0) rotate(-6deg); }
|
|
4
4
|
50% { transform: translateY(-16px) rotate(6deg); }
|
|
@@ -7,5 +7,5 @@ import {createRoot}from'react-dom/client';import {IDosGamesProvider,StatusProvid
|
|
|
7
7
|
0% { transform: scale(0.55); opacity: 0.55; }
|
|
8
8
|
100% { transform: scale(1.7); opacity: 0; }
|
|
9
9
|
}
|
|
10
|
-
`}),jsxs("div",{style:_e,children:[jsx("span",{style:{...ae,animationDelay:"0s"}}),jsx("span",{style:{...ae,animationDelay:"1.1s"}}),jsx("span",{style:je,children:"\u{1F9E9}"})]}),jsx("div",{style:{fontWeight:700,fontSize:18,marginBottom:6},children:"No modules installed"}),jsxs("div",{style:{opacity:.85,maxWidth:380,lineHeight:1.5},children:["Add a module under ",jsx("code",{children:"src/modules/"})," and register it in"," ",jsx("code",{children:"src/modules.ts"}),". The host shell will pick it up here."]})]})}var He={position:"absolute",inset:0,overflow:"hidden",background:"#0d66fe",color:"#fff",fontFamily:"system-ui, sans-serif"},Le={position:"absolute",inset:0,zIndex:0},de=16,Ue={position:"absolute",top:0,right:0,bottom:0,left:0,zIndex:1,pointerEvents:"none"},$e={display:"contents",pointerEvents:"auto"},Pe={position:"absolute",top:0,left:0,right:0,zIndex:2,display:"flex",gap:12,padding:16,pointerEvents:"none"},Oe={position:"absolute",top:0,right:0,bottom:0,width:340,maxWidth:"40vw",zIndex:2,display:"flex",flexDirection:"column",gap:12,padding:16,overflowY:"auto",pointerEvents:"none"},Te={position:"absolute",bottom:de,left:"50%",transform:"translateX(-50%)",zIndex:3,display:"flex",gap:8,padding:6,borderRadius:14,background:"rgba(4,32,90,0.72)",backdropFilter:"blur(6px)",pointerEvents:"auto"},ce={border:"none",borderRadius:10,padding:"8px 16px",fontWeight:700,fontSize:14,color:"#cfe0ff",background:"transparent",cursor:"pointer"},De={...ce,color:"#0d66fe",background:"#fff"},Be={position:"absolute",bottom:16,left:16,zIndex:3,display:"flex",gap:8,alignItems:"center",pointerEvents:"auto"},ue={border:"none",borderRadius:12,padding:"8px 14px",fontWeight:700,fontSize:13,color:"#cfe0ff",background:"rgba(4,32,90,0.72)",backdropFilter:"blur(6px)",cursor:"pointer"},ze={...ue,fontWeight:600,fontFamily:"ui-monospace, Consolas, monospace"},Ge={position:"absolute",inset:0,zIndex:4,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0,0,0,0.5)",pointerEvents:"none"},V={pointerEvents:"auto"},Ne={position:"absolute",inset:0,zIndex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",textAlign:"center",padding:24},_e={position:"relative",width:110,height:110,marginBottom:16,display:"grid",placeItems:"center"},ae={position:"absolute",inset:0,borderRadius:"50%",border:"2px solid rgba(255,255,255,0.55)",animation:"idos-empty-ripple 2.2s ease-out infinite"},je={fontSize:46,animation:"idos-empty-float 3s ease-in-out infinite",filter:"drop-shadow(0 8px 12px rgba(0,0,0,0.25))"};function q(e){let{client:o,modules:t,events:l,sharedUi:n,surface:a,renderLogin:c}=e,[g,u]=useState(true),[r,s]=useState(null),p=useRef(null),f=()=>{for(let v of p.current??[])v.dispose();p.current=null;},d=()=>{f();let v=j(t,{client:o,events:l,surface:a,sharedUi:n});p.current=v,s(v);};useEffect(()=>()=>f(),[]);let y=useRef(false);useEffect(()=>{if(y.current)return;y.current=true;let v=readSsoCodeFromUrl();if(v){(async()=>((await o.auth.loginWithSsoCode(v.code)).ok&&d(),u(false)))();return}if(o.auth.lastAuthType===AuthType.None){u(false);return}(async()=>((await o.auth.autoLogin()).ok&&d(),u(false)))();},[o]),useEffect(()=>{let v=()=>{f(),s(null);},x=o.on("auth:unauthorized",v),E=o.on("auth:loggedOut",v);return ()=>{x(),E();}},[o]);let b=r?"game":g?"loading":"login";return useEffect(()=>{G({screen:b,loggedIn:r!==null,userId:o.auth.context?.userID??null,titleId:o.titleID??null,modules:t.map(v=>v.id),sharedUi:n});},[b,r,o,t,n]),r?jsx(K,{registrations:r,sharedUi:n,events:l,onLogout:()=>o.auth.logout(),userID:o.auth.context?.userID??null}):g?null:jsx(c,{client:o,onAuthenticated:d})}var Fe='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 860 690" fill="#fff"><g transform="translate(243 -2)"><path d="M147.333 12.333c-13.6 2.534-12.533 1.2-12.933 15.067l-.4 12.267-4.533-11.067c-2.534-6-5.067-10.933-5.734-10.933-2.666 0-27.866 8.666-36.533 12.666-11.733 5.334-26.667 14.8-36.133 22.934l-6.934 5.866L51.6 69.267c8.133 11.066 7.333 11.466-5.067 2.933-7.6-5.067-8.4-5.333-11.466-3.733-3.467 1.866-18.4 17.333-20.4 21.2-.8 1.6 7.066 8.8 33.733 30.933l34.667 28.933 8.8-8.266c14.666-13.867 28.666-22 48.133-28.267 9.067-2.933 14.8-3.733 28.533-4.4 34.267-1.333 60 7.467 81.6 28.133 21.6 20.4 34.934 49.6 37.467 81.734l.8 11.2 14.8 4.533c8.133 2.533 23.733 7.333 34.667 10.8 10.933 3.333 20.4 5.6 21.066 4.933 1.6-1.6 6.134-20.533 7.734-32.666.8-6 1.333-17.6 1.066-25.6l-.4-14.667-8-1.067c-4.4-.533-10.133-1.466-12.666-1.866l-4.667-.8 4.667-1.2c16.933-4.534 18.666-5.2 18.666-8 0-5.467-9.6-31.334-16.666-44.8-4-7.6-10.667-18.667-14.934-24.667-9.866-13.867-31.333-35.467-45.2-45.2-10.4-7.467-34.4-20.933-37.2-21.067-.8 0-4 4-7.333 8.8-3.2 4.8-6.133 8.134-6.4 7.334s.4-5.6 1.6-10.667c1.2-5.2 2.133-9.6 2.133-9.867 0-.933-19.866-6.133-34.4-9.066-14.8-2.934-49.333-4.4-59.6-2.534"/><path d="M157.867 125.533c-21.067 3.334-42.134 14.8-57.467 31.334-13.333 14.133-13.733 12.8 5.6 22 9.2 4.4 16.667 8.266 16.667 8.533s-1.334.4-2.934.133c-13.866-2.133-41.6-5.866-41.733-5.6-.267.267-7.467 28.534-16.267 63.067l-16 62.667 7.334.4c4 .266 7.466.266 7.6 0 .266-.267 3.866-13.867 8.133-30.4 4.267-16.534 8.267-30.8 8.933-31.734.934-1.2 11.067-1.6 42.4-1.6 32.134 0 41.2.4 41.2 1.6 0 .934-1.733 4.667-3.866 8.4L153.733 261l-35.066 6.933c-19.334 3.867-35.2 7.2-35.467 7.467-.667.667-29.867 113.467-29.467 113.867.267.133 23.734-3.6 52.4-8.534l52-8.8 20.4-39.866c11.2-22 20.667-39.734 20.934-39.467.4.533-1.334 26.8-2.8 40.8l-.667 6.933 6.267-3.2c21.2-10.666 52.4-13.466 86.933-8l5.867.934-5.6-7.334C286.4 318.6 281.2 310.6 278 304.867c-5.867-10.134-6-10.8-6-21.867 0-6.267 1.467-20 3.333-30.667 1.867-10.666 3.334-19.466 3.334-19.466 0-.134-9.067-4.267-20.134-9.334s-19.466-9.333-18.8-9.6c.8-.266 7.734.8 15.6 2.267 7.734 1.6 14.4 2.8 14.8 2.8 1.2 0 .4-10.533-1.466-18-7.2-27.733-28-53.467-53.734-66-16.4-8-40.8-12-57.066-9.467"/><path d="M235.6 346.333c-24 4.534-44.133 13.867-68.267 31.467-14 10.267-28.533 18.133-47.733 25.867-23.467 9.466-52.8 32.666-64.4 50.666l-2.533 4L58 454.2c9.333-7.333 30.133-19.467 49.333-28.667C173.733 393.667 246.4 382.2 312.8 393c11.2 1.733 39.2 8.533 45.067 10.8 2.266.8 2.266.667.8-2.267-4-7.6-15.6-21.866-25.867-31.466-12-11.467-24.667-18.934-37.6-22.4-11.467-3.067-46.267-3.867-59.6-1.334"/></g><g transform="translate(-460 467)"><path d="M721.533 34.467c-14.933 5.466-22 17.466-22.933 38.666-.933 24.134 3.467 32.8 30.267 59.867 19.6 19.867 22.933 25.2 22.933 37.867.133 13.466-6.133 20.133-16.933 18.4-9.067-1.467-12.534-7.867-12.534-22.667V159H696.6l.667 13.333c.533 11.467 1.2 14.4 4.933 22 7.067 14.267 16.8 19.6 36.4 19.734 10.667.133 12.267-.134 20.667-4.4 7.6-3.867 9.733-5.867 13.2-11.734 7.6-12.533 9.066-32 3.733-47.6-3.733-11.066-10.667-20.4-27.867-37.2-19.866-19.6-22.533-24.133-22.666-38.4 0-8.933.4-10.533 3.2-13.6 6.266-6.666 18.266-5.6 22.133 2 1.067 2 2 7.067 2 11.2v7.334h27.067l-.934-9.2c-1.6-18.267-8.266-30.267-20-36.4-7.2-3.867-29.2-4.8-37.6-1.6M630.067 34.867c-11.734 4.666-18 11.6-21.734 24.4-1.866 6.4-2 15.333-1.733 67.2l.4 59.866 3.733 7.6c6.8 13.867 18.534 20.267 36.934 20.267 13.733 0 22.933-3.333 30.666-11.067 10.934-11.066 11.2-12.533 11.734-74.666.266-35.734-.134-56.934-1.067-62.8-2.667-16.134-11.6-27.467-24.8-31.467-8.933-2.667-26.4-2.267-34.133.667m28.666 26.8 3.6 4v56.666c0 40.934-.4 57.467-1.6 60-3.6 8-15.6 9.734-22.666 3.467l-4.4-3.867-.4-56.533c-.267-51.733-.134-56.8 2-61.067 3.066-5.866 7.6-8.266 14.4-7.466 3.733.4 6.4 1.866 9.066 4.8M511.667 123.133v89.334l29.066-.4c28.8-.4 28.934-.4 36.667-4.267 9.467-4.533 14.4-10.933 17.467-22.4 2-7.333 2.266-15.467 1.866-65.733l-.4-57.334-4.266-8.8c-8.267-16.666-17.2-19.866-55.334-19.866h-25.066zm53.6-60.266 4.4 3.866.4 52.8c.266 35.067-.134 54.4-1.067 58-2 7.467-5.733 9.6-18.667 10.4l-10.666.8V59h10.666c9.867 0 10.934.267 14.934 3.867M471.667 145v67.333h26.666V77.667h-26.666zM471.667 48.333V63h26.666V33.667h-26.666z"/></g><g transform="translate(-106 244)"><path d="M893.4 259.733c-6.8 3.467-9.2 5.6-12.667 11.467-10.666 17.733-9.2 42.933 3.467 62.267 2.8 4.266 12.267 14.8 20.933 23.333 9.867 9.467 17.067 17.733 18.934 21.6 5.6 11.333 5.2 25.333-.934 30.8-3.466 3.067-11.333 4.133-16.133 2.133-5.867-2.4-8-7.466-8-19.333v-10h-27.067l.8 11.6c1.2 15.867 3.867 24.133 10.267 31.333 7.467 8.534 16.4 12.134 30 12.267 19.067.133 30.133-5.733 37.333-19.867 3.734-7.466 4-8.666 4-24 0-16 0-16.133-5.2-26.666-4.4-9.2-7.733-13.2-23.066-28.534-21.067-21.066-24.8-27.066-24.934-40.4-.133-10.4 2.8-15.6 9.734-17.6 10.133-2.933 17.2 3.334 18.4 16.267l.8 8.267H955.4l-.8-10.8c-.533-8.4-1.6-12.667-4.8-19.2-7.067-14.134-16.667-19.334-36.133-19.334-10.667 0-12.534.4-20.267 4.4M791 346v89.333h76v-24h-48v-54.666h37.333v-24H819V282h48v-25.333h-76zM661.667 346v89.333h22.666l.134-63.066c0-34.534.533-61.734 1.066-60.267.534 1.467 5.467 29.867 10.8 62.933l9.867 60.4h13.067c7.2 0 13.066-.4 13.066-1.066 0-3.067 18.8-124.8 19.334-125.334.4-.4.666 27.867.666 62.8v63.6h25.334V256.667h-38l-9.2 61.6c-5.067 34-9.6 62.133-10 62.666-.534.534-5.334-26.4-10.667-60-5.467-33.466-10.133-61.733-10.533-62.666-.4-1.2-5.467-1.6-19.067-1.6h-18.533zM586.467 258.267c-.8 2.666-27.467 172.4-27.467 174.933 0 1.867 1.733 2.133 12 2.133h11.867l.8-4.4c.533-2.266 1.6-9.333 2.4-15.6l1.6-11.333 17.6-.4 17.466-.4 1.467 8.4c.8 4.667 1.733 11.867 2.267 16l.933 7.733h13.733c7.6 0 13.867-.266 13.867-.666 0-.8-26.533-168.134-27.467-173.734l-.8-4.266h-19.866c-14.8 0-20.134.4-20.4 1.6M613 336.533c3.333 23.067 5.867 42.134 5.6 42.4-.4.267-6.533.267-13.867.134l-13.2-.4 4.934-33.334c2.8-18.4 5.733-38.4 6.666-44.666C604.2 292.533 605 290.133 605.8 292c.533 1.467 3.867 21.467 7.2 44.533M497.267 257.2c-10.134 3.733-15.2 8.267-19.867 17.733L473 284l-.4 59.067c-.4 51.2-.133 60.133 1.733 66.533 5.6 19.333 17.067 27.333 39.467 27.467 10.267.133 12.267-.267 20.133-4.134 9.334-4.533 13.867-9.733 17.867-20.266 2-4.934 2.4-12 2.933-41.067l.534-34.933h-38.934v23.866l6.4.4 6.267.4v19.334c0 13.466-.533 20.666-1.867 23.733-5.066 12-23.333 10.4-26.8-2.4-.933-3.6-1.333-23.2-1.066-59.067.4-48.533.666-54.133 2.666-57.333 3.334-4.8 11.2-7.067 17.6-4.933 6.934 2.266 9.067 7.2 9.867 22.933l.667 13.067H555.4l-.8-15.734c-.8-18-3.067-25.6-9.867-33.466-7.466-8.8-13.466-11.2-29.066-11.734-9.067-.266-14.934.134-18.4 1.467"/></g></svg>',he=`data:image/svg+xml;utf8,${encodeURIComponent(Fe)}`;var qe=["https://cloud.idosgames.com","https://idosgames.com","https://www.idosgames.com"];function ge(){return typeof window<"u"&&qe.includes(window.location.origin)}function X({client:e,onAuthenticated:o}){let[t,l]=useState(false),[n,a]=useState(null),[c,g]=useState(true),u=async()=>{l(true),a(null),e.auth.setRememberSession(c);let r=await e.auth.loginWithDeviceID();if(r.ok){o();return}a(r.error),l(false);};return jsx("div",{style:w.root,children:jsxs("div",{style:w.card,children:[jsx("img",{src:he,alt:"iDos Games",style:w.logo}),jsx("h1",{style:w.title,children:"Sign in"}),ge()&&jsx("button",{type:"button",onClick:()=>beginSsoRedirect({titleID:e.titleID}),disabled:t,style:{...w.primary,opacity:t?.6:1,cursor:t?"default":"pointer"},children:"Continue with iDos Games"}),jsx("button",{type:"button",onClick:()=>{u();},disabled:t,style:{...ge()?w.ghost:w.primary,opacity:t?.6:1,cursor:t?"default":"pointer"},children:t?"Signing in\u2026":"Play as guest"}),jsxs("label",{style:{...w.remember,opacity:t?.6:1},children:[jsx("input",{type:"checkbox",checked:c,disabled:t,onChange:r=>g(r.target.checked),style:w.switchInput}),jsx("span",{style:{...w.switchTrack,background:c?"#fff":"rgba(255, 255, 255, 0.3)"},children:jsx("span",{style:{...w.switchKnob,left:c?"21px":"3px",background:c?"#0d66fe":"#fff"}})}),"Remember me"]}),n&&jsx("span",{style:w.error,children:n})]})})}var w={root:{position:"absolute",inset:0,display:"grid",placeItems:"center",background:"#0d66fe",color:"#fff",font:"14px system-ui, sans-serif"},card:{width:"min(340px, 88vw)",display:"grid",gap:"18px",justifyItems:"center"},logo:{width:"180px",userSelect:"none",pointerEvents:"none"},title:{margin:0,fontSize:"22px",fontWeight:600,textAlign:"center"},primary:{width:"100%",padding:"11px 16px",borderRadius:"8px",border:"none",background:"#fff",color:"#0d66fe",fontWeight:600,font:"inherit"},ghost:{width:"100%",padding:"11px 16px",borderRadius:"8px",border:"1px solid rgba(255, 255, 255, 0.45)",background:"transparent",color:"#fff",fontWeight:600,font:"inherit"},remember:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",color:"rgba(255, 255, 255, 0.85)"},switchInput:{position:"absolute",opacity:0,width:0,height:0},switchTrack:{position:"relative",width:"42px",height:"24px",borderRadius:"12px",transition:"background 0.15s",flexShrink:0},switchKnob:{position:"absolute",top:"3px",width:"18px",height:"18px",borderRadius:"50%",transition:"left 0.15s, background 0.15s"},error:{color:"#ffd7d7",textAlign:"center"}};function Qe(e){let{container:o,client:t,modules:l,renderLogin:n}=e;o.style.position="relative";let a=document.createElement("div");Object.assign(a.style,{position:"absolute",inset:"0",zIndex:"0",pointerEvents:"none"});let c=document.createElement("div");Object.assign(c.style,{position:"absolute",inset:"0",zIndex:"1"}),o.append(a,c);let g=T(),u=B(a);N(()=>g.describe());let r=I(l);for(let p of r.warnings)console.warn(`[idos shared-ui] ${p}`);let s=createRoot(c);return s.render(jsx(IDosGamesProvider,{client:t,children:jsx(StatusProvider,{children:jsx(q,{client:t,modules:l,events:g,sharedUi:r.owners,surface:u,renderLogin:n??X})})})),{unmount(){s.unmount(),a.remove(),c.remove();}}}
|
|
11
|
-
export{
|
|
10
|
+
`}),jsxs("div",{style:Ve,children:[jsx("span",{style:{...pe,animationDelay:"0s"}}),jsx("span",{style:{...pe,animationDelay:"1.1s"}}),jsx("span",{style:Fe,children:"\u{1F9E9}"})]}),jsx("div",{style:{fontWeight:700,fontSize:18,marginBottom:6},children:"No modules installed"}),jsxs("div",{style:{opacity:.85,maxWidth:380,lineHeight:1.5},children:["Add a module under ",jsx("code",{children:"src/modules/"})," and register it in"," ",jsx("code",{children:"src/modules.ts"}),". The host shell will pick it up here."]})]})}var Ue={position:"absolute",inset:0,overflow:"hidden",background:"#0d66fe",color:"#fff",fontFamily:"system-ui, sans-serif"},Te={position:"absolute",inset:0,zIndex:0},fe=16,Pe={position:"absolute",top:0,right:0,bottom:0,left:0,zIndex:1,pointerEvents:"none"},Oe={display:"contents",pointerEvents:"auto"},De={position:"absolute",top:0,left:0,right:0,zIndex:2,display:"flex",gap:12,padding:16,pointerEvents:"none"},Be={position:"absolute",top:0,right:0,bottom:0,width:340,maxWidth:"40vw",zIndex:2,display:"flex",flexDirection:"column",gap:12,padding:16,overflowY:"auto",pointerEvents:"none"},Ne={position:"absolute",bottom:fe,left:"50%",transform:"translateX(-50%)",zIndex:3,display:"flex",gap:8,padding:6,borderRadius:14,background:"rgba(4,32,90,0.72)",backdropFilter:"blur(6px)",pointerEvents:"auto"},ge={border:"none",borderRadius:10,padding:"8px 16px",fontWeight:700,fontSize:14,color:"#cfe0ff",background:"transparent",cursor:"pointer"},ze={...ge,color:"#0d66fe",background:"#fff"},Ge={position:"absolute",bottom:16,left:16,zIndex:3,display:"flex",gap:8,alignItems:"center",pointerEvents:"auto"},me={border:"none",borderRadius:12,padding:"8px 14px",fontWeight:700,fontSize:13,color:"#cfe0ff",background:"rgba(4,32,90,0.72)",backdropFilter:"blur(6px)",cursor:"pointer"},_e={...me,fontWeight:600,fontFamily:"ui-monospace, Consolas, monospace"},je={position:"absolute",inset:0,zIndex:4,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0,0,0,0.5)",pointerEvents:"none"},K={pointerEvents:"auto"},We={position:"absolute",inset:0,zIndex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",textAlign:"center",padding:24},Ve={position:"relative",width:110,height:110,marginBottom:16,display:"grid",placeItems:"center"},pe={position:"absolute",inset:0,borderRadius:"50%",border:"2px solid rgba(255,255,255,0.55)",animation:"idos-empty-ripple 2.2s ease-out infinite"},Fe={fontSize:46,animation:"idos-empty-float 3s ease-in-out infinite",filter:"drop-shadow(0 8px 12px rgba(0,0,0,0.25))"};function Q(e){let{client:o,modules:t,events:s,sharedUi:i,surface:l,renderLogin:d}=e,[y]=useState(V),[g,r]=useState(true),[n,c]=useState(null),p=useRef(null),u=()=>{for(let b of p.current??[])b.dispose();p.current=null;},m=()=>{u();let b=F(t,{client:o,events:s,surface:l,sharedUi:i,navigator:y});p.current=b,c(b);};useEffect(()=>()=>u(),[]);let S=useRef(false);useEffect(()=>{if(S.current)return;S.current=true;let b=readSsoCodeFromUrl();if(b){(async()=>((await o.auth.loginWithSsoCode(b.code)).ok&&m(),r(false)))();return}if(o.auth.lastAuthType===AuthType.None){r(false);return}(async()=>((await o.auth.autoLogin()).ok&&m(),r(false)))();},[o]),useEffect(()=>{let b=()=>{u(),c(null);},R=o.on("auth:unauthorized",b),k=o.on("auth:loggedOut",b);return ()=>{R(),k();}},[o]);let v=n?"game":g?"loading":"login";return useEffect(()=>{G({screen:v,loggedIn:n!==null,userId:o.auth.context?.userID??null,titleId:o.titleID??null,modules:t.map(b=>b.id),sharedUi:i});},[v,n,o,t,i]),n?jsx(X,{registrations:n,sharedUi:i,events:s,navigator:y,onLogout:()=>o.auth.logout(),userID:o.auth.context?.userID??null}):g?null:jsx(d,{client:o,onAuthenticated:m})}var Ye='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 860 690" fill="#fff"><g transform="translate(243 -2)"><path d="M147.333 12.333c-13.6 2.534-12.533 1.2-12.933 15.067l-.4 12.267-4.533-11.067c-2.534-6-5.067-10.933-5.734-10.933-2.666 0-27.866 8.666-36.533 12.666-11.733 5.334-26.667 14.8-36.133 22.934l-6.934 5.866L51.6 69.267c8.133 11.066 7.333 11.466-5.067 2.933-7.6-5.067-8.4-5.333-11.466-3.733-3.467 1.866-18.4 17.333-20.4 21.2-.8 1.6 7.066 8.8 33.733 30.933l34.667 28.933 8.8-8.266c14.666-13.867 28.666-22 48.133-28.267 9.067-2.933 14.8-3.733 28.533-4.4 34.267-1.333 60 7.467 81.6 28.133 21.6 20.4 34.934 49.6 37.467 81.734l.8 11.2 14.8 4.533c8.133 2.533 23.733 7.333 34.667 10.8 10.933 3.333 20.4 5.6 21.066 4.933 1.6-1.6 6.134-20.533 7.734-32.666.8-6 1.333-17.6 1.066-25.6l-.4-14.667-8-1.067c-4.4-.533-10.133-1.466-12.666-1.866l-4.667-.8 4.667-1.2c16.933-4.534 18.666-5.2 18.666-8 0-5.467-9.6-31.334-16.666-44.8-4-7.6-10.667-18.667-14.934-24.667-9.866-13.867-31.333-35.467-45.2-45.2-10.4-7.467-34.4-20.933-37.2-21.067-.8 0-4 4-7.333 8.8-3.2 4.8-6.133 8.134-6.4 7.334s.4-5.6 1.6-10.667c1.2-5.2 2.133-9.6 2.133-9.867 0-.933-19.866-6.133-34.4-9.066-14.8-2.934-49.333-4.4-59.6-2.534"/><path d="M157.867 125.533c-21.067 3.334-42.134 14.8-57.467 31.334-13.333 14.133-13.733 12.8 5.6 22 9.2 4.4 16.667 8.266 16.667 8.533s-1.334.4-2.934.133c-13.866-2.133-41.6-5.866-41.733-5.6-.267.267-7.467 28.534-16.267 63.067l-16 62.667 7.334.4c4 .266 7.466.266 7.6 0 .266-.267 3.866-13.867 8.133-30.4 4.267-16.534 8.267-30.8 8.933-31.734.934-1.2 11.067-1.6 42.4-1.6 32.134 0 41.2.4 41.2 1.6 0 .934-1.733 4.667-3.866 8.4L153.733 261l-35.066 6.933c-19.334 3.867-35.2 7.2-35.467 7.467-.667.667-29.867 113.467-29.467 113.867.267.133 23.734-3.6 52.4-8.534l52-8.8 20.4-39.866c11.2-22 20.667-39.734 20.934-39.467.4.533-1.334 26.8-2.8 40.8l-.667 6.933 6.267-3.2c21.2-10.666 52.4-13.466 86.933-8l5.867.934-5.6-7.334C286.4 318.6 281.2 310.6 278 304.867c-5.867-10.134-6-10.8-6-21.867 0-6.267 1.467-20 3.333-30.667 1.867-10.666 3.334-19.466 3.334-19.466 0-.134-9.067-4.267-20.134-9.334s-19.466-9.333-18.8-9.6c.8-.266 7.734.8 15.6 2.267 7.734 1.6 14.4 2.8 14.8 2.8 1.2 0 .4-10.533-1.466-18-7.2-27.733-28-53.467-53.734-66-16.4-8-40.8-12-57.066-9.467"/><path d="M235.6 346.333c-24 4.534-44.133 13.867-68.267 31.467-14 10.267-28.533 18.133-47.733 25.867-23.467 9.466-52.8 32.666-64.4 50.666l-2.533 4L58 454.2c9.333-7.333 30.133-19.467 49.333-28.667C173.733 393.667 246.4 382.2 312.8 393c11.2 1.733 39.2 8.533 45.067 10.8 2.266.8 2.266.667.8-2.267-4-7.6-15.6-21.866-25.867-31.466-12-11.467-24.667-18.934-37.6-22.4-11.467-3.067-46.267-3.867-59.6-1.334"/></g><g transform="translate(-460 467)"><path d="M721.533 34.467c-14.933 5.466-22 17.466-22.933 38.666-.933 24.134 3.467 32.8 30.267 59.867 19.6 19.867 22.933 25.2 22.933 37.867.133 13.466-6.133 20.133-16.933 18.4-9.067-1.467-12.534-7.867-12.534-22.667V159H696.6l.667 13.333c.533 11.467 1.2 14.4 4.933 22 7.067 14.267 16.8 19.6 36.4 19.734 10.667.133 12.267-.134 20.667-4.4 7.6-3.867 9.733-5.867 13.2-11.734 7.6-12.533 9.066-32 3.733-47.6-3.733-11.066-10.667-20.4-27.867-37.2-19.866-19.6-22.533-24.133-22.666-38.4 0-8.933.4-10.533 3.2-13.6 6.266-6.666 18.266-5.6 22.133 2 1.067 2 2 7.067 2 11.2v7.334h27.067l-.934-9.2c-1.6-18.267-8.266-30.267-20-36.4-7.2-3.867-29.2-4.8-37.6-1.6M630.067 34.867c-11.734 4.666-18 11.6-21.734 24.4-1.866 6.4-2 15.333-1.733 67.2l.4 59.866 3.733 7.6c6.8 13.867 18.534 20.267 36.934 20.267 13.733 0 22.933-3.333 30.666-11.067 10.934-11.066 11.2-12.533 11.734-74.666.266-35.734-.134-56.934-1.067-62.8-2.667-16.134-11.6-27.467-24.8-31.467-8.933-2.667-26.4-2.267-34.133.667m28.666 26.8 3.6 4v56.666c0 40.934-.4 57.467-1.6 60-3.6 8-15.6 9.734-22.666 3.467l-4.4-3.867-.4-56.533c-.267-51.733-.134-56.8 2-61.067 3.066-5.866 7.6-8.266 14.4-7.466 3.733.4 6.4 1.866 9.066 4.8M511.667 123.133v89.334l29.066-.4c28.8-.4 28.934-.4 36.667-4.267 9.467-4.533 14.4-10.933 17.467-22.4 2-7.333 2.266-15.467 1.866-65.733l-.4-57.334-4.266-8.8c-8.267-16.666-17.2-19.866-55.334-19.866h-25.066zm53.6-60.266 4.4 3.866.4 52.8c.266 35.067-.134 54.4-1.067 58-2 7.467-5.733 9.6-18.667 10.4l-10.666.8V59h10.666c9.867 0 10.934.267 14.934 3.867M471.667 145v67.333h26.666V77.667h-26.666zM471.667 48.333V63h26.666V33.667h-26.666z"/></g><g transform="translate(-106 244)"><path d="M893.4 259.733c-6.8 3.467-9.2 5.6-12.667 11.467-10.666 17.733-9.2 42.933 3.467 62.267 2.8 4.266 12.267 14.8 20.933 23.333 9.867 9.467 17.067 17.733 18.934 21.6 5.6 11.333 5.2 25.333-.934 30.8-3.466 3.067-11.333 4.133-16.133 2.133-5.867-2.4-8-7.466-8-19.333v-10h-27.067l.8 11.6c1.2 15.867 3.867 24.133 10.267 31.333 7.467 8.534 16.4 12.134 30 12.267 19.067.133 30.133-5.733 37.333-19.867 3.734-7.466 4-8.666 4-24 0-16 0-16.133-5.2-26.666-4.4-9.2-7.733-13.2-23.066-28.534-21.067-21.066-24.8-27.066-24.934-40.4-.133-10.4 2.8-15.6 9.734-17.6 10.133-2.933 17.2 3.334 18.4 16.267l.8 8.267H955.4l-.8-10.8c-.533-8.4-1.6-12.667-4.8-19.2-7.067-14.134-16.667-19.334-36.133-19.334-10.667 0-12.534.4-20.267 4.4M791 346v89.333h76v-24h-48v-54.666h37.333v-24H819V282h48v-25.333h-76zM661.667 346v89.333h22.666l.134-63.066c0-34.534.533-61.734 1.066-60.267.534 1.467 5.467 29.867 10.8 62.933l9.867 60.4h13.067c7.2 0 13.066-.4 13.066-1.066 0-3.067 18.8-124.8 19.334-125.334.4-.4.666 27.867.666 62.8v63.6h25.334V256.667h-38l-9.2 61.6c-5.067 34-9.6 62.133-10 62.666-.534.534-5.334-26.4-10.667-60-5.467-33.466-10.133-61.733-10.533-62.666-.4-1.2-5.467-1.6-19.067-1.6h-18.533zM586.467 258.267c-.8 2.666-27.467 172.4-27.467 174.933 0 1.867 1.733 2.133 12 2.133h11.867l.8-4.4c.533-2.266 1.6-9.333 2.4-15.6l1.6-11.333 17.6-.4 17.466-.4 1.467 8.4c.8 4.667 1.733 11.867 2.267 16l.933 7.733h13.733c7.6 0 13.867-.266 13.867-.666 0-.8-26.533-168.134-27.467-173.734l-.8-4.266h-19.866c-14.8 0-20.134.4-20.4 1.6M613 336.533c3.333 23.067 5.867 42.134 5.6 42.4-.4.267-6.533.267-13.867.134l-13.2-.4 4.934-33.334c2.8-18.4 5.733-38.4 6.666-44.666C604.2 292.533 605 290.133 605.8 292c.533 1.467 3.867 21.467 7.2 44.533M497.267 257.2c-10.134 3.733-15.2 8.267-19.867 17.733L473 284l-.4 59.067c-.4 51.2-.133 60.133 1.733 66.533 5.6 19.333 17.067 27.333 39.467 27.467 10.267.133 12.267-.267 20.133-4.134 9.334-4.533 13.867-9.733 17.867-20.266 2-4.934 2.4-12 2.933-41.067l.534-34.933h-38.934v23.866l6.4.4 6.267.4v19.334c0 13.466-.533 20.666-1.867 23.733-5.066 12-23.333 10.4-26.8-2.4-.933-3.6-1.333-23.2-1.066-59.067.4-48.533.666-54.133 2.666-57.333 3.334-4.8 11.2-7.067 17.6-4.933 6.934 2.266 9.067 7.2 9.867 22.933l.667 13.067H555.4l-.8-15.734c-.8-18-3.067-25.6-9.867-33.466-7.466-8.8-13.466-11.2-29.066-11.734-9.067-.266-14.934.134-18.4 1.467"/></g></svg>',ye=`data:image/svg+xml;utf8,${encodeURIComponent(Ye)}`;var Je=["https://cloud.idosgames.com","https://idosgames.com","https://www.idosgames.com"],Qe=/^https:\/\/[a-z0-9]{8}\.idos\.games$/;function Se(){if(typeof window>"u")return false;let{origin:e}=window.location;return Je.includes(e)||Qe.test(e)?true:typeof document<"u"&&document.querySelector('meta[name="idos-game-host"]')!==null}function ee({client:e,onAuthenticated:o}){let[t,s]=useState(false),[i,l]=useState(null),[d,y]=useState(true),g=async()=>{s(true),l(null),e.auth.setRememberSession(d);let r=await e.auth.loginWithDeviceID();if(r.ok){o();return}l(r.error),s(false);};return jsx("div",{style:w.root,children:jsxs("div",{style:w.card,children:[jsx("img",{src:ye,alt:"iDos Games",style:w.logo}),jsx("h1",{style:w.title,children:"Sign in"}),Se()&&jsx("button",{type:"button",onClick:()=>beginSsoRedirect({titleID:e.titleID}),disabled:t,style:{...w.primary,opacity:t?.6:1,cursor:t?"default":"pointer"},children:"Continue with iDos Games"}),jsx("button",{type:"button",onClick:()=>{g();},disabled:t,style:{...Se()?w.ghost:w.primary,opacity:t?.6:1,cursor:t?"default":"pointer"},children:t?"Signing in\u2026":"Play as guest"}),jsxs("label",{style:{...w.remember,opacity:t?.6:1},children:[jsx("input",{type:"checkbox",checked:d,disabled:t,onChange:r=>y(r.target.checked),style:w.switchInput}),jsx("span",{style:{...w.switchTrack,background:d?"#fff":"rgba(255, 255, 255, 0.3)"},children:jsx("span",{style:{...w.switchKnob,left:d?"21px":"3px",background:d?"#0d66fe":"#fff"}})}),"Remember me"]}),i&&jsx("span",{style:w.error,children:i})]})})}var w={root:{position:"absolute",inset:0,display:"grid",placeItems:"center",background:"#0d66fe",color:"#fff",font:"14px system-ui, sans-serif"},card:{width:"min(340px, 88vw)",display:"grid",gap:"18px",justifyItems:"center"},logo:{width:"180px",userSelect:"none",pointerEvents:"none"},title:{margin:0,fontSize:"22px",fontWeight:600,textAlign:"center"},primary:{width:"100%",padding:"11px 16px",borderRadius:"8px",border:"none",background:"#fff",color:"#0d66fe",fontWeight:600,font:"inherit"},ghost:{width:"100%",padding:"11px 16px",borderRadius:"8px",border:"1px solid rgba(255, 255, 255, 0.45)",background:"transparent",color:"#fff",fontWeight:600,font:"inherit"},remember:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",color:"rgba(255, 255, 255, 0.85)"},switchInput:{position:"absolute",opacity:0,width:0,height:0},switchTrack:{position:"relative",width:"42px",height:"24px",borderRadius:"12px",transition:"background 0.15s",flexShrink:0},switchKnob:{position:"absolute",top:"3px",width:"18px",height:"18px",borderRadius:"50%",transition:"left 0.15s, background 0.15s"},error:{color:"#ffd7d7",textAlign:"center"}};function ot(e){let{container:o,client:t,modules:s,renderLogin:i}=e;o.style.position="relative";let l=document.createElement("div");Object.assign(l.style,{position:"absolute",inset:"0",zIndex:"0",pointerEvents:"none"});let d=document.createElement("div");Object.assign(d.style,{position:"absolute",inset:"0",zIndex:"1"}),o.append(l,d);let y=D(),g=N(l);_(()=>y.describe());let r=A(s);for(let c of r.warnings)console.warn(`[idos shared-ui] ${c}`);let n=createRoot(d);return n.render(jsx(IDosGamesProvider,{client:t,children:jsx(StatusProvider,{children:jsx(Q,{client:t,modules:s,events:y,sharedUi:r.owners,surface:g,renderLogin:i??ee})})})),{unmount(){n.unmount(),l.remove(),d.remove();}}}
|
|
11
|
+
export{Q as AuthGate,ee as DefaultLoginScreen,X as HostShell,I as SceneStage,W as createContentRegistry,D as createHostEventBus,V as createHostNavigator,ke as createSharedEventBus,N as createSurfaceAllocator,le as emptySharedUiOwners,ot as mountHost,_ as publishEventsProvider,G as publishHostState,z as registerAgentApi,A as resolveSharedUi,F as runModules,B as sharedUiFor};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@idosgames/app-shell",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "The host runtime for composable modules: module registry, shared event bus, surface allocator, scene stage, and the React Mode Router shell. A project seeds one host shell and plugs N modules into it.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -47,9 +47,9 @@
|
|
|
47
47
|
},
|
|
48
48
|
"//": "react/react-dom are consumer-provided peers. @idosgames/* are real ranges pinned in step with those packages.",
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@idosgames/core": "^0.
|
|
51
|
-
"@idosgames/module-sdk": "^0.
|
|
52
|
-
"@idosgames/react": "^0.2.
|
|
50
|
+
"@idosgames/core": "^0.14.0",
|
|
51
|
+
"@idosgames/module-sdk": "^0.3.0",
|
|
52
|
+
"@idosgames/react": "^0.2.7"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
55
|
"react": "^18.3.1 || ^19.0.0",
|