New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@yomo/react-cursor-chat

Package Overview
Dependencies
Maintainers
4
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@yomo/react-cursor-chat - npm Package Compare versions

Comparing version 0.1.7 to 0.1.8

dist/apricot-yellow.css

4

dist/cursor/other.d.ts

@@ -20,4 +20,4 @@ import Presence from '@yomo/presencejs';

private subscribeEnter;
onLeave(): void;
onEnter(): void;
onLeave(id: string): void;
onEnter(id: string): void;
}
import React from 'react';
import './styles/apricot-yellow.css';
import './styles/hairy-green.css';
import './styles/dracula.css';

@@ -3,0 +5,0 @@ declare const _default: React.MemoExoticComponent<({ presenceURL, presenceAuthEndpoint, room, showLatency, name, avatar, colors, }: {

import Me from '../cursor/me';
import Other from '../cursor/other';
declare const useOnlineCursor: ({ presenceURL, presenceAuthEndpoint, room, name, avatar, color, }: {
declare const useOnlineCursor: ({ presenceURL, presenceAuthEndpoint, room, name, avatar, color, onOtherEntry, onOtherLeave, }: {
presenceURL: string;

@@ -10,2 +10,4 @@ presenceAuthEndpoint: string;

color?: string | undefined;
onOtherEntry?: (() => void) | undefined;
onOtherLeave?: (() => void) | undefined;
}) => {

@@ -12,0 +14,0 @@ me: Me | null;

@@ -1149,3 +1149,3 @@ 'use strict';

})).subscribe(function () {
_this3.onLeave();
_this3.onLeave(_this3.id);
});

@@ -1160,11 +1160,13 @@ };

})).subscribe(function () {
_this4.onEnter();
_this4.onEnter(_this4.id);
});
};
} // @ts-ignore
;
_proto.onLeave = function onLeave() {
_proto.onLeave = function onLeave(id) {
throw new Error('Method not implemented.');
};
} // @ts-ignore
;
_proto.onEnter = function onEnter() {
_proto.onEnter = function onEnter(id) {
throw new Error('Method not implemented.');

@@ -1182,3 +1184,7 @@ };

avatar = _ref.avatar,
color = _ref.color;
color = _ref.color,
_ref$onOtherEntry = _ref.onOtherEntry,
onOtherEntry = _ref$onOtherEntry === void 0 ? function () {} : _ref$onOtherEntry,
_ref$onOtherLeave = _ref.onOtherLeave,
onOtherLeave = _ref$onOtherLeave === void 0 ? function () {} : _ref$onOtherLeave;

@@ -1229,2 +1235,4 @@ var _useState = React.useState(null),

var other = new Other(data);
other.onLeave = onOtherLeave;
other.onEnter = onOtherEntry;
other.goOnline(yomo);

@@ -1260,2 +1268,4 @@ cursorMap.set(other.id, other);

var other = new Other(data);
other.onLeave = onOtherLeave;
other.onEnter = onOtherEntry;
other.goOnline(yomo);

@@ -1319,4 +1329,4 @@ cursorMap.set(other.id, other);

}, React__default.createElement("path", {
"fill-rule": "evenodd",
"clip-rule": "evenodd",
fillRule: "evenodd",
clipRule: "evenodd",
d: "M0 0L20 7.14286L11.0948 11.1194L7.14286 20L0 0Z"

@@ -1369,4 +1379,4 @@ }));

}, React__default.createElement("path", {
"fill-rule": "evenodd",
"clip-rule": "evenodd",
fillRule: "evenodd",
clipRule: "evenodd",
d: "M3.99993 0C4.99609 0 5.99332 0.367541 6.77237 1.10262C8.41307 2.65187 8.37032 5.28494 6.87655 6.95267L6.72235 7.11615L4.43096 9.41998C4.31176 9.53999 4.15531 9.6 3.99886 9.6C3.87371 9.6 3.74855 9.5616 3.64246 9.48479L3.56677 9.41998L1.27751 7.11508C-0.365737 5.46061 -0.467907 2.70352 1.22855 1.10262C2.00654 0.367541 3.00377 0 3.99993 0ZM3.99993 1C3.22932 1 2.48657 1.28975 1.91488 1.82992C0.711907 2.96512 0.701036 4.96169 1.84937 6.26336L1.98702 6.41038L3.999 8.436L6.01284 6.41146C7.2978 5.11772 7.33439 3.00868 6.08609 1.82996C5.51361 1.28979 4.77055 1 3.99993 1ZM4 2C5.10238 2 6 2.89762 6 4C6 5.10238 5.10238 6 4 6C2.89762 6 2 5.10238 2 4C2 2.89762 2.89762 2 4 2ZM4 3C3.4499 3 3 3.4499 3 4C3 4.5501 3.4499 5 4 5C4.5501 5 5 4.5501 5 4C5 3.4499 4.5501 3 4 3Z",

@@ -1373,0 +1383,0 @@ fill: "white"

@@ -1,2 +0,2 @@

"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react"),n=e(t),r=require("rxjs/operators"),o=e(require("@yomo/presencejs")),i=require("rxjs");function a(e,t,n,r,o,i,a){try{var c=e[i](a),s=c.value}catch(e){return void n(e)}c.done?t(s):Promise.resolve(s).then(r,o)}function c(e){return function(){var t=this,n=arguments;return new Promise((function(r,o){var i=e.apply(t,n);function c(e){a(i,r,o,c,s,"next",e)}function s(e){a(i,r,o,c,s,"throw",e)}c(void 0)}))}}function s(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,(Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var u,l=(function(e){var t=function(e){var t=Object.prototype,n=t.hasOwnProperty,r="function"==typeof Symbol?Symbol:{},o=r.iterator||"@@iterator",i=r.asyncIterator||"@@asyncIterator",a=r.toStringTag||"@@toStringTag";function c(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,n){return e[t]=n}}function s(e,t,n,r){var o=Object.create((t&&t.prototype instanceof f?t:f).prototype),i=new L(r||[]);return o._invoke=function(e,t,n){var r="suspendedStart";return function(o,i){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===o)throw i;return{value:void 0,done:!0}}for(n.method=o,n.arg=i;;){var a=n.delegate;if(a){var c=g(a,n);if(c){if(c===l)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var s=u(e,t,n);if("normal"===s.type){if(r=n.done?"completed":"suspendedYield",s.arg===l)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(r="completed",n.method="throw",n.arg=s.arg)}}}(e,n,i),o}function u(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=s;var l={};function f(){}function h(){}function d(){}var p={};c(p,o,(function(){return this}));var v=Object.getPrototypeOf,m=v&&v(v(_([])));m&&m!==t&&n.call(m,o)&&(p=m);var y=d.prototype=f.prototype=Object.create(p);function b(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function w(e,t){var r;this._invoke=function(o,i){function a(){return new t((function(r,a){!function r(o,i,a,c){var s=u(e[o],e,i);if("throw"!==s.type){var l=s.arg,f=l.value;return f&&"object"==typeof f&&n.call(f,"__await")?t.resolve(f.__await).then((function(e){r("next",e,a,c)}),(function(e){r("throw",e,a,c)})):t.resolve(f).then((function(e){l.value=e,a(l)}),(function(e){return r("throw",e,a,c)}))}c(s.arg)}(o,i,r,a)}))}return r=r?r.then(a,a):a()}}function g(e,t){var n=e.iterator[t.method];if(void 0===n){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,g(e,t),"throw"===t.method))return l;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var r=u(n,e.iterator,t.arg);if("throw"===r.type)return t.method="throw",t.arg=r.arg,t.delegate=null,l;var o=r.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,l):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,l)}function x(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function E(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function L(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(x,this),this.reset(!0)}function _(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,i=function t(){for(;++r<e.length;)if(n.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return i.next=i}}return{next:M}}function M(){return{value:void 0,done:!0}}return h.prototype=d,c(y,"constructor",d),c(d,"constructor",h),h.displayName=c(d,a,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===h||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,d):(e.__proto__=d,c(e,a,"GeneratorFunction")),e.prototype=Object.create(y),e},e.awrap=function(e){return{__await:e}},b(w.prototype),c(w.prototype,i,(function(){return this})),e.AsyncIterator=w,e.async=function(t,n,r,o,i){void 0===i&&(i=Promise);var a=new w(s(t,n,r,o),i);return e.isGeneratorFunction(n)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},b(y),c(y,a,"Generator"),c(y,o,(function(){return this})),c(y,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=[];for(var n in e)t.push(n);return t.reverse(),function n(){for(;t.length;){var r=t.pop();if(r in e)return n.value=r,n.done=!1,n}return n.done=!0,n}},e.values=_,L.prototype={constructor:L,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(E),!e)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(n,r){return a.type="throw",a.arg=e,t.next=n,r&&(t.method="next",t.arg=void 0),!!r}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return r("end");if(i.tryLoc<=this.prev){var c=n.call(i,"catchLoc"),s=n.call(i,"finallyLoc");if(c&&s){if(this.prev<i.catchLoc)return r(i.catchLoc,!0);if(this.prev<i.finallyLoc)return r(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return r(i.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return r(i.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=e,a.arg=t,i?(this.method="next",this.next=i.finallyLoc,l):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),l},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),E(n),l}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var o=r.arg;E(n)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:_(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),l}},e}(e.exports);try{regeneratorRuntime=t}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=t:Function("r","regeneratorRuntime = r")(t)}}(u={exports:{}}),u.exports),f=function(){function e(e,t,n,r,o,i){this.id=e,this.x=t,this.y=n,this.name=r,this.avatar=o,this.color=i}var t=e.prototype;return t.move=function(e,t){this.x=e,this.y=t},t.onMove=function(e){},t.onGetLatency=function(e){},t.subscribeLatency=function(e){var t=this;return e.on$("latency").subscribe((function(e){e.id===t.id&&t.onGetLatency(e)}))},e}(),h=function(){return window.getViewportSize||(window.onresize=function(){window.getViewportSize={width:window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth,height:window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight}},window.onresize()),window.getViewportSize},d=function(e){function t(t){var n,r=t.name,o=t.avatar,i=t.color;return(n=e.call(this,t.id,t.x,t.y,void 0===r?"":r,void 0===o?"":o,void 0===i?"":i)||this).subscription=n.subscribeMousemove(),n}s(t,e);var n=t.prototype;return n.goOnline=function(t){this.yomo=t,this.online(t);var n=this.subscribeOnline(t),r=this.subscribeMousePosition(t),o=e.prototype.subscribeLatency.call(this,t),i=this.subscribeVisibility(t);this.subscription.add(n),this.subscription.add(r),this.subscription.add(o),this.subscription.add(i)},n.goOffline=function(){var e=c(l.mark((function e(){return l.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.yomo&&this.yomo.send("offline",{id:this.id}),this.subscription&&this.subscription.unsubscribe(),e.next=4,new Promise((function(e){setTimeout(e,500)}));case 4:return e.abrupt("return",e.sent);case 5:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),n.sendMessage=function(e){this.yomo&&this.yomo.send("text",{id:this.id,message:e})},n.online=function(e){e.send("online",{id:this.id,x:0,y:0,name:this.name,avatar:this.avatar,color:this.color})},n.subscribeOnline=function(e){var t=this;return e.on$("online").subscribe((function(){e.send("sync",{id:t.id,x:t.x,y:t.y,name:t.name,avatar:t.avatar,color:t.color})}))},n.subscribeMousemove=function(){var t=this;return i.fromEvent(document,"mousemove").subscribe((function(n){var r=n.clientX,o=n.clientY;e.prototype.move.call(t,r,o),t.onMove({mouseX:r,mouseY:o})}))},n.subscribeMousePosition=function(e){var t=this;return i.fromEvent(document,"mousemove").pipe(r.map((function(e){var n,r,o=(n=e.clientY,{scaleX:e.clientX/(r=h()).width,scaleY:n/r.height});return{id:t.id,x:o.scaleX,y:o.scaleY}}))).subscribe((function(t){e.send("movement",t)}))},n.subscribeVisibility=function(e){var t=this;return i.fromEvent(document,"visibilitychange").pipe(r.map((function(){return{event:document.hidden?"leave":"enter"}}))).subscribe((function(n){e.send(n.event,{id:t.id})}))},t}(f),p=function(e){function t(t){var n=t.name,r=t.avatar,o=t.color;return e.call(this,t.id,t.x,t.y,void 0===n?"":n,void 0===r?"":r,void 0===o?"":o)||this}s(t,e);var n=t.prototype;return n.goOnline=function(t){this.subscription=this.subscribeMovement(t);var n=this.subscribeTextMessage(t),r=e.prototype.subscribeLatency.call(this,t),o=this.subscribeLeave(t),i=this.subscribeEnter(t);this.subscription.add(n),this.subscription.add(r),this.subscription.add(o),this.subscription.add(i)},n.unsubscribe=function(){this.subscription&&this.subscription.unsubscribe()},n.onTextMessage=function(e){},n.subscribeTextMessage=function(e){var t=this;return e.on$("text").pipe(r.filter((function(e){return e.id===t.id}))).subscribe((function(e){t.onTextMessage(e.message)}))},n.subscribeMovement=function(t){var n=this;return t.on$("movement").pipe(r.filter((function(e){return e.id===n.id})),r.map((function(e){return t=e.y,{mouseX:e.x*(n=h()).width,mouseY:t*n.height};var t,n}))).subscribe((function(t){var r=t.mouseX,o=t.mouseY;e.prototype.move.call(n,r,o),n.onMove({mouseX:r,mouseY:o})}))},n.subscribeLeave=function(e){var t=this;return e.on$("leave").pipe(r.filter((function(e){return e.id===t.id}))).subscribe((function(){t.onLeave()}))},n.subscribeEnter=function(e){var t=this;return e.on$("enter").pipe(r.filter((function(e){return e.id===t.id}))).subscribe((function(){t.onEnter()}))},n.onLeave=function(){throw new Error("Method not implemented.")},n.onEnter=function(){throw new Error("Method not implemented.")},t}(f),v=function(e){var n=e.presenceURL,i=e.presenceAuthEndpoint,a=e.room,s=e.name,u=e.avatar,f=e.color,h=t.useState(null),v=h[0],m=h[1],y=t.useState(new Map),b=y[0],w=y[1],g=t.useState([]),x=g[0],E=g[1];return t.useEffect((function(){var e="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})),t=new d({id:e,x:0,y:0,name:s||"",avatar:u||"",color:f||""});m(t);var h=new o(n,{auth:{type:"token",endpoint:i}});h.on("connected",(function(){a&&h.toRoom(a),h.on$("online").pipe(r.filter((function(t){return t.id!==e}))).subscribe((function(e){w((function(t){if(t.has(e.id))return t;var n=new Map(t),r=new p(e);return r.goOnline(h),n.set(r.id,r),n}))})),h.on("offline",(function(e){w((function(t){var n=new Map(t),r=n.get(e.id);return r&&r.unsubscribe(),n.delete(e.id),n}))})),h.on$("sync").pipe(r.filter((function(t){return t.id!==e}))).subscribe((function(e){w((function(t){if(t.has(e.id))return t;var n=new Map(t),r=new p(e);return r.goOnline(h),n.set(r.id,r),n}))})),t.goOnline(h)}));var v=function(){var e=c(l.mark((function e(){return l.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.goOffline();case 2:h.close();case 3:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();return window.addEventListener("unload",v),function(){v(),window.removeEventListener("unload",v)}}),[a]),t.useEffect((function(){E(Array.from(b.values()))}),[b]),{me:v,others:x}};function m(e){var r=e.color;return t.useMemo((function(){return n.createElement("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:r,xmlns:"http://www.w3.org/2000/svg"},n.createElement("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M0 0L20 7.14286L11.0948 11.1194L7.14286 20L0 0Z"}))}),[r])}var y=function(e){var r=e.cursor,o=e.showLatency,i=t.useState({meshId:"",latency:0}),a=i[0],c=i[1];return t.useEffect((function(){o?r.onGetLatency=function(e){c({meshId:e.meshId,latency:e.latency})}:(r.onGetLatency=function(e){},c({meshId:"",latency:0}))}),[o]),0===a.latency?null:n.createElement("div",{className:"online-cursor-wrapper__latency-box"}," ",n.createElement("svg",{width:"8",height:"10",viewBox:"0 0 8 10",fill:"white",xmlns:"http://www.w3.org/2000/svg"},n.createElement("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M3.99993 0C4.99609 0 5.99332 0.367541 6.77237 1.10262C8.41307 2.65187 8.37032 5.28494 6.87655 6.95267L6.72235 7.11615L4.43096 9.41998C4.31176 9.53999 4.15531 9.6 3.99886 9.6C3.87371 9.6 3.74855 9.5616 3.64246 9.48479L3.56677 9.41998L1.27751 7.11508C-0.365737 5.46061 -0.467907 2.70352 1.22855 1.10262C2.00654 0.367541 3.00377 0 3.99993 0ZM3.99993 1C3.22932 1 2.48657 1.28975 1.91488 1.82992C0.711907 2.96512 0.701036 4.96169 1.84937 6.26336L1.98702 6.41038L3.999 8.436L6.01284 6.41146C7.2978 5.11772 7.33439 3.00868 6.08609 1.82996C5.51361 1.28979 4.77055 1 3.99993 1ZM4 2C5.10238 2 6 2.89762 6 4C6 5.10238 5.10238 6 4 6C2.89762 6 2 5.10238 2 4C2 2.89762 2.89762 2 4 2ZM4 3C3.4499 3 3 3.4499 3 4C3 4.5501 3.4499 5 4 5C4.5501 5 5 4.5501 5 4C5 3.4499 4.5501 3 4 3Z",fill:"white"}))," ",n.createElement("span",null,a.meshId)," ",n.createElement("span",null,a.latency,"ms")," ")},b=function(e,n){var r=n||t.useRef(null);return t.useEffect((function(){var t=function(e){r.current&&r.current.style.setProperty("transform","translate3d("+e.mouseX+"px, "+e.mouseY+"px, 0)")};t({mouseX:e.x,mouseY:e.y}),e.onMove=function(e){t(e)}}),[e]),r},w=function(e){var r=e.cursor,o=e.showLatency,i=b(r);!function(e,n){var r=n||t.useRef(null);t.useEffect((function(){var t=function(e){r.current&&r.current.style.setProperty("opacity",String(e))};e.onLeave=function(){t(.5)},e.onEnter=function(){t(1)}}),[e])}(r,i);var a=t.useState(""),c=a[0],s=a[1];return t.useEffect((function(){r.onTextMessage=function(e){s(e)}}),[]),t.useMemo((function(){return n.createElement("div",{className:"online-cursor-wrapper__cursor",ref:i},n.createElement(m,{color:r.color}),n.createElement("div",{className:"online-cursor-wrapper__tail-box",style:{borderRadius:c?35:15,borderTopLeftRadius:c?10:15,backgroundColor:""+r.color}},n.createElement("div",{className:"online-cursor-wrapper__user"},r.avatar&&n.createElement("img",{className:"online-cursor-wrapper__avatar",src:r.avatar,alt:"avatar"}),r.name&&n.createElement("span",{className:"online-cursor-wrapper__name"},r.name),n.createElement(y,{cursor:r,showLatency:o})),n.createElement("div",{style:{height:"1px",width:"100%",visibility:"hidden",background:"transparent"}}),c&&n.createElement("div",{className:"online-cursor-wrapper__text"},c)))}),[c,o])},g=function(e){var t=e.showLatency,r=void 0!==t&&t;return n.createElement(n.Fragment,null,e.others.map((function(e){return n.createElement(w,{key:e.id,cursor:e,showLatency:r})})))},x=function(e){var r=e.cursor,o=e.showLatency,i=b(r),a=t.useState(!1),c=a[0],s=a[1],u=t.useState(""),l=u[0],f=u[1],h=t.useCallback((function(e){var t=e.target.value;"/"!==t&&(f(t),r.sendMessage(t))}),[]);return t.useEffect((function(){var e=function(e){"Slash"===e.code&&s(!0),"Escape"===e.code&&(s(!1),f(""),r.sendMessage(""))};return document.addEventListener("keydown",e),function(){document.removeEventListener("keydown",e)}}),[]),t.useMemo((function(){return n.createElement("div",{className:"online-cursor-wrapper__cursor",ref:i},n.createElement(m,{color:r.color}),n.createElement("div",{className:"online-cursor-wrapper__tail-box",style:{borderRadius:c?35:15,borderTopLeftRadius:c?10:15,backgroundColor:""+r.color}},n.createElement("div",{className:"online-cursor-wrapper__user"},r.avatar&&n.createElement("img",{className:"online-cursor-wrapper__avatar",src:r.avatar,alt:"avatar"}),r.name&&n.createElement("span",{className:"online-cursor-wrapper__name"},r.name),n.createElement(y,{cursor:r,showLatency:o})),n.createElement("div",{style:{height:"1px",width:"100%",visibility:"hidden",background:"transparent"}}),c&&n.createElement("div",{className:"online-cursor-wrapper__input-box"},n.createElement("span",null,l),n.createElement("input",{autoFocus:!0,placeholder:"Say something",value:l,onChange:h}))))}),[c,l,o])};exports.default=t.memo((function(e){var t=e.showLatency,r=void 0!==t&&t,o=e.colors,i=void 0===o?["#604CFF","#FF0BC6","#00C0ED","#FFAB24","#F52768"]:o,a=v({presenceURL:e.presenceURL,presenceAuthEndpoint:e.presenceAuthEndpoint,room:e.room,name:e.name,avatar:e.avatar,color:""+i[Math.floor(Math.random()*i.length)]}),c=a.me;return c?n.createElement("div",{className:"online-cursor-wrapper"},n.createElement(g,{others:a.others,showLatency:r}),n.createElement(x,{cursor:c,showLatency:r})):null})),exports.useOnlineCursor=v,exports.useRenderPosition=b;
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react"),n=e(t),r=require("rxjs/operators"),o=e(require("@yomo/presencejs")),i=require("rxjs");function a(e,t,n,r,o,i,a){try{var c=e[i](a),s=c.value}catch(e){return void n(e)}c.done?t(s):Promise.resolve(s).then(r,o)}function c(e){return function(){var t=this,n=arguments;return new Promise((function(r,o){var i=e.apply(t,n);function c(e){a(i,r,o,c,s,"next",e)}function s(e){a(i,r,o,c,s,"throw",e)}c(void 0)}))}}function s(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,(Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var u,l=(function(e){var t=function(e){var t=Object.prototype,n=t.hasOwnProperty,r="function"==typeof Symbol?Symbol:{},o=r.iterator||"@@iterator",i=r.asyncIterator||"@@asyncIterator",a=r.toStringTag||"@@toStringTag";function c(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,n){return e[t]=n}}function s(e,t,n,r){var o=Object.create((t&&t.prototype instanceof f?t:f).prototype),i=new L(r||[]);return o._invoke=function(e,t,n){var r="suspendedStart";return function(o,i){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===o)throw i;return{value:void 0,done:!0}}for(n.method=o,n.arg=i;;){var a=n.delegate;if(a){var c=g(a,n);if(c){if(c===l)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var s=u(e,t,n);if("normal"===s.type){if(r=n.done?"completed":"suspendedYield",s.arg===l)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(r="completed",n.method="throw",n.arg=s.arg)}}}(e,n,i),o}function u(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=s;var l={};function f(){}function h(){}function d(){}var p={};c(p,o,(function(){return this}));var v=Object.getPrototypeOf,m=v&&v(v(_([])));m&&m!==t&&n.call(m,o)&&(p=m);var y=d.prototype=f.prototype=Object.create(p);function b(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function w(e,t){var r;this._invoke=function(o,i){function a(){return new t((function(r,a){!function r(o,i,a,c){var s=u(e[o],e,i);if("throw"!==s.type){var l=s.arg,f=l.value;return f&&"object"==typeof f&&n.call(f,"__await")?t.resolve(f.__await).then((function(e){r("next",e,a,c)}),(function(e){r("throw",e,a,c)})):t.resolve(f).then((function(e){l.value=e,a(l)}),(function(e){return r("throw",e,a,c)}))}c(s.arg)}(o,i,r,a)}))}return r=r?r.then(a,a):a()}}function g(e,t){var n=e.iterator[t.method];if(void 0===n){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,g(e,t),"throw"===t.method))return l;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var r=u(n,e.iterator,t.arg);if("throw"===r.type)return t.method="throw",t.arg=r.arg,t.delegate=null,l;var o=r.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,l):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,l)}function x(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function E(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function L(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(x,this),this.reset(!0)}function _(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,i=function t(){for(;++r<e.length;)if(n.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return i.next=i}}return{next:M}}function M(){return{value:void 0,done:!0}}return h.prototype=d,c(y,"constructor",d),c(d,"constructor",h),h.displayName=c(d,a,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===h||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,d):(e.__proto__=d,c(e,a,"GeneratorFunction")),e.prototype=Object.create(y),e},e.awrap=function(e){return{__await:e}},b(w.prototype),c(w.prototype,i,(function(){return this})),e.AsyncIterator=w,e.async=function(t,n,r,o,i){void 0===i&&(i=Promise);var a=new w(s(t,n,r,o),i);return e.isGeneratorFunction(n)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},b(y),c(y,a,"Generator"),c(y,o,(function(){return this})),c(y,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=[];for(var n in e)t.push(n);return t.reverse(),function n(){for(;t.length;){var r=t.pop();if(r in e)return n.value=r,n.done=!1,n}return n.done=!0,n}},e.values=_,L.prototype={constructor:L,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(E),!e)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(n,r){return a.type="throw",a.arg=e,t.next=n,r&&(t.method="next",t.arg=void 0),!!r}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return r("end");if(i.tryLoc<=this.prev){var c=n.call(i,"catchLoc"),s=n.call(i,"finallyLoc");if(c&&s){if(this.prev<i.catchLoc)return r(i.catchLoc,!0);if(this.prev<i.finallyLoc)return r(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return r(i.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return r(i.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=e,a.arg=t,i?(this.method="next",this.next=i.finallyLoc,l):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),l},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),E(n),l}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var o=r.arg;E(n)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:_(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),l}},e}(e.exports);try{regeneratorRuntime=t}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=t:Function("r","regeneratorRuntime = r")(t)}}(u={exports:{}}),u.exports),f=function(){function e(e,t,n,r,o,i){this.id=e,this.x=t,this.y=n,this.name=r,this.avatar=o,this.color=i}var t=e.prototype;return t.move=function(e,t){this.x=e,this.y=t},t.onMove=function(e){},t.onGetLatency=function(e){},t.subscribeLatency=function(e){var t=this;return e.on$("latency").subscribe((function(e){e.id===t.id&&t.onGetLatency(e)}))},e}(),h=function(){return window.getViewportSize||(window.onresize=function(){window.getViewportSize={width:window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth,height:window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight}},window.onresize()),window.getViewportSize},d=function(e){function t(t){var n,r=t.name,o=t.avatar,i=t.color;return(n=e.call(this,t.id,t.x,t.y,void 0===r?"":r,void 0===o?"":o,void 0===i?"":i)||this).subscription=n.subscribeMousemove(),n}s(t,e);var n=t.prototype;return n.goOnline=function(t){this.yomo=t,this.online(t);var n=this.subscribeOnline(t),r=this.subscribeMousePosition(t),o=e.prototype.subscribeLatency.call(this,t),i=this.subscribeVisibility(t);this.subscription.add(n),this.subscription.add(r),this.subscription.add(o),this.subscription.add(i)},n.goOffline=function(){var e=c(l.mark((function e(){return l.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.yomo&&this.yomo.send("offline",{id:this.id}),this.subscription&&this.subscription.unsubscribe(),e.next=4,new Promise((function(e){setTimeout(e,500)}));case 4:return e.abrupt("return",e.sent);case 5:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),n.sendMessage=function(e){this.yomo&&this.yomo.send("text",{id:this.id,message:e})},n.online=function(e){e.send("online",{id:this.id,x:0,y:0,name:this.name,avatar:this.avatar,color:this.color})},n.subscribeOnline=function(e){var t=this;return e.on$("online").subscribe((function(){e.send("sync",{id:t.id,x:t.x,y:t.y,name:t.name,avatar:t.avatar,color:t.color})}))},n.subscribeMousemove=function(){var t=this;return i.fromEvent(document,"mousemove").subscribe((function(n){var r=n.clientX,o=n.clientY;e.prototype.move.call(t,r,o),t.onMove({mouseX:r,mouseY:o})}))},n.subscribeMousePosition=function(e){var t=this;return i.fromEvent(document,"mousemove").pipe(r.map((function(e){var n,r,o=(n=e.clientY,{scaleX:e.clientX/(r=h()).width,scaleY:n/r.height});return{id:t.id,x:o.scaleX,y:o.scaleY}}))).subscribe((function(t){e.send("movement",t)}))},n.subscribeVisibility=function(e){var t=this;return i.fromEvent(document,"visibilitychange").pipe(r.map((function(){return{event:document.hidden?"leave":"enter"}}))).subscribe((function(n){e.send(n.event,{id:t.id})}))},t}(f),p=function(e){function t(t){var n=t.name,r=t.avatar,o=t.color;return e.call(this,t.id,t.x,t.y,void 0===n?"":n,void 0===r?"":r,void 0===o?"":o)||this}s(t,e);var n=t.prototype;return n.goOnline=function(t){this.subscription=this.subscribeMovement(t);var n=this.subscribeTextMessage(t),r=e.prototype.subscribeLatency.call(this,t),o=this.subscribeLeave(t),i=this.subscribeEnter(t);this.subscription.add(n),this.subscription.add(r),this.subscription.add(o),this.subscription.add(i)},n.unsubscribe=function(){this.subscription&&this.subscription.unsubscribe()},n.onTextMessage=function(e){},n.subscribeTextMessage=function(e){var t=this;return e.on$("text").pipe(r.filter((function(e){return e.id===t.id}))).subscribe((function(e){t.onTextMessage(e.message)}))},n.subscribeMovement=function(t){var n=this;return t.on$("movement").pipe(r.filter((function(e){return e.id===n.id})),r.map((function(e){return t=e.y,{mouseX:e.x*(n=h()).width,mouseY:t*n.height};var t,n}))).subscribe((function(t){var r=t.mouseX,o=t.mouseY;e.prototype.move.call(n,r,o),n.onMove({mouseX:r,mouseY:o})}))},n.subscribeLeave=function(e){var t=this;return e.on$("leave").pipe(r.filter((function(e){return e.id===t.id}))).subscribe((function(){t.onLeave(t.id)}))},n.subscribeEnter=function(e){var t=this;return e.on$("enter").pipe(r.filter((function(e){return e.id===t.id}))).subscribe((function(){t.onEnter(t.id)}))},n.onLeave=function(e){throw new Error("Method not implemented.")},n.onEnter=function(e){throw new Error("Method not implemented.")},t}(f),v=function(e){var n=e.presenceURL,i=e.presenceAuthEndpoint,a=e.room,s=e.name,u=e.avatar,f=e.color,h=e.onOtherEntry,v=void 0===h?function(){}:h,m=e.onOtherLeave,y=void 0===m?function(){}:m,b=t.useState(null),w=b[0],g=b[1],x=t.useState(new Map),E=x[0],L=x[1],_=t.useState([]),M=_[0],O=_[1];return t.useEffect((function(){var e="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})),t=new d({id:e,x:0,y:0,name:s||"",avatar:u||"",color:f||""});g(t);var h=new o(n,{auth:{type:"token",endpoint:i}});h.on("connected",(function(){a&&h.toRoom(a),h.on$("online").pipe(r.filter((function(t){return t.id!==e}))).subscribe((function(e){L((function(t){if(t.has(e.id))return t;var n=new Map(t),r=new p(e);return r.onLeave=y,r.onEnter=v,r.goOnline(h),n.set(r.id,r),n}))})),h.on("offline",(function(e){L((function(t){var n=new Map(t),r=n.get(e.id);return r&&r.unsubscribe(),n.delete(e.id),n}))})),h.on$("sync").pipe(r.filter((function(t){return t.id!==e}))).subscribe((function(e){L((function(t){if(t.has(e.id))return t;var n=new Map(t),r=new p(e);return r.onLeave=y,r.onEnter=v,r.goOnline(h),n.set(r.id,r),n}))})),t.goOnline(h)}));var m=function(){var e=c(l.mark((function e(){return l.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.goOffline();case 2:h.close();case 3:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();return window.addEventListener("unload",m),function(){m(),window.removeEventListener("unload",m)}}),[a]),t.useEffect((function(){O(Array.from(E.values()))}),[E]),{me:w,others:M}};function m(e){var r=e.color;return t.useMemo((function(){return n.createElement("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:r,xmlns:"http://www.w3.org/2000/svg"},n.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M0 0L20 7.14286L11.0948 11.1194L7.14286 20L0 0Z"}))}),[r])}var y=function(e){var r=e.cursor,o=e.showLatency,i=t.useState({meshId:"",latency:0}),a=i[0],c=i[1];return t.useEffect((function(){o?r.onGetLatency=function(e){c({meshId:e.meshId,latency:e.latency})}:(r.onGetLatency=function(e){},c({meshId:"",latency:0}))}),[o]),0===a.latency?null:n.createElement("div",{className:"online-cursor-wrapper__latency-box"}," ",n.createElement("svg",{width:"8",height:"10",viewBox:"0 0 8 10",fill:"white",xmlns:"http://www.w3.org/2000/svg"},n.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M3.99993 0C4.99609 0 5.99332 0.367541 6.77237 1.10262C8.41307 2.65187 8.37032 5.28494 6.87655 6.95267L6.72235 7.11615L4.43096 9.41998C4.31176 9.53999 4.15531 9.6 3.99886 9.6C3.87371 9.6 3.74855 9.5616 3.64246 9.48479L3.56677 9.41998L1.27751 7.11508C-0.365737 5.46061 -0.467907 2.70352 1.22855 1.10262C2.00654 0.367541 3.00377 0 3.99993 0ZM3.99993 1C3.22932 1 2.48657 1.28975 1.91488 1.82992C0.711907 2.96512 0.701036 4.96169 1.84937 6.26336L1.98702 6.41038L3.999 8.436L6.01284 6.41146C7.2978 5.11772 7.33439 3.00868 6.08609 1.82996C5.51361 1.28979 4.77055 1 3.99993 1ZM4 2C5.10238 2 6 2.89762 6 4C6 5.10238 5.10238 6 4 6C2.89762 6 2 5.10238 2 4C2 2.89762 2.89762 2 4 2ZM4 3C3.4499 3 3 3.4499 3 4C3 4.5501 3.4499 5 4 5C4.5501 5 5 4.5501 5 4C5 3.4499 4.5501 3 4 3Z",fill:"white"}))," ",n.createElement("span",null,a.meshId)," ",n.createElement("span",null,a.latency,"ms")," ")},b=function(e,n){var r=n||t.useRef(null);return t.useEffect((function(){var t=function(e){r.current&&r.current.style.setProperty("transform","translate3d("+e.mouseX+"px, "+e.mouseY+"px, 0)")};t({mouseX:e.x,mouseY:e.y}),e.onMove=function(e){t(e)}}),[e]),r},w=function(e){var r=e.cursor,o=e.showLatency,i=b(r);!function(e,n){var r=n||t.useRef(null);t.useEffect((function(){var t=function(e){r.current&&r.current.style.setProperty("opacity",String(e))};e.onLeave=function(){t(.5)},e.onEnter=function(){t(1)}}),[e])}(r,i);var a=t.useState(""),c=a[0],s=a[1];return t.useEffect((function(){r.onTextMessage=function(e){s(e)}}),[]),t.useMemo((function(){return n.createElement("div",{className:"online-cursor-wrapper__cursor",ref:i},n.createElement(m,{color:r.color}),n.createElement("div",{className:"online-cursor-wrapper__tail-box",style:{borderRadius:c?35:15,borderTopLeftRadius:c?10:15,backgroundColor:""+r.color}},n.createElement("div",{className:"online-cursor-wrapper__user"},r.avatar&&n.createElement("img",{className:"online-cursor-wrapper__avatar",src:r.avatar,alt:"avatar"}),r.name&&n.createElement("span",{className:"online-cursor-wrapper__name"},r.name),n.createElement(y,{cursor:r,showLatency:o})),n.createElement("div",{style:{height:"1px",width:"100%",visibility:"hidden",background:"transparent"}}),c&&n.createElement("div",{className:"online-cursor-wrapper__text"},c)))}),[c,o])},g=function(e){var t=e.showLatency,r=void 0!==t&&t;return n.createElement(n.Fragment,null,e.others.map((function(e){return n.createElement(w,{key:e.id,cursor:e,showLatency:r})})))},x=function(e){var r=e.cursor,o=e.showLatency,i=b(r),a=t.useState(!1),c=a[0],s=a[1],u=t.useState(""),l=u[0],f=u[1],h=t.useCallback((function(e){var t=e.target.value;"/"!==t&&(f(t),r.sendMessage(t))}),[]);return t.useEffect((function(){var e=function(e){"Slash"===e.code&&s(!0),"Escape"===e.code&&(s(!1),f(""),r.sendMessage(""))};return document.addEventListener("keydown",e),function(){document.removeEventListener("keydown",e)}}),[]),t.useMemo((function(){return n.createElement("div",{className:"online-cursor-wrapper__cursor",ref:i},n.createElement(m,{color:r.color}),n.createElement("div",{className:"online-cursor-wrapper__tail-box",style:{borderRadius:c?35:15,borderTopLeftRadius:c?10:15,backgroundColor:""+r.color}},n.createElement("div",{className:"online-cursor-wrapper__user"},r.avatar&&n.createElement("img",{className:"online-cursor-wrapper__avatar",src:r.avatar,alt:"avatar"}),r.name&&n.createElement("span",{className:"online-cursor-wrapper__name"},r.name),n.createElement(y,{cursor:r,showLatency:o})),n.createElement("div",{style:{height:"1px",width:"100%",visibility:"hidden",background:"transparent"}}),c&&n.createElement("div",{className:"online-cursor-wrapper__input-box"},n.createElement("span",null,l),n.createElement("input",{autoFocus:!0,placeholder:"Say something",value:l,onChange:h}))))}),[c,l,o])};exports.default=t.memo((function(e){var t=e.showLatency,r=void 0!==t&&t,o=e.colors,i=void 0===o?["#604CFF","#FF0BC6","#00C0ED","#FFAB24","#F52768"]:o,a=v({presenceURL:e.presenceURL,presenceAuthEndpoint:e.presenceAuthEndpoint,room:e.room,name:e.name,avatar:e.avatar,color:""+i[Math.floor(Math.random()*i.length)]}),c=a.me;return c?n.createElement("div",{className:"online-cursor-wrapper"},n.createElement(g,{others:a.others,showLatency:r}),n.createElement(x,{cursor:c,showLatency:r})):null})),exports.useOnlineCursor=v,exports.useRenderPosition=b;
//# sourceMappingURL=react-cursor-chat.cjs.production.min.js.map

@@ -1142,3 +1142,3 @@ import React, { useState, useEffect, useMemo, useRef, useCallback, memo } from 'react';

})).subscribe(function () {
_this3.onLeave();
_this3.onLeave(_this3.id);
});

@@ -1153,11 +1153,13 @@ };

})).subscribe(function () {
_this4.onEnter();
_this4.onEnter(_this4.id);
});
};
} // @ts-ignore
;
_proto.onLeave = function onLeave() {
_proto.onLeave = function onLeave(id) {
throw new Error('Method not implemented.');
};
} // @ts-ignore
;
_proto.onEnter = function onEnter() {
_proto.onEnter = function onEnter(id) {
throw new Error('Method not implemented.');

@@ -1175,3 +1177,7 @@ };

avatar = _ref.avatar,
color = _ref.color;
color = _ref.color,
_ref$onOtherEntry = _ref.onOtherEntry,
onOtherEntry = _ref$onOtherEntry === void 0 ? function () {} : _ref$onOtherEntry,
_ref$onOtherLeave = _ref.onOtherLeave,
onOtherLeave = _ref$onOtherLeave === void 0 ? function () {} : _ref$onOtherLeave;

@@ -1222,2 +1228,4 @@ var _useState = useState(null),

var other = new Other(data);
other.onLeave = onOtherLeave;
other.onEnter = onOtherEntry;
other.goOnline(yomo);

@@ -1253,2 +1261,4 @@ cursorMap.set(other.id, other);

var other = new Other(data);
other.onLeave = onOtherLeave;
other.onEnter = onOtherEntry;
other.goOnline(yomo);

@@ -1312,4 +1322,4 @@ cursorMap.set(other.id, other);

}, React.createElement("path", {
"fill-rule": "evenodd",
"clip-rule": "evenodd",
fillRule: "evenodd",
clipRule: "evenodd",
d: "M0 0L20 7.14286L11.0948 11.1194L7.14286 20L0 0Z"

@@ -1362,4 +1372,4 @@ }));

}, React.createElement("path", {
"fill-rule": "evenodd",
"clip-rule": "evenodd",
fillRule: "evenodd",
clipRule: "evenodd",
d: "M3.99993 0C4.99609 0 5.99332 0.367541 6.77237 1.10262C8.41307 2.65187 8.37032 5.28494 6.87655 6.95267L6.72235 7.11615L4.43096 9.41998C4.31176 9.53999 4.15531 9.6 3.99886 9.6C3.87371 9.6 3.74855 9.5616 3.64246 9.48479L3.56677 9.41998L1.27751 7.11508C-0.365737 5.46061 -0.467907 2.70352 1.22855 1.10262C2.00654 0.367541 3.00377 0 3.99993 0ZM3.99993 1C3.22932 1 2.48657 1.28975 1.91488 1.82992C0.711907 2.96512 0.701036 4.96169 1.84937 6.26336L1.98702 6.41038L3.999 8.436L6.01284 6.41146C7.2978 5.11772 7.33439 3.00868 6.08609 1.82996C5.51361 1.28979 4.77055 1 3.99993 1ZM4 2C5.10238 2 6 2.89762 6 4C6 5.10238 5.10238 6 4 6C2.89762 6 2 5.10238 2 4C2 2.89762 2.89762 2 4 2ZM4 3C3.4499 3 3 3.4499 3 4C3 4.5501 3.4499 5 4 5C4.5501 5 5 4.5501 5 4C5 3.4499 4.5501 3 4 3Z",

@@ -1366,0 +1376,0 @@ fill: "white"

{
"name": "@yomo/react-cursor-chat",
"version": "0.1.7",
"version": "0.1.8",
"description": "A react component helps bring Figma's Cursor Chat to your web applications in less than 3 minutes, making real-time collaboration anywhere. based on Presencejs.",

@@ -5,0 +5,0 @@ "keywords": [

@@ -76,3 +76,3 @@ import { Subscription } from 'rxjs';

.subscribe(() => {
this.onLeave();
this.onLeave(this.id);
});

@@ -86,13 +86,15 @@ }

.subscribe(() => {
this.onEnter();
this.onEnter(this.id);
});
}
onLeave() {
// @ts-ignore
onLeave(id: string) {
throw new Error('Method not implemented.');
}
onEnter() {
// @ts-ignore
onEnter(id: string) {
throw new Error('Method not implemented.');
}
}

@@ -16,2 +16,4 @@ import { useEffect, useState } from 'react';

color,
onOtherEntry = () => {},
onOtherLeave = () => {},
}: {

@@ -24,2 +26,4 @@ presenceURL: string;

color?: string;
onOtherEntry?: () => void;
onOtherLeave?: () => void;
}) => {

@@ -67,2 +71,4 @@ const [me, setMe] = useState<Me | null>(null);

const other = new Other(data);
other.onLeave = onOtherLeave;
other.onEnter = onOtherEntry;
other.goOnline(yomo);

@@ -97,2 +103,4 @@ cursorMap.set(other.id, other);

const other = new Other(data);
other.onLeave = onOtherLeave;
other.onEnter = onOtherEntry;
other.goOnline(yomo);

@@ -122,5 +130,5 @@ cursorMap.set(other.id, other);

useEffect(()=>{
useEffect(() => {
setOthers(Array.from(otherMap.values()));
}, [otherMap])
}, [otherMap]);

@@ -127,0 +135,0 @@ return { me, others };

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc