@xsolla/xui-b2c-video-player 0.217.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.
- package/README.md +3 -0
- package/native/index.d.mts +111 -0
- package/native/index.d.ts +111 -0
- package/native/index.js +545 -0
- package/native/index.js.map +1 -0
- package/native/index.mjs +528 -0
- package/native/index.mjs.map +1 -0
- package/package.json +63 -0
- package/web/index.d.mts +111 -0
- package/web/index.d.ts +111 -0
- package/web/index.js +584 -0
- package/web/index.js.map +1 -0
- package/web/index.mjs +553 -0
- package/web/index.mjs.map +1 -0
package/web/index.js
ADDED
|
@@ -0,0 +1,584 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/index.tsx
|
|
31
|
+
var index_exports = {};
|
|
32
|
+
__export(index_exports, {
|
|
33
|
+
VideoPlayer: () => VideoPlayer,
|
|
34
|
+
formatPlaybackTime: () => formatPlaybackTime
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(index_exports);
|
|
37
|
+
|
|
38
|
+
// src/VideoPlayer.tsx
|
|
39
|
+
var import_react3 = require("react");
|
|
40
|
+
|
|
41
|
+
// ../../foundation/primitives-web/src/Box.tsx
|
|
42
|
+
var import_react2 = __toESM(require("react"));
|
|
43
|
+
var import_styled_components = __toESM(require("styled-components"));
|
|
44
|
+
|
|
45
|
+
// ../../foundation/primitives-web/src/filterDOMProps.ts
|
|
46
|
+
var import_react = __toESM(require("react"));
|
|
47
|
+
|
|
48
|
+
// ../../../node_modules/@emotion/memoize/dist/memoize.esm.js
|
|
49
|
+
function memoize(fn) {
|
|
50
|
+
var cache = {};
|
|
51
|
+
return function(arg) {
|
|
52
|
+
if (cache[arg] === void 0) cache[arg] = fn(arg);
|
|
53
|
+
return cache[arg];
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
var memoize_esm_default = memoize;
|
|
57
|
+
|
|
58
|
+
// ../../../node_modules/@emotion/is-prop-valid/dist/is-prop-valid.esm.js
|
|
59
|
+
var reactPropsRegex = /^((children|dangerouslySetInnerHTML|key|ref|autoFocus|defaultValue|defaultChecked|innerHTML|suppressContentEditableWarning|suppressHydrationWarning|valueLink|accept|acceptCharset|accessKey|action|allow|allowUserMedia|allowPaymentRequest|allowFullScreen|allowTransparency|alt|async|autoComplete|autoPlay|capture|cellPadding|cellSpacing|challenge|charSet|checked|cite|classID|className|cols|colSpan|content|contentEditable|contextMenu|controls|controlsList|coords|crossOrigin|data|dateTime|decoding|default|defer|dir|disabled|disablePictureInPicture|download|draggable|encType|form|formAction|formEncType|formMethod|formNoValidate|formTarget|frameBorder|headers|height|hidden|high|href|hrefLang|htmlFor|httpEquiv|id|inputMode|integrity|is|keyParams|keyType|kind|label|lang|list|loading|loop|low|marginHeight|marginWidth|max|maxLength|media|mediaGroup|method|min|minLength|multiple|muted|name|nonce|noValidate|open|optimum|pattern|placeholder|playsInline|poster|preload|profile|radioGroup|readOnly|referrerPolicy|rel|required|reversed|role|rows|rowSpan|sandbox|scope|scoped|scrolling|seamless|selected|shape|size|sizes|slot|span|spellCheck|src|srcDoc|srcLang|srcSet|start|step|style|summary|tabIndex|target|title|type|useMap|value|width|wmode|wrap|about|datatype|inlist|prefix|property|resource|typeof|vocab|autoCapitalize|autoCorrect|autoSave|color|inert|itemProp|itemScope|itemType|itemID|itemRef|on|results|security|unselectable|accentHeight|accumulate|additive|alignmentBaseline|allowReorder|alphabetic|amplitude|arabicForm|ascent|attributeName|attributeType|autoReverse|azimuth|baseFrequency|baselineShift|baseProfile|bbox|begin|bias|by|calcMode|capHeight|clip|clipPathUnits|clipPath|clipRule|colorInterpolation|colorInterpolationFilters|colorProfile|colorRendering|contentScriptType|contentStyleType|cursor|cx|cy|d|decelerate|descent|diffuseConstant|direction|display|divisor|dominantBaseline|dur|dx|dy|edgeMode|elevation|enableBackground|end|exponent|externalResourcesRequired|fill|fillOpacity|fillRule|filter|filterRes|filterUnits|floodColor|floodOpacity|focusable|fontFamily|fontSize|fontSizeAdjust|fontStretch|fontStyle|fontVariant|fontWeight|format|from|fr|fx|fy|g1|g2|glyphName|glyphOrientationHorizontal|glyphOrientationVertical|glyphRef|gradientTransform|gradientUnits|hanging|horizAdvX|horizOriginX|ideographic|imageRendering|in|in2|intercept|k|k1|k2|k3|k4|kernelMatrix|kernelUnitLength|kerning|keyPoints|keySplines|keyTimes|lengthAdjust|letterSpacing|lightingColor|limitingConeAngle|local|markerEnd|markerMid|markerStart|markerHeight|markerUnits|markerWidth|mask|maskContentUnits|maskUnits|mathematical|mode|numOctaves|offset|opacity|operator|order|orient|orientation|origin|overflow|overlinePosition|overlineThickness|panose1|paintOrder|pathLength|patternContentUnits|patternTransform|patternUnits|pointerEvents|points|pointsAtX|pointsAtY|pointsAtZ|preserveAlpha|preserveAspectRatio|primitiveUnits|r|radius|refX|refY|renderingIntent|repeatCount|repeatDur|requiredExtensions|requiredFeatures|restart|result|rotate|rx|ry|scale|seed|shapeRendering|slope|spacing|specularConstant|specularExponent|speed|spreadMethod|startOffset|stdDeviation|stemh|stemv|stitchTiles|stopColor|stopOpacity|strikethroughPosition|strikethroughThickness|string|stroke|strokeDasharray|strokeDashoffset|strokeLinecap|strokeLinejoin|strokeMiterlimit|strokeOpacity|strokeWidth|surfaceScale|systemLanguage|tableValues|targetX|targetY|textAnchor|textDecoration|textRendering|textLength|to|transform|u1|u2|underlinePosition|underlineThickness|unicode|unicodeBidi|unicodeRange|unitsPerEm|vAlphabetic|vHanging|vIdeographic|vMathematical|values|vectorEffect|version|vertAdvY|vertOriginX|vertOriginY|viewBox|viewTarget|visibility|widths|wordSpacing|writingMode|x|xHeight|x1|x2|xChannelSelector|xlinkActuate|xlinkArcrole|xlinkHref|xlinkRole|xlinkShow|xlinkTitle|xlinkType|xmlBase|xmlns|xmlnsXlink|xmlLang|xmlSpace|y|y1|y2|yChannelSelector|z|zoomAndPan|for|class|autofocus)|(([Dd][Aa][Tt][Aa]|[Aa][Rr][Ii][Aa]|x)-.*))$/;
|
|
60
|
+
var index = memoize_esm_default(
|
|
61
|
+
function(prop) {
|
|
62
|
+
return reactPropsRegex.test(prop) || prop.charCodeAt(0) === 111 && prop.charCodeAt(1) === 110 && prop.charCodeAt(2) < 91;
|
|
63
|
+
}
|
|
64
|
+
/* Z+1 */
|
|
65
|
+
);
|
|
66
|
+
var is_prop_valid_esm_default = index;
|
|
67
|
+
|
|
68
|
+
// ../../foundation/primitives-web/src/filterDOMProps.ts
|
|
69
|
+
var ADDITIONAL_BLOCKED_PROPS = /* @__PURE__ */ new Set([
|
|
70
|
+
// RN-only event handlers (pass isPropValid's on* pattern)
|
|
71
|
+
"onPress",
|
|
72
|
+
"onChangeText",
|
|
73
|
+
"onLayout",
|
|
74
|
+
"onMoveShouldSetResponder",
|
|
75
|
+
"onResponderGrant",
|
|
76
|
+
"onResponderMove",
|
|
77
|
+
"onResponderRelease",
|
|
78
|
+
"onResponderTerminate",
|
|
79
|
+
// SVG attributes that pass isPropValid
|
|
80
|
+
"strokeWidth",
|
|
81
|
+
// CSS properties that pass isPropValid but are used as component props
|
|
82
|
+
"overflow",
|
|
83
|
+
"opacity",
|
|
84
|
+
"cursor",
|
|
85
|
+
"fontSize",
|
|
86
|
+
"fontWeight",
|
|
87
|
+
"fontFamily",
|
|
88
|
+
"textDecoration",
|
|
89
|
+
// Cross-platform layout prop that Text consumes as CSS, never as an
|
|
90
|
+
// attribute. Pinned explicitly because it is now spread into the styled
|
|
91
|
+
// component rather than destructured away before it can reach the DOM.
|
|
92
|
+
"numberOfLines"
|
|
93
|
+
]);
|
|
94
|
+
function shouldForwardProp(key) {
|
|
95
|
+
if (ADDITIONAL_BLOCKED_PROPS.has(key)) return false;
|
|
96
|
+
return is_prop_valid_esm_default(key);
|
|
97
|
+
}
|
|
98
|
+
function createFilteredElement(defaultTag) {
|
|
99
|
+
const Component = import_react.default.forwardRef(
|
|
100
|
+
({ children, elementType, ...props }, ref) => {
|
|
101
|
+
const Tag2 = elementType || defaultTag;
|
|
102
|
+
const htmlProps = {};
|
|
103
|
+
for (const key of Object.keys(props)) {
|
|
104
|
+
if (shouldForwardProp(key)) {
|
|
105
|
+
htmlProps[key] = props[key];
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return import_react.default.createElement(
|
|
109
|
+
Tag2,
|
|
110
|
+
{ ref, ...htmlProps },
|
|
111
|
+
children
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
);
|
|
115
|
+
Component.displayName = `Filtered(${defaultTag})`;
|
|
116
|
+
return Component;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// ../../foundation/primitives-web/src/Box.tsx
|
|
120
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
121
|
+
var FilteredDiv = createFilteredElement("div");
|
|
122
|
+
var StyledBox = (0, import_styled_components.default)(FilteredDiv)`
|
|
123
|
+
display: flex;
|
|
124
|
+
box-sizing: border-box;
|
|
125
|
+
background-color: ${(props) => props.backgroundColor || "transparent"};
|
|
126
|
+
border-color: ${(props) => props.borderColor || "transparent"};
|
|
127
|
+
border-width: ${(props) => typeof props.borderWidth === "number" ? `${props.borderWidth}px` : props.borderWidth || 0};
|
|
128
|
+
|
|
129
|
+
${(props) => props.borderBottomWidth !== void 0 && `
|
|
130
|
+
border-bottom-width: ${typeof props.borderBottomWidth === "number" ? `${props.borderBottomWidth}px` : props.borderBottomWidth};
|
|
131
|
+
border-bottom-color: ${props.borderBottomColor || props.borderColor || "transparent"};
|
|
132
|
+
border-bottom-style: solid;
|
|
133
|
+
`}
|
|
134
|
+
${(props) => props.borderTopWidth !== void 0 && `
|
|
135
|
+
border-top-width: ${typeof props.borderTopWidth === "number" ? `${props.borderTopWidth}px` : props.borderTopWidth};
|
|
136
|
+
border-top-color: ${props.borderTopColor || props.borderColor || "transparent"};
|
|
137
|
+
border-top-style: solid;
|
|
138
|
+
`}
|
|
139
|
+
${(props) => props.borderLeftWidth !== void 0 && `
|
|
140
|
+
border-left-width: ${typeof props.borderLeftWidth === "number" ? `${props.borderLeftWidth}px` : props.borderLeftWidth};
|
|
141
|
+
border-left-color: ${props.borderLeftColor || props.borderColor || "transparent"};
|
|
142
|
+
border-left-style: solid;
|
|
143
|
+
`}
|
|
144
|
+
${(props) => props.borderRightWidth !== void 0 && `
|
|
145
|
+
border-right-width: ${typeof props.borderRightWidth === "number" ? `${props.borderRightWidth}px` : props.borderRightWidth};
|
|
146
|
+
border-right-color: ${props.borderRightColor || props.borderColor || "transparent"};
|
|
147
|
+
border-right-style: solid;
|
|
148
|
+
`}
|
|
149
|
+
|
|
150
|
+
border-style: ${(props) => props.borderStyle || (props.borderWidth || props.borderBottomWidth || props.borderTopWidth || props.borderLeftWidth || props.borderRightWidth ? "solid" : "none")};
|
|
151
|
+
border-radius: ${(props) => typeof props.borderRadius === "number" ? `${props.borderRadius}px` : props.borderRadius || 0};
|
|
152
|
+
height: ${(props) => typeof props.height === "number" ? `${props.height}px` : props.height || "auto"};
|
|
153
|
+
width: ${(props) => typeof props.width === "number" ? `${props.width}px` : props.width || "auto"};
|
|
154
|
+
min-width: ${(props) => typeof props.minWidth === "number" ? `${props.minWidth}px` : props.minWidth || "auto"};
|
|
155
|
+
min-height: ${(props) => typeof props.minHeight === "number" ? `${props.minHeight}px` : props.minHeight || "auto"};
|
|
156
|
+
max-width: ${(props) => typeof props.maxWidth === "number" ? `${props.maxWidth}px` : props.maxWidth || "none"};
|
|
157
|
+
max-height: ${(props) => typeof props.maxHeight === "number" ? `${props.maxHeight}px` : props.maxHeight || "none"};
|
|
158
|
+
|
|
159
|
+
padding: ${(props) => typeof props.padding === "number" ? `${props.padding}px` : props.padding || 0};
|
|
160
|
+
${(props) => props.paddingHorizontal && `
|
|
161
|
+
padding-left: ${typeof props.paddingHorizontal === "number" ? `${props.paddingHorizontal}px` : props.paddingHorizontal};
|
|
162
|
+
padding-right: ${typeof props.paddingHorizontal === "number" ? `${props.paddingHorizontal}px` : props.paddingHorizontal};
|
|
163
|
+
`}
|
|
164
|
+
${(props) => props.paddingVertical && `
|
|
165
|
+
padding-top: ${typeof props.paddingVertical === "number" ? `${props.paddingVertical}px` : props.paddingVertical};
|
|
166
|
+
padding-bottom: ${typeof props.paddingVertical === "number" ? `${props.paddingVertical}px` : props.paddingVertical};
|
|
167
|
+
`}
|
|
168
|
+
${(props) => props.paddingTop !== void 0 && `padding-top: ${typeof props.paddingTop === "number" ? `${props.paddingTop}px` : props.paddingTop};`}
|
|
169
|
+
${(props) => props.paddingBottom !== void 0 && `padding-bottom: ${typeof props.paddingBottom === "number" ? `${props.paddingBottom}px` : props.paddingBottom};`}
|
|
170
|
+
${(props) => props.paddingLeft !== void 0 && `padding-left: ${typeof props.paddingLeft === "number" ? `${props.paddingLeft}px` : props.paddingLeft};`}
|
|
171
|
+
${(props) => props.paddingRight !== void 0 && `padding-right: ${typeof props.paddingRight === "number" ? `${props.paddingRight}px` : props.paddingRight};`}
|
|
172
|
+
|
|
173
|
+
margin: ${(props) => typeof props.margin === "number" ? `${props.margin}px` : props.margin || 0};
|
|
174
|
+
${(props) => props.marginTop !== void 0 && `margin-top: ${typeof props.marginTop === "number" ? `${props.marginTop}px` : props.marginTop};`}
|
|
175
|
+
${(props) => props.marginBottom !== void 0 && `margin-bottom: ${typeof props.marginBottom === "number" ? `${props.marginBottom}px` : props.marginBottom};`}
|
|
176
|
+
${(props) => props.marginLeft !== void 0 && `margin-left: ${typeof props.marginLeft === "number" ? `${props.marginLeft}px` : props.marginLeft};`}
|
|
177
|
+
${(props) => props.marginRight !== void 0 && `margin-right: ${typeof props.marginRight === "number" ? `${props.marginRight}px` : props.marginRight};`}
|
|
178
|
+
|
|
179
|
+
flex-direction: ${(props) => props.flexDirection || "column"};
|
|
180
|
+
flex-wrap: ${(props) => props.flexWrap || "nowrap"};
|
|
181
|
+
align-items: ${(props) => props.alignItems || "stretch"};
|
|
182
|
+
justify-content: ${(props) => props.justifyContent || "flex-start"};
|
|
183
|
+
cursor: ${(props) => props.cursor ? props.cursor : props.onClick || props.onPress ? "pointer" : "inherit"};
|
|
184
|
+
position: ${(props) => props.position || "static"};
|
|
185
|
+
top: ${(props) => typeof props.top === "number" ? `${props.top}px` : props.top};
|
|
186
|
+
bottom: ${(props) => typeof props.bottom === "number" ? `${props.bottom}px` : props.bottom};
|
|
187
|
+
left: ${(props) => typeof props.left === "number" ? `${props.left}px` : props.left};
|
|
188
|
+
right: ${(props) => typeof props.right === "number" ? `${props.right}px` : props.right};
|
|
189
|
+
flex: ${(props) => props.flex};
|
|
190
|
+
flex-shrink: ${(props) => props.flexShrink ?? 1};
|
|
191
|
+
gap: ${(props) => typeof props.gap === "number" ? `${props.gap}px` : props.gap || 0};
|
|
192
|
+
align-self: ${(props) => props.alignSelf || "auto"};
|
|
193
|
+
/* Only emit overflow-x/y when explicitly set. Defaulting them to
|
|
194
|
+
visible after overflow would override the shorthand and break
|
|
195
|
+
clipping (e.g. OtherCard bottom-right promo image). */
|
|
196
|
+
overflow: ${(props) => props.overflow || "visible"};
|
|
197
|
+
${(props) => props.overflowX != null ? `overflow-x: ${props.overflowX};` : ""}
|
|
198
|
+
${(props) => props.overflowY != null ? `overflow-y: ${props.overflowY};` : ""}
|
|
199
|
+
z-index: ${(props) => props.zIndex};
|
|
200
|
+
opacity: ${(props) => props.opacity != null ? props.opacity : props.disabled ? 0.5 : 1};
|
|
201
|
+
pointer-events: ${(props) => props.disabled ? "none" : "auto"};
|
|
202
|
+
|
|
203
|
+
/* \`background\` is emitted before \`background-color\` so a caller passing
|
|
204
|
+
both still gets backgroundColor as the winner. Use the shorthand for a
|
|
205
|
+
layered fill (e.g. an overlay tint over a resting surface colour), which
|
|
206
|
+
a single background-color cannot express. */
|
|
207
|
+
&:hover {
|
|
208
|
+
${(props) => props.hoverStyle?.background && `background: ${props.hoverStyle.background};`}
|
|
209
|
+
${(props) => props.hoverStyle?.backgroundColor && `background-color: ${props.hoverStyle.backgroundColor};`}
|
|
210
|
+
${(props) => props.hoverStyle?.borderColor && `border-color: ${props.hoverStyle.borderColor};`}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
&:active {
|
|
214
|
+
${(props) => props.pressStyle?.background && `background: ${props.pressStyle.background};`}
|
|
215
|
+
${(props) => props.pressStyle?.backgroundColor && `background-color: ${props.pressStyle.backgroundColor};`}
|
|
216
|
+
}
|
|
217
|
+
`;
|
|
218
|
+
var Box = import_react2.default.forwardRef(
|
|
219
|
+
({
|
|
220
|
+
children,
|
|
221
|
+
onPress,
|
|
222
|
+
onKeyDown,
|
|
223
|
+
onKeyUp,
|
|
224
|
+
role,
|
|
225
|
+
"aria-label": ariaLabel,
|
|
226
|
+
"aria-labelledby": ariaLabelledBy,
|
|
227
|
+
"aria-current": ariaCurrent,
|
|
228
|
+
"aria-disabled": ariaDisabled,
|
|
229
|
+
"aria-live": ariaLive,
|
|
230
|
+
"aria-busy": ariaBusy,
|
|
231
|
+
"aria-describedby": ariaDescribedBy,
|
|
232
|
+
"aria-expanded": ariaExpanded,
|
|
233
|
+
"aria-haspopup": ariaHasPopup,
|
|
234
|
+
"aria-pressed": ariaPressed,
|
|
235
|
+
"aria-controls": ariaControls,
|
|
236
|
+
tabIndex,
|
|
237
|
+
as,
|
|
238
|
+
src,
|
|
239
|
+
alt,
|
|
240
|
+
onError,
|
|
241
|
+
onLoad,
|
|
242
|
+
type,
|
|
243
|
+
disabled,
|
|
244
|
+
id,
|
|
245
|
+
testID,
|
|
246
|
+
"data-testid": dataTestId,
|
|
247
|
+
...props
|
|
248
|
+
}, ref) => {
|
|
249
|
+
if (as === "img" && src) {
|
|
250
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
251
|
+
"img",
|
|
252
|
+
{
|
|
253
|
+
src,
|
|
254
|
+
alt: alt || "",
|
|
255
|
+
onError,
|
|
256
|
+
onLoad,
|
|
257
|
+
"data-testid": dataTestId || testID,
|
|
258
|
+
style: {
|
|
259
|
+
display: "block",
|
|
260
|
+
objectFit: "cover",
|
|
261
|
+
width: typeof props.width === "number" ? `${props.width}px` : props.width,
|
|
262
|
+
height: typeof props.height === "number" ? `${props.height}px` : props.height,
|
|
263
|
+
borderRadius: typeof props.borderRadius === "number" ? `${props.borderRadius}px` : props.borderRadius,
|
|
264
|
+
position: props.position,
|
|
265
|
+
top: typeof props.top === "number" ? `${props.top}px` : props.top,
|
|
266
|
+
left: typeof props.left === "number" ? `${props.left}px` : props.left,
|
|
267
|
+
right: typeof props.right === "number" ? `${props.right}px` : props.right,
|
|
268
|
+
bottom: typeof props.bottom === "number" ? `${props.bottom}px` : props.bottom,
|
|
269
|
+
...props.style
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
);
|
|
273
|
+
}
|
|
274
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
275
|
+
StyledBox,
|
|
276
|
+
{
|
|
277
|
+
ref,
|
|
278
|
+
elementType: as,
|
|
279
|
+
id,
|
|
280
|
+
type: as === "button" ? type || "button" : void 0,
|
|
281
|
+
disabled: as === "button" ? disabled : void 0,
|
|
282
|
+
onClick: onPress,
|
|
283
|
+
onKeyDown,
|
|
284
|
+
onKeyUp,
|
|
285
|
+
role,
|
|
286
|
+
"aria-label": ariaLabel,
|
|
287
|
+
"aria-labelledby": ariaLabelledBy,
|
|
288
|
+
"aria-current": ariaCurrent,
|
|
289
|
+
"aria-disabled": ariaDisabled,
|
|
290
|
+
"aria-busy": ariaBusy,
|
|
291
|
+
"aria-describedby": ariaDescribedBy,
|
|
292
|
+
"aria-expanded": ariaExpanded,
|
|
293
|
+
"aria-haspopup": ariaHasPopup,
|
|
294
|
+
"aria-pressed": ariaPressed,
|
|
295
|
+
"aria-controls": ariaControls,
|
|
296
|
+
"aria-live": ariaLive,
|
|
297
|
+
tabIndex: tabIndex !== void 0 ? tabIndex : void 0,
|
|
298
|
+
"data-testid": dataTestId || testID,
|
|
299
|
+
...props,
|
|
300
|
+
children
|
|
301
|
+
}
|
|
302
|
+
);
|
|
303
|
+
}
|
|
304
|
+
);
|
|
305
|
+
Box.displayName = "Box";
|
|
306
|
+
|
|
307
|
+
// src/VideoPlayer.tsx
|
|
308
|
+
var import_xui_core = require("@xsolla/xui-core");
|
|
309
|
+
var import_xui_button = require("@xsolla/xui-button");
|
|
310
|
+
var import_xui_slider = require("@xsolla/xui-slider");
|
|
311
|
+
var import_xui_tag = require("@xsolla/xui-tag");
|
|
312
|
+
var import_xui_b2c_currency_tag = require("@xsolla/xui-b2c-currency-tag");
|
|
313
|
+
var import_xui_typography = require("@xsolla/xui-typography");
|
|
314
|
+
var import_xui_icons_base = require("@xsolla/xui-icons-base");
|
|
315
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
316
|
+
var CONTROL_BAR_HEIGHT = 64;
|
|
317
|
+
var CONTROL_BAR_PADDING = 12;
|
|
318
|
+
var HEADER_COPY_GAP = 12;
|
|
319
|
+
var SIDE_CONTROL_GAP = 12;
|
|
320
|
+
var SUCCESS_REWARD_VEIL = "linear-gradient(rgba(255, 255, 255, 0.64), rgba(255, 255, 255, 0.64))";
|
|
321
|
+
var LABEL_REWARD_PADDING = 6;
|
|
322
|
+
var isCurrencyReward = (reward) => reward.kind === "currency";
|
|
323
|
+
var formatPlaybackTime = (seconds) => {
|
|
324
|
+
const safe = Number.isFinite(seconds) && seconds > 0 ? Math.floor(seconds) : 0;
|
|
325
|
+
const minutes = Math.floor(safe / 60);
|
|
326
|
+
const remainder = safe % 60;
|
|
327
|
+
return `${String(minutes).padStart(2, "0")}:${String(remainder).padStart(
|
|
328
|
+
2,
|
|
329
|
+
"0"
|
|
330
|
+
)}`;
|
|
331
|
+
};
|
|
332
|
+
var VideoPlayer = ({
|
|
333
|
+
view = "full",
|
|
334
|
+
title,
|
|
335
|
+
description,
|
|
336
|
+
rewards,
|
|
337
|
+
currentTime,
|
|
338
|
+
duration = 0,
|
|
339
|
+
playing,
|
|
340
|
+
muted,
|
|
341
|
+
expanded,
|
|
342
|
+
disabled = false,
|
|
343
|
+
onPlayPause,
|
|
344
|
+
onMute,
|
|
345
|
+
onExpand,
|
|
346
|
+
onSeek,
|
|
347
|
+
overlayThemeMode = "dark",
|
|
348
|
+
"aria-label": ariaLabel = "Video player",
|
|
349
|
+
testID,
|
|
350
|
+
themeMode,
|
|
351
|
+
themeProductContext = "b2c"
|
|
352
|
+
}) => {
|
|
353
|
+
const { theme } = (0, import_xui_core.useResolvedTheme)({ themeMode, themeProductContext });
|
|
354
|
+
const { theme: overlayTheme } = (0, import_xui_core.useResolvedTheme)({
|
|
355
|
+
themeMode: overlayThemeMode,
|
|
356
|
+
themeProductContext
|
|
357
|
+
});
|
|
358
|
+
const [internalTime, setInternalTime] = (0, import_react3.useState)(currentTime ?? 0);
|
|
359
|
+
const [internalPlaying, setInternalPlaying] = (0, import_react3.useState)(playing ?? false);
|
|
360
|
+
const [internalMuted, setInternalMuted] = (0, import_react3.useState)(muted ?? false);
|
|
361
|
+
const [internalExpanded, setInternalExpanded] = (0, import_react3.useState)(expanded ?? false);
|
|
362
|
+
const resolvedTime = currentTime ?? internalTime;
|
|
363
|
+
const isPlaying = playing ?? internalPlaying;
|
|
364
|
+
const isMuted = muted ?? internalMuted;
|
|
365
|
+
const isExpanded = expanded ?? internalExpanded;
|
|
366
|
+
const isCompact = view === "compact";
|
|
367
|
+
const isSeekable = duration > 0;
|
|
368
|
+
const overlayContentColor = overlayTheme.colors.content.static.light;
|
|
369
|
+
const copyColor = theme.colors.content.static.light;
|
|
370
|
+
const handleSeek = (next) => {
|
|
371
|
+
setInternalTime(next);
|
|
372
|
+
onSeek?.(next);
|
|
373
|
+
};
|
|
374
|
+
const handlePlayPause = () => {
|
|
375
|
+
const next = !isPlaying;
|
|
376
|
+
setInternalPlaying(next);
|
|
377
|
+
onPlayPause?.(next);
|
|
378
|
+
};
|
|
379
|
+
const handleMute = () => {
|
|
380
|
+
const next = !isMuted;
|
|
381
|
+
setInternalMuted(next);
|
|
382
|
+
onMute?.(next);
|
|
383
|
+
};
|
|
384
|
+
const handleExpand = () => {
|
|
385
|
+
const next = !isExpanded;
|
|
386
|
+
setInternalExpanded(next);
|
|
387
|
+
onExpand?.(next);
|
|
388
|
+
};
|
|
389
|
+
const hasRewards = Boolean(rewards && rewards.length > 0);
|
|
390
|
+
const hasCopy = Boolean(title || description);
|
|
391
|
+
const showHeader = !isCompact && (hasRewards || hasCopy);
|
|
392
|
+
const controlBar = /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
393
|
+
Box,
|
|
394
|
+
{
|
|
395
|
+
flexDirection: "row",
|
|
396
|
+
alignItems: "center",
|
|
397
|
+
width: "100%",
|
|
398
|
+
height: CONTROL_BAR_HEIGHT,
|
|
399
|
+
gap: theme.spacing.lg,
|
|
400
|
+
padding: CONTROL_BAR_PADDING,
|
|
401
|
+
borderRadius: theme.shape.cell.borderRadius,
|
|
402
|
+
backgroundColor: overlayTheme.colors.layer.scrim,
|
|
403
|
+
style: { backdropFilter: "blur(8px)", WebkitBackdropFilter: "blur(8px)" },
|
|
404
|
+
testID: testID ? `${testID}-controls` : "video-player-controls",
|
|
405
|
+
children: [
|
|
406
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
407
|
+
Box,
|
|
408
|
+
{
|
|
409
|
+
flex: 1,
|
|
410
|
+
minWidth: 0,
|
|
411
|
+
flexDirection: "row",
|
|
412
|
+
alignItems: "center",
|
|
413
|
+
gap: theme.spacing.sm,
|
|
414
|
+
children: [
|
|
415
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
416
|
+
import_xui_button.IconButton,
|
|
417
|
+
{
|
|
418
|
+
variant: "tertiary",
|
|
419
|
+
tone: "mono",
|
|
420
|
+
size: "xs",
|
|
421
|
+
themeMode: overlayThemeMode,
|
|
422
|
+
themeProductContext,
|
|
423
|
+
disabled,
|
|
424
|
+
icon: isPlaying ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_xui_icons_base.Pause, {}) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_xui_icons_base.Play, {}),
|
|
425
|
+
"aria-label": isPlaying ? "Pause" : "Play",
|
|
426
|
+
"aria-pressed": isPlaying,
|
|
427
|
+
onPress: handlePlayPause,
|
|
428
|
+
testID: testID ? `${testID}-play-pause` : "video-player-play-pause"
|
|
429
|
+
}
|
|
430
|
+
),
|
|
431
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Box, { flex: 1, minWidth: 0, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
432
|
+
import_xui_slider.Slider,
|
|
433
|
+
{
|
|
434
|
+
value: resolvedTime,
|
|
435
|
+
min: 0,
|
|
436
|
+
max: isSeekable ? duration : 1,
|
|
437
|
+
step: 1,
|
|
438
|
+
size: "sm",
|
|
439
|
+
disabled: disabled || !isSeekable,
|
|
440
|
+
onChange: handleSeek,
|
|
441
|
+
"aria-label": "Seek",
|
|
442
|
+
themeMode: overlayThemeMode,
|
|
443
|
+
themeProductContext,
|
|
444
|
+
testID: testID ? `${testID}-seek` : "video-player-seek"
|
|
445
|
+
}
|
|
446
|
+
) }),
|
|
447
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
448
|
+
import_xui_typography.Typography,
|
|
449
|
+
{
|
|
450
|
+
variant: "bodySm",
|
|
451
|
+
color: overlayContentColor,
|
|
452
|
+
productContext: themeProductContext,
|
|
453
|
+
align: "right",
|
|
454
|
+
noWrap: true,
|
|
455
|
+
testID: testID ? `${testID}-time` : "video-player-time",
|
|
456
|
+
children: formatPlaybackTime(resolvedTime)
|
|
457
|
+
}
|
|
458
|
+
)
|
|
459
|
+
]
|
|
460
|
+
}
|
|
461
|
+
),
|
|
462
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Box, { flexDirection: "row", alignItems: "center", gap: SIDE_CONTROL_GAP, children: [
|
|
463
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
464
|
+
import_xui_button.IconButton,
|
|
465
|
+
{
|
|
466
|
+
variant: "tertiary",
|
|
467
|
+
tone: "mono",
|
|
468
|
+
size: "sm",
|
|
469
|
+
themeMode: overlayThemeMode,
|
|
470
|
+
themeProductContext,
|
|
471
|
+
disabled,
|
|
472
|
+
icon: isMuted ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_xui_icons_base.VolumeMute, {}) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_xui_icons_base.VolumeUp, {}),
|
|
473
|
+
"aria-label": isMuted ? "Unmute" : "Mute",
|
|
474
|
+
"aria-pressed": isMuted,
|
|
475
|
+
onPress: handleMute,
|
|
476
|
+
testID: testID ? `${testID}-mute` : "video-player-mute"
|
|
477
|
+
}
|
|
478
|
+
),
|
|
479
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
480
|
+
import_xui_button.IconButton,
|
|
481
|
+
{
|
|
482
|
+
variant: "tertiary",
|
|
483
|
+
tone: "mono",
|
|
484
|
+
size: "sm",
|
|
485
|
+
themeMode: overlayThemeMode,
|
|
486
|
+
themeProductContext,
|
|
487
|
+
disabled,
|
|
488
|
+
icon: isExpanded ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_xui_icons_base.ExitFullScreen, {}) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_xui_icons_base.FullScreen, {}),
|
|
489
|
+
"aria-label": isExpanded ? "Collapse" : "Expand",
|
|
490
|
+
"aria-pressed": isExpanded,
|
|
491
|
+
onPress: handleExpand,
|
|
492
|
+
testID: testID ? `${testID}-expand` : "video-player-expand"
|
|
493
|
+
}
|
|
494
|
+
)
|
|
495
|
+
] })
|
|
496
|
+
]
|
|
497
|
+
}
|
|
498
|
+
);
|
|
499
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
500
|
+
Box,
|
|
501
|
+
{
|
|
502
|
+
role: "group",
|
|
503
|
+
"aria-label": ariaLabel,
|
|
504
|
+
flexDirection: "column",
|
|
505
|
+
justifyContent: "space-between",
|
|
506
|
+
width: "100%",
|
|
507
|
+
gap: theme.spacing.lg,
|
|
508
|
+
testID: testID || "video-player",
|
|
509
|
+
children: [
|
|
510
|
+
showHeader && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Box, { flexDirection: "column", gap: HEADER_COPY_GAP, children: [
|
|
511
|
+
hasRewards && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Box, { flexDirection: "row", alignItems: "center", gap: theme.spacing.xs, children: rewards?.map((reward) => {
|
|
512
|
+
const rewardTestID = testID ? `${testID}-reward-${reward.key}` : `video-player-reward-${reward.key}`;
|
|
513
|
+
if (isCurrencyReward(reward)) {
|
|
514
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
515
|
+
import_xui_b2c_currency_tag.CurrencyTag,
|
|
516
|
+
{
|
|
517
|
+
currency: reward.currency,
|
|
518
|
+
value: reward.value,
|
|
519
|
+
sublabel: reward.sublabel,
|
|
520
|
+
size: "sm",
|
|
521
|
+
themeProductContext,
|
|
522
|
+
testID: rewardTestID
|
|
523
|
+
},
|
|
524
|
+
reward.key
|
|
525
|
+
);
|
|
526
|
+
}
|
|
527
|
+
const tone = reward.tone ?? "primary";
|
|
528
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
529
|
+
import_xui_tag.Tag,
|
|
530
|
+
{
|
|
531
|
+
size: "sm",
|
|
532
|
+
tone,
|
|
533
|
+
iconLeft: reward.icon,
|
|
534
|
+
themeMode: "light",
|
|
535
|
+
themeProductContext,
|
|
536
|
+
style: {
|
|
537
|
+
...reward.icon ? {} : {
|
|
538
|
+
paddingLeft: LABEL_REWARD_PADDING,
|
|
539
|
+
paddingRight: LABEL_REWARD_PADDING
|
|
540
|
+
},
|
|
541
|
+
...tone === "success" ? { backgroundImage: SUCCESS_REWARD_VEIL } : {}
|
|
542
|
+
},
|
|
543
|
+
testID: rewardTestID,
|
|
544
|
+
children: reward.label
|
|
545
|
+
},
|
|
546
|
+
reward.key
|
|
547
|
+
);
|
|
548
|
+
}) }),
|
|
549
|
+
hasCopy && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Box, { flexDirection: "column", children: [
|
|
550
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
551
|
+
import_xui_typography.Typography,
|
|
552
|
+
{
|
|
553
|
+
variant: "bodyLgAccent",
|
|
554
|
+
color: copyColor,
|
|
555
|
+
productContext: themeProductContext,
|
|
556
|
+
noWrap: true,
|
|
557
|
+
children: title
|
|
558
|
+
}
|
|
559
|
+
),
|
|
560
|
+
description && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
561
|
+
import_xui_typography.Typography,
|
|
562
|
+
{
|
|
563
|
+
variant: "bodySm",
|
|
564
|
+
color: copyColor,
|
|
565
|
+
productContext: themeProductContext,
|
|
566
|
+
noWrap: true,
|
|
567
|
+
style: { opacity: 0.5 },
|
|
568
|
+
children: description
|
|
569
|
+
}
|
|
570
|
+
)
|
|
571
|
+
] })
|
|
572
|
+
] }),
|
|
573
|
+
controlBar
|
|
574
|
+
]
|
|
575
|
+
}
|
|
576
|
+
);
|
|
577
|
+
};
|
|
578
|
+
VideoPlayer.displayName = "VideoPlayer";
|
|
579
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
580
|
+
0 && (module.exports = {
|
|
581
|
+
VideoPlayer,
|
|
582
|
+
formatPlaybackTime
|
|
583
|
+
});
|
|
584
|
+
//# sourceMappingURL=index.js.map
|