@purestack/ts-util 1.1.15 → 1.1.16
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/dist/ts-util.d.mts +9 -1
- package/dist/ts-util.d.mts.map +1 -1
- package/dist/ts-util.mjs +93 -63
- package/dist/ts-util.mjs.map +1 -1
- package/package.json +1 -1
package/dist/ts-util.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @purestack/ts-util v1.1.
|
|
1
|
+
/*! @purestack/ts-util v1.1.16 | (c) 2026 Ahmed Yasin Koculu | MIT License */
|
|
2
2
|
|
|
3
3
|
//#region packages/ts-util/src/assetPath.d.ts
|
|
4
4
|
interface OutputAssetPathOptions {
|
|
@@ -88,6 +88,14 @@ export declare function clamp(value: number, min: number, max: number): number;
|
|
|
88
88
|
/** Copies arrays and plain objects recursively, retaining callbacks and other values. */
|
|
89
89
|
export declare function clonePlainData<T>(value: T): T;
|
|
90
90
|
//#endregion
|
|
91
|
+
//#region packages/ts-util/src/configValues.d.ts
|
|
92
|
+
export declare function resolveString(...values: Array<string | undefined>): string;
|
|
93
|
+
export declare function pickBoolean(input: unknown, file: unknown, fallback?: boolean): boolean;
|
|
94
|
+
export declare function resolveOptionalString(value: unknown): string | undefined;
|
|
95
|
+
/** Content-root-relative URL, independent of the current page. */
|
|
96
|
+
export declare function resolveConfigUrl(value: string): string;
|
|
97
|
+
export declare function resolveConfigUrl(value: string | undefined): string | undefined;
|
|
98
|
+
//#endregion
|
|
91
99
|
//#region packages/ts-util/src/escapeHtml.d.ts
|
|
92
100
|
/**
|
|
93
101
|
* Escapes &, `<`, `>`, and " (optionally) in a string for safe insertion into HTML.
|
package/dist/ts-util.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ts-util.d.mts","names":[],"sources":["../src/assetPath.ts","../src/base.ts","../src/cache.ts","../src/clamp.ts","../src/clonePlainData.ts","../src/escapeHtml.ts","../src/logging.ts","../src/merge.ts","../src/publicPath.ts","../src/typeCheck.ts","../src/types.ts","../src/urlNormalizer.ts"],"mappings":";UAKiB;EACf;;wBAGc,sBAAsB;wBAItB,YAAY;wBAIZ,aAAa;wBAQb,aAAa;wBAKb,mBAAmB;wBA0BnB,qBACd,iBACA,UAAS;;;;;;;wBCrDK,KAAK,WAMjB,MAAM,MACH;EAAM;;;;KCZR;EACH;EACA;EACA;EACA;EACA;;KAUU,aAAa,GAAG;EAC1B;EACA;EACA;EACA;EACA;EACA,kBAAkB,OAAO,GAAG,KAAK;EACjC,WAAW;IAAS,KAAK;IAAG,OAAO;IAAG;;EACtC;;qBAGW,MAAM,GAAG;mBACH;mBACA;mBACA;mBACA;mBACA;mBACA;mBACA;UACT;UAOA;UACA;UACA;UACA;EAER,YAAY,UAAS,aAAa,GAAG;MAWjC;MAIA;EAIJ,YAAY;EAIZ,UAAU;IAAW;IAAqB;;EAU1C,cAAc;EAId,IAAI,KAAK;EAUT,KAAK,KAAK,IAAI;EAUd,IAAI,KAAK,IAAI;EAqBb,IAAI,KAAK,GAAG,OAAO,GAAG,iBAAiB;EAgBvC,OAAO,KAAK;EAQZ;EAMM,cACJ,KAAK,GACL,cAAc,QAAQ,IACtB;IAAY;MACX,QAAQ;EAsBX;UAQQ;UAKA;UAMA;UAOA;UAmBA;;;;wBCjOM,MAAM,eAAe,aAAa;;;;wBCGlC,eAAe,GAAG,OAAO,IAAI;;;;;;
|
|
1
|
+
{"version":3,"file":"ts-util.d.mts","names":[],"sources":["../src/assetPath.ts","../src/base.ts","../src/cache.ts","../src/clamp.ts","../src/clonePlainData.ts","../src/configValues.ts","../src/escapeHtml.ts","../src/logging.ts","../src/merge.ts","../src/publicPath.ts","../src/typeCheck.ts","../src/types.ts","../src/urlNormalizer.ts"],"mappings":";UAKiB;EACf;;wBAGc,sBAAsB;wBAItB,YAAY;wBAIZ,aAAa;wBAQb,aAAa;wBAKb,mBAAmB;wBA0BnB,qBACd,iBACA,UAAS;;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AAY,KACtB,UAAU,YAAY,KAClB,MAAM,YAAY,MAClB,UAAU,oBAAoB,KAC5B,cAAc,YAAY,MAC1B,sBACK,WAAW,KAAK,YAAY,EAAE,SACjC;;;KCPL;UAEK;EACR,gBAAgB;;qBAGL;EACX,cAAa;EASb,eAAc;EAId,YAAW;IAAkB;IAAc;;EAa3C,cAAa,2BACc,UAChB;EA4BX,iBAAgB;EAOhB,sBAAqB;EAiBrB,iBAAgB"}
|
package/dist/ts-util.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @purestack/ts-util v1.1.
|
|
1
|
+
/*! @purestack/ts-util v1.1.16 | (c) 2026 Ahmed Yasin Koculu | MIT License */
|
|
2
2
|
|
|
3
3
|
//#region packages/ts-util/src/assetPath.ts
|
|
4
4
|
const TS_EXT = ".ts";
|
|
@@ -303,6 +303,97 @@ function clonePlainData(value) {
|
|
|
303
303
|
return value;
|
|
304
304
|
}
|
|
305
305
|
|
|
306
|
+
//#endregion
|
|
307
|
+
//#region packages/ts-util/src/urlNormalizer.ts
|
|
308
|
+
const urlNormalizer = {
|
|
309
|
+
isSpecialHref(href) {
|
|
310
|
+
return href.startsWith("#") || href.startsWith("?") || href.startsWith("//") || /^[a-zA-Z][a-zA-Z+.-]*:/.test(href);
|
|
311
|
+
},
|
|
312
|
+
isExternalHref(href) {
|
|
313
|
+
return urlNormalizer.isSpecialHref(href) || href.startsWith("../");
|
|
314
|
+
},
|
|
315
|
+
splitSuffix(href) {
|
|
316
|
+
const hashIndex = href.indexOf("#");
|
|
317
|
+
const queryIndex = href.indexOf("?");
|
|
318
|
+
const index = hashIndex === -1 ? queryIndex : queryIndex === -1 ? hashIndex : Math.min(hashIndex, queryIndex);
|
|
319
|
+
if (index === -1) return {
|
|
320
|
+
base: href,
|
|
321
|
+
suffix: ""
|
|
322
|
+
};
|
|
323
|
+
return {
|
|
324
|
+
base: href.slice(0, index),
|
|
325
|
+
suffix: href.slice(index)
|
|
326
|
+
};
|
|
327
|
+
},
|
|
328
|
+
normalizeHref(value, options = {}) {
|
|
329
|
+
if (typeof value !== "string") return void 0;
|
|
330
|
+
const trimmed = value.trim();
|
|
331
|
+
if (!trimmed) return void 0;
|
|
332
|
+
if (urlNormalizer.isExternalHref(trimmed)) return trimmed;
|
|
333
|
+
const { base, suffix } = urlNormalizer.splitSuffix(trimmed);
|
|
334
|
+
const withoutDot = base.replace(/^\.\/+/, "");
|
|
335
|
+
const withLeadingSlash = withoutDot.startsWith("/") ? withoutDot : `/${withoutDot}`;
|
|
336
|
+
const trailingSlash = options.trailingSlash ?? "preserve";
|
|
337
|
+
if (hasPathExtension(withLeadingSlash) || withLeadingSlash === "/") return `${withLeadingSlash}${suffix}`;
|
|
338
|
+
if (trailingSlash === "always" && !withLeadingSlash.endsWith("/")) return `${withLeadingSlash}/${suffix}`;
|
|
339
|
+
if (trailingSlash === "never" && withLeadingSlash.endsWith("/")) return `${withLeadingSlash.slice(0, -1)}${suffix}`;
|
|
340
|
+
return `${withLeadingSlash}${suffix}`;
|
|
341
|
+
},
|
|
342
|
+
normalizeUrlPath(urlPath) {
|
|
343
|
+
return urlNormalizer.normalizeHref(urlPath, { trailingSlash: "always" }) || "/";
|
|
344
|
+
},
|
|
345
|
+
normalizeInternalPath(value) {
|
|
346
|
+
if (typeof value !== "string") return void 0;
|
|
347
|
+
const trimmed = value.trim();
|
|
348
|
+
if (!trimmed || urlNormalizer.isExternalHref(trimmed)) return void 0;
|
|
349
|
+
const { base } = urlNormalizer.splitSuffix(trimmed);
|
|
350
|
+
const normalizedBase = base.replaceAll("\\", "/").replace(/^\.\/+/, "").replace(/\/{2,}/g, "/");
|
|
351
|
+
if (!normalizedBase) return void 0;
|
|
352
|
+
if (urlNormalizer.isExternalHref(normalizedBase)) return void 0;
|
|
353
|
+
return urlNormalizer.normalizeHref(normalizedBase, { trailingSlash: "always" });
|
|
354
|
+
},
|
|
355
|
+
hasPathExtension(value) {
|
|
356
|
+
return hasPathExtension(value);
|
|
357
|
+
}
|
|
358
|
+
};
|
|
359
|
+
function hasPathExtension(value) {
|
|
360
|
+
const lastSlashIndex = value.lastIndexOf("/");
|
|
361
|
+
const segment = lastSlashIndex >= 0 ? value.slice(lastSlashIndex + 1) : value;
|
|
362
|
+
if (!segment || segment === "." || segment === "..") return false;
|
|
363
|
+
const dotIndex = segment.lastIndexOf(".");
|
|
364
|
+
return dotIndex > 0 && dotIndex < segment.length - 1;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
//#endregion
|
|
368
|
+
//#region packages/ts-util/src/configValues.ts
|
|
369
|
+
function resolveString(...values) {
|
|
370
|
+
for (const value of values) if (typeof value === "string" && value.length > 0) return value;
|
|
371
|
+
return "";
|
|
372
|
+
}
|
|
373
|
+
function pickBoolean(input, file, fallback = false) {
|
|
374
|
+
const searchValues = [input, file];
|
|
375
|
+
for (const value of searchValues) if (typeof value === "boolean") return value;
|
|
376
|
+
return fallback;
|
|
377
|
+
}
|
|
378
|
+
function resolveOptionalString(value) {
|
|
379
|
+
if (typeof value !== "string") return void 0;
|
|
380
|
+
const normalized = value.trim();
|
|
381
|
+
return normalized.length > 0 ? normalized : void 0;
|
|
382
|
+
}
|
|
383
|
+
function resolveConfigUrl(value) {
|
|
384
|
+
if (!value || value.startsWith("/") || urlNormalizer.isSpecialHref(value)) return value;
|
|
385
|
+
const { base, suffix } = urlNormalizer.splitSuffix(value);
|
|
386
|
+
const segments = [];
|
|
387
|
+
const pathname = base.replaceAll("\\", "/");
|
|
388
|
+
for (const part of pathname.split("/")) {
|
|
389
|
+
if (!part || part === ".") continue;
|
|
390
|
+
if (part === "..") segments.pop();
|
|
391
|
+
else segments.push(part);
|
|
392
|
+
}
|
|
393
|
+
const trailing = pathname.endsWith("/") && segments.length > 0 ? "/" : "";
|
|
394
|
+
return `/${segments.join("/")}${trailing}${suffix}`;
|
|
395
|
+
}
|
|
396
|
+
|
|
306
397
|
//#endregion
|
|
307
398
|
//#region packages/ts-util/src/escapeHtml.ts
|
|
308
399
|
/**
|
|
@@ -391,67 +482,6 @@ function merge(base, ...overrides) {
|
|
|
391
482
|
return mergeInternal(base, ...overrides);
|
|
392
483
|
}
|
|
393
484
|
|
|
394
|
-
//#endregion
|
|
395
|
-
//#region packages/ts-util/src/urlNormalizer.ts
|
|
396
|
-
const urlNormalizer = {
|
|
397
|
-
isSpecialHref(href) {
|
|
398
|
-
return href.startsWith("#") || href.startsWith("?") || href.startsWith("//") || /^[a-zA-Z][a-zA-Z+.-]*:/.test(href);
|
|
399
|
-
},
|
|
400
|
-
isExternalHref(href) {
|
|
401
|
-
return urlNormalizer.isSpecialHref(href) || href.startsWith("../");
|
|
402
|
-
},
|
|
403
|
-
splitSuffix(href) {
|
|
404
|
-
const hashIndex = href.indexOf("#");
|
|
405
|
-
const queryIndex = href.indexOf("?");
|
|
406
|
-
const index = hashIndex === -1 ? queryIndex : queryIndex === -1 ? hashIndex : Math.min(hashIndex, queryIndex);
|
|
407
|
-
if (index === -1) return {
|
|
408
|
-
base: href,
|
|
409
|
-
suffix: ""
|
|
410
|
-
};
|
|
411
|
-
return {
|
|
412
|
-
base: href.slice(0, index),
|
|
413
|
-
suffix: href.slice(index)
|
|
414
|
-
};
|
|
415
|
-
},
|
|
416
|
-
normalizeHref(value, options = {}) {
|
|
417
|
-
if (typeof value !== "string") return void 0;
|
|
418
|
-
const trimmed = value.trim();
|
|
419
|
-
if (!trimmed) return void 0;
|
|
420
|
-
if (urlNormalizer.isExternalHref(trimmed)) return trimmed;
|
|
421
|
-
const { base, suffix } = urlNormalizer.splitSuffix(trimmed);
|
|
422
|
-
const withoutDot = base.replace(/^\.\/+/, "");
|
|
423
|
-
const withLeadingSlash = withoutDot.startsWith("/") ? withoutDot : `/${withoutDot}`;
|
|
424
|
-
const trailingSlash = options.trailingSlash ?? "preserve";
|
|
425
|
-
if (hasPathExtension(withLeadingSlash) || withLeadingSlash === "/") return `${withLeadingSlash}${suffix}`;
|
|
426
|
-
if (trailingSlash === "always" && !withLeadingSlash.endsWith("/")) return `${withLeadingSlash}/${suffix}`;
|
|
427
|
-
if (trailingSlash === "never" && withLeadingSlash.endsWith("/")) return `${withLeadingSlash.slice(0, -1)}${suffix}`;
|
|
428
|
-
return `${withLeadingSlash}${suffix}`;
|
|
429
|
-
},
|
|
430
|
-
normalizeUrlPath(urlPath) {
|
|
431
|
-
return urlNormalizer.normalizeHref(urlPath, { trailingSlash: "always" }) || "/";
|
|
432
|
-
},
|
|
433
|
-
normalizeInternalPath(value) {
|
|
434
|
-
if (typeof value !== "string") return void 0;
|
|
435
|
-
const trimmed = value.trim();
|
|
436
|
-
if (!trimmed || urlNormalizer.isExternalHref(trimmed)) return void 0;
|
|
437
|
-
const { base } = urlNormalizer.splitSuffix(trimmed);
|
|
438
|
-
const normalizedBase = base.replaceAll("\\", "/").replace(/^\.\/+/, "").replace(/\/{2,}/g, "/");
|
|
439
|
-
if (!normalizedBase) return void 0;
|
|
440
|
-
if (urlNormalizer.isExternalHref(normalizedBase)) return void 0;
|
|
441
|
-
return urlNormalizer.normalizeHref(normalizedBase, { trailingSlash: "always" });
|
|
442
|
-
},
|
|
443
|
-
hasPathExtension(value) {
|
|
444
|
-
return hasPathExtension(value);
|
|
445
|
-
}
|
|
446
|
-
};
|
|
447
|
-
function hasPathExtension(value) {
|
|
448
|
-
const lastSlashIndex = value.lastIndexOf("/");
|
|
449
|
-
const segment = lastSlashIndex >= 0 ? value.slice(lastSlashIndex + 1) : value;
|
|
450
|
-
if (!segment || segment === "." || segment === "..") return false;
|
|
451
|
-
const dotIndex = segment.lastIndexOf(".");
|
|
452
|
-
return dotIndex > 0 && dotIndex < segment.length - 1;
|
|
453
|
-
}
|
|
454
|
-
|
|
455
485
|
//#endregion
|
|
456
486
|
//#region packages/ts-util/src/publicPath.ts
|
|
457
487
|
function normalizeBasePath(value) {
|
|
@@ -487,5 +517,5 @@ function stripBasePath(basePath, pathname) {
|
|
|
487
517
|
}
|
|
488
518
|
|
|
489
519
|
//#endregion
|
|
490
|
-
export { Base, Cache, clamp, clonePlainData, dirnamePosix, escapeHtml, isAbortError, isEmptyPlainObject, isError, isFunction, isNumberOrBoolean, isPlainObject, isString, isTypeScriptAssetPath, joinPosix, logError, merge, normalizeBasePath, normalizePosixPath, stripBasePath, toOutputAssetRelPath, toPosixPath, urlNormalizer, withBasePath };
|
|
520
|
+
export { Base, Cache, clamp, clonePlainData, dirnamePosix, escapeHtml, isAbortError, isEmptyPlainObject, isError, isFunction, isNumberOrBoolean, isPlainObject, isString, isTypeScriptAssetPath, joinPosix, logError, merge, normalizeBasePath, normalizePosixPath, pickBoolean, resolveConfigUrl, resolveOptionalString, resolveString, stripBasePath, toOutputAssetRelPath, toPosixPath, urlNormalizer, withBasePath };
|
|
491
521
|
//# sourceMappingURL=ts-util.mjs.map
|
package/dist/ts-util.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ts-util.mjs","names":[],"sources":["../src/assetPath.ts","../src/base.ts","../src/cache.ts","../src/clamp.ts","../src/typeCheck.ts","../src/clonePlainData.ts","../src/escapeHtml.ts","../src/logging.ts","../src/merge.ts","../src/urlNormalizer.ts","../src/publicPath.ts"],"sourcesContent":["// Keep these helpers browser-safe so components like PageScript can reuse them\n// without pulling in Node-only modules such as node:path.\nconst TS_EXT = '.ts'\nconst JS_EXT = '.js'\n\nexport interface OutputAssetPathOptions {\n cacheKey?: string\n}\n\nexport function isTypeScriptAssetPath(filePath: string) {\n return getExtension(filePath).toLowerCase() === TS_EXT\n}\n\nexport function toPosixPath(filePath: string) {\n return filePath.replaceAll('\\\\', '/')\n}\n\nexport function dirnamePosix(filePath: string) {\n const normalized = toPosixPath(filePath)\n const slashIndex = normalized.lastIndexOf('/')\n if (slashIndex < 0) return '.'\n if (slashIndex === 0) return '/'\n return normalized.slice(0, slashIndex)\n}\n\nexport function joinPosix(...parts: string[]) {\n const filtered = parts.filter((part) => part.length > 0)\n return normalizePosixPath(filtered.join('/'))\n}\n\nexport function normalizePosixPath(filePath: string) {\n const normalized = toPosixPath(filePath)\n const isAbsolute = normalized.startsWith('/')\n const segments = normalized.split('/')\n const result: string[] = []\n\n for (const segment of segments) {\n if (segment.length === 0 || segment === '.') continue\n if (segment === '..') {\n const last = result[result.length - 1]\n if (last && last !== '..') {\n result.pop()\n } else if (!isAbsolute) {\n result.push('..')\n }\n continue\n }\n result.push(segment)\n }\n\n if (isAbsolute) {\n return result.length > 0 ? `/${result.join('/')}` : '/'\n }\n return result.length > 0 ? result.join('/') : '.'\n}\n\nexport function toOutputAssetRelPath(\n relPath: string,\n options: OutputAssetPathOptions = {},\n) {\n if (!isTypeScriptAssetPath(relPath)) return relPath\n const normalized = toPosixPath(relPath)\n const { dir, name } = splitPath(normalized)\n const cacheKey = normalizeCacheKey(options.cacheKey)\n const fileName = cacheKey\n ? `${name}.${cacheKey}${JS_EXT}`\n : `${name}${JS_EXT}`\n return dir.length > 0 ? `${dir}/${fileName}` : fileName\n}\n\nfunction normalizeCacheKey(value: string | undefined) {\n const normalized = value?.trim().replaceAll(/[^a-zA-Z0-9_-]/g, '')\n return normalized && normalized.length > 0 ? normalized : undefined\n}\n\nfunction getExtension(filePath: string) {\n const normalized = filePath.replaceAll('\\\\', '/')\n const fileName = normalized.slice(normalized.lastIndexOf('/') + 1)\n const dotIndex = fileName.lastIndexOf('.')\n if (dotIndex <= 0) return ''\n return fileName.slice(dotIndex)\n}\n\nfunction splitPath(filePath: string) {\n const slashIndex = filePath.lastIndexOf('/')\n const dir = slashIndex >= 0 ? filePath.slice(0, slashIndex) : ''\n const base = slashIndex >= 0 ? filePath.slice(slashIndex + 1) : filePath\n const ext = getExtension(base)\n const name = ext.length > 0 ? base.slice(0, -ext.length) : base\n return { dir, name }\n}\n","/**\n * Generates a base class that maps interface properties\n * to the class instance at runtime.\n */\n\nexport function Base<T>() {\n return class {\n constructor(opts: T) {\n Object.assign(this, opts)\n }\n } as new (\n data: T,\n ) => T & { constructor: unknown }\n}\n","type CacheStats = {\n hits: number\n misses: number\n staleHits: number\n evictions: number\n sets: number\n}\n\ntype CacheEntry<V> = {\n value: V\n expiresAt: number | null\n weight: number\n lastAccess: number\n}\n\nexport type CacheOptions<K, V> = {\n name?: string\n maxEntries?: number\n maxWeight?: number\n defaultTtlMs?: number\n allowStale?: boolean\n sizeCalculator?: (value: V, key: K) => number\n onEvict?: (entry: { key: K; value: V; reason: 'max' | 'expired' }) => void\n now?: () => number\n}\n\nexport class Cache<K, V> {\n private readonly name: string\n private readonly allowStale: boolean\n private readonly sizeCalculator: (value: V, key: K) => number\n private readonly onEvict?: CacheOptions<K, V>['onEvict']\n private readonly now: () => number\n private readonly entries = new Map<K, CacheEntry<V>>()\n private readonly inFlight = new Map<K, Promise<V>>()\n private stats: CacheStats = {\n hits: 0,\n misses: 0,\n staleHits: 0,\n evictions: 0,\n sets: 0,\n }\n private maxEntries: number\n private maxWeight: number\n private defaultTtlMs: number\n private totalWeight = 0\n\n constructor(options: CacheOptions<K, V> = {}) {\n this.name = options.name ?? 'cache'\n this.allowStale = options.allowStale ?? false\n this.sizeCalculator = options.sizeCalculator ?? (() => 1)\n this.onEvict = options.onEvict\n this.now = options.now ?? Date.now\n this.maxEntries = Math.max(1, options.maxEntries ?? 1000)\n this.maxWeight = Math.max(1, options.maxWeight ?? Number.MAX_SAFE_INTEGER)\n this.defaultTtlMs = Math.max(0, options.defaultTtlMs ?? 0)\n }\n\n get size() {\n return this.entries.size\n }\n\n get weight() {\n return this.totalWeight\n }\n\n getStats(): CacheStats {\n return { ...this.stats }\n }\n\n setLimits(options: { maxEntries?: number; maxWeight?: number }) {\n if (typeof options.maxEntries === 'number') {\n this.maxEntries = Math.max(1, options.maxEntries)\n }\n if (typeof options.maxWeight === 'number') {\n this.maxWeight = Math.max(1, options.maxWeight)\n }\n this.evictIfNeeded()\n }\n\n setDefaultTtl(ttlMs: number) {\n this.defaultTtlMs = Math.max(0, ttlMs)\n }\n\n has(key: K): boolean {\n const entry = this.entries.get(key)\n if (!entry) return false\n if (this.isExpired(entry)) {\n this.expireEntry(key, entry)\n return false\n }\n return true\n }\n\n peek(key: K): V | undefined {\n const entry = this.entries.get(key)\n if (!entry) return undefined\n if (this.isExpired(entry)) {\n this.expireEntry(key, entry)\n return this.allowStale ? entry.value : undefined\n }\n return entry.value\n }\n\n get(key: K): V | undefined {\n const entry = this.entries.get(key)\n if (!entry) {\n this.stats.misses += 1\n return undefined\n }\n if (this.isExpired(entry)) {\n this.expireEntry(key, entry)\n if (this.allowStale) {\n this.stats.staleHits += 1\n return entry.value\n }\n this.stats.misses += 1\n return undefined\n }\n entry.lastAccess = this.now()\n this.touch(key, entry)\n this.stats.hits += 1\n return entry.value\n }\n\n set(key: K, value: V, ttlMs?: number): V {\n const weight = Math.max(1, this.sizeCalculator(value, key))\n const expiresAt = this.computeExpiry(ttlMs)\n const now = this.now()\n const existing = this.entries.get(key)\n if (existing) {\n this.totalWeight -= existing.weight\n this.entries.delete(key)\n }\n this.entries.set(key, { value, expiresAt, weight, lastAccess: now })\n this.totalWeight += weight\n this.stats.sets += 1\n this.evictIfNeeded()\n return value\n }\n\n delete(key: K): boolean {\n const entry = this.entries.get(key)\n if (!entry) return false\n this.totalWeight -= entry.weight\n this.entries.delete(key)\n return true\n }\n\n clear() {\n this.entries.clear()\n this.inFlight.clear()\n this.totalWeight = 0\n }\n\n async getOrSetAsync(\n key: K,\n loader: () => Promise<V>,\n options?: { ttlMs?: number },\n ): Promise<V> {\n const cached = this.get(key)\n if (cached !== undefined) return cached\n\n const existing = this.inFlight.get(key)\n if (existing) return existing\n\n const promise = loader()\n .then((value) => {\n this.set(key, value, options?.ttlMs)\n this.inFlight.delete(key)\n return value\n })\n .catch((error) => {\n this.inFlight.delete(key)\n throw error\n })\n\n this.inFlight.set(key, promise)\n return promise\n }\n\n pruneExpired() {\n for (const [key, entry] of this.entries) {\n if (this.isExpired(entry)) {\n this.expireEntry(key, entry)\n }\n }\n }\n\n private isExpired(entry: CacheEntry<V>) {\n if (entry.expiresAt === null) return false\n return this.now() >= entry.expiresAt\n }\n\n private computeExpiry(ttlMs?: number) {\n const ttl = typeof ttlMs === 'number' ? ttlMs : this.defaultTtlMs\n if (ttl <= 0) return null\n return this.now() + ttl\n }\n\n private expireEntry(key: K, entry: CacheEntry<V>) {\n this.totalWeight -= entry.weight\n this.entries.delete(key)\n this.stats.evictions += 1\n this.onEvict?.({ key, value: entry.value, reason: 'expired' })\n }\n\n private evictIfNeeded() {\n while (\n this.entries.size > this.maxEntries ||\n this.totalWeight > this.maxWeight\n ) {\n const firstKey = this.entries.keys().next().value as K | undefined\n if (firstKey === undefined) break\n const entry = this.entries.get(firstKey)\n if (!entry) {\n this.entries.delete(firstKey)\n continue\n }\n this.totalWeight -= entry.weight\n this.entries.delete(firstKey)\n this.stats.evictions += 1\n this.onEvict?.({ key: firstKey, value: entry.value, reason: 'max' })\n }\n }\n\n private touch(key: K, entry: CacheEntry<V>) {\n this.entries.delete(key)\n this.entries.set(key, entry)\n }\n}\n","export function clamp(value: number, min: number, max: number): number {\n return Math.max(min, Math.min(max, value))\n}\n","export const isString = (value: unknown): value is string =>\n typeof value === 'string' || value instanceof String\n\nexport function isAbortError(err: unknown): boolean {\n const obj = err as Record<string, unknown>\n return (\n obj != null && typeof obj.name === 'string' && obj.name === 'AbortError'\n )\n}\n\nexport function isFunction(\n func: unknown,\n): func is (...args: unknown[]) => unknown {\n return typeof func === 'function'\n}\n\nexport function isPlainObject(\n value: unknown,\n): value is Record<string, unknown> {\n if (typeof value !== 'object' || value === null) return false\n const proto = Object.getPrototypeOf(value)\n return proto === Object.prototype || proto === null\n}\n\nexport function isNumberOrBoolean(value: unknown): value is number | boolean {\n return typeof value === 'number' || typeof value === 'boolean'\n}\n\nexport function isEmptyPlainObject(\n value: unknown,\n): value is Record<string, never> {\n if (!isPlainObject(value)) return false\n for (const _ in value) {\n return false\n }\n return true\n}\n\nexport function isError(o: unknown): o is Error {\n return o instanceof Error\n}\n","import { isPlainObject } from './typeCheck'\n\n/** Copies arrays and plain objects recursively, retaining callbacks and other values. */\nexport function clonePlainData<T>(value: T): T {\n if (Array.isArray(value)) return value.map(clonePlainData) as T\n if (isPlainObject(value))\n return Object.fromEntries(\n Object.entries(value).map(([key, item]) => [key, clonePlainData(item)]),\n ) as T\n return value\n}\n","/**\n * Escapes &, `<`, `>`, and \" (optionally) in a string for safe insertion into HTML.\n */\nexport function escapeHtml(str: string, escapeQuot = false): string {\n let result = ''\n let last = 0\n\n for (let i = 0; i < str.length; i++) {\n let replacement: string | undefined\n switch (str.charCodeAt(i)) {\n case 38:\n replacement = '&'\n break\n case 60:\n replacement = '<'\n break\n case 62:\n replacement = '>'\n break\n case 34:\n if (escapeQuot) replacement = '"'\n break\n }\n\n if (replacement) {\n if (last < i) {\n result += str.slice(last, i)\n }\n result += replacement\n last = i + 1\n }\n }\n\n if (last === 0) {\n return str\n }\n\n if (last < str.length) {\n result += str.slice(last)\n }\n\n return result\n}\n","export interface LoggerLike {\n error: (msg: string, meta?: Record<string, unknown> | Error) => void\n}\n\nexport function logError(logger: LoggerLike, error: unknown, msg: string) {\n const isError = error instanceof Error\n if (isError) {\n logger.error(msg, error)\n return\n }\n const errorText = String(error)\n logger.error(msg, { error: errorText })\n}\n","import { isPlainObject } from './typeCheck'\n\n/**\n * Recursively merges multiple objects into one plain object.\n *\n * Each provided object is iterated in order. If a key exists in multiple objects:\n * - If both the accumulated result and the new value are plain objects, they are merged recursively.\n * - Otherwise, the new value overwrites the previous one.\n *\n * @param objects - A list of objects (or undefined) to merge.\n * @returns A new object containing all merged keys.\n */\nfunction mergeInternal(\n ...objects: Array<Record<string, unknown> | undefined>\n): Record<string, unknown> {\n const result: Record<string, unknown> = {}\n\n for (const obj of objects) {\n if (!isPlainObject(obj)) continue\n for (const key of Object.keys(obj)) {\n const src = obj[key]\n const prev = result[key]\n if (isPlainObject(prev) && isPlainObject(src)) {\n result[key] = mergeInternal(prev, src)\n } else {\n result[key] = src\n }\n }\n }\n\n return result\n}\n\n/**\n * Deeply merge a base value `T` with any number of partial or full override objects.\n *\n * This function enforces that the base value is a plain object. It merges nested objects\n * recursively and overwrites non-object values or object/primitive mismatches with later overrides.\n *\n * @typeParam T - base type\n * @typeParam K - return type\n * @param base - The base object to merge into. Must be a plain object.\n * @param overrides - Partial or full override objects.\n * Non-object values or undefined entries will simply overwrite or be skipped.\n * @returns The merged result, typed as `K`.\n * @throws If the `base` argument is not a plain object.\n */\nexport function merge<T, K = T>(base: T, ...overrides: Array<unknown>): K {\n if (!isPlainObject(base)) {\n throw new Error(`merge is not possible with ${String(base)}`)\n }\n const merged = mergeInternal(\n base as Record<string, unknown>,\n ...(overrides as Record<string, unknown>[]),\n )\n return merged as K\n}\n","type TrailingSlashMode = 'preserve' | 'always' | 'never'\n\ninterface NormalizeHrefOptions {\n trailingSlash?: TrailingSlashMode\n}\n\nexport const urlNormalizer = {\n isSpecialHref(href: string): boolean {\n return (\n href.startsWith('#') ||\n href.startsWith('?') ||\n href.startsWith('//') ||\n /^[a-zA-Z][a-zA-Z+.-]*:/.test(href)\n )\n },\n\n isExternalHref(href: string): boolean {\n return urlNormalizer.isSpecialHref(href) || href.startsWith('../')\n },\n\n splitSuffix(href: string): { base: string; suffix: string } {\n const hashIndex = href.indexOf('#')\n const queryIndex = href.indexOf('?')\n const index =\n hashIndex === -1\n ? queryIndex\n : queryIndex === -1\n ? hashIndex\n : Math.min(hashIndex, queryIndex)\n if (index === -1) return { base: href, suffix: '' }\n return { base: href.slice(0, index), suffix: href.slice(index) }\n },\n\n normalizeHref(\n value: string | undefined,\n options: NormalizeHrefOptions = {},\n ): string | undefined {\n if (typeof value !== 'string') return undefined\n const trimmed = value.trim()\n if (!trimmed) return undefined\n if (urlNormalizer.isExternalHref(trimmed)) return trimmed\n\n const { base, suffix } = urlNormalizer.splitSuffix(trimmed)\n const withoutDot = base.replace(/^\\.\\/+/, '')\n const withLeadingSlash = withoutDot.startsWith('/')\n ? withoutDot\n : `/${withoutDot}`\n const trailingSlash = options.trailingSlash ?? 'preserve'\n const hasExt = hasPathExtension(withLeadingSlash)\n\n if (hasExt || withLeadingSlash === '/') {\n return `${withLeadingSlash}${suffix}`\n }\n\n if (trailingSlash === 'always' && !withLeadingSlash.endsWith('/')) {\n return `${withLeadingSlash}/${suffix}`\n }\n if (trailingSlash === 'never' && withLeadingSlash.endsWith('/')) {\n return `${withLeadingSlash.slice(0, -1)}${suffix}`\n }\n return `${withLeadingSlash}${suffix}`\n },\n\n normalizeUrlPath(urlPath: string): string {\n const normalized = urlNormalizer.normalizeHref(urlPath, {\n trailingSlash: 'always',\n })\n return normalized || '/'\n },\n\n normalizeInternalPath(value: string | undefined): string | undefined {\n if (typeof value !== 'string') return undefined\n const trimmed = value.trim()\n if (!trimmed || urlNormalizer.isExternalHref(trimmed)) return undefined\n\n const { base } = urlNormalizer.splitSuffix(trimmed)\n const normalizedBase = base\n .replaceAll('\\\\', '/')\n .replace(/^\\.\\/+/, '')\n .replace(/\\/{2,}/g, '/')\n if (!normalizedBase) return undefined\n if (urlNormalizer.isExternalHref(normalizedBase)) return undefined\n return urlNormalizer.normalizeHref(normalizedBase, {\n trailingSlash: 'always',\n })\n },\n\n hasPathExtension(value: string): boolean {\n return hasPathExtension(value)\n },\n}\n\nfunction hasPathExtension(value: string) {\n const lastSlashIndex = value.lastIndexOf('/')\n const segment = lastSlashIndex >= 0 ? value.slice(lastSlashIndex + 1) : value\n if (!segment || segment === '.' || segment === '..') return false\n const dotIndex = segment.lastIndexOf('.')\n return dotIndex > 0 && dotIndex < segment.length - 1\n}\n","import { normalizePosixPath } from './assetPath'\nimport { urlNormalizer } from './urlNormalizer'\n\nexport function normalizeBasePath(value: string | undefined): string {\n if (typeof value !== 'string') return ''\n const trimmed = value.trim()\n if (!trimmed || trimmed === '/') return ''\n if (urlNormalizer.isSpecialHref(trimmed)) {\n throw new Error(`basePath must be a site path, not \"${value}\".`)\n }\n if (trimmed.includes('?') || trimmed.includes('#')) {\n throw new Error(\n `basePath must not include query or hash parts: \"${value}\".`,\n )\n }\n\n const normalizedSlashes = trimmed.replaceAll('\\\\', '/')\n const withLeadingSlash = normalizedSlashes.startsWith('/')\n ? normalizedSlashes\n : `/${normalizedSlashes}`\n const segments = withLeadingSlash.split('/').filter(Boolean)\n if (segments.some((segment) => segment === '.' || segment === '..')) {\n throw new Error(`basePath must stay inside the site root: \"${value}\".`)\n }\n\n const normalized = normalizePosixPath(withLeadingSlash).replace(/\\/+$/, '')\n return normalized === '/' ? '' : normalized\n}\n\nexport function withBasePath(basePath: string, href: string): string {\n const normalizedBasePath = normalizeBasePath(basePath)\n if (!normalizedBasePath) return href\n if (!href || href.trim() !== href) return href\n if (urlNormalizer.isSpecialHref(href)) return href\n if (!href.startsWith('/')) return href\n\n const { base, suffix } = urlNormalizer.splitSuffix(href)\n if (base === normalizedBasePath) return `${base}${suffix}`\n if (base.startsWith(`${normalizedBasePath}/`)) return `${base}${suffix}`\n if (base === '/') return `${normalizedBasePath}/${suffix}`\n return `${normalizedBasePath}${base}${suffix}`\n}\n\nexport function stripBasePath(basePath: string, pathname: string): string {\n const normalizedBasePath = normalizeBasePath(basePath)\n if (!normalizedBasePath) return pathname\n if (pathname === normalizedBasePath) return '/'\n if (pathname.startsWith(`${normalizedBasePath}/`)) {\n return pathname.slice(normalizedBasePath.length) || '/'\n }\n return pathname\n}\n"],"mappings":";AAEA,MAAM,SAAS;AACf,MAAM,SAAS;AAMf,SAAgB,sBAAsB,UAAkB;CACtD,OAAO,aAAa,QAAQ,CAAC,CAAC,YAAY,MAAM;AAClD;AAEA,SAAgB,YAAY,UAAkB;CAC5C,OAAO,SAAS,WAAW,MAAM,GAAG;AACtC;AAEA,SAAgB,aAAa,UAAkB;CAC7C,MAAM,aAAa,YAAY,QAAQ;CACvC,MAAM,aAAa,WAAW,YAAY,GAAG;CAC7C,IAAI,aAAa,GAAG,OAAO;CAC3B,IAAI,eAAe,GAAG,OAAO;CAC7B,OAAO,WAAW,MAAM,GAAG,UAAU;AACvC;AAEA,SAAgB,UA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AO;CAC1C,IAAI,cAAc,cAAc,IAAI,GAAG,OAAO;CAC9C,IAAI,CAAC,KAAK,WAAW,GAAG,GAAG,OAAO;CAElC,MAAM,EAAE,MAAM,WAAW,cAAc,YAAY,IAAI;CACvD,IAAI,SAAS,oBAAoB,OAAO,GAAG,OAAO;CAClD,IAAI,KAAK,WAAW,GAAG,mBAAmB,EAAE,GAAG,OAAO,GAAG,OAAO;CAChE,IAAI,SAAS,KAAK,OAAO,GAAG,mBAAmB,GAAG;CAClD,OAAO,GAAG,qBAAqB,OAAO;AACxC;AAEA,SAAgB,cAAc,UAAkB,UAA0B;CACxE,MAAM,qBAAqB,kBAAkB,QAAQ;CACrD,IAAI,CAAC,oBAAoB,OAAO;CAChC,IAAI,aAAa,oBAAoB,OAAO;CAC5C,IAAI,SAAS,WAAW,GAAG,mBAAmB,EAAE,GAC9C,OAAO,SAAS,MAAM,mBAAmB,MAAM,KAAK;CAEtD,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"ts-util.mjs","names":[],"sources":["../src/assetPath.ts","../src/base.ts","../src/cache.ts","../src/clamp.ts","../src/typeCheck.ts","../src/clonePlainData.ts","../src/urlNormalizer.ts","../src/configValues.ts","../src/escapeHtml.ts","../src/logging.ts","../src/merge.ts","../src/publicPath.ts"],"sourcesContent":["// Keep these helpers browser-safe so components like PageScript can reuse them\n// without pulling in Node-only modules such as node:path.\nconst TS_EXT = '.ts'\nconst JS_EXT = '.js'\n\nexport interface OutputAssetPathOptions {\n cacheKey?: string\n}\n\nexport function isTypeScriptAssetPath(filePath: string) {\n return getExtension(filePath).toLowerCase() === TS_EXT\n}\n\nexport function toPosixPath(filePath: string) {\n return filePath.replaceAll('\\\\', '/')\n}\n\nexport function dirnamePosix(filePath: string) {\n const normalized = toPosixPath(filePath)\n const slashIndex = normalized.lastIndexOf('/')\n if (slashIndex < 0) return '.'\n if (slashIndex === 0) return '/'\n return normalized.slice(0, slashIndex)\n}\n\nexport function joinPosix(...parts: string[]) {\n const filtered = parts.filter((part) => part.length > 0)\n return normalizePosixPath(filtered.join('/'))\n}\n\nexport function normalizePosixPath(filePath: string) {\n const normalized = toPosixPath(filePath)\n const isAbsolute = normalized.startsWith('/')\n const segments = normalized.split('/')\n const result: string[] = []\n\n for (const segment of segments) {\n if (segment.length === 0 || segment === '.') continue\n if (segment === '..') {\n const last = result[result.length - 1]\n if (last && last !== '..') {\n result.pop()\n } else if (!isAbsolute) {\n result.push('..')\n }\n continue\n }\n result.push(segment)\n }\n\n if (isAbsolute) {\n return result.length > 0 ? `/${result.join('/')}` : '/'\n }\n return result.length > 0 ? result.join('/') : '.'\n}\n\nexport function toOutputAssetRelPath(\n relPath: string,\n options: OutputAssetPathOptions = {},\n) {\n if (!isTypeScriptAssetPath(relPath)) return relPath\n const normalized = toPosixPath(relPath)\n const { dir, name } = splitPath(normalized)\n const cacheKey = normalizeCacheKey(options.cacheKey)\n const fileName = cacheKey\n ? `${name}.${cacheKey}${JS_EXT}`\n : `${name}${JS_EXT}`\n return dir.length > 0 ? `${dir}/${fileName}` : fileName\n}\n\nfunction normalizeCacheKey(value: string | undefined) {\n const normalized = value?.trim().replaceAll(/[^a-zA-Z0-9_-]/g, '')\n return normalized && normalized.length > 0 ? normalized : undefined\n}\n\nfunction getExtension(filePath: string) {\n const normalized = filePath.replaceAll('\\\\', '/')\n const fileName = normalized.slice(normalized.lastIndexOf('/') + 1)\n const dotIndex = fileName.lastIndexOf('.')\n if (dotIndex <= 0) return ''\n return fileName.slice(dotIndex)\n}\n\nfunction splitPath(filePath: string) {\n const slashIndex = filePath.lastIndexOf('/')\n const dir = slashIndex >= 0 ? filePath.slice(0, slashIndex) : ''\n const base = slashIndex >= 0 ? filePath.slice(slashIndex + 1) : filePath\n const ext = getExtension(base)\n const name = ext.length > 0 ? base.slice(0, -ext.length) : base\n return { dir, name }\n}\n","/**\n * Generates a base class that maps interface properties\n * to the class instance at runtime.\n */\n\nexport function Base<T>() {\n return class {\n constructor(opts: T) {\n Object.assign(this, opts)\n }\n } as new (\n data: T,\n ) => T & { constructor: unknown }\n}\n","type CacheStats = {\n hits: number\n misses: number\n staleHits: number\n evictions: number\n sets: number\n}\n\ntype CacheEntry<V> = {\n value: V\n expiresAt: number | null\n weight: number\n lastAccess: number\n}\n\nexport type CacheOptions<K, V> = {\n name?: string\n maxEntries?: number\n maxWeight?: number\n defaultTtlMs?: number\n allowStale?: boolean\n sizeCalculator?: (value: V, key: K) => number\n onEvict?: (entry: { key: K; value: V; reason: 'max' | 'expired' }) => void\n now?: () => number\n}\n\nexport class Cache<K, V> {\n private readonly name: string\n private readonly allowStale: boolean\n private readonly sizeCalculator: (value: V, key: K) => number\n private readonly onEvict?: CacheOptions<K, V>['onEvict']\n private readonly now: () => number\n private readonly entries = new Map<K, CacheEntry<V>>()\n private readonly inFlight = new Map<K, Promise<V>>()\n private stats: CacheStats = {\n hits: 0,\n misses: 0,\n staleHits: 0,\n evictions: 0,\n sets: 0,\n }\n private maxEntries: number\n private maxWeight: number\n private defaultTtlMs: number\n private totalWeight = 0\n\n constructor(options: CacheOptions<K, V> = {}) {\n this.name = options.name ?? 'cache'\n this.allowStale = options.allowStale ?? false\n this.sizeCalculator = options.sizeCalculator ?? (() => 1)\n this.onEvict = options.onEvict\n this.now = options.now ?? Date.now\n this.maxEntries = Math.max(1, options.maxEntries ?? 1000)\n this.maxWeight = Math.max(1, options.maxWeight ?? Number.MAX_SAFE_INTEGER)\n this.defaultTtlMs = Math.max(0, options.defaultTtlMs ?? 0)\n }\n\n get size() {\n return this.entries.size\n }\n\n get weight() {\n return this.totalWeight\n }\n\n getStats(): CacheStats {\n return { ...this.stats }\n }\n\n setLimits(options: { maxEntries?: number; maxWeight?: number }) {\n if (typeof options.maxEntries === 'number') {\n this.maxEntries = Math.max(1, options.maxEntries)\n }\n if (typeof options.maxWeight === 'number') {\n this.maxWeight = Math.max(1, options.maxWeight)\n }\n this.evictIfNeeded()\n }\n\n setDefaultTtl(ttlMs: number) {\n this.defaultTtlMs = Math.max(0, ttlMs)\n }\n\n has(key: K): boolean {\n const entry = this.entries.get(key)\n if (!entry) return false\n if (this.isExpired(entry)) {\n this.expireEntry(key, entry)\n return false\n }\n return true\n }\n\n peek(key: K): V | undefined {\n const entry = this.entries.get(key)\n if (!entry) return undefined\n if (this.isExpired(entry)) {\n this.expireEntry(key, entry)\n return this.allowStale ? entry.value : undefined\n }\n return entry.value\n }\n\n get(key: K): V | undefined {\n const entry = this.entries.get(key)\n if (!entry) {\n this.stats.misses += 1\n return undefined\n }\n if (this.isExpired(entry)) {\n this.expireEntry(key, entry)\n if (this.allowStale) {\n this.stats.staleHits += 1\n return entry.value\n }\n this.stats.misses += 1\n return undefined\n }\n entry.lastAccess = this.now()\n this.touch(key, entry)\n this.stats.hits += 1\n return entry.value\n }\n\n set(key: K, value: V, ttlMs?: number): V {\n const weight = Math.max(1, this.sizeCalculator(value, key))\n const expiresAt = this.computeExpiry(ttlMs)\n const now = this.now()\n const existing = this.entries.get(key)\n if (existing) {\n this.totalWeight -= existing.weight\n this.entries.delete(key)\n }\n this.entries.set(key, { value, expiresAt, weight, lastAccess: now })\n this.totalWeight += weight\n this.stats.sets += 1\n this.evictIfNeeded()\n return value\n }\n\n delete(key: K): boolean {\n const entry = this.entries.get(key)\n if (!entry) return false\n this.totalWeight -= entry.weight\n this.entries.delete(key)\n return true\n }\n\n clear() {\n this.entries.clear()\n this.inFlight.clear()\n this.totalWeight = 0\n }\n\n async getOrSetAsync(\n key: K,\n loader: () => Promise<V>,\n options?: { ttlMs?: number },\n ): Promise<V> {\n const cached = this.get(key)\n if (cached !== undefined) return cached\n\n const existing = this.inFlight.get(key)\n if (existing) return existing\n\n const promise = loader()\n .then((value) => {\n this.set(key, value, options?.ttlMs)\n this.inFlight.delete(key)\n return value\n })\n .catch((error) => {\n this.inFlight.delete(key)\n throw error\n })\n\n this.inFlight.set(key, promise)\n return promise\n }\n\n pruneExpired() {\n for (const [key, entry] of this.entries) {\n if (this.isExpired(entry)) {\n this.expireEntry(key, entry)\n }\n }\n }\n\n private isExpired(entry: CacheEntry<V>) {\n if (entry.expiresAt === null) return false\n return this.now() >= entry.expiresAt\n }\n\n private computeExpiry(ttlMs?: number) {\n const ttl = typeof ttlMs === 'number' ? ttlMs : this.defaultTtlMs\n if (ttl <= 0) return null\n return this.now() + ttl\n }\n\n private expireEntry(key: K, entry: CacheEntry<V>) {\n this.totalWeight -= entry.weight\n this.entries.delete(key)\n this.stats.evictions += 1\n this.onEvict?.({ key, value: entry.value, reason: 'expired' })\n }\n\n private evictIfNeeded() {\n while (\n this.entries.size > this.maxEntries ||\n this.totalWeight > this.maxWeight\n ) {\n const firstKey = this.entries.keys().next().value as K | undefined\n if (firstKey === undefined) break\n const entry = this.entries.get(firstKey)\n if (!entry) {\n this.entries.delete(firstKey)\n continue\n }\n this.totalWeight -= entry.weight\n this.entries.delete(firstKey)\n this.stats.evictions += 1\n this.onEvict?.({ key: firstKey, value: entry.value, reason: 'max' })\n }\n }\n\n private touch(key: K, entry: CacheEntry<V>) {\n this.entries.delete(key)\n this.entries.set(key, entry)\n }\n}\n","export function clamp(value: number, min: number, max: number): number {\n return Math.max(min, Math.min(max, value))\n}\n","export const isString = (value: unknown): value is string =>\n typeof value === 'string' || value instanceof String\n\nexport function isAbortError(err: unknown): boolean {\n const obj = err as Record<string, unknown>\n return (\n obj != null && typeof obj.name === 'string' && obj.name === 'AbortError'\n )\n}\n\nexport function isFunction(\n func: unknown,\n): func is (...args: unknown[]) => unknown {\n return typeof func === 'function'\n}\n\nexport function isPlainObject(\n value: unknown,\n): value is Record<string, unknown> {\n if (typeof value !== 'object' || value === null) return false\n const proto = Object.getPrototypeOf(value)\n return proto === Object.prototype || proto === null\n}\n\nexport function isNumberOrBoolean(value: unknown): value is number | boolean {\n return typeof value === 'number' || typeof value === 'boolean'\n}\n\nexport function isEmptyPlainObject(\n value: unknown,\n): value is Record<string, never> {\n if (!isPlainObject(value)) return false\n for (const _ in value) {\n return false\n }\n return true\n}\n\nexport function isError(o: unknown): o is Error {\n return o instanceof Error\n}\n","import { isPlainObject } from './typeCheck'\n\n/** Copies arrays and plain objects recursively, retaining callbacks and other values. */\nexport function clonePlainData<T>(value: T): T {\n if (Array.isArray(value)) return value.map(clonePlainData) as T\n if (isPlainObject(value))\n return Object.fromEntries(\n Object.entries(value).map(([key, item]) => [key, clonePlainData(item)]),\n ) as T\n return value\n}\n","type TrailingSlashMode = 'preserve' | 'always' | 'never'\n\ninterface NormalizeHrefOptions {\n trailingSlash?: TrailingSlashMode\n}\n\nexport const urlNormalizer = {\n isSpecialHref(href: string): boolean {\n return (\n href.startsWith('#') ||\n href.startsWith('?') ||\n href.startsWith('//') ||\n /^[a-zA-Z][a-zA-Z+.-]*:/.test(href)\n )\n },\n\n isExternalHref(href: string): boolean {\n return urlNormalizer.isSpecialHref(href) || href.startsWith('../')\n },\n\n splitSuffix(href: string): { base: string; suffix: string } {\n const hashIndex = href.indexOf('#')\n const queryIndex = href.indexOf('?')\n const index =\n hashIndex === -1\n ? queryIndex\n : queryIndex === -1\n ? hashIndex\n : Math.min(hashIndex, queryIndex)\n if (index === -1) return { base: href, suffix: '' }\n return { base: href.slice(0, index), suffix: href.slice(index) }\n },\n\n normalizeHref(\n value: string | undefined,\n options: NormalizeHrefOptions = {},\n ): string | undefined {\n if (typeof value !== 'string') return undefined\n const trimmed = value.trim()\n if (!trimmed) return undefined\n if (urlNormalizer.isExternalHref(trimmed)) return trimmed\n\n const { base, suffix } = urlNormalizer.splitSuffix(trimmed)\n const withoutDot = base.replace(/^\\.\\/+/, '')\n const withLeadingSlash = withoutDot.startsWith('/')\n ? withoutDot\n : `/${withoutDot}`\n const trailingSlash = options.trailingSlash ?? 'preserve'\n const hasExt = hasPathExtension(withLeadingSlash)\n\n if (hasExt || withLeadingSlash === '/') {\n return `${withLeadingSlash}${suffix}`\n }\n\n if (trailingSlash === 'always' && !withLeadingSlash.endsWith('/')) {\n return `${withLeadingSlash}/${suffix}`\n }\n if (trailingSlash === 'never' && withLeadingSlash.endsWith('/')) {\n return `${withLeadingSlash.slice(0, -1)}${suffix}`\n }\n return `${withLeadingSlash}${suffix}`\n },\n\n normalizeUrlPath(urlPath: string): string {\n const normalized = urlNormalizer.normalizeHref(urlPath, {\n trailingSlash: 'always',\n })\n return normalized || '/'\n },\n\n normalizeInternalPath(value: string | undefined): string | undefined {\n if (typeof value !== 'string') return undefined\n const trimmed = value.trim()\n if (!trimmed || urlNormalizer.isExternalHref(trimmed)) return undefined\n\n const { base } = urlNormalizer.splitSuffix(trimmed)\n const normalizedBase = base\n .replaceAll('\\\\', '/')\n .replace(/^\\.\\/+/, '')\n .replace(/\\/{2,}/g, '/')\n if (!normalizedBase) return undefined\n if (urlNormalizer.isExternalHref(normalizedBase)) return undefined\n return urlNormalizer.normalizeHref(normalizedBase, {\n trailingSlash: 'always',\n })\n },\n\n hasPathExtension(value: string): boolean {\n return hasPathExtension(value)\n },\n}\n\nfunction hasPathExtension(value: string) {\n const lastSlashIndex = value.lastIndexOf('/')\n const segment = lastSlashIndex >= 0 ? value.slice(lastSlashIndex + 1) : value\n if (!segment || segment === '.' || segment === '..') return false\n const dotIndex = segment.lastIndexOf('.')\n return dotIndex > 0 && dotIndex < segment.length - 1\n}\n","import { urlNormalizer } from './urlNormalizer'\n\nexport function resolveString(...values: Array<string | undefined>) {\n for (const value of values) {\n if (typeof value === 'string' && value.length > 0) return value\n }\n return ''\n}\n\nexport function pickBoolean(input: unknown, file: unknown, fallback = false) {\n const searchValues = [input, file]\n for (const value of searchValues) {\n if (typeof value === 'boolean') return value\n }\n return fallback\n}\n\nexport function resolveOptionalString(value: unknown) {\n if (typeof value !== 'string') return undefined\n const normalized = value.trim()\n return normalized.length > 0 ? normalized : undefined\n}\n\n/** Content-root-relative URL, independent of the current page. */\nexport function resolveConfigUrl(value: string): string\nexport function resolveConfigUrl(value: string | undefined): string | undefined\nexport function resolveConfigUrl(value: string | undefined) {\n if (!value || value.startsWith('/') || urlNormalizer.isSpecialHref(value))\n return value\n const { base, suffix } = urlNormalizer.splitSuffix(value)\n const segments: string[] = []\n const pathname = base.replaceAll('\\\\', '/')\n for (const part of pathname.split('/')) {\n if (!part || part === '.') continue\n if (part === '..') segments.pop()\n else segments.push(part)\n }\n const trailing = pathname.endsWith('/') && segments.length > 0 ? '/' : ''\n return `/${segments.join('/')}${trailing}${suffix}`\n}\n","/**\n * Escapes &, `<`, `>`, and \" (optionally) in a string for safe insertion into HTML.\n */\nexport function escapeHtml(str: string, escapeQuot = false): string {\n let result = ''\n let last = 0\n\n for (let i = 0; i < str.length; i++) {\n let replacement: string | undefined\n switch (str.charCodeAt(i)) {\n case 38:\n replacement = '&'\n break\n case 60:\n replacement = '<'\n break\n case 62:\n replacement = '>'\n break\n case 34:\n if (escapeQuot) replacement = '"'\n break\n }\n\n if (replacement) {\n if (last < i) {\n result += str.slice(last, i)\n }\n result += replacement\n last = i + 1\n }\n }\n\n if (last === 0) {\n return str\n }\n\n if (last < str.length) {\n result += str.slice(last)\n }\n\n return result\n}\n","export interface LoggerLike {\n error: (msg: string, meta?: Record<string, unknown> | Error) => void\n}\n\nexport function logError(logger: LoggerLike, error: unknown, msg: string) {\n const isError = error instanceof Error\n if (isError) {\n logger.error(msg, error)\n return\n }\n const errorText = String(error)\n logger.error(msg, { error: errorText })\n}\n","import { isPlainObject } from './typeCheck'\n\n/**\n * Recursively merges multiple objects into one plain object.\n *\n * Each provided object is iterated in order. If a key exists in multiple objects:\n * - If both the accumulated result and the new value are plain objects, they are merged recursively.\n * - Otherwise, the new value overwrites the previous one.\n *\n * @param objects - A list of objects (or undefined) to merge.\n * @returns A new object containing all merged keys.\n */\nfunction mergeInternal(\n ...objects: Array<Record<string, unknown> | undefined>\n): Record<string, unknown> {\n const result: Record<string, unknown> = {}\n\n for (const obj of objects) {\n if (!isPlainObject(obj)) continue\n for (const key of Object.keys(obj)) {\n const src = obj[key]\n const prev = result[key]\n if (isPlainObject(prev) && isPlainObject(src)) {\n result[key] = mergeInternal(prev, src)\n } else {\n result[key] = src\n }\n }\n }\n\n return result\n}\n\n/**\n * Deeply merge a base value `T` with any number of partial or full override objects.\n *\n * This function enforces that the base value is a plain object. It merges nested objects\n * recursively and overwrites non-object values or object/primitive mismatches with later overrides.\n *\n * @typeParam T - base type\n * @typeParam K - return type\n * @param base - The base object to merge into. Must be a plain object.\n * @param overrides - Partial or full override objects.\n * Non-object values or undefined entries will simply overwrite or be skipped.\n * @returns The merged result, typed as `K`.\n * @throws If the `base` argument is not a plain object.\n */\nexport function merge<T, K = T>(base: T, ...overrides: Array<unknown>): K {\n if (!isPlainObject(base)) {\n throw new Error(`merge is not possible with ${String(base)}`)\n }\n const merged = mergeInternal(\n base as Record<string, unknown>,\n ...(overrides as Record<string, unknown>[]),\n )\n return merged as K\n}\n","import { normalizePosixPath } from './assetPath'\nimport { urlNormalizer } from './urlNormalizer'\n\nexport function normalizeBasePath(value: string | undefined): string {\n if (typeof value !== 'string') return ''\n const trimmed = value.trim()\n if (!trimmed || trimmed === '/') return ''\n if (urlNormalizer.isSpecialHref(trimmed)) {\n throw new Error(`basePath must be a site path, not \"${value}\".`)\n }\n if (trimmed.includes('?') || trimmed.includes('#')) {\n throw new Error(\n `basePath must not include query or hash parts: \"${value}\".`,\n )\n }\n\n const normalizedSlashes = trimmed.replaceAll('\\\\', '/')\n const withLeadingSlash = normalizedSlashes.startsWith('/')\n ? normalizedSlashes\n : `/${normalizedSlashes}`\n const segments = withLeadingSlash.split('/').filter(Boolean)\n if (segments.some((segment) => segment === '.' || segment === '..')) {\n throw new Error(`basePath must stay inside the site root: \"${value}\".`)\n }\n\n const normalized = normalizePosixPath(withLeadingSlash).replace(/\\/+$/, '')\n return normalized === '/' ? '' : normalized\n}\n\nexport function withBasePath(basePath: string, href: string): string {\n const normalizedBasePath = normalizeBasePath(basePath)\n if (!normalizedBasePath) return href\n if (!href || href.trim() !== href) return href\n if (urlNormalizer.isSpecialHref(href)) return href\n if (!href.startsWith('/')) return href\n\n const { base, suffix } = urlNormalizer.splitSuffix(href)\n if (base === normalizedBasePath) return `${base}${suffix}`\n if (base.startsWith(`${normalizedBasePath}/`)) return `${base}${suffix}`\n if (base === '/') return `${normalizedBasePath}/${suffix}`\n return `${normalizedBasePath}${base}${suffix}`\n}\n\nexport function stripBasePath(basePath: string, pathname: string): string {\n const normalizedBasePath = normalizeBasePath(basePath)\n if (!normalizedBasePath) return pathname\n if (pathname === normalizedBasePath) return '/'\n if (pathname.startsWith(`${normalizedBasePath}/`)) {\n return pathname.slice(normalizedBasePath.length) || '/'\n }\n return pathname\n}\n"],"mappings":";AAEA,MAAM,SAAS;AACf,MAAM,SAAS;AAMf,SAAgB,sBAAsB,UAAkB;CACtD,OAAO,aAAa,QAAQ,CAAC,CAAC,YAAY,MAAM;AAClD;AAEA,SAAgB,YAAY,UAAkB;CAC5C,OAAO,SAAS,WAAW,MAAM,GAAG;AACtC;AAEA,SAAgB,aAAa,UAAkB;CAC7C,MAAM,aAAa,YAAY,QAAQ;CACvC,MAAM,aAAa,WAAW,YAAY,GAAG;CAC7C,IAAI,aAAa,GAAG,OAAO;CAC3B,IAAI,eAAe,GAAG,OAAO;CAC7B,OAAO,WAAW,MAAM,GAAG,UAAU;AACvC;AAEA,SAAgB,UAAU,GAAG,OAAiB;CAE5C,OAAO,mBADU,MAAM,QAAQ,SAAS,KAAK,SAAS,CACrB,CAAC,CAAC,KAAK,GAAG,CAAC;AAC9C;AAEA,SAAgB,mBAAmB,UAAkB;CACnD,MAAM,aAAa,YAAY,QAAQ;CACvC,MAAM,aAAa,WAAW,WAAW,GAAG;CAC5C,MAAM,WAAW,WAAW,MAAM,GAAG;CACrC,MAAM,SAAmB,CAAC;CAE1B,KAAK,MAAM,WAAW,UAAU;EAC9B,IAAI,QAAQ,WAAW,KAAK,YAAY,KAAK;EAC7C,IAAI,YAAY,MAAM;GACpB,MAAM,OAAO,OAAO,OAAO,SAAS;GACpC,IAAI,QAAQ,SAAS,MACnB,OAAO,IAAI;QACN,IAAI,CAAC,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