@verdaccio/middleware 9.0.0-next-9.2 → 9.0.0-next-9.4
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.
- package/build/_virtual/_rolldown/runtime.js +23 -0
- package/build/index.d.ts +3 -0
- package/build/index.js +60 -213
- package/build/index.mjs +22 -0
- package/build/middlewares/allow.js +42 -50
- package/build/middlewares/allow.js.map +1 -1
- package/build/middlewares/allow.mjs +44 -0
- package/build/middlewares/allow.mjs.map +1 -0
- package/build/middlewares/antiLoop.d.ts +2 -2
- package/build/middlewares/antiLoop.js +22 -40
- package/build/middlewares/antiLoop.js.map +1 -1
- package/build/middlewares/antiLoop.mjs +25 -0
- package/build/middlewares/antiLoop.mjs.map +1 -0
- package/build/middlewares/api_urls.js +66 -59
- package/build/middlewares/api_urls.js.map +1 -1
- package/build/middlewares/api_urls.mjs +59 -0
- package/build/middlewares/api_urls.mjs.map +1 -0
- package/build/middlewares/dotfiles.d.ts +12 -0
- package/build/middlewares/dotfiles.js +28 -0
- package/build/middlewares/dotfiles.js.map +1 -0
- package/build/middlewares/dotfiles.mjs +27 -0
- package/build/middlewares/dotfiles.mjs.map +1 -0
- package/build/middlewares/encode-pkg.d.ts +1 -1
- package/build/middlewares/encode-pkg.js +20 -36
- package/build/middlewares/encode-pkg.js.map +1 -1
- package/build/middlewares/encode-pkg.mjs +22 -0
- package/build/middlewares/encode-pkg.mjs.map +1 -0
- package/build/middlewares/error.d.ts +3 -3
- package/build/middlewares/error.js +53 -71
- package/build/middlewares/error.js.map +1 -1
- package/build/middlewares/error.mjs +53 -0
- package/build/middlewares/error.mjs.map +1 -0
- package/build/middlewares/final.d.ts +2 -2
- package/build/middlewares/final.js +46 -57
- package/build/middlewares/final.js.map +1 -1
- package/build/middlewares/final.mjs +46 -0
- package/build/middlewares/final.mjs.map +1 -0
- package/build/middlewares/json.d.ts +1 -1
- package/build/middlewares/json.js +8 -11
- package/build/middlewares/json.js.map +1 -1
- package/build/middlewares/json.mjs +10 -0
- package/build/middlewares/json.mjs.map +1 -0
- package/build/middlewares/log.d.ts +5 -2
- package/build/middlewares/log.js +99 -93
- package/build/middlewares/log.js.map +1 -1
- package/build/middlewares/log.mjs +96 -0
- package/build/middlewares/log.mjs.map +1 -0
- package/build/middlewares/make-url-relative.d.ts +1 -1
- package/build/middlewares/make-url-relative.js +26 -41
- package/build/middlewares/make-url-relative.js.map +1 -1
- package/build/middlewares/make-url-relative.mjs +28 -0
- package/build/middlewares/make-url-relative.mjs.map +1 -0
- package/build/middlewares/match.js +8 -13
- package/build/middlewares/match.js.map +1 -1
- package/build/middlewares/match.mjs +11 -0
- package/build/middlewares/match.mjs.map +1 -0
- package/build/middlewares/media.js +15 -19
- package/build/middlewares/media.js.map +1 -1
- package/build/middlewares/media.mjs +17 -0
- package/build/middlewares/media.mjs.map +1 -0
- package/build/middlewares/rate-limit.d.ts +2 -2
- package/build/middlewares/rate-limit.js +8 -10
- package/build/middlewares/rate-limit.js.map +1 -1
- package/build/middlewares/rate-limit.mjs +9 -0
- package/build/middlewares/rate-limit.mjs.map +1 -0
- package/build/middlewares/request-options.d.ts +2 -2
- package/build/middlewares/request-options.js +18 -27
- package/build/middlewares/request-options.js.map +1 -1
- package/build/middlewares/request-options.mjs +19 -0
- package/build/middlewares/request-options.mjs.map +1 -0
- package/build/middlewares/user-agent.d.ts +1 -1
- package/build/middlewares/user-agent.js +11 -12
- package/build/middlewares/user-agent.js.map +1 -1
- package/build/middlewares/user-agent.mjs +13 -0
- package/build/middlewares/user-agent.mjs.map +1 -0
- package/build/middlewares/validation.d.ts +1 -1
- package/build/middlewares/validation.js +11 -18
- package/build/middlewares/validation.js.map +1 -1
- package/build/middlewares/validation.mjs +14 -0
- package/build/middlewares/validation.mjs.map +1 -0
- package/build/middlewares/web/index.js +4 -35
- package/build/middlewares/web/index.mjs +4 -0
- package/build/middlewares/web/render-web.d.ts +1 -1
- package/build/middlewares/web/render-web.js +80 -103
- package/build/middlewares/web/render-web.js.map +1 -1
- package/build/middlewares/web/render-web.mjs +79 -0
- package/build/middlewares/web/render-web.mjs.map +1 -0
- package/build/middlewares/web/security.js +29 -41
- package/build/middlewares/web/security.js.map +1 -1
- package/build/middlewares/web/security.mjs +30 -0
- package/build/middlewares/web/security.mjs.map +1 -0
- package/build/middlewares/web/utils/manifest.js +17 -18
- package/build/middlewares/web/utils/manifest.js.map +1 -1
- package/build/middlewares/web/utils/manifest.mjs +21 -0
- package/build/middlewares/web/utils/manifest.mjs.map +1 -0
- package/build/middlewares/web/utils/renderHTML.d.ts +5 -5
- package/build/middlewares/web/utils/renderHTML.js +109 -136
- package/build/middlewares/web/utils/renderHTML.js.map +1 -1
- package/build/middlewares/web/utils/renderHTML.mjs +113 -0
- package/build/middlewares/web/utils/renderHTML.mjs.map +1 -0
- package/build/middlewares/web/utils/template.d.ts +2 -2
- package/build/middlewares/web/utils/template.js +19 -20
- package/build/middlewares/web/utils/template.js.map +1 -1
- package/build/middlewares/web/utils/template.mjs +35 -0
- package/build/middlewares/web/utils/template.mjs.map +1 -0
- package/build/middlewares/web/utils/web-utils.js +17 -18
- package/build/middlewares/web/utils/web-utils.js.map +1 -1
- package/build/middlewares/web/utils/web-utils.mjs +18 -0
- package/build/middlewares/web/utils/web-utils.mjs.map +1 -0
- package/build/middlewares/web/web-api.d.ts +1 -2
- package/build/middlewares/web/web-api.js +18 -27
- package/build/middlewares/web/web-api.js.map +1 -1
- package/build/middlewares/web/web-api.mjs +19 -0
- package/build/middlewares/web/web-api.mjs.map +1 -0
- package/build/middlewares/web/web-middleware.js +16 -23
- package/build/middlewares/web/web-middleware.js.map +1 -1
- package/build/middlewares/web/web-middleware.mjs +16 -0
- package/build/middlewares/web/web-middleware.mjs.map +1 -0
- package/build/middlewares/web/web-urls.js +28 -29
- package/build/middlewares/web/web-urls.js.map +1 -1
- package/build/middlewares/web/web-urls.mjs +32 -0
- package/build/middlewares/web/web-urls.mjs.map +1 -0
- package/build/types.d.ts +2 -2
- package/package.json +23 -12
- package/build/index.js.map +0 -1
- package/build/middlewares/web/index.js.map +0 -1
- package/build/types.js +0 -6
- package/build/types.js.map +0 -1
|
@@ -1,24 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const resolvedItem = `${stripTrailingSlash(basePath)}/${stripLeadingSlash(manifest[item])}`;
|
|
14
|
-
debug('resolved item %o', resolvedItem);
|
|
15
|
-
return resolvedItem;
|
|
16
|
-
});
|
|
1
|
+
const require_runtime = require("../../../_virtual/_rolldown/runtime.js");
|
|
2
|
+
let debug = require("debug");
|
|
3
|
+
debug = require_runtime.__toESM(debug);
|
|
4
|
+
//#region src/middlewares/web/utils/manifest.ts
|
|
5
|
+
var debug$1 = (0, debug.default)("verdaccio:middleware:web:render:manifest");
|
|
6
|
+
function getManifestValue(manifestItems, manifest, basePath = "") {
|
|
7
|
+
return manifestItems?.map((item) => {
|
|
8
|
+
debug$1("resolve item %o", item);
|
|
9
|
+
const resolvedItem = `${stripTrailingSlash(basePath)}/${stripLeadingSlash(manifest[item])}`;
|
|
10
|
+
debug$1("resolved item %o", resolvedItem);
|
|
11
|
+
return resolvedItem;
|
|
12
|
+
});
|
|
17
13
|
}
|
|
18
14
|
function stripTrailingSlash(path) {
|
|
19
|
-
|
|
15
|
+
return path.replace(/\/$/, "");
|
|
20
16
|
}
|
|
21
17
|
function stripLeadingSlash(path) {
|
|
22
|
-
|
|
18
|
+
return path.replace(/^\//, "");
|
|
23
19
|
}
|
|
20
|
+
//#endregion
|
|
21
|
+
exports.getManifestValue = getManifestValue;
|
|
22
|
+
|
|
24
23
|
//# sourceMappingURL=manifest.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manifest.js","names":[
|
|
1
|
+
{"version":3,"file":"manifest.js","names":[],"sources":["../../../../src/middlewares/web/utils/manifest.ts"],"sourcesContent":["import buildDebug from 'debug';\n\nexport type Manifest = {\n // goes on first place at the header\n ico: string;\n css: string[];\n js: string[];\n};\n\nconst debug = buildDebug('verdaccio:middleware:web:render:manifest');\n\nexport function getManifestValue(\n manifestItems: string[],\n manifest,\n basePath: string = ''\n): string[] {\n return manifestItems?.map((item) => {\n debug('resolve item %o', item);\n const resolvedItem = `${stripTrailingSlash(basePath)}/${stripLeadingSlash(manifest[item])}`;\n debug('resolved item %o', resolvedItem);\n return resolvedItem;\n });\n}\n\nfunction stripTrailingSlash(path: string): string {\n return path.replace(/\\/$/, '');\n}\n\nfunction stripLeadingSlash(path: string): string {\n return path.replace(/^\\//, '');\n}\n"],"mappings":";;;;AASA,IAAM,WAAA,GAAA,MAAA,SAAmB,2CAA2C;AAEpE,SAAgB,iBACd,eACA,UACA,WAAmB,IACT;AACV,QAAO,eAAe,KAAK,SAAS;AAClC,UAAM,mBAAmB,KAAK;EAC9B,MAAM,eAAe,GAAG,mBAAmB,SAAS,CAAC,GAAG,kBAAkB,SAAS,MAAM;AACzF,UAAM,oBAAoB,aAAa;AACvC,SAAO;GACP;;AAGJ,SAAS,mBAAmB,MAAsB;AAChD,QAAO,KAAK,QAAQ,OAAO,GAAG;;AAGhC,SAAS,kBAAkB,MAAsB;AAC/C,QAAO,KAAK,QAAQ,OAAO,GAAG"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import buildDebug from "debug";
|
|
2
|
+
//#region src/middlewares/web/utils/manifest.ts
|
|
3
|
+
var debug = buildDebug("verdaccio:middleware:web:render:manifest");
|
|
4
|
+
function getManifestValue(manifestItems, manifest, basePath = "") {
|
|
5
|
+
return manifestItems?.map((item) => {
|
|
6
|
+
debug("resolve item %o", item);
|
|
7
|
+
const resolvedItem = `${stripTrailingSlash(basePath)}/${stripLeadingSlash(manifest[item])}`;
|
|
8
|
+
debug("resolved item %o", resolvedItem);
|
|
9
|
+
return resolvedItem;
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
function stripTrailingSlash(path) {
|
|
13
|
+
return path.replace(/\/$/, "");
|
|
14
|
+
}
|
|
15
|
+
function stripLeadingSlash(path) {
|
|
16
|
+
return path.replace(/^\//, "");
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
export { getManifestValue };
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=manifest.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest.mjs","names":[],"sources":["../../../../src/middlewares/web/utils/manifest.ts"],"sourcesContent":["import buildDebug from 'debug';\n\nexport type Manifest = {\n // goes on first place at the header\n ico: string;\n css: string[];\n js: string[];\n};\n\nconst debug = buildDebug('verdaccio:middleware:web:render:manifest');\n\nexport function getManifestValue(\n manifestItems: string[],\n manifest,\n basePath: string = ''\n): string[] {\n return manifestItems?.map((item) => {\n debug('resolve item %o', item);\n const resolvedItem = `${stripTrailingSlash(basePath)}/${stripLeadingSlash(manifest[item])}`;\n debug('resolved item %o', resolvedItem);\n return resolvedItem;\n });\n}\n\nfunction stripTrailingSlash(path: string): string {\n return path.replace(/\\/$/, '');\n}\n\nfunction stripLeadingSlash(path: string): string {\n return path.replace(/^\\//, '');\n}\n"],"mappings":";;AASA,IAAM,QAAQ,WAAW,2CAA2C;AAEpE,SAAgB,iBACd,eACA,UACA,WAAmB,IACT;AACV,QAAO,eAAe,KAAK,SAAS;AAClC,QAAM,mBAAmB,KAAK;EAC9B,MAAM,eAAe,GAAG,mBAAmB,SAAS,CAAC,GAAG,kBAAkB,SAAS,MAAM;AACzF,QAAM,oBAAoB,aAAa;AACvC,SAAO;GACP;;AAGJ,SAAS,mBAAmB,MAAsB;AAChD,QAAO,KAAK,QAAQ,OAAO,GAAG;;AAGhC,SAAS,kBAAkB,MAAsB;AAC/C,QAAO,KAAK,QAAQ,OAAO,GAAG"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
1
|
+
import { Response } from 'express';
|
|
2
|
+
import { ConfigYaml } from '@verdaccio/types';
|
|
3
|
+
import { RequestOptions } from '@verdaccio/url';
|
|
4
|
+
import { Manifest } from './manifest';
|
|
5
|
+
import { AssetManifest } from './template';
|
|
6
6
|
export declare function resolveLogo(logo: string | undefined, url_prefix: string | undefined, requestOptions: RequestOptions): string;
|
|
7
7
|
export default function renderHTML(config: ConfigYaml, manifest: AssetManifest, manifestFiles: Manifest | null | undefined, requestOptions: RequestOptions, res: Response): void;
|
|
@@ -1,143 +1,116 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
var
|
|
15
|
-
var
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const DEFAULT_LANGUAGE = 'es-US';
|
|
19
|
-
// Cache for rendered HTML templates: max 500 entries, 1 hour TTL
|
|
20
|
-
const cache = new _lruCache.LRUCache({
|
|
21
|
-
max: 500,
|
|
22
|
-
ttl: 1000 * 60 * 60
|
|
1
|
+
const require_runtime = require("../../../_virtual/_rolldown/runtime.js");
|
|
2
|
+
const require_template = require("./template.js");
|
|
3
|
+
const require_web_utils = require("./web-utils.js");
|
|
4
|
+
let _verdaccio_core = require("@verdaccio/core");
|
|
5
|
+
let debug = require("debug");
|
|
6
|
+
debug = require_runtime.__toESM(debug);
|
|
7
|
+
let node_url = require("node:url");
|
|
8
|
+
let _verdaccio_config = require("@verdaccio/config");
|
|
9
|
+
let node_path = require("node:path");
|
|
10
|
+
node_path = require_runtime.__toESM(node_path);
|
|
11
|
+
let _verdaccio_url = require("@verdaccio/url");
|
|
12
|
+
let lru_cache = require("lru-cache");
|
|
13
|
+
//#region src/middlewares/web/utils/renderHTML.ts
|
|
14
|
+
var DEFAULT_LANGUAGE = "es-US";
|
|
15
|
+
var cache = new lru_cache.LRUCache({
|
|
16
|
+
max: 500,
|
|
17
|
+
ttl: 1e3 * 60 * 60
|
|
23
18
|
});
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
19
|
+
var debug$1 = (0, debug.default)("verdaccio:web:render");
|
|
20
|
+
var defaultManifestFiles = {
|
|
21
|
+
js: ["vendors.js", "main.js"],
|
|
22
|
+
ico: "favicon.ico",
|
|
23
|
+
css: []
|
|
29
24
|
};
|
|
30
25
|
function resolveLogo(logo, url_prefix, requestOptions) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
if (isLocalFile) {
|
|
36
|
-
return `${(0, _url.getPublicUrl)(url_prefix, requestOptions)}-/static/${_nodePath.default.basename(logo)}`;
|
|
37
|
-
} else if ((0, _url.isURLhasValidProtocol)(logo)) {
|
|
38
|
-
return logo;
|
|
39
|
-
} else {
|
|
40
|
-
return '';
|
|
41
|
-
}
|
|
26
|
+
if (typeof logo !== "string") return "";
|
|
27
|
+
if (logo && !(0, _verdaccio_url.isURLhasValidProtocol)(logo)) return `${(0, _verdaccio_url.getPublicUrl)(url_prefix, requestOptions)}-/static/${node_path.default.basename(logo)}`;
|
|
28
|
+
else if ((0, _verdaccio_url.isURLhasValidProtocol)(logo)) return logo;
|
|
29
|
+
else return "";
|
|
42
30
|
}
|
|
43
31
|
function renderHTML(config, manifest, manifestFiles, requestOptions, res) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
options,
|
|
125
|
-
scriptsBodyAfter,
|
|
126
|
-
metaScripts,
|
|
127
|
-
scriptsBodyBefore
|
|
128
|
-
}, manifest);
|
|
129
|
-
if (needHtmlCache) {
|
|
130
|
-
cache.set(cacheKey, webPage);
|
|
131
|
-
debug('set template cache');
|
|
132
|
-
}
|
|
133
|
-
} else {
|
|
134
|
-
debug('reuse template cache');
|
|
135
|
-
}
|
|
136
|
-
} catch (error) {
|
|
137
|
-
throw new Error(`theme could not be load, stack ${error.stack}`);
|
|
138
|
-
}
|
|
139
|
-
res.setHeader('Content-Type', _core.HEADERS.TEXT_HTML);
|
|
140
|
-
res.send(webPage);
|
|
141
|
-
debug('web rendered');
|
|
32
|
+
const { url_prefix } = config;
|
|
33
|
+
const base = (0, _verdaccio_url.getPublicUrl)(config?.url_prefix, requestOptions);
|
|
34
|
+
const basename = node_url.URL.canParse(base) ? new node_url.URL(base).pathname : base;
|
|
35
|
+
const language = config?.i18n?.web ?? DEFAULT_LANGUAGE;
|
|
36
|
+
const hideDeprecatedVersions = config?.web?.hideDeprecatedVersions ?? false;
|
|
37
|
+
const needHtmlCache = [void 0, null].includes(config?.web?.html_cache) ? true : config?.web?.html_cache;
|
|
38
|
+
const darkMode = config?.web?.darkMode ?? false;
|
|
39
|
+
const title = config?.web?.title ?? _verdaccio_config.WEB_TITLE;
|
|
40
|
+
const login = require_web_utils.hasLogin(config);
|
|
41
|
+
const scope = config?.web?.scope ?? "";
|
|
42
|
+
const favicon = resolveLogo(config?.web?.favicon, config?.url_prefix, requestOptions);
|
|
43
|
+
const logo = resolveLogo(config?.web?.logo, config?.url_prefix, requestOptions);
|
|
44
|
+
const logoDark = resolveLogo(config?.web?.logoDark, config?.url_prefix, requestOptions);
|
|
45
|
+
const pkgManagers = config?.web?.pkgManagers ?? [
|
|
46
|
+
"yarn",
|
|
47
|
+
"pnpm",
|
|
48
|
+
"npm"
|
|
49
|
+
];
|
|
50
|
+
const version = res.locals.app_version ?? "";
|
|
51
|
+
const flags = {
|
|
52
|
+
...config.flags,
|
|
53
|
+
...config.experiments
|
|
54
|
+
};
|
|
55
|
+
const primaryColor = require_web_utils.validatePrimaryColor(config?.web?.primary_color ?? config?.web?.primaryColor) ?? "#4b5e40";
|
|
56
|
+
const { scriptsBodyAfter, metaScripts, scriptsbodyBefore, showInfo, showSettings, showThemeSwitch, showFooter, showSearch, showDownloadTarball, showRaw, showUplinks } = Object.assign({}, {
|
|
57
|
+
scriptsBodyAfter: [],
|
|
58
|
+
bodyBefore: [],
|
|
59
|
+
metaScripts: []
|
|
60
|
+
}, config?.web);
|
|
61
|
+
let scriptsBodyBefore = config?.web?.scriptsBodyBefore;
|
|
62
|
+
if (scriptsbodyBefore && !scriptsBodyBefore) scriptsBodyBefore = scriptsbodyBefore;
|
|
63
|
+
const options = {
|
|
64
|
+
showInfo,
|
|
65
|
+
showSettings,
|
|
66
|
+
showThemeSwitch,
|
|
67
|
+
showFooter,
|
|
68
|
+
showSearch,
|
|
69
|
+
showDownloadTarball,
|
|
70
|
+
showRaw,
|
|
71
|
+
showUplinks,
|
|
72
|
+
darkMode,
|
|
73
|
+
url_prefix,
|
|
74
|
+
basename,
|
|
75
|
+
base,
|
|
76
|
+
primaryColor,
|
|
77
|
+
version,
|
|
78
|
+
logo,
|
|
79
|
+
logoDark,
|
|
80
|
+
favicon,
|
|
81
|
+
flags,
|
|
82
|
+
login,
|
|
83
|
+
pkgManagers,
|
|
84
|
+
title,
|
|
85
|
+
scope,
|
|
86
|
+
language,
|
|
87
|
+
hideDeprecatedVersions
|
|
88
|
+
};
|
|
89
|
+
let webPage;
|
|
90
|
+
const cacheKey = `template:${JSON.stringify(options)}`;
|
|
91
|
+
try {
|
|
92
|
+
webPage = cache.get(cacheKey);
|
|
93
|
+
if (!webPage) {
|
|
94
|
+
webPage = require_template.default({
|
|
95
|
+
manifest: manifestFiles ?? defaultManifestFiles,
|
|
96
|
+
options,
|
|
97
|
+
scriptsBodyAfter,
|
|
98
|
+
metaScripts,
|
|
99
|
+
scriptsBodyBefore
|
|
100
|
+
}, manifest);
|
|
101
|
+
if (needHtmlCache) {
|
|
102
|
+
cache.set(cacheKey, webPage);
|
|
103
|
+
debug$1("set template cache");
|
|
104
|
+
}
|
|
105
|
+
} else debug$1("reuse template cache");
|
|
106
|
+
} catch (error) {
|
|
107
|
+
throw new Error(`theme could not be load, stack ${error.stack}`);
|
|
108
|
+
}
|
|
109
|
+
res.setHeader("Content-Type", _verdaccio_core.HEADERS.TEXT_HTML);
|
|
110
|
+
res.send(webPage);
|
|
111
|
+
debug$1("web rendered");
|
|
142
112
|
}
|
|
113
|
+
//#endregion
|
|
114
|
+
exports.default = renderHTML;
|
|
115
|
+
|
|
143
116
|
//# sourceMappingURL=renderHTML.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderHTML.js","names":[
|
|
1
|
+
{"version":3,"file":"renderHTML.js","names":[],"sources":["../../../../src/middlewares/web/utils/renderHTML.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport type { Response } from 'express';\nimport { LRUCache } from 'lru-cache';\nimport path from 'node:path';\nimport { URL } from 'node:url';\n\nimport { WEB_TITLE } from '@verdaccio/config';\nimport { HEADERS } from '@verdaccio/core';\nimport type { ConfigYaml, TemplateUIOptions } from '@verdaccio/types';\nimport type { RequestOptions } from '@verdaccio/url';\nimport { getPublicUrl, isURLhasValidProtocol } from '@verdaccio/url';\n\nimport type { Manifest } from './manifest';\nimport renderTemplate from './template';\nimport type { AssetManifest } from './template';\nimport { hasLogin, validatePrimaryColor } from './web-utils';\n\nconst DEFAULT_LANGUAGE = 'es-US';\n// Cache for rendered HTML templates: max 500 entries, 1 hour TTL\nconst cache = new LRUCache({ max: 500, ttl: 1000 * 60 * 60 });\n\nconst debug = buildDebug('verdaccio:web:render');\n\nconst defaultManifestFiles: Manifest = {\n js: ['vendors.js', 'main.js'],\n ico: 'favicon.ico',\n css: [],\n};\n\nexport function resolveLogo(\n logo: string | undefined,\n url_prefix: string | undefined,\n requestOptions: RequestOptions\n) {\n if (typeof logo !== 'string') {\n return '';\n }\n const isLocalFile = logo && !isURLhasValidProtocol(logo);\n\n if (isLocalFile) {\n return `${getPublicUrl(url_prefix, requestOptions)}-/static/${path.basename(logo)}`;\n } else if (isURLhasValidProtocol(logo)) {\n return logo;\n } else {\n return '';\n }\n}\n\nexport default function renderHTML(\n config: ConfigYaml,\n manifest: AssetManifest,\n manifestFiles: Manifest | null | undefined,\n requestOptions: RequestOptions,\n res: Response\n) {\n const { url_prefix } = config;\n const base = getPublicUrl(config?.url_prefix, requestOptions);\n const basename = URL.canParse(base) ? new URL(base).pathname : base;\n const language = config?.i18n?.web ?? DEFAULT_LANGUAGE;\n const hideDeprecatedVersions = config?.web?.hideDeprecatedVersions ?? false;\n // @ts-ignore\n const needHtmlCache = [undefined, null].includes(config?.web?.html_cache)\n ? true\n : config?.web?.html_cache;\n const darkMode = config?.web?.darkMode ?? false;\n const title = config?.web?.title ?? WEB_TITLE;\n const login = hasLogin(config);\n const scope = config?.web?.scope ?? '';\n const favicon = resolveLogo(config?.web?.favicon, config?.url_prefix, requestOptions);\n const logo = resolveLogo(config?.web?.logo, config?.url_prefix, requestOptions);\n const logoDark = resolveLogo(config?.web?.logoDark, config?.url_prefix, requestOptions);\n const pkgManagers = config?.web?.pkgManagers ?? ['yarn', 'pnpm', 'npm'];\n const version = res.locals.app_version ?? '';\n const flags = {\n ...config.flags,\n // legacy from 5.x\n ...config.experiments,\n };\n const primaryColor =\n validatePrimaryColor(config?.web?.primary_color ?? config?.web?.primaryColor) ?? '#4b5e40';\n const {\n scriptsBodyAfter,\n metaScripts,\n scriptsbodyBefore, // deprecated\n showInfo,\n showSettings,\n showThemeSwitch,\n showFooter,\n showSearch,\n showDownloadTarball,\n showRaw,\n showUplinks,\n } = Object.assign(\n {},\n {\n scriptsBodyAfter: [],\n bodyBefore: [],\n metaScripts: [],\n },\n config?.web\n );\n // Fallback\n let scriptsBodyBefore = config?.web?.scriptsBodyBefore;\n if (scriptsbodyBefore && !scriptsBodyBefore) {\n scriptsBodyBefore = scriptsbodyBefore;\n }\n const options: TemplateUIOptions = {\n showInfo,\n showSettings,\n showThemeSwitch,\n showFooter,\n showSearch,\n showDownloadTarball,\n showRaw,\n showUplinks,\n darkMode,\n url_prefix,\n basename,\n base,\n primaryColor,\n version,\n logo,\n logoDark,\n favicon,\n flags,\n login,\n pkgManagers,\n title,\n scope,\n language,\n hideDeprecatedVersions,\n };\n\n let webPage;\n\n const cacheKey = `template:${JSON.stringify(options)}`;\n\n try {\n webPage = cache.get(cacheKey);\n if (!webPage) {\n webPage = renderTemplate(\n {\n manifest: manifestFiles ?? defaultManifestFiles,\n options,\n scriptsBodyAfter,\n metaScripts,\n scriptsBodyBefore,\n },\n manifest\n );\n\n if (needHtmlCache) {\n cache.set(cacheKey, webPage);\n debug('set template cache');\n }\n } else {\n debug('reuse template cache');\n }\n } catch (error: any) {\n throw new Error(`theme could not be load, stack ${error.stack}`);\n }\n res.setHeader('Content-Type', HEADERS.TEXT_HTML);\n res.send(webPage);\n debug('web rendered');\n}\n"],"mappings":";;;;;;;;;;;;;AAiBA,IAAM,mBAAmB;AAEzB,IAAM,QAAQ,IAAI,UAAA,SAAS;CAAE,KAAK;CAAK,KAAK,MAAO,KAAK;CAAI,CAAC;AAE7D,IAAM,WAAA,GAAA,MAAA,SAAmB,uBAAuB;AAEhD,IAAM,uBAAiC;CACrC,IAAI,CAAC,cAAc,UAAU;CAC7B,KAAK;CACL,KAAK,EAAE;CACR;AAED,SAAgB,YACd,MACA,YACA,gBACA;AACA,KAAI,OAAO,SAAS,SAClB,QAAO;AAIT,KAFoB,QAAQ,EAAA,GAAA,eAAA,uBAAuB,KAAK,CAGtD,QAAO,IAAA,GAAA,eAAA,cAAgB,YAAY,eAAe,CAAC,WAAW,UAAA,QAAK,SAAS,KAAK;oDAClD,KAAK,CACpC,QAAO;KAEP,QAAO;;AAIX,SAAwB,WACtB,QACA,UACA,eACA,gBACA,KACA;CACA,MAAM,EAAE,eAAe;CACvB,MAAM,QAAA,GAAA,eAAA,cAAoB,QAAQ,YAAY,eAAe;CAC7D,MAAM,WAAW,SAAA,IAAI,SAAS,KAAK,GAAG,IAAI,SAAA,IAAI,KAAK,CAAC,WAAW;CAC/D,MAAM,WAAW,QAAQ,MAAM,OAAO;CACtC,MAAM,yBAAyB,QAAQ,KAAK,0BAA0B;CAEtE,MAAM,gBAAgB,CAAC,KAAA,GAAW,KAAK,CAAC,SAAS,QAAQ,KAAK,WAAW,GACrE,OACA,QAAQ,KAAK;CACjB,MAAM,WAAW,QAAQ,KAAK,YAAY;CAC1C,MAAM,QAAQ,QAAQ,KAAK,SAAS,kBAAA;CACpC,MAAM,QAAQ,kBAAA,SAAS,OAAO;CAC9B,MAAM,QAAQ,QAAQ,KAAK,SAAS;CACpC,MAAM,UAAU,YAAY,QAAQ,KAAK,SAAS,QAAQ,YAAY,eAAe;CACrF,MAAM,OAAO,YAAY,QAAQ,KAAK,MAAM,QAAQ,YAAY,eAAe;CAC/E,MAAM,WAAW,YAAY,QAAQ,KAAK,UAAU,QAAQ,YAAY,eAAe;CACvF,MAAM,cAAc,QAAQ,KAAK,eAAe;EAAC;EAAQ;EAAQ;EAAM;CACvE,MAAM,UAAU,IAAI,OAAO,eAAe;CAC1C,MAAM,QAAQ;EACZ,GAAG,OAAO;EAEV,GAAG,OAAO;EACX;CACD,MAAM,eACJ,kBAAA,qBAAqB,QAAQ,KAAK,iBAAiB,QAAQ,KAAK,aAAa,IAAI;CACnF,MAAM,EACJ,kBACA,aACA,mBACA,UACA,cACA,iBACA,YACA,YACA,qBACA,SACA,gBACE,OAAO,OACT,EAAE,EACF;EACE,kBAAkB,EAAE;EACpB,YAAY,EAAE;EACd,aAAa,EAAE;EAChB,EACD,QAAQ,IACT;CAED,IAAI,oBAAoB,QAAQ,KAAK;AACrC,KAAI,qBAAqB,CAAC,kBACxB,qBAAoB;CAEtB,MAAM,UAA6B;EACjC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD;CAED,IAAI;CAEJ,MAAM,WAAW,YAAY,KAAK,UAAU,QAAQ;AAEpD,KAAI;AACF,YAAU,MAAM,IAAI,SAAS;AAC7B,MAAI,CAAC,SAAS;AACZ,aAAU,iBAAA,QACR;IACE,UAAU,iBAAiB;IAC3B;IACA;IACA;IACA;IACD,EACD,SACD;AAED,OAAI,eAAe;AACjB,UAAM,IAAI,UAAU,QAAQ;AAC5B,YAAM,qBAAqB;;QAG7B,SAAM,uBAAuB;UAExB,OAAY;AACnB,QAAM,IAAI,MAAM,kCAAkC,MAAM,QAAQ;;AAElE,KAAI,UAAU,gBAAgB,gBAAA,QAAQ,UAAU;AAChD,KAAI,KAAK,QAAQ;AACjB,SAAM,eAAe"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import renderTemplate from "./template.mjs";
|
|
2
|
+
import { hasLogin, validatePrimaryColor } from "./web-utils.mjs";
|
|
3
|
+
import { HEADERS } from "@verdaccio/core";
|
|
4
|
+
import buildDebug from "debug";
|
|
5
|
+
import { URL } from "node:url";
|
|
6
|
+
import { WEB_TITLE } from "@verdaccio/config";
|
|
7
|
+
import path from "node:path";
|
|
8
|
+
import { getPublicUrl, isURLhasValidProtocol } from "@verdaccio/url";
|
|
9
|
+
import { LRUCache } from "lru-cache";
|
|
10
|
+
//#region src/middlewares/web/utils/renderHTML.ts
|
|
11
|
+
var DEFAULT_LANGUAGE = "es-US";
|
|
12
|
+
var cache = new LRUCache({
|
|
13
|
+
max: 500,
|
|
14
|
+
ttl: 1e3 * 60 * 60
|
|
15
|
+
});
|
|
16
|
+
var debug = buildDebug("verdaccio:web:render");
|
|
17
|
+
var defaultManifestFiles = {
|
|
18
|
+
js: ["vendors.js", "main.js"],
|
|
19
|
+
ico: "favicon.ico",
|
|
20
|
+
css: []
|
|
21
|
+
};
|
|
22
|
+
function resolveLogo(logo, url_prefix, requestOptions) {
|
|
23
|
+
if (typeof logo !== "string") return "";
|
|
24
|
+
if (logo && !isURLhasValidProtocol(logo)) return `${getPublicUrl(url_prefix, requestOptions)}-/static/${path.basename(logo)}`;
|
|
25
|
+
else if (isURLhasValidProtocol(logo)) return logo;
|
|
26
|
+
else return "";
|
|
27
|
+
}
|
|
28
|
+
function renderHTML(config, manifest, manifestFiles, requestOptions, res) {
|
|
29
|
+
const { url_prefix } = config;
|
|
30
|
+
const base = getPublicUrl(config?.url_prefix, requestOptions);
|
|
31
|
+
const basename = URL.canParse(base) ? new URL(base).pathname : base;
|
|
32
|
+
const language = config?.i18n?.web ?? DEFAULT_LANGUAGE;
|
|
33
|
+
const hideDeprecatedVersions = config?.web?.hideDeprecatedVersions ?? false;
|
|
34
|
+
const needHtmlCache = [void 0, null].includes(config?.web?.html_cache) ? true : config?.web?.html_cache;
|
|
35
|
+
const darkMode = config?.web?.darkMode ?? false;
|
|
36
|
+
const title = config?.web?.title ?? WEB_TITLE;
|
|
37
|
+
const login = hasLogin(config);
|
|
38
|
+
const scope = config?.web?.scope ?? "";
|
|
39
|
+
const favicon = resolveLogo(config?.web?.favicon, config?.url_prefix, requestOptions);
|
|
40
|
+
const logo = resolveLogo(config?.web?.logo, config?.url_prefix, requestOptions);
|
|
41
|
+
const logoDark = resolveLogo(config?.web?.logoDark, config?.url_prefix, requestOptions);
|
|
42
|
+
const pkgManagers = config?.web?.pkgManagers ?? [
|
|
43
|
+
"yarn",
|
|
44
|
+
"pnpm",
|
|
45
|
+
"npm"
|
|
46
|
+
];
|
|
47
|
+
const version = res.locals.app_version ?? "";
|
|
48
|
+
const flags = {
|
|
49
|
+
...config.flags,
|
|
50
|
+
...config.experiments
|
|
51
|
+
};
|
|
52
|
+
const primaryColor = validatePrimaryColor(config?.web?.primary_color ?? config?.web?.primaryColor) ?? "#4b5e40";
|
|
53
|
+
const { scriptsBodyAfter, metaScripts, scriptsbodyBefore, showInfo, showSettings, showThemeSwitch, showFooter, showSearch, showDownloadTarball, showRaw, showUplinks } = Object.assign({}, {
|
|
54
|
+
scriptsBodyAfter: [],
|
|
55
|
+
bodyBefore: [],
|
|
56
|
+
metaScripts: []
|
|
57
|
+
}, config?.web);
|
|
58
|
+
let scriptsBodyBefore = config?.web?.scriptsBodyBefore;
|
|
59
|
+
if (scriptsbodyBefore && !scriptsBodyBefore) scriptsBodyBefore = scriptsbodyBefore;
|
|
60
|
+
const options = {
|
|
61
|
+
showInfo,
|
|
62
|
+
showSettings,
|
|
63
|
+
showThemeSwitch,
|
|
64
|
+
showFooter,
|
|
65
|
+
showSearch,
|
|
66
|
+
showDownloadTarball,
|
|
67
|
+
showRaw,
|
|
68
|
+
showUplinks,
|
|
69
|
+
darkMode,
|
|
70
|
+
url_prefix,
|
|
71
|
+
basename,
|
|
72
|
+
base,
|
|
73
|
+
primaryColor,
|
|
74
|
+
version,
|
|
75
|
+
logo,
|
|
76
|
+
logoDark,
|
|
77
|
+
favicon,
|
|
78
|
+
flags,
|
|
79
|
+
login,
|
|
80
|
+
pkgManagers,
|
|
81
|
+
title,
|
|
82
|
+
scope,
|
|
83
|
+
language,
|
|
84
|
+
hideDeprecatedVersions
|
|
85
|
+
};
|
|
86
|
+
let webPage;
|
|
87
|
+
const cacheKey = `template:${JSON.stringify(options)}`;
|
|
88
|
+
try {
|
|
89
|
+
webPage = cache.get(cacheKey);
|
|
90
|
+
if (!webPage) {
|
|
91
|
+
webPage = renderTemplate({
|
|
92
|
+
manifest: manifestFiles ?? defaultManifestFiles,
|
|
93
|
+
options,
|
|
94
|
+
scriptsBodyAfter,
|
|
95
|
+
metaScripts,
|
|
96
|
+
scriptsBodyBefore
|
|
97
|
+
}, manifest);
|
|
98
|
+
if (needHtmlCache) {
|
|
99
|
+
cache.set(cacheKey, webPage);
|
|
100
|
+
debug("set template cache");
|
|
101
|
+
}
|
|
102
|
+
} else debug("reuse template cache");
|
|
103
|
+
} catch (error) {
|
|
104
|
+
throw new Error(`theme could not be load, stack ${error.stack}`);
|
|
105
|
+
}
|
|
106
|
+
res.setHeader("Content-Type", HEADERS.TEXT_HTML);
|
|
107
|
+
res.send(webPage);
|
|
108
|
+
debug("web rendered");
|
|
109
|
+
}
|
|
110
|
+
//#endregion
|
|
111
|
+
export { renderHTML as default };
|
|
112
|
+
|
|
113
|
+
//# sourceMappingURL=renderHTML.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderHTML.mjs","names":[],"sources":["../../../../src/middlewares/web/utils/renderHTML.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport type { Response } from 'express';\nimport { LRUCache } from 'lru-cache';\nimport path from 'node:path';\nimport { URL } from 'node:url';\n\nimport { WEB_TITLE } from '@verdaccio/config';\nimport { HEADERS } from '@verdaccio/core';\nimport type { ConfigYaml, TemplateUIOptions } from '@verdaccio/types';\nimport type { RequestOptions } from '@verdaccio/url';\nimport { getPublicUrl, isURLhasValidProtocol } from '@verdaccio/url';\n\nimport type { Manifest } from './manifest';\nimport renderTemplate from './template';\nimport type { AssetManifest } from './template';\nimport { hasLogin, validatePrimaryColor } from './web-utils';\n\nconst DEFAULT_LANGUAGE = 'es-US';\n// Cache for rendered HTML templates: max 500 entries, 1 hour TTL\nconst cache = new LRUCache({ max: 500, ttl: 1000 * 60 * 60 });\n\nconst debug = buildDebug('verdaccio:web:render');\n\nconst defaultManifestFiles: Manifest = {\n js: ['vendors.js', 'main.js'],\n ico: 'favicon.ico',\n css: [],\n};\n\nexport function resolveLogo(\n logo: string | undefined,\n url_prefix: string | undefined,\n requestOptions: RequestOptions\n) {\n if (typeof logo !== 'string') {\n return '';\n }\n const isLocalFile = logo && !isURLhasValidProtocol(logo);\n\n if (isLocalFile) {\n return `${getPublicUrl(url_prefix, requestOptions)}-/static/${path.basename(logo)}`;\n } else if (isURLhasValidProtocol(logo)) {\n return logo;\n } else {\n return '';\n }\n}\n\nexport default function renderHTML(\n config: ConfigYaml,\n manifest: AssetManifest,\n manifestFiles: Manifest | null | undefined,\n requestOptions: RequestOptions,\n res: Response\n) {\n const { url_prefix } = config;\n const base = getPublicUrl(config?.url_prefix, requestOptions);\n const basename = URL.canParse(base) ? new URL(base).pathname : base;\n const language = config?.i18n?.web ?? DEFAULT_LANGUAGE;\n const hideDeprecatedVersions = config?.web?.hideDeprecatedVersions ?? false;\n // @ts-ignore\n const needHtmlCache = [undefined, null].includes(config?.web?.html_cache)\n ? true\n : config?.web?.html_cache;\n const darkMode = config?.web?.darkMode ?? false;\n const title = config?.web?.title ?? WEB_TITLE;\n const login = hasLogin(config);\n const scope = config?.web?.scope ?? '';\n const favicon = resolveLogo(config?.web?.favicon, config?.url_prefix, requestOptions);\n const logo = resolveLogo(config?.web?.logo, config?.url_prefix, requestOptions);\n const logoDark = resolveLogo(config?.web?.logoDark, config?.url_prefix, requestOptions);\n const pkgManagers = config?.web?.pkgManagers ?? ['yarn', 'pnpm', 'npm'];\n const version = res.locals.app_version ?? '';\n const flags = {\n ...config.flags,\n // legacy from 5.x\n ...config.experiments,\n };\n const primaryColor =\n validatePrimaryColor(config?.web?.primary_color ?? config?.web?.primaryColor) ?? '#4b5e40';\n const {\n scriptsBodyAfter,\n metaScripts,\n scriptsbodyBefore, // deprecated\n showInfo,\n showSettings,\n showThemeSwitch,\n showFooter,\n showSearch,\n showDownloadTarball,\n showRaw,\n showUplinks,\n } = Object.assign(\n {},\n {\n scriptsBodyAfter: [],\n bodyBefore: [],\n metaScripts: [],\n },\n config?.web\n );\n // Fallback\n let scriptsBodyBefore = config?.web?.scriptsBodyBefore;\n if (scriptsbodyBefore && !scriptsBodyBefore) {\n scriptsBodyBefore = scriptsbodyBefore;\n }\n const options: TemplateUIOptions = {\n showInfo,\n showSettings,\n showThemeSwitch,\n showFooter,\n showSearch,\n showDownloadTarball,\n showRaw,\n showUplinks,\n darkMode,\n url_prefix,\n basename,\n base,\n primaryColor,\n version,\n logo,\n logoDark,\n favicon,\n flags,\n login,\n pkgManagers,\n title,\n scope,\n language,\n hideDeprecatedVersions,\n };\n\n let webPage;\n\n const cacheKey = `template:${JSON.stringify(options)}`;\n\n try {\n webPage = cache.get(cacheKey);\n if (!webPage) {\n webPage = renderTemplate(\n {\n manifest: manifestFiles ?? defaultManifestFiles,\n options,\n scriptsBodyAfter,\n metaScripts,\n scriptsBodyBefore,\n },\n manifest\n );\n\n if (needHtmlCache) {\n cache.set(cacheKey, webPage);\n debug('set template cache');\n }\n } else {\n debug('reuse template cache');\n }\n } catch (error: any) {\n throw new Error(`theme could not be load, stack ${error.stack}`);\n }\n res.setHeader('Content-Type', HEADERS.TEXT_HTML);\n res.send(webPage);\n debug('web rendered');\n}\n"],"mappings":";;;;;;;;;;AAiBA,IAAM,mBAAmB;AAEzB,IAAM,QAAQ,IAAI,SAAS;CAAE,KAAK;CAAK,KAAK,MAAO,KAAK;CAAI,CAAC;AAE7D,IAAM,QAAQ,WAAW,uBAAuB;AAEhD,IAAM,uBAAiC;CACrC,IAAI,CAAC,cAAc,UAAU;CAC7B,KAAK;CACL,KAAK,EAAE;CACR;AAED,SAAgB,YACd,MACA,YACA,gBACA;AACA,KAAI,OAAO,SAAS,SAClB,QAAO;AAIT,KAFoB,QAAQ,CAAC,sBAAsB,KAAK,CAGtD,QAAO,GAAG,aAAa,YAAY,eAAe,CAAC,WAAW,KAAK,SAAS,KAAK;UACxE,sBAAsB,KAAK,CACpC,QAAO;KAEP,QAAO;;AAIX,SAAwB,WACtB,QACA,UACA,eACA,gBACA,KACA;CACA,MAAM,EAAE,eAAe;CACvB,MAAM,OAAO,aAAa,QAAQ,YAAY,eAAe;CAC7D,MAAM,WAAW,IAAI,SAAS,KAAK,GAAG,IAAI,IAAI,KAAK,CAAC,WAAW;CAC/D,MAAM,WAAW,QAAQ,MAAM,OAAO;CACtC,MAAM,yBAAyB,QAAQ,KAAK,0BAA0B;CAEtE,MAAM,gBAAgB,CAAC,KAAA,GAAW,KAAK,CAAC,SAAS,QAAQ,KAAK,WAAW,GACrE,OACA,QAAQ,KAAK;CACjB,MAAM,WAAW,QAAQ,KAAK,YAAY;CAC1C,MAAM,QAAQ,QAAQ,KAAK,SAAS;CACpC,MAAM,QAAQ,SAAS,OAAO;CAC9B,MAAM,QAAQ,QAAQ,KAAK,SAAS;CACpC,MAAM,UAAU,YAAY,QAAQ,KAAK,SAAS,QAAQ,YAAY,eAAe;CACrF,MAAM,OAAO,YAAY,QAAQ,KAAK,MAAM,QAAQ,YAAY,eAAe;CAC/E,MAAM,WAAW,YAAY,QAAQ,KAAK,UAAU,QAAQ,YAAY,eAAe;CACvF,MAAM,cAAc,QAAQ,KAAK,eAAe;EAAC;EAAQ;EAAQ;EAAM;CACvE,MAAM,UAAU,IAAI,OAAO,eAAe;CAC1C,MAAM,QAAQ;EACZ,GAAG,OAAO;EAEV,GAAG,OAAO;EACX;CACD,MAAM,eACJ,qBAAqB,QAAQ,KAAK,iBAAiB,QAAQ,KAAK,aAAa,IAAI;CACnF,MAAM,EACJ,kBACA,aACA,mBACA,UACA,cACA,iBACA,YACA,YACA,qBACA,SACA,gBACE,OAAO,OACT,EAAE,EACF;EACE,kBAAkB,EAAE;EACpB,YAAY,EAAE;EACd,aAAa,EAAE;EAChB,EACD,QAAQ,IACT;CAED,IAAI,oBAAoB,QAAQ,KAAK;AACrC,KAAI,qBAAqB,CAAC,kBACxB,qBAAoB;CAEtB,MAAM,UAA6B;EACjC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD;CAED,IAAI;CAEJ,MAAM,WAAW,YAAY,KAAK,UAAU,QAAQ;AAEpD,KAAI;AACF,YAAU,MAAM,IAAI,SAAS;AAC7B,MAAI,CAAC,SAAS;AACZ,aAAU,eACR;IACE,UAAU,iBAAiB;IAC3B;IACA;IACA;IACA;IACD,EACD,SACD;AAED,OAAI,eAAe;AACjB,UAAM,IAAI,UAAU,QAAQ;AAC5B,UAAM,qBAAqB;;QAG7B,OAAM,uBAAuB;UAExB,OAAY;AACnB,QAAM,IAAI,MAAM,kCAAkC,MAAM,QAAQ;;AAElE,KAAI,UAAU,gBAAgB,QAAQ,UAAU;AAChD,KAAI,KAAK,QAAQ;AACjB,OAAM,eAAe"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { TemplateUIOptions } from '@verdaccio/types';
|
|
2
|
+
import { Manifest } from './manifest';
|
|
3
3
|
export type Template = {
|
|
4
4
|
manifest: Manifest;
|
|
5
5
|
options: TemplateUIOptions;
|
|
@@ -1,38 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var _debug = _interopRequireDefault(require("debug"));
|
|
8
|
-
var _manifest = require("./manifest");
|
|
9
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
-
const debug = (0, _debug.default)('verdaccio:web:render:template');
|
|
1
|
+
const require_runtime = require("../../../_virtual/_rolldown/runtime.js");
|
|
2
|
+
const require_manifest = require("./manifest.js");
|
|
3
|
+
let debug = require("debug");
|
|
4
|
+
debug = require_runtime.__toESM(debug);
|
|
5
|
+
//#region src/middlewares/web/utils/template.ts
|
|
6
|
+
var debug$1 = (0, debug.default)("verdaccio:web:render:template");
|
|
11
7
|
function renderTemplate(template, manifest) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
debug$1("template %o", template);
|
|
9
|
+
debug$1("manifest %o", manifest);
|
|
10
|
+
return `
|
|
15
11
|
<!DOCTYPE html>
|
|
16
12
|
<html lang="en-us">
|
|
17
13
|
<head>
|
|
18
14
|
<meta charset="utf-8">
|
|
19
15
|
<base href="${template?.options.base}">
|
|
20
|
-
<title>${template?.options?.title ??
|
|
16
|
+
<title>${template?.options?.title ?? ""}</title>
|
|
21
17
|
<link rel="icon" href="${template?.options.base}-/static/favicon.ico">
|
|
22
18
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
23
19
|
<script>
|
|
24
20
|
window.__VERDACCIO_BASENAME_UI_OPTIONS=${JSON.stringify(template.options)}
|
|
25
|
-
|
|
26
|
-
${template.manifest.css?.length ?
|
|
27
|
-
${template?.metaScripts ? template.metaScripts.join(
|
|
21
|
+
<\/script>
|
|
22
|
+
${template.manifest.css?.length ? require_manifest.getManifestValue(template.manifest.css, manifest, template?.options.base).map((item) => `<link rel="stylesheet" href="${item}">`).join("\n ") : ""}
|
|
23
|
+
${template?.metaScripts ? template.metaScripts.join("") : ""}
|
|
28
24
|
</head>
|
|
29
25
|
<body class="body">
|
|
30
|
-
${template?.scriptsBodyBefore ? template.scriptsBodyBefore.join(
|
|
26
|
+
${template?.scriptsBodyBefore ? template.scriptsBodyBefore.join("") : ""}
|
|
31
27
|
<div id="root"></div>
|
|
32
|
-
${
|
|
33
|
-
${template?.scriptsBodyAfter ? template.scriptsBodyAfter.join(
|
|
28
|
+
${require_manifest.getManifestValue(template.manifest.js, manifest, template?.options.base).map((item) => `<script type="module" src="${item}"><\/script>`).join(`\n `)}
|
|
29
|
+
${template?.scriptsBodyAfter ? template.scriptsBodyAfter.join("") : ""}
|
|
34
30
|
</body>
|
|
35
31
|
</html>
|
|
36
32
|
`;
|
|
37
33
|
}
|
|
34
|
+
//#endregion
|
|
35
|
+
exports.default = renderTemplate;
|
|
36
|
+
|
|
38
37
|
//# sourceMappingURL=template.js.map
|