canvasengine 2.0.0-beta.13 → 2.0.0-beta.15

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
@@ -959,135 +959,11 @@ var Scheduler = class extends Directive {
959
959
  };
960
960
  registerDirective("tick", Scheduler);
961
961
 
962
- // src/directives/ViewportFollow.ts
963
- var ViewportFollow = class extends Directive {
964
- onInit(element) {
965
- }
966
- onMount(element) {
967
- this.onUpdate(element.props, element);
968
- }
969
- onUpdate(props, element) {
970
- const { viewportFollow } = element.props;
971
- const { viewport } = element.props.context;
972
- if (!viewport) {
973
- throw error("ViewportFollow directive requires a Viewport component to be mounted in the same context");
974
- }
975
- if (viewportFollow) {
976
- viewport.follow(element.componentInstance);
977
- } else {
978
- viewport.plugins.remove("follow");
979
- }
980
- }
981
- onDestroy(element) {
982
- const { viewportFollow } = element.props;
983
- const { viewport } = element.props.context;
984
- if (viewportFollow) viewport.plugins.remove("follow");
985
- }
986
- };
987
- registerDirective("viewportFollow", ViewportFollow);
988
-
989
- // src/directives/Sound.ts
990
- import { effect } from "@signe/reactive";
991
- import { Howl } from "howler";
992
- var EVENTS = ["load", "loaderror", "playerror", "play", "end", "pause", "stop", "mute", "volume", "rate", "seek", "fade", "unlock"];
993
- var Sound = class extends Directive {
994
- constructor() {
995
- super(...arguments);
996
- this.eventsFn = [];
997
- this.maxVolume = 1;
998
- this.maxDistance = 100;
999
- }
1000
- onInit(element) {
1001
- }
1002
- onMount(element) {
1003
- const { props } = element;
1004
- const tick2 = props.context.tick;
1005
- const { src, autoplay, loop: loop2, volume, spatial } = props.sound;
1006
- this.sound = new Howl({
1007
- src,
1008
- autoplay,
1009
- loop: loop2,
1010
- volume
1011
- });
1012
- for (let event of EVENTS) {
1013
- if (!props.sound[event]) continue;
1014
- const fn = props.sound[event];
1015
- this.eventsFn.push(fn);
1016
- this.sound.on(event, fn);
1017
- }
1018
- if (spatial) {
1019
- const { soundListenerPosition } = props.context;
1020
- if (!soundListenerPosition) {
1021
- throw new error("SoundListenerPosition directive is required for spatial sound in component parent");
1022
- }
1023
- const { x: listenerX, y: listenerY } = soundListenerPosition;
1024
- this.tickSubscription = effect(() => {
1025
- tick2();
1026
- const { x, y } = element.componentInstance;
1027
- const distance = calculateDistance(x, y, listenerX(), listenerY());
1028
- const volume2 = Math.max(this.maxVolume - distance / this.maxDistance, 0);
1029
- this.sound.volume(volume2);
1030
- }).subscription;
1031
- }
1032
- }
1033
- onUpdate(props) {
1034
- const { volume, loop: loop2, mute, seek, playing, rate, spatial } = props;
1035
- if (volume != void 0) this.sound.volume(volume);
1036
- if (loop2 != void 0) this.sound.loop(loop2);
1037
- if (mute != void 0) this.sound.mute(mute);
1038
- if (seek != void 0) this.sound.seek(seek);
1039
- if (playing != void 0) {
1040
- if (playing) this.sound.play();
1041
- else this.sound.pause();
1042
- }
1043
- if (spatial) {
1044
- this.maxVolume = spatial.maxVolume ?? this.maxVolume;
1045
- this.maxDistance = spatial.maxDistance ?? this.maxDistance;
1046
- }
1047
- if (rate != void 0) this.sound.rate(rate);
1048
- }
1049
- onDestroy() {
1050
- this.sound.stop();
1051
- this.tickSubscription?.unsubscribe();
1052
- for (let event of EVENTS) {
1053
- if (this.eventsFn[event]) {
1054
- this.sound.off(event, this.eventsFn[event]);
1055
- }
1056
- }
1057
- }
1058
- };
1059
- var SoundListenerPosition = class extends Directive {
1060
- onMount(element) {
1061
- element.props.context.soundListenerPosition = element.propObservables?.soundListenerPosition;
1062
- }
1063
- onInit(element) {
1064
- }
1065
- onUpdate(props) {
1066
- }
1067
- onDestroy() {
1068
- }
1069
- };
1070
- registerDirective("sound", Sound);
1071
- registerDirective("soundListenerPosition", SoundListenerPosition);
1072
-
1073
- // src/directives/Drag.ts
1074
- import { effect as effect2, isSignal as isSignal3 } from "@signe/reactive";
1075
- import { Rectangle, Point } from "pixi.js";
1076
- import { snap } from "popmotion";
1077
-
1078
- // src/hooks/addContext.ts
1079
- var addContext = (element, key, value) => {
1080
- element.props.context = {
1081
- ...element.props.context ?? {},
1082
- [key]: value
1083
- };
1084
- };
1085
-
1086
962
  // src/hooks/useProps.ts
