@chromatic-com/vitest 1.0.1 → 1.0.3

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.
@@ -0,0 +1,2632 @@
1
+ import { a as outputFile, c as truncateFileName, i as ensureDir, o as outputJSONFile, s as removeLocalhostFromBaseUrl, t as DEFAULT_OUTPUT_DIR } from "./constants-Dos4OOMt.mjs";
2
+ import { c as TELEMETRY_LOG_FILE, i as cleanTelemetryLogFiles, o as setupTelemetryCleanup, r as trackEvent, s as resolveTelemetryOptions, t as TelemetryReporter } from "./telemetry-Db1MVI-S.mjs";
3
+ import { createRequire } from "node:module";
4
+ import { existsSync, readFileSync, readdirSync, rmSync } from "node:fs";
5
+ import path, { dirname, join, relative, resolve, sep } from "node:path";
6
+ import { createHash } from "node:crypto";
7
+ import { mkdir, readFile, readdir, rm, writeFile } from "node:fs/promises";
8
+ import { storyNameFromExport, toId } from "storybook/internal/csf";
9
+ import colors from "tinyrainbow";
10
+ import { isCSSRequest, version } from "vitest/node";
11
+ import assert from "node:assert";
12
+
13
+ //#region \0rolldown/runtime.js
14
+ var __create = Object.create;
15
+ var __defProp = Object.defineProperty;
16
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
17
+ var __getOwnPropNames = Object.getOwnPropertyNames;
18
+ var __getProtoOf = Object.getPrototypeOf;
19
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
20
+ var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
21
+ var __copyProps = (to, from, except, desc) => {
22
+ if (from && typeof from === "object" || typeof from === "function") {
23
+ for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
24
+ key = keys[i];
25
+ if (!__hasOwnProp.call(to, key) && key !== except) {
26
+ __defProp(to, key, {
27
+ get: ((k) => from[k]).bind(null, key),
28
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
29
+ });
30
+ }
31
+ }
32
+ }
33
+ return to;
34
+ };
35
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
36
+ value: mod,
37
+ enumerable: true
38
+ }) : target, mod));
39
+
40
+ //#endregion
41
+ //#region ../shared/src/utils/logger.ts
42
+ const logger = process.env.LOG ? console : {
43
+ log: (..._args) => {},
44
+ warn: (..._args) => {}
45
+ };
46
+
47
+ //#endregion
48
+ //#region ../shared/src/resource-archiver/index.ts
49
+ var ResourceArchiver = class {
50
+ archive = {};
51
+ client;
52
+ assetDomains;
53
+ firstUrl;
54
+ httpCredentials;
55
+ pendingRequests = /* @__PURE__ */ new Set();
56
+ constructor(cdpClient, allowedDomains, httpCredentials, firstUrl) {
57
+ this.client = cdpClient;
58
+ this.httpCredentials = httpCredentials;
59
+ this.firstUrl = firstUrl;
60
+ this.assetDomains = (allowedDomains || []).map((domain) => {
61
+ if (domain.startsWith("http")) return domain;
62
+ return `https://${domain}`;
63
+ });
64
+ }
65
+ async watch() {
66
+ this.client.on("Fetch.requestPaused", this.requestPaused);
67
+ this.client.on("Fetch.authRequired", this.authRequired);
68
+ await this.client.send("Fetch.enable", { handleAuthRequests: true });
69
+ }
70
+ async unwatch() {
71
+ this.client.off?.("Fetch.requestPaused", this.requestPaused);
72
+ this.client.off?.("Fetch.authRequired", this.authRequired);
73
+ await this.client.send("Fetch.disable");
74
+ this.pendingRequests.clear();
75
+ }
76
+ getPendingRequestsCount() {
77
+ return this.pendingRequests.size;
78
+ }
79
+ async clientSend(request, method, params) {
80
+ try {
81
+ return await this.client.send(method, params);
82
+ } catch (error) {
83
+ logger.log("Client error", request.url, error);
84
+ this.archive[request.url] = { error };
85
+ return null;
86
+ }
87
+ }
88
+ authRequired = async ({ requestId, request }) => {
89
+ await this.clientSend(request, "Fetch.continueWithAuth", {
90
+ requestId,
91
+ authChallengeResponse: {
92
+ response: "ProvideCredentials",
93
+ ...this.httpCredentials
94
+ }
95
+ });
96
+ };
97
+ requestPaused = async ({ requestId, request, responseStatusCode, responseStatusText, responseErrorReason, responseHeaders }) => {
98
+ this.pendingRequests.delete(requestId);
99
+ if (!request.method.match(/get/i)) {
100
+ await this.clientSend(request, "Fetch.continueRequest", { requestId });
101
+ return;
102
+ }
103
+ if (responseStatusCode === 304) {
104
+ await this.clientSend(request, "Fetch.continueRequest", { requestId });
105
+ return;
106
+ }
107
+ const requestUrl = new URL(request.url);
108
+ this.firstUrl ??= requestUrl;
109
+ const isRequestFromAllowedDomain = requestUrl.origin === this.firstUrl.origin || this.assetDomains.includes(requestUrl.origin);
110
+ logger.log("requestPaused", requestUrl.toString(), responseStatusCode || responseErrorReason ? "response" : "request", this.firstUrl.toString(), isRequestFromAllowedDomain);
111
+ if (responseErrorReason) {
112
+ logger.log(`Got response error: ${responseErrorReason}`);
113
+ await this.clientSend(request, "Fetch.continueRequest", { requestId });
114
+ return;
115
+ }
116
+ if (responseStatusCode) {
117
+ await this.handleSuccessfulResponse({
118
+ request,
119
+ requestId,
120
+ responseStatusCode,
121
+ responseStatusText,
122
+ responseHeaders
123
+ }, requestUrl, isRequestFromAllowedDomain);
124
+ return;
125
+ }
126
+ this.pendingRequests.add(requestId);
127
+ await this.clientSend(request, "Fetch.continueRequest", {
128
+ requestId,
129
+ interceptResponse: true
130
+ });
131
+ };
132
+ async handleSuccessfulResponse(requestPausedPayload, requestUrl, isRequestFromAllowedDomain) {
133
+ const { request, requestId, responseStatusCode, responseStatusText, responseHeaders } = requestPausedPayload;
134
+ if ([
135
+ 301,
136
+ 302,
137
+ 303,
138
+ 307,
139
+ 308
140
+ ].includes(responseStatusCode)) {
141
+ await this.clientSend(request, "Fetch.continueRequest", {
142
+ requestId,
143
+ interceptResponse: true
144
+ });
145
+ return;
146
+ }
147
+ const result = await this.clientSend(request, "Fetch.getResponseBody", { requestId });
148
+ if (result === null) return;
149
+ const { body, base64Encoded } = result;
150
+ const contentTypeHeader = responseHeaders.find(({ name }) => name.toLowerCase() === "content-type");
151
+ const isFirstRequest = requestUrl.toString() === this.firstUrl.toString();
152
+ if (isRequestFromAllowedDomain && !isFirstRequest) {
153
+ logger.log("Archiving request", {
154
+ url: request.url,
155
+ statusCode: responseStatusCode,
156
+ statusText: responseStatusText,
157
+ contentType: contentTypeHeader?.value
158
+ });
159
+ this.archive[request.url] = {
160
+ statusCode: responseStatusCode,
161
+ statusText: responseStatusText,
162
+ body: Buffer.from(body, base64Encoded ? "base64" : "utf8"),
163
+ contentType: contentTypeHeader?.value
164
+ };
165
+ } else logger.log("Skipping archiving of request", {
166
+ url: request.url,
167
+ firstUrl: this.firstUrl.toString(),
168
+ isFirstRequest,
169
+ isRequestFromAllowedDomain
170
+ });
171
+ await this.clientSend(request, "Fetch.continueRequest", { requestId });
172
+ }
173
+ };
174
+
175
+ //#endregion
176
+ //#region ../../node_modules/.pnpm/mime@3.0.0/node_modules/mime/Mime.js
177
+ var require_Mime = /* @__PURE__ */ __commonJSMin(((exports, module) => {
178
+ function Mime() {
179
+ this._types = Object.create(null);
180
+ this._extensions = Object.create(null);
181
+ for (let i = 0; i < arguments.length; i++) this.define(arguments[i]);
182
+ this.define = this.define.bind(this);
183
+ this.getType = this.getType.bind(this);
184
+ this.getExtension = this.getExtension.bind(this);
185
+ }
186
+ Mime.prototype.define = function(typeMap, force) {
187
+ for (let type in typeMap) {
188
+ let extensions = typeMap[type].map(function(t) {
189
+ return t.toLowerCase();
190
+ });
191
+ type = type.toLowerCase();
192
+ for (let i = 0; i < extensions.length; i++) {
193
+ const ext = extensions[i];
194
+ if (ext[0] === "*") continue;
195
+ if (!force && ext in this._types) throw new Error("Attempt to change mapping for \"" + ext + "\" extension from \"" + this._types[ext] + "\" to \"" + type + "\". Pass `force=true` to allow this, otherwise remove \"" + ext + "\" from the list of extensions for \"" + type + "\".");
196
+ this._types[ext] = type;
197
+ }
198
+ if (force || !this._extensions[type]) {
199
+ const ext = extensions[0];
200
+ this._extensions[type] = ext[0] !== "*" ? ext : ext.substr(1);
201
+ }
202
+ }
203
+ };
204
+ Mime.prototype.getType = function(path) {
205
+ path = String(path);
206
+ let last = path.replace(/^.*[/\\]/, "").toLowerCase();
207
+ let ext = last.replace(/^.*\./, "").toLowerCase();
208
+ let hasPath = last.length < path.length;
209
+ return (ext.length < last.length - 1 || !hasPath) && this._types[ext] || null;
210
+ };
211
+ Mime.prototype.getExtension = function(type) {
212
+ type = /^\s*([^;\s]*)/.test(type) && RegExp.$1;
213
+ return type && this._extensions[type.toLowerCase()] || null;
214
+ };
215
+ module.exports = Mime;
216
+ }));
217
+
218
+ //#endregion
219
+ //#region ../../node_modules/.pnpm/mime@3.0.0/node_modules/mime/types/standard.js
220
+ var require_standard = /* @__PURE__ */ __commonJSMin(((exports, module) => {
221
+ module.exports = {
222
+ "application/andrew-inset": ["ez"],
223
+ "application/applixware": ["aw"],
224
+ "application/atom+xml": ["atom"],
225
+ "application/atomcat+xml": ["atomcat"],
226
+ "application/atomdeleted+xml": ["atomdeleted"],
227
+ "application/atomsvc+xml": ["atomsvc"],
228
+ "application/atsc-dwd+xml": ["dwd"],
229
+ "application/atsc-held+xml": ["held"],
230
+ "application/atsc-rsat+xml": ["rsat"],
231
+ "application/bdoc": ["bdoc"],
232
+ "application/calendar+xml": ["xcs"],
233
+ "application/ccxml+xml": ["ccxml"],
234
+ "application/cdfx+xml": ["cdfx"],
235
+ "application/cdmi-capability": ["cdmia"],
236
+ "application/cdmi-container": ["cdmic"],
237
+ "application/cdmi-domain": ["cdmid"],
238
+ "application/cdmi-object": ["cdmio"],
239
+ "application/cdmi-queue": ["cdmiq"],
240
+ "application/cu-seeme": ["cu"],
241
+ "application/dash+xml": ["mpd"],
242
+ "application/davmount+xml": ["davmount"],
243
+ "application/docbook+xml": ["dbk"],
244
+ "application/dssc+der": ["dssc"],
245
+ "application/dssc+xml": ["xdssc"],
246
+ "application/ecmascript": ["es", "ecma"],
247
+ "application/emma+xml": ["emma"],
248
+ "application/emotionml+xml": ["emotionml"],
249
+ "application/epub+zip": ["epub"],
250
+ "application/exi": ["exi"],
251
+ "application/express": ["exp"],
252
+ "application/fdt+xml": ["fdt"],
253
+ "application/font-tdpfr": ["pfr"],
254
+ "application/geo+json": ["geojson"],
255
+ "application/gml+xml": ["gml"],
256
+ "application/gpx+xml": ["gpx"],
257
+ "application/gxf": ["gxf"],
258
+ "application/gzip": ["gz"],
259
+ "application/hjson": ["hjson"],
260
+ "application/hyperstudio": ["stk"],
261
+ "application/inkml+xml": ["ink", "inkml"],
262
+ "application/ipfix": ["ipfix"],
263
+ "application/its+xml": ["its"],
264
+ "application/java-archive": [
265
+ "jar",
266
+ "war",
267
+ "ear"
268
+ ],
269
+ "application/java-serialized-object": ["ser"],
270
+ "application/java-vm": ["class"],
271
+ "application/javascript": ["js", "mjs"],
272
+ "application/json": ["json", "map"],
273
+ "application/json5": ["json5"],
274
+ "application/jsonml+json": ["jsonml"],
275
+ "application/ld+json": ["jsonld"],
276
+ "application/lgr+xml": ["lgr"],
277
+ "application/lost+xml": ["lostxml"],
278
+ "application/mac-binhex40": ["hqx"],
279
+ "application/mac-compactpro": ["cpt"],
280
+ "application/mads+xml": ["mads"],
281
+ "application/manifest+json": ["webmanifest"],
282
+ "application/marc": ["mrc"],
283
+ "application/marcxml+xml": ["mrcx"],
284
+ "application/mathematica": [
285
+ "ma",
286
+ "nb",
287
+ "mb"
288
+ ],
289
+ "application/mathml+xml": ["mathml"],
290
+ "application/mbox": ["mbox"],
291
+ "application/mediaservercontrol+xml": ["mscml"],
292
+ "application/metalink+xml": ["metalink"],
293
+ "application/metalink4+xml": ["meta4"],
294
+ "application/mets+xml": ["mets"],
295
+ "application/mmt-aei+xml": ["maei"],
296
+ "application/mmt-usd+xml": ["musd"],
297
+ "application/mods+xml": ["mods"],
298
+ "application/mp21": ["m21", "mp21"],
299
+ "application/mp4": ["mp4s", "m4p"],
300
+ "application/msword": ["doc", "dot"],
301
+ "application/mxf": ["mxf"],
302
+ "application/n-quads": ["nq"],
303
+ "application/n-triples": ["nt"],
304
+ "application/node": ["cjs"],
305
+ "application/octet-stream": [
306
+ "bin",
307
+ "dms",
308
+ "lrf",
309
+ "mar",
310
+ "so",
311
+ "dist",
312
+ "distz",
313
+ "pkg",
314
+ "bpk",
315
+ "dump",
316
+ "elc",
317
+ "deploy",
318
+ "exe",
319
+ "dll",
320
+ "deb",
321
+ "dmg",
322
+ "iso",
323
+ "img",
324
+ "msi",
325
+ "msp",
326
+ "msm",
327
+ "buffer"
328
+ ],
329
+ "application/oda": ["oda"],
330
+ "application/oebps-package+xml": ["opf"],
331
+ "application/ogg": ["ogx"],
332
+ "application/omdoc+xml": ["omdoc"],
333
+ "application/onenote": [
334
+ "onetoc",
335
+ "onetoc2",
336
+ "onetmp",
337
+ "onepkg"
338
+ ],
339
+ "application/oxps": ["oxps"],
340
+ "application/p2p-overlay+xml": ["relo"],
341
+ "application/patch-ops-error+xml": ["xer"],
342
+ "application/pdf": ["pdf"],
343
+ "application/pgp-encrypted": ["pgp"],
344
+ "application/pgp-signature": ["asc", "sig"],
345
+ "application/pics-rules": ["prf"],
346
+ "application/pkcs10": ["p10"],
347
+ "application/pkcs7-mime": ["p7m", "p7c"],
348
+ "application/pkcs7-signature": ["p7s"],
349
+ "application/pkcs8": ["p8"],
350
+ "application/pkix-attr-cert": ["ac"],
351
+ "application/pkix-cert": ["cer"],
352
+ "application/pkix-crl": ["crl"],
353
+ "application/pkix-pkipath": ["pkipath"],
354
+ "application/pkixcmp": ["pki"],
355
+ "application/pls+xml": ["pls"],
356
+ "application/postscript": [
357
+ "ai",
358
+ "eps",
359
+ "ps"
360
+ ],
361
+ "application/provenance+xml": ["provx"],
362
+ "application/pskc+xml": ["pskcxml"],
363
+ "application/raml+yaml": ["raml"],
364
+ "application/rdf+xml": ["rdf", "owl"],
365
+ "application/reginfo+xml": ["rif"],
366
+ "application/relax-ng-compact-syntax": ["rnc"],
367
+ "application/resource-lists+xml": ["rl"],
368
+ "application/resource-lists-diff+xml": ["rld"],
369
+ "application/rls-services+xml": ["rs"],
370
+ "application/route-apd+xml": ["rapd"],
371
+ "application/route-s-tsid+xml": ["sls"],
372
+ "application/route-usd+xml": ["rusd"],
373
+ "application/rpki-ghostbusters": ["gbr"],
374
+ "application/rpki-manifest": ["mft"],
375
+ "application/rpki-roa": ["roa"],
376
+ "application/rsd+xml": ["rsd"],
377
+ "application/rss+xml": ["rss"],
378
+ "application/rtf": ["rtf"],
379
+ "application/sbml+xml": ["sbml"],
380
+ "application/scvp-cv-request": ["scq"],
381
+ "application/scvp-cv-response": ["scs"],
382
+ "application/scvp-vp-request": ["spq"],
383
+ "application/scvp-vp-response": ["spp"],
384
+ "application/sdp": ["sdp"],
385
+ "application/senml+xml": ["senmlx"],
386
+ "application/sensml+xml": ["sensmlx"],
387
+ "application/set-payment-initiation": ["setpay"],
388
+ "application/set-registration-initiation": ["setreg"],
389
+ "application/shf+xml": ["shf"],
390
+ "application/sieve": ["siv", "sieve"],
391
+ "application/smil+xml": ["smi", "smil"],
392
+ "application/sparql-query": ["rq"],
393
+ "application/sparql-results+xml": ["srx"],
394
+ "application/srgs": ["gram"],
395
+ "application/srgs+xml": ["grxml"],
396
+ "application/sru+xml": ["sru"],
397
+ "application/ssdl+xml": ["ssdl"],
398
+ "application/ssml+xml": ["ssml"],
399
+ "application/swid+xml": ["swidtag"],
400
+ "application/tei+xml": ["tei", "teicorpus"],
401
+ "application/thraud+xml": ["tfi"],
402
+ "application/timestamped-data": ["tsd"],
403
+ "application/toml": ["toml"],
404
+ "application/trig": ["trig"],
405
+ "application/ttml+xml": ["ttml"],
406
+ "application/ubjson": ["ubj"],
407
+ "application/urc-ressheet+xml": ["rsheet"],
408
+ "application/urc-targetdesc+xml": ["td"],
409
+ "application/voicexml+xml": ["vxml"],
410
+ "application/wasm": ["wasm"],
411
+ "application/widget": ["wgt"],
412
+ "application/winhlp": ["hlp"],
413
+ "application/wsdl+xml": ["wsdl"],
414
+ "application/wspolicy+xml": ["wspolicy"],
415
+ "application/xaml+xml": ["xaml"],
416
+ "application/xcap-att+xml": ["xav"],
417
+ "application/xcap-caps+xml": ["xca"],
418
+ "application/xcap-diff+xml": ["xdf"],
419
+ "application/xcap-el+xml": ["xel"],
420
+ "application/xcap-ns+xml": ["xns"],
421
+ "application/xenc+xml": ["xenc"],
422
+ "application/xhtml+xml": ["xhtml", "xht"],
423
+ "application/xliff+xml": ["xlf"],
424
+ "application/xml": [
425
+ "xml",
426
+ "xsl",
427
+ "xsd",
428
+ "rng"
429
+ ],
430
+ "application/xml-dtd": ["dtd"],
431
+ "application/xop+xml": ["xop"],
432
+ "application/xproc+xml": ["xpl"],
433
+ "application/xslt+xml": ["*xsl", "xslt"],
434
+ "application/xspf+xml": ["xspf"],
435
+ "application/xv+xml": [
436
+ "mxml",
437
+ "xhvml",
438
+ "xvml",
439
+ "xvm"
440
+ ],
441
+ "application/yang": ["yang"],
442
+ "application/yin+xml": ["yin"],
443
+ "application/zip": ["zip"],
444
+ "audio/3gpp": ["*3gpp"],
445
+ "audio/adpcm": ["adp"],
446
+ "audio/amr": ["amr"],
447
+ "audio/basic": ["au", "snd"],
448
+ "audio/midi": [
449
+ "mid",
450
+ "midi",
451
+ "kar",
452
+ "rmi"
453
+ ],
454
+ "audio/mobile-xmf": ["mxmf"],
455
+ "audio/mp3": ["*mp3"],
456
+ "audio/mp4": ["m4a", "mp4a"],
457
+ "audio/mpeg": [
458
+ "mpga",
459
+ "mp2",
460
+ "mp2a",
461
+ "mp3",
462
+ "m2a",
463
+ "m3a"
464
+ ],
465
+ "audio/ogg": [
466
+ "oga",
467
+ "ogg",
468
+ "spx",
469
+ "opus"
470
+ ],
471
+ "audio/s3m": ["s3m"],
472
+ "audio/silk": ["sil"],
473
+ "audio/wav": ["wav"],
474
+ "audio/wave": ["*wav"],
475
+ "audio/webm": ["weba"],
476
+ "audio/xm": ["xm"],
477
+ "font/collection": ["ttc"],
478
+ "font/otf": ["otf"],
479
+ "font/ttf": ["ttf"],
480
+ "font/woff": ["woff"],
481
+ "font/woff2": ["woff2"],
482
+ "image/aces": ["exr"],
483
+ "image/apng": ["apng"],
484
+ "image/avif": ["avif"],
485
+ "image/bmp": ["bmp"],
486
+ "image/cgm": ["cgm"],
487
+ "image/dicom-rle": ["drle"],
488
+ "image/emf": ["emf"],
489
+ "image/fits": ["fits"],
490
+ "image/g3fax": ["g3"],
491
+ "image/gif": ["gif"],
492
+ "image/heic": ["heic"],
493
+ "image/heic-sequence": ["heics"],
494
+ "image/heif": ["heif"],
495
+ "image/heif-sequence": ["heifs"],
496
+ "image/hej2k": ["hej2"],
497
+ "image/hsj2": ["hsj2"],
498
+ "image/ief": ["ief"],
499
+ "image/jls": ["jls"],
500
+ "image/jp2": ["jp2", "jpg2"],
501
+ "image/jpeg": [
502
+ "jpeg",
503
+ "jpg",
504
+ "jpe"
505
+ ],
506
+ "image/jph": ["jph"],
507
+ "image/jphc": ["jhc"],
508
+ "image/jpm": ["jpm"],
509
+ "image/jpx": ["jpx", "jpf"],
510
+ "image/jxr": ["jxr"],
511
+ "image/jxra": ["jxra"],
512
+ "image/jxrs": ["jxrs"],
513
+ "image/jxs": ["jxs"],
514
+ "image/jxsc": ["jxsc"],
515
+ "image/jxsi": ["jxsi"],
516
+ "image/jxss": ["jxss"],
517
+ "image/ktx": ["ktx"],
518
+ "image/ktx2": ["ktx2"],
519
+ "image/png": ["png"],
520
+ "image/sgi": ["sgi"],
521
+ "image/svg+xml": ["svg", "svgz"],
522
+ "image/t38": ["t38"],
523
+ "image/tiff": ["tif", "tiff"],
524
+ "image/tiff-fx": ["tfx"],
525
+ "image/webp": ["webp"],
526
+ "image/wmf": ["wmf"],
527
+ "message/disposition-notification": ["disposition-notification"],
528
+ "message/global": ["u8msg"],
529
+ "message/global-delivery-status": ["u8dsn"],
530
+ "message/global-disposition-notification": ["u8mdn"],
531
+ "message/global-headers": ["u8hdr"],
532
+ "message/rfc822": ["eml", "mime"],
533
+ "model/3mf": ["3mf"],
534
+ "model/gltf+json": ["gltf"],
535
+ "model/gltf-binary": ["glb"],
536
+ "model/iges": ["igs", "iges"],
537
+ "model/mesh": [
538
+ "msh",
539
+ "mesh",
540
+ "silo"
541
+ ],
542
+ "model/mtl": ["mtl"],
543
+ "model/obj": ["obj"],
544
+ "model/step+xml": ["stpx"],
545
+ "model/step+zip": ["stpz"],
546
+ "model/step-xml+zip": ["stpxz"],
547
+ "model/stl": ["stl"],
548
+ "model/vrml": ["wrl", "vrml"],
549
+ "model/x3d+binary": ["*x3db", "x3dbz"],
550
+ "model/x3d+fastinfoset": ["x3db"],
551
+ "model/x3d+vrml": ["*x3dv", "x3dvz"],
552
+ "model/x3d+xml": ["x3d", "x3dz"],
553
+ "model/x3d-vrml": ["x3dv"],
554
+ "text/cache-manifest": ["appcache", "manifest"],
555
+ "text/calendar": ["ics", "ifb"],
556
+ "text/coffeescript": ["coffee", "litcoffee"],
557
+ "text/css": ["css"],
558
+ "text/csv": ["csv"],
559
+ "text/html": [
560
+ "html",
561
+ "htm",
562
+ "shtml"
563
+ ],
564
+ "text/jade": ["jade"],
565
+ "text/jsx": ["jsx"],
566
+ "text/less": ["less"],
567
+ "text/markdown": ["markdown", "md"],
568
+ "text/mathml": ["mml"],
569
+ "text/mdx": ["mdx"],
570
+ "text/n3": ["n3"],
571
+ "text/plain": [
572
+ "txt",
573
+ "text",
574
+ "conf",
575
+ "def",
576
+ "list",
577
+ "log",
578
+ "in",
579
+ "ini"
580
+ ],
581
+ "text/richtext": ["rtx"],
582
+ "text/rtf": ["*rtf"],
583
+ "text/sgml": ["sgml", "sgm"],
584
+ "text/shex": ["shex"],
585
+ "text/slim": ["slim", "slm"],
586
+ "text/spdx": ["spdx"],
587
+ "text/stylus": ["stylus", "styl"],
588
+ "text/tab-separated-values": ["tsv"],
589
+ "text/troff": [
590
+ "t",
591
+ "tr",
592
+ "roff",
593
+ "man",
594
+ "me",
595
+ "ms"
596
+ ],
597
+ "text/turtle": ["ttl"],
598
+ "text/uri-list": [
599
+ "uri",
600
+ "uris",
601
+ "urls"
602
+ ],
603
+ "text/vcard": ["vcard"],
604
+ "text/vtt": ["vtt"],
605
+ "text/xml": ["*xml"],
606
+ "text/yaml": ["yaml", "yml"],
607
+ "video/3gpp": ["3gp", "3gpp"],
608
+ "video/3gpp2": ["3g2"],
609
+ "video/h261": ["h261"],
610
+ "video/h263": ["h263"],
611
+ "video/h264": ["h264"],
612
+ "video/iso.segment": ["m4s"],
613
+ "video/jpeg": ["jpgv"],
614
+ "video/jpm": ["*jpm", "jpgm"],
615
+ "video/mj2": ["mj2", "mjp2"],
616
+ "video/mp2t": ["ts"],
617
+ "video/mp4": [
618
+ "mp4",
619
+ "mp4v",
620
+ "mpg4"
621
+ ],
622
+ "video/mpeg": [
623
+ "mpeg",
624
+ "mpg",
625
+ "mpe",
626
+ "m1v",
627
+ "m2v"
628
+ ],
629
+ "video/ogg": ["ogv"],
630
+ "video/quicktime": ["qt", "mov"],
631
+ "video/webm": ["webm"]
632
+ };
633
+ }));
634
+
635
+ //#endregion
636
+ //#region ../../node_modules/.pnpm/mime@3.0.0/node_modules/mime/types/other.js
637
+ var require_other = /* @__PURE__ */ __commonJSMin(((exports, module) => {
638
+ module.exports = {
639
+ "application/prs.cww": ["cww"],
640
+ "application/vnd.1000minds.decision-model+xml": ["1km"],
641
+ "application/vnd.3gpp.pic-bw-large": ["plb"],
642
+ "application/vnd.3gpp.pic-bw-small": ["psb"],
643
+ "application/vnd.3gpp.pic-bw-var": ["pvb"],
644
+ "application/vnd.3gpp2.tcap": ["tcap"],
645
+ "application/vnd.3m.post-it-notes": ["pwn"],
646
+ "application/vnd.accpac.simply.aso": ["aso"],
647
+ "application/vnd.accpac.simply.imp": ["imp"],
648
+ "application/vnd.acucobol": ["acu"],
649
+ "application/vnd.acucorp": ["atc", "acutc"],
650
+ "application/vnd.adobe.air-application-installer-package+zip": ["air"],
651
+ "application/vnd.adobe.formscentral.fcdt": ["fcdt"],
652
+ "application/vnd.adobe.fxp": ["fxp", "fxpl"],
653
+ "application/vnd.adobe.xdp+xml": ["xdp"],
654
+ "application/vnd.adobe.xfdf": ["xfdf"],
655
+ "application/vnd.ahead.space": ["ahead"],
656
+ "application/vnd.airzip.filesecure.azf": ["azf"],
657
+ "application/vnd.airzip.filesecure.azs": ["azs"],
658
+ "application/vnd.amazon.ebook": ["azw"],
659
+ "application/vnd.americandynamics.acc": ["acc"],
660
+ "application/vnd.amiga.ami": ["ami"],
661
+ "application/vnd.android.package-archive": ["apk"],
662
+ "application/vnd.anser-web-certificate-issue-initiation": ["cii"],
663
+ "application/vnd.anser-web-funds-transfer-initiation": ["fti"],
664
+ "application/vnd.antix.game-component": ["atx"],
665
+ "application/vnd.apple.installer+xml": ["mpkg"],
666
+ "application/vnd.apple.keynote": ["key"],
667
+ "application/vnd.apple.mpegurl": ["m3u8"],
668
+ "application/vnd.apple.numbers": ["numbers"],
669
+ "application/vnd.apple.pages": ["pages"],
670
+ "application/vnd.apple.pkpass": ["pkpass"],
671
+ "application/vnd.aristanetworks.swi": ["swi"],
672
+ "application/vnd.astraea-software.iota": ["iota"],
673
+ "application/vnd.audiograph": ["aep"],
674
+ "application/vnd.balsamiq.bmml+xml": ["bmml"],
675
+ "application/vnd.blueice.multipass": ["mpm"],
676
+ "application/vnd.bmi": ["bmi"],
677
+ "application/vnd.businessobjects": ["rep"],
678
+ "application/vnd.chemdraw+xml": ["cdxml"],
679
+ "application/vnd.chipnuts.karaoke-mmd": ["mmd"],
680
+ "application/vnd.cinderella": ["cdy"],
681
+ "application/vnd.citationstyles.style+xml": ["csl"],
682
+ "application/vnd.claymore": ["cla"],
683
+ "application/vnd.cloanto.rp9": ["rp9"],
684
+ "application/vnd.clonk.c4group": [
685
+ "c4g",
686
+ "c4d",
687
+ "c4f",
688
+ "c4p",
689
+ "c4u"
690
+ ],
691
+ "application/vnd.cluetrust.cartomobile-config": ["c11amc"],
692
+ "application/vnd.cluetrust.cartomobile-config-pkg": ["c11amz"],
693
+ "application/vnd.commonspace": ["csp"],
694
+ "application/vnd.contact.cmsg": ["cdbcmsg"],
695
+ "application/vnd.cosmocaller": ["cmc"],
696
+ "application/vnd.crick.clicker": ["clkx"],
697
+ "application/vnd.crick.clicker.keyboard": ["clkk"],
698
+ "application/vnd.crick.clicker.palette": ["clkp"],
699
+ "application/vnd.crick.clicker.template": ["clkt"],
700
+ "application/vnd.crick.clicker.wordbank": ["clkw"],
701
+ "application/vnd.criticaltools.wbs+xml": ["wbs"],
702
+ "application/vnd.ctc-posml": ["pml"],
703
+ "application/vnd.cups-ppd": ["ppd"],
704
+ "application/vnd.curl.car": ["car"],
705
+ "application/vnd.curl.pcurl": ["pcurl"],
706
+ "application/vnd.dart": ["dart"],
707
+ "application/vnd.data-vision.rdz": ["rdz"],
708
+ "application/vnd.dbf": ["dbf"],
709
+ "application/vnd.dece.data": [
710
+ "uvf",
711
+ "uvvf",
712
+ "uvd",
713
+ "uvvd"
714
+ ],
715
+ "application/vnd.dece.ttml+xml": ["uvt", "uvvt"],
716
+ "application/vnd.dece.unspecified": ["uvx", "uvvx"],
717
+ "application/vnd.dece.zip": ["uvz", "uvvz"],
718
+ "application/vnd.denovo.fcselayout-link": ["fe_launch"],
719
+ "application/vnd.dna": ["dna"],
720
+ "application/vnd.dolby.mlp": ["mlp"],
721
+ "application/vnd.dpgraph": ["dpg"],
722
+ "application/vnd.dreamfactory": ["dfac"],
723
+ "application/vnd.ds-keypoint": ["kpxx"],
724
+ "application/vnd.dvb.ait": ["ait"],
725
+ "application/vnd.dvb.service": ["svc"],
726
+ "application/vnd.dynageo": ["geo"],
727
+ "application/vnd.ecowin.chart": ["mag"],
728
+ "application/vnd.enliven": ["nml"],
729
+ "application/vnd.epson.esf": ["esf"],
730
+ "application/vnd.epson.msf": ["msf"],
731
+ "application/vnd.epson.quickanime": ["qam"],
732
+ "application/vnd.epson.salt": ["slt"],
733
+ "application/vnd.epson.ssf": ["ssf"],
734
+ "application/vnd.eszigno3+xml": ["es3", "et3"],
735
+ "application/vnd.ezpix-album": ["ez2"],
736
+ "application/vnd.ezpix-package": ["ez3"],
737
+ "application/vnd.fdf": ["fdf"],
738
+ "application/vnd.fdsn.mseed": ["mseed"],
739
+ "application/vnd.fdsn.seed": ["seed", "dataless"],
740
+ "application/vnd.flographit": ["gph"],
741
+ "application/vnd.fluxtime.clip": ["ftc"],
742
+ "application/vnd.framemaker": [
743
+ "fm",
744
+ "frame",
745
+ "maker",
746
+ "book"
747
+ ],
748
+ "application/vnd.frogans.fnc": ["fnc"],
749
+ "application/vnd.frogans.ltf": ["ltf"],
750
+ "application/vnd.fsc.weblaunch": ["fsc"],
751
+ "application/vnd.fujitsu.oasys": ["oas"],
752
+ "application/vnd.fujitsu.oasys2": ["oa2"],
753
+ "application/vnd.fujitsu.oasys3": ["oa3"],
754
+ "application/vnd.fujitsu.oasysgp": ["fg5"],
755
+ "application/vnd.fujitsu.oasysprs": ["bh2"],
756
+ "application/vnd.fujixerox.ddd": ["ddd"],
757
+ "application/vnd.fujixerox.docuworks": ["xdw"],
758
+ "application/vnd.fujixerox.docuworks.binder": ["xbd"],
759
+ "application/vnd.fuzzysheet": ["fzs"],
760
+ "application/vnd.genomatix.tuxedo": ["txd"],
761
+ "application/vnd.geogebra.file": ["ggb"],
762
+ "application/vnd.geogebra.tool": ["ggt"],
763
+ "application/vnd.geometry-explorer": ["gex", "gre"],
764
+ "application/vnd.geonext": ["gxt"],
765
+ "application/vnd.geoplan": ["g2w"],
766
+ "application/vnd.geospace": ["g3w"],
767
+ "application/vnd.gmx": ["gmx"],
768
+ "application/vnd.google-apps.document": ["gdoc"],
769
+ "application/vnd.google-apps.presentation": ["gslides"],
770
+ "application/vnd.google-apps.spreadsheet": ["gsheet"],
771
+ "application/vnd.google-earth.kml+xml": ["kml"],
772
+ "application/vnd.google-earth.kmz": ["kmz"],
773
+ "application/vnd.grafeq": ["gqf", "gqs"],
774
+ "application/vnd.groove-account": ["gac"],
775
+ "application/vnd.groove-help": ["ghf"],
776
+ "application/vnd.groove-identity-message": ["gim"],
777
+ "application/vnd.groove-injector": ["grv"],
778
+ "application/vnd.groove-tool-message": ["gtm"],
779
+ "application/vnd.groove-tool-template": ["tpl"],
780
+ "application/vnd.groove-vcard": ["vcg"],
781
+ "application/vnd.hal+xml": ["hal"],
782
+ "application/vnd.handheld-entertainment+xml": ["zmm"],
783
+ "application/vnd.hbci": ["hbci"],
784
+ "application/vnd.hhe.lesson-player": ["les"],
785
+ "application/vnd.hp-hpgl": ["hpgl"],
786
+ "application/vnd.hp-hpid": ["hpid"],
787
+ "application/vnd.hp-hps": ["hps"],
788
+ "application/vnd.hp-jlyt": ["jlt"],
789
+ "application/vnd.hp-pcl": ["pcl"],
790
+ "application/vnd.hp-pclxl": ["pclxl"],
791
+ "application/vnd.hydrostatix.sof-data": ["sfd-hdstx"],
792
+ "application/vnd.ibm.minipay": ["mpy"],
793
+ "application/vnd.ibm.modcap": [
794
+ "afp",
795
+ "listafp",
796
+ "list3820"
797
+ ],
798
+ "application/vnd.ibm.rights-management": ["irm"],
799
+ "application/vnd.ibm.secure-container": ["sc"],
800
+ "application/vnd.iccprofile": ["icc", "icm"],
801
+ "application/vnd.igloader": ["igl"],
802
+ "application/vnd.immervision-ivp": ["ivp"],
803
+ "application/vnd.immervision-ivu": ["ivu"],
804
+ "application/vnd.insors.igm": ["igm"],
805
+ "application/vnd.intercon.formnet": ["xpw", "xpx"],
806
+ "application/vnd.intergeo": ["i2g"],
807
+ "application/vnd.intu.qbo": ["qbo"],
808
+ "application/vnd.intu.qfx": ["qfx"],
809
+ "application/vnd.ipunplugged.rcprofile": ["rcprofile"],
810
+ "application/vnd.irepository.package+xml": ["irp"],
811
+ "application/vnd.is-xpr": ["xpr"],
812
+ "application/vnd.isac.fcs": ["fcs"],
813
+ "application/vnd.jam": ["jam"],
814
+ "application/vnd.jcp.javame.midlet-rms": ["rms"],
815
+ "application/vnd.jisp": ["jisp"],
816
+ "application/vnd.joost.joda-archive": ["joda"],
817
+ "application/vnd.kahootz": ["ktz", "ktr"],
818
+ "application/vnd.kde.karbon": ["karbon"],
819
+ "application/vnd.kde.kchart": ["chrt"],
820
+ "application/vnd.kde.kformula": ["kfo"],
821
+ "application/vnd.kde.kivio": ["flw"],
822
+ "application/vnd.kde.kontour": ["kon"],
823
+ "application/vnd.kde.kpresenter": ["kpr", "kpt"],
824
+ "application/vnd.kde.kspread": ["ksp"],
825
+ "application/vnd.kde.kword": ["kwd", "kwt"],
826
+ "application/vnd.kenameaapp": ["htke"],
827
+ "application/vnd.kidspiration": ["kia"],
828
+ "application/vnd.kinar": ["kne", "knp"],
829
+ "application/vnd.koan": [
830
+ "skp",
831
+ "skd",
832
+ "skt",
833
+ "skm"
834
+ ],
835
+ "application/vnd.kodak-descriptor": ["sse"],
836
+ "application/vnd.las.las+xml": ["lasxml"],
837
+ "application/vnd.llamagraphics.life-balance.desktop": ["lbd"],
838
+ "application/vnd.llamagraphics.life-balance.exchange+xml": ["lbe"],
839
+ "application/vnd.lotus-1-2-3": ["123"],
840
+ "application/vnd.lotus-approach": ["apr"],
841
+ "application/vnd.lotus-freelance": ["pre"],
842
+ "application/vnd.lotus-notes": ["nsf"],
843
+ "application/vnd.lotus-organizer": ["org"],
844
+ "application/vnd.lotus-screencam": ["scm"],
845
+ "application/vnd.lotus-wordpro": ["lwp"],
846
+ "application/vnd.macports.portpkg": ["portpkg"],
847
+ "application/vnd.mapbox-vector-tile": ["mvt"],
848
+ "application/vnd.mcd": ["mcd"],
849
+ "application/vnd.medcalcdata": ["mc1"],
850
+ "application/vnd.mediastation.cdkey": ["cdkey"],
851
+ "application/vnd.mfer": ["mwf"],
852
+ "application/vnd.mfmp": ["mfm"],
853
+ "application/vnd.micrografx.flo": ["flo"],
854
+ "application/vnd.micrografx.igx": ["igx"],
855
+ "application/vnd.mif": ["mif"],
856
+ "application/vnd.mobius.daf": ["daf"],
857
+ "application/vnd.mobius.dis": ["dis"],
858
+ "application/vnd.mobius.mbk": ["mbk"],
859
+ "application/vnd.mobius.mqy": ["mqy"],
860
+ "application/vnd.mobius.msl": ["msl"],
861
+ "application/vnd.mobius.plc": ["plc"],
862
+ "application/vnd.mobius.txf": ["txf"],
863
+ "application/vnd.mophun.application": ["mpn"],
864
+ "application/vnd.mophun.certificate": ["mpc"],
865
+ "application/vnd.mozilla.xul+xml": ["xul"],
866
+ "application/vnd.ms-artgalry": ["cil"],
867
+ "application/vnd.ms-cab-compressed": ["cab"],
868
+ "application/vnd.ms-excel": [
869
+ "xls",
870
+ "xlm",
871
+ "xla",
872
+ "xlc",
873
+ "xlt",
874
+ "xlw"
875
+ ],
876
+ "application/vnd.ms-excel.addin.macroenabled.12": ["xlam"],
877
+ "application/vnd.ms-excel.sheet.binary.macroenabled.12": ["xlsb"],
878
+ "application/vnd.ms-excel.sheet.macroenabled.12": ["xlsm"],
879
+ "application/vnd.ms-excel.template.macroenabled.12": ["xltm"],
880
+ "application/vnd.ms-fontobject": ["eot"],
881
+ "application/vnd.ms-htmlhelp": ["chm"],
882
+ "application/vnd.ms-ims": ["ims"],
883
+ "application/vnd.ms-lrm": ["lrm"],
884
+ "application/vnd.ms-officetheme": ["thmx"],
885
+ "application/vnd.ms-outlook": ["msg"],
886
+ "application/vnd.ms-pki.seccat": ["cat"],
887
+ "application/vnd.ms-pki.stl": ["*stl"],
888
+ "application/vnd.ms-powerpoint": [
889
+ "ppt",
890
+ "pps",
891
+ "pot"
892
+ ],
893
+ "application/vnd.ms-powerpoint.addin.macroenabled.12": ["ppam"],
894
+ "application/vnd.ms-powerpoint.presentation.macroenabled.12": ["pptm"],
895
+ "application/vnd.ms-powerpoint.slide.macroenabled.12": ["sldm"],
896
+ "application/vnd.ms-powerpoint.slideshow.macroenabled.12": ["ppsm"],
897
+ "application/vnd.ms-powerpoint.template.macroenabled.12": ["potm"],
898
+ "application/vnd.ms-project": ["mpp", "mpt"],
899
+ "application/vnd.ms-word.document.macroenabled.12": ["docm"],
900
+ "application/vnd.ms-word.template.macroenabled.12": ["dotm"],
901
+ "application/vnd.ms-works": [
902
+ "wps",
903
+ "wks",
904
+ "wcm",
905
+ "wdb"
906
+ ],
907
+ "application/vnd.ms-wpl": ["wpl"],
908
+ "application/vnd.ms-xpsdocument": ["xps"],
909
+ "application/vnd.mseq": ["mseq"],
910
+ "application/vnd.musician": ["mus"],
911
+ "application/vnd.muvee.style": ["msty"],
912
+ "application/vnd.mynfc": ["taglet"],
913
+ "application/vnd.neurolanguage.nlu": ["nlu"],
914
+ "application/vnd.nitf": ["ntf", "nitf"],
915
+ "application/vnd.noblenet-directory": ["nnd"],
916
+ "application/vnd.noblenet-sealer": ["nns"],
917
+ "application/vnd.noblenet-web": ["nnw"],
918
+ "application/vnd.nokia.n-gage.ac+xml": ["*ac"],
919
+ "application/vnd.nokia.n-gage.data": ["ngdat"],
920
+ "application/vnd.nokia.n-gage.symbian.install": ["n-gage"],
921
+ "application/vnd.nokia.radio-preset": ["rpst"],
922
+ "application/vnd.nokia.radio-presets": ["rpss"],
923
+ "application/vnd.novadigm.edm": ["edm"],
924
+ "application/vnd.novadigm.edx": ["edx"],
925
+ "application/vnd.novadigm.ext": ["ext"],
926
+ "application/vnd.oasis.opendocument.chart": ["odc"],
927
+ "application/vnd.oasis.opendocument.chart-template": ["otc"],
928
+ "application/vnd.oasis.opendocument.database": ["odb"],
929
+ "application/vnd.oasis.opendocument.formula": ["odf"],
930
+ "application/vnd.oasis.opendocument.formula-template": ["odft"],
931
+ "application/vnd.oasis.opendocument.graphics": ["odg"],
932
+ "application/vnd.oasis.opendocument.graphics-template": ["otg"],
933
+ "application/vnd.oasis.opendocument.image": ["odi"],
934
+ "application/vnd.oasis.opendocument.image-template": ["oti"],
935
+ "application/vnd.oasis.opendocument.presentation": ["odp"],
936
+ "application/vnd.oasis.opendocument.presentation-template": ["otp"],
937
+ "application/vnd.oasis.opendocument.spreadsheet": ["ods"],
938
+ "application/vnd.oasis.opendocument.spreadsheet-template": ["ots"],
939
+ "application/vnd.oasis.opendocument.text": ["odt"],
940
+ "application/vnd.oasis.opendocument.text-master": ["odm"],
941
+ "application/vnd.oasis.opendocument.text-template": ["ott"],
942
+ "application/vnd.oasis.opendocument.text-web": ["oth"],
943
+ "application/vnd.olpc-sugar": ["xo"],
944
+ "application/vnd.oma.dd2+xml": ["dd2"],
945
+ "application/vnd.openblox.game+xml": ["obgx"],
946
+ "application/vnd.openofficeorg.extension": ["oxt"],
947
+ "application/vnd.openstreetmap.data+xml": ["osm"],
948
+ "application/vnd.openxmlformats-officedocument.presentationml.presentation": ["pptx"],
949
+ "application/vnd.openxmlformats-officedocument.presentationml.slide": ["sldx"],
950
+ "application/vnd.openxmlformats-officedocument.presentationml.slideshow": ["ppsx"],
951
+ "application/vnd.openxmlformats-officedocument.presentationml.template": ["potx"],
952
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": ["xlsx"],
953
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.template": ["xltx"],
954
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document": ["docx"],
955
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.template": ["dotx"],
956
+ "application/vnd.osgeo.mapguide.package": ["mgp"],
957
+ "application/vnd.osgi.dp": ["dp"],
958
+ "application/vnd.osgi.subsystem": ["esa"],
959
+ "application/vnd.palm": [
960
+ "pdb",
961
+ "pqa",
962
+ "oprc"
963
+ ],
964
+ "application/vnd.pawaafile": ["paw"],
965
+ "application/vnd.pg.format": ["str"],
966
+ "application/vnd.pg.osasli": ["ei6"],
967
+ "application/vnd.picsel": ["efif"],
968
+ "application/vnd.pmi.widget": ["wg"],
969
+ "application/vnd.pocketlearn": ["plf"],
970
+ "application/vnd.powerbuilder6": ["pbd"],
971
+ "application/vnd.previewsystems.box": ["box"],
972
+ "application/vnd.proteus.magazine": ["mgz"],
973
+ "application/vnd.publishare-delta-tree": ["qps"],
974
+ "application/vnd.pvi.ptid1": ["ptid"],
975
+ "application/vnd.quark.quarkxpress": [
976
+ "qxd",
977
+ "qxt",
978
+ "qwd",
979
+ "qwt",
980
+ "qxl",
981
+ "qxb"
982
+ ],
983
+ "application/vnd.rar": ["rar"],
984
+ "application/vnd.realvnc.bed": ["bed"],
985
+ "application/vnd.recordare.musicxml": ["mxl"],
986
+ "application/vnd.recordare.musicxml+xml": ["musicxml"],
987
+ "application/vnd.rig.cryptonote": ["cryptonote"],
988
+ "application/vnd.rim.cod": ["cod"],
989
+ "application/vnd.rn-realmedia": ["rm"],
990
+ "application/vnd.rn-realmedia-vbr": ["rmvb"],
991
+ "application/vnd.route66.link66+xml": ["link66"],
992
+ "application/vnd.sailingtracker.track": ["st"],
993
+ "application/vnd.seemail": ["see"],
994
+ "application/vnd.sema": ["sema"],
995
+ "application/vnd.semd": ["semd"],
996
+ "application/vnd.semf": ["semf"],
997
+ "application/vnd.shana.informed.formdata": ["ifm"],
998
+ "application/vnd.shana.informed.formtemplate": ["itp"],
999
+ "application/vnd.shana.informed.interchange": ["iif"],
1000
+ "application/vnd.shana.informed.package": ["ipk"],
1001
+ "application/vnd.simtech-mindmapper": ["twd", "twds"],
1002
+ "application/vnd.smaf": ["mmf"],
1003
+ "application/vnd.smart.teacher": ["teacher"],
1004
+ "application/vnd.software602.filler.form+xml": ["fo"],
1005
+ "application/vnd.solent.sdkm+xml": ["sdkm", "sdkd"],
1006
+ "application/vnd.spotfire.dxp": ["dxp"],
1007
+ "application/vnd.spotfire.sfs": ["sfs"],
1008
+ "application/vnd.stardivision.calc": ["sdc"],
1009
+ "application/vnd.stardivision.draw": ["sda"],
1010
+ "application/vnd.stardivision.impress": ["sdd"],
1011
+ "application/vnd.stardivision.math": ["smf"],
1012
+ "application/vnd.stardivision.writer": ["sdw", "vor"],
1013
+ "application/vnd.stardivision.writer-global": ["sgl"],
1014
+ "application/vnd.stepmania.package": ["smzip"],
1015
+ "application/vnd.stepmania.stepchart": ["sm"],
1016
+ "application/vnd.sun.wadl+xml": ["wadl"],
1017
+ "application/vnd.sun.xml.calc": ["sxc"],
1018
+ "application/vnd.sun.xml.calc.template": ["stc"],
1019
+ "application/vnd.sun.xml.draw": ["sxd"],
1020
+ "application/vnd.sun.xml.draw.template": ["std"],
1021
+ "application/vnd.sun.xml.impress": ["sxi"],
1022
+ "application/vnd.sun.xml.impress.template": ["sti"],
1023
+ "application/vnd.sun.xml.math": ["sxm"],
1024
+ "application/vnd.sun.xml.writer": ["sxw"],
1025
+ "application/vnd.sun.xml.writer.global": ["sxg"],
1026
+ "application/vnd.sun.xml.writer.template": ["stw"],
1027
+ "application/vnd.sus-calendar": ["sus", "susp"],
1028
+ "application/vnd.svd": ["svd"],
1029
+ "application/vnd.symbian.install": ["sis", "sisx"],
1030
+ "application/vnd.syncml+xml": ["xsm"],
1031
+ "application/vnd.syncml.dm+wbxml": ["bdm"],
1032
+ "application/vnd.syncml.dm+xml": ["xdm"],
1033
+ "application/vnd.syncml.dmddf+xml": ["ddf"],
1034
+ "application/vnd.tao.intent-module-archive": ["tao"],
1035
+ "application/vnd.tcpdump.pcap": [
1036
+ "pcap",
1037
+ "cap",
1038
+ "dmp"
1039
+ ],
1040
+ "application/vnd.tmobile-livetv": ["tmo"],
1041
+ "application/vnd.trid.tpt": ["tpt"],
1042
+ "application/vnd.triscape.mxs": ["mxs"],
1043
+ "application/vnd.trueapp": ["tra"],
1044
+ "application/vnd.ufdl": ["ufd", "ufdl"],
1045
+ "application/vnd.uiq.theme": ["utz"],
1046
+ "application/vnd.umajin": ["umj"],
1047
+ "application/vnd.unity": ["unityweb"],
1048
+ "application/vnd.uoml+xml": ["uoml"],
1049
+ "application/vnd.vcx": ["vcx"],
1050
+ "application/vnd.visio": [
1051
+ "vsd",
1052
+ "vst",
1053
+ "vss",
1054
+ "vsw"
1055
+ ],
1056
+ "application/vnd.visionary": ["vis"],
1057
+ "application/vnd.vsf": ["vsf"],
1058
+ "application/vnd.wap.wbxml": ["wbxml"],
1059
+ "application/vnd.wap.wmlc": ["wmlc"],
1060
+ "application/vnd.wap.wmlscriptc": ["wmlsc"],
1061
+ "application/vnd.webturbo": ["wtb"],
1062
+ "application/vnd.wolfram.player": ["nbp"],
1063
+ "application/vnd.wordperfect": ["wpd"],
1064
+ "application/vnd.wqd": ["wqd"],
1065
+ "application/vnd.wt.stf": ["stf"],
1066
+ "application/vnd.xara": ["xar"],
1067
+ "application/vnd.xfdl": ["xfdl"],
1068
+ "application/vnd.yamaha.hv-dic": ["hvd"],
1069
+ "application/vnd.yamaha.hv-script": ["hvs"],
1070
+ "application/vnd.yamaha.hv-voice": ["hvp"],
1071
+ "application/vnd.yamaha.openscoreformat": ["osf"],
1072
+ "application/vnd.yamaha.openscoreformat.osfpvg+xml": ["osfpvg"],
1073
+ "application/vnd.yamaha.smaf-audio": ["saf"],
1074
+ "application/vnd.yamaha.smaf-phrase": ["spf"],
1075
+ "application/vnd.yellowriver-custom-menu": ["cmp"],
1076
+ "application/vnd.zul": ["zir", "zirz"],
1077
+ "application/vnd.zzazz.deck+xml": ["zaz"],
1078
+ "application/x-7z-compressed": ["7z"],
1079
+ "application/x-abiword": ["abw"],
1080
+ "application/x-ace-compressed": ["ace"],
1081
+ "application/x-apple-diskimage": ["*dmg"],
1082
+ "application/x-arj": ["arj"],
1083
+ "application/x-authorware-bin": [
1084
+ "aab",
1085
+ "x32",
1086
+ "u32",
1087
+ "vox"
1088
+ ],
1089
+ "application/x-authorware-map": ["aam"],
1090
+ "application/x-authorware-seg": ["aas"],
1091
+ "application/x-bcpio": ["bcpio"],
1092
+ "application/x-bdoc": ["*bdoc"],
1093
+ "application/x-bittorrent": ["torrent"],
1094
+ "application/x-blorb": ["blb", "blorb"],
1095
+ "application/x-bzip": ["bz"],
1096
+ "application/x-bzip2": ["bz2", "boz"],
1097
+ "application/x-cbr": [
1098
+ "cbr",
1099
+ "cba",
1100
+ "cbt",
1101
+ "cbz",
1102
+ "cb7"
1103
+ ],
1104
+ "application/x-cdlink": ["vcd"],
1105
+ "application/x-cfs-compressed": ["cfs"],
1106
+ "application/x-chat": ["chat"],
1107
+ "application/x-chess-pgn": ["pgn"],
1108
+ "application/x-chrome-extension": ["crx"],
1109
+ "application/x-cocoa": ["cco"],
1110
+ "application/x-conference": ["nsc"],
1111
+ "application/x-cpio": ["cpio"],
1112
+ "application/x-csh": ["csh"],
1113
+ "application/x-debian-package": ["*deb", "udeb"],
1114
+ "application/x-dgc-compressed": ["dgc"],
1115
+ "application/x-director": [
1116
+ "dir",
1117
+ "dcr",
1118
+ "dxr",
1119
+ "cst",
1120
+ "cct",
1121
+ "cxt",
1122
+ "w3d",
1123
+ "fgd",
1124
+ "swa"
1125
+ ],
1126
+ "application/x-doom": ["wad"],
1127
+ "application/x-dtbncx+xml": ["ncx"],
1128
+ "application/x-dtbook+xml": ["dtb"],
1129
+ "application/x-dtbresource+xml": ["res"],
1130
+ "application/x-dvi": ["dvi"],
1131
+ "application/x-envoy": ["evy"],
1132
+ "application/x-eva": ["eva"],
1133
+ "application/x-font-bdf": ["bdf"],
1134
+ "application/x-font-ghostscript": ["gsf"],
1135
+ "application/x-font-linux-psf": ["psf"],
1136
+ "application/x-font-pcf": ["pcf"],
1137
+ "application/x-font-snf": ["snf"],
1138
+ "application/x-font-type1": [
1139
+ "pfa",
1140
+ "pfb",
1141
+ "pfm",
1142
+ "afm"
1143
+ ],
1144
+ "application/x-freearc": ["arc"],
1145
+ "application/x-futuresplash": ["spl"],
1146
+ "application/x-gca-compressed": ["gca"],
1147
+ "application/x-glulx": ["ulx"],
1148
+ "application/x-gnumeric": ["gnumeric"],
1149
+ "application/x-gramps-xml": ["gramps"],
1150
+ "application/x-gtar": ["gtar"],
1151
+ "application/x-hdf": ["hdf"],
1152
+ "application/x-httpd-php": ["php"],
1153
+ "application/x-install-instructions": ["install"],
1154
+ "application/x-iso9660-image": ["*iso"],
1155
+ "application/x-iwork-keynote-sffkey": ["*key"],
1156
+ "application/x-iwork-numbers-sffnumbers": ["*numbers"],
1157
+ "application/x-iwork-pages-sffpages": ["*pages"],
1158
+ "application/x-java-archive-diff": ["jardiff"],
1159
+ "application/x-java-jnlp-file": ["jnlp"],
1160
+ "application/x-keepass2": ["kdbx"],
1161
+ "application/x-latex": ["latex"],
1162
+ "application/x-lua-bytecode": ["luac"],
1163
+ "application/x-lzh-compressed": ["lzh", "lha"],
1164
+ "application/x-makeself": ["run"],
1165
+ "application/x-mie": ["mie"],
1166
+ "application/x-mobipocket-ebook": ["prc", "mobi"],
1167
+ "application/x-ms-application": ["application"],
1168
+ "application/x-ms-shortcut": ["lnk"],
1169
+ "application/x-ms-wmd": ["wmd"],
1170
+ "application/x-ms-wmz": ["wmz"],
1171
+ "application/x-ms-xbap": ["xbap"],
1172
+ "application/x-msaccess": ["mdb"],
1173
+ "application/x-msbinder": ["obd"],
1174
+ "application/x-mscardfile": ["crd"],
1175
+ "application/x-msclip": ["clp"],
1176
+ "application/x-msdos-program": ["*exe"],
1177
+ "application/x-msdownload": [
1178
+ "*exe",
1179
+ "*dll",
1180
+ "com",
1181
+ "bat",
1182
+ "*msi"
1183
+ ],
1184
+ "application/x-msmediaview": [
1185
+ "mvb",
1186
+ "m13",
1187
+ "m14"
1188
+ ],
1189
+ "application/x-msmetafile": [
1190
+ "*wmf",
1191
+ "*wmz",
1192
+ "*emf",
1193
+ "emz"
1194
+ ],
1195
+ "application/x-msmoney": ["mny"],
1196
+ "application/x-mspublisher": ["pub"],
1197
+ "application/x-msschedule": ["scd"],
1198
+ "application/x-msterminal": ["trm"],
1199
+ "application/x-mswrite": ["wri"],
1200
+ "application/x-netcdf": ["nc", "cdf"],
1201
+ "application/x-ns-proxy-autoconfig": ["pac"],
1202
+ "application/x-nzb": ["nzb"],
1203
+ "application/x-perl": ["pl", "pm"],
1204
+ "application/x-pilot": ["*prc", "*pdb"],
1205
+ "application/x-pkcs12": ["p12", "pfx"],
1206
+ "application/x-pkcs7-certificates": ["p7b", "spc"],
1207
+ "application/x-pkcs7-certreqresp": ["p7r"],
1208
+ "application/x-rar-compressed": ["*rar"],
1209
+ "application/x-redhat-package-manager": ["rpm"],
1210
+ "application/x-research-info-systems": ["ris"],
1211
+ "application/x-sea": ["sea"],
1212
+ "application/x-sh": ["sh"],
1213
+ "application/x-shar": ["shar"],
1214
+ "application/x-shockwave-flash": ["swf"],
1215
+ "application/x-silverlight-app": ["xap"],
1216
+ "application/x-sql": ["sql"],
1217
+ "application/x-stuffit": ["sit"],
1218
+ "application/x-stuffitx": ["sitx"],
1219
+ "application/x-subrip": ["srt"],
1220
+ "application/x-sv4cpio": ["sv4cpio"],
1221
+ "application/x-sv4crc": ["sv4crc"],
1222
+ "application/x-t3vm-image": ["t3"],
1223
+ "application/x-tads": ["gam"],
1224
+ "application/x-tar": ["tar"],
1225
+ "application/x-tcl": ["tcl", "tk"],
1226
+ "application/x-tex": ["tex"],
1227
+ "application/x-tex-tfm": ["tfm"],
1228
+ "application/x-texinfo": ["texinfo", "texi"],
1229
+ "application/x-tgif": ["*obj"],
1230
+ "application/x-ustar": ["ustar"],
1231
+ "application/x-virtualbox-hdd": ["hdd"],
1232
+ "application/x-virtualbox-ova": ["ova"],
1233
+ "application/x-virtualbox-ovf": ["ovf"],
1234
+ "application/x-virtualbox-vbox": ["vbox"],
1235
+ "application/x-virtualbox-vbox-extpack": ["vbox-extpack"],
1236
+ "application/x-virtualbox-vdi": ["vdi"],
1237
+ "application/x-virtualbox-vhd": ["vhd"],
1238
+ "application/x-virtualbox-vmdk": ["vmdk"],
1239
+ "application/x-wais-source": ["src"],
1240
+ "application/x-web-app-manifest+json": ["webapp"],
1241
+ "application/x-x509-ca-cert": [
1242
+ "der",
1243
+ "crt",
1244
+ "pem"
1245
+ ],
1246
+ "application/x-xfig": ["fig"],
1247
+ "application/x-xliff+xml": ["*xlf"],
1248
+ "application/x-xpinstall": ["xpi"],
1249
+ "application/x-xz": ["xz"],
1250
+ "application/x-zmachine": [
1251
+ "z1",
1252
+ "z2",
1253
+ "z3",
1254
+ "z4",
1255
+ "z5",
1256
+ "z6",
1257
+ "z7",
1258
+ "z8"
1259
+ ],
1260
+ "audio/vnd.dece.audio": ["uva", "uvva"],
1261
+ "audio/vnd.digital-winds": ["eol"],
1262
+ "audio/vnd.dra": ["dra"],
1263
+ "audio/vnd.dts": ["dts"],
1264
+ "audio/vnd.dts.hd": ["dtshd"],
1265
+ "audio/vnd.lucent.voice": ["lvp"],
1266
+ "audio/vnd.ms-playready.media.pya": ["pya"],
1267
+ "audio/vnd.nuera.ecelp4800": ["ecelp4800"],
1268
+ "audio/vnd.nuera.ecelp7470": ["ecelp7470"],
1269
+ "audio/vnd.nuera.ecelp9600": ["ecelp9600"],
1270
+ "audio/vnd.rip": ["rip"],
1271
+ "audio/x-aac": ["aac"],
1272
+ "audio/x-aiff": [
1273
+ "aif",
1274
+ "aiff",
1275
+ "aifc"
1276
+ ],
1277
+ "audio/x-caf": ["caf"],
1278
+ "audio/x-flac": ["flac"],
1279
+ "audio/x-m4a": ["*m4a"],
1280
+ "audio/x-matroska": ["mka"],
1281
+ "audio/x-mpegurl": ["m3u"],
1282
+ "audio/x-ms-wax": ["wax"],
1283
+ "audio/x-ms-wma": ["wma"],
1284
+ "audio/x-pn-realaudio": ["ram", "ra"],
1285
+ "audio/x-pn-realaudio-plugin": ["rmp"],
1286
+ "audio/x-realaudio": ["*ra"],
1287
+ "audio/x-wav": ["*wav"],
1288
+ "chemical/x-cdx": ["cdx"],
1289
+ "chemical/x-cif": ["cif"],
1290
+ "chemical/x-cmdf": ["cmdf"],
1291
+ "chemical/x-cml": ["cml"],
1292
+ "chemical/x-csml": ["csml"],
1293
+ "chemical/x-xyz": ["xyz"],
1294
+ "image/prs.btif": ["btif"],
1295
+ "image/prs.pti": ["pti"],
1296
+ "image/vnd.adobe.photoshop": ["psd"],
1297
+ "image/vnd.airzip.accelerator.azv": ["azv"],
1298
+ "image/vnd.dece.graphic": [
1299
+ "uvi",
1300
+ "uvvi",
1301
+ "uvg",
1302
+ "uvvg"
1303
+ ],
1304
+ "image/vnd.djvu": ["djvu", "djv"],
1305
+ "image/vnd.dvb.subtitle": ["*sub"],
1306
+ "image/vnd.dwg": ["dwg"],
1307
+ "image/vnd.dxf": ["dxf"],
1308
+ "image/vnd.fastbidsheet": ["fbs"],
1309
+ "image/vnd.fpx": ["fpx"],
1310
+ "image/vnd.fst": ["fst"],
1311
+ "image/vnd.fujixerox.edmics-mmr": ["mmr"],
1312
+ "image/vnd.fujixerox.edmics-rlc": ["rlc"],
1313
+ "image/vnd.microsoft.icon": ["ico"],
1314
+ "image/vnd.ms-dds": ["dds"],
1315
+ "image/vnd.ms-modi": ["mdi"],
1316
+ "image/vnd.ms-photo": ["wdp"],
1317
+ "image/vnd.net-fpx": ["npx"],
1318
+ "image/vnd.pco.b16": ["b16"],
1319
+ "image/vnd.tencent.tap": ["tap"],
1320
+ "image/vnd.valve.source.texture": ["vtf"],
1321
+ "image/vnd.wap.wbmp": ["wbmp"],
1322
+ "image/vnd.xiff": ["xif"],
1323
+ "image/vnd.zbrush.pcx": ["pcx"],
1324
+ "image/x-3ds": ["3ds"],
1325
+ "image/x-cmu-raster": ["ras"],
1326
+ "image/x-cmx": ["cmx"],
1327
+ "image/x-freehand": [
1328
+ "fh",
1329
+ "fhc",
1330
+ "fh4",
1331
+ "fh5",
1332
+ "fh7"
1333
+ ],
1334
+ "image/x-icon": ["*ico"],
1335
+ "image/x-jng": ["jng"],
1336
+ "image/x-mrsid-image": ["sid"],
1337
+ "image/x-ms-bmp": ["*bmp"],
1338
+ "image/x-pcx": ["*pcx"],
1339
+ "image/x-pict": ["pic", "pct"],
1340
+ "image/x-portable-anymap": ["pnm"],
1341
+ "image/x-portable-bitmap": ["pbm"],
1342
+ "image/x-portable-graymap": ["pgm"],
1343
+ "image/x-portable-pixmap": ["ppm"],
1344
+ "image/x-rgb": ["rgb"],
1345
+ "image/x-tga": ["tga"],
1346
+ "image/x-xbitmap": ["xbm"],
1347
+ "image/x-xpixmap": ["xpm"],
1348
+ "image/x-xwindowdump": ["xwd"],
1349
+ "message/vnd.wfa.wsc": ["wsc"],
1350
+ "model/vnd.collada+xml": ["dae"],
1351
+ "model/vnd.dwf": ["dwf"],
1352
+ "model/vnd.gdl": ["gdl"],
1353
+ "model/vnd.gtw": ["gtw"],
1354
+ "model/vnd.mts": ["mts"],
1355
+ "model/vnd.opengex": ["ogex"],
1356
+ "model/vnd.parasolid.transmit.binary": ["x_b"],
1357
+ "model/vnd.parasolid.transmit.text": ["x_t"],
1358
+ "model/vnd.sap.vds": ["vds"],
1359
+ "model/vnd.usdz+zip": ["usdz"],
1360
+ "model/vnd.valve.source.compiled-map": ["bsp"],
1361
+ "model/vnd.vtu": ["vtu"],
1362
+ "text/prs.lines.tag": ["dsc"],
1363
+ "text/vnd.curl": ["curl"],
1364
+ "text/vnd.curl.dcurl": ["dcurl"],
1365
+ "text/vnd.curl.mcurl": ["mcurl"],
1366
+ "text/vnd.curl.scurl": ["scurl"],
1367
+ "text/vnd.dvb.subtitle": ["sub"],
1368
+ "text/vnd.fly": ["fly"],
1369
+ "text/vnd.fmi.flexstor": ["flx"],
1370
+ "text/vnd.graphviz": ["gv"],
1371
+ "text/vnd.in3d.3dml": ["3dml"],
1372
+ "text/vnd.in3d.spot": ["spot"],
1373
+ "text/vnd.sun.j2me.app-descriptor": ["jad"],
1374
+ "text/vnd.wap.wml": ["wml"],
1375
+ "text/vnd.wap.wmlscript": ["wmls"],
1376
+ "text/x-asm": ["s", "asm"],
1377
+ "text/x-c": [
1378
+ "c",
1379
+ "cc",
1380
+ "cxx",
1381
+ "cpp",
1382
+ "h",
1383
+ "hh",
1384
+ "dic"
1385
+ ],
1386
+ "text/x-component": ["htc"],
1387
+ "text/x-fortran": [
1388
+ "f",
1389
+ "for",
1390
+ "f77",
1391
+ "f90"
1392
+ ],
1393
+ "text/x-handlebars-template": ["hbs"],
1394
+ "text/x-java-source": ["java"],
1395
+ "text/x-lua": ["lua"],
1396
+ "text/x-markdown": ["mkd"],
1397
+ "text/x-nfo": ["nfo"],
1398
+ "text/x-opml": ["opml"],
1399
+ "text/x-org": ["*org"],
1400
+ "text/x-pascal": ["p", "pas"],
1401
+ "text/x-processing": ["pde"],
1402
+ "text/x-sass": ["sass"],
1403
+ "text/x-scss": ["scss"],
1404
+ "text/x-setext": ["etx"],
1405
+ "text/x-sfv": ["sfv"],
1406
+ "text/x-suse-ymp": ["ymp"],
1407
+ "text/x-uuencode": ["uu"],
1408
+ "text/x-vcalendar": ["vcs"],
1409
+ "text/x-vcard": ["vcf"],
1410
+ "video/vnd.dece.hd": ["uvh", "uvvh"],
1411
+ "video/vnd.dece.mobile": ["uvm", "uvvm"],
1412
+ "video/vnd.dece.pd": ["uvp", "uvvp"],
1413
+ "video/vnd.dece.sd": ["uvs", "uvvs"],
1414
+ "video/vnd.dece.video": ["uvv", "uvvv"],
1415
+ "video/vnd.dvb.file": ["dvb"],
1416
+ "video/vnd.fvt": ["fvt"],
1417
+ "video/vnd.mpegurl": ["mxu", "m4u"],
1418
+ "video/vnd.ms-playready.media.pyv": ["pyv"],
1419
+ "video/vnd.uvvu.mp4": ["uvu", "uvvu"],
1420
+ "video/vnd.vivo": ["viv"],
1421
+ "video/x-f4v": ["f4v"],
1422
+ "video/x-fli": ["fli"],
1423
+ "video/x-flv": ["flv"],
1424
+ "video/x-m4v": ["m4v"],
1425
+ "video/x-matroska": [
1426
+ "mkv",
1427
+ "mk3d",
1428
+ "mks"
1429
+ ],
1430
+ "video/x-mng": ["mng"],
1431
+ "video/x-ms-asf": ["asf", "asx"],
1432
+ "video/x-ms-vob": ["vob"],
1433
+ "video/x-ms-wm": ["wm"],
1434
+ "video/x-ms-wmv": ["wmv"],
1435
+ "video/x-ms-wmx": ["wmx"],
1436
+ "video/x-ms-wvx": ["wvx"],
1437
+ "video/x-msvideo": ["avi"],
1438
+ "video/x-sgi-movie": ["movie"],
1439
+ "video/x-smv": ["smv"],
1440
+ "x-conference/x-cooltalk": ["ice"]
1441
+ };
1442
+ }));
1443
+
1444
+ //#endregion
1445
+ //#region ../../node_modules/.pnpm/mime@3.0.0/node_modules/mime/index.js
1446
+ var require_mime = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1447
+ let Mime = require_Mime();
1448
+ module.exports = new Mime(require_standard(), require_other());
1449
+ }));
1450
+
1451
+ //#endregion
1452
+ //#region ../shared/src/write-archive/archive-file.ts
1453
+ var import_mime = /* @__PURE__ */ __toESM(require_mime(), 1);
1454
+ const RESERVED_PATHNAMES = [
1455
+ "/index.json",
1456
+ "/iframe.html",
1457
+ "/index.html",
1458
+ "/main.iframe.bundle.js",
1459
+ "/runtime~main.iframe.bundle.js",
1460
+ "/sb-preview/runtime.js"
1461
+ ];
1462
+ var ArchiveFile = class {
1463
+ url;
1464
+ response;
1465
+ shortenedFileNameLength;
1466
+ pageUrl;
1467
+ constructor(url, response, pageUrl) {
1468
+ this.url = new URL(url);
1469
+ this.response = response;
1470
+ this.shortenedFileNameLength = 250;
1471
+ this.pageUrl = new URL(pageUrl);
1472
+ }
1473
+ originalSrc() {
1474
+ return this.url.toString();
1475
+ }
1476
+ toFileSystemPath() {
1477
+ let sanitizedSrc = this.url.pathname;
1478
+ sanitizedSrc = this.preserveExternalDomain();
1479
+ sanitizedSrc = this.ensureNonDirectory(sanitizedSrc);
1480
+ sanitizedSrc = this.encodeQueryString(sanitizedSrc);
1481
+ sanitizedSrc = this.truncateFileName(sanitizedSrc);
1482
+ sanitizedSrc = this.removeSpecialChars(sanitizedSrc);
1483
+ sanitizedSrc = this.renameReservedPathnames(sanitizedSrc);
1484
+ sanitizedSrc = this.addExtension(sanitizedSrc);
1485
+ return sanitizedSrc;
1486
+ }
1487
+ ensureNonDirectory(pathname) {
1488
+ return pathname.endsWith("/") ? `${pathname}index.html` : pathname;
1489
+ }
1490
+ encodeQueryString(pathname) {
1491
+ const queryString = this.url.search;
1492
+ if (!queryString) return pathname;
1493
+ const safeQueryString = this.hash(queryString);
1494
+ const extension = path.extname(pathname);
1495
+ if (extension) return `${pathname.substring(0, pathname.length - extension.length)}-${safeQueryString}${extension}`;
1496
+ return `${pathname}-${safeQueryString}`;
1497
+ }
1498
+ truncateFileName(pathname) {
1499
+ const pathPieces = pathname.split("/");
1500
+ const rebuiltPieces = [];
1501
+ pathPieces.forEach((piece) => {
1502
+ let shortName = piece;
1503
+ if (piece.length > this.shortenedFileNameLength) {
1504
+ shortName = piece.substring(0, this.shortenedFileNameLength);
1505
+ logger.log(`Chunk of filename '${piece}' is too long. Shortening to '${shortName}'`);
1506
+ }
1507
+ rebuiltPieces.push(shortName);
1508
+ });
1509
+ return rebuiltPieces.join("/");
1510
+ }
1511
+ removeSpecialChars(pathname) {
1512
+ return pathname.replace(/[%:@]/g, "");
1513
+ }
1514
+ addExtension(pathname) {
1515
+ if ("error" in this.response) return pathname;
1516
+ let nameWithExtension = pathname;
1517
+ if (!path.extname(nameWithExtension)) nameWithExtension = `${pathname}.${import_mime.default.getExtension(this.response.contentType) || "tmp"}`;
1518
+ return nameWithExtension;
1519
+ }
1520
+ preserveExternalDomain() {
1521
+ if (this.url.origin === this.pageUrl.origin) return this.url.pathname;
1522
+ return `/${encodeURIComponent(this.url.host)}${this.url.pathname}`;
1523
+ }
1524
+ hash(name) {
1525
+ return createHash("md5").update(name).digest("hex");
1526
+ }
1527
+ renameReservedPathnames(pathname) {
1528
+ if (this.url.origin === this.pageUrl.origin && RESERVED_PATHNAMES.includes(pathname)) {
1529
+ const hash = this.hash(this.url.toString());
1530
+ const basename = path.basename(pathname, path.extname(pathname));
1531
+ return `${path.dirname(pathname)}/${basename}-${hash}${path.extname(pathname)}`;
1532
+ }
1533
+ return pathname;
1534
+ }
1535
+ };
1536
+
1537
+ //#endregion
1538
+ //#region ../../node_modules/.pnpm/@rrweb+types@2.1.0/node_modules/@rrweb/types/dist/types.js
1539
+ var NodeType = /* @__PURE__ */ ((NodeType2) => {
1540
+ NodeType2[NodeType2["Document"] = 0] = "Document";
1541
+ NodeType2[NodeType2["DocumentType"] = 1] = "DocumentType";
1542
+ NodeType2[NodeType2["Element"] = 2] = "Element";
1543
+ NodeType2[NodeType2["Text"] = 3] = "Text";
1544
+ NodeType2[NodeType2["CDATA"] = 4] = "CDATA";
1545
+ NodeType2[NodeType2["Comment"] = 5] = "Comment";
1546
+ return NodeType2;
1547
+ })(NodeType || {});
1548
+
1549
+ //#endregion
1550
+ //#region ../../node_modules/.pnpm/srcset@4.0.0/node_modules/srcset/index.js
1551
+ var require_srcset = /* @__PURE__ */ __commonJSMin(((exports) => {
1552
+ const imageCandidateRegex = /\s*([^,]\S*[^,](?:\s+[^,]+)?)\s*(?:,|$)/;
1553
+ const duplicateDescriptorCheck = (allDescriptors, value, postfix) => {
1554
+ allDescriptors[postfix] = allDescriptors[postfix] || {};
1555
+ if (allDescriptors[postfix][value]) throw new Error(`No more than one image candidate is allowed for a given descriptor: ${value}${postfix}`);
1556
+ allDescriptors[postfix][value] = true;
1557
+ };
1558
+ const fallbackDescriptorDuplicateCheck = (allDescriptors) => {
1559
+ if (allDescriptors.fallback) throw new Error("Only one fallback image candidate is allowed");
1560
+ if (allDescriptors.x["1"]) throw new Error("A fallback image is equivalent to a 1x descriptor, providing both is invalid.");
1561
+ allDescriptors.fallback = true;
1562
+ };
1563
+ const descriptorCountCheck = (allDescriptors, currentDescriptors) => {
1564
+ if (currentDescriptors.length === 0) fallbackDescriptorDuplicateCheck(allDescriptors);
1565
+ else if (currentDescriptors.length > 1) throw new Error(`Image candidate may have no more than one descriptor, found ${currentDescriptors.length}: ${currentDescriptors.join(" ")}`);
1566
+ };
1567
+ const validDescriptorCheck = (value, postfix, descriptor) => {
1568
+ if (Number.isNaN(value)) throw new TypeError(`${descriptor || value} is not a valid number`);
1569
+ switch (postfix) {
1570
+ case "w":
1571
+ if (value <= 0) throw new Error("Width descriptor must be greater than zero");
1572
+ else if (!Number.isInteger(value)) throw new TypeError("Width descriptor must be an integer");
1573
+ break;
1574
+ case "x":
1575
+ if (value <= 0) throw new Error("Pixel density descriptor must be greater than zero");
1576
+ break;
1577
+ case "h": throw new Error("Height descriptor is no longer allowed");
1578
+ default: throw new Error(`Invalid srcset descriptor: ${descriptor}`);
1579
+ }
1580
+ };
1581
+ exports.parse = (string, { strict = false } = {}) => {
1582
+ const allDescriptors = strict ? {} : void 0;
1583
+ return string.split(imageCandidateRegex).filter((part, index) => index % 2 === 1).map((part) => {
1584
+ const [url, ...descriptors] = part.trim().split(/\s+/);
1585
+ const result = { url };
1586
+ if (strict) descriptorCountCheck(allDescriptors, descriptors);
1587
+ for (const descriptor of descriptors) {
1588
+ const postfix = descriptor[descriptor.length - 1];
1589
+ const value = Number.parseFloat(descriptor.slice(0, -1));
1590
+ if (strict) {
1591
+ validDescriptorCheck(value, postfix, descriptor);
1592
+ duplicateDescriptorCheck(allDescriptors, value, postfix);
1593
+ }
1594
+ switch (postfix) {
1595
+ case "w":
1596
+ result.width = value;
1597
+ break;
1598
+ case "h":
1599
+ result.height = value;
1600
+ break;
1601
+ case "x": result.density = value;
1602
+ }
1603
+ }
1604
+ return result;
1605
+ });
1606
+ };
1607
+ }));
1608
+
1609
+ //#endregion
1610
+ //#region ../shared/src/utils/nodes.ts
1611
+ var import_srcset = /* @__PURE__ */ __toESM(require_srcset(), 1);
1612
+ function isIframeSerializedNode(node) {
1613
+ return node.type === NodeType.Element && node.tagName === "iframe" && "contentDocument" in node && !!node.contentDocument;
1614
+ }
1615
+
1616
+ //#endregion
1617
+ //#region ../shared/src/write-archive/dom-snapshot.ts
1618
+ const CSS_URL_REGEX = /url\((?!['"]?(?:data):)['"]?([^'")]*)['"]?\)/gi;
1619
+ var DOMSnapshot = class {
1620
+ snapshot;
1621
+ pseudoClassIds;
1622
+ constructor({ snapshot, pseudoClassIds }) {
1623
+ if (Buffer.isBuffer(snapshot)) {
1624
+ const bufferAsString = snapshot.toString("utf-8");
1625
+ this.snapshot = JSON.parse(bufferAsString);
1626
+ } else this.snapshot = JSON.parse(snapshot);
1627
+ this.pseudoClassIds = pseudoClassIds;
1628
+ }
1629
+ async mapAssetPaths(sourceMap) {
1630
+ const savedSnapshot = {
1631
+ snapshot: await this.mapNode(this.snapshot, sourceMap),
1632
+ pseudoClassIds: this.pseudoClassIds
1633
+ };
1634
+ return JSON.stringify(savedSnapshot);
1635
+ }
1636
+ async mapNode(node, sourceMap) {
1637
+ node = this.mapNodeAttributes(node, sourceMap);
1638
+ node = this.mapTextElement(node, sourceMap);
1639
+ if ("childNodes" in node) node.childNodes = await Promise.all(node.childNodes.map(async (childNode) => {
1640
+ return this.mapNode(childNode, sourceMap);
1641
+ }));
1642
+ if (isIframeSerializedNode(node)) node.contentDocument = await this.mapNode(node.contentDocument, sourceMap);
1643
+ return node;
1644
+ }
1645
+ mapNodeAttributes(node, sourceMap) {
1646
+ if (node.type === NodeType.Element) {
1647
+ if (node.attributes.src) {
1648
+ const sourceVal = node.attributes.src;
1649
+ if (sourceMap.has(sourceVal)) node.attributes.src = sourceMap.get(sourceVal);
1650
+ }
1651
+ if (node.attributes.style) {
1652
+ const cssText = node.attributes.style;
1653
+ const mappedCssText = this.mapCssUrls(cssText, sourceMap);
1654
+ node.attributes.style = mappedCssText;
1655
+ }
1656
+ if (node.attributes._cssText) {
1657
+ const cssText = node.attributes._cssText;
1658
+ const mappedCssText = this.mapCssUrls(cssText, sourceMap);
1659
+ node.attributes._cssText = mappedCssText;
1660
+ }
1661
+ if (["link", "use"].includes(node.tagName) && node.attributes.href) {
1662
+ const hrefValAndAnchor = node.attributes.href.split("#");
1663
+ const hrefValWithoutAnchor = hrefValAndAnchor[0];
1664
+ if (sourceMap.has(hrefValWithoutAnchor)) {
1665
+ hrefValAndAnchor[0] = sourceMap.get(hrefValWithoutAnchor);
1666
+ node.attributes.href = hrefValAndAnchor.join("#");
1667
+ }
1668
+ }
1669
+ if (node.tagName === "img" && node.attributes.srcset) {
1670
+ const srcsetValue = node.attributes.srcset;
1671
+ const currentSrc = this.mapSrcsetUrls(srcsetValue, sourceMap);
1672
+ if (currentSrc) {
1673
+ node.attributes.src = currentSrc;
1674
+ this.removeResponsiveImageAttributes(node.attributes);
1675
+ }
1676
+ }
1677
+ if (node.tagName === "picture") this.mapPictureElement(node, sourceMap);
1678
+ if (node.tagName === "base" && node.attributes.href) node.attributes.href = removeLocalhostFromBaseUrl(node.attributes.href);
1679
+ }
1680
+ return node;
1681
+ }
1682
+ mapPictureElement(node, sourceMap) {
1683
+ const matchingUrl = node.childNodes.filter((element) => this.isSourceElement(element)).map((childNode) => {
1684
+ return import_srcset.parse(childNode.attributes?.srcset ?? "").map((srcSetValue) => srcSetValue.url);
1685
+ }).flat().find((sourceUrl) => {
1686
+ return sourceMap.has(sourceUrl);
1687
+ });
1688
+ if (matchingUrl) {
1689
+ node.childNodes = node.childNodes.filter((childNode) => !this.isSourceElement(childNode));
1690
+ const imageElement = node.childNodes.find((childNode) => childNode.type === NodeType.Element && childNode.tagName === "img");
1691
+ if (imageElement && imageElement.attributes) {
1692
+ imageElement.attributes.src = sourceMap.get(matchingUrl);
1693
+ this.removeResponsiveImageAttributes(imageElement.attributes);
1694
+ }
1695
+ }
1696
+ }
1697
+ isSourceElement(childNode) {
1698
+ return childNode.type === NodeType.Element && childNode.tagName === "source";
1699
+ }
1700
+ mapTextElement(node, sourceMap) {
1701
+ if (node.type === NodeType.Text && node.isStyle) {
1702
+ if (node.textContent) node.textContent = this.mapCssUrls(node.textContent, sourceMap);
1703
+ }
1704
+ return node;
1705
+ }
1706
+ mapCssUrls(cssText, sourceMap) {
1707
+ return cssText.replace(CSS_URL_REGEX, (match, fullUrl) => {
1708
+ let cssUrl = match;
1709
+ if (sourceMap.has(fullUrl)) cssUrl = match.replace(fullUrl, sourceMap.get(fullUrl));
1710
+ return cssUrl;
1711
+ });
1712
+ }
1713
+ mapSrcsetUrls(srcsetValue, sourceMap) {
1714
+ const parsedSrcset = import_srcset.parse(srcsetValue);
1715
+ let currentSrc;
1716
+ parsedSrcset.forEach((set) => {
1717
+ if (sourceMap.has(set.url)) currentSrc = sourceMap.get(set.url);
1718
+ });
1719
+ return currentSrc;
1720
+ }
1721
+ removeResponsiveImageAttributes(attributes) {
1722
+ delete attributes.srcset;
1723
+ delete attributes.sizes;
1724
+ }
1725
+ };
1726
+
1727
+ //#endregion
1728
+ //#region ../shared/src/utils/viewport.ts
1729
+ function viewportToString(viewport) {
1730
+ return `w${viewport.width}h${viewport.height}`;
1731
+ }
1732
+
1733
+ //#endregion
1734
+ //#region ../shared/src/write-archive/storybook-sanitize.ts
1735
+ const sanitize = (string) => {
1736
+ return string.toLowerCase().replace(/[ ’–—―′¿'`~!@#$%^&*()_|+\-=?;:'",.<>\{\}\[\]\\\/]/gi, "-").replace(/[\r\n]/g, "-").replace(/-+/g, "-").replace(/^-+/, "").replace(/-+$/, "");
1737
+ };
1738
+ const collapseNewlines = (title) => title.replace(/[\r\n]+/g, " ").trim();
1739
+
1740
+ //#endregion
1741
+ //#region ../shared/src/write-archive/snapshot-files.ts
1742
+ const SNAPSHOT_FILE_EXT = "snapshot.json";
1743
+ function snapshotId(testTitle, snapshotName) {
1744
+ const fullSnapshotId = `${sanitize(testTitle)}-${sanitize(snapshotName)}`;
1745
+ const maxByteLength = 255 - 25;
1746
+ return truncateFileName(fullSnapshotId, maxByteLength);
1747
+ }
1748
+ function snapshotFileName(snapshotId, viewport) {
1749
+ return [
1750
+ snapshotId,
1751
+ viewportToString(viewport),
1752
+ SNAPSHOT_FILE_EXT
1753
+ ].join(".");
1754
+ }
1755
+
1756
+ //#endregion
1757
+ //#region ../shared/src/write-archive/stories-files.ts
1758
+ const STORIES_FILE_EXT = "stories.json";
1759
+ function storiesFileName(testTitle, uniqueId) {
1760
+ const fileName = [sanitize([testTitle, uniqueId].filter(Boolean).join("-")), STORIES_FILE_EXT].join(".");
1761
+ const maxByteLength = 255 - 25;
1762
+ return truncateFileName(fileName, maxByteLength);
1763
+ }
1764
+ function createStories(storyTitle, domSnapshots, chromaticStorybookParams) {
1765
+ const title = collapseNewlines(storyTitle);
1766
+ return {
1767
+ title,
1768
+ stories: Object.entries(domSnapshots).map(([snapshotName, snapshotOptions]) => {
1769
+ const name = collapseNewlines(snapshotName);
1770
+ const { parameters, viewport, colorScheme } = snapshotOptions;
1771
+ const { chromatic: chromaticParams, ...restParameters } = parameters || {};
1772
+ return {
1773
+ name,
1774
+ globals: { viewport: viewportToString(viewport) },
1775
+ parameters: {
1776
+ __id: toId(title, storyNameFromExport(name)),
1777
+ server: { id: snapshotId(title, name) },
1778
+ chromatic: {
1779
+ ...chromaticStorybookParams,
1780
+ ...chromaticParams,
1781
+ colorScheme,
1782
+ modes: buildStoryModesConfig([viewport])
1783
+ },
1784
+ viewport: {
1785
+ options: buildStoryViewportsConfig([viewport]),
1786
+ defaultViewport: viewportToString(findDefaultViewport([viewport]))
1787
+ },
1788
+ ...restParameters
1789
+ }
1790
+ };
1791
+ })
1792
+ };
1793
+ }
1794
+ function buildStoryModesConfig(viewports) {
1795
+ return viewports.reduce((modes, viewport) => {
1796
+ const viewportName = viewportToString(viewport);
1797
+ modes[viewportName] = { viewport: viewportName };
1798
+ return modes;
1799
+ }, {});
1800
+ }
1801
+ function buildStoryViewportsConfig(viewports) {
1802
+ return viewports.reduce((viewportsConfig, viewport) => {
1803
+ const viewportName = viewportToString(viewport);
1804
+ viewportsConfig[viewportName] = {
1805
+ name: viewportName,
1806
+ type: viewportAddonType(viewport),
1807
+ styles: {
1808
+ width: `${viewport.width}px`,
1809
+ height: `${viewport.height}px`
1810
+ }
1811
+ };
1812
+ return viewportsConfig;
1813
+ }, {});
1814
+ }
1815
+ function viewportAddonType(viewport) {
1816
+ if (viewport.width < 600) return "mobile";
1817
+ if (viewport.width < 1024) return "tablet";
1818
+ return "desktop";
1819
+ }
1820
+ function findDefaultViewport(viewports) {
1821
+ const compareFn = (vp1, vp2) => {
1822
+ if (vp1.width < vp2.width) return 1;
1823
+ if (vp1.width > vp2.width) return -1;
1824
+ return 0;
1825
+ };
1826
+ return viewports.sort(compareFn)[0];
1827
+ }
1828
+
1829
+ //#endregion
1830
+ //#region ../shared/src/write-archive/index.ts
1831
+ async function writeTestResult(e2eTestInfo, domSnapshots, archive, chromaticStorybookParams) {
1832
+ const { titlePath, outputDir, pageUrl, storiesFileId } = e2eTestInfo;
1833
+ const title = titlePath.map((pathPart) => pathPart.replace(/\.(ts|js|mjs|cjs|tsx|jsx|cjsx|coffee)$/, "").replace(/\.(spec|test|cy)$/, "")).join("/").replace(/\/([ ’–—―′¿'`~!@#$%^&*()_|+\-=?;:'",.<>\{\}\[\]\\]+)\//gi, "$1/");
1834
+ const finalOutputDir = join(outputDir, "chromatic-archives");
1835
+ const archiveDir = join(finalOutputDir, "archive");
1836
+ ensureDir(archiveDir);
1837
+ logger.log(`Writing test results for "${title}"`);
1838
+ const sourceMap = /* @__PURE__ */ new Map();
1839
+ await Promise.all(Object.entries(archive).map(async ([url, response]) => {
1840
+ if ("error" in response) return;
1841
+ const archiveFile = new ArchiveFile(url, response, pageUrl);
1842
+ const origSrcPath = archiveFile.originalSrc();
1843
+ const fileSystemPath = archiveFile.toFileSystemPath();
1844
+ const responsePath = join(archiveDir, fileSystemPath);
1845
+ if (origSrcPath !== fileSystemPath) sourceMap.set(origSrcPath, fileSystemPath);
1846
+ if (!existsSync(responsePath)) await outputFile(responsePath, response.body);
1847
+ }));
1848
+ await Promise.all(Object.entries(domSnapshots).map(async ([name, domSnapshot]) => {
1849
+ const mappedSnapshot = await new DOMSnapshot(domSnapshot).mapAssetPaths(sourceMap);
1850
+ const snapshotFile = snapshotFileName(snapshotId(title, name), domSnapshot.viewport);
1851
+ await outputFile(join(archiveDir, snapshotFile), mappedSnapshot);
1852
+ }));
1853
+ const storiesFile = join(finalOutputDir, storiesFileName(title, storiesFileId));
1854
+ const storiesJson = createStories(title, domSnapshots, chromaticStorybookParams);
1855
+ await outputJSONFile(storiesFile, storiesJson);
1856
+ const errors = Object.entries(archive).filter(([, r]) => "error" in r);
1857
+ if (errors.length > 0) {
1858
+ logger.log(`Encountered ${errors.length} errors archiving resources, writing to 'errors.json'`);
1859
+ await outputJSONFile(join(archiveDir, `errors.json`), { errors: Object.fromEntries(errors) });
1860
+ }
1861
+ return { storiesFile };
1862
+ }
1863
+
1864
+ //#endregion
1865
+ //#region ../shared/src/constants.ts
1866
+ const DEFAULT_GLOBAL_RESOURCE_ARCHIVE_TIMEOUT_MS = 1e4;
1867
+
1868
+ //#endregion
1869
+ //#region src/node/NetworkIdleTracker.ts
1870
+ var NetworkIdleTimeoutError = class extends Error {
1871
+ name = "NetworkIdleTimeoutError";
1872
+ };
1873
+ var NetworkIdleTracker = class NetworkIdleTracker {
1874
+ cdp;
1875
+ idleTimeout;
1876
+ pending = /* @__PURE__ */ new Set();
1877
+ idleTimer = null;
1878
+ idleResolvers = [];
1879
+ constructor(cdp, idleTimeout) {
1880
+ this.cdp = cdp;
1881
+ this.idleTimeout = idleTimeout;
1882
+ }
1883
+ static async create(cdp, idleTimeout) {
1884
+ return new NetworkIdleTracker(cdp, idleTimeout);
1885
+ }
1886
+ async watch() {
1887
+ this.cdp.on("Network.requestWillBeSent", this.onRequest);
1888
+ this.cdp.on("Network.loadingFinished", this.onComplete);
1889
+ this.cdp.on("Network.loadingFailed", this.onComplete);
1890
+ await this.cdp.send("Network.enable");
1891
+ }
1892
+ async unwatch() {
1893
+ this.cdp.off("Network.requestWillBeSent", this.onRequest);
1894
+ this.cdp.off("Network.loadingFinished", this.onComplete);
1895
+ this.cdp.off("Network.loadingFailed", this.onComplete);
1896
+ this.clearTimer();
1897
+ this.pending.clear();
1898
+ this.idleResolvers.splice(0).forEach((fn) => fn());
1899
+ await this.cdp.send("Network.disable");
1900
+ }
1901
+ waitForIdle(rejectTimeout) {
1902
+ if (this.pending.size === 0 && this.idleTimer === null) return Promise.resolve();
1903
+ return new Promise((resolve, reject) => {
1904
+ const timeout = setTimeout(() => reject(new NetworkIdleTimeoutError("Timed out waiting for network to be idle")), rejectTimeout);
1905
+ this.idleResolvers.push(resolve, () => clearTimeout(timeout));
1906
+ });
1907
+ }
1908
+ onComplete = (params) => {
1909
+ this.pending.delete(params.requestId);
1910
+ if (this.pending.size === 0) this.startTimer();
1911
+ };
1912
+ onRequest = (params) => {
1913
+ this.pending.add(params.requestId);
1914
+ this.clearTimer();
1915
+ };
1916
+ startTimer() {
1917
+ this.clearTimer();
1918
+ this.idleTimer = setTimeout(() => {
1919
+ this.idleTimer = null;
1920
+ this.idleResolvers.splice(0).forEach((fn) => fn());
1921
+ }, this.idleTimeout)?.unref();
1922
+ }
1923
+ clearTimer() {
1924
+ if (this.idleTimer) {
1925
+ clearTimeout(this.idleTimer);
1926
+ this.idleTimer = null;
1927
+ }
1928
+ }
1929
+ };
1930
+
1931
+ //#endregion
1932
+ //#region src/node/reporter.ts
1933
+ const REPORTER_NAME$1 = "chromatic-reporter";
1934
+ var ChromaticReporter = class ChromaticReporter {
1935
+ ctx;
1936
+ options;
1937
+ snapshotCountPerEntity;
1938
+ isPluginActivated;
1939
+ name = REPORTER_NAME$1;
1940
+ constructor(ctx, options, snapshotCountPerEntity = /* @__PURE__ */ new Map(), isPluginActivated = false) {
1941
+ this.ctx = ctx;
1942
+ this.options = options;
1943
+ this.snapshotCountPerEntity = snapshotCountPerEntity;
1944
+ this.isPluginActivated = isPluginActivated;
1945
+ }
1946
+ static apply(ctx, pluginOptions) {
1947
+ const options = {
1948
+ verbose: pluginOptions.reporter.verbose,
1949
+ outputDirectory: pluginOptions.outputDirectory,
1950
+ turboSnap: pluginOptions.turboSnap,
1951
+ logToFile: pluginOptions.telemetry.enabled && pluginOptions.telemetry.logToFile,
1952
+ builtInReporter: "default"
1953
+ };
1954
+ for (const reporter of ctx.config.reporters) {
1955
+ if (isChromaticReporter(reporter)) return;
1956
+ if (!Array.isArray(reporter)) continue;
1957
+ const reporterName = reporter[0];
1958
+ if (reporterName === "tree" || reporterName === "default" || reporterName === "verbose") options.builtInReporter = reporterName;
1959
+ }
1960
+ ctx.config.reporters.push(new ChromaticReporter(ctx, options));
1961
+ }
1962
+ static onSnapshot(ctx, test) {
1963
+ ctx.config.reporters.find(isChromaticReporter)?._onSnapshot(test);
1964
+ }
1965
+ static onPluginActivated(ctx) {
1966
+ ctx.config.reporters.find(isChromaticReporter)?._onPluginActivated();
1967
+ }
1968
+ onTestCaseResult(testCase) {
1969
+ if (this.options.builtInReporter !== "verbose") return;
1970
+ this.logSnapshots({
1971
+ count: this.snapshotCountPerEntity.get(testCase.id) ?? 0,
1972
+ indentation: 3,
1973
+ projectName: testCase.project.name
1974
+ });
1975
+ }
1976
+ onTestModuleEnd(testModule) {
1977
+ if (this.options.builtInReporter !== "default" && this.options.builtInReporter !== "tree") return;
1978
+ let noSlowTests = true;
1979
+ for (const testCase of testModule.children.allTests()) if (testCase.diagnostic()?.slow) {
1980
+ noSlowTests = false;
1981
+ break;
1982
+ }
1983
+ const indentProjectName = noSlowTests && this.options.builtInReporter === "default";
1984
+ this.logSnapshots({
1985
+ count: this.snapshotCountPerEntity.get(testModule.id) ?? 0,
1986
+ indentation: indentProjectName ? 3 : 2,
1987
+ projectName: indentProjectName && testModule.project.name
1988
+ });
1989
+ }
1990
+ onTestRunEnd() {
1991
+ const snapshotCount = [...this.snapshotCountPerEntity.values()].reduce((a, b) => a + b, 0);
1992
+ this.snapshotCountPerEntity.clear();
1993
+ const separator = colors.dim("─".repeat(this.ctx.logger.getColumns()));
1994
+ if (!this.isPluginActivated) return this.ctx.logger.log(`${separator}`, `\n${colors.inverse(" Chromatic Visual Regression ")}`, `\n\n${colors.red("No archives captured. Chromatic plugin requires a browser mode project with Chromium project.")}`, `\n\n${separator}\n`);
1995
+ if (snapshotCount === 0) return;
1996
+ const output = resolve(this.ctx.config.root, this.options.outputDirectory);
1997
+ let uploadCommand = "chromatic --vitest --project-token=<TOKEN>";
1998
+ if (this.options.turboSnap) uploadCommand += " --only-changed";
1999
+ if (this.options.outputDirectory !== ".vitest/chromatic" || this.ctx.config.root !== process.cwd()) uploadCommand = `CHROMATIC_ARCHIVE_LOCATION=${relative(process.cwd(), output)} ${uploadCommand}`;
2000
+ const telemetryInfo = this.options.logToFile ? `\nTelemetry events logged to ${colors.dim(resolve(output, TELEMETRY_LOG_FILE))}` : "";
2001
+ this.ctx.logger.log(`${separator}`, `\n${colors.inverse(" Chromatic Visual Regression ")}`, `\n\n${colors.green("✓")} ${snapshotCount} ${pluralize(snapshotCount, "archive")} captured`, `\n\nArchives saved in ${colors.dim(output)}`, telemetryInfo, `\nTo upload archives into Chromatic run ${colors.green(uploadCommand)}`, `\n\n${separator}\n`);
2002
+ }
2003
+ logSnapshots(options) {
2004
+ if (!this.options.verbose || options.count === 0) return;
2005
+ const snapshots = `(${options.count} ${pluralize(options.count, "archive")} captured)`;
2006
+ if (options.projectName) options.indentation += options.projectName.length + 2;
2007
+ this.ctx.logger.log(`${" ".repeat(options.indentation)} ${colors.dim(snapshots)}`);
2008
+ }
2009
+ _onSnapshot(test) {
2010
+ const key = this.options.builtInReporter === "verbose" ? test.id : test.module.id;
2011
+ const previousCount = this.snapshotCountPerEntity.get(key) ?? 0;
2012
+ this.snapshotCountPerEntity.set(key, previousCount + 1);
2013
+ }
2014
+ _onPluginActivated() {
2015
+ this.isPluginActivated = true;
2016
+ }
2017
+ };
2018
+ function isChromaticReporter(reporter) {
2019
+ return "name" in reporter && reporter.name === REPORTER_NAME$1;
2020
+ }
2021
+ function pluralize(count, text) {
2022
+ return count === 1 ? text : `${text}s`;
2023
+ }
2024
+
2025
+ //#endregion
2026
+ //#region src/node/webpack-stats-reporter.ts
2027
+ const REPORTER_NAME = "chromatic-webpack-stats-reporter";
2028
+ const VIRTUAL_MODULE_PREFIX = "\0";
2029
+ const VITE_APP_FILE = "/virtual:/@storybook/builder-vite/vite-app.js";
2030
+ const VITE_STORIES_FILE = "/virtual:/@storybook/builder-vite/storybook-stories.js";
2031
+ var WebpackStatsReporter = class WebpackStatsReporter {
2032
+ ctx;
2033
+ options;
2034
+ moduleIdsToStoryFiles;
2035
+ name = REPORTER_NAME;
2036
+ constructor(ctx, options, moduleIdsToStoryFiles = /* @__PURE__ */ new Map()) {
2037
+ this.ctx = ctx;
2038
+ this.options = options;
2039
+ this.moduleIdsToStoryFiles = moduleIdsToStoryFiles;
2040
+ }
2041
+ static apply(ctx, pluginOptions) {
2042
+ if (!ctx.config.reporters.some(isWebpackStatsReporter)) {
2043
+ const filename = [
2044
+ "preview-stats",
2045
+ ctx.config.shard && `-${ctx.config.shard.index}-${ctx.config.shard.count}`,
2046
+ ".json"
2047
+ ].filter(Boolean).join("");
2048
+ const outputFile = resolve(ctx.config.root, pluginOptions.outputDirectory, filename);
2049
+ ctx.config.reporters.push(new WebpackStatsReporter(ctx, {
2050
+ outputFile,
2051
+ pluginOptions
2052
+ }));
2053
+ }
2054
+ }
2055
+ static onStoryFileWrite(ctx, testCase, storyFilePath) {
2056
+ ctx.config.reporters.find(isWebpackStatsReporter)?._onStoryFileWrite(testCase, storyFilePath);
2057
+ }
2058
+ _onStoryFileWrite(testCase, storyFilePath) {
2059
+ const moduleId = testCase.module.moduleId;
2060
+ let entry = this.moduleIdsToStoryFiles.get(moduleId);
2061
+ if (!entry) {
2062
+ entry = /* @__PURE__ */ new Set();
2063
+ this.moduleIdsToStoryFiles.set(moduleId, entry);
2064
+ }
2065
+ entry.add(storyFilePath);
2066
+ }
2067
+ async onTestRunStart() {
2068
+ await rm(this.options.outputFile, { force: true });
2069
+ this.moduleIdsToStoryFiles.clear();
2070
+ }
2071
+ async onTestRunEnd(testModules) {
2072
+ try {
2073
+ await this.writePreviewStats(testModules);
2074
+ } catch (error) {
2075
+ trackEvent({
2076
+ eventType: "turbosnap_error",
2077
+ level: "error",
2078
+ payload: {
2079
+ operation: "write-stats",
2080
+ error
2081
+ }
2082
+ }, this.ctx, this.options.pluginOptions);
2083
+ throw error;
2084
+ }
2085
+ }
2086
+ async writePreviewStats(testModules) {
2087
+ const statsMap = /* @__PURE__ */ new Map();
2088
+ if (this.moduleIdsToStoryFiles.size > 0) statsMap.set(VITE_STORIES_FILE, {
2089
+ id: VITE_STORIES_FILE,
2090
+ name: VITE_STORIES_FILE,
2091
+ reasons: [{ moduleName: VITE_APP_FILE }]
2092
+ });
2093
+ for (const testModule of testModules) {
2094
+ const storyFiles = this.moduleIdsToStoryFiles.get(testModule.moduleId);
2095
+ if (!storyFiles || storyFiles.size === 0) continue;
2096
+ const vite = testModule.project.browser?.vite;
2097
+ if (!vite) continue;
2098
+ const id = this.normalize(testModule.moduleId);
2099
+ const additionalModules = [];
2100
+ statsMap.set(id, this.createStatsMapModule(id, [...storyFiles]));
2101
+ for (const storyFile of storyFiles) {
2102
+ const name = this.normalize(storyFile);
2103
+ const storyFileId = `./${name}`;
2104
+ statsMap.set(storyFileId, {
2105
+ id: storyFileId,
2106
+ name,
2107
+ reasons: [{ moduleName: VITE_STORIES_FILE }]
2108
+ });
2109
+ }
2110
+ const configFile = testModule.project.vite.config.configFile;
2111
+ if (configFile) additionalModules.push({
2112
+ id: configFile,
2113
+ isInModuleGraph: false
2114
+ });
2115
+ for (const setupFile of testModule.project.config.setupFiles) additionalModules.push({
2116
+ id: setupFile,
2117
+ isInModuleGraph: true
2118
+ });
2119
+ this.addModule(testModule.moduleId, statsMap, vite.moduleGraph, vite.config.cacheDir, /* @__PURE__ */ new Set(), additionalModules);
2120
+ }
2121
+ if (!existsSync(dirname(this.options.outputFile))) await mkdir(dirname(this.options.outputFile), { recursive: true });
2122
+ await writeFile(this.options.outputFile, JSON.stringify({ modules: Array.from(statsMap.values()) }, null, 2), "utf-8");
2123
+ }
2124
+ addModule(id, statsMap, moduleGraph, cacheDir, visited, additionalModules = []) {
2125
+ if (visited.has(id)) return;
2126
+ visited.add(id);
2127
+ const mod = moduleGraph.getModuleById(id);
2128
+ if (!mod) return this.ctx.logger.error(`[chromatic] Could not find module for id ${id}. Excluding from TurboSnap.`);
2129
+ const importedModules = [...additionalModules];
2130
+ for (const imported of mod.importedModules) {
2131
+ if (imported.id == null) {
2132
+ if (imported.file) {
2133
+ if (mod.file && isCSSRequest(mod.file) && !isCSSRequest(imported.file)) continue;
2134
+ importedModules.push({
2135
+ id: imported.file,
2136
+ isInModuleGraph: false
2137
+ });
2138
+ }
2139
+ continue;
2140
+ }
2141
+ if (!imported.id.startsWith(cacheDir)) {
2142
+ importedModules.push({
2143
+ id: imported.id,
2144
+ isInModuleGraph: true
2145
+ });
2146
+ continue;
2147
+ }
2148
+ importedModules.push(...resolveOptimizedDependencySources(imported, cacheDir, visited));
2149
+ }
2150
+ for (const imported of importedModules) {
2151
+ if (imported.id.startsWith(VIRTUAL_MODULE_PREFIX)) continue;
2152
+ if (imported.isInModuleGraph) this.addModule(imported.id, statsMap, moduleGraph, cacheDir, visited);
2153
+ const depId = this.normalize(imported.id);
2154
+ const entry = statsMap.get(depId);
2155
+ if (!entry) {
2156
+ statsMap.set(depId, this.createStatsMapModule(depId, [mod.id]));
2157
+ continue;
2158
+ }
2159
+ const moduleName = this.normalize(mod.id);
2160
+ if (!entry.reasons.find((reason) => reason.moduleName === moduleName)) entry.reasons.push({ moduleName });
2161
+ }
2162
+ }
2163
+ createStatsMapModule(filename, importers) {
2164
+ return {
2165
+ id: filename,
2166
+ name: filename,
2167
+ reasons: importers.map((importer) => ({ moduleName: this.normalize(importer) }))
2168
+ };
2169
+ }
2170
+ normalize(filePath) {
2171
+ return relative(process.cwd(), filePath).replaceAll(sep, "/").split("?")[0];
2172
+ }
2173
+ };
2174
+ function isWebpackStatsReporter(reporter) {
2175
+ return "name" in reporter && reporter.name === REPORTER_NAME;
2176
+ }
2177
+ function resolveOptimizedDependencySources(mod, cacheDir, visited) {
2178
+ if (visited.has(mod.id)) return [];
2179
+ visited.add(mod.id);
2180
+ const sources = getChunkSources(mod, cacheDir).map((id) => ({
2181
+ id,
2182
+ isInModuleGraph: false
2183
+ }));
2184
+ for (const imported of mod.importedModules) {
2185
+ if (imported.id == null) {
2186
+ if (imported.file) sources.push({
2187
+ id: imported.file,
2188
+ isInModuleGraph: false
2189
+ });
2190
+ continue;
2191
+ }
2192
+ if (imported.id.startsWith(VIRTUAL_MODULE_PREFIX)) continue;
2193
+ if (imported.id.startsWith(cacheDir)) sources.push(...resolveOptimizedDependencySources(imported, cacheDir, visited));
2194
+ else sources.push({
2195
+ id: imported.id,
2196
+ isInModuleGraph: true
2197
+ });
2198
+ }
2199
+ return sources;
2200
+ }
2201
+ function getChunkSources(mod, cacheDir) {
2202
+ const sources = resolveMapSources(mod, mod.transformResult?.map, cacheDir);
2203
+ if (sources.length) return sources;
2204
+ try {
2205
+ return resolveMapSources(mod, JSON.parse(readFileSync(`${mod.id.split("?")[0]}.map`, "utf-8")), cacheDir);
2206
+ } catch {
2207
+ return [];
2208
+ }
2209
+ }
2210
+ function resolveMapSources(mod, map, cacheDir) {
2211
+ if (!map || typeof map !== "object" || !("sources" in map) || !Array.isArray(map.sources)) return [];
2212
+ return map.sources.flatMap((source) => {
2213
+ if (typeof source !== "string" || source.startsWith(VIRTUAL_MODULE_PREFIX)) return [];
2214
+ const resolved = resolve(dirname(mod.id), source).replaceAll(sep, "/");
2215
+ if (resolved.startsWith(cacheDir)) return [];
2216
+ return [resolved];
2217
+ });
2218
+ }
2219
+ async function mergePreviewStats(options) {
2220
+ const outputDirectory = resolve(options.root, options.outputDirectory);
2221
+ const merged = /* @__PURE__ */ new Map();
2222
+ for (const filename of await readdir(outputDirectory)) if (filename.startsWith("preview-stats") && filename.endsWith(".json")) {
2223
+ const fullFilename = resolve(outputDirectory, filename);
2224
+ const stats = JSON.parse(await readFile(fullFilename, "utf-8"));
2225
+ for (const mod of stats.modules) {
2226
+ const previous = merged.get(mod.id);
2227
+ if (previous) {
2228
+ for (const reason of mod.reasons) if (!previous.reasons.some((r) => r.moduleName === reason.moduleName)) previous.reasons.push(reason);
2229
+ } else merged.set(mod.id, mod);
2230
+ }
2231
+ await rm(fullFilename);
2232
+ }
2233
+ await writeFile(resolve(outputDirectory, "preview-stats.json"), JSON.stringify({ modules: Array.from(merged.values()) }, null, 2), "utf-8");
2234
+ }
2235
+
2236
+ //#endregion
2237
+ //#region src/node/commands.ts
2238
+ function createCommands(options) {
2239
+ const resourceArchivers = /* @__PURE__ */ new Map();
2240
+ const networkIdleTrackers = /* @__PURE__ */ new Map();
2241
+ const savedResults = /* @__PURE__ */ new Set();
2242
+ const trackedCommandFailures = /* @__PURE__ */ new Set();
2243
+ const snapshots = /* @__PURE__ */ new Map();
2244
+ return withErrorTracking({
2245
+ async __chromatic_uploadDOMSnapshot(context, id, snapshot, pseudoClassIds, name, snapshotOptions) {
2246
+ const entity = context.project.vitest.state.getReportedEntityById(id);
2247
+ assert(entity?.type === "test", `Expected entity with id ${id} to be a test, found ${entity?.type}`);
2248
+ let sessionSnapshots = snapshots.get(id);
2249
+ if (!sessionSnapshots) {
2250
+ sessionSnapshots = /* @__PURE__ */ new Map();
2251
+ snapshots.set(id, sessionSnapshots);
2252
+ }
2253
+ const isCustomName = name != void 0;
2254
+ name ||= `Snapshot #${sessionSnapshots.size + 1}`;
2255
+ const { viewport, colorScheme } = await (await context.frame()).evaluate(() => ({
2256
+ viewport: {
2257
+ width: window.innerWidth,
2258
+ height: window.innerHeight
2259
+ },
2260
+ colorScheme: window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light"
2261
+ }));
2262
+ sessionSnapshots.set(name, {
2263
+ snapshot,
2264
+ viewport,
2265
+ colorScheme,
2266
+ pseudoClassIds
2267
+ });
2268
+ ChromaticReporter.onSnapshot(context.project.vitest, entity);
2269
+ TelemetryReporter.onSnapshot(context.project.vitest, {
2270
+ isCustomName,
2271
+ colorScheme,
2272
+ isAutomaticSnapshot: snapshotOptions?.isAutomaticSnapshot ?? false
2273
+ });
2274
+ },
2275
+ async __chromatic_waitForIdleNetwork(context, timeout) {
2276
+ const networkIdleTracker = networkIdleTrackers.get(context.sessionId);
2277
+ assert(networkIdleTracker, `No network idle tracker found for session ${context.sessionId}`);
2278
+ await networkIdleTracker.waitForIdle(timeout);
2279
+ },
2280
+ async __chromatic_interceptFetch(context) {
2281
+ let resourceArchiver = resourceArchivers.get(context.sessionId);
2282
+ let networkIdleTracker = networkIdleTrackers.get(context.sessionId);
2283
+ let cdp;
2284
+ if (!resourceArchiver || !networkIdleTracker) {
2285
+ cdp = await context.provider.getCDPSession?.(context.sessionId);
2286
+ assert(cdp, `Unable to get CDP session for session ${context.sessionId}`);
2287
+ }
2288
+ if (!resourceArchiver) {
2289
+ const { contextOptions } = context.project.config.browser.provider?.options ?? {};
2290
+ resourceArchiver = new ResourceArchiver(cdp, options.assetDomains, contextOptions?.httpCredentials, new URL(context.page.url()));
2291
+ resourceArchivers.set(context.sessionId, resourceArchiver);
2292
+ }
2293
+ if (!networkIdleTracker) {
2294
+ networkIdleTracker = await NetworkIdleTracker.create(cdp, options.idleNetworkInterval);
2295
+ networkIdleTrackers.set(context.sessionId, networkIdleTracker);
2296
+ }
2297
+ await networkIdleTracker.watch();
2298
+ await resourceArchiver.watch();
2299
+ },
2300
+ async __chromatic_writeTestResult(context, id, testOptions = {}) {
2301
+ const entity = context.project.vitest.state.getReportedEntityById(id);
2302
+ assert(entity?.type === "test", `Expected entity with id ${id} to be a test, found ${entity?.type}`);
2303
+ const { archive, sessionSnapshots } = await onTestCleanup(context, id);
2304
+ assert(sessionSnapshots, `No snapshots found for test ${id}`);
2305
+ const snapshotBuffers = {};
2306
+ const titlePath = testOptions.title ? [testOptions.title] : getTitle(entity);
2307
+ for (const [name, { snapshot, viewport, colorScheme, pseudoClassIds }] of sessionSnapshots) {
2308
+ const names = generateUniqueSnapshotName({
2309
+ snapshotName: getSnapshotPrefix(entity).concat(name),
2310
+ titlePath
2311
+ });
2312
+ snapshotBuffers[names] = {
2313
+ snapshot: Buffer.from(JSON.stringify(snapshot)),
2314
+ viewport,
2315
+ colorScheme,
2316
+ pseudoClassIds,
2317
+ parameters: { chromatic: { vitest: {
2318
+ suites: getSuiteNames(entity),
2319
+ test: entity.name,
2320
+ snapshot: name
2321
+ } } }
2322
+ };
2323
+ }
2324
+ const { storiesFile } = await writeTestResult({
2325
+ outputDir: resolve(context.project.vitest.config.root, options.outputDirectory),
2326
+ pageUrl: context.page.url(),
2327
+ titlePath,
2328
+ storiesFileId: getStoriesFileId(entity, testOptions)
2329
+ }, snapshotBuffers, archive, {
2330
+ delay: testOptions.delay ?? options.delay,
2331
+ diffIncludeAntiAliasing: testOptions.diffIncludeAntiAliasing ?? options.diffIncludeAntiAliasing,
2332
+ diffThreshold: testOptions.diffThreshold ?? options.diffThreshold,
2333
+ forcedColors: testOptions.forcedColors ?? options.forcedColors,
2334
+ pauseAnimationAtEnd: testOptions.pauseAnimationAtEnd ?? options.pauseAnimationAtEnd,
2335
+ prefersReducedMotion: testOptions.prefersReducedMotion ?? options.prefersReducedMotion,
2336
+ cropToViewport: testOptions.cropToViewport ?? options.cropToViewport,
2337
+ ignoreSelectors: testOptions.ignoreSelectors ?? options.ignoreSelectors
2338
+ });
2339
+ if (options.turboSnap) WebpackStatsReporter.onStoryFileWrite(context.project.vitest, entity, storiesFile);
2340
+ trackEvent({
2341
+ eventType: "archives_created",
2342
+ level: "info",
2343
+ payload: { archiveCount: Object.keys(snapshotBuffers).length }
2344
+ }, context.project.vitest, options);
2345
+ },
2346
+ async __chromatic_stopWithoutSnapshots(context, id) {
2347
+ await onTestCleanup(context, id);
2348
+ },
2349
+ async __chromatic_telemetry(context, event) {
2350
+ trackEvent(event, context.project.vitest, options);
2351
+ },
2352
+ async __chromatic_reset() {
2353
+ for (const resourceArchiver of resourceArchivers.values()) resourceArchiver.archive = {};
2354
+ resourceArchivers.clear();
2355
+ networkIdleTrackers.clear();
2356
+ snapshots.clear();
2357
+ savedResults.clear();
2358
+ trackedCommandFailures.clear();
2359
+ },
2360
+ async __chromatic_getSnapshots(_, id) {
2361
+ return Object.fromEntries(snapshots.get(id) || []);
2362
+ }
2363
+ });
2364
+ function withErrorTracking(_commands) {
2365
+ return Object.fromEntries(Object.entries(_commands).map(([name, command]) => [name, async (context, ...args) => {
2366
+ try {
2367
+ return await command(context, ...args);
2368
+ } catch (error) {
2369
+ trackCommandFailure(name, error, context);
2370
+ throw error;
2371
+ }
2372
+ }]));
2373
+ }
2374
+ function trackCommandFailure(command, error, context) {
2375
+ if (command === "__chromatic_telemetry" || command === "__chromatic_getSnapshots") return;
2376
+ const key = `${command}:${error instanceof Error ? error.message : String(error)}`;
2377
+ if (trackedCommandFailures.has(key)) return;
2378
+ trackedCommandFailures.add(key);
2379
+ try {
2380
+ trackEvent({
2381
+ eventType: "command_failed",
2382
+ level: "error",
2383
+ payload: {
2384
+ command,
2385
+ error
2386
+ }
2387
+ }, context.project.vitest, options);
2388
+ } catch {}
2389
+ }
2390
+ async function onTestCleanup(context, id) {
2391
+ const resourceArchiver = resourceArchivers.get(context.sessionId);
2392
+ assert(resourceArchiver, `No resource archiver found for test ${id}`);
2393
+ const networkIdleTracker = networkIdleTrackers.get(context.sessionId);
2394
+ assert(networkIdleTracker, `No network idle tracker found for test ${id}`);
2395
+ await resourceArchiver.unwatch();
2396
+ await networkIdleTracker.unwatch();
2397
+ const sessionSnapshots = snapshots.get(id);
2398
+ snapshots.delete(id);
2399
+ return {
2400
+ archive: resourceArchiver.archive,
2401
+ sessionSnapshots
2402
+ };
2403
+ }
2404
+ function generateUniqueSnapshotName(options) {
2405
+ const names = options.snapshotName.join(" / ");
2406
+ const base = toId(options.titlePath.join(" / "), storyNameFromExport(names));
2407
+ let key = base;
2408
+ let count = 1;
2409
+ while (savedResults.has(key)) key = `${base} (${count++})`;
2410
+ savedResults.add(key);
2411
+ if (count > 1) return `${names} (${count})`;
2412
+ return names;
2413
+ }
2414
+ }
2415
+ function getTitle(test) {
2416
+ const names = [removeFileExtensions(test.module.relativeModuleId)];
2417
+ if (test.project.vitest.projects.filter((project) => project.config.browser.name === "chromium").length > 1 && test.project.name) names.unshift(test.project.name);
2418
+ return names;
2419
+ }
2420
+ function getStoriesFileId(test, testOptions) {
2421
+ const position = getTestPosition(test);
2422
+ if (testOptions.title) return [...getTitle(test), position].join("-");
2423
+ return position;
2424
+ }
2425
+ function getTestPosition(test) {
2426
+ let index = 0;
2427
+ for (const entry of test.module.children.allTests()) {
2428
+ if (entry.id === test.id) return String(index);
2429
+ index++;
2430
+ }
2431
+ throw new Error(`Test "${test.fullName}" not found from its test module ${test.module.moduleId}`);
2432
+ }
2433
+ function getSnapshotPrefix(test) {
2434
+ const names = [test.name];
2435
+ let current = test;
2436
+ while ("parent" in current && current.parent) {
2437
+ current = current.parent;
2438
+ if ("name" in current && current.name) names.unshift(current.name);
2439
+ }
2440
+ return names;
2441
+ }
2442
+ function getSuiteNames(test) {
2443
+ if (test.parent.type !== "suite") return [];
2444
+ const names = [];
2445
+ let current = test;
2446
+ while ("parent" in current && current.parent) {
2447
+ current = current.parent;
2448
+ if (current.type === "suite") names.unshift(current.name);
2449
+ }
2450
+ return names;
2451
+ }
2452
+ function removeFileExtensions(filepath) {
2453
+ const parts = filepath.split("/");
2454
+ const filename = parts.pop() || "";
2455
+ return parts.concat(filename.split(".")[0]).join("/");
2456
+ }
2457
+
2458
+ //#endregion
2459
+ //#region src/node/plugin.ts
2460
+ const DEFAULT_TAG_DESCRIPTION = "Visual Regression Tests for `@chromatic-com/vitest`";
2461
+ function chromaticPlugin(userOptions = {}) {
2462
+ const options = {
2463
+ assetDomains: [],
2464
+ disableAutoSnapshot: false,
2465
+ outputDirectory: DEFAULT_OUTPUT_DIR,
2466
+ resourceArchiveTimeout: DEFAULT_GLOBAL_RESOURCE_ARCHIVE_TIMEOUT_MS,
2467
+ idleNetworkInterval: 100,
2468
+ turboSnap: false,
2469
+ ...userOptions,
2470
+ reporter: resolveReporterOptions(userOptions.reporter),
2471
+ telemetry: resolveTelemetryOptions()
2472
+ };
2473
+ const isDist = import.meta.url.includes("dist/plugin.mjs");
2474
+ const setupFile = resolve(import.meta.dirname, isDist ? "./setupFile.mjs" : "../browser/setupFile.ts");
2475
+ return {
2476
+ name: "vitest:chromatic",
2477
+ config() {
2478
+ return {
2479
+ optimizeDeps: { entries: [setupFile] },
2480
+ resolve: version.startsWith("4.0") ? void 0 : { alias: { "vitest/suite": "vitest" } },
2481
+ test: {
2482
+ provide: { __chromatic_options: options },
2483
+ browser: { commands: createCommands(options) }
2484
+ }
2485
+ };
2486
+ },
2487
+ configureVitest: withErrorTracking(options, async (context) => {
2488
+ const project = context.project;
2489
+ const browser = project.config.browser;
2490
+ const sequence = context.vitest.config.sequence;
2491
+ const isMergeReports = project.globalConfig.mergeReports;
2492
+ if (!isMergeReports) cleanTelemetryLogFiles(resolve(project.vitest.config.root, options.outputDirectory));
2493
+ if (options.telemetry.enabled) {
2494
+ setupTelemetryCleanup(context.vitest);
2495
+ trackEvent$1({
2496
+ eventType: "plugin_configured",
2497
+ level: "info",
2498
+ payload: {
2499
+ isShardedRun: project.config.shard != null,
2500
+ cropToViewport: options.cropToViewport,
2501
+ delay: options.delay,
2502
+ diffIncludeAntiAliasing: options.diffIncludeAntiAliasing,
2503
+ diffThreshold: options.diffThreshold,
2504
+ disableAutoSnapshot: options.disableAutoSnapshot,
2505
+ forcedColors: options.forcedColors,
2506
+ idleNetworkInterval: options.idleNetworkInterval,
2507
+ pauseAnimationAtEnd: options.pauseAnimationAtEnd,
2508
+ prefersReducedMotion: options.prefersReducedMotion,
2509
+ resourceArchiveTimeout: options.resourceArchiveTimeout,
2510
+ turboSnap: options.turboSnap,
2511
+ reporter: !options.reporter.enabled ? "off" : options.reporter.verbose ? "verbose" : "non-verbose",
2512
+ isCustomOutputDirectory: options.outputDirectory !== DEFAULT_OUTPUT_DIR,
2513
+ assetDomainsCount: options.assetDomains?.length ?? 0,
2514
+ ignoreSelectorsCount: options.ignoreSelectors?.length ?? 0,
2515
+ tagsCount: options.tags?.length ?? 0
2516
+ }
2517
+ });
2518
+ }
2519
+ if (options.reporter.enabled) ChromaticReporter.apply(context.vitest, options);
2520
+ if (!browser.enabled || browser.name !== "chromium") {
2521
+ trackEvent$1({
2522
+ eventType: "project_ineligible",
2523
+ level: "warn",
2524
+ payload: {
2525
+ isBrowser: browser.enabled,
2526
+ isChromium: browser.name === "chromium"
2527
+ }
2528
+ });
2529
+ return clean();
2530
+ }
2531
+ ChromaticReporter.onPluginActivated(context.vitest);
2532
+ if (options.turboSnap && !isMergeReports) WebpackStatsReporter.apply(context.vitest, options);
2533
+ if (options.telemetry.enabled) TelemetryReporter.apply(context.vitest, options);
2534
+ if (sequence.hooks === "stack") project.config.setupFiles.push(setupFile);
2535
+ else if (sequence.hooks === "list") project.config.setupFiles.unshift(setupFile);
2536
+ else {
2537
+ trackEvent$1({
2538
+ eventType: "setup_files_parallel",
2539
+ level: "warn",
2540
+ payload: { setupFileCount: project.config.setupFiles.length }
2541
+ });
2542
+ project.config.setupFiles.push(setupFile);
2543
+ context.vitest.logger.warn(colors.bgYellow(colors.black(" chromatic ")), colors.yellow(`Using { sequence.hooks: 'parallel' } may cause unstable snapshots. Please set 'sequence.hooks' to 'list' or 'stack' to ensure reliable snapshot ordering.`));
2544
+ }
2545
+ if (options.tags && context.vitest.version.startsWith("4.0")) {
2546
+ context.vitest.logger.warn(colors.bgYellow(colors.black(" chromatic ")), colors.yellow(`Tags cannot be used with Vitest ${context.vitest.version}. Please upgrade to Vitest 4.1 or later to use this feature.`));
2547
+ trackEvent$1({
2548
+ eventType: "tags_low_version",
2549
+ level: "warn",
2550
+ payload: {}
2551
+ });
2552
+ }
2553
+ if (options.tags) {
2554
+ project.config.tags ||= [];
2555
+ for (const tag of options.tags) if (!project.config.tags.find((userTag) => userTag.name === tag)) project.config.tags.push({
2556
+ name: tag,
2557
+ description: DEFAULT_TAG_DESCRIPTION
2558
+ });
2559
+ }
2560
+ if (isMergeReports) {
2561
+ if (options.turboSnap) try {
2562
+ await mergePreviewStats({
2563
+ root: project.vitest.config.root,
2564
+ outputDirectory: options.outputDirectory
2565
+ });
2566
+ } catch (error) {
2567
+ trackEvent$1({
2568
+ eventType: "turbosnap_error",
2569
+ level: "error",
2570
+ payload: {
2571
+ operation: "merge-stats",
2572
+ error
2573
+ }
2574
+ });
2575
+ throw error;
2576
+ }
2577
+ } else clean();
2578
+ project.onTestsRerun(async () => {
2579
+ clean();
2580
+ await project.browser?.triggerCommand("__chromatic_reset", {});
2581
+ });
2582
+ function clean() {
2583
+ const outputDirectory = resolve(project.vitest.config.root, options.outputDirectory);
2584
+ rmSync(resolve(outputDirectory, "chromatic-archives"), {
2585
+ recursive: true,
2586
+ force: true
2587
+ });
2588
+ cleanTelemetryLogFiles(outputDirectory);
2589
+ if (existsSync(outputDirectory)) {
2590
+ for (const file of readdirSync(outputDirectory)) if (file.startsWith("preview-stats") && file.endsWith(".json")) rmSync(resolve(outputDirectory, file), { force: true });
2591
+ }
2592
+ }
2593
+ function trackEvent$1(event) {
2594
+ trackEvent(event, context.vitest, options);
2595
+ }
2596
+ })
2597
+ };
2598
+ }
2599
+ function withErrorTracking(options, configureVitest) {
2600
+ return async (context) => {
2601
+ try {
2602
+ return await configureVitest(context);
2603
+ } catch (error) {
2604
+ trackEvent({
2605
+ eventType: "plugin_error",
2606
+ level: "error",
2607
+ payload: {
2608
+ operation: "configure",
2609
+ error
2610
+ }
2611
+ }, context.vitest, options);
2612
+ throw error;
2613
+ }
2614
+ };
2615
+ }
2616
+ function resolveReporterOptions(reporter) {
2617
+ if (reporter == void 0 || reporter === true) return {
2618
+ enabled: true,
2619
+ verbose: true
2620
+ };
2621
+ if (reporter === false) return {
2622
+ enabled: false,
2623
+ verbose: false
2624
+ };
2625
+ return {
2626
+ enabled: reporter.enabled ?? true,
2627
+ verbose: reporter.verbose ?? true
2628
+ };
2629
+ }
2630
+
2631
+ //#endregion
2632
+ export { chromaticPlugin };