@wordpress/data 10.25.0 → 10.26.1-next.719a03cbe.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.
@@ -1 +1 @@
1
- {"version":3,"names":["_redux","require","_equivalentKeyMap","_interopRequireDefault","_reduxRoutine","_compose","_combineReducers","_controls","_lockUnlock","_promiseMiddleware","_resolversCacheMiddleware","_thunkMiddleware","_reducer","metadataSelectors","_interopRequireWildcard","metadataActions","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","trimUndefinedValues","array","result","length","undefined","splice","mapValues","obj","callback","fromEntries","entries","map","key","value","devToolsReplacer","state","Map","window","HTMLElement","createResolversCache","cache","isRunning","selectorName","args","clear","delete","markAsRunning","EquivalentKeyMap","createBindingCache","bind","item","itemName","boundItem","createReduxStore","options","privateActions","privateSelectors","privateRegistrationFunctions","registerPrivateActions","actions","assign","registerPrivateSelectors","selectors","storeDescriptor","name","instantiate","registry","listeners","Set","reducer","thunkArgs","dispatch","thunkActions","select","thunkSelectors","resolveSelect","getResolveSelectors","store","instantiateReduxStore","lock","resolversCache","bindAction","action","Promise","resolve","boundPrivateActions","allActions","Proxy","target","prop","privateAction","apply","thisArg","resolvers","mapResolvers","bindSelector","selector","isRegistrySelector","boundSelector","normalize","__unstableOriginalGetState","root","__unstableNormalizeArgs","resolver","hasResolver","mapSelectorWithResolver","bindMetadataSelector","metaDataSelector","originalSelectorName","originalSelectorArgs","targetSelector","metadata","boundPrivateSelectors","allSelectors","privateSelector","resolveSelectors","mapResolveSelectors","suspendSelectors","mapSuspendSelectors","getSelectors","getActions","getSuspendSelectors","getState","subscribe","listener","add","lastState","hasChanged","controls","builtinControls","normalizedControls","control","isRegistryControl","middlewares","createResolversCacheMiddleware","promise","createReduxRoutineMiddleware","createThunkMiddleware","enhancers","applyMiddleware","__REDUX_DEVTOOLS_EXTENSION__","push","instanceId","serialize","replacer","initialState","enhancedReducer","combineReducers","metadataReducer","createStore","compose","getIsResolving","hasStartedResolution","hasFinishedResolution","hasResolutionFailed","isResolving","getCachedResolvers","getResolutionState","getResolutionError","hasResolvingSelectors","countSelectorsByStatus","storeSelectors","reject","hasFinished","finalize","hasFailed","error","getResult","unsubscribe","fulfill","fulfillSelector","isFulfilled","setTimeout","startResolution","finishResolution","failResolution","selectorResolver"],"sources":["@wordpress/data/src/redux-store/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { createStore, applyMiddleware } from 'redux';\nimport EquivalentKeyMap from 'equivalent-key-map';\n\n/**\n * WordPress dependencies\n */\nimport createReduxRoutineMiddleware from '@wordpress/redux-routine';\nimport { compose } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { combineReducers } from './combine-reducers';\nimport { builtinControls } from '../controls';\nimport { lock } from '../lock-unlock';\nimport promise from '../promise-middleware';\nimport createResolversCacheMiddleware from '../resolvers-cache-middleware';\nimport createThunkMiddleware from './thunk-middleware';\nimport metadataReducer from './metadata/reducer';\nimport * as metadataSelectors from './metadata/selectors';\nimport * as metadataActions from './metadata/actions';\n\nexport { combineReducers };\n\n/** @typedef {import('../types').DataRegistry} DataRegistry */\n/** @typedef {import('../types').ListenerFunction} ListenerFunction */\n/**\n * @typedef {import('../types').StoreDescriptor<C>} StoreDescriptor\n * @template {import('../types').AnyConfig} C\n */\n/**\n * @typedef {import('../types').ReduxStoreConfig<State,Actions,Selectors>} ReduxStoreConfig\n * @template State\n * @template {Record<string,import('../types').ActionCreator>} Actions\n * @template Selectors\n */\n\nconst trimUndefinedValues = ( array ) => {\n\tconst result = [ ...array ];\n\tfor ( let i = result.length - 1; i >= 0; i-- ) {\n\t\tif ( result[ i ] === undefined ) {\n\t\t\tresult.splice( i, 1 );\n\t\t}\n\t}\n\treturn result;\n};\n\n/**\n * Creates a new object with the same keys, but with `callback()` called as\n * a transformer function on each of the values.\n *\n * @param {Object} obj The object to transform.\n * @param {Function} callback The function to transform each object value.\n * @return {Array} Transformed object.\n */\nconst mapValues = ( obj, callback ) =>\n\tObject.fromEntries(\n\t\tObject.entries( obj ?? {} ).map( ( [ key, value ] ) => [\n\t\t\tkey,\n\t\t\tcallback( value, key ),\n\t\t] )\n\t);\n\n// Convert non serializable types to plain objects\nconst devToolsReplacer = ( key, state ) => {\n\tif ( state instanceof Map ) {\n\t\treturn Object.fromEntries( state );\n\t}\n\n\tif ( state instanceof window.HTMLElement ) {\n\t\treturn null;\n\t}\n\n\treturn state;\n};\n\n/**\n * Create a cache to track whether resolvers started running or not.\n *\n * @return {Object} Resolvers Cache.\n */\nfunction createResolversCache() {\n\tconst cache = {};\n\treturn {\n\t\tisRunning( selectorName, args ) {\n\t\t\treturn (\n\t\t\t\tcache[ selectorName ] &&\n\t\t\t\tcache[ selectorName ].get( trimUndefinedValues( args ) )\n\t\t\t);\n\t\t},\n\n\t\tclear( selectorName, args ) {\n\t\t\tif ( cache[ selectorName ] ) {\n\t\t\t\tcache[ selectorName ].delete( trimUndefinedValues( args ) );\n\t\t\t}\n\t\t},\n\n\t\tmarkAsRunning( selectorName, args ) {\n\t\t\tif ( ! cache[ selectorName ] ) {\n\t\t\t\tcache[ selectorName ] = new EquivalentKeyMap();\n\t\t\t}\n\n\t\t\tcache[ selectorName ].set( trimUndefinedValues( args ), true );\n\t\t},\n\t};\n}\n\nfunction createBindingCache( bind ) {\n\tconst cache = new WeakMap();\n\n\treturn {\n\t\tget( item, itemName ) {\n\t\t\tlet boundItem = cache.get( item );\n\t\t\tif ( ! boundItem ) {\n\t\t\t\tboundItem = bind( item, itemName );\n\t\t\t\tcache.set( item, boundItem );\n\t\t\t}\n\t\t\treturn boundItem;\n\t\t},\n\t};\n}\n\n/**\n * Creates a data store descriptor for the provided Redux store configuration containing\n * properties describing reducer, actions, selectors, controls and resolvers.\n *\n * @example\n * ```js\n * import { createReduxStore } from '@wordpress/data';\n *\n * const store = createReduxStore( 'demo', {\n * reducer: ( state = 'OK' ) => state,\n * selectors: {\n * getValue: ( state ) => state,\n * },\n * } );\n * ```\n *\n * @template State\n * @template {Record<string,import('../types').ActionCreator>} Actions\n * @template Selectors\n * @param {string} key Unique namespace identifier.\n * @param {ReduxStoreConfig<State,Actions,Selectors>} options Registered store options, with properties\n * describing reducer, actions, selectors,\n * and resolvers.\n *\n * @return {StoreDescriptor<ReduxStoreConfig<State,Actions,Selectors>>} Store Object.\n */\nexport default function createReduxStore( key, options ) {\n\tconst privateActions = {};\n\tconst privateSelectors = {};\n\tconst privateRegistrationFunctions = {\n\t\tprivateActions,\n\t\tregisterPrivateActions: ( actions ) => {\n\t\t\tObject.assign( privateActions, actions );\n\t\t},\n\t\tprivateSelectors,\n\t\tregisterPrivateSelectors: ( selectors ) => {\n\t\t\tObject.assign( privateSelectors, selectors );\n\t\t},\n\t};\n\tconst storeDescriptor = {\n\t\tname: key,\n\t\tinstantiate: ( registry ) => {\n\t\t\t/**\n\t\t\t * Stores listener functions registered with `subscribe()`.\n\t\t\t *\n\t\t\t * When functions register to listen to store changes with\n\t\t\t * `subscribe()` they get added here. Although Redux offers\n\t\t\t * its own `subscribe()` function directly, by wrapping the\n\t\t\t * subscription in this store instance it's possible to\n\t\t\t * optimize checking if the state has changed before calling\n\t\t\t * each listener.\n\t\t\t *\n\t\t\t * @type {Set<ListenerFunction>}\n\t\t\t */\n\t\t\tconst listeners = new Set();\n\t\t\tconst reducer = options.reducer;\n\t\t\tconst thunkArgs = {\n\t\t\t\tregistry,\n\t\t\t\tget dispatch() {\n\t\t\t\t\treturn thunkActions;\n\t\t\t\t},\n\t\t\t\tget select() {\n\t\t\t\t\treturn thunkSelectors;\n\t\t\t\t},\n\t\t\t\tget resolveSelect() {\n\t\t\t\t\treturn getResolveSelectors();\n\t\t\t\t},\n\t\t\t};\n\n\t\t\tconst store = instantiateReduxStore(\n\t\t\t\tkey,\n\t\t\t\toptions,\n\t\t\t\tregistry,\n\t\t\t\tthunkArgs\n\t\t\t);\n\t\t\t// Expose the private registration functions on the store\n\t\t\t// so they can be copied to a sub registry in registry.js.\n\t\t\tlock( store, privateRegistrationFunctions );\n\t\t\tconst resolversCache = createResolversCache();\n\n\t\t\tfunction bindAction( action ) {\n\t\t\t\treturn ( ...args ) =>\n\t\t\t\t\tPromise.resolve( store.dispatch( action( ...args ) ) );\n\t\t\t}\n\n\t\t\tconst actions = {\n\t\t\t\t...mapValues( metadataActions, bindAction ),\n\t\t\t\t...mapValues( options.actions, bindAction ),\n\t\t\t};\n\n\t\t\tconst boundPrivateActions = createBindingCache( bindAction );\n\t\t\tconst allActions = new Proxy( () => {}, {\n\t\t\t\tget: ( target, prop ) => {\n\t\t\t\t\tconst privateAction = privateActions[ prop ];\n\t\t\t\t\treturn privateAction\n\t\t\t\t\t\t? boundPrivateActions.get( privateAction, prop )\n\t\t\t\t\t\t: actions[ prop ];\n\t\t\t\t},\n\t\t\t} );\n\n\t\t\tconst thunkActions = new Proxy( allActions, {\n\t\t\t\tapply: ( target, thisArg, [ action ] ) =>\n\t\t\t\t\tstore.dispatch( action ),\n\t\t\t} );\n\n\t\t\tlock( actions, allActions );\n\n\t\t\tconst resolvers = options.resolvers\n\t\t\t\t? mapResolvers( options.resolvers )\n\t\t\t\t: {};\n\n\t\t\tfunction bindSelector( selector, selectorName ) {\n\t\t\t\tif ( selector.isRegistrySelector ) {\n\t\t\t\t\tselector.registry = registry;\n\t\t\t\t}\n\t\t\t\tconst boundSelector = ( ...args ) => {\n\t\t\t\t\targs = normalize( selector, args );\n\t\t\t\t\tconst state = store.__unstableOriginalGetState();\n\t\t\t\t\t// Before calling the selector, switch to the correct\n\t\t\t\t\t// registry.\n\t\t\t\t\tif ( selector.isRegistrySelector ) {\n\t\t\t\t\t\tselector.registry = registry;\n\t\t\t\t\t}\n\t\t\t\t\treturn selector( state.root, ...args );\n\t\t\t\t};\n\n\t\t\t\t// Expose normalization method on the bound selector\n\t\t\t\t// in order that it can be called when fulfilling\n\t\t\t\t// the resolver.\n\t\t\t\tboundSelector.__unstableNormalizeArgs =\n\t\t\t\t\tselector.__unstableNormalizeArgs;\n\n\t\t\t\tconst resolver = resolvers[ selectorName ];\n\n\t\t\t\tif ( ! resolver ) {\n\t\t\t\t\tboundSelector.hasResolver = false;\n\t\t\t\t\treturn boundSelector;\n\t\t\t\t}\n\n\t\t\t\treturn mapSelectorWithResolver(\n\t\t\t\t\tboundSelector,\n\t\t\t\t\tselectorName,\n\t\t\t\t\tresolver,\n\t\t\t\t\tstore,\n\t\t\t\t\tresolversCache\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tfunction bindMetadataSelector( metaDataSelector ) {\n\t\t\t\tconst boundSelector = ( ...args ) => {\n\t\t\t\t\tconst state = store.__unstableOriginalGetState();\n\n\t\t\t\t\tconst originalSelectorName = args && args[ 0 ];\n\t\t\t\t\tconst originalSelectorArgs = args && args[ 1 ];\n\t\t\t\t\tconst targetSelector =\n\t\t\t\t\t\toptions?.selectors?.[ originalSelectorName ];\n\n\t\t\t\t\t// Normalize the arguments passed to the target selector.\n\t\t\t\t\tif ( originalSelectorName && targetSelector ) {\n\t\t\t\t\t\targs[ 1 ] = normalize(\n\t\t\t\t\t\t\ttargetSelector,\n\t\t\t\t\t\t\toriginalSelectorArgs\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\treturn metaDataSelector( state.metadata, ...args );\n\t\t\t\t};\n\t\t\t\tboundSelector.hasResolver = false;\n\t\t\t\treturn boundSelector;\n\t\t\t}\n\n\t\t\tconst selectors = {\n\t\t\t\t...mapValues( metadataSelectors, bindMetadataSelector ),\n\t\t\t\t...mapValues( options.selectors, bindSelector ),\n\t\t\t};\n\n\t\t\tconst boundPrivateSelectors = createBindingCache( bindSelector );\n\n\t\t\t// Pre-bind the private selectors that have been registered by the time of\n\t\t\t// instantiation, so that registry selectors are bound to the registry.\n\t\t\tfor ( const [ selectorName, selector ] of Object.entries(\n\t\t\t\tprivateSelectors\n\t\t\t) ) {\n\t\t\t\tboundPrivateSelectors.get( selector, selectorName );\n\t\t\t}\n\n\t\t\tconst allSelectors = new Proxy( () => {}, {\n\t\t\t\tget: ( target, prop ) => {\n\t\t\t\t\tconst privateSelector = privateSelectors[ prop ];\n\t\t\t\t\treturn privateSelector\n\t\t\t\t\t\t? boundPrivateSelectors.get( privateSelector, prop )\n\t\t\t\t\t\t: selectors[ prop ];\n\t\t\t\t},\n\t\t\t} );\n\n\t\t\tconst thunkSelectors = new Proxy( allSelectors, {\n\t\t\t\tapply: ( target, thisArg, [ selector ] ) =>\n\t\t\t\t\tselector( store.__unstableOriginalGetState() ),\n\t\t\t} );\n\n\t\t\tlock( selectors, allSelectors );\n\n\t\t\tconst resolveSelectors = mapResolveSelectors( selectors, store );\n\t\t\tconst suspendSelectors = mapSuspendSelectors( selectors, store );\n\n\t\t\tconst getSelectors = () => selectors;\n\t\t\tconst getActions = () => actions;\n\t\t\tconst getResolveSelectors = () => resolveSelectors;\n\t\t\tconst getSuspendSelectors = () => suspendSelectors;\n\n\t\t\t// We have some modules monkey-patching the store object\n\t\t\t// It's wrong to do so but until we refactor all of our effects to controls\n\t\t\t// We need to keep the same \"store\" instance here.\n\t\t\tstore.__unstableOriginalGetState = store.getState;\n\t\t\tstore.getState = () => store.__unstableOriginalGetState().root;\n\n\t\t\t// Customize subscribe behavior to call listeners only on effective change,\n\t\t\t// not on every dispatch.\n\t\t\tconst subscribe =\n\t\t\t\tstore &&\n\t\t\t\t( ( listener ) => {\n\t\t\t\t\tlisteners.add( listener );\n\n\t\t\t\t\treturn () => listeners.delete( listener );\n\t\t\t\t} );\n\n\t\t\tlet lastState = store.__unstableOriginalGetState();\n\t\t\tstore.subscribe( () => {\n\t\t\t\tconst state = store.__unstableOriginalGetState();\n\t\t\t\tconst hasChanged = state !== lastState;\n\t\t\t\tlastState = state;\n\n\t\t\t\tif ( hasChanged ) {\n\t\t\t\t\tfor ( const listener of listeners ) {\n\t\t\t\t\t\tlistener();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} );\n\n\t\t\t// This can be simplified to just { subscribe, getSelectors, getActions }\n\t\t\t// Once we remove the use function.\n\t\t\treturn {\n\t\t\t\treducer,\n\t\t\t\tstore,\n\t\t\t\tactions,\n\t\t\t\tselectors,\n\t\t\t\tresolvers,\n\t\t\t\tgetSelectors,\n\t\t\t\tgetResolveSelectors,\n\t\t\t\tgetSuspendSelectors,\n\t\t\t\tgetActions,\n\t\t\t\tsubscribe,\n\t\t\t};\n\t\t},\n\t};\n\n\t// Expose the private registration functions on the store\n\t// descriptor. That's a natural choice since that's where the\n\t// public actions and selectors are stored .\n\tlock( storeDescriptor, privateRegistrationFunctions );\n\n\treturn storeDescriptor;\n}\n\n/**\n * Creates a redux store for a namespace.\n *\n * @param {string} key Unique namespace identifier.\n * @param {Object} options Registered store options, with properties\n * describing reducer, actions, selectors,\n * and resolvers.\n * @param {DataRegistry} registry Registry reference.\n * @param {Object} thunkArgs Argument object for the thunk middleware.\n * @return {Object} Newly created redux store.\n */\nfunction instantiateReduxStore( key, options, registry, thunkArgs ) {\n\tconst controls = {\n\t\t...options.controls,\n\t\t...builtinControls,\n\t};\n\n\tconst normalizedControls = mapValues( controls, ( control ) =>\n\t\tcontrol.isRegistryControl ? control( registry ) : control\n\t);\n\n\tconst middlewares = [\n\t\tcreateResolversCacheMiddleware( registry, key ),\n\t\tpromise,\n\t\tcreateReduxRoutineMiddleware( normalizedControls ),\n\t\tcreateThunkMiddleware( thunkArgs ),\n\t];\n\n\tconst enhancers = [ applyMiddleware( ...middlewares ) ];\n\tif (\n\t\ttypeof window !== 'undefined' &&\n\t\twindow.__REDUX_DEVTOOLS_EXTENSION__\n\t) {\n\t\tenhancers.push(\n\t\t\twindow.__REDUX_DEVTOOLS_EXTENSION__( {\n\t\t\t\tname: key,\n\t\t\t\tinstanceId: key,\n\t\t\t\tserialize: {\n\t\t\t\t\treplacer: devToolsReplacer,\n\t\t\t\t},\n\t\t\t} )\n\t\t);\n\t}\n\n\tconst { reducer, initialState } = options;\n\tconst enhancedReducer = combineReducers( {\n\t\tmetadata: metadataReducer,\n\t\troot: reducer,\n\t} );\n\n\treturn createStore(\n\t\tenhancedReducer,\n\t\t{ root: initialState },\n\t\tcompose( enhancers )\n\t);\n}\n\n/**\n * Maps selectors to functions that return a resolution promise for them\n *\n * @param {Object} selectors Selectors to map.\n * @param {Object} store The redux store the selectors select from.\n *\n * @return {Object} Selectors mapped to their resolution functions.\n */\nfunction mapResolveSelectors( selectors, store ) {\n\tconst {\n\t\tgetIsResolving,\n\t\thasStartedResolution,\n\t\thasFinishedResolution,\n\t\thasResolutionFailed,\n\t\tisResolving,\n\t\tgetCachedResolvers,\n\t\tgetResolutionState,\n\t\tgetResolutionError,\n\t\thasResolvingSelectors,\n\t\tcountSelectorsByStatus,\n\t\t...storeSelectors\n\t} = selectors;\n\n\treturn mapValues( storeSelectors, ( selector, selectorName ) => {\n\t\t// If the selector doesn't have a resolver, just convert the return value\n\t\t// (including exceptions) to a Promise, no additional extra behavior is needed.\n\t\tif ( ! selector.hasResolver ) {\n\t\t\treturn async ( ...args ) => selector.apply( null, args );\n\t\t}\n\n\t\treturn ( ...args ) => {\n\t\t\treturn new Promise( ( resolve, reject ) => {\n\t\t\t\tconst hasFinished = () =>\n\t\t\t\t\tselectors.hasFinishedResolution( selectorName, args );\n\t\t\t\tconst finalize = ( result ) => {\n\t\t\t\t\tconst hasFailed = selectors.hasResolutionFailed(\n\t\t\t\t\t\tselectorName,\n\t\t\t\t\t\targs\n\t\t\t\t\t);\n\t\t\t\t\tif ( hasFailed ) {\n\t\t\t\t\t\tconst error = selectors.getResolutionError(\n\t\t\t\t\t\t\tselectorName,\n\t\t\t\t\t\t\targs\n\t\t\t\t\t\t);\n\t\t\t\t\t\treject( error );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tresolve( result );\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\tconst getResult = () => selector.apply( null, args );\n\t\t\t\t// Trigger the selector (to trigger the resolver)\n\t\t\t\tconst result = getResult();\n\t\t\t\tif ( hasFinished() ) {\n\t\t\t\t\treturn finalize( result );\n\t\t\t\t}\n\n\t\t\t\tconst unsubscribe = store.subscribe( () => {\n\t\t\t\t\tif ( hasFinished() ) {\n\t\t\t\t\t\tunsubscribe();\n\t\t\t\t\t\tfinalize( getResult() );\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t} );\n\t\t};\n\t} );\n}\n\n/**\n * Maps selectors to functions that throw a suspense promise if not yet resolved.\n *\n * @param {Object} selectors Selectors to map.\n * @param {Object} store The redux store the selectors select from.\n *\n * @return {Object} Selectors mapped to their suspense functions.\n */\nfunction mapSuspendSelectors( selectors, store ) {\n\treturn mapValues( selectors, ( selector, selectorName ) => {\n\t\t// Selector without a resolver doesn't have any extra suspense behavior.\n\t\tif ( ! selector.hasResolver ) {\n\t\t\treturn selector;\n\t\t}\n\n\t\treturn ( ...args ) => {\n\t\t\tconst result = selector.apply( null, args );\n\n\t\t\tif ( selectors.hasFinishedResolution( selectorName, args ) ) {\n\t\t\t\tif ( selectors.hasResolutionFailed( selectorName, args ) ) {\n\t\t\t\t\tthrow selectors.getResolutionError( selectorName, args );\n\t\t\t\t}\n\n\t\t\t\treturn result;\n\t\t\t}\n\n\t\t\tthrow new Promise( ( resolve ) => {\n\t\t\t\tconst unsubscribe = store.subscribe( () => {\n\t\t\t\t\tif (\n\t\t\t\t\t\tselectors.hasFinishedResolution( selectorName, args )\n\t\t\t\t\t) {\n\t\t\t\t\t\tresolve();\n\t\t\t\t\t\tunsubscribe();\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t} );\n\t\t};\n\t} );\n}\n\n/**\n * Convert resolvers to a normalized form, an object with `fulfill` method and\n * optional methods like `isFulfilled`.\n *\n * @param {Object} resolvers Resolver to convert\n */\nfunction mapResolvers( resolvers ) {\n\treturn mapValues( resolvers, ( resolver ) => {\n\t\tif ( resolver.fulfill ) {\n\t\t\treturn resolver;\n\t\t}\n\n\t\treturn {\n\t\t\t...resolver, // Copy the enumerable properties of the resolver function.\n\t\t\tfulfill: resolver, // Add the fulfill method.\n\t\t};\n\t} );\n}\n\n/**\n * Returns a selector with a matched resolver.\n * Resolvers are side effects invoked once per argument set of a given selector call,\n * used in ensuring that the data needs for the selector are satisfied.\n *\n * @param {Object} selector The selector function to be bound.\n * @param {string} selectorName The selector name.\n * @param {Object} resolver Resolver to call.\n * @param {Object} store The redux store to which the resolvers should be mapped.\n * @param {Object} resolversCache Resolvers Cache.\n */\nfunction mapSelectorWithResolver(\n\tselector,\n\tselectorName,\n\tresolver,\n\tstore,\n\tresolversCache\n) {\n\tfunction fulfillSelector( args ) {\n\t\tconst state = store.getState();\n\n\t\tif (\n\t\t\tresolversCache.isRunning( selectorName, args ) ||\n\t\t\t( typeof resolver.isFulfilled === 'function' &&\n\t\t\t\tresolver.isFulfilled( state, ...args ) )\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { metadata } = store.__unstableOriginalGetState();\n\n\t\tif (\n\t\t\tmetadataSelectors.hasStartedResolution(\n\t\t\t\tmetadata,\n\t\t\t\tselectorName,\n\t\t\t\targs\n\t\t\t)\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\tresolversCache.markAsRunning( selectorName, args );\n\n\t\tsetTimeout( async () => {\n\t\t\tresolversCache.clear( selectorName, args );\n\t\t\tstore.dispatch(\n\t\t\t\tmetadataActions.startResolution( selectorName, args )\n\t\t\t);\n\t\t\ttry {\n\t\t\t\tconst action = resolver.fulfill( ...args );\n\t\t\t\tif ( action ) {\n\t\t\t\t\tawait store.dispatch( action );\n\t\t\t\t}\n\t\t\t\tstore.dispatch(\n\t\t\t\t\tmetadataActions.finishResolution( selectorName, args )\n\t\t\t\t);\n\t\t\t} catch ( error ) {\n\t\t\t\tstore.dispatch(\n\t\t\t\t\tmetadataActions.failResolution( selectorName, args, error )\n\t\t\t\t);\n\t\t\t}\n\t\t}, 0 );\n\t}\n\n\tconst selectorResolver = ( ...args ) => {\n\t\targs = normalize( selector, args );\n\t\tfulfillSelector( args );\n\t\treturn selector( ...args );\n\t};\n\tselectorResolver.hasResolver = true;\n\treturn selectorResolver;\n}\n\n/**\n * Applies selector's normalization function to the given arguments\n * if it exists.\n *\n * @param {Object} selector The selector potentially with a normalization method property.\n * @param {Array} args selector arguments to normalize.\n * @return {Array} Potentially normalized arguments.\n */\nfunction normalize( selector, args ) {\n\tif (\n\t\tselector.__unstableNormalizeArgs &&\n\t\ttypeof selector.__unstableNormalizeArgs === 'function' &&\n\t\targs?.length\n\t) {\n\t\treturn selector.__unstableNormalizeArgs( args );\n\t}\n\treturn args;\n}\n"],"mappings":";;;;;;;;;;;;;AAGA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAC,sBAAA,CAAAF,OAAA;AAKA,IAAAG,aAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AAKA,IAAAK,gBAAA,GAAAL,OAAA;AACA,IAAAM,SAAA,GAAAN,OAAA;AACA,IAAAO,WAAA,GAAAP,OAAA;AACA,IAAAQ,kBAAA,GAAAN,sBAAA,CAAAF,OAAA;AACA,IAAAS,yBAAA,GAAAP,sBAAA,CAAAF,OAAA;AACA,IAAAU,gBAAA,GAAAR,sBAAA,CAAAF,OAAA;AACA,IAAAW,QAAA,GAAAT,sBAAA,CAAAF,OAAA;AACA,IAAAY,iBAAA,GAAAC,uBAAA,CAAAb,OAAA;AACA,IAAAc,eAAA,GAAAD,uBAAA,CAAAb,OAAA;AAAsD,SAAAe,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAH,wBAAAG,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,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ACDqI,gBAAgB,CAACxE,WAAW,GAAG,IAAI;EACnC,OAAOwE,gBAAgB;AACxB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS7E,SAASA,CAAEH,QAAQ,EAAErD,IAAI,EAAG;EACpC,IACCqD,QAAQ,CAACM,uBAAuB,IAChC,OAAON,QAAQ,CAACM,uBAAuB,KAAK,UAAU,IACtD3D,IAAI,EAAEpB,MAAM,EACX;IACD,OAAOyE,QAAQ,CAACM,uBAAuB,CAAE3D,IAAK,CAAC;EAChD;EACA,OAAOA,IAAI;AACZ","ignoreList":[]}
1
+ {"version":3,"names":["_redux","require","_equivalentKeyMap","_interopRequireDefault","_reduxRoutine","_compose","_combineReducers","_controls","_lockUnlock","_promiseMiddleware","_resolversCacheMiddleware","_thunkMiddleware","_reducer","metadataSelectors","_interopRequireWildcard","metadataActions","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","trimUndefinedValues","array","result","length","undefined","splice","mapValues","obj","callback","fromEntries","entries","map","key","value","devToolsReplacer","state","Map","window","HTMLElement","createResolversCache","cache","isRunning","selectorName","args","clear","delete","markAsRunning","EquivalentKeyMap","createBindingCache","getItem","bindItem","itemName","item","boundItem","createPrivateProxy","publicItems","privateItems","Proxy","target","Reflect","createReduxStore","options","privateActions","privateSelectors","privateRegistrationFunctions","registerPrivateActions","actions","assign","registerPrivateSelectors","selectors","storeDescriptor","name","instantiate","registry","listeners","Set","reducer","thunkArgs","dispatch","thunkDispatch","select","thunkSelect","resolveSelect","resolveSelectors","store","instantiateReduxStore","lock","resolversCache","bindAction","action","Promise","resolve","allActions","resolvers","mapResolver","bindSelector","selector","isRegistrySelector","boundSelector","normalize","__unstableOriginalGetState","root","__unstableNormalizeArgs","resolver","hasResolver","mapSelectorWithResolver","boundMetadataSelectors","bindMetadataSelector","metaDataSelector","selectorArgs","targetSelector","metadata","boundSelectors","boundPrivateSelectors","allSelectors","keys","bindResolveSelector","mapResolveSelector","allResolveSelectors","bindSuspendSelector","mapSuspendSelector","suspendSelectors","allSuspendSelectors","getSelectors","getActions","getResolveSelectors","getSuspendSelectors","getState","subscribe","listener","add","lastState","hasChanged","controls","builtinControls","normalizedControls","control","isRegistryControl","middlewares","createResolversCacheMiddleware","promise","createReduxRoutineMiddleware","createThunkMiddleware","enhancers","applyMiddleware","__REDUX_DEVTOOLS_EXTENSION__","push","instanceId","serialize","replacer","initialState","enhancedReducer","combineReducers","metadataReducer","createStore","compose","apply","reject","hasFinished","hasFinishedResolution","finalize","hasFailed","hasResolutionFailed","error","getResolutionError","getResult","unsubscribe","fulfill","fulfillSelector","isFulfilled","hasStartedResolution","setTimeout","startResolution","finishResolution","failResolution","selectorResolver"],"sources":["@wordpress/data/src/redux-store/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { createStore, applyMiddleware } from 'redux';\nimport EquivalentKeyMap from 'equivalent-key-map';\n\n/**\n * WordPress dependencies\n */\nimport createReduxRoutineMiddleware from '@wordpress/redux-routine';\nimport { compose } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { combineReducers } from './combine-reducers';\nimport { builtinControls } from '../controls';\nimport { lock } from '../lock-unlock';\nimport promise from '../promise-middleware';\nimport createResolversCacheMiddleware from '../resolvers-cache-middleware';\nimport createThunkMiddleware from './thunk-middleware';\nimport metadataReducer from './metadata/reducer';\nimport * as metadataSelectors from './metadata/selectors';\nimport * as metadataActions from './metadata/actions';\n\nexport { combineReducers };\n\n/** @typedef {import('../types').DataRegistry} DataRegistry */\n/** @typedef {import('../types').ListenerFunction} ListenerFunction */\n/**\n * @typedef {import('../types').StoreDescriptor<C>} StoreDescriptor\n * @template {import('../types').AnyConfig} C\n */\n/**\n * @typedef {import('../types').ReduxStoreConfig<State,Actions,Selectors>} ReduxStoreConfig\n * @template State\n * @template {Record<string,import('../types').ActionCreator>} Actions\n * @template Selectors\n */\n\nconst trimUndefinedValues = ( array ) => {\n\tconst result = [ ...array ];\n\tfor ( let i = result.length - 1; i >= 0; i-- ) {\n\t\tif ( result[ i ] === undefined ) {\n\t\t\tresult.splice( i, 1 );\n\t\t}\n\t}\n\treturn result;\n};\n\n/**\n * Creates a new object with the same keys, but with `callback()` called as\n * a transformer function on each of the values.\n *\n * @param {Object} obj The object to transform.\n * @param {Function} callback The function to transform each object value.\n * @return {Array} Transformed object.\n */\nconst mapValues = ( obj, callback ) =>\n\tObject.fromEntries(\n\t\tObject.entries( obj ?? {} ).map( ( [ key, value ] ) => [\n\t\t\tkey,\n\t\t\tcallback( value, key ),\n\t\t] )\n\t);\n\n// Convert non serializable types to plain objects\nconst devToolsReplacer = ( key, state ) => {\n\tif ( state instanceof Map ) {\n\t\treturn Object.fromEntries( state );\n\t}\n\n\tif ( state instanceof window.HTMLElement ) {\n\t\treturn null;\n\t}\n\n\treturn state;\n};\n\n/**\n * Create a cache to track whether resolvers started running or not.\n *\n * @return {Object} Resolvers Cache.\n */\nfunction createResolversCache() {\n\tconst cache = {};\n\treturn {\n\t\tisRunning( selectorName, args ) {\n\t\t\treturn (\n\t\t\t\tcache[ selectorName ] &&\n\t\t\t\tcache[ selectorName ].get( trimUndefinedValues( args ) )\n\t\t\t);\n\t\t},\n\n\t\tclear( selectorName, args ) {\n\t\t\tif ( cache[ selectorName ] ) {\n\t\t\t\tcache[ selectorName ].delete( trimUndefinedValues( args ) );\n\t\t\t}\n\t\t},\n\n\t\tmarkAsRunning( selectorName, args ) {\n\t\t\tif ( ! cache[ selectorName ] ) {\n\t\t\t\tcache[ selectorName ] = new EquivalentKeyMap();\n\t\t\t}\n\n\t\t\tcache[ selectorName ].set( trimUndefinedValues( args ), true );\n\t\t},\n\t};\n}\n\nfunction createBindingCache( getItem, bindItem ) {\n\tconst cache = new WeakMap();\n\n\treturn {\n\t\tget( itemName ) {\n\t\t\tconst item = getItem( itemName );\n\t\t\tif ( ! item ) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tlet boundItem = cache.get( item );\n\t\t\tif ( ! boundItem ) {\n\t\t\t\tboundItem = bindItem( item, itemName );\n\t\t\t\tcache.set( item, boundItem );\n\t\t\t}\n\t\t\treturn boundItem;\n\t\t},\n\t};\n}\n\nfunction createPrivateProxy( publicItems, privateItems ) {\n\treturn new Proxy( publicItems, {\n\t\tget: ( target, itemName ) =>\n\t\t\tprivateItems.get( itemName ) || Reflect.get( target, itemName ),\n\t} );\n}\n\n/**\n * Creates a data store descriptor for the provided Redux store configuration containing\n * properties describing reducer, actions, selectors, controls and resolvers.\n *\n * @example\n * ```js\n * import { createReduxStore } from '@wordpress/data';\n *\n * const store = createReduxStore( 'demo', {\n * reducer: ( state = 'OK' ) => state,\n * selectors: {\n * getValue: ( state ) => state,\n * },\n * } );\n * ```\n *\n * @template State\n * @template {Record<string,import('../types').ActionCreator>} Actions\n * @template Selectors\n * @param {string} key Unique namespace identifier.\n * @param {ReduxStoreConfig<State,Actions,Selectors>} options Registered store options, with properties\n * describing reducer, actions, selectors,\n * and resolvers.\n *\n * @return {StoreDescriptor<ReduxStoreConfig<State,Actions,Selectors>>} Store Object.\n */\nexport default function createReduxStore( key, options ) {\n\tconst privateActions = {};\n\tconst privateSelectors = {};\n\tconst privateRegistrationFunctions = {\n\t\tprivateActions,\n\t\tregisterPrivateActions: ( actions ) => {\n\t\t\tObject.assign( privateActions, actions );\n\t\t},\n\t\tprivateSelectors,\n\t\tregisterPrivateSelectors: ( selectors ) => {\n\t\t\tObject.assign( privateSelectors, selectors );\n\t\t},\n\t};\n\tconst storeDescriptor = {\n\t\tname: key,\n\t\tinstantiate: ( registry ) => {\n\t\t\t/**\n\t\t\t * Stores listener functions registered with `subscribe()`.\n\t\t\t *\n\t\t\t * When functions register to listen to store changes with\n\t\t\t * `subscribe()` they get added here. Although Redux offers\n\t\t\t * its own `subscribe()` function directly, by wrapping the\n\t\t\t * subscription in this store instance it's possible to\n\t\t\t * optimize checking if the state has changed before calling\n\t\t\t * each listener.\n\t\t\t *\n\t\t\t * @type {Set<ListenerFunction>}\n\t\t\t */\n\t\t\tconst listeners = new Set();\n\t\t\tconst reducer = options.reducer;\n\n\t\t\t// Object that every thunk function receives as the first argument. It contains the\n\t\t\t// `registry`, `dispatch`, `select` and `resolveSelect` fields. Some of them are\n\t\t\t// constructed as getters to avoid circular dependencies.\n\t\t\tconst thunkArgs = {\n\t\t\t\tregistry,\n\t\t\t\tget dispatch() {\n\t\t\t\t\treturn thunkDispatch;\n\t\t\t\t},\n\t\t\t\tget select() {\n\t\t\t\t\treturn thunkSelect;\n\t\t\t\t},\n\t\t\t\tget resolveSelect() {\n\t\t\t\t\treturn resolveSelectors;\n\t\t\t\t},\n\t\t\t};\n\n\t\t\tconst store = instantiateReduxStore(\n\t\t\t\tkey,\n\t\t\t\toptions,\n\t\t\t\tregistry,\n\t\t\t\tthunkArgs\n\t\t\t);\n\n\t\t\t// Expose the private registration functions on the store\n\t\t\t// so they can be copied to a sub registry in registry.js.\n\t\t\tlock( store, privateRegistrationFunctions );\n\t\t\tconst resolversCache = createResolversCache();\n\n\t\t\t// Binds an action creator (`action`) to the `store`, making it a callable function.\n\t\t\t// These are the functions that are returned by `useDispatch`, for example.\n\t\t\t// It always returns a `Promise`, although actions are not always async. That's an\n\t\t\t// unfortunate backward compatibility measure.\n\t\t\tfunction bindAction( action ) {\n\t\t\t\treturn ( ...args ) =>\n\t\t\t\t\tPromise.resolve( store.dispatch( action( ...args ) ) );\n\t\t\t}\n\n\t\t\t/*\n\t\t\t * Object with all public actions, both metadata and store actions.\n\t\t\t */\n\t\t\tconst actions = {\n\t\t\t\t...mapValues( metadataActions, bindAction ),\n\t\t\t\t...mapValues( options.actions, bindAction ),\n\t\t\t};\n\n\t\t\t// Object with both public and private actions. Private actions are accessed through a proxy,\n\t\t\t// which looks them up in real time on the `privateActions` object. That's because private\n\t\t\t// actions can be registered at any time with `registerPrivateActions`. Also once a private\n\t\t\t// action creator is bound to the store, it is cached to give it a stable identity.\n\t\t\tconst allActions = createPrivateProxy(\n\t\t\t\tactions,\n\t\t\t\tcreateBindingCache(\n\t\t\t\t\t( name ) => privateActions[ name ],\n\t\t\t\t\tbindAction\n\t\t\t\t)\n\t\t\t);\n\n\t\t\t// An object that implements the `dispatch` object that is passed to thunk functions.\n\t\t\t// It is callable (`dispatch( action )`) and also has methods (`dispatch.foo()`) that\n\t\t\t// correspond to bound registered actions, both public and private. Implemented with the proxy\n\t\t\t// `get` method, delegating to `allActions`.\n\t\t\tconst thunkDispatch = new Proxy(\n\t\t\t\t( action ) => store.dispatch( action ),\n\t\t\t\t{ get: ( target, name ) => allActions[ name ] }\n\t\t\t);\n\n\t\t\t// To the public `actions` object, add the \"locked\" `allActions` object. When used,\n\t\t\t// `unlock( actions )` will return `allActions`, implementing a way how to get at the private actions.\n\t\t\tlock( actions, allActions );\n\n\t\t\t// If we have selector resolvers, convert them to a normalized form.\n\t\t\tconst resolvers = options.resolvers\n\t\t\t\t? mapValues( options.resolvers, mapResolver )\n\t\t\t\t: {};\n\n\t\t\t// Bind a selector to the store. Call the selector with the current state, correct registry,\n\t\t\t// and if there is a resolver, attach the resolver logic to the selector.\n\t\t\tfunction bindSelector( selector, selectorName ) {\n\t\t\t\tif ( selector.isRegistrySelector ) {\n\t\t\t\t\tselector.registry = registry;\n\t\t\t\t}\n\t\t\t\tconst boundSelector = ( ...args ) => {\n\t\t\t\t\targs = normalize( selector, args );\n\t\t\t\t\tconst state = store.__unstableOriginalGetState();\n\t\t\t\t\t// Before calling the selector, switch to the correct registry.\n\t\t\t\t\tif ( selector.isRegistrySelector ) {\n\t\t\t\t\t\tselector.registry = registry;\n\t\t\t\t\t}\n\t\t\t\t\treturn selector( state.root, ...args );\n\t\t\t\t};\n\n\t\t\t\t// Expose normalization method on the bound selector\n\t\t\t\t// in order that it can be called when fulfilling\n\t\t\t\t// the resolver.\n\t\t\t\tboundSelector.__unstableNormalizeArgs =\n\t\t\t\t\tselector.__unstableNormalizeArgs;\n\n\t\t\t\tconst resolver = resolvers[ selectorName ];\n\n\t\t\t\tif ( ! resolver ) {\n\t\t\t\t\tboundSelector.hasResolver = false;\n\t\t\t\t\treturn boundSelector;\n\t\t\t\t}\n\n\t\t\t\treturn mapSelectorWithResolver(\n\t\t\t\t\tboundSelector,\n\t\t\t\t\tselectorName,\n\t\t\t\t\tresolver,\n\t\t\t\t\tstore,\n\t\t\t\t\tresolversCache,\n\t\t\t\t\tboundMetadataSelectors\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// Metadata selectors are bound differently: different state (`state.metadata`), no resolvers,\n\t\t\t// normalization depending on the target selector.\n\t\t\tfunction bindMetadataSelector( metaDataSelector ) {\n\t\t\t\tconst boundSelector = (\n\t\t\t\t\tselectorName,\n\t\t\t\t\tselectorArgs,\n\t\t\t\t\t...args\n\t\t\t\t) => {\n\t\t\t\t\t// Normalize the arguments passed to the target selector.\n\t\t\t\t\tif ( selectorName ) {\n\t\t\t\t\t\tconst targetSelector =\n\t\t\t\t\t\t\toptions.selectors?.[ selectorName ];\n\t\t\t\t\t\tif ( targetSelector ) {\n\t\t\t\t\t\t\tselectorArgs = normalize(\n\t\t\t\t\t\t\t\ttargetSelector,\n\t\t\t\t\t\t\t\tselectorArgs\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tconst state = store.__unstableOriginalGetState();\n\n\t\t\t\t\treturn metaDataSelector(\n\t\t\t\t\t\tstate.metadata,\n\t\t\t\t\t\tselectorName,\n\t\t\t\t\t\tselectorArgs,\n\t\t\t\t\t\t...args\n\t\t\t\t\t);\n\t\t\t\t};\n\t\t\t\tboundSelector.hasResolver = false;\n\t\t\t\treturn boundSelector;\n\t\t\t}\n\n\t\t\t// Perform binding of both metadata and store selectors and combine them in one\n\t\t\t// `selectors` object. These are all public selectors of the store.\n\t\t\tconst boundMetadataSelectors = mapValues(\n\t\t\t\tmetadataSelectors,\n\t\t\t\tbindMetadataSelector\n\t\t\t);\n\n\t\t\tconst boundSelectors = mapValues( options.selectors, bindSelector );\n\n\t\t\tconst selectors = {\n\t\t\t\t...boundMetadataSelectors,\n\t\t\t\t...boundSelectors,\n\t\t\t};\n\n\t\t\t// Cache of bould private selectors. They are bound only when first accessed, because\n\t\t\t// new private selectors can be registered at any time (with `registerPrivateSelectors`).\n\t\t\t// Once bound, they are cached to give them a stable identity.\n\t\t\tconst boundPrivateSelectors = createBindingCache(\n\t\t\t\t( name ) => privateSelectors[ name ],\n\t\t\t\tbindSelector\n\t\t\t);\n\n\t\t\tconst allSelectors = createPrivateProxy(\n\t\t\t\tselectors,\n\t\t\t\tboundPrivateSelectors\n\t\t\t);\n\n\t\t\t// Pre-bind the private selectors that have been registered by the time of\n\t\t\t// instantiation, so that registry selectors are bound to the registry.\n\t\t\tfor ( const selectorName of Object.keys( privateSelectors ) ) {\n\t\t\t\tboundPrivateSelectors.get( selectorName );\n\t\t\t}\n\n\t\t\t// An object that implements the `select` object that is passed to thunk functions.\n\t\t\t// It is callable (`select( selector )`) and also has methods (`select.foo()`) that\n\t\t\t// correspond to bound registered selectors, both public and private. Implemented with the proxy\n\t\t\t// `get` method, delegating to `allSelectors`.\n\t\t\tconst thunkSelect = new Proxy(\n\t\t\t\t( selector ) => selector( store.__unstableOriginalGetState() ),\n\t\t\t\t{ get: ( target, name ) => allSelectors[ name ] }\n\t\t\t);\n\n\t\t\t// To the public `selectors` object, add the \"locked\" `allSelectors` object. When used,\n\t\t\t// `unlock( selectors )` will return `allSelectors`, implementing a way how to get at the private selectors.\n\t\t\tlock( selectors, allSelectors );\n\n\t\t\t// For each selector, create a function that calls the selector, waits for resolution and returns\n\t\t\t// a promise that resolves when the resolution is finished.\n\t\t\tconst bindResolveSelector = mapResolveSelector(\n\t\t\t\tstore,\n\t\t\t\tboundMetadataSelectors\n\t\t\t);\n\n\t\t\t// Now apply this function to all bound selectors, public and private. We are excluding\n\t\t\t// metadata selectors because they don't have resolvers.\n\t\t\tconst resolveSelectors = mapValues(\n\t\t\t\tboundSelectors,\n\t\t\t\tbindResolveSelector\n\t\t\t);\n\n\t\t\tconst allResolveSelectors = createPrivateProxy(\n\t\t\t\tresolveSelectors,\n\t\t\t\tcreateBindingCache(\n\t\t\t\t\t( name ) => boundPrivateSelectors.get( name ),\n\t\t\t\t\tbindResolveSelector\n\t\t\t\t)\n\t\t\t);\n\n\t\t\t// Lock the selectors so that `unlock( resolveSelectors )` returns `allResolveSelectors`.\n\t\t\tlock( resolveSelectors, allResolveSelectors );\n\n\t\t\t// Now, in a way very similar to `bindResolveSelector`, we create a function that maps\n\t\t\t// selectors to functions that throw a suspense promise if not yet resolved.\n\t\t\tconst bindSuspendSelector = mapSuspendSelector(\n\t\t\t\tstore,\n\t\t\t\tboundMetadataSelectors\n\t\t\t);\n\n\t\t\tconst suspendSelectors = {\n\t\t\t\t...boundMetadataSelectors, // no special suspense behavior\n\t\t\t\t...mapValues( boundSelectors, bindSuspendSelector ),\n\t\t\t};\n\n\t\t\tconst allSuspendSelectors = createPrivateProxy(\n\t\t\t\tsuspendSelectors,\n\t\t\t\tcreateBindingCache(\n\t\t\t\t\t( name ) => boundPrivateSelectors.get( name ),\n\t\t\t\t\tbindSuspendSelector\n\t\t\t\t)\n\t\t\t);\n\n\t\t\t// Lock the selectors so that `unlock( suspendSelectors )` returns 'allSuspendSelectors`.\n\t\t\tlock( suspendSelectors, allSuspendSelectors );\n\n\t\t\tconst getSelectors = () => selectors;\n\t\t\tconst getActions = () => actions;\n\t\t\tconst getResolveSelectors = () => resolveSelectors;\n\t\t\tconst getSuspendSelectors = () => suspendSelectors;\n\n\t\t\t// We have some modules monkey-patching the store object\n\t\t\t// It's wrong to do so but until we refactor all of our effects to controls\n\t\t\t// We need to keep the same \"store\" instance here.\n\t\t\tstore.__unstableOriginalGetState = store.getState;\n\t\t\tstore.getState = () => store.__unstableOriginalGetState().root;\n\n\t\t\t// Customize subscribe behavior to call listeners only on effective change,\n\t\t\t// not on every dispatch.\n\t\t\tconst subscribe =\n\t\t\t\tstore &&\n\t\t\t\t( ( listener ) => {\n\t\t\t\t\tlisteners.add( listener );\n\n\t\t\t\t\treturn () => listeners.delete( listener );\n\t\t\t\t} );\n\n\t\t\tlet lastState = store.__unstableOriginalGetState();\n\t\t\tstore.subscribe( () => {\n\t\t\t\tconst state = store.__unstableOriginalGetState();\n\t\t\t\tconst hasChanged = state !== lastState;\n\t\t\t\tlastState = state;\n\n\t\t\t\tif ( hasChanged ) {\n\t\t\t\t\tfor ( const listener of listeners ) {\n\t\t\t\t\t\tlistener();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} );\n\n\t\t\t// This can be simplified to just { subscribe, getSelectors, getActions }\n\t\t\t// Once we remove the use function.\n\t\t\treturn {\n\t\t\t\treducer,\n\t\t\t\tstore,\n\t\t\t\tactions,\n\t\t\t\tselectors,\n\t\t\t\tresolvers,\n\t\t\t\tgetSelectors,\n\t\t\t\tgetResolveSelectors,\n\t\t\t\tgetSuspendSelectors,\n\t\t\t\tgetActions,\n\t\t\t\tsubscribe,\n\t\t\t};\n\t\t},\n\t};\n\n\t// Expose the private registration functions on the store\n\t// descriptor. That's a natural choice since that's where the\n\t// public actions and selectors are stored.\n\tlock( storeDescriptor, privateRegistrationFunctions );\n\n\treturn storeDescriptor;\n}\n\n/**\n * Creates a redux store for a namespace.\n *\n * @param {string} key Unique namespace identifier.\n * @param {Object} options Registered store options, with properties\n * describing reducer, actions, selectors,\n * and resolvers.\n * @param {DataRegistry} registry Registry reference.\n * @param {Object} thunkArgs Argument object for the thunk middleware.\n * @return {Object} Newly created redux store.\n */\nfunction instantiateReduxStore( key, options, registry, thunkArgs ) {\n\tconst controls = {\n\t\t...options.controls,\n\t\t...builtinControls,\n\t};\n\n\tconst normalizedControls = mapValues( controls, ( control ) =>\n\t\tcontrol.isRegistryControl ? control( registry ) : control\n\t);\n\n\tconst middlewares = [\n\t\tcreateResolversCacheMiddleware( registry, key ),\n\t\tpromise,\n\t\tcreateReduxRoutineMiddleware( normalizedControls ),\n\t\tcreateThunkMiddleware( thunkArgs ),\n\t];\n\n\tconst enhancers = [ applyMiddleware( ...middlewares ) ];\n\tif (\n\t\ttypeof window !== 'undefined' &&\n\t\twindow.__REDUX_DEVTOOLS_EXTENSION__\n\t) {\n\t\tenhancers.push(\n\t\t\twindow.__REDUX_DEVTOOLS_EXTENSION__( {\n\t\t\t\tname: key,\n\t\t\t\tinstanceId: key,\n\t\t\t\tserialize: {\n\t\t\t\t\treplacer: devToolsReplacer,\n\t\t\t\t},\n\t\t\t} )\n\t\t);\n\t}\n\n\tconst { reducer, initialState } = options;\n\tconst enhancedReducer = combineReducers( {\n\t\tmetadata: metadataReducer,\n\t\troot: reducer,\n\t} );\n\n\treturn createStore(\n\t\tenhancedReducer,\n\t\t{ root: initialState },\n\t\tcompose( enhancers )\n\t);\n}\n\n/**\n * Maps selectors to functions that return a resolution promise for them.\n *\n * @param {Object} store The redux store the selectors are bound to.\n * @param {Object} boundMetadataSelectors The bound metadata selectors.\n *\n * @return {Function} Function that maps selectors to resolvers.\n */\nfunction mapResolveSelector( store, boundMetadataSelectors ) {\n\treturn ( selector, selectorName ) => {\n\t\t// If the selector doesn't have a resolver, just convert the return value\n\t\t// (including exceptions) to a Promise, no additional extra behavior is needed.\n\t\tif ( ! selector.hasResolver ) {\n\t\t\treturn async ( ...args ) => selector.apply( null, args );\n\t\t}\n\n\t\treturn ( ...args ) =>\n\t\t\tnew Promise( ( resolve, reject ) => {\n\t\t\t\tconst hasFinished = () => {\n\t\t\t\t\treturn boundMetadataSelectors.hasFinishedResolution(\n\t\t\t\t\t\tselectorName,\n\t\t\t\t\t\targs\n\t\t\t\t\t);\n\t\t\t\t};\n\t\t\t\tconst finalize = ( result ) => {\n\t\t\t\t\tconst hasFailed =\n\t\t\t\t\t\tboundMetadataSelectors.hasResolutionFailed(\n\t\t\t\t\t\t\tselectorName,\n\t\t\t\t\t\t\targs\n\t\t\t\t\t\t);\n\t\t\t\t\tif ( hasFailed ) {\n\t\t\t\t\t\tconst error = boundMetadataSelectors.getResolutionError(\n\t\t\t\t\t\t\tselectorName,\n\t\t\t\t\t\t\targs\n\t\t\t\t\t\t);\n\t\t\t\t\t\treject( error );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tresolve( result );\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\tconst getResult = () => selector.apply( null, args );\n\n\t\t\t\t// Trigger the selector (to trigger the resolver)\n\t\t\t\tconst result = getResult();\n\t\t\t\tif ( hasFinished() ) {\n\t\t\t\t\treturn finalize( result );\n\t\t\t\t}\n\n\t\t\t\tconst unsubscribe = store.subscribe( () => {\n\t\t\t\t\tif ( hasFinished() ) {\n\t\t\t\t\t\tunsubscribe();\n\t\t\t\t\t\tfinalize( getResult() );\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t} );\n\t};\n}\n\n/**\n * Maps selectors to functions that throw a suspense promise if not yet resolved.\n *\n * @param {Object} store The redux store the selectors select from.\n * @param {Object} boundMetadataSelectors The bound metadata selectors.\n *\n * @return {Function} Function that maps selectors to their suspending versions.\n */\nfunction mapSuspendSelector( store, boundMetadataSelectors ) {\n\treturn ( selector, selectorName ) => {\n\t\t// Selector without a resolver doesn't have any extra suspense behavior.\n\t\tif ( ! selector.hasResolver ) {\n\t\t\treturn selector;\n\t\t}\n\n\t\treturn ( ...args ) => {\n\t\t\tconst result = selector.apply( null, args );\n\n\t\t\tif (\n\t\t\t\tboundMetadataSelectors.hasFinishedResolution(\n\t\t\t\t\tselectorName,\n\t\t\t\t\targs\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\tif (\n\t\t\t\t\tboundMetadataSelectors.hasResolutionFailed(\n\t\t\t\t\t\tselectorName,\n\t\t\t\t\t\targs\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\tthrow boundMetadataSelectors.getResolutionError(\n\t\t\t\t\t\tselectorName,\n\t\t\t\t\t\targs\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn result;\n\t\t\t}\n\n\t\t\tthrow new Promise( ( resolve ) => {\n\t\t\t\tconst unsubscribe = store.subscribe( () => {\n\t\t\t\t\tif (\n\t\t\t\t\t\tboundMetadataSelectors.hasFinishedResolution(\n\t\t\t\t\t\t\tselectorName,\n\t\t\t\t\t\t\targs\n\t\t\t\t\t\t)\n\t\t\t\t\t) {\n\t\t\t\t\t\tresolve();\n\t\t\t\t\t\tunsubscribe();\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t} );\n\t\t};\n\t};\n}\n\n/**\n * Convert a resolver to a normalized form, an object with `fulfill` method and\n * optional methods like `isFulfilled`.\n *\n * @param {Function} resolver Resolver to convert\n */\nfunction mapResolver( resolver ) {\n\tif ( resolver.fulfill ) {\n\t\treturn resolver;\n\t}\n\n\treturn {\n\t\t...resolver, // Copy the enumerable properties of the resolver function.\n\t\tfulfill: resolver, // Add the fulfill method.\n\t};\n}\n\n/**\n * Returns a selector with a matched resolver.\n * Resolvers are side effects invoked once per argument set of a given selector call,\n * used in ensuring that the data needs for the selector are satisfied.\n *\n * @param {Object} selector The selector function to be bound.\n * @param {string} selectorName The selector name.\n * @param {Object} resolver Resolver to call.\n * @param {Object} store The redux store to which the resolvers should be mapped.\n * @param {Object} resolversCache Resolvers Cache.\n * @param {Object} boundMetadataSelectors The bound metadata selectors.\n */\nfunction mapSelectorWithResolver(\n\tselector,\n\tselectorName,\n\tresolver,\n\tstore,\n\tresolversCache,\n\tboundMetadataSelectors\n) {\n\tfunction fulfillSelector( args ) {\n\t\tconst state = store.getState();\n\n\t\tif (\n\t\t\tresolversCache.isRunning( selectorName, args ) ||\n\t\t\t( typeof resolver.isFulfilled === 'function' &&\n\t\t\t\tresolver.isFulfilled( state, ...args ) )\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (\n\t\t\tboundMetadataSelectors.hasStartedResolution( selectorName, args )\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\tresolversCache.markAsRunning( selectorName, args );\n\n\t\tsetTimeout( async () => {\n\t\t\tresolversCache.clear( selectorName, args );\n\t\t\tstore.dispatch(\n\t\t\t\tmetadataActions.startResolution( selectorName, args )\n\t\t\t);\n\t\t\ttry {\n\t\t\t\tconst action = resolver.fulfill( ...args );\n\t\t\t\tif ( action ) {\n\t\t\t\t\tawait store.dispatch( action );\n\t\t\t\t}\n\t\t\t\tstore.dispatch(\n\t\t\t\t\tmetadataActions.finishResolution( selectorName, args )\n\t\t\t\t);\n\t\t\t} catch ( error ) {\n\t\t\t\tstore.dispatch(\n\t\t\t\t\tmetadataActions.failResolution( selectorName, args, error )\n\t\t\t\t);\n\t\t\t}\n\t\t}, 0 );\n\t}\n\n\tconst selectorResolver = ( ...args ) => {\n\t\targs = normalize( selector, args );\n\t\tfulfillSelector( args );\n\t\treturn selector( ...args );\n\t};\n\tselectorResolver.hasResolver = true;\n\treturn selectorResolver;\n}\n\n/**\n * Applies selector's normalization function to the given arguments\n * if it exists.\n *\n * @param {Object} selector The selector potentially with a normalization method property.\n * @param {Array} args selector arguments to normalize.\n * @return {Array} Potentially normalized arguments.\n */\nfunction normalize( selector, args ) {\n\tif (\n\t\tselector.__unstableNormalizeArgs &&\n\t\ttypeof selector.__unstableNormalizeArgs === 'function' &&\n\t\targs?.length\n\t) {\n\t\treturn selector.__unstableNormalizeArgs( args );\n\t}\n\treturn args;\n}\n"],"mappings":";;;;;;;;;;;;;AAGA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAC,sBAAA,CAAAF,OAAA;AAKA,IAAAG,aAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AAKA,IAAAK,gBAAA,GAAAL,OAAA;AACA,IAAAM,SAAA,GAAAN,OAAA;AACA,IAAAO,WAAA,GAAAP,OAAA;AACA,IAAAQ,kBAAA,GAAAN,sBAAA,CAAAF,OAAA;AACA,IAAAS,yBAAA,GAAAP,sBAAA,CAAAF,OAAA;AACA,IAAAU,gBAAA,GAAAR,sBAA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AY,EAAEC,IAAK,CAAC;MAC1CyC,KAAK,CAACN,QAAQ,CACb/E,eAAe,CAAC6K,eAAe,CAAElI,YAAY,EAAEC,IAAK,CACrD,CAAC;MACD,IAAI;QACH,MAAM8C,MAAM,GAAGc,QAAQ,CAACgE,OAAO,CAAE,GAAG5H,IAAK,CAAC;QAC1C,IAAK8C,MAAM,EAAG;UACb,MAAML,KAAK,CAACN,QAAQ,CAAEW,MAAO,CAAC;QAC/B;QACAL,KAAK,CAACN,QAAQ,CACb/E,eAAe,CAAC8K,gBAAgB,CAAEnI,YAAY,EAAEC,IAAK,CACtD,CAAC;MACF,CAAC,CAAC,OAAQwH,KAAK,EAAG;QACjB/E,KAAK,CAACN,QAAQ,CACb/E,eAAe,CAAC+K,cAAc,CAAEpI,YAAY,EAAEC,IAAI,EAAEwH,KAAM,CAC3D,CAAC;MACF;IACD,CAAC,EAAE,CAAE,CAAC;EACP;EAEA,MAAMY,gBAAgB,GAAGA,CAAE,GAAGpI,IAAI,KAAM;IACvCA,IAAI,GAAGwD,SAAS,CAAEH,QAAQ,EAAErD,IAAK,CAAC;IAClC6H,eAAe,CAAE7H,IAAK,CAAC;IACvB,OAAOqD,QAAQ,CAAE,GAAGrD,IAAK,CAAC;EAC3B,CAAC;EACDoI,gBAAgB,CAACvE,WAAW,GAAG,IAAI;EACnC,OAAOuE,gBAAgB;AACxB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS5E,SAASA,CAAEH,QAAQ,EAAErD,IAAI,EAAG;EACpC,IACCqD,QAAQ,CAACM,uBAAuB,IAChC,OAAON,QAAQ,CAACM,uBAAuB,KAAK,UAAU,IACtD3D,IAAI,EAAEpB,MAAM,EACX;IACD,OAAOyE,QAAQ,CAACM,uBAAuB,CAAE3D,IAAK,CAAC;EAChD;EACA,OAAOA,IAAI;AACZ","ignoreList":[]}
@@ -92,19 +92,28 @@ function createResolversCache() {
92
92
  }
