mirror of
https://github.com/Polymer/polymer.git
synced 2026-08-17 16:34:49 -05:00
Clean up closure externs
Generated closure externs substantially reduced in size with newer generator
This commit is contained in:
+26
-1612
File diff suppressed because it is too large
Load Diff
@@ -1,157 +0,0 @@
|
||||
<!--
|
||||
@license
|
||||
Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
|
||||
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
||||
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
||||
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
||||
Code distributed by Google as part of the polymer project is also
|
||||
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
||||
-->
|
||||
<!--<script src="closure-types.js"></script>-->
|
||||
<script>
|
||||
/* eslint-disable no-unused-vars, strict, valid-jsdoc */
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {DocumentFragment}
|
||||
*/
|
||||
function StampedTemplate(){}
|
||||
/** @type {boolean} */
|
||||
StampedTemplate.prototype.__noInsertionPoint;
|
||||
/** @type {!Array<!Node>} */
|
||||
StampedTemplate.prototype.nodeList;
|
||||
/** @type {!Object<string, !Node>} */
|
||||
StampedTemplate.prototype.$;
|
||||
/** @type {!TemplateInfo | undefined} */
|
||||
StampedTemplate.prototype.templateInfo;
|
||||
|
||||
/** @interface */
|
||||
function NodeInfo(){}
|
||||
/** @type {string} */
|
||||
NodeInfo.prototype.id;
|
||||
/** @type {!Array<{name: string, value: string}>}*/
|
||||
NodeInfo.prototype.events;
|
||||
/** @type {boolean} */
|
||||
NodeInfo.prototype.hasInsertionPoint;
|
||||
/** @type {!TemplateInfo} */
|
||||
NodeInfo.prototype.templateInfo;
|
||||
/** @type {!NodeInfo} */
|
||||
NodeInfo.prototype.parentInfo;
|
||||
/** @type {number} */
|
||||
NodeInfo.prototype.parentIndex;
|
||||
/** @type {number} */
|
||||
NodeInfo.prototype.infoIndex;
|
||||
/** @type {!Array<!Binding>} */
|
||||
NodeInfo.prototype.bindings;
|
||||
|
||||
/** @interface */
|
||||
function TemplateInfo(){}
|
||||
/** @type {!Array<!NodeInfo>} */
|
||||
TemplateInfo.prototype.nodeInfoList;
|
||||
/** @type {!Array<!Node>} */
|
||||
TemplateInfo.prototype.nodeList;
|
||||
/** @type {boolean} */
|
||||
TemplateInfo.prototype.stripWhitespace;
|
||||
/** @type {boolean | undefined} */
|
||||
TemplateInfo.prototype.hasInsertionPoint;
|
||||
/** @type {!Object} */
|
||||
TemplateInfo.prototype.hostProps;
|
||||
/** @type {!Object} */
|
||||
TemplateInfo.prototype.propertyEffects;
|
||||
/** @type {TemplateInfo | undefined} */
|
||||
TemplateInfo.prototype.nextTemplateInfo;
|
||||
/** @type {TemplateInfo | undefined} */
|
||||
TemplateInfo.prototype.previousTemplateInfo;
|
||||
/** @type {!Array<!Node>} */
|
||||
TemplateInfo.prototype.childNodes;
|
||||
/** @type {boolean} */
|
||||
TemplateInfo.prototype.wasPreBound;
|
||||
|
||||
/**
|
||||
* type for HTMLTemplateElement with `_templateInfo`
|
||||
*
|
||||
* @constructor
|
||||
* @extends {HTMLTemplateElement}
|
||||
*/
|
||||
function HTMLTemplateElementWithInfo(){}
|
||||
/** @type {TemplateInfo} */
|
||||
HTMLTemplateElementWithInfo.prototype._templateInfo;
|
||||
|
||||
/**
|
||||
* @typedef {{
|
||||
* literal: string,
|
||||
* compoundIndex: (number | undefined)
|
||||
* }}
|
||||
*/
|
||||
let LiteralBindingPart;
|
||||
|
||||
/**
|
||||
* @typedef {{
|
||||
* literal: boolean,
|
||||
* name: string,
|
||||
* value: (string | number),
|
||||
* rootProperty: (string | undefined),
|
||||
* structured: (boolean | undefined),
|
||||
* wildcard: (boolean | undefined)
|
||||
* }}
|
||||
*/
|
||||
let MethodArg;
|
||||
|
||||
/**
|
||||
* @typedef {{
|
||||
* methodName: string,
|
||||
* static: boolean,
|
||||
* args: !Array<!MethodArg>,
|
||||
* dynamicFn: (boolean | undefined),
|
||||
* }}
|
||||
*/
|
||||
let MethodSignature;
|
||||
|
||||
/**
|
||||
* @typedef {{
|
||||
* mode: string,
|
||||
* negate: boolean,
|
||||
* source: string,
|
||||
* dependencies: !Array<(!MethodArg|string)>,
|
||||
* customEvent: boolean,
|
||||
* signature: Object,
|
||||
* event: string
|
||||
* }}
|
||||
*/
|
||||
let ExpressionBindingPart;
|
||||
|
||||
/**
|
||||
* @typedef {LiteralBindingPart | ExpressionBindingPart}
|
||||
*/
|
||||
let BindingPart;
|
||||
|
||||
/**
|
||||
* @typedef {{
|
||||
* kind: string,
|
||||
* target: string,
|
||||
* parts: Array<!BindingPart>,
|
||||
* literal: (string | undefined),
|
||||
* isCompound: boolean,
|
||||
* listenerEvent: (string | undefined),
|
||||
* listenerNegate: (boolean | undefined)
|
||||
* }}
|
||||
*/
|
||||
let Binding;
|
||||
|
||||
/**
|
||||
* @typedef {{
|
||||
* path: string
|
||||
* }}
|
||||
*/
|
||||
let PathInfo;
|
||||
|
||||
/**
|
||||
* @typedef {{
|
||||
* forwardHostProp: (function(string, *) | undefined),
|
||||
* instanceProps: (Object | undefined),
|
||||
* mutableData: (boolean | undefined),
|
||||
* notifyInstanceProp: (function(*, string, *) | undefined),
|
||||
* parentModel: (boolean | undefined)
|
||||
* }}
|
||||
*/
|
||||
let TemplatizeOptions;
|
||||
</script>
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @fileoverview Externs for Polymer
|
||||
* @fileoverview Externs for Polymer Pass and external Polymer API
|
||||
* @externs
|
||||
*
|
||||
* @license
|
||||
@@ -101,4 +101,4 @@ Polymer.telemetry;
|
||||
* @extends {HTMLElement}
|
||||
* @implements {Polymer_LegacyElementMixin}
|
||||
*/
|
||||
var PolymerElement = Polymer.LegacyElementMixin();
|
||||
let PolymerElement = Polymer.LegacyElementMixin();
|
||||
|
||||
@@ -0,0 +1,158 @@
|
||||
/**
|
||||
* @fileoverview Internal shared types for Polymer
|
||||
*
|
||||
* @license
|
||||
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
|
||||
* This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
||||
* The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
||||
* The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
||||
* Code distributed by Google as part of the polymer project is also
|
||||
* subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
||||
*/
|
||||
|
||||
/* eslint-disable no-unused-vars, strict, valid-jsdoc */
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {DocumentFragment}
|
||||
*/
|
||||
function StampedTemplate() { }
|
||||
/** @type {boolean} */
|
||||
StampedTemplate.prototype.__noInsertionPoint;
|
||||
/** @type {!Array<!Node>} */
|
||||
StampedTemplate.prototype.nodeList;
|
||||
/** @type {!Object<string, !Node>} */
|
||||
StampedTemplate.prototype.$;
|
||||
/** @type {!TemplateInfo | undefined} */
|
||||
StampedTemplate.prototype.templateInfo;
|
||||
|
||||
/** @interface */
|
||||
function NodeInfo() { }
|
||||
/** @type {string} */
|
||||
NodeInfo.prototype.id;
|
||||
/** @type {!Array<{name: string, value: string}>}*/
|
||||
NodeInfo.prototype.events;
|
||||
/** @type {boolean} */
|
||||
NodeInfo.prototype.hasInsertionPoint;
|
||||
/** @type {!TemplateInfo} */
|
||||
NodeInfo.prototype.templateInfo;
|
||||
/** @type {!NodeInfo} */
|
||||
NodeInfo.prototype.parentInfo;
|
||||
/** @type {number} */
|
||||
NodeInfo.prototype.parentIndex;
|
||||
/** @type {number} */
|
||||
NodeInfo.prototype.infoIndex;
|
||||
/** @type {!Array<!Binding>} */
|
||||
NodeInfo.prototype.bindings;
|
||||
|
||||
/** @interface */
|
||||
function TemplateInfo() { }
|
||||
/** @type {!Array<!NodeInfo>} */
|
||||
TemplateInfo.prototype.nodeInfoList;
|
||||
/** @type {!Array<!Node>} */
|
||||
TemplateInfo.prototype.nodeList;
|
||||
/** @type {boolean} */
|
||||
TemplateInfo.prototype.stripWhitespace;
|
||||
/** @type {boolean | undefined} */
|
||||
TemplateInfo.prototype.hasInsertionPoint;
|
||||
/** @type {!Object} */
|
||||
TemplateInfo.prototype.hostProps;
|
||||
/** @type {!Object} */
|
||||
TemplateInfo.prototype.propertyEffects;
|
||||
/** @type {TemplateInfo | undefined} */
|
||||
TemplateInfo.prototype.nextTemplateInfo;
|
||||
/** @type {TemplateInfo | undefined} */
|
||||
TemplateInfo.prototype.previousTemplateInfo;
|
||||
/** @type {!Array<!Node>} */
|
||||
TemplateInfo.prototype.childNodes;
|
||||
/** @type {boolean} */
|
||||
TemplateInfo.prototype.wasPreBound;
|
||||
|
||||
/**
|
||||
* type for HTMLTemplateElement with `_templateInfo`
|
||||
*
|
||||
* @constructor
|
||||
* @extends {HTMLTemplateElement}
|
||||
*/
|
||||
function HTMLTemplateElementWithInfo() { }
|
||||
/** @type {TemplateInfo} */
|
||||
HTMLTemplateElementWithInfo.prototype._templateInfo;
|
||||
|
||||
/**
|
||||
* @typedef {{
|
||||
* literal: string,
|
||||
* compoundIndex: (number | undefined)
|
||||
* }}
|
||||
*/
|
||||
let LiteralBindingPart;
|
||||
|
||||
/**
|
||||
* @typedef {{
|
||||
* literal: boolean,
|
||||
* name: string,
|
||||
* value: (string | number),
|
||||
* rootProperty: (string | undefined),
|
||||
* structured: (boolean | undefined),
|
||||
* wildcard: (boolean | undefined)
|
||||
* }}
|
||||
*/
|
||||
let MethodArg;
|
||||
|
||||
/**
|
||||
* @typedef {{
|
||||
* methodName: string,
|
||||
* static: boolean,
|
||||
* args: !Array<!MethodArg>,
|
||||
* dynamicFn: (boolean | undefined),
|
||||
* }}
|
||||
*/
|
||||
let MethodSignature;
|
||||
|
||||
/**
|
||||
* @typedef {{
|
||||
* mode: string,
|
||||
* negate: boolean,
|
||||
* source: string,
|
||||
* dependencies: !Array<(!MethodArg|string)>,
|
||||
* customEvent: boolean,
|
||||
* signature: Object,
|
||||
* event: string
|
||||
* }}
|
||||
*/
|
||||
let ExpressionBindingPart;
|
||||
|
||||
/**
|
||||
* @typedef {LiteralBindingPart | ExpressionBindingPart}
|
||||
*/
|
||||
let BindingPart;
|
||||
|
||||
/**
|
||||
* @typedef {{
|
||||
* kind: string,
|
||||
* target: string,
|
||||
* parts: Array<!BindingPart>,
|
||||
* literal: (string | undefined),
|
||||
* isCompound: boolean,
|
||||
* listenerEvent: (string | undefined),
|
||||
* listenerNegate: (boolean | undefined)
|
||||
* }}
|
||||
*/
|
||||
let Binding;
|
||||
|
||||
/**
|
||||
* @typedef {{
|
||||
* path: string
|
||||
* }}
|
||||
*/
|
||||
let PathInfo;
|
||||
|
||||
/**
|
||||
* @typedef {{
|
||||
* forwardHostProp: (function(string, *) | undefined),
|
||||
* instanceProps: (Object | undefined),
|
||||
* mutableData: (boolean | undefined),
|
||||
* notifyInstanceProp: (function(*, string, *) | undefined),
|
||||
* parentModel: (boolean | undefined)
|
||||
* }}
|
||||
*/
|
||||
let TemplatizeOptions;
|
||||
@@ -0,0 +1,11 @@
|
||||
<!--
|
||||
@license
|
||||
Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
|
||||
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
||||
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
||||
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
||||
Code distributed by Google as part of the polymer project is also
|
||||
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
||||
-->
|
||||
<!-- internal shared types for closure pass -->
|
||||
<script src="polymer-internal-shared-types.js"></script>
|
||||
+25
-19
@@ -23,7 +23,7 @@ const babel = require('gulp-babel');
|
||||
const size = require('gulp-size');
|
||||
const lazypipe = require('lazypipe');
|
||||
const closure = require('google-closure-compiler').gulp();
|
||||
const minimalDocument = require('./util/minimalDocument.js')
|
||||
const minimalDocument = require('./util/minimalDocument.js');
|
||||
const dom5 = require('dom5');
|
||||
const parse5 = require('parse5');
|
||||
|
||||
@@ -33,8 +33,7 @@ const COMPILED_DIR = path.join(DIST_DIR, 'compiled');
|
||||
const POLYMER_LEGACY = 'polymer.html';
|
||||
const POLYMER_ELEMENT = 'polymer-element.html';
|
||||
|
||||
const polymer = require('polymer-build');
|
||||
const PolymerProject = polymer.PolymerProject;
|
||||
const {PolymerProject, HtmlSplitter} = require('polymer-build');
|
||||
|
||||
const {Transform} = require('stream');
|
||||
|
||||
@@ -66,10 +65,15 @@ class BackfillStream extends Transform {
|
||||
|
||||
let CLOSURE_LINT_ONLY = false;
|
||||
|
||||
let firstImportFinder = dom5.predicates.AND(dom5.predicates.hasTagName('link'), dom5.predicates.hasAttrValue('rel', 'import'));
|
||||
let firstImportFinder = dom5.predicates.AND(
|
||||
dom5.predicates.hasTagName('link'), dom5.predicates.hasAttrValue('rel', 'import')
|
||||
);
|
||||
|
||||
const licenseHeader =
|
||||
const header =
|
||||
`/**
|
||||
* @fileoverview Generated typings for Polymer mixins
|
||||
* @externs
|
||||
*
|
||||
* @license
|
||||
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
|
||||
* This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
||||
@@ -77,7 +81,9 @@ const licenseHeader =
|
||||
* The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
||||
* Code distributed by Google as part of the polymer project is also
|
||||
* subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
||||
*/`;
|
||||
*/
|
||||
/* eslint-disable */
|
||||
`;
|
||||
|
||||
class AddClosureTypeImport extends Transform {
|
||||
constructor(entryFileName, typeFileName) {
|
||||
@@ -114,7 +120,7 @@ gulp.task('closure', ['clean'], () => {
|
||||
entry = path;
|
||||
joinRx = new RegExp(path.split('/').join('\\/'));
|
||||
splitRx = new RegExp(joinRx.source + '_script_\\d+\\.js$');
|
||||
addClosureTypes = new AddClosureTypeImport(entry, 'externs/polymer-closure-types.html');
|
||||
addClosureTypes = new AddClosureTypeImport(entry, 'externs/polymer-internal-types.html');
|
||||
}
|
||||
|
||||
config('polymer.html');
|
||||
@@ -127,7 +133,7 @@ gulp.task('closure', ['clean'], () => {
|
||||
],
|
||||
extraDependencies: [
|
||||
addClosureTypes.importPath,
|
||||
'externs/closure-types.js'
|
||||
'externs/polymer-internal-shared-types.js',
|
||||
]
|
||||
});
|
||||
|
||||
@@ -144,7 +150,7 @@ gulp.task('closure', ['clean'], () => {
|
||||
if (CLOSURE_LINT_ONLY) {
|
||||
closurePluginOptions = {
|
||||
logger: closureLintLogger
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const closureStream = closure({
|
||||
@@ -175,7 +181,7 @@ gulp.task('closure', ['clean'], () => {
|
||||
|
||||
const closurePipeline = lazypipe()
|
||||
.pipe(() => closureStream)
|
||||
.pipe(() => new BackfillStream(closureStream.fileList_))
|
||||
.pipe(() => new BackfillStream(closureStream.fileList_));
|
||||
|
||||
// process source files in the project
|
||||
const sources = project.sources();
|
||||
@@ -186,7 +192,7 @@ gulp.task('closure', ['clean'], () => {
|
||||
// merge the source and dependencies streams to we can analyze the project
|
||||
const mergedFiles = mergeStream(sources, dependencies);
|
||||
|
||||
const splitter = new polymer.HtmlSplitter();
|
||||
const splitter = new HtmlSplitter();
|
||||
return mergedFiles
|
||||
.pipe(addClosureTypes)
|
||||
.pipe(project.bundler())
|
||||
@@ -195,18 +201,18 @@ gulp.task('closure', ['clean'], () => {
|
||||
.pipe(splitter.rejoin())
|
||||
.pipe(gulpif(joinRx, minimalDocument()))
|
||||
.pipe(gulpif(joinRx, size({title: 'closure size', gzip: true, showTotal: false, showFiles: true})))
|
||||
.pipe(gulp.dest(COMPILED_DIR))
|
||||
.pipe(gulp.dest(COMPILED_DIR));
|
||||
});
|
||||
|
||||
gulp.task('lint-closure', (done) => {
|
||||
CLOSURE_LINT_ONLY = true;
|
||||
runseq('closure', done);
|
||||
})
|
||||
});
|
||||
|
||||
gulp.task('estimate-size', ['clean'], () => {
|
||||
|
||||
const babelPresets = {
|
||||
presets: [['babili', {regexpConstructors: false, simplifyComparisons: false}]]
|
||||
presets: [['minify', {regexpConstructors: false, simplifyComparisons: false}]]
|
||||
};
|
||||
|
||||
const project = new PolymerProject({
|
||||
@@ -226,20 +232,20 @@ gulp.task('estimate-size', ['clean'], () => {
|
||||
// merge the source and dependencies streams to we can analyze the project
|
||||
const mergedFiles = mergeStream(sources, dependencies);
|
||||
|
||||
const bundledSplitter = new polymer.HtmlSplitter();
|
||||
const bundledSplitter = new HtmlSplitter();
|
||||
|
||||
const bundlePipe = lazypipe()
|
||||
.pipe(() => bundledSplitter.split())
|
||||
.pipe(() => gulpif(/\.js$/, babel(babelPresets)))
|
||||
.pipe(() => bundledSplitter.rejoin())
|
||||
.pipe(minimalDocument)
|
||||
.pipe(minimalDocument);
|
||||
|
||||
return mergedFiles
|
||||
.pipe(project.bundler())
|
||||
.pipe(gulpif(/polymer\.html$/, bundlePipe()))
|
||||
.pipe(gulpif(/polymer\.html$/, size({ title: 'bundled size', gzip: true, showTotal: false, showFiles: true })))
|
||||
// write to the bundled folder
|
||||
.pipe(gulp.dest(BUNDLED_DIR))
|
||||
.pipe(gulp.dest(BUNDLED_DIR));
|
||||
});
|
||||
|
||||
gulp.task('lint-eslint', function() {
|
||||
@@ -253,9 +259,9 @@ gulp.task('lint', (done) => {
|
||||
runseq('lint-eslint', 'lint-closure', done);
|
||||
});
|
||||
|
||||
gulp.task('generate-closure-externs', ['clean'], () => {
|
||||
gulp.task('generate-externs', ['clean'], () => {
|
||||
let genClosure = require('@polymer/gen-closure-declarations').generateDeclarations;
|
||||
return genClosure().then((declarations) => {
|
||||
fs.writeFileSync('externs/closure-types.js', `${licenseHeader}${declarations}`);
|
||||
fs.writeFileSync('externs/closure-types.js', `${header}${declarations}`);
|
||||
});
|
||||
});
|
||||
Generated
+1038
-559
File diff suppressed because it is too large
Load Diff
+8
-8
@@ -8,14 +8,14 @@
|
||||
"test": "test"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polymer/gen-closure-declarations": "^0.2.0",
|
||||
"@webcomponents/shadycss": "^1.0.4",
|
||||
"@webcomponents/webcomponentsjs": "^1.0.7",
|
||||
"babel-preset-babili": "^0.1.4",
|
||||
"@polymer/gen-closure-declarations": "^0.4.0",
|
||||
"@webcomponents/shadycss": "^1.0.6",
|
||||
"@webcomponents/webcomponentsjs": "^1.0.14",
|
||||
"babel-preset-minify": "^0.2.0",
|
||||
"del": "^3.0.0",
|
||||
"dom5": "^2.3.0",
|
||||
"eslint-plugin-html": "^2.0.1",
|
||||
"google-closure-compiler": "^20170806.0.0",
|
||||
"google-closure-compiler": "^20170910.0.0",
|
||||
"gulp": "^3.9.1",
|
||||
"gulp-babel": "^6.1.2",
|
||||
"gulp-eslint": "^3.0.1",
|
||||
@@ -25,10 +25,10 @@
|
||||
"lazypipe": "^1.0.1",
|
||||
"merge-stream": "^1.0.1",
|
||||
"parse5": "^3.0.2",
|
||||
"polymer-build": "^2.0.0",
|
||||
"run-sequence": "^2.1.0",
|
||||
"polymer-build": "^2.1.0",
|
||||
"run-sequence": "^2.2.0",
|
||||
"through2": "^2.0.0",
|
||||
"web-component-tester": "^6.0.1"
|
||||
"web-component-tester": "^6.3.0"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "gulp",
|
||||
|
||||
Reference in New Issue
Block a user