gamestage 0.35.30 → 0.35.31
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 +2 -2
- package/package.json +1 -1
package/cli.mjs
CHANGED
|
@@ -13919,7 +13919,7 @@ Expecting one of '${r.join("', '")}'`);return this._lifeCycleHooks[t]?this._life
|
|
|
13919
13919
|
`),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 Te.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()}`,Te.env[t.envVar]):this.emit(`optionEnv:${t.name()}`))}})}_parseOptionsImplied(){let t=new ms(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(),l=this.getOptionValue(s),d=this.options.find(p=>p.negate&&s===p.attributeName()),m=this.options.find(p=>!p.negate&&s===p.attributeName());return d&&(d.presetArg===void 0&&l===!1||d.presetArg!==void 0&&l===d.presetArg)?d:m||i},n=i=>{let s=r(i),l=s.attributeName();return this.getOptionValueSource(l)==="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=cu(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=cu(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}
|
|
13920
13920
|
`),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=>us(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=bn.basename(t,bn.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(Te.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.
|
|
13921
13921
|
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}
|
|
13922
|
-
`)}),this}_outputHelpIfRequested(t){let o=this._getHelpOption();o&&t.find(n=>o.is(n))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function Sw(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 Tw(){if(Te.env.NO_COLOR||Te.env.FORCE_COLOR==="0"||Te.env.FORCE_COLOR==="false")return!1;if(Te.env.FORCE_COLOR||Te.env.CLICOLOR_FORCE!==void 0)return!0}var wU=new nr;ke();sn();$e();import{mkdir as ON,readFile as zN,writeFile as RN}from"node:fs/promises";import{dirname as NN,join as jN,relative as LN,resolve as DN}from"node:path";async function MN(e,t){let o;try{o=await zN(e,"utf8")}catch{return"absent"}return o===t?"same":"different"}async function OE(e,t,o){let r=jN(e,t),n=await MN(r,o);try{await ON(NN(r),{recursive:!0}),await RN(r,o,"utf8")}catch{throw R(`Cannot write ${r}.`),new Error("unreachable")}return{where:LN(process.cwd(),r)||t,state:n}}async function zE(e){let t=DN(e.out??"."),o=await OE(t,qe,Bt),r=await OE(t,ot,qr),n=`import { start } from "./${qe}";`,a=`import { createPlayerClient, newIdempotencyKey } from "./${ot}";`,i=o.state==="same"&&r.state==="same";if(U())return ee({ok:!0,status:i?"unchanged":"written",files:[{path:o.where,digest:an,import:n},{path:r.where,digest:Bo,import:a}],path:o.where,digest:an,import:n});j(i?"Already current":"Wrote the Gamestage client"),O("Library",`${o.where} (${an})`),O("Player client",`${r.where} (${Bo})`),g(),k(`Import it: ${v.cyan(n)}`),k(`The player API on its own: ${v.cyan(a)}`),(o.state==="different"||r.state==="different")&&k("An earlier copy was replaced. It is generated, so nothing of yours was in it."),g()}ke();sn();uo();import{mkdir as pj,readdir as s$,stat as hj,writeFile as i$}from"node:fs/promises";import{join as fj}from"node:path";import{createInterface as gj}from"node:readline/promises";import{createHash as yj}from"node:crypto";var wt="0.35.
|
|
13922
|
+
`)}),this}_outputHelpIfRequested(t){let o=this._getHelpOption();o&&t.find(n=>o.is(n))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function Sw(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 Tw(){if(Te.env.NO_COLOR||Te.env.FORCE_COLOR==="0"||Te.env.FORCE_COLOR==="false")return!1;if(Te.env.FORCE_COLOR||Te.env.CLICOLOR_FORCE!==void 0)return!0}var wU=new nr;ke();sn();$e();import{mkdir as ON,readFile as zN,writeFile as RN}from"node:fs/promises";import{dirname as NN,join as jN,relative as LN,resolve as DN}from"node:path";async function MN(e,t){let o;try{o=await zN(e,"utf8")}catch{return"absent"}return o===t?"same":"different"}async function OE(e,t,o){let r=jN(e,t),n=await MN(r,o);try{await ON(NN(r),{recursive:!0}),await RN(r,o,"utf8")}catch{throw R(`Cannot write ${r}.`),new Error("unreachable")}return{where:LN(process.cwd(),r)||t,state:n}}async function zE(e){let t=DN(e.out??"."),o=await OE(t,qe,Bt),r=await OE(t,ot,qr),n=`import { start } from "./${qe}";`,a=`import { createPlayerClient, newIdempotencyKey } from "./${ot}";`,i=o.state==="same"&&r.state==="same";if(U())return ee({ok:!0,status:i?"unchanged":"written",files:[{path:o.where,digest:an,import:n},{path:r.where,digest:Bo,import:a}],path:o.where,digest:an,import:n});j(i?"Already current":"Wrote the Gamestage client"),O("Library",`${o.where} (${an})`),O("Player client",`${r.where} (${Bo})`),g(),k(`Import it: ${v.cyan(n)}`),k(`The player API on its own: ${v.cyan(a)}`),(o.state==="different"||r.state==="different")&&k("An earlier copy was replaced. It is generated, so nothing of yours was in it."),g()}ke();sn();uo();import{mkdir as pj,readdir as s$,stat as hj,writeFile as i$}from"node:fs/promises";import{join as fj}from"node:path";import{createInterface as gj}from"node:readline/promises";import{createHash as yj}from"node:crypto";var wt="0.35.31",$i="2026-09-29-1",Bl=">=22.13.0";function WN(e=Bl){let[t,o]=e.replace(/^[^\d]*/,"").split(".").map(Number);return[t,o||0]}function HE(e,t=Bl){let[o,r]=WN(t),[n,a]=e.split(".").map(Number);return n>o||n===o&&a>=r}import{randomUUID as HN}from"node:crypto";var KN=/-[0-9a-f]{4}$/;function ql(e){return`${e}-${HN().replace(/-/g,"").slice(0,4)}`}function KE(e){return KN.test(e)}ut();var Pn="favicon.svg",Ii=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">
|
|
13923
13923
|
<rect width="32" height="32" rx="7" fill="#1b1c1f"/>
|
|
13924
13924
|
<path d="m12 8 12 8-12 8Z" fill="#fff"/>
|
|
13925
13925
|
</svg>
|
|
@@ -13987,7 +13987,7 @@ window.GAMESTAGE_GAME = ${JSON.stringify(o)};
|
|
|
13987
13987
|
// This page was deployed, so it may ask which Interaction Cloud project it is.
|
|
13988
13988
|
window.GAMESTAGE_IC_LOOKUP = true;
|
|
13989
13989
|
</script>
|
|
13990
|
-
`,n=e.search(/<script\b/i);if(n===-1){let a=e.search(/<\/head>/i);return a===-1?r+e:e.slice(0,a)+r+e.slice(a)}return e.slice(0,n)+r+e.slice(n)}async function Jo(e,t,o,r){let n=await fetch(e,{method:"PUT",body:typeof t=="string"?new Uint8Array(Buffer.from(t,"utf8")):t,headers:{"content-type":o,...r?{"cache-control":r}:{}}});n.ok||R(`Upload refused with ${n.status}. Ask for a fresh URL and retry.`)}function Kd(e){let t=new URL(e.publicUrl);return t.pathname=`/${e.key.split("/").map(encodeURIComponent).join("/")}`,t.search="",t.hash="",t.toString()}function b6(e){switch(l6(e).toLowerCase()){case".html":return"text/html; charset=utf-8";case".css":return"text/css; charset=utf-8";case".js":case".mjs":return"text/javascript; charset=utf-8";case".json":return"application/json; charset=utf-8";case".svg":return"image/svg+xml";case".png":return"image/png";case".jpg":case".jpeg":return"image/jpeg";case".gif":return"image/gif";case".webp":return"image/webp";case".ico":return"image/x-icon";case".webmanifest":return"application/manifest+json; charset=utf-8";case".wasm":return"application/wasm";default:return"application/octet-stream"}}async function oC(e,t,o,r,n,a){let i=Ql(a.settings,a.fallbackTitle),s=i.description??i.title,l=fo(o),d=await e.uploadTarget(t,ho),m=d.publicUrl.replace(/[^/]+$/,"index.html"),p=null,h=l.get("og:image")||void 0;if(!h&&r&&(h=d.publicUrl),!h){let y=await(a.draw??v$)(n??Ei(a.settings,i.title),i.description);y.png?(p=y.png,h=d.publicUrl,k(`Link preview: drew ${ho} (${1200}x${630}) from the game's name and strapline.`)):k(`Link preview: no ${ho} drawn (${y.reason}). The link will unfurl without a picture; add ${ho} at ${1200}x${630} to the game folder, or install Chrome and deploy again.`)}return{tags:{title:i.title,description:s,siteName:i.siteName,url:m,image:h,imageAlt:i.description?`${i.title}: ${i.description}`:i.title,imageWidth:1200,imageHeight:630},card:p}}async function rC(e,t,o){if(!o)return;let r=await e.uploadTarget(t,ho);await Jo(r.uploadUrl,o,"image/png",r.cacheControl)}async function v6(e,t,o,r={},n,a,i){let s=sw(o),l;try{l=aw(s)}catch{throw R(`Cannot read ${o}.`),new Error("unreachable")}let d=await Tb({path:s,relativePath:o},r.round);d&&R(`${o} ${d.why}`,["A deploy is a publishing act, and --file publishes this file as the game's","own page. Point --file at the game's HTML, or use --dir and let the gate","withhold what the page does not need."]),await a?.(s);let m=await e.uploadTarget(t,"index.html"),p=i?await oC(e,t,l.toString("utf8"),!1,n,i):null,h=p?ji(l.toString("utf8"),p.tags):l.toString("utf8");await rC(e,t,p?.card??null);let y=nC(q2(Pi(h),n),`${m.playerApiOrigin}`,t);await Jo(m.uploadUrl,y,"text/html; charset=utf-8",m.cacheControl);let w=await e.uploadTarget(t,ot);await Jo(w.uploadUrl,qr,"text/javascript; charset=utf-8",w.cacheControl);let I=await e.uploadTarget(t,qe);await Jo(I.uploadUrl,Bt,"text/javascript; charset=utf-8",I.cacheControl);let L=await e.uploadTarget(t,Pn);return await Jo(L.uploadUrl,Ii,"image/svg+xml",L.cacheControl),U()||(g(),k(`Uploaded ${o} to ${Kd(m)}`),k(`Wired it to ${m.playerApiOrigin} as "${t}"`),k(`Shipped @monterosa/gamestage beside it (${an})`),k(`Shipped the player client beside it (${Bo})`)),Kd(m)}async function w6(e,t,o,r,n){if(r||!e||!t)return;let{browserCheck:a}=await Promise.resolve().then(()=>(Zo(),nw));x6(await a(e,t,o,n))}function k6(e){return[...(e??[]).slice(-8)].reverse().find(r=>r.level==="error"&&/not on Interaction Cloud/.test(r.message))?.message.replace(/^The game is not on Interaction Cloud: /,"Studio answered: ")}function _6(e,t,o){let r=e.studioUrl??Ai(e.id);return[`${v.bold(`No ${t} yet: add one in Studio.`)}`,` ${v.cyan(r)}`,"",e.studioUrl?" The game is online and its Studio project exists, so a fan opening it now":" The game is online, and Stage links to its Studio project once it has one, so a fan opening it now",` finds nothing to play. Write the first ${t} in Studio and it appears`,` without another deploy. Share the game once a ${t} is on.`,"",` ${v.cyan(re("dev --serve"))} try the game on this machine with a sample ${o.toLowerCase()} meanwhile`]}function x6(e){if(e.status==="verified"){O("Checked","the page loads and plays in a browser"),g();return}if(e.status==="skipped"||e.status==="n/a"){k(v.dim(`Not checked in a browser: ${e.detail??""}`.trim())),g();return}j("The published page did not start"),g(` ${e.detail??""}`),g(),k("The files are published, so the game is live and broken rather than unpublished."),k(`${v.cyan(re("verify"))} the same check, with the rest of them`),g(),process.exitCode=1}function S6(e){for(let t of e.walkedPast)k(`Walked past ${t}: it is a toolchain directory, not your game.`);for(let t of e.allowed)k(`Published ${t.path} because you allowed it.`);for(let t of e.withheld)k(`Withheld ${t.path} from the upload: it ${t.why}`);e.refuse&&R(`${e.refuse.path} ${e.refuse.why}`,["A deploy is a publishing act, so this file would sit at a public URL beside","your game. Remove it from the directory, or point --dir at a directory that","does not contain it, and deploy again."])}async function T6(e,t,o,r={},n,a,i){let s,l=[];try{let $=Mi(o,{symlinks:"throw"});s=$.files,l=$.withheld}catch($){throw R($ instanceof Error?$.message:`Cannot read ${o}.`),new Error("unreachable")}let d=await p$(s,{...r,exempt:[qe,ot]});S6(d);let m=d.publish,p=m.find($=>$.relativePath==="index.html");p||R(`Directory ${o} must contain an index.html file.`),await a?.(p.path);let h=k$(m,l);j(`Publishing ${m.length} ${m.length===1?"file":"files"} to the playground`);for(let $ of h.lines)k($);h.named.length&&(g(),k("The lines above are named because they are not ordinary web assets. Anything there you did not mean to publish, stop and remove it: a deploy puts every one of these at a public URL beside your game.")),g();let y=aw(p.path,"utf8"),w=i?await oC(e,t,y,m.some($=>$.relativePath===ho),n,i):null,I=bb(y),L=m.some($=>$.relativePath==="favicon.ico"),J=m.some($=>$.relativePath===Pn),Q=!I&&!L,q=Q&&!J,_=rw();if(_!=="0.0.0-test"){let $=`${He}/client/${_}/${qe}`,E=!1;try{E=(await fetch($,{method:"HEAD"})).ok}catch{E=!0}E||R(`The client this deploy would pin, ${_}, is not published yet.`,[`Every page uploaded here will import ${$},`,"which answers 404 today. The game would load, fetch nothing, and show a","blank screen with no error anywhere.","","Deploy the site first: it is what serves /client/<version>/.","",`${v.cyan("node scripts/deploy.mjs site")} then run this deploy again`])}let T;for(let $ of m){if($.relativePath===qe||$.relativePath===ot)continue;let E;try{E=await e.uploadTarget(t,$.relativePath)}catch(ce){throw new Error(`${$.relativePath} cannot be published: ${ce instanceof Error?ce.message:String(ce)}`,{cause:ce})}$.relativePath==="index.html"&&(T=E);let z=aw($.path),W=/\.(m?js)$/i.test($.relativePath),ae=/\.html$/i.test($.relativePath)?nC(F2($.relativePath==="index.html"?q2((()=>{let ce=w?ji(z.toString("utf8"),w.tags):z.toString("utf8");return Q?Pi(ce):ce})(),n):z.toString("utf8"),rw()),E.playerApiOrigin,t):W?F2(z.toString("utf8"),rw()):z;await Jo(E.uploadUrl,ae,b6($.relativePath),E.cacheControl)}if(await rC(e,t,w?.card??null),q){let $=await e.uploadTarget(t,Pn);await Jo($.uploadUrl,Ii,"image/svg+xml",$.cacheControl)}let Y=[...m.map($=>$.relativePath),...q?[Pn]:[],...w?.card?[ho]:[]];try{await e.pruneBundle(t,Y);for(let $ of d.withheld)k(`Removed ${$.path} from the playground.`)}catch($){let E=$ instanceof Error?$.message:String($),z=d.withheld.map(W=>W.path);j("The playground still holds files this deploy did not publish"),g(` ${E}`),g(),z.length?(k(`Could not remove ${z.join(", ")} from the playground: ${E}`),k("Anything an earlier deploy put there is still being served.")):k("Anything an earlier deploy put there is still being served."),g(),process.exitCode=1}if(!U()&&T&&(g(),k(`Uploaded ${m.length} files from ${o}`),k(`Playground: ${Kd(T)}`),k(`Wired it to ${T.playerApiOrigin} as "${t}"`),q&&k("Added a replaceable starter favicon")),!T)throw new Error("The directory index was not uploaded.");return Kd(T)}async function E6(e,t,o,r){let n=!0;try{let p=je(await hn(o,"utf8"));p.ok&&(n=p.manifest.identity?.consent?.analytics_requires_consent!==!1)}catch{}let{consentGate:a}=await Promise.resolve().then(()=>(Zo(),nw)),i=r?await a(t,e,n):{status:"skipped",detail:"asked not to open a browser (--no-check)."};if(i.status==="verified"){O("Consent","a fan is asked before anything is recorded");return}i.status==="open"&&R("This game would record fans without asking them first, so nothing was published.",[i.detail??"","",`${v.cyan(re("verify"))} the same check, with the rest of them`]);let s="";try{s=await hn(t,"utf8")}catch{return}let l=/gamestage(\.min)?\.js|@monterosa\/gamestage/.test(s),d=/consentBanner\s*:\s*false/.test(s),m=/data-gs-component=["']consent["']|<Consent\b|game\.consent\.decide\(/.test(s);n&&(!l||d&&!m)&&R("This game does not ask fans for consent, so nothing was published.",[l?"The page turns the consent banner off and draws no consent screen of its own.":"The page does not load the Gamestage client, which draws the consent banner.",`${v.cyan(re("client"))} add the client, then deploy again`]),k(v.dim(`Consent checked by reading the page, not in a browser: ${i.detail??""}`.trim()))}async function $6(e,t){let o=!0;try{let a=je(await hn(t,"utf8"));a.ok&&(o=a.manifest.identity?.consent?.analytics_requires_consent!==!1)}catch{}if(!o)return;let r=hs.filter(a=>!e?.[a]?.trim()),n=e?.privacy_policy_url?.trim()??"";r.length===0&&/^https:\/\/[^\s]+$/.test(n)||R("The consent banner would not say who is asking, so nothing was published.",[r.length?`${On} has no ${r.join(" or ")}.`:`privacy_policy_url must be an https address, and is "${n}".`,"Add your brand as consent_brand_name and your privacy policy's address as","privacy_policy_url. A fan is told who is recording them before they answer."])}Wo();uo();ke();import{readFile as pC,stat as M6}from"node:fs/promises";import{createServer as F6}from"node:http";import{extname as U6,join as G6,normalize as B6,resolve as pw,sep as q6}from"node:path";ke();var iC="player-conformance",uw="round-current",A6="sha256:emulator-conformance";function jn(e){return structuredClone(e)}function fn(){return{server_time:"2026-08-01T09:00:00.000Z",snapshot:A6}}var C6="2026-08-01T08:00:00.000Z";function I6(e){let t=e==="per-player-challenge",o=e==="locked";return{...fn(),id:uw,number:412,version:2,...o?{locks_at:C6}:{},can:{accepting_plays:!o,results_available:!1,solution_revealed:!1,closed:!1,optimistic_play:!1},challenge_instance_id:t?"challenge-player-conformance":null,challenge:{prompt:"alpha"}}}function aC(e,t){let o=t==="mistakes";return{...fn(),player_id:iC,round_id:e,attempts_used:o?6:0,attempts_allowed:10,mistakes_used:o?2:0,mistakes_allowed:4,progress:o?{solved:["group-1"]}:{},score:o?10:0,score_revision:0,finished:!1,outcome:o?"incomplete":void 0}}function P6(e){let t=I6(e),o=new Map([[t.id,t]]),r=new Map([[t.id,aC(t.id,e)]]);return e==="solution-disclosure"&&(o.set("round-revealed",{...t,id:"round-revealed",number:411,version:3,can:{accepting_plays:!1,results_available:!0,solution_revealed:!0,closed:!0,optimistic_play:!1},solution:{answer:"revealed-alpha"}}),r.set("round-revealed",aC("round-revealed",e))),{runtime:{...fn(),game:"conformance-game",api_version:"2.0",archetype:e==="at-settlement"?"predict":"group",marking:e==="at-settlement"?"at_settlement":"at_commit",challenge_source:e==="per-player-challenge"?"per_player":"shared",schedule:{kind:"continuous"},updates:{transport:"poll",freshness_seconds:30},display:{title:"Conformance game"},identity:{required:!1,provider:"identify",anonymous_play:!0},archive:!0,capabilities:["plays","profile","leaderboard"]},rounds:o,roundStates:r,leaderboard:{...fn(),round_id:uw,order:"high_first",tie_break:"earliest_play",entries:[{rank:1,player_id:"player-example",display_name:"Example",score:20}],total:1,truncated:!1},profile:{...fn(),player_id:iC,display_name:"Example",played:0,won:0,current_streak:0,max_streak:0,distribution:{},constraints:{}},plays:new Map,intents:new Map,nextPlay:1}}function Yd(e,t){return{...fn(),play_id:`rejected-${e.nextPlay++}`,outcome:"rejected",reason:t,round_version:2,marked:!1,feedback:[]}}function mw(e){let t=P6(e);return{async getRuntime(){return jn(t.runtime)},async getCurrentRound(){return jn(t.rounds.get(uw))},async getRound(o){let r=t.rounds.get(o);return r?jn(r):void 0},async play(o,r){let n=t.rounds.get(o);if(!n)return Yd(t,"round_not_found");let a=bl({round_id:o,round_version:r.round_version,challenge_instance_id:r.challenge_instance_id,payload:r.payload}),i=t.plays.get(r.idempotency_key);if(i)return t.intents.get(r.idempotency_key)!==a?Yd(t,"idempotency_conflict"):{...jn(i),outcome:"duplicate"};if(r.round_version!==n.version)return{...fn(),play_id:`stale-${t.nextPlay++}`,outcome:"stale",reason:"round_version",round_version:n.version,marked:!1,feedback:[]};if(n.challenge_instance_id!==null&&r.challenge_instance_id!==n.challenge_instance_id)return Yd(t,"challenge_instance_id");if(n.locks_at!==void 0&&n.locks_at<=fn().server_time)return Yd(t,"lock_deadline_passed");let s=t.roundStates.get(o),l=t.runtime.marking==="at_settlement",d={...s,...fn(),attempts_used:s.attempts_used+1,score:s.score+(l?0:10),finished:!l,outcome:l?"pending":"won"},m={...fn(),play_id:`play-${t.nextPlay++}`,outcome:"accepted",round_version:n.version,marked:!l,feedback:l?[]:[{key:"answer",verdict:"correct"}],round_state:jn(d)};return t.roundStates.set(o,d),t.plays.set(r.idempotency_key,m),t.intents.set(r.idempotency_key,a),d.finished&&!s.finished&&(t.profile=yl(t.profile,d.outcome)),jn(m)},async getRoundState(o){let r=t.roundStates.get(o);if(!r)throw new Error(`No such round: ${o}`);return jn(r)},async getProfile(){return jn(t.profile)},async getLeaderboard(){return jn(t.leaderboard)}}}function O6(){return e=>mw(e)}var FX=O6();ke();import{createServer as z6}from"node:http";function Qo(e){let t=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return new RegExp(`^${t.replace(/\\\{[^}]+\\\}/g,"([^/]+)")}$`)}var R6=Qo(ze.runtime),sC=Qo(ze.currentRound),cC=Qo(ze.round),lC=Qo(ze.plays),dC=Qo(ze.roundState),N6=Qo(ze.profile),j6=Qo(ze.leaderboard),uC={"access-control-allow-origin":"*","access-control-allow-methods":"GET, POST, OPTIONS","access-control-allow-headers":"authorization, content-type, x-gamestage-player","access-control-max-age":"600"};function _o(e,t,o){let r=JSON.stringify(o);e.writeHead(t,{...uC,"content-type":"application/json; charset=utf-8","content-length":Buffer.byteLength(r)}),e.end(r)}function Xo(e,t,o,r){_o(e,t,{error:{code:o,message:r,retryable:!1}})}async function L6(e){let t=[];for await(let o of e)t.push(Buffer.from(o));if(t.length!==0)return JSON.parse(Buffer.concat(t).toString("utf8"))}async function D6(e,t,o,r,n){if(!e.url){Xo(t,400,"invalid_request","The request URL is missing.");return}let i=new URL(e.url,"http://localhost").pathname;if(e.method==="OPTIONS"){t.writeHead(204,uC),t.end();return}if(n&&(sC.test(i)||cC.test(i)||lC.test(i)||dC.test(i))){Xo(t,404,"no_round",n);return}if(e.method==="GET"){if(r&&/^\/(client\/[^/]+\/)?gamestage\.js$/.test(i)){t.writeHead(200,{"content-type":"text/javascript; charset=utf-8","cache-control":"no-store","access-control-allow-origin":"*","content-length":Buffer.byteLength(r)}),t.end(r);return}if(R6.test(i)){_o(t,200,await o.getRuntime());return}if(sC.test(i)){_o(t,200,await o.getCurrentRound());return}let s=cC.exec(i);if(s){let d=await o.getRound(decodeURIComponent(s[2]));if(!d){Xo(t,404,"round_not_found","The requested round was not found.");return}_o(t,200,d);return}let l=dC.exec(i);if(l){let d=decodeURIComponent(l[2]);try{_o(t,200,await o.getRoundState(d))}catch{Xo(t,404,"round_not_found","The requested round was not found.")}return}if(N6.test(i)){_o(t,200,await o.getProfile());return}if(j6.test(i)){_o(t,200,await o.getLeaderboard());return}}if(e.method==="POST"){let s=lC.exec(i);if(s){try{let l=await L6(e);_o(t,200,await o.play(decodeURIComponent(s[2]),l))}catch(l){Xo(t,400,"invalid_request",l instanceof SyntaxError?"The request body must be valid JSON.":"The request body is invalid.")}return}}Xo(t,404,"not_found","The requested player API route was not found.")}function Vd(e="default",t,o){let r=mw(e);return z6((n,a)=>{D6(n,a,r,t,o).catch(()=>{a.headersSent?a.destroy():Xo(a,500,"internal_error","The emulator could not answer the request.")})})}sn();Bd();ut();Zo();$e();async function W6(e){let t;try{t=await pC(e,"utf8")}catch{return}let o=je(t);if(!o.ok){R(`${e} is not a valid App Manifest.`,o.issues.map(r=>`${v.cyan(r.path)} ${r.message}`));return}return o.manifest}var H6={unconfigured:"No round yet. Set one up in Studio, or add one to gamestage.yaml to play it locally.","studio-round":"This game's round is in Studio, which gamestage dev cannot reach. Play the deployed game, or add a round to gamestage.yaml to play it locally."};async function K6(e){let t=Number(e.port);if(!Number.isInteger(t)||t<0||t>65535)throw new Error("--port must be an integer between 0 and 65535");let o=e.scenario??"default";if(e.fixture)return{server:Vd(o,Bt),what:"fixture",fixtureReason:"requested",game:"conformance-game"};let r=await W6(e.manifest??"gamestage.yaml");if(!r)return{server:Vd(o,Bt),what:"fixture",fixtureReason:"no-manifest",game:"conformance-game"};let n=r.backend.archetype,a=!r.backend.round&&n&&pn.includes(n)?ko(n):void 0,i=r.backend.round??a;if(!i){let l=r.interaction_cloud.elements.length?"studio-round":"unconfigured";return{server:Vd(o,Bt,H6[l]),what:"fixture",fixtureReason:l,game:r.app.id,title:r.app.title}}let s=r.backend.archetype;return s&&s!==i.archetype&&R(`The manifest declares the ${s} format and a ${i.archetype} round.`,["One of the two is wrong. The round decides what the Engine marks."]),pn.includes(i.archetype)||R(`No Engine here serves the ${i.archetype} format yet.`,[`Built so far: ${pn.join(", ")}. \`gamestage dev --fixture\` serves`,"the contract fixture if you are working against the wire rather than the rules."]),{server:await ma({game:r.app.id,round:i,title:r.app.title,identityRequired:!!e.as,clientBundle:Bt}),what:"engine",game:r.app.id,round:i,title:r.app.title,containerLabel:r.experience.container_label,as:e.as,...a?{sample:!0}:{}}}var Y6={".html":"text/html; charset=utf-8",".js":"text/javascript; charset=utf-8",".mjs":"text/javascript; charset=utf-8",".css":"text/css; charset=utf-8",".json":"application/json; charset=utf-8",".svg":"image/svg+xml",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".webp":"image/webp",".ico":"image/x-icon",".woff2":"font/woff2"};function V6(e,t){let o=(n,a)=>`if (!window.${n}) window.${n} = ${JSON.stringify(a)};
|
|
13990
|
+
`,n=e.search(/<script\b/i);if(n===-1){let a=e.search(/<\/head>/i);return a===-1?r+e:e.slice(0,a)+r+e.slice(a)}return e.slice(0,n)+r+e.slice(n)}async function Jo(e,t,o,r){let n=await fetch(e,{method:"PUT",body:typeof t=="string"?new Uint8Array(Buffer.from(t,"utf8")):t,headers:{"content-type":o,...r?{"cache-control":r}:{}}});n.ok||R(`Upload refused with ${n.status}. Ask for a fresh URL and retry.`)}function Kd(e){let t=new URL(e.publicUrl);return t.pathname=`/${e.key.split("/").map(encodeURIComponent).join("/")}`,t.search="",t.hash="",t.toString()}function b6(e){switch(l6(e).toLowerCase()){case".html":return"text/html; charset=utf-8";case".css":return"text/css; charset=utf-8";case".js":case".mjs":return"text/javascript; charset=utf-8";case".json":return"application/json; charset=utf-8";case".svg":return"image/svg+xml";case".png":return"image/png";case".jpg":case".jpeg":return"image/jpeg";case".gif":return"image/gif";case".webp":return"image/webp";case".ico":return"image/x-icon";case".webmanifest":return"application/manifest+json; charset=utf-8";case".wasm":return"application/wasm";default:return"application/octet-stream"}}async function oC(e,t,o,r,n,a){let i=Ql(a.settings,a.fallbackTitle),s=i.description??i.title,l=fo(o),d=await e.uploadTarget(t,ho),m=d.publicUrl.replace(/[^/]+$/,"index.html"),p=null,h=l.get("og:image")||void 0;if(!h&&r&&(h=d.publicUrl),!h){let y=await(a.draw??v$)(n??Ei(a.settings,i.title),i.description);y.png?(p=y.png,h=d.publicUrl,k(`Link preview: drew ${ho} (${1200}x${630}) from the game's name and strapline.`)):k(`Link preview: no ${ho} drawn (${y.reason}). The link will unfurl without a picture; add ${ho} at ${1200}x${630} to the game folder, or install Chrome and deploy again.`)}return{tags:{title:i.title,description:s,siteName:i.siteName,url:m,image:h,imageAlt:i.description?`${i.title}: ${i.description}`:i.title,imageWidth:1200,imageHeight:630},card:p}}async function rC(e,t,o){if(!o)return;let r=await e.uploadTarget(t,ho);await Jo(r.uploadUrl,o,"image/png",r.cacheControl)}async function v6(e,t,o,r={},n,a,i){let s=sw(o),l;try{l=aw(s)}catch{throw R(`Cannot read ${o}.`),new Error("unreachable")}let d=await Tb({path:s,relativePath:o},r.round);d&&R(`${o} ${d.why}`,["A deploy is a publishing act, and --file publishes this file as the game's","own page. Point --file at the game's HTML, or use --dir and let the gate","withhold what the page does not need."]),await a?.(s);let m=await e.uploadTarget(t,"index.html"),p=i?await oC(e,t,l.toString("utf8"),!1,n,i):null,h=p?ji(l.toString("utf8"),p.tags):l.toString("utf8");await rC(e,t,p?.card??null);let y=nC(q2(Pi(h),n),`${m.playerApiOrigin}`,t);await Jo(m.uploadUrl,y,"text/html; charset=utf-8",m.cacheControl);let w=await e.uploadTarget(t,ot);await Jo(w.uploadUrl,qr,"text/javascript; charset=utf-8",w.cacheControl);let I=await e.uploadTarget(t,qe);await Jo(I.uploadUrl,Bt,"text/javascript; charset=utf-8",I.cacheControl);let L=await e.uploadTarget(t,Pn);return await Jo(L.uploadUrl,Ii,"image/svg+xml",L.cacheControl),U()||(g(),k(`Uploaded ${o} to ${Kd(m)}`),k(`Wired it to ${m.playerApiOrigin} as "${t}"`),k(`Shipped @monterosa/gamestage beside it (${an})`),k(`Shipped the player client beside it (${Bo})`)),Kd(m)}async function w6(e,t,o,r,n){if(r||!e||!t)return;let{browserCheck:a}=await Promise.resolve().then(()=>(Zo(),nw));x6(await a(e,t,o,n))}function k6(e){let t=e??[],o=-1;return t.forEach((a,i)=>{/^Deployed /.test(a.message)&&(o=i)}),[...o>=0?t.slice(o):t.slice(-8)].reverse().find(a=>a.level==="error"&&/not on Interaction Cloud/.test(a.message))?.message.replace(/^The game is not on Interaction Cloud: /,"Studio answered: ")}function _6(e,t,o){let r=e.studioUrl??Ai(e.id);return[`${v.bold(`No ${t} yet: add one in Studio.`)}`,` ${v.cyan(r)}`,"",e.studioUrl?" The game is online and its Studio project exists, so a fan opening it now":" The game is online, and Stage links to its Studio project once it has one, so a fan opening it now",` finds nothing to play. Write the first ${t} in Studio and it appears`,` without another deploy. Share the game once a ${t} is on.`,"",` ${v.cyan(re("dev --serve"))} try the game on this machine with a sample ${o.toLowerCase()} meanwhile`]}function x6(e){if(e.status==="verified"){O("Checked","the page loads and plays in a browser"),g();return}if(e.status==="skipped"||e.status==="n/a"){k(v.dim(`Not checked in a browser: ${e.detail??""}`.trim())),g();return}j("The published page did not start"),g(` ${e.detail??""}`),g(),k("The files are published, so the game is live and broken rather than unpublished."),k(`${v.cyan(re("verify"))} the same check, with the rest of them`),g(),process.exitCode=1}function S6(e){for(let t of e.walkedPast)k(`Walked past ${t}: it is a toolchain directory, not your game.`);for(let t of e.allowed)k(`Published ${t.path} because you allowed it.`);for(let t of e.withheld)k(`Withheld ${t.path} from the upload: it ${t.why}`);e.refuse&&R(`${e.refuse.path} ${e.refuse.why}`,["A deploy is a publishing act, so this file would sit at a public URL beside","your game. Remove it from the directory, or point --dir at a directory that","does not contain it, and deploy again."])}async function T6(e,t,o,r={},n,a,i){let s,l=[];try{let $=Mi(o,{symlinks:"throw"});s=$.files,l=$.withheld}catch($){throw R($ instanceof Error?$.message:`Cannot read ${o}.`),new Error("unreachable")}let d=await p$(s,{...r,exempt:[qe,ot]});S6(d);let m=d.publish,p=m.find($=>$.relativePath==="index.html");p||R(`Directory ${o} must contain an index.html file.`),await a?.(p.path);let h=k$(m,l);j(`Publishing ${m.length} ${m.length===1?"file":"files"} to the playground`);for(let $ of h.lines)k($);h.named.length&&(g(),k("The lines above are named because they are not ordinary web assets. Anything there you did not mean to publish, stop and remove it: a deploy puts every one of these at a public URL beside your game.")),g();let y=aw(p.path,"utf8"),w=i?await oC(e,t,y,m.some($=>$.relativePath===ho),n,i):null,I=bb(y),L=m.some($=>$.relativePath==="favicon.ico"),J=m.some($=>$.relativePath===Pn),Q=!I&&!L,q=Q&&!J,_=rw();if(_!=="0.0.0-test"){let $=`${He}/client/${_}/${qe}`,E=!1;try{E=(await fetch($,{method:"HEAD"})).ok}catch{E=!0}E||R(`The client this deploy would pin, ${_}, is not published yet.`,[`Every page uploaded here will import ${$},`,"which answers 404 today. The game would load, fetch nothing, and show a","blank screen with no error anywhere.","","Deploy the site first: it is what serves /client/<version>/.","",`${v.cyan("node scripts/deploy.mjs site")} then run this deploy again`])}let T;for(let $ of m){if($.relativePath===qe||$.relativePath===ot)continue;let E;try{E=await e.uploadTarget(t,$.relativePath)}catch(ce){throw new Error(`${$.relativePath} cannot be published: ${ce instanceof Error?ce.message:String(ce)}`,{cause:ce})}$.relativePath==="index.html"&&(T=E);let z=aw($.path),W=/\.(m?js)$/i.test($.relativePath),ae=/\.html$/i.test($.relativePath)?nC(F2($.relativePath==="index.html"?q2((()=>{let ce=w?ji(z.toString("utf8"),w.tags):z.toString("utf8");return Q?Pi(ce):ce})(),n):z.toString("utf8"),rw()),E.playerApiOrigin,t):W?F2(z.toString("utf8"),rw()):z;await Jo(E.uploadUrl,ae,b6($.relativePath),E.cacheControl)}if(await rC(e,t,w?.card??null),q){let $=await e.uploadTarget(t,Pn);await Jo($.uploadUrl,Ii,"image/svg+xml",$.cacheControl)}let Y=[...m.map($=>$.relativePath),...q?[Pn]:[],...w?.card?[ho]:[]];try{await e.pruneBundle(t,Y);for(let $ of d.withheld)k(`Removed ${$.path} from the playground.`)}catch($){let E=$ instanceof Error?$.message:String($),z=d.withheld.map(W=>W.path);j("The playground still holds files this deploy did not publish"),g(` ${E}`),g(),z.length?(k(`Could not remove ${z.join(", ")} from the playground: ${E}`),k("Anything an earlier deploy put there is still being served.")):k("Anything an earlier deploy put there is still being served."),g(),process.exitCode=1}if(!U()&&T&&(g(),k(`Uploaded ${m.length} files from ${o}`),k(`Playground: ${Kd(T)}`),k(`Wired it to ${T.playerApiOrigin} as "${t}"`),q&&k("Added a replaceable starter favicon")),!T)throw new Error("The directory index was not uploaded.");return Kd(T)}async function E6(e,t,o,r){let n=!0;try{let p=je(await hn(o,"utf8"));p.ok&&(n=p.manifest.identity?.consent?.analytics_requires_consent!==!1)}catch{}let{consentGate:a}=await Promise.resolve().then(()=>(Zo(),nw)),i=r?await a(t,e,n):{status:"skipped",detail:"asked not to open a browser (--no-check)."};if(i.status==="verified"){O("Consent","a fan is asked before anything is recorded");return}i.status==="open"&&R("This game would record fans without asking them first, so nothing was published.",[i.detail??"","",`${v.cyan(re("verify"))} the same check, with the rest of them`]);let s="";try{s=await hn(t,"utf8")}catch{return}let l=/gamestage(\.min)?\.js|@monterosa\/gamestage/.test(s),d=/consentBanner\s*:\s*false/.test(s),m=/data-gs-component=["']consent["']|<Consent\b|game\.consent\.decide\(/.test(s);n&&(!l||d&&!m)&&R("This game does not ask fans for consent, so nothing was published.",[l?"The page turns the consent banner off and draws no consent screen of its own.":"The page does not load the Gamestage client, which draws the consent banner.",`${v.cyan(re("client"))} add the client, then deploy again`]),k(v.dim(`Consent checked by reading the page, not in a browser: ${i.detail??""}`.trim()))}async function $6(e,t){let o=!0;try{let a=je(await hn(t,"utf8"));a.ok&&(o=a.manifest.identity?.consent?.analytics_requires_consent!==!1)}catch{}if(!o)return;let r=hs.filter(a=>!e?.[a]?.trim()),n=e?.privacy_policy_url?.trim()??"";r.length===0&&/^https:\/\/[^\s]+$/.test(n)||R("The consent banner would not say who is asking, so nothing was published.",[r.length?`${On} has no ${r.join(" or ")}.`:`privacy_policy_url must be an https address, and is "${n}".`,"Add your brand as consent_brand_name and your privacy policy's address as","privacy_policy_url. A fan is told who is recording them before they answer."])}Wo();uo();ke();import{readFile as pC,stat as M6}from"node:fs/promises";import{createServer as F6}from"node:http";import{extname as U6,join as G6,normalize as B6,resolve as pw,sep as q6}from"node:path";ke();var iC="player-conformance",uw="round-current",A6="sha256:emulator-conformance";function jn(e){return structuredClone(e)}function fn(){return{server_time:"2026-08-01T09:00:00.000Z",snapshot:A6}}var C6="2026-08-01T08:00:00.000Z";function I6(e){let t=e==="per-player-challenge",o=e==="locked";return{...fn(),id:uw,number:412,version:2,...o?{locks_at:C6}:{},can:{accepting_plays:!o,results_available:!1,solution_revealed:!1,closed:!1,optimistic_play:!1},challenge_instance_id:t?"challenge-player-conformance":null,challenge:{prompt:"alpha"}}}function aC(e,t){let o=t==="mistakes";return{...fn(),player_id:iC,round_id:e,attempts_used:o?6:0,attempts_allowed:10,mistakes_used:o?2:0,mistakes_allowed:4,progress:o?{solved:["group-1"]}:{},score:o?10:0,score_revision:0,finished:!1,outcome:o?"incomplete":void 0}}function P6(e){let t=I6(e),o=new Map([[t.id,t]]),r=new Map([[t.id,aC(t.id,e)]]);return e==="solution-disclosure"&&(o.set("round-revealed",{...t,id:"round-revealed",number:411,version:3,can:{accepting_plays:!1,results_available:!0,solution_revealed:!0,closed:!0,optimistic_play:!1},solution:{answer:"revealed-alpha"}}),r.set("round-revealed",aC("round-revealed",e))),{runtime:{...fn(),game:"conformance-game",api_version:"2.0",archetype:e==="at-settlement"?"predict":"group",marking:e==="at-settlement"?"at_settlement":"at_commit",challenge_source:e==="per-player-challenge"?"per_player":"shared",schedule:{kind:"continuous"},updates:{transport:"poll",freshness_seconds:30},display:{title:"Conformance game"},identity:{required:!1,provider:"identify",anonymous_play:!0},archive:!0,capabilities:["plays","profile","leaderboard"]},rounds:o,roundStates:r,leaderboard:{...fn(),round_id:uw,order:"high_first",tie_break:"earliest_play",entries:[{rank:1,player_id:"player-example",display_name:"Example",score:20}],total:1,truncated:!1},profile:{...fn(),player_id:iC,display_name:"Example",played:0,won:0,current_streak:0,max_streak:0,distribution:{},constraints:{}},plays:new Map,intents:new Map,nextPlay:1}}function Yd(e,t){return{...fn(),play_id:`rejected-${e.nextPlay++}`,outcome:"rejected",reason:t,round_version:2,marked:!1,feedback:[]}}function mw(e){let t=P6(e);return{async getRuntime(){return jn(t.runtime)},async getCurrentRound(){return jn(t.rounds.get(uw))},async getRound(o){let r=t.rounds.get(o);return r?jn(r):void 0},async play(o,r){let n=t.rounds.get(o);if(!n)return Yd(t,"round_not_found");let a=bl({round_id:o,round_version:r.round_version,challenge_instance_id:r.challenge_instance_id,payload:r.payload}),i=t.plays.get(r.idempotency_key);if(i)return t.intents.get(r.idempotency_key)!==a?Yd(t,"idempotency_conflict"):{...jn(i),outcome:"duplicate"};if(r.round_version!==n.version)return{...fn(),play_id:`stale-${t.nextPlay++}`,outcome:"stale",reason:"round_version",round_version:n.version,marked:!1,feedback:[]};if(n.challenge_instance_id!==null&&r.challenge_instance_id!==n.challenge_instance_id)return Yd(t,"challenge_instance_id");if(n.locks_at!==void 0&&n.locks_at<=fn().server_time)return Yd(t,"lock_deadline_passed");let s=t.roundStates.get(o),l=t.runtime.marking==="at_settlement",d={...s,...fn(),attempts_used:s.attempts_used+1,score:s.score+(l?0:10),finished:!l,outcome:l?"pending":"won"},m={...fn(),play_id:`play-${t.nextPlay++}`,outcome:"accepted",round_version:n.version,marked:!l,feedback:l?[]:[{key:"answer",verdict:"correct"}],round_state:jn(d)};return t.roundStates.set(o,d),t.plays.set(r.idempotency_key,m),t.intents.set(r.idempotency_key,a),d.finished&&!s.finished&&(t.profile=yl(t.profile,d.outcome)),jn(m)},async getRoundState(o){let r=t.roundStates.get(o);if(!r)throw new Error(`No such round: ${o}`);return jn(r)},async getProfile(){return jn(t.profile)},async getLeaderboard(){return jn(t.leaderboard)}}}function O6(){return e=>mw(e)}var FX=O6();ke();import{createServer as z6}from"node:http";function Qo(e){let t=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return new RegExp(`^${t.replace(/\\\{[^}]+\\\}/g,"([^/]+)")}$`)}var R6=Qo(ze.runtime),sC=Qo(ze.currentRound),cC=Qo(ze.round),lC=Qo(ze.plays),dC=Qo(ze.roundState),N6=Qo(ze.profile),j6=Qo(ze.leaderboard),uC={"access-control-allow-origin":"*","access-control-allow-methods":"GET, POST, OPTIONS","access-control-allow-headers":"authorization, content-type, x-gamestage-player","access-control-max-age":"600"};function _o(e,t,o){let r=JSON.stringify(o);e.writeHead(t,{...uC,"content-type":"application/json; charset=utf-8","content-length":Buffer.byteLength(r)}),e.end(r)}function Xo(e,t,o,r){_o(e,t,{error:{code:o,message:r,retryable:!1}})}async function L6(e){let t=[];for await(let o of e)t.push(Buffer.from(o));if(t.length!==0)return JSON.parse(Buffer.concat(t).toString("utf8"))}async function D6(e,t,o,r,n){if(!e.url){Xo(t,400,"invalid_request","The request URL is missing.");return}let i=new URL(e.url,"http://localhost").pathname;if(e.method==="OPTIONS"){t.writeHead(204,uC),t.end();return}if(n&&(sC.test(i)||cC.test(i)||lC.test(i)||dC.test(i))){Xo(t,404,"no_round",n);return}if(e.method==="GET"){if(r&&/^\/(client\/[^/]+\/)?gamestage\.js$/.test(i)){t.writeHead(200,{"content-type":"text/javascript; charset=utf-8","cache-control":"no-store","access-control-allow-origin":"*","content-length":Buffer.byteLength(r)}),t.end(r);return}if(R6.test(i)){_o(t,200,await o.getRuntime());return}if(sC.test(i)){_o(t,200,await o.getCurrentRound());return}let s=cC.exec(i);if(s){let d=await o.getRound(decodeURIComponent(s[2]));if(!d){Xo(t,404,"round_not_found","The requested round was not found.");return}_o(t,200,d);return}let l=dC.exec(i);if(l){let d=decodeURIComponent(l[2]);try{_o(t,200,await o.getRoundState(d))}catch{Xo(t,404,"round_not_found","The requested round was not found.")}return}if(N6.test(i)){_o(t,200,await o.getProfile());return}if(j6.test(i)){_o(t,200,await o.getLeaderboard());return}}if(e.method==="POST"){let s=lC.exec(i);if(s){try{let l=await L6(e);_o(t,200,await o.play(decodeURIComponent(s[2]),l))}catch(l){Xo(t,400,"invalid_request",l instanceof SyntaxError?"The request body must be valid JSON.":"The request body is invalid.")}return}}Xo(t,404,"not_found","The requested player API route was not found.")}function Vd(e="default",t,o){let r=mw(e);return z6((n,a)=>{D6(n,a,r,t,o).catch(()=>{a.headersSent?a.destroy():Xo(a,500,"internal_error","The emulator could not answer the request.")})})}sn();Bd();ut();Zo();$e();async function W6(e){let t;try{t=await pC(e,"utf8")}catch{return}let o=je(t);if(!o.ok){R(`${e} is not a valid App Manifest.`,o.issues.map(r=>`${v.cyan(r.path)} ${r.message}`));return}return o.manifest}var H6={unconfigured:"No round yet. Set one up in Studio, or add one to gamestage.yaml to play it locally.","studio-round":"This game's round is in Studio, which gamestage dev cannot reach. Play the deployed game, or add a round to gamestage.yaml to play it locally."};async function K6(e){let t=Number(e.port);if(!Number.isInteger(t)||t<0||t>65535)throw new Error("--port must be an integer between 0 and 65535");let o=e.scenario??"default";if(e.fixture)return{server:Vd(o,Bt),what:"fixture",fixtureReason:"requested",game:"conformance-game"};let r=await W6(e.manifest??"gamestage.yaml");if(!r)return{server:Vd(o,Bt),what:"fixture",fixtureReason:"no-manifest",game:"conformance-game"};let n=r.backend.archetype,a=!r.backend.round&&n&&pn.includes(n)?ko(n):void 0,i=r.backend.round??a;if(!i){let l=r.interaction_cloud.elements.length?"studio-round":"unconfigured";return{server:Vd(o,Bt,H6[l]),what:"fixture",fixtureReason:l,game:r.app.id,title:r.app.title}}let s=r.backend.archetype;return s&&s!==i.archetype&&R(`The manifest declares the ${s} format and a ${i.archetype} round.`,["One of the two is wrong. The round decides what the Engine marks."]),pn.includes(i.archetype)||R(`No Engine here serves the ${i.archetype} format yet.`,[`Built so far: ${pn.join(", ")}. \`gamestage dev --fixture\` serves`,"the contract fixture if you are working against the wire rather than the rules."]),{server:await ma({game:r.app.id,round:i,title:r.app.title,identityRequired:!!e.as,clientBundle:Bt}),what:"engine",game:r.app.id,round:i,title:r.app.title,containerLabel:r.experience.container_label,as:e.as,...a?{sample:!0}:{}}}var Y6={".html":"text/html; charset=utf-8",".js":"text/javascript; charset=utf-8",".mjs":"text/javascript; charset=utf-8",".css":"text/css; charset=utf-8",".json":"application/json; charset=utf-8",".svg":"image/svg+xml",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".webp":"image/webp",".ico":"image/x-icon",".woff2":"font/woff2"};function V6(e,t){let o=(n,a)=>`if (!window.${n}) window.${n} = ${JSON.stringify(a)};
|
|
13991
13991
|
`,r="<script>\n// Added by `gamestage dev --serve` as it served this page. Not in your file.\n"+o("GAMESTAGE_API",t.api)+o("GAMESTAGE_GAME",t.game)+(t.token?o("GAMESTAGE_TOKEN",t.token):"")+(t.presentation?`if (!window.GAMESTAGE_PRESENTATION) window.GAMESTAGE_PRESENTATION = ${JSON.stringify(t.presentation)};
|
|
13992
13992
|
`:"")+`</script>
|
|
13993
13993
|
`;return/<head[^>]*>/i.test(e)?e.replace(/<head[^>]*>/i,n=>`${n}
|
package/package.json
CHANGED