@clappr/hlsjs-playback 1.9.13 → 2.0.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 +11 -0
- package/dist/hlsjs-playback.esm.js +1 -0
- package/dist/hlsjs-playback.esm.js.map +1 -0
- package/dist/hlsjs-playback.external.js +1 -0
- package/dist/hlsjs-playback.external.js.map +1 -0
- package/dist/hlsjs-playback.external.min.js +1 -1
- package/dist/hlsjs-playback.external.min.js.map +1 -1
- package/dist/hlsjs-playback.js +1 -0
- package/dist/hlsjs-playback.js.map +1 -0
- package/dist/hlsjs-playback.min.js +1 -1
- package/dist/hlsjs-playback.min.js.map +1 -1
- package/package.json +2 -2
- package/src/dist.smoke.test.js +115 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clappr/hlsjs-playback",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "HLS Playback based on hls.js",
|
|
5
5
|
"main": "./dist/hlsjs-playback.js",
|
|
6
6
|
"module": "./dist/hlsjs-playback.esm.js",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"watch": "rollup --config --bundleConfigAsCjs --watch",
|
|
12
12
|
"bundle-check": "ANALYZE_BUNDLE=true rollup --config --bundleConfigAsCjs",
|
|
13
13
|
"release": "MINIMIZE=true rollup --config --bundleConfigAsCjs",
|
|
14
|
-
"test": "jest ./src --coverage --silent",
|
|
14
|
+
"test": "jest ./src --testPathIgnorePatterns=dist.smoke --coverage --silent && yarn release && jest ./src/dist.smoke.test.js --silent",
|
|
15
15
|
"test:watch": "jest ./src --watch",
|
|
16
16
|
"lint": "eslint *.js ./src",
|
|
17
17
|
"lint:fix": "yarn lint -- --fix",
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Smoke-tests the published dist/ artifacts. Core Jest maps @clappr/core to
|
|
3
|
+
* source, so without this the Rollup entry points have no CI signal.
|
|
4
|
+
*/
|
|
5
|
+
const fs = require('fs')
|
|
6
|
+
const path = require('path')
|
|
7
|
+
|
|
8
|
+
const DIST = path.join(__dirname, '..', 'dist')
|
|
9
|
+
|
|
10
|
+
const ARTIFACTS = {
|
|
11
|
+
main: 'hlsjs-playback.js',
|
|
12
|
+
mainMin: 'hlsjs-playback.min.js',
|
|
13
|
+
external: 'hlsjs-playback.external.js',
|
|
14
|
+
externalMin: 'hlsjs-playback.external.min.js',
|
|
15
|
+
esm: 'hlsjs-playback.esm.js'
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const EMBEDS_HLS = [ARTIFACTS.main, ARTIFACTS.mainMin, ARTIFACTS.esm]
|
|
19
|
+
const EXTERNAL_HLS = [ARTIFACTS.external, ARTIFACTS.externalMin]
|
|
20
|
+
|
|
21
|
+
function readArtifact(name) {
|
|
22
|
+
return fs.readFileSync(path.join(DIST, name), 'utf8')
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function loadArtifact(name) {
|
|
26
|
+
jest.resetModules()
|
|
27
|
+
return require(path.join(DIST, name))
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function assertPlaybackContract(HlsjsPlaybackExport) {
|
|
31
|
+
// Must re-require after resetModules so the prototype identity matches the
|
|
32
|
+
// @clappr/core instance the artifact just resolved.
|
|
33
|
+
const { HTML5Video } = require('@clappr/core')
|
|
34
|
+
const Playback = HlsjsPlaybackExport.default || HlsjsPlaybackExport
|
|
35
|
+
|
|
36
|
+
expect(typeof Playback).toBe('function')
|
|
37
|
+
expect(Object.getPrototypeOf(Playback.prototype)).toBe(HTML5Video.prototype)
|
|
38
|
+
|
|
39
|
+
const HLSJS = Playback.HLSJS
|
|
40
|
+
expect(HLSJS).toBeTruthy()
|
|
41
|
+
expect(typeof HLSJS.isSupported).toBe('function')
|
|
42
|
+
expect(HLSJS.Events).toBeTruthy()
|
|
43
|
+
expect(typeof HLSJS.version).toBe('string')
|
|
44
|
+
expect(HLSJS.version.length).toBeGreaterThan(0)
|
|
45
|
+
|
|
46
|
+
jest.spyOn(HLSJS, 'isSupported').mockReturnValue(true)
|
|
47
|
+
jest.spyOn(window.HTMLMediaElement.prototype, 'load').mockImplementation(() => {})
|
|
48
|
+
|
|
49
|
+
expect(Playback.canPlay('http://example.com/video.m3u8')).toBe(true)
|
|
50
|
+
expect(Playback.canPlay('http://example.com/video.m3u8?token=1')).toBe(true)
|
|
51
|
+
expect(Playback.canPlay('http://example.com/video.mpd')).toBe(false)
|
|
52
|
+
|
|
53
|
+
const playback = new Playback({ src: 'http://example.com/video.m3u8' })
|
|
54
|
+
playback.destroy()
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function assertDoesNotEmbedCore(source) {
|
|
58
|
+
// Same failure mode as the pre-fix min.js shipping a full Clappr + Zepto copy.
|
|
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)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function assertEmbedsHls(source) {
|
|
72
|
+
// Keep until #2538 inverts the default layout — flip deliberately then.
|
|
73
|
+
expect(source).not.toMatch(/require\(['"]hls\.js['"]\)/)
|
|
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
|
+
}
|
|
82
|
+
|
|
83
|
+
afterEach(() => {
|
|
84
|
+
jest.restoreAllMocks()
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
describe.each([
|
|
88
|
+
['main UMD', ARTIFACTS.main],
|
|
89
|
+
['main UMD minified', ARTIFACTS.mainMin],
|
|
90
|
+
['external UMD', ARTIFACTS.external],
|
|
91
|
+
['external UMD minified', ARTIFACTS.externalMin],
|
|
92
|
+
['ESM', ARTIFACTS.esm]
|
|
93
|
+
])('%s (%s)', (_label, filename) => {
|
|
94
|
+
test('exports a HlsjsPlayback class that extends HTML5Video and exposes HLSJS', () => {
|
|
95
|
+
assertPlaybackContract(loadArtifact(filename))
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
test('does not embed @clappr/core or Zepto', () => {
|
|
99
|
+
assertDoesNotEmbedCore(readArtifact(filename))
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
test('publishes a sourcemap', () => {
|
|
103
|
+
assertSourceMap(filename)
|
|
104
|
+
})
|
|
105
|
+
})
|
|
106
|
+
|
|
107
|
+
describe('hls.js embedding contract', () => {
|
|
108
|
+
test.each(EXTERNAL_HLS)('%s does not embed hls.js', filename => {
|
|
109
|
+
assertDoesNotEmbedHls(readArtifact(filename))
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
test.each(EMBEDS_HLS)('%s embeds hls.js', filename => {
|
|
113
|
+
assertEmbedsHls(readArtifact(filename))
|
|
114
|
+
})
|
|
115
|
+
})
|