Release 1.5.8

This commit is contained in:
2026-07-25 18:24:12 +01:00
parent 04ddec50ad
commit d24c9c4035
6 changed files with 42 additions and 212 deletions
+4 -121
View File
@@ -120,124 +120,6 @@ function buildRegionInnerHtml(region, regionContent, baseUrl) {
return buildTextRegionMarkup(region, regionContent);
}
function buildSlideHtml(slide, baseUrl) {
const canvasSize = getCanvasSize(slide);
const template = slide && slide.template ? slide.template : null;
const backgroundColor = sanitizeTextColor(template && template.background_color ? template.background_color : '#111111', '#111111');
const backgroundImagePath = template && template.background_image_path ? resolveAssetUrl(baseUrl, template.background_image_path) : '';
if (!template) {
const mediaPath = String(slide && slide.media_path || '').trim();
const mediaUrl = resolveAssetUrl(baseUrl, mediaPath);
const kind = mediaKind(mediaPath || slide.media_type || '');
const mediaMarkup = kind === 'image' && mediaUrl
? '<img src="' + escapeHtml(mediaUrl) + '" alt="' + escapeHtml(slide.title || 'slide') + '" />'
: '';
return [
'<!doctype html>',
'<html>',
' <head>',
' <meta charset="utf-8" />',
' <meta name="viewport" content="width=' + canvasSize.width + ', initial-scale=1" />',
' <link rel="stylesheet" href="' + escapeHtml(baseUrl + '/assets/css/player.css') + '" />',
' <style>',
' html, body { margin: 0; width: ' + canvasSize.width + 'px; height: ' + canvasSize.height + 'px; overflow: hidden; background: #111111; }',
' body { display: flex; align-items: stretch; justify-content: stretch; }',
' .thumbnail-stage { position: relative; width: ' + canvasSize.width + 'px; height: ' + canvasSize.height + 'px; overflow: hidden; background: ' + escapeHtml(backgroundColor) + '; }',
' .thumbnail-stage .template-region.text { color: #fff; display: block; padding: 0; text-align: left; white-space: normal; word-break: break-word; line-height: 1.35; }',
' .thumbnail-stage .template-region.text .template-region-text-scale { display: block; transform-origin: top left; width: 100%; height: 100%; white-space: normal; word-break: break-word; line-height: 1.35; text-align: left; overflow: hidden; }',
' .thumbnail-stage .template-region.text .template-region-text-scale > * { margin: 0; }',
' .thumbnail-stage .template-region.text .template-region-text-scale > * + * { margin-top: 0.5em; }',
' .thumbnail-stage .template-region.text .template-region-text-scale ul,',
' .thumbnail-stage .template-region.text .template-region-text-scale ol { padding-left: 1.2em; }',
' .thumbnail-stage .template-region.image img { width: 100%; height: 100%; object-fit: contain; display: block; }',
' .thumbnail-stage .template-region.webpage iframe { width: 100%; height: 100%; border: 0; display: block; background: #fff; overflow: hidden; }',
' .thumbnail-stage .template-region.html iframe { width: 100%; height: 100%; border: 0; display: block; background: transparent; overflow: hidden; }',
' .thumbnail-stage .template-region.rtmp { background: #000; }',
' .thumbnail-stage .template-region.rtmp video { width: 100%; height: 100%; object-fit: contain; display: block; pointer-events: none; }',
' .thumbnail-stage .template-region-placeholder { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; color: rgba(255, 255, 255, 0.65); background: rgba(255, 255, 255, 0.06); font-size: 0.9rem; }',
' .thumbnail-stage .template-region-rtmp-placeholder { position: absolute; inset: 0; }',
' </style>',
' </head>',
' <body>',
' <div class="thumbnail-stage">',
mediaMarkup ? '<div class="slide"><div class="slide-canvas slide-media" style="width:' + canvasSize.width + 'px;height:' + canvasSize.height + 'px;">' + mediaMarkup + '</div></div>' : '',
' </div>',
' </body>',
'</html>'
].join('\n');
}
const regions = Array.isArray(template && template.regions) ? template.regions.slice().sort(function (left, right) {
return Number(left.z_index || 0) - Number(right.z_index || 0) || Number(left.id || 0) - Number(right.id || 0);
}) : [];
const regionsHtml = regions.map(function (region) {
const content = getRegionContent(slide, region);
const left = Math.max(0, Number(region.x || 0));
const top = Math.max(0, Number(region.y || 0));
const width = Math.max(1, Number(region.width || 1));
const height = Math.max(1, Number(region.height || 1));
const regionType = String(region.region_type || 'text').toLowerCase();
const pixelWidth = Math.max(1, Math.round(Number(region.width || 0) || 1));
const pixelHeight = Math.max(1, Math.round(Number(region.height || 0) || 1));
const innerHtml = regionType === 'text'
? buildTextRegionMarkup(Object.assign({}, region, { baseStyle: 'left:' + left + '%;top:' + top + '%;width:' + width + '%;height:' + height + '%;z-index:' + Number(region.z_index || 0) + ';', pixelWidth: pixelWidth, pixelHeight: pixelHeight }), content)
: buildRegionInnerHtml(Object.assign({}, region, { baseStyle: 'left:' + left + '%;top:' + top + '%;width:' + width + '%;height:' + height + '%;z-index:' + Number(region.z_index || 0) + ';', pixelWidth: pixelWidth, pixelHeight: pixelHeight }), content, baseUrl);
if (!innerHtml) {
return '';
}
return [
'<div class="template-region ' + escapeHtml(regionType) + '" style="left:' + left + '%;top:' + top + '%;width:' + width + '%;height:' + height + '%;z-index:' + Number(region.z_index || 0) + ';">',
innerHtml,
'</div>'
].join('');
}).join('');
return [
'<!doctype html>',
'<html>',
' <head>',
' <meta charset="utf-8" />',
' <meta name="viewport" content="width=' + canvasSize.width + ', initial-scale=1" />',
' <link rel="stylesheet" href="' + escapeHtml(baseUrl + '/assets/css/player.css') + '" />',
' <style>',
' html, body { margin: 0; width: ' + canvasSize.width + 'px; height: ' + canvasSize.height + 'px; overflow: hidden; background: #111111; }',
' body { display: flex; align-items: stretch; justify-content: stretch; }',
' .thumbnail-stage { position: relative; width: ' + canvasSize.width + 'px; height: ' + canvasSize.height + 'px; overflow: hidden; background: ' + escapeHtml(backgroundColor) + '; }',
' .thumbnail-stage .template-stage { position: relative; width: 100%; height: 100%; }',
' .thumbnail-stage .template-stage .template-background { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill; display: block; z-index: 0; }',
' .thumbnail-stage .template-region { position: absolute; overflow: hidden; box-sizing: border-box; }',
' .thumbnail-stage .template-region.image img { width: 100%; height: 100%; object-fit: contain; display: block; }',
' .thumbnail-stage .template-region.webpage iframe { width: 100%; height: 100%; border: 0; display: block; background: #fff; overflow: hidden; }',
' .thumbnail-stage .template-region.html iframe { width: 100%; height: 100%; border: 0; display: block; background: transparent; overflow: hidden; }',
' .thumbnail-stage .template-region.rtmp { background: #000; }',
' .thumbnail-stage .template-region.rtmp video { width: 100%; height: 100%; object-fit: contain; display: block; pointer-events: none; }',
' .thumbnail-stage .template-region.text { color: #fff; display: block; padding: 0; text-align: left; white-space: normal; word-break: break-word; line-height: 1.35; }',
' .thumbnail-stage .template-region.text .template-region-text-scale { display: block; transform-origin: top left; width: 100%; height: 100%; white-space: normal; word-break: break-word; line-height: 1.35; text-align: left; overflow: hidden; }',
' .thumbnail-stage .template-region.text .template-region-text-scale > * { margin: 0; }',
' .thumbnail-stage .template-region.text .template-region-text-scale > * + * { margin-top: 0.5em; }',
' .thumbnail-stage .template-region.text .template-region-text-scale ul,',
' .thumbnail-stage .template-region.text .template-region-text-scale ol { padding-left: 1.2em; }',
' .thumbnail-stage .template-region-rtmp-placeholder { position: absolute; inset: 0; }',
' .thumbnail-stage .template-region-placeholder { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; color: rgba(255, 255, 255, 0.65); background: rgba(255, 255, 255, 0.06); font-size: 0.9rem; }',
' </style>',
' </head>',
' <body>',
' <div class="thumbnail-stage">',
' <div class="template-stage" style="background-color:' + escapeHtml(backgroundColor) + ';">',
backgroundImagePath ? ' <img class="template-background" src="' + escapeHtml(backgroundImagePath) + '" alt="" />' : '',
regionsHtml,
' </div>',
' </div>',
' </body>',
'</html>'
].join('\n');
}
async function launchBrowser() {
let executablePath = SYSTEM_CHROMIUM_PATHS.find(function (candidate) {
return fs.existsSync(candidate);
@@ -312,12 +194,13 @@ async function captureSlideThumbnail(options) {
const previewUrl = baseUrl + previewPath;
await page.setExtraHTTPHeaders(createRequestAuthHeaders({
method: 'GET',
pathname: previewPath,
body: {}
pathname: previewPath
}));
await page.setViewport(PLAYER_VIEWPORT);
await page.goto(previewUrl, { waitUntil: 'domcontentloaded', timeout: 30000 });
await page.waitForSelector('.slide-canvas', { timeout: 30000, visible: true });
await page.waitForFunction(function () {
return Boolean(document.querySelector('.slide-canvas'));
}, { timeout: 30000 });
const canvas = await page.$('.slide-canvas');
if (!canvas) {
throw new Error('Player render did not produce a slide canvas.');