بنقرة واحدة
introduce-puzzmo-sdk
Integrate the Puzzmo SDK into a Vite game project for host communication
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Integrate the Puzzmo SDK into a Vite game project for host communication
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
Create app metadata, thumbnail, and offline configuration for the Puzzmo platform
Wire up game completion signaling to the Puzzmo host
Configure the Puzzmo CLI for uploading game builds
Edit the `integrations` block in puzzmo.json (leaderboards, notables, etc.) using live game context from the dev.puzzmo.com MCP
Add integrations to puzzmo.json with leaderboard configuration using deeds
Convert hardcoded colors to use Puzzmo theme tokens for light/dark mode support
| name | introduce-puzzmo-sdk |
| description | Integrate the Puzzmo SDK into a Vite game project for host communication |
Add the @puzzmo/sdk package and wire up the game lifecycle.
Install @puzzmo/sdk:
Install `@puzzmo/sdk` using the project's package manager (e.g. npm, yarn, pnpm).
In the main game entry file, import and initialize the SDK:
import { createPuzzmoSDK } from "@puzzmo/sdk"
const sdk = createPuzzmoSDK()
Replace the game's initialization flow with the SDK lifecycle:
// Wait for puzzle data from the host
const { puzzleString, inputString, theme, completed } = await sdk.gameReady()
// Parse puzzle data and set up the game
const puzzle = JSON.parse(puzzleString)
initializeGame(puzzle)
// If there's saved state, restore it
if (inputString) restoreState(inputString)
// Apply the Puzzmo theme colors
if (theme) applyTheme(theme)
// Signal that the game is ready to start
sdk.gameLoaded()
Handle the start event to trigger the game start:
sdk.on("start", () => {
startGame()
})
Wire up other lifecycle events if there is relevant game logic for pause/resume/retry:
sdk.on("pause", () => {
/* pause game was triggered, system timer auto-pauses */
})
sdk.on("resume", () => {
/* resume game was triggered, system timer auto-resumes */
})
sdk.on("retry", () => {
/* retry game was triggered, system timer auto-resets, */
})
Wire up state saving - call sdk.updateGameState(stateString) whenever the game state changes so the host can save progress.
Create puzzle fixture files for local testing. Make a fixtures/puzzles/ directory and add a few different puzzle JSON files that exercise different aspects of the game:
fixtures/puzzles/
easy/
small-grid.json
basic.json
hard/
large-grid.json
tricky.json
Each JSON file should contain puzzle data in the format the game expects. Try to create at least 2-3 puzzles with different characteristics (e.g. varying difficulty, size, or edge cases) so the game can be tested against realistic variety.
If the original game already has a few puzzles hardcoded, use those as a starting point for creating the fixture files. Then delete the buttons which may have been used to load them, since the simulator will handle loading puzzles from the fixtures.
Set up the dev simulator for local testing. Add the Vite plugin to vite.config.ts:
import { defineConfig } from "vite"
import { puzzmoSimulator } from "@puzzmo/sdk/vite"
export default defineConfig({
plugins: [
puzzmoSimulator({
fixturesGlob: "/fixtures/puzzles/**/*.json",
}),
],
})
The plugin automatically:
For non-Vite setups, load the SDK and simulator from jsDelivr:
<script>
window.SIMULATOR_CONFIG = { slug: "my-game" }
</script>
<script src="https://cdn.jsdelivr.net/npm/@puzzmo/sdk/dist/simulator/standalone.js"></script>
sdk.gameReady() - Async. Sends READY, waits for puzzle data. Returns { puzzleString, inputString, theme, completed }.sdk.gameLoaded() - Signals game is ready. Host will send START_GAME.sdk.on(event, handler) - Listen for lifecycle events: start, pause, resume, retry, settingsUpdate.sdk.updateGameState(stateString) - Save current game state.sdk.timer - Auto-managed timer with .timeMs(), .timeSecs(), .display(), .addPenalty(ms).sdk.settings - User settings, persisted per-game by the host:
sdk.settings.initialize(components) - Call after gameReady() with GameSettingsUIComponents[] describing the settings UI (boolean/enum/number/text fields plus titles/paragraphs). Returns the resolved settings (component defaults merged with the player's saved values). The host renders the components in its settings panel.sdk.settings.get() - The current resolved settings object.sdk.settings.update(changes) - Merge changes from in-game UI into the settings and persist them to the host.sdk.on("settingsUpdate", handler) - Fires with the full settings object when the player changes a value in the host settings panel (the simulator's Set tab during development).build script completes without errorsupdateGameState on each user actionfixtures/puzzles/ with at least 2-3 varied puzzles