@clappr/hlsjs-playback 2.0.1 → 3.0.1
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 +21 -15
- package/dist/hlsjs-playback.esm.js +901 -37302
- package/dist/hlsjs-playback.esm.js.map +1 -1
- package/dist/hlsjs-playback.js +888 -37290
- package/dist/hlsjs-playback.js.map +1 -1
- package/dist/hlsjs-playback.min.js +1 -1
- package/dist/hlsjs-playback.min.js.map +1 -1
- package/package.json +4 -5
- package/src/dist.smoke.test.js +42 -10
- package/src/hls.js +4 -0
- package/dist/hlsjs-playback.external.js +0 -732
- package/dist/hlsjs-playback.external.js.map +0 -1
- package/dist/hlsjs-playback.external.min.js +0 -2
- package/dist/hlsjs-playback.external.min.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clappr/hlsjs-playback",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.1",
|
|
4
4
|
"description": "HLS Playback based on hls.js",
|
|
5
5
|
"main": "./dist/hlsjs-playback.js",
|
|
6
6
|
"module": "./dist/hlsjs-playback.esm.js",
|
|
@@ -38,13 +38,12 @@
|
|
|
38
38
|
"homepage": "https://github.com/clappr/hlsjs-playback",
|
|
39
39
|
"peerDependencies": {
|
|
40
40
|
"@clappr/core": "*",
|
|
41
|
-
"hls.js": "1
|
|
41
|
+
"hls.js": "^1"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@clappr/core": "^0.
|
|
44
|
+
"@clappr/core": "^0.16.1",
|
|
45
45
|
"@rollup/plugin-replace": "^2.4.2",
|
|
46
|
-
"hls.js": "1.6.
|
|
47
|
-
"rollup-plugin-filesize": "^9.1.1",
|
|
46
|
+
"hls.js": "~1.6.17",
|
|
48
47
|
"rollup-plugin-serve": "^1.1.0"
|
|
49
48
|
}
|
|
50
49
|
}
|
package/src/dist.smoke.test.js
CHANGED
|
@@ -4,19 +4,25 @@
|
|
|
4
4
|
*/
|
|
5
5
|
const fs = require('fs')
|
|
6
6
|
const path = require('path')
|
|
7
|
+
const vm = require('vm')
|
|
8
|
+
const { TextEncoder, TextDecoder } = require('util')
|
|
9
|
+
|
|
10
|
+
// jest-environment-jsdom omits these; must run before the require below —
|
|
11
|
+
// jsdom's whatwg-url throws on load without TextEncoder/TextDecoder.
|
|
12
|
+
global.TextEncoder = global.TextEncoder || TextEncoder
|
|
13
|
+
global.TextDecoder = global.TextDecoder || TextDecoder
|
|
14
|
+
const { JSDOM } = require('jsdom')
|
|
15
|
+
const { expectNoNativeClasses } = require('../../../test/dist-contract')
|
|
7
16
|
|
|
8
17
|
const DIST = path.join(__dirname, '..', 'dist')
|
|
9
18
|
|
|
10
19
|
const ARTIFACTS = {
|
|
11
20
|
main: 'hlsjs-playback.js',
|
|
12
21
|
mainMin: 'hlsjs-playback.min.js',
|
|
13
|
-
external: 'hlsjs-playback.external.js',
|
|
14
|
-
externalMin: 'hlsjs-playback.external.min.js',
|
|
15
22
|
esm: 'hlsjs-playback.esm.js'
|
|
16
23
|
}
|
|
17
24
|
|
|
18
|
-
const
|
|
19
|
-
const EXTERNAL_HLS = [ARTIFACTS.external, ARTIFACTS.externalMin]
|
|
25
|
+
const UMD_ARTIFACTS = [ARTIFACTS.main, ARTIFACTS.mainMin]
|
|
20
26
|
|
|
21
27
|
function readArtifact(name) {
|
|
22
28
|
return fs.readFileSync(path.join(DIST, name), 'utf8')
|
|
@@ -31,6 +37,21 @@ function resolvePlayback(HlsjsPlaybackExport) {
|
|
|
31
37
|
return HlsjsPlaybackExport.default || HlsjsPlaybackExport
|
|
32
38
|
}
|
|
33
39
|
|
|
40
|
+
function loadUmdInSandbox(filename, { hls } = {}) {
|
|
41
|
+
const code = readArtifact(filename)
|
|
42
|
+
const dom = new JSDOM('<!doctype html><html><body></body></html>', {
|
|
43
|
+
url: 'http://localhost/',
|
|
44
|
+
pretendToBeVisual: true,
|
|
45
|
+
runScripts: 'outside-only'
|
|
46
|
+
})
|
|
47
|
+
const sandbox = dom.getInternalVMContext()
|
|
48
|
+
sandbox.Clappr = require('@clappr/core')
|
|
49
|
+
if (hls !== undefined) sandbox.Hls = hls
|
|
50
|
+
|
|
51
|
+
vm.runInContext(code, sandbox, { filename: path.join(DIST, filename) })
|
|
52
|
+
return sandbox
|
|
53
|
+
}
|
|
54
|
+
|
|
34
55
|
function assertPlaybackContract(HlsjsPlaybackExport) {
|
|
35
56
|
// Must re-require after resetModules so the prototype identity matches the
|
|
36
57
|
// @clappr/core instance the artifact just resolved.
|
|
@@ -73,8 +94,6 @@ afterEach(() => {
|
|
|
73
94
|
describe.each([
|
|
74
95
|
['main UMD', ARTIFACTS.main],
|
|
75
96
|
['main UMD minified', ARTIFACTS.mainMin],
|
|
76
|
-
['external UMD', ARTIFACTS.external],
|
|
77
|
-
['external UMD minified', ARTIFACTS.externalMin],
|
|
78
97
|
['ESM', ARTIFACTS.esm]
|
|
79
98
|
])('%s (%s)', (_label, filename) => {
|
|
80
99
|
test('exports a HlsjsPlayback class that extends HTML5Video and exposes HLSJS', () => {
|
|
@@ -84,6 +103,10 @@ describe.each([
|
|
|
84
103
|
test('publishes a sourcemap comment', () => {
|
|
85
104
|
assertSourceMappingURL(filename)
|
|
86
105
|
})
|
|
106
|
+
|
|
107
|
+
test('does not emit native class syntax', () => {
|
|
108
|
+
expectNoNativeClasses(readArtifact(filename))
|
|
109
|
+
})
|
|
87
110
|
})
|
|
88
111
|
|
|
89
112
|
describe('dist sourcemap inventory', () => {
|
|
@@ -97,13 +120,22 @@ describe('dist sourcemap inventory', () => {
|
|
|
97
120
|
})
|
|
98
121
|
|
|
99
122
|
describe('hls.js peer identity', () => {
|
|
100
|
-
test.each(
|
|
123
|
+
test.each(Object.values(ARTIFACTS))('%s defers to the consumer hls.js', filename => {
|
|
101
124
|
const Playback = resolvePlayback(loadArtifact(filename))
|
|
102
125
|
expect(Playback.HLSJS).toBe(require('hls.js'))
|
|
103
126
|
})
|
|
127
|
+
})
|
|
104
128
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
129
|
+
describe('UMD global.Hls branch', () => {
|
|
130
|
+
test.each(UMD_ARTIFACTS)('%s resolves HLSJS from window.Hls', filename => {
|
|
131
|
+
const hls = require('hls.js')
|
|
132
|
+
const sandbox = loadUmdInSandbox(filename, { hls })
|
|
133
|
+
expect(sandbox.HlsjsPlayback.HLSJS).toBe(hls)
|
|
134
|
+
})
|
|
135
|
+
|
|
136
|
+
test.each(UMD_ARTIFACTS)('%s throws a clear error when window.Hls is missing', filename => {
|
|
137
|
+
expect(() => loadUmdInSandbox(filename)).toThrow(
|
|
138
|
+
'@clappr/hlsjs-playback requires hls.js (^1) to be loaded before it'
|
|
139
|
+
)
|
|
108
140
|
})
|
|
109
141
|
})
|
package/src/hls.js
CHANGED
|
@@ -5,6 +5,10 @@
|
|
|
5
5
|
import { Events, HTML5Video, Log, Playback, PlayerError, Utils } from '@clappr/core'
|
|
6
6
|
import HLSJS from 'hls.js'
|
|
7
7
|
|
|
8
|
+
if (!HLSJS) {
|
|
9
|
+
throw new Error('@clappr/hlsjs-playback requires hls.js (^1) to be loaded before it')
|
|
10
|
+
}
|
|
11
|
+
|
|
8
12
|
const { now, listContainsIgnoreCase } = Utils
|
|
9
13
|
const AUTO = -1
|
|
10
14
|
const DEFAULT_RECOVER_ATTEMPTS = 16
|