visualfries 0.1.0

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.
Files changed (219) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +213 -0
  3. package/dist/DIContainer.d.ts +4 -0
  4. package/dist/DIContainer.js +145 -0
  5. package/dist/SceneBuilder.svelte.d.ts +8574 -0
  6. package/dist/SceneBuilder.svelte.js +409 -0
  7. package/dist/adapters/subtitleHelpers.d.ts +2 -0
  8. package/dist/adapters/subtitleHelpers.js +187 -0
  9. package/dist/animations/AnimationContext.d.ts +17 -0
  10. package/dist/animations/AnimationContext.js +72 -0
  11. package/dist/animations/AnimationPresetsRegister.d.ts +362 -0
  12. package/dist/animations/AnimationPresetsRegister.js +20 -0
  13. package/dist/animations/AnimationSetup.d.ts +8 -0
  14. package/dist/animations/AnimationSetup.js +30 -0
  15. package/dist/animations/SplitTextCache.d.ts +28 -0
  16. package/dist/animations/SplitTextCache.js +68 -0
  17. package/dist/animations/animationBuilder.d.ts +31 -0
  18. package/dist/animations/animationBuilder.js +255 -0
  19. package/dist/animations/animationPreset.d.ts +7 -0
  20. package/dist/animations/animationPreset.js +31 -0
  21. package/dist/animations/builders/AnimationPresetFactory.d.ts +43 -0
  22. package/dist/animations/builders/AnimationPresetFactory.js +139 -0
  23. package/dist/animations/builders/LineHighlighterAnimationBuilder.d.ts +16 -0
  24. package/dist/animations/builders/LineHighlighterAnimationBuilder.js +183 -0
  25. package/dist/animations/builders/WordHighlighterAnimationBuilder.d.ts +15 -0
  26. package/dist/animations/builders/WordHighlighterAnimationBuilder.js +180 -0
  27. package/dist/animations/engines/AnimationEngineAdaptor.d.ts +107 -0
  28. package/dist/animations/engines/AnimationEngineAdaptor.js +1 -0
  29. package/dist/animations/engines/GSAPEngineAdaptor.d.ts +21 -0
  30. package/dist/animations/engines/GSAPEngineAdaptor.js +145 -0
  31. package/dist/animations/presets/index.d.ts +2 -0
  32. package/dist/animations/presets/index.js +3 -0
  33. package/dist/animations/presets/lines.d.ts +52 -0
  34. package/dist/animations/presets/lines.js +547 -0
  35. package/dist/animations/presets/words.d.ts +31 -0
  36. package/dist/animations/presets/words.js +268 -0
  37. package/dist/animations/transformers/AnimationReferenceTransformer.d.ts +9 -0
  38. package/dist/animations/transformers/AnimationReferenceTransformer.js +114 -0
  39. package/dist/builders/PixiComponentBuilder.d.ts +63 -0
  40. package/dist/builders/PixiComponentBuilder.js +112 -0
  41. package/dist/builders/_ComponentState.svelte.d.ts +795 -0
  42. package/dist/builders/_ComponentState.svelte.js +203 -0
  43. package/dist/builders/html/HtmlBuilder.d.ts +66 -0
  44. package/dist/builders/html/HtmlBuilder.js +171 -0
  45. package/dist/builders/html/HtmlBuilderFactory.d.ts +27 -0
  46. package/dist/builders/html/HtmlBuilderFactory.js +30 -0
  47. package/dist/builders/html/StyleBuilder.d.ts +13 -0
  48. package/dist/builders/html/StyleBuilder.js +133 -0
  49. package/dist/builders/html/StyleProcessor.d.ts +9 -0
  50. package/dist/builders/html/StyleProcessor.js +1 -0
  51. package/dist/builders/html/TextComponentHtmlBuilder.d.ts +16 -0
  52. package/dist/builders/html/TextComponentHtmlBuilder.js +93 -0
  53. package/dist/builders/html/TextShadowBuilder.d.ts +60 -0
  54. package/dist/builders/html/TextShadowBuilder.js +227 -0
  55. package/dist/builders/html/processors/AppearanceStyleProcessor.d.ts +5 -0
  56. package/dist/builders/html/processors/AppearanceStyleProcessor.js +57 -0
  57. package/dist/builders/html/processors/TextAppearanceStyleProcessor.d.ts +5 -0
  58. package/dist/builders/html/processors/TextAppearanceStyleProcessor.js +37 -0
  59. package/dist/builders/html/processors/TextEffectsStyleProcessor.d.ts +6 -0
  60. package/dist/builders/html/processors/TextEffectsStyleProcessor.js +68 -0
  61. package/dist/commands/Command.d.ts +6 -0
  62. package/dist/commands/Command.js +1 -0
  63. package/dist/commands/CommandRunner.d.ts +28 -0
  64. package/dist/commands/CommandRunner.js +81 -0
  65. package/dist/commands/CommandTypes.d.ts +11 -0
  66. package/dist/commands/CommandTypes.js +13 -0
  67. package/dist/commands/PauseCommand.d.ts +4 -0
  68. package/dist/commands/PauseCommand.js +5 -0
  69. package/dist/commands/PlayCommand.d.ts +4 -0
  70. package/dist/commands/PlayCommand.js +6 -0
  71. package/dist/commands/RenderCommand.d.ts +15 -0
  72. package/dist/commands/RenderCommand.js +18 -0
  73. package/dist/commands/RenderFrameCommand.d.ts +17 -0
  74. package/dist/commands/RenderFrameCommand.js +93 -0
  75. package/dist/commands/ReplaceSourceOnTimeCommand.d.ts +4 -0
  76. package/dist/commands/ReplaceSourceOnTimeCommand.js +22 -0
  77. package/dist/commands/SeekCommand.d.ts +15 -0
  78. package/dist/commands/SeekCommand.js +39 -0
  79. package/dist/commands/UpdateComponentCommand.d.ts +4 -0
  80. package/dist/commands/UpdateComponentCommand.js +17 -0
  81. package/dist/components/AnimatedGIF.d.ts +201 -0
  82. package/dist/components/AnimatedGIF.js +391 -0
  83. package/dist/components/Component.svelte.d.ts +33 -0
  84. package/dist/components/Component.svelte.js +152 -0
  85. package/dist/components/ComponentContext.svelte.d.ts +33 -0
  86. package/dist/components/ComponentContext.svelte.js +105 -0
  87. package/dist/components/hooks/AnimationHook.d.ts +25 -0
  88. package/dist/components/hooks/AnimationHook.js +180 -0
  89. package/dist/components/hooks/CanvasShapeHook.d.ts +12 -0
  90. package/dist/components/hooks/CanvasShapeHook.js +229 -0
  91. package/dist/components/hooks/HtmlAnimationHook.d.ts +8 -0
  92. package/dist/components/hooks/HtmlAnimationHook.js +70 -0
  93. package/dist/components/hooks/HtmlTextHook.d.ts +16 -0
  94. package/dist/components/hooks/HtmlTextHook.js +102 -0
  95. package/dist/components/hooks/HtmlToCanvasHook.d.ts +16 -0
  96. package/dist/components/hooks/HtmlToCanvasHook.js +148 -0
  97. package/dist/components/hooks/ImageHook.d.ts +10 -0
  98. package/dist/components/hooks/ImageHook.js +45 -0
  99. package/dist/components/hooks/MediaHook.d.ts +15 -0
  100. package/dist/components/hooks/MediaHook.js +252 -0
  101. package/dist/components/hooks/MediaSeekingHook.d.ts +12 -0
  102. package/dist/components/hooks/MediaSeekingHook.js +204 -0
  103. package/dist/components/hooks/PixiDisplayObjectHook.d.ts +15 -0
  104. package/dist/components/hooks/PixiDisplayObjectHook.js +77 -0
  105. package/dist/components/hooks/PixiGifHook.d.ts +15 -0
  106. package/dist/components/hooks/PixiGifHook.js +97 -0
  107. package/dist/components/hooks/PixiProgressShapeHook.d.ts +12 -0
  108. package/dist/components/hooks/PixiProgressShapeHook.js +128 -0
  109. package/dist/components/hooks/PixiSplitScreenDisplayObjectHook.d.ts +21 -0
  110. package/dist/components/hooks/PixiSplitScreenDisplayObjectHook.js +210 -0
  111. package/dist/components/hooks/PixiTextureHook.d.ts +7 -0
  112. package/dist/components/hooks/PixiTextureHook.js +29 -0
  113. package/dist/components/hooks/PixiVideoTextureHook.d.ts +10 -0
  114. package/dist/components/hooks/PixiVideoTextureHook.js +35 -0
  115. package/dist/components/hooks/SubtitlesHook.d.ts +88 -0
  116. package/dist/components/hooks/SubtitlesHook.js +199 -0
  117. package/dist/components/hooks/VerifyGifHook.d.ts +7 -0
  118. package/dist/components/hooks/VerifyGifHook.js +27 -0
  119. package/dist/components/hooks/VerifyImageHook.d.ts +7 -0
  120. package/dist/components/hooks/VerifyImageHook.js +27 -0
  121. package/dist/components/hooks/VerifyMediaHook.d.ts +7 -0
  122. package/dist/components/hooks/VerifyMediaHook.js +21 -0
  123. package/dist/components/hooks/shapes/progress/CustomProgressRenderer.d.ts +8 -0
  124. package/dist/components/hooks/shapes/progress/CustomProgressRenderer.js +53 -0
  125. package/dist/components/hooks/shapes/progress/DoubleProgressRenderer.d.ts +8 -0
  126. package/dist/components/hooks/shapes/progress/DoubleProgressRenderer.js +69 -0
  127. package/dist/components/hooks/shapes/progress/LinearProgressRenderer.d.ts +8 -0
  128. package/dist/components/hooks/shapes/progress/LinearProgressRenderer.js +60 -0
  129. package/dist/components/hooks/shapes/progress/PerimeterProgressRenderer.d.ts +9 -0
  130. package/dist/components/hooks/shapes/progress/PerimeterProgressRenderer.js +213 -0
  131. package/dist/components/hooks/shapes/progress/ProgressRenderer.d.ts +17 -0
  132. package/dist/components/hooks/shapes/progress/ProgressRenderer.js +75 -0
  133. package/dist/components/hooks/shapes/progress/RadialProgressRenderer.d.ts +8 -0
  134. package/dist/components/hooks/shapes/progress/RadialProgressRenderer.js +50 -0
  135. package/dist/components/hooks/shapes/progress/index.d.ts +6 -0
  136. package/dist/components/hooks/shapes/progress/index.js +6 -0
  137. package/dist/composers/componentComposer.d.ts +55 -0
  138. package/dist/composers/componentComposer.js +118 -0
  139. package/dist/composers/layerComposer.d.ts +46 -0
  140. package/dist/composers/layerComposer.js +79 -0
  141. package/dist/composers/sceneComposer.d.ts +48 -0
  142. package/dist/composers/sceneComposer.js +92 -0
  143. package/dist/constants.d.ts +12 -0
  144. package/dist/constants.js +14 -0
  145. package/dist/directors/ComponentDirector.d.ts +20 -0
  146. package/dist/directors/ComponentDirector.js +86 -0
  147. package/dist/factories/SceneBuilderFactory.d.ts +15 -0
  148. package/dist/factories/SceneBuilderFactory.js +51 -0
  149. package/dist/fonts/GoogleFontsProvider.d.ts +12 -0
  150. package/dist/fonts/GoogleFontsProvider.js +125 -0
  151. package/dist/fonts/fontLoader.d.ts +15 -0
  152. package/dist/fonts/fontLoader.js +41 -0
  153. package/dist/fonts/types.d.ts +1 -0
  154. package/dist/fonts/types.js +1 -0
  155. package/dist/index.d.ts +11 -0
  156. package/dist/index.js +14 -0
  157. package/dist/layers/Layer.svelte.d.ts +8492 -0
  158. package/dist/layers/Layer.svelte.js +125 -0
  159. package/dist/managers/AppManager.svelte.d.ts +23 -0
  160. package/dist/managers/AppManager.svelte.js +89 -0
  161. package/dist/managers/ComponentsManager.svelte.d.ts +49 -0
  162. package/dist/managers/ComponentsManager.svelte.js +247 -0
  163. package/dist/managers/DomManager.d.ts +18 -0
  164. package/dist/managers/DomManager.js +73 -0
  165. package/dist/managers/EventManager.d.ts +7 -0
  166. package/dist/managers/EventManager.js +22 -0
  167. package/dist/managers/LayersManager.svelte.d.ts +8499 -0
  168. package/dist/managers/LayersManager.svelte.js +176 -0
  169. package/dist/managers/MediaManager.d.ts +32 -0
  170. package/dist/managers/MediaManager.js +243 -0
  171. package/dist/managers/RenderManager.d.ts +23 -0
  172. package/dist/managers/RenderManager.js +59 -0
  173. package/dist/managers/StateManager.svelte.d.ts +8746 -0
  174. package/dist/managers/StateManager.svelte.js +272 -0
  175. package/dist/managers/SubtitlesManager.svelte.d.ts +261 -0
  176. package/dist/managers/SubtitlesManager.svelte.js +1385 -0
  177. package/dist/managers/TimeManager.svelte.d.ts +6 -0
  178. package/dist/managers/TimeManager.svelte.js +18 -0
  179. package/dist/managers/TimelineManager.svelte.d.ts +25 -0
  180. package/dist/managers/TimelineManager.svelte.js +152 -0
  181. package/dist/registers.d.ts +12 -0
  182. package/dist/registers.js +29 -0
  183. package/dist/schemas/runtime/index.d.ts +3 -0
  184. package/dist/schemas/runtime/index.js +4 -0
  185. package/dist/schemas/runtime/types.d.ts +323 -0
  186. package/dist/schemas/runtime/types.js +12 -0
  187. package/dist/schemas/scene/animations.d.ts +89738 -0
  188. package/dist/schemas/scene/animations.js +211 -0
  189. package/dist/schemas/scene/components.js +515 -0
  190. package/dist/schemas/scene/core.js +160 -0
  191. package/dist/schemas/scene/index.d.ts +22 -0
  192. package/dist/schemas/scene/index.js +10 -0
  193. package/dist/schemas/scene/properties.d.ts +914 -0
  194. package/dist/schemas/scene/properties.js +398 -0
  195. package/dist/schemas/scene/subtitles.d.ts +1141 -0
  196. package/dist/schemas/scene/subtitles.js +111 -0
  197. package/dist/schemas/scene/utils.d.ts +1 -0
  198. package/dist/schemas/scene/utils.js +5 -0
  199. package/dist/seeds/SeedFactory.d.ts +59 -0
  200. package/dist/seeds/SeedFactory.js +99 -0
  201. package/dist/seeds/index.d.ts +8 -0
  202. package/dist/seeds/index.js +8 -0
  203. package/dist/transformers/ColorTransformer.d.ts +5 -0
  204. package/dist/transformers/ColorTransformer.js +67 -0
  205. package/dist/transformers/PixiColorTransformer.d.ts +22 -0
  206. package/dist/transformers/PixiColorTransformer.js +104 -0
  207. package/dist/utils/canvas.d.ts +6 -0
  208. package/dist/utils/canvas.js +18 -0
  209. package/dist/utils/document.d.ts +2 -0
  210. package/dist/utils/document.js +36 -0
  211. package/dist/utils/emoji.d.ts +10 -0
  212. package/dist/utils/emoji.js +51 -0
  213. package/dist/utils/html.d.ts +4 -0
  214. package/dist/utils/html.js +45 -0
  215. package/dist/utils/svgGenerator.d.ts +20 -0
  216. package/dist/utils/svgGenerator.js +103 -0
  217. package/dist/utils/utils.d.ts +5 -0
  218. package/dist/utils/utils.js +125 -0
  219. package/package.json +96 -0
