Commit 5ff813fa authored by dpapad's avatar dpapad Committed by Commit Bot

WebUI: Add Polymer 2 to third_party/polymer

 - Update reproduce.sh as necessary.
 - Add python script to minify Polymer 2 since it does not come minified from
   bower, unlike Polymer 1. Minified version is 135kb (pre-gzip), which is
   smaller than Polymer 1 (220kb).
 - grd files will be modified in follow up CLs, along with the addition of the
   runtime flag.

Bug: 862472
Cq-Include-Trybots: luci.chromium.try:closure_compilation
Change-Id: Ia2d084e9ee37c419175831ff64694f47ea277bba
Reviewed-on: https://chromium-review.googlesource.com/1132478
Commit-Queue: Demetrios Papadopoulos <dpapad@chromium.org>
Reviewed-by: default avatarMichael Giuffrida <michaelpg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#575134}
parent 6fcaca75
......@@ -42,6 +42,8 @@ the Crisper tool (https://github.com/PolymerLabs/crisper).
css_strip_prefixes.py script.
- For paper-slider, added mixin for the pin text and removed custom focus change
handler code which was hiding ripples for pointer interactions.
- Bundled and minified Polymer 2 with minify_polymer.py, since Polymer 2 repo
does not distribute minified files (unlike Polymer 1).
To restore a content of the 'components-chromium' directory from scratch, run
./v1_0/reproduce.sh on a Linux machine.
......
......@@ -30,6 +30,9 @@ def _CheckBowerDependencies(input_api, output_api):
# Add web-animations-js because we keep it in a separate directory
# '../third_party/web-animations-js'.
installed_components.add('web-animations-js')
# Add shadycss because it ends up bundled withing
# components-chromium/polymer2 (see minify_polymer.py).
installed_components.add('shadycss')
if bower_dependencies == installed_components:
return []
......
......@@ -48,7 +48,9 @@
"paper-styles": "PolymerElements/paper-styles#2.1.0",
"paper-tabs": "PolymerElements/paper-tabs#2.0.0",
"paper-tooltip": "PolymerElements/paper-tooltip#2.0.0",
"polymer2": "Polymer/polymer#2.6.0",
"polymer": "Polymer/polymer#1.11.2",
"shadycss": "webcomponents/shadycss#1.2.1",
"web-animations-js": "web-animations/web-animations-js#2.2.2"
}
}
// Copyright (c) 2017 The Polymer Authors. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
{
"name": "polymer",
"main": [
"polymer.html"
],
"license": "http://polymer.github.io/LICENSE.txt",
"ignore": [
"/.*",
"/test/",
"/util/",
"gulpfile.js",
"CONTRIBUTING.md",
"CHANGELOG.md"
],
"authors": [
"The Polymer Authors (http://polymer.github.io/AUTHORS.txt)"
],
"repository": {
"type": "git",
"url": "https://github.com/Polymer/polymer.git"
},
"dependencies": {
"shadycss": "webcomponents/shadycss#^v1.1.0",
"webcomponentsjs": "webcomponents/webcomponentsjs#^v1.1.0"
},
"devDependencies": {
"web-component-tester": "^6.0.0",
"test-fixture": "PolymerElements/test-fixture#3.0.0-rc.1",
"iron-component-page": "PolymerElements/iron-component-page#^3.0.1"
},
"private": true,
"resolutions": {
"test-fixture": "3.0.0-rc.1"
}
}
This source diff could not be displayed because it is too large. You can view the blob instead.
<!--
@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
--><html><head></head><body><div hidden="" by-polymer-bundler=""></div>
<script src="polymer-extracted.js"></script></body></html>
\ No newline at end of file
......@@ -280,3 +280,9 @@ Tree: v1.11.2
Revision: 1dcf3839b3ce058d2d87737674a25ecdd7343f9a
Tree link: https://github.com/Polymer/polymer/tree/v1.11.2
Name: polymer
Repository: https://github.com/Polymer/polymer.git
Tree: v2.6.0
Revision: 00d510f17a19b5b2ffed2fab5c2220b562b69b4f
Tree link: https://github.com/Polymer/polymer/tree/v2.6.0
......@@ -19,7 +19,7 @@ import node
import node_modules
def main(original_html):
def ExtractFrom(original_html):
name = os_path.splitext(os_path.basename(original_html))[0]
dst_dir = os_path.dirname(original_html)
extracted_html = os_path.join(dst_dir, name + '-extracted.html')
......@@ -36,4 +36,4 @@ def main(original_html):
if __name__ == '__main__':
main(sys.argv[1])
ExtractFrom(sys.argv[1])
......@@ -26,6 +26,9 @@ class UnusedElementsDetector(object):
__WHITELIST = (
# Necessary for closure.
'polymer-externs',
# Not used yet. Will be used as part of Polymer 2 migration.
'polymer2',
'shadycss',
)
def __init__(self):
......
# Copyright 2018 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Minifies Polymer 2, since it does not come already minified from bower
(unlike Polymer 1).
"""
import os
import sys
import shutil
import tempfile
_HERE_PATH = os.path.dirname(__file__)
_SRC_PATH = os.path.normpath(os.path.join(_HERE_PATH, '..', '..', '..'))
sys.path.append(os.path.join(_SRC_PATH, 'third_party', 'node'))
import node
import node_modules
sys.path.append(_HERE_PATH)
import extract_inline_scripts
def main():
polymer_dir = os.path.join(_HERE_PATH, 'components-chromium', 'polymer2')
# Final HTML bundle.
polymer_html = os.path.join(polymer_dir, 'polymer.html')
# Final JS bundle.
polymer_js = os.path.join(polymer_dir, 'polymer-extracted.js')
# Move the entire checkout to a temp location.
tmp_dir = os.path.join(_HERE_PATH, 'components-chromium', 'polymer2temp')
if os.path.exists(tmp_dir):
shutil.rmtree(tmp_dir)
shutil.move(polymer_dir, tmp_dir)
tmp_out_dir = os.path.join(tmp_dir, 'out')
os.makedirs(tmp_out_dir)
try:
# Combine everything to a single HTML bundle file.
node.RunNode([
node_modules.PathToBundler(),
'--strip-comments',
'--inline-scripts',
'--inline-css',
'--in-html', os.path.join(tmp_dir, 'polymer.html'),
'--out-html', os.path.join(tmp_out_dir, 'polymer.html')
])
# Extract the JS to a separate file named polymer-extracted.js.
extract_inline_scripts.ExtractFrom(
os.path.join(tmp_out_dir, 'polymer.html'))
# Minify the JS bundle.
extracted_js = os.path.join(tmp_out_dir, 'polymer-extracted.js')
node.RunNode([
node_modules.PathToUglify(), extracted_js,
'--comments', '"/Copyright|license|LICENSE/"',
'--output', extracted_js])
# Copy generated bundled JS/HTML files back to the original location.
os.makedirs(polymer_dir)
shutil.move(os.path.join(tmp_out_dir, 'polymer.html'), polymer_html)
shutil.move(extracted_js, polymer_js)
# Copy a few more files.
shutil.move(os.path.join(tmp_dir, 'bower.json'), polymer_dir)
shutil.move(os.path.join(tmp_dir, 'LICENSE.txt'), polymer_dir)
finally:
# Delete component-chromium/shadycss since it ends up in the bundle.
shutil.rmtree(os.path.join(_HERE_PATH, 'components-chromium', 'shadycss'))
shutil.rmtree(tmp_dir)
if __name__ == '__main__':
main()
......@@ -62,14 +62,19 @@ find components -type f \( -name \*.html -o -name \*.css -o -name \*.js\
-o -name \*.bat -o -name \*.svg \) -print0 | xargs -0 sed -i -e $'s/\r$//g'
# Resolve a unicode encoding issue in dom-innerHTML.html.
# TODO(dpapad): Examine if this is necessary for polymer2/ as well.
NBSP=$(python -c 'print u"\u00A0".encode("utf-8")')
sed -i 's/['"$NBSP"']/\\u00A0/g' components/polymer/polymer-mini.html
rsync -c --delete -r -v --exclude-from="rsync_exclude.txt" \
--prune-empty-dirs "components/" "components-chromium/"
find "components-chromium/" -name "*.html" | \
xargs grep -l "<script>" | \
echo 'Minifying Polymer 2, since it comes non-minified from bower.'
python minify_polymer.py
find "components-chromium/" -name "*.html" \
! -path "components-chromium/polymer2*" | \
xargs grep -l "<script>" | \
while read original_html_name
do
echo "Crisping $original_html_name"
......
......@@ -7,10 +7,12 @@ demo*.html
*/demos/
docs.html
.eslintrc.json
*gen-tsd.json
.github
.gitignore
hero.svg
index.html
*.js.map
*.md
metadata.html
package.json
......@@ -26,9 +28,6 @@ package-lock.json
*/site/
*/templates/
# iron-flex-layout
iron-flex-layout/gen-tsd.json
# This is downloaded even though it's unused due to http://crbug.com/843701#c1
# paper-radio-button
paper-radio-button/
......@@ -39,6 +38,5 @@ paper-spinner/paper-spinner.html
# paper-styles
paper-styles/classes/global.html
paper-styles/element-styles/paper-item-styles.html
paper-styles/gen-tsd.json
paper-styles/paper-styles-classes.html
paper-styles/paper-styles.html
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment