@cappa/core 0.0.15 → 0.0.17

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.
@@ -1,6 +1,6 @@
1
1
 
2
2
 
3
- > @cappa/core@0.0.14 build /home/tim/code/work/cappa/packages/core
3
+ > @cappa/core@0.0.15 build /home/tim/code/work/cappa/packages/core
4
4
  > tsdown
5
5
 
6
6
  ℹ tsdown v0.14.1 powered by rolldown v1.0.0-beta.38
@@ -24,4 +24,4 @@
24
24
  ℹ [ESM] dist/index.mjs.map 12.50 kB │ gzip: 3.38 kB
25
25
  ℹ [ESM] dist/index.d.mts  3.74 kB │ gzip: 1.29 kB
26
26
  ℹ [ESM] 3 files, total: 22.07 kB
27
- ✔ Build complete in 1076ms
27
+ ✔ Build complete in 937ms
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @cappa/core
2
2
 
3
+ ## 0.0.17
4
+
5
+ ### Patch Changes
6
+
7
+ - 6d7176e: Fix error reporting
8
+
9
+ ## 0.0.16
10
+
11
+ ### Patch Changes
12
+
13
+ - 92d164e: Fix directory creation
14
+
3
15
  ## 0.0.15
4
16
 
5
17
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cappa/core",
3
- "version": "0.0.15",
3
+ "version": "0.0.17",
4
4
  "description": "Core Playwright screenshot functionality for Cappa",
5
5
  "author": "tim-richter",
6
6
  "license": "MIT",
package/src/config.ts CHANGED
@@ -4,7 +4,9 @@ import type { PossiblePromise, UserConfig } from "./types";
4
4
  * Type helper to make it easier to use vite.config.ts accepts a direct UserConfig object, or a function that returns it. The function receives a ConfigEnv object.
5
5
  */
6
6
  export function defineConfig(
7
- options: PossiblePromise<UserConfig | Array<UserConfig>> | (() => PossiblePromise<UserConfig | Array<UserConfig>>),
7
+ options:
8
+ | PossiblePromise<UserConfig | Array<UserConfig>>
9
+ | (() => PossiblePromise<UserConfig | Array<UserConfig>>),
8
10
  ): typeof options {
9
11
  return options;
10
12
  }
package/src/plugin.ts CHANGED
@@ -3,7 +3,10 @@ import type ScreenshotTool from "./screenshot";
3
3
  /**
4
4
  * Plugin function type definition
5
5
  */
6
- export type PluginFunction = (screenshotTool: ScreenshotTool, options?: any) => Promise<any[]>;
6
+ export type PluginFunction = (
7
+ screenshotTool: ScreenshotTool,
8
+ options?: any,
9
+ ) => Promise<any[]>;
7
10
 
8
11
  /**
9
12
  * Plugin definition interface
package/src/screenshot.ts CHANGED
@@ -49,7 +49,8 @@ class ScreenshotTool {
49
49
  webkit,
50
50
  };
51
51
 
52
- const browserClass = browserMap[this.browserType as keyof typeof browserMap];
52
+ const browserClass =
53
+ browserMap[this.browserType as keyof typeof browserMap];
53
54
  if (!browserClass) {
54
55
  throw new Error(`Unsupported browser type: ${this.browserType}`);
55
56
  }
@@ -113,7 +114,8 @@ class ScreenshotTool {
113
114
  }
114
115
 
115
116
  // Wait for custom timeout or default
116
- const waitTime = options.waitForTimeout !== undefined ? options.waitForTimeout : 0;
117
+ const waitTime =
118
+ options.waitForTimeout !== undefined ? options.waitForTimeout : 0;
117
119
  if (waitTime > 0) {
118
120
  console.log(`Waiting for ${waitTime}ms for dynamic content`);
119
121
  await page.waitForTimeout(waitTime);
@@ -125,7 +127,10 @@ class ScreenshotTool {
125
127
  // Take screenshot
126
128
  const screenshotOptions = {
127
129
  path: filepath,
128
- fullPage: (options.fullPage as boolean) !== undefined ? options.fullPage : this.fullPage,
130
+ fullPage:
131
+ (options.fullPage as boolean) !== undefined
132
+ ? options.fullPage
133
+ : this.fullPage,
129
134
  type: (options.type as "jpeg" | "png") || "jpeg",
130
135
  quality: (options.quality as number) || this.quality,
131
136
  } satisfies PageScreenshotOptions;
@@ -135,7 +140,10 @@ class ScreenshotTool {
135
140
  console.log(`Screenshot saved: ${filepath}`);
136
141
  return filepath;
137
142
  } catch (error) {
138
- console.error(`Error taking screenshot of ${page.url()}:`, (error as Error).message);
143
+ console.error(
144
+ `Error taking screenshot of ${page.url()}:`,
145
+ (error as Error).message,
146
+ );
139
147
  throw error;
140
148
  }
141
149
  }
@@ -163,7 +171,9 @@ class ScreenshotTool {
163
171
  throw new Error(`Element not found: ${selector}`);
164
172
  }
165
173
 
166
- const filename = (options.filename as string | undefined) || `${selector.replace(/[^a-zA-Z0-9]/g, "_")}.png`;
174
+ const filename =
175
+ (options.filename as string | undefined) ||
176
+ `${selector.replace(/[^a-zA-Z0-9]/g, "_")}.png`;
167
177
  const filepath = this.getFilePath(filename);
168
178
 
169
179
  const elementScreenshotOptions = {
@@ -177,7 +187,10 @@ class ScreenshotTool {
177
187
  console.log(`Element screenshot saved: ${filepath}`);
178
188
  return filepath;
179
189
  } catch (error) {
180
- console.error(`Error taking element screenshot of ${page.url()}:`, (error as Error).message);
190
+ console.error(
191
+ `Error taking element screenshot of ${page.url()}:`,
192
+ (error as Error).message,
193
+ );
181
194
  throw error;
182
195
  } finally {
183
196
  await page.close();
@@ -251,7 +264,10 @@ class ScreenshotTool {
251
264
 
252
265
  const responsiveScreenshotOptions = {
253
266
  path: filepath,
254
- fullPage: (options.fullPage as boolean) !== undefined ? options.fullPage : this.fullPage,
267
+ fullPage:
268
+ (options.fullPage as boolean) !== undefined
269
+ ? options.fullPage
270
+ : this.fullPage,
255
271
  type: (options.type as "jpeg" | "png") || "png",
256
272
  quality: (options.quality as number) || this.quality,
257
273
  };
@@ -263,7 +279,10 @@ class ScreenshotTool {
263
279
  console.log(`Responsive screenshot saved: ${filepath}`);
264
280
  results.push({ viewport: viewport.name, success: true, filepath });
265
281
  } catch (error) {
266
- console.error(`Error taking responsive screenshot for ${viewport.name}:`, (error as Error).message);
282
+ console.error(
283
+ `Error taking responsive screenshot for ${viewport.name}:`,
284
+ (error as Error).message,
285
+ );
267
286
  results.push({
268
287
  viewport: viewport.name,
269
288
  success: false,
package/tsconfig.json CHANGED
@@ -1,4 +1,9 @@
1
1
  {
2
2
  "extends": "../../tsconfig.json",
3
- "include": ["src/**/*", "./package.json", "./tsdown.config.ts", "./vitest.config.ts"]
3
+ "include": [
4
+ "src/**/*",
5
+ "./package.json",
6
+ "./tsdown.config.ts",
7
+ "./vitest.config.ts"
8
+ ]
4
9
  }