@wordpress/data 6.10.0 → 6.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/README.md +55 -36
- package/build/components/async-mode-provider/context.js +2 -1
- package/build/components/async-mode-provider/context.js.map +1 -1
- package/build/components/use-dispatch/use-dispatch.js +3 -2
- package/build/components/use-dispatch/use-dispatch.js.map +1 -1
- package/build/components/use-select/index.js +32 -19
- package/build/components/use-select/index.js.map +1 -1
- package/build/components/with-dispatch/index.js +5 -3
- package/build/components/with-dispatch/index.js.map +1 -1
- package/build/components/with-registry/index.js.map +1 -1
- package/build/components/with-select/index.js +2 -1
- package/build/components/with-select/index.js.map +1 -1
- package/build/controls.js +8 -9
- package/build/controls.js.map +1 -1
- package/build/factory.js +5 -2
- package/build/factory.js.map +1 -1
- package/build/index.js +26 -20
- package/build/index.js.map +1 -1
- package/build/plugins/persistence/index.js.map +1 -1
- package/build/redux-store/index.js +14 -7
- package/build/redux-store/index.js.map +1 -1
- package/build/redux-store/metadata/utils.js.map +1 -1
- package/build/registry.js +21 -16
- package/build/registry.js.map +1 -1
- package/build/resolvers-cache-middleware.js.map +1 -1
- package/build/store/index.js.map +1 -1
- package/build-module/components/async-mode-provider/context.js +2 -1
- package/build-module/components/async-mode-provider/context.js.map +1 -1
- package/build-module/components/use-dispatch/use-dispatch.js +3 -2
- package/build-module/components/use-dispatch/use-dispatch.js.map +1 -1
- package/build-module/components/use-select/index.js +33 -20
- package/build-module/components/use-select/index.js.map +1 -1
- package/build-module/components/with-dispatch/index.js +5 -3
- package/build-module/components/with-dispatch/index.js.map +1 -1
- package/build-module/components/with-registry/index.js.map +1 -1
- package/build-module/components/with-select/index.js +2 -1
- package/build-module/components/with-select/index.js.map +1 -1
- package/build-module/controls.js +5 -5
- package/build-module/controls.js.map +1 -1
- package/build-module/factory.js +5 -2
- package/build-module/factory.js.map +1 -1
- package/build-module/index.js +26 -20
- package/build-module/index.js.map +1 -1
- package/build-module/plugins/persistence/index.js.map +1 -1
- package/build-module/redux-store/index.js +14 -7
- package/build-module/redux-store/index.js.map +1 -1
- package/build-module/redux-store/metadata/utils.js.map +1 -1
- package/build-module/registry.js +17 -12
- package/build-module/registry.js.map +1 -1
- package/build-module/resolvers-cache-middleware.js.map +1 -1
- package/build-module/store/index.js.map +1 -1
- package/build-types/components/async-mode-provider/context.d.ts +5 -0
- package/build-types/components/async-mode-provider/context.d.ts.map +1 -0
- package/build-types/components/async-mode-provider/index.d.ts +3 -0
- package/build-types/components/async-mode-provider/index.d.ts.map +1 -0
- package/build-types/components/async-mode-provider/use-async-mode.d.ts +2 -0
- package/build-types/components/async-mode-provider/use-async-mode.d.ts.map +1 -0
- package/build-types/components/registry-provider/context.d.ts +36 -0
- package/build-types/components/registry-provider/context.d.ts.map +1 -0
- package/build-types/components/registry-provider/index.d.ts +3 -0
- package/build-types/components/registry-provider/index.d.ts.map +1 -0
- package/build-types/components/registry-provider/use-registry.d.ts +41 -0
- package/build-types/components/registry-provider/use-registry.d.ts.map +1 -0
- package/build-types/components/use-dispatch/index.d.ts +3 -0
- package/build-types/components/use-dispatch/index.d.ts.map +1 -0
- package/build-types/components/use-dispatch/use-dispatch-with-map.d.ts +17 -0
- package/build-types/components/use-dispatch/use-dispatch-with-map.d.ts.map +1 -0
- package/build-types/components/use-dispatch/use-dispatch.d.ts +50 -0
- package/build-types/components/use-dispatch/use-dispatch.d.ts.map +1 -0
- package/build-types/components/use-select/index.d.ts +99 -0
- package/build-types/components/use-select/index.d.ts.map +1 -0
- package/build-types/components/with-dispatch/index.d.ts +84 -0
- package/build-types/components/with-dispatch/index.d.ts.map +1 -0
- package/build-types/components/with-registry/index.d.ts +11 -0
- package/build-types/components/with-registry/index.d.ts.map +1 -0
- package/build-types/components/with-select/index.d.ts +43 -0
- package/build-types/components/with-select/index.d.ts.map +1 -0
- package/build-types/controls.d.ts +83 -0
- package/build-types/controls.d.ts.map +1 -0
- package/build-types/default-registry.d.ts +3 -0
- package/build-types/default-registry.d.ts.map +1 -0
- package/build-types/factory.d.ts +63 -0
- package/build-types/factory.d.ts.map +1 -0
- package/build-types/index.d.ts +156 -0
- package/build-types/index.d.ts.map +1 -0
- package/build-types/plugins/index.d.ts +2 -0
- package/build-types/plugins/index.d.ts.map +1 -0
- package/build-types/plugins/persistence/index.d.ts +41 -0
- package/build-types/plugins/persistence/index.d.ts.map +1 -0
- package/build-types/plugins/persistence/storage/default.d.ts +3 -0
- package/build-types/plugins/persistence/storage/default.d.ts.map +1 -0
- package/build-types/plugins/persistence/storage/object.d.ts +10 -0
- package/build-types/plugins/persistence/storage/object.d.ts.map +1 -0
- package/build-types/redux-store/index.d.ts +29 -0
- package/build-types/redux-store/index.d.ts.map +1 -0
- package/build-types/redux-store/metadata/utils.d.ts.map +1 -1
- package/build-types/redux-store/thunk-middleware.d.ts +2 -0
- package/build-types/redux-store/thunk-middleware.d.ts.map +1 -0
- package/build-types/registry.d.ts +56 -0
- package/build-types/registry.d.ts.map +1 -0
- package/build-types/resolvers-cache-middleware.d.ts +15 -0
- package/build-types/resolvers-cache-middleware.d.ts.map +1 -0
- package/build-types/store/index.d.ts +23 -0
- package/build-types/store/index.d.ts.map +1 -0
- package/build-types/types.d.ts +18 -1
- package/build-types/types.d.ts.map +1 -1
- package/package.json +8 -8
- package/src/components/async-mode-provider/context.js +2 -1
- package/src/components/use-dispatch/use-dispatch.js +3 -2
- package/src/components/use-select/index.js +37 -20
- package/src/components/use-select/test/suspense.js +15 -11
- package/src/components/with-dispatch/index.js +5 -3
- package/src/components/with-dispatch/test/index.js +4 -5
- package/src/components/with-registry/index.js +8 -7
- package/src/components/with-select/index.js +2 -1
- package/src/components/with-select/test/index.js +12 -18
- package/src/controls.js +20 -16
- package/src/factory.js +5 -2
- package/src/index.js +26 -20
- package/src/plugins/persistence/index.js +2 -4
- package/src/redux-store/index.js +22 -12
- package/src/redux-store/metadata/test/utils.js +1 -2
- package/src/redux-store/metadata/utils.ts +24 -24
- package/src/redux-store/test/index.js +4 -3
- package/src/registry.js +17 -12
- package/src/resolvers-cache-middleware.js +33 -34
- package/src/store/index.js +10 -6
- package/src/test/registry.js +19 -23
- package/src/types.ts +39 -6
- package/tsconfig.json +4 -2
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/data/src/registry.js"],"names":["mapValues","isObject","forEach","deprecated","createReduxStore","coreDataStore","createEmitter","createRegistry","storeConfigs","parent","stores","emitter","listeningStores","Set","globalListener","emit","subscribe","listener","select","storeNameOrDescriptor","storeName","name","add","store","getSelectors","__unstableMarkListeningStores","callback","ref","clear","call","current","Array","from","resolveSelect","getResolveSelectors","suspendSelect","getSuspendSelectors","dispatch","getActions","withPlugins","attributes","attribute","key","registry","apply","arguments","registerStoreInstance","TypeError","currentSubscribe","unsubscribeFromEmitter","unsubscribeFromStore","isPaused","register","instantiate","registerGenericStore","since","alternative","registerStore","options","reducer","__unstableSubscribeStore","handler","batch","pause","resume","namespaces","use","plugin","config","Object","entries"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAT,EAAoBC,QAApB,EAA8BC,OAA9B,QAA6C,QAA7C;AAEA;AACA;AACA;;AACA,OAAOC,UAAP,MAAuB,uBAAvB;AAEA;AACA;AACA;;AACA,OAAOC,gBAAP,MAA6B,eAA7B;AACA,OAAOC,aAAP,MAA0B,SAA1B;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,QAA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CAAEiB,IAAF,EAAQ+C,MAAR,CAAnC;AACA;;AAED,MAAK3D,MAAL,EAAc;AACbA,IAAAA,MAAM,CAACO,SAAP,CAAkBF,cAAlB;AACA;;AAED,SAAOyB,WAAW,CAAEI,QAAF,CAAlB;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { mapValues, isObject, forEach } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport createReduxStore from './redux-store';\nimport coreDataStore from './store';\nimport { createEmitter } from './utils/emitter';\n\n/** @typedef {import('./types').StoreDescriptor} StoreDescriptor */\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 listeningStores = 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|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store\n\t * or the store descriptor.\n\t *\n\t * @return {*} The selector's returned value.\n\t */\n\tfunction select( storeNameOrDescriptor ) {\n\t\tconst storeName = isObject( storeNameOrDescriptor )\n\t\t\t? storeNameOrDescriptor.name\n\t\t\t: storeNameOrDescriptor;\n\t\tlisteningStores.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?.select( storeName );\n\t}\n\n\tfunction __unstableMarkListeningStores( callback, ref ) {\n\t\tlisteningStores.clear();\n\t\ttry {\n\t\t\treturn callback.call( this );\n\t\t} finally {\n\t\t\tref.current = Array.from( listeningStores );\n\t\t}\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|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store\n\t * or the store descriptor.\n\t *\n\t * @return {Object} Each key of the object matches the name of a selector.\n\t */\n\tfunction resolveSelect( storeNameOrDescriptor ) {\n\t\tconst storeName = isObject( storeNameOrDescriptor )\n\t\t\t? storeNameOrDescriptor.name\n\t\t\t: storeNameOrDescriptor;\n\t\tlisteningStores.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 * 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 throw promises in case the selector is not resolved yet.\n\t *\n\t * @param {string|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store\n\t * or the store descriptor.\n\t *\n\t * @return {Object} Object containing the store's suspense-wrapped selectors.\n\t */\n\tfunction suspendSelect( storeNameOrDescriptor ) {\n\t\tconst storeName = isObject( storeNameOrDescriptor )\n\t\t\t? storeNameOrDescriptor.name\n\t\t\t: storeNameOrDescriptor;\n\t\tlisteningStores.add( storeName );\n\t\tconst store = stores[ storeName ];\n\t\tif ( store ) {\n\t\t\treturn store.getSuspendSelectors();\n\t\t}\n\n\t\treturn parent && parent.suspendSelect( storeName );\n\t}\n\n\t/**\n\t * Returns the available actions for a part of the state.\n\t *\n\t * @param {string|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store\n\t * or the store descriptor.\n\t *\n\t * @return {*} The action's returned value.\n\t */\n\tfunction dispatch( storeNameOrDescriptor ) {\n\t\tconst storeName = isObject( storeNameOrDescriptor )\n\t\t\t? storeNameOrDescriptor.name\n\t\t\t: storeNameOrDescriptor;\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\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 store instance.\n\t *\n\t * @param {string} name Store registry name.\n\t * @param {Object} store Store instance object (getSelectors, getActions, subscribe).\n\t */\n\tfunction registerStoreInstance( name, store ) {\n\t\tif ( typeof store.getSelectors !== 'function' ) {\n\t\t\tthrow new TypeError( 'store.getSelectors must be a function' );\n\t\t}\n\t\tif ( typeof store.getActions !== 'function' ) {\n\t\t\tthrow new TypeError( 'store.getActions must be a function' );\n\t\t}\n\t\tif ( typeof store.subscribe !== 'function' ) {\n\t\t\tthrow new TypeError( 'store.subscribe must be a function' );\n\t\t}\n\t\t// The 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\tstore.emitter = createEmitter();\n\t\tconst currentSubscribe = store.subscribe;\n\t\tstore.subscribe = ( listener ) => {\n\t\t\tconst unsubscribeFromEmitter = store.emitter.subscribe( listener );\n\t\t\tconst unsubscribeFromStore = currentSubscribe( () => {\n\t\t\t\tif ( store.emitter.isPaused ) {\n\t\t\t\t\tstore.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\tunsubscribeFromStore?.();\n\t\t\t\tunsubscribeFromEmitter?.();\n\t\t\t};\n\t\t};\n\t\tstores[ name ] = store;\n\t\tstore.subscribe( globalListener );\n\t}\n\n\t/**\n\t * Registers a new store given a store descriptor.\n\t *\n\t * @param {StoreDescriptor} store Store descriptor.\n\t */\n\tfunction register( store ) {\n\t\tregisterStoreInstance( store.name, store.instantiate( registry ) );\n\t}\n\n\tfunction registerGenericStore( name, store ) {\n\t\tdeprecated( 'wp.data.registerGenericStore', {\n\t\t\tsince: '5.9',\n\t\t\talternative: 'wp.data.register( storeDescriptor )',\n\t\t} );\n\t\tregisterStoreInstance( name, store );\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\tfunction 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\tregisterStoreInstance( storeName, store );\n\t\treturn store.store;\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 __unstableSubscribeStore( 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.__unstableSubscribeStore( 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\tstores,\n\t\tnamespaces: stores, // TODO: Deprecate/remove this.\n\t\tsubscribe,\n\t\tselect,\n\t\tresolveSelect,\n\t\tsuspendSelect,\n\t\tdispatch,\n\t\tuse,\n\t\tregister,\n\t\tregisterGenericStore,\n\t\tregisterStore,\n\t\t__unstableMarkListeningStores,\n\t\t__unstableSubscribeStore,\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\tfunction use( plugin, options ) {\n\t\tif ( ! plugin ) {\n\t\t\treturn;\n\t\t}\n\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\tregistry.register( coreDataStore );\n\n\tfor ( const [ name, config ] of Object.entries( storeConfigs ) ) {\n\t\tregistry.register( createReduxStore( 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","forEach","deprecated","createReduxStore","coreDataStore","createEmitter","isObject","object","createRegistry","storeConfigs","parent","stores","emitter","listeningStores","Set","globalListener","emit","subscribe","listener","select","storeNameOrDescriptor","storeName","name","add","store","getSelectors","__unstableMarkListeningStores","callback","ref","clear","call","current","Array","from","resolveSelect","getResolveSelectors","suspendSelect","getSuspendSelectors","dispatch","getActions","withPlugins","attributes","attribute","key","registry","apply","arguments","registerStoreInstance","TypeError","currentSubscribe","unsubscribeFromEmitter","unsubscribeFromStore","isPaused","register","instantiate","registerGenericStore","since","alternative","registerStore","options","reducer","__unstableSubscribeStore","handler","batch","pause","resume","namespaces","use","plugin","config","Object","entries"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAT,EAAoBC,OAApB,QAAmC,QAAnC;AAEA;AACA;AACA;;AACA,OAAOC,UAAP,MAAuB,uBAAvB;AAEA;AACA;AACA;;AACA,OAAOC,gBAAP,MAA6B,eAA7B;AACA,OAAOC,aAAP,MAA0B,SAA1B;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,SAASC,QAAT,CAAmBC,MAAnB,EAA4B;AAC3B,SAAOA,MAAM,KAAK,IAAX,IAAmB,OAAOA,MAAP,KAAkB,QAA5C;AACA;AAED;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,GAAGP,aAAa,EAA7B;AACA,QAAMQ,eAAe,GAAG,IAAIC,GAAJ,EAAxB;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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AAA,OAAO,CAACqD,MAAR;AACAhE,IAAAA,OAAO,CAAEU,MAAF,EAAYa,KAAF,IAAaA,KAAK,CAACZ,OAAN,CAAcqD,MAAd,EAAvB,CAAP;AACA;;AAED,MAAIrB,QAAQ,GAAG;AACdmB,IAAAA,KADc;AAEdpD,IAAAA,MAFc;AAGduD,IAAAA,UAAU,EAAEvD,MAHE;AAGM;AACpBM,IAAAA,SAJc;AAKdE,IAAAA,MALc;AAMde,IAAAA,aANc;AAOdE,IAAAA,aAPc;AAQdE,IAAAA,QARc;AASd6B,IAAAA,GATc;AAUdd,IAAAA,QAVc;AAWdE,IAAAA,oBAXc;AAYdG,IAAAA,aAZc;AAadhC,IAAAA,6BAbc;AAcdmC,IAAAA;AAdc,GAAf,CAnPkE,CAoQlE;AACA;AACA;;AACA,WAASM,GAAT,CAAcC,MAAd,EAAsBT,OAAtB,EAAgC;AAC/B,QAAK,CAAES,MAAP,EAAgB;AACf;AACA;;AAEDxB,IAAAA,QAAQ,GAAG,EACV,GAAGA,QADO;AAEV,SAAGwB,MAAM,CAAExB,QAAF,EAAYe,OAAZ;AAFC,KAAX;AAKA,WAAOf,QAAP;AACA;;AAEDA,EAAAA,QAAQ,CAACS,QAAT,CAAmBjD,aAAnB;;AAEA,OAAM,MAAM,CAAEkB,IAAF,EAAQ+C,MAAR,CAAZ,IAAgCC,MAAM,CAACC,OAAP,CAAgB9D,YAAhB,CAAhC,EAAiE;AAChEmC,IAAAA,QAAQ,CAACS,QAAT,CAAmBlD,gBAAgB,CAAEmB,IAAF,EAAQ+C,MAAR,CAAnC;AACA;;AAED,MAAK3D,MAAL,EAAc;AACbA,IAAAA,MAAM,CAACO,SAAP,CAAkBF,cAAlB;AACA;;AAED,SAAOyB,WAAW,CAAEI,QAAF,CAAlB;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { mapValues, forEach } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport createReduxStore from './redux-store';\nimport coreDataStore from './store';\nimport { createEmitter } from './utils/emitter';\n\n/** @typedef {import('./types').StoreDescriptor} StoreDescriptor */\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\nfunction isObject( object ) {\n\treturn object !== null && typeof object === 'object';\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 listeningStores = 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|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store\n\t * or the store descriptor.\n\t *\n\t * @return {*} The selector's returned value.\n\t */\n\tfunction select( storeNameOrDescriptor ) {\n\t\tconst storeName = isObject( storeNameOrDescriptor )\n\t\t\t? storeNameOrDescriptor.name\n\t\t\t: storeNameOrDescriptor;\n\t\tlisteningStores.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?.select( storeName );\n\t}\n\n\tfunction __unstableMarkListeningStores( callback, ref ) {\n\t\tlisteningStores.clear();\n\t\ttry {\n\t\t\treturn callback.call( this );\n\t\t} finally {\n\t\t\tref.current = Array.from( listeningStores );\n\t\t}\n\t}\n\n\t/**\n\t * Given a store descriptor, returns an object containing the store's selectors pre-bound to\n\t * state so that you only need to supply additional arguments, and modified so that they return\n\t * promises that resolve to their eventual values, after any resolvers have ran.\n\t *\n\t * @param {StoreDescriptor|string} storeNameOrDescriptor The store descriptor. The legacy calling\n\t * convention of passing the store name is\n\t * also supported.\n\t *\n\t * @return {Object} Each key of the object matches the name of a selector.\n\t */\n\tfunction resolveSelect( storeNameOrDescriptor ) {\n\t\tconst storeName = isObject( storeNameOrDescriptor )\n\t\t\t? storeNameOrDescriptor.name\n\t\t\t: storeNameOrDescriptor;\n\t\tlisteningStores.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 * Given a store descriptor, returns an object containing the store's selectors pre-bound to\n\t * state so that you only need to supply additional arguments, and modified so that they throw\n\t * promises in case the selector is not resolved yet.\n\t *\n\t * @param {StoreDescriptor|string} storeNameOrDescriptor The store descriptor. The legacy calling\n\t * convention of passing the store name is\n\t * also supported.\n\t *\n\t * @return {Object} Object containing the store's suspense-wrapped selectors.\n\t */\n\tfunction suspendSelect( storeNameOrDescriptor ) {\n\t\tconst storeName = isObject( storeNameOrDescriptor )\n\t\t\t? storeNameOrDescriptor.name\n\t\t\t: storeNameOrDescriptor;\n\t\tlisteningStores.add( storeName );\n\t\tconst store = stores[ storeName ];\n\t\tif ( store ) {\n\t\t\treturn store.getSuspendSelectors();\n\t\t}\n\n\t\treturn parent && parent.suspendSelect( storeName );\n\t}\n\n\t/**\n\t * Returns the available actions for a part of the state.\n\t *\n\t * @param {string|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store\n\t * or the store descriptor.\n\t *\n\t * @return {*} The action's returned value.\n\t */\n\tfunction dispatch( storeNameOrDescriptor ) {\n\t\tconst storeName = isObject( storeNameOrDescriptor )\n\t\t\t? storeNameOrDescriptor.name\n\t\t\t: storeNameOrDescriptor;\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\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 store instance.\n\t *\n\t * @param {string} name Store registry name.\n\t * @param {Object} store Store instance object (getSelectors, getActions, subscribe).\n\t */\n\tfunction registerStoreInstance( name, store ) {\n\t\tif ( typeof store.getSelectors !== 'function' ) {\n\t\t\tthrow new TypeError( 'store.getSelectors must be a function' );\n\t\t}\n\t\tif ( typeof store.getActions !== 'function' ) {\n\t\t\tthrow new TypeError( 'store.getActions must be a function' );\n\t\t}\n\t\tif ( typeof store.subscribe !== 'function' ) {\n\t\t\tthrow new TypeError( 'store.subscribe must be a function' );\n\t\t}\n\t\t// The 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\tstore.emitter = createEmitter();\n\t\tconst currentSubscribe = store.subscribe;\n\t\tstore.subscribe = ( listener ) => {\n\t\t\tconst unsubscribeFromEmitter = store.emitter.subscribe( listener );\n\t\t\tconst unsubscribeFromStore = currentSubscribe( () => {\n\t\t\t\tif ( store.emitter.isPaused ) {\n\t\t\t\t\tstore.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\tunsubscribeFromStore?.();\n\t\t\t\tunsubscribeFromEmitter?.();\n\t\t\t};\n\t\t};\n\t\tstores[ name ] = store;\n\t\tstore.subscribe( globalListener );\n\t}\n\n\t/**\n\t * Registers a new store given a store descriptor.\n\t *\n\t * @param {StoreDescriptor} store Store descriptor.\n\t */\n\tfunction register( store ) {\n\t\tregisterStoreInstance( store.name, store.instantiate( registry ) );\n\t}\n\n\tfunction registerGenericStore( name, store ) {\n\t\tdeprecated( 'wp.data.registerGenericStore', {\n\t\t\tsince: '5.9',\n\t\t\talternative: 'wp.data.register( storeDescriptor )',\n\t\t} );\n\t\tregisterStoreInstance( name, store );\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\tfunction 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\tregisterStoreInstance( storeName, store );\n\t\treturn store.store;\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 __unstableSubscribeStore( 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.__unstableSubscribeStore( 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\tstores,\n\t\tnamespaces: stores, // TODO: Deprecate/remove this.\n\t\tsubscribe,\n\t\tselect,\n\t\tresolveSelect,\n\t\tsuspendSelect,\n\t\tdispatch,\n\t\tuse,\n\t\tregister,\n\t\tregisterGenericStore,\n\t\tregisterStore,\n\t\t__unstableMarkListeningStores,\n\t\t__unstableSubscribeStore,\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\tfunction use( plugin, options ) {\n\t\tif ( ! plugin ) {\n\t\t\treturn;\n\t\t}\n\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\tregistry.register( coreDataStore );\n\n\tfor ( const [ name, config ] of Object.entries( storeConfigs ) ) {\n\t\tregistry.register( createReduxStore( name, config ) );\n\t}\n\n\tif ( parent ) {\n\t\tparent.subscribe( globalListener );\n\t}\n\n\treturn withPlugins( registry );\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/data/src/resolvers-cache-middleware.js"],"names":["get","coreDataStore","createResolversCacheMiddleware","registry","reducerKey","next","action","resolvers","select","getCachedResolvers","Object","entries","forEach","selectorName","resolversByArgs","resolver","stores","shouldInvalidate","value","args","status","dispatch","invalidateResolution"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,GAAT,QAAoB,QAApB;AAEA;AACA;AACA;;AACA,OAAOC,aAAP,MAA0B,SAA1B;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMC,8BAA8B,
|
|
1
|
+
{"version":3,"sources":["@wordpress/data/src/resolvers-cache-middleware.js"],"names":["get","coreDataStore","createResolversCacheMiddleware","registry","reducerKey","next","action","resolvers","select","getCachedResolvers","Object","entries","forEach","selectorName","resolversByArgs","resolver","stores","shouldInvalidate","value","args","status","dispatch","invalidateResolution"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,GAAT,QAAoB,QAApB;AAEA;AACA;AACA;;AACA,OAAOC,aAAP,MAA0B,SAA1B;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMC,8BAA8B,GACnC,CAAEC,QAAF,EAAYC,UAAZ,KAA4B,MAAQC,IAAF,IAAcC,MAAF,IAAc;AAC3D,QAAMC,SAAS,GAAGJ,QAAQ,CACxBK,MADgB,CACRP,aADQ,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,UACG,CAAAD,KAAK,SAAL,IAAAA,KAAK,WAAL,YAAAA,KAAK,CAAEE,MAAP,MAAkB,UAAlB,IACD,CAAAF,KAAK,SAAL,IAAAA,KAAK,WAAL,YAAAA,KAAK,CAAEE,MAAP,MAAkB,OADnB,IAEA,CAAEL,QAAQ,CAACE,gBAAT,CAA2BX,MAA3B,EAAmC,GAAGa,IAAtC,CAHH,EAIE;AACD;AACA,OAV0C,CAY3C;;;AACAhB,MAAAA,QAAQ,CACNkB,QADF,CACYpB,aADZ,EAEEqB,oBAFF,CAEwBlB,UAFxB,EAEoCS,YAFpC,EAEkDM,IAFlD;AAGA,KAhBD;AAiBA,GA3BF;AA6BA,SAAOd,IAAI,CAAEC,MAAF,CAAX;AACA,CAnCF;;AAqCA,eAAeJ,8BAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { get } from 'lodash';\n\n/**\n * Internal dependencies\n */\nimport coreDataStore from './store';\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 =\n\t( registry, reducerKey ) => () => ( next ) => ( action ) => {\n\t\tconst resolvers = registry\n\t\t\t.select( coreDataStore )\n\t\t\t.getCachedResolvers( reducerKey );\n\t\tObject.entries( resolvers ).forEach(\n\t\t\t( [ selectorName, resolversByArgs ] ) => {\n\t\t\t\tconst resolver = get( registry.stores, [\n\t\t\t\t\treducerKey,\n\t\t\t\t\t'resolvers',\n\t\t\t\t\tselectorName,\n\t\t\t\t] );\n\t\t\t\tif ( ! resolver || ! resolver.shouldInvalidate ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tresolversByArgs.forEach( ( value, args ) => {\n\t\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\t// If the value is \"finished\" or \"error\" it means this resolver has finished its resolution which means we need\n\t\t\t\t\t// to invalidate it, if it's true it means it's inflight and the invalidation is not necessary.\n\t\t\t\t\tif (\n\t\t\t\t\t\t( value?.status !== 'finished' &&\n\t\t\t\t\t\t\tvalue?.status !== 'error' ) ||\n\t\t\t\t\t\t! resolver.shouldInvalidate( action, ...args )\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Trigger cache invalidation\n\t\t\t\t\tregistry\n\t\t\t\t\t\t.dispatch( coreDataStore )\n\t\t\t\t\t\t.invalidateResolution( reducerKey, selectorName, args );\n\t\t\t\t} );\n\t\t\t}\n\t\t);\n\t\treturn next( action );\n\t};\n\nexport default createResolversCacheMiddleware;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/data/src/store/index.js"],"names":["coreDataStore","name","instantiate","registry","getCoreDataSelector","selectorName","key","args","select","getCoreDataAction","actionName","dispatch","getSelectors","Object","fromEntries","map","getActions","subscribe"],"mappings":"AAAA,MAAMA,aAAa,GAAG;AACrBC,EAAAA,IAAI,EAAE,WADe;;AAErBC,EAAAA,WAAW,CAAEC,QAAF,EAAa;AACvB,UAAMC,mBAAmB,
|
|
1
|
+
{"version":3,"sources":["@wordpress/data/src/store/index.js"],"names":["coreDataStore","name","instantiate","registry","getCoreDataSelector","selectorName","key","args","select","getCoreDataAction","actionName","dispatch","getSelectors","Object","fromEntries","map","getActions","subscribe"],"mappings":"AAAA,MAAMA,aAAa,GAAG;AACrBC,EAAAA,IAAI,EAAE,WADe;;AAErBC,EAAAA,WAAW,CAAEC,QAAF,EAAa;AACvB,UAAMC,mBAAmB,GACtBC,YAAF,IACA,UAAEC,GAAF,EAAoB;AAAA,wCAAVC,IAAU;AAAVA,QAAAA,IAAU;AAAA;;AACnB,aAAOJ,QAAQ,CAACK,MAAT,CAAiBF,GAAjB,EAAwBD,YAAxB,EAAwC,GAAGE,IAA3C,CAAP;AACA,KAJF;;AAMA,UAAME,iBAAiB,GACpBC,UAAF,IACA,UAAEJ,GAAF,EAAoB;AAAA,yCAAVC,IAAU;AAAVA,QAAAA,IAAU;AAAA;;AACnB,aAAOJ,QAAQ,CAACQ,QAAT,CAAmBL,GAAnB,EAA0BI,UAA1B,EAAwC,GAAGH,IAA3C,CAAP;AACA,KAJF;;AAMA,WAAO;AACNK,MAAAA,YAAY,GAAG;AACd,eAAOC,MAAM,CAACC,WAAP,CACN,CACC,gBADD,EAEC,sBAFD,EAGC,uBAHD,EAIC,aAJD,EAKC,oBALD,EAMEC,GANF,CAMSV,YAAF,IAAoB,CAC1BA,YAD0B,EAE1BD,mBAAmB,CAAEC,YAAF,CAFO,CAN3B,CADM,CAAP;AAYA,OAdK;;AAgBNW,MAAAA,UAAU,GAAG;AACZ,eAAOH,MAAM,CAACC,WAAP,CACN,CACC,iBADD,EAEC,kBAFD,EAGC,sBAHD,EAIC,8BAJD,EAKC,sCALD,EAMEC,GANF,CAMSL,UAAF,IAAkB,CACxBA,UADwB,EAExBD,iBAAiB,CAAEC,UAAF,CAFO,CANzB,CADM,CAAP;AAYA,OA7BK;;AA+BNO,MAAAA,SAAS,GAAG;AACX;AACA;AACA;AACA;AACA,eAAO,MAAM,MAAM,CAAE,CAArB;AACA;;AArCK,KAAP;AAuCA;;AAtDoB,CAAtB;AAyDA,eAAejB,aAAf","sourcesContent":["const coreDataStore = {\n\tname: 'core/data',\n\tinstantiate( registry ) {\n\t\tconst getCoreDataSelector =\n\t\t\t( selectorName ) =>\n\t\t\t( key, ...args ) => {\n\t\t\t\treturn registry.select( key )[ selectorName ]( ...args );\n\t\t\t};\n\n\t\tconst getCoreDataAction =\n\t\t\t( actionName ) =>\n\t\t\t( key, ...args ) => {\n\t\t\t\treturn registry.dispatch( key )[ actionName ]( ...args );\n\t\t\t};\n\n\t\treturn {\n\t\t\tgetSelectors() {\n\t\t\t\treturn Object.fromEntries(\n\t\t\t\t\t[\n\t\t\t\t\t\t'getIsResolving',\n\t\t\t\t\t\t'hasStartedResolution',\n\t\t\t\t\t\t'hasFinishedResolution',\n\t\t\t\t\t\t'isResolving',\n\t\t\t\t\t\t'getCachedResolvers',\n\t\t\t\t\t].map( ( selectorName ) => [\n\t\t\t\t\t\tselectorName,\n\t\t\t\t\t\tgetCoreDataSelector( selectorName ),\n\t\t\t\t\t] )\n\t\t\t\t);\n\t\t\t},\n\n\t\t\tgetActions() {\n\t\t\t\treturn Object.fromEntries(\n\t\t\t\t\t[\n\t\t\t\t\t\t'startResolution',\n\t\t\t\t\t\t'finishResolution',\n\t\t\t\t\t\t'invalidateResolution',\n\t\t\t\t\t\t'invalidateResolutionForStore',\n\t\t\t\t\t\t'invalidateResolutionForStoreSelector',\n\t\t\t\t\t].map( ( actionName ) => [\n\t\t\t\t\t\tactionName,\n\t\t\t\t\t\tgetCoreDataAction( actionName ),\n\t\t\t\t\t] )\n\t\t\t\t);\n\t\t\t},\n\n\t\t\tsubscribe() {\n\t\t\t\t// There's no reasons to trigger any listener when we subscribe to this store\n\t\t\t\t// because there's no state stored in this store that need to retrigger selectors\n\t\t\t\t// if a change happens, the corresponding store where the tracking stated live\n\t\t\t\t// would have already triggered a \"subscribe\" call.\n\t\t\t\treturn () => () => {};\n\t\t\t},\n\t\t};\n\t},\n};\n\nexport default coreDataStore;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/components/async-mode-provider/context.js"],"names":[],"mappings":"AAKA,uDAA8C;AAI9C,kEAA0C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/async-mode-provider/index.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-async-mode.d.ts","sourceRoot":"","sources":["../../../src/components/async-mode-provider/use-async-mode.js"],"names":[],"mappings":"AAUA,gDAEC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export const Context: import("react").Context<import("../../registry").WPDataRegistry>;
|
|
2
|
+
/**
|
|
3
|
+
* A custom react Context consumer exposing the provided `registry` to
|
|
4
|
+
* children components. Used along with the RegistryProvider.
|
|
5
|
+
*
|
|
6
|
+
* You can read more about the react context api here:
|
|
7
|
+
* https://reactjs.org/docs/context.html#contextprovider
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```js
|
|
11
|
+
* import {
|
|
12
|
+
* RegistryProvider,
|
|
13
|
+
* RegistryConsumer,
|
|
14
|
+
* createRegistry
|
|
15
|
+
* } from '@wordpress/data';
|
|
16
|
+
*
|
|
17
|
+
* const registry = createRegistry( {} );
|
|
18
|
+
*
|
|
19
|
+
* const App = ( { props } ) => {
|
|
20
|
+
* return <RegistryProvider value={ registry }>
|
|
21
|
+
* <div>Hello There</div>
|
|
22
|
+
* <RegistryConsumer>
|
|
23
|
+
* { ( registry ) => (
|
|
24
|
+
* <ComponentUsingRegistry
|
|
25
|
+
* { ...props }
|
|
26
|
+
* registry={ registry }
|
|
27
|
+
* ) }
|
|
28
|
+
* </RegistryConsumer>
|
|
29
|
+
* </RegistryProvider>
|
|
30
|
+
* }
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export const RegistryConsumer: import("react").Consumer<import("../../registry").WPDataRegistry>;
|
|
34
|
+
export default Provider;
|
|
35
|
+
declare const Provider: import("react").Provider<import("../../registry").WPDataRegistry>;
|
|
36
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/components/registry-provider/context.js"],"names":[],"mappings":"AAUA,uFAAwD;AAIxD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,iGAAyC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/registry-provider/index.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A custom react hook exposing the registry context for use.
|
|
3
|
+
*
|
|
4
|
+
* This exposes the `registry` value provided via the
|
|
5
|
+
* <a href="#RegistryProvider">Registry Provider</a> to a component implementing
|
|
6
|
+
* this hook.
|
|
7
|
+
*
|
|
8
|
+
* It acts similarly to the `useContext` react hook.
|
|
9
|
+
*
|
|
10
|
+
* Note: Generally speaking, `useRegistry` is a low level hook that in most cases
|
|
11
|
+
* won't be needed for implementation. Most interactions with the `@wordpress/data`
|
|
12
|
+
* API can be performed via the `useSelect` hook, or the `withSelect` and
|
|
13
|
+
* `withDispatch` higher order components.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```js
|
|
17
|
+
* import {
|
|
18
|
+
* RegistryProvider,
|
|
19
|
+
* createRegistry,
|
|
20
|
+
* useRegistry,
|
|
21
|
+
* } from '@wordpress/data';
|
|
22
|
+
*
|
|
23
|
+
* const registry = createRegistry( {} );
|
|
24
|
+
*
|
|
25
|
+
* const SomeChildUsingRegistry = ( props ) => {
|
|
26
|
+
* const registry = useRegistry();
|
|
27
|
+
* // ...logic implementing the registry in other react hooks.
|
|
28
|
+
* };
|
|
29
|
+
*
|
|
30
|
+
*
|
|
31
|
+
* const ParentProvidingRegistry = ( props ) => {
|
|
32
|
+
* return <RegistryProvider value={ registry }>
|
|
33
|
+
* <SomeChildUsingRegistry { ...props } />
|
|
34
|
+
* </RegistryProvider>
|
|
35
|
+
* };
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* @return {Function} A custom react hook exposing the registry context value.
|
|
39
|
+
*/
|
|
40
|
+
export default function useRegistry(): Function;
|
|
41
|
+
//# sourceMappingURL=use-registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-registry.d.ts","sourceRoot":"","sources":["../../../src/components/registry-provider/use-registry.js"],"names":[],"mappings":"AAUA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,gDAEC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/use-dispatch/index.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export default useDispatchWithMap;
|
|
2
|
+
/**
|
|
3
|
+
* Custom react hook for returning aggregate dispatch actions using the provided
|
|
4
|
+
* dispatchMap.
|
|
5
|
+
*
|
|
6
|
+
* Currently this is an internal api only and is implemented by `withDispatch`
|
|
7
|
+
*
|
|
8
|
+
* @param {Function} dispatchMap Receives the `registry.dispatch` function as
|
|
9
|
+
* the first argument and the `registry` object
|
|
10
|
+
* as the second argument. Should return an
|
|
11
|
+
* object mapping props to functions.
|
|
12
|
+
* @param {Array} deps An array of dependencies for the hook.
|
|
13
|
+
* @return {Object} An object mapping props to functions created by the passed
|
|
14
|
+
* in dispatchMap.
|
|
15
|
+
*/
|
|
16
|
+
declare function useDispatchWithMap(dispatchMap: Function, deps: any[]): Object;
|
|
17
|
+
//# sourceMappingURL=use-dispatch-with-map.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-dispatch-with-map.d.ts","sourceRoot":"","sources":["../../../src/components/use-dispatch/use-dispatch-with-map.js"],"names":[],"mappings":";AAgBA;;;;;;;;;;;;;GAaG;AACH,yEAHY,MAAM,CA6BjB"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export default useDispatch;
|
|
2
|
+
export type StoreDescriptor = import("../../types").StoreDescriptor<any>;
|
|
3
|
+
/** @typedef {import('../../types').StoreDescriptor} StoreDescriptor */
|
|
4
|
+
/**
|
|
5
|
+
* A custom react hook returning the current registry dispatch actions creators.
|
|
6
|
+
*
|
|
7
|
+
* Note: The component using this hook must be within the context of a
|
|
8
|
+
* RegistryProvider.
|
|
9
|
+
*
|
|
10
|
+
* @param {string|StoreDescriptor} [storeNameOrDescriptor] Optionally provide the name of the
|
|
11
|
+
* store or its descriptor from which to
|
|
12
|
+
* retrieve action creators. If not
|
|
13
|
+
* provided, the registry.dispatch
|
|
14
|
+
* function is returned instead.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* This illustrates a pattern where you may need to retrieve dynamic data from
|
|
18
|
+
* the server via the `useSelect` hook to use in combination with the dispatch
|
|
19
|
+
* action.
|
|
20
|
+
*
|
|
21
|
+
* ```jsx
|
|
22
|
+
* import { useDispatch, useSelect } from '@wordpress/data';
|
|
23
|
+
* import { useCallback } from '@wordpress/element';
|
|
24
|
+
* import { store as myCustomStore } from 'my-custom-store';
|
|
25
|
+
*
|
|
26
|
+
* function Button( { onClick, children } ) {
|
|
27
|
+
* return <button type="button" onClick={ onClick }>{ children }</button>
|
|
28
|
+
* }
|
|
29
|
+
*
|
|
30
|
+
* const SaleButton = ( { children } ) => {
|
|
31
|
+
* const { stockNumber } = useSelect(
|
|
32
|
+
* ( select ) => select( myCustomStore ).getStockNumber(),
|
|
33
|
+
* []
|
|
34
|
+
* );
|
|
35
|
+
* const { startSale } = useDispatch( myCustomStore );
|
|
36
|
+
* const onClick = useCallback( () => {
|
|
37
|
+
* const discountPercent = stockNumber > 50 ? 10: 20;
|
|
38
|
+
* startSale( discountPercent );
|
|
39
|
+
* }, [ stockNumber ] );
|
|
40
|
+
* return <Button onClick={ onClick }>{ children }</Button>
|
|
41
|
+
* }
|
|
42
|
+
*
|
|
43
|
+
* // Rendered somewhere in the application:
|
|
44
|
+
* //
|
|
45
|
+
* // <SaleButton>Start Sale!</SaleButton>
|
|
46
|
+
* ```
|
|
47
|
+
* @return {Function} A custom react hook.
|
|
48
|
+
*/
|
|
49
|
+
declare function useDispatch(storeNameOrDescriptor?: string | import("../../types").StoreDescriptor<any> | undefined): Function;
|
|
50
|
+
//# sourceMappingURL=use-dispatch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-dispatch.d.ts","sourceRoot":"","sources":["../../../src/components/use-dispatch/use-dispatch.js"],"names":[],"mappings":";;AAKA,uEAAuE;AAEvE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,gIAKC"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {import('../../types').StoreDescriptor<C>} StoreDescriptor
|
|
3
|
+
* @template C
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @typedef {import('../../types').ReduxStoreConfig<State,Actions,Selectors>} ReduxStoreConfig
|
|
7
|
+
* @template State,Actions,Selectors
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* @typedef {import('../../types').UseSelectReturn<T>} UseSelectReturn
|
|
11
|
+
* @template T
|
|
12
|
+
*/
|
|
13
|
+
/** @typedef {import('../../types').MapSelect} MapSelect */
|
|
14
|
+
/**
|
|
15
|
+
* Custom react hook for retrieving props from registered selectors.
|
|
16
|
+
*
|
|
17
|
+
* In general, this custom React hook follows the
|
|
18
|
+
* [rules of hooks](https://reactjs.org/docs/hooks-rules.html).
|
|
19
|
+
*
|
|
20
|
+
* @template {MapSelect | StoreDescriptor<any>} T
|
|
21
|
+
* @param {T} mapSelect Function called on every state change. The returned value is
|
|
22
|
+
* exposed to the component implementing this hook. The function
|
|
23
|
+
* receives the `registry.select` method on the first argument
|
|
24
|
+
* and the `registry` on the second argument.
|
|
25
|
+
* When a store key is passed, all selectors for the store will be
|
|
26
|
+
* returned. This is only meant for usage of these selectors in event
|
|
27
|
+
* callbacks, not for data needed to create the element tree.
|
|
28
|
+
* @param {unknown[]} deps If provided, this memoizes the mapSelect so the same `mapSelect` is
|
|
29
|
+
* invoked on every state change unless the dependencies change.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```js
|
|
33
|
+
* import { useSelect } from '@wordpress/data';
|
|
34
|
+
* import { store as myCustomStore } from 'my-custom-store';
|
|
35
|
+
*
|
|
36
|
+
* function HammerPriceDisplay( { currency } ) {
|
|
37
|
+
* const price = useSelect( ( select ) => {
|
|
38
|
+
* return select( myCustomStore ).getPrice( 'hammer', currency );
|
|
39
|
+
* }, [ currency ] );
|
|
40
|
+
* return new Intl.NumberFormat( 'en-US', {
|
|
41
|
+
* style: 'currency',
|
|
42
|
+
* currency,
|
|
43
|
+
* } ).format( price );
|
|
44
|
+
* }
|
|
45
|
+
*
|
|
46
|
+
* // Rendered in the application:
|
|
47
|
+
* // <HammerPriceDisplay currency="USD" />
|
|
48
|
+
* ```
|
|
49
|
+
*
|
|
50
|
+
* In the above example, when `HammerPriceDisplay` is rendered into an
|
|
51
|
+
* application, the price will be retrieved from the store state using the
|
|
52
|
+
* `mapSelect` callback on `useSelect`. If the currency prop changes then
|
|
53
|
+
* any price in the state for that currency is retrieved. If the currency prop
|
|
54
|
+
* doesn't change and other props are passed in that do change, the price will
|
|
55
|
+
* not change because the dependency is just the currency.
|
|
56
|
+
*
|
|
57
|
+
* When data is only used in an event callback, the data should not be retrieved
|
|
58
|
+
* on render, so it may be useful to get the selectors function instead.
|
|
59
|
+
*
|
|
60
|
+
* **Don't use `useSelect` this way when calling the selectors in the render
|
|
61
|
+
* function because your component won't re-render on a data change.**
|
|
62
|
+
*
|
|
63
|
+
* ```js
|
|
64
|
+
* import { useSelect } from '@wordpress/data';
|
|
65
|
+
* import { store as myCustomStore } from 'my-custom-store';
|
|
66
|
+
*
|
|
67
|
+
* function Paste( { children } ) {
|
|
68
|
+
* const { getSettings } = useSelect( myCustomStore );
|
|
69
|
+
* function onPaste() {
|
|
70
|
+
* // Do something with the settings.
|
|
71
|
+
* const settings = getSettings();
|
|
72
|
+
* }
|
|
73
|
+
* return <div onPaste={ onPaste }>{ children }</div>;
|
|
74
|
+
* }
|
|
75
|
+
* ```
|
|
76
|
+
* @return {UseSelectReturn<T>} A custom react hook.
|
|
77
|
+
*/
|
|
78
|
+
export default function useSelect<T extends import("../../types").MapSelect | import("../../types").StoreDescriptor<any>>(mapSelect: T, deps: unknown[]): import("../../types").UseSelectReturn<T>;
|
|
79
|
+
/**
|
|
80
|
+
* A variant of the `useSelect` hook that has the same API, but will throw a
|
|
81
|
+
* suspense Promise if any of the called selectors is in an unresolved state.
|
|
82
|
+
*
|
|
83
|
+
* @param {Function} mapSelect Function called on every state change. The
|
|
84
|
+
* returned value is exposed to the component
|
|
85
|
+
* using this hook. The function receives the
|
|
86
|
+
* `registry.suspendSelect` method as the first
|
|
87
|
+
* argument and the `registry` as the second one.
|
|
88
|
+
* @param {Array} deps A dependency array used to memoize the `mapSelect`
|
|
89
|
+
* so that the same `mapSelect` is invoked on every
|
|
90
|
+
* state change unless the dependencies change.
|
|
91
|
+
*
|
|
92
|
+
* @return {Object} Data object returned by the `mapSelect` function.
|
|
93
|
+
*/
|
|
94
|
+
export function useSuspenseSelect(mapSelect: Function, deps: any[]): Object;
|
|
95
|
+
export type StoreDescriptor<C> = import('../../types').StoreDescriptor<C>;
|
|
96
|
+
export type ReduxStoreConfig<State, Actions, Selectors> = import('../../types').ReduxStoreConfig<State, Actions, Selectors>;
|
|
97
|
+
export type UseSelectReturn<T> = import('../../types').UseSelectReturn<T>;
|
|
98
|
+
export type MapSelect = import('../../types').MapSelect;
|
|
99
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/use-select/index.js"],"names":[],"mappings":"AA4BA;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH,2DAA2D;AAE3D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+DG;AACH,8IAlDW,OAAO,EAAE,4CA2MnB;AAED;;;;;;;;;;;;;;GAcG;AACH,qEAFY,MAAM,CAgHjB;iCArWY,OAAO,aAAa,EAAE,eAAe,CAAC,CAAC,CAAC;0DAIxC,OAAO,aAAa,EAAE,gBAAgB,CAAC,KAAK,EAAC,OAAO,EAAC,SAAS,CAAC;iCAI/D,OAAO,aAAa,EAAE,eAAe,CAAC,CAAC,CAAC;wBAGvC,OAAO,aAAa,EAAE,SAAS"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
export default withDispatch;
|
|
2
|
+
/**
|
|
3
|
+
* Higher-order component used to add dispatch props using registered action
|
|
4
|
+
* creators.
|
|
5
|
+
*
|
|
6
|
+
* @param {Function} mapDispatchToProps A function of returning an object of
|
|
7
|
+
* prop names where value is a
|
|
8
|
+
* dispatch-bound action creator, or a
|
|
9
|
+
* function to be called with the
|
|
10
|
+
* component's props and returning an
|
|
11
|
+
* action creator.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```jsx
|
|
15
|
+
* function Button( { onClick, children } ) {
|
|
16
|
+
* return <button type="button" onClick={ onClick }>{ children }</button>;
|
|
17
|
+
* }
|
|
18
|
+
*
|
|
19
|
+
* import { withDispatch } from '@wordpress/data';
|
|
20
|
+
* import { store as myCustomStore } from 'my-custom-store';
|
|
21
|
+
*
|
|
22
|
+
* const SaleButton = withDispatch( ( dispatch, ownProps ) => {
|
|
23
|
+
* const { startSale } = dispatch( myCustomStore );
|
|
24
|
+
* const { discountPercent } = ownProps;
|
|
25
|
+
*
|
|
26
|
+
* return {
|
|
27
|
+
* onClick() {
|
|
28
|
+
* startSale( discountPercent );
|
|
29
|
+
* },
|
|
30
|
+
* };
|
|
31
|
+
* } )( Button );
|
|
32
|
+
*
|
|
33
|
+
* // Rendered in the application:
|
|
34
|
+
* //
|
|
35
|
+
* // <SaleButton discountPercent="20">Start Sale!</SaleButton>
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* In the majority of cases, it will be sufficient to use only two first params
|
|
40
|
+
* passed to `mapDispatchToProps` as illustrated in the previous example.
|
|
41
|
+
* However, there might be some very advanced use cases where using the
|
|
42
|
+
* `registry` object might be used as a tool to optimize the performance of
|
|
43
|
+
* your component. Using `select` function from the registry might be useful
|
|
44
|
+
* when you need to fetch some dynamic data from the store at the time when the
|
|
45
|
+
* event is fired, but at the same time, you never use it to render your
|
|
46
|
+
* component. In such scenario, you can avoid using the `withSelect` higher
|
|
47
|
+
* order component to compute such prop, which might lead to unnecessary
|
|
48
|
+
* re-renders of your component caused by its frequent value change.
|
|
49
|
+
* Keep in mind, that `mapDispatchToProps` must return an object with functions
|
|
50
|
+
* only.
|
|
51
|
+
*
|
|
52
|
+
* ```jsx
|
|
53
|
+
* function Button( { onClick, children } ) {
|
|
54
|
+
* return <button type="button" onClick={ onClick }>{ children }</button>;
|
|
55
|
+
* }
|
|
56
|
+
*
|
|
57
|
+
* import { withDispatch } from '@wordpress/data';
|
|
58
|
+
* import { store as myCustomStore } from 'my-custom-store';
|
|
59
|
+
*
|
|
60
|
+
* const SaleButton = withDispatch( ( dispatch, ownProps, { select } ) => {
|
|
61
|
+
* // Stock number changes frequently.
|
|
62
|
+
* const { getStockNumber } = select( myCustomStore );
|
|
63
|
+
* const { startSale } = dispatch( myCustomStore );
|
|
64
|
+
* return {
|
|
65
|
+
* onClick() {
|
|
66
|
+
* const discountPercent = getStockNumber() > 50 ? 10 : 20;
|
|
67
|
+
* startSale( discountPercent );
|
|
68
|
+
* },
|
|
69
|
+
* };
|
|
70
|
+
* } )( Button );
|
|
71
|
+
*
|
|
72
|
+
* // Rendered in the application:
|
|
73
|
+
* //
|
|
74
|
+
* // <SaleButton>Start Sale!</SaleButton>
|
|
75
|
+
* ```
|
|
76
|
+
*
|
|
77
|
+
* _Note:_ It is important that the `mapDispatchToProps` function always
|
|
78
|
+
* returns an object with the same keys. For example, it should not contain
|
|
79
|
+
* conditions under which a different value would be returned.
|
|
80
|
+
*
|
|
81
|
+
* @return {WPComponent} Enhanced component with merged dispatcher props.
|
|
82
|
+
*/
|
|
83
|
+
declare function withDispatch(mapDispatchToProps: Function): any;
|
|
84
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/with-dispatch/index.js"],"names":[],"mappings":";AAUA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgFG;AACH,iEASE"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export default withRegistry;
|
|
2
|
+
/**
|
|
3
|
+
* Higher-order component which renders the original component with the current
|
|
4
|
+
* registry context passed as its `registry` prop.
|
|
5
|
+
*
|
|
6
|
+
* @param {WPComponent} OriginalComponent Original component.
|
|
7
|
+
*
|
|
8
|
+
* @return {WPComponent} Enhanced component.
|
|
9
|
+
*/
|
|
10
|
+
declare const withRegistry: (Inner: import("react").ComponentType<any>) => (props: any) => JSX.Element;
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/with-registry/index.js"],"names":[],"mappings":";AAUA;;;;;;;GAOG;AACH,uGAUE"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export default withSelect;
|
|
2
|
+
/**
|
|
3
|
+
* Higher-order component used to inject state-derived props using registered
|
|
4
|
+
* selectors.
|
|
5
|
+
*
|
|
6
|
+
* @param {Function} mapSelectToProps Function called on every state change,
|
|
7
|
+
* expected to return object of props to
|
|
8
|
+
* merge with the component's own props.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```js
|
|
12
|
+
* import { withSelect } from '@wordpress/data';
|
|
13
|
+
* import { store as myCustomStore } from 'my-custom-store';
|
|
14
|
+
*
|
|
15
|
+
* function PriceDisplay( { price, currency } ) {
|
|
16
|
+
* return new Intl.NumberFormat( 'en-US', {
|
|
17
|
+
* style: 'currency',
|
|
18
|
+
* currency,
|
|
19
|
+
* } ).format( price );
|
|
20
|
+
* }
|
|
21
|
+
*
|
|
22
|
+
* const HammerPriceDisplay = withSelect( ( select, ownProps ) => {
|
|
23
|
+
* const { getPrice } = select( myCustomStore );
|
|
24
|
+
* const { currency } = ownProps;
|
|
25
|
+
*
|
|
26
|
+
* return {
|
|
27
|
+
* price: getPrice( 'hammer', currency ),
|
|
28
|
+
* };
|
|
29
|
+
* } )( PriceDisplay );
|
|
30
|
+
*
|
|
31
|
+
* // Rendered in the application:
|
|
32
|
+
* //
|
|
33
|
+
* // <HammerPriceDisplay currency="USD" />
|
|
34
|
+
* ```
|
|
35
|
+
* In the above example, when `HammerPriceDisplay` is rendered into an
|
|
36
|
+
* application, it will pass the price into the underlying `PriceDisplay`
|
|
37
|
+
* component and update automatically if the price of a hammer ever changes in
|
|
38
|
+
* the store.
|
|
39
|
+
*
|
|
40
|
+
* @return {WPComponent} Enhanced component with merged state data props.
|
|
41
|
+
*/
|
|
42
|
+
declare function withSelect(mapSelectToProps: Function): any;
|
|
43
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/with-select/index.js"],"names":[],"mappings":";AAUA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,6DAUE"}
|