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

@liveblocks/client

Package Overview
Dependencies
Maintainers
2
Versions
404
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@liveblocks/client - npm Package Compare versions

Comparing version 0.6.0-beta to 0.6.0-beta.2

4

lib/cjs/live.d.ts

@@ -8,3 +8,3 @@ import { Presence } from "./types";

Event = 103,
InitialDocumentState = 200,
InitialStorageState = 200,
UpdateStorage = 201

@@ -31,3 +31,3 @@ }

export declare type InitialDocumentStateMessage = {
type: ServerMessageType.InitialDocumentState;
type: ServerMessageType.InitialStorageState;
root: SerializedRecord | null;

@@ -34,0 +34,0 @@ };

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

ServerMessageType[ServerMessageType["Event"] = 103] = "Event";
ServerMessageType[ServerMessageType["InitialDocumentState"] = 200] = "InitialDocumentState";
ServerMessageType[ServerMessageType["InitialStorageState"] = 200] = "InitialStorageState";
ServerMessageType[ServerMessageType["UpdateStorage"] = 201] = "UpdateStorage";

@@ -13,0 +13,0 @@ })(ServerMessageType = exports.ServerMessageType || (exports.ServerMessageType = {}));

@@ -70,6 +70,20 @@ "use strict";

}
function makeIdFactory(actor) {
function makeIdFactory(connectionId) {
let count = 0;
return () => `${actor}:${count++}`;
return () => `${connectionId}:${count++}`;
}
function makeOthers(presenceMap) {
const array = Object.entries(presenceMap).map((entry) => [parseInt(entry[0]), entry[1]]);
return {
get count() {
return array.length;
},
map(callback) {
return array.map(callback);
},
toArray() {
return array;
},
};
}
function createRoom(name, options) {

@@ -96,2 +110,3 @@ const liveblocksServer = options.liveblocksServer || "wss://live.liveblocks.io";

let _users = {};
let _others = makeOthers({});
let state = types_1.RoomState.Default;

@@ -118,4 +133,5 @@ let numberOfRetry = 0;

_users = users;
_others = makeOthers(users);
for (const listener of _listeners["others-presence"]) {
listener(users);
listener(_others);
}

@@ -193,3 +209,3 @@ }

}
function onGetDocument(message) {
function onInitialStorageState(message) {
_storageState = types_1.LiveStorageState.Loaded;

@@ -208,3 +224,3 @@ if (message.root == null) {

}
function onDocumentUpdates(message) {
function onStorageUpdates(message) {
if (_doc == null) {

@@ -228,3 +244,3 @@ // TODO: Cache updates in case they are coming while root is queried

for (const listener of _listeners.event) {
listener({ actor: message.actor, event: message.event });
listener({ connectionId: message.actor, event: message.event });
}

@@ -235,8 +251,8 @@ }

switch (message.type) {
case live_1.ServerMessageType.InitialDocumentState: {
onGetDocument(message);
case live_1.ServerMessageType.InitialStorageState: {
onInitialStorageState(message);
break;
}
case live_1.ServerMessageType.UpdateStorage: {
onDocumentUpdates(message);
onStorageUpdates(message);
break;

@@ -337,3 +353,3 @@ }

function getOthers() {
return _users;
return _others;
}

@@ -340,0 +356,0 @@ function updatePresence(overrides) {

@@ -5,5 +5,7 @@ import { RecordData, Record, List } from "./doc";

*/
export declare type Others<T extends Presence = Presence> = {
[id: string]: T | null;
};
export interface Others<T extends Presence = Presence> {
readonly count: number;
toArray(): Array<[connectionId: number, presence: T | undefined]>;
map<U>(callback: (entry: [connectionId: number, presence: T | undefined]) => U): Array<U>;
}
export declare type Presence = Serializable;

@@ -71,4 +73,4 @@ export declare type SerializablePrimitive = boolean | string | number | null;

export declare type OthersPresenceEventCallback<T extends Presence = Presence> = (others: Others<T>) => void;
export declare type EventEventCallback = ({ actor, event, }: {
actor: number;
export declare type EventEventCallback = ({ connectionId, event, }: {
connectionId: number;
event: any;

@@ -75,0 +77,0 @@ }) => void;

@@ -8,3 +8,3 @@ import { Presence } from "./types";

Event = 103,
InitialDocumentState = 200,
InitialStorageState = 200,
UpdateStorage = 201

@@ -31,3 +31,3 @@ }

export declare type InitialDocumentStateMessage = {
type: ServerMessageType.InitialDocumentState;
type: ServerMessageType.InitialStorageState;
root: SerializedRecord | null;

@@ -34,0 +34,0 @@ };

@@ -7,3 +7,3 @@ export var ServerMessageType;

ServerMessageType[ServerMessageType["Event"] = 103] = "Event";
ServerMessageType[ServerMessageType["InitialDocumentState"] = 200] = "InitialDocumentState";
ServerMessageType[ServerMessageType["InitialStorageState"] = 200] = "InitialStorageState";
ServerMessageType[ServerMessageType["UpdateStorage"] = 201] = "UpdateStorage";

@@ -10,0 +10,0 @@ })(ServerMessageType || (ServerMessageType = {}));

@@ -48,6 +48,20 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

}
function makeIdFactory(actor) {
function makeIdFactory(connectionId) {
let count = 0;
return () => `${actor}:${count++}`;
return () => `${connectionId}:${count++}`;
}
function makeOthers(presenceMap) {
const array = Object.entries(presenceMap).map((entry) => [parseInt(entry[0]), entry[1]]);
return {
get count() {
return array.length;
},
map(callback) {
return array.map(callback);
},
toArray() {
return array;
},
};
}
export function createRoom(name, options) {

@@ -74,2 +88,3 @@ const liveblocksServer = options.liveblocksServer || "wss://live.liveblocks.io";

let _users = {};
let _others = makeOthers({});
let state = RoomState.Default;

@@ -96,4 +111,5 @@ let numberOfRetry = 0;

_users = users;
_others = makeOthers(users);
for (const listener of _listeners["others-presence"]) {
listener(users);
listener(_others);
}

@@ -171,3 +187,3 @@ }

}
function onGetDocument(message) {
function onInitialStorageState(message) {
_storageState = LiveStorageState.Loaded;

@@ -186,3 +202,3 @@ if (message.root == null) {

}
function onDocumentUpdates(message) {
function onStorageUpdates(message) {
if (_doc == null) {

@@ -206,3 +222,3 @@ // TODO: Cache updates in case they are coming while root is queried

for (const listener of _listeners.event) {
listener({ actor: message.actor, event: message.event });
listener({ connectionId: message.actor, event: message.event });
}

@@ -213,8 +229,8 @@ }

switch (message.type) {
case ServerMessageType.InitialDocumentState: {
onGetDocument(message);
case ServerMessageType.InitialStorageState: {
onInitialStorageState(message);
break;
}
case ServerMessageType.UpdateStorage: {
onDocumentUpdates(message);
onStorageUpdates(message);
break;

@@ -315,3 +331,3 @@ }

function getOthers() {
return _users;
return _others;
}

@@ -318,0 +334,0 @@ function updatePresence(overrides) {

@@ -5,5 +5,7 @@ import { RecordData, Record, List } from "./doc";

*/
export declare type Others<T extends Presence = Presence> = {
[id: string]: T | null;
};
export interface Others<T extends Presence = Presence> {
readonly count: number;
toArray(): Array<[connectionId: number, presence: T | undefined]>;
map<U>(callback: (entry: [connectionId: number, presence: T | undefined]) => U): Array<U>;
}
export declare type Presence = Serializable;

@@ -71,4 +73,4 @@ export declare type SerializablePrimitive = boolean | string | number | null;

export declare type OthersPresenceEventCallback<T extends Presence = Presence> = (others: Others<T>) => void;
export declare type EventEventCallback = ({ actor, event, }: {
actor: number;
export declare type EventEventCallback = ({ connectionId, event, }: {
connectionId: number;
event: any;

@@ -75,0 +77,0 @@ }) => void;

{
"name": "@liveblocks/client",
"version": "0.6.0-beta",
"version": "0.6.0-beta.2",
"description": "",

@@ -5,0 +5,0 @@ "main": "./lib/cjs/index.js",

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