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,272 @@
|
|
|
1
|
+
import { EventManager } from './EventManager.js';
|
|
2
|
+
import { TimeManager } from './TimeManager.svelte.js';
|
|
3
|
+
export class StateManager {
|
|
4
|
+
state = $state('paused');
|
|
5
|
+
isPlaying = $state(false);
|
|
6
|
+
renderAfterLoadingFinished = $state(false);
|
|
7
|
+
currentTimeRune = $state(0);
|
|
8
|
+
scale = $state(1);
|
|
9
|
+
loadingComponents = $state(new Set());
|
|
10
|
+
currentSceneData;
|
|
11
|
+
charactersList = [];
|
|
12
|
+
isDirtyFlag = true; // Tracks if visual updates occurred since last render
|
|
13
|
+
eventManager;
|
|
14
|
+
env;
|
|
15
|
+
loop = false;
|
|
16
|
+
timeManager;
|
|
17
|
+
layersManager;
|
|
18
|
+
constructor(cradle) {
|
|
19
|
+
const sceneDataRune = $state(cradle.sceneData);
|
|
20
|
+
this.currentSceneData = sceneDataRune;
|
|
21
|
+
this.setScale(cradle.scale);
|
|
22
|
+
this.eventManager = cradle.eventManager;
|
|
23
|
+
this.env = cradle.environment;
|
|
24
|
+
this.loop = cradle.loop ?? false;
|
|
25
|
+
this.timeManager = cradle.timeManager;
|
|
26
|
+
this.layersManager = cradle.layersManager;
|
|
27
|
+
this.timeManager.updateTimeConfig(this.currentSceneData.settings.fps, this.currentSceneData.settings.duration);
|
|
28
|
+
}
|
|
29
|
+
updateSceneData(sceneData) {
|
|
30
|
+
if (sceneData.layers) {
|
|
31
|
+
this.currentSceneData.layers = sceneData.layers;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
updateSceneSubtitlesSettings(subtitlesSettings) {
|
|
35
|
+
this.currentSceneData.settings.subtitles = subtitlesSettings;
|
|
36
|
+
}
|
|
37
|
+
get currentTime() {
|
|
38
|
+
if (this.currentTimeRune >= this.endTime) {
|
|
39
|
+
return this.endTime;
|
|
40
|
+
}
|
|
41
|
+
else if (this.currentTimeRune <= this.startTime) {
|
|
42
|
+
return this.startTime;
|
|
43
|
+
}
|
|
44
|
+
// Could cache fps if it doesn't change frequently
|
|
45
|
+
return this.timeManager.transformTime(this.currentTimeRune);
|
|
46
|
+
}
|
|
47
|
+
get data() {
|
|
48
|
+
return this.currentSceneData;
|
|
49
|
+
}
|
|
50
|
+
updateLayers() {
|
|
51
|
+
this.currentSceneData.layers = this.layersManager.getData();
|
|
52
|
+
}
|
|
53
|
+
get environment() {
|
|
54
|
+
return this.env;
|
|
55
|
+
}
|
|
56
|
+
getCharactersList() {
|
|
57
|
+
return this.charactersList;
|
|
58
|
+
}
|
|
59
|
+
setCharactersList(chars) {
|
|
60
|
+
this.charactersList = chars;
|
|
61
|
+
}
|
|
62
|
+
setScale(scale) {
|
|
63
|
+
this.scale = scale;
|
|
64
|
+
}
|
|
65
|
+
get startTime() {
|
|
66
|
+
return this.data.settings.startAt || 0;
|
|
67
|
+
}
|
|
68
|
+
get endTime() {
|
|
69
|
+
return Math.min(this.data.settings.endAt || this.duration, this.duration);
|
|
70
|
+
}
|
|
71
|
+
setCurrentTime(time) {
|
|
72
|
+
const currentTime = this.timeManager.transformTime(Math.max(this.startTime, Math.min(time, this.endTime)));
|
|
73
|
+
this.currentTimeRune = currentTime;
|
|
74
|
+
if (time >= this.endTime && this.isPlaying) {
|
|
75
|
+
if (this.loop) {
|
|
76
|
+
this.currentTimeRune = this.startTime;
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
this.changeState('paused');
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
setStartAt(start) {
|
|
84
|
+
if (start !== undefined) {
|
|
85
|
+
this.data.settings.startAt = start <= 0 ? undefined : start;
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
this.data.settings.startAt = undefined;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
setEndAt(end) {
|
|
92
|
+
if (end !== undefined) {
|
|
93
|
+
// TODO fix this because it causes bugs that shorten component duration
|
|
94
|
+
this.data.settings.endAt =
|
|
95
|
+
this.data.settings.endAt && end >= this.data.settings.endAt ? undefined : end;
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
this.data.settings.endAt = undefined;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
get currentFrame() {
|
|
102
|
+
return Math.round(this.currentTime * this.data.settings.fps);
|
|
103
|
+
}
|
|
104
|
+
get disabledTimeZones() {
|
|
105
|
+
const start = $derived(this.data.settings.startAt);
|
|
106
|
+
const end = $derived(this.data.settings.endAt);
|
|
107
|
+
const excluded_timestamps = $derived(this.data.settings.trimZones);
|
|
108
|
+
const duration = $derived(this.data.settings.duration);
|
|
109
|
+
const zones = $derived.by(() => {
|
|
110
|
+
const output = [];
|
|
111
|
+
if (start && start > 0) {
|
|
112
|
+
output.push({
|
|
113
|
+
start: 0,
|
|
114
|
+
end: start
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
if (excluded_timestamps && excluded_timestamps.length) {
|
|
118
|
+
for (const disabledZone of excluded_timestamps) {
|
|
119
|
+
const { start, end } = disabledZone;
|
|
120
|
+
if (end < duration) {
|
|
121
|
+
output.push({
|
|
122
|
+
start,
|
|
123
|
+
end
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
if (end && end < duration) {
|
|
129
|
+
output.push({
|
|
130
|
+
start: end,
|
|
131
|
+
end: duration
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
// Sort zones by start time
|
|
135
|
+
output.sort((a, b) => a.start - b.start);
|
|
136
|
+
// Merge overlapping zones
|
|
137
|
+
const mergedZones = [];
|
|
138
|
+
let currentZone = null;
|
|
139
|
+
for (const zone of output) {
|
|
140
|
+
if (!currentZone) {
|
|
141
|
+
currentZone = { ...zone };
|
|
142
|
+
}
|
|
143
|
+
else if (zone.start <= currentZone.end) {
|
|
144
|
+
// Zones overlap, extend the current zone
|
|
145
|
+
currentZone.end = Math.max(currentZone.end, zone.end);
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
// No overlap, push current zone and start a new one
|
|
149
|
+
mergedZones.push(currentZone);
|
|
150
|
+
currentZone = { ...zone };
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
if (currentZone) {
|
|
154
|
+
mergedZones.push(currentZone);
|
|
155
|
+
}
|
|
156
|
+
return mergedZones;
|
|
157
|
+
});
|
|
158
|
+
return zones;
|
|
159
|
+
}
|
|
160
|
+
changeState(updateState) {
|
|
161
|
+
let newState = this.determineNewState(updateState);
|
|
162
|
+
if (newState === 'ended' && this.loop) {
|
|
163
|
+
newState = 'playing';
|
|
164
|
+
this.setCurrentTime(this.startTime);
|
|
165
|
+
}
|
|
166
|
+
this.updatePlayingState(newState);
|
|
167
|
+
this.emitStateChange(newState);
|
|
168
|
+
// if (newState !== 'playing') {
|
|
169
|
+
// this.mediaManager.stopMediaElements();
|
|
170
|
+
// }
|
|
171
|
+
}
|
|
172
|
+
determineNewState(requestedState) {
|
|
173
|
+
if (this.loadingComponents.size > 0) {
|
|
174
|
+
return 'loading';
|
|
175
|
+
}
|
|
176
|
+
const t1 = this.transformTime(this.currentTime);
|
|
177
|
+
const t2 = this.transformTime(this.endTime);
|
|
178
|
+
if (t1 >= t2) {
|
|
179
|
+
return 'ended';
|
|
180
|
+
}
|
|
181
|
+
return requestedState;
|
|
182
|
+
}
|
|
183
|
+
transformTime(time, skipDurationCheck = false) {
|
|
184
|
+
return this.timeManager.transformTime(time, skipDurationCheck);
|
|
185
|
+
}
|
|
186
|
+
updatePlayingState(newState) {
|
|
187
|
+
if (newState === 'playing') {
|
|
188
|
+
this.isPlaying = true;
|
|
189
|
+
}
|
|
190
|
+
else if (newState === 'paused' || newState === 'ended') {
|
|
191
|
+
this.isPlaying = false;
|
|
192
|
+
}
|
|
193
|
+
this.state = newState;
|
|
194
|
+
}
|
|
195
|
+
emitStateChange(newState) {
|
|
196
|
+
this.emit('changestate', { state: newState, isPlaying: this.isPlaying });
|
|
197
|
+
if (this.renderAfterLoadingFinished && newState !== 'loading') {
|
|
198
|
+
this.renderAfterLoadingFinished = false;
|
|
199
|
+
this.emit('rerender');
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
emit(event, props) {
|
|
203
|
+
if (!this.eventManager) {
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
this.eventManager.emit(event, props);
|
|
207
|
+
}
|
|
208
|
+
refreshState() {
|
|
209
|
+
this.changeState(this.isPlaying ? 'playing' : 'paused');
|
|
210
|
+
}
|
|
211
|
+
get duration() {
|
|
212
|
+
return this.data.settings.duration;
|
|
213
|
+
}
|
|
214
|
+
get width() {
|
|
215
|
+
return this.data.settings.width;
|
|
216
|
+
}
|
|
217
|
+
get height() {
|
|
218
|
+
return this.data.settings.height;
|
|
219
|
+
}
|
|
220
|
+
setDuration(dur) {
|
|
221
|
+
this.data.settings.duration = dur;
|
|
222
|
+
}
|
|
223
|
+
setWidth(width) {
|
|
224
|
+
this.data.settings.width = width;
|
|
225
|
+
}
|
|
226
|
+
setHeight(height) {
|
|
227
|
+
this.data.settings.height = height;
|
|
228
|
+
}
|
|
229
|
+
setRenderAfterLoadingFinished(newVal) {
|
|
230
|
+
this.renderAfterLoadingFinished = newVal;
|
|
231
|
+
}
|
|
232
|
+
addLoadingComponent(componentId, type) {
|
|
233
|
+
if (this.loadingComponents.has(componentId))
|
|
234
|
+
return;
|
|
235
|
+
this.loadingComponents.add(componentId);
|
|
236
|
+
this.refreshState();
|
|
237
|
+
}
|
|
238
|
+
removeLoadingComponent(componentId) {
|
|
239
|
+
if (!this.loadingComponents.has(componentId))
|
|
240
|
+
return;
|
|
241
|
+
this.loadingComponents.delete(componentId);
|
|
242
|
+
if (this.loadingComponents.size === 0) {
|
|
243
|
+
this.refreshState();
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
isLoadingComponent(componentId) {
|
|
247
|
+
return this.loadingComponents.has(componentId);
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Mark scene as dirty (visual changes occurred)
|
|
251
|
+
* Should be called by hooks/components after visual updates
|
|
252
|
+
*/
|
|
253
|
+
markDirty() {
|
|
254
|
+
this.isDirtyFlag = true;
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Clear dirty flag after successful render
|
|
258
|
+
* Should be called by RenderFrameCommand after frame extraction
|
|
259
|
+
*/
|
|
260
|
+
clearDirty() {
|
|
261
|
+
this.isDirtyFlag = false;
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Check if scene has visual changes since last render
|
|
265
|
+
*/
|
|
266
|
+
get isDirty() {
|
|
267
|
+
return this.isDirtyFlag;
|
|
268
|
+
}
|
|
269
|
+
destroy() {
|
|
270
|
+
this.loadingComponents.clear();
|
|
271
|
+
}
|
|
272
|
+
}
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
import { EventManager } from './EventManager.js';
|
|
2
|
+
import type { SubtitleCollection, Subtitle, Scene, SceneSubtitlesSettings } from '..';
|
|
3
|
+
import type { TimeManager } from './TimeManager.svelte.js';
|
|
4
|
+
export declare class SubtitlesManager {
|
|
5
|
+
private builder;
|
|
6
|
+
private assetId;
|
|
7
|
+
private language;
|
|
8
|
+
constructor(cradle: {
|
|
9
|
+
timeManager: TimeManager;
|
|
10
|
+
eventManager: EventManager;
|
|
11
|
+
sceneData: Scene;
|
|
12
|
+
subtitles: Record<string, Subtitle[]> | Record<string, SubtitleCollection>;
|
|
13
|
+
});
|
|
14
|
+
get data(): Record<string, Record<string, ({
|
|
15
|
+
id: string;
|
|
16
|
+
text: string;
|
|
17
|
+
start_at: number;
|
|
18
|
+
end_at: number;
|
|
19
|
+
visible?: boolean | undefined;
|
|
20
|
+
color?: string | {
|
|
21
|
+
type: "linear" | "radial";
|
|
22
|
+
colors: string[];
|
|
23
|
+
stops?: number[] | undefined;
|
|
24
|
+
angle?: number | undefined;
|
|
25
|
+
position?: string | undefined;
|
|
26
|
+
shape?: "ellipse" | "circle" | undefined;
|
|
27
|
+
} | undefined;
|
|
28
|
+
background?: string | {
|
|
29
|
+
type: "linear" | "radial";
|
|
30
|
+
colors: string[];
|
|
31
|
+
stops?: number[] | undefined;
|
|
32
|
+
angle?: number | undefined;
|
|
33
|
+
position?: string | undefined;
|
|
34
|
+
shape?: "ellipse" | "circle" | undefined;
|
|
35
|
+
} | undefined;
|
|
36
|
+
words?: [string, number, number, ...(import("zod").objectOutputType<{
|
|
37
|
+
s: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
38
|
+
si: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
39
|
+
c: import("zod").ZodOptional<import("zod").ZodUnion<[import("zod").ZodEffects<import("zod").ZodString, string, string>, import("zod").ZodObject<{
|
|
40
|
+
type: import("zod").ZodEnum<["linear", "radial"]>;
|
|
41
|
+
colors: import("zod").ZodArray<import("zod").ZodEffects<import("zod").ZodString, string, string>, "many">;
|
|
42
|
+
stops: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodNumber, "many">>;
|
|
43
|
+
angle: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
44
|
+
position: import("zod").ZodOptional<import("zod").ZodString>;
|
|
45
|
+
shape: import("zod").ZodOptional<import("zod").ZodEnum<["ellipse", "circle"]>>;
|
|
46
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
47
|
+
type: "linear" | "radial";
|
|
48
|
+
colors: string[];
|
|
49
|
+
stops?: number[] | undefined;
|
|
50
|
+
angle?: number | undefined;
|
|
51
|
+
position?: string | undefined;
|
|
52
|
+
shape?: "ellipse" | "circle" | undefined;
|
|
53
|
+
}, {
|
|
54
|
+
type: "linear" | "radial";
|
|
55
|
+
colors: string[];
|
|
56
|
+
stops?: number[] | undefined;
|
|
57
|
+
angle?: number | undefined;
|
|
58
|
+
position?: string | undefined;
|
|
59
|
+
shape?: "ellipse" | "circle" | undefined;
|
|
60
|
+
}>]>>;
|
|
61
|
+
e: import("zod").ZodOptional<import("zod").ZodString>;
|
|
62
|
+
w: import("zod").ZodOptional<import("zod").ZodString>;
|
|
63
|
+
f: import("zod").ZodOptional<import("zod").ZodString>;
|
|
64
|
+
}, import("zod").ZodAny, "strip"> | null | undefined)[]][] | undefined;
|
|
65
|
+
emoji?: string | undefined;
|
|
66
|
+
enlarge?: number | undefined;
|
|
67
|
+
} | {
|
|
68
|
+
id: string;
|
|
69
|
+
text: string;
|
|
70
|
+
start_at: number;
|
|
71
|
+
end_at: number;
|
|
72
|
+
visible?: boolean | undefined;
|
|
73
|
+
color?: string | undefined;
|
|
74
|
+
background?: string | undefined;
|
|
75
|
+
words?: {
|
|
76
|
+
id: string;
|
|
77
|
+
text: string;
|
|
78
|
+
start_at: number;
|
|
79
|
+
end_at: number;
|
|
80
|
+
position?: number | undefined;
|
|
81
|
+
}[] | undefined;
|
|
82
|
+
emoji?: string | undefined;
|
|
83
|
+
enlarge?: number | undefined;
|
|
84
|
+
})[]>>;
|
|
85
|
+
get settings(): {
|
|
86
|
+
punctuation: boolean;
|
|
87
|
+
data?: Record<string, Record<string, ({
|
|
88
|
+
id: string;
|
|
89
|
+
text: string;
|
|
90
|
+
start_at: number;
|
|
91
|
+
end_at: number;
|
|
92
|
+
visible?: boolean | undefined;
|
|
93
|
+
color?: string | {
|
|
94
|
+
type: "linear" | "radial";
|
|
95
|
+
colors: string[];
|
|
96
|
+
stops?: number[] | undefined;
|
|
97
|
+
angle?: number | undefined;
|
|
98
|
+
position?: string | undefined;
|
|
99
|
+
shape?: "ellipse" | "circle" | undefined;
|
|
100
|
+
} | undefined;
|
|
101
|
+
background?: string | {
|
|
102
|
+
type: "linear" | "radial";
|
|
103
|
+
colors: string[];
|
|
104
|
+
stops?: number[] | undefined;
|
|
105
|
+
angle?: number | undefined;
|
|
106
|
+
position?: string | undefined;
|
|
107
|
+
shape?: "ellipse" | "circle" | undefined;
|
|
108
|
+
} | undefined;
|
|
109
|
+
words?: [string, number, number, ...(import("zod").objectOutputType<{
|
|
110
|
+
s: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
111
|
+
si: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
112
|
+
c: import("zod").ZodOptional<import("zod").ZodUnion<[import("zod").ZodEffects<import("zod").ZodString, string, string>, import("zod").ZodObject<{
|
|
113
|
+
type: import("zod").ZodEnum<["linear", "radial"]>;
|
|
114
|
+
colors: import("zod").ZodArray<import("zod").ZodEffects<import("zod").ZodString, string, string>, "many">;
|
|
115
|
+
stops: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodNumber, "many">>;
|
|
116
|
+
angle: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
117
|
+
position: import("zod").ZodOptional<import("zod").ZodString>;
|
|
118
|
+
shape: import("zod").ZodOptional<import("zod").ZodEnum<["ellipse", "circle"]>>;
|
|
119
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
120
|
+
type: "linear" | "radial";
|
|
121
|
+
colors: string[];
|
|
122
|
+
stops?: number[] | undefined;
|
|
123
|
+
angle?: number | undefined;
|
|
124
|
+
position?: string | undefined;
|
|
125
|
+
shape?: "ellipse" | "circle" | undefined;
|
|
126
|
+
}, {
|
|
127
|
+
type: "linear" | "radial";
|
|
128
|
+
colors: string[];
|
|
129
|
+
stops?: number[] | undefined;
|
|
130
|
+
angle?: number | undefined;
|
|
131
|
+
position?: string | undefined;
|
|
132
|
+
shape?: "ellipse" | "circle" | undefined;
|
|
133
|
+
}>]>>;
|
|
134
|
+
e: import("zod").ZodOptional<import("zod").ZodString>;
|
|
135
|
+
w: import("zod").ZodOptional<import("zod").ZodString>;
|
|
136
|
+
f: import("zod").ZodOptional<import("zod").ZodString>;
|
|
137
|
+
}, import("zod").ZodAny, "strip"> | null | undefined)[]][] | undefined;
|
|
138
|
+
emoji?: string | undefined;
|
|
139
|
+
enlarge?: number | undefined;
|
|
140
|
+
} | {
|
|
141
|
+
id: string;
|
|
142
|
+
text: string;
|
|
143
|
+
start_at: number;
|
|
144
|
+
end_at: number;
|
|
145
|
+
visible?: boolean | undefined;
|
|
146
|
+
color?: string | undefined;
|
|
147
|
+
background?: string | undefined;
|
|
148
|
+
words?: {
|
|
149
|
+
id: string;
|
|
150
|
+
text: string;
|
|
151
|
+
start_at: number;
|
|
152
|
+
end_at: number;
|
|
153
|
+
position?: number | undefined;
|
|
154
|
+
}[] | undefined;
|
|
155
|
+
emoji?: string | undefined;
|
|
156
|
+
enlarge?: number | undefined;
|
|
157
|
+
})[]>> | undefined;
|
|
158
|
+
mergeGap?: number | undefined;
|
|
159
|
+
};
|
|
160
|
+
setAssetId(assetId: string): string;
|
|
161
|
+
setLanguage(language: string): string;
|
|
162
|
+
getAssetSubtitlesForSceneData(assetId: string): Array<{
|
|
163
|
+
language_code: string;
|
|
164
|
+
subtitles: Subtitle[];
|
|
165
|
+
}>;
|
|
166
|
+
getAssetSubtitles(assetId: string): Record<string, ({
|
|
167
|
+
id: string;
|
|
168
|
+
text: string;
|
|
169
|
+
start_at: number;
|
|
170
|
+
end_at: number;
|
|
171
|
+
visible?: boolean | undefined;
|
|
172
|
+
color?: string | {
|
|
173
|
+
type: "linear" | "radial";
|
|
174
|
+
colors: string[];
|
|
175
|
+
stops?: number[] | undefined;
|
|
176
|
+
angle?: number | undefined;
|
|
177
|
+
position?: string | undefined;
|
|
178
|
+
shape?: "ellipse" | "circle" | undefined;
|
|
179
|
+
} | undefined;
|
|
180
|
+
background?: string | {
|
|
181
|
+
type: "linear" | "radial";
|
|
182
|
+
colors: string[];
|
|
183
|
+
stops?: number[] | undefined;
|
|
184
|
+
angle?: number | undefined;
|
|
185
|
+
position?: string | undefined;
|
|
186
|
+
shape?: "ellipse" | "circle" | undefined;
|
|
187
|
+
} | undefined;
|
|
188
|
+
words?: [string, number, number, ...(import("zod").objectOutputType<{
|
|
189
|
+
s: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
190
|
+
si: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
191
|
+
c: import("zod").ZodOptional<import("zod").ZodUnion<[import("zod").ZodEffects<import("zod").ZodString, string, string>, import("zod").ZodObject<{
|
|
192
|
+
type: import("zod").ZodEnum<["linear", "radial"]>;
|
|
193
|
+
colors: import("zod").ZodArray<import("zod").ZodEffects<import("zod").ZodString, string, string>, "many">;
|
|
194
|
+
stops: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodNumber, "many">>;
|
|
195
|
+
angle: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
196
|
+
position: import("zod").ZodOptional<import("zod").ZodString>;
|
|
197
|
+
shape: import("zod").ZodOptional<import("zod").ZodEnum<["ellipse", "circle"]>>;
|
|
198
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
199
|
+
type: "linear" | "radial";
|
|
200
|
+
colors: string[];
|
|
201
|
+
stops?: number[] | undefined;
|
|
202
|
+
angle?: number | undefined;
|
|
203
|
+
position?: string | undefined;
|
|
204
|
+
shape?: "ellipse" | "circle" | undefined;
|
|
205
|
+
}, {
|
|
206
|
+
type: "linear" | "radial";
|
|
207
|
+
colors: string[];
|
|
208
|
+
stops?: number[] | undefined;
|
|
209
|
+
angle?: number | undefined;
|
|
210
|
+
position?: string | undefined;
|
|
211
|
+
shape?: "ellipse" | "circle" | undefined;
|
|
212
|
+
}>]>>;
|
|
213
|
+
e: import("zod").ZodOptional<import("zod").ZodString>;
|
|
214
|
+
w: import("zod").ZodOptional<import("zod").ZodString>;
|
|
215
|
+
f: import("zod").ZodOptional<import("zod").ZodString>;
|
|
216
|
+
}, import("zod").ZodAny, "strip"> | null | undefined)[]][] | undefined;
|
|
217
|
+
emoji?: string | undefined;
|
|
218
|
+
enlarge?: number | undefined;
|
|
219
|
+
} | {
|
|
220
|
+
id: string;
|
|
221
|
+
text: string;
|
|
222
|
+
start_at: number;
|
|
223
|
+
end_at: number;
|
|
224
|
+
visible?: boolean | undefined;
|
|
225
|
+
color?: string | undefined;
|
|
226
|
+
background?: string | undefined;
|
|
227
|
+
words?: {
|
|
228
|
+
id: string;
|
|
229
|
+
text: string;
|
|
230
|
+
start_at: number;
|
|
231
|
+
end_at: number;
|
|
232
|
+
position?: number | undefined;
|
|
233
|
+
}[] | undefined;
|
|
234
|
+
emoji?: string | undefined;
|
|
235
|
+
enlarge?: number | undefined;
|
|
236
|
+
})[]>;
|
|
237
|
+
setAssetSubtitles(assetId: string, subtitles: Subtitle[]): void;
|
|
238
|
+
replaceCollection(assetId: string, newCollection: SubtitleCollection, language?: string): void;
|
|
239
|
+
updateSubtitleText(subtitleId: string, newText: string): void;
|
|
240
|
+
updateSubtitleProps(subtitleId: string, props: Partial<Subtitle>): void;
|
|
241
|
+
splitSubtitle(subtitleId: string, splitAt: number): void;
|
|
242
|
+
mergeSubtitles(sourceSubtitleId: string, mergeTo: 'start' | 'end'): void;
|
|
243
|
+
getSubtitle(timeOrId: string | number): Subtitle | undefined;
|
|
244
|
+
setTimesForSubtitleInAssetAndLanguage(assetId: string, language: string, subtitleId: string, start?: number, end?: number): void;
|
|
245
|
+
setStart(subtitleId: string, start: number): void;
|
|
246
|
+
setEnd(subtitleId: string, end: number): void;
|
|
247
|
+
addNewSubtitleAfter(subtitleId: string, newText: string): void;
|
|
248
|
+
splitByChars(maxChars: number): void;
|
|
249
|
+
getText(): string | undefined;
|
|
250
|
+
updateSettings(newSettings: Partial<SceneSubtitlesSettings>): void;
|
|
251
|
+
findTextChunkTiming(searchText: string, options?: {
|
|
252
|
+
caseSensitive?: boolean;
|
|
253
|
+
}): Array<{
|
|
254
|
+
startTime: number;
|
|
255
|
+
endTime: number;
|
|
256
|
+
startSubtitleId: string;
|
|
257
|
+
endSubtitleId: string;
|
|
258
|
+
matchedText: string;
|
|
259
|
+
}>;
|
|
260
|
+
destroy(): void;
|
|
261
|
+
}
|