shaka-player 3.3.7 → 3.3.8

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.
Files changed (119) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/CONTRIBUTORS +2 -0
  3. package/README.md +20 -6
  4. package/demo/index.html +0 -2
  5. package/dist/controls.css +1 -1
  6. package/dist/deps.js +2 -2
  7. package/dist/locales.js +30 -30
  8. package/dist/shaka-player.compiled.d.ts +11 -0
  9. package/dist/shaka-player.compiled.debug.d.ts +11 -0
  10. package/dist/shaka-player.compiled.debug.externs.js +48 -37
  11. package/dist/shaka-player.compiled.debug.js +31 -26
  12. package/dist/shaka-player.compiled.debug.map +4 -4
  13. package/dist/shaka-player.compiled.externs.js +48 -37
  14. package/dist/shaka-player.compiled.js +761 -760
  15. package/dist/shaka-player.compiled.map +4 -4
  16. package/dist/shaka-player.ui.d.ts +11 -0
  17. package/dist/shaka-player.ui.debug.d.ts +11 -0
  18. package/dist/shaka-player.ui.debug.externs.js +48 -37
  19. package/dist/shaka-player.ui.debug.js +33 -28
  20. package/dist/shaka-player.ui.debug.map +4 -4
  21. package/dist/shaka-player.ui.externs.js +48 -37
  22. package/dist/shaka-player.ui.js +876 -875
  23. package/dist/shaka-player.ui.map +4 -4
  24. package/docs/tutorials/welcome.md +6 -3
  25. package/lib/dash/dash_parser.js +5 -0
  26. package/lib/hls/hls_parser.js +6 -2
  27. package/lib/media/presentation_timeline.js +24 -1
  28. package/lib/player.js +1 -1
  29. package/lib/polyfill/media_capabilities.js +1 -0
  30. package/lib/polyfill/videoplaybackquality.js +3 -1
  31. package/lib/util/platform.js +41 -1
  32. package/lib/util/string_utils.js +56 -14
  33. package/maintained-branches.md +15 -0
  34. package/package.json +2 -4
  35. package/app-engine/README.md +0 -9
  36. package/app-engine/demo-version-index/README.md +0 -14
  37. package/app-engine/demo-version-index/app.yaml +0 -2
  38. package/app-engine/demo-version-index/main.py +0 -162
  39. package/app-engine/demo-version-index/requirements.txt +0 -6
  40. package/app-engine/demo-version-index/templates/index.html +0 -114
  41. package/app-engine/shaka-player-demo/README.md +0 -18
  42. package/app-engine/shaka-player-demo/app.yaml +0 -61
  43. package/app-engine/shaka-player-demo/main.py +0 -95
  44. package/app-engine/shaka-player-demo/posters/10yo.png +0 -0
  45. package/app-engine/shaka-player-demo/posters/10yo.xcf +0 -0
  46. package/app-engine/shaka-player-demo/posters/1yo.jpg +0 -0
  47. package/app-engine/shaka-player-demo/posters/2yo.png +0 -0
  48. package/app-engine/shaka-player-demo/posters/2yo.xcf +0 -0
  49. package/app-engine/shaka-player-demo/posters/3yo.png +0 -0
  50. package/app-engine/shaka-player-demo/posters/3yo.xcf +0 -0
  51. package/app-engine/shaka-player-demo/posters/4yo.png +0 -0
  52. package/app-engine/shaka-player-demo/posters/4yo.xcf +0 -0
  53. package/app-engine/shaka-player-demo/posters/5yo.png +0 -0
  54. package/app-engine/shaka-player-demo/posters/5yo.xcf +0 -0
  55. package/app-engine/shaka-player-demo/posters/6yo.png +0 -0
  56. package/app-engine/shaka-player-demo/posters/6yo.xcf +0 -0
  57. package/app-engine/shaka-player-demo/posters/7yo.png +0 -0
  58. package/app-engine/shaka-player-demo/posters/7yo.xcf +0 -0
  59. package/app-engine/shaka-player-demo/posters/8yo.png +0 -0
  60. package/app-engine/shaka-player-demo/posters/8yo.xcf +0 -0
  61. package/app-engine/shaka-player-demo/posters/9yo.png +0 -0
  62. package/app-engine/shaka-player-demo/posters/9yo.xcf +0 -0
  63. package/app-engine/shaka-player-demo/posters/audioOnly.gif +0 -0
  64. package/app-engine/shaka-player-demo/posters/audioRickRoll.gif +0 -0
  65. package/app-engine/shaka-player-demo/posters/colorbars.gif +0 -0
  66. package/app-engine/shaka-player-demo/posters/fireworks.jpg +0 -0
  67. package/app-engine/shaka-player-demo/posters/party-hat.png +0 -0
  68. package/app-engine/shaka-player-demo/posters/sources.txt +0 -46
  69. package/app-engine/shaka-player-demo/posters/standard.png +0 -0
  70. package/app-engine/shaka-player-demo/posters/trek.jpg +0 -0
  71. package/app-engine/shaka-player-demo/posters/valentines.png +0 -0
  72. package/app-engine/shaka-player-demo/posters/zombie.jpg +0 -0
  73. package/app-engine/shaka-player-demo/posters.py +0 -110
  74. package/app-engine/shaka-player-demo/requirements.txt +0 -5
  75. package/app-engine/shaka-player-demo/time.txt +0 -1
  76. package/build/README.md +0 -127
  77. package/build/__init__.py +0 -0
  78. package/build/all.py +0 -150
  79. package/build/apps.py +0 -186
  80. package/build/build.py +0 -392
  81. package/build/check.py +0 -354
  82. package/build/checkversion.py +0 -84
  83. package/build/compiler.py +0 -513
  84. package/build/conformance.textproto +0 -335
  85. package/build/docker/Dockerfile +0 -20
  86. package/build/docker/docker-compose.yml +0 -10
  87. package/build/docs.py +0 -54
  88. package/build/eslint-plugin-shaka-rules/arg-comment-spacing.js +0 -72
  89. package/build/eslint-plugin-shaka-rules/index.js +0 -24
  90. package/build/eslint-plugin-shaka-rules/package.json +0 -7
  91. package/build/eslint-plugin-shaka-rules/private.js +0 -109
  92. package/build/gendeps.py +0 -71
  93. package/build/generateExterns.js +0 -867
  94. package/build/generateLocalizations.py +0 -262
  95. package/build/generateTsDefs.py +0 -137
  96. package/build/install-linux-prereqs.sh +0 -136
  97. package/build/license-header +0 -5
  98. package/build/misspellings.txt +0 -38
  99. package/build/pixelsChanged.js +0 -35
  100. package/build/shaka-lab.yaml +0 -163
  101. package/build/shakaBuildHelpers.py +0 -356
  102. package/build/stats.py +0 -816
  103. package/build/subprocessWindowsPatch.py +0 -103
  104. package/build/test.py +0 -541
  105. package/build/types/ads +0 -8
  106. package/build/types/cast +0 -6
  107. package/build/types/cea +0 -13
  108. package/build/types/complete +0 -9
  109. package/build/types/core +0 -108
  110. package/build/types/dash +0 -8
  111. package/build/types/hls +0 -9
  112. package/build/types/manifests +0 -5
  113. package/build/types/networking +0 -6
  114. package/build/types/offline +0 -22
  115. package/build/types/polyfill +0 -21
  116. package/build/types/text +0 -11
  117. package/build/types/ui +0 -39
  118. package/build/updateScreenshots.py +0 -85
  119. package/build/wrapper.template.js +0 -52
