@twick/visualizer 0.15.8 → 0.15.10

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twick/visualizer",
3
- "version": "0.15.8",
3
+ "version": "0.15.10",
4
4
  "license": "https://github.com/ncounterspecialist/twick/blob/main/LICENSE.md",
5
5
  "scripts": {
6
6
  "start": "twick editor --projectFile ./src/live.tsx",
@@ -22,18 +22,18 @@
22
22
  },
23
23
  "dependencies": {
24
24
  "@preact/signals": "^1.2.1",
25
- "@twick/2d": "^0.15.8",
26
- "@twick/core": "^0.15.8",
27
- "@twick/renderer": "^0.15.8",
28
- "@twick/vite-plugin": "^0.15.8",
25
+ "@twick/2d": "^0.15.10",
26
+ "@twick/core": "^0.15.10",
27
+ "@twick/renderer": "^0.15.10",
28
+ "@twick/vite-plugin": "^0.15.10",
29
29
  "date-fns": "^4.1.0",
30
30
  "preact": "^10.19.2",
31
31
  "crelt": "^1.0.6",
32
- "@twick/media-utils": "0.15.8"
32
+ "@twick/media-utils": "0.15.10"
33
33
  },
34
34
  "devDependencies": {
35
- "@twick/cli": "^0.15.8",
36
- "@twick/ui": "^0.15.8",
35
+ "@twick/cli": "^0.15.10",
36
+ "@twick/ui": "^0.15.10",
37
37
  "typescript": "5.4.2",
38
38
  "typedoc": "^0.25.8",
39
39
  "typedoc-plugin-markdown": "^3.17.1",
@@ -177,6 +177,7 @@ export function* makeSceneTrack({
177
177
  containerRef: frameRef,
178
178
  element: sceneElement,
179
179
  view,
180
+ containerProps: track.containerProps,
180
181
  });
181
182
  }
182
183
  yield frameRef().remove();
@@ -89,7 +89,7 @@ export const CaptionElement = {
89
89
  * });
90
90
  * ```
91
91
  */
92
- *create({ containerRef, caption }: ElementParams) {
92
+ *create({ containerRef, caption, containerProps }: ElementParams) {
93
93
  const words = splitPhraseTiming(caption);
94
94
  let phraseStart = 0;
95
95
  if (words?.length) {
@@ -106,6 +106,13 @@ export const CaptionElement = {
106
106
  idx: 0,
107
107
  prevTime: phraseStart,
108
108
  };
109
+
110
+ // Set container properties
111
+ containerRef().maxWidth(containerProps?.maxWidth ?? "95%");
112
+ containerRef().wrap(containerProps?.wrap ?? "wrap");
113
+ containerRef().justifyContent(containerProps?.justifyContent ?? "center");
114
+ containerRef().alignItems(containerProps?.alignItems ?? "center");
115
+
109
116
  for (const word of words) {
110
117
  wordsState.props.push(caption.props);
111
118
  const textRef = createRef<Txt>();
@@ -141,6 +141,7 @@ export type CaptionProps = {
141
141
  bgMargin?: [number, number];
142
142
  bgRadius?: number;
143
143
  bgPadding?: [number, number];
144
+ maxWidth?: number;
144
145
  x?: number;
145
146
  y?: number;
146
147
  };
@@ -198,6 +199,7 @@ export type VisualizerTrack = {
198
199
  id: string;
199
200
  type: string;
200
201
  elements: VisualizerElement[];
202
+ containerProps?: ContainerProps;
201
203
  props?: {
202
204
  capStyle?: string;
203
205
  bgOpacity?: number;
@@ -219,6 +221,17 @@ export type VisualizerTrack = {
219
221
  };
220
222
  };
221
223
 
224
+ /**
225
+ * Container properties for layout and positioning of elements.
226
+ * Controls the layout and positioning of elements in the container.
227
+ */
228
+ export type ContainerProps = {
229
+ maxWidth?: number;
230
+ wrap?: "wrap" | "nowrap" | "wrap-reverse";
231
+ justifyContent?: "flex-start" | "flex-end" | "center" | "space-between" | "space-around" | "space-evenly";
232
+ alignItems?: "flex-start" | "flex-end" | "center" | "stretch" | "baseline";
233
+ };
234
+
222
235
  /**
223
236
  * Parameters for creating elements in the visualizer scene.
224
237
  * Contains all necessary references and configuration for element creation.
@@ -229,6 +242,7 @@ export type ElementParams = {
229
242
  element?: VisualizerElement;
230
243
  caption?: Caption;
231
244
  waitOnStart?: boolean;
245
+ containerProps?: ContainerProps;
232
246
  };
233
247
 
234
248
  /**
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Shim for @twick/2d/lib/jsx-dev-runtime when the installed @twick/2d
3
+ * doesn't export it. Re-exports jsx as jsxDEV from the main package.
4
+ */
5
+ export { Fragment, jsx as jsxDEV } from "@twick/2d";