Commit Graph

56 Commits

Author SHA1 Message Date
Joey Parrish 6ce9cf4ba7 fix: Fix URI encoding with plus characters (#8916)
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
2025-07-24 13:40:47 -07:00
xiao 7331e01064 feat: Shrink the size of language-mapping-list.js (#8526)
This PR helps reducing bundle size. All changes were part of
https://github.com/shaka-project/shaka-player/pull/8520
2025-04-29 10:06:48 +02:00
Álvaro Velad Galván 52fb15d3da chore: Stop using "Object" in goog.Uri annotations (#7953)
Related to #1672
2025-01-27 21:35:39 +01:00
Wojciech Tyczyński 6e55a3b21b build: Forbid using dot in generic types (#7904)
Fixes #2643

Happy reviewing!
2025-01-20 09:39:51 +01:00
Álvaro Velad Galván fda3189fd2 feat(HLS): Add support for QUERYPARAM variable type in #EXT-X-DEFINE (#5801)
Closes https://github.com/shaka-project/shaka-player/issues/5333
2023-10-24 19:55:42 +02:00
Joey Parrish e79c5eb051 chore: Fix typos (#5742)
These typos were reported by an internal tool at Google. This fixes
typos and updates our public tooling to catch future instances of these.
2023-10-06 10:32:30 -07:00
Joey Parrish 28b73b921d fix(hls): Fix type error in lazy-loading (#4687)
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.
2022-11-11 07:07:58 -08:00
Casey Occhialini f27401cc15 fix: Fix duplicate CMCD parameters in HLS live content (#3875)
Use goog.Uri to append CMCD query data to avoid duplicate query params

Fixes #3862

Co-authored-by: Dan Sparacio <daniel.sparacio@cbsinteractive.com>
2022-01-25 14:42:20 -08:00
Joey Parrish 13f3cc3922 fix: Force inclusion of third-party license headers
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
2020-06-09 16:14:38 -07:00
Joey Parrish 1076b78465 Unfork Closure base and update the compiler
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
2020-04-30 19:32:30 -07:00
Joey Parrish 342d35f4f9 Fix issues with nullability of numbers
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
2020-04-30 16:00:00 +00:00
Joey Parrish 07335d79f6 Fix missing or bad type info
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
2020-04-28 16:51:20 -07:00
Jacob Trimble 6ab4e68ff2 Fix default encoding when reading files.
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
2019-10-25 17:23:28 +00:00
Joey Parrish 49cbcefc9c Update language mapping
- Add Kurdish ("ku") to supplement Kurdish-Turkey ("ku-TR")
 - Alphabetize Norwegian ("no")
 - Normalize case on Chinese ("HANS" and "HANT")

Change-Id: I75ae78b446cdf8a3358da08f4f0474a7eb7f2060
2018-12-04 17:29:42 +00:00
Sandra Lokshina 6b1ca2d229 Initial release of Shaka Player UI
Other contributors:
 - @joeyparrish
 - @michellezhuogg
 - @TheModMaker
 - @theodab
 - @vaage

Change-Id: If6df33d9ab5035d1ead4402004f7de37ee8470f4
2018-11-16 14:40:37 -08:00
Joey Parrish 1d27c295ee Fix output wrapper for Electron, ESM, and Closure
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
2018-06-20 17:41:34 +00:00
Joey Parrish 962ec0a22d Patch Closure Compiler to fix polyfill+wrapper
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
2018-05-30 20:58:50 +00:00
Michelle Zhuo 535de4db84 Refactor: Remove underscore from parameter names
Change-Id: Ie9e6fb59763f454f245175f23c6444f919ba8135
2018-05-08 19:21:51 +00:00
Joey Parrish ff082ee9d4 Upgrade closure compiler and drop closure linter
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
2018-04-13 17:49:18 +00:00
Joey Parrish 3e8a83584d Update the compiler to v20180204
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
2018-03-21 13:57:46 -07:00
Joey Parrish ed54199260 Upgrade and unfork jsdoc
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
2018-01-31 22:04:48 +00:00
Joey Parrish b49f905e50 Replace CRLF endings with LF in jsdoc
Closes #1250

Change-Id: Ic414cef7cc90d068b25833fa9e36cb496f93ebc5
2018-01-29 12:44:17 -08:00
Joey Parrish 4067c20a7c [ES6] Replace gjslint with compiler linter & eslint
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
2018-01-16 17:25:05 +00:00
Joey Parrish bdc15ffae5 Update documentation of third-party tools
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
2018-01-03 15:07:02 -08:00
Joey Parrish 1a2c88745e Upgrade the Closure compiler to v20171203
Change-Id: Id0dd4619db0c3a141d60e9e38757739e0697e6f0
2018-01-03 15:07:02 -08:00
Joey Parrish 55816ac601 Fix jsdoc crash with @implements
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
2017-09-26 17:58:05 +00:00
Jacob Trimble 26bacb1489 Disallow unknown properties (3/5).
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
2017-07-05 17:47:03 +00:00
Joey Parrish 494d6081fc Update Closure Compiler to v20170423
Change-Id: I28361a6c2d50087edc34695596731035a083543d
2017-05-16 17:19:27 +00:00
Joey Parrish 395cc1745e Update the upgrade guides for v2.1
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
2017-04-20 23:39:27 +00:00
Joey Parrish 23a54180d2 Upgrade Closure Compiler to v20170218
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
2017-03-01 13:52:30 -08:00
Joey Parrish 8ba088a38f Generate externs automatically
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
2017-02-01 11:42:16 -08:00
Joey Parrish 98c62468f6 Enable linking to enum values in docs
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
2016-11-14 23:56:56 +00:00
Joey Parrish 09d221de16 Update the Closure Compiler to v20161024
Change-Id: I6642b1e386667028c1adbcce97ab64b21a9104b9
2016-11-11 22:08:43 +00:00
Andy Hochhaus b7fc078139 Update to compiler v20160713 2016-07-26 10:16:57 -07:00
Andy Hochhaus 3023377d84 Remove extraneous semicolons 2016-07-23 14:41:14 -07:00
Jacob Trimble 1749bb6626 Output enum values in jsdoc.
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
2016-04-19 13:26:52 -07:00
Joey Parrish 04d3df3ae8 Apply feedback from doc review
- 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
2016-04-13 17:12:32 -07:00
Joey Parrish c8e80cb58d Tutorials and other doc revisions
- 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
2016-04-06 19:17:51 +00:00
Joey Parrish 5e3647e20b Update closure compiler to v20160208
This new version catches some of our mistakes that were not caught in
earlier versions.

Change-Id: I21f05f3de2b131f441c32f21fb413dc6d037f098
2016-03-03 16:19:43 -08:00
Jacob Trimble 92075fbc29 Replaced remaining build scripts with python.
This also makes all build scripts runnable on Windows using both
Cygwin and native python.

Change-Id: If324800b8b899cac1cc715d30383255cd5f6ee71
2016-02-02 00:37:42 +00:00
Joey Parrish d21714e659 Enforce new record typedef annotations for jsdoc
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
2016-01-06 18:18:21 -08:00
Joey Parrish 58003ff9d6 Overhaul build and docs layout
* 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
2016-01-04 12:33:10 -08:00
Joey Parrish 1d1a0fcb46 Enable all compiler errors
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
2015-12-11 13:30:44 -08:00
Joey Parrish 03df140fb8 https://goo.gl/RvMyq4 2015-11-25 12:14:04 -08:00
Joey Parrish c04ad3e45d Update compiler to v20150901
Also fix duplicate declaration errors not seen on earlier versions.

Change-Id: Id8d5cf7636cb2b4b3ef54c84eb49dce4fe384d3d
2015-09-08 11:27:21 -07:00
Joey Parrish 2da8b2d334 Prefer local linter to globally-installed copy
Fixes #153

Change-Id: Idaf621af999a6eb53cab8dd0e814272bab0d0101
2015-09-08 09:31:45 -07:00
Jacob Trimble e74ad98eaa Added setNetworkCallback method to dash and offline video sources.
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
2015-08-24 09:35:27 -07:00
Jacob Trimble 671611ef37 Added build options to disable unneeded features
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
2015-08-14 15:58:00 -07:00
Joey Parrish 0089fdb594 Update the Closure Compiler
* 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
2015-07-14 03:30:34 +00:00
Joey Parrish 63f5a3a755 Sort tutorials.
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
2015-04-16 15:13:51 -07:00