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
395
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.19.0-beta0 to 0.19.0

14

dist/index.d.ts

@@ -11,3 +11,3 @@ import { JsonObject, BaseUserMeta, Client, User } from '@liveblocks/client';

*/
readonly others: Array<User<TPresence, TUserMeta>>;
readonly others: readonly User<TPresence, TUserMeta>[];
/**

@@ -59,6 +59,6 @@ * Whether or not the room storage is currently loading

*/
declare const liveblocksEnhancer: <T>(options: {
declare const liveblocksEnhancer: <TState>(options: {
client: Client;
storageMapping?: Mapping<T> | undefined;
presenceMapping?: Mapping<T> | undefined;
storageMapping?: Mapping<TState> | undefined;
presenceMapping?: Mapping<TState> | undefined;
}) => StoreEnhancer;

@@ -68,8 +68,8 @@ /**

*/
declare const enhancer: <T>(options: {
declare const enhancer: <TState>(options: {
client: Client;
storageMapping?: Mapping<T> | undefined;
presenceMapping?: Mapping<T> | undefined;
storageMapping?: Mapping<TState> | undefined;
presenceMapping?: Mapping<TState> | undefined;
}) => StoreEnhancer;
export { LiveblocksState, Mapping, WithLiveblocks, actions, enhancer, liveblocksEnhancer };

@@ -80,169 +80,168 @@ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var __defProp = Object.defineProperty;

}
return (createStore) => (reducer, initialState, enhancer2) => {
let room = null;
let isPatching = false;
let storageRoot = null;
let unsubscribeCallbacks = [];
const newReducer = (state, action) => {
switch (action.type) {
case ACTION_TYPES.PATCH_REDUX_STATE:
return __spreadValues(__spreadValues({}, state), action.state);
case ACTION_TYPES.INIT_STORAGE:
return __spreadProps(__spreadValues(__spreadValues({}, state), action.state), {
liveblocks: __spreadProps(__spreadValues({}, state.liveblocks), {
isStorageLoading: false
})
});
case ACTION_TYPES.START_LOADING_STORAGE:
return __spreadProps(__spreadValues({}, state), {
liveblocks: __spreadProps(__spreadValues({}, state.liveblocks), {
isStorageLoading: true
})
});
case ACTION_TYPES.UPDATE_CONNECTION: {
return __spreadProps(__spreadValues({}, state), {
liveblocks: __spreadProps(__spreadValues({}, state.liveblocks), {
connection: action.connection
})
});
}
case ACTION_TYPES.UPDATE_OTHERS: {
return __spreadProps(__spreadValues({}, state), {
liveblocks: __spreadProps(__spreadValues({}, state.liveblocks), {
others: action.others
})
});
}
default: {
const newState = reducer(state, action);
if (room) {
isPatching = true;
updatePresence(room, state, newState, presenceMapping);
room.batch(() => {
if (storageRoot) {
patchLiveblocksStorage(
storageRoot,
state,
newState,
mapping
);
}
return (createStore) => {
return (reducer, initialState, enhancer2) => {
let room = null;
let isPatching = false;
let storageRoot = null;
let unsubscribeCallbacks = [];
const newReducer = (state, action) => {
switch (action.type) {
case ACTION_TYPES.PATCH_REDUX_STATE:
return __spreadValues(__spreadValues({}, state), action.state);
case ACTION_TYPES.INIT_STORAGE:
return __spreadProps(__spreadValues(__spreadValues({}, state), action.state), {
liveblocks: __spreadProps(__spreadValues({}, state.liveblocks), {
isStorageLoading: false
})
});
isPatching = false;
case ACTION_TYPES.START_LOADING_STORAGE:
return __spreadProps(__spreadValues({}, state), {
liveblocks: __spreadProps(__spreadValues({}, state.liveblocks), {
isStorageLoading: true
})
});
case ACTION_TYPES.UPDATE_CONNECTION: {
return __spreadProps(__spreadValues({}, state), {
liveblocks: __spreadProps(__spreadValues({}, state.liveblocks), {
connection: action.connection
})
});
}
if (newState.liveblocks == null) {
return __spreadProps(__spreadValues({}, newState), {
liveblocks: {
others: [],
isStorageLoading: false,
connection: "closed"
}
case ACTION_TYPES.UPDATE_OTHERS: {
return __spreadProps(__spreadValues({}, state), {
liveblocks: __spreadProps(__spreadValues({}, state.liveblocks), {
others: action.others
})
});
}
return newState;
default: {
const newState = reducer(state, action);
if (room) {
isPatching = true;
updatePresence(room, state, newState, presenceMapping);
room.batch(() => {
if (storageRoot) {
patchLiveblocksStorage(
storageRoot,
state,
newState,
mapping
);
}
});
isPatching = false;
}
if (newState.liveblocks == null) {
return __spreadProps(__spreadValues({}, newState), {
liveblocks: {
others: [],
isStorageLoading: false,
connection: "closed"
}
});
}
return newState;
}
}
}
};
const store = createStore(newReducer, initialState, enhancer2);
function enterRoom2(roomId) {
if (storageRoot) {
return;
}
const initialPresence = selectFields(
store.getState(),
presenceMapping
);
room = client.enter(roomId, { initialPresence });
unsubscribeCallbacks.push(
room.events.connection.subscribe(() => {
store.dispatch({
type: ACTION_TYPES.UPDATE_CONNECTION,
connection: room.getConnectionState()
});
})
);
unsubscribeCallbacks.push(
room.events.others.subscribe(({ others }) => {
store.dispatch({
type: ACTION_TYPES.UPDATE_OTHERS,
others: others.toArray()
});
})
);
unsubscribeCallbacks.push(
room.events.me.subscribe(() => {
if (isPatching === false) {
};
const store = createStore(newReducer, initialState, enhancer2);
function enterRoom2(roomId) {
if (storageRoot) {
return;
}
const initialPresence = selectFields(
store.getState(),
presenceMapping
);
room = client.enter(roomId, { initialPresence });
unsubscribeCallbacks.push(
room.events.connection.subscribe(() => {
store.dispatch({
type: ACTION_TYPES.PATCH_REDUX_STATE,
state: selectFields(
room.getPresence(),
presenceMapping
)
type: ACTION_TYPES.UPDATE_CONNECTION,
connection: room.getConnectionState()
});
}
})
);
store.dispatch({
type: ACTION_TYPES.START_LOADING_STORAGE
});
room.getStorage().then(({ root }) => {
const updates = {};
room.batch(() => {
for (const key in mapping) {
const liveblocksStatePart = root.get(key);
if (liveblocksStatePart == null) {
updates[key] = store.getState()[key];
_core.patchLiveObjectKey.call(void 0, root, key, void 0, store.getState()[key]);
} else {
updates[key] = _core.lsonToJson.call(void 0, liveblocksStatePart);
})
);
unsubscribeCallbacks.push(
room.events.others.subscribe(({ others }) => {
store.dispatch({
type: ACTION_TYPES.UPDATE_OTHERS,
others
});
})
);
unsubscribeCallbacks.push(
room.events.me.subscribe(() => {
if (isPatching === false) {
store.dispatch({
type: ACTION_TYPES.PATCH_REDUX_STATE,
state: selectFields(room.getPresence(), presenceMapping)
});
}
}
});
})
);
store.dispatch({
type: ACTION_TYPES.INIT_STORAGE,
state: updates
type: ACTION_TYPES.START_LOADING_STORAGE
});
storageRoot = root;
unsubscribeCallbacks.push(
room.subscribe(
root,
(updates2) => {
if (isPatching === false) {
store.dispatch({
type: ACTION_TYPES.PATCH_REDUX_STATE,
state: patchState(
store.getState(),
updates2,
mapping
)
});
room.getStorage().then(({ root }) => {
const updates = {};
room.batch(() => {
for (const key in mapping) {
const liveblocksStatePart = root.get(key);
if (liveblocksStatePart == null) {
updates[key] = store.getState()[key];
_core.patchLiveObjectKey.call(void 0, root, key, void 0, store.getState()[key]);
} else {
updates[key] = _core.lsonToJson.call(void 0, liveblocksStatePart);
}
},
{ isDeep: true }
)
);
});
}
function leaveRoom2(roomId) {
for (const unsubscribe of unsubscribeCallbacks) {
unsubscribe();
}
});
store.dispatch({
type: ACTION_TYPES.INIT_STORAGE,
state: updates
});
storageRoot = root;
unsubscribeCallbacks.push(
room.subscribe(
root,
(updates2) => {
if (isPatching === false) {
store.dispatch({
type: ACTION_TYPES.PATCH_REDUX_STATE,
state: patchState(
store.getState(),
updates2,
mapping
)
});
}
},
{ isDeep: true }
)
);
});
}
storageRoot = null;
room = null;
isPatching = false;
unsubscribeCallbacks = [];
client.leave(roomId);
}
function newDispatch(action, state) {
if (action.type === ACTION_TYPES.ENTER) {
enterRoom2(action.roomId);
} else if (action.type === ACTION_TYPES.LEAVE) {
leaveRoom2(action.roomId);
} else {
store.dispatch(action, state);
function leaveRoom2(roomId) {
for (const unsubscribe of unsubscribeCallbacks) {
unsubscribe();
}
storageRoot = null;
room = null;
isPatching = false;
unsubscribeCallbacks = [];
client.leave(roomId);
}
}
return __spreadProps(__spreadValues({}, store), {
dispatch: newDispatch
});
function newDispatch(action) {
if (action.type === ACTION_TYPES.ENTER) {
enterRoom2(action.roomId);
} else if (action.type === ACTION_TYPES.LEAVE) {
leaveRoom2(action.roomId);
} else {
store.dispatch(action);
}
}
return __spreadProps(__spreadValues({}, store), {
dispatch: newDispatch
});
};
};

@@ -249,0 +248,0 @@ };

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

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

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

@@ -39,0 +39,0 @@ "peerDependencies": {

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