93
93
  };
94
94
  }
95
- function createBindingCache(bind) {
95
+ function createBindingCache(getItem, bindItem) {
96
96
  const cache = new WeakMap();
97
97
  return {
98
- get(item, itemName) {
98
+ get(itemName) {
99
+ const item = getItem(itemName);
100
+ if (!item) {
101
+ return null;
102
+ }
99
103
  let boundItem = cache.get(item);
100
104
  if (!boundItem) {
101
- boundItem = bind(item, itemName);
105
+ boundItem = bindItem(item, itemName);
102
106
  cache.set(item, boundItem);
103
107
  }
104
108
  return boundItem;
105
109
  }
106
110
  };
107
111
  }
112
+ function createPrivateProxy(publicItems, privateItems) {
113
+ return new Proxy(publicItems, {
114
+ get: (target, itemName) => privateItems.get(itemName) || Reflect.get(target, itemName)
115
+ });
116
+ }
108
117
 
109
118
  /**
110
119
  * Creates a data store descriptor for the provided Redux store configuration containing
@@ -162,42 +171,68 @@ export default function createReduxStore(key, options) {
162
171
  */
163
172
  const listeners = new Set();
164
173
  const reducer = options.reducer;
174
+
175
+ // Object that every thunk function receives as the first argument. It contains the
176
+ // `registry`, `dispatch`, `select` and `resolveSelect` fields. Some of them are
177
+ // constructed as getters to avoid circular dependencies.
165
178
  const thunkArgs = {
166
179
  registry,
167
180
  get dispatch() {
168
- return thunkActions;
181
+ return thunkDispatch;
169
182
  },
170
183
  get select() {
171
- return thunkSelectors;
184
+ return thunkSelect;
172
185
  },
173
186
  get resolveSelect() {
174
- return getResolveSelectors();
187
+ return resolveSelectors;
175
188
  }
176
189
  };
177
190
  const store = instantiateReduxStore(key, options, registry, thunkArgs);
191
+
178
192
  // Expose the private registration functions on the store
179
193
  // so they can be copied to a sub registry in registry.js.
180
194
  lock(store, privateRegistrationFunctions);
181
195
  const resolversCache = createResolversCache();
196
+
197
+ // Binds an action creator (`action`) to the `store`, making it a callable function.
198
+ // These are the functions that are returned by `useDispatch`, for example.
199
+ // It always returns a `Promise`, although actions are not always async. That's an
200
+ // unfortunate backward compatibility measure.
182
201
  function bindAction(action) {
183
202
  return (...args) => Promise.resolve(store.dispatch(action(...args)));
184
203
  }
204
+
205
+ /*
206
+ * Object with all public actions, both metadata and store actions.
207
+ */
185
208
  const actions = {
186
209
  ...mapValues(metadataActions, bindAction),
187
210
  ...mapValues(options.actions, bindAction)
188
211
  };
189
- const boundPrivateActions = createBindingCache(bindAction);
190
- const allActions = new Proxy(() => {}, {
191
- get: (target, prop) => {
192
- const privateAction = privateActions[prop];
193
- return privateAction ? boundPrivateActions.get(privateAction, prop) : actions[prop];
194
- }
195
- });
196
- const thunkActions = new Proxy(allActions, {
197
- apply: (target, thisArg, [action]) => store.dispatch(action)
212
+
213
+ // Object with both public and private actions. Private actions are accessed through a proxy,
214
+ // which looks them up in real time on the `privateActions` object. That's because private
215
+ // actions can be registered at any time with `registerPrivateActions`. Also once a private
216
+ // action creator is bound to the store, it is cached to give it a stable identity.
217
+ const allActions = createPrivateProxy(actions, createBindingCache(name => privateActions[name], bindAction));
218
+
219
+ // An object that implements the `dispatch` object that is passed to thunk functions.
220
+ // It is callable (`dispatch( action )`) and also has methods (`dispatch.foo()`) that
221
+ // correspond to bound registered actions, both public and private. Implemented with the proxy
222
+ // `get` method, delegating to `allActions`.
223
+ const thunkDispatch = new Proxy(action => store.dispatch(action), {
224
+ get: (target, name) => allActions[name]
198
225
  });
226
+
227
+ // To the public `actions` object, add the "locked" `allActions` object. When used,
228
+ // `unlock( actions )` will return `allActions`, implementing a way how to get at the private actions.
199
229
  lock(actions, allActions);
200
- const resolvers = options.resolvers ? mapResolvers(options.resolvers) : {};
230
+
231
+ // If we have selector resolvers, convert them to a normalized form.
232
+ const resolvers = options.resolvers ? mapValues(options.resolvers, mapResolver) : {};
233
+
234
+ // Bind a selector to the store. Call the selector with the current state, correct registry,
235
+ // and if there is a resolver, attach the resolver logic to the selector.
201
236
  function bindSelector(selector, selectorName) {
202
237
  if (selector.isRegistrySelector) {
203
238
  selector.registry = registry;
@@ -205,8 +240,7 @@ export default function createReduxStore(key, options) {
205
240
  const boundSelector = (...args) => {
206
241
  args = normalize(selector, args);
207
242
  const state = store.__unstableOriginalGetState();
208
- // Before calling the selector, switch to the correct
209
- // registry.
243
+ // Before calling the selector, switch to the correct registry.
210
244
  if (selector.isRegistrySelector) {
211
245
  selector.registry = registry;
212
246
  }
@@ -222,47 +256,84 @@ export default function createReduxStore(key, options) {
222
256
  boundSelector.hasResolver = false;
223
257
  return boundSelector;
224
258
  }
225
- return mapSelectorWithResolver(boundSelector, selectorName, resolver, store, resolversCache);
259
+ return mapSelectorWithResolver(boundSelector, selectorName, resolver, store, resolversCache, boundMetadataSelectors);
226
260
  }
227
- function bindMetadataSelector(metaDataSelector) {
228
- const boundSelector = (...args) => {
229
- const state = store.__unstableOriginalGetState();
230
- const originalSelectorName = args && args[0];
231
- const originalSelectorArgs = args && args[1];
232
- const targetSelector = options?.selectors?.[originalSelectorName];
233
261
 
262
+ // Metadata selectors are bound differently: different state (`state.metadata`), no resolvers,
263
+ // normalization depending on the target selector.
264
+ function bindMetadataSelector(metaDataSelector) {
265
+ const boundSelector = (selectorName, selectorArgs, ...args) => {
234
266
  // Normalize the arguments passed to the target selector.
235
- if (originalSelectorName && targetSelector) {
236
- args[1] = normalize(targetSelector, originalSelectorArgs);
267
+ if (selectorName) {
268
+ const targetSelector = options.selectors?.[selectorName];
269
+ if (targetSelector) {
270
+ selectorArgs = normalize(targetSelector, selectorArgs);
271
+ }
237
272
  }
238
- return metaDataSelector(state.metadata, ...args);
273
+ const state = store.__unstableOriginalGetState();
274
+ return metaDataSelector(state.metadata, selectorName, selectorArgs, ...args);
239
275
  };
240
276
  boundSelector.hasResolver = false;
241
277
  return boundSelector;
242
278
  }
279
+
280
+ // Perform binding of both metadata and store selectors and combine them in one
281
+ // `selectors` object. These are all public selectors of the store.
282
+ const boundMetadataSelectors = mapValues(metadataSelectors, bindMetadataSelector);
283
+ const boundSelectors = mapValues(options.selectors, bindSelector);
243
284
  const selectors = {
244
- ...mapValues(metadataSelectors, bindMetadataSelector),
245
- ...mapValues(options.selectors, bindSelector)
285
+ ...boundMetadataSelectors,
286
+ ...boundSelectors
246
287
  };
247
- const boundPrivateSelectors = createBindingCache(bindSelector);
288
+
289
+ // Cache of bould private selectors. They are bound only when first accessed, because
290
+ // new private selectors can be registered at any time (with `registerPrivateSelectors`).
291
+ // Once bound, they are cached to give them a stable identity.
292
+ const boundPrivateSelectors = createBindingCache(name => privateSelectors[name], bindSelector);
293
+ const allSelectors = createPrivateProxy(selectors, boundPrivateSelectors);
248
294
 
249
295
  // Pre-bind the private selectors that have been registered by the time of
250
296
  // instantiation, so that registry selectors are bound to the registry.
251
- for (const [selectorName, selector] of Object.entries(privateSelectors)) {
252
- boundPrivateSelectors.get(selector, selectorName);
297
+ for (const selectorName of Object.keys(privateSelectors)) {
298
+ boundPrivateSelectors.get(selectorName);
253
299
  }
254
- const allSelectors = new Proxy(() => {}, {
255
- get: (target, prop) => {
256
- const privateSelector = privateSelectors[prop];
257
- return privateSelector ? boundPrivateSelectors.get(privateSelector, prop) : selectors[prop];
258
- }
259
- });
260
- const thunkSelectors = new Proxy(allSelectors, {
261
- apply: (target, thisArg, [selector]) => selector(store.__unstableOriginalGetState())
300
+
301
+ // An object that implements the `select` object that is passed to thunk functions.
302
+ // It is callable (`select( selector )`) and also has methods (`select.foo()`) that
303
+ // correspond to bound registered selectors, both public and private. Implemented with the proxy
304
+ // `get` method, delegating to `allSelectors`.
305
+ const thunkSelect = new Proxy(selector => selector(store.__unstableOriginalGetState()), {
306
+ get: (target, name) => allSelectors[name]
262
307
  });
308
+
309
+ // To the public `selectors` object, add the "locked" `allSelectors` object. When used,
310
+ // `unlock( selectors )` will return `allSelectors`, implementing a way how to get at the private selectors.
263
311
  lock(selectors, allSelectors);
264
- const resolveSelectors = mapResolveSelectors(selectors, store);
265
- const suspendSelectors = mapSuspendSelectors(selectors, store);
312
+
313
+ // For each selector, create a function that calls the selector, waits for resolution and returns
314
+ // a promise that resolves when the resolution is finished.
315
+ const bindResolveSelector = mapResolveSelector(store, boundMetadataSelectors);
316
+
317
+ // Now apply this function to all bound selectors, public and private. We are excluding
318
+ // metadata selectors because they don't have resolvers.
319
+ const resolveSelectors = mapValues(boundSelectors, bindResolveSelector);
320
+ const allResolveSelectors = createPrivateProxy(resolveSelectors, createBindingCache(name => boundPrivateSelectors.get(name), bindResolveSelector));
321
+
322
+ // Lock the selectors so that `unlock( resolveSelectors )` returns `allResolveSelectors`.
323
+ lock(resolveSelectors, allResolveSelectors);
324
+
325
+ // Now, in a way very similar to `bindResolveSelector`, we create a function that maps
326
+ // selectors to functions that throw a suspense promise if not yet resolved.
327
+ const bindSuspendSelector = mapSuspendSelector(store, boundMetadataSelectors);
328
+ const suspendSelectors = {
329
+ ...boundMetadataSelectors,
330
+ // no special suspense behavior
331
+ ...mapValues(boundSelectors, bindSuspendSelector)
332
+ };
333
+ const allSuspendSelectors = createPrivateProxy(suspendSelectors, createBindingCache(name => boundPrivateSelectors.get(name), bindSuspendSelector));
334
+
335
+ // Lock the selectors so that `unlock( suspendSelectors )` returns 'allSuspendSelectors`.
336
+ lock(suspendSelectors, allSuspendSelectors);
266
337
  const getSelectors = () => selectors;
267
338
  const getActions = () => actions;
268
339
  const getResolveSelectors = () => resolveSelectors;
@@ -311,7 +382,7 @@ export default function createReduxStore(key, options) {
311
382
 
312
383
  // Expose the private registration functions on the store
313
384
  // descriptor. That's a natural choice since that's where the
314
- // public actions and selectors are stored .
385
+ // public actions and selectors are stored.
315
386
  lock(storeDescriptor, privateRegistrationFunctions);
316
387
  return storeDescriptor;
317
388
  }
@@ -358,113 +429,99 @@ function instantiateReduxStore(key, options, registry, thunkArgs) {
358
429
  }
359
430
 
360
431
  /**
361
- * Maps selectors to functions that return a resolution promise for them
432
+ * Maps selectors to functions that return a resolution promise for them.
362
433
  *
363
- * @param {Object} selectors Selectors to map.
364
- * @param {Object} store The redux store the selectors select from.
434
+ * @param {Object} store The redux store the selectors are bound to.
435
+ * @param {Object} boundMetadataSelectors The bound metadata selectors.
365
436
  *
366
- * @return {Object} Selectors mapped to their resolution functions.
437
+ * @return {Function} Function that maps selectors to resolvers.
367
438
  */
368
- function mapResolveSelectors(selectors, store) {
369
- const {
370
- getIsResolving,
371
- hasStartedResolution,
372
- hasFinishedResolution,
373
- hasResolutionFailed,
374
- isResolving,
375
- getCachedResolvers,
376
- getResolutionState,
377
- getResolutionError,
378
- hasResolvingSelectors,
379
- countSelectorsByStatus,
380
- ...storeSelectors
381
- } = selectors;
382
- return mapValues(storeSelectors, (selector, selectorName) => {
439
+ function mapResolveSelector(store, boundMetadataSelectors) {
440
+ return (selector, selectorName) => {
383
441
  // If the selector doesn't have a resolver, just convert the return value
384
442
  // (including exceptions) to a Promise, no additional extra behavior is needed.
385
443
  if (!selector.hasResolver) {
386
444
  return async (...args) => selector.apply(null, args);
387
445
  }
388
- return (...args) => {
389
- return new Promise((resolve, reject) => {
390
- const hasFinished = () => selectors.hasFinishedResolution(selectorName, args);
391
- const finalize = result => {
392
- const hasFailed = selectors.hasResolutionFailed(selectorName, args);
393
- if (hasFailed) {
394
- const error = selectors.getResolutionError(selectorName, args);
395
- reject(error);
396
- } else {
397
- resolve(result);
398
- }
399
- };
400
- const getResult = () => selector.apply(null, args);
401
- // Trigger the selector (to trigger the resolver)
402
- const result = getResult();
446
+ return (...args) => new Promise((resolve, reject) => {
447
+ const hasFinished = () => {
448
+ return boundMetadataSelectors.hasFinishedResolution(selectorName, args);
449
+ };
450
+ const finalize = result => {
451
+ const hasFailed = boundMetadataSelectors.hasResolutionFailed(selectorName, args);
452
+ if (hasFailed) {
453
+ const error = boundMetadataSelectors.getResolutionError(selectorName, args);
454
+ reject(error);
455
+ } else {
456
+ resolve(result);
457
+ }
458
+ };
459
+ const getResult = () => selector.apply(null, args);
460
+
461
+ // Trigger the selector (to trigger the resolver)
462
+ const result = getResult();
463
+ if (hasFinished()) {
464
+ return finalize(result);
465
+ }
466
+ const unsubscribe = store.subscribe(() => {
403
467
  if (hasFinished()) {
404
- return finalize(result);
468
+ unsubscribe();
469
+ finalize(getResult());
405
470
  }
406
- const unsubscribe = store.subscribe(() => {
407
- if (hasFinished()) {
408
- unsubscribe();
409
- finalize(getResult());
410
- }
411
- });
412
471
  });
413
- };
414
- });
472
+ });
473
+ };
415
474
  }
416
475
 
417
476
  /**
418
477
  * Maps selectors to functions that throw a suspense promise if not yet resolved.
419
478
  *
420
- * @param {Object} selectors Selectors to map.
421
- * @param {Object} store The redux store the selectors select from.
479
+ * @param {Object} store The redux store the selectors select from.
480
+ * @param {Object} boundMetadataSelectors The bound metadata selectors.
422
481
  *
423
- * @return {Object} Selectors mapped to their suspense functions.
482
+ * @return {Function} Function that maps selectors to their suspending versions.
424
483
  */
425
- function mapSuspendSelectors(selectors, store) {
426
- return mapValues(selectors, (selector, selectorName) => {
484
+ function mapSuspendSelector(store, boundMetadataSelectors) {
485
+ return (selector, selectorName) => {
427
486
  // Selector without a resolver doesn't have any extra suspense behavior.
428
487
  if (!selector.hasResolver) {
429
488
  return selector;
430
489
  }
431
490
  return (...args) => {
432
491
  const result = selector.apply(null, args);
433
- if (selectors.hasFinishedResolution(selectorName, args)) {
434
- if (selectors.hasResolutionFailed(selectorName, args)) {
435
- throw selectors.getResolutionError(selectorName, args);
492
+ if (boundMetadataSelectors.hasFinishedResolution(selectorName, args)) {
493
+ if (boundMetadataSelectors.hasResolutionFailed(selectorName, args)) {
494
+ throw boundMetadataSelectors.getResolutionError(selectorName, args);
436
495
  }
437
496
  return result;
438
497
  }
439
498
  throw new Promise(resolve => {
440
499
  const unsubscribe = store.subscribe(() => {
441
- if (selectors.hasFinishedResolution(selectorName, args)) {
500
+ if (boundMetadataSelectors.hasFinishedResolution(selectorName, args)) {
442
501
  resolve();
443
502
  unsubscribe();
444
503
  }
445
504
  });
446
505
  });
447
506
  };
448
- });
507
+ };
449
508
  }
450
509
 
451
510
  /**
452
- * Convert resolvers to a normalized form, an object with `fulfill` method and
511
+ * Convert a resolver to a normalized form, an object with `fulfill` method and
453
512
  * optional methods like `isFulfilled`.
454
513
  *
455
- * @param {Object} resolvers Resolver to convert
514
+ * @param {Function} resolver Resolver to convert
456
515
  */
457
- function mapResolvers(resolvers) {
458
- return mapValues(resolvers, resolver => {
459
- if (resolver.fulfill) {
460
- return resolver;
461
- }
462
- return {
463
- ...resolver,
464
- // Copy the enumerable properties of the resolver function.
465
- fulfill: resolver // Add the fulfill method.
466
- };
467
- });
516
+ function mapResolver(resolver) {
517
+ if (resolver.fulfill) {
518
+ return resolver;
519
+ }
520
+ return {
521
+ ...resolver,
522
+ // Copy the enumerable properties of the resolver function.
523
+ fulfill: resolver // Add the fulfill method.
524
+ };
468
525
  }
469
526
 
470
527
  /**
@@ -472,22 +529,20 @@ function mapResolvers(resolvers) {
472
529
  * Resolvers are side effects invoked once per argument set of a given selector call,
473
530
  * used in ensuring that the data needs for the selector are satisfied.
474
531
  *
475
- * @param {Object} selector The selector function to be bound.
476
- * @param {string} selectorName The selector name.
477
- * @param {Object} resolver Resolver to call.
478
- * @param {Object} store The redux store to which the resolvers should be mapped.
479
- * @param {Object} resolversCache Resolvers Cache.
532
+ * @param {Object} selector The selector function to be bound.
533
+ * @param {string} selectorName The selector name.
534
+ * @param {Object} resolver Resolver to call.
535
+ * @param {Object} store The redux store to which the resolvers should be mapped.
536
+ * @param {Object} resolversCache Resolvers Cache.
537
+ * @param {Object} boundMetadataSelectors The bound metadata selectors.
480
538
  */
481
- function mapSelectorWithResolver(selector, selectorName, resolver, store, resolversCache) {
539
+ function mapSelectorWithResolver(selector, selectorName, resolver, store, resolversCache, boundMetadataSelectors) {
482
540
  function fulfillSelector(args) {
483
541
  const state = store.getState();
484
542
  if (resolversCache.isRunning(selectorName, args) || typeof resolver.isFulfilled === 'function' && resolver.isFulfilled(state, ...args)) {
485
543
  return;
486
544
  }
487
- const {
488
- metadata
489
- } = store.__unstableOriginalGetState();
490
- if (metadataSelectors.hasStartedResolution(metadata, selectorName, args)) {
545
+ if (boundMetadataSelectors.hasStartedResolution(selectorName, args)) {
491
546
  return;
492
547
  }
493
548
  resolversCache.markAsRunning(selectorName, args);