redux-astroglide 0.1.21 → 0.1.22

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/CHANGELOG.md ADDED
@@ -0,0 +1,4 @@
1
+
2
+ ### Bug Fixes
3
+
4
+ ### Features
package/dist/index.es.js CHANGED
@@ -3892,6 +3892,8 @@ var configure = function configure(_ref) {
3892
3892
  name: name,
3893
3893
  initialState: initialState
3894
3894
  })]), [shorthandParams ? astroglideConfigOverrides : initialState]);
3895
+
3896
+ // @ts-ignore - params is dynamically constructed based on shorthand vs normal call
3895
3897
  return createAutomatedSlice.apply(void 0, _toConsumableArray(params));
3896
3898
  };
3897
3899
  return {
package/dist/index.js CHANGED
@@ -3896,6 +3896,8 @@ var configure = function configure(_ref) {
3896
3896
  name: name,
3897
3897
  initialState: initialState
3898
3898
  })]), [shorthandParams ? astroglideConfigOverrides : initialState]);
3899
+
3900
+ // @ts-ignore - params is dynamically constructed based on shorthand vs normal call
3899
3901
  return createAutomatedSlice.apply(void 0, _toConsumableArray(params));
3900
3902
  };
3901
3903
  return {
package/dist/index.umd.js CHANGED
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react-redux')) :
3
- typeof define === 'function' && define.amd ? define(['exports', 'react-redux'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["redux-astroglide"] = {}, global.reactRedux));
5
- })(this, (function (exports, reactRedux) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
3
+ typeof define === 'function' && define.amd ? define(['exports'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["redux-astroglide"] = {}));
5
+ })(this, (function (exports) { 'use strict';
6
6
 
7
7
  function _arrayLikeToArray(r, a) {
8
8
  (null == a || a > r.length) && (a = r.length);
@@ -5625,23 +5625,6 @@
5625
5625
  var upperFirst = createCaseFirst('toUpperCase');
5626
5626
  var upperFirst_1 = upperFirst;
5627
5627
 
5628
- const callbackObj = {
5629
- onAddMiddleware: () => {
5630
- throw Error("You can't inject middleware until after the store has been initialized.");
5631
- }
5632
- };
5633
- const injectMiddleware = middleware => {
5634
- callbackObj.onAddMiddleware(middleware);
5635
- };
5636
- const injectableMiddleware = store => _next => {
5637
- let next = _next;
5638
- callbackObj.onAddMiddleware = middleware => {
5639
- const currentNextFn = next;
5640
- next = compose(middleware(store))(currentNextFn); // wrap the previous `next` function with this new one, a la redux
5641
- };
5642
- return action => next(action);
5643
- };
5644
-
5645
5628
  var react = {exports: {}};
5646
5629
 
5647
5630
  var react_production_min = {};
@@ -8417,11 +8400,378 @@
8417
8400
  }
8418
8401
  })(react);
8419
8402
 
8403
+ var withSelector = {exports: {}};
8404
+
8405
+ var useSyncExternalStoreWithSelector_production = {};
8406
+
8407
+ /**
8408
+ * @license React
8409
+ * use-sync-external-store-with-selector.production.js
8410
+ *
8411
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
8412
+ *
8413
+ * This source code is licensed under the MIT license found in the
8414
+ * LICENSE file in the root directory of this source tree.
8415
+ */
8416
+ var hasRequiredUseSyncExternalStoreWithSelector_production;
8417
+ function requireUseSyncExternalStoreWithSelector_production() {
8418
+ if (hasRequiredUseSyncExternalStoreWithSelector_production) return useSyncExternalStoreWithSelector_production;
8419
+ hasRequiredUseSyncExternalStoreWithSelector_production = 1;
8420
+ var React = react.exports;
8421
+ function is(x, y) {
8422
+ return x === y && (0 !== x || 1 / x === 1 / y) || x !== x && y !== y;
8423
+ }
8424
+ var objectIs = "function" === typeof Object.is ? Object.is : is,
8425
+ useSyncExternalStore = React.useSyncExternalStore,
8426
+ useRef = React.useRef,
8427
+ useEffect = React.useEffect,
8428
+ useMemo = React.useMemo,
8429
+ useDebugValue = React.useDebugValue;
8430
+ useSyncExternalStoreWithSelector_production.useSyncExternalStoreWithSelector = function (subscribe, getSnapshot, getServerSnapshot, selector, isEqual) {
8431
+ var instRef = useRef(null);
8432
+ if (null === instRef.current) {
8433
+ var inst = {
8434
+ hasValue: !1,
8435
+ value: null
8436
+ };
8437
+ instRef.current = inst;
8438
+ } else inst = instRef.current;
8439
+ instRef = useMemo(function () {
8440
+ function memoizedSelector(nextSnapshot) {
8441
+ if (!hasMemo) {
8442
+ hasMemo = !0;
8443
+ memoizedSnapshot = nextSnapshot;
8444
+ nextSnapshot = selector(nextSnapshot);
8445
+ if (void 0 !== isEqual && inst.hasValue) {
8446
+ var currentSelection = inst.value;
8447
+ if (isEqual(currentSelection, nextSnapshot)) return memoizedSelection = currentSelection;
8448
+ }
8449
+ return memoizedSelection = nextSnapshot;
8450
+ }
8451
+ currentSelection = memoizedSelection;
8452
+ if (objectIs(memoizedSnapshot, nextSnapshot)) return currentSelection;
8453
+ var nextSelection = selector(nextSnapshot);
8454
+ if (void 0 !== isEqual && isEqual(currentSelection, nextSelection)) return memoizedSnapshot = nextSnapshot, currentSelection;
8455
+ memoizedSnapshot = nextSnapshot;
8456
+ return memoizedSelection = nextSelection;
8457
+ }
8458
+ var hasMemo = !1,
8459
+ memoizedSnapshot,
8460
+ memoizedSelection,
8461
+ maybeGetServerSnapshot = void 0 === getServerSnapshot ? null : getServerSnapshot;
8462
+ return [function () {
8463
+ return memoizedSelector(getSnapshot());
8464
+ }, null === maybeGetServerSnapshot ? void 0 : function () {
8465
+ return memoizedSelector(maybeGetServerSnapshot());
8466
+ }];
8467
+ }, [getSnapshot, getServerSnapshot, selector, isEqual]);
8468
+ var value = useSyncExternalStore(subscribe, instRef[0], instRef[1]);
8469
+ useEffect(function () {
8470
+ inst.hasValue = !0;
8471
+ inst.value = value;
8472
+ }, [value]);
8473
+ useDebugValue(value);
8474
+ return value;
8475
+ };
8476
+ return useSyncExternalStoreWithSelector_production;
8477
+ }
8478
+
8479
+ var useSyncExternalStoreWithSelector_development = {};
8480
+
8481
+ /**
8482
+ * @license React
8483
+ * use-sync-external-store-with-selector.development.js
8484
+ *
8485
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
8486
+ *
8487
+ * This source code is licensed under the MIT license found in the
8488
+ * LICENSE file in the root directory of this source tree.
8489
+ */
8490
+ var hasRequiredUseSyncExternalStoreWithSelector_development;
8491
+ function requireUseSyncExternalStoreWithSelector_development() {
8492
+ if (hasRequiredUseSyncExternalStoreWithSelector_development) return useSyncExternalStoreWithSelector_development;
8493
+ hasRequiredUseSyncExternalStoreWithSelector_development = 1;
8494
+ "production" !== process.env.NODE_ENV && function () {
8495
+ function is(x, y) {
8496
+ return x === y && (0 !== x || 1 / x === 1 / y) || x !== x && y !== y;
8497
+ }
8498
+ "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
8499
+ var React = react.exports,
8500
+ objectIs = "function" === typeof Object.is ? Object.is : is,
8501
+ useSyncExternalStore = React.useSyncExternalStore,
8502
+ useRef = React.useRef,
8503
+ useEffect = React.useEffect,
8504
+ useMemo = React.useMemo,
8505
+ useDebugValue = React.useDebugValue;
8506
+ useSyncExternalStoreWithSelector_development.useSyncExternalStoreWithSelector = function (subscribe, getSnapshot, getServerSnapshot, selector, isEqual) {
8507
+ var instRef = useRef(null);
8508
+ if (null === instRef.current) {
8509
+ var inst = {
8510
+ hasValue: !1,
8511
+ value: null
8512
+ };
8513
+ instRef.current = inst;
8514
+ } else inst = instRef.current;
8515
+ instRef = useMemo(function () {
8516
+ function memoizedSelector(nextSnapshot) {
8517
+ if (!hasMemo) {
8518
+ hasMemo = !0;
8519
+ memoizedSnapshot = nextSnapshot;
8520
+ nextSnapshot = selector(nextSnapshot);
8521
+ if (void 0 !== isEqual && inst.hasValue) {
8522
+ var currentSelection = inst.value;
8523
+ if (isEqual(currentSelection, nextSnapshot)) return memoizedSelection = currentSelection;
8524
+ }
8525
+ return memoizedSelection = nextSnapshot;
8526
+ }
8527
+ currentSelection = memoizedSelection;
8528
+ if (objectIs(memoizedSnapshot, nextSnapshot)) return currentSelection;
8529
+ var nextSelection = selector(nextSnapshot);
8530
+ if (void 0 !== isEqual && isEqual(currentSelection, nextSelection)) return memoizedSnapshot = nextSnapshot, currentSelection;
8531
+ memoizedSnapshot = nextSnapshot;
8532
+ return memoizedSelection = nextSelection;
8533
+ }
8534
+ var hasMemo = !1,
8535
+ memoizedSnapshot,
8536
+ memoizedSelection,
8537
+ maybeGetServerSnapshot = void 0 === getServerSnapshot ? null : getServerSnapshot;
8538
+ return [function () {
8539
+ return memoizedSelector(getSnapshot());
8540
+ }, null === maybeGetServerSnapshot ? void 0 : function () {
8541
+ return memoizedSelector(maybeGetServerSnapshot());
8542
+ }];
8543
+ }, [getSnapshot, getServerSnapshot, selector, isEqual]);
8544
+ var value = useSyncExternalStore(subscribe, instRef[0], instRef[1]);
8545
+ useEffect(function () {
8546
+ inst.hasValue = !0;
8547
+ inst.value = value;
8548
+ }, [value]);
8549
+ useDebugValue(value);
8550
+ return value;
8551
+ };
8552
+ "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
8553
+ }();
8554
+ return useSyncExternalStoreWithSelector_development;
8555
+ }
8556
+
8557
+ (function (module) {
8558
+
8559
+ if (process.env.NODE_ENV === 'production') {
8560
+ module.exports = requireUseSyncExternalStoreWithSelector_production();
8561
+ } else {
8562
+ module.exports = requireUseSyncExternalStoreWithSelector_development();
8563
+ }
8564
+ })(withSelector);
8565
+
8566
+ // src/utils/react.ts
8567
+
8568
+ // src/utils/shallowEqual.ts
8569
+ function is(x, y) {
8570
+ if (x === y) {
8571
+ return x !== 0 || y !== 0 || 1 / x === 1 / y;
8572
+ } else {
8573
+ return x !== x && y !== y;
8574
+ }
8575
+ }
8576
+ function shallowEqual(objA, objB) {
8577
+ if (is(objA, objB)) return true;
8578
+ if (typeof objA !== "object" || objA === null || typeof objB !== "object" || objB === null) {
8579
+ return false;
8580
+ }
8581
+ const keysA = Object.keys(objA);
8582
+ const keysB = Object.keys(objB);
8583
+ if (keysA.length !== keysB.length) return false;
8584
+ for (let i = 0; i < keysA.length; i++) {
8585
+ if (!Object.prototype.hasOwnProperty.call(objB, keysA[i]) || !is(objA[keysA[i]], objB[keysA[i]])) {
8586
+ return false;
8587
+ }
8588
+ }
8589
+ return true;
8590
+ }
8591
+
8592
+ // src/components/Context.ts
8593
+ var ContextKey = /* @__PURE__ */ Symbol.for(`react-redux-context`);
8594
+ var gT = typeof globalThis !== "undefined" ? globalThis : (
8595
+ /* fall back to a per-module scope (pre-8.1 behaviour) if `globalThis` is not available */
8596
+ {}
8597
+ );
8598
+ function getContext() {
8599
+ if (!react.exports.createContext) return {};
8600
+ const contextMap = gT[ContextKey] ??= /* @__PURE__ */ new Map();
8601
+ let realContext = contextMap.get(react.exports.createContext);
8602
+ if (!realContext) {
8603
+ realContext = react.exports.createContext(
8604
+ null
8605
+ );
8606
+ if (process.env.NODE_ENV !== "production") {
8607
+ realContext.displayName = "ReactRedux";
8608
+ }
8609
+ contextMap.set(react.exports.createContext, realContext);
8610
+ }
8611
+ return realContext;
8612
+ }
8613
+ var ReactReduxContext = /* @__PURE__ */ getContext();
8614
+
8615
+ // src/hooks/useReduxContext.ts
8616
+ function createReduxContextHook(context = ReactReduxContext) {
8617
+ return function useReduxContext2() {
8618
+ const contextValue = react.exports.useContext(context);
8619
+ if (process.env.NODE_ENV !== "production" && !contextValue) {
8620
+ throw new Error(
8621
+ "could not find react-redux context value; please ensure the component is wrapped in a <Provider>"
8622
+ );
8623
+ }
8624
+ return contextValue;
8625
+ };
8626
+ }
8627
+ var useReduxContext = /* @__PURE__ */ createReduxContextHook();
8628
+
8629
+ // src/hooks/useStore.ts
8630
+ function createStoreHook(context = ReactReduxContext) {
8631
+ const useReduxContext2 = context === ReactReduxContext ? useReduxContext : (
8632
+ // @ts-ignore
8633
+ createReduxContextHook(context)
8634
+ );
8635
+ const useStore2 = () => {
8636
+ const { store } = useReduxContext2();
8637
+ return store;
8638
+ };
8639
+ Object.assign(useStore2, {
8640
+ withTypes: () => useStore2
8641
+ });
8642
+ return useStore2;
8643
+ }
8644
+ var useStore = /* @__PURE__ */ createStoreHook();
8645
+
8646
+ // src/hooks/useDispatch.ts
8647
+ function createDispatchHook(context = ReactReduxContext) {
8648
+ const useStore2 = context === ReactReduxContext ? useStore : createStoreHook(context);
8649
+ const useDispatch2 = () => {
8650
+ const store = useStore2();
8651
+ return store.dispatch;
8652
+ };
8653
+ Object.assign(useDispatch2, {
8654
+ withTypes: () => useDispatch2
8655
+ });
8656
+ return useDispatch2;
8657
+ }
8658
+ var useDispatch = /* @__PURE__ */ createDispatchHook();
8659
+ var refEquality = (a, b) => a === b;
8660
+ function createSelectorHook$1(context = ReactReduxContext) {
8661
+ const useReduxContext2 = context === ReactReduxContext ? useReduxContext : createReduxContextHook(context);
8662
+ const useSelector2 = (selector, equalityFnOrOptions = {}) => {
8663
+ const { equalityFn = refEquality } = typeof equalityFnOrOptions === "function" ? { equalityFn: equalityFnOrOptions } : equalityFnOrOptions;
8664
+ if (process.env.NODE_ENV !== "production") {
8665
+ if (!selector) {
8666
+ throw new Error(`You must pass a selector to useSelector`);
8667
+ }
8668
+ if (typeof selector !== "function") {
8669
+ throw new Error(`You must pass a function as a selector to useSelector`);
8670
+ }
8671
+ if (typeof equalityFn !== "function") {
8672
+ throw new Error(
8673
+ `You must pass a function as an equality function to useSelector`
8674
+ );
8675
+ }
8676
+ }
8677
+ const reduxContext = useReduxContext2();
8678
+ const { store, subscription, getServerState } = reduxContext;
8679
+ const firstRun = react.exports.useRef(true);
8680
+ const wrappedSelector = react.exports.useCallback(
8681
+ {
8682
+ [selector.name](state) {
8683
+ const selected = selector(state);
8684
+ if (process.env.NODE_ENV !== "production") {
8685
+ const { devModeChecks = {} } = typeof equalityFnOrOptions === "function" ? {} : equalityFnOrOptions;
8686
+ const { identityFunctionCheck, stabilityCheck } = reduxContext;
8687
+ const {
8688
+ identityFunctionCheck: finalIdentityFunctionCheck,
8689
+ stabilityCheck: finalStabilityCheck
8690
+ } = {
8691
+ stabilityCheck,
8692
+ identityFunctionCheck,
8693
+ ...devModeChecks
8694
+ };
8695
+ if (finalStabilityCheck === "always" || finalStabilityCheck === "once" && firstRun.current) {
8696
+ const toCompare = selector(state);
8697
+ if (!equalityFn(selected, toCompare)) {
8698
+ let stack = void 0;
8699
+ try {
8700
+ throw new Error();
8701
+ } catch (e) {
8702
+ ({ stack } = e);
8703
+ }
8704
+ console.warn(
8705
+ "Selector " + (selector.name || "unknown") + " returned a different result when called with the same parameters. This can lead to unnecessary rerenders.\nSelectors that return a new reference (such as an object or an array) should be memoized: https://redux.js.org/usage/deriving-data-selectors#optimizing-selectors-with-memoization",
8706
+ {
8707
+ state,
8708
+ selected,
8709
+ selected2: toCompare,
8710
+ stack
8711
+ }
8712
+ );
8713
+ }
8714
+ }
8715
+ if (finalIdentityFunctionCheck === "always" || finalIdentityFunctionCheck === "once" && firstRun.current) {
8716
+ if (selected === state) {
8717
+ let stack = void 0;
8718
+ try {
8719
+ throw new Error();
8720
+ } catch (e) {
8721
+ ({ stack } = e);
8722
+ }
8723
+ console.warn(
8724
+ "Selector " + (selector.name || "unknown") + " returned the root state when called. This can lead to unnecessary rerenders.\nSelectors that return the entire state are almost certainly a mistake, as they will cause a rerender whenever *anything* in state changes.",
8725
+ { stack }
8726
+ );
8727
+ }
8728
+ }
8729
+ if (firstRun.current) firstRun.current = false;
8730
+ }
8731
+ return selected;
8732
+ }
8733
+ }[selector.name],
8734
+ [selector]
8735
+ );
8736
+ const selectedState = withSelector.exports.useSyncExternalStoreWithSelector(
8737
+ subscription.addNestedSub,
8738
+ store.getState,
8739
+ getServerState || store.getState,
8740
+ wrappedSelector,
8741
+ equalityFn
8742
+ );
8743
+ react.exports.useDebugValue(selectedState);
8744
+ return selectedState;
8745
+ };
8746
+ Object.assign(useSelector2, {
8747
+ withTypes: () => useSelector2
8748
+ });
8749
+ return useSelector2;
8750
+ }
8751
+ var useSelector = /* @__PURE__ */ createSelectorHook$1();
8752
+
8753
+ const callbackObj = {
8754
+ onAddMiddleware: () => {
8755
+ throw Error("You can't inject middleware until after the store has been initialized.");
8756
+ }
8757
+ };
8758
+ const injectMiddleware = middleware => {
8759
+ callbackObj.onAddMiddleware(middleware);
8760
+ };
8761
+ const injectableMiddleware = store => _next => {
8762
+ let next = _next;
8763
+ callbackObj.onAddMiddleware = middleware => {
8764
+ const currentNextFn = next;
8765
+ next = compose(middleware(store))(currentNextFn); // wrap the previous `next` function with this new one, a la redux
8766
+ };
8767
+ return action => next(action);
8768
+ };
8769
+
8420
8770
  var useAction = function useAction(action, deps) {
8421
8771
  return useActions([action], deps)[0];
8422
8772
  };
8423
8773
  var useActions = function useActions(actions, deps) {
8424
- var dispatch = reactRedux.useDispatch();
8774
+ var dispatch = useDispatch();
8425
8775
  return react.exports.useMemo(function () {
8426
8776
  if (Array.isArray(actions)) {
8427
8777
  return actions.map(function (a) {
@@ -8553,12 +8903,12 @@
8553
8903
 
8554
8904
  var makeSelectorHook = function makeSelectorHook(selector) {
8555
8905
  return function () {
8556
- return reactRedux.useSelector(selector, reactRedux.shallowEqual);
8906
+ return useSelector(selector, shallowEqual);
8557
8907
  };
8558
8908
  };
8559
8909
  var createSelectorUpdateHook = function createSelectorUpdateHook(selector, action) {
8560
8910
  return function () {
8561
- return [reactRedux.useSelector(selector), useAction(action, undefined)];
8911
+ return [useSelector(selector), useAction(action, undefined)];
8562
8912
  };
8563
8913
  };
8564
8914
  var createSelectorHook = function createSelectorHook() {
@@ -8626,7 +8976,7 @@
8626
8976
  var setterCb = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : function (value) {
8627
8977
  return value;
8628
8978
  };
8629
- return [reactRedux.useSelector(selector), useAction(function (value) {
8979
+ return [useSelector(selector), useAction(function (value) {
8630
8980
  return updateAction(setterCb(value));
8631
8981
  }, undefined)];
8632
8982
  };
@@ -8782,7 +9132,7 @@
8782
9132
 
8783
9133
  /* eslint-disable react-hooks/rules-of-hooks */
8784
9134
  hooks[domainHookKey] = function () {
8785
- return [reactRedux.useSelector(selectDomain), useAction(slice.actions[sliceSetterKey], undefined).apply(void 0, _toConsumableArray(getParams())),
9135
+ return [useSelector(selectDomain), useAction(slice.actions[sliceSetterKey], undefined).apply(void 0, _toConsumableArray(getParams())),
8786
9136
  // prop updater
8787
9137
  useAction(slice.actions.__override__slice__caution, undefined) // state overwriter
8788
9138
  ];
@@ -8810,6 +9160,8 @@
8810
9160
  name: name,
8811
9161
  initialState: initialState
8812
9162
  })]), [shorthandParams ? astroglideConfigOverrides : initialState]);
9163
+
9164
+ // @ts-ignore - params is dynamically constructed based on shorthand vs normal call
8813
9165
  return createAutomatedSlice.apply(void 0, _toConsumableArray(params));
8814
9166
  };
8815
9167
  return {