automovie 0.1.0 → 0.2.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 +25 -13
  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 +114 -0
  18. package/lib/AutoMovieCaptureHost.js +219 -0
  19. package/lib/AutoMovieCaptureHost.js.map +1 -0
  20. package/lib/AutoMovieCommand.d.ts +24 -13
  21. package/lib/IAutoMovieChromium.d.ts +75 -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 +122 -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 +103 -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 +245 -0
  118. package/src/AutoMovieCommand.ts +28 -13
  119. package/src/IAutoMovieChromium.ts +78 -0
  120. package/src/captureAutoMovie.ts +148 -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 +81 -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 +168 -0
  140. package/src/renderAutoMovie.ts +86 -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 +116 -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
package/lib/run.js CHANGED
@@ -37,35 +37,67 @@ exports.run = run;
37
37
  const template_1 = require("@automovie/template");
38
38
  const fs = __importStar(require("node:fs"));
39
39
  const path = __importStar(require("node:path"));
40
+ const captureAutoMovie_1 = require("./captureAutoMovie");
40
41
  const deriveAutoMovieProjectName_1 = require("./deriveAutoMovieProjectName");
42
+ const inspectAutoMovie_1 = require("./inspectAutoMovie");
41
43
  const promptAutoMovieProjectName_1 = require("./promptAutoMovieProjectName");
42
44
  const readAutoMovieCommandArguments_1 = require("./readAutoMovieCommandArguments");
45
+ const renderAutoMovie_1 = require("./renderAutoMovie");
43
46
  const renderAutoMovieScaffoldNextSteps_1 = require("./renderAutoMovieScaffoldNextSteps");
44
- const selectAutoMoviePackageManager_1 = require("./selectAutoMoviePackageManager");
47
+ const reviewAutoMovie_1 = require("./reviewAutoMovie");
45
48
  const selectAutoMovieProjectName_1 = require("./selectAutoMovieProjectName");
46
- const USAGE = `automovie: scaffold an automovie project
49
+ const USAGE = `automovie: scaffold an automovie project, and capture, render and review it
47
50
 
48
51
  Usage:
49
52
  npx automovie create <directory> [--workspace] [--name <name>] [--force]
50
53
  pnpm automovie add <shorts|series>/<name> [--name <name>] [--force]
51
- npx automovie sync <directory> [--check] [--baseline <directory>]
54
+ automovie capture --module <file> [--props <json>] [--backend software|gpu] [--out <dir>] [<request>]
55
+ automovie capture --file <video> [--out <dir>] [<request>]
56
+ automovie inspect --module <file> [--props <json>] [--port <n>] [<request>]
57
+ automovie render --module <file> [--subject <name>] [--props <json>] [--out <dir>] [--backend software|gpu]
58
+ automovie review --url <inspector address> --seconds <s> [--out <dir>]
52
59
 
53
60
  Commands:
54
61
  create A single production, or with --workspace a pnpm workspace
55
62
  root for movies/shorts, movies/series and packages.
56
63
  add From a workspace root, a production at movies/<family>/<name>:
57
64
  shorts run brief -> screenplay, series the long route.
58
- sync Update the generated instructions of a single production
59
- or a workspace root.
65
+ capture In a production, draw the subjects a module offers in headless
66
+ Chromium, or take a video file's own frames, into stills,
67
+ contact sheets and record.json. Needs @automovie/render, vite
68
+ and playwright-core in the production, and FFmpeg for --file.
69
+ inspect In a production or package, serve the inspector page over the
70
+ subjects a module offers and print its address, whose query
71
+ is the request. Needs @automovie/render, @automovie/viewer,
72
+ react, react-dom and vite there; Ctrl+C stops it.
73
+ render In a production, draw every frame of one subject through the
74
+ draw page in headless Chromium and encode film.mp4 with
75
+ render-report.json. Needs what capture needs, and FFmpeg.
76
+ review Record real-time playback of the running inspector page as a
77
+ video with playback.json. Needs playwright-core and
78
+ Playwright's ffmpeg (npx playwright-core install ffmpeg).
60
79
 
61
80
  Options:
62
81
  --workspace Create a pnpm workspace root instead of a single production.
63
82
  --name Package name; create asks for one when the target is the
64
83
  current directory, and add defaults to the directory name.
65
84
  --force Install into a non-empty directory, replacing same-path files.
66
- --check Report a sync plan; exit 1 when updates or conflicts remain.
67
- --baseline Previous adopted instructions the files came from; they
68
- override the stored sync state for the files they hold.
85
+ --module capture, inspect, render: the module whose subjects(props)
86
+ the page draws.
87
+ --port inspect: the port to serve on; default a free port.
88
+ --props capture, inspect, render: a JSON file the module's subjects(props) is
89
+ called with; default null.
90
+ --file capture: an encoded video file instead of a subject.
91
+ --backend capture, render: software (SwiftShader, the default) or gpu.
92
+ --out capture: the folder; default media/capture/<subject>.
93
+ render: default media/automovie/<subject>/videos.
94
+ review: default media/automovie/review.
95
+ --url review: the running inspector page's address.
96
+ --seconds review: wall-clock seconds of playback recorded.
97
+ <request> capture, inspect: --subject, --at, --from, --to, --rate, --events,
98
+ --views, --passes, --marks, --label, --round, --compare and
99
+ every other key of the capture request grammar; render takes
100
+ --subject alone, the subject rendered, default the only one.
69
101
  -h, --help Show this help as a standalone request.
