@argos-ci/util 4.2.1 → 4.2.2

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,2 +1,2 @@
1
- import { a as nextCaptureIndex, c as ScreenshotMetadata, i as getTestRunKey, l as getMetadataPath, n as getScreenshotName, o as resetCaptureIndexes, r as clearCaptureIndex, s as normalizeBaseNames, t as validateThreshold } from "./threshold-DGfnRf2_.mjs";
2
- export { type ScreenshotMetadata, clearCaptureIndex, getMetadataPath, getScreenshotName, getTestRunKey, nextCaptureIndex, normalizeBaseNames, resetCaptureIndexes, validateThreshold };
1
+ import { a as clearCaptureIndex, c as resetCaptureIndexes, d as getMetadataPath, i as getScreenshotName, l as normalizeBaseNames, n as hasPlay, o as getTestRunKey, r as mergeTags, s as nextCaptureIndex, t as validateThreshold, u as ScreenshotMetadata } from "./threshold-7lU01Zbd.mjs";
2
+ export { type ScreenshotMetadata, clearCaptureIndex, getMetadataPath, getScreenshotName, getTestRunKey, hasPlay, mergeTags, nextCaptureIndex, normalizeBaseNames, resetCaptureIndexes, validateThreshold };
package/dist/browser.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { a as getTestRunKey, c as normalizeBaseNames, i as clearCaptureIndex, n as getScreenshotName, o as nextCaptureIndex, r as getMetadataPath, s as resetCaptureIndexes, t as validateThreshold } from "./threshold-DBj5opgJ.mjs";
2
- export { clearCaptureIndex, getMetadataPath, getScreenshotName, getTestRunKey, nextCaptureIndex, normalizeBaseNames, resetCaptureIndexes, validateThreshold };
1
+ import { a as getMetadataPath, c as nextCaptureIndex, i as getScreenshotName, l as resetCaptureIndexes, n as hasPlay, o as clearCaptureIndex, r as mergeTags, s as getTestRunKey, t as validateThreshold, u as normalizeBaseNames } from "./threshold-CW8P4JMe.mjs";
2
+ export { clearCaptureIndex, getMetadataPath, getScreenshotName, getTestRunKey, hasPlay, mergeTags, nextCaptureIndex, normalizeBaseNames, resetCaptureIndexes, validateThreshold };
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as nextCaptureIndex, c as ScreenshotMetadata, i as getTestRunKey, l as getMetadataPath, n as getScreenshotName, o as resetCaptureIndexes, r as clearCaptureIndex, s as normalizeBaseNames, t as validateThreshold } from "./threshold-DGfnRf2_.mjs";
1
+ import { a as clearCaptureIndex, c as resetCaptureIndexes, d as getMetadataPath, i as getScreenshotName, l as normalizeBaseNames, n as hasPlay, o as getTestRunKey, r as mergeTags, s as nextCaptureIndex, t as validateThreshold, u as ScreenshotMetadata } from "./threshold-7lU01Zbd.mjs";
2
2
  //#region src/fs.d.ts
3
3
  /**
4
4
  * Create a directory if it doesn't exist.
@@ -39,4 +39,4 @@ export declare function readMetadata(screenshotPath: string): Promise<Screenshot
39
39
  */
40
40
  export declare function getPlaywrightTracePath(screenshotPath: string): Promise<string | null>;
41
41
  //#endregion
42
- export { ScreenshotMetadata, clearCaptureIndex, getMetadataPath, getScreenshotName, getTestRunKey, nextCaptureIndex, normalizeBaseNames, resetCaptureIndexes, validateThreshold };
42
+ export { ScreenshotMetadata, clearCaptureIndex, getMetadataPath, getScreenshotName, getTestRunKey, hasPlay, mergeTags, nextCaptureIndex, normalizeBaseNames, resetCaptureIndexes, validateThreshold };
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { a as getTestRunKey, c as normalizeBaseNames, i as clearCaptureIndex, n as getScreenshotName, o as nextCaptureIndex, r as getMetadataPath, s as resetCaptureIndexes, t as validateThreshold } from "./threshold-DBj5opgJ.mjs";
1
+ import { a as getMetadataPath, c as nextCaptureIndex, i as getScreenshotName, l as resetCaptureIndexes, n as hasPlay, o as clearCaptureIndex, r as mergeTags, s as getTestRunKey, t as validateThreshold, u as normalizeBaseNames } from "./threshold-CW8P4JMe.mjs";
2
2
  import { randomBytes } from "node:crypto";
3
3
  import { access, mkdir, readFile, writeFile } from "node:fs/promises";
4
4
  import { tmpdir } from "node:os";
@@ -101,4 +101,4 @@ async function getPlaywrightTracePath(screenshotPath) {
101
101
  }
102
102
  }
