@wix/video 1.72.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/LICENSE +21 -0
- package/README.md +126 -0
- package/dist/cjs/Video.js +121 -0
- package/dist/cjs/Video.js.map +1 -0
- package/dist/cjs/Video.module.scss +27 -0
- package/dist/cjs/Video.stories.js +68 -0
- package/dist/cjs/Video.stories.js.map +1 -0
- package/dist/cjs/custom-element/WowVideo.js +88 -0
- package/dist/cjs/custom-element/WowVideo.js.map +1 -0
- package/dist/cjs/custom-element/registry.js +34 -0
- package/dist/cjs/custom-element/registry.js.map +1 -0
- package/dist/cjs/custom-element/utils.js +138 -0
- package/dist/cjs/custom-element/utils.js.map +1 -0
- package/dist/cjs/custom-element/videoLayout.js +120 -0
- package/dist/cjs/custom-element/videoLayout.js.map +1 -0
- package/dist/cjs/customElementInit.js +10 -0
- package/dist/cjs/customElementInit.js.map +1 -0
- package/dist/cjs/dataManifest.js +53 -0
- package/dist/cjs/dataManifest.js.map +1 -0
- package/dist/cjs/external-types.d.js +2 -0
- package/dist/cjs/external-types.d.js.map +1 -0
- package/dist/cjs/index.js +23 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/storybook/Container.js +33 -0
- package/dist/cjs/storybook/Container.js.map +1 -0
- package/dist/cjs/storybook/args.js +178 -0
- package/dist/cjs/storybook/args.js.map +1 -0
- package/dist/cjs/test-types.d.js +2 -0
- package/dist/cjs/test-types.d.js.map +1 -0
- package/dist/cjs/types.js +4 -0
- package/dist/cjs/types.js.map +1 -0
- package/dist/esm/Video.js +95 -0
- package/dist/esm/Video.js.map +1 -0
- package/dist/esm/Video.module.scss +27 -0
- package/dist/esm/Video.stories.js +47 -0
- package/dist/esm/Video.stories.js.map +1 -0
- package/dist/esm/custom-element/WowVideo.js +83 -0
- package/dist/esm/custom-element/WowVideo.js.map +1 -0
- package/dist/esm/custom-element/registry.js +29 -0
- package/dist/esm/custom-element/registry.js.map +1 -0
- package/dist/esm/custom-element/utils.js +131 -0
- package/dist/esm/custom-element/utils.js.map +1 -0
- package/dist/esm/custom-element/videoLayout.js +117 -0
- package/dist/esm/custom-element/videoLayout.js.map +1 -0
- package/dist/esm/customElementInit.js +13 -0
- package/dist/esm/customElementInit.js.map +1 -0
- package/dist/esm/dataManifest.js +49 -0
- package/dist/esm/dataManifest.js.map +1 -0
- package/dist/esm/external-types.d.js +2 -0
- package/dist/esm/external-types.d.js.map +1 -0
- package/dist/esm/index.js +6 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/storybook/Container.js +21 -0
- package/dist/esm/storybook/Container.js.map +1 -0
- package/dist/esm/storybook/args.js +174 -0
- package/dist/esm/storybook/args.js.map +1 -0
- package/dist/esm/test-types.d.js +2 -0
- package/dist/esm/test-types.d.js.map +1 -0
- package/dist/esm/types.js +2 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/statics/189.chunk.js +35383 -0
- package/dist/statics/189.chunk.js.map +1 -0
- package/dist/statics/189.chunk.min.js +2 -0
- package/dist/statics/189.chunk.min.js.map +1 -0
- package/dist/statics/janet/110.8a580c2d.iframe.bundle.js +10826 -0
- package/dist/statics/janet/110.8a580c2d.iframe.bundle.js.map +1 -0
- package/dist/statics/janet/134.6007b391.iframe.bundle.js +484 -0
- package/dist/statics/janet/134.6007b391.iframe.bundle.js.map +1 -0
- package/dist/statics/janet/134.d48c36bc94ecd2280c0a.manager.bundle.js +1 -0
- package/dist/statics/janet/317.2df397a1e1f34d5a30fd.manager.bundle.js +1 -0
- package/dist/statics/janet/326.e8fcdb36.iframe.bundle.js +1998 -0
- package/dist/statics/janet/326.e8fcdb36.iframe.bundle.js.map +1 -0
- package/dist/statics/janet/326.ff40cdf1778fd94969c8.manager.bundle.js +2 -0
- package/dist/statics/janet/326.ff40cdf1778fd94969c8.manager.bundle.js.LICENSE.txt +31 -0
- package/dist/statics/janet/470.aab6696c.iframe.bundle.js +35380 -0
- package/dist/statics/janet/470.aab6696c.iframe.bundle.js.map +1 -0
- package/dist/statics/janet/599.37d4aa34.iframe.bundle.js +3294 -0
- package/dist/statics/janet/599.37d4aa34.iframe.bundle.js.map +1 -0
- package/dist/statics/janet/599.47c7dacc8997e4d71eac.manager.bundle.js +1 -0
- package/dist/statics/janet/61.5cb88eb5.iframe.bundle.js +2652 -0
- package/dist/statics/janet/61.5cb88eb5.iframe.bundle.js.map +1 -0
- package/dist/statics/janet/61.a575d4776ab0d42da5c8.manager.bundle.js +1 -0
- package/dist/statics/janet/673.59f2a23a.iframe.bundle.js +173 -0
- package/dist/statics/janet/673.59f2a23a.iframe.bundle.js.map +1 -0
- package/dist/statics/janet/725.0db49c6347dfe44ace2d.manager.bundle.js +2 -0
- package/dist/statics/janet/725.0db49c6347dfe44ace2d.manager.bundle.js.LICENSE.txt +8 -0
- package/dist/statics/janet/725.cbba2e4b.iframe.bundle.js +10451 -0
- package/dist/statics/janet/725.cbba2e4b.iframe.bundle.js.map +1 -0
- package/dist/statics/janet/734.428ea23e9773cd26fb57.manager.bundle.js +2 -0
- package/dist/statics/janet/734.428ea23e9773cd26fb57.manager.bundle.js.LICENSE.txt +94 -0
- package/dist/statics/janet/833.75275036.iframe.bundle.js +6777 -0
- package/dist/statics/janet/833.75275036.iframe.bundle.js.map +1 -0
- package/dist/statics/janet/833.ef639b005d7b76723595.manager.bundle.js +2 -0
- package/dist/statics/janet/833.ef639b005d7b76723595.manager.bundle.js.LICENSE.txt +12 -0
- package/dist/statics/janet/W-06.svg +1 -0
- package/dist/statics/janet/favicon.ico +0 -0
- package/dist/statics/janet/iframe.html +364 -0
- package/dist/statics/janet/index.html +59 -0
- package/dist/statics/janet/janet.json +10 -0
- package/dist/statics/janet/main.666d4853f3d62ab20aa1.manager.bundle.js +1 -0
- package/dist/statics/janet/main.d8a321d6.iframe.bundle.js +73260 -0
- package/dist/statics/janet/main.d8a321d6.iframe.bundle.js.map +1 -0
- package/dist/statics/janet/project.json +1 -0
- package/dist/statics/janet/runtime~main.2195d24e465f19ad9c9a.manager.bundle.js +1 -0
- package/dist/statics/janet/w-06.ico +0 -0
- package/dist/statics/manifest.json +4 -0
- package/dist/statics/manifest.min.json +4 -0
- package/dist/statics/video.css +10 -0
- package/dist/statics/video.css.map +1 -0
- package/dist/statics/video.min.css +1 -0
- package/dist/statics/video.rtl.css +8 -0
- package/dist/statics/video.rtl.min.css +1 -0
- package/dist/statics/video.umd.js +5990 -0
- package/dist/statics/video.umd.js.map +1 -0
- package/dist/statics/video.umd.min.js +2 -0
- package/dist/statics/video.umd.min.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/types/Video.d.ts +5 -0
- package/dist/types/Video.d.ts.map +1 -0
- package/dist/types/Video.stories.d.ts +20 -0
- package/dist/types/Video.stories.d.ts.map +1 -0
- package/dist/types/custom-element/WowVideo.d.ts +4 -0
- package/dist/types/custom-element/WowVideo.d.ts.map +1 -0
- package/dist/types/custom-element/registry.d.ts +3 -0
- package/dist/types/custom-element/registry.d.ts.map +1 -0
- package/dist/types/custom-element/utils.d.ts +11 -0
- package/dist/types/custom-element/utils.d.ts.map +1 -0
- package/dist/types/custom-element/videoLayout.d.ts +35 -0
- package/dist/types/custom-element/videoLayout.d.ts.map +1 -0
- package/dist/types/customElementInit.d.ts +4 -0
- package/dist/types/customElementInit.d.ts.map +1 -0
- package/dist/types/dataManifest.d.ts +2 -0
- package/dist/types/dataManifest.d.ts.map +1 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/storybook/Container.d.ts +5 -0
- package/dist/types/storybook/Container.d.ts.map +1 -0
- package/dist/types/storybook/args.d.ts +174 -0
- package/dist/types/storybook/args.d.ts.map +1 -0
- package/dist/types/types.d.ts +62 -0
- package/dist/types/types.d.ts.map +1 -0
- package/package.json +121 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Wix.com
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
# Video
|
|
2
|
+
|
|
3
|
+
Infra Video component.
|
|
4
|
+
|
|
5
|
+
## Example
|
|
6
|
+
|
|
7
|
+
```js
|
|
8
|
+
import { Video } from '@wix/video';
|
|
9
|
+
|
|
10
|
+
function Example() {
|
|
11
|
+
const videoRef = React.useRef(null);
|
|
12
|
+
|
|
13
|
+
return (
|
|
14
|
+
<Video
|
|
15
|
+
id="my-video"
|
|
16
|
+
videoMedia={{
|
|
17
|
+
uri: "video-base-uri",
|
|
18
|
+
name: "My Video",
|
|
19
|
+
sources: [/* video sources */],
|
|
20
|
+
hasAudio: true
|
|
21
|
+
}}
|
|
22
|
+
poster={{
|
|
23
|
+
uri: "poster-image-uri",
|
|
24
|
+
width: 1920,
|
|
25
|
+
height: 1080
|
|
26
|
+
}}
|
|
27
|
+
muted={true}
|
|
28
|
+
loop={true}
|
|
29
|
+
autoplay={true}
|
|
30
|
+
videoRef={videoRef}
|
|
31
|
+
qualityPolicy="proportional"
|
|
32
|
+
/>
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Installation
|
|
38
|
+
|
|
39
|
+
### Install package
|
|
40
|
+
You can install the package via npm/yarn
|
|
41
|
+
```
|
|
42
|
+
> npm install -s @wix/video --registry http://npm.dev.wixpress.com/
|
|
43
|
+
```
|
|
44
|
+
or:
|
|
45
|
+
```
|
|
46
|
+
> yarn add @wix/video --registry http://npm.dev.wixpress.com/
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Props
|
|
50
|
+
|
|
51
|
+
| Prop name | Type | Default | Description |
|
|
52
|
+
| --------- | ---- | ------- | ----------- |
|
|
53
|
+
| id | string | - | Required unique identifier for the video element |
|
|
54
|
+
| videoMedia | object | - | Video source information (see details below) |
|
|
55
|
+
| poster | object | - | Poster image that displays before video plays (Image props) |
|
|
56
|
+
| alt | string | '' | Alternate text for the video for accessibility |
|
|
57
|
+
| muted | boolean | - | Whether the video's audio is muted |
|
|
58
|
+
| loop | boolean | - | Whether the video should loop when it reaches the end |
|
|
59
|
+
| autoplay | boolean | - | Whether the video should start playing automatically when loaded |
|
|
60
|
+
| playbackRate | number | 1 | Playback speed of the video |
|
|
61
|
+
| posterEffect | 'fade' | - | Effect to apply when transitioning from poster to video |
|
|
62
|
+
| videoRef | React.RefObject<HTMLVideoElement> | - | React ref to access the underlying video element |
|
|
63
|
+
| qualityPolicy | 'proportional' \| 'adaptive' \| 'highest' | Video quality selection strategy: `'proportional'` - dynamically selects quality based on container size, `'adaptive'` - uses adaptive sources (HLS/DASH), `'highest'` - always uses the highest resolution available |
|
|
64
|
+
|
|
65
|
+
### videoMedia Object
|
|
66
|
+
|
|
67
|
+
| Property | Type | Required | Description |
|
|
68
|
+
| -------- | ---- | -------- | ----------- |
|
|
69
|
+
| uri | string | Yes | Base URI for the video |
|
|
70
|
+
| name | string | No | Name of the video |
|
|
71
|
+
| sources | VideoSource[] | No | Array of video sources with different qualities (see below) |
|
|
72
|
+
| adaptiveSources | AdaptiveVideoSource[] | No | Array of adaptive video sources (HLS/DASH) |
|
|
73
|
+
| hasAudio | boolean | No | Whether the video has audio |
|
|
74
|
+
| fps | number | No | Frames per second |
|
|
75
|
+
|
|
76
|
+
### VideoSource Object
|
|
77
|
+
|
|
78
|
+
| Property | Type | Description |
|
|
79
|
+
| -------- | ---- | ----------- |
|
|
80
|
+
| quality | '1080p' \| '720p' \| '480p' \| '360p' | Quality preset |
|
|
81
|
+
| width | number | Width of the video in pixels |
|
|
82
|
+
| height | number | Height of the video in pixels |
|
|
83
|
+
| types | object[] | Array of formats available `{ format: 'mp4' \| 'mp4-luminance'; uri: string }[]` |
|
|
84
|
+
|
|
85
|
+
### AdaptiveVideoSource Object
|
|
86
|
+
|
|
87
|
+
| Property | Type | Description |
|
|
88
|
+
| -------- | ---- | ----------- |
|
|
89
|
+
| format | 'hls' \| 'dash' | Adaptive streaming format |
|
|
90
|
+
| uri | string | URI for the adaptive source |
|
|
91
|
+
|
|
92
|
+
## Features
|
|
93
|
+
|
|
94
|
+
- Automatic quality selection based on container size
|
|
95
|
+
- Supports poster images with transition effects
|
|
96
|
+
- Custom playback rate
|
|
97
|
+
- Accessibility support through alt text
|
|
98
|
+
- Responsive scaling and positioning
|
|
99
|
+
- Support for adaptive streaming (HLS/DASH)
|
|
100
|
+
|
|
101
|
+
## Technical Details
|
|
102
|
+
|
|
103
|
+
The Video component uses a custom element (`wow-video`) under the hood that handles:
|
|
104
|
+
- Intersection observation for visibility-based optimizations
|
|
105
|
+
- Automatic resizing and layout adjustments
|
|
106
|
+
- Optimal video quality selection based on container dimensions
|
|
107
|
+
- Poster image display and transition
|
|
108
|
+
|
|
109
|
+
## Data Manifest
|
|
110
|
+
|
|
111
|
+
This package exports a `videoDataManifest` object that can be used for component manifests that use the Video component.
|
|
112
|
+
|
|
113
|
+
### Usage
|
|
114
|
+
|
|
115
|
+
```js
|
|
116
|
+
import { videoDataManifest } from '@wix/video';
|
|
117
|
+
|
|
118
|
+
// Use in your component manifest
|
|
119
|
+
const myComponentManifest = {
|
|
120
|
+
// ... other component properties
|
|
121
|
+
data: {
|
|
122
|
+
video: videoDataManifest,
|
|
123
|
+
// ... other properties
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
```
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
exports.__esModule = true;
|
|
5
|
+
exports.default = void 0;
|
|
6
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
7
|
+
var React = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _VideoModule = _interopRequireDefault(require("./Video.module.scss"));
|
|
9
|
+
var _utils = require("./custom-element/utils");
|
|
10
|
+
var _customElementInit = require("./customElementInit");
|
|
11
|
+
var _image = require("@wix/image");
|
|
12
|
+
var _jsxFileName = "/home/builduser/work/5a10c7a05f300a84/packages/video/dist/cjs/Video.tsx";
|
|
13
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
14
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
15
|
+
if (typeof window !== 'undefined') {
|
|
16
|
+
if (document.readyState === 'loading') {
|
|
17
|
+
document.addEventListener('DOMContentLoaded', () => {
|
|
18
|
+
(0, _customElementInit.initCustomElement)();
|
|
19
|
+
(0, _image.initCustomElement)();
|
|
20
|
+
}, {
|
|
21
|
+
once: true
|
|
22
|
+
});
|
|
23
|
+
} else {
|
|
24
|
+
(0, _customElementInit.initCustomElement)();
|
|
25
|
+
(0, _image.initCustomElement)();
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
const Video = props => {
|
|
29
|
+
const {
|
|
30
|
+
motionPart,
|
|
31
|
+
videoRef,
|
|
32
|
+
videoMedia,
|
|
33
|
+
muted,
|
|
34
|
+
loop,
|
|
35
|
+
autoplay,
|
|
36
|
+
playbackRate = 1,
|
|
37
|
+
posterEffect,
|
|
38
|
+
id,
|
|
39
|
+
qualityPolicy = 'proportional',
|
|
40
|
+
focalPoint,
|
|
41
|
+
onError
|
|
42
|
+
} = props;
|
|
43
|
+
const wowVideoRef = React.useRef(null);
|
|
44
|
+
const videoInfoString = React.useMemo(() => {
|
|
45
|
+
const sortedQualities = (0, _utils.sortQualities)(videoMedia.sources || []);
|
|
46
|
+
return JSON.stringify({
|
|
47
|
+
...videoMedia,
|
|
48
|
+
playbackRate,
|
|
49
|
+
posterEffect,
|
|
50
|
+
sources: sortedQualities,
|
|
51
|
+
autoplay,
|
|
52
|
+
qualityPolicy,
|
|
53
|
+
focalPoint
|
|
54
|
+
});
|
|
55
|
+
}, [videoMedia, playbackRate, posterEffect, autoplay, qualityPolicy, focalPoint]);
|
|
56
|
+
const VideoPosterImage = videoMedia.poster && /*#__PURE__*/React.createElement(_image.Image, (0, _extends2.default)({}, videoMedia.poster, {
|
|
57
|
+
focalPoint: focalPoint,
|
|
58
|
+
id: `videoPoster_${id}`,
|
|
59
|
+
displayMode: "fill",
|
|
60
|
+
alt: videoMedia.name || videoMedia.poster.alt || "",
|
|
61
|
+
quality: videoMedia.poster.quality ? {
|
|
62
|
+
quality: videoMedia.poster.quality
|
|
63
|
+
} : undefined,
|
|
64
|
+
__self: void 0,
|
|
65
|
+
__source: {
|
|
66
|
+
fileName: _jsxFileName,
|
|
67
|
+
lineNumber: 65,
|
|
68
|
+
columnNumber: 5
|
|
69
|
+
}
|
|
70
|
+
}));
|
|
71
|
+
const handleVideoElementError = React.useCallback(event => {
|
|
72
|
+
if (onError) {
|
|
73
|
+
var _videoElement$error;
|
|
74
|
+
const videoElement = event.currentTarget;
|
|
75
|
+
const error = new Error(`Video playback error: ${((_videoElement$error = videoElement.error) == null ? void 0 : _videoElement$error.message) || "Unknown error"}`);
|
|
76
|
+
onError(error);
|
|
77
|
+
}
|
|
78
|
+
}, [onError]);
|
|
79
|
+
const handleAdaptiveVideoError = React.useCallback(event => {
|
|
80
|
+
var _event$detail;
|
|
81
|
+
if (onError && (_event$detail = event.detail) != null && _event$detail.error) {
|
|
82
|
+
onError(event.detail.error);
|
|
83
|
+
}
|
|
84
|
+
}, [onError]);
|
|
85
|
+
React.useEffect(() => {
|
|
86
|
+
const element = wowVideoRef.current;
|
|
87
|
+
element == null || element.addEventListener("videoerror", handleAdaptiveVideoError);
|
|
88
|
+
return () => {
|
|
89
|
+
element == null || element.removeEventListener("videoerror", handleAdaptiveVideoError);
|
|
90
|
+
};
|
|
91
|
+
}, [onError, handleAdaptiveVideoError]);
|
|
92
|
+
return /*#__PURE__*/React.createElement("wow-video", {
|
|
93
|
+
ref: wowVideoRef,
|
|
94
|
+
"data-video-info": videoInfoString,
|
|
95
|
+
"data-motion-part": motionPart || '',
|
|
96
|
+
class: _VideoModule.default.videoContainer,
|
|
97
|
+
__self: void 0,
|
|
98
|
+
__source: {
|
|
99
|
+
fileName: _jsxFileName,
|
|
100
|
+
lineNumber: 112,
|
|
101
|
+
columnNumber: 5
|
|
102
|
+
}
|
|
103
|
+
}, /*#__PURE__*/React.createElement("video", {
|
|
104
|
+
ref: videoRef,
|
|
105
|
+
className: _VideoModule.default.video,
|
|
106
|
+
crossOrigin: "anonymous",
|
|
107
|
+
playsInline: true,
|
|
108
|
+
muted: muted,
|
|
109
|
+
loop: loop,
|
|
110
|
+
preload: "none",
|
|
111
|
+
onError: handleVideoElementError,
|
|
112
|
+
__self: void 0,
|
|
113
|
+
__source: {
|
|
114
|
+
fileName: _jsxFileName,
|
|
115
|
+
lineNumber: 118,
|
|
116
|
+
columnNumber: 7
|
|
117
|
+
}
|
|
118
|
+
}), VideoPosterImage);
|
|
119
|
+
};
|
|
120
|
+
var _default = exports.default = Video;
|
|
121
|
+
//# sourceMappingURL=Video.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","_interopRequireWildcard","require","_VideoModule","_interopRequireDefault","_utils","_customElementInit","_image","_jsxFileName","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","window","document","readyState","addEventListener","initCustomElement","initImageCustomElement","once","Video","props","motionPart","videoRef","videoMedia","muted","loop","autoplay","playbackRate","posterEffect","id","qualityPolicy","focalPoint","onError","wowVideoRef","useRef","videoInfoString","useMemo","sortedQualities","sortQualities","sources","JSON","stringify","VideoPosterImage","poster","createElement","Image","_extends2","displayMode","alt","name","quality","undefined","__self","__source","fileName","lineNumber","columnNumber","handleVideoElementError","useCallback","event","_videoElement$error","videoElement","currentTarget","error","Error","message","handleAdaptiveVideoError","_event$detail","detail","useEffect","element","current","removeEventListener","ref","class","styles","videoContainer","className","video","crossOrigin","playsInline","preload","_default","exports"],"sources":["../../src/Video.tsx"],"sourcesContent":["import * as React from 'react';\nimport type { VideoProps } from './types';\nimport styles from './Video.module.scss';\nimport { sortQualities } from './custom-element/utils';\nimport { initCustomElement } from './customElementInit';\nimport { Image, initCustomElement as initImageCustomElement } from '@wix/image';\n\nif (typeof window !== 'undefined') {\n if (document.readyState === 'loading') {\n document.addEventListener(\n 'DOMContentLoaded',\n () => {\n initCustomElement();\n initImageCustomElement();\n },\n {\n once: true,\n },\n );\n } else {\n initCustomElement();\n initImageCustomElement();\n }\n}\n\nconst Video: React.FC<VideoProps> = (props) => {\n const {\n motionPart,\n videoRef,\n videoMedia,\n muted,\n loop,\n autoplay,\n playbackRate = 1,\n posterEffect,\n id,\n qualityPolicy = 'proportional',\n focalPoint,\n onError,\n } = props;\n\n const wowVideoRef = React.useRef<HTMLElement>(null);\n\n const videoInfoString = React.useMemo(() => {\n const sortedQualities = sortQualities(videoMedia.sources || []);\n return JSON.stringify({\n ...videoMedia,\n playbackRate,\n posterEffect,\n sources: sortedQualities,\n autoplay,\n qualityPolicy,\n focalPoint,\n });\n }, [\n videoMedia,\n playbackRate,\n posterEffect,\n autoplay,\n qualityPolicy,\n focalPoint,\n ]);\n\n const VideoPosterImage = videoMedia.poster && (\n <Image\n {...videoMedia.poster}\n focalPoint={focalPoint}\n id={`videoPoster_${id}`}\n displayMode=\"fill\"\n alt={videoMedia.name || videoMedia.poster.alt || \"\"}\n quality={\n videoMedia.poster.quality\n ? { quality: videoMedia.poster.quality }\n : undefined\n }\n />\n );\n\n const handleVideoElementError = React.useCallback(\n (event: React.SyntheticEvent<HTMLVideoElement, Event>) => {\n if (onError) {\n const videoElement = event.currentTarget;\n const error = new Error(\n `Video playback error: ${\n videoElement.error?.message || \"Unknown error\"\n }`\n );\n onError(error);\n }\n },\n [onError]\n );\n\n const handleAdaptiveVideoError = React.useCallback(\n (event: any) => {\n if (onError && event.detail?.error) {\n onError(event.detail.error);\n }\n },\n [onError]\n );\n\n React.useEffect(() => {\n const element = wowVideoRef.current;\n element?.addEventListener(\"videoerror\", handleAdaptiveVideoError);\n return () => {\n element?.removeEventListener(\"videoerror\", handleAdaptiveVideoError);\n };\n }, [onError, handleAdaptiveVideoError]);\n\n return (\n <wow-video\n ref={wowVideoRef}\n data-video-info={videoInfoString}\n data-motion-part={motionPart || ''}\n class={styles.videoContainer}\n >\n <video\n ref={videoRef}\n className={styles.video}\n crossOrigin=\"anonymous\"\n playsInline={true}\n muted={muted}\n loop={loop}\n preload=\"none\"\n onError={handleVideoElementError}\n />\n {VideoPosterImage}\n </wow-video>\n );\n};\n\nexport default Video;\n"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,IAAAC,YAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,kBAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AAAgF,IAAAM,YAAA;AAAA,SAAAC,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAT,wBAAAS,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAd,CAAA,oBAAAc,CAAA,OAAAC,cAAA,CAAAC,IAAA,CAAAhB,CAAA,EAAAc,CAAA,SAAAG,CAAA,GAAAP,CAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAb,CAAA,EAAAc,CAAA,UAAAG,CAAA,KAAAA,CAAA,CAAAV,GAA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
+
.video-container {
|
|
2
|
+
width: 100%;
|
|
3
|
+
height: 100%;
|
|
4
|
+
display: block;
|
|
5
|
+
position: relative;
|
|
6
|
+
container-type: size;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.video-poster-img {
|
|
10
|
+
width: 100%;
|
|
11
|
+
height: 100%;
|
|
12
|
+
object-fit: var(--poster-fit, cover);
|
|
13
|
+
object-position: var(--poster-align, center);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.video {
|
|
17
|
+
height: 100%;
|
|
18
|
+
width: 100%;
|
|
19
|
+
top: 0;
|
|
20
|
+
left: 0;
|
|
21
|
+
position: absolute;
|
|
22
|
+
object-fit: var(--video-fit, cover);
|
|
23
|
+
opacity: 0;
|
|
24
|
+
--position-left: calc(50cqw - 1cqh * var(--focal-x, 50) * var(--aspect-ratio, 1));
|
|
25
|
+
--position-top: calc(50cqh - 1cqw * var(--focal-y, 50) / var(--aspect-ratio, 1));
|
|
26
|
+
object-position: clamp(100%, var(--position-left), 0%) clamp(100%, var(--position-top), 0%);
|
|
27
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
exports.__esModule = true;
|
|
5
|
+
exports.default = exports.Default = void 0;
|
|
6
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _index = require("./index");
|
|
9
|
+
var _Container = require("./storybook/Container");
|
|
10
|
+
var _args = require("./storybook/args");
|
|
11
|
+
var _jsxFileName = "/home/builduser/work/5a10c7a05f300a84/packages/video/dist/cjs/Video.stories.tsx";
|
|
12
|
+
const openExperiments = [];
|
|
13
|
+
const urlParams = new URLSearchParams(window.location.search);
|
|
14
|
+
const experimentsParam = urlParams.get('experiments');
|
|
15
|
+
((experimentsParam == null ? void 0 : experimentsParam.split(',')) || []).forEach(experiment => {
|
|
16
|
+
openExperiments.push(experiment);
|
|
17
|
+
});
|
|
18
|
+
var _default = exports.default = {
|
|
19
|
+
title: 'Video',
|
|
20
|
+
component: _index.Video,
|
|
21
|
+
argTypes: _args.argTypes
|
|
22
|
+
};
|
|
23
|
+
const Default = args => {
|
|
24
|
+
const id = 'comp_12345';
|
|
25
|
+
const videoRef = _react.default.useRef(null);
|
|
26
|
+
_react.default.useEffect(() => {
|
|
27
|
+
if (videoRef.current) {
|
|
28
|
+
videoRef.current.load();
|
|
29
|
+
}
|
|
30
|
+
}, [args.autoplay, args.qualityPolicy]);
|
|
31
|
+
const videoProps = {
|
|
32
|
+
loop: Boolean(args.loop),
|
|
33
|
+
muted: Boolean(args.muted),
|
|
34
|
+
playbackRate: args.playbackRate,
|
|
35
|
+
posterEffect: args.posterEffect,
|
|
36
|
+
autoplay: Boolean(args.autoplay),
|
|
37
|
+
videoMedia: _args.sampleVideo.videoMedia,
|
|
38
|
+
id,
|
|
39
|
+
videoRef,
|
|
40
|
+
qualityPolicy: args.qualityPolicy,
|
|
41
|
+
focalPoint: {
|
|
42
|
+
x: args.focalPointX,
|
|
43
|
+
y: args.focalPointY
|
|
44
|
+
},
|
|
45
|
+
onError: error => {
|
|
46
|
+
console.log('Video error:', error);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
return /*#__PURE__*/_react.default.createElement(_Container.Container, {
|
|
50
|
+
width: args.containerWidth,
|
|
51
|
+
height: args.containerHeight,
|
|
52
|
+
__self: void 0,
|
|
53
|
+
__source: {
|
|
54
|
+
fileName: _jsxFileName,
|
|
55
|
+
lineNumber: 63,
|
|
56
|
+
columnNumber: 5
|
|
57
|
+
}
|
|
58
|
+
}, /*#__PURE__*/_react.default.createElement(_index.Video, (0, _extends2.default)({}, videoProps, {
|
|
59
|
+
__self: void 0,
|
|
60
|
+
__source: {
|
|
61
|
+
fileName: _jsxFileName,
|
|
62
|
+
lineNumber: 64,
|
|
63
|
+
columnNumber: 7
|
|
64
|
+
}
|
|
65
|
+
})));
|
|
66
|
+
};
|
|
67
|
+
exports.Default = Default;
|
|
68
|
+
//# sourceMappingURL=Video.stories.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireDefault","require","_index","_Container","_args","_jsxFileName","openExperiments","urlParams","URLSearchParams","window","location","search","experimentsParam","get","split","forEach","experiment","push","_default","exports","default","title","component","Video","argTypes","Default","args","id","videoRef","React","useRef","useEffect","current","load","autoplay","qualityPolicy","videoProps","loop","Boolean","muted","playbackRate","posterEffect","videoMedia","sampleVideo","focalPoint","x","focalPointX","y","focalPointY","onError","error","console","log","createElement","Container","width","containerWidth","height","containerHeight","__self","__source","fileName","lineNumber","columnNumber","_extends2"],"sources":["../../src/Video.stories.tsx"],"sourcesContent":["import React from 'react';\nimport { Meta } from '@wix/yoshi-storybook-dependencies';\nimport { Video } from './index';\nimport { Container } from './storybook/Container';\nimport { argTypes, sampleVideo } from './storybook/args';\nimport type { QualityPolicy, VideoProps } from './types';\n\nconst openExperiments: string[] = [];\n\nconst urlParams = new URLSearchParams(window.location.search);\nconst experimentsParam = urlParams.get('experiments');\n(experimentsParam?.split(',') || []).forEach((experiment) => {\n openExperiments.push(experiment);\n});\n\nexport default {\n title: 'Video',\n component: Video,\n argTypes,\n} as Meta;\n\ntype StoryArgs = {\n qualityPolicy: QualityPolicy;\n uri: string;\n containerHeight: number;\n containerWidth: number;\n loop: boolean;\n muted: boolean;\n autoplay: boolean;\n playbackRate: number;\n posterEffect: 'fade';\n focalPointX: number;\n focalPointY: number;\n};\n\nexport const Default: React.VFC<StoryArgs> = (args) => {\n const id = 'comp_12345';\n const videoRef = React.useRef<HTMLVideoElement>(null);\n\n React.useEffect(() => {\n if (videoRef.current) {\n videoRef.current.load();\n }\n }, [args.autoplay, args.qualityPolicy]);\n\n const videoProps: VideoProps = {\n loop: Boolean(args.loop),\n muted: Boolean(args.muted),\n playbackRate: args.playbackRate,\n posterEffect: args.posterEffect,\n autoplay: Boolean(args.autoplay),\n videoMedia: sampleVideo.videoMedia,\n id,\n videoRef,\n qualityPolicy: args.qualityPolicy,\n focalPoint: { x: args.focalPointX, y: args.focalPointY },\n onError: (error) => {\n console.log('Video error:', error);\n },\n };\n\n return (\n <Container width={args.containerWidth} height={args.containerHeight}>\n <Video {...videoProps} />\n </Container>\n );\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AAAyD,IAAAI,YAAA;AAGzD,MAAMC,eAAyB,GAAG,EAAE;AAEpC,MAAMC,SAAS,GAAG,IAAIC,eAAe,CAACC,MAAM,CAACC,QAAQ,CAACC,MAAM,CAAC;AAC7D,MAAMC,gBAAgB,GAAGL,SAAS,CAACM,GAAG,CAAC,aAAa,CAAC;AACrD,CAAC,CAAAD,gBAAgB,oBAAhBA,gBAAgB,CAAEE,KAAK,CAAC,GAAG,CAAC,KAAI,EAAE,EAAEC,OAAO,CAAEC,UAAU,IAAK;EAC3DV,eAAe,CAACW,IAAI,CAACD,UAAU,CAAC;AAClC,CAAC,CAAC;AAAC,IAAAE,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEY;EACbC,KAAK,EAAE,OAAO;EACdC,SAAS,EAAEC,YAAK;EAChBC,QAAQ,EAARA;AACF,CAAC;AAgBM,MAAMC,OAA6B,GAAIC,IAAI,IAAK;EACrD,MAAMC,EAAE,GAAG,YAAY;EACvB,MAAMC,QAAQ,GAAGC,cAAK,CAACC,MAAM,CAAmB,IAAI,CAAC;EAErDD,cAAK,CAACE,SAAS,CAAC,MAAM;IACpB,IAAIH,QAAQ,CAACI,OAAO,EAAE;MACpBJ,QAAQ,CAACI,OAAO,CAACC,IAAI,CAAC,CAAC;IACzB;EACF,CAAC,EAAE,CAACP,IAAI,CAACQ,QAAQ,E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
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
exports.__esModule = true;
|
|
5
|
+
exports.default = void 0;
|
|
6
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
7
|
+
var _videoLayout = _interopRequireDefault(require("./videoLayout"));
|
|
8
|
+
function wowVideoFactory(services, contextWindow) {
|
|
9
|
+
return class WowVideo extends contextWindow.HTMLElement {
|
|
10
|
+
constructor() {
|
|
11
|
+
super();
|
|
12
|
+
(0, _defineProperty2.default)(this, "timeoutId", void 0);
|
|
13
|
+
this.timeoutId = null;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Dispatch a custom error event that bubbles up
|
|
18
|
+
*/
|
|
19
|
+
dispatchVideoError(error) {
|
|
20
|
+
this.dispatchEvent(new CustomEvent('videoerror', {
|
|
21
|
+
detail: {
|
|
22
|
+
error
|
|
23
|
+
},
|
|
24
|
+
bubbles: true
|
|
25
|
+
}));
|
|
26
|
+
}
|
|
27
|
+
attributeChangedCallback(_, oldValue) {
|
|
28
|
+
if (oldValue) {
|
|
29
|
+
this.reLayout();
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
connectedCallback() {
|
|
33
|
+
var _services$intersectio;
|
|
34
|
+
(_services$intersectio = services.intersectionService) == null || _services$intersectio.observe(this);
|
|
35
|
+
}
|
|
36
|
+
disconnectedCallback() {
|
|
37
|
+
this.unobserveIntersect();
|
|
38
|
+
}
|
|
39
|
+
unobserveIntersect() {
|
|
40
|
+
var _services$intersectio2;
|
|
41
|
+
(_services$intersectio2 = services.intersectionService) == null || _services$intersectio2.unobserve(this);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Check if the user prefers reduced motion
|
|
46
|
+
*
|
|
47
|
+
* @returns {boolean} True if reduced motion is preferred
|
|
48
|
+
*/
|
|
49
|
+
isPrefersReducedMotion() {
|
|
50
|
+
return contextWindow.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
51
|
+
}
|
|
52
|
+
reLayout() {
|
|
53
|
+
if (!this.dataset.videoInfo) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
const {
|
|
57
|
+
uri,
|
|
58
|
+
sources,
|
|
59
|
+
adaptiveSources,
|
|
60
|
+
autoplay,
|
|
61
|
+
playbackRate,
|
|
62
|
+
posterEffect,
|
|
63
|
+
qualityPolicy,
|
|
64
|
+
focalPoint,
|
|
65
|
+
duration
|
|
66
|
+
} = JSON.parse(this.dataset.videoInfo);
|
|
67
|
+
const prefersReducedMotion = this.isPrefersReducedMotion();
|
|
68
|
+
const autoPlayAllowed = !prefersReducedMotion && autoplay;
|
|
69
|
+
const videoNode = this.querySelector('video');
|
|
70
|
+
const poster = this.querySelector('img');
|
|
71
|
+
services.mutationService.measure(async () => {
|
|
72
|
+
const measures = await _videoLayout.default.measure(videoNode, this, qualityPolicy, uri, sources, adaptiveSources, duration, error => this.dispatchVideoError(error));
|
|
73
|
+
const {
|
|
74
|
+
needsSrcUpdate,
|
|
75
|
+
patchVideoSource
|
|
76
|
+
} = measures;
|
|
77
|
+
services.mutationService.mutate(() => {
|
|
78
|
+
_videoLayout.default.mutate(poster, videoNode, autoPlayAllowed, needsSrcUpdate, posterEffect, playbackRate, patchVideoSource, sources, focalPoint);
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
static get observedAttributes() {
|
|
83
|
+
return ['data-video-info'];
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
var _default = exports.default = wowVideoFactory;
|
|
88
|
+
//# sourceMappingURL=WowVideo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_videoLayout","_interopRequireDefault","require","wowVideoFactory","services","contextWindow","WowVideo","HTMLElement","constructor","_defineProperty2","default","timeoutId","dispatchVideoError","error","dispatchEvent","CustomEvent","detail","bubbles","attributeChangedCallback","_","oldValue","reLayout","connectedCallback","_services$intersectio","intersectionService","observe","disconnectedCallback","unobserveIntersect","_services$intersectio2","unobserve","isPrefersReducedMotion","matchMedia","matches","dataset","videoInfo","uri","sources","adaptiveSources","autoplay","playbackRate","posterEffect","qualityPolicy","focalPoint","duration","JSON","parse","prefersReducedMotion","autoPlayAllowed","videoNode","querySelector","poster","mutationService","measure","measures","videoLayout","needsSrcUpdate","patchVideoSource","mutate","observedAttributes","_default","exports"],"sources":["../../../src/custom-element/WowVideo.ts"],"sourcesContent":["import videoLayout from './videoLayout';\nimport type { WowVideoServices, Timeout } from '../types';\n\nfunction wowVideoFactory(\n services: WowVideoServices,\n contextWindow: Window & typeof globalThis,\n): any {\n return class WowVideo extends contextWindow.HTMLElement {\n timeoutId: Timeout | null;\n\n constructor() {\n super();\n this.timeoutId = null;\n }\n\n /**\n * Dispatch a custom error event that bubbles up\n */\n dispatchVideoError(error: Error) {\n this.dispatchEvent(\n new CustomEvent('videoerror', {\n detail: { error },\n bubbles: true,\n }),\n );\n }\n\n attributeChangedCallback(_: string, oldValue: string) {\n if (oldValue) {\n this.reLayout();\n }\n }\n\n connectedCallback() {\n services.intersectionService?.observe(this);\n }\n\n disconnectedCallback() {\n this.unobserveIntersect();\n }\n\n unobserveIntersect() {\n services.intersectionService?.unobserve(this);\n }\n\n /**\n * Check if the user prefers reduced motion\n *\n * @returns {boolean} True if reduced motion is preferred\n */\n isPrefersReducedMotion(): boolean {\n return contextWindow.matchMedia('(prefers-reduced-motion: reduce)')\n .matches;\n }\n\n reLayout() {\n if (!this.dataset.videoInfo) {\n return;\n }\n\n const {\n uri,\n sources,\n adaptiveSources,\n autoplay,\n playbackRate,\n posterEffect,\n qualityPolicy,\n focalPoint,\n duration,\n } = JSON.parse(this.dataset.videoInfo);\n\n const prefersReducedMotion = this.isPrefersReducedMotion();\n const autoPlayAllowed = !prefersReducedMotion && autoplay;\n\n const videoNode = this.querySelector('video') as HTMLVideoElement;\n const poster = this.querySelector('img') as HTMLImageElement;\n\n services.mutationService.measure(async () => {\n const measures = await videoLayout.measure(\n videoNode,\n this,\n qualityPolicy,\n uri,\n sources,\n adaptiveSources,\n duration,\n (error: Error) => this.dispatchVideoError(error),\n );\n\n const { needsSrcUpdate, patchVideoSource } = measures;\n services.mutationService.mutate(() => {\n videoLayout.mutate(\n poster,\n videoNode,\n autoPlayAllowed,\n needsSrcUpdate,\n posterEffect,\n playbackRate,\n patchVideoSource,\n sources,\n focalPoint,\n );\n });\n });\n }\n\n static get observedAttributes() {\n return ['data-video-info'];\n }\n };\n}\n\nexport default wowVideoFactory;\n"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,sBAAA,CAAAC,OAAA;AAGA,SAASC,eAAeA,CACtBC,QAA0B,EAC1BC,aAAyC,EACpC;EACL,OAAO,MAAMC,QAAQ,SAASD,aAAa,CAACE,WAAW,CAAC;IAGtDC,WAAWA,CAAA,EAAG;MACZ,KAAK,CAAC,CAAC;MAAC,IAAAC,gBAAA,CAAAC,OAAA;MACR,IAAI,CAACC,SAAS,GAAG,IAAI;IACvB;;IAEA;AACJ;AACA;IACIC,kBAAkBA,CAACC,KAAY,EAAE;MAC/B,IAAI,CAACC,aAAa,CAChB,IAAIC,WAAW,CAAC,YAAY,EAAE;QAC5BC,MAAM,EAAE;UAAEH;QAAM,CAAC;QACjBI,OAAO,EAAE;MACX,CAAC,CACH,CAAC;IACH;IAEAC,wBAAwBA,CAACC,CAAS,EAAEC,QAAgB,EAAE;MACpD,IAAIA,QAAQ,EAAE;QACZ,IAAI,CAACC,QAAQ,CAAC,CAAC;MACjB;IACF;IAEAC,iBAAiBA,CAAA,EAAG;MAAA,IAAAC,qBAAA;MAClB,CAAAA,qBAAA,GAAAnB,QAAQ,CAACoB,mBAAmB,aAA5BD,qBAAA,CAA8BE,OAAO,CAAC,IAAI,CAAC;IAC7C;IAEAC,oBAAoBA,CAAA,EAAG;MACrB,IAAI,CAACC,kBAAkB,CAAC,CAAC;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,MAAM,EACNF,SAAS,EACTD,eAAe,EACfQ,cAAc,EACdf,YAAY,EACZD,YAAY,EACZiB,gBAAgB,EAChBpB,OAAO,EACPM,UACF,CAAC;QACH,CAAC,CAAC;MACJ,CAAC,CAAC;IACJ;IAEA,WAAWgB,kBAAkBA,CAAA,EAAG;MAC9B,OAAO,CAAC,iBAAiB,CAAC;IAC5B;EACF,CAAC;AACH;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAlD,OAAA,GAEcP,eAAe","ignoreList":[]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
exports.__esModule = true;
|
|
5
|
+
exports.init = init;
|
|
6
|
+
var _WowVideo = _interopRequireDefault(require("./WowVideo"));
|
|
7
|
+
var _fastdom = _interopRequireDefault(require("fastdom"));
|
|
8
|
+
function init(contextWindow, services) {
|
|
9
|
+
contextWindow = contextWindow || window;
|
|
10
|
+
const elementName = 'wow-video';
|
|
11
|
+
if (contextWindow.customElements.get(elementName) === undefined) {
|
|
12
|
+
let intersectionObserver;
|
|
13
|
+
if (contextWindow.IntersectionObserver) {
|
|
14
|
+
intersectionObserver = new IntersectionObserver(entries => entries.map(entry => {
|
|
15
|
+
if (entry.isIntersecting) {
|
|
16
|
+
const target = entry.target;
|
|
17
|
+
target.unobserveIntersect();
|
|
18
|
+
target.reLayout();
|
|
19
|
+
}
|
|
20
|
+
return entry;
|
|
21
|
+
}), {
|
|
22
|
+
rootMargin: '50% 100%'
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
const WowVideo = (0, _WowVideo.default)({
|
|
26
|
+
mutationService: _fastdom.default,
|
|
27
|
+
intersectionService: intersectionObserver,
|
|
28
|
+
...services
|
|
29
|
+
}, contextWindow);
|
|
30
|
+
contextWindow.customElements.define(elementName, WowVideo);
|
|
31
|
+
}
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_WowVideo","_interopRequireDefault","require","_fastdom","init","contextWindow","services","window","elementName","customElements","get","undefined","intersectionObserver","IntersectionObserver","entries","map","entry","isIntersecting","target","unobserveIntersect","reLayout","rootMargin","WowVideo","wowVideoFactory","mutationService","fastdom","intersectionService","define"],"sources":["../../../src/custom-element/registry.ts"],"sourcesContent":["import wowVideoFactory from './WowVideo';\nimport fastdom from 'fastdom';\n\nimport type {\n CustomElementServices,\n WowVideo,\n WowVideoServices,\n} from '../types';\n\nexport function init(\n contextWindow: Window & typeof globalThis,\n services: CustomElementServices,\n) {\n contextWindow = contextWindow || window;\n const elementName = 'wow-video';\n\n if (contextWindow.customElements.get(elementName) === undefined) {\n let intersectionObserver: IntersectionObserver | undefined;\n\n if (contextWindow.IntersectionObserver) {\n intersectionObserver = new IntersectionObserver(\n (entries: IntersectionObserverEntry[]) =>\n entries.map((entry) => {\n if (entry.isIntersecting) {\n const target = entry.target as WowVideo;\n target.unobserveIntersect();\n target.reLayout();\n }\n return entry;\n }),\n {\n rootMargin: '50% 100%',\n },\n );\n }\n\n const WowVideo = wowVideoFactory(\n {\n mutationService: fastdom,\n intersectionService: intersectionObserver,\n ...services,\n } as WowVideoServices,\n contextWindow!,\n );\n contextWindow!.customElements.define(elementName, WowVideo);\n }\n\n return;\n}\n"],"mappings":";;;;;AAAA,IAAAA,SAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAF,sBAAA,CAAAC,OAAA;AAQO,SAASE,IAAIA,CAClBC,aAAyC,EACzCC,QAA+B,EAC/B;EACAD,aAAa,GAAGA,aAAa,IAAIE,MAAM;EACvC,MAAMC,WAAW,GAAG,WAAW;EAE/B,IAAIH,aAAa,CAACI,cAAc,CAACC,GAAG,CAACF,WAAW,CAAC,KAAKG,SAAS,EAAE;IAC/D,IAAIC,oBAAsD;IAE1D,IAAIP,aAAa,CAACQ,oBAAoB,EAAE;MACtCD,oBAAoB,GAAG,IAAIC,oBAAoB,CAC5CC,OAAoC,IACnCA,OAAO,CAACC,GAAG,CAAEC,KAAK,IAAK;QACrB,IAAIA,KAAK,CAACC,cAAc,EAAE;UACxB,MAAMC,MAAM,GAAGF,KAAK,CAACE,MAAkB;UACvCA,MAAM,CAACC,kBAAkB,CAAC,CAAC;UAC3BD,MAAM,CAACE,QAAQ,CAAC,CAAC;QACnB;QACA,OAAOJ,KAAK;MACd,CAAC,CAAC,EACJ;QACEK,UAAU,EAAE;MACd,CACF,CAAC;IACH;IAEA,MAAMC,QAAQ,GAAG,IAAAC,iBAAe,EAC9B;MACEC,eAAe,EAAEC,gBAAO;MACxBC,mBAAmB,EAAEd,oBAAoB;MACzC,GAAGN;IACL,CAAC,EACDD,aACF,CAAC;IACDA,aAAa,CAAEI,cAAc,CAACkB,MAAM,CAACnB,WAAW,EAAEc,QAAQ,CAAC;EAC7D;EAEA;AACF","ignoreList":[]}
|