@liveblocks/redux
Advanced tools
Comparing version 0.16.17 to 0.17.0-beta1
@@ -1,25 +0,35 @@ | ||
import { Presence, User, Client } from '@liveblocks/client'; | ||
import { StoreEnhancer } from 'redux'; | ||
import { JsonObject, BaseUserMeta, User, Client } from "@liveblocks/client"; | ||
import { StoreEnhancer } from "redux"; | ||
declare type Mapping<T> = Partial<{ | ||
[Property in keyof T]: boolean; | ||
}>; | ||
declare type LiveblocksState<TState, TPresence extends Presence = Presence> = TState & { | ||
declare type Mapping<T> = { | ||
[K in keyof T]?: boolean; | ||
}; | ||
declare type LiveblocksState< | ||
TState, | ||
TPresence extends JsonObject, | ||
TUserMeta extends BaseUserMeta | ||
> = TState & { | ||
/** | ||
* Liveblocks extra state attached by the enhancer | ||
*/ | ||
readonly liveblocks: { | ||
/** | ||
* 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>>; | ||
/** | ||
* 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"; | ||
}; | ||
}; | ||
@@ -30,29 +40,32 @@ /** | ||
declare const actions: { | ||
/** | ||
* Enters a room and starts sync it with zustand 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. | ||
* @param roomId The id of the room | ||
*/ | ||
leaveRoom: typeof leaveRoom; | ||
/** | ||
* Enters a room and starts sync it with zustand 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. | ||
* @param roomId The id of the room | ||
*/ | ||
leaveRoom: typeof leaveRoom; | ||
}; | ||
declare function enterRoom(roomId: string, initialState?: any): { | ||
type: string; | ||
roomId: string; | ||
initialState: any; | ||
declare function enterRoom<T>( | ||
roomId: string, | ||
initialState?: T | ||
): { | ||
type: string; | ||
roomId: string; | ||
initialState?: T; | ||
}; | ||
declare function leaveRoom(roomId: string): { | ||
type: string; | ||
roomId: string; | ||
type: string; | ||
roomId: string; | ||
}; | ||
declare const enhancer: <T>(options: { | ||
client: Client; | ||
storageMapping?: Partial<{ [Property in keyof T]: boolean; }> | undefined; | ||
presenceMapping?: Partial<{ [Property in keyof T]: boolean; }> | undefined; | ||
client: Client; | ||
storageMapping?: Mapping<T> | undefined; | ||
presenceMapping?: Mapping<T> | undefined; | ||
}) => StoreEnhancer; | ||
export { LiveblocksState, Mapping, actions, enhancer }; |
533
index.js
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: !0 | ||
}); | ||
Object.defineProperty(exports, "__esModule", { value: !0 }); | ||
var internal = require("@liveblocks/client/internal"); | ||
function _extends() { | ||
return _extends = Object.assign || function(target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i]; | ||
for (var key in source) Object.prototype.hasOwnProperty.call(source, key) && (target[key] = source[key]); | ||
} | ||
return target; | ||
}, _extends.apply(this, arguments); | ||
return ( | ||
(_extends = | ||
Object.assign || | ||
function (target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i]; | ||
for (var key in source) | ||
Object.prototype.hasOwnProperty.call(source, key) && | ||
(target[key] = source[key]); | ||
} | ||
return target; | ||
}), | ||
_extends.apply(this, arguments) | ||
); | ||
} | ||
function _arrayLikeToArray(arr, len) { | ||
(null == len || len > arr.length) && (len = arr.length); | ||
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; | ||
return arr2; | ||
(null == len || len > arr.length) && (len = arr.length); | ||
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; | ||
return arr2; | ||
} | ||
function _createForOfIteratorHelperLoose(o, allowArrayLike) { | ||
var it = "undefined" != typeof Symbol && o[Symbol.iterator] || o["@@iterator"]; | ||
if (it) return (it = it.call(o)).next.bind(it); | ||
if (Array.isArray(o) || (it = function(o, minLen) { | ||
if (o) { | ||
if ("string" == typeof o) return _arrayLikeToArray(o, minLen); | ||
var n = Object.prototype.toString.call(o).slice(8, -1); | ||
return "Object" === n && o.constructor && (n = o.constructor.name), "Map" === n || "Set" === n ? Array.from(o) : "Arguments" === n || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n) ? _arrayLikeToArray(o, minLen) : void 0; | ||
var it = | ||
("undefined" != typeof Symbol && o[Symbol.iterator]) || o["@@iterator"]; | ||
if (it) return (it = it.call(o)).next.bind(it); | ||
if ( | ||
Array.isArray(o) || | ||
(it = (function (o, minLen) { | ||
if (o) { | ||
if ("string" == typeof o) return _arrayLikeToArray(o, minLen); | ||
var n = Object.prototype.toString.call(o).slice(8, -1); | ||
return ( | ||
"Object" === n && o.constructor && (n = o.constructor.name), | ||
"Map" === n || "Set" === n | ||
? Array.from(o) | ||
: "Arguments" === n || | ||
/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n) | ||
? _arrayLikeToArray(o, minLen) | ||
: void 0 | ||
); | ||
} | ||
})(o)) || | ||
(allowArrayLike && o && "number" == typeof o.length) | ||
) { | ||
it && (o = it); | ||
var i = 0; | ||
return function () { | ||
return i >= o.length ? { done: !0 } : { done: !1, value: o[i++] }; | ||
}; | ||
} | ||
}(o)) || allowArrayLike && o && "number" == typeof o.length) { | ||
it && (o = it); | ||
var i = 0; | ||
return function() { | ||
return i >= o.length ? { | ||
done: !0 | ||
} : { | ||
done: !1, | ||
value: o[i++] | ||
}; | ||
}; | ||
} | ||
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); | ||
throw new TypeError( | ||
"Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method." | ||
); | ||
} | ||
var ERROR_PREFIX = "Invalid @liveblocks/redux middleware config."; | ||
function mappingValueShouldBeABoolean(mappingType, key) { | ||
return new Error(ERROR_PREFIX + " " + mappingType + "." + key + " value should be a boolean"); | ||
return new Error( | ||
ERROR_PREFIX + " " + mappingType + "." + key + " value should be a boolean" | ||
); | ||
} | ||
function mappingShouldNotHaveTheSameKeys(key) { | ||
return new Error(ERROR_PREFIX + ' "' + key + "\" is mapped on presenceMapping and storageMapping. A key shouldn't exist on both mapping."); | ||
return new Error( | ||
ERROR_PREFIX + | ||
' "' + | ||
key + | ||
"\" is mapped on presenceMapping and storageMapping. A key shouldn't exist on both mapping." | ||
); | ||
} | ||
function mappingToFunctionIsNotAllowed(key) { | ||
return new Error(ERROR_PREFIX + " mapping." + key + " is invalid. Mapping to a function is not allowed."); | ||
return new Error( | ||
ERROR_PREFIX + | ||
" mapping." + | ||
key + | ||
" is invalid. Mapping to a function is not allowed." | ||
); | ||
} | ||
var ACTION_TYPES_ENTER = "@@LIVEBLOCKS/ENTER", ACTION_TYPES_LEAVE = "@@LIVEBLOCKS/LEAVE", ACTION_TYPES_START_LOADING_STORAGE = "@@LIVEBLOCKS/START_LOADING_STORAGE", ACTION_TYPES_INIT_STORAGE = "@@LIVEBLOCKS/INIT_STORAGE", ACTION_TYPES_PATCH_REDUX_STATE = "@@LIVEBLOCKS/PATCH_REDUX_STATE", ACTION_TYPES_UPDATE_CONNECTION = "@@LIVEBLOCKS/UPDATE_CONNECTION", ACTION_TYPES_UPDATE_OTHERS = "@@LIVEBLOCKS/UPDATE_OTHERS", actions = { | ||
enterRoom: function(roomId, initialState) { | ||
return { | ||
type: ACTION_TYPES_ENTER, | ||
roomId: roomId, | ||
initialState: initialState | ||
var ACTION_TYPES_ENTER = "@@LIVEBLOCKS/ENTER", | ||
ACTION_TYPES_LEAVE = "@@LIVEBLOCKS/LEAVE", | ||
ACTION_TYPES_START_LOADING_STORAGE = "@@LIVEBLOCKS/START_LOADING_STORAGE", | ||
ACTION_TYPES_INIT_STORAGE = "@@LIVEBLOCKS/INIT_STORAGE", | ||
ACTION_TYPES_PATCH_REDUX_STATE = "@@LIVEBLOCKS/PATCH_REDUX_STATE", | ||
ACTION_TYPES_UPDATE_CONNECTION = "@@LIVEBLOCKS/UPDATE_CONNECTION", | ||
ACTION_TYPES_UPDATE_OTHERS = "@@LIVEBLOCKS/UPDATE_OTHERS", | ||
actions = { | ||
enterRoom: function (roomId, initialState) { | ||
return { | ||
type: ACTION_TYPES_ENTER, | ||
roomId: roomId, | ||
initialState: initialState, | ||
}; | ||
}, | ||
leaveRoom: function (roomId) { | ||
return { type: ACTION_TYPES_LEAVE, roomId: roomId }; | ||
}, | ||
}; | ||
}, | ||
leaveRoom: function(roomId) { | ||
return { | ||
type: ACTION_TYPES_LEAVE, | ||
roomId: roomId | ||
}; | ||
} | ||
}; | ||
var enhancer = function (options) { | ||
if ("production" !== process.env.NODE_ENV && null == options.client) | ||
throw new Error(ERROR_PREFIX + " client is missing"); | ||
var client = options.client, | ||
mapping = validateMapping(options.storageMapping || {}, "storageMapping"), | ||
presenceMapping = validateMapping( | ||
options.presenceMapping || {}, | ||
"presenceMapping" | ||
); | ||
return ( | ||
"production" !== process.env.NODE_ENV && | ||
(function (storageMapping, presenceMapping) { | ||
for (var key in storageMapping) | ||
if (void 0 !== presenceMapping[key]) | ||
throw mappingShouldNotHaveTheSameKeys(key); | ||
})(mapping, presenceMapping), | ||
function (createStore) { | ||
return function (reducer, initialState, enhancer) { | ||
var room = null, | ||
isPatching = !1, | ||
storageRoot = null, | ||
unsubscribeCallbacks = [], | ||
store = createStore( | ||
function (state, action) { | ||
switch (action.type) { | ||
case ACTION_TYPES_PATCH_REDUX_STATE: | ||
return _extends({}, state, action.state); | ||
case ACTION_TYPES_INIT_STORAGE: | ||
return _extends({}, state, action.state, { | ||
liveblocks: _extends({}, state.liveblocks, { | ||
isStorageLoading: !1, | ||
}), | ||
}); | ||
case ACTION_TYPES_START_LOADING_STORAGE: | ||
return _extends({}, state, { | ||
liveblocks: _extends({}, state.liveblocks, { | ||
isStorageLoading: !0, | ||
}), | ||
}); | ||
case ACTION_TYPES_UPDATE_CONNECTION: | ||
return _extends({}, state, { | ||
liveblocks: _extends({}, state.liveblocks, { | ||
connection: action.connection, | ||
}), | ||
}); | ||
case ACTION_TYPES_UPDATE_OTHERS: | ||
return _extends({}, state, { | ||
liveblocks: _extends({}, state.liveblocks, { | ||
others: action.others, | ||
}), | ||
}); | ||
default: | ||
var newState = reducer(state, action); | ||
return ( | ||
room && | ||
((isPatching = !0), | ||
(function (room, oldState, newState, presenceMapping) { | ||
for (var key in presenceMapping) { | ||
if ("function" == typeof newState[key]) | ||
throw mappingToFunctionIsNotAllowed("value"); | ||
var _room$updatePresence2; | ||
if (oldState[key] !== newState[key]) | ||
room.updatePresence( | ||
(((_room$updatePresence2 = {})[key] = | ||
newState[key]), | ||
_room$updatePresence2) | ||
); | ||
} | ||
})(room, state, newState, presenceMapping), | ||
room.batch(function () { | ||
storageRoot && | ||
(function (root, oldState, newState, mapping) { | ||
for (var key in mapping) { | ||
if ( | ||
"production" !== process.env.NODE_ENV && | ||
"function" == typeof newState[key] | ||
) | ||
throw mappingToFunctionIsNotAllowed("value"); | ||
oldState[key] !== newState[key] && | ||
internal.patchLiveObjectKey( | ||
root, | ||
key, | ||
oldState[key], | ||
newState[key] | ||
); | ||
} | ||
})(storageRoot, state, newState, mapping); | ||
}), | ||
(isPatching = !1)), | ||
null == newState.liveblocks | ||
? _extends({}, newState, { | ||
liveblocks: { | ||
others: [], | ||
isStorageLoading: !1, | ||
connection: "closed", | ||
}, | ||
}) | ||
: newState | ||
); | ||
} | ||
}, | ||
initialState, | ||
enhancer | ||
); | ||
return _extends({}, store, { | ||
dispatch: function (action, state) { | ||
var roomId, storageInitialState, reduxState; | ||
action.type === ACTION_TYPES_ENTER | ||
? ((roomId = action.roomId), | ||
(storageInitialState = action.initialState), | ||
(reduxState = store.getState()), | ||
void 0 === storageInitialState && (storageInitialState = {}), | ||
storageRoot || | ||
((function (room, state, mapping) { | ||
for (var key in mapping) { | ||
var _room$updatePresence; | ||
null == room || | ||
room.updatePresence( | ||
(((_room$updatePresence = {})[key] = state[key]), | ||
_room$updatePresence) | ||
); | ||
} | ||
})( | ||
(room = client.enter(roomId)), | ||
reduxState, | ||
presenceMapping | ||
), | ||
unsubscribeCallbacks.push( | ||
room.subscribe("connection", function () { | ||
store.dispatch({ | ||
type: ACTION_TYPES_UPDATE_CONNECTION, | ||
connection: room.getConnectionState(), | ||
}); | ||
}) | ||
), | ||
unsubscribeCallbacks.push( | ||
room.subscribe("others", function (others) { | ||
store.dispatch({ | ||
type: ACTION_TYPES_UPDATE_OTHERS, | ||
others: others.toArray(), | ||
}); | ||
}) | ||
), | ||
unsubscribeCallbacks.push( | ||
room.subscribe("my-presence", function () { | ||
!1 === isPatching && | ||
store.dispatch({ | ||
type: ACTION_TYPES_PATCH_REDUX_STATE, | ||
state: patchPresenceState( | ||
room.getPresence(), | ||
presenceMapping | ||
), | ||
}); | ||
}) | ||
), | ||
store.dispatch({ type: ACTION_TYPES_START_LOADING_STORAGE }), | ||
room.getStorage().then(function (_ref) { | ||
var root = _ref.root, | ||
updates = {}; | ||
room.batch(function () { | ||
for (var key in mapping) { | ||
var liveblocksStatePart = root.get(key); | ||
null == liveblocksStatePart | ||
? ((updates[key] = storageInitialState[key]), | ||
internal.patchLiveObjectKey( | ||
root, | ||
key, | ||
void 0, | ||
storageInitialState[key] | ||
)) | ||
: (updates[key] = | ||
internal.lsonToJson(liveblocksStatePart)); | ||
} | ||
}), | ||
store.dispatch({ | ||
type: ACTION_TYPES_INIT_STORAGE, | ||
state: updates, | ||
}), | ||
(storageRoot = root), | ||
unsubscribeCallbacks.push( | ||
room.subscribe( | ||
root, | ||
function (updates) { | ||
!1 === isPatching && | ||
store.dispatch({ | ||
type: ACTION_TYPES_PATCH_REDUX_STATE, | ||
state: patchState( | ||
store.getState(), | ||
updates, | ||
mapping | ||
), | ||
}); | ||
}, | ||
{ isDeep: !0 } | ||
) | ||
); | ||
}))) | ||
: action.type === ACTION_TYPES_LEAVE | ||
? (function (roomId) { | ||
for ( | ||
var _step, | ||
_iterator = | ||
_createForOfIteratorHelperLoose(unsubscribeCallbacks); | ||
!(_step = _iterator()).done; | ||
var enhancer = function(options) { | ||
if ("production" !== process.env.NODE_ENV && null == options.client) throw new Error(ERROR_PREFIX + " client is missing"); | ||
var client = options.client, mapping = validateMapping(options.storageMapping || {}, "storageMapping"), presenceMapping = validateMapping(options.presenceMapping || {}, "presenceMapping"); | ||
return "production" !== process.env.NODE_ENV && function(storageMapping, presenceMapping) { | ||
for (var key in storageMapping) if (void 0 !== presenceMapping[key]) throw mappingShouldNotHaveTheSameKeys(key); | ||
}(mapping, presenceMapping), function(createStore) { | ||
return function(reducer, initialState, enhancer) { | ||
var room = null, isPatching = !1, storageRoot = null, unsubscribeCallbacks = [], store = createStore((function(state, action) { | ||
switch (action.type) { | ||
case ACTION_TYPES_PATCH_REDUX_STATE: | ||
return _extends({}, state, action.state); | ||
case ACTION_TYPES_INIT_STORAGE: | ||
return _extends({}, state, action.state, { | ||
liveblocks: _extends({}, state.liveblocks, { | ||
isStorageLoading: !1 | ||
}) | ||
}); | ||
case ACTION_TYPES_START_LOADING_STORAGE: | ||
return _extends({}, state, { | ||
liveblocks: _extends({}, state.liveblocks, { | ||
isStorageLoading: !0 | ||
}) | ||
}); | ||
case ACTION_TYPES_UPDATE_CONNECTION: | ||
return _extends({}, state, { | ||
liveblocks: _extends({}, state.liveblocks, { | ||
connection: action.connection | ||
}) | ||
}); | ||
case ACTION_TYPES_UPDATE_OTHERS: | ||
return _extends({}, state, { | ||
liveblocks: _extends({}, state.liveblocks, { | ||
others: action.others | ||
}) | ||
}); | ||
default: | ||
var newState = reducer(state, action); | ||
return room && (isPatching = !0, function(room, oldState, newState, presenceMapping) { | ||
for (var key in presenceMapping) { | ||
if ("function" == typeof newState[key]) throw mappingToFunctionIsNotAllowed("value"); | ||
var _room$updatePresence2; | ||
if (oldState[key] !== newState[key]) room.updatePresence(((_room$updatePresence2 = {})[key] = newState[key], | ||
_room$updatePresence2)); | ||
} | ||
}(room, state, newState, presenceMapping), room.batch((function() { | ||
storageRoot && function(root, oldState, newState, mapping) { | ||
for (var key in mapping) { | ||
if ("production" !== process.env.NODE_ENV && "function" == typeof newState[key]) throw mappingToFunctionIsNotAllowed("value"); | ||
oldState[key] !== newState[key] && internal.patchLiveObjectKey(root, key, oldState[key], newState[key]); | ||
} | ||
}(storageRoot, state, newState, mapping); | ||
})), isPatching = !1), null == newState.liveblocks ? _extends({}, newState, { | ||
liveblocks: { | ||
others: [], | ||
isStorageLoading: !1, | ||
connection: "closed" | ||
} | ||
}) : newState; | ||
) | ||
(0, _step.value)(); | ||
(storageRoot = null), | ||
(room = null), | ||
(isPatching = !1), | ||
(unsubscribeCallbacks = []), | ||
client.leave(roomId); | ||
})(action.roomId) | ||
: store.dispatch(action, state); | ||
}, | ||
}); | ||
}; | ||
} | ||
}), initialState, enhancer); | ||
return _extends({}, store, { | ||
dispatch: function(action, state) { | ||
var roomId, storageInitialState, reduxState; | ||
action.type === ACTION_TYPES_ENTER ? (roomId = action.roomId, storageInitialState = action.initialState, | ||
reduxState = store.getState(), void 0 === storageInitialState && (storageInitialState = {}), | ||
storageRoot || (function(room, state, mapping) { | ||
for (var key in mapping) { | ||
var _room$updatePresence; | ||
null == room || room.updatePresence(((_room$updatePresence = {})[key] = state[key], | ||
_room$updatePresence)); | ||
} | ||
}(room = client.enter(roomId), reduxState, presenceMapping), unsubscribeCallbacks.push(room.subscribe("connection", (function() { | ||
store.dispatch({ | ||
type: ACTION_TYPES_UPDATE_CONNECTION, | ||
connection: room.getConnectionState() | ||
}); | ||
}))), unsubscribeCallbacks.push(room.subscribe("others", (function(others) { | ||
store.dispatch({ | ||
type: ACTION_TYPES_UPDATE_OTHERS, | ||
others: others.toArray() | ||
}); | ||
}))), unsubscribeCallbacks.push(room.subscribe("my-presence", (function() { | ||
!1 === isPatching && store.dispatch({ | ||
type: ACTION_TYPES_PATCH_REDUX_STATE, | ||
state: patchPresenceState(room.getPresence(), presenceMapping) | ||
}); | ||
}))), store.dispatch({ | ||
type: ACTION_TYPES_START_LOADING_STORAGE | ||
}), room.getStorage().then((function(_ref) { | ||
var root = _ref.root, updates = {}; | ||
room.batch((function() { | ||
for (var key in mapping) { | ||
var liveblocksStatePart = root.get(key); | ||
null == liveblocksStatePart ? (updates[key] = storageInitialState[key], internal.patchLiveObjectKey(root, key, void 0, storageInitialState[key])) : updates[key] = internal.lsonToJson(liveblocksStatePart); | ||
} | ||
})), store.dispatch({ | ||
type: ACTION_TYPES_INIT_STORAGE, | ||
state: updates | ||
}), storageRoot = root, unsubscribeCallbacks.push(room.subscribe(root, (function(updates) { | ||
!1 === isPatching && store.dispatch({ | ||
type: ACTION_TYPES_PATCH_REDUX_STATE, | ||
state: patchState(store.getState(), updates, mapping) | ||
}); | ||
}), { | ||
isDeep: !0 | ||
})); | ||
})))) : action.type === ACTION_TYPES_LEAVE ? function(roomId) { | ||
for (var _step, _iterator = _createForOfIteratorHelperLoose(unsubscribeCallbacks); !(_step = _iterator()).done; ) (0, | ||
_step.value)(); | ||
storageRoot = null, room = null, isPatching = !1, unsubscribeCallbacks = [], client.leave(roomId); | ||
}(action.roomId) : store.dispatch(action, state); | ||
} | ||
}); | ||
}; | ||
}; | ||
); | ||
}; | ||
function patchPresenceState(presence, mapping) { | ||
var partialState = {}; | ||
for (var key in mapping) partialState[key] = presence[key]; | ||
return partialState; | ||
var partialState = {}; | ||
for (var key in mapping) partialState[key] = presence[key]; | ||
return partialState; | ||
} | ||
function patchState(state, updates, mapping) { | ||
var partialState = {}; | ||
for (var key in mapping) partialState[key] = state[key]; | ||
var patched = internal.patchImmutableObject(partialState, updates), result = {}; | ||
for (var _key in mapping) result[_key] = patched[_key]; | ||
return result; | ||
var partialState = {}; | ||
for (var key in mapping) partialState[key] = state[key]; | ||
var patched = internal.patchImmutableObject(partialState, updates), | ||
result = {}; | ||
for (var _key in mapping) result[_key] = patched[_key]; | ||
return result; | ||
} | ||
function validateMapping(mapping, mappingType) { | ||
if ("production" !== process.env.NODE_ENV && (value = mapping, "[object Object]" !== Object.prototype.toString.call(value))) throw function(mappingType) { | ||
return new Error(ERROR_PREFIX + " " + mappingType + " should be an object where the values are boolean."); | ||
}(mappingType); | ||
var value, result = {}; | ||
for (var key in mapping) { | ||
if ("production" !== process.env.NODE_ENV && "boolean" != typeof mapping[key]) throw mappingValueShouldBeABoolean(mappingType, key); | ||
!0 === mapping[key] && (result[key] = !0); | ||
} | ||
return result; | ||
if ( | ||
"production" !== process.env.NODE_ENV && | ||
((value = mapping), | ||
"[object Object]" !== Object.prototype.toString.call(value)) | ||
) | ||
throw (function (mappingType) { | ||
return new Error( | ||
ERROR_PREFIX + | ||
" " + | ||
mappingType + | ||
" should be an object where the values are boolean." | ||
); | ||
})(mappingType); | ||
var value, | ||
result = {}; | ||
for (var key in mapping) { | ||
if ( | ||
"production" !== process.env.NODE_ENV && | ||
"boolean" != typeof mapping[key] | ||
) | ||
throw mappingValueShouldBeABoolean(mappingType, key); | ||
!0 === mapping[key] && (result[key] = !0); | ||
} | ||
return result; | ||
} | ||
exports.actions = actions, exports.enhancer = enhancer; | ||
(exports.actions = actions), (exports.enhancer = enhancer); |
{ | ||
"name": "@liveblocks/redux", | ||
"version": "0.16.17", | ||
"version": "0.17.0-beta1", | ||
"description": "A store enhancer to integrate Liveblocks into Redux stores.", | ||
@@ -23,4 +23,4 @@ "main": "./index.js", | ||
"lint": "eslint src/ test/", | ||
"test": "jest --watch", | ||
"test-ci": "jest", | ||
"test": "jest --watch --silent --verbose", | ||
"test-ci": "jest --silent --verbose", | ||
"dtslint": "dtslint --localTs node_modules/typescript/lib --expectOnly types" | ||
@@ -35,3 +35,3 @@ }, | ||
"peerDependencies": { | ||
"@liveblocks/client": "0.16.17", | ||
"@liveblocks/client": "0.17.0-beta1", | ||
"redux": "^4" | ||
@@ -52,5 +52,5 @@ }, | ||
"@testing-library/react-hooks": "^7.0.2", | ||
"@types/jest": "^27.4.1", | ||
"@typescript-eslint/eslint-plugin": "^5.18.0", | ||
"@typescript-eslint/parser": "^5.18.0", | ||
"@types/jest": "^27.5.1", | ||
"@typescript-eslint/eslint-plugin": "^5.26.0", | ||
"@typescript-eslint/parser": "^5.26.0", | ||
"eslint": "^8.12.0", | ||
@@ -64,4 +64,6 @@ "eslint-plugin-import": "^2.26.0", | ||
"rollup-plugin-command": "^1.1.3", | ||
"rollup-plugin-dts": "^4.2.1", | ||
"rollup-plugin-dts": "^4.2.2", | ||
"rollup-plugin-prettier": "^2.2.2", | ||
"rollup-plugin-terser": "^7.0.2", | ||
"typescript": "^4.7.2", | ||
"whatwg-fetch": "^3.6.2" | ||
@@ -68,0 +70,0 @@ }, |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
30512
700
28