@orkestrel/capture 0.0.9 → 0.0.10
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 +4 -2
- package/dist/src/core/index.cjs +75 -22
- package/dist/src/core/index.cjs.map +1 -1
- package/dist/src/core/index.d.cts +124 -51
- package/dist/src/core/index.d.ts +124 -51
- package/dist/src/core/index.js +73 -22
- package/dist/src/core/index.js.map +1 -1
- package/dist/src/server/index.cjs +1012 -316
- package/dist/src/server/index.cjs.map +1 -1
- package/dist/src/server/index.d.cts +523 -22
- package/dist/src/server/index.d.ts +523 -22
- package/dist/src/server/index.js +991 -319
- package/dist/src/server/index.js.map +1 -1
- package/package.json +2 -2
package/dist/src/server/index.js
CHANGED
|
@@ -4,14 +4,59 @@ import { dirname, isAbsolute, matchesGlob, relative, resolve, sep } from "node:p
|
|
|
4
4
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
5
5
|
import { parseArgs } from "node:util";
|
|
6
6
|
import { crc32, deflateSync, inflateSync } from "node:zlib";
|
|
7
|
-
import { arrayOf, attempt, isArray, isError, isFunction, isRecord, isString, parseJSON, preview } from "@orkestrel/contract";
|
|
7
|
+
import { arrayOf, attempt, failure, isArray, isError, isFailure, isFunction, isRecord, isString, isSuccess, parseJSON, preview, success } from "@orkestrel/contract";
|
|
8
8
|
import { createDuplex, executeSync, inspectProcess } from "@orkestrel/process/server";
|
|
9
9
|
import { computeProgress, computeProgressRun, createProgressPlugin, extractProgressEvents, readFileSnapshot, renderProgress } from "@orkestrel/test/server";
|
|
10
|
-
import { CAPTURE_LOOKUPS_FILE, CAPTURE_MANIFEST_FILE, CAPTURE_OWNER_PREFIX, CAPTURE_PNG_SIGNATURE, CAPTURE_REGISTRY_FILE, CAPTURE_REQUEST_PREFIX, CAPTURE_VERSION, CaptureError, buildCaptureTags, collectCaptureAncestors, collectCaptureChanges, collectCaptureDuplicates, describeCaptureDeclaration, describeCaptureDestination, describeCaptureError, describeCaptureIdentity, describeCaptureRequest, isCaptureError, isCaptureGeometry, isCaptureLookupJournal, isCapturePath, isCapturePattern, isCaptureReceipt, isCaptureRegistry, isCaptureRequest, isCaptureRun, isCaptureSegment, isCaptureSelector,
|
|
10
|
+
import { CAPTURE_LOOKUPS_FILE, CAPTURE_MANIFEST_FILE, CAPTURE_OWNER_PREFIX, CAPTURE_PNG_SIGNATURE, CAPTURE_REGISTRY_FILE, CAPTURE_REQUEST_PREFIX, CAPTURE_VERSION, CaptureError, buildCaptureTags, collectCaptureAncestors, collectCaptureChanges, collectCaptureDuplicates, describeCaptureDeclaration, describeCaptureDestination, describeCaptureError, describeCaptureIdentity, describeCaptureRequest, isCaptureError, isCaptureGeometry, isCaptureLookupJournal, isCaptureManifestDocument, isCapturePath, isCapturePattern, isCaptureReceipt, isCaptureRegistry, isCaptureRequest, isCaptureRun, isCaptureSegment, isCaptureSelector, matchesCaptureMembers, matchesCaptureSelector, readCaptureArtifact, readCaptureDirty, readCaptureReport, requireCaptureUnique, resolveCaptureKey, resolveCaptureOwner, resolveCaptureStatus, resolveLookupKey, validateCaptureReceipt, validateCaptureRun } from "../core/index.js";
|
|
11
11
|
import { StringDecoder } from "node:string_decoder";
|
|
12
12
|
import { createTimeout } from "@orkestrel/timeout";
|
|
13
13
|
// src/server/constants.ts
|
|
14
14
|
/**
|
|
15
|
+
* Names the command that clears each refusal condition, or none where no command clears it.
|
|
16
|
+
*
|
|
17
|
+
* @remarks
|
|
18
|
+
* `registry` is the complete-registry refresh, and `journey` is the selected owner's journey, which
|
|
19
|
+
* refreshes its state lookups. A runner prints the command on stdout after the report line it
|
|
20
|
+
* follows, ahead of the refusal on stderr, and on stderr after the refusal when no report line
|
|
21
|
+
* precedes it; a condition with no command prints none.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* CAPTURE_RECOVERIES.REGISTRY // 'registry'
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
var CAPTURE_RECOVERIES = Object.freeze({
|
|
29
|
+
USAGE: void 0,
|
|
30
|
+
SELECTION: void 0,
|
|
31
|
+
HOST: void 0,
|
|
32
|
+
STAGE: void 0,
|
|
33
|
+
EVIDENCE: void 0,
|
|
34
|
+
REGISTRY: "registry",
|
|
35
|
+
LOOKUP: "journey",
|
|
36
|
+
CONTAINMENT: void 0
|
|
37
|
+
});
|
|
38
|
+
/**
|
|
39
|
+
* Names the command that clears each freshness classification, or none where no command clears it.
|
|
40
|
+
*
|
|
41
|
+
* @remarks
|
|
42
|
+
* `capture` is a frames run over the read selection. A `duplicate` or an `orphan` names a registry
|
|
43
|
+
* or a file that no frames run changes, and a `current` frame needs nothing.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```ts
|
|
47
|
+
* CAPTURE_STATUS_RECOVERIES['stale-own'] // 'capture'
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
var CAPTURE_STATUS_RECOVERIES = Object.freeze({
|
|
51
|
+
current: void 0,
|
|
52
|
+
duplicate: void 0,
|
|
53
|
+
orphan: void 0,
|
|
54
|
+
missing: "capture",
|
|
55
|
+
unstamped: "capture",
|
|
56
|
+
"stale-shared": "capture",
|
|
57
|
+
"stale-own": "capture"
|
|
58
|
+
});
|
|
59
|
+
/**
|
|
15
60
|
* Names the executable subcommand each runner command answers to.
|
|
16
61
|
*
|
|
17
62
|
* @remarks
|
|
@@ -528,8 +573,13 @@ function buildCaptureChangePlan(paths, entries) {
|
|
|
528
573
|
/**
|
|
529
574
|
* Renders an exact owner command with the selected variants and filters in host shell syntax.
|
|
530
575
|
*
|
|
576
|
+
* @remarks
|
|
577
|
+
* A flag is rendered only when the rendered command's `CAPTURE_COMMAND_OPTIONS` entry declares it,
|
|
578
|
+
* so a journey drops `--state`, a registry refresh drops `--case`, and only `stale` keeps
|
|
579
|
+
* `--portfolio`. `--changed` and `--plan` are never rendered.
|
|
580
|
+
*
|
|
531
581
|
* @param command - The request command, translated to its executable name, or the registry command
|
|
532
|
-
* @param parsed - The parsed flags, a `false` bail rendered as `--no-bail
|
|
582
|
+
* @param parsed - The parsed flags, a `false` bail rendered as `--no-bail`; changed and plan flags are deliberately replaced by the owner
|
|
533
583
|
* @param selector - The explicit owner or all selector; omitted for a registry refresh
|
|
534
584
|
* @param root - The workspace that makes the wrapper path relative
|
|
535
585
|
* @returns The command ready to copy into the host shell
|
|
@@ -541,15 +591,17 @@ function buildCaptureChangePlan(paths, entries) {
|
|
|
541
591
|
*/
|
|
542
592
|
function renderCaptureCommand(command, parsed, selector, root) {
|
|
543
593
|
const config = resolveCaptureRelative(root, parsed.config);
|
|
594
|
+
const options = CAPTURE_COMMAND_OPTIONS[command];
|
|
544
595
|
return [
|
|
545
596
|
"capture",
|
|
546
597
|
command === "registry" ? command : CAPTURE_COMMAND_NAMES[command],
|
|
547
598
|
...selector === void 0 ? [] : [selector],
|
|
548
|
-
...parsed.variants.flatMap((variant) => ["--variant", variant]),
|
|
549
|
-
...parsed.mode === void 0 ? [] : ["--mode", parsed.mode],
|
|
550
|
-
...parsed.case === void 0 ? [] : parsed.case.startsWith("-") ? [`--case=${parsed.case}`] : ["--case", parsed.case],
|
|
551
|
-
...parsed.state === void 0 ? [] : ["--state", parsed.state],
|
|
552
|
-
...parsed.
|
|
599
|
+
...Object.hasOwn(options, "variant") ? parsed.variants.flatMap((variant) => ["--variant", variant]) : [],
|
|
600
|
+
...parsed.mode === void 0 || !Object.hasOwn(options, "mode") ? [] : ["--mode", parsed.mode],
|
|
601
|
+
...parsed.case === void 0 || !Object.hasOwn(options, "case") ? [] : parsed.case.startsWith("-") ? [`--case=${parsed.case}`] : ["--case", parsed.case],
|
|
602
|
+
...parsed.state === void 0 || !Object.hasOwn(options, "state") ? [] : ["--state", parsed.state],
|
|
603
|
+
...parsed.portfolio === void 0 || !Object.hasOwn(options, "portfolio") ? [] : ["--portfolio", parsed.portfolio],
|
|
604
|
+
...parsed.bail === false && Object.hasOwn(options, "bail") ? ["--no-bail"] : [],
|
|
553
605
|
...config.startsWith("-") ? [`--config=${config}`] : ["--config", config]
|
|
554
606
|
].map((argument) => /^[\w./:-]+$/u.test(argument) ? argument : process.platform === "win32" ? `'${argument.replaceAll("'", "''")}'` : `'${argument.replaceAll("'", "'\\''")}'`).join(" ");
|
|
555
607
|
}
|
|
@@ -829,55 +881,341 @@ function filterCaptureInputs(inputs, patterns) {
|
|
|
829
881
|
*
|
|
830
882
|
* @example
|
|
831
883
|
* ```ts
|
|
832
|
-
* buildCaptureLookupJournal([], []).
|
|
884
|
+
* buildCaptureLookupJournal([], []).populations // {}
|
|
833
885
|
* ```
|
|
834
886
|
*/
|
|
835
887
|
function buildCaptureLookupJournal(lookups, collections, manifest) {
|
|
836
|
-
const
|
|
837
|
-
const references = lookups.map((lookup) => {
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
return {
|
|
842
|
-
...lookup,
|
|
843
|
-
inputs: population.digest
|
|
844
|
-
};
|
|
845
|
-
});
|
|
888
|
+
const memo = /* @__PURE__ */ new Map();
|
|
889
|
+
const references = lookups.map((lookup) => ({
|
|
890
|
+
...lookup,
|
|
891
|
+
inputs: computeCaptureTableKey(lookup.inputs, memo)
|
|
892
|
+
}));
|
|
846
893
|
return {
|
|
847
894
|
version: CAPTURE_VERSION,
|
|
848
895
|
...manifest === void 0 ? {} : { manifest },
|
|
849
|
-
|
|
896
|
+
populations: buildCaptureTable(memo),
|
|
850
897
|
lookups: references,
|
|
851
898
|
collections
|
|
852
899
|
};
|
|
853
900
|
}
|
|
854
901
|
/**
|
|
902
|
+
* Admits a decoded lookup journal, checking its declared version before its schema.
|
|
903
|
+
*
|
|
904
|
+
* @param value - The decoded journal file
|
|
905
|
+
* @param file - The journal path each refusal names
|
|
906
|
+
* @returns The journal, whose table digests `readCaptureLookups` verifies
|
|
907
|
+
* @throws Thrown with the removal and the refresh commands when the journal declares another
|
|
908
|
+
* protocol version, and thrown naming the file when its schema is invalid.
|
|
909
|
+
*
|
|
910
|
+
* @example
|
|
911
|
+
* ```ts
|
|
912
|
+
* readCaptureLookupJournal(JSON.parse(text), 'tmp/captures/states/lookups.json').lookups.length
|
|
913
|
+
* ```
|
|
914
|
+
*/
|
|
915
|
+
function readCaptureLookupJournal(value, file) {
|
|
916
|
+
requireCaptureVersion(value, "Lookup journal", file, [file]);
|
|
917
|
+
if (!isCaptureLookupJournal(value)) throw new CaptureError(`Invalid lookup journal schema: ${file}`, {
|
|
918
|
+
code: "EVIDENCE",
|
|
919
|
+
context: { file }
|
|
920
|
+
});
|
|
921
|
+
return value;
|
|
922
|
+
}
|
|
923
|
+
/**
|
|
855
924
|
* Resolves journal lookup references after verifying each stored input population's digest.
|
|
856
925
|
*
|
|
857
926
|
* @param journal - A structurally validated lookup journal
|
|
927
|
+
* @param file - The journal path each refusal names
|
|
858
928
|
* @returns Every expanded lookup in its stored order, sharing the verified input maps
|
|
859
|
-
* @throws Thrown when
|
|
929
|
+
* @throws Thrown when a population does not hash to its key or a lookup names an unknown key.
|
|
860
930
|
*
|
|
861
931
|
* @example
|
|
862
932
|
* ```ts
|
|
863
|
-
* readCaptureLookups(buildCaptureLookupJournal([], [])) // []
|
|
933
|
+
* readCaptureLookups(buildCaptureLookupJournal([], []), 'tmp/captures/states/lookups.json') // []
|
|
864
934
|
* ```
|
|
865
935
|
*/
|
|
866
|
-
function readCaptureLookups(journal) {
|
|
867
|
-
const
|
|
868
|
-
|
|
869
|
-
|
|
936
|
+
function readCaptureLookups(journal, file) {
|
|
937
|
+
const subject = `Lookup journal at ${file}`;
|
|
938
|
+
const populations = readCaptureTable(journal.populations, subject);
|
|
939
|
+
return journal.lookups.map((lookup) => ({
|
|
940
|
+
...lookup,
|
|
941
|
+
inputs: requireCaptureTableEntry(populations, lookup.inputs, subject, "inputs")
|
|
870
942
|
}));
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
943
|
+
}
|
|
944
|
+
/**
|
|
945
|
+
* Computes the table key of a file map, the digest from `buildCaptureDigest([], files)`, once per map.
|
|
946
|
+
*
|
|
947
|
+
* @remarks
|
|
948
|
+
* The memo belongs to one document build: it holds each map by identity beside its ordered,
|
|
949
|
+
* digested population, so equal maps from different objects share one key.
|
|
950
|
+
*
|
|
951
|
+
* @param files - The path-to-hash map a document stores once
|
|
952
|
+
* @param memo - The build's memo from each map to its ordered, digested population
|
|
953
|
+
* @returns The digest that names the map in the document's population table
|
|
954
|
+
*
|
|
955
|
+
* @example
|
|
956
|
+
* ```ts
|
|
957
|
+
* const memo = new Map()
|
|
958
|
+
* computeCaptureTableKey({ 'src/a.ts': 'f'.repeat(64) }, memo).length // 64
|
|
959
|
+
* ```
|
|
960
|
+
*/
|
|
961
|
+
function computeCaptureTableKey(files, memo) {
|
|
962
|
+
const known = memo.get(files);
|
|
963
|
+
if (known !== void 0) return known.digest;
|
|
964
|
+
const population = buildCaptureDigest([], files);
|
|
965
|
+
memo.set(files, population);
|
|
966
|
+
return population.digest;
|
|
967
|
+
}
|
|
968
|
+
/**
|
|
969
|
+
* Builds a document's population table from the memo its table keys were computed through.
|
|
970
|
+
*
|
|
971
|
+
* @param memo - The memo `computeCaptureTableKey` filled for one document build
|
|
972
|
+
* @returns Each distinct ordered map under its digest, in the order the build first met it
|
|
973
|
+
*
|
|
974
|
+
* @example
|
|
975
|
+
* ```ts
|
|
976
|
+
* const memo = new Map()
|
|
977
|
+
* const key = computeCaptureTableKey({ 'src/a.ts': 'f'.repeat(64) }, memo)
|
|
978
|
+
* buildCaptureTable(memo)[key] // { 'src/a.ts': 'ffff…' }
|
|
979
|
+
* ```
|
|
980
|
+
*/
|
|
981
|
+
function buildCaptureTable(memo) {
|
|
982
|
+
return Object.fromEntries([...memo.values()].map((population) => [population.digest, population.files]));
|
|
983
|
+
}
|
|
984
|
+
/**
|
|
985
|
+
* Reads a document's population table after verifying that each map hashes to the key it is stored under.
|
|
986
|
+
*
|
|
987
|
+
* @param table - The stored table from each digest to its path-to-hash map
|
|
988
|
+
* @param subject - The document and its path, which open the refusal message
|
|
989
|
+
* @returns Each verified map by its digest
|
|
990
|
+
* @throws Thrown when a stored map does not hash to its key.
|
|
991
|
+
*
|
|
992
|
+
* @example
|
|
993
|
+
* ```ts
|
|
994
|
+
* readCaptureTable({}, 'Manifest at tmp/captures/states/manifest.json').size // 0
|
|
995
|
+
* ```
|
|
996
|
+
*/
|
|
997
|
+
function readCaptureTable(table, subject) {
|
|
998
|
+
return new Map(Object.entries(table).map(([digest, files]) => {
|
|
999
|
+
if (buildCaptureDigest([], files).digest !== digest) throw new CaptureError(`${subject} stores a population that does not hash to its key: ${digest}`, { code: "EVIDENCE" });
|
|
1000
|
+
return [digest, files];
|
|
1001
|
+
}));
|
|
1002
|
+
}
|
|
1003
|
+
/**
|
|
1004
|
+
* Returns the verified map a table key names, refusing a key the table does not hold.
|
|
1005
|
+
*
|
|
1006
|
+
* @param table - The verified table `readCaptureTable` returns
|
|
1007
|
+
* @param key - The digest a stored member names
|
|
1008
|
+
* @param subject - The document and its path, which open the refusal message
|
|
1009
|
+
* @param field - The referencing field the refusal message names
|
|
1010
|
+
* @returns The file map stored under the key
|
|
1011
|
+
* @throws Thrown when the table holds no map under the key.
|
|
1012
|
+
*
|
|
1013
|
+
* @example
|
|
1014
|
+
* ```ts
|
|
1015
|
+
* requireCaptureTableEntry(new Map([[key, files]]), key, 'Manifest at manifest.json', 'inputs') === files // true
|
|
1016
|
+
* ```
|
|
1017
|
+
*/
|
|
1018
|
+
function requireCaptureTableEntry(table, key, subject, field) {
|
|
1019
|
+
const files = table.get(key);
|
|
1020
|
+
if (files === void 0) throw new CaptureError(`${subject} names an unknown ${field} digest: ${key}`, { code: "EVIDENCE" });
|
|
1021
|
+
return files;
|
|
1022
|
+
}
|
|
1023
|
+
/**
|
|
1024
|
+
* Stores each distinct file map of an expanded manifest once, in a table keyed by the map's digest.
|
|
1025
|
+
*
|
|
1026
|
+
* @param manifest - The expanded manifest the engine publishes
|
|
1027
|
+
* @returns The document whose stamps, lookups, and collections name their maps by table key
|
|
1028
|
+
*
|
|
1029
|
+
* @example
|
|
1030
|
+
* ```ts
|
|
1031
|
+
* const document = buildCaptureManifestDocument(manifest)
|
|
1032
|
+
* Object.keys(document.populations) // one digest per distinct shared or input map
|
|
1033
|
+
* ```
|
|
1034
|
+
*/
|
|
1035
|
+
function buildCaptureManifestDocument(manifest) {
|
|
1036
|
+
const memo = /* @__PURE__ */ new Map();
|
|
1037
|
+
const entries = Object.fromEntries(Object.entries(manifest.entries).map(([key, stamp]) => [key, {
|
|
1038
|
+
...stamp,
|
|
1039
|
+
shared: {
|
|
1040
|
+
...stamp.shared,
|
|
1041
|
+
files: computeCaptureTableKey(stamp.shared.files, memo)
|
|
1042
|
+
}
|
|
1043
|
+
}]));
|
|
1044
|
+
const lookups = manifest.lookups.map((lookup) => ({
|
|
1045
|
+
...lookup,
|
|
1046
|
+
inputs: computeCaptureTableKey(lookup.inputs, memo)
|
|
1047
|
+
}));
|
|
1048
|
+
const collections = manifest.collections?.map((receipt) => ({
|
|
1049
|
+
...receipt,
|
|
1050
|
+
inputs: {
|
|
1051
|
+
...receipt.inputs,
|
|
1052
|
+
files: computeCaptureTableKey(receipt.inputs.files, memo)
|
|
1053
|
+
}
|
|
1054
|
+
}));
|
|
1055
|
+
return {
|
|
1056
|
+
version: manifest.version,
|
|
1057
|
+
populations: buildCaptureTable(memo),
|
|
1058
|
+
registry: manifest.registry,
|
|
1059
|
+
entries,
|
|
1060
|
+
lookups,
|
|
1061
|
+
...collections === void 0 ? {} : { collections }
|
|
1062
|
+
};
|
|
1063
|
+
}
|
|
1064
|
+
/**
|
|
1065
|
+
* Admits a stored manifest and expands every table reference into the file map it names.
|
|
1066
|
+
*
|
|
1067
|
+
* @param value - The decoded manifest file
|
|
1068
|
+
* @param file - The manifest path each refusal names
|
|
1069
|
+
* @returns The expanded manifest, whose references to one key share one verified map
|
|
1070
|
+
* @throws Thrown with the removal and the refresh commands when the document declares another
|
|
1071
|
+
* protocol version, and thrown when its schema is invalid, a table map does not hash to its key,
|
|
1072
|
+
* or a reference names no table key.
|
|
1073
|
+
*
|
|
1074
|
+
* @example
|
|
1075
|
+
* ```ts
|
|
1076
|
+
* const manifest = readCaptureManifest(JSON.parse(text), 'tmp/captures/states/manifest.json')
|
|
1077
|
+
* manifest.lookups[0]?.inputs // the expanded input map
|
|
1078
|
+
* ```
|
|
1079
|
+
*/
|
|
1080
|
+
function readCaptureManifest(value, file) {
|
|
1081
|
+
requireCaptureVersion(value, "Manifest", file, [file, "its lookup journal"]);
|
|
1082
|
+
if (!isCaptureManifestDocument(value)) throw new CaptureError(`Invalid inherited manifest schema: ${file}`, { code: "EVIDENCE" });
|
|
1083
|
+
const subject = `Manifest at ${file}`;
|
|
1084
|
+
const table = readCaptureTable(value.populations, subject);
|
|
1085
|
+
return {
|
|
1086
|
+
version: value.version,
|
|
1087
|
+
registry: value.registry,
|
|
1088
|
+
entries: Object.fromEntries(Object.entries(value.entries).map(([key, stamp]) => [key, {
|
|
1089
|
+
...stamp,
|
|
1090
|
+
shared: {
|
|
1091
|
+
...stamp.shared,
|
|
1092
|
+
files: requireCaptureTableEntry(table, stamp.shared.files, subject, "shared.files")
|
|
1093
|
+
}
|
|
1094
|
+
}])),
|
|
1095
|
+
lookups: value.lookups.map((lookup) => ({
|
|
875
1096
|
...lookup,
|
|
876
|
-
inputs
|
|
877
|
-
}
|
|
1097
|
+
inputs: requireCaptureTableEntry(table, lookup.inputs, subject, "inputs")
|
|
1098
|
+
})),
|
|
1099
|
+
...value.collections === void 0 ? {} : { collections: value.collections.map((receipt) => ({
|
|
1100
|
+
...receipt,
|
|
1101
|
+
inputs: {
|
|
1102
|
+
...receipt.inputs,
|
|
1103
|
+
files: requireCaptureTableEntry(table, receipt.inputs.files, subject, "inputs.files")
|
|
1104
|
+
}
|
|
1105
|
+
})) }
|
|
1106
|
+
};
|
|
1107
|
+
}
|
|
1108
|
+
/**
|
|
1109
|
+
* Refuses a document that declares a numeric version other than `CAPTURE_VERSION`, naming what to remove and the refresh commands.
|
|
1110
|
+
*
|
|
1111
|
+
* @remarks
|
|
1112
|
+
* A document with no numeric version passes, so the schema check that follows names that fault.
|
|
1113
|
+
* No document of another version is converted.
|
|
1114
|
+
*
|
|
1115
|
+
* @param value - The decoded document
|
|
1116
|
+
* @param subject - The document kind that opens the refusal, such as `Registry`
|
|
1117
|
+
* @param file - The document path the refusal names
|
|
1118
|
+
* @param removal - The paths, or the phrases naming them, to remove before the refresh
|
|
1119
|
+
* @throws Thrown as an `EVIDENCE` capture error whose context carries `file` and `version` when the
|
|
1120
|
+
* document declares another numeric version.
|
|
1121
|
+
*
|
|
1122
|
+
* @example
|
|
1123
|
+
* ```ts
|
|
1124
|
+
* requireCaptureVersion({ version: 1 }, 'Registry', 'registry.json', ['registry.json'])
|
|
1125
|
+
* // throws: Registry version 1 at registry.json is not version 2, … Remove registry.json, then refresh explicitly with: capture registry, then capture frames all
|
|
1126
|
+
* ```
|
|
1127
|
+
*/
|
|
1128
|
+
function requireCaptureVersion(value, subject, file, removal) {
|
|
1129
|
+
const version = isRecord(value) ? value.version : void 0;
|
|
1130
|
+
if (typeof version === "number" && version !== CAPTURE_VERSION) throw new CaptureError(`${subject} version ${String(version)} at ${file} is not version ${String(CAPTURE_VERSION)}, and no other version is converted. Remove ${new Intl.ListFormat("en", { type: "conjunction" }).format(removal)}, then refresh explicitly with: capture registry, then capture frames all`, {
|
|
1131
|
+
code: "EVIDENCE",
|
|
1132
|
+
context: {
|
|
1133
|
+
file,
|
|
1134
|
+
version
|
|
1135
|
+
}
|
|
878
1136
|
});
|
|
879
1137
|
}
|
|
880
1138
|
/**
|
|
1139
|
+
* Checks whether an error is the refusal `requireCaptureVersion` throws for another document version.
|
|
1140
|
+
*
|
|
1141
|
+
* @remarks
|
|
1142
|
+
* A caller that adds its own recovery to a refusal passes this one through unchanged, because it
|
|
1143
|
+
* already names the removal and the refresh.
|
|
1144
|
+
*
|
|
1145
|
+
* @param error - The caught value
|
|
1146
|
+
* @returns True if it is an `EVIDENCE` capture error whose context carries a file and a numeric version; false otherwise
|
|
1147
|
+
*
|
|
1148
|
+
* @example
|
|
1149
|
+
* ```ts
|
|
1150
|
+
* matchesCaptureVersionRefusal(captureError(() => requireCaptureVersion({ version: 1 }, 'Registry', file, [file]))) // true
|
|
1151
|
+
* matchesCaptureVersionRefusal(new Error('Invalid')) // false
|
|
1152
|
+
* ```
|
|
1153
|
+
*/
|
|
1154
|
+
function matchesCaptureVersionRefusal(error) {
|
|
1155
|
+
return isCaptureError(error) && error.code === "EVIDENCE" && typeof error.context?.file === "string" && typeof error.context.version === "number";
|
|
1156
|
+
}
|
|
1157
|
+
/**
|
|
1158
|
+
* Classifies a failure raised while reading the accepted registry as the registry condition.
|
|
1159
|
+
*
|
|
1160
|
+
* @remarks
|
|
1161
|
+
* The complete-registry refresh clears every such failure but a document of another version, whose
|
|
1162
|
+
* refusal names its own removal and refresh.
|
|
1163
|
+
*
|
|
1164
|
+
* @param error - The value a registry read threw
|
|
1165
|
+
* @returns A `REGISTRY` capture error with the same message and the original as its cause, for a
|
|
1166
|
+
* value that is not a capture error or is an `EVIDENCE` capture error other than a version refusal;
|
|
1167
|
+
* otherwise the value itself
|
|
1168
|
+
*
|
|
1169
|
+
* @example
|
|
1170
|
+
* ```ts
|
|
1171
|
+
* resolveCaptureRegistryFault(new CaptureError('Invalid accepted registry schema or digest', { code: 'EVIDENCE' })) // a REGISTRY capture error
|
|
1172
|
+
* resolveCaptureRegistryFault(new CaptureError('Unknown portfolio: x', { code: 'SELECTION' })) // the same error
|
|
1173
|
+
* ```
|
|
1174
|
+
*/
|
|
1175
|
+
function resolveCaptureRegistryFault(error) {
|
|
1176
|
+
return isCaptureError(error) && (error.code !== "EVIDENCE" || matchesCaptureVersionRefusal(error)) ? error : new CaptureError(describeCaptureError(error), {
|
|
1177
|
+
code: "REGISTRY",
|
|
1178
|
+
cause: error
|
|
1179
|
+
});
|
|
1180
|
+
}
|
|
1181
|
+
/**
|
|
1182
|
+
* Collects the variants that produce each destination across the registry receipts and the lookup runs.
|
|
1183
|
+
*
|
|
1184
|
+
* @param evidence - The accepted registry and the authenticated lookup runs
|
|
1185
|
+
* @returns Each destination description mapped to its distinct producing variants, in first-seen order
|
|
1186
|
+
*
|
|
1187
|
+
* @example
|
|
1188
|
+
* ```ts
|
|
1189
|
+
* collectCaptureProducers({ registry, runs: [] }).get(describeCaptureDestination(destination)) // ['light-390']
|
|
1190
|
+
* ```
|
|
1191
|
+
*/
|
|
1192
|
+
function collectCaptureProducers(evidence) {
|
|
1193
|
+
const sources = [...evidence.registry.receipts, ...evidence.runs.map((entry) => entry.run)];
|
|
1194
|
+
const attributions = Map.groupBy(sources.flatMap((source) => source.registry.map((entry) => ({
|
|
1195
|
+
description: describeCaptureDestination(entry),
|
|
1196
|
+
variant: source.variant
|
|
1197
|
+
}))), (entry) => entry.description);
|
|
1198
|
+
return new Map([...attributions].map(([description, entries]) => [description, [...new Set(entries.map((entry) => entry.variant))]]));
|
|
1199
|
+
}
|
|
1200
|
+
/**
|
|
1201
|
+
* Returns the one variant that produces a destination, refusing a destination with none or several.
|
|
1202
|
+
*
|
|
1203
|
+
* @param destination - The destination whose producer is read
|
|
1204
|
+
* @param producers - The map `collectCaptureProducers` returns
|
|
1205
|
+
* @returns The destination's unique producing variant
|
|
1206
|
+
* @throws Thrown as an `EVIDENCE` capture error when no variant or more than one produces the destination.
|
|
1207
|
+
*
|
|
1208
|
+
* @example
|
|
1209
|
+
* ```ts
|
|
1210
|
+
* requireCaptureProducer(destination, collectCaptureProducers({ registry, runs: [] })) // 'light-390'
|
|
1211
|
+
* ```
|
|
1212
|
+
*/
|
|
1213
|
+
function requireCaptureProducer(destination, producers) {
|
|
1214
|
+
const variants = producers.get(describeCaptureDestination(destination)) ?? [];
|
|
1215
|
+
if (variants.length !== 1 || variants[0] === void 0) throw new CaptureError("Destination has no unique producing variant", { code: "EVIDENCE" });
|
|
1216
|
+
return variants[0];
|
|
1217
|
+
}
|
|
1218
|
+
/**
|
|
881
1219
|
* Computes the registry identity from its authenticated receipts and exact output population.
|
|
882
1220
|
*
|
|
883
1221
|
* @param registry - The registry fields before its digest is attached
|
|
@@ -885,7 +1223,7 @@ function readCaptureLookups(journal) {
|
|
|
885
1223
|
*
|
|
886
1224
|
* @example
|
|
887
1225
|
* ```ts
|
|
888
|
-
* computeRegistryDigest({ version:
|
|
1226
|
+
* computeRegistryDigest({ version: 2, receipts: [], entries: [] }).length // 64
|
|
889
1227
|
* ```
|
|
890
1228
|
*/
|
|
891
1229
|
function computeRegistryDigest(registry) {
|
|
@@ -969,12 +1307,10 @@ function matchesCaptureSignature(bytes) {
|
|
|
969
1307
|
*/
|
|
970
1308
|
function predictCaptureByte(left, up, corner) {
|
|
971
1309
|
const estimate = left + up - corner;
|
|
972
|
-
const
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
];
|
|
977
|
-
return (distances[0] ?? 0) <= (distances[1] ?? 0) && (distances[0] ?? 0) <= (distances[2] ?? 0) ? left : (distances[1] ?? 0) <= (distances[2] ?? 0) ? up : corner;
|
|
1310
|
+
const west = Math.abs(estimate - left);
|
|
1311
|
+
const north = Math.abs(estimate - up);
|
|
1312
|
+
const diagonal = Math.abs(estimate - corner);
|
|
1313
|
+
return west <= north && west <= diagonal ? left : north <= diagonal ? up : corner;
|
|
978
1314
|
}
|
|
979
1315
|
/**
|
|
980
1316
|
* Reads PNG compressed-data chunks while refusing truncated or corrupt image bytes.
|
|
@@ -982,7 +1318,10 @@ function predictCaptureByte(left, up, corner) {
|
|
|
982
1318
|
* @param bytes - The complete PNG
|
|
983
1319
|
* @param offset - The next chunk header. Default: 8.
|
|
984
1320
|
* @returns Ordered compressed-data chunks
|
|
985
|
-
* @throws Thrown for
|
|
1321
|
+
* @throws Thrown for bytes over the file budget; a truncated chunk, which a file with no closing
|
|
1322
|
+
* chunk also meets; a bad checksum; a closing chunk that is not empty and last; an IHDR chunk
|
|
1323
|
+
* anywhere but offset 8; a critical chunk other than IHDR, PLTE, IDAT, and IEND; or IDAT chunks
|
|
1324
|
+
* that are not consecutive.
|
|
986
1325
|
*
|
|
987
1326
|
* @example
|
|
988
1327
|
* ```ts
|
|
@@ -991,23 +1330,89 @@ function predictCaptureByte(left, up, corner) {
|
|
|
991
1330
|
*/
|
|
992
1331
|
function readCaptureChunks(bytes, offset = 8) {
|
|
993
1332
|
requireCaptureImageSize(bytes.length);
|
|
994
|
-
const positions =
|
|
995
|
-
const
|
|
996
|
-
|
|
997
|
-
|
|
1333
|
+
const positions = scanCaptureChunks(bytes, offset, Infinity);
|
|
1334
|
+
const types = positions.map((position) => bytes.readUInt32BE(position + 4));
|
|
1335
|
+
const header = Buffer.from("IHDR", "latin1").readUInt32BE(0);
|
|
1336
|
+
const palette = Buffer.from("PLTE", "latin1").readUInt32BE(0);
|
|
1337
|
+
const data = Buffer.from("IDAT", "latin1").readUInt32BE(0);
|
|
1338
|
+
const end = Buffer.from("IEND", "latin1").readUInt32BE(0);
|
|
1339
|
+
const last = positions.at(-1);
|
|
1340
|
+
if (last === void 0 || types.at(-1) !== end) throw new CaptureError(`Missing capture PNG closing chunk: ${last === void 0 ? `no chunk follows offset ${preview(offset)}` : `the last chunk is ${preview(bytes.toString("latin1", last + 4, last + 8))} at offset ${String(last)}`}; expected an empty IEND chunk that ends the file`, { code: "EVIDENCE" });
|
|
1341
|
+
const first = types.indexOf(data);
|
|
1342
|
+
const final = types.lastIndexOf(data);
|
|
1343
|
+
const placed = positions.find((position, index) => types[index] === header && position !== 8);
|
|
1344
|
+
if (placed !== void 0) throw new CaptureError(`Invalid capture PNG chunk order: ${describeCaptureChunk(bytes, placed)}; expected one IHDR chunk, at offset 8`, { code: "EVIDENCE" });
|
|
1345
|
+
const unknown = positions.find((position, index) => ((bytes[position + 4] ?? 0) & 32) === 0 && ![
|
|
1346
|
+
header,
|
|
1347
|
+
palette,
|
|
1348
|
+
data,
|
|
1349
|
+
end
|
|
1350
|
+
].includes(types[index] ?? 0));
|
|
1351
|
+
if (unknown !== void 0) throw new CaptureError(`Unsupported capture PNG chunk: critical ${describeCaptureChunk(bytes, unknown)}; expected a critical chunk to be IHDR, PLTE, IDAT, or IEND`, { code: "EVIDENCE" });
|
|
1352
|
+
const gap = types.findIndex((type, index) => index > first && index < final && type !== data);
|
|
1353
|
+
const resume = gap === -1 ? -1 : types.indexOf(data, gap);
|
|
1354
|
+
const resumed = positions[resume];
|
|
1355
|
+
const before = positions[resume - 1];
|
|
1356
|
+
if (resumed !== void 0 && before !== void 0) throw new CaptureError(`Invalid capture PNG chunk order: ${describeCaptureChunk(bytes, resumed)} follows ${preview(bytes.toString("latin1", before + 4, before + 8))} at offset ${String(before)}; expected every IDAT chunk in one consecutive run`, { code: "EVIDENCE" });
|
|
1357
|
+
return positions.flatMap((position, index) => {
|
|
998
1358
|
const length = bytes.readUInt32BE(position);
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1359
|
+
return types[index] === data && length > 0 ? [bytes.subarray(position + 8, position + 8 + length)] : [];
|
|
1360
|
+
});
|
|
1361
|
+
}
|
|
1362
|
+
/**
|
|
1363
|
+
* Walks a PNG's checked chunks from one header and returns each header's offset, up to the closing chunk.
|
|
1364
|
+
*
|
|
1365
|
+
* @remarks
|
|
1366
|
+
* The walk reads at most `count` chunks, and never more than the bytes can hold, so an infinite or
|
|
1367
|
+
* very large count ends at the closing chunk or at a refusal. Each level halves the count, so the
|
|
1368
|
+
* call depth grows with the logarithm of the chunks the bytes can hold.
|
|
1369
|
+
*
|
|
1370
|
+
* @param bytes - The complete PNG
|
|
1371
|
+
* @param position - The offset of the first chunk header to read
|
|
1372
|
+
* @param count - The most chunks to read
|
|
1373
|
+
* @returns The offset of each chunk header read, in order
|
|
1374
|
+
* @throws Thrown for a truncated chunk, a bad checksum, or a closing chunk that is not empty and last.
|
|
1375
|
+
*
|
|
1376
|
+
* @example
|
|
1377
|
+
* ```ts
|
|
1378
|
+
* scanCaptureChunks(encodeCapturePicture({ width: 1, height: 1, pixels: Uint8Array.from([1, 2, 3]) }), 8, Infinity) // [8, 33, 57]
|
|
1379
|
+
* ```
|
|
1380
|
+
*/
|
|
1381
|
+
function scanCaptureChunks(bytes, position, count) {
|
|
1382
|
+
const limit = Math.min(count, Math.floor(bytes.length / 12) + 1);
|
|
1383
|
+
if (limit >= 2) {
|
|
1384
|
+
const half = Math.ceil(limit / 2);
|
|
1385
|
+
const head = scanCaptureChunks(bytes, position, half);
|
|
1386
|
+
const last = head.at(-1);
|
|
1387
|
+
if (last === void 0 || bytes.toString("latin1", last + 4, last + 8) === "IEND") return head;
|
|
1388
|
+
return [...head, ...scanCaptureChunks(bytes, last + 12 + bytes.readUInt32BE(last), limit - half)];
|
|
1009
1389
|
}
|
|
1010
|
-
|
|
1390
|
+
if (!(limit >= 1)) return [];
|
|
1391
|
+
if (!Number.isSafeInteger(position) || position < 8 || position + 12 > bytes.length) throw new CaptureError(`Truncated capture PNG: no 12-byte chunk frame fits at offset ${preview(position)} in ${String(bytes.length)} bytes; expected a whole offset from 8 with 12 bytes after it`, { code: "EVIDENCE" });
|
|
1392
|
+
const end = position + 12 + bytes.readUInt32BE(position);
|
|
1393
|
+
if (end > bytes.length) throw new CaptureError(`Truncated capture PNG chunk: ${describeCaptureChunk(bytes, position)} ends at byte ${String(end)}; expected it to end within the file's ${String(bytes.length)} bytes`, { code: "EVIDENCE" });
|
|
1394
|
+
const stored = bytes.readUInt32BE(end - 4);
|
|
1395
|
+
const computed = crc32(bytes.subarray(position + 4, end - 4)) >>> 0;
|
|
1396
|
+
if (computed !== stored) throw new CaptureError(`Capture PNG checksum differs: ${describeCaptureChunk(bytes, position)} stores ${stored.toString(16).padStart(8, "0")}; expected ${computed.toString(16).padStart(8, "0")}`, { code: "EVIDENCE" });
|
|
1397
|
+
if (bytes.toString("latin1", position + 4, position + 8) === "IEND" && (end !== position + 12 || end !== bytes.length)) throw new CaptureError(`Invalid capture PNG closing chunk: ${describeCaptureChunk(bytes, position)} ends at byte ${String(end)} of ${String(bytes.length)}; expected an empty IEND chunk that ends the file`, { code: "EVIDENCE" });
|
|
1398
|
+
return [position];
|
|
1399
|
+
}
|
|
1400
|
+
/**
|
|
1401
|
+
* Describes the PNG chunk whose header sits at an offset by its type, offset, and length.
|
|
1402
|
+
*
|
|
1403
|
+
* @remarks The type is untrusted file bytes, so it is JSON-encoded and length-capped.
|
|
1404
|
+
*
|
|
1405
|
+
* @param bytes - The complete PNG
|
|
1406
|
+
* @param position - The offset of the chunk header, with its 8 header bytes inside `bytes`
|
|
1407
|
+
* @returns The chunk's description for a refusal
|
|
1408
|
+
*
|
|
1409
|
+
* @example
|
|
1410
|
+
* ```ts
|
|
1411
|
+
* describeCaptureChunk(encodeCapturePicture(picture), 8) // '"IHDR" at offset 8 with length 13'
|
|
1412
|
+
* ```
|
|
1413
|
+
*/
|
|
1414
|
+
function describeCaptureChunk(bytes, position) {
|
|
1415
|
+
return `${preview(bytes.toString("latin1", position + 4, position + 8))} at offset ${String(position)} with length ${String(bytes.readUInt32BE(position))}`;
|
|
1011
1416
|
}
|
|
1012
1417
|
/**
|
|
1013
1418
|
* Reads an image only after its opened file's size is inside the compressed-byte budget.
|
|
@@ -1037,7 +1442,7 @@ function readCaptureImage(file) {
|
|
|
1037
1442
|
* ```
|
|
1038
1443
|
*/
|
|
1039
1444
|
function requireCaptureImageSize(size) {
|
|
1040
|
-
if (!Number.isSafeInteger(size) || size < 0 || size > CAPTURE_PNG_LIMITS.bytes) throw new CaptureError(
|
|
1445
|
+
if (!Number.isSafeInteger(size) || size < 0 || size > CAPTURE_PNG_LIMITS.bytes) throw new CaptureError(`Capture PNG size is outside the file budget: ${preview(size)} bytes; expected a whole number of bytes from 0 to ${String(CAPTURE_PNG_LIMITS.bytes)}`, { code: "EVIDENCE" });
|
|
1041
1446
|
}
|
|
1042
1447
|
/**
|
|
1043
1448
|
* Reconstructs one filtered PNG scanline from its filter byte and the row above.
|
|
@@ -1055,19 +1460,19 @@ function requireCaptureImageSize(size) {
|
|
|
1055
1460
|
*/
|
|
1056
1461
|
function unfilterCaptureRow(filter, line, above, channels) {
|
|
1057
1462
|
const bytes = new Uint8Array(line.length);
|
|
1058
|
-
for (const
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
}
|
|
1463
|
+
if (filter === 1) for (const index of line.keys()) bytes[index] = (line[index] ?? 0) + (index >= channels ? bytes[index - channels] ?? 0 : 0) & 255;
|
|
1464
|
+
else if (filter === 2) for (const index of line.keys()) bytes[index] = (line[index] ?? 0) + (above?.[index] ?? 0) & 255;
|
|
1465
|
+
else if (filter === 3) for (const index of line.keys()) bytes[index] = (line[index] ?? 0) + ((index >= channels ? bytes[index - channels] ?? 0 : 0) + (above?.[index] ?? 0) >> 1) & 255;
|
|
1466
|
+
else if (filter === 4) for (const index of line.keys()) bytes[index] = (line[index] ?? 0) + predictCaptureByte(index >= channels ? bytes[index - channels] ?? 0 : 0, above?.[index] ?? 0, index >= channels ? above?.[index - channels] ?? 0 : 0) & 255;
|
|
1467
|
+
else bytes.set(line);
|
|
1064
1468
|
return bytes;
|
|
1065
1469
|
}
|
|
1066
1470
|
/**
|
|
1067
1471
|
* Inflates a PNG's compressed stream, refusing one that is corrupt or longer than declared.
|
|
1068
1472
|
*
|
|
1069
1473
|
* @param data - The concatenated data-chunk payloads
|
|
1070
|
-
* @param length - The inflated length the header's dimensions declare
|
|
1474
|
+
* @param length - The inflated length the header's dimensions declare, a whole number from 1 to
|
|
1475
|
+
* `Number.MAX_SAFE_INTEGER`; any other value gives an unspecified result that might throw
|
|
1071
1476
|
* @returns The inflated scanlines
|
|
1072
1477
|
* @throws Thrown when the stream is not valid deflate data or inflates past `length`.
|
|
1073
1478
|
*
|
|
@@ -1080,7 +1485,7 @@ function inflateCaptureStream(data, length) {
|
|
|
1080
1485
|
try {
|
|
1081
1486
|
return inflateSync(data, { maxOutputLength: length });
|
|
1082
1487
|
} catch (error) {
|
|
1083
|
-
throw new CaptureError(
|
|
1488
|
+
throw new CaptureError(`Capture PNG stream is corrupt or longer than declared: ${preview(isError(error) ? error.message : error)} in ${String(data.length)} compressed bytes; expected a zlib stream that inflates to at most ${preview(length)} bytes`, {
|
|
1084
1489
|
code: "EVIDENCE",
|
|
1085
1490
|
cause: error
|
|
1086
1491
|
});
|
|
@@ -1105,24 +1510,27 @@ function inflateCaptureStream(data, length) {
|
|
|
1105
1510
|
*/
|
|
1106
1511
|
function decodeCapturePicture(bytes) {
|
|
1107
1512
|
requireCaptureImageSize(bytes.length);
|
|
1108
|
-
if (bytes.length < 33 || !matchesCaptureSignature(bytes) || bytes.toString("latin1", 12, 16) !== "IHDR" || bytes.readUInt32BE(8) !== 13) throw new CaptureError(
|
|
1513
|
+
if (bytes.length < 33 || !matchesCaptureSignature(bytes) || bytes.toString("latin1", 12, 16) !== "IHDR" || bytes.readUInt32BE(8) !== 13) throw new CaptureError(`Invalid capture PNG header: ${bytes.length < 33 ? `the file is ${String(bytes.length)} bytes` : !matchesCaptureSignature(bytes) ? `the signature is ${bytes.toString("hex", 0, 8)}` : `the first chunk is ${preview(bytes.toString("latin1", 12, 16))} with length ${String(bytes.readUInt32BE(8))}`}; expected at least 33 bytes that open with the signature ${Buffer.from(CAPTURE_PNG_SIGNATURE).toString("hex")} and an IHDR chunk with length 13`, { code: "EVIDENCE" });
|
|
1514
|
+
scanCaptureChunks(bytes, 8, 1);
|
|
1109
1515
|
const width = bytes.readUInt32BE(16);
|
|
1110
1516
|
const height = bytes.readUInt32BE(20);
|
|
1111
1517
|
const channels = bytes[25] === 6 ? 4 : bytes[25] === 2 ? 3 : bytes[25] === 4 ? 2 : bytes[25] === 0 ? 1 : 0;
|
|
1112
1518
|
const gray = bytes[25] === 0 || bytes[25] === 4;
|
|
1113
|
-
if (
|
|
1519
|
+
if (channels === 0 || bytes[24] !== 8 || bytes[26] !== 0 || bytes[27] !== 0 || bytes[28] !== 0) throw new CaptureError(`Unsupported capture PNG encoding: bit depth ${String(bytes[24])}, colour type ${String(bytes[25])}, compression ${String(bytes[26])}, filter ${String(bytes[27])}, interlace ${String(bytes[28])}; expected bit depth 8, colour type 0, 2, 4, or 6, compression 0, filter 0, and interlace 0`, { code: "EVIDENCE" });
|
|
1520
|
+
const size = `${String(width)} × ${String(height)}`;
|
|
1521
|
+
if (width === 0 || height === 0) throw new CaptureError(`Invalid capture PNG dimensions: ${size}; expected a width and a height of at least 1`, { code: "EVIDENCE" });
|
|
1114
1522
|
const stride = width * channels;
|
|
1115
1523
|
const length = (stride + 1) * height;
|
|
1116
|
-
if (!Number.isSafeInteger(length)) throw new CaptureError(
|
|
1117
|
-
if (width * height > CAPTURE_PNG_LIMITS.pixels) throw new CaptureError(
|
|
1118
|
-
if (width > CAPTURE_PNG_LIMITS.side || height > CAPTURE_PNG_LIMITS.side) throw new CaptureError(
|
|
1524
|
+
if (!Number.isSafeInteger(length)) throw new CaptureError(`Invalid capture PNG dimensions: ${size} at ${String(channels)} bytes per pixel; expected scanlines of at most ${String(Number.MAX_SAFE_INTEGER)} bytes in all`, { code: "EVIDENCE" });
|
|
1525
|
+
if (width * height > CAPTURE_PNG_LIMITS.pixels) throw new CaptureError(`Capture PNG exceeds the pixel budget: ${size} is ${String(width * height)} pixels; expected at most ${String(CAPTURE_PNG_LIMITS.pixels)} pixels`, { code: "EVIDENCE" });
|
|
1526
|
+
if (width > CAPTURE_PNG_LIMITS.side || height > CAPTURE_PNG_LIMITS.side) throw new CaptureError(`Capture PNG exceeds the dimension budget: ${size}; expected at most ${String(CAPTURE_PNG_LIMITS.side)} pixels per side`, { code: "EVIDENCE" });
|
|
1119
1527
|
const chunks = readCaptureChunks(bytes);
|
|
1120
1528
|
const raw = inflateCaptureStream(chunks.length === 1 && chunks[0] !== void 0 ? chunks[0] : Buffer.concat(chunks), length);
|
|
1121
|
-
if (raw.length !== length) throw new CaptureError(
|
|
1529
|
+
if (raw.length !== length) throw new CaptureError(`Capture PNG scanline length differs: the stream inflates to ${String(raw.length)} bytes; expected ${String(length)} bytes for ${size} at ${String(channels)} bytes per pixel and one filter byte per row`, { code: "EVIDENCE" });
|
|
1122
1530
|
const rows = new Uint8Array(stride * height);
|
|
1123
1531
|
for (const row of new Array(height).keys()) {
|
|
1124
1532
|
const filter = raw[row * (stride + 1)];
|
|
1125
|
-
if (filter === void 0 || filter > 4) throw new CaptureError(
|
|
1533
|
+
if (filter === void 0 || filter > 4) throw new CaptureError(`Unsupported capture PNG filter: type ${String(filter)} on row ${String(row)}; expected a type from 0 to 4`, { code: "EVIDENCE" });
|
|
1126
1534
|
const line = raw.subarray(row * (stride + 1) + 1, (row + 1) * (stride + 1));
|
|
1127
1535
|
rows.set(filter === 0 ? line : unfilterCaptureRow(filter, line, row === 0 ? void 0 : rows.subarray((row - 1) * stride, row * stride), channels), row * stride);
|
|
1128
1536
|
}
|
|
@@ -1192,7 +1600,8 @@ function encodeCaptureChunk(name, data) {
|
|
|
1192
1600
|
* @param picture - The complete RGB pixel buffer
|
|
1193
1601
|
* @param compressed - If `true`, compresses scanlines; if `false`, stores them in the deflate stream. Default: `true`.
|
|
1194
1602
|
* @returns A PNG file
|
|
1195
|
-
* @throws Thrown when
|
|
1603
|
+
* @throws Thrown when a dimension is not a whole number of at least 1, or when the pixel length is
|
|
1604
|
+
* not `width * height * 3`.
|
|
1196
1605
|
*
|
|
1197
1606
|
* @example
|
|
1198
1607
|
* ```ts
|
|
@@ -1221,11 +1630,78 @@ function encodeCapturePicture(picture, compressed = true) {
|
|
|
1221
1630
|
]);
|
|
1222
1631
|
}
|
|
1223
1632
|
/**
|
|
1633
|
+
* Sums a run of samples three bytes apart, one channel of consecutive RGB pixels.
|
|
1634
|
+
*
|
|
1635
|
+
* @remarks
|
|
1636
|
+
* The caller bounds the run: the call reads one sample per column, inside the bytes or not, so a
|
|
1637
|
+
* count that is not above 0 sums nothing and a fractional count reads its ceiling. Each sample reads
|
|
1638
|
+
* `pixels[index] ?? 0` at the index the call computes, so an index outside the bytes, a fractional
|
|
1639
|
+
* index, or a `NaN` index reads 0. For whole-number arguments, the sum equals the direct sum of
|
|
1640
|
+
* those samples where every number the call computes from its arguments is a safe integer, each
|
|
1641
|
+
* sample index among them.
|
|
1642
|
+
*
|
|
1643
|
+
* @param pixels - The source RGB bytes
|
|
1644
|
+
* @param start - The index of the first sample
|
|
1645
|
+
* @param columns - The number of samples to sum
|
|
1646
|
+
* @returns The sum, reading an index outside the bytes or a fractional index as 0
|
|
1647
|
+
* @throws Thrown as an `EVIDENCE` capture error when `columns` is `Infinity`.
|
|
1648
|
+
*
|
|
1649
|
+
* @example
|
|
1650
|
+
* ```ts
|
|
1651
|
+
* sumCaptureRow(Uint8Array.from([1, 0, 0, 2, 0, 0, 3]), 0, 3) // 6
|
|
1652
|
+
* ```
|
|
1653
|
+
*/
|
|
1654
|
+
function sumCaptureRow(pixels, start, columns) {
|
|
1655
|
+
if (columns > 8) {
|
|
1656
|
+
if (columns === Infinity) throw new CaptureError("Capture sum columns must be a finite sample count, not Infinity", { code: "EVIDENCE" });
|
|
1657
|
+
const half = Math.ceil(columns / 2);
|
|
1658
|
+
return sumCaptureRow(pixels, start, half) + sumCaptureRow(pixels, start + half * 3, columns - half);
|
|
1659
|
+
}
|
|
1660
|
+
return (columns > 0 ? pixels[start] ?? 0 : 0) + (columns > 1 ? pixels[start + 3] ?? 0 : 0) + (columns > 2 ? pixels[start + 6] ?? 0 : 0) + (columns > 3 ? pixels[start + 9] ?? 0 : 0) + (columns > 4 ? pixels[start + 12] ?? 0 : 0) + (columns > 5 ? pixels[start + 15] ?? 0 : 0) + (columns > 6 ? pixels[start + 18] ?? 0 : 0) + (columns > 7 ? pixels[start + 21] ?? 0 : 0);
|
|
1661
|
+
}
|
|
1662
|
+
/**
|
|
1663
|
+
* Sums one channel of a picture over a block of source rows.
|
|
1664
|
+
*
|
|
1665
|
+
* @remarks
|
|
1666
|
+
* Source row `top + row` starts its block at `(top + row) * picture.width * 3 + left`, and each row
|
|
1667
|
+
* contributes `columns` samples through `sumCaptureRow`. The caller bounds the block: the call reads
|
|
1668
|
+
* `rows × columns` samples, inside the bytes or not, so a row count that is not above 0 sums nothing
|
|
1669
|
+
* and a fractional row count reads its ceiling. For whole-number arguments, the sum equals the
|
|
1670
|
+
* direct sum of those samples where every number the call computes from its arguments is a safe
|
|
1671
|
+
* integer, each row number, each intermediate sum and product of a row start, and each sample index
|
|
1672
|
+
* among them.
|
|
1673
|
+
*
|
|
1674
|
+
* @param picture - The source RGB picture
|
|
1675
|
+
* @param top - The block's first source row
|
|
1676
|
+
* @param left - The byte offset of the block's first sample inside a row, its channel included
|
|
1677
|
+
* @param row - The first row to sum, counted from `top`
|
|
1678
|
+
* @param rows - The number of rows to sum
|
|
1679
|
+
* @param columns - The number of samples to sum in each row
|
|
1680
|
+
* @returns The block's sum
|
|
1681
|
+
* @throws Thrown as an `EVIDENCE` capture error when `rows` is `Infinity`, or when `columns` is
|
|
1682
|
+
* `Infinity` and the block reads a row.
|
|
1683
|
+
*
|
|
1684
|
+
* @example
|
|
1685
|
+
* ```ts
|
|
1686
|
+
* sumCaptureBlock({ width: 2, height: 2, pixels: Uint8Array.from([1, 0, 0, 2, 0, 0, 3, 0, 0, 4, 0, 0]) }, 0, 0, 0, 2, 2) // 10
|
|
1687
|
+
* ```
|
|
1688
|
+
*/
|
|
1689
|
+
function sumCaptureBlock(picture, top, left, row, rows, columns) {
|
|
1690
|
+
if (rows > 2) {
|
|
1691
|
+
if (rows === Infinity) throw new CaptureError("Capture sum rows must be a finite row count, not Infinity", { code: "EVIDENCE" });
|
|
1692
|
+
const half = Math.ceil(rows / 2);
|
|
1693
|
+
return sumCaptureBlock(picture, top, left, row, half, columns) + sumCaptureBlock(picture, top, left, row + half, rows - half, columns);
|
|
1694
|
+
}
|
|
1695
|
+
return (rows > 0 ? sumCaptureRow(picture.pixels, (top + row) * picture.width * 3 + left, columns) : 0) + (rows > 1 ? sumCaptureRow(picture.pixels, (top + (row + 1)) * picture.width * 3 + left, columns) : 0);
|
|
1696
|
+
}
|
|
1697
|
+
/**
|
|
1224
1698
|
* Scales a picture with an exact area average and clips its displayed height.
|
|
1225
1699
|
*
|
|
1226
1700
|
* @param picture - The source RGB picture
|
|
1227
|
-
* @param factor - The
|
|
1228
|
-
*
|
|
1701
|
+
* @param factor - The reduction factor, a whole number of at least 1; any other value gives an
|
|
1702
|
+
* unspecified result that might throw
|
|
1703
|
+
* @param limit - The maximum displayed height, a whole number of at least 1; any other value gives
|
|
1704
|
+
* an unspecified result that might throw
|
|
1229
1705
|
* @returns A separately owned scaled picture
|
|
1230
1706
|
*
|
|
1231
1707
|
* @example
|
|
@@ -1236,7 +1712,7 @@ function encodeCapturePicture(picture, compressed = true) {
|
|
|
1236
1712
|
function shrinkCapturePicture(picture, factor, limit) {
|
|
1237
1713
|
const width = Math.max(1, Math.ceil(picture.width / factor));
|
|
1238
1714
|
const height = Math.min(Math.max(1, Math.ceil(picture.height / factor)), limit);
|
|
1239
|
-
const
|
|
1715
|
+
const reach = Array.from({ length: Math.ceil(Math.min(factor, Math.max(picture.width, picture.height))) }).length;
|
|
1240
1716
|
const pixels = new Uint8Array(Math.min(Math.max(Math.trunc(width * height * 3) || 0, 0), Number.MAX_SAFE_INTEGER));
|
|
1241
1717
|
const offsets = Array.from({ length: Math.min(width * 3, pixels.length) }, (_, offset) => offset);
|
|
1242
1718
|
const lines = pixels.length === 0 ? 0 : Math.ceil(pixels.length / (width * 3));
|
|
@@ -1245,15 +1721,9 @@ function shrinkCapturePicture(picture, factor, limit) {
|
|
|
1245
1721
|
for (const offset of offsets) {
|
|
1246
1722
|
const index = y * width * 3 + offset;
|
|
1247
1723
|
if (index >= pixels.length) break;
|
|
1248
|
-
const channel = offset % 3;
|
|
1249
1724
|
const x = Math.floor(offset / 3);
|
|
1250
1725
|
const columns = Math.min(factor, picture.width - x * factor);
|
|
1251
|
-
|
|
1252
|
-
if (row >= rows) return total;
|
|
1253
|
-
const start = (y * factor + row) * picture.width * 3 + x * Math.ceil(factor) * 3 + channel;
|
|
1254
|
-
return span.reduce((block, column) => column >= columns ? block : block + (picture.pixels[start + column * 3] ?? 0), total);
|
|
1255
|
-
}, 0);
|
|
1256
|
-
pixels[index] = Math.round(sum / (rows * columns));
|
|
1726
|
+
pixels[index] = Math.round(sumCaptureBlock(picture, y * factor, x * Math.ceil(factor) * 3 + offset % 3, 0, rows > 0 ? Math.min(reach, Math.ceil(rows)) : 0, columns > 0 ? Math.min(reach, Math.ceil(columns)) : 0) / (rows * columns));
|
|
1257
1727
|
}
|
|
1258
1728
|
}
|
|
1259
1729
|
return {
|
|
@@ -1283,16 +1753,19 @@ function composeCapturePictures(pictures, vertical, gap = 6) {
|
|
|
1283
1753
|
if (pictures.length === 0) throw new CaptureError("Empty contact-sheet picture selection", { code: "USAGE" });
|
|
1284
1754
|
const { side, pixels: budget } = CAPTURE_PNG_LIMITS;
|
|
1285
1755
|
const faults = [...pictures.flatMap((picture, position) => ["width", "height"].flatMap((axis) => Number.isSafeInteger(picture[axis]) && picture[axis] >= 0 && picture[axis] <= side ? [] : [`pictures[${String(position)}].${axis} is ${preview(picture[axis])}`])), ...Number.isSafeInteger(gap) && gap >= 0 && gap <= side ? [] : [`gap is ${preview(gap)}`]];
|
|
1286
|
-
const width
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1756
|
+
const { width, height } = computeCaptureComposite(pictures, vertical, gap);
|
|
1757
|
+
if (faults.length > 0 || !matchesCaptureLimits({
|
|
1758
|
+
width,
|
|
1759
|
+
height
|
|
1760
|
+
})) throw new CaptureError(`Contact-sheet geometry is out of range: ${faults.length === 0 ? `composite is ${String(width)} × ${String(height)}` : [...faults.slice(0, 16), ...faults.length > 16 ? [`… ${String(faults.length - 16)} more`] : []].join("; ")}; expected whole numbers from 0 to ${String(side)} for every width, height, and gap, and a composite of at most ${String(side)} per side and ${String(budget)} pixels`, { code: "EVIDENCE" });
|
|
1761
|
+
const ends = [];
|
|
1762
|
+
for (const picture of pictures) ends.push((ends.at(-1) ?? 0) + (vertical ? picture.height : picture.width) + gap);
|
|
1291
1763
|
const spans = pictures.map((picture, position) => ({
|
|
1292
1764
|
picture,
|
|
1293
|
-
start:
|
|
1294
|
-
end: Math.min(
|
|
1295
|
-
}));
|
|
1765
|
+
start: ends[position - 1] ?? 0,
|
|
1766
|
+
end: Math.min(ends[position] ?? 0, vertical ? height : width)
|
|
1767
|
+
})).filter((span) => span.end > span.start);
|
|
1768
|
+
const pixels = new Uint8Array(width * height * 3);
|
|
1296
1769
|
if (vertical) {
|
|
1297
1770
|
for (const { picture, start, end } of spans) for (const row of new Array(Math.max(0, end - start)).keys()) {
|
|
1298
1771
|
const copied = row < picture.height ? picture.width : 0;
|
|
@@ -1319,6 +1792,87 @@ function composeCapturePictures(pictures, vertical, gap = 6) {
|
|
|
1319
1792
|
};
|
|
1320
1793
|
}
|
|
1321
1794
|
/**
|
|
1795
|
+
* Computes the width and height of the composite that `composeCapturePictures` builds from
|
|
1796
|
+
* pictures of these sizes.
|
|
1797
|
+
*
|
|
1798
|
+
* @param pictures - The ordered source sizes
|
|
1799
|
+
* @param vertical - If `true`, stacks them; if `false`, places them side by side
|
|
1800
|
+
* @param gap - The space between source pictures. Default: 6.
|
|
1801
|
+
* @returns The composite's width and height, each 0 for no pictures
|
|
1802
|
+
*
|
|
1803
|
+
* @example
|
|
1804
|
+
* ```ts
|
|
1805
|
+
* computeCaptureComposite([{ width: 4, height: 2 }, { width: 3, height: 5 }], false) // { width: 13, height: 5 }
|
|
1806
|
+
* ```
|
|
1807
|
+
*/
|
|
1808
|
+
function computeCaptureComposite(pictures, vertical, gap = 6) {
|
|
1809
|
+
const span = gap * Math.max(0, pictures.length - 1);
|
|
1810
|
+
return vertical ? {
|
|
1811
|
+
width: pictures.reduce((widest, entry) => Math.max(widest, entry.width), 0),
|
|
1812
|
+
height: pictures.reduce((sum, entry) => sum + entry.height, 0) + span
|
|
1813
|
+
} : {
|
|
1814
|
+
width: pictures.reduce((sum, entry) => sum + entry.width, 0) + span,
|
|
1815
|
+
height: pictures.reduce((tallest, entry) => Math.max(tallest, entry.height), 0)
|
|
1816
|
+
};
|
|
1817
|
+
}
|
|
1818
|
+
/**
|
|
1819
|
+
* Checks whether a picture size fits `CAPTURE_PNG_LIMITS`, per side and in pixels.
|
|
1820
|
+
*
|
|
1821
|
+
* @param picture - The size to check
|
|
1822
|
+
* @returns True if neither side passes `CAPTURE_PNG_LIMITS.side` and the area does not pass
|
|
1823
|
+
* `CAPTURE_PNG_LIMITS.pixels`; false otherwise
|
|
1824
|
+
*
|
|
1825
|
+
* @example
|
|
1826
|
+
* ```ts
|
|
1827
|
+
* matchesCaptureLimits({ width: 13040, height: 1636 }) // false
|
|
1828
|
+
* ```
|
|
1829
|
+
*/
|
|
1830
|
+
function matchesCaptureLimits(picture) {
|
|
1831
|
+
const { side, pixels } = CAPTURE_PNG_LIMITS;
|
|
1832
|
+
return picture.width <= side && picture.height <= side && picture.width * picture.height <= pixels;
|
|
1833
|
+
}
|
|
1834
|
+
/**
|
|
1835
|
+
* Splits contact-sheet rows into consecutive pages of at most `size` rows whose stacked composite
|
|
1836
|
+
* fits `CAPTURE_PNG_LIMITS`.
|
|
1837
|
+
*
|
|
1838
|
+
* @remarks
|
|
1839
|
+
* A page takes each next row while it holds fewer than `size` rows and the stacked composite,
|
|
1840
|
+
* with `gap` between rows, still fits; otherwise the row opens the next page.
|
|
1841
|
+
*
|
|
1842
|
+
* @param rows - The ordered rows, each with its composite width and height
|
|
1843
|
+
* @param size - The most rows a page holds, a whole number of at least 1; any other value gives an
|
|
1844
|
+
* unspecified result that might throw
|
|
1845
|
+
* @param gap - The space between stacked rows
|
|
1846
|
+
* @returns The pages, in order
|
|
1847
|
+
* @throws Thrown with the `USAGE` condition when one row alone does not fit `CAPTURE_PNG_LIMITS`,
|
|
1848
|
+
* naming its composite, the limits, and the narrower `--variant` selection that recovers.
|
|
1849
|
+
*
|
|
1850
|
+
* @example
|
|
1851
|
+
* ```ts
|
|
1852
|
+
* splitCaptureSheets([{ width: 13040, height: 400 }, { width: 13040, height: 400 }], 4, 12).length // 1
|
|
1853
|
+
* ```
|
|
1854
|
+
*/
|
|
1855
|
+
function splitCaptureSheets(rows, size, gap) {
|
|
1856
|
+
const wide = rows.find((row) => !matchesCaptureLimits(row));
|
|
1857
|
+
if (wide !== void 0) throw new CaptureError(`Contact-sheet row is out of range: composite is ${String(wide.width)} × ${String(wide.height)}; expected at most ${String(CAPTURE_PNG_LIMITS.side)} per side and ${String(CAPTURE_PNG_LIMITS.pixels)} pixels; select fewer variants with --variant`, { code: "USAGE" });
|
|
1858
|
+
const marks = [];
|
|
1859
|
+
for (const [index, row] of rows.entries()) {
|
|
1860
|
+
const last = marks.at(-1);
|
|
1861
|
+
const joined = last === void 0 ? void 0 : {
|
|
1862
|
+
first: last.first,
|
|
1863
|
+
width: Math.max(last.width, row.width),
|
|
1864
|
+
height: last.height + gap + row.height
|
|
1865
|
+
};
|
|
1866
|
+
marks.push(joined !== void 0 && index - joined.first < size && matchesCaptureLimits(joined) ? joined : {
|
|
1867
|
+
first: index,
|
|
1868
|
+
width: row.width,
|
|
1869
|
+
height: row.height
|
|
1870
|
+
});
|
|
1871
|
+
}
|
|
1872
|
+
const starts = marks.flatMap((mark, index) => mark.first === index ? [index] : []);
|
|
1873
|
+
return starts.map((first, page) => rows.slice(first, starts[page + 1] ?? rows.length));
|
|
1874
|
+
}
|
|
1875
|
+
/**
|
|
1322
1876
|
* Reads the process id that a request file, or its temporary sibling, names.
|
|
1323
1877
|
*
|
|
1324
1878
|
* @param name - A file name from the request directory
|
|
@@ -1469,6 +2023,19 @@ function resolveCaptureVariants(selected, projects) {
|
|
|
1469
2023
|
return variants;
|
|
1470
2024
|
}
|
|
1471
2025
|
/**
|
|
2026
|
+
* Collects the owner selectors the projects' owner tags declare, once each, in tag order.
|
|
2027
|
+
*
|
|
2028
|
+
* @param projects - The discovered host projects
|
|
2029
|
+
* @returns Each tagged owner selector, ancestors included where the wrapper tags them
|
|
2030
|
+
* @example
|
|
2031
|
+
* ```ts
|
|
2032
|
+
* collectCaptureOwners(projects) // ['pages', 'pages:mail'] for owner:pages and owner:pages:mail tags
|
|
2033
|
+
* ```
|
|
2034
|
+
*/
|
|
2035
|
+
function collectCaptureOwners(projects) {
|
|
2036
|
+
return [...new Set(projects.flatMap((project) => project.tags))].filter((tag) => tag.startsWith(CAPTURE_OWNER_PREFIX)).map((tag) => tag.slice(CAPTURE_OWNER_PREFIX.length));
|
|
2037
|
+
}
|
|
2038
|
+
/**
|
|
1472
2039
|
* Refuses unknown command selections from the wrapper before authenticating disk evidence.
|
|
1473
2040
|
* @example
|
|
1474
2041
|
* ```ts
|
|
@@ -1476,7 +2043,7 @@ function resolveCaptureVariants(selected, projects) {
|
|
|
1476
2043
|
* ```
|
|
1477
2044
|
*/
|
|
1478
2045
|
function requireCaptureSelection(selector, variants, projects, outputs = [], portfolio) {
|
|
1479
|
-
const fault = describeCaptureSelectorFault(selector, [...new Set(projects.flatMap((project) => [...project
|
|
2046
|
+
const fault = describeCaptureSelectorFault(selector, [...new Set(projects.flatMap((project) => [...collectCaptureOwners([project]), ...project.standalone.map((entry) => entry.portfolio)]))]);
|
|
1480
2047
|
if (fault !== void 0) throw new CaptureError(fault, { code: "USAGE" });
|
|
1481
2048
|
const portfolios = [...new Set(projects.flatMap((project) => [...project.portfolios, ...project.standalone].map((entry) => entry.portfolio)))];
|
|
1482
2049
|
if (portfolio !== void 0 && !portfolios.includes(portfolio)) throw new CaptureError(describeCaptureFault("--portfolio", portfolio, "a portfolio declared by the wrapper", portfolios), { code: "USAGE" });
|
|
@@ -1484,6 +2051,27 @@ function requireCaptureSelection(selector, variants, projects, outputs = [], por
|
|
|
1484
2051
|
for (const variant of variants) if (!declared.includes(variant)) throw new CaptureError(describeCaptureFault("--variant", variant, "a variant declared by the wrapper or registry output population", declared), { code: "USAGE" });
|
|
1485
2052
|
}
|
|
1486
2053
|
/**
|
|
2054
|
+
* Picks the standalone portfolio root a selection names by its selector or its portfolio.
|
|
2055
|
+
*
|
|
2056
|
+
* @remarks
|
|
2057
|
+
* A standalone root has no stamping route and no registry refresh, so a selection reads it only
|
|
2058
|
+
* when it names the root's portfolio. Every other selection reads the primary directory.
|
|
2059
|
+
*
|
|
2060
|
+
* @param roots - The wrapper's standalone roots
|
|
2061
|
+
* @param selector - The selected owner selector
|
|
2062
|
+
* @param portfolio - The selected portfolio, when the selection names one
|
|
2063
|
+
* @returns The named standalone root, or `undefined` for a primary selection
|
|
2064
|
+
* @example
|
|
2065
|
+
* ```ts
|
|
2066
|
+
* const vue = { portfolio: 'vue', directory: 'tmp/captures/vue', scoped: false }
|
|
2067
|
+
* resolveCaptureStandalone([vue], 'vue:home') // vue
|
|
2068
|
+
* resolveCaptureStandalone([vue], 'pages:mail') // undefined
|
|
2069
|
+
* ```
|
|
2070
|
+
*/
|
|
2071
|
+
function resolveCaptureStandalone(roots, selector, portfolio) {
|
|
2072
|
+
return roots.find((root) => portfolio === root.portfolio || selector === root.portfolio || selector.startsWith(`${root.portfolio}:`));
|
|
2073
|
+
}
|
|
2074
|
+
/**
|
|
1487
2075
|
* Reads output variant candidates without authenticating or accepting registry evidence.
|
|
1488
2076
|
* @remarks Missing, unreadable, or malformed registries supply no candidate hints; the integrity engine still authenticates every accepted read.
|
|
1489
2077
|
* @example
|
|
@@ -1566,33 +2154,46 @@ function readCaptureSeparator(entry) {
|
|
|
1566
2154
|
* @param file - The accepted registry path
|
|
1567
2155
|
* @param selector - The optional owner selector that bounds the case candidates
|
|
1568
2156
|
* @returns Exact case names mapped to their original title segments within the selected owners
|
|
2157
|
+
* @throws Thrown with the removal of the registry and the manifest and lookup journal beside it,
|
|
2158
|
+
* and the refresh commands, when the registry declares another protocol version; thrown as a
|
|
2159
|
+
* `REGISTRY` capture error when the registry or a reporter it names is absent, unreadable, or fails
|
|
2160
|
+
* authentication.
|
|
1569
2161
|
* @example
|
|
1570
2162
|
* ```ts
|
|
1571
2163
|
* const titles = readCaptureTitles('/workspace', '/workspace/tmp/captures/states/registry.json')
|
|
1572
2164
|
* ```
|
|
1573
2165
|
*/
|
|
1574
2166
|
function readCaptureTitles(root, file, selector) {
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
return
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
2167
|
+
try {
|
|
2168
|
+
const path = requireCaptureContained(root, file);
|
|
2169
|
+
const loaded = attempt(() => readFileSync(path, "utf8"));
|
|
2170
|
+
if (!loaded.success) throw new CaptureError(`Missing accepted registry; run the explicit complete-registry refresh: capture registry. Registry path: ${file}`, {
|
|
2171
|
+
code: "EVIDENCE",
|
|
2172
|
+
cause: loaded.error
|
|
2173
|
+
});
|
|
2174
|
+
const registry = parseJSON(loaded.value);
|
|
2175
|
+
requireCaptureVersion(registry, "Registry", file, [
|
|
2176
|
+
file,
|
|
2177
|
+
resolve(dirname(file), CAPTURE_MANIFEST_FILE),
|
|
2178
|
+
resolve(dirname(file), CAPTURE_LOOKUPS_FILE)
|
|
2179
|
+
]);
|
|
2180
|
+
if (!isCaptureRegistry(registry)) throw new CaptureError("Invalid accepted registry for case titles", { code: "EVIDENCE" });
|
|
2181
|
+
return Object.fromEntries(registry.receipts.flatMap((receipt) => {
|
|
2182
|
+
const text = readFileSync(requireCaptureContained(root, resolve(root, receipt.report.file)), "utf8");
|
|
2183
|
+
if (computeCaptureHash(text) !== receipt.report.digest) throw new CaptureError("Registry reporter digest differs for case titles", { code: "EVIDENCE" });
|
|
2184
|
+
const report = parseJSON(text);
|
|
2185
|
+
if (!isRecord(report) || !arrayOf(isRecord)(report.testResults)) throw new CaptureError("Invalid registry reporter for case titles", { code: "EVIDENCE" });
|
|
2186
|
+
const selected = selector === void 0 ? void 0 : new Set(readCaptureReport(report).assertions.filter((entry) => matchesCaptureSelector(entry.owner, selector)).map((entry) => entry.case));
|
|
2187
|
+
return report.testResults.flatMap((result) => !arrayOf(isRecord)(result.assertionResults) ? [] : result.assertionResults.flatMap((assertion) => {
|
|
2188
|
+
if (!isString(assertion.fullName) || !isString(assertion.title) || !arrayOf(isString)(assertion.ancestorTitles)) return [];
|
|
2189
|
+
const titles = [...assertion.ancestorTitles, assertion.title];
|
|
2190
|
+
if (titles.join(" ") !== assertion.fullName) throw new CaptureError("Registry reporter title segments differ from its case", { code: "EVIDENCE" });
|
|
2191
|
+
return selected === void 0 || selected.has(assertion.fullName) ? [[assertion.fullName, titles]] : [];
|
|
2192
|
+
}));
|
|
1594
2193
|
}));
|
|
1595
|
-
})
|
|
2194
|
+
} catch (error) {
|
|
2195
|
+
throw resolveCaptureRegistryFault(error);
|
|
2196
|
+
}
|
|
1596
2197
|
}
|
|
1597
2198
|
/**
|
|
1598
2199
|
* Parses standard option tokens and refuses empty values, terminators, and repeated single options.
|
|
@@ -1946,7 +2547,7 @@ function readCaptureRequest(options) {
|
|
|
1946
2547
|
code: "HOST",
|
|
1947
2548
|
context: { file }
|
|
1948
2549
|
});
|
|
1949
|
-
if (parsed.version !==
|
|
2550
|
+
if (parsed.version !== CAPTURE_VERSION) throw new CaptureError("Journey selection request has invalid version", { code: "HOST" });
|
|
1950
2551
|
if (!isCaptureSegment(parsed.id) || !isCaptureSegment(parsed.stage)) throw new CaptureError("Journey selection request has invalid identity", { code: "HOST" });
|
|
1951
2552
|
if (parsed.config !== options.config) throw new CaptureError("Journey selection request has invalid config", { code: "HOST" });
|
|
1952
2553
|
if (parsed.mode !== void 0 && (typeof parsed.mode !== "string" || parsed.mode.trim() === "")) throw new CaptureError("Journey selection request has invalid mode", { code: "HOST" });
|
|
@@ -1956,7 +2557,7 @@ function readCaptureRequest(options) {
|
|
|
1956
2557
|
const variants = arrayOf(isString)(parsed.variants) ? parsed.variants : void 0;
|
|
1957
2558
|
if (command === void 0 || selector === void 0 || selector.trim() === "" || selector !== "all" && !options.owners.some((owner) => matchesCaptureSelector(owner, selector)) || variants === void 0 || variants.length === 0 || new Set(variants).size !== variants.length || variants.some((variant) => !options.variants.includes(variant)) || parsed.case !== void 0 && (typeof parsed.case !== "string" || parsed.case.trim() === "")) throw new CaptureError("Journey selection request has invalid command, selector, variants, or case", { code: "HOST" });
|
|
1958
2559
|
return {
|
|
1959
|
-
version:
|
|
2560
|
+
version: CAPTURE_VERSION,
|
|
1960
2561
|
id: parsed.id,
|
|
1961
2562
|
stage: parsed.stage,
|
|
1962
2563
|
config: options.config,
|
|
@@ -2129,7 +2730,34 @@ function scanCaptureFrames(images, producers) {
|
|
|
2129
2730
|
* ```
|
|
2130
2731
|
*/
|
|
2131
2732
|
function collectCaptureIdentical(images) {
|
|
2132
|
-
return [...
|
|
2733
|
+
return [...Map.groupBy(images, (image) => image.digest).values()].filter((group) => group.length > 1).map((group) => group.map((image) => image.entry.file));
|
|
2734
|
+
}
|
|
2735
|
+
/**
|
|
2736
|
+
* Builds the report a preflight prints and a contact-sheet index carries from one preflight result.
|
|
2737
|
+
*
|
|
2738
|
+
* @param result - The judged selection
|
|
2739
|
+
* @returns The selection, freshness, mixed observations, issues, identical groups, image sizes, and `acceptance: false`
|
|
2740
|
+
*
|
|
2741
|
+
* @example
|
|
2742
|
+
* ```ts
|
|
2743
|
+
* buildCaptureReaderReport(await preflight.check()).acceptance // false
|
|
2744
|
+
* ```
|
|
2745
|
+
*/
|
|
2746
|
+
function buildCaptureReaderReport(result) {
|
|
2747
|
+
return {
|
|
2748
|
+
selection: result.selection,
|
|
2749
|
+
freshness: result.freshness,
|
|
2750
|
+
mixed: result.mixed,
|
|
2751
|
+
issues: result.issues,
|
|
2752
|
+
identical: collectCaptureIdentical(result.images),
|
|
2753
|
+
sizes: result.images.map(({ entry, picture, size }) => ({
|
|
2754
|
+
file: entry.file,
|
|
2755
|
+
width: picture.width,
|
|
2756
|
+
height: picture.height,
|
|
2757
|
+
bytes: size
|
|
2758
|
+
})),
|
|
2759
|
+
acceptance: false
|
|
2760
|
+
};
|
|
2133
2761
|
}
|
|
2134
2762
|
/**
|
|
2135
2763
|
* Finds the journey artifact lines that report an uncaught, unhandled, or logged error.
|
|
@@ -2265,7 +2893,7 @@ function readCaptureDescription(value, expected) {
|
|
|
2265
2893
|
"pid",
|
|
2266
2894
|
"projects"
|
|
2267
2895
|
];
|
|
2268
|
-
if (!isRecord(value) || value.version !== CAPTURE_VERSION || !isArray(value.projects) || keys.some((key) => value[key] === void 0) || Object.keys(value).some((key) => !keys.includes(key))) throw new CaptureError(`The host description is malformed; ${describeCaptureFault("description", value,
|
|
2896
|
+
if (!isRecord(value) || value.version !== CAPTURE_VERSION || !isArray(value.projects) || keys.some((key) => value[key] === void 0) || Object.keys(value).some((key) => !keys.includes(key))) throw new CaptureError(`The host description is malformed; ${describeCaptureFault("description", value, `{ version: ${String(CAPTURE_VERSION)}, id: invocation id, nonce: challenge, config: wrapper path, parent: parent pid, pid: discovery child pid, projects: project[] }`, keys, keys)}`, { code: "HOST" });
|
|
2269
2897
|
if (value.id !== expected.id) throw new CaptureError(`The host description answers another invocation; ${describeCaptureFault("description.id", value.id, "the active invocation id", [expected.id])}`, { code: "HOST" });
|
|
2270
2898
|
if (value.nonce !== expected.nonce) throw new CaptureError(`The host description answers another challenge (a replay); ${describeCaptureFault("description.nonce", value.nonce, "the active discovery challenge", [expected.nonce])}`, { code: "HOST" });
|
|
2271
2899
|
if (value.config !== expected.config) throw new CaptureError(`The host description names another wrapper; ${describeCaptureFault("description.config", value.config, "the requested wrapper path", [expected.config])}`, { code: "HOST" });
|
|
@@ -3095,15 +3723,15 @@ var CaptureIntegrity = class {
|
|
|
3095
3723
|
if (request.command === "capture" && stamps.length > 0) {
|
|
3096
3724
|
const inherited = Object.entries(evidence.manifest?.entries ?? {});
|
|
3097
3725
|
const replaced = new Set(stamps.map(resolveCaptureKey));
|
|
3098
|
-
const
|
|
3726
|
+
const document = buildCaptureManifestDocument({
|
|
3099
3727
|
collections,
|
|
3100
3728
|
version: CAPTURE_VERSION,
|
|
3101
3729
|
registry: evidence.registry,
|
|
3102
3730
|
entries: Object.fromEntries([...inherited.filter(([key]) => !replaced.has(key)), ...stamps.map((stamp) => [resolveCaptureKey(stamp), stamp])]),
|
|
3103
3731
|
lookups: merged
|
|
3104
|
-
};
|
|
3105
|
-
if (!
|
|
3106
|
-
this.#commit(this.#options.manifest,
|
|
3732
|
+
});
|
|
3733
|
+
if (!isCaptureManifestDocument(document)) throw new CaptureError("Invalid next manifest", { code: "EVIDENCE" });
|
|
3734
|
+
this.#commit(this.#options.manifest, document, options.signal);
|
|
3107
3735
|
} else if (request.command === "journey" && collected.length > 0) {
|
|
3108
3736
|
const manifest = before.files.find((file) => file.file === this.#options.manifest)?.image.digest;
|
|
3109
3737
|
this.#commit(this.#options.lookups, buildCaptureLookupJournal(merged, collections, manifest), options.signal);
|
|
@@ -3147,12 +3775,13 @@ var CaptureIntegrity = class {
|
|
|
3147
3775
|
const destinations = this.#destinations(populated);
|
|
3148
3776
|
this.#uniqueRegistry(destinations);
|
|
3149
3777
|
const variants = this.#variants(destinations, options);
|
|
3150
|
-
const entries = this.#select(
|
|
3778
|
+
const entries = this.#select(destinations, {
|
|
3151
3779
|
...options,
|
|
3152
3780
|
variants
|
|
3153
|
-
}
|
|
3781
|
+
});
|
|
3154
3782
|
const inputs = this.#digest(this.#options.inputs, snapshots, digests);
|
|
3155
|
-
|
|
3783
|
+
const producers = collectCaptureProducers(populated);
|
|
3784
|
+
for (const variant of new Set(entries.map((entry) => requireCaptureProducer(entry, producers)))) {
|
|
3156
3785
|
const anchor = evidence.registry.receipts.find((receipt) => receipt.variant === variant);
|
|
3157
3786
|
if (anchor !== void 0 && collectCaptureChanges(anchor.inputs, inputs.files).length === 0) continue;
|
|
3158
3787
|
if (!collections.some((entry) => entry.run.variant === variant && entry.receipt.inputs.digest === inputs.digest)) throw new CaptureError(`No current full-collection evidence for producing variant: ${variant}`, {
|
|
@@ -3166,6 +3795,7 @@ var CaptureIntegrity = class {
|
|
|
3166
3795
|
entries
|
|
3167
3796
|
};
|
|
3168
3797
|
} catch (error) {
|
|
3798
|
+
if (matchesCaptureVersionRefusal(error)) throw error;
|
|
3169
3799
|
throw new CaptureError(`${describeCaptureError(error)}. Prepare the explicit complete-registry refresh, or an explicit capture-free owner/case run whose full collection equals that anchor for each affected producing variant; this read starts no process.`, {
|
|
3170
3800
|
code: isCaptureError(error) ? error.code : "EVIDENCE",
|
|
3171
3801
|
cause: error
|
|
@@ -3196,7 +3826,7 @@ var CaptureIntegrity = class {
|
|
|
3196
3826
|
const attested = /* @__PURE__ */ new Set([...evidence.registry.receipts.map((receipt) => receipt.variant), ...evidence.runs.map(({ run }) => run.variant)]);
|
|
3197
3827
|
const unattested = selection.variants === void 0 ? (selection.declared ?? []).filter((variant) => !attested.has(variant)) : [];
|
|
3198
3828
|
if (unattested.length > 0) throw new CaptureError(`Unattested declared variant: ${unattested.join(", ")}`, {
|
|
3199
|
-
code: "
|
|
3829
|
+
code: "REGISTRY",
|
|
3200
3830
|
context: { variants: unattested }
|
|
3201
3831
|
});
|
|
3202
3832
|
const registry = this.#destinations(evidence);
|
|
@@ -3204,7 +3834,7 @@ var CaptureIntegrity = class {
|
|
|
3204
3834
|
...selection,
|
|
3205
3835
|
variants: this.#variants(registry, selection)
|
|
3206
3836
|
};
|
|
3207
|
-
const required = this.#select(
|
|
3837
|
+
const required = this.#select(registry, options);
|
|
3208
3838
|
const disk = this.#images();
|
|
3209
3839
|
const identities = /* @__PURE__ */ new Map();
|
|
3210
3840
|
const physical = Map.groupBy(disk, (file) => this.#physicalIdentity(file, identities));
|
|
@@ -3294,8 +3924,9 @@ var CaptureIntegrity = class {
|
|
|
3294
3924
|
*
|
|
3295
3925
|
* @param options - The original selector, producing variants, state, and optional exact case
|
|
3296
3926
|
* @returns The agreed declaring case, output mappings, and validated lookup receipts
|
|
3297
|
-
* @throws Thrown when evidence is missing, stale, ambiguous, or disagrees with the selection;
|
|
3298
|
-
* the
|
|
3927
|
+
* @throws Thrown when evidence is missing, stale, ambiguous, or disagrees with the selection; a
|
|
3928
|
+
* refusal of the requested state names the owner's journey refresh, and a fault in the evidence
|
|
3929
|
+
* read keeps its own message.
|
|
3299
3930
|
*
|
|
3300
3931
|
* @example
|
|
3301
3932
|
* ```ts
|
|
@@ -3307,7 +3938,7 @@ var CaptureIntegrity = class {
|
|
|
3307
3938
|
const snapshots = /* @__PURE__ */ new Map();
|
|
3308
3939
|
const digests = /* @__PURE__ */ new Map();
|
|
3309
3940
|
const evidence = this.#evidence(snapshots);
|
|
3310
|
-
const entries = this.#select(
|
|
3941
|
+
const entries = this.#select(this.#destinations(evidence), options, collectCaptureProducers(evidence));
|
|
3311
3942
|
this.#uniqueRegistry(entries);
|
|
3312
3943
|
const cases = [...new Set(entries.map((entry) => entry.case))];
|
|
3313
3944
|
const [name] = cases;
|
|
@@ -3318,15 +3949,17 @@ var CaptureIntegrity = class {
|
|
|
3318
3949
|
lookups: entries.map((entry) => {
|
|
3319
3950
|
const run = evidence.runs.find((record) => record.run.registry.some((destination) => describeCaptureDestination(destination) === describeCaptureDestination(entry)));
|
|
3320
3951
|
const lookup = evidence.lookups.find((candidate) => candidate.case === entry.case && candidate.variant === run?.run.variant && candidate.states.includes(options.state));
|
|
3321
|
-
if (lookup === void 0 || lookup.registry !== evidence.registry.digest || !matchesCaptureSelector(lookup.owner, options.selector) || collectCaptureChanges(lookup.inputs, this.#digest(this.#options.inputs, snapshots, digests).files).length > 0) throw new CaptureError(`Missing or stale state lookup: ${entry.state} in ${entry.project}`, { code: "
|
|
3952
|
+
if (lookup === void 0 || lookup.registry !== evidence.registry.digest || !matchesCaptureSelector(lookup.owner, options.selector) || collectCaptureChanges(lookup.inputs, this.#digest(this.#options.inputs, snapshots, digests).files).length > 0) throw new CaptureError(`Missing or stale state lookup: ${entry.state} in ${entry.project}`, { code: "LOOKUP" });
|
|
3322
3953
|
const stamp = evidence.manifest?.entries[resolveCaptureKey(entry)];
|
|
3323
3954
|
if (stamp !== void 0 && describeCaptureIdentity(stamp) !== describeCaptureIdentity(entry)) throw new CaptureError("State lookup disagrees with the manifest identity", { code: "EVIDENCE" });
|
|
3324
3955
|
return lookup;
|
|
3325
3956
|
})
|
|
3326
3957
|
};
|
|
3327
3958
|
} catch (error) {
|
|
3328
|
-
|
|
3329
|
-
|
|
3959
|
+
if (matchesCaptureVersionRefusal(error)) throw error;
|
|
3960
|
+
const code = isCaptureError(error) ? error.code : "EVIDENCE";
|
|
3961
|
+
throw new CaptureError(code === "LOOKUP" || code === "USAGE" || code === "SELECTION" ? `${describeCaptureError(error)}. Refresh explicitly with: capture journey ${options.selector}${options.variants.map((variant) => ` --variant ${variant}`).join("")}${options.case === void 0 ? "" : ` --case ${JSON.stringify(options.case)}`}. Registry declaration changes require the complete-registry refresh: capture registry.` : describeCaptureError(error), {
|
|
3962
|
+
code,
|
|
3330
3963
|
cause: error
|
|
3331
3964
|
});
|
|
3332
3965
|
}
|
|
@@ -3539,26 +4172,34 @@ var CaptureIntegrity = class {
|
|
|
3539
4172
|
requireCaptureUnique(entries.map((entry) => entry.file), "registry paths", true);
|
|
3540
4173
|
}
|
|
3541
4174
|
#registry(snapshots, paths) {
|
|
3542
|
-
|
|
3543
|
-
|
|
3544
|
-
|
|
3545
|
-
|
|
3546
|
-
|
|
3547
|
-
|
|
3548
|
-
|
|
3549
|
-
|
|
3550
|
-
|
|
3551
|
-
requireCaptureUnique(
|
|
4175
|
+
try {
|
|
4176
|
+
if (!existsSync(this.#path(this.#options.registry, paths))) throw new CaptureError("Missing accepted registry; run the explicit complete-registry refresh", { code: "EVIDENCE" });
|
|
4177
|
+
const registry = this.#json(this.#options.registry, paths);
|
|
4178
|
+
requireCaptureVersion(registry, "Registry", this.#options.registry, [
|
|
4179
|
+
this.#options.registry,
|
|
4180
|
+
this.#options.manifest,
|
|
4181
|
+
this.#options.lookups
|
|
4182
|
+
]);
|
|
4183
|
+
if (!isCaptureRegistry(registry) || registry.digest !== computeRegistryDigest(registry) || registry.receipts.length === 0) throw new CaptureError("Invalid accepted registry schema or digest", { code: "EVIDENCE" });
|
|
4184
|
+
requireCaptureUnique(registry.receipts.map((receipt) => receipt.variant), "complete receipt variants", true);
|
|
4185
|
+
for (const receipt of registry.receipts) {
|
|
4186
|
+
const report = this.#file(receipt.report.file, snapshots, paths);
|
|
4187
|
+
if (!receipt.complete || report?.image.digest !== receipt.report.digest) throw new CaptureError("Registry receipt is incomplete or its report changed", { code: "EVIDENCE" });
|
|
4188
|
+
validateCaptureReceipt(receipt, readCaptureReport(this.#json(receipt.report.file, paths)));
|
|
4189
|
+
for (const path of Object.keys(receipt.inputs)) this.#path(path, paths);
|
|
4190
|
+
requireCaptureUnique(Object.keys(receipt.inputs), "receipt input paths", true);
|
|
4191
|
+
}
|
|
4192
|
+
if (!matchesCaptureMembers(registry.entries.map(describeCaptureDestination), registry.receipts.flatMap((receipt) => receipt.registry.map(describeCaptureDestination)))) throw new CaptureError("Registry entries differ from complete receipts", { code: "EVIDENCE" });
|
|
4193
|
+
for (const entry of registry.entries) this.#destination(entry, paths);
|
|
4194
|
+
return registry;
|
|
4195
|
+
} catch (error) {
|
|
4196
|
+
throw resolveCaptureRegistryFault(error);
|
|
3552
4197
|
}
|
|
3553
|
-
if (!matchesCaptureMembers(registry.entries.map(describeCaptureDestination), registry.receipts.flatMap((receipt) => receipt.registry.map(describeCaptureDestination)))) throw new CaptureError("Registry entries differ from complete receipts", { code: "EVIDENCE" });
|
|
3554
|
-
for (const entry of registry.entries) this.#destination(entry, paths);
|
|
3555
|
-
return registry;
|
|
3556
4198
|
}
|
|
3557
4199
|
#evidence(snapshots) {
|
|
3558
4200
|
const paths = /* @__PURE__ */ new Map();
|
|
3559
4201
|
const registry = this.#registry(snapshots, paths);
|
|
3560
|
-
const manifest = existsSync(this.#path(this.#options.manifest, paths)) ? this.#json(this.#options.manifest, paths) : void 0;
|
|
3561
|
-
if (manifest !== void 0 && !isCaptureStoredManifest(manifest)) throw new CaptureError("Invalid inherited manifest schema", { code: "EVIDENCE" });
|
|
4202
|
+
const manifest = existsSync(this.#path(this.#options.manifest, paths)) ? readCaptureManifest(this.#json(this.#options.manifest, paths), this.#options.manifest) : void 0;
|
|
3562
4203
|
if (manifest !== void 0) {
|
|
3563
4204
|
requireCaptureUnique(Object.keys(manifest.entries), "manifest keys", true);
|
|
3564
4205
|
if (manifest.registry.digest !== computeRegistryDigest(manifest.registry)) throw new CaptureError("Invalid inherited registry digest", { code: "EVIDENCE" });
|
|
@@ -3573,10 +4214,9 @@ var CaptureIntegrity = class {
|
|
|
3573
4214
|
]) this.#path(path, paths);
|
|
3574
4215
|
}
|
|
3575
4216
|
}
|
|
3576
|
-
const separate = existsSync(this.#path(this.#options.lookups, paths)) ? this.#json(this.#options.lookups, paths) : void 0;
|
|
3577
|
-
if (separate !== void 0 && !isCaptureLookupJournal(separate)) throw new CaptureError("Invalid separate lookup schema", { code: "EVIDENCE" });
|
|
4217
|
+
const separate = existsSync(this.#path(this.#options.lookups, paths)) ? readCaptureLookupJournal(this.#json(this.#options.lookups, paths), this.#options.lookups) : void 0;
|
|
3578
4218
|
const manifestDigest = this.#file(this.#options.manifest, snapshots, paths)?.image.digest;
|
|
3579
|
-
const current = separate !== void 0 && separate.manifest === manifestDigest ? readCaptureLookups(separate) : [];
|
|
4219
|
+
const current = separate !== void 0 && separate.manifest === manifestDigest ? readCaptureLookups(separate, this.#options.lookups) : [];
|
|
3580
4220
|
const lookups = mergeCaptureLookups(manifest?.lookups ?? [], current).filter((entry) => entry.registry === registry.digest);
|
|
3581
4221
|
const populations = /* @__PURE__ */ new Map();
|
|
3582
4222
|
const runs = [...Map.groupBy(lookups, (entry) => entry.run.file)].map(([file, referenced]) => {
|
|
@@ -3620,9 +4260,9 @@ var CaptureIntegrity = class {
|
|
|
3620
4260
|
const declarations = receipt?.declarations ?? previous?.declarations;
|
|
3621
4261
|
const registry = receipt?.registry ?? previous?.registry;
|
|
3622
4262
|
if (declarations !== void 0 && registry !== void 0) {
|
|
3623
|
-
if (!matchesCaptureMembers(declarations.map(describeCaptureDeclaration), run.declarations.map(describeCaptureDeclaration)) || !matchesCaptureMembers(registry.map(describeCaptureDestination), run.registry.map(describeCaptureDestination))) throw new CaptureError("Collected registry declarations changed; run the explicit complete-registry refresh", { code: "
|
|
4263
|
+
if (!matchesCaptureMembers(declarations.map(describeCaptureDeclaration), run.declarations.map(describeCaptureDeclaration)) || !matchesCaptureMembers(registry.map(describeCaptureDestination), run.registry.map(describeCaptureDestination))) throw new CaptureError("Collected registry declarations changed; run the explicit complete-registry refresh", { code: "REGISTRY" });
|
|
3624
4264
|
} else if (!evidence.registry.receipts.some((entry) => collectCaptureChanges(entry.inputs, inputs).length === 0)) throw new CaptureError("Unattested producing variant; run the explicit complete-registry refresh before its owner lookup refresh", {
|
|
3625
|
-
code: "
|
|
4265
|
+
code: "REGISTRY",
|
|
3626
4266
|
context: { variant: run.variant }
|
|
3627
4267
|
});
|
|
3628
4268
|
}
|
|
@@ -3637,7 +4277,7 @@ var CaptureIntegrity = class {
|
|
|
3637
4277
|
return first.run.registry;
|
|
3638
4278
|
})];
|
|
3639
4279
|
}
|
|
3640
|
-
#select(
|
|
4280
|
+
#select(entries, options, producers) {
|
|
3641
4281
|
const selectors = [...new Set(entries.flatMap((entry) => {
|
|
3642
4282
|
const parts = resolveCaptureOwner(entry).split(":");
|
|
3643
4283
|
return parts.map((_part, index) => parts.slice(0, index + 1).join(":"));
|
|
@@ -3662,19 +4302,16 @@ var CaptureIntegrity = class {
|
|
|
3662
4302
|
const scoped = entries.filter((entry) => matchesCaptureSelector(resolveCaptureOwner(entry), options.selector) && (options.portfolio === void 0 || entry.portfolio === options.portfolio));
|
|
3663
4303
|
if (scoped.length === 0) throw new CaptureError(`Empty selector; ${describeCaptureFault("selector", options.selector, "a declared selector with destinations in the selected portfolio", ["all", ...selectors])}`, { code: "USAGE" });
|
|
3664
4304
|
if (options.variants.length === 0) throw new CaptureError(`Invalid capture selection; ${describeCaptureFault("selection.variants", options.variants, "a nonempty selected variant list", [...new Set(scoped.map((entry) => entry.variant))])}`, { code: "USAGE" });
|
|
3665
|
-
const variants = [...new Set(
|
|
4305
|
+
const variants = [...new Set(producers === void 0 ? entries.map((entry) => entry.variant) : entries.map((entry) => requireCaptureProducer(entry, producers)))];
|
|
3666
4306
|
const unknown = options.variants.find((variant) => !variants.includes(variant));
|
|
3667
|
-
if (unknown !== void 0) throw new CaptureError(`Unknown or unattested selected variant; ${describeCaptureFault("selection.variants", unknown, "an attested registry variant", variants)}`, {
|
|
3668
|
-
|
|
4307
|
+
if (unknown !== void 0) throw new CaptureError(`Unknown or unattested selected variant; ${describeCaptureFault("selection.variants", unknown, "an attested registry variant", variants)}`, {
|
|
4308
|
+
code: "REGISTRY",
|
|
4309
|
+
context: { variant: unknown }
|
|
4310
|
+
});
|
|
4311
|
+
const selected = scoped.filter((entry) => options.variants.includes(producers === void 0 ? entry.variant : requireCaptureProducer(entry, producers)) && (options.state === void 0 || entry.state === options.state) && (options.case === void 0 || entry.case === options.case));
|
|
3669
4312
|
if (selected.length === 0) throw new CaptureError(`Empty selection or state outside selector/case; ${describeCaptureFault("selection.state", options.state, "a state in the selected selector/case", [...new Set(scoped.map((entry) => entry.state))])}; ${describeCaptureFault("selection.case", options.case, "a case in the selected selector", [...new Set(scoped.map((entry) => entry.case))])}`, { code: "USAGE" });
|
|
3670
4313
|
return selected;
|
|
3671
4314
|
}
|
|
3672
|
-
#producer(destination, evidence) {
|
|
3673
|
-
const sources = [...evidence.registry.receipts, ...evidence.runs.map((entry) => entry.run)];
|
|
3674
|
-
const variants = [...new Set(sources.filter((source) => source.registry.some((entry) => describeCaptureDestination(entry) === describeCaptureDestination(destination))).map((source) => source.variant))];
|
|
3675
|
-
if (variants.length !== 1 || variants[0] === void 0) throw new CaptureError("Destination has no unique producing variant", { code: "EVIDENCE" });
|
|
3676
|
-
return variants[0];
|
|
3677
|
-
}
|
|
3678
4315
|
#reportPath(args, paths) {
|
|
3679
4316
|
const outputs = args.filter((argument) => argument.startsWith("--outputFile.json="));
|
|
3680
4317
|
if (outputs.length !== 1 || outputs[0] === void 0) throw new CaptureError("Request has no unique JSON reporter path", { code: "HOST" });
|
|
@@ -4254,7 +4891,7 @@ var CapturePreflight = class {
|
|
|
4254
4891
|
if (!isCapturePath(resolveCaptureRelative(root, config))) throw new CaptureError("Reader config must be a contained repository path", { code: "USAGE" });
|
|
4255
4892
|
requireCaptureSelection(selection.selector, [], loaded.map((entry) => entry.project), [], selection.portfolio);
|
|
4256
4893
|
const primary = requireCaptureProjects(loaded.map((entry) => entry.project));
|
|
4257
|
-
const standalone = primary.standalone
|
|
4894
|
+
const standalone = resolveCaptureStandalone(primary.standalone, selection.selector, selection.portfolio);
|
|
4258
4895
|
const options = buildCaptureIntegrityOptions(root, primary, standalone);
|
|
4259
4896
|
requireCaptureSelection(selection.selector, selection.variants ?? [], loaded.map((entry) => entry.project), readCaptureVariants(root, resolve(root, options.directory, CAPTURE_REGISTRY_FILE)));
|
|
4260
4897
|
const integrity = new CaptureIntegrity(options);
|
|
@@ -4347,22 +4984,8 @@ var CapturePreflight = class {
|
|
|
4347
4984
|
async execute() {
|
|
4348
4985
|
try {
|
|
4349
4986
|
const result = await this.check();
|
|
4350
|
-
|
|
4351
|
-
|
|
4352
|
-
selection: result.selection,
|
|
4353
|
-
freshness: result.freshness,
|
|
4354
|
-
mixed: result.mixed,
|
|
4355
|
-
issues,
|
|
4356
|
-
identical: collectCaptureIdentical(result.images),
|
|
4357
|
-
sizes: result.images.map(({ entry, picture, size }) => ({
|
|
4358
|
-
file: entry.file,
|
|
4359
|
-
width: picture.width,
|
|
4360
|
-
height: picture.height,
|
|
4361
|
-
bytes: size
|
|
4362
|
-
})),
|
|
4363
|
-
acceptance: false
|
|
4364
|
-
})}\n`);
|
|
4365
|
-
return issues.length > 0 || result.freshness.entries.some((entry) => entry.status !== "current") ? CAPTURE_EXIT.failed : CAPTURE_EXIT.passed;
|
|
4987
|
+
this.#stdout(`${CAPTURE_REPORT_LINES.preflight} ${JSON.stringify(buildCaptureReaderReport(result))}\n`);
|
|
4988
|
+
return result.issues.length > 0 || result.freshness.entries.some((entry) => entry.status !== "current") ? CAPTURE_EXIT.failed : CAPTURE_EXIT.passed;
|
|
4366
4989
|
} catch (error) {
|
|
4367
4990
|
this.#stderr(`${describeCaptureError(error)}\n`);
|
|
4368
4991
|
return resolveCaptureExit(error);
|
|
@@ -4470,9 +5093,7 @@ var CapturePreflight = class {
|
|
|
4470
5093
|
#manifest(directory) {
|
|
4471
5094
|
const file = resolve(this.#options.root, directory, CAPTURE_MANIFEST_FILE);
|
|
4472
5095
|
if (!existsSync(file)) return void 0;
|
|
4473
|
-
|
|
4474
|
-
if (!isCaptureStoredManifest(manifest)) throw new CaptureError("Invalid stamped manifest schema", { code: "EVIDENCE" });
|
|
4475
|
-
return manifest;
|
|
5096
|
+
return readCaptureManifest(parseJSON(readFileSync(file, "utf8")), `${directory}/${CAPTURE_MANIFEST_FILE}`);
|
|
4476
5097
|
}
|
|
4477
5098
|
#locate(entry, stored, producers, directory) {
|
|
4478
5099
|
const stamp = stored?.entries[resolveCaptureKey(entry)];
|
|
@@ -4532,7 +5153,8 @@ var CapturePreflight = class {
|
|
|
4532
5153
|
* place, so a registry the engine would refuse never replaces a good one. With `--variant`, the
|
|
4533
5154
|
* existing registry's receipts for the other declared variants are kept. It never widens a scoped
|
|
4534
5155
|
* run into a refresh and refuses while another runner holds a request file in the request directory.
|
|
4535
|
-
* Before any stage, it reads the inherited manifest and lookup journal
|
|
5156
|
+
* Before any stage, it reads the inherited manifest and lookup journal: it refuses a document of
|
|
5157
|
+
* another version with that refusal's own removal and refresh commands alone, and an unsupported
|
|
4536
5158
|
* schema with the file to inspect and repair.
|
|
4537
5159
|
*
|
|
4538
5160
|
* @example
|
|
@@ -4650,13 +5272,16 @@ var CaptureRegistrar = class {
|
|
|
4650
5272
|
return CAPTURE_EXIT.passed;
|
|
4651
5273
|
}
|
|
4652
5274
|
#inherit(options) {
|
|
4653
|
-
for (const
|
|
5275
|
+
for (const file of [options.manifest, options.lookups]) {
|
|
4654
5276
|
const path = resolve(options.root, file);
|
|
4655
5277
|
try {
|
|
4656
5278
|
requireCaptureContained(options.root, path);
|
|
4657
5279
|
if (!existsSync(path)) continue;
|
|
4658
|
-
|
|
5280
|
+
const value = parseJSON(readFileSync(path, "utf8"));
|
|
5281
|
+
if (file === options.manifest) readCaptureManifest(value, file);
|
|
5282
|
+
else readCaptureLookupJournal(value, file);
|
|
4659
5283
|
} catch (error) {
|
|
5284
|
+
if (matchesCaptureVersionRefusal(error)) throw error;
|
|
4660
5285
|
throw new CaptureError(`Cannot refresh the registry with inherited evidence at ${JSON.stringify(file)}: ${describeCaptureError(error)}; inspect and repair this file before retrying`, {
|
|
4661
5286
|
code: "EVIDENCE",
|
|
4662
5287
|
cause: error,
|
|
@@ -4683,7 +5308,7 @@ var CaptureRegistrar = class {
|
|
|
4683
5308
|
...parsed.mode === void 0 ? {} : { mode: parsed.mode }
|
|
4684
5309
|
});
|
|
4685
5310
|
const request = {
|
|
4686
|
-
version:
|
|
5311
|
+
version: CAPTURE_VERSION,
|
|
4687
5312
|
id: invocation.id,
|
|
4688
5313
|
stage,
|
|
4689
5314
|
config: resolveCaptureRelative(root, parsed.config),
|
|
@@ -4850,60 +5475,69 @@ var CaptureRunner = class {
|
|
|
4850
5475
|
stderr: this.#stderr
|
|
4851
5476
|
});
|
|
4852
5477
|
invocation.attach();
|
|
5478
|
+
const invocations = [invocation];
|
|
5479
|
+
const reports = [];
|
|
4853
5480
|
const argumentsResult = attempt(() => readCaptureArguments(argv, command, root, config));
|
|
5481
|
+
const described = await this.#describe(invocation, argumentsResult).then((description) => success(description), (error) => failure(error));
|
|
5482
|
+
const result = isFailure(described) ? described : await this.#dispatch(invocation, invocations, reports, described.value.parsed, described.value.projects).then((code) => success(code), (error) => failure(error));
|
|
4854
5483
|
try {
|
|
4855
|
-
|
|
4856
|
-
if (
|
|
4857
|
-
const parsed = argumentsResult.value;
|
|
4858
|
-
const projects = (await new CaptureDiscovery({
|
|
4859
|
-
root,
|
|
4860
|
-
config: parsed.config,
|
|
4861
|
-
invocation,
|
|
4862
|
-
...parsed.mode === void 0 ? {} : { mode: parsed.mode },
|
|
4863
|
-
...this.#options.deadline === void 0 ? {} : { deadline: this.#options.deadline }
|
|
4864
|
-
}).describe()).projects.map((entry) => entry.project);
|
|
4865
|
-
if (parsed.selector !== void 0) requireCaptureSelection(parsed.selector, [], projects, [], parsed.portfolio);
|
|
4866
|
-
if (command !== "stale" && parsed.variants.length > 0) resolveCaptureVariants(parsed.variants, projects);
|
|
4867
|
-
if (command !== "stale" && parsed.case !== void 0) this.#case(requireCaptureProjects(projects), parsed.case, parsed.selector);
|
|
4868
|
-
if (command !== "stale" && parsed.changed !== void 0) {
|
|
4869
|
-
await invocation.release();
|
|
4870
|
-
invocation.attach();
|
|
4871
|
-
const code = await this.#changed(invocation, command, parsed, projects);
|
|
4872
|
-
if (code === 64) rmSync(invocation.directory, {
|
|
4873
|
-
recursive: true,
|
|
4874
|
-
force: true
|
|
4875
|
-
});
|
|
4876
|
-
return code;
|
|
4877
|
-
}
|
|
4878
|
-
return command === "stale" ? await this.#check(parsed, projects) : await this.#run(invocation, command, parsed, projects);
|
|
4879
|
-
} catch (error) {
|
|
4880
|
-
if (resolveCaptureExit(error) === 64) rmSync(invocation.directory, {
|
|
5484
|
+
const code = isSuccess(result) ? result.value : resolveCaptureExit(result.error);
|
|
5485
|
+
if (code === CAPTURE_EXIT.usage) rmSync(invocation.directory, {
|
|
4881
5486
|
recursive: true,
|
|
4882
5487
|
force: true
|
|
4883
5488
|
});
|
|
4884
|
-
|
|
4885
|
-
|
|
4886
|
-
config: argumentsResult.success ? argumentsResult.value.config : resolve(root, config),
|
|
4887
|
-
variants: []
|
|
4888
|
-
}, "all", root);
|
|
4889
|
-
this.#stderr(`${describeCaptureError(error)}\n${ran.length === 0 ? "No execution child ran; the command was refused before execution." : `Execution stopped after stages: ${ran.join(", ")}; no later stage ran.`}\nNEXT ${next}\n`);
|
|
4890
|
-
return resolveCaptureExit(error);
|
|
5489
|
+
this.#conclude(result, invocations, reports, argumentsResult.success ? argumentsResult.value : void 0, isSuccess(described) ? described.value.projects : []);
|
|
5490
|
+
return code;
|
|
4891
5491
|
} finally {
|
|
4892
5492
|
await invocation.release().catch((error) => this.#stderr(`Capture cleanup failed: ${describeCaptureError(error)}\n`));
|
|
4893
5493
|
}
|
|
4894
5494
|
}
|
|
4895
|
-
async #
|
|
5495
|
+
async #describe(invocation, argumentsResult) {
|
|
5496
|
+
const { root } = this.#options;
|
|
5497
|
+
invocation.prepare();
|
|
5498
|
+
if (!argumentsResult.success) throw argumentsResult.error;
|
|
5499
|
+
const parsed = argumentsResult.value;
|
|
5500
|
+
return {
|
|
5501
|
+
parsed,
|
|
5502
|
+
projects: (await new CaptureDiscovery({
|
|
5503
|
+
root,
|
|
5504
|
+
config: parsed.config,
|
|
5505
|
+
invocation,
|
|
5506
|
+
...parsed.mode === void 0 ? {} : { mode: parsed.mode },
|
|
5507
|
+
...this.#options.deadline === void 0 ? {} : { deadline: this.#options.deadline }
|
|
5508
|
+
}).describe()).projects.map((entry) => entry.project)
|
|
5509
|
+
};
|
|
5510
|
+
}
|
|
5511
|
+
async #dispatch(invocation, invocations, reports, parsed, projects) {
|
|
5512
|
+
const { command } = this.#options;
|
|
5513
|
+
if (parsed.selector !== void 0) requireCaptureSelection(parsed.selector, [], projects, [], parsed.portfolio);
|
|
5514
|
+
if (command !== "stale" && parsed.variants.length > 0) resolveCaptureVariants(parsed.variants, projects);
|
|
5515
|
+
if (command !== "stale" && parsed.changed === void 0) this.#scope(parsed.selector, collectCaptureOwners(projects));
|
|
5516
|
+
if (command !== "stale" && parsed.case !== void 0) this.#case(requireCaptureProjects(projects), parsed.case, parsed.selector);
|
|
5517
|
+
if (command !== "stale" && parsed.changed !== void 0) {
|
|
5518
|
+
await invocation.release();
|
|
5519
|
+
invocation.attach();
|
|
5520
|
+
return await this.#changed(invocation, invocations, reports, command, parsed, projects);
|
|
5521
|
+
}
|
|
5522
|
+
return command === "stale" ? await this.#check(parsed, projects, reports) : await this.#run(invocation, command, parsed, projects, reports);
|
|
5523
|
+
}
|
|
5524
|
+
#conclude(result, invocations, reports, parsed, projects) {
|
|
5525
|
+
const { command } = this.#options;
|
|
5526
|
+
const lines = reports.length > 0 || isSuccess(result) || parsed === void 0 ? reports : this.#recover(result.error, parsed, parsed.selector, invocations.some((entry) => entry.interrupted), projects);
|
|
5527
|
+
const next = [...new Set(lines)].map((line) => `NEXT ${line}\n`).join("");
|
|
5528
|
+
if (reports.length > 0 && next !== "") this.#stdout(next);
|
|
5529
|
+
if (isSuccess(result)) return;
|
|
5530
|
+
const ran = Object.values(CAPTURE_STAGES).filter((stage) => invocations.some((entry) => entry.launched(resolve(entry.directory, `${command}-${stage}.log`))));
|
|
5531
|
+
this.#stderr(`${describeCaptureError(result.error)}\n${ran.length === 0 ? "No execution child ran; the command was refused before execution." : `Execution stopped after stages: ${ran.join(", ")}; no later stage ran.`}\n${reports.length > 0 ? "" : next}`);
|
|
5532
|
+
}
|
|
5533
|
+
async #changed(discovery, invocations, reports, command, parsed, projects) {
|
|
4896
5534
|
const { root, requests } = this.#options;
|
|
4897
5535
|
const primary = requireCaptureProjects(projects);
|
|
4898
5536
|
const plan = this.#changes(parsed, primary);
|
|
4899
5537
|
for (const change of plan.changes) this.#stdout(`CHANGE ${JSON.stringify(change)}\n`);
|
|
4900
5538
|
const commands = plan.owners.map((owner) => renderCaptureCommand(command, parsed, owner, root));
|
|
4901
5539
|
const shared = plan.changes.filter((change) => change.classification === "shared");
|
|
4902
|
-
const complete =
|
|
4903
|
-
config: parsed.config,
|
|
4904
|
-
variants: parsed.variants,
|
|
4905
|
-
...parsed.mode === void 0 ? {} : { mode: parsed.mode }
|
|
4906
|
-
}, "all", root);
|
|
5540
|
+
const complete = this.#complete(parsed);
|
|
4907
5541
|
for (const next of commands) this.#stdout(`COMMAND ${next}\n`);
|
|
4908
5542
|
const variants = resolveCaptureVariants(parsed.variants, projects);
|
|
4909
5543
|
if (shared.length > 0) {
|
|
@@ -4915,7 +5549,7 @@ var CaptureRunner = class {
|
|
|
4915
5549
|
notrun: plan.owners,
|
|
4916
5550
|
reason: "shared inputs require an explicit journey selection"
|
|
4917
5551
|
})}\n`);
|
|
4918
|
-
|
|
5552
|
+
reports.push(...commands, complete);
|
|
4919
5553
|
return CAPTURE_EXIT.usage;
|
|
4920
5554
|
}
|
|
4921
5555
|
if (plan.owners.length === 0) {
|
|
@@ -4925,10 +5559,11 @@ var CaptureRunner = class {
|
|
|
4925
5559
|
failed: [],
|
|
4926
5560
|
notrun: [],
|
|
4927
5561
|
reason: "only outside paths or no changed paths"
|
|
4928
|
-
})}\
|
|
5562
|
+
})}\n`);
|
|
5563
|
+
reports.push(complete);
|
|
4929
5564
|
return parsed.plan ? CAPTURE_EXIT.passed : CAPTURE_EXIT.failed;
|
|
4930
5565
|
}
|
|
4931
|
-
const selectors =
|
|
5566
|
+
const selectors = collectCaptureOwners(projects);
|
|
4932
5567
|
for (const owner of plan.owners) {
|
|
4933
5568
|
const fault = describeCaptureSelectorFault(owner, selectors);
|
|
4934
5569
|
if (fault !== void 0) throw new CaptureError(fault, { code: "HOST" });
|
|
@@ -4943,10 +5578,11 @@ var CaptureRunner = class {
|
|
|
4943
5578
|
notrun: plan.owners,
|
|
4944
5579
|
reason: "--plan starts no execution child"
|
|
4945
5580
|
})}\n`);
|
|
4946
|
-
|
|
5581
|
+
reports.push(...commands);
|
|
4947
5582
|
return CAPTURE_EXIT.passed;
|
|
4948
5583
|
}
|
|
4949
5584
|
const outcomes = [];
|
|
5585
|
+
const recorded = [];
|
|
4950
5586
|
for (const owner of plan.owners) {
|
|
4951
5587
|
if (discovery.interrupted) break;
|
|
4952
5588
|
const invocation = new CaptureInvocation({
|
|
@@ -4956,16 +5592,24 @@ var CaptureRunner = class {
|
|
|
4956
5592
|
stdout: this.#stdout,
|
|
4957
5593
|
stderr: this.#stderr
|
|
4958
5594
|
});
|
|
5595
|
+
invocations.push(invocation);
|
|
4959
5596
|
invocation.attach();
|
|
5597
|
+
const owned = {
|
|
5598
|
+
...parsed,
|
|
5599
|
+
selector: owner
|
|
5600
|
+
};
|
|
5601
|
+
const lines = [];
|
|
4960
5602
|
try {
|
|
4961
|
-
|
|
4962
|
-
|
|
4963
|
-
|
|
4964
|
-
|
|
4965
|
-
|
|
5603
|
+
const code = await Promise.resolve().then(async () => {
|
|
5604
|
+
invocation.prepare();
|
|
5605
|
+
return await this.#run(invocation, command, owned, projects, lines);
|
|
5606
|
+
}).catch((error) => {
|
|
5607
|
+
if (matchesCaptureVersionRefusal(error)) throw error;
|
|
4966
5608
|
this.#stderr(`${describeCaptureError(error)}\n`);
|
|
5609
|
+
if (lines.length === 0) lines.push(...this.#recover(error, owned, owner, false, projects));
|
|
4967
5610
|
return resolveCaptureExit(error);
|
|
4968
5611
|
});
|
|
5612
|
+
if (code !== CAPTURE_EXIT.passed) recorded.push(...lines);
|
|
4969
5613
|
outcomes.push({
|
|
4970
5614
|
owner,
|
|
4971
5615
|
code,
|
|
@@ -4985,10 +5629,18 @@ var CaptureRunner = class {
|
|
|
4985
5629
|
notrun,
|
|
4986
5630
|
reason: discovery.interrupted ? "interrupted" : failed.length > 0 ? "stopped at the first red owner" : "every selected owner passed"
|
|
4987
5631
|
})}\n`);
|
|
4988
|
-
|
|
4989
|
-
if (failed.length === 0 && notrun.length === 0) this.#stdout(`NEXT ${complete}\n`);
|
|
5632
|
+
reports.push(...failed.length === 0 && notrun.length === 0 ? [complete] : [...recorded, ...notrun.map((owner) => renderCaptureCommand(command, parsed, owner, root))]);
|
|
4990
5633
|
return failed.at(0)?.code ?? (discovery.interrupted ? CAPTURE_EXIT.failed : CAPTURE_EXIT.passed);
|
|
4991
5634
|
}
|
|
5635
|
+
#scope(selector, selectors) {
|
|
5636
|
+
if (selector === void 0) throw new CaptureError(this.#usage(selectors), { code: "USAGE" });
|
|
5637
|
+
const fault = describeCaptureSelectorFault(selector, selectors);
|
|
5638
|
+
if (fault !== void 0) throw new CaptureError(fault, {
|
|
5639
|
+
code: "USAGE",
|
|
5640
|
+
context: { selector }
|
|
5641
|
+
});
|
|
5642
|
+
return selector;
|
|
5643
|
+
}
|
|
4992
5644
|
#case(primary, name, selector) {
|
|
4993
5645
|
const { root } = this.#options;
|
|
4994
5646
|
const titles = readCaptureTitles(root, resolve(root, primary.directory, CAPTURE_REGISTRY_FILE), selector);
|
|
@@ -4999,31 +5651,18 @@ var CaptureRunner = class {
|
|
|
4999
5651
|
if (parsed.changed === void 0) throw new CaptureError("Missing value: --changed", { code: "USAGE" });
|
|
5000
5652
|
return this.#integrity(primary).changed(parsed.changed);
|
|
5001
5653
|
} catch (error) {
|
|
5002
|
-
|
|
5003
|
-
|
|
5004
|
-
variants: []
|
|
5005
|
-
}, "all", this.#options.root);
|
|
5006
|
-
const registry = renderCaptureCommand("registry", {
|
|
5007
|
-
config: parsed.config,
|
|
5008
|
-
variants: []
|
|
5009
|
-
}, void 0, this.#options.root);
|
|
5010
|
-
throw new CaptureError(`${describeCaptureError(error)}\nNo owner ran; changed selection was refused.\n${isCaptureError(error) && error.code === "EVIDENCE" ? `NEXT ${registry}\n` : ""}NEXT ${command}`, {
|
|
5654
|
+
if (matchesCaptureVersionRefusal(error)) throw error;
|
|
5655
|
+
throw new CaptureError(`${describeCaptureError(error)}\nNo owner ran; changed selection was refused.`, {
|
|
5011
5656
|
code: isCaptureError(error) ? error.code : "EVIDENCE",
|
|
5012
5657
|
cause: error
|
|
5013
5658
|
});
|
|
5014
5659
|
}
|
|
5015
5660
|
}
|
|
5016
|
-
async #run(invocation, command, parsed, projects) {
|
|
5661
|
+
async #run(invocation, command, parsed, projects, reports) {
|
|
5017
5662
|
const { root } = this.#options;
|
|
5018
5663
|
const primary = requireCaptureProjects(projects);
|
|
5019
|
-
const selectors =
|
|
5020
|
-
const selector = parsed.selector;
|
|
5021
|
-
if (selector === void 0) throw new CaptureError(this.#usage(selectors), { code: "USAGE" });
|
|
5022
|
-
const fault = describeCaptureSelectorFault(selector, selectors);
|
|
5023
|
-
if (fault !== void 0) throw new CaptureError(fault, {
|
|
5024
|
-
code: "USAGE",
|
|
5025
|
-
context: { selector }
|
|
5026
|
-
});
|
|
5664
|
+
const selectors = collectCaptureOwners(projects);
|
|
5665
|
+
const selector = this.#scope(parsed.selector, selectors);
|
|
5027
5666
|
const variants = resolveCaptureVariants(parsed.variants, projects);
|
|
5028
5667
|
const integrity = this.#integrity(primary);
|
|
5029
5668
|
const selected = await this.#resolve(integrity, parsed, selector, variants);
|
|
@@ -5043,33 +5682,32 @@ var CaptureRunner = class {
|
|
|
5043
5682
|
const outcomes = [];
|
|
5044
5683
|
const stages = resolveCaptureStages(variants, primary.first, command);
|
|
5045
5684
|
const completed = [];
|
|
5046
|
-
|
|
5047
|
-
|
|
5048
|
-
|
|
5049
|
-
|
|
5050
|
-
|
|
5051
|
-
|
|
5052
|
-
|
|
5053
|
-
|
|
5054
|
-
|
|
5055
|
-
|
|
5056
|
-
|
|
5057
|
-
|
|
5058
|
-
|
|
5059
|
-
|
|
5060
|
-
|
|
5061
|
-
|
|
5062
|
-
|
|
5063
|
-
|
|
5064
|
-
|
|
5065
|
-
|
|
5066
|
-
|
|
5067
|
-
|
|
5068
|
-
this.#stdout(`NEXT ${renderCaptureCommand(passed ? "journey" : command, passed ? {
|
|
5069
|
-
config: parsed.config,
|
|
5070
|
-
variants: []
|
|
5071
|
-
} : parsed, passed ? "all" : selector, root)}\n`);
|
|
5685
|
+
const result = await this.#stages(invocation, integrity, plan, stages, outcomes, completed).then((code) => success(code), (error) => failure(error));
|
|
5686
|
+
const ran = stages.filter((stage) => invocation.launched(resolve(invocation.directory, `${command}-${stage.name}.log`)));
|
|
5687
|
+
const notrun = stages.filter((stage) => !ran.includes(stage));
|
|
5688
|
+
const failed = ran.filter((stage) => !completed.includes(stage));
|
|
5689
|
+
const passed = completed.length === stages.length && outcomes.some((outcome) => outcome.count > 0);
|
|
5690
|
+
this.#stdout(`STAGES ${JSON.stringify({
|
|
5691
|
+
selector,
|
|
5692
|
+
run: ran.map((stage) => stage.name),
|
|
5693
|
+
passed: completed.map((stage) => stage.name),
|
|
5694
|
+
failed: failed.map((stage) => stage.name),
|
|
5695
|
+
notrun: notrun.map((stage) => stage.name),
|
|
5696
|
+
reason: invocation.interrupted ? "interrupted; no later stage ran" : passed ? "selected workload passed" : failed.length > 0 ? "stage failed; no later stage ran" : notrun.length > 0 ? "refused before execution" : "empty selected workload"
|
|
5697
|
+
})}\n`);
|
|
5698
|
+
reports.push(...passed ? command === "journey" && selector === "all" && parsed.case === void 0 ? [] : [this.#complete(parsed)] : this.#recover(isFailure(result) ? result.error : void 0, parsed, selector, failed.length > 0 || invocation.interrupted, projects));
|
|
5699
|
+
if (isFailure(result)) throw result.error;
|
|
5700
|
+
return result.value;
|
|
5701
|
+
}
|
|
5702
|
+
async #stages(invocation, integrity, plan, stages, outcomes, completed) {
|
|
5703
|
+
for (const stage of stages) {
|
|
5704
|
+
if (invocation.interrupted) return CAPTURE_EXIT.failed;
|
|
5705
|
+
outcomes.push(...await this.#stage(invocation, integrity, plan, stage));
|
|
5706
|
+
completed.push(stage);
|
|
5072
5707
|
}
|
|
5708
|
+
for (const outcome of outcomes) this.#stdout(`${outcome.project}: ${String(outcome.count)} owner-bearing passed cases\n`);
|
|
5709
|
+
if (outcomes.every((outcome) => outcome.count === 0)) throw new CaptureError("Empty selected workload: no requested project held applicable work", { code: "SELECTION" });
|
|
5710
|
+
return CAPTURE_EXIT.passed;
|
|
5073
5711
|
}
|
|
5074
5712
|
async #stage(invocation, integrity, plan, stage) {
|
|
5075
5713
|
const { root } = this.#options;
|
|
@@ -5090,7 +5728,7 @@ var CaptureRunner = class {
|
|
|
5090
5728
|
final: plan.final
|
|
5091
5729
|
});
|
|
5092
5730
|
const request = {
|
|
5093
|
-
version:
|
|
5731
|
+
version: CAPTURE_VERSION,
|
|
5094
5732
|
id: invocation.id,
|
|
5095
5733
|
stage: stage.name,
|
|
5096
5734
|
config: plan.config,
|
|
@@ -5166,11 +5804,11 @@ var CaptureRunner = class {
|
|
|
5166
5804
|
const create = this.#options.integrity;
|
|
5167
5805
|
return create === void 0 ? new CaptureIntegrity(options) : create(options);
|
|
5168
5806
|
}
|
|
5169
|
-
async #check(parsed, projects) {
|
|
5807
|
+
async #check(parsed, projects, reports) {
|
|
5170
5808
|
const selector = parsed.selector;
|
|
5171
5809
|
if (selector === void 0) throw new CaptureError(`Usage: capture ${CAPTURE_COMMAND_NAMES.stale} <selector> [--variant <output>] [--state <state>] [--case <full name>] [--portfolio <name>]`, { code: "USAGE" });
|
|
5172
5810
|
const primary = requireCaptureProjects(projects);
|
|
5173
|
-
const standalone = primary.standalone
|
|
5811
|
+
const standalone = resolveCaptureStandalone(primary.standalone, selector, parsed.portfolio);
|
|
5174
5812
|
requireCaptureSelection(selector, parsed.variants, projects, readCaptureVariants(this.#options.root, resolve(this.#options.root, standalone?.directory ?? primary.directory, CAPTURE_REGISTRY_FILE)));
|
|
5175
5813
|
const result = await this.#integrity(primary, standalone).check({
|
|
5176
5814
|
selector,
|
|
@@ -5184,8 +5822,36 @@ var CaptureRunner = class {
|
|
|
5184
5822
|
command: "stale",
|
|
5185
5823
|
...result
|
|
5186
5824
|
})}\n`);
|
|
5825
|
+
if (standalone === void 0 && result.entries.some((entry) => CAPTURE_STATUS_RECOVERIES[entry.status] === "capture")) reports.push(renderCaptureCommand("capture", {
|
|
5826
|
+
config: parsed.config,
|
|
5827
|
+
variants: [],
|
|
5828
|
+
...parsed.mode === void 0 ? {} : { mode: parsed.mode },
|
|
5829
|
+
...parsed.case === void 0 ? {} : { case: parsed.case }
|
|
5830
|
+
}, selector, this.#options.root));
|
|
5187
5831
|
return result.entries.every((entry) => entry.status === "current") ? CAPTURE_EXIT.passed : CAPTURE_EXIT.failed;
|
|
5188
5832
|
}
|
|
5833
|
+
#recover(error, parsed, selector, unfinished, projects) {
|
|
5834
|
+
if (matchesCaptureVersionRefusal(error)) return [];
|
|
5835
|
+
const { command, root } = this.#options;
|
|
5836
|
+
const recovery = isCaptureError(error) ? CAPTURE_RECOVERIES[error.code] : void 0;
|
|
5837
|
+
const standalone = command === "stale" && selector !== void 0 && resolveCaptureStandalone(projects.flatMap((project) => project.standalone), selector, parsed.portfolio) !== void 0;
|
|
5838
|
+
return [
|
|
5839
|
+
...recovery === "registry" && !standalone ? [renderCaptureCommand("registry", {
|
|
5840
|
+
config: parsed.config,
|
|
5841
|
+
variants: [],
|
|
5842
|
+
...parsed.mode === void 0 ? {} : { mode: parsed.mode }
|
|
5843
|
+
}, void 0, root)] : [],
|
|
5844
|
+
...recovery === "journey" && selector !== void 0 ? [renderCaptureCommand("journey", parsed, selector, root)] : [],
|
|
5845
|
+
...unfinished && selector !== void 0 ? [renderCaptureCommand(command, parsed, selector, root)] : []
|
|
5846
|
+
];
|
|
5847
|
+
}
|
|
5848
|
+
#complete(parsed) {
|
|
5849
|
+
return renderCaptureCommand("journey", {
|
|
5850
|
+
config: parsed.config,
|
|
5851
|
+
variants: parsed.variants,
|
|
5852
|
+
...parsed.mode === void 0 ? {} : { mode: parsed.mode }
|
|
5853
|
+
}, "all", this.#options.root);
|
|
5854
|
+
}
|
|
5189
5855
|
#usage(selectors) {
|
|
5190
5856
|
const { command } = this.#options;
|
|
5191
5857
|
const state = command === "capture" ? " [--state <name>]" : "";
|
|
@@ -5201,8 +5867,8 @@ var CaptureRunner = class {
|
|
|
5201
5867
|
* selection through `CapturePreflight`, so it judges the same population the preflight does and
|
|
5202
5868
|
* keeps its refusals. It writes the sheets, an index of every cell, and a notes document into a new
|
|
5203
5869
|
* directory that is contained in the workspace, has an existing parent, and lies outside every
|
|
5204
|
-
* selected capture directory. A frame whose image cannot be read shows as a red mark
|
|
5205
|
-
*
|
|
5870
|
+
* selected capture directory. A frame whose image cannot be read shows as a red mark with no source
|
|
5871
|
+
* size, and its index cell carries the freshness the engine classified, `missing` for an absent file.
|
|
5206
5872
|
*
|
|
5207
5873
|
* @example
|
|
5208
5874
|
* ```ts
|
|
@@ -5251,23 +5917,31 @@ var CaptureSheets = class {
|
|
|
5251
5917
|
await invocation.release().catch((error) => this.#stderr(`Capture cleanup failed: ${describeCaptureError(error)}\n`));
|
|
5252
5918
|
}
|
|
5253
5919
|
const result = await new CapturePreflight(reader).check();
|
|
5254
|
-
const sheets =
|
|
5255
|
-
|
|
5256
|
-
|
|
5257
|
-
})), CAPTURE_SHEET.rows).map((page, index) =>
|
|
5258
|
-
|
|
5259
|
-
|
|
5260
|
-
|
|
5261
|
-
|
|
5920
|
+
const sheets = splitCaptureSheets(splitCapturePages(this.#groups(result), CAPTURE_SHEET.pairs).map((pair) => ({
|
|
5921
|
+
pair,
|
|
5922
|
+
...computeCaptureComposite(pair.map((group) => computeCaptureComposite(group.cells.map((cell) => cell.picture), false)), false, CAPTURE_SHEET.gap)
|
|
5923
|
+
})), CAPTURE_SHEET.rows, CAPTURE_SHEET.gap).map((page, index) => {
|
|
5924
|
+
const rows = page.map(({ pair }) => {
|
|
5925
|
+
const groups = pair.map((group) => ({
|
|
5926
|
+
...group,
|
|
5927
|
+
picture: composeCapturePictures(group.cells.map((cell) => cell.picture), false)
|
|
5928
|
+
}));
|
|
5929
|
+
return {
|
|
5930
|
+
groups,
|
|
5931
|
+
picture: composeCapturePictures(groups.map((group) => group.picture), false, CAPTURE_SHEET.gap)
|
|
5932
|
+
};
|
|
5933
|
+
});
|
|
5934
|
+
return {
|
|
5935
|
+
file: `${CAPTURE_SHEET_FILES.prefix}${String(index + 1).padStart(CAPTURE_SHEET_FILES.digits, "0")}.png`,
|
|
5936
|
+
rows,
|
|
5937
|
+
picture: composeCapturePictures(rows.map((row) => row.picture), true, CAPTURE_SHEET.gap)
|
|
5938
|
+
};
|
|
5939
|
+
});
|
|
5262
5940
|
const output = this.#output(result);
|
|
5263
5941
|
mkdirSync(output);
|
|
5264
5942
|
for (const sheet of sheets) writeFileSync(resolve(output, sheet.file), encodeCapturePicture(sheet.picture));
|
|
5265
5943
|
const index = {
|
|
5266
|
-
|
|
5267
|
-
freshness: result.freshness,
|
|
5268
|
-
mixed: result.mixed,
|
|
5269
|
-
issues: result.issues,
|
|
5270
|
-
acceptance: false,
|
|
5944
|
+
...buildCaptureReaderReport(result),
|
|
5271
5945
|
sheets: sheets.map((sheet) => ({
|
|
5272
5946
|
file: sheet.file,
|
|
5273
5947
|
width: sheet.picture.width,
|
|
@@ -5307,30 +5981,28 @@ var CaptureSheets = class {
|
|
|
5307
5981
|
}
|
|
5308
5982
|
#groups(result) {
|
|
5309
5983
|
return [...new Set(result.selection.entries.map((entry) => resolveCaptureSheetIdentity(entry)))].map((identity) => {
|
|
5310
|
-
const cells = result.selection.entries.filter((entry) => resolveCaptureSheetIdentity(entry) === identity).map((entry) => {
|
|
5311
|
-
const image = result.images.find((candidate) => candidate.entry.file === entry.file);
|
|
5312
|
-
const factor = image === void 0 ? 1 : Math.max(1, Math.ceil(image.picture.width / CAPTURE_SHEET.cell));
|
|
5313
|
-
return {
|
|
5314
|
-
entry,
|
|
5315
|
-
picture: image === void 0 ? {
|
|
5316
|
-
width: CAPTURE_SHEET.mark.width,
|
|
5317
|
-
height: CAPTURE_SHEET.mark.height,
|
|
5318
|
-
pixels: Uint8Array.from({ length: CAPTURE_SHEET.mark.width * CAPTURE_SHEET.mark.height * 3 }, (_, index) => index % 3 === 0 ? CAPTURE_SHEET.mark.present : CAPTURE_SHEET.mark.absent)
|
|
5319
|
-
} : image.thumbnail,
|
|
5320
|
-
source: image === void 0 ? void 0 : {
|
|
5321
|
-
width: image.picture.width,
|
|
5322
|
-
height: image.picture.height,
|
|
5323
|
-
bytes: image.size
|
|
5324
|
-
},
|
|
5325
|
-
factor,
|
|
5326
|
-
clipped: image !== void 0 && Math.ceil(image.picture.height / factor) > CAPTURE_SHEET.limit,
|
|
5327
|
-
freshness: result.freshness.entries.find((candidate) => candidate.file === entry.file)
|
|
5328
|
-
};
|
|
5329
|
-
});
|
|
5330
5984
|
return {
|
|
5331
5985
|
identity,
|
|
5332
|
-
cells
|
|
5333
|
-
|
|
5986
|
+
cells: result.selection.entries.filter((entry) => resolveCaptureSheetIdentity(entry) === identity).map((entry) => {
|
|
5987
|
+
const image = result.images.find((candidate) => candidate.entry.file === entry.file);
|
|
5988
|
+
const factor = image === void 0 ? 1 : Math.max(1, Math.ceil(image.picture.width / CAPTURE_SHEET.cell));
|
|
5989
|
+
return {
|
|
5990
|
+
entry,
|
|
5991
|
+
picture: image === void 0 ? {
|
|
5992
|
+
width: CAPTURE_SHEET.mark.width,
|
|
5993
|
+
height: CAPTURE_SHEET.mark.height,
|
|
5994
|
+
pixels: Uint8Array.from({ length: CAPTURE_SHEET.mark.width * CAPTURE_SHEET.mark.height * 3 }, (_, index) => index % 3 === 0 ? CAPTURE_SHEET.mark.present : CAPTURE_SHEET.mark.absent)
|
|
5995
|
+
} : image.thumbnail,
|
|
5996
|
+
source: image === void 0 ? void 0 : {
|
|
5997
|
+
width: image.picture.width,
|
|
5998
|
+
height: image.picture.height,
|
|
5999
|
+
bytes: image.size
|
|
6000
|
+
},
|
|
6001
|
+
factor,
|
|
6002
|
+
clipped: image !== void 0 && Math.ceil(image.picture.height / factor) > CAPTURE_SHEET.limit,
|
|
6003
|
+
freshness: result.freshness.entries.find((candidate) => candidate.file === entry.file)
|
|
6004
|
+
};
|
|
6005
|
+
})
|
|
5334
6006
|
};
|
|
5335
6007
|
});
|
|
5336
6008
|
}
|
|
@@ -5584,6 +6256,6 @@ function createCaptureRegistrar(options) {
|
|
|
5584
6256
|
function createCaptureCLI(options = {}) {
|
|
5585
6257
|
return new CaptureCLI(options);
|
|
5586
6258
|
}
|
|
5587
|
-
export { CAPTURE_COMMAND_NAMES, CAPTURE_COMMAND_OPTIONS, CAPTURE_DEFAULTS, CAPTURE_DISCOVERY, CAPTURE_EXIT, CAPTURE_FLAG, CAPTURE_FLAG_VALUE, CAPTURE_MESSAGE_LIMIT, CAPTURE_MINIMUM_IMAGE, CAPTURE_OWNER_BACKOFF, CAPTURE_OWNER_FILE, CAPTURE_OWNER_TIMEOUT, CAPTURE_PID_LIMIT, CAPTURE_PNG_LIMITS, CAPTURE_PROGRESS_SUFFIX, CAPTURE_REFUSAL_LIMIT, CAPTURE_REGISTRY_LINE, CAPTURE_REGISTRY_STAGE, CAPTURE_REPORT_LINES, CAPTURE_REQUESTS_FLAG, CAPTURE_RUNS_DIRECTORY, CAPTURE_SHEET, CAPTURE_SHEET_FILES, CAPTURE_STAGES, CAPTURE_SUBCOMMANDS, CAPTURE_SURVIVORS_FILE, CAPTURE_TAG_OPERATORS, CAPTURE_USAGE, CAPTURE_VITEST_ENTRY, CAPTURE_WRAPPER_PREFIXES, CaptureCLI, CaptureDiscovery, CaptureIntegrity, CaptureInvocation, CapturePreflight, CaptureRegistrar, CaptureRunner, CaptureSheets, answerCaptureDiscovery, buildCaptureArguments, buildCaptureChangePlan, buildCaptureDigest, buildCaptureDiscoveryConfig, buildCaptureFilter, buildCaptureIntegrityOptions, buildCaptureLookupJournal, buildCaptureOverride, buildCaptureRegistry, buildCaptureRequestRefusal, buildCaptureWrapper, collectCaptureErrors, collectCaptureIdentical, composeCapturePictures, computeCaptureHash, computeCaptureMatchKey, computeRegistryDigest, createCaptureCLI, createCaptureDiscovery, createCaptureIntegrity, createCapturePreflight, createCaptureRegistrar, createCaptureRunner, createCaptureSheets, decodeCapturePicture, describeCaptureFault, describeCaptureHolders, describeCaptureMembers, describeCaptureOutput, describeCapturePortfolios, describeCaptureSelectorFault, encodeCaptureChunk, encodeCapturePicture, encodeCaptureWord, escapeCapturePattern, filterCaptureInputs, inflateCaptureStream, matchesCaptureFile, matchesCaptureSignature, matchesCaptureTransient, mergeCaptureLookups, normalizeSlashes, predictCaptureByte, readCaptureAncestor, readCaptureArguments, readCaptureChunks, readCaptureDescription, readCaptureEntry, readCaptureFrames, readCaptureImage, readCaptureInputs, readCaptureListing, readCaptureLookups, readCaptureOptions, readCapturePortfolios, readCaptureProgress, readCaptureProject, readCaptureReaderArguments, readCaptureRegistryArguments, readCaptureRequest, readCaptureRequestOwner, readCaptureSeparator, readCaptureTitles, readCaptureVariants, readCaptureViewport, renderCaptureCommand, renderCaptureProgress, requireCaptureArgument, requireCaptureContained, requireCaptureImageSize, requireCaptureProjects, requireCaptureSelection, resolveCaptureExit, resolveCapturePhysical, resolveCaptureRelative, resolveCaptureRequests, resolveCaptureSheetIdentity, resolveCaptureStages, resolveCaptureVariants, resolveCaptureWrapperProject, scanCaptureFrames, settleCaptureShutdown, shrinkCapturePicture, splitCapturePages, unfilterCaptureRow, writeCaptureDocument };
|
|
6259
|
+
export { CAPTURE_COMMAND_NAMES, CAPTURE_COMMAND_OPTIONS, CAPTURE_DEFAULTS, CAPTURE_DISCOVERY, CAPTURE_EXIT, CAPTURE_FLAG, CAPTURE_FLAG_VALUE, CAPTURE_MESSAGE_LIMIT, CAPTURE_MINIMUM_IMAGE, CAPTURE_OWNER_BACKOFF, CAPTURE_OWNER_FILE, CAPTURE_OWNER_TIMEOUT, CAPTURE_PID_LIMIT, CAPTURE_PNG_LIMITS, CAPTURE_PROGRESS_SUFFIX, CAPTURE_RECOVERIES, CAPTURE_REFUSAL_LIMIT, CAPTURE_REGISTRY_LINE, CAPTURE_REGISTRY_STAGE, CAPTURE_REPORT_LINES, CAPTURE_REQUESTS_FLAG, CAPTURE_RUNS_DIRECTORY, CAPTURE_SHEET, CAPTURE_SHEET_FILES, CAPTURE_STAGES, CAPTURE_STATUS_RECOVERIES, CAPTURE_SUBCOMMANDS, CAPTURE_SURVIVORS_FILE, CAPTURE_TAG_OPERATORS, CAPTURE_USAGE, CAPTURE_VITEST_ENTRY, CAPTURE_WRAPPER_PREFIXES, CaptureCLI, CaptureDiscovery, CaptureIntegrity, CaptureInvocation, CapturePreflight, CaptureRegistrar, CaptureRunner, CaptureSheets, answerCaptureDiscovery, buildCaptureArguments, buildCaptureChangePlan, buildCaptureDigest, buildCaptureDiscoveryConfig, buildCaptureFilter, buildCaptureIntegrityOptions, buildCaptureLookupJournal, buildCaptureManifestDocument, buildCaptureOverride, buildCaptureReaderReport, buildCaptureRegistry, buildCaptureRequestRefusal, buildCaptureTable, buildCaptureWrapper, collectCaptureErrors, collectCaptureIdentical, collectCaptureOwners, collectCaptureProducers, composeCapturePictures, computeCaptureComposite, computeCaptureHash, computeCaptureMatchKey, computeCaptureTableKey, computeRegistryDigest, createCaptureCLI, createCaptureDiscovery, createCaptureIntegrity, createCapturePreflight, createCaptureRegistrar, createCaptureRunner, createCaptureSheets, decodeCapturePicture, describeCaptureChunk, describeCaptureFault, describeCaptureHolders, describeCaptureMembers, describeCaptureOutput, describeCapturePortfolios, describeCaptureSelectorFault, encodeCaptureChunk, encodeCapturePicture, encodeCaptureWord, escapeCapturePattern, filterCaptureInputs, inflateCaptureStream, matchesCaptureFile, matchesCaptureLimits, matchesCaptureSignature, matchesCaptureTransient, matchesCaptureVersionRefusal, mergeCaptureLookups, normalizeSlashes, predictCaptureByte, readCaptureAncestor, readCaptureArguments, readCaptureChunks, readCaptureDescription, readCaptureEntry, readCaptureFrames, readCaptureImage, readCaptureInputs, readCaptureListing, readCaptureLookupJournal, readCaptureLookups, readCaptureManifest, readCaptureOptions, readCapturePortfolios, readCaptureProgress, readCaptureProject, readCaptureReaderArguments, readCaptureRegistryArguments, readCaptureRequest, readCaptureRequestOwner, readCaptureSeparator, readCaptureTable, readCaptureTitles, readCaptureVariants, readCaptureViewport, renderCaptureCommand, renderCaptureProgress, requireCaptureArgument, requireCaptureContained, requireCaptureImageSize, requireCaptureProducer, requireCaptureProjects, requireCaptureSelection, requireCaptureTableEntry, requireCaptureVersion, resolveCaptureExit, resolveCapturePhysical, resolveCaptureRegistryFault, resolveCaptureRelative, resolveCaptureRequests, resolveCaptureSheetIdentity, resolveCaptureStages, resolveCaptureStandalone, resolveCaptureVariants, resolveCaptureWrapperProject, scanCaptureChunks, scanCaptureFrames, settleCaptureShutdown, shrinkCapturePicture, splitCapturePages, splitCaptureSheets, sumCaptureBlock, sumCaptureRow, unfilterCaptureRow, writeCaptureDocument };
|
|
5588
6260
|
|
|
5589
6261
|
//# sourceMappingURL=index.js.map
|