reshow-return
Advanced tools
Comparing version 0.17.48 to 0.18.0
@@ -10,15 +10,6 @@ "use strict"; | ||
var _reshowConstant = require("reshow-constant"); | ||
var _reshowFluxBase = require("reshow-flux-base"); | ||
//@ts-check | ||
var getImmutable = function getImmutable( /** @type boolean */immutable) { | ||
return function ( /** @type any */data) { | ||
return !immutable ? (0, _reshowFlux.toJS)(data) : data; | ||
}; | ||
}; | ||
/** | ||
* @typedef {any[]|object} InitStatesProps | ||
*/ | ||
/** | ||
* @param {object} props | ||
@@ -66,6 +57,18 @@ * @param {object} [more] | ||
/** | ||
* @param {InitStatesProps} initStates | ||
* @returns {[any[], function(string):any]} | ||
* @typedef {Record<string, string>} InitStateObject | ||
*/ | ||
var stateKeyLocator = function stateKeyLocator(initStates) { | ||
/** | ||
* @typedef {Record<string, any>} StateObject | ||
*/ | ||
/** | ||
* @typedef { string[] | InitStateObject } InitStatesType | ||
*/ | ||
/** | ||
* @param {InitStatesType} initStates | ||
* @returns {[initStates extends string[] ? initStates : (keyof InitStateObject)[], function(string):string]} | ||
*/ | ||
var stateKeyLocator = exports.stateKeyLocator = function stateKeyLocator(initStates) { | ||
var keys; | ||
@@ -88,8 +91,30 @@ var getNewKey; | ||
/** | ||
* @param {object} prevState | ||
* @param {object} options | ||
* @returns {object} | ||
* @param {boolean} immutable | ||
* @returns {function(any):any} | ||
*/ | ||
exports.stateKeyLocator = stateKeyLocator; | ||
var calculateState = function calculateState(prevState, options) { | ||
var getImmutable = function getImmutable(immutable) { | ||
return function (data) { | ||
return !immutable ? (0, _reshowFlux.toJS)(data) : data; | ||
}; | ||
}; | ||
/** | ||
* @typedef {Object<string, string[]>} PathStates | ||
*/ | ||
/** | ||
* @typedef {object} calculateOptions | ||
* @property {InitStatesType} initStates | ||
* @property {StoreObject} store | ||
* @property {PathStates=} pathStates | ||
* @property {string[]=} excludeStates | ||
* @property {boolean=} immutable | ||
*/ | ||
/** | ||
* @param {StateObject} prevState | ||
* @param {calculateOptions} calculateOptions | ||
* @returns {StateObject} | ||
*/ | ||
var calculateState = function calculateState(prevState, calculateOptions) { | ||
/** | ||
@@ -100,8 +125,8 @@ * Why not support multi stores? | ||
*/ | ||
var initStates = options.initStates, | ||
pathStates = options.pathStates, | ||
_options$excludeState = options.excludeStates, | ||
excludeStates = _options$excludeState === void 0 ? [] : _options$excludeState, | ||
optImmutable = options.immutable, | ||
store = options.store; | ||
var initStates = calculateOptions.initStates, | ||
pathStates = calculateOptions.pathStates, | ||
_calculateOptions$exc = calculateOptions.excludeStates, | ||
excludeStates = _calculateOptions$exc === void 0 ? [] : _calculateOptions$exc, | ||
optImmutable = calculateOptions.immutable, | ||
store = calculateOptions.store; | ||
var getStateValue = stateValueGetter(store.getState()); | ||
@@ -112,11 +137,17 @@ var immutable = optImmutable !== null && optImmutable !== void 0 ? optImmutable : getStateValue("immutable"); | ||
stateKeys = _stateKeyLocator[0], | ||
newKey = _stateKeyLocator[1]; | ||
toNewKey = _stateKeyLocator[1]; | ||
var results = {}; | ||
stateKeys.forEach(function (key) { | ||
stateKeys.forEach( | ||
/** | ||
* @param {string} key | ||
*/ | ||
function (key) { | ||
var data = getStateValue(key); | ||
results[newKey(key)] = toImmutable(data); | ||
results[toNewKey(key)] = toImmutable(data); | ||
}); | ||
(0, _reshowConstant.KEYS)(pathStates || {}).forEach(function (key) { | ||
return results[key] = (0, _getObjectValue["default"])(results, pathStates[key]); | ||
}); | ||
if (pathStates) { | ||
(0, _reshowConstant.KEYS)(pathStates || {}).forEach(function (key) { | ||
return results[key] = (0, _getObjectValue["default"])(results, pathStates[key]); | ||
}); | ||
} | ||
var resultKeys = (0, _reshowConstant.KEYS)(results); | ||
@@ -138,7 +169,5 @@ var bSame = true; | ||
}; | ||
var connectOptions = { | ||
var _default = exports["default"] = { | ||
calculateState: calculateState, | ||
reset: reset | ||
}; | ||
var _default = connectOptions; | ||
exports["default"] = _default; | ||
}; |
@@ -15,4 +15,3 @@ "use strict"; | ||
}; | ||
var _default = hydrate; | ||
exports["default"] = _default; | ||
var _default = exports["default"] = hydrate; | ||
module.exports = exports.default; |
@@ -48,4 +48,3 @@ "use strict"; | ||
}; | ||
var _default = ClientReturnHoc; | ||
exports["default"] = _default; | ||
var _default = exports["default"] = ClientReturnHoc; | ||
module.exports = exports.default; |
@@ -12,3 +12,3 @@ "use strict"; | ||
* @param {any} [props] | ||
* @returns {React.ReactElement} | ||
* @returns {?React.ReactElement} | ||
*/ | ||
@@ -20,4 +20,3 @@ var MemoReturn = function MemoReturn(props) { | ||
}; | ||
var _default = MemoReturn; | ||
exports["default"] = _default; | ||
var _default = exports["default"] = MemoReturn; | ||
module.exports = exports.default; |
@@ -25,3 +25,3 @@ "use strict"; | ||
* @property {import("reshow-flux-base").StoreObject} store | ||
* @property {import("../../connectOptions").InitStatesProps} initStates | ||
* @property {import("../../connectOptions").InitStatesType} initStates | ||
* @property {{[key: string]: string[]}} [pathStates] | ||
@@ -36,3 +36,3 @@ * @property {string[]} [excludeStates] | ||
*/ | ||
var getReturn = function getReturn(_temp) { | ||
var getReturn = exports.getReturn = function getReturn(_temp) { | ||
var _ref = _temp === void 0 ? {} : _temp, | ||
@@ -62,5 +62,3 @@ _ref$displayName = _ref.displayName, | ||
}; | ||
exports.getReturn = getReturn; | ||
var Return = getReturn(); | ||
var _default = Return; | ||
exports["default"] = _default; | ||
var _default = exports["default"] = Return; |
@@ -28,4 +28,3 @@ "use strict"; | ||
}; | ||
var _default = useClientReturn; | ||
exports["default"] = _default; | ||
var _default = exports["default"] = useClientReturn; | ||
module.exports = exports.default; |
@@ -16,3 +16,3 @@ "use strict"; | ||
* @template ActionType | ||
* @typedef {import('reshow-flux-base').DispatchType<StateType, ActionType>} DispatchType | ||
* @typedef {import('reshow-flux-base').DispatchFunction<StateType, ActionType>} DispatchType | ||
*/ | ||
@@ -23,2 +23,3 @@ | ||
*/ | ||
/** | ||
@@ -72,4 +73,3 @@ * @template ChildrenType | ||
}; | ||
var _default = usePartialRender; | ||
exports["default"] = _default; | ||
var _default = exports["default"] = usePartialRender; | ||
module.exports = exports.default; |
@@ -22,6 +22,7 @@ "use strict"; | ||
* @callback UseReturnType | ||
* @param {import('./connectOptions').InitStatesProps} initStates | ||
* @param {import('./connectOptions').InitStatesType} initStates | ||
* @param {import("reshow-flux-base").StoreObject} store | ||
* @param {UseReturnPayLoad} [payload] | ||
*/ | ||
/** | ||
@@ -49,4 +50,3 @@ * @type UseReturnType | ||
}; | ||
var _default = useReturn; | ||
exports["default"] = _default; | ||
var _default = exports["default"] = useReturn; | ||
module.exports = exports.default; |
{ | ||
"version": "0.17.48", | ||
"version": "0.18.0", | ||
"name": "reshow-return", | ||
@@ -4,0 +4,0 @@ "repository": { |
@@ -1,21 +0,37 @@ | ||
export default connectOptions; | ||
export type InitStatesProps = any[] | object; | ||
declare namespace connectOptions { | ||
export function stateKeyLocator(initStates: InitStatesType): [InitStatesType extends string[] ? InitStatesType : (keyof InitStateObject)[], (arg0: string) => string]; | ||
declare namespace _default { | ||
export { calculateState }; | ||
export { reset }; | ||
} | ||
export default _default; | ||
export type InitStateObject = Record<string, string>; | ||
export type StateObject = Record<string, any>; | ||
export type InitStatesType = string[] | InitStateObject; | ||
export type PathStates = { | ||
[x: string]: string[]; | ||
}; | ||
export type calculateOptions = { | ||
initStates: InitStatesType; | ||
store: StoreObject<any, any>; | ||
pathStates?: PathStates | undefined; | ||
excludeStates?: string[] | undefined; | ||
immutable?: boolean | undefined; | ||
}; | ||
/** | ||
* @param {InitStatesProps} initStates | ||
* @returns {[any[], function(string):any]} | ||
* @typedef {Object<string, string[]>} PathStates | ||
*/ | ||
export function stateKeyLocator(initStates: InitStatesProps): [any[], (arg0: string) => any]; | ||
/** | ||
* @param {object} prevState | ||
* @param {object} options | ||
* @returns {object} | ||
* @typedef {object} calculateOptions | ||
* @property {InitStatesType} initStates | ||
* @property {StoreObject} store | ||
* @property {PathStates=} pathStates | ||
* @property {string[]=} excludeStates | ||
* @property {boolean=} immutable | ||
*/ | ||
declare function calculateState(prevState: object, options: object): object; | ||
/** | ||
* @typedef {any[]|object} InitStatesProps | ||
* @param {StateObject} prevState | ||
* @param {calculateOptions} calculateOptions | ||
* @returns {StateObject} | ||
*/ | ||
declare function calculateState(prevState: StateObject, calculateOptions: calculateOptions): StateObject; | ||
/** | ||
@@ -27,1 +43,2 @@ * @param {object} props | ||
declare function reset(props: object, more?: object): object; | ||
import { StoreObject } from "reshow-flux-base"; |
export default MemoReturn; | ||
/** | ||
* @param {any} [props] | ||
* @returns {React.ReactElement} | ||
* @returns {?React.ReactElement} | ||
*/ | ||
declare function MemoReturn(props?: any): React.ReactElement; | ||
declare function MemoReturn(props?: any): React.ReactElement | null; |
@@ -10,3 +10,3 @@ export default Return; | ||
store: import("reshow-flux-base").StoreObject<any, any>; | ||
initStates: import("../../connectOptions").InitStatesProps; | ||
initStates: import("../../connectOptions").InitStatesType; | ||
pathStates?: { | ||
@@ -19,3 +19,3 @@ [key: string]: string[]; | ||
}; | ||
declare const Return: React.ElementType<any>; | ||
declare const Return: React.ElementType<any, keyof React.JSX.IntrinsicElements>; | ||
/** | ||
@@ -31,3 +31,3 @@ * @typedef {object} GetReturnOptions | ||
* @property {import("reshow-flux-base").StoreObject} store | ||
* @property {import("../../connectOptions").InitStatesProps} initStates | ||
* @property {import("../../connectOptions").InitStatesType} initStates | ||
* @property {{[key: string]: string[]}} [pathStates] | ||
@@ -34,0 +34,0 @@ * @property {string[]} [excludeStates] |
export default usePartialRender; | ||
export type DispatchType<StateType, ActionType> = import('reshow-flux-base').DispatchType<StateType, ActionType>; | ||
export type DispatchType<StateType, ActionType> = import('reshow-flux-base').DispatchFunction<StateType, ActionType>; | ||
export type RenderKeysType = string[] | import("immutable").Seq<any, any>; | ||
@@ -7,3 +7,3 @@ /** | ||
* @template ActionType | ||
* @typedef {import('reshow-flux-base').DispatchType<StateType, ActionType>} DispatchType | ||
* @typedef {import('reshow-flux-base').DispatchFunction<StateType, ActionType>} DispatchType | ||
*/ | ||
@@ -10,0 +10,0 @@ /** |
@@ -16,3 +16,3 @@ export default useReturn; | ||
}; | ||
export type UseReturnType = (initStates: import('./connectOptions').InitStatesProps, store: import("reshow-flux-base").StoreObject<any, any>, payload?: UseReturnPayLoad) => any; | ||
export type UseReturnType = (initStates: import('./connectOptions').InitStatesType, store: import("reshow-flux-base").StoreObject<any, any>, payload?: UseReturnPayLoad) => any; | ||
/** | ||
@@ -29,3 +29,3 @@ * @typedef {object} UseReturnPayLoad | ||
* @callback UseReturnType | ||
* @param {import('./connectOptions').InitStatesProps} initStates | ||
* @param {import('./connectOptions').InitStatesType} initStates | ||
* @param {import("reshow-flux-base").StoreObject} store | ||
@@ -32,0 +32,0 @@ * @param {UseReturnPayLoad} [payload] |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
59764
1745