@midscene/web 0.7.2 → 0.7.3-beta-20241104100519.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.
@@ -1,389 +1,487 @@
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 __commonJS = (cb, mod) => function __require() {
8
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
19
- // If the importer is in node compatibility mode or this is not an ESM
20
- // file that has been converted to a CommonJS file using a Babel-
21
- // compatible transform (i.e. "__esModule" has not been set), then set
22
- // "default" to the CommonJS "module.exports" for node compatibility.
23
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
24
- mod
25
- ));
26
-
27
- // ../../node_modules/.pnpm/dayjs@1.11.11/node_modules/dayjs/dayjs.min.js
28
- var require_dayjs_min = __commonJS({
29
- "../../node_modules/.pnpm/dayjs@1.11.11/node_modules/dayjs/dayjs.min.js"(exports, module) {
1
+ (function(global, factory) {
2
+ if (typeof module === "object" && typeof module.exports === "object") factory(exports, require("assert"), require("fs"), require("path"), require("@midscene/shared/constants"), require("@midscene/shared/fs"), require("@midscene/shared/img"), require("@midscene/shared/utils"), require("@midscene/core/utils"));
3
+ else if (typeof define === "function" && define.amd) define([
4
+ "exports",
5
+ "assert",
6
+ "fs",
7
+ "path",
8
+ "@midscene/shared/constants",
9
+ "@midscene/shared/fs",
10
+ "@midscene/shared/img",
11
+ "@midscene/shared/utils",
12
+ "@midscene/core/utils"
13
+ ], factory);
14
+ else if (global = typeof globalThis !== "undefined" ? globalThis : global || self) factory(global.playwrightReport = {}, global.assert, global.fs, global.path, global.constants, global.fs, global.img, global.utils, global.utils);
15
+ })(this, function(exports, _assert, _fs, _path, _constants, _fs1, _img, _utils, _utils1) {
30
16
  "use strict";
31
- !function(t, e) {
32
- "object" == typeof exports && "undefined" != typeof module ? module.exports = e() : "function" == typeof define && define.amd ? define(e) : (t = "undefined" != typeof globalThis ? globalThis : t || self).dayjs = e();
33
- }(exports, function() {
34
- "use strict";
35
- var t = 1e3, e = 6e4, n = 36e5, r = "millisecond", i = "second", s = "minute", u = "hour", a = "day", o = "week", c = "month", f = "quarter", h = "year", d = "date", l = "Invalid Date", $ = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/, y = /\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g, M = { name: "en", weekdays: "Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"), months: "January_February_March_April_May_June_July_August_September_October_November_December".split("_"), ordinal: function(t2) {
36
- var e2 = ["th", "st", "nd", "rd"], n2 = t2 % 100;
37
- return "[" + t2 + (e2[(n2 - 20) % 10] || e2[n2] || e2[0]) + "]";
38
- } }, m = function(t2, e2, n2) {
39
- var r2 = String(t2);
40
- return !r2 || r2.length >= e2 ? t2 : "" + Array(e2 + 1 - r2.length).join(n2) + t2;
41
- }, v = { s: m, z: function(t2) {
42
- var e2 = -t2.utcOffset(), n2 = Math.abs(e2), r2 = Math.floor(n2 / 60), i2 = n2 % 60;
43
- return (e2 <= 0 ? "+" : "-") + m(r2, 2, "0") + ":" + m(i2, 2, "0");
44
- }, m: function t2(e2, n2) {
45
- if (e2.date() < n2.date())
46
- return -t2(n2, e2);
47
- var r2 = 12 * (n2.year() - e2.year()) + (n2.month() - e2.month()), i2 = e2.clone().add(r2, c), s2 = n2 - i2 < 0, u2 = e2.clone().add(r2 + (s2 ? -1 : 1), c);
48
- return +(-(r2 + (n2 - i2) / (s2 ? i2 - u2 : u2 - i2)) || 0);
49
- }, a: function(t2) {
50
- return t2 < 0 ? Math.ceil(t2) || 0 : Math.floor(t2);
51
- }, p: function(t2) {
52
- return { M: c, y: h, w: o, d: a, D: d, h: u, m: s, s: i, ms: r, Q: f }[t2] || String(t2 || "").toLowerCase().replace(/s$/, "");
53
- }, u: function(t2) {
54
- return void 0 === t2;
55
- } }, g = "en", D = {};
56
- D[g] = M;
57
- var p = "$isDayjsObject", S = function(t2) {
58
- return t2 instanceof _ || !(!t2 || !t2[p]);
59
- }, w = function t2(e2, n2, r2) {
60
- var i2;
61
- if (!e2)
62
- return g;
63
- if ("string" == typeof e2) {
64
- var s2 = e2.toLowerCase();
65
- D[s2] && (i2 = s2), n2 && (D[s2] = n2, i2 = s2);
66
- var u2 = e2.split("-");
67
- if (!i2 && u2.length > 1)
68
- return t2(u2[0]);
69
- } else {
70
- var a2 = e2.name;
71
- D[a2] = e2, i2 = a2;
72
- }
73
- return !r2 && i2 && (g = i2), i2 || !r2 && g;
74
- }, O = function(t2, e2) {
75
- if (S(t2))
76
- return t2.clone();
77
- var n2 = "object" == typeof e2 ? e2 : {};
78
- return n2.date = t2, n2.args = arguments, new _(n2);
79
- }, b = v;
80
- b.l = w, b.i = S, b.w = function(t2, e2) {
81
- return O(t2, { locale: e2.$L, utc: e2.$u, x: e2.$x, $offset: e2.$offset });
82
- };
83
- var _ = function() {
84
- function M2(t2) {
85
- this.$L = w(t2.locale, null, true), this.parse(t2), this.$x = this.$x || t2.x || {}, this[p] = true;
17
+ Object.defineProperty(exports, "__esModule", {
18
+ value: true
19
+ });
20
+ Object.defineProperty(exports, "default", {
21
+ enumerable: true,
22
+ get: function() {
23
+ return reporter_default;
86
24
  }
87
- var m2 = M2.prototype;
88
- return m2.parse = function(t2) {
89
- this.$d = function(t3) {
90
- var e2 = t3.date, n2 = t3.utc;
91
- if (null === e2)
92
- return /* @__PURE__ */ new Date(NaN);
93
- if (b.u(e2))
94
- return /* @__PURE__ */ new Date();
95
- if (e2 instanceof Date)
96
- return new Date(e2);
97
- if ("string" == typeof e2 && !/Z$/i.test(e2)) {
98
- var r2 = e2.match($);
99
- if (r2) {
100
- var i2 = r2[2] - 1 || 0, s2 = (r2[7] || "0").substring(0, 3);
101
- return n2 ? new Date(Date.UTC(r2[1], i2, r2[3] || 1, r2[4] || 0, r2[5] || 0, r2[6] || 0, s2)) : new Date(r2[1], i2, r2[3] || 1, r2[4] || 0, r2[5] || 0, r2[6] || 0, s2);
102
- }
103
- }
104
- return new Date(e2);
105
- }(t2), this.init();
106
- }, m2.init = function() {
107
- var t2 = this.$d;
108
- this.$y = t2.getFullYear(), this.$M = t2.getMonth(), this.$D = t2.getDate(), this.$W = t2.getDay(), this.$H = t2.getHours(), this.$m = t2.getMinutes(), this.$s = t2.getSeconds(), this.$ms = t2.getMilliseconds();
109
- }, m2.$utils = function() {
110
- return b;
111
- }, m2.isValid = function() {
112
- return !(this.$d.toString() === l);
113
- }, m2.isSame = function(t2, e2) {
114
- var n2 = O(t2);
115
- return this.startOf(e2) <= n2 && n2 <= this.endOf(e2);
116
- }, m2.isAfter = function(t2, e2) {
117
- return O(t2) < this.startOf(e2);
118
- }, m2.isBefore = function(t2, e2) {
119
- return this.endOf(e2) < O(t2);
120
- }, m2.$g = function(t2, e2, n2) {
121
- return b.u(t2) ? this[e2] : this.set(n2, t2);
122
- }, m2.unix = function() {
123
- return Math.floor(this.valueOf() / 1e3);
124
- }, m2.valueOf = function() {
125
- return this.$d.getTime();
126
- }, m2.startOf = function(t2, e2) {
127
- var n2 = this, r2 = !!b.u(e2) || e2, f2 = b.p(t2), l2 = function(t3, e3) {
128
- var i2 = b.w(n2.$u ? Date.UTC(n2.$y, e3, t3) : new Date(n2.$y, e3, t3), n2);
129
- return r2 ? i2 : i2.endOf(a);
130
- }, $2 = function(t3, e3) {
131
- return b.w(n2.toDate()[t3].apply(n2.toDate("s"), (r2 ? [0, 0, 0, 0] : [23, 59, 59, 999]).slice(e3)), n2);
132
- }, y2 = this.$W, M3 = this.$M, m3 = this.$D, v2 = "set" + (this.$u ? "UTC" : "");
133
- switch (f2) {
134
- case h:
135
- return r2 ? l2(1, 0) : l2(31, 11);
136
- case c:
137
- return r2 ? l2(1, M3) : l2(0, M3 + 1);
138
- case o:
139
- var g2 = this.$locale().weekStart || 0, D2 = (y2 < g2 ? y2 + 7 : y2) - g2;
140
- return l2(r2 ? m3 - D2 : m3 + (6 - D2), M3);
141
- case a:
142
- case d:
143
- return $2(v2 + "Hours", 0);
144
- case u:
145
- return $2(v2 + "Minutes", 1);
146
- case s:
147
- return $2(v2 + "Seconds", 2);
148
- case i:
149
- return $2(v2 + "Milliseconds", 3);
150
- default:
151
- return this.clone();
152
- }
153
- }, m2.endOf = function(t2) {
154
- return this.startOf(t2, false);
155
- }, m2.$set = function(t2, e2) {
156
- var n2, o2 = b.p(t2), f2 = "set" + (this.$u ? "UTC" : ""), l2 = (n2 = {}, n2[a] = f2 + "Date", n2[d] = f2 + "Date", n2[c] = f2 + "Month", n2[h] = f2 + "FullYear", n2[u] = f2 + "Hours", n2[s] = f2 + "Minutes", n2[i] = f2 + "Seconds", n2[r] = f2 + "Milliseconds", n2)[o2], $2 = o2 === a ? this.$D + (e2 - this.$W) : e2;
157
- if (o2 === c || o2 === h) {
158
- var y2 = this.clone().set(d, 1);
159
- y2.$d[l2]($2), y2.init(), this.$d = y2.set(d, Math.min(this.$D, y2.daysInMonth())).$d;
160
- } else
161
- l2 && this.$d[l2]($2);
162
- return this.init(), this;
163
- }, m2.set = function(t2, e2) {
164
- return this.clone().$set(t2, e2);
165
- }, m2.get = function(t2) {
166
- return this[b.p(t2)]();
167
- }, m2.add = function(r2, f2) {
168
- var d2, l2 = this;
169
- r2 = Number(r2);
170
- var $2 = b.p(f2), y2 = function(t2) {
171
- var e2 = O(l2);
172
- return b.w(e2.date(e2.date() + Math.round(t2 * r2)), l2);
173
- };
174
- if ($2 === c)
175
- return this.set(c, this.$M + r2);
176
- if ($2 === h)
177
- return this.set(h, this.$y + r2);
178
- if ($2 === a)
179
- return y2(1);
180
- if ($2 === o)
181
- return y2(7);
182
- var M3 = (d2 = {}, d2[s] = e, d2[u] = n, d2[i] = t, d2)[$2] || 1, m3 = this.$d.getTime() + r2 * M3;
183
- return b.w(m3, this);
184
- }, m2.subtract = function(t2, e2) {
185
- return this.add(-1 * t2, e2);
186
- }, m2.format = function(t2) {
187
- var e2 = this, n2 = this.$locale();
188
- if (!this.isValid())
189
- return n2.invalidDate || l;
190
- var r2 = t2 || "YYYY-MM-DDTHH:mm:ssZ", i2 = b.z(this), s2 = this.$H, u2 = this.$m, a2 = this.$M, o2 = n2.weekdays, c2 = n2.months, f2 = n2.meridiem, h2 = function(t3, n3, i3, s3) {
191
- return t3 && (t3[n3] || t3(e2, r2)) || i3[n3].slice(0, s3);
192
- }, d2 = function(t3) {
193
- return b.s(s2 % 12 || 12, t3, "0");
194
- }, $2 = f2 || function(t3, e3, n3) {
195
- var r3 = t3 < 12 ? "AM" : "PM";
196
- return n3 ? r3.toLowerCase() : r3;
197
- };
198
- return r2.replace(y, function(t3, r3) {
199
- return r3 || function(t4) {
200
- switch (t4) {
201
- case "YY":
202
- return String(e2.$y).slice(-2);
203
- case "YYYY":
204
- return b.s(e2.$y, 4, "0");
205
- case "M":
206
- return a2 + 1;
207
- case "MM":
208
- return b.s(a2 + 1, 2, "0");
209
- case "MMM":
210
- return h2(n2.monthsShort, a2, c2, 3);
211
- case "MMMM":
212
- return h2(c2, a2);
213
- case "D":
214
- return e2.$D;
215
- case "DD":
216
- return b.s(e2.$D, 2, "0");
217
- case "d":
218
- return String(e2.$W);
219
- case "dd":
220
- return h2(n2.weekdaysMin, e2.$W, o2, 2);
221
- case "ddd":
222
- return h2(n2.weekdaysShort, e2.$W, o2, 3);
223
- case "dddd":
224
- return o2[e2.$W];
225
- case "H":
226
- return String(s2);
227
- case "HH":
228
- return b.s(s2, 2, "0");
229
- case "h":
230
- return d2(1);
231
- case "hh":
232
- return d2(2);
233
- case "a":
234
- return $2(s2, u2, true);
235
- case "A":
236
- return $2(s2, u2, false);
237
- case "m":
238
- return String(u2);
239
- case "mm":
240
- return b.s(u2, 2, "0");
241
- case "s":
242
- return String(e2.$s);
243
- case "ss":
244
- return b.s(e2.$s, 2, "0");
245
- case "SSS":
246
- return b.s(e2.$ms, 3, "0");
247
- case "Z":
248
- return i2;
249
- }
250
- return null;
251
- }(t3) || i2.replace(":", "");
252
- });
253
- }, m2.utcOffset = function() {
254
- return 15 * -Math.round(this.$d.getTimezoneOffset() / 15);
255
- }, m2.diff = function(r2, d2, l2) {
256
- var $2, y2 = this, M3 = b.p(d2), m3 = O(r2), v2 = (m3.utcOffset() - this.utcOffset()) * e, g2 = this - m3, D2 = function() {
257
- return b.m(y2, m3);
258
- };
259
- switch (M3) {
260
- case h:
261
- $2 = D2() / 12;
262
- break;
263
- case c:
264
- $2 = D2();
265
- break;
266
- case f:
267
- $2 = D2() / 3;
268
- break;
269
- case o:
270
- $2 = (g2 - v2) / 6048e5;
271
- break;
272
- case a:
273
- $2 = (g2 - v2) / 864e5;
274
- break;
275
- case u:
276
- $2 = g2 / n;
277
- break;
278
- case s:
279
- $2 = g2 / e;
280
- break;
281
- case i:
282
- $2 = g2 / t;
283
- break;
284
- default:
285
- $2 = g2;
286
- }
287
- return l2 ? $2 : b.a($2);
288
- }, m2.daysInMonth = function() {
289
- return this.endOf(c).$D;
290
- }, m2.$locale = function() {
291
- return D[this.$L];
292
- }, m2.locale = function(t2, e2) {
293
- if (!t2)
294
- return this.$L;
295
- var n2 = this.clone(), r2 = w(t2, e2, true);
296
- return r2 && (n2.$L = r2), n2;
297
- }, m2.clone = function() {
298
- return b.w(this.$d, this);
299
- }, m2.toDate = function() {
300
- return new Date(this.valueOf());
301
- }, m2.toJSON = function() {
302
- return this.isValid() ? this.toISOString() : null;
303
- }, m2.toISOString = function() {
304
- return this.$d.toISOString();
305
- }, m2.toString = function() {
306
- return this.$d.toUTCString();
307
- }, M2;
308
- }(), k = _.prototype;
309
- return O.prototype = k, [["$ms", r], ["$s", i], ["$m", s], ["$H", u], ["$W", a], ["$M", c], ["$y", h], ["$D", d]].forEach(function(t2) {
310
- k[t2[1]] = function(e2) {
311
- return this.$g(e2, t2[0], t2[1]);
312
- };
313
- }), O.extend = function(t2, e2) {
314
- return t2.$i || (t2(e2, _, O), t2.$i = true), O;
315
- }, O.locale = w, O.isDayjs = S, O.unix = function(t2) {
316
- return O(1e3 * t2);
317
- }, O.en = D[g], O.Ls = D, O.p = {}, O;
318
25
  });
319
- }
320
- });
321
-
322
- // src/common/utils.ts
323
- var import_dayjs = __toESM(require_dayjs_min());
324
- import assert from "assert";
325
- import { randomUUID } from "crypto";
326
- import { readFileSync } from "fs";
327
- import path from "path";
328
- import { NodeType } from "@midscene/shared/constants";
329
- import { findNearestPackageJson } from "@midscene/shared/fs";
330
- import {
331
- base64Encoded,
332
- imageInfoOfBase64
333
- } from "@midscene/shared/img";
334
- import { compositeElementInfoImg } from "@midscene/shared/img";
335
- function reportFileName(tag = "web") {
336
- const dateTimeInFileName = (0, import_dayjs.default)().format("YYYY-MM-DD_HH-mm-ss-SSS");
337
- return `${tag}-${dateTimeInFileName}`;
338
- }
339
- function printReportMsg(filepath) {
340
- console.log("Midscene - report file updated:", filepath);
341
- }
342
-
343
- // src/playwright/reporter/index.ts
344
- import { writeDumpReport } from "@midscene/core/utils";
345
- function logger(...message) {
346
- if (process.env.DEBUG === "true") {
347
- console.log("Midscene e2e report:", ...message);
348
- }
349
- }
350
- var testDataList = [];
351
- var filename;
352
- function updateReport() {
353
- const reportPath = writeDumpReport(filename, testDataList);
354
- writeDumpReport("latest-playwright-report", testDataList);
355
- printReportMsg(reportPath);
356
- }
357
- var MidsceneReporter = class {
358
- async onBegin(config, suite) {
359
- if (!filename) {
360
- filename = reportFileName("playwright-merged");
26
+ _assert = /*#__PURE__*/ _interop_require_default(_assert);
27
+ _path = /*#__PURE__*/ _interop_require_default(_path);
28
+ function _interop_require_default(obj) {
29
+ return obj && obj.__esModule ? obj : {
30
+ default: obj
31
+ };
361
32
  }
362
- }
363
- onTestBegin(test, _result) {
364
- }
365
- onTestEnd(test, result) {
366
- const dumpAnnotation = test.annotations.find((annotation) => {
367
- return annotation.type === "MIDSCENE_DUMP_ANNOTATION";
368
- });
369
- if (!(dumpAnnotation == null ? void 0 : dumpAnnotation.description))
370
- return;
371
- testDataList.push({
372
- dumpString: dumpAnnotation.description,
373
- attributes: {
374
- playwright_test_title: test.title,
375
- playwright_test_status: result.status,
376
- playwright_test_duration: result.duration
377
- }
33
+ var __create = Object.create;
34
+ var __defProp = Object.defineProperty;
35
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
36
+ var __getOwnPropNames = Object.getOwnPropertyNames;
37
+ var __getProtoOf = Object.getPrototypeOf;
38
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
39
+ var __commonJS = (cb, mod)=>function __require() {
40
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = {
41
+ exports: {}
42
+ }).exports, mod), mod.exports;
43
+ };
44
+ var __copyProps = (to, from, except, desc)=>{
45
+ if (from && typeof from === "object" || typeof from === "function") {
46
+ for (let key of __getOwnPropNames(from))if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
47
+ get: ()=>from[key],
48
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
49
+ });
50
+ }
51
+ return to;
52
+ };
53
+ var __toESM = (mod, isNodeMode, target)=>(target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(// If the importer is in node compatibility mode or this is not an ESM
54
+ // file that has been converted to a CommonJS file using a Babel-
55
+ // compatible transform (i.e. "__esModule" has not been set), then set
56
+ // "default" to the CommonJS "module.exports" for node compatibility.
57
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
58
+ value: mod,
59
+ enumerable: true
60
+ }) : target, mod));
61
+ var __async = (__this, __arguments, generator)=>{
62
+ return new Promise((resolve, reject)=>{
63
+ var fulfilled = (value)=>{
64
+ try {
65
+ step(generator.next(value));
66
+ } catch (e) {
67
+ reject(e);
68
+ }
69
+ };
70
+ var rejected = (value)=>{
71
+ try {
72
+ step(generator.throw(value));
73
+ } catch (e) {
74
+ reject(e);
75
+ }
76
+ };
77
+ var step = (x)=>x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
78
+ step((generator = generator.apply(__this, __arguments)).next());
79
+ });
80
+ };
81
+ // ../../node_modules/.pnpm/dayjs@1.11.11/node_modules/dayjs/dayjs.min.js
82
+ var require_dayjs_min = __commonJS({
83
+ "../../node_modules/.pnpm/dayjs@1.11.11/node_modules/dayjs/dayjs.min.js" (exports, module1) {
84
+ "use strict";
85
+ !function(t, e) {
86
+ "object" == typeof exports && "undefined" != typeof module1 ? module1.exports = e() : "function" == typeof define && define.amd ? define(e) : (t = "undefined" != typeof globalThis ? globalThis : t || self).dayjs = e();
87
+ }(exports, function() {
88
+ "use strict";
89
+ var t = 1e3, e = 6e4, n = 36e5, r = "millisecond", i = "second", s = "minute", u = "hour", a = "day", o = "week", c = "month", f = "quarter", h = "year", d = "date", l = "Invalid Date", $ = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/, y = /\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g, M = {
90
+ name: "en",
91
+ weekdays: "Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),
92
+ months: "January_February_March_April_May_June_July_August_September_October_November_December".split("_"),
93
+ ordinal: function(t2) {
94
+ var e2 = [
95
+ "th",
96
+ "st",
97
+ "nd",
98
+ "rd"
99
+ ], n2 = t2 % 100;
100
+ return "[" + t2 + (e2[(n2 - 20) % 10] || e2[n2] || e2[0]) + "]";
101
+ }
102
+ }, m = function(t2, e2, n2) {
103
+ var r2 = String(t2);
104
+ return !r2 || r2.length >= e2 ? t2 : "" + Array(e2 + 1 - r2.length).join(n2) + t2;
105
+ }, v = {
106
+ s: m,
107
+ z: function(t2) {
108
+ var e2 = -t2.utcOffset(), n2 = Math.abs(e2), r2 = Math.floor(n2 / 60), i2 = n2 % 60;
109
+ return (e2 <= 0 ? "+" : "-") + m(r2, 2, "0") + ":" + m(i2, 2, "0");
110
+ },
111
+ m: function t2(e2, n2) {
112
+ if (e2.date() < n2.date()) return -t2(n2, e2);
113
+ var r2 = 12 * (n2.year() - e2.year()) + (n2.month() - e2.month()), i2 = e2.clone().add(r2, c), s2 = n2 - i2 < 0, u2 = e2.clone().add(r2 + (s2 ? -1 : 1), c);
114
+ return +(-(r2 + (n2 - i2) / (s2 ? i2 - u2 : u2 - i2)) || 0);
115
+ },
116
+ a: function(t2) {
117
+ return t2 < 0 ? Math.ceil(t2) || 0 : Math.floor(t2);
118
+ },
119
+ p: function(t2) {
120
+ return ({
121
+ M: c,
122
+ y: h,
123
+ w: o,
124
+ d: a,
125
+ D: d,
126
+ h: u,
127
+ m: s,
128
+ s: i,
129
+ ms: r,
130
+ Q: f
131
+ })[t2] || String(t2 || "").toLowerCase().replace(/s$/, "");
132
+ },
133
+ u: function(t2) {
134
+ return void 0 === t2;
135
+ }
136
+ }, g = "en", D = {};
137
+ D[g] = M;
138
+ var p = "$isDayjsObject", S = function(t2) {
139
+ return t2 instanceof _ || !(!t2 || !t2[p]);
140
+ }, w = function t2(e2, n2, r2) {
141
+ var i2;
142
+ if (!e2) return g;
143
+ if ("string" == typeof e2) {
144
+ var s2 = e2.toLowerCase();
145
+ D[s2] && (i2 = s2), n2 && (D[s2] = n2, i2 = s2);
146
+ var u2 = e2.split("-");
147
+ if (!i2 && u2.length > 1) return t2(u2[0]);
148
+ } else {
149
+ var a2 = e2.name;
150
+ D[a2] = e2, i2 = a2;
151
+ }
152
+ return !r2 && i2 && (g = i2), i2 || !r2 && g;
153
+ }, O = function(t2, e2) {
154
+ if (S(t2)) return t2.clone();
155
+ var n2 = "object" == typeof e2 ? e2 : {};
156
+ return n2.date = t2, n2.args = arguments, new _(n2);
157
+ }, b = v;
158
+ b.l = w, b.i = S, b.w = function(t2, e2) {
159
+ return O(t2, {
160
+ locale: e2.$L,
161
+ utc: e2.$u,
162
+ x: e2.$x,
163
+ $offset: e2.$offset
164
+ });
165
+ };
166
+ var _ = function() {
167
+ function M2(t2) {
168
+ this.$L = w(t2.locale, null, true), this.parse(t2), this.$x = this.$x || t2.x || {}, this[p] = true;
169
+ }
170
+ var m2 = M2.prototype;
171
+ return m2.parse = function(t2) {
172
+ this.$d = function(t3) {
173
+ var e2 = t3.date, n2 = t3.utc;
174
+ if (null === e2) return /* @__PURE__ */ new Date(NaN);
175
+ if (b.u(e2)) return /* @__PURE__ */ new Date();
176
+ if (e2 instanceof Date) return new Date(e2);
177
+ if ("string" == typeof e2 && !/Z$/i.test(e2)) {
178
+ var r2 = e2.match($);
179
+ if (r2) {
180
+ var i2 = r2[2] - 1 || 0, s2 = (r2[7] || "0").substring(0, 3);
181
+ return n2 ? new Date(Date.UTC(r2[1], i2, r2[3] || 1, r2[4] || 0, r2[5] || 0, r2[6] || 0, s2)) : new Date(r2[1], i2, r2[3] || 1, r2[4] || 0, r2[5] || 0, r2[6] || 0, s2);
182
+ }
183
+ }
184
+ return new Date(e2);
185
+ }(t2), this.init();
186
+ }, m2.init = function() {
187
+ var t2 = this.$d;
188
+ this.$y = t2.getFullYear(), this.$M = t2.getMonth(), this.$D = t2.getDate(), this.$W = t2.getDay(), this.$H = t2.getHours(), this.$m = t2.getMinutes(), this.$s = t2.getSeconds(), this.$ms = t2.getMilliseconds();
189
+ }, m2.$utils = function() {
190
+ return b;
191
+ }, m2.isValid = function() {
192
+ return !(this.$d.toString() === l);
193
+ }, m2.isSame = function(t2, e2) {
194
+ var n2 = O(t2);
195
+ return this.startOf(e2) <= n2 && n2 <= this.endOf(e2);
196
+ }, m2.isAfter = function(t2, e2) {
197
+ return O(t2) < this.startOf(e2);
198
+ }, m2.isBefore = function(t2, e2) {
199
+ return this.endOf(e2) < O(t2);
200
+ }, m2.$g = function(t2, e2, n2) {
201
+ return b.u(t2) ? this[e2] : this.set(n2, t2);
202
+ }, m2.unix = function() {
203
+ return Math.floor(this.valueOf() / 1e3);
204
+ }, m2.valueOf = function() {
205
+ return this.$d.getTime();
206
+ }, m2.startOf = function(t2, e2) {
207
+ var n2 = this, r2 = !!b.u(e2) || e2, f2 = b.p(t2), l2 = function(t3, e3) {
208
+ var i2 = b.w(n2.$u ? Date.UTC(n2.$y, e3, t3) : new Date(n2.$y, e3, t3), n2);
209
+ return r2 ? i2 : i2.endOf(a);
210
+ }, $2 = function(t3, e3) {
211
+ return b.w(n2.toDate()[t3].apply(n2.toDate("s"), (r2 ? [
212
+ 0,
213
+ 0,
214
+ 0,
215
+ 0
216
+ ] : [
217
+ 23,
218
+ 59,
219
+ 59,
220
+ 999
221
+ ]).slice(e3)), n2);
222
+ }, y2 = this.$W, M3 = this.$M, m3 = this.$D, v2 = "set" + (this.$u ? "UTC" : "");
223
+ switch(f2){
224
+ case h:
225
+ return r2 ? l2(1, 0) : l2(31, 11);
226
+ case c:
227
+ return r2 ? l2(1, M3) : l2(0, M3 + 1);
228
+ case o:
229
+ var g2 = this.$locale().weekStart || 0, D2 = (y2 < g2 ? y2 + 7 : y2) - g2;
230
+ return l2(r2 ? m3 - D2 : m3 + (6 - D2), M3);
231
+ case a:
232
+ case d:
233
+ return $2(v2 + "Hours", 0);
234
+ case u:
235
+ return $2(v2 + "Minutes", 1);
236
+ case s:
237
+ return $2(v2 + "Seconds", 2);
238
+ case i:
239
+ return $2(v2 + "Milliseconds", 3);
240
+ default:
241
+ return this.clone();
242
+ }
243
+ }, m2.endOf = function(t2) {
244
+ return this.startOf(t2, false);
245
+ }, m2.$set = function(t2, e2) {
246
+ var n2, o2 = b.p(t2), f2 = "set" + (this.$u ? "UTC" : ""), l2 = (n2 = {}, n2[a] = f2 + "Date", n2[d] = f2 + "Date", n2[c] = f2 + "Month", n2[h] = f2 + "FullYear", n2[u] = f2 + "Hours", n2[s] = f2 + "Minutes", n2[i] = f2 + "Seconds", n2[r] = f2 + "Milliseconds", n2)[o2], $2 = o2 === a ? this.$D + (e2 - this.$W) : e2;
247
+ if (o2 === c || o2 === h) {
248
+ var y2 = this.clone().set(d, 1);
249
+ y2.$d[l2]($2), y2.init(), this.$d = y2.set(d, Math.min(this.$D, y2.daysInMonth())).$d;
250
+ } else l2 && this.$d[l2]($2);
251
+ return this.init(), this;
252
+ }, m2.set = function(t2, e2) {
253
+ return this.clone().$set(t2, e2);
254
+ }, m2.get = function(t2) {
255
+ return this[b.p(t2)]();
256
+ }, m2.add = function(r2, f2) {
257
+ var d2, l2 = this;
258
+ r2 = Number(r2);
259
+ var $2 = b.p(f2), y2 = function(t2) {
260
+ var e2 = O(l2);
261
+ return b.w(e2.date(e2.date() + Math.round(t2 * r2)), l2);
262
+ };
263
+ if ($2 === c) return this.set(c, this.$M + r2);
264
+ if ($2 === h) return this.set(h, this.$y + r2);
265
+ if ($2 === a) return y2(1);
266
+ if ($2 === o) return y2(7);
267
+ var M3 = (d2 = {}, d2[s] = e, d2[u] = n, d2[i] = t, d2)[$2] || 1, m3 = this.$d.getTime() + r2 * M3;
268
+ return b.w(m3, this);
269
+ }, m2.subtract = function(t2, e2) {
270
+ return this.add(-1 * t2, e2);
271
+ }, m2.format = function(t2) {
272
+ var e2 = this, n2 = this.$locale();
273
+ if (!this.isValid()) return n2.invalidDate || l;
274
+ var r2 = t2 || "YYYY-MM-DDTHH:mm:ssZ", i2 = b.z(this), s2 = this.$H, u2 = this.$m, a2 = this.$M, o2 = n2.weekdays, c2 = n2.months, f2 = n2.meridiem, h2 = function(t3, n3, i3, s3) {
275
+ return t3 && (t3[n3] || t3(e2, r2)) || i3[n3].slice(0, s3);
276
+ }, d2 = function(t3) {
277
+ return b.s(s2 % 12 || 12, t3, "0");
278
+ }, $2 = f2 || function(t3, e3, n3) {
279
+ var r3 = t3 < 12 ? "AM" : "PM";
280
+ return n3 ? r3.toLowerCase() : r3;
281
+ };
282
+ return r2.replace(y, function(t3, r3) {
283
+ return r3 || function(t4) {
284
+ switch(t4){
285
+ case "YY":
286
+ return String(e2.$y).slice(-2);
287
+ case "YYYY":
288
+ return b.s(e2.$y, 4, "0");
289
+ case "M":
290
+ return a2 + 1;
291
+ case "MM":
292
+ return b.s(a2 + 1, 2, "0");
293
+ case "MMM":
294
+ return h2(n2.monthsShort, a2, c2, 3);
295
+ case "MMMM":
296
+ return h2(c2, a2);
297
+ case "D":
298
+ return e2.$D;
299
+ case "DD":
300
+ return b.s(e2.$D, 2, "0");
301
+ case "d":
302
+ return String(e2.$W);
303
+ case "dd":
304
+ return h2(n2.weekdaysMin, e2.$W, o2, 2);
305
+ case "ddd":
306
+ return h2(n2.weekdaysShort, e2.$W, o2, 3);
307
+ case "dddd":
308
+ return o2[e2.$W];
309
+ case "H":
310
+ return String(s2);
311
+ case "HH":
312
+ return b.s(s2, 2, "0");
313
+ case "h":
314
+ return d2(1);
315
+ case "hh":
316
+ return d2(2);
317
+ case "a":
318
+ return $2(s2, u2, true);
319
+ case "A":
320
+ return $2(s2, u2, false);
321
+ case "m":
322
+ return String(u2);
323
+ case "mm":
324
+ return b.s(u2, 2, "0");
325
+ case "s":
326
+ return String(e2.$s);
327
+ case "ss":
328
+ return b.s(e2.$s, 2, "0");
329
+ case "SSS":
330
+ return b.s(e2.$ms, 3, "0");
331
+ case "Z":
332
+ return i2;
333
+ }
334
+ return null;
335
+ }(t3) || i2.replace(":", "");
336
+ });
337
+ }, m2.utcOffset = function() {
338
+ return 15 * -Math.round(this.$d.getTimezoneOffset() / 15);
339
+ }, m2.diff = function(r2, d2, l2) {
340
+ var $2, y2 = this, M3 = b.p(d2), m3 = O(r2), v2 = (m3.utcOffset() - this.utcOffset()) * e, g2 = this - m3, D2 = function() {
341
+ return b.m(y2, m3);
342
+ };
343
+ switch(M3){
344
+ case h:
345
+ $2 = D2() / 12;
346
+ break;
347
+ case c:
348
+ $2 = D2();
349
+ break;
350
+ case f:
351
+ $2 = D2() / 3;
352
+ break;
353
+ case o:
354
+ $2 = (g2 - v2) / 6048e5;
355
+ break;
356
+ case a:
357
+ $2 = (g2 - v2) / 864e5;
358
+ break;
359
+ case u:
360
+ $2 = g2 / n;
361
+ break;
362
+ case s:
363
+ $2 = g2 / e;
364
+ break;
365
+ case i:
366
+ $2 = g2 / t;
367
+ break;
368
+ default:
369
+ $2 = g2;
370
+ }
371
+ return l2 ? $2 : b.a($2);
372
+ }, m2.daysInMonth = function() {
373
+ return this.endOf(c).$D;
374
+ }, m2.$locale = function() {
375
+ return D[this.$L];
376
+ }, m2.locale = function(t2, e2) {
377
+ if (!t2) return this.$L;
378
+ var n2 = this.clone(), r2 = w(t2, e2, true);
379
+ return r2 && (n2.$L = r2), n2;
380
+ }, m2.clone = function() {
381
+ return b.w(this.$d, this);
382
+ }, m2.toDate = function() {
383
+ return new Date(this.valueOf());
384
+ }, m2.toJSON = function() {
385
+ return this.isValid() ? this.toISOString() : null;
386
+ }, m2.toISOString = function() {
387
+ return this.$d.toISOString();
388
+ }, m2.toString = function() {
389
+ return this.$d.toUTCString();
390
+ }, M2;
391
+ }(), k = _.prototype;
392
+ return O.prototype = k, [
393
+ [
394
+ "$ms",
395
+ r
396
+ ],
397
+ [
398
+ "$s",
399
+ i
400
+ ],
401
+ [
402
+ "$m",
403
+ s
404
+ ],
405
+ [
406
+ "$H",
407
+ u
408
+ ],
409
+ [
410
+ "$W",
411
+ a
412
+ ],
413
+ [
414
+ "$M",
415
+ c
416
+ ],
417
+ [
418
+ "$y",
419
+ h
420
+ ],
421
+ [
422
+ "$D",
423
+ d
424
+ ]
425
+ ].forEach(function(t2) {
426
+ k[t2[1]] = function(e2) {
427
+ return this.$g(e2, t2[0], t2[1]);
428
+ };
429
+ }), O.extend = function(t2, e2) {
430
+ return t2.$i || (t2(e2, _, O), t2.$i = true), O;
431
+ }, O.locale = w, O.isDayjs = S, O.unix = function(t2) {
432
+ return O(1e3 * t2);
433
+ }, O.en = D[g], O.Ls = D, O.p = {}, O;
434
+ });
435
+ }
378
436
  });
379
- updateReport();
380
- }
381
- onEnd(result) {
382
- updateReport();
383
- logger(`Finished the run: ${result.status}`);
384
- }
385
- };
386
- var reporter_default = MidsceneReporter;
387
- export {
388
- reporter_default as default
389
- };
437
+ // src/common/utils.ts
438
+ var import_dayjs = __toESM(require_dayjs_min());
439
+ function reportFileName(tag = "web") {
440
+ const dateTimeInFileName = (0, import_dayjs.default)().format("YYYY-MM-DD_HH-mm-ss-SSS");
441
+ return `${tag}-${dateTimeInFileName}`;
442
+ }
443
+ function printReportMsg(filepath) {
444
+ console.log("Midscene - report file updated:", filepath);
445
+ }
446
+ function logger(...message) {
447
+ if (process.env.DEBUG === "true") {
448
+ console.log("Midscene e2e report:", ...message);
449
+ }
450
+ }
451
+ var testDataList = [];
452
+ var filename;
453
+ function updateReport() {
454
+ const reportPath = (0, _utils1.writeDumpReport)(filename, testDataList);
455
+ reportPath && printReportMsg(reportPath);
456
+ }
457
+ var MidsceneReporter = class {
458
+ onBegin(config, suite) {
459
+ return __async(this, null, function*() {
460
+ if (!filename) {
461
+ filename = reportFileName("playwright-merged");
462
+ }
463
+ });
464
+ }
465
+ onTestBegin(test, _result) {}
466
+ onTestEnd(test, result) {
467
+ const dumpAnnotation = test.annotations.find((annotation)=>{
468
+ return annotation.type === "MIDSCENE_DUMP_ANNOTATION";
469
+ });
470
+ if (!(dumpAnnotation == null ? void 0 : dumpAnnotation.description)) return;
471
+ testDataList.push({
472
+ dumpString: dumpAnnotation.description,
473
+ attributes: {
474
+ playwright_test_title: test.title,
475
+ playwright_test_status: result.status,
476
+ playwright_test_duration: result.duration
477
+ }
478
+ });
479
+ updateReport();
480
+ }
481
+ onEnd(result) {
482
+ updateReport();
483
+ logger(`Finished the run: ${result.status}`);
484
+ }
485
+ };
486
+ var reporter_default = MidsceneReporter;
487
+ });