fix(build): migrate build tooling to tsbuild v4 and tsbundle config while updating sitemap integration

This commit is contained in:
2026-03-23 11:49:55 +00:00
parent d4c4e0971f
commit 292fb824fd
23 changed files with 3601 additions and 4401 deletions

View File

@@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@api.global/typedserver',
version: '8.4.4',
version: '8.4.5',
description: 'A TypeScript-based project for easy serving of static files with support for live reloading, compression, and typed requests.'
}

View File

@@ -1,5 +1,5 @@
import * as plugins from './plugins.js';
import * as interfaces from '../dist_ts_interfaces/index.js';
import * as interfaces from '../ts_interfaces/index.js';
import { DevToolsController } from './controllers/controller.devtools.js';
import { TypedRequestController } from './controllers/controller.typedrequest.js';
import { BuiltInRoutesController } from './controllers/controller.builtin.js';
@@ -1056,32 +1056,31 @@ export class TypedServer {
* Sitemap helper class
*/
class SitemapHelper {
private smartSitemap = new plugins.smartsitemap.SmartSitemap();
public urls: plugins.smartsitemap.IUrlInfo[] = [];
public urls: plugins.smartsitemap.ISitemapUrl[] = [];
constructor(domain?: string) {
if (domain) {
this.urls.push({
url: `https://${domain}/`,
timestamp: Date.now(),
frequency: 'daily',
loc: `https://${domain}/`,
lastmod: new Date(),
changefreq: 'daily',
});
}
}
async createSitemap(): Promise<string> {
return this.smartSitemap.createSitemapFromUrlInfoArray(this.urls);
return plugins.smartsitemap.SmartSitemap.create().addUrls(this.urls).toXml();
}
async createSitemapNews(articles: plugins.tsclass.content.IArticle[]): Promise<string> {
return this.smartSitemap.createSitemapNewsFromArticleArray(articles);
return plugins.smartsitemap.SmartSitemap.fromArticles(articles, { publicationName: 'News' }).toXml();
}
replaceUrls(urlsArg: plugins.smartsitemap.IUrlInfo[]) {
replaceUrls(urlsArg: plugins.smartsitemap.ISitemapUrl[]) {
this.urls = urlsArg;
}
addUrls(urlsArg: plugins.smartsitemap.IUrlInfo[]) {
addUrls(urlsArg: plugins.smartsitemap.ISitemapUrl[]) {
this.urls = this.urls.concat(urlsArg);
}
}

View File

@@ -17,7 +17,7 @@ export class BuiltInRoutesController {
feedMetadata?: plugins.smartfeed.IFeedOptions;
articleGetterFunction?: () => Promise<plugins.tsclass.content.IArticle[]>;
blockWaybackMachine?: boolean;
getSitemapUrls: () => plugins.smartsitemap.IUrlInfo[];
getSitemapUrls: () => plugins.smartsitemap.ISitemapUrl[];
};
constructor(options: typeof BuiltInRoutesController.prototype.options) {
@@ -64,9 +64,8 @@ export class BuiltInRoutesController {
throw new plugins.smartserve.RouteNotFoundError(ctx.path, ctx.method);
}
const smartsitemap = new plugins.smartsitemap.SmartSitemap();
const urls = this.options.getSitemapUrls();
const sitemapXml = await smartsitemap.createSitemapFromUrlInfoArray(urls);
const sitemapXml = plugins.smartsitemap.SmartSitemap.create().addUrls(urls).toXml();
return new Response(sitemapXml, {
status: 200,
@@ -80,9 +79,8 @@ export class BuiltInRoutesController {
throw new plugins.smartserve.RouteNotFoundError(ctx.path, ctx.method);
}
const smartsitemap = new plugins.smartsitemap.SmartSitemap();
const articles = await this.options.articleGetterFunction();
const sitemapNewsXml = await smartsitemap.createSitemapNewsFromArticleArray(articles);
const sitemapNewsXml = plugins.smartsitemap.SmartSitemap.fromArticles(articles, { publicationName: this.options.domain || 'News' }).toXml();
return new Response(sitemapNewsXml, {
status: 200,
@@ -127,7 +125,7 @@ export class BuiltInRoutesController {
@plugins.smartserve.Get('/sw-dash')
async getSwDash(ctx: plugins.smartserve.IRequestContext): Promise<Response> {
// Import shared HTML from interfaces
const { SW_DASH_HTML } = await import('../../dist_ts_interfaces/serviceworker.js');
const { SW_DASH_HTML } = await import('../../ts_interfaces/serviceworker.js');
return new Response(SW_DASH_HTML, {
status: 200,
headers: { 'Content-Type': 'text/html' },

View File

@@ -1,4 +1,4 @@
import * as interfaces from '../../dist_ts_interfaces/index.js';
import * as interfaces from '../../ts_interfaces/index.js';
import { type IServerOptions, type ISecurityHeaders, type IBundledContentItem, TypedServer } from '../classes.typedserver.js';
import * as plugins from '../plugins.js';