@@ -185,17 +185,18 @@ export class FFmpeg {
185
185
* @returns `true` if ffmpeg core is loaded for the first time.
186
186
*/
187
187
public load = (
188
- { classWorkerURL, ...config } : FFMessageLoadConfig = { } ,
188
+ { classWorkerURL, trustedTypePolicy , ...config } : FFMessageLoadConfig = { } ,
189
189
{ signal } : FFMessageOptions = { }
190
190
) : Promise < IsFirst > => {
191
+ const createScriptURL = ( ( url : string ) => ( trustedTypePolicy ?? window . trustedTypes ?. defaultPolicy ) ?. createScriptURL ?.( url ) ?? url )
191
192
if ( ! this . #worker) {
192
193
this . #worker = classWorkerURL ?
193
- new Worker ( new URL ( classWorkerURL , import . meta. url ) , {
194
+ new Worker ( createScriptURL ( new URL ( classWorkerURL , import . meta. url ) . toString ( ) ) , {
194
195
type : "module" ,
195
196
} ) :
196
197
// We need to duplicated the code here to enable webpack
197
198
// to bundle worekr.js here.
198
- new Worker ( new URL ( "./worker.js" , import . meta. url ) , {
199
+ new Worker ( createScriptURL ( new URL ( "./worker.js" , import . meta. url ) . toString ( ) ) , {
199
200
type : "module" ,
200
201
} ) ;
201
202
this . #registerHandlers( ) ;
@@ -340,7 +341,7 @@ export class FFmpeg {
340
341
) as Promise < OK > ;
341
342
} ;
342
343
343
- public mount = ( fsType : FFFSType , options : FFFSMountOptions , mountPoint : FFFSPath , ) : Promise < OK > => {
344
+ public mount = ( fsType : FFFSType , options : FFFSMountOptions , mountPoint : FFFSPath ) : Promise < OK > => {
344
345
const trans : Transferable [ ] = [ ] ;
345
346
return this . #send(
346
347
{
0 commit comments