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