@percy/cli-upload 1.32.9 → 1.32.10-beta.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 (2) hide show
  1. package/dist/utils.js +14 -24
  2. package/package.json +4 -4
package/dist/utils.js CHANGED
@@ -1,9 +1,11 @@
1
1
  import fs from 'fs';
2
- import { createResource, createRootResource } from '@percy/cli-command/utils';
2
+ import { createImageSnapshotResources } from '@percy/cli-command/utils';
3
3
  export { yieldAll } from '@percy/cli-command/utils';
4
4
 
5
- // Returns root resource and image resource objects based on image properties. The root resource is
6
- // a generated DOM designed to display an image at it's native size without margins or padding.
5
+ // Returns root resource and image resource objects based on image properties. The wrapper DOM
6
+ // itself lives in @percy/core's utils as createImageSnapshotResources: its exact shape is what
7
+ // percy-api matches to extract the image and skip the renderer, and the PDF snapshot path builds
8
+ // the same pair, so there must only be one definition of it.
7
9
  export async function getImageResources({
8
10
  name,
9
11
  type,
@@ -12,25 +14,13 @@ export async function getImageResources({
12
14
  relativePath,
13
15
  absolutePath
14
16
  }) {
15
- let rootUrl = `http://local/${encodeURIComponent(name)}`;
16
- let imageUrl = `http://local/${encodeURIComponent(relativePath)}`;
17
- let content = await fs.promises.readFile(absolutePath);
18
- let mimetype = `image/${type}`;
19
- return [createRootResource(rootUrl, `
20
- <!doctype html>
21
- <html lang="en">
22
- <head>
23
- <meta charset="utf-8">
24
- <title>${name}</title>
25
- <style>
26
- *, *::before, *::after { margin: 0; padding: 0; font-size: 0; }
27
- html, body { width: 100%; }
28
- img { max-width: 100%; }
29
- </style>
30
- </head>
31
- <body>
32
- <img src="${imageUrl}" width="${width}px" height="${height}px"/>
33
- </body>
34
- </html>
35
- `), createResource(imageUrl, content, mimetype)];
17
+ return createImageSnapshotResources({
18
+ name,
19
+ rootUrl: `http://local/${encodeURIComponent(name)}`,
20
+ imageUrl: `http://local/${encodeURIComponent(relativePath)}`,
21
+ width,
22
+ height,
23
+ content: await fs.promises.readFile(absolutePath),
24
+ mimetype: `image/${type}`
25
+ });
36
26
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@percy/cli-upload",
3
- "version": "1.32.9",
3
+ "version": "1.32.10-beta.1",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -9,7 +9,7 @@
9
9
  },
10
10
  "publishConfig": {
11
11
  "access": "public",
12
- "tag": "latest"
12
+ "tag": "beta"
13
13
  },
14
14
  "engines": {
15
15
  "node": ">=14"
@@ -33,9 +33,9 @@
33
33
  ]
34
34
  },
35
35
  "dependencies": {
36
- "@percy/cli-command": "1.32.9",
36
+ "@percy/cli-command": "1.32.10-beta.1",
37
37
  "fast-glob": "^3.2.11",
38
38
  "probe-image-size": "^7.3.0"
39
39
  },
40
- "gitHead": "598d96e0ae2f4fde8cdcd9e1542eff3f8bd7e8ab"
40
+ "gitHead": "b90cd9fe29b14fdb7a1e383609654b227adacf17"
41
41
  }