There's no requirement that "+" characters not be used in URLs. In fact,
if you start up `python3 -m http.server` and point your browser at
`http://localhost:8000/foo+bar?bar+baz=baz+bar`, you'll see every one of
those "+" symbols sent directly to the server without encoding at all.
There is an old convention in CGI parameters to turn " " into "+", but
proper URL encoding turns " " into "%20".
The URI parser we use was assuming that "+" is always an escaped " ". So
it would decode "+" into " " and then later re-encode it into "%20".
By removing the special treatment of "+" in the URI parser, we make
requests to the correct URLs when they involve "+".
Fixes#8713
There was a potential type error in an edge case in lib/player.js. It
would have been caught by the latest compiler, so this upgrades the
compiler and fixes another type error in one other place, as well.
This forces the inclusion of the following license headers from
third-party code:
- language-mapping-list (Copyright 2013 Ali Al Dallal)
- goog-uri (Copyright 2006 & 2008 The Closure Library Authors)
The Closure headers have been shortened, since they use the same
Apache-2.0 license as Shaka Player. The other license has been left
in its full form.
Issue #2638
Change-Id: Idea7c0f2cb9eb8039eeb3f64fe5cc27e7cb78006
The Closure Library's base.js, the Closure Compiler, and the Closure
deps-writer are all now loaded via NPM instead of commiting them
directly to the repo. This also updates both the library and compiler
to the latest version: 20200406.
We still have a fork of the Closure Library's URI parser. The latest
upstream version of that has too many dependencies on the rest of the
library to import directly from NPM.
Some internals of the build system have been refactored, and the
"complete" set of files in the build system now includes third_party.
Our forked URI parser does not pass lint checks yet, so the linter
does not run over third_party yet.
A couple of overly-severe sets of compiler checks have been disabled,
since even the latest Closure Library's base.js doesn't pass them.
The script-loader in load.js had to be updated for compatibility with
the new Closure Library. If you don't return "true" now, Closure's
base.js will stop loading subsequent source files.
Some local externs that we had written are now available from the
compiler, so our local copies have been deleted.
A few type-related changes have been made as well, removing casts that
were necessary with the old compiler, but not necessary with the new
one.
Finally, this corrects some type issues in the tests using the new
"typeof" annotation from the compiler. This allows us to type a
variable as a class defined elsewhere. For example, after loading the
compiled library, we can reference compiledShaka.Player, which has the
type "typeof shaka.Player". The compiler can then type-check all uses
of it in the tests.
Closes#2528 (bad polyfill code generated by the old compiler)
Change-Id: I62ec61e82d4edf342b2c576c2d4f89f11562ee65
Various issues with the nullability of number types led to various
fixes, including:
- defaulting a nullable number to 0 to avoid propagating a null value
through calculations
- adding an assertion or runtime check that something is not null
- moving an existing null check to before the calculation
- returning early on null during an iteration
- changing a nullable number to non-nullable
- defaulting to NaN instead of null
These issues were caught by a compiler upgrade.
Issue #2528
Change-Id: I86d516c74a42ee3624c33d7513d2d4c76d3ea589
In many places, the implicit type info was insufficient. For example,
document.createElement returns Element, but the actual return is
always a subclass of Element. In many cases, we need the compiler to
know that a specific subclass is in use, so that it can correctly
check our use of subclass-specific properties. Another common pattern
is confusion between Node and Element (which is a subclass of Node).
Almost all of the changes in the demo and UI are Element-related.
In some places, we referred to HTMLMediaElement, used in the Player
API, instead of the more specific HTMLVideoElement in use in our demo.
Since the demo uses video-specific properties, we must use the more
specific type.
Another case is the use of document.createEvent, which returns Event
according to the compiler, but in reality always returns a subclass,
like CustomEvent.
In one case in NetworkingEngine, correcting the type of an
AbortableOperation led to the discovery that we had been incorrectly
accessing a private method of that type.
In goog.Uri, there were several instances of "*" for a type, which the
newer compiler won't accept. These have all been corrected.
Finally, in some places, we had the wrong nullability on a type.
These were all caught by a compiler upgrade.
Issue #2528
Change-Id: I7f2d070e3da32fe9ff5f444315649f3cbdb5a4a5
Under Windows, the default encoding isn't UTF-8, so we are getting
encoding errors when trying to read files. This adds a helper to
explicitly set the encoding to UTF-8 in Python3. This doesn't really
affect Python2 since it reads the file as byte strings.
We can't use 'locale.setlocale' to fix this since (at least on my
machine) we can't set the encoding to be UTF-8 on Windows.
Fixes#2206
Change-Id: I76e35cc9ae638b433ca61c7bda6478e989bc755a
- Add Kurdish ("ku") to supplement Kurdish-Turkey ("ku-TR")
- Alphabetize Norwegian ("no")
- Normalize case on Chinese ("HANS" and "HANT")
Change-Id: I75ae78b446cdf8a3358da08f4f0474a7eb7f2060
This updates our wrapper in several ways:
- Adds comments and whitespace and meaningful variable names
- Makes the CommonJS loader compatible with Electron, fixing #1463
- Adds a "global" parameter to the inner scope, fixing #1455
- Strips whitespace and comments from the wrapper during the build
The wrapper is much more readable and debuggable, which should help
maintain support for these various module loaders in the future.
Tested and working with the new wrapper:
- CommonJS (NodeJS, etc.)
- AMD (requirejs)
- Electron (loads into global scope without loader, no longer
conflicts with CommonJS)
- ES modules (partially supported, loads into global scope)
Since the wrapper is now fixed in a way that avoids #1455 and
google/closure-compiler#2957, this also reverts
"Patch Closure Compiler to fix polyfill+wrapper",
commit 962ec0a22d.
Closes#1463
Change-Id: I5d3ac056cb8db04dc714afee0cb069f2a45a456d
When using a module wrapper, polyfills inserted by the compiler do not
go to "window", so all internal references to "Symbol" from those
polyfills must go through "$jscomp.global". This patches the compiler
to fix this issue.
Upstream: google/closure-compiler#2957
Closes#1455
Change-Id: Ifb9a4f651f31c3099d660c4b818da8457d89dbbc
This upgrades to the latest compiler release and drops the linter.
Since we adopted it, the closure linter has produced far more problems
than it has caught. It takes no command-line arguments and can't be
configured. Eslint takes care of traditional linting tasks, and it is
unclear what we would stand to gain by conforming to the demands of
newer versions of the closure linter.
This also fixes a few issues caught by the new compiler:
- Type adjustments for the evolving Fetch externs
- Drops our custom extern for AbortController, which the compiler
now has built-in
- Adds a type annotation to player.js to fix a type inference
failure in the new version of the compiler
- Drops more non-nullable annotations on functions, which are
implicitly non-nullable
Change-Id: Ia03936a5426277d970612c0eacef40fbaf6ee35d
This unblocks conversion of tests to async. We ran into issues in
compiler version v20171203 which have already been fixed upstream.
We are not, however, updating the linter. The matching linter version
reports errors about our tests not using goog.require, which we do on
purpose. We will wait to update the linter until we have resolved
that.
This change also fixes issues discovered by the upgraded compiler:
1. Missing property definition in playhead_unit
2. Wrong type name in storage_unit
3. Wrong type name in FakeManifestParser
Change-Id: I4ba3f43e6a6471e182a69c85cfc619de3380c559
This updates jsdoc to the latest version from npm and forks a copy of
the default jsdoc template.
In subsequent commits, we will reapply our customizations to the
template and to a jsdoc plugin.
This also fixes several bad annotations that the new jsdoc failed to
parse.
Issue #1259
Change-Id: I00a47270ea4754e1c96c43ca900d5cf889ab72e6
The eslint configuration is derived from analyzing the style of our
sources as they are now, plus a few tweaks.
In particular, we have disabled checks for undefined variables and use
of console, both of which the compiler handle with greater precision.
The compiler already knows what is defined in the environment through
our externs, and has specific exceptions for the use of console (demo,
tests).
We have also disabled a few checks that we should use, but will
require many changes to the code: no-unused-vars, no-redeclare,
and comma-dangle.
This commit also fixes several types of eslint errors that were easy:
- no-useless-escape (unneccessary escape characters in Regexp)
- no-constant-condition (using true/false/0/1/etc in if/while)
- no-fallthrough (caught an actual bug in one EME polyfill)
- no-irregular-whitespace (we had a UTF-8 nbsp in externs)
- no-cond-assign (using an assignment inside a conditional)
To satisfy stricter provide/require checks in the Closure Compiler
Linter, we will no longer use provide/require at all in tests. We
will still use provide in test utilities (test/test/util/) since it
sets up the namespace for us. But we will not use require there
because there is no deps management for test code.
Issue #1157
Change-Id: Icc44f51feeb568ea7d3980e693e92e560d897afd
This includes a guess at the original forked version of the closure
library and a list of modifications for the things we forked.
Change-Id: I12e1e6dd2e1dcf9f8549328f006020729bc97546
When a class @implements something specific, but also overrides a
low-level Object method like toString(), jsdoc would throw an
exception. This fixes jsdoc so we do not have to add strange
workarounds to the annotations themselves.
Change-Id: If01d6ca58d66bad87f90d6644f561665a5b3004d
This is part of adding a new conformance rule to add additional type
safety. This will disallow using properties of unknown types or using
unknown properties.
The first parts will be fixing errors caused by the new rule. These
are backwards compatible, so can be applied before the rule is enabled.
Once all the errors and bugs are fixed, the rule will be enabled.
Change-Id: Ic37437a1ad2305bc50a814cdcc562e74703222ac
Also changes the jsdoc template for tutorials with children, to give
the tutorial content itself control over how the links to children are
formatted.
Also fixes annotations for the TextParser interface.
Change-Id: I99502f38bf711b74a596ad804d8abdddee5d6f4d
The new compiler complains about our abuse of the shakaDemo class.
For now, we work around it by suppressing the visibility error.
Long term, we should not try to create one class in many files,
but instead refactor into several classes that use each other's
public methods instead of shared private members.
Change-Id: I96fb53f6e7aab115ae94beb34b3c8d675601826e
We were not able to get our externs generated by the Closure compiler.
There were many issues with the Closure-generated externs, including
the order of the externs and the replacement of record types and enums
with their underlying types.
We made a few attempts to patch the compiler, but could not get our
patches accepted upstream.
This change introduces a new script to generate our externs from
scratch. It uses a JavaScript parser called 'esprima'.
Some interfaces need to be exported to the generated externs, but are
not actually attached to the namespace by the compiler. For this, we
introduce a new annotation. These are the currently-supported export
annotations:
- @export: truly exported (attached to namespace) by the compiler
- @expose: truly exposed (not renamed) by the compiler
- @exportDoc: considered part of the exports in the docs
- @exportInterface: considered part of the exports in generated externs
These annotations are now documented in docs/design/export.md
Change-Id: I33bf7384889c14c9edb0fa5f11caa7c4f4d79af6
This adds anchors to enum docs so that we can link directly to an enum
value. This will be useful for linking to error code docs from the
demo app.
Issue #553
Change-Id: I5d3a7bf11588d9ed4bfea2133edc52f99555d957
Now the generated documentation will include the values of enums, not
just the names. This also adds documentation for shaka.log.
Closes#337
Change-Id: Ie45a5f5df8d173e5a4ba08a1807d918c22d5497c
- Add prereqs section
- Add architecture diagrams
- Adjust doc margins
- Change some wording and fix typos
- Convert alert() to console.error() in basic usage tutorial
- Expand prose in debugging tutorial
- Add comments about asynchronous methods
- Expand description of Closure base
- Change some links to source rather than API docs
- Clarify some vague language
- Refactor some of the plugin text
Modified jsdoc to add a new 'linksource' tag to link directly to the
source code for an entity.
Change-Id: I6b879050fc59917ce98954a4fabd8afca60af456
- Update tutorial link in README
- Fix python version in README
- Move jsdoc conf to docs/ folder
- Add API docs main page
- Change style of inline code blocks
- Don't repeat tutorial title in jsdoc template
- (makes it easier to read tutorials on github as MD)
- Add tutorials for:
- Welcome to Shaka
- Basic Usage
- Debugging
- Configuration
- Networking and Buffering Configuration
- DRM Configuration
- License Server Authentication
- Plugins
- Tutorials still to come:
- License Headers and Track Restrictions
- Special Considerations for Live
- v2 Upgrade Guide
Change-Id: I16401c216cf4023d9097750ac7f6090c68bf3c9b
From now on, all record typedefs will be annotated with @property for
each field in the record. This results in better output from jsdoc.
Since the compiler doesn't care about @property, it's up to the linter
to enforce this documentation convention.
Change-Id: I821badf411175ea2a581f6321ca2911a9ef94547
* Move redesign docs to docs/design/
* Put all build output (including closure deps) in dist/
* Restore doc-building scripts
* Fix small doc error in MPD utils
Change-Id: I930f4f976370885b3c3c37c59f1ae7fcc5522413
This also cleans up compiler errors for:
- Things required but not used
- Things used but not required
- Write-only local variables
We are suppressing the 'unnecessaryCasts' error in specific places
where it is, in fact, necessary to convert between unrelated types
for polyfills and work-alikes.
Change-Id: I155c746116f95383ea0a9caf9239fadccd8601af
This allows the app to intercept media requests to modify its URLs.
The callback accepts the URL for the request and returns a modified
URL or null to use the original.
Closes#148
Change-Id: I08352754ace05f318706fd93910097c0fa7696f0
build.sh now accepts several arguments that will disable features
that will not be needed. The default is to include all features.
Part of #116.
--disable-offline
--disable-dash
--disable-http
Change-Id: Icdaf82b322debbdc1e898e93c539e35894678a8d
* Update compiler to v20150609.
* Since v20150315:
* Promise.prototype.catch externs now provided by compiler.
* Iterator externs now provided by compiler.
* Variadic function syntax has changed.
* Since v20150505:
* BufferSource extern now provided by compiler.
* Since v20150609:
* VideoPlaybackQuality extern now provided by compiler.
b/21559591
Change-Id: Ie7d030422e132879e28b1bdf538991a27ebc25df
Name all tutorials in one file.
Ensure that they are displayed in the same order as they are named
in the JSON file.
Change-Id: I013bcd987e564ea9f345dd80bd1497b55296713a