automovie 0.0.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.
- package/README.md +145 -18
- 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 +114 -0
- package/lib/AutoMovieCaptureHost.js +219 -0
- package/lib/AutoMovieCaptureHost.js.map +1 -0
- package/lib/AutoMovieCommand.d.ts +24 -13
- package/lib/IAutoMovieChromium.d.ts +75 -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 +122 -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 +103 -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 +27 -6
- 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 +245 -0
- package/src/AutoMovieCommand.ts +28 -13
- package/src/IAutoMovieChromium.ts +78 -0
- package/src/captureAutoMovie.ts +148 -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 +81 -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 +168 -0
- package/src/renderAutoMovie.ts +86 -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 +116 -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
|
@@ -0,0 +1,219 @@
|
|
|
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. 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 One page, one session open, one close on failure.
|
|
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
|
+
try {
|
|
141
|
+
return await this.render.AutoMovieDrawSession.open({
|
|
142
|
+
page,
|
|
143
|
+
url: this.page.url,
|
|
144
|
+
props: { subject: props.subject, props: props.props },
|
|
145
|
+
backend: this.backend,
|
|
146
|
+
timeout: TIMEOUT,
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
catch (error) {
|
|
150
|
+
await page.close();
|
|
151
|
+
throw error;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* 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`.
|
|
156
|
+
*
|
|
157
|
+
* 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.
|
|
158
|
+
*
|
|
159
|
+
* @evidence contracts/development/common.md#meaningful-documentation States the steps, the revision and the page's lifetime, and which refusals precede drawing.
|
|
160
|
+
* @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.
|
|
161
|
+
* @evidence contracts/development/implementation.md#clear-and-simple-structure Open the session, plan, open the folder, run, close the page.
|
|
162
|
+
* @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts Storage is `node:fs/promises` itself, with no adapter.
|
|
163
|
+
* @evidence contracts/development/implementation.md#efficient-algorithms One page per capture; drawing is the capture core's loop.
|
|
164
|
+
* @evidenceExclude contracts/development/implementation.md#reuse-equivalent-work Each capture draws afresh, because the subject or the request differs.
|
|
165
|
+
* @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.
|
|
166
|
+
*/
|
|
167
|
+
async capture(props) {
|
|
168
|
+
const { render } = this;
|
|
169
|
+
const session = await this.session({
|
|
170
|
+
subject: props.request.subject,
|
|
171
|
+
props: props.props,
|
|
172
|
+
});
|
|
173
|
+
try {
|
|
174
|
+
const plan = render.planAutoMovieCapture({
|
|
175
|
+
request: props.request,
|
|
176
|
+
subject: session.subject,
|
|
177
|
+
cuts: [],
|
|
178
|
+
});
|
|
179
|
+
const folder = await render.AutoMovieCaptureFolder.open({
|
|
180
|
+
storage: fs,
|
|
181
|
+
root: path.resolve(this.root, props.out ?? path.join("media", "capture", session.subject.name)),
|
|
182
|
+
round: props.request.round,
|
|
183
|
+
compare: props.request.compare,
|
|
184
|
+
});
|
|
185
|
+
return await render.runAutoMovieCapture({
|
|
186
|
+
plan,
|
|
187
|
+
draw: (cell) => session.drawing(cell, plan),
|
|
188
|
+
folder,
|
|
189
|
+
revision: (0, readAutoMovieRevision_1.readAutoMovieRevision)(this.root),
|
|
190
|
+
match: "cell",
|
|
191
|
+
...(props.section === undefined ? {} : { section: props.section }),
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
finally {
|
|
195
|
+
await session.close();
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* End the browser, stop the server and delete the built page.
|
|
200
|
+
*
|
|
201
|
+
* @evidence contracts/development/common.md#meaningful-documentation States what is released.
|
|
202
|
+
* @evidence contracts/development/implementation.md#principled-implementation The browser ends before the server it loads pages from.
|
|
203
|
+
* @evidence contracts/development/implementation.md#clear-and-simple-structure Two releases in order, the second attempted even when the first fails.
|
|
204
|
+
* @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts A release failure propagates after both are attempted.
|
|
205
|
+
* @evidence contracts/development/implementation.md#efficient-algorithms Two calls.
|
|
206
|
+
* @evidenceExclude contracts/development/implementation.md#reuse-equivalent-work Closing happens once.
|
|
207
|
+
* @evidence contracts/development/implementation.md#bound-retention-and-release-resources The release point of the browser, the server and the scratch folder.
|
|
208
|
+
*/
|
|
209
|
+
async close() {
|
|
210
|
+
try {
|
|
211
|
+
await this.browser.close();
|
|
212
|
+
}
|
|
213
|
+
finally {
|
|
214
|
+
await this.page.close();
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
exports.AutoMovieCaptureHost = AutoMovieCaptureHost;
|
|
219
|
+
//# sourceMappingURL=AutoMovieCaptureHost.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AutoMovieCaptureHost.js","sourceRoot":"","sources":["../src/AutoMovieCaptureHost.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,MAAY,EAAE,6CAAyB;AACvC,MAAY,IAAI,sCAAkB;AAI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AO,CAAC,KAAK,EAAE,CAAC;QAC7B,CAAC;gBAAS,CAAC;YACT,MAAM,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;QAC1B,CAAC;IACH,CAAC;CACF"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* One admitted CLI request, discriminated by `command`.
|
|
3
3
|
*
|
|
4
|
-
* `help` and `version` carry nothing because they are standalone requests. `create
|
|
4
|
+
* `help` and `version` carry nothing because they are standalone requests. `create` and `add` carry their targets exactly as typed; `run` resolves them against the working directory. An explicit `name` is carried as typed; `run` chooses the name when it is absent.
|
|
5
5
|
*
|
|
6
|
-
* @evidence contracts/development/design.md#principled-representation Each variant carries exactly what its command needs after admission, so `run` performs no further argument parsing.
|
|
6
|
+
* @evidence contracts/development/design.md#principled-representation Each variant carries exactly what its command needs after admission, so `run` performs no further argument parsing, except `capture`, `inspect`, `render` and `review`, whose options are read by the production's renderer's option reader once that renderer is loaded.
|
|
7
7
|
* @evidence contracts/development/design.md#minimal-and-owned-surface A closed union over the command name lets `run` switch on one field, and the workspace family is a closed pair instead of a free path.
|
|
8
|
-
* @evidence contracts/development/design.md#prohibited-design-shortcuts No variant
|
|
8
|
+
* @evidence contracts/development/design.md#prohibited-design-shortcuts No variant other than `capture`, `inspect`, `render` and `review` carries unparsed tokens, and theirs are read by the one option reader every host shares rather than a second grammar here.
|
|
9
9
|
* @evidence contracts/development/common.md#meaningful-documentation Every variant and member states its meaning and who resolves it.
|
|
10
10
|
*/
|
|
11
11
|
export type AutoMovieCommand = {
|
|
@@ -21,7 +21,7 @@ export type AutoMovieCommand = {
|
|
|
21
21
|
directory: string;
|
|
22
22
|
/** Install a pnpm workspace root instead of a single production. */
|
|
23
23
|
workspace: boolean;
|
|
24
|
-
/** Admit a non-empty target,
|
|
24
|
+
/** Admit a non-empty target, writing over same-path files and keeping the rest. */
|
|
25
25
|
force: boolean;
|
|
26
26
|
/** Package name as typed; absent, `run` derives or asks for one. */
|
|
27
27
|
name?: string;
|
|
@@ -32,17 +32,28 @@ export type AutoMovieCommand = {
|
|
|
32
32
|
family: "shorts" | "series";
|
|
33
33
|
/** The production's directory under `movies/<family>`, one admitted path segment. */
|
|
34
34
|
directory: string;
|
|
35
|
-
/** Admit a non-empty production directory,
|
|
35
|
+
/** Admit a non-empty production directory, writing over same-path files and keeping the rest. */
|
|
36
36
|
force: boolean;
|
|
37
37
|
/** Package name as typed; absent, `run` derives one from the directory segment. */
|
|
38
38
|
name?: string;
|
|
39
39
|
} | {
|
|
40
|
-
/**
|
|
41
|
-
command: "
|
|
42
|
-
/** The
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
40
|
+
/** Capture stills of a subject or a video file in the production at the working directory. */
|
|
41
|
+
command: "capture";
|
|
42
|
+
/** The tokens after `capture`, as typed; `run` reads them through the production's request grammar, which only the production's `@automovie/render` holds. */
|
|
43
|
+
args: string[];
|
|
44
|
+
} | {
|
|
45
|
+
/** Serve the inspector page over a subject module of the production or package at the working directory. */
|
|
46
|
+
command: "inspect";
|
|
47
|
+
/** The tokens after `inspect`, as typed; `run` reads them through the production's request grammar, as for `capture`. */
|
|
48
|
+
args: string[];
|
|
49
|
+
} | {
|
|
50
|
+
/** Render one subject of the production at the working directory into a video. */
|
|
51
|
+
command: "render";
|
|
52
|
+
/** The tokens after `render`, as typed; `run` reads them with the production's option reader. */
|
|
53
|
+
args: string[];
|
|
54
|
+
} | {
|
|
55
|
+
/** Record real-time playback of the production's running inspector page. */
|
|
56
|
+
command: "review";
|
|
57
|
+
/** The tokens after `review`, as typed; `run` reads them with the production's option reader. */
|
|
58
|
+
args: string[];
|
|
48
59
|
};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type { IAutoMovieDrawPage } from "@automovie/render";
|
|
2
|
+
/**
|
|
3
|
+
* The part of `playwright-core`'s `chromium` the capture host calls, declared structurally so the command loads the production's own Playwright at run time and a test passes a double.
|
|
4
|
+
*
|
|
5
|
+
* @evidence contracts/development/design.md#principled-representation Playwright's own call shapes: launch with switches, then pages and a version from the browser.
|
|
6
|
+
* @evidence contracts/development/design.md#minimal-and-owned-surface Exactly what `launchAutoMovieChromium` and the capture host call; the page is the draw session's structural page.
|
|
7
|
+
* @evidence contracts/development/design.md#prohibited-design-shortcuts No Playwright type is imported, so the command compiles and installs without Playwright, which is an optional peer.
|
|
8
|
+
* @evidence contracts/development/common.md#meaningful-documentation States who satisfies it and why it is structural.
|
|
9
|
+
*/
|
|
10
|
+
export interface IAutoMovieChromium {
|
|
11
|
+
/**
|
|
12
|
+
* Start a headless browser with the given switches, from `executablePath` when given.
|
|
13
|
+
*
|
|
14
|
+
* @evidence contracts/development/common.md#meaningful-documentation States what is started and from where.
|
|
15
|
+
* @evidenceExclude contracts/development/implementation.md#principled-implementation A signature has no body; Playwright answers.
|
|
16
|
+
* @evidenceExclude contracts/development/implementation.md#clear-and-simple-structure A signature has no body; Playwright answers.
|
|
17
|
+
* @evidenceExclude contracts/development/implementation.md#prohibited-implementation-shortcuts A signature has no body; Playwright answers.
|
|
18
|
+
* @evidenceExclude contracts/development/implementation.md#efficient-algorithms A signature has no body; Playwright answers.
|
|
19
|
+
* @evidenceExclude contracts/development/implementation.md#reuse-equivalent-work A signature has no body; Playwright answers.
|
|
20
|
+
* @evidenceExclude contracts/development/implementation.md#bound-retention-and-release-resources A signature has no body; Playwright answers.
|
|
21
|
+
*/
|
|
22
|
+
launch(options: {
|
|
23
|
+
headless: true;
|
|
24
|
+
args: string[];
|
|
25
|
+
executablePath?: string;
|
|
26
|
+
}): Promise<IAutoMovieChromium.IBrowser>;
|
|
27
|
+
}
|
|
28
|
+
export declare namespace IAutoMovieChromium {
|
|
29
|
+
/**
|
|
30
|
+
* A launched browser: its version, its pages, and its end.
|
|
31
|
+
*
|
|
32
|
+
* @evidence contracts/development/design.md#principled-representation Playwright's `Browser` call shapes.
|
|
33
|
+
* @evidence contracts/development/design.md#minimal-and-owned-surface The three calls the host makes.
|
|
34
|
+
* @evidence contracts/development/design.md#prohibited-design-shortcuts Structural, as its parent.
|
|
35
|
+
* @evidence contracts/development/common.md#meaningful-documentation States what it is.
|
|
36
|
+
*/
|
|
37
|
+
interface IBrowser {
|
|
38
|
+
/**
|
|
39
|
+
* The browser's version, such as `131.0.6778.33`.
|
|
40
|
+
*
|
|
41
|
+
* @evidence contracts/development/common.md#meaningful-documentation States what is returned.
|
|
42
|
+
* @evidenceExclude contracts/development/implementation.md#principled-implementation A signature has no body; Playwright answers.
|
|
43
|
+
* @evidenceExclude contracts/development/implementation.md#clear-and-simple-structure A signature has no body; Playwright answers.
|
|
44
|
+
* @evidenceExclude contracts/development/implementation.md#prohibited-implementation-shortcuts A signature has no body; Playwright answers.
|
|
45
|
+
* @evidenceExclude contracts/development/implementation.md#efficient-algorithms A signature has no body; Playwright answers.
|
|
46
|
+
* @evidenceExclude contracts/development/implementation.md#reuse-equivalent-work A signature has no body; Playwright answers.
|
|
47
|
+
* @evidenceExclude contracts/development/implementation.md#bound-retention-and-release-resources A signature has no body; Playwright answers.
|
|
48
|
+
*/
|
|
49
|
+
version(): string;
|
|
50
|
+
/**
|
|
51
|
+
* Open a fresh page.
|
|
52
|
+
*
|
|
53
|
+
* @evidence contracts/development/common.md#meaningful-documentation States the effect.
|
|
54
|
+
* @evidenceExclude contracts/development/implementation.md#principled-implementation A signature has no body; Playwright answers.
|
|
55
|
+
* @evidenceExclude contracts/development/implementation.md#clear-and-simple-structure A signature has no body; Playwright answers.
|
|
56
|
+
* @evidenceExclude contracts/development/implementation.md#prohibited-implementation-shortcuts A signature has no body; Playwright answers.
|
|
57
|
+
* @evidenceExclude contracts/development/implementation.md#efficient-algorithms A signature has no body; Playwright answers.
|
|
58
|
+
* @evidenceExclude contracts/development/implementation.md#reuse-equivalent-work A signature has no body; Playwright answers.
|
|
59
|
+
* @evidenceExclude contracts/development/implementation.md#bound-retention-and-release-resources A signature has no body; Playwright answers.
|
|
60
|
+
*/
|
|
61
|
+
newPage(): Promise<IAutoMovieDrawPage>;
|
|
62
|
+
/**
|
|
63
|
+
* End the browser and every page it holds.
|
|
64
|
+
*
|
|
65
|
+
* @evidence contracts/development/common.md#meaningful-documentation States the effect.
|
|
66
|
+
* @evidenceExclude contracts/development/implementation.md#principled-implementation A signature has no body; Playwright answers.
|
|
67
|
+
* @evidenceExclude contracts/development/implementation.md#clear-and-simple-structure A signature has no body; Playwright answers.
|
|
68
|
+
* @evidenceExclude contracts/development/implementation.md#prohibited-implementation-shortcuts A signature has no body; Playwright answers.
|
|
69
|
+
* @evidenceExclude contracts/development/implementation.md#efficient-algorithms A signature has no body; Playwright answers.
|
|
70
|
+
* @evidenceExclude contracts/development/implementation.md#reuse-equivalent-work A signature has no body; Playwright answers.
|
|
71
|
+
* @evidenceExclude contracts/development/implementation.md#bound-retention-and-release-resources A signature has no body; Playwright answers.
|
|
72
|
+
*/
|
|
73
|
+
close(): Promise<void>;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IAutoMovieChromium.js","sourceRoot":"","sources":["../src/IAutoMovieChromium.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Run `automovie capture` in a production: read the options through the request grammar, capture a subject drawn by the draw page or a video file's own frames, print what was written, and resolve to the exit status.
|
|
3
|
+
*
|
|
4
|
+
* Options are read by `readAutoMovieCaptureArguments` and split by `readAutoMovieCaptureHostOptions`; the rest is the request `parseAutoMovieCapturePlanRequest` reads, so the command takes exactly the keys of a page's address. With `--module` the subject is drawn through `AutoMovieCaptureHost`, its module called with the JSON of `--props` when given; with `--file` the file is probed by FFmpeg and captured by `runAutoMovieVideoCapture`, its subject named by `subject` or the file's name. Both write into `--out`, or `media/capture/<subject>`.
|
|
5
|
+
*
|
|
6
|
+
* It prints the folder and how many cells were drawn, the backend, every sheet, every cell not drawn with its cause, and each unmatched or changed comparison entry. The status is 1 when any cell was not drawn, because an undrawn cell is unverified evidence, and 0 otherwise; a refusal throws to `run`, which prints it.
|
|
7
|
+
*
|
|
8
|
+
* @evidence contracts/development/common.md#meaningful-documentation States how options are read and split, both sources, where they write, what is printed, and the exit status with its reason.
|
|
9
|
+
* @evidence contracts/development/implementation.md#principled-implementation Every rule of a capture is the render package's; the command loads that package from the production, supplies the browser or FFmpeg, and reports.
|
|
10
|
+
* @evidence contracts/development/implementation.md#clear-and-simple-structure Read, then one branch per source, then one report.
|
|
11
|
+
* @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts An unknown option is refused by the request reader instead of ignored, and FFmpeg is resolved only for a video so a drawn capture never needs it.
|
|
12
|
+
* @evidence contracts/development/implementation.md#efficient-algorithms One host or two FFmpeg runs plus the probe; printing is linear in the record.
|
|
13
|
+
* @evidenceExclude contracts/development/implementation.md#reuse-equivalent-work One capture per command.
|
|
14
|
+
* @evidence contracts/development/implementation.md#bound-retention-and-release-resources The host is closed on every outcome.
|
|
15
|
+
*/
|
|
16
|
+
export declare function captureAutoMovie(props: {
|
|
17
|
+
/** The tokens after `capture`. */
|
|
18
|
+
args: readonly string[];
|
|
19
|
+
/** The production's root folder, the working directory. */
|
|
20
|
+
root: string;
|
|
21
|
+
/** The environment, read for `CHROME_PATH` and `FFMPEG_PATH`. */
|
|
22
|
+
env: Readonly<Record<string, string | undefined>>;
|
|
23
|
+
}): Promise<number>;
|
|
@@ -0,0 +1,133 @@
|
|
|
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.captureAutoMovie = captureAutoMovie;
|
|
37
|
+
const fs = __importStar(require("node:fs/promises"));
|
|
38
|
+
const path = __importStar(require("node:path"));
|
|
39
|
+
const AutoMovieCaptureHost_1 = require("./AutoMovieCaptureHost");
|
|
40
|
+
const loadAutoMovieProductionModule_1 = require("./loadAutoMovieProductionModule");
|
|
41
|
+
const readAutoMovieCaptureHostOptions_1 = require("./readAutoMovieCaptureHostOptions");
|
|
42
|
+
const readAutoMovieRevision_1 = require("./readAutoMovieRevision");
|
|
43
|
+
const readAutoMovieVideoProbe_1 = require("./readAutoMovieVideoProbe");
|
|
44
|
+
const resolveAutoMovieFfmpeg_1 = require("./resolveAutoMovieFfmpeg");
|
|
45
|
+
const runAutoMovieFfmpeg_1 = require("./runAutoMovieFfmpeg");
|
|
46
|
+
/**
|
|
47
|
+
* Run `automovie capture` in a production: read the options through the request grammar, capture a subject drawn by the draw page or a video file's own frames, print what was written, and resolve to the exit status.
|
|
48
|
+
*
|
|
49
|
+
* Options are read by `readAutoMovieCaptureArguments` and split by `readAutoMovieCaptureHostOptions`; the rest is the request `parseAutoMovieCapturePlanRequest` reads, so the command takes exactly the keys of a page's address. With `--module` the subject is drawn through `AutoMovieCaptureHost`, its module called with the JSON of `--props` when given; with `--file` the file is probed by FFmpeg and captured by `runAutoMovieVideoCapture`, its subject named by `subject` or the file's name. Both write into `--out`, or `media/capture/<subject>`.
|
|
50
|
+
*
|
|
51
|
+
* It prints the folder and how many cells were drawn, the backend, every sheet, every cell not drawn with its cause, and each unmatched or changed comparison entry. The status is 1 when any cell was not drawn, because an undrawn cell is unverified evidence, and 0 otherwise; a refusal throws to `run`, which prints it.
|
|
52
|
+
*
|
|
53
|
+
* @evidence contracts/development/common.md#meaningful-documentation States how options are read and split, both sources, where they write, what is printed, and the exit status with its reason.
|
|
54
|
+
* @evidence contracts/development/implementation.md#principled-implementation Every rule of a capture is the render package's; the command loads that package from the production, supplies the browser or FFmpeg, and reports.
|
|
55
|
+
* @evidence contracts/development/implementation.md#clear-and-simple-structure Read, then one branch per source, then one report.
|
|
56
|
+
* @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts An unknown option is refused by the request reader instead of ignored, and FFmpeg is resolved only for a video so a drawn capture never needs it.
|
|
57
|
+
* @evidence contracts/development/implementation.md#efficient-algorithms One host or two FFmpeg runs plus the probe; printing is linear in the record.
|
|
58
|
+
* @evidenceExclude contracts/development/implementation.md#reuse-equivalent-work One capture per command.
|
|
59
|
+
* @evidence contracts/development/implementation.md#bound-retention-and-release-resources The host is closed on every outcome.
|
|
60
|
+
*/
|
|
61
|
+
async function captureAutoMovie(props) {
|
|
62
|
+
const { root } = props;
|
|
63
|
+
const render = (0, loadAutoMovieProductionModule_1.loadAutoMovieProductionModule)(root, "@automovie/render");
|
|
64
|
+
const options = (0, readAutoMovieCaptureHostOptions_1.readAutoMovieCaptureHostOptions)(render.readAutoMovieCaptureArguments(props.args));
|
|
65
|
+
const request = render.parseAutoMovieCapturePlanRequest(options.request);
|
|
66
|
+
let record;
|
|
67
|
+
let backend;
|
|
68
|
+
let folder;
|
|
69
|
+
if (options.file !== null) {
|
|
70
|
+
// A video file: probe it, then capture its own frames.
|
|
71
|
+
const ffmpeg = (0, resolveAutoMovieFfmpeg_1.resolveAutoMovieFfmpeg)({
|
|
72
|
+
env: props.env,
|
|
73
|
+
load: (id) => (0, loadAutoMovieProductionModule_1.loadAutoMovieProductionModule)(root, id),
|
|
74
|
+
});
|
|
75
|
+
const file = path.resolve(root, options.file);
|
|
76
|
+
const probe = (0, readAutoMovieVideoProbe_1.readAutoMovieVideoProbe)(await (0, runAutoMovieFfmpeg_1.runAutoMovieFfmpeg)(ffmpeg, ["-hide_banner", "-i", file], () => true));
|
|
77
|
+
const name = request.subject ?? path.parse(file).name;
|
|
78
|
+
folder = path.resolve(root, options.out ?? path.join("media", "capture", name));
|
|
79
|
+
record = await render.runAutoMovieVideoCapture({
|
|
80
|
+
file,
|
|
81
|
+
subject: { name, ...probe },
|
|
82
|
+
request,
|
|
83
|
+
storage: fs,
|
|
84
|
+
root: folder,
|
|
85
|
+
run: async (args) => {
|
|
86
|
+
await (0, runAutoMovieFfmpeg_1.runAutoMovieFfmpeg)(ffmpeg, args);
|
|
87
|
+
},
|
|
88
|
+
revision: (0, readAutoMovieRevision_1.readAutoMovieRevision)(root),
|
|
89
|
+
});
|
|
90
|
+
backend = `ffmpeg ${ffmpeg}`;
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
// A drawn subject, through the draw page in headless Chromium.
|
|
94
|
+
const host = await AutoMovieCaptureHost_1.AutoMovieCaptureHost.open({
|
|
95
|
+
root,
|
|
96
|
+
module: options.module,
|
|
97
|
+
backend: options.backend,
|
|
98
|
+
env: props.env,
|
|
99
|
+
});
|
|
100
|
+
try {
|
|
101
|
+
record = await host.capture({
|
|
102
|
+
request,
|
|
103
|
+
props: options.props === null
|
|
104
|
+
? null
|
|
105
|
+
: JSON.parse(await fs.readFile(path.resolve(root, options.props), "utf8")),
|
|
106
|
+
...(options.out === null ? {} : { out: options.out }),
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
finally {
|
|
110
|
+
await host.close();
|
|
111
|
+
}
|
|
112
|
+
backend = host.backend;
|
|
113
|
+
folder = path.resolve(root, options.out ?? path.join("media", "capture", record.subject.name));
|
|
114
|
+
}
|
|
115
|
+
// What was written, and what was not drawn.
|
|
116
|
+
const failed = record.rows.filter((row) => row.state === "failed");
|
|
117
|
+
const lines = [
|
|
118
|
+
`capture ${record.subject.name}: ${record.rows.length - failed.length} of ${record.rows.length} cells drawn into ${folder}`,
|
|
119
|
+
`backend ${backend}`,
|
|
120
|
+
...record.sheets.map((sheet) => path.join(folder, sheet)),
|
|
121
|
+
...failed.map((row) => `not drawn ${row.name}: ${row.cause}`),
|
|
122
|
+
...(record.comparison === null
|
|
123
|
+
? []
|
|
124
|
+
: record.comparison.entries.flatMap((entry) => entry.state === "unmatched"
|
|
125
|
+
? [`unmatched ${entry.current ?? entry.earlier}: ${entry.cause}`]
|
|
126
|
+
: entry.mode === "difference" && entry.changed !== 0
|
|
127
|
+
? [`changed ${entry.current}: ${entry.changed} pixels`]
|
|
128
|
+
: [])),
|
|
129
|
+
];
|
|
130
|
+
process.stdout.write(`${lines.join("\n")}\n`);
|
|
131
|
+
return failed.length === 0 ? 0 : 1;
|
|
132
|
+
}
|
|
133
|
+
//# sourceMappingURL=captureAutoMovie.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"captureAutoMovie.js","sourceRoot":"","sources":["../src/captureAutoMovie.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,M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AE,CAAC;gBACjE,CAAC,CAAC,KAAK,CAAC,IAAI,KAAK,YAAY,IAAI,KAAK,CAAC,OAAO,KAAK,CAAC;oBAClD,CAAC,CAAC,CAAC,WAAW,KAAK,CAAC,OAAO,KAAK,KAAK,CAAC,OAAO,SAAS,CAAC;oBACvD,CAAC,CAAC,EAAE,CACX,CAAC;KACP,CAAC;IACF,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC9C,OAAO,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACrC,CAAC"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* The basename is lowercased, each run of characters other than `a-z`, `0-9`, `.`, `_` and `-` becomes one `-`, the result is cut to npm's 214-character limit, and leading `-`, `.` or `_` and trailing `-` or `.` are removed. A basename with nothing left, such as a filesystem root, yields `AUTOMOVIE_DEFAULT_PROJECT_NAME`. `selectAutoMovieProjectName` passes a `create` request's absolute target, `run` passes an `add` request's directory segment, and `run` hands the result to the template renderer as the project name.
|
|
5
5
|
*
|
|
6
|
-
* This transformation does not validate npm's reserved names; `node_modules` and `favicon.ico` remain unchanged. Windows device names such as `con` also remain unchanged and are refused by `
|
|
6
|
+
* This transformation does not validate npm's reserved names; `node_modules` and `favicon.ico` remain unchanged. Windows device names such as `con` also remain unchanged and are refused by `createAutoMovieScaffold` before any file is written.
|
|
7
7
|
*
|
|
8
8
|
* @evidence contracts/development/implementation.md#principled-implementation Lowercasing and character replacement produce an unscoped-name candidate from the basename in the host's path syntax, then the 214-character cut precedes trimming so the result stays within that limit. This is normalization rather than complete npm admission: reserved names remain unchanged, while the downstream scaffold renderer separately refuses Windows device names.
|
|
9
9
|
* @evidence contracts/development/implementation.md#clear-and-simple-structure One pure function owns the directory-to-name rule, so `run` keeps only dispatch and the rule is checked without publishing a scaffold.
|
|
@@ -43,7 +43,7 @@ const NPM_NAME_LIMIT = 214;
|
|
|
43
43
|
*
|
|
44
44
|
* The basename is lowercased, each run of characters other than `a-z`, `0-9`, `.`, `_` and `-` becomes one `-`, the result is cut to npm's 214-character limit, and leading `-`, `.` or `_` and trailing `-` or `.` are removed. A basename with nothing left, such as a filesystem root, yields `AUTOMOVIE_DEFAULT_PROJECT_NAME`. `selectAutoMovieProjectName` passes a `create` request's absolute target, `run` passes an `add` request's directory segment, and `run` hands the result to the template renderer as the project name.
|
|
45
45
|
*
|
|
46
|
-
* This transformation does not validate npm's reserved names; `node_modules` and `favicon.ico` remain unchanged. Windows device names such as `con` also remain unchanged and are refused by `
|
|
46
|
+
* This transformation does not validate npm's reserved names; `node_modules` and `favicon.ico` remain unchanged. Windows device names such as `con` also remain unchanged and are refused by `createAutoMovieScaffold` before any file is written.
|
|
47
47
|
*
|
|
48
48
|
* @evidence contracts/development/implementation.md#principled-implementation Lowercasing and character replacement produce an unscoped-name candidate from the basename in the host's path syntax, then the 214-character cut precedes trimming so the result stays within that limit. This is normalization rather than complete npm admission: reserved names remain unchanged, while the downstream scaffold renderer separately refuses Windows device names.
|
|
49
49
|
* @evidence contracts/development/implementation.md#clear-and-simple-structure One pure function owns the directory-to-name rule, so `run` keeps only dispatch and the rule is checked without publishing a scaffold.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A TCP port the operating system reports free on 127.0.0.1 at the moment of asking, for a page server that must not take another server's port.
|
|
3
|
+
*
|
|
4
|
+
* The port is free only at that moment; the server that takes it listens with `strictPort`, so a port taken meanwhile fails the start instead of moving elsewhere.
|
|
5
|
+
*
|
|
6
|
+
* @evidence contracts/development/common.md#meaningful-documentation States what is returned, the race it leaves and how a caller closes it.
|
|
7
|
+
* @evidence contracts/development/implementation.md#principled-implementation Listening on port 0 asks the operating system for an unused ephemeral port, which the address then reports.
|
|
8
|
+
* @evidence contracts/development/implementation.md#clear-and-simple-structure Listen, read the address, close.
|
|
9
|
+
* @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts No fixed port is guessed.
|
|
10
|
+
* @evidence contracts/development/implementation.md#efficient-algorithms One listen and one close.
|
|
11
|
+
* @evidenceExclude contracts/development/implementation.md#reuse-equivalent-work Each server asks once.
|
|
12
|
+
* @evidence contracts/development/implementation.md#bound-retention-and-release-resources The probing server is closed before the promise resolves.
|
|
13
|
+
*/
|
|
14
|
+
export declare function findAutoMovieFreePort(): Promise<number>;
|