reductive-dev-tools
Advanced tools
Comparing version 0.1.6 to 0.1.7
@@ -181,2 +181,50 @@ // Generated by BUCKLESCRIPT VERSION 4.0.18, PLEASE EDIT WITH CARE | ||
function processToogleAction(store, payload, liftedState, meta) { | ||
var skippedActions = liftedState.skippedActionIds; | ||
var stagedActions = liftedState.stagedActionIds; | ||
var computedStates = liftedState.computedStates; | ||
var actionsById = liftedState.actionsById; | ||
var id = Belt_Option.getExn(Caml_option.undefined_to_opt(payload.id)); | ||
var idx = skippedActions.indexOf(id); | ||
var start = stagedActions.indexOf(id); | ||
var skipped = idx !== -1; | ||
if (start === -1) { | ||
return liftedState; | ||
} else { | ||
var initialIdx = start - 1 | 0; | ||
while(skippedActions.includes(initialIdx)) { | ||
initialIdx = initialIdx - 1 | 0; | ||
}; | ||
var initialState = Caml_array.caml_array_get(computedStates, initialIdx).state; | ||
mutateState(Curry._1(deserializeObject, initialState), store); | ||
var preservedActionCount = meta[/* actionCount */2]; | ||
$$Array.iter((function (i) { | ||
var stagedActionKey = String(Caml_array.caml_array_get(stagedActions, i)); | ||
var targetAction = Belt_Option.getExn(Js_dict.get(actionsById, stagedActionKey)).action; | ||
Curry._1(store[/* component */0][/* send */3], Curry._1(deserializeVariant, targetAction)); | ||
var newState = getState(store); | ||
Caml_array.caml_array_get(computedStates, i).state = Curry._1(serializeObject, newState); | ||
return /* () */0; | ||
}), Belt_Array.keep(Belt_Array.range(skipped ? start : start + 1 | 0, stagedActions.length - 1 | 0), (function (i) { | ||
if (i === start) { | ||
return true; | ||
} else { | ||
return skippedActions.indexOf(Caml_array.caml_array_get(stagedActions, i)) === -1; | ||
} | ||
}))); | ||
meta[/* actionCount */2] = preservedActionCount; | ||
if (liftedState.currentStateIndex !== (stagedActions.length - 1 | 0)) { | ||
var targetState = Caml_array.caml_array_get(computedStates, liftedState.currentStateIndex).state; | ||
mutateState(Curry._1(deserializeObject, targetState), store); | ||
} | ||
if (skipped) { | ||
skippedActions.splice(idx, 1); | ||
} else { | ||
skippedActions.push(id); | ||
} | ||
meta[/* liftedState */0] = Caml_option.some(liftedState); | ||
return liftedState; | ||
} | ||
} | ||
var PayloadNotFound$1 = Caml_exceptions.create("Connectors-ReductiveDevTools.ConnectionHandler(Store).Exceptions.PayloadNotFound"); | ||
@@ -186,3 +234,5 @@ | ||
function processToogleAction(store, payload, liftedState, meta) { | ||
var ConnectionNotFound$1 = Caml_exceptions.create("Connectors-ReductiveDevTools.ConnectionHandler(Store).Exceptions.ConnectionNotFound"); | ||
function processToogleAction$1(store, payload, liftedState, meta) { | ||
var skippedActions = liftedState.skippedActionIds; | ||
@@ -212,3 +262,12 @@ var stagedActions = liftedState.stagedActionIds; | ||
Reductive.Store[/* dispatch */4](store, action); | ||
Caml_array.caml_array_get(computedStates, i).state = Curry._1(serializeObject, Reductive.Store[/* getState */5](store)); | ||
var connectionInfo = unwrap(Js_dict.get(connections, meta[/* connectionId */3]), [ | ||
ConnectionNotFound$1, | ||
"DevTool connection(id=$connectionId) not found" | ||
]); | ||
var match = Curry._2(connectionInfo[/* retainedReducer */1], Curry._1(deserializeVariant, targetAction), connectionInfo[/* retainedState */0]); | ||
var tmp; | ||
tmp = typeof match === "number" || match.tag ? connectionInfo[/* retainedState */0] : match[0]; | ||
connectionInfo[/* retainedState */0] = tmp; | ||
var newState = connectionInfo[/* retainedState */0]; | ||
Caml_array.caml_array_get(computedStates, i).state = Curry._1(serializeObject, newState); | ||
return /* () */0; | ||
@@ -319,3 +378,3 @@ }), Belt_Array.keep(Belt_Array.range(skipped ? start : start + 1 | 0, stagedActions.length - 1 | 0), (function (i) { | ||
var liftedState = JSON.parse(stateString$1); | ||
Extension$ReductiveDevTools.send(devTools$1, null, processToogleAction(store$3, payload$2, liftedState, meta$2)); | ||
Extension$ReductiveDevTools.send(devTools$1, null, processToogleAction$1(store$3, payload$2, liftedState, meta$2)); | ||
return notifyListeners(store$3); | ||
@@ -407,7 +466,9 @@ } else { | ||
"rewindActionIdx", | ||
"actionCount" | ||
"actionCount", | ||
"connectionId" | ||
], [ | ||
undefined, | ||
undefined, | ||
0 | ||
0, | ||
Belt_Option.getWithDefault(Caml_option.undefined_to_opt(targetOptions.name), "ReductiveDevTools") | ||
]); | ||
@@ -443,2 +504,3 @@ var devToolsDispatch = function (store, next, action) { | ||
"retainedState", | ||
"retainedReducer", | ||
"connection", | ||
@@ -448,2 +510,5 @@ "meta" | ||
component[/* state */1], | ||
(function (action, state) { | ||
return /* NoUpdate */0; | ||
}), | ||
devTools, | ||
@@ -453,7 +518,9 @@ Block.record([ | ||
"rewindActionIdx", | ||
"actionCount" | ||
"actionCount", | ||
"connectionId" | ||
], [ | ||
undefined, | ||
undefined, | ||
0 | ||
0, | ||
connectionId | ||
]) | ||
@@ -470,3 +537,3 @@ ]); | ||
]); | ||
var meta = connectionInfo[/* meta */2]; | ||
var meta = connectionInfo[/* meta */3]; | ||
var actionCreators$1 = actionCreators === undefined ? undefined : Caml_option.some(actionCreators); | ||
@@ -538,4 +605,15 @@ var initialState = getState(store); | ||
case "SWEEP" : | ||
return /* () */0; | ||
case "TOGGLE_ACTION" : | ||
return /* () */0; | ||
var stateString$1 = unwrap(Caml_option.undefined_to_opt(action$3.state), [ | ||
StateNotFound, | ||
"action(" + (String(payloadType) + ") doesn\'t contain state while expected") | ||
]); | ||
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 /* () */0; | ||
} else { | ||
return 0; | ||
} | ||
default: | ||
@@ -545,3 +623,3 @@ return /* () */0; | ||
if (exit === 1) { | ||
var stateString$1 = unwrap(Caml_option.undefined_to_opt(action$3.state), [ | ||
var stateString$2 = unwrap(Caml_option.undefined_to_opt(action$3.state), [ | ||
StateNotFound, | ||
@@ -555,7 +633,7 @@ "action(" + (String(payloadType) + ") doesn\'t contain state while expected") | ||
if (match$2 !== undefined) { | ||
var liftedState = Caml_option.valFromOption(match$2); | ||
var actionInLiftedStateRange = actionId < liftedState.nextActionId; | ||
var liftedState$1 = Caml_option.valFromOption(match$2); | ||
var actionInLiftedStateRange = actionId < liftedState$1.nextActionId; | ||
if (actionInLiftedStateRange) { | ||
var skippedActions = liftedState.skippedActionIds; | ||
var computedStates$1 = liftedState.computedStates; | ||
var skippedActions = liftedState$1.skippedActionIds; | ||
var computedStates$1 = liftedState$1.computedStates; | ||
var nonSkippedIdx = actionId; | ||
@@ -568,6 +646,6 @@ while(skippedActions.includes(nonSkippedIdx)) { | ||
} else { | ||
mutateState(Curry._1(deserializeObject, JSON.parse(stateString$1)), store$3); | ||
mutateState(Curry._1(deserializeObject, JSON.parse(stateString$2)), store$3); | ||
} | ||
} else { | ||
mutateState(Curry._1(deserializeObject, JSON.parse(stateString$1)), store$3); | ||
mutateState(Curry._1(deserializeObject, JSON.parse(stateString$2)), store$3); | ||
} | ||
@@ -591,3 +669,3 @@ return /* () */0; | ||
Js_dict.unsafeDeleteKey(connections, connectionId); | ||
return Extension$ReductiveDevTools.unsubscribe(connectionInfo[/* connection */1]); | ||
return Extension$ReductiveDevTools.unsubscribe(connectionInfo[/* connection */2]); | ||
} | ||
@@ -599,2 +677,3 @@ | ||
var connectionInfo = match; | ||
connectionInfo[/* retainedReducer */1] = reducer; | ||
var propageAction = function (state, action) { | ||
@@ -612,5 +691,5 @@ var result = Curry._2(reducer, action, state); | ||
var state$1 = result[0]; | ||
connectionInfo[/* meta */2][/* actionCount */2] = connectionInfo[/* meta */2][/* actionCount */2] + 1 | 0; | ||
connectionInfo[/* meta */3][/* actionCount */2] = connectionInfo[/* meta */3][/* actionCount */2] + 1 | 0; | ||
connectionInfo[/* retainedState */0] = state$1; | ||
Extension$ReductiveDevTools.send(connectionInfo[/* connection */1], Curry._2(serializeMaybeVariant, action, false), Curry._1(serializeObject, state$1)); | ||
Extension$ReductiveDevTools.send(connectionInfo[/* connection */2], Curry._2(serializeMaybeVariant, action, false), Curry._1(serializeObject, state$1)); | ||
} | ||
@@ -623,6 +702,6 @@ | ||
}; | ||
var match$1 = connectionInfo[/* meta */2][/* rewindActionIdx */1]; | ||
var match$1 = connectionInfo[/* meta */3][/* rewindActionIdx */1]; | ||
if (match$1 !== undefined) { | ||
var isDevToolsStateUpdateAction = typeof action === "number" ? false : action[0] === 161605709; | ||
if (match$1 >= connectionInfo[/* meta */2][/* actionCount */2] || isDevToolsStateUpdateAction) { | ||
if (match$1 >= connectionInfo[/* meta */3][/* actionCount */2] || isDevToolsStateUpdateAction) { | ||
return propageAction(state, action); | ||
@@ -629,0 +708,0 @@ } else { |
{ | ||
"name": "reductive-dev-tools", | ||
"version": "0.1.6", | ||
"version": "0.1.7", | ||
"description": "reductive and reason-react reducer component integration with Redux DevTools", | ||
@@ -5,0 +5,0 @@ "main": "lib/js/src/reductiveDevTools.bs.js", |
@@ -31,3 +31,3 @@ ## reductive-dev-tools | ||
| jump | ✔ | ✔ | | ||
| skip | ✔ | [#1](https://github.com/ambientlight/reductive-dev-tools/issues/1)| | ||
| skip | ✔ | ✔ | | ||
| sweep | [redux-devtools-extension/#618](https://github.com/zalmoxisus/redux-devtools-extension/issues/618) | [redux-devtools-extension/#618](https://github.com/zalmoxisus/redux-devtools-extension/issues/618) | | ||
@@ -34,0 +34,0 @@ | reorder | [redux-devtools-extension/#618](https://github.com/zalmoxisus/redux-devtools-extension/issues/618) | [redux-devtools-extension/#618](https://github.com/zalmoxisus/redux-devtools-extension/issues/618) | |
Sorry, the diff of this file is not supported yet
86318
766