canvasengine 2.0.0-beta.38 → 2.0.0-beta.39

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 (32) hide show
  1. package/dist/{DebugRenderer-DxJSMb9B.js → DebugRenderer-Rrw9FlTd.js} +2 -2
  2. package/dist/{DebugRenderer-DxJSMb9B.js.map → DebugRenderer-Rrw9FlTd.js.map} +1 -1
  3. package/dist/components/Button.d.ts +50 -3
  4. package/dist/components/Button.d.ts.map +1 -1
  5. package/dist/components/Joystick.d.ts +36 -0
  6. package/dist/components/Joystick.d.ts.map +1 -0
  7. package/dist/components/index.d.ts +1 -0
  8. package/dist/components/index.d.ts.map +1 -1
  9. package/dist/directives/Controls.d.ts +16 -7
  10. package/dist/directives/Controls.d.ts.map +1 -1
  11. package/dist/directives/GamepadControls.d.ts +3 -1
  12. package/dist/directives/GamepadControls.d.ts.map +1 -1
  13. package/dist/directives/JoystickControls.d.ts +172 -0
  14. package/dist/directives/JoystickControls.d.ts.map +1 -0
  15. package/dist/directives/index.d.ts +1 -0
  16. package/dist/directives/index.d.ts.map +1 -1
  17. package/dist/engine/reactive.d.ts.map +1 -1
  18. package/dist/{index-BgNWflRE.js → index-BQ99FClW.js} +5543 -5141
  19. package/dist/index-BQ99FClW.js.map +1 -0
  20. package/dist/index.global.js +7 -7
  21. package/dist/index.global.js.map +1 -1
  22. package/dist/index.js +59 -57
  23. package/package.json +1 -1
  24. package/src/components/Button.ts +168 -41
  25. package/src/components/Joystick.ts +361 -0
  26. package/src/components/index.ts +2 -1
  27. package/src/directives/Controls.ts +42 -8
  28. package/src/directives/GamepadControls.ts +40 -11
  29. package/src/directives/JoystickControls.ts +396 -0
  30. package/src/directives/index.ts +1 -0
  31. package/src/engine/reactive.ts +41 -14
  32. package/dist/index-BgNWflRE.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  import { Bounds as F, Rectangle as C, Container as M, Graphics as x, BigPool as b } from "pixi.js";
2
- import { F as _, E as p } from "./index-BgNWflRE.js";
2
+ import { F as _, E as p } from "./index-BQ99FClW.js";
3
3
  var l = /* @__PURE__ */ ((e) => (e.Margin = "margin", e.Padding = "padding", e.Border = "border", e.Flex = "flex", e.Content = "content", e))(l || {});
