Fix lint error
This commit is contained in:
parent
6de5d2dc50
commit
e6fe3d1aae
@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"extends": "airbnb-base",
|
"extends": "airbnb-base",
|
||||||
|
"parser": "babel-eslint",
|
||||||
"rules": {
|
"rules": {
|
||||||
"no-underscore-dangle": 0,
|
"no-underscore-dangle": 0,
|
||||||
"linebreak-style": 0,
|
"linebreak-style": 0,
|
||||||
|
2283
package-lock.json
generated
2283
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -54,6 +54,7 @@
|
|||||||
"@babel/preset-env": "^7.12.1",
|
"@babel/preset-env": "^7.12.1",
|
||||||
"@ffmpeg/core": "^0.11.0",
|
"@ffmpeg/core": "^0.11.0",
|
||||||
"@types/emscripten": "^1.39.4",
|
"@types/emscripten": "^1.39.4",
|
||||||
|
"babel-eslint": "^10.1.0",
|
||||||
"babel-loader": "^8.1.0",
|
"babel-loader": "^8.1.0",
|
||||||
"chai": "^4.2.0",
|
"chai": "^4.2.0",
|
||||||
"cors": "^2.8.5",
|
"cors": "^2.8.5",
|
||||||
|
@ -4,7 +4,7 @@ const { devDependencies } = require('../../package.json');
|
|||||||
* Default options for browser environment
|
* Default options for browser environment
|
||||||
*/
|
*/
|
||||||
const corePath = typeof process !== 'undefined' && process.env.NODE_ENV === 'development'
|
const corePath = typeof process !== 'undefined' && process.env.NODE_ENV === 'development'
|
||||||
? new URL('/node_modules/@ffmpeg/core/dist/ffmpeg-core.js', import.meta.url).href
|
? 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`
|
: `https://unpkg.com/@ffmpeg/core@${devDependencies['@ffmpeg/core'].substring(1)}/dist/ffmpeg-core.js`;
|
||||||
|
|
||||||
export {corePath};
|
module.exports = { corePath };
|
||||||
|
@ -11,6 +11,7 @@ const readFromBlobOrFile = (blob) => (
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// eslint-disable-next-line
|
||||||
export const fetchFile = async (_data) => {
|
export const fetchFile = async (_data) => {
|
||||||
let data = _data;
|
let data = _data;
|
||||||
if (typeof _data === 'undefined') {
|
if (typeof _data === 'undefined') {
|
||||||
|
@ -18,8 +18,14 @@ const toBlobURL = async (url, mimeType) => {
|
|||||||
return blobURL;
|
return blobURL;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getCreateFFmpegCore = async ({ corePath: _corePath, workerPath: _workerPath, wasmPath: _wasmPath }) => {
|
// eslint-disable-next-line
|
||||||
|
export const getCreateFFmpegCore = async ({
|
||||||
|
corePath: _corePath,
|
||||||
|
workerPath: _workerPath,
|
||||||
|
wasmPath: _wasmPath,
|
||||||
|
}) => {
|
||||||
// in Web Worker context
|
// in Web Worker context
|
||||||
|
// eslint-disable-next-line
|
||||||
if (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope) {
|
if (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope) {
|
||||||
if (typeof _corePath !== 'string') {
|
if (typeof _corePath !== 'string') {
|
||||||
throw Error('corePath should be a string!');
|
throw Error('corePath should be a string!');
|
||||||
@ -59,54 +65,50 @@ export const getCreateFFmpegCore = async ({ corePath: _corePath, workerPath: _wo
|
|||||||
wasmPath,
|
wasmPath,
|
||||||
workerPath,
|
workerPath,
|
||||||
});
|
});
|
||||||
} else {
|
}
|
||||||
if (typeof _corePath !== 'string') {
|
if (typeof _corePath !== 'string') {
|
||||||
throw Error('corePath should be a string!');
|
throw Error('corePath should be a string!');
|
||||||
}
|
}
|
||||||
const coreRemotePath = new URL(_corePath, import.meta.url).href;
|
const coreRemotePath = new URL(_corePath, import.meta.url).href;
|
||||||
const corePath = await toBlobURL(
|
const corePath = await toBlobURL(
|
||||||
coreRemotePath,
|
coreRemotePath,
|
||||||
'application/javascript',
|
'application/javascript',
|
||||||
);
|
);
|
||||||
const wasmPath = await toBlobURL(
|
const wasmPath = await toBlobURL(
|
||||||
coreRemotePath.replace('ffmpeg-core.js', 'ffmpeg-core.wasm'),
|
coreRemotePath.replace('ffmpeg-core.js', 'ffmpeg-core.wasm'),
|
||||||
'application/wasm',
|
'application/wasm',
|
||||||
);
|
);
|
||||||
const workerPath = await toBlobURL(
|
const workerPath = await toBlobURL(
|
||||||
coreRemotePath.replace('ffmpeg-core.js', 'ffmpeg-core.worker.js'),
|
coreRemotePath.replace('ffmpeg-core.js', 'ffmpeg-core.worker.js'),
|
||||||
'application/javascript',
|
'application/javascript',
|
||||||
);
|
);
|
||||||
if (typeof createFFmpegCore === 'undefined') {
|
if (typeof createFFmpegCore === 'undefined') {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
const script = document.createElement('script');
|
const script = document.createElement('script');
|
||||||
const eventHandler = () => {
|
const eventHandler = () => {
|
||||||
script.removeEventListener('load', eventHandler);
|
script.removeEventListener('load', eventHandler);
|
||||||
if (typeof createFFmpegCore === 'undefined') {
|
if (typeof createFFmpegCore === 'undefined') {
|
||||||
throw Error(CREATE_FFMPEG_CORE_IS_NOT_DEFINED(coreRemotePath));
|
throw Error(CREATE_FFMPEG_CORE_IS_NOT_DEFINED(coreRemotePath));
|
||||||
}
|
}
|
||||||
log('info', 'ffmpeg-core.js script loaded');
|
log('info', 'ffmpeg-core.js script loaded');
|
||||||
resolve({
|
resolve({
|
||||||
createFFmpegCore,
|
createFFmpegCore,
|
||||||
corePath,
|
corePath,
|
||||||
wasmPath,
|
wasmPath,
|
||||||
workerPath,
|
workerPath,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
script.src = corePath;
|
script.src = corePath;
|
||||||
script.type = 'text/javascript';
|
script.type = 'text/javascript';
|
||||||
script.addEventListener('load', eventHandler);
|
script.addEventListener('load', eventHandler);
|
||||||
document.getElementsByTagName('head')[0].appendChild(script);
|
document.getElementsByTagName('head')[0].appendChild(script);
|
||||||
});
|
|
||||||
}
|
|
||||||
log('info', 'ffmpeg-core.js script is loaded already');
|
|
||||||
return Promise.resolve({
|
|
||||||
createFFmpegCore,
|
|
||||||
corePath,
|
|
||||||
wasmPath,
|
|
||||||
workerPath,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
log('info', 'ffmpeg-core.js script is loaded already');
|
||||||
}
|
return Promise.resolve({
|
||||||
|
createFFmpegCore,
|
||||||
|
corePath,
|
||||||
|
wasmPath,
|
||||||
|
workerPath,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user