@twick/visualizer 0.14.0 → 0.14.2
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/.eslintrc.json +20 -20
- package/README.md +12 -12
- package/package.json +13 -13
- package/package.json.bak +34 -0
- package/src/animations/blur.tsx +60 -60
- package/src/animations/breathe.tsx +60 -60
- package/src/animations/fade.tsx +60 -60
- package/src/animations/photo-rise.tsx +66 -66
- package/src/animations/photo-zoom.tsx +73 -73
- package/src/animations/rise.tsx +118 -118
- package/src/animations/succession.tsx +77 -77
- package/src/components/frame-effects.tsx +188 -188
- package/src/components/track.tsx +237 -232
- package/src/controllers/animation.controller.ts +38 -38
- package/src/controllers/element.controller.ts +42 -42
- package/src/controllers/frame-effect.controller.tsx +29 -29
- package/src/controllers/text-effect.controller.ts +32 -32
- package/src/elements/audio.element.tsx +17 -17
- package/src/elements/caption.element.tsx +87 -87
- package/src/elements/circle.element.tsx +20 -20
- package/src/elements/icon.element.tsx +20 -20
- package/src/elements/image.element.tsx +53 -55
- package/src/elements/rect.element.tsx +22 -22
- package/src/elements/scene.element.tsx +29 -29
- package/src/elements/text.element.tsx +27 -27
- package/src/elements/video.element.tsx +55 -56
- package/src/frame-effects/circle.frame.tsx +103 -103
- package/src/frame-effects/rect.frame.tsx +103 -103
- package/src/global.css +11 -11
- package/src/helpers/caption.utils.ts +29 -29
- package/src/helpers/constants.ts +162 -158
- package/src/helpers/element.utils.ts +239 -239
- package/src/helpers/event.utils.ts +6 -0
- package/src/helpers/filters.ts +127 -127
- package/src/helpers/log.utils.ts +29 -29
- package/src/helpers/timing.utils.ts +109 -109
- package/src/helpers/types.ts +242 -241
- package/src/helpers/utils.ts +19 -19
- package/src/index.ts +6 -6
- package/src/live.tsx +16 -16
- package/src/project.ts +6 -6
- package/src/sample.ts +247 -247
- package/src/text-effects/elastic.tsx +39 -39
- package/src/text-effects/erase.tsx +58 -58
- package/src/text-effects/stream-word.tsx +60 -60
- package/src/text-effects/typewriter.tsx +59 -59
- package/src/visualizer.tsx +98 -78
- package/tsconfig.json +11 -11
- package/typedoc.json +14 -14
- package/vite.config.ts +15 -15
- package/.turbo/turbo-build.log +0 -19
- package/.turbo/turbo-docs.log +0 -7
- package/LICENSE +0 -197
- package/dist/mp4.wasm +0 -0
- package/dist/project.css +0 -1
- package/dist/project.js +0 -145
- package/docs/.nojekyll +0 -1
- package/docs/README.md +0 -13
- package/docs/interfaces/Animation.md +0 -47
- package/docs/interfaces/Element.md +0 -47
- package/docs/interfaces/FrameEffectPlugin.md +0 -47
- package/docs/interfaces/TextEffect.md +0 -47
- package/docs/modules.md +0 -535
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Caption utilities for the visualizer package.
|
|
3
|
-
* Provides functions for handling caption text formatting and timing.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Splits a phrase into words with timing information
|
|
8
|
-
* @param {string} t - The phrase to split
|
|
9
|
-
* @param {number} s - Start time of the phrase
|
|
10
|
-
* @param {number} e - End time of the phrase
|
|
11
|
-
* @returns {Array} Array of words with timing information
|
|
12
|
-
*/
|
|
13
|
-
export function splitPhraseTiming({ t, s, e }: { t: string, s: number, e: number }) {
|
|
14
|
-
const words = t.split(" ");
|
|
15
|
-
const totalDuration = e - s;
|
|
16
|
-
const totalLength = words.join("").length; // Total character length without spaces
|
|
17
|
-
|
|
18
|
-
let currentTime = s;
|
|
19
|
-
return words.map((word) => {
|
|
20
|
-
const wordDuration = (word.length / totalLength) * totalDuration;
|
|
21
|
-
const wordStart = currentTime;
|
|
22
|
-
const wordEnd = wordStart + wordDuration;
|
|
23
|
-
currentTime = wordEnd;
|
|
24
|
-
return {
|
|
25
|
-
t: word,
|
|
26
|
-
s: parseFloat(wordStart.toFixed(2)),
|
|
27
|
-
e: parseFloat(wordEnd.toFixed(2)),
|
|
28
|
-
};
|
|
29
|
-
});
|
|
1
|
+
/**
|
|
2
|
+
* Caption utilities for the visualizer package.
|
|
3
|
+
* Provides functions for handling caption text formatting and timing.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Splits a phrase into words with timing information
|
|
8
|
+
* @param {string} t - The phrase to split
|
|
9
|
+
* @param {number} s - Start time of the phrase
|
|
10
|
+
* @param {number} e - End time of the phrase
|
|
11
|
+
* @returns {Array} Array of words with timing information
|
|
12
|
+
*/
|
|
13
|
+
export function splitPhraseTiming({ t, s, e }: { t: string, s: number, e: number }) {
|
|
14
|
+
const words = t.split(" ");
|
|
15
|
+
const totalDuration = e - s;
|
|
16
|
+
const totalLength = words.join("").length; // Total character length without spaces
|
|
17
|
+
|
|
18
|
+
let currentTime = s;
|
|
19
|
+
return words.map((word) => {
|
|
20
|
+
const wordDuration = (word.length / totalLength) * totalDuration;
|
|
21
|
+
const wordStart = currentTime;
|
|
22
|
+
const wordEnd = wordStart + wordDuration;
|
|
23
|
+
currentTime = wordEnd;
|
|
24
|
+
return {
|
|
25
|
+
t: word,
|
|
26
|
+
s: parseFloat(wordStart.toFixed(2)),
|
|
27
|
+
e: parseFloat(wordEnd.toFixed(2)),
|
|
28
|
+
};
|
|
29
|
+
});
|
|
30
30
|
}
|
package/src/helpers/constants.ts
CHANGED
|
@@ -1,159 +1,163 @@
|
|
|
1
|
-
import { CaptionStyle } from "./types";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Constants used throughout the visualizer package.
|
|
5
|
-
* Contains default values, configuration options, and type definitions.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Default background color for scenes
|
|
10
|
-
*/
|
|
11
|
-
export const DEFAULT_BACKGROUND_COLOR = "#000000";
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Default position for elements
|
|
15
|
-
*/
|
|
16
|
-
export const DEFAULT_POSITION = {
|
|
17
|
-
x: 0,
|
|
18
|
-
y: 0
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Default timing function for animations
|
|
23
|
-
*/
|
|
24
|
-
export const DEFAULT_TIMING_FUNCTION = "easeInOut";
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Available frame shapes for elements
|
|
28
|
-
*/
|
|
29
|
-
export const FRAME_SHAPE = {
|
|
30
|
-
RECTANGLE: "rectangle",
|
|
31
|
-
CIRCLE: "circle",
|
|
32
|
-
LINE: "line"
|
|
33
|
-
} as const;
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Timeline types for different media elements
|
|
37
|
-
*/
|
|
38
|
-
export const TRACK_TYPES = {
|
|
39
|
-
VIDEO: "video",
|
|
40
|
-
AUDIO: "audio",
|
|
41
|
-
CAPTION: "caption",
|
|
42
|
-
SCENE: "scene",
|
|
43
|
-
ELEMENT: "element"
|
|
44
|
-
} as const;
|
|
45
|
-
|
|
46
|
-
export const CAPTION_STYLE: Record<string, CaptionStyle> = {
|
|
47
|
-
highlight_bg: {
|
|
48
|
-
rect: {
|
|
49
|
-
alignItems: "center",
|
|
50
|
-
gap: 2,
|
|
51
|
-
},
|
|
52
|
-
word: {
|
|
53
|
-
lineWidth: 0.35,
|
|
54
|
-
stroke: "#000000",
|
|
55
|
-
fontWeight: 700,
|
|
56
|
-
shadowOffset: [-3, 3],
|
|
57
|
-
shadowColor: "#000000",
|
|
58
|
-
fill: "#ffffff",
|
|
59
|
-
fontFamily: "Bangers",
|
|
60
|
-
bgColor: "#000000",
|
|
61
|
-
bgOffsetWidth: 30,
|
|
62
|
-
bgOffsetHeight: 8,
|
|
63
|
-
fontSize: 54,
|
|
64
|
-
},
|
|
65
|
-
},
|
|
66
|
-
word_by_word: {
|
|
67
|
-
rect: {
|
|
68
|
-
alignItems: "center",
|
|
69
|
-
justifyContent: "center",
|
|
70
|
-
gap: 12,
|
|
71
|
-
},
|
|
72
|
-
word: {
|
|
73
|
-
lineWidth: 0.35,
|
|
74
|
-
stroke: "#000000",
|
|
75
|
-
fontWeight: 700,
|
|
76
|
-
strokeFirst: true,
|
|
77
|
-
shadowOffset: [-2, 2],
|
|
78
|
-
shadowColor: "#000000",
|
|
79
|
-
shadowBlur: 5,
|
|
80
|
-
fontFamily: "Bangers",
|
|
81
|
-
fill: "#FFFFFF",
|
|
82
|
-
bgOffsetWidth: 20,
|
|
83
|
-
bgOffsetHeight: 10,
|
|
84
|
-
fontSize: 54,
|
|
85
|
-
},
|
|
86
|
-
},
|
|
87
|
-
word_by_word_with_bg: {
|
|
88
|
-
rect: {
|
|
89
|
-
alignItems: "center",
|
|
90
|
-
gap: 12,
|
|
91
|
-
padding: [10, 20],
|
|
92
|
-
radius: 10,
|
|
93
|
-
},
|
|
94
|
-
word: {
|
|
95
|
-
lineWidth: 0.35,
|
|
96
|
-
stroke: "#000000",
|
|
97
|
-
fontWeight: 700,
|
|
98
|
-
strokeFirst: true,
|
|
99
|
-
shadowOffset: [-2, 2],
|
|
100
|
-
shadowColor: "#000000",
|
|
101
|
-
shadowBlur: 5,
|
|
102
|
-
fontFamily: "Bangers",
|
|
103
|
-
fill: "#FFFFFF",
|
|
104
|
-
bgOffsetWidth: 20,
|
|
105
|
-
bgOffsetHeight: 10,
|
|
106
|
-
fontSize: 54,
|
|
107
|
-
},
|
|
108
|
-
},
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
export const DEFAULT_CAPTION_COLORS = {
|
|
112
|
-
text: "#000000",
|
|
113
|
-
background: "#FFFFFF",
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
export const DEFAULT_CAPTION_FONT = {
|
|
117
|
-
family: "Poppins",
|
|
118
|
-
size: 48,
|
|
119
|
-
weight: 400,
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
export const TRANSPARENT_COLOR = "#FFFFFF00";
|
|
123
|
-
|
|
124
|
-
export const ELEMENT_TYPES = {
|
|
125
|
-
VIDEO: "video",
|
|
126
|
-
IMAGE: "image",
|
|
127
|
-
AUDIO: "audio",
|
|
128
|
-
TEXT: "text",
|
|
129
|
-
CAPTION: "caption",
|
|
130
|
-
RECT: "rect",
|
|
131
|
-
CIRCLE: "circle",
|
|
132
|
-
ICON: "icon",
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
export const OBJECT_FIT = {
|
|
136
|
-
CONTAIN: "contain",
|
|
137
|
-
COVER: "cover",
|
|
138
|
-
FILL: "fill",
|
|
139
|
-
NONE: "none",
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
export const COLOR_FILTERS = {
|
|
143
|
-
SATURATED: "saturated",
|
|
144
|
-
BRIGHT: "bright",
|
|
145
|
-
VIBRANT: "vibrant",
|
|
146
|
-
RETRO: "retro",
|
|
147
|
-
BLACK_WHITE: "blackWhite",
|
|
148
|
-
SEPIA: "sepia",
|
|
149
|
-
COOL: "cool",
|
|
150
|
-
WARM: "warm",
|
|
151
|
-
CINEMATIC: "cinematic",
|
|
152
|
-
SOFT_GLOW: "softGlow",
|
|
153
|
-
MOODY: "moody",
|
|
154
|
-
DREAMY: "dreamy",
|
|
155
|
-
INVERTED: "inverted",
|
|
156
|
-
VINTAGE: "vintage",
|
|
157
|
-
DRAMATIC: "dramatic",
|
|
158
|
-
FADED: "faded",
|
|
1
|
+
import { CaptionStyle } from "./types";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Constants used throughout the visualizer package.
|
|
5
|
+
* Contains default values, configuration options, and type definitions.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Default background color for scenes
|
|
10
|
+
*/
|
|
11
|
+
export const DEFAULT_BACKGROUND_COLOR = "#000000";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Default position for elements
|
|
15
|
+
*/
|
|
16
|
+
export const DEFAULT_POSITION = {
|
|
17
|
+
x: 0,
|
|
18
|
+
y: 0
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Default timing function for animations
|
|
23
|
+
*/
|
|
24
|
+
export const DEFAULT_TIMING_FUNCTION = "easeInOut";
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Available frame shapes for elements
|
|
28
|
+
*/
|
|
29
|
+
export const FRAME_SHAPE = {
|
|
30
|
+
RECTANGLE: "rectangle",
|
|
31
|
+
CIRCLE: "circle",
|
|
32
|
+
LINE: "line"
|
|
33
|
+
} as const;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Timeline types for different media elements
|
|
37
|
+
*/
|
|
38
|
+
export const TRACK_TYPES = {
|
|
39
|
+
VIDEO: "video",
|
|
40
|
+
AUDIO: "audio",
|
|
41
|
+
CAPTION: "caption",
|
|
42
|
+
SCENE: "scene",
|
|
43
|
+
ELEMENT: "element"
|
|
44
|
+
} as const;
|
|
45
|
+
|
|
46
|
+
export const CAPTION_STYLE: Record<string, CaptionStyle> = {
|
|
47
|
+
highlight_bg: {
|
|
48
|
+
rect: {
|
|
49
|
+
alignItems: "center",
|
|
50
|
+
gap: 2,
|
|
51
|
+
},
|
|
52
|
+
word: {
|
|
53
|
+
lineWidth: 0.35,
|
|
54
|
+
stroke: "#000000",
|
|
55
|
+
fontWeight: 700,
|
|
56
|
+
shadowOffset: [-3, 3],
|
|
57
|
+
shadowColor: "#000000",
|
|
58
|
+
fill: "#ffffff",
|
|
59
|
+
fontFamily: "Bangers",
|
|
60
|
+
bgColor: "#000000",
|
|
61
|
+
bgOffsetWidth: 30,
|
|
62
|
+
bgOffsetHeight: 8,
|
|
63
|
+
fontSize: 54,
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
word_by_word: {
|
|
67
|
+
rect: {
|
|
68
|
+
alignItems: "center",
|
|
69
|
+
justifyContent: "center",
|
|
70
|
+
gap: 12,
|
|
71
|
+
},
|
|
72
|
+
word: {
|
|
73
|
+
lineWidth: 0.35,
|
|
74
|
+
stroke: "#000000",
|
|
75
|
+
fontWeight: 700,
|
|
76
|
+
strokeFirst: true,
|
|
77
|
+
shadowOffset: [-2, 2],
|
|
78
|
+
shadowColor: "#000000",
|
|
79
|
+
shadowBlur: 5,
|
|
80
|
+
fontFamily: "Bangers",
|
|
81
|
+
fill: "#FFFFFF",
|
|
82
|
+
bgOffsetWidth: 20,
|
|
83
|
+
bgOffsetHeight: 10,
|
|
84
|
+
fontSize: 54,
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
word_by_word_with_bg: {
|
|
88
|
+
rect: {
|
|
89
|
+
alignItems: "center",
|
|
90
|
+
gap: 12,
|
|
91
|
+
padding: [10, 20],
|
|
92
|
+
radius: 10,
|
|
93
|
+
},
|
|
94
|
+
word: {
|
|
95
|
+
lineWidth: 0.35,
|
|
96
|
+
stroke: "#000000",
|
|
97
|
+
fontWeight: 700,
|
|
98
|
+
strokeFirst: true,
|
|
99
|
+
shadowOffset: [-2, 2],
|
|
100
|
+
shadowColor: "#000000",
|
|
101
|
+
shadowBlur: 5,
|
|
102
|
+
fontFamily: "Bangers",
|
|
103
|
+
fill: "#FFFFFF",
|
|
104
|
+
bgOffsetWidth: 20,
|
|
105
|
+
bgOffsetHeight: 10,
|
|
106
|
+
fontSize: 54,
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
export const DEFAULT_CAPTION_COLORS = {
|
|
112
|
+
text: "#000000",
|
|
113
|
+
background: "#FFFFFF",
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
export const DEFAULT_CAPTION_FONT = {
|
|
117
|
+
family: "Poppins",
|
|
118
|
+
size: 48,
|
|
119
|
+
weight: 400,
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
export const TRANSPARENT_COLOR = "#FFFFFF00";
|
|
123
|
+
|
|
124
|
+
export const ELEMENT_TYPES = {
|
|
125
|
+
VIDEO: "video",
|
|
126
|
+
IMAGE: "image",
|
|
127
|
+
AUDIO: "audio",
|
|
128
|
+
TEXT: "text",
|
|
129
|
+
CAPTION: "caption",
|
|
130
|
+
RECT: "rect",
|
|
131
|
+
CIRCLE: "circle",
|
|
132
|
+
ICON: "icon",
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
export const OBJECT_FIT = {
|
|
136
|
+
CONTAIN: "contain",
|
|
137
|
+
COVER: "cover",
|
|
138
|
+
FILL: "fill",
|
|
139
|
+
NONE: "none",
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export const COLOR_FILTERS = {
|
|
143
|
+
SATURATED: "saturated",
|
|
144
|
+
BRIGHT: "bright",
|
|
145
|
+
VIBRANT: "vibrant",
|
|
146
|
+
RETRO: "retro",
|
|
147
|
+
BLACK_WHITE: "blackWhite",
|
|
148
|
+
SEPIA: "sepia",
|
|
149
|
+
COOL: "cool",
|
|
150
|
+
WARM: "warm",
|
|
151
|
+
CINEMATIC: "cinematic",
|
|
152
|
+
SOFT_GLOW: "softGlow",
|
|
153
|
+
MOODY: "moody",
|
|
154
|
+
DREAMY: "dreamy",
|
|
155
|
+
INVERTED: "inverted",
|
|
156
|
+
VINTAGE: "vintage",
|
|
157
|
+
DRAMATIC: "dramatic",
|
|
158
|
+
FADED: "faded",
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export const EVENT_TYPES = {
|
|
162
|
+
PLAYER_UPDATE: "twick:playerUpdate",
|
|
159
163
|
}
|