File tree Expand file tree Collapse file tree 7 files changed +25
-19
lines changed Expand file tree Collapse file tree 7 files changed +25
-19
lines changed Original file line number Diff line number Diff line change 11{
22 "name" : " @ffmpeg/ffmpeg" ,
3- "version" : " 0.12.1 " ,
3+ "version" : " 0.12.2 " ,
44 "description" : " FFmpeg WebAssembly version for browser" ,
55 "main" : " ./dist/umd/ffmpeg.js" ,
66 "types" : " ./dist/esm/index.d.ts" ,
1717 "clean" : " rimraf dist" ,
1818 "build:esm" : " tsc -p tsconfig.esm.json" ,
1919 "build:umd" : " webpack" ,
20- "build" : " npm run clean && npm run build:esm && npm run build:umd"
20+ "build" : " npm run clean && npm run build:esm && npm run build:umd" ,
21+ "prepublishOnly" : " npm run build"
2122 },
2223 "files" : [
2324 " dist" ,
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ export const CORE_VERSION = "0.12.1";
55export const CORE_URL = `https://unpkg.com/@ffmpeg/core@${ CORE_VERSION } /dist/umd/ffmpeg-core.js` ;
66
77export enum FFMessageType {
8- LOAD = "load " ,
8+ LOAD = "LOAD " ,
99 EXEC = "EXEC" ,
1010 WRITE_FILE = "WRITE_FILE" ,
1111 READ_FILE = "READ_FILE" ,
Original file line number Diff line number Diff line change @@ -3,3 +3,6 @@ export const ERROR_NOT_LOADED = new Error(
33 "ffmpeg is not loaded, call `await ffmpeg.load()` first"
44) ;
55export const ERROR_TERMINATED = new Error ( "called FFmpeg.terminate()" ) ;
6+ export const ERROR_IMPORT_FAILURE = new Error (
7+ "failed to import ffmpeg-core.js"
8+ ) ;
Original file line number Diff line number Diff line change @@ -22,13 +22,6 @@ export interface FFMessageLoadConfig {
2222 * @defaultValue `https://unpkg.com/@ffmpeg/core-mt@${CORE_VERSION}/dist/umd/ffmpeg-core.worker.js`;
2323 */
2424 workerURL ?: string ;
25- /**
26- * When `thread` is true, ffmpeg imports `ffmpeg-core.worker.js` and thus
27- * makes multi-threaded core work.
28- *
29- * @defaultValue `false`
30- */
31- thread ?: boolean ;
3225}
3326
3427export interface FFMessageExecData {
Original file line number Diff line number Diff line change @@ -22,7 +22,11 @@ import type {
2222 FileData ,
2323} from "./types" ;
2424import { CORE_URL , FFMessageType } from "./const.js" ;
25- import { ERROR_UNKNOWN_MESSAGE_TYPE , ERROR_NOT_LOADED } from "./errors.js" ;
25+ import {
26+ ERROR_UNKNOWN_MESSAGE_TYPE ,
27+ ERROR_NOT_LOADED ,
28+ ERROR_IMPORT_FAILURE ,
29+ } from "./errors.js" ;
2630
2731declare global {
2832 interface WorkerGlobalScope {
@@ -51,13 +55,17 @@ const load = async ({
5155 try {
5256 // when web worker type is `classic`.
5357 importScripts ( coreURL ) ;
54- } catch ( e : unknown ) {
58+ } catch {
5559 // when web worker type is `module`.
56- if ( e instanceof TypeError && e . toString ( ) . includes ( "Module scripts" ) ) {
57- ( self as WorkerGlobalScope ) . createFFmpegCore = (
58- ( await import ( coreURL ) ) as ImportedFFmpegCoreModuleFactory
59- ) . default ;
60- } else throw e ;
60+ ( self as WorkerGlobalScope ) . createFFmpegCore = (
61+ ( await import (
62+ /* @vite -ignore */ coreURL
63+ ) ) as ImportedFFmpegCoreModuleFactory
64+ ) . default ;
65+
66+ if ( ! ( self as WorkerGlobalScope ) . createFFmpegCore ) {
67+ throw ERROR_IMPORT_FAILURE ;
68+ }
6169 }
6270
6371 ffmpeg = await ( self as WorkerGlobalScope ) . createFFmpegCore ( {
Original file line number Diff line number Diff line change 1717 "clean" : " rimraf dist" ,
1818 "build:esm" : " tsc -p tsconfig.esm.json" ,
1919 "build:umd" : " tsc -p tsconfig.cjs.json && webpack" ,
20- "build" : " npm run clean && npm run build:esm && npm run build:umd"
20+ "build" : " npm run clean && npm run build:esm && npm run build:umd" ,
21+ "prepublishOnly" : " npm run build"
2122 },
2223 "files" : [
2324 " dist"
You can’t perform that action at this time.
0 commit comments