automovie 0.1.0 → 0.3.0

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 (160) hide show
  1. package/README.md +28 -16
  2. package/lib/AUTOMOVIE_CAPTURE_OPTIONS.d.ts +6 -0
  3. package/lib/AUTOMOVIE_CAPTURE_OPTIONS.js +16 -0
  4. package/lib/AUTOMOVIE_CAPTURE_OPTIONS.js.map +1 -0
  5. package/lib/AUTOMOVIE_INSPECT_OPTIONS.d.ts +6 -0
  6. package/lib/AUTOMOVIE_INSPECT_OPTIONS.js +14 -0
  7. package/lib/AUTOMOVIE_INSPECT_OPTIONS.js.map +1 -0
  8. package/lib/AUTOMOVIE_RENDER_OPTIONS.d.ts +6 -0
  9. package/lib/AUTOMOVIE_RENDER_OPTIONS.js +15 -0
  10. package/lib/AUTOMOVIE_RENDER_OPTIONS.js.map +1 -0
  11. package/lib/AUTOMOVIE_REVIEW_OPTIONS.d.ts +6 -0
  12. package/lib/AUTOMOVIE_REVIEW_OPTIONS.js +14 -0
  13. package/lib/AUTOMOVIE_REVIEW_OPTIONS.js.map +1 -0
  14. package/lib/AutoMovieCaptureBackend.d.ts +9 -0
  15. package/lib/{IAutoMoviePackageManager.js → AutoMovieCaptureBackend.js} +1 -1
  16. package/lib/AutoMovieCaptureBackend.js.map +1 -0
  17. package/lib/AutoMovieCaptureHost.d.ts +115 -0
  18. package/lib/AutoMovieCaptureHost.js +234 -0
  19. package/lib/AutoMovieCaptureHost.js.map +1 -0
  20. package/lib/AutoMovieCommand.d.ts +24 -13
  21. package/lib/IAutoMovieChromium.d.ts +84 -0
  22. package/lib/IAutoMovieChromium.js +3 -0
  23. package/lib/IAutoMovieChromium.js.map +1 -0
  24. package/lib/captureAutoMovie.d.ts +23 -0
  25. package/lib/captureAutoMovie.js +133 -0
  26. package/lib/captureAutoMovie.js.map +1 -0
  27. package/lib/deriveAutoMovieProjectName.d.ts +1 -1
  28. package/lib/deriveAutoMovieProjectName.js +1 -1
  29. package/lib/findAutoMovieFreePort.d.ts +14 -0
  30. package/lib/findAutoMovieFreePort.js +61 -0
  31. package/lib/findAutoMovieFreePort.js.map +1 -0
  32. package/lib/formatAutoMovieInspectUrl.d.ts +14 -0
  33. package/lib/formatAutoMovieInspectUrl.js +24 -0
  34. package/lib/formatAutoMovieInspectUrl.js.map +1 -0
  35. package/lib/index.d.ts +30 -2
  36. package/lib/index.js +30 -2
  37. package/lib/index.js.map +1 -1
  38. package/lib/inspectAutoMovie.d.ts +19 -0
  39. package/lib/inspectAutoMovie.js +97 -0
  40. package/lib/inspectAutoMovie.js.map +1 -0
  41. package/lib/launchAutoMovieChromium.d.ts +28 -0
  42. package/lib/launchAutoMovieChromium.js +42 -0
  43. package/lib/launchAutoMovieChromium.js.map +1 -0
  44. package/lib/loadAutoMovieProductionModule.d.ts +14 -0
  45. package/lib/loadAutoMovieProductionModule.js +61 -0
  46. package/lib/loadAutoMovieProductionModule.js.map +1 -0
  47. package/lib/planAutoMovieChromiumLaunch.d.ts +27 -0
  48. package/lib/planAutoMovieChromiumLaunch.js +34 -0
  49. package/lib/planAutoMovieChromiumLaunch.js.map +1 -0
  50. package/lib/planAutoMovieModulePageViteConfig.d.ts +37 -0
  51. package/lib/planAutoMovieModulePageViteConfig.js +27 -0
  52. package/lib/planAutoMovieModulePageViteConfig.js.map +1 -0
  53. package/lib/readAutoMovieAddArguments.d.ts +1 -1
  54. package/lib/readAutoMovieAddArguments.js +1 -1
  55. package/lib/readAutoMovieCaptureHostOptions.d.ts +36 -0
  56. package/lib/readAutoMovieCaptureHostOptions.js +57 -0
  57. package/lib/readAutoMovieCaptureHostOptions.js.map +1 -0
  58. package/lib/readAutoMovieCommandArguments.d.ts +1 -1
  59. package/lib/readAutoMovieCommandArguments.js +10 -5
  60. package/lib/readAutoMovieCommandArguments.js.map +1 -1
  61. package/lib/readAutoMovieCreateArguments.d.ts +1 -1
  62. package/lib/readAutoMovieCreateArguments.js +1 -1
  63. package/lib/readAutoMovieInspectHostOptions.d.ts +29 -0
  64. package/lib/readAutoMovieInspectHostOptions.js +48 -0
  65. package/lib/readAutoMovieInspectHostOptions.js.map +1 -0
  66. package/lib/readAutoMovieRenderOptions.d.ts +33 -0
  67. package/lib/readAutoMovieRenderOptions.js +51 -0
  68. package/lib/readAutoMovieRenderOptions.js.map +1 -0
  69. package/lib/readAutoMovieReviewOptions.d.ts +27 -0
  70. package/lib/readAutoMovieReviewOptions.js +54 -0
  71. package/lib/readAutoMovieReviewOptions.js.map +1 -0
  72. package/lib/readAutoMovieRevision.d.ts +12 -0
  73. package/lib/readAutoMovieRevision.js +32 -0
  74. package/lib/readAutoMovieRevision.js.map +1 -0
  75. package/lib/readAutoMovieVideoProbe.d.ts +23 -0
  76. package/lib/readAutoMovieVideoProbe.js +39 -0
  77. package/lib/readAutoMovieVideoProbe.js.map +1 -0
  78. package/lib/recordAutoMoviePlayback.d.ts +37 -0
  79. package/lib/recordAutoMoviePlayback.js +131 -0
  80. package/lib/recordAutoMoviePlayback.js.map +1 -0
  81. package/lib/renderAutoMovie.d.ts +21 -0
  82. package/lib/renderAutoMovie.js +95 -0
  83. package/lib/renderAutoMovie.js.map +1 -0
  84. package/lib/renderAutoMovieScaffoldNextSteps.d.ts +3 -5
  85. package/lib/renderAutoMovieScaffoldNextSteps.js +5 -14
  86. package/lib/renderAutoMovieScaffoldNextSteps.js.map +1 -1
  87. package/lib/renderAutoMovieVideo.d.ts +35 -0
  88. package/lib/renderAutoMovieVideo.js +110 -0
  89. package/lib/renderAutoMovieVideo.js.map +1 -0
  90. package/lib/resolveAutoMovieFfmpeg.d.ts +19 -0
  91. package/lib/resolveAutoMovieFfmpeg.js +32 -0
  92. package/lib/resolveAutoMovieFfmpeg.js.map +1 -0
  93. package/lib/reviewAutoMovie.d.ts +21 -0
  94. package/lib/reviewAutoMovie.js +71 -0
  95. package/lib/reviewAutoMovie.js.map +1 -0
  96. package/lib/run.d.ts +14 -11
  97. package/lib/run.js +139 -67
  98. package/lib/run.js.map +1 -1
  99. package/lib/runAutoMovieFfmpeg.d.ts +14 -0
  100. package/lib/runAutoMovieFfmpeg.js +40 -0
  101. package/lib/runAutoMovieFfmpeg.js.map +1 -0
  102. package/lib/serveAutoMovieDrawPage.d.ts +28 -0
  103. package/lib/serveAutoMovieDrawPage.js +108 -0
  104. package/lib/serveAutoMovieDrawPage.js.map +1 -0
  105. package/lib/serveAutoMovieInspectorPage.d.ts +32 -0
  106. package/lib/serveAutoMovieInspectorPage.js +52 -0
  107. package/lib/serveAutoMovieInspectorPage.js.map +1 -0
  108. package/lib/writeAutoMovieModulePage.d.ts +38 -0
  109. package/lib/writeAutoMovieModulePage.js +75 -0
  110. package/lib/writeAutoMovieModulePage.js.map +1 -0
  111. package/package.json +26 -5
  112. package/src/AUTOMOVIE_CAPTURE_OPTIONS.ts +12 -0
  113. package/src/AUTOMOVIE_INSPECT_OPTIONS.ts +10 -0
  114. package/src/AUTOMOVIE_RENDER_OPTIONS.ts +11 -0
  115. package/src/AUTOMOVIE_REVIEW_OPTIONS.ts +10 -0
  116. package/src/AutoMovieCaptureBackend.ts +9 -0
  117. package/src/AutoMovieCaptureHost.ts +276 -0
  118. package/src/AutoMovieCommand.ts +28 -13
  119. package/src/IAutoMovieChromium.ts +89 -0
  120. package/src/captureAutoMovie.ts +150 -0
  121. package/src/deriveAutoMovieProjectName.ts +1 -1
  122. package/src/findAutoMovieFreePort.ts +27 -0
  123. package/src/formatAutoMovieInspectUrl.ts +25 -0
  124. package/src/index.ts +30 -2
  125. package/src/inspectAutoMovie.ts +82 -0
  126. package/src/launchAutoMovieChromium.ts +61 -0
  127. package/src/loadAutoMovieProductionModule.ts +30 -0
  128. package/src/planAutoMovieChromiumLaunch.ts +45 -0
  129. package/src/planAutoMovieModulePageViteConfig.ts +53 -0
  130. package/src/readAutoMovieAddArguments.ts +1 -1
  131. package/src/readAutoMovieCaptureHostOptions.ts +76 -0
  132. package/src/readAutoMovieCommandArguments.ts +6 -4
  133. package/src/readAutoMovieCreateArguments.ts +1 -1
  134. package/src/readAutoMovieInspectHostOptions.ts +66 -0
  135. package/src/readAutoMovieRenderOptions.ts +67 -0
  136. package/src/readAutoMovieReviewOptions.ts +70 -0
  137. package/src/readAutoMovieRevision.ts +29 -0
  138. package/src/readAutoMovieVideoProbe.ts +55 -0
  139. package/src/recordAutoMoviePlayback.ts +182 -0
  140. package/src/renderAutoMovie.ts +87 -0
  141. package/src/renderAutoMovieScaffoldNextSteps.ts +4 -18
  142. package/src/renderAutoMovieVideo.ts +127 -0
  143. package/src/resolveAutoMovieFfmpeg.ts +33 -0
  144. package/src/reviewAutoMovie.ts +65 -0
  145. package/src/run.ts +154 -105
  146. package/src/runAutoMovieFfmpeg.ts +50 -0
  147. package/src/serveAutoMovieDrawPage.ts +105 -0
  148. package/src/serveAutoMovieInspectorPage.ts +82 -0
  149. package/src/writeAutoMovieModulePage.ts +83 -0
  150. package/lib/IAutoMoviePackageManager.d.ts +0 -14
  151. package/lib/IAutoMoviePackageManager.js.map +0 -1
  152. package/lib/readAutoMovieSyncArguments.d.ts +0 -13
  153. package/lib/readAutoMovieSyncArguments.js +0 -49
  154. package/lib/readAutoMovieSyncArguments.js.map +0 -1
  155. package/lib/selectAutoMoviePackageManager.d.ts +0 -23
  156. package/lib/selectAutoMoviePackageManager.js +0 -70
  157. package/lib/selectAutoMoviePackageManager.js.map +0 -1
  158. package/src/IAutoMoviePackageManager.ts +0 -15
  159. package/src/readAutoMovieSyncArguments.ts +0 -48
  160. package/src/selectAutoMoviePackageManager.ts +0 -45
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Split the options of `automovie inspect` into the command's own, `AUTOMOVIE_INSPECT_OPTIONS`, and the request the page opens on, which `parseAutoMovieCapturePlanRequest` reads.
3
+ *
4
+ * | Option | Meaning | Absent |
5
+ * | --- | --- | --- |
6
+ * | `--module <file>` | The subject module whose `subjects` the inspector page offers | Required |
7
+ * | `--port <n>` | The port the page is served on, 1 to 65535 | A free port |
8
+ * | `--props <file>` | A JSON file whose value the module's `subjects` is called with, for a module whose subjects are built from data a host computes, such as a motion case | `null` |
9
+ *
10
+ * Every other option is left for the request reader, which refuses one it does not know. It throws for a missing `--module`, an empty value of any of its options, and a port that is not a whole number from 1 to 65535.
11
+ *
12
+ * @evidence contracts/development/common.md#meaningful-documentation Tabulates the command's options with their meaning and absent value, says where the rest go, and states every refusal.
13
+ * @evidence contracts/development/implementation.md#principled-implementation The command's keys are removed before the request is read, as the capture command does, so the address and the command line share one grammar and a command key cannot be mistaken for a request key.
14
+ * @evidence contracts/development/implementation.md#clear-and-simple-structure One pass that takes the command's keys out, then the checks.
15
+ * @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts No module is guessed from the folder: the page shows what the command names.
16
+ * @evidence contracts/development/implementation.md#efficient-algorithms Linear in the options.
17
+ * @evidenceExclude contracts/development/implementation.md#reuse-equivalent-work Read once per command.
18
+ * @evidenceExclude contracts/development/implementation.md#bound-retention-and-release-resources Returns a fresh map and keeps nothing.
19
+ */
20
+ export declare function readAutoMovieInspectHostOptions(values: ReadonlyMap<string, string>): {
21
+ /** Subject module path, relative to the production or absolute. */
22
+ module: string;
23
+ /** The port to serve on, or null for a free one. */
24
+ port: number | null;
25
+ /** Path of the props JSON file, relative to the production or absolute, or null for none. */
26
+ props: string | null;
27
+ /** The request's own options, for the request reader. */
28
+ request: Map<string, string>;
29
+ };
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.readAutoMovieInspectHostOptions = readAutoMovieInspectHostOptions;
4
+ const AUTOMOVIE_INSPECT_OPTIONS_1 = require("./AUTOMOVIE_INSPECT_OPTIONS");
5
+ /** Highest TCP port. */
6
+ const PORTS = 65_535;
7
+ /**
8
+ * Split the options of `automovie inspect` into the command's own, `AUTOMOVIE_INSPECT_OPTIONS`, and the request the page opens on, which `parseAutoMovieCapturePlanRequest` reads.
9
+ *
10
+ * | Option | Meaning | Absent |
11
+ * | --- | --- | --- |
12
+ * | `--module <file>` | The subject module whose `subjects` the inspector page offers | Required |
13
+ * | `--port <n>` | The port the page is served on, 1 to 65535 | A free port |
14
+ * | `--props <file>` | A JSON file whose value the module's `subjects` is called with, for a module whose subjects are built from data a host computes, such as a motion case | `null` |
15
+ *
16
+ * Every other option is left for the request reader, which refuses one it does not know. It throws for a missing `--module`, an empty value of any of its options, and a port that is not a whole number from 1 to 65535.
17
+ *
18
+ * @evidence contracts/development/common.md#meaningful-documentation Tabulates the command's options with their meaning and absent value, says where the rest go, and states every refusal.
19
+ * @evidence contracts/development/implementation.md#principled-implementation The command's keys are removed before the request is read, as the capture command does, so the address and the command line share one grammar and a command key cannot be mistaken for a request key.
20
+ * @evidence contracts/development/implementation.md#clear-and-simple-structure One pass that takes the command's keys out, then the checks.
21
+ * @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts No module is guessed from the folder: the page shows what the command names.
22
+ * @evidence contracts/development/implementation.md#efficient-algorithms Linear in the options.
23
+ * @evidenceExclude contracts/development/implementation.md#reuse-equivalent-work Read once per command.
24
+ * @evidenceExclude contracts/development/implementation.md#bound-retention-and-release-resources Returns a fresh map and keeps nothing.
25
+ */
26
+ function readAutoMovieInspectHostOptions(values) {
27
+ const request = new Map(values);
28
+ const taken = new Map();
29
+ for (const key of AUTOMOVIE_INSPECT_OPTIONS_1.AUTOMOVIE_INSPECT_OPTIONS) {
30
+ const value = request.get(key);
31
+ request.delete(key);
32
+ if (value === undefined)
33
+ continue;
34
+ if (value.trim() === "")
35
+ throw new Error(`Inspect option --${key} needs a value`);
36
+ taken.set(key, value);
37
+ }
38
+ const module = taken.get("module");
39
+ if (module === undefined)
40
+ throw new Error("Inspect needs --module <subject module>, the module whose subjects the page offers");
41
+ const text = taken.get("port");
42
+ const port = text === undefined ? null : Number(text);
43
+ if (port !== null &&
44
+ !(Number.isSafeInteger(port) && port >= 1 && port <= PORTS))
45
+ throw new Error(`Inspect --port "${text}" is not a whole number from 1 to ${PORTS}`);
46
+ return { module, port, props: taken.get("props") ?? null, request };
47
+ }
48
+ //# sourceMappingURL=readAutoMovieInspectHostOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"readAutoMovieInspectHostOptions.js","sourceRoot":"","sources":["../src/readAutoMovieInspectHostOptions.ts"],"names":[],"mappings":";;;AAAA,2EAAwE;AAExE,wBAAwB;AACxB,MAAM,KAAK,GAAW,MAAM,CAAC;AAE7B;;;;;;;;;;;;;;;;;;GAkBG;AACH,yCACE,MAAmC;IAcnC,MAAM,OAAO,GAAwB,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC;IACrD,MAAM,KAAK,GAAwB,IAAI,GAAG,EAAE,CAAC;IAC7C,KAAK,MAAM,GAAG,IAAI,qDAAyB,EAAE,CAAC;QAC5C,MAAM,KAAK,GAAuB,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACnD,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACpB,IAAI,KAAK,KAAK,SAAS;YAAE,SAAS;QAClC,IAAI,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE;YACrB,MAAM,IAAI,KAAK,CAAC,oBAAoB,GAAG,gBAAgB,CAAC,CAAC;QAC3D,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IACxB,CAAC;IAED,MAAM,MAAM,GAAuB,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACvD,IAAI,MAAM,KAAK,SAAS;QACtB,MAAM,IAAI,KAAK,CACb,oFAAoF,CACrF,CAAC;IACJ,MAAM,IAAI,GAAuB,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACnD,MAAM,IAAI,GAAkB,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACrE,IACE,IAAI,KAAK,IAAI;QACb,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,KAAK,CAAC;QAE3D,MAAM,IAAI,KAAK,CACb,mBAAmB,IAAI,qCAAqC,KAAK,EAAE,CACpE,CAAC;IACJ,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,IAAI,EAAE,OAAO,EAAE,CAAC;AACtE,CAAC"}
@@ -0,0 +1,33 @@
1
+ import type { AutoMovieCaptureBackend } from "./AutoMovieCaptureBackend";
2
+ /**
3
+ * Split the options of `automovie render` into the command's own, `AUTOMOVIE_RENDER_OPTIONS`, and the request's, which `parseAutoMovieCapturePlanRequest` reads for the request's `subject`.
4
+ *
5
+ * | Option | Meaning | Absent |
6
+ * | --- | --- | --- |
7
+ * | `--module <file>` | The subject module whose `subjects` the draw page offers | Required |
8
+ * | `--props <file>` | A JSON file whose value the module's `subjects` is called with | `null` |
9
+ * | `--out <folder>` | Where `film.mp4` and `render-report.json` go | `media/automovie/<subject>/videos` |
10
+ * | `--backend <software\|gpu>` | How the browser draws | `software` |
11
+ *
12
+ * Every other option is left for the request reader, which names the subject as `capture` and the inspector do; a render draws the subject's whole clock through its own camera, so `renderAutoMovie` refuses any request key but `subject`. It throws for an empty value of its own options, a missing `--module`, and a backend that is not `software` or `gpu`.
13
+ *
14
+ * @evidence contracts/development/common.md#meaningful-documentation Tabulates the command's options with their meaning and absent value, says where the rest go and which of them a render admits, and states every refusal.
15
+ * @evidence contracts/development/implementation.md#principled-implementation The command's keys are removed before the request is read, as `capture` and `inspect` do, so the subject has one name and one reader in every host.
16
+ * @evidence contracts/development/implementation.md#clear-and-simple-structure One pass over the listed options that takes them out, then the checks.
17
+ * @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts No module is guessed from the folder.
18
+ * @evidence contracts/development/implementation.md#efficient-algorithms Linear in the options.
19
+ * @evidenceExclude contracts/development/implementation.md#reuse-equivalent-work Read once per command.
20
+ * @evidenceExclude contracts/development/implementation.md#bound-retention-and-release-resources Returns a fresh record and keeps nothing.
21
+ */
22
+ export declare function readAutoMovieRenderOptions(values: ReadonlyMap<string, string>): {
23
+ /** Subject module path, relative to the production or absolute. */
24
+ module: string;
25
+ /** Path of the props JSON file, or null for none. */
26
+ props: string | null;
27
+ /** The output folder, or null for the default. */
28
+ out: string | null;
29
+ /** How the browser draws. */
30
+ backend: AutoMovieCaptureBackend;
31
+ /** The request's own options, for the request reader. */
32
+ request: Map<string, string>;
33
+ };
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.readAutoMovieRenderOptions = readAutoMovieRenderOptions;
4
+ const AUTOMOVIE_RENDER_OPTIONS_1 = require("./AUTOMOVIE_RENDER_OPTIONS");
5
+ /**
6
+ * Split the options of `automovie render` into the command's own, `AUTOMOVIE_RENDER_OPTIONS`, and the request's, which `parseAutoMovieCapturePlanRequest` reads for the request's `subject`.
7
+ *
8
+ * | Option | Meaning | Absent |
9
+ * | --- | --- | --- |
10
+ * | `--module <file>` | The subject module whose `subjects` the draw page offers | Required |
11
+ * | `--props <file>` | A JSON file whose value the module's `subjects` is called with | `null` |
12
+ * | `--out <folder>` | Where `film.mp4` and `render-report.json` go | `media/automovie/<subject>/videos` |
13
+ * | `--backend <software\|gpu>` | How the browser draws | `software` |
14
+ *
15
+ * Every other option is left for the request reader, which names the subject as `capture` and the inspector do; a render draws the subject's whole clock through its own camera, so `renderAutoMovie` refuses any request key but `subject`. It throws for an empty value of its own options, a missing `--module`, and a backend that is not `software` or `gpu`.
16
+ *
17
+ * @evidence contracts/development/common.md#meaningful-documentation Tabulates the command's options with their meaning and absent value, says where the rest go and which of them a render admits, and states every refusal.
18
+ * @evidence contracts/development/implementation.md#principled-implementation The command's keys are removed before the request is read, as `capture` and `inspect` do, so the subject has one name and one reader in every host.
19
+ * @evidence contracts/development/implementation.md#clear-and-simple-structure One pass over the listed options that takes them out, then the checks.
20
+ * @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts No module is guessed from the folder.
21
+ * @evidence contracts/development/implementation.md#efficient-algorithms Linear in the options.
22
+ * @evidenceExclude contracts/development/implementation.md#reuse-equivalent-work Read once per command.
23
+ * @evidenceExclude contracts/development/implementation.md#bound-retention-and-release-resources Returns a fresh record and keeps nothing.
24
+ */
25
+ function readAutoMovieRenderOptions(values) {
26
+ const request = new Map(values);
27
+ const taken = new Map();
28
+ for (const key of AUTOMOVIE_RENDER_OPTIONS_1.AUTOMOVIE_RENDER_OPTIONS) {
29
+ const value = request.get(key);
30
+ request.delete(key);
31
+ if (value === undefined)
32
+ continue;
33
+ if (value.trim() === "")
34
+ throw new Error(`Render option --${key} needs a value`);
35
+ taken.set(key, value);
36
+ }
37
+ const module = taken.get("module");
38
+ if (module === undefined)
39
+ throw new Error("Render needs --module <subject module>, the module whose subjects the draw page offers");
40
+ const backend = taken.get("backend") ?? "software";
41
+ if (backend !== "software" && backend !== "gpu")
42
+ throw new Error(`Render --backend "${backend}" is not software or gpu`);
43
+ return {
44
+ module,
45
+ props: taken.get("props") ?? null,
46
+ out: taken.get("out") ?? null,
47
+ backend,
48
+ request,
49
+ };
50
+ }
51
+ //# sourceMappingURL=readAutoMovieRenderOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"readAutoMovieRenderOptions.js","sourceRoot":"","sources":["../src/readAutoMovieRenderOptions.ts"],"names":[],"mappings":";;;AAAA,yEAAsE;AAGtE;;;;;;;;;;;;;;;;;;;GAmBG;AACH,oCACE,MAAmC;IAiBnC,MAAM,OAAO,GAAwB,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC;IACrD,MAAM,KAAK,GAAwB,IAAI,GAAG,EAAE,CAAC;IAC7C,KAAK,MAAM,GAAG,IAAI,mDAAwB,EAAE,CAAC;QAC3C,MAAM,KAAK,GAAuB,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACnD,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACpB,IAAI,KAAK,KAAK,SAAS;YAAE,SAAS;QAClC,IAAI,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE;YACrB,MAAM,IAAI,KAAK,CAAC,mBAAmB,GAAG,gBAAgB,CAAC,CAAC;QAC1D,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IACxB,CAAC;IACD,MAAM,MAAM,GAAuB,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACvD,IAAI,MAAM,KAAK,SAAS;QACtB,MAAM,IAAI,KAAK,CACb,wFAAwF,CACzF,CAAC;IACJ,MAAM,OAAO,GAAW,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,UAAU,CAAC;IAC3D,IAAI,OAAO,KAAK,UAAU,IAAI,OAAO,KAAK,KAAK;QAC7C,MAAM,IAAI,KAAK,CAAC,qBAAqB,OAAO,0BAA0B,CAAC,CAAC;IAC1E,OAAO;QACL,MAAM;QACN,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,IAAI;QACjC,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,IAAI;QAC7B,OAAO;QACP,OAAO;KACR,CAAC;AACJ,CAAC"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Read the options of `automovie review`, `AUTOMOVIE_REVIEW_OPTIONS`.
3
+ *
4
+ * | Option | Meaning | Absent |
5
+ * | --- | --- | --- |
6
+ * | `--url <address>` | The running inspector page, with the request it opens on | Required |
7
+ * | `--seconds <s>` | Wall-clock seconds of playback recorded, positive, at most a day | Required |
8
+ * | `--out <folder>` | Where the recording and `playback.json` go | `media/automovie/review` |
9
+ *
10
+ * It throws naming the option for an option outside the list, an empty value, a missing `--url` or `--seconds`, an address that is not HTTP on this machine, and seconds out of range.
11
+ *
12
+ * @evidence contracts/development/common.md#meaningful-documentation Tabulates every option with its meaning and absent value, and states every refusal.
13
+ * @evidence contracts/development/implementation.md#principled-implementation A review records the page a person would watch, so the command names that page and how long to watch it; only a loopback address is admitted, so the command never drives a page elsewhere.
14
+ * @evidence contracts/development/implementation.md#clear-and-simple-structure One pass admitting the listed options, then the checks.
15
+ * @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts No address or duration is guessed.
16
+ * @evidence contracts/development/implementation.md#efficient-algorithms Linear in the options.
17
+ * @evidenceExclude contracts/development/implementation.md#reuse-equivalent-work Read once per command.
18
+ * @evidenceExclude contracts/development/implementation.md#bound-retention-and-release-resources Returns a fresh record and keeps nothing.
19
+ */
20
+ export declare function readAutoMovieReviewOptions(values: ReadonlyMap<string, string>): {
21
+ /** The page's address. */
22
+ url: string;
23
+ /** Seconds of playback recorded. */
24
+ seconds: number;
25
+ /** The output folder, or null for the default. */
26
+ out: string | null;
27
+ };
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.readAutoMovieReviewOptions = readAutoMovieReviewOptions;
4
+ const AUTOMOVIE_REVIEW_OPTIONS_1 = require("./AUTOMOVIE_REVIEW_OPTIONS");
5
+ /** Longest observation in seconds: one day, beyond any film's playback a person reviews. */
6
+ const LONGEST = 86_400;
7
+ /**
8
+ * Read the options of `automovie review`, `AUTOMOVIE_REVIEW_OPTIONS`.
9
+ *
10
+ * | Option | Meaning | Absent |
11
+ * | --- | --- | --- |
12
+ * | `--url <address>` | The running inspector page, with the request it opens on | Required |
13
+ * | `--seconds <s>` | Wall-clock seconds of playback recorded, positive, at most a day | Required |
14
+ * | `--out <folder>` | Where the recording and `playback.json` go | `media/automovie/review` |
15
+ *
16
+ * It throws naming the option for an option outside the list, an empty value, a missing `--url` or `--seconds`, an address that is not HTTP on this machine, and seconds out of range.
17
+ *
18
+ * @evidence contracts/development/common.md#meaningful-documentation Tabulates every option with its meaning and absent value, and states every refusal.
19
+ * @evidence contracts/development/implementation.md#principled-implementation A review records the page a person would watch, so the command names that page and how long to watch it; only a loopback address is admitted, so the command never drives a page elsewhere.
20
+ * @evidence contracts/development/implementation.md#clear-and-simple-structure One pass admitting the listed options, then the checks.
21
+ * @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts No address or duration is guessed.
22
+ * @evidence contracts/development/implementation.md#efficient-algorithms Linear in the options.
23
+ * @evidenceExclude contracts/development/implementation.md#reuse-equivalent-work Read once per command.
24
+ * @evidenceExclude contracts/development/implementation.md#bound-retention-and-release-resources Returns a fresh record and keeps nothing.
25
+ */
26
+ function readAutoMovieReviewOptions(values) {
27
+ for (const [key, value] of values) {
28
+ if (!AUTOMOVIE_REVIEW_OPTIONS_1.AUTOMOVIE_REVIEW_OPTIONS.includes(key))
29
+ throw new Error(`Review takes no option --${key}; it takes ${AUTOMOVIE_REVIEW_OPTIONS_1.AUTOMOVIE_REVIEW_OPTIONS.map((option) => `--${option}`).join(", ")}`);
30
+ if (value.trim() === "")
31
+ throw new Error(`Review option --${key} needs a value`);
32
+ }
33
+ const url = values.get("url");
34
+ const text = values.get("seconds");
35
+ if (url === undefined || text === undefined)
36
+ throw new Error("Review needs --url <inspector address> and --seconds <s>");
37
+ let address;
38
+ try {
39
+ address = new URL(url);
40
+ }
41
+ catch (error) {
42
+ throw new Error(`Review --url "${url}" is not an address`, {
43
+ cause: error,
44
+ });
45
+ }
46
+ if (address.protocol !== "http:" ||
47
+ !["127.0.0.1", "localhost", "[::1]"].includes(address.hostname))
48
+ throw new Error(`Review --url "${url}" is not an HTTP page on this machine`);
49
+ const seconds = Number(text);
50
+ if (!(Number.isFinite(seconds) && seconds > 0 && seconds <= LONGEST))
51
+ throw new Error(`Review --seconds "${text}" is not a number of seconds above 0 and at most ${LONGEST}`);
52
+ return { url: address.href, seconds, out: values.get("out") ?? null };
53
+ }
54
+ //# sourceMappingURL=readAutoMovieReviewOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"readAutoMovieReviewOptions.js","sourceRoot":"","sources":["../src/readAutoMovieReviewOptions.ts"],"names":[],"mappings":";;;AAAA,yE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D,CAAC;IACJ,MAAM,OAAO,GAAW,MAAM,CAAC,IAAI,CAAC,CAAC;IACrC,IAAI,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,OAAO,GAAG,CAAC,IAAI,OAAO,IAAI,OAAO,CAAC;QAClE,MAAM,IAAI,KAAK,CACb,qBAAqB,IAAI,oDAAoD,OAAO,EAAE,CACvF,CAAC;IACJ,OAAO,EAAE,GAAG,EAAE,OAAO,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,IAAI,EAAE,CAAC;AACxE,CAAC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * The source revision a capture records: the production's git commit, with `+changes` when its working tree differs from that commit, or `unrecorded` when the folder is not in a git checkout or git is not installed.
3
+ *
4
+ * @evidence contracts/development/common.md#meaningful-documentation States the three forms and when each is written.
5
+ * @evidence contracts/development/implementation.md#principled-implementation `git rev-parse HEAD` names the commit and `git status --porcelain` is empty exactly when nothing differs from it, so the revision says whether the commit alone repeats the capture.
6
+ * @evidence contracts/development/implementation.md#clear-and-simple-structure Two git calls, one fallback.
7
+ * @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts A missing revision is written as `unrecorded`, never as a guessed commit.
8
+ * @evidence contracts/development/implementation.md#efficient-algorithms Two short processes per capture.
9
+ * @evidenceExclude contracts/development/implementation.md#reuse-equivalent-work Read once per capture, since the tree may change between captures.
10
+ * @evidence contracts/development/implementation.md#bound-retention-and-release-resources Both processes end before it returns.
11
+ */
12
+ export declare function readAutoMovieRevision(root: string): string;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.readAutoMovieRevision = readAutoMovieRevision;
4
+ const node_child_process_1 = require("node:child_process");
5
+ /**
6
+ * The source revision a capture records: the production's git commit, with `+changes` when its working tree differs from that commit, or `unrecorded` when the folder is not in a git checkout or git is not installed.
7
+ *
8
+ * @evidence contracts/development/common.md#meaningful-documentation States the three forms and when each is written.
9
+ * @evidence contracts/development/implementation.md#principled-implementation `git rev-parse HEAD` names the commit and `git status --porcelain` is empty exactly when nothing differs from it, so the revision says whether the commit alone repeats the capture.
10
+ * @evidence contracts/development/implementation.md#clear-and-simple-structure Two git calls, one fallback.
11
+ * @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts A missing revision is written as `unrecorded`, never as a guessed commit.
12
+ * @evidence contracts/development/implementation.md#efficient-algorithms Two short processes per capture.
13
+ * @evidenceExclude contracts/development/implementation.md#reuse-equivalent-work Read once per capture, since the tree may change between captures.
14
+ * @evidence contracts/development/implementation.md#bound-retention-and-release-resources Both processes end before it returns.
15
+ */
16
+ function readAutoMovieRevision(root) {
17
+ const git = (args) => (0, node_child_process_1.execFileSync)("git", ["-C", root, ...args], {
18
+ encoding: "utf8",
19
+ stdio: ["ignore", "pipe", "ignore"],
20
+ windowsHide: true,
21
+ }).trim();
22
+ try {
23
+ const commit = git(["rev-parse", "HEAD"]);
24
+ return git(["status", "--porcelain", "--", "."]) === ""
25
+ ? commit
26
+ : `${commit}+changes`;
27
+ }
28
+ catch {
29
+ return "unrecorded";
30
+ }
31
+ }
32
+ //# sourceMappingURL=readAutoMovieRevision.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"readAutoMovieRevision.js","sourceRoot":"","sources":["../src/readAutoMovieRevision.ts"],"names":[],"mappings":";;;AAAA,2DAAkD;AAElD;;;;;;;;;;GAUG;AACH,+BAAsC,IAAY;IAChD,MAAM,GAAG,GAA+B,CAAC,IAAc,EAAU,EAAE,CACjE,IAAA,iCAAY,EAAC,KAAK,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,EAAE;QACzC,QAAQ,EAAE,MAAM;QAChB,KAAK,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC;QACnC,WAAW,EAAE,IAAI;KAClB,CAAC,CAAC,IAAI,EAAE,CAAC;IACZ,IAAI,CAAC;QACH,MAAM,MAAM,GAAW,GAAG,CAAC,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC,CAAC;QAClD,OAAO,GAAG,CAAC,CAAC,QAAQ,EAAE,aAAa,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC,KAAK,EAAE;YACrD,CAAC,CAAC,MAAM;YACR,CAAC,CAAC,GAAG,MAAM,UAAU,CAAC;IAC1B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,YAAY,CAAC;IACtB,CAAC;AACH,CAAC"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Read a video file's clock and raster from the log FFmpeg writes when it opens the file: the `Duration:` of the input and the size and rate of its first video stream.
3
+ *
4
+ * The rate is the stream's `fps` value, or its `tbr` when FFmpeg prints no `fps`. It throws naming what is missing when the log holds no duration, no video stream, or a stream without a size or a rate.
5
+ *
6
+ * @evidence contracts/development/common.md#meaningful-documentation States what is read from where, the rate's fallback and the refusal.
7
+ * @evidence contracts/development/implementation.md#principled-implementation FFmpeg prints `Duration: HH:MM:SS.ss` for every input and, for a video stream, `WxH` followed by `fps` and `tbr`, its frame and base rates; reading the log FFmpeg already writes needs no `ffprobe`, which `ffmpeg-static` does not ship.
8
+ * @evidence contracts/development/implementation.md#clear-and-simple-structure One expression per value.
9
+ * @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts A missing value throws instead of taking a default raster or rate.
10
+ * @evidence contracts/development/implementation.md#efficient-algorithms Linear in the log.
11
+ * @evidenceExclude contracts/development/implementation.md#reuse-equivalent-work A pure reading of one log.
12
+ * @evidenceExclude contracts/development/implementation.md#bound-retention-and-release-resources Returns four numbers.
13
+ */
14
+ export declare function readAutoMovieVideoProbe(log: string): {
15
+ /** Running time in seconds. */
16
+ durationSeconds: number;
17
+ /** Frames per second. */
18
+ fps: number;
19
+ /** Width in pixels. */
20
+ width: number;
21
+ /** Height in pixels. */
22
+ height: number;
23
+ };
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.readAutoMovieVideoProbe = readAutoMovieVideoProbe;
4
+ /**
5
+ * Read a video file's clock and raster from the log FFmpeg writes when it opens the file: the `Duration:` of the input and the size and rate of its first video stream.
6
+ *
7
+ * The rate is the stream's `fps` value, or its `tbr` when FFmpeg prints no `fps`. It throws naming what is missing when the log holds no duration, no video stream, or a stream without a size or a rate.
8
+ *
9
+ * @evidence contracts/development/common.md#meaningful-documentation States what is read from where, the rate's fallback and the refusal.
10
+ * @evidence contracts/development/implementation.md#principled-implementation FFmpeg prints `Duration: HH:MM:SS.ss` for every input and, for a video stream, `WxH` followed by `fps` and `tbr`, its frame and base rates; reading the log FFmpeg already writes needs no `ffprobe`, which `ffmpeg-static` does not ship.
11
+ * @evidence contracts/development/implementation.md#clear-and-simple-structure One expression per value.
12
+ * @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts A missing value throws instead of taking a default raster or rate.
13
+ * @evidence contracts/development/implementation.md#efficient-algorithms Linear in the log.
14
+ * @evidenceExclude contracts/development/implementation.md#reuse-equivalent-work A pure reading of one log.
15
+ * @evidenceExclude contracts/development/implementation.md#bound-retention-and-release-resources Returns four numbers.
16
+ */
17
+ function readAutoMovieVideoProbe(log) {
18
+ const duration = log.match(/Duration:\s*(\d+):(\d{2}):(\d{2}(?:\.\d+)?)/u);
19
+ if (duration === null)
20
+ throw new Error("FFmpeg reported no duration for the video");
21
+ const stream = log
22
+ .split(/\r?\n/u)
23
+ .find((line) => /Stream #.*Video:/u.test(line));
24
+ if (stream === undefined)
25
+ throw new Error("FFmpeg reported no video stream in the file");
26
+ const size = stream.match(/[ ,](\d{2,5})x(\d{2,5})[ ,[]/u);
27
+ const rate = stream.match(/([\d.]+) fps/u) ?? stream.match(/([\d.]+) tbr/u);
28
+ if (size === null || rate === null)
29
+ throw new Error(`FFmpeg reported no size or rate for the video stream: ${stream.trim()}`);
30
+ return {
31
+ durationSeconds: Number(duration[1]) * 3600 +
32
+ Number(duration[2]) * 60 +
33
+ Number(duration[3]),
34
+ fps: Number(rate[1]),
35
+ width: Number(size[1]),
36
+ height: Number(size[2]),
37
+ };
38
+ }
39
+ //# sourceMappingURL=readAutoMovieVideoProbe.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"readAutoMovieVideoProbe.js","sourceRoot":"","sources":["../src/readAutoMovieVideoProbe.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;GAYG;AACH,iCAAwC,GAAW;IAajD,MAAM,QAAQ,GAA4B,GAAG,CAAC,KAAK,CACjD,8CAA8C,CAC/C,CAAC;IACF,IAAI,QAAQ,KAAK,IAAI;QACnB,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;IAC/D,MAAM,MAAM,GAAuB,GAAG;SACnC,KAAK,CAAC,QAAQ,CAAC;SACf,IAAI,CAAC,CAAC,IAAY,EAAW,EAAE,CAAC,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACnE,IAAI,MAAM,KAAK,SAAS;QACtB,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;IACjE,MAAM,IAAI,GAA4B,MAAM,CAAC,KAAK,CAChD,+BAA+B,CAChC,CAAC;IACF,MAAM,IAAI,GACR,MAAM,CAAC,KAAK,CAAC,eAAe,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;IACjE,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,IAAI;QAChC,MAAM,IAAI,KAAK,CACb,yDAAyD,MAAM,CAAC,IAAI,EAAE,EAAE,CACzE,CAAC;IACJ,OAAO;QACL,eAAe,EACb,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI;YAC1B,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE;YACxB,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;QACrB,GAAG,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACpB,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACtB,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;KACxB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Record real-time playback of the running inspector page: load it, press its Play button, and record the page as a video while reading its time readout, for a person to watch.
3
+ *
4
+ * The browser draws on the GPU backend, since playback is judged in real time; the recording is Playwright's own video of the page at a 1280 by 900 viewport, which `npx playwright-core install ffmpeg` provides. The page's Play button is found by its role and name, and the readout as the `output` showing `<second> / <duration> s`, both as the inspector renders them. The readout is read at most every half second for `seconds` of wall time after the click, and the page's script errors are collected. The video begins at navigation, so it includes the page's preparation; a reading's elapsed seconds count from the click.
5
+ *
6
+ * An uncaught page error before the controls are ready rejects immediately with that error as its cause; every page error also prints its stack, so a failed preparation leaves a usable diagnostic. It rejects when the page shows no Play button or readout within ten minutes and when the browser produced no video. Errors during playback remain in the returned report. The browser is closed on every outcome.
7
+ *
8
+ * @evidence contracts/development/common.md#meaningful-documentation States what is recorded and how, which backend and why, how the controls are found, the reading cadence, the clocks of the video and the readings, the refusals and the release.
9
+ * @evidence contracts/development/implementation.md#principled-implementation Playback is observed on the page a person uses, through its own controls, so the recording shows the real loop's pacing instead of seeks turned into a supposed playback; Playwright closes the context to finish writing the video.
10
+ * @evidence contracts/development/implementation.md#clear-and-simple-structure Launch, open a recording context, load, press Play, read for the duration, close.
11
+ * @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts A missing control or video is an error, never a recording of nothing.
12
+ * @evidence contracts/development/implementation.md#efficient-algorithms One reading per half second.
13
+ * @evidenceExclude contracts/development/implementation.md#reuse-equivalent-work Each review records afresh.
14
+ * @evidence contracts/development/implementation.md#bound-retention-and-release-resources The browser and its context are closed on every outcome; the readings grow by two per second of observation.
15
+ */
16
+ export declare function recordAutoMoviePlayback(props: {
17
+ /** Playwright's `chromium`, loaded from the production. */
18
+ chromium: unknown;
19
+ /** The inspector page's address. */
20
+ url: string;
21
+ /** Wall-clock seconds observed after Play is pressed. */
22
+ seconds: number;
23
+ /** Folder the video is written into. */
24
+ out: string;
25
+ /** The environment, read for `CHROME_PATH`. */
26
+ env: Readonly<Record<string, string | undefined>>;
27
+ }): Promise<{
28
+ /** The recording. */
29
+ video: string;
30
+ /** Each reading of the time readout, with wall seconds since Play was pressed. */
31
+ readings: {
32
+ elapsedSeconds: number;
33
+ text: string;
34
+ }[];
35
+ /** The page's script errors. */
36
+ errors: string[];
37
+ }>;
@@ -0,0 +1,131 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.recordAutoMoviePlayback = recordAutoMoviePlayback;
37
+ const fs = __importStar(require("node:fs/promises"));
38
+ const planAutoMovieChromiumLaunch_1 = require("./planAutoMovieChromiumLaunch");
39
+ /** Milliseconds the page may take to load and show its controls: ten minutes, room for a film that prepares its performance before its first frame. */
40
+ const PREPARE = 600_000;
41
+ /** Longest pause between two readings of the time readout, milliseconds. */
42
+ const READING = 500;
43
+ /** The time readout the inspector shows: the second and the duration, such as `1.25 / 12.00 s`. */
44
+ const READOUT = /\d+\.\d+ \/ \d+\.\d+ s/u;
45
+ /**
46
+ * Record real-time playback of the running inspector page: load it, press its Play button, and record the page as a video while reading its time readout, for a person to watch.
47
+ *
48
+ * The browser draws on the GPU backend, since playback is judged in real time; the recording is Playwright's own video of the page at a 1280 by 900 viewport, which `npx playwright-core install ffmpeg` provides. The page's Play button is found by its role and name, and the readout as the `output` showing `<second> / <duration> s`, both as the inspector renders them. The readout is read at most every half second for `seconds` of wall time after the click, and the page's script errors are collected. The video begins at navigation, so it includes the page's preparation; a reading's elapsed seconds count from the click.
49
+ *
50
+ * An uncaught page error before the controls are ready rejects immediately with that error as its cause; every page error also prints its stack, so a failed preparation leaves a usable diagnostic. It rejects when the page shows no Play button or readout within ten minutes and when the browser produced no video. Errors during playback remain in the returned report. The browser is closed on every outcome.
51
+ *
52
+ * @evidence contracts/development/common.md#meaningful-documentation States what is recorded and how, which backend and why, how the controls are found, the reading cadence, the clocks of the video and the readings, the refusals and the release.
53
+ * @evidence contracts/development/implementation.md#principled-implementation Playback is observed on the page a person uses, through its own controls, so the recording shows the real loop's pacing instead of seeks turned into a supposed playback; Playwright closes the context to finish writing the video.
54
+ * @evidence contracts/development/implementation.md#clear-and-simple-structure Launch, open a recording context, load, press Play, read for the duration, close.
55
+ * @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts A missing control or video is an error, never a recording of nothing.
56
+ * @evidence contracts/development/implementation.md#efficient-algorithms One reading per half second.
57
+ * @evidenceExclude contracts/development/implementation.md#reuse-equivalent-work Each review records afresh.
58
+ * @evidence contracts/development/implementation.md#bound-retention-and-release-resources The browser and its context are closed on every outcome; the readings grow by two per second of observation.
59
+ */
60
+ async function recordAutoMoviePlayback(props) {
61
+ const chromium = props.chromium;
62
+ const plan = (0, planAutoMovieChromiumLaunch_1.planAutoMovieChromiumLaunch)("gpu", props.env);
63
+ await fs.mkdir(props.out, { recursive: true });
64
+ const browser = await chromium.launch({
65
+ headless: true,
66
+ args: [
67
+ ...plan.args,
68
+ "--autoplay-policy=no-user-gesture-required",
69
+ "--disable-background-timer-throttling",
70
+ ],
71
+ ...(plan.executablePath === undefined
72
+ ? {}
73
+ : { executablePath: plan.executablePath }),
74
+ });
75
+ try {
76
+ const viewport = {
77
+ width: 1280,
78
+ height: 900,
79
+ };
80
+ const context = await browser.newContext({
81
+ viewport,
82
+ recordVideo: { dir: props.out, size: viewport },
83
+ });
84
+ const page = await context.newPage();
85
+ const errors = [];
86
+ const failed = new Promise((_resolve, reject) => {
87
+ page.on("pageerror", (error) => {
88
+ errors.push(error.message);
89
+ console.error("Inspector page error:", error.stack ?? error.message);
90
+ reject(new Error(`The inspector page at ${props.url} failed during initialization`, { cause: error }));
91
+ });
92
+ });
93
+ const play = page
94
+ .getByRole("button", { name: "Play", exact: true })
95
+ .first();
96
+ const readout = page
97
+ .locator("output", { hasText: READOUT })
98
+ .first();
99
+ await Promise.race([
100
+ (async () => {
101
+ await page.goto(props.url, {
102
+ waitUntil: "domcontentloaded",
103
+ timeout: PREPARE,
104
+ });
105
+ await play.waitFor({ timeout: PREPARE });
106
+ await readout.waitFor({ timeout: PREPARE });
107
+ })(),
108
+ failed,
109
+ ]);
110
+ // Press Play and read the readout for the observed seconds.
111
+ await play.click();
112
+ const started = performance.now();
113
+ const readings = [];
114
+ while (performance.now() - started < props.seconds * 1000) {
115
+ readings.push({
116
+ elapsedSeconds: (performance.now() - started) / 1000,
117
+ text: await readout.innerText(),
118
+ });
119
+ await page.waitForTimeout(Math.min(READING, Math.max(1, props.seconds * 1000 - (performance.now() - started))));
120
+ }
121
+ const video = page.video();
122
+ await context.close();
123
+ if (video === null)
124
+ throw new Error("The browser produced no playback recording");
125
+ return { video: await video.path(), readings, errors };
126
+ }
127
+ finally {
128
+ await browser.close();
129
+ }
130
+ }
131
+ //# sourceMappingURL=recordAutoMoviePlayback.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recordAutoMoviePlayback.js","sourceRoot":"","sources":["../src/recordAutoMoviePlayback.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,MAAY,EAAE,6CAAyB;AAEvC,+EAA4E;AAE5E,uJAAuJ;AACvJ,MAAM,OAAO,GAAW,OAAO,CAAC;AAEhC,4EAA4E;AAC5E,MAAM,OAAO,GAAW,GAAG,CAAC;AAE5B,mGAAmG;AACnG,MAAM,OAAO,GAAW,yBAAyB,CAAC;AAkDlD;;;;;;;;;;;;;;GAcG;AACI,KAAK,kCAAkC,KAe7C;IAUC,MAAM,QAAQ,GAAuB,KAAK,CAAC,QAA8B,CAAC;IAC1E,MAAM,IAAI,GACR,IAAA,yDAA2B,EAAC,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;IAChD,MAAM,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC/C,MAAM,OAAO,GAAsB,MAAM,QAAQ,CAAC,MAAM,CAAC;QACvD,QAAQ,EAAE,IAAI;QACd,IAAI,EAAE;YACJ,GAAG,IAAI,CAAC,IAAI;YACZ,4CAA4C;YAC5C,uCAAuC;SACxC;QACD,GAAG,CAAC,IAAI,CAAC,cAAc,KAAK,SAAS;YACnC,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC,EAAE,cAAc,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC;KAC7C,CAAC,CAAC;IACH,IAAI,CAAC;QACH,MAAM,QA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OAAO,CAAC,KAAK,EAAE,CAAC;IACxB,CAAC;AACH,CAAC"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Run `automovie render` in a production: draw one subject of a module's draw page frame by frame in headless Chromium and encode it into one video, resolving to the exit status.
3
+ *
4
+ * Options are read by `readAutoMovieCaptureArguments` and split by `readAutoMovieRenderOptions`; the rest is the request, of which a render takes only `subject`, read by `parseAutoMovieCapturePlanRequest` as `capture` reads it, and any other key is refused. A `--props` file is read as JSON before anything starts. FFmpeg is resolved before the page is built, so a missing encoder costs no drawing. The work is `renderAutoMovieVideo` through one `AutoMovieCaptureHost`, closed on every outcome. It prints the video, the report and the frame count, and resolves to 0; a refusal throws to `run`, which prints it.
5
+ *
6
+ * @evidence contracts/development/common.md#meaningful-documentation States how options are read, the order of the checks, what does the work, what is printed and the status.
7
+ * @evidence contracts/development/implementation.md#principled-implementation Every rule is the render package's or `renderAutoMovieVideo`'s; the command loads the production's packages and reports.
8
+ * @evidence contracts/development/implementation.md#clear-and-simple-structure Read, resolve FFmpeg, open the host, render, report.
9
+ * @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts An unknown option and a request key a render cannot honour are refused, and FFmpeg's absence fails before any drawing.
10
+ * @evidence contracts/development/implementation.md#efficient-algorithms One page build, one browser and one encode.
11
+ * @evidenceExclude contracts/development/implementation.md#reuse-equivalent-work One render per command.
12
+ * @evidence contracts/development/implementation.md#bound-retention-and-release-resources The host is closed on every outcome.
13
+ */
14
+ export declare function renderAutoMovie(props: {
15
+ /** The tokens after `render`. */
16
+ args: readonly string[];
17
+ /** The production's root folder, the working directory. */
18
+ root: string;
19
+ /** The environment, read for `CHROME_PATH` and `FFMPEG_PATH`. */
20
+ env: Readonly<Record<string, string | undefined>>;
21
+ }): Promise<number>;