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 @@
1
+ {"version":3,"file":"serveAutoMovieInspectorPage.js","sourceRoot":"","sources":["../src/serveAutoMovieInspectorPage.ts"],"names":[],"mappings":";;;AAAA,mEAAgE;AAChE,2FAAwF;AACxF,yEAAsE;AAYtE;;;;;;;;;;;;;;GAcG;AACI,KAAK,sCAAsC,KAejD;IAOC,MAAM,IAAI,GAAU,KAAK,CAAC,IAAa,CAAC;IACxC,MAAM,IAAI,GACR,IAAA,mDAAwB,EAAC;QACvB,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,IAAI,EAAE,SAAS;QACf,KAAK,EAAE,qBAAqB;QAC5B,IAAI,EAAE,uBAAuB;QAC7B,MAAM,EAAE,CAAC,SAAiB,EAAU,EAAE,CACpC,8FAA8F,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,sGAAsG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,IAAI,IAAI,CAAC,qEAAqE;KACxU,CAAC,CAAC;IACL,IAAI,CAAC;QACH,MAAM,IAAI,GAAW,KAAK,CAAC,IAAI,IAAI,CAAC,MAAM,IAAA,6CAAqB,GAAE,CAAC,CAAC;QACnE,MAAM,MAAM,GACV,MAAM,IAAI,CAAC,YAAY,CAAC;YACtB,GAAG,IAAA,qEAAiC,EAAC,IAAI,CAAC;YAC1C,MAAM,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE;SACnE,CAAC,CAAC;QACL,MAAM,MAAM,CAAC,MAAM,EAAE,CAAC;QACtB,OAAO;YACL,GAAG,EAAE,oBAAoB,IAAI,GAAG;YAChC,KAAK,EAAE,KAAK,IAAmB,EAAE;gBAC/B,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;gBACrB,IAAI,CAAC,MAAM,EAAE,CAAC;YAChB,CAAC;SACF,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,CAAC,MAAM,EAAE,CAAC;QACd,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Write a one-script page over a subject module into a scratch folder of the production, with the Vite configuration and public folder the production's own page uses, for the draw page and the inspector page alike.
3
+ *
4
+ * The folder is `<root>/node_modules/.cache/automovie/<kind>-<pid>-<time>`, inside the production so the page's bare imports resolve from the production's own dependencies. It holds an `index.html` with `body` and a `main.js` whose text `script` writes from the module's import specifier, a path relative to the folder with the module's own extension, so the page imports exactly the named file even where a compiled `.js` lies beside it. `configFile` is the production's `vite.config.ts` when it has one, and `publicDir` its `public` folder when it has one, `false` otherwise.
5
+ *
6
+ * It throws naming the module when the module does not exist, before anything is written.
7
+ *
8
+ * @evidence contracts/development/common.md#meaningful-documentation States where the page is written and why, what it holds, what the specifier is, what the configuration fields hold, and the refusal.
9
+ * @evidence contracts/development/implementation.md#principled-implementation Node resolves a bare import from the importing file's folder upward, so a page written inside the production imports the production's installed packages; Vite compiles a relative import of a `.ts` file named with its extension, and the extension keeps resolution from preferring a stale `.js` beside it.
10
+ * @evidence contracts/development/implementation.md#clear-and-simple-structure Check, write two files, report the folder and its configuration; what the page runs is the caller's.
11
+ * @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts The production's own page and configuration file are only read, never changed.
12
+ * @evidence contracts/development/implementation.md#efficient-algorithms Two small writes and three existence checks.
13
+ * @evidenceExclude contracts/development/implementation.md#reuse-equivalent-work One page per host.
14
+ * @evidence contracts/development/implementation.md#bound-retention-and-release-resources The returned `remove` deletes the folder; the caller owns it from the return on.
15
+ */
16
+ export declare function writeAutoMovieModulePage(props: {
17
+ /** The production's root folder. */
18
+ root: string;
19
+ /** Path of the subject module, relative to `root` or absolute. */
20
+ module: string;
21
+ /** A short name for the page, the start of the scratch folder's name, such as `draw` or `inspect`. */
22
+ kind: string;
23
+ /** The page's title. */
24
+ title: string;
25
+ /** The body's markup before the script. */
26
+ body: string;
27
+ /** The text of `main.js`, given the module's import specifier. */
28
+ script: (specifier: string) => string;
29
+ }): {
30
+ /** The scratch folder, the page's Vite root. */
31
+ folder: string;
32
+ /** The production's `vite.config.ts`, or `false` when it has none. */
33
+ configFile: string | false;
34
+ /** The production's `public` folder, or `false` when it has none. */
35
+ publicDir: string | false;
36
+ /** Delete the scratch folder. */
37
+ remove: () => void;
38
+ };
@@ -0,0 +1,75 @@
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.writeAutoMovieModulePage = writeAutoMovieModulePage;
37
+ const fs = __importStar(require("node:fs"));
38
+ const path = __importStar(require("node:path"));
39
+ /**
40
+ * Write a one-script page over a subject module into a scratch folder of the production, with the Vite configuration and public folder the production's own page uses, for the draw page and the inspector page alike.
41
+ *
42
+ * The folder is `<root>/node_modules/.cache/automovie/<kind>-<pid>-<time>`, inside the production so the page's bare imports resolve from the production's own dependencies. It holds an `index.html` with `body` and a `main.js` whose text `script` writes from the module's import specifier, a path relative to the folder with the module's own extension, so the page imports exactly the named file even where a compiled `.js` lies beside it. `configFile` is the production's `vite.config.ts` when it has one, and `publicDir` its `public` folder when it has one, `false` otherwise.
43
+ *
44
+ * It throws naming the module when the module does not exist, before anything is written.
45
+ *
46
+ * @evidence contracts/development/common.md#meaningful-documentation States where the page is written and why, what it holds, what the specifier is, what the configuration fields hold, and the refusal.
47
+ * @evidence contracts/development/implementation.md#principled-implementation Node resolves a bare import from the importing file's folder upward, so a page written inside the production imports the production's installed packages; Vite compiles a relative import of a `.ts` file named with its extension, and the extension keeps resolution from preferring a stale `.js` beside it.
48
+ * @evidence contracts/development/implementation.md#clear-and-simple-structure Check, write two files, report the folder and its configuration; what the page runs is the caller's.
49
+ * @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts The production's own page and configuration file are only read, never changed.
50
+ * @evidence contracts/development/implementation.md#efficient-algorithms Two small writes and three existence checks.
51
+ * @evidenceExclude contracts/development/implementation.md#reuse-equivalent-work One page per host.
52
+ * @evidence contracts/development/implementation.md#bound-retention-and-release-resources The returned `remove` deletes the folder; the caller owns it from the return on.
53
+ */
54
+ function writeAutoMovieModulePage(props) {
55
+ const module = path.resolve(props.root, props.module);
56
+ if (!fs.existsSync(module))
57
+ throw new Error(`The subject module ${module} does not exist`);
58
+ const folder = path.join(props.root, "node_modules", ".cache", "automovie", `${props.kind}-${process.pid}-${Date.now()}`);
59
+ fs.mkdirSync(folder, { recursive: true });
60
+ const relative = path
61
+ .relative(folder, module)
62
+ .split(path.sep)
63
+ .join("/");
64
+ fs.writeFileSync(path.join(folder, "index.html"), `<!doctype html>\n<html><head><meta charset="utf-8" /><title>${props.title}</title></head><body>${props.body}<script type="module" src="./main.js"></script></body></html>\n`);
65
+ fs.writeFileSync(path.join(folder, "main.js"), props.script(relative.startsWith(".") ? relative : `./${relative}`));
66
+ const config = path.join(props.root, "vite.config.ts");
67
+ const publicDir = path.join(props.root, "public");
68
+ return {
69
+ folder,
70
+ configFile: fs.existsSync(config) ? config : false,
71
+ publicDir: fs.existsSync(publicDir) ? publicDir : false,
72
+ remove: () => fs.rmSync(folder, { recursive: true, force: true }),
73
+ };
74
+ }
75
+ //# sourceMappingURL=writeAutoMovieModulePage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"writeAutoMovieModulePage.js","sourceRoot":"","sources":["../src/writeAutoMovieModulePage.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,MAAY,EAAE,oCAAgB;AAC9B,MAAY,IAAI,sCAAkB;AAElC;;;;;;;;;;;;;;GAcG;AACH,kCAAyC,KAkBxC;IAaC,MAAM,MAAM,GAAW,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC9D,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC;QACxB,MAAM,IAAI,KAAK,CAAC,sBAAsB,MAAM,iBAAiB,CAAC,CAAC;IAEjE,MAAM,MAAM,GAAW,IAAI,CAAC,IAAI,CAC9B,KAAK,CAAC,IAAI,EACV,cAAc,EACd,QAAQ,EACR,WAAW,EACX,GAAG,KAAK,CAAC,IAAI,IAAI,OAAO,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,EAAE,EAAE,CAC7C,CAAC;IACF,EAAE,CAAC,SAAS,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC1C,MAAM,QAAQ,GAAW,IAAI;SAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;SACxB,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC;SACf,IAAI,CAAC,GAAG,CAAC,CAAC;IACb,EAAE,CAAC,aAAa,CACd,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,YAAY,CAAC,EAC/B,+DAA+D,KAAK,CAAC,KAAK,wBAAwB,KAAK,CAAC,IAAI,iEAAiE,CAC9K,CAAC;IACF,EAAE,CAAC,aAAa,CACd,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,SAAS,CAAC,EAC5B,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,QAAQ,EAAE,CAAC,CACpE,CAAC;IAEF,MAAM,MAAM,GAAW,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,gBAAgB,CAAC,CAAC;IAC/D,MAAM,SAAS,GAAW,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IAC1D,OAAO;QACL,MAAM;QACN,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK;QAClD,SAAS,EAAE,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK;QACvD,MAAM,EAAE,GAAS,EAAE,CAAC,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;KACxE,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "automovie",
3
- "version": "0.1.0",
3
+ "version": "0.3.0",
4
4
  "description": "Scaffold a coding-agent-first AutoMovie production repository.",
5
5
  "main": "lib/index.js",
6
6
  "bin": {
@@ -38,15 +38,36 @@
38
38
  "access": "public"
39
39
  },
40
40
  "dependencies": {
41
- "@automovie/template": "^0.1.0"
41
+ "@automovie/template": "^0.3.0"
42
+ },
43
+ "peerDependencies": {
44
+ "@automovie/render": "^0.3.0",
45
+ "ffmpeg-static": "^5.2.0",
46
+ "playwright-core": "^1.60.0",
47
+ "vite": "^5.4.10"
48
+ },
49
+ "peerDependenciesMeta": {
50
+ "@automovie/render": {
51
+ "optional": true
52
+ },
53
+ "ffmpeg-static": {
54
+ "optional": true
55
+ },
56
+ "playwright-core": {
57
+ "optional": true
58
+ },
59
+ "vite": {
60
+ "optional": true
61
+ }
42
62
  },
43
63
  "devDependencies": {
44
- "@ttsc/evidence": "^0.36.3",
64
+ "@automovie/render": "^0.3.0",
65
+ "@ttsc/evidence": "^0.37.1",
45
66
  "@types/node": "^22.19.17",
46
67
  "rimraf": "^6.0.1",
47
- "ttsc": "^0.36.3",
68
+ "ttsc": "^0.37.1",
48
69
  "typescript": "^7.0.2",
49
- "@ttsc/lint": "^0.36.3",
70
+ "@ttsc/lint": "^0.37.1",
50
71
  "@wrtnlabs/evidence": "^0.8.2"
51
72
  },
52
73
  "scripts": {
@@ -0,0 +1,12 @@
1
+ /**
2
+ * The options `automovie capture` takes for itself, written `--<name>`; every other option is a key of the capture request grammar.
3
+ *
4
+ * `readAutoMovieCaptureHostOptions` takes exactly these out of the command line, and a test enumerates them against the render README's key table, so each option the command takes is documented with the requirement it serves.
5
+ */
6
+ export const AUTOMOVIE_CAPTURE_OPTIONS: readonly string[] = [
7
+ "module",
8
+ "file",
9
+ "props",
10
+ "out",
11
+ "backend",
12
+ ];
@@ -0,0 +1,10 @@
1
+ /**
2
+ * The options `automovie inspect` takes for itself, written `--<name>`; every other option is a key of the capture request grammar and becomes the page's address.
3
+ *
4
+ * A test enumerates them against the render README's key table, so each option the command takes is documented with the requirement it serves.
5
+ */
6
+ export const AUTOMOVIE_INSPECT_OPTIONS: readonly string[] = [
7
+ "module",
8
+ "port",
9
+ "props",
10
+ ];
@@ -0,0 +1,11 @@
1
+ /**
2
+ * The options `automovie render` takes for itself, written `--<name>`; of the capture request grammar it takes only `subject`, the subject rendered.
3
+ *
4
+ * `readAutoMovieRenderOptions` takes exactly these out of the command line, and a test enumerates them against the render README's key table, so each option the command takes is documented with the requirement it serves.
5
+ */
6
+ export const AUTOMOVIE_RENDER_OPTIONS: readonly string[] = [
7
+ "module",
8
+ "props",
9
+ "out",
10
+ "backend",
11
+ ];
@@ -0,0 +1,10 @@
1
+ /**
2
+ * The options `automovie review` takes, written `--<name>`; it takes no other.
3
+ *
4
+ * `readAutoMovieReviewOptions` refuses any option outside the list, and a test enumerates them against the render README's key table, so each option the command takes is documented with the requirement it serves.
5
+ */
6
+ export const AUTOMOVIE_REVIEW_OPTIONS: readonly string[] = [
7
+ "url",
8
+ "seconds",
9
+ "out",
10
+ ];
@@ -0,0 +1,9 @@
1
+ /**
2
+ * How the browser draws a capture: `software` through SwiftShader, the CPU implementation of WebGL that removes GPU driver variation and is used for recorded output, or `gpu` through the machine's graphics driver, which is faster and may differ by machine.
3
+ *
4
+ * @evidence contracts/development/design.md#principled-representation The two backends the campaign decides on, as a closed pair, so a mistyped backend cannot be launched.
5
+ * @evidence contracts/development/design.md#minimal-and-owned-surface Read by `planAutoMovieChromiumLaunch`, which turns it into switches, and by the record through the backend text.
6
+ * @evidence contracts/development/design.md#prohibited-design-shortcuts No driver or vendor is named; the renderer the browser reports goes into the record instead.
7
+ * @evidence contracts/development/common.md#meaningful-documentation States what each backend draws with and when each is used.
8
+ */
9
+ export type AutoMovieCaptureBackend = "software" | "gpu";
@@ -0,0 +1,276 @@
1
+ import type {
2
+ IAutoMovieCaptureCell,
3
+ IAutoMovieCaptureDrawing,
4
+ IAutoMovieCapturePlan,
5
+ IAutoMovieCapturePlanRequest,
6
+ IAutoMovieCaptureRecord,
7
+ } from "@automovie/interface";
8
+ import type * as Render from "@automovie/render";
9
+ import * as fs from "node:fs/promises";
10
+ import * as path from "node:path";
11
+
12
+ import type { AutoMovieCaptureBackend } from "./AutoMovieCaptureBackend";
13
+ import type { IAutoMovieChromium } from "./IAutoMovieChromium";
14
+ import { launchAutoMovieChromium } from "./launchAutoMovieChromium";
15
+ import { loadAutoMovieProductionModule } from "./loadAutoMovieProductionModule";
16
+ import { readAutoMovieRevision } from "./readAutoMovieRevision";
17
+ import { serveAutoMovieDrawPage } from "./serveAutoMovieDrawPage";
18
+
19
+ /** Milliseconds one page call may take before its cell fails: two minutes, room for SwiftShader to draw a large raster of a heavy scene. */
20
+ const TIMEOUT: number = 120_000;
21
+
22
+ /**
23
+ * The Node host that draws a production's subjects in headless Chromium: one built draw page, one browser, and any number of sessions, captures and renders through them.
24
+ *
25
+ * `open` loads `@automovie/render`, `vite` and `playwright-core` from the production, builds and serves the draw page for a subject module, and launches Chromium with the asked backend. Each `capture` opens a fresh page with the subject and props injected before it loads, describes the subject, plans the request against it, and runs the capture core with `node:fs/promises` as storage and the page's draw function as the draw, so every saved picture comes from the draw function. `close` ends the browser and the server and deletes the built page. `session` opens one subject for any other host that draws through the page, such as `renderAutoMovieVideo`. The `automovie capture` and `automovie render` commands use one host for one subject; a package with many subjects, such as the motion cases, uses one host for all of them.
26
+ *
27
+ * ```ts
28
+ * const host = await AutoMovieCaptureHost.open({ root, module: "src/subjects.ts", backend: "software", env: process.env });
29
+ * try {
30
+ * const record = await host.capture({ request, props: null });
31
+ * } finally {
32
+ * await host.close();
33
+ * }
34
+ * ```
35
+ *
36
+ * @evidence contracts/development/common.md#meaningful-documentation States what open loads, builds and launches, every step of a capture, what close releases, and both users, and shows the order.
37
+ * @evidence contracts/development/design.md#principled-representation A host is the three long-lived resources a capture needs and the render module they were loaded with; a capture is a request, the module's props and a folder.
38
+ * @evidence contracts/development/design.md#minimal-and-owned-surface `open`, `capture`, `close`, and the `backend` the command reports; planning, drawing, files and records are the render package's.
39
+ * @evidence contracts/development/design.md#prohibited-design-shortcuts No subject kind is named; the module and its props say what is drawn.
40
+ */
41
+ export class AutoMovieCaptureHost {
42
+ /** The production's `@automovie/render`, which drew the page; a host that draws through `session` uses it for the rules it applies. */
43
+ public readonly render: typeof Render;
44
+
45
+ /** The backend and Chromium version, such as `swiftshader; Chromium 131.0.6778.33`. */
46
+ public readonly backend: string;
47
+
48
+ /** The production's root folder. */
49
+ private readonly root: string;
50
+
51
+ /** The launched browser. */
52
+ private readonly browser: IAutoMovieChromium.IBrowser;
53
+
54
+ /** The served draw page. */
55
+ private readonly page: { url: string; close: () => Promise<void> };
56
+
57
+ /** Hold opened resources; `open` acquires them. */
58
+ private constructor(props: {
59
+ render: typeof Render;
60
+ backend: string;
61
+ root: string;
62
+ browser: IAutoMovieChromium.IBrowser;
63
+ page: { url: string; close: () => Promise<void> };
64
+ }) {
65
+ this.render = props.render;
66
+ this.backend = props.backend;
67
+ this.root = props.root;
68
+ this.browser = props.browser;
69
+ this.page = props.page;
70
+ }
71
+
72
+ /**
73
+ * Load the production's packages, build and serve the draw page for the subject module, and launch Chromium.
74
+ *
75
+ * It rejects naming a package the production lacks, a missing module, a failed build, and a missing Chromium with the command that installs it; whatever was started before the failure is stopped.
76
+ *
77
+ * @evidence contracts/development/common.md#meaningful-documentation States the three steps, the refusals and the cleanup.
78
+ * @evidence contracts/development/implementation.md#principled-implementation Every package comes from the production, so the page draws with the renderer the production installed, and the browser is Playwright's pinned build with the stated backend.
79
+ * @evidence contracts/development/implementation.md#clear-and-simple-structure Load, serve, launch; building and launching belong to their own functions.
80
+ * @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts A failure is reported, never answered by another backend or a development server.
81
+ * @evidence contracts/development/implementation.md#efficient-algorithms One build and one launch for every capture of the host.
82
+ * @evidence contracts/development/implementation.md#reuse-equivalent-work The built page and the browser serve every capture until `close`.
83
+ * @evidence contracts/development/implementation.md#bound-retention-and-release-resources The host owns the server, its scratch folder and the browser until `close`; a failed launch stops the server first.
84
+ */
85
+ public static async open(props: {
86
+ /** The production's root folder. */
87
+ root: string;
88
+
89
+ /** Path of the subject module, relative to `root` or absolute. */
90
+ module: string;
91
+
92
+ /** How the browser draws. */
93
+ backend: AutoMovieCaptureBackend;
94
+
95
+ /** The environment, read for `CHROME_PATH`. */
96
+ env: Readonly<Record<string, string | undefined>>;
97
+ }): Promise<AutoMovieCaptureHost> {
98
+ const render: typeof Render = loadAutoMovieProductionModule(
99
+ props.root,
100
+ "@automovie/render",
101
+ ) as typeof Render;
102
+ const chromium: IAutoMovieChromium = (
103
+ loadAutoMovieProductionModule(props.root, "playwright-core") as {
104
+ chromium: IAutoMovieChromium;
105
+ }
106
+ ).chromium;
107
+
108
+ // Vite's CommonJS entry warns once per load; the command loads it on purpose.
109
+ process.env.VITE_CJS_IGNORE_WARNING = "true";
110
+ const page: { url: string; close: () => Promise<void> } =
111
+ await serveAutoMovieDrawPage({
112
+ root: props.root,
113
+ module: props.module,
114
+ vite: loadAutoMovieProductionModule(props.root, "vite"),
115
+ });
116
+ try {
117
+ const launched: Awaited<ReturnType<typeof launchAutoMovieChromium>> =
118
+ await launchAutoMovieChromium({
119
+ chromium,
120
+ backend: props.backend,
121
+ env: props.env,
122
+ });
123
+ return new AutoMovieCaptureHost({
124
+ render,
125
+ backend: launched.backend,
126
+ root: props.root,
127
+ browser: launched.browser,
128
+ page,
129
+ });
130
+ } catch (error) {
131
+ await page.close();
132
+ throw error;
133
+ }
134
+ }
135
+
136
+ /**
137
+ * Open a fresh page of the served draw page with a subject and its props injected before it loads, and describe the subject through it.
138
+ *
139
+ * The returned session owns the page; the caller closes it. An uncaught browser error during initialization rejects immediately with the original cause and logs its stack; console errors are forwarded too. A page that installs no draw function or cannot describe its subject rejects, and the page is closed first.
140
+ *
141
+ * @evidence contracts/development/common.md#meaningful-documentation States what is opened and injected, who closes it, and the refusal.
142
+ * @evidence contracts/development/implementation.md#principled-implementation Every picture of a capture or a render comes through one such session, so both hosts draw through the same function.
143
+ * @evidence contracts/development/implementation.md#clear-and-simple-structure Observe the browser, race opening against a script failure, and close the page on rejection.
144
+ * @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts A failed open is reported, never retried.
145
+ * @evidence contracts/development/implementation.md#efficient-algorithms One page per call.
146
+ * @evidenceExclude contracts/development/implementation.md#reuse-equivalent-work Each call is a fresh page, because props differ between subjects.
147
+ * @evidence contracts/development/implementation.md#bound-retention-and-release-resources The page passes to the returned session, or is closed here when opening fails.
148
+ */
149
+ public async session(props: {
150
+ /** Name of the subject, or null for the page's only subject. */
151
+ subject: string | null;
152
+
153
+ /** Data the subject module reads, as JSON, or null. */
154
+ props: unknown;
155
+ }): Promise<Render.AutoMovieDrawSession> {
156
+ const page: Awaited<ReturnType<IAutoMovieChromium.IBrowser["newPage"]>> =
157
+ await this.browser.newPage();
158
+
159
+ // A module can fail before installing the draw port, leaving only a timeout.
160
+ // Forward its original browser error while the failed page is still alive.
161
+ const failed: Promise<never> = new Promise((_resolve, reject): void => {
162
+ page.on?.("pageerror", (error: Error): void => {
163
+ console.error("Draw page error:", error.stack ?? error.message);
164
+ reject(
165
+ new Error(
166
+ `The draw page at ${this.page.url} failed during initialization`,
167
+ { cause: error },
168
+ ),
169
+ );
170
+ });
171
+ });
172
+ page.on?.(
173
+ "console",
174
+ (message: { type(): string; text(): string }): void => {
175
+ if (message.type() === "error")
176
+ console.error("Draw page console:", message.text());
177
+ },
178
+ );
179
+ try {
180
+ return await Promise.race([
181
+ this.render.AutoMovieDrawSession.open({
182
+ page,
183
+ url: this.page.url,
184
+ props: { subject: props.subject, props: props.props },
185
+ backend: this.backend,
186
+ timeout: TIMEOUT,
187
+ }),
188
+ failed,
189
+ ]);
190
+ } catch (error) {
191
+ await page.close();
192
+ throw error;
193
+ }
194
+ }
195
+
196
+ /**
197
+ * Capture one subject: open a page with the subject and props injected, plan the request against what it describes, and draw every cell into the folder at `out`.
198
+ *
199
+ * The revision recorded is the production's git commit. It rejects what the planner or the folder refuses before anything is drawn, and a page that installs no draw function; the page is closed on every outcome.
200
+ *
201
+ * @evidence contracts/development/common.md#meaningful-documentation States the steps, the revision and the page's lifetime, and which refusals precede drawing.
202
+ * @evidence contracts/development/implementation.md#principled-implementation The capture core plans, writes, records and compares; this host only supplies the subject, the draw and the storage, as law 6 of the campaign asks.
203
+ * @evidence contracts/development/implementation.md#clear-and-simple-structure Open the session, plan, open the folder, run, close the page.
204
+ * @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts Storage is `node:fs/promises` itself, with no adapter.
205
+ * @evidence contracts/development/implementation.md#efficient-algorithms One page per capture; drawing is the capture core's loop.
206
+ * @evidenceExclude contracts/development/implementation.md#reuse-equivalent-work Each capture draws afresh, because the subject or the request differs.
207
+ * @evidence contracts/development/implementation.md#bound-retention-and-release-resources The page opened here is closed here; the capture core holds one still at a time.
208
+ */
209
+ public async capture(props: {
210
+ /** The request, as `parseAutoMovieCapturePlanRequest` read it. */
211
+ request: IAutoMovieCapturePlanRequest;
212
+
213
+ /** Data the subject module reads, as JSON, or null. */
214
+ props: unknown;
215
+
216
+ /** The capture's root folder, relative to the production or absolute; absent, `media/capture/<subject>` of the production. */
217
+ out?: string;
218
+
219
+ /** The subject owner's own section of the record, or absent. */
220
+ section?: Readonly<Record<string, unknown>>;
221
+ }): Promise<Extract<IAutoMovieCaptureRecord, { state: "complete" }>> {
222
+ const { render } = this;
223
+ const session: Render.AutoMovieDrawSession = await this.session({
224
+ subject: props.request.subject,
225
+ props: props.props,
226
+ });
227
+ try {
228
+ const plan: IAutoMovieCapturePlan = render.planAutoMovieCapture({
229
+ request: props.request,
230
+ subject: session.subject,
231
+ cuts: [],
232
+ });
233
+ const folder: Render.AutoMovieCaptureFolder =
234
+ await render.AutoMovieCaptureFolder.open({
235
+ storage: fs,
236
+ root: path.resolve(
237
+ this.root,
238
+ props.out ?? path.join("media", "capture", session.subject.name),
239
+ ),
240
+ round: props.request.round,
241
+ compare: props.request.compare,
242
+ });
243
+ return await render.runAutoMovieCapture({
244
+ plan,
245
+ draw: (
246
+ cell: IAutoMovieCaptureCell,
247
+ ): Promise<IAutoMovieCaptureDrawing> => session.drawing(cell, plan),
248
+ folder,
249
+ revision: readAutoMovieRevision(this.root),
250
+ match: "cell",
251
+ ...(props.section === undefined ? {} : { section: props.section }),
252
+ });
253
+ } finally {
254
+ await session.close();
255
+ }
256
+ }
257
+
258
+ /**
259
+ * End the browser, stop the server and delete the built page.
260
+ *
261
+ * @evidence contracts/development/common.md#meaningful-documentation States what is released.
262
+ * @evidence contracts/development/implementation.md#principled-implementation The browser ends before the server it loads pages from.
263
+ * @evidence contracts/development/implementation.md#clear-and-simple-structure Two releases in order, the second attempted even when the first fails.
264
+ * @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts A release failure propagates after both are attempted.
265
+ * @evidence contracts/development/implementation.md#efficient-algorithms Two calls.
266
+ * @evidenceExclude contracts/development/implementation.md#reuse-equivalent-work Closing happens once.
267
+ * @evidence contracts/development/implementation.md#bound-retention-and-release-resources The release point of the browser, the server and the scratch folder.
268
+ */
269
+ public async close(): Promise<void> {
270
+ try {
271
+ await this.browser.close();
272
+ } finally {
273
+ await this.page.close();
274
+ }
275
+ }
276
+ }
@@ -1,11 +1,11 @@
1
1
  /**
2
2
  * One admitted CLI request, discriminated by `command`.
3
3
  *
4
- * `help` and `version` carry nothing because they are standalone requests. `create`, `add` and `sync` carry their targets exactly as typed; `run` resolves them against the working directory. An explicit `name` is carried as typed; `run` chooses the name when it is absent.
4
+ * `help` and `version` carry nothing because they are standalone requests. `create` and `add` carry their targets exactly as typed; `run` resolves them against the working directory. An explicit `name` is carried as typed; `run` chooses the name when it is absent.
5
5
  *
6
- * @evidence contracts/development/design.md#principled-representation Each variant carries exactly what its command needs after admission, so `run` performs no further argument parsing.
6
+ * @evidence contracts/development/design.md#principled-representation Each variant carries exactly what its command needs after admission, so `run` performs no further argument parsing, except `capture`, `inspect`, `render` and `review`, whose options are read by the production's renderer's option reader once that renderer is loaded.
7
7
  * @evidence contracts/development/design.md#minimal-and-owned-surface A closed union over the command name lets `run` switch on one field, and the workspace family is a closed pair instead of a free path.
8
- * @evidence contracts/development/design.md#prohibited-design-shortcuts No variant has an escape field for unparsed tokens.
8
+ * @evidence contracts/development/design.md#prohibited-design-shortcuts No variant other than `capture`, `inspect`, `render` and `review` carries unparsed tokens, and theirs are read by the one option reader every host shares rather than a second grammar here.
9
9
  * @evidence contracts/development/common.md#meaningful-documentation Every variant and member states its meaning and who resolves it.
10
10
  */
11
11
  export type AutoMovieCommand =
@@ -27,7 +27,7 @@ export type AutoMovieCommand =
27
27
  /** Install a pnpm workspace root instead of a single production. */
28
28
  workspace: boolean;
29
29
 
30
- /** Admit a non-empty target, as `publishFiles`' `force` option defines it. */
30
+ /** Admit a non-empty target, writing over same-path files and keeping the rest. */
31
31
  force: boolean;
32
32
 
33
33
  /** Package name as typed; absent, `run` derives or asks for one. */
@@ -43,22 +43,37 @@ export type AutoMovieCommand =
43
43
  /** The production's directory under `movies/<family>`, one admitted path segment. */
44
44
  directory: string;
45
45
 
46
- /** Admit a non-empty production directory, as `publishFiles`' `force` option defines it. */
46
+ /** Admit a non-empty production directory, writing over same-path files and keeping the rest. */
47
47
  force: boolean;
48
48
 
49
49
  /** Package name as typed; absent, `run` derives one from the directory segment. */
50
50
  name?: string;
51
51
  }
52
52
  | {
53
- /** Update only generated instructions. */
54
- command: "sync";
53
+ /** Capture stills of a subject or a video file in the production at the working directory. */
54
+ command: "capture";
55
55
 
56
- /** The directory holding `AGENTS.md`, resolved by run. */
57
- directory: string;
56
+ /** The tokens after `capture`, as typed; `run` reads them through the production's request grammar, which only the production's `@automovie/render` holds. */
57
+ args: string[];
58
+ }
59
+ | {
60
+ /** Serve the inspector page over a subject module of the production or package at the working directory. */
61
+ command: "inspect";
62
+
63
+ /** The tokens after `inspect`, as typed; `run` reads them through the production's request grammar, as for `capture`. */
64
+ args: string[];
65
+ }
66
+ | {
67
+ /** Render one subject of the production at the working directory into a video. */
68
+ command: "render";
58
69
 
59
- /** Inspect pending changes and conflicts without writing. */
60
- check: boolean;
70
+ /** The tokens after `render`, as typed; `run` reads them with the production's option reader. */
71
+ args: string[];
72
+ }
73
+ | {
74
+ /** Record real-time playback of the production's running inspector page. */
75
+ command: "review";
61
76
 
62
- /** Explicit prior adopted instruction root; the files it supplies govern over stored sync state. */
63
- baseline?: string;
77
+ /** The tokens after `review`, as typed; `run` reads them with the production's option reader. */
78
+ args: string[];
64
79
  };