103
103
  //#endregion
104
- export { clearCaptureIndex, createDirectory, createTemporaryDirectory, getGitRepositoryPath, getMetadataPath, getPlaywrightTracePath, getScreenshotName, getTestRunKey, nextCaptureIndex, normalizeBaseNames, readMetadata, readVersionFromPackage, resetCaptureIndexes, validateThreshold, writeMetadata };
104
+ export { clearCaptureIndex, createDirectory, createTemporaryDirectory, getGitRepositoryPath, getMetadataPath, getPlaywrightTracePath, getScreenshotName, getTestRunKey, hasPlay, mergeTags, nextCaptureIndex, normalizeBaseNames, readMetadata, readVersionFromPackage, resetCaptureIndexes, validateThreshold, writeMetadata };
@@ -151,10 +151,23 @@ declare function getScreenshotName(name: string, options?: {
151
151
  viewportWidth?: number;
152
152
  }): string;
153
153
  //#endregion
154
+ //#region src/story.d.ts
155
+ /**
156
+ * Merge the tags of a story given by several sources (the story, its
157
+ * parameters…), deduplicated and without empty values.
158
+ */
159
+ declare function mergeTags(...tags: unknown[]): string[];
160
+ /**
161
+ * Return whether a story has a play function.
162
+ * Handles the `play` field of a composed story (itself a function) and the
163
+ * `playFunction` field of a story context.
164
+ */
165
+ declare function hasPlay(story: unknown): boolean;
166
+ //#endregion
154
167
  //#region src/threshold.d.ts
155
168
  /**
156
169
  * Validates the threshold value.
157
170
  */
158
171
  declare function validateThreshold(threshold: number): void;
159
172
  //#endregion
160
- export { nextCaptureIndex as a, ScreenshotMetadata as c, getTestRunKey as i, getMetadataPath as l, getScreenshotName as n, resetCaptureIndexes as o, clearCaptureIndex as r, normalizeBaseNames as s, validateThreshold as t };
173
+ export { clearCaptureIndex as a, resetCaptureIndexes as c, getMetadataPath as d, getScreenshotName as i, normalizeBaseNames as l, hasPlay as n, getTestRunKey as o, mergeTags as r, nextCaptureIndex as s, validateThreshold as t, ScreenshotMetadata as u };
@@ -86,6 +86,25 @@ function sanitizeFilename(name) {
86
86
  return sanitized;
87
87
  }
88
88
  //#endregion
89
+ //#region src/story.ts
90
+ /**
91
+ * Merge the tags of a story given by several sources (the story, its
92
+ * parameters…), deduplicated and without empty values.
93
+ */
94
+ function mergeTags(...tags) {
95
+ const merged = tags.flatMap((tag) => Array.isArray(tag) ? tag : tag ? [tag] : []);
96
+ return Array.from(new Set(merged)).filter((tag) => typeof tag === "string" && tag !== "");
97
+ }
98
+ /**
99
+ * Return whether a story has a play function.
100
+ * Handles the `play` field of a composed story (itself a function) and the
101
+ * `playFunction` field of a story context.
102
+ */
103
+ function hasPlay(story) {
104
+ if (!story || typeof story !== "object" && typeof story !== "function") return false;
105
+ return "play" in story && typeof story.play === "function" || "playFunction" in story && typeof story.playFunction === "function";
106
+ }
107
+ //#endregion
89
108
  //#region src/threshold.ts
90
109
  /**
91
110
  * Validates the threshold value.
@@ -94,4 +113,4 @@ function validateThreshold(threshold) {
94
113
  if (threshold < 0 || threshold > 1) throw new Error("The threshold must be between 0 and 1.");
95
114
  }
96
115
  //#endregion
97
- export { getTestRunKey as a, normalizeBaseNames as c, clearCaptureIndex as i, getScreenshotName as n, nextCaptureIndex as o, getMetadataPath as r, resetCaptureIndexes as s, validateThreshold as t };
116
+ export { getMetadataPath as a, nextCaptureIndex as c, getScreenshotName as i, resetCaptureIndexes as l, hasPlay as n, clearCaptureIndex as o, mergeTags as r, getTestRunKey as s, validateThreshold as t, normalizeBaseNames as u };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@argos-ci/util",
3
3
  "description": "Set of utilities used across all Argos SDKs.",
4
- "version": "4.2.1",
4
+ "version": "4.2.2",
5
5
  "author": "Smooth Code",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -48,5 +48,5 @@
48
48
  "@types/node": "catalog:",
49
49
  "vitest": "catalog:"
50
50
  },
51
- "gitHead": "4f0edc08d8549534dd3a682bbe034ebcb604bddf"
51
+ "gitHead": "e9d0b2fb39001683230eff86f9c39e0016b5cf27"
52
52
  }