4
4
  function w(e, t) {
5
5
  const r = `getComputed${t.charAt(0).toUpperCase() + t.slice(1)}`;
@@ -169,4 +169,4 @@ class y {
169
169
  export {
170
170
  y as DebugRenderer
171
171
  };
172
- //# sourceMappingURL=DebugRenderer-DxJSMb9B.js.map
172
+ //# sourceMappingURL=DebugRenderer-Rrw9FlTd.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"DebugRenderer-DxJSMb9B.js","sources":["../../../node_modules/.pnpm/@pixi+layout@3.0.2_@types+react@19.1.3_pixi.js@8.9.2_react@19.1.0_yoga-layout@3.2.1/node_modules/@pixi/layout/dist/core/debug/calculateDebugRegions.mjs","../../../node_modules/.pnpm/@pixi+layout@3.0.2_@types+react@19.1.3_pixi.js@8.9.2_react@19.1.0_yoga-layout@3.2.1/node_modules/@pixi/layout/dist/core/debug/DebugNode.mjs","../../../node_modules/.pnpm/@pixi+layout@3.0.2_@types+react@19.1.3_pixi.js@8.9.2_react@19.1.0_yoga-layout@3.2.1/node_modules/@pixi/layout/dist/core/debug/DebugRenderer.mjs"],"sourcesContent":["import { Bounds, Rectangle } from \"pixi.js\";\nimport { Edge, FlexDirection } from \"yoga-layout/load\";\nvar DebugRegionType = /* @__PURE__ */ ((DebugRegionType2) => {\n DebugRegionType2[\"Margin\"] = \"margin\";\n DebugRegionType2[\"Padding\"] = \"padding\";\n DebugRegionType2[\"Border\"] = \"border\";\n DebugRegionType2[\"Flex\"] = \"flex\";\n DebugRegionType2[\"Content\"] = \"content\";\n return DebugRegionType2;\n})(DebugRegionType || {});\nfunction getEdgeValues(layout, type) {\n const method = `getComputed${type.charAt(0).toUpperCase() + type.slice(1)}`;\n return {\n top: layout.yoga[method](Edge.Top),\n right: layout.yoga[method](Edge.Right),\n bottom: layout.yoga[method](Edge.Bottom),\n left: layout.yoga[method](Edge.Left)\n };\n}\nfunction calculateRegions(layout, regions) {\n const { width, height } = layout.computedLayout;\n const margin = getEdgeValues(layout, \"margin\");\n const border = getEdgeValues(layout, \"border\");\n const padding = getEdgeValues(layout, \"padding\");\n const marginRegion = regions.get(\n \"margin\"\n /* Margin */\n );\n marginRegion.outer.x = -margin.left;\n marginRegion.outer.y = -margin.top;\n marginRegion.outer.width = width + margin.left + margin.right;\n marginRegion.outer.height = height + margin.top + margin.bottom;\n marginRegion.inner.x = 0;\n marginRegion.inner.y = 0;\n marginRegion.inner.width = width;\n marginRegion.inner.height = height;\n const borderRegion = regions.get(\n \"border\"\n /* Border */\n );\n borderRegion.outer.x = 0;\n borderRegion.outer.y = 0;\n borderRegion.outer.width = width;\n borderRegion.outer.height = height;\n borderRegion.inner.x = border.left;\n borderRegion.inner.y = border.top;\n borderRegion.inner.width = width - border.left - border.right;\n borderRegion.inner.height = height - border.top - border.bottom;\n const paddingRegion = regions.get(\n \"padding\"\n /* Padding */\n );\n paddingRegion.outer.copyFrom(borderRegion.inner);\n paddingRegion.inner.x = padding.left + border.left;\n paddingRegion.inner.y = padding.top + border.top;\n paddingRegion.inner.width = width - padding.left - padding.right - border.left - border.right;\n paddingRegion.inner.height = height - padding.top - padding.bottom - border.top - border.bottom;\n calculateFlexRegion(layout, regions);\n}\nfunction calculateFlexRegion(layout, regions) {\n var _a;\n const flexRegion = regions.get(\n \"flex\"\n /* Flex */\n );\n const paddingRegion = regions.get(\n \"padding\"\n /* Padding */\n );\n flexRegion.outer.copyFrom(paddingRegion.inner);\n const bounds = new Bounds();\n const children = layout.yoga.getChildCount();\n for (let i = 0; i < children; i++) {\n const child = layout.yoga.getChild(i);\n const computedBounds = child.getComputedLayout();\n bounds.addRect(\n new Rectangle(computedBounds.left, computedBounds.top, computedBounds.width, computedBounds.height)\n );\n }\n const flexDir = layout.yoga.getFlexDirection();\n if (flexDir === FlexDirection.Column || flexDir === FlexDirection.ColumnReverse) {\n bounds.width = flexRegion.outer.width;\n bounds.x = flexRegion.outer.x;\n } else {\n bounds.height = flexRegion.outer.height;\n bounds.y = flexRegion.outer.y;\n }\n (_a = flexRegion.inner) == null ? void 0 : _a.copyFrom(bounds.rectangle);\n regions.get(\n \"content\"\n /* Content */\n ).outer.copyFrom(bounds.rectangle);\n}\nexport {\n DebugRegionType,\n calculateRegions\n};\n//# sourceMappingURL=calculateDebugRegions.mjs.map\n","var __defProp = Object.defineProperty;\nvar __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;\nvar __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== \"symbol\" ? key + \"\" : key, value);\nimport { Container, Graphics as Graphics$1 } from \"pixi.js\";\nimport { DebugRegionType } from \"./calculateDebugRegions.mjs\";\nfunction lerpColor(start, end, t) {\n const r = Math.round(start[0] + (end[0] - start[0]) * t);\n const g = Math.round(start[1] + (end[1] - start[1]) * t);\n const b = Math.round(start[2] + (end[2] - start[2]) * t);\n return `rgb(${r},${g},${b})`;\n}\nclass DebugNode extends Container {\n constructor() {\n super();\n /** Graphics objects for each region type */\n __publicField(this, \"graphics\");\n __publicField(this, \"heatGraphics\");\n this.graphics = /* @__PURE__ */ new Map();\n Object.values(DebugRegionType).forEach((type) => {\n const graphics = new Graphics$1();\n this.graphics.set(type, graphics);\n this.addChild(graphics);\n });\n this.heatGraphics = new Graphics$1();\n this.addChild(this.heatGraphics);\n }\n /**\n * Initialize the debug object with region data\n */\n init(regions) {\n const { target, alpha, heat } = regions;\n if (!regions.heatOnly) {\n Object.entries(regions).forEach(([type, region]) => {\n if (type === \"target\" || type === \"alpha\" || type === \"heat\" || type === \"heatOnly\") return;\n region = region;\n const graphics = this.graphics.get(type);\n if (!graphics || !region.draw) return;\n if (region.inner) {\n this.drawCutBox(graphics, region.outer, region.inner, region.color, alpha);\n } else {\n const { x, y, width, height } = region.outer;\n graphics.rect(x, y, width, Math.max(height, 1));\n graphics.fill({ color: region.color, alpha });\n }\n });\n }\n const { invalidationCount, draw } = heat;\n if (invalidationCount > 0 && draw) {\n const MAX_INVALIDATE_COUNT = 20;\n const normalizedAlpha = Math.min(invalidationCount / MAX_INVALIDATE_COUNT, 1);\n const marginRegion = regions[DebugRegionType.Margin];\n const startColor = [255, 255, 0];\n const endColor = [255, 0, 0];\n const color = lerpColor(startColor, endColor, normalizedAlpha);\n this.heatGraphics.rect(\n marginRegion.outer.x,\n marginRegion.outer.y,\n marginRegion.outer.width,\n marginRegion.outer.height\n );\n this.heatGraphics.fill({ color, alpha: Math.min(0.3, normalizedAlpha) });\n this.heatGraphics.stroke({ color, alpha: Math.max(0.3, normalizedAlpha), pixelLine: true });\n }\n this.position.set(target.x, target.y);\n }\n /**\n * Reset the debug object's state\n */\n reset() {\n this.graphics.forEach((graphics) => graphics.clear());\n this.heatGraphics.clear();\n this.removeFromParent();\n }\n /**\n * Draw a box with a cut-out center\n */\n drawCutBox(graphics, outer, inner, color, alpha) {\n const { x, y, width, height } = outer;\n const { x: innerX, y: innerY, width: innerWidth, height: innerHeight } = inner;\n graphics.rect(x, y, width, height);\n graphics.fill({ color, alpha });\n graphics.rect(innerX, innerY, innerWidth, innerHeight);\n graphics.cut();\n }\n}\nexport {\n DebugNode\n};\n//# sourceMappingURL=DebugNode.mjs.map\n","var __defProp = Object.defineProperty;\nvar __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;\nvar __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== \"symbol\" ? key + \"\" : key, value);\nimport { Container, Rectangle, BigPool } from \"pixi.js\";\nimport { DebugRegionType, calculateRegions } from \"./calculateDebugRegions.mjs\";\nimport { DebugNode } from \"./DebugNode.mjs\";\nclass DebugRenderer {\n constructor() {\n /** Container for all debug visuals */\n __publicField(this, \"holder\", new Container());\n /** Region data for each debug type */\n __publicField(this, \"regions\", /* @__PURE__ */ new Map());\n /** Color configuration for each region type */\n __publicField(this, \"colors\", {\n [DebugRegionType.Margin]: \"#B68655\",\n [DebugRegionType.Padding]: \"#BAC57F\",\n [DebugRegionType.Border]: \"#E7C583\",\n [DebugRegionType.Content]: \"#89B1BE\",\n [DebugRegionType.Flex]: \"#6E28D9\"\n });\n /** Global alpha value for all regions */\n __publicField(this, \"alpha\", 0.75);\n Object.values(DebugRegionType).forEach((type) => {\n this.regions.set(type, {\n outer: new Rectangle(),\n inner: new Rectangle()\n });\n });\n this.holder.__devtoolIgnore = true;\n this.holder.__devtoolIgnoreChildren = true;\n this.holder.eventMode = \"none\";\n this.holder.interactiveChildren = false;\n }\n /**\n * Clean up previous render state\n */\n reset() {\n for (let i = this.holder.children.length - 1; i >= 0; i--) {\n const child = this.holder.children[i];\n BigPool.return(child);\n }\n }\n /**\n * Render debug visuals for the given layout\n */\n render(layout) {\n calculateRegions(layout, this.regions);\n const regionData = Object.values(DebugRegionType).reduce(\n (acc, type) => {\n const region = this.regions.get(type);\n if (!region) return acc;\n const drawString = `debugDraw${type.charAt(0).toUpperCase()}${type.slice(1)}`;\n acc[type] = {\n ...region,\n color: this.colors[type],\n draw: layout._styles.custom[drawString] ?? true\n };\n return acc;\n },\n {}\n );\n const { left, top } = layout.computedLayout;\n const pos = layout.target.getGlobalPosition();\n const debugObject = BigPool.get(DebugNode, {\n ...regionData,\n target: { x: pos.x + left, y: pos.y + top },\n alpha: this.alpha,\n heat: {\n invalidationCount: layout._modificationCount,\n draw: layout._styles.custom.debugHeat !== false\n },\n heatOnly: !layout._styles.custom.debug\n });\n this.holder.addChildAt(debugObject, 0);\n }\n /**\n * Clean up the debug renderer\n */\n destroy() {\n this.reset();\n this.holder.destroy();\n this.regions.clear();\n }\n}\nexport {\n DebugRenderer\n};\n//# sourceMappingURL=DebugRenderer.mjs.map\n"],"names":["DebugRegionType","DebugRegionType2","getEdgeValues","layout","type","method","Edge","calculateRegions","regions","width","height","margin","border","padding","marginRegion","borderRegion","paddingRegion","calculateFlexRegion","_a","flexRegion","bounds","Bounds","children","i","computedBounds","Rectangle","flexDir","FlexDirection","__defProp","__defNormalProp","obj","key","value","__publicField","lerpColor","start","end","t","r","g","b","DebugNode","Container","graphics","Graphics$1","target","alpha","heat","region","x","y","invalidationCount","draw","normalizedAlpha","color","outer","inner","innerX","innerY","innerWidth","innerHeight","DebugRenderer","child","BigPool","regionData","acc","drawString","left","top","pos","debugObject"],"mappings":";;AAEA,IAAIA,IAAmC,kBAACC,OACtCA,EAAiB,SAAY,UAC7BA,EAAiB,UAAa,WAC9BA,EAAiB,SAAY,UAC7BA,EAAiB,OAAU,QAC3BA,EAAiB,UAAa,WACvBA,IACND,KAAmB,CAAA,CAAE;AACxB,SAASE,EAAcC,GAAQC,GAAM;AACnC,QAAMC,IAAS,cAAcD,EAAK,OAAO,CAAC,EAAE,YAAa,IAAGA,EAAK,MAAM,CAAC,CAAC;AACzE,SAAO;AAAA,IACL,KAAKD,EAAO,KAAKE,CAAM,EAAEC,EAAK,GAAG;AAAA,IACjC,OAAOH,EAAO,KAAKE,CAAM,EAAEC,EAAK,KAAK;AAAA,IACrC,QAAQH,EAAO,KAAKE,CAAM,EAAEC,EAAK,MAAM;AAAA,IACvC,MAAMH,EAAO,KAAKE,CAAM,EAAEC,EAAK,IAAI;AAAA,EACpC;AACH;AACA,SAASC,EAAiBJ,GAAQK,GAAS;AACzC,QAAM,EAAE,OAAAC,GAAO,QAAAC,EAAQ,IAAGP,EAAO,gBAC3BQ,IAAST,EAAcC,GAAQ,QAAQ,GACvCS,IAASV,EAAcC,GAAQ,QAAQ,GACvCU,IAAUX,EAAcC,GAAQ,SAAS,GACzCW,IAAeN,EAAQ;AAAA,IAC3B;AAAA;AAAA,EAED;AACD,EAAAM,EAAa,MAAM,IAAI,CAACH,EAAO,MAC/BG,EAAa,MAAM,IAAI,CAACH,EAAO,KAC/BG,EAAa,MAAM,QAAQL,IAAQE,EAAO,OAAOA,EAAO,OACxDG,EAAa,MA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AAQ,IAAI5C,CAAI;AACpC,YAAI,CAAC4C,EAAQ,QAAOiB;AACpB,cAAMC,IAAa,YAAY9D,EAAK,OAAO,CAAC,EAAE,YAAW,CAAE,GAAGA,EAAK,MAAM,CAAC,CAAC;AAC3E,eAAA6D,EAAI7D,CAAI,IAAI;AAAA,UACV,GAAG4C;AAAA,UACH,OAAO,KAAK,OAAO5C,CAAI;AAAA,UACvB,MAAMD,EAAO,QAAQ,OAAO+D,CAAU,KAAK;AAAA,QAC5C,GACMD;AAAA,MACR;AAAA,MACD,CAAA;AAAA,IACD,GACK,EAAE,MAAAE,GAAM,KAAAC,EAAK,IAAGjE,EAAO,gBACvBkE,IAAMlE,EAAO,OAAO,kBAAmB,GACvCmE,IAAcP,EAAQ,IAAItB,GAAW;AAAA,MACzC,GAAGuB;AAAA,MACH,QAAQ,EAAE,GAAGK,EAAI,IAAIF,GAAM,GAAGE,EAAI,IAAID,EAAK;AAAA,MAC3C,OAAO,KAAK;AAAA,MACZ,MAAM;AAAA,QACJ,mBAAmBjE,EAAO;AAAA,QAC1B,MAAMA,EAAO,QAAQ,OAAO,cAAc;AAAA,MAC3C;AAAA,MACD,UAAU,CAACA,EAAO,QAAQ,OAAO;AAAA,IACvC,CAAK;AACD,SAAK,OAAO,WAAWmE,GAAa,CAAC;AAAA,EACzC;AAAA;AAAA;AAAA;AAAA,EAIE,UAAU;AACR,SAAK,MAAO,GACZ,KAAK,OAAO,QAAS,GACrB,KAAK,QAAQ,MAAO;AAAA,EACxB;AACA;","x_google_ignoreList":[0,1,2]}
1
+ {"version":3,"file":"DebugRenderer-Rrw9FlTd.js","sources":["../../../node_modules/.pnpm/@pixi+layout@3.0.2_@types+react@19.1.3_pixi.js@8.9.2_react@19.1.0_yoga-layout@3.2.1/node_modules/@pixi/layout/dist/core/debug/calculateDebugRegions.mjs","../../../node_modules/.pnpm/@pixi+layout@3.0.2_@types+react@19.1.3_pixi.js@8.9.2_react@19.1.0_yoga-layout@3.2.1/node_modules/@pixi/layout/dist/core/debug/DebugNode.mjs","../../../node_modules/.pnpm/@pixi+layout@3.0.2_@types+react@19.1.3_pixi.js@8.9.2_react@19.1.0_yoga-layout@3.2.1/node_modules/@pixi/layout/dist/core/debug/DebugRenderer.mjs"],"sourcesContent":["import { Bounds, Rectangle } from \"pixi.js\";\nimport { Edge, FlexDirection } from \"yoga-layout/load\";\nvar DebugRegionType = /* @__PURE__ */ ((DebugRegionType2) => {\n DebugRegionType2[\"Margin\"] = \"margin\";\n DebugRegionType2[\"Padding\"] = \"padding\";\n DebugRegionType2[\"Border\"] = \"border\";\n DebugRegionType2[\"Flex\"] = \"flex\";\n DebugRegionType2[\"Content\"] = \"content\";\n return DebugRegionType2;\n})(DebugRegionType || {});\nfunction getEdgeValues(layout, type) {\n const method = `getComputed${type.charAt(0).toUpperCase() + type.slice(1)}`;\n return {\n top: layout.yoga[method](Edge.Top),\n right: layout.yoga[method](Edge.Right),\n bottom: layout.yoga[method](Edge.Bottom),\n left: layout.yoga[method](Edge.Left)\n };\n}\nfunction calculateRegions(layout, regions) {\n const { width, height } = layout.computedLayout;\n const margin = getEdgeValues(layout, \"margin\");\n const border = getEdgeValues(layout, \"border\");\n const padding = getEdgeValues(layout, \"padding\");\n const marginRegion = regions.get(\n \"margin\"\n /* Margin */\n );\n marginRegion.outer.x = -margin.left;\n marginRegion.outer.y = -margin.top;\n marginRegion.outer.width = width + margin.left + margin.right;\n marginRegion.outer.height = height + margin.top + margin.bottom;\n marginRegion.inner.x = 0;\n marginRegion.inner.y = 0;\n marginRegion.inner.width = width;\n marginRegion.inner.height = height;\n const borderRegion = regions.get(\n \"border\"\n /* Border */\n );\n borderRegion.outer.x = 0;\n borderRegion.outer.y = 0;\n borderRegion.outer.width = width;\n borderRegion.outer.height = height;\n borderRegion.inner.x = border.left;\n borderRegion.inner.y = border.top;\n borderRegion.inner.width = width - border.left - border.right;\n borderRegion.inner.height = height - border.top - border.bottom;\n const paddingRegion = regions.get(\n \"padding\"\n /* Padding */\n );\n paddingRegion.outer.copyFrom(borderRegion.inner);\n paddingRegion.inner.x = padding.left + border.left;\n paddingRegion.inner.y = padding.top + border.top;\n paddingRegion.inner.width = width - padding.left - padding.right - border.left - border.right;\n paddingRegion.inner.height = height - padding.top - padding.bottom - border.top - border.bottom;\n calculateFlexRegion(layout, regions);\n}\nfunction calculateFlexRegion(layout, regions) {\n var _a;\n const flexRegion = regions.get(\n \"flex\"\n /* Flex */\n );\n const paddingRegion = regions.get(\n \"padding\"\n /* Padding */\n );\n flexRegion.outer.copyFrom(paddingRegion.inner);\n const bounds = new Bounds();\n const children = layout.yoga.getChildCount();\n for (let i = 0; i < children; i++) {\n const child = layout.yoga.getChild(i);\n const computedBounds = child.getComputedLayout();\n bounds.addRect(\n new Rectangle(computedBounds.left, computedBounds.top, computedBounds.width, computedBounds.height)\n );\n }\n const flexDir = layout.yoga.getFlexDirection();\n if (flexDir === FlexDirection.Column || flexDir === FlexDirection.ColumnReverse) {\n bounds.width = flexRegion.outer.width;\n bounds.x = flexRegion.outer.x;\n } else {\n bounds.height = flexRegion.outer.height;\n bounds.y = flexRegion.outer.y;\n }\n (_a = flexRegion.inner) == null ? void 0 : _a.copyFrom(bounds.rectangle);\n regions.get(\n \"content\"\n /* Content */\n ).outer.copyFrom(bounds.rectangle);\n}\nexport {\n DebugRegionType,\n calculateRegions\n};\n//# sourceMappingURL=calculateDebugRegions.mjs.map\n","var __defProp = Object.defineProperty;\nvar __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;\nvar __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== \"symbol\" ? key + \"\" : key, value);\nimport { Container, Graphics as Graphics$1 } from \"pixi.js\";\nimport { DebugRegionType } from \"./calculateDebugRegions.mjs\";\nfunction lerpColor(start, end, t) {\n const r = Math.round(start[0] + (end[0] - start[0]) * t);\n const g = Math.round(start[1] + (end[1] - start[1]) * t);\n const b = Math.round(start[2] + (end[2] - start[2]) * t);\n return `rgb(${r},${g},${b})`;\n}\nclass DebugNode extends Container {\n constructor() {\n super();\n /** Graphics objects for each region type */\n __publicField(this, \"graphics\");\n __publicField(this, \"heatGraphics\");\n this.graphics = /* @__PURE__ */ new Map();\n Object.values(DebugRegionType).forEach((type) => {\n const graphics = new Graphics$1();\n this.graphics.set(type, graphics);\n this.addChild(graphics);\n });\n this.heatGraphics = new Graphics$1();\n this.addChild(this.heatGraphics);\n }\n /**\n * Initialize the debug object with region data\n */\n init(regions) {\n const { target, alpha, heat } = regions;\n if (!regions.heatOnly) {\n Object.entries(regions).forEach(([type, region]) => {\n if (type === \"target\" || type === \"alpha\" || type === \"heat\" || type === \"heatOnly\") return;\n region = region;\n const graphics = this.graphics.get(type);\n if (!graphics || !region.draw) return;\n if (region.inner) {\n this.drawCutBox(graphics, region.outer, region.inner, region.color, alpha);\n } else {\n const { x, y, width, height } = region.outer;\n graphics.rect(x, y, width, Math.max(height, 1));\n graphics.fill({ color: region.color, alpha });\n }\n });\n }\n const { invalidationCount, draw } = heat;\n if (invalidationCount > 0 && draw) {\n const MAX_INVALIDATE_COUNT = 20;\n const normalizedAlpha = Math.min(invalidationCount / MAX_INVALIDATE_COUNT, 1);\n const marginRegion = regions[DebugRegionType.Margin];\n const startColor = [255, 255, 0];\n const endColor = [255, 0, 0];\n const color = lerpColor(startColor, endColor, normalizedAlpha);\n this.heatGraphics.rect(\n marginRegion.outer.x,\n marginRegion.outer.y,\n marginRegion.outer.width,\n marginRegion.outer.height\n );\n this.heatGraphics.fill({ color, alpha: Math.min(0.3, normalizedAlpha) });\n this.heatGraphics.stroke({ color, alpha: Math.max(0.3, normalizedAlpha), pixelLine: true });\n }\n this.position.set(target.x, target.y);\n }\n /**\n * Reset the debug object's state\n */\n reset() {\n this.graphics.forEach((graphics) => graphics.clear());\n this.heatGraphics.clear();\n this.removeFromParent();\n }\n /**\n * Draw a box with a cut-out center\n */\n drawCutBox(graphics, outer, inner, color, alpha) {\n const { x, y, width, height } = outer;\n const { x: innerX, y: innerY, width: innerWidth, height: innerHeight } = inner;\n graphics.rect(x, y, width, height);\n graphics.fill({ color, alpha });\n graphics.rect(innerX, innerY, innerWidth, innerHeight);\n graphics.cut();\n }\n}\nexport {\n DebugNode\n};\n//# sourceMappingURL=DebugNode.mjs.map\n","var __defProp = Object.defineProperty;\nvar __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;\nvar __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== \"symbol\" ? key + \"\" : key, value);\nimport { Container, Rectangle, BigPool } from \"pixi.js\";\nimport { DebugRegionType, calculateRegions } from \"./calculateDebugRegions.mjs\";\nimport { DebugNode } from \"./DebugNode.mjs\";\nclass DebugRenderer {\n constructor() {\n /** Container for all debug visuals */\n __publicField(this, \"holder\", new Container());\n /** Region data for each debug type */\n __publicField(this, \"regions\", /* @__PURE__ */ new Map());\n /** Color configuration for each region type */\n __publicField(this, \"colors\", {\n [DebugRegionType.Margin]: \"#B68655\",\n [DebugRegionType.Padding]: \"#BAC57F\",\n [DebugRegionType.Border]: \"#E7C583\",\n [DebugRegionType.Content]: \"#89B1BE\",\n [DebugRegionType.Flex]: \"#6E28D9\"\n });\n /** Global alpha value for all regions */\n __publicField(this, \"alpha\", 0.75);\n Object.values(DebugRegionType).forEach((type) => {\n this.regions.set(type, {\n outer: new Rectangle(),\n inner: new Rectangle()\n });\n });\n this.holder.__devtoolIgnore = true;\n this.holder.__devtoolIgnoreChildren = true;\n this.holder.eventMode = \"none\";\n this.holder.interactiveChildren = false;\n }\n /**\n * Clean up previous render state\n */\n reset() {\n for (let i = this.holder.children.length - 1; i >= 0; i--) {\n const child = this.holder.children[i];\n BigPool.return(child);\n }\n }\n /**\n * Render debug visuals for the given layout\n */\n render(layout) {\n calculateRegions(layout, this.regions);\n const regionData = Object.values(DebugRegionType).reduce(\n (acc, type) => {\n const region = this.regions.get(type);\n if (!region) return acc;\n const drawString = `debugDraw${type.charAt(0).toUpperCase()}${type.slice(1)}`;\n acc[type] = {\n ...region,\n color: this.colors[type],\n draw: layout._styles.custom[drawString] ?? true\n };\n return acc;\n },\n {}\n );\n const { left, top } = layout.computedLayout;\n const pos = layout.target.getGlobalPosition();\n const debugObject = BigPool.get(DebugNode, {\n ...regionData,\n target: { x: pos.x + left, y: pos.y + top },\n alpha: this.alpha,\n heat: {\n invalidationCount: layout._modificationCount,\n draw: layout._styles.custom.debugHeat !== false\n },\n heatOnly: !layout._styles.custom.debug\n });\n this.holder.addChildAt(debugObject, 0);\n }\n /**\n * Clean up the debug renderer\n */\n destroy() {\n this.reset();\n this.holder.destroy();\n this.regions.clear();\n }\n}\nexport {\n DebugRenderer\n};\n//# sourceMappingURL=DebugRenderer.mjs.map\n"],"names":["DebugRegionType","DebugRegionType2","getEdgeValues","layout","type","method","Edge","calculateRegions","regions","width","height","margin","border","padding","marginRegion","borderRegion","paddingRegion","calculateFlexRegion","_a","flexRegion","bounds","Bounds","children","i","computedBounds","Rectangle","flexDir","FlexDirection","__defProp","__defNormalProp","obj","key","value","__publicField","lerpColor","start","end","t","r","g","b","DebugNode","Container","graphics","Graphics$1","target","alpha","heat","region","x","y","invalidationCount","draw","normalizedAlpha","color","outer","inner","innerX","innerY","innerWidth","innerHeight","DebugRenderer","child","BigPool","regionData","acc","drawString","left","top","pos","debugObject"],"mappings":";;AAEA,IAAIA,IAAmC,kBAACC,OACtCA,EAAiB,SAAY,UAC7BA,EAAiB,UAAa,WAC9BA,EAAiB,SAAY,UAC7BA,EAAiB,OAAU,QAC3BA,EAAiB,UAAa,WACvBA,IACND,KAAmB,CAAA,CAAE;AACxB,SAASE,EAAcC,GAAQC,GAAM;AACnC,QAAMC,IAAS,cAAcD,EAAK,OAAO,CAAC,EAAE,YAAa,IAAGA,EAAK,MAAM,CAAC,CAAC;AACzE,SAAO;AAAA,IACL,KAAKD,EAAO,KAAKE,CAAM,EAAEC,EAAK,GAAG;AAAA,IACjC,OAA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,QAC1B,MAAMA,EAAO,QAAQ,OAAO,cAAc;AAAA,MAC3C;AAAA,MACD,UAAU,CAACA,EAAO,QAAQ,OAAO;AAAA,IACvC,CAAK;AACD,SAAK,OAAO,WAAWmE,GAAa,CAAC;AAAA,EACzC;AAAA;AAAA;AAAA;AAAA,EAIE,UAAU;AACR,SAAK,MAAO,GACZ,KAAK,OAAO,QAAS,GACrB,KAAK,QAAQ,MAAO;AAAA,EACxB;AACA;","x_google_ignoreList":[0,1,2]}
@@ -1,4 +1,7 @@
1
1
  import { FederatedPointerEvent } from 'pixi.js';
2
+ import { ControlsDirective } from '../directives/Controls';
3
+ import { JoystickControls } from '../directives/JoystickControls';
4
+ import { Element } from '../engine/reactive';
2
5
 
3
6
  /**
4
7
  * Button states for visual feedback
@@ -74,6 +77,16 @@ export interface ButtonProps {
74
77
  visible?: boolean;
75
78
  /** Button cursor */
76
79
  cursor?: string;
80
+ /** Controls instance to automatically apply button events to (e.g., ControlsDirective or JoystickControls) */
81
+ controls?: ControlsDirective | JoystickControls | any;
82
+ /** Name of the control to trigger with applyControl when button is clicked */
83
+ controlName?: string;
84
+ /** Shape of the button background: 'rect', 'circle', or 'ellipse' */
85
+ shape?: 'rect' | 'circle' | 'ellipse';
86
+ /** Custom background component or element (replaces default background if provided) */
87
+ background?: Element | any;
88
+ /** Custom children components for button content (takes priority over text if provided) */
89
+ children?: Element[];
77
90
  }
78
91
  /**
79
92
  * Creates a Button component with interactive states and customizable styling.
@@ -85,18 +98,52 @@ export interface ButtonProps {
85
98
  * The button is built using a Container with background and text elements,
86
99
  * providing reactive state management and event handling.
87
100
  *
88
- * @param props - Button configuration including text, styling, and event handlers
101
+ * ## Features
102
+ *
103
+ * - **Controls Integration**: Automatically trigger controls via `applyControl` when clicked
104
+ * - **Multiple Shapes**: Support for rect, circle, and ellipse shapes
105
+ * - **Custom Content**: Use children components for custom button content
106
+ * - **Custom Background**: Provide a custom background component
107
+ *
108
+ * @param props - Button configuration including text, styling, controls, shape, and event handlers
89
109
  * @returns A reactive Button component
90
110
  * @example
91
111
  * ```typescript
92
112
  * // Simple button with text and click handler
93
113
  * const simpleButton = Button({
94
114
  * text: "Click Me",
95
- * onClick: () => console.log("Button clicked!"),
115
+ * click: () => console.log("Button clicked!"),
96
116
  * width: 150,
97
117
  * height: 50
98
118
  * });
99
119
  *
120
+ * // Button with controls integration
121
+ * const jumpButton = Button({
122
+ * text: "Jump",
123
+ * controls: controlsInstance,
124
+ * controlName: "jump",
125
+ * width: 120,
126
+ * height: 40
127
+ * });
128
+ *
129
+ * // Circular button
130
+ * const circleButton = Button({
131
+ * text: "Action",
132
+ * shape: "circle",
133
+ * width: 100,
134
+ * height: 100
135
+ * });
136
+ *
137
+ * // Button with custom content (children)
138
+ * const customButton = Button({
139
+ * shape: "circle",
140
+ * width: 80,
141
+ * height: 80,
142
+ * children: [
143
+ * h(Sprite, { image: "icon.png", width: 50, height: 50 })
144
+ * ]
145
+ * });
146
+ *
100
147
  * // Styled button with custom colors
101
148
  * const styledButton = Button({
102
149
  * text: "Styled Button",
@@ -132,5 +179,5 @@ export interface ButtonProps {
132
179
  * });
133
180
  * ```
134
181
  */
135
- export declare function Button(props: ButtonProps): import('..').Element<import('./DisplayObject').ComponentInstance> | Promise<import('..').Element<import('./DisplayObject').ComponentInstance>>;
182
+ export declare function Button(props: ButtonProps): Element<import('./DisplayObject').ComponentInstance> | Promise<Element<import('./DisplayObject').ComponentInstance>>;
136
183
  //# sourceMappingURL=Button.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../src/components/Button.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAOhD;;GAEG;AACH,oBAAY,WAAW;IACrB,MAAM,WAAW;IACjB,KAAK,UAAU;IACf,OAAO,YAAY;IACnB,QAAQ,aAAa;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,sCAAsC;IACtC,eAAe,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I,CAAC;IACpD,+BAA+B;IAC/B,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,qBAAqB,KAAK,IAAI,CAAC;IACnD,6BAA6B;IAC7B,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,qBAAqB,KAAK,IAAI,CAAC;IACjD,iCAAiC;IACjC,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,mBAAmB;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,oBAAoB;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,wBAAwB;IACxB,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,wBAAwB;IACxB,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,2BAA2B;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,wBAAwB;IACxB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,oBAAoB;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,8GAA8G;IAC9G,QAAQ,CAAC,EAAE,iBAAiB,GAAG,gBAAgB,GAAG,GAAG,CAAC;IACtD,8EAA8E;IAC9E,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,qEAAqE;IACrE,KAAK,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS,CAAC;IACtC,uFAAuF;IACvF,UAAU,CAAC,EAAE,OAAO,GAAG,GAAG,CAAC;IAC3B,2FAA2F;IAC3F,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC;CACtB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0FG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,WAAW,wHA6MxC"}
@@ -0,0 +1,36 @@
1
+ export interface JoystickChangeEvent {
2
+ angle: number;
3
+ direction: Direction;
4
+ power: number;
5
+ }
6
+ export declare enum Direction {
7
+ LEFT = "left",
8
+ TOP = "top",
9
+ BOTTOM = "bottom",
10
+ RIGHT = "right",
11
+ TOP_LEFT = "top_left",
12
+ TOP_RIGHT = "top_right",
13
+ BOTTOM_LEFT = "bottom_left",
14
+ BOTTOM_RIGHT = "bottom_right"
15
+ }
16
+ export interface JoystickSettings {
17
+ outer?: string;
18
+ inner?: string;
19
+ outerScale?: {
20
+ x: number;
21
+ y: number;
22
+ };
23
+ innerScale?: {
24
+ x: number;
25
+ y: number;
26
+ };
27
+ innerColor?: string;
28
+ outerColor?: string;
29
+ onChange?: (data: JoystickChangeEvent) => void;
30
+ onStart?: () => void;
31
+ onEnd?: () => void;
32
+ /** Controls instance to automatically apply joystick events to (e.g., JoystickControls or ControlsDirective) */
33
+ controls?: any;
34
+ }
35
+ export declare function Joystick(opts?: JoystickSettings): import('../').Element<import('./DisplayObject').ComponentInstance> | Promise<import('../').Element<import('./DisplayObject').ComponentInstance>>;
36
+ //# sourceMappingURL=Joystick.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Joystick.d.ts","sourceRoot":"","sources":["../../src/components/Joystick.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,SAAS,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,oBAAY,SAAS;IACnB,IAAI,SAAS;IACb,GAAG,QAAQ;IACX,MAAM,WAAW;IACjB,KAAK,UAAU;IACf,QAAQ,aAAa;IACrB,SAAS,cAAc;IACvB,WAAW,gBAAgB;IAC3B,YAAY,iBAAiB;CAC9B;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACtC,UAAU,CAAC,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACtC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,mBAAmB,KAAK,IAAI,CAAC;IAC/C,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,IAAI,CAAC;IACnB,gHAAgH;IAChH,QAAQ,CAAC,EAAE,GAAG,CAAC;CAChB;AAED,wBAAgB,QAAQ,CAAC,IAAI,GAAE,gBAAqB,oJAgUnD"}
@@ -14,4 +14,5 @@ export { type ComponentInstance } from './DisplayObject';
14
14
  export { DOMContainer } from './DOMContainer';
15
15
  export { DOMElement } from './DOMElement';
16
16
  export { Button, ButtonState, type ButtonProps, type ButtonStyle } from './Button';
17
+ export { Joystick, type JoystickSettings, type JoystickChangeEvent } from './Joystick';
17
18
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,WAAW,CAAA;AAC1E,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAC7B,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAC/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACjC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAC/B,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAC7B,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;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M,cAAc,CAAA;AACzC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,KAAK,WAAW,EAAE,KAAK,WAAW,EAAE,MAAM,UAAU,CAAA;AAClF,OAAO,EAAE,QAAQ,EAAE,KAAK,gBAAgB,EAAE,KAAK,mBAAmB,EAAE,MAAM,YAAY,CAAA"}
@@ -3,14 +3,15 @@ import { Element } from '../engine/reactive';
3
3
  import { Controls } from './ControlsBase';
4
4
  import { KeyboardControls } from './KeyboardControls';
5
5
  import { GamepadControls } from './GamepadControls';
6
+ import { JoystickControls } from './JoystickControls';
6
7
 
7
8
  /**
8
- * Controls directive that coordinates keyboard and gamepad input systems
9
+ * Controls directive that coordinates keyboard, gamepad, and joystick input systems
9
10
  *
10
- * This directive automatically activates both keyboard and gamepad controls when available.
11
+ * This directive automatically activates keyboard, gamepad, and joystick controls when available.
11
12
  * The gamepad is automatically enabled if joypad.js is detected in the environment.
12
13
  *
13
- * Both systems share the same control configuration and can work simultaneously.
14
+ * All systems share the same control configuration and can work simultaneously.
14
15
  *
15
16
  * @example
16
17
  * ```html
@@ -25,9 +26,10 @@ import { GamepadControls } from './GamepadControls';
25
26
  export declare class ControlsDirective extends Directive {
26
27
  private keyboardControls;
27
28
  private gamepadControls;
29
+ private joystickControls;
28
30
  /**
29
31
  * Initialize the controls directive
30
- * Sets up keyboard and gamepad controls if available
32
+ * Sets up keyboard, gamepad, and joystick controls if available
31
33
  */
32
34
  onInit(element: Element): void;
33
35
  /**
@@ -66,17 +68,18 @@ export declare class ControlsDirective extends Directive {
66
68
  *
67
69
  * @param controlName - Name of the control
68
70
  * @param isDown - Whether the control is pressed (true) or released (false)
71
+ * @param payload - Optional payload to pass to keyDown/keyUp callbacks (e.g., { power: 0.8 })
69
72
  * @returns Promise that resolves when the action is complete
70
73
  */
71
- applyControl(controlName: string | number, isDown?: boolean): Promise<void>;
74
+ applyControl(controlName: string | number, isDown?: boolean, payload?: any): Promise<void>;
72
75
  /**
73
76
  * Stop listening to inputs
74
- * Stops both keyboard and gamepad input processing
77
+ * Stops keyboard, gamepad, and joystick input processing
75
78
  */
76
79
  stopInputs(): void;
77
80
  /**
78
81
  * Resume listening to inputs
79
- * Resumes both keyboard and gamepad input processing
82
+ * Resumes keyboard, gamepad, and joystick input processing
80
83
  */
81
84
  listenInputs(): void;
82
85
  /**
@@ -98,5 +101,11 @@ export declare class ControlsDirective extends Directive {
98
101
  * @returns GamepadControls instance or null
99
102
  */
100
103
  get gamepad(): GamepadControls | null;
104
+ /**
105
+ * Get the joystick controls instance
106
+ *
107
+ * @returns JoystickControls instance or null
108
+ */
109
+ get joystick(): JoystickControls | null;
101
110
  }
