astroshot 0.2.1

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.
Files changed (119) hide show
  1. package/README.md +87 -0
  2. package/bin/astroshot.mjs +71 -0
  3. package/node_modules/@archastro/astroshot/LICENSE +21 -0
  4. package/node_modules/@archastro/astroshot/README.md +96 -0
  5. package/node_modules/@archastro/astroshot/bin/astroshot.mjs +276 -0
  6. package/node_modules/@archastro/astroshot/bin/demo.mjs +275 -0
  7. package/node_modules/@archastro/astroshot/bin/doctor.mjs +492 -0
  8. package/node_modules/@archastro/astroshot/bin/mac-preferences.mjs +346 -0
  9. package/node_modules/@archastro/astroshot/bin/templates.mjs +186 -0
  10. package/node_modules/@archastro/astroshot/fixtures/demo/fixtures.json +42 -0
  11. package/node_modules/@archastro/astroshot/fixtures/demo/journey.png +0 -0
  12. package/node_modules/@archastro/astroshot/fixtures/demo/journey.webm +0 -0
  13. package/node_modules/@archastro/astroshot/fixtures/demo/next-steps.png +0 -0
  14. package/node_modules/@archastro/astroshot/fixtures/demo/welcome.png +0 -0
  15. package/node_modules/@archastro/astroshot/ink.d.ts +5 -0
  16. package/node_modules/@archastro/astroshot/ink.js +1 -0
  17. package/node_modules/@archastro/astroshot/package.json +79 -0
  18. package/node_modules/@archastro/astroshot/pty.d.ts +8 -0
  19. package/node_modules/@archastro/astroshot/pty.js +1 -0
  20. package/node_modules/@archastro/astroshot/react.d.ts +1 -0
  21. package/node_modules/@archastro/astroshot/react.js +1 -0
  22. package/node_modules/@archastro/astroshot/tui.d.ts +1 -0
  23. package/node_modules/@archastro/astroshot/tui.js +1 -0
  24. package/node_modules/@archastro/movie-harness/README.md +138 -0
  25. package/node_modules/@archastro/movie-harness/bin/astroshot-movie.mjs +5 -0
  26. package/node_modules/@archastro/movie-harness/dist/cli.d.ts +1 -0
  27. package/node_modules/@archastro/movie-harness/dist/cli.js +389 -0
  28. package/node_modules/@archastro/movie-harness/dist/encode.d.ts +14 -0
  29. package/node_modules/@archastro/movie-harness/dist/encode.js +184 -0
  30. package/node_modules/@archastro/movie-harness/dist/index.d.ts +14 -0
  31. package/node_modules/@archastro/movie-harness/dist/index.js +11 -0
  32. package/node_modules/@archastro/movie-harness/dist/paths.d.ts +9 -0
  33. package/node_modules/@archastro/movie-harness/dist/paths.js +57 -0
  34. package/node_modules/@archastro/movie-harness/dist/png.d.ts +8 -0
  35. package/node_modules/@archastro/movie-harness/dist/png.js +79 -0
  36. package/node_modules/@archastro/movie-harness/dist/session.d.ts +45 -0
  37. package/node_modules/@archastro/movie-harness/dist/session.js +170 -0
  38. package/node_modules/@archastro/movie-harness/dist/sink.d.ts +7 -0
  39. package/node_modules/@archastro/movie-harness/dist/sink.js +113 -0
  40. package/node_modules/@archastro/movie-harness/dist/source-help.d.ts +29 -0
  41. package/node_modules/@archastro/movie-harness/dist/source-help.js +222 -0
  42. package/node_modules/@archastro/movie-harness/dist/sources/browser.d.ts +7 -0
  43. package/node_modules/@archastro/movie-harness/dist/sources/browser.js +87 -0
  44. package/node_modules/@archastro/movie-harness/dist/sources/desktop-macos.d.ts +110 -0
  45. package/node_modules/@archastro/movie-harness/dist/sources/desktop-macos.js +505 -0
  46. package/node_modules/@archastro/movie-harness/dist/sources/frames-store.d.ts +19 -0
  47. package/node_modules/@archastro/movie-harness/dist/sources/frames-store.js +165 -0
  48. package/node_modules/@archastro/movie-harness/dist/sources/pty.d.ts +15 -0
  49. package/node_modules/@archastro/movie-harness/dist/sources/pty.js +330 -0
  50. package/node_modules/@archastro/movie-harness/dist/terminal-paint.d.ts +27 -0
  51. package/node_modules/@archastro/movie-harness/dist/terminal-paint.js +190 -0
  52. package/node_modules/@archastro/movie-harness/dist/types.d.ts +140 -0
  53. package/node_modules/@archastro/movie-harness/dist/types.js +1 -0
  54. package/node_modules/@archastro/movie-harness/native/macos/WindowTools.swift +164 -0
  55. package/node_modules/@archastro/movie-harness/package.json +67 -0
  56. package/node_modules/@archastro/react-shot/LICENSE +21 -0
  57. package/node_modules/@archastro/react-shot/README.md +181 -0
  58. package/node_modules/@archastro/react-shot/bin/react-shot.mjs +2 -0
  59. package/node_modules/@archastro/react-shot/dist/batch-paths.d.ts +4 -0
  60. package/node_modules/@archastro/react-shot/dist/batch-paths.d.ts.map +1 -0
  61. package/node_modules/@archastro/react-shot/dist/batch-paths.js +34 -0
  62. package/node_modules/@archastro/react-shot/dist/batch-paths.js.map +1 -0
  63. package/node_modules/@archastro/react-shot/dist/cli.d.ts +3 -0
  64. package/node_modules/@archastro/react-shot/dist/cli.d.ts.map +1 -0
  65. package/node_modules/@archastro/react-shot/dist/cli.js +217 -0
  66. package/node_modules/@archastro/react-shot/dist/cli.js.map +1 -0
  67. package/node_modules/@archastro/react-shot/dist/config.d.ts +5 -0
  68. package/node_modules/@archastro/react-shot/dist/config.d.ts.map +1 -0
  69. package/node_modules/@archastro/react-shot/dist/config.js +75 -0
  70. package/node_modules/@archastro/react-shot/dist/config.js.map +1 -0
  71. package/node_modules/@archastro/react-shot/dist/create-server.d.ts +13 -0
  72. package/node_modules/@archastro/react-shot/dist/create-server.d.ts.map +1 -0
  73. package/node_modules/@archastro/react-shot/dist/create-server.js +254 -0
  74. package/node_modules/@archastro/react-shot/dist/create-server.js.map +1 -0
  75. package/node_modules/@archastro/react-shot/dist/index.d.ts +4 -0
  76. package/node_modules/@archastro/react-shot/dist/index.d.ts.map +1 -0
  77. package/node_modules/@archastro/react-shot/dist/index.js +3 -0
  78. package/node_modules/@archastro/react-shot/dist/index.js.map +1 -0
  79. package/node_modules/@archastro/react-shot/dist/meta.d.ts +9 -0
  80. package/node_modules/@archastro/react-shot/dist/meta.d.ts.map +1 -0
  81. package/node_modules/@archastro/react-shot/dist/meta.js +23 -0
  82. package/node_modules/@archastro/react-shot/dist/meta.js.map +1 -0
  83. package/node_modules/@archastro/react-shot/dist/shot.d.ts +4 -0
  84. package/node_modules/@archastro/react-shot/dist/shot.d.ts.map +1 -0
  85. package/node_modules/@archastro/react-shot/dist/shot.js +259 -0
  86. package/node_modules/@archastro/react-shot/dist/shot.js.map +1 -0
  87. package/node_modules/@archastro/react-shot/dist/stubs.d.ts +6 -0
  88. package/node_modules/@archastro/react-shot/dist/stubs.d.ts.map +1 -0
  89. package/node_modules/@archastro/react-shot/dist/stubs.js +49 -0
  90. package/node_modules/@archastro/react-shot/dist/stubs.js.map +1 -0
  91. package/node_modules/@archastro/react-shot/dist/types.d.ts +79 -0
  92. package/node_modules/@archastro/react-shot/dist/types.d.ts.map +1 -0
  93. package/node_modules/@archastro/react-shot/dist/types.js +2 -0
  94. package/node_modules/@archastro/react-shot/dist/types.js.map +1 -0
  95. package/node_modules/@archastro/react-shot/host/index.html +22 -0
  96. package/node_modules/@archastro/react-shot/package.json +81 -0
  97. package/node_modules/@archastro/tui-shot/LICENSE +21 -0
  98. package/node_modules/@archastro/tui-shot/README.md +145 -0
  99. package/node_modules/@archastro/tui-shot/bin/tui-shot.mjs +23 -0
  100. package/node_modules/@archastro/tui-shot/dist/batch-paths.d.ts +3 -0
  101. package/node_modules/@archastro/tui-shot/dist/batch-paths.js +33 -0
  102. package/node_modules/@archastro/tui-shot/dist/cli.d.ts +2 -0
  103. package/node_modules/@archastro/tui-shot/dist/cli.js +224 -0
  104. package/node_modules/@archastro/tui-shot/dist/index.d.ts +3 -0
  105. package/node_modules/@archastro/tui-shot/dist/index.js +2 -0
  106. package/node_modules/@archastro/tui-shot/dist/pty-exit-wrapper.d.ts +1 -0
  107. package/node_modules/@archastro/tui-shot/dist/pty-exit-wrapper.js +50 -0
  108. package/node_modules/@archastro/tui-shot/dist/pty-shot.d.ts +2 -0
  109. package/node_modules/@archastro/tui-shot/dist/pty-shot.js +483 -0
  110. package/node_modules/@archastro/tui-shot/dist/render-ink.d.ts +10 -0
  111. package/node_modules/@archastro/tui-shot/dist/render-ink.js +87 -0
  112. package/node_modules/@archastro/tui-shot/dist/shot.d.ts +24 -0
  113. package/node_modules/@archastro/tui-shot/dist/shot.js +250 -0
  114. package/node_modules/@archastro/tui-shot/dist/terminal-html.d.ts +14 -0
  115. package/node_modules/@archastro/tui-shot/dist/terminal-html.js +144 -0
  116. package/node_modules/@archastro/tui-shot/dist/types.d.ts +81 -0
  117. package/node_modules/@archastro/tui-shot/dist/types.js +1 -0
  118. package/node_modules/@archastro/tui-shot/package.json +90 -0
  119. package/package.json +68 -0
