feat: update gitea vendor
runner nix smoke / nix label and flake smoke (push) Failing after 1m28s

This commit is contained in:
2026-09-26 21:18:24 +00:00
parent c439c1b948
commit d9b2a4e787
3538 changed files with 116131 additions and 44340 deletions
@@ -1,6 +1,12 @@
import {renderAnsi} from './ansi.ts';
import {renderAnsiInto} from './ansi.ts';
test('renderAnsi', () => {
const renderAnsi = (line: string) => {
const el = document.createElement('div');
renderAnsiInto(el, line);
return el.innerHTML;
};
expect(renderAnsi('abc')).toEqual('abc');
expect(renderAnsi('abc\n')).toEqual('abc');
expect(renderAnsi('abc\r\n')).toEqual('abc');
@@ -20,6 +26,9 @@ test('renderAnsi', () => {
// URLs in ANSI output become clickable links
const link = (url: string) => `<a href="${url}" target="_blank">${url}</a>`;
expect(renderAnsi('Downloading https://github.com/actions/upload-artifact/releases')).toEqual(`Downloading ${link('https://github.com/actions/upload-artifact/releases')}`);
expect(renderAnsi('\x1b[32mhttps://proxy.golang.org/cached-only\x1b[0m')).toEqual(`<span class="ansi-green-fg">${link('https://proxy.golang.org/cached-only')}</span>`);
expect(renderAnsi('foo https://example.com bar')).toEqual(`foo ${link('https://example.com')} bar`);
expect(renderAnsi('<https://example.com?a=b&c=d#h>')).toEqual(`&lt;${link('https://example.com?a=b&amp;c=d#h')}&gt;`);
expect(renderAnsi('open https://example.com.')).toEqual(`open ${link('https://example.com')}.`);
expect(renderAnsi('"https://example.com"')).toEqual(`"${link('https://example.com')}"`);
expect(renderAnsi('\x1b[32mhttps://example.com\x1b[0m')).toEqual(`<span class="ansi-green-fg">${link('https://example.com')}</span>`);
});
+40 -3
View File
@@ -1,5 +1,5 @@
import {AnsiUp} from 'ansi_up';
import {linkifyURLs} from '../utils/url.ts';
import {trimUrlPunctuation, urlRawRegex} from '../utils/url.ts';
const replacements: Array<[RegExp, string]> = [
[/\x1b\[\d+[A-H]/g, ''], // Move cursor, treat them as no-op
@@ -7,7 +7,7 @@ const replacements: Array<[RegExp, string]> = [
];
// render ANSI to HTML
export function renderAnsi(line: string): string {
export function renderAnsiInto(el: HTMLElement, line: string) {
// create a fresh ansi_up instance because otherwise previous renders can influence
// the output of future renders, because ansi_up is stateful and remembers things like
// unclosed opening tags for colors.
@@ -44,5 +44,42 @@ export function renderAnsi(line: string): string {
result = lines.join('\n');
}
return linkifyURLs(result);
el.innerHTML = result;
// at the moment, only need to do post-process when there are potential URL links
if (result.includes('://')) renderAnsiPostProcessNode(el);
}
function renderAnsiProcessText(node: ChildNode): ChildNode {
const text = node.textContent!;
const match = urlRawRegex().exec(text);
if (!match || match.index === undefined) return node;
const before = text.slice(0, match.index);
const urlMatched = match[0];
const urlTrimmed = trimUrlPunctuation(urlMatched);
const after = text.slice(match.index + urlMatched.length - (urlMatched.length - urlTrimmed.length));
const link = document.createElement('a');
link.setAttribute('href', urlTrimmed);
link.setAttribute('target', '_blank');
link.textContent = urlTrimmed;
const newNodes: Array<Node | string> = [];
if (before) newNodes.push(before);
newNodes.push(link);
if (after) newNodes.push(after);
node.replaceWith(...newNodes);
return link;
}
function renderAnsiPostProcessNode(el: ChildNode) {
for (let node = el.firstChild; node; node = node.nextSibling) {
if (node.nodeName === 'A') continue;
if (node.nodeType !== Node.TEXT_NODE) {
renderAnsiPostProcessNode(node);
continue;
}
node = renderAnsiProcessText(node);
}
}
@@ -0,0 +1,23 @@
import type {FrontendRenderFunc} from '../plugin.ts';
export const frontendRender: FrontendRenderFunc = async (opts): Promise<boolean> => {
try {
const [player] = await Promise.all([
import('asciinema-player'),
import('asciinema-player/dist/bundle/asciinema-player.css'),
]);
player.create({data: opts.contentString()}, opts.container, {
// poster (a preview frame) to display until the playback is started.
// Set it to 1 hour (also means the end if the video is shorter) to make the preview frame show more.
poster: 'npt:1:0:0',
});
// Related: https://github.com/asciinema/asciinema-player/blob/develop/src/components/Terminal.js : <div class="ap-term" ...>
// Old PR: Fix UI regression of asciinema player https://github.com/go-gitea/gitea/pull/26159
opts.container.querySelector<HTMLElement>('.ap-term')!.style.overflow = 'hidden';
opts.container.querySelector<HTMLElement>('.ap-player')!.style.borderRadius = '0';
return true;
} catch (error) {
console.error(error);
return false;
}
};
@@ -1,15 +1,11 @@
import type {FrontendRenderFunc} from '../plugin.ts';
import {initSwaggerUI} from '../swagger.ts';
// HINT: SWAGGER-CSS-IMPORT: this import is also necessary when swagger is used as a frontend external render
// But it can't share the same CSS file with the standalone page: it triggers our Vite manifest parser's bug
// Although single top-level "await import(css)" can work, it requires es2022.
// Otherwise, single function-level "await import(css)" can't work due to Vite's dependency analysis and bundling.
// HINT: SWAGGER-CSS-IMPORT: these styles are for the render only.
import '../../../css/swagger-render.css';
export const frontendRender: FrontendRenderFunc = async (opts): Promise<boolean> => {
try {
await import('../../../css/swagger-render.css');
await initSwaggerUI(opts.container, {specText: opts.contentString()});
return true;
} catch (error) {
@@ -4,9 +4,7 @@ export function newInplacePluginPdfViewer(): InplaceRenderPlugin {
return {
name: 'pdf-viewer',
canHandle(filename: string, _mimeType: string): boolean {
return filename.toLowerCase().endsWith('.pdf');
},
canHandle: (filename: string, _mimeType: string): boolean => filename.toLowerCase().endsWith('.pdf'),
async render(container: HTMLElement, fileUrl: string): Promise<void> {
const PDFObject = await import('pdfobject');