102
111
  //# sourceMappingURL=Controls.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Controls.d.ts","sourceRoot":"","sources":["../../src/directives/Controls.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAqB,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAgB,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAiB,MAAM,mBAAmB,CAAC;AAEnE;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,iBAAkB,SAAQ,SAAS;IAC5C,OAAO,CAAC,gBAAgB,CAAiC;IACzD,OAAO,CAAC,eAAe,CAAgC;IAEvD;;;OAGG;IACH,MAAM,CAAC,OAAO,EAAE,OAAO;IAmBvB;;OAEG;IACH,OAAO,CAAC,OAAO,EAAE,OAAO;IAExB;;;OAGG;IACH,QAAQ,CAAC,KAAK,EAAE,GAAG;IAanB;;OAEG;IACH,SAAS,CAAC,OAAO,EAAE,OAAO;IAY1B;;;;;;OAMG;IACH,UAAU,CAAC,SAAS,EAAE,MAAM;IAI5B;;;;;OAKG;IACH,WAAW;;;IAIX;;;;;;;OAOG;IACG,YAAY,CA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,GAAG,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;IAYhG;;;OAGG;IACH,UAAU;IAYV;;;OAGG;IACH,YAAY;IAYZ;;;;;OAKG;IACH,IAAI,OAAO,IAAI,QAAQ,CAEtB;IAED;;;;OAIG;IACH,IAAI,QAAQ,IAAI,gBAAgB,GAAG,IAAI,CAEtC;IAED;;;;OAIG;IACH,IAAI,OAAO,IAAI,eAAe,GAAG,IAAI,CAEpC;IAED;;;;OAIG;IACH,IAAI,QAAQ,IAAI,gBAAgB,GAAG,IAAI,CAEtC;CACJ"}