@@ -0,0 +1,23 @@
1
+ const DIALOG_SELECTOR_RE = /role\s*=\s*["']?dialog["']?/i;
2
+ export function resolveShotMeta(nodeMeta, browserMeta, cli = {}) {
3
+ const merged = { ...nodeMeta, ...browserMeta };
4
+ const selector = merged.selector ?? "[data-react-shot-root]";
5
+ const looksLikeDialog = DIALOG_SELECTOR_RE.test(selector);
6
+ return {
7
+ ...merged,
8
+ width: cli.width ?? merged.width ?? 1280,
9
+ height: cli.height ?? merged.height ?? 800,
10
+ selector,
11
+ settleMs: merged.settleMs ?? 150,
12
+ fullPage: merged.fullPage ?? false,
13
+ stripOverlay: merged.stripOverlay ?? looksLikeDialog,
14
+ omitBackground: merged.omitBackground ??
15
+ Boolean(merged.stripOverlay ?? looksLikeDialog),
16
+ waitFor: merged.waitFor,
17
+ background: merged.background,
18
+ };
19
+ }
20
+ export function isDialogSelector(selector) {
21
+ return DIALOG_SELECTOR_RE.test(selector);
22
+ }
23
+ //# sourceMappingURL=meta.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"meta.js","sourceRoot":"","sources":["../src/meta.ts"],"names":[],"mappings":"AAKA,MAAM,kBAAkB,GAAG,8BAA8B,CAAC;AAE1D,MAAM,UAAU,eAAe,CAC7B,QAA2B,EAC3B,WAA8B,EAC9B,MAA2C,EAAE;IAc7C,MAAM,MAAM,GAAsB,EAAE,GAAG,QAAQ,EAAE,GAAG,WAAW,EAAE,CAAC;IAClE,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,IAAI,wBAAwB,CAAC;IAC7D,MAAM,eAAe,GAAG,kBAAkB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAE1D,OAAO;QACL,GAAG,MAAM;QACT,KAAK,EAAE,GAAG,CAAC,KAAK,IAAI,MAAM,CAAC,KAAK,IAAI,IAAI;QACxC,MAAM,EAAE,GAAG,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,IAAI,GAAG;QAC1C,QAAQ;QACR,QAAQ,EAAE,MAAM,CAAC,QAAQ,IAAI,GAAG;QAChC,QAAQ,EAAE,MAAM,CAAC,QAAQ,IAAI,KAAK;QAClC,YAAY,EAAE,MAAM,CAAC,YAAY,IAAI,eAAe;QACpD,cAAc,EACZ,MAAM,CAAC,cAAc;YACrB,OAAO,CAAC,MAAM,CAAC,YAAY,IAAI,eAAe,CAAC;QACjD,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,UAAU,EAAE,MAAM,CAAC,UAAU;KAC9B,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,QAAgB;IAC/C,OAAO,kBAAkB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AAC3C,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { ShotRequest } from "./types.js";
2
+ export declare function closeSharedBrowser(): Promise<void>;
3
+ export declare function takeShot(request: ShotRequest): Promise<string>;
4
+ //# sourceMappingURL=shot.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shot.d.ts","sourceRoot":"","sources":["../src/shot.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAoB,WAAW,EAAE,MAAM,YAAY,CAAC;AAiChE,wBAAgB,kBAAkB,IAAI,OAAO,CAAC,IAAI,CAAC,CAOlD;AA6QD,wBAAgB,QAAQ,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,CAO9D"}
@@ -0,0 +1,259 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ import { pathToFileURL } from "node:url";
4
+ import { chromium } from "playwright";
5
+ import { findConfigPath, loadConfig, resolvePackageRoot } from "./config.js";
6
+ import { startShotServer } from "./create-server.js";
7
+ import { resolveShotMeta } from "./meta.js";
8
+ let sharedBrowser = null;
9
+ let sharedBrowserHeaded = null;
10
+ let shotQueue = Promise.resolve();
11
+ async function getBrowser(headed) {
12
+ if (sharedBrowser?.isConnected() && sharedBrowserHeaded === headed) {
13
+ return sharedBrowser;
14
+ }
15
+ if (sharedBrowser)
16
+ await closeBrowserNow();
17
+ try {
18
+ sharedBrowser = await chromium.launch({ headless: !headed });
19
+ sharedBrowserHeaded = headed;
20
+ }
21
+ catch (error) {
22
+ const message = error instanceof Error ? error.message : String(error);
23
+ throw new Error(`Could not launch Chromium. Install it with "npx astroshot install-browser".\n${message}`);
24
+ }
25
+ return sharedBrowser;
26
+ }
27
+ async function closeBrowserNow() {
28
+ if (!sharedBrowser)
29
+ return;
30
+ try {
31
+ await sharedBrowser.close();
32
+ }
33
+ finally {
34
+ sharedBrowser = null;
35
+ sharedBrowserHeaded = null;
36
+ }
37
+ }
38
+ export function closeSharedBrowser() {
39
+ const close = shotQueue.then(closeBrowserNow);
40
+ shotQueue = close.then(() => undefined, () => undefined);
41
+ return close;
42
+ }
43
+ async function readFixtureMeta(fixturePath) {
44
+ try {
45
+ const url = `${pathToFileURL(path.resolve(fixturePath)).href}?reactShot=${Date.now()}`;
46
+ const module = await import(url);
47
+ const fixture = (module.default ?? module.fixture);
48
+ if (!fixture || typeof fixture !== "object")
49
+ return {};
50
+ const { width, height, selector, waitFor, settleMs, background, fullPage, stripOverlay, omitBackground, } = fixture;
51
+ return {
52
+ width,
53
+ height,
54
+ selector,
55
+ waitFor,
56
+ settleMs,
57
+ background,
58
+ fullPage,
59
+ stripOverlay,
60
+ omitBackground,
61
+ };
62
+ }
63
+ catch {
64
+ // TSX and application imports often cannot execute in Node. The browser
65
+ // reports the same metadata after Vite transforms the fixture.
66
+ return {};
67
+ }
68
+ }
69
+ async function takeIsolatedShot(request) {
70
+ const fixturePath = path.resolve(request.fixturePath);
71
+ if (!fs.existsSync(fixturePath)) {
72
+ throw new Error(`Fixture not found: ${fixturePath}`);
73
+ }
74
+ if (path.extname(request.outPath).toLowerCase() !== ".png") {
75
+ throw new Error(`Output must use a .png extension: ${request.outPath}`);
76
+ }
77
+ for (const [name, value] of [
78
+ ["width", request.width],
79
+ ["height", request.height],
80
+ ]) {
81
+ if (value !== undefined &&
82
+ (!Number.isInteger(value) || value < 1 || value > 10_000)) {
83
+ throw new Error(`${name} must be an integer between 1 and 10000`);
84
+ }
85
+ }
86
+ const configPath = request.configPath ?? findConfigPath(path.dirname(fixturePath));
87
+ const config = await loadConfig(configPath);
88
+ const packageRoot = resolvePackageRoot(fixturePath, request.root, config);
89
+ const nodeMeta = await readFixtureMeta(fixturePath);
90
+ let width = request.width ?? nodeMeta.width ?? 1280;
91
+ let height = request.height ?? nodeMeta.height ?? 800;
92
+ const outPath = path.resolve(request.outPath);
93
+ fs.mkdirSync(path.dirname(outPath), { recursive: true });
94
+ const { server, url } = await startShotServer({
95
+ fixturePath,
96
+ packageRoot,
97
+ config,
98
+ });
99
+ let page;
100
+ try {
101
+ const browser = await getBrowser(Boolean(request.headed));
102
+ page = await browser.newPage({
103
+ viewport: { width, height },
104
+ deviceScaleFactor: 1,
105
+ });
106
+ const pageErrors = [];
107
+ page.on("pageerror", (error) => pageErrors.push(String(error)));
108
+ page.on("console", (message) => {
109
+ if (message.type() === "error")
110
+ pageErrors.push(message.text());
111
+ });
112
+ await page.goto(url, { waitUntil: "domcontentloaded", timeout: 60_000 });
113
+ try {
114
+ await page.waitForFunction(() => window
115
+ .__REACT_SHOT_READY__ === true, undefined, { timeout: 45_000 });
116
+ }
117
+ catch (error) {
118
+ const bootError = await page
119
+ .evaluate(() => window
120
+ .__REACT_SHOT_ERROR__ ?? null)
121
+ .catch(() => null);
122
+ const body = await page.locator("body").innerText().catch(() => "");
123
+ throw new Error([
124
+ `Fixture page never became ready: ${error instanceof Error ? error.message : error}`,
125
+ bootError ? `Boot error: ${bootError}` : null,
126
+ pageErrors.length
127
+ ? `Browser errors:\n${[...new Set(pageErrors)].slice(0, 10).map((item) => ` - ${item}`).join("\n")}`
128
+ : null,
129
+ body ? `Rendered body:\n${body.slice(0, 800)}` : null,
130
+ ]
131
+ .filter(Boolean)
132
+ .join("\n"));
133
+ }
134
+ const bootError = await page.evaluate(() => window
135
+ .__REACT_SHOT_ERROR__ ?? null);
136
+ if (bootError)
137
+ throw new Error(`Fixture threw while mounting:\n${bootError}`);
138
+ const browserMeta = (await page.evaluate(() => window
139
+ .__REACT_SHOT_META__ ?? {}));
140
+ const meta = resolveShotMeta(nodeMeta, browserMeta, {
141
+ width: request.width,
142
+ height: request.height,
143
+ });
144
+ width = meta.width;
145
+ height = meta.height;
146
+ if (!Number.isInteger(width) ||
147
+ !Number.isInteger(height) ||
148
+ width < 1 ||
149
+ height < 1 ||
150
+ width > 10_000 ||
151
+ height > 10_000) {
152
+ throw new Error(`Fixture dimensions must be integers between 1 and 10000; received ${width}x${height}`);
153
+ }
154
+ const viewport = page.viewportSize();
155
+ if (viewport && (viewport.width !== width || viewport.height !== height)) {
156
+ await page.setViewportSize({ width, height });
157
+ }
158
+ if (meta.waitFor) {
159
+ if (meta.waitFor.startsWith("text=") || meta.waitFor.startsWith("text/")) {
160
+ const text = meta.waitFor.replace(/^text[=/]/, "");
161
+ await page.getByText(text, { exact: false }).first().waitFor({
162
+ state: "visible",
163
+ timeout: 15_000,
164
+ });
165
+ }
166
+ else {
167
+ await page.waitForSelector(meta.waitFor, {
168
+ state: "visible",
169
+ timeout: 15_000,
170
+ });
171
+ }
172
+ }
173
+ else {
174
+ await page.waitForSelector(meta.selector, {
175
+ state: "visible",
176
+ timeout: 15_000,
177
+ });
178
+ }
179
+ if (meta.settleMs > 0)
180
+ await page.waitForTimeout(meta.settleMs);
181
+ const seriousErrors = pageErrors.filter((error) => !/Download the React DevTools/i.test(error) &&
182
+ !/React does not recognize/i.test(error) &&
183
+ !/\[vite\]/i.test(error));
184
+ if (seriousErrors.length > 0) {
185
+ throw new Error(`Fixture rendered with browser errors:\n${[...new Set(seriousErrors)]
186
+ .slice(0, 8)
187
+ .map((error) => ` - ${error}`)
188
+ .join("\n")}`);
189
+ }
190
+ if (meta.stripOverlay) {
191
+ if ((await page.locator(meta.selector).count()) === 0) {
192
+ throw new Error(`stripOverlay is enabled but ${JSON.stringify(meta.selector)} matched nothing`);
193
+ }
194
+ await page.evaluate((selector) => {
195
+ const target = document.querySelector(selector);
196
+ if (!(target instanceof HTMLElement))
197
+ return;
198
+ const clone = target.cloneNode(true);
199
+ document.documentElement.style.cssText =
200
+ "background:transparent !important;";
201
+ document.body.replaceChildren();
202
+ document.body.style.cssText =
203
+ "margin:0;padding:0;background:transparent !important;display:block;width:fit-content;height:fit-content;";
204
+ for (const [property, value] of [
205
+ ["position", "relative"],
206
+ ["inset", "auto"],
207
+ ["transform", "none"],
208
+ ["margin", "0"],
209
+ ["max-height", "none"],
210
+ ["left", "auto"],
211
+ ["top", "auto"],
212
+ ["box-shadow", "none"],
213
+ ["filter", "none"],
214
+ ]) {
215
+ clone.style.setProperty(property, value, "important");
216
+ }
217
+ clone.setAttribute("data-react-shot-isolated", "true");
218
+ document.body.appendChild(clone);
219
+ }, meta.selector);
220
+ await page.waitForTimeout(80);
221
+ }
222
+ if (meta.fullPage) {
223
+ await page.screenshot({
224
+ path: outPath,
225
+ fullPage: true,
226
+ omitBackground: meta.omitBackground,
227
+ });
228
+ return outPath;
229
+ }
230
+ const target = page
231
+ .locator(meta.stripOverlay ? "[data-react-shot-isolated]" : meta.selector)
232
+ .first();
233
+ await target.waitFor({ state: "visible", timeout: 10_000 });
234
+ const box = await target.boundingBox();
235
+ if (!box || box.width < 2 || box.height < 2) {
236
+ throw new Error(`Screenshot target has an empty bounding box: ${meta.selector}`);
237
+ }
238
+ if (meta.stripOverlay &&
239
+ box.width >= width * 0.9 &&
240
+ box.height >= height * 0.9) {
241
+ throw new Error(`Overlay removal produced a viewport-sized target (${Math.round(box.width)}x${Math.round(box.height)}); check selector ${JSON.stringify(meta.selector)}`);
242
+ }
243
+ await target.screenshot({
244
+ path: outPath,
245
+ omitBackground: meta.omitBackground,
246
+ });
247
+ return outPath;
248
+ }
249
+ finally {
250
+ await page?.close();
251
+ await server.close();
252
+ }
253
+ }
254
+ export function takeShot(request) {
255
+ const shot = shotQueue.then(() => takeIsolatedShot(request));
256
+ shotQueue = shot.then(() => undefined, () => undefined);
257
+ return shot;
258
+ }
259
+ //# sourceMappingURL=shot.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shot.js","sourceRoot":"","sources":["../src/shot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,QAAQ,EAA2B,MAAM,YAAY,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAC7E,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAiB,MAAM,WAAW,CAAC;AAG3D,IAAI,aAAa,GAAmB,IAAI,CAAC;AACzC,IAAI,mBAAmB,GAAmB,IAAI,CAAC;AAC/C,IAAI,SAAS,GAAkB,OAAO,CAAC,OAAO,EAAE,CAAC;AAEjD,KAAK,UAAU,UAAU,CAAC,MAAe;IACvC,IAAI,aAAa,EAAE,WAAW,EAAE,IAAI,mBAAmB,KAAK,MAAM,EAAE,CAAC;QACnE,OAAO,aAAa,CAAC;IACvB,CAAC;IACD,IAAI,aAAa;QAAE,MAAM,eAAe,EAAE,CAAC;IAC3C,IAAI,CAAC;QACH,aAAa,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC;QAC7D,mBAAmB,GAAG,MAAM,CAAC;IAC/B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,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Q,EAAE,CAChE,CAAC;QACJ,CAAC;QACD,IACE,IAAI,CAAC,YAAY;YACjB,GAAG,CAAC,KAAK,IAAI,KAAK,GAAG,GAAG;YACxB,GAAG,CAAC,MAAM,IAAI,MAAM,GAAG,GAAG,EAC1B,CAAC;YACD,MAAM,IAAI,KAAK,CACb,qDAAqD,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,qBAAqB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CACzJ,CAAC;QACJ,CAAC;QAED,MAAM,MAAM,CAAC,UAAU,CAAC;YACtB,IAAI,EAAE,OAAO;YACb,cAAc,EAAE,IAAI,CAAC,cAAc;SACpC,CAAC,CAAC;QACH,OAAO,OAAO,CAAC;IACjB,CAAC;YAAS,CAAC;QACT,MAAM,IAAI,EAAE,KAAK,EAAE,CAAC;QACpB,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;IACvB,CAAC;AACH,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,OAAoB;IAC3C,MAAM,IAAI,GAAG,SAAS,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC;IAC7D,SAAS,GAAG,IAAI,CAAC,IAAI,CACnB,GAAG,EAAE,CAAC,SAAS,EACf,GAAG,EAAE,CAAC,SAAS,CAChB,CAAC;IACF,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,6 @@
1
+ export declare const nextNavigationStub = "\nexport function useRouter() {\n return {\n push() {}, replace() {}, prefetch() {}, back() {},\n forward() {}, refresh() {},\n };\n}\nexport function usePathname() { return \"/\"; }\nexport function useSearchParams() { return new URLSearchParams(); }\nexport function useParams() { return {}; }\nexport function redirect() {}\nexport function notFound() {}\n";
2
+ export declare const nextLinkStub = "\nimport React from \"react\";\nexport default function Link({ href, children, ...rest }) {\n return React.createElement(\"a\", { href: typeof href === \"string\" ? href : \"#\", ...rest }, children);\n}\n";
3
+ export declare const nextImageStub = "\nimport React from \"react\";\nexport default function Image({ src, alt, width, height, ...rest }) {\n return React.createElement(\"img\", {\n src: typeof src === \"string\" ? src : \"\",\n alt: alt || \"\",\n width,\n height,\n ...rest,\n });\n}\n";
4
+ export declare const serverOnlyStub = "export {};";
5
+ export declare const nextDynamicStub = "\nimport React from \"react\";\nexport default function dynamic(loader, options) {\n const Lazy = React.lazy(loader);\n const fallback = options && options.loading\n ? React.createElement(options.loading)\n : null;\n return function DynamicComponent(props) {\n return React.createElement(\n React.Suspense,\n { fallback },\n React.createElement(Lazy, props),\n );\n };\n}\n";
6
+ //# sourceMappingURL=stubs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stubs.d.ts","sourceRoot":"","sources":["../src/stubs.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,kBAAkB,oXAY9B,CAAC;AAEF,eAAO,MAAM,YAAY,mNAKxB,CAAC;AAEF,eAAO,MAAM,aAAa,+QAWzB,CAAC;AAEF,eAAO,MAAM,cAAc,eAAe,CAAC;AAE3C,eAAO,MAAM,eAAe,yZAe3B,CAAC"}
@@ -0,0 +1,49 @@
1
+ export const nextNavigationStub = `
2
+ export function useRouter() {
3
+ return {
4
+ push() {}, replace() {}, prefetch() {}, back() {},
5
+ forward() {}, refresh() {},
6
+ };
7
+ }
8
+ export function usePathname() { return "/"; }
9
+ export function useSearchParams() { return new URLSearchParams(); }
10
+ export function useParams() { return {}; }
11
+ export function redirect() {}
12
+ export function notFound() {}
13
+ `;
14
+ export const nextLinkStub = `
15
+ import React from "react";
16
+ export default function Link({ href, children, ...rest }) {
17
+ return React.createElement("a", { href: typeof href === "string" ? href : "#", ...rest }, children);
18
+ }
19
+ `;
20
+ export const nextImageStub = `
21
+ import React from "react";
22
+ export default function Image({ src, alt, width, height, ...rest }) {
23
+ return React.createElement("img", {
24
+ src: typeof src === "string" ? src : "",
25
+ alt: alt || "",
26
+ width,
27
+ height,
28
+ ...rest,
29
+ });
30
+ }
31
+ `;
32
+ export const serverOnlyStub = `export {};`;
33
+ export const nextDynamicStub = `
34
+ import React from "react";
35
+ export default function dynamic(loader, options) {
36
+ const Lazy = React.lazy(loader);
37
+ const fallback = options && options.loading
38
+ ? React.createElement(options.loading)
39
+ : null;
40
+ return function DynamicComponent(props) {
41
+ return React.createElement(
42
+ React.Suspense,
43
+ { fallback },
44
+ React.createElement(Lazy, props),
45
+ );
46
+ };
47
+ }
48
+ `;
49
+ //# sourceMappingURL=stubs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stubs.js","sourceRoot":"","sources":["../src/stubs.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,kBAAkB,GAAG;;;;;;;;;;;;CAYjC,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAG;;;;;CAK3B,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAG;;;;;;;;;;;CAW5B,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG,YAAY,CAAC;AAE3C,MAAM,CAAC,MAAM,eAAe,GAAG;;;;;;;;;;;;;;;CAe9B,CAAC"}
@@ -0,0 +1,79 @@
1
+ import type { ReactNode } from "react";
2
+ /**
3
+ * Default export shape for a react-shot fixture module.
4
+ *
5
+ * @example
6
+ * ```tsx
7
+ * export default {
8
+ * width: 720,
9
+ * height: 900,
10
+ * background: "#faf9f6",
11
+ * component: <MyModal />,
12
+ * } satisfies ReactShotFixture;
13
+ * ```
14
+ */
15
+ export interface ReactShotFixture {
16
+ /** React tree to mount. */
17
+ component: ReactNode;
18
+ /** Viewport width in CSS pixels. Defaults to 1280. */
19
+ width?: number;
20
+ /** Viewport height in CSS pixels. Defaults to 800. */
21
+ height?: number;
22
+ /** Page or canvas background. Defaults to transparent. */
23
+ background?: string;
24
+ /** CSS selector to capture. Defaults to `[data-react-shot-root]`. */
25
+ selector?: string;
26
+ /** Optional selector or `text=...` value that must become visible. */
27
+ waitFor?: string;
28
+ /** Additional layout settling time in milliseconds. Defaults to 150. */
29
+ settleMs?: number;
30
+ /** Capture the full page instead of the selected element. */
31
+ fullPage?: boolean;
32
+ /**
33
+ * Remove a full-screen overlay around the target before capture.
34
+ * Defaults to true when `selector` targets a dialog.
35
+ */
36
+ stripOverlay?: boolean;
37
+ /**
38
+ * Preserve transparency in the PNG. Defaults to true for isolated dialogs.
39
+ */
40
+ omitBackground?: boolean;
41
+ }
42
+ /** Package-level config exported from `react-shot.config.*`. */
43
+ export interface ReactShotConfig {
44
+ /** Package root used for module resolution. Relative paths are config-relative. */
45
+ root?: string;
46
+ /** Vite aliases, such as `@` to an application's source directory. */
47
+ alias?: Record<string, string>;
48
+ /** CSS files imported into every fixture host page. */
49
+ styles?: string[];
50
+ /** Path to a PostCSS config file. */
51
+ postcssConfig?: string;
52
+ /** Additional dependencies Vite should deduplicate. */
53
+ dedupe?: string[];
54
+ /** Module names that should resolve to an empty browser-safe stub. */
55
+ stubModules?: string[];
56
+ }
57
+ export interface ShotRequest {
58
+ fixturePath: string;
59
+ outPath: string;
60
+ root?: string;
61
+ configPath?: string;
62
+ headed?: boolean;
63
+ width?: number;
64
+ height?: number;
65
+ }
66
+ export interface BatchEntry {
67
+ fixture: string;
68
+ out: string;
69
+ root?: string;
70
+ config?: string;
71
+ width?: number;
72
+ height?: number;
73
+ }
74
+ export interface BatchManifest {
75
+ root?: string;
76
+ config?: string;
77
+ shots: BatchEntry[];
78
+ }
79
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,gBAAgB;IAC/B,2BAA2B;IAC3B,SAAS,EAAE,SAAS,CAAC;IACrB,sDAAsD;IACtD,KAAK,CAAC,EAAE,MA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M,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,UAAU,EAAE,CAAC;CACrB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,22 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>react-shot</title>
7
+ <style>
8
+ html,
9
+ body {
10
+ margin: 0;
11
+ padding: 0;
12
+ }
13
+ #root {
14
+ min-height: 100vh;
15
+ }
16
+ </style>
17
+ </head>
18
+ <body>
19
+ <div id="root"></div>
20
+ <script type="module" src="/@react-shot/entry.tsx"></script>
21
+ </body>
22
+ </html>
@@ -0,0 +1,81 @@
1
+ {
2
+ "name": "@archastro/react-shot",
3
+ "version": "0.2.1",
4
+ "description": "Capture deterministic PNG screenshots from React and TSX fixtures",
5
+ "keywords": [
6
+ "react",
7
+ "screenshot",
8
+ "playwright",
9
+ "tsx",
10
+ "visual-testing"
11
+ ],
12
+ "homepage": "https://github.com/ArchAstro/astroshots#readme",
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "git+https://github.com/ArchAstro/astroshots.git",
16
+ "directory": "packages/react-shot"
17
+ },
18
+ "bugs": {
19
+ "url": "https://github.com/ArchAstro/astroshots/issues"
20
+ },
21
+ "license": "MIT",
22
+ "type": "module",
23
+ "main": "./dist/index.js",
24
+ "types": "./dist/index.d.ts",
25
+ "exports": {
26
+ ".": {
27
+ "types": "./dist/index.d.ts",
28
+ "import": "./dist/index.js"
29
+ },
30
+ "./types": {
31
+ "types": "./dist/types.d.ts",
32
+ "import": "./dist/types.js"
33
+ }
34
+ },
35
+ "bin": {
36
+ "react-shot": "bin/react-shot.mjs"
37
+ },
38
+ "files": [
39
+ "bin",
40
+ "dist",
41
+ "host",
42
+ "README.md"
43
+ ],
44
+ "engines": {
45
+ "node": ">=22.14.0"
46
+ },
47
+ "publishConfig": {
48
+ "access": "public",
49
+ "provenance": true,
50
+ "registry": "https://registry.npmjs.org/"
51
+ },
52
+ "scripts": {
53
+ "build": "tsc -p tsconfig.build.json",
54
+ "clean": "node -e \"require('node:fs').rmSync('dist', { recursive: true, force: true })\"",
55
+ "test": "npm run build && vitest run",
56
+ "test:unit": "vitest run src/meta.test.ts",
57
+ "test:e2e": "npm run build && vitest run src/cli.e2e.test.ts",
58
+ "typecheck": "tsc -p tsconfig.json --noEmit",
59
+ "prepack": "npm run clean && npm run build"
60
+ },
61
+ "dependencies": {
62
+ "@vitejs/plugin-react": "^5.2.0",
63
+ "playwright": "1.61.1",
64
+ "tsx": "^4.19.0",
65
+ "vite": "^6.2.0",
66
+ "yaml": "^2.7.0"
67
+ },
68
+ "peerDependencies": {
69
+ "react": ">=18",
70
+ "react-dom": ">=18"
71
+ },
72
+ "devDependencies": {
73
+ "@types/node": "^22.0.0",
74
+ "@types/react": "^19.0.0",
75
+ "@types/react-dom": "^19.0.0",
76
+ "react": "^19.0.0",
77
+ "react-dom": "^19.0.0",
78
+ "typescript": "^5.0.0",
79
+ "vitest": "^4.1.9"
80
+ }
81
+ }
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ArchAstro
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.