@reshotdev/screenshot 0.0.1-beta.12 → 0.0.1-beta.14
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 +67 -22
- package/package.json +18 -14
- package/src/commands/auth.js +37 -7
- package/src/commands/capture-dom.js +50 -0
- package/src/commands/compose.js +220 -0
- package/src/commands/doctor-release.js +7 -0
- package/src/commands/doctor-target.js +36 -4
- package/src/commands/drifts.js +13 -1
- package/src/commands/publish.js +183 -21
- package/src/commands/pull.js +9 -4
- package/src/commands/refresh.js +166 -0
- package/src/commands/setup-wizard.js +57 -3
- package/src/commands/status.js +22 -2
- package/src/commands/variation.js +194 -0
- package/src/index.js +190 -10
- package/src/lib/api-client.js +61 -35
- package/src/lib/auto-update/refresh.js +598 -0
- package/src/lib/auto-update/scene-runtime.compose.tsx +73 -0
- package/src/lib/auto-update/spec.js +89 -0
- package/src/lib/capture-engine.js +76 -2
- package/src/lib/capture-script-runner.js +289 -138
- package/src/lib/certification.js +23 -1
- package/src/lib/compose-context.js +156 -0
- package/src/lib/compose-pack.js +42 -0
- package/src/lib/compose-runtime.js +34 -0
- package/src/lib/compose-upload.js +142 -0
- package/src/lib/config.js +2 -2
- package/src/lib/dom-capture.js +64 -0
- package/src/lib/ensure-browser.js +147 -0
- package/src/lib/record-clip.js +83 -3
- package/src/lib/record-config.js +0 -4
- package/src/lib/release-doctor.js +11 -3
- package/src/lib/resolve-targets.js +60 -0
- package/src/lib/run-manifest.js +45 -0
- package/src/lib/ui-api-helpers.js +118 -0
- package/src/lib/ui-api.js +28 -820
- package/src/lib/ui-asset-cleanup.js +62 -0
- package/src/lib/ui-output-versions.js +165 -0
- package/src/lib/ui-recorder-routes.js +341 -0
- package/src/lib/ui-scenario-metadata.js +161 -0
- package/vendor/compose/dist/auto-update.cjs +5544 -0
- package/vendor/compose/dist/auto-update.mjs +5518 -0
- package/vendor/compose/dist/capture.cjs +1450 -0
- package/vendor/compose/dist/capture.mjs +1416 -0
- package/vendor/compose/dist/eligibility.cjs +5331 -0
- package/vendor/compose/dist/eligibility.mjs +5313 -0
- package/vendor/compose/dist/index.cjs +2046 -0
- package/vendor/compose/dist/index.mjs +1997 -0
- package/vendor/compose/dist/jsx-dev-runtime.cjs +55 -0
- package/vendor/compose/dist/jsx-dev-runtime.mjs +27 -0
- package/vendor/compose/dist/jsx-runtime.cjs +58 -0
- package/vendor/compose/dist/jsx-runtime.mjs +31 -0
- package/vendor/compose/dist/render.cjs +558 -0
- package/vendor/compose/dist/render.mjs +515 -0
- package/vendor/compose/dist/verify-cli.cjs +3806 -0
- package/vendor/compose/dist/verify-cli.mjs +3812 -0
- package/vendor/compose/dist/verify.cjs +3880 -0
- package/vendor/compose/dist/verify.mjs +3858 -0
- package/web/manager/dist/assets/{index-CvleJUur.js → index-D0S2otug.js} +56 -56
- package/web/manager/dist/index.html +1 -1
- package/src/commands/ingest.js +0 -458
- package/src/commands/setup.js +0 -165
- package/src/lib/playwright-runner.js +0 -252
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
const fs = require("fs-extra");
|
|
2
|
+
const path = require("path");
|
|
3
|
+
|
|
4
|
+
const TIMESTAMP_DIR_PATTERN = /^\d{4}-\d{2}-\d{2}_\d{2}-\d{2}-\d{2}$/;
|
|
5
|
+
const ASSET_EXTENSIONS = new Set([".png", ".jpg", ".mp4", ".webm"]);
|
|
6
|
+
|
|
7
|
+
function parseTimestampDirName(name) {
|
|
8
|
+
if (!TIMESTAMP_DIR_PATTERN.test(name)) {
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const [date, time] = name.split("_");
|
|
13
|
+
const [year, month, day] = date.split("-");
|
|
14
|
+
const [hour, min, sec] = time.split("-");
|
|
15
|
+
const parsed = new Date(`${year}-${month}-${day}T${hour}:${min}:${sec}`);
|
|
16
|
+
|
|
17
|
+
return Number.isNaN(parsed.getTime()) ? null : parsed;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function countAssetsInLatestDir(latestDir) {
|
|
21
|
+
if (!fs.existsSync(latestDir)) {
|
|
22
|
+
return 0;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
try {
|
|
26
|
+
return fs
|
|
27
|
+
.readdirSync(latestDir)
|
|
28
|
+
.filter((file) => ASSET_EXTENSIONS.has(path.extname(file).toLowerCase()))
|
|
29
|
+
.length;
|
|
30
|
+
} catch {
|
|
31
|
+
return 0;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function readScenarioOutputMetadata(outputBaseDir, scenarioKey) {
|
|
36
|
+
const scenarioOutputDir = path.join(outputBaseDir, scenarioKey);
|
|
37
|
+
const metadata = {
|
|
38
|
+
createdAt: null,
|
|
39
|
+
lastRunAt: null,
|
|
40
|
+
assetCount: 0,
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
if (!fs.existsSync(scenarioOutputDir)) {
|
|
44
|
+
return metadata;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
try {
|
|
48
|
+
const timestamps = fs
|
|
49
|
+
.readdirSync(scenarioOutputDir)
|
|
50
|
+
.filter((item) => {
|
|
51
|
+
const fullPath = path.join(scenarioOutputDir, item);
|
|
52
|
+
try {
|
|
53
|
+
return fs.statSync(fullPath).isDirectory() && item !== "latest";
|
|
54
|
+
} catch {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
})
|
|
58
|
+
.map(parseTimestampDirName)
|
|
59
|
+
.filter(Boolean)
|
|
60
|
+
.sort((a, b) => a.getTime() - b.getTime());
|
|
61
|
+
|
|
62
|
+
if (timestamps.length > 0) {
|
|
63
|
+
metadata.createdAt = timestamps[0].toISOString();
|
|
64
|
+
metadata.lastRunAt = timestamps[timestamps.length - 1].toISOString();
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
metadata.assetCount = countAssetsInLatestDir(
|
|
68
|
+
path.join(scenarioOutputDir, "latest"),
|
|
69
|
+
);
|
|
70
|
+
} catch {
|
|
71
|
+
return metadata;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return metadata;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function findScenarioRunJobs(jobs, scenarioKey) {
|
|
78
|
+
return jobs
|
|
79
|
+
.filter((job) => {
|
|
80
|
+
if (job.type !== "run") {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const keys = job.params?.scenarioKeys || [];
|
|
85
|
+
return keys.includes(scenarioKey);
|
|
86
|
+
})
|
|
87
|
+
.sort(
|
|
88
|
+
(a, b) =>
|
|
89
|
+
new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime(),
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function mergeJobMetadata(metadata, jobs) {
|
|
94
|
+
if (jobs.length === 0) {
|
|
95
|
+
return { ...metadata, lastRunStatus: null };
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const latestJob = jobs[0];
|
|
99
|
+
const latestJobTime = latestJob.completedAt || latestJob.createdAt;
|
|
100
|
+
let lastRunAt = metadata.lastRunAt;
|
|
101
|
+
let lastRunStatus = null;
|
|
102
|
+
|
|
103
|
+
if (latestJobTime) {
|
|
104
|
+
const jobTime = new Date(latestJobTime).toISOString();
|
|
105
|
+
if (!lastRunAt || jobTime > lastRunAt) {
|
|
106
|
+
lastRunAt = jobTime;
|
|
107
|
+
lastRunStatus = latestJob.status;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const earliestJob = jobs[jobs.length - 1];
|
|
112
|
+
const createdAt =
|
|
113
|
+
earliestJob.createdAt &&
|
|
114
|
+
(!metadata.createdAt || earliestJob.createdAt < metadata.createdAt)
|
|
115
|
+
? earliestJob.createdAt
|
|
116
|
+
: metadata.createdAt;
|
|
117
|
+
|
|
118
|
+
return {
|
|
119
|
+
...metadata,
|
|
120
|
+
createdAt,
|
|
121
|
+
lastRunAt,
|
|
122
|
+
lastRunStatus,
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function addScenarioMetadata(scenarios, jobs, outputBaseDir) {
|
|
127
|
+
return scenarios
|
|
128
|
+
.map((scenario) => {
|
|
129
|
+
const outputMetadata = readScenarioOutputMetadata(
|
|
130
|
+
outputBaseDir,
|
|
131
|
+
scenario.key,
|
|
132
|
+
);
|
|
133
|
+
const scenarioJobs = findScenarioRunJobs(jobs, scenario.key);
|
|
134
|
+
|
|
135
|
+
return {
|
|
136
|
+
...scenario,
|
|
137
|
+
_metadata: mergeJobMetadata(outputMetadata, scenarioJobs),
|
|
138
|
+
};
|
|
139
|
+
})
|
|
140
|
+
.sort((a, b) => {
|
|
141
|
+
const aTime = a._metadata?.lastRunAt
|
|
142
|
+
? new Date(a._metadata.lastRunAt).getTime()
|
|
143
|
+
: 0;
|
|
144
|
+
const bTime = b._metadata?.lastRunAt
|
|
145
|
+
? new Date(b._metadata.lastRunAt).getTime()
|
|
146
|
+
: 0;
|
|
147
|
+
|
|
148
|
+
if (aTime !== bTime) {
|
|
149
|
+
return bTime - aTime;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
return a.name.localeCompare(b.name);
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
module.exports = {
|
|
157
|
+
addScenarioMetadata,
|
|
158
|
+
countAssetsInLatestDir,
|
|
159
|
+
parseTimestampDirName,
|
|
160
|
+
readScenarioOutputMetadata,
|
|
161
|
+
};
|