Skip to content

Commit d216f27

Browse files
committed
use vite worker syntax
1 parent 9f2d1b3 commit d216f27

File tree

5 files changed

+23
-29
lines changed

5 files changed

+23
-29
lines changed

react/features/base/i18n/i18next.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,10 @@ i18next.addResourceBundle(
128128
/* overwrite */ true);
129129

130130
// Add builtin languages.
131-
// XXX: Note we are using require here, because we want the side-effects of the
132-
// import, but imports can only be placed at the top, and it would be too early,
133-
// since i18next is not yet initialized at that point.
134-
require('./BuiltinLanguages');
131+
// XXX: Note we are importing here, because we want the side-effects of the
132+
// import, but at the top it would be too early since i18next is not yet
133+
// initialized at that point.
134+
import('./BuiltinLanguages');
135135

136136
// Label change through dynamic branding is available only for web
137137
if (typeof APP !== 'undefined') {

react/features/face-landmarks/FaceLandmarksDetector.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import 'image-capture';
22
import { IStore } from '../app/types';
33
import { isMobileBrowser } from '../base/environment/utils';
44
import { getLocalVideoTrack } from '../base/tracks/functions';
5-
import { getBaseUrl } from '../base/util/helpers';
65

76
import {
87
addFaceLandmarks,
@@ -94,17 +93,16 @@ class FaceLandmarksDetector {
9493
return;
9594
}
9695

97-
const baseUrl = `${getBaseUrl()}libs/`;
98-
let workerUrl = `${baseUrl}face-landmarks-worker.min.js`;
99-
100-
// @ts-ignore
101-
const workerBlob = new Blob([ `importScripts("${workerUrl}");` ], { type: 'application/javascript' });
10296
const state = getState();
10397
const addToBuffer = Boolean(state['features/base/config'].webhookProxyUrl);
10498

105-
// @ts-ignore
106-
workerUrl = window.URL.createObjectURL(workerBlob);
107-
this.worker = new Worker(workerUrl, { name: 'Face Landmarks Worker' });
99+
this.worker = new Worker(
100+
new URL('./faceLandmarksWorker.ts', import.meta.url),
101+
{
102+
name: 'Face Landmarks Worker',
103+
type: 'module'
104+
}
105+
);
108106
this.worker.onmessage = ({ data }: MessageEvent<any>) => {
109107
const { faceExpression, faceBox, faceCount } = data;
110108
const messageTimestamp = Date.now();
@@ -159,7 +157,7 @@ class FaceLandmarksDetector {
159157

160158
this.worker.postMessage({
161159
type: INIT_WORKER,
162-
baseUrl,
160+
baseUrl: '', // Vite mode - baseUrl not needed
163161
detectionTypes
164162
});
165163
this.initialized = true;

react/features/screenshot-capture/ScreenshotCaptureSummary.tsx

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { sendAnalytics } from '../analytics/functions';
55
import { IReduxState } from '../app/types';
66
import { getCurrentConference } from '../base/conference/functions';
77
import { getLocalParticipant, getRemoteParticipants } from '../base/participants/functions';
8-
import { getBaseUrl } from '../base/util/helpers';
98
import { extractFqnFromPath } from '../dynamic-branding/functions.any';
109

1110
import {
@@ -43,16 +42,14 @@ export default class ScreenshotCaptureSummary {
4342

4443
// Bind handlers such that they access the same instance.
4544
this._handleWorkerAction = this._handleWorkerAction.bind(this);
46-
const baseUrl = `${getBaseUrl()}libs/`;
4745

48-
let workerUrl = `${baseUrl}screenshot-capture-worker.min.js`;
49-
50-
// @ts-ignore
51-
const workerBlob = new Blob([ `importScripts("${workerUrl}");` ], { type: 'application/javascript' });
52-
53-
// @ts-ignore
54-
workerUrl = window.URL.createObjectURL(workerBlob);
55-
this._streamWorker = new Worker(workerUrl, { name: 'Screenshot capture worker' });
46+
this._streamWorker = new Worker(
47+
new URL('./worker.ts', import.meta.url),
48+
{
49+
name: 'Screenshot capture worker',
50+
type: 'module'
51+
}
52+
);
5653
this._streamWorker.onmessage = this._handleWorkerAction;
5754

5855
this._initializedRegion = false;

react/features/stream-effects/noise-suppression/NoiseSuppressionEffect.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { INoiseSuppressionConfig } from '../../base/config/configType';
22
import { getBaseUrl } from '../../base/util/helpers';
33

4+
import workletUrl from "./NoiseSuppressorWorklet?worker&url";
5+
46
import logger from './logger';
57

68
interface IKrispState {
@@ -179,7 +181,7 @@ async function _initializeKrisp(
179181

180182
if (!krispState.sdk) {
181183
const baseUrl = `${getBaseUrl()}libs/krisp`;
182-
const { default: KrispSDK } = await import(/* webpackIgnore: true */ `${baseUrl}/krispsdk.mjs`);
184+
const { default: KrispSDK } = await import(/* webpackIgnore: true */ /* @vite-ignore */ `${baseUrl}/krispsdk.mjs`);
183185

184186
const ncParams = {
185187
krisp: {
@@ -260,9 +262,6 @@ async function _initializeKrisp(
260262
async function _initializeKRnnoise(): Promise<AudioWorkletNode | undefined> {
261263
await audioContext.resume();
262264

263-
const baseUrl = `${getBaseUrl()}libs/`;
264-
const workletUrl = `${baseUrl}noise-suppressor-worklet.min.js`;
265-
266265
try {
267266
await audioContext.audioWorklet.addModule(workletUrl);
268267
} catch (e) {

react/features/stream-effects/virtual-background/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export async function createVirtualBackgroundEffect(virtualBackground: IBackgrou
5656

5757
if (!tflite) {
5858
try {
59-
wasmCheck = require('wasm-check');
59+
const { default: wasmCheck } = await import('wasm-check');
6060
const tfliteTimeout = 10000;
6161

6262
if (wasmCheck?.feature?.simd) {

0 commit comments

Comments
 (0)