70
102
  -v, --version Print the version as a standalone request.
71
103
  `;
@@ -73,24 +105,27 @@ Options:
73
105
  * The `automovie` CLI entry. `argv` is the full process vector; its first two positions (executable and script) are skipped.
74
106
  *
75
107
  * - `help` and `version` write to stdout; the version is read from this package's `package.json`.
76
- * - `create` renders a single production, or with `--workspace` a workspace root, and publishes it into the directory resolved against the working directory. The name is the typed `--name`, else derived from the target's basename; for the working directory itself the terminal is asked, offering `automovie-examples`, which is used without asking when no terminal is attached.
77
- * - `add` requires `pnpm-workspace.yaml` in the working directory, which it takes as the workspace root without searching elsewhere, and publishes a workspace production into `movies/<family>/<directory>`, named by `--name`, else by the npm-safe name derived from the directory segment as `create` derives one.
78
- * - `sync` plans explicit generated-instruction updates for the directory holding `AGENTS.md`, preserves project contracts and content and refuses local conflicts; check reports pending updates without writing.
108
+ * - `create` writes a single production, or with `--workspace` a workspace root, into the directory resolved against the working directory. The name is the typed `--name`, else derived from the target's basename; for the working directory itself the terminal is asked, offering `automovie-examples`, which is used without asking when no terminal is attached.
109
+ * - `add` requires `pnpm-workspace.yaml` in the working directory, which it takes as the workspace root without searching elsewhere, and writes a workspace production into `movies/<family>/<directory>`, named by `--name`, else by the npm-safe name derived from the directory segment as `create` derives one.
110
+ * - `capture` runs `captureAutoMovie` in the working directory as the production, resolving to its status: 1 when a cell was not drawn.
111
+ * - `inspect` runs `inspectAutoMovie` in the working directory, serving the inspector page until the process is interrupted.
112
+ * - `render` runs `renderAutoMovie` in the working directory as the production, resolving to 0 once the video is written.
113
+ * - `review` runs `reviewAutoMovie`, resolving to 1 when the recorded page reported a script error.
79
114
  *
80
- * `create` and `add` refuse a non-empty target without `--force`. On success they list the written files relative to the target, then the next steps. Completed and partial file effects stay after failure; the error names the completed files and the stopping entry. Prepared directories can remain even when no file was written.
115
+ * `create` and `add` take their files from `createAutoMovieScaffold` and refuse a non-empty target without `--force`, which writes over same-path files and keeps every other file. On success they list the written files relative to the target, then the next steps. A failed write stops there and leaves the files already written.
81
116
  *
82
117
  * Resolves to the process exit code, 0 after queuing the requested stdout text or 1 after queuing a caught error's message and distinct `cause` objects' messages without stacks. A repeated cause ends the chain. Reading or stringifying an unusual thrown value, or writing stderr, can itself throw. The executable assigns the result to `process.exitCode` so queued output can drain.
83
118
  *
84
119
  * @param argv The full process vector.
85
120
  * @returns The exit code.
86
121
  *
87
- * @evidence contracts/development/implementation.md#principled-implementation Parsing finishes before rendering or publication, and path.resolve binds every target to the current working directory. A non-completed receipt becomes ScaffoldPublicationError, preserving the completed prefix and stopping outcome; describeError follows distinct cause values with a set to terminate cycles, but assumes their message access and string conversion do not throw.
88
- * @evidence contracts/development/implementation.md#clear-and-simple-structure This dispatcher delegates admission, name choice, the prompt and closing text to CLI owners and rendering and publication to the template package. Only bin.ts invokes it at module load, so importing run does not execute a request.
89
- * @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts `add` checks only the working directory for `pnpm-workspace.yaml` and never searches ancestors; only `create`'s next steps detect a package manager. The catch reports failures without stacks and never retries publication or rolls back files.
90
- * @evidence contracts/development/common.md#meaningful-documentation The comment gives argv ownership, every command's effect, name and target choice, retained file and directory effects, and the returned status.
91
- * @evidence contracts/development/implementation.md#efficient-algorithms For n files, rendering reads total bytes and sorts directory entries and the n rendered paths for deterministic order and collision reporting. Publication encodes those bytes and checks each path's ancestors before writing; listing scans completed paths once. Sync adds linear instruction reads and digests and the existing conditional publication path. Failure formatting additionally walks the distinct cause chain.
92
- * @evidence contracts/development/implementation.md#reuse-equivalent-work Every command takes fresh filesystem observations and cannot reuse an earlier receipt. Check observes without publishing. Rendering reads the installed scaffold anew; only the template's per-call directory captures are reused and revalidated during that publication.
93
- * @evidence contracts/development/implementation.md#bound-retention-and-release-resources Rendered strings, encoded candidate bytes, receipt entries, and listing text scale with scaffold size; the cause set scales with chain length without a fixed cap. The prompt closes its terminal interface before returning. This dispatcher owns no descriptor; queued stdout and stderr bytes belong to the process streams.
122
+ * @evidence contracts/development/implementation.md#principled-implementation Parsing finishes before the scaffold is created, the whole file map exists before the first write, and path.resolve binds every target to the current working directory. describeError follows distinct cause values with a set to terminate cycles, but assumes their message access and string conversion do not throw.
123
+ * @evidence contracts/development/implementation.md#clear-and-simple-structure This dispatcher delegates admission, name choice, the prompt and closing text to CLI owners and the file map to the template package, keeping only the write. Only bin.ts invokes it at module load, so importing run does not execute a request.
124
+ * @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts `add` checks only the working directory for `pnpm-workspace.yaml` and never searches ancestors. The catch reports failures without stacks and never retries a write or rolls back files.
125
+ * @evidence contracts/development/common.md#meaningful-documentation The comment gives argv ownership, every command's effect, name and target choice, retained file effects, and the returned status.
126
+ * @evidence contracts/development/implementation.md#efficient-algorithms For n files, creation reads the scaffold once and each file is written once with its directory ensured; listing scans the written paths once. Failure formatting additionally walks the distinct cause chain.
127
+ * @evidenceExclude contracts/development/implementation.md#reuse-equivalent-work Every command takes fresh filesystem observations and reads the installed scaffold anew.
128
+ * @evidence contracts/development/implementation.md#bound-retention-and-release-resources The file map and listing text scale with scaffold size; the cause set scales with chain length without a fixed cap. The prompt closes its terminal interface before returning. This dispatcher owns no descriptor; queued stdout and stderr bytes belong to the process streams.
94
129
  */
95
130
  async function run(argv) {
96
131
  try {
@@ -103,52 +138,48 @@ async function run(argv) {
103
138
  process.stdout.write(`${packageVersion()}\n`);
104
139
  return 0;
105
140
  }
106
- if (command.command === "sync") {
107
- const targetDir = path.resolve(process.cwd(), command.directory);
108
- const result = (0, template_1.syncScaffold)({
109
- location: targetDir,
110
- check: command.check,
111
- baseline: command.baseline,
141
+ if (command.command === "capture")
142
+ return await (0, captureAutoMovie_1.captureAutoMovie)({
143
+ args: command.args,
144
+ root: process.cwd(),
145
+ env: process.env,
146
+ });
147
+ if (command.command === "inspect")
148
+ return await (0, inspectAutoMovie_1.inspectAutoMovie)({
149
+ args: command.args,
150
+ root: process.cwd(),
151
+ });
152
+ if (command.command === "render")
153
+ return await (0, renderAutoMovie_1.renderAutoMovie)({
154
+ args: command.args,
155
+ root: process.cwd(),
156
+ env: process.env,
157
+ });
158
+ if (command.command === "review")
159
+ return await (0, reviewAutoMovie_1.reviewAutoMovie)({
160
+ args: command.args,
161
+ root: process.cwd(),
162
+ env: process.env,
112
163
  });
113
- process.stdout.write(`Scaffold sync ${result.status}: ${targetDir}\n` +
114
- [
115
- ...Object.keys(result.plan.files).map((file) => ` update ${file}`),
116
- ...result.plan.conflicts.map((file) => ` conflict ${file}`),
117
- ...result.plan.retired.map((file) => ` retained retired instruction ${file}`),
118
- ].join("\n") +
119
- "\n");
120
- if (result.receipt !== undefined && result.receipt.status !== "completed")
121
- throw new template_1.ScaffoldPublicationError(result.receipt);
122
- return result.status === "conflicted" ||
123
- (command.check && Object.keys(result.plan.files).length > 0)
124
- ? 1
125
- : 0;
126
- }
127
164
  if (command.command === "add") {
128
165
  const root = process.cwd();
129
166
  if (!fs.existsSync(path.join(root, "pnpm-workspace.yaml")))
130
167
  throw new Error(`add runs at an AutoMovie workspace root, and ${root} has no pnpm-workspace.yaml; create one with automovie create <directory> --workspace.`);
131
- const targetDir = path.join(root, "movies", command.family, command.directory);
132
- publish(targetDir, (0, template_1.renderWorkspaceProductionScaffold)({
168
+ write(path.join(root, "movies", command.family, command.directory), {
169
+ kind: "workspace-production",
133
170
  name: command.name ?? (0, deriveAutoMovieProjectName_1.deriveAutoMovieProjectName)(command.directory),
134
- }), command.force, "workspace-production");
171
+ }, command.force);
135
172
  return 0;
136
173
  }
137
174
  // Create: a typed or derived name, else the terminal's answer for the working directory itself.
138
- const targetDir = path.resolve(process.cwd(), command.directory);
139
- const name = (0, selectAutoMovieProjectName_1.selectAutoMovieProjectName)({
140
- directory: command.directory,
141
- cwd: process.cwd(),
142
- ...(command.name === undefined ? {} : { name: command.name }),
143
- }) ?? (await (0, promptAutoMovieProjectName_1.promptAutoMovieProjectName)());
144
- publish(targetDir, command.workspace
145
- ? (0, template_1.renderWorkspaceScaffold)({ name })
146
- : (0, template_1.renderScaffold)({ name }), command.force, command.workspace ? "workspace" : "production", (0, selectAutoMoviePackageManager_1.selectAutoMoviePackageManager)({
147
- directory: targetDir,
148
- ...(process.env.npm_config_user_agent === undefined
149
- ? {}
150
- : { userAgent: process.env.npm_config_user_agent }),
151
- }));
175
+ write(path.resolve(process.cwd(), command.directory), {
176
+ kind: command.workspace ? "workspace" : "production",
177
+ name: (0, selectAutoMovieProjectName_1.selectAutoMovieProjectName)({
178
+ directory: command.directory,
179
+ cwd: process.cwd(),
180
+ ...(command.name === undefined ? {} : { name: command.name }),
181
+ }) ?? (await (0, promptAutoMovieProjectName_1.promptAutoMovieProjectName)()),
182
+ }, command.force);
152
183
  return 0;
153
184
  }
154
185
  catch (error) {
@@ -157,19 +188,24 @@ async function run(argv) {
157
188
  }
158
189
  }
159
190
  /**
160
- * Publish one rendered installation, then list the written files and the next steps; a refused or partial receipt throws with its completed prefix.
191
+ * Write one created installation into `directory`, then list the written files and the next steps. A non-empty directory is refused unless `force` is set, which writes over same-path files and keeps every other file.
161
192
  */
162
- function publish(targetDir, files, force, kind, packageManager) {
163
- const receipt = (0, template_1.publishFiles)(targetDir, files, {
164
- force,
165
- });
166
- if (receipt.status !== "completed")
167
- throw new template_1.ScaffoldPublicationError(receipt);
168
- process.stdout.write(`Scaffolded ${receipt.completed.length} files into ${targetDir}\n\n` +
169
- receipt.completed
170
- .map(({ entry }) => ` ${entry.relative}`)
193
+ function write(directory, props, force) {
194
+ const files = (0, template_1.createAutoMovieScaffold)(props);
195
+ if (force === false &&
196
+ fs.existsSync(directory) &&
197
+ fs.readdirSync(directory).length !== 0)
198
+ throw new Error(`${directory} is not empty; pass --force to write into it, replacing same-path files.`);
199
+ for (const [relative, content] of Object.entries(files)) {
200
+ const file = path.join(directory, relative);
201
+ fs.mkdirSync(path.dirname(file), { recursive: true });
202
+ fs.writeFileSync(file, content, "utf8");
203
+ }
204
+ process.stdout.write(`Scaffolded ${Object.keys(files).length} files into ${directory}\n\n` +
205
+ Object.keys(files)
206
+ .map((relative) => ` ${relative}`)
171
207
  .join("\n") +
172
- (0, renderAutoMovieScaffoldNextSteps_1.renderAutoMovieScaffoldNextSteps)(targetDir, kind, packageManager));
208
+ (0, renderAutoMovieScaffoldNextSteps_1.renderAutoMovieScaffoldNextSteps)(directory, props.kind));
173
209
  }
174
210
  /**
175
211
  * This package's version, read at runtime from the sibling `package.json` (`require`, not an `import`, so it stays outside `rootDir`). `__dirname` resolves to `src` under ttsx and `lib` when published; the file sits one level up in both.
package/lib/run.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"run.js","sourceRoot":"","sources":["../src/run.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAS6B;AAC7B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AK,KAAK,EAAE,CAAC;QAC5D,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAClB,MAAM,OAAO,GACX,OAAO,YAAY,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAC/D,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,gBAAgB,OAAO,EAAE,CAAC,CAAC;QACrE,OAAO,GAAG,OAAO,YAAY,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;IACjE,CAAC;IACD,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;AACjC,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Run FFmpeg once with the given arguments, resolving with its error output when it exits as `accept` allows and rejecting otherwise.
3
+ *
4
+ * FFmpeg writes its log, including a probe of every input, to its error output, so that text is what callers read. By default only exit status 0 is accepted; a probe that names no output exits 1 by design and accepts it. A rejection names the binary, the exit status and the last lines of the log.
5
+ *
6
+ * @evidence contracts/development/common.md#meaningful-documentation States what is resolved, the acceptance rule and its default, and what a rejection names.
7
+ * @evidence contracts/development/implementation.md#principled-implementation `child_process.spawn` without a shell passes each argument as it is, so a path with spaces or quotes needs no escaping.
8
+ * @evidence contracts/development/implementation.md#clear-and-simple-structure Spawn, collect the error output, settle on exit.
9
+ * @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts A failed run is never retried, and a failure to start rejects with its cause.
10
+ * @evidence contracts/development/implementation.md#efficient-algorithms Linear in the log FFmpeg writes.
11
+ * @evidenceExclude contracts/development/implementation.md#reuse-equivalent-work Each run is its own process.
12
+ * @evidence contracts/development/implementation.md#bound-retention-and-release-resources The child process ends before the promise settles; its log is held until then.
13
+ */
14
+ export declare function runAutoMovieFfmpeg(binary: string, args: readonly string[], accept?: (code: number | null) => boolean): Promise<string>;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.runAutoMovieFfmpeg = runAutoMovieFfmpeg;
4
+ const node_child_process_1 = require("node:child_process");
5
+ /** Lines of FFmpeg's error output kept for a failure message. */
6
+ const TAIL = 12;
7
+ /**
8
+ * Run FFmpeg once with the given arguments, resolving with its error output when it exits as `accept` allows and rejecting otherwise.
9
+ *
10
+ * FFmpeg writes its log, including a probe of every input, to its error output, so that text is what callers read. By default only exit status 0 is accepted; a probe that names no output exits 1 by design and accepts it. A rejection names the binary, the exit status and the last lines of the log.
11
+ *
12
+ * @evidence contracts/development/common.md#meaningful-documentation States what is resolved, the acceptance rule and its default, and what a rejection names.
13
+ * @evidence contracts/development/implementation.md#principled-implementation `child_process.spawn` without a shell passes each argument as it is, so a path with spaces or quotes needs no escaping.
14
+ * @evidence contracts/development/implementation.md#clear-and-simple-structure Spawn, collect the error output, settle on exit.
15
+ * @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts A failed run is never retried, and a failure to start rejects with its cause.
16
+ * @evidence contracts/development/implementation.md#efficient-algorithms Linear in the log FFmpeg writes.
17
+ * @evidenceExclude contracts/development/implementation.md#reuse-equivalent-work Each run is its own process.
18
+ * @evidence contracts/development/implementation.md#bound-retention-and-release-resources The child process ends before the promise settles; its log is held until then.
19
+ */
20
+ function runAutoMovieFfmpeg(binary, args, accept = (code) => code === 0) {
21
+ return new Promise((resolve, reject) => {
22
+ const child = (0, node_child_process_1.spawn)(binary, [...args], {
23
+ stdio: ["ignore", "ignore", "pipe"],
24
+ windowsHide: true,
25
+ });
26
+ let log = "";
27
+ child.stderr.setEncoding("utf8");
28
+ child.stderr.on("data", (chunk) => {
29
+ log += chunk;
30
+ });
31
+ child.on("error", (error) => reject(new Error(`FFmpeg ${binary} did not start`, { cause: error })));
32
+ child.on("close", (code) => {
33
+ if (accept(code))
34
+ resolve(log);
35
+ else
36
+ reject(new Error(`FFmpeg ${binary} exited with ${code}:\n${log.trimEnd().split(/\r?\n/u).slice(-TAIL).join("\n")}`));
37
+ });
38
+ });
39
+ }
40
+ //# sourceMappingURL=runAutoMovieFfmpeg.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runAutoMovieFfmpeg.js","sourceRoot":"","sources":["../src/runAutoMovieFfmpeg.ts"],"names":[],"mappings":";;;AAAA,2DAA2C;AAE3C,iEAAiE;AACjE,MAAM,IAAI,GAAW,EAAE,CAAC;AAExB;;;;;;;;;;;;GAYG;AACH,4BACE,MAAc,EACd,IAAuB,EACvB,MAAM,GAAqC,CAAC,IAAmB,EAAW,EAAE,CAC1E,IAAI,KAAK,CAAC;IAEZ,OAAO,IAAI,OAAO,CAChB,CAAC,OAA8B,EAAE,MAA8B,EAAQ,EAAE;QACvE,MAAM,KAAK,GAA6B,IAAA,0BAAK,EAAC,MAAM,EAAE,CAAC,GAAG,IAAI,CAAC,EAAE;YAC/D,KAAK,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,CAAC;YACnC,WAAW,EAAE,IAAI;SAClB,CAAC,CAAC;QACH,IAAI,GAAG,GAAW,EAAE,CAAC;QACrB,KAAK,CAAC,MAAO,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;QAClC,KAAK,CAAC,MAAO,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAa,EAAQ,EAAE;YAC/C,GAAG,IAAI,KAAK,CAAC;QACf,CAAC,CAAC,CAAC;QACH,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,KAAY,EAAQ,EAAE,CACvC,MAAM,CAAC,IAAI,KAAK,CAAC,UAAU,MAAM,gBAAgB,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC,CACtE,CAAC;QACF,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,IAAmB,EAAQ,EAAE;YAC9C,IAAI,MAAM,CAAC,IAAI,CAAC;gBAAE,OAAO,CAAC,GAAG,CAAC,CAAC;;gBAE7B,MAAM,CACJ,IAAI,KAAK,CACP,UAAU,MAAM,gBAAgB,IAAI,MAAM,GAAG,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAClG,CACF,CAAC;QACN,CAAC,CAAC,CAAC;IACL,CAAC,CACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Build a draw-only page for a subject module with the production's Vite, serve it with `vite preview`, and return its address and the call that stops the server and deletes the build.
3
+ *
4
+ * The page is generated in a scratch folder under `<root>/node_modules/.cache/automovie/`: an `index.html` with no interface and a script that calls `installAutoMovieDraw` with the module's `subjects` export. The build takes `planAutoMovieModulePageViteConfig`, the one configuration both page hosts share: the production's `vite.config.ts` when it has one and its `public` folder as its public files, with the generated page as the only input, so a subject loads the assets and plugins the production's own page does. The preview listens on 127.0.0.1 at a free port with `strictPort`, so it never moves to another server's port.
5
+ *
6
+ * It rejects when the module does not exist, naming it, and when the build or the server fails, after deleting the scratch folder.
7
+ *
8
+ * @evidence contracts/development/common.md#meaningful-documentation States what is generated and where, how the build is configured and why, where the server listens, what the return holds, and the refusals.
9
+ * @evidence contracts/development/implementation.md#principled-implementation A built page served by `vite preview` does not rebuild or reload while pages draw, which the development server does on a new import; the scratch folder sits inside the production so bare imports resolve from its own dependencies.
10
+ * @evidence contracts/development/implementation.md#clear-and-simple-structure Generate through `writeAutoMovieModulePage`, which the inspector page shares, build, find a port, preview; the draw function and subjects are the page's.
11
+ * @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts The production's page and configuration file are left untouched; the generated page replaces only the build input.
12
+ * @evidence contracts/development/implementation.md#efficient-algorithms One build per host; every capture of the host reuses the served page.
13
+ * @evidence contracts/development/implementation.md#reuse-equivalent-work The built page serves every subject and round of one host.
14
+ * @evidence contracts/development/implementation.md#bound-retention-and-release-resources The server and the scratch folder are owned by the returned `close`, which stops one and deletes the other; a failed start deletes the folder before rejecting.
15
+ */
16
+ export declare function serveAutoMovieDrawPage(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
+ /** The production's `vite`. */
22
+ vite: unknown;
23
+ }): Promise<{
24
+ /** Address of the draw page. */
25
+ url: string;
26
+ /** Stop the server and delete the build. */
27
+ close: () => Promise<void>;
28
+ }>;
@@ -0,0 +1,108 @@
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.serveAutoMovieDrawPage = serveAutoMovieDrawPage;
37
+ const path = __importStar(require("node:path"));
38
+ const node_util_1 = require("node:util");
39
+ const findAutoMovieFreePort_1 = require("./findAutoMovieFreePort");
40
+ const planAutoMovieModulePageViteConfig_1 = require("./planAutoMovieModulePageViteConfig");
41
+ const writeAutoMovieModulePage_1 = require("./writeAutoMovieModulePage");
42
+ /**
43
+ * Build a draw-only page for a subject module with the production's Vite, serve it with `vite preview`, and return its address and the call that stops the server and deletes the build.
44
+ *
45
+ * The page is generated in a scratch folder under `<root>/node_modules/.cache/automovie/`: an `index.html` with no interface and a script that calls `installAutoMovieDraw` with the module's `subjects` export. The build takes `planAutoMovieModulePageViteConfig`, the one configuration both page hosts share: the production's `vite.config.ts` when it has one and its `public` folder as its public files, with the generated page as the only input, so a subject loads the assets and plugins the production's own page does. The preview listens on 127.0.0.1 at a free port with `strictPort`, so it never moves to another server's port.
46
+ *
47
+ * It rejects when the module does not exist, naming it, and when the build or the server fails, after deleting the scratch folder.
48
+ *
49
+ * @evidence contracts/development/common.md#meaningful-documentation States what is generated and where, how the build is configured and why, where the server listens, what the return holds, and the refusals.
50
+ * @evidence contracts/development/implementation.md#principled-implementation A built page served by `vite preview` does not rebuild or reload while pages draw, which the development server does on a new import; the scratch folder sits inside the production so bare imports resolve from its own dependencies.
51
+ * @evidence contracts/development/implementation.md#clear-and-simple-structure Generate through `writeAutoMovieModulePage`, which the inspector page shares, build, find a port, preview; the draw function and subjects are the page's.
52
+ * @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts The production's page and configuration file are left untouched; the generated page replaces only the build input.
53
+ * @evidence contracts/development/implementation.md#efficient-algorithms One build per host; every capture of the host reuses the served page.
54
+ * @evidence contracts/development/implementation.md#reuse-equivalent-work The built page serves every subject and round of one host.
55
+ * @evidence contracts/development/implementation.md#bound-retention-and-release-resources The server and the scratch folder are owned by the returned `close`, which stops one and deletes the other; a failed start deletes the folder before rejecting.
56
+ */
57
+ async function serveAutoMovieDrawPage(props) {
58
+ const vite = props.vite;
59
+ // The generated page, in a scratch folder of this process.
60
+ const page = (0, writeAutoMovieModulePage_1.writeAutoMovieModulePage)({
61
+ root: props.root,
62
+ module: props.module,
63
+ kind: "draw",
64
+ title: "draw",
65
+ body: "",
66
+ script: (specifier) => `import { installAutoMovieDraw } from "@automovie/render";\nimport { subjects } from ${JSON.stringify(specifier)};\n\ninstallAutoMovieDraw(subjects);\n`,
67
+ });
68
+ const scratch = page.folder;
69
+ const remove = page.remove;
70
+ try {
71
+ // The production's configuration, with the generated page as the only input.
72
+ const outDir = path.join(scratch, "dist");
73
+ await vite.build({
74
+ ...(0, planAutoMovieModulePageViteConfig_1.planAutoMovieModulePageViteConfig)(page),
75
+ base: "./",
76
+ build: {
77
+ outDir,
78
+ emptyOutDir: true,
79
+ target: "es2022",
80
+ reportCompressedSize: false,
81
+ chunkSizeWarningLimit: Number.MAX_SAFE_INTEGER,
82
+ rollupOptions: { input: path.join(scratch, "index.html") },
83
+ },
84
+ });
85
+ const port = await (0, findAutoMovieFreePort_1.findAutoMovieFreePort)();
86
+ const server = await vite.preview({
87
+ root: scratch,
88
+ configFile: false,
89
+ base: "./",
90
+ logLevel: "warn",
91
+ clearScreen: false,
92
+ build: { outDir },
93
+ preview: { host: "127.0.0.1", port, strictPort: true, open: false },
94
+ });
95
+ return {
96
+ url: `http://127.0.0.1:${port}/index.html`,
97
+ close: async () => {
98
+ await (0, node_util_1.promisify)((done) => server.httpServer.close(done))();
99
+ remove();
100
+ },
101
+ };
102
+ }
103
+ catch (error) {
104
+ remove();
105
+ throw error;
106
+ }
107
+ }
108
+ //# sourceMappingURL=serveAutoMovieDrawPage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serveAutoMovieDrawPage.js","sourceRoot":"","sources":["../src/serveAutoMovieDrawPage.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,MAAY,IAAI,sCAAkB;AAClC,yCAAsC;AAEtC,mEAAgE;AAChE,2FAAwF;AACxF,y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AE,KAAK;YAClB,KAAK,EAAE,EAAE,MAAM,EAAE;YACjB,OAAO,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE;SACpE,CAAC,CAAC;QACH,OAAO;YACL,GAAG,EAAE,oBAAoB,IAAI,aAAa;YAC1C,KAAK,EAAE,KAAK,IAAmB,EAAE;gBAC/B,MAAM,IAAA,qBAAS,EAAC,CAAC,IAA6B,EAAQ,EAAE,CACtD,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,CAC9B,EAAE,CAAC;gBACJ,MAAM,EAAE,CAAC;YACX,CAAC;SACF,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,EAAE,CAAC;QACT,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Serve the inspector page over a subject module with the production's Vite in development mode, and return its address and the call that stops it.
3
+ *
4
+ * The page is written by `writeAutoMovieModulePage`, as the draw page is: one `div` and a script that calls `@automovie/viewer`'s `mountAutoMovieInspectorPage` with the module's `subjects` called on `props` and the window's `location` and `history`, the same call the scaffold's own page makes. The development server takes `planAutoMovieModulePageViteConfig`: the production's `vite.config.ts` and `public` folder and the page as the dependency scanner's entry, so dependencies are pre-bundled before the first load; listens on 127.0.0.1 at `port` or a free port with `strictPort`, and transforms the production's sources on request, so an edit is seen on the next reload.
5
+ *
6
+ * It rejects when the module does not exist, naming it, and when the server cannot start, after deleting the scratch folder.
7
+ *
8
+ * @evidence contracts/development/common.md#meaningful-documentation States what the page runs, which configuration serves it, where it listens and why a development server is used, what the return holds, and the refusals.
9
+ * @evidence contracts/development/implementation.md#principled-implementation A person inspecting edits sources between looks, so the page is served by Vite's development server, which compiles each module when the page asks for it; capture draws a built page instead because it must not reload between cells.
10
+ * @evidence contracts/development/implementation.md#clear-and-simple-structure Write the page, find a port, start the server; the inspector and the subjects are the page's.
11
+ * @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts The production's own page and configuration file are left untouched, and a taken port fails the start instead of moving to another.
12
+ * @evidence contracts/development/implementation.md#efficient-algorithms One server for the command's life; Vite compiles what the page imports.
13
+ * @evidenceExclude contracts/development/implementation.md#reuse-equivalent-work One page per command.
14
+ * @evidence contracts/development/implementation.md#bound-retention-and-release-resources The server and the scratch folder are owned by the returned `close`, which stops one and deletes the other; a failed start deletes the folder before rejecting.
15
+ */
16
+ export declare function serveAutoMovieInspectorPage(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
+ /** The production's `vite`. */
22
+ vite: unknown;
23
+ /** The port to listen on, or null for a free one. */
24
+ port: number | null;
25
+ /** The JSON value the module's `subjects` is called with, null for none. */
26
+ props: unknown;
27
+ }): Promise<{
28
+ /** Address of the inspector page, without a query. */
29
+ url: string;
30
+ /** Stop the server and delete the page. */
31
+ close: () => Promise<void>;
32
+ }>;
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.serveAutoMovieInspectorPage = serveAutoMovieInspectorPage;
4
+ const findAutoMovieFreePort_1 = require("./findAutoMovieFreePort");
5
+ const planAutoMovieModulePageViteConfig_1 = require("./planAutoMovieModulePageViteConfig");
6
+ const writeAutoMovieModulePage_1 = require("./writeAutoMovieModulePage");
7
+ /**
8
+ * Serve the inspector page over a subject module with the production's Vite in development mode, and return its address and the call that stops it.
9
+ *
10
+ * The page is written by `writeAutoMovieModulePage`, as the draw page is: one `div` and a script that calls `@automovie/viewer`'s `mountAutoMovieInspectorPage` with the module's `subjects` called on `props` and the window's `location` and `history`, the same call the scaffold's own page makes. The development server takes `planAutoMovieModulePageViteConfig`: the production's `vite.config.ts` and `public` folder and the page as the dependency scanner's entry, so dependencies are pre-bundled before the first load; listens on 127.0.0.1 at `port` or a free port with `strictPort`, and transforms the production's sources on request, so an edit is seen on the next reload.
11
+ *
12
+ * It rejects when the module does not exist, naming it, and when the server cannot start, after deleting the scratch folder.
13
+ *
14
+ * @evidence contracts/development/common.md#meaningful-documentation States what the page runs, which configuration serves it, where it listens and why a development server is used, what the return holds, and the refusals.
15
+ * @evidence contracts/development/implementation.md#principled-implementation A person inspecting edits sources between looks, so the page is served by Vite's development server, which compiles each module when the page asks for it; capture draws a built page instead because it must not reload between cells.
16
+ * @evidence contracts/development/implementation.md#clear-and-simple-structure Write the page, find a port, start the server; the inspector and the subjects are the page's.
17
+ * @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts The production's own page and configuration file are left untouched, and a taken port fails the start instead of moving to another.
18
+ * @evidence contracts/development/implementation.md#efficient-algorithms One server for the command's life; Vite compiles what the page imports.
19
+ * @evidenceExclude contracts/development/implementation.md#reuse-equivalent-work One page per command.
20
+ * @evidence contracts/development/implementation.md#bound-retention-and-release-resources The server and the scratch folder are owned by the returned `close`, which stops one and deletes the other; a failed start deletes the folder before rejecting.
21
+ */
22
+ async function serveAutoMovieInspectorPage(props) {
23
+ const vite = props.vite;
24
+ const page = (0, writeAutoMovieModulePage_1.writeAutoMovieModulePage)({
25
+ root: props.root,
26
+ module: props.module,
27
+ kind: "inspect",
28
+ title: "AutoMovie inspector",
29
+ body: `<div id="root"></div>`,
30
+ script: (specifier) => `import { mountAutoMovieInspectorPage } from "@automovie/viewer";\nimport { subjects } from ${JSON.stringify(specifier)};\n\nmountAutoMovieInspectorPage({\n root: document.getElementById("root"),\n subjects: subjects(${JSON.stringify(props.props ?? null)}),\n location: window.location,\n history: window.history,\n});\n`,
31
+ });
32
+ try {
33
+ const port = props.port ?? (await (0, findAutoMovieFreePort_1.findAutoMovieFreePort)());
34
+ const server = await vite.createServer({
35
+ ...(0, planAutoMovieModulePageViteConfig_1.planAutoMovieModulePageViteConfig)(page),
36
+ server: { host: "127.0.0.1", port, strictPort: true, open: false },
37
+ });
38
+ await server.listen();
39
+ return {
40
+ url: `http://127.0.0.1:${port}/`,
41
+ close: async () => {
42
+ await server.close();
43
+ page.remove();
44
+ },
45
+ };
46
+ }
47
+ catch (error) {
48
+ page.remove();
49
+ throw error;
50
+ }
51
+ }
52
+ //# sourceMappingURL=serveAutoMovieInspectorPage.js.map
@@ -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;YACh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