canvasengine 2.0.0-beta.27 → 2.0.0-beta.29
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-EZWNhJKJ.js → DebugRenderer-DhQSLsCe.js} +2 -2
- package/dist/{DebugRenderer-EZWNhJKJ.js.map → DebugRenderer-DhQSLsCe.js.map} +1 -1
- package/dist/components/Graphic.d.ts.map +1 -1
- package/dist/components/Sprite.d.ts.map +1 -1
- package/dist/{index-JzoygiZz.js → index-DQHrtntP.js} +343 -341
- package/dist/index-DQHrtntP.js.map +1 -0
- package/dist/index.global.js +5 -5
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +2 -2
- package/package.json +1 -1
- package/src/components/Graphic.ts +25 -33
- package/src/components/Sprite.ts +3 -2
- package/dist/index-JzoygiZz.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { h as a } from "./index-
|
|
2
|
-
import { A as r, B as n, w as o, C as c, m as l, l as p, D as S, v as m, a5 as u, a4 as g, a2 as b, n as d, G as C, c as j, M as T, N as E, O, P as f, a3 as v, R as w, o as h, p as D, S as P, q as k, r as x, T as y, b as A, V as H, t as M, a1 as V, a0 as B, _ as G, d as N, J as R, H as q, K as U, e as z, W as I, $ as J, f as K, g as L, x as Q, j as W, i as X, y as Y, k as Z, X as _, I as $, Q as F, L as aa, Z as sa, z as ea, s as ta, U as ia, Y as ra, a as na, u as oa } from "./index-
|
|
1
|
+
import { h as a } from "./index-DQHrtntP.js";
|
|
2
|
+
import { A as r, B as n, w as o, C as c, m as l, l as p, D as S, v as m, a5 as u, a4 as g, a2 as b, n as d, G as C, c as j, M as T, N as E, O, P as f, a3 as v, R as w, o as h, p as D, S as P, q as k, r as x, T as y, b as A, V as H, t as M, a1 as V, a0 as B, _ as G, d as N, J as R, H as q, K as U, e as z, W as I, $ as J, f as K, g as L, x as Q, j as W, i as X, y as Y, k as Z, X as _, I as $, Q as F, L as aa, Z as sa, z as ea, s as ta, U as ia, Y as ra, a as na, u as oa } from "./index-DQHrtntP.js";
|
|
3
3
|
const e = a.Howler;
|
|
4
4
|
export {
|
|
5
5
|
r as ArraySubject,
|
package/package.json
CHANGED
|
@@ -40,8 +40,8 @@ interface SvgProps extends DisplayObjectProps {
|
|
|
40
40
|
|
|
41
41
|
class CanvasGraphics extends DisplayObject(PixiGraphics) {
|
|
42
42
|
clearEffect: Effect;
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
_width: WritableSignal<number>;
|
|
44
|
+
_height: WritableSignal<number>;
|
|
45
45
|
|
|
46
46
|
/**
|
|
47
47
|
* Initializes the graphics component with reactive width and height handling.
|
|
@@ -89,10 +89,10 @@ class CanvasGraphics extends DisplayObject(PixiGraphics) {
|
|
|
89
89
|
// Use original signals from propObservables if available, otherwise create new ones
|
|
90
90
|
const width = (isSignal(propObservables?.width) ? propObservables.width : signal(props.width || 0)) as WritableSignal<number>;
|
|
91
91
|
const height = (isSignal(propObservables?.height) ? propObservables.height : signal(props.height || 0)) as WritableSignal<number>;
|
|
92
|
-
|
|
92
|
+
|
|
93
93
|
// Store as class properties for access in other methods
|
|
94
|
-
this.
|
|
95
|
-
this.
|
|
94
|
+
this._width = width;
|
|
95
|
+
this._height = height;
|
|
96
96
|
|
|
97
97
|
// Check if width or height are percentages to set display flex
|
|
98
98
|
const isWidthPercentage = isPercent(width());
|
|
@@ -113,13 +113,13 @@ class CanvasGraphics extends DisplayObject(PixiGraphics) {
|
|
|
113
113
|
|
|
114
114
|
this.on('layout', (event) => {
|
|
115
115
|
const layoutBox = event.computedLayout;
|
|
116
|
-
// Update width if it's a percentage
|
|
117
|
-
if (isWidthPercentage && isSignal(width)) {
|
|
116
|
+
// Update width if it's a percentage and value has changed
|
|
117
|
+
if (isWidthPercentage && isSignal(width) && width() !== layoutBox.width) {
|
|
118
118
|
width.set(layoutBox.width);
|
|
119
119
|
}
|
|
120
120
|
|
|
121
|
-
// Update height if it's a percentage
|
|
122
|
-
if (isHeightPercentage && isSignal(height)) {
|
|
121
|
+
// Update height if it's a percentage and value has changed
|
|
122
|
+
if (isHeightPercentage && isSignal(height) && height() !== layoutBox.height) {
|
|
123
123
|
height.set(layoutBox.height);
|
|
124
124
|
}
|
|
125
125
|
});
|
|
@@ -132,29 +132,15 @@ class CanvasGraphics extends DisplayObject(PixiGraphics) {
|
|
|
132
132
|
*/
|
|
133
133
|
onUpdate(props: any) {
|
|
134
134
|
super.onUpdate(props);
|
|
135
|
-
|
|
136
|
-
// Update width signal if width prop changed
|
|
137
|
-
if (props.width !== undefined && this.width) {
|
|
138
|
-
|
|
139
|
-
// If the new prop is a signal, we need to replace our local signal
|
|
140
|
-
// This shouldn't happen in normal usage, but handle it just in case
|
|
141
|
-
this.width = props.width;
|
|
142
|
-
} else {
|
|
143
|
-
// Update our local signal with the new value
|
|
144
|
-
this.width.set(props.width);
|
|
145
|
-
}
|
|
135
|
+
|
|
136
|
+
// Update width signal if width prop changed and value is different
|
|
137
|
+
if (props.width !== undefined && this._width && this._width() !== props.width) {
|
|
138
|
+
this._width.set(props.width);
|
|
146
139
|
}
|
|
147
140
|
|
|
148
|
-
// Update height signal if height prop changed
|
|
149
|
-
if (props.height !== undefined && this.height) {
|
|
150
|
-
|
|
151
|
-
// If the new prop is a signal, we need to replace our local signal
|
|
152
|
-
// This shouldn't happen in normal usage, but handle it just in case
|
|
153
|
-
this.height = props.height;
|
|
154
|
-
} else {
|
|
155
|
-
// Update our local signal with the new value
|
|
156
|
-
this.height.set(props.height);
|
|
157
|
-
}
|
|
141
|
+
// Update height signal if height prop changed and value is different
|
|
142
|
+
if (props.height !== undefined && this._height && this._height() !== props.height) {
|
|
143
|
+
this._height.set(props.height);
|
|
158
144
|
}
|
|
159
145
|
}
|
|
160
146
|
|
|
@@ -210,8 +196,8 @@ function drawShape(g: PixiGraphics, shape: 'circle' | 'ellipse', props: {
|
|
|
210
196
|
color: Signal<string>;
|
|
211
197
|
border: Signal<number>;
|
|
212
198
|
} | {
|
|
213
|
-
width:
|
|
214
|
-
height:
|
|
199
|
+
width: Signal<number>;
|
|
200
|
+
height: Signal<number>;
|
|
215
201
|
color: Signal<string>;
|
|
216
202
|
border: Signal<number>;
|
|
217
203
|
}) {
|
|
@@ -242,7 +228,13 @@ export function Ellipse(props: EllipseProps) {
|
|
|
242
228
|
border: null
|
|
243
229
|
})
|
|
244
230
|
return Graphics({
|
|
245
|
-
draw: (g, gWidth, gHeight) =>
|
|
231
|
+
draw: (g, gWidth, gHeight) => {
|
|
232
|
+
g.ellipse(0, 0, gWidth / 2, gHeight / 2);
|
|
233
|
+
if (border()) {
|
|
234
|
+
g.stroke(border());
|
|
235
|
+
}
|
|
236
|
+
g.fill(color());
|
|
237
|
+
},
|
|
246
238
|
...props
|
|
247
239
|
})
|
|
248
240
|
}
|
package/src/components/Sprite.ts
CHANGED
|
@@ -275,7 +275,7 @@ export class CanvasSprite extends DisplayObject(PixiSprite) {
|
|
|
275
275
|
this.play(this.sheetCurrentAnimation, [this.sheetParams]);
|
|
276
276
|
}
|
|
277
277
|
|
|
278
|
-
if (props.hitbox) this.hitbox = props.hitbox;
|
|
278
|
+
if (props.hitbox) this.hitbox = props.hitbox.value ?? props.hitbox;
|
|
279
279
|
|
|
280
280
|
if (props.scaleMode) this.baseTexture.scaleMode = props.scaleMode;
|
|
281
281
|
else if (props.image && this.fullProps.rectangle === undefined) {
|
|
@@ -353,7 +353,7 @@ export class CanvasSprite extends DisplayObject(PixiSprite) {
|
|
|
353
353
|
);
|
|
354
354
|
}
|
|
355
355
|
|
|
356
|
-
const cloneParams =
|
|
356
|
+
const cloneParams = (params);
|
|
357
357
|
|
|
358
358
|
this.removeChildren();
|
|
359
359
|
animation.sprites = [];
|
|
@@ -459,6 +459,7 @@ export class CanvasSprite extends DisplayObject(PixiSprite) {
|
|
|
459
459
|
const widthOfSprite =
|
|
460
460
|
typeof realSize == "number" ? realSize : realSize?.width;
|
|
461
461
|
|
|
462
|
+
|
|
462
463
|
const applyAnchorBySize = () => {
|
|
463
464
|
if (heightOfSprite && this.hitbox) {
|
|
464
465
|
const { spriteWidth, spriteHeight } = data;
|