Commit Graph

52 Commits

Author SHA1 Message Date
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
Theodore Abshire 39090dfc28 Also check for misspellings in externs.
Change-Id: Ia10e58cc350cd1192b7098134215a659564e20a6
2020-06-05 00:41:38 +00: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
Jacob Trimble c8043f3916 Allow configuring when to fetch prev segment.
We fetch the previous segment in Live streams to combat differences
between the manfiest times and the segment times.  Now this can be
configured so apps with correct manifests can avoid the extra segment
request.

Also, we'll update the buffering state when a segment appends so we
leave the buffering state sooner.

Issue #2291

Change-Id: Id12c8132dc11739e4c8d42cb1f08e6ae7da1a966
2020-02-15 01:52:05 +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
Theodore Abshire 4c6325de08 Added localization system to demo.
No localizations exist currently, but this adds the framework for them.

Change-Id: I81a8cab128884753c765a192181d5d88f0ed13f1
2019-11-18 19:41:58 +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 f6f8be3b06 Add a filter for check.py.
This allows only running a specific check to aid in debugging and
fixing problems.  This also refactors the code to avoid having to
have a list of all the checks.

Change-Id: I6381ab563f648124c6b900d7b4a24686baebc4cc
2019-08-19 17:24:23 +00:00
Jacob Trimble 6fa0292cc3 Fix bug with eslint-disable checking.
Change-Id: I49c3994616a36a70bedbe33b0d2a6071a1ec4523
2019-08-19 17:23:46 +00:00
Jacob Trimble 568cc46720 Add a custom eslint plugin for private names.
This plugin can be used to write custom eslint rules.  This adds a
single rule to check we name private members correctly.  This plugin
does not get added to NPM, it is only used locally.

Fixes #1553

Change-Id: Ifdf9208d2bd0d09e1adb9c281b0be34266a867c9
2019-08-16 16:15:49 +00:00
Theodore Abshire f24c4a783f Added stylelint, a linter for our CSS/less files.
Also unified CSS/less style based on that.
This does have to use a forked version of stylelint, since there
is a bug (?) in the globbing library they use that causes it to
fail on our buildbot. I found the simplest solution was just to add
an option to disable globbing, a feature we weren't using anyway.

Closes #1867

Change-Id: I9295b01d5b15d060356e314938b64b551b75de6a
2019-08-08 18:38:19 +00:00
Jacob Trimble 8a3f51de41 Allow multiple spelling matches per line.
Before, it would only check one match per line.  Now it finds all the
matches to ensure a correct spelling doesn't hide an incorrect spelling
on the same line.

Change-Id: Iee6c7fb617852bf858a27c1c2a19026be5d8d089
2019-07-17 15:50:46 -07:00
Jacob Trimble 716215ab38 Spell-check build scripts and fix style.
Now the spell-checking is run over the scripts too.  The spelling
regexes are stored in another file to avoid having them be caught by
the check itself (or needing to whitelist the Python file).

This also fixes another spelling error and some line-length issues.

Change-Id: Ieabef3cf3e46c6dd2cd4341dfc6c158a9d6a50ea
2019-07-09 16:40:16 +00:00
Jacob Trimble 001c3c7b8c Add check for common misspellings.
Change-Id: Iaf546678ed787724513ed21b19a78cc895f069e8
2019-07-08 12:08:45 -07:00
Jacob Trimble a591cb538a Add .eslintrc.js to linter and fix style.
Change-Id: I91f909eb7f55cec9a8dc9da3598972ddf50159ea
2019-05-15 20:31:45 +00:00
Joey Parrish d412792e0b Update karma config for ES6
Issue #1157

Change-Id: I37630c762c760c4a0ef349b4aa32282c23b28eed
2019-05-15 20:27:18 +00:00
Joey Parrish e2089026b8 Update jsdoc plugin for ES6
Issue #1157

Change-Id: I6ad6370d37d9a1e3bbcfafb994bb6f0a0a604982
2019-05-15 17:40:18 +00:00
Joey Parrish 2fdbc07dda Update generateExterns to ES6
This updates build/generateExterns.js to use ES6 syntax and comply
with linter rules in eslint.  It also adds this to the list of things
checked with that linter.

Issue #1157

Change-Id: I5d7fecc9375b8e97db529dd2c5efb74276a9acfb
2019-05-15 16:33:20 +00:00
Jacob Trimble 984bb6f340 Fix ManifestGenerator indentation.
We use custom indentation for the ManifestGenerator to make the repeated
calls easier to read.  This disables the coming linter rule for these
blocks of code.  This also goes through and unifies the formatting.  The
indentation should be 4 spaces from the left side.

