@anvpx/motion-cli 0.1.14 → 0.1.15

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.
@@ -4,7 +4,13 @@ type BuiltWord = {
4
4
  start: number;
5
5
  end: number;
6
6
  };
7
- /** Split a scene into balanced cue chunks, at most CUE_MAX_WORDS each. */
7
+ /**
8
+ * Split a scene into cue chunks of at most CUE_MAX_WORDS, **on clause
9
+ * boundaries first**. A cue that starts mid-clause ("in it is built, one cue at a
10
+ * time.") is the defect this avoids: a blind review of the first 3D film caught
11
+ * exactly that, so the splitter now prefers a sentence end, then a comma near the
12
+ * cap, and only cuts blind when there is no boundary at all.
13
+ */
8
14
  export declare const splitCueWords: (words: readonly BuiltWord[]) => BuiltWord[][];
9
15
  export declare const captionsCommand: Command;
10
16
  export {};
@@ -58,17 +58,72 @@ const sceneWords = (row, bound, fallback) => {
58
58
  };
59
59
  /** Cue budget: broadcast captions rarely hold more than this many words. */
60
60
  const CUE_MAX_WORDS = 12;
61
- /** Split a scene into balanced cue chunks, at most CUE_MAX_WORDS each. */
61
+ const SENTENCE_END = /[.!?…]$/;
62
+ const CLAUSE_END = /[,;:—–]$/;
63
+ /**
64
+ * Split a scene into cue chunks of at most CUE_MAX_WORDS, **on clause
65
+ * boundaries first**. A cue that starts mid-clause ("in it is built, one cue at a
66
+ * time.") is the defect this avoids: a blind review of the first 3D film caught
67
+ * exactly that, so the splitter now prefers a sentence end, then a comma near the
68
+ * cap, and only cuts blind when there is no boundary at all.
69
+ */
62
70
  export const splitCueWords = (words) => {
63
- if (words.length <= CUE_MAX_WORDS)
64
- return [[...words]];
65
- const count = Math.ceil(words.length / CUE_MAX_WORDS);
66
- const size = Math.ceil(words.length / count);
71
+ if (words.length === 0)
72
+ return [[]];
73
+ /** @type {BuiltWord[][]} */
74
+ const sentences = [];
75
+ let run = [];
76
+ for (const word of words) {
77
+ run.push(word);
78
+ if (SENTENCE_END.test(word.w)) {
79
+ sentences.push(run);
80
+ run = [];
81
+ }
82
+ }
83
+ if (run.length > 0)
84
+ sentences.push(run);
67
85
  const cues = [];
68
- for (let i = 0; i < words.length; i += size) {
69
- cues.push(words.slice(i, i + size));
86
+ for (const sentence of sentences) {
87
+ if (sentence.length === 0)
88
+ continue;
89
+ if (sentence.length <= CUE_MAX_WORDS) {
90
+ cues.push(sentence);
91
+ continue;
92
+ }
93
+ // An over-long sentence keeps the even chunk size it always had, but a clause
94
+ // end within two words of a cut wins: a cue must not start mid-clause for the
95
+ // sake of an exact word count.
96
+ const count = Math.ceil(sentence.length / CUE_MAX_WORDS);
97
+ const size = Math.ceil(sentence.length / count);
98
+ const clauseAt = (index) => {
99
+ const word = sentence[index];
100
+ return word !== undefined && CLAUSE_END.test(word.w);
101
+ };
102
+ let start = 0;
103
+ while (sentence.length - start > CUE_MAX_WORDS) {
104
+ let cut = start + size;
105
+ for (let shift = 0; shift <= 2; shift += 1) {
106
+ const after = start + size - 1 + shift;
107
+ const before = start + size - 1 - shift;
108
+ if (clauseAt(after)) {
109
+ cut = after + 1;
110
+ break;
111
+ }
112
+ if (clauseAt(before)) {
113
+ cut = before + 1;
114
+ break;
115
+ }
116
+ }
117
+ cut = Math.min(cut, start + CUE_MAX_WORDS);
118
+ if (cut <= start)
119
+ cut = start + 1;
120
+ cues.push(sentence.slice(start, cut));
121
+ start = cut;
122
+ }
123
+ if (start < sentence.length)
124
+ cues.push(sentence.slice(start));
70
125
  }
71
- return cues;
126
+ return cues.length === 0 ? [[]] : cues;
72
127
  };
73
128
  /** One `add /scenes/-` op per caption cue, with a per-scene captioned/omitted report. */
74
129
  const planFromManifest = (board, manifest) => {
@@ -12,8 +12,8 @@ import type { Command } from "../types.ts";
12
12
  * at real versions) or choiceB (bundle into one tarball); either lands with
13
13
  * a version bump of core manifest + this pin + plugin.json together.
14
14
  */
15
- export declare const PINNED_CORE_VERSION = "0.1.14";
16
- export declare const PINNED_NPX = "npx -y @anvpx/motion@0.1.14";
15
+ export declare const PINNED_CORE_VERSION = "0.1.15";
16
+ export declare const PINNED_NPX = "npx -y @anvpx/motion@0.1.15";
17
17
  /** Skill file whose sha256 must survive `plugin install` byte for byte. */
18
18
  export declare const PLUGIN_SKILL: string;
19
19
  export interface PluginEnv {
@@ -17,7 +17,7 @@ import { EXIT } from "../exit-codes.js";
17
17
  * at real versions) or choiceB (bundle into one tarball); either lands with
18
18
  * a version bump of core manifest + this pin + plugin.json together.
19
19
  */
20
- export const PINNED_CORE_VERSION = "0.1.14";
20
+ export const PINNED_CORE_VERSION = "0.1.15";
21
21
  export const PINNED_NPX = `npx -y @anvpx/motion@${PINNED_CORE_VERSION}`;
22
22
  /** Skill file whose sha256 must survive `plugin install` byte for byte. */
23
23
  export const PLUGIN_SKILL = join("skills", "motion-kit", "SKILL.md");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anvpx/motion-cli",
3
- "version": "0.1.14",
3
+ "version": "0.1.15",
4
4
  "description": "The mk CLI for @anvpx/motion: validate, preview, approve and render storyboards.",
5
5
  "license": "MIT",
6
6
  "author": "anvpx",
@@ -30,10 +30,10 @@
30
30
  "dist/**/*.d.ts"
31
31
  ],
32
32
  "dependencies": {
33
- "@anvpx/motion-audio": "0.1.14",
34
- "@anvpx/motion-build": "0.1.14",
35
- "@anvpx/motion-schema": "0.1.14",
36
- "@anvpx/motion-templates": "0.1.14"
33
+ "@anvpx/motion-audio": "0.1.15",
34
+ "@anvpx/motion-build": "0.1.15",
35
+ "@anvpx/motion-schema": "0.1.15",
36
+ "@anvpx/motion-templates": "0.1.15"
37
37
  },
38
38
  "scripts": {
39
39
  "test:integration": "vitest run --config vitest.integration.config.ts"