canvasengine 2.0.0-beta.21 → 2.0.0-beta.23

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/package.json CHANGED
@@ -1,9 +1,12 @@
1
1
  {
2
2
  "name": "canvasengine",
3
- "version": "2.0.0-beta.21",
3
+ "version": "2.0.0-beta.23",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
+ "peerDependencies": {
8
+ "pixi.js": "^8.9.2"
9
+ },
7
10
  "dependencies": {
8
11
  "@barvynkoa/particle-emitter": "^0.0.1",
9
12
  "@pixi/layout": "^3.0.2",
@@ -11,7 +14,6 @@
11
14
  "howler": "^2.2.4",
12
15
  "pixi-filters": "^6.0.5",
13
16
  "pixi-viewport": "^6.0.3",
14
- "pixi.js": "^8.9.2",
15
17
  "popmotion": "^11.0.5",
16
18
  "rxjs": "^7.8.1",
17
19
  "yoga-layout": "^3.2.1"
@@ -84,14 +84,26 @@ function destroyElement(element: Element | Element[]) {
84
84
  if (!element) {
85
85
  return;
86
86
  }
87
+ if (element.props?.children) {
88
+ for (let child of element.props.children) {
89
+ destroyElement(child)
90
+ }
91
+ }
87
92
  for (let name in element.directives) {
88
93
  element.directives[name].onDestroy?.(element);
89
94
  }
90
- element.componentInstance.onDestroy(element.parent as any, () => {
91
- element.propSubscriptions.forEach((sub) => sub.unsubscribe());
92
- element.effectSubscriptions.forEach((sub) => sub.unsubscribe());
93
- element.effectUnmounts.forEach((fn) => fn?.());
94
- });
95
+ if (element.componentInstance && element.componentInstance.onDestroy) {
96
+ element.componentInstance.onDestroy(element.parent as any, () => {
97
+ element.propSubscriptions?.forEach((sub) => sub.unsubscribe());
98
+ element.effectSubscriptions?.forEach((sub) => sub.unsubscribe());
99
+ element.effectUnmounts?.forEach((fn) => fn?.());
100
+ });
101
+ } else {
102
+ // If componentInstance is undefined or doesn't have onDestroy, still clean up subscriptions
103
+ element.propSubscriptions?.forEach((sub) => sub.unsubscribe());
104
+ element.effectSubscriptions?.forEach((sub) => sub.unsubscribe());
105
+ element.effectUnmounts?.forEach((fn) => fn?.());
106
+ }
95
107
  }
96
108
 
97
109
  /**