@puzzmo/sdk 1.0.55 → 1.0.57

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/README.md CHANGED
@@ -91,6 +91,27 @@ sdk.timer.isPaused() // Check if paused
91
91
  sdk.timer.isRunning() // Check if running
92
92
  ```
93
93
 
94
+ ### Haptics
95
+
96
+ ```ts
97
+ sdk.haptics.play("selection") // on placing a letter
98
+ sdk.haptics.play("success", { id: "puzzle-solved" }) // `id` names the cue in host logs
99
+ ```
100
+
101
+ Names are the iOS feedback generators: `selection`, `light`, `medium`, `heavy`, `soft`, `rigid`, `success`, `warning`, `error`.
102
+
103
+ Fire-and-forget — it never reports back, and it is a no-op wherever the host can't deliver one, so never make gameplay depend on a haptic landing:
104
+
105
+ | Where | What happens |
106
+ | --- | --- |
107
+ | Puzzmo's iOS app | Real UIKit haptics via the native bridge |
108
+ | puzzmo.com on Android/desktop | Approximated with `navigator.vibrate` |
109
+ | Partner embeds | No haptic — see below |
110
+
111
+ The call goes to the host rather than vibrating from your game because Chrome has blocked `navigator.vibrate` in cross-origin iframes since Chrome 55, and games run in one. There is no Permissions-Policy opt-in, so calling it yourself is silently ignored. Partner embeds fire no haptic for the same reason: our frame is cross-origin to the partner's page, so the host is blocked too and there is no native bridge to fall back on. The cue is still forwarded to the partner page on the private message stream, so a partner can action it themselves.
112
+
113
+ Haptics are also off entirely when the player has turned them off in their Puzzmo settings, and the OS drops them in silent/DND or on hardware with no motor.
114
+
94
115
  ## Theme
95
116
 
96
117
  The `theme` object from `gameReady()` contains color tokens for the current Puzzmo theme:
@@ -154,8 +175,14 @@ sdk.keyboard.hide()
154
175
  `defaultKeyboardConfig` is a standard QWERTY layout with Enter and Backspace. Customize it by spreading:
155
176
 
156
177
  ```ts
178
+ sdk.keyboard.show({ ...defaultKeyboardConfig,
157
179
  // Disable letters that are no longer valid given the current game state
158
- sdk.keyboard.show({ ...defaultKeyboardConfig, disabled: usedLetters })
180
+ disabled: usedLetters })
181
+ // Override inidividual keys with their own styles for emphasis
182
+ individualKeyStyles: keyStylesFromRules([
183
+ { keys: ["?"], background: { backgroundColor: "#ffd54a" } },
184
+ { keys: usedLetters, text: { opacity: "0.4", transition: "opacity 200ms ease-out" } },
185
+ ]),
159
186
  ```
160
187
 
161
188
  For games with a spatial input model (e.g. selecting a grid cell by dragging across the keyboard),