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,217 @@
1
+ #!/usr/bin/env node
2
+ import { spawnSync } from "node:child_process";
3
+ import fs from "node:fs";
4
+ import { createRequire } from "node:module";
5
+ import path from "node:path";
6
+ import { fileURLToPath } from "node:url";
7
+ import YAML from "yaml";
8
+ import { resolveBatchOutputPaths } from "./batch-paths.js";
9
+ import { closeSharedBrowser, takeShot } from "./shot.js";
10
+ function packageVersion() {
11
+ const here = path.dirname(fileURLToPath(import.meta.url));
12
+ const packagePath = path.resolve(here, "../package.json");
13
+ const parsed = JSON.parse(fs.readFileSync(packagePath, "utf8"));
14
+ return parsed.version ?? "unknown";
15
+ }
16
+ function printHelp() {
17
+ console.log(`react-shot - deterministic React component screenshots
18
+
19
+ Usage:
20
+ react-shot shot <fixture.tsx> -o <out.png> [options]
21
+ react-shot batch <manifest.yaml|json> [options]
22
+ react-shot <fixture.tsx> -o <out.png> [options]
23
+ react-shot install-browser [--with-deps]
24
+
25
+ Options:
26
+ -o, --out <path> Output PNG path
27
+ --root <dir> Package root for imports and aliases
28
+ --config <path> Config path; otherwise discovered from the fixture
29
+ --width <px> Override viewport width
30
+ --height <px> Override viewport height
31
+ --headed Show Chromium for debugging
32
+ --with-deps Install Chromium OS dependencies too
33
+ -v, --version Print the installed version
34
+ -h, --help Show this help
35
+
36
+ Run "react-shot install-browser" once before the first capture.
37
+ `);
38
+ }
39
+ function requiredValue(args, flag) {
40
+ const value = args.shift();
41
+ if (!value || value.startsWith("-")) {
42
+ throw new Error(`${flag} requires a value`);
43
+ }
44
+ return value;
45
+ }
46
+ function parseArgs(argv) {
47
+ const args = [...argv];
48
+ const flags = {};
49
+ const positionals = [];
50
+ while (args.length > 0) {
51
+ const argument = args.shift();
52
+ if (argument === "-h" || argument === "--help")
53
+ flags.help = true;
54
+ else if (argument === "-v" || argument === "--version")
55
+ flags.version = true;
56
+ else if (argument === "--headed")
57
+ flags.headed = true;
58
+ else if (argument === "--with-deps")
59
+ flags.withDeps = true;
60
+ else if (argument === "-o" || argument === "--out") {
61
+ flags.out = requiredValue(args, argument);
62
+ }
63
+ else if (argument === "--root") {
64
+ flags.root = requiredValue(args, argument);
65
+ }
66
+ else if (argument === "--config") {
67
+ flags.config = requiredValue(args, argument);
68
+ }
69
+ else if (argument === "--width") {
70
+ flags.width = requiredValue(args, argument);
71
+ }
72
+ else if (argument === "--height") {
73
+ flags.height = requiredValue(args, argument);
74
+ }
75
+ else if (argument.startsWith("-")) {
76
+ throw new Error(`Unknown option: ${argument}`);
77
+ }
78
+ else {
79
+ positionals.push(argument);
80
+ }
81
+ }
82
+ return { flags, positionals };
83
+ }
84
+ function dimension(flags, name) {
85
+ const raw = flags[name];
86
+ if (raw === undefined)
87
+ return undefined;
88
+ const value = Number(raw);
89
+ if (!Number.isInteger(value) || value < 1 || value > 10_000) {
90
+ throw new Error(`--${name} must be an integer between 1 and 10000`);
91
+ }
92
+ return value;
93
+ }
94
+ async function captureFixture(fixture, flags) {
95
+ const output = flags.out;
96
+ if (typeof output !== "string") {
97
+ throw new Error("A screenshot requires -o <out.png>");
98
+ }
99
+ const outPath = await takeShot({
100
+ fixturePath: fixture,
101
+ outPath: output,
102
+ root: typeof flags.root === "string" ? flags.root : undefined,
103
+ configPath: typeof flags.config === "string" ? flags.config : undefined,
104
+ headed: Boolean(flags.headed),
105
+ width: dimension(flags, "width"),
106
+ height: dimension(flags, "height"),
107
+ });
108
+ console.log(`wrote ${outPath}`);
109
+ }
110
+ function manifestRelative(baseDirectory, value) {
111
+ return value ? path.resolve(baseDirectory, value) : undefined;
112
+ }
113
+ async function captureBatch(manifestPath, flags) {
114
+ const absoluteManifest = path.resolve(manifestPath);
115
+ const raw = fs.readFileSync(absoluteManifest, "utf8");
116
+ const manifest = (absoluteManifest.endsWith(".json") ? JSON.parse(raw) : YAML.parse(raw));
117
+ if (!Array.isArray(manifest?.shots) || manifest.shots.length === 0) {
118
+ throw new Error(`No shots listed in ${absoluteManifest}`);
119
+ }
120
+ const baseDirectory = path.dirname(absoluteManifest);
121
+ for (const entry of manifest.shots) {
122
+ if (!entry.fixture || !entry.out) {
123
+ throw new Error("Each batch entry requires fixture and out");
124
+ }
125
+ }
126
+ const outPaths = resolveBatchOutputPaths(manifest.shots, baseDirectory);
127
+ const cliWidth = dimension(flags, "width");
128
+ const cliHeight = dimension(flags, "height");
129
+ let completed = 0;
130
+ for (const [index, entry] of manifest.shots.entries()) {
131
+ const fixturePath = path.resolve(baseDirectory, entry.fixture);
132
+ const outPath = outPaths[index];
133
+ const root = typeof flags.root === "string"
134
+ ? path.resolve(flags.root)
135
+ : manifestRelative(baseDirectory, entry.root ?? manifest.root);
136
+ const configPath = typeof flags.config === "string"
137
+ ? path.resolve(flags.config)
138
+ : manifestRelative(baseDirectory, entry.config ?? manifest.config);
139
+ process.stdout.write(`shot ${path.relative(process.cwd(), fixturePath)} ... `);
140
+ await takeShot({
141
+ fixturePath,
142
+ outPath,
143
+ root,
144
+ configPath,
145
+ headed: Boolean(flags.headed),
146
+ width: cliWidth ?? entry.width,
147
+ height: cliHeight ?? entry.height,
148
+ });
149
+ completed += 1;
150
+ console.log(`wrote ${path.relative(process.cwd(), outPath)}`);
151
+ }
152
+ console.log(`done: ${completed}/${manifest.shots.length} shots`);
153
+ }
154
+ function installBrowser(flags) {
155
+ const require = createRequire(import.meta.url);
156
+ const packagePath = require.resolve("playwright/package.json");
157
+ const cliPath = path.join(path.dirname(packagePath), "cli.js");
158
+ const arguments_ = ["install"];
159
+ if (flags.withDeps)
160
+ arguments_.push("--with-deps");
161
+ arguments_.push("chromium");
162
+ const result = spawnSync(process.execPath, [cliPath, ...arguments_], {
163
+ stdio: "inherit",
164
+ });
165
+ if (result.error) {
166
+ throw new Error(`Could not start Playwright installer: ${result.error.message}`);
167
+ }
168
+ if (result.status !== 0) {
169
+ throw new Error(`Playwright browser installation failed with exit code ${result.status ?? "unknown"}`);
170
+ }
171
+ }
172
+ async function main() {
173
+ const argv = process.argv.slice(2);
174
+ if (argv.length === 0) {
175
+ printHelp();
176
+ process.exitCode = 1;
177
+ return;
178
+ }
179
+ const { flags, positionals } = parseArgs(argv);
180
+ if (flags.version) {
181
+ console.log(packageVersion());
182
+ return;
183
+ }
184
+ if (flags.help || positionals[0] === "help") {
185
+ printHelp();
186
+ return;
187
+ }
188
+ try {
189
+ if (positionals[0] === "install-browser") {
190
+ installBrowser(flags);
191
+ }
192
+ else if (positionals[0] === "shot") {
193
+ if (!positionals[1])
194
+ throw new Error("shot requires a fixture path");
195
+ await captureFixture(positionals[1], flags);
196
+ }
197
+ else if (positionals[0] === "batch") {
198
+ if (!positionals[1])
199
+ throw new Error("batch requires a manifest path");
200
+ await captureBatch(positionals[1], flags);
201
+ }
202
+ else if (/\.[cm]?tsx?$/.test(positionals[0] ?? "")) {
203
+ await captureFixture(positionals[0], flags);
204
+ }
205
+ else {
206
+ throw new Error(`Unknown command: ${positionals[0]}`);
207
+ }
208
+ }
209
+ finally {
210
+ await closeSharedBrowser();
211
+ }
212
+ }
213
+ main().catch((error) => {
214
+ console.error(error instanceof Error ? error.message : error);
215
+ process.exitCode = 1;
216
+ });
217
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,IAAI,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;YACN,MAAM,IAAI,KAAK,CAAC,oBAAoB,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QACxD,CAAC;IACH,CAAC;YAAS,CAAC;QACT,MAAM,kBAAkB,EAAE,CAAC;IAC7B,CAAC;AACH,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,OAAO,CAAC,KAAK,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IAC9D,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACvB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type { ReactShotConfig } from "./types.js";
2
+ export declare function findConfigPath(startDir: string): string | null;
3
+ export declare function loadConfig(configPath: string | null | undefined): Promise<ReactShotConfig>;
4
+ export declare function resolvePackageRoot(fixturePath: string, explicitRoot?: string, config?: ReactShotConfig): string;
5
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AASlD,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAW9D;AAED,wBAAsB,UAAU,CAC9B,UAAU,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GACpC,OAAO,CAAC,eAAe,CAAC,CA2C1B;AAED,wBAAgB,kBAAkB,CAChC,WAAW,EAAE,MAAM,EACnB,YAAY,CAAC,EAAE,MAAM,EACrB,MAAM,CAAC,EAAE,eAAe,GACvB,MAAM,CAWR"}
@@ -0,0 +1,75 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ import { pathToFileURL } from "node:url";
4
+ import { tsImport } from "tsx/esm/api";
5
+ const CONFIG_NAMES = [
6
+ "react-shot.config.ts",
7
+ "react-shot.config.mts",
8
+ "react-shot.config.js",
9
+ "react-shot.config.mjs",
10
+ ];
11
+ export function findConfigPath(startDir) {
12
+ let dir = path.resolve(startDir);
13
+ while (true) {
14
+ for (const name of CONFIG_NAMES) {
15
+ const candidate = path.join(dir, name);
16
+ if (fs.existsSync(candidate))
17
+ return candidate;
18
+ }
19
+ const parent = path.dirname(dir);
20
+ if (parent === dir)
21
+ return null;
22
+ dir = parent;
23
+ }
24
+ }
25
+ export async function loadConfig(configPath) {
26
+ if (!configPath)
27
+ return {};
28
+ const absolutePath = path.resolve(configPath);
29
+ if (!fs.existsSync(absolutePath)) {
30
+ throw new Error(`react-shot config not found: ${absolutePath}`);
31
+ }
32
+ const module = absolutePath.endsWith(".ts") || absolutePath.endsWith(".mts")
33
+ ? await tsImport(absolutePath, import.meta.url)
34
+ : await import(`${pathToFileURL(absolutePath).href}?t=${Date.now()}`);
35
+ const imported = (module.default ?? module);
36
+ // tsx exposes a TypeScript default export through one additional interop
37
+ // layer when the importing package is ESM.
38
+ const config = "default" in imported &&
39
+ Object.keys(imported).every((key) => key === "default")
40
+ ? imported.default
41
+ : imported;
42
+ const configDirectory = path.dirname(absolutePath);
43
+ return {
44
+ ...config,
45
+ root: config.root
46
+ ? path.resolve(configDirectory, config.root)
47
+ : configDirectory,
48
+ alias: config.alias
49
+ ? Object.fromEntries(Object.entries(config.alias).map(([key, value]) => [
50
+ key,
51
+ path.resolve(configDirectory, value),
52
+ ]))
53
+ : undefined,
54
+ styles: config.styles?.map((value) => path.resolve(configDirectory, value)),
55
+ postcssConfig: config.postcssConfig
56
+ ? path.resolve(configDirectory, config.postcssConfig)
57
+ : undefined,
58
+ };
59
+ }
60
+ export function resolvePackageRoot(fixturePath, explicitRoot, config) {
61
+ if (explicitRoot)
62
+ return path.resolve(explicitRoot);
63
+ if (config?.root)
64
+ return config.root;
65
+ let directory = path.dirname(path.resolve(fixturePath));
66
+ while (true) {
67
+ if (fs.existsSync(path.join(directory, "package.json")))
68
+ return directory;
69
+ const parent = path.dirname(directory);
70
+ if (parent === directory)
71
+ return path.dirname(path.resolve(fixturePath));
72
+ directory = parent;
73
+ }
74
+ }
75
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.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,EAAE,MAAM,aAAa,CAAC;AAGvC,MAAM,YAAY,GAAG;IACnB,sBAAsB;IACtB,uBAAuB;IACvB,sBAAsB;IACtB,uBAAuB;CACxB,CAAC;AAEF,MAAM,UAAU,cAAc,CAAC,QAAgB;IAC7C,IAAI,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACjC,OAAO,IAAI,EAAE,CAAC;QACZ,KAAK,MAAM,IAAI,IAAI,YAAY,EAAE,CAAC;YAChC,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;YACvC,IAAI,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC;gBAAE,OAAO,SAAS,CAAC;QACjD,CAAC;QACD,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACjC,IAAI,MAAM,KAAK,GAAG;YAAE,OAAO,IAAI,CAAC;QAChC,GAAG,GAAG,MAAM,CAAC;IACf,CAAC;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,UAAqC;IAErC,IAAI,CAAC,UAAU;QAAE,OAAO,EAAE,CAAC;IAE3B,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IAC9C,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;QACjC,M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ACH,CAAC,CAAC,SAAS;QACb,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CACnC,IAAI,CAAC,OAAO,CAAC,eAAe,EAAE,KAAK,CAAC,CACrC;QACD,aAAa,EAAE,MAAM,CAAC,aAAa;YACjC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,eAAe,EAAE,MAAM,CAAC,aAAa,CAAC;YACrD,CAAC,CAAC,SAAS;KACd,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,kBAAkB,CAChC,WAAmB,EACnB,YAAqB,EACrB,MAAwB;IAExB,IAAI,YAAY;QAAE,OAAO,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;IACpD,IAAI,MAAM,EAAE,IAAI;QAAE,OAAO,MAAM,CAAC,IAAI,CAAC;IAErC,IAAI,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC;IACxD,OAAO,IAAI,EAAE,CAAC;QACZ,IAAI,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC;YAAE,OAAO,SAAS,CAAC;QAC1E,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QACvC,IAAI,MAAM,KAAK,SAAS;YAAE,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC;QACzE,SAAS,GAAG,MAAM,CAAC;IACrB,CAAC;AACH,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { type ViteDevServer } from "vite";
2
+ import type { ReactShotConfig } from "./types.js";
3
+ export declare function resolveInstalledPackage(packageRoot: string, name: string): string | null;
4
+ export declare function resolveInstalledModule(packageRoot: string, moduleName: string): string | null;
5
+ export declare function startShotServer(options: {
6
+ fixturePath: string;
7
+ packageRoot: string;
8
+ config: ReactShotConfig;
9
+ }): Promise<{
10
+ server: ViteDevServer;
11
+ url: string;
12
+ }>;
13
+ //# sourceMappingURL=create-server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-server.d.ts","sourceRoot":"","sources":["../src/create-server.ts"],"names":[],"mappings":"AAKA,OAAO,EAIL,KAAK,aAAa,EACnB,MAAM,MAAM,CAAC;AACd,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAgBlD,wBAAgB,uBAAuB,CACrC,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE,MAAM,GACX,MAAM,GAAG,IAAI,CAiBf;AAED,wBAAgB,sBAAsB,CACpC,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,MAAM,GACjB,MAAM,GAAG,IAAI,CAYf;AAoID,wBAAsB,eAAe,CAAC,OAAO,EAAE;IAC7C,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,eAAe,CAAC;CACzB,GAAG,OAAO,CAAC;IAAE,MAAM,EAAE,aAAa,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC,CA2FlD"}
@@ -0,0 +1,254 @@
1
+ import fs from "node:fs";
2
+ import { createRequire } from "node:module";
3
+ import path from "node:path";
4
+ import { fileURLToPath, pathToFileURL } from "node:url";
5
+ import react from "@vitejs/plugin-react";
6
+ import { createServer as createViteServer, } from "vite";
7
+ import { nextDynamicStub, nextImageStub, nextLinkStub, nextNavigationStub, serverOnlyStub, } from "./stubs.js";
8
+ const TOOL_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
9
+ const HOST_DIR = path.join(TOOL_ROOT, "host");
10
+ const FIXTURE_ID = "virtual:react-shot-fixture";
11
+ const STYLES_ID = "virtual:react-shot-styles";
12
+ const ENTRY_ID = "virtual:react-shot-entry";
13
+ const ENTRY_URL = "/@react-shot/entry.tsx";
14
+ export function resolveInstalledPackage(packageRoot, name) {
15
+ const entry = resolveInstalledModule(packageRoot, name);
16
+ if (!entry)
17
+ return null;
18
+ let directory = path.dirname(entry);
19
+ while (true) {
20
+ const packagePath = path.join(directory, "package.json");
21
+ if (fs.existsSync(packagePath)) {
22
+ const manifest = JSON.parse(fs.readFileSync(packagePath, "utf8"));
23
+ if (manifest.name === name)
24
+ return directory;
25
+ }
26
+ const parent = path.dirname(directory);
27
+ if (parent === directory)
28
+ return null;
29
+ directory = parent;
30
+ }
31
+ }
32
+ export function resolveInstalledModule(packageRoot, moduleName) {
33
+ for (const base of [path.resolve(packageRoot), TOOL_ROOT]) {
34
+ const resolver = createRequire(path.join(base, "__react_shot_resolver__.cjs"));
35
+ try {
36
+ return resolver.resolve(moduleName);
37
+ }
38
+ catch (error) {
39
+ if (error.code !== "MODULE_NOT_FOUND") {
40
+ throw error;
41
+ }
42
+ }
43
+ }
44
+ return null;
45
+ }
46
+ async function loadTailwindVitePlugin(packageRoot) {
47
+ const entry = resolveInstalledModule(packageRoot, "@tailwindcss/vite");
48
+ if (!entry)
49
+ return null;
50
+ const module = await import(pathToFileURL(entry).href);
51
+ const tailwind = (module.default ?? module);
52
+ return tailwind();
53
+ }
54
+ function reactShotPlugin(options) {
55
+ const fixturePath = path.resolve(options.fixturePath);
56
+ const styleFiles = options.config.styles ?? [];
57
+ return {
58
+ name: "react-shot",
59
+ enforce: "pre",
60
+ resolveId(id) {
61
+ if (id === FIXTURE_ID)
62
+ return `\0${FIXTURE_ID}`;
63
+ if (id === STYLES_ID)
64
+ return `\0${STYLES_ID}`;
65
+ if (id === ENTRY_ID ||
66
+ id === ENTRY_URL ||
67
+ id.endsWith(ENTRY_URL)) {
68
+ return `\0${ENTRY_ID}`;
69
+ }
70
+ return null;
71
+ },
72
+ load(id) {
73
+ if (id === `\0${FIXTURE_ID}`) {
74
+ return `export { default } from ${JSON.stringify(fixturePath.replaceAll("\\", "/"))};\n`;
75
+ }
76
+ if (id === `\0${STYLES_ID}`) {
77
+ return styleFiles.length === 0
78
+ ? "export {};\n"
79
+ : styleFiles
80
+ .map((file) => `import ${JSON.stringify(file.replaceAll("\\", "/"))};`)
81
+ .join("\n");
82
+ }
83
+ if (id === `\0${ENTRY_ID}`) {
84
+ return `
85
+ import React from "react";
86
+ import { createRoot } from "react-dom/client";
87
+ import fixture from ${JSON.stringify(FIXTURE_ID)};
88
+ import ${JSON.stringify(STYLES_ID)};
89
+
90
+ const width = fixture.width ?? 1280;
91
+ const height = fixture.height ?? 800;
92
+ const background = fixture.background ?? "transparent";
93
+ const win = window;
94
+
95
+ win.__REACT_SHOT_META__ = {
96
+ width: fixture.width,
97
+ height: fixture.height,
98
+ background: fixture.background,
99
+ selector: fixture.selector,
100
+ waitFor: fixture.waitFor,
101
+ settleMs: fixture.settleMs,
102
+ fullPage: fixture.fullPage,
103
+ stripOverlay: fixture.stripOverlay,
104
+ omitBackground: fixture.omitBackground,
105
+ };
106
+
107
+ document.documentElement.style.width = width + "px";
108
+ document.documentElement.style.height = height + "px";
109
+ document.body.style.width = width + "px";
110
+ document.body.style.height = height + "px";
111
+ document.body.style.background = background;
112
+ document.body.style.overflow = "hidden";
113
+
114
+ const root = document.getElementById("root");
115
+ if (!root) throw new Error("#root missing");
116
+ root.setAttribute("data-react-shot-root", "true");
117
+ root.style.minHeight = height + "px";
118
+ root.style.width = width + "px";
119
+ root.style.background = background;
120
+
121
+ try {
122
+ createRoot(root).render(React.createElement(React.StrictMode, null, fixture.component));
123
+ requestAnimationFrame(function () { win.__REACT_SHOT_READY__ = true; });
124
+ } catch (error) {
125
+ win.__REACT_SHOT_ERROR__ = error && error.stack ? error.stack : String(error);
126
+ win.__REACT_SHOT_READY__ = true;
127
+ root.textContent = win.__REACT_SHOT_ERROR__;
128
+ }
129
+ `;
130
+ }
131
+ return null;
132
+ },
133
+ configureServer(server) {
134
+ server.middlewares.use((request, response, next) => {
135
+ if (request.url !== "/" && !request.url?.startsWith("/?")) {
136
+ next();
137
+ return;
138
+ }
139
+ const html = fs.readFileSync(path.join(HOST_DIR, "index.html"), "utf8");
140
+ server
141
+ .transformIndexHtml("/", html)
142
+ .then((transformed) => {
143
+ response.setHeader("Content-Type", "text/html");
144
+ response.end(transformed);
145
+ })
146
+ .catch(next);
147
+ });
148
+ },
149
+ };
150
+ }
151
+ function stubPlugin(stubs) {
152
+ return {
153
+ name: "react-shot-stubs",
154
+ enforce: "pre",
155
+ resolveId(id) {
156
+ return id in stubs ? `\0react-shot-stub:${id}` : null;
157
+ },
158
+ load(id) {
159
+ if (!id.startsWith("\0react-shot-stub:"))
160
+ return null;
161
+ const name = id.slice("\0react-shot-stub:".length);
162
+ return stubs[name] ?? "export {};";
163
+ },
164
+ };
165
+ }
166
+ export async function startShotServer(options) {
167
+ const packageRoot = path.resolve(options.packageRoot);
168
+ const aliases = { ...(options.config.alias ?? {}) };
169
+ if (!aliases["@"])
170
+ aliases["@"] = packageRoot;
171
+ const stubs = {
172
+ "next/navigation": nextNavigationStub,
173
+ "next/link": nextLinkStub,
174
+ "next/image": nextImageStub,
175
+ "next/dynamic": nextDynamicStub,
176
+ "server-only": serverOnlyStub,
177
+ };
178
+ for (const moduleName of options.config.stubModules ?? []) {
179
+ stubs[moduleName] = serverOnlyStub;
180
+ }
181
+ const alias = Object.entries(aliases)
182
+ .sort(([left], [right]) => right.length - left.length)
183
+ .map(([find, replacement]) => ({ find, replacement }));
184
+ const reactPackage = resolveInstalledPackage(packageRoot, "react");
185
+ const reactDomPackage = resolveInstalledPackage(packageRoot, "react-dom");
186
+ if (reactPackage)
187
+ alias.unshift({ find: "react", replacement: reactPackage });
188
+ if (reactDomPackage) {
189
+ alias.unshift({ find: "react-dom", replacement: reactDomPackage });
190
+ }
191
+ const tailwindPlugin = await loadTailwindVitePlugin(packageRoot);
192
+ const plugins = [
193
+ reactShotPlugin({
194
+ fixturePath: options.fixturePath,
195
+ config: options.config,
196
+ }),
197
+ stubPlugin(stubs),
198
+ react({ jsxRuntime: "automatic" }),
199
+ ];
200
+ if (tailwindPlugin)
201
+ plugins.unshift(tailwindPlugin);
202
+ const allowedDirectories = new Set([
203
+ packageRoot,
204
+ TOOL_ROOT,
205
+ path.dirname(path.resolve(options.fixturePath)),
206
+ ...Object.values(aliases),
207
+ ...(options.config.styles ?? []).map(path.dirname),
208
+ ]);
209
+ const server = await createViteServer({
210
+ configFile: false,
211
+ root: packageRoot,
212
+ server: {
213
+ host: "127.0.0.1",
214
+ port: 0,
215
+ strictPort: false,
216
+ fs: { allow: [...allowedDirectories] },
217
+ },
218
+ plugins,
219
+ resolve: {
220
+ alias,
221
+ dedupe: [
222
+ "react",
223
+ "react-dom",
224
+ "react/jsx-runtime",
225
+ ...(options.config.dedupe ?? []),
226
+ ],
227
+ },
228
+ css: tailwindPlugin || !options.config.postcssConfig
229
+ ? undefined
230
+ : { postcss: options.config.postcssConfig },
231
+ optimizeDeps: {
232
+ include: [
233
+ "react",
234
+ "react-dom",
235
+ "react/jsx-runtime",
236
+ "react-dom/client",
237
+ ],
238
+ // Fixtures are executable entry points, not an application tree for Vite
239
+ // to crawl. Discovery can otherwise walk unrelated HTML reachable from
240
+ // unusual host filesystems; declared imports still load on demand.
241
+ noDiscovery: true,
242
+ force: true,
243
+ },
244
+ logLevel: "warn",
245
+ });
246
+ await server.listen();
247
+ const address = server.httpServer?.address();
248
+ if (!address || typeof address === "string") {
249
+ await server.close();
250
+ throw new Error("Vite server did not bind a TCP port");
251
+ }
252
+ return { server, url: `http://127.0.0.1:${address.port}/` };
253
+ }
254
+ //# sourceMappingURL=create-server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-server.js","sourceRoot":"","sources":["../src/create-server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACxD,OAAO,KAAK,MAAM,sBAAsB,CAAC;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AE,OAAO,CAAC,MAAM,CAAC,aAAa,EAAE;QAC/C,YAAY,EAAE;YACZ,OAAO,EAAE;gBACP,OAAO;gBACP,WAAW;gBACX,mBAAmB;gBACnB,kBAAkB;aACnB;YACD,yEAAyE;YACzE,uEAAuE;YACvE,mEAAmE;YACnE,WAAW,EAAE,IAAI;YACjB,KAAK,EAAE,IAAI;SACZ;QACD,QAAQ,EAAE,MAAM;KACjB,CAAC,CAAC;IAEH,MAAM,MAAM,CAAC,MAAM,EAAE,CAAC;IACtB,MAAM,OAAO,GAAG,MAAM,CAAC,UAAU,EAAE,OAAO,EAAE,CAAC;IAC7C,IAAI,CAAC,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAC5C,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;QACrB,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;IACzD,CAAC;IACD,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,oBAAoB,OAAO,CAAC,IAAI,GAAG,EAAE,CAAC;AAC9D,CAAC"}
@@ -0,0 +1,4 @@
1
+ export type { BatchEntry, BatchManifest, ReactShotConfig, ReactShotFixture, ShotRequest, } from "./types.js";
2
+ export { closeSharedBrowser, takeShot } from "./shot.js";
3
+ export { isDialogSelector, resolveShotMeta } from "./meta.js";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,UAAU,EACV,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,WAAW,GACZ,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { closeSharedBrowser, takeShot } from "./shot.js";
2
+ export { isDialogSelector, resolveShotMeta } from "./meta.js";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { ReactShotFixture } from "./types.js";
2
+ /** Capture controls from a fixture, excluding its React tree. */
3
+ export type ShotMeta = Omit<ReactShotFixture, "component">;
4
+ export declare function resolveShotMeta(nodeMeta: Partial<ShotMeta>, browserMeta: Partial<ShotMeta>, cli?: {
5
+ width?: number;
6
+ height?: number;
7
+ }): Required<Pick<ShotMeta, "width" | "height" | "selector" | "settleMs" | "fullPage" | "stripOverlay" | "omitBackground">> & ShotMeta;
8
+ export declare function isDialogSelector(selector: string): boolean;
9
+ //# sourceMappingURL=meta.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"meta.d.ts","sourceRoot":"","sources":["../src/meta.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD,iEAAiE;AACjE,MAAM,MAAM,QAAQ,GAAG,IAAI,CAAC,gBAAgB,EAAE,WAAW,CAAC,CAAC;AAI3D,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,OAAO,CAAC,QAAQ,CAAC,EAC3B,WAAW,EAAE,OAAO,CAAC,QAAQ,CAAC,EAC9B,GAAG,GAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAO,GAC5C,QAAQ,CACT,IAAI,CACF,QAAQ,EACN,OAAO,GACP,QAAQ,GACR,UAAU,GACV,UAAU,GACV,UAAU,GACV,cAAc,GACd,gBAAgB,CACnB,CACF,GACC,QAAQ,CAmBT;AAED,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAE1D"}