@wordpress/data
Advanced tools
Comparing version 4.24.0 to 4.25.0
/** | ||
* Internal dependencies | ||
*/ | ||
import defaultRegistry from './default-registry'; | ||
/** @typedef {import('./registry').WPDataRegistry} WPDataRegistry */ | ||
/** | ||
* Creates a selector function that takes additional curried argument with the | ||
@@ -44,3 +38,2 @@ * registry `select` function. While a regular selector has signature | ||
*/ | ||
export function createRegistrySelector(registrySelector) { | ||
@@ -63,11 +56,2 @@ // create a selector function that is bound to the registry referenced by `selector.registry` | ||
selector.isRegistrySelector = true; | ||
/** | ||
* Registry on which to call `select`. The `defaultRegistry` value is overwritten with | ||
* the actual registry when the selector is registered with a store. Therefore, it's never | ||
* used and is assigned here only to satisfy the type constraint of the `registry` field. | ||
* | ||
* @type {WPDataRegistry} | ||
*/ | ||
selector.registry = defaultRegistry; | ||
return selector; | ||
@@ -74,0 +58,0 @@ } |
@@ -20,2 +20,3 @@ /** | ||
export { createRegistrySelector, createRegistryControl } from './factory'; | ||
export { controls } from './controls'; | ||
/** | ||
@@ -22,0 +23,0 @@ * Object of available plugins to use with a registry. |
@@ -25,2 +25,3 @@ import _regeneratorRuntime from "@babel/runtime/regenerator"; | ||
import { builtinControls } from '../controls'; | ||
import promise from '../promise-middleware'; | ||
@@ -168,11 +169,8 @@ import createResolversCacheMiddleware from '../resolvers-cache-middleware'; | ||
function createReduxStore(key, options, registry) { | ||
var middlewares = [createResolversCacheMiddleware(registry, key), promise]; | ||
var controls = _objectSpread(_objectSpread({}, options.controls), builtinControls); | ||
if (options.controls) { | ||
var normalizedControls = mapValues(options.controls, function (control) { | ||
return control.isRegistryControl ? control(registry) : control; | ||
}); | ||
middlewares.push(createReduxRoutineMiddleware(normalizedControls)); | ||
} | ||
var normalizedControls = mapValues(controls, function (control) { | ||
return control.isRegistryControl ? control(registry) : control; | ||
}); | ||
var middlewares = [createResolversCacheMiddleware(registry, key), promise, createReduxRoutineMiddleware(normalizedControls)]; | ||
var enhancers = [applyMiddleware.apply(void 0, middlewares)]; | ||
@@ -179,0 +177,0 @@ |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -11,11 +9,3 @@ value: true | ||
var _defaultRegistry = _interopRequireDefault(require("./default-registry")); | ||
/** | ||
* Internal dependencies | ||
*/ | ||
/** @typedef {import('./registry').WPDataRegistry} WPDataRegistry */ | ||
/** | ||
* Creates a selector function that takes additional curried argument with the | ||
@@ -74,11 +64,2 @@ * registry `select` function. While a regular selector has signature | ||
selector.isRegistrySelector = true; | ||
/** | ||
* Registry on which to call `select`. The `defaultRegistry` value is overwritten with | ||
* the actual registry when the selector is registered with a store. Therefore, it's never | ||
* used and is assigned here only to satisfy the type constraint of the `registry` field. | ||
* | ||
* @type {WPDataRegistry} | ||
*/ | ||
selector.registry = _defaultRegistry.default; | ||
return selector; | ||
@@ -85,0 +66,0 @@ } |
@@ -88,2 +88,8 @@ "use strict"; | ||
}); | ||
Object.defineProperty(exports, "controls", { | ||
enumerable: true, | ||
get: function get() { | ||
return _controls.controls; | ||
} | ||
}); | ||
exports.plugins = exports.use = exports.registerStore = exports.registerGenericStore = exports.subscribe = exports.dispatch = exports.__experimentalResolveSelect = exports.select = void 0; | ||
@@ -117,2 +123,4 @@ | ||
var _controls = require("./controls"); | ||
/** | ||
@@ -119,0 +127,0 @@ * External dependencies |
@@ -28,2 +28,4 @@ "use strict"; | ||
var _controls = require("../controls"); | ||
var _promiseMiddleware = _interopRequireDefault(require("../promise-middleware")); | ||
@@ -180,11 +182,8 @@ | ||
function createReduxStore(key, options, registry) { | ||
var middlewares = [(0, _resolversCacheMiddleware.default)(registry, key), _promiseMiddleware.default]; | ||
var controls = _objectSpread(_objectSpread({}, options.controls), _controls.builtinControls); | ||
if (options.controls) { | ||
var normalizedControls = (0, _lodash.mapValues)(options.controls, function (control) { | ||
return control.isRegistryControl ? control(registry) : control; | ||
}); | ||
middlewares.push((0, _reduxRoutine.default)(normalizedControls)); | ||
} | ||
var normalizedControls = (0, _lodash.mapValues)(controls, function (control) { | ||
return control.isRegistryControl ? control(registry) : control; | ||
}); | ||
var middlewares = [(0, _resolversCacheMiddleware.default)(registry, key), _promiseMiddleware.default, (0, _reduxRoutine.default)(normalizedControls)]; | ||
var enhancers = [_redux.applyMiddleware.apply(void 0, middlewares)]; | ||
@@ -191,0 +190,0 @@ |
{ | ||
"name": "@wordpress/data", | ||
"version": "4.24.0", | ||
"version": "4.25.0", | ||
"description": "Data module for WordPress.", | ||
@@ -28,3 +28,3 @@ "author": "The WordPress Contributors", | ||
"@babel/runtime": "^7.11.2", | ||
"@wordpress/compose": "^3.21.0", | ||
"@wordpress/compose": "^3.22.0", | ||
"@wordpress/deprecated": "^2.10.0", | ||
@@ -46,3 +46,3 @@ "@wordpress/element": "^2.18.0", | ||
}, | ||
"gitHead": "cbcd167ffb9b67f87a79df71d95aa48dc4db1a64" | ||
"gitHead": "68a2e6dc7d154f9d33dce06152a8a5bdd28b6e90" | ||
} |
@@ -335,2 +335,6 @@ # Data | ||
<a name="controls" href="#controls">#</a> **controls** | ||
Undocumented declaration. | ||
<a name="createRegistry" href="#createRegistry">#</a> **createRegistry** | ||
@@ -337,0 +341,0 @@ |
/** | ||
* Internal dependencies | ||
*/ | ||
import defaultRegistry from './default-registry'; | ||
/** @typedef {import('./registry').WPDataRegistry} WPDataRegistry */ | ||
/** | ||
* Creates a selector function that takes additional curried argument with the | ||
@@ -61,11 +54,2 @@ * registry `select` function. While a regular selector has signature | ||
/** | ||
* Registry on which to call `select`. The `defaultRegistry` value is overwritten with | ||
* the actual registry when the selector is registered with a store. Therefore, it's never | ||
* used and is assigned here only to satisfy the type constraint of the `registry` field. | ||
* | ||
* @type {WPDataRegistry} | ||
*/ | ||
selector.registry = defaultRegistry; | ||
return selector; | ||
@@ -72,0 +56,0 @@ } |
@@ -25,2 +25,3 @@ /** | ||
export { createRegistrySelector, createRegistryControl } from './factory'; | ||
export { controls } from './controls'; | ||
@@ -27,0 +28,0 @@ /** |
@@ -17,2 +17,3 @@ /** | ||
*/ | ||
import { builtinControls } from '../controls'; | ||
import promise from '../promise-middleware'; | ||
@@ -160,14 +161,17 @@ import createResolversCacheMiddleware from '../resolvers-cache-middleware'; | ||
function createReduxStore( key, options, registry ) { | ||
const controls = { | ||
...options.controls, | ||
...builtinControls, | ||
}; | ||
const normalizedControls = mapValues( controls, ( control ) => | ||
control.isRegistryControl ? control( registry ) : control | ||
); | ||
const middlewares = [ | ||
createResolversCacheMiddleware( registry, key ), | ||
promise, | ||
createReduxRoutineMiddleware( normalizedControls ), | ||
]; | ||
if ( options.controls ) { | ||
const normalizedControls = mapValues( options.controls, ( control ) => { | ||
return control.isRegistryControl ? control( registry ) : control; | ||
} ); | ||
middlewares.push( createReduxRoutineMiddleware( normalizedControls ) ); | ||
} | ||
const enhancers = [ applyMiddleware( ...middlewares ) ]; | ||
@@ -174,0 +178,0 @@ if ( |
@@ -578,13 +578,2 @@ /** | ||
} ); | ||
it( 'gracefully stubs select on selector calls', () => { | ||
const selector = createRegistrySelector( ( select ) => () => | ||
select | ||
); | ||
const maybeSelect = selector(); | ||
expect( maybeSelect ).toEqual( expect.any( Function ) ); | ||
expect( maybeSelect() ).toEqual( expect.any( Object ) ); | ||
} ); | ||
} ); | ||
@@ -591,0 +580,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
620427
173
9791
859
Updated@wordpress/compose@^3.22.0