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

@liveblocks/redux

Package Overview
Dependencies
Maintainers
5
Versions
389
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@liveblocks/redux - npm Package Compare versions

Comparing version 0.18.5 to 0.19.0-beta0

61

dist/index.d.ts

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

import { JsonObject, BaseUserMeta, User, Client } from '@liveblocks/client';
import { JsonObject, BaseUserMeta, Client, User } from '@liveblocks/client';
import { StoreEnhancer } from 'redux';

@@ -7,22 +7,27 @@

};
declare type LiveblocksState<TState, TPresence extends JsonObject, TUserMeta extends BaseUserMeta> = TState & {
declare type LiveblocksContext<TPresence extends JsonObject, TUserMeta extends BaseUserMeta> = {
/**
* Liveblocks extra state attached by the enhancer
* Other users in the room. Empty no room is currently synced
*/
readonly liveblocks: {
/**
* Other users in the room. Empty no room is currently synced
*/
readonly others: Array<User<TPresence, TUserMeta>>;
/**
* Whether or not the room storage is currently loading
*/
readonly isStorageLoading: boolean;
/**
* Connection state of the room
*/
readonly connection: "closed" | "authenticating" | "unavailable" | "failed" | "open" | "connecting";
};
readonly others: Array<User<TPresence, TUserMeta>>;
/**
* Whether or not the room storage is currently loading
*/
readonly isStorageLoading: boolean;
/**
* Connection state of the room
*/
readonly connection: "closed" | "authenticating" | "unavailable" | "failed" | "open" | "connecting";
};
/**
* @deprecated Please rename to WithLiveblocks<...>
*/
declare type LiveblocksState<TState, TPresence extends JsonObject, TUserMeta extends BaseUserMeta> = WithLiveblocks<TState, TPresence, TUserMeta>;
/**
* Adds the `liveblocks` property to your custom Redux state.
*/
declare type WithLiveblocks<TState, TPresence extends JsonObject, TUserMeta extends BaseUserMeta> = TState & {
readonly liveblocks: LiveblocksContext<TPresence, TUserMeta>;
};
/**
* Actions used to interact with Liveblocks

@@ -32,9 +37,8 @@ */

/**
* Enters a room and starts sync it with zustand state
* Enters a room and starts sync it with Redux state
* @param roomId The id of the room
* @param initialState The initial state of the room storage. If a key does not exist if your room storage root, initialState[key] will be used.
*/
enterRoom: typeof enterRoom;
/**
* Leaves a room and stops sync it with zustand state.
* Leaves a room and stops sync it with Redux state.
* @param roomId The id of the room

@@ -44,6 +48,5 @@ */

};
declare function enterRoom<T>(roomId: string, initialState?: T): {
declare function enterRoom(roomId: string): {
type: string;
roomId: string;
initialState?: T;
};

@@ -54,2 +57,14 @@ declare function leaveRoom(roomId: string): {

};
/**
* Redux store enhancer that will make the `liveblocks` key available on your
* Redux store.
*/
declare const liveblocksEnhancer: <T>(options: {
client: Client;
storageMapping?: Mapping<T> | undefined;
presenceMapping?: Mapping<T> | undefined;
}) => StoreEnhancer;
/**
* @deprecated Renamed to `liveblocksEnhancer`.
*/
declare const enhancer: <T>(options: {

@@ -61,2 +76,2 @@ client: Client;

export { LiveblocksState, Mapping, actions, enhancer };
export { LiveblocksState, Mapping, WithLiveblocks, actions, enhancer, liveblocksEnhancer };

@@ -146,8 +146,11 @@ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var __defProp = Object.defineProperty;

const store = createStore(newReducer, initialState, enhancer2);
function enterRoom2(roomId, storageInitialState = {}, reduxState) {
function enterRoom2(roomId) {
if (storageRoot) {
return;
}
room = client.enter(roomId, { initialPresence: {} });
broadcastInitialPresence(room, reduxState, presenceMapping);
const initialPresence = selectFields(
store.getState(),
presenceMapping
);
room = client.enter(roomId, { initialPresence });
unsubscribeCallbacks.push(

@@ -174,3 +177,3 @@ room.events.connection.subscribe(() => {

type: ACTION_TYPES.PATCH_REDUX_STATE,
state: patchPresenceState(
state: selectFields(
room.getPresence(),

@@ -192,9 +195,4 @@ presenceMapping

if (liveblocksStatePart == null) {
updates[key] = storageInitialState[key];
_core.patchLiveObjectKey.call(void 0,
root,
key,
void 0,
storageInitialState[key]
);
updates[key] = store.getState()[key];
_core.patchLiveObjectKey.call(void 0, root, key, void 0, store.getState()[key]);
} else {

@@ -242,3 +240,3 @@ updates[key] = _core.lsonToJson.call(void 0, liveblocksStatePart);

if (action.type === ACTION_TYPES.ENTER) {
enterRoom2(action.roomId, action.initialState, store.getState());
enterRoom2(action.roomId);
} else if (action.type === ACTION_TYPES.LEAVE) {

@@ -259,7 +257,6 @@ leaveRoom2(action.roomId);

};
function enterRoom(roomId, initialState) {
function enterRoom(roomId) {
return {
type: ACTION_TYPES.ENTER,
roomId,
initialState
roomId
};

@@ -273,3 +270,4 @@ }

}
var enhancer = internalEnhancer;
var liveblocksEnhancer = internalEnhancer;
var enhancer = liveblocksEnhancer;
function patchLiveblocksStorage(root, oldState, newState, mapping) {

@@ -281,11 +279,8 @@ for (const key in mapping) {

if (oldState[key] !== newState[key]) {
_core.patchLiveObjectKey.call(void 0, root, key, oldState[key], newState[key]);
const oldVal = oldState[key];
const newVal = newState[key];
_core.patchLiveObjectKey.call(void 0, root, key, oldVal, newVal);
}
}
}
function broadcastInitialPresence(room, state, mapping) {
for (const key in mapping) {
room == null ? void 0 : room.updatePresence({ [key]: state[key] });
}
}
function updatePresence(room, oldState, newState, presenceMapping) {

@@ -311,3 +306,3 @@ for (const key in presenceMapping) {

}
function patchPresenceState(presence, mapping) {
function selectFields(presence, mapping) {
const partialState = {};

@@ -351,2 +346,3 @@ for (const key in mapping) {

exports.actions = actions; exports.enhancer = enhancer;
exports.actions = actions; exports.enhancer = enhancer; exports.liveblocksEnhancer = liveblocksEnhancer;
{
"name": "@liveblocks/redux",
"version": "0.18.5",
"version": "0.19.0-beta0",
"description": "A store enhancer to integrate Liveblocks into Redux stores.",

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

"test": "jest --silent --verbose",
"test:watch": "jest --silent --verbose --watch",
"dtslint": "dtslint --localTs node_modules/typescript/lib --expectOnly types"
"test:watch": "jest --silent --verbose --watch"
},

@@ -37,4 +36,4 @@ "license": "Apache-2.0",

"dependencies": {
"@liveblocks/client": "0.18.5",
"@liveblocks/core": "0.18.5"
"@liveblocks/client": "0.19.0-beta0",
"@liveblocks/core": "0.19.0-beta0"
},

@@ -45,3 +44,2 @@ "peerDependencies": {

"devDependencies": {
"@definitelytyped/dtslint": "^0.0.103",
"@liveblocks/eslint-config": "*",

@@ -48,0 +46,0 @@ "@liveblocks/jest-config": "*",

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