@twick/visualizer 0.14.7 → 0.14.8
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/package.json +7 -7
- package/package.json.bak +7 -7
- package/src/components/track.tsx +17 -35
- package/src/elements/caption.element.tsx +1 -1
- package/src/helpers/constants.ts +86 -86
- package/src/helpers/types.ts +2 -1
- package/src/visualizer.tsx +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twick/visualizer",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.8",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"start": "twick editor --projectFile ./src/live.tsx",
|
|
@@ -13,14 +13,14 @@
|
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"@preact/signals": "^1.2.1",
|
|
16
|
-
"@twick/2d": "0.14.
|
|
17
|
-
"@twick/core": "0.14.
|
|
18
|
-
"@twick/renderer": "0.14.
|
|
19
|
-
"@twick/vite-plugin": "0.14.
|
|
16
|
+
"@twick/2d": "0.14.8",
|
|
17
|
+
"@twick/core": "0.14.8",
|
|
18
|
+
"@twick/renderer": "0.14.8",
|
|
19
|
+
"@twick/vite-plugin": "0.14.8",
|
|
20
20
|
"date-fns": "^4.1.0",
|
|
21
21
|
"preact": "^10.19.2",
|
|
22
22
|
"crelt": "^1.0.6",
|
|
23
|
-
"@twick/media-utils": "0.14.
|
|
23
|
+
"@twick/media-utils": "0.14.8"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@twick/cli": "0.14.0",
|
|
@@ -29,6 +29,6 @@
|
|
|
29
29
|
"typedoc": "^0.25.8",
|
|
30
30
|
"typedoc-plugin-markdown": "^3.17.1",
|
|
31
31
|
"vite-plugin-dts": "^3.7.3",
|
|
32
|
-
"vite": "^5.4.
|
|
32
|
+
"vite": "^5.4.21"
|
|
33
33
|
}
|
|
34
34
|
}
|
package/package.json.bak
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twick/visualizer",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.8",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"start": "twick editor --projectFile ./src/live.tsx",
|
|
@@ -13,14 +13,14 @@
|
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"@preact/signals": "^1.2.1",
|
|
16
|
-
"@twick/2d": "0.14.
|
|
17
|
-
"@twick/core": "0.14.
|
|
18
|
-
"@twick/renderer": "0.14.
|
|
19
|
-
"@twick/vite-plugin": "0.14.
|
|
16
|
+
"@twick/2d": "0.14.8",
|
|
17
|
+
"@twick/core": "0.14.8",
|
|
18
|
+
"@twick/renderer": "0.14.8",
|
|
19
|
+
"@twick/vite-plugin": "0.14.8",
|
|
20
20
|
"date-fns": "^4.1.0",
|
|
21
21
|
"preact": "^10.19.2",
|
|
22
22
|
"crelt": "^1.0.6",
|
|
23
|
-
"@twick/media-utils": "0.14.
|
|
23
|
+
"@twick/media-utils": "0.14.8"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@twick/cli": "0.14.0",
|
|
@@ -29,6 +29,6 @@
|
|
|
29
29
|
"typedoc": "^0.25.8",
|
|
30
30
|
"typedoc-plugin-markdown": "^3.17.1",
|
|
31
31
|
"vite-plugin-dts": "^3.7.3",
|
|
32
|
-
"vite": "^5.4.
|
|
32
|
+
"vite": "^5.4.21"
|
|
33
33
|
}
|
|
34
34
|
}
|
package/src/components/track.tsx
CHANGED
|
@@ -93,6 +93,8 @@ export function* makeCaptionTrack({
|
|
|
93
93
|
|
|
94
94
|
const tProps = track?.props;
|
|
95
95
|
|
|
96
|
+
const applyToAll = tProps?.applyToAll ?? false;
|
|
97
|
+
|
|
96
98
|
const trackDefaultProps =
|
|
97
99
|
(CAPTION_STYLE[tProps?.capStyle ?? ""] || {}).word || {};
|
|
98
100
|
|
|
@@ -107,40 +109,17 @@ export function* makeCaptionTrack({
|
|
|
107
109
|
justifyContent: rectStyle.justifyContent as any,
|
|
108
110
|
alignItems: rectStyle.alignItems as any,
|
|
109
111
|
};
|
|
112
|
+
|
|
113
|
+
const phraseColors = applyToAll ? tProps?.colors : eProps?.colors ?? tProps?.colors ?? DEFAULT_CAPTION_COLORS;
|
|
114
|
+
|
|
110
115
|
const phraseProps = {
|
|
111
116
|
...trackDefaultProps,
|
|
112
|
-
colors: {
|
|
113
|
-
text:
|
|
114
|
-
eProps?.colors?.text ??
|
|
115
|
-
tProps?.colors?.text ??
|
|
116
|
-
DEFAULT_CAPTION_COLORS.text,
|
|
117
|
-
background:
|
|
118
|
-
eProps?.colors?.background ??
|
|
119
|
-
tProps?.colors?.background ??
|
|
120
|
-
DEFAULT_CAPTION_COLORS.background,
|
|
121
|
-
},
|
|
122
|
-
font: {
|
|
123
|
-
family:
|
|
124
|
-
eProps?.font?.family ??
|
|
125
|
-
tProps?.font?.family ??
|
|
126
|
-
DEFAULT_CAPTION_FONT.family,
|
|
127
|
-
size:
|
|
128
|
-
eProps?.font?.size ?? tProps?.font?.size ?? DEFAULT_CAPTION_FONT.size,
|
|
129
|
-
weight:
|
|
130
|
-
eProps?.font?.weight ??
|
|
131
|
-
tProps?.font?.weight ??
|
|
132
|
-
DEFAULT_CAPTION_FONT.weight,
|
|
133
|
-
},
|
|
134
|
-
fill:
|
|
135
|
-
eProps?.colors?.text ??
|
|
136
|
-
tProps?.colors?.text ??
|
|
137
|
-
DEFAULT_CAPTION_COLORS.text,
|
|
138
|
-
bgColor:
|
|
139
|
-
eProps?.colors?.background ??
|
|
140
|
-
tProps?.colors?.background ??
|
|
141
|
-
DEFAULT_CAPTION_COLORS.background,
|
|
142
|
-
bgOpacity: eProps?.bgOpacity ?? tProps?.bgOpacity ?? 1,
|
|
143
117
|
...(tProps?.captionProps || {}),
|
|
118
|
+
colors: phraseColors,
|
|
119
|
+
font: applyToAll ? tProps?.font : eProps?.font ?? tProps?.font ?? DEFAULT_CAPTION_FONT,
|
|
120
|
+
fill: phraseColors.text,
|
|
121
|
+
bgColor: phraseColors.bgColor,
|
|
122
|
+
bgOpacity: tProps?.bgOpacity ?? 1,
|
|
144
123
|
};
|
|
145
124
|
|
|
146
125
|
yield* waitFor(element?.s - prevTime);
|
|
@@ -150,13 +129,16 @@ export function* makeCaptionTrack({
|
|
|
150
129
|
ref={phraseRef}
|
|
151
130
|
key={element.id}
|
|
152
131
|
{...mappedRectStyle}
|
|
153
|
-
x={eProps?.x ?? tProps?.x}
|
|
154
|
-
y={eProps?.y ?? tProps?.y}
|
|
132
|
+
x={applyToAll ? tProps?.x : eProps?.x ?? tProps?.x}
|
|
133
|
+
y={applyToAll ? tProps?.y : eProps?.y ?? tProps?.y}
|
|
155
134
|
layout
|
|
156
135
|
/>
|
|
157
136
|
);
|
|
158
137
|
if (tProps?.capStyle === "word_by_word_with_bg") {
|
|
159
|
-
const _color = new Color({
|
|
138
|
+
const _color = new Color({
|
|
139
|
+
...hexToRGB(phraseProps.bgColor),
|
|
140
|
+
a: phraseProps?.bgOpacity ?? 1,
|
|
141
|
+
});
|
|
160
142
|
phraseRef().fill(_color);
|
|
161
143
|
}
|
|
162
144
|
yield* elementController.get("caption")?.create({
|
|
@@ -231,7 +213,7 @@ export function* makeElementTrack({
|
|
|
231
213
|
} catch (error) {
|
|
232
214
|
logger("Error creating element track", error);
|
|
233
215
|
}
|
|
234
|
-
|
|
216
|
+
|
|
235
217
|
yield* all(...sequence);
|
|
236
218
|
yield elementTrackRef().remove();
|
|
237
219
|
}
|
|
@@ -116,7 +116,7 @@ export const CaptionElement = {
|
|
|
116
116
|
if (caption.capStyle == "highlight_bg") {
|
|
117
117
|
const bgContainerRef = createRef();
|
|
118
118
|
const childTextRef = createRef();
|
|
119
|
-
const _color = new Color({...hexToRGB(captionProps.colors.
|
|
119
|
+
const _color = new Color({...hexToRGB(captionProps.colors.bgColor), a: captionProps?.bgOpacity ?? 1});
|
|
120
120
|
containerRef().add(
|
|
121
121
|
<Rect
|
|
122
122
|
ref={bgContainerRef}
|
package/src/helpers/constants.ts
CHANGED
|
@@ -15,7 +15,7 @@ export const DEFAULT_BACKGROUND_COLOR = "#000000";
|
|
|
15
15
|
*/
|
|
16
16
|
export const DEFAULT_POSITION = {
|
|
17
17
|
x: 0,
|
|
18
|
-
y: 0
|
|
18
|
+
y: 0,
|
|
19
19
|
};
|
|
20
20
|
|
|
21
21
|
/**
|
|
@@ -29,7 +29,7 @@ export const DEFAULT_TIMING_FUNCTION = "easeInOut";
|
|
|
29
29
|
export const FRAME_SHAPE = {
|
|
30
30
|
RECTANGLE: "rectangle",
|
|
31
31
|
CIRCLE: "circle",
|
|
32
|
-
LINE: "line"
|
|
32
|
+
LINE: "line",
|
|
33
33
|
} as const;
|
|
34
34
|
|
|
35
35
|
/**
|
|
@@ -40,104 +40,104 @@ export const TRACK_TYPES = {
|
|
|
40
40
|
AUDIO: "audio",
|
|
41
41
|
CAPTION: "caption",
|
|
42
42
|
SCENE: "scene",
|
|
43
|
-
ELEMENT: "element"
|
|
43
|
+
ELEMENT: "element",
|
|
44
44
|
} as const;
|
|
45
45
|
|
|
46
46
|
export const CAPTION_STYLE: Record<string, CaptionStyle> = {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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
|
-
},
|
|
47
|
+
highlight_bg: {
|
|
48
|
+
rect: {
|
|
49
|
+
alignItems: "center",
|
|
50
|
+
gap: 2,
|
|
65
51
|
},
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
shadowColor: "#000000",
|
|
79
|
-
shadowBlur: 5,
|
|
80
|
-
fontFamily: "Bangers",
|
|
81
|
-
fill: "#FFFFFF",
|
|
82
|
-
bgOffsetWidth: 20,
|
|
83
|
-
bgOffsetHeight: 10,
|
|
84
|
-
fontSize: 54,
|
|
85
|
-
},
|
|
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: "#444444",
|
|
61
|
+
bgOffsetWidth: 30,
|
|
62
|
+
bgOffsetHeight: 8,
|
|
63
|
+
fontSize: 50,
|
|
86
64
|
},
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
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
|
-
},
|
|
65
|
+
},
|
|
66
|
+
word_by_word: {
|
|
67
|
+
rect: {
|
|
68
|
+
alignItems: "center",
|
|
69
|
+
justifyContent: "center",
|
|
70
|
+
gap: 8,
|
|
108
71
|
},
|
|
109
|
-
|
|
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: 50,
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
word_by_word_with_bg: {
|
|
88
|
+
rect: {
|
|
89
|
+
alignItems: "center",
|
|
90
|
+
gap: 8,
|
|
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: 50,
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
110
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
111
|
+
export const DEFAULT_CAPTION_COLORS = {
|
|
112
|
+
text: "#000000",
|
|
113
|
+
bgColor: "#444444",
|
|
114
|
+
};
|
|
115
115
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
116
|
+
export const DEFAULT_CAPTION_FONT = {
|
|
117
|
+
family: "Poppins",
|
|
118
|
+
size: 48,
|
|
119
|
+
weight: 400,
|
|
120
|
+
};
|
|
121
121
|
|
|
122
|
-
|
|
122
|
+
export const TRANSPARENT_COLOR = "#FFFFFF00";
|
|
123
123
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
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
134
|
|
|
135
135
|
export const OBJECT_FIT = {
|
|
136
136
|
CONTAIN: "contain",
|
|
137
137
|
COVER: "cover",
|
|
138
138
|
FILL: "fill",
|
|
139
139
|
NONE: "none",
|
|
140
|
-
}
|
|
140
|
+
};
|
|
141
141
|
|
|
142
142
|
export const COLOR_FILTERS = {
|
|
143
143
|
SATURATED: "saturated",
|
|
@@ -156,8 +156,8 @@ export const COLOR_FILTERS = {
|
|
|
156
156
|
VINTAGE: "vintage",
|
|
157
157
|
DRAMATIC: "dramatic",
|
|
158
158
|
FADED: "faded",
|
|
159
|
-
}
|
|
159
|
+
};
|
|
160
160
|
|
|
161
161
|
export const EVENT_TYPES = {
|
|
162
162
|
PLAYER_UPDATE: "twick:playerUpdate",
|
|
163
|
-
}
|
|
163
|
+
};
|
package/src/helpers/types.ts
CHANGED
|
@@ -151,7 +151,7 @@ export type CaptionProps = {
|
|
|
151
151
|
*/
|
|
152
152
|
export type CaptionColors = {
|
|
153
153
|
text?: string;
|
|
154
|
-
|
|
154
|
+
bgColor?: string;
|
|
155
155
|
highlight?: string;
|
|
156
156
|
};
|
|
157
157
|
|
|
@@ -214,6 +214,7 @@ export type VisualizerTrack = {
|
|
|
214
214
|
weight?: number;
|
|
215
215
|
style?: string;
|
|
216
216
|
};
|
|
217
|
+
applyToAll?: boolean;
|
|
217
218
|
captionProps?: CaptionProps;
|
|
218
219
|
};
|
|
219
220
|
};
|
package/src/visualizer.tsx
CHANGED
|
@@ -120,7 +120,7 @@ export const scene = makeScene2D("scene", function* (view: View2D) {
|
|
|
120
120
|
| string
|
|
121
121
|
| null;
|
|
122
122
|
if (input) {
|
|
123
|
-
|
|
123
|
+
console.log("Scene updated", { playerId, input });
|
|
124
124
|
// Add background rectangle with specified or default color
|
|
125
125
|
yield view.add(
|
|
126
126
|
<Rect
|