gamestage 0.36.1 → 0.36.3
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/cli.mjs +3 -3
- package/package.json +1 -1
package/cli.mjs
CHANGED
|
@@ -14124,9 +14124,9 @@ main()
|
|
|
14124
14124
|
# this folder. Real rounds are written in Monterosa Studio;
|
|
14125
14125
|
# \`gamestage round push\` copies this one there if you want to start from it.
|
|
14126
14126
|
`+ft.dump(e,{indent:2,lineWidth:100,noRefs:!0,sortKeys:!1})}async function _r(e,t){let o=await wo(e);return o.ok?{source:"practice",round:o.round,line:SP,path:o.path}:o.missing?t?{source:"stand-in",round:t,line:TP}:{source:"none",line:"Round: none. This format has no stand-in round yet."}:{source:"invalid",path:o.path,problems:o.problems}}function Fn(e){return`${pe} is not a valid round (${e}).`}function Et(e,t){return t.some(o=>o.path==="backend.round")?kr:`${e} is not a valid App Manifest.`}async function KS(e){let t;try{t=await VS(e,"utf8")}catch{return null}let o=an(t);return o.ok&&o.manifest.backend.round!==void 0?kr:null}var ti,pe,kr,SP,TP,$t=_(()=>{"use strict";qa();ye();ti="practice",pe=`${ti}/round.yaml`,kr="Rounds don't go in gamestage.yaml. Put practice rounds in practice/round.yaml, and real ones in Studio.",SP=`Round: ${pe} (practice only, fans never see it)`,TP="Round: stand-in round"});import{readFile as EP}from"node:fs/promises";import{dirname as $P,join as AP}from"node:path";async function Wt(e){let t=AP($P(e),un),o;try{o=await EP(t,"utf8")}catch{return{path:t,problems:[]}}let r;try{r=JSON.parse(o)}catch(a){return{path:t,problems:[`${un} is not valid JSON: ${a instanceof Error?a.message:String(a)}`]}}let n=Rx(r);return n.length>0?{path:t,problems:n}:{path:t,settings:r,problems:n}}function OP(e){let t=e.trim();return t.startsWith("//")||t.startsWith("*")||t.startsWith("/*")||t.startsWith("<!--")||/^<title\b/i.test(t)||/^<meta\b/i.test(t)}function zP(e){if(e==="primary_colour")return"gamestage-primary";let t=/^css_variables_([A-Za-z]+)$/.exec(e);return t?`gs-${t[1]}`:void 0}function RP(e){let t=o=>o.replace(/[^\n]/g," ");return e.replace(/\/\*[\s\S]*?\*\//g,t).replace(/<!--[\s\S]*?-->/g,t)}function JS(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Wc(e,t){if(!e)return[];let o=[];for(let[r,n]of Object.entries(e)){if(CP.has(r))continue;let a=typeof n=="string"?n.trim():"";if(!a)continue;let i;if(PP.test(a)){let s=zP(r);if(!s)continue;i=new RegExp(`var\\(\\s*--${JS(s)}\\s*,\\s*(?!var\\()[^)\\s]`,"i")}else{if(a.length<4)continue;i=new RegExp(`(?<!["'][a-z][a-z-]*\\.[A-Za-z.]+["']\\s*:\\s*)(?<![{,]\\s*\\d+\\s*:\\s*)(["'\`>])\\s*${JS(a)}\\s*(["'\`<])`)}for(let s of t)if(s.relative.split("/").pop()!==un&&!IP.test(s.relative)&&RP(ES(s.text)).split(`
|
|
14127
|
-
`).some(m=>!OP(m)&&i.test(m))){o.push({setting:r,file:s.relative});break}}return o}function Hc(e){return`The page keeps its own copy of ${e.map(t=>`${t.setting} (in ${t.file})`).join(", ")}. Studio is the only home of these: delete the value from the page and render what game.presentation gives you. The client remembers the last settings on the fan's device and draws its own retry screen if Studio cannot be reached.`}var un,CP,IP,PP,ko=_(()=>{"use strict";ye();un="gamestage.settings.json";CP=new Set(["title_font","title_font_weight","title_case"]),IP=/(^|\/)components\/gamestage\//,PP=/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i});function XS(e,t,o,r=""){let n=new Set([...Va(),...Za(r)]),a={},i=(s,m)=>{m&&n.has(s)&&(a[s]=m)};i("display_name",t.trim());for(let[s,m]of Object.entries(e))i(s,m);if(o&&i("how_to_play",NP[o]),i("splash_play_label",dn.play),i("splash_continue_label",dn.continue),i("splash_error_text",dn.error),i("splash_retry_label",dn.retry),/\bmountRecovery\s*\(/.test(r))for(let[s,m]of Object.entries(jS))i(s,NS[m]);return a}function QS(e){return new Set([...e.matchAll(/var\(\s*--gs-([A-Za-z]+)\s*[,)]/g)].map(t=>t[1]))}var NP,Rf=_(()=>{"use strict";ye();NP={hunt:"Find the right ones on the board. A wrong pick costs a try.",push:"Pick one from each line. Get as close to the limit as you dare without going over.",group:"Sort the board into its groups. A wrong group costs a life.",predict:"Call what will happen before it does. You score when you are right.",bingo:"Lock your board, then mark each square as it happens. A full line scores.",shoot:"Pick a spot and a power, then shoot. The keeper decides the rest."}});import{spawn as aT}from"node:child_process";import{chmod as eT,mkdir as tT,readFile as nT,rm as oT,writeFile as rT}from"node:fs/promises";import{homedir as jP,platform as xr}from"node:os";import{dirname as LP,join as iT}from"node:path";async function sT(){let e=await fetch(`${Nf}/user_management/authorize/device`,{method:"POST",headers:{"content-type":"application/x-www-form-urlencoded"},body:new URLSearchParams({client_id:jf})});if(!e.ok)throw new Error(`Could not start sign-in (${e.status}). ${await e.text()}`);return await e.json()}async function cT(e){let t=await fetch(`${Nf}/user_management/authenticate`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({client_id:jf,grant_type:"urn:ietf:params:oauth:grant-type:device_code",device_code:e})}),o=await t.json();if(t.ok){let r=o.user;return{status:"ok",session:{accessToken:String(o.access_token??""),refreshToken:o.refresh_token?String(o.refresh_token):void 0,email:r?.email,userId:r?.id}}}switch(o.error){case"authorization_pending":return{status:"pending"};case"slow_down":return{status:"slow_down"};case"expired_token":return{status:"expired"};default:return{status:"denied",reason:String(o.error_description??o.error??"unknown error")}}}function lT(e){let t=xr()==="darwin"?"open":xr()==="win32"?"cmd":"xdg-open",o=xr()==="win32"?["/c","start","",e]:[e];try{aT(t,o,{stdio:"ignore",detached:!0}).unref()}catch{}}function Lf(){let e=process.env.GAMESTAGE_CREDENTIALS?.trim();return e||void 0}function Df(e,t){return new Promise(o=>{let r=aT("security",e,{stdio:["pipe","pipe","ignore"]}),n="";r.stdout.on("data",a=>n+=a),r.on("error",()=>o(null)),r.on("close",a=>o(a===0?n.trim():null)),t!==void 0?r.stdin.end(t):r.stdin.end()})}async function Mf(e){let t=JSON.stringify(e),o=Lf();return o?(await tT(LP(o),{recursive:!0,mode:448}),await rT(o,t,{mode:384}),await eT(o,384),"file"):xr()==="darwin"&&await Df(["add-generic-password","-a",Sr,"-s",Sr,"-U","-w",t])!==null?"keychain":(await tT(dT,{recursive:!0,mode:448}),await rT(Yc,t,{mode:384}),await eT(Yc,384),"file")}function DP(e){try{let[,t]=e.split("."),{exp:o}=JSON.parse(Buffer.from(t,"base64url").toString());return typeof o!="number"?!0:o*1e3-Date.now()<3e4}catch{return!0}}async function MP(e){if(!e.refreshToken)return null;let t=await fetch(`${Nf}/user_management/authenticate`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({client_id:jf,grant_type:"refresh_token",refresh_token:e.refreshToken})});if(!t.ok)return null;let o=await t.json();return o.access_token?{...e,accessToken:String(o.access_token),refreshToken:o.refresh_token?String(o.refresh_token):e.refreshToken}:null}async function FP(){let e=Lf();if(e)try{return JSON.parse(await nT(e,"utf8"))}catch{return null}if(xr()==="darwin"){let t=await Df(["find-generic-password","-a",Sr,"-s",Sr,"-w"]);if(t)try{return JSON.parse(t)}catch{}}try{return JSON.parse(await nT(Yc,"utf8"))}catch{return null}}async function mT(){let e=Lf();if(e){await oT(e,{force:!0});return}xr()==="darwin"&&await Df(["delete-generic-password","-a",Sr,"-s",Sr]),await oT(Yc,{force:!0})}async function Pe(){let e=await FP();if(!e)return null;if(!DP(e.accessToken)||!e.refreshToken)return e;let t=await MP(e);return t?(await Mf(t),t):null}var Nf,jf,Sr,dT,Yc,Un=_(()=>{"use strict";Nf="https://api.workos.com",jf=process.env.GAMESTAGE_CLIENT_ID??"client_01KYVPJ1MA6GA9EXTJ7GJ81YW4";Sr="gamestage-cli",dT=iT(jP(),".gamestage"),Yc=iT(dT,"credentials.json")});function Tr(e){return`${Le}/stage/games/${encodeURIComponent(e)}?tab=overview`}function uT(e){return e&&new Set(["hunt","push","group","predict"]).has(e)?`${Le}/docs/game-formats#${e}`:`${Le}/docs`}var Le,_o=_(()=>{"use strict";Le=process.env.GAMESTAGE_SITE_URL??"https://gamestage.ai"});function UP(e){try{let t=new URL(e).hostname.toLowerCase();return t==="localhost"||t.endsWith(".localhost")||t==="::1"||t.startsWith("127.")}catch{return!1}}function GP(e){return e.GAMESTAGE_TEST_RUN==="1"||e.NODE_TEST_CONTEXT!==void 0}function BP(e=Te,t=process.env){if(GP(t)&&!UP(e)&&t.GAMESTAGE_ALLOW_REMOTE_TESTS!=="1")return`Refusing to register a test game against non-local control plane ${e}. Use the throwaway local control plane, or set GAMESTAGE_ALLOW_REMOTE_TESTS=1 for a deliberate real-plane run.`}function $r(e=Te){let t=BP(e);t&&$(t)}async function Vc(){let e=await Pe();return e||$("You are not signed in.",["Run `gamestage login`. It creates the account too if you do not have one.","Inspecting, scaffolding and validating a manifest still need no account."]),e}async function le(){let e=await Vc();return{client:bo({baseUrl:Te,token:async()=>(await Pe())?.accessToken??e.accessToken}),email:e.email??e.userId??"unknown"}}async function ni(){let e=await Pe().catch(()=>null);if(e)return bo({baseUrl:Te,token:async()=>(await Pe())?.accessToken??e.accessToken})}async function Gn(){let e=await Pe();return e||$("You are not signed in.",["Run `gamestage login`. An operator's command needs an operator's own session."]),{admin:tS({baseUrl:Te,token:async()=>(await Pe())?.accessToken??e.accessToken}),email:e.email??e.userId??"unknown"}}async function Zc(e){try{let t=await e.getWorkspace(),o=t?.access;return o==="approved"||o==="pending"||o==="refused"?{access:o,workspace:t}:{access:"unreported",workspace:t}}catch(t){let o=t.status,r=t.code;return r===Uf?{access:"pending"}:o===404||r==="not_found"?{access:"unknown",problem:"no_control_plane",reason:`Nothing is serving a control plane at ${Te}.`,detail:["You are signed in, and deploying will fail until this is pointed somewhere real.","Set GAMESTAGE_CONTROL_URL to your control plane and run this again."]}:o===401||o===403?{access:"unknown",problem:"token_refused",reason:"The control plane refused this account's token.",detail:[`It is at ${Te}.`,"A token from one environment is refused by another, so check which one you signed into."]}:{access:"unknown",problem:"unreachable",reason:`Could not reach the control plane at ${Te}.`,detail:[String(t.message??t),"You are signed in. Deploying will fail until this answers."]}}}function oi(e){switch(e.access){case"approved":return{ok:!0,status:"approved",access:"approved",heading:"Approved",message:"Your account is approved, so every command works, including deploy.",next:["`gamestage status` shows the workspace, its games and what they are using."]};case"pending":return{ok:!0,status:"pending_approval",access:"pending",code:Uf,heading:"Registered, waiting for approval",message:"You are registered and your account is waiting for approval. That is the normal path for a new account, and approval is a person's decision today.",next:["Nothing is wrong and nothing is lost. There is no second form to fill in.","Inspecting a prototype, scaffolding a game and writing a round all work now and need no approval.","`gamestage status` re-checks approval. It never opens the browser again."]};case"refused":return{ok:!0,status:"access_refused",access:"refused",heading:"Access refused",message:"This account has been refused access. Signing in worked, so this is a decision about the account rather than a broken token.",next:["Nothing in the CLI changes this, and running `gamestage login` again will not.","Inspecting, scaffolding and writing a round still work and need no account.",`If you think this is wrong, say so where you registered: ${Le}.`]};case"unreported":return{ok:!0,status:"access_not_reported",access:null,heading:"Signed in",message:"This control plane answered and does not report an access state, so whether this account is approved is not known here.",next:["It predates the access state rather than being broken, so carry on.","A deploy that is refused for approval will say so in its own words."]};default:return{ok:!1,status:e.problem==="no_control_plane"?"no_control_plane":e.problem==="token_refused"?"token_refused":"control_plane_unreachable",access:null,heading:"Signed in, and the control plane is not usable",message:e.reason,next:e.detail}}}function pT(e){return!e.changed&&e.refused?{ok:!0,status:"refused_by_store",access:e.access,code:e.code,heading:"Not approved",message:e.refused,next:["Nothing was written. When they have accepted the terms, run this again."]}:e.changed?e.access==="approved"?{ok:!0,status:"approved",access:"approved",heading:"Approved",message:`${e.workspaceId} was ${e.previous} and is now approved.`,next:["Their next `gamestage status` says approved, and deploy works from then on."]}:{ok:!0,status:"refused",access:"refused",heading:"Refused",message:`${e.workspaceId} was ${e.previous} and is now refused.`,next:["Their next `gamestage status` says refused, and says how to argue with it."]}:{ok:!0,status:"unchanged",access:e.access,heading:"No change",message:`${e.workspaceId} was already ${e.previous}. Nothing was written.`,next:["No audit record either: the trail records transitions, and this was not one."]}}function Ar(e){if(I(e.heading),g(` ${e.message}`),e.next.length){g();for(let t of e.next)w(t)}g()}function hT(e,t,o){let r=i=>{let s=i.trim().toLowerCase();return mr.options.find(m=>m===s||Ua[m].toLowerCase()===s)},n=mr.options.map(i=>`${i} (${Ua[i]})`).join(", "),a=r(t);return a?o===void 0?{request:{workspaceId:e,tier:a}}:!/^\d+$/.test(o)||Number(o)>1e4?{problem:`"${o}" is not a live-game allowance.`,detail:["Give a whole number from 0 to 10000, where 0 means no ceiling.","Nothing has been changed."]}:{request:{workspaceId:e,tier:a,allowance:Number(o)}}:r(e)?{problem:"The workspace comes first and the plan second.",detail:[`Try: ${Y(`admin plan ${t} ${e}`)}`,"Nothing has been changed."]}:{problem:`"${t}" is not a plan.`,detail:[`Use one of: ${n}.`,"Nothing has been changed."]}}function Er(e){let t=Ua[e.tier];if(e.liveGameAllowance===void 0)return t;let o=e.liveGameAllowance===0?"no live-game ceiling":`${e.liveGameAllowance} live game${e.liveGameAllowance===1?"":"s"}`;return`${t}, ${o}`}function gT(e){let{request:t,previous:o,result:r,stored:n}=e,a=Er({tier:t.tier,liveGameAllowance:t.allowance}),i={previous:o,stored:n};return r.refused?{...i,status:"refused_by_store",exitCode:0,heading:"Not changed",message:r.refused,next:["Nothing was written."]}:n?n.tier===t.tier&&(t.allowance===void 0||n.liveGameAllowance===t.allowance)?o!==null&&o.tier===n.tier&&o.liveGameAllowance===n.liveGameAllowance?{...i,status:"unchanged",exitCode:0,heading:"No change",message:`${t.workspaceId} was already on ${Er(n)}, and still is.`,next:[Ff]}:{...i,status:"set",exitCode:0,heading:"Plan set",message:`${t.workspaceId} is on ${Er(n)}, read back from the control plane after the write.`,next:[Ff]}:{...i,status:"not_what_was_asked",exitCode:1,heading:"Not what was asked",message:`${t.workspaceId} was sent ${a} and holds ${Er(n)}. The write reported success, and the stored workspace disagrees with it.`,next:["Run it again to see whether the second read agrees. If it still disagrees, that is a control-plane defect to raise, not an operator mistake."]}:{...i,status:"unconfirmed",exitCode:2,heading:"Sent, and not confirmed",message:`The control plane accepted ${t.workspaceId} moving to ${a}, and could not then be asked what it kept: ${e.unreadable??"no reason given"}.`,next:["Treat the plan as unknown rather than set. Run this again once the control plane answers reads; repeating the same plan is safe.",Ff]}}function fT(e){if(I(e.heading),g(` ${e.message}`),g(),A("Before",e.previous?Er(e.previous):"could not be read"),A("Stored now",e.stored?Er(e.stored):"could not be read"),e.next.length){g();for(let t of e.next)w(t)}g()}function ge(e){let t=[],o=e.status,r=e.code;if(r===Uf){let n=oi({access:"pending"});N()?U({ok:n.ok,status:n.status,access:n.access,code:n.code,message:n.message,next:n.next}):Ar(n),process.exit(0)}o===401?t.push("Your session has expired. Run `gamestage login` again."):o===403?t.push("Either your session expired or that is not something this workspace is allowed to do. `gamestage login` rules out the first."):o===429?t.push("You are being rate limited. Wait a moment and try again."):e.retryable&&t.push("This one is worth retrying: the failure was at our end."),r&&t.push(`Code: ${r}`),t.push(`Control plane: ${Te}`),$(e instanceof Error?e.message:"The control plane call failed.",t)}var Te,Uf,Ff,Ge=_(()=>{"use strict";ye();Un();be();_o();Te=process.env.GAMESTAGE_CONTROL_URL??"https://api.gamestage.ai";Uf="access_pending";Ff="This does not re-provision. A live round keeps the caps it was provisioned with, including its day cap, until the game is deployed again, so a creator refused before this is refused the same way until they redeploy with `gamestage deploy`. That is not this change failing."});import{createServer as qP}from"node:http";async function HP(e){let t=[];for await(let o of e)t.push(o);return Buffer.concat(t)}function yT(e){return new pt("unreachable",`Cannot reach the Gamestage Engine at ${e}.`,["This needs a network connection: the Engine that marks your game runs in the cloud, not on this laptop.","Check your connection and run the command again. Nothing about your game is wrong."])}async function Ir(e){let t=Date.now(),o;try{o=await e.client.practiceRound(e.game,e.round)}catch(l){throw l instanceof Ne?l.status===404&&/no such game|no game with id/i.test(l.message)?new pt("unregistered",`${e.game} is not registered to your workspace.`,["`gamestage manifest register` registers this directory's game, then run this again.","`gamestage create` registers a new game as it scaffolds it."]):l.status===401||l.status===403?new pt("refused",l.message,["`gamestage login` signs this machine in again."]):l.status>=500||l.retryable?yT(e.controlUrl):new pt("refused",l.message):yT(e.controlUrl)}let r=Date.now()-t;if(!o.ok)throw new pt("refused",o.refused);let n=o.playerApiOrigin.replace(/\/+$/,""),a=o.engineGame,i=`/play/v1/games/${encodeURIComponent(e.game)}`,s=`/play/v1/games/${a}`;return{server:qP((l,u)=>{(async()=>{let p=new URL(l.url??"/","http://localhost");if(l.method==="OPTIONS"){u.writeHead(204,Cr).end();return}if(e.clientBundle&&l.method==="GET"&&/^\/(client\/[^/]+\/)?gamestage\.js$/.test(p.pathname)){u.writeHead(200,{"content-type":"text/javascript; charset=utf-8","cache-control":"no-store","access-control-allow-origin":"*"}),u.end(e.clientBundle);return}if(!p.pathname.startsWith("/play/")){u.writeHead(404,{"content-type":"application/json",...Cr}),u.end(JSON.stringify({error:{code:"not_found",message:"Only the player API answers here."}}));return}let f=p.pathname;if(f===i||f.startsWith(`${i}/`))f=s+f.slice(i.length);else if(f.startsWith("/play/v1/games/")){let re=decodeURIComponent(f.split("/")[4]??"");u.writeHead(404,{"content-type":"application/json",...Cr}),u.end(JSON.stringify({error:{code:"not_found",message:`This page asked for the game "${re}", and this run serves "${e.game}". Set window.GAMESTAGE_GAME to the id in gamestage.yaml.`,retryable:!1}}));return}let b={};for(let[re,K]of Object.entries(l.headers))K===void 0||WP.has(re)||(b[re]=Array.isArray(K)?K.join(", "):K);b["x-gamestage-test"]="1";let x=l.method==="GET"||l.method==="HEAD"?void 0:await HP(l),P;try{P=await fetch(`${n}${f}${p.search}`,{method:l.method,headers:b,body:x&&x.length?new Uint8Array(x):void 0})}catch{u.writeHead(502,{"content-type":"application/json",...Cr}),u.end(JSON.stringify({error:{code:"engine_unreachable",message:`Cannot reach the Gamestage Engine at ${n}. Check your connection.`,retryable:!0}}));return}let q=Buffer.from(await P.arrayBuffer()),ie={...Cr};for(let re of["content-type","cache-control","retry-after"]){let K=P.headers.get(re);K&&(ie[re]=K)}u.writeHead(P.status,ie),u.end(q)})().catch(()=>{u.headersSent?u.destroy():(u.writeHead(500,{"content-type":"application/json",...Cr}),u.end(JSON.stringify({error:{code:"internal",message:"The local proxy failed.",retryable:!0}})))})}),engineGame:a,roundId:o.roundId,upstream:n,provisionMs:r}}var pt,Cr,WP,Kc=_(()=>{"use strict";ye();pt=class extends Error{constructor(o,r,n=[]){super(r);this.kind=o;this.lines=n;this.name="PracticeEngineError"}kind;lines},Cr={"access-control-allow-origin":"*","access-control-allow-methods":"GET, POST, PUT, DELETE, OPTIONS","access-control-allow-headers":"authorization, content-type, x-gamestage-player, x-gamestage-test","access-control-max-age":"600"},WP=new Set(["host","connection","content-length","transfer-encoding","keep-alive","upgrade","accept-encoding","origin","referer"])});async function ri(e,t){let o=t.referenceName;if(o)try{let{datasets:r}=await e.listDatasets(),n=r.find(s=>s.name===o),a=n?.supplier?mS(n.supplier):void 0,i=a?Qa(a):void 0;return!a||!i?void 0:{dataset:o,source:a.label,caveat:i}}catch{return}}function ai(e){!e||N()||(I("This game's data comes from an unofficial source"),w(`It is scored on ${e.dataset}, from ${e.source}.`),w(e.caveat),g())}var Gf=_(()=>{"use strict";ye();be()});import{readFile as YP}from"node:fs/promises";import{dirname as VP,join as ZP}from"node:path";async function bT(e){let t=ZP(VP(e),KP);try{return(await YP(t,"utf8")).trim()||void 0}catch{return}}function vT(e){!e||N()||(I("This game's copy is AI-drafted"),w(e),g())}var KP,wT=_(()=>{"use strict";be();KP="COPY-STATUS.md"});function kT(e){return{disclaimer:Ng,checks:jg(e).map(t=>({key:t.key,label:t.label,recorded:!!t.record,...t.record?{result:t.record.result,ran_at:t.record.ran_at,tool:t.record.tool}:{},...t.problem?{problem:t.problem}:{},suggestion:t.command}))}}function JP(e){if(e.problem)return`${e.label}: your entry is not counted, because ${e.problem}. Fix it in gamestage.yaml.`;if(!e.record)return`${e.label}: nothing recorded. Run \`${e.command}\`. ${e.about}`;let{result:t,ran_at:o,tool:r}=e.record;return`${e.label}: ${K_[t]}, ${o}, with ${r}.`}function _T(e){if(N())return;let t=jg(e),o=t.filter(r=>!r.record).length;I(o?"Checks worth running":"Checks you recorded"),w(`These do not affect verify or deploy. ${Ng}`);for(let r of[...t.filter(n=>n.record),...t.filter(n=>!n.record)])w(JP(r));o&&w("Record what you ran under `assurance:` in gamestage.yaml, with `tool`, `ran_at` and `result`, so it shows on the game's page in Stage."),g()}var xT=_(()=>{"use strict";ye();be()});import{spawn as XP}from"node:child_process";import{createHash as QP,randomBytes as TT}from"node:crypto";import{constants as eO}from"node:fs";import{access as tO,mkdtemp as nO,rm as ET}from"node:fs/promises";import{request as oO}from"node:http";import{homedir as Jc,tmpdir as rO}from"node:os";import{join as ii}from"node:path";function Bf(e,t={}){let o=Buffer.isBuffer(e)?e:Buffer.from(e),r=t.maskingKey??TT(4);if(r.length!==4)throw new Error("A WebSocket masking key must be four bytes.");let n=o.length<126?0:o.length<=65535?2:8,a=Buffer.alloc(2+n+4+o.length);a[0]=(t.fin===!1?0:128)|(t.opcode??1),a[1]=128|(n===0?o.length:n===2?126:127);let i=2;n===2?(a.writeUInt16BE(o.length,i),i+=2):n===8&&(a.writeBigUInt64BE(BigInt(o.length),i),i+=8),r.copy(a,i),i+=4;for(let s=0;s<o.length;s++)a[i+s]=o[s]^r[s%4];return a}async function Ht(e={}){let o=[(e.env??process.env).GAMESTAGE_CHROME,...e.locations??iO].filter(s=>!!s),r;for(let s of[...new Set(o)])try{await tO(s,eO.X_OK),r=s;break}catch{}if(!r)return{status:"skipped",detail:"No supported browser found. Install Chrome, Chromium, Brave or Edge, or set GAMESTAGE_CHROME to its executable path, then run verify again."};let n=await nO(ii(rO(),"gamestage-chrome-")),a=XP(r,["--headless=new","--remote-debugging-port=0","--no-first-run","--no-default-browser-check",`--user-data-dir=${n}`,"about:blank"],{stdio:["ignore","ignore","pipe"]}),i;try{i=await lO(await cO(a,1e4));let{targetId:s}=await i.send("Target.createTarget",{url:"about:blank"}),{sessionId:m}=await i.send("Target.attachToTarget",{targetId:s,flatten:!0});return{status:"available",browser:await Yf.create(i,m,a,n)}}catch(s){throw i?.close(),await $T(a),await ET(n,{recursive:!0,force:!0}),s}}function cO(e,t){return new Promise((o,r)=>{let n="",a=u=>{clearTimeout(l),e.stderr?.off("data",i),e.off("error",s),e.off("close",m),u()},i=u=>{n=(n+u.toString("utf8")).slice(-4e3);let p=n.match(/DevTools listening on (ws:\/\/\S+)/);p&&a(()=>o(p[1]))},s=u=>a(()=>r(u)),m=u=>a(()=>r(new Error(`Chrome exited before DevTools was ready${u===null?"":` (code ${u})`}.`)));e.stderr?.on("data",i),e.on("error",s),e.on("close",m);let l=setTimeout(()=>a(()=>r(new Error("Chrome did not open DevTools within 10000ms."))),t)})}function lO(e){return new Promise((t,o)=>{let r=new URL(e),n=TT(16).toString("base64"),a=QP("sha1").update(n+aO).digest("base64"),i=oO({hostname:r.hostname,port:r.port,path:`${r.pathname}${r.search}`,headers:{Connection:"Upgrade",Upgrade:"websocket","Sec-WebSocket-Version":"13","Sec-WebSocket-Key":n}});i.on("upgrade",(s,m,l)=>{s.headers["sec-websocket-accept"]!==a?(m.destroy(),o(new Error("Chrome returned an invalid WebSocket handshake."))):t(new Hf(m,l))}),i.on("response",s=>{s.resume(),o(new Error(`Chrome refused the WebSocket upgrade with status ${s.statusCode}.`))}),i.on("error",o),i.end()})}async function $T(e){e.exitCode===null&&(e.kill("SIGTERM"),!await ST(e,1e3)&&(e.kill("SIGKILL"),await ST(e,1e3)))}function ST(e,t){return e.exitCode!==null?Promise.resolve(!0):new Promise(o=>{let r=i=>{clearTimeout(a),e.off("close",n),o(i)},n=()=>r(!0);e.once("close",n);let a=setTimeout(()=>r(!1),t)})}function qf(e){return new Promise(t=>setTimeout(t,e))}var aO,Wf,Hf,Yf,iO,sO,Xc=_(()=>{"use strict";aO="258EAFA5-E914-47DA-95CA-C5AB0DC85B11";Wf=class{buffered=Buffer.alloc(0);fragments=[];fragmentedOpcode;push(t){this.buffered=this.buffered.length?Buffer.concat([this.buffered,t]):Buffer.from(t);let o=[];for(;this.buffered.length>=2;){let r=this.buffered[0],n=this.buffered[1],a=(r&128)!==0,i=r&15,s=(n&128)!==0,m=n&127,l=2;if(m===126){if(this.buffered.length<l+2)break;m=this.buffered.readUInt16BE(l),l+=2}else if(m===127){if(this.buffered.length<l+8)break;let f=this.buffered.readBigUInt64BE(l);if(f>BigInt(Number.MAX_SAFE_INTEGER))throw new Error("WebSocket frame is too large to decode safely.");m=Number(f),l+=8}let u=l;if(s&&(l+=4),this.buffered.length<l+m)break;let p=Buffer.from(this.buffered.subarray(l,l+m));if(s)for(let f=0;f<p.length;f++)p[f]^=this.buffered[u+f%4];if(this.buffered=this.buffered.subarray(l+m),i===8||i===9||i===10)o.push({opcode:i,payload:p});else if(i===1){if(this.fragmentedOpcode!==void 0)throw new Error("A new WebSocket message arrived before its continuation finished.");a?o.push({opcode:i,payload:p}):(this.fragmentedOpcode=i,this.fragments=[p])}else if(i===0){if(this.fragmentedOpcode===void 0)throw new Error("A WebSocket continuation arrived without a first frame.");this.fragments.push(p),a&&(o.push({opcode:this.fragmentedOpcode,payload:Buffer.concat(this.fragments)}),this.fragmentedOpcode=void 0,this.fragments=[])}else throw new Error(`Unsupported WebSocket opcode ${i}.`)}return o}},Hf=class{constructor(t,o){this.socket=t;t.on("data",r=>this.receive(r)),t.on("error",r=>this.fail(r)),t.on("close",()=>this.fail(new Error("Chrome closed the DevTools connection."))),o.length&&this.receive(o)}socket;decoder=new Wf;pending=new Map;listeners=new Map;nextId=1;ended=!1;send(t,o={},r,n=sO){if(this.ended)return Promise.reject(new Error("Chrome's DevTools connection is closed."));let a=this.nextId++;return new Promise((i,s)=>{let m=setTimeout(()=>{if(!this.pending.delete(a))return;let l=JSON.stringify(o).replace(/\s+/g," ").slice(0,300),u=`Chrome did not answer ${t} within ${Math.round(n/1e3)}s. It was asked: ${l}`;process.stderr.write(`gamestage: ${u}
|
|
14127
|
+
`).some(m=>!OP(m)&&i.test(m))){o.push({setting:r,file:s.relative});break}}return o}function Hc(e){return`The page keeps its own copy of ${e.map(t=>`${t.setting} (in ${t.file})`).join(", ")}. Studio is the only home of these: delete the value from the page and render what game.presentation gives you. The client remembers the last settings on the fan's device and draws its own retry screen if Studio cannot be reached.`}var un,CP,IP,PP,ko=_(()=>{"use strict";ye();un="gamestage.settings.json";CP=new Set(["title_font","title_font_weight","title_case"]),IP=/(^|\/)components\/gamestage\//,PP=/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i});function XS(e,t,o,r=""){let n=new Set([...Va(),...Za(r)]),a={},i=(s,m)=>{m&&n.has(s)&&(a[s]=m)};i("display_name",t.trim());for(let[s,m]of Object.entries(e))i(s,m);if(o&&i("how_to_play",NP[o]),i("splash_play_label",dn.play),i("splash_continue_label",dn.continue),i("splash_error_text",dn.error),i("splash_retry_label",dn.retry),/\bmountRecovery\s*\(/.test(r))for(let[s,m]of Object.entries(jS))i(s,NS[m]);return a}function QS(e){return new Set([...e.matchAll(/var\(\s*--gs-([A-Za-z]+)\s*[,)]/g)].map(t=>t[1]))}var NP,Rf=_(()=>{"use strict";ye();NP={hunt:"Find the right ones on the board. A wrong pick costs a try.",push:"Pick one from each line. Get as close to the limit as you dare without going over.",group:"Sort the board into its groups. A wrong group costs a life.",predict:"Call what will happen before it does. You score when you are right.",bingo:"Lock your board, then mark each square as it happens. A full line scores.",shoot:"Pick a spot and a power, then shoot. The keeper decides the rest."}});import{spawn as aT}from"node:child_process";import{chmod as eT,mkdir as tT,readFile as nT,rm as oT,writeFile as rT}from"node:fs/promises";import{homedir as jP,platform as xr}from"node:os";import{dirname as LP,join as iT}from"node:path";async function sT(){let e=await fetch(`${Nf}/user_management/authorize/device`,{method:"POST",headers:{"content-type":"application/x-www-form-urlencoded"},body:new URLSearchParams({client_id:jf})});if(!e.ok)throw new Error(`Could not start sign-in (${e.status}). ${await e.text()}`);return await e.json()}async function cT(e){let t=await fetch(`${Nf}/user_management/authenticate`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({client_id:jf,grant_type:"urn:ietf:params:oauth:grant-type:device_code",device_code:e})}),o=await t.json();if(t.ok){let r=o.user;return{status:"ok",session:{accessToken:String(o.access_token??""),refreshToken:o.refresh_token?String(o.refresh_token):void 0,email:r?.email,userId:r?.id}}}switch(o.error){case"authorization_pending":return{status:"pending"};case"slow_down":return{status:"slow_down"};case"expired_token":return{status:"expired"};default:return{status:"denied",reason:String(o.error_description??o.error??"unknown error")}}}function lT(e){let t=xr()==="darwin"?"open":xr()==="win32"?"cmd":"xdg-open",o=xr()==="win32"?["/c","start","",e]:[e];try{aT(t,o,{stdio:"ignore",detached:!0}).unref()}catch{}}function Lf(){let e=process.env.GAMESTAGE_CREDENTIALS?.trim();return e||void 0}function Df(e,t){return new Promise(o=>{let r=aT("security",e,{stdio:["pipe","pipe","ignore"]}),n="";r.stdout.on("data",a=>n+=a),r.on("error",()=>o(null)),r.on("close",a=>o(a===0?n.trim():null)),t!==void 0?r.stdin.end(t):r.stdin.end()})}async function Mf(e){let t=JSON.stringify(e),o=Lf();return o?(await tT(LP(o),{recursive:!0,mode:448}),await rT(o,t,{mode:384}),await eT(o,384),"file"):xr()==="darwin"&&await Df(["add-generic-password","-a",Sr,"-s",Sr,"-U","-w",t])!==null?"keychain":(await tT(dT,{recursive:!0,mode:448}),await rT(Yc,t,{mode:384}),await eT(Yc,384),"file")}function DP(e){try{let[,t]=e.split("."),{exp:o}=JSON.parse(Buffer.from(t,"base64url").toString());return typeof o!="number"?!0:o*1e3-Date.now()<3e4}catch{return!0}}async function MP(e){if(!e.refreshToken)return null;let t=await fetch(`${Nf}/user_management/authenticate`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({client_id:jf,grant_type:"refresh_token",refresh_token:e.refreshToken})});if(!t.ok)return null;let o=await t.json();return o.access_token?{...e,accessToken:String(o.access_token),refreshToken:o.refresh_token?String(o.refresh_token):e.refreshToken}:null}async function FP(){let e=Lf();if(e)try{return JSON.parse(await nT(e,"utf8"))}catch{return null}if(xr()==="darwin"){let t=await Df(["find-generic-password","-a",Sr,"-s",Sr,"-w"]);if(t)try{return JSON.parse(t)}catch{}}try{return JSON.parse(await nT(Yc,"utf8"))}catch{return null}}async function mT(){let e=Lf();if(e){await oT(e,{force:!0});return}xr()==="darwin"&&await Df(["delete-generic-password","-a",Sr,"-s",Sr]),await oT(Yc,{force:!0})}async function Pe(){let e=await FP();if(!e)return null;if(!DP(e.accessToken)||!e.refreshToken)return e;let t=await MP(e);return t?(await Mf(t),t):null}var Nf,jf,Sr,dT,Yc,Un=_(()=>{"use strict";Nf="https://api.workos.com",jf=process.env.GAMESTAGE_CLIENT_ID??"client_01KYVPJ1MA6GA9EXTJ7GJ81YW4";Sr="gamestage-cli",dT=iT(jP(),".gamestage"),Yc=iT(dT,"credentials.json")});function Tr(e){return`${Le}/stage/games/${encodeURIComponent(e)}?tab=overview`}function uT(e){return e&&new Set(["hunt","push","group","predict"]).has(e)?`${Le}/docs/game-formats#${e}`:`${Le}/docs`}var Le,_o=_(()=>{"use strict";Le=process.env.GAMESTAGE_SITE_URL??"https://gamestage.ai"});function UP(e){try{let t=new URL(e).hostname.toLowerCase();return t==="localhost"||t.endsWith(".localhost")||t==="::1"||t.startsWith("127.")}catch{return!1}}function GP(e){return e.GAMESTAGE_TEST_RUN==="1"||e.NODE_TEST_CONTEXT!==void 0}function BP(e=Te,t=process.env){if(GP(t)&&!UP(e)&&t.GAMESTAGE_ALLOW_REMOTE_TESTS!=="1")return`Refusing to register a test game against non-local control plane ${e}. Use the throwaway local control plane, or set GAMESTAGE_ALLOW_REMOTE_TESTS=1 for a deliberate real-plane run.`}function $r(e=Te){let t=BP(e);t&&$(t)}async function Vc(){let e=await Pe();return e||$("You are not signed in.",["Run `gamestage login`. It creates the account too if you do not have one.","Inspecting, scaffolding and validating a manifest still need no account."]),e}async function le(){let e=await Vc();return{client:bo({baseUrl:Te,token:async()=>(await Pe())?.accessToken??e.accessToken}),email:e.email??e.userId??"unknown"}}async function ni(){let e=await Pe().catch(()=>null);if(e)return bo({baseUrl:Te,token:async()=>(await Pe())?.accessToken??e.accessToken})}async function Gn(){let e=await Pe();return e||$("You are not signed in.",["Run `gamestage login`. An operator's command needs an operator's own session."]),{admin:tS({baseUrl:Te,token:async()=>(await Pe())?.accessToken??e.accessToken}),email:e.email??e.userId??"unknown"}}async function Zc(e){try{let t=await e.getWorkspace(),o=t?.access;return o==="approved"||o==="pending"||o==="refused"?{access:o,workspace:t}:{access:"unreported",workspace:t}}catch(t){let o=t.status,r=t.code;return r===Uf?{access:"pending"}:o===404||r==="not_found"?{access:"unknown",problem:"no_control_plane",reason:`Nothing is serving a control plane at ${Te}.`,detail:["You are signed in, and deploying will fail until this is pointed somewhere real.","Set GAMESTAGE_CONTROL_URL to your control plane and run this again."]}:o===401||o===403?{access:"unknown",problem:"token_refused",reason:"The control plane refused this account's token.",detail:[`It is at ${Te}.`,"A token from one environment is refused by another, so check which one you signed into."]}:{access:"unknown",problem:"unreachable",reason:`Could not reach the control plane at ${Te}.`,detail:[String(t.message??t),"You are signed in. Deploying will fail until this answers."]}}}function oi(e){switch(e.access){case"approved":return{ok:!0,status:"approved",access:"approved",heading:"Approved",message:"Your account is approved, so every command works, including deploy.",next:["`gamestage status` shows the workspace, its games and what they are using."]};case"pending":return{ok:!0,status:"pending_approval",access:"pending",code:Uf,heading:"Registered, waiting for approval",message:"You are registered and your account is waiting for approval. That is the normal path for a new account, and approval is a person's decision today.",next:["Nothing is wrong and nothing is lost. There is no second form to fill in.","Inspecting a prototype, scaffolding a game and writing a round all work now and need no approval.","`gamestage status` re-checks approval. It never opens the browser again."]};case"refused":return{ok:!0,status:"access_refused",access:"refused",heading:"Access refused",message:"This account has been refused access. Signing in worked, so this is a decision about the account rather than a broken token.",next:["Nothing in the CLI changes this, and running `gamestage login` again will not.","Inspecting, scaffolding and writing a round still work and need no account.",`If you think this is wrong, say so where you registered: ${Le}.`]};case"unreported":return{ok:!0,status:"access_not_reported",access:null,heading:"Signed in",message:"This control plane answered and does not report an access state, so whether this account is approved is not known here.",next:["It predates the access state rather than being broken, so carry on.","A deploy that is refused for approval will say so in its own words."]};default:return{ok:!1,status:e.problem==="no_control_plane"?"no_control_plane":e.problem==="token_refused"?"token_refused":"control_plane_unreachable",access:null,heading:"Signed in, and the control plane is not usable",message:e.reason,next:e.detail}}}function pT(e){return!e.changed&&e.refused?{ok:!0,status:"refused_by_store",access:e.access,code:e.code,heading:"Not approved",message:e.refused,next:["Nothing was written. When they have accepted the terms, run this again."]}:e.changed?e.access==="approved"?{ok:!0,status:"approved",access:"approved",heading:"Approved",message:`${e.workspaceId} was ${e.previous} and is now approved.`,next:["Their next `gamestage status` says approved, and deploy works from then on."]}:{ok:!0,status:"refused",access:"refused",heading:"Refused",message:`${e.workspaceId} was ${e.previous} and is now refused.`,next:["Their next `gamestage status` says refused, and says how to argue with it."]}:{ok:!0,status:"unchanged",access:e.access,heading:"No change",message:`${e.workspaceId} was already ${e.previous}. Nothing was written.`,next:["No audit record either: the trail records transitions, and this was not one."]}}function Ar(e){if(I(e.heading),g(` ${e.message}`),e.next.length){g();for(let t of e.next)w(t)}g()}function hT(e,t,o){let r=i=>{let s=i.trim().toLowerCase();return mr.options.find(m=>m===s||Ua[m].toLowerCase()===s)},n=mr.options.map(i=>`${i} (${Ua[i]})`).join(", "),a=r(t);return a?o===void 0?{request:{workspaceId:e,tier:a}}:!/^\d+$/.test(o)||Number(o)>1e4?{problem:`"${o}" is not a live-game allowance.`,detail:["Give a whole number from 0 to 10000, where 0 means no ceiling.","Nothing has been changed."]}:{request:{workspaceId:e,tier:a,allowance:Number(o)}}:r(e)?{problem:"The workspace comes first and the plan second.",detail:[`Try: ${Y(`admin plan ${t} ${e}`)}`,"Nothing has been changed."]}:{problem:`"${t}" is not a plan.`,detail:[`Use one of: ${n}.`,"Nothing has been changed."]}}function Er(e){let t=Ua[e.tier];if(e.liveGameAllowance===void 0)return t;let o=e.liveGameAllowance===0?"no live-game ceiling":`${e.liveGameAllowance} live game${e.liveGameAllowance===1?"":"s"}`;return`${t}, ${o}`}function gT(e){let{request:t,previous:o,result:r,stored:n}=e,a=Er({tier:t.tier,liveGameAllowance:t.allowance}),i={previous:o,stored:n};return r.refused?{...i,status:"refused_by_store",exitCode:0,heading:"Not changed",message:r.refused,next:["Nothing was written."]}:n?n.tier===t.tier&&(t.allowance===void 0||n.liveGameAllowance===t.allowance)?o!==null&&o.tier===n.tier&&o.liveGameAllowance===n.liveGameAllowance?{...i,status:"unchanged",exitCode:0,heading:"No change",message:`${t.workspaceId} was already on ${Er(n)}, and still is.`,next:[Ff]}:{...i,status:"set",exitCode:0,heading:"Plan set",message:`${t.workspaceId} is on ${Er(n)}, read back from the control plane after the write.`,next:[Ff]}:{...i,status:"not_what_was_asked",exitCode:1,heading:"Not what was asked",message:`${t.workspaceId} was sent ${a} and holds ${Er(n)}. The write reported success, and the stored workspace disagrees with it.`,next:["Run it again to see whether the second read agrees. If it still disagrees, that is a control-plane defect to raise, not an operator mistake."]}:{...i,status:"unconfirmed",exitCode:2,heading:"Sent, and not confirmed",message:`The control plane accepted ${t.workspaceId} moving to ${a}, and could not then be asked what it kept: ${e.unreadable??"no reason given"}.`,next:["Treat the plan as unknown rather than set. Run this again once the control plane answers reads; repeating the same plan is safe.",Ff]}}function fT(e){if(I(e.heading),g(` ${e.message}`),g(),A("Before",e.previous?Er(e.previous):"could not be read"),A("Stored now",e.stored?Er(e.stored):"could not be read"),e.next.length){g();for(let t of e.next)w(t)}g()}function ge(e){let t=[],o=e.status,r=e.code;if(r===Uf){let n=oi({access:"pending"});N()?U({ok:n.ok,status:n.status,access:n.access,code:n.code,message:n.message,next:n.next}):Ar(n),process.exit(0)}o===401?t.push("Your session has expired. Run `gamestage login` again."):o===403?t.push("Either your session expired or that is not something this workspace is allowed to do. `gamestage login` rules out the first."):o===429?t.push("You are being rate limited. Wait a moment and try again."):e.retryable&&t.push("This one is worth retrying: the failure was at our end."),r&&t.push(`Code: ${r}`),t.push(`Control plane: ${Te}`),$(e instanceof Error?e.message:"The control plane call failed.",t)}var Te,Uf,Ff,Ge=_(()=>{"use strict";ye();Un();be();_o();Te=process.env.GAMESTAGE_CONTROL_URL??"https://api.gamestage.ai";Uf="access_pending";Ff="This does not re-provision. A live round keeps the caps it was provisioned with, including its day cap, until the game is deployed again, so a creator refused before this is refused the same way until they redeploy with `gamestage deploy`. That is not this change failing."});import{createServer as qP}from"node:http";async function HP(e){let t=[];for await(let o of e)t.push(o);return Buffer.concat(t)}function yT(e){return new pt("unreachable",`Cannot reach the Gamestage Engine at ${e}.`,["This needs a network connection: the Engine that marks your game runs in the cloud, not on this laptop.","Check your connection and run the command again. Nothing about your game is wrong."])}async function Ir(e){let t=Date.now(),o;try{o=await e.client.practiceRound(e.game,e.round)}catch(l){throw l instanceof Ne?l.status===404&&/no such game|no game with id/i.test(l.message)?new pt("unregistered",`${e.game} is not registered to your workspace.`,["`gamestage manifest register` registers this directory's game, then run this again.","`gamestage create` registers a new game as it scaffolds it."]):l.status===401||l.status===403?new pt("refused",l.message,["`gamestage login` signs this machine in again."]):l.status>=500||l.retryable?yT(e.controlUrl):new pt("refused",l.message):yT(e.controlUrl)}let r=Date.now()-t;if(!o.ok)throw new pt("refused",o.refused);let n=o.playerApiOrigin.replace(/\/+$/,""),a=o.engineGame,i=`/play/v1/games/${encodeURIComponent(e.game)}`,s=`/play/v1/games/${a}`;return{server:qP((l,u)=>{(async()=>{let p=new URL(l.url??"/","http://localhost");if(l.method==="OPTIONS"){u.writeHead(204,Cr).end();return}if(e.clientBundle&&l.method==="GET"&&/^\/(client\/[^/]+\/)?gamestage\.js$/.test(p.pathname)){u.writeHead(200,{"content-type":"text/javascript; charset=utf-8","cache-control":"no-store","access-control-allow-origin":"*"}),u.end(e.clientBundle);return}if(!p.pathname.startsWith("/play/")){u.writeHead(404,{"content-type":"application/json",...Cr}),u.end(JSON.stringify({error:{code:"not_found",message:"Only the player API answers here."}}));return}let f=p.pathname;if(f===i||f.startsWith(`${i}/`))f=s+f.slice(i.length);else if(f.startsWith("/play/v1/games/")){let re=decodeURIComponent(f.split("/")[4]??"");u.writeHead(404,{"content-type":"application/json",...Cr}),u.end(JSON.stringify({error:{code:"not_found",message:`This page asked for the game "${re}", and this run serves "${e.game}". Set window.GAMESTAGE_GAME to the id in gamestage.yaml.`,retryable:!1}}));return}let b={};for(let[re,K]of Object.entries(l.headers))K===void 0||WP.has(re)||(b[re]=Array.isArray(K)?K.join(", "):K);b["x-gamestage-test"]="1";let x=l.method==="GET"||l.method==="HEAD"?void 0:await HP(l),P;try{P=await fetch(`${n}${f}${p.search}`,{method:l.method,headers:b,body:x&&x.length?new Uint8Array(x):void 0})}catch{u.writeHead(502,{"content-type":"application/json",...Cr}),u.end(JSON.stringify({error:{code:"engine_unreachable",message:`Cannot reach the Gamestage Engine at ${n}. Check your connection.`,retryable:!0}}));return}let q=Buffer.from(await P.arrayBuffer()),ie={...Cr};for(let re of["content-type","cache-control","retry-after"]){let K=P.headers.get(re);K&&(ie[re]=K)}u.writeHead(P.status,ie),u.end(q)})().catch(()=>{u.headersSent?u.destroy():(u.writeHead(500,{"content-type":"application/json",...Cr}),u.end(JSON.stringify({error:{code:"internal",message:"The local proxy failed.",retryable:!0}})))})}),engineGame:a,roundId:o.roundId,upstream:n,provisionMs:r}}var pt,Cr,WP,Kc=_(()=>{"use strict";ye();pt=class extends Error{constructor(o,r,n=[]){super(r);this.kind=o;this.lines=n;this.name="PracticeEngineError"}kind;lines},Cr={"access-control-allow-origin":"*","access-control-allow-methods":"GET, POST, PUT, DELETE, OPTIONS","access-control-allow-headers":"authorization, content-type, x-gamestage-player, x-gamestage-test","access-control-max-age":"600"},WP=new Set(["host","connection","content-length","transfer-encoding","keep-alive","upgrade","accept-encoding","origin","referer"])});async function ri(e,t){let o=t.referenceName;if(o)try{let{datasets:r}=await e.listDatasets(),n=r.find(s=>s.name===o),a=n?.supplier?mS(n.supplier):void 0,i=a?Qa(a):void 0;return!a||!i?void 0:{dataset:o,source:a.label,caveat:i}}catch{return}}function ai(e){!e||N()||(I("This game's data comes from an unofficial source"),w(`It is scored on ${e.dataset}, from ${e.source}.`),w(e.caveat),g())}var Gf=_(()=>{"use strict";ye();be()});import{readFile as YP}from"node:fs/promises";import{dirname as VP,join as ZP}from"node:path";async function bT(e){let t=ZP(VP(e),KP);try{return(await YP(t,"utf8")).trim()||void 0}catch{return}}function vT(e){!e||N()||(I("This game's copy is AI-drafted"),w(e),g())}var KP,wT=_(()=>{"use strict";be();KP="COPY-STATUS.md"});function kT(e){return{disclaimer:Ng,checks:jg(e).map(t=>({key:t.key,label:t.label,recorded:!!t.record,...t.record?{result:t.record.result,ran_at:t.record.ran_at,tool:t.record.tool}:{},...t.problem?{problem:t.problem}:{},suggestion:t.command}))}}function JP(e){if(e.problem)return`${e.label}: your entry is not counted, because ${e.problem}. Fix it in gamestage.yaml.`;if(!e.record)return`${e.label}: nothing recorded. Run \`${e.command}\`. ${e.about}`;let{result:t,ran_at:o,tool:r}=e.record;return`${e.label}: ${K_[t]}, ${o}, with ${r}.`}function _T(e){if(N())return;let t=jg(e),o=t.filter(r=>!r.record).length;I(o?"Checks worth running":"Checks you recorded"),w(`These do not affect verify or deploy. ${Ng}`);for(let r of[...t.filter(n=>n.record),...t.filter(n=>!n.record)])w(JP(r));o&&w("Record what you ran under `assurance:` in gamestage.yaml, with `tool`, `ran_at` and `result`, so it shows on the game's page in Stage."),g()}var xT=_(()=>{"use strict";ye();be()});import{spawn as XP}from"node:child_process";import{createHash as QP,randomBytes as TT}from"node:crypto";import{constants as eO}from"node:fs";import{access as tO,mkdtemp as nO,rm as ET}from"node:fs/promises";import{request as oO}from"node:http";import{homedir as Jc,tmpdir as rO}from"node:os";import{join as ii}from"node:path";function Bf(e,t={}){let o=Buffer.isBuffer(e)?e:Buffer.from(e),r=t.maskingKey??TT(4);if(r.length!==4)throw new Error("A WebSocket masking key must be four bytes.");let n=o.length<126?0:o.length<=65535?2:8,a=Buffer.alloc(2+n+4+o.length);a[0]=(t.fin===!1?0:128)|(t.opcode??1),a[1]=128|(n===0?o.length:n===2?126:127);let i=2;n===2?(a.writeUInt16BE(o.length,i),i+=2):n===8&&(a.writeBigUInt64BE(BigInt(o.length),i),i+=8),r.copy(a,i),i+=4;for(let s=0;s<o.length;s++)a[i+s]=o[s]^r[s%4];return a}async function Ht(e={}){let o=[(e.env??process.env).GAMESTAGE_CHROME,...e.locations??iO].filter(m=>!!m),r;for(let m of[...new Set(o)])try{await tO(m,eO.X_OK),r=m;break}catch{}if(!r)return{status:"skipped",detail:"No supported browser found. Install Chrome, Chromium, Brave or Edge, or set GAMESTAGE_CHROME to its executable path, then run verify again."};let n=await nO(ii(rO(),"gamestage-chrome-")),a=XP(r,["--headless=new","--remote-debugging-port=0","--no-first-run","--no-default-browser-check","--use-mock-keychain","--password-store=basic",`--user-data-dir=${n}`,"about:blank"],{stdio:["ignore","ignore","pipe"]}),i=()=>{a.exitCode===null&&a.kill("SIGKILL")};process.once("exit",i),a.once("close",()=>process.off("exit",i));let s;try{s=await lO(await cO(a,1e4));let{targetId:m}=await s.send("Target.createTarget",{url:"about:blank"}),{sessionId:l}=await s.send("Target.attachToTarget",{targetId:m,flatten:!0});return{status:"available",browser:await Yf.create(s,l,a,n)}}catch(m){throw s?.close(),await $T(a),await ET(n,{recursive:!0,force:!0}),m}}function cO(e,t){return new Promise((o,r)=>{let n="",a=u=>{clearTimeout(l),e.stderr?.off("data",i),e.off("error",s),e.off("close",m),u()},i=u=>{n=(n+u.toString("utf8")).slice(-4e3);let p=n.match(/DevTools listening on (ws:\/\/\S+)/);p&&a(()=>o(p[1]))},s=u=>a(()=>r(u)),m=u=>a(()=>r(new Error(`Chrome exited before DevTools was ready${u===null?"":` (code ${u})`}.`)));e.stderr?.on("data",i),e.on("error",s),e.on("close",m);let l=setTimeout(()=>a(()=>r(new Error("Chrome did not open DevTools within 10000ms."))),t)})}function lO(e){return new Promise((t,o)=>{let r=new URL(e),n=TT(16).toString("base64"),a=QP("sha1").update(n+aO).digest("base64"),i=oO({hostname:r.hostname,port:r.port,path:`${r.pathname}${r.search}`,headers:{Connection:"Upgrade",Upgrade:"websocket","Sec-WebSocket-Version":"13","Sec-WebSocket-Key":n}});i.on("upgrade",(s,m,l)=>{s.headers["sec-websocket-accept"]!==a?(m.destroy(),o(new Error("Chrome returned an invalid WebSocket handshake."))):t(new Hf(m,l))}),i.on("response",s=>{s.resume(),o(new Error(`Chrome refused the WebSocket upgrade with status ${s.statusCode}.`))}),i.on("error",o),i.end()})}async function $T(e){e.exitCode===null&&(e.kill("SIGTERM"),!await ST(e,1e3)&&(e.kill("SIGKILL"),await ST(e,1e3)))}function ST(e,t){return e.exitCode!==null?Promise.resolve(!0):new Promise(o=>{let r=i=>{clearTimeout(a),e.off("close",n),o(i)},n=()=>r(!0);e.once("close",n);let a=setTimeout(()=>r(!1),t)})}function qf(e){return new Promise(t=>setTimeout(t,e))}var aO,Wf,Hf,Yf,iO,sO,Xc=_(()=>{"use strict";aO="258EAFA5-E914-47DA-95CA-C5AB0DC85B11";Wf=class{buffered=Buffer.alloc(0);fragments=[];fragmentedOpcode;push(t){this.buffered=this.buffered.length?Buffer.concat([this.buffered,t]):Buffer.from(t);let o=[];for(;this.buffered.length>=2;){let r=this.buffered[0],n=this.buffered[1],a=(r&128)!==0,i=r&15,s=(n&128)!==0,m=n&127,l=2;if(m===126){if(this.buffered.length<l+2)break;m=this.buffered.readUInt16BE(l),l+=2}else if(m===127){if(this.buffered.length<l+8)break;let f=this.buffered.readBigUInt64BE(l);if(f>BigInt(Number.MAX_SAFE_INTEGER))throw new Error("WebSocket frame is too large to decode safely.");m=Number(f),l+=8}let u=l;if(s&&(l+=4),this.buffered.length<l+m)break;let p=Buffer.from(this.buffered.subarray(l,l+m));if(s)for(let f=0;f<p.length;f++)p[f]^=this.buffered[u+f%4];if(this.buffered=this.buffered.subarray(l+m),i===8||i===9||i===10)o.push({opcode:i,payload:p});else if(i===1){if(this.fragmentedOpcode!==void 0)throw new Error("A new WebSocket message arrived before its continuation finished.");a?o.push({opcode:i,payload:p}):(this.fragmentedOpcode=i,this.fragments=[p])}else if(i===0){if(this.fragmentedOpcode===void 0)throw new Error("A WebSocket continuation arrived without a first frame.");this.fragments.push(p),a&&(o.push({opcode:this.fragmentedOpcode,payload:Buffer.concat(this.fragments)}),this.fragmentedOpcode=void 0,this.fragments=[])}else throw new Error(`Unsupported WebSocket opcode ${i}.`)}return o}},Hf=class{constructor(t,o){this.socket=t;t.on("data",r=>this.receive(r)),t.on("error",r=>this.fail(r)),t.on("close",()=>this.fail(new Error("Chrome closed the DevTools connection."))),o.length&&this.receive(o)}socket;decoder=new Wf;pending=new Map;listeners=new Map;nextId=1;ended=!1;send(t,o={},r,n=sO){if(this.ended)return Promise.reject(new Error("Chrome's DevTools connection is closed."));let a=this.nextId++;return new Promise((i,s)=>{let m=setTimeout(()=>{if(!this.pending.delete(a))return;let l=JSON.stringify(o).replace(/\s+/g," ").slice(0,300),u=`Chrome did not answer ${t} within ${Math.round(n/1e3)}s. It was asked: ${l}`;process.stderr.write(`gamestage: ${u}
|
|
14128
14128
|
`),s(new Error(u))},n);m.unref?.(),this.pending.set(a,{resolve:l=>{clearTimeout(m),i(l)},reject:l=>{clearTimeout(m),s(l)}}),this.socket.write(Bf(JSON.stringify({id:a,method:t,params:o,...r?{sessionId:r}:{}})),l=>{l&&(clearTimeout(m),this.pending.delete(a),s(l))})})}on(t,o,r){let n=`${r??""}:${t}`,a=this.listeners.get(n)??new Set;return a.add(o),this.listeners.set(n,a),()=>a.delete(o)}close(){this.ended||(this.ended=!0,this.socket.end(Bf(Buffer.alloc(0),{opcode:8})),this.rejectPending(new Error("Chrome's DevTools connection was closed.")))}receive(t){try{for(let o of this.decoder.push(t)){if(o.opcode===8){this.ended=!0,this.socket.end(),this.rejectPending(new Error("Chrome closed the DevTools connection."));continue}if(o.opcode===9){this.socket.write(Bf(o.payload,{opcode:10}));continue}if(o.opcode===10)continue;let r=JSON.parse(o.payload.toString("utf8"));if(r.id!==void 0){let n=this.pending.get(r.id);if(!n)continue;this.pending.delete(r.id),r.error?n.reject(new Error(r.error.message??"Chrome rejected a CDP command.")):n.resolve(r.result)}else if(r.method){let n=`${r.sessionId??""}:${r.method}`;for(let a of this.listeners.get(n)??[])a(r.params??{})}}}catch(o){this.fail(o instanceof Error?o:new Error("Could not read Chrome's response."))}}fail(t){this.ended||(this.ended=!0,this.socket.destroy(),this.rejectPending(t))}rejectPending(t){for(let o of this.pending.values())o.reject(t);this.pending.clear()}},Yf=class e{constructor(t,o,r,n){this.cdp=t;this.sessionId=o;this.child=r;this.profile=n;this.on("Runtime.exceptionThrown",i=>{let s=i.exceptionDetails,m=s?.exception?.description??s?.text??"Unknown page error";this.pageErrors.push(m.split(`
|
|
14129
|
-
`)[0].replace(/^[A-Za-z]*Error:\s*/,""))}),this.on("Network.requestWillBeSent",i=>{let s=String(i.requestId);this.requests.set(s,i.request??{}),this.inflight.add(s),this.lastNetworkActivity=Date.now()}),this.on("Network.responseReceived",i=>{let s=i.response;this.sizes.set(String(i.requestId),{url:s?.url??"",type:String(i.type??"Other"),bytes:0})});let a=i=>{this.inflight.delete(String(i.requestId)),this.lastNetworkActivity=Date.now()};this.on("Network.loadingFinished",i=>{let s=this.sizes.get(String(i.requestId));s&&(s.bytes=Number(i.encodedDataLength??0)),a(i)}),this.on("Network.loadingFailed",a)}cdp;sessionId;child;profile;pageErrors=[];requests=new Map;sizes=new Map;inflight=new Set;lastNetworkActivity=Date.now();closed=!1;static async create(t,o,r,n){let a=new e(t,o,r,n);return await Promise.all([a.send("Page.enable"),a.send("Runtime.enable"),a.send("Network.enable")]),a}async addScriptToEvaluateOnNewDocument(t){await this.send("Page.addScriptToEvaluateOnNewDocument",{source:t})}async navigate(t,o=2e4){this.sizes.clear();let r=Date.now()+o,n=this.waitForEvent("Page.loadEventFired",o,"page load")
|
|
14129
|
+
`)[0].replace(/^[A-Za-z]*Error:\s*/,""))}),this.on("Network.requestWillBeSent",i=>{let s=String(i.requestId);this.requests.set(s,i.request??{}),this.inflight.add(s),this.lastNetworkActivity=Date.now()}),this.on("Network.responseReceived",i=>{let s=i.response;this.sizes.set(String(i.requestId),{url:s?.url??"",type:String(i.type??"Other"),bytes:0})});let a=i=>{this.inflight.delete(String(i.requestId)),this.lastNetworkActivity=Date.now()};this.on("Network.loadingFinished",i=>{let s=this.sizes.get(String(i.requestId));s&&(s.bytes=Number(i.encodedDataLength??0)),a(i)}),this.on("Network.loadingFailed",a)}cdp;sessionId;child;profile;pageErrors=[];requests=new Map;sizes=new Map;inflight=new Set;lastNetworkActivity=Date.now();closed=!1;static async create(t,o,r,n){let a=new e(t,o,r,n);return await Promise.all([a.send("Page.enable"),a.send("Runtime.enable"),a.send("Network.enable")]),a}async addScriptToEvaluateOnNewDocument(t){await this.send("Page.addScriptToEvaluateOnNewDocument",{source:t})}async navigate(t,o=2e4){this.sizes.clear();let r=Date.now()+o,n=this.waitForEvent("Page.loadEventFired",o,"page load");n.catch(()=>{});let a=await this.send("Page.navigate",{url:t});if(a.errorText)throw new Error(a.errorText);await n,await this.waitForNetworkIdle(Math.max(1,r-Date.now()))}query(t){return this.evaluate(`Array.from(document.querySelectorAll(${JSON.stringify(t)}), (_, index) => index)`)}isVisible(t,o){return this.evaluate(`(() => {
|
|
14130
14130
|
const element = document.querySelectorAll(${JSON.stringify(t)})[${o}];
|
|
14131
14131
|
if (!element) return false;
|
|
14132
14132
|
const style = getComputedStyle(element);
|
|
@@ -14271,7 +14271,7 @@ Expecting one of '${r.join("', '")}'`);return this._lifeCycleHooks[t]?this._life
|
|
|
14271
14271
|
`),this.outputHelp({error:!0}));let r=o||{},n=r.exitCode||1,a=r.code||"commander.error";this._exit(n,a,t)}_parseOptionsEnv(){this.options.forEach(t=>{if(t.envVar&&t.envVar in he.env){let o=t.attributeName();(this.getOptionValue(o)===void 0||["default","config","env"].includes(this.getOptionValueSource(o)))&&(t.required||t.optional?this.emit(`optionEnv:${t.name()}`,he.env[t.envVar]):this.emit(`optionEnv:${t.name()}`))}})}_parseOptionsImplied(){let t=new ki(this.options),o=r=>this.getOptionValue(r)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(r));this.options.filter(r=>r.implied!==void 0&&o(r.attributeName())&&t.valueFromOption(this.getOptionValue(r.attributeName()),r)).forEach(r=>{Object.keys(r.implied).filter(n=>!o(n)).forEach(n=>{this.setOptionValueWithSource(n,r.implied[n],"implied")})})}missingArgument(t){let o=`error: missing required argument '${t}'`;this.error(o,{code:"commander.missingArgument"})}optionMissingArgument(t){let o=`error: option '${t.flags}' argument missing`;this.error(o,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(t){let o=`error: required option '${t.flags}' not specified`;this.error(o,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(t,o){let r=i=>{let s=i.attributeName(),m=this.getOptionValue(s),l=this.options.find(p=>p.negate&&s===p.attributeName()),u=this.options.find(p=>!p.negate&&s===p.attributeName());return l&&(l.presetArg===void 0&&m===!1||l.presetArg!==void 0&&m===l.presetArg)?l:u||i},n=i=>{let s=r(i),m=s.attributeName();return this.getOptionValueSource(m)==="env"?`environment variable '${s.envVar}'`:`option '${s.flags}'`},a=`error: ${n(t)} cannot be used with ${n(o)}`;this.error(a,{code:"commander.conflictingOption"})}unknownOption(t){if(this._allowUnknownOption)return;let o="";if(t.startsWith("--")&&this._showSuggestionAfterError){let n=[],a=this;do{let i=a.createHelp().visibleOptions(a).filter(s=>s.long).map(s=>s.long);n=n.concat(i),a=a.parent}while(a&&!a._enablePositionalOptions);o=Pl(t,n)}let r=`error: unknown option '${t}'${o}`;this.error(r,{code:"commander.unknownOption"})}_excessArguments(t){if(this._allowExcessArguments)return;let o=this.registeredArguments.length,r=o===1?"":"s",n=t.length,a=this.parent?` for '${this.name()}'`:"",i=t.join(", "),s=`error: too many arguments${a}. Expected ${o} argument${r} but got ${n}: ${i}.`;this.error(s,{code:"commander.excessArguments"})}unknownCommand(){let t=this.args[0],o="";if(this._showSuggestionAfterError){let n=[];this.createHelp().visibleCommands(this).forEach(a=>{n.push(a.name()),a.alias()&&n.push(a.alias())}),o=Pl(t,n)}let r=`error: unknown command '${t}'${o}`;this.error(r,{code:"commander.unknownCommand"})}version(t,o,r){if(t===void 0)return this._version;this._version=t,o=o||"-V, --version",r=r||"output the version number";let n=this.createOption(o,r);return this._versionOptionName=n.attributeName(),this._registerOption(n),this.on("option:"+n.name(),()=>{this._outputConfiguration.writeOut(`${t}
|
|
14272
14272
|
`),this._exit(0,"commander.version",t)}),this}description(t,o){return t===void 0&&o===void 0?this._description:(this._description=t,o&&(this._argsDescription=o),this)}summary(t){return t===void 0?this._summary:(this._summary=t,this)}alias(t){if(t===void 0)return this._aliases[0];let o=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(o=this.commands[this.commands.length-1]),t===o._name)throw new Error("Command alias can't be the same as its name");let r=this.parent?._findCommand(t);if(r){let n=[r.name()].concat(r.aliases()).join("|");throw new Error(`cannot add alias '${t}' to command '${this.name()}' as already have command '${n}'`)}return o._aliases.push(t),this}aliases(t){return t===void 0?this._aliases:(t.forEach(o=>this.alias(o)),this)}usage(t){if(t===void 0){if(this._usage)return this._usage;let o=this.registeredArguments.map(r=>wi(r));return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?o:[]).join(" ")}return this._usage=t,this}name(t){return t===void 0?this._name:(this._name=t,this)}helpGroup(t){return t===void 0?this._helpGroupHeading??"":(this._helpGroupHeading=t,this)}commandsGroup(t){return t===void 0?this._defaultCommandGroup??"":(this._defaultCommandGroup=t,this)}optionsGroup(t){return t===void 0?this._defaultOptionGroup??"":(this._defaultOptionGroup=t,this)}_initOptionGroup(t){this._defaultOptionGroup&&!t.helpGroupHeading&&t.helpGroup(this._defaultOptionGroup)}_initCommandGroup(t){this._defaultCommandGroup&&!t.helpGroup()&&t.helpGroup(this._defaultCommandGroup)}nameFromFilename(t){return this._name=Qt.basename(t,Qt.extname(t)),this}executableDir(t){return t===void 0?this._executableDir:(this._executableDir=t,this)}helpInformation(t){let o=this.createHelp(),r=this._getOutputContext(t);o.prepareContext({error:r.error,helpWidth:r.helpWidth,outputHasColors:r.hasColors});let n=o.formatHelp(this,o);return r.hasColors?n:this._outputConfiguration.stripColor(n)}_getOutputContext(t){t=t||{};let o=!!t.error,r,n,a;return o?(r=s=>this._outputConfiguration.writeErr(s),n=this._outputConfiguration.getErrHasColors(),a=this._outputConfiguration.getErrHelpWidth()):(r=s=>this._outputConfiguration.writeOut(s),n=this._outputConfiguration.getOutHasColors(),a=this._outputConfiguration.getOutHelpWidth()),{error:o,write:s=>(n||(s=this._outputConfiguration.stripColor(s)),r(s)),hasColors:n,helpWidth:a}}outputHelp(t){let o;typeof t=="function"&&(o=t,t=void 0);let r=this._getOutputContext(t),n={error:r.error,write:r.write,command:this};this._getCommandAndAncestors().reverse().forEach(i=>i.emit("beforeAllHelp",n)),this.emit("beforeHelp",n);let a=this.helpInformation({error:r.error});if(o&&(a=o(a),typeof a!="string"&&!Buffer.isBuffer(a)))throw new Error("outputHelp callback must return a string or a Buffer");r.write(a),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit("afterHelp",n),this._getCommandAndAncestors().forEach(i=>i.emit("afterAllHelp",n))}helpOption(t,o){return typeof t=="boolean"?(t?(this._helpOption===null&&(this._helpOption=void 0),this._defaultOptionGroup&&this._initOptionGroup(this._getHelpOption())):this._helpOption=null,this):(this._helpOption=this.createOption(t??"-h, --help",o??"display help for command"),(t||o)&&this._initOptionGroup(this._helpOption),this)}_getHelpOption(){return this._helpOption===void 0&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(t){return this._helpOption=t,this._initOptionGroup(t),this}help(t){this.outputHelp(t);let o=Number(he.exitCode??0);o===0&&t&&typeof t!="function"&&t.error&&(o=1),this._exit(o,"commander.help","(outputHelp)")}addHelpText(t,o){let r=["beforeAll","before","after","afterAll"];if(!r.includes(t))throw new Error(`Unexpected value for position to addHelpText.
|
|
14273
14273
|
Expecting one of '${r.join("', '")}'`);let n=`${t}Help`;return this.on(n,a=>{let i;typeof o=="function"?i=o({error:a.error,command:a.command}):i=o,i&&a.write(`${i}
|
|
14274
|
-
`)}),this}_outputHelpIfRequested(t){let o=this._getHelpOption();o&&t.find(n=>o.is(n))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function Fy(e){return e.map(t=>{if(!t.startsWith("--inspect"))return t;let o,r="127.0.0.1",n="9229",a;return(a=t.match(/^(--inspect(-brk)?)$/))!==null?o=a[1]:(a=t.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(o=a[1],/^\d+$/.test(a[3])?n=a[3]:r=a[3]):(a=t.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(o=a[1],r=a[3],n=a[4]),o&&n!=="0"?`${o}=${r}:${parseInt(n)+1}`:t})}function Uy(){if(he.env.NO_COLOR||he.env.FORCE_COLOR==="0"||he.env.FORCE_COLOR==="false")return!1;if(he.env.FORCE_COLOR||he.env.CLICOLOR_FORCE!==void 0)return!0}var qj=new Io;ye();qt();be();import{mkdir as pP,readFile as hP,writeFile as gP}from"node:fs/promises";import{dirname as fP,join as yP,relative as bP,resolve as vP}from"node:path";async function wP(e,t){let o;try{o=await hP(e,"utf8")}catch{return"absent"}return o===t?"same":"different"}async function HS(e,t,o){let r=yP(e,t),n=await wP(r,o);try{await pP(fP(r),{recursive:!0}),await gP(r,o,"utf8")}catch{throw $(`Cannot write ${r}.`),new Error("unreachable")}return{where:bP(process.cwd(),r)||t,state:n}}async function YS(e){let t=vP(e.out??"."),o=await HS(t,ze,Mn),r=await HS(t,Ue,yr),n=`import { start } from "./${ze}";`,a=`import { createPlayerClient, newIdempotencyKey } from "./${Ue}";`,i=o.state==="same"&&r.state==="same";if(N())return U({ok:!0,status:i?"unchanged":"written",files:[{path:o.where,digest:Bt,import:n},{path:r.where,digest:vo,import:a}],path:o.where,digest:Bt,import:n});I(i?"Already current":"Wrote the Gamestage client"),A("Library",`${o.where} (${Bt})`),A("Player client",`${r.where} (${vo})`),g(),w(`Import it: ${v.cyan(n)}`),w(`The player API on its own: ${v.cyan(a)}`),(o.state==="different"||r.state==="different")&&w("An earlier copy was replaced. It is generated, so nothing of yours was in it."),g()}$t();Yn();ye();qt();Un();import{mkdir as cE,readdir as dE,stat as $z,writeFile as lE}from"node:fs/promises";import{join as Az}from"node:path";import{createInterface as Cz}from"node:readline/promises";import{createHash as Iz}from"node:crypto";var et="0.36.
|
|
14274
|
+
`)}),this}_outputHelpIfRequested(t){let o=this._getHelpOption();o&&t.find(n=>o.is(n))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function Fy(e){return e.map(t=>{if(!t.startsWith("--inspect"))return t;let o,r="127.0.0.1",n="9229",a;return(a=t.match(/^(--inspect(-brk)?)$/))!==null?o=a[1]:(a=t.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(o=a[1],/^\d+$/.test(a[3])?n=a[3]:r=a[3]):(a=t.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(o=a[1],r=a[3],n=a[4]),o&&n!=="0"?`${o}=${r}:${parseInt(n)+1}`:t})}function Uy(){if(he.env.NO_COLOR||he.env.FORCE_COLOR==="0"||he.env.FORCE_COLOR==="false")return!1;if(he.env.FORCE_COLOR||he.env.CLICOLOR_FORCE!==void 0)return!0}var qj=new Io;ye();qt();be();import{mkdir as pP,readFile as hP,writeFile as gP}from"node:fs/promises";import{dirname as fP,join as yP,relative as bP,resolve as vP}from"node:path";async function wP(e,t){let o;try{o=await hP(e,"utf8")}catch{return"absent"}return o===t?"same":"different"}async function HS(e,t,o){let r=yP(e,t),n=await wP(r,o);try{await pP(fP(r),{recursive:!0}),await gP(r,o,"utf8")}catch{throw $(`Cannot write ${r}.`),new Error("unreachable")}return{where:bP(process.cwd(),r)||t,state:n}}async function YS(e){let t=vP(e.out??"."),o=await HS(t,ze,Mn),r=await HS(t,Ue,yr),n=`import { start } from "./${ze}";`,a=`import { createPlayerClient, newIdempotencyKey } from "./${Ue}";`,i=o.state==="same"&&r.state==="same";if(N())return U({ok:!0,status:i?"unchanged":"written",files:[{path:o.where,digest:Bt,import:n},{path:r.where,digest:vo,import:a}],path:o.where,digest:Bt,import:n});I(i?"Already current":"Wrote the Gamestage client"),A("Library",`${o.where} (${Bt})`),A("Player client",`${r.where} (${vo})`),g(),w(`Import it: ${v.cyan(n)}`),w(`The player API on its own: ${v.cyan(a)}`),(o.state==="different"||r.state==="different")&&w("An earlier copy was replaced. It is generated, so nothing of yours was in it."),g()}$t();Yn();ye();qt();Un();import{mkdir as cE,readdir as dE,stat as $z,writeFile as lE}from"node:fs/promises";import{join as Az}from"node:path";import{createInterface as Cz}from"node:readline/promises";import{createHash as Iz}from"node:crypto";var et="0.36.3",pi="2026-10-01",dl=">=22.13.0";function bz(e=dl){let[t,o]=e.replace(/^[^\d]*/,"").split(".").map(Number);return[t,o||0]}function nE(e,t=dl){let[o,r]=bz(t),[n,a]=e.split(".").map(Number);return n>o||n===o&&a>=r}import{randomUUID as vz}from"node:crypto";var wz=/-[0-9a-f]{4}$/;function ml(e){return`${e}-${vz().replace(/-/g,"").slice(0,4)}`}function oE(e){return wz.test(e)}Ge();var pn="favicon.svg",hi=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">
|
|
14275
14275
|
<rect width="32" height="32" rx="7" fill="#1b1c1f"/>
|
|
14276
14276
|
<path d="m12 8 12 8-12 8Z" fill="#fff"/>
|
|
14277
14277
|
</svg>
|
package/package.json
CHANGED