2020-02-25 11:36:53 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { registerStore } from '@wordpress/data';
|
2020-03-19 11:50:51 +00:00
|
|
|
import { controls as dataControls } from '@wordpress/data-controls';
|
2021-12-07 15:47:50 +00:00
|
|
|
|
2020-02-25 11:36:53 +00:00
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
import { STORE_KEY } from './constants';
|
|
|
|
import * as selectors from './selectors';
|
|
|
|
import * as actions from './actions';
|
|
|
|
import * as resolvers from './resolvers';
|
2021-03-01 17:47:22 +00:00
|
|
|
import reducer, { State } from './reducers';
|
2021-06-04 08:17:13 +00:00
|
|
|
import { controls as sharedControls } from '../shared-controls';
|
|
|
|
import { controls } from './controls';
|
2021-12-07 15:47:50 +00:00
|
|
|
import type { SelectFromMap, DispatchFromMap } from '../mapped-types';
|
2020-02-25 11:36:53 +00:00
|
|
|
|
2021-03-01 17:47:22 +00:00
|
|
|
registerStore< State >( STORE_KEY, {
|
2020-02-25 11:36:53 +00:00
|
|
|
reducer,
|
|
|
|
actions,
|
2021-03-01 17:47:22 +00:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
2021-06-04 08:17:13 +00:00
|
|
|
controls: { ...dataControls, ...sharedControls, ...controls } as any,
|
2020-02-25 11:36:53 +00:00
|
|
|
selectors,
|
|
|
|
resolvers,
|
|
|
|
} );
|
|
|
|
|
|
|
|
export const CART_STORE_KEY = STORE_KEY;
|
2021-03-01 17:47:22 +00:00
|
|
|
|
|
|
|
declare module '@wordpress/data' {
|
|
|
|
function dispatch(
|
|
|
|
key: typeof CART_STORE_KEY
|
|
|
|
): DispatchFromMap< typeof actions >;
|
|
|
|
function select(
|
|
|
|
key: typeof CART_STORE_KEY
|
|
|
|
): SelectFromMap< typeof selectors >;
|
|
|
|
}
|