Commit Graph

57 Commits

Author SHA1 Message Date
Joey Parrish ec4bc1ddeb test: Fix Chromecast testing in lab (#6643)
These changes are necessary for compatibility with Chromecast WebDriver Server v2.

 - Fix a bug in Karma's flat environment support (joeyparrish/karma@9875e98)
 - Add a test boot file to load CAF on Chromecast devices; required by Chromecast WebDriver Server v2's redirect mode (flat environment at that level)
 - Also load this cast-boot file in support.html
 - Rename/reorganize Cast-related externs, which were messy even before the addition of CAF
 - Remove proxy-cast-platform.js; no longer needed as we move to flatten the test environment
 - Ignore error events with "null" error; these appear on Linux Chromecasts, only since including CAF
 - Ignore error events that are actually strings; these appear on Linux Chromecasts, only since including CAF
 - Disable Fuchsia in the lab until autoplay issues can be resolved
2024-05-20 15:14:49 -07:00
Wojciech Tyczyński 382f316460 build: Parametrize output language (#5158)
Modify build script to support customizing output language. Custom
builds now can be prepared with `ECMASCRIPT_2015` or higher to reduce
bundle size on newer platforms.
2023-04-19 10:13:16 -07:00
theodab 089e3ff254 feat(ui): Add ability to build UI without cast (#4781)
With this, if you build Shaka Player with "-@cast", the UI will contain
a dummy cast proxy that does not require the full cast system.
2022-12-06 17:28:18 -08:00
Joey Parrish 75ef9752a4 fix: Polyfill missing AbortController on Tizen (#4707)
We started using AbortController in HlsParser in 777c27ee, but that
change was made while the Tizen TV in our lab was offline. This restores
functionality to Tizen.

This polyfill uses getters, a feature of ES6 that the compiler won't
transpile into ES3, so this also changes the output language to ES5.
This should not be an issue, since ES5 has been well supported in all
browsers since IE10.
2022-11-15 09:16:25 +01:00
Joey Parrish 7d1a047fab build: fix build failure in context of node module
Building Shaka Player after installing it via node currently results
in a build failure.  This is because stylelint wants to filter out any
sources that match the glob **/node_modules/**, which in that context
is all of our sources.

To fix the failure, we add the --disable-default-ignores flag to the
stylelint command line.

We also had a similar hard-coded exclusion in build.py, which is now
fixed, as well.

Change-Id: I33f6619ebaccce1e1efa5da68e31cd49036addcd
2020-12-08 22:33:10 +00:00
Chuong 14460ad10e build: add mkdir to make all py commands self-contained (#2977)
Fixes #2973
2020-11-10 17:19:58 -08:00
michellezhuo 0eb3b620d3 build: add goog.require for compiler upgrade (Part 5)
Change-Id: I7c001f1c6d68a994342c1184e394f4643fd56ac9
2020-10-16 00:10:07 +00:00
Joey Parrish fe6c192d39 build: Generate TypeScript defs with Clutz
The output of Clutz is not directly usable.  We must perform several
transformations on the generated defs:

 - Remove the prefix clutz puts on all namespaces ("ಠ_ಠ.clutz")
 - Replace "GlobalObject" (from Clutz) with TypeScript-native "object"
 - Remove "Global" prefix from Date, Element, Event, and EventTarget
   and use the original definitions instead
 - Remove "protected", which appears on some fields, but is only
   supported on methods
 - Remove duplicate extension of EventTarget on IAdManager
 - Transform "Promise | null | undefined" return type into "Promise |
   void"
 - Fix the definitions of Error and shaka.util.Error
 - Remove an unnecessary second interface on SegmentIndex types
 - Remove definitions for Closure Compiler built-ins

We still need some basic TypeScript sample code that references Shaka
Player, so that we can try to compile it and automatically verify that
the defs work at every commit.

Issue #1030

Change-Id: If394269205e57dbcce4e0f76f6ef582fba0afacb
2020-10-15 03:56:18 +00:00
Joey Parrish 7e6a0f38ff fix: Correct license headers in misc. files
This corrects/normalizes license headers in misc. files, such as
config files, docs, build tools, tests, and externs.  This does not
affect the compiled output, and is only done for consistency.

Issue #2638

Change-Id: I9d8da2de55243b08d7df2b743aac73c6f15e858a
2020-06-09 16:13:56 -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 f757690777 Use the module wrapper in debug builds
When we wrote the build scripts and module wrapper, we must have
assumed that module loaders would be used only in production, and
didn't consider that they may be required by an environment like react
even for debugging.

This changes the debug build so that the module wrapper is applied,
allowing react apps or other module-loader-based apps to switch
trivially to the debug build.

There is a slight difference, which is that non-exported classes are
not available through the wrapper. Private members of objects are
still accessible with their original names in the debug build with the
wrapper.

Closes #2465

Change-Id: Ife9374455303abaa1573dc5f763bc867a729770c
2020-04-07 16:38:47 +00:00
Joey Parrish b9b4118938 Add a polyfill for EME encryption scheme queries
Note that the encryptionScheme field isn't being used by Shaka Player
yet, but that this will enable us to experiment with it ahead of the
full launch of the feature in browsers.

See also:
 - https://wicg.github.io/encrypted-media-encryption-scheme/
 - https://github.com/WICG/encrypted-media-encryption-scheme/issues/13
 - https://github.com/w3c/encrypted-media/pull/457

Change-Id: I9e8c2b6ce4ce3f4fe634fa4164669c69959e7fde
2019-11-22 18:18:36 +00: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
Jacob Trimble 38442986e0 Error when excluding core files.
Fixes #1761

Change-Id: If06d4945be693e83bafb6317988b477ec4f610cc
2019-07-22 15:53:04 +00:00
Jacob Trimble 1e8ec90393 Fix Windows path problem with UI.
Determining if the UI is in the build had a bug where it hard-coded the
path separator, which broke on Windows.

Fixes #1965

Change-Id: I8c59235fea9a304969186da0e6dd459ccafaf5be
2019-05-28 11:38:41 -07:00
Joey Parrish 00442a9a7c Split up localization data for lazy loading
This changes the format of the localization data to enable apps to
trivially lazy-load translations.  It also adds --locales to the build
scripts to allow app developers to choose the compiled-in locales.
The generated output now goes into dist/ and is not checked into
revision control.  Finally, it adds "description" and "meaning" fields
to the source messages to allow us to more easily integrate with a
context-aware human translation service.  The "description" field
provides application context for the translator, while the "meaning"
field provides linguistic disambiguation for words with multiple
meanings or parts of speech in the original English.

Because the translation service wants to collapse messages with
identical text, we had to merge several messages together.  To this
end, we have removed the prefixes "ARIA_LABEL_" and "LABEL_" from the
messages themselves and collapsed what remained.

Issue #1688

Change-Id: I24c17e71c73f6663cf123cfdba118c486fa80ecc
2019-04-09 16:06:14 -07:00
Joey Parrish d2069dcd76 Fix broken version definition in compiled build
This regression was introduced in 6b1ca2d.

Closes #1816

Change-Id: Icdd5e617771799e19a25fa110cf789bfa009b410
2019-02-21 09:17:43 -08: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
Jacob Trimble 841f31b3ba Add support for Python3.
Change-Id: Ia7a5b41e3e7d4a75339d6e4de85b8b303fad8d9d
2018-10-23 19:10:29 +00:00
Jacob Trimble c4aecb81c5 Fix confusing log when building.
Currently when building, the compiler prints a confusing log while
compiling the wrapper. "The compiler is waiting for input via stdin."
Since we are handling that, just suppress the message.

Change-Id: Ie1ad7eba51774e80b515d37d5ae926aabc507a5f
2018-06-21 21:36:38 +00: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 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 b27ea82e7f Allow Player to attach/detach from video
This adds attach/detach methods to replace the media element in the
Player constructor.  Now applications can take back control of the
media element or provide a reference later in the Player's life cycle.

This also allows applications to decide whether or not to set up
MediaSource in advance, through an optional argument on attach and
unload.  The default will be to set up MediaSource in advance, which
maintains current behavior.  This advanced setup of MediaSource can
improve load latency later.

This change also introduces async/await for the first time in the
project, which required changes to eslint config, Closure build
arguments, Babel & Babel-polyfill setup, and the esprima parser used
by our extern generator.

The use of async/await will improve readability in many places, and
these infrastructure changes to enable async/await should also unblock
issues #1336 and #1337.

Closes #1087

Change-Id: I0d6b4e0e2af27a6520a3d070fa92b7139b2cb8b0
2018-03-06 22:19:53 +00:00
Joey Parrish 6bf201f920 [ES6] Allow ES6 input in the Closure Compiler
Note that until we replace gjslint, the linter will still not accept
ES6 syntax.  So we cannot yet merge any commits which use ES6.

But this should allow us to start experimenting with ES6 locally by
bypassing the old linter.

Issue #1157

Change-Id: Ic0902f57a34f61b0a7831c3e019425cee6e0308f
2018-01-05 20:10:42 +00:00
Aaron Vaage 71455957c7 Changed build/build.py to use argparse in main
Changed build/build.py to use argparse in its main method to help standardized
how all our scripts parse command line arguments.

Change-Id: Ib766d7fe7a8629fd42014cba8312eb1e09917bef
2018-01-05 19:37:57 +00:00
Joey Parrish 1a2c88745e Upgrade the Closure compiler to v20171203
Change-Id: Id0dd4619db0c3a141d60e9e38757739e0697e6f0
2018-01-03 15:07:02 -08:00
Joey Parrish 45a1d71b8a Add more strict conformance checks
This adds extra conformance checks:
  - A ban on @expose, which we already got rid of in 775d7552
  - A ban on unresolved types, which did not generate any failures
  - A ban on global variables
  - A more comprehensive ban on console logging

None of these caught any real bugs in the existing code base.

In one test suite (MediaSourceEngine unit tests), the compiler was
unable to determine the type of one of the mocks, leading it to
suspect that it could possibly violate the new ban on console.error.

The goog.define('GIT_VERSION', ...) line in player.js was seen
(correctly) as a global variable.  This has been fixed and simplified
as a result.

The only custom conformance checks we are not using are "BanNullDeref"
(too many false negatives) and "BanThrowOfNonErrorTypes" (for which
we have our own, more restrictive version).

Since we have now tried all custom conformance rules provided by the
compiler today, this closes the associated issue.

Closes #1130.

Change-Id: Iad9040d0f5ee397c7d46b1d64bc5bebf2def57bc
2017-11-29 14:50:47 -08:00
Jacob Trimble 56740adffb Have all.py build both debug and release builds.
Change-Id: I67e830d45f7d4383b313c835c55b3119349ab1d2
2017-10-19 20:22:07 +00:00
Jacob Trimble 1458832a31 Change Player version suffix.
Rather than using the -debug suffix for uncompiled builds, use
-uncompiled.  This also changes the version for debug compiled builds
to use the -debug suffix.

Change-Id: I3c0c1c3b849d5f817c4d7f7bcfd7f967a00d1aaf
2017-10-19 20:21:40 +00:00
Jacob Trimble 117ed46bd5 Add links to switch between compiled and uncompiled
This also modifies the build scripts to produce debug builds of the
demo and the receiver when doing debug builds.

Change-Id: I386a7b8f541332594a5022955a69970ebbe79200
2017-10-17 17:26:37 +00:00
Joey Parrish 802a674c13 [PWA] Add a service worker
This adds a service worker, which will cache application resources to
make the application itself available offline in browsers which
support service workers.

Issue #876

Change-Id: I13096b2d4b9236d2a3f220af6b1dfce43d7a0004
2017-10-02 11:19:10 -07:00
Joey Parrish 958e1c68dd [PWA] Compile the demo app and cast receiver app
When using the compiled version of the library, use a compiled version
of the demo app, as well.  This makes use of the generated externs, so
we now have additional confidence that they are correctly generated.

Refactor the load.js script to use a configurable list of sources.
This enables us to use the same load.js in both the demo and cast
receiver.

This, ultimately, makes it easier to cache demo resources in our PWA.

Issue #876

Change-Id: I274660fe2ea23236ceea3c2d3c97572762d2f785
2017-10-02 11:19:10 -07:00
Tim Plummer 775d755259 Remove deprecated @expose annotations.
Added externs for error.js and removed the @expose declarations from the
actual error.js file. Updated the jscompiler flags and docs.

Change-Id: I2aa95ef1c82fc7bd349c637cca3141d5a003b646
2017-09-26 13:51:36 -07:00
Joey Parrish f02feb97ef Check generated externs
This helps catch a certain class of error before we do a release.
Otherwise, we only find out that the generated externs are broken
when someone tries to build an app against them.

Change-Id: I6aa000ee9129c40fffcaa9c8e2cc73d3eb17a144
2017-09-26 17:57:47 +00:00
Jacob Trimble fddcf0c259 Use logging module over print.
Rather than using print, use the logging module.  This allows embedding
environments to setup logging how they want.  This also ensures the logs
are flushed properly.

The prints for check.py, checkversion.py, stats.py, and for the --help
flag will still be printed to stdout since that would be the expected
output location.

Change-Id: I26e1bc866803c42981628c7e62261d13c7b3ff2b
2017-05-10 21:25:39 +00:00
Joey Parrish 9f8b540ee5 Update node modules only when needed
Since node modules are required in several parts of the build
process now, avoid updating them unless package.json has changed
since the last update.

Change-Id: Ied40f198fff80bf261f77269995e9a58881a0462
2017-04-25 17:06:57 +00:00
Joey Parrish 1e0ad7126f Update shebang lines of python scripts
/usr/bin/env python is preferable, since it allows us to support
executable scripts on systems where python is installed in places
other than /usr/bin.

Incidentally, this was the only thing I needed to do to confirm
full build support on Windows, so I'm dropping a TODO about Windows
support for the extern generator.

Change-Id: Ice93174428e0d8015d0a7787f07a17e8ac808dc7
2017-04-24 20:17:43 +00: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
Jacob Trimble dfa356b7d9 Print error when missing dependencies in build scripts.
When a program (e.g. Java) cannot be found in the build scripts, it
will now print a more specific error message and quit early to avoid
other confusing messages.

Change-Id: I5f1f26a6c05b8db45355bfbc8d799d603c80c55c
2017-01-11 18:14:28 +00:00
Joey Parrish 4f0acf852d Revert dependency_mode=loose
This reverts the addition of dependency_mode, introduced by PR #465.
The change inadvertently breaks part of our build system, namely the
ability to exclude standard features from the build.  For example:

./build/build.py --name nodash +@complete -@dash

This worked before #465, and now it works again.  This bug affects all
v2.0.x releases.

Change-Id: Ice2f2f282678d8cb02519830dc1214ef410f4d86
2017-01-07 00:13:35 +00:00
Jacob Trimble 40aab9387e Allow compiling a debug compiled file.
This adds a new option (--debug) to build/build.py which allows
building for debugging.  This will expose all internal members on the
global |shaka| object and will not rename anything.  This allows apps
to import the single compiled file but still perform debugging.

This also changes the file naming a little.  Before, we would create
a |.debug.js| and |.debug.map| file when we compiled.  However this
was not a debug file, it just linked to the source map.  Now it will
always generate the source map and attach it to the compiled file.  If
compiling with --debug it will add |.debug| to the file name.

This should also help with importing the debug library in ES6.
Issue #466

Change-Id: Ic51abbdb04763e8a3687c5d59a23d721436e1c7b
2016-12-20 00:43:44 +00:00
Joey Parrish 09d221de16 Update the Closure Compiler to v20161024
Change-Id: I6642b1e386667028c1adbcce97ab64b21a9104b9
2016-11-11 22:08:43 +00:00
Andy Hochhaus 9bd0803ac1 Use --dependency_mode=LOOSE for library compiles (#465)
This change does not order input files for the --checks_only
pass used to type-check the unit tests.
2016-08-15 20:28:04 -07:00
Andy Hochhaus b7fc078139 Update to compiler v20160713 2016-07-26 10:16:57 -07:00
Jacob Trimble a1449e44dc Make build files consistent with Google python style guide.
Change-Id: I49d181c4dbe4fe12b73cdc4a5c78b3dcf1319b56
2016-06-28 22:30:30 +00:00
Jacob Trimble e36f00955c Fix source map paths on Windows.
Because Windows uses '\' for paths while Linux uses '/', the previous
fix to use relative paths in the source map did not work.  Now
we use relative paths for all platforms.

Closes #413

Change-Id: Ie83f8343e2dab725ce4af59f66af19d4fb8ff036
2016-06-15 10:05:18 -07:00
Jacob Trimble 294841de17 Add README for build files.
Change-Id: Iea23da14d2954a2d0ec5d731990a4b0f7ac45169
2016-06-06 21:41:34 +00:00
Joey Parrish e325d031e6 Print progress during all build steps
Change-Id: I3e41f1a88cf4d866125c8e62cdb769d6dc2164c6
2016-04-06 13:40:49 -07:00
Jacob Trimble 58ac690104 Paths in source map should be relative.
This makes the paths in the source map relative to the dist/
directory so it can be used on a web server correctly.

Closes #323

Change-Id: Ib69ff2e1393548a3ebd1d67520422173a5827704
2016-04-06 20:30:58 +00:00
Joey Parrish bb1a379fc9 Fix debug map name
Change-Id: I1cb57745f99678ff154bcfca7dfd7f14ba9e0c1d
2016-03-29 23:19:08 +00:00