stormcloud-video-player 0.7.44 → 0.7.45
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/stormcloud-vp.min.js +1 -1
- package/lib/index.cjs +18 -227
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +1 -9
- package/lib/index.d.ts +1 -9
- package/lib/index.js +19 -208
- package/lib/index.js.map +1 -1
- package/lib/ui/OverlayRenderer.cjs +2 -28
- package/lib/ui/OverlayRenderer.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.cjs +18 -207
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/utils/overlays.cjs +0 -200
- package/lib/utils/overlays.cjs.map +1 -1
- package/lib/utils/overlays.d.cts +1 -9
- package/package.json +1 -1
package/lib/utils/overlays.cjs
CHANGED
|
@@ -211,33 +211,18 @@ __export(overlays_exports, {
|
|
|
211
211
|
OVERLAY_API_BASE: function OVERLAY_API_BASE1() {
|
|
212
212
|
return OVERLAY_API_BASE;
|
|
213
213
|
},
|
|
214
|
-
SWIRL_HD_AUTHORING_HEIGHT: function SWIRL_HD_AUTHORING_HEIGHT1() {
|
|
215
|
-
return SWIRL_HD_AUTHORING_HEIGHT;
|
|
216
|
-
},
|
|
217
|
-
SWIRL_HD_AUTHORING_WIDTH: function SWIRL_HD_AUTHORING_WIDTH1() {
|
|
218
|
-
return SWIRL_HD_AUTHORING_WIDTH;
|
|
219
|
-
},
|
|
220
214
|
fetchProjectOverlays: function fetchProjectOverlays1() {
|
|
221
215
|
return fetchProjectOverlays;
|
|
222
216
|
},
|
|
223
|
-
inferSwirlOverlayCoordinateSpace: function inferSwirlOverlayCoordinateSpace1() {
|
|
224
|
-
return inferSwirlOverlayCoordinateSpace;
|
|
225
|
-
},
|
|
226
217
|
isOverlayActive: function isOverlayActive1() {
|
|
227
218
|
return isOverlayActive;
|
|
228
219
|
},
|
|
229
220
|
normalizeSwirlOverlay: function normalizeSwirlOverlay1() {
|
|
230
221
|
return normalizeSwirlOverlay;
|
|
231
222
|
},
|
|
232
|
-
overlayAuthoringDimensions: function overlayAuthoringDimensions1() {
|
|
233
|
-
return overlayAuthoringDimensions;
|
|
234
|
-
},
|
|
235
223
|
resolveImageUrl: function resolveImageUrl1() {
|
|
236
224
|
return resolveImageUrl;
|
|
237
225
|
},
|
|
238
|
-
swirlProjectHasNabDemoMixedWithOther: function swirlProjectHasNabDemoMixedWithOther1() {
|
|
239
|
-
return swirlProjectHasNabDemoMixedWithOther;
|
|
240
|
-
},
|
|
241
226
|
timeStringToSeconds: function timeStringToSeconds1() {
|
|
242
227
|
return timeStringToSeconds;
|
|
243
228
|
}
|
|
@@ -278,186 +263,6 @@ function isOverlayActive(overlay, currentTime) {
|
|
|
278
263
|
if (durationSec <= 0) return false;
|
|
279
264
|
return currentTime >= startSec && currentTime < startSec + durationSec;
|
|
280
265
|
}
|
|
281
|
-
var SWIRL_HD_AUTHORING_WIDTH = 1920;
|
|
282
|
-
var SWIRL_HD_AUTHORING_HEIGHT = 1080;
|
|
283
|
-
var NAB_DEMO_NAME_PREFIX = "NAB Demo \u2014 ";
|
|
284
|
-
function overlayAuthoringDimensions(overlay, decodeWidth, decodeHeight) {
|
|
285
|
-
if (overlay.name.startsWith(NAB_DEMO_NAME_PREFIX)) {
|
|
286
|
-
return {
|
|
287
|
-
width: SWIRL_HD_AUTHORING_WIDTH,
|
|
288
|
-
height: SWIRL_HD_AUTHORING_HEIGHT
|
|
289
|
-
};
|
|
290
|
-
}
|
|
291
|
-
if (!decodeWidth || !decodeHeight) {
|
|
292
|
-
return {
|
|
293
|
-
width: decodeWidth || SWIRL_HD_AUTHORING_WIDTH,
|
|
294
|
-
height: decodeHeight || SWIRL_HD_AUTHORING_HEIGHT
|
|
295
|
-
};
|
|
296
|
-
}
|
|
297
|
-
return {
|
|
298
|
-
width: decodeWidth,
|
|
299
|
-
height: decodeHeight
|
|
300
|
-
};
|
|
301
|
-
}
|
|
302
|
-
function overlayExtents(overlays) {
|
|
303
|
-
var maxR = 0;
|
|
304
|
-
var maxB = 0;
|
|
305
|
-
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
306
|
-
try {
|
|
307
|
-
for(var _iterator = overlays[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
308
|
-
var o = _step.value;
|
|
309
|
-
if (!o.visible) continue;
|
|
310
|
-
maxR = Math.max(maxR, o.x + o.width);
|
|
311
|
-
maxB = Math.max(maxB, o.y + o.height);
|
|
312
|
-
}
|
|
313
|
-
} catch (err) {
|
|
314
|
-
_didIteratorError = true;
|
|
315
|
-
_iteratorError = err;
|
|
316
|
-
} finally{
|
|
317
|
-
try {
|
|
318
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
319
|
-
_iterator.return();
|
|
320
|
-
}
|
|
321
|
-
} finally{
|
|
322
|
-
if (_didIteratorError) {
|
|
323
|
-
throw _iteratorError;
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
return {
|
|
328
|
-
maxR: maxR,
|
|
329
|
-
maxB: maxB
|
|
330
|
-
};
|
|
331
|
-
}
|
|
332
|
-
function swirlProjectHasNabDemoMixedWithOther(overlays) {
|
|
333
|
-
var hasNab = false;
|
|
334
|
-
var hasOther = false;
|
|
335
|
-
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
336
|
-
try {
|
|
337
|
-
for(var _iterator = overlays[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
338
|
-
var o = _step.value;
|
|
339
|
-
if (!o.visible) continue;
|
|
340
|
-
if (o.name.startsWith(NAB_DEMO_NAME_PREFIX)) hasNab = true;
|
|
341
|
-
else hasOther = true;
|
|
342
|
-
}
|
|
343
|
-
} catch (err) {
|
|
344
|
-
_didIteratorError = true;
|
|
345
|
-
_iteratorError = err;
|
|
346
|
-
} finally{
|
|
347
|
-
try {
|
|
348
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
349
|
-
_iterator.return();
|
|
350
|
-
}
|
|
351
|
-
} finally{
|
|
352
|
-
if (_didIteratorError) {
|
|
353
|
-
throw _iteratorError;
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
return hasNab && hasOther;
|
|
358
|
-
}
|
|
359
|
-
var STANDARD_16_9_LADDER = [
|
|
360
|
-
{
|
|
361
|
-
width: 384,
|
|
362
|
-
height: 216
|
|
363
|
-
},
|
|
364
|
-
{
|
|
365
|
-
width: 640,
|
|
366
|
-
height: 360
|
|
367
|
-
},
|
|
368
|
-
{
|
|
369
|
-
width: 854,
|
|
370
|
-
height: 480
|
|
371
|
-
},
|
|
372
|
-
{
|
|
373
|
-
width: 1280,
|
|
374
|
-
height: 720
|
|
375
|
-
},
|
|
376
|
-
{
|
|
377
|
-
width: 1920,
|
|
378
|
-
height: 1080
|
|
379
|
-
},
|
|
380
|
-
{
|
|
381
|
-
width: 2560,
|
|
382
|
-
height: 1440
|
|
383
|
-
},
|
|
384
|
-
{
|
|
385
|
-
width: 3840,
|
|
386
|
-
height: 2160
|
|
387
|
-
}
|
|
388
|
-
];
|
|
389
|
-
function smallestLadderRungContaining(maxR, maxB, eps) {
|
|
390
|
-
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
391
|
-
try {
|
|
392
|
-
for(var _iterator = STANDARD_16_9_LADDER[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
393
|
-
var rung = _step.value;
|
|
394
|
-
if (maxR <= rung.width + eps && maxB <= rung.height + eps) return rung;
|
|
395
|
-
}
|
|
396
|
-
} catch (err) {
|
|
397
|
-
_didIteratorError = true;
|
|
398
|
-
_iteratorError = err;
|
|
399
|
-
} finally{
|
|
400
|
-
try {
|
|
401
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
402
|
-
_iterator.return();
|
|
403
|
-
}
|
|
404
|
-
} finally{
|
|
405
|
-
if (_didIteratorError) {
|
|
406
|
-
throw _iteratorError;
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
return null;
|
|
411
|
-
}
|
|
412
|
-
function inferSwirlOverlayCoordinateSpace(overlays, videoWidth, videoHeight) {
|
|
413
|
-
if (!videoWidth || !videoHeight) {
|
|
414
|
-
return {
|
|
415
|
-
width: videoWidth || SWIRL_HD_AUTHORING_WIDTH,
|
|
416
|
-
height: videoHeight || SWIRL_HD_AUTHORING_HEIGHT
|
|
417
|
-
};
|
|
418
|
-
}
|
|
419
|
-
if (!overlays.length) {
|
|
420
|
-
return {
|
|
421
|
-
width: videoWidth,
|
|
422
|
-
height: videoHeight
|
|
423
|
-
};
|
|
424
|
-
}
|
|
425
|
-
var _overlayExtents = overlayExtents(overlays), maxR = _overlayExtents.maxR, maxB = _overlayExtents.maxB;
|
|
426
|
-
var EPS = 1;
|
|
427
|
-
if (maxR <= 0 || maxB <= 0) {
|
|
428
|
-
return {
|
|
429
|
-
width: videoWidth,
|
|
430
|
-
height: videoHeight
|
|
431
|
-
};
|
|
432
|
-
}
|
|
433
|
-
var mixed = swirlProjectHasNabDemoMixedWithOther(overlays);
|
|
434
|
-
var fitsHdCanvas = maxR <= SWIRL_HD_AUTHORING_WIDTH + EPS && maxB <= SWIRL_HD_AUTHORING_HEIGHT + EPS;
|
|
435
|
-
var exceedsDecode = maxR > videoWidth + EPS || maxB > videoHeight + EPS;
|
|
436
|
-
var decodeLargerThanHd = videoWidth > SWIRL_HD_AUTHORING_WIDTH + EPS || videoHeight > SWIRL_HD_AUTHORING_HEIGHT + EPS;
|
|
437
|
-
if (fitsHdCanvas && (decodeLargerThanHd || exceedsDecode && !mixed)) {
|
|
438
|
-
return {
|
|
439
|
-
width: SWIRL_HD_AUTHORING_WIDTH,
|
|
440
|
-
height: SWIRL_HD_AUTHORING_HEIGHT
|
|
441
|
-
};
|
|
442
|
-
}
|
|
443
|
-
if (mixed) {
|
|
444
|
-
return {
|
|
445
|
-
width: videoWidth,
|
|
446
|
-
height: videoHeight
|
|
447
|
-
};
|
|
448
|
-
}
|
|
449
|
-
var rung = smallestLadderRungContaining(maxR, maxB, EPS);
|
|
450
|
-
if (rung && rung.width < videoWidth - EPS && rung.height < videoHeight - EPS) {
|
|
451
|
-
return {
|
|
452
|
-
width: rung.width,
|
|
453
|
-
height: rung.height
|
|
454
|
-
};
|
|
455
|
-
}
|
|
456
|
-
return {
|
|
457
|
-
width: videoWidth,
|
|
458
|
-
height: videoHeight
|
|
459
|
-
};
|
|
460
|
-
}
|
|
461
266
|
function normalizeScrollerConfig(raw) {
|
|
462
267
|
if (!raw || (typeof raw === "undefined" ? "undefined" : _type_of(raw)) !== "object") return void 0;
|
|
463
268
|
var r = raw;
|
|
@@ -540,15 +345,10 @@ function resolveImageUrl(imageUrl) {
|
|
|
540
345
|
// Annotate the CommonJS export names for ESM import in node:
|
|
541
346
|
0 && (module.exports = {
|
|
542
347
|
OVERLAY_API_BASE: OVERLAY_API_BASE,
|
|
543
|
-
SWIRL_HD_AUTHORING_HEIGHT: SWIRL_HD_AUTHORING_HEIGHT,
|
|
544
|
-
SWIRL_HD_AUTHORING_WIDTH: SWIRL_HD_AUTHORING_WIDTH,
|
|
545
348
|
fetchProjectOverlays: fetchProjectOverlays,
|
|
546
|
-
inferSwirlOverlayCoordinateSpace: inferSwirlOverlayCoordinateSpace,
|
|
547
349
|
isOverlayActive: isOverlayActive,
|
|
548
350
|
normalizeSwirlOverlay: normalizeSwirlOverlay,
|
|
549
|
-
overlayAuthoringDimensions: overlayAuthoringDimensions,
|
|
550
351
|
resolveImageUrl: resolveImageUrl,
|
|
551
|
-
swirlProjectHasNabDemoMixedWithOther: swirlProjectHasNabDemoMixedWithOther,
|
|
552
352
|
timeStringToSeconds: timeStringToSeconds
|
|
553
353
|
});
|
|
554
354
|
//# sourceMappingURL=overlays.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/ubuntu24-new/Dev/stormcloud-vp/lib/utils/overlays.cjs","../../src/utils/overlays.ts"],"names":["__defProp","Object","defineProperty","__getOwnPropDesc","getOwnPropertyDescriptor","__getOwnPropNames","getOwnPropertyNames","__hasOwnProp","prototype","hasOwnProperty","__export","target","all","name","get","enumerable","__copyProps","to","from","except","desc","key","call","__toCommonJS","mod","value","overlays_exports","OVERLAY_API_BASE","SWIRL_HD_AUTHORING_HEIGHT","SWIRL_HD_AUTHORING_WIDTH","fetchProjectOverlays","inferSwirlOverlayCoordinateSpace"],"mappings":"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","sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\n\n// src/utils/overlays.ts\nvar overlays_exports = {};\n__export(overlays_exports, {\n OVERLAY_API_BASE: () => OVERLAY_API_BASE,\n SWIRL_HD_AUTHORING_HEIGHT: () => SWIRL_HD_AUTHORING_HEIGHT,\n SWIRL_HD_AUTHORING_WIDTH: () => SWIRL_HD_AUTHORING_WIDTH,\n fetchProjectOverlays: () => fetchProjectOverlays,\n inferSwirlOverlayCoordinateSpace: () => inferSwirlOverlayCoordinateSpace,\n isOverlayActive: () => isOverlayActive,\n normalizeSwirlOverlay: () => normalizeSwirlOverlay,\n overlayAuthoringDimensions: () => overlayAuthoringDimensions,\n resolveImageUrl: () => resolveImageUrl,\n swirlProjectHasNabDemoMixedWithOther: () => swirlProjectHasNabDemoMixedWithOther,\n timeStringToSeconds: () => timeStringToSeconds\n});\nmodule.exports = __toCommonJS(overlays_exports);\nvar OVERLAY_API_BASE = \"https://adstorm.co/api-adstorm-dev\";\nfunction timeStringToSeconds(timeStr) {\n if (!timeStr) return 0;\n const parts = timeStr.split(\":\");\n if (parts.length >= 3) {\n const hours = parseInt(parts[0] ?? \"0\", 10) || 0;\n const minutes = parseInt(parts[1] ?? \"0\", 10) || 0;\n const secStr = parts[2] ?? \"0\";\n const dotIdx = secStr.indexOf(\".\");\n const seconds = parseInt(dotIdx >= 0 ? secStr.substring(0, dotIdx) : secStr, 10) || 0;\n const msFrag = dotIdx >= 0 ? secStr.substring(dotIdx + 1) : \"\";\n const ms = msFrag ? parseInt(msFrag.padEnd(3, \"0\").substring(0, 3), 10) || 0 : 0;\n return hours * 3600 + minutes * 60 + seconds + ms / 1e3;\n }\n if (parts.length === 2) {\n const minutes = parseInt(parts[0] ?? \"0\", 10) || 0;\n const secStr = parts[1] ?? \"0\";\n const dotIdx = secStr.indexOf(\".\");\n const seconds = parseInt(dotIdx >= 0 ? secStr.substring(0, dotIdx) : secStr, 10) || 0;\n const msFrag = dotIdx >= 0 ? secStr.substring(dotIdx + 1) : \"\";\n const ms = msFrag ? parseInt(msFrag.padEnd(3, \"0\").substring(0, 3), 10) || 0 : 0;\n return minutes * 60 + seconds + ms / 1e3;\n }\n const num = parseFloat(timeStr);\n return isFinite(num) ? Math.max(0, num) : 0;\n}\nfunction isOverlayActive(overlay, currentTime) {\n if (!overlay.visible) return false;\n const startSec = timeStringToSeconds(overlay.start_time);\n const durationSec = timeStringToSeconds(overlay.duration);\n if (durationSec <= 0) return false;\n return currentTime >= startSec && currentTime < startSec + durationSec;\n}\nvar SWIRL_HD_AUTHORING_WIDTH = 1920;\nvar SWIRL_HD_AUTHORING_HEIGHT = 1080;\nvar NAB_DEMO_NAME_PREFIX = \"NAB Demo \\u2014 \";\nfunction overlayAuthoringDimensions(overlay, decodeWidth, decodeHeight) {\n if (overlay.name.startsWith(NAB_DEMO_NAME_PREFIX)) {\n return {\n width: SWIRL_HD_AUTHORING_WIDTH,\n height: SWIRL_HD_AUTHORING_HEIGHT\n };\n }\n if (!decodeWidth || !decodeHeight) {\n return {\n width: decodeWidth || SWIRL_HD_AUTHORING_WIDTH,\n height: decodeHeight || SWIRL_HD_AUTHORING_HEIGHT\n };\n }\n return { width: decodeWidth, height: decodeHeight };\n}\nfunction overlayExtents(overlays) {\n let maxR = 0;\n let maxB = 0;\n for (const o of overlays) {\n if (!o.visible) continue;\n maxR = Math.max(maxR, o.x + o.width);\n maxB = Math.max(maxB, o.y + o.height);\n }\n return { maxR, maxB };\n}\nfunction swirlProjectHasNabDemoMixedWithOther(overlays) {\n let hasNab = false;\n let hasOther = false;\n for (const o of overlays) {\n if (!o.visible) continue;\n if (o.name.startsWith(NAB_DEMO_NAME_PREFIX)) hasNab = true;\n else hasOther = true;\n }\n return hasNab && hasOther;\n}\nvar STANDARD_16_9_LADDER = [\n { width: 384, height: 216 },\n { width: 640, height: 360 },\n { width: 854, height: 480 },\n { width: 1280, height: 720 },\n { width: 1920, height: 1080 },\n { width: 2560, height: 1440 },\n { width: 3840, height: 2160 }\n];\nfunction smallestLadderRungContaining(maxR, maxB, eps) {\n for (const rung of STANDARD_16_9_LADDER) {\n if (maxR <= rung.width + eps && maxB <= rung.height + eps) return rung;\n }\n return null;\n}\nfunction inferSwirlOverlayCoordinateSpace(overlays, videoWidth, videoHeight) {\n if (!videoWidth || !videoHeight) {\n return {\n width: videoWidth || SWIRL_HD_AUTHORING_WIDTH,\n height: videoHeight || SWIRL_HD_AUTHORING_HEIGHT\n };\n }\n if (!overlays.length) {\n return { width: videoWidth, height: videoHeight };\n }\n const { maxR, maxB } = overlayExtents(overlays);\n const EPS = 1;\n if (maxR <= 0 || maxB <= 0) {\n return { width: videoWidth, height: videoHeight };\n }\n const mixed = swirlProjectHasNabDemoMixedWithOther(overlays);\n const fitsHdCanvas = maxR <= SWIRL_HD_AUTHORING_WIDTH + EPS && maxB <= SWIRL_HD_AUTHORING_HEIGHT + EPS;\n const exceedsDecode = maxR > videoWidth + EPS || maxB > videoHeight + EPS;\n const decodeLargerThanHd = videoWidth > SWIRL_HD_AUTHORING_WIDTH + EPS || videoHeight > SWIRL_HD_AUTHORING_HEIGHT + EPS;\n if (fitsHdCanvas && (decodeLargerThanHd || exceedsDecode && !mixed)) {\n return {\n width: SWIRL_HD_AUTHORING_WIDTH,\n height: SWIRL_HD_AUTHORING_HEIGHT\n };\n }\n if (mixed) {\n return { width: videoWidth, height: videoHeight };\n }\n const rung = smallestLadderRungContaining(maxR, maxB, EPS);\n if (rung && rung.width < videoWidth - EPS && rung.height < videoHeight - EPS) {\n return { width: rung.width, height: rung.height };\n }\n return { width: videoWidth, height: videoHeight };\n}\nfunction normalizeScrollerConfig(raw) {\n if (!raw || typeof raw !== \"object\") return void 0;\n const r = raw;\n const merged = { ...raw };\n if (merged.use_custom_text === void 0 && typeof r.useCustomText === \"boolean\") {\n merged.use_custom_text = r.useCustomText;\n }\n if ((merged.custom_text === void 0 || merged.custom_text === \"\") && typeof r.customText === \"string\") {\n merged.custom_text = r.customText;\n }\n if (!merged.rss_url && typeof r.rssUrl === \"string\") {\n merged.rss_url = r.rssUrl;\n }\n return merged;\n}\nfunction normalizeSwirlOverlay(raw) {\n const o = { ...raw };\n if (o.type === \"scroller\") {\n const sc = raw.scroller_config ?? raw.scrollerConfig;\n const normalized = normalizeScrollerConfig(sc);\n if (normalized) o.scroller_config = normalized;\n }\n return o;\n}\nasync function fetchProjectOverlays(projectId, apiBaseUrl = OVERLAY_API_BASE) {\n const base = apiBaseUrl.replace(/\\/$/, \"\");\n const response = await fetch(\n `${base}/adstorm/swirl/projects/${projectId}/overlays`\n );\n if (!response.ok) {\n throw new Error(\n `Failed to fetch overlays: ${response.status} ${response.statusText}`\n );\n }\n const data = await response.json();\n if (!Array.isArray(data)) return [];\n return data.map(\n (row) => normalizeSwirlOverlay(row)\n );\n}\nfunction resolveImageUrl(imageUrl, apiBaseUrl = OVERLAY_API_BASE) {\n if (!imageUrl) return \"\";\n if (imageUrl.startsWith(\"http://\") || imageUrl.startsWith(\"https://\")) {\n return imageUrl;\n }\n if (imageUrl.startsWith(\"/\")) {\n try {\n const url = new URL(apiBaseUrl);\n return `${url.origin}${imageUrl}`;\n } catch {\n return imageUrl;\n }\n }\n return `${apiBaseUrl}/${imageUrl}`;\n}\n// Annotate the CommonJS export names for ESM import in node:\n0 && (module.exports = {\n OVERLAY_API_BASE,\n SWIRL_HD_AUTHORING_HEIGHT,\n SWIRL_HD_AUTHORING_WIDTH,\n fetchProjectOverlays,\n inferSwirlOverlayCoordinateSpace,\n isOverlayActive,\n normalizeSwirlOverlay,\n overlayAuthoringDimensions,\n resolveImageUrl,\n swirlProjectHasNabDemoMixedWithOther,\n timeStringToSeconds\n});\n","export const OVERLAY_API_BASE = \"https://adstorm.co/api-adstorm-dev\";\n\nexport interface OverlayCoordinateSpace {\n width: number;\n height: number;\n}\n\nexport interface SwirlScrollerConfig {\n rss_url?: string;\n update_interval?: number;\n scroll_speed?: number;\n direction?: string;\n font_size?: number;\n font_family?: string;\n font_weight?: string;\n text_color?: string;\n background_color?: string;\n background_opacity?: number;\n border_color?: string;\n border_width?: number;\n border_radius?: number;\n padding?: number;\n margin?: number;\n show_title?: boolean;\n show_description?: boolean;\n show_timestamp?: boolean;\n show_author?: boolean;\n show_category?: boolean;\n max_items?: number;\n item_spacing?: number;\n fade_in_out?: boolean;\n fade_distance?: number;\n auto_refresh?: boolean;\n use_custom_text?: boolean;\n custom_text?: string;\n label?: string;\n label_line2?: string;\n label_color?: string;\n label_text_color?: string;\n accent_color?: string;\n show_accent_line?: boolean;\n separator_char?: string;\n preset?: string;\n}\n\nexport type SwirlOverlayType =\n | \"image\"\n | \"text\"\n | \"scroller\"\n | \"shape\"\n | \"score_bug\"\n | \"lower_third\"\n | \"qr_code\"\n | \"coming_up_next\"\n | \"contextual_trigger\"\n | \"odds_betting\"\n | \"breaking_news\"\n | \"countdown\";\n\nexport interface SwirlOverlay {\n id: number;\n project_id: number;\n name: string;\n type: SwirlOverlayType | string;\n visible: boolean;\n x: number;\n y: number;\n width: number;\n height: number;\n opacity: number;\n start_time: string;\n duration: string;\n content?: string;\n image_url?: string;\n scroller_config?: SwirlScrollerConfig;\n z_index: number;\n created_at?: string;\n updated_at?: string;\n}\n\nexport function timeStringToSeconds(timeStr: string): number {\n if (!timeStr) return 0;\n\n const parts = timeStr.split(\":\");\n\n if (parts.length >= 3) {\n const hours = parseInt(parts[0] ?? \"0\", 10) || 0;\n const minutes = parseInt(parts[1] ?? \"0\", 10) || 0;\n const secStr = parts[2] ?? \"0\";\n const dotIdx = secStr.indexOf(\".\");\n const seconds =\n parseInt(dotIdx >= 0 ? secStr.substring(0, dotIdx) : secStr, 10) || 0;\n const msFrag = dotIdx >= 0 ? secStr.substring(dotIdx + 1) : \"\";\n const ms = msFrag ? parseInt(msFrag.padEnd(3, \"0\").substring(0, 3), 10) || 0 : 0;\n return hours * 3600 + minutes * 60 + seconds + ms / 1000;\n }\n\n if (parts.length === 2) {\n const minutes = parseInt(parts[0] ?? \"0\", 10) || 0;\n const secStr = parts[1] ?? \"0\";\n const dotIdx = secStr.indexOf(\".\");\n const seconds =\n parseInt(dotIdx >= 0 ? secStr.substring(0, dotIdx) : secStr, 10) || 0;\n const msFrag = dotIdx >= 0 ? secStr.substring(dotIdx + 1) : \"\";\n const ms = msFrag ? parseInt(msFrag.padEnd(3, \"0\").substring(0, 3), 10) || 0 : 0;\n return minutes * 60 + seconds + ms / 1000;\n }\n\n const num = parseFloat(timeStr);\n return isFinite(num) ? Math.max(0, num) : 0;\n}\n\nexport function isOverlayActive(\n overlay: SwirlOverlay,\n currentTime: number\n): boolean {\n if (!overlay.visible) return false;\n const startSec = timeStringToSeconds(overlay.start_time);\n const durationSec = timeStringToSeconds(overlay.duration);\n if (durationSec <= 0) return false;\n return currentTime >= startSec && currentTime < startSec + durationSec;\n}\n\nexport const SWIRL_HD_AUTHORING_WIDTH = 1920;\nexport const SWIRL_HD_AUTHORING_HEIGHT = 1080;\n\nconst NAB_DEMO_NAME_PREFIX = \"NAB Demo — \";\n\nexport function overlayAuthoringDimensions(\n overlay: SwirlOverlay,\n decodeWidth: number,\n decodeHeight: number\n): { width: number; height: number } {\n if (overlay.name.startsWith(NAB_DEMO_NAME_PREFIX)) {\n return {\n width: SWIRL_HD_AUTHORING_WIDTH,\n height: SWIRL_HD_AUTHORING_HEIGHT,\n };\n }\n if (!decodeWidth || !decodeHeight) {\n return {\n width: decodeWidth || SWIRL_HD_AUTHORING_WIDTH,\n height: decodeHeight || SWIRL_HD_AUTHORING_HEIGHT,\n };\n }\n return { width: decodeWidth, height: decodeHeight };\n}\n\nfunction overlayExtents(overlays: SwirlOverlay[]): { maxR: number; maxB: number } {\n let maxR = 0;\n let maxB = 0;\n for (const o of overlays) {\n if (!o.visible) continue;\n maxR = Math.max(maxR, o.x + o.width);\n maxB = Math.max(maxB, o.y + o.height);\n }\n return { maxR, maxB };\n}\n\nexport function swirlProjectHasNabDemoMixedWithOther(overlays: SwirlOverlay[]): boolean {\n let hasNab = false;\n let hasOther = false;\n for (const o of overlays) {\n if (!o.visible) continue;\n if (o.name.startsWith(NAB_DEMO_NAME_PREFIX)) hasNab = true;\n else hasOther = true;\n }\n return hasNab && hasOther;\n}\n\nconst STANDARD_16_9_LADDER: ReadonlyArray<OverlayCoordinateSpace> = [\n { width: 384, height: 216 },\n { width: 640, height: 360 },\n { width: 854, height: 480 },\n { width: 1280, height: 720 },\n { width: 1920, height: 1080 },\n { width: 2560, height: 1440 },\n { width: 3840, height: 2160 },\n];\n\nfunction smallestLadderRungContaining(\n maxR: number,\n maxB: number,\n eps: number\n): OverlayCoordinateSpace | null {\n for (const rung of STANDARD_16_9_LADDER) {\n if (maxR <= rung.width + eps && maxB <= rung.height + eps) return rung;\n }\n return null;\n}\n\nexport function inferSwirlOverlayCoordinateSpace(\n overlays: SwirlOverlay[],\n videoWidth: number,\n videoHeight: number\n): OverlayCoordinateSpace {\n if (!videoWidth || !videoHeight) {\n return {\n width: videoWidth || SWIRL_HD_AUTHORING_WIDTH,\n height: videoHeight || SWIRL_HD_AUTHORING_HEIGHT,\n };\n }\n if (!overlays.length) {\n return { width: videoWidth, height: videoHeight };\n }\n\n const { maxR, maxB } = overlayExtents(overlays);\n const EPS = 1;\n\n if (maxR <= 0 || maxB <= 0) {\n return { width: videoWidth, height: videoHeight };\n }\n\n const mixed = swirlProjectHasNabDemoMixedWithOther(overlays);\n const fitsHdCanvas =\n maxR <= SWIRL_HD_AUTHORING_WIDTH + EPS &&\n maxB <= SWIRL_HD_AUTHORING_HEIGHT + EPS;\n const exceedsDecode = maxR > videoWidth + EPS || maxB > videoHeight + EPS;\n const decodeLargerThanHd =\n videoWidth > SWIRL_HD_AUTHORING_WIDTH + EPS ||\n videoHeight > SWIRL_HD_AUTHORING_HEIGHT + EPS;\n\n if (fitsHdCanvas && (decodeLargerThanHd || (exceedsDecode && !mixed))) {\n return {\n width: SWIRL_HD_AUTHORING_WIDTH,\n height: SWIRL_HD_AUTHORING_HEIGHT,\n };\n }\n\n if (mixed) {\n return { width: videoWidth, height: videoHeight };\n }\n\n const rung = smallestLadderRungContaining(maxR, maxB, EPS);\n if (rung && rung.width < videoWidth - EPS && rung.height < videoHeight - EPS) {\n return { width: rung.width, height: rung.height };\n }\n\n return { width: videoWidth, height: videoHeight };\n}\n\nfunction normalizeScrollerConfig(\n raw: SwirlScrollerConfig | Record<string, unknown> | undefined\n): SwirlScrollerConfig | undefined {\n if (!raw || typeof raw !== \"object\") return undefined;\n const r = raw as Record<string, unknown>;\n const merged: SwirlScrollerConfig = { ...(raw as SwirlScrollerConfig) };\n if (merged.use_custom_text === undefined && typeof r.useCustomText === \"boolean\") {\n merged.use_custom_text = r.useCustomText;\n }\n if ((merged.custom_text === undefined || merged.custom_text === \"\") && typeof r.customText === \"string\") {\n merged.custom_text = r.customText;\n }\n if (!merged.rss_url && typeof r.rssUrl === \"string\") {\n merged.rss_url = r.rssUrl;\n }\n return merged;\n}\n\nexport function normalizeSwirlOverlay(raw: SwirlOverlay & Record<string, unknown>): SwirlOverlay {\n const o = { ...raw };\n if (o.type === \"scroller\") {\n const sc = raw.scroller_config ?? (raw as Record<string, unknown>).scrollerConfig;\n const normalized = normalizeScrollerConfig(sc as SwirlScrollerConfig);\n if (normalized) o.scroller_config = normalized;\n }\n return o;\n}\n\nexport async function fetchProjectOverlays(\n projectId: number,\n apiBaseUrl: string = OVERLAY_API_BASE\n): Promise<SwirlOverlay[]> {\n const base = apiBaseUrl.replace(/\\/$/, \"\");\n const response = await fetch(\n `${base}/adstorm/swirl/projects/${projectId}/overlays`\n );\n if (!response.ok) {\n throw new Error(\n `Failed to fetch overlays: ${response.status} ${response.statusText}`\n );\n }\n const data = await response.json();\n if (!Array.isArray(data)) return [];\n return data.map((row: SwirlOverlay & Record<string, unknown>) =>\n normalizeSwirlOverlay(row)\n );\n}\n\nexport function resolveImageUrl(\n imageUrl: string,\n apiBaseUrl: string = OVERLAY_API_BASE\n): string {\n if (!imageUrl) return \"\";\n if (imageUrl.startsWith(\"http://\") || imageUrl.startsWith(\"https://\")) {\n return imageUrl;\n }\n if (imageUrl.startsWith(\"/\")) {\n try {\n const url = new URL(apiBaseUrl);\n return `${url.origin}${imageUrl}`;\n } catch {\n return imageUrl;\n }\n }\n return `${apiBaseUrl}/${imageUrl}`;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["/home/ubuntu24-new/Dev/stormcloud-vp/lib/utils/overlays.cjs"],"names":[],"mappings":"AAAA","sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\n\n// src/utils/overlays.ts\nvar overlays_exports = {};\n__export(overlays_exports, {\n OVERLAY_API_BASE: () => OVERLAY_API_BASE,\n fetchProjectOverlays: () => fetchProjectOverlays,\n isOverlayActive: () => isOverlayActive,\n normalizeSwirlOverlay: () => normalizeSwirlOverlay,\n resolveImageUrl: () => resolveImageUrl,\n timeStringToSeconds: () => timeStringToSeconds\n});\nmodule.exports = __toCommonJS(overlays_exports);\nvar OVERLAY_API_BASE = \"https://adstorm.co/api-adstorm-dev\";\nfunction timeStringToSeconds(timeStr) {\n if (!timeStr) return 0;\n const parts = timeStr.split(\":\");\n if (parts.length >= 3) {\n const hours = parseInt(parts[0] ?? \"0\", 10) || 0;\n const minutes = parseInt(parts[1] ?? \"0\", 10) || 0;\n const secStr = parts[2] ?? \"0\";\n const dotIdx = secStr.indexOf(\".\");\n const seconds = parseInt(dotIdx >= 0 ? secStr.substring(0, dotIdx) : secStr, 10) || 0;\n const msFrag = dotIdx >= 0 ? secStr.substring(dotIdx + 1) : \"\";\n const ms = msFrag ? parseInt(msFrag.padEnd(3, \"0\").substring(0, 3), 10) || 0 : 0;\n return hours * 3600 + minutes * 60 + seconds + ms / 1e3;\n }\n if (parts.length === 2) {\n const minutes = parseInt(parts[0] ?? \"0\", 10) || 0;\n const secStr = parts[1] ?? \"0\";\n const dotIdx = secStr.indexOf(\".\");\n const seconds = parseInt(dotIdx >= 0 ? secStr.substring(0, dotIdx) : secStr, 10) || 0;\n const msFrag = dotIdx >= 0 ? secStr.substring(dotIdx + 1) : \"\";\n const ms = msFrag ? parseInt(msFrag.padEnd(3, \"0\").substring(0, 3), 10) || 0 : 0;\n return minutes * 60 + seconds + ms / 1e3;\n }\n const num = parseFloat(timeStr);\n return isFinite(num) ? Math.max(0, num) : 0;\n}\nfunction isOverlayActive(overlay, currentTime) {\n if (!overlay.visible) return false;\n const startSec = timeStringToSeconds(overlay.start_time);\n const durationSec = timeStringToSeconds(overlay.duration);\n if (durationSec <= 0) return false;\n return currentTime >= startSec && currentTime < startSec + durationSec;\n}\nfunction normalizeScrollerConfig(raw) {\n if (!raw || typeof raw !== \"object\") return void 0;\n const r = raw;\n const merged = { ...raw };\n if (merged.use_custom_text === void 0 && typeof r.useCustomText === \"boolean\") {\n merged.use_custom_text = r.useCustomText;\n }\n if ((merged.custom_text === void 0 || merged.custom_text === \"\") && typeof r.customText === \"string\") {\n merged.custom_text = r.customText;\n }\n if (!merged.rss_url && typeof r.rssUrl === \"string\") {\n merged.rss_url = r.rssUrl;\n }\n return merged;\n}\nfunction normalizeSwirlOverlay(raw) {\n const o = { ...raw };\n if (o.type === \"scroller\") {\n const sc = raw.scroller_config ?? raw.scrollerConfig;\n const normalized = normalizeScrollerConfig(sc);\n if (normalized) o.scroller_config = normalized;\n }\n return o;\n}\nasync function fetchProjectOverlays(projectId, apiBaseUrl = OVERLAY_API_BASE) {\n const base = apiBaseUrl.replace(/\\/$/, \"\");\n const response = await fetch(\n `${base}/adstorm/swirl/projects/${projectId}/overlays`\n );\n if (!response.ok) {\n throw new Error(\n `Failed to fetch overlays: ${response.status} ${response.statusText}`\n );\n }\n const data = await response.json();\n if (!Array.isArray(data)) return [];\n return data.map(\n (row) => normalizeSwirlOverlay(row)\n );\n}\nfunction resolveImageUrl(imageUrl, apiBaseUrl = OVERLAY_API_BASE) {\n if (!imageUrl) return \"\";\n if (imageUrl.startsWith(\"http://\") || imageUrl.startsWith(\"https://\")) {\n return imageUrl;\n }\n if (imageUrl.startsWith(\"/\")) {\n try {\n const url = new URL(apiBaseUrl);\n return `${url.origin}${imageUrl}`;\n } catch {\n return imageUrl;\n }\n }\n return `${apiBaseUrl}/${imageUrl}`;\n}\n// Annotate the CommonJS export names for ESM import in node:\n0 && (module.exports = {\n OVERLAY_API_BASE,\n fetchProjectOverlays,\n isOverlayActive,\n normalizeSwirlOverlay,\n resolveImageUrl,\n timeStringToSeconds\n});\n"]}
|
package/lib/utils/overlays.d.cts
CHANGED
|
@@ -63,16 +63,8 @@ interface SwirlOverlay {
|
|
|
63
63
|
}
|
|
64
64
|
declare function timeStringToSeconds(timeStr: string): number;
|
|
65
65
|
declare function isOverlayActive(overlay: SwirlOverlay, currentTime: number): boolean;
|
|
66
|
-
declare const SWIRL_HD_AUTHORING_WIDTH = 1920;
|
|
67
|
-
declare const SWIRL_HD_AUTHORING_HEIGHT = 1080;
|
|
68
|
-
declare function overlayAuthoringDimensions(overlay: SwirlOverlay, decodeWidth: number, decodeHeight: number): {
|
|
69
|
-
width: number;
|
|
70
|
-
height: number;
|
|
71
|
-
};
|
|
72
|
-
declare function swirlProjectHasNabDemoMixedWithOther(overlays: SwirlOverlay[]): boolean;
|
|
73
|
-
declare function inferSwirlOverlayCoordinateSpace(overlays: SwirlOverlay[], videoWidth: number, videoHeight: number): OverlayCoordinateSpace;
|
|
74
66
|
declare function normalizeSwirlOverlay(raw: SwirlOverlay & Record<string, unknown>): SwirlOverlay;
|
|
75
67
|
declare function fetchProjectOverlays(projectId: number, apiBaseUrl?: string): Promise<SwirlOverlay[]>;
|
|
76
68
|
declare function resolveImageUrl(imageUrl: string, apiBaseUrl?: string): string;
|
|
77
69
|
|
|
78
|
-
export { OVERLAY_API_BASE, type OverlayCoordinateSpace,
|
|
70
|
+
export { OVERLAY_API_BASE, type OverlayCoordinateSpace, type SwirlOverlay, type SwirlOverlayType, type SwirlScrollerConfig, fetchProjectOverlays, isOverlayActive, normalizeSwirlOverlay, resolveImageUrl, timeStringToSeconds };
|