@daily-co/daily-js
Advanced tools
Comparing version 0.9.992-beta.6 to 0.9.992-beta.7
{ | ||
"name": "@daily-co/daily-js", | ||
"version": "0.9.992-beta.6", | ||
"version": "0.9.992-beta.7", | ||
"engines": { | ||
@@ -10,2 +10,3 @@ "node": ">=10.0.0" | ||
"module": "dist/daily-iframe-esm.js", | ||
"types": "index.d.ts", | ||
"files": "dist", | ||
@@ -12,0 +13,0 @@ "unpkg": "dist/daily-iframe.js", |
@@ -7,1 +7,13 @@ **🚨Our docs have moved! 🚨** | ||
- [REST API docs](https://docs.daily.co/reference): To create video call rooms, configure features for the rooms, and manage users and permissions | ||
**A note on the default branch name** | ||
For anyone currently depending on bleeding-edge, not-yet-published changes in `daily-js`: the name of the default branch where these changes land is **`main`**. Please make sure your `package.json` reflects this. | ||
```json | ||
{ | ||
"dependencies": { | ||
"@daily-co/daily-js": "daily-co/daily-js#main" | ||
} | ||
} | ||
``` |
@@ -92,2 +92,3 @@ import EventEmitter from 'events'; | ||
DAILY_UI_EXIT_FULLSCREEN, | ||
DAILY_EVENT_LOAD_ATTEMPT_FAILED, | ||
} from './shared-with-pluot-core/CommonIncludes.js'; | ||
@@ -97,7 +98,7 @@ import { isReactNative, browserInfo } from './shared-with-pluot-core/Environment.js'; | ||
import ReactNativeMessageChannel from './shared-with-pluot-core/script-message-channels/ReactNativeMessageChannel'; | ||
import CallObjectLoaderWeb from './call-object-loaders/CallObjectLoaderWeb.js'; | ||
import CallObjectLoaderReactNative from './call-object-loaders/CallObjectLoaderReactNative.js'; | ||
import CallObjectLoader from "./CallObjectLoader"; | ||
import { | ||
getLocalIsSubscribedToTrack, | ||
} from './shared-with-pluot-core/selectors'; | ||
import { callObjectBundleUrl } from './utils.js'; | ||
@@ -119,2 +120,6 @@ | ||
}, | ||
baseUrl: { | ||
validate: (url) => typeof url === 'string', | ||
help: 'baseUrl should be a string' | ||
}, | ||
token: { | ||
@@ -370,5 +375,3 @@ validate: (token) => typeof token === 'string', | ||
this._callObjectLoader = this._callObjectMode | ||
? isReactNative() | ||
? new CallObjectLoaderReactNative() | ||
: new CallObjectLoaderWeb() | ||
? new CallObjectLoader() | ||
: null; | ||
@@ -422,3 +425,3 @@ this._meetingState = DAILY_STATE_NEW; | ||
try { | ||
if (this._meetingState === DAILY_STATE_JOINED) { | ||
if ([DAILY_STATE_JOINED, DAILY_STATE_LOADING].includes(this._meetingState)) { | ||
await this.leave(); | ||
@@ -534,3 +537,3 @@ } | ||
startCamera(properties={}) { | ||
return new Promise(async (resolve, _) => { | ||
return new Promise(async (resolve, reject) => { | ||
let k = (msg) => { | ||
@@ -542,3 +545,8 @@ delete msg.action; | ||
if (this.needsLoad()) { | ||
await this.load(properties); | ||
try { | ||
await this.load(properties); | ||
} | ||
catch (e) { | ||
reject(e); | ||
} | ||
} | ||
@@ -649,5 +657,10 @@ this.sendMessageToCallMachine({ | ||
} | ||
if (!this.properties.url) { | ||
throw new Error("can't load meeting because url property isn't set"); | ||
// In iframe mode, we *must* have a meeting url | ||
// (As opposed to call object mode, where a meeting url, a base url, or no | ||
// url at all are all valid here) | ||
if (!this._callObjectMode && !this.properties.url) { | ||
throw new Error("can't load iframe meeting because url property isn't set"); | ||
} | ||
this._meetingState = DAILY_STATE_LOADING; | ||
@@ -662,4 +675,5 @@ try { | ||
// non-iframe, callObjectMode | ||
return new Promise((resolve, _) => { | ||
this._callObjectLoader.load(this.properties.url, this._callFrameId, (wasNoOp) => { | ||
return new Promise((resolve, reject) => { | ||
this._callObjectLoader.cancel(); | ||
this._callObjectLoader.load(this.properties.url || this.properties.baseUrl, this._callFrameId, (wasNoOp) => { | ||
this._meetingState = DAILY_STATE_LOADED; | ||
@@ -670,2 +684,9 @@ // Only need to emit event if load was a no-op, since the loaded | ||
resolve(); | ||
}, (errorMsg, willRetry) => { | ||
this.emit(DAILY_EVENT_LOAD_ATTEMPT_FAILED, { action: DAILY_EVENT_LOAD_ATTEMPT_FAILED, errorMsg }); | ||
if (!willRetry) { | ||
this._meetingState = DAILY_STATE_ERROR; | ||
this.emit(DAILY_EVENT_ERROR, { action: DAILY_EVENT_ERROR, errorMsg }); | ||
reject(errorMsg); | ||
} | ||
}); | ||
@@ -696,9 +717,32 @@ }); | ||
if (this.needsLoad()) { | ||
await this.load(properties); | ||
try { | ||
await this.load(properties); | ||
} | ||
catch (e) { | ||
return Promise.reject(e); | ||
} | ||
} else { | ||
newCss = !!(this.properties.cssFile || this.properties.cssText) | ||
if (properties.url && | ||
properties.url !== this.properties.url) { | ||
console.error("error: can't change the daily.co call url after load()"); | ||
return Promise.reject(); | ||
newCss = !!(this.properties.cssFile || this.properties.cssText); | ||
if (properties.url) { | ||
if (this._callObjectMode) { | ||
const newBundleUrl = callObjectBundleUrl(properties.url); | ||
const loadedBundleUrl = callObjectBundleUrl( | ||
this.properties.url || this.properties.baseUrl | ||
); | ||
if (newBundleUrl !== loadedBundleUrl) { | ||
console.error( | ||
`error: in call object mode, can't change the daily.co call url after load() to one with a different bundle url (${loadedBundleUrl} -> ${newBundleUrl})` | ||
); | ||
return Promise.reject(); | ||
} | ||
this.properties.url = properties.url; | ||
} else { | ||
// iframe mode | ||
if (properties.url && properties.url !== this.properties.url) { | ||
console.error( | ||
`error: in iframe mode, can't change the daily.co call url after load() (${this.properties.url} -> ${properties.url})` | ||
); | ||
return Promise.reject(); | ||
} | ||
} | ||
} | ||
@@ -762,3 +806,14 @@ } | ||
} | ||
this.sendMessageToCallMachine({ action: DAILY_METHOD_LEAVE }, k); | ||
if (this._callObjectLoader && !this._callObjectLoader.loaded) { | ||
// If call object bundle never successfully loaded, cancel load if | ||
// needed and clean up state immediately (without waiting for call | ||
// machine to clean up its state). | ||
this._callObjectLoader.cancel(); | ||
k(); | ||
} | ||
else { | ||
// TODO: the possibility that the iframe call machine is not yet loaded | ||
// is never handled here... | ||
this.sendMessageToCallMachine({ action: DAILY_METHOD_LEAVE }, k); | ||
} | ||
}); | ||
@@ -1312,3 +1367,3 @@ } | ||
let sp = state.participants[p.session_id]; | ||
if (sp && sp.public.rtcType.impl === 'peer-to-peer') { | ||
if (sp && sp.public && sp.public.rtcType && sp.public.rtcType.impl === 'peer-to-peer') { | ||
if (sp.private && !['connected', 'completed'].includes(sp.private.peeringState)) { | ||
@@ -1315,0 +1370,0 @@ connected = false; |
@@ -15,2 +15,3 @@ | ||
export const DAILY_EVENT_LOADING = 'loading'; | ||
export const DAILY_EVENT_LOAD_ATTEMPT_FAILED = 'load-attempt-failed'; | ||
export const DAILY_EVENT_LOADED = 'loaded'; | ||
@@ -17,0 +18,0 @@ export const DAILY_EVENT_STARTED_CAMERA = 'started-camera'; |
@@ -7,9 +7,16 @@ import { browserInfo } from "./shared-with-pluot-core/Environment"; | ||
export function callObjectBundleUrl(meetingUrl) { | ||
// Use the CDN to get call-machine-object. (But use whatever's | ||
// "local" for dev+staging, checking both the build-time NODE_ENV | ||
// variable and whether the meetingUrl is foo.daily.co and not, for | ||
// example, foo.staging.daily.co) | ||
if (process.env.NODE_ENV === 'production' && | ||
meetingUrl && meetingUrl.match(/https:\/\/[^.]+\.daily\.co\//)) { | ||
export function callObjectBundleUrl(meetingOrBaseUrl) { | ||
// Take the provided URL, which is either a meeting URL (like | ||
// https://somecompany.daily.co/hello) or a base URL (like | ||
// https://somecompany.daily.co), and make it a base URL. | ||
let baseUrl = meetingOrBaseUrl ? new URL(meetingOrBaseUrl).origin : null; | ||
// Production: | ||
// - no url provided --> load bundle from c.daily.co (CDN) | ||
// - x.daily.co url provided --> load bundle from c.daily.co (CDN) | ||
// - x.staging.daily.co url provided --> see dev/staging logic | ||
if ( | ||
process.env.NODE_ENV === "production" && | ||
(!baseUrl || baseUrl.match(/https:\/\/[^.]+\.daily\.co/)) | ||
) { | ||
if (!browserInfo().supportsSfu) { | ||
@@ -20,10 +27,16 @@ return `https://c.daily.co/static/call-machine-object-nosfu-bundle.js`; | ||
} | ||
} | ||
// Dev/staging: | ||
// - no url provided --> error | ||
// - url provided --> load bundle from url | ||
if (!baseUrl) { | ||
console.warn("No baseUrl provided for call object bundle. Defaulting to production CDN..."); | ||
baseUrl = "https://c.daily.co"; | ||
} | ||
if (!browserInfo().supportsSfu) { | ||
return `${baseUrl}/static/call-machine-object-nosfu-bundle.js`; | ||
} else { | ||
let url = new URL(meetingUrl); | ||
if (!browserInfo().supportsSfu) { | ||
return `${url.origin}/static/call-machine-object-nosfu-bundle.js`; | ||
} else { | ||
return `${url.origin}/static/call-machine-object-bundle.js`; | ||
} | ||
return `${baseUrl}/static/call-machine-object-bundle.js`; | ||
} | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
385288
3059
19
26
12