-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(pdf): Update pdf.js to v2.2.228 and closure compiler to v20190729
- Loading branch information
Showing
196 changed files
with
92,433 additions
and
317 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file renamed
BIN
+6.76 MB
build/closure-compiler-v20161201.jar → build/closure-compiler-v20190729.jar
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,25 @@ | ||
DOC_STATIC_ASSETS_VERSION=$1 || $(./build/current_version.sh) | ||
#!/bin/bash | ||
|
||
DOC_COMPILER_BINARY="build/closure-compiler-v20190729.jar" | ||
DOC_STATIC_ASSETS_VERSION=$(./build/current_version.sh) | ||
|
||
# Minify using Google Closure Compiler, options: | ||
# Output to ECMASCRIPT5 / ES5 (Box supports Chrome, IE11, Firefox, Safari, and newer versions of iOS, Android) | ||
# Skip rewriting polyfills since pdf.js includes its own WeakMap polyfill | ||
echo "-----------------------------------------------------------------------------------" | ||
echo "Minifying pdf.js files with Google Closure... Warnings are okay!" | ||
echo "-----------------------------------------------------------------------------------" | ||
java -jar build/closure-compiler-v20161201.jar --rewrite_polyfills false --language_out ECMASCRIPT5 --js src/third-party/doc/$DOC_STATIC_ASSETS_VERSION/pdf.js --js_output_file src/third-party/doc/$DOC_STATIC_ASSETS_VERSION/pdf.min.js | ||
java -jar ${DOC_COMPILER_BINARY} --rewrite_polyfills false --language_out ECMASCRIPT5 --js src/third-party/doc/${DOC_STATIC_ASSETS_VERSION}/pdf.js --js_output_file src/third-party/doc/${DOC_STATIC_ASSETS_VERSION}/pdf.min.js | ||
|
||
java -jar ${DOC_COMPILER_BINARY} --rewrite_polyfills false --language_out ECMASCRIPT5 --js src/third-party/doc/${DOC_STATIC_ASSETS_VERSION}/pdf.worker.js --js_output_file src/third-party/doc/${DOC_STATIC_ASSETS_VERSION}/pdf.worker.min.js | ||
|
||
java -jar build/closure-compiler-v20161201.jar --rewrite_polyfills false --language_out ECMASCRIPT5 --js src/third-party/doc/$DOC_STATIC_ASSETS_VERSION/pdf.worker.js --js_output_file src/third-party/doc/$DOC_STATIC_ASSETS_VERSION/pdf.worker.min.js | ||
java -jar ${DOC_COMPILER_BINARY} --rewrite_polyfills false --language_out ECMASCRIPT5 --js src/third-party/doc/${DOC_STATIC_ASSETS_VERSION}/pdf_viewer.js --js_output_file src/third-party/doc/${DOC_STATIC_ASSETS_VERSION}/pdf_viewer.min.js | ||
|
||
java -jar build/closure-compiler-v20161201.jar --rewrite_polyfills false --language_out ECMASCRIPT5 --js src/third-party/doc/$DOC_STATIC_ASSETS_VERSION/pdf_viewer.js --js_output_file src/third-party/doc/$DOC_STATIC_ASSETS_VERSION/pdf_viewer.min.js | ||
echo "-----------------------------------------------------------------------------------" | ||
echo "Minifying pdf.js CSS with cssnano" | ||
echo "-----------------------------------------------------------------------------------" | ||
./node_modules/.bin/cssnano src/third-party/doc/$DOC_STATIC_ASSETS_VERSION/pdf_viewer.css src/third-party/doc/$DOC_STATIC_ASSETS_VERSION/pdf_viewer.min.css | ||
./node_modules/.bin/cssnano src/third-party/doc/${DOC_STATIC_ASSETS_VERSION}/pdf_viewer.css src/third-party/doc/${DOC_STATIC_ASSETS_VERSION}/pdf_viewer.min.css | ||
|
||
echo "-----------------------------------------------------------------------------------" | ||
echo "Successfully updated and minified pdf.js files!" | ||
echo "-----------------------------------------------------------------------------------" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,55 @@ | ||
#!/bin/bash | ||
# Run with specific branch/tag (e.g. ./upgrade_pdfjs.sh tags/v2.2.228) or with no arguments to use master | ||
|
||
DOC_STATIC_ASSETS_BRANCH=${1:-master} | ||
DOC_STATIC_ASSETS_VERSION=$(./build/current_version.sh) | ||
DOC_STATIC_ASSETS_PATH="src/third-party/doc/$DOC_STATIC_ASSETS_VERSION" | ||
DOC_STATIC_ASSETS_PATH="src/third-party/doc/${DOC_STATIC_ASSETS_VERSION}" | ||
|
||
if [ ! -d $DOC_STATIC_ASSETS_PATH ]; then | ||
DOC_LATEST_STATIC_ASSETS=`ls src/third-party/doc | sort -t "." -k1,1n -k2,2n -k3,3n | tail -1` | ||
echo "Latest version is $DOC_LATEST_STATIC_ASSETS" | ||
`cp -R src/third-party/doc/$DOC_LATEST_STATIC_ASSETS $DOC_STATIC_ASSETS_PATH` | ||
echo "Created build directory for $DOC_STATIC_ASSETS_PATH" | ||
fi | ||
echo "Upgrading pdf.js to $DOC_STATIC_ASSETS_BRANCH"; | ||
|
||
echo "-----------------------------------------------------------------------------------" | ||
echo "Fetching latest pdf.js files from pdfjs-dist repo..." | ||
echo "Creating target directory at $DOC_STATIC_ASSETS_PATH..." | ||
echo "-----------------------------------------------------------------------------------" | ||
|
||
rm -rf ${DOC_STATIC_ASSETS_PATH} | ||
|
||
DOC_LATEST_STATIC_ASSETS=`ls src/third-party/doc | sort -t "." -k1,1n -k2,2n -k3,3n | tail -1` | ||
echo "Usig base version from $DOC_LATEST_STATIC_ASSETS" | ||
`cp -R src/third-party/doc/${DOC_LATEST_STATIC_ASSETS} ${DOC_STATIC_ASSETS_PATH}` | ||
|
||
echo "-----------------------------------------------------------------------------------" | ||
echo "Cloining pdfjs-dist repo at branch: $DOC_STATIC_ASSETS_BRANCH..." | ||
echo "-----------------------------------------------------------------------------------" | ||
rm -rf ./pdfjs-dist/ | ||
git clone https://github.com/mozilla/pdfjs-dist.git | ||
git clone https://github.com/mozilla/pdfjs-dist.git --depth 1 --single-branch --branch ${DOC_STATIC_ASSETS_BRANCH} | ||
|
||
echo "-----------------------------------------------------------------------------------" | ||
echo "Copying relevant files to Preview third-party dir..." | ||
echo "-----------------------------------------------------------------------------------" | ||
cp pdfjs-dist/build/pdf.js src/third-party/doc/$DOC_STATIC_ASSETS_VERSION/ | ||
cp pdfjs-dist/build/pdf.worker.js src/third-party/doc/$DOC_STATIC_ASSETS_VERSION/ | ||
cp pdfjs-dist/web/pdf_viewer.js src/third-party/doc/$DOC_STATIC_ASSETS_VERSION/ | ||
cp pdfjs-dist/web/pdf_viewer.css src/third-party/doc/$DOC_STATIC_ASSETS_VERSION/ | ||
cp pdfjs-dist/cmaps/* src/third-party/doc/$DOC_STATIC_ASSETS_VERSION/cmaps/ | ||
\cp -rf pdfjs-dist/build/pdf.js src/third-party/doc/${DOC_STATIC_ASSETS_VERSION}/ | ||
\cp -rf pdfjs-dist/build/pdf.worker.js src/third-party/doc/${DOC_STATIC_ASSETS_VERSION}/ | ||
\cp -rf pdfjs-dist/web/pdf_viewer.js src/third-party/doc/${DOC_STATIC_ASSETS_VERSION}/ | ||
\cp -rf pdfjs-dist/web/pdf_viewer.css src/third-party/doc/${DOC_STATIC_ASSETS_VERSION}/ | ||
\cp -rf pdfjs-dist/cmaps/* src/third-party/doc/${DOC_STATIC_ASSETS_VERSION}/cmaps/ | ||
rm -rf ./pdfjs-dist/ | ||
|
||
# Fix Chrome console warning issue by not testing for moz-chunked-arraybuffer support in Chrome | ||
echo "-----------------------------------------------------------------------------------" | ||
echo "Tweaking pdf.js for Chrome..." | ||
echo "-----------------------------------------------------------------------------------" | ||
sed -e 's/function supportsMozChunkedClosure/!\(\/Chrome\/\.test\(navigator\.userAgent\)\) \&\& function supportsMozChunkedClosure/' -i '' src/third-party/doc/$DOC_STATIC_ASSETS_VERSION/pdf.js | ||
sed -e 's/function supportsMozChunkedClosure/!\(\/Chrome\/\.test\(navigator\.userAgent\)\) \&\& function supportsMozChunkedClosure/' -i '' src/third-party/doc/${DOC_STATIC_ASSETS_VERSION}/pdf.js | ||
|
||
# Decreased default cached pages size to 5 on mobile web to lower memory usage | ||
echo "-----------------------------------------------------------------------------------" | ||
echo "Decreasing # of cached pages on mobile web" | ||
echo "Decreasing # of cached pages on mobile web..." | ||
echo "-----------------------------------------------------------------------------------" | ||
sed -e 's@var DEFAULT_CACHE_SIZE = 10;@var DEFAULT_CACHE_SIZE = /iphone|ipad|ipod|android|blackberry|bb10|mini|windows\sce|palm/i.test(navigator.userAgent) ? 5 : 10;@' -i '' src/third-party/doc/$DOC_STATIC_ASSETS_VERSION/pdf_viewer.js | ||
sed -e 's@var DEFAULT_CACHE_SIZE = 10;@var DEFAULT_CACHE_SIZE = /iphone|ipad|ipod|android|blackberry|bb10|mini|windows\sce|palm/i.test(navigator.userAgent) ? 5 : 10;@' -i '' src/third-party/doc/${DOC_STATIC_ASSETS_VERSION}/pdf_viewer.js | ||
|
||
# Deletes code hiding PDF signatures. | ||
# For preview purposes, it is acceptable to show signatures without verifying them. | ||
# Render e-signatures without validation | ||
echo "-----------------------------------------------------------------------------------" | ||
echo "Enabling PDF signatures" | ||
echo "Enabling e-signature rendering without validation..." | ||
echo "-----------------------------------------------------------------------------------" | ||
# Deletes a block of code that starts with `if (data.fieldType === 'Sig') {``, and ends with `}` | ||
sed -e "/if (data.fieldType === 'Sig') {/,/}/d" -i '' src/third-party/doc/$DOC_STATIC_ASSETS_VERSION/pdf.worker.js | ||
sed -e 's@_this2.setFlags(_util.AnnotationFlag.HIDDEN);@\/\/_this2.setFlags(_util.AnnotationFlag.HIDDEN);@' -i '' src/third-party/doc/${DOC_STATIC_ASSETS_VERSION}/pdf.worker.js | ||
|
||
# Miniy the libraries | ||
./build/minify_pdfjs.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.