Removed references to resolveURL
This commit is contained in:
		
							parent
							
								
									8d45d585b2
								
							
						
					
					
						commit
						6e99e5f96f
					
				| @ -1,4 +1,3 @@ | ||||
| const resolveURL = require('resolve-url'); | ||||
| const { devDependencies } = require('../../package.json'); | ||||
| 
 | ||||
| /* | ||||
| @ -6,6 +5,6 @@ const { devDependencies } = require('../../package.json'); | ||||
|  */ | ||||
| module.exports = { | ||||
|   corePath: typeof process !== 'undefined' && process.env.NODE_ENV === 'development' | ||||
|     ? resolveURL('/node_modules/@ffmpeg/core/dist/ffmpeg-core.js') | ||||
|     ? new URL('/node_modules/@ffmpeg/core/dist/ffmpeg-core.js', import.meta.url).href | ||||
|     : `https://unpkg.com/@ffmpeg/core@${devDependencies['@ffmpeg/core'].substring(1)}/dist/ffmpeg-core.js`, | ||||
| }; | ||||
|  | ||||
| @ -1,5 +1,3 @@ | ||||
| const resolveURL = require('resolve-url'); | ||||
| 
 | ||||
| const readFromBlobOrFile = (blob) => ( | ||||
|   new Promise((resolve, reject) => { | ||||
|     const fileReader = new FileReader(); | ||||
| @ -27,7 +25,7 @@ module.exports = async (_data) => { | ||||
|         .map((c) => c.charCodeAt(0)); | ||||
|     /* From remote server/URL */ | ||||
|     } else { | ||||
|       const res = await fetch(resolveURL(_data)); | ||||
|       const res = await fetch(new URL(_data, import.meta.url).href); | ||||
|       data = await res.arrayBuffer(); | ||||
|     } | ||||
|   /* From Blob or File */ | ||||
|  | ||||
| @ -1,5 +1,4 @@ | ||||
| /* eslint-disable no-undef */ | ||||
| const resolveURL = require('resolve-url'); | ||||
| const { log } = require('../utils/log'); | ||||
| const { | ||||
|   CREATE_FFMPEG_CORE_IS_NOT_DEFINED, | ||||
| @ -19,11 +18,54 @@ const toBlobURL = async (url, mimeType) => { | ||||
|   return blobURL; | ||||
| }; | ||||
| 
 | ||||
| if (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope) { | ||||
|   // in Web Worker context
 | ||||
|   module.exports = async ({ corePath: _corePath }) => { | ||||
|     if (typeof _corePath !== 'string') { | ||||
|       throw Error('corePath should be a string!'); | ||||
|     } | ||||
|   const coreRemotePath = resolveURL(_corePath); | ||||
|     const coreRemotePath = new URL(_corePath, import.meta.url).href; | ||||
|     const corePath = await toBlobURL( | ||||
|       coreRemotePath, | ||||
|       'application/javascript', | ||||
|     ); | ||||
|     const wasmPath = await toBlobURL( | ||||
|       coreRemotePath.replace('ffmpeg-core.js', 'ffmpeg-core.wasm'), | ||||
|       'application/wasm', | ||||
|     ); | ||||
|     const workerPath = await toBlobURL( | ||||
|       coreRemotePath.replace('ffmpeg-core.js', 'ffmpeg-core.worker.js'), | ||||
|       'application/javascript', | ||||
|     ); | ||||
|     if (typeof createFFmpegCore === 'undefined') { | ||||
|       return new Promise((resolve) => { | ||||
|         if (typeof createFFmpegCore === 'undefined') { | ||||
|           throw Error(CREATE_FFMPEG_CORE_IS_NOT_DEFINED(coreRemotePath)); | ||||
|         } | ||||
|         importScripts(corePath); | ||||
|         log('info', 'ffmpeg-core.js script loaded'); | ||||
|         resolve({ | ||||
|           createFFmpegCore, | ||||
|           corePath, | ||||
|           wasmPath, | ||||
|           workerPath, | ||||
|         }); | ||||
|       }); | ||||
|     } | ||||
|     log('info', 'ffmpeg-core.js script is loaded already'); | ||||
|     return Promise.resolve({ | ||||
|       createFFmpegCore, | ||||
|       corePath, | ||||
|       wasmPath, | ||||
|       workerPath, | ||||
|     }); | ||||
|   }; | ||||
| } else { | ||||
|   module.exports = async ({ corePath: _corePath }) => { | ||||
|     if (typeof _corePath !== 'string') { | ||||
|       throw Error('corePath should be a string!'); | ||||
|     } | ||||
|     const coreRemotePath = new URL(_corePath, import.meta.url).href; | ||||
|     const corePath = await toBlobURL( | ||||
|       coreRemotePath, | ||||
|       'application/javascript', | ||||
| @ -66,3 +108,5 @@ module.exports = async ({ corePath: _corePath }) => { | ||||
|       workerPath, | ||||
|     }); | ||||
|   }; | ||||
| } | ||||
| 
 | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Nathan Johnson
						Nathan Johnson