filepond-plugin-file-encode
Advanced tools
Comparing version 2.1.13 to 2.1.14
/*! | ||
* FilePondPluginFileEncode 2.1.12 | ||
* FilePondPluginFileEncode 2.1.14 | ||
* Licensed under MIT, https://opensource.org/licenses/MIT/ | ||
@@ -45,3 +45,3 @@ * Please visit https://pqina.nl/filepond/ for details. | ||
addFilter('DID_CREATE_ITEM', (item, { query }) => { | ||
if (!query('GET_ALLOW_FILE_ENCODE') || !base64Cache[item.id]) return; | ||
if (!query('GET_ALLOW_FILE_ENCODE')) return; | ||
@@ -54,3 +54,4 @@ item.extend( | ||
'getFileEncodeDataURL', | ||
() => `data:${item.fileType};base64,${base64Cache[item.id].data}` | ||
() => | ||
base64Cache[item.id] && `data:${item.fileType};base64,${base64Cache[item.id].data}` | ||
); | ||
@@ -57,0 +58,0 @@ }); |
/*! | ||
* FilePondPluginFileEncode 2.1.12 | ||
* FilePondPluginFileEncode 2.1.14 | ||
* Licensed under MIT, https://opensource.org/licenses/MIT/ | ||
@@ -9,2 +9,2 @@ * Please visit https://pqina.nl/filepond/ for details. | ||
const e=function(){self.onmessage=(a=>{e(a.data.message,e=>{self.postMessage({id:a.data.id,message:e})})});const e=(e,a)=>{const{file:t}=e,i=new FileReader;i.onloadend=(()=>{a(i.result.replace("data:","").replace(/^.+,/,""))}),i.readAsDataURL(t)}},a=({addFilter:a,utils:t})=>{const{Type:i,createWorker:d,createRoute:n,isFile:E}=t,o=({name:a,file:t})=>new Promise(i=>{const n=d(e);n.post({file:t},e=>{i({name:a,data:e}),n.terminate()})}),r=[];return a("DID_CREATE_ITEM",(e,{query:a})=>{a("GET_ALLOW_FILE_ENCODE")&&r[e.id]&&(e.extend("getFileEncodeBase64String",()=>r[e.id]&&r[e.id].data),e.extend("getFileEncodeDataURL",()=>`data:${e.fileType};base64,${r[e.id].data}`))}),a("SHOULD_PREPARE_OUTPUT",(e,{query:a})=>new Promise(e=>{e(a("GET_ALLOW_FILE_ENCODE"))})),a("COMPLETE_PREPARE_OUTPUT",(e,{item:a,query:t})=>new Promise(i=>{if(!t("GET_ALLOW_FILE_ENCODE")||!E(e)&&!Array.isArray(e))return i(e);r[a.id]={metadata:a.getMetadata(),data:null},Promise.all((e instanceof Blob?[{name:null,file:e}]:e).map(o)).then(t=>{r[a.id].data=e instanceof Blob?t[0].data:t,i(e)})})),a("CREATE_VIEW",e=>{const{is:a,view:t,query:i}=e;a("file-wrapper")&&i("GET_ALLOW_FILE_ENCODE")&&t.registerWriter(n({DID_PREPARE_OUTPUT:({root:e,action:a})=>{if(i("IS_ASYNC"))return;const t=i("GET_ITEM",a.id);if(!t)return;const d=r[t.id],n=d.metadata,E=d.data,o=JSON.stringify({id:t.id,name:t.file.name,type:t.file.type,size:t.file.size,metadata:n,data:E});e.ref.data?e.ref.data.value=o:e.dispatch("DID_DEFINE_VALUE",{id:t.id,value:o})},DID_REMOVE_ITEM:({action:e})=>{const a=i("GET_ITEM",e.id);a&&delete r[a.id]}}))}),{options:{allowFileEncode:[!0,i.BOOLEAN]}}};"undefined"!=typeof window&&void 0!==window.document&&document.dispatchEvent(new CustomEvent("FilePond:pluginloaded",{detail:a}));export default a; | ||
const e=function(){self.onmessage=(a=>{e(a.data.message,e=>{self.postMessage({id:a.data.id,message:e})})});const e=(e,a)=>{const{file:t}=e,i=new FileReader;i.onloadend=(()=>{a(i.result.replace("data:","").replace(/^.+,/,""))}),i.readAsDataURL(t)}},a=({addFilter:a,utils:t})=>{const{Type:i,createWorker:d,createRoute:n,isFile:E}=t,o=({name:a,file:t})=>new Promise(i=>{const n=d(e);n.post({file:t},e=>{i({name:a,data:e}),n.terminate()})}),r=[];return a("DID_CREATE_ITEM",(e,{query:a})=>{a("GET_ALLOW_FILE_ENCODE")&&(e.extend("getFileEncodeBase64String",()=>r[e.id]&&r[e.id].data),e.extend("getFileEncodeDataURL",()=>r[e.id]&&`data:${e.fileType};base64,${r[e.id].data}`))}),a("SHOULD_PREPARE_OUTPUT",(e,{query:a})=>new Promise(e=>{e(a("GET_ALLOW_FILE_ENCODE"))})),a("COMPLETE_PREPARE_OUTPUT",(e,{item:a,query:t})=>new Promise(i=>{if(!t("GET_ALLOW_FILE_ENCODE")||!E(e)&&!Array.isArray(e))return i(e);r[a.id]={metadata:a.getMetadata(),data:null},Promise.all((e instanceof Blob?[{name:null,file:e}]:e).map(o)).then(t=>{r[a.id].data=e instanceof Blob?t[0].data:t,i(e)})})),a("CREATE_VIEW",e=>{const{is:a,view:t,query:i}=e;a("file-wrapper")&&i("GET_ALLOW_FILE_ENCODE")&&t.registerWriter(n({DID_PREPARE_OUTPUT:({root:e,action:a})=>{if(i("IS_ASYNC"))return;const t=i("GET_ITEM",a.id);if(!t)return;const d=r[t.id],n=d.metadata,E=d.data,o=JSON.stringify({id:t.id,name:t.file.name,type:t.file.type,size:t.file.size,metadata:n,data:E});e.ref.data?e.ref.data.value=o:e.dispatch("DID_DEFINE_VALUE",{id:t.id,value:o})},DID_REMOVE_ITEM:({action:e})=>{const a=i("GET_ITEM",e.id);a&&delete r[a.id]}}))}),{options:{allowFileEncode:[!0,i.BOOLEAN]}}};"undefined"!=typeof window&&void 0!==window.document&&document.dispatchEvent(new CustomEvent("FilePond:pluginloaded",{detail:a}));export default a; |
/*! | ||
* FilePondPluginFileEncode 2.1.12 | ||
* FilePondPluginFileEncode 2.1.14 | ||
* Licensed under MIT, https://opensource.org/licenses/MIT/ | ||
@@ -63,3 +63,3 @@ * Please visit https://pqina.nl/filepond/ for details. | ||
var query = _ref3.query; | ||
if (!query('GET_ALLOW_FILE_ENCODE') || !base64Cache[item.id]) return; | ||
if (!query('GET_ALLOW_FILE_ENCODE')) return; | ||
@@ -71,3 +71,6 @@ item.extend('getFileEncodeBase64String', function() { | ||
item.extend('getFileEncodeDataURL', function() { | ||
return 'data:'.concat(item.fileType, ';base64,').concat(base64Cache[item.id].data); | ||
return ( | ||
base64Cache[item.id] && | ||
'data:'.concat(item.fileType, ';base64,').concat(base64Cache[item.id].data) | ||
); | ||
}); | ||
@@ -74,0 +77,0 @@ }); |
/*! | ||
* FilePondPluginFileEncode 2.1.12 | ||
* FilePondPluginFileEncode 2.1.14 | ||
* Licensed under MIT, https://opensource.org/licenses/MIT/ | ||
@@ -9,2 +9,2 @@ * Please visit https://pqina.nl/filepond/ for details. | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e=e||self).FilePondPluginFileEncode=n()}(this,function(){"use strict";var e=function(){self.onmessage=function(n){e(n.data.message,function(e){self.postMessage({id:n.data.id,message:e})})};var e=function(e,n){var t=e.file,i=new FileReader;i.onloadend=function(){n(i.result.replace("data:","").replace(/^.+,/,""))},i.readAsDataURL(t)}},n=function(n){var t=n.addFilter,i=n.utils,a=i.Type,d=i.createWorker,o=i.createRoute,r=i.isFile,f=function(n){var t=n.name,i=n.file;return new Promise(function(n){var a=d(e);a.post({file:i},function(e){n({name:t,data:e}),a.terminate()})})},u=[];return t("DID_CREATE_ITEM",function(e,n){(0,n.query)("GET_ALLOW_FILE_ENCODE")&&u[e.id]&&(e.extend("getFileEncodeBase64String",function(){return u[e.id]&&u[e.id].data}),e.extend("getFileEncodeDataURL",function(){return"data:".concat(e.fileType,";base64,").concat(u[e.id].data)}))}),t("SHOULD_PREPARE_OUTPUT",function(e,n){var t=n.query;return new Promise(function(e){e(t("GET_ALLOW_FILE_ENCODE"))})}),t("COMPLETE_PREPARE_OUTPUT",function(e,n){var t=n.item,i=n.query;return new Promise(function(n){if(!i("GET_ALLOW_FILE_ENCODE")||!r(e)&&!Array.isArray(e))return n(e);u[t.id]={metadata:t.getMetadata(),data:null},Promise.all((e instanceof Blob?[{name:null,file:e}]:e).map(f)).then(function(i){u[t.id].data=e instanceof Blob?i[0].data:i,n(e)})})}),t("CREATE_VIEW",function(e){var n=e.is,t=e.view,i=e.query;n("file-wrapper")&&i("GET_ALLOW_FILE_ENCODE")&&t.registerWriter(o({DID_PREPARE_OUTPUT:function(e){var n=e.root,t=e.action;if(!i("IS_ASYNC")){var a=i("GET_ITEM",t.id);if(a){var d=u[a.id],o=d.metadata,r=d.data,f=JSON.stringify({id:a.id,name:a.file.name,type:a.file.type,size:a.file.size,metadata:o,data:r});n.ref.data?n.ref.data.value=f:n.dispatch("DID_DEFINE_VALUE",{id:a.id,value:f})}}},DID_REMOVE_ITEM:function(e){var n=e.action,t=i("GET_ITEM",n.id);t&&delete u[t.id]}}))}),{options:{allowFileEncode:[!0,a.BOOLEAN]}}};return"undefined"!=typeof window&&void 0!==window.document&&document.dispatchEvent(new CustomEvent("FilePond:pluginloaded",{detail:n})),n}); | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e=e||self).FilePondPluginFileEncode=n()}(this,function(){"use strict";var e=function(){self.onmessage=function(n){e(n.data.message,function(e){self.postMessage({id:n.data.id,message:e})})};var e=function(e,n){var t=e.file,i=new FileReader;i.onloadend=function(){n(i.result.replace("data:","").replace(/^.+,/,""))},i.readAsDataURL(t)}},n=function(n){var t=n.addFilter,i=n.utils,a=i.Type,d=i.createWorker,o=i.createRoute,r=i.isFile,f=function(n){var t=n.name,i=n.file;return new Promise(function(n){var a=d(e);a.post({file:i},function(e){n({name:t,data:e}),a.terminate()})})},u=[];return t("DID_CREATE_ITEM",function(e,n){(0,n.query)("GET_ALLOW_FILE_ENCODE")&&(e.extend("getFileEncodeBase64String",function(){return u[e.id]&&u[e.id].data}),e.extend("getFileEncodeDataURL",function(){return u[e.id]&&"data:".concat(e.fileType,";base64,").concat(u[e.id].data)}))}),t("SHOULD_PREPARE_OUTPUT",function(e,n){var t=n.query;return new Promise(function(e){e(t("GET_ALLOW_FILE_ENCODE"))})}),t("COMPLETE_PREPARE_OUTPUT",function(e,n){var t=n.item,i=n.query;return new Promise(function(n){if(!i("GET_ALLOW_FILE_ENCODE")||!r(e)&&!Array.isArray(e))return n(e);u[t.id]={metadata:t.getMetadata(),data:null},Promise.all((e instanceof Blob?[{name:null,file:e}]:e).map(f)).then(function(i){u[t.id].data=e instanceof Blob?i[0].data:i,n(e)})})}),t("CREATE_VIEW",function(e){var n=e.is,t=e.view,i=e.query;n("file-wrapper")&&i("GET_ALLOW_FILE_ENCODE")&&t.registerWriter(o({DID_PREPARE_OUTPUT:function(e){var n=e.root,t=e.action;if(!i("IS_ASYNC")){var a=i("GET_ITEM",t.id);if(a){var d=u[a.id],o=d.metadata,r=d.data,f=JSON.stringify({id:a.id,name:a.file.name,type:a.file.type,size:a.file.size,metadata:o,data:r});n.ref.data?n.ref.data.value=f:n.dispatch("DID_DEFINE_VALUE",{id:a.id,value:f})}}},DID_REMOVE_ITEM:function(e){var n=e.action,t=i("GET_ITEM",n.id);t&&delete u[t.id]}}))}),{options:{allowFileEncode:[!0,a.BOOLEAN]}}};return"undefined"!=typeof window&&void 0!==window.document&&document.dispatchEvent(new CustomEvent("FilePond:pluginloaded",{detail:n})),n}); |
{ | ||
"name": "filepond-plugin-file-encode", | ||
"version": "2.1.13", | ||
"version": "2.1.14", | ||
"description": "File Encoding Plugin for FilePond", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
20017
344