filepond-plugin-file-encode
Advanced tools
Comparing version 1.0.4 to 1.0.5
/* | ||
* FilePondPluginFileEncode 1.0.4 | ||
* FilePondPluginFileEncode 1.0.5 | ||
* Licensed under MIT, https://opensource.org/licenses/MIT | ||
@@ -31,3 +31,3 @@ * Please visit https://pqina.nl/filepond for details. | ||
// get quick reference to Type utils | ||
const { Type, createWorker, createRoute, applyFilterChain } = utils; | ||
const { Type, createWorker, createRoute, isFile } = utils; | ||
@@ -47,2 +47,8 @@ addFilter( | ||
new Promise((resolve, reject) => { | ||
// this is not a file, continue | ||
if (!isFile(file)) { | ||
resolve(file); | ||
return; | ||
} | ||
const metadata = item.getMetadata(); | ||
@@ -49,0 +55,0 @@ delete metadata.base64; |
/* | ||
* FilePondPluginFileEncode 1.0.4 | ||
* FilePondPluginFileEncode 1.0.5 | ||
* Licensed under MIT, https://opensource.org/licenses/MIT | ||
* Please visit https://pqina.nl/filepond for details. | ||
*/ | ||
const DataURIWorker=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)}};var plugin$1=({addFilter:e,utils:a})=>{const{Type:t,createWorker:i,createRoute:n,applyFilterChain:s}=a;return e("SHOULD_PREPARE_OUTPUT",e=>new Promise((e,a)=>{e(!0)})),e("COMPLETE_PREPARE_OUTPUT",(e,{item:a})=>new Promise((t,n)=>{delete a.getMetadata().base64;i(DataURIWorker).post({file:e},i=>{a.setMetadata("base64",i),t(e)})})),e("CREATE_VIEW",e=>{const{is:a,view:t,query:i}=e;a("file-wrapper")&&i("GET_ALLOW_FILE_ENCODE")&&t.registerWriter(n({DID_LOAD_ITEM:({root:e,action:a})=>{if(i("IS_ASYNC"))return;const t=i("GET_ITEM",a.id),n=t.getMetadata(),s=n.base64;delete n.base64,e.ref.data.value=JSON.stringify({id:t.id,name:t.file.name,type:t.file.type,size:t.file.size,metadata:n,data:s})}}))}),{options:{allowFileEncode:[!0,t.BOOLEAN]}}};"undefined"!=typeof navigator&&document&&document.dispatchEvent(new CustomEvent("FilePond:pluginloaded",{detail:plugin$1}));export default plugin$1; | ||
const DataURIWorker=function(){self.onmessage=(t=>{e(t.data.message,e=>{self.postMessage({id:t.data.id,message:e})})});const e=(e,t)=>{const{file:a}=e,i=new FileReader;i.onloadend=(()=>{t(i.result.replace("data:","").replace(/^.+,/,""))}),i.readAsDataURL(a)}};var plugin$1=({addFilter:e,utils:t})=>{const{Type:a,createWorker:i,createRoute:s,isFile:n}=t;return e("SHOULD_PREPARE_OUTPUT",e=>new Promise((e,t)=>{e(!0)})),e("COMPLETE_PREPARE_OUTPUT",(e,{item:t})=>new Promise((a,s)=>{if(!n(e))return void a(e);delete t.getMetadata().base64;i(DataURIWorker).post({file:e},i=>{t.setMetadata("base64",i),a(e)})})),e("CREATE_VIEW",e=>{const{is:t,view:a,query:i}=e;t("file-wrapper")&&i("GET_ALLOW_FILE_ENCODE")&&a.registerWriter(s({DID_LOAD_ITEM:({root:e,action:t})=>{if(i("IS_ASYNC"))return;const a=i("GET_ITEM",t.id),s=a.getMetadata(),n=s.base64;delete s.base64,e.ref.data.value=JSON.stringify({id:a.id,name:a.file.name,type:a.file.type,size:a.file.size,metadata:s,data:n})}}))}),{options:{allowFileEncode:[!0,a.BOOLEAN]}}};"undefined"!=typeof navigator&&document&&document.dispatchEvent(new CustomEvent("FilePond:pluginloaded",{detail:plugin$1}));export default plugin$1; |
/* | ||
* FilePondPluginFileEncode 1.0.4 | ||
* FilePondPluginFileEncode 1.0.5 | ||
* Licensed under MIT, https://opensource.org/licenses/MIT | ||
@@ -45,3 +45,4 @@ * Please visit https://pqina.nl/filepond for details. | ||
createWorker = utils.createWorker, | ||
createRoute = utils.createRoute; | ||
createRoute = utils.createRoute, | ||
isFile = utils.isFile; | ||
@@ -58,2 +59,8 @@ addFilter('SHOULD_PREPARE_OUTPUT', function(shouldPrepareOutput) { | ||
return new Promise(function(resolve, reject) { | ||
// this is not a file, continue | ||
if (!isFile(file)) { | ||
resolve(file); | ||
return; | ||
} | ||
var metadata = item.getMetadata(); | ||
@@ -60,0 +67,0 @@ delete metadata.base64; |
/* | ||
* FilePondPluginFileEncode 1.0.4 | ||
* FilePondPluginFileEncode 1.0.5 | ||
* Licensed under MIT, https://opensource.org/licenses/MIT | ||
* Please visit https://pqina.nl/filepond for details. | ||
*/ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.FilePondPluginFileEncode=t()}(this,function(){"use strict";var e=function(){self.onmessage=function(t){e(t.data.message,function(e){self.postMessage({id:t.data.id,message:e})})};var e=function(e,t){var n=e.file,a=new FileReader;a.onloadend=function(){t(a.result.replace("data:","").replace(/^.+,/,""))},a.readAsDataURL(n)}},t=function(t){var n=t.addFilter,a=t.utils,i=a.Type,o=a.createWorker,r=a.createRoute;return n("SHOULD_PREPARE_OUTPUT",function(e){return new Promise(function(e,t){e(!0)})}),n("COMPLETE_PREPARE_OUTPUT",function(t,n){var a=n.item;return new Promise(function(n,i){var r=a.getMetadata();delete r.base64;var d=o(e);d.post({file:t},function(e){a.setMetadata("base64",e),n(t)})})}),n("CREATE_VIEW",function(e){var t=e.is,n=e.view,a=e.query;t("file-wrapper")&&a("GET_ALLOW_FILE_ENCODE")&&n.registerWriter(r({DID_LOAD_ITEM:function(e){var t=e.root,n=e.action;if(!a("IS_ASYNC")){var i=a("GET_ITEM",n.id),o=i.getMetadata(),r=o.base64;delete o.base64,t.ref.data.value=JSON.stringify({id:i.id,name:i.file.name,type:i.file.type,size:i.file.size,metadata:o,data:r})}}}))}),{options:{allowFileEncode:[!0,i.BOOLEAN]}}};return"undefined"!=typeof navigator&&document&&document.dispatchEvent(new CustomEvent("FilePond:pluginloaded",{detail:t})),t}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.FilePondPluginFileEncode=t()}(this,function(){"use strict";var e=function(){self.onmessage=function(t){e(t.data.message,function(e){self.postMessage({id:t.data.id,message:e})})};var e=function(e,t){var n=e.file,i=new FileReader;i.onloadend=function(){t(i.result.replace("data:","").replace(/^.+,/,""))},i.readAsDataURL(n)}},t=function(t){var n=t.addFilter,i=t.utils,a=i.Type,o=i.createWorker,r=i.createRoute,d=i.isFile;return n("SHOULD_PREPARE_OUTPUT",function(e){return new Promise(function(e,t){e(!0)})}),n("COMPLETE_PREPARE_OUTPUT",function(t,n){var i=n.item;return new Promise(function(n,a){if(!d(t))return void n(t);var r=i.getMetadata();delete r.base64;var f=o(e);f.post({file:t},function(e){i.setMetadata("base64",e),n(t)})})}),n("CREATE_VIEW",function(e){var t=e.is,n=e.view,i=e.query;t("file-wrapper")&&i("GET_ALLOW_FILE_ENCODE")&&n.registerWriter(r({DID_LOAD_ITEM:function(e){var t=e.root,n=e.action;if(!i("IS_ASYNC")){var a=i("GET_ITEM",n.id),o=a.getMetadata(),r=o.base64;delete o.base64,t.ref.data.value=JSON.stringify({id:a.id,name:a.file.name,type:a.file.type,size:a.file.size,metadata:o,data:r})}}}))}),{options:{allowFileEncode:[!0,a.BOOLEAN]}}};return"undefined"!=typeof navigator&&document&&document.dispatchEvent(new CustomEvent("FilePond:pluginloaded",{detail:t})),t}); |
{ | ||
"name": "filepond-plugin-file-encode", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "File Encoding Plugin for FilePond", | ||
@@ -14,3 +14,6 @@ "homepage": "https://pqina.nl/filepond", | ||
"url": "https://pqina.nl" | ||
}, | ||
"peerDependencies": { | ||
"filepond": "^1.8.0" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
11535
231
1