@@ -0,0 +1,21 @@
1
+ import { VideoComponentShape } from '../..';
2
+ export class VerifyMediaHook {
3
+ types = ['setup', 'refresh'];
4
+ priority = 1;
5
+ #context;
6
+ async #handleSetup() {
7
+ const data = VideoComponentShape.safeParse(this.#context.contextData);
8
+ if (!data.success) {
9
+ console.error('Video Compoponent verify failed: ' + data.error.message);
10
+ this.#context.disabled = true;
11
+ return;
12
+ }
13
+ this.#context.setResource('mediaShape', data.data);
14
+ }
15
+ async handle(type, context) {
16
+ this.#context = context;
17
+ if (type === 'setup' || type === 'refresh') {
18
+ return await this.#handleSetup();
19
+ }
20
+ }
21
+ }
@@ -0,0 +1,8 @@
1
+ import type { IComponentContext } from '../../../..';
2
+ import type { CustomProgressConfig } from '../../../..';
3
+ import { ProgressRenderer } from './ProgressRenderer.js';
4
+ export declare class CustomProgressRenderer extends ProgressRenderer {
5
+ private config;
6
+ constructor(context: IComponentContext, width: number, height: number, config: CustomProgressConfig);
7
+ update(progress: number): void;
8
+ }
@@ -0,0 +1,53 @@
1
+ import * as PIXI from 'pixi.js-legacy';
2
+ import { ProgressRenderer } from './ProgressRenderer.js';
3
+ export class CustomProgressRenderer extends ProgressRenderer {
4
+ config;
5
+ constructor(context, width, height, config) {
6
+ super(context, width, height);
7
+ this.config = config;
8
+ }
9
+ update(progress) {
10
+ // Use original dimensions, not the scaled display object dimensions
11
+ const displayWidth = this.width;
12
+ const displayHeight = this.height;
13
+ // Progress bars only support solid colors - graphics drawing
14
+ const graphics = this.displayObject;
15
+ graphics.clear();
16
+ const color = this.getSolidColor();
17
+ const strokeWidth = this.config.strokeWidth || 4;
18
+ // For custom progress, we'll create a simple implementation
19
+ // that draws a path-based progress indicator
20
+ // In a full implementation, you'd parse the SVG path data
21
+ // and create a custom progress visualization
22
+ graphics.lineStyle({
23
+ width: strokeWidth,
24
+ color: color,
25
+ cap: this.config.capStyle === 'butt'
26
+ ? PIXI.LINE_CAP.BUTT
27
+ : this.config.capStyle === 'square'
28
+ ? PIXI.LINE_CAP.SQUARE
29
+ : PIXI.LINE_CAP.ROUND
30
+ });
31
+ // Simple implementation: draw a custom shape that fills based on progress
32
+ // This is a placeholder - in practice you'd parse the pathData
33
+ const centerX = displayWidth / 2;
34
+ const centerY = displayHeight / 2;
35
+ const radius = Math.min(displayWidth, displayHeight) / 4;
36
+ // Draw a custom progress indicator
37
+ // For now, we'll draw a star-like shape that fills based on progress
38
+ const points = 5;
39
+ const outerRadius = radius * 2;
40
+ const innerRadius = radius;
41
+ graphics.beginFill(color);
42
+ graphics.moveTo(centerX, centerY - outerRadius * progress);
43
+ for (let i = 0; i < points * 2; i++) {
44
+ const angle = (Math.PI * i) / points - Math.PI / 2;
45
+ const currentRadius = i % 2 === 0 ? outerRadius * progress : innerRadius * progress;
46
+ const x = centerX + Math.cos(angle) * currentRadius;
47
+ const y = centerY + Math.sin(angle) * currentRadius;
48
+ graphics.lineTo(x, y);
49
+ }
50
+ graphics.closePath();
51
+ graphics.endFill();
52
+ }
53
+ }
@@ -0,0 +1,8 @@
1
+ import type { IComponentContext } from '../../../..';
2
+ import type { DoubleProgressConfig } from '../../../..';
3
+ import { ProgressRenderer } from './ProgressRenderer.js';
4
+ export declare class DoubleProgressRenderer extends ProgressRenderer {
5
+ private config;
6
+ constructor(context: IComponentContext, width: number, height: number, config: DoubleProgressConfig);
7
+ update(progress: number): void;
8
+ }
@@ -0,0 +1,69 @@
1
+ import * as PIXI from 'pixi.js-legacy';
2
+ import { ProgressRenderer } from './ProgressRenderer.js';
3
+ export class DoubleProgressRenderer extends ProgressRenderer {
4
+ config;
5
+ constructor(context, width, height, config) {
6
+ super(context, width, height);
7
+ this.config = config;
8
+ }
9
+ update(progress) {
10
+ // Use original dimensions, not the scaled display object dimensions
11
+ const displayWidth = this.width;
12
+ const displayHeight = this.height;
13
+ // Progress bars only support solid colors - graphics drawing
14
+ const graphics = this.displayObject;
15
+ graphics.clear();
16
+ const color = this.getSolidColor();
17
+ const strokeWidth = 4; // Default stroke width for double progress
18
+ graphics.lineStyle({
19
+ width: strokeWidth,
20
+ color: color,
21
+ cap: PIXI.LINE_CAP.ROUND
22
+ });
23
+ // Draw each progress path
24
+ this.config.paths.forEach((path) => {
25
+ const pathProgress = progress; // Could be different for each path in the future
26
+ const offset = path.offset || 0;
27
+ let startX = 0, startY = 0, endX = 0, endY = 0;
28
+ // Calculate path coordinates based on position
29
+ switch (path.position) {
30
+ case 'top':
31
+ startX = 0;
32
+ startY = offset;
33
+ endX = displayWidth;
34
+ endY = offset;
35
+ break;
36
+ case 'bottom':
37
+ startX = 0;
38
+ startY = displayHeight - offset;
39
+ endX = displayWidth;
40
+ endY = displayHeight - offset;
41
+ break;
42
+ case 'left':
43
+ startX = offset;
44
+ startY = 0;
45
+ endX = offset;
46
+ endY = displayHeight;
47
+ break;
48
+ case 'right':
49
+ startX = displayWidth - offset;
50
+ startY = 0;
51
+ endX = displayWidth - offset;
52
+ endY = displayHeight;
53
+ break;
54
+ }
55
+ // Apply reverse if needed
56
+ if (path.reverse) {
57
+ [startX, startY, endX, endY] = [endX, endY, startX, startY];
58
+ }
59
+ // Calculate progress point
60
+ const progressDistance = pathProgress * Math.sqrt(Math.pow(endX - startX, 2) + Math.pow(endY - startY, 2));
61
+ const ratio = progressDistance / Math.sqrt(Math.pow(endX - startX, 2) + Math.pow(endY - startY, 2));
62
+ const progressX = startX + (endX - startX) * ratio;
63
+ const progressY = startY + (endY - startY) * ratio;
64
+ // Draw the progress line
65
+ graphics.moveTo(startX, startY);
66
+ graphics.lineTo(progressX, progressY);
67
+ });
68
+ }
69
+ }
@@ -0,0 +1,8 @@
1
+ import type { IComponentContext } from '../../../..';
2
+ import type { LinearProgressConfig } from '../../../..';
3
+ import { ProgressRenderer } from './ProgressRenderer.js';
4
+ export declare class LinearProgressRenderer extends ProgressRenderer {
5
+ private config;
6
+ constructor(context: IComponentContext, width: number, height: number, config: LinearProgressConfig);
7
+ update(progress: number): void;
8
+ }
@@ -0,0 +1,60 @@
1
+ import * as PIXI from 'pixi.js-legacy';
2
+ import { ProgressRenderer } from './ProgressRenderer.js';
3
+ export class LinearProgressRenderer extends ProgressRenderer {
4
+ config;
5
+ constructor(context, width, height, config) {
6
+ super(context, width, height);
7
+ this.config = config;
8
+ }
9
+ update(progress) {
10
+ const amount = this.config.reverse ? 1 - progress : progress;
11
+ // current dimensions after placement
12
+ const displayWidth = this.width;
13
+ const displayHeight = this.height;
14
+ const color = this.getSolidColor();
15
+ // solid color graphics
16
+ const graphics = this.displayObject;
17
+ graphics.clear();
18
+ // fix for legacy pixi renderer - without this it does not work as expected!!! this sets the right boundaries for rects to work
19
+ // graphics.beginFill(color);
20
+ graphics.beginFill(0x00000001, 0.0000000001);
21
+ graphics.drawRect(0, 0, displayWidth, displayHeight);
22
+ graphics.endFill();
23
+ const originalX = graphics.x;
24
+ const originalY = graphics.y;
25
+ let x = 0, y = 0, w = 0, h = 0;
26
+ if (this.config.direction === 'horizontal') {
27
+ w = displayWidth * amount;
28
+ h = displayHeight;
29
+ switch (this.config.anchor) {
30
+ case 'center':
31
+ x = originalX + (displayWidth - w) / 2;
32
+ break;
33
+ case 'end':
34
+ x = originalX + displayWidth - w;
35
+ break;
36
+ default:
37
+ x = originalX;
38
+ }
39
+ y = originalY;
40
+ }
41
+ else {
42
+ w = displayWidth;
43
+ h = displayHeight * amount;
44
+ switch (this.config.anchor) {
45
+ case 'center':
46
+ y = originalY + (displayHeight - h) / 2;
47
+ break;
48
+ case 'end':
49
+ y = originalY + displayHeight - h;
50
+ break;
51
+ default:
52
+ y = originalY;
53
+ }
54
+ x = originalX;
55
+ }
56
+ if (w > 0 && h > 0) {
57
+ graphics.beginFill(color).drawRect(0, 0, w, h).endFill();
58
+ }
59
+ }
60
+ }
@@ -0,0 +1,9 @@
1
+ import type { IComponentContext } from '../../../..';
2
+ import type { PerimeterProgressConfig } from '../../../..';
3
+ import { ProgressRenderer } from './ProgressRenderer.js';
4
+ export declare class PerimeterProgressRenderer extends ProgressRenderer {
5
+ private config;
6
+ constructor(context: IComponentContext, width: number, height: number, config: PerimeterProgressConfig);
7
+ update(progress: number): void;
8
+ private getRectanglesForStartCorner;
9
+ }
@@ -0,0 +1,213 @@
1
+ import * as PIXI from 'pixi.js-legacy';
2
+ import { ProgressRenderer } from './ProgressRenderer.js';
3
+ export class PerimeterProgressRenderer extends ProgressRenderer {
4
+ config;
5
+ constructor(context, width, height, config) {
6
+ super(context, width, height);
7
+ this.config = config;
8
+ }
9
+ update(progress) {
10
+ const displayWidth = this.width;
11
+ const displayHeight = this.height;
12
+ const graphics = this.displayObject;
13
+ // fix for legacy pixi renderer - without this it does not work as expected!!! this sets the right boundaries for rects to work
14
+ // graphics.clear();
15
+ // graphics.beginFill(0x00000001, 0.0000000001);
16
+ // graphics.drawRect(0, 0, displayWidth, displayHeight);
17
+ // graphics.endFill();
18
+ const strokeWidth = this.config.strokeWidth || 4;
19
+ const clockwise = this.config.clockwise !== false;
20
+ const startCorner = this.config.startCorner || 'top-left';
21
+ const color = this.getSolidColor();
22
+ const perimeter = 2 * (displayWidth + displayHeight);
23
+ let remainingDistance = progress * perimeter;
24
+ const rectangles = this.getRectanglesForStartCorner(startCorner, displayWidth, displayHeight, strokeWidth, clockwise);
25
+ let drawnLength = 0;
26
+ for (const rect of rectangles) {
27
+ if (remainingDistance <= 0)
28
+ break;
29
+ const edgeLength = rect.length;
30
+ const isPartial = remainingDistance < edgeLength;
31
+ if (isPartial) {
32
+ const ratio = remainingDistance / edgeLength;
33
+ graphics.beginFill(color);
34
+ if (rect.isHorizontal) {
35
+ const partialWidth = rect.width * ratio;
36
+ if (rect.reverse) {
37
+ const startX = rect.x + rect.width - partialWidth;
38
+ graphics.drawRect(startX, rect.y, partialWidth, rect.height);
39
+ }
40
+ else {
41
+ graphics.drawRect(rect.x, rect.y, partialWidth, rect.height);
42
+ }
43
+ }
44
+ else {
45
+ // Vertical
46
+ const partialHeight = rect.height * ratio;
47
+ if (rect.reverse) {
48
+ const startY = rect.y + rect.height - partialHeight;
49
+ graphics.drawRect(rect.x, startY, rect.width, partialHeight);
50
+ }
51
+ else {
52
+ graphics.drawRect(rect.x, rect.y, rect.width, partialHeight);
53
+ }
54
+ }
55
+ graphics.endFill();
56
+ remainingDistance = 0;
57
+ }
58
+ else {
59
+ graphics.beginFill(color);
60
+ graphics.drawRect(rect.x, rect.y, rect.width, rect.height);
61
+ graphics.endFill();
62
+ remainingDistance -= edgeLength;
63
+ }
64
+ drawnLength += edgeLength;
65
+ }
66
+ }
67
+ getRectanglesForStartCorner(startCorner, width, height, strokeWidth, clockwise) {
68
+ // Define 4 rectangles, one for each edge
69
+ const allRectangles = {
70
+ // Top rectangle (left to right)
71
+ topLR: {
72
+ x: 0,
73
+ y: 0,
74
+ width: width,
75
+ height: strokeWidth,
76
+ length: width,
77
+ isHorizontal: true,
78
+ reverse: false
79
+ },
80
+ // Top rectangle (right to left)
81
+ topRL: {
82
+ x: 0,
83
+ y: 0,
84
+ width: width,
85
+ height: strokeWidth,
86
+ length: width,
87
+ isHorizontal: true,
88
+ reverse: true
89
+ },
90
+ // Right rectangle (top to bottom)
91
+ rightTB: {
92
+ x: width - strokeWidth,
93
+ y: 0,
94
+ width: strokeWidth,
95
+ height: height,
96
+ length: height,
97
+ isHorizontal: false,
98
+ reverse: false
99
+ },
100
+ // Right rectangle (bottom to top)
101
+ rightBT: {
102
+ x: width - strokeWidth,
103
+ y: 0,
104
+ width: strokeWidth,
105
+ height: height,
106
+ length: height,
107
+ isHorizontal: false,
108
+ reverse: true
109
+ },
110
+ // Bottom rectangle (right to left)
111
+ bottomRL: {
112
+ x: 0,
113
+ y: height - strokeWidth,
114
+ width: width,
115
+ height: strokeWidth,
116
+ length: width,
117
+ isHorizontal: true,
118
+ reverse: true
119
+ },
120
+ // Bottom rectangle (left to right)
121
+ bottomLR: {
122
+ x: 0,
123
+ y: height - strokeWidth,
124
+ width: width,
125
+ height: strokeWidth,
126
+ length: width,
127
+ isHorizontal: true,
128
+ reverse: false
129
+ },
130
+ // Left rectangle (bottom to top)
131
+ leftBT: {
132
+ x: 0,
133
+ y: 0,
134
+ width: strokeWidth,
135
+ height: height,
136
+ length: height,
137
+ isHorizontal: false,
138
+ reverse: true
139
+ },
140
+ // Left rectangle (top to bottom)
141
+ leftTB: {
142
+ x: 0,
143
+ y: 0,
144
+ width: strokeWidth,
145
+ height: height,
146
+ length: height,
147
+ isHorizontal: false,
148
+ reverse: false
149
+ }
150
+ };
151
+ // Define rectangle sequences for each starting corner and direction
152
+ const rectangleSequences = {
153
+ 'top-left': {
154
+ clockwise: [
155
+ allRectangles.topLR,
156
+ allRectangles.rightTB,
157
+ allRectangles.bottomRL,
158
+ allRectangles.leftBT
159
+ ],
160
+ counterclockwise: [
161
+ allRectangles.leftTB,
162
+ allRectangles.bottomLR,
163
+ allRectangles.rightBT,
164
+ allRectangles.topRL
165
+ ]
166
+ },
167
+ 'top-right': {
168
+ clockwise: [
169
+ allRectangles.rightTB,
170
+ allRectangles.bottomRL,
171
+ allRectangles.leftBT,
172
+ allRectangles.topLR
173
+ ],
174
+ counterclockwise: [
175
+ allRectangles.topRL,
176
+ allRectangles.leftTB,
177
+ allRectangles.bottomLR,
178
+ allRectangles.rightBT
179
+ ]
180
+ },
181
+ 'bottom-right': {
182
+ clockwise: [
183
+ allRectangles.bottomRL,
184
+ allRectangles.leftBT,
185
+ allRectangles.topLR,
186
+ allRectangles.rightTB
187
+ ],
188
+ counterclockwise: [
189
+ allRectangles.rightBT,
190
+ allRectangles.topRL,
191
+ allRectangles.leftTB,
192
+ allRectangles.bottomLR
193
+ ]
194
+ },
195
+ 'bottom-left': {
196
+ clockwise: [
197
+ allRectangles.leftBT,
198
+ allRectangles.topLR,
199
+ allRectangles.rightTB,
200
+ allRectangles.bottomRL
201
+ ],
202
+ counterclockwise: [
203
+ allRectangles.bottomLR,
204
+ allRectangles.rightBT,
205
+ allRectangles.topRL,
206
+ allRectangles.leftTB
207
+ ]
208
+ }
209
+ };
210
+ const direction = clockwise ? 'clockwise' : 'counterclockwise';
211
+ return rectangleSequences[startCorner][direction];
212
+ }
213
+ }
@@ -0,0 +1,17 @@
1
+ import * as PIXI from 'pixi.js-legacy';
2
+ import type { IComponentContext } from '../../../..';
3
+ /**
4
+ * Base class for progress renderers
5
+ */
6
+ export declare abstract class ProgressRenderer {
7
+ #private;
8
+ protected context: IComponentContext;
9
+ protected displayObject: PIXI.Container;
10
+ protected width: number;
11
+ protected height: number;
12
+ protected isGradient: boolean;
13
+ constructor(context: IComponentContext, width: number, height: number);
14
+ protected getSolidColor(): string | 0 | undefined;
15
+ abstract update(progress: number): void;
16
+ getDisplayObject(): PIXI.Container;
17
+ }
@@ -0,0 +1,75 @@
1
+ import * as PIXI from 'pixi.js-legacy';
2
+ import { PixiColorTransformer } from '../../../../transformers/PixiColorTransformer.js';
3
+ /**
4
+ * Base class for progress renderers
5
+ */
6
+ export class ProgressRenderer {
7
+ context;
8
+ displayObject;
9
+ width;
10
+ height;
11
+ isGradient;
12
+ constructor(context, width, height) {
13
+ this.context = context;
14
+ this.width = width;
15
+ this.height = height;
16
+ this.isGradient = this.#checkIsGradient();
17
+ this.displayObject = this.#createDisplayObject();
18
+ }
19
+ #checkIsGradient() {
20
+ const background = this.context.data.appearance.background;
21
+ const isGradient = PixiColorTransformer.isGradient(background);
22
+ // For now, progress bars don't support gradients - fallback to solid color
23
+ if (isGradient) {
24
+ console.warn('Progress bars currently only support solid colors. Using fallback color.');
25
+ return false;
26
+ }
27
+ return isGradient;
28
+ }
29
+ #createDisplayObject() {
30
+ // TODO - implement always active background
31
+ // const background = (this.context.data as ShapeComponent).appearance.background;
32
+ // For progress bars, always use Graphics (solid colors only)
33
+ const graphics = new PIXI.Graphics();
34
+ // // Get solid color - if gradient is passed, extract first color as fallback
35
+ // if (PixiColorTransformer.isGradient(background)) {
36
+ // // Extract first color from gradient as fallback
37
+ // if (
38
+ // typeof background === 'object' &&
39
+ // background &&
40
+ // 'stops' in background &&
41
+ // background.stops &&
42
+ // background.stops.length > 0
43
+ // ) {
44
+ // const firstStop = background.stops[0];
45
+ // if (firstStop && 'color' in firstStop) {
46
+ // const colorResult = PixiColorTransformer.transform(
47
+ // firstStop.color,
48
+ // this.width,
49
+ // this.height
50
+ // );
51
+ // color = colorResult.color || 0x000000;
52
+ // }
53
+ // }
54
+ // } else {
55
+ // // Use solid color normally
56
+ // const colorResult = PixiColorTransformer.transform(background, this.width, this.height);
57
+ // color = colorResult.color || 0x000000;
58
+ // }
59
+ graphics.beginFill(0x00000001, 0.0000000001);
60
+ graphics.drawRect(0, 0, this.width, this.height);
61
+ return graphics;
62
+ }
63
+ getSolidColor() {
64
+ const defaulColor = 0x000000;
65
+ const background = this.context.data.appearance.color;
66
+ if (PixiColorTransformer.isGradient(background)) {
67
+ console.warn('Progress bars currently only support solid colors. Using fallback color.');
68
+ return defaulColor;
69
+ }
70
+ return background;
71
+ }
72
+ getDisplayObject() {
73
+ return this.displayObject;
74
+ }
75
+ }
@@ -0,0 +1,8 @@
1
+ import type { IComponentContext } from '../../../..';
2
+ import type { RadialProgressConfig } from '../../../..';
3
+ import { ProgressRenderer } from './ProgressRenderer.js';
4
+ export declare class RadialProgressRenderer extends ProgressRenderer {
5
+ private config;
6
+ constructor(context: IComponentContext, width: number, height: number, config: RadialProgressConfig);
7
+ update(progress: number): void;
8
+ }
@@ -0,0 +1,50 @@
1
+ import * as PIXI from 'pixi.js-legacy';
2
+ import { ProgressRenderer } from './ProgressRenderer.js';
3
+ export class RadialProgressRenderer extends ProgressRenderer {
4
+ config;
5
+ constructor(context, width, height, config) {
6
+ super(context, width, height);
7
+ this.config = config;
8
+ }
9
+ update(progress) {
10
+ // Use original dimensions, not the scaled display object dimensions
11
+ const displayWidth = this.width;
12
+ const displayHeight = this.height;
13
+ // Progress bars only support solid colors - graphics drawing
14
+ const graphics = this.displayObject;
15
+ graphics.clear();
16
+ const centerX = displayWidth / 2;
17
+ const centerY = displayHeight / 2;
18
+ const radius = Math.min(displayWidth, displayHeight) / 2;
19
+ const innerRadius = (this.config.innerRadius || 0) * radius;
20
+ const strokeWidth = this.config.strokeWidth || 4;
21
+ // Convert start angle from degrees to radians
22
+ const startAngleRad = ((this.config.startAngle || -90) * Math.PI) / 180;
23
+ const clockwise = this.config.clockwise !== false; // default to true
24
+ // Calculate the end angle based on progress
25
+ const angleRange = 2 * Math.PI; // Full circle
26
+ const endAngleRad = startAngleRad + (clockwise ? progress : -progress) * angleRange;
27
+ const color = this.getSolidColor();
28
+ if (innerRadius > 0) {
29
+ // Ring style - draw arc
30
+ graphics.lineStyle({
31
+ width: strokeWidth,
32
+ color: color,
33
+ cap: this.config.capStyle === 'butt'
34
+ ? PIXI.LINE_CAP.BUTT
35
+ : this.config.capStyle === 'square'
36
+ ? PIXI.LINE_CAP.SQUARE
37
+ : PIXI.LINE_CAP.ROUND
38
+ });
39
+ graphics.arc(centerX, centerY, radius, startAngleRad, endAngleRad, !clockwise);
40
+ }
41
+ else {
42
+ // Filled circle style - draw pie slice
43
+ graphics.beginFill(color);
44
+ graphics.moveTo(centerX, centerY);
45
+ graphics.arc(centerX, centerY, radius, startAngleRad, endAngleRad, !clockwise);
46
+ graphics.lineTo(centerX, centerY);
47
+ graphics.endFill();
48
+ }
49
+ }
50
+ }
@@ -0,0 +1,6 @@
1
+ export { ProgressRenderer } from './ProgressRenderer.js';
2
+ export { LinearProgressRenderer } from './LinearProgressRenderer.js';
3
+ export { RadialProgressRenderer } from './RadialProgressRenderer.js';
4
+ export { PerimeterProgressRenderer } from './PerimeterProgressRenderer.js';
5
+ export { DoubleProgressRenderer } from './DoubleProgressRenderer.js';
6
+ export { CustomProgressRenderer } from './CustomProgressRenderer.js';
@@ -0,0 +1,6 @@
1
+ export { ProgressRenderer } from './ProgressRenderer.js';
2
+ export { LinearProgressRenderer } from './LinearProgressRenderer.js';
3
+ export { RadialProgressRenderer } from './RadialProgressRenderer.js';
4
+ export { PerimeterProgressRenderer } from './PerimeterProgressRenderer.js';
5
+ export { DoubleProgressRenderer } from './DoubleProgressRenderer.js';
6
+ export { CustomProgressRenderer } from './CustomProgressRenderer.js';