Skip to content

Commit e609b6c

Browse files
kompfnermattieruth
authored andcommitted
Only use the new eval-less web bundle loading strategy when avoidEval is passed into dailyConfig
1 parent 2e7cb78 commit e609b6c

3 files changed

Lines changed: 29 additions & 10 deletions

File tree

index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ export interface DailyAdvancedConfig {
258258
useDevicePreferenceCookies?: boolean;
259259
userMediaAudioConstraints?: boolean | MediaTrackConstraints;
260260
userMediaVideoConstraints?: boolean | MediaTrackConstraints;
261+
avoidEval?: boolean;
261262
}
262263

263264
export interface DailyTrackState {

src/CallObjectLoader.js

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import { isReactNative } from './shared-with-pluot-core/Environment';
22
import { callObjectBundleUrl, randomStringId } from './utils';
33

4-
function prepareDailyConfig(callFrameId) {
4+
function prepareDailyConfig(callFrameId, avoidEval) {
55
// Add a global callFrameId so we can have both iframes and one
66
// call object mode calls live at the same time
77
if (!window._dailyConfig) {
88
window._dailyConfig = {};
99
}
1010
window._dailyConfig.callFrameId = callFrameId;
11+
window._dailyConfig.avoidEval = avoidEval;
1112
}
1213

1314
export default class CallObjectLoader {
@@ -29,19 +30,28 @@ export default class CallObjectLoader {
2930
* to load the bundle from.
3031
* @param callFrameId A string identifying this "call frame", to distinguish it
3132
* from other iframe-based calls for message channel purposes.
33+
* @param avoidEval Whether to use the new eval-less loading mechanism on web
34+
* (LoadAttempt_Web) instead of the legacy loading mechanism
35+
* (LoadAttempt_ReactNative).
3236
* @param successCallback Callback function that takes a wasNoOp argument
3337
* (true if call object script was ever loaded once before).
3438
* @param failureCallback Callback function that takes an error message and a
3539
* boolean indicating whether an automatic retry is slated to occur.
3640
*/
37-
load(meetingOrBaseUrl, callFrameId, successCallback, failureCallback) {
41+
load(
42+
meetingOrBaseUrl,
43+
callFrameId,
44+
avoidEval,
45+
successCallback,
46+
failureCallback
47+
) {
3848
if (this.loaded) {
3949
window._dailyCallObjectSetup(callFrameId);
4050
successCallback(true); // true = "this load() was a no-op"
4151
return;
4252
}
4353

44-
prepareDailyConfig(callFrameId);
54+
prepareDailyConfig(callFrameId, avoidEval);
4555

4656
// Cancel current load, if any
4757
this._currentLoad && this._currentLoad.cancel();
@@ -178,13 +188,18 @@ const LOAD_ATTEMPT_NETWORK_TIMEOUT = 20 * 1000;
178188
*/
179189
class LoadAttempt {
180190
constructor(meetingOrBaseUrl, successCallback, failureCallback) {
181-
this._loadAttemptImpl = isReactNative()
182-
? new LoadAttempt_ReactNative(
183-
meetingOrBaseUrl,
184-
successCallback,
185-
failureCallback
186-
)
187-
: new LoadAttempt_Web(meetingOrBaseUrl, successCallback, failureCallback);
191+
this._loadAttemptImpl =
192+
isReactNative() || !_dailyConfig.avoidEval
193+
? new LoadAttempt_ReactNative(
194+
meetingOrBaseUrl,
195+
successCallback,
196+
failureCallback
197+
)
198+
: new LoadAttempt_Web(
199+
meetingOrBaseUrl,
200+
successCallback,
201+
failureCallback
202+
);
188203
}
189204

190205
async start() {
@@ -206,6 +221,8 @@ class LoadAttempt {
206221

207222
/**
208223
* Represents a single call machine bundle load attempt in React Native.
224+
*
225+
* NOTE: this is also the legacy web code path, when avoidEval is not set.
209226
*/
210227
class LoadAttempt_ReactNative {
211228
// Here successCallback takes no parameters, and failureCallback takes a

src/module.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1855,6 +1855,7 @@ export default class DailyIframe extends EventEmitter {
18551855
this._callObjectLoader.load(
18561856
this.properties.url || this.properties.baseUrl,
18571857
this._callFrameId,
1858+
this.properties.dailyConfig && this.properties.dailyConfig.avoidEval,
18581859
(wasNoOp) => {
18591860
this.updateMeetingState(DAILY_STATE_LOADED);
18601861
// Only need to emit event if load was a no-op, since the loaded

0 commit comments

Comments
 (0)