Change-Id: I687e69cea39bded1e9e06bffdcc888970b383fa2
2019-05-13 22:11:37 +00:00
Theodore Abshire efc2ed3df1 Added new demo page.
This is a complete replacement for the old demo page, made to be more
modern-looking and easier to maintain. It contains new features such as
remembering the URIs you provide for custom assets, and searching through
the default assets by feature.
This demo page is not quite ready for release yet, but it's getting close.

Change-Id: Iad01d1fc02c3cd238d73b9b9e02dbb4301cb6f2a
2019-05-01 19:58:18 +00: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 f6a8e81e1d Check for missing files in ui/
This would have prevented #1787 by checking both lib/ and ui/ for
missing files.  Every source file should be listed in build/types/.

Closes #1790

Change-Id: I6c883fd96566f284ace51d4622003aacbbf618d5
2019-02-04 15:27:33 -08:00
Joey Parrish d0822eed88 Fix windows path handling in build scripts
This bug seems to have been triggered because the app build adds and
subtracts things from the file set, but their paths didn't match
because of inconsistency in path separators.  This fixes build errors
on Windows.

Closes #1759

Change-Id: I598634dbff2bfe9853873477cd720fa14fd2ef82
2019-01-10 20:11:51 +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
Jacob Trimble 841f31b3ba Add support for Python3.
Change-Id: Ia7a5b41e3e7d4a75339d6e4de85b8b303fad8d9d
2018-10-23 19:10:29 +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
Sandra Lokshina 8065bd54a8 Change namespace from shakaExterns to shaka.externs
Change-Id: I16432351e2a266aa8fd175669aa27c44bfdffeae
2018-04-11 17:26:26 +00:00
Jacob Trimble 41ac7d25c6 Forward --fix to eslint.
Now both all.py and check.py will forward --fix to eslint so it can
automatically fix style violations.

Change-Id: Ic6048e58cfb35c7c5719a45200f23940b7590735
2018-02-20 12:17:43 -08:00
Joey Parrish 53a7433478 Execute node module bins directly
This avoids line-length limits on Windows in the node module's
pass-through shell script.

The long list of files, combined with a node module's bin file,
tripped the Windows command-line length limit of 8k.  The transition
to eslint, therefore, broke the Windows build.

Issue #1157
Closes #1228

Change-Id: Ie57624efbbbfb4a27035e82ab12e788d18652ae3
2018-01-18 00:05:17 +00: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 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
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
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 6d4c3d0447 Fix linter error (tutorial tag)
Introduced in d4cb9818 with the first use of @tutorial.

I didn't run that PR through the buildbot, so this linter failure
slipped in.

Change-Id: If4d8c70f2f7606ff068094b1f7fd8041af88678f
2016-09-29 12:09:06 -07:00
Jacob Trimble c21c62f0da Use a default python executable
It is possible that |sys.executable| is None, which results in an
error.  So use the default of 'python' when it is not present.

Change-Id: I5dab881f85c188bf3b2128b0f7cc6ee96ca8d959
2016-09-21 09:29:22 -07:00
Jacob Trimble 1e5dc5cc14 Fix build scripts for Windows.
* Node binaries should have .cmd appended to file name.
* htmlhint cannot find .htmlhintrc file.
* Use same python environment for subprocesses.

Closes #526

Change-Id: I6b4c898b39a3e2eb8d808feb2b46b79fba5dc455
2016-09-20 14:01:42 -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
Joey Parrish e325d031e6 Print progress during all build steps
Change-Id: I3e41f1a88cf4d866125c8e62cdb769d6dc2164c6
2016-04-06 13:40:49 -07:00
Joey Parrish 46473b5f52 Fix skipping of htmlhint when missing
We were returning 0 in a function that was supposed to return True/False.

Change-Id: Ie569c017b2620a5c0fe3ffc0df951bdb2a2ab546
2016-04-06 20:40:20 +00:00
Joey Parrish 13bcbb76a8 Do not require npm for build/all.py
This makes htmlhint an optional lint step, so that build/all.py can
run without npm.  The buildbot will still install htmlhint and run
these checks.

Change-Id: I09f01a10886a715b5303b879556a8ba563311735
2016-04-01 20:12:32 +00:00
Joey Parrish bda33cc9b6 Demo app v2
Still missing custom controls for live, but otherwise functional.

UI design and CSS based on work by Sam Dutton.

Change-Id: I0ee41254fb3b145822b018dff87aa583d6bef179
2016-03-30 00:36:32 +00:00
Jacob Trimble 19973d63f4 Changed copyright headers from 2015 to 2016.
Change-Id: I429ff27e4794c03b7ea392e38415075077f9bfb1
2016-03-15 16:32:13 -07:00
Jacob Trimble 37ca57326e Add a collection of public test assets.
This also alters the check.py script to include checking files in
demo/.  This will only check for type and style violations, it will
not compile it.

Change-Id: I610c3ad329c24287bc5d6030137652cb88aca3d4
2016-03-02 17:59:50 +00: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