canvasengine 2.0.0-beta.4 → 2.0.0-beta.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/DebugRenderer-DgECR3yZ.js +172 -0
- package/dist/DebugRenderer-DgECR3yZ.js.map +1 -0
- package/dist/components/Button.d.ts +183 -0
- package/dist/components/Button.d.ts.map +1 -0
- package/dist/components/Canvas.d.ts +18 -0
- package/dist/components/Canvas.d.ts.map +1 -0
- package/dist/components/DOMElement.d.ts +44 -0
- package/dist/components/DOMElement.d.ts.map +1 -0
- package/dist/components/Graphic.d.ts +65 -0
- package/dist/components/Graphic.d.ts.map +1 -0
- package/dist/components/Joystick.d.ts +36 -0
- package/dist/components/Joystick.d.ts.map +1 -0
- package/dist/components/NineSliceSprite.d.ts +17 -0
- package/dist/components/NineSliceSprite.d.ts.map +1 -0
- package/dist/components/ParticleEmitter.d.ts +5 -0
- package/dist/components/ParticleEmitter.d.ts.map +1 -0
- package/dist/components/Scene.d.ts +2 -0
- package/dist/components/Scene.d.ts.map +1 -0
- package/dist/components/Text.d.ts +26 -0
- package/dist/components/Text.d.ts.map +1 -0
- package/dist/components/TilingSprite.d.ts +18 -0
- package/dist/components/TilingSprite.d.ts.map +1 -0
- package/dist/components/Video.d.ts +15 -0
- package/dist/components/Video.d.ts.map +1 -0
- package/dist/components/index.d.ts +18 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/types/DisplayObject.d.ts +110 -0
- package/dist/components/types/DisplayObject.d.ts.map +1 -0
- package/dist/components/types/MouseEvent.d.ts +4 -0
- package/dist/components/types/MouseEvent.d.ts.map +1 -0
- package/dist/components/types/Spritesheet.d.ts +248 -0
- package/dist/components/types/Spritesheet.d.ts.map +1 -0
- package/dist/components/types/index.d.ts +5 -0
- package/dist/components/types/index.d.ts.map +1 -0
- package/dist/directives/Controls.d.ts +113 -0
- package/dist/directives/Controls.d.ts.map +1 -0
- package/dist/directives/ControlsBase.d.ts +198 -0
- package/dist/directives/ControlsBase.d.ts.map +1 -0
- package/dist/directives/Drag.d.ts +70 -0
- package/dist/directives/Drag.d.ts.map +1 -0
- package/dist/directives/Flash.d.ts +117 -0
- package/dist/directives/Flash.d.ts.map +1 -0
- package/dist/directives/GamepadControls.d.ts +225 -0
- package/dist/directives/GamepadControls.d.ts.map +1 -0
- package/dist/directives/JoystickControls.d.ts +172 -0
- package/dist/directives/JoystickControls.d.ts.map +1 -0
- package/dist/directives/KeyboardControls.d.ts +219 -0
- package/dist/directives/KeyboardControls.d.ts.map +1 -0
- package/dist/directives/Scheduler.d.ts +36 -0
- package/dist/directives/Scheduler.d.ts.map +1 -0
- package/dist/directives/Shake.d.ts +98 -0
- package/dist/directives/Shake.d.ts.map +1 -0
- package/dist/directives/Sound.d.ts +26 -0
- package/dist/directives/Sound.d.ts.map +1 -0
- package/dist/directives/Transition.d.ts +11 -0
- package/dist/directives/Transition.d.ts.map +1 -0
- package/dist/directives/ViewportCull.d.ts +12 -0
- package/dist/directives/ViewportCull.d.ts.map +1 -0
- package/dist/directives/ViewportFollow.d.ts +19 -0
- package/dist/directives/ViewportFollow.d.ts.map +1 -0
- package/dist/directives/index.d.ts +13 -0
- package/dist/directives/index.d.ts.map +1 -0
- package/dist/engine/animation.d.ts +73 -0
- package/dist/engine/animation.d.ts.map +1 -0
- package/dist/engine/bootstrap.d.ts +16 -0
- package/dist/engine/bootstrap.d.ts.map +1 -0
- package/dist/engine/directive.d.ts +14 -0
- package/dist/engine/directive.d.ts.map +1 -0
- package/dist/engine/reactive.d.ts +105 -0
- package/dist/engine/reactive.d.ts.map +1 -0
- package/dist/engine/signal.d.ts +72 -0
- package/dist/engine/signal.d.ts.map +1 -0
- package/dist/engine/trigger.d.ts +50 -0
- package/dist/engine/trigger.d.ts.map +1 -0
- package/dist/engine/utils.d.ts +90 -0
- package/dist/engine/utils.d.ts.map +1 -0
- package/dist/hooks/addContext.d.ts +2 -0
- package/dist/hooks/addContext.d.ts.map +1 -0
- package/dist/hooks/useProps.d.ts +42 -0
- package/dist/hooks/useProps.d.ts.map +1 -0
- package/dist/hooks/useRef.d.ts +5 -0
- package/dist/hooks/useRef.d.ts.map +1 -0
- package/dist/index-gb763Hyx.js +12560 -0
- package/dist/index-gb763Hyx.js.map +1 -0
- package/dist/index.d.ts +15 -1083
- package/dist/index.d.ts.map +1 -0
- package/dist/index.global.js +29 -0
- package/dist/index.global.js.map +1 -0
- package/dist/index.js +81 -3041
- package/dist/index.js.map +1 -1
- package/dist/utils/Ease.d.ts +17 -0
- package/dist/utils/Ease.d.ts.map +1 -0
- package/dist/utils/GlobalAssetLoader.d.ts +141 -0
- package/dist/utils/GlobalAssetLoader.d.ts.map +1 -0
- package/dist/utils/RadialGradient.d.ts +58 -0
- package/dist/utils/RadialGradient.d.ts.map +1 -0
- package/dist/utils/functions.d.ts +2 -0
- package/dist/utils/functions.d.ts.map +1 -0
- package/package.json +13 -7
- package/src/components/Button.ts +396 -0
- package/src/components/Canvas.ts +61 -45
- package/src/components/Container.ts +21 -2
- package/src/components/DOMContainer.ts +123 -0
- package/src/components/DOMElement.ts +421 -0
- package/src/components/DisplayObject.ts +350 -197
- package/src/components/Graphic.ts +200 -34
- package/src/components/Joystick.ts +361 -0
- package/src/components/Mesh.ts +222 -0
- package/src/components/NineSliceSprite.ts +4 -1
- package/src/components/ParticleEmitter.ts +12 -8
- package/src/components/Sprite.ts +306 -30
- package/src/components/Text.ts +125 -18
- package/src/components/Video.ts +110 -0
- package/src/components/Viewport.ts +59 -43
- package/src/components/index.ts +8 -2
- package/src/components/types/DisplayObject.ts +34 -0
- package/src/components/types/Spritesheet.ts +0 -118
- package/src/directives/Controls.ts +254 -0
- package/src/directives/ControlsBase.ts +266 -0
- package/src/directives/Drag.ts +357 -52
- package/src/directives/Flash.ts +409 -0
- package/src/directives/GamepadControls.ts +537 -0
- package/src/directives/JoystickControls.ts +396 -0
- package/src/directives/KeyboardControls.ts +66 -424
- package/src/directives/Shake.ts +282 -0
- package/src/directives/Sound.ts +94 -31
- package/src/directives/ViewportFollow.ts +35 -7
- package/src/directives/index.ts +12 -6
- package/src/engine/animation.ts +175 -21
- package/src/engine/bootstrap.ts +23 -3
- package/src/engine/directive.ts +2 -2
- package/src/engine/reactive.ts +780 -177
- package/src/engine/signal.ts +35 -4
- package/src/engine/trigger.ts +21 -4
- package/src/engine/utils.ts +19 -3
- package/src/hooks/useProps.ts +1 -1
- package/src/index.ts +4 -2
- package/src/utils/GlobalAssetLoader.ts +257 -0
- package/src/utils/functions.ts +7 -0
- package/testing/index.ts +12 -0
- package/tsconfig.json +17 -0
- package/vite.config.ts +39 -0
|
@@ -0,0 +1,172 @@
|
|
|
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-gb763Hyx.js";
|
|
3
|
+
var l = /* @__PURE__ */ ((e) => (e.Margin = "margin", e.Padding = "padding", e.Border = "border", e.Flex = "flex", e.Content = "content", e))(l || {});
|
|
4
|
+
function w(e, t) {
|
|
5
|
+
const r = `getComputed${t.charAt(0).toUpperCase() + t.slice(1)}`;
|
|
6
|
+
return {
|
|
7
|
+
top: e.yoga[r](p.Top),
|
|
8
|
+
right: e.yoga[r](p.Right),
|
|
9
|
+
bottom: e.yoga[r](p.Bottom),
|
|
10
|
+
left: e.yoga[r](p.Left)
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
function B(e, t) {
|
|
14
|
+
const { width: r, height: h } = e.computedLayout, a = w(e, "margin"), i = w(e, "border"), c = w(e, "padding"), n = t.get(
|
|
15
|
+
"margin"
|
|
16
|
+
/* Margin */
|
|
17
|
+
);
|
|
18
|
+
n.outer.x = -a.left, n.outer.y = -a.top, n.outer.width = r + a.left + a.right, n.outer.height = h + a.top + a.bottom, n.inner.x = 0, n.inner.y = 0, n.inner.width = r, n.inner.height = h;
|
|
19
|
+
const o = t.get(
|
|
20
|
+
"border"
|
|
21
|
+
/* Border */
|
|
22
|
+
);
|
|
23
|
+
o.outer.x = 0, o.outer.y = 0, o.outer.width = r, o.outer.height = h, o.inner.x = i.left, o.inner.y = i.top, o.inner.width = r - i.left - i.right, o.inner.height = h - i.top - i.bottom;
|
|
24
|
+
const s = t.get(
|
|
25
|
+
"padding"
|
|
26
|
+
/* Padding */
|
|
27
|
+
);
|
|
28
|
+
s.outer.copyFrom(o.inner), s.inner.x = c.left + i.left, s.inner.y = c.top + i.top, s.inner.width = r - c.left - c.right - i.left - i.right, s.inner.height = h - c.top - c.bottom - i.top - i.bottom, E(e, t);
|
|
29
|
+
}
|
|
30
|
+
function E(e, t) {
|
|
31
|
+
var r;
|
|
32
|
+
const h = t.get(
|
|
33
|
+
"flex"
|
|
34
|
+
/* Flex */
|
|
35
|
+
), a = t.get(
|
|
36
|
+
"padding"
|
|
37
|
+
/* Padding */
|
|
38
|
+
);
|
|
39
|
+
h.outer.copyFrom(a.inner);
|
|
40
|
+
const i = new F(), c = e.yoga.getChildCount();
|
|
41
|
+
for (let o = 0; o < c; o++) {
|
|
42
|
+
const d = e.yoga.getChild(o).getComputedLayout();
|
|
43
|
+
i.addRect(
|
|
44
|
+
new C(d.left, d.top, d.width, d.height)
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
const n = e.yoga.getFlexDirection();
|
|
48
|
+
n === _.Column || n === _.ColumnReverse ? (i.width = h.outer.width, i.x = h.outer.x) : (i.height = h.outer.height, i.y = h.outer.y), (r = h.inner) == null || r.copyFrom(i.rectangle), t.get(
|
|
49
|
+
"content"
|
|
50
|
+
/* Content */
|
|
51
|
+
).outer.copyFrom(i.rectangle);
|
|
52
|
+
}
|
|
53
|
+
var O = Object.defineProperty, A = (e, t, r) => t in e ? O(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r, v = (e, t, r) => A(e, typeof t != "symbol" ? t + "" : t, r);
|
|
54
|
+
function P(e, t, r) {
|
|
55
|
+
const h = Math.round(e[0] + (t[0] - e[0]) * r), a = Math.round(e[1] + (t[1] - e[1]) * r), i = Math.round(e[2] + (t[2] - e[2]) * r);
|
|
56
|
+
return `rgb(${h},${a},${i})`;
|
|
57
|
+
}
|
|
58
|
+
class G extends M {
|
|
59
|
+
constructor() {
|
|
60
|
+
super(), v(this, "graphics"), v(this, "heatGraphics"), this.graphics = /* @__PURE__ */ new Map(), Object.values(l).forEach((t) => {
|
|
61
|
+
const r = new x();
|
|
62
|
+
this.graphics.set(t, r), this.addChild(r);
|
|
63
|
+
}), this.heatGraphics = new x(), this.addChild(this.heatGraphics);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Initialize the debug object with region data
|
|
67
|
+
*/
|
|
68
|
+
init(t) {
|
|
69
|
+
const { target: r, alpha: h, heat: a } = t;
|
|
70
|
+
t.heatOnly || Object.entries(t).forEach(([n, o]) => {
|
|
71
|
+
if (n === "target" || n === "alpha" || n === "heat" || n === "heatOnly") return;
|
|
72
|
+
o = o;
|
|
73
|
+
const s = this.graphics.get(n);
|
|
74
|
+
if (!(!s || !o.draw))
|
|
75
|
+
if (o.inner)
|
|
76
|
+
this.drawCutBox(s, o.outer, o.inner, o.color, h);
|
|
77
|
+
else {
|
|
78
|
+
const { x: d, y: u, width: g, height: m } = o.outer;
|
|
79
|
+
s.rect(d, u, g, Math.max(m, 1)), s.fill({ color: o.color, alpha: h });
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
const { invalidationCount: i, draw: c } = a;
|
|
83
|
+
if (i > 0 && c) {
|
|
84
|
+
const o = Math.min(i / 20, 1), s = t[l.Margin], g = P([255, 255, 0], [255, 0, 0], o);
|
|
85
|
+
this.heatGraphics.rect(
|
|
86
|
+
s.outer.x,
|
|
87
|
+
s.outer.y,
|
|
88
|
+
s.outer.width,
|
|
89
|
+
s.outer.height
|
|
90
|
+
), this.heatGraphics.fill({ color: g, alpha: Math.min(0.3, o) }), this.heatGraphics.stroke({ color: g, alpha: Math.max(0.3, o), pixelLine: !0 });
|
|
91
|
+
}
|
|
92
|
+
this.position.set(r.x, r.y);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Reset the debug object's state
|
|
96
|
+
*/
|
|
97
|
+
reset() {
|
|
98
|
+
this.graphics.forEach((t) => t.clear()), this.heatGraphics.clear(), this.removeFromParent();
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Draw a box with a cut-out center
|
|
102
|
+
*/
|
|
103
|
+
drawCutBox(t, r, h, a, i) {
|
|
104
|
+
const { x: c, y: n, width: o, height: s } = r, { x: d, y: u, width: g, height: m } = h;
|
|
105
|
+
t.rect(c, n, o, s), t.fill({ color: a, alpha: i }), t.rect(d, u, g, m), t.cut();
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
var R = Object.defineProperty, $ = (e, t, r) => t in e ? R(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r, f = (e, t, r) => $(e, typeof t != "symbol" ? t + "" : t, r);
|
|
109
|
+
class y {
|
|
110
|
+
constructor() {
|
|
111
|
+
f(this, "holder", new M()), f(this, "regions", /* @__PURE__ */ new Map()), f(this, "colors", {
|
|
112
|
+
[l.Margin]: "#B68655",
|
|
113
|
+
[l.Padding]: "#BAC57F",
|
|
114
|
+
[l.Border]: "#E7C583",
|
|
115
|
+
[l.Content]: "#89B1BE",
|
|
116
|
+
[l.Flex]: "#6E28D9"
|
|
117
|
+
}), f(this, "alpha", 0.75), Object.values(l).forEach((t) => {
|
|
118
|
+
this.regions.set(t, {
|
|
119
|
+
outer: new C(),
|
|
120
|
+
inner: new C()
|
|
121
|
+
});
|
|
122
|
+
}), this.holder.__devtoolIgnore = !0, this.holder.__devtoolIgnoreChildren = !0, this.holder.eventMode = "none", this.holder.interactiveChildren = !1;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Clean up previous render state
|
|
126
|
+
*/
|
|
127
|
+
reset() {
|
|
128
|
+
for (let t = this.holder.children.length - 1; t >= 0; t--) {
|
|
129
|
+
const r = this.holder.children[t];
|
|
130
|
+
b.return(r);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Render debug visuals for the given layout
|
|
135
|
+
*/
|
|
136
|
+
render(t) {
|
|
137
|
+
B(t, this.regions);
|
|
138
|
+
const r = Object.values(l).reduce(
|
|
139
|
+
(n, o) => {
|
|
140
|
+
const s = this.regions.get(o);
|
|
141
|
+
if (!s) return n;
|
|
142
|
+
const d = `debugDraw${o.charAt(0).toUpperCase()}${o.slice(1)}`;
|
|
143
|
+
return n[o] = {
|
|
144
|
+
...s,
|
|
145
|
+
color: this.colors[o],
|
|
146
|
+
draw: t._styles.custom[d] ?? !0
|
|
147
|
+
}, n;
|
|
148
|
+
},
|
|
149
|
+
{}
|
|
150
|
+
), { left: h, top: a } = t.computedLayout, i = t.target.getGlobalPosition(), c = b.get(G, {
|
|
151
|
+
...r,
|
|
152
|
+
target: { x: i.x + h, y: i.y + a },
|
|
153
|
+
alpha: this.alpha,
|
|
154
|
+
heat: {
|
|
155
|
+
invalidationCount: t._modificationCount,
|
|
156
|
+
draw: t._styles.custom.debugHeat !== !1
|
|
157
|
+
},
|
|
158
|
+
heatOnly: !t._styles.custom.debug
|
|
159
|
+
});
|
|
160
|
+
this.holder.addChildAt(c, 0);
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Clean up the debug renderer
|
|
164
|
+
*/
|
|
165
|
+
destroy() {
|
|
166
|
+
this.reset(), this.holder.destroy(), this.regions.clear();
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
export {
|
|
170
|
+
y as DebugRenderer
|
|
171
|
+
};
|
|
172
|
+
//# sourceMappingURL=DebugRenderer-DgECR3yZ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DebugRenderer-DgECR3yZ.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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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]}
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { FederatedPointerEvent } from 'pixi.js';
|
|
2
|
+
import { ControlsDirective } from '../directives/Controls';
|
|
3
|
+
import { JoystickControls } from '../directives/JoystickControls';
|
|
4
|
+
import { Element } from '../engine/reactive';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Button states for visual feedback
|
|
8
|
+
*/
|
|
9
|
+
export declare enum ButtonState {
|
|
10
|
+
Normal = "normal",
|
|
11
|
+
Hover = "hover",
|
|
12
|
+
Pressed = "pressed",
|
|
13
|
+
Disabled = "disabled"
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Button style configuration for different visual approaches
|
|
17
|
+
*/
|
|
18
|
+
export interface ButtonStyle {
|
|
19
|
+
/** Background color for each state */
|
|
20
|
+
backgroundColor?: {
|
|
21
|
+
[ButtonState.Normal]?: string;
|
|
22
|
+
[ButtonState.Hover]?: string;
|
|
23
|
+
[ButtonState.Pressed]?: string;
|
|
24
|
+
[ButtonState.Disabled]?: string;
|
|
25
|
+
};
|
|
26
|
+
/** Border configuration */
|
|
27
|
+
border?: {
|
|
28
|
+
color?: string;
|
|
29
|
+
width?: number;
|
|
30
|
+
radius?: number;
|
|
31
|
+
};
|
|
32
|
+
/** Text styling */
|
|
33
|
+
text?: {
|
|
34
|
+
color?: string;
|
|
35
|
+
fontSize?: number;
|
|
36
|
+
fontFamily?: string;
|
|
37
|
+
};
|
|
38
|
+
/** Sprite textures for each state (alternative to backgroundColor) */
|
|
39
|
+
textures?: {
|
|
40
|
+
[ButtonState.Normal]?: string;
|
|
41
|
+
[ButtonState.Hover]?: string;
|
|
42
|
+
[ButtonState.Pressed]?: string;
|
|
43
|
+
[ButtonState.Disabled]?: string;
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Properties for the Button component
|
|
48
|
+
*/
|
|
49
|
+
export interface ButtonProps {
|
|
50
|
+
/** Button text content */
|
|
51
|
+
text?: string;
|
|
52
|
+
/** Button disabled state */
|
|
53
|
+
disabled?: boolean;
|
|
54
|
+
/** Click event handler */
|
|
55
|
+
click?: (event: FederatedPointerEvent) => void;
|
|
56
|
+
/** Hover enter event handler */
|
|
57
|
+
hoverEnter?: (event: FederatedPointerEvent) => void;
|
|
58
|
+
/** Hover leave event handler */
|
|
59
|
+
hoverLeave?: (event: FederatedPointerEvent) => void;
|
|
60
|
+
/** Press down event handler */
|
|
61
|
+
pressDown?: (event: FederatedPointerEvent) => void;
|
|
62
|
+
/** Press up event handler */
|
|
63
|
+
pressUp?: (event: FederatedPointerEvent) => void;
|
|
64
|
+
/** Visual style configuration */
|
|
65
|
+
style?: ButtonStyle;
|
|
66
|
+
/** Button width */
|
|
67
|
+
width?: number;
|
|
68
|
+
/** Button height */
|
|
69
|
+
height?: number;
|
|
70
|
+
/** Button position X */
|
|
71
|
+
x?: number;
|
|
72
|
+
/** Button position Y */
|
|
73
|
+
y?: number;
|
|
74
|
+
/** Button alpha/opacity */
|
|
75
|
+
alpha?: number;
|
|
76
|
+
/** Button visibility */
|
|
77
|
+
visible?: boolean;
|
|
78
|
+
/** Button cursor */
|
|
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[];
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Creates a Button component with interactive states and customizable styling.
|
|
93
|
+
*
|
|
94
|
+
* This component provides a fully interactive button with visual feedback
|
|
95
|
+
* for different states (normal, hover, pressed, disabled). It supports both
|
|
96
|
+
* sprite-based and graphics-based rendering approaches.
|
|
97
|
+
*
|
|
98
|
+
* The button is built using a Container with background and text elements,
|
|
99
|
+
* providing reactive state management and event handling.
|
|
100
|
+
*
|
|
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
|
|
109
|
+
* @returns A reactive Button component
|
|
110
|
+
* @example
|
|
111
|
+
* ```typescript
|
|
112
|
+
* // Simple button with text and click handler
|
|
113
|
+
* const simpleButton = Button({
|
|
114
|
+
* text: "Click Me",
|
|
115
|
+
* click: () => console.log("Button clicked!"),
|
|
116
|
+
* width: 150,
|
|
117
|
+
* height: 50
|
|
118
|
+
* });
|
|
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
|
+
*
|
|
147
|
+
* // Styled button with custom colors
|
|
148
|
+
* const styledButton = Button({
|
|
149
|
+
* text: "Styled Button",
|
|
150
|
+
* style: {
|
|
151
|
+
* backgroundColor: {
|
|
152
|
+
* normal: "#28a745",
|
|
153
|
+
* hover: "#218838",
|
|
154
|
+
* pressed: "#1e7e34",
|
|
155
|
+
* disabled: "#6c757d"
|
|
156
|
+
* },
|
|
157
|
+
* border: {
|
|
158
|
+
* radius: 8,
|
|
159
|
+
* width: 2,
|
|
160
|
+
* color: "#ffffff"
|
|
161
|
+
* },
|
|
162
|
+
* text: {
|
|
163
|
+
* fontSize: 18,
|
|
164
|
+
* color: "#ffffff"
|
|
165
|
+
* }
|
|
166
|
+
* }
|
|
167
|
+
* });
|
|
168
|
+
*
|
|
169
|
+
* // Sprite-based button
|
|
170
|
+
* const spriteButton = Button({
|
|
171
|
+
* text: "Play Game",
|
|
172
|
+
* style: {
|
|
173
|
+
* textures: {
|
|
174
|
+
* normal: "/assets/button-normal.png",
|
|
175
|
+
* hover: "/assets/button-hover.png",
|
|
176
|
+
* pressed: "/assets/button-pressed.png"
|
|
177
|
+
* }
|
|
178
|
+
* }
|
|
179
|
+
* });
|
|
180
|
+
* ```
|
|
181
|
+
*/
|
|
182
|
+
export declare function Button(props: ButtonProps): Element<import('./DisplayObject').ComponentInstance> | Promise<Element<import('./DisplayObject').ComponentInstance>>;
|
|
183
|
+
//# sourceMappingURL=Button.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../src/components/Button.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAMhD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAE7C;;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,CAAC,EAAE;QAChB,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC;QAC9B,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,CAAC;QAC7B,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,EAAE,MAAM,CAAC;QAC/B,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;KACjC,CAAC;IACF,2BAA2B;IAC3B,MAAM,CAAC,EAAE;QACP,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,CAAC;IACF,mBAAmB;IACnB,IAAI,CAAC,EAAE;QACL,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC;IACF,sEAAsE;IACtE,QAAQ,CAAC,EAAE;QACT,CAAC,WAAW,C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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,18 @@
|
|
|
1
|
+
import { Props } from '../engine/reactive';
|
|
2
|
+
import { ComponentFunction } from '../engine/signal';
|
|
3
|
+
import { SignalOrPrimitive } from './types';
|
|
4
|
+
import { Size } from './types/DisplayObject';
|
|
5
|
+
|
|
6
|
+
export interface CanvasProps extends Props {
|
|
7
|
+
cursorStyles?: () => any;
|
|
8
|
+
width?: SignalOrPrimitive<Size>;
|
|
9
|
+
height?: SignalOrPrimitive<Size>;
|
|
10
|
+
canvasEl?: HTMLElement;
|
|
11
|
+
selector?: string;
|
|
12
|
+
isRoot?: boolean;
|
|
13
|
+
tick?: any;
|
|
14
|
+
class?: SignalOrPrimitive<string>;
|
|
15
|
+
background?: string;
|
|
16
|
+
}
|
|
17
|
+
export declare const Canvas: ComponentFunction<CanvasProps>;
|
|
18
|
+
//# sourceMappingURL=Canvas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Canvas.d.ts","sourceRoot":"","sources":["../../src/components/Canvas.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,EAIN,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAgB7C,MAAM,WAAW,WAAY,SAAQ,KAAK;IACxC,YAAY,CAAC,EAAE,MAAM,GAAG,CAAC;IACzB,KAAK,CAAC,EAAE,iBAAiB,CAAC,IAAI,CAAC,CAAC;IAChC,MAAM,CAAC,EAAE,iBAAiB,CAAC,IAAI,CAAC,CAAC;IACjC,QAAQ,CAAC,EAAE,WAAW,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,KAAK,CAAC,EAAE,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAClC,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,eAAO,MAAM,MAAM,EAAE,iBAAiB,CAAC,WAAW,CA6GjD,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Element } from '../engine/reactive';
|
|
2
|
+
import { OnHook } from './DisplayObject';
|
|
3
|
+
import { ComponentFunction } from '../engine/signal';
|
|
4
|
+
import { DisplayObjectProps } from './types/DisplayObject';
|
|
5
|
+
|
|
6
|
+
interface DOMContainerProps extends DisplayObjectProps {
|
|
7
|
+
element: string | {
|
|
8
|
+
value: HTMLElement;
|
|
9
|
+
};
|
|
10
|
+
textContent?: string;
|
|
11
|
+
attrs?: Record<string, any> & {
|
|
12
|
+
class?: string | string[] | Record<string, boolean> | {
|
|
13
|
+
items?: string[];
|
|
14
|
+
} | {
|
|
15
|
+
value?: string | string[] | Record<string, boolean>;
|
|
16
|
+
};
|
|
17
|
+
style?: string | Record<string, string | number> | {
|
|
18
|
+
value?: string | Record<string, string | number>;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
onBeforeDestroy?: OnHook;
|
|
22
|
+
}
|
|
23
|
+
export declare class CanvasDOMElement {
|
|
24
|
+
element: HTMLElement;
|
|
25
|
+
private eventListeners;
|
|
26
|
+
private onBeforeDestroy;
|
|
27
|
+
private valueSignal;
|
|
28
|
+
private isFormElementType;
|
|
29
|
+
/**
|
|
30
|
+
* Checks if the element is a form element that supports the value attribute
|
|
31
|
+
* @param elementType - The element type string from props
|
|
32
|
+
* @returns true if the element is a form element with value support
|
|
33
|
+
*/
|
|
34
|
+
private isFormElement;
|
|
35
|
+
onInit(props: DOMContainerProps): void;
|
|
36
|
+
onMount(context: Element<CanvasDOMElement>): void;
|
|
37
|
+
onUpdate(props: DOMContainerProps): void;
|
|
38
|
+
onDestroy(parent: Element<CanvasDOMElement>, afterDestroy: () => void): Promise<void>;
|
|
39
|
+
}
|
|
40
|
+
export interface CanvasDOMElement extends DisplayObjectProps {
|
|
41
|
+
}
|
|
42
|
+
export declare const DOMElement: ComponentFunction<DOMContainerProps>;
|
|
43
|
+
export {};
|
|
44
|
+
//# sourceMappingURL=DOMElement.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DOMElement.d.ts","sourceRoot":"","sources":["../../src/components/DOMElement.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,OAAO,EAER,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAoC,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAC3E,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAI3D,UAAU,iBAAkB,SAAQ,kBAAkB;IACpD,OAAO,EACH,MAAM,GACN;QACE,KAAK,EAAE,WAAW,CAAC;KACpB,CAAC;IACN,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG;QAC5B,KAAK,CAAC,EACF,MAAM,GACN,MAAM,EAAE,GACR,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACvB;YAAE,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;SAAE,GACpB;YAAE,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;SAAE,CAAC;QAC5D,KAAK,CAAC,EACF,MAAM,GACN,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,GAC/B;YAAE,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAA;SAAE,CAAC;KAC1D,CAAC;IACF,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAwKD,qBAAa,gBAAgB;IACpB,OAAO,EAAE,WAAW,CAAC;IAC5B,OAAO,CAAC,cAAc,CAA8C;IACpE,OAAO,CAAC,eAAe,CAAuB;IAC9C,OAAO,CAAC,WAAW,CAAa;IAChC,OAAO,CAAC,iBAAiB,CAAkB;IAE3C;;;;OAIG;IACH,OAAO,CAAC,aAAa;IAKrB,MAAM,CAAC,KAAK,EAAE,iBAAiB;IAgE/B,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,gBAAgB,CAAC;IAgC1C,QAAQ,CAAC,KAAK,EAAE,iBAAiB;IA2E3B,SAAS,CACb,MAAM,EAAE,OAAO,CAAC,gBAAgB,CAAC,EACjC,YAAY,EAAE,MAAM,IAAI,GACvB,OAAO,CAAC,IAAI,CAAC;CAqBjB;AAED,MAAM,WAAW,gBAAiB,SAAQ,kBAAkB;CAAG;AAI/D,eAAO,MAAM,UAAU,EAAE,iBAAiB,CAAC,iBAAiB,CAE3D,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { Graphics as PixiGraphics } from 'pixi.js';
|
|
2
|
+
import { Element } from '../engine/reactive';
|
|
3
|
+
import { ComponentInstance } from './DisplayObject';
|
|
4
|
+
import { DisplayObjectProps } from './types/DisplayObject';
|
|
5
|
+
import { SignalOrPrimitive } from './types';
|
|
6
|
+
|
|
7
|
+
interface GraphicsProps extends DisplayObjectProps {
|
|
8
|
+
draw?: (graphics: PixiGraphics, width: number, height: number) => void;
|
|
9
|
+
}
|
|
10
|
+
interface RectProps extends DisplayObjectProps {
|
|
11
|
+
color: SignalOrPrimitive<string>;
|
|
12
|
+
}
|
|
13
|
+
interface CircleProps extends DisplayObjectProps {
|
|
14
|
+
radius: SignalOrPrimitive<number>;
|
|
15
|
+
color: SignalOrPrimitive<string>;
|
|
16
|
+
}
|
|
17
|
+
interface EllipseProps extends DisplayObjectProps {
|
|
18
|
+
color: SignalOrPrimitive<string>;
|
|
19
|
+
}
|
|
20
|
+
interface TriangleProps extends DisplayObjectProps {
|
|
21
|
+
base: SignalOrPrimitive<number>;
|
|
22
|
+
color: SignalOrPrimitive<string>;
|
|
23
|
+
}
|
|
24
|
+
interface SvgProps extends DisplayObjectProps {
|
|
25
|
+
/** SVG content as string (legacy prop) */
|
|
26
|
+
svg?: string;
|
|
27
|
+
/** URL source of the SVG file to load */
|
|
28
|
+
src?: string;
|
|
29
|
+
/** Direct SVG content as string */
|
|
30
|
+
content?: string;
|
|
31
|
+
}
|
|
32
|
+
export declare function Graphics(props: GraphicsProps): Element<ComponentInstance>;
|
|
33
|
+
export declare function Rect(props: RectProps): Element<ComponentInstance>;
|
|
34
|
+
export declare function Circle(props: CircleProps): Element<ComponentInstance>;
|
|
35
|
+
export declare function Ellipse(props: EllipseProps): Element<ComponentInstance>;
|
|
36
|
+
export declare function Triangle(props: TriangleProps): Element<ComponentInstance>;
|
|
37
|
+
/**
|
|
38
|
+
* Creates an SVG component that can render SVG graphics from URL, content, or legacy svg prop.
|
|
39
|
+
*
|
|
40
|
+
* This component provides three ways to display SVG graphics:
|
|
41
|
+
* - **src**: Load SVG from a URL using Assets.load with parseAsGraphicsContext option
|
|
42
|
+
* - **content**: Render SVG directly from string content using Graphics.svg() method
|
|
43
|
+
* - **svg**: Legacy prop for SVG content (for backward compatibility)
|
|
44
|
+
*
|
|
45
|
+
* @param props - Component properties including src, content, or svg
|
|
46
|
+
* @returns A reactive SVG component
|
|
47
|
+
* @example
|
|
48
|
+
* ```typescript
|
|
49
|
+
* // Load from URL
|
|
50
|
+
* const svgFromUrl = Svg({ src: "/assets/logo.svg" });
|
|
51
|
+
*
|
|
52
|
+
* // Direct content
|
|
53
|
+
* const svgFromContent = Svg({
|
|
54
|
+
* content: `<svg viewBox="0 0 100 100">
|
|
55
|
+
* <circle cx="50" cy="50" r="40" fill="blue"/>
|
|
56
|
+
* </svg>`
|
|
57
|
+
* });
|
|
58
|
+
*
|
|
59
|
+
* // Legacy usage
|
|
60
|
+
* const svgLegacy = Svg({ svg: "<svg>...</svg>" });
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
export declare function Svg(props: SvgProps): Element<ComponentInstance>;
|
|
64
|
+
export {};
|
|
65
|
+
//# sourceMappingURL=Graphic.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Graphic.d.ts","sourceRoot":"","sources":["../../src/components/Graphic.ts"],"names":[],"mappings":"AACA,OAAO,EAAU,QAAQ,IAAI,YAAY,EAAE,MAAM,SAAS,CAAC;AAC3D,OAAO,EAAmB,OAAO,EAAqB,MAAM,oBAAoB,CAAC;AACjF,OAAO,EAAE,iBAAiB,EAAiB,MAAM,iBAAiB,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAE3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAG5C,UAAU,aAAc,SAAQ,kBAAkB;IAChD,IAAI,CAAC,EAAE,CAAC,QAAQ,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;CACxE;AAED,UAAU,SAAU,SAAQ,kBAAkB;IAC5C,KAAK,EAAE,iBAAiB,CAAC,MAAM,CAAC,CAAC;CAClC;AAED,UAAU,WAAY,SAAQ,kBAAkB;IAC9C,MAAM,EAAE,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAClC,KAAK,EAAE,iBAAiB,CAAC,MAAM,CAAC,CAAC;CAClC;AAED,UAAU,YAAa,SAAQ,kBAAkB;IAC/C,KAAK,EAAE,iBAAiB,CAAC,MAAM,CAAC,CAAC;CAClC;AAED,UAAU,aAAc,SAAQ,kBAAkB;IAChD,IAAI,EAAE,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAChC,KAAK,EAAE,iBAAiB,CAAC,MAAM,CAAC,CAAC;CAClC;AAED,UAAU,QAAS,SAAQ,kBAAkB;IAC3C,0CAA0C;IAC1C,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,yCAAyC;IACzC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,mCAAmC;IACnC,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAiID,wBAAgB,QAAQ,CAAC,KAAK,EAAE,aAAa,8BAE5C;AAED,wBAAgB,IAAI,CAAC,KAAK,EAAE,SAAS,8BAoBpC;AAwBD,wBAAgB,MAAM,CAAC,KAAK,EAAE,WAAW,8BAQxC;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,YAAY,8BAc1C;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,aAAa,8BAkB5C;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,GAAG,CAAC,KAAK,EAAE,QAAQ,8BAyBlC"}
|
|
@@ -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"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Texture } from 'pixi.js';
|
|
2
|
+
import { DisplayObjectProps } from './types/DisplayObject';
|
|
3
|
+
|
|
4
|
+
interface NineSliceSpriteProps extends DisplayObjectProps {
|
|
5
|
+
image?: string;
|
|
6
|
+
texture?: Texture;
|
|
7
|
+
width?: number;
|
|
8
|
+
height?: number;
|
|
9
|
+
leftWidth?: number;
|
|
10
|
+
rightWidth?: number;
|
|
11
|
+
topHeight?: number;
|
|
12
|
+
bottomHeight?: number;
|
|
13
|
+
roundPixels?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export declare function NineSliceSprite(props: NineSliceSpriteProps): import('..').Element<import('./DisplayObject').ComponentInstance>;
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=NineSliceSprite.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NineSliceSprite.d.ts","sourceRoot":"","sources":["../../src/components/NineSliceSprite.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkD,OAAO,EAAE,MAAM,SAAS,CAAC;AAGlF,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAG3D,UAAU,oBAAqB,SAAQ,kBAAkB;IACrD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,OAAO,CAAC;CACzB;AA8BD,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,qEAE1D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ParticleEmitter.d.ts","sourceRoot":"","sources":["../../src/components/ParticleEmitter.ts"],"names":[],"mappings":"AACA,OAAO,EAAmB,OAAO,EAAqB,MAAM,oBAAoB,CAAC;AAGjF,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAoCpD,wBAAgB,gBAAgB,CAAC,KAAK,KAAA,8BAErC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Scene.d.ts","sourceRoot":"","sources":["../../src/components/Scene.ts"],"names":[],"mappings":"AAGA,wBAAgB,KAAK,CAAC,KAAK,KAAA,kJAE1B"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { TextStyle } from 'pixi.js';
|
|
2
|
+
import { Element } from '../engine/reactive';
|
|
3
|
+
import { ComponentInstance } from './DisplayObject';
|
|
4
|
+
import { DisplayObjectProps } from './types/DisplayObject';
|
|
5
|
+
|
|
6
|
+
export interface TextProps extends DisplayObjectProps {
|
|
7
|
+
text?: string;
|
|
8
|
+
style?: Partial<TextStyle>;
|
|
9
|
+
color?: string;
|
|
10
|
+
size?: string;
|
|
11
|
+
fontFamily?: string;
|
|
12
|
+
typewriter?: {
|
|
13
|
+
speed?: number;
|
|
14
|
+
start?: () => void;
|
|
15
|
+
onComplete?: () => void;
|
|
16
|
+
skip?: () => void;
|
|
17
|
+
sound?: {
|
|
18
|
+
src: string;
|
|
19
|
+
volume?: number;
|
|
20
|
+
rate?: number;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
context?: any;
|
|
24
|
+
}
|
|
25
|
+
export declare function Text(props: TextProps): Element<ComponentInstance>;
|
|
26
|
+
//# sourceMappingURL=Text.d.ts.map
|