browsermation 0.0.56 → 0.0.60

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/bin/cli.js CHANGED
@@ -42258,25 +42258,10 @@ var {
42258
42258
  // package.json
42259
42259
  var package_default = {
42260
42260
  name: "browsermation",
42261
- version: "0.0.56",
42261
+ version: "0.0.60",
42262
42262
  description: "The testing platform for Playwright by Browsermation.",
42263
42263
  main: "./dist/index.js",
42264
42264
  types: "./dist/index.d.ts",
42265
- exports: {
42266
- ".": {
42267
- import: "./dist/index.js",
42268
- require: "./dist/index.js",
42269
- types: "./dist/index.d.ts",
42270
- default: "./dist/index.js"
42271
- },
42272
- "./reporter": {
42273
- import: "./dist/reporter.js",
42274
- require: "./dist/reporter.js",
42275
- types: "./dist/reporter.d.ts",
42276
- default: "./dist/reporter.js"
42277
- },
42278
- "./package.json": "./package.json"
42279
- },
42280
42265
  bin: {
42281
42266
  browsermation: "dist/bin/cli.js"
42282
42267
  },
@@ -42285,10 +42270,7 @@ var package_default = {
42285
42270
  ],
42286
42271
  scripts: {
42287
42272
  "build:cli": "esbuild src/bin/cli.ts --bundle --platform=node --external:playwright --target=node22 --outfile=dist/bin/cli.js",
42288
- "build:reporter": "esbuild src/reporter/reporter.ts --bundle --platform=node --external:playwright --target=node22 --outfile=dist/reporter.js",
42289
- "build:index": "esbuild src/index.ts --bundle --platform=node --external:playwright --target=node22 --outfile=dist/index.js",
42290
- "build:types": "tsc --emitDeclarationOnly --outDir dist",
42291
- build: "rm -rf dist && npm run build:cli && npm run build:index && npm run build:reporter && npm run build:types",
42273
+ build: "rm -rf dist && npm run build:cli",
42292
42274
  start: "node dist/bin/cli.js",
42293
42275
  "build:start": "npm run build && npm start",
42294
42276
  publishPackage: "npm run build && npm publish --access public"
@@ -42308,8 +42290,6 @@ var package_default = {
42308
42290
  typescript: "^5.9.2"
42309
42291
  },
42310
42292
  dependencies: {
42311
- browsermation: "^0.0.36",
42312
- "@playwright/test": "^1.55.0",
42313
42293
  archiver: "^7.0.1",
42314
42294
  axios: "^1.10.0",
42315
42295
  chalk: "^5.4.1",
package/package.json CHANGED
@@ -1,24 +1,9 @@
1
1
  {
2
2
  "name": "browsermation",
3
- "version": "0.0.56",
3
+ "version": "0.0.60",
4
4
  "description": "The testing platform for Playwright by Browsermation.",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
7
- "exports": {
8
- ".": {
9
- "import": "./dist/index.js",
10
- "require": "./dist/index.js",
11
- "types": "./dist/index.d.ts",
12
- "default": "./dist/index.js"
13
- },
14
- "./reporter": {
15
- "import": "./dist/reporter.js",
16
- "require": "./dist/reporter.js",
17
- "types": "./dist/reporter.d.ts",
18
- "default": "./dist/reporter.js"
19
- },
20
- "./package.json": "./package.json"
21
- },
22
7
  "bin": {
23
8
  "browsermation": "dist/bin/cli.js"
24
9
  },
@@ -27,10 +12,7 @@
27
12
  ],
28
13
  "scripts": {
29
14
  "build:cli": "esbuild src/bin/cli.ts --bundle --platform=node --external:playwright --target=node22 --outfile=dist/bin/cli.js",
30
- "build:reporter": "esbuild src/reporter/reporter.ts --bundle --platform=node --external:playwright --target=node22 --outfile=dist/reporter.js",
31
- "build:index": "esbuild src/index.ts --bundle --platform=node --external:playwright --target=node22 --outfile=dist/index.js",
32
- "build:types": "tsc --emitDeclarationOnly --outDir dist",
33
- "build": "rm -rf dist && npm run build:cli && npm run build:index && npm run build:reporter && npm run build:types",
15
+ "build": "rm -rf dist && npm run build:cli",
34
16
  "start": "node dist/bin/cli.js",
35
17
  "build:start": "npm run build && npm start",
36
18
  "publishPackage": "npm run build && npm publish --access public"
@@ -50,8 +32,6 @@
50
32
  "typescript": "^5.9.2"
51
33
  },
52
34
  "dependencies": {
53
- "browsermation": "^0.0.36",
54
- "@playwright/test": "^1.55.0",
55
35
  "archiver": "^7.0.1",
56
36
  "axios": "^1.10.0",
57
37
  "chalk": "^5.4.1",
package/dist/bin/cli.d.ts DELETED
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
package/dist/core.d.ts DELETED
@@ -1,8 +0,0 @@
1
- import { Readable } from 'node:stream';
2
- /**
3
- * The main function that orchestrates zipping and uploading.
4
- * @param folderPath The path to the folder to process.
5
- * @param testFiles The list of test files to include in the upload.
6
- */
7
- export declare function zip(folder: string, testFiles: string[]): Promise<Buffer>;
8
- export declare function upload(zipBuffer: Buffer, shardNumber: number, totalShards: number, playwrightConfig: object, options: object, eventStream: Readable): Promise<void>;
@@ -1,2 +0,0 @@
1
- import { PlaywrightTestConfig } from 'playwright/test';
2
- export declare function defineConfig<T>(config: PlaywrightTestConfig<T>): Promise<PlaywrightTestConfig<T>>;
package/dist/esbuild.d.ts DELETED
@@ -1 +0,0 @@
1
- export declare function compileFileUsingEsbuild(folder: string, filepath: string): Promise<unknown>;
package/dist/http.d.ts DELETED
@@ -1 +0,0 @@
1
- export declare function downloadFile(fileUrl: string, outputLocationPath: string): Promise<unknown>;
package/dist/index.d.ts DELETED
@@ -1,2 +0,0 @@
1
- export { defineConfig } from './defineConfig';
2
- export { test } from './test';
package/dist/index.js DELETED
@@ -1,796 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
-
30
- // src/index.ts
31
- var index_exports = {};
32
- __export(index_exports, {
33
- defineConfig: () => defineConfig,
34
- test: () => test
35
- });
36
- module.exports = __toCommonJS(index_exports);
37
-
38
- // src/defineConfig.ts
39
- var import_node_https = __toESM(require("node:https"));
40
- var import_node_http = __toESM(require("node:http"));
41
-
42
- // node_modules/chalk/source/vendor/ansi-styles/index.js
43
- var ANSI_BACKGROUND_OFFSET = 10;
44
- var wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`;
45
- var wrapAnsi256 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`;
46
- var wrapAnsi16m = (offset = 0) => (red, green, blue) => `\x1B[${38 + offset};2;${red};${green};${blue}m`;
47
- var styles = {
48
- modifier: {
49
- reset: [0, 0],
50
- // 21 isn't widely supported and 22 does the same thing
51
- bold: [1, 22],
52
- dim: [2, 22],
53
- italic: [3, 23],
54
- underline: [4, 24],
55
- overline: [53, 55],
56
- inverse: [7, 27],
57
- hidden: [8, 28],
58
- strikethrough: [9, 29]
59
- },
60
- color: {
61
- black: [30, 39],
62
- red: [31, 39],
63
- green: [32, 39],
64
- yellow: [33, 39],
65
- blue: [34, 39],
66
- magenta: [35, 39],
67
- cyan: [36, 39],
68
- white: [37, 39],
69
- // Bright color
70
- blackBright: [90, 39],
71
- gray: [90, 39],
72
- // Alias of `blackBright`
73
- grey: [90, 39],
74
- // Alias of `blackBright`
75
- redBright: [91, 39],
76
- greenBright: [92, 39],
77
- yellowBright: [93, 39],
78
- blueBright: [94, 39],
79
- magentaBright: [95, 39],
80
- cyanBright: [96, 39],
81
- whiteBright: [97, 39]
82
- },
83
- bgColor: {
84
- bgBlack: [40, 49],
85
- bgRed: [41, 49],
86
- bgGreen: [42, 49],
87
- bgYellow: [43, 49],
88
- bgBlue: [44, 49],
89
- bgMagenta: [45, 49],
90
- bgCyan: [46, 49],
91
- bgWhite: [47, 49],
92
- // Bright color
93
- bgBlackBright: [100, 49],
94
- bgGray: [100, 49],
95
- // Alias of `bgBlackBright`
96
- bgGrey: [100, 49],
97
- // Alias of `bgBlackBright`
98
- bgRedBright: [101, 49],
99
- bgGreenBright: [102, 49],
100
- bgYellowBright: [103, 49],
101
- bgBlueBright: [104, 49],
102
- bgMagentaBright: [105, 49],
103
- bgCyanBright: [106, 49],
104
- bgWhiteBright: [107, 49]
105
- }
106
- };
107
- var modifierNames = Object.keys(styles.modifier);
108
- var foregroundColorNames = Object.keys(styles.color);
109
- var backgroundColorNames = Object.keys(styles.bgColor);
110
- var colorNames = [...foregroundColorNames, ...backgroundColorNames];
111
- function assembleStyles() {
112
- const codes = /* @__PURE__ */ new Map();
113
- for (const [groupName, group] of Object.entries(styles)) {
114
- for (const [styleName, style] of Object.entries(group)) {
115
- styles[styleName] = {
116
- open: `\x1B[${style[0]}m`,
117
- close: `\x1B[${style[1]}m`
118
- };
119
- group[styleName] = styles[styleName];
120
- codes.set(style[0], style[1]);
121
- }
122
- Object.defineProperty(styles, groupName, {
123
- value: group,
124
- enumerable: false
125
- });
126
- }
127
- Object.defineProperty(styles, "codes", {
128
- value: codes,
129
- enumerable: false
130
- });
131
- styles.color.close = "\x1B[39m";
132
- styles.bgColor.close = "\x1B[49m";
133
- styles.color.ansi = wrapAnsi16();
134
- styles.color.ansi256 = wrapAnsi256();
135
- styles.color.ansi16m = wrapAnsi16m();
136
- styles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);
137
- styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
138
- styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
139
- Object.defineProperties(styles, {
140
- rgbToAnsi256: {
141
- value(red, green, blue) {
142
- if (red === green && green === blue) {
143
- if (red < 8) {
144
- return 16;
145
- }
146
- if (red > 248) {
147
- return 231;
148
- }
149
- return Math.round((red - 8) / 247 * 24) + 232;
150
- }
151
- return 16 + 36 * Math.round(red / 255 * 5) + 6 * Math.round(green / 255 * 5) + Math.round(blue / 255 * 5);
152
- },
153
- enumerable: false
154
- },
155
- hexToRgb: {
156
- value(hex) {
157
- const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));
158
- if (!matches) {
159
- return [0, 0, 0];
160
- }
161
- let [colorString] = matches;
162
- if (colorString.length === 3) {
163
- colorString = [...colorString].map((character) => character + character).join("");
164
- }
165
- const integer = Number.parseInt(colorString, 16);
166
- return [
167
- /* eslint-disable no-bitwise */
168
- integer >> 16 & 255,
169
- integer >> 8 & 255,
170
- integer & 255
171
- /* eslint-enable no-bitwise */
172
- ];
173
- },
174
- enumerable: false
175
- },
176
- hexToAnsi256: {
177
- value: (hex) => styles.rgbToAnsi256(...styles.hexToRgb(hex)),
178
- enumerable: false
179
- },
180
- ansi256ToAnsi: {
181
- value(code) {
182
- if (code < 8) {
183
- return 30 + code;
184
- }
185
- if (code < 16) {
186
- return 90 + (code - 8);
187
- }
188
- let red;
189
- let green;
190
- let blue;
191
- if (code >= 232) {
192
- red = ((code - 232) * 10 + 8) / 255;
193
- green = red;
194
- blue = red;
195
- } else {
196
- code -= 16;
197
- const remainder = code % 36;
198
- red = Math.floor(code / 36) / 5;
199
- green = Math.floor(remainder / 6) / 5;
200
- blue = remainder % 6 / 5;
201
- }
202
- const value = Math.max(red, green, blue) * 2;
203
- if (value === 0) {
204
- return 30;
205
- }
206
- let result = 30 + (Math.round(blue) << 2 | Math.round(green) << 1 | Math.round(red));
207
- if (value === 2) {
208
- result += 60;
209
- }
210
- return result;
211
- },
212
- enumerable: false
213
- },
214
- rgbToAnsi: {
215
- value: (red, green, blue) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)),
216
- enumerable: false
217
- },
218
- hexToAnsi: {
219
- value: (hex) => styles.ansi256ToAnsi(styles.hexToAnsi256(hex)),
220
- enumerable: false
221
- }
222
- });
223
- return styles;
224
- }
225
- var ansiStyles = assembleStyles();
226
- var ansi_styles_default = ansiStyles;
227
-
228
- // node_modules/chalk/source/vendor/supports-color/index.js
229
- var import_node_process = __toESM(require("node:process"), 1);
230
- var import_node_os = __toESM(require("node:os"), 1);
231
- var import_node_tty = __toESM(require("node:tty"), 1);
232
- function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : import_node_process.default.argv) {
233
- const prefix2 = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
234
- const position = argv.indexOf(prefix2 + flag);
235
- const terminatorPosition = argv.indexOf("--");
236
- return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
237
- }
238
- var { env } = import_node_process.default;
239
- var flagForceColor;
240
- if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
241
- flagForceColor = 0;
242
- } else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
243
- flagForceColor = 1;
244
- }
245
- function envForceColor() {
246
- if ("FORCE_COLOR" in env) {
247
- if (env.FORCE_COLOR === "true") {
248
- return 1;
249
- }
250
- if (env.FORCE_COLOR === "false") {
251
- return 0;
252
- }
253
- return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
254
- }
255
- }
256
- function translateLevel(level) {
257
- if (level === 0) {
258
- return false;
259
- }
260
- return {
261
- level,
262
- hasBasic: true,
263
- has256: level >= 2,
264
- has16m: level >= 3
265
- };
266
- }
267
- function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
268
- const noFlagForceColor = envForceColor();
269
- if (noFlagForceColor !== void 0) {
270
- flagForceColor = noFlagForceColor;
271
- }
272
- const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
273
- if (forceColor === 0) {
274
- return 0;
275
- }
276
- if (sniffFlags) {
277
- if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
278
- return 3;
279
- }
280
- if (hasFlag("color=256")) {
281
- return 2;
282
- }
283
- }
284
- if ("TF_BUILD" in env && "AGENT_NAME" in env) {
285
- return 1;
286
- }
287
- if (haveStream && !streamIsTTY && forceColor === void 0) {
288
- return 0;
289
- }
290
- const min = forceColor || 0;
291
- if (env.TERM === "dumb") {
292
- return min;
293
- }
294
- if (import_node_process.default.platform === "win32") {
295
- const osRelease = import_node_os.default.release().split(".");
296
- if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
297
- return Number(osRelease[2]) >= 14931 ? 3 : 2;
298
- }
299
- return 1;
300
- }
301
- if ("CI" in env) {
302
- if (["GITHUB_ACTIONS", "GITEA_ACTIONS", "CIRCLECI"].some((key) => key in env)) {
303
- return 3;
304
- }
305
- if (["TRAVIS", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
306
- return 1;
307
- }
308
- return min;
309
- }
310
- if ("TEAMCITY_VERSION" in env) {
311
- return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
312
- }
313
- if (env.COLORTERM === "truecolor") {
314
- return 3;
315
- }
316
- if (env.TERM === "xterm-kitty") {
317
- return 3;
318
- }
319
- if (env.TERM === "xterm-ghostty") {
320
- return 3;
321
- }
322
- if (env.TERM === "wezterm") {
323
- return 3;
324
- }
325
- if ("TERM_PROGRAM" in env) {
326
- const version = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
327
- switch (env.TERM_PROGRAM) {
328
- case "iTerm.app": {
329
- return version >= 3 ? 3 : 2;
330
- }
331
- case "Apple_Terminal": {
332
- return 2;
333
- }
334
- }
335
- }
336
- if (/-256(color)?$/i.test(env.TERM)) {
337
- return 2;
338
- }
339
- if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
340
- return 1;
341
- }
342
- if ("COLORTERM" in env) {
343
- return 1;
344
- }
345
- return min;
346
- }
347
- function createSupportsColor(stream, options = {}) {
348
- const level = _supportsColor(stream, {
349
- streamIsTTY: stream && stream.isTTY,
350
- ...options
351
- });
352
- return translateLevel(level);
353
- }
354
- var supportsColor = {
355
- stdout: createSupportsColor({ isTTY: import_node_tty.default.isatty(1) }),
356
- stderr: createSupportsColor({ isTTY: import_node_tty.default.isatty(2) })
357
- };
358
- var supports_color_default = supportsColor;
359
-
360
- // node_modules/chalk/source/utilities.js
361
- function stringReplaceAll(string, substring, replacer) {
362
- let index = string.indexOf(substring);
363
- if (index === -1) {
364
- return string;
365
- }
366
- const substringLength = substring.length;
367
- let endIndex = 0;
368
- let returnValue = "";
369
- do {
370
- returnValue += string.slice(endIndex, index) + substring + replacer;
371
- endIndex = index + substringLength;
372
- index = string.indexOf(substring, endIndex);
373
- } while (index !== -1);
374
- returnValue += string.slice(endIndex);
375
- return returnValue;
376
- }
377
- function stringEncaseCRLFWithFirstIndex(string, prefix2, postfix, index) {
378
- let endIndex = 0;
379
- let returnValue = "";
380
- do {
381
- const gotCR = string[index - 1] === "\r";
382
- returnValue += string.slice(endIndex, gotCR ? index - 1 : index) + prefix2 + (gotCR ? "\r\n" : "\n") + postfix;
383
- endIndex = index + 1;
384
- index = string.indexOf("\n", endIndex);
385
- } while (index !== -1);
386
- returnValue += string.slice(endIndex);
387
- return returnValue;
388
- }
389
-
390
- // node_modules/chalk/source/index.js
391
- var { stdout: stdoutColor, stderr: stderrColor } = supports_color_default;
392
- var GENERATOR = Symbol("GENERATOR");
393
- var STYLER = Symbol("STYLER");
394
- var IS_EMPTY = Symbol("IS_EMPTY");
395
- var levelMapping = [
396
- "ansi",
397
- "ansi",
398
- "ansi256",
399
- "ansi16m"
400
- ];
401
- var styles2 = /* @__PURE__ */ Object.create(null);
402
- var applyOptions = (object, options = {}) => {
403
- if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
404
- throw new Error("The `level` option should be an integer from 0 to 3");
405
- }
406
- const colorLevel = stdoutColor ? stdoutColor.level : 0;
407
- object.level = options.level === void 0 ? colorLevel : options.level;
408
- };
409
- var chalkFactory = (options) => {
410
- const chalk2 = (...strings) => strings.join(" ");
411
- applyOptions(chalk2, options);
412
- Object.setPrototypeOf(chalk2, createChalk.prototype);
413
- return chalk2;
414
- };
415
- function createChalk(options) {
416
- return chalkFactory(options);
417
- }
418
- Object.setPrototypeOf(createChalk.prototype, Function.prototype);
419
- for (const [styleName, style] of Object.entries(ansi_styles_default)) {
420
- styles2[styleName] = {
421
- get() {
422
- const builder = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]);
423
- Object.defineProperty(this, styleName, { value: builder });
424
- return builder;
425
- }
426
- };
427
- }
428
- styles2.visible = {
429
- get() {
430
- const builder = createBuilder(this, this[STYLER], true);
431
- Object.defineProperty(this, "visible", { value: builder });
432
- return builder;
433
- }
434
- };
435
- var getModelAnsi = (model, level, type, ...arguments_) => {
436
- if (model === "rgb") {
437
- if (level === "ansi16m") {
438
- return ansi_styles_default[type].ansi16m(...arguments_);
439
- }
440
- if (level === "ansi256") {
441
- return ansi_styles_default[type].ansi256(ansi_styles_default.rgbToAnsi256(...arguments_));
442
- }
443
- return ansi_styles_default[type].ansi(ansi_styles_default.rgbToAnsi(...arguments_));
444
- }
445
- if (model === "hex") {
446
- return getModelAnsi("rgb", level, type, ...ansi_styles_default.hexToRgb(...arguments_));
447
- }
448
- return ansi_styles_default[type][model](...arguments_);
449
- };
450
- var usedModels = ["rgb", "hex", "ansi256"];
451
- for (const model of usedModels) {
452
- styles2[model] = {
453
- get() {
454
- const { level } = this;
455
- return function(...arguments_) {
456
- const styler = createStyler(getModelAnsi(model, levelMapping[level], "color", ...arguments_), ansi_styles_default.color.close, this[STYLER]);
457
- return createBuilder(this, styler, this[IS_EMPTY]);
458
- };
459
- }
460
- };
461
- const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
462
- styles2[bgModel] = {
463
- get() {
464
- const { level } = this;
465
- return function(...arguments_) {
466
- const styler = createStyler(getModelAnsi(model, levelMapping[level], "bgColor", ...arguments_), ansi_styles_default.bgColor.close, this[STYLER]);
467
- return createBuilder(this, styler, this[IS_EMPTY]);
468
- };
469
- }
470
- };
471
- }
472
- var proto = Object.defineProperties(() => {
473
- }, {
474
- ...styles2,
475
- level: {
476
- enumerable: true,
477
- get() {
478
- return this[GENERATOR].level;
479
- },
480
- set(level) {
481
- this[GENERATOR].level = level;
482
- }
483
- }
484
- });
485
- var createStyler = (open, close, parent) => {
486
- let openAll;
487
- let closeAll;
488
- if (parent === void 0) {
489
- openAll = open;
490
- closeAll = close;
491
- } else {
492
- openAll = parent.openAll + open;
493
- closeAll = close + parent.closeAll;
494
- }
495
- return {
496
- open,
497
- close,
498
- openAll,
499
- closeAll,
500
- parent
501
- };
502
- };
503
- var createBuilder = (self, _styler, _isEmpty) => {
504
- const builder = (...arguments_) => applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
505
- Object.setPrototypeOf(builder, proto);
506
- builder[GENERATOR] = self;
507
- builder[STYLER] = _styler;
508
- builder[IS_EMPTY] = _isEmpty;
509
- return builder;
510
- };
511
- var applyStyle = (self, string) => {
512
- if (self.level <= 0 || !string) {
513
- return self[IS_EMPTY] ? "" : string;
514
- }
515
- let styler = self[STYLER];
516
- if (styler === void 0) {
517
- return string;
518
- }
519
- const { openAll, closeAll } = styler;
520
- if (string.includes("\x1B")) {
521
- while (styler !== void 0) {
522
- string = stringReplaceAll(string, styler.close, styler.open);
523
- styler = styler.parent;
524
- }
525
- }
526
- const lfIndex = string.indexOf("\n");
527
- if (lfIndex !== -1) {
528
- string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
529
- }
530
- return openAll + string + closeAll;
531
- };
532
- Object.defineProperties(createChalk.prototype, styles2);
533
- var chalk = createChalk();
534
- var chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
535
- var source_default = chalk;
536
-
537
- // src/tunnel.ts
538
- var import_node_child_process = require("node:child_process");
539
- function startTunnel(tunnelProcess2, options) {
540
- if (!process.env.BM_TUNNEL_TOKEN) {
541
- console.error(
542
- source_default.red.bold(
543
- "\u274C Error: BM_TUNNEL_TOKEN environment variable is not set. Please set it to your tunnel token."
544
- )
545
- );
546
- process.exit(1);
547
- }
548
- if (!options?.port) {
549
- console.error(
550
- source_default.red.bold(
551
- "\u274C Error: Please provide a port to expose via the tunnel using the --tunnel or --port option."
552
- )
553
- );
554
- process.exit(1);
555
- }
556
- const tunnelDomain = `${options.subdomain || crypto.randomUUID()}.browsermationtunnel.com`;
557
- tunnelProcess2 = (0, import_node_child_process.spawn)("ssh", [
558
- "-o",
559
- "StrictHostKeyChecking=no",
560
- "-o",
561
- "UserKnownHostsFile=/dev/null",
562
- "-R",
563
- `:80:localhost:${options.port}`,
564
- "v0@browsermationtunnel.com",
565
- "-p",
566
- "2200",
567
- "http",
568
- "--proxy_name",
569
- tunnelDomain,
570
- "--custom_domain",
571
- tunnelDomain,
572
- "--token",
573
- process.env.BM_TUNNEL_TOKEN || ""
574
- ]);
575
- process.on("SIGINT", function() {
576
- console.log("\nGracefully shutting down from SIGINT (Ctrl+C)");
577
- if (tunnelProcess2) {
578
- console.log("Killing proxy process...");
579
- tunnelProcess2.kill();
580
- }
581
- process.exit();
582
- });
583
- tunnelProcess2?.stdout?.on("data", (data) => {
584
- if (process.env.BM_DEBUG) {
585
- console.log(`stdout: ${data}`);
586
- }
587
- });
588
- tunnelProcess2?.stderr?.on("data", (data) => {
589
- console.error(`stderr: ${data}`);
590
- });
591
- const tunnelUrl = `https://${tunnelDomain}`;
592
- console.log(
593
- source_default.green.bold(
594
- `\u2705 Tunnel setup complete. You can now access your project at: ${tunnelUrl}`
595
- )
596
- );
597
- return { tunnelProcess: tunnelProcess2, tunnelUrl };
598
- }
599
-
600
- // src/defineConfig.ts
601
- async function fetchEndpoint() {
602
- if (!process.env.BM_API_TOKEN) {
603
- console.error(
604
- source_default.red.bold(
605
- "\u274C Error: BM_API_TOKEN environment variable is not set. Please set it to your API token."
606
- )
607
- );
608
- process.exit(1);
609
- }
610
- if (!process.env.BM_SERVER_URL) {
611
- process.env.BM_SERVER_URL = "https://browsermation.test/api/v1/tasks/tests/playwright/ws";
612
- }
613
- let protocol = import_node_https.default;
614
- if (process.env.BM_SERVER_URL.startsWith("http:")) {
615
- protocol = import_node_http.default;
616
- }
617
- console.log(
618
- source_default.blue.bold(
619
- `\u{1F50D} Fetching WebSocket endpoint from ${process.env.BM_SERVER_URL}...`
620
- )
621
- );
622
- return new Promise((resolve, reject) => {
623
- const options = {
624
- headers: {
625
- Authorization: `Bearer ${process.env.BM_API_TOKEN || ""}`,
626
- Accept: "application/json"
627
- }
628
- };
629
- protocol.get(process.env.BM_SERVER_URL || "", options, (res) => {
630
- if (res.statusCode && res.statusCode >= 300 && res.statusCode < 400) {
631
- const redirectUrl = res.headers.location;
632
- if (redirectUrl) {
633
- resolve(redirectUrl);
634
- }
635
- }
636
- });
637
- });
638
- }
639
- var tunnelProcess = null;
640
- process.on("exit", () => {
641
- tunnelProcess?.kill();
642
- });
643
- async function defineConfig(config) {
644
- const endpointUrl = await fetchEndpoint();
645
- if (!endpointUrl) {
646
- console.error(
647
- source_default.red.bold(
648
- "\u274C Error: Failed to fetch WebSocket endpoint. Please check your BM_API_TOKEN and network connection."
649
- )
650
- );
651
- process.exit(1);
652
- }
653
- console.log(
654
- source_default.green.bold(
655
- `\u2705 WebSocket endpoint fetched successfully: ${endpointUrl}`
656
- )
657
- );
658
- let tunnelUrl = void 0;
659
- if (process.env.BM_TUNNEL_PORT || config.webServer && (Array.isArray(config.webServer) ? config.webServer.some((server) => server?.port) : config.webServer?.port)) {
660
- const port = process.env.BM_TUNNEL_PORT || (Array.isArray(config.webServer) ? config.webServer.find((server) => server?.port)?.port : config?.webServer?.port);
661
- ({ tunnelUrl } = await startTunnel(tunnelProcess, {
662
- tunnel: port
663
- }));
664
- }
665
- const bmConfig = {
666
- ...config,
667
- use: {
668
- ...config.use,
669
- connectOptions: {
670
- wsEndpoint: endpointUrl
671
- }
672
- }
673
- };
674
- if (tunnelUrl) {
675
- bmConfig.use.baseURL = tunnelUrl;
676
- console.log(source_default.green.bold(`\u2705 Tunnel URL: ${tunnelUrl}`));
677
- }
678
- if (process.env.BM_DEBUG) {
679
- console.log(source_default.yellow.bold("\u{1F527} BM_DEBUG is enabled. Configuration:"));
680
- console.dir(bmConfig, { depth: null });
681
- }
682
- return bmConfig;
683
- }
684
-
685
- // node_modules/@playwright/test/index.mjs
686
- var test_exports = {};
687
- __export(test_exports, {
688
- default: () => import_test.default
689
- });
690
- __reExport(test_exports, require("playwright/test"));
691
- var import_test = __toESM(require("playwright/test"), 1);
692
-
693
- // src/test.ts
694
- var import_node_https2 = __toESM(require("node:https"));
695
-
696
- // node_modules/tiny-invariant/dist/esm/tiny-invariant.js
697
- var isProduction = process.env.NODE_ENV === "production";
698
- var prefix = "Invariant failed";
699
- function invariant(condition, message) {
700
- if (condition) {
701
- return;
702
- }
703
- if (isProduction) {
704
- throw new Error(prefix);
705
- }
706
- var provided = typeof message === "function" ? message() : message;
707
- var value = provided ? "".concat(prefix, ": ").concat(provided) : prefix;
708
- throw new Error(value);
709
- }
710
-
711
- // src/test.ts
712
- async function fetchEndpoint2() {
713
- invariant(
714
- process.env.SERVER_URL,
715
- "SERVER_URL environment variable is not set"
716
- );
717
- invariant(
718
- process.env.BM_API_TOKEN,
719
- "BM_API_TOKEN environment variable is not set"
720
- );
721
- return new Promise((resolve, reject) => {
722
- import_node_https2.default.get(process.env.SERVER_URL, (res) => {
723
- res.on("data", (chunk) => {
724
- const parsedData = JSON.parse(chunk.toString());
725
- if (parsedData.type === "tunnel-domain") {
726
- console.log(`Tunnel domain found: ${parsedData.tunnelDomain}`);
727
- resolve(`https://${parsedData.tunnelDomain}`);
728
- res.destroy();
729
- }
730
- });
731
- }).on("error", (err) => {
732
- console.log("err", err);
733
- reject(err);
734
- });
735
- });
736
- }
737
- function checkIfBrowsermationTestReporterIsUsed() {
738
- if (!test.info().config.reporter.some(
739
- (reporter) => typeof reporter === "string" ? reporter === "browsermation/reporter" : reporter[0] === "browsermation/reporter"
740
- )) {
741
- throw new Error(
742
- "The browsermation/reporter reporter must be configured to use the page fixture."
743
- );
744
- }
745
- }
746
- var test = test_exports.test.extend({
747
- page: async ({ page }, use) => {
748
- checkIfBrowsermationTestReporterIsUsed();
749
- const endpointUrl = await fetchEndpoint2();
750
- let isConnected = false;
751
- while (!isConnected) {
752
- try {
753
- const response = await fetch(endpointUrl);
754
- if (response.ok && response.status === 200) {
755
- isConnected = true;
756
- break;
757
- }
758
- console.log("Waiting for browser to be ready...");
759
- await new Promise((resolve) => setTimeout(resolve, 1e3));
760
- } catch (error) {
761
- console.error("Error connecting to browser:", error);
762
- }
763
- }
764
- console.log("Connected to browser:", endpointUrl);
765
- const browser = await test_exports.chromium.connectOverCDP(endpointUrl, {});
766
- const context = await browser.newContext(test.info().project.use);
767
- const newPage = await context.newPage();
768
- await use(newPage);
769
- await newPage.close();
770
- await browser.close();
771
- },
772
- browser: async ({}, use) => {
773
- checkIfBrowsermationTestReporterIsUsed();
774
- const endpointUrl = await fetchEndpoint2();
775
- let isConnected = false;
776
- while (!isConnected) {
777
- try {
778
- const response = await fetch(endpointUrl);
779
- if (response.ok && response.status === 200) {
780
- isConnected = true;
781
- }
782
- await new Promise((resolve) => setTimeout(resolve, 1e3));
783
- } catch (error) {
784
- console.error("Error connecting to browser:", error);
785
- }
786
- }
787
- const browser = await test_exports.chromium.connectOverCDP(endpointUrl);
788
- await use(browser);
789
- await browser.close();
790
- }
791
- });
792
- // Annotate the CommonJS export names for ESM import in node:
793
- 0 && (module.exports = {
794
- defineConfig,
795
- test
796
- });
@@ -1,3 +0,0 @@
1
- export declare function getConfigViaTypescript(folder: string): Promise<unknown>;
2
- export declare function getConfig(projectPath: string): Promise<unknown>;
3
- export declare function getUniqueFilesFromJson(data: any, key?: string): any[];
@@ -1,11 +0,0 @@
1
- import type { FullConfig, FullResult, Reporter, Suite, TestCase, TestError, TestResult } from '@playwright/test/reporter';
2
- export default class BrowsermationReporter implements Reporter {
3
- log(message: string): void;
4
- sendData(data: Record<string, any>): Promise<void>;
5
- onBegin(_config: FullConfig, suite: Suite): Promise<void>;
6
- onEnd(result: FullResult): Promise<void>;
7
- onTestBegin(test: TestCase): Promise<void>;
8
- onTestEnd(test: TestCase, result: TestResult): Promise<void>;
9
- onError(error: TestError): Promise<void>;
10
- onExit(): Promise<void>;
11
- }
package/dist/reporter.js DELETED
@@ -1,128 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // src/reporter/reporter.ts
20
- var reporter_exports = {};
21
- __export(reporter_exports, {
22
- default: () => BrowsermationReporter
23
- });
24
- module.exports = __toCommonJS(reporter_exports);
25
- var regex = (({ onlyFirst = false } = {}) => {
26
- const ST = "(?:\\u0007|\\u001B\\u005C|\\u009C)";
27
- const pattern = [
28
- `[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?${ST})`,
29
- "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"
30
- ].join("|");
31
- return new RegExp(pattern, onlyFirst ? void 0 : "g");
32
- })();
33
- var stripAnsi = (str) => str.replace(regex, "");
34
- var BrowsermationReporter = class {
35
- log(message) {
36
- if (process.env.BM_REPORTER_LOGS) {
37
- console.log(message);
38
- }
39
- }
40
- async sendData(data) {
41
- try {
42
- await fetch(
43
- process.env.BM_REPORTING_URL || "https://browsermation.com/api/v1/playwright/reporting",
44
- {
45
- method: "POST",
46
- headers: {
47
- Accept: "application/json",
48
- "Content-Type": "application/json",
49
- Authorization: `Bearer ${process.env.BM_API_TOKEN}`
50
- },
51
- body: JSON.stringify(data)
52
- }
53
- );
54
- } catch (error) {
55
- console.error("Error sending data to Browsermation:", error);
56
- }
57
- }
58
- async onBegin(_config, suite) {
59
- const data = {
60
- type: "begin",
61
- title: suite.title,
62
- file: suite.location?.file,
63
- timestamp: Date.now()
64
- };
65
- this.log(`${JSON.stringify(data)}
66
- `);
67
- await this.sendData(data);
68
- }
69
- async onEnd(result) {
70
- const data = {
71
- type: "end",
72
- startTime: result.startTime,
73
- duration: result.duration,
74
- status: result.status,
75
- timestamp: Date.now()
76
- };
77
- this.log(`${JSON.stringify(data)}
78
- `);
79
- await this.sendData(data);
80
- }
81
- async onTestBegin(test) {
82
- const data = {
83
- id: test.id,
84
- type: "test-start",
85
- title: test.title,
86
- file: test.location.file,
87
- timestamp: Date.now()
88
- };
89
- this.log(`${JSON.stringify(data)}
90
- `);
91
- await this.sendData(data);
92
- }
93
- async onTestEnd(test, result) {
94
- const data = {
95
- id: test.id,
96
- type: "test-end",
97
- title: test.title,
98
- titlePath: test.titlePath,
99
- status: result.status,
100
- duration: result.duration,
101
- errors: stripAnsi(result.error?.message || ""),
102
- timestamp: Date.now()
103
- };
104
- this.log(`${JSON.stringify(data)}
105
- `);
106
- await this.sendData(data);
107
- }
108
- async onError(error) {
109
- const data = {
110
- type: "error",
111
- message: error.message,
112
- stack: error.stack,
113
- timestamp: Date.now()
114
- };
115
- console.error(`${JSON.stringify(data)}
116
- `);
117
- await this.sendData(data);
118
- }
119
- async onExit() {
120
- const data = {
121
- type: "exit",
122
- timestamp: Date.now()
123
- };
124
- this.log(`${JSON.stringify(data)}
125
- `);
126
- await this.sendData(data);
127
- }
128
- };
package/dist/test.d.ts DELETED
@@ -1 +0,0 @@
1
- export declare const test: import("@playwright/test").TestType<import("@playwright/test").PlaywrightTestArgs & import("@playwright/test").PlaywrightTestOptions, import("@playwright/test").PlaywrightWorkerArgs & import("@playwright/test").PlaywrightWorkerOptions>;
package/dist/tunnel.d.ts DELETED
@@ -1,5 +0,0 @@
1
- import { spawn } from 'node:child_process';
2
- export declare function startTunnel(tunnelProcess: ReturnType<typeof spawn> | null, options: any): {
3
- tunnelProcess: import("child_process").ChildProcess;
4
- tunnelUrl: string;
5
- };
package/dist/zip.d.ts DELETED
@@ -1,6 +0,0 @@
1
- /**
2
- * Zips a folder to a Buffer. it keeps the folder structure intact.
3
- * @param folder the folder where the testFiles are located
4
- * @param testFiles Array of file paths to include in the zip.
5
- */
6
- export declare function zipFolderToBuffer(folder: string, testFiles: string[]): Promise<Buffer>;