@percy/sdk-utils 1.31.9 → 1.31.10-alpha.0

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/dist/bundle.js CHANGED
@@ -309,6 +309,23 @@
309
309
  });
310
310
  }
311
311
 
312
+ // Gets computed responsive widths from the Percy server for responsive snapshot capture
313
+ async function getResponsiveWidths(widths = []) {
314
+ let log = logger('utils');
315
+ try {
316
+ var _response$body;
317
+ // Ensure widths is an array
318
+ const widthsArray = Array.isArray(widths) ? widths : [];
319
+ const queryParam = widthsArray.length > 0 ? `?widths=${widthsArray.join(',')}` : '';
320
+ const response = await request(`/percy/widths-config${queryParam}`);
321
+ return Array.isArray((_response$body = response.body) === null || _response$body === void 0 ? void 0 : _response$body.widths) ? response.body.widths : [];
322
+ } catch (error) {
323
+ // Log error and return empty array as fallback
324
+ log.debug(`Failed to get responsive widths: ${error.message}`);
325
+ return [];
326
+ }
327
+ }
328
+
312
329
  var index = /*#__PURE__*/Object.freeze({
313
330
  __proto__: null,
314
331
  logger: logger,
@@ -322,6 +339,7 @@
322
339
  flushSnapshots: flushSnapshots,
323
340
  captureAutomateScreenshot: captureAutomateScreenshot,
324
341
  postBuildEvents: postBuildEvents,
342
+ getResponsiveWidths: getResponsiveWidths,
325
343
  'default': index
326
344
  });
327
345
 
@@ -329,6 +347,7 @@
329
347
  exports["default"] = index;
330
348
  exports.fetchPercyDOM = fetchPercyDOM;
331
349
  exports.flushSnapshots = flushSnapshots;
350
+ exports.getResponsiveWidths = getResponsiveWidths;
332
351
  exports.isPercyEnabled = isPercyEnabled;
333
352
  exports.logger = logger;
334
353
  exports.percy = info;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ exports.getResponsiveWidths = getResponsiveWidths;
8
+ var _request = _interopRequireDefault(require("./request.js"));
9
+ var _logger = _interopRequireDefault(require("./logger.js"));
10
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
+ // Gets computed responsive widths from the Percy server for responsive snapshot capture
12
+ async function getResponsiveWidths(widths = []) {
13
+ let log = (0, _logger.default)('utils');
14
+ try {
15
+ var _response$body;
16
+ // Ensure widths is an array
17
+ const widthsArray = Array.isArray(widths) ? widths : [];
18
+ const queryParam = widthsArray.length > 0 ? `?widths=${widthsArray.join(',')}` : '';
19
+ const response = await (0, _request.default)(`/percy/widths-config${queryParam}`);
20
+ return Array.isArray((_response$body = response.body) === null || _response$body === void 0 ? void 0 : _response$body.widths) ? response.body.widths : [];
21
+ } catch (error) {
22
+ // Log error and return empty array as fallback
23
+ log.debug(`Failed to get responsive widths: ${error.message}`);
24
+ return [];
25
+ }
26
+ }
27
+ var _default = exports.default = getResponsiveWidths;
package/dist/index.js CHANGED
@@ -22,6 +22,12 @@ Object.defineProperty(exports, "flushSnapshots", {
22
22
  return _flushSnapshots.default;
23
23
  }
24
24
  });
25
+ Object.defineProperty(exports, "getResponsiveWidths", {
26
+ enumerable: true,
27
+ get: function () {
28
+ return _getResponsiveWidths.default;
29
+ }
30
+ });
25
31
  Object.defineProperty(exports, "isPercyEnabled", {
26
32
  enumerable: true,
27
33
  get: function () {
@@ -81,6 +87,7 @@ var _postComparison = _interopRequireDefault(require("./post-comparison.js"));
81
87
  var _postBuildEvent = _interopRequireDefault(require("./post-build-event.js"));
82
88
  var _flushSnapshots = _interopRequireDefault(require("./flush-snapshots.js"));
83
89
  var _postScreenshot = _interopRequireDefault(require("./post-screenshot.js"));
90
+ var _getResponsiveWidths = _interopRequireDefault(require("./get-responsive-widths.js"));
84
91
  var _default = _interopRequireWildcard(require("./index.js"));
85
92
  exports.default = _default;
86
93
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@percy/sdk-utils",
3
- "version": "1.31.9",
3
+ "version": "1.31.10-alpha.0",
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": "alpha"
13
13
  },
14
14
  "engines": {
15
15
  "node": ">=14"
@@ -54,5 +54,5 @@
54
54
  "dependencies": {
55
55
  "pac-proxy-agent": "^7.0.2"
56
56
  },
57
- "gitHead": "5dc18fc7b8a1ed395a025a8f54dfa0094f92c599"
57
+ "gitHead": "9ee22836105a578d5f602d376a660c349bf6da0c"
58
58
  }