@wordpress/data 6.1.3 → 6.1.4
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/build/components/async-mode-provider/context.js +1 -1
- package/build/components/async-mode-provider/index.js +8 -6
- package/build/components/async-mode-provider/index.js.map +1 -1
- package/build/components/registry-provider/index.js +8 -6
- package/build/components/registry-provider/index.js.map +1 -1
- package/build/components/use-dispatch/use-dispatch-with-map.js +3 -1
- package/build/components/use-dispatch/use-dispatch-with-map.js.map +1 -1
- package/build/controls.js +38 -19
- package/build/controls.js.map +1 -1
- package/build/factory.js +4 -2
- package/build/factory.js.map +1 -1
- package/build/index.js +35 -33
- package/build/index.js.map +1 -1
- package/build/plugins/persistence/index.js +2 -1
- package/build/plugins/persistence/index.js.map +1 -1
- package/build/redux-store/index.js +47 -19
- package/build/redux-store/index.js.map +1 -1
- package/build/redux-store/metadata/actions.js +2 -2
- package/build/redux-store/metadata/reducer.js +8 -2
- package/build/redux-store/metadata/reducer.js.map +1 -1
- package/build/redux-store/metadata/selectors.js +8 -5
- package/build/redux-store/metadata/selectors.js.map +1 -1
- package/build/redux-store/metadata/utils.js +5 -5
- package/build/redux-store/metadata/utils.js.map +1 -1
- package/build/registry.js +7 -2
- package/build/registry.js.map +1 -1
- package/build/resolvers-cache-middleware.js +2 -1
- package/build/resolvers-cache-middleware.js.map +1 -1
- package/build/store/index.js +10 -2
- package/build/store/index.js.map +1 -1
- package/build/types.js +4 -0
- package/build-module/components/use-dispatch/use-dispatch-with-map.js +3 -1
- package/build-module/components/use-dispatch/use-dispatch-with-map.js.map +1 -1
- package/build-module/controls.js +37 -18
- package/build-module/controls.js.map +1 -1
- package/build-module/factory.js +3 -1
- package/build-module/factory.js.map +1 -1
- package/build-module/redux-store/index.js +43 -17
- package/build-module/redux-store/index.js.map +1 -1
- package/build-module/redux-store/metadata/reducer.js +8 -2
- package/build-module/redux-store/metadata/reducer.js.map +1 -1
- package/build-module/redux-store/metadata/selectors.js +6 -3
- package/build-module/redux-store/metadata/selectors.js.map +1 -1
- package/build-module/redux-store/metadata/utils.js +5 -5
- package/build-module/redux-store/metadata/utils.js.map +1 -1
- package/build-module/registry.js +7 -2
- package/build-module/registry.js.map +1 -1
- package/build-module/resolvers-cache-middleware.js +2 -1
- package/build-module/resolvers-cache-middleware.js.map +1 -1
- package/build-module/store/index.js +10 -2
- package/build-module/store/index.js.map +1 -1
- package/build-module/types.js +1 -1
- package/package.json +9 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/data/src/registry.js"],"names":["mapValues","isObject","forEach","createReduxStore","createCoreDataStore","STORE_NAME","createEmitter","createRegistry","storeConfigs","parent","stores","emitter","__experimentalListeningStores","Set","globalListener","emit","subscribe","listener","select","storeNameOrDefinition","storeName","name","add","store","getSelectors","__experimentalMarkListeningStores","callback","ref","clear","result","call","current","Array","from","resolveSelect","getResolveSelectors","dispatch","getActions","withPlugins","attributes","attribute","key","registry","apply","arguments","registerGenericStore","config","TypeError","currentSubscribe","unsubscribeFromStoreEmitter","unsubscribeFromRootStore","isPaused","register","instantiate","__experimentalSubscribeStore","handler","batch","pause","resume","namespaces","use","registerStore","options","reducer","plugin","Object","entries"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAT,EAAoBC,QAApB,EAA8BC,OAA9B,QAA6C,QAA7C;AAEA;AACA;AACA;;AACA,OAAOC,gBAAP,MAA6B,eAA7B;AACA,OAAOC,mBAAP,MAAgC,SAAhC;AACA,SAASC,UAAT,QAA2B,cAA3B;AACA,SAASC,aAAT,QAA8B,iBAA9B;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,cAAT,CAAyBC,YAAY,GAAG,EAAxC,EAA4CC,MAAM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,oBAAoB,CAAEzB,SAAF,EAAaG,KAAb,CAApB;AACA,WAAOA,KAAK,CAACA,KAAb;AACA,GAVD,CAzNkE,CAqOlE;AACA;AACA;AACA;;;AACA,WAASqC,GAAT,CAAcI,MAAd,EAAsBF,OAAtB,EAAgC;AAC/BpB,IAAAA,QAAQ,GAAG,EACV,GAAGA,QADO;AAEV,SAAGsB,MAAM,CAAEtB,QAAF,EAAYoB,OAAZ;AAFC,KAAX;AAKA,WAAOpB,QAAP;AACA;;AAEDG,EAAAA,oBAAoB,CAAExC,UAAF,EAAcD,mBAAmB,CAAEsC,QAAF,CAAjC,CAApB;AAEAuB,EAAAA,MAAM,CAACC,OAAP,CAAgB1D,YAAhB,EAA+BN,OAA/B,CAAwC,CAAE,CAAEmB,IAAF,EAAQyB,MAAR,CAAF,KACvCJ,QAAQ,CAACmB,aAAT,CAAwBxC,IAAxB,EAA8ByB,MAA9B,CADD;;AAIA,MAAKrC,MAAL,EAAc;AACbA,IAAAA,MAAM,CAACO,SAAP,CAAkBF,cAAlB;AACA;;AAED,SAAOwB,WAAW,CAAEI,QAAF,CAAlB;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { mapValues, isObject, forEach } from 'lodash';\n\n/**\n * Internal dependencies\n */\nimport createReduxStore from './redux-store';\nimport createCoreDataStore from './store';\nimport { STORE_NAME } from './store/name';\nimport { createEmitter } from './utils/emitter';\n\n/** @typedef {import('./types').WPDataStore} WPDataStore */\n\n/**\n * @typedef {Object} WPDataRegistry An isolated orchestrator of store registrations.\n *\n * @property {Function} registerGenericStore Given a namespace key and settings\n * object, registers a new generic\n * store.\n * @property {Function} registerStore Given a namespace key and settings\n * object, registers a new namespace\n * store.\n * @property {Function} subscribe Given a function callback, invokes\n * the callback on any change to state\n * within any registered store.\n * @property {Function} select Given a namespace key, returns an\n * object of the store's registered\n * selectors.\n * @property {Function} dispatch Given a namespace key, returns an\n * object of the store's registered\n * action dispatchers.\n */\n\n/**\n * @typedef {Object} WPDataPlugin An object of registry function overrides.\n *\n * @property {Function} registerStore registers store.\n */\n\n/**\n * Creates a new store registry, given an optional object of initial store\n * configurations.\n *\n * @param {Object} storeConfigs Initial store configurations.\n * @param {Object?} parent Parent registry.\n *\n * @return {WPDataRegistry} Data registry.\n */\nexport function createRegistry( storeConfigs = {}, parent = null ) {\n\tconst stores = {};\n\tconst emitter = createEmitter();\n\tconst __experimentalListeningStores = new Set();\n\n\t/**\n\t * Global listener called for each store's update.\n\t */\n\tfunction globalListener() {\n\t\temitter.emit();\n\t}\n\n\t/**\n\t * Subscribe to changes to any data.\n\t *\n\t * @param {Function} listener Listener function.\n\t *\n\t * @return {Function} Unsubscribe function.\n\t */\n\tconst subscribe = ( listener ) => {\n\t\treturn emitter.subscribe( listener );\n\t};\n\n\t/**\n\t * Calls a selector given the current state and extra arguments.\n\t *\n\t * @param {string|WPDataStore} storeNameOrDefinition Unique namespace identifier for the store\n\t * or the store definition.\n\t *\n\t * @return {*} The selector's returned value.\n\t */\n\tfunction select( storeNameOrDefinition ) {\n\t\tconst storeName = isObject( storeNameOrDefinition )\n\t\t\t? storeNameOrDefinition.name\n\t\t\t: storeNameOrDefinition;\n\t\t__experimentalListeningStores.add( storeName );\n\t\tconst store = stores[ storeName ];\n\t\tif ( store ) {\n\t\t\treturn store.getSelectors();\n\t\t}\n\n\t\treturn parent && parent.select( storeName );\n\t}\n\n\tfunction __experimentalMarkListeningStores( callback, ref ) {\n\t\t__experimentalListeningStores.clear();\n\t\tconst result = callback.call( this );\n\t\tref.current = Array.from( __experimentalListeningStores );\n\t\treturn result;\n\t}\n\n\t/**\n\t * Given the name of a registered store, returns an object containing the store's\n\t * selectors pre-bound to state so that you only need to supply additional arguments,\n\t * and modified so that they return promises that resolve to their eventual values,\n\t * after any resolvers have ran.\n\t *\n\t * @param {string|WPDataStore} storeNameOrDefinition Unique namespace identifier for the store\n\t * or the store definition.\n\t *\n\t * @return {Object} Each key of the object matches the name of a selector.\n\t */\n\tfunction resolveSelect( storeNameOrDefinition ) {\n\t\tconst storeName = isObject( storeNameOrDefinition )\n\t\t\t? storeNameOrDefinition.name\n\t\t\t: storeNameOrDefinition;\n\t\t__experimentalListeningStores.add( storeName );\n\t\tconst store = stores[ storeName ];\n\t\tif ( store ) {\n\t\t\treturn store.getResolveSelectors();\n\t\t}\n\n\t\treturn parent && parent.resolveSelect( storeName );\n\t}\n\n\t/**\n\t * Returns the available actions for a part of the state.\n\t *\n\t * @param {string|WPDataStore} storeNameOrDefinition Unique namespace identifier for the store\n\t * or the store definition.\n\t *\n\t * @return {*} The action's returned value.\n\t */\n\tfunction dispatch( storeNameOrDefinition ) {\n\t\tconst storeName = isObject( storeNameOrDefinition )\n\t\t\t? storeNameOrDefinition.name\n\t\t\t: storeNameOrDefinition;\n\t\tconst store = stores[ storeName ];\n\t\tif ( store ) {\n\t\t\treturn store.getActions();\n\t\t}\n\n\t\treturn parent && parent.dispatch( storeName );\n\t}\n\n\t//\n\t// Deprecated\n\t// TODO: Remove this after `use()` is removed.\n\t//\n\tfunction withPlugins( attributes ) {\n\t\treturn mapValues( attributes, ( attribute, key ) => {\n\t\t\tif ( typeof attribute !== 'function' ) {\n\t\t\t\treturn attribute;\n\t\t\t}\n\t\t\treturn function () {\n\t\t\t\treturn registry[ key ].apply( null, arguments );\n\t\t\t};\n\t\t} );\n\t}\n\n\t/**\n\t * Registers a generic store.\n\t *\n\t * @param {string} key Store registry key.\n\t * @param {Object} config Configuration (getSelectors, getActions, subscribe).\n\t */\n\tfunction registerGenericStore( key, config ) {\n\t\tif ( typeof config.getSelectors !== 'function' ) {\n\t\t\tthrow new TypeError( 'config.getSelectors must be a function' );\n\t\t}\n\t\tif ( typeof config.getActions !== 'function' ) {\n\t\t\tthrow new TypeError( 'config.getActions must be a function' );\n\t\t}\n\t\tif ( typeof config.subscribe !== 'function' ) {\n\t\t\tthrow new TypeError( 'config.subscribe must be a function' );\n\t\t}\n\t\t// Thi emitter is used to keep track of active listeners when the registry\n\t\t// get paused, that way, when resumed we should be able to call all these\n\t\t// pending listeners.\n\t\tconfig.emitter = createEmitter();\n\t\tconst currentSubscribe = config.subscribe;\n\t\tconfig.subscribe = ( listener ) => {\n\t\t\tconst unsubscribeFromStoreEmitter = config.emitter.subscribe(\n\t\t\t\tlistener\n\t\t\t);\n\t\t\tconst unsubscribeFromRootStore = currentSubscribe( () => {\n\t\t\t\tif ( config.emitter.isPaused ) {\n\t\t\t\t\tconfig.emitter.emit();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlistener();\n\t\t\t} );\n\n\t\t\treturn () => {\n\t\t\t\tif ( unsubscribeFromRootStore ) {\n\t\t\t\t\tunsubscribeFromRootStore();\n\t\t\t\t}\n\t\t\t\tunsubscribeFromStoreEmitter();\n\t\t\t};\n\t\t};\n\t\tstores[ key ] = config;\n\t\tconfig.subscribe( globalListener );\n\t}\n\n\t/**\n\t * Registers a new store definition.\n\t *\n\t * @param {WPDataStore} store Store definition.\n\t */\n\tfunction register( store ) {\n\t\tregisterGenericStore( store.name, store.instantiate( registry ) );\n\t}\n\n\t/**\n\t * Subscribe handler to a store.\n\t *\n\t * @param {string[]} storeName The store name.\n\t * @param {Function} handler The function subscribed to the store.\n\t * @return {Function} A function to unsubscribe the handler.\n\t */\n\tfunction __experimentalSubscribeStore( storeName, handler ) {\n\t\tif ( storeName in stores ) {\n\t\t\treturn stores[ storeName ].subscribe( handler );\n\t\t}\n\n\t\t// Trying to access a store that hasn't been registered,\n\t\t// this is a pattern rarely used but seen in some places.\n\t\t// We fallback to regular `subscribe` here for backward-compatibility for now.\n\t\t// See https://github.com/WordPress/gutenberg/pull/27466 for more info.\n\t\tif ( ! parent ) {\n\t\t\treturn subscribe( handler );\n\t\t}\n\n\t\treturn parent.__experimentalSubscribeStore( storeName, handler );\n\t}\n\n\tfunction batch( callback ) {\n\t\temitter.pause();\n\t\tforEach( stores, ( store ) => store.emitter.pause() );\n\t\tcallback();\n\t\temitter.resume();\n\t\tforEach( stores, ( store ) => store.emitter.resume() );\n\t}\n\n\tlet registry = {\n\t\tbatch,\n\t\tregisterGenericStore,\n\t\tstores,\n\t\tnamespaces: stores, // TODO: Deprecate/remove this.\n\t\tsubscribe,\n\t\tselect,\n\t\tresolveSelect,\n\t\tdispatch,\n\t\tuse,\n\t\tregister,\n\t\t__experimentalMarkListeningStores,\n\t\t__experimentalSubscribeStore,\n\t};\n\n\t/**\n\t * Registers a standard `@wordpress/data` store.\n\t *\n\t * @param {string} storeName Unique namespace identifier.\n\t * @param {Object} options Store description (reducer, actions, selectors, resolvers).\n\t *\n\t * @return {Object} Registered store object.\n\t */\n\tregistry.registerStore = ( storeName, options ) => {\n\t\tif ( ! options.reducer ) {\n\t\t\tthrow new TypeError( 'Must specify store reducer' );\n\t\t}\n\n\t\tconst store = createReduxStore( storeName, options ).instantiate(\n\t\t\tregistry\n\t\t);\n\t\tregisterGenericStore( storeName, store );\n\t\treturn store.store;\n\t};\n\n\t//\n\t// TODO:\n\t// This function will be deprecated as soon as it is no longer internally referenced.\n\t//\n\tfunction use( plugin, options ) {\n\t\tregistry = {\n\t\t\t...registry,\n\t\t\t...plugin( registry, options ),\n\t\t};\n\n\t\treturn registry;\n\t}\n\n\tregisterGenericStore( STORE_NAME, createCoreDataStore( registry ) );\n\n\tObject.entries( storeConfigs ).forEach( ( [ name, config ] ) =>\n\t\tregistry.registerStore( name, config )\n\t);\n\n\tif ( parent ) {\n\t\tparent.subscribe( globalListener );\n\t}\n\n\treturn withPlugins( registry );\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/data/src/registry.js"],"names":["mapValues","isObject","forEach","createReduxStore","createCoreDataStore","STORE_NAME","createEmitter","createRegistry","storeConfigs","parent","stores","emitter","__experimentalListeningStores","Set","globalListener","emit","subscribe","listener","select","storeNameOrDefinition","storeName","name","add","store","getSelectors","__experimentalMarkListeningStores","callback","ref","clear","result","call","current","Array","from","resolveSelect","getResolveSelectors","dispatch","getActions","withPlugins","attributes","attribute","key","registry","apply","arguments","registerGenericStore","config","TypeError","currentSubscribe","unsubscribeFromStoreEmitter","unsubscribeFromRootStore","isPaused","register","instantiate","__experimentalSubscribeStore","handler","batch","pause","resume","namespaces","use","registerStore","options","reducer","plugin","Object","entries"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAT,EAAoBC,QAApB,EAA8BC,OAA9B,QAA6C,QAA7C;AAEA;AACA;AACA;;AACA,OAAOC,gBAAP,MAA6B,eAA7B;AACA,OAAOC,mBAAP,MAAgC,SAAhC;AACA,SAASC,UAAT,QAA2B,cAA3B;AACA,SAASC,aAAT,QAA8B,iBAA9B;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,cAAT,GAA4D;AAAA,MAAnCC,YAAmC,uEAApB,EAAoB;AAAA,MAAhBC,MAAgB,uEAAP,IAAO;AAClE,QAAMC,MAAM,GAAG,EAAf;AACA,QAAMC,OAAO,GAAGL,aAAa,EAA7B;;AACA,QAAMM,6BAA6B,GAAG,IAAIC,GAAJ,EAAtC;AAEA;AACD;AACA;;;AACC,WAASC,cAAT,GAA0B;AACzBH,IAAAA,OAAO,CAACI,IAAR;AACA;AAED;AACD;AACA;AACA;AACA;AACA;AACA;;;AACC,QAAMC,SAAS,GAAKC,QAAF,IAAgB;AACjC,WAAON,OAAO,CAACK,SAAR,CAAmBC,QAAnB,CAAP;AACA,GAFD;AAIA;AACD;AACA;AACA;AACA;AACA;AACA;AACA;;;AACC,WAASC,MAAT,CAAiBC,qBAAjB,EAAyC;AACxC,UAAMC,SAAS,GAAGnB,QAAQ,CAAEkB,qBAAF,CAAR,GACfA,qBAAqB,CAACE,IADP,GAEfF,qBAFH;;AAGAP,IAAAA,6BAA6B,CAACU,GAA9B,CAAmCF,SAAnC;;AACA,UAAMG,KAAK,G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C,MAAL,EAAc;AACbA,IAAAA,MAAM,CAACO,SAAP,CAAkBF,cAAlB;AACA;;AAED,SAAOwB,WAAW,CAAEI,QAAF,CAAlB;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { mapValues, isObject, forEach } from 'lodash';\n\n/**\n * Internal dependencies\n */\nimport createReduxStore from './redux-store';\nimport createCoreDataStore from './store';\nimport { STORE_NAME } from './store/name';\nimport { createEmitter } from './utils/emitter';\n\n/** @typedef {import('./types').WPDataStore} WPDataStore */\n\n/**\n * @typedef {Object} WPDataRegistry An isolated orchestrator of store registrations.\n *\n * @property {Function} registerGenericStore Given a namespace key and settings\n * object, registers a new generic\n * store.\n * @property {Function} registerStore Given a namespace key and settings\n * object, registers a new namespace\n * store.\n * @property {Function} subscribe Given a function callback, invokes\n * the callback on any change to state\n * within any registered store.\n * @property {Function} select Given a namespace key, returns an\n * object of the store's registered\n * selectors.\n * @property {Function} dispatch Given a namespace key, returns an\n * object of the store's registered\n * action dispatchers.\n */\n\n/**\n * @typedef {Object} WPDataPlugin An object of registry function overrides.\n *\n * @property {Function} registerStore registers store.\n */\n\n/**\n * Creates a new store registry, given an optional object of initial store\n * configurations.\n *\n * @param {Object} storeConfigs Initial store configurations.\n * @param {Object?} parent Parent registry.\n *\n * @return {WPDataRegistry} Data registry.\n */\nexport function createRegistry( storeConfigs = {}, parent = null ) {\n\tconst stores = {};\n\tconst emitter = createEmitter();\n\tconst __experimentalListeningStores = new Set();\n\n\t/**\n\t * Global listener called for each store's update.\n\t */\n\tfunction globalListener() {\n\t\temitter.emit();\n\t}\n\n\t/**\n\t * Subscribe to changes to any data.\n\t *\n\t * @param {Function} listener Listener function.\n\t *\n\t * @return {Function} Unsubscribe function.\n\t */\n\tconst subscribe = ( listener ) => {\n\t\treturn emitter.subscribe( listener );\n\t};\n\n\t/**\n\t * Calls a selector given the current state and extra arguments.\n\t *\n\t * @param {string|WPDataStore} storeNameOrDefinition Unique namespace identifier for the store\n\t * or the store definition.\n\t *\n\t * @return {*} The selector's returned value.\n\t */\n\tfunction select( storeNameOrDefinition ) {\n\t\tconst storeName = isObject( storeNameOrDefinition )\n\t\t\t? storeNameOrDefinition.name\n\t\t\t: storeNameOrDefinition;\n\t\t__experimentalListeningStores.add( storeName );\n\t\tconst store = stores[ storeName ];\n\t\tif ( store ) {\n\t\t\treturn store.getSelectors();\n\t\t}\n\n\t\treturn parent && parent.select( storeName );\n\t}\n\n\tfunction __experimentalMarkListeningStores( callback, ref ) {\n\t\t__experimentalListeningStores.clear();\n\t\tconst result = callback.call( this );\n\t\tref.current = Array.from( __experimentalListeningStores );\n\t\treturn result;\n\t}\n\n\t/**\n\t * Given the name of a registered store, returns an object containing the store's\n\t * selectors pre-bound to state so that you only need to supply additional arguments,\n\t * and modified so that they return promises that resolve to their eventual values,\n\t * after any resolvers have ran.\n\t *\n\t * @param {string|WPDataStore} storeNameOrDefinition Unique namespace identifier for the store\n\t * or the store definition.\n\t *\n\t * @return {Object} Each key of the object matches the name of a selector.\n\t */\n\tfunction resolveSelect( storeNameOrDefinition ) {\n\t\tconst storeName = isObject( storeNameOrDefinition )\n\t\t\t? storeNameOrDefinition.name\n\t\t\t: storeNameOrDefinition;\n\t\t__experimentalListeningStores.add( storeName );\n\t\tconst store = stores[ storeName ];\n\t\tif ( store ) {\n\t\t\treturn store.getResolveSelectors();\n\t\t}\n\n\t\treturn parent && parent.resolveSelect( storeName );\n\t}\n\n\t/**\n\t * Returns the available actions for a part of the state.\n\t *\n\t * @param {string|WPDataStore} storeNameOrDefinition Unique namespace identifier for the store\n\t * or the store definition.\n\t *\n\t * @return {*} The action's returned value.\n\t */\n\tfunction dispatch( storeNameOrDefinition ) {\n\t\tconst storeName = isObject( storeNameOrDefinition )\n\t\t\t? storeNameOrDefinition.name\n\t\t\t: storeNameOrDefinition;\n\t\tconst store = stores[ storeName ];\n\t\tif ( store ) {\n\t\t\treturn store.getActions();\n\t\t}\n\n\t\treturn parent && parent.dispatch( storeName );\n\t}\n\n\t//\n\t// Deprecated\n\t// TODO: Remove this after `use()` is removed.\n\t//\n\tfunction withPlugins( attributes ) {\n\t\treturn mapValues( attributes, ( attribute, key ) => {\n\t\t\tif ( typeof attribute !== 'function' ) {\n\t\t\t\treturn attribute;\n\t\t\t}\n\t\t\treturn function () {\n\t\t\t\treturn registry[ key ].apply( null, arguments );\n\t\t\t};\n\t\t} );\n\t}\n\n\t/**\n\t * Registers a generic store.\n\t *\n\t * @param {string} key Store registry key.\n\t * @param {Object} config Configuration (getSelectors, getActions, subscribe).\n\t */\n\tfunction registerGenericStore( key, config ) {\n\t\tif ( typeof config.getSelectors !== 'function' ) {\n\t\t\tthrow new TypeError( 'config.getSelectors must be a function' );\n\t\t}\n\t\tif ( typeof config.getActions !== 'function' ) {\n\t\t\tthrow new TypeError( 'config.getActions must be a function' );\n\t\t}\n\t\tif ( typeof config.subscribe !== 'function' ) {\n\t\t\tthrow new TypeError( 'config.subscribe must be a function' );\n\t\t}\n\t\t// Thi emitter is used to keep track of active listeners when the registry\n\t\t// get paused, that way, when resumed we should be able to call all these\n\t\t// pending listeners.\n\t\tconfig.emitter = createEmitter();\n\t\tconst currentSubscribe = config.subscribe;\n\t\tconfig.subscribe = ( listener ) => {\n\t\t\tconst unsubscribeFromStoreEmitter = config.emitter.subscribe(\n\t\t\t\tlistener\n\t\t\t);\n\t\t\tconst unsubscribeFromRootStore = currentSubscribe( () => {\n\t\t\t\tif ( config.emitter.isPaused ) {\n\t\t\t\t\tconfig.emitter.emit();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlistener();\n\t\t\t} );\n\n\t\t\treturn () => {\n\t\t\t\tif ( unsubscribeFromRootStore ) {\n\t\t\t\t\tunsubscribeFromRootStore();\n\t\t\t\t}\n\t\t\t\tunsubscribeFromStoreEmitter();\n\t\t\t};\n\t\t};\n\t\tstores[ key ] = config;\n\t\tconfig.subscribe( globalListener );\n\t}\n\n\t/**\n\t * Registers a new store definition.\n\t *\n\t * @param {WPDataStore} store Store definition.\n\t */\n\tfunction register( store ) {\n\t\tregisterGenericStore( store.name, store.instantiate( registry ) );\n\t}\n\n\t/**\n\t * Subscribe handler to a store.\n\t *\n\t * @param {string[]} storeName The store name.\n\t * @param {Function} handler The function subscribed to the store.\n\t * @return {Function} A function to unsubscribe the handler.\n\t */\n\tfunction __experimentalSubscribeStore( storeName, handler ) {\n\t\tif ( storeName in stores ) {\n\t\t\treturn stores[ storeName ].subscribe( handler );\n\t\t}\n\n\t\t// Trying to access a store that hasn't been registered,\n\t\t// this is a pattern rarely used but seen in some places.\n\t\t// We fallback to regular `subscribe` here for backward-compatibility for now.\n\t\t// See https://github.com/WordPress/gutenberg/pull/27466 for more info.\n\t\tif ( ! parent ) {\n\t\t\treturn subscribe( handler );\n\t\t}\n\n\t\treturn parent.__experimentalSubscribeStore( storeName, handler );\n\t}\n\n\tfunction batch( callback ) {\n\t\temitter.pause();\n\t\tforEach( stores, ( store ) => store.emitter.pause() );\n\t\tcallback();\n\t\temitter.resume();\n\t\tforEach( stores, ( store ) => store.emitter.resume() );\n\t}\n\n\tlet registry = {\n\t\tbatch,\n\t\tregisterGenericStore,\n\t\tstores,\n\t\tnamespaces: stores, // TODO: Deprecate/remove this.\n\t\tsubscribe,\n\t\tselect,\n\t\tresolveSelect,\n\t\tdispatch,\n\t\tuse,\n\t\tregister,\n\t\t__experimentalMarkListeningStores,\n\t\t__experimentalSubscribeStore,\n\t};\n\n\t/**\n\t * Registers a standard `@wordpress/data` store.\n\t *\n\t * @param {string} storeName Unique namespace identifier.\n\t * @param {Object} options Store description (reducer, actions, selectors, resolvers).\n\t *\n\t * @return {Object} Registered store object.\n\t */\n\tregistry.registerStore = ( storeName, options ) => {\n\t\tif ( ! options.reducer ) {\n\t\t\tthrow new TypeError( 'Must specify store reducer' );\n\t\t}\n\n\t\tconst store = createReduxStore( storeName, options ).instantiate(\n\t\t\tregistry\n\t\t);\n\t\tregisterGenericStore( storeName, store );\n\t\treturn store.store;\n\t};\n\n\t//\n\t// TODO:\n\t// This function will be deprecated as soon as it is no longer internally referenced.\n\t//\n\tfunction use( plugin, options ) {\n\t\tregistry = {\n\t\t\t...registry,\n\t\t\t...plugin( registry, options ),\n\t\t};\n\n\t\treturn registry;\n\t}\n\n\tregisterGenericStore( STORE_NAME, createCoreDataStore( registry ) );\n\n\tObject.entries( storeConfigs ).forEach( ( [ name, config ] ) =>\n\t\tregistry.registerStore( name, config )\n\t);\n\n\tif ( parent ) {\n\t\tparent.subscribe( globalListener );\n\t}\n\n\treturn withPlugins( registry );\n}\n"]}
|
|
@@ -22,7 +22,8 @@ import { STORE_NAME } from './store/name';
|
|
|
22
22
|
|
|
23
23
|
const createResolversCacheMiddleware = (registry, reducerKey) => () => next => action => {
|
|
24
24
|
const resolvers = registry.select(STORE_NAME).getCachedResolvers(reducerKey);
|
|
25
|
-
Object.entries(resolvers).forEach(
|
|
25
|
+
Object.entries(resolvers).forEach(_ref => {
|
|
26
|
+
let [selectorName, resolversByArgs] = _ref;
|
|
26
27
|
const resolver = get(registry.stores, [reducerKey, 'resolvers', selectorName]);
|
|
27
28
|
|
|
28
29
|
if (!resolver || !resolver.shouldInvalidate) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/data/src/resolvers-cache-middleware.js"],"names":["get","STORE_NAME","createResolversCacheMiddleware","registry","reducerKey","next","action","resolvers","select","getCachedResolvers","Object","entries","forEach","selectorName","resolversByArgs","resolver","stores","shouldInvalidate","value","args","dispatch","invalidateResolution"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,GAAT,QAAoB,QAApB;AAEA;AACA;AACA;;AACA,SAASC,UAAT,QAA2B,cAA3B;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMC,8BAA8B,GAAG,CAAEC,QAAF,EAAYC,UAAZ,KAA4B,MAClEC,IADwE,IAElEC,MAAF,IAAc;AAClB,QAAMC,SAAS,GAAGJ,QAAQ,CACxBK,MADgB,CACRP,UADQ,EAEhBQ,kBAFgB,CAEIL,UAFJ,CAAlB;AAGAM,EAAAA,MAAM,CAACC,OAAP,CAAgBJ,SAAhB,EAA4BK,OAA5B,CACC,
|
|
1
|
+
{"version":3,"sources":["@wordpress/data/src/resolvers-cache-middleware.js"],"names":["get","STORE_NAME","createResolversCacheMiddleware","registry","reducerKey","next","action","resolvers","select","getCachedResolvers","Object","entries","forEach","selectorName","resolversByArgs","resolver","stores","shouldInvalidate","value","args","dispatch","invalidateResolution"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,GAAT,QAAoB,QAApB;AAEA;AACA;AACA;;AACA,SAASC,UAAT,QAA2B,cAA3B;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMC,8BAA8B,GAAG,CAAEC,QAAF,EAAYC,UAAZ,KAA4B,MAClEC,IADwE,IAElEC,MAAF,IAAc;AAClB,QAAMC,SAAS,GAAGJ,QAAQ,CACxBK,MADgB,CACRP,UADQ,EAEhBQ,kBAFgB,CAEIL,UAFJ,CAAlB;AAGAM,EAAAA,MAAM,CAACC,OAAP,CAAgBJ,SAAhB,EAA4BK,OAA5B,CACC,QAAyC;AAAA,QAAvC,CAAEC,YAAF,EAAgBC,eAAhB,CAAuC;AACxC,UAAMC,QAAQ,GAAGf,GAAG,CAAEG,QAAQ,CAACa,MAAX,EAAmB,CACtCZ,UADsC,EAEtC,WAFsC,EAGtCS,YAHsC,CAAnB,CAApB;;AAKA,QAAK,CAAEE,QAAF,IAAc,CAAEA,QAAQ,CAACE,gBAA9B,EAAiD;AAChD;AACA;;AACDH,IAAAA,eAAe,CAACF,OAAhB,CAAyB,CAAEM,KAAF,EAASC,IAAT,KAAmB;AAC3C;AACA;AACA;AACA,UACCD,KAAK,KAAK,KAAV,IACA,CAAEH,QAAQ,CAACE,gBAAT,CAA2BX,MAA3B,EAAmC,GAAGa,IAAtC,CAFH,EAGE;AACD;AACA,OAT0C,CAW3C;;;AACAhB,MAAAA,QAAQ,CACNiB,QADF,CACYnB,UADZ,EAEEoB,oBAFF,CAEwBjB,UAFxB,EAEoCS,YAFpC,EAEkDM,IAFlD;AAGA,KAfD;AAgBA,GA1BF;AA4BA,SAAOd,IAAI,CAAEC,MAAF,CAAX;AACA,CAnCD;;AAqCA,eAAeJ,8BAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { get } from 'lodash';\n\n/**\n * Internal dependencies\n */\nimport { STORE_NAME } from './store/name';\n\n/** @typedef {import('./registry').WPDataRegistry} WPDataRegistry */\n\n/**\n * Creates a middleware handling resolvers cache invalidation.\n *\n * @param {WPDataRegistry} registry The registry reference for which to create\n * the middleware.\n * @param {string} reducerKey The namespace for which to create the\n * middleware.\n *\n * @return {Function} Middleware function.\n */\nconst createResolversCacheMiddleware = ( registry, reducerKey ) => () => (\n\tnext\n) => ( action ) => {\n\tconst resolvers = registry\n\t\t.select( STORE_NAME )\n\t\t.getCachedResolvers( reducerKey );\n\tObject.entries( resolvers ).forEach(\n\t\t( [ selectorName, resolversByArgs ] ) => {\n\t\t\tconst resolver = get( registry.stores, [\n\t\t\t\treducerKey,\n\t\t\t\t'resolvers',\n\t\t\t\tselectorName,\n\t\t\t] );\n\t\t\tif ( ! resolver || ! resolver.shouldInvalidate ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tresolversByArgs.forEach( ( value, args ) => {\n\t\t\t\t// resolversByArgs is the map Map([ args ] => boolean) storing the cache resolution status for a given selector.\n\t\t\t\t// If the value is false it means this resolver has finished its resolution which means we need to invalidate it,\n\t\t\t\t// if it's true it means it's inflight and the invalidation is not necessary.\n\t\t\t\tif (\n\t\t\t\t\tvalue !== false ||\n\t\t\t\t\t! resolver.shouldInvalidate( action, ...args )\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Trigger cache invalidation\n\t\t\t\tregistry\n\t\t\t\t\t.dispatch( STORE_NAME )\n\t\t\t\t\t.invalidateResolution( reducerKey, selectorName, args );\n\t\t\t} );\n\t\t}\n\t);\n\treturn next( action );\n};\n\nexport default createResolversCacheMiddleware;\n"]}
|
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
function createCoreDataStore(registry) {
|
|
2
|
-
const getCoreDataSelector = selectorName => (key
|
|
2
|
+
const getCoreDataSelector = selectorName => function (key) {
|
|
3
|
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
4
|
+
args[_key - 1] = arguments[_key];
|
|
5
|
+
}
|
|
6
|
+
|
|
3
7
|
return registry.select(key)[selectorName](...args);
|
|
4
8
|
};
|
|
5
9
|
|
|
6
|
-
const getCoreDataAction = actionName => (key
|
|
10
|
+
const getCoreDataAction = actionName => function (key) {
|
|
11
|
+
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
12
|
+
args[_key2 - 1] = arguments[_key2];
|
|
13
|
+
}
|
|
14
|
+
|
|
7
15
|
return registry.dispatch(key)[actionName](...args);
|
|
8
16
|
};
|
|
9
17
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/data/src/store/index.js"],"names":["createCoreDataStore","registry","getCoreDataSelector","selectorName","key","args","select","getCoreDataAction","actionName","dispatch","getSelectors","reduce","memo","getActions","subscribe"],"mappings":"AAAA,SAASA,mBAAT,CAA8BC,QAA9B,EAAyC;AACxC,QAAMC,mBAAmB,GAAKC,YAAF,IAAoB,
|
|
1
|
+
{"version":3,"sources":["@wordpress/data/src/store/index.js"],"names":["createCoreDataStore","registry","getCoreDataSelector","selectorName","key","args","select","getCoreDataAction","actionName","dispatch","getSelectors","reduce","memo","getActions","subscribe"],"mappings":"AAAA,SAASA,mBAAT,CAA8BC,QAA9B,EAAyC;AACxC,QAAMC,mBAAmB,GAAKC,YAAF,IAAoB,UAAEC,GAAF,EAAoB;AAAA,sCAAVC,IAAU;AAAVA,MAAAA,IAAU;AAAA;;AACnE,WAAOJ,QAAQ,CAACK,MAAT,CAAiBF,GAAjB,EAAwBD,YAAxB,EAAwC,GAAGE,IAA3C,CAAP;AACA,GAFD;;AAIA,QAAME,iBAAiB,GAAKC,UAAF,IAAkB,UAAEJ,GAAF,EAAoB;AAAA,uCAAVC,IAAU;AAAVA,MAAAA,IAAU;AAAA;;AAC/D,WAAOJ,QAAQ,CAACQ,QAAT,CAAmBL,GAAnB,EAA0BI,UAA1B,EAAwC,GAAGH,IAA3C,CAAP;AACA,GAFD;;AAIA,SAAO;AACNK,IAAAA,YAAY,GAAG;AACd,aAAO,CACN,gBADM,EAEN,sBAFM,EAGN,uBAHM,EAIN,aAJM,EAKN,oBALM,EAMLC,MANK,CAON,CAAEC,IAAF,EAAQT,YAAR,MAA4B,EAC3B,GAAGS,IADwB;AAE3B,SAAET,YAAF,GAAkBD,mBAAmB,CAAEC,YAAF;AAFV,OAA5B,CAPM,EAWN,EAXM,CAAP;AAaA,KAfK;;AAiBNU,IAAAA,UAAU,GAAG;AACZ,aAAO,CACN,iBADM,EAEN,kBAFM,EAGN,sBAHM,EAIN,8BAJM,EAKN,sCALM,EAMLF,MANK,CAON,CAAEC,IAAF,EAAQJ,UAAR,MAA0B,EACzB,GAAGI,IADsB;AAEzB,SAAEJ,UAAF,GAAgBD,iBAAiB,CAAEC,UAAF;AAFR,OAA1B,CAPM,EAWN,EAXM,CAAP;AAaA,KA/BK;;AAiCNM,IAAAA,SAAS,GAAG;AACX;AACA;AACA;AACA;AACA,aAAO,MAAM,CAAE,CAAf;AACA;;AAvCK,GAAP;AAyCA;;AAED,eAAed,mBAAf","sourcesContent":["function createCoreDataStore( registry ) {\n\tconst getCoreDataSelector = ( selectorName ) => ( key, ...args ) => {\n\t\treturn registry.select( key )[ selectorName ]( ...args );\n\t};\n\n\tconst getCoreDataAction = ( actionName ) => ( key, ...args ) => {\n\t\treturn registry.dispatch( key )[ actionName ]( ...args );\n\t};\n\n\treturn {\n\t\tgetSelectors() {\n\t\t\treturn [\n\t\t\t\t'getIsResolving',\n\t\t\t\t'hasStartedResolution',\n\t\t\t\t'hasFinishedResolution',\n\t\t\t\t'isResolving',\n\t\t\t\t'getCachedResolvers',\n\t\t\t].reduce(\n\t\t\t\t( memo, selectorName ) => ( {\n\t\t\t\t\t...memo,\n\t\t\t\t\t[ selectorName ]: getCoreDataSelector( selectorName ),\n\t\t\t\t} ),\n\t\t\t\t{}\n\t\t\t);\n\t\t},\n\n\t\tgetActions() {\n\t\t\treturn [\n\t\t\t\t'startResolution',\n\t\t\t\t'finishResolution',\n\t\t\t\t'invalidateResolution',\n\t\t\t\t'invalidateResolutionForStore',\n\t\t\t\t'invalidateResolutionForStoreSelector',\n\t\t\t].reduce(\n\t\t\t\t( memo, actionName ) => ( {\n\t\t\t\t\t...memo,\n\t\t\t\t\t[ actionName ]: getCoreDataAction( actionName ),\n\t\t\t\t} ),\n\t\t\t\t{}\n\t\t\t);\n\t\t},\n\n\t\tsubscribe() {\n\t\t\t// There's no reasons to trigger any listener when we subscribe to this store\n\t\t\t// because there's no state stored in this store that need to retrigger selectors\n\t\t\t// if a change happens, the corresponding store where the tracking stated live\n\t\t\t// would have already triggered a \"subscribe\" call.\n\t\t\treturn () => {};\n\t\t},\n\t};\n}\n\nexport default createCoreDataStore;\n"]}
|
package/build-module/types.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
export {};
|
|
2
2
|
//# sourceMappingURL=types.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/data",
|
|
3
|
-
"version": "6.1.
|
|
3
|
+
"version": "6.1.4",
|
|
4
4
|
"description": "Data module for WordPress.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -27,13 +27,13 @@
|
|
|
27
27
|
"react-native": "src/index",
|
|
28
28
|
"sideEffects": false,
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@babel/runtime": "^7.
|
|
31
|
-
"@wordpress/compose": "^5.0.
|
|
32
|
-
"@wordpress/deprecated": "^3.2.
|
|
33
|
-
"@wordpress/element": "^4.0.
|
|
34
|
-
"@wordpress/is-shallow-equal": "^4.2.
|
|
35
|
-
"@wordpress/priority-queue": "^2.2.
|
|
36
|
-
"@wordpress/redux-routine": "^4.2.
|
|
30
|
+
"@babel/runtime": "^7.16.0",
|
|
31
|
+
"@wordpress/compose": "^5.0.6",
|
|
32
|
+
"@wordpress/deprecated": "^3.2.3",
|
|
33
|
+
"@wordpress/element": "^4.0.4",
|
|
34
|
+
"@wordpress/is-shallow-equal": "^4.2.1",
|
|
35
|
+
"@wordpress/priority-queue": "^2.2.3",
|
|
36
|
+
"@wordpress/redux-routine": "^4.2.2",
|
|
37
37
|
"equivalent-key-map": "^0.2.2",
|
|
38
38
|
"is-promise": "^4.0.0",
|
|
39
39
|
"lodash": "^4.17.21",
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"publishConfig": {
|
|
48
48
|
"access": "public"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "9a1dd3474d937468e4cf9caf9886ad61ef0a8f50"
|
|
51
51
|
}
|