canvasengine 2.0.0-beta.28 → 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/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { h as a } from "./index-Cif_Fy_t.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-Cif_Fy_t.js";
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "canvasengine",
3
- "version": "2.0.0-beta.28",
3
+ "version": "2.0.0-beta.29",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -40,8 +40,8 @@ interface SvgProps extends DisplayObjectProps {
40
40
 
41
41
  class CanvasGraphics extends DisplayObject(PixiGraphics) {
42
42
  clearEffect: Effect;
43
- width: WritableSignal<number>;
44
- height: WritableSignal<number>;
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.width = width;
95
- this.height = height;
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
- if (isSignal(props.width)) {
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
- if (isSignal(props.height)) {
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: WritableSignal<number>;
214
- height: WritableSignal<number>;
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) => drawShape(g, 'ellipse', { width: signal(gWidth), height: signal(gHeight), color, border }),
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
  }