reductive-dev-tools
Advanced tools
Comparing version 0.1.4 to 0.1.5
@@ -156,6 +156,6 @@ // Generated by BUCKLESCRIPT VERSION 4.0.18, PLEASE EDIT WITH CARE | ||
var retainedStates = { }; | ||
var connections = { }; | ||
function getState(store) { | ||
return retainedStates[store[/* connectionId */1]]; | ||
return connections[store[/* connectionId */1]][/* retainedState */0]; | ||
} | ||
@@ -315,5 +315,9 @@ | ||
]); | ||
var liftedState = JSON.parse(stateString$1); | ||
Extension$ReductiveDevTools.send(devTools$1, null, processToogleAction(store$3, payload$2, liftedState, meta$2)); | ||
return notifyListeners(store$3); | ||
if (Belt_Option.isSome(meta$2[/* rewindActionIdx */1]) && Belt_Option.getExn(meta$2[/* rewindActionIdx */1]) >= meta$2[/* actionCount */2] || Belt_Option.isNone(meta$2[/* rewindActionIdx */1])) { | ||
var liftedState = JSON.parse(stateString$1); | ||
Extension$ReductiveDevTools.send(devTools$1, null, processToogleAction(store$3, payload$2, liftedState, meta$2)); | ||
return notifyListeners(store$3); | ||
} else { | ||
return 0; | ||
} | ||
default: | ||
@@ -430,4 +434,2 @@ return /* () */0; | ||
var connections = { }; | ||
function register(connectionId, component, options, param) { | ||
@@ -437,13 +439,20 @@ var targetOptions = options !== undefined ? constructOptions(Caml_option.valFromOption(options), defaultOptions(connectionId)) : defaultOptions(connectionId); | ||
var actionCreators = targetOptions.actionCreators; | ||
connections[connectionId] = devTools; | ||
retainedStates[connectionId] = component[/* state */1]; | ||
var meta = /* record */Block.record([ | ||
"liftedState", | ||
"rewindActionIdx", | ||
"actionCount" | ||
var connectionInfo = /* record */Block.record([ | ||
"retainedState", | ||
"connection", | ||
"meta" | ||
], [ | ||
undefined, | ||
undefined, | ||
0 | ||
component[/* state */1], | ||
devTools, | ||
Block.record([ | ||
"liftedState", | ||
"rewindActionIdx", | ||
"actionCount" | ||
], [ | ||
undefined, | ||
undefined, | ||
0 | ||
]) | ||
]); | ||
connections[connectionId] = connectionInfo; | ||
var connection = devTools; | ||
@@ -457,3 +466,3 @@ var store = /* record */Block.record([ | ||
]); | ||
var meta$1 = meta; | ||
var meta = connectionInfo[/* meta */2]; | ||
var actionCreators$1 = actionCreators === undefined ? undefined : Caml_option.some(actionCreators); | ||
@@ -483,3 +492,3 @@ var initialState = getState(store); | ||
var initial = initialState; | ||
var meta$2 = meta$1; | ||
var meta$1 = meta; | ||
var payload$1 = unwrap(Caml_option.undefined_to_opt(action$2.payload), [ | ||
@@ -494,3 +503,3 @@ PayloadNotFound, | ||
var initial$1 = initial; | ||
var meta$3 = meta$2; | ||
var meta$2 = meta$1; | ||
var payloadType = payload$2.type; | ||
@@ -500,3 +509,3 @@ var exit = 0; | ||
case "COMMIT" : | ||
meta$3[/* actionCount */2] = 0; | ||
meta$2[/* actionCount */2] = 0; | ||
return Extension$ReductiveDevTools.init(devTools$1, getState(store$3)); | ||
@@ -508,3 +517,3 @@ case "IMPORT_STATE" : | ||
mutateState(Curry._1(deserializeObject, targetState), store$3); | ||
meta$3[/* actionCount */2] = nextLiftedState.nextActionId - 1 | 0; | ||
meta$2[/* actionCount */2] = nextLiftedState.nextActionId - 1 | 0; | ||
return Extension$ReductiveDevTools.send(devTools$1, null, nextLiftedState); | ||
@@ -517,3 +526,3 @@ case "JUMP_TO_ACTION" : | ||
mutateState(initial$1, store$3); | ||
meta$3[/* actionCount */2] = 0; | ||
meta$2[/* actionCount */2] = 0; | ||
return Extension$ReductiveDevTools.init(devTools$1, getState(store$3)); | ||
@@ -526,3 +535,3 @@ case "ROLLBACK" : | ||
mutateState(Curry._1(deserializeObject, JSON.parse(stateString)), store$3); | ||
meta$3[/* actionCount */2] = 0; | ||
meta$2[/* actionCount */2] = 0; | ||
return Extension$ReductiveDevTools.init(devTools$1, getState(store$3)); | ||
@@ -542,5 +551,5 @@ case "LOCK_CHANGES" : | ||
var actionId = Belt_Option.getExn(Caml_option.undefined_to_opt(payload$2.actionId)); | ||
var match$1 = actionId === meta$3[/* actionCount */2]; | ||
meta$3[/* rewindActionIdx */1] = match$1 ? undefined : actionId; | ||
var match$2 = meta$3[/* liftedState */0]; | ||
var match$1 = actionId === meta$2[/* actionCount */2]; | ||
meta$2[/* rewindActionIdx */1] = match$1 ? undefined : actionId; | ||
var match$2 = meta$2[/* liftedState */0]; | ||
if (match$2 !== undefined) { | ||
@@ -576,3 +585,3 @@ var liftedState = Caml_option.valFromOption(match$2); | ||
function unsubscribe(connectionId) { | ||
var connection = unwrap(Js_dict.get(connections, connectionId), [ | ||
var connectionInfo = unwrap(Js_dict.get(connections, connectionId), [ | ||
ConnectionNotFound, | ||
@@ -582,12 +591,11 @@ "DevTool connection(id=$connectionId) not found" | ||
Js_dict.unsafeDeleteKey(connections, connectionId); | ||
Js_dict.unsafeDeleteKey(retainedStates, connectionId); | ||
return Extension$ReductiveDevTools.unsubscribe(connection); | ||
return Extension$ReductiveDevTools.unsubscribe(connectionInfo[/* connection */1]); | ||
} | ||
function send(connectionId, action, state) { | ||
var connection = unwrap(Js_dict.get(connections, connectionId), [ | ||
var connectionInfo = unwrap(Js_dict.get(connections, connectionId), [ | ||
ConnectionNotFound, | ||
"DevTool connection(id=$connectionId) not found" | ||
]); | ||
retainedStates[connectionId] = state; | ||
connectionInfo[/* retainedState */0] = state; | ||
var exit = 0; | ||
@@ -600,3 +608,3 @@ if (typeof action === "number" || action[0] !== 161605709) { | ||
if (exit === 1) { | ||
return Extension$ReductiveDevTools.send(connection, Curry._2(serializeMaybeVariant, action, false), Curry._1(serializeObject, state)); | ||
return Extension$ReductiveDevTools.send(connectionInfo[/* connection */1], Curry._2(serializeMaybeVariant, action, false), Curry._1(serializeObject, state)); | ||
} | ||
@@ -603,0 +611,0 @@ |
{ | ||
"name": "reductive-dev-tools", | ||
"version": "0.1.4", | ||
"version": "0.1.5", | ||
"description": "reductive and reason-react reducer component integration with Redux DevTools", | ||
@@ -5,0 +5,0 @@ "main": "lib/js/src/reductiveDevTools.bs.js", |
## reductive-dev-tools | ||
[reductive](https://github.com/reasonml-community/reductive) and [reason-react](https://github.com/reasonml/reason-react) reducer component integration with Redux DevTools. | ||
[reductive](https://github.com/reasonml-community/reductive) and [reason-react](https://github.com/reasonml/reason-react) reducer component integration with [redux-devtools-extension](https://github.com/zalmoxisus/redux-devtools-extension) | ||
@@ -162,2 +162,2 @@ ![image](assets/demo.gif) | ||
## Word Of Caution | ||
Current implementation depends on internal bucklescript representation of debug metadata and variants in js. Changes to it in future may silently break the extension. | ||
Current implementation depends on internal bucklescript representation of debug metadata and variants in js. Changes to it in future may silently break the extension. |
Sorry, the diff of this file is not supported yet
79093
665
163