@purestack/ts-util 1.1.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ahmed Yasin Koculu
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,8 @@
1
+ # @purestack/ts-util
2
+
3
+ Small, browser-safe helpers shared across PureStack packages. Exports include
4
+ HTML escaping, object merging, value and type checks, caching, and URL and asset
5
+ path handling.
6
+
7
+ Use `escapeHtml`, `merge`, `normalizeBasePath`, or the other named exports when
8
+ building on PureStack without pulling in Node.js APIs.
@@ -0,0 +1,152 @@
1
+ /*! @purestack/ts-util v1.1.0 | (c) 2026 Ahmed Yasin Koculu | MIT License */
2
+
3
+ //#region packages/ts-util/src/assetPath.d.ts
4
+ interface OutputAssetPathOptions {
5
+ cacheKey?: string;
6
+ }
7
+ export declare function isTypeScriptAssetPath(filePath: string): boolean;
8
+ export declare function toPosixPath(filePath: string): string;
9
+ export declare function dirnamePosix(filePath: string): string;
10
+ export declare function joinPosix(...parts: string[]): string;
11
+ export declare function normalizePosixPath(filePath: string): string;
12
+ export declare function toOutputAssetRelPath(relPath: string, options?: OutputAssetPathOptions): string;
13
+ //#endregion
14
+ //#region packages/ts-util/src/base.d.ts
15
+ /**
16
+ * Generates a base class that maps interface properties
17
+ * to the class instance at runtime.
18
+ */
19
+ export declare function Base<T>(): new (data: T) => T & {
20
+ constructor: unknown;
21
+ };
22
+ //#endregion
23
+ //#region packages/ts-util/src/cache.d.ts
24
+ type CacheStats = {
25
+ hits: number;
26
+ misses: number;
27
+ staleHits: number;
28
+ evictions: number;
29
+ sets: number;
30
+ };
31
+ type CacheOptions<K, V> = {
32
+ name?: string;
33
+ maxEntries?: number;
34
+ maxWeight?: number;
35
+ defaultTtlMs?: number;
36
+ allowStale?: boolean;
37
+ sizeCalculator?: (value: V, key: K) => number;
38
+ onEvict?: (entry: {
39
+ key: K;
40
+ value: V;
41
+ reason: 'max' | 'expired';
42
+ }) => void;
43
+ now?: () => number;
44
+ };
45
+ export declare class Cache<K, V> {
46
+ private readonly name;
47
+ private readonly allowStale;
48
+ private readonly sizeCalculator;
49
+ private readonly onEvict?;
50
+ private readonly now;
51
+ private readonly entries;
52
+ private readonly inFlight;
53
+ private stats;
54
+ private maxEntries;
55
+ private maxWeight;
56
+ private defaultTtlMs;
57
+ private totalWeight;
58
+ constructor(options?: CacheOptions<K, V>);
59
+ get size(): number;
60
+ get weight(): number;
61
+ getStats(): CacheStats;
62
+ setLimits(options: {
63
+ maxEntries?: number;
64
+ maxWeight?: number;
65
+ }): void;
66
+ setDefaultTtl(ttlMs: number): void;
67
+ has(key: K): boolean;
68
+ peek(key: K): V | undefined;
69
+ get(key: K): V | undefined;
70
+ set(key: K, value: V, ttlMs?: number): V;
71
+ delete(key: K): boolean;
72
+ clear(): void;
73
+ getOrSetAsync(key: K, loader: () => Promise<V>, options?: {
74
+ ttlMs?: number;
75
+ }): Promise<V>;
76
+ pruneExpired(): void;
77
+ private isExpired;
78
+ private computeExpiry;
79
+ private expireEntry;
80
+ private evictIfNeeded;
81
+ private touch;
82
+ }
83
+ //#endregion
84
+ //#region packages/ts-util/src/clamp.d.ts
85
+ export declare function clamp(value: number, min: number, max: number): number;
86
+ //#endregion
87
+ //#region packages/ts-util/src/escapeHtml.d.ts
88
+ /**
89
+ * Escapes &, `<`, `>`, and " (optionally) in a string for safe insertion into HTML.
90
+ */
91
+ export declare function escapeHtml(str: string, escapeQuot?: boolean): string;
92
+ //#endregion
93
+ //#region packages/ts-util/src/logging.d.ts
94
+ interface LoggerLike {
95
+ error: (msg: string, meta?: Record<string, unknown> | Error) => void;
96
+ }
97
+ export declare function logError(logger: LoggerLike, error: unknown, msg: string): void;
98
+ //#endregion
99
+ //#region packages/ts-util/src/merge.d.ts
100
+ /**
101
+ * Deeply merge a base value `T` with any number of partial or full override objects.
102
+ *
103
+ * This function enforces that the base value is a plain object. It merges nested objects
104
+ * recursively and overwrites non-object values or object/primitive mismatches with later overrides.
105
+ *
106
+ * @typeParam T - base type
107
+ * @typeParam K - return type
108
+ * @param base - The base object to merge into. Must be a plain object.
109
+ * @param overrides - Partial or full override objects.
110
+ * Non-object values or undefined entries will simply overwrite or be skipped.
111
+ * @returns The merged result, typed as `K`.
112
+ * @throws If the `base` argument is not a plain object.
113
+ */
114
+ export declare function merge<T, K = T>(base: T, ...overrides: Array<unknown>): K;
115
+ //#endregion
116
+ //#region packages/ts-util/src/publicPath.d.ts
117
+ export declare function normalizeBasePath(value: string | undefined): string;
118
+ export declare function withBasePath(basePath: string, href: string): string;
119
+ export declare function stripBasePath(basePath: string, pathname: string): string;
120
+ //#endregion
121
+ //#region packages/ts-util/src/typeCheck.d.ts
122
+ export declare const isString: (value: unknown) => value is string;
123
+ export declare function isAbortError(err: unknown): boolean;
124
+ export declare function isFunction(func: unknown): func is (...args: unknown[]) => unknown;
125
+ export declare function isPlainObject(value: unknown): value is Record<string, unknown>;
126
+ export declare function isNumberOrBoolean(value: unknown): value is number | boolean;
127
+ export declare function isEmptyPlainObject(value: unknown): value is Record<string, never>;
128
+ export declare function isError(o: unknown): o is Error;
129
+ //#endregion
130
+ //#region packages/ts-util/src/types.d.ts
131
+ type DeepPartial<T> = T extends Array<infer U> ? Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : T extends object ? { [K in keyof T]?: DeepPartial<T[K]>; } : T;
132
+ //#endregion
133
+ //#region packages/ts-util/src/urlNormalizer.d.ts
134
+ type TrailingSlashMode = 'preserve' | 'always' | 'never';
135
+ interface NormalizeHrefOptions {
136
+ trailingSlash?: TrailingSlashMode;
137
+ }
138
+ export declare const urlNormalizer: {
139
+ isSpecialHref(href: string): boolean;
140
+ isExternalHref(href: string): boolean;
141
+ splitSuffix(href: string): {
142
+ base: string;
143
+ suffix: string;
144
+ };
145
+ normalizeHref(value: string | undefined, options?: NormalizeHrefOptions): string | undefined;
146
+ normalizeUrlPath(urlPath: string): string;
147
+ normalizeInternalPath(value: string | undefined): string | undefined;
148
+ hasPathExtension(value: string): boolean;
149
+ };
150
+ //#endregion
151
+ export type { CacheOptions, DeepPartial, LoggerLike };
152
+ //# sourceMappingURL=ts-util.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ts-util.d.mts","names":[],"sources":["../src/assetPath.ts","../src/base.ts","../src/cache.ts","../src/clamp.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;E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cAAa,2BACc,UAChB;EA4BX,iBAAgB;EAOhB,sBAAqB;EAiBrB,iBAAgB"}
@@ -0,0 +1,482 @@
1
+ /*! @purestack/ts-util v1.1.0 | (c) 2026 Ahmed Yasin Koculu | MIT License */
2
+
3
+ //#region packages/ts-util/src/assetPath.ts
4
+ const TS_EXT = ".ts";
5
+ const JS_EXT = ".js";
6
+ function isTypeScriptAssetPath(filePath) {
7
+ return getExtension(filePath).toLowerCase() === TS_EXT;
8
+ }
9
+ function toPosixPath(filePath) {
10
+ return filePath.replaceAll("\\", "/");
11
+ }
12
+ function dirnamePosix(filePath) {
13
+ const normalized = toPosixPath(filePath);
14
+ const slashIndex = normalized.lastIndexOf("/");
15
+ if (slashIndex < 0) return ".";
16
+ if (slashIndex === 0) return "/";
17
+ return normalized.slice(0, slashIndex);
18
+ }
19
+ function joinPosix(...parts) {
20
+ return normalizePosixPath(parts.filter((part) => part.length > 0).join("/"));
21
+ }
22
+ function normalizePosixPath(filePath) {
23
+ const normalized = toPosixPath(filePath);
24
+ const isAbsolute = normalized.startsWith("/");
25
+ const segments = normalized.split("/");
26
+ const result = [];
27
+ for (const segment of segments) {
28
+ if (segment.length === 0 || segment === ".") continue;
29
+ if (segment === "..") {
30
+ const last = result[result.length - 1];
31
+ if (last && last !== "..") result.pop();
32
+ else if (!isAbsolute) result.push("..");
33
+ continue;
34
+ }
35
+ result.push(segment);
36
+ }
37
+ if (isAbsolute) return result.length > 0 ? `/${result.join("/")}` : "/";
38
+ return result.length > 0 ? result.join("/") : ".";
39
+ }
40
+ function toOutputAssetRelPath(relPath, options = {}) {
41
+ if (!isTypeScriptAssetPath(relPath)) return relPath;
42
+ const { dir, name } = splitPath(toPosixPath(relPath));
43
+ const cacheKey = normalizeCacheKey(options.cacheKey);
44
+ const fileName = cacheKey ? `${name}.${cacheKey}${JS_EXT}` : `${name}${JS_EXT}`;
45
+ return dir.length > 0 ? `${dir}/${fileName}` : fileName;
46
+ }
47
+ function normalizeCacheKey(value) {
48
+ const normalized = value?.trim().replaceAll(/[^a-zA-Z0-9_-]/g, "");
49
+ return normalized && normalized.length > 0 ? normalized : void 0;
50
+ }
51
+ function getExtension(filePath) {
52
+ const normalized = filePath.replaceAll("\\", "/");
53
+ const fileName = normalized.slice(normalized.lastIndexOf("/") + 1);
54
+ const dotIndex = fileName.lastIndexOf(".");
55
+ if (dotIndex <= 0) return "";
56
+ return fileName.slice(dotIndex);
57
+ }
58
+ function splitPath(filePath) {
59
+ const slashIndex = filePath.lastIndexOf("/");
60
+ const dir = slashIndex >= 0 ? filePath.slice(0, slashIndex) : "";
61
+ const base = slashIndex >= 0 ? filePath.slice(slashIndex + 1) : filePath;
62
+ const ext = getExtension(base);
63
+ return {
64
+ dir,
65
+ name: ext.length > 0 ? base.slice(0, -ext.length) : base
66
+ };
67
+ }
68
+
69
+ //#endregion
70
+ //#region packages/ts-util/src/base.ts
71
+ /**
72
+ * Generates a base class that maps interface properties
73
+ * to the class instance at runtime.
74
+ */
75
+ function Base() {
76
+ return class {
77
+ constructor(opts) {
78
+ Object.assign(this, opts);
79
+ }
80
+ };
81
+ }
82
+
83
+ //#endregion
84
+ //#region packages/ts-util/src/cache.ts
85
+ var Cache = class {
86
+ name;
87
+ allowStale;
88
+ sizeCalculator;
89
+ onEvict;
90
+ now;
91
+ entries = /* @__PURE__ */ new Map();
92
+ inFlight = /* @__PURE__ */ new Map();
93
+ stats = {
94
+ hits: 0,
95
+ misses: 0,
96
+ staleHits: 0,
97
+ evictions: 0,
98
+ sets: 0
99
+ };
100
+ maxEntries;
101
+ maxWeight;
102
+ defaultTtlMs;
103
+ totalWeight = 0;
104
+ constructor(options = {}) {
105
+ this.name = options.name ?? "cache";
106
+ this.allowStale = options.allowStale ?? false;
107
+ this.sizeCalculator = options.sizeCalculator ?? (() => 1);
108
+ this.onEvict = options.onEvict;
109
+ this.now = options.now ?? Date.now;
110
+ this.maxEntries = Math.max(1, options.maxEntries ?? 1e3);
111
+ this.maxWeight = Math.max(1, options.maxWeight ?? Number.MAX_SAFE_INTEGER);
112
+ this.defaultTtlMs = Math.max(0, options.defaultTtlMs ?? 0);
113
+ }
114
+ get size() {
115
+ return this.entries.size;
116
+ }
117
+ get weight() {
118
+ return this.totalWeight;
119
+ }
120
+ getStats() {
121
+ return { ...this.stats };
122
+ }
123
+ setLimits(options) {
124
+ if (typeof options.maxEntries === "number") this.maxEntries = Math.max(1, options.maxEntries);
125
+ if (typeof options.maxWeight === "number") this.maxWeight = Math.max(1, options.maxWeight);
126
+ this.evictIfNeeded();
127
+ }
128
+ setDefaultTtl(ttlMs) {
129
+ this.defaultTtlMs = Math.max(0, ttlMs);
130
+ }
131
+ has(key) {
132
+ const entry = this.entries.get(key);
133
+ if (!entry) return false;
134
+ if (this.isExpired(entry)) {
135
+ this.expireEntry(key, entry);
136
+ return false;
137
+ }
138
+ return true;
139
+ }
140
+ peek(key) {
141
+ const entry = this.entries.get(key);
142
+ if (!entry) return void 0;
143
+ if (this.isExpired(entry)) {
144
+ this.expireEntry(key, entry);
145
+ return this.allowStale ? entry.value : void 0;
146
+ }
147
+ return entry.value;
148
+ }
149
+ get(key) {
150
+ const entry = this.entries.get(key);
151
+ if (!entry) {
152
+ this.stats.misses += 1;
153
+ return;
154
+ }
155
+ if (this.isExpired(entry)) {
156
+ this.expireEntry(key, entry);
157
+ if (this.allowStale) {
158
+ this.stats.staleHits += 1;
159
+ return entry.value;
160
+ }
161
+ this.stats.misses += 1;
162
+ return;
163
+ }
164
+ entry.lastAccess = this.now();
165
+ this.touch(key, entry);
166
+ this.stats.hits += 1;
167
+ return entry.value;
168
+ }
169
+ set(key, value, ttlMs) {
170
+ const weight = Math.max(1, this.sizeCalculator(value, key));
171
+ const expiresAt = this.computeExpiry(ttlMs);
172
+ const now = this.now();
173
+ const existing = this.entries.get(key);
174
+ if (existing) {
175
+ this.totalWeight -= existing.weight;
176
+ this.entries.delete(key);
177
+ }
178
+ this.entries.set(key, {
179
+ value,
180
+ expiresAt,
181
+ weight,
182
+ lastAccess: now
183
+ });
184
+ this.totalWeight += weight;
185
+ this.stats.sets += 1;
186
+ this.evictIfNeeded();
187
+ return value;
188
+ }
189
+ delete(key) {
190
+ const entry = this.entries.get(key);
191
+ if (!entry) return false;
192
+ this.totalWeight -= entry.weight;
193
+ this.entries.delete(key);
194
+ return true;
195
+ }
196
+ clear() {
197
+ this.entries.clear();
198
+ this.inFlight.clear();
199
+ this.totalWeight = 0;
200
+ }
201
+ async getOrSetAsync(key, loader, options) {
202
+ const cached = this.get(key);
203
+ if (cached !== void 0) return cached;
204
+ const existing = this.inFlight.get(key);
205
+ if (existing) return existing;
206
+ const promise = loader().then((value) => {
207
+ this.set(key, value, options?.ttlMs);
208
+ this.inFlight.delete(key);
209
+ return value;
210
+ }).catch((error) => {
211
+ this.inFlight.delete(key);
212
+ throw error;
213
+ });
214
+ this.inFlight.set(key, promise);
215
+ return promise;
216
+ }
217
+ pruneExpired() {
218
+ for (const [key, entry] of this.entries) if (this.isExpired(entry)) this.expireEntry(key, entry);
219
+ }
220
+ isExpired(entry) {
221
+ if (entry.expiresAt === null) return false;
222
+ return this.now() >= entry.expiresAt;
223
+ }
224
+ computeExpiry(ttlMs) {
225
+ const ttl = typeof ttlMs === "number" ? ttlMs : this.defaultTtlMs;
226
+ if (ttl <= 0) return null;
227
+ return this.now() + ttl;
228
+ }
229
+ expireEntry(key, entry) {
230
+ this.totalWeight -= entry.weight;
231
+ this.entries.delete(key);
232
+ this.stats.evictions += 1;
233
+ this.onEvict?.({
234
+ key,
235
+ value: entry.value,
236
+ reason: "expired"
237
+ });
238
+ }
239
+ evictIfNeeded() {
240
+ while (this.entries.size > this.maxEntries || this.totalWeight > this.maxWeight) {
241
+ const firstKey = this.entries.keys().next().value;
242
+ if (firstKey === void 0) break;
243
+ const entry = this.entries.get(firstKey);
244
+ if (!entry) {
245
+ this.entries.delete(firstKey);
246
+ continue;
247
+ }
248
+ this.totalWeight -= entry.weight;
249
+ this.entries.delete(firstKey);
250
+ this.stats.evictions += 1;
251
+ this.onEvict?.({
252
+ key: firstKey,
253
+ value: entry.value,
254
+ reason: "max"
255
+ });
256
+ }
257
+ }
258
+ touch(key, entry) {
259
+ this.entries.delete(key);
260
+ this.entries.set(key, entry);
261
+ }
262
+ };
263
+
264
+ //#endregion
265
+ //#region packages/ts-util/src/clamp.ts
266
+ function clamp(value, min, max) {
267
+ return Math.max(min, Math.min(max, value));
268
+ }
269
+
270
+ //#endregion
271
+ //#region packages/ts-util/src/escapeHtml.ts
272
+ /**
273
+ * Escapes &, `<`, `>`, and " (optionally) in a string for safe insertion into HTML.
274
+ */
275
+ function escapeHtml(str, escapeQuot = false) {
276
+ let result = "";
277
+ let last = 0;
278
+ for (let i = 0; i < str.length; i++) {
279
+ let replacement;
280
+ switch (str.charCodeAt(i)) {
281
+ case 38:
282
+ replacement = "&amp;";
283
+ break;
284
+ case 60:
285
+ replacement = "&lt;";
286
+ break;
287
+ case 62:
288
+ replacement = "&gt;";
289
+ break;
290
+ case 34: if (escapeQuot) replacement = "&quot;";
291
+ }
292
+ if (replacement) {
293
+ if (last < i) result += str.slice(last, i);
294
+ result += replacement;
295
+ last = i + 1;
296
+ }
297
+ }
298
+ if (last === 0) return str;
299
+ if (last < str.length) result += str.slice(last);
300
+ return result;
301
+ }
302
+
303
+ //#endregion
304
+ //#region packages/ts-util/src/logging.ts
305
+ function logError(logger, error, msg) {
306
+ if (error instanceof Error) {
307
+ logger.error(msg, error);
308
+ return;
309
+ }
310
+ const errorText = String(error);
311
+ logger.error(msg, { error: errorText });
312
+ }
313
+
314
+ //#endregion
315
+ //#region packages/ts-util/src/typeCheck.ts
316
+ const isString = (value) => typeof value === "string" || value instanceof String;
317
+ function isAbortError(err) {
318
+ const obj = err;
319
+ return obj != null && typeof obj.name === "string" && obj.name === "AbortError";
320
+ }
321
+ function isFunction(func) {
322
+ return typeof func === "function";
323
+ }
324
+ function isPlainObject(value) {
325
+ if (typeof value !== "object" || value === null) return false;
326
+ const proto = Object.getPrototypeOf(value);
327
+ return proto === Object.prototype || proto === null;
328
+ }
329
+ function isNumberOrBoolean(value) {
330
+ return typeof value === "number" || typeof value === "boolean";
331
+ }
332
+ function isEmptyPlainObject(value) {
333
+ if (!isPlainObject(value)) return false;
334
+ for (const _ in value) return false;
335
+ return true;
336
+ }
337
+ function isError(o) {
338
+ return o instanceof Error;
339
+ }
340
+
341
+ //#endregion
342
+ //#region packages/ts-util/src/merge.ts
343
+ /**
344
+ * Recursively merges multiple objects into one plain object.
345
+ *
346
+ * Each provided object is iterated in order. If a key exists in multiple objects:
347
+ * - If both the accumulated result and the new value are plain objects, they are merged recursively.
348
+ * - Otherwise, the new value overwrites the previous one.
349
+ *
350
+ * @param objects - A list of objects (or undefined) to merge.
351
+ * @returns A new object containing all merged keys.
352
+ */
353
+ function mergeInternal(...objects) {
354
+ const result = {};
355
+ for (const obj of objects) {
356
+ if (!isPlainObject(obj)) continue;
357
+ for (const key of Object.keys(obj)) {
358
+ const src = obj[key];
359
+ const prev = result[key];
360
+ if (isPlainObject(prev) && isPlainObject(src)) result[key] = mergeInternal(prev, src);
361
+ else result[key] = src;
362
+ }
363
+ }
364
+ return result;
365
+ }
366
+ /**
367
+ * Deeply merge a base value `T` with any number of partial or full override objects.
368
+ *
369
+ * This function enforces that the base value is a plain object. It merges nested objects
370
+ * recursively and overwrites non-object values or object/primitive mismatches with later overrides.
371
+ *
372
+ * @typeParam T - base type
373
+ * @typeParam K - return type
374
+ * @param base - The base object to merge into. Must be a plain object.
375
+ * @param overrides - Partial or full override objects.
376
+ * Non-object values or undefined entries will simply overwrite or be skipped.
377
+ * @returns The merged result, typed as `K`.
378
+ * @throws If the `base` argument is not a plain object.
379
+ */
380
+ function merge(base, ...overrides) {
381
+ if (!isPlainObject(base)) throw new Error(`merge is not possible with ${String(base)}`);
382
+ return mergeInternal(base, ...overrides);
383
+ }
384
+
385
+ //#endregion
386
+ //#region packages/ts-util/src/urlNormalizer.ts
387
+ const urlNormalizer = {
388
+ isSpecialHref(href) {
389
+ return href.startsWith("#") || href.startsWith("?") || href.startsWith("//") || /^[a-zA-Z][a-zA-Z+.-]*:/.test(href);
390
+ },
391
+ isExternalHref(href) {
392
+ return urlNormalizer.isSpecialHref(href) || href.startsWith("../");
393
+ },
394
+ splitSuffix(href) {
395
+ const hashIndex = href.indexOf("#");
396
+ const queryIndex = href.indexOf("?");
397
+ const index = hashIndex === -1 ? queryIndex : queryIndex === -1 ? hashIndex : Math.min(hashIndex, queryIndex);
398
+ if (index === -1) return {
399
+ base: href,
400
+ suffix: ""
401
+ };
402
+ return {
403
+ base: href.slice(0, index),
404
+ suffix: href.slice(index)
405
+ };
406
+ },
407
+ normalizeHref(value, options = {}) {
408
+ if (typeof value !== "string") return void 0;
409
+ const trimmed = value.trim();
410
+ if (!trimmed) return void 0;
411
+ if (urlNormalizer.isExternalHref(trimmed)) return trimmed;
412
+ const { base, suffix } = urlNormalizer.splitSuffix(trimmed);
413
+ const withoutDot = base.replace(/^\.\/+/, "");
414
+ const withLeadingSlash = withoutDot.startsWith("/") ? withoutDot : `/${withoutDot}`;
415
+ const trailingSlash = options.trailingSlash ?? "preserve";
416
+ if (hasPathExtension(withLeadingSlash) || withLeadingSlash === "/") return `${withLeadingSlash}${suffix}`;
417
+ if (trailingSlash === "always" && !withLeadingSlash.endsWith("/")) return `${withLeadingSlash}/${suffix}`;
418
+ if (trailingSlash === "never" && withLeadingSlash.endsWith("/")) return `${withLeadingSlash.slice(0, -1)}${suffix}`;
419
+ return `${withLeadingSlash}${suffix}`;
420
+ },
421
+ normalizeUrlPath(urlPath) {
422
+ return urlNormalizer.normalizeHref(urlPath, { trailingSlash: "always" }) || "/";
423
+ },
424
+ normalizeInternalPath(value) {
425
+ if (typeof value !== "string") return void 0;
426
+ const trimmed = value.trim();
427
+ if (!trimmed || urlNormalizer.isExternalHref(trimmed)) return void 0;
428
+ const { base } = urlNormalizer.splitSuffix(trimmed);
429
+ const normalizedBase = base.replaceAll("\\", "/").replace(/^\.\/+/, "").replace(/\/{2,}/g, "/");
430
+ if (!normalizedBase) return void 0;
431
+ if (urlNormalizer.isExternalHref(normalizedBase)) return void 0;
432
+ return urlNormalizer.normalizeHref(normalizedBase, { trailingSlash: "always" });
433
+ },
434
+ hasPathExtension(value) {
435
+ return hasPathExtension(value);
436
+ }
437
+ };
438
+ function hasPathExtension(value) {
439
+ const lastSlashIndex = value.lastIndexOf("/");
440
+ const segment = lastSlashIndex >= 0 ? value.slice(lastSlashIndex + 1) : value;
441
+ if (!segment || segment === "." || segment === "..") return false;
442
+ const dotIndex = segment.lastIndexOf(".");
443
+ return dotIndex > 0 && dotIndex < segment.length - 1;
444
+ }
445
+
446
+ //#endregion
447
+ //#region packages/ts-util/src/publicPath.ts
448
+ function normalizeBasePath(value) {
449
+ if (typeof value !== "string") return "";
450
+ const trimmed = value.trim();
451
+ if (!trimmed || trimmed === "/") return "";
452
+ if (urlNormalizer.isSpecialHref(trimmed)) throw new Error(`basePath must be a site path, not "${value}".`);
453
+ if (trimmed.includes("?") || trimmed.includes("#")) throw new Error(`basePath must not include query or hash parts: "${value}".`);
454
+ const normalizedSlashes = trimmed.replaceAll("\\", "/");
455
+ const withLeadingSlash = normalizedSlashes.startsWith("/") ? normalizedSlashes : `/${normalizedSlashes}`;
456
+ if (withLeadingSlash.split("/").filter(Boolean).some((segment) => segment === "." || segment === "..")) throw new Error(`basePath must stay inside the site root: "${value}".`);
457
+ const normalized = normalizePosixPath(withLeadingSlash).replace(/\/+$/, "");
458
+ return normalized === "/" ? "" : normalized;
459
+ }
460
+ function withBasePath(basePath, href) {
461
+ const normalizedBasePath = normalizeBasePath(basePath);
462
+ if (!normalizedBasePath) return href;
463
+ if (!href || href.trim() !== href) return href;
464
+ if (urlNormalizer.isSpecialHref(href)) return href;
465
+ if (!href.startsWith("/")) return href;
466
+ const { base, suffix } = urlNormalizer.splitSuffix(href);
467
+ if (base === normalizedBasePath) return `${base}${suffix}`;
468
+ if (base.startsWith(`${normalizedBasePath}/`)) return `${base}${suffix}`;
469
+ if (base === "/") return `${normalizedBasePath}/${suffix}`;
470
+ return `${normalizedBasePath}${base}${suffix}`;
471
+ }
472
+ function stripBasePath(basePath, pathname) {
473
+ const normalizedBasePath = normalizeBasePath(basePath);
474
+ if (!normalizedBasePath) return pathname;
475
+ if (pathname === normalizedBasePath) return "/";
476
+ if (pathname.startsWith(`${normalizedBasePath}/`)) return pathname.slice(normalizedBasePath.length) || "/";
477
+ return pathname;
478
+ }
479
+
480
+ //#endregion
481
+ export { Base, Cache, clamp, dirnamePosix, escapeHtml, isAbortError, isEmptyPlainObject, isError, isFunction, isNumberOrBoolean, isPlainObject, isString, isTypeScriptAssetPath, joinPosix, logError, merge, normalizeBasePath, normalizePosixPath, stripBasePath, toOutputAssetRelPath, toPosixPath, urlNormalizer, withBasePath };
482
+ //# sourceMappingURL=ts-util.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ts-util.mjs","names":[],"sources":["../src/assetPath.ts","../src/base.ts","../src/cache.ts","../src/clamp.ts","../src/escapeHtml.ts","../src/logging.ts","../src/typeCheck.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","/**\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 = '&amp;'\n break\n case 60:\n replacement = '&lt;'\n break\n case 62:\n replacement = '&gt;'\n break\n case 34:\n if (escapeQuot) replacement = '&quot;'\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","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/**\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,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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aAAa,oBAAoB,OAAO;CAC5C,IAAI,SAAS,WAAW,GAAG,mBAAmB,EAAE,GAC9C,OAAO,SAAS,MAAM,mBAAmB,MAAM,KAAK;CAEtD,OAAO;AACT"}
package/package.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "@purestack/ts-util",
3
+ "version": "1.1.0",
4
+ "packageManager": "yarn@4.9.2",
5
+ "module": "./dist/ts-util.mjs",
6
+ "types": "./dist/ts-util.d.mts",
7
+ "type": "module",
8
+ "sideEffects": false,
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/PureStackStudio/PureStack.git",
12
+ "directory": "packages/ts-util"
13
+ },
14
+ "homepage": "https://purestack.studio",
15
+ "bugs": {
16
+ "url": "https://github.com/PureStackStudio/PureStack/issues"
17
+ },
18
+ "publishConfig": {
19
+ "access": "public"
20
+ },
21
+ "exports": {
22
+ ".": {
23
+ "types": "./dist/ts-util.d.mts",
24
+ "import": "./dist/ts-util.mjs"
25
+ }
26
+ },
27
+ "license": "MIT",
28
+ "files": [
29
+ "dist/*.mjs",
30
+ "dist/*.mjs.map",
31
+ "dist/*.d.mts",
32
+ "dist/*.d.mts.map",
33
+ "README.md",
34
+ "LICENSE"
35
+ ],
36
+ "scripts": {
37
+ "build": "tsc",
38
+ "lint": "biome check ./src --formatter-enabled=false --write",
39
+ "test": "vitest"
40
+ }
41
+ }