@whereby.com/browser-sdk 1.8.0 → 1.9.0

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/README.md CHANGED
@@ -1,11 +1,20 @@
1
1
  # @whereby.com/browser-sdk
2
2
 
3
- Clientside library defining a web component to allow embedding Whereby video rooms in web applications. Only normal iframe under the hood, the web component adds syntactic sugar to make it easier to customize the Whereby experience and hook into powerful features such as listening to room events and sending commands to the room from the host application.
3
+ <a href="https://www.npmjs.com/package/@whereby.com/browser-sdk" alt="NPM Package">
4
+ <img src="https://img.shields.io/npm/v/@whereby.com/browser-sdk" />
5
+ </a>
6
+
7
+ Clientside library defining a web component to allow embedding Whereby video
8
+ rooms in web applications. Only normal iframe under the hood, the web component
9
+ adds syntactic sugar to make it easier to customize the Whereby experience and
10
+ hook into powerful features such as listening to room events and sending
11
+ commands to the room from the host application.
4
12
 
5
13
  ## Usage
6
14
 
7
15
  ### React + a bundler (webpack, rollup, parcel etc)
8
- ```
16
+
17
+ ```js
9
18
  import "@whereby.com/browser-sdk"
10
19
 
11
20
  const MyComponent = ({ roomUrl }) => {
@@ -17,7 +26,8 @@ export default MyComponent
17
26
  ```
18
27
 
19
28
  ### Directly using a script tag
20
- ```
29
+
30
+ ```html
21
31
  <html>
22
32
  <head>
23
33
  <script src="...."></script>
@@ -32,4 +42,6 @@ export default MyComponent
32
42
 
33
43
  **Note**
34
44
 
35
- Although we have just higlighted two combinations of how to load and use the web component, it should be possible to use this library with all the major frontend frameworks.
45
+ Although we have just higlighted two combinations of how to load and use the
46
+ web component, it should be possible to use this library with all the major
47
+ frontend frameworks.
@@ -0,0 +1,156 @@
1
+ 'use strict';
2
+
3
+ var heresy = require('heresy');
4
+
5
+ const boolAttrs = [
6
+ "audio",
7
+ "background",
8
+ "cameraAccess",
9
+ "chat",
10
+ "people",
11
+ "embed",
12
+ "emptyRoomInvitation",
13
+ "help",
14
+ "leaveButton",
15
+ "precallReview",
16
+ "screenshare",
17
+ "video",
18
+ "floatSelf",
19
+ "recording",
20
+ "logo",
21
+ "locking",
22
+ "participantCount",
23
+ "settingsButton",
24
+ "pipButton",
25
+ "moreButton",
26
+ "personality",
27
+ "subgridLabels",
28
+ "lowData",
29
+ "breakout",
30
+ ];
31
+
32
+ heresy.define("WherebyEmbed", {
33
+ oninit() {
34
+ this.iframe = heresy.ref();
35
+ },
36
+ onconnected() {
37
+ window.addEventListener("message", this);
38
+ },
39
+ ondisconnected() {
40
+ window.removeEventListener("message", this);
41
+ },
42
+ observedAttributes: [
43
+ "displayName",
44
+ "minimal",
45
+ "room",
46
+ "subdomain",
47
+ "lang",
48
+ "metadata",
49
+ "groups",
50
+ "virtualBackgroundUrl",
51
+ "avatarUrl",
52
+ ...boolAttrs,
53
+ ].map((a) => a.toLowerCase()),
54
+ onattributechanged({ attributeName, oldValue }) {
55
+ if (["room", "subdomain"].includes(attributeName) && oldValue == null) return;
56
+ this.render();
57
+ },
58
+ style(self) {
59
+ return `
60
+ ${self} {
61
+ display: block;
62
+ }
63
+ ${self} iframe {
64
+ border: none;
65
+ height: 100%;
66
+ width: 100%;
67
+ }
68
+ `;
69
+ },
70
+
71
+ // Commands
72
+ _postCommand(command, args = []) {
73
+ if (this.iframe.current) {
74
+ this.iframe.current.contentWindow.postMessage({ command, args }, this.url.origin);
75
+ }
76
+ },
77
+ startRecording() {
78
+ this._postCommand("start_recording");
79
+ },
80
+ stopRecording() {
81
+ this._postCommand("stop_recording");
82
+ },
83
+ startStreaming() {
84
+ this._postCommand("start_streaming");
85
+ },
86
+ stopStreaming() {
87
+ this._postCommand("stop_streaming");
88
+ },
89
+ toggleCamera(enabled) {
90
+ this._postCommand("toggle_camera", [enabled]);
91
+ },
92
+ toggleMicrophone(enabled) {
93
+ this._postCommand("toggle_microphone", [enabled]);
94
+ },
95
+ toggleScreenshare(enabled) {
96
+ this._postCommand("toggle_screenshare", [enabled]);
97
+ },
98
+
99
+ onmessage({ origin, data }) {
100
+ if (origin !== this.url.origin) return;
101
+ const { type, payload: detail } = data;
102
+ this.dispatchEvent(new CustomEvent(type, { detail }));
103
+ },
104
+ render() {
105
+ const {
106
+ avatarurl: avatarUrl,
107
+ displayname: displayName,
108
+ lang,
109
+ metadata,
110
+ minimal,
111
+ room,
112
+ groups,
113
+ virtualbackgroundurl: virtualBackgroundUrl,
114
+ } = this;
115
+ if (!room) return this.html`Whereby: Missing room attr.`;
116
+ // Get subdomain from room URL, or use it specified
117
+ let m = /https:\/\/([^.]+)\.whereby.com\/.+/.exec(room);
118
+ const subdomain = (m && m[1]) || this.subdomain || null;
119
+ if (!subdomain) return this.html`Whereby: Missing subdomain attr.`;
120
+ const baseURL = `.whereby.com`;
121
+ this.url = new URL(room, `https://${subdomain}${baseURL}`);
122
+
123
+ Object.entries({
124
+ jsApi: true,
125
+ we: "1.9.0",
126
+ iframeSource: subdomain,
127
+ ...(displayName && { displayName }),
128
+ ...(lang && { lang: lang }),
129
+ ...(metadata && { metadata: metadata }),
130
+ ...(groups && { groups: groups }),
131
+ ...(virtualBackgroundUrl && { virtualBackgroundUrl: virtualBackgroundUrl }),
132
+ ...(avatarUrl && { avatarUrl: avatarUrl }),
133
+ // the original ?embed name was confusing, so we give minimal
134
+ ...(minimal != null && { embed: minimal }),
135
+ ...boolAttrs.reduce(
136
+ // add to URL if set in any way
137
+ (o, v) => (this[v.toLowerCase()] != null ? { ...o, [v]: this[v.toLowerCase()] } : o),
138
+ {}
139
+ ),
140
+ }).forEach(([k, v]) => {
141
+ if (!this.url.searchParams.has(k)) {
142
+ this.url.searchParams.set(k, v);
143
+ }
144
+ });
145
+ this.html`
146
+ <iframe
147
+ ref=${this.iframe}
148
+ src=${this.url}
149
+ allow="autoplay; camera; microphone; fullscreen; speaker; display-capture" />
150
+ `;
151
+ },
152
+ });
153
+
154
+ var index = { sdkVersion: "1.9.0" };
155
+
156
+ module.exports = index;
@@ -1,4 +1,4 @@
1
- import { define, ref } from "heresy";
1
+ import { define, ref } from 'heresy';
2
2
 
