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
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.
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.
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
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
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
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
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
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
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
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
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
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
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 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
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
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
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
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
This also modifies the build scripts to produce debug builds of the
demo and the receiver when doing debug builds.
Change-Id: I386a7b8f541332594a5022955a69970ebbe79200
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
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
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
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
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
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
/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
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
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
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
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
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
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