redux-astroglide 0.1.22 → 0.1.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -3744,15 +3744,86 @@ var configure$1 = function configure(store) {
3744
3744
 
3745
3745
  var _excluded = ["middleware", "devTools", "preloadedState", "enhancers"],
3746
3746
  _excluded2 = ["selectDomain"];
3747
- var configure = function configure(_ref) {
3748
- var _middleware = _ref.middleware,
3747
+
3748
+ // ============================================================================
3749
+ // Utility Types
3750
+ // ============================================================================
3751
+
3752
+ /** Capitalize first letter of a string type */
3753
+
3754
+ // ============================================================================
3755
+ // Hook Types
3756
+ // ============================================================================
3757
+
3758
+ /** Return type for hooks - [value, setter, extras] */
3759
+
3760
+ /** A hook with static methods for non-component usage */
3761
+
3762
+ /** Generate hook types from initial state - creates useFieldName for each field */
3763
+
3764
+ /** Domain hook for the entire slice state */
3765
+
3766
+ // ============================================================================
3767
+ // Selector Types
3768
+ // ============================================================================
3769
+
3770
+ /** Generate selector types from initial state - creates selectFieldName for each field */
3771
+
3772
+ // ============================================================================
3773
+ // Action Types
3774
+ // ============================================================================
3775
+
3776
+ /** Generate setter action types from initial state - creates setFieldName for each field */
3777
+
3778
+ /** Slice-level setter action */
3779
+
3780
+ /** Extract action types from custom reducers */
3781
+
3782
+ // ============================================================================
3783
+ // Extended Slice Type
3784
+ // ============================================================================
3785
+
3786
+ /** Extended slice with hooks, selectors, and properly typed actions */
3787
+
3788
+ // ============================================================================
3789
+ // Configure Options Types
3790
+ // ============================================================================
3791
+
3792
+ /** Configuration options for the store - reducer is NOT required */
3793
+
3794
+ // ============================================================================
3795
+ // RTK Config Types
3796
+ // ============================================================================
3797
+
3798
+ /** RTK-compatible configuration for custom reducers */
3799
+
3800
+ /** Astroglide-specific configuration overrides */
3801
+
3802
+ // ============================================================================
3803
+ // Configure Result Type
3804
+ // ============================================================================
3805
+
3806
+ /** Result returned from configure() */
3807
+
3808
+ var configure = function configure() {
3809
+ var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
3810
+ _middleware = _ref.middleware,
3749
3811
  devTools = _ref.devTools,
3750
3812
  preloadedState = _ref.preloadedState,
3751
3813
  enhancers = _ref.enhancers,
3752
3814
  staticReducers = _objectWithoutProperties(_ref, _excluded);
3815
+ // Add a placeholder reducer if no static reducers provided
3816
+ // This prevents combineReducers({}) from throwing an error
3817
+ var hasStaticReducers = Object.keys(staticReducers).length > 0;
3818
+ var initialReducers = hasStaticReducers ? staticReducers : {
3819
+ __astroglide_init__: function __astroglide_init__() {
3820
+ var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3821
+ return state;
3822
+ }
3823
+ };
3753
3824
  var store = toolkit.configureStore({
3754
3825
  // @ts-ignore-next-line
3755
- reducer: toolkit.combineReducers(staticReducers),
3826
+ reducer: toolkit.combineReducers(initialReducers),
3756
3827
  middleware: function middleware(getDefaultMiddleware) {
3757
3828
  return [].concat(_toConsumableArray(typeof _middleware === "function" ? _middleware(getDefaultMiddleware) : _middleware || []), [reduxInjectableMiddleware.injectableMiddleware]);
3758
3829
  },
@@ -3763,12 +3834,13 @@ var configure = function configure(_ref) {
3763
3834
  var _configureSelectors = configure$1(store),
3764
3835
  makePropertySelectorsFromSlice = _configureSelectors.makePropertySelectorsFromSlice;
3765
3836
  var injectSlice$1 = function injectSlice$1(slice) {
3766
- return injectSlice(store, staticReducers, slice);
3837
+ return injectSlice(store, initialReducers, slice);
3767
3838
  };
3768
3839
  var injectReducer$1 = function injectReducer$1(key, asyncReducer) {
3769
- return injectReducer(store, staticReducers, key, asyncReducer);
3840
+ return injectReducer(store, initialReducers, key, asyncReducer);
3770
3841
  };
3771
- var createAutomatedSlice = function createAutomatedSlice(sliceConfig, rtkConfig) {
3842
+ var createAutomatedSlice = function createAutomatedSlice(sliceConfig) {
3843
+ var rtkConfig = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3772
3844
  var pluginData = {};
3773
3845
  map_1(sliceConfig.initialState, function (_item, key) {
3774
3846
  var item = _item; // cache it here to pull item -> value -> value -> value if multiple plugins are used...
@@ -3824,18 +3896,18 @@ var configure = function configure(_ref) {
3824
3896
  return action.payload;
3825
3897
  }
3826
3898
  }, sliceSetterKey, function (state, action) {
3827
- var _loop = function _loop(key) {
3828
- var actionType = "set".concat(upperFirst_1(key));
3899
+ var _loop = function _loop(_key) {
3900
+ var actionType = "set".concat(upperFirst_1(_key));
3829
3901
  var setter = setterReducers[actionType] || function (_state, _action) {
3830
- _state[key] = _action.payload;
3902
+ _state[_key] = _action.payload;
3831
3903
  };
3832
3904
  setter(state, {
3833
3905
  type: actionType,
3834
- payload: action.payload[key]
3906
+ payload: action.payload[_key]
3835
3907
  });
3836
3908
  };
3837
- for (var key in action.payload) {
3838
- _loop(key);
3909
+ for (var _key in action.payload) {
3910
+ _loop(_key);
3839
3911
  }
3840
3912
  }), sliceConfig.reducers || {})
3841
3913
  }));
@@ -3848,8 +3920,8 @@ var configure = function configure(_ref) {
3848
3920
  domainHookKey = domainHookKey.replace(/(^use)(.*)(Slice$)/, "$1$2_$3");
3849
3921
  }
3850
3922
  var getParams = function getParams() {
3851
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
3852
- args[_key] = arguments[_key];
3923
+ for (var _len = arguments.length, args = new Array(_len), _key2 = 0; _key2 < _len; _key2++) {
3924
+ args[_key2] = arguments[_key2];
3853
3925
  }
3854
3926
  var params = args;
3855
3927
  if (args.length === 1 && typeof args[0] === "function") {
@@ -3888,10 +3960,16 @@ var configure = function configure(_ref) {
3888
3960
  injectSlice$1(slice);
3889
3961
  return slice;
3890
3962
  };
3891
- var astroglide = function astroglide(name, initialState) {
3963
+
3964
+ // Overload signatures for the astroglide/createSlice function
3965
+
3966
+ function astroglide(name) {
3967
+ var initialState = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3892
3968
  var rtkConfig = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
3893
3969
  var astroglideConfigOverrides = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
3894
3970
  var shorthandParams = _typeof(name) === "object";
3971
+
3972
+ // Restore original parameter passing logic exactly
3895
3973
  var params = [].concat(_toConsumableArray(shorthandParams ? [name, initialState, rtkConfig] : [_objectSpread2(_objectSpread2({}, rtkConfig), {}, {
3896
3974
  name: name,
3897
3975
  initialState: initialState
@@ -3899,7 +3977,7 @@ var configure = function configure(_ref) {
3899
3977
 
3900
3978
  // @ts-ignore - params is dynamically constructed based on shorthand vs normal call
3901
3979
  return createAutomatedSlice.apply(void 0, _toConsumableArray(params));
3902
- };
3980
+ }
3903
3981
  return {
3904
3982
  createSlice: astroglide,
3905
3983
  astroglide: astroglide,
@@ -3910,6 +3988,8 @@ var configure = function configure(_ref) {
3910
3988
  };
3911
3989
  };
3912
3990
 
3991
+ // Export types for consumer usage
3992
+
3913
3993
  exports.addPlugin = addPlugin;
3914
3994
  exports.addPlugins = addPlugins;
3915
3995
  exports.configure = configure;
@@ -3740,15 +3740,86 @@ var configure$1 = function configure(store) {
3740
3740
 
3741
3741
  var _excluded = ["middleware", "devTools", "preloadedState", "enhancers"],
3742
3742
  _excluded2 = ["selectDomain"];
3743
- var configure = function configure(_ref) {
3744
- var _middleware = _ref.middleware,
3743
+
3744
+ // ============================================================================
3745
+ // Utility Types
3746
+ // ============================================================================
3747
+
3748
+ /** Capitalize first letter of a string type */
3749
+
3750
+ // ============================================================================
3751
+ // Hook Types
3752
+ // ============================================================================
3753
+
3754
+ /** Return type for hooks - [value, setter, extras] */
3755
+
3756
+ /** A hook with static methods for non-component usage */
3757
+
3758
+ /** Generate hook types from initial state - creates useFieldName for each field */
3759
+
3760
+ /** Domain hook for the entire slice state */
3761
+
3762
+ // ============================================================================
3763
+ // Selector Types
3764
+ // ============================================================================
3765
+
3766
+ /** Generate selector types from initial state - creates selectFieldName for each field */
3767
+
3768
+ // ============================================================================
3769
+ // Action Types
3770
+ // ============================================================================
3771
+
3772
+ /** Generate setter action types from initial state - creates setFieldName for each field */
3773
+
3774
+ /** Slice-level setter action */
3775
+
3776
+ /** Extract action types from custom reducers */
3777
+
3778
+ // ============================================================================
3779
+ // Extended Slice Type
3780
+ // ============================================================================
3781
+
3782
+ /** Extended slice with hooks, selectors, and properly typed actions */
3783
+
3784
+ // ============================================================================
3785
+ // Configure Options Types
3786
+ // ============================================================================
3787
+
3788
+ /** Configuration options for the store - reducer is NOT required */
3789
+
3790
+ // ============================================================================
3791
+ // RTK Config Types
3792
+ // ============================================================================
3793
+
3794
+ /** RTK-compatible configuration for custom reducers */
3795
+
3796
+ /** Astroglide-specific configuration overrides */
3797
+
3798
+ // ============================================================================
3799
+ // Configure Result Type
3800
+ // ============================================================================
3801
+
3802
+ /** Result returned from configure() */
3803
+
3804
+ var configure = function configure() {
3805
+ var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
3806
+ _middleware = _ref.middleware,
3745
3807
  devTools = _ref.devTools,
3746
3808
  preloadedState = _ref.preloadedState,
3747
3809
  enhancers = _ref.enhancers,
3748
3810
  staticReducers = _objectWithoutProperties(_ref, _excluded);
3811
+ // Add a placeholder reducer if no static reducers provided
3812
+ // This prevents combineReducers({}) from throwing an error
3813
+ var hasStaticReducers = Object.keys(staticReducers).length > 0;
3814
+ var initialReducers = hasStaticReducers ? staticReducers : {
3815
+ __astroglide_init__: function __astroglide_init__() {
3816
+ var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3817
+ return state;
3818
+ }
3819
+ };
3749
3820
  var store = configureStore({
3750
3821
  // @ts-ignore-next-line
3751
- reducer: combineReducers(staticReducers),
3822
+ reducer: combineReducers(initialReducers),
3752
3823
  middleware: function middleware(getDefaultMiddleware) {
3753
3824
  return [].concat(_toConsumableArray(typeof _middleware === "function" ? _middleware(getDefaultMiddleware) : _middleware || []), [injectableMiddleware]);
3754
3825
  },
@@ -3759,12 +3830,13 @@ var configure = function configure(_ref) {
3759
3830
  var _configureSelectors = configure$1(store),
3760
3831
  makePropertySelectorsFromSlice = _configureSelectors.makePropertySelectorsFromSlice;
3761
3832
  var injectSlice$1 = function injectSlice$1(slice) {
3762
- return injectSlice(store, staticReducers, slice);
3833
+ return injectSlice(store, initialReducers, slice);
3763
3834
  };
3764
3835
  var injectReducer$1 = function injectReducer$1(key, asyncReducer) {
3765
- return injectReducer(store, staticReducers, key, asyncReducer);
3836
+ return injectReducer(store, initialReducers, key, asyncReducer);
3766
3837
  };
3767
- var createAutomatedSlice = function createAutomatedSlice(sliceConfig, rtkConfig) {
3838
+ var createAutomatedSlice = function createAutomatedSlice(sliceConfig) {
3839
+ var rtkConfig = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3768
3840
  var pluginData = {};
3769
3841
  map_1(sliceConfig.initialState, function (_item, key) {
3770
3842
  var item = _item; // cache it here to pull item -> value -> value -> value if multiple plugins are used...
@@ -3820,18 +3892,18 @@ var configure = function configure(_ref) {
3820
3892
  return action.payload;
3821
3893
  }
3822
3894
  }, sliceSetterKey, function (state, action) {
3823
- var _loop = function _loop(key) {
3824
- var actionType = "set".concat(upperFirst_1(key));
3895
+ var _loop = function _loop(_key) {
3896
+ var actionType = "set".concat(upperFirst_1(_key));
3825
3897
  var setter = setterReducers[actionType] || function (_state, _action) {
3826
- _state[key] = _action.payload;
3898
+ _state[_key] = _action.payload;
3827
3899
  };
3828
3900
  setter(state, {
3829
3901
  type: actionType,
3830
- payload: action.payload[key]
3902
+ payload: action.payload[_key]
3831
3903
  });
3832
3904
  };
3833
- for (var key in action.payload) {
3834
- _loop(key);
3905
+ for (var _key in action.payload) {
3906
+ _loop(_key);
3835
3907
  }
3836
3908
  }), sliceConfig.reducers || {})
3837
3909
  }));
@@ -3844,8 +3916,8 @@ var configure = function configure(_ref) {
3844
3916
  domainHookKey = domainHookKey.replace(/(^use)(.*)(Slice$)/, "$1$2_$3");
3845
3917
  }
3846
3918
  var getParams = function getParams() {
3847
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
3848
- args[_key] = arguments[_key];
3919
+ for (var _len = arguments.length, args = new Array(_len), _key2 = 0; _key2 < _len; _key2++) {
3920
+ args[_key2] = arguments[_key2];
3849
3921
  }
3850
3922
  var params = args;
3851
3923
  if (args.length === 1 && typeof args[0] === "function") {
@@ -3884,10 +3956,16 @@ var configure = function configure(_ref) {
3884
3956
  injectSlice$1(slice);
3885
3957
  return slice;
3886
3958
  };
3887
- var astroglide = function astroglide(name, initialState) {
3959
+
3960
+ // Overload signatures for the astroglide/createSlice function
3961
+
3962
+ function astroglide(name) {
3963
+ var initialState = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3888
3964
  var rtkConfig = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
3889
3965
  var astroglideConfigOverrides = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
3890
3966
  var shorthandParams = _typeof(name) === "object";
3967
+
3968
+ // Restore original parameter passing logic exactly
3891
3969
  var params = [].concat(_toConsumableArray(shorthandParams ? [name, initialState, rtkConfig] : [_objectSpread2(_objectSpread2({}, rtkConfig), {}, {
3892
3970
  name: name,
3893
3971
  initialState: initialState
@@ -3895,7 +3973,7 @@ var configure = function configure(_ref) {
3895
3973
 
3896
3974
  // @ts-ignore - params is dynamically constructed based on shorthand vs normal call
3897
3975
  return createAutomatedSlice.apply(void 0, _toConsumableArray(params));
3898
- };
3976
+ }
3899
3977
  return {
3900
3978
  createSlice: astroglide,
3901
3979
  astroglide: astroglide,
@@ -3906,4 +3984,6 @@ var configure = function configure(_ref) {
3906
3984
  };
3907
3985
  };
3908
3986
 
3987
+ // Export types for consumer usage
3988
+
3909
3989
  export { addPlugin, addPlugins, configure, createSelectorHook, createSelectorUpdateHook, configure as default, plugins };
package/dist/index.umd.js CHANGED
@@ -9008,15 +9008,86 @@
9008
9008
 
9009
9009
  var _excluded = ["middleware", "devTools", "preloadedState", "enhancers"],
9010
9010
  _excluded2 = ["selectDomain"];
9011
- var configure = function configure(_ref) {
9012
- var _middleware = _ref.middleware,
9011
+
9012
+ // ============================================================================
9013
+ // Utility Types
9014
+ // ============================================================================
9015
+
9016
+ /** Capitalize first letter of a string type */
9017
+
9018
+ // ============================================================================
9019
+ // Hook Types
9020
+ // ============================================================================
9021
+
9022
+ /** Return type for hooks - [value, setter, extras] */
9023
+
9024
+ /** A hook with static methods for non-component usage */
9025
+
9026
+ /** Generate hook types from initial state - creates useFieldName for each field */
9027
+
9028
+ /** Domain hook for the entire slice state */
9029
+
9030
+ // ============================================================================
9031
+ // Selector Types
9032
+ // ============================================================================
9033
+
9034
+ /** Generate selector types from initial state - creates selectFieldName for each field */
9035
+
9036
+ // ============================================================================
9037
+ // Action Types
9038
+ // ============================================================================
9039
+
9040
+ /** Generate setter action types from initial state - creates setFieldName for each field */
9041
+
9042
+ /** Slice-level setter action */
9043
+
9044
+ /** Extract action types from custom reducers */
9045
+
9046
+ // ============================================================================
9047
+ // Extended Slice Type
9048
+ // ============================================================================
9049
+
9050
+ /** Extended slice with hooks, selectors, and properly typed actions */
9051
+
9052
+ // ============================================================================
9053
+ // Configure Options Types
9054
+ // ============================================================================
9055
+
9056
+ /** Configuration options for the store - reducer is NOT required */
9057
+
9058
+ // ============================================================================
9059
+ // RTK Config Types
9060
+ // ============================================================================
9061
+
9062
+ /** RTK-compatible configuration for custom reducers */
9063
+
9064
+ /** Astroglide-specific configuration overrides */
9065
+
9066
+ // ============================================================================
9067
+ // Configure Result Type
9068
+ // ============================================================================
9069
+
9070
+ /** Result returned from configure() */
9071
+
9072
+ var configure = function configure() {
9073
+ var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
9074
+ _middleware = _ref.middleware,
9013
9075
  devTools = _ref.devTools,
9014
9076
  preloadedState = _ref.preloadedState,
9015
9077
  enhancers = _ref.enhancers,
9016
9078
  staticReducers = _objectWithoutProperties(_ref, _excluded);
9079
+ // Add a placeholder reducer if no static reducers provided
9080
+ // This prevents combineReducers({}) from throwing an error
9081
+ var hasStaticReducers = Object.keys(staticReducers).length > 0;
9082
+ var initialReducers = hasStaticReducers ? staticReducers : {
9083
+ __astroglide_init__: function __astroglide_init__() {
9084
+ var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
9085
+ return state;
9086
+ }
9087
+ };
9017
9088
  var store = configureStore({
9018
9089
  // @ts-ignore-next-line
9019
- reducer: combineReducers(staticReducers),
9090
+ reducer: combineReducers(initialReducers),
9020
9091
  middleware: function middleware(getDefaultMiddleware) {
9021
9092
  return [].concat(_toConsumableArray(typeof _middleware === "function" ? _middleware(getDefaultMiddleware) : _middleware || []), [injectableMiddleware]);
9022
9093
  },
@@ -9027,12 +9098,13 @@
9027
9098
  var _configureSelectors = configure$1(store),
9028
9099
  makePropertySelectorsFromSlice = _configureSelectors.makePropertySelectorsFromSlice;
9029
9100
  var injectSlice$1 = function injectSlice$1(slice) {
9030
- return injectSlice(store, staticReducers, slice);
9101
+ return injectSlice(store, initialReducers, slice);
9031
9102
  };
9032
9103
  var injectReducer$1 = function injectReducer$1(key, asyncReducer) {
9033
- return injectReducer(store, staticReducers, key, asyncReducer);
9104
+ return injectReducer(store, initialReducers, key, asyncReducer);
9034
9105
  };
9035
- var createAutomatedSlice = function createAutomatedSlice(sliceConfig, rtkConfig) {
9106
+ var createAutomatedSlice = function createAutomatedSlice(sliceConfig) {
9107
+ var rtkConfig = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
9036
9108
  var pluginData = {};
9037
9109
  map_1(sliceConfig.initialState, function (_item, key) {
9038
9110
  var item = _item; // cache it here to pull item -> value -> value -> value if multiple plugins are used...
@@ -9088,18 +9160,18 @@
9088
9160
  return action.payload;
9089
9161
  }
9090
9162
  }, sliceSetterKey, function (state, action) {
9091
- var _loop = function _loop(key) {
9092
- var actionType = "set".concat(upperFirst_1(key));
9163
+ var _loop = function _loop(_key) {
9164
+ var actionType = "set".concat(upperFirst_1(_key));
9093
9165
  var setter = setterReducers[actionType] || function (_state, _action) {
9094
- _state[key] = _action.payload;
9166
+ _state[_key] = _action.payload;
9095
9167
  };
9096
9168
  setter(state, {
9097
9169
  type: actionType,
9098
- payload: action.payload[key]
9170
+ payload: action.payload[_key]
9099
9171
  });
9100
9172
  };
9101
- for (var key in action.payload) {
9102
- _loop(key);
9173
+ for (var _key in action.payload) {
9174
+ _loop(_key);
9103
9175
  }
9104
9176
  }), sliceConfig.reducers || {})
9105
9177
  }));
@@ -9112,8 +9184,8 @@
9112
9184
  domainHookKey = domainHookKey.replace(/(^use)(.*)(Slice$)/, "$1$2_$3");
9113
9185
  }
9114
9186
  var getParams = function getParams() {
9115
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
9116
- args[_key] = arguments[_key];
9187
+ for (var _len = arguments.length, args = new Array(_len), _key2 = 0; _key2 < _len; _key2++) {
9188
+ args[_key2] = arguments[_key2];
9117
9189
  }
9118
9190
  var params = args;
9119
9191
  if (args.length === 1 && typeof args[0] === "function") {
@@ -9152,10 +9224,16 @@
9152
9224
  injectSlice$1(slice);
9153
9225
  return slice;
9154
9226
  };
9155
- var astroglide = function astroglide(name, initialState) {
9227
+
9228
+ // Overload signatures for the astroglide/createSlice function
9229
+
9230
+ function astroglide(name) {
9231
+ var initialState = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
9156
9232
  var rtkConfig = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
9157
9233
  var astroglideConfigOverrides = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
9158
9234
  var shorthandParams = _typeof$1(name) === "object";
9235
+
9236
+ // Restore original parameter passing logic exactly
9159
9237
  var params = [].concat(_toConsumableArray(shorthandParams ? [name, initialState, rtkConfig] : [_objectSpread2$1(_objectSpread2$1({}, rtkConfig), {}, {
9160
9238
  name: name,
9161
9239
  initialState: initialState
@@ -9163,7 +9241,7 @@
9163
9241
 
9164
9242
  // @ts-ignore - params is dynamically constructed based on shorthand vs normal call
9165
9243
  return createAutomatedSlice.apply(void 0, _toConsumableArray(params));
9166
- };
9244
+ }
9167
9245
  return {
9168
9246
  createSlice: astroglide,
9169
9247
  astroglide: astroglide,
@@ -9174,6 +9252,8 @@
9174
9252
  };
9175
9253
  };
9176
9254
 
9255
+ // Export types for consumer usage
9256
+
9177
9257
  exports.addPlugin = addPlugin;
9178
9258
  exports.addPlugins = addPlugins;
9179
9259
  exports.configure = configure;
@@ -1,20 +1,101 @@
1
- import type { ConfigureStoreOptions, Slice } from "@reduxjs/toolkit";
2
- type ExtendedSlice = Slice & {
3
- hooks: object;
4
- selectors: object;
1
+ import { injectMiddleware } from "redux-injectable-middleware";
2
+ import type { Slice, Reducer, Action, Dispatch, Store, CaseReducer, PayloadAction } from "@reduxjs/toolkit";
3
+ /** Capitalize first letter of a string type */
4
+ type Capitalize<S extends string> = S extends `${infer F}${infer R}` ? `${Uppercase<F>}${R}` : S;
5
+ /** Return type for hooks - [value, setter, extras] */
6
+ type HookReturn<T> = [
7
+ T,
8
+ (value: T | ((prev: T) => T)) => void,
9
+ {
10
+ dispatch: Dispatch;
11
+ toggle?: T extends boolean ? () => void : never;
12
+ }
13
+ ];
14
+ /** A hook with static methods for non-component usage */
15
+ interface SliceHook<T> {
16
+ (setterCb?: (value: T) => T): [T, (value: T | ((prev: T) => T)) => void];
17
+ select: (state: any) => T;
18
+ update: (value: T | ((prev: T) => T)) => Action;
19
+ }
20
+ /** Generate hook types from initial state - creates useFieldName for each field */
21
+ type GeneratedHooks<S> = {
22
+ [K in keyof S as `use${Capitalize<string & K>}`]: SliceHook<S[K]>;
5
23
  };
6
- export declare const configure: ({ middleware, devTools, preloadedState, enhancers, ...staticReducers }: ConfigureStoreOptions) => {
7
- createSlice: (name: string | {
24
+ /** Domain hook for the entire slice state */
25
+ interface SliceDomainHook<S> {
26
+ (): [S, (value: Partial<S> | ((prev: S) => Partial<S>)) => void, (value: S) => void];
27
+ select: (state: any) => S;
28
+ update: (value: Partial<S> | ((prev: S) => Partial<S>)) => Action;
29
+ }
30
+ /** Generate selector types from initial state - creates selectFieldName for each field */
31
+ type GeneratedSelectors<S> = {
32
+ [K in keyof S as `select${Capitalize<string & K>}`]: (state: any) => S[K];
33
+ } & {
34
+ selectDomain: (state: any) => S;
35
+ };
36
+ /** Generate setter action types from initial state - creates setFieldName for each field */
37
+ type GeneratedSetterActions<S> = {
38
+ [K in keyof S as `set${Capitalize<string & K>}`]: (payload: S[K]) => PayloadAction<S[K]>;
39
+ };
40
+ /** Slice-level setter action */
41
+ type SliceSetterAction<S> = (payload: Partial<S>) => PayloadAction<Partial<S>>;
42
+ /** Extract action types from custom reducers */
43
+ type CustomReducerActions<R> = {
44
+ [K in keyof R]: R[K] extends CaseReducer<any, infer A> ? A extends PayloadAction<infer P> ? (payload: P) => PayloadAction<P> : () => Action<string> : never;
45
+ };
46
+ /** Extended slice with hooks, selectors, and properly typed actions */
47
+ interface ExtendedSlice<S extends Record<string, any> = Record<string, any>, CustomReducers extends Record<string, CaseReducer<S, any>> = {}> extends Omit<Slice<S>, 'actions'> {
48
+ name: string;
49
+ reducer: Reducer<S>;
50
+ actions: GeneratedSetterActions<S> & CustomReducerActions<CustomReducers> & {
51
+ setSlice: SliceSetterAction<S>;
52
+ __override__slice__caution: (payload: S) => PayloadAction<S>;
53
+ };
54
+ selectors: GeneratedSelectors<S>;
55
+ hooks: GeneratedHooks<S> & {
56
+ useSlice: SliceDomainHook<S>;
57
+ };
58
+ getInitialState: () => S;
59
+ }
60
+ /** Configuration options for the store - reducer is NOT required */
61
+ interface AstroglideConfigureOptions {
62
+ middleware?: any;
63
+ devTools?: boolean;
64
+ preloadedState?: any;
65
+ enhancers?: any;
66
+ [key: string]: any;
67
+ }
68
+ /** RTK-compatible configuration for custom reducers */
69
+ interface RtkConfig<S, R extends Record<string, CaseReducer<S, any>> = {}> {
70
+ reducers?: R;
71
+ extraReducers?: any;
72
+ selectors?: Record<string, (state: S) => any>;
73
+ }
74
+ /** Astroglide-specific configuration overrides */
75
+ interface AstroglideConfig {
76
+ }
77
+ /** Result returned from configure() */
78
+ interface ConfigureResult {
79
+ store: Store;
80
+ /** Create a slice with simple form: createSlice("name", initialState) */
81
+ createSlice<S extends Record<string, any>>(name: string, initialState: S): ExtendedSlice<S>;
82
+ /** Create a slice with RTK config: createSlice("name", initialState, { reducers }) */
83
+ createSlice<S extends Record<string, any>, R extends Record<string, CaseReducer<S, any>>>(name: string, initialState: S, rtkConfig: RtkConfig<S, R>): ExtendedSlice<S, R>;
84
+ /** Create a slice with RTK-compatible object form: createSlice({ name, initialState }) */
85
+ createSlice<S extends Record<string, any>>(config: {
8
86
  name: string;
9
- initialState: object;
10
- }, initialState: object, rtkConfig?: {}, astroglideConfigOverrides?: {}) => ExtendedSlice;
11
- astroglide: (name: string | {
87
+ initialState: S;
88
+ }): ExtendedSlice<S>;
89
+ /** Create a slice with RTK-compatible object form and reducers: createSlice({ name, initialState }, {}, { reducers }) */
90
+ createSlice<S extends Record<string, any>, R extends Record<string, CaseReducer<S, any>>>(config: {
12
91
  name: string;
13
- initialState: object;
14
- }, initialState: object, rtkConfig?: {}, astroglideConfigOverrides?: {}) => ExtendedSlice;
15
- injectReducer: (key: any, asyncReducer: any) => void;
16
- injectSlice: (slice: any) => void;
17
- injectMiddleware: any;
18
- store: import("@reduxjs/toolkit/dist/configureStore").ToolkitStore<any, import("@reduxjs/toolkit").AnyAction, any[]>;
19
- };
20
- export {};
92
+ initialState: S;
93
+ }, _unused: any, rtkConfig: RtkConfig<S, R>): ExtendedSlice<S, R>;
94
+ /** Alias for createSlice */
95
+ astroglide: ConfigureResult['createSlice'];
96
+ injectReducer: (key: string, reducer: Reducer) => void;
97
+ injectSlice: (slice: Slice | ExtendedSlice<any>) => void;
98
+ injectMiddleware: typeof injectMiddleware;
99
+ }
100
+ export declare const configure: ({ middleware, devTools, preloadedState, enhancers, ...staticReducers }?: AstroglideConfigureOptions) => ConfigureResult;
101
+ export type { ExtendedSlice, ConfigureResult, AstroglideConfigureOptions, RtkConfig, AstroglideConfig, SliceHook, SliceDomainHook, GeneratedHooks, GeneratedSelectors, GeneratedSetterActions, HookReturn, };
@@ -2,4 +2,5 @@ import { configure } from "./astroglide";
2
2
  export { createSelectorHook, createSelectorUpdateHook } from "./selectors";
3
3
  export { configure };
4
4
  export { plugins, addPlugin, addPlugins } from "./plugins/service";
5
+ export type { ExtendedSlice, ConfigureResult, AstroglideConfigureOptions, RtkConfig, AstroglideConfig, SliceHook, SliceDomainHook, GeneratedHooks, GeneratedSelectors, GeneratedSetterActions, HookReturn, } from "./astroglide";
5
6
  export default configure;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "redux-astroglide",
3
- "version": "0.1.22",
3
+ "version": "0.1.24",
4
4
  "description": "Taking the pain out of redux state management",
5
5
  "keywords": [
6
6
  "redux",
@@ -23,37 +23,37 @@
23
23
  "exports": {
24
24
  ".": {
25
25
  "types": "./dist/types/index.d.ts",
26
- "import": "./dist/index.es.js",
26
+ "import": "./dist/index.mjs",
27
27
  "require": "./dist/index.js"
28
28
  },
29
29
  "./plugins": {
30
30
  "types": "./dist/types/plugins/index.d.ts",
31
- "import": "./dist/plugins/index.es.js",
31
+ "import": "./dist/plugins/index.mjs",
32
32
  "require": "./dist/plugins/index.js"
33
33
  },
34
34
  "./plugins/set": {
35
35
  "types": "./dist/types/plugins/set/index.d.ts",
36
- "import": "./dist/plugins/set/index.es.js",
36
+ "import": "./dist/plugins/set/index.mjs",
37
37
  "require": "./dist/plugins/set/index.js"
38
38
  },
39
39
  "./plugins/type": {
40
40
  "types": "./dist/types/plugins/type/index.d.ts",
41
- "import": "./dist/plugins/type/index.es.js",
41
+ "import": "./dist/plugins/type/index.mjs",
42
42
  "require": "./dist/plugins/type/index.js"
43
43
  },
44
44
  "./plugins/persist": {
45
45
  "types": "./dist/types/plugins/persist/index.d.ts",
46
- "import": "./dist/plugins/persist/index.es.js",
46
+ "import": "./dist/plugins/persist/index.mjs",
47
47
  "require": "./dist/plugins/persist/index.js"
48
48
  },
49
49
  "./selectors": {
50
50
  "types": "./dist/types/selectors/index.d.ts",
51
- "import": "./dist/selectors/index.es.js",
51
+ "import": "./dist/selectors/index.mjs",
52
52
  "require": "./dist/selectors/index.js"
53
53
  }
54
54
  },
55
55
  "main": "./dist/index.js",
56
- "module": "./dist/index.es.js",
56
+ "module": "./dist/index.mjs",
57
57
  "browser": "./dist/index.umd.js",
58
58
  "types": "./dist/types/index.d.ts",
59
59
  "files": [
File without changes
File without changes
File without changes
File without changes
File without changes