@@ -98,11 +98,14 @@ You can find a full list of available browsers with `--browsers help`, and you
98
98
  can find a complete list of testing options with `--help`.
99
99
 
100
100
 
101
- #### Join the announcement list
101
+ #### Announcements
102
102
 
103
- If you want to receive release or survey announcements, you should join our
103
+ To subscribe to new releases on GitHub, you can follow
104
+ [instructions from this blog](https://www.jessesquires.com/blog/2020/07/30/github-tip-watching-releases/).
105
+
106
+ To receive infrequent announcements and surveys from us, you can join our
104
107
  [mailing list](https://groups.google.com/forum/#!forum/shaka-player-users).
105
- The list is very low volume.
108
+ The list is very low volume, and can only be written to by us.
106
109
 
107
110
 
108
111
  #### Continue the Tutorials
@@ -512,6 +512,11 @@ shaka.dash.DashParser = class {
512
512
  }
513
513
  presentationTimeline.setClockOffset(offset);
514
514
  }
515
+
516
+ // This is the first point where we have a meaningful presentation start
517
+ // time, and we need to tell PresentationTimeline that so that it can
518
+ // maintain consistency from here on.
519
+ presentationTimeline.lockStartTime();
515
520
  } else {
516
521
  // Just update the variants and text streams, which may change as periods
517
522
  // are added or removed.
@@ -549,8 +549,14 @@ shaka.hls.HlsParser = class {
549
549
  for (const stream of streamsToNotify) {
550
550
  this.segmentsToNotifyByStream_.push(stream.segmentIndex.references);
551
551
  }
552
+
552
553
  this.notifySegments_();
553
554
 
555
+ // This is the first point where we have a meaningful presentation start
556
+ // time, and we need to tell PresentationTimeline that so that it can
557
+ // maintain consistency from here on.
558
+ this.presentationTimeline_.lockStartTime();
559
+
554
560
  // This asserts that the live edge is being calculated from segment times.
555
561
  // For VOD and event streams, this check should still pass.
556
562
  goog.asserts.assert(
@@ -1663,8 +1669,6 @@ shaka.hls.HlsParser = class {
1663
1669
  /* presentationStartTime= */ null, /* delay= */ 0);
1664
1670
  this.presentationTimeline_.setStatic(true);
1665
1671
  }
1666
-
1667
- this.notifySegments_();
1668
1672
  }
1669
1673
 
1670
1674
  /**
@@ -93,6 +93,9 @@ shaka.media.PresentationTimeline = class {
93
93
  * @private {number}
94
94
  */
95
95
  this.availabilityTimeOffset_ = 0;
96
+
97
+ /** @private {boolean} */
98
+ this.startTimeLocked_ = false;
96
99
  }
