ortoni-report 4.1.0-test.0 → 5.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,1504 +0,0 @@
1
- import {
2
- DatabaseManager,
3
- FileManager,
4
- HTMLGenerator,
5
- __publicField,
6
- ensureHtmlExtension,
7
- escapeHtml,
8
- extractSuites,
9
- normalizeFilePath,
10
- startReportServer
11
- } from "./chunk-4RZ5C7KY.mjs";
12
-
13
- // src/helpers/resultProcessor.ts
14
- import AnsiToHtml from "ansi-to-html";
15
- import path2 from "path";
16
-
17
- // src/utils/attachFiles.ts
18
- import path from "path";
19
- import fs2 from "fs";
20
-
21
- // src/helpers/markdownConverter.ts
22
- import fs from "fs";
23
-
24
- // node_modules/marked/lib/marked.esm.js
25
- function M() {
26
- return { async: false, breaks: false, extensions: null, gfm: true, hooks: null, pedantic: false, renderer: null, silent: false, tokenizer: null, walkTokens: null };
27
- }
28
- var w = M();
29
- function H(a3) {
30
- w = a3;
31
- }
32
- var C = { exec: () => null };
33
- function h(a3, e = "") {
34
- let t = typeof a3 == "string" ? a3 : a3.source, n = { replace: (s, i) => {
35
- let r = typeof i == "string" ? i : i.source;
36
- return r = r.replace(m.caret, "$1"), t = t.replace(s, r), n;
37
- }, getRegex: () => new RegExp(t, e) };
38
- return n;
39
- }
40
- var m = { codeRemoveIndent: /^(?: {1,4}| {0,3}\t)/gm, outputLinkReplace: /\\([\[\]])/g, indentCodeCompensation: /^(\s+)(?:```)/, beginningSpace: /^\s+/, endingHash: /#$/, startingSpaceChar: /^ /, endingSpaceChar: / $/, nonSpaceChar: /[^ ]/, newLineCharGlobal: /\n/g, tabCharGlobal: /\t/g, multipleSpaceGlobal: /\s+/g, blankLine: /^[ \t]*$/, doubleBlankLine: /\n[ \t]*\n[ \t]*$/, blockquoteStart: /^ {0,3}>/, blockquoteSetextReplace: /\n {0,3}((?:=+|-+) *)(?=\n|$)/g, blockquoteSetextReplace2: /^ {0,3}>[ \t]?/gm, listReplaceTabs: /^\t+/, listReplaceNesting: /^ {1,4}(?=( {4})*[^ ])/g, listIsTask: /^\[[ xX]\] /, listReplaceTask: /^\[[ xX]\] +/, anyLine: /\n.*\n/, hrefBrackets: /^<(.*)>$/, tableDelimiter: /[:|]/, tableAlignChars: /^\||\| *$/g, tableRowBlankLine: /\n[ \t]*$/, tableAlignRight: /^ *-+: *$/, tableAlignCenter: /^ *:-+: *$/, tableAlignLeft: /^ *:-+ *$/, startATag: /^<a /i, endATag: /^<\/a>/i, startPreScriptTag: /^<(pre|code|kbd|script)(\s|>)/i, endPreScriptTag: /^<\/(pre|code|kbd|script)(\s|>)/i, startAngleBracket: /^</, endAngleBracket: />$/, pedanticHrefTitle: /^([^'"]*[^\s])\s+(['"])(.*)\2/, unicodeAlphaNumeric: /[\p{L}\p{N}]/u, escapeTest: /[&<>"']/, escapeReplace: /[&<>"']/g, escapeTestNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/, escapeReplaceNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g, unescapeTest: /&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig, caret: /(^|[^\[])\^/g, percentDecode: /%25/g, findPipe: /\|/g, splitPipe: / \|/, slashPipe: /\\\|/g, carriageReturn: /\r\n|\r/g, spaceLine: /^ +$/gm, notSpaceStart: /^\S*/, endingNewline: /\n$/, listItemRegex: (a3) => new RegExp(`^( {0,3}${a3})((?:[ ][^\\n]*)?(?:\\n|$))`), nextBulletRegex: (a3) => new RegExp(`^ {0,${Math.min(3, a3 - 1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`), hrRegex: (a3) => new RegExp(`^ {0,${Math.min(3, a3 - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`), fencesBeginRegex: (a3) => new RegExp(`^ {0,${Math.min(3, a3 - 1)}}(?:\`\`\`|~~~)`), headingBeginRegex: (a3) => new RegExp(`^ {0,${Math.min(3, a3 - 1)}}#`), htmlBeginRegex: (a3) => new RegExp(`^ {0,${Math.min(3, a3 - 1)}}<(?:[a-z].*>|!--)`, "i") };
41
- var xe = /^(?:[ \t]*(?:\n|$))+/;
42
- var be = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/;
43
- var Te = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/;
44
- var I = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/;
45
- var we = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/;
46
- var j = /(?:[*+-]|\d{1,9}[.)])/;
47
- var re = /^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/;
48
- var ie = h(re).replace(/bull/g, j).replace(/blockCode/g, /(?: {4}| {0,3}\t)/).replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g, / {0,3}>/).replace(/heading/g, / {0,3}#{1,6}/).replace(/html/g, / {0,3}<[^\n>]+>\n/).replace(/\|table/g, "").getRegex();
49
- var ye = h(re).replace(/bull/g, j).replace(/blockCode/g, /(?: {4}| {0,3}\t)/).replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g, / {0,3}>/).replace(/heading/g, / {0,3}#{1,6}/).replace(/html/g, / {0,3}<[^\n>]+>\n/).replace(/table/g, / {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex();
50
- var F = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/;
51
- var Re = /^[^\n]+/;
52
- var Q = /(?!\s*\])(?:\\.|[^\[\]\\])+/;
53
- var Se = h(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label", Q).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex();
54
- var $e = h(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g, j).getRegex();
55
- var v = "address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul";
56
- var U = /<!--(?:-?>|[\s\S]*?(?:-->|$))/;
57
- var _e = h("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))", "i").replace("comment", U).replace("tag", v).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex();
58
- var oe = h(F).replace("hr", I).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("|table", "").replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", v).getRegex();
59
- var Le = h(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", oe).getRegex();
60
- var K = { blockquote: Le, code: be, def: Se, fences: Te, heading: we, hr: I, html: _e, lheading: ie, list: $e, newline: xe, paragraph: oe, table: C, text: Re };
61
- var se = h("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr", I).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("blockquote", " {0,3}>").replace("code", "(?: {4}| {0,3} )[^\\n]").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", v).getRegex();
62
- var ze = { ...K, lheading: ye, table: se, paragraph: h(F).replace("hr", I).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("table", se).replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", v).getRegex() };
63
- var Me = { ...K, html: h(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment", U).replace(/tag/g, "(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(), def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/, heading: /^(#{1,6})(.*)(?:\n+|$)/, fences: C, lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/, paragraph: h(F).replace("hr", I).replace("heading", ` *#{1,6} *[^
64
- ]`).replace("lheading", ie).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex() };
65
- var Pe = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/;
66
- var Ae = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/;
67
- var le = /^( {2,}|\\)\n(?!\s*$)/;
68
- var Ee = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/;
69
- var D = /[\p{P}\p{S}]/u;
70
- var X = /[\s\p{P}\p{S}]/u;
71
- var ae = /[^\s\p{P}\p{S}]/u;
72
- var Ce = h(/^((?![*_])punctSpace)/, "u").replace(/punctSpace/g, X).getRegex();
73
- var ce = /(?!~)[\p{P}\p{S}]/u;
74
- var Ie = /(?!~)[\s\p{P}\p{S}]/u;
75
- var Oe = /(?:[^\s\p{P}\p{S}]|~)/u;
76
- var Be = /\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g;
77
- var pe = /^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/;
78
- var qe = h(pe, "u").replace(/punct/g, D).getRegex();
79
- var ve = h(pe, "u").replace(/punct/g, ce).getRegex();
80
- var ue = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)";
81
- var De = h(ue, "gu").replace(/notPunctSpace/g, ae).replace(/punctSpace/g, X).replace(/punct/g, D).getRegex();
82
- var Ze = h(ue, "gu").replace(/notPunctSpace/g, Oe).replace(/punctSpace/g, Ie).replace(/punct/g, ce).getRegex();
83
- var Ge = h("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)", "gu").replace(/notPunctSpace/g, ae).replace(/punctSpace/g, X).replace(/punct/g, D).getRegex();
84
- var He = h(/\\(punct)/, "gu").replace(/punct/g, D).getRegex();
85
- var Ne = h(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme", /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email", /[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex();
86
- var je = h(U).replace("(?:-->|$)", "-->").getRegex();
87
- var Fe = h("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment", je).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex();
88
- var q = /(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/;
89
- var Qe = h(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label", q).replace("href", /<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex();
90
- var he = h(/^!?\[(label)\]\[(ref)\]/).replace("label", q).replace("ref", Q).getRegex();
91
- var ke = h(/^!?\[(ref)\](?:\[\])?/).replace("ref", Q).getRegex();
92
- var Ue = h("reflink|nolink(?!\\()", "g").replace("reflink", he).replace("nolink", ke).getRegex();
93
- var W = { _backpedal: C, anyPunctuation: He, autolink: Ne, blockSkip: Be, br: le, code: Ae, del: C, emStrongLDelim: qe, emStrongRDelimAst: De, emStrongRDelimUnd: Ge, escape: Pe, link: Qe, nolink: ke, punctuation: Ce, reflink: he, reflinkSearch: Ue, tag: Fe, text: Ee, url: C };
94
- var Ke = { ...W, link: h(/^!?\[(label)\]\((.*?)\)/).replace("label", q).getRegex(), reflink: h(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", q).getRegex() };
95
- var N = { ...W, emStrongRDelimAst: Ze, emStrongLDelim: ve, url: h(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/, "i").replace("email", /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(), _backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/, del: /^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/, text: /^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/ };
96
- var Xe = { ...N, br: h(le).replace("{2,}", "*").getRegex(), text: h(N.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex() };
97
- var O = { normal: K, gfm: ze, pedantic: Me };
98
- var P = { normal: W, gfm: N, breaks: Xe, pedantic: Ke };
99
- var We = { "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" };
100
- var ge = (a3) => We[a3];
101
- function R(a3, e) {
102
- if (e) {
103
- if (m.escapeTest.test(a3)) return a3.replace(m.escapeReplace, ge);
104
- } else if (m.escapeTestNoEncode.test(a3)) return a3.replace(m.escapeReplaceNoEncode, ge);
105
- return a3;
106
- }
107
- function J(a3) {
108
- try {
109
- a3 = encodeURI(a3).replace(m.percentDecode, "%");
110
- } catch {
111
- return null;
112
- }
113
- return a3;
114
- }
115
- function V(a3, e) {
116
- let t = a3.replace(m.findPipe, (i, r, o) => {
117
- let l = false, c = r;
118
- for (; --c >= 0 && o[c] === "\\"; ) l = !l;
119
- return l ? "|" : " |";
120
- }), n = t.split(m.splitPipe), s = 0;
121
- if (n[0].trim() || n.shift(), n.length > 0 && !n.at(-1)?.trim() && n.pop(), e) if (n.length > e) n.splice(e);
122
- else for (; n.length < e; ) n.push("");
123
- for (; s < n.length; s++) n[s] = n[s].trim().replace(m.slashPipe, "|");
124
- return n;
125
- }
126
- function A(a3, e, t) {
127
- let n = a3.length;
128
- if (n === 0) return "";
129
- let s = 0;
130
- for (; s < n; ) {
131
- let i = a3.charAt(n - s - 1);
132
- if (i === e && !t) s++;
133
- else if (i !== e && t) s++;
134
- else break;
135
- }
136
- return a3.slice(0, n - s);
137
- }
138
- function fe(a3, e) {
139
- if (a3.indexOf(e[1]) === -1) return -1;
140
- let t = 0;
141
- for (let n = 0; n < a3.length; n++) if (a3[n] === "\\") n++;
142
- else if (a3[n] === e[0]) t++;
143
- else if (a3[n] === e[1] && (t--, t < 0)) return n;
144
- return t > 0 ? -2 : -1;
145
- }
146
- function de(a3, e, t, n, s) {
147
- let i = e.href, r = e.title || null, o = a3[1].replace(s.other.outputLinkReplace, "$1");
148
- n.state.inLink = true;
149
- let l = { type: a3[0].charAt(0) === "!" ? "image" : "link", raw: t, href: i, title: r, text: o, tokens: n.inlineTokens(o) };
150
- return n.state.inLink = false, l;
151
- }
152
- function Je(a3, e, t) {
153
- let n = a3.match(t.other.indentCodeCompensation);
154
- if (n === null) return e;
155
- let s = n[1];
156
- return e.split(`
157
- `).map((i) => {
158
- let r = i.match(t.other.beginningSpace);
159
- if (r === null) return i;
160
- let [o] = r;
161
- return o.length >= s.length ? i.slice(s.length) : i;
162
- }).join(`
163
- `);
164
- }
165
- var S = class {
166
- constructor(e) {
167
- __publicField(this, "options");
168
- __publicField(this, "rules");
169
- __publicField(this, "lexer");
170
- this.options = e || w;
171
- }
172
- space(e) {
173
- let t = this.rules.block.newline.exec(e);
174
- if (t && t[0].length > 0) return { type: "space", raw: t[0] };
175
- }
176
- code(e) {
177
- let t = this.rules.block.code.exec(e);
178
- if (t) {
179
- let n = t[0].replace(this.rules.other.codeRemoveIndent, "");
180
- return { type: "code", raw: t[0], codeBlockStyle: "indented", text: this.options.pedantic ? n : A(n, `
181
- `) };
182
- }
183
- }
184
- fences(e) {
185
- let t = this.rules.block.fences.exec(e);
186
- if (t) {
187
- let n = t[0], s = Je(n, t[3] || "", this.rules);
188
- return { type: "code", raw: n, lang: t[2] ? t[2].trim().replace(this.rules.inline.anyPunctuation, "$1") : t[2], text: s };
189
- }
190
- }
191
- heading(e) {
192
- let t = this.rules.block.heading.exec(e);
193
- if (t) {
194
- let n = t[2].trim();
195
- if (this.rules.other.endingHash.test(n)) {
196
- let s = A(n, "#");
197
- (this.options.pedantic || !s || this.rules.other.endingSpaceChar.test(s)) && (n = s.trim());
198
- }
199
- return { type: "heading", raw: t[0], depth: t[1].length, text: n, tokens: this.lexer.inline(n) };
200
- }
201
- }
202
- hr(e) {
203
- let t = this.rules.block.hr.exec(e);
204
- if (t) return { type: "hr", raw: A(t[0], `
205
- `) };
206
- }
207
- blockquote(e) {
208
- let t = this.rules.block.blockquote.exec(e);
209
- if (t) {
210
- let n = A(t[0], `
211
- `).split(`
212
- `), s = "", i = "", r = [];
213
- for (; n.length > 0; ) {
214
- let o = false, l = [], c;
215
- for (c = 0; c < n.length; c++) if (this.rules.other.blockquoteStart.test(n[c])) l.push(n[c]), o = true;
216
- else if (!o) l.push(n[c]);
217
- else break;
218
- n = n.slice(c);
219
- let p = l.join(`
220
- `), u = p.replace(this.rules.other.blockquoteSetextReplace, `
221
- $1`).replace(this.rules.other.blockquoteSetextReplace2, "");
222
- s = s ? `${s}
223
- ${p}` : p, i = i ? `${i}
224
- ${u}` : u;
225
- let d = this.lexer.state.top;
226
- if (this.lexer.state.top = true, this.lexer.blockTokens(u, r, true), this.lexer.state.top = d, n.length === 0) break;
227
- let g = r.at(-1);
228
- if (g?.type === "code") break;
229
- if (g?.type === "blockquote") {
230
- let x = g, f = x.raw + `
231
- ` + n.join(`
232
- `), y = this.blockquote(f);
233
- r[r.length - 1] = y, s = s.substring(0, s.length - x.raw.length) + y.raw, i = i.substring(0, i.length - x.text.length) + y.text;
234
- break;
235
- } else if (g?.type === "list") {
236
- let x = g, f = x.raw + `
237
- ` + n.join(`
238
- `), y = this.list(f);
239
- r[r.length - 1] = y, s = s.substring(0, s.length - g.raw.length) + y.raw, i = i.substring(0, i.length - x.raw.length) + y.raw, n = f.substring(r.at(-1).raw.length).split(`
240
- `);
241
- continue;
242
- }
243
- }
244
- return { type: "blockquote", raw: s, tokens: r, text: i };
245
- }
246
- }
247
- list(e) {
248
- let t = this.rules.block.list.exec(e);
249
- if (t) {
250
- let n = t[1].trim(), s = n.length > 1, i = { type: "list", raw: "", ordered: s, start: s ? +n.slice(0, -1) : "", loose: false, items: [] };
251
- n = s ? `\\d{1,9}\\${n.slice(-1)}` : `\\${n}`, this.options.pedantic && (n = s ? n : "[*+-]");
252
- let r = this.rules.other.listItemRegex(n), o = false;
253
- for (; e; ) {
254
- let c = false, p = "", u = "";
255
- if (!(t = r.exec(e)) || this.rules.block.hr.test(e)) break;
256
- p = t[0], e = e.substring(p.length);
257
- let d = t[2].split(`
258
- `, 1)[0].replace(this.rules.other.listReplaceTabs, (Z) => " ".repeat(3 * Z.length)), g = e.split(`
259
- `, 1)[0], x = !d.trim(), f = 0;
260
- if (this.options.pedantic ? (f = 2, u = d.trimStart()) : x ? f = t[1].length + 1 : (f = t[2].search(this.rules.other.nonSpaceChar), f = f > 4 ? 1 : f, u = d.slice(f), f += t[1].length), x && this.rules.other.blankLine.test(g) && (p += g + `
261
- `, e = e.substring(g.length + 1), c = true), !c) {
262
- let Z = this.rules.other.nextBulletRegex(f), ee = this.rules.other.hrRegex(f), te = this.rules.other.fencesBeginRegex(f), ne = this.rules.other.headingBeginRegex(f), me = this.rules.other.htmlBeginRegex(f);
263
- for (; e; ) {
264
- let G = e.split(`
265
- `, 1)[0], E;
266
- if (g = G, this.options.pedantic ? (g = g.replace(this.rules.other.listReplaceNesting, " "), E = g) : E = g.replace(this.rules.other.tabCharGlobal, " "), te.test(g) || ne.test(g) || me.test(g) || Z.test(g) || ee.test(g)) break;
267
- if (E.search(this.rules.other.nonSpaceChar) >= f || !g.trim()) u += `
268
- ` + E.slice(f);
269
- else {
270
- if (x || d.replace(this.rules.other.tabCharGlobal, " ").search(this.rules.other.nonSpaceChar) >= 4 || te.test(d) || ne.test(d) || ee.test(d)) break;
271
- u += `
272
- ` + g;
273
- }
274
- !x && !g.trim() && (x = true), p += G + `
275
- `, e = e.substring(G.length + 1), d = E.slice(f);
276
- }
277
- }
278
- i.loose || (o ? i.loose = true : this.rules.other.doubleBlankLine.test(p) && (o = true));
279
- let y = null, Y;
280
- this.options.gfm && (y = this.rules.other.listIsTask.exec(u), y && (Y = y[0] !== "[ ] ", u = u.replace(this.rules.other.listReplaceTask, ""))), i.items.push({ type: "list_item", raw: p, task: !!y, checked: Y, loose: false, text: u, tokens: [] }), i.raw += p;
281
- }
282
- let l = i.items.at(-1);
283
- if (l) l.raw = l.raw.trimEnd(), l.text = l.text.trimEnd();
284
- else return;
285
- i.raw = i.raw.trimEnd();
286
- for (let c = 0; c < i.items.length; c++) if (this.lexer.state.top = false, i.items[c].tokens = this.lexer.blockTokens(i.items[c].text, []), !i.loose) {
287
- let p = i.items[c].tokens.filter((d) => d.type === "space"), u = p.length > 0 && p.some((d) => this.rules.other.anyLine.test(d.raw));
288
- i.loose = u;
289
- }
290
- if (i.loose) for (let c = 0; c < i.items.length; c++) i.items[c].loose = true;
291
- return i;
292
- }
293
- }
294
- html(e) {
295
- let t = this.rules.block.html.exec(e);
296
- if (t) return { type: "html", block: true, raw: t[0], pre: t[1] === "pre" || t[1] === "script" || t[1] === "style", text: t[0] };
297
- }
298
- def(e) {
299
- let t = this.rules.block.def.exec(e);
300
- if (t) {
301
- let n = t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal, " "), s = t[2] ? t[2].replace(this.rules.other.hrefBrackets, "$1").replace(this.rules.inline.anyPunctuation, "$1") : "", i = t[3] ? t[3].substring(1, t[3].length - 1).replace(this.rules.inline.anyPunctuation, "$1") : t[3];
302
- return { type: "def", tag: n, raw: t[0], href: s, title: i };
303
- }
304
- }
305
- table(e) {
306
- let t = this.rules.block.table.exec(e);
307
- if (!t || !this.rules.other.tableDelimiter.test(t[2])) return;
308
- let n = V(t[1]), s = t[2].replace(this.rules.other.tableAlignChars, "").split("|"), i = t[3]?.trim() ? t[3].replace(this.rules.other.tableRowBlankLine, "").split(`
309
- `) : [], r = { type: "table", raw: t[0], header: [], align: [], rows: [] };
310
- if (n.length === s.length) {
311
- for (let o of s) this.rules.other.tableAlignRight.test(o) ? r.align.push("right") : this.rules.other.tableAlignCenter.test(o) ? r.align.push("center") : this.rules.other.tableAlignLeft.test(o) ? r.align.push("left") : r.align.push(null);
312
- for (let o = 0; o < n.length; o++) r.header.push({ text: n[o], tokens: this.lexer.inline(n[o]), header: true, align: r.align[o] });
313
- for (let o of i) r.rows.push(V(o, r.header.length).map((l, c) => ({ text: l, tokens: this.lexer.inline(l), header: false, align: r.align[c] })));
314
- return r;
315
- }
316
- }
317
- lheading(e) {
318
- let t = this.rules.block.lheading.exec(e);
319
- if (t) return { type: "heading", raw: t[0], depth: t[2].charAt(0) === "=" ? 1 : 2, text: t[1], tokens: this.lexer.inline(t[1]) };
320
- }
321
- paragraph(e) {
322
- let t = this.rules.block.paragraph.exec(e);
323
- if (t) {
324
- let n = t[1].charAt(t[1].length - 1) === `
325
- ` ? t[1].slice(0, -1) : t[1];
326
- return { type: "paragraph", raw: t[0], text: n, tokens: this.lexer.inline(n) };
327
- }
328
- }
329
- text(e) {
330
- let t = this.rules.block.text.exec(e);
331
- if (t) return { type: "text", raw: t[0], text: t[0], tokens: this.lexer.inline(t[0]) };
332
- }
333
- escape(e) {
334
- let t = this.rules.inline.escape.exec(e);
335
- if (t) return { type: "escape", raw: t[0], text: t[1] };
336
- }
337
- tag(e) {
338
- let t = this.rules.inline.tag.exec(e);
339
- if (t) return !this.lexer.state.inLink && this.rules.other.startATag.test(t[0]) ? this.lexer.state.inLink = true : this.lexer.state.inLink && this.rules.other.endATag.test(t[0]) && (this.lexer.state.inLink = false), !this.lexer.state.inRawBlock && this.rules.other.startPreScriptTag.test(t[0]) ? this.lexer.state.inRawBlock = true : this.lexer.state.inRawBlock && this.rules.other.endPreScriptTag.test(t[0]) && (this.lexer.state.inRawBlock = false), { type: "html", raw: t[0], inLink: this.lexer.state.inLink, inRawBlock: this.lexer.state.inRawBlock, block: false, text: t[0] };
340
- }
341
- link(e) {
342
- let t = this.rules.inline.link.exec(e);
343
- if (t) {
344
- let n = t[2].trim();
345
- if (!this.options.pedantic && this.rules.other.startAngleBracket.test(n)) {
346
- if (!this.rules.other.endAngleBracket.test(n)) return;
347
- let r = A(n.slice(0, -1), "\\");
348
- if ((n.length - r.length) % 2 === 0) return;
349
- } else {
350
- let r = fe(t[2], "()");
351
- if (r === -2) return;
352
- if (r > -1) {
353
- let l = (t[0].indexOf("!") === 0 ? 5 : 4) + t[1].length + r;
354
- t[2] = t[2].substring(0, r), t[0] = t[0].substring(0, l).trim(), t[3] = "";
355
- }
356
- }
357
- let s = t[2], i = "";
358
- if (this.options.pedantic) {
359
- let r = this.rules.other.pedanticHrefTitle.exec(s);
360
- r && (s = r[1], i = r[3]);
361
- } else i = t[3] ? t[3].slice(1, -1) : "";
362
- return s = s.trim(), this.rules.other.startAngleBracket.test(s) && (this.options.pedantic && !this.rules.other.endAngleBracket.test(n) ? s = s.slice(1) : s = s.slice(1, -1)), de(t, { href: s && s.replace(this.rules.inline.anyPunctuation, "$1"), title: i && i.replace(this.rules.inline.anyPunctuation, "$1") }, t[0], this.lexer, this.rules);
363
- }
364
- }
365
- reflink(e, t) {
366
- let n;
367
- if ((n = this.rules.inline.reflink.exec(e)) || (n = this.rules.inline.nolink.exec(e))) {
368
- let s = (n[2] || n[1]).replace(this.rules.other.multipleSpaceGlobal, " "), i = t[s.toLowerCase()];
369
- if (!i) {
370
- let r = n[0].charAt(0);
371
- return { type: "text", raw: r, text: r };
372
- }
373
- return de(n, i, n[0], this.lexer, this.rules);
374
- }
375
- }
376
- emStrong(e, t, n = "") {
377
- let s = this.rules.inline.emStrongLDelim.exec(e);
378
- if (!s || s[3] && n.match(this.rules.other.unicodeAlphaNumeric)) return;
379
- if (!(s[1] || s[2] || "") || !n || this.rules.inline.punctuation.exec(n)) {
380
- let r = [...s[0]].length - 1, o, l, c = r, p = 0, u = s[0][0] === "*" ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd;
381
- for (u.lastIndex = 0, t = t.slice(-1 * e.length + r); (s = u.exec(t)) != null; ) {
382
- if (o = s[1] || s[2] || s[3] || s[4] || s[5] || s[6], !o) continue;
383
- if (l = [...o].length, s[3] || s[4]) {
384
- c += l;
385
- continue;
386
- } else if ((s[5] || s[6]) && r % 3 && !((r + l) % 3)) {
387
- p += l;
388
- continue;
389
- }
390
- if (c -= l, c > 0) continue;
391
- l = Math.min(l, l + c + p);
392
- let d = [...s[0]][0].length, g = e.slice(0, r + s.index + d + l);
393
- if (Math.min(r, l) % 2) {
394
- let f = g.slice(1, -1);
395
- return { type: "em", raw: g, text: f, tokens: this.lexer.inlineTokens(f) };
396
- }
397
- let x = g.slice(2, -2);
398
- return { type: "strong", raw: g, text: x, tokens: this.lexer.inlineTokens(x) };
399
- }
400
- }
401
- }
402
- codespan(e) {
403
- let t = this.rules.inline.code.exec(e);
404
- if (t) {
405
- let n = t[2].replace(this.rules.other.newLineCharGlobal, " "), s = this.rules.other.nonSpaceChar.test(n), i = this.rules.other.startingSpaceChar.test(n) && this.rules.other.endingSpaceChar.test(n);
406
- return s && i && (n = n.substring(1, n.length - 1)), { type: "codespan", raw: t[0], text: n };
407
- }
408
- }
409
- br(e) {
410
- let t = this.rules.inline.br.exec(e);
411
- if (t) return { type: "br", raw: t[0] };
412
- }
413
- del(e) {
414
- let t = this.rules.inline.del.exec(e);
415
- if (t) return { type: "del", raw: t[0], text: t[2], tokens: this.lexer.inlineTokens(t[2]) };
416
- }
417
- autolink(e) {
418
- let t = this.rules.inline.autolink.exec(e);
419
- if (t) {
420
- let n, s;
421
- return t[2] === "@" ? (n = t[1], s = "mailto:" + n) : (n = t[1], s = n), { type: "link", raw: t[0], text: n, href: s, tokens: [{ type: "text", raw: n, text: n }] };
422
- }
423
- }
424
- url(e) {
425
- let t;
426
- if (t = this.rules.inline.url.exec(e)) {
427
- let n, s;
428
- if (t[2] === "@") n = t[0], s = "mailto:" + n;
429
- else {
430
- let i;
431
- do
432
- i = t[0], t[0] = this.rules.inline._backpedal.exec(t[0])?.[0] ?? "";
433
- while (i !== t[0]);
434
- n = t[0], t[1] === "www." ? s = "http://" + t[0] : s = t[0];
435
- }
436
- return { type: "link", raw: t[0], text: n, href: s, tokens: [{ type: "text", raw: n, text: n }] };
437
- }
438
- }
439
- inlineText(e) {
440
- let t = this.rules.inline.text.exec(e);
441
- if (t) {
442
- let n = this.lexer.state.inRawBlock;
443
- return { type: "text", raw: t[0], text: t[0], escaped: n };
444
- }
445
- }
446
- };
447
- var b = class a {
448
- constructor(e) {
449
- __publicField(this, "tokens");
450
- __publicField(this, "options");
451
- __publicField(this, "state");
452
- __publicField(this, "tokenizer");
453
- __publicField(this, "inlineQueue");
454
- this.tokens = [], this.tokens.links = /* @__PURE__ */ Object.create(null), this.options = e || w, this.options.tokenizer = this.options.tokenizer || new S(), this.tokenizer = this.options.tokenizer, this.tokenizer.options = this.options, this.tokenizer.lexer = this, this.inlineQueue = [], this.state = { inLink: false, inRawBlock: false, top: true };
455
- let t = { other: m, block: O.normal, inline: P.normal };
456
- this.options.pedantic ? (t.block = O.pedantic, t.inline = P.pedantic) : this.options.gfm && (t.block = O.gfm, this.options.breaks ? t.inline = P.breaks : t.inline = P.gfm), this.tokenizer.rules = t;
457
- }
458
- static get rules() {
459
- return { block: O, inline: P };
460
- }
461
- static lex(e, t) {
462
- return new a(t).lex(e);
463
- }
464
- static lexInline(e, t) {
465
- return new a(t).inlineTokens(e);
466
- }
467
- lex(e) {
468
- e = e.replace(m.carriageReturn, `
469
- `), this.blockTokens(e, this.tokens);
470
- for (let t = 0; t < this.inlineQueue.length; t++) {
471
- let n = this.inlineQueue[t];
472
- this.inlineTokens(n.src, n.tokens);
473
- }
474
- return this.inlineQueue = [], this.tokens;
475
- }
476
- blockTokens(e, t = [], n = false) {
477
- for (this.options.pedantic && (e = e.replace(m.tabCharGlobal, " ").replace(m.spaceLine, "")); e; ) {
478
- let s;
479
- if (this.options.extensions?.block?.some((r) => (s = r.call({ lexer: this }, e, t)) ? (e = e.substring(s.raw.length), t.push(s), true) : false)) continue;
480
- if (s = this.tokenizer.space(e)) {
481
- e = e.substring(s.raw.length);
482
- let r = t.at(-1);
483
- s.raw.length === 1 && r !== void 0 ? r.raw += `
484
- ` : t.push(s);
485
- continue;
486
- }
487
- if (s = this.tokenizer.code(e)) {
488
- e = e.substring(s.raw.length);
489
- let r = t.at(-1);
490
- r?.type === "paragraph" || r?.type === "text" ? (r.raw += `
491
- ` + s.raw, r.text += `
492
- ` + s.text, this.inlineQueue.at(-1).src = r.text) : t.push(s);
493
- continue;
494
- }
495
- if (s = this.tokenizer.fences(e)) {
496
- e = e.substring(s.raw.length), t.push(s);
497
- continue;
498
- }
499
- if (s = this.tokenizer.heading(e)) {
500
- e = e.substring(s.raw.length), t.push(s);
501
- continue;
502
- }
503
- if (s = this.tokenizer.hr(e)) {
504
- e = e.substring(s.raw.length), t.push(s);
505
- continue;
506
- }
507
- if (s = this.tokenizer.blockquote(e)) {
508
- e = e.substring(s.raw.length), t.push(s);
509
- continue;
510
- }
511
- if (s = this.tokenizer.list(e)) {
512
- e = e.substring(s.raw.length), t.push(s);
513
- continue;
514
- }
515
- if (s = this.tokenizer.html(e)) {
516
- e = e.substring(s.raw.length), t.push(s);
517
- continue;
518
- }
519
- if (s = this.tokenizer.def(e)) {
520
- e = e.substring(s.raw.length);
521
- let r = t.at(-1);
522
- r?.type === "paragraph" || r?.type === "text" ? (r.raw += `
523
- ` + s.raw, r.text += `
524
- ` + s.raw, this.inlineQueue.at(-1).src = r.text) : this.tokens.links[s.tag] || (this.tokens.links[s.tag] = { href: s.href, title: s.title });
525
- continue;
526
- }
527
- if (s = this.tokenizer.table(e)) {
528
- e = e.substring(s.raw.length), t.push(s);
529
- continue;
530
- }
531
- if (s = this.tokenizer.lheading(e)) {
532
- e = e.substring(s.raw.length), t.push(s);
533
- continue;
534
- }
535
- let i = e;
536
- if (this.options.extensions?.startBlock) {
537
- let r = 1 / 0, o = e.slice(1), l;
538
- this.options.extensions.startBlock.forEach((c) => {
539
- l = c.call({ lexer: this }, o), typeof l == "number" && l >= 0 && (r = Math.min(r, l));
540
- }), r < 1 / 0 && r >= 0 && (i = e.substring(0, r + 1));
541
- }
542
- if (this.state.top && (s = this.tokenizer.paragraph(i))) {
543
- let r = t.at(-1);
544
- n && r?.type === "paragraph" ? (r.raw += `
545
- ` + s.raw, r.text += `
546
- ` + s.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = r.text) : t.push(s), n = i.length !== e.length, e = e.substring(s.raw.length);
547
- continue;
548
- }
549
- if (s = this.tokenizer.text(e)) {
550
- e = e.substring(s.raw.length);
551
- let r = t.at(-1);
552
- r?.type === "text" ? (r.raw += `
553
- ` + s.raw, r.text += `
554
- ` + s.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = r.text) : t.push(s);
555
- continue;
556
- }
557
- if (e) {
558
- let r = "Infinite loop on byte: " + e.charCodeAt(0);
559
- if (this.options.silent) {
560
- console.error(r);
561
- break;
562
- } else throw new Error(r);
563
- }
564
- }
565
- return this.state.top = true, t;
566
- }
567
- inline(e, t = []) {
568
- return this.inlineQueue.push({ src: e, tokens: t }), t;
569
- }
570
- inlineTokens(e, t = []) {
571
- let n = e, s = null;
572
- if (this.tokens.links) {
573
- let o = Object.keys(this.tokens.links);
574
- if (o.length > 0) for (; (s = this.tokenizer.rules.inline.reflinkSearch.exec(n)) != null; ) o.includes(s[0].slice(s[0].lastIndexOf("[") + 1, -1)) && (n = n.slice(0, s.index) + "[" + "a".repeat(s[0].length - 2) + "]" + n.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex));
575
- }
576
- for (; (s = this.tokenizer.rules.inline.anyPunctuation.exec(n)) != null; ) n = n.slice(0, s.index) + "++" + n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);
577
- for (; (s = this.tokenizer.rules.inline.blockSkip.exec(n)) != null; ) n = n.slice(0, s.index) + "[" + "a".repeat(s[0].length - 2) + "]" + n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
578
- let i = false, r = "";
579
- for (; e; ) {
580
- i || (r = ""), i = false;
581
- let o;
582
- if (this.options.extensions?.inline?.some((c) => (o = c.call({ lexer: this }, e, t)) ? (e = e.substring(o.raw.length), t.push(o), true) : false)) continue;
583
- if (o = this.tokenizer.escape(e)) {
584
- e = e.substring(o.raw.length), t.push(o);
585
- continue;
586
- }
587
- if (o = this.tokenizer.tag(e)) {
588
- e = e.substring(o.raw.length), t.push(o);
589
- continue;
590
- }
591
- if (o = this.tokenizer.link(e)) {
592
- e = e.substring(o.raw.length), t.push(o);
593
- continue;
594
- }
595
- if (o = this.tokenizer.reflink(e, this.tokens.links)) {
596
- e = e.substring(o.raw.length);
597
- let c = t.at(-1);
598
- o.type === "text" && c?.type === "text" ? (c.raw += o.raw, c.text += o.text) : t.push(o);
599
- continue;
600
- }
601
- if (o = this.tokenizer.emStrong(e, n, r)) {
602
- e = e.substring(o.raw.length), t.push(o);
603
- continue;
604
- }
605
- if (o = this.tokenizer.codespan(e)) {
606
- e = e.substring(o.raw.length), t.push(o);
607
- continue;
608
- }
609
- if (o = this.tokenizer.br(e)) {
610
- e = e.substring(o.raw.length), t.push(o);
611
- continue;
612
- }
613
- if (o = this.tokenizer.del(e)) {
614
- e = e.substring(o.raw.length), t.push(o);
615
- continue;
616
- }
617
- if (o = this.tokenizer.autolink(e)) {
618
- e = e.substring(o.raw.length), t.push(o);
619
- continue;
620
- }
621
- if (!this.state.inLink && (o = this.tokenizer.url(e))) {
622
- e = e.substring(o.raw.length), t.push(o);
623
- continue;
624
- }
625
- let l = e;
626
- if (this.options.extensions?.startInline) {
627
- let c = 1 / 0, p = e.slice(1), u;
628
- this.options.extensions.startInline.forEach((d) => {
629
- u = d.call({ lexer: this }, p), typeof u == "number" && u >= 0 && (c = Math.min(c, u));
630
- }), c < 1 / 0 && c >= 0 && (l = e.substring(0, c + 1));
631
- }
632
- if (o = this.tokenizer.inlineText(l)) {
633
- e = e.substring(o.raw.length), o.raw.slice(-1) !== "_" && (r = o.raw.slice(-1)), i = true;
634
- let c = t.at(-1);
635
- c?.type === "text" ? (c.raw += o.raw, c.text += o.text) : t.push(o);
636
- continue;
637
- }
638
- if (e) {
639
- let c = "Infinite loop on byte: " + e.charCodeAt(0);
640
- if (this.options.silent) {
641
- console.error(c);
642
- break;
643
- } else throw new Error(c);
644
- }
645
- }
646
- return t;
647
- }
648
- };
649
- var $ = class {
650
- constructor(e) {
651
- __publicField(this, "options");
652
- __publicField(this, "parser");
653
- this.options = e || w;
654
- }
655
- space(e) {
656
- return "";
657
- }
658
- code({ text: e, lang: t, escaped: n }) {
659
- let s = (t || "").match(m.notSpaceStart)?.[0], i = e.replace(m.endingNewline, "") + `
660
- `;
661
- return s ? '<pre><code class="language-' + R(s) + '">' + (n ? i : R(i, true)) + `</code></pre>
662
- ` : "<pre><code>" + (n ? i : R(i, true)) + `</code></pre>
663
- `;
664
- }
665
- blockquote({ tokens: e }) {
666
- return `<blockquote>
667
- ${this.parser.parse(e)}</blockquote>
668
- `;
669
- }
670
- html({ text: e }) {
671
- return e;
672
- }
673
- heading({ tokens: e, depth: t }) {
674
- return `<h${t}>${this.parser.parseInline(e)}</h${t}>
675
- `;
676
- }
677
- hr(e) {
678
- return `<hr>
679
- `;
680
- }
681
- list(e) {
682
- let t = e.ordered, n = e.start, s = "";
683
- for (let o = 0; o < e.items.length; o++) {
684
- let l = e.items[o];
685
- s += this.listitem(l);
686
- }
687
- let i = t ? "ol" : "ul", r = t && n !== 1 ? ' start="' + n + '"' : "";
688
- return "<" + i + r + `>
689
- ` + s + "</" + i + `>
690
- `;
691
- }
692
- listitem(e) {
693
- let t = "";
694
- if (e.task) {
695
- let n = this.checkbox({ checked: !!e.checked });
696
- e.loose ? e.tokens[0]?.type === "paragraph" ? (e.tokens[0].text = n + " " + e.tokens[0].text, e.tokens[0].tokens && e.tokens[0].tokens.length > 0 && e.tokens[0].tokens[0].type === "text" && (e.tokens[0].tokens[0].text = n + " " + R(e.tokens[0].tokens[0].text), e.tokens[0].tokens[0].escaped = true)) : e.tokens.unshift({ type: "text", raw: n + " ", text: n + " ", escaped: true }) : t += n + " ";
697
- }
698
- return t += this.parser.parse(e.tokens, !!e.loose), `<li>${t}</li>
699
- `;
700
- }
701
- checkbox({ checked: e }) {
702
- return "<input " + (e ? 'checked="" ' : "") + 'disabled="" type="checkbox">';
703
- }
704
- paragraph({ tokens: e }) {
705
- return `<p>${this.parser.parseInline(e)}</p>
706
- `;
707
- }
708
- table(e) {
709
- let t = "", n = "";
710
- for (let i = 0; i < e.header.length; i++) n += this.tablecell(e.header[i]);
711
- t += this.tablerow({ text: n });
712
- let s = "";
713
- for (let i = 0; i < e.rows.length; i++) {
714
- let r = e.rows[i];
715
- n = "";
716
- for (let o = 0; o < r.length; o++) n += this.tablecell(r[o]);
717
- s += this.tablerow({ text: n });
718
- }
719
- return s && (s = `<tbody>${s}</tbody>`), `<table>
720
- <thead>
721
- ` + t + `</thead>
722
- ` + s + `</table>
723
- `;
724
- }
725
- tablerow({ text: e }) {
726
- return `<tr>
727
- ${e}</tr>
728
- `;
729
- }
730
- tablecell(e) {
731
- let t = this.parser.parseInline(e.tokens), n = e.header ? "th" : "td";
732
- return (e.align ? `<${n} align="${e.align}">` : `<${n}>`) + t + `</${n}>
733
- `;
734
- }
735
- strong({ tokens: e }) {
736
- return `<strong>${this.parser.parseInline(e)}</strong>`;
737
- }
738
- em({ tokens: e }) {
739
- return `<em>${this.parser.parseInline(e)}</em>`;
740
- }
741
- codespan({ text: e }) {
742
- return `<code>${R(e, true)}</code>`;
743
- }
744
- br(e) {
745
- return "<br>";
746
- }
747
- del({ tokens: e }) {
748
- return `<del>${this.parser.parseInline(e)}</del>`;
749
- }
750
- link({ href: e, title: t, tokens: n }) {
751
- let s = this.parser.parseInline(n), i = J(e);
752
- if (i === null) return s;
753
- e = i;
754
- let r = '<a href="' + e + '"';
755
- return t && (r += ' title="' + R(t) + '"'), r += ">" + s + "</a>", r;
756
- }
757
- image({ href: e, title: t, text: n, tokens: s }) {
758
- s && (n = this.parser.parseInline(s, this.parser.textRenderer));
759
- let i = J(e);
760
- if (i === null) return R(n);
761
- e = i;
762
- let r = `<img src="${e}" alt="${n}"`;
763
- return t && (r += ` title="${R(t)}"`), r += ">", r;
764
- }
765
- text(e) {
766
- return "tokens" in e && e.tokens ? this.parser.parseInline(e.tokens) : "escaped" in e && e.escaped ? e.text : R(e.text);
767
- }
768
- };
769
- var _ = class {
770
- strong({ text: e }) {
771
- return e;
772
- }
773
- em({ text: e }) {
774
- return e;
775
- }
776
- codespan({ text: e }) {
777
- return e;
778
- }
779
- del({ text: e }) {
780
- return e;
781
- }
782
- html({ text: e }) {
783
- return e;
784
- }
785
- text({ text: e }) {
786
- return e;
787
- }
788
- link({ text: e }) {
789
- return "" + e;
790
- }
791
- image({ text: e }) {
792
- return "" + e;
793
- }
794
- br() {
795
- return "";
796
- }
797
- };
798
- var T = class a2 {
799
- constructor(e) {
800
- __publicField(this, "options");
801
- __publicField(this, "renderer");
802
- __publicField(this, "textRenderer");
803
- this.options = e || w, this.options.renderer = this.options.renderer || new $(), this.renderer = this.options.renderer, this.renderer.options = this.options, this.renderer.parser = this, this.textRenderer = new _();
804
- }
805
- static parse(e, t) {
806
- return new a2(t).parse(e);
807
- }
808
- static parseInline(e, t) {
809
- return new a2(t).parseInline(e);
810
- }
811
- parse(e, t = true) {
812
- let n = "";
813
- for (let s = 0; s < e.length; s++) {
814
- let i = e[s];
815
- if (this.options.extensions?.renderers?.[i.type]) {
816
- let o = i, l = this.options.extensions.renderers[o.type].call({ parser: this }, o);
817
- if (l !== false || !["space", "hr", "heading", "code", "table", "blockquote", "list", "html", "paragraph", "text"].includes(o.type)) {
818
- n += l || "";
819
- continue;
820
- }
821
- }
822
- let r = i;
823
- switch (r.type) {
824
- case "space": {
825
- n += this.renderer.space(r);
826
- continue;
827
- }
828
- case "hr": {
829
- n += this.renderer.hr(r);
830
- continue;
831
- }
832
- case "heading": {
833
- n += this.renderer.heading(r);
834
- continue;
835
- }
836
- case "code": {
837
- n += this.renderer.code(r);
838
- continue;
839
- }
840
- case "table": {
841
- n += this.renderer.table(r);
842
- continue;
843
- }
844
- case "blockquote": {
845
- n += this.renderer.blockquote(r);
846
- continue;
847
- }
848
- case "list": {
849
- n += this.renderer.list(r);
850
- continue;
851
- }
852
- case "html": {
853
- n += this.renderer.html(r);
854
- continue;
855
- }
856
- case "paragraph": {
857
- n += this.renderer.paragraph(r);
858
- continue;
859
- }
860
- case "text": {
861
- let o = r, l = this.renderer.text(o);
862
- for (; s + 1 < e.length && e[s + 1].type === "text"; ) o = e[++s], l += `
863
- ` + this.renderer.text(o);
864
- t ? n += this.renderer.paragraph({ type: "paragraph", raw: l, text: l, tokens: [{ type: "text", raw: l, text: l, escaped: true }] }) : n += l;
865
- continue;
866
- }
867
- default: {
868
- let o = 'Token with "' + r.type + '" type was not found.';
869
- if (this.options.silent) return console.error(o), "";
870
- throw new Error(o);
871
- }
872
- }
873
- }
874
- return n;
875
- }
876
- parseInline(e, t = this.renderer) {
877
- let n = "";
878
- for (let s = 0; s < e.length; s++) {
879
- let i = e[s];
880
- if (this.options.extensions?.renderers?.[i.type]) {
881
- let o = this.options.extensions.renderers[i.type].call({ parser: this }, i);
882
- if (o !== false || !["escape", "html", "link", "image", "strong", "em", "codespan", "br", "del", "text"].includes(i.type)) {
883
- n += o || "";
884
- continue;
885
- }
886
- }
887
- let r = i;
888
- switch (r.type) {
889
- case "escape": {
890
- n += t.text(r);
891
- break;
892
- }
893
- case "html": {
894
- n += t.html(r);
895
- break;
896
- }
897
- case "link": {
898
- n += t.link(r);
899
- break;
900
- }
901
- case "image": {
902
- n += t.image(r);
903
- break;
904
- }
905
- case "strong": {
906
- n += t.strong(r);
907
- break;
908
- }
909
- case "em": {
910
- n += t.em(r);
911
- break;
912
- }
913
- case "codespan": {
914
- n += t.codespan(r);
915
- break;
916
- }
917
- case "br": {
918
- n += t.br(r);
919
- break;
920
- }
921
- case "del": {
922
- n += t.del(r);
923
- break;
924
- }
925
- case "text": {
926
- n += t.text(r);
927
- break;
928
- }
929
- default: {
930
- let o = 'Token with "' + r.type + '" type was not found.';
931
- if (this.options.silent) return console.error(o), "";
932
- throw new Error(o);
933
- }
934
- }
935
- }
936
- return n;
937
- }
938
- };
939
- var _a;
940
- var L = (_a = class {
941
- constructor(e) {
942
- __publicField(this, "options");
943
- __publicField(this, "block");
944
- this.options = e || w;
945
- }
946
- preprocess(e) {
947
- return e;
948
- }
949
- postprocess(e) {
950
- return e;
951
- }
952
- processAllTokens(e) {
953
- return e;
954
- }
955
- provideLexer() {
956
- return this.block ? b.lex : b.lexInline;
957
- }
958
- provideParser() {
959
- return this.block ? T.parse : T.parseInline;
960
- }
961
- }, __publicField(_a, "passThroughHooks", /* @__PURE__ */ new Set(["preprocess", "postprocess", "processAllTokens"])), _a);
962
- var B = class {
963
- constructor(...e) {
964
- __publicField(this, "defaults", M());
965
- __publicField(this, "options", this.setOptions);
966
- __publicField(this, "parse", this.parseMarkdown(true));
967
- __publicField(this, "parseInline", this.parseMarkdown(false));
968
- __publicField(this, "Parser", T);
969
- __publicField(this, "Renderer", $);
970
- __publicField(this, "TextRenderer", _);
971
- __publicField(this, "Lexer", b);
972
- __publicField(this, "Tokenizer", S);
973
- __publicField(this, "Hooks", L);
974
- this.use(...e);
975
- }
976
- walkTokens(e, t) {
977
- let n = [];
978
- for (let s of e) switch (n = n.concat(t.call(this, s)), s.type) {
979
- case "table": {
980
- let i = s;
981
- for (let r of i.header) n = n.concat(this.walkTokens(r.tokens, t));
982
- for (let r of i.rows) for (let o of r) n = n.concat(this.walkTokens(o.tokens, t));
983
- break;
984
- }
985
- case "list": {
986
- let i = s;
987
- n = n.concat(this.walkTokens(i.items, t));
988
- break;
989
- }
990
- default: {
991
- let i = s;
992
- this.defaults.extensions?.childTokens?.[i.type] ? this.defaults.extensions.childTokens[i.type].forEach((r) => {
993
- let o = i[r].flat(1 / 0);
994
- n = n.concat(this.walkTokens(o, t));
995
- }) : i.tokens && (n = n.concat(this.walkTokens(i.tokens, t)));
996
- }
997
- }
998
- return n;
999
- }
1000
- use(...e) {
1001
- let t = this.defaults.extensions || { renderers: {}, childTokens: {} };
1002
- return e.forEach((n) => {
1003
- let s = { ...n };
1004
- if (s.async = this.defaults.async || s.async || false, n.extensions && (n.extensions.forEach((i) => {
1005
- if (!i.name) throw new Error("extension name required");
1006
- if ("renderer" in i) {
1007
- let r = t.renderers[i.name];
1008
- r ? t.renderers[i.name] = function(...o) {
1009
- let l = i.renderer.apply(this, o);
1010
- return l === false && (l = r.apply(this, o)), l;
1011
- } : t.renderers[i.name] = i.renderer;
1012
- }
1013
- if ("tokenizer" in i) {
1014
- if (!i.level || i.level !== "block" && i.level !== "inline") throw new Error("extension level must be 'block' or 'inline'");
1015
- let r = t[i.level];
1016
- r ? r.unshift(i.tokenizer) : t[i.level] = [i.tokenizer], i.start && (i.level === "block" ? t.startBlock ? t.startBlock.push(i.start) : t.startBlock = [i.start] : i.level === "inline" && (t.startInline ? t.startInline.push(i.start) : t.startInline = [i.start]));
1017
- }
1018
- "childTokens" in i && i.childTokens && (t.childTokens[i.name] = i.childTokens);
1019
- }), s.extensions = t), n.renderer) {
1020
- let i = this.defaults.renderer || new $(this.defaults);
1021
- for (let r in n.renderer) {
1022
- if (!(r in i)) throw new Error(`renderer '${r}' does not exist`);
1023
- if (["options", "parser"].includes(r)) continue;
1024
- let o = r, l = n.renderer[o], c = i[o];
1025
- i[o] = (...p) => {
1026
- let u = l.apply(i, p);
1027
- return u === false && (u = c.apply(i, p)), u || "";
1028
- };
1029
- }
1030
- s.renderer = i;
1031
- }
1032
- if (n.tokenizer) {
1033
- let i = this.defaults.tokenizer || new S(this.defaults);
1034
- for (let r in n.tokenizer) {
1035
- if (!(r in i)) throw new Error(`tokenizer '${r}' does not exist`);
1036
- if (["options", "rules", "lexer"].includes(r)) continue;
1037
- let o = r, l = n.tokenizer[o], c = i[o];
1038
- i[o] = (...p) => {
1039
- let u = l.apply(i, p);
1040
- return u === false && (u = c.apply(i, p)), u;
1041
- };
1042
- }
1043
- s.tokenizer = i;
1044
- }
1045
- if (n.hooks) {
1046
- let i = this.defaults.hooks || new L();
1047
- for (let r in n.hooks) {
1048
- if (!(r in i)) throw new Error(`hook '${r}' does not exist`);
1049
- if (["options", "block"].includes(r)) continue;
1050
- let o = r, l = n.hooks[o], c = i[o];
1051
- L.passThroughHooks.has(r) ? i[o] = (p) => {
1052
- if (this.defaults.async) return Promise.resolve(l.call(i, p)).then((d) => c.call(i, d));
1053
- let u = l.call(i, p);
1054
- return c.call(i, u);
1055
- } : i[o] = (...p) => {
1056
- let u = l.apply(i, p);
1057
- return u === false && (u = c.apply(i, p)), u;
1058
- };
1059
- }
1060
- s.hooks = i;
1061
- }
1062
- if (n.walkTokens) {
1063
- let i = this.defaults.walkTokens, r = n.walkTokens;
1064
- s.walkTokens = function(o) {
1065
- let l = [];
1066
- return l.push(r.call(this, o)), i && (l = l.concat(i.call(this, o))), l;
1067
- };
1068
- }
1069
- this.defaults = { ...this.defaults, ...s };
1070
- }), this;
1071
- }
1072
- setOptions(e) {
1073
- return this.defaults = { ...this.defaults, ...e }, this;
1074
- }
1075
- lexer(e, t) {
1076
- return b.lex(e, t ?? this.defaults);
1077
- }
1078
- parser(e, t) {
1079
- return T.parse(e, t ?? this.defaults);
1080
- }
1081
- parseMarkdown(e) {
1082
- return (n, s) => {
1083
- let i = { ...s }, r = { ...this.defaults, ...i }, o = this.onError(!!r.silent, !!r.async);
1084
- if (this.defaults.async === true && i.async === false) return o(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));
1085
- if (typeof n > "u" || n === null) return o(new Error("marked(): input parameter is undefined or null"));
1086
- if (typeof n != "string") return o(new Error("marked(): input parameter is of type " + Object.prototype.toString.call(n) + ", string expected"));
1087
- r.hooks && (r.hooks.options = r, r.hooks.block = e);
1088
- let l = r.hooks ? r.hooks.provideLexer() : e ? b.lex : b.lexInline, c = r.hooks ? r.hooks.provideParser() : e ? T.parse : T.parseInline;
1089
- if (r.async) return Promise.resolve(r.hooks ? r.hooks.preprocess(n) : n).then((p) => l(p, r)).then((p) => r.hooks ? r.hooks.processAllTokens(p) : p).then((p) => r.walkTokens ? Promise.all(this.walkTokens(p, r.walkTokens)).then(() => p) : p).then((p) => c(p, r)).then((p) => r.hooks ? r.hooks.postprocess(p) : p).catch(o);
1090
- try {
1091
- r.hooks && (n = r.hooks.preprocess(n));
1092
- let p = l(n, r);
1093
- r.hooks && (p = r.hooks.processAllTokens(p)), r.walkTokens && this.walkTokens(p, r.walkTokens);
1094
- let u = c(p, r);
1095
- return r.hooks && (u = r.hooks.postprocess(u)), u;
1096
- } catch (p) {
1097
- return o(p);
1098
- }
1099
- };
1100
- }
1101
- onError(e, t) {
1102
- return (n) => {
1103
- if (n.message += `
1104
- Please report this to https://github.com/markedjs/marked.`, e) {
1105
- let s = "<p>An error occurred:</p><pre>" + R(n.message + "", true) + "</pre>";
1106
- return t ? Promise.resolve(s) : s;
1107
- }
1108
- if (t) return Promise.reject(n);
1109
- throw n;
1110
- };
1111
- }
1112
- };
1113
- var z = new B();
1114
- function k(a3, e) {
1115
- return z.parse(a3, e);
1116
- }
1117
- k.options = k.setOptions = function(a3) {
1118
- return z.setOptions(a3), k.defaults = z.defaults, H(k.defaults), k;
1119
- };
1120
- k.getDefaults = M;
1121
- k.defaults = w;
1122
- k.use = function(...a3) {
1123
- return z.use(...a3), k.defaults = z.defaults, H(k.defaults), k;
1124
- };
1125
- k.walkTokens = function(a3, e) {
1126
- return z.walkTokens(a3, e);
1127
- };
1128
- k.parseInline = z.parseInline;
1129
- k.Parser = T;
1130
- k.parser = T.parse;
1131
- k.Renderer = $;
1132
- k.TextRenderer = _;
1133
- k.Lexer = b;
1134
- k.lexer = b.lex;
1135
- k.Tokenizer = S;
1136
- k.Hooks = L;
1137
- k.parse = k;
1138
- var Dt = k.options;
1139
- var Zt = k.setOptions;
1140
- var Gt = k.use;
1141
- var Ht = k.walkTokens;
1142
- var Nt = k.parseInline;
1143
- var Ft = T.parse;
1144
- var Qt = b.lex;
1145
-
1146
- // src/helpers/markdownConverter.ts
1147
- function convertMarkdownToHtml(markdownPath, htmlOutputPath) {
1148
- const hasMarkdown = fs.existsSync(markdownPath);
1149
- const markdownContent = hasMarkdown ? fs.readFileSync(markdownPath, "utf-8") : "";
1150
- const markdownHtml = hasMarkdown ? k(markdownContent) : "";
1151
- const drawerHtml = `${markdownHtml || ""}`;
1152
- fs.writeFileSync(htmlOutputPath, drawerHtml.trim(), "utf-8");
1153
- if (hasMarkdown) {
1154
- fs.unlinkSync(markdownPath);
1155
- }
1156
- }
1157
-
1158
- // src/utils/attachFiles.ts
1159
- function attachFiles(subFolder, result, testResult, config, steps, errors) {
1160
- const folderPath = config.folderPath || "ortoni-report";
1161
- const attachmentsFolder = path.join(
1162
- folderPath,
1163
- "ortoni-data",
1164
- "attachments",
1165
- subFolder
1166
- );
1167
- if (!fs2.existsSync(attachmentsFolder)) {
1168
- fs2.mkdirSync(attachmentsFolder, { recursive: true });
1169
- }
1170
- if (!result.attachments) return;
1171
- const { base64Image } = config;
1172
- testResult.screenshots = [];
1173
- testResult.videoPath = [];
1174
- result.attachments.forEach((attachment) => {
1175
- const { contentType, name, path: attachmentPath, body } = attachment;
1176
- if (!attachmentPath && !body) return;
1177
- const fileName = attachmentPath ? path.basename(attachmentPath) : `${name}.${getFileExtension(contentType)}`;
1178
- const relativePath = path.join(
1179
- "ortoni-data",
1180
- "attachments",
1181
- subFolder,
1182
- fileName
1183
- );
1184
- const fullPath = path.join(attachmentsFolder, fileName);
1185
- if (contentType === "image/png") {
1186
- handleImage(
1187
- attachmentPath,
1188
- body,
1189
- base64Image,
1190
- fullPath,
1191
- relativePath,
1192
- testResult
1193
- );
1194
- } else if (name === "video") {
1195
- handleAttachment(
1196
- attachmentPath,
1197
- fullPath,
1198
- relativePath,
1199
- "videoPath",
1200
- testResult
1201
- );
1202
- } else if (name === "trace") {
1203
- handleAttachment(
1204
- attachmentPath,
1205
- fullPath,
1206
- relativePath,
1207
- "tracePath",
1208
- testResult
1209
- );
1210
- } else if (name === "error-context") {
1211
- handleAttachment(
1212
- attachmentPath,
1213
- fullPath,
1214
- relativePath,
1215
- "markdownPath",
1216
- testResult,
1217
- steps,
1218
- errors
1219
- );
1220
- }
1221
- });
1222
- }
1223
- function handleImage(attachmentPath, body, base64Image, fullPath, relativePath, testResult) {
1224
- let screenshotPath = "";
1225
- if (attachmentPath) {
1226
- try {
1227
- const screenshotContent = fs2.readFileSync(
1228
- attachmentPath,
1229
- base64Image ? "base64" : void 0
1230
- );
1231
- screenshotPath = base64Image ? `data:image/png;base64,${screenshotContent}` : relativePath;
1232
- if (!base64Image) {
1233
- fs2.copyFileSync(attachmentPath, fullPath);
1234
- }
1235
- } catch (error) {
1236
- console.error(
1237
- `OrtoniReport: Failed to read screenshot file: ${attachmentPath}`,
1238
- error
1239
- );
1240
- }
1241
- } else if (body) {
1242
- screenshotPath = `data:image/png;base64,${body.toString("base64")}`;
1243
- }
1244
- if (screenshotPath) {
1245
- testResult.screenshots?.push(screenshotPath);
1246
- }
1247
- }
1248
- function handleAttachment(attachmentPath, fullPath, relativePath, resultKey, testResult, steps, errors) {
1249
- if (attachmentPath) {
1250
- fs2.copyFileSync(attachmentPath, fullPath);
1251
- if (resultKey === "videoPath") {
1252
- testResult[resultKey]?.push(relativePath);
1253
- } else if (resultKey === "tracePath") {
1254
- testResult[resultKey] = relativePath;
1255
- }
1256
- }
1257
- if (resultKey === "markdownPath" && errors) {
1258
- const htmlPath = fullPath.replace(/\.md$/, ".html");
1259
- const htmlRelativePath = relativePath.replace(/\.md$/, ".html");
1260
- convertMarkdownToHtml(fullPath, htmlPath);
1261
- testResult[resultKey] = htmlRelativePath;
1262
- return;
1263
- }
1264
- }
1265
- function getFileExtension(contentType) {
1266
- const extensions = {
1267
- "image/png": "png",
1268
- "video/webm": "webm",
1269
- "application/zip": "zip",
1270
- "text/markdown": "md"
1271
- };
1272
- return extensions[contentType] || "unknown";
1273
- }
1274
-
1275
- // src/helpers/resultProcessor.ts
1276
- var TestResultProcessor = class {
1277
- constructor(projectRoot) {
1278
- this.ansiToHtml = new AnsiToHtml({ fg: "var(--snippet-color)" });
1279
- this.projectRoot = projectRoot;
1280
- }
1281
- processTestResult(test, result, projectSet, ortoniConfig) {
1282
- const status = test.outcome() === "flaky" ? "flaky" : result.status;
1283
- const projectName = test.titlePath()[1];
1284
- projectSet.add(projectName);
1285
- const location = test.location;
1286
- const filePath = normalizeFilePath(test.titlePath()[2]);
1287
- const tagPattern = /@[\w]+/g;
1288
- const title = test.title.replace(tagPattern, "").trim();
1289
- const suite = test.titlePath()[3].replace(tagPattern, "").trim();
1290
- const suiteAndTitle = extractSuites(test.titlePath());
1291
- const suiteHierarchy = suiteAndTitle.hierarchy;
1292
- const testResult = {
1293
- suiteHierarchy,
1294
- key: test.id,
1295
- annotations: test.annotations,
1296
- testTags: test.tags,
1297
- location: `${filePath}:${location.line}:${location.column}`,
1298
- retryAttemptCount: result.retry,
1299
- projectName,
1300
- suite,
1301
- title,
1302
- status,
1303
- flaky: test.outcome(),
1304
- duration: result.duration,
1305
- errors: result.errors.map(
1306
- (e) => this.ansiToHtml.toHtml(escapeHtml(e.stack || e.toString()))
1307
- ),
1308
- steps: this.processSteps(result.steps),
1309
- logs: this.ansiToHtml.toHtml(
1310
- escapeHtml(
1311
- result.stdout.concat(result.stderr).map((log) => log).join("\n")
1312
- )
1313
- ),
1314
- filePath,
1315
- filters: projectSet,
1316
- base64Image: ortoniConfig.base64Image,
1317
- testId: `${filePath}:${projectName}:${title}`
1318
- };
1319
- attachFiles(
1320
- test.id,
1321
- result,
1322
- testResult,
1323
- ortoniConfig,
1324
- testResult.steps,
1325
- testResult.errors
1326
- );
1327
- return testResult;
1328
- }
1329
- processSteps(steps) {
1330
- return steps.map((step) => {
1331
- const stepLocation = step.location ? `${path2.relative(this.projectRoot, step.location.file)}:${step.location.line}:${step.location.column}` : "";
1332
- return {
1333
- snippet: this.ansiToHtml.toHtml(escapeHtml(step.error?.snippet || "")),
1334
- title: step.title,
1335
- location: step.error ? stepLocation : ""
1336
- };
1337
- });
1338
- }
1339
- };
1340
-
1341
- // src/helpers/serverManager.ts
1342
- var ServerManager = class {
1343
- constructor(ortoniConfig) {
1344
- this.ortoniConfig = ortoniConfig;
1345
- }
1346
- startServer(folderPath, outputFilename, overAllStatus) {
1347
- const openOption = this.ortoniConfig.open || "never";
1348
- const hasFailures = overAllStatus === "failed";
1349
- if (openOption === "always" || openOption === "on-failure" && hasFailures) {
1350
- startReportServer(
1351
- folderPath,
1352
- outputFilename,
1353
- this.ortoniConfig.port,
1354
- openOption
1355
- );
1356
- }
1357
- }
1358
- };
1359
-
1360
- // src/ortoni-report.ts
1361
- import path3 from "path";
1362
- var OrtoniReport = class {
1363
- constructor(ortoniConfig = {}) {
1364
- this.ortoniConfig = ortoniConfig;
1365
- this.results = [];
1366
- this.projectSet = /* @__PURE__ */ new Set();
1367
- this.shouldGenerateReport = true;
1368
- this.showConsoleLogs = true;
1369
- this.skipTraceViewer = false;
1370
- this.reportsCount = 0;
1371
- this.folderPath = ortoniConfig.folderPath || "ortoni-report";
1372
- this.outputFilename = ensureHtmlExtension(
1373
- ortoniConfig.filename || "ortoni-report.html"
1374
- );
1375
- this.dbManager = new DatabaseManager();
1376
- this.htmlGenerator = new HTMLGenerator(ortoniConfig, this.dbManager);
1377
- this.fileManager = new FileManager(this.folderPath);
1378
- this.serverManager = new ServerManager(ortoniConfig);
1379
- this.testResultProcessor = new TestResultProcessor("");
1380
- this.showConsoleLogs = ortoniConfig.stdIO !== false;
1381
- }
1382
- async onBegin(config, _suite) {
1383
- this.skipTraceViewer = config.projects.every((project) => {
1384
- const trace = project.use?.trace;
1385
- return trace === void 0 || trace === "off";
1386
- });
1387
- this.reportsCount = config.reporter.length;
1388
- this.results = [];
1389
- this.testResultProcessor = new TestResultProcessor(config.rootDir);
1390
- this.fileManager.ensureReportDirectory();
1391
- await this.dbManager.initialize(
1392
- path3.join(this.folderPath, "ortoni-data-history.sqlite")
1393
- );
1394
- this.shardConfig = config?.shard;
1395
- }
1396
- onStdOut(chunk, _test, _result) {
1397
- if (this.reportsCount == 1 && this.showConsoleLogs) {
1398
- console.log(chunk.toString().trim());
1399
- }
1400
- }
1401
- onTestEnd(test, result) {
1402
- try {
1403
- const testResult = this.testResultProcessor.processTestResult(
1404
- test,
1405
- result,
1406
- this.projectSet,
1407
- this.ortoniConfig
1408
- );
1409
- this.results.push(testResult);
1410
- } catch (error) {
1411
- console.error("Ortoni Report: Error processing test end:", error);
1412
- }
1413
- }
1414
- printsToStdio() {
1415
- return true;
1416
- }
1417
- onError(error) {
1418
- if (error.location === void 0) {
1419
- this.shouldGenerateReport = false;
1420
- }
1421
- }
1422
- async onEnd(result) {
1423
- try {
1424
- this.overAllStatus = result.status;
1425
- if (this.shouldGenerateReport) {
1426
- const filteredResults = this.results.filter(
1427
- (r) => r.status !== "skipped"
1428
- );
1429
- const totalDuration = result.duration;
1430
- if (this.shardConfig && this.shardConfig.total > 1) {
1431
- const shard = this.shardConfig;
1432
- const shardFile = `ortoni-shard-${shard.current}-of-${shard.total}.json`;
1433
- const shardData = {
1434
- status: result.status,
1435
- duration: totalDuration,
1436
- results: this.results,
1437
- projectSet: Array.from(this.projectSet),
1438
- userConfig: {
1439
- projectName: this.ortoniConfig.projectName,
1440
- authorName: this.ortoniConfig.authorName,
1441
- type: this.ortoniConfig.testType,
1442
- title: this.ortoniConfig.title
1443
- },
1444
- userMeta: {
1445
- meta: this.ortoniConfig.meta
1446
- }
1447
- };
1448
- const shardFilePath = this.fileManager.writeRawFile(
1449
- shardFile,
1450
- shardData
1451
- );
1452
- console.info(`Ortoni Report: Shard data written to ${shardFilePath}`);
1453
- this.shouldGenerateReport = false;
1454
- return;
1455
- }
1456
- const runId = await this.dbManager.saveTestRun();
1457
- if (runId !== null) {
1458
- await this.dbManager.saveTestResults(runId, this.results);
1459
- const finalReportData = await this.htmlGenerator.generateFinalReport(
1460
- filteredResults,
1461
- totalDuration,
1462
- this.results,
1463
- this.projectSet
1464
- );
1465
- this.outputPath = await this.fileManager.writeReportFile(
1466
- this.outputFilename,
1467
- finalReportData
1468
- );
1469
- } else {
1470
- console.error("Ortoni Report: Error saving test run to database");
1471
- }
1472
- } else {
1473
- console.error(
1474
- "Ortoni Report: Report generation skipped due to error in Playwright worker!"
1475
- );
1476
- }
1477
- } catch (error) {
1478
- this.shouldGenerateReport = false;
1479
- console.error("Ortoni Report: Error generating report:", error);
1480
- }
1481
- }
1482
- async onExit() {
1483
- try {
1484
- await this.dbManager.close();
1485
- if (this.shouldGenerateReport) {
1486
- this.fileManager.copyTraceViewerAssets(this.skipTraceViewer);
1487
- console.info(`Ortoni Report generated at ${this.outputPath}`);
1488
- this.serverManager.startServer(
1489
- this.folderPath,
1490
- this.outputFilename,
1491
- this.overAllStatus
1492
- );
1493
- await new Promise((_resolve) => {
1494
- });
1495
- }
1496
- } catch (error) {
1497
- console.error("Ortoni Report: Error in onExit:", error);
1498
- }
1499
- }
1500
- };
1501
- export {
1502
- OrtoniReport,
1503
- OrtoniReport as default
1504
- };