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.
- package/LICENSE +21 -0
- package/README.md +213 -0
- package/dist/DIContainer.d.ts +4 -0
- package/dist/DIContainer.js +145 -0
- package/dist/SceneBuilder.svelte.d.ts +8574 -0
- package/dist/SceneBuilder.svelte.js +409 -0
- package/dist/adapters/subtitleHelpers.d.ts +2 -0
- package/dist/adapters/subtitleHelpers.js +187 -0
- package/dist/animations/AnimationContext.d.ts +17 -0
- package/dist/animations/AnimationContext.js +72 -0
- package/dist/animations/AnimationPresetsRegister.d.ts +362 -0
- package/dist/animations/AnimationPresetsRegister.js +20 -0
- package/dist/animations/AnimationSetup.d.ts +8 -0
- package/dist/animations/AnimationSetup.js +30 -0
- package/dist/animations/SplitTextCache.d.ts +28 -0
- package/dist/animations/SplitTextCache.js +68 -0
- package/dist/animations/animationBuilder.d.ts +31 -0
- package/dist/animations/animationBuilder.js +255 -0
- package/dist/animations/animationPreset.d.ts +7 -0
- package/dist/animations/animationPreset.js +31 -0
- package/dist/animations/builders/AnimationPresetFactory.d.ts +43 -0
- package/dist/animations/builders/AnimationPresetFactory.js +139 -0
- package/dist/animations/builders/LineHighlighterAnimationBuilder.d.ts +16 -0
- package/dist/animations/builders/LineHighlighterAnimationBuilder.js +183 -0
- package/dist/animations/builders/WordHighlighterAnimationBuilder.d.ts +15 -0
- package/dist/animations/builders/WordHighlighterAnimationBuilder.js +180 -0
- package/dist/animations/engines/AnimationEngineAdaptor.d.ts +107 -0
- package/dist/animations/engines/AnimationEngineAdaptor.js +1 -0
- package/dist/animations/engines/GSAPEngineAdaptor.d.ts +21 -0
- package/dist/animations/engines/GSAPEngineAdaptor.js +145 -0
- package/dist/animations/presets/index.d.ts +2 -0
- package/dist/animations/presets/index.js +3 -0
- package/dist/animations/presets/lines.d.ts +52 -0
- package/dist/animations/presets/lines.js +547 -0
- package/dist/animations/presets/words.d.ts +31 -0
- package/dist/animations/presets/words.js +268 -0
- package/dist/animations/transformers/AnimationReferenceTransformer.d.ts +9 -0
- package/dist/animations/transformers/AnimationReferenceTransformer.js +114 -0
- package/dist/builders/PixiComponentBuilder.d.ts +63 -0
- package/dist/builders/PixiComponentBuilder.js +112 -0
- package/dist/builders/_ComponentState.svelte.d.ts +795 -0
- package/dist/builders/_ComponentState.svelte.js +203 -0
- package/dist/builders/html/HtmlBuilder.d.ts +66 -0
- package/dist/builders/html/HtmlBuilder.js +171 -0
- package/dist/builders/html/HtmlBuilderFactory.d.ts +27 -0
- package/dist/builders/html/HtmlBuilderFactory.js +30 -0
- package/dist/builders/html/StyleBuilder.d.ts +13 -0
- package/dist/builders/html/StyleBuilder.js +133 -0
- package/dist/builders/html/StyleProcessor.d.ts +9 -0
- package/dist/builders/html/StyleProcessor.js +1 -0
- package/dist/builders/html/TextComponentHtmlBuilder.d.ts +16 -0
- package/dist/builders/html/TextComponentHtmlBuilder.js +93 -0
- package/dist/builders/html/TextShadowBuilder.d.ts +60 -0
- package/dist/builders/html/TextShadowBuilder.js +227 -0
- package/dist/builders/html/processors/AppearanceStyleProcessor.d.ts +5 -0
- package/dist/builders/html/processors/AppearanceStyleProcessor.js +57 -0
- package/dist/builders/html/processors/TextAppearanceStyleProcessor.d.ts +5 -0
- package/dist/builders/html/processors/TextAppearanceStyleProcessor.js +37 -0
- package/dist/builders/html/processors/TextEffectsStyleProcessor.d.ts +6 -0
- package/dist/builders/html/processors/TextEffectsStyleProcessor.js +68 -0
- package/dist/commands/Command.d.ts +6 -0
- package/dist/commands/Command.js +1 -0
- package/dist/commands/CommandRunner.d.ts +28 -0
- package/dist/commands/CommandRunner.js +81 -0
- package/dist/commands/CommandTypes.d.ts +11 -0
- package/dist/commands/CommandTypes.js +13 -0
- package/dist/commands/PauseCommand.d.ts +4 -0
- package/dist/commands/PauseCommand.js +5 -0
- package/dist/commands/PlayCommand.d.ts +4 -0
- package/dist/commands/PlayCommand.js +6 -0
- package/dist/commands/RenderCommand.d.ts +15 -0
- package/dist/commands/RenderCommand.js +18 -0
- package/dist/commands/RenderFrameCommand.d.ts +17 -0
- package/dist/commands/RenderFrameCommand.js +93 -0
- package/dist/commands/ReplaceSourceOnTimeCommand.d.ts +4 -0
- package/dist/commands/ReplaceSourceOnTimeCommand.js +22 -0
- package/dist/commands/SeekCommand.d.ts +15 -0
- package/dist/commands/SeekCommand.js +39 -0
- package/dist/commands/UpdateComponentCommand.d.ts +4 -0
- package/dist/commands/UpdateComponentCommand.js +17 -0
- package/dist/components/AnimatedGIF.d.ts +201 -0
- package/dist/components/AnimatedGIF.js +391 -0
- package/dist/components/Component.svelte.d.ts +33 -0
- package/dist/components/Component.svelte.js +152 -0
- package/dist/components/ComponentContext.svelte.d.ts +33 -0
- package/dist/components/ComponentContext.svelte.js +105 -0
- package/dist/components/hooks/AnimationHook.d.ts +25 -0
- package/dist/components/hooks/AnimationHook.js +180 -0
- package/dist/components/hooks/CanvasShapeHook.d.ts +12 -0
- package/dist/components/hooks/CanvasShapeHook.js +229 -0
- package/dist/components/hooks/HtmlAnimationHook.d.ts +8 -0
- package/dist/components/hooks/HtmlAnimationHook.js +70 -0
- package/dist/components/hooks/HtmlTextHook.d.ts +16 -0
- package/dist/components/hooks/HtmlTextHook.js +102 -0
- package/dist/components/hooks/HtmlToCanvasHook.d.ts +16 -0
- package/dist/components/hooks/HtmlToCanvasHook.js +148 -0
- package/dist/components/hooks/ImageHook.d.ts +10 -0
- package/dist/components/hooks/ImageHook.js +45 -0
- package/dist/components/hooks/MediaHook.d.ts +15 -0
- package/dist/components/hooks/MediaHook.js +252 -0
- package/dist/components/hooks/MediaSeekingHook.d.ts +12 -0
- package/dist/components/hooks/MediaSeekingHook.js +204 -0
- package/dist/components/hooks/PixiDisplayObjectHook.d.ts +15 -0
- package/dist/components/hooks/PixiDisplayObjectHook.js +77 -0
- package/dist/components/hooks/PixiGifHook.d.ts +15 -0
- package/dist/components/hooks/PixiGifHook.js +97 -0
- package/dist/components/hooks/PixiProgressShapeHook.d.ts +12 -0
- package/dist/components/hooks/PixiProgressShapeHook.js +128 -0
- package/dist/components/hooks/PixiSplitScreenDisplayObjectHook.d.ts +21 -0
- package/dist/components/hooks/PixiSplitScreenDisplayObjectHook.js +210 -0
- package/dist/components/hooks/PixiTextureHook.d.ts +7 -0
- package/dist/components/hooks/PixiTextureHook.js +29 -0
- package/dist/components/hooks/PixiVideoTextureHook.d.ts +10 -0
- package/dist/components/hooks/PixiVideoTextureHook.js +35 -0
- package/dist/components/hooks/SubtitlesHook.d.ts +88 -0
- package/dist/components/hooks/SubtitlesHook.js +199 -0
- package/dist/components/hooks/VerifyGifHook.d.ts +7 -0
- package/dist/components/hooks/VerifyGifHook.js +27 -0
- package/dist/components/hooks/VerifyImageHook.d.ts +7 -0
- package/dist/components/hooks/VerifyImageHook.js +27 -0
- package/dist/components/hooks/VerifyMediaHook.d.ts +7 -0
- package/dist/components/hooks/VerifyMediaHook.js +21 -0
- package/dist/components/hooks/shapes/progress/CustomProgressRenderer.d.ts +8 -0
- package/dist/components/hooks/shapes/progress/CustomProgressRenderer.js +53 -0
- package/dist/components/hooks/shapes/progress/DoubleProgressRenderer.d.ts +8 -0
- package/dist/components/hooks/shapes/progress/DoubleProgressRenderer.js +69 -0
- package/dist/components/hooks/shapes/progress/LinearProgressRenderer.d.ts +8 -0
- package/dist/components/hooks/shapes/progress/LinearProgressRenderer.js +60 -0
- package/dist/components/hooks/shapes/progress/PerimeterProgressRenderer.d.ts +9 -0
- package/dist/components/hooks/shapes/progress/PerimeterProgressRenderer.js +213 -0
- package/dist/components/hooks/shapes/progress/ProgressRenderer.d.ts +17 -0
- package/dist/components/hooks/shapes/progress/ProgressRenderer.js +75 -0
- package/dist/components/hooks/shapes/progress/RadialProgressRenderer.d.ts +8 -0
- package/dist/components/hooks/shapes/progress/RadialProgressRenderer.js +50 -0
- package/dist/components/hooks/shapes/progress/index.d.ts +6 -0
- package/dist/components/hooks/shapes/progress/index.js +6 -0
- package/dist/composers/componentComposer.d.ts +55 -0
- package/dist/composers/componentComposer.js +118 -0
- package/dist/composers/layerComposer.d.ts +46 -0
- package/dist/composers/layerComposer.js +79 -0
- package/dist/composers/sceneComposer.d.ts +48 -0
- package/dist/composers/sceneComposer.js +92 -0
- package/dist/constants.d.ts +12 -0
- package/dist/constants.js +14 -0
- package/dist/directors/ComponentDirector.d.ts +20 -0
- package/dist/directors/ComponentDirector.js +86 -0
- package/dist/factories/SceneBuilderFactory.d.ts +15 -0
- package/dist/factories/SceneBuilderFactory.js +51 -0
- package/dist/fonts/GoogleFontsProvider.d.ts +12 -0
- package/dist/fonts/GoogleFontsProvider.js +125 -0
- package/dist/fonts/fontLoader.d.ts +15 -0
- package/dist/fonts/fontLoader.js +41 -0
- package/dist/fonts/types.d.ts +1 -0
- package/dist/fonts/types.js +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +14 -0
- package/dist/layers/Layer.svelte.d.ts +8492 -0
- package/dist/layers/Layer.svelte.js +125 -0
- package/dist/managers/AppManager.svelte.d.ts +23 -0
- package/dist/managers/AppManager.svelte.js +89 -0
- package/dist/managers/ComponentsManager.svelte.d.ts +49 -0
- package/dist/managers/ComponentsManager.svelte.js +247 -0
- package/dist/managers/DomManager.d.ts +18 -0
- package/dist/managers/DomManager.js +73 -0
- package/dist/managers/EventManager.d.ts +7 -0
- package/dist/managers/EventManager.js +22 -0
- package/dist/managers/LayersManager.svelte.d.ts +8499 -0
- package/dist/managers/LayersManager.svelte.js +176 -0
- package/dist/managers/MediaManager.d.ts +32 -0
- package/dist/managers/MediaManager.js +243 -0
- package/dist/managers/RenderManager.d.ts +23 -0
- package/dist/managers/RenderManager.js +59 -0
- package/dist/managers/StateManager.svelte.d.ts +8746 -0
- package/dist/managers/StateManager.svelte.js +272 -0
- package/dist/managers/SubtitlesManager.svelte.d.ts +261 -0
- package/dist/managers/SubtitlesManager.svelte.js +1385 -0
- package/dist/managers/TimeManager.svelte.d.ts +6 -0
- package/dist/managers/TimeManager.svelte.js +18 -0
- package/dist/managers/TimelineManager.svelte.d.ts +25 -0
- package/dist/managers/TimelineManager.svelte.js +152 -0
- package/dist/registers.d.ts +12 -0
- package/dist/registers.js +29 -0
- package/dist/schemas/runtime/index.d.ts +3 -0
- package/dist/schemas/runtime/index.js +4 -0
- package/dist/schemas/runtime/types.d.ts +323 -0
- package/dist/schemas/runtime/types.js +12 -0
- package/dist/schemas/scene/animations.d.ts +89738 -0
- package/dist/schemas/scene/animations.js +211 -0
- package/dist/schemas/scene/components.js +515 -0
- package/dist/schemas/scene/core.js +160 -0
- package/dist/schemas/scene/index.d.ts +22 -0
- package/dist/schemas/scene/index.js +10 -0
- package/dist/schemas/scene/properties.d.ts +914 -0
- package/dist/schemas/scene/properties.js +398 -0
- package/dist/schemas/scene/subtitles.d.ts +1141 -0
- package/dist/schemas/scene/subtitles.js +111 -0
- package/dist/schemas/scene/utils.d.ts +1 -0
- package/dist/schemas/scene/utils.js +5 -0
- package/dist/seeds/SeedFactory.d.ts +59 -0
- package/dist/seeds/SeedFactory.js +99 -0
- package/dist/seeds/index.d.ts +8 -0
- package/dist/seeds/index.js +8 -0
- package/dist/transformers/ColorTransformer.d.ts +5 -0
- package/dist/transformers/ColorTransformer.js +67 -0
- package/dist/transformers/PixiColorTransformer.d.ts +22 -0
- package/dist/transformers/PixiColorTransformer.js +104 -0
- package/dist/utils/canvas.d.ts +6 -0
- package/dist/utils/canvas.js +18 -0
- package/dist/utils/document.d.ts +2 -0
- package/dist/utils/document.js +36 -0
- package/dist/utils/emoji.d.ts +10 -0
- package/dist/utils/emoji.js +51 -0
- package/dist/utils/html.d.ts +4 -0
- package/dist/utils/html.js +45 -0
- package/dist/utils/svgGenerator.d.ts +20 -0
- package/dist/utils/svgGenerator.js +103 -0
- package/dist/utils/utils.d.ts +5 -0
- package/dist/utils/utils.js +125 -0
- package/package.json +96 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { CommandType } from './CommandTypes.js';
|
|
2
|
+
// import type { HistoryCommand } from './HistoryCommand.js';
|
|
3
|
+
import { PlayCommand } from './PlayCommand.js';
|
|
4
|
+
import { PauseCommand } from './PauseCommand.js';
|
|
5
|
+
import { SeekCommand } from './SeekCommand.js';
|
|
6
|
+
import { UpdateComponentCommand } from './UpdateComponentCommand.js';
|
|
7
|
+
import { RenderCommand } from './RenderCommand.js';
|
|
8
|
+
import { ReplaceSourceOnTimeCommand } from './ReplaceSourceOnTimeCommand.js';
|
|
9
|
+
import { RenderFrameCommand } from './RenderFrameCommand.js';
|
|
10
|
+
export class CommandRunner {
|
|
11
|
+
playCommand;
|
|
12
|
+
pauseCommand;
|
|
13
|
+
seekCommand;
|
|
14
|
+
replaceSourceOnTimeCommand;
|
|
15
|
+
renderFrameCommand;
|
|
16
|
+
updateComponentCommand;
|
|
17
|
+
renderCommand;
|
|
18
|
+
constructor(cradle) {
|
|
19
|
+
this.playCommand = cradle.playCommand;
|
|
20
|
+
this.pauseCommand = cradle.pauseCommand;
|
|
21
|
+
this.seekCommand = cradle.seekCommand;
|
|
22
|
+
this.replaceSourceOnTimeCommand = cradle.replaceSourceOnTimeCommand;
|
|
23
|
+
this.renderFrameCommand = cradle.renderFrameCommand;
|
|
24
|
+
this.updateComponentCommand = cradle.updateComponentCommand;
|
|
25
|
+
this.renderCommand = cradle.renderCommand;
|
|
26
|
+
}
|
|
27
|
+
async run(commandType, props) {
|
|
28
|
+
let command; // | HistoryCommand<T>
|
|
29
|
+
switch (commandType) {
|
|
30
|
+
case CommandType.PLAY:
|
|
31
|
+
command = this.playCommand;
|
|
32
|
+
break;
|
|
33
|
+
case CommandType.PAUSE:
|
|
34
|
+
command = this.pauseCommand;
|
|
35
|
+
break;
|
|
36
|
+
case CommandType.SEEK:
|
|
37
|
+
command = this.seekCommand;
|
|
38
|
+
break;
|
|
39
|
+
case CommandType.REPLACE_SOURCE_ON_TIME:
|
|
40
|
+
command = this.replaceSourceOnTimeCommand;
|
|
41
|
+
break;
|
|
42
|
+
case CommandType.RENDER_FRAME:
|
|
43
|
+
command = this.renderFrameCommand;
|
|
44
|
+
break;
|
|
45
|
+
case CommandType.UPDATE_COMPONENT:
|
|
46
|
+
command = this.updateComponentCommand;
|
|
47
|
+
break;
|
|
48
|
+
// ... add other cases as needed
|
|
49
|
+
case CommandType.RENDER:
|
|
50
|
+
throw new Error(`Render command should be run as runSync`);
|
|
51
|
+
default:
|
|
52
|
+
throw new Error(`Unknown command type: ${commandType}`);
|
|
53
|
+
}
|
|
54
|
+
if (!command) {
|
|
55
|
+
throw Error('Command not set ' + commandType);
|
|
56
|
+
}
|
|
57
|
+
const result = await command.execute(props);
|
|
58
|
+
if ('isHistoryCommand' in command && command.isHistoryCommand) {
|
|
59
|
+
// this.sceneBuilder.addToHistory(command);
|
|
60
|
+
}
|
|
61
|
+
return result;
|
|
62
|
+
}
|
|
63
|
+
runSync(commandType, props) {
|
|
64
|
+
let command;
|
|
65
|
+
switch (commandType) {
|
|
66
|
+
case CommandType.RENDER:
|
|
67
|
+
command = this.renderCommand;
|
|
68
|
+
break;
|
|
69
|
+
default:
|
|
70
|
+
throw new Error(`Unknown sync command type: ${commandType}`);
|
|
71
|
+
}
|
|
72
|
+
if (!command) {
|
|
73
|
+
throw Error('Command not set ' + commandType);
|
|
74
|
+
}
|
|
75
|
+
const result = command.execute(props);
|
|
76
|
+
if ('isHistoryCommand' in command && command.isHistoryCommand) {
|
|
77
|
+
// this.sceneBuilder.addToHistory(command);
|
|
78
|
+
}
|
|
79
|
+
return result;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare enum CommandType {
|
|
2
|
+
PLAY = "play",
|
|
3
|
+
PAUSE = "pause",
|
|
4
|
+
SEEK = "seek",
|
|
5
|
+
UPDATE_COMPONENT = "updateComponent",
|
|
6
|
+
UPDATE_ANIMATED_PROPERTY = "updateAnimatedProperty",
|
|
7
|
+
GET_COMPONENT_DATA = "getComponentData",
|
|
8
|
+
RENDER = "render",
|
|
9
|
+
REPLACE_SOURCE_ON_TIME = "replaceSourceOnTime",
|
|
10
|
+
RENDER_FRAME = "renderFrame"
|
|
11
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export var CommandType;
|
|
2
|
+
(function (CommandType) {
|
|
3
|
+
CommandType["PLAY"] = "play";
|
|
4
|
+
CommandType["PAUSE"] = "pause";
|
|
5
|
+
CommandType["SEEK"] = "seek";
|
|
6
|
+
CommandType["UPDATE_COMPONENT"] = "updateComponent";
|
|
7
|
+
CommandType["UPDATE_ANIMATED_PROPERTY"] = "updateAnimatedProperty";
|
|
8
|
+
CommandType["GET_COMPONENT_DATA"] = "getComponentData";
|
|
9
|
+
CommandType["RENDER"] = "render";
|
|
10
|
+
CommandType["REPLACE_SOURCE_ON_TIME"] = "replaceSourceOnTime";
|
|
11
|
+
CommandType["RENDER_FRAME"] = "renderFrame";
|
|
12
|
+
// ... add other command types as needed
|
|
13
|
+
})(CommandType || (CommandType = {}));
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { EventManager } from '../managers/EventManager.js';
|
|
2
|
+
import type { RenderManager } from '../managers/RenderManager.js';
|
|
3
|
+
import type { StateManager } from '../managers/StateManager.svelte.js';
|
|
4
|
+
import type { SyncCommand } from './Command.js';
|
|
5
|
+
export declare class RenderCommand implements SyncCommand<boolean | number> {
|
|
6
|
+
private eventManager;
|
|
7
|
+
private state;
|
|
8
|
+
private renderManager;
|
|
9
|
+
constructor(cradle: {
|
|
10
|
+
eventManager: EventManager;
|
|
11
|
+
stateManager: StateManager;
|
|
12
|
+
renderManager: RenderManager;
|
|
13
|
+
});
|
|
14
|
+
execute(): boolean | number;
|
|
15
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export class RenderCommand {
|
|
2
|
+
eventManager;
|
|
3
|
+
state;
|
|
4
|
+
renderManager;
|
|
5
|
+
constructor(cradle) {
|
|
6
|
+
this.eventManager = cradle.eventManager;
|
|
7
|
+
this.state = cradle.stateManager;
|
|
8
|
+
this.renderManager = cradle.renderManager;
|
|
9
|
+
}
|
|
10
|
+
execute() {
|
|
11
|
+
if (this.state.state === 'loading') {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
this.eventManager.emit('beforerender');
|
|
15
|
+
this.renderManager.render();
|
|
16
|
+
return this.state.currentTime;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Command } from './Command.js';
|
|
2
|
+
import { StateManager } from '../managers/StateManager.svelte.js';
|
|
3
|
+
import { DomManager } from '../managers/DomManager.js';
|
|
4
|
+
import { AppManager } from '../managers/AppManager.svelte.js';
|
|
5
|
+
export declare class RenderFrameCommand implements Command<string | ArrayBuffer | Blob | null> {
|
|
6
|
+
private sceneState;
|
|
7
|
+
private domManager;
|
|
8
|
+
private appManager;
|
|
9
|
+
private lastRenderedFrame;
|
|
10
|
+
private lastRenderArgs;
|
|
11
|
+
constructor(cradle: {
|
|
12
|
+
stateManager: StateManager;
|
|
13
|
+
domManager: DomManager;
|
|
14
|
+
appManager: AppManager;
|
|
15
|
+
});
|
|
16
|
+
execute(args: unknown): Promise<string | ArrayBuffer | Blob | null>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { StateManager } from '../managers/StateManager.svelte.js';
|
|
3
|
+
import { DomManager } from '../managers/DomManager.js';
|
|
4
|
+
import { AppManager } from '../managers/AppManager.svelte.js';
|
|
5
|
+
const replaceSourceOnTimeSchema = z.object({
|
|
6
|
+
format: z.enum(['arraybuffer', 'blob', 'png', 'jpg', 'jpeg']),
|
|
7
|
+
quality: z.number().min(0).max(1),
|
|
8
|
+
target: z.any()
|
|
9
|
+
});
|
|
10
|
+
export class RenderFrameCommand {
|
|
11
|
+
sceneState;
|
|
12
|
+
domManager;
|
|
13
|
+
appManager;
|
|
14
|
+
lastRenderedFrame = null;
|
|
15
|
+
lastRenderArgs = null;
|
|
16
|
+
constructor(cradle) {
|
|
17
|
+
this.sceneState = cradle.stateManager;
|
|
18
|
+
this.domManager = cradle.domManager;
|
|
19
|
+
this.appManager = cradle.appManager;
|
|
20
|
+
}
|
|
21
|
+
async execute(args) {
|
|
22
|
+
const check = replaceSourceOnTimeSchema.safeParse(args);
|
|
23
|
+
if (!check.success) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
const { format, quality, target } = check.data;
|
|
27
|
+
// Server optimization: Return cached frame if nothing changed visually and render args match
|
|
28
|
+
if (this.sceneState.environment === 'server' && !this.sceneState.isDirty) {
|
|
29
|
+
if (this.lastRenderedFrame && this.lastRenderArgs) {
|
|
30
|
+
// Check if render args match current args
|
|
31
|
+
const argsMatch = this.lastRenderArgs.format === format &&
|
|
32
|
+
this.lastRenderArgs.quality === quality &&
|
|
33
|
+
this.lastRenderArgs.target === target;
|
|
34
|
+
if (argsMatch) {
|
|
35
|
+
return this.lastRenderedFrame;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
let frame = null;
|
|
40
|
+
if (format === 'arraybuffer') {
|
|
41
|
+
frame = (await new Promise((resolve, reject) => {
|
|
42
|
+
requestAnimationFrame(() => {
|
|
43
|
+
const context = this.domManager.canvas.getContext('2d');
|
|
44
|
+
if (!context) {
|
|
45
|
+
reject(new Error('Failed to get canvas context'));
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
const imagewidth = this.domManager.canvas.width;
|
|
49
|
+
const imageheight = this.domManager.canvas.height;
|
|
50
|
+
const imagedata = context.getImageData(0, 0, imagewidth, imageheight);
|
|
51
|
+
const frame = imagedata.data.buffer;
|
|
52
|
+
resolve(frame);
|
|
53
|
+
});
|
|
54
|
+
}));
|
|
55
|
+
}
|
|
56
|
+
if (format === 'blob') {
|
|
57
|
+
frame = (await new Promise((resolve) => {
|
|
58
|
+
requestAnimationFrame(() => {
|
|
59
|
+
this.domManager.canvas.toBlob((blob) => {
|
|
60
|
+
resolve(blob);
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
}));
|
|
64
|
+
}
|
|
65
|
+
if (format === 'png' || format === 'jpg' || format === 'jpeg') {
|
|
66
|
+
frame =
|
|
67
|
+
this.sceneState.environment === 'server'
|
|
68
|
+
? (await new Promise((resolve) => {
|
|
69
|
+
requestAnimationFrame(() => {
|
|
70
|
+
const frame = format === 'jpg' || format === 'jpeg'
|
|
71
|
+
? this.domManager.canvas.toDataURL('image/jpeg', quality)
|
|
72
|
+
: this.domManager.canvas.toDataURL();
|
|
73
|
+
resolve(frame);
|
|
74
|
+
});
|
|
75
|
+
}))
|
|
76
|
+
: (await new Promise((resolve) => {
|
|
77
|
+
requestAnimationFrame(async () => {
|
|
78
|
+
// Re-render in the RAF so video texture updates are included
|
|
79
|
+
this.appManager.render();
|
|
80
|
+
const b64 = await this.appManager.app.renderer.extract.base64(target || this.appManager.app.stage, format, quality);
|
|
81
|
+
resolve(b64);
|
|
82
|
+
});
|
|
83
|
+
}));
|
|
84
|
+
}
|
|
85
|
+
// Cache frame and render args, then clear dirty flag after successful render
|
|
86
|
+
if (this.sceneState.environment === 'server') {
|
|
87
|
+
this.lastRenderedFrame = frame;
|
|
88
|
+
this.lastRenderArgs = { format, quality, target };
|
|
89
|
+
this.sceneState.clearDirty();
|
|
90
|
+
}
|
|
91
|
+
return frame;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
const replaceSourceOnTimeSchema = z.object({
|
|
3
|
+
componentId: z.string(),
|
|
4
|
+
base64data: z.string(),
|
|
5
|
+
time: z.number()
|
|
6
|
+
});
|
|
7
|
+
export class ReplaceSourceOnTimeCommand {
|
|
8
|
+
async execute(args) {
|
|
9
|
+
// TODO: Complete implementation - this is work in progress
|
|
10
|
+
// if (this.sceneBuilder.environment != 'server') {
|
|
11
|
+
// this.sceneBuilder.log('replaceSource is only available in server environment');
|
|
12
|
+
// return;
|
|
13
|
+
// }
|
|
14
|
+
const check = replaceSourceOnTimeSchema.safeParse(args);
|
|
15
|
+
if (!check.success) {
|
|
16
|
+
// this.sceneBuilder.log('ReplaceSourceOnTimeCommand failed with error: ' + check.error);
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
// WIP: Need to implement the actual source replacement logic
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Command } from './Command.js';
|
|
2
|
+
import { TimelineManager } from '../managers/TimelineManager.svelte.js';
|
|
3
|
+
import { StateManager } from '../managers/StateManager.svelte.js';
|
|
4
|
+
import { RenderManager } from '../managers/RenderManager.js';
|
|
5
|
+
export declare class SeekCommand implements Command {
|
|
6
|
+
private timeline;
|
|
7
|
+
private state;
|
|
8
|
+
private renderManager;
|
|
9
|
+
constructor(cradle: {
|
|
10
|
+
timelineManager: TimelineManager;
|
|
11
|
+
stateManager: StateManager;
|
|
12
|
+
renderManager: RenderManager;
|
|
13
|
+
});
|
|
14
|
+
execute(args: unknown): Promise<void>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { TimelineManager } from '../managers/TimelineManager.svelte.js';
|
|
3
|
+
import { StateManager } from '../managers/StateManager.svelte.js';
|
|
4
|
+
import { RenderManager } from '../managers/RenderManager.js';
|
|
5
|
+
const seekSchema = z.object({
|
|
6
|
+
time: z.number()
|
|
7
|
+
});
|
|
8
|
+
export class SeekCommand {
|
|
9
|
+
timeline;
|
|
10
|
+
state;
|
|
11
|
+
renderManager;
|
|
12
|
+
constructor(cradle) {
|
|
13
|
+
this.timeline = cradle.timelineManager;
|
|
14
|
+
this.state = cradle.stateManager;
|
|
15
|
+
this.renderManager = cradle.renderManager;
|
|
16
|
+
}
|
|
17
|
+
async execute(args) {
|
|
18
|
+
const check = seekSchema.safeParse(args);
|
|
19
|
+
if (!check.success) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
const time = Math.max(0, Math.min(check.data.time, this.state.duration));
|
|
23
|
+
this.timeline.seek(time);
|
|
24
|
+
// Ensure a deterministic render on server after seek to advance media frames
|
|
25
|
+
if (this.state.environment === 'server') {
|
|
26
|
+
// Try multiple render passes until loading state clears or attempts exhausted
|
|
27
|
+
const maxAttempts = 10;
|
|
28
|
+
for (let i = 0; i < maxAttempts; i += 1) {
|
|
29
|
+
await this.renderManager.render();
|
|
30
|
+
if (this.state.state !== 'loading')
|
|
31
|
+
break;
|
|
32
|
+
await new Promise((resolve) => setTimeout(resolve, 30));
|
|
33
|
+
}
|
|
34
|
+
if (this.state.state === 'loading') {
|
|
35
|
+
console.warn('SeekCommand: Max render attempts exhausted while still loading');
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ComponentShape } from '../schemas/scene/components.js';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
const replaceSourceOnTimeSchema = z.object({
|
|
4
|
+
componentId: z.string(),
|
|
5
|
+
data: ComponentShape
|
|
6
|
+
});
|
|
7
|
+
export class UpdateComponentCommand {
|
|
8
|
+
async execute(props) {
|
|
9
|
+
const check = replaceSourceOnTimeSchema.safeParse(props);
|
|
10
|
+
if (!check.success) {
|
|
11
|
+
// this.sceneBuilder.log('UpdateComponentCommand validation error: ' + check.error);
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
// should return true on successful component update, false otherwise (component not found etc.)
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { Sprite } from "pixi.js-legacy";
|
|
2
|
+
import { Renderer, SCALE_MODES } from "pixi.js-legacy";
|
|
3
|
+
/** Represents a single frame of a GIF. Includes image and timing data. */
|
|
4
|
+
interface FrameObject {
|
|
5
|
+
/** Image data for the current frame */
|
|
6
|
+
imageData: ImageData;
|
|
7
|
+
/** The start of the current frame, in milliseconds */
|
|
8
|
+
start: number;
|
|
9
|
+
/** The end of the current frame, in milliseconds */
|
|
10
|
+
end: number;
|
|
11
|
+
}
|
|
12
|
+
/** Default options for all AnimatedGIF objects. */
|
|
13
|
+
interface AnimatedGIFOptions {
|
|
14
|
+
/** Whether to start playing right away */
|
|
15
|
+
autoPlay: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Scale Mode to use for the texture
|
|
18
|
+
* @type {PIXI.SCALE_MODES}
|
|
19
|
+
*/
|
|
20
|
+
scaleMode: SCALE_MODES;
|
|
21
|
+
/** To enable looping */
|
|
22
|
+
loop: boolean;
|
|
23
|
+
/** Speed of the animation */
|
|
24
|
+
animationSpeed: number;
|
|
25
|
+
/** Set to `false` to manage updates yourself */
|
|
26
|
+
autoUpdate: boolean;
|
|
27
|
+
/** The completed callback, optional */
|
|
28
|
+
onComplete: null | (() => void);
|
|
29
|
+
/** The loop callback, optional */
|
|
30
|
+
onLoop: null | (() => void);
|
|
31
|
+
/** The frame callback, optional */
|
|
32
|
+
onFrameChange: null | ((currentFrame: number) => void);
|
|
33
|
+
/** Fallback FPS if GIF contains no time information */
|
|
34
|
+
fps?: number;
|
|
35
|
+
}
|
|
36
|
+
/** Options for the AnimatedGIF constructor. */
|
|
37
|
+
interface AnimatedGIFSize {
|
|
38
|
+
/** Width of the GIF image */
|
|
39
|
+
width: number;
|
|
40
|
+
/** Height of the GIF image */
|
|
41
|
+
height: number;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Runtime object to play animated GIFs. This object is similar to an AnimatedSprite.
|
|
45
|
+
* It support playback (seek, play, stop) as well as animation speed and looping.
|
|
46
|
+
* @see Thanks to {@link https://github.com/matt-way/gifuct-js/ gifuct-js}
|
|
47
|
+
*/
|
|
48
|
+
declare class AnimatedGIF extends Sprite {
|
|
49
|
+
/**
|
|
50
|
+
* Default options for all AnimatedGIF objects.
|
|
51
|
+
* @property {PIXI.SCALE_MODES} [scaleMode=PIXI.SCALE_MODES.LINEAR] - Scale mode to use for the texture.
|
|
52
|
+
* @property {boolean} [loop=true] - To enable looping.
|
|
53
|
+
* @property {number} [animationSpeed=1] - Speed of the animation.
|
|
54
|
+
* @property {boolean} [autoUpdate=true] - Set to `false` to manage updates yourself.
|
|
55
|
+
* @property {boolean} [autoPlay=true] - To start playing right away.
|
|
56
|
+
* @property {Function} [onComplete=null] - The completed callback, optional.
|
|
57
|
+
* @property {Function} [onLoop=null] - The loop callback, optional.
|
|
58
|
+
* @property {Function} [onFrameChange=null] - The frame callback, optional.
|
|
59
|
+
* @property {number} [fps=30] - Fallback FPS if GIF contains no time information.
|
|
60
|
+
*/
|
|
61
|
+
static defaultOptions: AnimatedGIFOptions;
|
|
62
|
+
/**
|
|
63
|
+
* The speed that the animation will play at. Higher is faster, lower is slower.
|
|
64
|
+
* @default 1
|
|
65
|
+
*/
|
|
66
|
+
animationSpeed: number;
|
|
67
|
+
/**
|
|
68
|
+
* Whether or not the animate sprite repeats after playing.
|
|
69
|
+
* @default true
|
|
70
|
+
*/
|
|
71
|
+
loop: boolean;
|
|
72
|
+
/**
|
|
73
|
+
* User-assigned function to call when animation finishes playing. This only happens
|
|
74
|
+
* if loop is set to `false`.
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* animation.onComplete = () => {
|
|
78
|
+
* // finished!
|
|
79
|
+
* };
|
|
80
|
+
*/
|
|
81
|
+
onComplete?: () => void;
|
|
82
|
+
/**
|
|
83
|
+
* User-assigned function to call when animation changes which texture is being rendered.
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* animation.onFrameChange = () => {
|
|
87
|
+
* // updated!
|
|
88
|
+
* };
|
|
89
|
+
*/
|
|
90
|
+
onFrameChange?: (currentFrame: number) => void;
|
|
91
|
+
/**
|
|
92
|
+
* User-assigned function to call when `loop` is true, and animation is played and
|
|
93
|
+
* loops around to start again. This only happens if loop is set to `true`.
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* animation.onLoop = () => {
|
|
97
|
+
* // looped!
|
|
98
|
+
* };
|
|
99
|
+
*/
|
|
100
|
+
onLoop?: () => void;
|
|
101
|
+
/** The total duration of animation in milliseconds. */
|
|
102
|
+
readonly duration: number;
|
|
103
|
+
/** Whether to play the animation after constructing. */
|
|
104
|
+
readonly autoPlay: boolean;
|
|
105
|
+
/** Collection of frame to render. */
|
|
106
|
+
private _frames;
|
|
107
|
+
/** Drawing context reference. */
|
|
108
|
+
private _context;
|
|
109
|
+
/** Dirty means the image needs to be redrawn. Set to `true` to force redraw. */
|
|
110
|
+
dirty: boolean;
|
|
111
|
+
/** The current frame number (zero-based index). */
|
|
112
|
+
private _currentFrame;
|
|
113
|
+
/** `true` uses PIXI.Ticker.shared to auto update animation time.*/
|
|
114
|
+
private _autoUpdate;
|
|
115
|
+
/** `true` if the instance is currently connected to PIXI.Ticker.shared to auto update animation time. */
|
|
116
|
+
private _isConnectedToTicker;
|
|
117
|
+
/** If animation is currently playing. */
|
|
118
|
+
private _playing;
|
|
119
|
+
/** Current playback position in milliseconds. */
|
|
120
|
+
private _currentTime;
|
|
121
|
+
/**
|
|
122
|
+
* Create an animated GIF animation from a GIF image's ArrayBuffer. The easiest way to get
|
|
123
|
+
* the buffer is to use Assets.
|
|
124
|
+
* @example
|
|
125
|
+
* import { Assets } from 'pixi.js';
|
|
126
|
+
* import '@pixi/gif';
|
|
127
|
+
*
|
|
128
|
+
* const gif = await Assets.load('file.gif');
|
|
129
|
+
* @param buffer - GIF image arraybuffer from Assets.
|
|
130
|
+
* @param options - Options to use.
|
|
131
|
+
* @returns
|
|
132
|
+
*/
|
|
133
|
+
static fromBuffer(buffer: ArrayBuffer, options?: Partial<AnimatedGIFOptions>): AnimatedGIF;
|
|
134
|
+
/**
|
|
135
|
+
* @param frames - Data of the GIF image.
|
|
136
|
+
* @param options - Options for the AnimatedGIF
|
|
137
|
+
*/
|
|
138
|
+
constructor(frames: FrameObject[], options: Partial<AnimatedGIFOptions> & AnimatedGIFSize);
|
|
139
|
+
/** Stops the animation. */
|
|
140
|
+
stop(): void;
|
|
141
|
+
/** Plays the animation. */
|
|
142
|
+
play(): void;
|
|
143
|
+
/**
|
|
144
|
+
* Get the current progress of the animation from 0 to 1.
|
|
145
|
+
* @readonly
|
|
146
|
+
*/
|
|
147
|
+
get progress(): number;
|
|
148
|
+
/** `true` if the current animation is playing */
|
|
149
|
+
get playing(): boolean;
|
|
150
|
+
/**
|
|
151
|
+
* Updates the object transform for rendering. You only need to call this
|
|
152
|
+
* if the `autoUpdate` property is set to `false`.
|
|
153
|
+
*
|
|
154
|
+
* @param deltaTime - Time since last tick.
|
|
155
|
+
*/
|
|
156
|
+
update(deltaTime: number): void;
|
|
157
|
+
/**
|
|
158
|
+
* Redraw the current frame, is necessary for the animation to work when
|
|
159
|
+
*/
|
|
160
|
+
private updateFrame;
|
|
161
|
+
/**
|
|
162
|
+
* Renders the object using the WebGL renderer
|
|
163
|
+
*
|
|
164
|
+
* @param {PIXI.Renderer} renderer - The renderer
|
|
165
|
+
* @private
|
|
166
|
+
*/
|
|
167
|
+
_render(renderer: Renderer): void;
|
|
168
|
+
/**
|
|
169
|
+
* Renders the object using the WebGL renderer
|
|
170
|
+
*
|
|
171
|
+
* @param {PIXI.CanvasRenderer} renderer - The renderer
|
|
172
|
+
* @private
|
|
173
|
+
*/
|
|
174
|
+
_renderCanvas(renderer: any): void;
|
|
175
|
+
/**
|
|
176
|
+
* Whether to use PIXI.Ticker.shared to auto update animation time.
|
|
177
|
+
* @default true
|
|
178
|
+
*/
|
|
179
|
+
get autoUpdate(): boolean;
|
|
180
|
+
set autoUpdate(value: boolean);
|
|
181
|
+
/** Set the current frame number */
|
|
182
|
+
get currentFrame(): number;
|
|
183
|
+
set currentFrame(value: number);
|
|
184
|
+
/** Internally handle updating the frame index */
|
|
185
|
+
private updateFrameIndex;
|
|
186
|
+
/**
|
|
187
|
+
* Get the total number of frame in the GIF.
|
|
188
|
+
*/
|
|
189
|
+
get totalFrames(): number;
|
|
190
|
+
/** Destroy and don't use after this. */
|
|
191
|
+
destroy(): void;
|
|
192
|
+
/**
|
|
193
|
+
* Cloning the animation is a useful way to create a duplicate animation.
|
|
194
|
+
* This maintains all the properties of the original animation but allows
|
|
195
|
+
* you to control playback independent of the original animation.
|
|
196
|
+
* If you want to create a simple copy, and not control independently,
|
|
197
|
+
* then you can simply create a new Sprite, e.g. `const sprite = new Sprite(animation.texture)`.
|
|
198
|
+
*/
|
|
199
|
+
clone(): AnimatedGIF;
|
|
200
|
+
}
|
|
201
|
+
export { AnimatedGIF };
|