@combos-fun/engine 0.1.18 → 0.1.19

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.
@@ -891,7 +891,7 @@ class Scene extends GameObject {
891
891
  }
892
892
 
893
893
  /** Generated at build from package.json */
894
- const version = "0.1.18";
894
+ const version = "0.1.19";
895
895
 
896
896
  /**
897
897
  * Sent to `window.parent` after each `System.init` completes during `Game.addSystem`
@@ -1683,9 +1683,30 @@ function missingUrlError(resourceName, slot) {
1683
1683
  `Use { type, url } (e.g. { type: "webp", url: "https://..." }). ` +
1684
1684
  `A flat path string is also accepted and will be normalized.`);
1685
1685
  }
1686
+ function isSpriteSheetResource(resourceType) {
1687
+ return resourceType === 'SPRITE' || resourceType === 'SPRITE_ANIMATION';
1688
+ }
1689
+ /**
1690
+ * Agent atlases name the sheet `atlas_json` and may also attach `animation_json`.
1691
+ * Playback only reads `data.json`. Prefer an existing `json` slot, and drop the
1692
+ * animator so a failed extra request cannot fail the whole resource.
1693
+ */
1694
+ function foldSpriteSheetSlots(src) {
1695
+ const next = { ...src };
1696
+ delete next.animation_json;
1697
+ if (next.json != null) {
1698
+ delete next.atlas_json;
1699
+ }
1700
+ else if (next.atlas_json != null) {
1701
+ next.json = next.atlas_json;
1702
+ delete next.atlas_json;
1703
+ }
1704
+ return next;
1705
+ }
1686
1706
  /**
1687
1707
  * Accept the documented `{ type, url }` slots, plus the common guesses
1688
1708
  * `src: "file.png"` and `src: { image: "a.webp", json: "a.json" }`.
1709
+ * `SPRITE` / `SPRITE_ANIMATION` also accept `atlas_json` in place of `json`.
1689
1710
  */
1690
1711
  function normalizeResourceSrc(src, resourceType, resourceName = '(unnamed)') {
1691
1712
  if (src == null) {
@@ -1698,8 +1719,11 @@ function normalizeResourceSrc(src, resourceType, resourceName = '(unnamed)') {
1698
1719
  if (typeof src !== 'object' || Array.isArray(src)) {
1699
1720
  throw new Error(`Resource "${resourceName}" src must be a url string or a slot object.`);
1700
1721
  }
1722
+ const slots = isSpriteSheetResource(resourceType)
1723
+ ? foldSpriteSheetSlots(src)
1724
+ : src;
1701
1725
  const out = {};
1702
- for (const [slot, value] of Object.entries(src)) {
1726
+ for (const [slot, value] of Object.entries(slots)) {
1703
1727
  if (value == null)
1704
1728
  continue;
1705
1729
  out[slot] = wrapSlot(slot, value, resourceName);