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.
- package/README.md +28 -16
- package/lib/AUTOMOVIE_CAPTURE_OPTIONS.d.ts +6 -0
- package/lib/AUTOMOVIE_CAPTURE_OPTIONS.js +16 -0
- package/lib/AUTOMOVIE_CAPTURE_OPTIONS.js.map +1 -0
- package/lib/AUTOMOVIE_INSPECT_OPTIONS.d.ts +6 -0
- package/lib/AUTOMOVIE_INSPECT_OPTIONS.js +14 -0
- package/lib/AUTOMOVIE_INSPECT_OPTIONS.js.map +1 -0
- package/lib/AUTOMOVIE_RENDER_OPTIONS.d.ts +6 -0
- package/lib/AUTOMOVIE_RENDER_OPTIONS.js +15 -0
- package/lib/AUTOMOVIE_RENDER_OPTIONS.js.map +1 -0
- package/lib/AUTOMOVIE_REVIEW_OPTIONS.d.ts +6 -0
- package/lib/AUTOMOVIE_REVIEW_OPTIONS.js +14 -0
- package/lib/AUTOMOVIE_REVIEW_OPTIONS.js.map +1 -0
- package/lib/AutoMovieCaptureBackend.d.ts +9 -0
- package/lib/{IAutoMoviePackageManager.js → AutoMovieCaptureBackend.js} +1 -1
- package/lib/AutoMovieCaptureBackend.js.map +1 -0
- package/lib/AutoMovieCaptureHost.d.ts +115 -0
- package/lib/AutoMovieCaptureHost.js +234 -0
- package/lib/AutoMovieCaptureHost.js.map +1 -0
- package/lib/AutoMovieCommand.d.ts +24 -13
- package/lib/IAutoMovieChromium.d.ts +84 -0
- package/lib/IAutoMovieChromium.js +3 -0
- package/lib/IAutoMovieChromium.js.map +1 -0
- package/lib/captureAutoMovie.d.ts +23 -0
- package/lib/captureAutoMovie.js +133 -0
- package/lib/captureAutoMovie.js.map +1 -0
- package/lib/deriveAutoMovieProjectName.d.ts +1 -1
- package/lib/deriveAutoMovieProjectName.js +1 -1
- package/lib/findAutoMovieFreePort.d.ts +14 -0
- package/lib/findAutoMovieFreePort.js +61 -0
- package/lib/findAutoMovieFreePort.js.map +1 -0
- package/lib/formatAutoMovieInspectUrl.d.ts +14 -0
- package/lib/formatAutoMovieInspectUrl.js +24 -0
- package/lib/formatAutoMovieInspectUrl.js.map +1 -0
- package/lib/index.d.ts +30 -2
- package/lib/index.js +30 -2
- package/lib/index.js.map +1 -1
- package/lib/inspectAutoMovie.d.ts +19 -0
- package/lib/inspectAutoMovie.js +97 -0
- package/lib/inspectAutoMovie.js.map +1 -0
- package/lib/launchAutoMovieChromium.d.ts +28 -0
- package/lib/launchAutoMovieChromium.js +42 -0
- package/lib/launchAutoMovieChromium.js.map +1 -0
- package/lib/loadAutoMovieProductionModule.d.ts +14 -0
- package/lib/loadAutoMovieProductionModule.js +61 -0
- package/lib/loadAutoMovieProductionModule.js.map +1 -0
- package/lib/planAutoMovieChromiumLaunch.d.ts +27 -0
- package/lib/planAutoMovieChromiumLaunch.js +34 -0
- package/lib/planAutoMovieChromiumLaunch.js.map +1 -0
- package/lib/planAutoMovieModulePageViteConfig.d.ts +37 -0
- package/lib/planAutoMovieModulePageViteConfig.js +27 -0
- package/lib/planAutoMovieModulePageViteConfig.js.map +1 -0
- package/lib/readAutoMovieAddArguments.d.ts +1 -1
- package/lib/readAutoMovieAddArguments.js +1 -1
- package/lib/readAutoMovieCaptureHostOptions.d.ts +36 -0
- package/lib/readAutoMovieCaptureHostOptions.js +57 -0
- package/lib/readAutoMovieCaptureHostOptions.js.map +1 -0
- package/lib/readAutoMovieCommandArguments.d.ts +1 -1
- package/lib/readAutoMovieCommandArguments.js +10 -5
- package/lib/readAutoMovieCommandArguments.js.map +1 -1
- package/lib/readAutoMovieCreateArguments.d.ts +1 -1
- package/lib/readAutoMovieCreateArguments.js +1 -1
- package/lib/readAutoMovieInspectHostOptions.d.ts +29 -0
- package/lib/readAutoMovieInspectHostOptions.js +48 -0
- package/lib/readAutoMovieInspectHostOptions.js.map +1 -0
- package/lib/readAutoMovieRenderOptions.d.ts +33 -0
- package/lib/readAutoMovieRenderOptions.js +51 -0
- package/lib/readAutoMovieRenderOptions.js.map +1 -0
- package/lib/readAutoMovieReviewOptions.d.ts +27 -0
- package/lib/readAutoMovieReviewOptions.js +54 -0
- package/lib/readAutoMovieReviewOptions.js.map +1 -0
- package/lib/readAutoMovieRevision.d.ts +12 -0
- package/lib/readAutoMovieRevision.js +32 -0
- package/lib/readAutoMovieRevision.js.map +1 -0
- package/lib/readAutoMovieVideoProbe.d.ts +23 -0
- package/lib/readAutoMovieVideoProbe.js +39 -0
- package/lib/readAutoMovieVideoProbe.js.map +1 -0
- package/lib/recordAutoMoviePlayback.d.ts +37 -0
- package/lib/recordAutoMoviePlayback.js +131 -0
- package/lib/recordAutoMoviePlayback.js.map +1 -0
- package/lib/renderAutoMovie.d.ts +21 -0
- package/lib/renderAutoMovie.js +95 -0
- package/lib/renderAutoMovie.js.map +1 -0
- package/lib/renderAutoMovieScaffoldNextSteps.d.ts +3 -5
- package/lib/renderAutoMovieScaffoldNextSteps.js +5 -14
- package/lib/renderAutoMovieScaffoldNextSteps.js.map +1 -1
- package/lib/renderAutoMovieVideo.d.ts +35 -0
- package/lib/renderAutoMovieVideo.js +110 -0
- package/lib/renderAutoMovieVideo.js.map +1 -0
- package/lib/resolveAutoMovieFfmpeg.d.ts +19 -0
- package/lib/resolveAutoMovieFfmpeg.js +32 -0
- package/lib/resolveAutoMovieFfmpeg.js.map +1 -0
- package/lib/reviewAutoMovie.d.ts +21 -0
- package/lib/reviewAutoMovie.js +71 -0
- package/lib/reviewAutoMovie.js.map +1 -0
- package/lib/run.d.ts +14 -11
- package/lib/run.js +139 -67
- package/lib/run.js.map +1 -1
- package/lib/runAutoMovieFfmpeg.d.ts +14 -0
- package/lib/runAutoMovieFfmpeg.js +40 -0
- package/lib/runAutoMovieFfmpeg.js.map +1 -0
- package/lib/serveAutoMovieDrawPage.d.ts +28 -0
- package/lib/serveAutoMovieDrawPage.js +108 -0
- package/lib/serveAutoMovieDrawPage.js.map +1 -0
- package/lib/serveAutoMovieInspectorPage.d.ts +32 -0
- package/lib/serveAutoMovieInspectorPage.js +52 -0
- package/lib/serveAutoMovieInspectorPage.js.map +1 -0
- package/lib/writeAutoMovieModulePage.d.ts +38 -0
- package/lib/writeAutoMovieModulePage.js +75 -0
- package/lib/writeAutoMovieModulePage.js.map +1 -0
- package/package.json +26 -5
- package/src/AUTOMOVIE_CAPTURE_OPTIONS.ts +12 -0
- package/src/AUTOMOVIE_INSPECT_OPTIONS.ts +10 -0
- package/src/AUTOMOVIE_RENDER_OPTIONS.ts +11 -0
- package/src/AUTOMOVIE_REVIEW_OPTIONS.ts +10 -0
- package/src/AutoMovieCaptureBackend.ts +9 -0
- package/src/AutoMovieCaptureHost.ts +276 -0
- package/src/AutoMovieCommand.ts +28 -13
- package/src/IAutoMovieChromium.ts +89 -0
- package/src/captureAutoMovie.ts +150 -0
- package/src/deriveAutoMovieProjectName.ts +1 -1
- package/src/findAutoMovieFreePort.ts +27 -0
- package/src/formatAutoMovieInspectUrl.ts +25 -0
- package/src/index.ts +30 -2
- package/src/inspectAutoMovie.ts +82 -0
- package/src/launchAutoMovieChromium.ts +61 -0
- package/src/loadAutoMovieProductionModule.ts +30 -0
- package/src/planAutoMovieChromiumLaunch.ts +45 -0
- package/src/planAutoMovieModulePageViteConfig.ts +53 -0
- package/src/readAutoMovieAddArguments.ts +1 -1
- package/src/readAutoMovieCaptureHostOptions.ts +76 -0
- package/src/readAutoMovieCommandArguments.ts +6 -4
- package/src/readAutoMovieCreateArguments.ts +1 -1
- package/src/readAutoMovieInspectHostOptions.ts +66 -0
- package/src/readAutoMovieRenderOptions.ts +67 -0
- package/src/readAutoMovieReviewOptions.ts +70 -0
- package/src/readAutoMovieRevision.ts +29 -0
- package/src/readAutoMovieVideoProbe.ts +55 -0
- package/src/recordAutoMoviePlayback.ts +182 -0
- package/src/renderAutoMovie.ts +87 -0
- package/src/renderAutoMovieScaffoldNextSteps.ts +4 -18
- package/src/renderAutoMovieVideo.ts +127 -0
- package/src/resolveAutoMovieFfmpeg.ts +33 -0
- package/src/reviewAutoMovie.ts +65 -0
- package/src/run.ts +154 -105
- package/src/runAutoMovieFfmpeg.ts +50 -0
- package/src/serveAutoMovieDrawPage.ts +105 -0
- package/src/serveAutoMovieInspectorPage.ts +82 -0
- package/src/writeAutoMovieModulePage.ts +83 -0
- package/lib/IAutoMoviePackageManager.d.ts +0 -14
- package/lib/IAutoMoviePackageManager.js.map +0 -1
- package/lib/readAutoMovieSyncArguments.d.ts +0 -13
- package/lib/readAutoMovieSyncArguments.js +0 -49
- package/lib/readAutoMovieSyncArguments.js.map +0 -1
- package/lib/selectAutoMoviePackageManager.d.ts +0 -23
- package/lib/selectAutoMoviePackageManager.js +0 -70
- package/lib/selectAutoMoviePackageManager.js.map +0 -1
- package/src/IAutoMoviePackageManager.ts +0 -15
- package/src/readAutoMovieSyncArguments.ts +0 -48
- package/src/selectAutoMoviePackageManager.ts +0 -45
package/README.md
CHANGED
|
@@ -24,11 +24,11 @@ The motion is where the accuracy goes. Every movement is a goal for hands, feet
|
|
|
24
24
|
|
|
25
25
|
### Motion as code
|
|
26
26
|
|
|
27
|
-
The cast, sets, performance, staging and camera are TypeScript the agent writes against `@automovie/interface
|
|
27
|
+
The cast, sets, performance, staging and camera are TypeScript the agent writes against the authoring contracts in `@automovie/interface` and the human action vocabulary in `@automovie/motions`. An action is a law that brings the body onto its targets, so one chain of actions fits people of different stature and proportion, and an action can be interrupted mid-motion. A production composes each person's performance from that vocabulary, writes a law of its own only for what the vocabulary lacks, tests it against its study, and accepts every module in catalog cases on stills before a scene uses it. A scene then only composes accepted modules, and a defect the scene shows is fixed in the module and its case, never patched in the scene.
|
|
28
28
|
|
|
29
29
|
### The motion hint
|
|
30
30
|
|
|
31
|
-
The hint reaches a video model as a hint video and the control channels that model takes, such as pose, depth, normal, outline or a semantic mask, rendered from the same performance and aligned frame for frame. Some models restyle the hint video, some read it as a reference for motion and camera, and open models
|
|
31
|
+
The hint reaches a video model as a hint video and the control channels that model takes, such as pose, depth, normal, outline or a semantic mask, rendered from the same performance and aligned frame for frame. Some models restyle the hint video, some read it as a reference for motion and camera, some turn a gray layout into the shot, and open models take pose, depth or outline passes at a strength each request sets. An accurate hint does not decide what the model makes of it, so generated takes are inspected against the hint at matched frames, and the agent's report says what it verified and what only you watched.
|
|
32
32
|
|
|
33
33
|
### Inspect and correct
|
|
34
34
|
|
|
@@ -56,13 +56,13 @@ flowchart LR
|
|
|
56
56
|
code -.-> film
|
|
57
57
|
```
|
|
58
58
|
|
|
59
|
-
A short runs brief → screenplay and a series settings → treatments → scripts → screenplay; in a workspace the production's folder, `movies/shorts/<name>` or `movies/series/<name>`, fixes the route. The agent follows one chain, and each link cites the decisions of the link above it, so no scene exists without a written basis and no decision goes unrealized.
|
|
59
|
+
A short runs brief → screenplay and a series settings → treatments → scripts → screenplay; in a workspace the production's folder, `movies/shorts/<name>` or `movies/series/<name>`, fixes the route. The agent follows one chain, and each link cites the decisions of the link above it, so no scene exists without a written basis and no decision goes unrealized. A series inspects, repairs and independently reviews each layer before the next starts; a short drafts its brief, screenplay and film together, then answers its checklists and takes one independent review. A gap found downstream is repaired in the layer that owns it.
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
The agent studies every practice and style the film shows, a sport, a craft, a crowd's conduct, a camera style, when a decision first needs it, starting from the density and distribution of the practice as it is really performed, and keeps the sources under `references/`, because a law written without a study invents the practice.
|
|
62
62
|
|
|
63
63
|
### A short: brief, then screenplay
|
|
64
64
|
|
|
65
|
-
A short is a film of a few minutes whose events fit one screenplay. Its brief is
|
|
65
|
+
A short is a film of a few minutes whose events fit one screenplay. Its brief is a minimal canon: only the decisions about its people, places and recurring props that several scenes must keep true, one file per subject with an anchor per decision that the screenplay cites. Several shorts can share one brief and one world.
|
|
66
66
|
|
|
67
67
|
### A series: settings, treatments, scripts, then screenplay
|
|
68
68
|
|
|
@@ -70,7 +70,7 @@ A series, a feature or an episode spans causes, setups and payoffs over many sce
|
|
|
70
70
|
|
|
71
71
|
### The screenplay
|
|
72
72
|
|
|
73
|
-
On both routes the screenplay composes what the audience sees and hears, beat by beat, with each action named as one the installed motion vocabulary performs or as a law the research describes. It is the last place a decision is made; code only realizes it.
|
|
73
|
+
On both routes the screenplay composes what the audience sees and hears, beat by beat in one file per scene, with each action named as one the installed motion vocabulary performs or as a law the research describes. It is the last place a decision is made; code only realizes it.
|
|
74
74
|
|
|
75
75
|
### Staging, motion and camera as code
|
|
76
76
|
|
|
@@ -78,7 +78,7 @@ The agent builds the cast and sets as coarse entities, composes each person's pe
|
|
|
78
78
|
|
|
79
79
|
### The motion-hint video
|
|
80
80
|
|
|
81
|
-
The production's Viewer plays, pauses and seeks the same performance the export uses, a
|
|
81
|
+
The production's Viewer plays, pauses and seeks the same performance the export uses, a capture draws stills of any second from any view through the same draw function the render uses, and the render exports the film through headless Chromium and FFmpeg on your machine. The agent assembles the film in the screenplay's order, renders the control channels from the same performance, inspects stills from the source and from the encoded file, and hands off the fixed inputs, the commands that reproduce it and the remaining limits. The whole hint is complete when every main scene is programmed and the whole video is assembled; stills or pilot clips do not complete it.
|
|
82
82
|
|
|
83
83
|
### A finished film
|
|
84
84
|
|
|
@@ -93,7 +93,7 @@ The generated production [README](https://github.com/samchon/automovie/blob/mast
|
|
|
93
93
|
```bash
|
|
94
94
|
npx automovie create <directory>
|
|
95
95
|
cd <directory>
|
|
96
|
-
|
|
96
|
+
pnpm install
|
|
97
97
|
```
|
|
98
98
|
|
|
99
99
|
Open the directory in your coding agent and tell it what to make. The new production holds the instructions, contracts, configuration and an empty Viewer, and no film.
|
|
@@ -115,36 +115,48 @@ A workspace keeps several productions under one `AGENTS.md`, `CLAUDE.md` and `.a
|
|
|
115
115
|
```text
|
|
116
116
|
npx automovie create <directory> [--workspace] [--name <name>] [--force]
|
|
117
117
|
pnpm automovie add <shorts|series>/<name> [--name <name>] [--force]
|
|
118
|
-
|
|
118
|
+
automovie capture --module <file> [--props <json>] [--backend software|gpu] [--out <dir>] [<request>]
|
|
119
|
+
automovie capture --file <video> [--out <dir>] [<request>]
|
|
120
|
+
automovie render --module <file> [--subject <name>] [--props <json>] [--out <dir>] [--backend software|gpu]
|
|
121
|
+
automovie review --url <inspector address> --seconds <s> [--out <dir>]
|
|
119
122
|
```
|
|
120
123
|
|
|
121
124
|
### create
|
|
122
125
|
|
|
123
|
-
`create` installs a single production. With `--workspace` it installs a pnpm workspace root instead, with a `pnpm-workspace.yaml` whose members are `movies/shorts/*`, `movies/series/*` and `packages/*` and whose catalogs pin every production dependency. The package name is `--name` when given and otherwise comes from the directory name.
|
|
126
|
+
`create` installs a single production, a pnpm project whose `pnpm-workspace.yaml` holds the catalogs that pin its dependencies. With `--workspace` it installs a pnpm workspace root instead, with a `pnpm-workspace.yaml` whose members are `movies/shorts/*`, `movies/series/*` and `packages/*` and whose catalogs pin every production dependency. The package name is `--name` when given and otherwise comes from the directory name.
|
|
124
127
|
|
|
125
128
|
### add
|
|
126
129
|
|
|
127
|
-
`add` runs at
|
|
130
|
+
`add` runs at the workspace root and writes a production into `movies/shorts/<name>` or `movies/series/<name>`. It fills missing dependency entries in `pnpm-workspace.yaml` and preserves existing pins and overrides. Run `pnpm install` again to link the production. Its skills come from the root's `.agents/skills`.
|
|
128
131
|
|
|
129
132
|
`create` and `add` refuse a non-empty target unless `--force` is given, which replaces files at the same paths.
|
|
130
133
|
|
|
131
|
-
###
|
|
134
|
+
### capture
|
|
135
|
+
|
|
136
|
+
`capture` runs in a production, which `pnpm run capture` does with `--module src/subjects.ts`. It builds a draw-only page for the module's subjects with the production's Vite, draws every planned still in headless Chromium through `@automovie/render`'s draw function, with SwiftShader unless `--backend gpu`, and writes stills, contact sheets and `record.json` into `--out` or `media/capture/<subject>`. `--props <json>` passes a module the data its subjects are built from, and `--file` captures a video file's own frames with FFmpeg from `FFMPEG_PATH` or `ffmpeg-static` instead. The remaining options are the capture request: `--subject`, the seconds, views, passes, inspection and rounds. `npx playwright-core install chromium-headless-shell` installs the browser, and `CHROME_PATH` selects another. It exits 1 when a cell could not be drawn.
|
|
137
|
+
|
|
138
|
+
### render
|
|
139
|
+
|
|
140
|
+
`render` runs in a production, which `pnpm run render` does with `--module src/subjects.ts`. It draws every frame of one subject, `--subject` or the module's only one, through the same draw page and function as `capture`, and encodes them once with FFmpeg into `film.mp4` with `render-report.json` beside it, in `--out` or `media/automovie/<subject>/videos`. `--props <json>` passes a module the data its subjects are built from.
|
|
141
|
+
|
|
142
|
+
### review
|
|
132
143
|
|
|
133
|
-
`
|
|
144
|
+
`review` records real-time playback of the production's running inspector page, `pnpm run dev`, at `--url` for `--seconds` of wall time after pressing its Play button, into a video with `playback.json` of the readings and page errors, in `--out` or `media/automovie/review`. `npx playwright-core install ffmpeg` provides the recorder. It exits 1 when the page reported a script error.
|
|
134
145
|
|
|
135
146
|
## Packages
|
|
136
147
|
|
|
137
148
|
| Package | Purpose |
|
|
138
149
|
| --- | --- |
|
|
139
150
|
| [`automovie`](https://github.com/samchon/automovie/tree/master/packages/cli) | The CLI that installs and updates the scaffold |
|
|
140
|
-
| [`@automovie/interface`](https://github.com/samchon/automovie/tree/master/packages/interface) |
|
|
151
|
+
| [`@automovie/interface`](https://github.com/samchon/automovie/tree/master/packages/interface) | Common and domain contracts, including the authoring AST |
|
|
141
152
|
| [`@automovie/engine`](https://github.com/samchon/automovie/tree/master/packages/engine) | Deterministic validation and computation of everything a frame contains |
|
|
142
153
|
| [`@automovie/human`](https://github.com/samchon/automovie/tree/master/packages/human) | The body of a person, its skeleton and contact profile, generated by code from typed parameters (being rebuilt) |
|
|
143
154
|
| [`@automovie/motions`](https://github.com/samchon/automovie/tree/master/packages/motions) | Human actions, such as walk, sit and pick up, as deterministic laws scaled to the body |
|
|
155
|
+
| [`@automovie/archetypes`](https://github.com/samchon/automovie/tree/master/packages/archetypes) | Coarse seeded models of the things people hold, use, sit on, ride and fight with, each with the contacts an action reads |
|
|
144
156
|
| [`@automovie/ingest`](https://github.com/samchon/automovie/tree/master/packages/ingest) | Deterministic import of glTF, GLB, VRM, WAVE and PPM inputs |
|
|
145
157
|
| [`@automovie/recovery`](https://github.com/samchon/automovie/tree/master/packages/recovery) | Curves recovered from a reference mesh, and geometry rebuilt from them |
|
|
146
|
-
| [`@automovie/viewer`](https://github.com/samchon/automovie/tree/master/packages/viewer) | Three.js display,
|
|
147
|
-
| [`@automovie/render`](https://github.com/samchon/automovie/tree/master/packages/render) |
|
|
158
|
+
| [`@automovie/viewer`](https://github.com/samchon/automovie/tree/master/packages/viewer) | Interactive Three.js display: canvas mount, playback, snapshot saving and transport controls |
|
|
159
|
+
| [`@automovie/render`](https://github.com/samchon/automovie/tree/master/packages/render) | Three.js scene building, passes, inspection and the polygon man, plus frame schedules, edit timelines and encoder plans, with capture and encoding supplied by the calling program |
|
|
148
160
|
| [`@automovie/evidence`](https://github.com/samchon/automovie/tree/master/packages/evidence) | Checks that a production's code and writing answer their checklists |
|
|
149
161
|
| [`@automovie/template`](https://github.com/samchon/automovie/tree/master/packages/template) | The scaffold every production starts from |
|
|
150
162
|
|
|
@@ -0,0 +1,6 @@
|
|
|
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 declare const AUTOMOVIE_CAPTURE_OPTIONS: readonly string[];
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AUTOMOVIE_CAPTURE_OPTIONS = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* The options `automovie capture` takes for itself, written `--<name>`; every other option is a key of the capture request grammar.
|
|
6
|
+
*
|
|
7
|
+
* `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.
|
|
8
|
+
*/
|
|
9
|
+
exports.AUTOMOVIE_CAPTURE_OPTIONS = [
|
|
10
|
+
"module",
|
|
11
|
+
"file",
|
|
12
|
+
"props",
|
|
13
|
+
"out",
|
|
14
|
+
"backend",
|
|
15
|
+
];
|
|
16
|
+
//# sourceMappingURL=AUTOMOVIE_CAPTURE_OPTIONS.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AUTOMOVIE_CAPTURE_OPTIONS.js","sourceRoot":"","sources":["../src/AUTOMOVIE_CAPTURE_OPTIONS.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACU,QAAA,yBAAyB,GAAsB;IAC1D,QAAQ;IACR,MAAM;IACN,OAAO;IACP,KAAK;IACL,SAAS;CACV,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
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 declare const AUTOMOVIE_INSPECT_OPTIONS: readonly string[];
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AUTOMOVIE_INSPECT_OPTIONS = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* 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.
|
|
6
|
+
*
|
|
7
|
+
* A test enumerates them against the render README's key table, so each option the command takes is documented with the requirement it serves.
|
|
8
|
+
*/
|
|
9
|
+
exports.AUTOMOVIE_INSPECT_OPTIONS = [
|
|
10
|
+
"module",
|
|
11
|
+
"port",
|
|
12
|
+
"props",
|
|
13
|
+
];
|
|
14
|
+
//# sourceMappingURL=AUTOMOVIE_INSPECT_OPTIONS.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AUTOMOVIE_INSPECT_OPTIONS.js","sourceRoot":"","sources":["../src/AUTOMOVIE_INSPECT_OPTIONS.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACU,QAAA,yBAAyB,GAAsB;IAC1D,QAAQ;IACR,MAAM;IACN,OAAO;CACR,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
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 declare const AUTOMOVIE_RENDER_OPTIONS: readonly string[];
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AUTOMOVIE_RENDER_OPTIONS = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* The options `automovie render` takes for itself, written `--<name>`; of the capture request grammar it takes only `subject`, the subject rendered.
|
|
6
|
+
*
|
|
7
|
+
* `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.
|
|
8
|
+
*/
|
|
9
|
+
exports.AUTOMOVIE_RENDER_OPTIONS = [
|
|
10
|
+
"module",
|
|
11
|
+
"props",
|
|
12
|
+
"out",
|
|
13
|
+
"backend",
|
|
14
|
+
];
|
|
15
|
+
//# sourceMappingURL=AUTOMOVIE_RENDER_OPTIONS.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AUTOMOVIE_RENDER_OPTIONS.js","sourceRoot":"","sources":["../src/AUTOMOVIE_RENDER_OPTIONS.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACU,QAAA,wBAAwB,GAAsB;IACzD,QAAQ;IACR,OAAO;IACP,KAAK;IACL,SAAS;CACV,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
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 declare const AUTOMOVIE_REVIEW_OPTIONS: readonly string[];
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AUTOMOVIE_REVIEW_OPTIONS = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* The options `automovie review` takes, written `--<name>`; it takes no other.
|
|
6
|
+
*
|
|
7
|
+
* `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.
|
|
8
|
+
*/
|
|
9
|
+
exports.AUTOMOVIE_REVIEW_OPTIONS = [
|
|
10
|
+
"url",
|
|
11
|
+
"seconds",
|
|
12
|
+
"out",
|
|
13
|
+
];
|
|
14
|
+
//# sourceMappingURL=AUTOMOVIE_REVIEW_OPTIONS.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AUTOMOVIE_REVIEW_OPTIONS.js","sourceRoot":"","sources":["../src/AUTOMOVIE_REVIEW_OPTIONS.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACU,QAAA,wBAAwB,GAAsB;IACzD,KAAK;IACL,SAAS;IACT,KAAK;CACN,CAAC"}
|
|
@@ -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 @@
|
|
|
1
|
+
{"version":3,"file":"AutoMovieCaptureBackend.js","sourceRoot":"","sources":["../src/AutoMovieCaptureBackend.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import type { IAutoMovieCapturePlanRequest, IAutoMovieCaptureRecord } from "@automovie/interface";
|
|
2
|
+
import type * as Render from "@automovie/render";
|
|
3
|
+
import type { AutoMovieCaptureBackend } from "./AutoMovieCaptureBackend";
|
|
4
|
+
/**
|
|
5
|
+
* 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.
|
|
6
|
+
*
|
|
7
|
+
* `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.
|
|
8
|
+
*
|
|
9
|
+
* ```ts
|
|
10
|
+
* const host = await AutoMovieCaptureHost.open({ root, module: "src/subjects.ts", backend: "software", env: process.env });
|
|
11
|
+
* try {
|
|
12
|
+
* const record = await host.capture({ request, props: null });
|
|
13
|
+
* } finally {
|
|
14
|
+
* await host.close();
|
|
15
|
+
* }
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* @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.
|
|
19
|
+
* @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.
|
|
20
|
+
* @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.
|
|
21
|
+
* @evidence contracts/development/design.md#prohibited-design-shortcuts No subject kind is named; the module and its props say what is drawn.
|
|
22
|
+
*/
|
|
23
|
+
export declare class AutoMovieCaptureHost {
|
|
24
|
+
/** The production's `@automovie/render`, which drew the page; a host that draws through `session` uses it for the rules it applies. */
|
|
25
|
+
readonly render: typeof Render;
|
|
26
|
+
/** The backend and Chromium version, such as `swiftshader; Chromium 131.0.6778.33`. */
|
|
27
|
+
readonly backend: string;
|
|
28
|
+
/** The production's root folder. */
|
|
29
|
+
private readonly root;
|
|
30
|
+
/** The launched browser. */
|
|
31
|
+
private readonly browser;
|
|
32
|
+
/** The served draw page. */
|
|
33
|
+
private readonly page;
|
|
34
|
+
/** Hold opened resources; `open` acquires them. */
|
|
35
|
+
private constructor();
|
|
36
|
+
/**
|
|
37
|
+
* Load the production's packages, build and serve the draw page for the subject module, and launch Chromium.
|
|
38
|
+
*
|
|
39
|
+
* 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.
|
|
40
|
+
*
|
|
41
|
+
* @evidence contracts/development/common.md#meaningful-documentation States the three steps, the refusals and the cleanup.
|
|
42
|
+
* @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.
|
|
43
|
+
* @evidence contracts/development/implementation.md#clear-and-simple-structure Load, serve, launch; building and launching belong to their own functions.
|
|
44
|
+
* @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts A failure is reported, never answered by another backend or a development server.
|
|
45
|
+
* @evidence contracts/development/implementation.md#efficient-algorithms One build and one launch for every capture of the host.
|
|
46
|
+
* @evidence contracts/development/implementation.md#reuse-equivalent-work The built page and the browser serve every capture until `close`.
|
|
47
|
+
* @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.
|
|
48
|
+
*/
|
|
49
|
+
static open(props: {
|
|
50
|
+
/** The production's root folder. */
|
|
51
|
+
root: string;
|
|
52
|
+
/** Path of the subject module, relative to `root` or absolute. */
|
|
53
|
+
module: string;
|
|
54
|
+
/** How the browser draws. */
|
|
55
|
+
backend: AutoMovieCaptureBackend;
|
|
56
|
+
/** The environment, read for `CHROME_PATH`. */
|
|
57
|
+
env: Readonly<Record<string, string | undefined>>;
|
|
58
|
+
}): Promise<AutoMovieCaptureHost>;
|
|
59
|
+
/**
|
|
60
|
+
* 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.
|
|
61
|
+
*
|
|
62
|
+
* 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.
|
|
63
|
+
*
|
|
64
|
+
* @evidence contracts/development/common.md#meaningful-documentation States what is opened and injected, who closes it, and the refusal.
|
|
65
|
+
* @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.
|
|
66
|
+
* @evidence contracts/development/implementation.md#clear-and-simple-structure Observe the browser, race opening against a script failure, and close the page on rejection.
|
|
67
|
+
* @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts A failed open is reported, never retried.
|
|
68
|
+
* @evidence contracts/development/implementation.md#efficient-algorithms One page per call.
|
|
69
|
+
* @evidenceExclude contracts/development/implementation.md#reuse-equivalent-work Each call is a fresh page, because props differ between subjects.
|
|
70
|
+
* @evidence contracts/development/implementation.md#bound-retention-and-release-resources The page passes to the returned session, or is closed here when opening fails.
|
|
71
|
+
*/
|
|
72
|
+
session(props: {
|
|
73
|
+
/** Name of the subject, or null for the page's only subject. */
|
|
74
|
+
subject: string | null;
|
|
75
|
+
/** Data the subject module reads, as JSON, or null. */
|
|
76
|
+
props: unknown;
|
|
77
|
+
}): Promise<Render.AutoMovieDrawSession>;
|
|
78
|
+
/**
|
|
79
|
+
* 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`.
|
|
80
|
+
*
|
|
81
|
+
* 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.
|
|
82
|
+
*
|
|
83
|
+
* @evidence contracts/development/common.md#meaningful-documentation States the steps, the revision and the page's lifetime, and which refusals precede drawing.
|
|
84
|
+
* @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.
|
|
85
|
+
* @evidence contracts/development/implementation.md#clear-and-simple-structure Open the session, plan, open the folder, run, close the page.
|
|
86
|
+
* @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts Storage is `node:fs/promises` itself, with no adapter.
|
|
87
|
+
* @evidence contracts/development/implementation.md#efficient-algorithms One page per capture; drawing is the capture core's loop.
|
|
88
|
+
* @evidenceExclude contracts/development/implementation.md#reuse-equivalent-work Each capture draws afresh, because the subject or the request differs.
|
|
89
|
+
* @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.
|
|
90
|
+
*/
|
|
91
|
+
capture(props: {
|
|
92
|
+
/** The request, as `parseAutoMovieCapturePlanRequest` read it. */
|
|
93
|
+
request: IAutoMovieCapturePlanRequest;
|
|
94
|
+
/** Data the subject module reads, as JSON, or null. */
|
|
95
|
+
props: unknown;
|
|
96
|
+
/** The capture's root folder, relative to the production or absolute; absent, `media/capture/<subject>` of the production. */
|
|
97
|
+
out?: string;
|
|
98
|
+
/** The subject owner's own section of the record, or absent. */
|
|
99
|
+
section?: Readonly<Record<string, unknown>>;
|
|
100
|
+
}): Promise<Extract<IAutoMovieCaptureRecord, {
|
|
101
|
+
state: "complete";
|
|
102
|
+
}>>;
|
|
103
|
+
/**
|
|
104
|
+
* End the browser, stop the server and delete the built page.
|
|
105
|
+
*
|
|
106
|
+
* @evidence contracts/development/common.md#meaningful-documentation States what is released.
|
|
107
|
+
* @evidence contracts/development/implementation.md#principled-implementation The browser ends before the server it loads pages from.
|
|
108
|
+
* @evidence contracts/development/implementation.md#clear-and-simple-structure Two releases in order, the second attempted even when the first fails.
|
|
109
|
+
* @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts A release failure propagates after both are attempted.
|
|
110
|
+
* @evidence contracts/development/implementation.md#efficient-algorithms Two calls.
|
|
111
|
+
* @evidenceExclude contracts/development/implementation.md#reuse-equivalent-work Closing happens once.
|
|
112
|
+
* @evidence contracts/development/implementation.md#bound-retention-and-release-resources The release point of the browser, the server and the scratch folder.
|
|
113
|
+
*/
|
|
114
|
+
close(): Promise<void>;
|
|
115
|
+
}
|
|
@@ -0,0 +1,234 @@
|
|
|
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.AutoMovieCaptureHost = void 0;
|
|
37
|
+
const fs = __importStar(require("node:fs/promises"));
|
|
38
|
+
const path = __importStar(require("node:path"));
|
|
39
|
+
const launchAutoMovieChromium_1 = require("./launchAutoMovieChromium");
|
|
40
|
+
const loadAutoMovieProductionModule_1 = require("./loadAutoMovieProductionModule");
|
|
41
|
+
const readAutoMovieRevision_1 = require("./readAutoMovieRevision");
|
|
42
|
+
const serveAutoMovieDrawPage_1 = require("./serveAutoMovieDrawPage");
|
|
43
|
+
/** Milliseconds one page call may take before its cell fails: two minutes, room for SwiftShader to draw a large raster of a heavy scene. */
|
|
44
|
+
const TIMEOUT = 120_000;
|
|
45
|
+
/**
|
|
46
|
+
* 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.
|
|
47
|
+
*
|
|
48
|
+
* `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.
|
|
49
|
+
*
|
|
50
|
+
* ```ts
|
|
51
|
+
* const host = await AutoMovieCaptureHost.open({ root, module: "src/subjects.ts", backend: "software", env: process.env });
|
|
52
|
+
* try {
|
|
53
|
+
* const record = await host.capture({ request, props: null });
|
|
54
|
+
* } finally {
|
|
55
|
+
* await host.close();
|
|
56
|
+
* }
|
|
57
|
+
* ```
|
|
58
|
+
*
|
|
59
|
+
* @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.
|
|
60
|
+
* @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.
|
|
61
|
+
* @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.
|
|
62
|
+
* @evidence contracts/development/design.md#prohibited-design-shortcuts No subject kind is named; the module and its props say what is drawn.
|
|
63
|
+
*/
|
|
64
|
+
class AutoMovieCaptureHost {
|
|
65
|
+
/** The production's `@automovie/render`, which drew the page; a host that draws through `session` uses it for the rules it applies. */
|
|
66
|
+
render;
|
|
67
|
+
/** The backend and Chromium version, such as `swiftshader; Chromium 131.0.6778.33`. */
|
|
68
|
+
backend;
|
|
69
|
+
/** The production's root folder. */
|
|
70
|
+
root;
|
|
71
|
+
/** The launched browser. */
|
|
72
|
+
browser;
|
|
73
|
+
/** The served draw page. */
|
|
74
|
+
page;
|
|
75
|
+
/** Hold opened resources; `open` acquires them. */
|
|
76
|
+
constructor(props) {
|
|
77
|
+
this.render = props.render;
|
|
78
|
+
this.backend = props.backend;
|
|
79
|
+
this.root = props.root;
|
|
80
|
+
this.browser = props.browser;
|
|
81
|
+
this.page = props.page;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Load the production's packages, build and serve the draw page for the subject module, and launch Chromium.
|
|
85
|
+
*
|
|
86
|
+
* 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.
|
|
87
|
+
*
|
|
88
|
+
* @evidence contracts/development/common.md#meaningful-documentation States the three steps, the refusals and the cleanup.
|
|
89
|
+
* @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.
|
|
90
|
+
* @evidence contracts/development/implementation.md#clear-and-simple-structure Load, serve, launch; building and launching belong to their own functions.
|
|
91
|
+
* @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts A failure is reported, never answered by another backend or a development server.
|
|
92
|
+
* @evidence contracts/development/implementation.md#efficient-algorithms One build and one launch for every capture of the host.
|
|
93
|
+
* @evidence contracts/development/implementation.md#reuse-equivalent-work The built page and the browser serve every capture until `close`.
|
|
94
|
+
* @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.
|
|
95
|
+
*/
|
|
96
|
+
static async open(props) {
|
|
97
|
+
const render = (0, loadAutoMovieProductionModule_1.loadAutoMovieProductionModule)(props.root, "@automovie/render");
|
|
98
|
+
const chromium = (0, loadAutoMovieProductionModule_1.loadAutoMovieProductionModule)(props.root, "playwright-core").chromium;
|
|
99
|
+
// Vite's CommonJS entry warns once per load; the command loads it on purpose.
|
|
100
|
+
process.env.VITE_CJS_IGNORE_WARNING = "true";
|
|
101
|
+
const page = await (0, serveAutoMovieDrawPage_1.serveAutoMovieDrawPage)({
|
|
102
|
+
root: props.root,
|
|
103
|
+
module: props.module,
|
|
104
|
+
vite: (0, loadAutoMovieProductionModule_1.loadAutoMovieProductionModule)(props.root, "vite"),
|
|
105
|
+
});
|
|
106
|
+
try {
|
|
107
|
+
const launched = await (0, launchAutoMovieChromium_1.launchAutoMovieChromium)({
|
|
108
|
+
chromium,
|
|
109
|
+
backend: props.backend,
|
|
110
|
+
env: props.env,
|
|
111
|
+
});
|
|
112
|
+
return new AutoMovieCaptureHost({
|
|
113
|
+
render,
|
|
114
|
+
backend: launched.backend,
|
|
115
|
+
root: props.root,
|
|
116
|
+
browser: launched.browser,
|
|
117
|
+
page,
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
catch (error) {
|
|
121
|
+
await page.close();
|
|
122
|
+
throw error;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* 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.
|
|
127
|
+
*
|
|
128
|
+
* 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.
|
|
129
|
+
*
|
|
130
|
+
* @evidence contracts/development/common.md#meaningful-documentation States what is opened and injected, who closes it, and the refusal.
|
|
131
|
+
* @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.
|
|
132
|
+
* @evidence contracts/development/implementation.md#clear-and-simple-structure Observe the browser, race opening against a script failure, and close the page on rejection.
|
|
133
|
+
* @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts A failed open is reported, never retried.
|
|
134
|
+
* @evidence contracts/development/implementation.md#efficient-algorithms One page per call.
|
|
135
|
+
* @evidenceExclude contracts/development/implementation.md#reuse-equivalent-work Each call is a fresh page, because props differ between subjects.
|
|
136
|
+
* @evidence contracts/development/implementation.md#bound-retention-and-release-resources The page passes to the returned session, or is closed here when opening fails.
|
|
137
|
+
*/
|
|
138
|
+
async session(props) {
|
|
139
|
+
const page = await this.browser.newPage();
|
|
140
|
+
// A module can fail before installing the draw port, leaving only a timeout.
|
|
141
|
+
// Forward its original browser error while the failed page is still alive.
|
|
142
|
+
const failed = new Promise((_resolve, reject) => {
|
|
143
|
+
page.on?.("pageerror", (error) => {
|
|
144
|
+
console.error("Draw page error:", error.stack ?? error.message);
|
|
145
|
+
reject(new Error(`The draw page at ${this.page.url} failed during initialization`, { cause: error }));
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
page.on?.("console", (message) => {
|
|
149
|
+
if (message.type() === "error")
|
|
150
|
+
console.error("Draw page console:", message.text());
|
|
151
|
+
});
|
|
152
|
+
try {
|
|
153
|
+
return await Promise.race([
|
|
154
|
+
this.render.AutoMovieDrawSession.open({
|
|
155
|
+
page,
|
|
156
|
+
url: this.page.url,
|
|
157
|
+
props: { subject: props.subject, props: props.props },
|
|
158
|
+
backend: this.backend,
|
|
159
|
+
timeout: TIMEOUT,
|
|
160
|
+
}),
|
|
161
|
+
failed,
|
|
162
|
+
]);
|
|
163
|
+
}
|
|
164
|
+
catch (error) {
|
|
165
|
+
await page.close();
|
|
166
|
+
throw error;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* 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`.
|
|
171
|
+
*
|
|
172
|
+
* 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.
|
|
173
|
+
*
|
|
174
|
+
* @evidence contracts/development/common.md#meaningful-documentation States the steps, the revision and the page's lifetime, and which refusals precede drawing.
|
|
175
|
+
* @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.
|
|
176
|
+
* @evidence contracts/development/implementation.md#clear-and-simple-structure Open the session, plan, open the folder, run, close the page.
|
|
177
|
+
* @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts Storage is `node:fs/promises` itself, with no adapter.
|
|
178
|
+
* @evidence contracts/development/implementation.md#efficient-algorithms One page per capture; drawing is the capture core's loop.
|
|
179
|
+
* @evidenceExclude contracts/development/implementation.md#reuse-equivalent-work Each capture draws afresh, because the subject or the request differs.
|
|
180
|
+
* @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.
|
|
181
|
+
*/
|
|
182
|
+
async capture(props) {
|
|
183
|
+
const { render } = this;
|
|
184
|
+
const session = await this.session({
|
|
185
|
+
subject: props.request.subject,
|
|
186
|
+
props: props.props,
|
|
187
|
+
});
|
|
188
|
+
try {
|
|
189
|
+
const plan = render.planAutoMovieCapture({
|
|
190
|
+
request: props.request,
|
|
191
|
+
subject: session.subject,
|
|
192
|
+
cuts: [],
|
|
193
|
+
});
|
|
194
|
+
const folder = await render.AutoMovieCaptureFolder.open({
|
|
195
|
+
storage: fs,
|
|
196
|
+
root: path.resolve(this.root, props.out ?? path.join("media", "capture", session.subject.name)),
|
|
197
|
+
round: props.request.round,
|
|
198
|
+
compare: props.request.compare,
|
|
199
|
+
});
|
|
200
|
+
return await render.runAutoMovieCapture({
|
|
201
|
+
plan,
|
|
202
|
+
draw: (cell) => session.drawing(cell, plan),
|
|
203
|
+
folder,
|
|
204
|
+
revision: (0, readAutoMovieRevision_1.readAutoMovieRevision)(this.root),
|
|
205
|
+
match: "cell",
|
|
206
|
+
...(props.section === undefined ? {} : { section: props.section }),
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
finally {
|
|
210
|
+
await session.close();
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* End the browser, stop the server and delete the built page.
|
|
215
|
+
*
|
|
216
|
+
* @evidence contracts/development/common.md#meaningful-documentation States what is released.
|
|
217
|
+
* @evidence contracts/development/implementation.md#principled-implementation The browser ends before the server it loads pages from.
|
|
218
|
+
* @evidence contracts/development/implementation.md#clear-and-simple-structure Two releases in order, the second attempted even when the first fails.
|
|
219
|
+
* @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts A release failure propagates after both are attempted.
|
|
220
|
+
* @evidence contracts/development/implementation.md#efficient-algorithms Two calls.
|
|
221
|
+
* @evidenceExclude contracts/development/implementation.md#reuse-equivalent-work Closing happens once.
|
|
222
|
+
* @evidence contracts/development/implementation.md#bound-retention-and-release-resources The release point of the browser, the server and the scratch folder.
|
|
223
|
+
*/
|
|
224
|
+
async close() {
|
|
225
|
+
try {
|
|
226
|
+
await this.browser.close();
|
|
227
|
+
}
|
|
228
|
+
finally {
|
|
229
|
+
await this.page.close();
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
exports.AutoMovieCaptureHost = AutoMovieCaptureHost;
|
|
234
|
+
//# sourceMappingURL=AutoMovieCaptureHost.js.map
|