1087
- import { isSignal as isSignal2, signal } from "@signe/reactive";
963
+ import { isSignal as isSignal2, signal as signal2 } from "@signe/reactive";
1088
964
 
1089
965
  // src/engine/reactive.ts
1090
- import { isSignal } from "@signe/reactive";
966
+ import { isComputed, isSignal, signal } from "@signe/reactive";
1091
967
  import {
1092
968
  Observable,
1093
969
  Subject,
@@ -1116,11 +992,11 @@ function destroyElement(element) {
1116
992
  }
1117
993
  element.propSubscriptions.forEach((sub) => sub.unsubscribe());
1118
994
  element.effectSubscriptions.forEach((sub) => sub.unsubscribe());
995
+ element.effectUnmounts.forEach((fn) => fn?.());
1119
996
  for (let name in element.directives) {
1120
997
  element.directives[name].onDestroy?.(element);
1121
998
  }
1122
999
  element.componentInstance.onDestroy?.(element.parent);
1123
- element.effectUnmounts.forEach((fn) => fn?.());
1124
1000
  }
1125
1001
  function createComponent(tag, props) {
1126
1002
  if (!components[tag]) {
@@ -1285,11 +1161,16 @@ function createComponent(tag, props) {
1285
1161
  return element;
1286
1162
  }
1287
1163
  function loop(itemsSubject, createElementFn) {
1164
+ if (isComputed(itemsSubject) && itemsSubject.dependencies.size == 0) {
1165
+ itemsSubject = signal(itemsSubject());
1166
+ } else if (!isSignal(itemsSubject)) {
1167
+ itemsSubject = signal(itemsSubject);
1168
+ }
1288
1169
  return defer(() => {
1289
1170
  let elements = [];
1290
1171
  let elementMap = /* @__PURE__ */ new Map();
1291
1172
  let isFirstSubscription = true;
1292
- const isArraySignal = (signal8) => Array.isArray(signal8());
1173
+ const isArraySignal = (signal9) => Array.isArray(signal9());
1293
1174
  return new Observable((subscriber) => {
1294
1175
  const subscription = isArraySignal(itemsSubject) ? itemsSubject.observable.subscribe((change) => {
1295
1176
  if (isFirstSubscription) {
@@ -1341,6 +1222,29 @@ function loop(itemsSubject, createElementFn) {
1341
1222
  el.destroy();
1342
1223
  elementMap.delete(change.index);
1343
1224
  });
1225
+ } else if (change.type === "update" && change.index !== void 0 && change.items.length === 1) {
1226
+ const index = change.index;
1227
+ const newItem = change.items[0];
1228
+ if (index >= elements.length || elements[index] === void 0 || !elementMap.has(index)) {
1229
+ const newElement = createElementFn(newItem, index);
1230
+ if (newElement) {
1231
+ elements.splice(index, 0, newElement);
1232
+ elementMap.set(index, newElement);
1233
+ } else {
1234
+ console.warn(`Element creation returned null for index ${index} during add-like update.`);
1235
+ }
1236
+ } else {
1237
+ const oldElement = elements[index];
1238
+ oldElement.destroy();
1239
+ const newElement = createElementFn(newItem, index);
1240
+ if (newElement) {
1241
+ elements[index] = newElement;
1242
+ elementMap.set(index, newElement);
1243
+ } else {
1244
+ elements.splice(index, 1);
1245
+ elementMap.delete(index);
1246
+ }
1247
+ }
1344
1248
  }
1345
1249
  subscriber.next({
1346
1250
  elements: [...elements]
@@ -1481,11 +1385,11 @@ var useProps = (props, defaults = {}) => {
1481
1385
  const obj = {};
1482
1386
  for (let key in props) {
1483
1387
  const value = props[key];
1484
- obj[key] = isPrimitive(value) ? signal(value) : value;
1388
+ obj[key] = isPrimitive(value) ? signal2(value) : value;
1485
1389
  }
1486
1390
  for (let key in defaults) {
1487
1391
  if (!(key in obj)) {
1488
- obj[key] = isPrimitive(defaults[key]) ? signal(defaults[key]) : defaults[key];
1392
+ obj[key] = isPrimitive(defaults[key]) ? signal2(defaults[key]) : defaults[key];
1489
1393
  }
1490
1394
  }
1491
1395
  return obj;
@@ -1521,7 +1425,7 @@ var useDefineProps = (props) => {
1521
1425
  validatedValue = value;
1522
1426
  }
1523
1427
  }
1524
- validatedProps[key] = isSignal2(validatedValue) ? validatedValue : signal(validatedValue);
1428
+ validatedProps[key] = isSignal2(validatedValue) ? validatedValue : signal2(validatedValue);
1525
1429
  }
1526
1430
  return {
1527
1431
  ...useProps(rawProps),
@@ -1549,6 +1453,143 @@ function validateType(key, value, types) {
1549
1453
  }
1550
1454
  }
1551
1455
 
1456
+ // src/directives/ViewportFollow.ts
1457
+ var ViewportFollow = class extends Directive {
1458
+ onInit(element) {
1459
+ }
1460
+ onMount(element) {
1461
+ this.onUpdate(element.props.viewportFollow, element);
1462
+ }
1463
+ onUpdate(viewportFollow, element) {
1464
+ const { viewport } = element.props.context;
1465
+ if (!viewport) {
1466
+ throw error("ViewportFollow directive requires a Viewport component to be mounted in the same context");
1467
+ }
1468
+ if (viewportFollow) {
1469
+ if (viewportFollow === true) {
1470
+ viewport.follow(element.componentInstance);
1471
+ } else {
1472
+ const options = useProps(viewportFollow, {
1473
+ speed: void 0,
1474
+ acceleration: void 0,
1475
+ radius: void 0
1476
+ });
1477
+ viewport.follow(element.componentInstance, {
1478
+ speed: options.speed(),
1479
+ acceleration: options.acceleration(),
1480
+ radius: options.radius()
1481
+ });
1482
+ }
1483
+ } else {
1484
+ viewport.plugins.remove("follow");
1485
+ }
1486
+ }
1487
+ onDestroy(element) {
1488
+ const { viewportFollow } = element.props;
1489
+ const { viewport } = element.props.context;
1490
+ if (viewportFollow) viewport.plugins.remove("follow");
1491
+ }
1492
+ };
1493
+ registerDirective("viewportFollow", ViewportFollow);
1494
+
1495
+ // src/directives/Sound.ts
1496
+ import { effect } from "@signe/reactive";
1497
+ import { Howl } from "howler";
1498
+ var EVENTS = ["load", "loaderror", "playerror", "play", "end", "pause", "stop", "mute", "volume", "rate", "seek", "fade", "unlock"];
1499
+ var Sound = class extends Directive {
1500
+ constructor() {
1501
+ super(...arguments);
1502
+ this.eventsFn = [];
1503
+ this.maxVolume = 1;
1504
+ this.maxDistance = 100;
1505
+ }
1506
+ onInit(element) {
1507
+ }
1508
+ onMount(element) {
1509
+ const { props } = element;
1510
+ const tick2 = props.context.tick;
1511
+ const propsSound = props.sound.value ?? props.sound;
1512
+ const { src, autoplay, loop: loop2, volume, spatial } = propsSound;
1513
+ this.sound = new Howl({
1514
+ src,
1515
+ autoplay,
1516
+ loop: loop2,
1517
+ volume
1518
+ });
1519
+ for (let event of EVENTS) {
1520
+ if (!propsSound[event]) continue;
1521
+ const fn = propsSound[event];
1522
+ this.eventsFn.push(fn);
1523
+ this.sound.on(event, fn);
1524
+ }
1525
+ if (spatial) {
1526
+ const { soundListenerPosition } = props.context;
1527
+ if (!soundListenerPosition) {
1528
+ throw new error("SoundListenerPosition directive is required for spatial sound in component parent");
1529
+ }
1530
+ const { x: listenerX, y: listenerY } = soundListenerPosition;
1531
+ this.tickSubscription = effect(() => {
1532
+ tick2();
1533
+ const { x, y } = element.componentInstance;
1534
+ const distance = calculateDistance(x, y, listenerX(), listenerY());
1535
+ const volume2 = Math.max(this.maxVolume - distance / this.maxDistance, 0);
1536
+ this.sound.volume(volume2);
1537
+ }).subscription;
1538
+ }
1539
+ }
1540
+ onUpdate(props) {
1541
+ const { volume, loop: loop2, mute, seek, playing, rate, spatial } = props.value ?? props;
1542
+ if (volume != void 0) this.sound.volume(volume);
1543
+ if (loop2 != void 0) this.sound.loop(loop2);
1544
+ if (mute != void 0) this.sound.mute(mute);
1545
+ if (seek != void 0) this.sound.seek(seek);
1546
+ if (playing != void 0) {
1547
+ if (playing) this.sound.play();
1548
+ else this.sound.pause();
1549
+ }
1550
+ if (spatial) {
1551
+ this.maxVolume = spatial.maxVolume ?? this.maxVolume;
1552
+ this.maxDistance = spatial.maxDistance ?? this.maxDistance;
1553
+ }
1554
+ if (rate != void 0) this.sound.rate(rate);
1555
+ }
1556
+ onDestroy() {
1557
+ this.sound.stop();
1558
+ this.tickSubscription?.unsubscribe();
1559
+ for (let event of EVENTS) {
1560
+ if (this.eventsFn[event]) {
1561
+ this.sound.off(event, this.eventsFn[event]);
1562
+ }
1563
+ }
1564
+ }
1565
+ };
1566
+ var SoundListenerPosition = class extends Directive {
1567
+ onMount(element) {
1568
+ element.props.context.soundListenerPosition = element.propObservables?.soundListenerPosition;
1569
+ }
1570
+ onInit(element) {
1571
+ }
1572
+ onUpdate(props) {
1573
+ }
1574
+ onDestroy() {
1575
+ }
1576
+ };
1577
+ registerDirective("sound", Sound);
1578
+ registerDirective("soundListenerPosition", SoundListenerPosition);
1579
+
1580
+ // src/directives/Drag.ts
1581
+ import { effect as effect2, isComputed as isComputed2, isSignal as isSignal3 } from "@signe/reactive";
1582
+ import { Rectangle, Point } from "pixi.js";
1583
+ import { snap } from "popmotion";
1584
+
1585
+ // src/hooks/addContext.ts
1586
+ var addContext = (element, key, value) => {
1587
+ element.props.context = {
1588
+ ...element.props.context ?? {},
1589
+ [key]: value
1590
+ };
1591
+ };
1592
+
1552
1593
  // src/directives/Drag.ts
1553
1594
  var Drop = class extends Directive {
1554
1595
  constructor() {
@@ -1577,12 +1618,18 @@ var Drag = class extends Directive {
1577
1618
  this.viewport = null;
1578
1619
  this.animationFrameId = null;
1579
1620
  this.lastPointerPosition = new Point();
1621
+ this.pressedKeys = /* @__PURE__ */ new Set();
1622
+ this.pointerIsDown = false;
1580
1623
  this.onDragMoveHandler = () => {
1581
1624
  };
1582
1625
  this.onDragEndHandler = () => {
1583
1626
  };
1584
1627
  this.onDragStartHandler = () => {
1585
1628
  };
1629
+ this.onKeyDownHandler = () => {
1630
+ };
1631
+ this.onKeyUpHandler = () => {
1632
+ };
1586
1633
  this.subscriptions = [];
1587
1634
  }
1588
1635
  onInit(element) {
@@ -1590,6 +1637,8 @@ var Drag = class extends Directive {
1590
1637
  this.onDragMoveHandler = this.onDragMove.bind(this);
1591
1638
  this.onDragEndHandler = this.onDragEnd.bind(this);
1592
1639
  this.onDragStartHandler = this.onPointerDown.bind(this);
1640
+ this.onKeyDownHandler = this.onKeyDown.bind(this);
1641
+ this.onKeyUpHandler = this.onKeyUp.bind(this);
1593
1642
  }
1594
1643
  onMount(element) {
1595
1644
  const { rootElement, canvasSize, viewport, tick: tick2 } = element.props.context;
@@ -1614,6 +1663,9 @@ var Drag = class extends Directive {
1614
1663
  instance.on("pointerdown", this.onDragStartHandler);
1615
1664
  this.stageRef.on("pointerup", this.onDragEndHandler);
1616
1665
  this.stageRef.on("pointerupoutside", this.onDragEndHandler);
1666
+ const keysToPress = dragProps.keyToPress ? dragProps.keyToPress : [];
1667
+ window.addEventListener("keydown", this.onKeyDownHandler);
1668
+ window.addEventListener("keyup", this.onKeyUpHandler);
1617
1669
  this.subscriptions = [
1618
1670
  tick2.observable.subscribe(() => {
1619
1671
  if (this.isDragging && this.viewport) {
@@ -1628,7 +1680,8 @@ var Drag = class extends Directive {
1628
1680
  const options = useProps(drag?.value ?? drag, {
1629
1681
  snap: 0,
1630
1682
  viewport: {},
1631
- direction: "all"
1683
+ direction: "all",
1684
+ keyToPress: []
1632
1685
  });
1633
1686
  options.viewport = useProps(options.viewport, {
1634
1687
  edgeThreshold: 300,
@@ -1674,10 +1727,17 @@ var Drag = class extends Directive {
1674
1727
  }
1675
1728
  this.lastPointerPosition.copyFrom(event.global);
1676
1729
  const { x: xProp, y: yProp } = propObservables;
1677
- if (xProp !== void 0 && isSignal3(xProp)) {
1678
- }
1679
- if (yProp !== void 0 && isSignal3(yProp)) {
1680
- }
1730
+ const updatePosition = (prop, value) => {
1731
+ if (isComputed2(prop)) {
1732
+ prop.dependencies.forEach((dependency) => {
1733
+ dependency.set(value);
1734
+ });
1735
+ } else if (isSignal3(prop)) {
1736
+ prop.set(value);
1737
+ }
1738
+ };
1739
+ if (xProp !== void 0) updatePosition(xProp, instance.position.x);
1740
+ if (yProp !== void 0) updatePosition(yProp, instance.position.y);
1681
1741
  }
1682
1742
  /**
1683
1743
  * Moves the viewport if the dragged element is near screen edges
@@ -1731,7 +1791,8 @@ var Drag = class extends Directive {
1731
1791
  * Handles drag end event and stops viewport movement
1732
1792
  */
1733
1793
  onDragEnd() {
1734
- if (!this.isDragging || !this.elementRef) return;
1794
+ this.pointerIsDown = false;
1795
+ if (!this.isDragging) return;
1735
1796
  const dragProps = this.dragProps;
1736
1797
  this.isDragging = false;
1737
1798
  dragProps?.end?.();
@@ -1739,16 +1800,61 @@ var Drag = class extends Directive {
1739
1800
  this.stageRef.off("pointermove", this.onDragMoveHandler);
1740
1801
  }
1741
1802
  }
1803
+ onKeyDown(event) {
1804
+ this.pressedKeys.add(event.code);
1805
+ this.pressedKeys.add(event.key.toLowerCase());
1806
+ if (this.pointerIsDown && !this.isDragging && this.areRequiredKeysPressed()) {
1807
+ this.startDrag();
1808
+ }
1809
+ }
1810
+ onKeyUp(event) {
1811
+ this.pressedKeys.delete(event.code);
1812
+ this.pressedKeys.delete(event.key.toLowerCase());
1813
+ if (this.isDragging && !this.areRequiredKeysPressed()) {
1814
+ this.onDragEnd();
1815
+ }
1816
+ }
1817
+ areRequiredKeysPressed() {
1818
+ const keyToPress = this.dragProps.keyToPress ? this.dragProps.keyToPress : [];
1819
+ if (!keyToPress || keyToPress.length === 0) {
1820
+ return true;
1821
+ }
1822
+ return keyToPress.some((key) => {
1823
+ if (this.pressedKeys.has(key)) {
1824
+ return true;
1825
+ }
1826
+ if (key.toLowerCase() === "space") {
1827
+ return this.pressedKeys.has("Space") || this.pressedKeys.has(" ");
1828
+ }
1829
+ if (key.toLowerCase() === "shift") {
1830
+ return this.pressedKeys.has("ShiftLeft") || this.pressedKeys.has("ShiftRight");
1831
+ }
1832
+ if (key.toLowerCase() === "control" || key.toLowerCase() === "ctrl") {
1833
+ return this.pressedKeys.has("ControlLeft") || this.pressedKeys.has("ControlRight");
1834
+ }
1835
+ if (key.toLowerCase() === "alt") {
1836
+ return this.pressedKeys.has("AltLeft") || this.pressedKeys.has("AltRight");
1837
+ }
1838
+ return false;
1839
+ });
1840
+ }
1742
1841
  onPointerDown(event) {
1743
1842
  if (!this.elementRef?.componentInstance || !this.stageRef || !this.elementRef.componentInstance.parent) return;
1843
+ this.pointerIsDown = true;
1744
1844
  const instance = this.elementRef.componentInstance;
1745
1845
  const parent = instance.parent;
1746
- const dragProps = this.dragProps;
1747
1846
  const parentLocalPointer = parent.toLocal(event.global);
1748
1847
  this.offsetInParent.x = parentLocalPointer.x - instance.position.x;
1749
1848
  this.offsetInParent.y = parentLocalPointer.y - instance.position.y;
1750
- this.isDragging = true;
1751
1849
  this.lastPointerPosition.copyFrom(event.global);
1850
+ if (this.areRequiredKeysPressed()) {
1851
+ this.startDrag();
1852
+ }
1853
+ }
1854
+ startDrag() {
1855
+ if (this.isDragging || !this.stageRef) return;
1856
+ this.isDragging = true;
1857
+ const dragProps = this.dragProps;
1752
1858
  dragProps?.start?.();
1753
1859
  this.stageRef.on("pointermove", this.onDragMoveHandler);
1754
1860
  }
@@ -1769,8 +1875,12 @@ var Drag = class extends Directive {
1769
1875
  this.stageRef.off("pointerup", this.onDragEndHandler);
1770
1876
  this.stageRef.off("pointerupoutside", this.onDragEndHandler);
1771
1877
  }
1878
+ window.removeEventListener("keydown", this.onKeyDownHandler);
1879
+ window.removeEventListener("keyup", this.onKeyUpHandler);
1772
1880
  this.stageRef = null;
1773
1881
  this.viewport = null;
1882
+ this.pressedKeys.clear();
1883
+ this.pointerIsDown = false;
1774
1884
  }
1775
1885
  };
1776
1886
  registerDirective("drag", Drag);
@@ -1814,12 +1924,12 @@ export * from "@signe/reactive";
1814
1924
  import { Howler } from "howler";
1815
1925
 
1816
1926
  // src/components/Canvas.ts
1817
- import { effect as effect4, signal as signal4 } from "@signe/reactive";
1927
+ import { effect as effect4, signal as signal5 } from "@signe/reactive";
1818
1928
  import { Container as Container3, autoDetectRenderer } from "pixi.js";
1819
1929
  import { loadYoga } from "yoga-layout";
1820
1930
 
1821
1931
  // src/components/DisplayObject.ts
1822
- import { effect as effect3, signal as signal3 } from "@signe/reactive";
1932
+ import { effect as effect3, signal as signal4 } from "@signe/reactive";
1823
1933
  import { DropShadowFilter } from "pixi-filters";
1824
1934
  import { BlurFilter, ObservablePoint } from "pixi.js";
1825
1935
  var EVENTS2 = [
@@ -1909,8 +2019,8 @@ function DisplayObject(extendClass) {
1909
2019
  0
1910
2020
  );
1911
2021
  this.isCustomAnchor = false;
1912
- this.displayWidth = signal3(0);
1913
- this.displayHeight = signal3(0);
2022
+ this.displayWidth = signal4(0);
2023
+ this.displayHeight = signal4(0);
1914
2024
  this.overrideProps = [];
1915
2025
  }
1916
2026
  get yoga() {
@@ -2206,14 +2316,14 @@ registerComponent("Canvas", class Canvas extends DisplayObject(Container3) {
2206
2316
  var Canvas2 = async (props = {}) => {
2207
2317
  let { cursorStyles, width, height, class: className } = useProps(props);
2208
2318
  const Yoga = await loadYoga();
2209
- if (!props.width) width = signal4(800);
2210
- if (!props.height) height = signal4(600);
2319
+ if (!props.width) width = signal5(800);
2320
+ if (!props.height) height = signal5(600);
2211
2321
  const renderer = await autoDetectRenderer({
2212
2322
  ...props,
2213
2323
  width: width?.(),
2214
2324
  height: height?.()
2215
2325
  });
2216
- const canvasSize = signal4({
2326
+ const canvasSize = signal5({
2217
2327
  width: renderer.width,
2218
2328
  height: renderer.height
2219
2329
  });
@@ -2229,7 +2339,7 @@ var Canvas2 = async (props = {}) => {
2229
2339
  height: height?.()
2230
2340
  };
2231
2341
  if (!props.tick) {
2232
- options.context.tick = options.tick = signal4({
2342
+ options.context.tick = options.tick = signal5({
2233
2343
  timestamp: 0,
2234
2344
  deltaTime: 0,
2235
2345
  frame: 0,
@@ -2326,12 +2436,16 @@ var CanvasGraphics = class extends DisplayObject(PixiGraphics) {
2326
2436
  onInit(props) {
2327
2437
  super.onInit(props);
2328
2438
  if (props.draw) {
2329
- effect5(() => {
2439
+ this.clearEffect = effect5(() => {
2330
2440
  this.clear();
2331
2441
  props.draw?.(this);
2332
2442
  });
2333
2443
  }
2334
2444
  }
2445
+ onDestroy() {
2446
+ this.clearEffect.subscription.unsubscribe();
2447
+ super.onDestroy();
2448
+ }
2335
2449
  };
2336
2450
  registerComponent("Graphics", CanvasGraphics);
2337
2451
  function Graphics(props) {
@@ -2505,6 +2619,7 @@ function ParticlesEmitter(props) {
2505
2619
  }
2506
2620
 
2507
2621
  // src/components/Sprite.ts
2622
+ import { Howl as Howl2 } from "howler";
2508
2623
  import { computed, effect as effect7, isSignal as isSignal4 } from "@signe/reactive";
2509
2624
  import {
2510
2625
  Assets,
@@ -2515,10 +2630,10 @@ import {
2515
2630
  } from "pixi.js";
2516
2631
 
2517
2632
  // src/engine/animation.ts
2518
- import { effect as effect6, signal as signal5 } from "@signe/reactive";
2633
+ import { effect as effect6, signal as signal6 } from "@signe/reactive";
2519
2634
  import { animate as animatePopmotion } from "popmotion";
2520
- function isAnimatedSignal(signal8) {
2521
- return signal8.animatedState !== void 0;
2635
+ function isAnimatedSignal(signal9) {
2636
+ return signal9.animatedState !== void 0;
2522
2637
  }
2523
2638
  function animatedSignal(initialValue, options = {}) {
2524
2639
  const state = {
@@ -2527,8 +2642,8 @@ function animatedSignal(initialValue, options = {}) {
2527
2642
  end: initialValue
2528
2643
  };
2529
2644
  let animation;
2530
- const publicSignal = signal5(initialValue);
2531
- const privateSignal = signal5(state);
2645
+ const publicSignal = signal6(initialValue);
2646
+ const privateSignal = signal6(state);
2532
2647
  effect6(() => {
2533
2648
  const currentState = privateSignal();
2534
2649
  publicSignal.set(currentState.current);
@@ -2826,6 +2941,12 @@ var CanvasSprite = class extends DisplayObject(PixiSprite) {
2826
2941
  }
2827
2942
  const sound = this.currentAnimation.data.sound;
2828
2943
  if (sound) {
2944
+ new Howl2({
2945
+ src: sound,
2946
+ autoplay: true,
2947
+ loop: false,
2948
+ volume: 1
2949
+ });
2829
2950
  }
2830
2951
  this.update({
2831
2952
  deltaRatio: 1
@@ -2910,7 +3031,7 @@ var Sprite2 = (props) => {
2910
3031
  };
2911
3032
 
2912
3033
  // src/components/Video.ts
2913
- import { effect as effect8, signal as signal6 } from "@signe/reactive";
3034
+ import { effect as effect8, signal as signal7 } from "@signe/reactive";
2914
3035
  function Video(props) {
2915
3036
  const eventsMap = {
2916
3037
  audioprocess: null,
@@ -2935,7 +3056,7 @@ function Video(props) {
2935
3056
  volumechange: null,
2936
3057
  waiting: null
2937
3058
  };
2938
- const video = signal6(null);
3059
+ const video = signal7(null);
2939
3060
  const defineProps = useDefineProps(props);
2940
3061
  const { play, loop: loop2, muted } = defineProps({
2941
3062
  play: {
@@ -3005,12 +3126,12 @@ function Video(props) {
3005
3126
  import { Text as PixiText } from "pixi.js";
3006
3127
 
3007
3128
  // src/engine/trigger.ts
3008
- import { effect as effect9, signal as signal7 } from "@signe/reactive";
3129
+ import { effect as effect9, signal as signal8 } from "@signe/reactive";
3009
3130
  function isTrigger(arg) {
3010
3131
  return arg?.start && arg?.listen;
3011
3132
  }
3012
3133
  function trigger(globalConfig) {
3013
- const _signal = signal7({
3134
+ const _signal = signal8({
3014
3135
  config: globalConfig,
3015
3136
  value: 0,
3016
3137
  resolve: (value) => void 0
@@ -3467,6 +3588,7 @@ var RadialGradient = class {
3467
3588
 
3468
3589
  // src/index.ts
3469
3590
  import { isObservable } from "rxjs";
3591
+ import * as Howl3 from "howler";
3470
3592
  export {
3471
3593
  Canvas2 as Canvas,
3472
3594
  Circle,
@@ -3476,6 +3598,7 @@ export {
3476
3598
  Easing,
3477
3599
  Ellipse,
3478
3600
  Graphics,
3601
+ Howl3 as Howl,
3479
3602
  Howler,
3480
3603
  NineSliceSprite,
3481
3604
  ParticlesEmitter,