To comply with internal regulations, even our generated externs should
have a license header. This prepends the header to all generated
externs.
Closes#2638
Change-Id: Idef8e7bff53363175aefa34274a8f71477e830fa
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 old compiler would let us export a static method on a class
without exporting the whole class and its constructor. The new
compiler silently ignores `@export` for any methods of a non-exported
class.
This means that for the latest Closure Compiler, we must export any
class with exported static methods. In some cases, these are
non-utility classes with constructors we'd rather not export, but the
constructor is implicitly exported by exporting the class itself.
This was initially caught by the integration tests. The error wasn't
especially helpful, so I added a try/catch to loadShaka that makes the
error more apparent:
TypeError: Cannot read property 'registerParserByMime' of undefined
To make sure we do not make this mistake again, I've added a check to
the extern generator, which was already able to detect these types of
classes. I don't know a compiler-based way to do it, since the
compiler silently ignores the export annotations in these cases.
Issue #2528
Change-Id: I797c75a8098b0bb3cf837588569f878253dec2cf
In v2.5, we had some classes which were not exported, but which had
certain individual methods which were exported. This is still true in
v2.6, except that we're using ES6 classes everywhere instead of mostly
using .prototype.
The extern generator had support for exporting individual .prototype
methods, but not for exporting individual class methods (unless the
class itself was exported already).
This adds support in the extern generator for these "partially
exported" classes, to correct missing externs in preparation for the
v2.6 launch.
Change-Id: I17ef377980ce771d74fab78afe26aa36ba3cce90
The parameters for prototype methods and other function expressions
was already correct, but there was a lack of spaces between parameters
in class methods.
Change-Id: I3b77a36efc91d8a3648bf45da0f9b155d78e5da5
This changes the eslint rule to enforce a strict pattern for the
argument comments. The comment must appear before the argument and
must be /* foo= */. This still ignores line comments.
Change-Id: I3afb01c65e1088eda13facb3aeeaa7595a2f5aee
This reflects changes in Google's policy on JavaScript license
headers, which should be smaller to avoid increasing the size of the
binary unnecessarily.
This also updates the company name from "Google, Inc" to "Google LLC".
Change-Id: I3f8b9ed3700b6351f43173d50c94d35c333e82b4
Previously, generateExterns required all methods to have JSDoc.
This made sense most of the time, but for an ES6 constructor not as
much. What the constructor does is kind of self-explanatory, and a JSDoc
along the lines of "/** Creates a Foo object. */" is a waste of space.
This changes generateExterns to not require a comment for such
constructors.
Change-Id: I12ae019934de9c020340baf0ca25f940d58d7d2f
The 'assert' module will throw an error that will crash the script.
This ensures an error is caught instead of causing silent problems.
Change-Id: I47d54924bff3a83b9897fd84a85142e237f18da6
For classes which only contain a bunch of public, exported members set
in the constructor, the extern generator goes through some extra steps
to create externs for those. This updates the generator to handle
these as they are converted to ES6.
Note that we currently have only three such classes:
- shaka.util.Error
- shaka.text.Cue
- shaka.text.CueRegion
Issue #1157
Change-Id: I8041998b2bdca0e6f44dcc6f897eb3c660b3424f
This updates our build requirements to NodeJS v8+ and NPM v5+, both
released in 2017.
This also clarifies our support for Python 3 (not well-documented
before) to the version we are using on Debian, v3.5.
Requiring NodeJS v8+ means our node tools (like our extern generator)
no longer need shims for compatibility. This allows us to drop the
"es6-shim" and "array-includes" modules.
In NPM v5+, the "prepublish" script has been deprecated, and replaced
with "prepublishOnly" (which is what we want) and "prepare" (the old
behavior we had to work around). This allows us to drop the
"in-publish" module.
Change-Id: Ied189c76a58fe981c12d41155b834f2d6ea73bbd
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
During a recent refactor, startTime || null got introduced.
This would not only use null as a default, but would also convert 0
into null, which changes the meaning of 0 from "exactly timestamp 0"
to "default start position" (which is non-zero for live streams).
This fix adds a regression test that fails without the fix.
Change-Id: I01e1628df9d141697fdb7d9fb5e77a16ac3dab5b
Generated externs should include member assignments from constructors.
Without them, the generated externs may not appear to implement the
full interface. The alternative is to re-declare these members on the
prototype, but that is more difficult to maintain. Instead, the
extern generator can convert them for us.
Example code:
/** @interface @exportInterface */
FooLike = function() {};
/** @exportInterface @type {number} */
FooLike.prototype.bar;
/** @constructor @export @implements {FooLike} */
Foo = function() {
/** @override @exportInterface */
this.bar = 10;
};
Example externs:
/** @interface */
FooLike = function() {};
/** @type {number} */
FooLike.prototype.bar;
/**
* @constructor @implements {FooLike}
*/
Foo = function() {}
/**
* @override
*/
Foo.prototype.bar;
Change-Id: I435ba1800d5eefbf68c27851d6454c1a572cc6f6
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