gooseworks 0.5.7 → 0.5.9-dev.53.c1bd6be2

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.
Files changed (65) hide show
  1. package/dist/kit/core/progress.d.ts +23 -3
  2. package/dist/kit/core/progress.d.ts.map +1 -1
  3. package/dist/kit/core/progress.js +62 -18
  4. package/dist/kit/core/progress.js.map +1 -1
  5. package/dist/kit/core/run.d.ts +5 -1
  6. package/dist/kit/core/run.d.ts.map +1 -1
  7. package/dist/kit/core/run.js +17 -4
  8. package/dist/kit/core/run.js.map +1 -1
  9. package/dist/kit/core/style.d.ts +1 -0
  10. package/dist/kit/core/style.d.ts.map +1 -1
  11. package/dist/kit/maker/cues.d.ts +67 -0
  12. package/dist/kit/maker/cues.d.ts.map +1 -0
  13. package/dist/kit/maker/cues.js +204 -0
  14. package/dist/kit/maker/cues.js.map +1 -0
  15. package/dist/kit/maker/encode.d.ts +5 -0
  16. package/dist/kit/maker/encode.d.ts.map +1 -1
  17. package/dist/kit/maker/encode.js +7 -1
  18. package/dist/kit/maker/encode.js.map +1 -1
  19. package/dist/kit/maker/facts.d.ts +46 -0
  20. package/dist/kit/maker/facts.d.ts.map +1 -0
  21. package/dist/kit/maker/facts.js +159 -0
  22. package/dist/kit/maker/facts.js.map +1 -0
  23. package/dist/kit/maker/inputs.d.ts +48 -3
  24. package/dist/kit/maker/inputs.d.ts.map +1 -1
  25. package/dist/kit/maker/inputs.js +151 -22
  26. package/dist/kit/maker/inputs.js.map +1 -1
  27. package/dist/kit/maker/make.d.ts +20 -1
  28. package/dist/kit/maker/make.d.ts.map +1 -1
  29. package/dist/kit/maker/make.js +125 -19
  30. package/dist/kit/maker/make.js.map +1 -1
  31. package/dist/kit/maker/page.d.ts.map +1 -1
  32. package/dist/kit/maker/page.js +49 -1
  33. package/dist/kit/maker/page.js.map +1 -1
  34. package/dist/kit/maker/parts/html-frames/1.2.0/part.json +1083 -0
  35. package/dist/kit/maker/parts/html-frames/src/part.d.ts.map +1 -1
  36. package/dist/kit/maker/parts/html-frames/src/part.js +4 -1
  37. package/dist/kit/maker/parts/html-frames/src/part.js.map +1 -1
  38. package/dist/kit/maker/runtime.d.ts.map +1 -1
  39. package/dist/kit/maker/runtime.js +54 -7
  40. package/dist/kit/maker/runtime.js.map +1 -1
  41. package/dist/kit/maker/timing.d.ts +74 -0
  42. package/dist/kit/maker/timing.d.ts.map +1 -0
  43. package/dist/kit/maker/timing.js +152 -0
  44. package/dist/kit/maker/timing.js.map +1 -0
  45. package/dist/kit/maker/under.d.ts +126 -0
  46. package/dist/kit/maker/under.d.ts.map +1 -0
  47. package/dist/kit/maker/under.js +299 -0
  48. package/dist/kit/maker/under.js.map +1 -0
  49. package/dist/skills/master-skill.js +1 -1
  50. package/dist/skills/routes.js +2 -2
  51. package/dist/skills/routes.js.map +1 -1
  52. package/dist/skills/server-entry-skills.d.ts +6 -6
  53. package/dist/skills/server-entry-skills.d.ts.map +1 -1
  54. package/dist/skills/server-entry-skills.js +84 -55
  55. package/dist/skills/server-entry-skills.js.map +1 -1
  56. package/package.json +3 -3
  57. package/skills/goose-ads/SKILL.md +6 -6
  58. package/skills/goose-product-photos/SKILL.md +6 -6
  59. package/skills/goose-video/SKILL.md +23 -13
  60. package/skills/goose-video-local/SKILL.md +1 -1
  61. package/skills/gooseworks/SKILL.md +6 -6
  62. package/skills/make-custom-video/SKILL.md +42 -23
  63. package/skills/manifest.json +7 -7
  64. package/skills/routes.json +1 -1
  65. package/dist/kit/maker/parts/html-frames/1.1.0/part.json +0 -199
