stormcloud-video-player 0.6.6 → 0.7.0

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.
@@ -7,6 +7,7 @@ type StormcloudVideoPlayerProps = Omit<StormcloudVideoPlayerConfig, "videoElemen
7
7
  wrapperClassName?: string;
8
8
  wrapperStyle?: React.CSSProperties;
9
9
  licenseKey?: string;
10
+ swirlProjectId?: number;
10
11
  };
11
12
  declare const StormcloudVideoPlayerComponent: React.FC<StormcloudVideoPlayerProps>;
12
13
 
@@ -0,0 +1,286 @@
1
+ "use strict";
2
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
3
+ try {
4
+ var info = gen[key](arg);
5
+ var value = info.value;
6
+ } catch (error) {
7
+ reject(error);
8
+ return;
9
+ }
10
+ if (info.done) {
11
+ resolve(value);
12
+ } else {
13
+ Promise.resolve(value).then(_next, _throw);
14
+ }
15
+ }
16
+ function _async_to_generator(fn) {
17
+ return function() {
18
+ var self = this, args = arguments;
19
+ return new Promise(function(resolve, reject) {
20
+ var gen = fn.apply(self, args);
21
+ function _next(value) {
22
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
23
+ }
24
+ function _throw(err) {
25
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
26
+ }
27
+ _next(undefined);
28
+ });
29
+ };
30
+ }
31
+ function _type_of(obj) {
32
+ "@swc/helpers - typeof";
33
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
34
+ }
35
+ function _ts_generator(thisArg, body) {
36
+ var f, y, t, _ = {
37
+ label: 0,
38
+ sent: function() {
39
+ if (t[0] & 1) throw t[1];
40
+ return t[1];
41
+ },
42
+ trys: [],
43
+ ops: []
44
+ }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
45
+ return d(g, "next", {
46
+ value: verb(0)
47
+ }), d(g, "throw", {
48
+ value: verb(1)
49
+ }), d(g, "return", {
50
+ value: verb(2)
51
+ }), typeof Symbol === "function" && d(g, Symbol.iterator, {
52
+ value: function() {
53
+ return this;
54
+ }
55
+ }), g;
56
+ function verb(n) {
57
+ return function(v) {
58
+ return step([
59
+ n,
60
+ v
61
+ ]);
62
+ };
63
+ }
64
+ function step(op) {
65
+ if (f) throw new TypeError("Generator is already executing.");
66
+ while(g && (g = 0, op[0] && (_ = 0)), _)try {
67
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
68
+ if (y = 0, t) op = [
69
+ op[0] & 2,
70
+ t.value
71
+ ];
72
+ switch(op[0]){
73
+ case 0:
74
+ case 1:
75
+ t = op;
76
+ break;
77
+ case 4:
78
+ _.label++;
79
+ return {
80
+ value: op[1],
81
+ done: false
82
+ };
83
+ case 5:
84
+ _.label++;
85
+ y = op[1];
86
+ op = [
87
+ 0
88
+ ];
89
+ continue;
90
+ case 7:
91
+ op = _.ops.pop();
92
+ _.trys.pop();
93
+ continue;
94
+ default:
95
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
96
+ _ = 0;
97
+ continue;
98
+ }
99
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
100
+ _.label = op[1];
101
+ break;
102
+ }
103
+ if (op[0] === 6 && _.label < t[1]) {
104
+ _.label = t[1];
105
+ t = op;
106
+ break;
107
+ }
108
+ if (t && _.label < t[2]) {
109
+ _.label = t[2];
110
+ _.ops.push(op);
111
+ break;
112
+ }
113
+ if (t[2]) _.ops.pop();
114
+ _.trys.pop();
115
+ continue;
116
+ }
117
+ op = body.call(thisArg, _);
118
+ } catch (e) {
119
+ op = [
120
+ 6,
121
+ e
122
+ ];
123
+ y = 0;
124
+ } finally{
125
+ f = t = 0;
126
+ }
127
+ if (op[0] & 5) throw op[1];
128
+ return {
129
+ value: op[0] ? op[1] : void 0,
130
+ done: true
131
+ };
132
+ }
133
+ }
134
+ var __defProp = Object.defineProperty;
135
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
136
+ var __getOwnPropNames = Object.getOwnPropertyNames;
137
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
138
+ var __export = function __export(target, all) {
139
+ for(var name in all)__defProp(target, name, {
140
+ get: all[name],
141
+ enumerable: true
142
+ });
143
+ };
144
+ var __copyProps = function __copyProps(to, from, except, desc) {
145
+ if (from && (typeof from === "undefined" ? "undefined" : _type_of(from)) === "object" || typeof from === "function") {
146
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
147
+ try {
148
+ var _loop = function() {
149
+ var key = _step.value;
150
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
151
+ get: function get() {
152
+ return from[key];
153
+ },
154
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
155
+ });
156
+ };
157
+ for(var _iterator = __getOwnPropNames(from)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true)_loop();
158
+ } catch (err) {
159
+ _didIteratorError = true;
160
+ _iteratorError = err;
161
+ } finally{
162
+ try {
163
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
164
+ _iterator.return();
165
+ }
166
+ } finally{
167
+ if (_didIteratorError) {
168
+ throw _iteratorError;
169
+ }
170
+ }
171
+ }
172
+ }
173
+ return to;
174
+ };
175
+ var __toCommonJS = function __toCommonJS(mod) {
176
+ return __copyProps(__defProp({}, "__esModule", {
177
+ value: true
178
+ }), mod);
179
+ };
180
+ // src/utils/overlays.ts
181
+ var overlays_exports = {};
182
+ __export(overlays_exports, {
183
+ fetchProjectOverlays: function fetchProjectOverlays1() {
184
+ return fetchProjectOverlays;
185
+ },
186
+ isOverlayActive: function isOverlayActive1() {
187
+ return isOverlayActive;
188
+ },
189
+ resolveImageUrl: function resolveImageUrl1() {
190
+ return resolveImageUrl;
191
+ },
192
+ timeStringToSeconds: function timeStringToSeconds1() {
193
+ return timeStringToSeconds;
194
+ }
195
+ });
196
+ module.exports = __toCommonJS(overlays_exports);
197
+ var OVERLAY_API_BASE = "https://adstorm.co/api-adstorm-dev";
198
+ function timeStringToSeconds(timeStr) {
199
+ if (!timeStr) return 0;
200
+ var parts = timeStr.split(":");
201
+ if (parts.length >= 3) {
202
+ var _parts_, _parts_1, _parts_2;
203
+ var hours = parseInt((_parts_ = parts[0]) !== null && _parts_ !== void 0 ? _parts_ : "0", 10) || 0;
204
+ var minutes = parseInt((_parts_1 = parts[1]) !== null && _parts_1 !== void 0 ? _parts_1 : "0", 10) || 0;
205
+ var secStr = (_parts_2 = parts[2]) !== null && _parts_2 !== void 0 ? _parts_2 : "0";
206
+ var dotIdx = secStr.indexOf(".");
207
+ var seconds = parseInt(dotIdx >= 0 ? secStr.substring(0, dotIdx) : secStr, 10) || 0;
208
+ var msFrag = dotIdx >= 0 ? secStr.substring(dotIdx + 1) : "";
209
+ var ms = msFrag ? parseInt(msFrag.padEnd(3, "0").substring(0, 3), 10) || 0 : 0;
210
+ return hours * 3600 + minutes * 60 + seconds + ms / 1e3;
211
+ }
212
+ if (parts.length === 2) {
213
+ var _parts_3, _parts_4;
214
+ var minutes1 = parseInt((_parts_3 = parts[0]) !== null && _parts_3 !== void 0 ? _parts_3 : "0", 10) || 0;
215
+ var secStr1 = (_parts_4 = parts[1]) !== null && _parts_4 !== void 0 ? _parts_4 : "0";
216
+ var dotIdx1 = secStr1.indexOf(".");
217
+ var seconds1 = parseInt(dotIdx1 >= 0 ? secStr1.substring(0, dotIdx1) : secStr1, 10) || 0;
218
+ var msFrag1 = dotIdx1 >= 0 ? secStr1.substring(dotIdx1 + 1) : "";
219
+ var ms1 = msFrag1 ? parseInt(msFrag1.padEnd(3, "0").substring(0, 3), 10) || 0 : 0;
220
+ return minutes1 * 60 + seconds1 + ms1 / 1e3;
221
+ }
222
+ var num = parseFloat(timeStr);
223
+ return isFinite(num) ? Math.max(0, num) : 0;
224
+ }
225
+ function isOverlayActive(overlay, currentTime) {
226
+ if (!overlay.visible) return false;
227
+ var startSec = timeStringToSeconds(overlay.start_time);
228
+ var durationSec = timeStringToSeconds(overlay.duration);
229
+ if (durationSec <= 0) return false;
230
+ return currentTime >= startSec && currentTime < startSec + durationSec;
231
+ }
232
+ function fetchProjectOverlays(_0) {
233
+ return _async_to_generator(function(projectId) {
234
+ var apiBaseUrl, response, data;
235
+ var _arguments = arguments;
236
+ return _ts_generator(this, function(_state) {
237
+ switch(_state.label){
238
+ case 0:
239
+ apiBaseUrl = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : OVERLAY_API_BASE;
240
+ return [
241
+ 4,
242
+ fetch("".concat(apiBaseUrl, "/adstorm/swirl/projects/").concat(projectId, "/overlays"))
243
+ ];
244
+ case 1:
245
+ response = _state.sent();
246
+ if (!response.ok) {
247
+ throw new Error("Failed to fetch overlays: ".concat(response.status, " ").concat(response.statusText));
248
+ }
249
+ return [
250
+ 4,
251
+ response.json()
252
+ ];
253
+ case 2:
254
+ data = _state.sent();
255
+ return [
256
+ 2,
257
+ Array.isArray(data) ? data : []
258
+ ];
259
+ }
260
+ });
261
+ }).apply(this, arguments);
262
+ }
263
+ function resolveImageUrl(imageUrl) {
264
+ var apiBaseUrl = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : OVERLAY_API_BASE;
265
+ if (!imageUrl) return "";
266
+ if (imageUrl.startsWith("http://") || imageUrl.startsWith("https://")) {
267
+ return imageUrl;
268
+ }
269
+ if (imageUrl.startsWith("/")) {
270
+ try {
271
+ var url = new URL(apiBaseUrl);
272
+ return "".concat(url.origin).concat(imageUrl);
273
+ } catch (unused) {
274
+ return imageUrl;
275
+ }
276
+ }
277
+ return "".concat(apiBaseUrl, "/").concat(imageUrl);
278
+ }
279
+ // Annotate the CommonJS export names for ESM import in node:
280
+ 0 && (module.exports = {
281
+ fetchProjectOverlays: fetchProjectOverlays,
282
+ isOverlayActive: isOverlayActive,
283
+ resolveImageUrl: resolveImageUrl,
284
+ timeStringToSeconds: timeStringToSeconds
285
+ });
286
+ //# sourceMappingURL=overlays.cjs.map
@@ -0,0 +1 @@
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 fetchProjectOverlays: () => fetchProjectOverlays,\n isOverlayActive: () => isOverlayActive,\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}\nasync function fetchProjectOverlays(projectId, apiBaseUrl = OVERLAY_API_BASE) {\n const response = await fetch(\n `${apiBaseUrl}/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 return Array.isArray(data) ? data : [];\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 fetchProjectOverlays,\n isOverlayActive,\n resolveImageUrl,\n timeStringToSeconds\n});\n"]}
@@ -0,0 +1,59 @@
1
+ interface OverlayCoordinateSpace {
2
+ width: number;
3
+ height: number;
4
+ }
5
+ interface SwirlScrollerConfig {
6
+ rss_url?: string;
7
+ update_interval?: number;
8
+ scroll_speed?: number;
9
+ direction?: string;
10
+ font_size?: number;
11
+ font_family?: string;
12
+ font_weight?: string;
13
+ text_color?: string;
14
+ background_color?: string;
15
+ background_opacity?: number;
16
+ border_color?: string;
17
+ border_width?: number;
18
+ border_radius?: number;
19
+ padding?: number;
20
+ margin?: number;
21
+ show_title?: boolean;
22
+ show_description?: boolean;
23
+ show_timestamp?: boolean;
24
+ show_author?: boolean;
25
+ show_category?: boolean;
26
+ max_items?: number;
27
+ item_spacing?: number;
28
+ fade_in_out?: boolean;
29
+ fade_distance?: number;
30
+ auto_refresh?: boolean;
31
+ use_custom_text?: boolean;
32
+ custom_text?: string;
33
+ }
34
+ interface SwirlOverlay {
35
+ id: number;
36
+ project_id: number;
37
+ name: string;
38
+ type: "image" | "text" | "scroller" | string;
39
+ visible: boolean;
40
+ x: number;
41
+ y: number;
42
+ width: number;
43
+ height: number;
44
+ opacity: number;
45
+ start_time: string;
46
+ duration: string;
47
+ content?: string;
48
+ image_url?: string;
49
+ scroller_config?: SwirlScrollerConfig;
50
+ z_index: number;
51
+ created_at?: string;
52
+ updated_at?: string;
53
+ }
54
+ declare function timeStringToSeconds(timeStr: string): number;
55
+ declare function isOverlayActive(overlay: SwirlOverlay, currentTime: number): boolean;
56
+ declare function fetchProjectOverlays(projectId: number, apiBaseUrl?: string): Promise<SwirlOverlay[]>;
57
+ declare function resolveImageUrl(imageUrl: string, apiBaseUrl?: string): string;
58
+
59
+ export { type OverlayCoordinateSpace, type SwirlOverlay, type SwirlScrollerConfig, fetchProjectOverlays, isOverlayActive, resolveImageUrl, timeStringToSeconds };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stormcloud-video-player",
3
- "version": "0.6.6",
3
+ "version": "0.7.0",
4
4
  "main": "lib/index.js",
5
5
  "typings": "lib/index.d.ts",
6
6
  "scripts": {