@zylem/game-lib 0.3.17 → 0.4.1

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.
Files changed (290) hide show
  1. package/README.md +2 -2
  2. package/dist/.vite/manifest.json +63 -58
  3. package/dist/api/actions.d.ts +5 -0
  4. package/dist/api/actions.d.ts.map +1 -0
  5. package/dist/api/behaviors.d.ts +4 -0
  6. package/dist/api/behaviors.d.ts.map +1 -0
  7. package/dist/api/camera.d.ts +4 -0
  8. package/dist/api/camera.d.ts.map +1 -0
  9. package/dist/api/core.d.ts +6 -0
  10. package/dist/api/core.d.ts.map +1 -0
  11. package/dist/api/entities.d.ts +9 -0
  12. package/dist/api/entities.d.ts.map +1 -0
  13. package/dist/api/main.d.ts +32 -0
  14. package/dist/api/main.d.ts.map +1 -0
  15. package/dist/api/stage.d.ts +6 -0
  16. package/dist/api/stage.d.ts.map +1 -0
  17. package/dist/core.js +4 -4
  18. package/dist/lib/actions/behaviors/actions.d.ts +1 -0
  19. package/dist/lib/actions/behaviors/actions.d.ts.map +1 -0
  20. package/dist/lib/actions/behaviors/behavior.d.ts +1 -0
  21. package/dist/lib/actions/behaviors/behavior.d.ts.map +1 -0
  22. package/dist/lib/actions/behaviors/boundaries/boundary.d.ts +1 -0
  23. package/dist/lib/actions/behaviors/boundaries/boundary.d.ts.map +1 -0
  24. package/dist/lib/actions/behaviors/character-controller.d.ts +1 -0
  25. package/dist/lib/actions/behaviors/character-controller.d.ts.map +1 -0
  26. package/dist/lib/actions/behaviors/debug/debug-collision.d.ts +1 -0
  27. package/dist/lib/actions/behaviors/debug/debug-collision.d.ts.map +1 -0
  28. package/dist/lib/actions/behaviors/debug/debug-update.d.ts +1 -0
  29. package/dist/lib/actions/behaviors/debug/debug-update.d.ts.map +1 -0
  30. package/dist/lib/actions/behaviors/debug/debug.d.ts +1 -0
  31. package/dist/lib/actions/behaviors/debug/debug.d.ts.map +1 -0
  32. package/dist/lib/actions/behaviors/movement/movement-sequence-2d.d.ts +1 -0
  33. package/dist/lib/actions/behaviors/movement/movement-sequence-2d.d.ts.map +1 -0
  34. package/dist/lib/actions/behaviors/ricochet/ricochet-2d-collision.d.ts +1 -0
  35. package/dist/lib/actions/behaviors/ricochet/ricochet-2d-collision.d.ts.map +1 -0
  36. package/dist/lib/actions/behaviors/ricochet/ricochet-2d-in-bounds.d.ts +1 -0
  37. package/dist/lib/actions/behaviors/ricochet/ricochet-2d-in-bounds.d.ts.map +1 -0
  38. package/dist/lib/actions/behaviors/ricochet/ricochet.d.ts +1 -0
  39. package/dist/lib/actions/behaviors/ricochet/ricochet.d.ts.map +1 -0
  40. package/dist/lib/actions/behaviors/zylem-behavior.d.ts +1 -0
  41. package/dist/lib/actions/behaviors/zylem-behavior.d.ts.map +1 -0
  42. package/dist/lib/actions/capabilities/moveable.d.ts +1 -0
  43. package/dist/lib/actions/capabilities/moveable.d.ts.map +1 -0
  44. package/dist/lib/actions/capabilities/rotatable.d.ts +1 -0
  45. package/dist/lib/actions/capabilities/rotatable.d.ts.map +1 -0
  46. package/dist/lib/actions/capabilities/transformable.d.ts +1 -0
  47. package/dist/lib/actions/capabilities/transformable.d.ts.map +1 -0
  48. package/dist/lib/actions/global-change.d.ts +1 -0
  49. package/dist/lib/actions/global-change.d.ts.map +1 -0
  50. package/dist/lib/camera/camera.d.ts +1 -0
  51. package/dist/lib/camera/camera.d.ts.map +1 -0
  52. package/dist/lib/camera/fixed-2d.d.ts +1 -0
  53. package/dist/lib/camera/fixed-2d.d.ts.map +1 -0
  54. package/dist/lib/camera/perspective.d.ts +1 -0
  55. package/dist/lib/camera/perspective.d.ts.map +1 -0
  56. package/dist/lib/camera/third-person.d.ts +1 -8
  57. package/dist/lib/camera/third-person.d.ts.map +1 -0
  58. package/dist/lib/camera/zylem-camera.d.ts +27 -0
  59. package/dist/lib/camera/zylem-camera.d.ts.map +1 -0
  60. package/dist/lib/camera/zylem-camera.js +100 -37
  61. package/dist/lib/collision/collision-builder.d.ts +1 -5
  62. package/dist/lib/collision/collision-builder.d.ts.map +1 -0
  63. package/dist/lib/collision/collision-delegate.d.ts +1 -6
  64. package/dist/lib/collision/collision-delegate.d.ts.map +1 -0
  65. package/dist/lib/collision/collision-group.d.ts +1 -0
  66. package/dist/lib/collision/collision-group.d.ts.map +1 -0
  67. package/dist/lib/collision/collision-mask.d.ts +1 -0
  68. package/dist/lib/collision/collision-mask.d.ts.map +1 -0
  69. package/dist/lib/collision/collision.d.ts +1 -9
  70. package/dist/lib/collision/collision.d.ts.map +1 -0
  71. package/dist/lib/collision/utils.d.ts +1 -0
  72. package/dist/lib/collision/utils.d.ts.map +1 -0
  73. package/dist/lib/collision/world.d.ts +1 -0
  74. package/dist/lib/collision/world.d.ts.map +1 -0
  75. package/dist/lib/core/asset-manager.d.ts +1 -0
  76. package/dist/lib/core/asset-manager.d.ts.map +1 -0
  77. package/dist/lib/core/base-node-life-cycle.d.ts +1 -0
  78. package/dist/lib/core/base-node-life-cycle.d.ts.map +1 -0
  79. package/dist/lib/core/base-node.d.ts +1 -0
  80. package/dist/lib/core/base-node.d.ts.map +1 -0
  81. package/dist/lib/core/base-node.js +1 -1
  82. package/dist/lib/core/entity-asset-loader.d.ts +1 -14
  83. package/dist/lib/core/entity-asset-loader.d.ts.map +1 -0
  84. package/dist/lib/core/entity-asset-loader.js +1 -4
  85. package/dist/lib/core/errors.d.ts +1 -0
  86. package/dist/lib/core/errors.d.ts.map +1 -0
  87. package/dist/lib/core/flags.d.ts +1 -0
  88. package/dist/lib/core/flags.d.ts.map +1 -0
  89. package/dist/lib/core/index.d.ts +1 -0
  90. package/dist/lib/core/index.d.ts.map +1 -0
  91. package/dist/lib/core/lazy-loader.d.ts +1 -0
  92. package/dist/lib/core/lazy-loader.d.ts.map +1 -0
  93. package/dist/lib/core/lifecycle-base.d.ts +1 -0
  94. package/dist/lib/core/lifecycle-base.d.ts.map +1 -0
  95. package/dist/lib/core/preset-shader.d.ts +1 -4
  96. package/dist/lib/core/preset-shader.d.ts.map +1 -0
  97. package/dist/lib/core/preset-shader.js +1 -5
  98. package/dist/lib/core/three-addons/Timer.d.ts +2 -16
  99. package/dist/lib/core/three-addons/Timer.d.ts.map +1 -0
  100. package/dist/lib/core/utility/nodes.d.ts +5 -3
  101. package/dist/lib/core/utility/nodes.d.ts.map +1 -0
  102. package/dist/lib/core/utility/nodes.js +20 -16
  103. package/dist/lib/core/utility/strings.d.ts +1 -0
  104. package/dist/lib/core/utility/strings.d.ts.map +1 -0
  105. package/dist/lib/core/utility/vector.d.ts +1 -6
  106. package/dist/lib/core/utility/vector.d.ts.map +1 -0
  107. package/dist/lib/core/vector.d.ts +1 -0
  108. package/dist/lib/core/vector.d.ts.map +1 -0
  109. package/dist/lib/core/vessel.d.ts +1 -1
  110. package/dist/lib/core/vessel.d.ts.map +1 -0
  111. package/dist/lib/core/vessel.js +0 -1
  112. package/dist/lib/debug/console/console-state.d.ts +1 -0
  113. package/dist/lib/debug/console/console-state.d.ts.map +1 -0
  114. package/dist/lib/debug/console/console-store.d.ts +1 -0
  115. package/dist/lib/debug/console/console-store.d.ts.map +1 -0
  116. package/dist/lib/debug/debug-state.d.ts +2 -7
  117. package/dist/lib/debug/debug-state.d.ts.map +1 -0
  118. package/dist/lib/debug/debug-store.d.ts +1 -0
  119. package/dist/lib/debug/debug-store.d.ts.map +1 -0
  120. package/dist/lib/debug/state-based-debug-loader.d.ts +1 -0
  121. package/dist/lib/debug/state-based-debug-loader.d.ts.map +1 -0
  122. package/dist/lib/device/aspect-ratio.d.ts +1 -0
  123. package/dist/lib/device/aspect-ratio.d.ts.map +1 -0
  124. package/dist/lib/device/desktop.d.ts +1 -0
  125. package/dist/lib/device/desktop.d.ts.map +1 -0
  126. package/dist/lib/device/mobile.d.ts +1 -0
  127. package/dist/lib/device/mobile.d.ts.map +1 -0
  128. package/dist/lib/device/tablet.d.ts +1 -0
  129. package/dist/lib/device/tablet.d.ts.map +1 -0
  130. package/dist/lib/entities/actor.d.ts +2 -15
  131. package/dist/lib/entities/actor.d.ts.map +1 -0
  132. package/dist/lib/entities/actor.js +0 -3
  133. package/dist/lib/entities/box.d.ts +1 -0
  134. package/dist/lib/entities/box.d.ts.map +1 -0
  135. package/dist/lib/entities/builder.d.ts +1 -0
  136. package/dist/lib/entities/builder.d.ts.map +1 -0
  137. package/dist/lib/entities/create.d.ts +1 -0
  138. package/dist/lib/entities/create.d.ts.map +1 -0
  139. package/dist/lib/entities/delegates/animation.d.ts +1 -0
  140. package/dist/lib/entities/delegates/animation.d.ts.map +1 -0
  141. package/dist/lib/entities/delegates/debug.d.ts +2 -10
  142. package/dist/lib/entities/delegates/debug.d.ts.map +1 -0
  143. package/dist/lib/entities/delegates/debug.js +1 -2
  144. package/dist/lib/entities/delegates/loader.d.ts +1 -0
  145. package/dist/lib/entities/delegates/loader.d.ts.map +1 -0
  146. package/dist/lib/entities/destroy.d.ts +1 -0
  147. package/dist/lib/entities/destroy.d.ts.map +1 -0
  148. package/dist/lib/entities/entity.d.ts +1 -5
  149. package/dist/lib/entities/entity.d.ts.map +1 -0
  150. package/dist/lib/entities/index.d.ts +2 -1
  151. package/dist/lib/entities/index.d.ts.map +1 -0
  152. package/dist/lib/entities/plane.d.ts +1 -0
  153. package/dist/lib/entities/plane.d.ts.map +1 -0
  154. package/dist/lib/entities/rect.d.ts +1 -0
  155. package/dist/lib/entities/rect.d.ts.map +1 -0
  156. package/dist/lib/entities/sphere.d.ts +1 -0
  157. package/dist/lib/entities/sphere.d.ts.map +1 -0
  158. package/dist/lib/entities/sprite.d.ts +1 -0
  159. package/dist/lib/entities/sprite.d.ts.map +1 -0
  160. package/dist/lib/entities/text.d.ts +8 -0
  161. package/dist/lib/entities/text.d.ts.map +1 -0
  162. package/dist/lib/entities/text.js +77 -48
  163. package/dist/lib/entities/zone.d.ts +1 -0
  164. package/dist/lib/entities/zone.d.ts.map +1 -0
  165. package/dist/lib/game/game-blueprint.d.ts +5 -11
  166. package/dist/lib/game/game-blueprint.d.ts.map +1 -0
  167. package/dist/lib/game/game-canvas.d.ts +1 -0
  168. package/dist/lib/game/game-canvas.d.ts.map +1 -0
  169. package/dist/lib/game/game-canvas.js +9 -9
  170. package/dist/lib/game/game-config.d.ts +17 -5
  171. package/dist/lib/game/game-config.d.ts.map +1 -0
  172. package/dist/lib/game/game-config.js +49 -24
  173. package/dist/lib/game/game-default.d.ts +3 -7
  174. package/dist/lib/game/game-default.d.ts.map +1 -0
  175. package/dist/lib/game/game-default.js +0 -1
  176. package/dist/lib/game/game-interfaces.d.ts +3 -2
  177. package/dist/lib/game/game-interfaces.d.ts.map +1 -0
  178. package/dist/lib/game/game-retro-resolutions.d.ts +25 -0
  179. package/dist/lib/game/game-retro-resolutions.d.ts.map +1 -0
  180. package/dist/lib/game/game-retro-resolutions.js +80 -0
  181. package/dist/lib/game/game-state.d.ts +6 -5
  182. package/dist/lib/game/game-state.d.ts.map +1 -0
  183. package/dist/lib/game/game.d.ts +7 -8
  184. package/dist/lib/game/game.d.ts.map +1 -0
  185. package/dist/lib/game/game.js +46 -70
  186. package/dist/lib/game/zylem-game.d.ts +5 -4
  187. package/dist/lib/game/zylem-game.d.ts.map +1 -0
  188. package/dist/lib/game/zylem-game.js +38 -31
  189. package/dist/lib/graphics/geometries/XZPlaneGeometry.d.ts +1 -0
  190. package/dist/lib/graphics/geometries/XZPlaneGeometry.d.ts.map +1 -0
  191. package/dist/lib/graphics/material.d.ts +1 -0
  192. package/dist/lib/graphics/material.d.ts.map +1 -0
  193. package/dist/lib/graphics/mesh.d.ts +1 -0
  194. package/dist/lib/graphics/mesh.d.ts.map +1 -0
  195. package/dist/lib/graphics/render-pass.d.ts +1 -0
  196. package/dist/lib/graphics/render-pass.d.ts.map +1 -0
  197. package/dist/lib/graphics/zylem-scene.d.ts +1 -0
  198. package/dist/lib/graphics/zylem-scene.d.ts.map +1 -0
  199. package/dist/lib/input/gamepad-provider.d.ts +1 -0
  200. package/dist/lib/input/gamepad-provider.d.ts.map +1 -0
  201. package/dist/lib/input/input-manager.d.ts +1 -0
  202. package/dist/lib/input/input-manager.d.ts.map +1 -0
  203. package/dist/lib/input/input-provider.d.ts +1 -0
  204. package/dist/lib/input/input-provider.d.ts.map +1 -0
  205. package/dist/lib/input/input.d.ts +1 -4
  206. package/dist/lib/input/input.d.ts.map +1 -0
  207. package/dist/lib/input/keyboard-provider.d.ts +1 -0
  208. package/dist/lib/input/keyboard-provider.d.ts.map +1 -0
  209. package/dist/lib/interfaces/entity.d.ts +1 -6
  210. package/dist/lib/interfaces/entity.d.ts.map +1 -0
  211. package/dist/lib/sounds/index.d.ts +1 -0
  212. package/dist/lib/sounds/index.d.ts.map +1 -0
  213. package/dist/lib/sounds/ping-pong-sound.d.ts +1 -0
  214. package/dist/lib/sounds/ping-pong-sound.d.ts.map +1 -0
  215. package/dist/lib/sounds/ricochet-sound.d.ts +1 -0
  216. package/dist/lib/sounds/ricochet-sound.d.ts.map +1 -0
  217. package/dist/lib/stage/debug-entity-cursor.d.ts +1 -0
  218. package/dist/lib/stage/debug-entity-cursor.d.ts.map +1 -0
  219. package/dist/lib/stage/entity-spawner.d.ts +1 -0
  220. package/dist/lib/stage/entity-spawner.d.ts.map +1 -0
  221. package/dist/lib/stage/stage-blueprint.d.ts +1 -0
  222. package/dist/lib/stage/stage-blueprint.d.ts.map +1 -0
  223. package/dist/lib/stage/stage-camera-debug-delegate.d.ts +14 -0
  224. package/dist/lib/stage/stage-camera-debug-delegate.d.ts.map +1 -0
  225. package/dist/lib/stage/stage-debug-delegate.d.ts +1 -0
  226. package/dist/lib/stage/stage-debug-delegate.d.ts.map +1 -0
  227. package/dist/lib/stage/stage-default.d.ts +2 -8
  228. package/dist/lib/stage/stage-default.d.ts.map +1 -0
  229. package/dist/lib/stage/stage-default.js +18 -28
  230. package/dist/lib/stage/stage-state.d.ts +2 -4
  231. package/dist/lib/stage/stage-state.d.ts.map +1 -0
  232. package/dist/lib/stage/stage.d.ts +2 -1
  233. package/dist/lib/stage/stage.d.ts.map +1 -0
  234. package/dist/lib/stage/stage.js +28 -28
  235. package/dist/lib/stage/zylem-stage.d.ts +4 -2
  236. package/dist/lib/stage/zylem-stage.d.ts.map +1 -0
  237. package/dist/lib/stage/zylem-stage.js +24 -24
  238. package/dist/lib/systems/test-system.d.ts +1 -0
  239. package/dist/lib/systems/test-system.d.ts.map +1 -0
  240. package/dist/lib/systems/transformable.system.d.ts +1 -0
  241. package/dist/lib/systems/transformable.system.d.ts.map +1 -0
  242. package/dist/lib/types/entity-types.d.ts +1 -15
  243. package/dist/lib/types/entity-types.d.ts.map +1 -0
  244. package/dist/lib/types/index.d.ts +1 -0
  245. package/dist/lib/types/index.d.ts.map +1 -0
  246. package/dist/lib/types/stage-types.d.ts +1 -9
  247. package/dist/lib/types/stage-types.d.ts.map +1 -0
  248. package/dist/lib/ui/Debug.d.ts +5 -0
  249. package/dist/lib/ui/Debug.d.ts.map +1 -0
  250. package/dist/lib/ui/console/Console.d.ts +1 -0
  251. package/dist/lib/ui/console/Console.d.ts.map +1 -0
  252. package/dist/lib/ui/debug-panel/AccordionMenu.d.ts +1 -0
  253. package/dist/lib/ui/debug-panel/AccordionMenu.d.ts.map +1 -0
  254. package/dist/lib/ui/debug-panel/Menu.d.ts +1 -0
  255. package/dist/lib/ui/debug-panel/Menu.d.ts.map +1 -0
  256. package/dist/lib/ui/debug-panel/sections/EntitiesSection.d.ts +1 -8
  257. package/dist/lib/ui/debug-panel/sections/EntitiesSection.d.ts.map +1 -0
  258. package/dist/lib/ui/debug-panel/sections/GameSection.d.ts +1 -0
  259. package/dist/lib/ui/debug-panel/sections/GameSection.d.ts.map +1 -0
  260. package/dist/lib/ui/debug-panel/sections/StagesSection.d.ts +1 -0
  261. package/dist/lib/ui/debug-panel/sections/StagesSection.d.ts.map +1 -0
  262. package/dist/lib/ui/debug-panel/sections/all.d.ts +1 -0
  263. package/dist/lib/ui/debug-panel/sections/all.d.ts.map +1 -0
  264. package/dist/lib/ui/toolbar/Toolbar.d.ts +1 -0
  265. package/dist/lib/ui/toolbar/Toolbar.d.ts.map +1 -0
  266. package/dist/main.js +10 -10
  267. package/dist/stage.js +12 -17
  268. package/dist/tests/integration/debug.sim.spec.d.ts +2 -0
  269. package/dist/tests/integration/debug.sim.spec.d.ts.map +1 -0
  270. package/dist/tests/unit/collision/collision.spec.d.ts +2 -0
  271. package/dist/tests/unit/collision/collision.spec.d.ts.map +1 -0
  272. package/dist/tests/unit/core/game.spec.d.ts +2 -0
  273. package/dist/tests/unit/core/game.spec.d.ts.map +1 -0
  274. package/dist/tests/unit/core/stage.spec.d.ts +2 -0
  275. package/dist/tests/unit/core/stage.spec.d.ts.map +1 -0
  276. package/dist/tests/unit/core/vessel.spec.d.ts +2 -0
  277. package/dist/tests/unit/core/vessel.spec.d.ts.map +1 -0
  278. package/package.json +22 -44
  279. package/dist/actions.d.ts +0 -4
  280. package/dist/behaviors.d.ts +0 -3
  281. package/dist/camera.d.ts +0 -3
  282. package/dist/core.d.ts +0 -5
  283. package/dist/entities.d.ts +0 -8
  284. package/dist/main.d.ts +0 -31
  285. package/dist/stage.d.ts +0 -6
  286. package/dist/tests/collision/collision.spec.d.ts +0 -1
  287. package/dist/tests/core/game.spec.d.ts +0 -1
  288. package/dist/tests/core/stage.spec.d.ts +0 -1
  289. package/dist/tests/core/vessel.spec.d.ts +0 -1
  290. package/dist/tests/stage/stage-blueprint.spec.d.ts +0 -1