@@ -85,6 +85,7 @@ export declare class GamepadControls extends ControlsBase {
85
85
  private joypad;
86
86
  private connectCallbacks;
87
87
  private disconnectCallbacks;
88
+ private currentPower;
88
89
  /**
89
90
  * Setup gamepad event listeners
90
91
  * Initializes joypad.js if available
@@ -157,9 +158,10 @@ export declare class GamepadControls extends ControlsBase {
157
158
  *
158
159
  * @param controlName - Name of the control
159
160
  * @param isDown - Whether the control is pressed (true) or released (false)
161
+ * @param payload - Optional payload to pass to keyDown/keyUp callbacks (e.g., { power: 0.8 })
160
162
  * @returns Promise that resolves when the action is complete
161
163
  */
162
- applyControl(controlName: string | number, isDown?: boolean): Promise<void>;
164
+ applyControl(controlName: string | number, isDown?: boolean, payload?: any): Promise<void>;
163
165
  /**
164
166
  * Override setInputs to extract gamepad config
165
167
  */
@@ -1 +1 @@
1
- {"version":3,"file":"GamepadControls.d.ts","sourceRoot":"","sources":["../../src/directives/GamepadControls.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,WAAW,CAAA;AAElB;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,WAAW,aAAa;IAC1B,iDAAiD;IACjD,OAAO,C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;OAGG;IACH,OAAO,CAAC,sBAAsB;IAwB9B;;;OAGG;IACH,SAAS,CAAC,OAAO,IAAI,IAAI;IAiBzB;;;;;;OAMG;IACH,mBAAmB,CAAC,MAAM,EAAE,OAAO,CAAC,aAAa,CAAC,GAAG,IAAI;IA6BzD;;;;;OAKG;IACH,oBAAoB,CAAC,MAAM,EAAE,QAAQ,GAAG;QAAE,OAAO,CAAC,EAAE,aAAa,CAAA;KAAE,GAAG,IAAI;IAM1E;;;;OAIG;IACH,gBAAgB,IAAI,aAAa;IAIjC;;;;;;;;OAQG;IACG,YAAY,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;IAsDhG;;OAEG;IACH,SAAS,CAAC,MAAM,EAAE,QAAQ,GAAG;QAAE,OAAO,CAAC,EAAE,aAAa,CAAA;KAAE,GAAG,IAAI;IAK/D;;;;;;;;;;OAUG;IACH,SAAS,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI;IAIrC;;;;;;;;;;OAUG;IACH,YAAY,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI;IAIxC;;;;OAIG;IACH,UAAU,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI;IAOtC;;;;OAIG;IACH,aAAa,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI;IAOzC;;;;OAIG;IACH,WAAW,IAAI,OAAO;IAItB;;;;;;;;;OASG;IACH,MAAM,IAAI,IAAI;CAKjB"}
@@ -0,0 +1,172 @@
1
+ import { ControlsBase, Controls } from './ControlsBase';
2
+
3
+ /**
4
+ * Joystick directions reported by the Joystick component
5
+ */
6
+ export type JoystickDirection = 'left' | 'right' | 'top' | 'bottom' | 'top_left' | 'top_right' | 'bottom_left' | 'bottom_right';
7
+ /**
8
+ * Joystick change event payload
9
+ */
10
+ export interface JoystickChangeEvent {
11
+ angle: number;
12
+ direction: JoystickDirection;
13
+ power: number;
14
+ }
15
+ /**
16
+ * Joystick configuration interface
17
+ *
18
+ * @example
19
+ * ```ts
20
+ * const joystickConfig: JoystickConfig = {
21
+ * enabled: true,
22
+ * directionMapping: {
23
+ * 'top': 'up',
24
+ * 'bottom': 'down',
25
+ * 'left': 'left',
26
+ * 'right': 'right',
27
+ * 'top_left': ['up', 'left'],
28
+ * 'top_right': ['up', 'right'],
29
+ * 'bottom_left': ['down', 'left'],
30
+ * 'bottom_right': ['down', 'right']
31
+ * },
32
+ * moveInterval: 50,
33
+ * threshold: 0.1
34
+ * };
35
+ * ```
36
+ */
37
+ export interface JoystickConfig {
38
+ /** Whether joystick is enabled (default: true) */
39
+ enabled?: boolean;
40
+ /** Mapping of joystick direction names to control names (can be single string or array for diagonals) */
41
+ directionMapping?: {
42
+ [joystickDirection: string]: string | string[];
43
+ };
44
+ /** Interval in milliseconds for repeating movement actions (default: 50) */
45
+ moveInterval?: number;
46
+ /** Threshold for power value to trigger movement (default: 0.1) */
47
+ threshold?: number;
48
+ }
49
+ /**
50
+ * Joystick input controls implementation
51
+ *
52
+ * Handles joystick input events from the Joystick component and maps them to control actions.
53
+ * Supports directional movement with configurable mappings, including diagonal directions.
54
+ *
55
+ * The joystick controls work by receiving change events from a Joystick component instance.
56
+ *
57
+ * @example
58
+ * ```ts
59
+ * const joystickControls = new JoystickControls();
60
+ * joystickControls.setInputs({
61
+ * up: {
62
+ * repeat: true,
63
+ * bind: 'up',
64
+ * keyDown() {
65
+ * console.log('Up pressed');
66
+ * }
67
+ * }
68
+ * });
69
+ * joystickControls.updateJoystickConfig({
70
+ * enabled: true,
71
+ * directionMapping: {
72
+ * 'top': 'up'
73
+ * }
74
+ * });
75
+ * joystickControls.start();
76
+ *
77
+ * // Later, when joystick changes:
78
+ * joystickControls.handleJoystickChange({ angle: 90, direction: Direction.TOP, power: 0.8 });
79
+ * ```
80
+ */
81
+ export declare class JoystickControls extends ControlsBase {
82
+ private joystickEnabled;
83
+ private joystickConfig;
84
+ private joystickMoving;
85
+ private joystickDirections;
86
+ private joystickLastUpdate;
87
+ private joystickMoveInterval;
88
+ private currentPower;
89
+ /**
90
+ * Setup joystick event listeners
91
+ * Note: Joystick events are handled via handleJoystickChange() method
92
+ */
93
+ protected setupListeners(): void;
94
+ /**
95
+ * Cleanup joystick intervals
96
+ */
97
+ protected cleanup(): void;
98
+ /**
99
+ * Process joystick inputs each step
100
+ * Continuous actions are handled by the interval; no inactivity timeout here.
101
+ */
102
+ protected preStep(): void;
103
+ /**
104
+ * Handle joystick change event
105
+ * Called by the Joystick component when its position changes
106
+ *
107
+ * @param event - Joystick change event containing angle, direction, and power
108
+ */
109
+ handleJoystickChange(event: JoystickChangeEvent): void;
110
+ /**
111
+ * Handle joystick start event
112
+ * Called when user starts interacting with the joystick
113
+ */
114
+ handleJoystickStart(): void;
115
+ /**
116
+ * Handle joystick end event
117
+ * Called when user stops interacting with the joystick
118
+ */
119
+ handleJoystickEnd(): void;
120
+ /**
121
+ * Stop all active joystick movements
122
+ */
123
+ private stopAllMovements;
124
+ /**
125
+ * Process continuous joystick movement
126
+ * Called at intervals to repeat movement actions while joystick is active
127
+ */
128
+ private processJoystickMovement;
129
+ /**
130
+ * Update joystick configuration
131
+ * Merges provided config with defaults
132
+ *
133
+ * @param config - Partial joystick configuration
134
+ */
135
+ updateJoystickConfig(config: Partial<JoystickConfig>): void;
136
+ /**
137
+ * Extract joystick config from controls configuration and update
138
+ *
139
+ * @param inputs - Controls configuration that may contain a 'joystick' property
140
+ */
141
+ extractJoystickConfig(inputs: Controls & {
142
+ joystick?: JoystickConfig;
143
+ }): void;
144
+ /**
145
+ * Get the current joystick configuration
146
+ *
147
+ * @returns The joystick configuration object
148
+ */
149
+ getJoystickConfig(): JoystickConfig;
150
+ /**
151
+ * Apply a control action programmatically
152
+ * Uses the bound controls to trigger actions
153
+ *
154
+ * @param controlName - Name of the control
155
+ * @param isDown - Whether the control is pressed (true) or released (false)
156
+ * @returns Promise that resolves when the action is complete
157
+ */
158
+ applyControl(controlName: string | number, isDown?: boolean, payload?: any): Promise<void>;
159
+ /**
160
+ * Override setInputs to extract joystick config
161
+ */
162
+ setInputs(inputs: Controls & {
163
+ joystick?: JoystickConfig;
164
+ }): void;
165
+ /**
166
+ * Check if joystick is currently active
167
+ *
168
+ * @returns true if joystick is moving, false otherwise
169
+ */
170
+ isActive(): boolean;
171
+ }
172
+ //# sourceMappingURL=JoystickControls.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"JoystickControls.d.ts","sourceRoot":"","sources":["../../src/directives/JoystickControls.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAExD;;GAEG;AACH,MAAM,MAAM,iBAAiB,GACvB,MAAM,GACN,OAAO,GACP,KAAK,GACL,QAAQ,GACR,UAAU,GACV,WAAW,GACX,aAAa,GACb,cAAc,CAAC;AAErB;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,iBAAiB,CAAC;IAC7B,KAAK,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,WAAW,cAAc;IAC3B,kDAAkD;IAClD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,yGAAyG;IACzG,gBAAgB,CAAC,EAAE;QACf,CAAC,iBAAiB,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,CAAC;KAClD,CAAC;IACF,4EAA4E;IAC5E,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,mEAAmE;IACnE,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAgBD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,qBAAa,gBAAiB,SAAQ,YAAY;IAC9C,OAAO,CAAC,eAAe,CAAiB;IACxC,OAAO,CAAC,cAAc,CAKpB;IACF,OAAO,CAAC,cAAc,CAAkB;IACxC,OAAO,CAAC,kBAAkB,CAAwC;IAClE,OAAO,CAAC,kBAAkB,CAAa;IACvC,OAAO,CAAC,oBAAoB,CAAa;IACzC,OAAO,CAAC,YAAY,CAAa;IAEjC;;;OAGG;IACH,SAAS,CAAC,cAAc,IAAI,IAAI;IAKhC;;OAEG;IACH,SAAS,CAAC,OAAO,IAAI,IAAI;IAOzB;;;OAGG;IACH,SAAS,CAAC,OAAO,IAAI,IAAI;IAKzB;;;;;OAKG;IACH,oBAAoB,CAAC,KAAK,EAAE,mBAAmB,GAAG,IAAI;IAwEtD;;;OAGG;IACH,mBAAmB,IAAI,IAAI;IAM3B;;;OAGG;IACH,iBAAiB,IAAI,IAAI;IAKzB;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAkBxB;;;OAGG;IACH,OAAO,CAAC,uBAAuB;IAa/B;;;;;OAKG;IACH,oBAAoB,CAAC,MAAM,EAAE,OAAO,CAAC,cAAc,CAAC,GAAG,IAAI;IAS3D;;;;OAIG;IACH,qBAAqB,CAAC,MAAM,EAAE,QAAQ,GAAG;QAAE,QAAQ,CAAC,EAAE,cAAc,CAAA;KAAE,GAAG,IAAI;IAM7E;;;;OAIG;IACH,iBAAiB,IAAI,cAAc;IAInC;;;;;;;OAOG;IACG,YAAY,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;IAsDhG;;OAEG;IACH,SAAS,CAAC,MAAM,EAAE,QAAQ,GAAG;QAAE,QAAQ,CAAC,EAAE,cAAc,CAAA;KAAE,GAAG,IAAI;IAKjE;;;;OAIG;IACH,QAAQ,IAAI,OAAO;CAGtB"}
@@ -1,6 +1,7 @@
1
1
  export * from './ControlsBase';
2
2
  export * from './KeyboardControls';
3
3
  export * from './GamepadControls';
4
+ export * from './JoystickControls';
4
5
  export * from './Controls';
5
6
  export * from './Scheduler';
6
7
  export * from './ViewportFollow';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/directives/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,oBAAoB,CAAA;AAClC,cAAc,mBAAmB,CAAA;AACjC,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA;AAC3B,cAAc,kBAAkB,CAAA;AAEhC,cAAc,SAAS,CAAA;AACvB,cAAc,QAAQ,CAAA;AACtB,cAAc,cAAc,CAAA;AAC5B,cAAc,SAAS,CAAA;AACvB,cAAc,SAAS,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/directives/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,oBAAoB,CAAA;AAClC,cAAc,mBAAmB,CAAA;AACjC,cAAc,oBAAoB,CAAA;AAClC,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA;AAC3B,cAAc,kBAAkB,CAAA;AAEhC,cAAc,SAAS,CAAA;AACvB,cAAc,QAAQ,CAAA;AACtB,cAAc,cAAc,CAAA;AAC5B,cAAc,SAAS,CAAA;AACvB,cAAc,SAAS,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"reactive.d.ts","sourceRoot":"","sources":["../../src/engine/reactive.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6B,MAAM,EAAqF,MAAM,iBAAiB,CAAC;AACvJ,OAAO,EACL,UAAU,EACV,OAAO,EACP,YAAY,EAab,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,SAAS,EAAkB,MAAM,aAAa,CAAC;AAGxD,MAAM,WAAW,KAAK;IACpB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,KAAK,mBAAmB,GAAG;KACxB,GAAG,IAAI,MAAM,GAAG,mBAAmB,GAAG,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