@wordpress/data 6.11.0 → 6.14.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 +10 -0
- package/README.md +44 -32
- package/build/components/async-mode-provider/context.js +2 -1
- package/build/components/async-mode-provider/context.js.map +1 -1
- package/build/components/use-dispatch/use-dispatch.js +3 -2
- package/build/components/use-dispatch/use-dispatch.js.map +1 -1
- package/build/components/use-select/index.js +32 -19
- package/build/components/use-select/index.js.map +1 -1
- package/build/components/with-dispatch/index.js +5 -3
- package/build/components/with-dispatch/index.js.map +1 -1
- package/build/components/with-select/index.js +2 -1
- package/build/components/with-select/index.js.map +1 -1
- package/build/controls.js +8 -9
- package/build/controls.js.map +1 -1
- package/build/factory.js +5 -2
- package/build/factory.js.map +1 -1
- package/build/index.js +26 -20
- package/build/index.js.map +1 -1
- package/build/redux-store/index.js +14 -7
- package/build/redux-store/index.js.map +1 -1
- package/build/registry.js +21 -16
- package/build/registry.js.map +1 -1
- package/build-module/components/async-mode-provider/context.js +2 -1
- package/build-module/components/async-mode-provider/context.js.map +1 -1
- package/build-module/components/use-dispatch/use-dispatch.js +3 -2
- package/build-module/components/use-dispatch/use-dispatch.js.map +1 -1
- package/build-module/components/use-select/index.js +33 -20
- package/build-module/components/use-select/index.js.map +1 -1
- package/build-module/components/with-dispatch/index.js +5 -3
- package/build-module/components/with-dispatch/index.js.map +1 -1
- package/build-module/components/with-select/index.js +2 -1
- package/build-module/components/with-select/index.js.map +1 -1
- package/build-module/controls.js +5 -5
- package/build-module/controls.js.map +1 -1
- package/build-module/factory.js +5 -2
- package/build-module/factory.js.map +1 -1
- package/build-module/index.js +26 -20
- package/build-module/index.js.map +1 -1
- package/build-module/redux-store/index.js +14 -7
- package/build-module/redux-store/index.js.map +1 -1
- package/build-module/registry.js +17 -12
- package/build-module/registry.js.map +1 -1
- package/build-types/components/async-mode-provider/context.d.ts +5 -0
- package/build-types/components/async-mode-provider/context.d.ts.map +1 -0
- package/build-types/components/async-mode-provider/index.d.ts +3 -0
- package/build-types/components/async-mode-provider/index.d.ts.map +1 -0
- package/build-types/components/async-mode-provider/use-async-mode.d.ts +2 -0
- package/build-types/components/async-mode-provider/use-async-mode.d.ts.map +1 -0
- package/build-types/components/registry-provider/context.d.ts +36 -0
- package/build-types/components/registry-provider/context.d.ts.map +1 -0
- package/build-types/components/registry-provider/index.d.ts +3 -0
- package/build-types/components/registry-provider/index.d.ts.map +1 -0
- package/build-types/components/registry-provider/use-registry.d.ts +41 -0
- package/build-types/components/registry-provider/use-registry.d.ts.map +1 -0
- package/build-types/components/use-dispatch/index.d.ts +3 -0
- package/build-types/components/use-dispatch/index.d.ts.map +1 -0
- package/build-types/components/use-dispatch/use-dispatch-with-map.d.ts +17 -0
- package/build-types/components/use-dispatch/use-dispatch-with-map.d.ts.map +1 -0
- package/build-types/components/use-dispatch/use-dispatch.d.ts +50 -0
- package/build-types/components/use-dispatch/use-dispatch.d.ts.map +1 -0
- package/build-types/components/use-select/index.d.ts +99 -0
- package/build-types/components/use-select/index.d.ts.map +1 -0
- package/build-types/components/with-dispatch/index.d.ts +84 -0
- package/build-types/components/with-dispatch/index.d.ts.map +1 -0
- package/build-types/components/with-registry/index.d.ts +11 -0
- package/build-types/components/with-registry/index.d.ts.map +1 -0
- package/build-types/components/with-select/index.d.ts +43 -0
- package/build-types/components/with-select/index.d.ts.map +1 -0
- package/build-types/controls.d.ts +83 -0
- package/build-types/controls.d.ts.map +1 -0
- package/build-types/default-registry.d.ts +3 -0
- package/build-types/default-registry.d.ts.map +1 -0
- package/build-types/factory.d.ts +63 -0
- package/build-types/factory.d.ts.map +1 -0
- package/build-types/index.d.ts +156 -0
- package/build-types/index.d.ts.map +1 -0
- package/build-types/plugins/index.d.ts +2 -0
- package/build-types/plugins/index.d.ts.map +1 -0
- package/build-types/plugins/persistence/index.d.ts +41 -0
- package/build-types/plugins/persistence/index.d.ts.map +1 -0
- package/build-types/plugins/persistence/storage/default.d.ts +3 -0
- package/build-types/plugins/persistence/storage/default.d.ts.map +1 -0
- package/build-types/plugins/persistence/storage/object.d.ts +10 -0
- package/build-types/plugins/persistence/storage/object.d.ts.map +1 -0
- package/build-types/redux-store/index.d.ts +29 -0
- package/build-types/redux-store/index.d.ts.map +1 -0
- package/build-types/redux-store/thunk-middleware.d.ts +2 -0
- package/build-types/redux-store/thunk-middleware.d.ts.map +1 -0
- package/build-types/registry.d.ts +56 -0
- package/build-types/registry.d.ts.map +1 -0
- package/build-types/resolvers-cache-middleware.d.ts +15 -0
- package/build-types/resolvers-cache-middleware.d.ts.map +1 -0
- package/build-types/store/index.d.ts +23 -0
- package/build-types/store/index.d.ts.map +1 -0
- package/build-types/types.d.ts +18 -1
- package/build-types/types.d.ts.map +1 -1
- package/package.json +8 -8
- package/src/components/async-mode-provider/context.js +2 -1
- package/src/components/use-dispatch/use-dispatch.js +3 -2
- package/src/components/use-select/index.js +37 -20
- package/src/components/with-dispatch/index.js +5 -3
- package/src/components/with-select/index.js +2 -1
- package/src/controls.js +4 -5
- package/src/factory.js +5 -2
- package/src/index.js +26 -20
- package/src/redux-store/index.js +14 -7
- package/src/registry.js +17 -12
- package/src/test/registry.js +13 -16
- package/src/types.ts +35 -1
- package/tsconfig.json +4 -2
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":";;;;;;;;AAiFA;;;;;;;;;;;;;;;;;;GAkBG;AACH,8BAA6C;AAE7C;;;;;;;;;;;;;;;;;;GAkBG;AACH,gCAA2D;AAE3D;;;;;;;;;;GAUG;AACH,gCAA2D;AAE3D;;;;;;;;;;;;;;;;;;;GAmBG;AACH,gCAAiD;AAEjD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,iCAAmD;AAEnD;;;;;;;GAOG;AACH,4CAAyE;AAEzE;;;;;;;;;GASG;AACH,qCAA2D;AAE3D;;;;;;GAMG;AACH,sBAAuC;AAEvC;;;;;;;;;;;;;;;;;GAiBG;AACH,2BAAiD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/plugins/index.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a persistence interface, exposing getter and setter methods (`get`
|
|
3
|
+
* and `set` respectively).
|
|
4
|
+
*
|
|
5
|
+
* @param {WPDataPersistencePluginOptions} options Plugin options.
|
|
6
|
+
*
|
|
7
|
+
* @return {Object} Persistence interface.
|
|
8
|
+
*/
|
|
9
|
+
export function createPersistenceInterface(options: WPDataPersistencePluginOptions): Object;
|
|
10
|
+
export function withLazySameState(reducer: Function): Function;
|
|
11
|
+
export default persistencePlugin;
|
|
12
|
+
export type WPDataRegistry = import('../../registry').WPDataRegistry;
|
|
13
|
+
export type WPDataPlugin = import('../../registry').WPDataPlugin;
|
|
14
|
+
/**
|
|
15
|
+
* Persistence plugin options.
|
|
16
|
+
*/
|
|
17
|
+
export type WPDataPersistencePluginOptions = {
|
|
18
|
+
/**
|
|
19
|
+
* Persistent storage implementation. This must
|
|
20
|
+
* at least implement `getItem` and `setItem` of
|
|
21
|
+
* the Web Storage API.
|
|
22
|
+
*/
|
|
23
|
+
storage: Storage;
|
|
24
|
+
/**
|
|
25
|
+
* Key on which to set in persistent storage.
|
|
26
|
+
*/
|
|
27
|
+
storageKey: string;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Data plugin to persist store state into a single storage key.
|
|
31
|
+
*
|
|
32
|
+
* @param {WPDataRegistry} registry Data registry.
|
|
33
|
+
* @param {?WPDataPersistencePluginOptions} pluginOptions Plugin options.
|
|
34
|
+
*
|
|
35
|
+
* @return {WPDataPlugin} Data plugin.
|
|
36
|
+
*/
|
|
37
|
+
declare function persistencePlugin(registry: WPDataRegistry, pluginOptions: WPDataPersistencePluginOptions | null): WPDataPlugin;
|
|
38
|
+
declare namespace persistencePlugin {
|
|
39
|
+
function __unstableMigrate(): void;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/persistence/index.js"],"names":[],"mappings":"AAwDA;;;;;;;GAOG;AACH,oDAJW,8BAA8B,GAE7B,MAAM,CAiDjB;AA/DM,+DAMN;;6BA3Ca,OAAO,gBAAgB,EAAE,cAAc;2BAEvC,OAAO,gBAAgB,EAAE,YAAY;;;;;;;;;;aAKrC,OAAO;;;;gBAGP,MAAM;;AA4FpB;;;;;;;GAOG;AACH,6CALW,cAAc,iBACb,8BAA8B,UAE9B,YAAY,CAqGvB;;IAED,mCAA8C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default.d.ts","sourceRoot":"","sources":["../../../../src/plugins/persistence/storage/default.js"],"names":[],"mappings":";AAKA,yBAAY"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export default storage;
|
|
2
|
+
declare namespace storage {
|
|
3
|
+
function getItem(key: any): any;
|
|
4
|
+
function getItem(key: any): any;
|
|
5
|
+
function setItem(key: any, value: any): void;
|
|
6
|
+
function setItem(key: any, value: any): void;
|
|
7
|
+
function clear(): void;
|
|
8
|
+
function clear(): void;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=object.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"object.d.ts","sourceRoot":"","sources":["../../../../src/plugins/persistence/storage/object.js"],"names":[],"mappings":";;IAGC,gCAMC;IAND,gCAMC;IACD,6CAMC;IAND,6CAMC;IACD,uBAEC;IAFD,uBAEC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a data store descriptor for the provided Redux store configuration containing
|
|
3
|
+
* properties describing reducer, actions, selectors, controls and resolvers.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```js
|
|
7
|
+
* import { createReduxStore } from '@wordpress/data';
|
|
8
|
+
*
|
|
9
|
+
* const store = createReduxStore( 'demo', {
|
|
10
|
+
* reducer: ( state = 'OK' ) => state,
|
|
11
|
+
* selectors: {
|
|
12
|
+
* getValue: ( state ) => state,
|
|
13
|
+
* },
|
|
14
|
+
* } );
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* @template State,Actions,Selectors
|
|
18
|
+
* @param {string} key Unique namespace identifier.
|
|
19
|
+
* @param {ReduxStoreConfig<State,Actions,Selectors>} options Registered store options, with properties
|
|
20
|
+
* describing reducer, actions, selectors,
|
|
21
|
+
* and resolvers.
|
|
22
|
+
*
|
|
23
|
+
* @return {StoreDescriptor<ReduxStoreConfig<State,Actions,Selectors>>} Store Object.
|
|
24
|
+
*/
|
|
25
|
+
export default function createReduxStore<State, Actions, Selectors>(key: string, options: import("../types").ReduxStoreConfig<State, Actions, Selectors>): import("../types").StoreDescriptor<import("../types").ReduxStoreConfig<State, Actions, Selectors>>;
|
|
26
|
+
export type DataRegistry = import('../types').DataRegistry;
|
|
27
|
+
export type StoreDescriptor<C> = import('../types').StoreDescriptor<C>;
|
|
28
|
+
export type ReduxStoreConfig<State, Actions, Selectors> = import('../types').ReduxStoreConfig<State, Actions, Selectors>;
|
|
29
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/redux-store/index.js"],"names":[],"mappings":"AA2EA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,yEAPW,MAAM,+KA8HhB;2BAlMa,OAAO,UAAU,EAAE,YAAY;iCAEhC,OAAO,UAAU,EAAE,eAAe,CAAC,CAAC,CAAC;0DAIrC,OAAO,UAAU,EAAE,gBAAgB,CAAC,KAAK,EAAC,OAAO,EAAC,SAAS,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"thunk-middleware.d.ts","sourceRoot":"","sources":["../../src/redux-store/thunk-middleware.js"],"names":[],"mappings":"AAAA,oGAQC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a new store registry, given an optional object of initial store
|
|
3
|
+
* configurations.
|
|
4
|
+
*
|
|
5
|
+
* @param {Object} storeConfigs Initial store configurations.
|
|
6
|
+
* @param {Object?} parent Parent registry.
|
|
7
|
+
*
|
|
8
|
+
* @return {WPDataRegistry} Data registry.
|
|
9
|
+
*/
|
|
10
|
+
export function createRegistry(storeConfigs?: Object, parent?: Object | null): WPDataRegistry;
|
|
11
|
+
export type StoreDescriptor = import("./types").StoreDescriptor<any>;
|
|
12
|
+
/**
|
|
13
|
+
* An isolated orchestrator of store registrations.
|
|
14
|
+
*/
|
|
15
|
+
export type WPDataRegistry = {
|
|
16
|
+
/**
|
|
17
|
+
* Given a namespace key and settings
|
|
18
|
+
* object, registers a new generic
|
|
19
|
+
* store.
|
|
20
|
+
*/
|
|
21
|
+
registerGenericStore: Function;
|
|
22
|
+
/**
|
|
23
|
+
* Given a namespace key and settings
|
|
24
|
+
* object, registers a new namespace
|
|
25
|
+
* store.
|
|
26
|
+
*/
|
|
27
|
+
registerStore: Function;
|
|
28
|
+
/**
|
|
29
|
+
* Given a function callback, invokes
|
|
30
|
+
* the callback on any change to state
|
|
31
|
+
* within any registered store.
|
|
32
|
+
*/
|
|
33
|
+
subscribe: Function;
|
|
34
|
+
/**
|
|
35
|
+
* Given a namespace key, returns an
|
|
36
|
+
* object of the store's registered
|
|
37
|
+
* selectors.
|
|
38
|
+
*/
|
|
39
|
+
select: Function;
|
|
40
|
+
/**
|
|
41
|
+
* Given a namespace key, returns an
|
|
42
|
+
* object of the store's registered
|
|
43
|
+
* action dispatchers.
|
|
44
|
+
*/
|
|
45
|
+
dispatch: Function;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* An object of registry function overrides.
|
|
49
|
+
*/
|
|
50
|
+
export type WPDataPlugin = {
|
|
51
|
+
/**
|
|
52
|
+
* registers store.
|
|
53
|
+
*/
|
|
54
|
+
registerStore: Function;
|
|
55
|
+
};
|
|
56
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../src/registry.js"],"names":[],"mappings":"AAiDA;;;;;;;;GAQG;AACH,8CALW,MAAM,WACN,MAAM,UAEL,cAAc,CAiSzB"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export default createResolversCacheMiddleware;
|
|
2
|
+
export type WPDataRegistry = import('./registry').WPDataRegistry;
|
|
3
|
+
/** @typedef {import('./registry').WPDataRegistry} WPDataRegistry */
|
|
4
|
+
/**
|
|
5
|
+
* Creates a middleware handling resolvers cache invalidation.
|
|
6
|
+
*
|
|
7
|
+
* @param {WPDataRegistry} registry The registry reference for which to create
|
|
8
|
+
* the middleware.
|
|
9
|
+
* @param {string} reducerKey The namespace for which to create the
|
|
10
|
+
* middleware.
|
|
11
|
+
*
|
|
12
|
+
* @return {Function} Middleware function.
|
|
13
|
+
*/
|
|
14
|
+
declare function createResolversCacheMiddleware(registry: WPDataRegistry, reducerKey: string): Function;
|
|
15
|
+
//# sourceMappingURL=resolvers-cache-middleware.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolvers-cache-middleware.d.ts","sourceRoot":"","sources":["../src/resolvers-cache-middleware.js"],"names":[],"mappings":";6BAUc,OAAO,YAAY,EAAE,cAAc;AAAjD,oEAAoE;AAEpE;;;;;;;;;GASG;AACH,0DAPW,cAAc,cAEd,MAAM,YAwCf"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export default coreDataStore;
|
|
2
|
+
declare namespace coreDataStore {
|
|
3
|
+
const name: string;
|
|
4
|
+
function instantiate(registry: any): {
|
|
5
|
+
getSelectors(): {
|
|
6
|
+
[k: string]: (key: any, ...args: any[]) => any;
|
|
7
|
+
};
|
|
8
|
+
getActions(): {
|
|
9
|
+
[k: string]: (key: any, ...args: any[]) => any;
|
|
10
|
+
};
|
|
11
|
+
subscribe(): () => () => void;
|
|
12
|
+
};
|
|
13
|
+
function instantiate(registry: any): {
|
|
14
|
+
getSelectors(): {
|
|
15
|
+
[k: string]: (key: any, ...args: any[]) => any;
|
|
16
|
+
};
|
|
17
|
+
getActions(): {
|
|
18
|
+
[k: string]: (key: any, ...args: any[]) => any;
|
|
19
|
+
};
|
|
20
|
+
subscribe(): () => () => void;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/store/index.js"],"names":[],"mappings":";;;IAEC;;;;;;;;MAoDC;IApDD;;;;;;;;MAoDC"}
|
package/build-types/types.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ export interface StoreDescriptor<Config extends AnyConfig> {
|
|
|
20
20
|
*/
|
|
21
21
|
instantiate: (registry: DataRegistry) => StoreInstance<Config>;
|
|
22
22
|
}
|
|
23
|
-
export interface ReduxStoreConfig<State, ActionCreators extends MapOf<ActionCreator>, Selectors
|
|
23
|
+
export interface ReduxStoreConfig<State, ActionCreators extends MapOf<ActionCreator>, Selectors> {
|
|
24
24
|
initialState?: State;
|
|
25
25
|
reducer: (state: any, action: any) => any;
|
|
26
26
|
actions?: ActionCreators;
|
|
@@ -28,6 +28,23 @@ export interface ReduxStoreConfig<State, ActionCreators extends MapOf<ActionCrea
|
|
|
28
28
|
selectors?: Selectors;
|
|
29
29
|
controls?: MapOf<Function>;
|
|
30
30
|
}
|
|
31
|
+
export declare type UseSelectReturn<F extends MapSelect | StoreDescriptor<any>> = F extends MapSelect ? ReturnType<F> : F extends StoreDescriptor<any> ? CurriedSelectorsOf<F> : never;
|
|
32
|
+
export declare type MapSelect = (select: SelectFunction) => any;
|
|
33
|
+
export declare type SelectFunction = <S>(store: S) => CurriedSelectorsOf<S>;
|
|
34
|
+
export declare type CurriedSelectorsOf<S> = S extends StoreDescriptor<ReduxStoreConfig<any, any, infer Selectors>> ? {
|
|
35
|
+
[key in keyof Selectors]: CurriedState<Selectors[key]>;
|
|
36
|
+
} : never;
|
|
37
|
+
/**
|
|
38
|
+
* Removes the first argument from a function
|
|
39
|
+
*
|
|
40
|
+
* This is designed to remove the `state` parameter from
|
|
41
|
+
* registered selectors since that argument is supplied
|
|
42
|
+
* by the editor when calling `select(…)`.
|
|
43
|
+
*
|
|
44
|
+
* For functions with no arguments, which some selectors
|
|
45
|
+
* are free to define, returns the original function.
|
|
46
|
+
*/
|
|
47
|
+
export declare type CurriedState<F> = F extends (state: any, ...args: infer P) => infer R ? (...args: P) => R : F;
|
|
31
48
|
export interface DataRegistry {
|
|
32
49
|
register: (store: StoreDescriptor<any>) => void;
|
|
33
50
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,aAAK,KAAK,CAAE,CAAC,IAAK;IAAE,CAAE,IAAI,EAAE,MAAM,GAAI,CAAC,CAAA;CAAE,CAAC;AAE1C,oBAAY,aAAa,GAAG,QAAQ,GAAG,SAAS,CAAC;AACjD,oBAAY,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAAC;AAC5C,oBAAY,QAAQ,GAAG,QAAQ,CAAC;AAEhC,oBAAY,SAAS,GAAG,gBAAgB,CAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAE,CAAC;AAE1D,MAAM,WAAW,aAAa,CAAE,MAAM,SAAS,SAAS;IACvD,YAAY,EAAE,MAAM,WAAW,CAAE,MAAM,CAAE,CAAC;IAC1C,UAAU,EAAE,MAAM,gBAAgB,CAAE,MAAM,CAAE,CAAC;IAC7C,SAAS,EAAE,CAAE,QAAQ,EAAE,MAAM,IAAI,KAAM,MAAM,IAAI,CAAC;CAClD;AAED,MAAM,WAAW,eAAe,CAAE,MAAM,SAAS,SAAS;IACzD;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,WAAW,EAAE,CAAE,QAAQ,EAAE,YAAY,KAAM,aAAa,CAAE,MAAM,CAAE,CAAC;CACnE;AAED,MAAM,WAAW,gBAAgB,CAChC,KAAK,EACL,cAAc,SAAS,KAAK,CAAE,aAAa,CAAE,EAC7C,SAAS
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/data",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.14.0",
|
|
4
4
|
"description": "Data module for WordPress.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -28,12 +28,12 @@
|
|
|
28
28
|
"sideEffects": false,
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@babel/runtime": "^7.16.0",
|
|
31
|
-
"@wordpress/compose": "^5.
|
|
32
|
-
"@wordpress/deprecated": "^3.
|
|
33
|
-
"@wordpress/element": "^4.
|
|
34
|
-
"@wordpress/is-shallow-equal": "^4.
|
|
35
|
-
"@wordpress/priority-queue": "^2.
|
|
36
|
-
"@wordpress/redux-routine": "^4.
|
|
31
|
+
"@wordpress/compose": "^5.12.0",
|
|
32
|
+
"@wordpress/deprecated": "^3.14.0",
|
|
33
|
+
"@wordpress/element": "^4.12.0",
|
|
34
|
+
"@wordpress/is-shallow-equal": "^4.14.0",
|
|
35
|
+
"@wordpress/priority-queue": "^2.14.0",
|
|
36
|
+
"@wordpress/redux-routine": "^4.14.0",
|
|
37
37
|
"equivalent-key-map": "^0.2.2",
|
|
38
38
|
"is-promise": "^4.0.0",
|
|
39
39
|
"lodash": "^4.17.21",
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"publishConfig": {
|
|
48
48
|
"access": "public"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "0315dbc240cb2aa146d7c1bafd251f004b88300e"
|
|
51
51
|
}
|
|
@@ -17,10 +17,11 @@ export const AsyncModeConsumer = Consumer;
|
|
|
17
17
|
*
|
|
18
18
|
* ```js
|
|
19
19
|
* import { useSelect, AsyncModeProvider } from '@wordpress/data';
|
|
20
|
+
* import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
20
21
|
*
|
|
21
22
|
* function BlockCount() {
|
|
22
23
|
* const count = useSelect( ( select ) => {
|
|
23
|
-
* return select(
|
|
24
|
+
* return select( blockEditorStore ).getBlockCount()
|
|
24
25
|
* }, [] );
|
|
25
26
|
*
|
|
26
27
|
* return count;
|
|
@@ -25,6 +25,7 @@ import useRegistry from '../registry-provider/use-registry';
|
|
|
25
25
|
* ```jsx
|
|
26
26
|
* import { useDispatch, useSelect } from '@wordpress/data';
|
|
27
27
|
* import { useCallback } from '@wordpress/element';
|
|
28
|
+
* import { store as myCustomStore } from 'my-custom-store';
|
|
28
29
|
*
|
|
29
30
|
* function Button( { onClick, children } ) {
|
|
30
31
|
* return <button type="button" onClick={ onClick }>{ children }</button>
|
|
@@ -32,10 +33,10 @@ import useRegistry from '../registry-provider/use-registry';
|
|
|
32
33
|
*
|
|
33
34
|
* const SaleButton = ( { children } ) => {
|
|
34
35
|
* const { stockNumber } = useSelect(
|
|
35
|
-
* ( select ) => select(
|
|
36
|
+
* ( select ) => select( myCustomStore ).getStockNumber(),
|
|
36
37
|
* []
|
|
37
38
|
* );
|
|
38
|
-
* const { startSale } = useDispatch(
|
|
39
|
+
* const { startSale } = useDispatch( myCustomStore );
|
|
39
40
|
* const onClick = useCallback( () => {
|
|
40
41
|
* const discountPercent = stockNumber > 50 ? 10: 20;
|
|
41
42
|
* startSale( discountPercent );
|
|
@@ -7,7 +7,13 @@ import { useMemoOne } from 'use-memo-one';
|
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
9
|
import { createQueue } from '@wordpress/priority-queue';
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
useRef,
|
|
12
|
+
useCallback,
|
|
13
|
+
useMemo,
|
|
14
|
+
useReducer,
|
|
15
|
+
useDebugValue,
|
|
16
|
+
} from '@wordpress/element';
|
|
11
17
|
import isShallowEqual from '@wordpress/is-shallow-equal';
|
|
12
18
|
import { useIsomorphicLayoutEffect } from '@wordpress/compose';
|
|
13
19
|
|
|
@@ -20,7 +26,19 @@ import useAsyncMode from '../async-mode-provider/use-async-mode';
|
|
|
20
26
|
const noop = () => {};
|
|
21
27
|
const renderQueue = createQueue();
|
|
22
28
|
|
|
23
|
-
/**
|
|
29
|
+
/**
|
|
30
|
+
* @typedef {import('../../types').StoreDescriptor<C>} StoreDescriptor
|
|
31
|
+
* @template C
|
|
32
|
+
*/
|
|
33
|
+
/**
|
|
34
|
+
* @typedef {import('../../types').ReduxStoreConfig<State,Actions,Selectors>} ReduxStoreConfig
|
|
35
|
+
* @template State,Actions,Selectors
|
|
36
|
+
*/
|
|
37
|
+
/**
|
|
38
|
+
* @typedef {import('../../types').UseSelectReturn<T>} UseSelectReturn
|
|
39
|
+
* @template T
|
|
40
|
+
*/
|
|
41
|
+
/** @typedef {import('../../types').MapSelect} MapSelect */
|
|
24
42
|
|
|
25
43
|
/**
|
|
26
44
|
* Custom react hook for retrieving props from registered selectors.
|
|
@@ -28,28 +46,25 @@ const renderQueue = createQueue();
|
|
|
28
46
|
* In general, this custom React hook follows the
|
|
29
47
|
* [rules of hooks](https://reactjs.org/docs/hooks-rules.html).
|
|
30
48
|
*
|
|
31
|
-
* @
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* element tree.
|
|
42
|
-
* @param {Array} deps If provided, this memoizes the mapSelect so the
|
|
43
|
-
* same `mapSelect` is invoked on every state
|
|
44
|
-
* change unless the dependencies change.
|
|
49
|
+
* @template {MapSelect | StoreDescriptor<any>} T
|
|
50
|
+
* @param {T} mapSelect Function called on every state change. The returned value is
|
|
51
|
+
* exposed to the component implementing this hook. The function
|
|
52
|
+
* receives the `registry.select` method on the first argument
|
|
53
|
+
* and the `registry` on the second argument.
|
|
54
|
+
* When a store key is passed, all selectors for the store will be
|
|
55
|
+
* returned. This is only meant for usage of these selectors in event
|
|
56
|
+
* callbacks, not for data needed to create the element tree.
|
|
57
|
+
* @param {unknown[]} deps If provided, this memoizes the mapSelect so the same `mapSelect` is
|
|
58
|
+
* invoked on every state change unless the dependencies change.
|
|
45
59
|
*
|
|
46
60
|
* @example
|
|
47
61
|
* ```js
|
|
48
62
|
* import { useSelect } from '@wordpress/data';
|
|
63
|
+
* import { store as myCustomStore } from 'my-custom-store';
|
|
49
64
|
*
|
|
50
65
|
* function HammerPriceDisplay( { currency } ) {
|
|
51
66
|
* const price = useSelect( ( select ) => {
|
|
52
|
-
* return select(
|
|
67
|
+
* return select( myCustomStore ).getPrice( 'hammer', currency );
|
|
53
68
|
* }, [ currency ] );
|
|
54
69
|
* return new Intl.NumberFormat( 'en-US', {
|
|
55
70
|
* style: 'currency',
|
|
@@ -76,9 +91,10 @@ const renderQueue = createQueue();
|
|
|
76
91
|
*
|
|
77
92
|
* ```js
|
|
78
93
|
* import { useSelect } from '@wordpress/data';
|
|
94
|
+
* import { store as myCustomStore } from 'my-custom-store';
|
|
79
95
|
*
|
|
80
96
|
* function Paste( { children } ) {
|
|
81
|
-
* const { getSettings } = useSelect(
|
|
97
|
+
* const { getSettings } = useSelect( myCustomStore );
|
|
82
98
|
* function onPaste() {
|
|
83
99
|
* // Do something with the settings.
|
|
84
100
|
* const settings = getSettings();
|
|
@@ -86,8 +102,7 @@ const renderQueue = createQueue();
|
|
|
86
102
|
* return <div onPaste={ onPaste }>{ children }</div>;
|
|
87
103
|
* }
|
|
88
104
|
* ```
|
|
89
|
-
*
|
|
90
|
-
* @return {Function} A custom react hook.
|
|
105
|
+
* @return {UseSelectReturn<T>} A custom react hook.
|
|
91
106
|
*/
|
|
92
107
|
export default function useSelect( mapSelect, deps ) {
|
|
93
108
|
const hasMappingFunction = 'function' === typeof mapSelect;
|
|
@@ -239,6 +254,8 @@ export default function useSelect( mapSelect, deps ) {
|
|
|
239
254
|
// examining every individual value inside the `deps` array.
|
|
240
255
|
}, [ registry, wrapSelect, hasMappingFunction, depsChangedFlag ] );
|
|
241
256
|
|
|
257
|
+
useDebugValue( mapOutput );
|
|
258
|
+
|
|
242
259
|
return hasMappingFunction ? mapOutput : registry.select( mapSelect );
|
|
243
260
|
}
|
|
244
261
|
|
|
@@ -26,9 +26,10 @@ import { useDispatchWithMap } from '../use-dispatch';
|
|
|
26
26
|
* }
|
|
27
27
|
*
|
|
28
28
|
* import { withDispatch } from '@wordpress/data';
|
|
29
|
+
* import { store as myCustomStore } from 'my-custom-store';
|
|
29
30
|
*
|
|
30
31
|
* const SaleButton = withDispatch( ( dispatch, ownProps ) => {
|
|
31
|
-
* const { startSale } = dispatch(
|
|
32
|
+
* const { startSale } = dispatch( myCustomStore );
|
|
32
33
|
* const { discountPercent } = ownProps;
|
|
33
34
|
*
|
|
34
35
|
* return {
|
|
@@ -63,11 +64,12 @@ import { useDispatchWithMap } from '../use-dispatch';
|
|
|
63
64
|
* }
|
|
64
65
|
*
|
|
65
66
|
* import { withDispatch } from '@wordpress/data';
|
|
67
|
+
* import { store as myCustomStore } from 'my-custom-store';
|
|
66
68
|
*
|
|
67
69
|
* const SaleButton = withDispatch( ( dispatch, ownProps, { select } ) => {
|
|
68
70
|
* // Stock number changes frequently.
|
|
69
|
-
* const { getStockNumber } = select(
|
|
70
|
-
* const { startSale } = dispatch(
|
|
71
|
+
* const { getStockNumber } = select( myCustomStore );
|
|
72
|
+
* const { startSale } = dispatch( myCustomStore );
|
|
71
73
|
* return {
|
|
72
74
|
* onClick() {
|
|
73
75
|
* const discountPercent = getStockNumber() > 50 ? 10 : 20;
|
|
@@ -19,6 +19,7 @@ import useSelect from '../use-select';
|
|
|
19
19
|
* @example
|
|
20
20
|
* ```js
|
|
21
21
|
* import { withSelect } from '@wordpress/data';
|
|
22
|
+
* import { store as myCustomStore } from 'my-custom-store';
|
|
22
23
|
*
|
|
23
24
|
* function PriceDisplay( { price, currency } ) {
|
|
24
25
|
* return new Intl.NumberFormat( 'en-US', {
|
|
@@ -28,7 +29,7 @@ import useSelect from '../use-select';
|
|
|
28
29
|
* }
|
|
29
30
|
*
|
|
30
31
|
* const HammerPriceDisplay = withSelect( ( select, ownProps ) => {
|
|
31
|
-
* const { getPrice } = select(
|
|
32
|
+
* const { getPrice } = select( myCustomStore );
|
|
32
33
|
* const { currency } = ownProps;
|
|
33
34
|
*
|
|
34
35
|
* return {
|
package/src/controls.js
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { isObject } from 'lodash';
|
|
5
|
-
|
|
6
1
|
/**
|
|
7
2
|
* Internal dependencies
|
|
8
3
|
*/
|
|
@@ -14,6 +9,10 @@ const SELECT = '@@data/SELECT';
|
|
|
14
9
|
const RESOLVE_SELECT = '@@data/RESOLVE_SELECT';
|
|
15
10
|
const DISPATCH = '@@data/DISPATCH';
|
|
16
11
|
|
|
12
|
+
function isObject( object ) {
|
|
13
|
+
return object !== null && typeof object === 'object';
|
|
14
|
+
}
|
|
15
|
+
|
|
17
16
|
/**
|
|
18
17
|
* Dispatches a control action for triggering a synchronous registry select.
|
|
19
18
|
*
|
package/src/factory.js
CHANGED
|
@@ -13,15 +13,18 @@
|
|
|
13
13
|
*
|
|
14
14
|
* @example
|
|
15
15
|
* ```js
|
|
16
|
+
* import { store as coreStore } from '@wordpress/core-data';
|
|
17
|
+
* import { store as editorStore } from '@wordpress/editor';
|
|
18
|
+
*
|
|
16
19
|
* const getCurrentPostId = createRegistrySelector( ( select ) => ( state ) => {
|
|
17
|
-
* return select(
|
|
20
|
+
* return select( editorStore ).getCurrentPostId();
|
|
18
21
|
* } );
|
|
19
22
|
*
|
|
20
23
|
* const getPostEdits = createRegistrySelector( ( select ) => ( state ) => {
|
|
21
24
|
* // calling another registry selector just like any other function
|
|
22
25
|
* const postType = getCurrentPostType( state );
|
|
23
26
|
* const postId = getCurrentPostId( state );
|
|
24
|
-
* return select(
|
|
27
|
+
* return select( coreStore ).getEntityRecordEdits( 'postType', postType, postId );
|
|
25
28
|
* } );
|
|
26
29
|
* ```
|
|
27
30
|
*
|
package/src/index.js
CHANGED
|
@@ -80,18 +80,20 @@ export { plugins };
|
|
|
80
80
|
export { combineReducers };
|
|
81
81
|
|
|
82
82
|
/**
|
|
83
|
-
* Given
|
|
83
|
+
* Given a store descriptor, returns an object of the store's selectors.
|
|
84
84
|
* The selector functions are been pre-bound to pass the current state automatically.
|
|
85
85
|
* As a consumer, you need only pass arguments of the selector, if applicable.
|
|
86
86
|
*
|
|
87
|
-
* @param {string
|
|
88
|
-
*
|
|
87
|
+
* @param {StoreDescriptor|string} storeNameOrDescriptor The store descriptor. The legacy calling
|
|
88
|
+
* convention of passing the store name is
|
|
89
|
+
* also supported.
|
|
89
90
|
*
|
|
90
91
|
* @example
|
|
91
92
|
* ```js
|
|
92
93
|
* import { select } from '@wordpress/data';
|
|
94
|
+
* import { store as myCustomStore } from 'my-custom-store';
|
|
93
95
|
*
|
|
94
|
-
* select(
|
|
96
|
+
* select( myCustomStore ).getPrice( 'hammer' );
|
|
95
97
|
* ```
|
|
96
98
|
*
|
|
97
99
|
* @return {Object} Object containing the store's selectors.
|
|
@@ -99,19 +101,20 @@ export { combineReducers };
|
|
|
99
101
|
export const select = defaultRegistry.select;
|
|
100
102
|
|
|
101
103
|
/**
|
|
102
|
-
* Given
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
* after any resolvers have ran.
|
|
104
|
+
* Given a store descriptor, returns an object containing the store's selectors pre-bound to state
|
|
105
|
+
* so that you only need to supply additional arguments, and modified so that they return promises
|
|
106
|
+
* that resolve to their eventual values, after any resolvers have ran.
|
|
106
107
|
*
|
|
107
|
-
* @param {string
|
|
108
|
-
*
|
|
108
|
+
* @param {StoreDescriptor|string} storeNameOrDescriptor The store descriptor. The legacy calling
|
|
109
|
+
* convention of passing the store name is
|
|
110
|
+
* also supported.
|
|
109
111
|
*
|
|
110
112
|
* @example
|
|
111
113
|
* ```js
|
|
112
114
|
* import { resolveSelect } from '@wordpress/data';
|
|
115
|
+
* import { store as myCustomStore } from 'my-custom-store';
|
|
113
116
|
*
|
|
114
|
-
* resolveSelect(
|
|
117
|
+
* resolveSelect( myCustomStore ).getPrice( 'hammer' ).then(console.log)
|
|
115
118
|
* ```
|
|
116
119
|
*
|
|
117
120
|
* @return {Object} Object containing the store's promise-wrapped selectors.
|
|
@@ -119,32 +122,35 @@ export const select = defaultRegistry.select;
|
|
|
119
122
|
export const resolveSelect = defaultRegistry.resolveSelect;
|
|
120
123
|
|
|
121
124
|
/**
|
|
122
|
-
* Given
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
+
* Given a store descriptor, returns an object containing the store's selectors pre-bound to state
|
|
126
|
+
* so that you only need to supply additional arguments, and modified so that they throw promises
|
|
127
|
+
* in case the selector is not resolved yet.
|
|
125
128
|
*
|
|
126
|
-
* @param {string
|
|
127
|
-
*
|
|
129
|
+
* @param {StoreDescriptor|string} storeNameOrDescriptor The store descriptor. The legacy calling
|
|
130
|
+
* convention of passing the store name is
|
|
131
|
+
* also supported.
|
|
128
132
|
*
|
|
129
133
|
* @return {Object} Object containing the store's suspense-wrapped selectors.
|
|
130
134
|
*/
|
|
131
135
|
export const suspendSelect = defaultRegistry.suspendSelect;
|
|
132
136
|
|
|
133
137
|
/**
|
|
134
|
-
* Given
|
|
138
|
+
* Given a store descriptor, returns an object of the store's action creators.
|
|
135
139
|
* Calling an action creator will cause it to be dispatched, updating the state value accordingly.
|
|
136
140
|
*
|
|
137
141
|
* Note: Action creators returned by the dispatch will return a promise when
|
|
138
142
|
* they are called.
|
|
139
143
|
*
|
|
140
|
-
* @param {string
|
|
141
|
-
*
|
|
144
|
+
* @param {StoreDescriptor|string} storeNameOrDescriptor The store descriptor. The legacy calling
|
|
145
|
+
* convention of passing the store name is
|
|
146
|
+
* also supported.
|
|
142
147
|
*
|
|
143
148
|
* @example
|
|
144
149
|
* ```js
|
|
145
150
|
* import { dispatch } from '@wordpress/data';
|
|
151
|
+
* import { store as myCustomStore } from 'my-custom-store';
|
|
146
152
|
*
|
|
147
|
-
* dispatch(
|
|
153
|
+
* dispatch( myCustomStore ).setPrice( 'hammer', 9.75 );
|
|
148
154
|
* ```
|
|
149
155
|
* @return {Object} Object containing the action creators.
|
|
150
156
|
*/
|