@elementor/store 0.4.0 → 0.6.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/CHANGELOG.md CHANGED
@@ -3,6 +3,28 @@
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.6.0](https://github.com/elementor/elementor-packages/compare/@elementor/store@0.5.0...@elementor/store@0.6.0) (2023-06-11)
7
+
8
+
9
+ ### Features
10
+
11
+ * **editor-panels:** init [ED-10804] ([#44](https://github.com/elementor/elementor-packages/issues/44)) ([1ed4113](https://github.com/elementor/elementor-packages/commit/1ed41131db8fb9151163175bfa614f784159e04b))
12
+
13
+
14
+
15
+
16
+
17
+ # [0.5.0](https://github.com/elementor/elementor-packages/compare/@elementor/store@0.4.0...@elementor/store@0.5.0) (2023-06-06)
18
+
19
+
20
+ ### Features
21
+
22
+ * drop support for React 17 [ED-10982] ([#50](https://github.com/elementor/elementor-packages/issues/50)) ([59c576c](https://github.com/elementor/elementor-packages/commit/59c576ca218947dc0992616311d4d399a20e91a6))
23
+
24
+
25
+
26
+
27
+
6
28
  # [0.4.0](https://github.com/elementor/elementor-packages/compare/@elementor/store@0.3.0...@elementor/store@0.4.0) (2023-06-05)
7
29
 
8
30
 
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import * as redux from 'redux';
1
2
  import { Slice, Middleware, AnyAction, Store } from '@reduxjs/toolkit';
2
3
  export { Action, AnyAction, CreateSliceOptions, Dispatch, Middleware, MiddlewareAPI, PayloadAction, Slice, Store, createSelector, createSlice } from '@reduxjs/toolkit';
3
4
  export { Provider as StoreProvider, useDispatch, useSelector } from 'react-redux';
@@ -17,8 +18,10 @@ type SliceState<S extends Slice> = {
17
18
  declare function registerSlice(slice: Slice): void;
18
19
  declare const addMiddleware: (middleware: Middleware) => void;
19
20
  declare const dispatch: (action: AnyAction) => AnyAction | undefined;
21
+ declare const getState: () => any;
22
+ declare const subscribe: (listener: () => void) => redux.Unsubscribe;
20
23
  declare const createStore: () => Store<any, AnyAction>;
21
24
  declare const getStore: () => Store<any, AnyAction> | null;
22
25
  declare const deleteStore: () => void;
23
26
 
24
- export { SliceState, addMiddleware, createStore, deleteStore, dispatch, getStore, registerSlice };
27
+ export { SliceState, addMiddleware, createStore, deleteStore, dispatch, getState, getStore, registerSlice, subscribe };
package/dist/index.js CHANGED
@@ -27,8 +27,10 @@ __export(src_exports, {
27
27
  createStore: () => createStore,
28
28
  deleteStore: () => deleteStore,
29
29
  dispatch: () => dispatch,
30
+ getState: () => getState,
30
31
  getStore: () => getStore,
31
32
  registerSlice: () => registerSlice,
33
+ subscribe: () => subscribe,
32
34
  useDispatch: () => import_react_redux.useDispatch,
33
35
  useSelector: () => import_react_redux.useSelector
34
36
  });
@@ -63,6 +65,18 @@ var dispatch = (action) => {
63
65
  }
64
66
  return instance.dispatch(action);
65
67
  };
68
+ var getState = () => {
69
+ if (!instance) {
70
+ throw new Error("The store instance does not exist.");
71
+ }
72
+ return instance.getState();
73
+ };
74
+ var subscribe = (listener) => {
75
+ if (!instance) {
76
+ throw new Error("The store instance does not exist.");
77
+ }
78
+ return instance.subscribe(listener);
79
+ };
66
80
  var createStore = () => {
67
81
  if (instance) {
68
82
  throw new Error("The store instance already exists.");
@@ -95,8 +109,10 @@ var deleteStore = () => {
95
109
  createStore,
96
110
  deleteStore,
97
111
  dispatch,
112
+ getState,
98
113
  getStore,
99
114
  registerSlice,
115
+ subscribe,
100
116
  useDispatch,
101
117
  useSelector
102
118
  });
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\tStore,\n\tSlice,\n\tAnyAction,\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 { createSelector, createSlice } from '@reduxjs/toolkit';\n\nexport { useSelector, useDispatch, Provider as StoreProvider } 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\ninterface SlicesMap {\n\t[key: Slice['name']]: Slice;\n}\n\nlet instance: Store | 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\nexport function 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\nexport const addMiddleware = ( middleware: Middleware ) => {\n\tmiddlewares.add( middleware );\n};\n\nexport const dispatch = ( action: AnyAction ) => {\n\tif ( ! instance ) {\n\t\tpendingActions.push( action );\n\n\t\treturn;\n\t}\n\n\treturn instance.dispatch( action );\n};\n\nexport const 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: Array.from( middlewares ),\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;\n};\n\nexport const getStore = () => {\n\treturn instance;\n};\n\nexport const deleteStore = () => {\n\tinstance = null;\n\tslices =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M;AAC7B,SAAO;AACR;AAEO,IAAM,cAAc,MAAM;AAChC,aAAW;AACX,WAAS,CAAC;AACV,iBAAe,SAAS;AACxB,cAAY,MAAM;AACnB;","names":["import_toolkit"]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import {\n\tReducersMapObject,\n\tconfigureStore,\n\tcombineReducers,\n\tMiddleware,\n\tStore,\n\tSlice,\n\tAnyAction,\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 { createSelector, createSlice } from '@reduxjs/toolkit';\n\nexport { useSelector, useDispatch, Provider as StoreProvider } 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\ninterface SlicesMap {\n\t[key: Slice['name']]: Slice;\n}\n\nlet instance: Store | 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\nexport function 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\nexport const addMiddleware = ( middleware: Middleware ) => {\n\tmiddlewares.add( middleware );\n};\n\nexport const dispatch = ( action: AnyAction ) => {\n\tif ( ! instance ) {\n\t\tpendingActions.push( action );\n\n\t\treturn;\n\t}\n\n\treturn instance.dispatch( action );\n};\n\nexport const getState = () => {\n\tif ( ! instance ) {\n\t\tthrow new Error( 'The store instance does not exist.' );\n\t}\n\n\treturn instance.getState();\n};\n\nexport const 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\nexport const 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: Array.from( middlewares ),\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;\n};\n\nexport const getStore = () => {\n\treturn instance;\n};\n\nexport const deleteStore = () => {\n\tinstance = null;\n\tslices = {};\n\tpendingActions.length = 0;\n\tmiddlewares.clear();\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAQO;AAcP,IAAAA,kBAA4C;AAE5C,yBAAoE;AAmBpE,IAAI,WAAyB;AAC7B,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;AAEO,SAAS,cAAe,OAAe;AAC7C,MAAK,OAAQ,MAAM,IAAK,GAAI;AAC3B,UAAM,IAAI,MAAO,oBAAqB,MAAM,uBAAyB;AAAA,EACtE;AAEA,SAAQ,MAAM,IAAK,IAAI;AACxB;AAEO,IAAM,gBAAgB,CAAE,eAA4B;AAC1D,cAAY,IAAK,UAAW;AAC7B;AAEO,IAAM,WAAW,CAAE,WAAuB;AAChD,MAAK,CAAE,UAAW;AACjB,mBAAe,KAAM,MAAO;AAE5B;AAAA,EACD;AAEA,SAAO,SAAS,SAAU,MAAO;AAClC;AAEO,IAAM,WAAW,MAAM;AAC7B,MAAK,CAAE,UAAW;AACjB,UAAM,IAAI,MAAO,oCAAqC;AAAA,EACvD;AAEA,SAAO,SAAS,SAAS;AAC1B;AAEO,IAAM,YAAY,CAAE,aAA0B;AACpD,MAAK,CAAE,UAAW;AACjB,UAAM,IAAI,MAAO,oCAAqC;AAAA,EACvD;AAEA,SAAO,SAAS,UAAW,QAAS;AACrC;AAEO,IAAM,cAAc,MAAM;AAChC,MAAK,UAAW;AACf,UAAM,IAAI,MAAO,oCAAqC;AAAA,EACvD;AAEA,iBAAW,+BAAgB;AAAA,IAC1B,SAAS,YAAY;AAAA,IACrB,YAAY,MAAM,KAAM,WAAY;AAAA,EACrC,CAAE;AAEF,MAAK,eAAe,QAAS;AAC5B,mBAAe,QAAS,CAAE,WAAY,SAAU,MAAO,CAAE;AACzD,mBAAe,SAAS;AAAA,EACzB;AAEA,SAAO;AACR;AAEO,IAAM,WAAW,MAAM;AAC7B,SAAO;AACR;AAEO,IAAM,cAAc,MAAM;AAChC,aAAW;AACX,WAAS,CAAC;AACV,iBAAe,SAAS;AACxB,cAAY,MAAM;AACnB;","names":["import_toolkit"]}
package/dist/index.mjs CHANGED
@@ -32,6 +32,18 @@ var dispatch = (action) => {
32
32
  }
33
33
  return instance.dispatch(action);
34
34
  };
35
+ var getState = () => {
36
+ if (!instance) {
37
+ throw new Error("The store instance does not exist.");
38
+ }
39
+ return instance.getState();
40
+ };
41
+ var subscribe = (listener) => {
42
+ if (!instance) {
43
+ throw new Error("The store instance does not exist.");
44
+ }
45
+ return instance.subscribe(listener);
46
+ };
35
47
  var createStore = () => {
36
48
  if (instance) {
37
49
  throw new Error("The store instance already exists.");
@@ -63,8 +75,10 @@ export {
63
75
  createStore,
64
76
  deleteStore,
65
77
  dispatch,
78
+ getState,
66
79
  getStore,
67
80
  registerSlice,
81
+ subscribe,
68
82
  useDispatch,
69
83
  useSelector
70
84
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import {\n\tReducersMapObject,\n\tconfigureStore,\n\tcombineReducers,\n\tMiddleware,\n\tStore,\n\tSlice,\n\tAnyAction,\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 { createSelector, createSlice } from '@reduxjs/toolkit';\n\nexport { useSelector, useDispatch, Provider as StoreProvider } 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\ninterface SlicesMap {\n\t[key: Slice['name']]: Slice;\n}\n\nlet instance: Store | 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\nexport function 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\nexport const addMiddleware = ( middleware: Middleware ) => {\n\tmiddlewares.add( middleware );\n};\n\nexport const dispatch = ( action: AnyAction ) => {\n\tif ( ! instance ) {\n\t\tpendingActions.push( action );\n\n\t\treturn;\n\t}\n\n\treturn instance.dispatch( action );\n};\n\nexport const 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: Array.from( middlewares ),\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;\n};\n\nexport const getStore = () => {\n\treturn instance;\n};\n\nexport const deleteStore = () => {\n\tinstance = null;\n\tslices = {};\n\tpendingActions.length = 0;\n\tmiddlewares.clear();\n};\n"],"mappings":";AAAA;AAAA,EAEC;AAAA,EACA;AAAA,OAKM;AAcP,SAAS,gBAAgB,mBAAmB;AAE5C,SAAS,aAAa,aAAyB,gBAAqB;AAmBpE,IAAI,WAAyB;AAC7B,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;AAEO,SAAS,cAAe,OAAe;AAC7C,MAAK,OAAQ,MAAM,IAAK,GAAI;AAC3B,UAAM,IAAI,MAAO,oBAAqB,MAAM,uBAAyB;AAAA,EACtE;AAEA,SAAQ,MAAM,IAAK,IAAI;AACxB;AAEO,IAAM,gBAAgB,CAAE,eAA4B;AAC1D,cAAY,IAAK,UAAW;AAC7B;AAEO,IAAM,WAAW,CAAE,WAAuB;AAChD,MAAK,CAAE,UAAW;AACjB,mBAAe,KAAM,MAAO;AAE5B;AAAA,EACD;AAEA,SAAO,SAAS,SAAU,MAAO;AAClC;AAEO,IAAM,cAAc,MAAM;AAChC,MAAK,UAAW;AACf,UAAM,IAAI,MAAO,oCAAqC;AAAA,EACvD;AAEA,aAAW,eAAgB;AAAA,IAC1B,SAAS,YAAY;AAAA,IACrB,YAAY,MAAM,KAAM,WAAY;AAAA,EACrC,CAAE;AAEF,MAAK,eAAe,QAAS;AAC5B,mBAAe,QAAS,CAAE,WAAY,SAAU,MAAO,CAAE;AACzD,mBAAe,SAAS;AAAA,EACzB;AAEA,SAAO;AACR;AAEO,IAAM,WAAW,MAAM;AAC7B,SAAO;AACR;AAEO,IAAM,cAAc,MAAM;AAChC,aAAW;AACX,WAAS,CAAC;AACV,iBAAe,SAAS;AACxB,cAAY,MAAM;AACnB;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import {\n\tReducersMapObject,\n\tconfigureStore,\n\tcombineReducers,\n\tMiddleware,\n\tStore,\n\tSlice,\n\tAnyAction,\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 { createSelector, createSlice } from '@reduxjs/toolkit';\n\nexport { useSelector, useDispatch, Provider as StoreProvider } 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\ninterface SlicesMap {\n\t[key: Slice['name']]: Slice;\n}\n\nlet instance: Store | 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\nexport function 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\nexport const addMiddleware = ( middleware: Middleware ) => {\n\tmiddlewares.add( middleware );\n};\n\nexport const dispatch = ( action: AnyAction ) => {\n\tif ( ! instance ) {\n\t\tpendingActions.push( action );\n\n\t\treturn;\n\t}\n\n\treturn instance.dispatch( action );\n};\n\nexport const getState = () => {\n\tif ( ! instance ) {\n\t\tthrow new Error( 'The store instance does not exist.' );\n\t}\n\n\treturn instance.getState();\n};\n\nexport const 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\nexport const 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: Array.from( middlewares ),\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;\n};\n\nexport const getStore = () => {\n\treturn instance;\n};\n\nexport const deleteStore = () => {\n\tinstance = null;\n\tslices = {};\n\tpendingActions.length = 0;\n\tmiddlewares.clear();\n};\n"],"mappings":";AAAA;AAAA,EAEC;AAAA,EACA;AAAA,OAKM;AAcP,SAAS,gBAAgB,mBAAmB;AAE5C,SAAS,aAAa,aAAyB,gBAAqB;AAmBpE,IAAI,WAAyB;AAC7B,IAAI,SAAoB,CAAC;AACzB,IAAM,iBAA8B,CAAC;AACrC,IAAM,cAAc,oBAAI,IAAgB;AAExC,IAAM,cAAc,MAAM;AACzB,QAAM,WAAW,OAAO,QAAS,MAAO,EAAE,OAA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ED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elementor/store",
3
- "version": "0.4.0",
3
+ "version": "0.6.0",
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": "17.x || 18.x"
35
+ "react": "18.x"
36
36
  },
37
37
  "dependencies": {
38
38
  "@reduxjs/toolkit": "^1.9.1",
39
39
  "react-redux": "^8.0.5"
40
40
  },
41
- "gitHead": "753851e1a5003eb1ea5349b76d96c75f70e0a594"
41
+ "gitHead": "70a2c6139730b7afa69d13eb65023b0e6612f23b"
42
42
  }
package/src/index.ts CHANGED
@@ -78,6 +78,22 @@ export const dispatch = ( action: AnyAction ) => {
78
78
  return instance.dispatch( action );
79
79
  };
80
80
 
81
+ export const getState = () => {
82
+ if ( ! instance ) {
83
+ throw new Error( 'The store instance does not exist.' );
84
+ }
85
+
86
+ return instance.getState();
87
+ };
88
+
89
+ export const subscribe = ( listener: () => void ) => {
90
+ if ( ! instance ) {
91
+ throw new Error( 'The store instance does not exist.' );
92
+ }
93
+
94
+ return instance.subscribe( listener );
95
+ };
96
+
81
97
  export const createStore = () => {
82
98
  if ( instance ) {
83
99
  throw new Error( 'The store instance already exists.' );