mirror of
https://github.com/hanzoai/forge.git
synced 2026-10-30 15:00:39 +00:00
In dev mode `/api/swagger` returned HTTP 500 (`Failed to locate local path for managed asset URI: css/swagger.css`): the backend synthesised asset keys from the Vite entry name instead of reading the manifest, which only worked by coincidence and broke once a source file name diverged from its entry name. This keys the manifest by its source path (e.g. `web_src/js/index.ts`) and resolves entries directly — hashed `file` in prod, dev-server source in dev. A new `AssetCSSLinks` helper renders a JS entry's stylesheet `<link>` tags from the manifest (the entry's CSS plus the CSS of its statically-imported chunks). Fixes: https://github.com/go-gitea/gitea/issues/37830 Fixes: https://github.com/go-gitea/gitea/pull/37832 Fixes: https://github.com/go-gitea/gitea/pull/37876 Signed-off-by: silverwind <[email protected]> Co-authored-by: prakhar0x01 <[email protected]> Co-authored-by: Nicolas <[email protected]> Co-authored-by: Claude (Opus 4.7) <[email protected]> Co-authored-by: Giteabot <[email protected]>
13 lines
551 B
TypeScript
13 lines
551 B
TypeScript
import '../css/swagger-standalone.css';
|
|
import {initSwaggerUI} from './render/swagger.ts';
|
|
|
|
async function initGiteaAPIViewer() {
|
|
const elSwaggerUi = document.querySelector<HTMLElement>('#swagger-ui')!;
|
|
const url = elSwaggerUi.getAttribute('data-source')!;
|
|
const res = await fetch(url); // eslint-disable-line no-restricted-globals
|
|
// HINT: SWAGGER-CSS-IMPORT: this is used in the standalone page which already has the related CSS imported by `<link>`
|
|
await initSwaggerUI(elSwaggerUi, {specText: await res.text()});
|
|
}
|
|
|
|
initGiteaAPIViewer();
|