shaka-player 3.2.8 → 3.2.11
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/.github/workflows/build-and-test.yaml +67 -15
- package/.github/workflows/compute-incremental-coverage.py +251 -0
- package/.github/workflows/report-incremental-coverage.yaml +39 -0
- package/.github/workflows/selenium-lab-tests.yaml +44 -1
- package/AUTHORS +1 -1
- package/CHANGELOG.md +37 -0
- package/CONTRIBUTORS +4 -1
- package/README.md +20 -6
- package/demo/common/assets.js +1 -1
- package/demo/index.html +0 -2
- package/demo/main.js +3 -3
- package/dist/controls.css +1 -1
- package/dist/demo.compiled.debug.js +3 -3
- package/dist/demo.compiled.debug.map +2 -2
- package/dist/demo.compiled.js +3 -3
- package/dist/demo.compiled.map +2 -2
- package/dist/deps.js +2 -2
- package/dist/locales.js +29 -29
- package/dist/receiver.compiled.debug.js +1 -1
- package/dist/receiver.compiled.debug.map +1 -1
- package/dist/receiver.compiled.js +1 -1
- package/dist/receiver.compiled.map +1 -1
- package/dist/shaka-player.compiled.d.ts +12 -1
- package/dist/shaka-player.compiled.debug.d.ts +12 -1
- package/dist/shaka-player.compiled.debug.externs.js +49 -38
- package/dist/shaka-player.compiled.debug.js +238 -227
- package/dist/shaka-player.compiled.debug.map +4 -4
- package/dist/shaka-player.compiled.externs.js +49 -38
- package/dist/shaka-player.compiled.js +766 -760
- package/dist/shaka-player.compiled.map +4 -4
- package/dist/shaka-player.ui.d.ts +12 -1
- package/dist/shaka-player.ui.debug.d.ts +12 -1
- package/dist/shaka-player.ui.debug.externs.js +49 -38
- package/dist/shaka-player.ui.debug.js +227 -217
- package/dist/shaka-player.ui.debug.map +4 -4
- package/dist/shaka-player.ui.externs.js +49 -38
- package/dist/shaka-player.ui.js +870 -865
- package/dist/shaka-player.ui.map +4 -4
- package/docs/tutorials/welcome.md +6 -3
- package/karma.conf.js +3 -11
- package/lib/dash/dash_parser.js +5 -0
- package/lib/hls/hls_parser.js +14 -6
- package/lib/media/drm_engine.js +1 -1
- package/lib/media/presentation_timeline.js +24 -1
- package/lib/media/streaming_engine.js +1 -0
- package/lib/player.js +1 -6
- package/lib/polyfill/media_capabilities.js +3 -0
- package/lib/polyfill/videoplaybackquality.js +3 -1
- package/lib/text/cue.js +0 -5
- package/lib/text/simple_text_displayer.js +21 -9
- package/lib/text/ui_text_displayer.js +83 -19
- package/lib/util/buffer_utils.js +3 -0
- package/lib/util/object_utils.js +1 -0
- package/lib/util/platform.js +41 -1
- package/lib/util/stream_utils.js +24 -3
- package/lib/util/string_utils.js +102 -13
- package/maintained-branches.md +15 -0
- package/package.json +6 -5
- package/test/text/simple_text_displayer_unit.js +27 -0
- package/test/text/ui_text_displayer_unit.js +65 -0
- package/test/util/string_utils_unit.js +46 -8
- package/app-engine/README.md +0 -9
- package/app-engine/demo-version-index/README.md +0 -14
- package/app-engine/demo-version-index/app.yaml +0 -2
- package/app-engine/demo-version-index/main.py +0 -162
- package/app-engine/demo-version-index/requirements.txt +0 -6
- package/app-engine/demo-version-index/templates/index.html +0 -114
- package/app-engine/shaka-player-demo/README.md +0 -18
- package/app-engine/shaka-player-demo/app.yaml +0 -61
- package/app-engine/shaka-player-demo/main.py +0 -95
- package/app-engine/shaka-player-demo/posters/10yo.png +0 -0
- package/app-engine/shaka-player-demo/posters/10yo.xcf +0 -0
- package/app-engine/shaka-player-demo/posters/1yo.jpg +0 -0
- package/app-engine/shaka-player-demo/posters/2yo.png +0 -0
- package/app-engine/shaka-player-demo/posters/2yo.xcf +0 -0
- package/app-engine/shaka-player-demo/posters/3yo.png +0 -0
- package/app-engine/shaka-player-demo/posters/3yo.xcf +0 -0
- package/app-engine/shaka-player-demo/posters/4yo.png +0 -0
- package/app-engine/shaka-player-demo/posters/4yo.xcf +0 -0
- package/app-engine/shaka-player-demo/posters/5yo.png +0 -0
- package/app-engine/shaka-player-demo/posters/5yo.xcf +0 -0
- package/app-engine/shaka-player-demo/posters/6yo.png +0 -0
- package/app-engine/shaka-player-demo/posters/6yo.xcf +0 -0
- package/app-engine/shaka-player-demo/posters/7yo.png +0 -0
- package/app-engine/shaka-player-demo/posters/7yo.xcf +0 -0
- package/app-engine/shaka-player-demo/posters/8yo.png +0 -0
- package/app-engine/shaka-player-demo/posters/8yo.xcf +0 -0
- package/app-engine/shaka-player-demo/posters/9yo.png +0 -0
- package/app-engine/shaka-player-demo/posters/9yo.xcf +0 -0
- package/app-engine/shaka-player-demo/posters/audioOnly.gif +0 -0
- package/app-engine/shaka-player-demo/posters/audioRickRoll.gif +0 -0
- package/app-engine/shaka-player-demo/posters/colorbars.gif +0 -0
- package/app-engine/shaka-player-demo/posters/fireworks.jpg +0 -0
- package/app-engine/shaka-player-demo/posters/party-hat.png +0 -0
- package/app-engine/shaka-player-demo/posters/sources.txt +0 -46
- package/app-engine/shaka-player-demo/posters/standard.png +0 -0
- package/app-engine/shaka-player-demo/posters/trek.jpg +0 -0
- package/app-engine/shaka-player-demo/posters/valentines.png +0 -0
- package/app-engine/shaka-player-demo/posters/zombie.jpg +0 -0
- package/app-engine/shaka-player-demo/posters.py +0 -110
- package/app-engine/shaka-player-demo/requirements.txt +0 -5
- package/app-engine/shaka-player-demo/time.txt +0 -1
- package/build/README.md +0 -127
- package/build/__init__.py +0 -0
- package/build/all.py +0 -150
- package/build/apps.py +0 -186
- package/build/build.py +0 -392
- package/build/check.py +0 -354
- package/build/checkversion.py +0 -84
- package/build/compiler.py +0 -513
- package/build/conformance.textproto +0 -321
- package/build/docker/Dockerfile +0 -20
- package/build/docker/docker-compose.yml +0 -10
- package/build/docs.py +0 -54
- package/build/eslint-plugin-shaka-rules/arg-comment-spacing.js +0 -72
- package/build/eslint-plugin-shaka-rules/index.js +0 -24
- package/build/eslint-plugin-shaka-rules/package.json +0 -7
- package/build/eslint-plugin-shaka-rules/private.js +0 -109
- package/build/gendeps.py +0 -71
- package/build/generateExterns.js +0 -867
- package/build/generateLocalizations.py +0 -262
- package/build/generateTsDefs.py +0 -137
- package/build/install-linux-prereqs.sh +0 -136
- package/build/license-header +0 -5
- package/build/misspellings.txt +0 -38
- package/build/pixelsChanged.js +0 -35
- package/build/shaka-lab.yaml +0 -163
- package/build/shakaBuildHelpers.py +0 -356
- package/build/stats.py +0 -816
- package/build/subprocessWindowsPatch.py +0 -103
- package/build/test.py +0 -541
- package/build/types/ads +0 -8
- package/build/types/cast +0 -6
- package/build/types/cea +0 -13
- package/build/types/complete +0 -9
- package/build/types/core +0 -106
- package/build/types/dash +0 -8
- package/build/types/hls +0 -9
- package/build/types/manifests +0 -5
- package/build/types/networking +0 -6
- package/build/types/offline +0 -21
- package/build/types/polyfill +0 -19
- package/build/types/text +0 -11
- package/build/types/ui +0 -37
- package/build/updateScreenshots.py +0 -85
- package/build/wrapper.template.js +0 -52
|
@@ -1,262 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python
|
|
2
|
-
#
|
|
3
|
-
# Copyright 2018 Google LLC
|
|
4
|
-
#
|
|
5
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
# you may not use this file except in compliance with the License.
|
|
7
|
-
# You may obtain a copy of the License at
|
|
8
|
-
#
|
|
9
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
#
|
|
11
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
# See the License for the specific language governing permissions and
|
|
15
|
-
# limitations under the License.
|
|
16
|
-
|
|
17
|
-
"""Generates Javascript to load compile-time localization data.
|
|
18
|
-
|
|
19
|
-
This reads localization data at compile-time in a flat JSON-formatted
|
|
20
|
-
dictionary. The keys are message IDs, and the values are the translated
|
|
21
|
-
strings. For example:
|
|
22
|
-
{
|
|
23
|
-
"BEST_WISHES": "Merin sa haryalye alasse"
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
Each locale's translations are read from a separate file. For example, the path
|
|
27
|
-
the Arabic data would be ui/locales/ar.json.
|
|
28
|
-
"""
|
|
29
|
-
|
|
30
|
-
import argparse
|
|
31
|
-
import contextlib
|
|
32
|
-
import json
|
|
33
|
-
import os
|
|
34
|
-
import sys
|
|
35
|
-
import io
|
|
36
|
-
import shakaBuildHelpers
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
_INDENTATION = ' '
|
|
40
|
-
|
|
41
|
-
# These are Google's "Tier 1" languages as of April 2019.
|
|
42
|
-
DEFAULT_LOCALES = [
|
|
43
|
-
'ar',
|
|
44
|
-
'de',
|
|
45
|
-
'en',
|
|
46
|
-
'en-GB',
|
|
47
|
-
'es',
|
|
48
|
-
'es-419',
|
|
49
|
-
'fr',
|
|
50
|
-
'it',
|
|
51
|
-
'ja',
|
|
52
|
-
'ko',
|
|
53
|
-
'nl',
|
|
54
|
-
'pl',
|
|
55
|
-
'pt-BR',
|
|
56
|
-
'ru',
|
|
57
|
-
'th',
|
|
58
|
-
'tr',
|
|
59
|
-
'zh',
|
|
60
|
-
'zh-TW',
|
|
61
|
-
]
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
class Doc(object):
|
|
65
|
-
"""A string builder class used to build out a tab-sensitive document."""
|
|
66
|
-
|
|
67
|
-
def __init__(self):
|
|
68
|
-
# All the lines that make-up this document.
|
|
69
|
-
self._lines = []
|
|
70
|
-
|
|
71
|
-
# Track each tab we need to insert ahead of the next line.
|
|
72
|
-
self._tab_level = 0
|
|
73
|
-
|
|
74
|
-
@contextlib.contextmanager
|
|
75
|
-
def Block(self):
|
|
76
|
-
"""Starts a new tabbed block.
|
|
77
|
-
|
|
78
|
-
This should be used with |with| to ensure that the block closes.
|
|
79
|
-
"""
|
|
80
|
-
self._tab_level += 1
|
|
81
|
-
yield
|
|
82
|
-
self._tab_level -= 1
|
|
83
|
-
|
|
84
|
-
def Code(self, block):
|
|
85
|
-
"""Insert a block of code with the current tab level.
|
|
86
|
-
|
|
87
|
-
This will add the required leading white space to the line.
|
|
88
|
-
"""
|
|
89
|
-
# Break the code block into each line of code
|
|
90
|
-
lines = block.split('\n')
|
|
91
|
-
|
|
92
|
-
for line in lines:
|
|
93
|
-
# Right-strip the line to avoid trailing white space. We do this on the
|
|
94
|
-
# full string so that tabbing will be removed if a blank line was added.
|
|
95
|
-
new_line = (_INDENTATION * self._tab_level) + line
|
|
96
|
-
self._lines.append(new_line.rstrip())
|
|
97
|
-
|
|
98
|
-
def ToString(self):
|
|
99
|
-
return '\n'.join(self._lines) + '\n'
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
def AsQuotedString(input_string):
|
|
103
|
-
"""Convert |input_string| into a quoted string."""
|
|
104
|
-
subs = [
|
|
105
|
-
('\n', '\\n'),
|
|
106
|
-
('\t', '\\t'),
|
|
107
|
-
("'", "\\'")
|
|
108
|
-
]
|
|
109
|
-
|
|
110
|
-
# Go through each substitution and replace any occurrences.
|
|
111
|
-
output_string = input_string
|
|
112
|
-
for before, after in subs:
|
|
113
|
-
output_string = output_string.replace(before, after)
|
|
114
|
-
|
|
115
|
-
# Lastly wrap the string in quotes.
|
|
116
|
-
return "'%s'" % output_string
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
def GenerateLocalizations(localizations, class_name):
|
|
120
|
-
"""Generates JavaScript code to insert the localization data.
|
|
121
|
-
|
|
122
|
-
This creates a function called "addTo" in the class called |class_name| that,
|
|
123
|
-
when called, will insert the data from |localizations|.
|
|
124
|
-
|
|
125
|
-
Args:
|
|
126
|
-
localizations: A map of string locale name to a map of string tag to the
|
|
127
|
-
string localization.
|
|
128
|
-
class_name: A string name of the class to put generated code into.
|
|
129
|
-
|
|
130
|
-
Returns:
|
|
131
|
-
A string containing the generated code.
|
|
132
|
-
"""
|
|
133
|
-
doc = Doc()
|
|
134
|
-
|
|
135
|
-
doc.Code("""
|
|
136
|
-
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
137
|
-
// This file is auto-generated. DO NOT EDIT THIS FILE. If you need to:
|
|
138
|
-
// - change which locales are in this file, use the --locales option in
|
|
139
|
-
// "build/all.py" or "build/build.py"
|
|
140
|
-
// - change an entry for a specific locale, update "ui/locales/"
|
|
141
|
-
// - change anything else, update "build/generateLocalizations.py".
|
|
142
|
-
//
|
|
143
|
-
// To regenerate this file, run "build/generateLocalizations.py".
|
|
144
|
-
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
145
|
-
""")
|
|
146
|
-
|
|
147
|
-
# Insert a comment that the build scripts will read to determine the freshness
|
|
148
|
-
# of this output. This will be compared against a list of locales in the
|
|
149
|
-
# current build to decide if the output needs to be regenerated.
|
|
150
|
-
# DO NOT change the formatting here without also updating the "compiler.py"
|
|
151
|
-
# module and the "GenerateLocalizations" class's "_locales_changed" method.
|
|
152
|
-
locale_list_string = ', '.join(sorted(localizations.keys()))
|
|
153
|
-
doc.Code('// LOCALES: %s' % locale_list_string)
|
|
154
|
-
|
|
155
|
-
doc.Code("goog.provide('%s');" % class_name)
|
|
156
|
-
doc.Code("goog.require('shaka.ui.Localization');")
|
|
157
|
-
|
|
158
|
-
doc.Code("""
|
|
159
|
-
/**
|
|
160
|
-
* Insert all localization data for the UI into |localization|. This should be
|
|
161
|
-
* done BEFORE any listeners are added to the localization system (to avoid
|
|
162
|
-
* callbacks for each insert) and should be done BEFORE changing to the initial
|
|
163
|
-
* preferred locale (reduces the work needed to update the internal state after
|
|
164
|
-
* each insert).
|
|
165
|
-
*
|
|
166
|
-
* @param {!shaka.ui.Localization} localization
|
|
167
|
-
*/""")
|
|
168
|
-
|
|
169
|
-
doc.Code('%s.addTo = function(localization) {' % class_name)
|
|
170
|
-
|
|
171
|
-
message_ids = set()
|
|
172
|
-
|
|
173
|
-
# Go through the locales in sorted order so that we will be consistent between
|
|
174
|
-
# runs.
|
|
175
|
-
for locale in sorted(localizations.keys()):
|
|
176
|
-
localization = localizations[locale]
|
|
177
|
-
|
|
178
|
-
with doc.Block():
|
|
179
|
-
quoted_locale = AsQuotedString(locale)
|
|
180
|
-
doc.Code('localization.insert(%s, new Map([' % quoted_locale)
|
|
181
|
-
|
|
182
|
-
with doc.Block():
|
|
183
|
-
# Make sure that we sort by the localization keys so that they will
|
|
184
|
-
# always be in the same order.
|
|
185
|
-
for key, value in sorted(localization.items()):
|
|
186
|
-
message_ids.add(key)
|
|
187
|
-
quoted_key = AsQuotedString(key)
|
|
188
|
-
quoted_value = AsQuotedString(value)
|
|
189
|
-
doc.Code('[%s, %s],' % (quoted_key, quoted_value))
|
|
190
|
-
|
|
191
|
-
doc.Code(']));') # Close the call to insert.
|
|
192
|
-
|
|
193
|
-
doc.Code('};') # Close the function.
|
|
194
|
-
|
|
195
|
-
doc.Code("""
|
|
196
|
-
/**
|
|
197
|
-
* @enum {string}
|
|
198
|
-
* @const
|
|
199
|
-
*/
|
|
200
|
-
%s.Ids = {""" % class_name)
|
|
201
|
-
for message_id in message_ids:
|
|
202
|
-
doc.Code(' %s: %s,' % (message_id, AsQuotedString(message_id)))
|
|
203
|
-
doc.Code('};')
|
|
204
|
-
|
|
205
|
-
return doc.ToString()
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
def CreateParser():
|
|
209
|
-
"""Create the argument parser for this application."""
|
|
210
|
-
base = shakaBuildHelpers.get_source_base()
|
|
211
|
-
|
|
212
|
-
parser = argparse.ArgumentParser(
|
|
213
|
-
description=__doc__,
|
|
214
|
-
formatter_class=argparse.RawDescriptionHelpFormatter)
|
|
215
|
-
|
|
216
|
-
parser.add_argument(
|
|
217
|
-
'--locales',
|
|
218
|
-
type=str,
|
|
219
|
-
nargs='+',
|
|
220
|
-
default=DEFAULT_LOCALES,
|
|
221
|
-
help='The list of locales to compile in (default %(default)r)')
|
|
222
|
-
|
|
223
|
-
parser.add_argument(
|
|
224
|
-
'--source',
|
|
225
|
-
type=str,
|
|
226
|
-
default=os.path.join(base, 'ui', 'locales'),
|
|
227
|
-
help='The folder path for JSON inputs')
|
|
228
|
-
|
|
229
|
-
parser.add_argument(
|
|
230
|
-
'--output',
|
|
231
|
-
type=str,
|
|
232
|
-
default=os.path.join(base, 'dist', 'locales.js'),
|
|
233
|
-
help='The file path for JavaScript output')
|
|
234
|
-
|
|
235
|
-
parser.add_argument(
|
|
236
|
-
'--class-name',
|
|
237
|
-
type=str,
|
|
238
|
-
default='shaka.ui.Locales',
|
|
239
|
-
help='The fully qualified class name for the JavaScript output')
|
|
240
|
-
|
|
241
|
-
return parser
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
def main(args):
|
|
245
|
-
parser = CreateParser()
|
|
246
|
-
args = parser.parse_args(args)
|
|
247
|
-
|
|
248
|
-
combined_localizations = {}
|
|
249
|
-
for locale in args.locales:
|
|
250
|
-
path = os.path.join(args.source, locale + '.json')
|
|
251
|
-
with io.open(path, 'r', encoding='utf8') as f:
|
|
252
|
-
combined_localizations[locale] = json.load(f)
|
|
253
|
-
|
|
254
|
-
doc = GenerateLocalizations(combined_localizations, args.class_name)
|
|
255
|
-
with open(args.output, 'wb') as f:
|
|
256
|
-
f.write(doc.encode('utf-8'))
|
|
257
|
-
|
|
258
|
-
return args.output
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
if __name__ == '__main__':
|
|
262
|
-
main(sys.argv[1:])
|
package/build/generateTsDefs.py
DELETED
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python
|
|
2
|
-
#
|
|
3
|
-
# Copyright 2016 Google LLC
|
|
4
|
-
#
|
|
5
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
# you may not use this file except in compliance with the License.
|
|
7
|
-
# You may obtain a copy of the License at
|
|
8
|
-
#
|
|
9
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
#
|
|
11
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
# See the License for the specific language governing permissions and
|
|
15
|
-
# limitations under the License.
|
|
16
|
-
|
|
17
|
-
"""Generates TypeScript defs from Closure externs.
|
|
18
|
-
|
|
19
|
-
This uses the Clutz tool from https://github.com/angular/clutz and then performs
|
|
20
|
-
additional transformations to make the generated defs independent of Clutz.
|
|
21
|
-
"""
|
|
22
|
-
|
|
23
|
-
import argparse
|
|
24
|
-
import os
|
|
25
|
-
import re
|
|
26
|
-
import sys
|
|
27
|
-
|
|
28
|
-
import shakaBuildHelpers
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
def GenerateTsDefs(inputs, output):
|
|
32
|
-
"""Generates TypeScript defs from Closure externs.
|
|
33
|
-
|
|
34
|
-
Args:
|
|
35
|
-
inputs: A list of paths to Closure extern files.
|
|
36
|
-
output: A path to a TypeScript def output file.
|
|
37
|
-
"""
|
|
38
|
-
clutz = shakaBuildHelpers.get_node_binary('@teppeis/clutz', 'clutz')
|
|
39
|
-
|
|
40
|
-
command = clutz + [
|
|
41
|
-
'--closure_env', 'BROWSER',
|
|
42
|
-
'--externs',
|
|
43
|
-
] + inputs + [
|
|
44
|
-
'-o', '-',
|
|
45
|
-
]
|
|
46
|
-
|
|
47
|
-
# Get the output of Clutz, then transform it to make it independent of Clutz
|
|
48
|
-
# and usable directly in TypeScript projects.
|
|
49
|
-
contents = shakaBuildHelpers.execute_get_output(command)
|
|
50
|
-
|
|
51
|
-
# Remove the prefix clutz puts on all namespaces.
|
|
52
|
-
contents = contents.replace(b'\xe0\xb2\xa0_\xe0\xb2\xa0.clutz.', b'')
|
|
53
|
-
# Replace "GlobalObject" (from Clutz) with TypeScript-native "object".
|
|
54
|
-
contents = re.sub(br'\bGlobalObject\b', b'object', contents)
|
|
55
|
-
# Remove "Global" from Clutz's Global{Date,Element,Event,EventTarget} and use
|
|
56
|
-
# their original definitions instead.
|
|
57
|
-
contents = re.sub(
|
|
58
|
-
br'\bGlobal(Date|Element|Event|EventTarget)\b', br'\1', contents)
|
|
59
|
-
# Remove "protected", which appears on some fields, and is only supported on
|
|
60
|
-
# methods.
|
|
61
|
-
contents = re.sub(br'^\s*protected ', b'', contents, flags=re.MULTILINE)
|
|
62
|
-
# Clutz really likes EventTargets, so it wants IAdManager to extend it twice.
|
|
63
|
-
contents = contents.replace(
|
|
64
|
-
b'extends EventTarget extends EventTarget',
|
|
65
|
-
b'extends EventTarget')
|
|
66
|
-
# Some types allow you to return a Promise or nothing, but the Clutz output of
|
|
67
|
-
# "Promise | null | undefined" doesn't work in TypeScript. We need to use
|
|
68
|
-
# "Promise | void" instead.
|
|
69
|
-
contents = contents.replace(b'| null | undefined', b'| void')
|
|
70
|
-
# shaka.util.Error extends Error and implements shaka.extern.Error, but this
|
|
71
|
-
# confuses TypeScript when both are called "Error" in context of the namespace
|
|
72
|
-
# declaration for "shaka.util". Therefore we need to declare this
|
|
73
|
-
# "GlobalError" type, which is already referenced by Clutz but never defined.
|
|
74
|
-
global_error_def = b'declare class GlobalError extends Error {}\n\n'
|
|
75
|
-
contents = global_error_def + contents
|
|
76
|
-
# There are some types that implement multiple interfaces, such as IReleasable
|
|
77
|
-
# and Iteratable. Also, there are tools used inside Google that (for some
|
|
78
|
-
# reason) want to convert TS defs _BACK_ into Closure Compiler externs. When
|
|
79
|
-
# that happens, these multiple implementors generate externs with broken
|
|
80
|
-
# @implements annotations. Since this team can't control that process or
|
|
81
|
-
# those tools, we need to adjust our TS defs instead. In these particular
|
|
82
|
-
# cases, thankfully, we can just remove the reference to the IReleasable
|
|
83
|
-
# interface, which is not needed outside the library.
|
|
84
|
-
# TODO: This only covers one very specific pattern, and could be brittle.
|
|
85
|
-
contents = contents.replace(
|
|
86
|
-
b'implements shaka.util.IReleasable , ', b'implements ')
|
|
87
|
-
# Finally, Clutz includes a bunch of basic defs for a browser environment
|
|
88
|
-
# generated from Closure compiler's builtins. Remove these.
|
|
89
|
-
sections = re.split(br'\n(?=// Generated from .*)', contents)
|
|
90
|
-
sections = filter(
|
|
91
|
-
lambda s: not s.startswith(b'// Generated from externs.zip'),
|
|
92
|
-
sections)
|
|
93
|
-
contents = b'\n'.join(sections) + b'\n'
|
|
94
|
-
|
|
95
|
-
license_header_path = os.path.join(
|
|
96
|
-
shakaBuildHelpers.get_source_base(), 'build/license-header')
|
|
97
|
-
|
|
98
|
-
with open(license_header_path, 'rb') as f:
|
|
99
|
-
license_header = f.read()
|
|
100
|
-
|
|
101
|
-
with open(output, 'wb') as f:
|
|
102
|
-
f.write(license_header)
|
|
103
|
-
f.write(b'\n')
|
|
104
|
-
f.write(contents)
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
def CreateParser():
|
|
108
|
-
"""Create the argument parser for this application."""
|
|
109
|
-
base = shakaBuildHelpers.get_source_base()
|
|
110
|
-
|
|
111
|
-
parser = argparse.ArgumentParser(
|
|
112
|
-
description=__doc__,
|
|
113
|
-
formatter_class=argparse.RawDescriptionHelpFormatter)
|
|
114
|
-
|
|
115
|
-
parser.add_argument(
|
|
116
|
-
'--output',
|
|
117
|
-
type=str,
|
|
118
|
-
help='The file path for TypeScripts defs output')
|
|
119
|
-
|
|
120
|
-
parser.add_argument(
|
|
121
|
-
'input',
|
|
122
|
-
type=str,
|
|
123
|
-
nargs='+',
|
|
124
|
-
help='The Closure extern files to be converted to TypeScript defs')
|
|
125
|
-
|
|
126
|
-
return parser
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
def main(args):
|
|
130
|
-
parser = CreateParser()
|
|
131
|
-
args = parser.parse_args(args)
|
|
132
|
-
GenerateTsDefs(args.input, args.output)
|
|
133
|
-
return 0
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
if __name__ == '__main__':
|
|
137
|
-
main(sys.argv[1:])
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
# Installs prerequisites for Shaka Player development on Linux:
|
|
4
|
-
# - Git v1.9+ (to check out the code)
|
|
5
|
-
# - Python v2.7 (to run the build scripts)
|
|
6
|
-
# - Java Runtime Environment v8+ (to run the Closure compiler)
|
|
7
|
-
# - Apache (to serve the Shaka Player demo)
|
|
8
|
-
# - NodeJS v8+ (to run some build deps, such as jsdoc, karma, etc)
|
|
9
|
-
|
|
10
|
-
# Tested on:
|
|
11
|
-
# - Ubuntu 16.04 LTS (Xenial)
|
|
12
|
-
# - Ubuntu 17.10 (Artful)
|
|
13
|
-
# - Debian 9 (Stretch)
|
|
14
|
-
# - gLinux
|
|
15
|
-
|
|
16
|
-
# Tested with:
|
|
17
|
-
# - Fresh install, no nodejs/npm
|
|
18
|
-
# - Standard install of nodejs/npm
|
|
19
|
-
# - Previous install/upgrade of nodejs/npm through n or nvm
|
|
20
|
-
|
|
21
|
-
# Not supported:
|
|
22
|
-
# - Ubuntu 14.04 LTS (Trusty) - Java 7
|
|
23
|
-
# - Debian 8 (Jessie) - Java 7
|
|
24
|
-
# - RHEL/CentOS 6 - python 2.6, git 1.7
|
|
25
|
-
# - RHEL/CentOS 7 - git 1.8
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
# It's best not to run as root or with sudo, because we need to be able to
|
|
29
|
-
# detect node versions installed locally for the user.
|
|
30
|
-
if [[ $EUID == 0 ]]; then
|
|
31
|
-
echo "*****" 1>&2
|
|
32
|
-
echo "Please do not run as root." 1>&2
|
|
33
|
-
echo "This script will use sudo when needed." 1>&2
|
|
34
|
-
echo "*****" 1>&2
|
|
35
|
-
exit 1
|
|
36
|
-
fi
|
|
37
|
-
|
|
38
|
-
# Make sure this is an OS we can support.
|
|
39
|
-
# "which apt" will return success if apt is found.
|
|
40
|
-
if ! which apt &>/dev/null; then
|
|
41
|
-
echo "*****" 1>&2
|
|
42
|
-
echo "Could not find apt. Unsupported Linux distribution!" 1>&2
|
|
43
|
-
echo "*****" 1>&2
|
|
44
|
-
exit 1
|
|
45
|
-
fi
|
|
46
|
-
|
|
47
|
-
# Exit if any command fails.
|
|
48
|
-
set -e
|
|
49
|
-
|
|
50
|
-
# Install prerequisites other than nodejs. These package names work for both
|
|
51
|
-
# Ubuntu and Debian, and may work for other derivatives as well.
|
|
52
|
-
echo "*****" 1>&2
|
|
53
|
-
echo "Updating packages and installing git, Python, JRE, and Apache." 1>&2
|
|
54
|
-
echo "*****" 1>&2
|
|
55
|
-
sudo apt -y update
|
|
56
|
-
sudo apt -y install git python2.7 default-jre-headless apache2
|
|
57
|
-
|
|
58
|
-
# NodeJS in Ubuntu and Debian is often out of date, so we may need to grab a
|
|
59
|
-
# newer version. We require v8+.
|
|
60
|
-
|
|
61
|
-
if node --version 2>/dev/null | grep -q 'v\([89]\|1[0-9]\)'; then
|
|
62
|
-
echo "*****" 1>&2
|
|
63
|
-
echo "NodeJS v8+ detected. No update needed." 1>&2
|
|
64
|
-
echo "*****" 1>&2
|
|
65
|
-
else
|
|
66
|
-
if node --version &>/dev/null; then
|
|
67
|
-
echo "*****" 1>&2
|
|
68
|
-
echo "Old NodeJS version detected: $(node --version)." 1>&2
|
|
69
|
-
echo "A newer version is needed." 1>&2
|
|
70
|
-
echo "*****" 1>&2
|
|
71
|
-
read -r -p "Remove the existing version and install a new one? [Y/n] "
|
|
72
|
-
if [[ $REPLY =~ ^[Yy] ]] || [[ $REPLY == "" ]]; then
|
|
73
|
-
echo "*****" 1>&2
|
|
74
|
-
echo "Removing existing copies of nodejs." 1>&2
|
|
75
|
-
echo "*****" 1>&2
|
|
76
|
-
|
|
77
|
-
# Remove any old packaged copy of nodejs/npm. Some of these commands may
|
|
78
|
-
# fail, for example if a package does not exist. Ignore errors here.
|
|
79
|
-
sudo apt -y remove --purge nodejs || true
|
|
80
|
-
sudo apt -y remove --purge nodejs-dev || true
|
|
81
|
-
sudo apt -y remove --purge npm || true
|
|
82
|
-
sudo apt -y remove --purge libnode || true
|
|
83
|
-
sudo apt -y remove --purge libnode64 || true
|
|
84
|
-
sudo apt -y autoremove || true
|
|
85
|
-
|
|
86
|
-
# Remove any old symlinks or other copies.
|
|
87
|
-
sudo rm -f /usr/local/bin/node{,js} /usr/bin/node{,js}
|
|
88
|
-
sudo rm -f /usr/local/bin/npm /usr/bin/npm
|
|
89
|
-
|
|
90
|
-
# Remove any copies installed by "n".
|
|
91
|
-
sudo rm -rf /usr/local/n
|
|
92
|
-
# Remove any copies installed by "nvm".
|
|
93
|
-
if [[ ! -e "$NVM_DIR" ]]; then
|
|
94
|
-
NVM_DIR="$HOME/.nvm"
|
|
95
|
-
fi
|
|
96
|
-
# Safety check: before wiping out NVM_DIR, make sure it contains nvm.sh,
|
|
97
|
-
# so we don't somehow get tricked into rm -rf /
|
|
98
|
-
if [[ -e "$NVM_DIR" ]] && [[ -e "$NVM_DIR"/nvm.sh ]]; then
|
|
99
|
-
rm -rf "$NVM_DIR"
|
|
100
|
-
sed -i '/NVM_DIR/d' ~/.bashrc
|
|
101
|
-
fi
|
|
102
|
-
else
|
|
103
|
-
echo "*****" 1>&2
|
|
104
|
-
echo "You will need to upgrade NodeJS yourself to v8+." 1>&2
|
|
105
|
-
echo "*****" 1>&2
|
|
106
|
-
exit 1
|
|
107
|
-
fi
|
|
108
|
-
else
|
|
109
|
-
echo "*****" 1>&2
|
|
110
|
-
echo "NodeJS not found. We will install an up-to-date version for you." 1>&2
|
|
111
|
-
echo "*****" 1>&2
|
|
112
|
-
fi
|
|
113
|
-
|
|
114
|
-
available_node_version=$(apt-cache show nodejs \
|
|
115
|
-
| grep '^Version:' | cut -f 2 -d ' ')
|
|
116
|
-
available_node_major_version=$(echo "$available_node_version" \
|
|
117
|
-
| cut -f 1 -d '.')
|
|
118
|
-
if [ "$available_node_major_version" -gt "8" ]; then
|
|
119
|
-
sudo apt -y install nodejs npm
|
|
120
|
-
echo "*****" 1>&2
|
|
121
|
-
echo "NodeJS v$available_node_version installed from your distro." 1>&2
|
|
122
|
-
echo "*****" 1>&2
|
|
123
|
-
else
|
|
124
|
-
# Fetch a known-good copy of NodeJS from nodesource.com and install it.
|
|
125
|
-
# NodeJS v10.19.0 has npm v6.13.4.
|
|
126
|
-
deb_file=$(mktemp --suffix .deb)
|
|
127
|
-
curl -o "$deb_file" \
|
|
128
|
-
https://deb.nodesource.com/node_10.x/pool/main/n/nodejs/nodejs_10.19.0-1nodesource1_amd64.deb
|
|
129
|
-
sudo dpkg -i "$deb_file"
|
|
130
|
-
rm -f "$deb_file"
|
|
131
|
-
|
|
132
|
-
echo "*****" 1>&2
|
|
133
|
-
echo "NodeJS v10.19 installed from nodesource." 1>&2
|
|
134
|
-
echo "*****" 1>&2
|
|
135
|
-
fi
|
|
136
|
-
fi
|
package/build/license-header
DELETED
package/build/misspellings.txt
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
# A map of a regex to the suggested replacement. The replacement can include
|
|
2
|
-
# capture groups from the regex and will be ignored if the replacement is the
|
|
3
|
-
# same as the match.
|
|
4
|
-
{
|
|
5
|
-
r'(?i)arti?fi?ci?ai?l': 'artificial',
|
|
6
|
-
r'(?i)cur+ent': 'current',
|
|
7
|
-
r"(?i)doens?'t": "doesn't",
|
|
8
|
-
r'(?i)ful+screen': 'fullscreen',
|
|
9
|
-
r'(?i)futher': 'further',
|
|
10
|
-
r'(?i)gene?ra?tor': 'generator',
|
|
11
|
-
r'(?i)(?:(in|)n*)ac+ur+ate': r'\1accurate',
|
|
12
|
-
r'(?i)in?ter[ai]ble': 'iterable',
|
|
13
|
-
r'(?i)int(er|re)p(er|re)tation': 'interpretation',
|
|
14
|
-
r'(?i)langauge': 'language',
|
|
15
|
-
r'(?i)mananger': 'manager',
|
|
16
|
-
r'(?i)mani?fe?st': 'manifest',
|
|
17
|
-
r'(?i)mil+isecond': 'millisecond',
|
|
18
|
-
r'(?i)oc+ur+(?!ed|ing|ence)': 'occur',
|
|
19
|
-
r'(?i)oc+ur+(ed|ing|ence)': r'occurr\1',
|
|
20
|
-
r'(?i)oc+ur+ance': 'occurrence',
|
|
21
|
-
r'(?i)parrent': 'parent',
|
|
22
|
-
r'(?i)pol+yfil+': 'polyfill',
|
|
23
|
-
r'(?i)propogate': 'propagate',
|
|
24
|
-
r'(?i)refrence': 'reference',
|
|
25
|
-
r'(?i)substract': 'subtract',
|
|
26
|
-
# Only match an "s" if it is not part of "spy".
|
|
27
|
-
r'(?i)suc+e(?:(?!spy)s)+': 'success',
|
|
28
|
-
r'(?i)suc+es+ful+(?!y)': 'successful',
|
|
29
|
-
r'(?i)suc+es+ful+y': 'successfully',
|
|
30
|
-
r'(?i)tol+[ae]r+[ae]nce': 'tolerance',
|
|
31
|
-
r'(?i)uncomplied': 'uncompiled',
|
|
32
|
-
r'(?i)udpate': 'update',
|
|
33
|
-
r'(?i)wether': 'whether',
|
|
34
|
-
r'(?i)@returns': '@return',
|
|
35
|
-
r'(?i)varint': 'variant',
|
|
36
|
-
r'(?i)asynchronus': 'asynchronous',
|
|
37
|
-
r'(?i)deafult': 'default',
|
|
38
|
-
}
|
package/build/pixelsChanged.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/*! @license
|
|
3
|
-
* Shaka Player
|
|
4
|
-
* Copyright 2016 Google LLC
|
|
5
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* @fileoverview
|
|
10
|
-
*
|
|
11
|
-
* A node script that uses the Jimp module to compute the number of changed
|
|
12
|
-
* pixels between two images.
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
const Jimp = require('jimp');
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Compare two images and output the number of changed pixels. Uses the same
|
|
19
|
-
* node module as the comparisons done in the tests through Karma.
|
|
20
|
-
*
|
|
21
|
-
* @param {string} oldPath
|
|
22
|
-
* @param {string} newPath
|
|
23
|
-
*/
|
|
24
|
-
async function main(oldPath, newPath) {
|
|
25
|
-
const oldImage = await Jimp.read(oldPath);
|
|
26
|
-
const newImage = await Jimp.read(newPath);
|
|
27
|
-
const diff = Jimp.diff(oldImage, newImage, /* threshold= */ 0.07);
|
|
28
|
-
// "percent" is, surprisingly, a number between 0 and 1, not between 0 and
|
|
29
|
-
// 100. Convert this to a number of pixels.
|
|
30
|
-
const pixelsChanged =
|
|
31
|
-
diff.percent * diff.image.bitmap.width * diff.image.bitmap.height;
|
|
32
|
-
console.log(pixelsChanged);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
main(process.argv[2], process.argv[3]);
|