97
100
 
98
101
 
@@ -229,7 +232,8 @@ shaka.media.PresentationTimeline = class {
229
232
  this.maxSegmentEndTime_ =
230
233
  Math.max(this.maxSegmentEndTime_, lastReferenceEndTime);
231
234
 
232
- if (this.presentationStartTime_ != null && this.autoCorrectDrift_) {
235
+ if (this.presentationStartTime_ != null && this.autoCorrectDrift_ &&
236
+ !this.startTimeLocked_) {
233
237
  // Since we have explicit segment end times, calculate a presentation
234
238
  // start based on them. This start time accounts for drift.
235
239
  // Date.now() is in milliseconds, from which we compute "now" in seconds.
@@ -243,6 +247,25 @@ shaka.media.PresentationTimeline = class {
243
247
  }
244
248
 
245
249
 
250
+ /**
251
+ * Lock the presentation timeline's start time. After this is called, no
252
+ * further adjustments to presentationStartTime_ will be permitted.
253
+ *
254
+ * This should be called after all Periods have been parsed, and all calls to
255
+ * notifySegments() from the initial manifest parse have been made.
256
+ *
257
+ * Without this, we can get assertion failures in SegmentIndex for certain
258
+ * DAI content. If DAI adds ad segments to the manifest faster than
259
+ * real-time, adjustments to presentationStartTime_ can cause availability
260
+ * windows to jump around on updates.
261
+ *
262
+ * @export
263
+ */
264
+ lockStartTime() {
265
+ this.startTimeLocked_ = true;
266
+ }
267
+
268
+
246
269
  /**
247
270
  * Gives PresentationTimeline a Stream's minimum segment start time.
248
271
  *
package/lib/player.js CHANGED
@@ -6634,7 +6634,7 @@ shaka.Player.TYPICAL_BUFFERING_THRESHOLD_ = 0.5;
6634
6634
  * @define {string} A version number taken from git at compile time.
6635
6635
  * @export
6636
6636
  */
6637
- shaka.Player.version = 'v3.3.7-uncompiled';
6637
+ shaka.Player.version = 'v3.3.8-uncompiled';
6638
6638
 
6639
6639
  // Initialize the deprecation system using the version string we just set
6640
6640
  // on the player.
@@ -39,6 +39,7 @@ shaka.polyfill.MediaCapabilities = class {
39
39
  // Browsers.
40
40
  if (!shaka.util.Platform.isChromecast() &&
41
41
  !shaka.util.Platform.isApple() &&
42
+ !shaka.util.Platform.isPS4() &&
42
43
  !shaka.util.Platform.isPS5() &&
43
44
  navigator.mediaCapabilities) {
44
45
  shaka.log.info(
@@ -7,6 +7,7 @@
7
7
  goog.provide('shaka.polyfill.VideoPlaybackQuality');
8
8
 
9
9
  goog.require('shaka.polyfill');
10
+ goog.require('shaka.util.Platform');
10
11
 
11
12
 
12
13
  /**
@@ -33,7 +34,8 @@ shaka.polyfill.VideoPlaybackQuality = class {
33
34
  return;
34
35
  }
35
36
 
36
- if ('webkitDroppedFrameCount' in proto) {
37
+ if ('webkitDroppedFrameCount' in proto ||
38
+ shaka.util.Platform.isWebOS3()) {
37
39
  proto.getVideoPlaybackQuality =
38
40
  shaka.polyfill.VideoPlaybackQuality.webkit_;
39
41
  }
@@ -142,6 +142,18 @@ shaka.util.Platform = class {
142
142
  return shaka.util.Platform.userAgentContains_('Web0S');
143
143
  }
144
144
 
145
+ /**
146
+ * Check if the current platform is a WebOS 3.
147
+ *
148
+ * @return {boolean}
149
+ */
150
+ static isWebOS3() {
151
+ // See: http://webostv.developer.lge.com/discover/specifications/web-engine/
152
+ return shaka.util.Platform.userAgentContains_('Web0S') &&
153
+ shaka.util.Platform.userAgentContains_(
154
+ 'Chrome/38.0.2125.122 Safari/537.36');
155
+ }
156
+
145
157
  /**
146
158
  * Check if the current platform is a Google Chromecast.
147
159
  *
@@ -175,7 +187,9 @@ shaka.util.Platform = class {
175
187
  */
176
188
  static isApple() {
177
189
  return !!navigator.vendor && navigator.vendor.includes('Apple') &&
178
- !shaka.util.Platform.isTizen();
190
+ !shaka.util.Platform.isTizen() &&
191
+ !shaka.util.Platform.isEOS() &&
192
+ !shaka.util.Platform.isPS4();
179
193
  }
180
194
 
181
195
  /**
@@ -191,6 +205,13 @@ shaka.util.Platform = class {
191
205
  return shaka.util.Platform.userAgentContains_('PlayStation 5');
192
206
  }
193
207
 
208
+ /**
209
+ * Check if the current platform is Playstation 4.
210
+ */
211
+ static isPS4() {
212
+ return shaka.util.Platform.userAgentContains_('PlayStation 4');
213
+ }
214
+
194
215
  /**
195
216
  * Returns a major version number for Safari, or Safari-based iOS browsers.
196
217
  *
@@ -228,6 +249,25 @@ shaka.util.Platform = class {
228
249
  return null;
229
250
  }
230
251
 
252
+ /**
253
+ * Check if the current platform is Apple Safari
254
+ * or Safari-based iOS browsers.
255
+ *
256
+ * @return {boolean}
257
+ */
258
+ static isSafari() {
259
+ return !!shaka.util.Platform.safariVersion();
260
+ }
261
+
262
+ /**
263
+ * Check if the current platform is an EOS set-top box.
264
+ *
265
+ * @return {boolean}
266
+ */
267
+ static isEOS() {
268
+ return shaka.util.Platform.userAgentContains_('PC=EOS');
269
+ }
270
+
231
271
  /**
232
272
  * Guesses if the platform is a mobile one (iOS or Android).
233
273
  *
@@ -11,6 +11,7 @@ goog.require('shaka.log');
11
11
  goog.require('shaka.util.BufferUtils');
12
12
  goog.require('shaka.util.Error');
13
13
  goog.require('shaka.util.Lazy');
14
+ goog.require('shaka.util.Platform');
14
15
 
15
16
 
16
17
  /**
@@ -36,19 +37,38 @@ shaka.util.StringUtils = class {
36
37
  if (uint8[0] == 0xef && uint8[1] == 0xbb && uint8[2] == 0xbf) {
37
38
  uint8 = uint8.subarray(3);
38
39
  }
39
-
40
- // Use the TextDecoder interface to decode the text. This has the advantage
41
- // compared to the previously-standard decodeUriComponent that it will
42
- // continue parsing even if it finds an invalid UTF8 character, rather than
43
- // stop and throw an error.
44
- const utf8decoder = new TextDecoder();
45
- const decoded = utf8decoder.decode(uint8);
46
- if (decoded.includes('\uFFFD')) {
47
- shaka.log.alwaysError('Decoded string contains an "unknown character" ' +
48
- 'codepoint. That probably means the UTF8 ' +
49
- 'encoding was incorrect!');
40
+ if (window.TextDecoder && !shaka.util.Platform.isPS4()) {
41
+ // Use the TextDecoder interface to decode the text. This has the
42
+ // advantage compared to the previously-standard decodeUriComponent that
43
+ // it will continue parsing even if it finds an invalid UTF8 character,
44
+ // rather than stop and throw an error.
45
+ const utf8decoder = new TextDecoder();
46
+ const decoded = utf8decoder.decode(uint8);
47
+ if (decoded.includes('\uFFFD')) {
48
+ shaka.log.alwaysError('Decoded string contains an "unknown character' +
49
+ '" codepoint. That probably means the UTF8 ' +
50
+ 'encoding was incorrect!');
51
+ }
52
+ return decoded;
53
+ } else {
54
+ // http://stackoverflow.com/a/13691499
55
+ const utf8 = shaka.util.StringUtils.fromCharCode(uint8);
56
+ // This converts each character in the string to an escape sequence. If
57
+ // the character is in the ASCII range, it is not converted; otherwise it
58
+ // is converted to a URI escape sequence.
59
+ // Example: '\x67\x35\xe3\x82\xac' -> 'g#%E3%82%AC'
60
+ const escaped = escape(utf8);
61
+ // Decode the escaped sequence. This will interpret UTF-8 sequences into
62
+ // the correct character.
63
+ // Example: 'g#%E3%82%AC' -> 'g#€'
64
+ try {
65
+ return decodeURIComponent(escaped);
66
+ } catch (e) {
67
+ throw new shaka.util.Error(
68
+ shaka.util.Error.Severity.CRITICAL, shaka.util.Error.Category.TEXT,
69
+ shaka.util.Error.Code.BAD_ENCODING);
70
+ }
50
71
  }
51
- return decoded;
52
72
  }
53
73
 
54
74
 
@@ -141,8 +161,30 @@ shaka.util.StringUtils = class {
141
161
  * @export
142
162
  */
143
163
  static toUTF8(str) {
144
- const utf8Encoder = new TextEncoder();
145
- return shaka.util.BufferUtils.toArrayBuffer(utf8Encoder.encode(str));
164
+ if (window.TextEncoder && !shaka.util.Platform.isPS4()) {
165
+ const utf8Encoder = new TextEncoder();
166
+ return shaka.util.BufferUtils.toArrayBuffer(utf8Encoder.encode(str));
167
+ } else {
168
+ // http://stackoverflow.com/a/13691499
169
+ // Converts the given string to a URI encoded string. If a character
170
+ // falls in the ASCII range, it is not converted; otherwise it will be
171
+ // converted to a series of URI escape sequences according to UTF-8.
172
+ // Example: 'g#€' -> 'g#%E3%82%AC'
173
+ const encoded = encodeURIComponent(str);
174
+ // Convert each escape sequence individually into a character. Each
175
+ // escape sequence is interpreted as a code-point, so if an escape
176
+ // sequence happens to be part of a multi-byte sequence, each byte will
177
+ // be converted to a single character.
178
+ // Example: 'g#%E3%82%AC' -> '\x67\x35\xe3\x82\xac'
179
+ const utf8 = unescape(encoded);
180
+
181
+ const result = new Uint8Array(utf8.length);
182
+ for (let i = 0; i < utf8.length; i++) {
183
+ const item = utf8[i];
184
+ result[i] = item.charCodeAt(0);
185
+ }
186
+ return shaka.util.BufferUtils.toArrayBuffer(result);
187
+ }
146
188
  }
147
189
 
148
190
 
@@ -0,0 +1,15 @@
1
+ # Maintained Shaka Player Branches
2
+
3
+ We are currently maintaining the following branches of Shaka Player:
4
+
5
+ - v4.1 (latest)
6
+ - v4.0 (previous)
7
+ - v3.3 (LTS until April 30, 2023)
8
+ - v3.2 (in use by the Cast Application Framework)
9
+
10
+ Other branches are no longer receiving bug fixes, and we recommend you upgrade
11
+ to a maintained branch. For details on upgrading, please see our
12
+ [upgrade guide](https://shaka-player-demo.appspot.com/docs/api/tutorial-upgrade.html).
13
+
14
+ For more information on how these branches are chosen, please refer to our
15
+ [Branch Maintenance Policy](https://shaka-project.github.io/maintenance/shaka-player.html#branch-maintenance-policy).
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "shaka-player",
3
3
  "description": "DASH/EME video player library",
4
- "version": "3.3.7",
4
+ "version": "3.3.8",
5
5
  "homepage": "https://github.com/shaka-project/shaka-player",
6
6
  "author": "Google",
7
7
  "maintainers": [
@@ -27,7 +27,6 @@
27
27
  "eslint-config-google": "^0.14.0",
28
28
  "eslint-plugin-shaka-rules": "file:./build/eslint-plugin-shaka-rules",
29
29
  "esprima": "^4.0.1",
30
- "fastestsmallesttextencoderdecoder": "^1.0.22",
31
30
  "fontfaceonload": "^1.0.2",
32
31
  "google-closure-compiler-java": "^20220301.0.0",
33
32
  "google-closure-deps": "https://gitpkg.now.sh/google/closure-library/closure-deps?d7736da6",
@@ -50,7 +49,7 @@
50
49
  "less": "https://gitpkg.now.sh/joeyparrish/less.js/packages/less?28c63a43",
51
50
  "less-plugin-clean-css": "github:austingardner/less-plugin-clean-css#4e9e77bf",
52
51
  "material-design-lite": "^1.3.0",
53
- "mux.js": "^6.1.0",
52
+ "mux.js": "^6.2.0",
54
53
  "open-sans-fonts": "^1.6.2",
55
54
  "postcss-less": "^6.0.0",
56
55
  "pwacompat": "^2.0.17",
@@ -71,7 +70,6 @@
71
70
  "dialog-polyfill/dist/dialog-polyfill.js",
72
71
  "eme-encryption-scheme-polyfill/index.js",
73
72
  "es6-promise-polyfill/promise.min.js",
74
- "fastestsmallesttextencoderdecoder/EncoderDecoderTogether.min.js",
75
73
  "google-closure-library/closure/goog/base.js",
76
74
  "less/dist/less.js",
77
75
  "material-design-lite/dist/material.indigo-blue.min.css",
@@ -1,9 +0,0 @@
1
- # Google App Engine Code
2
-
3
- This folder contains source code for the services we run on Google App Engine
4
- (appspot.com).
5
-
6
- - shaka-player-demo: Our hosted demo on https://shaka-player-demo.appspot.com/
7
-
8
- - demo-version-index: An index of Shaka Player releases and demos, hosted at
9
- https://index-dot-shaka-player-demo.appspot.com/
@@ -1,14 +0,0 @@
1
- # Google App Engine Version Index
2
-
3
- This folder contains everything necessary to host an index of Shaka Player
4
- releases and demos at https://index-dot-shaka-player-demo.appspot.com/
5
-
6
- - app.yaml: App Engine config file. Defines the runtime (Python 3).
7
-
8
- - main.py: A python service that queries available versions and generates the
9
- index from a template.
10
-
11
- - requirements.txt: Used by App Engine to install the necessary Python server
12
- requirements (Flask, App Engine API).
13
-
14
- - templates/index.html: A Jinja2 template used to generate the index HTML.
@@ -1,2 +0,0 @@
1
- runtime: python39
2
- default_expiration: 1s
@@ -1,162 +0,0 @@
1
- # Shaka Player Version Index - Appspot Entrypoint
2
- # Copyright 2022 Google LLC
3
- # SPDX-License-Identifier: Apache-2.0
4
-
5
- # Generate an index of Shaka Player versions on appspot.
6
-
7
- import collections
8
- import google.appengine.api.modules
9
- import jinja2
10
- import os
11
- import random
12
- import re
13
-
14
- from flask import Flask, render_template
15
-
16
- DEMO_URL_TEMPLATE = 'https://{0}-dot-shaka-player-demo.appspot.com/'
17
-
18
- # In Google Hosted Libraries
19
- HOSTED_URL_TEMPLATE = 'https://ajax.googleapis.com/ajax/libs/shaka-player/{0}/shaka-player.{1}'
20
-
21
- # Before Google Hosted Libraries, v1 appspot URLs
22
- V1_URL_TEMPLATE = 'https://{0}-dot-shaka-player-demo.appspot.com/shaka-player.{1}'
23
- # Before Google Hosted Libraries, v2 appspot URLs
24
- V2_URL_TEMPLATE = 'https://{0}-dot-shaka-player-demo.appspot.com/dist/shaka-player.{1}'
25
-
26
- def version_to_demo_url(v):
27
- return DEMO_URL_TEMPLATE.format(v.replace('.', '-'))
28
-
29
- def version_to_lib_url(v):
30
- if v == 'nightly':
31
- return V2_URL_TEMPLATE.format(v, 'compiled.js')
32
- elif (version_key(v) == version_key('v1.6.5') or
33
- version_key(v) >= version_key('v2.0.6')):
34
- return HOSTED_URL_TEMPLATE.format(v.replace('v', ''), 'compiled.js')
35
- elif version_key(v) >= version_key('v2.0.0-beta'):
36
- return V2_URL_TEMPLATE.format(v.replace('.', '-'), 'compiled.js')
37
- else:
38
- return V1_URL_TEMPLATE.format(v.replace('.', '-'), 'compiled.js')
39
-
40
- def version_to_ui_lib_url(v):
41
- if v == 'nightly':
42
- return V2_URL_TEMPLATE.format(v, 'ui.js')
43
- elif version_key(v) >= version_key('v2.5.0'):
44
- return HOSTED_URL_TEMPLATE.format(v.replace('v', ''), 'ui.js')
45
- else:
46
- return None
47
-
48
- def version_to_lib_externs_url(v):
49
- if v == 'nightly':
50
- return V2_URL_TEMPLATE.format(v, 'compiled.externs.js')
51
- elif version_key(v) >= version_key('v2.0.6'):
52
- return HOSTED_URL_TEMPLATE.format(v.replace('v', ''), 'compiled.externs.js')
53
- else:
54
- return None
55
-
56
- def version_to_ui_lib_externs_url(v):
57
- if v == 'nightly':
58
- return V2_URL_TEMPLATE.format(v, 'ui.externs.js')
59
- elif version_key(v) >= version_key('v2.5.0'):
60
- return HOSTED_URL_TEMPLATE.format(v.replace('v', ''), 'ui.externs.js')
61
- else:
62
- return None
63
-
64
- def version_to_lib_defs_url(v):
65
- if v == 'nightly':
66
- return V2_URL_TEMPLATE.format(v, 'compiled.d.ts')
67
- elif version_key(v) >= version_key('v3.0.6'):
68
- return HOSTED_URL_TEMPLATE.format(v.replace('v', ''), 'compiled.d.ts')
69
- else:
70
- return None
71
-
72
- def version_to_ui_lib_defs_url(v):
73
- if v == 'nightly':
74
- return V2_URL_TEMPLATE.format(v, 'ui.d.ts')
75
- elif version_key(v) >= version_key('v3.0.6'):
76
- return HOSTED_URL_TEMPLATE.format(v.replace('v', ''), 'ui.d.ts')
77
- else:
78
- return None
79
-
80
- def version_to_metadata(v):
81
- return {
82
- 'version': v,
83
- 'best': False, # Corrected later in another loop
84
- 'demo': version_to_demo_url(v),
85
- 'lib': version_to_lib_url(v),
86
- 'ui_lib': version_to_ui_lib_url(v),
87
- 'lib_externs': version_to_lib_externs_url(v),
88
- 'ui_lib_externs': version_to_ui_lib_externs_url(v),
89
- 'lib_defs': version_to_lib_defs_url(v),
90
- 'ui_lib_defs': version_to_ui_lib_defs_url(v),
91
- }
92
-
93
- def is_release_version(name):
94
- return re.match(r'v\d+-\d+-\d+(?:-.+)?', name)
95
-
96
- def appengine_version_to_package_version(version):
97
- # Replace the first two dashes with dots. More dashes indicate a prerelease
98
- # version, as seen in "v2.0.0-beta3".
99
- return version.replace('-', '.', 2)
100
-
101
- def version_key(version):
102
- if version == 'nightly':
103
- # A false version number for nightly, greater than any actual release
104
- # version.
105
- return [float('inf')]
106
-
107
- assert version[0] == 'v'
108
- main_version, _, suffix = version[1:].partition('-')
109
- if not suffix:
110
- suffix = '}}}' # this puts main releases after prerelease versions
111
- version_tuple = [int(x) for x in main_version.split('.')]
112
- return version_tuple + [suffix]
113
-
114
- def get_appengine_versions():
115
- if os.getenv('GAE_ENV', '').startswith('standard'):
116
- # NOTE: this doesn't return anything useful in a local dev server.
117
- return google.appengine.api.modules.modules.get_versions()
118
-
119
- # For a local dev server, fake it so we can test sorting.
120
- fake_versions = [
121
- 'v1-6-0', 'v1-6-1', 'v1-6-2', 'v1-6-3', 'v1-6-4', 'v1-6-5',
122
- 'v2-0-0-beta', 'v2-0-0-beta2', 'v2-0-0-beta3', 'v2-0-0',
123
- 'v2-1-0', 'v2-1-1', 'v2-1-2',
124
- 'v2-2-1', 'v2-2-2-beta', 'v2-2-2-beta2', 'v2-2-2', 'v2-2-9', 'v2-2-10',
125
- ]
126
- random.shuffle(fake_versions) # in-place shuffle
127
- return fake_versions
128
-
129
-
130
- app = Flask(__name__)
131
-
132
- @app.route('/')
133
- def root():
134
- appengine_versions = get_appengine_versions()
135
- # Filter for release versions only.
136
- appengine_versions = filter(is_release_version, appengine_versions)
137
-
138
- # Now convert from appengine versions (v2-0-0) to package versions (v2.0.0).
139
- versions = list(map(appengine_version_to_package_version, appengine_versions))
140
- # Now sort, putting prerelease versions ahead of the corresponding release.
141
- versions.sort(key=version_key)
142
-
143
- version_metadata = collections.OrderedDict()
144
- latest_by_branch = {}
145
- for v in versions:
146
- version_metadata[v] = version_to_metadata(v)
147
-
148
- # Because |versions| is already sorted, we can just overwrite the entry
149
- # in the latest_by_branch dictionary.
150
- branch_key = tuple(version_key(v)[0:2])
151
- latest_by_branch[branch_key] = v
152
-
153
- for v in latest_by_branch.values():
154
- version_metadata[v]['best'] = True
155
-
156
- # Append nightly rather than filter for it, so that it always appears at the
157
- # end of the list.
158
- version_metadata['nightly'] = version_to_metadata('nightly')
159
- version_metadata['nightly']['best'] = True
160
-
161
- for i in version_metadata.values(): print(i)
162
- return render_template('index.html', versions=version_metadata.values())
@@ -1,6 +0,0 @@
1
- # Shaka Player Version Index - Appspot Python Runtime Requirements
2
- # Copyright 2022 Google LLC
3
- # SPDX-License-Identifier: Apache-2.0
4
-
5
- Flask==2.0.3
6
- appengine-python-standard==0.3.1
@@ -1,114 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>Shaka Player Demo - Version Index</title>
5
- <style>
6
-
7
- #background {
8
- top: 0;
9
- left: 0;
10
- bottom: 0;
11
- right: 0;
12
- position: fixed;
13
- z-index: -1;
14
-
15
- background:
16
- url(https://shaka-player-demo.appspot.com/assets/poster.jpg)
17
- no-repeat center center fixed;
18
- background-size: contain;
19
-
20
- opacity: 0.4;
21
- filter: sepia(50%);
22
- }
23
-
24
- #links {
25
- margin: 20px;
26
- }
27
-
28
- #links a {
29
- margin: 0.5em;
30
- padding: 0.5em;
31
-
32
- border: 2px solid black;
33
- background-color: #006;
34
-
35
- font-size: 110%;
36
- color: white;
37
- font-weight: bold;
38
- text-decoration: none;
39
- }
40
-
41
- table.best tr.old {
42
- display: none;
43
- }
44
-
45
- th, td {
46
- border: 1px solid black;
47
- padding: 0.2em 2em;
48
- }
49
-
50
- table.best tr.best-even,
51
- table.all tr:nth-child(2n) {
52
- background-color: rgba(0,0,0,0.1);
53
- }
54
-
55
- </style>
56
- <script>
57
- function display(which) {
58
- table.class = 'which';
59
- }
60
- </script>
61
- </head>
62
- <body>
63
- <div id="background"></div>
64
-
65
- <h1>Shaka Player release demos on appspot</h1>
66
-
67
- <div id="links">
68
- <a href="#" onclick="table.className = 'best'">Best versions</a>
69
- <a href="#" onclick="table.className = 'all'">All versions</a>
70
- </div>
71
-
72
- <table id="table" class="best">
73
- <tr><th>Version</th></tr>
74
- {% set best_counter = 0 %}
75
- {% for v in versions %}
76
- {% if v.best %}
77
- <tr class="best {{'best-even' if best_counter % 2 == 0 else ''}}">
78
- {% set best_counter = best_counter + 1 %}
79
- {% else %}
80
- <tr class="old">
81
- {% endif %}
82
- <th>{{ v.version }}</th>
83
- <td><a href="{{ v.demo }}">demo</a></td>
84
- <td><a href="{{ v.lib }}">non-UI library</a></td>
85
- <td>
86
- {% if v.ui_lib %}
87
- <a href="{{ v.ui_lib }}">UI-enabled library</a>
88
- {% endif %}
89
- </td>
90
- <td>
91
- {% if v.lib_externs %}
92
- <a href="{{ v.lib_externs }}">non-UI externs</a>
93
- {% endif %}
94
- </td>
95
- <td>
96
- {% if v.ui_lib_externs %}
97
- <a href="{{ v.ui_lib_externs }}">UI-enabled externs</a>
98
- {% endif %}
99
- </td>
100
- <td>
101
- {% if v.lib_defs %}
102
- <a href="{{ v.lib_defs }}">non-UI typescript defs</a>
103
- {% endif %}
104
- </td>
105
- <td>
106
- {% if v.ui_lib_defs %}
107
- <a href="{{ v.ui_lib_defs }}">UI-enabled typescript defs</a>
108
- {% endif %}
109
- </td>
110
- </tr>
111
- {% endfor %}
112
- </table>
113
- </body>
114
- </html>