Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@roomservice/core

Package Overview
Dependencies
Maintainers
2
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@roomservice/core - npm Package Compare versions

Comparing version 0.2.1 to 0.3.1

11

dist/core.cjs.development.js

@@ -324,4 +324,5 @@ 'use strict';

_proto["import"] = function _import(checkpoint, listID) {
_proto["import"] = function _import(actor, checkpoint, listID) {
!checkpoint ? invariant(false) : void 0;
this.actor = actor;
this.log = [];

@@ -533,3 +534,3 @@ this.nodes = {};

function importFromRawCheckpoint$1(store, rawCheckpoint, listID) {
function importFromRawCheckpoint$1(store, actor, rawCheckpoint, listID) {
store.itemIDs = [];

@@ -541,3 +542,3 @@

store.rt["import"](rawCheckpoint, listID);
store.rt["import"](actor, rawCheckpoint, listID);
var list = rawCheckpoint.lists[listID];

@@ -673,3 +674,3 @@ var ids = list.ids || [];

if (index < 0) {
throw 'Negative indices unsupported';
throw new Error('Negative indices unsupported');
}

@@ -679,3 +680,3 @@

if (index == 0) {
if (index === 0) {
afterID = 'root';

@@ -682,0 +683,0 @@ } else {

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

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=(e=require("tiny-invariant"))&&"object"==typeof e&&"default"in e?e.default:e,r=function(){function e(e){this.stringToB64=e}var t=e.prototype;return t.base64toArrayBuffer=function(e){for(var t=this.stringToB64(e),r=t.length,n=new Uint8Array(r),o=0;o<r;o++)n[o]=t.charCodeAt(o);return n.buffer},t.isOlderVS=function(e,t){if(!e)return!0;if(!t)return!1;for(var r=new Uint8Array(this.base64toArrayBuffer(e).slice(0,9)),n=new Uint8Array(this.base64toArrayBuffer(t).slice(0,9)),o=0;o<r.byteLength;o++){if(n[o]>r[o])return!0;if(n[o]<r[o])return!1}return!1},e}();function n(e){return JSON.stringify(e)}function o(e){try{return JSON.parse(e)}catch(t){return e}}var i={validateCommand:function(e,t){if(t.length<3)throw new Error("Unexpected command: "+t);if(t[1]!==e.docID||t[2]!==e.mapID)throw new Error("Command unexpectedly routed to the wrong client")},applyCommand:function(e,t){var r=t[0];switch(r){case"mput":if(5!==t.length){console.error("Malformed command ",t);break}e[t[3]]=o(t[4]);break;case"mdel":if(4!==t.length){console.error("Malformed command ",t);break}delete e[t[3]];break;case"mcreate":break;default:throw new Error("Unexpected command keyword: "+r)}},newMap:function(e,t){return{cmd:["mcreate",e,t],meta:{docID:e,mapID:t},store:{}}},importFromRawCheckpoint:function(e,t,r){for(var n=0,i=Object.keys(e);n<i.length;n++)delete e[i[n]];if(t.maps[r])for(var a in t.maps[r]){var s=t.maps[r][a];"string"==typeof s&&(e[a]=o(s))}},runSet:function(e,t,r,o){var i=n(o);return e[r]=o,["mput",t.docID,t.mapID,r,i]},runDelete:function(e,t,r){return delete e[r],["mdel",t.docID,t.mapID,r]}};function a(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function s(e,t){var r;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return a(e,void 0);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?a(e,void 0):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(r=e[Symbol.iterator]()).next.bind(r)}function u(e,t){if("root"===t)return"root";var r=t.split(":");return r[0]+":"+e.actors[parseInt(r[1])]}var c=function(){function e(e){this.count=0,this.actor=e,this.nodes={},this.log=[]}var r,n=e.prototype;return n.import=function(e,r){e||t(!1),this.log=[],this.nodes={},this.count=0;for(var n=e.lists[r],o=n.afters||[],i=n.ids||[],a=n.values||[],s=0;s<o.length;s++){var c={after:u(e,o[s]),id:u(e,i[s]),value:a[s]};this.nodes[c.id]=c,this.log.push(c)}this.count=this.log.length},n.get=function(e){if(this.nodes[e])return this.nodes[e].value},n.insert=function(e,r,n){this.log||t(!1);var o=n;o||(o=this.count+":"+this.actor),this.count++;var i={after:e,value:r,id:o};return this.nodes[o]=i,this.log.push(i),o},n.put=function(e,t){this.nodes[e]&&(this.nodes[e].value=t)},n.has=function(e){return!!this.nodes[e]},n.delete=function(e){this.nodes[e]&&(this.nodes[e].value={t:""})},n.toTree=function(){for(var e,t=new Map,r=new Map,n=s(this.log);!(e=n()).done;){var o,i=e.value;t.has(i.after)||t.set(i.after,[]),null==(o=t.get(i.after))||o.push(i.id),r.set(i.id,i.value)}return t.forEach((function(e){e.sort((function(e,t){var r=e.split(":"),n=r[0],o=r[1],i=t.split(":"),a=i[0];return n===a?o.localeCompare(i[1]):parseInt(a)-parseInt(n)}))})),{childrenById:t,valueById:r}},n.lastID=function(){return 0===this.log.length?"root":function e(t,r){var n=t.childrenById.get(r);return n&&0!==n.length?e(t,n[n.length-1]):r}(this.toTree(),"root")},n.preOrderTraverse=function(){var e=this.toTree(),t=new Set;return function e(r,n){if(t.has(n))return console.warn("RoomService list cycle detected. Consider updating @roomservice/browser."),[];t.add(n);var o=[],i=r.valueById.get(n);if(i)if("string"==typeof i)o.push({value:i,id:n});else if(!("t"in i)||""!==i.t)throw new Error("Unimplemented");var a=r.childrenById.get(n);if(!a||0===a.length)return o;for(var u,c=s(a);!(u=c()).done;)o=o.concat(e(r,u.value));return o}(e,"root")},n.toArray=function(){return this.preOrderTraverse().map((function(e){return e.value}))},(r=[{key:"length",get:function(){return Object.keys(this.nodes).length}}])&&function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(e.prototype,r),e}();function l(e,t,r,o){if(r<0)throw"Negative indices unsupported";var i;if(!(i=0==r?"root":e.itemIDs[r-1]))throw new RangeError("List '"+t.listID+"' has no index: '"+r+"'");var a=n(o),s=e.rt.insert(i,a);return e.itemIDs.splice(r,0,s),["lins",t.docID,t.listID,i,s,a]}function f(e,t,r){var o=e.rt.lastID(),i=n(r),a=e.rt.insert(o,i);return e.itemIDs.push(a),["lins",t.docID,t.listID,o,a,i]}exports.ListInterpreter={importFromRawCheckpoint:function(e,t,r){if(e.itemIDs=[],t.lists[r]){e.rt.import(t,r);for(var n=t.lists[r].ids||[],o=0;o<n.length;o++){var i=t.lists[r].values[o];"object"==typeof i&&""===i.t||e.itemIDs.push(u(t,n[o]))}}},validateCommand:function(e,t){if(t.length<3)throw new Error("Unexpected command: "+t);if(t[1]!==e.docID||t[2]!==e.listID)throw new Error("Command unexpectedly routed to the wrong client")},applyCommand:function(e,t){var r=t[0];switch(r){case"lins":var n=t[3],o=t[4],i=t[5];e.itemIDs.splice(e.itemIDs.findIndex((function(e){return e===n}))+1,0,o),e.rt.insert(n,i,o);break;case"lput":e.rt.put(t[3],t[4]);break;case"ldel":var a=t[3];e.rt.delete(a),e.itemIDs.splice(e.itemIDs.findIndex((function(e){return e===a})),1);break;case"lcreate":break;default:throw new Error("Unexpected command keyword: "+r)}},get:function(e,t){var r=e.itemIDs[t];if(r){var n=e.rt.get(r);if(n){if("object"==typeof n){if(""===n.t)return;throw new Error("Unimplemented references")}return o(n)}}},map:function(e,t){return e.rt.preOrderTraverse().map((function(e,r){return t(o(e.value),r,e.id)}))},toArray:function(e){return e.rt.toArray().map((function(e){return o(e)}))},newList:function(e,t,r){return{store:{itemIDs:[],rt:new c(r)},meta:{docID:e,listID:t},cmd:["mcreate",e,t]}},runSet:function(e,t,r,o){var i=e.itemIDs[r];if(!i)throw new Error("Index '"+r+"' doesn't already exist. Try .push() or .insertAfter() instead.");var a=n(o);return e.rt.put(i,a),["lput",t.docID,t.listID,i,a]},runDelete:function(e,t,r){if(0===e.itemIDs.length)return!1;var n=e.itemIDs[r];return n?(e.rt.delete(n),e.itemIDs.splice(r,1),["ldel",t.docID,t.listID,n]):(console.warn("Unknown index: ",r,e.itemIDs),!1)},runInsertAt:l,runInsertAfter:function(e,t,r,n){return l(e,t,r+1,n)},runPush:function(e,t){for(var r=[],n=arguments.length,o=new Array(n>2?n-2:0),i=2;i<n;i++)o[i-2]=arguments[i];for(var a=0,s=o;a<s.length;a++){var u=s[a];r.push(f(e,t,u))}return r}},exports.MapInterpreter=i,exports.vsReader=function(e){return new r(e)};
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=(e=require("tiny-invariant"))&&"object"==typeof e&&"default"in e?e.default:e,r=function(){function e(e){this.stringToB64=e}var t=e.prototype;return t.base64toArrayBuffer=function(e){for(var t=this.stringToB64(e),r=t.length,n=new Uint8Array(r),o=0;o<r;o++)n[o]=t.charCodeAt(o);return n.buffer},t.isOlderVS=function(e,t){if(!e)return!0;if(!t)return!1;for(var r=new Uint8Array(this.base64toArrayBuffer(e).slice(0,9)),n=new Uint8Array(this.base64toArrayBuffer(t).slice(0,9)),o=0;o<r.byteLength;o++){if(n[o]>r[o])return!0;if(n[o]<r[o])return!1}return!1},e}();function n(e){return JSON.stringify(e)}function o(e){try{return JSON.parse(e)}catch(t){return e}}var i={validateCommand:function(e,t){if(t.length<3)throw new Error("Unexpected command: "+t);if(t[1]!==e.docID||t[2]!==e.mapID)throw new Error("Command unexpectedly routed to the wrong client")},applyCommand:function(e,t){var r=t[0];switch(r){case"mput":if(5!==t.length){console.error("Malformed command ",t);break}e[t[3]]=o(t[4]);break;case"mdel":if(4!==t.length){console.error("Malformed command ",t);break}delete e[t[3]];break;case"mcreate":break;default:throw new Error("Unexpected command keyword: "+r)}},newMap:function(e,t){return{cmd:["mcreate",e,t],meta:{docID:e,mapID:t},store:{}}},importFromRawCheckpoint:function(e,t,r){for(var n=0,i=Object.keys(e);n<i.length;n++)delete e[i[n]];if(t.maps[r])for(var a in t.maps[r]){var s=t.maps[r][a];"string"==typeof s&&(e[a]=o(s))}},runSet:function(e,t,r,o){var i=n(o);return e[r]=o,["mput",t.docID,t.mapID,r,i]},runDelete:function(e,t,r){return delete e[r],["mdel",t.docID,t.mapID,r]}};function a(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function s(e,t){var r;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return a(e,void 0);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?a(e,void 0):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(r=e[Symbol.iterator]()).next.bind(r)}function u(e,t){if("root"===t)return"root";var r=t.split(":");return r[0]+":"+e.actors[parseInt(r[1])]}var c=function(){function e(e){this.count=0,this.actor=e,this.nodes={},this.log=[]}var r,n=e.prototype;return n.import=function(e,r,n){r||t(!1),this.actor=e,this.log=[],this.nodes={},this.count=0;for(var o=r.lists[n],i=o.afters||[],a=o.ids||[],s=o.values||[],c=0;c<i.length;c++){var l={after:u(r,i[c]),id:u(r,a[c]),value:s[c]};this.nodes[l.id]=l,this.log.push(l)}this.count=this.log.length},n.get=function(e){if(this.nodes[e])return this.nodes[e].value},n.insert=function(e,r,n){this.log||t(!1);var o=n;o||(o=this.count+":"+this.actor),this.count++;var i={after:e,value:r,id:o};return this.nodes[o]=i,this.log.push(i),o},n.put=function(e,t){this.nodes[e]&&(this.nodes[e].value=t)},n.has=function(e){return!!this.nodes[e]},n.delete=function(e){this.nodes[e]&&(this.nodes[e].value={t:""})},n.toTree=function(){for(var e,t=new Map,r=new Map,n=s(this.log);!(e=n()).done;){var o,i=e.value;t.has(i.after)||t.set(i.after,[]),null==(o=t.get(i.after))||o.push(i.id),r.set(i.id,i.value)}return t.forEach((function(e){e.sort((function(e,t){var r=e.split(":"),n=r[0],o=r[1],i=t.split(":"),a=i[0];return n===a?o.localeCompare(i[1]):parseInt(a)-parseInt(n)}))})),{childrenById:t,valueById:r}},n.lastID=function(){return 0===this.log.length?"root":function e(t,r){var n=t.childrenById.get(r);return n&&0!==n.length?e(t,n[n.length-1]):r}(this.toTree(),"root")},n.preOrderTraverse=function(){var e=this.toTree(),t=new Set;return function e(r,n){if(t.has(n))return console.warn("RoomService list cycle detected. Consider updating @roomservice/browser."),[];t.add(n);var o=[],i=r.valueById.get(n);if(i)if("string"==typeof i)o.push({value:i,id:n});else if(!("t"in i)||""!==i.t)throw new Error("Unimplemented");var a=r.childrenById.get(n);if(!a||0===a.length)return o;for(var u,c=s(a);!(u=c()).done;)o=o.concat(e(r,u.value));return o}(e,"root")},n.toArray=function(){return this.preOrderTraverse().map((function(e){return e.value}))},(r=[{key:"length",get:function(){return Object.keys(this.nodes).length}}])&&function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(e.prototype,r),e}();function l(e,t,r,o){if(r<0)throw new Error("Negative indices unsupported");var i;if(!(i=0===r?"root":e.itemIDs[r-1]))throw new RangeError("List '"+t.listID+"' has no index: '"+r+"'");var a=n(o),s=e.rt.insert(i,a);return e.itemIDs.splice(r,0,s),["lins",t.docID,t.listID,i,s,a]}function f(e,t,r){var o=e.rt.lastID(),i=n(r),a=e.rt.insert(o,i);return e.itemIDs.push(a),["lins",t.docID,t.listID,o,a,i]}exports.ListInterpreter={importFromRawCheckpoint:function(e,t,r,n){if(e.itemIDs=[],r.lists[n]){e.rt.import(t,r,n);for(var o=r.lists[n].ids||[],i=0;i<o.length;i++){var a=r.lists[n].values[i];"object"==typeof a&&""===a.t||e.itemIDs.push(u(r,o[i]))}}},validateCommand:function(e,t){if(t.length<3)throw new Error("Unexpected command: "+t);if(t[1]!==e.docID||t[2]!==e.listID)throw new Error("Command unexpectedly routed to the wrong client")},applyCommand:function(e,t){var r=t[0];switch(r){case"lins":var n=t[3],o=t[4],i=t[5];e.itemIDs.splice(e.itemIDs.findIndex((function(e){return e===n}))+1,0,o),e.rt.insert(n,i,o);break;case"lput":e.rt.put(t[3],t[4]);break;case"ldel":var a=t[3];e.rt.delete(a),e.itemIDs.splice(e.itemIDs.findIndex((function(e){return e===a})),1);break;case"lcreate":break;default:throw new Error("Unexpected command keyword: "+r)}},get:function(e,t){var r=e.itemIDs[t];if(r){var n=e.rt.get(r);if(n){if("object"==typeof n){if(""===n.t)return;throw new Error("Unimplemented references")}return o(n)}}},map:function(e,t){return e.rt.preOrderTraverse().map((function(e,r){return t(o(e.value),r,e.id)}))},toArray:function(e){return e.rt.toArray().map((function(e){return o(e)}))},newList:function(e,t,r){return{store:{itemIDs:[],rt:new c(r)},meta:{docID:e,listID:t},cmd:["mcreate",e,t]}},runSet:function(e,t,r,o){var i=e.itemIDs[r];if(!i)throw new Error("Index '"+r+"' doesn't already exist. Try .push() or .insertAfter() instead.");var a=n(o);return e.rt.put(i,a),["lput",t.docID,t.listID,i,a]},runDelete:function(e,t,r){if(0===e.itemIDs.length)return!1;var n=e.itemIDs[r];return n?(e.rt.delete(n),e.itemIDs.splice(r,1),["ldel",t.docID,t.listID,n]):(console.warn("Unknown index: ",r,e.itemIDs),!1)},runInsertAt:l,runInsertAfter:function(e,t,r,n){return l(e,t,r+1,n)},runPush:function(e,t){for(var r=[],n=arguments.length,o=new Array(n>2?n-2:0),i=2;i<n;i++)o[i-2]=arguments[i];for(var a=0,s=o;a<s.length;a++){var u=s[a];r.push(f(e,t,u))}return r}},exports.MapInterpreter=i,exports.vsReader=function(e){return new r(e)};
//# sourceMappingURL=core.cjs.production.min.js.map

@@ -318,4 +318,5 @@ import invariant from 'tiny-invariant';

_proto["import"] = function _import(checkpoint, listID) {
_proto["import"] = function _import(actor, checkpoint, listID) {
!checkpoint ? process.env.NODE_ENV !== "production" ? invariant(false) : invariant(false) : void 0;
this.actor = actor;
this.log = [];

@@ -527,3 +528,3 @@ this.nodes = {};

function importFromRawCheckpoint$1(store, rawCheckpoint, listID) {
function importFromRawCheckpoint$1(store, actor, rawCheckpoint, listID) {
store.itemIDs = [];

@@ -535,3 +536,3 @@

store.rt["import"](rawCheckpoint, listID);
store.rt["import"](actor, rawCheckpoint, listID);
var list = rawCheckpoint.lists[listID];

@@ -667,3 +668,3 @@ var ids = list.ids || [];

if (index < 0) {
throw 'Negative indices unsupported';
throw new Error('Negative indices unsupported');
}

@@ -673,3 +674,3 @@

if (index == 0) {
if (index === 0) {
afterID = 'root';

@@ -676,0 +677,0 @@ } else {

@@ -22,3 +22,3 @@ import { ReverseTree } from './ReverseTree';

*/
declare function importFromRawCheckpoint(store: ListStore, rawCheckpoint: DocumentCheckpoint, listID: string): void;
declare function importFromRawCheckpoint(store: ListStore, actor: string, rawCheckpoint: DocumentCheckpoint, listID: string): void;
/**

@@ -25,0 +25,0 @@ * Validates an incoming command. Throws an error

@@ -27,3 +27,3 @@ import { NodeValue, DocumentCheckpoint } from './types';

constructor(actor: string);
import(checkpoint: DocumentCheckpoint, listID: string): void;
import(actor: string, checkpoint: DocumentCheckpoint, listID: string): void;
get(itemID: string): NodeValue | undefined;

@@ -30,0 +30,0 @@ insert(after: 'root' | string, value: NodeValue, externalNewID?: string): string;

{
"version": "0.2.1",
"version": "0.3.1",
"license": "MIT",

@@ -4,0 +4,0 @@ "main": "dist/index.js",

@@ -35,2 +35,3 @@ import { ListInterpreter } from './list';

store,
'actor',
checkpoint(

@@ -37,0 +38,0 @@ 'list',

@@ -44,2 +44,3 @@ import { unescape, escape } from './escape';

store: ListStore,
actor: string,
rawCheckpoint: DocumentCheckpoint,

@@ -53,3 +54,3 @@ listID: string

store.rt.import(rawCheckpoint, listID);
store.rt.import(actor, rawCheckpoint, listID);
const list = rawCheckpoint.lists[listID];

@@ -192,6 +193,6 @@ const ids = list.ids || [];

if (index < 0) {
throw 'Negative indices unsupported';
throw new Error('Negative indices unsupported');
}
let afterID: string;
if (index == 0) {
if (index === 0) {
afterID = 'root';

@@ -198,0 +199,0 @@ } else {

@@ -62,3 +62,3 @@ import { unescape, escape } from './escape';

const MALFORMED = 'Malformed command '
const MALFORMED = 'Malformed command ';

@@ -65,0 +65,0 @@ switch (keyword) {

@@ -12,2 +12,3 @@ import { ReverseTree } from './ReverseTree';

rt.import(
'me',
{

@@ -14,0 +15,0 @@ id: 'doc',

@@ -54,5 +54,7 @@ import { NodeValue, DocumentCheckpoint } from './types';

import(checkpoint: DocumentCheckpoint, listID: string) {
import(actor: string, checkpoint: DocumentCheckpoint, listID: string) {
invariant(checkpoint);
this.actor = actor;
this.log = [];

@@ -59,0 +61,0 @@ this.nodes = {};

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