3
3
  const boolAttrs = [
4
4
  "audio",
@@ -69,8 +69,7 @@ define("WherebyEmbed", {
69
69
  // Commands
70
70
  _postCommand(command, args = []) {
71
71
  if (this.iframe.current) {
72
- const url = new URL(this.room, `https://${this.subdomain}.whereby.com`);
73
- this.iframe.current.contentWindow.postMessage({ command, args }, url.origin);
72
+ this.iframe.current.contentWindow.postMessage({ command, args }, this.url.origin);
74
73
  }
75
74
  },
76
75
  startRecording() {
@@ -79,6 +78,12 @@ define("WherebyEmbed", {
79
78
  stopRecording() {
80
79
  this._postCommand("stop_recording");
81
80
  },
81
+ startStreaming() {
82
+ this._postCommand("start_streaming");
83
+ },
84
+ stopStreaming() {
85
+ this._postCommand("stop_streaming");
86
+ },
82
87
  toggleCamera(enabled) {
83
88
  this._postCommand("toggle_camera", [enabled]);
84
89
  },
@@ -90,8 +95,7 @@ define("WherebyEmbed", {
90
95
  },
91
96
 
92
97
  onmessage({ origin, data }) {
93
- const url = new URL(this.room, `https://${this.subdomain}.whereby.com`);
94
- if (origin !== url.origin) return;
98
+ if (origin !== this.url.origin) return;
95
99
  const { type, payload: detail } = data;
96
100
  this.dispatchEvent(new CustomEvent(type, { detail }));
97
101
  },
@@ -109,12 +113,14 @@ define("WherebyEmbed", {
109
113
  if (!room) return this.html`Whereby: Missing room attr.`;
110
114
  // Get subdomain from room URL, or use it specified
111
115
  let m = /https:\/\/([^.]+)\.whereby.com\/.+/.exec(room);
112
- const subdomain = (m && m[1]) || this.subdomain;
116
+ const subdomain = (m && m[1]) || this.subdomain || null;
113
117
  if (!subdomain) return this.html`Whereby: Missing subdomain attr.`;
114
- const url = new URL(room, `https://${subdomain}.whereby.com`);
118
+ const baseURL = `.whereby.com`;
119
+ this.url = new URL(room, `https://${subdomain}${baseURL}`);
120
+
115
121
  Object.entries({
116
122
  jsApi: true,
117
- we: "__SDK_VERSION__",
123
+ we: "1.9.0",
118
124
  iframeSource: subdomain,
119
125
  ...(displayName && { displayName }),
120
126
  ...(lang && { lang: lang }),
@@ -130,17 +136,19 @@ define("WherebyEmbed", {
130
136
  {}
131
137
  ),
132
138
  }).forEach(([k, v]) => {
133
- if (!url.searchParams.has(k)) {
134
- url.searchParams.set(k, v);
139
+ if (!this.url.searchParams.has(k)) {
140
+ this.url.searchParams.set(k, v);
135
141
  }
136
142
  });
137
143
  this.html`
138
144
  <iframe
139
145
  ref=${this.iframe}
140
- src=${url}
146
+ src=${this.url}
141
147
  allow="autoplay; camera; microphone; fullscreen; speaker; display-capture" />
142
148
  `;
143
149
  },
144
150
  });
145
151
 
146
- export default { sdkVersion: "__SDK_VERSION__" };
152
+ var index = { sdkVersion: "1.9.0" };
153
+
154
+ export { index as default };
package/dist/v1.js ADDED
@@ -0,0 +1,15 @@
1
+ /*! (c) Andrea Giammarchi - ISC */
2
+ var e={};try{e.WeakMap=WeakMap}catch(t){e.WeakMap=function(e,t){var n=t.defineProperty,r=t.hasOwnProperty,s=o.prototype;return s.delete=function(e){return this.has(e)&&delete e[this._]},s.get=function(e){return this.has(e)?e[this._]:void 0},s.has=function(e){return r.call(e,this._)},s.set=function(e,t){return n(e,this._,{configurable:!0,value:t}),this},o;function o(t){n(this,"_",{value:"_@ungap/weakmap"+e++}),t&&t.forEach(a,this)}function a(e){this.set(e[0],e[1])}}(Math.random(),Object)}var t=e.WeakMap,n={};try{n.Event=new Event(".").constructor}catch(e){try{n.Event=new CustomEvent(".").constructor}catch(e){n.Event=function(e,t){t||(t={});var n=document.createEvent("Event"),r=!!t.bubbles,s=!!t.cancelable;n.initEvent(e,r,s);try{n.bubbles=r,n.cancelable=s}catch(n){}return n}}}var r=n.Event,s={};
3
+ /*! (c) Andrea Giammarchi - ISC */try{s.WeakSet=WeakSet}catch(e){!function(e){var t=new e,n=r.prototype;function r(n){t.set(this,new e),n&&n.forEach(this.add,this)}n.add=function(e){return t.get(this).set(e,1),this},n.delete=function(e){return t.get(this).delete(e)},n.has=function(e){return t.get(this).has(e)},s.WeakSet=r}(WeakMap)}var o,a,i=s.WeakSet,c="-"+Math.random().toFixed(6)+"%",l=!1;
4
+ /*! (c) Andrea Giammarchi - ISC */try{o=document.createElement("template"),a="tabindex","content"in o&&(o.innerHTML='<p tabindex="'+c+'"></p>',o.content.childNodes[0].getAttribute(a)==c)||(c="_dt: "+c.slice(1,-1)+";",l=!0)}catch(e){}var u="\x3c!--"+c+"--\x3e",h=/^(?:plaintext|script|style|textarea|title|xmp)$/i,f=/^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i;
5
+ /*! (c) Andrea Giammarchi - ISC */
6
+ function p(e){return e.join(u).replace(w,N).replace(y,C)}var d=" \\f\\n\\r\\t",m="[^ \\f\\n\\r\\t\\/>\"'=]+",g="[ \\f\\n\\r\\t]+"+m,v="<([A-Za-z]+[A-Za-z0-9:._-]*)((?:",b="(?:\\s*=\\s*(?:'[^']*?'|\"[^\"]*?\"|<[^>]*?>|"+m.replace("\\/","")+"))?)",y=new RegExp(v+g+b+"+)(["+d+"]*/?>)","g"),w=new RegExp(v+g+b+"*)(["+d+"]*/>)","g"),E=new RegExp("("+g+"\\s*=\\s*)(['\"]?)"+u+"\\2","gi");function C(e,t,n,r){return"<"+t+n.replace(E,x)+r}function x(e,t,n){return t+(n||'"')+c+(n||'"')}function N(e,t,n){return f.test(t)?e:"<"+t+n+"></"+t+">"}const{isArray:k}=Array,{indexOf:A,slice:$}=[];var _=e=>({get:t=>e.get(t),set:(t,n)=>(e.set(t,n),n)});const S=(e,t)=>111===e.nodeType?1/t<0?t?(({firstChild:e,lastChild:t})=>{const n=document.createRange();return n.setStartAfter(e),n.setEndAfter(t),n.deleteContents(),e})(e):e.lastChild:t?e.valueOf():e.firstChild:e,L=e=>{const{childNodes:t}=e,{length:n}=t;if(n<2)return n?t[0]:e;const r=$.call(t,0);return{ELEMENT_NODE:1,nodeType:111,firstChild:r[0],lastChild:r[n-1],valueOf(){if(t.length!==n){let t=0;for(;t<n;)e.appendChild(r[t++])}return e}}};
7
+ /*! (c) Andrea Giammarchi - ISC */
8
+ var j=function(e){var t="fragment",n="template",r="content"in o(n)?function(e){var t=o(n);return t.innerHTML=e,t.content}:function(e){var r=o(t),a=o(n),i=null;if(/^[^\S]*?<(col(?:group)?|t(?:head|body|foot|r|d|h))/i.test(e)){var c=RegExp.$1;a.innerHTML="<table>"+e+"</table>",i=a.querySelectorAll(c)}else a.innerHTML=e,i=a.childNodes;return s(r,i),r};return function(e,t){return("svg"===t?a:r)(e)};function s(e,t){for(var n=t.length;n--;)e.appendChild(t[0])}function o(n){return n===t?e.createDocumentFragment():e.createElementNS("http://www.w3.org/1999/xhtml",n)}function a(e){var n=o(t),r=o("div");return r.innerHTML='<svg xmlns="http://www.w3.org/2000/svg">'+e+"</svg>",s(n,r.firstChild.childNodes),n}}(document),M=(e,t,n,r,s)=>{const o=n.length;let a=t.length,i=o,c=0,l=0,u=null;for(;c<a||l<i;)if(a===c){const t=i<o?l?r(n[l-1],-0).nextSibling:r(n[i-l],0):s;for(;l<i;)e.insertBefore(r(n[l++],1),t)}else if(i===l)for(;c<a;)u&&u.has(t[c])||e.removeChild(r(t[c],-1)),c++;else if(t[c]===n[l])c++,l++;else if(t[a-1]===n[i-1])a--,i--;else if(t[c]===n[i-1]&&n[l]===t[a-1]){const s=r(t[--a],-1).nextSibling;e.insertBefore(r(n[l++],1),r(t[c++],-1).nextSibling),e.insertBefore(r(n[--i],1),s),t[a]=n[i]}else{if(!u){u=new Map;let e=l;for(;e<i;)u.set(n[e],e++)}if(u.has(t[c])){const s=u.get(t[c]);if(l<s&&s<i){let o=c,h=1;for(;++o<a&&o<i&&u.get(t[o])===s+h;)h++;if(h>s-l){const o=r(t[c],0);for(;l<s;)e.insertBefore(r(n[l++],1),o)}else e.replaceChild(r(n[l++],1),r(t[c++],-1))}else c++}else e.removeChild(r(t[c++],-1))}return n},O=function(e,t,n,r,s){var o=s in e,a=e.createDocumentFragment();return a.appendChild(e.createTextNode("g")),a.appendChild(e.createTextNode("")),(o?e.importNode(a,!0):a.cloneNode(!0)).childNodes.length<2?function e(t,n){for(var r=t.cloneNode(),s=t.childNodes||[],o=s.length,a=0;n&&a<o;a++)r.appendChild(e(s[a],n));return r}:o?e.importNode:function(e,t){return e.cloneNode(!!t)}}(document,0,0,0,"importNode"),T="".trim||function(){return String(this).replace(/^\s+|\s+/g,"")},R=l?function(e,t){var n=t.join(" ");return t.slice.call(e,0).sort((function(e,t){return n.indexOf(e.name)<=n.indexOf(t.name)?-1:1}))}:function(e,t){return t.slice.call(e,0)};function W(e,t){for(var n=t.length,r=0;r<n;)e=e.childNodes[t[r++]];return e}function P(e,t,n,r){for(var s=e.childNodes,o=s.length,a=0;a<o;){var i=s[a];switch(i.nodeType){case 1:var l=r.concat(a);Z(i,t,n,l),P(i,t,n,l);break;case 8:var f=i.textContent;if(f===c)n.shift(),t.push(h.test(e.nodeName)?D(e,r):B(i,r.concat(a)));else switch(f.slice(0,2)){case"/*":if("*/"!==f.slice(-2))break;case"👻":e.removeChild(i),a--,o--}break;case 3:h.test(e.nodeName)&&T.call(i.textContent)===u&&(n.shift(),t.push(D(e,r)))}a++}}function Z(e,t,n,r){for(var s=e.attributes,o=[],a=[],i=R(s,n),h=i.length,f=0;f<h;){var p,d=i[f++],m=d.value===c;if(m||1<(p=d.value.split(u)).length){var g=d.name;if(o.indexOf(g)<0){o.push(g);var v=n.shift().replace(m?/^(?:|[\S\s]*?\s)(\S+?)\s*=\s*('|")?$/:new RegExp("^(?:|[\\S\\s]*?\\s)("+g+")\\s*=\\s*('|\")[\\S\\s]*","i"),"$1"),b=s[v]||s[v.toLowerCase()];if(m)t.push(z(b,r,v,null));else{for(var y=p.length-2;y--;)n.shift();t.push(z(b,r,v,p))}}a.push(d)}}f=0;for(var w=(0<(h=a.length)&&l&&!("ownerSVGElement"in e));f<h;){var E=a[f++];w&&(E.value=""),e.removeAttribute(E.name)}var C=e.nodeName;if(/^script$/i.test(C)){var x=document.createElement(C);for(h=s.length,f=0;f<h;)x.setAttributeNode(s[f++].cloneNode(!0));x.textContent=e.textContent,e.parentNode.replaceChild(x,e)}}function B(e,t){return{type:"any",node:e,path:t}}function z(e,t,n,r){return{type:"attr",node:e,path:t,name:n,sparse:r}}function D(e,t){return{type:"text",node:e,path:t}}var F=_(new t);function H(e,t){var n=(e.convert||p)(t),r=e.transform;r&&(n=r(n));var s=j(n,e.type);q(s);var o=[];return P(s,o,t.slice(0),[]),{content:s,updates:function(n){for(var r=[],s=o.length,a=0,i=0;a<s;){var c=o[a++],l=W(n,c.path);switch(c.type){case"any":r.push({fn:e.any(l,[]),sparse:!1});break;case"attr":var u=c.sparse,h=e.attribute(l,c.name,c.node);null===u?r.push({fn:h,sparse:!1}):(i+=u.length-2,r.push({fn:h,sparse:!0,values:u}));break;case"text":r.push({fn:e.text(l),sparse:!1}),l.textContent=""}}return s+=i,function(){var e=arguments.length;if(s!==e-1)throw new Error(e-1+" values instead of "+s+"\n"+t.join("${value}"));for(var o=1,a=1;o<e;){var i=r[o-a];if(i.sparse){var c=i.values,l=c[0],u=1,h=c.length;for(a+=h-2;u<h;)l+=arguments[o++]+c[u++];i.fn(l)}else i.fn(arguments[o++])}return n}}}}function U(e,t){var n=F.get(t)||F.set(t,H(e,t));return n.updates(O.call(document,n.content,!0))}var V=[];function q(e){for(var t=e.childNodes,n=t.length;n--;){var r=t[n];1!==r.nodeType&&0===T.call(r.textContent).length&&e.removeChild(r)}}
9
+ /*! (c) Andrea Giammarchi - ISC */var I=function(){var e=/acit|ex(?:s|g|n|p|$)|rph|ows|mnc|ntw|ine[ch]|zoo|^ord/i,t=/([^A-Z])([A-Z]+)/g;return function(e,t){return"ownerSVGElement"in e?function(e,t){var n;t?n=t.cloneNode(!0):(e.setAttribute("style","--hyper:style;"),n=e.getAttributeNode("style"));return n.value="",e.setAttributeNode(n),r(n,!0)}(e,t):r(e.style,!1)};function n(e,t,n){return t+"-"+n.toLowerCase()}function r(r,s){var o,a;return function(i){var c,l,u,h;switch(typeof i){case"object":if(i){if("object"===o){if(!s&&a!==i)for(l in a)l in i||(r[l]="")}else s?r.value="":r.cssText="";for(l in c=s?{}:r,i)u="number"!=typeof(h=i[l])||e.test(l)?h:h+"px",!s&&/^--/.test(l)?c.setProperty(l,u):c[l]=u;o="object",s?r.value=function(e){var r,s=[];for(r in e)s.push(r.replace(t,n),":",e[r],";");return s.join("")}(a=c):a=i;break}default:a!=i&&(o="string",a=i,s?r.value=i||"":r.cssText=i||"")}}}}();const G=(e,t)=>{let n,r=!0;const s=document.createAttributeNS(null,t);return t=>{n!==t&&(n=t,null==n?r||(e.removeAttributeNode(s),r=!0):(s.value=t,r&&(e.setAttributeNodeNS(s),r=!1)))}},J=({dataset:e})=>t=>{for(const n in t){const r=t[n];null==r?delete e[n]:e[n]=r}},K=(e,t)=>"dataset"===t?J(e):n=>{e[t]=n},Q=/^(?:form|list)$/i,X=(e,t)=>e.ownerDocument.createTextNode(t);function Y(e){return this.type=e,function(e){var t=V,n=q;return function(r){return t!==r&&(n=U(e,t=r)),n.apply(null,arguments)}}(this)}function ee(e){return e(this)}Y.prototype={attribute(e,t,n){const r="svg"===this.type;switch(t){case"class":if(r)return G(e,t);t="className";case"props":return K(e,t);case"aria":return(e=>t=>{for(const n in t){const r="role"===n?n:`aria-${n}`,s=t[n];null==s?e.removeAttribute(r):e.setAttribute(r,s)}})(e);case"style":return I(e,n,r);case"ref":return(e=>t=>{"function"==typeof t?t(e):t.current=e})(e);case".dataset":return J(e);default:return"."===t.slice(0,1)?K(e,t.slice(1)):"?"===t.slice(0,1)?((e,t,n)=>r=>{n!==!!r&&((n=!!r)?e.setAttribute(t,""):e.removeAttribute(t))})(e,t.slice(1)):"on"===t.slice(0,2)?((e,t)=>{let n,r=t.slice(2);return!(t in e)&&t.toLowerCase()in e&&(r=r.toLowerCase()),t=>{const s=k(t)?t:[t,!1];n!==s[0]&&(n&&e.removeEventListener(r,n,s[1]),(n=s[0])&&e.addEventListener(r,n,s[1]))}})(e,t):!(t in e)||r||Q.test(t)?G(e,t):((e,t)=>{let n;return r=>{n!==r&&(n=r,e[t]!==r&&(null==r?(e[t]="",e.removeAttribute(t)):e[t]=r))}})(e,t)}},any(e,t){const{type:n}=this;let r,s=!1;const o=a=>{switch(typeof a){case"string":case"number":case"boolean":s?r!==a&&(r=a,t[0].textContent=a):(s=!0,r=a,t=M(e.parentNode,t,[X(e,a)],S,e));break;case"function":o(a(e));break;case"object":case"undefined":if(null==a){s=!1,t=M(e.parentNode,t,[],S,e);break}default:if(s=!1,r=a,k(a))if(0===a.length)t.length&&(t=M(e.parentNode,t,[],S,e));else switch(typeof a[0]){case"string":case"number":case"boolean":o(String(a));break;case"function":o(a.map(ee,e));break;case"object":k(a[0])&&(a=a.concat.apply([],a));default:t=M(e.parentNode,t,a,S,e)}else"ELEMENT_NODE"in a?t=M(e.parentNode,t,11===a.nodeType?$.call(a.childNodes):[a],S,e):"text"in a?o(String(a.text)):"any"in a?o(a.any):"html"in a?t=M(e.parentNode,t,$.call(j([].concat(a.html).join(""),n).childNodes),S,e):"length"in a&&o($.call(a))}};return o},text(e){let t;const n=r=>{if(t!==r){t=r;const s=typeof r;"object"===s&&r?"text"in r?n(String(r.text)):"any"in r?n(r.any):"html"in r?n([].concat(r.html).join("")):"length"in r&&n($.call(r).join("")):"function"===s?n(r(e)):e.textContent=null==r?"":r}};return n}};const{create:te,freeze:ne,keys:re}=Object,se=Y.prototype,oe=_(new t),ae=e=>({html:ce("html",e),svg:ce("svg",e),render(t,n){const r="function"==typeof n?n():n,s=oe.get(t)||oe.set(t,ie()),o=r instanceof he?le(e,s,r):r;return o!==s.wire&&(s.wire=o,t.textContent="",t.appendChild(o.valueOf())),t}}),ie=()=>({stack:[],entry:null,wire:null}),ce=(e,n)=>{const r=_(new t);return s.for=(e,t)=>{const o=r.get(e)||r.set(e,te(null));return o[t]||(o[t]=(e=>function(){return le(n,e,s.apply(null,arguments))})(ie()))},s.node=function(){return le(n,ie(),s.apply(null,arguments)).valueOf()},s;function s(){return new he(e,pe.apply(null,arguments))}},le=(e,t,{type:n,template:r,values:s})=>{const{length:o}=s;ue(e,t,s,o);let{entry:a}=t;if(a&&a.template===r&&a.type===n)a.tag(r,...s);else{const o=new e(n);t.entry=a={type:n,template:r,tag:o,wire:L(o(r,...s))}}return a.wire},ue=(e,{stack:t},n,r)=>{for(let s=0;s<r;s++){const r=n[s];r instanceof fe?n[s]=le(e,t[s]||(t[s]=ie()),r):k(r)?ue(e,t[s]||(t[s]=ie()),r,r.length):t[s]=null}r<t.length&&t.splice(r)};function he(e,t){this.type=e,this.template=t.shift(),this.values=t}ne(he);const fe=he;function pe(){let e=[],t=0,{length:n}=arguments;for(;t<n;)e.push(arguments[t++]);return e}ae(Y);var de="function"==typeof cancelAnimationFrame,me=de?cancelAnimationFrame:clearTimeout,ge=de?requestAnimationFrame:setTimeout;function ve(e){var t,n,r,s,o;return i(),function(e,i,l){return r=e,s=i,o=l,n||(n=ge(a)),--t<0&&c(!0),c};function a(){i(),r.apply(s,o||[])}function i(){t=e||1/0,n=de?0:null}function c(e){var t=!!n;return t&&(me(n),e&&a()),t}}
10
+ /*! (c) Andrea Giammarchi - ISC */let be=null;const ye=_(new WeakMap),we=(e,t,n)=>{e.apply(t,n)},Ee={async:!1,always:!1},Ce=(e,t)=>"function"==typeof t?t(e):t,xe=(e,t,n,r)=>{const s=be.i++,{hook:o,args:a,stack:i,length:c}=be;s===c&&(be.length=i.push({}));const l=i[s];if(l.args=a,s===c){const s="function"==typeof n,{async:a,always:i}=(s?r:n)||r||Ee;l.$=s?n(t):Ce(void 0,t),l._=a?ye.get(o)||ye.set(o,ve()):we,l.f=t=>{const n=e(l.$,t);(i||l.$!==n)&&(l.$=n,l._(o,null,l.args))}}return[l.$,l.f]},Ne=new WeakMap;function ke({hook:e}){return e===this.hook}const Ae=new WeakMap,$e=_(Ae),_e=()=>{},Se=e=>(t,n)=>{const r=be.i++,{hook:s,after:o,stack:a,length:i}=be;if(r<i){const s=a[r],{update:i,values:c,stop:l}=s;if(!n||n.some(Te,c)){s.values=n,e&&l(e);const{clean:r}=s;r&&(s.clean=null,r());const a=()=>{s.clean=t()};e?i(a):o.push(a)}}else{const r=e?ve():_e,i={clean:null,update:r,values:n,stop:_e};be.length=a.push(i),($e.get(s)||$e.set(s,[])).push(i);const c=()=>{i.clean=t()};e?i.stop=r(c):o.push(c)}},Le=e=>{(Ae.get(e)||[]).forEach((e=>{const{clean:t,stop:n}=e;n(),t&&(e.clean=null,t())}))};Ae.has.bind(Ae);const je=Se(!0),Me=Se(!1),Oe=(e,t)=>{const n=be.i++,{stack:r,length:s}=be;return n===s?be.length=r.push({$:e(),_:t}):t&&!t.some(Te,r[n]._)||(r[n]={$:e(),_:t}),r[n].$};function Te(e,t){return e!==this[t]}let Re=null;try{Re=new{o(){}}.o}catch(Ot){}let We=e=>class extends e{};if(Re){const{getPrototypeOf:e,setPrototypeOf:t}=Object,{construct:n}="object"==typeof Reflect?Reflect:{construct(e,n,r){const s=[null];for(let e=0;e<n.length;e++)s.push(n[e]);const o=e.bind.apply(e,s);return t(new o,r.prototype)}};We=function(r,s){function o(){return n(s?e(r):r,arguments,o)}return t(o.prototype,r.prototype),t(o,r)}}const Pe={map:{},re:null},Ze=e=>new RegExp(`<(/)?(${e.join("|")})([^A-Za-z0-9:._-])`,"g");let Be=null;const ze=(e,t)=>{const{map:n,re:r}=Be||t;return e.replace(r,((e,t,r,s)=>{const{tagName:o,is:a,element:i}=n[r];return i?t?`</${a}>`:`<${a}${s}`:t?`</${o}>`:`<${o} is="${a}"${s}`}))},De=({tagName:e,is:t,element:n})=>n?t:`${e}[is="${t}"]`,Fe=()=>Be,He=e=>{Be=e},Ue={useCallback:(e,t)=>Oe((()=>e),t),useContext:e=>{const{hook:t,args:n}=be,r=Ne.get(e),s={hook:t,args:n};return r.some(ke,s)||r.push(s),e.value},useEffect:je,useLayoutEffect:Me,useMemo:Oe,useReducer:xe,useRef:e=>{const t=be.i++,{stack:n,length:r}=be;return t===r&&(be.length=n.push({current:e})),n[t]},useState:(e,t)=>xe(Ce,e,void 0,t)},{render:Ve,html:qe,svg:Ie}=(e=>{const t=te(se);return re(e).forEach((n=>{t[n]=e[n](t[n]||("convert"===n?p:String))})),n.prototype=t,ae(n);function n(){return Y.apply(this,arguments)}})({transform:()=>e=>ze(e,Pe)}),{defineProperties:Ge}=Object,Je=new t,Ke=new t,Qe=new t,Xe=new i,Ye="attributeChangedCallback",et="connectedCallback",tt=`dis${et}`,nt=(e,t,n)=>{if(n in e){const r=e[n];t[n]={configurable:true,value(){return dt.call(this),r.apply(this,arguments)}}}else t[n]={configurable:true,value:dt}},rt=e=>{const{prototype:n}=e,r=[],s={html:{configurable:true,get:ht},svg:{configurable:true,get:ft}};if(s["_🔥"]={value:{events:r,info:null}},"handleEvent"in n||(s.handleEvent={configurable:true,value:pt}),"render"in n&&n.render.length){const{oninit:e}=n;Ge(n,{oninit:{configurable:true,value(){const t=(e=>{const t=[];return function n(){const r=be,s=[];be={hook:n,args:arguments,stack:t,i:0,length:t.length,after:s};try{return e.apply(null,arguments)}finally{be=r;for(let e=0,{length:t}=s;e<t;e++)s[e]()}}})(this.render.bind(this,Ue));Ge(this,{render:{configurable:true,value:t}}),this.addEventListener("disconnected",Le.bind(null,t),!1),e&&e.apply(this,arguments)}}})}"oninit"in n&&(r.push("init"),nt(n,s,"render")),nt(n,s,Ye),nt(n,s,et),nt(n,s,tt),[[Ye,"onattributechanged",mt],[et,"onconnected",gt],[tt,"ondisconnected",bt],[et,"render",vt]].forEach((([e,t,o])=>{if(!(e in n)&&t in n)if("render"!==t&&r.push(t.slice(2)),e in s){const t=s[e].value;s[e]={configurable:true,value(){return t.apply(this,arguments),o.apply(this,arguments)}}}else s[e]={configurable:true,value:o}}));const o=e.booleanAttributes||[];o.forEach((e=>{e in n||(s[e]={configurable:true,get(){return this.hasAttribute(e)},set(t){t&&"false"!==t?this.setAttribute(e,t):this.removeAttribute(e)}})}));const a=e.observedAttributes||[];a.forEach((e=>{e in n||(s[e]={configurable:true,get(){return this.getAttribute(e)},set(t){null==t?this.removeAttribute(e):this.setAttribute(e,t)}})}));(e.mappedAttributes||[]).forEach((e=>{const o=new t,a="on"+e in n;a&&r.push(e),s[e]={configurable:true,get(){return o.get(this)},set(t){if(o.set(this,t),a){const n=st(e);if(n.detail=t,Xe.has(this))this.dispatchEvent(n);else{const e=Qe.get(this);e?e.push(n):Qe.set(this,[n])}}}}})),Ge(n,s);const i=o.concat(a);return i.length?Ge(e,{observedAttributes:{configurable:true,get:()=>i}}):e},st=e=>new r(e),ot=(...e)=>new fe("html",e);ot.for=qe.for;const at=(...e)=>new fe("svg",e);at.for=Ie.for;const it=(e,n,r)=>{const s=ct(e,n,new t);return r.set(e,s),s},ct=(e,t,n)=>(r,...s)=>{const o=n.get(r)||((e,t,{info:n})=>{const r=n?ze(t.join("_🔥"),n).split("_🔥"):t;return e.set(t,r),r})(n,r,e["_🔥"]);return Ve(e,(()=>t(o,...s)))};function lt(e){this.addEventListener(e,this)}function ut(e){this.dispatchEvent(e)}function ht(){return Je.get(this)||it(this,ot,Je)}function ft(){return Ke.get(this)||it(this,at,Ke)}function pt(e){this[`on${e.type}`](e)}function dt(){if(!Xe.has(this)){Xe.add(this),this["_🔥"].events.forEach(lt,this),this.dispatchEvent(st("init"));const e=Qe.get(this);e&&(Qe.delete(this),e.forEach(ut,this))}}function mt(e,t,n){const r=st("attributechanged");r.attributeName=e,r.oldValue=t,r.newValue=n,this.dispatchEvent(r)}function gt(){this.dispatchEvent(st("connected"))}function vt(){this.render()}function bt(){this.dispatchEvent(st("disconnected"))}const{create:yt,defineProperty:wt,defineProperties:Et,getOwnPropertyNames:Ct,getOwnPropertySymbols:xt,getOwnPropertyDescriptor:Nt,keys:kt}=Object,At={element:HTMLElement},$t=new t;new t;const _t=new t;new t;const St=e=>{const t=yt(null),n=yt(null),r={prototype:n,statics:t};return Ct(e).concat(xt(e)).forEach((r=>{const s=Nt(e,r);switch(s.enumerable=!1,r){case"extends":r="tagName";case"contains":case"includes":case"name":case"booleanAttributes":case"mappedAttributes":case"observedAttributes":case"style":case"tagName":t[r]=s;break;default:n[r]=s}})),r},Lt=(e,t,n)=>{if(!/^([A-Z][A-Za-z0-9_]*)(<([A-Za-z0-9:._-]+)>|:([A-Za-z0-9:._-]+))?$/.test(e))throw"Invalid name";const{$1:r,$3:s,$4:o}=RegExp;let a=s||o||t.tagName||t.extends||"element";const i="fragment"===a;if(i)a="element";else if(!/^[A-Za-z0-9:._-]+$/.test(a))throw"Invalid tag";let c="",l="";a.indexOf("-")<0?(c=r.replace(/(([A-Z0-9])([A-Z0-9][a-z]))|(([a-z])([A-Z]))/g,"$2$5-$3$6").toLowerCase()+n,c.indexOf("-")<0&&(l="-heresy")):(c=a+n,a="element");const u=c+l;if(customElements.get(u))throw`Duplicated ${u} definition`;const h=We("object"==typeof t?_t.get(t)||((e,t)=>{const{statics:n,prototype:r}=St(e),s=We(At[t]||(At[t]=document.createElement(t).constructor),!1);return Et(s.prototype,r),Et(s,n),_t.set(e,rt(s)),s})(t,a):$t.get(t)||(e=>{const t=We(e,!1);return $t.set(e,rt(t)),t})(t),!0),f="element"===a;if(wt(h,"new",{value:f?()=>document.createElement(u):()=>document.createElement(a,{is:u})}),wt(h.prototype,"is",{value:u}),""===n){const e=(e=>{const{length:t}=e;let n=0,r=0;for(;r<t;)n=(n<<5)-n+e.charCodeAt(r++),n&=n;return n.toString(36)})(c.toUpperCase());Pe.map[r]=jt(h,a,u,{id:e,i:0}),Pe.re=Ze(kt(Pe.map))}if(i){const{render:e}=h.prototype;wt(h.prototype,"render",{configurable:!0,value(){if(e&&e.apply(this,arguments),this.parentNode){const{firstChild:e}=this;let t=null;if(e){const n=document.createRange();n.setStartBefore(e),n.setEndAfter(this.lastChild),t=n.extractContents(),this.parentNode.replaceChild(t,this)}}}})}const p=[u,h];return f||p.push({extends:a}),customElements.define(...p),{Class:h,is:u,name:r,tagName:a}},jt=(e,t,n,r)=>{const{prototype:s}=e,o=((e,t)=>({tagName:e,is:t,element:"element"===e}))(t,n),a=[De(o)],i=e.includes||e.contains;if(i){const e={};kt(i).forEach((t=>{const n=`-${r.id}-${r.i++}`,{Class:s,is:o,name:c,tagName:l}=Lt(t,i[t],n);a.push(De(e[c]=jt(s,l,o,r)))}));const t=Ze(kt(e)),{events:n}=s["_🔥"],o={events:n,info:{map:e,re:t}};if(wt(s,"_🔥",{value:o}),"render"in s){const{render:e}=s,{info:t}=o;wt(s,"render",{configurable:!0,value(){const n=Fe();He(t);const r=e.apply(this,arguments);return He(n),r}})}}return"style"in e&&(e=>{if((e||"").length){const t=document.createElement("style");t.type="text/css",t.styleSheet?t.styleSheet.cssText=e:t.appendChild(document.createTextNode(e));const n=document.head||document.querySelector("head");n.insertBefore(t,n.lastChild)}})(e.style(...a)),o},Mt=["audio","background","cameraAccess","chat","people","embed","emptyRoomInvitation","help","leaveButton","precallReview","screenshare","video","floatSelf","recording","logo","locking","participantCount","settingsButton","pipButton","moreButton","personality","subgridLabels","lowData","breakout"];var Ot,Tt;Ot="WherebyEmbed",Tt={oninit(){this.iframe=((e,t)=>e?e[t]||(e[t]={current:null}):{current:null})()},onconnected(){window.addEventListener("message",this)},ondisconnected(){window.removeEventListener("message",this)},observedAttributes:["displayName","minimal","room","subdomain","lang","metadata","groups","virtualBackgroundUrl","avatarUrl",...Mt].map((e=>e.toLowerCase())),onattributechanged({attributeName:e,oldValue:t}){["room","subdomain"].includes(e)&&null==t||this.render()},style:e=>`\n ${e} {\n display: block;\n }\n ${e} iframe {\n border: none;\n height: 100%;\n width: 100%;\n }\n `,_postCommand(e,t=[]){this.iframe.current&&this.iframe.current.contentWindow.postMessage({command:e,args:t},this.url.origin)},startRecording(){this._postCommand("start_recording")},stopRecording(){this._postCommand("stop_recording")},startStreaming(){this._postCommand("start_streaming")},stopStreaming(){this._postCommand("stop_streaming")},toggleCamera(e){this._postCommand("toggle_camera",[e])},toggleMicrophone(e){this._postCommand("toggle_microphone",[e])},toggleScreenshare(e){this._postCommand("toggle_screenshare",[e])},onmessage({origin:e,data:t}){if(e!==this.url.origin)return;const{type:n,payload:r}=t;this.dispatchEvent(new CustomEvent(n,{detail:r}))},render(){const{avatarurl:e,displayname:t,lang:n,metadata:r,minimal:s,room:o,groups:a,virtualbackgroundurl:i}=this;if(!o)return this.html`Whereby: Missing room attr.`;let c=/https:\/\/([^.]+)\.whereby.com\/.+/.exec(o);const l=c&&c[1]||this.subdomain||null;if(!l)return this.html`Whereby: Missing subdomain attr.`;this.url=new URL(o,`https://${l}.whereby.com`),Object.entries({jsApi:!0,we:"1.9.0",iframeSource:l,...t&&{displayName:t},...n&&{lang:n},...r&&{metadata:r},...a&&{groups:a},...i&&{virtualBackgroundUrl:i},...e&&{avatarUrl:e},...null!=s&&{embed:s},...Mt.reduce(((e,t)=>null!=this[t.toLowerCase()]?{...e,[t]:this[t.toLowerCase()]}:e),{})}).forEach((([e,t])=>{this.url.searchParams.has(e)||this.url.searchParams.set(e,t)})),this.html`
11
+ <iframe
12
+ ref=${this.iframe}
13
+ src=${this.url}
14
+ allow="autoplay; camera; microphone; fullscreen; speaker; display-capture" />
15
+ `}},("string"==typeof Ot?Lt(Ot,Tt,""):Lt(Ot.name,Ot,"")).Class;var Rt={sdkVersion:"1.9.0"};export{Rt as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whereby.com/browser-sdk",
3
- "version": "1.8.0",
3
+ "version": "1.9.0",
4
4
  "description": "Configurable web component for embedding Whereby video rooms in web applications",
5
5
  "author": "Whereby AS",
6
6
  "license": "MIT",
@@ -13,6 +13,7 @@
13
13
  "main": "dist/lib.cjs.js",
14
14
  "module": "dist/lib.esm.js",
15
15
  "type": "module",
16
+ "files": ["dist/**/*.js", "dist/*.d.ts"],
16
17
  "scripts": {
17
18
  "prebuild": "rimraf dist",
18
19
  "build": "rollup -c",
package/.eslintrc DELETED
@@ -1,21 +0,0 @@
1
- {
2
- "env": {
3
- "browser": true,
4
- "es6": true,
5
- "jest": true,
6
- "node": true
7
- },
8
- "ignorePatterns": ["dist/*"],
9
- "parserOptions": {
10
- "ecmaVersion": "latest",
11
- "sourceType": "module",
12
- "ecmaFeatures": {
13
- "experimentalObjectRestSpread": true
14
- }
15
- },
16
- "extends": ["eslint:recommended"],
17
- "plugins": ["jest"],
18
- "rules": {
19
- "no-console": ["error", { "allow": ["warn", "error"] }]
20
- }
21
- }
@@ -1,17 +0,0 @@
1
- name: "Build"
2
- description: "Installs dependencies and builds lib"
3
- runs:
4
- using: "composite"
5
- steps:
6
- - uses: actions/setup-node@v2
7
- with:
8
- node-version: "16"
9
- cache: "yarn"
10
-
11
- - name: Install dependencies
12
- run: yarn install --frozen-lockfile
13
- shell: bash
14
-
15
- - name: Build
16
- run: yarn build
17
- shell: bash
@@ -1,102 +0,0 @@
1
- ---
2
- name: Build, test & deploy
3
- on:
4
- release:
5
- types: [created]
6
- jobs:
7
- build_and_test:
8
- concurrency: build_and_test_main_${{ github.head_ref }}
9
- name: Build & test
10
- runs-on: ubuntu-latest
11
- env:
12
- GITHUB_TOKEN: ${{ secrets.WHEREBY_GITHUB_TOKEN }}
13
- steps:
14
- - name: Checkout source code
15
- uses: actions/checkout@v2
16
-
17
- - name: Build
18
- uses: ./.github/actions/build
19
-
20
- - name: Test
21
- run: yarn test
22
- get_version_tag:
23
- runs-on: ubuntu-latest
24
- needs: build_and_test
25
- outputs:
26
- tag: ${{ steps.tag_check.outputs.tag }}
27
- steps:
28
- - uses: actions/checkout@v3
29
- - name: Get version tag
30
- id: tag_check
31
- # 1st sed: remove major.minor.patch numbers
32
- # 2nd sed: remove wrapper quotes
33
- # 3rd sed: remove "-" and tag version if exists
34
- run: |
35
- TAG=$(npm pkg get version \
36
- | sed 's/\([0-9]*\.[0-9]*\.[0-9]*\)//' \
37
- | sed 's/^"\(.*\)"$/\1/' \
38
- | sed 's/-\([a-z]*\)\([0-9]*\)/\1/')
39
- echo "tag=$TAG" >> $GITHUB_OUTPUT
40
- deploy_cdn:
41
- concurrency: deploy_cdn_main_${{ github.head_ref }}
42
- name: Deploy to CDN
43
- needs: get_version_tag
44
- # Only run when there's no version tag (e.g. -beta) specified
45
- if: ${{ needs.get_version_tag.outputs.tag == 0 }}
46
- runs-on: ubuntu-latest
47
- env:
48
- GITHUB_TOKEN: ${{ secrets.WHEREBY_GITHUB_TOKEN }}
49
- steps:
50
- - name: Checkout source code
51
- uses: actions/checkout@v2
52
-
53
- - name: Build
54
- uses: ./.github/actions/build
55
-
56
- - name: Configure AWS Credentials
57
- uses: aws-actions/configure-aws-credentials@v1
58
- with:
59
- aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
60
- aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
61
- aws-region: eu-west-1
62
-
63
- - uses: jakejarvis/s3-sync-action@master
64
- with:
65
- args: --acl public-read --follow-symlinks
66
- env:
67
- AWS_S3_BUCKET: whereby-cdn
68
- AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
69
- AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
70
- AWS_REGION: "es-west-1"
71
- SOURCE_DIR: "dist/"
72
- DEST_DIR: "embed/"
73
-
74
- - name: Invalidate cloudfront publication
75
- run: aws cloudfront create-invalidation --distribution-id=E6H48QPJYYL39 --paths "/embed/*"
76
- deploy_npm:
77
- concurrency: deploy_npm_main_${{ github.head_ref }}
78
- name: Deploy to npm
79
- needs: get_version_tag
80
- runs-on: ubuntu-latest
81
- steps:
82
- - name: Checkout source code
83
- uses: actions/checkout@v3
84
-
85
- # Setup .npmrc file to publish to npm
86
- - uses: actions/setup-node@v3
87
- with:
88
- node-version: "16.x"
89
- registry-url: "https://registry.npmjs.org"
90
-
91
- - name: Publish on npm
92
- run: |
93
- TAG=${{ needs.get_version_tag.outputs.tag }}
94
- if [[ -z ${TAG} ]]; then
95
- echo "deploy with latest tag"
96
- npm publish
97
- else
98
- echo "deploy with ${{ needs.get_version_tag.outputs.tag }} tag"
99
- npm publish --tag ${{ needs.get_version_tag.outputs.tag }}
100
- fi
101
- env:
102
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
@@ -1,24 +0,0 @@
1
- ---
2
- name: Test
3
- on:
4
- push:
5
- branches:
6
- - main
7
- pull_request:
8
- branches:
9
- - main
10
- jobs:
11
- test:
12
- name: Test
13
- concurrency: test_${{ github.head_ref }}
14
- runs-on: ubuntu-latest
15
-
16
- steps:
17
- - name: Checkout source code
18
- uses: actions/checkout@v2
19
-
20
- - name: Build
21
- uses: ./.github/actions/build
22
-
23
- - name: Test
24
- run: yarn test
package/.prettierignore DELETED
@@ -1,7 +0,0 @@
1
- build/
2
- dist/
3
- node_modules/
4
- *.css
5
- *.json
6
- *.html
7
- *.md
package/.prettierrc DELETED
@@ -1,4 +0,0 @@
1
- {
2
- "tabWidth": 4,
3
- "printWidth": 120
4
- }
@@ -1,5 +0,0 @@
1
- module.exports = {
2
- stories: ["../src/**/*.stories.mdx", "../src/**/*.stories.@(js|jsx|ts|tsx)"],
3
- addons: ["@storybook/addon-links", "@storybook/addon-essentials"],
4
- framework: "@storybook/web-components",
5
- };
@@ -1,9 +0,0 @@
1
- export const parameters = {
2
- actions: { argTypesRegex: "^on[A-Z].*" },
3
- controls: {
4
- matchers: {
5
- color: /(background|color)$/i,
6
- date: /Date$/,
7
- },
8
- },
9
- };
package/jest.config.js DELETED
@@ -1,4 +0,0 @@
1
- export default {
2
- testEnvironment: "jest-environment-node",
3
- transform: {},
4
- };
package/rollup.config.js DELETED
@@ -1,46 +0,0 @@
1
- import nodeResolve from "@rollup/plugin-node-resolve";
2
- import replace from "@rollup/plugin-replace";
3
- import { terser } from "rollup-plugin-terser";
4
- import pkg from "./package.json";
5
-
6
- const replaceValues = {
7
- preventAssignment: true,
8
- values: {
9
- __SDK_VERSION__: pkg.version,
10
- },
11
- };
12
-
13
- export default [
14
- // Commonjs build of lib, to be used with bundlers
15
- {
16
- input: "src/lib/index.js",
17
- output: {
18
- exports: "default",
19
- file: "dist/lib.cjs.js",
20
- format: "cjs",
21
- },
22
- external: ["heresy"],
23
- plugins: [replace(replaceValues)],
24
- },
25
- // Esm build of lib, to be used with bundlers
26
- {
27
- input: "src/lib/index.js",
28
- output: {
29
- exports: "default",
30
- file: "dist/lib.esm.js",
31
- format: "esm",
32
- },
33
- external: ["heresy"],
34
- plugins: [replace(replaceValues)],
35
- },
36
- // Legacy build of lib in ES format, bundling the dependencies
37
- {
38
- input: "src/lib/index.js",
39
- output: {
40
- exports: "default",
41
- file: `dist/v${pkg.version.split(".")[0]}.js`,
42
- format: "esm",
43
- },
44
- plugins: [nodeResolve(), terser(), replace(replaceValues)],
45
- },
46
- ];
@@ -1,105 +0,0 @@
1
- import { html } from "lit-html";
2
- import "./lib";
3
-
4
- export default {
5
- title: "Examples/<whereby-embed>",
6
- argTypes: {
7
- audio: { control: "boolean" },
8
- avatarUrl: { control: "text", description: "Image url to use for avatar" },
9
- background: { control: "boolean" },
10
- cameraAccess: { control: "boolean" },
11
- chat: { control: "boolean" },
12
- displayName: { control: "text", description: "The name to use for the local participant" },
13
- embed: { control: "boolean" },
14
- emptyRoomInvitation: { control: "boolean" },
15
- floatSelf: { control: "boolean" },
16
- help: { control: "boolean" },
17
- leaveButton: { control: "boolean" },
18
- locking: { control: "boolean" },
19
- logo: { control: "boolean" },
20
- people: { control: "boolean" },
21
- precallReview: { control: "boolean" },
22
- recording: { control: "boolean" },
23
- room: { control: "text" },
24
- screenshare: { control: "boolean" },
25
- topToolbar: { control: "boolean" },
26
- video: { control: "boolean" },
27
- virtualBackgroundUrl: { control: "text", description: "Image url to use for virtual background" },
28
- },
29
- };
30
-
31
- const offOn = (arg) => (arg ? "on" : "off");
32
-
33
- const WherebyEmbed = ({
34
- audio,
35
- avatarUrl,
36
- background,
37
- cameraAccess,
38
- chat,
39
- displayName,
40
- emptyRoomInvitation,
41
- floatSelf,
42
- help,
43
- leaveButton,
44
- logo,
45
- people,
46
- precallReview,
47
- recording,
48
- room,
49
- screenshare,
50
- video,
51
- virtualBackgroundUrl,
52
- }) => {
53
- return html`<whereby-embed
54
- audio=${offOn(audio)}
55
- avatarUrl=${avatarUrl}
56
- background=${offOn(background)}
57
- cameraAccess=${offOn(cameraAccess)}
58
- chat=${offOn(chat)}
59
- displayName=${displayName}
60
- emptyRoomInvitation=${emptyRoomInvitation}
61
- floatSelf=${offOn(floatSelf)}
62
- help=${offOn(help)}
63
- leaveButton=${offOn(leaveButton)}
64
- logo=${offOn(logo)}
65
- people=${offOn(people)}
66
- precallReview=${offOn(precallReview)}
67
- recording=${offOn(recording)}
68
- screenshare=${offOn(screenshare)}
69
- video=${offOn(video)}
70
- virtualBackgroundUrl=${virtualBackgroundUrl}
71
- room="${room}"
72
- style="height: 100vh"
73
- />`;
74
- };
75
-
76
- const Template = (args) => WherebyEmbed(args);
77
- export const Primary = Template.bind({});
78
-
79
- Primary.args = {
80
- audio: true,
81
- avatarUrl: "",
82
- background: true,
83
- cameraAccess: true,
84
- chat: true,
85
- displayName: "Your name",
86
- emptyRoomInvitation: true,
87
- floatSelf: false,
88
- help: true,
89
- leaveButton: true,
90
- logo: true,
91
- people: true,
92
- precallReview: true,
93
- room: process.env.STORYBOOK_ROOM,
94
- screenshare: true,
95
- video: true,
96
- virtualBackgroundUrl: "",
97
- };
98
-
99
- Primary.parameters = {
100
- docs: {
101
- transformSource: (src) => {
102
- return (src || "").replace(/><iframe(.+)$/, " />");
103
- },
104
- },
105
- };
@@ -1,83 +0,0 @@
1
- import { jest } from "@jest/globals";
2
-
3
- const define = jest.fn();
4
- const ref = jest.fn();
5
- jest.mock("heresy", () => ({
6
- __esModule: true,
7
- define,
8
- ref,
9
- }));
10
-
11
- describe("@whereby/browser-sdk", () => {
12
- it("should export sdk version", async () => {
13
- const whereby = await import("../");
14
- expect(whereby.default.sdkVersion).toEqual(expect.any(String));
15
- });
16
-
17
- describe("web component", () => {
18
- it("should define <whereby-embed />", async () => {
19
- await import("../");
20
- expect(define).toBeCalledWith("WherebyEmbed", expect.any(Object));
21
- });
22
-
23
- it("should expose attributes", async () => {
24
- await import("..");
25
-
26
- expect(define).toBeCalledWith(
27
- expect.any(String),
28
- expect.objectContaining({
29
- observedAttributes: [
30
- "displayname",
31
- "minimal",
32
- "room",
33
- "subdomain",
34
- "lang",
35
- "metadata",
36
- "groups",
37
- "virtualbackgroundurl",
38
- "avatarurl",
39
- "audio",
40
- "background",
41
- "cameraaccess",
42
- "chat",
43
- "people",
44
- "embed",
45
- "emptyroominvitation",
46
- "help",
47
- "leavebutton",
48
- "precallreview",
49
- "screenshare",
50
- "video",
51
- "floatself",
52
- "recording",
53
- "logo",
54
- "locking",
55
- "participantcount",
56
- "settingsbutton",
57
- "pipbutton",
58
- "morebutton",
59
- "personality",
60
- "subgridlabels",
61
- "lowdata",
62
- "breakout",
63
- ],
64
- })
65
- );
66
- });
67
-
68
- it("should expose commands", async () => {
69
- await import("../");
70
-
71
- expect(define).toBeCalledWith(
72
- expect.any(String),
73
- expect.objectContaining({
74
- startRecording: expect.any(Function),
75
- stopRecording: expect.any(Function),
76
- toggleCamera: expect.any(Function),
77
- toggleMicrophone: expect.any(Function),
78
- toggleScreenshare: expect.any(Function),
79
- })
80
- );
81
- });
82
- });
83
- });