@digitalsamba/embedded-sdk 0.0.35 → 0.0.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@digitalsamba/embedded-sdk",
3
3
  "packageManager": "yarn@3.1.0",
4
- "version": "0.0.35",
4
+ "version": "0.0.36",
5
5
  "license": "BSD-2-Clause",
6
6
  "scripts": {
7
7
  "build": "npm run build:cjs && npm run build:esm && npm run build:umd && npm run build:types && npm run build:update-demo",
package/CHANGELOG.md DELETED
@@ -1,33 +0,0 @@
1
- # Changelog
2
-
3
- Historical list of changes in releases
4
- ## [v0.0.35] - 2023-11-16
5
- * Add `sessionEnded` event to type definitions ([#146f159](https://github.com/digitalsamba/embedded-sdk/commit/146f1599e74590aa0a3f130bf38cee1071120874))
6
-
7
- ## [v0.0.34] - 2023-11-01
8
- * Add `UICallback` commands to attach listeners for custom interface actions in embedded app ([#59](https://github.com/digitalsamba/embedded-sdk/pull/59))
9
- * Add `changeRole` command and `roleChanged` event ([#60](https://github.com/digitalsamba/embedded-sdk/pull/60))
10
-
11
-
12
- ## [v0.0.33] - 2023-10-05
13
- * Add `appLanguage` field to room state to match rooms localization language
14
- * Add virtual background image `name` field to room state
15
- * Expose list of active media devices in room state
16
-
17
- ## [v0.0.31] - 2023-09-07
18
- * Allow listening to document or window events fired inside the frame ([#47](https://github.com/digitalsamba/embedded-sdk/pull/47))
19
- * Allow pre-selecting app language using init options ([#48](https://github.com/digitalsamba/embedded-sdk/pull/48))
20
-
21
- ## [v0.0.29] - 2023-09-01
22
- * Fix an issue with EventEmitter import in typescript declaration
23
-
24
- ## [v0.0.28] - 2023-08-24
25
- * Connect demos to test drive endpoint to dynamically create demo rooms
26
- * Allow pre-selecting media devices through initial settings ([#44](https://github.com/digitalsamba/embedded-sdk/pull/44))
27
- * Add support for custom CNAME, handle cname property in init options ([#45](https://github.com/digitalsamba/embedded-sdk/pull/45))
28
-
29
- ## [v0.0.27] - 2023-08-09
30
- * Fix an issue with stored state not resetting properly when creating a new control instance
31
-
32
- ## [v0.0.26] - 2023-08-09
33
- * Add missing type definitions for newest methods and state fields ([#01a3bf1](https://github.com/digitalsamba/embedded-sdk/commit/01a3bf1730b03db453acf091e39e4c2c6ea61e22))
package/dist/index.js DELETED
@@ -1,194 +0,0 @@
1
- "use strict";
2
- var __read = (this && this.__read) || function (o, n) {
3
- var m = typeof Symbol === "function" && o[Symbol.iterator];
4
- if (!m) return o;
5
- var i = m.call(o), r, ar = [], e;
6
- try {
7
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
8
- }
9
- catch (error) { e = { error: error }; }
10
- finally {
11
- try {
12
- if (r && !r.done && (m = i["return"])) m.call(i);
13
- }
14
- finally { if (e) throw e.error; }
15
- }
16
- return ar;
17
- };
18
- var INVALID_CONFIG = "Initializations options are invalid. Missing team name or room ID";
19
- var CONNECT_TIMEOUT = 5000;
20
- function isFunction(func) {
21
- return func instanceof Function;
22
- }
23
- var DigitalSambaEmbedded = /** @class */ (function () {
24
- function DigitalSambaEmbedded(options, instanceProperties, loadImmediately) {
25
- if (options === void 0) { options = {}; }
26
- if (instanceProperties === void 0) { instanceProperties = {}; }
27
- if (loadImmediately === void 0) { loadImmediately = true; }
28
- var _this = this;
29
- this.savedIframeSrc = "";
30
- this.allowedOrigin = "";
31
- this.connected = false;
32
- this.frame = document.createElement("iframe");
33
- this.eventHandlers = {};
34
- this.reportErrors = false;
35
- this.mountFrame = function (loadImmediately) {
36
- var _b = _this.initOptions, frame = _b.frame, root = _b.root;
37
- if (root) {
38
- root.appendChild(_this.frame);
39
- }
40
- else if (frame) {
41
- _this.frame = frame;
42
- if (!loadImmediately) {
43
- _this.savedIframeSrc = _this.frame.src;
44
- _this.frame.src = "";
45
- }
46
- }
47
- else {
48
- document.body.appendChild(_this.frame);
49
- }
50
- };
51
- this.load = function (instanceProperties) {
52
- if (instanceProperties === void 0) { instanceProperties = {}; }
53
- _this.reportErrors = instanceProperties.reportErrors || false;
54
- _this.setFrameSrc();
55
- _this.applyFrameProperties(instanceProperties);
56
- _this.frame.style.display = "block";
57
- };
58
- this.on = function (type, handler) {
59
- _this.eventHandlers[type] = handler;
60
- };
61
- // commands
62
- this.enableVideo = function () {
63
- _this.sendMessage({ type: "enableVideo" });
64
- };
65
- this.disableVideo = function () {
66
- _this.sendMessage({ type: "disableVideo" });
67
- };
68
- this.toggleVideo = function (enable) {
69
- if (typeof enable === "undefined") {
70
- _this.sendMessage({ type: "toggleVideo" });
71
- }
72
- else {
73
- if (enable) {
74
- _this.enableVideo();
75
- }
76
- else {
77
- _this.disableVideo();
78
- }
79
- }
80
- };
81
- this.enableAudio = function () {
82
- _this.sendMessage({ type: "enableAudio" });
83
- };
84
- this.disableAudio = function () {
85
- _this.sendMessage({ type: "disableAudio" });
86
- };
87
- this.toggleAudio = function (enable) {
88
- if (typeof enable === "undefined") {
89
- _this.sendMessage({ type: "toggleAudio" });
90
- }
91
- else {
92
- if (enable) {
93
- _this.enableAudio();
94
- }
95
- else {
96
- _this.disableAudio();
97
- }
98
- }
99
- };
100
- this.onMessage = function (event) {
101
- if (event.origin !== _this.allowedOrigin) {
102
- // ignore messages from other sources;
103
- return;
104
- }
105
- if (typeof _this.eventHandlers["*"] === "function") {
106
- _this.eventHandlers["*"](event.data);
107
- }
108
- if (event.data.type) {
109
- var callback = _this.eventHandlers[event.data.type];
110
- if (isFunction(callback)) {
111
- callback(event.data);
112
- }
113
- }
114
- };
115
- this.setFrameSrc = function () {
116
- if (_this.savedIframeSrc) {
117
- _this.frame.src = _this.savedIframeSrc;
118
- return;
119
- }
120
- var _b = _this.initOptions, team = _b.team, room = _b.room, token = _b.token;
121
- if (team && room) {
122
- var url = "https://".concat(team, ".digitalsamba.com/").concat(room);
123
- if (token) {
124
- var params = new URLSearchParams({ token: token });
125
- url = "".concat(url, "?").concat(params);
126
- }
127
- _this.frame.src = url;
128
- var allowedURL = new URL(url);
129
- _this.allowedOrigin = allowedURL.origin;
130
- }
131
- else {
132
- _this.logError(INVALID_CONFIG);
133
- }
134
- };
135
- this.logError = function (message) {
136
- if (_this.reportErrors) {
137
- throw new Error(message);
138
- }
139
- };
140
- this.applyFrameProperties = function (instanceProperties) {
141
- _this.frame.setAttribute("allow", "camera; microphone; display-capture; autoplay;");
142
- _this.frame.setAttribute("allowFullscreen", "true");
143
- if (instanceProperties.frameAttributes) {
144
- // TODO: only allow specific attrs here; This is a heck to support
145
- Object.entries(instanceProperties.frameAttributes).forEach(function (_b) {
146
- var _c = __read(_b, 2), attr = _c[0], value = _c[1];
147
- if (value !== null && typeof value !== "undefined") {
148
- _this.frame.setAttribute(attr, value.toString());
149
- }
150
- else {
151
- _this.frame.removeAttribute(attr);
152
- }
153
- });
154
- }
155
- if (instanceProperties.reportErrors) {
156
- _this.reportErrors = true;
157
- }
158
- };
159
- this.initOptions = options;
160
- this.mountFrame(loadImmediately);
161
- if (loadImmediately) {
162
- this.load(instanceProperties);
163
- }
164
- else {
165
- this.frame.style.display = "none";
166
- }
167
- this.frame.onload = function () { return _this.checkTarget(); };
168
- window.addEventListener("message", this.onMessage);
169
- }
170
- DigitalSambaEmbedded.prototype.checkTarget = function () {
171
- var _this = this;
172
- this.sendMessage({ type: "connect" });
173
- var confirmationTimeout = window.setTimeout(function () {
174
- _this.logError("Could not verify target frame identity. Commands may not work");
175
- }, CONNECT_TIMEOUT);
176
- this.on("connected", function () {
177
- _this.connected = true;
178
- clearTimeout(confirmationTimeout);
179
- });
180
- };
181
- DigitalSambaEmbedded.prototype.sendMessage = function (message) {
182
- if (this.frame.contentWindow) {
183
- this.frame.contentWindow.postMessage(message, this.allowedOrigin);
184
- }
185
- };
186
- var _a;
187
- _a = DigitalSambaEmbedded;
188
- DigitalSambaEmbedded.createControl = function (initOptions) {
189
- return new _a(initOptions, {}, false);
190
- };
191
- return DigitalSambaEmbedded;
192
- }());
193
- // @ts-ignore
194
- window.DigitalSambaEmbedded = DigitalSambaEmbedded;