matrix-api
Advanced tools
| !function(){"use strict";var e="undefined"==typeof global?self:global;if("function"!=typeof e.require){var t={},n={},r={},o={}.hasOwnProperty,c=/^\.\.?(\/|$)/,a=function(e,t){for(var n,r=[],o=(c.test(t)?e+"/"+t:t).split("/"),a=0,s=o.length;a<s;a++)".."===(n=o[a])?r.pop():"."!==n&&""!==n&&r.push(n);return r.join("/")},s=function(e){return e.split("/").slice(0,-1).join("/")},i=function(t,r){var o,c={id:t,exports:{},hot:v&&v.createHot(t)};return n[t]=c,r(c.exports,(o=t,function(t){var n=a(s(o),t);return e.require(n,o)}),c),c.exports},u=function(e){var t=r[e];return t&&e!==t?u(t):e},l=function(e,r){null==r&&(r="/");var c=u(e);if(o.call(n,c))return n[c].exports;if(o.call(t,c))return i(c,t[c]);throw new Error("Cannot find module '"+e+"' from '"+r+"'")};l.alias=function(e,t){r[t]=e};var f=/\.[^.\/]+$/,h=/\/index(\.[^\/]+)?$/;l.register=l.define=function(e,c){if(e&&"object"==typeof e)for(var a in e)o.call(e,a)&&l.register(a,e[a]);else t[e]=c,delete n[e],function(e){if(f.test(e)){var t=e.replace(f,"");o.call(r,t)&&r[t].replace(f,"")!==t+"/index"||(r[t]=e)}if(h.test(e)){var n=e.replace(h,"");o.call(r,n)||(r[n]=e)}}(e)},l.list=function(){var e=[];for(var n in t)o.call(t,n)&&e.push(n);return e};var v=e._hmr&&new e._hmr(function(e,t){return u(a(s(e),t))},l,t,n);l._cache=n,l.hmr=v&&v.wrap,l.brunch=!0,e.require=l}}(),"undefined"==typeof window||window,require.register("matrix-api/Matrix.js",function(e,t,n){"use strict";function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(e,"__esModule",{value:!0}),e.Matrix=void 0;var o=t("curvature/base/Mixin"),c=t("curvature/mixin/EventTargetMixin");function a(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function s(e,t){for(var n,r=0;r<t.length;r++)(n=t[r]).enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}function i(e,t){if(t&&("object"===r(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function u(e){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var l=function(e){function t(e){var r;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),(r=n.call(this)).baseUrl=e||"https://matrix.org/_matrix",r.clientUrl="".concat(r.baseUrl,"/client/r0"),r.mediaUrl="".concat(r.baseUrl,"/media/r0"),r.profileCache=new Map,r.mediaCache=new Map,r}!function(e,t){throw new TypeError("Super expression must either be null or a function")}(0,o.Mixin.with(c.EventTargetMixin));var n=function(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}();return function(){var n,r=u(e);if(t){var o=u(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return i(this,n)}}(t);return function(e,t,n){t&&s(e.prototype,t)}(t,[{key:"isLoggedIn",get:function(){sessionStorage.getItem("matrix:access-token")&&this.dispatchEvent(new CustomEvent("logged-in"));var e=sessionStorage.getItem("matrix:access-token")||"false";return JSON.parse(e),sessionStorage.getItem("matrix:access-token")}},{key:"initSso",value:function(e){var t=this,n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:window,r=window.screenX+window.outerWidth/2+200,o=window.screenY+window.outerHeight/2-300,c="width=".concat(400,",height=").concat(600,",screenX=").concat(r,",screenY=").concat(o);n.open("".concat(this.clientUrl,"/").concat("login/sso/redirect?redirectUrl="+e),"matrix-login",c),n.addEventListener("message",function(e){if(e.origin===location.origin){var n=JSON.parse(e.data);"s.sso.complete"!==n.type||(sessionStorage.setItem("matrix:access-token",JSON.stringify(n.data)),t.dispatchEvent(new CustomEvent("logged-in")))}})}},{key:"completeSso",value:function(e){var t={type:"m.login.token",token:e,txn_id:(1/Math.random()).toString(36)};fetch("".concat(this.clientUrl,"/").concat("login"),{method:"POST",body:JSON.stringify(t)}).then(function(e){return e.json()}).then(function(e){window.opener.postMessage(JSON.stringify({type:"s.sso.complete",data:e}),location.origin),window.close()})}},{key:"getGuestToken",value:function(){var e=sessionStorage.getItem("matrix:access-token")||"false",t=JSON.parse(e);if(t&&t.isGuest)return Promise.resolve(t);var n=fetch("".concat(this.clientUrl,"/register?kind=guest"),{method:"POST",body:"{}"}).then(function(e){return e.json()});return n.then(function(e){e.isGuest=!0,sessionStorage.setItem("matrix:access-token",JSON.stringify(e))}),n}},{key:"getToken",value:function(){var e=sessionStorage.getItem("matrix:access-token")||"false",t=JSON.parse(e);return t?Promise.resolve(t):matrix.getGuestToken()}},{key:"listenForServerEvents",value:function(){var e=this,t=JSON.parse(sessionStorage.getItem("matrix:access-token")||"false");if(!t)return Promise.reject("No access token found.");var n="".concat(this.clientUrl,"/events?access_token=").concat(t.access_token);fetch(n).then(function(e){return e.json()}).then(function(t){return e.streamServerEvents(t)})}},{key:"listenForRoomEvents",value:function(e,t){var n=this,r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"";if(!t||!t.cancelled){var o=JSON.parse(sessionStorage.getItem("matrix:access-token")||"false");if(!o)return Promise.reject("No access token found.");var c="".concat(this.clientUrl,"/events?room_id=").concat(e,"&access_token=").concat(o.access_token,"&from=").concat(r);return t=t||{cancelled:!1},fetch(c).then(function(e){return e.json()}).then(function(r){return n.streamServerEvents(r,e,t)}),t}}},{key:"getUserProfile",value:function(e){if(this.profileCache.has(e,void 0))return this.profileCache.get(e,void 0);var t=fetch("".concat(this.clientUrl,"/profile/").concat(e)).then(function(e){return e.json()});return this.profileCache.set(e,t),t}},{key:"getUserData",value:function(e){var t=JSON.parse(sessionStorage.getItem("matrix:access-token")||"false");return t?fetch("".concat(this.clientUrl,"/user/").concat(t.user_id,"/account_data/").concat(e,"?access_token=").concat(t.access_token)).then(function(e){return e.json()}):Promise.reject("No access token found.")}},{key:"putUserData",value:function(e,t){var n=JSON.parse(sessionStorage.getItem("matrix:access-token")||"false");if(n){var r="".concat(this.clientUrl,"/user/").concat(n.user_id,"/account_data/").concat(e,"?access_token=").concat(n.access_token);return fetch(r,{method:"PUT",body:t}).then(function(e){if(!e.ok){var t=new Error("HTTP status code: "+e.status);throw t.status=e.status,t.response=e,t}return e}).then(function(e){return e.json()})}}},{key:"getMediaUrl",value:function(e){var t=new URL(e);return"".concat(this.mediaUrl,"/download/").concat(t.pathname.substr(2))}},{key:"getMedia",value:function(e){if(this.mediaCache.has(e))return this.mediaCache.get(e);var t=fetch(this.getMediaUrl(e)).then(function(e){return Promise.all([e.arrayBuffer(),e.headers.get("Content-type")])}).then(function(e){var t=function(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,c=[],a=!0,s=!1;try{for(n=n.call(e);!(a=(r=n.next()).done)&&(c.push(r.value),!t||c.length!==t);a=!0);}catch(e){s=!0,o=e}finally{try{a||null==n.return||n.return()}finally{if(s)throw o}}return c}}(e,t)||function(e,t){if(e){if("string"==typeof e)return a(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?a(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(e,2),n=t[0],r=t[1];return URL.createObjectURL(new Blob([n],{type:r}))});return this.mediaCache.set(e,t),t}},{key:"postMedia",value:function(e){var t=sessionStorage.getItem("matrix:access-token")||"false",n=JSON.parse(t);if(n){var r="".concat(this.mediaUrl,"/upload?access_token=").concat(n.access_token),o=new Headers({"Content-Type":e.type});return fetch(r,{method:"POST",headers:o,body:e}).then(function(e){return e.json()})}}},{key:"putEvent",value:function(e,t,n){var r=sessionStorage.getItem("matrix:access-token")||"false",o=JSON.parse(r);if(o){var c="".concat(this.clientUrl,"/rooms/").concat(e,"/send/").concat(t,"/").concat(Math.random().toString(36),"?access_token=").concat(o.access_token),a={method:"PUT",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify(n)};return fetch(c,a).then(function(e){return e.json()})}}},{key:"getEvent",value:function(e,t){var n=sessionStorage.getItem("matrix:access-token")||"false",r=JSON.parse(n);if(r){var o="".concat(this.clientUrl,"/rooms/").concat(e,"/event/").concat(t,"?access_token=").concat(r.access_token),c=new Headers({"Content-Type":"application/json"});return fetch(o,{method:"GET",headers:c}).then(function(e){return e.json()})}}},{key:"sync",value:function(){var e=sessionStorage.getItem("matrix:access-token")||"false",t=JSON.parse(e);if(!t)return Promise.resolve();var n="".concat(this.clientUrl,"/sync?full_state=true&access_token=").concat(t.access_token);return fetch(n).then(function(e){return e.json()})}},{key:"getRoomState",value:function(e){var t=sessionStorage.getItem("matrix:access-token")||"false",n=JSON.parse(t);if(!n)return Promise.resolve();var r="".concat(this.clientUrl,"/rooms/").concat(e,"/state?access_token=").concat(n.access_token);return fetch(r).then(function(e){return e.json()})}},{key:"syncRoom",value:function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"",n=JSON.parse(sessionStorage.getItem("matrix:access-token")||"false");if(!n)return Promise.reject("No access token found.");var r="".concat(this.clientUrl,"/rooms/").concat(e,"/messages?dir=b&room_id=").concat(e,"&access_token=").concat(n.access_token,"&from=").concat(t);return fetch(r).then(function(e){return e.json()})}},{key:"syncRoomHistory",value:function(e,t){var n=this,r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null;this.syncRoom(e,t).then(function(t){return t.chunk&&r&&t.chunk.forEach(r),t.chunk.length&&n.syncRoomHistory(e,t.end,r)})}},{key:"streamServerEvents",value:function(e,t,n){var r=this;n&&n.cancelled||(t?this.listenForRoomEvents(t,n,e.end):this.listenForServerEvents(),e.chunk&&e.chunk.forEach(function(e){var t=new MatrixEvent;e.event_id||(e.event_id="local:"+(1/Math.random()).toString(36)),t.consume(e),r.dispatchEvent(new CustomEvent("matrix-event",{detail:t})),r.dispatchEvent(new CustomEvent(t.type,{detail:t}))}))}},{key:"getCurrentUserId",value:function(){var e=sessionStorage.getItem("matrix:access-token")||"false",t=JSON.parse(e);return t?t.user_id:void 0}},{key:"createRoom",value:function(e,t,n){var r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{},o=JSON.stringify({name:e,topic:t,visibility:n,initial_state:r}),c=JSON.parse(sessionStorage.getItem("matrix:access-token")||"false");if(!c)return Promise.resolve();var a="".concat(this.clientUrl,"/createRoom?access_token=").concat(c.access_token);return fetch(a,{body:o,method:"POST"}).then(function(e){return e.json()})}},{key:"joinRoom",value:function(e){var t=JSON.parse(sessionStorage.getItem("matrix:access-token")||"false");return t?void fetch("".concat(this.clientUrl,"/rooms/").concat(e,"/join?access_token=").concat(t.access_token),{method:"POST"}).then(function(e){return e.json()}):Promise.reject("No access token found.")}},{key:"leaveRoom",value:function(e){var t=JSON.parse(sessionStorage.getItem("matrix:access-token")||"false");return t?void fetch("".concat(this.clientUrl,"/rooms/").concat(e,"/leave?access_token=").concat(t.access_token),{method:"POST"}).then(function(e){return e.json()}):Promise.reject("No access token found.")}},{key:"whoAmI",value:function(){var e=JSON.parse(sessionStorage.getItem("matrix:access-token")||"false");return e?fetch("".concat(this.clientUrl,"/account/whoami?access_token=").concat(e.access_token)).then(function(e){return e.json()}):Promise.reject("No access token found.")}}]),t}();e.Matrix=l}),require.register("___globals___",function(e,t,n){}),require("___globals___"); | ||
| !function(){"use strict";var e="undefined"==typeof global?self:global;if("function"!=typeof e.require){var t={},n={},r={},o={}.hasOwnProperty,c=/^\.\.?(\/|$)/,a=function(e,t){for(var n,r=[],o=(c.test(t)?e+"/"+t:t).split("/"),a=0,s=o.length;a<s;a++)".."===(n=o[a])?r.pop():"."!==n&&""!==n&&r.push(n);return r.join("/")},s=function(e){return e.split("/").slice(0,-1).join("/")},i=function(t,r){var o,c={id:t,exports:{},hot:v&&v.createHot(t)};return n[t]=c,r(c.exports,(o=t,function(t){var n=a(s(o),t);return e.require(n,o)}),c),c.exports},u=function(e){var t=r[e];return t&&e!==t?u(t):e},l=function(e,r){null==r&&(r="/");var c=u(e);if(o.call(n,c))return n[c].exports;if(o.call(t,c))return i(c,t[c]);throw new Error("Cannot find module '"+e+"' from '"+r+"'")};l.alias=function(e,t){r[t]=e};var f=/\.[^.\/]+$/,h=/\/index(\.[^\/]+)?$/;l.register=l.define=function(e,c){if(e&&"object"==typeof e)for(var a in e)o.call(e,a)&&l.register(a,e[a]);else t[e]=c,delete n[e],function(e){if(f.test(e)){var t=e.replace(f,"");o.call(r,t)&&r[t].replace(f,"")!==t+"/index"||(r[t]=e)}if(h.test(e)){var n=e.replace(h,"");o.call(r,n)||(r[n]=e)}}(e)},l.list=function(){var e=[];for(var n in t)o.call(t,n)&&e.push(n);return e};var v=e._hmr&&new e._hmr(function(e,t){return u(a(s(e),t))},l,t,n);l._cache=n,l.hmr=v&&v.wrap,l.brunch=!0,e.require=l}}(),"undefined"==typeof window||window,require.register("matrix-api/Matrix.js",function(e,t,n){"use strict";function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(e,"__esModule",{value:!0}),e.Matrix=void 0;var o=t("curvature/base/Mixin"),c=t("curvature/mixin/EventTargetMixin");function a(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function s(e,t){for(var n,r=0;r<t.length;r++)(n=t[r]).enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}function i(e,t){if(t&&("object"===r(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function u(e){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var l=function(e){function t(e){var r;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),(r=n.call(this)).baseUrl=e||"https://matrix.org/_matrix",r.clientUrl="".concat(r.baseUrl,"/client/r0"),r.mediaUrl="".concat(r.baseUrl,"/media/r0"),r.profileCache=new Map,r.mediaCache=new Map,r}!function(e,t){throw new TypeError("Super expression must either be null or a function")}(0,o.Mixin.with(c.EventTargetMixin));var n=function(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}();return function(){var n,r=u(e);if(t){var o=u(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return i(this,n)}}(t);return function(e,t,n){t&&s(e.prototype,t)}(t,[{key:"isLoggedIn",get:function(){sessionStorage.getItem("matrix:access-token")&&this.dispatchEvent(new CustomEvent("logged-in"));var e=sessionStorage.getItem("matrix:access-token")||"false";return JSON.parse(e),sessionStorage.getItem("matrix:access-token")}},{key:"initSso",value:function(e){var t=this,n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:window,r=window.screenX+window.outerWidth/2+200,o=window.screenY+window.outerHeight/2-300,c="width=".concat(400,",height=").concat(600,",screenX=").concat(r,",screenY=").concat(o);n.open("".concat(this.clientUrl,"/").concat("login/sso/redirect?redirectUrl="+e),"matrix-login",c),n.addEventListener("message",function(e){if(e.origin===location.origin){var n=JSON.parse(e.data);"s.sso.complete"!==n.type||(sessionStorage.setItem("matrix:access-token",JSON.stringify(n.data)),t.dispatchEvent(new CustomEvent("logged-in")))}})}},{key:"completeSso",value:function(e){var t={type:"m.login.token",token:e,txn_id:(1/Math.random()).toString(36)};fetch("".concat(this.clientUrl,"/").concat("login"),{method:"POST",body:JSON.stringify(t)}).then(function(e){return e.json()}).then(function(e){window.opener.postMessage(JSON.stringify({type:"s.sso.complete",data:e}),location.origin),window.close()})}},{key:"getGuestToken",value:function(){var e=sessionStorage.getItem("matrix:access-token")||"false",t=JSON.parse(e);if(t&&t.isGuest)return Promise.resolve(t);var n=fetch("".concat(this.clientUrl,"/register?kind=guest"),{method:"POST",body:"{}"}).then(function(e){return e.json()});return n.then(function(e){e.isGuest=!0,sessionStorage.setItem("matrix:access-token",JSON.stringify(e))}),n}},{key:"getToken",value:function(){var e=sessionStorage.getItem("matrix:access-token")||"false",t=JSON.parse(e);return t?Promise.resolve(t):matrix.getGuestToken()}},{key:"listenForServerEvents",value:function(){var e=this,t=JSON.parse(sessionStorage.getItem("matrix:access-token")||"false");if(!t)return Promise.reject("No access token found.");var n="".concat(this.clientUrl,"/events?access_token=").concat(t.access_token);fetch(n).then(function(e){return e.json()}).then(function(t){return e.streamServerEvents(t)})}},{key:"listenForRoomEvents",value:function(e,t){var n=this,r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"";if(!t||!t.cancelled){var o=JSON.parse(sessionStorage.getItem("matrix:access-token")||"false");if(!o)return Promise.reject("No access token found.");var c="".concat(this.clientUrl,"/events?room_id=").concat(e,"&access_token=").concat(o.access_token,"&from=").concat(r);return t=t||{cancelled:!1},fetch(c).then(function(e){return e.json()}).then(function(r){return n.streamServerEvents(r,e,t)}),t}}},{key:"getUserProfile",value:function(e){if(this.profileCache.has(e,void 0))return this.profileCache.get(e,void 0);var t=fetch("".concat(this.clientUrl,"/profile/").concat(e)).then(function(e){return e.json()});return this.profileCache.set(e,t),t}},{key:"getUserData",value:function(e){var t=JSON.parse(sessionStorage.getItem("matrix:access-token")||"false");return t?fetch("".concat(this.clientUrl,"/user/").concat(t.user_id,"/account_data/").concat(e,"?access_token=").concat(t.access_token)).then(function(e){return e.json()}):Promise.reject("No access token found.")}},{key:"putUserData",value:function(e,t){var n=JSON.parse(sessionStorage.getItem("matrix:access-token")||"false");if(n){var r="".concat(this.clientUrl,"/user/").concat(n.user_id,"/account_data/").concat(e,"?access_token=").concat(n.access_token);return fetch(r,{method:"PUT",body:t}).then(function(e){if(!e.ok){var t=new Error("HTTP status code: "+e.status);throw t.status=e.status,t.response=e,t}return e}).then(function(e){return e.json()})}}},{key:"getMediaUrl",value:function(e){var t=new URL(e);return"".concat(this.mediaUrl,"/download/").concat(t.pathname.substr(2))}},{key:"getMedia",value:function(e){if(this.mediaCache.has(e))return this.mediaCache.get(e);var t=fetch(this.getMediaUrl(e)).then(function(e){return Promise.all([e.arrayBuffer(),e.headers.get("Content-type")])}).then(function(e){var t=function(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,c=[],a=!0,s=!1;try{for(n=n.call(e);!(a=(r=n.next()).done)&&(c.push(r.value),!t||c.length!==t);a=!0);}catch(e){s=!0,o=e}finally{try{a||null==n.return||n.return()}finally{if(s)throw o}}return c}}(e,t)||function(e,t){if(e){if("string"==typeof e)return a(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?a(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(e,2),n=t[0],r=t[1];return URL.createObjectURL(new Blob([n],{type:r}))});return this.mediaCache.set(e,t),t}},{key:"postMedia",value:function(e){var t=sessionStorage.getItem("matrix:access-token")||"false",n=JSON.parse(t);if(n){var r="".concat(this.mediaUrl,"/upload?access_token=").concat(n.access_token),o=new Headers({"Content-Type":e.type});return fetch(r,{method:"POST",headers:o,body:e}).then(function(e){return e.json()})}}},{key:"putEvent",value:function(e,t,n){var r=sessionStorage.getItem("matrix:access-token")||"false",o=JSON.parse(r);if(o){var c="".concat(this.clientUrl,"/rooms/").concat(e,"/send/").concat(t,"/").concat(Math.random().toString(36),"?access_token=").concat(o.access_token),a={method:"PUT",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify(n)};return fetch(c,a).then(function(e){return e.json()})}}},{key:"getEvent",value:function(e,t){var n=sessionStorage.getItem("matrix:access-token")||"false",r=JSON.parse(n);if(r){var o="".concat(this.clientUrl,"/rooms/").concat(e,"/event/").concat(t,"?access_token=").concat(r.access_token),c=new Headers({"Content-Type":"application/json"});return fetch(o,{method:"GET",headers:c}).then(function(e){return e.json()})}}},{key:"sync",value:function(){var e=sessionStorage.getItem("matrix:access-token")||"false",t=JSON.parse(e);if(!t)return Promise.resolve();var n="".concat(this.clientUrl,"/sync?full_state=true&access_token=").concat(t.access_token);return fetch(n).then(function(e){return e.json()})}},{key:"getRoomState",value:function(e){var t=sessionStorage.getItem("matrix:access-token")||"false",n=JSON.parse(t);if(!n)return Promise.resolve();var r="".concat(this.clientUrl,"/rooms/").concat(e,"/state?access_token=").concat(n.access_token);return fetch(r).then(function(e){return e.json()})}},{key:"syncRoom",value:function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"",n=JSON.parse(sessionStorage.getItem("matrix:access-token")||"false");if(!n)return Promise.reject("No access token found.");var r="".concat(this.clientUrl,"/rooms/").concat(e,"/messages?dir=b&room_id=").concat(e,"&access_token=").concat(n.access_token,"&from=").concat(t);return fetch(r).then(function(e){return e.json()})}},{key:"syncRoomHistory",value:function(e,t){var n=this,r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null;this.syncRoom(e,t).then(function(t){return t.chunk&&r&&t.chunk.forEach(r),t.chunk.length&&n.syncRoomHistory(e,t.end,r)})}},{key:"streamServerEvents",value:function(e,t,n){var r=this;n&&n.cancelled||(t?this.listenForRoomEvents(t,n,e.end):this.listenForServerEvents(),e.chunk&&e.chunk.forEach(function(e){var t=new MatrixEvent;e.event_id||(e.event_id="local:"+(1/Math.random()).toString(36)),t.consume(e),r.dispatchEvent(new CustomEvent("matrix-event",{detail:t})),r.dispatchEvent(new CustomEvent(t.type,{detail:t}))}))}},{key:"getCurrentUserId",value:function(){var e=sessionStorage.getItem("matrix:access-token")||"false",t=JSON.parse(e);return t?t.user_id:void 0}},{key:"createRoom",value:function(e,t,n){var r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{},o=JSON.stringify({name:e,topic:t,visibility:n,initial_state:r}),c=JSON.parse(sessionStorage.getItem("matrix:access-token")||"false");if(!c)return Promise.resolve();var a="".concat(this.clientUrl,"/createRoom?access_token=").concat(c.access_token);return fetch(a,{body:o,method:"POST"}).then(function(e){return e.json()})}},{key:"joinRoom",value:function(e){var t=JSON.parse(sessionStorage.getItem("matrix:access-token")||"false");return t?void fetch("".concat(this.clientUrl,"/rooms/").concat(e,"/join?access_token=").concat(t.access_token),{method:"POST"}).then(function(e){return e.json()}):Promise.reject("No access token found.")}},{key:"leaveRoom",value:function(e){var t=JSON.parse(sessionStorage.getItem("matrix:access-token")||"false");return t?void fetch("".concat(this.clientUrl,"/rooms/").concat(e,"/leave?access_token=").concat(t.access_token),{method:"POST"}).then(function(e){return e.json()}):Promise.reject("No access token found.")}},{key:"whoAmI",value:function(){var e=JSON.parse(sessionStorage.getItem("matrix:access-token")||"false");return e?fetch("".concat(this.clientUrl,"/account/whoami?access_token=").concat(e.access_token)).then(function(e){return e.json()}):Promise.reject("No access token found.")}}]),t}();e.Matrix=l}),require.register("___globals___",function(e,t,n){}),require("___globals___"); | ||
| !function(){"use strict";var e="undefined"==typeof global?self:global;if("function"!=typeof e.require){var t={},r={},n={},o={}.hasOwnProperty,i=/^\.\.?(\/|$)/,a=function(e,t){for(var r,n=[],o=(i.test(t)?e+"/"+t:t).split("/"),a=0,u=o.length;a<u;a++)".."===(r=o[a])?n.pop():"."!==r&&""!==r&&n.push(r);return n.join("/")},u=function(e){return e.split("/").slice(0,-1).join("/")},f=function(t,n){var o,i={id:t,exports:{},hot:y&&y.createHot(t)};return r[t]=i,n(i.exports,(o=t,function(t){var r=a(u(o),t);return e.require(r,o)}),i),i.exports},c=function(e){var t=n[e];return t&&e!==t?c(t):e},l=function(e,n){null==n&&(n="/");var i=c(e);if(o.call(r,i))return r[i].exports;if(o.call(t,i))return f(i,t[i]);throw new Error("Cannot find module '"+e+"' from '"+n+"'")};l.alias=function(e,t){n[t]=e};var s=/\.[^.\/]+$/,b=/\/index(\.[^\/]+)?$/;l.register=l.define=function(e,i){if(e&&"object"==typeof e)for(var a in e)o.call(e,a)&&l.register(a,e[a]);else t[e]=i,delete r[e],function(e){if(s.test(e)){var t=e.replace(s,"");o.call(n,t)&&n[t].replace(s,"")!==t+"/index"||(n[t]=e)}if(b.test(e)){var r=e.replace(b,"");o.call(n,r)||(n[r]=e)}}(e)},l.list=function(){var e=[];for(var r in t)o.call(t,r)&&e.push(r);return e};var y=e._hmr&&new e._hmr(function(e,t){return c(a(u(e),t))},l,t,r);l._cache=r,l.hmr=y&&y.wrap,l.brunch=!0,e.require=l}}(),function(){"undefined"==typeof window||window;var e=function(e,t,r){var n={},o=function(t,r){try{return e(r+"/node_modules/"+t)}catch(e){if(-1===e.toString().indexOf("Cannot find module"))throw e;if(-1!==r.indexOf("node_modules")){var i=r.split("/"),a=i.lastIndexOf("node_modules"),u=i.slice(0,a).join("/");return o(t,u)}}return n};return function(i){if(i in t&&(i=t[i]),i){if("."!==i[0]&&r){var a=o(i,r);if(a!==n)return a}return e(i)}}};require.register("curvature/base/Bindable.js",function(t,r,n){r=e(r,{},"curvature"),function(){"use strict";function e(t,n,o){return(e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}()?Reflect.construct:function(e,t,n){var o=[null];o.push.apply(o,t);var i=new(Function.bind.apply(e,o));return n&&r(i,n.prototype),i}).apply(null,arguments)}function r(e,t){return(r=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function n(e){return function(e){if(Array.isArray(e))return a(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||i(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=i(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,u=!0,f=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return u=e.done,e},e:function(e){f=!0,a=e},f:function(){try{u||null==r.return||r.return()}finally{if(f)throw a}}}}function i(e,t){if(e){if("string"==typeof e)return a(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?a(e,t):void 0}}function a(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function u(e){return(u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function f(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function c(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}Object.defineProperty(t,"__esModule",{value:!0}),t.Bindable=void 0;var l=Symbol("ref"),s=Symbol("original"),b=Symbol("deck"),y=Symbol("binding"),p=Symbol("subBinding"),v=Symbol("bindingAll"),d=Symbol("isBindable"),m=Symbol("wrapping"),h=Symbol("Names"),_=Symbol("executing"),g=Symbol("stack"),w=(Symbol("object"),Symbol("wrapped")),O=Symbol("unwrapped"),j=Symbol("getProto"),P=Symbol("onGet"),S=Symbol("onAllGet"),k=Symbol("bindChain"),A=Symbol("Descriptors"),x=Symbol("NoGetters"),M=Object.getPrototypeOf(Int8Array),E=Set.prototype[Symbol.iterator],C=Map.prototype[Symbol.iterator],B=globalThis,T=[B.Node,B.File,B.Map,B.Set,B.WeakMap,B.WeakSet,B.ArrayBuffer,B.ResizeObserver,B.MutationObserver,B.PerformanceObserver,B.IntersectionObserver].filter(function(e){return"function"==typeof e}),I=function(){function t(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t)}var r,i;return r=t,i=[{key:"isBindable",value:function(e){return!(!e||!e[d])&&e[d]===t}},{key:"onDeck",value:function(e,t){return e[b][t]||!1}},{key:"ref",value:function(e){return e[l]||e||!1}},{key:"makeBindable",value:function(e){return this.make(e)}},{key:"shuck",value:function(e,r){r=r||new Map;var n={};if(e instanceof M||e instanceof ArrayBuffer){var o=e.slice(0);return r.set(e,o),o}var i=Object.keys(e);for(var a in i){var f=i[a];if("___"!==f.substring(0,3)){var c=r.get(e[f]);if(c)n[f]=c;else if(e[f]!==e){if(e[f]&&"object"===u(e[f])){var l=e[f];t.isBindable(e[f])&&(l=e[f][s]),n[f]=this.shuck(l,r)}else n[f]=e[f];r.set(e[f],n[f])}else r.set(e[f],n),n[f]=n}}return t.isBindable(e)&&(delete n.bindTo,delete n.isBound),n}},{key:"make",value:function(r){var i=this;if(!r||!["function","object"].includes(u(r)))return r;if(T.filter(function(e){return r instanceof e}).length||Object.isSealed(r)||!Object.isExtensible(r))return r;if(r[l])return r[l];if(r[y])return r;Object.defineProperty(r,l,{configurable:!0,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(r,s,{configurable:!1,enumerable:!1,writable:!1,value:r}),Object.defineProperty(r,b,{configurable:!1,enumerable:!1,writable:!1,value:{}}),Object.defineProperty(r,y,{configurable:!1,enumerable:!1,writable:!1,value:{}}),Object.defineProperty(r,p,{configurable:!1,enumerable:!1,writable:!1,value:new Map}),Object.defineProperty(r,v,{configurable:!1,enumerable:!1,writable:!1,value:[]}),Object.defineProperty(r,d,{configurable:!1,enumerable:!1,writable:!1,value:t}),Object.defineProperty(r,_,{enumerable:!1,writable:!0}),Object.defineProperty(r,m,{enumerable:!1,writable:!0}),Object.defineProperty(r,g,{configurable:!1,enumerable:!1,writable:!1,value:[]}),Object.defineProperty(r,"___before___",{configurable:!1,enumerable:!1,writable:!1,value:[]}),Object.defineProperty(r,"___after___",{configurable:!1,enumerable:!1,writable:!1,value:[]}),Object.defineProperty(r,w,{configurable:!1,enumerable:!1,writable:!1,value:new Map}),Object.defineProperty(r,O,{configurable:!1,enumerable:!1,writable:!1,value:{}}),Object.defineProperty(r,A,{configurable:!1,enumerable:!1,writable:!1,value:new Map}),Object.defineProperty(r,"bindTo",{configurable:!1,enumerable:!1,writable:!1,value:function e(n){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},f=!1;if(Array.isArray(n)){var c=n.forEach(function(t){return e(t,o,a)});return function(){return c.forEach(function(e){return e()})}}if(n instanceof Function&&(a=o||{},o=n,f=!0),a.delay>=0&&(o=i.wrapDelayCallback(o,a.delay)),a.throttle>=0&&(o=i.wrapThrottleCallback(o,a.throttle)),a.wait>=0&&(o=i.wrapWaitCallback(o,a.wait)),a.frame&&(o=i.wrapFrameCallback(o,a.frame)),a.idle&&(o=i.wrapIdleCallback(o)),f){var l=r[v].length;if(r[v].push(o),!("now"in a)||a.now)for(var s in r)o(r[s],s,r,!1);return function(){delete r[v][l]}}if(r[y][n]||(r[y][n]=new Set),a.children){var b=o;o=function(){for(var e=arguments.length,n=new Array(e),o=0;o<e;o++)n[o]=arguments[o];var i=n[0],f=r[p].get(b);if(f&&(r[p].delete(b),f()),"object"===u(i)){var c=t.make(i);t.isBindable(c)&&r[p].set(b,c.bindTo(function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return b.apply(void 0,n.concat(t))},Object.assign({},a,{children:!1}))),b.apply(void 0,n)}else b.apply(void 0,n)}}r[y][n].add(o),"now"in a&&!a.now||o(r[n],n,r,!1);var d=function(){var e=r[p].get(o);e&&(r[p].delete(o),e()),r[y][n]&&r[y][n].has(o)&&r[y][n].delete(o)};return a.removeWith&&a.removeWith instanceof View&&a.removeWith.onRemove(function(){return d}),d}}),Object.defineProperty(r,k,{configurable:!1,enumerable:!1,writable:!1,value:function(e,t){var n=e.split("."),o=n.shift(),a=n.slice(0),u=[];return u.push(r.bindTo(o,function(e,r,n,o){var f=a.join(".");0!==a.length?(void 0===e&&(e=n[r]=i.makeBindable({})),u=u.concat(e[k](f,t))):t(e,r,n,o)})),function(){return u.forEach(function(e){return e()})}}}),Object.defineProperty(r,"___before",{configurable:!1,enumerable:!1,writable:!1,value:function(e){var t=r.___before___.length;r.___before___.push(e);var n=!1;return function(){n||(n=!0,delete r.___before___[t])}}}),Object.defineProperty(r,"___after",{configurable:!1,enumerable:!1,writable:!1,value:function(e){var t=r.___after___.length;r.___after___.push(e);var n=!1;return function(){n||(n=!0,delete r.___after___[t])}}}),Object.defineProperty(r,"isBound",{configurable:!1,enumerable:!1,writable:!1,value:function(){for(var e in r[v])if(r[v][e])return!0;for(var t in r[y])for(var n in r[y][t])if(r[y][t][n])return!0;return!1}});var a=function(e){r[e]&&r[e]instanceof Object&&!r[e]instanceof Promise&&(T.filter(function(t){return r[e]instanceof t}).length||!Object.isExtensible(r[e])||Object.isSealed(r[e])||(r[e]=t.make(r[e])))};for(var f in r)a(f);var c=r[A],B=r[w],I=r[g],R={get:function(n,i){if(B.has(i))return B.get(i);if(i===l||i===s||"apply"===i||"isBound"===i||"bindTo"===i||"__proto__"===i||"constructor"===i)return r[i];var a;if(c.has(i)?a=c.get(i):(a=Object.getOwnPropertyDescriptor(r,i),c.set(i,a)),a&&!a.configurable&&!a.writable)return r[i];if(S in r)return r[S](i);if(P in r&&!(i in r))return r[P](i);if(a&&!a.configurable&&!a.writable)return B.set(i,r[i]),r[i];if("function"==typeof r[i]){if(h in r[i])return r[i];Object.defineProperty(r[O],i,{configurable:!1,enumerable:!1,writable:!1,value:r[i]});var u=Object.getPrototypeOf(r)[i]===r[i],f="function"==typeof Promise&&r instanceof Promise||"function"==typeof Map&&r instanceof Map||"function"==typeof Set&&r instanceof Set||"function"==typeof C&&r.prototype===C||"function"==typeof E&&r.prototype===E||"function"==typeof E&&r.prototype===E||"function"==typeof WeakMap&&r instanceof WeakMap||"function"==typeof WeakSet&&r instanceof WeakSet||"function"==typeof Date&&r instanceof Date||"function"==typeof M&&r instanceof M||"function"==typeof ArrayBuffer&&r instanceof ArrayBuffer||"function"==typeof EventTarget&&r instanceof EventTarget||"function"==typeof ResizeObserver&&r instanceof ResizeObserver||"function"==typeof MutationObserver&&r instanceof MutationObserver||"function"==typeof PerformanceObserver&&r instanceof PerformanceObserver||"function"==typeof IntersectionObserver&&r instanceof IntersectionObserver||"function"==typeof r[Symbol.iterator]&&"next"===i?r:r[l],b=function(){r[_]=i,I.unshift(i);for(var t=arguments.length,n=new Array(t),a=0;a<t;a++)n[a]=arguments[a];var c,l,s=o(r.___before___);try{for(s.s();!(c=s.n()).done;){(0,c.value)(r,i,I,r,n)}}catch(e){s.e(e)}finally{s.f()}if(new.target)l=e(r[O][i],n);else{var b=r[O][i];l=u?b.apply(f||r,n):b.apply(void 0,n)}var y,p=o(r.___after___);try{for(p.s();!(y=p.n()).done;){(0,y.value)(r,i,I,r,n)}}catch(e){p.e(e)}finally{p.f()}return r[_]=null,I.shift(),l};(b[h]=b[h]||new WeakMap).set(r,i),b[S]=function(e){var t=b[h].get(r);return r[t][e]};var y=t.make(b);return B.set(i,y),y}return r[i]},set:function(e,n,i){if(n===s)return!0;if(void 0!==r[b][n]&&r[b][n]===i)return!0;if("string"==typeof n&&"___"===n.substring(0,3)&&"___"===n.slice(-3))return!0;if(e[n]===i)return!0;for(var a in i&&i instanceof Object&&(T.filter(function(e){return r instanceof e}).length||!Object.isExtensible(r)||Object.isSealed(r)||(r[x],i=t.makeBindable(i))),r[b][n]=i,r[v])r[v][a]&&r[v][a](i,n,e,!1);var u=!1;if(n in r[y]){var f,c=o(r[y][n]);try{for(c.s();!(f=c.n()).done;)!1===(0,f.value)(i,n,e,!1,e[n])&&(u=!0)}catch(e){c.e(e)}finally{c.f()}}if(delete r[b][n],!u){var l=Object.getOwnPropertyDescriptor(e,n);e instanceof File&&"lastModifiedDate"==n||l&&!l.writable||e[n]!==i||(e[n]=i)}var p=Reflect.set(e,n,i);if(Array.isArray(e)&&r[y].length)for(var d in r[y].length)(0,r[y].length[d])(e.length,"length",e,!1,e.length);return p},construct:function(o,i){var a="constructor";for(var u in o.___before___)o.___before___[u](o,a,r[g],void 0,i);var f=t.make(e(o[s],n(i)));for(var c in o.___after___)o.___after___[c](o,a,r[g],f,i);return f},getPrototypeOf:function(e){return j in r?r[j]:Reflect.getPrototypeOf(e)},deleteProperty:function(e,t){if(!(t in e))return!0;if(c.has(t)){var n=c.get(t);if(n&&!n.configurable)return!1;c.delete(t)}for(var o in r[v])r[v][o](void 0,t,e,!0,e[t]);if(t in r[y])for(var i in r[y][t])r[y][t][i]&&r[y][t][i](void 0,t,e,!0,e[t]);return delete e[t],!0}};return r[x]&&delete R.get,Object.defineProperty(r,l,{configurable:!1,enumerable:!1,writable:!1,value:new Proxy(r,R)}),r[l]}},{key:"clearBindings",value:function(e){var t;(t=function(e){return Object.keys(e).map(function(t){return delete e[t]})},function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];return r.map(t)})(e[w],e[y],e[v],e.___after___,e.___before___)}},{key:"resolve",value:function(e,t){for(var r,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=t.split("."),i=o[0];o.length;){if(n&&1===o.length)return[this.make(e),o.shift(),i];!(!(r=o.shift())in e)&&e[r]&&e[r]instanceof Object||(e[r]={}),e=this.make(e[r])}return[this.make(e),r,i]}},{key:"wrapDelayCallback",value:function(e,t){return function(){for(var r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];return setTimeout(function(){return e.apply(void 0,n)},t)}}},{key:"wrapThrottleCallback",value:function(e,t){var r=this;return this.throttles.set(e,!1),function(){r.throttles.get(e,!0)||(e.apply(void 0,arguments),r.throttles.set(e,!0),setTimeout(function(){r.throttles.set(e,!1)},t))}}},{key:"wrapWaitCallback",value:function(e,t){var r=this;return function(){for(var n=arguments.length,o=new Array(n),i=0;i<n;i++)o[i]=arguments[i];var a;(a=r.waiters.get(e))&&(r.waiters.delete(e),clearTimeout(a)),a=setTimeout(function(){return e.apply(void 0,o)},t),r.waiters.set(e,a)}}},{key:"wrapFrameCallback",value:function(e,t){return function(){for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];requestAnimationFrame(function(){return e.apply(void 0,r)})}}},{key:"wrapIdleCallback",value:function(e){return function(){for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];(window.requestIdleCallback||requestAnimationFrame)(function(){return e.apply(void 0,r)})}}}],null&&f(r.prototype,null),i&&f(r,i),t}();t.Bindable=I,c(I,"waiters",new WeakMap),c(I,"throttles",new WeakMap),Object.defineProperty(I,"OnGet",{configurable:!1,enumerable:!1,writable:!1,value:P}),Object.defineProperty(I,"NoGetters",{configurable:!1,enumerable:!1,writable:!1,value:x}),Object.defineProperty(I,"GetProto",{configurable:!1,enumerable:!1,writable:!1,value:j}),Object.defineProperty(I,"OnAllGet",{configurable:!1,enumerable:!1,writable:!1,value:S})}()}),require.register("curvature/base/Mixin.js",function(t,r,n){r=e(r,{},"curvature"),function(){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Mixin=void 0;var e=r("./Bindable");function n(e){return function(e){if(Array.isArray(e))return u(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||a(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(e){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function i(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=a(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,u=!0,f=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return u=e.done,e},e:function(e){f=!0,i=e},f:function(){try{u||null==r.return||r.return()}finally{if(f)throw i}}}}function a(e,t){if(e){if("string"==typeof e)return u(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?u(e,t):void 0}}function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function f(e,t){return(f=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function c(e,t){if(t&&("object"===o(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return l(e)}function l(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function s(e){return(s=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function b(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function y(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var p=Symbol("constructor"),v=(Symbol("mixinList"),function(){function t(){b(this,t)}return function(e,t,r){r&&y(e,r)}(t,0,[{key:"from",value:function(e){for(var r=arguments.length,n=new Array(r>1?r-1:0),a=1;a<r;a++)n[a-1]=arguments[a];return function(r){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&f(e,t)}(u,e);var a=function(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}();return function(){var r,n=s(e);if(t){var o=s(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return c(this,r)}}(u);function u(){var r;b(this,u);for(var f=arguments.length,s=new Array(f),y=0;y<f;y++)s[y]=arguments[y];var p,v=e.constructor?r=a.call.apply(a,[this].concat(s)):void 0,d=i(n);try{for(d.s();!(p=d.n()).done;){var m=p.value;m[t.Constructor]&&m[t.Constructor].apply(l(r)),"object"===o(m)&&t.mixObject(m,l(r))}}catch(e){d.e(e)}finally{d.f()}return c(r,v)}return u}()}},{key:"to",value:function(e){for(var t={},r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];n.map(function(r){switch(o(r)){case"object":Object.assign(t,Object.getOwnPropertyDescriptors(r));break;case"function":Object.assign(t,Object.getOwnPropertyDescriptors(r.prototype))}delete t.constructor,Object.defineProperties(e.prototype,t)})}},{key:"with",value:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return this.from.apply(this,[function e(){b(this,e)}].concat(t))}},{key:"mixObject",value:function(e,t){var r,n=i(Object.getOwnPropertyNames(e));try{for(n.s();!(r=n.n()).done;){var o=r.value;"function"!=typeof e[o]?t[o]=e[o]:t[o]=e[o].bind(t)}}catch(e){n.e(e)}finally{n.f()}var a,u=i(Object.getOwnPropertySymbols(e));try{for(u.s();!(a=u.n()).done;){var f=a.value;"function"!=typeof e[f]?t[f]=e[f]:t[f]=e[f].bind(t)}}catch(e){u.e(e)}finally{u.f()}}},{key:"mixClass",value:function(e,t){var r,n=i(Object.getOwnPropertyNames(e.prototype));try{for(n.s();!(r=n.n()).done;){var o=r.value;t.prototype[o]=e.prototype[o].bind(t.prototype)}}catch(e){n.e(e)}finally{n.f()}var a,u=i(Object.getOwnPropertySymbols(e.prototype));try{for(u.s();!(a=u.n()).done;){var f=a.value;t.prototype[f]=e.prototype[f].bind(t.prototype)}}catch(e){u.e(e)}finally{u.f()}var c,l=i(Object.getOwnPropertyNames(e));try{var s=function(){var r=c.value;if("function"!=typeof e[r])return"continue";var n=t[r]||!1,o=e[r].bind(t);t[r]=function(){return n&&n.apply(void 0,arguments),o.apply(void 0,arguments)}};for(l.s();!(c=l.n()).done;)s()}catch(e){l.e(e)}finally{l.f()}var b,y=i(Object.getOwnPropertySymbols(e));try{var p=function(){var r=b.value;if("function"!=typeof e[r])return"continue";var n=t[r]||!1,o=e[r].bind(t);t[r]=function(){return n&&n.apply(void 0,arguments),o.apply(void 0,arguments)}};for(y.s();!(b=y.n()).done;)p()}catch(e){y.e(e)}finally{y.f()}}},{key:"mix",value:function(t){for(var r={},o={},a=e.Bindable.makeBindable(t),u=function(e){var t,u=Object.getOwnPropertyNames(e.prototype),f=/^(before|after)__(.+)/,c=i(Object.getOwnPropertyNames(e));try{var l=function(){var o=t.value,i=o.match(f);if(i){switch(i[1]){case"before":a.___before(function(t,r,a,u,f){if(r===i[2])return e[o].bind(u).apply(void 0,n(f))});break;case"after":a.___after(function(t,r,a,u,f){if(r===i[2])return e[o].bind(u).apply(void 0,n(f))})}return"continue"}return r[o]||"function"!=typeof e[o]?"continue":void(r[o]=e[o])};for(c.s();!(t=c.n()).done;)l()}catch(e){c.e(e)}finally{c.f()}var s,b=i(u);try{var y=function(){var t=s.value,r=t.match(f);if(r){switch(r[1]){case"before":a.___before(function(o,i,a,u,f){if(i===r[2])return e.prototype[t].bind(u).apply(void 0,n(f))});break;case"after":a.___after(function(o,i,a,u,f){if(i===r[2])return e.prototype[t].bind(u).apply(void 0,n(f))})}return"continue"}return o[t]||"function"!=typeof e.prototype[t]?"continue":void(o[t]=e.prototype[t])};for(b.s();!(s=b.n()).done;)y()}catch(e){b.e(e)}finally{b.f()}},f=this;f&&f.prototype;f=Object.getPrototypeOf(f))u(f);for(var c in r)t[c]=r[c].bind(t);var l=function(e){t.prototype[e]=function(){for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];return o[e].apply(this,r)}};for(var s in o)l(s);return a}}]),t}());t.Mixin=v,v.Constructor=p}()}),require.register("curvature/mixin/EventTargetMixin.js",function(t,r,n){r=e(r,{},"curvature"),function(){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EventTargetMixin=void 0;var e,n=r("../base/Mixin");function o(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var i=Symbol("Target"),a=(o(e={},n.Mixin.Constructor,function(){try{this[i]=new EventTarget}catch(e){this[i]=document.createDocumentFragment()}}),o(e,"dispatchEvent",function(){for(var e,t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];var o=r[0];"string"==typeof o&&(o=new CustomEvent(o),r[0]=o),(e=this[i]).dispatchEvent.apply(e,r);var a="on".concat(o.type[0].toUpperCase()+o.type.slice(1));return"function"==typeof this[a]&&this[a](o),o.returnValue}),o(e,"addEventListener",function(){var e;(e=this[i]).addEventListener.apply(e,arguments)}),o(e,"removeEventListener",function(){var e;(e=this[i]).removeEventListener.apply(e,arguments)}),e);t.EventTargetMixin=a}()}),require.register("build/Config.js",function(e,t,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Config=void 0,e.Config={title:"matrix-api 0.0.0-d"}}),require.register("___globals___",function(e,t,r){})}(),require("___globals___"); | ||
+16
-6
| { | ||
| "name": "matrix-api", | ||
| "description": "Basic Matrix API lib", | ||
| "description": "Matrix API library for the frontend.", | ||
| "license": "Apache-2.0", | ||
| "main":"Matrix.js", | ||
| "author": "Sean Morris", | ||
| "version": "0.0.0-c", | ||
| "version": "0.0.0-d", | ||
| "repository": "https://github.com/seanmorris/matrix-api", | ||
@@ -17,10 +16,21 @@ "scripts": { | ||
| "@babel/plugin-proposal-class-properties": "^7.13.0", | ||
| "@babel/preset-env": "^7.13.12" | ||
| "@babel/preset-env": "^7.13.12", | ||
| "auto-reload-brunch": "^2", | ||
| "babel-brunch": "^7.0.1", | ||
| "babel-minify": "^0.5.1", | ||
| "brunch": "^3", | ||
| "clean-css-brunch": "^3", | ||
| "raw-brunch": "^1.0.2", | ||
| "terser-brunch": "^4", | ||
| "uglify-es-brunch": "^1" | ||
| }, | ||
| "dependencies": { | ||
| "curvature": "^0.0.66-n" | ||
| "curvature": "^0.0.66-p" | ||
| }, | ||
| "files": [ | ||
| "Matrix.js" | ||
| "Matrix.js", | ||
| "dist/matrix-api.js", | ||
| "dist/matrix-api.min.js", | ||
| "dist/matrix-api.standalone.js" | ||
| ] | ||
| } |
+96
-1
@@ -1,1 +0,96 @@ | ||
| Curvature Matrix API | ||
| # Matrix API | ||
| Matrix API. 100% frontend. | ||
| https://curvature.seanmorr.is/matrix-api | ||
| ## Install: | ||
| ```html | ||
| <script src = "https://unpkg.com/curvature@0.0.66-q/dist/curvature.js"></script> | ||
| <script src = "https://unpkg.com/matrix-api@0.0.0-d/dist/matrix-api.js"></script> | ||
| ``` | ||
| ```html | ||
| <script src = "https://unpkg.com/matrix-api@0.0.0-d/dist/matrix-api.standalone.js"></script> | ||
| ``` | ||
| ## Usage: | ||
| ### Step 1: | ||
| Set up a page that can serve as your redirect target. | ||
| This page will post a message back to its opener when the login flow completes, and then it will close. | ||
| ```javascript | ||
| // Under /accept-sso | ||
| const baseUrl = 'https://matrix.org/_matrix'; | ||
| const matrix = new Matrix(baseUrl); | ||
| const loginToken = '...'; // Get the loginToken from the query string. | ||
| matrix.completeSso(loginToken); | ||
| ``` | ||
| ### Step 2: | ||
| In your main application, initialize a Matrix object with the same baseUrl. Log in and listen for events: | ||
| ```javascript | ||
| // In your main application | ||
| // Connect to your Matrix endpoint: | ||
| const baseUrl = 'https://matrix.org/_matrix'; | ||
| const matrix = new Matrix(baseUrl); | ||
| // Open the login popup, targetting the url from the first step: | ||
| const redirectUrl = location.origin + '/accept-sso'; | ||
| matrix.initSso(redirectUrl); | ||
| // ... and wait or the user to log in: | ||
| matrix.addEventListener('logged-in', event => console.log('Logged in!', event)); | ||
| // Listen for events of only one type: | ||
| matrix.addEventListener('m.room.message', event => console.log('Message:', event)); | ||
| // Listen for ALL events from the server: | ||
| matrix.addEventListener('matrix-event', event => console.log('Event:', event)); | ||
| ``` | ||
| ### Step 3: | ||
| Join a room: | ||
| ```javascript | ||
| // Send a message: | ||
| const roomId = 'ROOM_ID_HERE'; | ||
| // You'll receive a promise that will complete | ||
| // when the server responds: | ||
| matrix.joinRoom(roomId) | ||
| .then(response => console.log(response)) | ||
| .catch(error => console.error(error)); | ||
| ``` | ||
| ### Step 4: | ||
| Send messages to a room: | ||
| ```javascript | ||
| // Send a message: | ||
| const roomId = 'ROOM_ID_HERE'; | ||
| const msgtype = 'm.text'; | ||
| const body = 'message body...'; | ||
| const message = {msgtype, body}; | ||
| // You'll receive a promise that will complete | ||
| // when the server responds: | ||
| matrix.putEvent(roomId, 'm.room.message', message) | ||
| .then(response => console.log(response)) | ||
| .catch(error => console.error(error)); | ||
| ``` |
Sorry, the diff of this file is too big to display
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
82525
5.76%7
40%97
9600%12
200%645
-65.58%4
100%5
150%55
243.75%Updated