mirror of
https://github.com/element-hq/element-call.git
synced 2026-11-12 22:37:53 +00:00
fix Config.get before ready
This commit is contained in:
1 parent
fbac98f0eb
commit
a2b51c94a0
3 files changed
+16
-7
No files matched your search
@@ -76,10 +76,14 @@ describe("BackgroundEffectTransformer", () => {
|
||||
.spyOn(FilesetResolver, "forVisionTasks")
|
||||
.mockResolvedValue(served);
|
||||
|
||||
await new BackgroundEffectTransformer(
|
||||
const wasmBaseUrl = vi.fn(() => "https://cdn.example.org/mediapipe");
|
||||
const transformer = new BackgroundEffectTransformer(
|
||||
{ backgroundDisabled: true },
|
||||
{ wasmBaseUrl: "https://cdn.example.org/mediapipe" },
|
||||
).init({} as VideoTransformerInitOptions);
|
||||
{ wasmBaseUrl },
|
||||
);
|
||||
expect(wasmBaseUrl).not.toHaveBeenCalled();
|
||||
|
||||
await transformer.init({} as VideoTransformerInitOptions);
|
||||
|
||||
expect(resolve).toHaveBeenCalledWith("https://cdn.example.org/mediapipe");
|
||||
expect(create.mock.calls[0][0]).toBe(served);
|
||||
|
||||
@@ -36,8 +36,10 @@ export interface BackgroundEffectTransformerSources {
|
||||
/**
|
||||
* Where to fetch MediaPipe's runtime from instead of the bundled copy: a
|
||||
* directory holding its `vision_wasm_internal.js` and `.wasm` files.
|
||||
* Consulted only when the runtime is about to load, so a transformer can be
|
||||
* built before the deployment's config has arrived.
|
||||
*/
|
||||
wasmBaseUrl?: string;
|
||||
wasmBaseUrl?: () => string | undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -94,10 +96,11 @@ export class BackgroundEffectTransformer extends BackgroundTransformer {
|
||||
inputElement: inputVideo,
|
||||
});
|
||||
|
||||
const wasmBaseUrl = this.sources.wasmBaseUrl?.();
|
||||
const fileset =
|
||||
this.sources.wasmBaseUrl === undefined
|
||||
wasmBaseUrl === undefined
|
||||
? bundledFileset
|
||||
: await FilesetResolver.forVisionTasks(this.sources.wasmBaseUrl);
|
||||
: await FilesetResolver.forVisionTasks(wasmBaseUrl);
|
||||
this.imageSegmenter = await ImageSegmenter.createFromOptions(fileset, {
|
||||
baseOptions: {
|
||||
modelAssetPath,
|
||||
|
||||
@@ -50,7 +50,9 @@ export function createAppBackgroundEffects(
|
||||
): BackgroundEffects {
|
||||
const transformer = new BackgroundEffectTransformer(
|
||||
{ backgroundDisabled: true },
|
||||
{ wasmBaseUrl: Config.get().background_effects?.mediapipe_wasm_url },
|
||||
{
|
||||
wasmBaseUrl: () => Config.get().background_effects?.mediapipe_wasm_url,
|
||||
},
|
||||
);
|
||||
return createBackgroundEffects(scope, {
|
||||
supported: supportsBackgroundProcessors(),
|
||||
|
||||
Reference in new issue
Block a user