stormcloud-video-player 0.7.42 → 0.7.43
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 +140 -56
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +140 -56
- package/lib/index.js.map +1 -1
- package/lib/ui/OverlayRenderer.cjs +140 -56
- package/lib/ui/OverlayRenderer.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.cjs +140 -56
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/utils/overlays.cjs +6 -17
- package/lib/utils/overlays.cjs.map +1 -1
- package/package.json +1 -1
package/lib/utils/overlays.cjs
CHANGED
|
@@ -282,27 +282,16 @@ var SWIRL_HD_AUTHORING_WIDTH = 1920;
|
|
|
282
282
|
var SWIRL_HD_AUTHORING_HEIGHT = 1080;
|
|
283
283
|
var NAB_DEMO_NAME_PREFIX = "NAB Demo \u2014 ";
|
|
284
284
|
function overlayAuthoringDimensions(overlay, decodeWidth, decodeHeight) {
|
|
285
|
-
if (
|
|
285
|
+
if (overlay.name.startsWith(NAB_DEMO_NAME_PREFIX)) {
|
|
286
286
|
return {
|
|
287
|
-
width:
|
|
288
|
-
height:
|
|
289
|
-
};
|
|
290
|
-
}
|
|
291
|
-
if (!overlay.visible) {
|
|
292
|
-
return {
|
|
293
|
-
width: decodeWidth,
|
|
294
|
-
height: decodeHeight
|
|
287
|
+
width: SWIRL_HD_AUTHORING_WIDTH,
|
|
288
|
+
height: SWIRL_HD_AUTHORING_HEIGHT
|
|
295
289
|
};
|
|
296
290
|
}
|
|
297
|
-
|
|
298
|
-
var extB = overlay.y + overlay.height;
|
|
299
|
-
var EPS = 2;
|
|
300
|
-
var exceedsDecode = extR > decodeWidth + EPS || extB > decodeHeight + EPS;
|
|
301
|
-
var isNabDemo = overlay.name.startsWith(NAB_DEMO_NAME_PREFIX);
|
|
302
|
-
if (exceedsDecode && isNabDemo) {
|
|
291
|
+
if (!decodeWidth || !decodeHeight) {
|
|
303
292
|
return {
|
|
304
|
-
width: SWIRL_HD_AUTHORING_WIDTH,
|
|
305
|
-
height: SWIRL_HD_AUTHORING_HEIGHT
|
|
293
|
+
width: decodeWidth || SWIRL_HD_AUTHORING_WIDTH,
|
|
294
|
+
height: decodeHeight || SWIRL_HD_AUTHORING_HEIGHT
|
|
306
295
|
};
|
|
307
296
|
}
|
|
308
297
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/ubuntu24-new/Dev/stormcloud-vp/lib/utils/overlays.cjs"],"names":["__defProp","Object","defineProperty","
|
|
1
|
+
{"version":3,"sources":["/home/ubuntu24-new/Dev/stormcloud-vp/lib/utils/overlays.cjs"],"names":["__hasOwnProp","__defProp","Object","defineProperty","__getOwnPropNames","getOwnPropertyNames","prototype","hasOwnProperty","__export","target","all","name","get","__copyProps","to","from","except","desc","key","call","enumerable","__getOwnPropDesc"],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wCAIIA;;;;;;;;;;;;;;wCAHAC,SAAYC,OAAOC,aAAc,OAAdA,EAAc,OAAA,MAAA,EAAA,KAAA,OAAA,SAAA,UAAA;oBAErC,EAAIC,oBAAoBF,OAAOG,mBAAmB;oBAC9CL;;wBAAeE,KAAOI,IAAAA,IAAAA,CAAS,CAACC,cAAc;;;oBAA9CP,OAAAA,IAAeE;oBACnB,EAAIM,EAAAA,CAAAA,MAAAA,EAAW,KAAA,CAAA,OAAA,KAACC,QAAQC;;;;sBACtB,IAAK;;wBAAA,GAAIC,EAAAA,GAAAA,GAAQD,IACfT,MAA0BW,IAAhBH,QAAQE,MAAM;mCAAOD,GAAG,CAACC,KAAK,aAAA;;;;;QAAmB;;AAC/D,SAAA,gBAAA,QAAA;QAAA,aAAA,iEAAA;IACA,EAAIE,EAAAA,CAAAA,UAAAA,CAAc,MAAA,eAACC,IAAIC,MAAMC,QAAQC;MACnC,EAAA,EAAIF,OAAAA,CAAQ,CAAA,OAAOA,CAAAA,CAAAA,cAAAA,SAAAA,UAAAA,CAAAA,CAAP,SAAOA,GAAAA,EAAG,MAAM,YAAY,OAAOA,SAAS,YAAY;gBAC7D,kCAAA,2BAAA;;;oBAAA,IAAIG,MAAJ;oBACH,EAAA,EAAI,CAAClB,CAAAA,IAAAA,QAAamB,IAAI,CAACL,IAAII,QAAQA,QAAQF,QACzCf,UAAUa,IAAII,KAAK;sBAAO,WAALN,KAAK,CAAA,EAALA,OAAK,KAALA;4CAAWG,IAAI,CAACG,IAAI;;wBAAEE,YAAY,CAAEH,CAAAA,OAAOI,iBAAiBN,MAAMG,IAAG,KAAMD,KAAKG,UAAU;kBAAC;;YAFpH,QAAK,YAAWhB,kBAAkBW,0BAA7B,SAAA,6BAAA,QAAA,yBAAA;;YAAA,CAAA,OAAA,GAAA;gCAAA;;;6CAAA,6BAAA;wDAAA;;;kDAAA;6CAAA","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}\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 const exceedsDecode = maxR > videoWidth + EPS || maxB > videoHeight + EPS;\n const fitsHdCanvas = maxR <= SWIRL_HD_AUTHORING_WIDTH + EPS && maxB <= SWIRL_HD_AUTHORING_HEIGHT + EPS;\n const mixed = swirlProjectHasNabDemoMixedWithOther(overlays);\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 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"]}
|