11import { isReactNative } from './shared-with-pluot-core/Environment' ;
22import { 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
1314export 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 */
179189class 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 */
210227class LoadAttempt_ReactNative {
211228 // Here successCallback takes no parameters, and failureCallback takes a
0 commit comments