-
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(pdfjs): upgrade pdf.js to 4.3.136 (#1517)
* feat(pdfjs): upgrade pdj.js * feat(pdfjs): upgrade pdj.js * feat(pdfjs): upgrade pdj.js * feat(pdfjs): upgrade pdj.js * feat(pdfjs): upgrade pdj.js * feat(pdfjs): upgrade pdj.js * feat(pdfjs): upgrade pdj.js * feat(pdfjs): upgrade pdj.js * feat(pdfjs): upgrade pdj.js * feat(pdfjs): upgrade pdj.js * feat(pdfjs): upgrade pdj.js * feat(pdfjs): upgrade pdj.js * feat(pdfjs): upgrade pdj.js * feat(pdfjs): upgrade pdj.js * feat(pdfjs): upgrade pdj.js * feat(pdfjs): upgrade pdj.js * feat(pdfjs): upgrade pdj.js * feat(pdfjs): upgrade pdj.js * feat(pdfjs): upgrade pdj.js * feat(pdfjs): upgrade pdj.js * feat(pdfjs): upgrade pdj.js * feat(pdfjs): upgrade pdj.js * feat(pdfjs): upgrade pdj.js * feat(pdfjs): upgrade pdj.js * feat(pdfjs): upgrade pdj.js * feat(pdfjs): upgrade pdj.js * feat(pdfjs): upgrade pdj.js * feat(pdfjs): upgrade pdj.js
- Loading branch information
1 parent
b81e748
commit 87d1b17
Showing
185 changed files
with
1,426 additions
and
690 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,77 +1,74 @@ | ||
#!/bin/bash | ||
# Run with specific branch/tag (e.g. ./upgrade_pdfjs.sh tags/v2.2.228) or with no arguments to use master | ||
# Run with specific version (e.g. ./upgrade_pdfjs.sh <version>) | ||
|
||
#IMPORTANT!!!! See https://github.com/box/box-content-preview/pull/1466 and make sure any updated version of pdf.js includes | ||
#this fix or fixes it on it's own | ||
#IMPORTANT!!!! Make sure apply the updates in the verify_custom_updates.sh script and remove them | ||
# if they are no longer necessary. | ||
|
||
|
||
DOC_COMPILER_BINARY="build/closure-compiler-v20200719.jar" | ||
DOC_STATIC_ASSETS_BRANCH=${1:-master} | ||
DOC_STATIC_ASSETS_PDFJS_VERSION=${1} | ||
DOC_STATIC_ASSETS_VERSION=$(./build/current_version.sh) | ||
DOC_STATIC_ASSETS_PATH="src/third-party/doc/${DOC_STATIC_ASSETS_VERSION}" | ||
CURL_PATH="https://cdn.jsdelivr.net/npm/pdfjs-dist@${DOC_STATIC_ASSETS_PDFJS_VERSION}/legacy" | ||
|
||
echo "Upgrading pdf.js to $DOC_STATIC_ASSETS_BRANCH"; | ||
|
||
echo "-----------------------------------------------------------------------------------" | ||
echo "Creating target directory at $DOC_STATIC_ASSETS_PATH..." | ||
echo "Cleaning up existing upgrade files/folders if they exist..." | ||
echo "-----------------------------------------------------------------------------------" | ||
|
||
rm -rf ${DOC_STATIC_ASSETS_PATH} | ||
DOC_CURRENT_ASSETS_VERSIONS=`ls src/third-party/doc | sort -t "." -k1,1n -k2,2n -k3,3n | tail -1` | ||
rm -rf pdfjs-dist | ||
rm pdfjs-dist.zip | ||
|
||
echo "Using base version from $DOC_CURRENT_ASSETS_VERSIONS" | ||
mkdir ${DOC_STATIC_ASSETS_PATH} | ||
\cp -R src/third-party/doc/${DOC_CURRENT_ASSETS_VERSIONS}/exif.js ${DOC_STATIC_ASSETS_PATH}/ | ||
\cp -R src/third-party/doc/${DOC_CURRENT_ASSETS_VERSIONS}/exif.min.js ${DOC_STATIC_ASSETS_PATH}/ | ||
\cp -R src/third-party/doc/${DOC_CURRENT_ASSETS_VERSIONS}/images ${DOC_STATIC_ASSETS_PATH}/images | ||
DOC_CURRENT_ASSETS_VERSIONS=`ls src/third-party/doc | sort -t "." -k1,1n -k2,2n -k3,3n | tail -1` | ||
|
||
echo "-----------------------------------------------------------------------------------" | ||
echo "Cloning pdfjs-dist repo at branch: $DOC_STATIC_ASSETS_BRANCH..." | ||
echo "Creating target directory at $DOC_STATIC_ASSETS_PATH..." | ||
echo "-----------------------------------------------------------------------------------" | ||
rm -rf ./pdfjs-dist/ | ||
git clone https://github.com/mozilla/pdfjs-dist.git --depth 1 --single-branch --branch ${DOC_STATIC_ASSETS_BRANCH} | ||
mkdir ${DOC_STATIC_ASSETS_PATH} | ||
|
||
echo "-----------------------------------------------------------------------------------" | ||
echo "Copying relevant files to third-party directory..." | ||
echo "Copying legacy files/folders from version ${DOC_CURRENT_ASSETS_VERSIONS}..." | ||
echo "-----------------------------------------------------------------------------------" | ||
\cp -rf pdfjs-dist/legacy/build/pdf.js ${DOC_STATIC_ASSETS_PATH} | ||
\cp -rf pdfjs-dist/legacy/build/pdf.min.js ${DOC_STATIC_ASSETS_PATH} | ||
\cp -rf pdfjs-dist/legacy/build/pdf.worker.js ${DOC_STATIC_ASSETS_PATH} | ||
\cp -rf pdfjs-dist/legacy/build/pdf.worker.min.js ${DOC_STATIC_ASSETS_PATH} | ||
\cp -rf pdfjs-dist/legacy/web/pdf_viewer.css ${DOC_STATIC_ASSETS_PATH} | ||
\cp -rf pdfjs-dist/legacy/web/pdf_viewer.js ${DOC_STATIC_ASSETS_PATH} | ||
\cp -rf pdfjs-dist/cmaps ${DOC_STATIC_ASSETS_PATH}/cmaps | ||
rm -rf ./pdfjs-dist/ | ||
\cp -R src/third-party/doc/${DOC_CURRENT_ASSETS_VERSIONS}/exif.js ${DOC_STATIC_ASSETS_PATH}/ | ||
\cp -R src/third-party/doc/${DOC_CURRENT_ASSETS_VERSIONS}/exif.min.js ${DOC_STATIC_ASSETS_PATH}/ | ||
\cp -R src/third-party/doc/${DOC_CURRENT_ASSETS_VERSIONS}/images ${DOC_STATIC_ASSETS_PATH}/images | ||
|
||
# Decreased default cached pages size to 5 on mobile web to lower memory usage | ||
echo "-----------------------------------------------------------------------------------" | ||
echo "Decreasing # of cached pages on mobile web..." | ||
echo "Downloading pdf.js files and placing them in third-party directory..." | ||
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 '' ${DOC_STATIC_ASSETS_PATH}/pdf_viewer.js | ||
curl ${CURL_PATH}/build/pdf.mjs -o ${DOC_STATIC_ASSETS_PATH}/pdf.mjs | ||
curl ${CURL_PATH}/build/pdf.worker.mjs -o ${DOC_STATIC_ASSETS_PATH}/pdf.worker.mjs | ||
curl ${CURL_PATH}/web/pdf_viewer.mjs -o ${DOC_STATIC_ASSETS_PATH}/pdf_viewer.mjs | ||
curl ${CURL_PATH}/web/pdf_viewer.min.css -o ${DOC_STATIC_ASSETS_PATH}/pdf_viewer.min.css | ||
|
||
# Render e-signatures without validation | ||
# We minify the files ourself to avoid the cdn incorrectly minifying the files. | ||
# We use the terser options defined by pdf.js here: | ||
# https://github.com/mozilla/pdf.js/blob/ea34e5ccf6fdc7b3efcf6eba5b937dc7d63c5961/gulpfile.mjs#L345-L359 | ||
echo "-----------------------------------------------------------------------------------" | ||
echo "Enabling e-signature rendering without validation..." | ||
echo "Minifying pdf.js files using terser..." | ||
echo "-----------------------------------------------------------------------------------" | ||
sed -e 's@;r.setFlags(o.AnnotationFlag.HIDDEN)@@' -i '' ${DOC_STATIC_ASSETS_PATH}/pdf.worker.min.js | ||
TERSER_ARGS=(--comments false -c sequences=false -m reserved=['__webpack_exports__'] --keep-classnames --keep-fnames --module) | ||
yarn run terser ${DOC_STATIC_ASSETS_PATH}/pdf.mjs -o ${DOC_STATIC_ASSETS_PATH}/pdf.min.mjs ${TERSER_ARGS[@]} | ||
yarn run terser ${DOC_STATIC_ASSETS_PATH}/pdf.worker.mjs -o ${DOC_STATIC_ASSETS_PATH}/pdf.worker.min.mjs ${TERSER_ARGS[@]} | ||
yarn run terser ${DOC_STATIC_ASSETS_PATH}/pdf_viewer.mjs -o ${DOC_STATIC_ASSETS_PATH}/pdf_viewer.min.mjs ${TERSER_ARGS[@]} | ||
|
||
# Minify using Google Closure Compiler, options: | ||
# Output to ES5 (Box supports Chrome, Edge, IE11, Firefox, Safari, and newer versions of iOS, Android) | ||
# Do not minify pdf.js or pdf.worker.js, as the closure compiler will mangle function names and cause bugs | ||
echo "-----------------------------------------------------------------------------------" | ||
echo "Minifying pdf.js files with Google Closure... Warnings are okay!" | ||
echo "Cleaning up un-minified pdf.js files..." | ||
echo "-----------------------------------------------------------------------------------" | ||
java -jar ${DOC_COMPILER_BINARY} --rewrite_polyfills false --language_in ECMASCRIPT_2020 --language_out ECMASCRIPT_2018 --js ${DOC_STATIC_ASSETS_PATH}/pdf_viewer.js --js_output_file ${DOC_STATIC_ASSETS_PATH}/pdf_viewer.min.js | ||
rm ${DOC_STATIC_ASSETS_PATH}/pdf.mjs | ||
rm ${DOC_STATIC_ASSETS_PATH}/pdf.worker.mjs | ||
rm ${DOC_STATIC_ASSETS_PATH}/pdf_viewer.mjs | ||
|
||
# we get the cmaps from the prebuild rather than the cdn because we would have to web scrape the cdn in order to get the cmap file names. | ||
# We don't use the prebuild for the pdf.js files because it doesn't include pdf_viewer | ||
echo "-----------------------------------------------------------------------------------" | ||
echo "Minifying pdf.js CSS with cssnano" | ||
echo "Downloading and copying cmaps to third-party directory..." | ||
echo "-----------------------------------------------------------------------------------" | ||
./node_modules/.bin/cssnano ${DOC_STATIC_ASSETS_PATH}/pdf_viewer.css ${DOC_STATIC_ASSETS_PATH}/pdf_viewer.min.css | ||
curl -L https://github.com/mozilla/pdf.js/releases/download/v${DOC_STATIC_ASSETS_PDFJS_VERSION}/pdfjs-${DOC_STATIC_ASSETS_PDFJS_VERSION}-legacy-dist.zip -o pdfjs-dist.zip | ||
unzip -q -d pdfjs-dist pdfjs-dist.zip | ||
\cp -rf pdfjs-dist/web/cmaps ${DOC_STATIC_ASSETS_PATH}/cmaps | ||
rm -rf pdfjs-dist | ||
rm pdfjs-dist.zip | ||
|
||
echo "-----------------------------------------------------------------------------------" | ||
echo "Successfully updated and minified pdf.js files!" | ||
echo "Successfully updated pdf.js files!" | ||
echo "-----------------------------------------------------------------------------------" | ||
|
||
echo "------------------------------------------------------------------------------------" | ||
echo "please see https://github.com/box/box-content-preview/pull/1466 and make sure your version of pdf.js includes this fix" | ||
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
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
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,13 +1,10 @@ | ||
import Browser from '../../Browser'; | ||
import { DOC_LEGACY_STATIC_ASSETS_VERSION, DOC_STATIC_ASSETS_VERSION } from '../../constants'; | ||
|
||
const STATIC_VERSION = Browser.isIE() ? DOC_LEGACY_STATIC_ASSETS_VERSION : DOC_STATIC_ASSETS_VERSION; | ||
const STATIC_URI = `third-party/doc/${STATIC_VERSION}`; | ||
import { DOC_STATIC_ASSETS_VERSION } from '../../constants'; | ||
|
||
const STATIC_URI = `third-party/doc/${DOC_STATIC_ASSETS_VERSION}`; | ||
export const CMAP = `${STATIC_URI}/cmaps/`; | ||
export const IMAGES = `${STATIC_URI}/images/`; | ||
export const WORKER = `${STATIC_URI}/pdf.worker.min.js`; | ||
export const WORKER = `${STATIC_URI}/pdf.worker.min.mjs`; | ||
|
||
export const JS = [`${STATIC_URI}/pdf.min.js`, `${STATIC_URI}/pdf_viewer.min.js`, `${STATIC_URI}/exif.min.js`]; | ||
export const JS = [`${STATIC_URI}/pdf.min.mjs`, `${STATIC_URI}/pdf_viewer.min.mjs`, `${STATIC_URI}/exif.min.js`]; | ||
export const CSS = [`${STATIC_URI}/pdf_viewer.min.css`]; | ||
export const PRELOAD_JS = [WORKER]; |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
�RCopyright 1990-2009 Adobe Systems Incorporated. | ||
All rights reserved. | ||
See ./LICENSE�CNS2-H |
Binary file not shown.
Binary file not shown.
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
�RCopyright 1990-2009 Adobe Systems Incorporated. | ||
All rights reserved. | ||
See ./LICENSE� ETen-B5-H` ^ |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
%%Copyright: ----------------------------------------------------------- | ||
%%Copyright: Copyright 1990-2009 Adobe Systems Incorporated. | ||
%%Copyright: All rights reserved. | ||
%%Copyright: | ||
%%Copyright: Redistribution and use in source and binary forms, with or | ||
%%Copyright: without modification, are permitted provided that the | ||
%%Copyright: following conditions are met: | ||
%%Copyright: | ||
%%Copyright: Redistributions of source code must retain the above | ||
%%Copyright: copyright notice, this list of conditions and the following | ||
%%Copyright: disclaimer. | ||
%%Copyright: | ||
%%Copyright: Redistributions in binary form must reproduce the above | ||
%%Copyright: copyright notice, this list of conditions and the following | ||
%%Copyright: disclaimer in the documentation and/or other materials | ||
%%Copyright: provided with the distribution. | ||
%%Copyright: | ||
%%Copyright: Neither the name of Adobe Systems Incorporated nor the names | ||
%%Copyright: of its contributors may be used to endorse or promote | ||
%%Copyright: products derived from this software without specific prior | ||
%%Copyright: written permission. | ||
%%Copyright: | ||
%%Copyright: THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND | ||
%%Copyright: CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, | ||
%%Copyright: INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | ||
%%Copyright: MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
%%Copyright: DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR | ||
%%Copyright: CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
%%Copyright: SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
%%Copyright: NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
%%Copyright: LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
%%Copyright: HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
%%Copyright: CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR | ||
%%Copyright: OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
%%Copyright: SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
%%Copyright: ----------------------------------------------------------- |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Oops, something went wrong.