@clappr/hlsjs-playback 2.0.0 → 2.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/dist/hlsjs-playback.esm.js +3 -4
- package/dist/hlsjs-playback.esm.js.map +1 -1
- package/dist/hlsjs-playback.external.js +3 -4
- package/dist/hlsjs-playback.external.js.map +1 -1
- package/dist/hlsjs-playback.external.min.js +1 -1
- package/dist/hlsjs-playback.external.min.js.map +1 -1
- package/dist/hlsjs-playback.js +3 -4
- 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 +5 -4
- package/src/dist.smoke.test.js +27 -33
- package/src/hls.js +2 -3
- package/src/hls.test.js +780 -12
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clappr/hlsjs-playback",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.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",
|
|
@@ -10,8 +10,9 @@
|
|
|
10
10
|
"build": "rollup --config --bundleConfigAsCjs",
|
|
11
11
|
"watch": "rollup --config --bundleConfigAsCjs --watch",
|
|
12
12
|
"bundle-check": "ANALYZE_BUNDLE=true rollup --config --bundleConfigAsCjs",
|
|
13
|
-
"release": "MINIMIZE=true rollup --config --bundleConfigAsCjs",
|
|
14
|
-
"test": "jest ./src --
|
|
13
|
+
"release": "rm -rf dist && MINIMIZE=true rollup --config --bundleConfigAsCjs",
|
|
14
|
+
"test": "jest ./src --coverage --silent",
|
|
15
|
+
"test:smoke": "jest ./src/dist.smoke.test.js --testPathIgnorePatterns=/node_modules/ --silent",
|
|
15
16
|
"test:watch": "jest ./src --watch",
|
|
16
17
|
"lint": "eslint *.js ./src",
|
|
17
18
|
"lint:fix": "yarn lint -- --fix",
|
|
@@ -40,7 +41,7 @@
|
|
|
40
41
|
"hls.js": "1.6.16"
|
|
41
42
|
},
|
|
42
43
|
"devDependencies": {
|
|
43
|
-
"@clappr/core": "^0.
|
|
44
|
+
"@clappr/core": "^0.15.0",
|
|
44
45
|
"@rollup/plugin-replace": "^2.4.2",
|
|
45
46
|
"hls.js": "1.6.16",
|
|
46
47
|
"rollup-plugin-filesize": "^9.1.1",
|
package/src/dist.smoke.test.js
CHANGED
|
@@ -27,11 +27,15 @@ function loadArtifact(name) {
|
|
|
27
27
|
return require(path.join(DIST, name))
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
function resolvePlayback(HlsjsPlaybackExport) {
|
|
31
|
+
return HlsjsPlaybackExport.default || HlsjsPlaybackExport
|
|
32
|
+
}
|
|
33
|
+
|
|
30
34
|
function assertPlaybackContract(HlsjsPlaybackExport) {
|
|
31
35
|
// Must re-require after resetModules so the prototype identity matches the
|
|
32
36
|
// @clappr/core instance the artifact just resolved.
|
|
33
37
|
const { HTML5Video } = require('@clappr/core')
|
|
34
|
-
const Playback = HlsjsPlaybackExport
|
|
38
|
+
const Playback = resolvePlayback(HlsjsPlaybackExport)
|
|
35
39
|
|
|
36
40
|
expect(typeof Playback).toBe('function')
|
|
37
41
|
expect(Object.getPrototypeOf(Playback.prototype)).toBe(HTML5Video.prototype)
|
|
@@ -54,31 +58,13 @@ function assertPlaybackContract(HlsjsPlaybackExport) {
|
|
|
54
58
|
playback.destroy()
|
|
55
59
|
}
|
|
56
60
|
|
|
57
|
-
function
|
|
58
|
-
|
|
59
|
-
expect(source).not.toMatch(/\bZepto\b/)
|
|
60
|
-
expect(source).not.toContain('clappr-core')
|
|
61
|
-
expect(source).not.toContain('@clappr/zepto')
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
function assertDoesNotEmbedHls(source) {
|
|
65
|
-
expect(source).toMatch(/['"]hls\.js['"]/)
|
|
66
|
-
// External builds are ~14–31 KB; 100 KB leaves headroom without matching the
|
|
67
|
-
// ~500 KB+ hls.js-embedded family.
|
|
68
|
-
expect(source.length).toBeLessThan(100000)
|
|
61
|
+
function assertSourceMappingURL(filename) {
|
|
62
|
+
expect(readArtifact(filename)).toContain(`sourceMappingURL=${filename}.map`)
|
|
69
63
|
}
|
|
70
64
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
expect(source.length).toBeGreaterThan(100000)
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
function assertSourceMap(filename) {
|
|
78
|
-
const mapName = `${filename}.map`
|
|
79
|
-
expect(fs.existsSync(path.join(DIST, mapName))).toBe(true)
|
|
80
|
-
expect(readArtifact(filename)).toContain(`sourceMappingURL=${mapName}`)
|
|
81
|
-
}
|
|
65
|
+
const EXPECTED_SOURCEMAPS = Object.values(ARTIFACTS)
|
|
66
|
+
.map(filename => `${filename}.map`)
|
|
67
|
+
.sort()
|
|
82
68
|
|
|
83
69
|
afterEach(() => {
|
|
84
70
|
jest.restoreAllMocks()
|
|
@@ -95,21 +81,29 @@ describe.each([
|
|
|
95
81
|
assertPlaybackContract(loadArtifact(filename))
|
|
96
82
|
})
|
|
97
83
|
|
|
98
|
-
test('
|
|
99
|
-
|
|
84
|
+
test('publishes a sourcemap comment', () => {
|
|
85
|
+
assertSourceMappingURL(filename)
|
|
100
86
|
})
|
|
87
|
+
})
|
|
101
88
|
|
|
102
|
-
|
|
103
|
-
|
|
89
|
+
describe('dist sourcemap inventory', () => {
|
|
90
|
+
test('ships exactly the expected .map files', () => {
|
|
91
|
+
const maps = fs
|
|
92
|
+
.readdirSync(DIST)
|
|
93
|
+
.filter(f => f.endsWith('.map'))
|
|
94
|
+
.sort()
|
|
95
|
+
expect(maps).toEqual(EXPECTED_SOURCEMAPS)
|
|
104
96
|
})
|
|
105
97
|
})
|
|
106
98
|
|
|
107
|
-
describe('hls.js
|
|
108
|
-
test.each(EXTERNAL_HLS)('%s
|
|
109
|
-
|
|
99
|
+
describe('hls.js peer identity', () => {
|
|
100
|
+
test.each(EXTERNAL_HLS)('%s defers to the consumer hls.js', filename => {
|
|
101
|
+
const Playback = resolvePlayback(loadArtifact(filename))
|
|
102
|
+
expect(Playback.HLSJS).toBe(require('hls.js'))
|
|
110
103
|
})
|
|
111
104
|
|
|
112
|
-
test.each(EMBEDS_HLS)('%s embeds hls.js', filename => {
|
|
113
|
-
|
|
105
|
+
test.each(EMBEDS_HLS)('%s embeds its own hls.js copy', filename => {
|
|
106
|
+
const Playback = resolvePlayback(loadArtifact(filename))
|
|
107
|
+
expect(Playback.HLSJS).not.toBe(require('hls.js'))
|
|
114
108
|
})
|
|
115
109
|
})
|
package/src/hls.js
CHANGED
|
@@ -213,7 +213,7 @@ export default class HlsjsPlayback extends HTML5Video {
|
|
|
213
213
|
this._segmentTargetDuration = null
|
|
214
214
|
// #EXT-X-PLAYLIST-TYPE
|
|
215
215
|
this._playlistType = null
|
|
216
|
-
this._recoverAttemptsRemaining = this.options.hlsRecoverAttempts
|
|
216
|
+
this._recoverAttemptsRemaining = this.options.hlsRecoverAttempts ?? DEFAULT_RECOVER_ATTEMPTS
|
|
217
217
|
}
|
|
218
218
|
|
|
219
219
|
_setup() {
|
|
@@ -372,8 +372,7 @@ export default class HlsjsPlayback extends HTML5Video {
|
|
|
372
372
|
}
|
|
373
373
|
|
|
374
374
|
seekPercentage(percentage) {
|
|
375
|
-
|
|
376
|
-
this.seek(seekTo)
|
|
375
|
+
this.seek(this._duration * (percentage / 100))
|
|
377
376
|
}
|
|
378
377
|
|
|
379
378
|
seek(time) {
|