{"version":3,"file":"template.mjs","names":[],"sources":["../../../../src/middlewares/web/utils/template.ts"],"sourcesContent":["import buildDebug from 'debug';\n\nimport type { TemplateUIOptions } from '@verdaccio/types';\n\nimport type { Manifest } from './manifest';\nimport { getManifestValue } from './manifest';\n\nconst debug = buildDebug('verdaccio:web:render:template');\n\nexport type Template = {\n  manifest: Manifest;\n  options: TemplateUIOptions;\n  metaScripts?: string[];\n  scriptsBodyAfter?: string[];\n  scriptsBodyBefore?: string[];\n};\n\nexport interface AssetManifest {\n  [key: string]: string;\n}\n\nexport default function renderTemplate(template: Template, manifest: AssetManifest) {\n  debug('template %o', template);\n  debug('manifest %o', manifest);\n\n  return `\n    <!DOCTYPE html>\n      <html lang=\"en-us\">\n      <head>\n        <meta charset=\"utf-8\">\n        <base href=\"${template?.options.base}\">\n        <title>${template?.options?.title ?? ''}</title>\n        <link rel=\"icon\" href=\"${template?.options.base}-/static/favicon.ico\">\n        <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n        <script src=\"${template?.options.base}-/static/ui-options.js\"></script>\n        ${\n          template.manifest.css?.length\n            ? getManifestValue(template.manifest.css, manifest, template?.options.base)\n                .map((item) => `<link rel=\"stylesheet\" href=\"${item}\">`)\n                .join('\\n        ')\n            : ''\n        }\n        ${template?.metaScripts ? template.metaScripts.join('') : ''}\n      </head>\n      <body class=\"body\">\n        ${template?.scriptsBodyBefore ? template.scriptsBodyBefore.join('') : ''}\n        <div id=\"root\"></div>\n        ${getManifestValue(template.manifest.js, manifest, template?.options.base)\n          .map((item) => `<script type=\"module\" src=\"${item}\"></script>`)\n          .join(`\\n        `)}\n        ${template?.scriptsBodyAfter ? template.scriptsBodyAfter.join('') : ''}\n      </body>\n    </html>\n  `;\n}\n"],"mappings":";;;AAOA,IAAM,QAAQ,WAAW,+BAA+B;AAcxD,SAAwB,eAAe,UAAoB,UAAyB;CAClF,MAAM,eAAe,QAAQ;CAC7B,MAAM,eAAe,QAAQ;CAE7B,OAAO;;;;;sBAKa,UAAU,QAAQ,KAAK;iBAC5B,UAAU,SAAS,SAAS,GAAG;iCACf,UAAU,QAAQ,KAAK;;uBAEjC,UAAU,QAAQ,KAAK;UAEpC,SAAS,SAAS,KAAK,SACnB,iBAAiB,SAAS,SAAS,KAAK,UAAU,UAAU,QAAQ,IAAI,CAAC,CACtE,KAAK,SAAS,gCAAgC,KAAK,GAAG,CAAC,CACvD,KAAK,YAAY,IACpB,GACL;UACC,UAAU,cAAc,SAAS,YAAY,KAAK,EAAE,IAAI,GAAG;;;UAG3D,UAAU,oBAAoB,SAAS,kBAAkB,KAAK,EAAE,IAAI,GAAG;;UAEvE,iBAAiB,SAAS,SAAS,IAAI,UAAU,UAAU,QAAQ,IAAI,CAAC,CACvE,KAAK,SAAS,8BAA8B,KAAK,aAAY,CAAC,CAC9D,KAAK,YAAY,EAAE;UACpB,UAAU,mBAAmB,SAAS,iBAAiB,KAAK,EAAE,IAAI,GAAG;;;;AAI/E"}