@@ -1 +1 @@
1
- {"version":3,"file":"part.d.ts","sourceRoot":"","sources":["../../../../../../src/kit/maker/parts/html-frames/src/part.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAG1D,eAAO,MAAM,GAAG,EAAE,OAGjB,CAAC"}
1
+ {"version":3,"file":"part.d.ts","sourceRoot":"","sources":["../../../../../../src/kit/maker/parts/html-frames/src/part.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAG1D,eAAO,MAAM,GAAG,EAAE,OAKjB,CAAC"}
@@ -3,7 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.run = void 0;
4
4
  const make_1 = require("../../../make");
5
5
  const run = async (inputs, ctx) => {
6
- const made = await (0, make_1.makeVideo)(inputs, ctx);
6
+ const made = await (0, make_1.makeOrSkip)(inputs, ctx);
7
+ // skip_blank with no text anywhere: no outputs at all.
8
+ if (!made)
9
+ return {};
7
10
  return { video: made.video, seconds: made.seconds, timeline: made.timeline };
8
11
  };
9
12
  exports.run = run;
@@ -1 +1 @@
1
- {"version":3,"file":"part.js","sourceRoot":"","sources":["../../../../../../src/kit/maker/parts/html-frames/src/part.ts"],"names":[],"mappings":";;;AAIA,wCAA0C;AAEnC,MAAM,GAAG,GAAY,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE;IAChD,MAAM,IAAI,GAAG,MAAM,IAAA,gBAAS,EAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC1C,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC;AAC/E,CAAC,CAAC;AAHW,QAAA,GAAG,OAGd"}
1
+ {"version":3,"file":"part.js","sourceRoot":"","sources":["../../../../../../src/kit/maker/parts/html-frames/src/part.ts"],"names":[],"mappings":";;;AAIA,wCAA2C;AAEpC,MAAM,GAAG,GAAY,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE;IAChD,MAAM,IAAI,GAAG,MAAM,IAAA,iBAAU,EAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC3C,uDAAuD;IACvD,IAAI,CAAC,IAAI;QAAE,OAAO,EAAE,CAAC;IACrB,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC;AAC/E,CAAC,CAAC;AALW,QAAA,GAAG,OAKd"}
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../src/kit/maker/runtime.ts"],"names":[],"mappings":"AAsCA,iEAAiE;AACjE,eAAO,MAAM,aAAa,gBAAgB,CAAC;AAkoB3C,wEAAwE;AACxE,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAMjD;AAED,+CAA+C;AAC/C,wBAAgB,aAAa,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAEnD"}
1
+ {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../src/kit/maker/runtime.ts"],"names":[],"mappings":"AAwCA,iEAAiE;AACjE,eAAO,MAAM,aAAa,gBAAgB,CAAC;AA8qB3C,wEAAwE;AACxE,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAMjD;AAED,+CAA+C;AAC/C,wBAAgB,aAAa,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAInD"}
@@ -1,4 +1,8 @@
1
1
  "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PAGE_EPOCH_MS = void 0;
4
+ exports.scriptJson = scriptJson;
5
+ exports.runtimeScript = runtimeScript;
2
6
  // The script the maker puts first in every frame page, before any of the
3
7
  // page's own code. It gives the page its data (window.kit) and replaces every
4
8
  // clock and source of chance the page could read, at the prototype level so
@@ -34,12 +38,9 @@
34
38
  // case on a case-insensitive disk; the zip comes only from the pinned,
35
39
  // checksummed browser download, so it is first-party too.
36
40
  //
41
+ const cues_1 = require("./cues");
37
42
  // Plain ES2020 in a string: nothing here is compiled, so the page runs exactly
38
43
  // this text. Keep it free of backticks and "${".
39
- Object.defineProperty(exports, "__esModule", { value: true });
40
- exports.PAGE_EPOCH_MS = void 0;
41
- exports.scriptJson = scriptJson;
42
- exports.runtimeScript = runtimeScript;
43
44
  /** Fixed wall-clock start for the page: 2026-01-01T00:00:00Z. */
44
45
  exports.PAGE_EPOCH_MS = 1767225600000;
45
46
  const RUNTIME = String.raw `(function () {
@@ -367,6 +368,39 @@ const RUNTIME = String.raw `(function () {
367
368
  // Frame data for the page.
368
369
  var renderers = [];
369
370
  var waits = [];
371
+ // 1.2.0 sound cues: marked before the page is ready, mixed by the maker at their frames.
372
+ var SOUNDS = __KIT_SOUNDS__;
373
+ var cues = [];
374
+ var cuesClosed = false;
375
+ function cue(name, at_s, options) {
376
+ if (cuesClosed) {
377
+ report('The frame page marks a sound cue after it got ready. Mark every cue before kit.ready settles.');
378
+ return;
379
+ }
380
+ if (typeof name !== 'string' || SOUNDS.indexOf(name) < 0) {
381
+ report('The frame page asks for the sound "' + String(name).slice(0, 40) + '"; the sounds are ' + SOUNDS.join(', ') + '.');
382
+ return;
383
+ }
384
+ if (typeof at_s !== 'number' || !isFinite(at_s) || at_s < 0 || at_s >= DATA.duration_s) {
385
+ report('The frame page marks a sound cue at ' + String(at_s).slice(0, 40) + ' s, outside the video (0 to ' + DATA.duration_s + ' s).');
386
+ return;
387
+ }
388
+ var gain = 1;
389
+ var max_s = null;
390
+ if (options !== undefined && options !== null) {
391
+ if (typeof options !== 'object') { report('The frame page gives sound cue options that are not an object.'); return; }
392
+ if (options.gain !== undefined) {
393
+ if (typeof options.gain !== 'number' || !isFinite(options.gain) || options.gain < 0 || options.gain > 4) { report('The frame page gives a sound cue a gain outside 0 to 4.'); return; }
394
+ gain = options.gain;
395
+ }
396
+ if (options.max_s !== undefined && options.max_s !== null) {
397
+ if (typeof options.max_s !== 'number' || !isFinite(options.max_s) || options.max_s <= 0 || options.max_s > 10) { report('The frame page gives a sound cue a max_s outside 0 to 10 seconds.'); return; }
398
+ max_s = options.max_s;
399
+ }
400
+ }
401
+ if (cues.length >= 500) { report('The frame page marks more than 500 sound cues.'); return; }
402
+ cues.push({ sound: name, at_s: at_s, gain: gain, max_s: max_s });
403
+ }
370
404
  function sceneAt(t) {
371
405
  var scenes = DATA.scenes;
372
406
  for (var i = scenes.length - 1; i >= 0; i--) {
@@ -397,9 +431,16 @@ const RUNTIME = String.raw `(function () {
397
431
  brand: DATA.brand,
398
432
  fonts: DATA.fonts,
399
433
  values: DATA.values,
434
+ // 1.2.0: the video drawn over (quiet bands), the voice track, extra pictures and picture facts.
435
+ under: DATA.under || null,
436
+ speech: DATA.speech || [],
437
+ media: DATA.media || [],
438
+ facts: DATA.facts || {},
439
+ footage: DATA.footage || [],
400
440
  sceneAt: sceneAt,
401
441
  render: function (fn) { if (typeof fn === 'function') renderers.push(fn); },
402
- ready: function (promise) { waits.push(Promise.resolve(promise)); }
442
+ ready: function (promise) { waits.push(Promise.resolve(promise)); },
443
+ cue: cue
403
444
  });
404
445
  window.kit = kit;
405
446
 
@@ -641,7 +682,11 @@ const RUNTIME = String.raw `(function () {
641
682
  syncAnimations();
642
683
  await settle();
643
684
  syncAnimations();
644
- return take();
685
+ // Cues are a pure function of the page's data: none may be marked once it is ready.
686
+ cuesClosed = true;
687
+ var started = await take();
688
+ started.cues = cues.slice();
689
+ return started;
645
690
  },
646
691
  frame: async function (index) {
647
692
  findRoots();
@@ -691,6 +736,8 @@ function scriptJson(value) {
691
736
  }
692
737
  /** The runtime with this page's data in it. */
693
738
  function runtimeScript(data) {
694
- return RUNTIME.replace('__KIT_DATA__', () => scriptJson(data)).replace('__KIT_EPOCH__', String(exports.PAGE_EPOCH_MS));
739
+ return RUNTIME.replace('__KIT_DATA__', () => scriptJson(data))
740
+ .replace('__KIT_EPOCH__', String(exports.PAGE_EPOCH_MS))
741
+ .replace('__KIT_SOUNDS__', () => scriptJson(cues_1.CUE_SOUNDS));
695
742
  }
696
743
  //# sourceMappingURL=runtime.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.js","sourceRoot":"","sources":["../../../src/kit/maker/runtime.ts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AAwE;AACxE,SAAgB,UAAU,CAAC,KAAc;IACvC,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC;SACzB,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC;SACxB,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC;SACxB,KAAK,CAAC,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC;SAClD,KAAK,CAAC,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;AACxD,CAAC;AAED,+CAA+C;AAC/C,SAAgB,aAAa,CAAC,IAAa;IACzC,OAAO,OAAO,CAAC,OAAO,CAAC,cAAc,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;SAC3D,OAAO,CAAC,eAAe,EAAE,MAAM,CAAC,qBAAa,CAAC,CAAC;SAC/C,OAAO,CAAC,gBAAgB,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,iBAAU,CAAC,CAAC,CAAC;AAC7D,CAAC"}
@@ -0,0 +1,74 @@
1
+ import type { Timeline } from '../part-interface';
2
+ export type SpeechEntry = Timeline['speech'][number];
3
+ export type SpokenWord = {
4
+ text: string;
5
+ start_s: number;
6
+ end_s: number;
7
+ };
8
+ export interface PaceSpec {
9
+ base_s: number;
10
+ per_word_s: number;
11
+ min_s?: number;
12
+ max_s?: number;
13
+ last_min_s?: number;
14
+ }
15
+ export interface Zone {
16
+ x: number;
17
+ y: number;
18
+ w: number;
19
+ h: number;
20
+ }
21
+ /** Words as a reader counts them: runs of letters or digits, joined by ' or -. */
22
+ export declare function countWords(text: string | null): number;
23
+ /** A scene with neither on-screen text nor a line (skip_blank looks for these). */
24
+ export declare function isBlankScene(scene: {
25
+ line: string | null;
26
+ on_screen: string | null;
27
+ }): boolean;
28
+ /**
29
+ * Which speech entries belong to which scene. Entries that name a scene_id go
30
+ * to that scene (entries with none are left out of the timing). When no entry
31
+ * names a scene, entries pair with scenes in order, which needs the same count.
32
+ * Returns the reason in plain words when they cannot be paired.
33
+ */
34
+ export declare function speechByScene(ids: string[], speech: SpeechEntry[]): SpeechEntry[][] | string;
35
+ /**
36
+ * Scene start times from a voice track. The first scene starts at 0; a scene
37
+ * with speech starts at its first entry. Scenes with no speech share the time
38
+ * between the speech before them and the next scene's start (or the end) evenly.
39
+ * The video lasts until the last entry ends, plus tail_s.
40
+ */
41
+ export declare function speechTimes(ids: string[], speech: SpeechEntry[], tailS: number): {
42
+ starts: number[];
43
+ seconds: number;
44
+ } | string;
45
+ /** How long each scene holds under `pace`: base_s plus per_word_s a word, kept between min_s and max_s; the last at least last_min_s. */
46
+ export declare function paceHolds(scenes: Array<{
47
+ line: string | null;
48
+ on_screen: string | null;
49
+ }>, pace: PaceSpec): number[] | string;
50
+ /** Start times from holds, plus the whole length. */
51
+ export declare function startsOfHolds(holds: number[]): {
52
+ starts: number[];
53
+ seconds: number;
54
+ };
55
+ /**
56
+ * Scene start frames from start times, with the end appended. Returns the
57
+ * index of the first scene that would get no frame, or the frames.
58
+ */
59
+ export declare function framesOfStarts(starts: number[], fps: number, frameCount: number): number[] | {
60
+ empty: number;
61
+ };
62
+ /** Each scene's spoken words, by when each word starts (on the video's frames); words after the end go to the last scene. */
63
+ export declare function wordsByScene(speech: SpeechEntry[], sceneFrames: number[], fps: number): SpokenWord[][];
64
+ /** The caption zone kept to the page; null when none of it is on the page. */
65
+ export declare function clipZone(zone: Zone, page: {
66
+ width: number;
67
+ height: number;
68
+ }): Zone | null;
69
+ /** A zone in the page's CSS pixels as video pixels, rounded inward so captions stay inside it. */
70
+ export declare function zoneOnVideo(zone: Zone, scale: number, size: {
71
+ width: number;
72
+ height: number;
73
+ }): Zone | null;
74
+ //# sourceMappingURL=timing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"timing.d.ts","sourceRoot":"","sources":["../../../src/kit/maker/timing.ts"],"names":[],"mappings":"AAIA,OAAO,KA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,SAAS,CAAC,MAAM,EAAE,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAAC,EAAE,IAAI,EAAE,QAAQ,GAAG,MAAM,EAAE,GAAG,MAAM,CAU7H;AAED,qDAAqD;AACrD,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG;IAAE,MAAM,EAAE,MAAM,EAAE,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAQpF;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAK9G;AAED,6HAA6H;AAC7H,wBAAgB,YAAY,CAAC,MAAM,EAAE,WAAW,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,GAAG,UAAU,EAAE,EAAE,CAWtG;AAED,8EAA8E;AAC9E,wBAAgB,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,GAAG,IAAI,CAOzF;AAED,kGAAkG;AAClG,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,GAAG,IAAI,CAO3G"}
@@ -0,0 +1,152 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.countWords = countWords;
4
+ exports.isBlankScene = isBlankScene;
5
+ exports.speechByScene = speechByScene;
6
+ exports.speechTimes = speechTimes;
7
+ exports.paceHolds = paceHolds;
8
+ exports.startsOfHolds = startsOfHolds;
9
+ exports.framesOfStarts = framesOfStarts;
10
+ exports.wordsByScene = wordsByScene;
11
+ exports.clipZone = clipZone;
12
+ exports.zoneOnVideo = zoneOnVideo;
13
+ /** Words as a reader counts them: runs of letters or digits, joined by ' or -. */
14
+ function countWords(text) {
15
+ if (!text)
16
+ return 0;
17
+ return text.split(/\s+/u).filter((token) => /[\p{L}\p{N}]/u.test(token)).length;
18
+ }
19
+ /** A scene with neither on-screen text nor a line (skip_blank looks for these). */
20
+ function isBlankScene(scene) {
21
+ return !scene.on_screen?.trim() && !scene.line?.trim();
22
+ }
23
+ /**
24
+ * Which speech entries belong to which scene. Entries that name a scene_id go
25
+ * to that scene (entries with none are left out of the timing). When no entry
26
+ * names a scene, entries pair with scenes in order, which needs the same count.
27
+ * Returns the reason in plain words when they cannot be paired.
28
+ */
29
+ function speechByScene(ids, speech) {
30
+ const byScene = ids.map(() => []);
31
+ if (speech.some((entry) => typeof entry.scene_id === 'string')) {
32
+ const index = new Map(ids.map((id, i) => [id, i]));
33
+ for (const entry of speech) {
34
+ if (typeof entry.scene_id !== 'string')
35
+ continue;
36
+ const i = index.get(entry.scene_id);
37
+ if (i === undefined)
38
+ return `speech names scene "${entry.scene_id}", which is not one of the scenes`;
39
+ byScene[i].push(entry);
40
+ }
41
+ return byScene;
42
+ }
43
+ if (speech.length !== ids.length) {
44
+ return `speech has ${speech.length} entries without scene ids, so they cannot be paired with ${ids.length} scenes`;
45
+ }
46
+ speech.forEach((entry, i) => byScene[i].push(entry));
47
+ return byScene;
48
+ }
49
+ /**
50
+ * Scene start times from a voice track. The first scene starts at 0; a scene
51
+ * with speech starts at its first entry. Scenes with no speech share the time
52
+ * between the speech before them and the next scene's start (or the end) evenly.
53
+ * The video lasts until the last entry ends, plus tail_s.
54
+ */
55
+ function speechTimes(ids, speech, tailS) {
56
+ for (const [k, entry] of speech.entries()) {
57
+ if (entry.end_s < entry.start_s)
58
+ return `speech entry ${k + 1} ends (${entry.end_s} s) before it starts (${entry.start_s} s)`;
59
+ }
60
+ const byScene = speechByScene(ids, speech);
61
+ if (typeof byScene === 'string')
62
+ return byScene;
63
+ const seconds = Math.max(...speech.map((entry) => entry.end_s)) + tailS;
64
+ const first = byScene.map((entries) => (entries.length ? Math.min(...entries.map((e) => e.start_s)) : null));
65
+ const last = byScene.map((entries) => (entries.length ? Math.max(...entries.map((e) => e.end_s)) : null));
66
+ const starts = ids.map((_, i) => (i === 0 ? 0 : first[i]));
67
+ for (let a = 1; a < ids.length; a++) {
68
+ if (starts[a] !== null)
69
+ continue;
70
+ let b = a;
71
+ while (b + 1 < ids.length && starts[b + 1] === null)
72
+ b++;
73
+ const to = b + 1 < ids.length ? starts[b + 1] : seconds;
74
+ const spoken = last.slice(0, a).filter((v) => v !== null);
75
+ const from = Math.min(to, Math.max(starts[a - 1], ...spoken));
76
+ const count = b - a + 1;
77
+ for (let k = 0; k < count; k++)
78
+ starts[a + k] = from + ((to - from) * k) / count;
79
+ a = b;
80
+ }
81
+ return { starts: starts, seconds };
82
+ }
83
+ /** How long each scene holds under `pace`: base_s plus per_word_s a word, kept between min_s and max_s; the last at least last_min_s. */
84
+ function paceHolds(scenes, pace) {
85
+ const min = pace.min_s ?? 0;
86
+ const max = pace.max_s ?? Infinity;
87
+ if (min > max)
88
+ return `pace.min_s (${min}) is more than pace.max_s (${max})`;
89
+ const holds = scenes.map((scene) => {
90
+ const words = countWords(scene.on_screen) || countWords(scene.line);
91
+ return Math.min(max, Math.max(min, pace.base_s + pace.per_word_s * words));
92
+ });
93
+ holds[holds.length - 1] = Math.max(holds[holds.length - 1], pace.last_min_s ?? 0);
94
+ return holds;
95
+ }
96
+ /** Start times from holds, plus the whole length. */
97
+ function startsOfHolds(holds) {
98
+ const starts = [];
99
+ let at = 0;
100
+ for (const hold of holds) {
101
+ starts.push(at);
102
+ at += hold;
103
+ }
104
+ return { starts, seconds: at };
105
+ }
106
+ /**
107
+ * Scene start frames from start times, with the end appended. Returns the
108
+ * index of the first scene that would get no frame, or the frames.
109
+ */
110
+ function framesOfStarts(starts, fps, frameCount) {
111
+ const frames = starts.map((s, i) => (i === 0 ? 0 : Math.min(frameCount, Math.max(0, Math.round(s * fps)))));
112
+ frames.push(frameCount);
113
+ for (let i = 0; i + 1 < frames.length; i++)
114
+ if (frames[i + 1] <= frames[i])
115
+ return { empty: i };
116
+ return frames;
117
+ }
118
+ /** Each scene's spoken words, by when each word starts (on the video's frames); words after the end go to the last scene. */
119
+ function wordsByScene(speech, sceneFrames, fps) {
120
+ const scenes = sceneFrames.length - 1;
121
+ const out = Array.from({ length: scenes }, () => []);
122
+ const words = speech.flatMap((entry) => entry.words ?? []).slice().sort((a, b) => a.start_s - b.start_s);
123
+ for (const word of words) {
124
+ const frame = Math.round(word.start_s * fps);
125
+ let i = scenes - 1;
126
+ while (i > 0 && frame < sceneFrames[i])
127
+ i--;
128
+ out[i].push({ text: word.text, start_s: word.start_s, end_s: word.end_s });
129
+ }
130
+ return out;
131
+ }
132
+ /** The caption zone kept to the page; null when none of it is on the page. */
133
+ function clipZone(zone, page) {
134
+ const x0 = Math.max(0, zone.x);
135
+ const y0 = Math.max(0, zone.y);
136
+ const x1 = Math.min(page.width, zone.x + zone.w);
137
+ const y1 = Math.min(page.height, zone.y + zone.h);
138
+ if (x1 - x0 < 1 || y1 - y0 < 1)
139
+ return null;
140
+ return { x: x0, y: y0, w: x1 - x0, h: y1 - y0 };
141
+ }
142
+ /** A zone in the page's CSS pixels as video pixels, rounded inward so captions stay inside it. */
143
+ function zoneOnVideo(zone, scale, size) {
144
+ const x0 = Math.max(0, Math.ceil(zone.x * scale - 1e-6));
145
+ const y0 = Math.max(0, Math.ceil(zone.y * scale - 1e-6));
146
+ const x1 = Math.min(size.width, Math.floor((zone.x + zone.w) * scale + 1e-6));
147
+ const y1 = Math.min(size.height, Math.floor((zone.y + zone.h) * scale + 1e-6));
148
+ if (x1 - x0 < 1 || y1 - y0 < 1)
149
+ return null;
150
+ return { x: x0, y: y0, w: x1 - x0, h: y1 - y0 };
151
+ }
152
+ //# sourceMappingURL=timing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"timing.js","sourceRoot":"","sources":["../../../src/kit/maker/timing.ts"],"names":[],"mappings":";;AAyBA,gCAGC;AAGD,oCAEC;AAQD,sCAiBC;AAQD,kCAsBC;AAGD,8BAUC;AAGD,sCAQC;AAMD,wCAKC;AAGD,oCAWC;AAGD,4BAOC;AAGD,kCAOC;AArID,kFAAkF;AAClF,SAAgB,UAAU,CAAC,IAAmB;IAC5C,IAAI,CAAC,IAAI;QAAE,OAAO,CAAC,CAAC;IACpB,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC;AAClF,CAAC;AAED,mFAAmF;AACnF,SAAgB,YAAY,CAAC,KAAwD;IACnF,OAAO,CAAC,KAAK,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC;AACzD,CAAC;AAED;;;;;GAKG;AACH,SAAgB,aAAa,CAAC,GAAa,EAAE,MAAqB;IAChE,MAAM,OAAO,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,EAAmB,CAAC,CAAC;IACnD,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,KAAK,CAAC,QAAQ,KAAK,QAAQ,CAAC,EAAE,CAAC;QAC/D,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QACnD,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;YAC3B,IAAI,OAAO,KAAK,CAAC,QAAQ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,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC;IAC/E,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC;IAC5C,OAAO,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,GAAG,EAAE,EAAE,CAAC,EAAE,EAAE,GAAG,EAAE,EAAE,CAAC;AAClD,CAAC"}
@@ -0,0 +1,126 @@
1
+ import type { FileRef, KitTools, Timeline } from '../part-interface';
2
+ /** What the maker measures of the video it draws over. */
3
+ export interface UnderInfo {
4
+ /** Length of its picture, in seconds. */
5
+ seconds: number;
6
+ width: number;
7
+ height: number;
8
+ fps: number | null;
9
+ hasAudio: boolean;
10
+ }
11
+ /** A band of rows, as fractions of the height (0 at the top). */
12
+ export interface QuietBand {
13
+ y0: number;
14
+ y1: number;
15
+ }
16
+ /** The band a quiet band is looked for in, and its height, as fractions of the height. */
17
+ export declare const QUIET_SAFE: {
18
+ readonly top: 0.15;
19
+ readonly bottom: 0.85;
20
+ readonly height: 0.15;
21
+ };
22
+ /** Reads the video's picture length, size, frame rate and whether it has sound, with ffprobe. */
23
+ export declare function probeUnder(tools: Pick<KitTools, 'exec'>, file: string): Promise<UnderInfo | null>;
24
+ /** How the video is fitted to the page: scaled to cover it, then cropped to the middle. */
25
+ export interface CoverFit {
26
+ scale: number;
27
+ offsetX: number;
28
+ offsetY: number;
29
+ }
30
+ export declare function coverFit(from: {
31
+ width: number;
32
+ height: number;
33
+ }, to: {
34
+ width: number;
35
+ height: number;
36
+ }): CoverFit;
37
+ /** The ffmpeg filter that fits the video to the page: cover, centre crop, square pixels. */
38
+ export declare function coverFilter(size: {
39
+ width: number;
40
+ height: number;
41
+ }): string;
42
+ /**
43
+ * The emptiest band of a grey picture: rows are scored by how much the picture
44
+ * changes along and down them (the per-row gradient), and the band of
45
+ * QUIET_SAFE.height whose rows change least, inside QUIET_SAFE, wins. Ties go
46
+ * to the band nearer the bottom, where captions usually sit.
47
+ */
48
+ export declare function quietBandOf(gray: Uint8Array, width: number, height: number): QuietBand;
49
+ /**
50
+ * Each scene's quiet band, from the video's frame at the middle of the scene,
51
+ * fitted to the page the way the last pass fits it (cover, centre crop), so the
52
+ * band describes what shows. Frames are read one at a time as raw grey pixels into `dir`.
53
+ */
54
+ export declare function quietBands(tools: Pick<KitTools, 'exec'>, file: string, info: UnderInfo, times: Array<{
55
+ start_s: number;
56
+ end_s: number;
57
+ }>, dir: string, page: {
58
+ width: number;
59
+ height: number;
60
+ }): Promise<QuietBand[]>;
61
+ /**
62
+ * True when the plan's scenes share the video drawn over evenly: that video is
63
+ * one scene (one clip, say) and the plan has several.
64
+ */
65
+ export declare function underIsShared(ids: string[], timeline: Pick<Timeline, 'scenes'>): boolean;
66
+ /**
67
+ * Scene start frames from the timeline of the video drawn over. Each plan scene
68
+ * takes the time of the timeline scene with its id; when ids do not match and
69
+ * both list the same number of scenes, they pair in order. When that video is
70
+ * one scene and the plan has several, the plan's scenes share it evenly on
71
+ * whole frames, as they share a video of a given length. Returns null when the
72
+ * scenes cannot be paired.
73
+ */
74
+ export declare function underSceneFrames(ids: string[], timeline: Pick<Timeline, 'scenes'>, fps: number, frameCount: number): number[] | null;
75
+ /** One segment of transparent page frames, kept with their alpha (PNG in MOV), to be laid over the video later. */
76
+ export declare function alphaSegmentArgs(opts: {
77
+ framesDir: string;
78
+ framePattern: string;
79
+ start: number;
80
+ count: number;
81
+ fps: number;
82
+ out: string;
83
+ }): string[];
84
+ /**
85
+ * The last pass: the video fitted to the page, the page's frames laid over it,
86
+ * encoded like every html-frames video, with the video's sound kept as AAC.
87
+ */
88
+ export declare function compositeArgs(opts: {
89
+ tools: Pick<KitTools, 'encodeArgs'>;
90
+ under: string;
91
+ list: string;
92
+ size: {
93
+ width: number;
94
+ height: number;
95
+ };
96
+ fps: number;
97
+ frames: number;
98
+ hasAudio: boolean;
99
+ out: string;
100
+ }): string[];
101
+ /**
102
+ * The timeline of a video drawn over: the video's own scenes, speech, end card
103
+ * and safe zones carried through (cut to the new length, zones moved to the
104
+ * new picture), with this video's length, size and frame rate. When the plan's
105
+ * scenes shared a one-scene video (`scenes` given), they are the scenes, and a
106
+ * speech entry that names a scene names the one it starts in.
107
+ */
108
+ export declare function passThroughTimeline(under: Timeline, out: {
109
+ duration_s: number;
110
+ width: number;
111
+ height: number;
112
+ fps: number;
113
+ }, scenes?: Array<{
114
+ id: string;
115
+ start_s: number;
116
+ end_s: number;
117
+ }>): Timeline;
118
+ /** The under video as the part takes it: the file and its timeline. */
119
+ export interface UnderSpec {
120
+ file: FileRef;
121
+ timeline: Timeline;
122
+ info: UnderInfo;
123
+ /** Each plan scene's quiet band, measured before the page is built (kit.under.quiet_band). */
124
+ quietBands?: QuietBand[];
125
+ }
126
+ //# sourceMappingURL=under.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"under.d.ts","sourceRoot":"","sources":["../../../src/kit/maker/under.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAGrE,0DAA0D;AAC1D,MAAM,WAAW,SAAS;IACxB,yCAAyC;IACzC,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,iEAAiE;AACjE,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,0FAA0F;AAC1F,eAAO,MAAM,UAAU;;;;CAAqD,CAAC;AAiB7E,iGAAiG;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