# Results and publishing

> What one Scenlit run writes: films, posts, carousels, thumbnails and screenshots. Export MP4 and GIF, put the player on your site, or publish to scenlit.dev.

## In your codebase

- **Scenes live where the feature lives.** Besides `.scenlit/scenes/`, any `*.scene.mjs`, `*.scene.js` or
  `*.scene.ts` in the project is found by its name: `src/checkout/checkout.scene.ts` runs as `scenlit run checkout`.
  TypeScript scenes need Node 22.18 or newer.
- **Typed.** `import type { Scene } from "scenlit"`, or `export default defineScene({ ... })`. The settings file
  points at a schema, so your editor completes and checks it.
- **Write, save, watch.** `npx scenlit dev checkout` runs the scene, serves the film on a local address, and runs
  again whenever you save the scene, the settings, the style sheet or a component. The page reloads itself.
- **Reuse your tests' login.** `"sessions": { "member": "playwright/.auth/user.json" }` starts scenes from the
  saved login your Playwright tests already make.
- **One command for the team.** `init` adds `npm run films` and `npm run films:check` to `package.json`.
- **From code.** Everything the command line does is exported: `import { project, runScene, writeFilm } from "scenlit"`.

### Where the results go

Everything is written to `.scenlit/output/<scene>/`. To have a result in your project as well, name its place. A
copy is made there on every run, so the film on your site and the picture in your docs are new whenever the app is.

```js
export default {
  save: {
    film: "public/films/checkout",        // the player and all it needs: a folder for any web host
    video: "public/videos/checkout.mp4",  // the MP4 when it is exported, with its captions and poster beside it
    posts: "marketing/checkout",
    guide: "docs/guides/checkout",
    thumbnail: "public/checkout.png",
  },
  async run({ shot }) {
    await shot("paid", { save: "docs/img/paid.png" }); // one picture, where the docs want it
  },
};
```

The same `save` in `.scenlit/config.json` is for every scene: `{ "film": "public/films/{scene}" }`. `{scene}` is the
scene's name and `{shape}` the frame's shape; `video` can also name a place for each shape,
`{ wide: "…", square: "…" }`. Nothing already in a folder of yours is removed.

For one result once, `--out` puts a copy where you say: `scenlit export checkout --out public/checkout.mp4`,
`scenlit frames checkout --at 12 --out docs/img/step.jpg`, `scenlit sheet checkout --out review/`.

## Posts, pieces and carousels

```js
posts: [
  { name: "paid", lead: "The order went through.", key: "We watched it happen.", shot: "paid" },
  { name: "pieces", lead: "The list, and the customer:", key: "side by side.", shots: ["list", "customer"], tilt: true },
],
carousels: [{ name: "tour", slides: [{ lead: "...", key: "...", line: "...", shot: "list" }, ...] }],
```

- `shot` cropped to one element shows that piece of the product on its own, with no browser around it.
- `shots` overlaps two or three pieces; `tilt` turns them a little in space.
- A carousel is written as one PNG per slide and one PDF, which is what LinkedIn takes as a document post.

## Thumbnails

Every run writes `thumbnail.png` (1280×720): the scene's title beside its first named picture. Set
`thumbnail: { lead, key, shot }` in the scene to choose the words and the picture, or `thumbnail: false`. Posts
can also ask for the `thumb` size.

## Export for a place

`npx scenlit export checkout --for youtube` writes the right shape and the files that place wants into
`.scenlit/output/checkout/export/youtube/`:

| `--for` | What you get |
|---|---|
| `web` | The film with its player, as a folder to put on any web host and embed like a video. No ffmpeg needed |
| `youtube` | 1920×1080 MP4, thumbnail, captions (`.vtt`, `.srt`), transcript |
| `linkedin` | 1080×1080 MP4 with the captions drawn in, captions file |
| `x` | 1920×1080 MP4, captions file |
| `reels` | 1080×1920 MP4 for Reels, Shorts and TikTok |
| `docs` | MP4, poster, captions, and the `<video>` tag to paste (`embed.html`) |
| `readme` | A GIF, 960 wide |
| `all` | Every one of them |

`--4k` doubles the size, `--fps 60` smooths motion, `--blur` adds motion blur (five times slower to make).

### On your own site, with the player

`--for web` writes `export/web/`: `index.html` (the player), the pictures and narration it needs, and `embed.html`
with the tag to paste. Put the folder on any static host and embed it:

```html
<iframe src="https://your-site.example/films/checkout/index.html"
  style="width:100%;aspect-ratio:16/9;border:0;border-radius:12px" allow="fullscreen; autoplay" loading="lazy"></iframe>
```

