state-decorator 7.7.0-beta.1 → 9.0.0-rc.0
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/README.md +137 -179
- package/development.js +2 -2
- package/development.js.map +1 -1
- package/helpers.js +2 -2
- package/helpers.js.map +1 -1
- package/impl.js +2 -2
- package/impl.js.map +1 -1
- package/index.d.ts +0 -1
- package/index.js +42 -2
- package/index.js.map +1 -1
- package/middlewares.js +2 -2
- package/middlewares.js.map +1 -1
- package/package.json +2 -2
- package/test.js +2 -2
- package/test.js.map +1 -1
- package/es/development.d.ts +0 -10
- package/es/development.js +0 -2
- package/es/development.js.map +0 -1
- package/es/graph.d.ts +0 -8
- package/es/helpers.d.ts +0 -67
- package/es/helpers.js +0 -2
- package/es/helpers.js.map +0 -1
- package/es/impl.d.ts +0 -204
- package/es/impl.js +0 -2
- package/es/impl.js.map +0 -1
- package/es/index.d.ts +0 -183
- package/es/index.js +0 -2
- package/es/index.js.map +0 -1
- package/es/middlewares.d.ts +0 -3
- package/es/middlewares.js +0 -2
- package/es/middlewares.js.map +0 -1
- package/es/shallow.d.ts +0 -1
- package/es/test.d.ts +0 -126
- package/es/test.js +0 -2
- package/es/test.js.map +0 -1
- package/es/types.d.ts +0 -387
- package/es/v5.d.ts +0 -45
- package/es/v5.js +0 -2
- package/es/v5.js.map +0 -1
- package/es/v5_test.d.ts +0 -57
- package/es/v5_test.js +0 -2
- package/es/v5_test.js.map +0 -1
- package/es/v5_types.d.ts +0 -213
- package/es/v6.d.ts +0 -21
- package/es/v6.js +0 -2
- package/es/v6.js.map +0 -1
- package/v5.d.ts +0 -45
- package/v5.js +0 -2
- package/v5.js.map +0 -1
- package/v5_test.d.ts +0 -57
- package/v5_test.js +0 -2
- package/v5_test.js.map +0 -1
- package/v5_types.d.ts +0 -213
- package/v6.d.ts +0 -21
- package/v6.js +0 -2
- package/v6.js.map +0 -1
package/README.md
CHANGED
|
@@ -6,6 +6,43 @@
|
|
|
6
6
|
|
|
7
7
|
The StateDecorator is a set of React hooks that manage a complex component state in an easy, testable and deterministic way.
|
|
8
8
|
|
|
9
|
+
## Table of contents
|
|
10
|
+
|
|
11
|
+
- [Features](#features)
|
|
12
|
+
- [V7: Partial state and new hooks](#v7-partial-state-and-new-hooks)
|
|
13
|
+
- [V8: Better React 19 compatibility](#v8-better-react-19-compatibility)
|
|
14
|
+
- [V9: ES-only build and legacy removal](#v9-es-only-build-and-legacy-removal)
|
|
15
|
+
- [Getting started](#getting-started)
|
|
16
|
+
- [React hooks](#react-hooks)
|
|
17
|
+
- [StoreApi](#storeapi)
|
|
18
|
+
- [Initial state](#initial-state)
|
|
19
|
+
- [Action context](#action-context)
|
|
20
|
+
- [Actions](#actions)
|
|
21
|
+
- [Synchronous actions](#synchronous-actions)
|
|
22
|
+
- [Asynchronous actions](#asynchronous-actions)
|
|
23
|
+
- [Error management](#ErrorManagement)
|
|
24
|
+
- [Conflicting actions](#ConflictingActions)
|
|
25
|
+
- [Global / local Stores and State sharing](#GlobalLocalStores)
|
|
26
|
+
- [Derived state](#derived-state)
|
|
27
|
+
- [Global configuration](#global-configuration)
|
|
28
|
+
- [Trace actions](#trace-actions)
|
|
29
|
+
- [Concise logger](#concise-logger)
|
|
30
|
+
- [Detailed Logger](#detailed-logger)
|
|
31
|
+
- [Redux devtools](#redux-devtools)
|
|
32
|
+
- [Unit testing](#unit-testing)
|
|
33
|
+
- [Example](#example)
|
|
34
|
+
- [Error testing](#error-testing)
|
|
35
|
+
- [API](#api)
|
|
36
|
+
- [Immutability](#immutability)
|
|
37
|
+
- [Build](#build)
|
|
38
|
+
- [Limitations](#limitations)
|
|
39
|
+
- [Migration](#migration)
|
|
40
|
+
- [V8 to V9](#v8-to-v9)
|
|
41
|
+
- [V7 to V8](#v7-to-v8)
|
|
42
|
+
- [V6 to V7](#v6-to-v7)
|
|
43
|
+
- [Examples](#examples)
|
|
44
|
+
- [Visual Studio Code user snippet](#visual-studio-code-user-snippet)
|
|
45
|
+
|
|
9
46
|
# Features
|
|
10
47
|
|
|
11
48
|
- Deterministic state changes (clear separation of effects and side effects)
|
|
@@ -28,6 +65,18 @@ The StateDecorator is a set of React hooks that manage a complex component state
|
|
|
28
65
|
- New effect helpers
|
|
29
66
|
- See migration details in [migration section](#migration).
|
|
30
67
|
|
|
68
|
+
# V8: Better React 19 compatibility
|
|
69
|
+
|
|
70
|
+
- Fixed a React 18+/19 concurrent rendering issue: **onMount** (and **onPropsChange** entries flagged **onMount: true**) used to run during **init()**, which can itself run during render. Under concurrent rendering, a discarded and retried render attempt could trigger these side effects (e.g. data fetches) more than once per real mount. They are now deferred to a new **runMountEffects()** store method, called once from a layout effect after the render that actually commits — see [Call actions on mount](#call-actions-on-mount).
|
|
71
|
+
- See migration details in [migration section](#migration).
|
|
72
|
+
|
|
73
|
+
# V9: ES-only build and legacy removal
|
|
74
|
+
|
|
75
|
+
- The **v5** and **v6** compatibility layers were removed: the `state-decorator/v5`, `state-decorator/v5_test` and `state-decorator/v6` entry points no longer exist.
|
|
76
|
+
- The package is now ES modules only: the CommonJS build and the `es/` folder were removed, the output is not transpiled (ESNext, it was ES5) and the ES files are now at the package root. A bundler is required.
|
|
77
|
+
- The library is now built with [rolldown](https://rolldown.rs).
|
|
78
|
+
- See migration details in [migration section](#migration).
|
|
79
|
+
|
|
31
80
|
# Getting started
|
|
32
81
|
|
|
33
82
|
## Installation
|
|
@@ -141,13 +190,40 @@ export function App(props: Props) => {
|
|
|
141
190
|
|
|
142
191
|
# React hooks
|
|
143
192
|
|
|
144
|
-
| Hook | Purpose
|
|
145
|
-
| -------------------- |
|
|
146
|
-
| useLocalStore | Create a store and binds it to the react component.
|
|
147
|
-
| useStore |
|
|
148
|
-
| useBindStore | Binds a store instance to the react component (inject props).
|
|
149
|
-
| useStoreSlice | Get a slice of a store.
|
|
150
|
-
| useStoreContextSlice | Get a slice of a store stored in a context
|
|
193
|
+
| Hook | Purpose | Returns | Is component refreshed on store change? | Is store destroyed on unmount? |
|
|
194
|
+
| -------------------- | ------------------------------------------------------------------------------------------------------------------- | ------- | --------------------------------------- | ------------------------------ |
|
|
195
|
+
| useLocalStore | Create a store and binds it to the react component. | Store | if **refreshOnUpdate** is set | Y |
|
|
196
|
+
| useStore | Subscribes the component to a store instance already owned/initialized elsewhere (does not call `init`/`setProps`). | Store | yes | N |
|
|
197
|
+
| useBindStore | Binds a store instance to the react component (inject props). | Store | yes | N |
|
|
198
|
+
| useStoreSlice | Get a slice of a store. | Slice | yes | N |
|
|
199
|
+
| useStoreContextSlice | Get a slice of a store stored in a context | Slice | If slice has changed only | N |
|
|
200
|
+
|
|
201
|
+
# StoreApi
|
|
202
|
+
|
|
203
|
+
Whatever hook is used (or a plain `createStore`), the resulting store exposes the same **StoreApi**:
|
|
204
|
+
|
|
205
|
+
| Member | Signature | Description |
|
|
206
|
+
| ------------------------------------ | ------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
207
|
+
| state | `S & DS` | Current state, merged with derived state if any. |
|
|
208
|
+
| actions | `A` | Decorated actions, ready to call. |
|
|
209
|
+
| loading | `boolean` | `true` if at least one asynchronous action is currently loading. |
|
|
210
|
+
| loadingMap | `LoadingMap<A>` | Per-action loading flags (computed on access). |
|
|
211
|
+
| errorMap | `ErrorMap<A>` | Per-action error map (computed on access). |
|
|
212
|
+
| loadingParallelMap | `LoadingParallelMap<A>` | Per-action, per-`promiseId` loading flags for parallel actions. |
|
|
213
|
+
| errorParallelMap | `ErrorParallelMap<A>` | Per-action, per-`promiseId` error map for parallel actions. |
|
|
214
|
+
| `init(p)` | `(p: P) => void` | Initializes the store with the given props: computes initial state, runs `onPropsChange` effects. Called automatically by **useLocalStore** / **useBindStore**. |
|
|
215
|
+
| `runMountEffects()` | `() => void` | Runs **onMount** (and `onPropsChange` entries flagged `onMount: true`) exactly once. Must be called after `init()`, from an effect (never a render body). Called automatically by **useLocalStore** / **useBindStore** — see [Call actions on mount](#call-actions-on-mount). |
|
|
216
|
+
| `setProps(p)` | `(p: P) => void` | Updates the store with new props, triggering matching `onPropsChange` entries. |
|
|
217
|
+
| `destroy()` | `() => void` | Destroys the store: runs **onUnmount**, clears listeners/timers. Called automatically when a **useLocalStore**-owned component unmounts. |
|
|
218
|
+
| `abortAction(name, promiseId?)` | `(actionName: keyof A, promiseId?: string) => boolean` | Aborts a running asynchronous action marked `abortable`. See [Abort asynchronous action](#abort-asynchronous-action). |
|
|
219
|
+
| `addStateListener(listener)` | `(listener: () => void) => unregister` | Subscribes to state changes; returns an unregister function. |
|
|
220
|
+
| `isLoading(...)` | `IsLoadingFunc<A>` | Returns `true` if any of the given action names (or `[name, promiseId]` tuples) are loading. |
|
|
221
|
+
| `clearError(...)` | `ClearErrorFunc<A>` | Clears the error of an action marked `isErrorManaged: true`. |
|
|
222
|
+
| `getConfig()` | `() => StoreConfig<S, A, P, DS>` | Returns the store's configuration. |
|
|
223
|
+
| `getSnapshot()` | `() => StateListenerContext<S, DS, A, P>` | Returns a snapshot of the current state/props/actions. Used internally (e.g. by `useSyncExternalStore`). |
|
|
224
|
+
| `listenToStoreProps(depStore, keys)` | `(depStore: StoreApi, keys: K[]) => unregister` | Subscribes to another store's state changes and mirrors the listed properties into this store's props (via `setProps`) whenever they change. Returns an unregister function. |
|
|
225
|
+
|
|
226
|
+
**Note**: most of these methods (`init`, `runMountEffects`, `destroy`, `setProps`) are lifecycle methods already called for you by **useLocalStore** and **useBindStore**. You only need to call them yourself when driving a store outside these two hooks — e.g. a plain **createStore** used without React, or read through **useStore** / **useStoreSlice** (which only subscribe, they don't own the lifecycle).
|
|
151
227
|
|
|
152
228
|
# Initial state
|
|
153
229
|
|
|
@@ -648,7 +724,7 @@ const actions: StoreActions<State, Actions> = {
|
|
|
648
724
|
|
|
649
725
|
## Call actions on mount
|
|
650
726
|
|
|
651
|
-
When store is
|
|
727
|
+
When the store is mounted, the **onMount** option is called.
|
|
652
728
|
|
|
653
729
|
```typescript
|
|
654
730
|
import { StoreConfig } from 'state-decorator';
|
|
@@ -662,9 +738,19 @@ const config: StoreConfig<State, Actions, Props> = {
|
|
|
662
738
|
};
|
|
663
739
|
```
|
|
664
740
|
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
React
|
|
741
|
+
**onMount** (and any **onPropsChange** entry flagged **onMount: true**, see below) is _not_ called by **init()**. It is called by **runMountEffects()**, a separate store method that must be called once, after **init()**, from a React layout/passive effect (never from a render body) — **useLocalStore** and **useBindStore** already call it for you automatically, since these are the hooks that own the store's lifecycle (they call `init`/`runMountEffects`/`destroy`). **useStore** does not: it only subscribes to a store that is already initialized and mounted elsewhere (e.g. by `useBindStore`, `useLocalStore`, or manual code), so it never calls `init` or `runMountEffects` itself.
|
|
742
|
+
|
|
743
|
+
If you use **createStore** without any of these hooks (a store driven entirely outside React, e.g. `store.init(props)` called directly), you are responsible for calling `store.runMountEffects()` yourself once after `init()` — otherwise **onMount** (and any props change effects flagged `onMount: true`) will never run.
|
|
744
|
+
|
|
745
|
+
```typescript
|
|
746
|
+
const store = createStore(config);
|
|
747
|
+
store.init(props);
|
|
748
|
+
store.runMountEffects(); // required if the store isn't bound via useLocalStore / useBindStore
|
|
749
|
+
```
|
|
750
|
+
|
|
751
|
+
**onMount** is called from a layout effect (_useLayoutEffect_), synchronously right after mount and before paint. **onMountDeferred** is called from a passive effect (_useEffect_), after paint.
|
|
752
|
+
|
|
753
|
+
Use **onMount** for state changes that should be visible on first paint (e.g. avoiding a flash of missing data). Use **onMountDeferred** for work that doesn't need to block paint (e.g. expensive initialization, or work that depends on child components' own effects/refs having already run).
|
|
668
754
|
|
|
669
755
|
```typescript
|
|
670
756
|
import { StoreConfig } from 'state-decorator';
|
|
@@ -735,7 +821,7 @@ const config: StoreConfig<State, Actions, Props> = {
|
|
|
735
821
|
|
|
736
822
|
## OnMount
|
|
737
823
|
|
|
738
|
-
If the onMount flag is set on the props change configuration, the effects and side effects will be executed
|
|
824
|
+
If the onMount flag is set on the props change configuration, the effects and side effects will be executed when **runMountEffects()** is called (see [Call actions on mount](#call-actions-on-mount) above) — automatically after mount when using **useLocalStore** / **useStore** / **useBindStore**, or manually via `store.runMountEffects()` if the store isn't bound to any of these hooks.
|
|
739
825
|
|
|
740
826
|
It allows to trigger same actions at creation time and when the dependencies props are changed.
|
|
741
827
|
|
|
@@ -786,7 +872,7 @@ const config: StoreConfig<State, Actions, Props> = {
|
|
|
786
872
|
- Use several prop change configurations to separate dependencies between props and have simple definition.
|
|
787
873
|
- Use onMount flag to have a more systematic and simpler code.
|
|
788
874
|
|
|
789
|
-
# Global / local Stores and State sharing
|
|
875
|
+
# <a name="GlobalLocalStores"></a>Global / local Stores and State sharing
|
|
790
876
|
|
|
791
877
|
There are two ways to share state and actions:
|
|
792
878
|
|
|
@@ -825,13 +911,13 @@ export const store = createStore(getInitialState, userAppActions);
|
|
|
825
911
|
|
|
826
912
|
// In another file
|
|
827
913
|
import { memo } from 'react';
|
|
828
|
-
import {
|
|
914
|
+
import { useBindStore } from 'state-decorator';
|
|
829
915
|
import store from './GlobalStore';
|
|
830
916
|
|
|
831
|
-
// Bind to react component
|
|
917
|
+
// Bind to react component and inject props
|
|
832
918
|
// Each time the store state changes, a re-render is done.
|
|
833
919
|
export function Container(props: Props) {
|
|
834
|
-
const { state, actions } =
|
|
920
|
+
const { state, actions } = useBindStore(store, props);
|
|
835
921
|
return (
|
|
836
922
|
<div>
|
|
837
923
|
<Title text={state.title} />
|
|
@@ -1046,7 +1132,7 @@ const store = createStore<State, Actions, Props, DerivedState>({
|
|
|
1046
1132
|
});
|
|
1047
1133
|
|
|
1048
1134
|
export function App(props: Props) {
|
|
1049
|
-
const { state } =
|
|
1135
|
+
const { state } = useBindStore(store, props);
|
|
1050
1136
|
// state contains the store state and derived state
|
|
1051
1137
|
return (
|
|
1052
1138
|
<div>
|
|
@@ -1679,17 +1765,15 @@ TypeError: Cannot set property 'crash' of null
|
|
|
1679
1765
|
|
|
1680
1766
|
# Build
|
|
1681
1767
|
|
|
1682
|
-
This library provides
|
|
1768
|
+
This library provides ES modules only, with untranspiled ESNext output: it is meant to be consumed through a bundler (webpack, Vite, Rollup, esbuild...) that transpiles it for your target browsers. Each entry point (`index`, `helpers`, `middlewares`, `development`, `test`) is a file at the package root, and no bundler alias is needed.
|
|
1683
1769
|
|
|
1684
|
-
|
|
1770
|
+
It is built with [rolldown](https://rolldown.rs):
|
|
1685
1771
|
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
},
|
|
1692
|
-
```
|
|
1772
|
+
- `yarn bundle` builds the production bundles (minified) in `lib` and emits the type declarations with `tsc`
|
|
1773
|
+
- `yarn bundle:dev` builds non-minified bundles
|
|
1774
|
+
- `yarn build` runs `yarn bundle` and prepares `lib` for publication
|
|
1775
|
+
|
|
1776
|
+
`process.env.NODE_ENV` is not replaced at build time: the development tools (`state-decorator/development`) rely on your own bundler defining it.
|
|
1693
1777
|
|
|
1694
1778
|
# Limitations
|
|
1695
1779
|
|
|
@@ -1701,18 +1785,39 @@ resolve: {
|
|
|
1701
1785
|
|
|
1702
1786
|
# Migration
|
|
1703
1787
|
|
|
1704
|
-
##
|
|
1788
|
+
## V8 to V9
|
|
1789
|
+
|
|
1790
|
+
### Legacy compatibility layers removed
|
|
1791
|
+
|
|
1792
|
+
The following entry points were removed, along with everything they exported (**useStateDecorator**, **StateDecoratorActions**, the **testV6\*** helpers...):
|
|
1793
|
+
|
|
1794
|
+
- `state-decorator/v5`
|
|
1795
|
+
- `state-decorator/v5_test`
|
|
1796
|
+
- `state-decorator/v6`
|
|
1797
|
+
|
|
1798
|
+
If your code still imports one of them, migrate it to the current API **before** upgrading, using the guides of a previous release (the V5 to V6 guide only exists in the README of v8.0.0). The V6 to V7 guide below describes the code changes.
|
|
1799
|
+
|
|
1800
|
+
### ES modules only
|
|
1801
|
+
|
|
1802
|
+
- The CommonJS build was removed: `main` and `module` now both point to the ES file `index.js`, so `require('state-decorator')` is no longer supported. A bundler (webpack, Vite, Rollup, esbuild...) is required.
|
|
1803
|
+
- The `es/` folder was removed: the ES files are now at the package root, like the former CommonJS ones. Imports like `state-decorator/helpers` or `state-decorator/middlewares` are unchanged, but deep imports of `state-decorator/es/...` must drop the `es/` segment (`state-decorator/es/helpers` becomes `state-decorator/helpers`). The webpack alias `'state-decorator': 'state-decorator/es'` must be removed.
|
|
1804
|
+
- The output is ESNext instead of ES5: it is not transpiled, so your bundler must transpile `state-decorator` (e.g. include it in your Babel/SWC rules if `node_modules` is excluded) for the browsers you support.
|
|
1705
1805
|
|
|
1706
|
-
|
|
1806
|
+
## V7 to V8
|
|
1707
1807
|
|
|
1708
|
-
|
|
1808
|
+
No breaking changes for **useLocalStore** / **useStore** / **useBindStore** users — they behave the same, no code change needed.
|
|
1809
|
+
|
|
1810
|
+
The only breaking change concerns code using **createStore** directly without any of these hooks: **onMount** (and **onPropsChange** entries flagged **onMount: true**) is no longer called by **init()**. It is now called by a new **runMountEffects()** store method, which you must call once yourself, right after **init()**:
|
|
1709
1811
|
|
|
1710
1812
|
```diff
|
|
1711
|
-
|
|
1712
|
-
|
|
1813
|
+
const store = createStore(config);
|
|
1814
|
+
store.init(props);
|
|
1815
|
+
+store.runMountEffects();
|
|
1713
1816
|
```
|
|
1714
1817
|
|
|
1715
|
-
|
|
1818
|
+
If you skip this, **onMount** (and `onMount`-flagged **onPropsChange** entries) will simply never run. See [Call actions on mount](#call-actions-on-mount) for details.
|
|
1819
|
+
|
|
1820
|
+
## V6 to V7
|
|
1716
1821
|
|
|
1717
1822
|
- Merge _getInitialState_, _actions_, _options_ in a single object.
|
|
1718
1823
|
- Remove state spread in effects
|
|
@@ -1758,153 +1863,6 @@ Only **useLocalStore** is supported by compatiblity layer.
|
|
|
1758
1863
|
+ }
|
|
1759
1864
|
```
|
|
1760
1865
|
|
|
1761
|
-
## V5 to V6
|
|
1762
|
-
|
|
1763
|
-
### Step 1: v5 compatibility layer
|
|
1764
|
-
|
|
1765
|
-
To use the new engine while still using v5 API, juste import the v5 compatibility layer.
|
|
1766
|
-
You can new store in new code.
|
|
1767
|
-
|
|
1768
|
-
```diff
|
|
1769
|
-
-import useStateDecorator, { StateDecoratorActions } from 'state-decorator';
|
|
1770
|
-
+import useStateDecorator, { StateDecoratorActions } from 'state-decorator/v5';
|
|
1771
|
-
```
|
|
1772
|
-
|
|
1773
|
-
If you are using optimistic effects, make sure to set the **optimisticActions** middleware as a default middleware, see [Optimistic actions](#optimistic-actions).
|
|
1774
|
-
|
|
1775
|
-
```typescript
|
|
1776
|
-
import { setGlobalConfig } from 'state-decorator';
|
|
1777
|
-
import { optimisticActions } from 'state-decorator/middlewares';
|
|
1778
|
-
|
|
1779
|
-
setGlobalConfig({
|
|
1780
|
-
defaultMiddlewares: [optimisticActions()],
|
|
1781
|
-
});
|
|
1782
|
-
```
|
|
1783
|
-
|
|
1784
|
-
### Step 2: Migrate code but keep v5 tests
|
|
1785
|
-
|
|
1786
|
-
#### Code
|
|
1787
|
-
|
|
1788
|
-
##### Types
|
|
1789
|
-
|
|
1790
|
-
| Before | After |
|
|
1791
|
-
| --------------------- | ------------ |
|
|
1792
|
-
| StateDecoratorActions | StoreActions |
|
|
1793
|
-
| StateDecoratorOptions | StoreOptions |
|
|
1794
|
-
|
|
1795
|
-
##### Optimistic actions
|
|
1796
|
-
|
|
1797
|
-
If you are using optimistic effects, make sure to set the **optimisticActions** middleware to your stores, see [Optimistic actions](#optimistic-actions).
|
|
1798
|
-
|
|
1799
|
-
#### Hooks
|
|
1800
|
-
|
|
1801
|
-
Choose one of _useLocalStore_, _useStore_, _useStoreSlice_.
|
|
1802
|
-
|
|
1803
|
-
#### Actions
|
|
1804
|
-
|
|
1805
|
-
- rename action properties
|
|
1806
|
-
|
|
1807
|
-
| Before | After |
|
|
1808
|
-
| ----------------- | ----------------- |
|
|
1809
|
-
| action | effects |
|
|
1810
|
-
| onActionDone | sideEffects |
|
|
1811
|
-
| preReducer | preEffects |
|
|
1812
|
-
| optimisticReducer | optimisticEffects |
|
|
1813
|
-
| reducer | effects |
|
|
1814
|
-
| errorReducer | errorEffects |
|
|
1815
|
-
| onDone | sideEffects |
|
|
1816
|
-
| onFail | errorSideEffects |
|
|
1817
|
-
| promise | getPromise |
|
|
1818
|
-
| promiseGet | getGetPromise |
|
|
1819
|
-
| successMessage | getSuccessMessage |
|
|
1820
|
-
| errorMessage | getErrorMessage |
|
|
1821
|
-
|
|
1822
|
-
- replace argumtents by action context
|
|
1823
|
-
|
|
1824
|
-
```diff
|
|
1825
|
-
- const actions: StateDecoratorActions<S, A, P> = {
|
|
1826
|
-
+ const actions: StoreActions<S, A, P> = {
|
|
1827
|
-
loadList: {
|
|
1828
|
-
- promise: ([id], s, p, a) => {
|
|
1829
|
-
+ getPromise: ({ s, args: [id], p, a }) => {
|
|
1830
|
-
/* ... */
|
|
1831
|
-
},
|
|
1832
|
-
- reducer: (s, res) => ({
|
|
1833
|
-
+ effects: ({ s, res }) => ({
|
|
1834
|
-
/* ... */
|
|
1835
|
-
}),
|
|
1836
|
-
- errorReducer: (s, err) => ({
|
|
1837
|
-
+ errorEffects: ({ s, err }) => ({
|
|
1838
|
-
/* ... */
|
|
1839
|
-
}),
|
|
1840
|
-
},
|
|
1841
|
-
};
|
|
1842
|
-
```
|
|
1843
|
-
|
|
1844
|
-
#### Options
|
|
1845
|
-
|
|
1846
|
-
##### onMount
|
|
1847
|
-
|
|
1848
|
-
```diff
|
|
1849
|
-
- const options: StateDecoratorOptions<S, A, P> = {
|
|
1850
|
-
- onMount: (actions, props, state) => { /* initial side effects */ }
|
|
1851
|
-
- };
|
|
1852
|
-
|
|
1853
|
-
+ const options: StoreOptions<S, A, P> = {
|
|
1854
|
-
+ onMount: ({state, props, actions}) => { /* initial side effects */ }
|
|
1855
|
-
+} ;
|
|
1856
|
-
```
|
|
1857
|
-
|
|
1858
|
-
##### logEnabled
|
|
1859
|
-
|
|
1860
|
-
```diff
|
|
1861
|
-
- function Container(props: Props) {
|
|
1862
|
-
- const { state, actions } = useStateDecorator(getInitialState, actionsImpl, props, { logEnabled: true });
|
|
1863
|
-
- return <div />;
|
|
1864
|
-
- }
|
|
1865
|
-
|
|
1866
|
-
+ import { logDetailedEffects } from 'state-decorator/middlewares';
|
|
1867
|
-
+
|
|
1868
|
-
+ function Container(props: Props) {
|
|
1869
|
-
+ const { state, actions } = useLocalStore(getInitialState, actionsImpl, props, {}, [logDetailedEffects()]);
|
|
1870
|
-
+ return <div />;
|
|
1871
|
-
+ }
|
|
1872
|
-
```
|
|
1873
|
-
|
|
1874
|
-
##### Props changes
|
|
1875
|
-
|
|
1876
|
-
```diff
|
|
1877
|
-
- const options: StateDecoratorOptions<S, A, P> = {
|
|
1878
|
-
- getPropsRefValues: (p) => [],
|
|
1879
|
-
- onPropsChangeReducer: (s, p, indices) => ({ ...s /* new state */ }),
|
|
1880
|
-
- onPropsChange: (s, p, a, indices) => {
|
|
1881
|
-
- /* side effects */
|
|
1882
|
-
- },
|
|
1883
|
-
- };
|
|
1884
|
-
|
|
1885
|
-
+ const options: StoreOptions<S, A, P> = {
|
|
1886
|
-
+ onPropsChange: {
|
|
1887
|
-
+ getDeps: (p) => [],
|
|
1888
|
-
+ effects: ({ s, p, indices }) => ({ ...s /* new state */ }),
|
|
1889
|
-
+ sideEffects: ({ s, p, a, indices }) => {
|
|
1890
|
-
+ /* side effects */
|
|
1891
|
-
+ },
|
|
1892
|
-
+ },
|
|
1893
|
-
+} ;
|
|
1894
|
-
```
|
|
1895
|
-
|
|
1896
|
-
#### Reuse v5 tests with v6 actions
|
|
1897
|
-
|
|
1898
|
-
```diff
|
|
1899
|
-
- import { testSyncAction, testAsyncAction } from 'state-decorator';
|
|
1900
|
-
|
|
1901
|
-
+ import { testV6SyncAction, testV6AsyncAction } from 'state-decorator/v5_test';
|
|
1902
|
-
```
|
|
1903
|
-
|
|
1904
|
-
### Step 3 (optional): Migrate tests
|
|
1905
|
-
|
|
1906
|
-
🎊 Congratulations! 🎊
|
|
1907
|
-
|
|
1908
1866
|
# Examples
|
|
1909
1867
|
|
|
1910
1868
|
## TodoApp
|
package/development.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
//# sourceMappingURL=development.js.map
|
|
1
|
+
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t,t.exports),e=null),t.exports),s=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},c=/* @__PURE__ */ ((n,r,o)=>(o=n==null?{}:e(i(n)),s(r||!n||!n.__esModule||!a.call(n,`default`)?t(o,`default`,{value:n,enumerable:!0}):o,n)))((/* @__PURE__ */ o(((e,t)=>{t.exports=function e(t,n){if(t===n)return!0;if(t&&n&&typeof t==`object`&&typeof n==`object`){if(t.constructor!==n.constructor)return!1;var r,i,a;if(Array.isArray(t)){if(r=t.length,r!=n.length)return!1;for(i=r;i--!==0;)if(!e(t[i],n[i]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if(a=Object.keys(t),r=a.length,r!==Object.keys(n).length)return!1;for(i=r;i--!==0;)if(!Object.prototype.hasOwnProperty.call(n,a[i]))return!1;for(i=r;i--!==0;){var o=a[i];if(!e(t[o],n[o]))return!1}return!0}return t!==t&&n!==n}})))());let l=null,u=null,d=null;if(process.env.NODE_ENV===`development`||process.env.NODE_ENV===`test`){let e=()=>({init:()=>{},destroy:null,effects:()=>null});l=(e=console.log)=>()=>{let t=e,n=``;return{init:e=>{n=e.options?.name?`[${e.options?.name}]`:``;let r=e.state;t(n,`initialState`,r)},destroy:null,effects:(e,r,i,a)=>(t(n,e.name,e.type,i===null?`no effect`:i,e.isAsync?e.type===`preEffects`&&!a?`Promise cancelled`:`loading: ${a}`:``),null)}},u=(e=console)=>()=>{let t=``,n=e,r=(e,t)=>{let n;if(t!==e){let r=e==null?typeof t:typeof e;if(r===`number`||r===`string`||r===`boolean`)n=`${e} => ${t===``?`""`:t}`;else if(e&&e.length||t&&t.length){if(e==null)n=`was ${e}, now contains ${t.length} element(s)`;else if(t==null)n=`contained ${e.length} element(s), now is ${t}`;else if(e.length===0)n=`was empty, now contains ${t.length} elements`;else if(t.length===0)n=`contained ${e.length} elements, now is empty`;else{let r=t.filter(t=>!e.find(e=>(0,c.default)(t,e))),i=e.filter(e=>!t.find(t=>(0,c.default)(e,t)));r.length>10&&(r=`${r.length} element(s) added`),i.length>10&&(i=`${i.length} element(s) removed`),n={added:r,removed:i}}}else n=t}return n},i=(e,t)=>{let n={};return e&&Object.keys(e).forEach(i=>{if(t.hasOwnProperty(i)){let a=e[i],o=t[i],s=r(a,o);s&&(n[i]=s)}else n[i]=`was deleted`}),Object.keys(t).forEach(i=>{if(e==null||!e.hasOwnProperty(i)){let e=t[i];n[i]=r(void 0,e)}}),n},a=e=>typeof e==`string`?`"${e}"`:e;return{init:r=>{t=r.options?.name?`[${r.options?.name}]`:``;let i=r.state;e.group(t,`initialState`),Object.keys(i).forEach(e=>void n.log(e,`:`,a(i[e]))),e.groupEnd()},destroy:null,effects:(e,r,o,s)=>{let c=e.context?.args,l=[t,e.name.toString()];if(e.isAsync&&(e.type===`preEffects`?l.push(s?`START`:`CANCELLED`):e.type===`effects`?l.push(`DONE`):l.push(`FAILED`)),o==null&&(!c||Object.keys(c).length===0)?n.log(...l):n.group(...l),c&&Object.keys(c).length>0&&(n.group(`Arguments`),c.forEach(e=>void n.log(e,`:`,a(e))),n.groupEnd()),o!=null&&(n.groupCollapsed(`Before`),r==null?n.log(`was null`):Object.keys(r).forEach(e=>void n.log(e,`:`,a(r[e]))),n.groupEnd(),n.groupCollapsed(`After`),o==null?n.log(`was null`):Object.keys(o).forEach(e=>void n.log(e,`:`,a(o[e]))),n.groupEnd(),o!=null)){n.group(`Diff`);let e=i(r,o);Object.keys(e).forEach(t=>n.log(t,`:`,e[t])),n.groupEnd()}return n.groupEnd(),null}}},d=()=>()=>{let t;try{t=window.__REDUX_DEVTOOLS_EXTENSION__||window.top.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!t)return e();let n,r;return{init(e){n=t.connect({name:e.options?.name??`StateDecorator`}),n.init(e.state);let i=null,a=e.state;r=n.subscribe(t=>{if(t.type===`DISPATCH`&&t.state&&t.payload?.type!==`ROLLBACK`){let n=JSON.parse(t.state);e.setState(n)}else t.payload?.type===`COMMIT`?i=e.state:t.payload?.type===`ROLLBACK`?i!=null&&e.setState(i):t.payload?.type===`RESET`&&e.setState(a)})},effects(e,t,r){if(r!=null){let t={...e.context};delete t.a,delete t.s,delete t.p,delete t.res,delete t.err,delete t.ds,n.send({type:`${e.name.toString()} ${e.type}`,args:t.args,context:t},r)}return null},destroy(){r(),n=null}}}}export{d as devtools,u as logDetailedEffects,l as logEffects};
|
|
2
|
+
//# sourceMappingURL=development.js.map
|
package/development.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"development.js","sources":["../node_modules/tslib/tslib.es6.mjs","../node_modules/fast-deep-equal/index.js"],"sourcesContent":["/******************************************************************************\nCopyright (c) Microsoft Corporation.\n\nPermission to use, copy, modify, and/or distribute this software for any\npurpose with or without fee is hereby granted.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\nPERFORMANCE OF THIS SOFTWARE.\n***************************************************************************** */\n/* global Reflect, Promise, SuppressedError, Symbol, Iterator */\n\nvar extendStatics = function(d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\n return extendStatics(d, b);\n};\n\nexport function __extends(d, b) {\n if (typeof b !== \"function\" && b !== null)\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n}\n\nexport var __assign = function() {\n __assign = Object.assign || function __assign(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\n }\n return t;\n }\n return __assign.apply(this, arguments);\n}\n\nexport function __rest(s, e) {\n var t = {};\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\n t[p] = s[p];\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\n t[p[i]] = s[p[i]];\n }\n return t;\n}\n\nexport function __decorate(decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n}\n\nexport function __param(paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n}\n\nexport function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {\n function accept(f) { if (f !== void 0 && typeof f !== \"function\") throw new TypeError(\"Function expected\"); return f; }\n var kind = contextIn.kind, key = kind === \"getter\" ? \"get\" : kind === \"setter\" ? \"set\" : \"value\";\n var target = !descriptorIn && ctor ? contextIn[\"static\"] ? ctor : ctor.prototype : null;\n var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});\n var _, done = false;\n for (var i = decorators.length - 1; i >= 0; i--) {\n var context = {};\n for (var p in contextIn) context[p] = p === \"access\" ? {} : contextIn[p];\n for (var p in contextIn.access) context.access[p] = contextIn.access[p];\n context.addInitializer = function (f) { if (done) throw new TypeError(\"Cannot add initializers after decoration has completed\"); extraInitializers.push(accept(f || null)); };\n var result = (0, decorators[i])(kind === \"accessor\" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);\n if (kind === \"accessor\") {\n if (result === void 0) continue;\n if (result === null || typeof result !== \"object\") throw new TypeError(\"Object expected\");\n if (_ = accept(result.get)) descriptor.get = _;\n if (_ = accept(result.set)) descriptor.set = _;\n if (_ = accept(result.init)) initializers.unshift(_);\n }\n else if (_ = accept(result)) {\n if (kind === \"field\") initializers.unshift(_);\n else descriptor[key] = _;\n }\n }\n if (target) Object.defineProperty(target, contextIn.name, descriptor);\n done = true;\n};\n\nexport function __runInitializers(thisArg, initializers, value) {\n var useValue = arguments.length > 2;\n for (var i = 0; i < initializers.length; i++) {\n value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);\n }\n return useValue ? value : void 0;\n};\n\nexport function __propKey(x) {\n return typeof x === \"symbol\" ? x : \"\".concat(x);\n};\n\nexport function __setFunctionName(f, name, prefix) {\n if (typeof name === \"symbol\") name = name.description ? \"[\".concat(name.description, \"]\") : \"\";\n return Object.defineProperty(f, \"name\", { configurable: true, value: prefix ? \"\".concat(prefix, \" \", name) : name });\n};\n\nexport function __metadata(metadataKey, metadataValue) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\n}\n\nexport function __awaiter(thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n}\n\nexport function __generator(thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === \"function\" ? Iterator : Object).prototype);\n return g.next = verb(0), g[\"throw\"] = verb(1), g[\"return\"] = verb(2), typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n}\n\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n var desc = Object.getOwnPropertyDescriptor(m, k);\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\n desc = { enumerable: true, get: function() { return m[k]; } };\n }\n Object.defineProperty(o, k2, desc);\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n});\n\nexport function __exportStar(m, o) {\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\n}\n\nexport function __values(o) {\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\n if (m) return m.call(o);\n if (o && typeof o.length === \"number\") return {\n next: function () {\n if (o && i >= o.length) o = void 0;\n return { value: o && o[i++], done: !o };\n }\n };\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\n}\n\nexport function __read(o, n) {\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\n if (!m) return o;\n var i = m.call(o), r, ar = [], e;\n try {\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\n }\n catch (error) { e = { error: error }; }\n finally {\n try {\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\n }\n finally { if (e) throw e.error; }\n }\n return ar;\n}\n\n/** @deprecated */\nexport function __spread() {\n for (var ar = [], i = 0; i < arguments.length; i++)\n ar = ar.concat(__read(arguments[i]));\n return ar;\n}\n\n/** @deprecated */\nexport function __spreadArrays() {\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\n r[k] = a[j];\n return r;\n}\n\nexport function __spreadArray(to, from, pack) {\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\n if (ar || !(i in from)) {\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\n ar[i] = from[i];\n }\n }\n return to.concat(ar || Array.prototype.slice.call(from));\n}\n\nexport function __await(v) {\n return this instanceof __await ? (this.v = v, this) : new __await(v);\n}\n\nexport function __asyncGenerator(thisArg, _arguments, generator) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\n return i = Object.create((typeof AsyncIterator === \"function\" ? AsyncIterator : Object).prototype), verb(\"next\"), verb(\"throw\"), verb(\"return\", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;\n function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }\n function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\n function fulfill(value) { resume(\"next\", value); }\n function reject(value) { resume(\"throw\", value); }\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\n}\n\nexport function __asyncDelegator(o) {\n var i, p;\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }\n}\n\nexport function __asyncValues(o) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var m = o[Symbol.asyncIterator], i;\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\n}\n\nexport function __makeTemplateObject(cooked, raw) {\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\n return cooked;\n};\n\nvar __setModuleDefault = Object.create ? (function(o, v) {\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\n}) : function(o, v) {\n o[\"default\"] = v;\n};\n\nvar ownKeys = function(o) {\n ownKeys = Object.getOwnPropertyNames || function (o) {\n var ar = [];\n for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;\n return ar;\n };\n return ownKeys(o);\n};\n\nexport function __importStar(mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== \"default\") __createBinding(result, mod, k[i]);\n __setModuleDefault(result, mod);\n return result;\n}\n\nexport function __importDefault(mod) {\n return (mod && mod.__esModule) ? mod : { default: mod };\n}\n\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\n}\n\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\n}\n\nexport function __classPrivateFieldIn(state, receiver) {\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\n}\n\nexport function __addDisposableResource(env, value, async) {\n if (value !== null && value !== void 0) {\n if (typeof value !== \"object\" && typeof value !== \"function\") throw new TypeError(\"Object expected.\");\n var dispose, inner;\n if (async) {\n if (!Symbol.asyncDispose) throw new TypeError(\"Symbol.asyncDispose is not defined.\");\n dispose = value[Symbol.asyncDispose];\n }\n if (dispose === void 0) {\n if (!Symbol.dispose) throw new TypeError(\"Symbol.dispose is not defined.\");\n dispose = value[Symbol.dispose];\n if (async) inner = dispose;\n }\n if (typeof dispose !== \"function\") throw new TypeError(\"Object not disposable.\");\n if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };\n env.stack.push({ value: value, dispose: dispose, async: async });\n }\n else if (async) {\n env.stack.push({ async: true });\n }\n return value;\n}\n\nvar _SuppressedError = typeof SuppressedError === \"function\" ? SuppressedError : function (error, suppressed, message) {\n var e = new Error(message);\n return e.name = \"SuppressedError\", e.error = error, e.suppressed = suppressed, e;\n};\n\nexport function __disposeResources(env) {\n function fail(e) {\n env.error = env.hasError ? new _SuppressedError(e, env.error, \"An error was suppressed during disposal.\") : e;\n env.hasError = true;\n }\n var r, s = 0;\n function next() {\n while (r = env.stack.pop()) {\n try {\n if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);\n if (r.dispose) {\n var result = r.dispose.call(r.value);\n if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });\n }\n else s |= 1;\n }\n catch (e) {\n fail(e);\n }\n }\n if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();\n if (env.hasError) throw env.error;\n }\n return next();\n}\n\nexport function __rewriteRelativeImportExtension(path, preserveJsx) {\n if (typeof path === \"string\" && /^\\.\\.?\\//.test(path)) {\n return path.replace(/\\.(tsx)$|((?:\\.d)?)((?:\\.[^./]+?)?)\\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {\n return tsx ? preserveJsx ? \".jsx\" : \".js\" : d && (!ext || !cm) ? m : (d + ext + \".\" + cm.toLowerCase() + \"js\");\n });\n }\n return path;\n}\n\nexport default {\n __extends,\n __assign,\n __rest,\n __decorate,\n __param,\n __esDecorate,\n __runInitializers,\n __propKey,\n __setFunctionName,\n __metadata,\n __awaiter,\n __generator,\n __createBinding,\n __exportStar,\n __values,\n __read,\n __spread,\n __spreadArrays,\n __spreadArray,\n __await,\n __asyncGenerator,\n __asyncDelegator,\n __asyncValues,\n __makeTemplateObject,\n __importStar,\n __importDefault,\n __classPrivateFieldGet,\n __classPrivateFieldSet,\n __classPrivateFieldIn,\n __addDisposableResource,\n __disposeResources,\n __rewriteRelativeImportExtension,\n};\n","'use strict';\n\n// do not edit .js files directly - edit src/index.jst\n\n\n\nmodule.exports = function equal(a, b) {\n if (a === b) return true;\n\n if (a && b && typeof a == 'object' && typeof b == 'object') {\n if (a.constructor !== b.constructor) return false;\n\n var length, i, keys;\n if (Array.isArray(a)) {\n length = a.length;\n if (length != b.length) return false;\n for (i = length; i-- !== 0;)\n if (!equal(a[i], b[i])) return false;\n return true;\n }\n\n\n\n if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags;\n if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf();\n if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();\n\n keys = Object.keys(a);\n length = keys.length;\n if (length !== Object.keys(b).length) return false;\n\n for (i = length; i-- !== 0;)\n if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;\n\n for (i = length; i-- !== 0;) {\n var key = keys[i];\n\n if (!equal(a[key], b[key])) return false;\n }\n\n return true;\n }\n\n // true if both NaN, false otherwise\n return a!==a && b!==b;\n};\n"],"names":["__assign","Object","assign","t","s","i","n","arguments","length","p","prototype","hasOwnProperty","call","apply","this","SuppressedError","equal","a","b","constructor","keys","Array","isArray","RegExp","source","flags","valueOf","toString","key"],"mappings":"oEA+BO,IAAIA,EAAW,WAQpB,OAPAA,EAAWC,OAAOC,QAAU,SAAkBC,GAC1C,IAAK,IAAIC,EAAGC,EAAI,EAAGC,EAAIC,UAAUC,OAAQH,EAAIC,EAAGD,IAE5C,IAAK,IAAII,KADTL,EAAIG,UAAUF,GACOJ,OAAOS,UAAUC,eAAeC,KAAKR,EAAGK,KAAIN,EAAEM,GAAKL,EAAEK,IAE9E,OAAON,CACV,EACMH,EAASa,MAAMC,KAAMP,UAC9B,EA+RkD,mBAApBQ,iBAAiCA,gBCjU/D,MAAiB,SAASC,EAAMC,EAAGC,GACjC,GAAID,IAAMC,EAAG,OAAO,EAEpB,GAAID,GAAKC,GAAiB,iBAALD,GAA6B,iBAALC,EAAe,CAC1D,GAAID,EAAEE,cAAgBD,EAAEC,YAAa,OAAO,EAE5C,IAAIX,EAAQH,EAAGe,EACf,GAAIC,MAAMC,QAAQL,GAAI,CAEpB,IADAT,EAASS,EAAET,SACGU,EAAEV,OAAQ,OAAO,EAC/B,IAAKH,EAAIG,EAAgB,GAARH,KACf,IAAKW,EAAMC,EAAEZ,GAAIa,EAAEb,IAAK,OAAO,EACjC,OAAO,CACR,CAID,GAAIY,EAAEE,cAAgBI,OAAQ,OAAON,EAAEO,SAAWN,EAAEM,QAAUP,EAAEQ,QAAUP,EAAEO,MAC5E,GAAIR,EAAES,UAAYzB,OAAOS,UAAUgB,QAAS,OAAOT,EAAES,YAAcR,EAAEQ,UACrE,GAAIT,EAAEU,WAAa1B,OAAOS,UAAUiB,SAAU,OAAOV,EAAEU,aAAeT,EAAES,WAIxE,IADAnB,GADAY,EAAOnB,OAAOmB,KAAKH,IACLT,UACCP,OAAOmB,KAAKF,GAAGV,OAAQ,OAAO,EAE7C,IAAKH,EAAIG,EAAgB,GAARH,KACf,IAAKJ,OAAOS,UAAUC,eAAeC,KAAKM,EAAGE,EAAKf,IAAK,OAAO,EAEhE,IAAKA,EAAIG,EAAgB,GAARH,KAAY,CAC3B,IAAIuB,EAAMR,EAAKf,GAEf,IAAKW,EAAMC,EAAEW,GAAMV,EAAEU,IAAO,OAAO,CACpC,CAED,OAAO,CACR,CAGD,OAAOX,GAAIA,GAAKC,GAAIA,CACtB"}
|
|
1
|
+
{"version":3,"file":"development.js","names":["isEqual","__create","__defProp","__getOwnPropDesc","__getOwnPropNames","__getProtoOf","__hasOwnProp","__commonJSMin","cb","mod","__copyProps","to","from","except","desc","keys","i","n","key","k","import_fast_deep_equal","isNodeMode","target","exports","module","equal","a","b","length","logEffects","logDetailedEffects","devtools","getNoopMiddleware","log","logger","storeName","storeContext","newState","action","_oldState","loading","console","computeDiffPropValue","oldValue","newValue","res","type","addedValues","removedValues","buildDiff","oldState","diff","getStr","v","prop","args","params","arg","extension","unsubscribe","savedState","initialState","message","ctx","cleanCtx"],"sources":["../node_modules/fast-deep-equal/index.js","../src/development.ts"],"sourcesContent":["'use strict';\n\n// do not edit .js files directly - edit src/index.jst\n\n\n\nmodule.exports = function equal(a, b) {\n if (a === b) return true;\n\n if (a && b && typeof a == 'object' && typeof b == 'object') {\n if (a.constructor !== b.constructor) return false;\n\n var length, i, keys;\n if (Array.isArray(a)) {\n length = a.length;\n if (length != b.length) return false;\n for (i = length; i-- !== 0;)\n if (!equal(a[i], b[i])) return false;\n return true;\n }\n\n\n\n if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags;\n if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf();\n if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();\n\n keys = Object.keys(a);\n length = keys.length;\n if (length !== Object.keys(b).length) return false;\n\n for (i = length; i-- !== 0;)\n if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;\n\n for (i = length; i-- !== 0;) {\n var key = keys[i];\n\n if (!equal(a[key], b[key])) return false;\n }\n\n return true;\n }\n\n // true if both NaN, false otherwise\n return a!==a && b!==b;\n};\n","/* ! *****************************************************************************\nCopyright (c) GlobalSport SAS.\n\nPermission to use, copy, modify, and/or distribute this software for any\npurpose with or without fee is hereby granted.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\nPERFORMANCE OF THIS SOFTWARE.\n***************************************************************************** */\n\nimport type { DecoratedActions, Middleware, MiddlewareFactory } from './types';\nimport isEqual from 'fast-deep-equal';\n\nexport type Logger = {\n log: (...args: any[]) => void;\n group: (...args: any[]) => void;\n groupCollapsed: (...args: any[]) => void;\n groupEnd: (...args: any[]) => void;\n};\n\nexport let logEffects: <S, A extends DecoratedActions, P>(\n log?: (...msg: any[]) => void\n) => MiddlewareFactory<S, A, P> = null;\n\nexport let logDetailedEffects: <S, A extends DecoratedActions, P>(logger?: Logger) => MiddlewareFactory<S, A, P> = null;\n\nexport let devtools: <S, A extends DecoratedActions, P>() => MiddlewareFactory<S, A, P> = null;\n\n// @ts-ignore\nif (process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'test') {\n const getNoopMiddleware = <S, A extends DecoratedActions, P>(): Middleware<S, A, P> => {\n const middleware: Middleware<S, A, P> = {\n init: () => {},\n destroy: null,\n effects: () => null,\n };\n\n return middleware;\n };\n\n logEffects = <S, A extends DecoratedActions, P>(\n log: (...msg: any[]) => void = console.log\n ): MiddlewareFactory<S, A, P> => {\n const f = () => {\n const logger = log;\n let storeName = '';\n\n const middleware: Middleware<S, A, P> = {\n init: (storeContext) => {\n storeName = storeContext.options?.name ? `[${storeContext.options?.name}]` : '';\n const newState = storeContext.state;\n logger(storeName, 'initialState', newState);\n },\n destroy: null,\n effects: (action, _oldState, newState, loading: boolean) => {\n logger(\n storeName,\n action.name,\n action.type,\n newState === null ? 'no effect' : newState,\n action.isAsync\n ? action.type === 'preEffects' && !loading\n ? 'Promise cancelled'\n : `loading: ${loading}`\n : ''\n );\n return null;\n },\n };\n return middleware;\n };\n\n return f;\n };\n\n logDetailedEffects = <S, A extends DecoratedActions, P>(logger: Logger = console): MiddlewareFactory<S, A, P> => {\n return () => {\n let storeName = '';\n\n const console = logger;\n\n const computeDiffPropValue = (oldValue: any, newValue: any) => {\n let res: any;\n if (newValue !== oldValue) {\n const type = oldValue != null ? typeof oldValue : typeof newValue;\n if (type === 'number' || type === 'string' || type === 'boolean') {\n res = `${oldValue} => ${newValue === '' ? '\"\"' : newValue}`;\n } else if ((oldValue && oldValue.length) || (newValue && newValue.length)) {\n if (oldValue == null) {\n res = `was ${oldValue}, now contains ${newValue.length} element(s)`;\n } else if (newValue == null) {\n res = `contained ${oldValue.length} element(s), now is ${newValue}`;\n } else if (oldValue.length === 0) {\n res = `was empty, now contains ${newValue.length} elements`;\n } else if (newValue.length === 0) {\n res = `contained ${oldValue.length} elements, now is empty`;\n } else {\n let addedValues = newValue.filter((a: any) => !oldValue.find((b: any) => isEqual(a, b)));\n let removedValues = oldValue.filter((a: any) => !newValue.find((b: any) => isEqual(a, b)));\n\n if (addedValues.length > 10) {\n addedValues = `${addedValues.length} element(s) added`;\n }\n if (removedValues.length > 10) {\n removedValues = `${removedValues.length} element(s) removed`;\n }\n res = {\n added: addedValues,\n removed: removedValues,\n };\n }\n } else {\n res = newValue;\n }\n }\n return res;\n };\n\n const buildDiff = <S>(oldState: S, newState: S) => {\n const res: Record<string, any> = {};\n\n if (oldState) {\n const keys = Object.keys(oldState) as (keyof S)[];\n keys.forEach((k) => {\n if (newState.hasOwnProperty(k)) {\n const oldValue = oldState[k];\n const newValue = newState[k];\n const diff = computeDiffPropValue(oldValue, newValue);\n if (diff) {\n res[k as any] = diff;\n }\n } else {\n res[k as any] = 'was deleted';\n }\n });\n }\n\n const keys = Object.keys(newState) as (keyof S)[];\n keys.forEach((k) => {\n if (oldState == null || !oldState.hasOwnProperty(k)) {\n const newValue = newState[k];\n\n res[k as any] = computeDiffPropValue(undefined, newValue);\n }\n });\n\n return res;\n };\n\n const getStr = (v: any) => {\n if (typeof v === 'string') {\n return `\"${v}\"`;\n }\n return v;\n };\n\n const middleware: Middleware<S, A, P> = {\n init: (storeContext) => {\n storeName = storeContext.options?.name ? `[${storeContext.options?.name}]` : '';\n const newState = storeContext.state;\n logger.group(storeName, 'initialState');\n const keys = Object.keys(newState) as (keyof S)[];\n keys.forEach((prop) => void console.log(prop, ':', getStr(newState[prop])));\n logger.groupEnd();\n },\n destroy: null,\n effects: (action, oldState, newState, loading) => {\n const args: any[] = action.context?.args;\n\n const params: string[] = [storeName, action.name.toString()];\n\n if (action.isAsync) {\n if (action.type === 'preEffects') {\n params.push(loading ? 'START' : 'CANCELLED');\n } else if (action.type === 'effects') {\n params.push('DONE');\n } else {\n params.push('FAILED');\n }\n }\n\n if (newState == null && (!args || Object.keys(args).length === 0)) {\n console.log(...params);\n } else {\n console.group(...params);\n }\n\n if (args && Object.keys(args).length > 0) {\n console.group('Arguments');\n args.forEach((arg) => void console.log(arg, ':', getStr(arg)));\n console.groupEnd();\n }\n\n if (newState != null) {\n console.groupCollapsed('Before');\n if (oldState == null) {\n console.log('was null');\n } else {\n const keys = Object.keys(oldState) as (keyof S)[];\n keys.forEach((prop) => void console.log(prop, ':', getStr(oldState[prop])));\n }\n console.groupEnd();\n\n console.groupCollapsed('After');\n if (newState == null) {\n console.log('was null');\n } else {\n const keys = Object.keys(newState) as (keyof S)[];\n keys.forEach((prop) => void console.log(prop, ':', getStr(newState[prop])));\n }\n console.groupEnd();\n\n if (newState != null) {\n console.group('Diff');\n const diff = buildDiff(oldState, newState);\n Object.keys(diff).forEach((prop) => console.log(prop, ':', diff[prop]));\n console.groupEnd();\n }\n }\n //\n console.groupEnd();\n\n return null;\n },\n };\n return middleware;\n };\n };\n\n devtools = <S, A extends DecoratedActions, P>(): MiddlewareFactory<S, A, P> => {\n const getMiddleware = () => {\n let extension: any;\n try {\n extension = (window as any).__REDUX_DEVTOOLS_EXTENSION__ || (window as any).top.__REDUX_DEVTOOLS_EXTENSION__;\n } catch {}\n\n if (!extension) {\n return getNoopMiddleware<S, A, P>();\n }\n\n let devtools: any;\n let unsubscribe: () => void;\n\n const middleware: Middleware<S, A, P> = {\n init(storeContext) {\n devtools = extension.connect({ name: storeContext.options?.name ?? 'StateDecorator' });\n devtools.init(storeContext.state);\n let savedState: S = null;\n const initialState: S = storeContext.state;\n\n unsubscribe = devtools.subscribe((message: any) => {\n if (message.type === 'DISPATCH' && message.state && message.payload?.type !== 'ROLLBACK') {\n const newState = JSON.parse(message.state);\n storeContext.setState(newState);\n } else if (message.payload?.type === 'COMMIT') {\n savedState = storeContext.state;\n } else if (message.payload?.type === 'ROLLBACK') {\n if (savedState != null) {\n storeContext.setState(savedState);\n }\n } else if (message.payload?.type === 'RESET') {\n storeContext.setState(initialState);\n }\n });\n },\n\n effects(ctx, _oldState, newState) {\n if (newState != null) {\n const cleanCtx: any = {\n ...ctx.context,\n };\n\n delete cleanCtx.a;\n delete cleanCtx.s;\n delete cleanCtx.p;\n delete cleanCtx.res;\n delete cleanCtx.err;\n delete cleanCtx.ds;\n\n devtools.send(\n {\n type: `${ctx.name.toString()} ${ctx.type}`,\n args: cleanCtx.args,\n context: cleanCtx,\n },\n newState\n );\n }\n\n return null; // no op on state\n },\n\n destroy() {\n unsubscribe();\n devtools = null;\n },\n };\n\n return middleware;\n };\n\n return getMiddleware;\n };\n}\n"],"ignoreList":[0],"mappings":"A,+mBAMAwB,EAAO,QAAU,SAASC,EAAMC,EAAGC,EAAG,CACpC,GAAID,IAAMC,EAAG,MAAO,GAEpB,GAAID,GAAKC,GAAK,OAAOD,GAAK,UAAY,OAAOC,GAAK,SAAU,CAC1D,GAAID,EAAE,cAAgBC,EAAE,YAAa,MAAO,GAE5C,IAAIC,EAAQ,EAAGb,EACf,GAAI,MAAM,QAAQW,CAAC,EAAG,CAEpB,GADAE,EAASF,EAAE,OACPE,GAAUD,EAAE,OAAQ,MAAO,GAC/B,IAAK,EAAIC,EAAQ,MAAQ,GACvB,GAAI,CAACH,EAAMC,EAAE,GAAIC,EAAE,EAAE,EAAG,MAAO,GACjC,MAAO,EACT,CAIA,GAAID,EAAE,cAAgB,OAAQ,OAAOA,EAAE,SAAWC,EAAE,QAAUD,EAAE,QAAUC,EAAE,MAC5E,GAAID,EAAE,UAAY,OAAO,UAAU,QAAS,OAAOA,EAAE,QAAQ,IAAMC,EAAE,QAAQ,EAC7E,GAAID,EAAE,WAAa,OAAO,UAAU,SAAU,OAAOA,EAAE,SAAS,IAAMC,EAAE,SAAS,EAIjF,GAFAZ,EAAO,OAAO,KAAKW,CAAC,EACpBE,EAASb,EAAK,OACVa,IAAW,OAAO,KAAKD,CAAC,CAAC,CAAC,OAAQ,MAAO,GAE7C,IAAK,EAAIC,EAAQ,MAAQ,GACvB,GAAI,CAAC,OAAO,UAAU,eAAe,KAAKD,EAAGZ,EAAK,EAAE,EAAG,MAAO,GAEhE,IAAK,EAAIa,EAAQ,MAAQ,GAAI,CAC3B,IAAIV,EAAMH,EAAK,GAEf,GAAI,CAACU,EAAMC,EAAER,GAAMS,EAAET,EAAI,EAAG,MAAO,EACrC,CAEA,MAAO,EACT,CAGA,OAAOQ,IAAIA,GAAKC,IAAIA,CACtB,C,QCpBA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EAAS,KACf,QAASA,CACX,EACA3B,CACF,CACF,CAEA,OAAO,IACT,EAEA,SAAU,CACRsB,EAAY,EACZ5B,EAAW,IACb,CAGc,CAClB,CAIJ,C"}
|
package/helpers.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
//# sourceMappingURL=helpers.js.map
|
|
1
|
+
function e(e,t){return t&&(e[t]=!0),e}function t(t,n){return({s:r,args:[i]})=>r[t]===i?null:e({[t]:i},n)}function n(t,n){return({s:r})=>r[t]?null:e({[t]:!0},n)}function r(t,n){return({s:r})=>r[t]?e({[t]:!1},n):null}function i(t,n){return({s:r})=>e({[t]:!r[t]},n)}function a(t,n){return({s:r,args:[i,a]})=>e({[t]:{...r[t],[i]:a}},n)}function o(t,n){return({s:r,args:[i,a]})=>{let o=[...r[t]];return o[i]=a,e({[t]:o},n)}}function s(t,n){return({res:r})=>e({[t]:r},n)}function c(t,n){return({s:r,args:[i],res:a})=>{let o=[...r[t]];return o[i]=a,e({[t]:o},n)}}function l(t,n){return({s:r,args:[i],res:a})=>e({[t]:{...r[t],[i]:a}},n)}export{t as setArgIn,o as setArgsInArray,a as setArgsInMap,r as setFalseIn,s as setResIn,c as setResInArray,l as setResInMap,n as setTrueIn,i as toggleProp};
|
|
2
|
+
//# sourceMappingURL=helpers.js.map
|