stormcloud-video-player 0.8.68 → 0.8.70
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 +2 -2
- package/lib/Player.cjs +30 -8
- package/lib/Player.cjs.map +1 -1
- package/lib/Player.d.cts +2 -1
- package/lib/StormcloudPlayer.cjs +6104 -5114
- package/lib/StormcloudPlayer.cjs.map +1 -1
- package/lib/StormcloudPlayer.d.cts +1 -0
- package/lib/index.cjs +6217 -5149
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +2 -1
- package/lib/index.d.ts +93 -2
- package/lib/index.js +6199 -5158
- package/lib/index.js.map +1 -1
- package/lib/player/AdBreakOrchestrator.cjs +669 -131
- package/lib/player/AdBreakOrchestrator.cjs.map +1 -1
- package/lib/player/AdBreakOrchestrator.d.cts +27 -3
- package/lib/player/EdgePodRequest.cjs +136 -0
- package/lib/player/EdgePodRequest.cjs.map +1 -0
- package/lib/player/EdgePodRequest.d.cts +14 -0
- package/lib/player/FloorLadder.cjs +578 -0
- package/lib/player/FloorLadder.cjs.map +1 -0
- package/lib/player/FloorLadder.d.cts +74 -0
- package/lib/player/StormcloudVideoPlayer.cjs +6104 -5114
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/player/StormcloudVideoPlayer.d.cts +13 -1
- package/lib/players/HlsPlayer.cjs +6104 -5114
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/index.cjs +6104 -5114
- package/lib/players/index.cjs.map +1 -1
- package/lib/props.cjs +30 -8
- package/lib/props.cjs.map +1 -1
- package/lib/props.d.cts +1 -0
- package/lib/sdk/hlsAdPlayer.cjs +120 -19
- package/lib/sdk/hlsAdPlayer.cjs.map +1 -1
- package/lib/types.d.cts +30 -2
- package/lib/ui/StormcloudVideoPlayer.cjs +6169 -5129
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.d.cts +1 -0
- package/lib/utils/vastMacros.cjs +4 -0
- package/lib/utils/vastMacros.cjs.map +1 -1
- package/lib/utils/vastMacros.d.cts +2 -1
- package/package.json +1 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { Scte35Marker, StormcloudVideoPlayerConfig, AdController } from '../types.cjs';
|
|
1
|
+
import { Scte35Marker, StormcloudVideoPlayerConfig, AdController, AdPosition } from '../types.cjs';
|
|
2
|
+
import { OpportunityFloor } from './FloorLadder.cjs';
|
|
2
3
|
import { AdTimingService } from './AdTimingService.cjs';
|
|
3
4
|
import { AdConfigManager } from './AdConfigManager.cjs';
|
|
4
5
|
import { Scte35CueManager } from './Scte35CueManager.cjs';
|
|
@@ -21,6 +22,9 @@ interface AdBreakOrchestratorHost {
|
|
|
21
22
|
recoverMediaError(): void;
|
|
22
23
|
requiresMediaPipelineResetAfterAds(): boolean;
|
|
23
24
|
generatePodVastUrl(baseUrl: string, breakDurationMs?: number): string;
|
|
25
|
+
/** Validated Edge pod URL, or undefined when Edge-first is disabled. */
|
|
26
|
+
getEdgePodBaseUrl(): string | undefined;
|
|
27
|
+
getFloorSnapshot(position: AdPosition): OpportunityFloor | undefined;
|
|
24
28
|
onAdClick(): void;
|
|
25
29
|
onAdInteraction(event: MouseEvent | TouchEvent): void;
|
|
26
30
|
}
|
|
@@ -45,6 +49,10 @@ declare class AdBreakOrchestrator {
|
|
|
45
49
|
private requestStartedAt;
|
|
46
50
|
private opportunityBreakKey;
|
|
47
51
|
private opportunityEpoch;
|
|
52
|
+
private opportunityFloor;
|
|
53
|
+
private currentPodSource;
|
|
54
|
+
private edgeExhaustedForBreak;
|
|
55
|
+
private edgeRequestsInBreak;
|
|
48
56
|
adPodQueue: string[];
|
|
49
57
|
private readonly defaultMinRemainingMsToRequestAd;
|
|
50
58
|
private readonly defaultMaxNoFillsPerBreak;
|
|
@@ -72,10 +80,23 @@ declare class AdBreakOrchestrator {
|
|
|
72
80
|
clearPendingAdBreak(): void;
|
|
73
81
|
isBreakActive(): boolean;
|
|
74
82
|
getSlotState(): AdSlotState;
|
|
75
|
-
beginVmapBreak(breakKey: string): void;
|
|
83
|
+
beginVmapBreak(breakKey: string, position: AdPosition): void;
|
|
76
84
|
handleAdStart(marker: Scte35Marker): Promise<void>;
|
|
77
85
|
private waitForBreakDuration;
|
|
78
86
|
private startOptimizedPod;
|
|
87
|
+
private resetEdgeStateForBreak;
|
|
88
|
+
private isLiveBreak;
|
|
89
|
+
private canRequestEdge;
|
|
90
|
+
private markEdgeExhausted;
|
|
91
|
+
/**
|
|
92
|
+
* Builds the next Edge request from the budget left right now, or marks Edge
|
|
93
|
+
* exhausted for this break. Synchronous on purpose: callers must reach the
|
|
94
|
+
* REQUESTING state in the same tick so a second completion event cannot race
|
|
95
|
+
* in a parallel request.
|
|
96
|
+
*/
|
|
97
|
+
private prepareEdgePodRequest;
|
|
98
|
+
private runEdgePod;
|
|
99
|
+
private continueAfterEdgeOutcome;
|
|
79
100
|
private setSlotState;
|
|
80
101
|
private isStale;
|
|
81
102
|
private getMinRemainingMsToRequestAd;
|
|
@@ -92,9 +113,12 @@ declare class AdBreakOrchestrator {
|
|
|
92
113
|
private recordRequestDiagnostic;
|
|
93
114
|
private finalizeRequestDiagnostics;
|
|
94
115
|
private withCurrentPodBudget;
|
|
116
|
+
private opportunityFloorFields;
|
|
117
|
+
private requestFloorFields;
|
|
118
|
+
private applyOpportunityFloor;
|
|
95
119
|
private countFunnelStage;
|
|
96
120
|
private logOrchestratorFunnel;
|
|
97
|
-
noteOpportunity(source: "scte35" | "vmap", breakKey: string | undefined): void;
|
|
121
|
+
noteOpportunity(source: "scte35" | "vmap", breakKey: string | undefined, position: AdPosition): void;
|
|
98
122
|
private beginFunnelRequest;
|
|
99
123
|
isAdLoadingWithoutPlayback(): boolean;
|
|
100
124
|
noteStopBeforeStart(reason: string): void;
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
function _type_of(obj) {
|
|
3
|
+
"@swc/helpers - typeof";
|
|
4
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
5
|
+
}
|
|
6
|
+
var __defProp = Object.defineProperty;
|
|
7
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
8
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __export = function __export(target, all) {
|
|
11
|
+
for(var name in all)__defProp(target, name, {
|
|
12
|
+
get: all[name],
|
|
13
|
+
enumerable: true
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
var __copyProps = function __copyProps(to, from, except, desc) {
|
|
17
|
+
if (from && (typeof from === "undefined" ? "undefined" : _type_of(from)) === "object" || typeof from === "function") {
|
|
18
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
19
|
+
try {
|
|
20
|
+
var _loop = function() {
|
|
21
|
+
var key = _step.value;
|
|
22
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
23
|
+
get: function get() {
|
|
24
|
+
return from[key];
|
|
25
|
+
},
|
|
26
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
for(var _iterator = __getOwnPropNames(from)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true)_loop();
|
|
30
|
+
} catch (err) {
|
|
31
|
+
_didIteratorError = true;
|
|
32
|
+
_iteratorError = err;
|
|
33
|
+
} finally{
|
|
34
|
+
try {
|
|
35
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
36
|
+
_iterator.return();
|
|
37
|
+
}
|
|
38
|
+
} finally{
|
|
39
|
+
if (_didIteratorError) {
|
|
40
|
+
throw _iteratorError;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return to;
|
|
46
|
+
};
|
|
47
|
+
var __toCommonJS = function __toCommonJS(mod) {
|
|
48
|
+
return __copyProps(__defProp({}, "__esModule", {
|
|
49
|
+
value: true
|
|
50
|
+
}), mod);
|
|
51
|
+
};
|
|
52
|
+
// src/player/EdgePodRequest.ts
|
|
53
|
+
var EdgePodRequest_exports = {};
|
|
54
|
+
__export(EdgePodRequest_exports, {
|
|
55
|
+
EDGE_POD_EXCEEDS_BUDGET: function EDGE_POD_EXCEEDS_BUDGET1() {
|
|
56
|
+
return EDGE_POD_EXCEEDS_BUDGET;
|
|
57
|
+
},
|
|
58
|
+
EDGE_POD_MAX_ADS: function EDGE_POD_MAX_ADS1() {
|
|
59
|
+
return EDGE_POD_MAX_ADS;
|
|
60
|
+
},
|
|
61
|
+
buildEdgePodUrl: function buildEdgePodUrl1() {
|
|
62
|
+
return buildEdgePodUrl;
|
|
63
|
+
},
|
|
64
|
+
classifyEdgeVastResponse: function classifyEdgeVastResponse1() {
|
|
65
|
+
return classifyEdgeVastResponse;
|
|
66
|
+
},
|
|
67
|
+
describeEdgeUrl: function describeEdgeUrl1() {
|
|
68
|
+
return describeEdgeUrl;
|
|
69
|
+
},
|
|
70
|
+
resolveEdgePodBaseUrl: function resolveEdgePodBaseUrl1() {
|
|
71
|
+
return resolveEdgePodBaseUrl;
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
module.exports = __toCommonJS(EdgePodRequest_exports);
|
|
75
|
+
var EDGE_POD_MAX_ADS = 10;
|
|
76
|
+
var EDGE_POD_EXCEEDS_BUDGET = "edge_pod_exceeds_budget";
|
|
77
|
+
function resolveEdgePodBaseUrl(config) {
|
|
78
|
+
var _config_edgePodUrl;
|
|
79
|
+
if (config.enableEdgePodRequest !== true) return void 0;
|
|
80
|
+
var raw = (_config_edgePodUrl = config.edgePodUrl) === null || _config_edgePodUrl === void 0 ? void 0 : _config_edgePodUrl.trim();
|
|
81
|
+
if (!raw) {
|
|
82
|
+
console.warn("[AdBreak][EDGE] enableEdgePodRequest is true but edgePodUrl is missing; using GAM only");
|
|
83
|
+
return void 0;
|
|
84
|
+
}
|
|
85
|
+
try {
|
|
86
|
+
var url = new URL(raw);
|
|
87
|
+
if (url.protocol !== "https:" && url.protocol !== "http:") {
|
|
88
|
+
throw new Error("unsupported protocol ".concat(url.protocol));
|
|
89
|
+
}
|
|
90
|
+
return url.toString();
|
|
91
|
+
} catch (unused) {
|
|
92
|
+
console.warn("[AdBreak][EDGE] edgePodUrl is not a valid http(s) URL; using GAM only");
|
|
93
|
+
return void 0;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
function buildEdgePodUrl(baseUrl, remainingMs, remainingAdLimit) {
|
|
97
|
+
var url = new URL(baseUrl);
|
|
98
|
+
var maxMs = Math.max(0, Math.floor(remainingMs));
|
|
99
|
+
var maxAds = Math.max(1, Math.min(EDGE_POD_MAX_ADS, Math.floor(remainingAdLimit)));
|
|
100
|
+
url.searchParams.set("pmxd", String(maxMs));
|
|
101
|
+
url.searchParams.set("pmad", String(maxAds));
|
|
102
|
+
url.searchParams.set("duration", String(Math.floor(maxMs / 1e3)));
|
|
103
|
+
url.searchParams.set("count", String(maxAds));
|
|
104
|
+
return url.toString();
|
|
105
|
+
}
|
|
106
|
+
function classifyEdgeVastResponse(result) {
|
|
107
|
+
var _ref;
|
|
108
|
+
var _result_error;
|
|
109
|
+
if (result.error == null) {
|
|
110
|
+
return result.podAdCount > 0 ? "fill" : "no_fill";
|
|
111
|
+
}
|
|
112
|
+
var message = (_ref = (_result_error = result.error) === null || _result_error === void 0 ? void 0 : _result_error.message) !== null && _ref !== void 0 ? _ref : String(result.error);
|
|
113
|
+
if (/no ads available|fill rejected|no media file|no ad loaded/i.test(message) || message.includes(EDGE_POD_EXCEEDS_BUDGET)) {
|
|
114
|
+
return "no_fill";
|
|
115
|
+
}
|
|
116
|
+
return "invalid";
|
|
117
|
+
}
|
|
118
|
+
function describeEdgeUrl(url) {
|
|
119
|
+
try {
|
|
120
|
+
var parsed = new URL(url);
|
|
121
|
+
return "".concat(parsed.origin).concat(parsed.pathname);
|
|
122
|
+
} catch (unused) {
|
|
123
|
+
var _url_split_;
|
|
124
|
+
return (_url_split_ = url.split("?")[0]) !== null && _url_split_ !== void 0 ? _url_split_ : "";
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
128
|
+
0 && (module.exports = {
|
|
129
|
+
EDGE_POD_EXCEEDS_BUDGET: EDGE_POD_EXCEEDS_BUDGET,
|
|
130
|
+
EDGE_POD_MAX_ADS: EDGE_POD_MAX_ADS,
|
|
131
|
+
buildEdgePodUrl: buildEdgePodUrl,
|
|
132
|
+
classifyEdgeVastResponse: classifyEdgeVastResponse,
|
|
133
|
+
describeEdgeUrl: describeEdgeUrl,
|
|
134
|
+
resolveEdgePodBaseUrl: resolveEdgePodBaseUrl
|
|
135
|
+
});
|
|
136
|
+
//# sourceMappingURL=EdgePodRequest.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["d:\\project\\stormcloud-vp\\lib\\player\\EdgePodRequest.cjs"],"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","EdgePodRequest_exports","EDGE_POD_EXCEEDS_BUDGET","EDGE_POD_MAX_ADS","buildEdgePodUrl","classifyEdgeVastResponse","describeEdgeUrl","resolveEdgePodBaseUrl","module","exports","config","enableEdgePodRequest","raw","edgePodUrl","trim","console","warn","url","URL","protocol","Error","toString","baseUrl","remainingMs","remainingAdLimit","maxMs","Math","max","floor","maxAds","min","searchParams","set","String","result","error","podAdCount","message","test","includes","parsed","origin","pathname","split"],"mappings":"AAAA;;;;;AACA,IAAIA,YAAYC,OAAOC,cAAc;AACrC,IAAIC,mBA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AAZD,oCAAAA,cAAcG,OAAO,uCAAIJ,OAAOC,OAAOC,KAAK;IAC5D,IAAI,6DAA6DG,IAAI,CAACD,YAAYA,QAAQE,QAAQ,CAACrC,0BAA0B;QAC3H,OAAO;IACT;IACA,OAAO;AACT;AACA,SAASI,gBAAgBW,GAAG;IAC1B,IAAI;QACF,IAAMuB,SAAS,IAAItB,IAAID;QACvB,OAAO,AAAC,GAAkBuB,OAAhBA,OAAOC,MAAM,EAAmB,OAAhBD,OAAOE,QAAQ;IAC3C,EAAE,eAAM;YACCzB;QAAP,QAAOA,cAAAA,IAAI0B,KAAK,CAAC,IAAI,CAAC,EAAE,cAAjB1B,yBAAAA,cAAqB;IAC9B;AACF;AACA,6DAA6D;AAC7D,KAAMT,CAAAA,OAAOC,OAAO,GAAG;IACrBP,yBAAAA;IACAC,kBAAAA;IACAC,iBAAAA;IACAC,0BAAAA;IACAC,iBAAAA;IACAC,uBAAAA;AACF,CAAA","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/player/EdgePodRequest.ts\nvar EdgePodRequest_exports = {};\n__export(EdgePodRequest_exports, {\n EDGE_POD_EXCEEDS_BUDGET: () => EDGE_POD_EXCEEDS_BUDGET,\n EDGE_POD_MAX_ADS: () => EDGE_POD_MAX_ADS,\n buildEdgePodUrl: () => buildEdgePodUrl,\n classifyEdgeVastResponse: () => classifyEdgeVastResponse,\n describeEdgeUrl: () => describeEdgeUrl,\n resolveEdgePodBaseUrl: () => resolveEdgePodBaseUrl\n});\nmodule.exports = __toCommonJS(EdgePodRequest_exports);\nvar EDGE_POD_MAX_ADS = 10;\nvar EDGE_POD_EXCEEDS_BUDGET = \"edge_pod_exceeds_budget\";\nfunction resolveEdgePodBaseUrl(config) {\n if (config.enableEdgePodRequest !== true) return void 0;\n const raw = config.edgePodUrl?.trim();\n if (!raw) {\n console.warn(\n \"[AdBreak][EDGE] enableEdgePodRequest is true but edgePodUrl is missing; using GAM only\"\n );\n return void 0;\n }\n try {\n const url = new URL(raw);\n if (url.protocol !== \"https:\" && url.protocol !== \"http:\") {\n throw new Error(`unsupported protocol ${url.protocol}`);\n }\n return url.toString();\n } catch {\n console.warn(\"[AdBreak][EDGE] edgePodUrl is not a valid http(s) URL; using GAM only\");\n return void 0;\n }\n}\nfunction buildEdgePodUrl(baseUrl, remainingMs, remainingAdLimit) {\n const url = new URL(baseUrl);\n const maxMs = Math.max(0, Math.floor(remainingMs));\n const maxAds = Math.max(1, Math.min(EDGE_POD_MAX_ADS, Math.floor(remainingAdLimit)));\n url.searchParams.set(\"pmxd\", String(maxMs));\n url.searchParams.set(\"pmad\", String(maxAds));\n url.searchParams.set(\"duration\", String(Math.floor(maxMs / 1e3)));\n url.searchParams.set(\"count\", String(maxAds));\n return url.toString();\n}\nfunction classifyEdgeVastResponse(result) {\n if (result.error == null) {\n return result.podAdCount > 0 ? \"fill\" : \"no_fill\";\n }\n const message = result.error?.message ?? String(result.error);\n if (/no ads available|fill rejected|no media file|no ad loaded/i.test(message) || message.includes(EDGE_POD_EXCEEDS_BUDGET)) {\n return \"no_fill\";\n }\n return \"invalid\";\n}\nfunction describeEdgeUrl(url) {\n try {\n const parsed = new URL(url);\n return `${parsed.origin}${parsed.pathname}`;\n } catch {\n return url.split(\"?\")[0] ?? \"\";\n }\n}\n// Annotate the CommonJS export names for ESM import in node:\n0 && (module.exports = {\n EDGE_POD_EXCEEDS_BUDGET,\n EDGE_POD_MAX_ADS,\n buildEdgePodUrl,\n classifyEdgeVastResponse,\n describeEdgeUrl,\n resolveEdgePodBaseUrl\n});\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { StormcloudVideoPlayerConfig } from '../types.cjs';
|
|
2
|
+
|
|
3
|
+
declare const EDGE_POD_MAX_ADS = 10;
|
|
4
|
+
type EdgePodClassification = "fill" | "no_fill" | "invalid";
|
|
5
|
+
declare const EDGE_POD_EXCEEDS_BUDGET = "edge_pod_exceeds_budget";
|
|
6
|
+
declare function resolveEdgePodBaseUrl(config: Pick<StormcloudVideoPlayerConfig, "enableEdgePodRequest" | "edgePodUrl">): string | undefined;
|
|
7
|
+
declare function buildEdgePodUrl(baseUrl: string, remainingMs: number, remainingAdLimit: number): string;
|
|
8
|
+
declare function classifyEdgeVastResponse(result: {
|
|
9
|
+
podAdCount: number;
|
|
10
|
+
error?: unknown;
|
|
11
|
+
}): EdgePodClassification;
|
|
12
|
+
declare function describeEdgeUrl(url: string): string;
|
|
13
|
+
|
|
14
|
+
export { EDGE_POD_EXCEEDS_BUDGET, EDGE_POD_MAX_ADS, type EdgePodClassification, buildEdgePodUrl, classifyEdgeVastResponse, describeEdgeUrl, resolveEdgePodBaseUrl };
|