From 141155a1533ff8fb616b70ea313432781bbebffd Mon Sep 17 00:00:00 2001 From: Daniel Gasienica Date: Mon, 12 Feb 2018 20:12:50 -0500 Subject: [PATCH] Move `blueimp-canvas-to-blob` from Bower to npm --- bower.json | 5 ----- js/modules/types/attachment.js | 4 ++-- js/views/file_input_view.js | 7 ++----- package.json | 1 + preload.js | 1 + yarn.lock | 4 ++++ 6 files changed, 10 insertions(+), 12 deletions(-) diff --git a/bower.json b/bower.json index f8a7d7ea06..f5a3e660c4 100644 --- a/bower.json +++ b/bower.json @@ -15,7 +15,6 @@ "indexeddb-backbonejs-adapter": "*", "intl-tel-input": "~4.0.1", "blueimp-load-image": "~1.13.0", - "blueimp-canvas-to-blob": "~2.1.1", "autosize": "~4.0.0", "webaudiorecorder": "https://github.com/higuma/web-audio-recorder-js.git", "mp3lameencoder": "https://github.com/higuma/mp3-lame-encoder-js.git", @@ -69,9 +68,6 @@ "build/img/flags.png", "build/js/intlTelInput.js" ], - "blueimp-canvas-to-blob": [ - "js/canvas-to-blob.js" - ], "emojijs": [ "lib/emoji.js", "demo/emoji.css" @@ -110,7 +106,6 @@ "moment", "intl-tel-input", "backbone.typeahead", - "blueimp-canvas-to-blob", "autosize", "filesize" ], diff --git a/js/modules/types/attachment.js b/js/modules/types/attachment.js index b48767f332..8cd25bde7a 100644 --- a/js/modules/types/attachment.js +++ b/js/modules/types/attachment.js @@ -1,6 +1,6 @@ /* jshint ignore:start */ -const {autoOrientImage} = require('../auto_orient_image'); +const dataURLToBlob = require('blueimp-canvas-to-blob'); // // Fields // { @@ -46,7 +46,7 @@ const autoOrientJPEGs = async attachment => { } const dataBlob = arrayBufferToBlob(attachment.data, attachment.contentType); - const newDataBlob = dataURLtoBlob(await autoOrientImage(dataBlob)); + const newDataBlob = dataURLToBlob(await autoOrientImage(dataBlob)); const newDataArrayBuffer = await blobToArrayBuffer(newDataBlob); const newAttachment = Object.assign({}, attachment, { data: newDataArrayBuffer, diff --git a/js/views/file_input_view.js b/js/views/file_input_view.js index bb01d372c3..67acabb2d7 100644 --- a/js/views/file_input_view.js +++ b/js/views/file_input_view.js @@ -93,7 +93,6 @@ return; } - // loadImage.scale -> components/blueimp-load-image var canvas = loadImage.scale(img, { canvas: true, maxWidth: maxWidth, maxHeight: maxHeight }); @@ -103,10 +102,9 @@ var blob; do { i = i - 1; - // dataURLtoBlob -> components/blueimp-canvas-to-blob // TODO: Replace with native `Canvas::toBlob`: // https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob - blob = dataURLtoBlob( + blob = window.dataURLToBlob( canvas.toDataURL('image/jpeg', quality) ); quality = quality * maxSize / blob.size; @@ -230,10 +228,9 @@ crop: true, minWidth: size, minHeight: size }); - // dataURLtoBlob -> components/blueimp-canvas-to-blob // TODO: Replace with native `Canvas::toBlob`: // https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob - var blob = dataURLtoBlob(canvas.toDataURL('image/png')); + var blob = window.dataURLToBlob(canvas.toDataURL('image/png')); resolve(blob); }; diff --git a/package.json b/package.json index af15d496c0..aa67daf5cf 100644 --- a/package.json +++ b/package.json @@ -41,6 +41,7 @@ "open-coverage": "open coverage/lcov-report/index.html" }, "dependencies": { + "blueimp-canvas-to-blob": "^3.14.0", "blueimp-load-image": "^2.18.0", "bunyan": "^1.8.12", "config": "^1.28.1", diff --git a/preload.js b/preload.js index faebdd71ee..dee25709f5 100644 --- a/preload.js +++ b/preload.js @@ -60,6 +60,7 @@ window.nodeSetImmediate(function() {}); }, 1000); + window.dataURLToBlob = require('blueimp-canvas-to-blob'); window.ProxyAgent = require('proxy-agent'); window.EmojiConvertor = require('emoji-js'); window.emojiData = require('emoji-datasource'); diff --git a/yarn.lock b/yarn.lock index 62ff2bd975..937a7e8186 100644 --- a/yarn.lock +++ b/yarn.lock @@ -457,6 +457,10 @@ bluebird@^3.5.1: version "3.5.1" resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.5.1.tgz#d9551f9de98f1fcda1e683d17ee91a0602ee2eb9" +blueimp-canvas-to-blob@^3.14.0: + version "3.14.0" + resolved "https://registry.yarnpkg.com/blueimp-canvas-to-blob/-/blueimp-canvas-to-blob-3.14.0.tgz#ea075ffbfb1436607b0c75e951fb1ceb3ca0288e" + blueimp-load-image@^2.18.0: version "2.18.0" resolved "https://registry.yarnpkg.com/blueimp-load-image/-/blueimp-load-image-2.18.0.tgz#03b93687eb382a7136cfbcbd4f0e936b6763fc0e"