Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/ffmpeg/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"webpack-cli": "^5.1.4"
},
"dependencies": {
"@types/trusted-types": "^2.0.7",
"@ffmpeg/types": "^0.12.4"
}
}
9 changes: 5 additions & 4 deletions packages/ffmpeg/src/classes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,17 +185,18 @@ export class FFmpeg {
* @returns `true` if ffmpeg core is loaded for the first time.
*/
public load = (
{ classWorkerURL, ...config }: FFMessageLoadConfig = {},
{ classWorkerURL, trustedTypePolicy, ...config }: FFMessageLoadConfig = { },
{ signal }: FFMessageOptions = {}
): Promise<IsFirst> => {
const createScriptURL = ((url: string) => ((trustedTypePolicy ?? window.trustedTypes?.defaultPolicy)?.createScriptURL?.(url) ?? url) as unknown as string)
if (!this.#worker) {
this.#worker = classWorkerURL ?
new Worker(new URL(classWorkerURL, import.meta.url), {
new Worker(createScriptURL(new URL(classWorkerURL, import.meta.url).toString()), {
type: "module",
}) :
// We need to duplicated the code here to enable webpack
// to bundle worekr.js here.
new Worker(new URL("./worker.js", import.meta.url), {
new Worker(createScriptURL(new URL("./worker.js", import.meta.url).toString()), {
type: "module",
});
this.#registerHandlers();
Expand Down Expand Up @@ -340,7 +341,7 @@ export class FFmpeg {
) as Promise<OK>;
};

public mount = (fsType: FFFSType, options: FFFSMountOptions, mountPoint: FFFSPath, ): Promise<OK> => {
public mount = (fsType: FFFSType, options: FFFSMountOptions, mountPoint: FFFSPath): Promise<OK> => {
const trans: Transferable[] = [];
return this.#send(
{
Expand Down
5 changes: 5 additions & 0 deletions packages/ffmpeg/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ export interface FFMessageLoadConfig {
* @defaultValue `./worker.js`
*/
classWorkerURL?: string;

/**
* Trusted type policy to use on workers
*/
trustedTypePolicy?: TrustedTypePolicy
}

export interface FFMessageExecData {
Expand Down