rushes 0.6.0 → 0.6.1

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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "rushes",
3
3
  "description": "A local review desk for video made with AI agents: timecoded notes, script edits and audio picks your agent reads and acts on.",
4
- "version": "0.6.0",
4
+ "version": "0.6.1",
5
5
  "author": { "name": "Red Morley Hewitt" },
6
6
  "homepage": "https://github.com/iamredmh/rushes",
7
7
  "repository": "https://github.com/iamredmh/rushes",
@@ -19,8 +19,40 @@ function gif(b) {
19
19
  }
20
20
  /** The start-of-frame markers, which carry the size: every one from C0 to CF except the three that are not frames. */
21
21
  const isFrame = (m) => m >= 0xc0 && m <= 0xcf && m !== 0xc4 && m !== 0xc8 && m !== 0xcc;
22
+ /**
23
+ * The EXIF orientation (1 to 8) in an APP1 segment whose data starts at `at` and is `len` bytes long, or 1 when there is none
24
+ * or it cannot be read. Only IFD0's orientation tag (0x0112) is looked at, and nothing is read outside the segment.
25
+ */
26
+ function exifOrientation(b, at, len) {
27
+ const end = Math.min(b.length, at + len);
28
+ if (!ascii(b, at, "Exif") || b[at + 4] !== 0 || b[at + 5] !== 0)
29
+ return 1;
30
+ const tiff = at + 6;
31
+ const little = ascii(b, tiff, "II");
32
+ if (!little && !ascii(b, tiff, "MM"))
33
+ return 1;
34
+ const u16 = (o) => (little ? u16le(b, o) : u16be(b, o));
35
+ const u32 = (o) => (little ? (u16le(b, o) | (u16le(b, o + 2) << 16)) >>> 0 : u32be(b, o));
36
+ if (tiff + 8 > end || u16(tiff + 2) !== 42)
37
+ return 1;
38
+ const ifd = tiff + u32(tiff + 4);
39
+ if (ifd + 2 > end)
40
+ return 1;
41
+ const count = Math.min(u16(ifd), 256);
42
+ for (let i = 0; i < count; i++) {
43
+ const entry = ifd + 2 + i * 12;
44
+ if (entry + 12 > end)
45
+ return 1;
46
+ if (u16(entry) === 0x0112) {
47
+ const value = u16(entry + 8);
48
+ return value >= 1 && value <= 8 ? value : 1;
49
+ }
50
+ }
51
+ return 1;
52
+ }
22
53
  function jpeg(b) {
23
54
  let at = 2;
55
+ let orientation = 1;
24
56
  while (at + 4 <= b.length) {
25
57
  if (b[at] !== 0xff)
26
58
  return null;
@@ -29,8 +61,16 @@ function jpeg(b) {
29
61
  at++;
30
62
  continue;
31
63
  }
32
- if (isFrame(marker))
33
- return b.length >= at + 9 ? sized(u16be(b, at + 7), u16be(b, at + 5), "jpeg") : null;
64
+ if (isFrame(marker)) {
65
+ if (b.length < at + 9)
66
+ return null;
67
+ const [width, height] = [u16be(b, at + 7), u16be(b, at + 5)];
68
+ // A browser draws a picture stored on its side turned upright, so its shape is the turned one (EXIF orientations 5 to 8).
69
+ return orientation >= 5 ? sized(height, width, "jpeg") : sized(width, height, "jpeg");
70
+ }
71
+ // Another APP1 segment (XMP, say) says nothing about orientation and must not undo what the EXIF one said.
72
+ if (marker === 0xe1)
73
+ orientation = [exifOrientation(b, at + 4, u16be(b, at + 2) - 2), orientation].find((o) => o !== 1) ?? 1;
34
74
  at += 2 + u16be(b, at + 2);
35
75
  }
36
76
  return null;
@@ -33,7 +33,7 @@ import { buildState, planWarning } from "../core/plan.js";
33
33
  import { broughtInEvent, cutEvent, fileEvent, formatEvent, lineEvent, lockEvent, notesSentEvent, picksEvent, repliesEvent, scriptEvent, takeEvent, variantEvent, visualEvent, } from "../core/logEvents.js";
34
34
  import { LOG_AREAS, LOG_MAX, changeLogFileName, logText, recentChanges } from "../core/logText.js";
35
35
  import { defaultRunner, measureMix } from "./loudness.js";
36
- export const VERSION = "0.6.0";
36
+ export const VERSION = "0.6.1";
37
37
  async function body(c, schema) {
38
38
  let json;
39
39
  try {
@@ -1229,10 +1229,14 @@ export function createApp(store, opts = {}) {
1229
1229
  // ---- visuals (§25) ----
1230
1230
  app.post("/api/visuals", async (c) => {
1231
1231
  const b = await body(c, VisualBody);
1232
- // Every picture is read first, in the order given, so a refusal always names the first one and writes nothing.
1232
+ // Every picture is read first, one after the other in the order given, so a refusal always names the first bad one and writes nothing.
1233
1233
  const pages = [];
1234
- for (const p of b.pages)
1235
- pages.push({ n: p.n, files: await Promise.all(p.files.map((f) => readPicture(store.root, f))) });
1234
+ for (const p of b.pages) {
1235
+ const files = [];
1236
+ for (const f of p.files)
1237
+ files.push(await readPicture(store.root, f));
1238
+ pages.push({ n: p.n, files });
1239
+ }
1236
1240
  const { result } = await store.update("visuals", (f) => b.name !== undefined ? registerVisual(f, { name: b.name, kind: b.kind, label: b.label, pages }) : addVisualVersion(f, { visual: b.visual, label: b.label, pages }));
1237
1241
  await log.add(() => visualEvent(result.visual, { id: result.version.id, note: "", file: "", label: result.version.label }), by(c));
1238
1242
  return c.json({ visual: { id: result.visual.id, name: result.visual.name, kind: result.visual.kind }, version: { id: result.version.id, label: result.version.label }, pages: result.version.pages.length, ratios: visualRatios(result.version).map(labelOfId) }, 201);
@@ -16,7 +16,8 @@ const refuse = (code, message, file) => {
16
16
  function inProject(root, file) {
17
17
  const abs = isAbsolute(file) ? normalize(file) : resolve(root, file);
18
18
  const rel = relative(root, abs);
19
- if (rel === "" || rel.startsWith("..") || isAbsolute(rel))
19
+ // "..cover.png" is a name inside the project; only ".." itself or ".." as a path part leads out of it.
20
+ if (rel === "" || rel === ".." || rel.startsWith(".." + sep) || isAbsolute(rel))
20
21
  return null;
21
22
  return rel.split(sep).join("/");
22
23
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rushes",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "description": "A local review desk for video made with AI agents: timecoded notes, script edits and audio picks your agent can read and act on.",
5
5
  "keywords": [
6
6
  "video",