@@ -1,9 +1,9 @@
1
- import { Vector2 as u, Group as H, CanvasTexture as w, LinearFilter as l, SpriteMaterial as k, Sprite as M, ClampToEdgeWrapping as C, Color as v } from "three";
2
- import { GameEntity as R } from "./entity.js";
3
- import { EntityBuilder as W } from "./builder.js";
4
- import { createEntity as E } from "./create.js";
5
- import { DebugDelegate as D } from "./delegates/debug.js";
6
- const x = {
1
+ import { Vector2 as m, Group as v, CanvasTexture as d, LinearFilter as l, SpriteMaterial as y, Sprite as T, ClampToEdgeWrapping as _, Color as f } from "three";
2
+ import { GameEntity as S } from "./entity.js";
3
+ import { EntityBuilder as F } from "./builder.js";
4
+ import { createEntity as R } from "./create.js";
5
+ import { DebugDelegate as H } from "./delegates/debug.js";
6
+ const u = {
7
7
  position: void 0,
8
8
  text: "",
9
9
  fontFamily: 'Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',
@@ -12,17 +12,17 @@ const x = {
12
12
  backgroundColor: null,
13
13
  padding: 4,
14
14
  stickToViewport: !0,
15
- screenPosition: new u(24, 24),
15
+ screenPosition: new m(24, 24),
16
16
  zDistance: 1
17
17
  };
18
- class P extends W {
18
+ class k extends F {
19
19
  createEntity(t) {
20
- return new o(t);
20
+ return new c(t);
21
21
  }
22
22
  }
23
- const z = Symbol("Text");
24
- class o extends R {
25
- static type = z;
23
+ const b = Symbol("Text");
24
+ class c extends S {
25
+ static type = b;
26
26
  _sprite = null;
27
27
  _texture = null;
28
28
  _canvas = null;
@@ -31,81 +31,110 @@ class o extends R {
31
31
  _lastCanvasW = 0;
32
32
  _lastCanvasH = 0;
33
33
  constructor(t) {
34
- super(), this.options = { ...x, ...t }, this.group = new H(), this.createSprite(), this.lifeCycleDelegate = {
34
+ super(), this.options = { ...u, ...t }, this.group = new v(), this.createSprite(), this.lifeCycleDelegate = {
35
35
  setup: [this.textSetup.bind(this)],
36
36
  update: [this.textUpdate.bind(this)]
37
37
  };
38
38
  }
39
39
  createSprite() {
40
- this._canvas = document.createElement("canvas"), this._ctx = this._canvas.getContext("2d"), this._texture = new w(this._canvas), this._texture.minFilter = l, this._texture.magFilter = l;
41
- const t = new k({
40
+ this._canvas = document.createElement("canvas"), this._ctx = this._canvas.getContext("2d"), this._texture = new d(this._canvas), this._texture.minFilter = l, this._texture.magFilter = l;
41
+ const t = new y({
42
42
  map: this._texture,
43
43
  transparent: !0,
44
44
  depthTest: !1,
45
45
  depthWrite: !1,
46
46
  alphaTest: 0.5
47
47
  });
48
- this._sprite = new M(t), this.group?.add(this._sprite), this.redrawText(this.options.text ?? "");
48
+ this._sprite = new T(t), this.group?.add(this._sprite), this.redrawText(this.options.text ?? "");
49
+ }
50
+ measureAndResizeCanvas(t, e, s, a) {
51
+ if (!this._canvas || !this._ctx)
52
+ return { sizeChanged: !1 };
53
+ this._ctx.font = `${e}px ${s}`;
54
+ const i = this._ctx.measureText(t), n = Math.ceil(i.width), r = Math.ceil(e * 1.4), o = Math.max(2, n + a * 2), h = Math.max(2, r + a * 2), p = o !== this._lastCanvasW || h !== this._lastCanvasH;
55
+ return this._canvas.width = o, this._canvas.height = h, this._lastCanvasW = o, this._lastCanvasH = h, { sizeChanged: p };
56
+ }
57
+ drawCenteredText(t, e, s) {
58
+ !this._canvas || !this._ctx || (this._ctx.font = `${e}px ${s}`, this._ctx.textAlign = "center", this._ctx.textBaseline = "middle", this._ctx.clearRect(0, 0, this._canvas.width, this._canvas.height), this.options.backgroundColor && (this._ctx.fillStyle = this.toCssColor(this.options.backgroundColor), this._ctx.fillRect(0, 0, this._canvas.width, this._canvas.height)), this._ctx.fillStyle = this.toCssColor(this.options.fontColor ?? "#FFFFFF"), this._ctx.fillText(t, this._canvas.width / 2, this._canvas.height / 2));
59
+ }
60
+ updateTexture(t) {
61
+ !this._texture || !this._canvas || (t && (this._texture.dispose(), this._texture = new d(this._canvas), this._texture.minFilter = l, this._texture.magFilter = l, this._texture.wrapS = _, this._texture.wrapT = _), this._texture.image = this._canvas, this._texture.needsUpdate = !0, this._sprite && this._sprite.material && (this._sprite.material.map = this._texture, this._sprite.material.needsUpdate = !0));
49
62
  }
50
63
  redrawText(t) {
51
64
  if (!this._canvas || !this._ctx)
52
65
  return;
53
- const e = this.options.fontSize ?? 18, r = this.options.fontFamily ?? x.fontFamily, a = this.options.padding ?? 4;
54
- this._ctx.font = `${e}px ${r}`;
55
- const p = this._ctx.measureText(t), _ = Math.ceil(p.width), h = Math.ceil(e * 1.4), n = Math.max(2, _ + a * 2), s = Math.max(2, h + a * 2), f = n !== this._lastCanvasW || s !== this._lastCanvasH;
56
- this._canvas.width = n, this._canvas.height = s, this._lastCanvasW = n, this._lastCanvasH = s, this._ctx.font = `${e}px ${r}`, this._ctx.textBaseline = "top", this._ctx.clearRect(0, 0, this._canvas.width, this._canvas.height), this.options.backgroundColor && (this._ctx.fillStyle = this.toCssColor(this.options.backgroundColor), this._ctx.fillRect(0, 0, this._canvas.width, this._canvas.height)), this._ctx.fillStyle = this.toCssColor(this.options.fontColor ?? "#FFFFFF"), this._ctx.fillText(t, a, a), this._texture && (f && (this._texture.dispose(), this._texture = new w(this._canvas), this._texture.minFilter = l, this._texture.magFilter = l, this._texture.wrapS = C, this._texture.wrapT = C), this._texture.image = this._canvas, this._texture.needsUpdate = !0, this._sprite && this._sprite.material && (this._sprite.material.map = this._texture, this._sprite.material.needsUpdate = !0));
66
+ const e = this.options.fontSize ?? 18, s = this.options.fontFamily ?? u.fontFamily, a = this.options.padding ?? 4, { sizeChanged: i } = this.measureAndResizeCanvas(t, e, s, a);
67
+ this.drawCenteredText(t, e, s), this.updateTexture(!!i), this.options.stickToViewport && this._cameraRef && this.updateStickyTransform();
57
68
  }
58
69
  toCssColor(t) {
59
- return typeof t == "string" ? t : `#${(t instanceof v ? t : new v(t)).getHexString()}`;
70
+ return typeof t == "string" ? t : `#${(t instanceof f ? t : new f(t)).getHexString()}`;
60
71
  }
61
72
  textSetup(t) {
62
- this._cameraRef = t.camera, this.options.stickToViewport && this._cameraRef && this._cameraRef.camera.add(this.group);
73
+ this._cameraRef = t.camera, this.options.stickToViewport && this._cameraRef && (this._cameraRef.camera.add(this.group), this.updateStickyTransform());
63
74
  }
64
75
  textUpdate(t) {
65
76
  this._sprite && this.options.stickToViewport && this._cameraRef && this.updateStickyTransform();
66
77
  }
67
- updateStickyTransform() {
68
- if (!this._sprite || !this._cameraRef)
69
- return;
70
- const t = this._cameraRef.camera, e = this._cameraRef.renderer.domElement, r = e.clientWidth, a = e.clientHeight, p = (this.options.screenPosition ?? new u(24, 24)).x, _ = (this.options.screenPosition ?? new u(24, 24)).y, h = Math.max(1e-3, this.options.zDistance ?? 1);
71
- let n = 1, s = 1;
78
+ getResolution() {
79
+ return {
80
+ width: this._cameraRef?.screenResolution.x ?? 1,
81
+ height: this._cameraRef?.screenResolution.y ?? 1
82
+ };
83
+ }
84
+ getScreenPixels(t, e, s) {
85
+ const a = t.x >= 0 && t.x <= 1, i = t.y >= 0 && t.y <= 1;
86
+ return {
87
+ px: a ? t.x * e : t.x,
88
+ py: i ? t.y * s : t.y
89
+ };
90
+ }
91
+ computeWorldExtents(t, e) {
92
+ let s = 1, a = 1;
72
93
  if (t.isPerspectiveCamera) {
73
- const i = t, c = Math.tan(i.fov * Math.PI / 180 / 2) * h;
74
- n = c * i.aspect, s = c;
94
+ const i = t, n = Math.tan(i.fov * Math.PI / 180 / 2) * e;
95
+ s = n * i.aspect, a = n;
75
96
  } else if (t.isOrthographicCamera) {
76
97
  const i = t;
77
- n = (i.right - i.left) / 2, s = (i.top - i.bottom) / 2;
78
- }
79
- const f = p / r * 2 - 1, y = 1 - _ / a * 2, T = f * n, F = y * s;
80
- if (this.group?.position.set(T, F, -h), this._canvas) {
81
- const c = s * 2 / a, m = this._canvas.height, g = Math.max(1e-4, m * c), S = this._canvas.width / this._canvas.height, b = g * S;
82
- this._sprite.scale.set(b, g, 1);
98
+ s = (i.right - i.left) / 2, a = (i.top - i.bottom) / 2;
83
99
  }
100
+ return { worldHalfW: s, worldHalfH: a };
101
+ }
102
+ updateSpriteScale(t, e) {
103
+ if (!this._canvas || !this._sprite)
104
+ return;
105
+ const a = t * 2 / e, i = this._canvas.height, n = Math.max(1e-4, i * a), r = this._canvas.width / this._canvas.height, o = n * r;
106
+ this._sprite.scale.set(o, n, 1);
107
+ }
108
+ updateStickyTransform() {
109
+ if (!this._sprite || !this._cameraRef)
110
+ return;
111
+ const t = this._cameraRef.camera, { width: e, height: s } = this.getResolution(), a = this.options.screenPosition ?? new m(24, 24), { px: i, py: n } = this.getScreenPixels(a, e, s), r = Math.max(1e-3, this.options.zDistance ?? 1), { worldHalfW: o, worldHalfH: h } = this.computeWorldExtents(t, r), p = i / e * 2 - 1, g = 1 - n / s * 2, w = p * o, C = g * h;
112
+ this.group?.position.set(w, C, -r), this.updateSpriteScale(h, s);
84
113
  }
85
114
  updateText(t) {
86
115
  this.options.text = t, this.redrawText(t), this.options.stickToViewport && this._cameraRef && this.updateStickyTransform();
87
116
  }
88
117
  buildInfo() {
89
118
  return {
90
- ...new D(this).buildDebugInfo(),
91
- type: String(o.type),
119
+ ...new H(this).buildDebugInfo(),
120
+ type: String(c.type),
92
121
  text: this.options.text ?? "",
93
122
  sticky: this.options.stickToViewport
94
123
  };
95
124
  }
96
125
  }
97
- async function X(...d) {
98
- return E({
99
- args: d,
100
- defaultConfig: { ...x },
101
- EntityClass: o,
102
- BuilderClass: P,
103
- entityType: o.type
126
+ async function D(...x) {
127
+ return R({
128
+ args: x,
129
+ defaultConfig: { ...u },
130
+ EntityClass: c,
131
+ BuilderClass: k,
132
+ entityType: c.type
104
133
  });
105
134
  }
106
135
  export {
107
- z as TEXT_TYPE,
108
- P as TextBuilder,
109
- o as ZylemText,
110
- X as text
136
+ b as TEXT_TYPE,
137
+ k as TextBuilder,
138
+ c as ZylemText,
139
+ D as text
111
140
  };
@@ -51,3 +51,4 @@ export declare class ZylemZone extends GameEntity<ZylemZoneOptions> implements C
51
51
  type ZoneOptions = BaseNode | Partial<ZylemZoneOptions>;
52
52
  export declare function zone(...args: Array<ZoneOptions>): Promise<ZylemZone>;
53
53
  export {};
54
+ //# sourceMappingURL=zone.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"zone.d.ts","sourceRoot":"","sources":["../../../src/lib/entities/zone.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC/E,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AAEnD,OAAO,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAG3E,MAAM,MAAM,YAAY,GAAG;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,SAAS,CAAC;IAChB,OAAO,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,GAAG,CAAC;CACb,CAAA;AAED,MAAM,MAAM,aAAa,GAAG,IAAI,CAAC,YAAY,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAAC,CAAC;AAC/E,MAAM,MAAM,YAAY,GAAG,IAAI,CAAC,YAAY,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAAC,CAAC;AAE9E,KAAK,gBAAgB,GAAG,iBAAiB,GAAG;IAC3C,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,aAAa,KAAK,IAAI,CAAC;IAC1C,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,YAAY,KAAK,IAAI,CAAC;IACxC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,YAAY,KAAK,IAAI,CAAC;CACxC,CAAC;AAaF,qBAAa,oBAAqB,SAAQ,sBAAsB;IAC/D,QAAQ,CAAC,OAAO,EAAE,gBAAgB,GAAG,YAAY;CAQjD;AAED,qBAAa,WAAY,SAAQ,aAAa,CAAC,SAAS,EAAE,gBAAgB,CAAC;IAC1E,SAAS,CAAC,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,gBAAgB,CAAC,GAAG,SAAS;CAGrE;AAED,eAAO,MAAM,SAAS,eAAiB,CAAC;AAExC,qBAAa,SAAU,SAAQ,UAAU,CAAC,gBAAgB,CAAE,YAAW,wBAAwB;IAC9F,MAAM,CAAC,IAAI,SAAa;IAExB,OAAO,CAAC,YAAY,CAAkC;IACtD,OAAO,CAAC,WAAW,CAAkC;IACrD,OAAO,CAAC,aAAa,CAA+B;gBAExC,OAAO,CAAC,EAAE,gBAAgB;IAK/B,mBAAmB,CAAC,EAAE,KAAK,EAAE,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO;IAO1D,uBAAuB,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE;QAAE,KAAK,EAAE,GAAG,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE;IAU9E,OAAO,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,aAAa,KAAK,IAAI;IAKjD,MAAM,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,YAAY,KAAK,IAAI;IAK/C,MAAM,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,YAAY,KAAK,IAAI;IAK/C,OAAO,CAAC,KAAK,EAAE,GAAG;IAWlB,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM;IAkBjC,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG;CAc9B;AAED,KAAK,WAAW,GAAG,QAAQ,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;AAExD,wBAAsB,IAAI,CAAC,GAAG,IAAI,EAAE,KAAK,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC,SAAS,CAAC,CAS1E"}
@@ -1,12 +1,11 @@
1
1
  import type { Stage } from '../stage/stage';
2
- import type { BasicTypes, GlobalVariablesType, ZylemGameConfig } from './game-interfaces';
3
- import type { GameOptions } from '../core/utility/nodes';
2
+ import type { BaseGlobals, ZylemGameConfig } from './game-interfaces';
4
3
  /**
5
4
  * A lightweight, serializable blueprint representing the initial configuration
6
5
  * of a `Game`. It should not include runtime references. Use blueprints only to
7
6
  * build games.
8
7
  */
9
- export interface GameBlueprint<TGlobals extends Record<string, BasicTypes> = GlobalVariablesType> {
8
+ export interface GameBlueprint<TGlobals extends BaseGlobals = BaseGlobals> {
10
9
  id: string;
11
10
  name?: string;
12
11
  config: Partial<ZylemGameConfig<Stage, any, TGlobals>>;
@@ -19,13 +18,13 @@ export declare const gameBlueprintsState: {
19
18
  /** Reset the blueprints store back to its initial empty state. */
20
19
  export declare function resetGameBlueprints(): void;
21
20
  /** Create and register a new `GameBlueprint`. */
22
- export declare function createGameBlueprint<TGlobals extends Record<string, BasicTypes> = GlobalVariablesType>(config: Partial<ZylemGameConfig<Stage, any, TGlobals>>, options?: {
21
+ export declare function createGameBlueprint<TGlobals extends BaseGlobals>(config: Partial<ZylemGameConfig<Stage, any, TGlobals>>, options?: {
23
22
  id?: string;
24
23
  name?: string;
25
24
  setCurrent?: boolean;
26
25
  }): GameBlueprint<TGlobals>;
27
26
  /** Upsert a blueprint into the store. */
28
- export declare function upsertGameBlueprint<TGlobals extends Record<string, BasicTypes> = GlobalVariablesType>(blueprint: GameBlueprint<TGlobals>): void;
27
+ export declare function upsertGameBlueprint<TGlobals extends BaseGlobals>(blueprint: GameBlueprint<TGlobals>): void;
29
28
  /** Remove a blueprint by id. */
30
29
  export declare function removeGameBlueprint(id: string): void;
31
30
  /** Get a blueprint by id. */
@@ -36,9 +35,4 @@ export declare function listGameBlueprints(): GameBlueprint[];
36
35
  export declare function setCurrentGameBlueprint(id: string | null): void;
37
36
  /** Get the current blueprint object, if any. */
38
37
  export declare function getCurrentGameBlueprint(): GameBlueprint | null;
39
- /**
40
- * Build a `Game` instance from a blueprint and optional extra `GameOptions`
41
- * (e.g., additional stages or nodes). This returns a `Game` wrapper instance;
42
- * call `.start()` to run it.
43
- */
44
- export declare function buildGameFromBlueprint<TGlobals extends Record<string, BasicTypes> = GlobalVariablesType>(input: string | GameBlueprint<TGlobals>, ...extras: GameOptions<TGlobals>): import("./game").Game<TGlobals>;
38
+ //# sourceMappingURL=game-blueprint.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"game-blueprint.d.ts","sourceRoot":"","sources":["../../../src/lib/game/game-blueprint.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEtE;;;;GAIG;AACH,MAAM,WAAW,aAAa,CAAC,QAAQ,SAAS,WAAW,GAAG,WAAW;IACxE,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,OAAO,CAAC,eAAe,CAAC,KAAK,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAC;CACvD;AAYD,eAAO,MAAM,mBAAmB;UALnB,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC;WAC5B,MAAM,EAAE;eACF,MAAM,GAAG,IAAI;CAG8C,CAAC;AAEhF,kEAAkE;AAClE,wBAAgB,mBAAmB,IAAI,IAAI,CAK1C;AAED,iDAAiD;AACjD,wBAAgB,mBAAmB,CAAC,QAAQ,SAAS,WAAW,EAC/D,MAAM,EAAE,OAAO,CAAC,eAAe,CAAC,KAAK,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAC,EACtD,OAAO,CAAC,EAAE;IAAE,EAAE,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,OAAO,CAAC;CAAE,GAC7D,aAAa,CAAC,QAAQ,CAAC,CAWzB;AAED,yCAAyC;AACzC,wBAAgB,mBAAmB,CAAC,QAAQ,SAAS,WAAW,EAC/D,SAAS,EAAE,aAAa,CAAC,QAAQ,CAAC,GAChC,IAAI,CAKN;AAED,gCAAgC;AAChC,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAMpD;AAED,6BAA6B;AAC7B,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS,CAEtE;AAED,8CAA8C;AAC9C,wBAAgB,kBAAkB,IAAI,aAAa,EAAE,CAIpD;AAED,+DAA+D;AAC/D,wBAAgB,uBAAuB,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAE/D;AAED,gDAAgD;AAChD,wBAAgB,uBAAuB,IAAI,aAAa,GAAG,IAAI,CAG9D"}
@@ -32,3 +32,4 @@ export declare class GameCanvas {
32
32
  destroy(): void;
33
33
  private ensureContainer;
34
34
  }
35
+ //# sourceMappingURL=game-canvas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"game-canvas.d.ts","sourceRoot":"","sources":["../../../src/lib/game/game-canvas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE/E,MAAM,WAAW,iBAAiB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,CAAC,EAAE,WAAW,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,iBAAiB,CAAC;IAC3B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,WAAW,EAAE,gBAAgB,GAAG,MAAM,CAAC;CACvC;AAED;;;;;;GAMG;AACH,qBAAa,UAAU;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAG,WAAW,CAAC;IACxB,MAAM,EAAG,iBAAiB,CAAC;IAC3B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,OAAO,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,aAAa,CAAoC;gBAE7C,OAAO,EAAE,iBAAiB;IAStC,mBAAmB;IAMnB,WAAW;IAOX,aAAa,CAAC,WAAW,EAAE,iBAAiB,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI;IAS/F,kBAAkB;IAUlB,iBAAiB,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI;IAiBnE,OAAO;IAKP,OAAO,CAAC,eAAe;CAevB"}
@@ -18,10 +18,10 @@ class o {
18
18
  this.container.removeChild(this.container.firstChild);
19
19
  this.container.appendChild(this.canvas);
20
20
  }
21
- mountRenderer(t, i) {
21
+ mountRenderer(t, a) {
22
22
  for (; this.container.firstChild; )
23
23
  this.container.removeChild(this.container.firstChild);
24
- this.container.appendChild(t), this.canvas = t, this.attachAspectRatio(i);
24
+ this.container.appendChild(t), this.canvas = t, this.attachAspectRatio(a);
25
25
  }
26
26
  centerIfFullscreen() {
27
27
  if (!this.fullscreen)
@@ -30,7 +30,7 @@ class o {
30
30
  t.display = "flex", t.alignItems = "center", t.justifyContent = "center", t.position = "fixed", t.inset = "0";
31
31
  }
32
32
  attachAspectRatio(t) {
33
- this.ratioDelegate ? this.ratioDelegate.apply() : (this.ratioDelegate = new s({
33
+ this.ratioDelegate ? (this.ratioDelegate.canvas = this.canvas, this.ratioDelegate.onResize = t, this.ratioDelegate.aspectRatio = this.aspectRatio, this.ratioDelegate.apply()) : (this.ratioDelegate = new s({
34
34
  container: this.container,
35
35
  canvas: this.canvas,
36
36
  aspectRatio: this.aspectRatio,
@@ -40,13 +40,13 @@ class o {
40
40
  destroy() {
41
41
  this.ratioDelegate?.detach(), this.ratioDelegate = null;
42
42
  }
43
- ensureContainer(t, i) {
44
- if (i)
45
- return i;
43
+ ensureContainer(t, a) {
44
+ if (a)
45
+ return a;
46
46
  if (t) {
47
- const a = document.getElementById(t);
48
- if (a)
49
- return a;
47
+ const i = document.getElementById(t);
48
+ if (i)
49
+ return i;
50
50
  }
51
51
  const n = t || this.id || "zylem-root", e = document.createElement("main");
52
52
  return e.setAttribute("id", n), e.style.position = "relative", e.style.width = "100%", e.style.height = "100%", document.body.appendChild(e), e;
@@ -1,6 +1,7 @@
1
1
  import { StageInterface } from "../types";
2
2
  import { GameInputConfig } from "./game-interfaces";
3
3
  import { AspectRatio, AspectRatioValue } from "../device/aspect-ratio";
4
+ import { RetroPresetKey } from "./game-retro-resolutions";
4
5
  export type GameConfigLike = Partial<{
5
6
  id: string;
6
7
  globals: Record<string, any>;
@@ -10,6 +11,13 @@ export type GameConfigLike = Partial<{
10
11
  input: GameInputConfig;
11
12
  /** numeric value or key in AspectRatio */
12
13
  aspectRatio: AspectRatioValue | keyof typeof AspectRatio;
14
+ /** console/display preset to derive aspect ratio */
15
+ preset: RetroPresetKey;
16
+ /** lock internal render buffer to this resolution (e.g., '256x240' or { width, height }) */
17
+ resolution: string | {
18
+ width: number;
19
+ height: number;
20
+ };
13
21
  fullscreen: boolean;
14
22
  /** CSS background value for document body */
15
23
  bodyBackground: string;
@@ -28,20 +36,24 @@ export declare class GameConfig {
28
36
  time: number;
29
37
  input: GameInputConfig | undefined;
30
38
  aspectRatio: number;
39
+ internalResolution: {
40
+ width: number;
41
+ height: number;
42
+ } | undefined;
31
43
  fullscreen: boolean;
32
44
  bodyBackground: string | undefined;
33
45
  container: HTMLElement;
34
46
  containerId?: string | undefined;
35
47
  canvas?: HTMLCanvasElement | undefined;
36
- constructor(id: string, globals: Record<string, any>, stages: StageInterface[], debug: boolean, time: number, input: GameInputConfig | undefined, aspectRatio: number, fullscreen: boolean, bodyBackground: string | undefined, container: HTMLElement, containerId?: string | undefined, canvas?: HTMLCanvasElement | undefined);
48
+ constructor(id: string, globals: Record<string, any>, stages: StageInterface[], debug: boolean, time: number, input: GameInputConfig | undefined, aspectRatio: number, internalResolution: {
49
+ width: number;
50
+ height: number;
51
+ } | undefined, fullscreen: boolean, bodyBackground: string | undefined, container: HTMLElement, containerId?: string | undefined, canvas?: HTMLCanvasElement | undefined);
37
52
  }
38
- export declare function createDefaultGameConfig(base?: Partial<Pick<GameConfig, 'id' | 'debug' | 'time' | 'input'>> & {
39
- stages?: StageInterface[];
40
- globals?: Record<string, any>;
41
- }): GameConfig;
42
53
  export declare function resolveGameConfig(user?: GameConfigLike): GameConfig;
43
54
  /**
44
55
  * Factory for authoring configuration objects in user code.
45
56
  * Returns a plain object that can be passed to `game(...)`.
46
57
  */
47
58
  export declare function gameConfig(config: GameConfigLike): GameConfigLike;
59
+ //# sourceMappingURL=game-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"game-config.d.ts","sourceRoot":"","sources":["../../../src/lib/game/game-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AACvE,OAAO,EAA0D,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAElH,MAAM,MAAM,cAAc,GAAG,OAAO,CAAC;IACpC,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC7B,MAAM,EAAE,cAAc,EAAE,CAAC;IACzB,KAAK,EAAE,OAAO,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,eAAe,CAAC;IACvB,0CAA0C;IAC1C,WAAW,EAAE,gBAAgB,GAAG,MAAM,OAAO,WAAW,CAAC;IACzD,oDAAoD;IACpD,MAAM,EAAE,cAAc,CAAC;IACvB,4FAA4F;IAC5F,UAAU,EAAE,MAAM,GAAG;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IACvD,UAAU,EAAE,OAAO,CAAC;IACpB,6CAA6C;IAC7C,cAAc,EAAE,MAAM,CAAC;IACvB,sCAAsC;IACtC,SAAS,EAAE,WAAW,CAAC;IACvB,kCAAkC;IAClC,WAAW,EAAE,MAAM,CAAC;IACpB,mDAAmD;IACnD,MAAM,EAAE,iBAAiB,CAAC;CAC1B,CAAC,CAAC;AAEH,qBAAa,UAAU;IAEd,EAAE,EAAE,MAAM;IACV,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAC5B,MAAM,EAAE,cAAc,EAAE;IACxB,KAAK,EAAE,OAAO;IACd,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE,eAAe,GAAG,SAAS;IAClC,WAAW,EAAE,MAAM;IACnB,kBAAkB,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS;IACjE,UAAU,EAAE,OAAO;IACnB,cAAc,EAAE,MAAM,GAAG,SAAS;IAClC,SAAS,EAAE,WAAW;IACtB,WAAW,CAAC,EAAE,MAAM;IACpB,MAAM,CAAC,EAAE,iBAAiB;gBAZ1B,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC5B,MAAM,EAAE,cAAc,EAAE,EACxB,KAAK,EAAE,OAAO,EACd,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,eAAe,GAAG,SAAS,EAClC,WAAW,EAAE,MAAM,EACnB,kBAAkB,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS,EACjE,UAAU,EAAE,OAAO,EACnB,cAAc,EAAE,MAAM,GAAG,SAAS,EAClC,SAAS,EAAE,WAAW,EACtB,WAAW,CAAC,EAAE,MAAM,YAAA,EACpB,MAAM,CAAC,EAAE,iBAAiB,YAAA;CAElC;AAsCD,wBAAgB,iBAAiB,CAAC,IAAI,CAAC,EAAE,cAAc,GAAG,UAAU,CAoEnE;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,cAAc,GAAG,cAAc,CAEjE"}
@@ -1,5 +1,6 @@
1
- import { AspectRatio as d } from "../device/aspect-ratio.js";
2
- class g {
1
+ import { AspectRatio as p } from "../device/aspect-ratio.js";
2
+ import { getDisplayAspect as b, parseResolution as y, getPresetResolution as R } from "./game-retro-resolutions.js";
3
+ class f {
3
4
  id;
4
5
  globals;
5
6
  stages;
@@ -7,47 +8,71 @@ class g {
7
8
  time;
8
9
  input;
9
10
  aspectRatio;
11
+ internalResolution;
10
12
  fullscreen;
11
13
  bodyBackground;
12
14
  container;
13
15
  containerId;
14
16
  canvas;
15
- constructor(n, o, e, i, a, c, s, l, u, m, f, p) {
16
- this.id = n, this.globals = o, this.stages = e, this.debug = i, this.time = a, this.input = c, this.aspectRatio = s, this.fullscreen = l, this.bodyBackground = u, this.container = m, this.containerId = f, this.canvas = p;
17
+ constructor(i, o, n, e, l, d, r, a, g, c, s, h, m) {
18
+ this.id = i, this.globals = o, this.stages = n, this.debug = e, this.time = l, this.input = d, this.aspectRatio = r, this.internalResolution = a, this.fullscreen = g, this.bodyBackground = c, this.container = s, this.containerId = h, this.canvas = m;
17
19
  }
18
20
  }
19
- function r(t, n) {
20
- if (n)
21
- return n;
21
+ function u(t, i) {
22
+ if (i)
23
+ return i;
22
24
  if (t) {
23
- const i = document.getElementById(t);
24
- if (i)
25
- return i;
25
+ const e = document.getElementById(t);
26
+ if (e)
27
+ return e;
26
28
  }
27
- const o = t || "zylem-root", e = document.createElement("main");
28
- return e.setAttribute("id", o), e.style.position = "relative", e.style.width = "100%", e.style.height = "100%", document.body.appendChild(e), e;
29
+ const o = t || "zylem-root", n = document.createElement("main");
30
+ return n.setAttribute("id", o), n.style.position = "relative", n.style.width = "100%", n.style.height = "100%", document.body.appendChild(n), n;
29
31
  }
30
- function b(t) {
31
- const n = t?.id ?? "zylem", o = r(n);
32
- return new g(n, t?.globals ?? {}, t?.stages ?? [], !!t?.debug, t?.time ?? 0, t?.input, d.SixteenByNine, !0, "#000000", o, n, void 0);
32
+ function B(t) {
33
+ const i = t?.id ?? "zylem", o = u(i);
34
+ return new f(i, t?.globals ?? {}, t?.stages ?? [], !!t?.debug, t?.time ?? 0, t?.input, p.SixteenByNine, void 0, !0, "#000000", o, i, void 0);
33
35
  }
34
- function y(t) {
35
- const n = b({
36
+ function C(t) {
37
+ const i = B({
36
38
  id: t?.id ?? "zylem",
37
39
  debug: !!t?.debug,
38
40
  time: t?.time ?? 0,
39
41
  input: t?.input,
40
42
  stages: t?.stages ?? [],
41
43
  globals: t?.globals ?? {}
42
- }), o = t?.containerId ?? n.containerId, e = r(o, t?.container ?? null), i = t?.aspectRatio ?? n.aspectRatio, a = typeof i == "number" ? i : d[i] ?? d.SixteenByNine, c = t?.fullscreen ?? n.fullscreen, s = t?.bodyBackground ?? n.bodyBackground, l = t?.canvas ?? void 0;
43
- return new g(t?.id ?? n.id, t?.globals ?? n.globals, t?.stages ?? n.stages, !!(t?.debug ?? n.debug), t?.time ?? n.time, t?.input ?? n.input, a, c, s, e, o, l);
44
+ }), o = t?.containerId ?? i.containerId, n = u(o, t?.container ?? null), e = t?.aspectRatio;
45
+ let l = i.aspectRatio;
46
+ if (typeof e == "number" || e && typeof e == "string")
47
+ l = typeof e == "number" ? e : p[e] ?? i.aspectRatio;
48
+ else if (t?.preset)
49
+ try {
50
+ l = b(t.preset) || i.aspectRatio;
51
+ } catch {
52
+ l = i.aspectRatio;
53
+ }
54
+ const d = t?.fullscreen ?? i.fullscreen, r = t?.bodyBackground ?? i.bodyBackground;
55
+ let a;
56
+ if (t?.resolution) {
57
+ if (typeof t.resolution == "string") {
58
+ const c = y(t.resolution);
59
+ if (c && (a = c), !a && t.preset) {
60
+ const s = R(t.preset, t.resolution);
61
+ s && (a = { width: s.width, height: s.height });
62
+ }
63
+ } else if (typeof t.resolution == "object") {
64
+ const c = t.resolution.width, s = t.resolution.height;
65
+ Number.isFinite(c) && Number.isFinite(s) && (a = { width: c, height: s });
66
+ }
67
+ }
68
+ const g = t?.canvas ?? void 0;
69
+ return new f(t?.id ?? i.id, t?.globals ?? i.globals, t?.stages ?? i.stages, !!(t?.debug ?? i.debug), t?.time ?? i.time, t?.input ?? i.input, l, a, d, r, n, o, g);
44
70
  }
45
- function B(t) {
71
+ function k(t) {
46
72
  return { ...t };
47
73
  }
48
74
  export {
49
- g as GameConfig,
50
- b as createDefaultGameConfig,
51
- B as gameConfig,
52
- y as resolveGameConfig
75
+ f as GameConfig,
76
+ k as gameConfig,
77
+ C as resolveGameConfig
53
78
  };
@@ -1,14 +1,9 @@
1
1
  import { Stage } from '../stage/stage';
2
- import type { BasicTypes, GlobalVariablesType, ZylemGameConfig, GameInputConfig } from './game-interfaces';
3
- export declare const gameDefaultsState: Partial<ZylemGameConfig<Stage, any, GlobalVariablesType>>;
4
- /** Replace multiple defaults at once (shallow merge). */
5
- export declare function setGameDefaults(partial: Partial<ZylemGameConfig<Stage, any, GlobalVariablesType>>): void;
6
- /** Reset defaults back to library defaults. */
7
- export declare function resetGameDefaults(): void;
2
+ import type { BasicTypes, BaseGlobals, GameInputConfig } from './game-interfaces';
8
3
  /**
9
4
  * Get a plain object copy of the current defaults.
10
5
  */
11
- export declare function getGameDefaultConfig<TGlobals extends Record<string, BasicTypes> = GlobalVariablesType>(): {
6
+ export declare function getGameDefaultConfig<TGlobals extends Record<string, BasicTypes> = BaseGlobals>(): {
12
7
  id: string;
13
8
  globals: TGlobals;
14
9
  stages: Stage[];
@@ -16,3 +11,4 @@ export declare function getGameDefaultConfig<TGlobals extends Record<string, Bas
16
11
  time?: number;
17
12
  input?: GameInputConfig;
18
13
  };
14
+ //# sourceMappingURL=game-default.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"game-default.d.ts","sourceRoot":"","sources":["../../../src/lib/game/game-default.ts"],"names":[],"mappings":"AACA,OAAO,EAAS,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAmB,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAiCnG;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,SAAS,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,GAAG,WAAW,KAAK;IAClG,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,QAAQ,CAAC;IAClB,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,eAAe,CAAC;CACxB,CASA"}
@@ -19,6 +19,5 @@ function g() {
19
19
  };
20
20
  }
21
21
  export {
22
- t as gameDefaultsState,
23
22
  g as getGameDefaultConfig
24
23
  };
@@ -1,6 +1,6 @@
1
1
  import { UpdateFunction } from "../core/base-node-life-cycle";
2
2
  export type BasicTypes = number | string | boolean;
3
- export type GlobalVariablesType = Record<string, BasicTypes>;
3
+ export type BaseGlobals = Record<string, BasicTypes>;
4
4
  export type KeyboardMapping = Record<string, string[]>;
5
5
  export type MouseMapping = Record<string, string[]>;
6
6
  export interface GameInputPlayerConfig {
@@ -17,7 +17,7 @@ export interface GameInputConfig {
17
17
  p7?: GameInputPlayerConfig;
18
18
  p8?: GameInputPlayerConfig;
19
19
  }
20
- export interface ZylemGameConfig<StageInterface, GameInterface, TGlobals extends Record<string, BasicTypes> = GlobalVariablesType> {
20
+ export interface ZylemGameConfig<StageInterface, GameInterface, TGlobals extends BaseGlobals> {
21
21
  id: string;
22
22
  globals?: TGlobals;
23
23
  stages?: StageInterface[];
@@ -26,3 +26,4 @@ export interface ZylemGameConfig<StageInterface, GameInterface, TGlobals extends
26
26
  time?: number;
27
27
  input?: GameInputConfig;
28
28
  }
29
+ //# sourceMappingURL=game-interfaces.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"game-interfaces.d.ts","sourceRoot":"","sources":["../../../src/lib/game/game-interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAE9D,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AACnD,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;AAErD,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;AACvD,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;AAEpD,MAAM,WAAW,qBAAqB;IACrC,GAAG,CAAC,EAAE,eAAe,CAAC;IACtB,KAAK,CAAC,EAAE,YAAY,CAAC;CACrB;AAED,MAAM,WAAW,eAAe;IAC/B,EAAE,CAAC,EAAE,qBAAqB,CAAC;IAC3B,EAAE,CAAC,EAAE,qBAAqB,CAAC;IAC3B,EAAE,CAAC,EAAE,qBAAqB,CAAC;IAC3B,EAAE,CAAC,EAAE,qBAAqB,CAAC;IAC3B,EAAE,CAAC,EAAE,qBAAqB,CAAC;IAC3B,EAAE,CAAC,EAAE,qBAAqB,CAAC;IAC3B,EAAE,CAAC,EAAE,qBAAqB,CAAC;IAC3B,EAAE,CAAC,EAAE,qBAAqB,CAAC;CAC3B;AAED,MAAM,WAAW,eAAe,CAAC,cAAc,EAAE,aAAa,EAAE,QAAQ,SAAS,WAAW;IAC3F,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,CAAC,EAAE,QAAQ,CAAC;IACnB,MAAM,CAAC,EAAE,cAAc,EAAE,CAAC;IAC1B,MAAM,CAAC,EAAE,cAAc,CAAC,aAAa,CAAC,CAAC;IACvC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,eAAe,CAAC;CACxB"}
@@ -0,0 +1,25 @@
1
+ export type RetroResolution = {
2
+ key: string;
3
+ width: number;
4
+ height: number;
5
+ notes?: string;
6
+ };
7
+ export type RetroPreset = {
8
+ displayAspect: number;
9
+ resolutions: RetroResolution[];
10
+ };
11
+ /**
12
+ * Retro and console display presets.
13
+ * displayAspect represents the intended display aspect (letterboxing target),
14
+ * not necessarily the raw pixel aspect of internal buffers.
15
+ */
16
+ declare const RetroPresets: Record<string, RetroPreset>;
17
+ export type RetroPresetKey = keyof typeof RetroPresets;
18
+ export declare function getDisplayAspect(preset: RetroPresetKey): number;
19
+ export declare function getPresetResolution(preset: RetroPresetKey, key?: string): RetroResolution | undefined;
20
+ export declare function parseResolution(text: string): {
21
+ width: number;
22
+ height: number;
23
+ } | null;
24
+ export {};
25
+ //# sourceMappingURL=game-retro-resolutions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"game-retro-resolutions.d.ts","sourceRoot":"","sources":["../../../src/lib/game/game-retro-resolutions.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAE7F,MAAM,MAAM,WAAW,GAAG;IACzB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,eAAe,EAAE,CAAC;CAC/B,CAAC;AAEF;;;;GAIG;AACH,QAAA,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAuD7C,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,MAAM,OAAO,YAAY,CAAC;AAEvD,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,cAAc,GAAG,MAAM,CAE/D;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,cAAc,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,eAAe,GAAG,SAAS,CAKrG;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAStF"}
@@ -0,0 +1,80 @@
1
+ const n = {
2
+ NES: {
3
+ displayAspect: 1.3333333333333333,
4
+ resolutions: [
5
+ { key: "256x240", width: 256, height: 240, notes: "Standard NTSC; effective 240p." }
6
+ ]
7
+ },
8
+ SNES: {
9
+ displayAspect: 1.3333333333333333,
10
+ resolutions: [
11
+ { key: "256x224", width: 256, height: 224, notes: "Common 240p-equivalent mode." },
12
+ { key: "512x448", width: 512, height: 448, notes: "Hi-res interlaced (480i)." }
13
+ ]
14
+ },
15
+ N64: {
16
+ displayAspect: 1.3333333333333333,
17
+ resolutions: [
18
+ { key: "320x240", width: 320, height: 240, notes: "Common 240p mode." },
19
+ { key: "640x480", width: 640, height: 480, notes: "Higher resolution (480i)." }
20
+ ]
21
+ },
22
+ PS1: {
23
+ displayAspect: 1.3333333333333333,
24
+ resolutions: [
25
+ { key: "320x240", width: 320, height: 240, notes: "Progressive 240p common." },
26
+ { key: "640x480", width: 640, height: 480, notes: "Interlaced 480i for higher detail." }
27
+ ]
28
+ },
29
+ PS2: {
30
+ displayAspect: 1.3333333333333333,
31
+ resolutions: [
32
+ { key: "640x480", width: 640, height: 480, notes: "480i/480p baseline." },
33
+ { key: "720x480", width: 720, height: 480, notes: "480p (widescreen capable in some titles)." },
34
+ { key: "1280x720", width: 1280, height: 720, notes: "720p (select titles)." }
35
+ ]
36
+ },
37
+ PS5: {
38
+ displayAspect: 1.7777777777777777,
39
+ resolutions: [
40
+ { key: "720x480", width: 720, height: 480, notes: "Legacy compatibility." },
41
+ { key: "1280x720", width: 1280, height: 720, notes: "720p." },
42
+ { key: "1920x1080", width: 1920, height: 1080, notes: "1080p." },
43
+ { key: "2560x1440", width: 2560, height: 1440, notes: "1440p." },
44
+ { key: "3840x2160", width: 3840, height: 2160, notes: "4K (up to 120Hz)." },
45
+ { key: "7680x4320", width: 7680, height: 4320, notes: "8K (limited)." }
46
+ ]
47
+ },
48
+ XboxOne: {
49
+ displayAspect: 1.7777777777777777,
50
+ resolutions: [
51
+ { key: "1280x720", width: 1280, height: 720, notes: "720p (original)." },
52
+ { key: "1920x1080", width: 1920, height: 1080, notes: "1080p (original)." },
53
+ { key: "3840x2160", width: 3840, height: 2160, notes: "4K UHD (S/X models)." }
54
+ ]
55
+ }
56
+ };
57
+ function h(e) {
58
+ return n[e].displayAspect;
59
+ }
60
+ function r(e, o) {
61
+ const t = n[e]?.resolutions || [];
62
+ if (!o)
63
+ return t[0];
64
+ const i = o.toLowerCase().replace(/\s+/g, "").replace("×", "x");
65
+ return t.find((s) => s.key.toLowerCase() === i);
66
+ }
67
+ function l(e) {
68
+ if (!e)
69
+ return null;
70
+ const t = String(e).toLowerCase().trim().replace(/\s+/g, "").replace("×", "x").match(/^(\d+)x(\d+)$/);
71
+ if (!t)
72
+ return null;
73
+ const i = parseInt(t[1], 10), s = parseInt(t[2], 10);
74
+ return !Number.isFinite(i) || !Number.isFinite(s) ? null : { width: i, height: s };
75
+ }
76
+ export {
77
+ h as getDisplayAspect,
78
+ r as getPresetResolution,
79
+ l as parseResolution
80
+ };