Files
pulse-signage/src/web/lib/region-scripts.js
T
lzstealth 3f4f57020a
Publish Docker Image / build-and-push-existing-registry (./build/Dockerfile, web, pulse-signage-web) (push) Successful in 1m13s
Publish Docker Image / build-and-push-existing-registry (./build/Dockerfile.player, player, pulse-signage-player) (push) Successful in 31s
Release v2.10.3
2026-08-29 01:56:45 +01:00

38 lines
1.4 KiB
JavaScript

// Load and normalize browser region scripts for server-rendered player pages.
const fs = require('fs');
const path = require('path');
const PUBLIC_JS_ROOT = path.join(__dirname, '..', 'public', 'js');
const REGION_ROOT_DIR = path.join(PUBLIC_JS_ROOT, 'regions');
const REGION_TYPE_DIR = path.join(REGION_ROOT_DIR, 'type');
const REGION_CORE_SCRIPTS = ['js/shared/placeholder-utils.js', 'js/shared/placeholder-chips.js', 'js/shared/placeholder-info.js', 'js/shared/time-date-placeholders.js', 'js/regions/region-utils.js', 'js/regions/region-types.js'];
function withAssetVersion(scriptPath, assetVersion) {
if (!assetVersion) {
return scriptPath;
}
return scriptPath + (String(scriptPath).indexOf('?') === -1 ? '?v=' : '&v=') + encodeURIComponent(String(assetVersion));
}
function getRegionModuleScripts(assetVersion) {
if (!fs.existsSync(REGION_TYPE_DIR)) {
return [];
}
return fs.readdirSync(REGION_TYPE_DIR, { withFileTypes: true })
.filter((entry) => entry.isFile() && entry.name.toLowerCase().endsWith('.js'))
.map((entry) => withAssetVersion(`js/regions/type/${entry.name}`, assetVersion))
.sort((left, right) => left.localeCompare(right));
}
function getRegionEditorScripts(assetVersion) {
return REGION_CORE_SCRIPTS.map((script) => withAssetVersion(script, assetVersion)).concat(getRegionModuleScripts(assetVersion));
}
module.exports = {
getRegionModuleScripts,
getRegionEditorScripts,
withAssetVersion
};