automovie 0.3.4 → 0.4.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 +40 -139
- package/lib/AUTOMOVIE_CAPTURE_OPTIONS.d.ts +5 -2
- package/lib/AUTOMOVIE_CAPTURE_OPTIONS.js +6 -2
- package/lib/AUTOMOVIE_CAPTURE_OPTIONS.js.map +1 -1
- package/lib/AUTOMOVIE_DEFAULT_PROJECT_NAME.d.ts +3 -1
- package/lib/AUTOMOVIE_DEFAULT_PROJECT_NAME.js +3 -1
- package/lib/AUTOMOVIE_DEFAULT_PROJECT_NAME.js.map +1 -1
- package/lib/AUTOMOVIE_INSPECT_OPTIONS.d.ts +5 -2
- package/lib/AUTOMOVIE_INSPECT_OPTIONS.js +5 -2
- package/lib/AUTOMOVIE_INSPECT_OPTIONS.js.map +1 -1
- package/lib/AUTOMOVIE_RENDER_OPTIONS.d.ts +6 -2
- package/lib/AUTOMOVIE_RENDER_OPTIONS.js +8 -2
- package/lib/AUTOMOVIE_RENDER_OPTIONS.js.map +1 -1
- package/lib/AUTOMOVIE_REVIEW_OPTIONS.d.ts +3 -1
- package/lib/AUTOMOVIE_REVIEW_OPTIONS.js +12 -1
- package/lib/AUTOMOVIE_REVIEW_OPTIONS.js.map +1 -1
- package/lib/AutoMovieCaptureBackend.d.ts +4 -6
- package/lib/AutoMovieCaptureHost.d.ts +73 -53
- package/lib/AutoMovieCaptureHost.js +89 -56
- package/lib/AutoMovieCaptureHost.js.map +1 -1
- package/lib/AutoMovieCommand.d.ts +69 -20
- package/lib/AutoMovieFfmpegStaticPath.d.ts +6 -0
- package/lib/AutoMovieFfmpegStaticPath.js +3 -0
- package/lib/AutoMovieFfmpegStaticPath.js.map +1 -0
- package/lib/AutoMovieMp4Boxes.d.ts +78 -0
- package/lib/AutoMovieMp4Boxes.js +227 -0
- package/lib/AutoMovieMp4Boxes.js.map +1 -0
- package/lib/AutoMovieRenderOutputReservation.d.ts +18 -0
- package/lib/AutoMovieRenderOutputReservation.js +118 -0
- package/lib/AutoMovieRenderOutputReservation.js.map +1 -0
- package/lib/IAutoMovieChromium.d.ts +13 -57
- package/lib/IAutoMovieDeliveryAudioTrack.d.ts +17 -0
- package/lib/IAutoMovieDeliveryAudioTrack.js +3 -0
- package/lib/IAutoMovieDeliveryAudioTrack.js.map +1 -0
- package/lib/IAutoMovieDeliveryProfileFinding.d.ts +21 -0
- package/lib/IAutoMovieDeliveryProfileFinding.js +3 -0
- package/lib/IAutoMovieDeliveryProfileFinding.js.map +1 -0
- package/lib/IAutoMovieFfmpegSources.d.ts +11 -0
- package/lib/IAutoMovieFfmpegSources.js +3 -0
- package/lib/IAutoMovieFfmpegSources.js.map +1 -0
- package/lib/IAutoMovieReviewObservation.d.ts +66 -0
- package/lib/IAutoMovieReviewObservation.js +3 -0
- package/lib/IAutoMovieReviewObservation.js.map +1 -0
- package/lib/IAutoMovieVerification.d.ts +163 -0
- package/lib/IAutoMovieVerification.js +3 -0
- package/lib/IAutoMovieVerification.js.map +1 -0
- package/lib/auditAutoMovieAlphaSamples.d.ts +23 -0
- package/lib/auditAutoMovieAlphaSamples.js +183 -0
- package/lib/auditAutoMovieAlphaSamples.js.map +1 -0
- package/lib/auditAutoMovieDeliveryProfile.d.ts +33 -0
- package/lib/auditAutoMovieDeliveryProfile.js +93 -0
- package/lib/auditAutoMovieDeliveryProfile.js.map +1 -0
- package/lib/captureAutoMovie.d.ts +23 -11
- package/lib/captureAutoMovie.js +102 -18
- package/lib/captureAutoMovie.js.map +1 -1
- package/lib/createAutoMovieDeliveryAudioLog.d.ts +31 -0
- package/lib/createAutoMovieDeliveryAudioLog.js +110 -0
- package/lib/createAutoMovieDeliveryAudioLog.js.map +1 -0
- package/lib/createAutoMovieDeliveryAudioScan.d.ts +39 -0
- package/lib/createAutoMovieDeliveryAudioScan.js +125 -0
- package/lib/createAutoMovieDeliveryAudioScan.js.map +1 -0
- package/lib/createAutoMovieVerificationInputScope.d.ts +19 -0
- package/lib/createAutoMovieVerificationInputScope.js +147 -0
- package/lib/createAutoMovieVerificationInputScope.js.map +1 -0
- package/lib/createAutoMovieVerificationMediaHash.d.ts +5 -0
- package/lib/createAutoMovieVerificationMediaHash.js +61 -0
- package/lib/createAutoMovieVerificationMediaHash.js.map +1 -0
- package/lib/decodeAutoMovieDeliveryAudio.d.ts +24 -0
- package/lib/decodeAutoMovieDeliveryAudio.js +77 -0
- package/lib/decodeAutoMovieDeliveryAudio.js.map +1 -0
- package/lib/deriveAutoMovieProjectName.d.ts +14 -11
- package/lib/deriveAutoMovieProjectName.js +14 -11
- package/lib/deriveAutoMovieProjectName.js.map +1 -1
- package/lib/findAutoMovieFreePort.d.ts +5 -10
- package/lib/findAutoMovieFreePort.js +5 -10
- package/lib/findAutoMovieFreePort.js.map +1 -1
- package/lib/formatAutoMovieInspectUrl.d.ts +6 -10
- package/lib/formatAutoMovieInspectUrl.js +6 -10
- package/lib/formatAutoMovieInspectUrl.js.map +1 -1
- package/lib/hashAutoMovieFile.d.ts +5 -0
- package/lib/hashAutoMovieFile.js +16 -0
- package/lib/hashAutoMovieFile.js.map +1 -0
- package/lib/importAutoMovieVerificationEntry.d.mts +2 -0
- package/lib/importAutoMovieVerificationEntry.mjs +6 -0
- package/lib/importAutoMovieVerificationEntry.mjs.map +1 -0
- package/lib/index.d.ts +9 -0
- package/lib/index.js +9 -0
- package/lib/index.js.map +1 -1
- package/lib/inspectAutoMovie.d.ts +15 -9
- package/lib/inspectAutoMovie.js +25 -9
- package/lib/inspectAutoMovie.js.map +1 -1
- package/lib/inspectAutoMovieVerificationCapture.d.ts +15 -0
- package/lib/inspectAutoMovieVerificationCapture.js +221 -0
- package/lib/inspectAutoMovieVerificationCapture.js.map +1 -0
- package/lib/inspectAutoMovieVerificationDelivery.d.ts +13 -0
- package/lib/inspectAutoMovieVerificationDelivery.js +247 -0
- package/lib/inspectAutoMovieVerificationDelivery.js.map +1 -0
- package/lib/inspectAutoMovieVerificationReview.d.ts +11 -0
- package/lib/inspectAutoMovieVerificationReview.js +141 -0
- package/lib/inspectAutoMovieVerificationReview.js.map +1 -0
- package/lib/launchAutoMovieChromium.d.ts +9 -11
- package/lib/launchAutoMovieChromium.js +10 -11
- package/lib/launchAutoMovieChromium.js.map +1 -1
- package/lib/listAutoMovieReleaseFindings.d.ts +9 -0
- package/lib/listAutoMovieReleaseFindings.js +58 -0
- package/lib/listAutoMovieReleaseFindings.js.map +1 -0
- package/lib/loadAutoMovieProductionModule.d.ts +11 -10
- package/lib/loadAutoMovieProductionModule.js +18 -10
- package/lib/loadAutoMovieProductionModule.js.map +1 -1
- package/lib/loadAutoMovieVerificationModule.d.ts +6 -0
- package/lib/loadAutoMovieVerificationModule.js +246 -0
- package/lib/loadAutoMovieVerificationModule.js.map +1 -0
- package/lib/planAutoMovieChromiumLaunch.d.ts +7 -13
- package/lib/planAutoMovieChromiumLaunch.js +7 -13
- package/lib/planAutoMovieChromiumLaunch.js.map +1 -1
- package/lib/planAutoMovieDeliveryAudioDecode.d.ts +10 -0
- package/lib/planAutoMovieDeliveryAudioDecode.js +29 -0
- package/lib/planAutoMovieDeliveryAudioDecode.js.map +1 -0
- package/lib/planAutoMovieDeliveryDecode.d.ts +19 -0
- package/lib/planAutoMovieDeliveryDecode.js +57 -0
- package/lib/planAutoMovieDeliveryDecode.js.map +1 -0
- package/lib/planAutoMovieDeliveryInput.d.ts +11 -0
- package/lib/planAutoMovieDeliveryInput.js +26 -0
- package/lib/planAutoMovieDeliveryInput.js.map +1 -0
- package/lib/planAutoMovieModulePageViteConfig.d.ts +13 -10
- package/lib/planAutoMovieModulePageViteConfig.js +13 -10
- package/lib/planAutoMovieModulePageViteConfig.js.map +1 -1
- package/lib/promptAutoMovieProjectName.d.ts +6 -10
- package/lib/promptAutoMovieProjectName.js +6 -10
- package/lib/promptAutoMovieProjectName.js.map +1 -1
- package/lib/publishAutoMovieRenderAttempt.d.ts +32 -0
- package/lib/publishAutoMovieRenderAttempt.js +91 -0
- package/lib/publishAutoMovieRenderAttempt.js.map +1 -0
- package/lib/readAutoMovieAddArguments.d.ts +10 -11
- package/lib/readAutoMovieAddArguments.js +10 -11
- package/lib/readAutoMovieAddArguments.js.map +1 -1
- package/lib/readAutoMovieCaptureHostOptions.d.ts +19 -17
- package/lib/readAutoMovieCaptureHostOptions.js +16 -17
- package/lib/readAutoMovieCaptureHostOptions.js.map +1 -1
- package/lib/readAutoMovieCommandArguments.d.ts +6 -9
- package/lib/readAutoMovieCommandArguments.js +9 -10
- package/lib/readAutoMovieCommandArguments.js.map +1 -1
- package/lib/readAutoMovieCreateArguments.d.ts +7 -11
- package/lib/readAutoMovieCreateArguments.js +7 -11
- package/lib/readAutoMovieCreateArguments.js.map +1 -1
- package/lib/readAutoMovieDeliveryAudioTrack.d.ts +21 -0
- package/lib/readAutoMovieDeliveryAudioTrack.js +104 -0
- package/lib/readAutoMovieDeliveryAudioTrack.js.map +1 -0
- package/lib/readAutoMovieDeliveryDecode.d.ts +19 -0
- package/lib/readAutoMovieDeliveryDecode.js +209 -0
- package/lib/readAutoMovieDeliveryDecode.js.map +1 -0
- package/lib/readAutoMovieDeliveryProbe.d.ts +35 -0
- package/lib/readAutoMovieDeliveryProbe.js +363 -0
- package/lib/readAutoMovieDeliveryProbe.js.map +1 -0
- package/lib/readAutoMovieErrorCode.d.ts +9 -0
- package/lib/readAutoMovieErrorCode.js +18 -0
- package/lib/readAutoMovieErrorCode.js.map +1 -0
- package/lib/readAutoMovieInspectHostOptions.d.ts +15 -16
- package/lib/readAutoMovieInspectHostOptions.js +11 -15
- package/lib/readAutoMovieInspectHostOptions.js.map +1 -1
- package/lib/readAutoMovieNameOption.d.ts +4 -10
- package/lib/readAutoMovieNameOption.js +4 -10
- package/lib/readAutoMovieNameOption.js.map +1 -1
- package/lib/readAutoMoviePageTimeout.d.ts +13 -0
- package/lib/readAutoMoviePageTimeout.js +21 -0
- package/lib/readAutoMoviePageTimeout.js.map +1 -0
- package/lib/readAutoMovieRenderOptions.d.ts +24 -16
- package/lib/readAutoMovieRenderOptions.js +23 -16
- package/lib/readAutoMovieRenderOptions.js.map +1 -1
- package/lib/readAutoMovieReviewObservation.d.ts +6 -0
- package/lib/readAutoMovieReviewObservation.js +108 -0
- package/lib/readAutoMovieReviewObservation.js.map +1 -0
- package/lib/readAutoMovieReviewOptions.d.ts +32 -24
- package/lib/readAutoMovieReviewOptions.js +82 -18
- package/lib/readAutoMovieReviewOptions.js.map +1 -1
- package/lib/readAutoMovieRevision.d.ts +3 -9
- package/lib/readAutoMovieRevision.js +3 -9
- package/lib/readAutoMovieRevision.js.map +1 -1
- package/lib/readAutoMovieVerifyOptions.d.ts +17 -0
- package/lib/readAutoMovieVerifyOptions.js +45 -0
- package/lib/readAutoMovieVerifyOptions.js.map +1 -0
- package/lib/readAutoMovieVideoProbe.d.ts +6 -10
- package/lib/readAutoMovieVideoProbe.js +20 -13
- package/lib/readAutoMovieVideoProbe.js.map +1 -1
- package/lib/recordAutoMoviePlayback.d.ts +18 -11
- package/lib/recordAutoMoviePlayback.js +26 -13
- package/lib/recordAutoMoviePlayback.js.map +1 -1
- package/lib/renderAutoMovie.d.ts +16 -10
- package/lib/renderAutoMovie.js +31 -14
- package/lib/renderAutoMovie.js.map +1 -1
- package/lib/renderAutoMovieScaffoldNextSteps.d.ts +10 -10
- package/lib/renderAutoMovieScaffoldNextSteps.js +10 -10
- package/lib/renderAutoMovieVideo.d.ts +53 -15
- package/lib/renderAutoMovieVideo.js +290 -45
- package/lib/renderAutoMovieVideo.js.map +1 -1
- package/lib/resolveAutoMovieFfmpeg.d.ts +12 -15
- package/lib/resolveAutoMovieFfmpeg.js +12 -17
- package/lib/resolveAutoMovieFfmpeg.js.map +1 -1
- package/lib/reviewAutoMovie.d.ts +10 -10
- package/lib/reviewAutoMovie.js +15 -10
- package/lib/reviewAutoMovie.js.map +1 -1
- package/lib/reviewAutoMovieFile.d.ts +21 -0
- package/lib/reviewAutoMovieFile.js +378 -0
- package/lib/reviewAutoMovieFile.js.map +1 -0
- package/lib/run.d.ts +32 -18
- package/lib/run.js +67 -23
- package/lib/run.js.map +1 -1
- package/lib/runAutoMovieDeliveryAudioDecode.d.ts +18 -0
- package/lib/runAutoMovieDeliveryAudioDecode.js +28 -0
- package/lib/runAutoMovieDeliveryAudioDecode.js.map +1 -0
- package/lib/runAutoMovieDeliveryDecode.d.ts +19 -0
- package/lib/runAutoMovieDeliveryDecode.js +42 -0
- package/lib/runAutoMovieDeliveryDecode.js.map +1 -0
- package/lib/runAutoMovieDeliveryReferenceDecode.d.ts +28 -0
- package/lib/runAutoMovieDeliveryReferenceDecode.js +77 -0
- package/lib/runAutoMovieDeliveryReferenceDecode.js.map +1 -0
- package/lib/runAutoMovieDeliverySourceAudioDecode.d.ts +20 -0
- package/lib/runAutoMovieDeliverySourceAudioDecode.js +56 -0
- package/lib/runAutoMovieDeliverySourceAudioDecode.js.map +1 -0
- package/lib/runAutoMovieFfmpeg.d.ts +15 -10
- package/lib/runAutoMovieFfmpeg.js +36 -13
- package/lib/runAutoMovieFfmpeg.js.map +1 -1
- package/lib/runAutoMovieVerification.d.ts +28 -0
- package/lib/runAutoMovieVerification.js +393 -0
- package/lib/runAutoMovieVerification.js.map +1 -0
- package/lib/sameAutoMovieReviewFile.d.ts +2 -0
- package/lib/sameAutoMovieReviewFile.js +57 -0
- package/lib/sameAutoMovieReviewFile.js.map +1 -0
- package/lib/selectAutoMovieProjectName.d.ts +8 -11
- package/lib/selectAutoMovieProjectName.js +8 -11
- package/lib/selectAutoMovieProjectName.js.map +1 -1
- package/lib/serveAutoMovieDrawPage.d.ts +14 -11
- package/lib/serveAutoMovieDrawPage.js +14 -11
- package/lib/serveAutoMovieDrawPage.js.map +1 -1
- package/lib/serveAutoMovieInspectorPage.d.ts +4 -8
- package/lib/serveAutoMovieInspectorPage.js +3 -9
- package/lib/serveAutoMovieInspectorPage.js.map +1 -1
- package/lib/verifyAutoMovie.d.ts +19 -0
- package/lib/verifyAutoMovie.js +44 -0
- package/lib/verifyAutoMovie.js.map +1 -0
- package/lib/writeAutoMovieModulePage.d.ts +17 -12
- package/lib/writeAutoMovieModulePage.js +13 -11
- package/lib/writeAutoMovieModulePage.js.map +1 -1
- package/lib/writeAutoMovieVerificationReceipt.d.ts +2 -0
- package/lib/writeAutoMovieVerificationReceipt.js +75 -0
- package/lib/writeAutoMovieVerificationReceipt.js.map +1 -0
- package/package.json +8 -8
- package/src/AUTOMOVIE_CAPTURE_OPTIONS.ts +6 -2
- package/src/AUTOMOVIE_DEFAULT_PROJECT_NAME.ts +3 -1
- package/src/AUTOMOVIE_INSPECT_OPTIONS.ts +5 -2
- package/src/AUTOMOVIE_RENDER_OPTIONS.ts +8 -2
- package/src/AUTOMOVIE_REVIEW_OPTIONS.ts +12 -1
- package/src/AutoMovieCaptureBackend.ts +4 -6
- package/src/AutoMovieCaptureHost.ts +122 -68
- package/src/AutoMovieCommand.ts +71 -20
- package/src/AutoMovieFfmpegStaticPath.ts +7 -0
- package/src/AutoMovieMp4Boxes.ts +263 -0
- package/src/AutoMovieRenderOutputReservation.ts +97 -0
- package/src/IAutoMovieChromium.ts +13 -57
- package/src/IAutoMovieDeliveryAudioTrack.ts +19 -0
- package/src/IAutoMovieDeliveryProfileFinding.ts +24 -0
- package/src/IAutoMovieFfmpegSources.ts +13 -0
- package/src/IAutoMovieReviewObservation.ts +59 -0
- package/src/IAutoMovieVerification.ts +207 -0
- package/src/auditAutoMovieAlphaSamples.ts +201 -0
- package/src/auditAutoMovieDeliveryProfile.ts +125 -0
- package/src/captureAutoMovie.ts +137 -28
- package/src/createAutoMovieDeliveryAudioLog.ts +141 -0
- package/src/createAutoMovieDeliveryAudioScan.ts +150 -0
- package/src/createAutoMovieVerificationInputScope.ts +156 -0
- package/src/createAutoMovieVerificationMediaHash.ts +32 -0
- package/src/decodeAutoMovieDeliveryAudio.ts +95 -0
- package/src/deriveAutoMovieProjectName.ts +14 -11
- package/src/findAutoMovieFreePort.ts +5 -10
- package/src/formatAutoMovieInspectUrl.ts +6 -10
- package/src/hashAutoMovieFile.ts +12 -0
- package/src/importAutoMovieVerificationEntry.mts +6 -0
- package/src/index.ts +9 -0
- package/src/inspectAutoMovie.ts +28 -11
- package/src/inspectAutoMovieVerificationCapture.ts +292 -0
- package/src/inspectAutoMovieVerificationDelivery.ts +301 -0
- package/src/inspectAutoMovieVerificationReview.ts +130 -0
- package/src/launchAutoMovieChromium.ts +14 -12
- package/src/listAutoMovieReleaseFindings.ts +87 -0
- package/src/loadAutoMovieProductionModule.ts +22 -15
- package/src/loadAutoMovieVerificationModule.ts +278 -0
- package/src/planAutoMovieChromiumLaunch.ts +7 -13
- package/src/planAutoMovieDeliveryAudioDecode.ts +26 -0
- package/src/planAutoMovieDeliveryDecode.ts +66 -0
- package/src/planAutoMovieDeliveryInput.ts +25 -0
- package/src/planAutoMovieModulePageViteConfig.ts +13 -10
- package/src/promptAutoMovieProjectName.ts +6 -10
- package/src/publishAutoMovieRenderAttempt.ts +89 -0
- package/src/readAutoMovieAddArguments.ts +10 -11
- package/src/readAutoMovieCaptureHostOptions.ts +22 -17
- package/src/readAutoMovieCommandArguments.ts +8 -10
- package/src/readAutoMovieCreateArguments.ts +7 -11
- package/src/readAutoMovieDeliveryAudioTrack.ts +137 -0
- package/src/readAutoMovieDeliveryDecode.ts +269 -0
- package/src/readAutoMovieDeliveryProbe.ts +499 -0
- package/src/readAutoMovieErrorCode.ts +13 -0
- package/src/readAutoMovieInspectHostOptions.ts +15 -16
- package/src/readAutoMovieNameOption.ts +4 -10
- package/src/readAutoMoviePageTimeout.ts +19 -0
- package/src/readAutoMovieRenderOptions.ts +34 -16
- package/src/readAutoMovieReviewObservation.ts +146 -0
- package/src/readAutoMovieReviewOptions.ts +133 -28
- package/src/readAutoMovieRevision.ts +3 -9
- package/src/readAutoMovieVerifyOptions.ts +50 -0
- package/src/readAutoMovieVideoProbe.ts +24 -13
- package/src/recordAutoMoviePlayback.ts +26 -13
- package/src/renderAutoMovie.ts +38 -17
- package/src/renderAutoMovieScaffoldNextSteps.ts +10 -10
- package/src/renderAutoMovieVideo.ts +474 -85
- package/src/resolveAutoMovieFfmpeg.ts +17 -24
- package/src/reviewAutoMovie.ts +21 -16
- package/src/reviewAutoMovieFile.ts +479 -0
- package/src/run.ts +75 -25
- package/src/runAutoMovieDeliveryAudioDecode.ts +45 -0
- package/src/runAutoMovieDeliveryDecode.ts +63 -0
- package/src/runAutoMovieDeliveryReferenceDecode.ts +107 -0
- package/src/runAutoMovieDeliverySourceAudioDecode.ts +71 -0
- package/src/runAutoMovieFfmpeg.ts +48 -14
- package/src/runAutoMovieVerification.ts +487 -0
- package/src/sameAutoMovieReviewFile.ts +23 -0
- package/src/selectAutoMovieProjectName.ts +8 -11
- package/src/serveAutoMovieDrawPage.ts +16 -12
- package/src/serveAutoMovieInspectorPage.ts +6 -9
- package/src/verifyAutoMovie.ts +67 -0
- package/src/writeAutoMovieModulePage.ts +17 -12
- package/src/writeAutoMovieVerificationReceipt.ts +51 -0
|
@@ -0,0 +1,487 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import * as fs from "node:fs/promises";
|
|
3
|
+
import * as path from "node:path";
|
|
4
|
+
|
|
5
|
+
import type { IAutoMovieVerification } from "./IAutoMovieVerification";
|
|
6
|
+
import { captureAutoMovie } from "./captureAutoMovie";
|
|
7
|
+
import { createAutoMovieVerificationInputScope } from "./createAutoMovieVerificationInputScope";
|
|
8
|
+
import { createAutoMovieVerificationMediaHash } from "./createAutoMovieVerificationMediaHash";
|
|
9
|
+
import { hashAutoMovieFile } from "./hashAutoMovieFile";
|
|
10
|
+
import { inspectAutoMovieVerificationCapture } from "./inspectAutoMovieVerificationCapture";
|
|
11
|
+
import { inspectAutoMovieVerificationDelivery } from "./inspectAutoMovieVerificationDelivery";
|
|
12
|
+
import { inspectAutoMovieVerificationReview } from "./inspectAutoMovieVerificationReview";
|
|
13
|
+
import { readAutoMovieErrorCode } from "./readAutoMovieErrorCode";
|
|
14
|
+
import { readAutoMovieRevision } from "./readAutoMovieRevision";
|
|
15
|
+
import type { readAutoMovieVerifyOptions } from "./readAutoMovieVerifyOptions";
|
|
16
|
+
import { writeAutoMovieVerificationReceipt } from "./writeAutoMovieVerificationReceipt";
|
|
17
|
+
|
|
18
|
+
/** Settings the evaluator needs after the CLI admitted its arguments. */
|
|
19
|
+
type ISelection = Pick<
|
|
20
|
+
ReturnType<typeof readAutoMovieVerifyOptions>,
|
|
21
|
+
"subjects" | "only" | "require" | "run"
|
|
22
|
+
>;
|
|
23
|
+
|
|
24
|
+
/** A scoped result before its identity and stage membership are attached. */
|
|
25
|
+
type IOutcome = Pick<
|
|
26
|
+
IAutoMovieVerification.IResult,
|
|
27
|
+
"state" | "message" | "evidence"
|
|
28
|
+
>;
|
|
29
|
+
|
|
30
|
+
/** A retained local run and its input identity. */
|
|
31
|
+
interface IReceipt {
|
|
32
|
+
readonly signature: string;
|
|
33
|
+
readonly outcome: IOutcome;
|
|
34
|
+
readonly measurement?: number;
|
|
35
|
+
readonly recordSha256?: string;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** Lazily resolved boundaries for explicitly named production inputs. */
|
|
39
|
+
type AutoMovieVerificationInputScope = ReturnType<
|
|
40
|
+
typeof createAutoMovieVerificationInputScope
|
|
41
|
+
>;
|
|
42
|
+
|
|
43
|
+
const DAMAGED_JSON: unique symbol = Symbol("damaged verification JSON");
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Evaluate selected targets in declaration order. A status read uses available
|
|
47
|
+
* records and actual bytes. An explicit run executes only the chosen enabled
|
|
48
|
+
* checks and writes a local receipt for each completed measurement or capture
|
|
49
|
+
* refresh. A required stage includes its omitted and unselected required IDs in
|
|
50
|
+
* the same report, so filtering cannot turn missing work into a pass.
|
|
51
|
+
*
|
|
52
|
+
* @param props Production root, admitted command selection and editable
|
|
53
|
+
* targets.
|
|
54
|
+
* @returns Current results and whether the requested stage is blocked.
|
|
55
|
+
* @throws When target/check IDs or the requested scope are not usable.
|
|
56
|
+
*/
|
|
57
|
+
export async function runAutoMovieVerification(props: {
|
|
58
|
+
/** Absolute production directory, resolving inputs and owned observations. */
|
|
59
|
+
readonly root: string;
|
|
60
|
+
|
|
61
|
+
/** The installed capture host's environment. */
|
|
62
|
+
readonly env: Readonly<Record<string, string | undefined>>;
|
|
63
|
+
|
|
64
|
+
/** Subjects defined by this production. */
|
|
65
|
+
readonly targets: readonly IAutoMovieVerification[];
|
|
66
|
+
|
|
67
|
+
/** Explicit workload and optional gate. */
|
|
68
|
+
readonly options: ISelection;
|
|
69
|
+
|
|
70
|
+
readonly measurementSources?: (
|
|
71
|
+
file: string | undefined,
|
|
72
|
+
) => ReadonlyMap<string, string>;
|
|
73
|
+
}): Promise<IAutoMovieVerification.IReport> {
|
|
74
|
+
const { options, root }: typeof props = props;
|
|
75
|
+
const targets: Map<string, IAutoMovieVerification> = new Map();
|
|
76
|
+
for (const target of props.targets) {
|
|
77
|
+
if (
|
|
78
|
+
!target.id?.trim() ||
|
|
79
|
+
targets.has(target.id) ||
|
|
80
|
+
!Array.isArray(target.checks)
|
|
81
|
+
)
|
|
82
|
+
throw new Error(
|
|
83
|
+
`verify needs a unique ID and a check list for each target: ${target.id}.`,
|
|
84
|
+
);
|
|
85
|
+
targets.set(target.id, target);
|
|
86
|
+
}
|
|
87
|
+
if (options.subjects.length === 0 && targets.size > 1)
|
|
88
|
+
throw new Error(
|
|
89
|
+
`Select --subject from: ${[...targets.keys()].join(", ")}.`,
|
|
90
|
+
);
|
|
91
|
+
const selected: readonly string[] =
|
|
92
|
+
options.subjects.length === 0
|
|
93
|
+
? [...targets.keys()]
|
|
94
|
+
: [...new Set(options.subjects)];
|
|
95
|
+
if (options.require !== null && selected.length === 0)
|
|
96
|
+
throw new Error(
|
|
97
|
+
`Define a verification target before requiring ${options.require}.`,
|
|
98
|
+
);
|
|
99
|
+
const only: Set<string> = new Set(options.only);
|
|
100
|
+
const found: Set<string> = new Set();
|
|
101
|
+
const plans: {
|
|
102
|
+
readonly target: IAutoMovieVerification;
|
|
103
|
+
readonly requirements: readonly string[] | undefined;
|
|
104
|
+
}[] = [];
|
|
105
|
+
for (const id of selected) {
|
|
106
|
+
const target: IAutoMovieVerification | undefined = targets.get(id);
|
|
107
|
+
if (target === undefined)
|
|
108
|
+
throw new Error(`No verification target named ${id}.`);
|
|
109
|
+
const requirements: readonly string[] | undefined =
|
|
110
|
+
options.require === null ||
|
|
111
|
+
!Object.hasOwn(target.required ?? {}, options.require)
|
|
112
|
+
? undefined
|
|
113
|
+
: target.required?.[options.require];
|
|
114
|
+
if (
|
|
115
|
+
options.require !== null &&
|
|
116
|
+
(!Array.isArray(requirements) ||
|
|
117
|
+
requirements.length === 0 ||
|
|
118
|
+
requirements.some(
|
|
119
|
+
(name: unknown): boolean => typeof name !== "string" || !name.trim(),
|
|
120
|
+
))
|
|
121
|
+
)
|
|
122
|
+
throw new Error(
|
|
123
|
+
`Target ${id} needs named requirements for verification stage ${options.require}.`,
|
|
124
|
+
);
|
|
125
|
+
const seen: Set<string> = new Set();
|
|
126
|
+
for (const check of target.checks) {
|
|
127
|
+
if (
|
|
128
|
+
!check.id?.trim() ||
|
|
129
|
+
!check.title?.trim() ||
|
|
130
|
+
!check.scope?.trim() ||
|
|
131
|
+
seen.has(check.id)
|
|
132
|
+
)
|
|
133
|
+
throw new Error(
|
|
134
|
+
`Target ${id} needs unique check IDs, titles and scopes: ${check.id}.`,
|
|
135
|
+
);
|
|
136
|
+
seen.add(check.id);
|
|
137
|
+
if (only.has(check.id)) found.add(check.id);
|
|
138
|
+
}
|
|
139
|
+
plans.push({ target, requirements });
|
|
140
|
+
}
|
|
141
|
+
for (const id of only)
|
|
142
|
+
if (!found.has(id))
|
|
143
|
+
throw new Error(`No selected verification check named ${id}.`);
|
|
144
|
+
|
|
145
|
+
const items: IAutoMovieVerification.IResult[] = [];
|
|
146
|
+
let revision: string | undefined;
|
|
147
|
+
const inputScope: AutoMovieVerificationInputScope =
|
|
148
|
+
createAutoMovieVerificationInputScope(root);
|
|
149
|
+
const hashMedia: (file: string) => Promise<string> =
|
|
150
|
+
createAutoMovieVerificationMediaHash();
|
|
151
|
+
for (const { target, requirements } of plans) {
|
|
152
|
+
const remaining: Set<string> = new Set(requirements);
|
|
153
|
+
for (const check of target.checks) {
|
|
154
|
+
const required: boolean = remaining.delete(check.id);
|
|
155
|
+
const chosen: boolean = only.size === 0 || only.has(check.id);
|
|
156
|
+
if (!chosen && !required) continue;
|
|
157
|
+
const execute: boolean = options.run && chosen;
|
|
158
|
+
let result: IOutcome;
|
|
159
|
+
try {
|
|
160
|
+
result =
|
|
161
|
+
check.enabled === false
|
|
162
|
+
? {
|
|
163
|
+
state: "disabled",
|
|
164
|
+
message: "Enable the check to obtain current evidence.",
|
|
165
|
+
}
|
|
166
|
+
: await evaluate({
|
|
167
|
+
root,
|
|
168
|
+
env: props.env,
|
|
169
|
+
target: target.id,
|
|
170
|
+
check,
|
|
171
|
+
execute,
|
|
172
|
+
inputScope,
|
|
173
|
+
measurementSources: props.measurementSources,
|
|
174
|
+
hashMedia,
|
|
175
|
+
readRevision: (): string =>
|
|
176
|
+
(revision ??= readAutoMovieRevision(root)),
|
|
177
|
+
});
|
|
178
|
+
} catch (error) {
|
|
179
|
+
result = {
|
|
180
|
+
state: "unobserved",
|
|
181
|
+
message: error instanceof Error ? error.message : String(error),
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
items.push({
|
|
185
|
+
target: target.id,
|
|
186
|
+
id: check.id,
|
|
187
|
+
title: check.title,
|
|
188
|
+
scope: check.scope,
|
|
189
|
+
required,
|
|
190
|
+
...result,
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
for (const missing of remaining)
|
|
194
|
+
items.push({
|
|
195
|
+
target: target.id,
|
|
196
|
+
id: missing,
|
|
197
|
+
title: missing,
|
|
198
|
+
scope: options.require ?? "",
|
|
199
|
+
required: true,
|
|
200
|
+
state: "not-run",
|
|
201
|
+
message:
|
|
202
|
+
"Restore the required check or record the changed requirement at its owner.",
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
return {
|
|
206
|
+
targets: selected,
|
|
207
|
+
requiredStage: options.require,
|
|
208
|
+
items,
|
|
209
|
+
blocked: items.some(
|
|
210
|
+
(item: IAutoMovieVerification.IResult): boolean =>
|
|
211
|
+
item.required && item.state !== "passed",
|
|
212
|
+
),
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/** Read a check's owning evidence or produce an explicit local or capture run. */
|
|
217
|
+
async function evaluate(props: {
|
|
218
|
+
readonly root: string;
|
|
219
|
+
readonly env: Readonly<Record<string, string | undefined>>;
|
|
220
|
+
readonly target: string;
|
|
221
|
+
readonly check: IAutoMovieVerification.Check;
|
|
222
|
+
readonly execute: boolean;
|
|
223
|
+
readonly inputScope: AutoMovieVerificationInputScope;
|
|
224
|
+
readonly measurementSources?: (
|
|
225
|
+
file: string | undefined,
|
|
226
|
+
) => ReadonlyMap<string, string>;
|
|
227
|
+
readonly hashMedia: (file: string) => Promise<string>;
|
|
228
|
+
readonly readRevision: () => string;
|
|
229
|
+
}): Promise<IOutcome> {
|
|
230
|
+
const { root, check }: typeof props = props;
|
|
231
|
+
if (check.kind === "delivery")
|
|
232
|
+
return inspectAutoMovieVerificationDelivery(check, root, props.hashMedia);
|
|
233
|
+
if (check.kind === "review")
|
|
234
|
+
return inspectAutoMovieVerificationReview(check, root, props.hashMedia);
|
|
235
|
+
if (check.kind !== "measure" && check.kind !== "capture")
|
|
236
|
+
throw new Error("Unknown verification check kind.");
|
|
237
|
+
|
|
238
|
+
const file: string = path.join(
|
|
239
|
+
root,
|
|
240
|
+
".cache",
|
|
241
|
+
"automovie",
|
|
242
|
+
"verify",
|
|
243
|
+
`${digest([props.target, check.id])}.json`,
|
|
244
|
+
);
|
|
245
|
+
const refresh: boolean =
|
|
246
|
+
props.execute && (check.kind === "measure" || check.capture !== undefined);
|
|
247
|
+
const retained: IReceipt | undefined | typeof DAMAGED_JSON = refresh
|
|
248
|
+
? undefined
|
|
249
|
+
: ((await readJson(file)) as IReceipt | undefined | typeof DAMAGED_JSON);
|
|
250
|
+
if (retained === DAMAGED_JSON)
|
|
251
|
+
return damaged(
|
|
252
|
+
path.relative(root, file),
|
|
253
|
+
"Run verify --run for this check to rebuild its receipt.",
|
|
254
|
+
);
|
|
255
|
+
if (check.kind === "measure") {
|
|
256
|
+
const signature: string = await props.inputScope.identify(
|
|
257
|
+
check,
|
|
258
|
+
props.measurementSources,
|
|
259
|
+
);
|
|
260
|
+
if (!props.execute) {
|
|
261
|
+
if (retained === undefined)
|
|
262
|
+
return {
|
|
263
|
+
state: "not-run",
|
|
264
|
+
message: "Run this measurement with verify --run.",
|
|
265
|
+
};
|
|
266
|
+
if (retained.signature !== signature)
|
|
267
|
+
return {
|
|
268
|
+
state: "stale",
|
|
269
|
+
message:
|
|
270
|
+
"The criterion or input bytes changed. Run the measurement again.",
|
|
271
|
+
};
|
|
272
|
+
if (
|
|
273
|
+
typeof retained.measurement !== "number" ||
|
|
274
|
+
!Number.isFinite(retained.measurement)
|
|
275
|
+
)
|
|
276
|
+
return {
|
|
277
|
+
state: "failed",
|
|
278
|
+
message:
|
|
279
|
+
retained.outcome?.state === "failed" &&
|
|
280
|
+
typeof retained.outcome.message === "string"
|
|
281
|
+
? retained.outcome.message
|
|
282
|
+
: "Run the measurement to record its observed quantity.",
|
|
283
|
+
evidence: path.relative(root, file),
|
|
284
|
+
};
|
|
285
|
+
return {
|
|
286
|
+
...measured(check, retained.measurement),
|
|
287
|
+
evidence: path.relative(root, file),
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
let outcome: IOutcome;
|
|
291
|
+
let measurement: number | undefined;
|
|
292
|
+
try {
|
|
293
|
+
measurement = await check.measure(root);
|
|
294
|
+
outcome = measured(check, measurement);
|
|
295
|
+
} catch (error) {
|
|
296
|
+
outcome = {
|
|
297
|
+
state: "failed",
|
|
298
|
+
message: error instanceof Error ? error.message : String(error),
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
if (
|
|
302
|
+
(await props.inputScope.identify(check, props.measurementSources)) !==
|
|
303
|
+
signature
|
|
304
|
+
)
|
|
305
|
+
return {
|
|
306
|
+
state: "stale",
|
|
307
|
+
message: "Inputs changed while the measurement ran. Run it again.",
|
|
308
|
+
};
|
|
309
|
+
await writeReceipt(file, {
|
|
310
|
+
signature,
|
|
311
|
+
outcome,
|
|
312
|
+
...(measurement !== undefined && Number.isFinite(measurement)
|
|
313
|
+
? { measurement }
|
|
314
|
+
: {}),
|
|
315
|
+
});
|
|
316
|
+
return { ...outcome, evidence: path.relative(root, file) };
|
|
317
|
+
}
|
|
318
|
+
const recordPath: string = path.resolve(root, check.record);
|
|
319
|
+
if (props.execute && check.capture !== undefined) {
|
|
320
|
+
const signature: string = await props.inputScope.identify(check);
|
|
321
|
+
let serializedRecord: string | undefined;
|
|
322
|
+
try {
|
|
323
|
+
await captureAutoMovie({
|
|
324
|
+
root,
|
|
325
|
+
env: props.env,
|
|
326
|
+
args: check.capture,
|
|
327
|
+
expectedRecord: recordPath,
|
|
328
|
+
write: (): void => {},
|
|
329
|
+
recorded: (_file: string, serialized: string): void => {
|
|
330
|
+
serializedRecord = serialized;
|
|
331
|
+
},
|
|
332
|
+
});
|
|
333
|
+
} catch (error) {
|
|
334
|
+
return {
|
|
335
|
+
state: "failed",
|
|
336
|
+
message: error instanceof Error ? error.message : String(error),
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
if (serializedRecord === undefined)
|
|
340
|
+
return {
|
|
341
|
+
state: "failed",
|
|
342
|
+
message: `The configured capture did not complete ${check.record}.`,
|
|
343
|
+
};
|
|
344
|
+
if ((await props.inputScope.identify(check)) !== signature)
|
|
345
|
+
return {
|
|
346
|
+
state: "stale",
|
|
347
|
+
message: "Inputs changed during capture. Run it again.",
|
|
348
|
+
evidence: check.record,
|
|
349
|
+
};
|
|
350
|
+
const recordSha256: string = createHash("sha256")
|
|
351
|
+
.update(serializedRecord)
|
|
352
|
+
.digest("hex");
|
|
353
|
+
const outcome: IOutcome = await inspectAutoMovieVerificationCapture(
|
|
354
|
+
check,
|
|
355
|
+
JSON.parse(serializedRecord) as unknown,
|
|
356
|
+
root,
|
|
357
|
+
props.hashMedia,
|
|
358
|
+
);
|
|
359
|
+
if ((await hashAutoMovieFile(recordPath)) !== recordSha256)
|
|
360
|
+
return {
|
|
361
|
+
state: "stale",
|
|
362
|
+
message: "Another capture replaced the record. Refresh it again.",
|
|
363
|
+
evidence: check.record,
|
|
364
|
+
};
|
|
365
|
+
await writeReceipt(file, { signature, outcome, recordSha256 });
|
|
366
|
+
return outcome;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
let recordBytes: Buffer;
|
|
370
|
+
try {
|
|
371
|
+
recordBytes = await fs.readFile(recordPath);
|
|
372
|
+
} catch (error) {
|
|
373
|
+
if (readAutoMovieErrorCode(error) !== "ENOENT") throw error;
|
|
374
|
+
return {
|
|
375
|
+
state: "not-run",
|
|
376
|
+
message: "Capture the scoped subject to write its record.",
|
|
377
|
+
evidence: check.record,
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
const record: unknown = parseJson(recordBytes.toString("utf8"));
|
|
381
|
+
if (record === DAMAGED_JSON)
|
|
382
|
+
return damaged(check.record, "Restore its record or refresh this capture.");
|
|
383
|
+
if (retained?.recordSha256 !== undefined) {
|
|
384
|
+
if (
|
|
385
|
+
retained.signature !== (await props.inputScope.identify(check)) ||
|
|
386
|
+
retained.recordSha256 !==
|
|
387
|
+
createHash("sha256").update(recordBytes).digest("hex")
|
|
388
|
+
)
|
|
389
|
+
return {
|
|
390
|
+
state: "stale",
|
|
391
|
+
message:
|
|
392
|
+
"The check, input files or recorded bytes changed. Refresh the capture.",
|
|
393
|
+
evidence: check.record,
|
|
394
|
+
};
|
|
395
|
+
} else {
|
|
396
|
+
const recordedRevision: unknown = (record as { revision?: unknown } | null)
|
|
397
|
+
?.revision;
|
|
398
|
+
if (
|
|
399
|
+
check.inputs !== undefined ||
|
|
400
|
+
typeof recordedRevision !== "string" ||
|
|
401
|
+
!/^(?:[a-f\d]{40}|[a-f\d]{64})$/u.test(recordedRevision) ||
|
|
402
|
+
(await props.inputScope.checkout()) !==
|
|
403
|
+
(await props.inputScope.project()) ||
|
|
404
|
+
recordedRevision !== props.readRevision()
|
|
405
|
+
)
|
|
406
|
+
return {
|
|
407
|
+
state: "unobserved",
|
|
408
|
+
message:
|
|
409
|
+
"Capture input identity is unknown. Declare the scoped files and refresh through verify --run.",
|
|
410
|
+
evidence: check.record,
|
|
411
|
+
};
|
|
412
|
+
}
|
|
413
|
+
return inspectAutoMovieVerificationCapture(
|
|
414
|
+
check,
|
|
415
|
+
record,
|
|
416
|
+
root,
|
|
417
|
+
props.hashMedia,
|
|
418
|
+
);
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
/** Derive the status of an actual finite measurement under inclusive limits. */
|
|
422
|
+
function measured(
|
|
423
|
+
check: IAutoMovieVerification.IMeasurement,
|
|
424
|
+
value: number,
|
|
425
|
+
): IOutcome {
|
|
426
|
+
const { minimum, maximum }: IAutoMovieVerification.IMeasurement = check;
|
|
427
|
+
if (
|
|
428
|
+
!Number.isFinite(value) ||
|
|
429
|
+
!check.unit.trim() ||
|
|
430
|
+
(minimum === undefined && maximum === undefined) ||
|
|
431
|
+
(minimum !== undefined && !Number.isFinite(minimum)) ||
|
|
432
|
+
(maximum !== undefined && !Number.isFinite(maximum)) ||
|
|
433
|
+
(minimum ?? -Infinity) > (maximum ?? Infinity)
|
|
434
|
+
)
|
|
435
|
+
return {
|
|
436
|
+
state: "failed",
|
|
437
|
+
message: "Provide a finite measurement, unit and ordered finite bounds.",
|
|
438
|
+
};
|
|
439
|
+
return {
|
|
440
|
+
state:
|
|
441
|
+
value < (minimum ?? -Infinity) || value > (maximum ?? Infinity)
|
|
442
|
+
? "failed"
|
|
443
|
+
: "passed",
|
|
444
|
+
message: `${value} ${check.unit}. Required ${minimum ?? "−∞"} through ${maximum ?? "∞"} ${check.unit}.`,
|
|
445
|
+
};
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
/** Compact deterministic identity of a serializable definition or receipt key. */
|
|
449
|
+
function digest(value: unknown): string {
|
|
450
|
+
return createHash("sha256").update(JSON.stringify(value)).digest("hex");
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
/** Read a JSON observation, treating only a missing file as unavailable. */
|
|
454
|
+
async function readJson(file: string): Promise<unknown> {
|
|
455
|
+
try {
|
|
456
|
+
return parseJson(await fs.readFile(file, "utf8"));
|
|
457
|
+
} catch (error) {
|
|
458
|
+
if (readAutoMovieErrorCode(error) === "ENOENT") return undefined;
|
|
459
|
+
throw error;
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
/** Publish the latest receipt and retain independent first-failure bytes. */
|
|
464
|
+
function parseJson(contents: string): unknown {
|
|
465
|
+
try {
|
|
466
|
+
return JSON.parse(contents) as unknown;
|
|
467
|
+
} catch (error) {
|
|
468
|
+
if (error instanceof SyntaxError) return DAMAGED_JSON;
|
|
469
|
+
throw error;
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
function damaged(evidence: string, recovery: string): IOutcome {
|
|
474
|
+
return {
|
|
475
|
+
state: "unobserved",
|
|
476
|
+
message: `The JSON record is damaged. ${recovery}`,
|
|
477
|
+
evidence,
|
|
478
|
+
};
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
function writeReceipt(file: string, latest: IReceipt): Promise<void> {
|
|
482
|
+
return writeAutoMovieVerificationReceipt(
|
|
483
|
+
file,
|
|
484
|
+
`${JSON.stringify(latest)}\n`,
|
|
485
|
+
latest.outcome.state === "failed",
|
|
486
|
+
);
|
|
487
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as fs from "node:fs/promises";
|
|
2
|
+
import * as path from "node:path";
|
|
3
|
+
|
|
4
|
+
import { readAutoMovieErrorCode } from "./readAutoMovieErrorCode";
|
|
5
|
+
|
|
6
|
+
/** Check filesystem identity for two spellings of the same native review path. */
|
|
7
|
+
export async function sameAutoMovieReviewFile(
|
|
8
|
+
left: string,
|
|
9
|
+
right: string,
|
|
10
|
+
): Promise<boolean> {
|
|
11
|
+
if (left === right) return true;
|
|
12
|
+
if (path.relative(left, right) !== "") return false;
|
|
13
|
+
try {
|
|
14
|
+
const [canonicalLeft, canonicalRight]: [string, string] = await Promise.all(
|
|
15
|
+
[fs.realpath(left), fs.realpath(right)],
|
|
16
|
+
);
|
|
17
|
+
return canonicalLeft === canonicalRight;
|
|
18
|
+
} catch (error) {
|
|
19
|
+
const code: unknown = readAutoMovieErrorCode(error);
|
|
20
|
+
if (code === "ENOENT" || code === "ENOTDIR") return false;
|
|
21
|
+
throw error;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -3,20 +3,17 @@ import * as path from "node:path";
|
|
|
3
3
|
import { deriveAutoMovieProjectName } from "./deriveAutoMovieProjectName";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* Choose a `create` request's project name, or report that it must be asked
|
|
6
|
+
* Choose a `create` request's project name, or report that it must be asked
|
|
7
|
+
* for.
|
|
7
8
|
*
|
|
8
|
-
* A typed `name` wins. A target that resolves to the working directory itself,
|
|
9
|
+
* A typed `name` wins. A target that resolves to the working directory itself,
|
|
10
|
+
* such as `.`, returns `undefined`: its basename was chosen before the user ran
|
|
11
|
+
* the command, so it is not taken as the name and `run` asks instead. Any other
|
|
12
|
+
* target gives {@link deriveAutoMovieProjectName} of its resolved path.
|
|
9
13
|
*
|
|
10
|
-
* @param props The target as typed, the working directory, and the typed name
|
|
14
|
+
* @param props The target as typed, the working directory, and the typed name
|
|
15
|
+
* if any.
|
|
11
16
|
* @returns The chosen name, or `undefined` when the name must be asked for.
|
|
12
|
-
*
|
|
13
|
-
* @evidence contracts/development/implementation.md#principled-implementation Both paths are resolved before comparison, so `.`, `./` and the absolute working directory are the same target.
|
|
14
|
-
* @evidence contracts/development/implementation.md#clear-and-simple-structure The pure decision is separate from the terminal prompt, so `run` owns the only I/O.
|
|
15
|
-
* @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts The working directory's own name is never silently adopted; the caller must ask or fall back explicitly.
|
|
16
|
-
* @evidence contracts/development/common.md#meaningful-documentation The comment states the precedence, why the working directory is asked about, and the derivation for other targets.
|
|
17
|
-
* @evidence contracts/development/implementation.md#efficient-algorithms Two path resolutions and one comparison, linear in path length.
|
|
18
|
-
* @evidenceExclude contracts/development/implementation.md#reuse-equivalent-work Each call decides one request once.
|
|
19
|
-
* @evidenceExclude contracts/development/implementation.md#bound-retention-and-release-resources The function returns a string or nothing and retains nothing.
|
|
20
17
|
*/
|
|
21
18
|
export function selectAutoMovieProjectName(props: {
|
|
22
19
|
/** Target directory as typed. */
|
|
@@ -6,7 +6,8 @@ import { planAutoMovieModulePageViteConfig } from "./planAutoMovieModulePageVite
|
|
|
6
6
|
import { writeAutoMovieModulePage } from "./writeAutoMovieModulePage";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
* The part of the production's `vite` the capture host calls, declared
|
|
9
|
+
* The part of the production's `vite` the capture host calls, declared
|
|
10
|
+
* structurally so the command loads the production's own Vite at run time.
|
|
10
11
|
*/
|
|
11
12
|
interface IVite {
|
|
12
13
|
build(config: object): Promise<unknown>;
|
|
@@ -17,19 +18,22 @@ interface IVite {
|
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
/**
|
|
20
|
-
* Build a draw-only page for a subject module with the production's Vite, serve
|
|
21
|
+
* Build a draw-only page for a subject module with the production's Vite, serve
|
|
22
|
+
* it with `vite preview`, and return its address and the call that stops the
|
|
23
|
+
* server and deletes the build.
|
|
21
24
|
*
|
|
22
|
-
* The page is generated in a scratch folder under
|
|
25
|
+
* The page is generated in a scratch folder under
|
|
26
|
+
* `<root>/node_modules/.cache/automovie/`: an `index.html` with no interface
|
|
27
|
+
* and a script that calls `installAutoMovieDraw` with the module's `subjects`
|
|
28
|
+
* export. The build takes `planAutoMovieModulePageViteConfig`, the one
|
|
29
|
+
* configuration both page hosts share: the production's `vite.config.ts` when
|
|
30
|
+
* it has one and its `public` folder as its public files, with the generated
|
|
31
|
+
* page as the only input, so a subject loads the assets and plugins the
|
|
32
|
+
* production's own page does. The preview listens on 127.0.0.1 at a free port
|
|
33
|
+
* with `strictPort`, so it never moves to another server's port.
|
|
23
34
|
*
|
|
24
|
-
* It rejects when the module does not exist, naming it, and when the build or
|
|
25
|
-
*
|
|
26
|
-
* @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.
|
|
27
|
-
* @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.
|
|
28
|
-
* @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.
|
|
29
|
-
* @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.
|
|
30
|
-
* @evidence contracts/development/implementation.md#efficient-algorithms One build per host; every capture of the host reuses the served page.
|
|
31
|
-
* @evidence contracts/development/implementation.md#reuse-equivalent-work The built page serves every subject and round of one host.
|
|
32
|
-
* @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.
|
|
35
|
+
* It rejects when the module does not exist, naming it, and when the build or
|
|
36
|
+
* the server fails, after deleting the scratch folder.
|
|
33
37
|
*/
|
|
34
38
|
export async function serveAutoMovieDrawPage(props: {
|
|
35
39
|
/** The production's root folder. */
|
|
@@ -17,15 +17,9 @@ interface IVite {
|
|
|
17
17
|
*
|
|
18
18
|
* The page is written by `writeAutoMovieModulePage`, as the draw page is: one `div` and a script that calls `@automovie/viewer`'s `mountAutoMovieInspectorPage` with the module's `subjects` called on `props` and the window's `location` and `history`, the same call the scaffold's own page makes. The development server takes `planAutoMovieModulePageViteConfig`: the production's `vite.config.ts` and `public` folder and the page as the dependency scanner's entry, so dependencies are pre-bundled before the first load; listens on 127.0.0.1 at `port` or a free port with `strictPort`, and transforms the production's sources on request, so an edit is seen on the next reload.
|
|
19
19
|
*
|
|
20
|
-
*
|
|
20
|
+
* The script also passes through the host's capture command prefix when supplied.
|
|
21
21
|
*
|
|
22
|
-
*
|
|
23
|
-
* @evidence contracts/development/implementation.md#principled-implementation A person inspecting edits sources between looks, so the page is served by Vite's development server, which compiles each module when the page asks for it; capture draws a built page instead because it must not reload between cells.
|
|
24
|
-
* @evidence contracts/development/implementation.md#clear-and-simple-structure Write the page, find a port, start the server; the inspector and the subjects are the page's.
|
|
25
|
-
* @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts The production's own page and configuration file are left untouched, and a taken port fails the start instead of moving to another.
|
|
26
|
-
* @evidence contracts/development/implementation.md#efficient-algorithms One server for the command's life; Vite compiles what the page imports.
|
|
27
|
-
* @evidenceExclude contracts/development/implementation.md#reuse-equivalent-work One page per command.
|
|
28
|
-
* @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.
|
|
22
|
+
* It rejects when the module does not exist, naming it, and when the server cannot start, after deleting the scratch folder.
|
|
29
23
|
*/
|
|
30
24
|
export async function serveAutoMovieInspectorPage(props: {
|
|
31
25
|
/** The production's root folder. */
|
|
@@ -42,6 +36,9 @@ export async function serveAutoMovieInspectorPage(props: {
|
|
|
42
36
|
|
|
43
37
|
/** The JSON value the module's `subjects` is called with, null for none. */
|
|
44
38
|
props: unknown;
|
|
39
|
+
|
|
40
|
+
/** Optional executable and fixed arguments for capturing this subject from `root`. */
|
|
41
|
+
captureCommand?: readonly [string, ...string[]];
|
|
45
42
|
}): Promise<{
|
|
46
43
|
/** Address of the inspector page, without a query. */
|
|
47
44
|
url: string;
|
|
@@ -58,7 +55,7 @@ export async function serveAutoMovieInspectorPage(props: {
|
|
|
58
55
|
title: "AutoMovie inspector",
|
|
59
56
|
body: `<div id="root"></div>`,
|
|
60
57
|
script: (specifier: string): string =>
|
|
61
|
-
`import { mountAutoMovieInspectorPage } from "@automovie/viewer";\nimport { subjects } from ${JSON.stringify(specifier)};\n\nmountAutoMovieInspectorPage({\n root: document.getElementById("root"),\n subjects: subjects(${JSON.stringify(props.props ?? null)}),\n location: window.location,\n history: window.history,\n});\n`,
|
|
58
|
+
`import { mountAutoMovieInspectorPage } from "@automovie/viewer";\nimport { subjects } from ${JSON.stringify(specifier)};\n\nmountAutoMovieInspectorPage({\n root: document.getElementById("root"),\n subjects: subjects(${JSON.stringify(props.props ?? null)}),\n location: window.location,\n history: window.history,\n captureCommand: ${JSON.stringify(props.captureCommand)},\n});\n`,
|
|
62
59
|
});
|
|
63
60
|
try {
|
|
64
61
|
const port: number = props.port ?? (await findAutoMovieFreePort());
|