Socket
Socket
Sign inDemoInstall

@roomservice/browser

Package Overview
Dependencies
49
Maintainers
1
Versions
126
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.9 to 0.0.10

2

dist/client.d.ts

@@ -13,2 +13,3 @@ import { KeyValueObject } from "./types";

private _onDisconnectCallback?;
private _saveOffline;
constructor(authorizationUrl: string, reference: string, state?: T);

@@ -23,2 +24,3 @@ connect(): Promise<{

onDisconnect(callback: () => any): void;
private syncOfflineCache;
private _sendMsgToSocket;

@@ -25,0 +27,0 @@ publishState(callback: (state: T) => void): T;

28

dist/client.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const automerge_1 = tslib_1.__importDefault(require("automerge"));
const automerge_1 = tslib_1.__importStar(require("automerge"));
const invariant_1 = tslib_1.__importDefault(require("invariant"));
const lodash_1 = require("lodash");
const safe_json_stringify_1 = tslib_1.__importDefault(require("safe-json-stringify"));
const authorize_1 = tslib_1.__importDefault(require("./authorize"));
const constants_1 = require("./constants");
const offline_1 = tslib_1.__importDefault(require("./offline"));
const socket_1 = tslib_1.__importDefault(require("./socket"));

@@ -49,2 +51,8 @@ function asRoomStr(room) {

this._automergeConn = new automerge_1.default.Connection(this._docs, this._sendMsgToSocket);
// We define this here so we can debounce the save function
// Otherwise we'll get quite the performance hit
let saveOffline = (docId, doc) => {
offline_1.default.set(this._reference, docId, automerge_1.save(doc));
};
this._saveOffline = lodash_1.debounce(saveOffline, 120);
}

@@ -90,8 +98,3 @@ async connect() {

*/
// TODO Offline
// const data = await Offline.get(this._reference);
// if (data) {
// const room: RoomValue = fromRoomStr(data as string);
// Sockets.emit(this._socket, "update_room", asRoomStr(room));
// }
this.syncOfflineCache();
let state;

@@ -131,2 +134,3 @@ try {

const newDoc = this._automergeConn.receiveMsg(payload.msg);
this._saveOffline("default", newDoc);
callback(newDoc);

@@ -157,2 +161,9 @@ };

}
async syncOfflineCache() {
const data = await offline_1.default.get(this._reference, "default");
if (data) {
const roomDoc = automerge_1.load(data);
this._docs.setDoc("default", roomDoc);
}
}
publishState(callback) {

@@ -168,4 +179,3 @@ const newDoc = automerge_1.default.change(this._docs.getDoc("default"), callback);

this._docs.setDoc("default", newDoc);
// TODO OFFLINE HERE
// Offline.set(room.reference, asStr);
this._saveOffline("default", newDoc);
return newDoc;

@@ -172,0 +182,0 @@ }

@@ -6,7 +6,7 @@ /**

*/
import { get, set } from "idb-keyval";
declare const Offline: {
get: typeof get;
set: typeof set;
};
interface IOffline {
get: (roomRef: string, docId: string) => Promise<string>;
set: (roomRef: string, docId: string, value: string) => Promise<any>;
}
declare const Offline: IOffline;
export default Offline;

@@ -10,6 +10,6 @@ "use strict";

const Offline = {
get: idb_keyval_1.get,
set: idb_keyval_1.set
get: (roomRef, docId) => idb_keyval_1.get(roomRef + "/" + docId),
set: (roomRef, docId, value) => idb_keyval_1.set(roomRef + "/" + docId, value)
};
exports.default = Offline;
//# sourceMappingURL=offline.js.map
{
"name": "@roomservice/browser",
"version": "0.0.9",
"version": "0.0.10",
"main": "dist/index",

@@ -19,2 +19,3 @@ "types": "dist/index",

"@types/jest": "^24.0.23",
"@types/lodash": "^4.14.149",
"@types/node": "^12.12.17",

@@ -34,2 +35,3 @@ "@types/safe-json-stringify": "^1.1.0",

"ky-universal": "^0.3.0",
"lodash": "^4.17.15",
"safe-json-stringify": "^1.2.0",

@@ -36,0 +38,0 @@ "socket.io-client": "^2.3.0"

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc