@wordpress/data 10.41.0 → 10.41.1-next.v.202603102151.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 +20 -28
- package/build/components/async-mode-provider/context.cjs +1 -1
- package/build/components/async-mode-provider/context.cjs.map +3 -3
- package/build/components/async-mode-provider/index.cjs +1 -1
- package/build/components/async-mode-provider/index.cjs.map +1 -1
- package/build/components/async-mode-provider/use-async-mode.cjs +1 -1
- package/build/components/async-mode-provider/use-async-mode.cjs.map +3 -3
- package/build/components/registry-provider/context.cjs +1 -1
- package/build/components/registry-provider/context.cjs.map +1 -1
- package/build/components/registry-provider/index.cjs +1 -1
- package/build/components/registry-provider/index.cjs.map +1 -1
- package/build/components/registry-provider/use-registry.cjs +1 -1
- package/build/components/registry-provider/use-registry.cjs.map +3 -3
- package/build/components/use-dispatch/index.cjs +1 -1
- package/build/components/use-dispatch/index.cjs.map +1 -1
- package/build/components/use-dispatch/use-dispatch-with-map.cjs +1 -1
- package/build/components/use-dispatch/use-dispatch-with-map.cjs.map +3 -3
- package/build/components/use-dispatch/use-dispatch.cjs +1 -1
- package/build/components/use-dispatch/use-dispatch.cjs.map +3 -3
- package/build/components/use-select/index.cjs +2 -2
- package/build/components/use-select/index.cjs.map +3 -3
- package/build/components/with-dispatch/index.cjs +1 -1
- package/build/components/with-dispatch/index.cjs.map +3 -3
- package/build/components/with-registry/index.cjs +1 -1
- package/build/components/with-registry/index.cjs.map +3 -3
- package/build/components/with-select/index.cjs +1 -1
- package/build/components/with-select/index.cjs.map +3 -3
- package/build/controls.cjs +7 -6
- package/build/controls.cjs.map +3 -3
- package/build/default-registry.cjs +3 -2
- package/build/default-registry.cjs.map +3 -3
- package/build/dispatch.cjs +3 -1
- package/build/dispatch.cjs.map +2 -2
- package/build/factory.cjs.map +2 -2
- package/build/index.cjs +9 -8
- package/build/index.cjs.map +3 -3
- package/build/plugins/index.cjs +1 -1
- package/build/plugins/index.cjs.map +1 -1
- package/build/plugins/persistence/index.cjs +13 -8
- package/build/plugins/persistence/index.cjs.map +3 -3
- package/build/plugins/persistence/storage/default.cjs +1 -1
- package/build/plugins/persistence/storage/default.cjs.map +3 -3
- package/build/plugins/persistence/storage/object.cjs +1 -1
- package/build/plugins/persistence/storage/object.cjs.map +3 -3
- package/build/promise-middleware.cjs +2 -1
- package/build/promise-middleware.cjs.map +3 -3
- package/build/redux-store/index.cjs +32 -16
- package/build/redux-store/index.cjs.map +3 -3
- package/build/redux-store/metadata/selectors.cjs +1 -1
- package/build/redux-store/metadata/selectors.cjs.map +3 -3
- package/build/redux-store/metadata/types.cjs +19 -0
- package/build/redux-store/metadata/types.cjs.map +7 -0
- package/build/registry.cjs +11 -7
- package/build/registry.cjs.map +3 -3
- package/build/resolvers-cache-middleware.cjs +6 -3
- package/build/resolvers-cache-middleware.cjs.map +3 -3
- package/build/select.cjs +3 -1
- package/build/select.cjs.map +2 -2
- package/build/store/index.cjs +1 -1
- package/build/store/index.cjs.map +3 -3
- package/build/types.cjs.map +1 -1
- package/build-module/components/async-mode-provider/context.mjs +1 -1
- package/build-module/components/async-mode-provider/context.mjs.map +3 -3
- package/build-module/components/async-mode-provider/index.mjs +1 -1
- package/build-module/components/async-mode-provider/index.mjs.map +1 -1
- package/build-module/components/async-mode-provider/use-async-mode.mjs +1 -1
- package/build-module/components/async-mode-provider/use-async-mode.mjs.map +3 -3
- package/build-module/components/registry-provider/context.mjs +1 -1
- package/build-module/components/registry-provider/context.mjs.map +1 -1
- package/build-module/components/registry-provider/index.mjs +1 -1
- package/build-module/components/registry-provider/index.mjs.map +1 -1
- package/build-module/components/registry-provider/use-registry.mjs +1 -1
- package/build-module/components/registry-provider/use-registry.mjs.map +3 -3
- package/build-module/components/use-dispatch/index.mjs +1 -1
- package/build-module/components/use-dispatch/index.mjs.map +1 -1
- package/build-module/components/use-dispatch/use-dispatch-with-map.mjs +1 -1
- package/build-module/components/use-dispatch/use-dispatch-with-map.mjs.map +3 -3
- package/build-module/components/use-dispatch/use-dispatch.mjs +1 -1
- package/build-module/components/use-dispatch/use-dispatch.mjs.map +3 -3
- package/build-module/components/use-select/index.mjs +2 -2
- package/build-module/components/use-select/index.mjs.map +3 -3
- package/build-module/components/with-dispatch/index.mjs +1 -1
- package/build-module/components/with-dispatch/index.mjs.map +3 -3
- package/build-module/components/with-registry/index.mjs +1 -1
- package/build-module/components/with-registry/index.mjs.map +3 -3
- package/build-module/components/with-select/index.mjs +1 -1
- package/build-module/components/with-select/index.mjs.map +3 -3
- package/build-module/controls.mjs +7 -6
- package/build-module/controls.mjs.map +3 -3
- package/build-module/default-registry.mjs +3 -2
- package/build-module/default-registry.mjs.map +3 -3
- package/build-module/dispatch.mjs +3 -1
- package/build-module/dispatch.mjs.map +2 -2
- package/build-module/factory.mjs.map +2 -2
- package/build-module/index.mjs +4 -3
- package/build-module/index.mjs.map +2 -2
- package/build-module/plugins/index.mjs +1 -1
- package/build-module/plugins/index.mjs.map +1 -1
- package/build-module/plugins/persistence/index.mjs +13 -8
- package/build-module/plugins/persistence/index.mjs.map +3 -3
- package/build-module/plugins/persistence/storage/default.mjs +1 -1
- package/build-module/plugins/persistence/storage/default.mjs.map +3 -3
- package/build-module/plugins/persistence/storage/object.mjs +1 -1
- package/build-module/plugins/persistence/storage/object.mjs.map +3 -3
- package/build-module/promise-middleware.mjs +2 -1
- package/build-module/promise-middleware.mjs.map +3 -3
- package/build-module/redux-store/index.mjs +32 -16
- package/build-module/redux-store/index.mjs.map +3 -3
- package/build-module/redux-store/metadata/selectors.mjs +1 -1
- package/build-module/redux-store/metadata/selectors.mjs.map +3 -3
- package/build-module/redux-store/metadata/types.mjs +1 -0
- package/build-module/redux-store/metadata/types.mjs.map +7 -0
- package/build-module/registry.mjs +11 -7
- package/build-module/registry.mjs.map +3 -3
- package/build-module/resolvers-cache-middleware.mjs +6 -3
- package/build-module/resolvers-cache-middleware.mjs.map +3 -3
- package/build-module/select.mjs +3 -1
- package/build-module/select.mjs.map +2 -2
- package/build-module/store/index.mjs +1 -1
- package/build-module/store/index.mjs.map +3 -3
- package/build-types/components/async-mode-provider/context.d.ts +37 -3
- package/build-types/components/async-mode-provider/context.d.ts.map +1 -1
- package/build-types/components/async-mode-provider/index.d.ts +2 -2
- package/build-types/components/async-mode-provider/index.d.ts.map +1 -1
- package/build-types/components/async-mode-provider/use-async-mode.d.ts.map +1 -1
- package/build-types/components/registry-provider/context.d.ts +10 -3
- package/build-types/components/registry-provider/context.d.ts.map +1 -1
- package/build-types/components/registry-provider/index.d.ts +2 -2
- package/build-types/components/registry-provider/index.d.ts.map +1 -1
- package/build-types/components/registry-provider/use-registry.d.ts +3 -2
- package/build-types/components/registry-provider/use-registry.d.ts.map +1 -1
- package/build-types/components/use-dispatch/index.d.ts +2 -2
- package/build-types/components/use-dispatch/index.d.ts.map +1 -1
- package/build-types/components/use-dispatch/use-dispatch-with-map.d.ts +11 -9
- package/build-types/components/use-dispatch/use-dispatch-with-map.d.ts.map +1 -1
- package/build-types/components/use-dispatch/use-dispatch.d.ts +10 -19
- package/build-types/components/use-dispatch/use-dispatch.d.ts.map +1 -1
- package/build-types/components/use-select/index.d.ts +24 -28
- package/build-types/components/use-select/index.d.ts.map +1 -1
- package/build-types/components/with-dispatch/index.d.ts +10 -11
- package/build-types/components/with-dispatch/index.d.ts.map +1 -1
- package/build-types/components/with-registry/index.d.ts +2 -6
- package/build-types/components/with-registry/index.d.ts.map +1 -1
- package/build-types/components/with-select/index.d.ts +7 -8
- package/build-types/components/with-select/index.d.ts.map +1 -1
- package/build-types/controls.d.ts +57 -44
- package/build-types/controls.d.ts.map +1 -1
- package/build-types/default-registry.d.ts +2 -2
- package/build-types/default-registry.d.ts.map +1 -1
- package/build-types/dispatch.d.ts +4 -0
- package/build-types/dispatch.d.ts.map +1 -1
- package/build-types/factory.d.ts +2 -1
- package/build-types/factory.d.ts.map +1 -1
- package/build-types/index.d.ts.map +1 -1
- package/build-types/plugins/index.d.ts +1 -1
- package/build-types/plugins/index.d.ts.map +1 -1
- package/build-types/plugins/persistence/index.d.ts +38 -27
- package/build-types/plugins/persistence/index.d.ts.map +1 -1
- package/build-types/plugins/persistence/storage/default.d.ts +7 -1
- package/build-types/plugins/persistence/storage/default.d.ts.map +1 -1
- package/build-types/plugins/persistence/storage/object.d.ts +4 -5
- package/build-types/plugins/persistence/storage/object.d.ts.map +1 -1
- package/build-types/promise-middleware.d.ts +6 -4
- package/build-types/promise-middleware.d.ts.map +1 -1
- package/build-types/redux-store/index.d.ts +12 -15
- package/build-types/redux-store/index.d.ts.map +1 -1
- package/build-types/redux-store/metadata/selectors.d.ts +45 -50
- package/build-types/redux-store/metadata/selectors.d.ts.map +1 -1
- package/build-types/redux-store/metadata/types.d.ts +48 -0
- package/build-types/redux-store/metadata/types.d.ts.map +1 -0
- package/build-types/registry.d.ts +5 -49
- package/build-types/registry.d.ts.map +1 -1
- package/build-types/resolvers-cache-middleware.d.ts +13 -7
- package/build-types/resolvers-cache-middleware.d.ts.map +1 -1
- package/build-types/select.d.ts +3 -0
- package/build-types/select.d.ts.map +1 -1
- package/build-types/store/index.d.ts +5 -12
- package/build-types/store/index.d.ts.map +1 -1
- package/build-types/types.d.ts +201 -10
- package/build-types/types.d.ts.map +1 -1
- package/package.json +9 -9
- package/src/components/async-mode-provider/{context.js → context.ts} +0 -1
- package/src/components/async-mode-provider/{use-async-mode.js → use-async-mode.ts} +1 -1
- package/src/components/registry-provider/{use-registry.js → use-registry.ts} +3 -2
- package/src/components/use-dispatch/{use-dispatch-with-map.js → use-dispatch-with-map.ts} +18 -9
- package/src/components/use-dispatch/{use-dispatch.js → use-dispatch.ts} +25 -20
- package/src/components/use-select/{index.js → index.ts} +84 -70
- package/src/components/with-dispatch/{index.js → index.tsx} +20 -13
- package/src/components/with-registry/{index.js → index.tsx} +1 -5
- package/src/components/with-select/{index.js → index.tsx} +17 -10
- package/src/{controls.js → controls.ts} +53 -26
- package/src/{default-registry.js → default-registry.ts} +3 -1
- package/src/dispatch.ts +7 -1
- package/src/factory.ts +4 -3
- package/src/index.ts +4 -8
- package/src/plugins/persistence/{index.js → index.ts} +93 -54
- package/src/plugins/persistence/storage/{default.js → default.ts} +3 -2
- package/src/plugins/persistence/storage/object.ts +25 -0
- package/src/{promise-middleware.js → promise-middleware.ts} +3 -3
- package/src/redux-store/{index.js → index.ts} +218 -131
- package/src/redux-store/metadata/{selectors.js → selectors.ts} +83 -54
- package/src/redux-store/metadata/types.ts +100 -0
- package/src/{registry.js → registry.ts} +98 -88
- package/src/{resolvers-cache-middleware.js → resolvers-cache-middleware.ts} +22 -7
- package/src/select.ts +6 -1
- package/src/store/{index.js → index.ts} +13 -8
- package/src/types.ts +263 -24
- package/src/plugins/persistence/storage/object.js +0 -23
- /package/src/components/async-mode-provider/{index.js → index.ts} +0 -0
- /package/src/components/registry-provider/{context.js → context.ts} +0 -0
- /package/src/components/registry-provider/{index.js → index.ts} +0 -0
- /package/src/components/use-dispatch/{index.js → index.ts} +0 -0
- /package/src/plugins/{index.js → index.ts} +0 -0
package/build-types/types.d.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import type { combineReducers as reduxCombineReducers } from 'redux';
|
|
4
|
+
import type { combineReducers as reduxCombineReducers, Store as ReduxStore } from 'redux';
|
|
5
|
+
/**
|
|
6
|
+
* Internal dependencies
|
|
7
|
+
*/
|
|
8
|
+
import type { DataEmitter } from './utils/emitter';
|
|
9
|
+
import type { MetadataSelectors, MetadataActions } from './redux-store/metadata/types';
|
|
5
10
|
type MapOf<T> = {
|
|
6
11
|
[name: string]: T;
|
|
7
12
|
};
|
|
@@ -24,7 +29,7 @@ export interface StoreDescriptor<Config extends AnyConfig = AnyConfig> {
|
|
|
24
29
|
*/
|
|
25
30
|
instantiate: (registry: DataRegistry) => StoreInstance<Config>;
|
|
26
31
|
}
|
|
27
|
-
export interface ReduxStoreConfig<State, ActionCreators
|
|
32
|
+
export interface ReduxStoreConfig<State, ActionCreators, Selectors> {
|
|
28
33
|
initialState?: State;
|
|
29
34
|
reducer: (state: any, action: any) => any;
|
|
30
35
|
actions?: ActionCreators;
|
|
@@ -33,9 +38,9 @@ export interface ReduxStoreConfig<State, ActionCreators extends MapOf<ActionCrea
|
|
|
33
38
|
controls?: MapOf<Function>;
|
|
34
39
|
}
|
|
35
40
|
export type UseSelectReturn<F extends MapSelect | StoreDescriptor<any>> = F extends MapSelect ? ReturnType<F> : F extends StoreDescriptor<any> ? CurriedSelectorsOf<F> : never;
|
|
36
|
-
export type UseDispatchReturn<StoreNameOrDescriptor> = StoreNameOrDescriptor extends StoreDescriptor<any> ? ActionCreatorsOf<
|
|
41
|
+
export type UseDispatchReturn<StoreNameOrDescriptor> = StoreNameOrDescriptor extends StoreDescriptor<any> ? ActionCreatorsOf<StoreNameOrDescriptor> : StoreNameOrDescriptor extends undefined ? DispatchFunction : any;
|
|
37
42
|
export type DispatchFunction = <StoreNameOrDescriptor>(store: StoreNameOrDescriptor) => DispatchReturn<StoreNameOrDescriptor>;
|
|
38
|
-
export type DispatchReturn<StoreNameOrDescriptor> = StoreNameOrDescriptor extends StoreDescriptor<any> ? ActionCreatorsOf<
|
|
43
|
+
export type DispatchReturn<StoreNameOrDescriptor> = StoreNameOrDescriptor extends StoreDescriptor<any> ? ActionCreatorsOf<StoreNameOrDescriptor> : unknown;
|
|
39
44
|
export type MapSelect = (select: SelectFunction, registry: DataRegistry) => any;
|
|
40
45
|
export type SelectFunction = <S>(store: S) => CurriedSelectorsOf<S>;
|
|
41
46
|
/**
|
|
@@ -45,7 +50,7 @@ export type SelectFunction = <S>(store: S) => CurriedSelectorsOf<S>;
|
|
|
45
50
|
export type ListenerFunction = () => void;
|
|
46
51
|
export type CurriedSelectorsOf<S> = S extends StoreDescriptor<ReduxStoreConfig<any, any, infer Selectors>> ? {
|
|
47
52
|
[key in keyof Selectors]: CurriedState<Selectors[key]>;
|
|
48
|
-
} : never;
|
|
53
|
+
} & MetadataSelectors<S> : never;
|
|
49
54
|
/**
|
|
50
55
|
* Like CurriedState but wraps the return type in a Promise.
|
|
51
56
|
* Used for resolveSelect where selectors return promises.
|
|
@@ -131,20 +136,206 @@ export interface SelectorWithCustomCurrySignature {
|
|
|
131
136
|
CurriedSignature: Function;
|
|
132
137
|
PromiseCurriedSignature?: Function;
|
|
133
138
|
}
|
|
139
|
+
/**
|
|
140
|
+
* A store name or store descriptor, used throughout the API.
|
|
141
|
+
*/
|
|
142
|
+
export type StoreNameOrDescriptor = string | StoreDescriptor;
|
|
143
|
+
/**
|
|
144
|
+
* An isolated orchestrator of store registrations.
|
|
145
|
+
*
|
|
146
|
+
* Returned by `createRegistry`. Provides methods to register stores,
|
|
147
|
+
* select data, dispatch actions, and subscribe to changes.
|
|
148
|
+
*/
|
|
134
149
|
export interface DataRegistry {
|
|
150
|
+
batch: (callback: () => void) => void;
|
|
151
|
+
stores: Record<string, InternalStoreInstance>;
|
|
152
|
+
namespaces: Record<string, InternalStoreInstance>;
|
|
153
|
+
subscribe: (listener: ListenerFunction, storeNameOrDescriptor?: StoreNameOrDescriptor) => () => void;
|
|
154
|
+
select: {
|
|
155
|
+
<S extends StoreDescriptor<any>>(store: S): CurriedSelectorsOf<S>;
|
|
156
|
+
(store: StoreNameOrDescriptor): Record<string, (...args: any[]) => any>;
|
|
157
|
+
};
|
|
158
|
+
resolveSelect: {
|
|
159
|
+
<S extends StoreDescriptor<any>>(store: S): CurriedSelectorsResolveOf<S>;
|
|
160
|
+
(store: StoreNameOrDescriptor): Record<string, (...args: any[]) => Promise<any>>;
|
|
161
|
+
};
|
|
162
|
+
suspendSelect: {
|
|
163
|
+
<S extends StoreDescriptor<any>>(store: S): CurriedSelectorsOf<S>;
|
|
164
|
+
(store: StoreNameOrDescriptor): Record<string, (...args: any[]) => any>;
|
|
165
|
+
};
|
|
166
|
+
dispatch: {
|
|
167
|
+
<S extends StoreDescriptor<any>>(store: S): ActionCreatorsOf<S>;
|
|
168
|
+
(store: StoreNameOrDescriptor): Record<string, (...args: any[]) => any>;
|
|
169
|
+
};
|
|
170
|
+
use: (plugin: DataPlugin, options?: Record<string, unknown>) => DataRegistry;
|
|
135
171
|
register: (store: StoreDescriptor<any>) => void;
|
|
136
|
-
|
|
172
|
+
registerGenericStore: (name: string, store: StoreInstance<AnyConfig>) => void;
|
|
173
|
+
registerStore: (storeName: string, options: ReduxStoreConfig<any, any, any>) => ReduxStore;
|
|
174
|
+
__unstableMarkListeningStores: <T>(callback: () => T, ref: {
|
|
175
|
+
current: string[] | null;
|
|
176
|
+
}) => T;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* The plugin function signature.
|
|
180
|
+
*/
|
|
181
|
+
export type DataPlugin = (registry: DataRegistry, options?: Record<string, unknown>) => Partial<DataRegistry>;
|
|
182
|
+
/**
|
|
183
|
+
* Status of a selector resolution.
|
|
184
|
+
*/
|
|
185
|
+
export type ResolutionStatus = 'resolving' | 'finished' | 'error';
|
|
186
|
+
/**
|
|
187
|
+
* State value for a single resolution.
|
|
188
|
+
*/
|
|
189
|
+
export type ResolutionState = {
|
|
190
|
+
status: 'resolving';
|
|
191
|
+
} | {
|
|
192
|
+
status: 'finished';
|
|
193
|
+
} | {
|
|
194
|
+
status: 'error';
|
|
195
|
+
error: Error | unknown;
|
|
196
|
+
};
|
|
197
|
+
/**
|
|
198
|
+
* A normalized resolver with a `fulfill` method and optional `isFulfilled`.
|
|
199
|
+
*/
|
|
200
|
+
export interface NormalizedResolver {
|
|
201
|
+
/**
|
|
202
|
+
* The function to call to fulfill the resolver.
|
|
203
|
+
*/
|
|
204
|
+
fulfill: (...args: any[]) => any;
|
|
205
|
+
/**
|
|
206
|
+
* Optional function to check if the resolver is already fulfilled.
|
|
207
|
+
*/
|
|
208
|
+
isFulfilled?: (state: any, ...args: any[]) => boolean;
|
|
209
|
+
/**
|
|
210
|
+
* Optional function to check if the resolver should be invalidated.
|
|
211
|
+
*/
|
|
212
|
+
shouldInvalidate?: (action: any, ...args: any[]) => boolean;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* A bound selector with optional resolver metadata.
|
|
216
|
+
*/
|
|
217
|
+
export interface BoundSelector {
|
|
218
|
+
(...args: any[]): any;
|
|
219
|
+
/**
|
|
220
|
+
* Whether this selector has a resolver attached.
|
|
221
|
+
*/
|
|
222
|
+
hasResolver: boolean;
|
|
223
|
+
/**
|
|
224
|
+
* Optional function to normalize the arguments.
|
|
225
|
+
*/
|
|
226
|
+
__unstableNormalizeArgs?: (args: any[]) => any[];
|
|
227
|
+
/**
|
|
228
|
+
* Whether this selector is a registry selector.
|
|
229
|
+
*/
|
|
230
|
+
isRegistrySelector?: boolean;
|
|
231
|
+
/**
|
|
232
|
+
* The registry instance this selector is bound to.
|
|
233
|
+
*/
|
|
234
|
+
registry?: DataRegistry;
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* The shape of a store instance as seen internally by the registry.
|
|
238
|
+
* Extends the public StoreInstance with additional internal properties.
|
|
239
|
+
*/
|
|
240
|
+
export interface InternalStoreInstance<Config extends AnyConfig = AnyConfig> extends StoreInstance<Config> {
|
|
241
|
+
/**
|
|
242
|
+
* The Redux store instance (only for Redux-based stores).
|
|
243
|
+
*/
|
|
244
|
+
store?: ReduxStore;
|
|
245
|
+
/**
|
|
246
|
+
* The internal emitter for pause/resume batching.
|
|
247
|
+
*/
|
|
248
|
+
emitter: DataEmitter;
|
|
249
|
+
/**
|
|
250
|
+
* The combined reducer.
|
|
251
|
+
*/
|
|
252
|
+
reducer?: (state: any, action: any) => any;
|
|
253
|
+
/**
|
|
254
|
+
* Bound actions object.
|
|
255
|
+
*/
|
|
256
|
+
actions?: Record<string, ActionCreator>;
|
|
257
|
+
/**
|
|
258
|
+
* Bound selectors object.
|
|
259
|
+
*/
|
|
260
|
+
selectors?: Record<string, Selector>;
|
|
261
|
+
/**
|
|
262
|
+
* Resolver definitions.
|
|
263
|
+
*/
|
|
264
|
+
resolvers?: Record<string, NormalizedResolver>;
|
|
265
|
+
/**
|
|
266
|
+
* Returns resolve-wrapped selectors.
|
|
267
|
+
*/
|
|
268
|
+
getResolveSelectors?: () => Record<string, (...args: any[]) => Promise<any>>;
|
|
269
|
+
/**
|
|
270
|
+
* Returns suspense-wrapped selectors.
|
|
271
|
+
*/
|
|
272
|
+
getSuspendSelectors?: () => Record<string, (...args: any[]) => any>;
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Control descriptor for the controls system.
|
|
276
|
+
*/
|
|
277
|
+
export interface ControlDescriptor {
|
|
278
|
+
/**
|
|
279
|
+
* The type of the control action.
|
|
280
|
+
*/
|
|
281
|
+
type: string;
|
|
282
|
+
/**
|
|
283
|
+
* The store key to target.
|
|
284
|
+
*/
|
|
285
|
+
storeKey: string;
|
|
286
|
+
/**
|
|
287
|
+
* The name of the selector (for select/resolveSelect controls).
|
|
288
|
+
*/
|
|
289
|
+
selectorName?: string;
|
|
290
|
+
/**
|
|
291
|
+
* The name of the action (for dispatch controls).
|
|
292
|
+
*/
|
|
293
|
+
actionName?: string;
|
|
294
|
+
/**
|
|
295
|
+
* Arguments for the selector or action.
|
|
296
|
+
*/
|
|
297
|
+
args: any[];
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Storage interface (Web Storage API subset).
|
|
301
|
+
*/
|
|
302
|
+
export interface StorageInterface {
|
|
303
|
+
getItem: (key: string) => string | null;
|
|
304
|
+
setItem: (key: string, value: string) => void;
|
|
305
|
+
removeItem?: (key: string) => void;
|
|
306
|
+
clear?: VoidFunction;
|
|
137
307
|
}
|
|
138
308
|
export type ConfigOf<S> = S extends StoreDescriptor<infer C> ? C : never;
|
|
139
|
-
export type ActionCreatorsOf<
|
|
140
|
-
export type PromisifiedActionCreators<ActionCreators
|
|
141
|
-
[Action in keyof ActionCreators]: PromisifyActionCreator<ActionCreators[Action]
|
|
309
|
+
export type ActionCreatorsOf<T> = T extends StoreDescriptor<ReduxStoreConfig<any, infer ActionCreators, any>> ? PromisifiedActionCreators<ActionCreators> & MetadataActions<T> : T extends ReduxStoreConfig<any, infer ActionCreators, any> ? PromisifiedActionCreators<ActionCreators> : never;
|
|
310
|
+
export type PromisifiedActionCreators<ActionCreators> = {
|
|
311
|
+
[Action in keyof ActionCreators]: ActionCreators[Action] extends ActionCreator ? PromisifyActionCreator<ActionCreators[Action]> : ActionCreators[Action];
|
|
142
312
|
};
|
|
143
|
-
export type PromisifyActionCreator<Action extends ActionCreator> = (...args: Parameters<Action>) => Promise<ReturnType<Action> extends (..._args: any[]) => any ? ThunkReturnType<Action> : ReturnType<Action>>;
|
|
313
|
+
export type PromisifyActionCreator<Action extends ActionCreator> = (...args: Parameters<Action>) => Promise<ReturnType<Action> extends (..._args: any[]) => any ? ThunkReturnType<Action> : ReturnType<Action> extends Generator<any, infer TReturn, any> ? TReturn : ReturnType<Action>>;
|
|
144
314
|
export type ThunkReturnType<Action extends ActionCreator> = Awaited<ReturnType<ReturnType<Action>>>;
|
|
145
315
|
type SelectorsOf<Config extends AnyConfig> = Config extends ReduxStoreConfig<any, any, infer Selectors> ? {
|
|
146
316
|
[name in keyof Selectors]: Function;
|
|
147
317
|
} : never;
|
|
318
|
+
/**
|
|
319
|
+
* The argument object passed to every thunk function. When parameterized with
|
|
320
|
+
* a store descriptor, `dispatch`, `select`, and `resolveSelect` are fully
|
|
321
|
+
* typed against that store's actions and selectors.
|
|
322
|
+
*
|
|
323
|
+
* @example
|
|
324
|
+
* ```ts
|
|
325
|
+
* const myAction =
|
|
326
|
+
* ( id: number ) =>
|
|
327
|
+
* async ( { dispatch, select }: ThunkArgs< typeof myStore > ) => {
|
|
328
|
+
* const record = select.getRecord( id );
|
|
329
|
+
* dispatch.setLoading( true );
|
|
330
|
+
* };
|
|
331
|
+
* ```
|
|
332
|
+
*/
|
|
333
|
+
export interface ThunkArgs<S extends StoreDescriptor = StoreDescriptor> {
|
|
334
|
+
dispatch: ActionCreatorsOf<S> & ((action: Record<string, unknown> | Function) => unknown);
|
|
335
|
+
select: CurriedSelectorsOf<S>;
|
|
336
|
+
resolveSelect: CurriedSelectorsResolveOf<S>;
|
|
337
|
+
registry: DataRegistry;
|
|
338
|
+
}
|
|
148
339
|
export type combineReducers = typeof reduxCombineReducers;
|
|
149
340
|
export {};
|
|
150
341
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAEX,eAAe,IAAI,oBAAoB,EACvC,KAAK,IAAI,UAAU,EACnB,MAAM,OAAO,CAAC;AAEf;;GAEG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,KAAK,EACX,iBAAiB,EACjB,eAAe,EACf,MAAM,8BAA8B,CAAC;AAEtC,KAAK,KAAK,CAAE,CAAC,IAAK;IAAE,CAAE,IAAI,EAAE,MAAM,GAAI,CAAC,CAAA;CAAE,CAAC;AAE1C,MAAM,MAAM,aAAa,GAAG,CAAE,GAAG,IAAI,EAAE,GAAG,EAAE,KAAM,GAAG,GAAG,SAAS,CAAC;AAClE,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAAC;AAC5C,MAAM,MAAM,QAAQ,GAAG,QAAQ,CAAC;AAEhC,MAAM,MAAM,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,C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AE,GACjE,OAAO,GACP,UAAU,CAAE,MAAM,CAAE,CACvB,CAAC;AAMF,MAAM,MAAM,eAAe,CAAE,MAAM,SAAS,aAAa,IAAK,OAAO,CACpE,UAAU,CAAE,UAAU,CAAE,MAAM,CAAE,CAAE,CAClC,CAAC;AAEF,KAAK,WAAW,CAAE,MAAM,SAAS,SAAS,IAAK,MAAM,SAAS,gBAAgB,CAC7E,GAAG,EACH,GAAG,EACH,MAAM,SAAS,CACf,GACE;KAAI,IAAI,IAAI,MAAM,SAAS,GAAI,QAAQ;CAAE,GACzC,KAAK,CAAC;AAET;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,SAAS,CAAE,CAAC,SAAS,eAAe,GAAG,eAAe;IACtE,QAAQ,EAAE,gBAAgB,CAAE,CAAC,CAAE,GAC9B,CAAE,CAAE,MAAM,EAAE,MAAM,CAAE,MAAM,EAAE,OAAO,CAAE,GAAG,QAAQ,KAAM,OAAO,CAAE,CAAC;IACjE,MAAM,EAAE,kBAAkB,CAAE,CAAC,CAAE,CAAC;IAChC,aAAa,EAAE,yBAAyB,CAAE,CAAC,CAAE,CAAC;IAC9C,QAAQ,EAAE,YAAY,CAAC;CACvB;AAED,MAAM,MAAM,eAAe,GAAG,OAAO,oBAAoB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/data",
|
|
3
|
-
"version": "10.41.0",
|
|
3
|
+
"version": "10.41.1-next.v.202603102151.0+59e17f9ec",
|
|
4
4
|
"description": "Data module for WordPress.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -45,13 +45,13 @@
|
|
|
45
45
|
"types": "build-types",
|
|
46
46
|
"sideEffects": false,
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@wordpress/compose": "^7.41.0",
|
|
49
|
-
"@wordpress/deprecated": "^4.41.0",
|
|
50
|
-
"@wordpress/element": "^6.41.0",
|
|
51
|
-
"@wordpress/is-shallow-equal": "^5.41.0",
|
|
52
|
-
"@wordpress/priority-queue": "^3.41.0",
|
|
53
|
-
"@wordpress/private-apis": "^1.41.0",
|
|
54
|
-
"@wordpress/redux-routine": "^5.41.0",
|
|
48
|
+
"@wordpress/compose": "^7.41.1-next.v.202603102151.0+59e17f9ec",
|
|
49
|
+
"@wordpress/deprecated": "^4.41.1-next.v.202603102151.0+59e17f9ec",
|
|
50
|
+
"@wordpress/element": "^6.41.1-next.v.202603102151.0+59e17f9ec",
|
|
51
|
+
"@wordpress/is-shallow-equal": "^5.41.1-next.v.202603102151.0+59e17f9ec",
|
|
52
|
+
"@wordpress/priority-queue": "^3.41.1-next.v.202603102151.0+59e17f9ec",
|
|
53
|
+
"@wordpress/private-apis": "^1.41.1-next.v.202603102151.0+59e17f9ec",
|
|
54
|
+
"@wordpress/redux-routine": "^5.41.1-next.v.202603102151.0+59e17f9ec",
|
|
55
55
|
"deepmerge": "^4.3.0",
|
|
56
56
|
"equivalent-key-map": "^0.2.2",
|
|
57
57
|
"is-plain-object": "^5.0.0",
|
|
@@ -69,5 +69,5 @@
|
|
|
69
69
|
"publishConfig": {
|
|
70
70
|
"access": "public"
|
|
71
71
|
},
|
|
72
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "86db21e727d89e8f0dbba9300d2f97fd22b08693"
|
|
73
73
|
}
|
|
@@ -43,6 +43,5 @@ export const AsyncModeConsumer = Consumer;
|
|
|
43
43
|
* It is possible to nest multiple levels of AsyncModeProvider to fine-tune the rendering behavior.
|
|
44
44
|
*
|
|
45
45
|
* @param {boolean} props.value Enable Async Mode.
|
|
46
|
-
* @return {Component} The component to be rendered.
|
|
47
46
|
*/
|
|
48
47
|
export default Provider;
|
|
@@ -7,6 +7,7 @@ import { useContext } from '@wordpress/element';
|
|
|
7
7
|
* Internal dependencies
|
|
8
8
|
*/
|
|
9
9
|
import { Context } from './context';
|
|
10
|
+
import type { DataRegistry } from '../../types';
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* A custom react hook exposing the registry context for use.
|
|
@@ -45,8 +46,8 @@ import { Context } from './context';
|
|
|
45
46
|
* };
|
|
46
47
|
* ```
|
|
47
48
|
*
|
|
48
|
-
* @return
|
|
49
|
+
* @return A custom react hook exposing the registry context value.
|
|
49
50
|
*/
|
|
50
|
-
export default function useRegistry() {
|
|
51
|
+
export default function useRegistry(): DataRegistry {
|
|
51
52
|
return useContext( Context );
|
|
52
53
|
}
|
|
@@ -8,6 +8,12 @@ import { useIsomorphicLayoutEffect } from '@wordpress/compose';
|
|
|
8
8
|
* Internal dependencies
|
|
9
9
|
*/
|
|
10
10
|
import useRegistry from '../registry-provider/use-registry';
|
|
11
|
+
import type { DataRegistry } from '../../types';
|
|
12
|
+
|
|
13
|
+
type DispatchMap = (
|
|
14
|
+
dispatch: DataRegistry[ 'dispatch' ],
|
|
15
|
+
registry: DataRegistry
|
|
16
|
+
) => Record< string, ( ...args: unknown[] ) => unknown >;
|
|
11
17
|
|
|
12
18
|
/**
|
|
13
19
|
* Custom react hook for returning aggregate dispatch actions using the provided
|
|
@@ -15,15 +21,18 @@ import useRegistry from '../registry-provider/use-registry';
|
|
|
15
21
|
*
|
|
16
22
|
* Currently this is an internal api only and is implemented by `withDispatch`
|
|
17
23
|
*
|
|
18
|
-
* @param
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* @param
|
|
23
|
-
* @return
|
|
24
|
-
*
|
|
24
|
+
* @param dispatchMap Receives the `registry.dispatch` function as
|
|
25
|
+
* the first argument and the `registry` object
|
|
26
|
+
* as the second argument. Should return an
|
|
27
|
+
* object mapping props to functions.
|
|
28
|
+
* @param deps An array of dependencies for the hook.
|
|
29
|
+
* @return An object mapping props to functions created by the passed
|
|
30
|
+
* in dispatchMap.
|
|
25
31
|
*/
|
|
26
|
-
const useDispatchWithMap = (
|
|
32
|
+
const useDispatchWithMap = (
|
|
33
|
+
dispatchMap: DispatchMap,
|
|
34
|
+
deps: unknown[]
|
|
35
|
+
): Record< string, ( ...args: unknown[] ) => unknown > => {
|
|
27
36
|
const registry = useRegistry();
|
|
28
37
|
const currentDispatchMapRef = useRef( dispatchMap );
|
|
29
38
|
|
|
@@ -47,7 +56,7 @@ const useDispatchWithMap = ( dispatchMap, deps ) => {
|
|
|
47
56
|
}
|
|
48
57
|
return [
|
|
49
58
|
propName,
|
|
50
|
-
( ...args ) =>
|
|
59
|
+
( ...args: unknown[] ) =>
|
|
51
60
|
currentDispatchMapRef
|
|
52
61
|
.current( registry.dispatch, registry )
|
|
53
62
|
[ propName ]( ...args ),
|
|
@@ -2,15 +2,11 @@
|
|
|
2
2
|
* Internal dependencies
|
|
3
3
|
*/
|
|
4
4
|
import useRegistry from '../registry-provider/use-registry';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* @typedef {import('../../types').UseDispatchReturn<StoreNameOrDescriptor>} UseDispatchReturn
|
|
12
|
-
* @template StoreNameOrDescriptor
|
|
13
|
-
*/
|
|
5
|
+
import type {
|
|
6
|
+
StoreDescriptor,
|
|
7
|
+
AnyConfig,
|
|
8
|
+
UseDispatchReturn,
|
|
9
|
+
} from '../../types';
|
|
14
10
|
|
|
15
11
|
/**
|
|
16
12
|
* A custom react hook returning the current registry dispatch actions creators.
|
|
@@ -18,12 +14,11 @@ import useRegistry from '../registry-provider/use-registry';
|
|
|
18
14
|
* Note: The component using this hook must be within the context of a
|
|
19
15
|
* RegistryProvider.
|
|
20
16
|
*
|
|
21
|
-
* @
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* function is returned instead.
|
|
17
|
+
* @param storeNameOrDescriptor Optionally provide the name of the
|
|
18
|
+
* store or its descriptor from which to
|
|
19
|
+
* retrieve action creators. If not
|
|
20
|
+
* provided, the registry.dispatch
|
|
21
|
+
* function is returned instead.
|
|
27
22
|
*
|
|
28
23
|
* @example
|
|
29
24
|
* This illustrates a pattern where you may need to retrieve dynamic data from
|
|
@@ -56,13 +51,23 @@ import useRegistry from '../registry-provider/use-registry';
|
|
|
56
51
|
* //
|
|
57
52
|
* // <SaleButton>Start Sale!</SaleButton>
|
|
58
53
|
* ```
|
|
59
|
-
*
|
|
54
|
+
*
|
|
55
|
+
* @return The dispatch function or action creators for the store.
|
|
60
56
|
*/
|
|
61
|
-
const useDispatch =
|
|
57
|
+
const useDispatch = <
|
|
58
|
+
StoreNameOrDescriptor extends
|
|
59
|
+
| undefined
|
|
60
|
+
| string
|
|
61
|
+
| StoreDescriptor< AnyConfig > = undefined,
|
|
62
|
+
>(
|
|
63
|
+
storeNameOrDescriptor?: StoreNameOrDescriptor
|
|
64
|
+
): UseDispatchReturn< StoreNameOrDescriptor > => {
|
|
62
65
|
const { dispatch } = useRegistry();
|
|
63
|
-
return
|
|
64
|
-
|
|
65
|
-
|
|
66
|
+
return (
|
|
67
|
+
storeNameOrDescriptor === void 0
|
|
68
|
+
? dispatch
|
|
69
|
+
: dispatch( storeNameOrDescriptor as StoreDescriptor< AnyConfig > )
|
|
70
|
+
) as UseDispatchReturn< StoreNameOrDescriptor >;
|
|
66
71
|
};
|
|
67
72
|
|
|
68
73
|
export default useDispatch;
|