@elementor/store 0.8.1 → 0.8.3
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 +16 -0
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/index.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,22 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [0.8.3](https://github.com/elementor/elementor-packages/compare/@elementor/store@0.8.2...@elementor/store@0.8.3) (2024-07-03)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @elementor/store
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [0.8.2](https://github.com/elementor/elementor-packages/compare/@elementor/store@0.8.1...@elementor/store@0.8.2) (2024-04-16)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @elementor/store
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
6
22
|
## [0.8.1](https://github.com/elementor/elementor-packages/compare/@elementor/store@0.8.0...@elementor/store@0.8.1) (2024-02-28)
|
|
7
23
|
|
|
8
24
|
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as _reduxjs_toolkit_dist_configureStore from '@reduxjs/toolkit/dist/configureStore';
|
|
2
2
|
import * as redux from 'redux';
|
|
3
3
|
import { Slice, Middleware, AnyAction, ThunkMiddleware } from '@reduxjs/toolkit';
|
|
4
|
-
export { Action, AnyAction, CreateSliceOptions, Dispatch, Middleware, MiddlewareAPI, PayloadAction, Slice, Store, createAsyncThunk as __createAsyncThunk, createSelector as __createSelector, createSlice as __createSlice } from '@reduxjs/toolkit';
|
|
4
|
+
export { Action, AnyAction, CreateSliceOptions, Dispatch, Middleware, MiddlewareAPI, PayloadAction, Slice, Store, createAction as __createAction, createAsyncThunk as __createAsyncThunk, createSelector as __createSelector, createSlice as __createSlice } from '@reduxjs/toolkit';
|
|
5
5
|
export { Provider as __StoreProvider, useDispatch as __useDispatch, useSelector as __useSelector } from 'react-redux';
|
|
6
6
|
|
|
7
7
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as _reduxjs_toolkit_dist_configureStore from '@reduxjs/toolkit/dist/configureStore';
|
|
2
2
|
import * as redux from 'redux';
|
|
3
3
|
import { Slice, Middleware, AnyAction, ThunkMiddleware } from '@reduxjs/toolkit';
|
|
4
|
-
export { Action, AnyAction, CreateSliceOptions, Dispatch, Middleware, MiddlewareAPI, PayloadAction, Slice, Store, createAsyncThunk as __createAsyncThunk, createSelector as __createSelector, createSlice as __createSlice } from '@reduxjs/toolkit';
|
|
4
|
+
export { Action, AnyAction, CreateSliceOptions, Dispatch, Middleware, MiddlewareAPI, PayloadAction, Slice, Store, createAction as __createAction, createAsyncThunk as __createAsyncThunk, createSelector as __createSelector, createSlice as __createSlice } from '@reduxjs/toolkit';
|
|
5
5
|
export { Provider as __StoreProvider, useDispatch as __useDispatch, useSelector as __useSelector } from 'react-redux';
|
|
6
6
|
|
|
7
7
|
/**
|
package/dist/index.js
CHANGED
|
@@ -22,6 +22,7 @@ var src_exports = {};
|
|
|
22
22
|
__export(src_exports, {
|
|
23
23
|
__StoreProvider: () => import_react_redux.Provider,
|
|
24
24
|
__addMiddleware: () => addMiddleware,
|
|
25
|
+
__createAction: () => import_toolkit2.createAction,
|
|
25
26
|
__createAsyncThunk: () => import_toolkit2.createAsyncThunk,
|
|
26
27
|
__createSelector: () => import_toolkit2.createSelector,
|
|
27
28
|
__createSlice: () => import_toolkit2.createSlice,
|
|
@@ -110,6 +111,7 @@ var deleteStore = () => {
|
|
|
110
111
|
0 && (module.exports = {
|
|
111
112
|
__StoreProvider,
|
|
112
113
|
__addMiddleware,
|
|
114
|
+
__createAction,
|
|
113
115
|
__createAsyncThunk,
|
|
114
116
|
__createSelector,
|
|
115
117
|
__createSlice,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import {\n\tReducersMapObject,\n\tconfigureStore,\n\tcombineReducers,\n\tMiddleware,\n\tSlice,\n\tAnyAction,\n\tEnhancedStore,\n\tStoreEnhancer,\n\tThunkMiddleware,\n} from '@reduxjs/toolkit';\n\nexport type {\n\tSlice,\n\tCreateSliceOptions,\n\tPayloadAction,\n\tStore,\n\tDispatch,\n\tAnyAction,\n\tAction,\n\tMiddlewareAPI,\n\tMiddleware,\n} from '@reduxjs/toolkit';\n\nexport {\n\tcreateSelector as __createSelector,\n\tcreateSlice as __createSlice,\n\tcreateAsyncThunk as __createAsyncThunk,\n} from '@reduxjs/toolkit';\n\nexport {\n\tuseSelector as __useSelector,\n\tuseDispatch as __useDispatch,\n\tProvider as __StoreProvider,\n} from 'react-redux';\n\n/**\n * Usage:\n *\n * const mySlice = addSlice( ... );\n *\n * type MySliceState = SliceState<typeof mySlice>;\n *\n * const value = useSelector( ( state: MySliceState ) => state.mySlice.value );\n */\nexport type SliceState<S extends Slice> = {\n\t[ key in S['name'] ]: ReturnType<S['getInitialState']>;\n}\n\n// The `configureStore` function from Redux Toolkit infers its actions from the `reducers`\n// key of the initialization object. This is fine when creating the store statically, but\n// breaks in our case since we create the store dynamically, which means that TypeScript\n// can't infer the types. Therefore, we force the store to accept any actions using a\n// generic store type.\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype AnyStore<State = any> = EnhancedStore<\n\tState,\n\tAnyAction,\n\t[ThunkMiddleware<State, AnyAction>],\n\t[StoreEnhancer]\n>\n\ninterface SlicesMap {\n\t[key: Slice['name']]: Slice;\n}\n\nlet instance: AnyStore | null = null;\nlet slices: SlicesMap = {};\nconst pendingActions: AnyAction[] = [];\nconst middlewares = new Set<Middleware>();\n\nconst getReducers = () => {\n\tconst reducers = Object.entries( slices ).reduce( ( reducersData: ReducersMapObject, [ name, slice ] ) => {\n\t\treducersData[ name ] = slice.reducer;\n\n\t\treturn reducersData;\n\t}, {} );\n\n\treturn combineReducers( reducers );\n};\n\nfunction registerSlice( slice: Slice ) {\n\tif ( slices[ slice.name ] ) {\n\t\tthrow new Error( `Slice with name \"${ slice.name }\" already exists.` );\n\t}\n\n\tslices[ slice.name ] = slice;\n}\n\nconst addMiddleware = ( middleware: Middleware ) => {\n\tmiddlewares.add( middleware );\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any -- See the comment above about `AnyStore`\nconst dispatch = ( action: any ) => {\n\tif ( ! instance ) {\n\t\tpendingActions.push( action );\n\n\t\treturn;\n\t}\n\n\treturn instance.dispatch( action );\n};\n\nconst getState = () => {\n\tif ( ! instance ) {\n\t\tthrow new Error( 'The store instance does not exist.' );\n\t}\n\n\treturn instance.getState();\n};\n\nconst subscribe = ( listener: () => void ) => {\n\tif ( ! instance ) {\n\t\tthrow new Error( 'The store instance does not exist.' );\n\t}\n\n\treturn instance.subscribe( listener );\n};\n\nconst createStore = () => {\n\tif ( instance ) {\n\t\tthrow new Error( 'The store instance already exists.' );\n\t}\n\n\tinstance = configureStore( {\n\t\treducer: getReducers(),\n\t\tmiddleware: ( getDefaultMiddleware ) => {\n\t\t\treturn [\n\t\t\t\t...getDefaultMiddleware(),\n\t\t\t\t...Array.from( middlewares ),\n\t\t\t];\n\t\t},\n\t} );\n\n\tif ( pendingActions.length ) {\n\t\tpendingActions.forEach( ( action ) => dispatch( action ) );\n\t\tpendingActions.length = 0;\n\t}\n\n\treturn instance as AnyStore;\n};\n\nconst getStore = () => {\n\treturn instance;\n};\n\nconst deleteStore = () => {\n\tinstance = null;\n\tslices = {};\n\tpendingActions.length = 0;\n\tmiddlewares.clear();\n};\n\nexport {\n\tregisterSlice as __registerSlice,\n\taddMiddleware as __addMiddleware,\n\tdispatch as __dispatch,\n\tgetState as __getState,\n\tsubscribe as __subscribe,\n\tcreateStore as __createStore,\n\tgetStore as __getStore,\n\tdeleteStore as __deleteStore,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAUO;AAcP,IAAAA,
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import {\n\tReducersMapObject,\n\tconfigureStore,\n\tcombineReducers,\n\tMiddleware,\n\tSlice,\n\tAnyAction,\n\tEnhancedStore,\n\tStoreEnhancer,\n\tThunkMiddleware,\n} from '@reduxjs/toolkit';\n\nexport type {\n\tSlice,\n\tCreateSliceOptions,\n\tPayloadAction,\n\tStore,\n\tDispatch,\n\tAnyAction,\n\tAction,\n\tMiddlewareAPI,\n\tMiddleware,\n} from '@reduxjs/toolkit';\n\nexport {\n\tcreateSelector as __createSelector,\n\tcreateSlice as __createSlice,\n\tcreateAsyncThunk as __createAsyncThunk,\n\tcreateAction as __createAction,\n} from '@reduxjs/toolkit';\n\nexport {\n\tuseSelector as __useSelector,\n\tuseDispatch as __useDispatch,\n\tProvider as __StoreProvider,\n} from 'react-redux';\n\n/**\n * Usage:\n *\n * const mySlice = addSlice( ... );\n *\n * type MySliceState = SliceState<typeof mySlice>;\n *\n * const value = useSelector( ( state: MySliceState ) => state.mySlice.value );\n */\nexport type SliceState<S extends Slice> = {\n\t[ key in S['name'] ]: ReturnType<S['getInitialState']>;\n}\n\n// The `configureStore` function from Redux Toolkit infers its actions from the `reducers`\n// key of the initialization object. This is fine when creating the store statically, but\n// breaks in our case since we create the store dynamically, which means that TypeScript\n// can't infer the types. Therefore, we force the store to accept any actions using a\n// generic store type.\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype AnyStore<State = any> = EnhancedStore<\n\tState,\n\tAnyAction,\n\t[ThunkMiddleware<State, AnyAction>],\n\t[StoreEnhancer]\n>\n\ninterface SlicesMap {\n\t[key: Slice['name']]: Slice;\n}\n\nlet instance: AnyStore | null = null;\nlet slices: SlicesMap = {};\nconst pendingActions: AnyAction[] = [];\nconst middlewares = new Set<Middleware>();\n\nconst getReducers = () => {\n\tconst reducers = Object.entries( slices ).reduce( ( reducersData: ReducersMapObject, [ name, slice ] ) => {\n\t\treducersData[ name ] = slice.reducer;\n\n\t\treturn reducersData;\n\t}, {} );\n\n\treturn combineReducers( reducers );\n};\n\nfunction registerSlice( slice: Slice ) {\n\tif ( slices[ slice.name ] ) {\n\t\tthrow new Error( `Slice with name \"${ slice.name }\" already exists.` );\n\t}\n\n\tslices[ slice.name ] = slice;\n}\n\nconst addMiddleware = ( middleware: Middleware ) => {\n\tmiddlewares.add( middleware );\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any -- See the comment above about `AnyStore`\nconst dispatch = ( action: any ) => {\n\tif ( ! instance ) {\n\t\tpendingActions.push( action );\n\n\t\treturn;\n\t}\n\n\treturn instance.dispatch( action );\n};\n\nconst getState = () => {\n\tif ( ! instance ) {\n\t\tthrow new Error( 'The store instance does not exist.' );\n\t}\n\n\treturn instance.getState();\n};\n\nconst subscribe = ( listener: () => void ) => {\n\tif ( ! instance ) {\n\t\tthrow new Error( 'The store instance does not exist.' );\n\t}\n\n\treturn instance.subscribe( listener );\n};\n\nconst createStore = () => {\n\tif ( instance ) {\n\t\tthrow new Error( 'The store instance already exists.' );\n\t}\n\n\tinstance = configureStore( {\n\t\treducer: getReducers(),\n\t\tmiddleware: ( getDefaultMiddleware ) => {\n\t\t\treturn [\n\t\t\t\t...getDefaultMiddleware(),\n\t\t\t\t...Array.from( middlewares ),\n\t\t\t];\n\t\t},\n\t} );\n\n\tif ( pendingActions.length ) {\n\t\tpendingActions.forEach( ( action ) => dispatch( action ) );\n\t\tpendingActions.length = 0;\n\t}\n\n\treturn instance as AnyStore;\n};\n\nconst getStore = () => {\n\treturn instance;\n};\n\nconst deleteStore = () => {\n\tinstance = null;\n\tslices = {};\n\tpendingActions.length = 0;\n\tmiddlewares.clear();\n};\n\nexport {\n\tregisterSlice as __registerSlice,\n\taddMiddleware as __addMiddleware,\n\tdispatch as __dispatch,\n\tgetState as __getState,\n\tsubscribe as __subscribe,\n\tcreateStore as __createStore,\n\tgetStore as __getStore,\n\tdeleteStore as __deleteStore,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAUO;AAcP,IAAAA,kBAKO;AAEP,yBAIO;AAiCP,IAAI,WAA4B;AAChC,IAAI,SAAoB,CAAC;AACzB,IAAM,iBAA8B,CAAC;AACrC,IAAM,cAAc,oBAAI,IAAgB;AAExC,IAAM,cAAc,MAAM;AACzB,QAAM,WAAW,OAAO,QAAS,MAAO,EAAE,OAAQ,CAAE,cAAiC,CAAE,MAAM,KAAM,MAAO;AACzG,iBAAc,IAAK,IAAI,MAAM;AAE7B,WAAO;AAAA,EACR,GAAG,CAAC,CAAE;AAEN,aAAO,gCAAiB,QAAS;AAClC;AAEA,SAAS,cAAe,OAAe;AACtC,MAAK,OAAQ,MAAM,IAAK,GAAI;AAC3B,UAAM,IAAI,MAAO,oBAAqB,MAAM,IAAK,mBAAoB;AAAA,EACtE;AAEA,SAAQ,MAAM,IAAK,IAAI;AACxB;AAEA,IAAM,gBAAgB,CAAE,eAA4B;AACnD,cAAY,IAAK,UAAW;AAC7B;AAGA,IAAM,WAAW,CAAE,WAAiB;AACnC,MAAK,CAAE,UAAW;AACjB,mBAAe,KAAM,MAAO;AAE5B;AAAA,EACD;AAEA,SAAO,SAAS,SAAU,MAAO;AAClC;AAEA,IAAM,WAAW,MAAM;AACtB,MAAK,CAAE,UAAW;AACjB,UAAM,IAAI,MAAO,oCAAqC;AAAA,EACvD;AAEA,SAAO,SAAS,SAAS;AAC1B;AAEA,IAAM,YAAY,CAAE,aAA0B;AAC7C,MAAK,CAAE,UAAW;AACjB,UAAM,IAAI,MAAO,oCAAqC;AAAA,EACvD;AAEA,SAAO,SAAS,UAAW,QAAS;AACrC;AAEA,IAAM,cAAc,MAAM;AACzB,MAAK,UAAW;AACf,UAAM,IAAI,MAAO,oCAAqC;AAAA,EACvD;AAEA,iBAAW,+BAAgB;AAAA,IAC1B,SAAS,YAAY;AAAA,IACrB,YAAY,CAAE,yBAA0B;AACvC,aAAO;AAAA,QACN,GAAG,qBAAqB;AAAA,QACxB,GAAG,MAAM,KAAM,WAAY;AAAA,MAC5B;AAAA,IACD;AAAA,EACD,CAAE;AAEF,MAAK,eAAe,QAAS;AAC5B,mBAAe,QAAS,CAAE,WAAY,SAAU,MAAO,CAAE;AACzD,mBAAe,SAAS;AAAA,EACzB;AAEA,SAAO;AACR;AAEA,IAAM,WAAW,MAAM;AACtB,SAAO;AACR;AAEA,IAAM,cAAc,MAAM;AACzB,aAAW;AACX,WAAS,CAAC;AACV,iBAAe,SAAS;AACxB,cAAY,MAAM;AACnB;","names":["import_toolkit"]}
|
package/dist/index.mjs
CHANGED
|
@@ -6,7 +6,8 @@ import {
|
|
|
6
6
|
import {
|
|
7
7
|
createSelector,
|
|
8
8
|
createSlice,
|
|
9
|
-
createAsyncThunk
|
|
9
|
+
createAsyncThunk,
|
|
10
|
+
createAction
|
|
10
11
|
} from "@reduxjs/toolkit";
|
|
11
12
|
import {
|
|
12
13
|
useSelector,
|
|
@@ -83,6 +84,7 @@ var deleteStore = () => {
|
|
|
83
84
|
export {
|
|
84
85
|
Provider as __StoreProvider,
|
|
85
86
|
addMiddleware as __addMiddleware,
|
|
87
|
+
createAction as __createAction,
|
|
86
88
|
createAsyncThunk as __createAsyncThunk,
|
|
87
89
|
createSelector as __createSelector,
|
|
88
90
|
createSlice as __createSlice,
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import {\n\tReducersMapObject,\n\tconfigureStore,\n\tcombineReducers,\n\tMiddleware,\n\tSlice,\n\tAnyAction,\n\tEnhancedStore,\n\tStoreEnhancer,\n\tThunkMiddleware,\n} from '@reduxjs/toolkit';\n\nexport type {\n\tSlice,\n\tCreateSliceOptions,\n\tPayloadAction,\n\tStore,\n\tDispatch,\n\tAnyAction,\n\tAction,\n\tMiddlewareAPI,\n\tMiddleware,\n} from '@reduxjs/toolkit';\n\nexport {\n\tcreateSelector as __createSelector,\n\tcreateSlice as __createSlice,\n\tcreateAsyncThunk as __createAsyncThunk,\n} from '@reduxjs/toolkit';\n\nexport {\n\tuseSelector as __useSelector,\n\tuseDispatch as __useDispatch,\n\tProvider as __StoreProvider,\n} from 'react-redux';\n\n/**\n * Usage:\n *\n * const mySlice = addSlice( ... );\n *\n * type MySliceState = SliceState<typeof mySlice>;\n *\n * const value = useSelector( ( state: MySliceState ) => state.mySlice.value );\n */\nexport type SliceState<S extends Slice> = {\n\t[ key in S['name'] ]: ReturnType<S['getInitialState']>;\n}\n\n// The `configureStore` function from Redux Toolkit infers its actions from the `reducers`\n// key of the initialization object. This is fine when creating the store statically, but\n// breaks in our case since we create the store dynamically, which means that TypeScript\n// can't infer the types. Therefore, we force the store to accept any actions using a\n// generic store type.\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype AnyStore<State = any> = EnhancedStore<\n\tState,\n\tAnyAction,\n\t[ThunkMiddleware<State, AnyAction>],\n\t[StoreEnhancer]\n>\n\ninterface SlicesMap {\n\t[key: Slice['name']]: Slice;\n}\n\nlet instance: AnyStore | null = null;\nlet slices: SlicesMap = {};\nconst pendingActions: AnyAction[] = [];\nconst middlewares = new Set<Middleware>();\n\nconst getReducers = () => {\n\tconst reducers = Object.entries( slices ).reduce( ( reducersData: ReducersMapObject, [ name, slice ] ) => {\n\t\treducersData[ name ] = slice.reducer;\n\n\t\treturn reducersData;\n\t}, {} );\n\n\treturn combineReducers( reducers );\n};\n\nfunction registerSlice( slice: Slice ) {\n\tif ( slices[ slice.name ] ) {\n\t\tthrow new Error( `Slice with name \"${ slice.name }\" already exists.` );\n\t}\n\n\tslices[ slice.name ] = slice;\n}\n\nconst addMiddleware = ( middleware: Middleware ) => {\n\tmiddlewares.add( middleware );\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any -- See the comment above about `AnyStore`\nconst dispatch = ( action: any ) => {\n\tif ( ! instance ) {\n\t\tpendingActions.push( action );\n\n\t\treturn;\n\t}\n\n\treturn instance.dispatch( action );\n};\n\nconst getState = () => {\n\tif ( ! instance ) {\n\t\tthrow new Error( 'The store instance does not exist.' );\n\t}\n\n\treturn instance.getState();\n};\n\nconst subscribe = ( listener: () => void ) => {\n\tif ( ! instance ) {\n\t\tthrow new Error( 'The store instance does not exist.' );\n\t}\n\n\treturn instance.subscribe( listener );\n};\n\nconst createStore = () => {\n\tif ( instance ) {\n\t\tthrow new Error( 'The store instance already exists.' );\n\t}\n\n\tinstance = configureStore( {\n\t\treducer: getReducers(),\n\t\tmiddleware: ( getDefaultMiddleware ) => {\n\t\t\treturn [\n\t\t\t\t...getDefaultMiddleware(),\n\t\t\t\t...Array.from( middlewares ),\n\t\t\t];\n\t\t},\n\t} );\n\n\tif ( pendingActions.length ) {\n\t\tpendingActions.forEach( ( action ) => dispatch( action ) );\n\t\tpendingActions.length = 0;\n\t}\n\n\treturn instance as AnyStore;\n};\n\nconst getStore = () => {\n\treturn instance;\n};\n\nconst deleteStore = () => {\n\tinstance = null;\n\tslices = {};\n\tpendingActions.length = 0;\n\tmiddlewares.clear();\n};\n\nexport {\n\tregisterSlice as __registerSlice,\n\taddMiddleware as __addMiddleware,\n\tdispatch as __dispatch,\n\tgetState as __getState,\n\tsubscribe as __subscribe,\n\tcreateStore as __createStore,\n\tgetStore as __getStore,\n\tdeleteStore as __deleteStore,\n};\n"],"mappings":";AAAA;AAAA,EAEC;AAAA,EACA;AAAA,OAOM;AAcP;AAAA,EACmB;AAAA,EACH;AAAA,EACK;AAAA,
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import {\n\tReducersMapObject,\n\tconfigureStore,\n\tcombineReducers,\n\tMiddleware,\n\tSlice,\n\tAnyAction,\n\tEnhancedStore,\n\tStoreEnhancer,\n\tThunkMiddleware,\n} from '@reduxjs/toolkit';\n\nexport type {\n\tSlice,\n\tCreateSliceOptions,\n\tPayloadAction,\n\tStore,\n\tDispatch,\n\tAnyAction,\n\tAction,\n\tMiddlewareAPI,\n\tMiddleware,\n} from '@reduxjs/toolkit';\n\nexport {\n\tcreateSelector as __createSelector,\n\tcreateSlice as __createSlice,\n\tcreateAsyncThunk as __createAsyncThunk,\n\tcreateAction as __createAction,\n} from '@reduxjs/toolkit';\n\nexport {\n\tuseSelector as __useSelector,\n\tuseDispatch as __useDispatch,\n\tProvider as __StoreProvider,\n} from 'react-redux';\n\n/**\n * Usage:\n *\n * const mySlice = addSlice( ... );\n *\n * type MySliceState = SliceState<typeof mySlice>;\n *\n * const value = useSelector( ( state: MySliceState ) => state.mySlice.value );\n */\nexport type SliceState<S extends Slice> = {\n\t[ key in S['name'] ]: ReturnType<S['getInitialState']>;\n}\n\n// The `configureStore` function from Redux Toolkit infers its actions from the `reducers`\n// key of the initialization object. This is fine when creating the store statically, but\n// breaks in our case since we create the store dynamically, which means that TypeScript\n// can't infer the types. Therefore, we force the store to accept any actions using a\n// generic store type.\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype AnyStore<State = any> = EnhancedStore<\n\tState,\n\tAnyAction,\n\t[ThunkMiddleware<State, AnyAction>],\n\t[StoreEnhancer]\n>\n\ninterface SlicesMap {\n\t[key: Slice['name']]: Slice;\n}\n\nlet instance: AnyStore | null = null;\nlet slices: SlicesMap = {};\nconst pendingActions: AnyAction[] = [];\nconst middlewares = new Set<Middleware>();\n\nconst getReducers = () => {\n\tconst reducers = Object.entries( slices ).reduce( ( reducersData: ReducersMapObject, [ name, slice ] ) => {\n\t\treducersData[ name ] = slice.reducer;\n\n\t\treturn reducersData;\n\t}, {} );\n\n\treturn combineReducers( reducers );\n};\n\nfunction registerSlice( slice: Slice ) {\n\tif ( slices[ slice.name ] ) {\n\t\tthrow new Error( `Slice with name \"${ slice.name }\" already exists.` );\n\t}\n\n\tslices[ slice.name ] = slice;\n}\n\nconst addMiddleware = ( middleware: Middleware ) => {\n\tmiddlewares.add( middleware );\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any -- See the comment above about `AnyStore`\nconst dispatch = ( action: any ) => {\n\tif ( ! instance ) {\n\t\tpendingActions.push( action );\n\n\t\treturn;\n\t}\n\n\treturn instance.dispatch( action );\n};\n\nconst getState = () => {\n\tif ( ! instance ) {\n\t\tthrow new Error( 'The store instance does not exist.' );\n\t}\n\n\treturn instance.getState();\n};\n\nconst subscribe = ( listener: () => void ) => {\n\tif ( ! instance ) {\n\t\tthrow new Error( 'The store instance does not exist.' );\n\t}\n\n\treturn instance.subscribe( listener );\n};\n\nconst createStore = () => {\n\tif ( instance ) {\n\t\tthrow new Error( 'The store instance already exists.' );\n\t}\n\n\tinstance = configureStore( {\n\t\treducer: getReducers(),\n\t\tmiddleware: ( getDefaultMiddleware ) => {\n\t\t\treturn [\n\t\t\t\t...getDefaultMiddleware(),\n\t\t\t\t...Array.from( middlewares ),\n\t\t\t];\n\t\t},\n\t} );\n\n\tif ( pendingActions.length ) {\n\t\tpendingActions.forEach( ( action ) => dispatch( action ) );\n\t\tpendingActions.length = 0;\n\t}\n\n\treturn instance as AnyStore;\n};\n\nconst getStore = () => {\n\treturn instance;\n};\n\nconst deleteStore = () => {\n\tinstance = null;\n\tslices = {};\n\tpendingActions.length = 0;\n\tmiddlewares.clear();\n};\n\nexport {\n\tregisterSlice as __registerSlice,\n\taddMiddleware as __addMiddleware,\n\tdispatch as __dispatch,\n\tgetState as __getState,\n\tsubscribe as __subscribe,\n\tcreateStore as __createStore,\n\tgetStore as __getStore,\n\tdeleteStore as __deleteStore,\n};\n"],"mappings":";AAAA;AAAA,EAEC;AAAA,EACA;AAAA,OAOM;AAcP;AAAA,EACmB;AAAA,EACH;AAAA,EACK;AAAA,EACJ;AAAA,OACV;AAEP;AAAA,EACgB;AAAA,EACA;AAAA,EACH;AAAA,OACN;AAiCP,IAAI,WAA4B;AAChC,IAAI,SAAoB,CAAC;AACzB,IAAM,iBAA8B,CAAC;AACrC,IAAM,cAAc,oBAAI,IAAgB;AAExC,IAAM,cAAc,MAAM;AACzB,QAAM,WAAW,OAAO,QAAS,MAAO,EAAE,OAAQ,CAAE,cAAiC,CAAE,MAAM,KAAM,MAAO;AACzG,iBAAc,IAAK,IAAI,MAAM;AAE7B,WAAO;AAAA,EACR,GAAG,CAAC,CAAE;AAEN,SAAO,gBAAiB,QAAS;AAClC;AAEA,SAAS,cAAe,OAAe;AACtC,MAAK,OAAQ,MAAM,IAAK,GAAI;AAC3B,UAAM,IAAI,MAAO,oBAAqB,MAAM,IAAK,mBAAoB;AAAA,EACtE;AAEA,SAAQ,MAAM,IAAK,IAAI;AACxB;AAEA,IAAM,gBAAgB,CAAE,eAA4B;AACnD,cAAY,IAAK,UAAW;AAC7B;AAGA,IAAM,WAAW,CAAE,WAAiB;AACnC,MAAK,CAAE,UAAW;AACjB,mBAAe,KAAM,MAAO;AAE5B;AAAA,EACD;AAEA,SAAO,SAAS,SAAU,MAAO;AAClC;AAEA,IAAM,WAAW,MAAM;AACtB,MAAK,CAAE,UAAW;AACjB,UAAM,IAAI,MAAO,oCAAqC;AAAA,EACvD;AAEA,SAAO,SAAS,SAAS;AAC1B;AAEA,IAAM,YAAY,CAAE,aAA0B;AAC7C,MAAK,CAAE,UAAW;AACjB,UAAM,IAAI,MAAO,oCAAqC;AAAA,EACvD;AAEA,SAAO,SAAS,UAAW,QAAS;AACrC;AAEA,IAAM,cAAc,MAAM;AACzB,MAAK,UAAW;AACf,UAAM,IAAI,MAAO,oCAAqC;AAAA,EACvD;AAEA,aAAW,eAAgB;AAAA,IAC1B,SAAS,YAAY;AAAA,IACrB,YAAY,CAAE,yBAA0B;AACvC,aAAO;AAAA,QACN,GAAG,qBAAqB;AAAA,QACxB,GAAG,MAAM,KAAM,WAAY;AAAA,MAC5B;AAAA,IACD;AAAA,EACD,CAAE;AAEF,MAAK,eAAe,QAAS;AAC5B,mBAAe,QAAS,CAAE,WAAY,SAAU,MAAO,CAAE;AACzD,mBAAe,SAAS;AAAA,EACzB;AAEA,SAAO;AACR;AAEA,IAAM,WAAW,MAAM;AACtB,SAAO;AACR;AAEA,IAAM,cAAc,MAAM;AACzB,aAAW;AACX,WAAS,CAAC;AACV,iBAAe,SAAS;AACxB,cAAY,MAAM;AACnB;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elementor/store",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "Elementor Team",
|
|
6
6
|
"homepage": "https://elementor.com/",
|
|
@@ -32,11 +32,11 @@
|
|
|
32
32
|
"dev": "tsup --config=../../tsup.dev.ts"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
|
-
"react": "18.
|
|
35
|
+
"react": "^18.3.1"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@reduxjs/toolkit": "^1.9.7",
|
|
39
39
|
"react-redux": "^8.1.3"
|
|
40
40
|
},
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "8fee803f32268363169a260a99c2eb7c2d548b39"
|
|
42
42
|
}
|