@unboxy/phaser-sdk 0.2.44 → 0.2.45

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/SDK-GUIDE.md CHANGED
@@ -1012,6 +1012,7 @@ footprint for characters, foundation for buildings).
1012
1012
 
1013
1013
  ## Changelog
1014
1014
 
1015
+ - **0.2.45** — fix: `isPerFrameHitbox` type guard tightened to check `default != null` rather than `'default' in h`. Closes a wire-shape gap from slice 8 v1.1 — the backend now writes explicit null values on the alternate shape's fields when a Hitbox PATCH switches modes (Single ↔ Per-frame), because OpenSearch's `_update` API deep-merges nested objects and would otherwise leave stale per-frame fields after a Single-mode save. Without this guard fix, the SDK's `applyAssetHitbox` would have treated the explicit-null `default: null` as "per-frame mode" via the `'in'` check and crashed when calling `applyShape(body, null)`. Pure SDK change — no API additions; only the guard's branch condition.
1015
1016
  - **0.2.44** — visual editor slice 8: depth + asymmetric collision. New fields `AssetRecord.hitbox` (single rect or per-frame overrides) + `AssetRecord.depthAnchor` (footprint pixel for Y-sort). New scene flag `WorldScene.ySort: boolean` (per-frame `setDepth(y)` hook). New SDK export `applyAssetHitbox(sprite, asset)` — silent no-op without metadata, dev-warn on missing body, idempotent `ANIMATION_UPDATE` listener install for per-frame variants. New type guard `isPerFrameHitbox`. Two new editor protocol messages — `unboxy:editor:assetUpdate { asset }` (broadcast hitbox/anchor edits to running iframe; re-applies to every spawned instance, no scene reload) + `unboxy:editor:setDebugOverlay { showHitboxes }` (toggle the EditorOverlayScene's per-frame hitbox + anchor draw). See "Collision + Y-sort" chapter. Pairs with: backend `PATCH /games/{id}/assets/{aid}/hitbox`, vision detection in pack import (character/tree/building/rock/decoration subjects), Hitbox Editor modal in home-ui, `asset-hitbox-physics` agent skill teaching the conditional rule.
1016
1017
  - **0.2.33** — docs: HUD scenes chapter added to this guide (covers slice-5 widget kinds, anchor model, dynamic bindings via `scene.registry`, `hud:press` event). Existing workspaces pick this up via `npm update @unboxy/phaser-sdk`.
1017
1018
  - **0.2.32** — fix: 9-grid anchor side change in the visual editor moved container-based widgets (icon-button, progress-bar, panel) far from the new corner. `applyHudPatch` now re-applies the origin shift that compensates for containers having no `setOrigin`.
@@ -205,6 +205,15 @@ export interface HitboxPerFrame {
205
205
  * Type guard — true when `hitbox` is the per-frame variant. Used by SDK
206
206
  * runtime to decide whether to install an `ANIMATION_UPDATE` listener that
207
207
  * swaps body shape per frame.
208
+ *
209
+ * <p>Checks `default != null` (handles both `null` and `undefined`) rather
210
+ * than `'default' in h`. The backend stores hitboxes after a mode switch
211
+ * with EXPLICIT NULLS on the alternate shape's fields — `{ kind: 'rect',
212
+ * x, y, w, h, default: null, frames: null }` for Single mode — because
213
+ * OpenSearch's _update API deep-merges nested objects and would otherwise
214
+ * leave stale fields. `'default' in h` would return true on that shape and
215
+ * trip the per-frame path with a null default. The null check is the
216
+ * correct discriminator.
208
217
  */
209
218
  export declare function isPerFrameHitbox(h: HitboxRect | HitboxPerFrame | undefined): h is HitboxPerFrame;
210
219
  /**
@@ -19,7 +19,16 @@ export function isPerFrameNinePatch(np) {
19
19
  * Type guard — true when `hitbox` is the per-frame variant. Used by SDK
20
20
  * runtime to decide whether to install an `ANIMATION_UPDATE` listener that
21
21
  * swaps body shape per frame.
22
+ *
23
+ * <p>Checks `default != null` (handles both `null` and `undefined`) rather
24
+ * than `'default' in h`. The backend stores hitboxes after a mode switch
25
+ * with EXPLICIT NULLS on the alternate shape's fields — `{ kind: 'rect',
26
+ * x, y, w, h, default: null, frames: null }` for Single mode — because
27
+ * OpenSearch's _update API deep-merges nested objects and would otherwise
28
+ * leave stale fields. `'default' in h` would return true on that shape and
29
+ * trip the per-frame path with a null default. The null check is the
30
+ * correct discriminator.
22
31
  */
23
32
  export function isPerFrameHitbox(h) {
24
- return !!h && 'default' in h;
33
+ return !!h && h.default != null;
25
34
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unboxy/phaser-sdk",
3
- "version": "0.2.44",
3
+ "version": "0.2.45",
4
4
  "description": "Unboxy Phaser 3 SDK — game infrastructure for the Unboxy platform",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",