diff --git a/dist/build.js b/dist/build.js index 05cc629..1874e9e 100644 --- a/dist/build.js +++ b/dist/build.js @@ -1,2 +1,2 @@ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("ChatMessages",[],e):"object"==typeof exports?exports.ChatMessages=e():t.ChatMessages=e()}(this,(function(){return(()=>{"use strict";var t={d:(e,n)=>{for(var r in n)t.o(n,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:n[r]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},e={};function n(t){return function(t){if(Array.isArray(t))return r(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return r(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(t,e):void 0}}(t)||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 r(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);no});const o={name:"chat-messages",builder:function(t,e){var r={type:"object",properties:{"@context":{type:"string",default:"https://kosmos.org/ns/v2",enum:["https://kosmos.org/ns/v2"]},"@id":{type:"string",required:!0},"@type":{type:"string",default:"ChatChannel",enum:["ChatChannel"]},service:{type:"object",properties:{domain:{type:"string",required:!0},protocol:{type:"string",required:!0}}},name:{type:"string",required:!0},type:{type:"string",required:!0,enum:["room","person"]},today:{type:"object",properties:{"@id":{type:"string",pattern:"^[0-9]{4}/[0-9]{2}/[0-9]{2}$",required:!0},"@type":{type:"string",default:"ChatLog",pattern:"^ChatLog$"},messageType:{type:"string",default:"InstantMessage",pattern:"^InstantMessage$"},previous:{type:"string",pattern:"^[0-9]{4}/[0-9]{2}/[0-9]{2}$"},next:{type:"string",pattern:"^[0-9]{4}/[0-9]{2}/[0-9]{2}$"},messages:{type:"array",required:!0,items:{type:"object",properties:{date:{type:"string",format:"date-time"},user:{type:"string"},text:{type:"string"},type:"string",default:"text",enum:["text","join","leave","action"]}}}}}},required:[]};return t.declareType("daily-archive","https://kosmos.org/ns/v2",r),e.declareType("daily-archive","https://kosmos.org/ns/v2",r),{exports:{DailyArchive:function(){function r(n){if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,r),n.isPublic=n.isPublic||!1,n.channelType=n.channelType||"room","object"!==a(n))throw"options must be an object";if("object"!==a(n.service)||"string"!=typeof n.service.protocol||"string"!=typeof n.service.domain)throw'service must be an object containing at least service "protocol" and "domain"';if("string"!=typeof n.channelName)throw"channelName must be a string";if(!(n.date instanceof Date))throw"date must be a date object";if("boolean"!=typeof n.isPublic)throw"isPublic must be a boolean value";var i;if(this.service=n.service,this.channelName=n.channelName,this.channelType=n.channelType,this.date=n.date,this.isPublic=n.isPublic||!1,this.parsedDate={year:(i=this.date).getUTCFullYear(),month:s(i.getUTCMonth()+1),day:s(i.getUTCDate())},this.dateId=this.parsedDate.year+"/"+this.parsedDate.month+"/"+this.parsedDate.day,"room"===this.channelType){var o=this.channelName.replace(/#/,"");this.path="".concat(this.service.domain,"/channels/").concat(o,"/").concat(this.dateId)}else this.path="".concat(this.service.domain,"/users/").concat(this.channelName,"/").concat(this.dateId);this.client=this.isPublic?e:t,this.previous=n.previous,this.next=n.next}var o,c;return o=r,(c=[{key:"addMessage",value:function(t){var e=this;return this.isPublic&&!this.channelName.match(/^#/)?Promise.resolve(!1):(t.type=t.type||"text",this.client.getObject(this.path).then((function(n){return"object"===a(n)?e._updateDocument(n,t):e._createDocument(t)})))}},{key:"addMessages",value:function(t,e){var n=this;return this.isPublic&&!this.channelName.match(/^#/)?Promise.resolve(!1):(e=e||!1,t.forEach((function(t){t.type=t.type||"text"})),e?this._createDocument(t):this.client.getObject(this.path).then((function(e){return"object"===a(e)?n._updateDocument(e,t):n._createDocument(t)})))}},{key:"remove",value:function(){return this.client.remove(this.path)}},{key:"_updateDocument",value:function(t,e){return console.debug("[chat-messages] Updating archive document"),Array.isArray(e)?e.forEach((function(e){t.today.messages.push(e)})):t.today.messages.push(e),this._sync(t)}},{key:"_createDocument",value:function(t){var e=this;console.debug("[chat-messages] Creating new archive document");var n=this._buildArchiveObject();return Array.isArray(t)?t.forEach((function(t){n.today.messages.push(t)})):n.today.messages.push(t),this.previous||this.next?(this.previous&&(n.today.previous=this.previous),this.next&&(n.today.next=this.next),this._sync(n)):this._updatePreviousArchive().then((function(t){return"object"===a(t)&&(n.today.previous=t.today["@id"]),e._sync(n)}))}},{key:"_buildArchiveObject",value:function(){var t=this.channelName.replace(/#/,""),e={"@id":"chat-messages/"+this.service.domain+"/channels/"+t+"/","@type":"ChatChannel",service:this.service,name:this.channelName,type:this.channelType,today:{"@id":this.dateId,"@type":"ChatLog",messageType:"InstantMessage",messages:[]}};switch(this.service.protocol){case"IRC":this.channelName.match(/^#/)||(e["@id"]="chat-messages/"+this.service.domain+"/users/"+this.channelName+"/")}return e}},{key:"_updatePreviousArchive",value:function(){var t=this;return this._findPreviousArchive().then((function(e){if("object"===a(e)&&e.today){e.today.next=t.dateId;var n=t.path.substring(0,t.path.length-t.dateId.length)+e.today["@id"];return t.client.storeObject("daily-archive",n,e).then((function(){return console.debug("[chat-messages] Previous archive written to remote storage",n,e),e}))}return console.debug("[chat-messages] Previous archive not found"),!1}))}},{key:"_findPreviousArchive",value:function(){var t=this,e=this.path.substring(0,this.path.length-2),r=this.path.substring(0,this.path.length-5),a=this.path.substring(0,this.path.length-10);return this.client.getListing(e).then((function(i){var o=Object.keys(i).map((function(t){return parseInt(t)})).map((function(e){return e0){var c=s(Math.max.apply(Math,n(o)).toString());return t.client.getObject(e+c)}return t.client.getListing(r).then((function(e){var i=Object.keys(e).map((function(t){return parseInt(t.substr(0,2))})).map((function(e){return e0){var o=s(Math.max.apply(Math,n(i)).toString());return t.client.getListing(r+o+"/").then((function(e){var a=Object.keys(e).map((function(t){return parseInt(t)})),i=s(Math.max.apply(Math,n(a)).toString());return t.client.getObject(r+o+"/"+i)}))}return t.client.getListing(a).then((function(e){var r=Object.keys(e).map((function(t){return parseInt(t.substr(0,4))})).map((function(e){return e0){var i=Math.max.apply(Math,n(r)).toString();return t.client.getListing(a+i+"/").then((function(e){var r=Object.keys(e).map((function(t){return parseInt(t.substr(0,2))})),o=s(Math.max.apply(Math,n(r)).toString());return t.client.getListing(a+i+"/"+o+"/").then((function(e){var r=Object.keys(e).map((function(t){return parseInt(t)})),c=s(Math.max.apply(Math,n(r)).toString());return t.client.getObject(a+i+"/"+o+"/"+c)}))}))}return!1}))}))}))}},{key:"_sync",value:function(t){return console.debug("[chat-messages] Writing archive object with ".concat(t.today.messages.length," messages")),this.client.storeObject("daily-archive",this.path,t).then((function(){return console.debug("[chat-messages] Archive written to remote storage"),!0}),(function(t){return console.warn("[chat-messages] Error trying to store object",t),t}))}}])&&i(o.prototype,c),r}(),privateClient:t,publicClient:e}}}};return e.default})()})); +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("ChatMessages",[],e):"object"==typeof exports?exports.ChatMessages=e():t.ChatMessages=e()}(this,(function(){return(()=>{var t={666:t=>{var e=function(t){"use strict";var e,r=Object.prototype,n=r.hasOwnProperty,a="function"==typeof Symbol?Symbol:{},i=a.iterator||"@@iterator",o=a.asyncIterator||"@@asyncIterator",s=a.toStringTag||"@@toStringTag";function c(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,r){return t[e]=r}}function u(t,e,r,n){var a=e&&e.prototype instanceof d?e:d,i=Object.create(a.prototype),o=new M(n||[]);return i._invoke=function(t,e,r){var n=l;return function(a,i){if(n===f)throw new Error("Generator is already running");if(n===y){if("throw"===a)throw i;return E()}for(r.method=a,r.arg=i;;){var o=r.delegate;if(o){var s=P(o,r);if(s){if(s===m)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(n===l)throw n=y,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n=f;var c=h(t,e,r);if("normal"===c.type){if(n=r.done?y:p,c.arg===m)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n=y,r.method="throw",r.arg=c.arg)}}}(t,r,o),i}function h(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var l="suspendedStart",p="suspendedYield",f="executing",y="completed",m={};function d(){}function g(){}function v(){}var b={};c(b,i,(function(){return this}));var w=Object.getPrototypeOf,x=w&&w(w(C([])));x&&x!==r&&n.call(x,i)&&(b=x);var j=v.prototype=d.prototype=Object.create(b);function k(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function L(t,e){function r(a,i,o,s){var c=h(t[a],t,i);if("throw"!==c.type){var u=c.arg,l=u.value;return l&&"object"==typeof l&&n.call(l,"__await")?e.resolve(l.__await).then((function(t){r("next",t,o,s)}),(function(t){r("throw",t,o,s)})):e.resolve(l).then((function(t){u.value=t,o(u)}),(function(t){return r("throw",t,o,s)}))}s(c.arg)}var a;this._invoke=function(t,n){function i(){return new e((function(e,a){r(t,n,e,a)}))}return a=a?a.then(i,i):i()}}function P(t,r){var n=t.iterator[r.method];if(n===e){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=e,P(t,r),"throw"===r.method))return m;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return m}var a=h(n,t.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,m;var i=a.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,m):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,m)}function _(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function O(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function M(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(_,this),this.reset(!0)}function C(t){if(t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var a=-1,o=function r(){for(;++a=0;--i){var o=this.tryEntries[i],s=o.completion;if("root"===o.tryLoc)return a("end");if(o.tryLoc<=this.prev){var c=n.call(o,"catchLoc"),u=n.call(o,"finallyLoc");if(c&&u){if(this.prev=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),O(r),m}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var a=n.arg;O(r)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:C(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),m}},t}(t.exports);try{regeneratorRuntime=e}catch(t){"object"==typeof globalThis?globalThis.regeneratorRuntime=e:Function("r","regeneratorRuntime = r")(e)}}},e={};function r(n){var a=e[n];if(void 0!==a)return a.exports;var i=e[n]={exports:{}};return t[n](i,i.exports,r),i.exports}r.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return r.d(e,{a:e}),e},r.d=(t,e)=>{for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var n={};return(()=>{"use strict";function t(t){return function(t){if(Array.isArray(t))return e(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,r){if(t){if("string"==typeof t)return e(t,r);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?e(t,r):void 0}}(t)||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 e(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);rh}),r(666);const h={name:"chat-messages",builder:function(e,r){var n={type:"object",properties:{"@context":{type:"string",default:"https://kosmos.org/ns/v2/chat-channel"},"@id":{type:"string",required:!0},"@type":{type:"string",default:"ChatChannel",enum:["ChatChannel"]},service:{type:"object",properties:{domain:{type:"string",required:!0},protocol:{type:"string",required:!0}}},name:{type:"string",required:!0},type:{type:"string",required:!0,enum:["room","person"]},today:{type:"object",properties:{"@id":{type:"string",pattern:"^[0-9]{4}/[0-9]{2}/[0-9]{2}$",required:!0},"@type":{type:"string",default:"ChatLog",pattern:"^ChatLog$"},messageType:{type:"string",default:"InstantMessage",pattern:"^InstantMessage$"},previous:{type:"string",pattern:"^[0-9]{4}/[0-9]{2}/[0-9]{2}$"},next:{type:"string",pattern:"^[0-9]{4}/[0-9]{2}/[0-9]{2}$"},messages:{type:"array",required:!0,items:{type:"object",properties:{date:{type:"string",format:"date-time"},user:{type:"string"},text:{type:"string"},type:"string",default:"text",enum:["text","join","leave","action"]}}}}}},required:[]};e.declareType("daily-archive","https://kosmos.org/ns/v2/chat-channel",n),r.declareType("daily-archive","https://kosmos.org/ns/v2/chat-channel",n);var a={type:"object",properties:{"@context":{type:"string",default:"https://kosmos.org/ns/v2/chat-channel-meta"},"@id":{type:"string"},"@type":{type:"string",default:"ChatChannelMeta",enum:["ChatChannelMeta"]},first:{type:"string",pattern:"^[0-9]{4}/[0-9]{2}/[0-9]{2}$"},last:{type:"string",pattern:"^[0-9]{4}/[0-9]{2}/[0-9]{2}$"}},required:["@id","first","last"]};return e.declareType("daily-archive-meta","https://kosmos.org/ns/v2/chat-channel-meta",a),r.declareType("daily-archive-meta","https://kosmos.org/ns/v2/chat-channel-meta",a),{exports:{DailyArchive:function(){function n(t){if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,n),t.isPublic=t.isPublic||!1,t.channelType=t.channelType||"room","object"!==o(t))throw"options must be an object";if("object"!==o(t.service)||"string"!=typeof t.service.protocol||"string"!=typeof t.service.domain)throw'service must be an object containing at least service "protocol" and "domain"';if("string"!=typeof t.channelName)throw"channelName must be a string";if(!(t.date instanceof Date))throw"date must be a date object";if("boolean"!=typeof t.isPublic)throw"isPublic must be a boolean value";var a;if(this.service=t.service,this.channelName=t.channelName,this.channelType=t.channelType,this.date=t.date,this.isPublic=t.isPublic||!1,this.parsedDate={year:(a=this.date).getUTCFullYear(),month:c(a.getUTCMonth()+1),day:c(a.getUTCDate())},this.dateId=this.parsedDate.year+"/"+this.parsedDate.month+"/"+this.parsedDate.day,"room"===this.channelType){var i=this.channelName.replace(/#/,"");this.channelPath="".concat(this.service.domain,"/channels/").concat(i)}else this.channelPath="".concat(this.service.domain,"/users/").concat(this.channelName);this.path="".concat(this.channelPath,"/").concat(this.dateId),this.metaPath="".concat(this.channelPath,"/meta"),this.client=this.isPublic?r:e,this.previous=t.previous,this.next=t.next}var a,h,l,p,f,y,m,d;return a=n,(h=[{key:"addMessage",value:function(t){var e=this;return this.isPublic&&!this.channelName.match(/^#/)?Promise.resolve(!1):(t.type=t.type||"text",this.client.getObject(this.path).then((function(r){return"object"===o(r)?e._updateDocument(r,t):e._createDocument(t)})))}},{key:"addMessages",value:function(t,e){var r=this;return this.isPublic&&!this.channelName.match(/^#/)?Promise.resolve(!1):(e=e||!1,t.forEach((function(t){t.type=t.type||"text"})),e?this._createDocument(t):this.client.getObject(this.path).then((function(e){return"object"===o(e)?r._updateDocument(e,t):r._createDocument(t)})))}},{key:"remove",value:function(){return this.client.remove(this.path)}},{key:"_updateDocument",value:(d=i(regeneratorRuntime.mark((function t(e,r){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return console.debug("[chat-messages] Updating archive document"),Array.isArray(r)?r.forEach((function(t){e.today.messages.push(t)})):e.today.messages.push(r),t.abrupt("return",this._sync(e));case 3:case"end":return t.stop()}}),t,this)}))),function(t,e){return d.apply(this,arguments)})},{key:"_createDocument",value:(m=i(regeneratorRuntime.mark((function t(e){var r,n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(console.debug("[chat-messages] Creating new archive document"),r=this._buildArchiveObject(),Array.isArray(e)?e.forEach((function(t){r.today.messages.push(t)})):r.today.messages.push(e),!this.previous&&!this.next){t.next=8;break}this.previous&&(r.today.previous=this.previous),this.next&&(r.today.next=this.next),t.next=12;break;case 8:return t.next=10,this._updatePreviousArchive();case 10:"object"===o(n=t.sent)&&(r.today.previous=n.today["@id"]);case 12:return t.next=14,this._sync(r);case 14:return t.next=16,this._updateArchiveMetaDocument();case 16:return t.abrupt("return");case 17:case"end":return t.stop()}}),t,this)}))),function(t){return m.apply(this,arguments)})},{key:"_buildArchiveObject",value:function(){var t=this.channelName.replace(/#/,""),e={"@id":"chat-messages/"+this.service.domain+"/channels/"+t+"/","@type":"ChatChannel",service:this.service,name:this.channelName,type:this.channelType,today:{"@id":this.dateId,"@type":"ChatLog",messageType:"InstantMessage",messages:[]}};switch(this.service.protocol){case"IRC":this.channelName.match(/^#/)||(e["@id"]="chat-messages/"+this.service.domain+"/users/"+this.channelName+"/")}return e}},{key:"_updatePreviousArchive",value:function(){var t=this;return this._findPreviousArchive().then((function(e){if("object"===o(e)&&e.today){e.today.next=t.dateId;var r=t.path.substring(0,t.path.length-t.dateId.length)+e.today["@id"];return t.client.storeObject("daily-archive",r,e).then((function(){return console.debug("[chat-messages] Previous archive written to remote storage at",r),e}))}return console.debug("[chat-messages] Previous archive not found"),!1}))}},{key:"_findPreviousArchive",value:function(){var e=this,r=this.path.substring(0,this.path.length-2),n=this.path.substring(0,this.path.length-5),a=this.path.substring(0,this.path.length-10);return this.client.getListing(r).then((function(i){var o=Object.keys(i).map((function(t){return parseInt(t)})).map((function(t){return t0){var s=c(Math.max.apply(Math,t(o)).toString());return e.client.getObject(r+s)}return e.client.getListing(n).then((function(r){var i=Object.keys(r).map((function(t){return parseInt(t.substr(0,2))})).map((function(t){return t0){var o=c(Math.max.apply(Math,t(i)).toString());return e.client.getListing(n+o+"/").then((function(r){var a=Object.keys(r).map((function(t){return parseInt(t)})),i=c(Math.max.apply(Math,t(a)).toString());return e.client.getObject(n+o+"/"+i)}))}return e.client.getListing(a).then((function(r){var n=Object.keys(r).map((function(t){return parseInt(t.substr(0,4))})).map((function(t){return t0){var i=Math.max.apply(Math,t(n)).toString();return e.client.getListing(a+i+"/").then((function(r){var n=Object.keys(r).map((function(t){return parseInt(t.substr(0,2))})),o=c(Math.max.apply(Math,t(n)).toString());return e.client.getListing(a+i+"/"+o+"/").then((function(r){var n=Object.keys(r).map((function(t){return parseInt(t)})),s=c(Math.max.apply(Math,t(n)).toString());return e.client.getObject(a+i+"/"+o+"/"+s)}))}))}return!1}))}))}))}},{key:"_updateArchiveMetaDocument",value:(y=i(regeneratorRuntime.mark((function t(){var e;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.client.getObject(this.metaPath);case 2:if("object"===o(e=t.sent)){t.next=5;break}return t.abrupt("return",this._createArchiveMetaDocument());case 5:if(!(Date.parse(e.last.replace("/","-"))>Date.parse(this.date))){t.next=10;break}return console.debug("[chat-messages]","Updating meta document for channel"),e.last=this.dateId,t.next=10,this.client.storeObject("daily-archive-meta",this.metaPath,e);case 10:return t.abrupt("return");case 11:case"end":return t.stop()}}),t,this)}))),function(){return y.apply(this,arguments)})},{key:"_createArchiveMetaDocument",value:(f=i(regeneratorRuntime.mark((function t(){var e,r,n,a=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return console.debug("[chat-messages]","Creating new meta document for channel"),t.next=3,this._findFirstArchive();case 3:return e=t.sent,r=this.channelName.replace(/#/,""),n={"@id":"chat-messages/".concat(this.service.domain,"/channels/").concat(r,"/meta"),"@type":"ChatChannelMeta",first:e,last:this.dateId},t.abrupt("return",this.client.storeObject("daily-archive-meta",this.metaPath,n).then((function(){return console.debug("[chat-messages]","Meta document written to remote storage")})).catch((function(t){console.log("[chat-messages]","Failed to store ".concat(a.metaPath)),console.error(t)})));case 7:case"end":return t.stop()}}),t,this)}))),function(){return f.apply(this,arguments)})},{key:"_findFirstArchive",value:(p=i(regeneratorRuntime.mark((function t(){var e,r,n,a,i,o,s;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return console.debug("[chat-messages]","Finding first archive for channel"),t.next=3,this.client.getListing("".concat(this.channelPath,"/"));case 3:return e=t.sent,r=u(e),t.next=7,this.client.getListing("".concat(this.channelPath,"/").concat(r,"/"));case 7:return n=t.sent,a=u(n),t.next=11,this.client.getListing("".concat(this.channelPath,"/").concat(r,"/").concat(c(a),"/"));case 11:return i=t.sent,o=u(i),s="".concat(r,"/").concat(c(a),"/").concat(c(o)),console.debug("[chat-messages]","First is",s),t.abrupt("return",s);case 16:case"end":return t.stop()}}),t,this)}))),function(){return p.apply(this,arguments)})},{key:"_sync",value:(l=i(regeneratorRuntime.mark((function t(e){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return console.debug("[chat-messages] Writing archive object with ".concat(e.today.messages.length," messages")),t.abrupt("return",this.client.storeObject("daily-archive",this.path,e).then((function(){return console.debug("[chat-messages] Archive written to remote storage"),!0}),(function(t){return console.warn("[chat-messages] Error trying to store object",t),t})));case 2:case"end":return t.stop()}}),t,this)}))),function(t){return l.apply(this,arguments)})}])&&s(a.prototype,h),n}(),privateClient:e,publicClient:r}}}}})(),n.default})()})); //# sourceMappingURL=build.js.map \ No newline at end of file diff --git a/dist/build.js.map b/dist/build.js.map index e8cdf35..df928f0 100644 --- a/dist/build.js.map +++ b/dist/build.js.map @@ -1 +1 @@ -{"version":3,"file":"build.js","mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,eAAgB,GAAIH,GACD,iBAAZC,QACdA,QAAsB,aAAID,IAE1BD,EAAmB,aAAIC,IARzB,CASGK,MAAM,WACT,M,mBCTA,IAAIC,EAAsB,CCA1B,EAAwB,CAACL,EAASM,KACjC,IAAI,IAAIC,KAAOD,EACXD,EAAoBG,EAAEF,EAAYC,KAASF,EAAoBG,EAAER,EAASO,IAC5EE,OAAOC,eAAeV,EAASO,EAAK,CAAEI,YAAY,EAAMC,IAAKN,EAAWC,MCJ3E,EAAwB,CAACM,EAAKC,IAAUL,OAAOM,UAAUC,eAAeC,KAAKJ,EAAKC,I,goCCAlF,SAASI,EAAKC,GAGZ,OADmB,KADnBA,EAAMC,OAAOD,IACLE,SAAgBF,EAAM,IAAMA,GAC7BA,E,uBAqjBT,SAAiBG,KAAM,gBAAiBC,QA1iBnB,SAAUC,EAAeC,GA+B5C,IAAMC,EAAgB,CACpB,KAAQ,SACR,WAAc,CACZ,WAAY,CACV,KAAQ,SACR,QAAW,2BACX,KAAQ,CAAC,6BAEX,MAAO,CACL,KAAQ,SACR,UAAY,GAEd,QAAS,CACP,KAAQ,SACR,QAAW,cACX,KAAQ,CAAC,gBAEX,QAAW,CACT,KAAQ,SACR,WAAc,CACZ,OAAU,CACR,KAAQ,SACR,UAAY,GAEd,SAAY,CACV,KAAQ,SACR,UAAY,KAIlB,KAAQ,CACN,KAAQ,SACR,UAAY,GAEd,KAAQ,CACN,KAAQ,SACR,UAAY,EACZ,KAAQ,CAAE,OAAQ,WAEpB,MAAS,CACP,KAAQ,SACR,WAAc,CACZ,MAAO,CACL,KAAQ,SACR,QAAW,+B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AQN,IAAMQ,YAClC,OAAO,EAAK3C,OAAOQ,UAAUwB,EAASzC,EAAK,IAAIE,EAAM,IAAIE,SAI7D,OAAO,aArgBqC,mBAohBxD,SAAO9B,GAGL,OAFAoD,QAAQC,MAAR,sDAA6DrD,EAAIwD,MAAMR,SAASxC,OAAhF,cAEOjB,KAAK4C,OAAO6B,YAAY,gBAAiBzE,KAAK2C,KAAMlC,GAAK4C,MAAK,WAEnE,OADAQ,QAAQC,MAAM,sDACP,KACP,SAAS6B,GAET,OADA9B,QAAQ+B,KAAK,+CAAgDD,GACtDA,U,iBA5hB6C,KAoiBtDvE,cAAAA,EACAC,aAAAA,M","sources":["webpack://ChatMessages/webpack/universalModuleDefinition","webpack://ChatMessages/webpack/bootstrap","webpack://ChatMessages/webpack/runtime/define property getters","webpack://ChatMessages/webpack/runtime/hasOwnProperty shorthand","webpack://ChatMessages/./src/chat-messages.js"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"ChatMessages\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"ChatMessages\"] = factory();\n\telse\n\t\troot[\"ChatMessages\"] = factory();\n})(this, function() {\nreturn ","// The require scope\nvar __webpack_require__ = {};\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","function pad (num) {\n num = String(num);\n if (num.length === 1) { num = \"0\" + num; }\n return num;\n};\n\nfunction parseDate (date) {\n return {\n year: date.getUTCFullYear(),\n month: pad( date.getUTCMonth() + 1 ),\n day: pad( date.getUTCDate() )\n };\n};\n\nconst ChatMessages = function (privateClient, publicClient) {\n /**\n * Schema: chat-messages/daily\n *\n * Represents one calendar day of chat messages\n *\n * @example\n * {\n * \"@context\": \"https://kosmos.org/ns/v2\",\n * \"@id\": \"chat-messages/irc.libera.chat/channels/kosmos/\",\n * \"@type\": \"ChatChannel\",\n * \"service\": {\n * \"domain\": \"irc.libera.chat\",\n * \"protocol\": \"IRC\",\n * },\n * \"name\": \"#kosmos\",\n * \"type\": \"room\",\n * \"today\": {\n * \"@id\": \"2015/01/01\",\n * \"@type\": \"ChatLog\",\n * \"messageType\": \"InstantMessage\",\n * \"previous\": \"2014/12/31\",\n * \"next\": \"2015/01/02\",\n * \"messages\": [\n * { \"date\": \"2015-06-05T17:35:28.454Z\", \"user\": \"hal8000\", \"text\": \"knock knock\" },\n * { \"date\": \"2015-06-05T17:37:42.123Z\", \"user\": \"raucao\", \"text\": \"who's there?\" },\n * { \"date\": \"2015-06-05T17:55:01.235Z\", \"user\": \"hal8000\", \"text\": \"HAL\" }\n * ]\n * }\n * }\n */\n const archiveSchema = {\n \"type\": \"object\",\n \"properties\": {\n \"@context\": {\n \"type\": \"string\",\n \"default\": \"https://kosmos.org/ns/v2\",\n \"enum\": [\"https://kosmos.org/ns/v2\"]\n },\n \"@id\": {\n \"type\": \"string\",\n \"required\": true\n },\n \"@type\": {\n \"type\": \"string\",\n \"default\": \"ChatChannel\",\n \"enum\": [\"ChatChannel\"]\n },\n \"service\": {\n \"type\": \"object\",\n \"properties\": {\n \"domain\": {\n \"type\": \"string\",\n \"required\": true\n },\n \"protocol\": {\n \"type\": \"string\",\n \"required\": true\n }\n }\n },\n \"name\": {\n \"type\": \"string\",\n \"required\": true\n },\n \"type\": {\n \"type\": \"string\",\n \"required\": true,\n \"enum\": [ \"room\", \"person\" ]\n },\n \"today\": {\n \"type\": \"object\",\n \"properties\": {\n \"@id\": {\n \"type\": \"string\",\n \"pattern\": \"^[0-9]{4}\\/[0-9]{2}\\/[0-9]{2}$\",\n \"required\": true\n },\n \"@type\": {\n \"type\": \"string\",\n \"default\": \"ChatLog\",\n \"pattern\": \"^ChatLog$\"\n },\n \"messageType\": {\n \"type\": \"string\",\n \"default\": \"InstantMessage\",\n \"pattern\": \"^InstantMessage$\"\n },\n \"previous\": {\n \"type\": \"string\",\n \"pattern\": \"^[0-9]{4}\\/[0-9]{2}\\/[0-9]{2}$\"\n },\n \"next\": {\n \"type\": \"string\",\n \"pattern\": \"^[0-9]{4}\\/[0-9]{2}\\/[0-9]{2}$\"\n },\n \"messages\": {\n \"type\": \"array\",\n \"required\": true,\n \"items\": {\n \"type\": \"object\",\n \"properties\": {\n \"date\": {\n \"type\": \"string\",\n \"format\": \"date-time\"\n },\n \"user\": {\n \"type\": \"string\"\n },\n \"text\": {\n \"type\": \"string\"\n },\n \"type\": \"string\",\n \"default\": \"text\",\n \"enum\": [\n \"text\",\n \"join\",\n \"leave\",\n \"action\"\n ]\n }\n }\n }\n }\n }\n },\n \"required\": []\n };\n\n privateClient.declareType(\"daily-archive\", \"https://kosmos.org/ns/v2\", archiveSchema);\n publicClient.declareType(\"daily-archive\", \"https://kosmos.org/ns/v2\", archiveSchema);\n\n /**\n * A daily archive stores chat messages by calendar day.\n *\n * @class\n */\n class DailyArchive {\n /**\n * @param {object} options\n * @param {object} options.service\n * @param {string} options.service.protocol - Type of chat service/protocol (e.g. \"IRC\", \"XMPP\", \"Campfire\", \"Slack\")\n * @param {string} options.service.domain - Domain of the chat service (e.g. \"irc.libera.chat\", \"kosmos.chat\")\n * @param {string} options.channelName - Name of room/channel (e.g. \"#kosmos\")\n * @param {string} [options.channelType] - Type of channel (\"room\" or \"person\")\n * @param {date} options.date - Date of archive day\n * @param {boolean} [options.isPublic] - Store logs in public folder (defaults to false)\n * @param {string} [options.previous] - Date of previous log file as `YYYY/MM/DD`. Looked up automatically when not given\n * @param {string} [options.next] - Date of next log file as `YYYY/MM/DD`. looked up automatically when not given\n *\n * @example\n * // IRC archive:\n * const archive = new chatMessages.DailyArchive({\n * service: {\n * protocol: 'IRC',\n * domain: 'irc.libera.chat',\n * },\n * channelName: '#kosmos-dev',\n * channelType: 'room',\n * date: new Date(),\n * isPublic: true\n * });\n *\n * // XMPP archive:\n * const archive = new chatMessages.DailyArchive({\n * service: {\n * protocol: 'XMPP',\n * domain: 'kosmos.chat',\n * },\n * channelName: 'kosmos-dev',\n * channelType: 'room',\n * date: new Date(),\n * isPublic: false\n * });\n *\n */\n constructor (options) {\n //\n // Defaults\n //\n options.isPublic = options.isPublic || false;\n options.channelType = options.channelType || \"room\";\n\n //\n // Validate options\n //\n if (typeof options !== \"object\") {\n throw \"options must be an object\";\n }\n if (typeof options.service !== \"object\" ||\n typeof options.service.protocol !== \"string\" ||\n typeof options.service.domain !== \"string\") {\n throw \"service must be an object containing at least service \\\"protocol\\\" and \\\"domain\\\"\";\n }\n if (typeof options.channelName !== \"string\") {\n throw \"channelName must be a string\";\n }\n if (!(options.date instanceof Date)) {\n throw \"date must be a date object\";\n }\n if (typeof options.isPublic !== \"boolean\") {\n throw \"isPublic must be a boolean value\";\n }\n\n /**\n * @property {object} service\n * @property {string} service.protocol - Type of chat service/protocol (e.g. \"IRC\", \"XMPP\", \"campfire\", \"slack\")\n * @property {string} service.domain - Domain of the chat service (e.g. \"irc.libera.chat\", \"kosmos.chat\")\n */\n this.service = options.service;\n\n /**\n * @property {string} channelName - Name of channel (e.g. \"#kosmos\")\n */\n this.channelName = options.channelName;\n\n /**\n * @property {string} channelType - Type of channel (\"room\" or \"person\")\n */\n this.channelType = options.channelType;\n\n /**\n * @property {string} date - Gregorian calendar date of the archive's content\n */\n this.date = options.date;\n\n /**\n * @property {boolean} isPublic - `true` for public archives, `false` for private ones\n */\n this.isPublic = options.isPublic || false;\n\n /**\n * @property {object} parsedDate - Contains padded year, month and day of date\n * @property {string} year\n * @property {string} month\n * @property {string} day\n */\n this.parsedDate = parseDate(this.date);\n\n /**\n * @property {string} dateId - Date string in the form of YYYY/MM/DD\n */\n this.dateId = this.parsedDate.year+'/'+this.parsedDate.month+'/'+this.parsedDate.day;\n\n /**\n * @property {string} path - Document path of the archive file\n */\n if (this.channelType === \"room\") {\n // Normal chatroom\n const channelName = this.channelName.replace(/#/,'');\n this.path = `${this.service.domain}/channels/${channelName}/${this.dateId}`;\n } else {\n // User direct message\n this.path = `${this.service.domain}/users/${this.channelName}/${this.dateId}`;\n }\n\n /**\n * @property {object} client - Public or private remoteStorgage.js BaseClient\n */\n this.client = this.isPublic ? publicClient : privateClient;\n\n /**\n * @property {string} previous - Date of previous log file as YYYY/MM/DD\n */\n this.previous = options.previous;\n\n /**\n * @property {string} next - Date of next log file as YYYY/MM/DD\n */\n this.next = options.next;\n }\n\n /*\n * @param {object} message\n * @param {string} message.timestamp - Timestamp of the message\n * @param {string} message.from - The sender of the message\n * @param {string} message.text - The message itself\n * @param {string} message.type - Type of message (one of text, join, leave, action)\n * @param {string} [message.id] - Unique ID of message. TODO implement\n *\n * @returns {Promise}\n */\n addMessage (message) {\n if (this.isPublic && !this.channelName.match(/^#/)) {\n return Promise.resolve(false);\n }\n\n message.type = message.type || 'text';\n\n return this.client.getObject(this.path).then((archive) => {\n if (typeof archive === 'object') {\n return this._updateDocument(archive, message);\n } else {\n return this._createDocument(message);\n }\n });\n }\n\n /*\n * Like , but for multiple messages at once. Useful for bulk\n * imports of messages.\n *\n * @param {Array} messages - Array of message objects (see params for addMessage)\n * @param {boolean} overwrite - If true, creates a new archive file and overwrites the old one. Defaults to false.\n *\n * @returns {Promise}\n */\n addMessages (messages, overwrite) {\n if (this.isPublic && !this.channelName.match(/^#/)) {\n return Promise.resolve(false);\n }\n\n overwrite = overwrite || false;\n\n messages.forEach(function(message) {\n message.type = message.type || 'text';\n });\n\n if (overwrite) {\n return this._createDocument(messages);\n } else {\n return this.client.getObject(this.path).then((archive) => {\n if (typeof archive === 'object') {\n return this._updateDocument(archive, messages);\n } else {\n return this._createDocument(messages);\n }\n });\n }\n }\n\n /*\n * Deletes the entire archive document from storage\n *\n * @returns {Promise}\n */\n remove () {\n return this.client.remove(this.path);\n }\n\n /*\n * Updates and writes an existing archive document\n *\n * @returns {Promise}\n *\n * @private\n */\n _updateDocument (archive, messages) {\n console.debug('[chat-messages] Updating archive document');\n\n if (Array.isArray(messages)) {\n messages.forEach(function(message) {\n archive.today.messages.push(message);\n });\n } else {\n archive.today.messages.push(messages);\n }\n\n return this._sync(archive);\n }\n\n /*\n * Creates and writes a new archive document\n *\n * @returns {Promise}\n *\n * @private\n */\n _createDocument (messages) {\n console.debug('[chat-messages] Creating new archive document');\n const archive = this._buildArchiveObject();\n\n if (Array.isArray(messages)) {\n messages.forEach((message) => {\n archive.today.messages.push(message);\n });\n } else {\n archive.today.messages.push(messages);\n }\n\n if (this.previous || this.next) {\n // The app is handling previous/next keys itself\n // That includes setting 'next' in the previous log file\n if (this.previous) { archive.today.previous = this.previous; }\n if (this.next) { archive.today.next = this.next; }\n return this._sync(archive);\n } else {\n // Find and update previous archive, set 'previous' on this one\n return this._updatePreviousArchive().then((previous) => {\n if (typeof previous === 'object') {\n archive.today.previous = previous.today['@id'];\n }\n return this._sync(archive);\n });\n }\n }\n\n /*\n * Builds the object to be stored in remote storage\n *\n * @returns {object}\n *\n * @private\n */\n _buildArchiveObject () {\n const roomName = this.channelName.replace(/#/,'');\n\n const archive = {\n \"@id\": \"chat-messages/\"+this.service.domain+\"/channels/\"+roomName+\"/\",\n \"@type\": \"ChatChannel\",\n \"service\": this.service,\n \"name\": this.channelName,\n \"type\": this.channelType,\n \"today\": {\n \"@id\": this.dateId,\n \"@type\": \"ChatLog\",\n \"messageType\": \"InstantMessage\",\n \"messages\": []\n }\n };\n\n switch (this.service.protocol) {\n case 'IRC':\n if (!this.channelName.match(/^#/)) {\n archive[\"@id\"] = \"chat-messages/\"+this.service.domain+\"/users/\"+this.channelName+\"/\";\n }\n break;\n case 'XMPP':\n // XMPP-specific adjustments\n break;\n }\n\n return archive;\n }\n\n /*\n * Finds the previous archive document and updates its today.next value\n *\n * @returns {boolean|Promise}\n *\n * @private\n */\n _updatePreviousArchive () {\n return this._findPreviousArchive().then((archive) => {\n if (typeof archive === 'object' && archive.today) {\n archive.today.next = this.dateId;\n const path = this.path.substring(0, this.path.length-this.dateId.length)+archive.today['@id'];\n\n return this.client.storeObject('daily-archive', path, archive).then(() => {\n console.debug('[chat-messages] Previous archive written to remote storage', path, archive);\n return archive;\n });\n } else {\n console.debug('[chat-messages] Previous archive not found');\n return false;\n }\n });\n }\n\n /*\n * Returns the previous archive document\n *\n * @returns {Promise}\n *\n * @private\n */\n _findPreviousArchive () {\n const monthPath = this.path.substring(0, this.path.length-2);\n const yearPath = this.path.substring(0, this.path.length-5);\n const basePath = this.path.substring(0, this.path.length-10);\n\n return this.client.getListing(monthPath).then((listing) => {\n const days = Object.keys(listing).map((i) => parseInt(i)).map((i) => {\n return (i < parseInt(this.parsedDate.day)) ? i : null;\n }).filter(function(i){ return i != null; });\n\n if (days.length > 0) {\n const day = pad(Math.max(...days).toString());\n return this.client.getObject(monthPath+day);\n }\n\n // Find last day in previous month\n return this.client.getListing(yearPath).then((listing) => {\n const months = Object.keys(listing).map((i) => parseInt(i.substr(0,2))).map((i) => {\n return (i < parseInt(this.parsedDate.month)) ? i : null;\n }).filter(function(i){ return i != null; });\n\n if (months.length > 0) {\n const month = pad(Math.max(...months).toString());\n\n return this.client.getListing(yearPath+month+'/').then((listing) => {\n const days = Object.keys(listing).map((i) => parseInt(i));\n const day = pad(Math.max(...days).toString());\n return this.client.getObject(yearPath+month+'/'+day);\n });\n } else {\n // Find last month and day in previous year\n return this.client.getListing(basePath).then((listing) => {\n\n const years = Object.keys(listing).map((i) => parseInt(i.substr(0,4))).map((i) => {\n return (i < parseInt(this.parsedDate.year)) ? i : null;\n }).filter(function(i){ return i != null; });\n\n if (years.length > 0) {\n const year = Math.max(...years).toString();\n\n return this.client.getListing(basePath+year+'/').then((listing) => {\n const months = Object.keys(listing).map((i) => parseInt(i.substr(0,2)));\n const month = pad(Math.max(...months).toString());\n\n return this.client.getListing(basePath+year+'/'+month+'/').then((listing) => {\n const days = Object.keys(listing).map((i) => parseInt(i));\n const day = pad(Math.max(...days).toString());\n return this.client.getObject(basePath+year+'/'+month+'/'+day);\n });\n });\n } else {\n return false;\n }\n });\n }\n });\n });\n }\n\n /*\n * Write archive document\n *\n * @returns {Promise}\n *\n * @private\n */\n _sync (obj) {\n console.debug(`[chat-messages] Writing archive object with ${obj.today.messages.length} messages`);\n\n return this.client.storeObject('daily-archive', this.path, obj).then(function(){\n console.debug('[chat-messages] Archive written to remote storage');\n return true;\n },function(error){\n console.warn('[chat-messages] Error trying to store object', error);\n return error;\n });\n }\n };\n\n return {\n exports: {\n DailyArchive,\n privateClient,\n publicClient\n }\n };\n};\n\nexport default { name: 'chat-messages', builder: ChatMessages };\n"],"names":["root","factory","exports","module","define","amd","this","__webpack_require__","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","pad","num","String","length","name","builder","privateClient","publicClient","archiveSchema","declareType","DailyArchive","options","isPublic","channelType","service","protocol","domain","channelName","date","Date","parsedDate","year","getUTCFullYear","month","getUTCMonth","day","getUTCDate","dateId","replace","path","client","previous","next","message","match","Promise","resolve","type","getObject","then","archive","_updateDocument","_createDocument","messages","overwrite","forEach","remove","console","debug","Array","isArray","today","push","_sync","_buildArchiveObject","_updatePreviousArchive","roomName","_findPreviousArchive","substring","storeObject","monthPath","yearPath","basePath","getListing","listing","days","keys","map","i","parseInt","filter","Math","max","toString","months","substr","years","error","warn"],"sourceRoot":""} \ No newline at end of file +{"version":3,"file":"build.js","mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,eAAgB,GAAIH,GACD,iBAAZC,QACdA,QAAsB,aAAID,IAE1BD,EAAmB,aAAIC,IARzB,CASGK,MAAM,WACT,M,qBCHA,IAAIC,EAAW,SAAUL,GACvB,aAEA,IAEIM,EAFAC,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,+CAAgDjK,GACtDA,MARX,gDAroBwD,iD,iBAAA,KAqpBtDyF,cAAAA,EACAC,aAAAA,O","sources":["webpack://ChatMessages/webpack/universalModuleDefinition","webpack://ChatMessages/./node_modules/regenerator-runtime/runtime.js","webpack://ChatMessages/webpack/bootstrap","webpack://ChatMessages/webpack/runtime/compat get default export","webpack://ChatMessages/webpack/runtime/define property getters","webpack://ChatMessages/webpack/runtime/hasOwnProperty shorthand","webpack://ChatMessages/./src/chat-messages.js"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"ChatMessages\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"ChatMessages\"] = factory();\n\telse\n\t\troot[\"ChatMessages\"] = factory();\n})(this, function() {\nreturn ","/**\n * Copyright (c) 2014-present, Facebook, Inc.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nvar runtime = (function (exports) {\n \"use strict\";\n\n var Op = Object.prototype;\n var hasOwn = Op.hasOwnProperty;\n var undefined; // More compressible than void 0.\n var $Symbol = typeof Symbol === \"function\" ? Symbol : {};\n var iteratorSymbol = $Symbol.iterator || \"@@iterator\";\n var asyncIteratorSymbol = $Symbol.asyncIterator || \"@@asyncIterator\";\n var toStringTagSymbol = $Symbol.toStringTag || \"@@toStringTag\";\n\n function define(obj, key, value) {\n Object.defineProperty(obj, key, {\n value: value,\n enumerable: true,\n configurable: true,\n writable: true\n });\n return obj[key];\n }\n try {\n // IE 8 has a broken Object.defineProperty that only works on DOM objects.\n define({}, \"\");\n } catch (err) {\n define = function(obj, key, value) {\n return obj[key] = value;\n };\n }\n\n function wrap(innerFn, outerFn, self, tryLocsList) {\n // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.\n var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;\n var generator = Object.create(protoGenerator.prototype);\n var context = new Context(tryLocsList || []);\n\n // The ._invoke method unifies the implementations of the .next,\n // .throw, and .return methods.\n generator._invoke = makeInvokeMethod(innerFn, self, context);\n\n return generator;\n }\n exports.wrap = wrap;\n\n // Try/catch helper to minimize deoptimizations. Returns a completion\n // record like context.tryEntries[i].completion. This interface could\n // have been (and was previously) designed to take a closure to be\n // invoked without arguments, but in all the cases we care about we\n // already have an existing method we want to call, so there's no need\n // to create a new function object. We can even get away with assuming\n // the method takes exactly one argument, since that happens to be true\n // in every case, so we don't have to touch the arguments object. The\n // only additional allocation required is the completion record, which\n // has a stable shape and so hopefully should be cheap to allocate.\n function tryCatch(fn, obj, arg) {\n try {\n return { type: \"normal\", arg: fn.call(obj, arg) };\n } catch (err) {\n return { type: \"throw\", arg: err };\n }\n }\n\n var GenStateSuspendedStart = \"suspendedStart\";\n var GenStateSuspendedYield = \"suspendedYield\";\n var GenStateExecuting = \"executing\";\n var GenStateCompleted = \"completed\";\n\n // Returning this object from the innerFn has the same effect as\n // breaking out of the dispatch switch statement.\n var ContinueSentinel = {};\n\n // Dummy constructor functions that we use as the .constructor and\n // .constructor.prototype properties for functions that return Generator\n // objects. For full spec compliance, you may wish to configure your\n // minifier not to mangle the names of these two functions.\n function Generator() {}\n function GeneratorFunction() {}\n function GeneratorFunctionPrototype() {}\n\n // This is a polyfill for %IteratorPrototype% for environments that\n // don't natively support it.\n var IteratorPrototype = {};\n define(IteratorPrototype, iteratorSymbol, function () {\n return this;\n });\n\n var getProto = Object.getPrototypeOf;\n var NativeIteratorPrototype = getProto && getProto(getProto(values([])));\n if (NativeIteratorPrototype &&\n NativeIteratorPrototype !== Op &&\n hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {\n // This environment has a native %IteratorPrototype%; use it instead\n // of the polyfill.\n IteratorPrototype = NativeIteratorPrototype;\n }\n\n var Gp = GeneratorFunctionPrototype.prototype =\n Generator.prototype = Object.create(IteratorPrototype);\n GeneratorFunction.prototype = GeneratorFunctionPrototype;\n define(Gp, \"constructor\", GeneratorFunctionPrototype);\n define(GeneratorFunctionPrototype, \"constructor\", GeneratorFunction);\n GeneratorFunction.displayName = define(\n GeneratorFunctionPrototype,\n toStringTagSymbol,\n \"GeneratorFunction\"\n );\n\n // Helper for defining the .next, .throw, and .return methods of the\n // Iterator interface in terms of a single ._invoke method.\n function defineIteratorMethods(prototype) {\n [\"next\", \"throw\", \"return\"].forEach(function(method) {\n define(prototype, method, function(arg) {\n return this._invoke(method, arg);\n });\n });\n }\n\n exports.isGeneratorFunction = function(genFun) {\n var ctor = typeof genFun === \"function\" && genFun.constructor;\n return ctor\n ? ctor === GeneratorFunction ||\n // For the native GeneratorFunction constructor, the best we can\n // do is to check its .name property.\n (ctor.displayName || ctor.name) === \"GeneratorFunction\"\n : false;\n };\n\n exports.mark = function(genFun) {\n if (Object.setPrototypeOf) {\n Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);\n } else {\n genFun.__proto__ = GeneratorFunctionPrototype;\n define(genFun, toStringTagSymbol, \"GeneratorFunction\");\n }\n genFun.prototype = Object.create(Gp);\n return genFun;\n };\n\n // Within the body of any async function, `await x` is transformed to\n // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test\n // `hasOwn.call(value, \"__await\")` to determine if the yielded value is\n // meant to be awaited.\n exports.awrap = function(arg) {\n return { __await: arg };\n };\n\n function AsyncIterator(generator, PromiseImpl) {\n function invoke(method, arg, resolve, reject) {\n var record = tryCatch(generator[method], generator, arg);\n if (record.type === \"throw\") {\n reject(record.arg);\n } else {\n var result = record.arg;\n var value = result.value;\n if (value &&\n typeof value === \"object\" &&\n hasOwn.call(value, \"__await\")) {\n return PromiseImpl.resolve(value.__await).then(function(value) {\n invoke(\"next\", value, resolve, reject);\n }, function(err) {\n invoke(\"throw\", err, resolve, reject);\n });\n }\n\n return PromiseImpl.resolve(value).then(function(unwrapped) {\n // When a yielded Promise is resolved, its final value becomes\n // the .value of the Promise<{value,done}> result for the\n // current iteration.\n result.value = unwrapped;\n resolve(result);\n }, function(error) {\n // If a rejected Promise was yielded, throw the rejection back\n // into the async generator function so it can be handled there.\n return invoke(\"throw\", error, resolve, reject);\n });\n }\n }\n\n var previousPromise;\n\n function enqueue(method, arg) {\n function callInvokeWithMethodAndArg() {\n return new PromiseImpl(function(resolve, reject) {\n invoke(method, arg, resolve, reject);\n });\n }\n\n return previousPromise =\n // If enqueue has been called before, then we want to wait until\n // all previous Promises have been resolved before calling invoke,\n // so that results are always delivered in the correct order. If\n // enqueue has not been called before, then it is important to\n // call invoke immediately, without waiting on a callback to fire,\n // so that the async generator function has the opportunity to do\n // any necessary setup in a predictable way. This predictability\n // is why the Promise constructor synchronously invokes its\n // executor callback, and why async functions synchronously\n // execute code before the first await. Since we implement simple\n // async functions in terms of async generators, it is especially\n // important to get this right, even though it requires care.\n previousPromise ? previousPromise.then(\n callInvokeWithMethodAndArg,\n // Avoid propagating failures to Promises returned by later\n // invocations of the iterator.\n callInvokeWithMethodAndArg\n ) : callInvokeWithMethodAndArg();\n }\n\n // Define the unified helper method that is used to implement .next,\n // .throw, and .return (see defineIteratorMethods).\n this._invoke = enqueue;\n }\n\n defineIteratorMethods(AsyncIterator.prototype);\n define(AsyncIterator.prototype, asyncIteratorSymbol, function () {\n return this;\n });\n exports.AsyncIterator = AsyncIterator;\n\n // Note that simple async functions are implemented on top of\n // AsyncIterator objects; they just return a Promise for the value of\n // the final result produced by the iterator.\n exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) {\n if (PromiseImpl === void 0) PromiseImpl = Promise;\n\n var iter = new AsyncIterator(\n wrap(innerFn, outerFn, self, tryLocsList),\n PromiseImpl\n );\n\n return exports.isGeneratorFunction(outerFn)\n ? iter // If outerFn is a generator, return the full iterator.\n : iter.next().then(function(result) {\n return result.done ? result.value : iter.next();\n });\n };\n\n function makeInvokeMethod(innerFn, self, context) {\n var state = GenStateSuspendedStart;\n\n return function invoke(method, arg) {\n if (state === GenStateExecuting) {\n throw new Error(\"Generator is already running\");\n }\n\n if (state === GenStateCompleted) {\n if (method === \"throw\") {\n throw arg;\n }\n\n // Be forgiving, per 25.3.3.3.3 of the spec:\n // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume\n return doneResult();\n }\n\n context.method = method;\n context.arg = arg;\n\n while (true) {\n var delegate = context.delegate;\n if (delegate) {\n var delegateResult = maybeInvokeDelegate(delegate, context);\n if (delegateResult) {\n if (delegateResult === ContinueSentinel) continue;\n return delegateResult;\n }\n }\n\n if (context.method === \"next\") {\n // Setting context._sent for legacy support of Babel's\n // function.sent implementation.\n context.sent = context._sent = context.arg;\n\n } else if (context.method === \"throw\") {\n if (state === GenStateSuspendedStart) {\n state = GenStateCompleted;\n throw context.arg;\n }\n\n context.dispatchException(context.arg);\n\n } else if (context.method === \"return\") {\n context.abrupt(\"return\", context.arg);\n }\n\n state = GenStateExecuting;\n\n var record = tryCatch(innerFn, self, context);\n if (record.type === \"normal\") {\n // If an exception is thrown from innerFn, we leave state ===\n // GenStateExecuting and loop back for another invocation.\n state = context.done\n ? GenStateCompleted\n : GenStateSuspendedYield;\n\n if (record.arg === ContinueSentinel) {\n continue;\n }\n\n return {\n value: record.arg,\n done: context.done\n };\n\n } else if (record.type === \"throw\") {\n state = GenStateCompleted;\n // Dispatch the exception by looping back around to the\n // context.dispatchException(context.arg) call above.\n context.method = \"throw\";\n context.arg = record.arg;\n }\n }\n };\n }\n\n // Call delegate.iterator[context.method](context.arg) and handle the\n // result, either by returning a { value, done } result from the\n // delegate iterator, or by modifying context.method and context.arg,\n // setting context.delegate to null, and returning the ContinueSentinel.\n function maybeInvokeDelegate(delegate, context) {\n var method = delegate.iterator[context.method];\n if (method === undefined) {\n // A .throw or .return when the delegate iterator has no .throw\n // method always terminates the yield* loop.\n context.delegate = null;\n\n if (context.method === \"throw\") {\n // Note: [\"return\"] must be used for ES3 parsing compatibility.\n if (delegate.iterator[\"return\"]) {\n // If the delegate iterator has a return method, give it a\n // chance to clean up.\n context.method = \"return\";\n context.arg = undefined;\n maybeInvokeDelegate(delegate, context);\n\n if (context.method === \"throw\") {\n // If maybeInvokeDelegate(context) changed context.method from\n // \"return\" to \"throw\", let that override the TypeError below.\n return ContinueSentinel;\n }\n }\n\n context.method = \"throw\";\n context.arg = new TypeError(\n \"The iterator does not provide a 'throw' method\");\n }\n\n return ContinueSentinel;\n }\n\n var record = tryCatch(method, delegate.iterator, context.arg);\n\n if (record.type === \"throw\") {\n context.method = \"throw\";\n context.arg = record.arg;\n context.delegate = null;\n return ContinueSentinel;\n }\n\n var info = record.arg;\n\n if (! info) {\n context.method = \"throw\";\n context.arg = new TypeError(\"iterator result is not an object\");\n context.delegate = null;\n return ContinueSentinel;\n }\n\n if (info.done) {\n // Assign the result of the finished delegate to the temporary\n // variable specified by delegate.resultName (see delegateYield).\n context[delegate.resultName] = info.value;\n\n // Resume execution at the desired location (see delegateYield).\n context.next = delegate.nextLoc;\n\n // If context.method was \"throw\" but the delegate handled the\n // exception, let the outer generator proceed normally. If\n // context.method was \"next\", forget context.arg since it has been\n // \"consumed\" by the delegate iterator. If context.method was\n // \"return\", allow the original .return call to continue in the\n // outer generator.\n if (context.method !== \"return\") {\n context.method = \"next\";\n context.arg = undefined;\n }\n\n } else {\n // Re-yield the result returned by the delegate method.\n return info;\n }\n\n // The delegate iterator is finished, so forget it and continue with\n // the outer generator.\n context.delegate = null;\n return ContinueSentinel;\n }\n\n // Define Generator.prototype.{next,throw,return} in terms of the\n // unified ._invoke helper method.\n defineIteratorMethods(Gp);\n\n define(Gp, toStringTagSymbol, \"Generator\");\n\n // A Generator should always return itself as the iterator object when the\n // @@iterator function is called on it. Some browsers' implementations of the\n // iterator prototype chain incorrectly implement this, causing the Generator\n // object to not be returned from this call. This ensures that doesn't happen.\n // See https://github.com/facebook/regenerator/issues/274 for more details.\n define(Gp, iteratorSymbol, function() {\n return this;\n });\n\n define(Gp, \"toString\", function() {\n return \"[object Generator]\";\n });\n\n function pushTryEntry(locs) {\n var entry = { tryLoc: locs[0] };\n\n if (1 in locs) {\n entry.catchLoc = locs[1];\n }\n\n if (2 in locs) {\n entry.finallyLoc = locs[2];\n entry.afterLoc = locs[3];\n }\n\n this.tryEntries.push(entry);\n }\n\n function resetTryEntry(entry) {\n var record = entry.completion || {};\n record.type = \"normal\";\n delete record.arg;\n entry.completion = record;\n }\n\n function Context(tryLocsList) {\n // The root entry object (effectively a try statement without a catch\n // or a finally block) gives us a place to store values thrown from\n // locations where there is no enclosing try statement.\n this.tryEntries = [{ tryLoc: \"root\" }];\n tryLocsList.forEach(pushTryEntry, this);\n this.reset(true);\n }\n\n exports.keys = function(object) {\n var keys = [];\n for (var key in object) {\n keys.push(key);\n }\n keys.reverse();\n\n // Rather than returning an object with a next method, we keep\n // things simple and return the next function itself.\n return function next() {\n while (keys.length) {\n var key = keys.pop();\n if (key in object) {\n next.value = key;\n next.done = false;\n return next;\n }\n }\n\n // To avoid creating an additional object, we just hang the .value\n // and .done properties off the next function object itself. This\n // also ensures that the minifier will not anonymize the function.\n next.done = true;\n return next;\n };\n };\n\n function values(iterable) {\n if (iterable) {\n var iteratorMethod = iterable[iteratorSymbol];\n if (iteratorMethod) {\n return iteratorMethod.call(iterable);\n }\n\n if (typeof iterable.next === \"function\") {\n return iterable;\n }\n\n if (!isNaN(iterable.length)) {\n var i = -1, next = function next() {\n while (++i < iterable.length) {\n if (hasOwn.call(iterable, i)) {\n next.value = iterable[i];\n next.done = false;\n return next;\n }\n }\n\n next.value = undefined;\n next.done = true;\n\n return next;\n };\n\n return next.next = next;\n }\n }\n\n // Return an iterator with no values.\n return { next: doneResult };\n }\n exports.values = values;\n\n function doneResult() {\n return { value: undefined, done: true };\n }\n\n Context.prototype = {\n constructor: Context,\n\n reset: function(skipTempReset) {\n this.prev = 0;\n this.next = 0;\n // Resetting context._sent for legacy support of Babel's\n // function.sent implementation.\n this.sent = this._sent = undefined;\n this.done = false;\n this.delegate = null;\n\n this.method = \"next\";\n this.arg = undefined;\n\n this.tryEntries.forEach(resetTryEntry);\n\n if (!skipTempReset) {\n for (var name in this) {\n // Not sure about the optimal order of these conditions:\n if (name.charAt(0) === \"t\" &&\n hasOwn.call(this, name) &&\n !isNaN(+name.slice(1))) {\n this[name] = undefined;\n }\n }\n }\n },\n\n stop: function() {\n this.done = true;\n\n var rootEntry = this.tryEntries[0];\n var rootRecord = rootEntry.completion;\n if (rootRecord.type === \"throw\") {\n throw rootRecord.arg;\n }\n\n return this.rval;\n },\n\n dispatchException: function(exception) {\n if (this.done) {\n throw exception;\n }\n\n var context = this;\n function handle(loc, caught) {\n record.type = \"throw\";\n record.arg = exception;\n context.next = loc;\n\n if (caught) {\n // If the dispatched exception was caught by a catch block,\n // then let that catch block handle the exception normally.\n context.method = \"next\";\n context.arg = undefined;\n }\n\n return !! caught;\n }\n\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n var record = entry.completion;\n\n if (entry.tryLoc === \"root\") {\n // Exception thrown outside of any try block that could handle\n // it, so set the completion value of the entire function to\n // throw the exception.\n return handle(\"end\");\n }\n\n if (entry.tryLoc <= this.prev) {\n var hasCatch = hasOwn.call(entry, \"catchLoc\");\n var hasFinally = hasOwn.call(entry, \"finallyLoc\");\n\n if (hasCatch && hasFinally) {\n if (this.prev < entry.catchLoc) {\n return handle(entry.catchLoc, true);\n } else if (this.prev < entry.finallyLoc) {\n return handle(entry.finallyLoc);\n }\n\n } else if (hasCatch) {\n if (this.prev < entry.catchLoc) {\n return handle(entry.catchLoc, true);\n }\n\n } else if (hasFinally) {\n if (this.prev < entry.finallyLoc) {\n return handle(entry.finallyLoc);\n }\n\n } else {\n throw new Error(\"try statement without catch or finally\");\n }\n }\n }\n },\n\n abrupt: function(type, arg) {\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n if (entry.tryLoc <= this.prev &&\n hasOwn.call(entry, \"finallyLoc\") &&\n this.prev < entry.finallyLoc) {\n var finallyEntry = entry;\n break;\n }\n }\n\n if (finallyEntry &&\n (type === \"break\" ||\n type === \"continue\") &&\n finallyEntry.tryLoc <= arg &&\n arg <= finallyEntry.finallyLoc) {\n // Ignore the finally entry if control is not jumping to a\n // location outside the try/catch block.\n finallyEntry = null;\n }\n\n var record = finallyEntry ? finallyEntry.completion : {};\n record.type = type;\n record.arg = arg;\n\n if (finallyEntry) {\n this.method = \"next\";\n this.next = finallyEntry.finallyLoc;\n return ContinueSentinel;\n }\n\n return this.complete(record);\n },\n\n complete: function(record, afterLoc) {\n if (record.type === \"throw\") {\n throw record.arg;\n }\n\n if (record.type === \"break\" ||\n record.type === \"continue\") {\n this.next = record.arg;\n } else if (record.type === \"return\") {\n this.rval = this.arg = record.arg;\n this.method = \"return\";\n this.next = \"end\";\n } else if (record.type === \"normal\" && afterLoc) {\n this.next = afterLoc;\n }\n\n return ContinueSentinel;\n },\n\n finish: function(finallyLoc) {\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n if (entry.finallyLoc === finallyLoc) {\n this.complete(entry.completion, entry.afterLoc);\n resetTryEntry(entry);\n return ContinueSentinel;\n }\n }\n },\n\n \"catch\": function(tryLoc) {\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n if (entry.tryLoc === tryLoc) {\n var record = entry.completion;\n if (record.type === \"throw\") {\n var thrown = record.arg;\n resetTryEntry(entry);\n }\n return thrown;\n }\n }\n\n // The context.catch method must only be called with a location\n // argument that corresponds to a known catch block.\n throw new Error(\"illegal catch attempt\");\n },\n\n delegateYield: function(iterable, resultName, nextLoc) {\n this.delegate = {\n iterator: values(iterable),\n resultName: resultName,\n nextLoc: nextLoc\n };\n\n if (this.method === \"next\") {\n // Deliberately forget the last sent value so that we don't\n // accidentally pass it on to the delegate.\n this.arg = undefined;\n }\n\n return ContinueSentinel;\n }\n };\n\n // Regardless of whether this script is executing as a CommonJS module\n // or not, return the runtime object so that we can declare the variable\n // regeneratorRuntime in the outer scope, which allows this module to be\n // injected easily by `bin/regenerator --include-runtime script.js`.\n return exports;\n\n}(\n // If this script is executing as a CommonJS module, use module.exports\n // as the regeneratorRuntime namespace. Otherwise create a new empty\n // object. Either way, the resulting object will be used to initialize\n // the regeneratorRuntime variable at the top of this file.\n typeof module === \"object\" ? module.exports : {}\n));\n\ntry {\n regeneratorRuntime = runtime;\n} catch (accidentalStrictMode) {\n // This module should not be running in strict mode, so the above\n // assignment should always work unless something is misconfigured. Just\n // in case runtime.js accidentally runs in strict mode, in modern engines\n // we can explicitly access globalThis. In older engines we can escape\n // strict mode using a global Function call. This could conceivably fail\n // if a Content Security Policy forbids using Function, but in that case\n // the proper solution is to fix the accidental strict mode problem. If\n // you've misconfigured your bundler to force strict mode and applied a\n // CSP to forbid Function, and you're not willing to fix either of those\n // problems, please detail your unique predicament in a GitHub issue.\n if (typeof globalThis === \"object\") {\n globalThis.regeneratorRuntime = runtime;\n } else {\n Function(\"r\", \"regeneratorRuntime = r\")(runtime);\n }\n}\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","import 'regenerator-runtime/runtime';\n\nfunction pad (num) {\n num = String(num);\n if (num.length === 1) { num = \"0\" + num; }\n return num;\n};\n\nfunction parseDate (date) {\n return {\n year: date.getUTCFullYear(),\n month: pad( date.getUTCMonth() + 1 ),\n day: pad( date.getUTCDate() )\n };\n};\n\nfunction lowestNumberInListing(items) {\n const sortedNumbers = Object.keys(items)\n .map(i => parseInt(i))\n .filter(i => !Number.isNaN(i))\n .sort();\n return sortedNumbers[0];\n}\n\nconst ChatMessages = function (privateClient, publicClient) {\n /**\n * Schema: chat-messages/daily-archive\n *\n * Represents one calendar day of chat messages\n *\n * @example\n * {\n * \"@context\": \"https://kosmos.org/ns/v2\",\n * \"@id\": \"chat-messages/irc.libera.chat/channels/kosmos/\",\n * \"@type\": \"ChatChannel\",\n * \"service\": {\n * \"domain\": \"irc.libera.chat\",\n * \"protocol\": \"IRC\",\n * },\n * \"name\": \"#kosmos\",\n * \"type\": \"room\",\n * \"today\": {\n * \"@id\": \"2015/01/01\",\n * \"@type\": \"ChatLog\",\n * \"messageType\": \"InstantMessage\",\n * \"previous\": \"2014/12/31\",\n * \"next\": \"2015/01/02\",\n * \"messages\": [\n * { \"date\": \"2015-06-05T17:35:28.454Z\", \"user\": \"hal8000\", \"text\": \"knock knock\" },\n * { \"date\": \"2015-06-05T17:37:42.123Z\", \"user\": \"raucao\", \"text\": \"who's there?\" },\n * { \"date\": \"2015-06-05T17:55:01.235Z\", \"user\": \"hal8000\", \"text\": \"HAL\" }\n * ]\n * }\n * }\n */\n const archiveSchema = {\n \"type\": \"object\",\n \"properties\": {\n \"@context\": {\n \"type\": \"string\",\n \"default\": \"https://kosmos.org/ns/v2/chat-channel\"\n },\n \"@id\": {\n \"type\": \"string\",\n \"required\": true\n },\n \"@type\": {\n \"type\": \"string\",\n \"default\": \"ChatChannel\",\n \"enum\": [\"ChatChannel\"]\n },\n \"service\": {\n \"type\": \"object\",\n \"properties\": {\n \"domain\": {\n \"type\": \"string\",\n \"required\": true\n },\n \"protocol\": {\n \"type\": \"string\",\n \"required\": true\n }\n }\n },\n \"name\": {\n \"type\": \"string\",\n \"required\": true\n },\n \"type\": {\n \"type\": \"string\",\n \"required\": true,\n \"enum\": [ \"room\", \"person\" ]\n },\n \"today\": {\n \"type\": \"object\",\n \"properties\": {\n \"@id\": {\n \"type\": \"string\",\n \"pattern\": \"^[0-9]{4}\\/[0-9]{2}\\/[0-9]{2}$\",\n \"required\": true\n },\n \"@type\": {\n \"type\": \"string\",\n \"default\": \"ChatLog\",\n \"pattern\": \"^ChatLog$\"\n },\n \"messageType\": {\n \"type\": \"string\",\n \"default\": \"InstantMessage\",\n \"pattern\": \"^InstantMessage$\"\n },\n \"previous\": {\n \"type\": \"string\",\n \"pattern\": \"^[0-9]{4}\\/[0-9]{2}\\/[0-9]{2}$\"\n },\n \"next\": {\n \"type\": \"string\",\n \"pattern\": \"^[0-9]{4}\\/[0-9]{2}\\/[0-9]{2}$\"\n },\n \"messages\": {\n \"type\": \"array\",\n \"required\": true,\n \"items\": {\n \"type\": \"object\",\n \"properties\": {\n \"date\": {\n \"type\": \"string\",\n \"format\": \"date-time\"\n },\n \"user\": {\n \"type\": \"string\"\n },\n \"text\": {\n \"type\": \"string\"\n },\n \"type\": \"string\",\n \"default\": \"text\",\n \"enum\": [\n \"text\",\n \"join\",\n \"leave\",\n \"action\"\n ]\n }\n }\n }\n }\n }\n },\n \"required\": []\n };\n\n privateClient.declareType(\"daily-archive\", \"https://kosmos.org/ns/v2/chat-channel\", archiveSchema);\n publicClient.declareType(\"daily-archive\", \"https://kosmos.org/ns/v2/chat-channel\", archiveSchema);\n\n /**\n * Schema: chat-messages/daily-archive-meta\n *\n * Stores meta information about the daily archives\n *\n * @example\n * {\n * \"@context\": \"https://kosmos.org/ns/v2\",\n * \"@id\": \"chat-messages/irc.libera.chat/channels/kosmos/meta\",\n * \"@type\": \"ChatChannelMeta\",\n * \"first\": \"2009/01/03\",\n * \"last\": \"2021/11/05\"\n * }\n * }\n */\n const archiveMetaSchema = {\n \"type\": \"object\",\n \"properties\": {\n \"@context\": {\n \"type\": \"string\",\n \"default\": \"https://kosmos.org/ns/v2/chat-channel-meta\"\n },\n \"@id\": {\n \"type\": \"string\",\n },\n \"@type\": {\n \"type\": \"string\",\n \"default\": \"ChatChannelMeta\",\n \"enum\": [\"ChatChannelMeta\"]\n },\n \"first\": {\n \"type\": \"string\",\n \"pattern\": \"^[0-9]{4}\\/[0-9]{2}\\/[0-9]{2}$\"\n },\n \"last\": {\n \"type\": \"string\",\n \"pattern\": \"^[0-9]{4}\\/[0-9]{2}\\/[0-9]{2}$\"\n }\n },\n \"required\": [\"@id\", \"first\", \"last\"]\n };\n\n privateClient.declareType(\"daily-archive-meta\", \"https://kosmos.org/ns/v2/chat-channel-meta\", archiveMetaSchema);\n publicClient.declareType(\"daily-archive-meta\", \"https://kosmos.org/ns/v2/chat-channel-meta\", archiveMetaSchema);\n\n /**\n * A daily archive stores chat messages by calendar day.\n *\n * @class\n */\n class DailyArchive {\n /**\n * @param {object} options\n * @param {object} options.service\n * @param {string} options.service.protocol - Type of chat service/protocol (e.g. \"IRC\", \"XMPP\", \"Campfire\", \"Slack\")\n * @param {string} options.service.domain - Domain of the chat service (e.g. \"irc.libera.chat\", \"kosmos.chat\")\n * @param {string} options.channelName - Name of room/channel (e.g. \"#kosmos\")\n * @param {string} [options.channelType] - Type of channel (\"room\" or \"person\")\n * @param {date} options.date - Date of archive day\n * @param {boolean} [options.isPublic] - Store logs in public folder (defaults to false)\n * @param {string} [options.previous] - Date of previous log file as `YYYY/MM/DD`. Looked up automatically when not given\n * @param {string} [options.next] - Date of next log file as `YYYY/MM/DD`. looked up automatically when not given\n *\n * @example\n * // IRC archive:\n * const archive = new chatMessages.DailyArchive({\n * service: {\n * protocol: 'IRC',\n * domain: 'irc.libera.chat',\n * },\n * channelName: '#kosmos-dev',\n * channelType: 'room',\n * date: new Date(),\n * isPublic: true\n * });\n *\n * // XMPP archive:\n * const archive = new chatMessages.DailyArchive({\n * service: {\n * protocol: 'XMPP',\n * domain: 'kosmos.chat',\n * },\n * channelName: 'kosmos-dev',\n * channelType: 'room',\n * date: new Date(),\n * isPublic: false\n * });\n *\n */\n constructor (options) {\n //\n // Defaults\n //\n options.isPublic = options.isPublic || false;\n options.channelType = options.channelType || \"room\";\n\n //\n // Validate options\n //\n if (typeof options !== \"object\") {\n throw \"options must be an object\";\n }\n if (typeof options.service !== \"object\" ||\n typeof options.service.protocol !== \"string\" ||\n typeof options.service.domain !== \"string\") {\n throw \"service must be an object containing at least service \\\"protocol\\\" and \\\"domain\\\"\";\n }\n if (typeof options.channelName !== \"string\") {\n throw \"channelName must be a string\";\n }\n if (!(options.date instanceof Date)) {\n throw \"date must be a date object\";\n }\n if (typeof options.isPublic !== \"boolean\") {\n throw \"isPublic must be a boolean value\";\n }\n\n /**\n * @property {object} service\n * @property {string} service.protocol - Type of chat service/protocol (e.g. \"IRC\", \"XMPP\", \"campfire\", \"slack\")\n * @property {string} service.domain - Domain of the chat service (e.g. \"irc.libera.chat\", \"kosmos.chat\")\n */\n this.service = options.service;\n\n /**\n * @property {string} channelName - Name of channel (e.g. \"#kosmos\")\n */\n this.channelName = options.channelName;\n\n /**\n * @property {string} channelType - Type of channel (\"room\" or \"person\")\n */\n this.channelType = options.channelType;\n\n /**\n * @property {string} date - Gregorian calendar date of the archive's content\n */\n this.date = options.date;\n\n /**\n * @property {boolean} isPublic - `true` for public archives, `false` for private ones\n */\n this.isPublic = options.isPublic || false;\n\n /**\n * @property {object} parsedDate - Contains padded year, month and day of date\n * @property {string} year\n * @property {string} month\n * @property {string} day\n */\n this.parsedDate = parseDate(this.date);\n\n /**\n * @property {string} dateId - Date string in the form of YYYY/MM/DD\n */\n this.dateId = this.parsedDate.year+'/'+this.parsedDate.month+'/'+this.parsedDate.day;\n\n /**\n * @property {string} channelPath - Base directory path of the channel archives\n */\n if (this.channelType === \"room\") {\n // Normal chatroom\n const channelName = this.channelName.replace(/#/,'');\n this.channelPath = `${this.service.domain}/channels/${channelName}`;\n } else {\n // User direct messages\n this.channelPath = `${this.service.domain}/users/${this.channelName}`;\n }\n\n /**\n * @property {string} path - Path of the archive document\n */\n this.path = `${this.channelPath}/${this.dateId}`;\n\n /**\n * @property {string} metaPath - Path of the channel's metadata document\n */\n this.metaPath = `${this.channelPath}/meta`;\n\n /**\n * @property {object} client - Public or private remoteStorgage.js BaseClient\n */\n this.client = this.isPublic ? publicClient : privateClient;\n\n /**\n * @property {string} previous - Date of previous log file as YYYY/MM/DD\n */\n this.previous = options.previous;\n\n /**\n * @property {string} next - Date of next log file as YYYY/MM/DD\n */\n this.next = options.next;\n }\n\n /*\n * @param {object} message\n * @param {string} message.timestamp - Timestamp of the message\n * @param {string} message.from - The sender of the message\n * @param {string} message.text - The message itself\n * @param {string} message.type - Type of message (one of text, join, leave, action)\n * @param {string} [message.id] - Unique ID of message. TODO implement\n *\n * @returns {Promise}\n */\n addMessage (message) {\n if (this.isPublic && !this.channelName.match(/^#/)) {\n return Promise.resolve(false);\n }\n\n message.type = message.type || 'text';\n\n return this.client.getObject(this.path).then((archive) => {\n if (typeof archive === 'object') {\n return this._updateDocument(archive, message);\n } else {\n return this._createDocument(message);\n }\n });\n }\n\n /*\n * Like , but for multiple messages at once. Useful for bulk\n * imports of messages.\n *\n * @param {Array} messages - Array of message objects (see params for addMessage)\n * @param {boolean} overwrite - If true, creates a new archive file and overwrites the old one. Defaults to false.\n *\n * @returns {Promise}\n */\n addMessages (messages, overwrite) {\n if (this.isPublic && !this.channelName.match(/^#/)) {\n return Promise.resolve(false);\n }\n\n overwrite = overwrite || false;\n\n messages.forEach(function(message) {\n message.type = message.type || 'text';\n });\n\n if (overwrite) {\n return this._createDocument(messages);\n } else {\n return this.client.getObject(this.path).then((archive) => {\n if (typeof archive === 'object') {\n return this._updateDocument(archive, messages);\n } else {\n return this._createDocument(messages);\n }\n });\n }\n }\n\n /*\n * Deletes the entire archive document from storage\n *\n * @returns {Promise}\n */\n remove () {\n // TODO when removing, if previous is set, but not next, it means the\n // removed file is the last archive. Thus, set \"last\" to previous file.\n return this.client.remove(this.path);\n }\n\n /*\n * Updates and writes an existing archive document\n *\n * @returns {Promise}\n *\n * @private\n */\n async _updateDocument (archive, messages) {\n console.debug('[chat-messages] Updating archive document');\n\n if (Array.isArray(messages)) {\n messages.forEach(function(message) {\n archive.today.messages.push(message);\n });\n } else {\n archive.today.messages.push(messages);\n }\n\n return this._sync(archive);\n }\n\n /*\n * Creates and writes a new archive document\n *\n * @returns {Promise}\n *\n * @private\n */\n async _createDocument (messages) {\n console.debug('[chat-messages] Creating new archive document');\n const archive = this._buildArchiveObject();\n\n if (Array.isArray(messages)) {\n messages.forEach(message => {\n archive.today.messages.push(message);\n });\n } else {\n archive.today.messages.push(messages);\n }\n\n if (this.previous || this.next) {\n // The app is handling previous/next keys itself\n // That includes setting 'next' in the previous log file\n if (this.previous) { archive.today.previous = this.previous; }\n if (this.next) { archive.today.next = this.next; }\n } else {\n // Find and update previous archive, set 'previous' on this one\n const previous = await this._updatePreviousArchive();\n if (typeof previous === 'object') {\n archive.today.previous = previous.today['@id'];\n }\n }\n\n await this._sync(archive);\n\n // TODO only write meta doc if argument is set on addMessages. This way\n // we can avoid race conditions when syncing remote chat messages all at\n // once for multiple days\n await this._updateArchiveMetaDocument();\n\n return;\n }\n\n /*\n * Builds the object to be stored in remote storage\n *\n * @returns {object}\n *\n * @private\n */\n _buildArchiveObject () {\n const roomName = this.channelName.replace(/#/,'');\n\n const archive = {\n \"@id\": \"chat-messages/\"+this.service.domain+\"/channels/\"+roomName+\"/\",\n \"@type\": \"ChatChannel\",\n \"service\": this.service,\n \"name\": this.channelName,\n \"type\": this.channelType,\n \"today\": {\n \"@id\": this.dateId,\n \"@type\": \"ChatLog\",\n \"messageType\": \"InstantMessage\",\n \"messages\": []\n }\n };\n\n switch (this.service.protocol) {\n case 'IRC':\n if (!this.channelName.match(/^#/)) {\n archive[\"@id\"] = \"chat-messages/\"+this.service.domain+\"/users/\"+this.channelName+\"/\";\n }\n break;\n case 'XMPP':\n // XMPP-specific adjustments\n break;\n }\n\n return archive;\n }\n\n /*\n * Finds the previous archive document and updates its today.next value\n *\n * @returns {boolean|Promise}\n *\n * @private\n */\n _updatePreviousArchive () {\n return this._findPreviousArchive().then((archive) => {\n if (typeof archive === 'object' && archive.today) {\n archive.today.next = this.dateId;\n const path = this.path.substring(0, this.path.length-this.dateId.length)+archive.today['@id'];\n\n return this.client.storeObject('daily-archive', path, archive).then(() => {\n console.debug('[chat-messages] Previous archive written to remote storage at', path);\n return archive;\n });\n } else {\n console.debug('[chat-messages] Previous archive not found');\n return false;\n }\n });\n }\n\n /*\n * Returns the previous archive document\n *\n * @returns {Promise}\n *\n * @private\n */\n _findPreviousArchive () {\n const monthPath = this.path.substring(0, this.path.length-2);\n const yearPath = this.path.substring(0, this.path.length-5);\n const basePath = this.path.substring(0, this.path.length-10);\n\n return this.client.getListing(monthPath).then((listing) => {\n const days = Object.keys(listing).map((i) => parseInt(i)).map((i) => {\n return (i < parseInt(this.parsedDate.day)) ? i : null;\n }).filter(function(i){ return i != null; });\n\n if (days.length > 0) {\n const day = pad(Math.max(...days).toString());\n return this.client.getObject(monthPath+day);\n }\n\n // Find last day in previous month\n return this.client.getListing(yearPath).then((listing) => {\n const months = Object.keys(listing).map((i) => parseInt(i.substr(0,2))).map((i) => {\n return (i < parseInt(this.parsedDate.month)) ? i : null;\n }).filter(function(i){ return i != null; });\n\n if (months.length > 0) {\n const month = pad(Math.max(...months).toString());\n\n return this.client.getListing(yearPath+month+'/').then((listing) => {\n const days = Object.keys(listing).map((i) => parseInt(i));\n const day = pad(Math.max(...days).toString());\n return this.client.getObject(yearPath+month+'/'+day);\n });\n } else {\n // Find last month and day in previous year\n return this.client.getListing(basePath).then((listing) => {\n\n const years = Object.keys(listing).map((i) => parseInt(i.substr(0,4))).map((i) => {\n return (i < parseInt(this.parsedDate.year)) ? i : null;\n }).filter(function(i){ return i != null; });\n\n if (years.length > 0) {\n const year = Math.max(...years).toString();\n\n return this.client.getListing(basePath+year+'/').then((listing) => {\n const months = Object.keys(listing).map((i) => parseInt(i.substr(0,2)));\n const month = pad(Math.max(...months).toString());\n\n return this.client.getListing(basePath+year+'/'+month+'/').then((listing) => {\n const days = Object.keys(listing).map((i) => parseInt(i));\n const day = pad(Math.max(...days).toString());\n return this.client.getObject(basePath+year+'/'+month+'/'+day);\n });\n });\n } else {\n return false;\n }\n });\n }\n });\n });\n }\n\n async _updateArchiveMetaDocument () {\n const meta = await this.client.getObject(this.metaPath);\n if (typeof meta !== 'object') {\n return this._createArchiveMetaDocument();\n }\n\n // Only update document if current date is newer than known \"last\"\n if (Date.parse(meta.last.replace('/','-')) > Date.parse(this.date)) {\n console.debug('[chat-messages]', 'Updating meta document for channel');\n meta.last = this.dateId;\n await this.client.storeObject('daily-archive-meta', this.metaPath, meta);\n }\n\n return;\n }\n\n async _createArchiveMetaDocument () {\n console.debug('[chat-messages]', 'Creating new meta document for channel');\n // When creating a new meta doc, we need to find the oldest archive,\n // because older versions of the module did not write a meta doc.\n const first = await this._findFirstArchive();\n const roomName = this.channelName.replace(/#/,'');\n\n const meta = {\n '@id': `chat-messages/${this.service.domain}/channels/${roomName}/meta`,\n '@type': 'ChatChannelMeta',\n first: first,\n last: this.dateId // TODO might have to search for last?\n };\n\n return this.client.storeObject('daily-archive-meta', this.metaPath, meta)\n .then(() => console.debug('[chat-messages]', 'Meta document written to remote storage'))\n .catch(e => {\n console.log('[chat-messages]', `Failed to store ${this.metaPath}`);\n console.error(e);\n });\n }\n\n async _findFirstArchive () {\n console.debug('[chat-messages]', 'Finding first archive for channel');\n const years = await this.client.getListing(`${this.channelPath}/`);\n const year = lowestNumberInListing(years);\n const months = await this.client.getListing(`${this.channelPath}/${year}/`);\n const month = lowestNumberInListing(months);\n const days = await this.client.getListing(`${this.channelPath}/${year}/${pad(month)}/`);\n const day = lowestNumberInListing(days);\n const firstId = `${year}/${pad(month)}/${pad(day)}`;\n console.debug('[chat-messages]', 'First is', firstId);\n return firstId;\n }\n\n /*\n * Write archive document\n *\n * @returns {Promise}\n *\n * @private\n */\n async _sync (obj) {\n console.debug(`[chat-messages] Writing archive object with ${obj.today.messages.length} messages`);\n\n return this.client.storeObject('daily-archive', this.path, obj).then(function(){\n console.debug('[chat-messages] Archive written to remote storage');\n return true;\n },function(error){\n console.warn('[chat-messages] Error trying to store object', error);\n return error;\n });\n }\n };\n\n return {\n exports: {\n DailyArchive,\n privateClient,\n publicClient\n }\n };\n};\n\nexport default { name: 'chat-messages', builder: ChatMessages };\n"],"names":["root","factory","exports","module","define","amd","this","runtime","undefined","Op","Object","prototype","hasOwn","hasOwnProperty","$Symbol","Symbol","iteratorSymbol","iterator","asyncIteratorSymbol","asyncIterator","toStringTagSymbol","toStringTag","obj","key","value","defineProperty","enumerable","configurable","writable","err","wrap","innerFn","outerFn","self","tryLocsList","protoGenerator","Generator","generator","create","context","Context","_invoke","state","GenStateSuspendedStart","method","arg","GenStateExecuting","Error","GenStateCompleted","doneResult","delegate","delegateResult","maybeInvokeDelegate","ContinueSentinel","sent","_sent","dispatchException","abrupt","record","tryCatch","type","done","GenStateSuspendedYield","makeInvokeMethod","fn","call","GeneratorFunction","GeneratorFunctionPrototype","IteratorPrototype","getProto","getPrototypeOf","NativeIteratorPrototype","values","Gp","defineIteratorMethods","forEach","AsyncIterator","PromiseImpl","invoke","resolve","reject","result","__await","then","unwrapped","error","previousPromise","callInvokeWithMethodAndArg","TypeError","info","resultName","next","nextLoc","pushTryEntry","locs","entry","tryLoc","catchLoc","finallyLoc","afterLoc","tryEntries","push","resetTryEntry","completion","reset","iterable","iteratorMethod","isNaN","length","i","displayName","isGeneratorFunction","genFun","ctor","constructor","name","mark","setPrototypeOf","__proto__","awrap","async","Promise","iter","keys","object","reverse","pop","skipTempReset","prev","charAt","slice","stop","rootRecord","rval","exception","handle","loc","caught","hasCatch","hasFinally","finallyEntry","complete","finish","thrown","delegateYield","regeneratorRuntime","accidentalStrictMode","globalThis","Function","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","__webpack_modules__","n","getter","__esModule","d","a","definition","o","get","prop","pad","num","String","lowestNumberInListing","items","map","parseInt","filter","Number","sort","builder","privateClient","publicClient","archiveSchema","declareType","archiveMetaSchema","DailyArchive","options","isPublic","channelType","service","protocol","domain","channelName","date","Date","parsedDate","year","getUTCFullYear","month","getUTCMonth","day","getUTCDate","dateId","replace","channelPath","path","metaPath","client","previous","message","match","getObject","archive","_updateDocument","_createDocument","messages","overwrite","remove","console","debug","Array","isArray","today","_sync","_buildArchiveObject","_updatePreviousArchive","_updateArchiveMetaDocument","roomName","_findPreviousArchive","substring","storeObject","monthPath","yearPath","basePath","getListing","listing","days","Math","max","toString","months","substr","years","meta","_createArchiveMetaDocument","parse","last","_findFirstArchive","first","e","log","firstId","warn"],"sourceRoot":""} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index de0c8b9..8f90599 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "remotestorage-module-chat-messages", - "version": "2.0.0", + "version": "2.1.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index fd34f55..7f42002 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "remotestorage-module-chat-messages", - "version": "2.0.0", + "version": "2.1.0", "description": "Stores chat messages in daily archive files", "main": "./dist/build.js", "scripts": {