@puzzmo/sdk 1.0.74 → 1.0.76

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.
@@ -0,0 +1,2 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=e=>e,t=e=>e;exports.createAppBundle=e,exports.createServerBundle=t;
2
+ //# sourceMappingURL=bundles.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bundles.cjs","names":[],"sources":["../src/bundles.ts"],"sourcesContent":["/**\n * Helpers for writing a game's bundles, so the public app bundle and the private server bundle are\n * written the same way. Free of side effects, so importing them never pulls the SDK into a bundle.\n *\n * ```ts\n * // src/appBundle.ts, built by appBundlePlugin\n * export default createAppBundle({ renderThumbnail })\n *\n * // src/serverBundle.ts, built by serverBundlePlugin\n * export default createServerBundle({ achievements: { describe, replayRound } })\n * ```\n */\nimport type { AppBundle, ServerBundle } from \"./types\"\n\n/** Types a game's app bundle: the public code Puzzmo and players' browsers call, such as its thumbnail renderer */\nexport const createAppBundle = <T extends AppBundle>(bundle: T): T => bundle\n\n/** Types a game's server bundle: the private code only Puzzmo calls, such as the replay achievements read */\nexport const createServerBundle = <T extends ServerBundle>(bundle: T): T => bundle\n\nexport type {\n AchievementCounterDescription,\n AchievementEventDescription,\n AchievementFactDescription,\n AchievementsDescription,\n AchievementsServerCapability,\n AppBundle,\n RoundReplayInput,\n RoundReplayResult,\n ServerBundle,\n ServerCallConfig,\n ThumbnailConfig,\n ThumbnailResult,\n} from \"./types\"\n"],"mappings":"mEAeA,MAAa,EAAwC,GAAiB,EAGzD,EAA8C,GAAiB"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Helpers for writing a game's bundles, so the public app bundle and the private server bundle are
3
+ * written the same way. Free of side effects, so importing them never pulls the SDK into a bundle.
4
+ *
5
+ * ```ts
6
+ * // src/appBundle.ts, built by appBundlePlugin
7
+ * export default createAppBundle({ renderThumbnail })
8
+ *
9
+ * // src/serverBundle.ts, built by serverBundlePlugin
10
+ * export default createServerBundle({ achievements: { describe, replayRound } })
11
+ * ```
12
+ */
13
+ import type { AppBundle, ServerBundle } from "./types";
14
+ /** Types a game's app bundle: the public code Puzzmo and players' browsers call, such as its thumbnail renderer */
15
+ export declare const createAppBundle: <T extends AppBundle>(bundle: T) => T;
16
+ /** Types a game's server bundle: the private code only Puzzmo calls, such as the replay achievements read */
17
+ export declare const createServerBundle: <T extends ServerBundle>(bundle: T) => T;
18
+ export type { AchievementCounterDescription, AchievementEventDescription, AchievementFactDescription, AchievementsDescription, AchievementsServerCapability, AppBundle, RoundReplayInput, RoundReplayResult, ServerBundle, ServerCallConfig, ThumbnailConfig, ThumbnailResult, } from "./types";
19
+ //# sourceMappingURL=bundles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bundles.d.ts","sourceRoot":"","sources":["../src/bundles.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAEtD,mHAAmH;AACnH,eAAO,MAAM,eAAe,GAAI,CAAC,SAAS,SAAS,EAAE,QAAQ,CAAC,KAAG,CAAW,CAAA;AAE5E,6GAA6G;AAC7G,eAAO,MAAM,kBAAkB,GAAI,CAAC,SAAS,YAAY,EAAE,QAAQ,CAAC,KAAG,CAAW,CAAA;AAElF,YAAY,EACV,6BAA6B,EAC7B,2BAA2B,EAC3B,0BAA0B,EAC1B,uBAAuB,EACvB,4BAA4B,EAC5B,SAAS,EACT,gBAAgB,EAChB,iBAAiB,EACjB,YAAY,EACZ,gBAAgB,EAChB,eAAe,EACf,eAAe,GAChB,MAAM,SAAS,CAAA"}
@@ -0,0 +1,5 @@
1
+ /** Types a game's app bundle: the public code Puzzmo and players' browsers call, such as its thumbnail renderer */
2
+ const e = (e) => e, t = (e) => e;
3
+ export { e as createAppBundle, t as createServerBundle };
4
+
5
+ //# sourceMappingURL=bundles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bundles.js","names":[],"sources":["../src/bundles.ts"],"sourcesContent":["/**\n * Helpers for writing a game's bundles, so the public app bundle and the private server bundle are\n * written the same way. Free of side effects, so importing them never pulls the SDK into a bundle.\n *\n * ```ts\n * // src/appBundle.ts, built by appBundlePlugin\n * export default createAppBundle({ renderThumbnail })\n *\n * // src/serverBundle.ts, built by serverBundlePlugin\n * export default createServerBundle({ achievements: { describe, replayRound } })\n * ```\n */\nimport type { AppBundle, ServerBundle } from \"./types\"\n\n/** Types a game's app bundle: the public code Puzzmo and players' browsers call, such as its thumbnail renderer */\nexport const createAppBundle = <T extends AppBundle>(bundle: T): T => bundle\n\n/** Types a game's server bundle: the private code only Puzzmo calls, such as the replay achievements read */\nexport const createServerBundle = <T extends ServerBundle>(bundle: T): T => bundle\n\nexport type {\n AchievementCounterDescription,\n AchievementEventDescription,\n AchievementFactDescription,\n AchievementsDescription,\n AchievementsServerCapability,\n AppBundle,\n RoundReplayInput,\n RoundReplayResult,\n ServerBundle,\n ServerCallConfig,\n ThumbnailConfig,\n ThumbnailResult,\n} from \"./types\"\n"],"mappings":";AAeA,MAAa,KAAwC,MAAiB,GAGzD,KAA8C,MAAiB"}
@@ -1926,5 +1926,5 @@ http://errors.angularjs.org/"NG_VERSION_FULL"/`+(e?e+`/`:``)+i,c=n,s=`?`;c<r.len
1926
1926
  </div>
