@puzzmo/sdk 1.0.55 → 1.0.56

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.
@@ -407,7 +407,7 @@ const e=require(`./objectSpread2-CuluYLUL.cjs`),t=require(`./asyncToGenerator-DA
407
407
  <div class="simulator-field">
408
408
  ${Z(e)}
409
409
  ${r}
410
- </div>`}default:return`<div class="sim-settings-unsupported">Unsupported component type: ${Q(e.type)}</div>`}}function Z(e){let t=e.subtitle?`<div class="sim-settings-subtitle">${Q(e.subtitle)}</div>`:``;return`<span class="simulator-label">${Q(e.title)}</span>${t}`}function Dt(e){let t={};for(let n of e)n.type===`split`?Object.assign(t,Dt(n.content)):`name`in n&&(t[n.name]=n.defaultValue);return t}function Q(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`)}function Ot(){let e=[],t=!0,n=()=>e.length===0?`<div class="sound-empty">No sensory events yet. Play the game to hear from it.</div>`:e.map(e=>`<div class="sound-row"><span class="sound-id">${At(e.id)}</span>${e.haptic?`<span class="sound-haptic">${At(e.haptic)}</span>`:``}<span class="sound-time">${e.time}</span></div>`).join(``),r=t=>{let r=t.getElement(`#sound-events`);r&&(r.innerHTML=n()),t.updateBadge(`sound`,e.length)};return{id:`sound`,label:`Sound`,render(){return`
410
+ </div>`}default:return`<div class="sim-settings-unsupported">Unsupported component type: ${Q(e.type)}</div>`}}function Z(e){let t=e.subtitle?`<div class="sim-settings-subtitle">${Q(e.subtitle)}</div>`:``;return`<span class="simulator-label">${Q(e.title)}</span>${t}`}function Dt(e){let t={};for(let n of e)n.type===`split`?Object.assign(t,Dt(n.content)):`name`in n&&(t[n.name]=n.defaultValue);return t}function Q(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`)}function Ot(){let e=[],t=!0,n=()=>e.length===0?`<div class="sound-empty">No cues yet. Play the game to hear from it.</div>`:e.map(e=>`<div class="sound-row"><span class="sound-id">${At(e.id)}</span>${e.haptic?`<span class="sound-haptic">${At(e.haptic)}</span>`:``}<span class="sound-time">${e.time}</span></div>`).join(``),r=t=>{let r=t.getElement(`#sound-events`);r&&(r.innerHTML=n()),t.updateBadge(`sound`,e.length)};return{id:`sound`,label:`Sound`,render(){return`
411
411
  <style>
412
412
  #simulator-tab-sound .sound-row { display: flex; justify-content: space-between; gap: 8px; padding: 3px 0; font-family: monospace; font-size: 11px; }
413
413
  #simulator-tab-sound .sound-id { color: var(--accent, #6cf); }
@@ -418,14 +418,14 @@ const e=require(`./objectSpread2-CuluYLUL.cjs`),t=require(`./asyncToGenerator-DA
418
418
  #simulator-tab-sound .sound-toggle { font-size: 11px; display: flex; align-items: center; gap: 4px; }
419
419
  </style>
420
420
  <div class="simulator-section">
421
- <div class="simulator-section-title">Sensory Events</div>
421
+ <div class="simulator-section-title">Cues</div>
422
422
  <div class="sound-controls">
423
423
  <label class="sound-toggle"><input type="checkbox" id="sound-enabled" ${t?`checked`:``} /> Sound enabled</label>
424
424
  <button class="simulator-btn" id="sound-clear">Clear</button>
425
425
  </div>
426
426
  <div id="sound-events">${n()}</div>
427
427
  </div>
428
- `},bind(n){let i=n.getElement(`#sound-clear`);i==null||i.addEventListener(`click`,()=>{e.length=0,r(n)});let a=n.getElement(`#sound-enabled`);a==null||a.addEventListener(`change`,()=>{t=!!a.checked,n.sendToGame(`SOUND_ENABLED`,{enabled:t})}),n.sendToGame(`SOUND_ENABLED`,{enabled:t})},onMessage(n,i,a){var o;if(n===`READY_GAME_LOADED`){a.sendToGame(`SOUND_ENABLED`,{enabled:t});return}if(n!==`SENSORY_EVENT`)return;let s=typeof i==`string`?i:(o=i==null?void 0:i.id)==null?JSON.stringify(i):o;e.unshift({id:s,haptic:typeof i==`string`||i==null?void 0:i.haptic,time:kt()}),e.length>100&&e.pop(),r(a)}}}function kt(){return new Date().toLocaleTimeString(`en-US`,{hour12:!1,hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}function At(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`)}var $=null;function jt(){return typeof window>`u`?!1:new URLSearchParams(window.location.search).has(`developer`)}var Mt={updateFixtures:()=>{},sendToGame:()=>{},loadPuzzle:function(){var e=t.t(function*(){return null});return function(){return e.apply(this,arguments)}}()};function Nt(e={}){var n,r,i;if(jt())return console.log(`[Simulator] developer=true in URL — running inside the Puzzmo app, skipping simulator boot`),Mt;if(console.log(`[Simulator] createSimulator called with config:`,{slug:e.slug,hasFixtures:!!e.fixtures}),$)return e.fixtures&&(console.log(`[Simulator] Instance already exists, updating fixtures`),$.updateFixtures(e.fixtures)),$;let a=(n=e.autoStart)==null?!0:n,o=e.fixtures?ae(e.fixtures):null,s=o?Array.from(o.keys()).sort():[],c=me(),l=Ce(),u=[se(),le(),c,he(),ge(),l,Te(),De(e.hostContextPresets),Ke(),dt(),Ct(),Tt(),Ot(),...(r=e.views)==null?[]:r],d=u.map(e=>e.id),f=ee(e,s,d),p={pause:`<svg width="10" height="10" viewBox="0 0 10 10" fill="currentColor"><rect x="1" y="1" width="3" height="8"/><rect x="6" y="1" width="3" height="8"/></svg>`,play:`<svg width="10" height="10" viewBox="0 0 10 10" fill="currentColor"><polygon points="2,1 9,5 2,9"/></svg>`,retry:`<svg width="10" height="10" viewBox="0 0 10 10" fill="currentColor"><path d="M5 1C2.8 1 1 2.8 1 5s1.8 4 4 4c1.8 0 3.3-1.2 3.8-2.8H7.5c-.4.9-1.3 1.5-2.5 1.5-1.5 0-2.7-1.2-2.7-2.7S3.5 2.3 5 2.3c.7 0 1.4.3 1.9.8L5.5 4.5H9V1L7.6 2.4C6.9 1.5 5.9 1 5 1z"/></svg>`,cog:`<svg width="10" height="10" viewBox="0 0 10 10" fill="currentColor"><path d="M9.5 5.8l-.8-.5c0-.2.1-.5.1-.8s0-.5-.1-.8l.8-.5c.1-.1.2-.2.1-.4l-.8-1.4c-.1-.1-.2-.2-.4-.1l-1 .3c-.3-.3-.7-.5-1.1-.6L6.1.2C6.1.1 6 0 5.8 0H4.2c-.2 0-.3.1-.3.2l-.2 1c-.4.1-.7.3-1.1.6l-1-.3c-.2 0-.3 0-.4.1l-.8 1.4c-.1.2 0 .3.1.4l.8.5c0 .2-.1.5-.1.8s0 .5.1.8l-.8.5c-.1.1-.2.2-.1.4l.8 1.4c.1.1.2.2.4.1l1-.3c.3.3.7.5 1.1.6l.2 1c0 .1.1.2.3.2h1.6c.2 0 .3-.1.3-.2l.2-1c.4-.1.7-.3 1.1-.6l1 .3c.2 0 .3 0 .4-.1l.8-1.4c.1-.2 0-.3-.1-.4zM5 6.5c-.8 0-1.5-.7-1.5-1.5S4.2 3.5 5 3.5 6.5 4.2 6.5 5 5.8 6.5 5 6.5z"/></svg>`,minimize:`<svg width="10" height="10" viewBox="0 0 10 10" fill="currentColor"><rect x="1" y="4" width="8" height="2"/></svg>`,expand:`<svg width="8" height="8" viewBox="0 0 8 8" fill="currentColor"><polygon points="1,1 7,4 1,7"/></svg>`},m=document.createElement(`div`);m.id=`simulator`,m.dataset.puzzmoBuild=oe,m.innerHTML=`
428
+ `},bind(n){let i=n.getElement(`#sound-clear`);i==null||i.addEventListener(`click`,()=>{e.length=0,r(n)});let a=n.getElement(`#sound-enabled`);a==null||a.addEventListener(`change`,()=>{t=!!a.checked,n.sendToGame(`SOUND_ENABLED`,{enabled:t})}),n.sendToGame(`SOUND_ENABLED`,{enabled:t})},onMessage(n,i,a){var o;if(n===`READY_GAME_LOADED`){a.sendToGame(`SOUND_ENABLED`,{enabled:t});return}n===`SENSORY_EVENT`&&(e.unshift({id:(o=i==null?void 0:i.id)==null?JSON.stringify(i):o,haptic:i==null?void 0:i.haptic,time:kt()}),e.length>100&&e.pop(),r(a))}}}function kt(){return new Date().toLocaleTimeString(`en-US`,{hour12:!1,hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}function At(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`)}var $=null;function jt(){return typeof window>`u`?!1:new URLSearchParams(window.location.search).has(`developer`)}var Mt={updateFixtures:()=>{},sendToGame:()=>{},loadPuzzle:function(){var e=t.t(function*(){return null});return function(){return e.apply(this,arguments)}}()};function Nt(e={}){var n,r,i;if(jt())return console.log(`[Simulator] developer=true in URL — running inside the Puzzmo app, skipping simulator boot`),Mt;if(console.log(`[Simulator] createSimulator called with config:`,{slug:e.slug,hasFixtures:!!e.fixtures}),$)return e.fixtures&&(console.log(`[Simulator] Instance already exists, updating fixtures`),$.updateFixtures(e.fixtures)),$;let a=(n=e.autoStart)==null?!0:n,o=e.fixtures?ae(e.fixtures):null,s=o?Array.from(o.keys()).sort():[],c=me(),l=Ce(),u=[se(),le(),c,he(),ge(),l,Te(),De(e.hostContextPresets),Ke(),dt(),Ct(),Tt(),Ot(),...(r=e.views)==null?[]:r],d=u.map(e=>e.id),f=ee(e,s,d),p={pause:`<svg width="10" height="10" viewBox="0 0 10 10" fill="currentColor"><rect x="1" y="1" width="3" height="8"/><rect x="6" y="1" width="3" height="8"/></svg>`,play:`<svg width="10" height="10" viewBox="0 0 10 10" fill="currentColor"><polygon points="2,1 9,5 2,9"/></svg>`,retry:`<svg width="10" height="10" viewBox="0 0 10 10" fill="currentColor"><path d="M5 1C2.8 1 1 2.8 1 5s1.8 4 4 4c1.8 0 3.3-1.2 3.8-2.8H7.5c-.4.9-1.3 1.5-2.5 1.5-1.5 0-2.7-1.2-2.7-2.7S3.5 2.3 5 2.3c.7 0 1.4.3 1.9.8L5.5 4.5H9V1L7.6 2.4C6.9 1.5 5.9 1 5 1z"/></svg>`,cog:`<svg width="10" height="10" viewBox="0 0 10 10" fill="currentColor"><path d="M9.5 5.8l-.8-.5c0-.2.1-.5.1-.8s0-.5-.1-.8l.8-.5c.1-.1.2-.2.1-.4l-.8-1.4c-.1-.1-.2-.2-.4-.1l-1 .3c-.3-.3-.7-.5-1.1-.6L6.1.2C6.1.1 6 0 5.8 0H4.2c-.2 0-.3.1-.3.2l-.2 1c-.4.1-.7.3-1.1.6l-1-.3c-.2 0-.3 0-.4.1l-.8 1.4c-.1.2 0 .3.1.4l.8.5c0 .2-.1.5-.1.8s0 .5.1.8l-.8.5c-.1.1-.2.2-.1.4l.8 1.4c.1.1.2.2.4.1l1-.3c.3.3.7.5 1.1.6l.2 1c0 .1.1.2.3.2h1.6c.2 0 .3-.1.3-.2l.2-1c.4-.1.7-.3 1.1-.6l1 .3c.2 0 .3 0 .4-.1l.8-1.4c.1-.2 0-.3-.1-.4zM5 6.5c-.8 0-1.5-.7-1.5-1.5S4.2 3.5 5 3.5 6.5 4.2 6.5 5 5.8 6.5 5 6.5z"/></svg>`,minimize:`<svg width="10" height="10" viewBox="0 0 10 10" fill="currentColor"><rect x="1" y="4" width="8" height="2"/></svg>`,expand:`<svg width="8" height="8" viewBox="0 0 8 8" fill="currentColor"><polygon points="1,1 7,4 1,7"/></svg>`},m=document.createElement(`div`);m.id=`simulator`,m.dataset.puzzmoBuild=oe,m.innerHTML=`
429
429
  <style>
430
430
  :root {
431
431
  --sim-bg: #1a1a2e;
@@ -1772,4 +1772,4 @@ const e=require(`./objectSpread2-CuluYLUL.cjs`),t=require(`./asyncToGenerator-DA
1772
1772
  </div>
1773
1773
  </div>
1774
1774
  `,document.body.appendChild(m);let h=m.querySelector(`#simulator-panel`),g=m.querySelector(`#simulator-header`),_=m.querySelector(`#simulator-header-indicator`),v=m.querySelector(`#simulator-header-status-text`),y=m.querySelector(`#simulator-header-pause`),b=m.querySelector(`#simulator-header-retry`),x=m.querySelector(`#simulator-header-settings`),S=m.querySelector(`#simulator-toggle`),C=m.querySelector(`#simulator-timer`),T=m.querySelector(`#simulator-tabs`),E=m.querySelector(`#simulator-content`),D=e=>m.querySelector(e),O=e=>{y.innerHTML=e?p.play:p.pause,y.title=e?`Resume`:`Pause`},k=(e,t)=>{let n=D(`#simulator-status .text`),r=D(`#simulator-status .indicator`),i=t===`complete`?`✓`:``;n&&(n.textContent=e),r&&(r.className=`indicator ${t}`,r.textContent=i),_.className=t,_.textContent=i,v.textContent=e},A=(e,t)=>{t&&t!==`0`?C.innerHTML=`${e}<span class="penalty">+${t}</span>`:C.textContent=e},j=e=>{var t;f.activeTab=e,E.classList.remove(`hidden`),w(e),T.querySelectorAll(`.simulator-tab`).forEach(t=>{t.classList.toggle(`active`,t.getAttribute(`data-tab`)===e)}),m.querySelectorAll(`.simulator-tab-content`).forEach(t=>{t.classList.toggle(`active`,t.id===`simulator-tab-${e}`)}),x.classList.toggle(`active`,e===`auth`);let n=u.find(t=>t.id===e);n==null||(t=n.onActivate)==null||t.call(n,R)},M=e=>{f.isCollapsed=e,h.classList.toggle(`collapsed`,e),te(e),e?(E.classList.add(`hidden`),T.querySelectorAll(`.simulator-tab`).forEach(e=>e.classList.remove(`active`))):j(f.activeTab)},N=()=>{l.updatePreview(R)},P=function(){var e=t.t(function*(){var e,t;if(f.appliedPuzzleOverride!==null)return f.appliedPuzzleOverride;if(f.puzzleData)return f.puzzleData;if(!o||o.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=f.selectedCategory)==null?s[0]:e,r=n?o.get(n):void 0;if(!r||r.size===0)throw Error(`No puzzles found in fixture category "${n}"`);let i=(t=f.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}"`);f.puzzleData=a,console.log(`Simulator: Puzzle loaded from fixtures`,{category:n,puzzle:i}),f.originalPuzzle=a;let c=D(`#simulator-puzzle`);return c&&(c.value=f.originalPuzzle),f.activeTab===`thumb`&&N(),f.puzzleData});return function(){return e.apply(this,arguments)}}(),F=ne(e=>{c.addLogEntry(e,R)}),I=(e,t)=>{re(e,t,F)},L=(e,t)=>{let n=m.querySelector(`[data-badge="${e}"]`);n&&(n.textContent=t&&t>0?String(t):``)},R={state:f,getElement:D,sendToGame:I,logMessage:F.log,loadPuzzle:P,updateStatus:k,updateTimer:A,setCollapsed:M,switchTab:j,updateThumbnail:N,updateBadge:L,fixtures:o,fixtureCategories:s,gameSlug:(i=e.slug)==null?null:i};console.log(`[Simulator] Context created with gameSlug:`,R.gameSlug),u.forEach(e=>e.bind(R)),T.querySelectorAll(`.simulator-tab`).forEach(e=>{e.addEventListener(`click`,()=>{let t=e.getAttribute(`data-tab`);j(t),L(t,0)})}),S.addEventListener(`click`,e=>{e.stopPropagation(),M(!0)}),y.addEventListener(`click`,e=>{e.stopPropagation(),f.isPaused?(I(`RESUME_GAME`,{}),f.isPaused=!1,O(!1),k(`Running`,`ready`)):(I(`PAUSE_GAME`,{}),f.isPaused=!0,O(!0),k(`Paused`,`paused`));let t=D(`#simulator-pause`);t&&(t.textContent=f.isPaused?`Resume`:`Pause`)}),b.addEventListener(`click`,e=>{e.stopPropagation(),I(`RETRY_PUZZLE`,{}),f.hasStarted=!1,f.isPaused=!1,O(!1),y.disabled=!0,k(`Ready to retry`,`ready`);let t=D(`#simulator-pause`),n=D(`#simulator-start`);t&&(t.disabled=!0,t.textContent=`Pause`),n&&(n.textContent=`Start`)}),x.addEventListener(`click`,e=>{e.stopPropagation(),f.isCollapsed&&M(!1),j(`auth`)}),g.addEventListener(`click`,e=>{f.isCollapsed&&e.target!==S&&M(!1)}),f.isCollapsed||j(f.activeTab);let ce=new URLSearchParams(window.location.search);(ce.has(`code`)||ce.has(`error`))&&(M(!1),j(`auth`));let z=e=>({userState:{gameSettings:{"proto-game":f.gameSettings},id:`simulator-user`,ownerID:`simulator-owner`},currentUser:{id:`simulator-user`,name:`Simulator`,username:`simulator`,usernameID:`0000`,type:`User`,roles:``},startOrFindGameplay:{gamePlayed:{additionalTimeAddedSecs:0,boardState:f.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,puzzle:{id:`simulator-puzzle`,name:`Proto Jig Puzzle`,puzzle:e,game:{displayName:`Proto Game`,jsPath:``,slug:`proto-game`},mostRecentDaily:null}}},theme:f.selectedTheme,hostContext:f.hostContext,appRuntimeContract:`1.0`}),B=function(){var e=t.t(function*(){k(`Loading puzzle...`,`waiting`);try{let e=z(yield P());k(`Sending READY_DATA...`,`waiting`),I(`READY_DATA`,e),k(`Waiting for game to load...`,`waiting`)}catch(e){k(`Error: ${e}`,`paused`)}});return function(){return e.apply(this,arguments)}}(),V=()=>{console.log(`Simulator: Game loaded, ready to start`),b.disabled=!1,u.forEach(e=>{var t;return(t=e.onMessage)==null?void 0:t.call(e,`READY_GAME_LOADED`,void 0,R)}),a&&!f.hasStarted&&setTimeout(()=>{let e=D(`#simulator-start`);e==null||e.click(),y.disabled=!1,f.hasStarted=!0,k(`Running`,`ready`)},100)};return ie((e,t)=>{var n,r;if(e===`READY`){console.log(`Simulator: Received READY from game`),B();return}if(e===`READY_GAME_LOADED`){V();return}if(e===`TIMER_TICK`){if(t!=null&&t.display){let[e,n]=t.display;A(e,n)}return}if(e===`TIMER_SYNC`)return;if(e===`SIDEBAR_UPDATE`){console.log(`Simulator: Sidebar update`,t);return}u.forEach(n=>{var r;return(r=n.onMessage)==null?void 0:r.call(n,e,t,R)});let i=(n=t==null||(r=t.input)==null?void 0:r.boardState)==null?t==null?void 0:t.boardState:n;e===`UPLOAD_NEW_GAME_STATE`&&i&&(f.currentInputStr=i,f.activeTab===`thumb`&&N(),console.log(`Simulator: Game state uploaded`,t)),e===`GAME_COMPLETED`&&(console.log(`Simulator: Game completed!`,t),y.disabled=!0,f.hasStarted=!1,k(`Completed!`,`complete`))},F),console.log(`Simulator initialized`),$={updateFixtures:e=>{o=ae(e),s=Array.from(o.keys()).sort(),R.fixtures=o,R.fixtureCategories=s;let t=localStorage.getItem(`simulator-fixture-category`);if(!f.selectedCategory||!s.includes(f.selectedCategory)){var n;f.selectedCategory=t&&s.includes(t)?t:(n=s[0])==null?null:n}let r=u.find(e=>e.id===`ctrl`);r==null||r.bind(R),console.log(`Simulator: Fixtures updated`,{categories:s,selectedCategory:f.selectedCategory})},sendToGame:I,loadPuzzle:P},$}Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return Ot}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return oe}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return Nt}});
1775
- //# sourceMappingURL=createSimulator-CiUXlL22.cjs.map
1775
+ //# sourceMappingURL=createSimulator-BqKldPIq.cjs.map