visualfries 0.1.105 → 0.1.107

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.
@@ -24,6 +24,7 @@ export class AnimationHook {
24
24
  #currentId = undefined;
25
25
  #componentTimeline = undefined;
26
26
  #animationsBuilt = false;
27
+ #lastAnimationDataHash = undefined; // Track animationData changes
27
28
  timeline;
28
29
  splitTextCache;
29
30
  types = Object.keys(this.#handlers);
@@ -142,6 +143,18 @@ export class AnimationHook {
142
143
  if (this.#context.isActive && this.#currentId !== this.#context.contextData.id) {
143
144
  await this.#handleRefresh();
144
145
  }
146
+ // Check if animationData has changed (e.g., SubtitlesHook just set wordStartTimes)
147
+ // This fixes the issue where animations are built before animationData is available
148
+ if (this.#context.isActive && this.#animationsBuilt) {
149
+ const animationData = this.#context.resources.get('animationData');
150
+ const currentHash = animationData?.wordStartTimes?.length?.toString() ?? '';
151
+ if (currentHash !== this.#lastAnimationDataHash && currentHash !== '') {
152
+ // animationData changed (became available) - need to rebuild animations
153
+ this.#lastAnimationDataHash = currentHash;
154
+ await this.#handleRefresh();
155
+ return;
156
+ }
157
+ }
145
158
  // Setup if component becomes active and animations aren't set up
146
159
  if (this.#context.isActive) {
147
160
  // && !this.#controls
@@ -2,7 +2,7 @@ import { MediaManager } from '../../managers/MediaManager.js';
2
2
  import { z } from 'zod';
3
3
  import { StateManager } from '../../managers/StateManager.svelte.js';
4
4
  export class MediaHook {
5
- types = ['setup', 'update', 'destroy', 'refresh'];
5
+ types = ['setup', 'update', 'destroy'];
6
6
  priority = 1;
7
7
  #context;
8
8
  #mediaElement;
@@ -53,6 +53,8 @@ export class PixiDisplayObjectHook {
53
53
  async #handleUpdate() {
54
54
  const isActive = this.#context.isActive;
55
55
  if (this.#displayObject) {
56
+ // Always re-assert the resource in case the context was cleared or updated
57
+ this.#context.setResource('pixiRenderObject', this.#displayObject);
56
58
  // Only mark dirty if visibility actually changed
57
59
  if (this.#displayObject.visible !== isActive) {
58
60
  this.#displayObject.visible = isActive;
@@ -172,6 +172,8 @@ export class PixiSplitScreenDisplayObjectHook {
172
172
  this.#drawBlurredBackground();
173
173
  }
174
174
  if (this.#displayObject) {
175
+ // Always re-assert the resource in case the context was cleared or updated
176
+ this.#context.setResource('pixiRenderObject', this.#displayObject);
175
177
  if (this.#displayObject.visible != isActive) {
176
178
  this.#displayObject.visible = isActive;
177
179
  }
@@ -9,6 +9,7 @@ export class PixiVideoTextureHook {
9
9
  priority = 1;
10
10
  #context;
11
11
  #videoTexture;
12
+ #videoElement;
12
13
  componentElement;
13
14
  #handlers = {
14
15
  update: this.#handleUpdate.bind(this),
@@ -16,27 +17,29 @@ export class PixiVideoTextureHook {
16
17
  'refresh:content': this.#handleRefreshContent.bind(this)
17
18
  };
18
19
  async #handleUpdate() {
19
- if (this.#videoTexture) {
20
- return;
21
- }
22
20
  const media = this.#context.getResource('videoElement');
23
- if (!media) {
24
- // Video element not ready yet - will be called again on next update
25
- return;
21
+ // If element changed or texture is missing, recreate it
22
+ if (media && (media !== this.#videoElement || !this.#videoTexture)) {
23
+ await this.#handleDestroy();
24
+ const res = new PIXI.VideoResource(media, {
25
+ autoPlay: false,
26
+ updateFPS: 30
27
+ });
28
+ const baseTexture = new PIXI.BaseTexture(res);
29
+ this.#videoTexture = new PIXI.Texture(baseTexture);
30
+ this.#videoElement = media;
31
+ }
32
+ // Always re-assert the resource in case the context was cleared or updated
33
+ if (this.#videoTexture) {
34
+ this.#context.setResource('pixiTexture', this.#videoTexture);
26
35
  }
27
- const res = new PIXI.VideoResource(media, {
28
- autoPlay: false,
29
- updateFPS: 30
30
- });
31
- const baseTexture = new PIXI.BaseTexture(res);
32
- this.#videoTexture = new PIXI.Texture(baseTexture);
33
- this.#context.setResource('pixiTexture', this.#videoTexture);
34
36
  }
35
37
  async #handleDestroy() {
36
38
  if (this.#videoTexture) {
37
39
  // Destroy the texture and its base texture to free GPU memory
38
40
  this.#videoTexture.destroy(true);
39
41
  this.#videoTexture = undefined;
42
+ this.#videoElement = undefined;
40
43
  this.#context.removeResource('pixiTexture');
41
44
  }
42
45
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "visualfries",
3
- "version": "0.1.105",
3
+ "version": "0.1.107",
4
4
  "license": "MIT",
5
5
  "author": "ContentFries",
6
6
  "repository": {