It waits on the title card with a play button, has a scrubber and full screen, and stays sharp at any size
because it shows the frozen pages, not a video. A thirty-second film is about 2 MB. `index.html?shape=square` or
`?shape=vertical` gives the other shapes. `?background` plays the app part only, silently, on a loop (for behind a
page's words, or a README-style loop), and `?clear` makes the stage see-through, so the window floats on your page.

The player is yours to set, in the project's `style`, a format's or a scene's own:

```js
style: { player: { accent: "#3366ff", controls: ["play", "scrub", "time", "captions", "speed", "chapters", "fullscreen"], poster: 6 } }
```

| | |
|---|---|
| `accent` | The colour of its controls, and of what the viewer can click in the film. The brand's accent when not given |
| `controls` | Which it has: `play`, `scrub`, `time`, `sound`, `captions`, `speed`, `chapters`, `fullscreen`. The bar runs across the top; under it `play`, `sound` and `time` sit on the left and the rest on the right, each side in your order. `false`: none, and a click on the film plays and pauses it |
| `marks` | The places a viewer can go to, marked on the bar as on a video site: the film's chapters (its cards in the middle), or in a film without any, each step that says something. The pointer over the bar names the place, and a click near a mark lands on it. `"chapters"` or `"steps"` to choose; `false`: none |
| `poster` | What waits before the film is played: seconds into the film, or a picture in your project |
| `captions`, `speed` | Whether captions start on; how fast it plays (`1.5`). With the buttons, the viewer changes both |
| `tour` | A click-through demo: the film stops at every click, choice and typing, and the viewer does it (also `?tour`) |
| `autoplay`, `loop` | It starts by itself, with its sound off until the viewer turns it on; it starts again at its end. Also `?autoplay` and `?loop` on the address |

`chapters` lists the same places as the marks, to jump to. The controls are icons on a slim bar: under the film
when the film is opened by itself, over it when it is on a page, where they step back while it plays and the
captions move up clear of them. Keys: the space bar plays and pauses, the arrows go five seconds back or on, M is
the sound, C the captions, F full screen. For anything else, `.scenlit/style.css` reaches the player too (`#bar`,
`#track`, `#pp`, `#big`, `#chapters`).

To build your own controls around the film, talk to it from your page:

```js
const film = document.querySelector("iframe").contentWindow;
film.postMessage({ scenlit: { do: "play" } }, "*");          // "play", "pause", "seek" (at: seconds), "sound" (on: true)
addEventListener("message", (e) => {
  const m = e.data?.scenlit;                                 // { event, at } and what the event brings
  if (m?.event === "step") show(m.step);                     // ready, play, pause, ended, time, step, ask, link
});
```

`step` is the step now on screen (-1: the title, -2: the end), so a page can show the matching text beside the
film; `ask` says the film is waiting for the viewer; `link` says they followed a link or a button (its `text` and
`address`).

### Publish it: a link, a product page, and who watched

[scenlit.dev](https://scenlit.dev) gives each video a link without you hosting anything, gives your product a page
with its demos, help and what's new, and shows how each video was watched (`--to <address>`, or `"portal"` in
config.json, for another platform):

```sh
npx scenlit connect            # once per computer: you approve it in the browser
npx scenlit publish checkout   # to the portal this computer is connected to
# published: https://scenlit.dev/f/k3x9m2pq7a  (version 1)
# embed:     https://scenlit.dev/e/k3x9m2pq7a
# product:   https://scenlit.dev/ledgerly
npx scenlit portal             # your products, in the browser
```

- **The link stays.** Publishing the same scene again puts a new version behind the same link and embed. The platform
  keeps the newest three, counts each on its own, shows whether the new one keeps people watching longer, and can
  play an earlier one again.
- **A product, with a team.** Videos belong to the project's product (`"product"` in config.json, else the brand's
  name). Teammates join with an invite link; CI publishes with a product's token in `SCENLIT_TOKEN`.
- **Its page.** A tutorial is shown under Help with its step-by-step guide, a scene with `kind: "news"` under What's
  new, the rest under Demos (`--kind` to choose).
- **Pictures that stay current.** A scene's screenshots and thumbnail get addresses of their own: put one in your docs
  once, and every publish shows the app as it is now.
- **Who watched.** Plays, who stayed to the end, the share still watching at every second, the step where most left,
  links followed, the sites it was embedded on, and links made for one person ("Acme") counted apart. Viewings are
  counted, viewers are not: no cookie, no address is kept.
- **`--private`** keeps a video to the product's people, for a change to review. **`--listed`** puts it on the
  platform's front page with the scene that made it.

There is no public platform yet. It lives in its own repository and runs on Cloudflare (a Worker, Postgres, R2).

---
From the README of Scenlit 0.1.0. The docs: https://scenlit.dev/docs. Every page: https://scenlit.dev/llms.txt
