198 lines
16 KiB
JavaScript
198 lines
16 KiB
JavaScript
|
import '@astrojs/internal-helpers/path';
|
||
|
import 'cookie';
|
||
|
import { bold, red, yellow, dim, blue } from 'kleur/colors';
|
||
|
import 'string-width';
|
||
|
import 'html-escaper';
|
||
|
import 'clsx';
|
||
|
import './chunks/astro_5WdVqH1c.mjs';
|
||
|
import { compile } from 'path-to-regexp';
|
||
|
|
||
|
const dateTimeFormat = new Intl.DateTimeFormat([], {
|
||
|
hour: "2-digit",
|
||
|
minute: "2-digit",
|
||
|
second: "2-digit",
|
||
|
hour12: false
|
||
|
});
|
||
|
const levels = {
|
||
|
debug: 20,
|
||
|
info: 30,
|
||
|
warn: 40,
|
||
|
error: 50,
|
||
|
silent: 90
|
||
|
};
|
||
|
function log(opts, level, label, message, newLine = true) {
|
||
|
const logLevel = opts.level;
|
||
|
const dest = opts.dest;
|
||
|
const event = {
|
||
|
label,
|
||
|
level,
|
||
|
message,
|
||
|
newLine
|
||
|
};
|
||
|
if (!isLogLevelEnabled(logLevel, level)) {
|
||
|
return;
|
||
|
}
|
||
|
dest.write(event);
|
||
|
}
|
||
|
function isLogLevelEnabled(configuredLogLevel, level) {
|
||
|
return levels[configuredLogLevel] <= levels[level];
|
||
|
}
|
||
|
function info(opts, label, message, newLine = true) {
|
||
|
return log(opts, "info", label, message, newLine);
|
||
|
}
|
||
|
function warn(opts, label, message, newLine = true) {
|
||
|
return log(opts, "warn", label, message, newLine);
|
||
|
}
|
||
|
function error(opts, label, message, newLine = true) {
|
||
|
return log(opts, "error", label, message, newLine);
|
||
|
}
|
||
|
function debug(...args) {
|
||
|
if ("_astroGlobalDebug" in globalThis) {
|
||
|
globalThis._astroGlobalDebug(...args);
|
||
|
}
|
||
|
}
|
||
|
function getEventPrefix({ level, label }) {
|
||
|
const timestamp = `${dateTimeFormat.format(/* @__PURE__ */ new Date())}`;
|
||
|
const prefix = [];
|
||
|
if (level === "error" || level === "warn") {
|
||
|
prefix.push(bold(timestamp));
|
||
|
prefix.push(`[${level.toUpperCase()}]`);
|
||
|
} else {
|
||
|
prefix.push(timestamp);
|
||
|
}
|
||
|
if (label) {
|
||
|
prefix.push(`[${label}]`);
|
||
|
}
|
||
|
if (level === "error") {
|
||
|
return red(prefix.join(" "));
|
||
|
}
|
||
|
if (level === "warn") {
|
||
|
return yellow(prefix.join(" "));
|
||
|
}
|
||
|
if (prefix.length === 1) {
|
||
|
return dim(prefix[0]);
|
||
|
}
|
||
|
return dim(prefix[0]) + " " + blue(prefix.splice(1).join(" "));
|
||
|
}
|
||
|
if (typeof process !== "undefined") {
|
||
|
let proc = process;
|
||
|
if ("argv" in proc && Array.isArray(proc.argv)) {
|
||
|
if (proc.argv.includes("--verbose")) ; else if (proc.argv.includes("--silent")) ; else ;
|
||
|
}
|
||
|
}
|
||
|
class Logger {
|
||
|
options;
|
||
|
constructor(options) {
|
||
|
this.options = options;
|
||
|
}
|
||
|
info(label, message, newLine = true) {
|
||
|
info(this.options, label, message, newLine);
|
||
|
}
|
||
|
warn(label, message, newLine = true) {
|
||
|
warn(this.options, label, message, newLine);
|
||
|
}
|
||
|
error(label, message, newLine = true) {
|
||
|
error(this.options, label, message, newLine);
|
||
|
}
|
||
|
debug(label, ...messages) {
|
||
|
debug(label, ...messages);
|
||
|
}
|
||
|
level() {
|
||
|
return this.options.level;
|
||
|
}
|
||
|
forkIntegrationLogger(label) {
|
||
|
return new AstroIntegrationLogger(this.options, label);
|
||
|
}
|
||
|
}
|
||
|
class AstroIntegrationLogger {
|
||
|
options;
|
||
|
label;
|
||
|
constructor(logging, label) {
|
||
|
this.options = logging;
|
||
|
this.label = label;
|
||
|
}
|
||
|
/**
|
||
|
* Creates a new logger instance with a new label, but the same log options.
|
||
|
*/
|
||
|
fork(label) {
|
||
|
return new AstroIntegrationLogger(this.options, label);
|
||
|
}
|
||
|
info(message) {
|
||
|
info(this.options, this.label, message);
|
||
|
}
|
||
|
warn(message) {
|
||
|
warn(this.options, this.label, message);
|
||
|
}
|
||
|
error(message) {
|
||
|
error(this.options, this.label, message);
|
||
|
}
|
||
|
debug(message) {
|
||
|
debug(this.label, message);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function getRouteGenerator(segments, addTrailingSlash) {
|
||
|
const template = segments.map((segment) => {
|
||
|
return "/" + segment.map((part) => {
|
||
|
if (part.spread) {
|
||
|
return `:${part.content.slice(3)}(.*)?`;
|
||
|
} else if (part.dynamic) {
|
||
|
return `:${part.content}`;
|
||
|
} else {
|
||
|
return part.content.normalize().replace(/\?/g, "%3F").replace(/#/g, "%23").replace(/%5B/g, "[").replace(/%5D/g, "]").replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
||
|
}
|
||
|
}).join("");
|
||
|
}).join("");
|
||
|
let trailing = "";
|
||
|
if (addTrailingSlash === "always" && segments.length) {
|
||
|
trailing = "/";
|
||
|
}
|
||
|
const toPath = compile(template + trailing);
|
||
|
return toPath;
|
||
|
}
|
||
|
|
||
|
function deserializeRouteData(rawRouteData) {
|
||
|
return {
|
||
|
route: rawRouteData.route,
|
||
|
type: rawRouteData.type,
|
||
|
pattern: new RegExp(rawRouteData.pattern),
|
||
|
params: rawRouteData.params,
|
||
|
component: rawRouteData.component,
|
||
|
generate: getRouteGenerator(rawRouteData.segments, rawRouteData._meta.trailingSlash),
|
||
|
pathname: rawRouteData.pathname || void 0,
|
||
|
segments: rawRouteData.segments,
|
||
|
prerender: rawRouteData.prerender,
|
||
|
redirect: rawRouteData.redirect,
|
||
|
redirectRoute: rawRouteData.redirectRoute ? deserializeRouteData(rawRouteData.redirectRoute) : void 0,
|
||
|
fallbackRoutes: rawRouteData.fallbackRoutes.map((fallback) => {
|
||
|
return deserializeRouteData(fallback);
|
||
|
})
|
||
|
};
|
||
|
}
|
||
|
|
||
|
function deserializeManifest(serializedManifest) {
|
||
|
const routes = [];
|
||
|
for (const serializedRoute of serializedManifest.routes) {
|
||
|
routes.push({
|
||
|
...serializedRoute,
|
||
|
routeData: deserializeRouteData(serializedRoute.routeData)
|
||
|
});
|
||
|
const route = serializedRoute;
|
||
|
route.routeData = deserializeRouteData(serializedRoute.routeData);
|
||
|
}
|
||
|
const assets = new Set(serializedManifest.assets);
|
||
|
const componentMetadata = new Map(serializedManifest.componentMetadata);
|
||
|
const clientDirectives = new Map(serializedManifest.clientDirectives);
|
||
|
return {
|
||
|
...serializedManifest,
|
||
|
assets,
|
||
|
componentMetadata,
|
||
|
clientDirectives,
|
||
|
routes
|
||
|
};
|
||
|
}
|
||
|
|
||
|
const manifest = deserializeManifest({"adapterName":"@astrojs/node","routes":[{"file":"","links":[],"scripts":[],"styles":[],"routeData":{"type":"endpoint","isIndex":false,"route":"/_image","pattern":"^\\/_image$","segments":[[{"content":"_image","dynamic":false,"spread":false}]],"params":[],"component":"node_modules/astro/dist/assets/endpoint/node.js","pathname":"/_image","prerender":false,"fallbackRoutes":[],"_meta":{"trailingSlash":"ignore"}}},{"file":"","links":[],"scripts":[{"type":"external","value":"/_astro/hoisted.l-JsOPk0.js"}],"styles":[{"type":"external","src":"/_astro/_slug_.yOjdTrIk.css"},{"type":"external","src":"/_astro/_slug_.bcjV8AoT.css"}],"routeData":{"route":"/events","isIndex":true,"type":"page","pattern":"^\\/events\\/?$","segments":[[{"content":"events","dynamic":false,"spread":false}]],"params":[],"component":"src/pages/events/index.astro","pathname":"/events","prerender":false,"fallbackRoutes":[],"_meta":{"trailingSlash":"ignore"}}},{"file":"","links":[],"scripts":[{"type":"external","value":"/_astro/hoisted.l-JsOPk0.js"}],"styles":[{"type":"external","src":"/_astro/_slug_.yOjdTrIk.css"},{"type":"external","src":"/_astro/_slug_.bcjV8AoT.css"}],"routeData":{"route":"/posts","isIndex":true,"type":"page","pattern":"^\\/posts\\/?$","segments":[[{"content":"posts","dynamic":false,"spread":false}]],"params":[],"component":"src/pages/posts/index.astro","pathname":"/posts","prerender":false,"fallbackRoutes":[],"_meta":{"trailingSlash":"ignore"}}},{"file":"","links":[],"scripts":[{"type":"external","value":"/_astro/hoisted.l-JsOPk0.js"}],"styles":[{"type":"external","src":"/_astro/_slug_.yOjdTrIk.css"},{"type":"external","src":"/_astro/_slug_.bcjV8AoT.css"}],"routeData":{"route":"/categories/[slug]","isIndex":false,"type":"page","pattern":"^\\/categories\\/([^/]+?)\\/?$","segments":[[{"content":"categories","dynamic":false,"spread":false}],[{"content":"slug","dynamic":true,"spread":false}]],"params":["slug"],"component":"src/pages/categories/[slug].astro","prerender":false,"fallbackRoutes":[],"_meta":{"trailingSlash":"ignore"}}},{"file":"","links":[],"scripts":[{"type":"external","value":"/_astro/hoisted.l-JsOPk0.js"}],"styles":[{"type":"external","src":"/_astro/_slug_.yOjdTrIk.css"},{"type":"external","src":"/_astro/_slug_.bcjV8AoT.css"},{"type":"inline","content":".wrapper[data-astro-cid-gysqo7gh]{display:grid;grid-template-columns:1fr;gap:20px}.description[data-astro-cid-gysqo7gh]{color:oklch(var(--bc) / .8)}.metadata[data-astro-cid-gysqo7gh]{display:flex;flex-direction:column;transition:color .3s}@media (min-width: 768px){.wrapper[data-astro-cid-gysqo7gh]{grid-template-columns:2fr 1fr}}\n"},{"type":"external","src":"/_astro/Media.Co8_pG1j.css"}],"routeData":{"route":"/posts/[slug]","isIndex":false,"type":"page","pattern":"^\\/posts\\/([^/]+?)\\/?$","segments":[[{"content":"posts","dynamic":false,"spread":false}],[{"content":"slug","dynamic":true,"spread":false}]],"params":["slug"],"component":"src/pages/posts/[slug].astro","prerender":false,"fallbackRoutes":[],"_meta":{"trailingSlash":"ignore"}}},{"file":"","links":[],"scripts":[{"type":"external","value":"/_astro/hoisted.l-JsOPk0.js"}],"styles":[{"type":"external","src":"/_astro/_slug_.yOjdTrIk.css"},{"type":"external","src":"/_astro/_slug_.bcjV8AoT.css"}],"routeData":{"route":"/tags/[slug]","isIndex":false,"type":"page","pattern":"^\\/tags\\/([^/]+?)\\/?$","segments":[[{"content":"tags","dynamic":false,"spread":false}],[{"content":"slug","dynamic":true,"spread":false}]],"params":["slug"],"component":"src/pages/tags/[slug].astro","prerender":false,"fallbackRoutes":[],"_meta":{"trailingSlash":"ignore"}}},{"file":"","links":[],"scripts":[{"type":"external","value":"/_astro/hoisted.l-JsOPk0.js"}],"styles":[{"type":"external","src":"/_astro/_slug_.yOjdTrIk.css"},{"type":"external","src":"/_astro/_slug_.bcjV8AoT.css"},{"type":"inline","content":".wrapper[data-astro-cid-j7pv25f6]{overflow-y:auto;scrollbar-width:none;scroll-behavior:smooth}.wrapper[data-astro-cid-j7pv25f6]::-webkit-scrollbar{width:0}.history[data-astro-cid-j7pv25f6]{overflow-x:auto;scrollb
|
||
|
|
||
|
export { AstroIntegrationLogger as A, Logger as L, getEventPrefix as g, levels as l, manifest };
|