reductive-dev-tools
Advanced tools
Comparing version 0.2.2 to 0.2.3
@@ -340,193 +340,201 @@ // Generated by BUCKLESCRIPT VERSION 4.0.18, PLEASE EDIT WITH CARE | ||
function reductiveEnhancer(options, storeCreator, reducer, preloadedState, enhancer, param) { | ||
var targetOptions = constructOptions(options, defaultOptions("ReductiveDevTools")); | ||
var devTools = Extension$ReductiveDevTools.connect(Extension$ReductiveDevTools.devToolsEnhancer, targetOptions); | ||
var meta = /* record */Block.record([ | ||
"liftedState", | ||
"rewindActionIdx", | ||
"actionCount", | ||
"connectionId" | ||
], [ | ||
undefined, | ||
undefined, | ||
0, | ||
Belt_Option.getWithDefault(Caml_option.undefined_to_opt(targetOptions.name), "ReductiveDevTools") | ||
]); | ||
var devToolsDispatch = function (store, next, action) { | ||
var match = meta[/* rewindActionIdx */1]; | ||
if (match !== undefined && match < meta[/* actionCount */2]) { | ||
return 0; | ||
} else { | ||
var store$1 = store; | ||
var next$1 = next; | ||
var action$1 = action; | ||
if (enhancer !== undefined) { | ||
Curry._3(enhancer, store$1, next$1, action$1); | ||
if (window.__REDUX_DEVTOOLS_EXTENSION__ === undefined) { | ||
return Curry._4(storeCreator, reducer, preloadedState, enhancer, /* () */0); | ||
} else { | ||
var targetOptions = constructOptions(options, defaultOptions("ReductiveDevTools")); | ||
var devTools = Extension$ReductiveDevTools.connect(Extension$ReductiveDevTools.devToolsEnhancer, targetOptions); | ||
var meta = /* record */Block.record([ | ||
"liftedState", | ||
"rewindActionIdx", | ||
"actionCount", | ||
"connectionId" | ||
], [ | ||
undefined, | ||
undefined, | ||
0, | ||
Belt_Option.getWithDefault(Caml_option.undefined_to_opt(targetOptions.name), "ReductiveDevTools") | ||
]); | ||
var devToolsDispatch = function (store, next, action) { | ||
var match = meta[/* rewindActionIdx */1]; | ||
if (match !== undefined && match < meta[/* actionCount */2]) { | ||
return 0; | ||
} else { | ||
Curry._1(next$1, action$1); | ||
var store$1 = store; | ||
var next$1 = next; | ||
var action$1 = action; | ||
if (enhancer !== undefined) { | ||
Curry._3(enhancer, store$1, next$1, action$1); | ||
} else { | ||
Curry._1(next$1, action$1); | ||
} | ||
meta[/* actionCount */2] = meta[/* actionCount */2] + 1 | 0; | ||
return Extension$ReductiveDevTools.send(devTools, Utilities$ReductiveDevTools.Serializer[/* serializeAction */1](action$1), Utilities$ReductiveDevTools.Serializer[/* serializeObject */2](Reductive.Store[/* getState */5](store$1))); | ||
} | ||
meta[/* actionCount */2] = meta[/* actionCount */2] + 1 | 0; | ||
return Extension$ReductiveDevTools.send(devTools, Utilities$ReductiveDevTools.Serializer[/* serializeAction */1](action$1), Utilities$ReductiveDevTools.Serializer[/* serializeObject */2](Reductive.Store[/* getState */5](store$1))); | ||
} | ||
}; | ||
var store = Curry._4(storeCreator, reducer, preloadedState, devToolsDispatch, /* () */0); | ||
var actionCreators = targetOptions.actionCreators; | ||
handle(devTools, store, meta, actionCreators === undefined ? undefined : Caml_option.some(actionCreators), /* () */0); | ||
return store; | ||
}; | ||
var store = Curry._4(storeCreator, reducer, preloadedState, devToolsDispatch, /* () */0); | ||
var actionCreators = targetOptions.actionCreators; | ||
handle(devTools, store, meta, actionCreators === undefined ? undefined : Caml_option.some(actionCreators), /* () */0); | ||
return store; | ||
} | ||
} | ||
function register(connectionId, component, options, param) { | ||
var targetOptions = options !== undefined ? constructOptions(Caml_option.valFromOption(options), defaultOptions(connectionId)) : defaultOptions(connectionId); | ||
var devTools = Extension$ReductiveDevTools.connect(Extension$ReductiveDevTools.devToolsEnhancer, targetOptions); | ||
var actionCreators = targetOptions.actionCreators; | ||
var connectionInfo = /* record */Block.record([ | ||
"retainedState", | ||
"retainedReducer", | ||
"connection", | ||
"meta" | ||
], [ | ||
component[/* state */1], | ||
(function (_action, _state) { | ||
return /* NoUpdate */0; | ||
}), | ||
devTools, | ||
Block.record([ | ||
"liftedState", | ||
"rewindActionIdx", | ||
"actionCount", | ||
"connectionId" | ||
], [ | ||
undefined, | ||
undefined, | ||
0, | ||
connectionId | ||
]) | ||
]); | ||
connections[connectionId] = connectionInfo; | ||
var connection = devTools; | ||
var store = /* record */Block.record([ | ||
"component", | ||
"connectionId" | ||
], [ | ||
component, | ||
connectionId | ||
]); | ||
var meta = connectionInfo[/* meta */3]; | ||
var actionCreators$1 = actionCreators === undefined ? undefined : Caml_option.some(actionCreators); | ||
var initialState = getState(store); | ||
Extension$ReductiveDevTools.init(connection, Utilities$ReductiveDevTools.Serializer[/* serializeObject */2](initialState)); | ||
Extension$ReductiveDevTools.subscribe(connection, (function (action) { | ||
var match = action.type; | ||
switch (match) { | ||
case "ACTION" : | ||
var action$1 = action; | ||
var store$1 = store; | ||
var actionCreators$2 = actionCreators$1; | ||
var payload = Utilities$ReductiveDevTools.unwrap(Caml_option.undefined_to_opt(action$1.payload), [ | ||
PayloadNotFound, | ||
"action doesn't contain payload while expected" | ||
]); | ||
if (actionCreators$2 !== undefined) { | ||
return Curry._1(store$1[/* component */0][/* send */3], Curry._2(evalMethod, payload, Caml_option.valFromOption(actionCreators$2))); | ||
} else { | ||
return /* () */0; | ||
} | ||
case "DISPATCH" : | ||
var action$2 = action; | ||
var devTools = connection; | ||
var store$2 = store; | ||
var initial = initialState; | ||
var meta$1 = meta; | ||
var payload$1 = Utilities$ReductiveDevTools.unwrap(Caml_option.undefined_to_opt(action$2.payload), [ | ||
PayloadNotFound, | ||
"action doesn't contain payload while expected" | ||
]); | ||
var devTools$1 = devTools; | ||
var store$3 = store$2; | ||
var payload$2 = payload$1; | ||
var action$3 = action$2; | ||
var initial$1 = initial; | ||
var meta$2 = meta$1; | ||
var payloadType = payload$2.type; | ||
var exit = 0; | ||
switch (payloadType) { | ||
case "COMMIT" : | ||
meta$2[/* actionCount */2] = 0; | ||
return Extension$ReductiveDevTools.init(devTools$1, Utilities$ReductiveDevTools.Serializer[/* serializeObject */2](getState(store$3))); | ||
case "IMPORT_STATE" : | ||
var nextLiftedState = Belt_Option.getExn(Caml_option.undefined_to_opt(payload$2.nextLiftedState)); | ||
var computedStates = nextLiftedState.computedStates; | ||
var targetState = Caml_array.caml_array_get(computedStates, computedStates.length - 1 | 0).state; | ||
mutateState(Utilities$ReductiveDevTools.Serializer[/* deserializeObject */4](targetState), store$3); | ||
meta$2[/* actionCount */2] = nextLiftedState.nextActionId - 1 | 0; | ||
return Extension$ReductiveDevTools.send(devTools$1, null, nextLiftedState); | ||
case "JUMP_TO_ACTION" : | ||
case "JUMP_TO_STATE" : | ||
exit = 1; | ||
break; | ||
case "RESET" : | ||
mutateState(initial$1, store$3); | ||
meta$2[/* actionCount */2] = 0; | ||
return Extension$ReductiveDevTools.init(devTools$1, Utilities$ReductiveDevTools.Serializer[/* serializeObject */2](getState(store$3))); | ||
case "ROLLBACK" : | ||
var stateString = Utilities$ReductiveDevTools.unwrap(Caml_option.undefined_to_opt(action$3.state), [ | ||
StateNotFound, | ||
"action(" + (String(payloadType) + ") doesn\'t contain state while expected") | ||
]); | ||
mutateState(Utilities$ReductiveDevTools.Serializer[/* deserializeObject */4](Utilities$ReductiveDevTools.parse(stateString)), store$3); | ||
meta$2[/* actionCount */2] = 0; | ||
return Extension$ReductiveDevTools.init(devTools$1, Utilities$ReductiveDevTools.Serializer[/* serializeObject */2](getState(store$3))); | ||
case "LOCK_CHANGES" : | ||
case "SWEEP" : | ||
if (window.__REDUX_DEVTOOLS_EXTENSION__ === undefined) { | ||
return /* () */0; | ||
} else { | ||
var targetOptions = options !== undefined ? constructOptions(Caml_option.valFromOption(options), defaultOptions(connectionId)) : defaultOptions(connectionId); | ||
var devTools = Extension$ReductiveDevTools.connect(Extension$ReductiveDevTools.devToolsEnhancer, targetOptions); | ||
var actionCreators = targetOptions.actionCreators; | ||
var connectionInfo = /* record */Block.record([ | ||
"retainedState", | ||
"retainedReducer", | ||
"connection", | ||
"meta" | ||
], [ | ||
component[/* state */1], | ||
(function (_action, _state) { | ||
return /* NoUpdate */0; | ||
}), | ||
devTools, | ||
Block.record([ | ||
"liftedState", | ||
"rewindActionIdx", | ||
"actionCount", | ||
"connectionId" | ||
], [ | ||
undefined, | ||
undefined, | ||
0, | ||
connectionId | ||
]) | ||
]); | ||
connections[connectionId] = connectionInfo; | ||
var connection = devTools; | ||
var store = /* record */Block.record([ | ||
"component", | ||
"connectionId" | ||
], [ | ||
component, | ||
connectionId | ||
]); | ||
var meta = connectionInfo[/* meta */3]; | ||
var actionCreators$1 = actionCreators === undefined ? undefined : Caml_option.some(actionCreators); | ||
var initialState = getState(store); | ||
Extension$ReductiveDevTools.init(connection, Utilities$ReductiveDevTools.Serializer[/* serializeObject */2](initialState)); | ||
Extension$ReductiveDevTools.subscribe(connection, (function (action) { | ||
var match = action.type; | ||
switch (match) { | ||
case "ACTION" : | ||
var action$1 = action; | ||
var store$1 = store; | ||
var actionCreators$2 = actionCreators$1; | ||
var payload = Utilities$ReductiveDevTools.unwrap(Caml_option.undefined_to_opt(action$1.payload), [ | ||
PayloadNotFound, | ||
"action doesn't contain payload while expected" | ||
]); | ||
if (actionCreators$2 !== undefined) { | ||
return Curry._1(store$1[/* component */0][/* send */3], Curry._2(evalMethod, payload, Caml_option.valFromOption(actionCreators$2))); | ||
} else { | ||
return /* () */0; | ||
} | ||
case "DISPATCH" : | ||
var action$2 = action; | ||
var devTools = connection; | ||
var store$2 = store; | ||
var initial = initialState; | ||
var meta$1 = meta; | ||
var payload$1 = Utilities$ReductiveDevTools.unwrap(Caml_option.undefined_to_opt(action$2.payload), [ | ||
PayloadNotFound, | ||
"action doesn't contain payload while expected" | ||
]); | ||
var devTools$1 = devTools; | ||
var store$3 = store$2; | ||
var payload$2 = payload$1; | ||
var action$3 = action$2; | ||
var initial$1 = initial; | ||
var meta$2 = meta$1; | ||
var payloadType = payload$2.type; | ||
var exit = 0; | ||
switch (payloadType) { | ||
case "COMMIT" : | ||
meta$2[/* actionCount */2] = 0; | ||
return Extension$ReductiveDevTools.init(devTools$1, Utilities$ReductiveDevTools.Serializer[/* serializeObject */2](getState(store$3))); | ||
case "IMPORT_STATE" : | ||
var nextLiftedState = Belt_Option.getExn(Caml_option.undefined_to_opt(payload$2.nextLiftedState)); | ||
var computedStates = nextLiftedState.computedStates; | ||
var targetState = Caml_array.caml_array_get(computedStates, computedStates.length - 1 | 0).state; | ||
mutateState(Utilities$ReductiveDevTools.Serializer[/* deserializeObject */4](targetState), store$3); | ||
meta$2[/* actionCount */2] = nextLiftedState.nextActionId - 1 | 0; | ||
return Extension$ReductiveDevTools.send(devTools$1, null, nextLiftedState); | ||
case "JUMP_TO_ACTION" : | ||
case "JUMP_TO_STATE" : | ||
exit = 1; | ||
break; | ||
case "RESET" : | ||
mutateState(initial$1, store$3); | ||
meta$2[/* actionCount */2] = 0; | ||
return Extension$ReductiveDevTools.init(devTools$1, Utilities$ReductiveDevTools.Serializer[/* serializeObject */2](getState(store$3))); | ||
case "ROLLBACK" : | ||
var stateString = Utilities$ReductiveDevTools.unwrap(Caml_option.undefined_to_opt(action$3.state), [ | ||
StateNotFound, | ||
"action(" + (String(payloadType) + ") doesn\'t contain state while expected") | ||
]); | ||
mutateState(Utilities$ReductiveDevTools.Serializer[/* deserializeObject */4](Utilities$ReductiveDevTools.parse(stateString)), store$3); | ||
meta$2[/* actionCount */2] = 0; | ||
return Extension$ReductiveDevTools.init(devTools$1, Utilities$ReductiveDevTools.Serializer[/* serializeObject */2](getState(store$3))); | ||
case "LOCK_CHANGES" : | ||
case "SWEEP" : | ||
return /* () */0; | ||
case "TOGGLE_ACTION" : | ||
var stateString$1 = Utilities$ReductiveDevTools.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 = Utilities$ReductiveDevTools.parse(stateString$1); | ||
Extension$ReductiveDevTools.send(devTools$1, null, processToogleAction(store$3, payload$2, liftedState, meta$2)); | ||
return /* () */0; | ||
} else { | ||
return 0; | ||
} | ||
default: | ||
return /* () */0; | ||
case "TOGGLE_ACTION" : | ||
var stateString$1 = Utilities$ReductiveDevTools.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 = Utilities$ReductiveDevTools.parse(stateString$1); | ||
Extension$ReductiveDevTools.send(devTools$1, null, processToogleAction(store$3, payload$2, liftedState, meta$2)); | ||
return /* () */0; | ||
} | ||
if (exit === 1) { | ||
var stateString$2 = Utilities$ReductiveDevTools.unwrap(Caml_option.undefined_to_opt(action$3.state), [ | ||
StateNotFound, | ||
"action(" + (String(payloadType) + ") doesn\'t contain state while expected") | ||
]); | ||
var actionId = Belt_Option.getExn(Caml_option.undefined_to_opt(payload$2.actionId)); | ||
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) { | ||
var liftedState$1 = Caml_option.valFromOption(match$2); | ||
var actionInLiftedStateRange = actionId < liftedState$1.nextActionId; | ||
if (actionInLiftedStateRange) { | ||
var skippedActions = liftedState$1.skippedActionIds; | ||
var computedStates$1 = liftedState$1.computedStates; | ||
var nonSkippedIdx = actionId; | ||
while(skippedActions.includes(nonSkippedIdx)) { | ||
nonSkippedIdx = nonSkippedIdx - 1 | 0; | ||
}; | ||
var targetState$1 = Caml_array.caml_array_get(computedStates$1, nonSkippedIdx).state; | ||
mutateState(Utilities$ReductiveDevTools.Serializer[/* deserializeObject */4](targetState$1), store$3); | ||
} else { | ||
return 0; | ||
mutateState(Utilities$ReductiveDevTools.Serializer[/* deserializeObject */4](Utilities$ReductiveDevTools.parse(stateString$2)), store$3); | ||
} | ||
default: | ||
return /* () */0; | ||
} | ||
if (exit === 1) { | ||
var stateString$2 = Utilities$ReductiveDevTools.unwrap(Caml_option.undefined_to_opt(action$3.state), [ | ||
StateNotFound, | ||
"action(" + (String(payloadType) + ") doesn\'t contain state while expected") | ||
]); | ||
var actionId = Belt_Option.getExn(Caml_option.undefined_to_opt(payload$2.actionId)); | ||
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) { | ||
var liftedState$1 = Caml_option.valFromOption(match$2); | ||
var actionInLiftedStateRange = actionId < liftedState$1.nextActionId; | ||
if (actionInLiftedStateRange) { | ||
var skippedActions = liftedState$1.skippedActionIds; | ||
var computedStates$1 = liftedState$1.computedStates; | ||
var nonSkippedIdx = actionId; | ||
while(skippedActions.includes(nonSkippedIdx)) { | ||
nonSkippedIdx = nonSkippedIdx - 1 | 0; | ||
}; | ||
var targetState$1 = Caml_array.caml_array_get(computedStates$1, nonSkippedIdx).state; | ||
mutateState(Utilities$ReductiveDevTools.Serializer[/* deserializeObject */4](targetState$1), store$3); | ||
} else { | ||
mutateState(Utilities$ReductiveDevTools.Serializer[/* deserializeObject */4](Utilities$ReductiveDevTools.parse(stateString$2)), store$3); | ||
} | ||
} else { | ||
mutateState(Utilities$ReductiveDevTools.Serializer[/* deserializeObject */4](Utilities$ReductiveDevTools.parse(stateString$2)), store$3); | ||
return /* () */0; | ||
} | ||
case "START" : | ||
return /* () */0; | ||
} | ||
case "START" : | ||
default: | ||
return /* () */0; | ||
default: | ||
return /* () */0; | ||
} | ||
})); | ||
return /* () */0; | ||
} | ||
})); | ||
return /* () */0; | ||
} | ||
} | ||
@@ -591,3 +599,5 @@ | ||
} else { | ||
console.warn("reductive-dev-tools connection not found while expected"); | ||
if (window.__REDUX_DEVTOOLS_EXTENSION__ !== undefined) { | ||
console.warn("reductive-dev-tools connection not found while expected"); | ||
} | ||
return Curry._2(reducer, action, state); | ||
@@ -594,0 +604,0 @@ } |
{ | ||
"name": "reductive-dev-tools", | ||
"version": "0.2.2", | ||
"version": "0.2.3", | ||
"description": "reductive and reason-react reducer component integration with Redux DevTools", | ||
@@ -5,0 +5,0 @@ "main": "lib/js/src/reductiveDevTools.bs.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
117741
1164