canvasengine 2.0.0-beta.34 → 2.0.0-beta.35

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.
@@ -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-BLbc2zG5.js";
2
+ import { F as _, E as p } from "./index-B9ATEmLe.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-BYa_lwD-.js.map
172
+ //# sourceMappingURL=DebugRenderer-DMqhoMfE.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"DebugRenderer-BYa_lwD-.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,S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ixi+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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CmE,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]}
@@ -111,6 +111,50 @@ export declare class CanvasSprite extends CanvasSprite_base {
111
111
  onFinish: () => void;
112
112
  get renderer(): import('pixi.js').Renderer;
113
113
  private currentAnimationContainer;
114
+ /**
115
+ * Auto-detects image dimensions by loading the image and reading its natural size
116
+ * This is used when width/height are not explicitly provided in the spritesheet definition
117
+ *
118
+ * @param imagePath - Path to the image file
119
+ * @returns Object containing the detected width and height of the image
120
+ *
121
+ * @example
122
+ * ```typescript
123
+ * const { width, height } = await sprite.detectImageDimensions('path/to/image.png');
124
+ * // width: 256, height: 128
125
+ * ```
126
+ */
127
+ private detectImageDimensions;
128
+ /**
129
+ * Creates textures from a spritesheet image by cutting it into frames
130
+ * Automatically detects image dimensions if width/height are not provided
131
+ *
132
+ * @param options - Texture options containing image path, dimensions, and frame configuration
133
+ * @returns A 2D array of textures organized by rows and columns
134
+ *
135
+ * @example
136
+ * ```typescript
137
+ * // With explicit dimensions
138
+ * const textures = await sprite.createTextures({
139
+ * image: 'path/to/image.png',
140
+ * width: 256,
141
+ * height: 128,
142
+ * framesWidth: 4,
143
+ * framesHeight: 2,
144
+ * spriteWidth: 64,
145
+ * spriteHeight: 64
146
+ * });
147
+ *
148
+ * // Without dimensions (automatically detected)
149
+ * const textures = await sprite.createTextures({
150
+ * image: 'path/to/image.png',
151
+ * framesWidth: 4,
152
+ * framesHeight: 2,
153
+ * spriteWidth: 64,
154
+ * spriteHeight: 64
155
+ * });
156
+ * ```
157
+ */
114
158
  private createTextures;
115
159
  private createAnimations;
116
160
  onMount(params: Element<CanvasSprite>): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"Sprite.d.ts","sourceRoot":"","sources":["../../src/components/Sprite.ts"],"names":[],"mappings":"AACA,OAAO,EAA8B,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACrE,OAAO,EAIL,MAAM,IAAI,UAAU,EAEpB,OAAO,EACR,MAAM,SAAS,CAAC;AAEjB,OAAO,EACL,OAAO,EAIR,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EACL,eAAe,EACf,YAAY,EACZ,kBAAkB,EAClB,cAAc,EACd,gBAAgB,EACjB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAE3D,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAItC,KAAK,KAAK,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAE/B,KAAK,qBAAqB,GAAG,cAAc,GAAG;IAC5C,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,GAAG,KAAK,GACP,gBAAgB,CAAC;AAEnB,KAAK,mBAAmB,GAAG,qBAAqB,GAAG,YAAY,CAAC;AAChE,KAAK,yBAAyB,GAAG,qBAAqB,GAAG,kBAAkB,CAAC;AAM5E,KAAK,mBAAmB,GAAG;IACzB,OAAO,EAAE,mBAAmB,EAAE,CAAC;IAC/B,MAAM,EAAE,OAAO,EAAE,EAAE,CAAC;IACp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AQ,IAAI,CAAC,WAAW,EAAE,OAAO,CAAC;IACtE,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE;QACV,CAAC,EAAE,MAAM,CAAC;QACV,CAAC,EAAE,MAAM,CAAC;QACV,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;CACH;AAED,MAAM,WAAW,oBACf,SAAQ,IAAI,CAAC,WAAW,EAAE,OAAO,GAAG,WAAW,CAAC;IAChD,KAAK,EAAE;QACL,UAAU,EAAE,yBAAyB,CAAC;QACtC,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,MAAM,CAAC,EAAE,GAAG,CAAC;QACb,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;KACvB,CAAC;IACF,MAAM,CAAC,EAAE;QACP,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;QACxC,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;KACzC,CAAC;CACH;AAED,MAAM,MAAM,eAAe,GAAG,oBAAoB,GAAG,oBAAoB,CAAC;AAG1E,eAAO,MAAM,MAAM,EAAE,iBAAiB,CAAC,eAAe,CAErD,CAAC"}