1927
1927
  </div>
1928
1928
  </div>
1929
- `,document.body.appendChild(_);let v=_.querySelector(`#simulator-panel`),y=_.querySelector(`#simulator-header`),b=_.querySelector(`#simulator-header-indicator`),x=_.querySelector(`#simulator-header-status-text`),S=_.querySelector(`#simulator-header-pause`),C=_.querySelector(`#simulator-header-retry`),w=_.querySelector(`#simulator-header-settings`),T=_.querySelector(`#simulator-toggle`),E=_.querySelector(`#simulator-timer`),D=_.querySelector(`#simulator-tabs`),O=_.querySelector(`#simulator-content`),k=e=>_.querySelector(e),A=e=>{S.innerHTML=e?g.play:g.pause,S.title=e?`Resume`:`Pause`},j=(e,t)=>{let n=k(`#simulator-status .text`),r=k(`#simulator-status .indicator`),i=t===`complete`?`✓`:``;n&&(n.textContent=e),r&&(r.className=`indicator ${t}`,r.textContent=i),b.className=t,b.textContent=i,x.textContent=e},M=(e,t)=>{t&&t!==`0`?E.innerHTML=`${e}<span class="penalty">+${t}</span>`:E.textContent=e},F=e=>{var t;h.activeTab=e,O.classList.remove(`hidden`),ne(e),D.querySelectorAll(`.simulator-tab`).forEach(t=>{t.classList.toggle(`active`,t.getAttribute(`data-tab`)===e)}),_.querySelectorAll(`.simulator-tab-content`).forEach(t=>{t.classList.toggle(`active`,t.id===`simulator-tab-${e}`)}),w.classList.toggle(`active`,e===`auth`);let n=p.find(t=>t.id===e);n==null||(t=n.onActivate)==null||t.call(n,H)},I=e=>{h.isCollapsed=e,v.classList.toggle(`collapsed`,e),te(e),e?(O.classList.add(`hidden`),D.querySelectorAll(`.simulator-tab`).forEach(e=>e.classList.remove(`active`))):F(h.activeTab)},L=()=>{f.updatePreview(H)},R=function(){var e=n.t(function*(){var e,t;if(h.appliedPuzzleOverride!==null)return h.appliedPuzzleOverride;if(h.puzzleData)return h.puzzleData;if(!l||l.size===0)throw Error(`No fixtures configured. Add puzzle fixture files (.json or .toml) to a fixtures directory and pass fixturesGlob to the simulator.`);let n=(e=h.selectedCategory)==null?u[0]:e,r=n?l.get(n):void 0;if(!r||r.size===0)throw Error(`No puzzles found in fixture category "${n}"`);let i=(t=h.selectedPuzzle)==null?r.keys().next().value:t,a=i?r.get(i):void 0;if(!a)throw Error(`Puzzle "${i}" not found in category "${n}"`);h.puzzleData=a,console.log(`Simulator: Puzzle loaded from fixtures`,{category:n,puzzle:i}),h.originalPuzzle=a;let o=k(`#simulator-puzzle`);return o&&(o.value=h.originalPuzzle),h.activeTab===`thumb`&&L(),h.puzzleData});return function(){return e.apply(this,arguments)}}(),z=N(e=>{d.addLogEntry(e,H)}),B=(e,t)=>{P(e,t,z)},se=e=>{var t;let n=(t=e.buckets)!=null&&t.length?e.buckets:u,r=n.find(e=>{var t;return!(!(l==null||(t=l.get(e))==null)&&t.size)});if(r!==void 0||!n.length)return{nonce:e.nonce,error:`No fixtures in "${r==null?``:r}" to stand in for a pool`,failed:!0};let i=n.flatMap(e=>[...l.get(e).keys()].map(t=>`fixtures/${e}/${t}`)),a=i.filter(t=>{var n;return!((n=e.exclude)!=null&&n.includes(t))}),o=a.length?a:i,s=o[Math.floor(Math.random()*o.length)],[,c,...d]=s.split(`/`);return{nonce:e.nonce,puzzle:{key:s,puzzle:l.get(c).get(d.join(`/`))}}},V=(e,t)=>{let n=_.querySelector(`[data-badge="${e}"]`);n&&(n.textContent=t&&t>0?String(t):``)},H={state:h,getElement:k,sendToGame:B,logMessage:z.log,loadPuzzle:R,updateStatus:j,updateTimer:M,setCollapsed:I,switchTab:F,updateThumbnail:L,updateBadge:V,fixtures:l,fixtureCategories:u,gameSlug:(s=e.slug)==null?null:s};console.log(`[Simulator] Context created with gameSlug:`,H.gameSlug),p.forEach(e=>e.bind(H)),D.querySelectorAll(`.simulator-tab`).forEach(e=>{e.addEventListener(`click`,()=>{let t=e.getAttribute(`data-tab`);F(t),V(t,0)})}),T.addEventListener(`click`,e=>{e.stopPropagation(),I(!0)}),S.addEventListener(`click`,e=>{e.stopPropagation(),h.isPaused?(B(`RESUME_GAME`,{}),h.isPaused=!1,A(!1),j(`Running`,`ready`)):(B(`PAUSE_GAME`,{}),h.isPaused=!0,A(!0),j(`Paused`,`paused`));let t=k(`#simulator-pause`);t&&(t.textContent=h.isPaused?`Resume`:`Pause`)}),C.addEventListener(`click`,e=>{e.stopPropagation(),B(`RETRY_PUZZLE`,{}),h.hasStarted=!1,h.isPaused=!1,A(!1),S.disabled=!0,j(`Ready to retry`,`ready`);let t=k(`#simulator-pause`),n=k(`#simulator-start`);t&&(t.disabled=!0,t.textContent=`Pause`),n&&(n.textContent=`Start`)}),w.addEventListener(`click`,e=>{e.stopPropagation(),h.isCollapsed&&I(!1),F(`auth`)}),y.addEventListener(`click`,e=>{h.isCollapsed&&e.target!==T&&I(!1)}),h.isCollapsed||F(h.activeTab);let U=new URLSearchParams(window.location.search);(U.has(`code`)||U.has(`error`))&&(I(!1),F(`auth`));let le=e=>{let t={additionalTimeAddedSecs:0,boardState:h.currentInputStr,combinedTimeSecs:0,completed:!1,createdAt:new Date().toISOString(),elapsedTimeSecs:0,id:`simulator-gameplay-${Date.now()}`,ownerID:`simulator-owner`,pointsAwarded:0,slug:`simulator-game`,viewerOwnsPuzzle:!0},n=e===null?void 0:{gameplay:t,puzzle:{id:`simulator-puzzle`,name:`Proto Jig Puzzle`,puzzle:e,mostRecentDaily:null}};return{userState:{gameSettings:{"proto-game":h.gameSettings},id:`simulator-user`,ownerID:`simulator-owner`},currentUser:{id:`simulator-user`,name:`Simulator`,username:`simulator`,usernameID:`0000`,type:`User`,roles:``},game:qt,session:n,viewerStorage:h.userStorage,theme:h.selectedTheme,hostContext:h.hostContext,appRuntimeContract:`1.0`}},W=[`1.0`,`1.1`],G=function(){var r=n.t(function*(n){let r=e.session!==!1||n===`1.0`;r?e.session===!1&&console.warn("Simulator: `session: false` needs a game built on an SDK speaking runtime contract 1.1 or later"):console.log(`Simulator: Sending READY_DATA without a session`),j(r?`Loading puzzle...`:`Sending READY_DATA...`,`waiting`);try{let e=t.t(t.t({},le(r?yield R():null)),{},{appRuntimeContract:n});j(`Sending READY_DATA...`,`waiting`),B(`READY_DATA`,e),j(`Waiting for game to load...`,`waiting`)}catch(e){j(`Error: ${e}`,`paused`)}});return function(e){return r.apply(this,arguments)}}(),ue=()=>{console.log(`Simulator: Game loaded, ready to start`),C.disabled=!1,p.forEach(e=>{var t;return(t=e.onMessage)==null?void 0:t.call(e,`READY_GAME_LOADED`,void 0,H)}),c&&!h.hasStarted&&setTimeout(()=>{let e=k(`#simulator-start`);e==null||e.click(),S.disabled=!1,h.hasStarted=!0,j(`Running`,`ready`)},100)};return re((e,t)=>{var n,r;if(e===`READY`){console.log(`Simulator: Received READY from game`),G(W.includes(t==null?void 0:t.runtimeContract)?t.runtimeContract:`1.0`);return}if(e===`READY_GAME_LOADED`){ue();return}if(e===`TIMER_TICK`){if(t!=null&&t.display){let[e,n]=t.display;M(e,n)}return}if(e===`TIMER_SYNC`)return;if(e===`SIDEBAR_UPDATE`){console.log(`Simulator: Sidebar update`,t);return}p.forEach(n=>{var r;return(r=n.onMessage)==null?void 0:r.call(n,e,t,H)});let i=(n=t==null||(r=t.input)==null?void 0:r.boardState)==null?t==null?void 0:t.boardState:n;if(e===`UPLOAD_NEW_GAME_STATE`&&i&&(h.currentInputStr=i,h.activeTab===`thumb`&&L(),console.log(`Simulator: Game state uploaded`,t)),e===`COMPLETE_REPEATABLE_RUN`&&console.log(`Simulator: Repeatable run completed`,t),e===`REQUEST_PUZZLE`){B(`PUZZLE_DATA`,se(t));return}if(e===`UPDATE_GAME_USER_STATE`&&typeof(t==null?void 0:t.state)==`string`){var a;h.userStorage={state:t.state,stateVersion:(a=t.stateVersion)==null?1:a},console.log(`Simulator: Game user storage updated`,t)}e===`GAME_COMPLETED`&&(console.log(`Simulator: Game completed!`,t),S.disabled=!0,h.hasStarted=!1,j(`Completed!`,`complete`))},z),console.log(`Simulator initialized`),$={updateFixtures:e=>{l=ie(e),u=Array.from(l.keys()).sort(),H.fixtures=l,H.fixtureCategories=u;let t=localStorage.getItem(`simulator-fixture-category`);if(!h.selectedCategory||!u.includes(h.selectedCategory)){var n;h.selectedCategory=t&&u.includes(t)?t:(n=u[0])==null?null:n}let r=p.find(e=>e.id===`ctrl`);r==null||r.bind(H),console.log(`Simulator: Fixtures updated`,{categories:u,selectedCategory:h.selectedCategory})},sendToGame:B,loadPuzzle:R},$}var qt={id:`simulator-game`,slug:`proto-game`,stableSlug:`proto-game`,displayName:`Proto Game`,version:{id:`simulator-version`,label:null,featuresArr:[0],flagsArr:[0],runtime:{id:`simulator-runtime`,version:null}}};Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return Vt}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return ae}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return Kt}});
1930
- //# sourceMappingURL=createSimulator-Bb1LTB5P.cjs.map
1929
+ `,document.body.appendChild(_);let v=_.querySelector(`#simulator-panel`),y=_.querySelector(`#simulator-header`),b=_.querySelector(`#simulator-header-indicator`),x=_.querySelector(`#simulator-header-status-text`),S=_.querySelector(`#simulator-header-pause`),C=_.querySelector(`#simulator-header-retry`),w=_.querySelector(`#simulator-header-settings`),T=_.querySelector(`#simulator-toggle`),E=_.querySelector(`#simulator-timer`),D=_.querySelector(`#simulator-tabs`),O=_.querySelector(`#simulator-content`),k=e=>_.querySelector(e),A=e=>{S.innerHTML=e?g.play:g.pause,S.title=e?`Resume`:`Pause`},j=(e,t)=>{let n=k(`#simulator-status .text`),r=k(`#simulator-status .indicator`),i=t===`complete`?`✓`:``;n&&(n.textContent=e),r&&(r.className=`indicator ${t}`,r.textContent=i),b.className=t,b.textContent=i,x.textContent=e},M=(e,t)=>{t&&t!==`0`?E.innerHTML=`${e}<span class="penalty">+${t}</span>`:E.textContent=e},F=e=>{var t;h.activeTab=e,O.classList.remove(`hidden`),ne(e),D.querySelectorAll(`.simulator-tab`).forEach(t=>{t.classList.toggle(`active`,t.getAttribute(`data-tab`)===e)}),_.querySelectorAll(`.simulator-tab-content`).forEach(t=>{t.classList.toggle(`active`,t.id===`simulator-tab-${e}`)}),w.classList.toggle(`active`,e===`auth`);let n=p.find(t=>t.id===e);n==null||(t=n.onActivate)==null||t.call(n,H)},I=e=>{h.isCollapsed=e,v.classList.toggle(`collapsed`,e),te(e),e?(O.classList.add(`hidden`),D.querySelectorAll(`.simulator-tab`).forEach(e=>e.classList.remove(`active`))):F(h.activeTab)},L=()=>{f.updatePreview(H)},R=function(){var e=n.t(function*(){var e,t;if(h.appliedPuzzleOverride!==null)return h.appliedPuzzleOverride;if(h.puzzleData)return h.puzzleData;if(!l||l.size===0)throw Error(`No fixtures configured. Add puzzle fixture files (.json or .toml) to a fixtures directory and pass fixturesGlob to the simulator.`);let n=(e=h.selectedCategory)==null?u[0]:e,r=n?l.get(n):void 0;if(!r||r.size===0)throw Error(`No puzzles found in fixture category "${n}"`);let i=(t=h.selectedPuzzle)==null?r.keys().next().value:t,a=i?r.get(i):void 0;if(!a)throw Error(`Puzzle "${i}" not found in category "${n}"`);h.puzzleData=a,console.log(`Simulator: Puzzle loaded from fixtures`,{category:n,puzzle:i}),h.originalPuzzle=a;let o=k(`#simulator-puzzle`);return o&&(o.value=h.originalPuzzle),h.activeTab===`thumb`&&L(),h.puzzleData});return function(){return e.apply(this,arguments)}}(),z=N(e=>{d.addLogEntry(e,H)}),B=(e,t)=>{P(e,t,z)},se=e=>{var t;let n=(t=e.buckets)!=null&&t.length?e.buckets:u,r=n.find(e=>{var t;return!(!(l==null||(t=l.get(e))==null)&&t.size)});if(r!==void 0||!n.length)return{nonce:e.nonce,error:`No fixtures in "${r==null?``:r}" to stand in for a pool`,failed:!0};let i=n.flatMap(e=>[...l.get(e).keys()].map(t=>`fixtures/${e}/${t}`)),a=i.filter(t=>{var n;return!((n=e.exclude)!=null&&n.includes(t))}),o=a.length?a:i,s=o[Math.floor(Math.random()*o.length)],[,c,...d]=s.split(`/`);return{nonce:e.nonce,puzzle:{key:s,puzzle:l.get(c).get(d.join(`/`))}}},V=(e,t)=>{let n=_.querySelector(`[data-badge="${e}"]`);n&&(n.textContent=t&&t>0?String(t):``)},H={state:h,getElement:k,sendToGame:B,logMessage:z.log,loadPuzzle:R,updateStatus:j,updateTimer:M,setCollapsed:I,switchTab:F,updateThumbnail:L,updateBadge:V,fixtures:l,fixtureCategories:u,gameSlug:(s=e.slug)==null?null:s};console.log(`[Simulator] Context created with gameSlug:`,H.gameSlug),p.forEach(e=>e.bind(H)),D.querySelectorAll(`.simulator-tab`).forEach(e=>{e.addEventListener(`click`,()=>{let t=e.getAttribute(`data-tab`);F(t),V(t,0)})}),T.addEventListener(`click`,e=>{e.stopPropagation(),I(!0)}),S.addEventListener(`click`,e=>{e.stopPropagation(),h.isPaused?(B(`RESUME_GAME`,{}),h.isPaused=!1,A(!1),j(`Running`,`ready`)):(B(`PAUSE_GAME`,{}),h.isPaused=!0,A(!0),j(`Paused`,`paused`));let t=k(`#simulator-pause`);t&&(t.textContent=h.isPaused?`Resume`:`Pause`)}),C.addEventListener(`click`,e=>{e.stopPropagation(),B(`RETRY_PUZZLE`,{}),h.hasStarted=!1,h.isPaused=!1,A(!1),S.disabled=!0,j(`Ready to retry`,`ready`);let t=k(`#simulator-pause`),n=k(`#simulator-start`);t&&(t.disabled=!0,t.textContent=`Pause`),n&&(n.textContent=`Start`)}),w.addEventListener(`click`,e=>{e.stopPropagation(),h.isCollapsed&&I(!1),F(`auth`)}),y.addEventListener(`click`,e=>{h.isCollapsed&&e.target!==T&&I(!1)}),h.isCollapsed||F(h.activeTab);let U=new URLSearchParams(window.location.search);(U.has(`code`)||U.has(`error`))&&(I(!1),F(`auth`));let le=e=>{let t={additionalTimeAddedSecs:0,boardState:h.currentInputStr,combinedTimeSecs:0,completed:!1,createdAt:new Date().toISOString(),elapsedTimeSecs:0,id:`simulator-gameplay-${Date.now()}`,ownerID:`simulator-owner`,pointsAwarded:0,slug:`simulator-game`,viewerOwnsPuzzle:!0},n=e===null?void 0:{gameplay:t,puzzle:{id:`simulator-puzzle`,name:`Proto Jig Puzzle`,puzzle:e,mostRecentDaily:null}};return{userState:{gameSettings:{"proto-game":h.gameSettings},id:`simulator-user`,ownerID:`simulator-owner`},currentUser:{id:`simulator-user`,name:`Simulator`,username:`simulator`,usernameID:`0000`,type:`User`,roles:``},game:qt,session:n,viewerStorage:h.userStorage,theme:h.selectedTheme,hostContext:h.hostContext,appRuntimeContract:`1.0`}},W=[`1.0`,`1.1`],G=function(){var r=n.t(function*(n){let r=e.session!==!1||n===`1.0`;r?e.session===!1&&console.warn("Simulator: `session: false` needs a game built on an SDK speaking runtime contract 1.1 or later"):console.log(`Simulator: Sending READY_DATA without a session`),j(r?`Loading puzzle...`:`Sending READY_DATA...`,`waiting`);try{let e=t.t(t.t({},le(r?yield R():null)),{},{appRuntimeContract:n});j(`Sending READY_DATA...`,`waiting`),B(`READY_DATA`,e),j(`Waiting for game to load...`,`waiting`)}catch(e){j(`Error: ${e}`,`paused`)}});return function(e){return r.apply(this,arguments)}}(),ue=()=>{console.log(`Simulator: Game loaded, ready to start`),C.disabled=!1,p.forEach(e=>{var t;return(t=e.onMessage)==null?void 0:t.call(e,`READY_GAME_LOADED`,void 0,H)}),c&&!h.hasStarted&&setTimeout(()=>{let e=k(`#simulator-start`);e==null||e.click(),S.disabled=!1,h.hasStarted=!0,j(`Running`,`ready`)},100)};return re((e,t)=>{var n,r;if(e===`READY`){console.log(`Simulator: Received READY from game`),G(W.includes(t==null?void 0:t.runtimeContract)?t.runtimeContract:`1.0`);return}if(e===`READY_GAME_LOADED`){ue();return}if(e===`TIMER_TICK`){if(t!=null&&t.display){let[e,n]=t.display;M(e,n)}return}if(e===`TIMER_SYNC`)return;if(e===`SIDEBAR_UPDATE`){console.log(`Simulator: Sidebar update`,t);return}p.forEach(n=>{var r;return(r=n.onMessage)==null?void 0:r.call(n,e,t,H)});let i=(n=t==null||(r=t.input)==null?void 0:r.boardState)==null?t==null?void 0:t.boardState:n;if(e===`UPLOAD_NEW_GAME_STATE`&&i&&(h.currentInputStr=i,h.activeTab===`thumb`&&L(),console.log(`Simulator: Game state uploaded`,t)),e===`COMPLETE_REPEATABLE_RUN`&&console.log(`Simulator: Repeatable run completed`,t),e===`START_REPEATABLE_ROUND`&&console.log(`Simulator: Repeatable round started`,t),e===`REQUEST_PUZZLE`){B(`PUZZLE_DATA`,se(t));return}if(e===`UPDATE_GAME_USER_STATE`&&typeof(t==null?void 0:t.state)==`string`){var a;h.userStorage={state:t.state,stateVersion:(a=t.stateVersion)==null?1:a},console.log(`Simulator: Game user storage updated`,t)}e===`GAME_COMPLETED`&&(console.log(`Simulator: Game completed!`,t),S.disabled=!0,h.hasStarted=!1,j(`Completed!`,`complete`))},z),console.log(`Simulator initialized`),$={updateFixtures:e=>{l=ie(e),u=Array.from(l.keys()).sort(),H.fixtures=l,H.fixtureCategories=u;let t=localStorage.getItem(`simulator-fixture-category`);if(!h.selectedCategory||!u.includes(h.selectedCategory)){var n;h.selectedCategory=t&&u.includes(t)?t:(n=u[0])==null?null:n}let r=p.find(e=>e.id===`ctrl`);r==null||r.bind(H),console.log(`Simulator: Fixtures updated`,{categories:u,selectedCategory:h.selectedCategory})},sendToGame:B,loadPuzzle:R},$}var qt={id:`simulator-game`,slug:`proto-game`,stableSlug:`proto-game`,displayName:`Proto Game`,version:{id:`simulator-version`,label:null,featuresArr:[0],flagsArr:[0],runtime:{id:`simulator-runtime`,version:null}}};Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return Vt}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return ae}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return Kt}});
1930
+ //# sourceMappingURL=createSimulator-C5cyzYAo.cjs.map