@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clappr/hlsjs-playback",
3
- "version": "2.0.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 --testPathIgnorePatterns=dist.smoke --coverage --silent && yarn release && jest ./src/dist.smoke.test.js --silent",
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.14.8",
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",
@@ -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.default || 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 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)
61
+ function assertSourceMappingURL(filename) {
62
+ expect(readArtifact(filename)).toContain(`sourceMappingURL=${filename}.map`)
69
63
  }
70
64
 
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
- }
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('does not embed @clappr/core or Zepto', () => {
99
- assertDoesNotEmbedCore(readArtifact(filename))
84
+ test('publishes a sourcemap comment', () => {
85
+ assertSourceMappingURL(filename)
100
86
  })
87
+ })
101
88
 
102
- test('publishes a sourcemap', () => {
103
- assertSourceMap(filename)
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 embedding contract', () => {
108
- test.each(EXTERNAL_HLS)('%s does not embed hls.js', filename => {
109
- assertDoesNotEmbedHls(readArtifact(filename))
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
- assertEmbedsHls(readArtifact(filename))
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 || DEFAULT_RECOVER_ATTEMPTS
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
- const seekTo = percentage > 0 ? this._duration * (percentage / 100) : this._duration
376
- this.seek(seekTo)
375
+ this.seek(this._duration * (percentage / 100))
377
376
  }
378
377
 
379
378
  seek(time) {