@@ -0,0 +1,102 @@
1
+ import { Directive } from '../engine/directive';
2
+ import { Element } from '../engine/reactive';
3
+ import { Controls } from './ControlsBase';
4
+ import { KeyboardControls } from './KeyboardControls';
5
+ import { GamepadControls } from './GamepadControls';
6
+
7
+ /**
8
+ * Controls directive that coordinates keyboard and gamepad input systems
9
+ *
10
+ * This directive automatically activates both keyboard and gamepad controls when available.
11
+ * The gamepad is automatically enabled if joypad.js is detected in the environment.
12
+ *
13
+ * Both systems share the same control configuration and can work simultaneously.
14
+ *
15
+ * @example
16
+ * ```html
17
+ * <Sprite
18
+ * image="path/to/image.png"
19
+ * controls={controlsConfig}
20
+ * x={x}
21
+ * y={y}
22
+ * />
23
+ * ```
24
+ */
25
+ export declare class ControlsDirective extends Directive {
26
+ private keyboardControls;
27
+ private gamepadControls;
28
+ /**
29
+ * Initialize the controls directive
30
+ * Sets up keyboard and gamepad controls if available
31
+ */
32
+ onInit(element: Element): void;
33
+ /**
34
+ * Mount hook (no specific action needed)
35
+ */
36
+ onMount(element: Element): void;
37
+ /**
38
+ * Update controls configuration
39
+ * Updates both keyboard and gamepad controls
40
+ */
41
+ onUpdate(props: any): void;
42
+ /**
43
+ * Cleanup and destroy all control systems
44
+ */
45
+ onDestroy(element: Element): void;
46
+ /**
47
+ * Get a control by input name
48
+ * Delegates to keyboard controls (primary system)
49
+ *
50
+ * @param inputName - Name of the input/key
51
+ * @returns BoundKey if found, undefined otherwise
52
+ */
53
+ getControl(inputName: string): import('./ControlsBase').BoundKey;
54
+ /**
55
+ * Get all bound controls
56
+ * Delegates to keyboard controls (primary system)
57
+ *
58
+ * @returns Object mapping input names to BoundKey objects
59
+ */
60
+ getControls(): {
61
+ [key: string]: import('./ControlsBase').BoundKey;
62
+ };
63
+ /**
64
+ * Apply a control action programmatically
65
+ * Applies to both keyboard and gamepad if available
66
+ *
67
+ * @param controlName - Name of the control
68
+ * @param isDown - Whether the control is pressed (true) or released (false)
69
+ * @returns Promise that resolves when the action is complete
70
+ */
71
+ applyControl(controlName: string | number, isDown?: boolean): Promise<void>;
72
+ /**
73
+ * Stop listening to inputs
74
+ * Stops both keyboard and gamepad input processing
75
+ */
76
+ stopInputs(): void;
77
+ /**
78
+ * Resume listening to inputs
79
+ * Resumes both keyboard and gamepad input processing
80
+ */
81
+ listenInputs(): void;
82
+ /**
83
+ * Get the current controls configuration
84
+ * Returns keyboard controls options (both systems share the same config)
85
+ *
86
+ * @returns The controls options object
87
+ */
88
+ get options(): Controls;
89
+ /**
90
+ * Get the keyboard controls instance
91
+ *
92
+ * @returns KeyboardControls instance or null
93
+ */
94
+ get keyboard(): KeyboardControls | null;
95
+ /**
96
+ * Get the gamepad controls instance
97
+ *
98
+ * @returns GamepadControls instance or null
99
+ */
100
+ get gamepad(): GamepadControls | null;
101
+ }
102
+ //# sourceMappingURL=Controls.d.ts.map
@@ -0,0 +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,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IASjF;;;OAGG;IACH,UAAU;IASV;;;OAGG;IACH,YAAY;IASZ;;;;;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;CACJ"}
@@ -0,0 +1,198 @@
1
+ export interface ControlOptions {
2
+ repeat?: boolean;
3
+ bind: string | string[];
4
+ keyUp?: Function;
5
+ keyDown?: Function;
6
+ delay?: number | {
7
+ duration: number;
8
+ otherControls?: (string)[];
9
+ };
10
+ }
11
+ export interface Controls {
12
+ [controlName: string]: ControlOptions;
13
+ }
14
+ export type BoundKey = {
15
+ actionName: string;
16
+ options: ControlOptions;
17
+ parameters?: any;
18
+ };
19
+ /**
20
+ * Abstract base class for control systems (keyboard, gamepad, etc.)
21
+ *
22
+ * This class provides common functionality shared across all control implementations:
23
+ * - Input binding and management
24
+ * - Control configuration
25
+ * - Input state management
26
+ * - Common methods for querying and triggering controls
27
+ *
28
+ * @example
29
+ * ```ts
30
+ * class MyControls extends ControlsBase {
31
+ * protected setupListeners() {
32
+ * // Setup specific input listeners
33
+ * }
34
+ *
35
+ * protected cleanup() {
36
+ * // Cleanup specific resources
37
+ * }
38
+ *
39
+ * protected preStep() {
40
+ * // Process inputs each frame
41
+ * }
42
+ * }
43
+ * ```
44
+ */
45
+ export declare abstract class ControlsBase {
46
+ protected boundKeys: {
47
+ [keyName: string]: BoundKey;
48
+ };
49
+ protected stop: boolean;
50
+ protected _controlsOptions: Controls;
51
+ protected interval: any;
52
+ protected serverFps: number;
53
+ /**
54
+ * Setup input listeners specific to this control implementation
55
+ * Must be implemented by subclasses
56
+ */
57
+ protected abstract setupListeners(): void;
58
+ /**
59
+ * Cleanup resources specific to this control implementation
60
+ * Must be implemented by subclasses
61
+ */
62
+ protected abstract cleanup(): void;
63
+ /**
64
+ * Process inputs each step/frame
65
+ * Must be implemented by subclasses
66
+ */
67
+ protected abstract preStep(): void;
68
+ /**
69
+ * Start the control processing loop
70
+ * Initializes listeners and starts the interval
71
+ */
72
+ start(): void;
73
+ /**
74
+ * Stop the control processing and cleanup resources
75
+ */
76
+ destroy(): void;
77
+ /**
78
+ * Bind a key/input to a control action
79
+ *
80
+ * @param keys - Single key or array of keys to bind
81
+ * @param actionName - Name of the control action
82
+ * @param options - Control options (repeat, keyDown, keyUp, etc.)
83
+ * @param parameters - Optional parameters to pass to the control callbacks
84
+ */
85
+ protected bindKey(keys: string | string[], actionName: string, options: ControlOptions, parameters?: object): void;
86
+ /**
87
+ * Apply an input action for a bound key
88
+ * Can be overridden by subclasses for custom behavior
89
+ *
90
+ * @param keyName - Name of the key/input to process
91
+ */
92
+ protected applyInput(keyName: string): void;
93
+ /**
94
+ * Get a control by input name
95
+ *
96
+ * @param inputName - Name of the input/key
97
+ * @returns BoundKey if found, undefined otherwise
98
+ * @example
99
+ * ```ts
100
+ * const control = controls.getControl('up');
101
+ * if (control) {
102
+ * console.log(control.actionName); // 'up'
103
+ * }
104
+ * ```
105
+ */
106
+ getControl(inputName: string): BoundKey | undefined;
107
+ /**
108
+ * Get all bound controls
109
+ *
110
+ * @returns Object mapping input names to BoundKey objects
111
+ * @example
112
+ * ```ts
113
+ * const allControls = controls.getControls();
114
+ * console.log(Object.keys(allControls)); // ['up', 'down', 'left', 'right', ...]
115
+ * ```
116
+ */
117
+ getControls(): {
118
+ [key: string]: BoundKey;
119
+ };
120
+ /**
121
+ * Apply a control action programmatically
122
+ *
123
+ * Must be implemented by subclasses to provide input-specific behavior
124
+ *
125
+ * @param controlName - Name or identifier of the control
126
+ * @param isDown - Whether the control is pressed down (true) or released (false)
127
+ * @returns Promise that resolves when the control action is complete
128
+ * @example
129
+ * ```ts
130
+ * // Press a control
131
+ * await controls.applyControl('action', true);
132
+ *
133
+ * // Release a control
134
+ * await controls.applyControl('action', false);
135
+ *
136
+ * // Press and release (default)
137
+ * await controls.applyControl('action');
138
+ * ```
139
+ */
140
+ abstract applyControl(controlName: string | number, isDown?: boolean): Promise<void>;
141
+ /**
142
+ * Stop listening to inputs
143
+ * Input events will be ignored until listenInputs() is called
144
+ *
145
+ * @example
146
+ * ```ts
147
+ * controls.stopInputs();
148
+ * // ... later
149
+ * controls.listenInputs();
150
+ * ```
151
+ */
152
+ stopInputs(): void;
153
+ /**
154
+ * Resume listening to inputs after stopInputs() was called
155
+ *
156
+ * @example
157
+ * ```ts
158
+ * controls.stopInputs();
159
+ * // ... later
160
+ * controls.listenInputs();
161
+ * ```
162
+ */
163
+ listenInputs(): void;
164
+ /**
165
+ * Configure controls with input mappings
166
+ *
167
+ * This method sets up the binding between input keys/buttons and control actions.
168
+ * It clears existing bindings and creates new ones based on the provided configuration.
169
+ *
170
+ * @param inputs - Control configuration object
171
+ * @example
172
+ * ```ts
173
+ * controls.setInputs({
174
+ * up: {
175
+ * repeat: true,
176
+ * bind: 'up',
177
+ * keyDown() {
178
+ * console.log('Up pressed');
179
+ * }
180
+ * },
181
+ * action: {
182
+ * bind: ['space', 'enter'],
183
+ * keyDown() {
184
+ * console.log('Action triggered');
185
+ * }
186
+ * }
187
+ * });
188
+ * ```
189
+ */
190
+ setInputs(inputs: Controls): void;
191
+ /**
192
+ * Get the current controls configuration
193
+ *
194
+ * @returns The controls options object
195
+ */
196
+ get options(): Controls;
197
+ }
198
+ //# sourceMappingURL=ControlsBase.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ControlsBase.d.ts","sourceRoot":"","sources":["../../src/directives/ControlsBase.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,cAAc;IAC3B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACxB,KAAK,CAAC,EAAE,QAAQ,CAAC;IACjB,OAAO,CAAC,EAAE,QAAQ,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,GAAG;QACb,QAAQ,EAAE,MAAM,CAAC;QACjB,aAAa,CAAC,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC;KAC9B,CAAC;CACL;AAED,MAAM,WAAW,QAAQ;IACrB,CAAC,WAAW,EAAE,MAAM,GAAG,cAAc,CAAC;CACzC;AAED,MAAM,MAAM,QAAQ,GAAG;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,cAAc,CAAC;IAAC,UAAU,CAAC,E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