@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
package/src/helpers/types.ts
CHANGED
|
@@ -1,241 +1,242 @@
|
|
|
1
|
-
import { View2D } from "@twick/2d";
|
|
2
|
-
import { Reference, ThreadGenerator, Vector2 } from "@twick/core";
|
|
3
|
-
|
|
4
|
-
export type VideoInput = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
};
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
};
|
|
1
|
+
import { View2D } from "@twick/2d";
|
|
2
|
+
import { Reference, ThreadGenerator, Vector2 } from "@twick/core";
|
|
3
|
+
|
|
4
|
+
export type VideoInput = {
|
|
5
|
+
playerId: string,
|
|
6
|
+
backgroundColor: string;
|
|
7
|
+
properties: {
|
|
8
|
+
width: number;
|
|
9
|
+
height: number;
|
|
10
|
+
};
|
|
11
|
+
tracks: VisualizerTrack[];
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export type MediaType = "video" | "image";
|
|
15
|
+
|
|
16
|
+
export type ObjectFit = "contain" | "cover" | "fill" | "none";
|
|
17
|
+
|
|
18
|
+
export type SizeVector = {
|
|
19
|
+
x: number;
|
|
20
|
+
y: number;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export type Size = {
|
|
24
|
+
width: number;
|
|
25
|
+
height: number;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export type SizeArray = [number, number];
|
|
29
|
+
|
|
30
|
+
export type Position = {
|
|
31
|
+
x: number;
|
|
32
|
+
y: number;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export type FrameEffect = {
|
|
36
|
+
name: string;
|
|
37
|
+
s: number;
|
|
38
|
+
e: number;
|
|
39
|
+
props: FrameEffectProps;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export type FrameEffectProps = {
|
|
43
|
+
frameSize: SizeArray;
|
|
44
|
+
frameShape: "circle" | "rect";
|
|
45
|
+
framePosition: Position;
|
|
46
|
+
radius: number;
|
|
47
|
+
objectFit: ObjectFit;
|
|
48
|
+
transitionDuration: number;
|
|
49
|
+
transitionEasing?: string;
|
|
50
|
+
elementPosition: Position;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export type CaptionStyle = {
|
|
54
|
+
rect: {
|
|
55
|
+
alignItems?: string;
|
|
56
|
+
gap?: number;
|
|
57
|
+
justifyContent?: string;
|
|
58
|
+
padding?: [number, number];
|
|
59
|
+
radius?: number;
|
|
60
|
+
};
|
|
61
|
+
word: {
|
|
62
|
+
lineWidth: number;
|
|
63
|
+
stroke: string;
|
|
64
|
+
fontWeight: number;
|
|
65
|
+
shadowOffset?: number[];
|
|
66
|
+
shadowColor?: string;
|
|
67
|
+
shadowBlur?: number;
|
|
68
|
+
fill: string;
|
|
69
|
+
fontFamily: string;
|
|
70
|
+
bgColor?: string;
|
|
71
|
+
bgOffsetWidth?: number;
|
|
72
|
+
bgOffsetHeight?: number;
|
|
73
|
+
fontSize: number;
|
|
74
|
+
strokeFirst?: boolean;
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
export type Caption = {
|
|
79
|
+
t: string;
|
|
80
|
+
s: number;
|
|
81
|
+
e: number;
|
|
82
|
+
capStyle?: string;
|
|
83
|
+
props?: CaptionProps;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export type CaptionProps = {
|
|
87
|
+
colors: CaptionColors;
|
|
88
|
+
font: CaptionFont;
|
|
89
|
+
bgOpacity?: number;
|
|
90
|
+
bgOffsetWidth?: number;
|
|
91
|
+
bgOffsetHeight?: number;
|
|
92
|
+
bgMargin?: [number, number];
|
|
93
|
+
bgRadius?: number;
|
|
94
|
+
bgPadding?: [number, number];
|
|
95
|
+
x?: number;
|
|
96
|
+
y?: number;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
export type CaptionColors = {
|
|
100
|
+
text?: string;
|
|
101
|
+
background?: string;
|
|
102
|
+
highlight?: string;
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
export type CaptionFont = {
|
|
106
|
+
family?: string;
|
|
107
|
+
size?: number;
|
|
108
|
+
weight?: number;
|
|
109
|
+
style?: string;
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
export type VisualizerElement = {
|
|
113
|
+
id: string;
|
|
114
|
+
trackId?: string;
|
|
115
|
+
frame?: any;
|
|
116
|
+
props?: any;
|
|
117
|
+
objectFit?: "contain" | "cover" | "fill";
|
|
118
|
+
type?: string;
|
|
119
|
+
s: number;
|
|
120
|
+
e: number;
|
|
121
|
+
backgroundColor?: string;
|
|
122
|
+
animation?: AnimationProps;
|
|
123
|
+
textEffect: TextEffectProps;
|
|
124
|
+
frameEffects?: FrameEffect[];
|
|
125
|
+
scale?: number;
|
|
126
|
+
t?: string;
|
|
127
|
+
hWords?: any;
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
export type VisualizerTrack = {
|
|
131
|
+
id: string;
|
|
132
|
+
type: string;
|
|
133
|
+
elements: VisualizerElement[];
|
|
134
|
+
props?: {
|
|
135
|
+
capStyle?: string;
|
|
136
|
+
bgOpacity?: number;
|
|
137
|
+
x?: number;
|
|
138
|
+
y?: number;
|
|
139
|
+
colors?: {
|
|
140
|
+
text?: string;
|
|
141
|
+
background?: string;
|
|
142
|
+
highlight?: string;
|
|
143
|
+
};
|
|
144
|
+
font?: {
|
|
145
|
+
family?: string;
|
|
146
|
+
size?: number;
|
|
147
|
+
weight?: number;
|
|
148
|
+
style?: string;
|
|
149
|
+
};
|
|
150
|
+
captionProps?: CaptionProps;
|
|
151
|
+
};
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
export type ElementParams = {
|
|
155
|
+
view: View2D;
|
|
156
|
+
containerRef: Reference<any>;
|
|
157
|
+
element?: VisualizerElement;
|
|
158
|
+
caption?: Caption;
|
|
159
|
+
waitOnStart?: boolean;
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
export interface Element<Params = ElementParams> {
|
|
163
|
+
name: string;
|
|
164
|
+
create(params: Params): ThreadGenerator;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export type TextEffectParams = {
|
|
168
|
+
elementRef: Reference<any>;
|
|
169
|
+
interval?: number;
|
|
170
|
+
duration?: number;
|
|
171
|
+
bufferTime?: number;
|
|
172
|
+
delay?: number;
|
|
173
|
+
direction?: "left" | "right" | "center";
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
export type TextEffectProps = {
|
|
177
|
+
name: string;
|
|
178
|
+
interval?: number;
|
|
179
|
+
duration?: number;
|
|
180
|
+
bufferTime?: number;
|
|
181
|
+
delay?: number;
|
|
182
|
+
direction?: "left" | "right" | "center";
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
export interface TextEffect<Params = TextEffectParams> {
|
|
186
|
+
name: string;
|
|
187
|
+
run(params: Params): Generator;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
export type AnimationParams = {
|
|
191
|
+
elementRef: Reference<any>;
|
|
192
|
+
containerRef?: Reference<any>;
|
|
193
|
+
view: View2D;
|
|
194
|
+
interval?: number;
|
|
195
|
+
duration?: number;
|
|
196
|
+
intensity?: number;
|
|
197
|
+
mode?: "in" | "out";
|
|
198
|
+
animate?: "enter" | "exit" | "both";
|
|
199
|
+
direction?: "left" | "right" | "center" | "up" | "down";
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
export type AnimationProps = {
|
|
203
|
+
name: string;
|
|
204
|
+
interval?: number;
|
|
205
|
+
duration?: number;
|
|
206
|
+
intensity?: number;
|
|
207
|
+
mode?: "in" | "out";
|
|
208
|
+
animate?: "enter" | "exit" | "both";
|
|
209
|
+
direction?: "left" | "right" | "center" | "up" | "down";
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
export interface Animation<Params = AnimationParams> {
|
|
213
|
+
name: string;
|
|
214
|
+
run(params: Params): ThreadGenerator;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
export type FrameEffectParams = {
|
|
218
|
+
elementRef: Reference<any>;
|
|
219
|
+
containerRef?: Reference<any>;
|
|
220
|
+
initFrameState: FrameState;
|
|
221
|
+
frameEffect: FrameEffect;
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
export interface FrameEffectPlugin<Params = FrameEffectParams> {
|
|
225
|
+
name: string;
|
|
226
|
+
run(params: Params): ThreadGenerator;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
export type FrameState = {
|
|
230
|
+
frame: {
|
|
231
|
+
size: Vector2;
|
|
232
|
+
pos: Vector2;
|
|
233
|
+
radius: number;
|
|
234
|
+
scale: Vector2;
|
|
235
|
+
rotation: number;
|
|
236
|
+
};
|
|
237
|
+
element: {
|
|
238
|
+
size: Vector2;
|
|
239
|
+
pos: Vector2;
|
|
240
|
+
scale: Vector2;
|
|
241
|
+
};
|
|
242
|
+
};
|
package/src/helpers/utils.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
export const hexToRGB = (color: string) => {
|
|
2
|
-
// Remove leading '#' if present
|
|
3
|
-
let hex = color.replace(/^#/, '');
|
|
4
|
-
|
|
5
|
-
// Handle shorthand hex (e.g., #abc)
|
|
6
|
-
if (hex.length === 3) {
|
|
7
|
-
hex = hex.split('').map(c => c + c).join('');
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
if (hex.length !== 6) {
|
|
11
|
-
throw new Error('Invalid hex color');
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const num = parseInt(hex, 16);
|
|
15
|
-
const r = (num >> 16) & 255;
|
|
16
|
-
const g = (num >> 8) & 255;
|
|
17
|
-
const b = num & 255;
|
|
18
|
-
|
|
19
|
-
return { r, g, b };
|
|
1
|
+
export const hexToRGB = (color: string) => {
|
|
2
|
+
// Remove leading '#' if present
|
|
3
|
+
let hex = color.replace(/^#/, '');
|
|
4
|
+
|
|
5
|
+
// Handle shorthand hex (e.g., #abc)
|
|
6
|
+
if (hex.length === 3) {
|
|
7
|
+
hex = hex.split('').map(c => c + c).join('');
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
if (hex.length !== 6) {
|
|
11
|
+
throw new Error('Invalid hex color');
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const num = parseInt(hex, 16);
|
|
15
|
+
const r = (num >> 16) & 255;
|
|
16
|
+
const g = (num >> 8) & 255;
|
|
17
|
+
const b = num & 255;
|
|
18
|
+
|
|
19
|
+
return { r, g, b };
|
|
20
20
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
// Types
|
|
2
|
-
export * from './helpers/types';
|
|
3
|
-
|
|
4
|
-
// Components
|
|
5
|
-
export * from './visualizer';
|
|
6
|
-
|
|
1
|
+
// Types
|
|
2
|
+
export * from './helpers/types';
|
|
3
|
+
|
|
4
|
+
// Components
|
|
5
|
+
export * from './visualizer';
|
|
6
|
+
|
package/src/live.tsx
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { makeProject } from "@twick/core";
|
|
2
|
-
import { scene } from "./visualizer";
|
|
3
|
-
import { sample } from "./sample";
|
|
4
|
-
|
|
5
|
-
export default makeProject({
|
|
6
|
-
scenes: [scene],
|
|
7
|
-
variables: sample,
|
|
8
|
-
settings: {
|
|
9
|
-
shared: {
|
|
10
|
-
size: {
|
|
11
|
-
x: sample.input.properties.width,
|
|
12
|
-
y: sample.input.properties.height,
|
|
13
|
-
},
|
|
14
|
-
},
|
|
15
|
-
},
|
|
16
|
-
});
|
|
1
|
+
import { makeProject } from "@twick/core";
|
|
2
|
+
import { scene } from "./visualizer";
|
|
3
|
+
import { sample } from "./sample";
|
|
4
|
+
|
|
5
|
+
export default makeProject({
|
|
6
|
+
scenes: [scene],
|
|
7
|
+
variables: sample,
|
|
8
|
+
settings: {
|
|
9
|
+
shared: {
|
|
10
|
+
size: {
|
|
11
|
+
x: sample.input.properties.width,
|
|
12
|
+
y: sample.input.properties.height,
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
});
|
package/src/project.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { makeProject } from "@twick/core";
|
|
2
|
-
import { scene } from "./visualizer";
|
|
3
|
-
|
|
4
|
-
export default makeProject({
|
|
5
|
-
scenes: [scene],
|
|
6
|
-
});
|
|
1
|
+
import { makeProject } from "@twick/core";
|
|
2
|
+
import { scene } from "./visualizer";
|
|
3
|
+
|
|
4
|
+
export default makeProject({
|
|
5
|
+
scenes: [scene],
|
|
6
|
+
});
|