@tongue-core/ui 0.1.0-rc.2 → 0.1.0-rc.3

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/README.md CHANGED
@@ -38,6 +38,10 @@ player.fit(canvas.clientWidth); // render a
38
38
  const bitmap = await player.preview(900, 160); // a thumbnail, when the workers are free
39
39
  ```
40
40
 
41
+ The picture keeps the film's shape in whatever box the page gives the canvas: unless the page
42
+ sets its own `object-fit`, the player sets `contain`, so a box of another shape letterboxes the
43
+ frame instead of stretching it.
44
+
41
45
  A build is static files: `build.json`, `film.json`, `scenes/*.js`, `assets/…` (`tongue build`
42
46
  writes one). The player fetches the manifests and bundles, then the asset files frames need, nearest
43
47
  the playhead first, each checked against its hash. **A frame is drawn only once every file it needs
@@ -31,6 +31,10 @@ const SETTLE_MS = 90;
31
31
  export function createPlayer(options) {
32
32
  const canvas = options.canvas;
33
33
  const ctx = canvas.getContext("2d");
34
+ // The picture keeps the film's shape in whatever box the page gives the canvas: letterboxed,
35
+ // never stretched. A page that sets its own object-fit keeps it.
36
+ if (canvas.style.objectFit === "")
37
+ canvas.style.objectFit = "contain";
34
38
  if (!ctx)
35
39
  throw new Error("The player needs a canvas with a 2D context.");
36
40
  const pool = new WorkerPool({ workerUrl: options.workerUrl, workers: options.workers ?? defaultWorkers() });
@@ -46,6 +46,7 @@ export declare const Clip: import("react").NamedExoticComponent<Styled & {
46
46
  /** A transition: the stretch where two clips overlap. */
47
47
  export declare const Transition: import("react").NamedExoticComponent<Styled & {
48
48
  readonly transition: TimelineTransition;
49
+ readonly title?: string;
49
50
  readonly children?: ReactNode;
50
51
  }>;
51
52
  /** The playhead. It moves without React: its frame is a CSS variable on itself, set as reports
@@ -88,6 +89,7 @@ export declare const Timeline: {
88
89
  }>;
89
90
  Transition: import("react").NamedExoticComponent<Styled & {
90
91
  readonly transition: TimelineTransition;
92
+ readonly title?: string;
91
93
  readonly children?: ReactNode;
92
94
  }>;
93
95
  Playhead: typeof Playhead;
@@ -169,7 +169,7 @@ export const Clip = memo(function Clip(props) {
169
169
  /** A transition: the stretch where two clips overlap. */
170
170
  export const Transition = memo(function Transition(props) {
171
171
  const t = props.transition;
172
- return (_jsx("div", { "data-tl-transition": "", "data-style": t.style, className: props.className, style: { position: "absolute", top: 0, bottom: 0, left: px("--t-start"), width: px("--t-frames"), contain: "strict", "--t-start": t.start, "--t-frames": t.end - t.start, pointerEvents: "none", ...props.style }, children: props.children }));
172
+ return (_jsx("div", { "data-tl-transition": "", "data-style": t.style, title: props.title, className: props.className, style: { position: "absolute", top: 0, bottom: 0, left: px("--t-start"), width: px("--t-frames"), contain: "strict", "--t-start": t.start, "--t-frames": t.end - t.start, pointerEvents: "none", ...props.style }, children: props.children }));
173
173
  });
174
174
  /** The playhead. It moves without React: its frame is a CSS variable on itself, set as reports
175
175
  * come in. When it moves out of view (playing on, a jump) the view follows it (`follow`, on by
@@ -15,6 +15,8 @@ export interface TimelineClip {
15
15
  export interface TimelineTransition {
16
16
  readonly row: string;
17
17
  readonly style: TransitionDoc["style"];
18
+ /** Everything film.json says about it: a dissolve's noise and edge, a wipe's direction. */
19
+ readonly doc: TransitionDoc;
18
20
  readonly from: string;
19
21
  readonly to: string;
20
22
  /** Film frames [start, end). */
@@ -31,7 +31,7 @@ export function timelineModel(doc) {
31
31
  const transitions = track.transitions.map((t) => {
32
32
  edges.add(t.start);
33
33
  edges.add(t.end);
34
- return { row: track.id, style: t.style, from: t.from, to: t.to, start: t.start, end: t.end };
34
+ return { row: track.id, style: t.style, doc: t, from: t.from, to: t.to, start: t.start, end: t.end };
35
35
  });
36
36
  return { id: track.id, kind: track.kind, clips: rowClips, transitions };
37
37
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tongue-core/ui",
3
- "version": "0.1.0-rc.2",
3
+ "version": "0.1.0-rc.3",
4
4
  "description": "The pieces of a film's interface: the player, the timeline's state and geometry, and unstyled React primitives. Build your own studio from them.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -36,9 +36,9 @@
36
36
  "README.md"
37
37
  ],
38
38
  "dependencies": {
39
- "@tongue-core/engine": "0.1.0-rc.2",
40
- "@tongue-core/film": "0.1.0-rc.2",
41
- "@tongue-core/project": "0.1.0-rc.2"
39
+ "@tongue-core/engine": "0.1.0-rc.3",
40
+ "@tongue-core/film": "0.1.0-rc.3",
41
+ "@tongue-core/project": "0.1.0-rc.3"
42
42
  },
43
43
  "peerDependencies": {
44
44
  "@effect/atom-react": "^4.0.6",