forked from jitsi/lib-jitsi-meet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
30 lines (28 loc) · 1.41 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
const ljm = require('./JitsiMeetJS').default;
/**
* Tries to deal with the following problem: {@code JitsiMeetJS} is not only
* this module, it's also a global (i.e. attached to {@code window}) namespace
* for all globals of the projects in the Jitsi Meet family. If lib-jitsi-meet
* is loaded through an HTML {@code script} tag, {@code JitsiMeetJS} will
* automatically be attached to {@code window} by webpack. Unfortunately,
* webpack's source code does not check whether the global variable has already
* been assigned and overwrites it. Which is OK for the module
* {@code JitsiMeetJS} but is not OK for the namespace {@code JitsiMeetJS}
* because it may already contain the values of other projects in the Jitsi Meet
* family. The solution offered here works around webpack by merging all
* existing values of the namespace {@code JitsiMeetJS} into the module
* {@code JitsiMeetJS}.
*
* @param {Object} module - The module {@code JitsiMeetJS} (which will be
* exported and may be attached to {@code window} by webpack later on).
* @private
* @returns {Object} - A {@code JitsiMeetJS} module which contains all existing
* value of the namespace {@code JitsiMeetJS} (if any).
*/
function _mergeNamespaceAndModule(module) {
return (
typeof window.JitsiMeetJS === 'object'
? Object.assign({}, window.JitsiMeetJS, module)
: module);
}
module.exports = _mergeNamespaceAndModule(ljm);