11// add support for cordova-plugin-file
2- const moduleMapper = typeof window !== 'undefined' && window . cordova && window . cordova . require && window . cordova . require ( 'cordova/modulemapper' ) ;
3- export const CustomFile = ( moduleMapper && moduleMapper . getOriginalSymbol ( window , 'File' ) ) || File ;
4- export const CustomFileReader = ( moduleMapper && moduleMapper . getOriginalSymbol ( window , 'FileReader' ) ) || FileReader ;
2+ const moduleMapper = typeof window !== 'undefined' && window . cordova && window . cordova . require && window . cordova . require ( 'cordova/modulemapper' )
3+ export const CustomFile = ( moduleMapper && moduleMapper . getOriginalSymbol ( window , 'File' ) ) || File
4+ export const CustomFileReader = ( moduleMapper && moduleMapper . getOriginalSymbol ( window , 'FileReader' ) ) || FileReader
5+
56/**
67 * getDataUrlFromFile
78 *
@@ -259,6 +260,9 @@ export function getNewCanvasAndCtx (width, height) {
259260 try {
260261 canvas = new OffscreenCanvas ( width , height )
261262 ctx = canvas . getContext ( '2d' )
263+ if ( ctx === null ) {
264+ throw new Error ( 'getContext of OffscreenCanvas returns null' )
265+ }
262266 } catch ( e ) {
263267 canvas = document . createElement ( 'canvas' )
264268 ctx = canvas . getContext ( '2d' )
@@ -268,18 +272,19 @@ export function getNewCanvasAndCtx (width, height) {
268272 return [ canvas , ctx ]
269273}
270274
271- Number . isInteger = Number . isInteger || function ( value ) {
272- return typeof value === 'number' &&
273- isFinite ( value ) &&
274- Math . floor ( value ) === value ;
275+ Number . isInteger = Number . isInteger || function ( value ) {
276+ return typeof value === 'number' &&
277+ isFinite ( value ) &&
278+ Math . floor ( value ) === value
279+ }
275280
276281/**
277282 * clear Canvas memory
278283 * @param canvas
279284 * @returns null
280285 */
281- export function cleanupMemory ( canvas ) {
282- canvas . width = 0 ;
283- canvas . height = 0 ;
284- canvas = null ;
286+ export function cleanupMemory ( canvas ) {
287+ canvas . width = 0
288+ canvas . height = 0
289+ canvas = null
285290}
0 commit comments