Urara-Blog/node_modules/.pnpm-store/v3/files/3d/7bf15c1c953de69c7f5ad2794e784fbae4ae6444a7d331670c88f5cf230df3c04777bd53e6bc9678285206c3a21a96c44cf7714a6df2c752e18b85093d4b92
2022-08-14 01:14:53 +08:00

66 lines
1.7 KiB
Text

import path__default from 'path';
import { $ } from './index.js';
import 'url';
/**
* Get the prefix for the `runtime` directory, for use with import declarations
* @param {import('types').ValidatedKitConfig} config
*/
function get_runtime_prefix(config) {
{
return posixify_path(path__default.join(config.outDir, 'runtime'));
}
}
/**
* Get the resolved path of the `runtime` directory
* @param {import('types').ValidatedKitConfig} config
*/
function get_runtime_directory(config) {
{
return path__default.join(config.outDir, 'runtime');
}
}
/** @param {string} str */
function posixify_path(str) {
const parsed = path__default.parse(str);
return `/${parsed.dir.slice(parsed.root.length).split(path__default.sep).join('/')}/${parsed.base}`;
}
function noop() {}
/** @param {{ verbose: boolean }} opts */
function logger({ verbose }) {
/** @type {import('types').Logger} */
const log = (msg) => console.log(msg.replace(/^/gm, ' '));
/** @param {string} msg */
const err = (msg) => console.error(msg.replace(/^/gm, ' '));
log.success = (msg) => log($.green(`✔ ${msg}`));
log.error = (msg) => err($.bold().red(msg));
log.warn = (msg) => log($.bold().yellow(msg));
log.minor = verbose ? (msg) => log($.grey(msg)) : noop;
log.info = verbose ? log : noop;
return log;
}
/** @param {import('types').ManifestData} manifest_data */
function get_mime_lookup(manifest_data) {
/** @type {Record<string, string>} */
const mime = {};
manifest_data.assets.forEach((asset) => {
if (asset.type) {
const ext = path__default.extname(asset.file);
mime[ext] = asset.type;
}
});
return mime;
}
export { get_runtime_prefix as a, get_mime_lookup as b, get_runtime_directory as g, logger as l };