@wordpress/core-data 4.0.2 → 4.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -5
- package/build/actions.js +79 -34
- package/build/actions.js.map +1 -1
- package/build/entities.js +51 -9
- package/build/entities.js.map +1 -1
- package/build/fetch/__experimental-fetch-url-data.js +1 -1
- package/build/fetch/__experimental-fetch-url-data.js.map +1 -1
- package/build/index.js +0 -7
- package/build/index.js.map +1 -1
- package/build/queried-data/get-query-parts.js +2 -0
- package/build/queried-data/get-query-parts.js.map +1 -1
- package/build/reducer.js +16 -18
- package/build/reducer.js.map +1 -1
- package/build/resolvers.js +48 -31
- package/build/resolvers.js.map +1 -1
- package/build/selectors.js +70 -10
- package/build/selectors.js.map +1 -1
- package/build/utils/forward-resolver.js +23 -0
- package/build/utils/forward-resolver.js.map +1 -0
- package/build/utils/index.js +3 -3
- package/build/utils/index.js.map +1 -1
- package/build-module/actions.js +74 -33
- package/build-module/actions.js.map +1 -1
- package/build-module/entities.js +51 -9
- package/build-module/entities.js.map +1 -1
- package/build-module/fetch/__experimental-fetch-url-data.js +1 -1
- package/build-module/fetch/__experimental-fetch-url-data.js.map +1 -1
- package/build-module/index.js +0 -5
- package/build-module/index.js.map +1 -1
- package/build-module/queried-data/get-query-parts.js +2 -0
- package/build-module/queried-data/get-query-parts.js.map +1 -1
- package/build-module/reducer.js +14 -16
- package/build-module/reducer.js.map +1 -1
- package/build-module/resolvers.js +51 -37
- package/build-module/resolvers.js.map +1 -1
- package/build-module/selectors.js +64 -8
- package/build-module/selectors.js.map +1 -1
- package/build-module/utils/forward-resolver.js +15 -0
- package/build-module/utils/forward-resolver.js.map +1 -0
- package/build-module/utils/index.js +1 -1
- package/build-module/utils/index.js.map +1 -1
- package/package.json +10 -11
- package/src/actions.js +83 -52
- package/src/entities.js +36 -6
- package/src/fetch/__experimental-fetch-url-data.js +1 -1
- package/src/index.js +0 -3
- package/src/queried-data/get-query-parts.js +2 -0
- package/src/reducer.js +14 -17
- package/src/resolvers.js +67 -42
- package/src/selectors.js +143 -35
- package/src/test/actions.js +116 -37
- package/src/test/selectors.js +56 -1
- package/src/utils/forward-resolver.js +14 -0
- package/src/utils/index.js +1 -1
- package/build/controls.js +0 -44
- package/build/controls.js.map +0 -1
- package/build/utils/if-not-resolved.js +0 -31
- package/build/utils/if-not-resolved.js.map +0 -1
- package/build-module/controls.js +0 -31
- package/build-module/controls.js.map +0 -1
- package/build-module/utils/if-not-resolved.js +0 -23
- package/build-module/utils/if-not-resolved.js.map +0 -1
- package/src/controls.js +0 -31
- package/src/utils/if-not-resolved.js +0 -22
- package/src/utils/test/if-not-resolved.js +0 -76
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/core-data/src/fetch/__experimental-fetch-url-data.js"],"names":["apiFetch","addQueryArgs","prependHTTP","isURL","getProtocol","isValidProtocol","CACHE","Map","fetchUrlData","url","options","endpoint","args","Promise","reject","protocol","startsWith","test","has","get","path","then","res","set"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,QAAP,MAAqB,sBAArB;AACA,SACCC,YADD,EAECC,WAFD,EAGCC,KAHD,EAICC,WAJD,EAKCC,eALD,QAMO,gBANP;AAQA;AACA;AACA;AACA;AACA;;AACA,MAAMC,KAAK,GAAG,IAAIC,GAAJ,EAAd;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMC,YAAY,GAAG,OAAQC,GAAR,EAAaC,OAAO,GAAG,EAAvB,KAA+B;AACnD,QAAMC,QAAQ,GAAG,
|
|
1
|
+
{"version":3,"sources":["@wordpress/core-data/src/fetch/__experimental-fetch-url-data.js"],"names":["apiFetch","addQueryArgs","prependHTTP","isURL","getProtocol","isValidProtocol","CACHE","Map","fetchUrlData","url","options","endpoint","args","Promise","reject","protocol","startsWith","test","has","get","path","then","res","set"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,QAAP,MAAqB,sBAArB;AACA,SACCC,YADD,EAECC,WAFD,EAGCC,KAHD,EAICC,WAJD,EAKCC,eALD,QAMO,gBANP;AAQA;AACA;AACA;AACA;AACA;;AACA,MAAMC,KAAK,GAAG,IAAIC,GAAJ,EAAd;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMC,YAAY,GAAG,OAAQC,GAAR,EAAaC,OAAO,GAAG,EAAvB,KAA+B;AACnD,QAAMC,QAAQ,GAAG,iCAAjB;AAEA,QAAMC,IAAI,GAAG;AACZH,IAAAA,GAAG,EAAEP,WAAW,CAAEO,GAAF;AADJ,GAAb;;AAIA,MAAK,CAAEN,KAAK,CAAEM,GAAF,CAAZ,EAAsB;AACrB,WAAOI,OAAO,CAACC,MAAR,CAAiB,GAAGL,GAAK,sBAAzB,CAAP;AACA,GATkD,CAWnD;AACA;;;AACA,QAAMM,QAAQ,GAAGX,WAAW,CAAEK,GAAF,CAA5B;;AAEA,MACC,CAAEJ,eAAe,CAAEU,QAAF,CAAjB,IACA,CAAEA,QAAQ,CAACC,UAAT,CAAqB,MAArB,CADF,IAEA,CAAE,uBAAuBC,IAAvB,CAA6BR,GAA7B,CAHH,EAIE;AACD,WAAOI,OAAO,CAACC,MAAR,CACL,GAAGL,GAAK,4DADH,CAAP;AAGA;;AAED,MAAKH,KAAK,CAACY,GAAN,CAAWT,GAAX,CAAL,EAAwB;AACvB,WAAOH,KAAK,CAACa,GAAN,CAAWV,GAAX,CAAP;AACA;;AAED,SAAOT,QAAQ,CAAE;AAChBoB,IAAAA,IAAI,EAAEnB,YAAY,CAAEU,QAAF,EAAYC,IAAZ,CADF;AAEhB,OAAGF;AAFa,GAAF,CAAR,CAGHW,IAHG,CAGKC,GAAF,IAAW;AACpBhB,IAAAA,KAAK,CAACiB,GAAN,CAAWd,GAAX,EAAgBa,GAAhB;AACA,WAAOA,GAAP;AACA,GANM,CAAP;AAOA,CApCD;;AAsCA,eAAed,YAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport apiFetch from '@wordpress/api-fetch';\nimport {\n\taddQueryArgs,\n\tprependHTTP,\n\tisURL,\n\tgetProtocol,\n\tisValidProtocol,\n} from '@wordpress/url';\n\n/**\n * A simple in-memory cache for requests.\n * This avoids repeat HTTP requests which may be beneficial\n * for those wishing to preserve low-bandwidth.\n */\nconst CACHE = new Map();\n\n/**\n * @typedef WPRemoteUrlData\n *\n * @property {string} title contents of the remote URL's `<title>` tag.\n */\n\n/**\n * Fetches data about a remote URL.\n * eg: <title> tag, favicon...etc.\n *\n * @async\n * @param {string} url the URL to request details from.\n * @param {Object?} options any options to pass to the underlying fetch.\n * @example\n * ```js\n * import { __experimentalFetchUrlData as fetchUrlData } from '@wordpress/core-data';\n *\n * //...\n *\n * export function initialize( id, settings ) {\n *\n * settings.__experimentalFetchUrlData = (\n * url\n * ) => fetchUrlData( url );\n * ```\n * @return {Promise< WPRemoteUrlData[] >} Remote URL data.\n */\nconst fetchUrlData = async ( url, options = {} ) => {\n\tconst endpoint = '/wp-block-editor/v1/url-details';\n\n\tconst args = {\n\t\turl: prependHTTP( url ),\n\t};\n\n\tif ( ! isURL( url ) ) {\n\t\treturn Promise.reject( `${ url } is not a valid URL.` );\n\t}\n\n\t// Test for \"http\" based URL as it is possible for valid\n\t// yet unusable URLs such as `tel:123456` to be passed.\n\tconst protocol = getProtocol( url );\n\n\tif (\n\t\t! isValidProtocol( protocol ) ||\n\t\t! protocol.startsWith( 'http' ) ||\n\t\t! /^https?:\\/\\/[^\\/\\s]/i.test( url )\n\t) {\n\t\treturn Promise.reject(\n\t\t\t`${ url } does not have a valid protocol. URLs must be \"http\" based`\n\t\t);\n\t}\n\n\tif ( CACHE.has( url ) ) {\n\t\treturn CACHE.get( url );\n\t}\n\n\treturn apiFetch( {\n\t\tpath: addQueryArgs( endpoint, args ),\n\t\t...options,\n\t} ).then( ( res ) => {\n\t\tCACHE.set( url, res );\n\t\treturn res;\n\t} );\n};\n\nexport default fetchUrlData;\n"]}
|
package/build-module/index.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { createReduxStore, register } from '@wordpress/data';
|
|
5
|
-
import { controls } from '@wordpress/data-controls';
|
|
6
5
|
/**
|
|
7
6
|
* Internal dependencies
|
|
8
7
|
*/
|
|
@@ -12,7 +11,6 @@ import * as selectors from './selectors';
|
|
|
12
11
|
import * as actions from './actions';
|
|
13
12
|
import * as resolvers from './resolvers';
|
|
14
13
|
import createLocksActions from './locks/actions';
|
|
15
|
-
import customControls from './controls';
|
|
16
14
|
import { defaultEntities, getMethodName } from './entities';
|
|
17
15
|
import { STORE_NAME } from './name'; // The entity selectors/resolvers and actions are shortcuts to their generic equivalents
|
|
18
16
|
// (getEntityRecord, getEntityRecords, updateEntityRecord, updateEntityRecordss)
|
|
@@ -62,9 +60,6 @@ const entityActions = defaultEntities.reduce((result, entity) => {
|
|
|
62
60
|
|
|
63
61
|
const storeConfig = () => ({
|
|
64
62
|
reducer,
|
|
65
|
-
controls: { ...customControls,
|
|
66
|
-
...controls
|
|
67
|
-
},
|
|
68
63
|
actions: { ...actions,
|
|
69
64
|
...entityActions,
|
|
70
65
|
...createLocksActions()
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/core-data/src/index.js"],"names":["createReduxStore","register","
|
|
1
|
+
{"version":3,"sources":["@wordpress/core-data/src/index.js"],"names":["createReduxStore","register","reducer","selectors","actions","resolvers","createLocksActions","defaultEntities","getMethodName","STORE_NAME","entitySelectors","reduce","result","entity","kind","name","state","key","query","getEntityRecord","args","getEntityRecords","entityResolvers","pluralMethodName","shouldInvalidate","action","entityActions","saveEntityRecord","deleteEntityRecord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AAkCC,IAAlC,EAAwCE,GAAxC,EAA6CC,KAA7C,CADD;;AAEA,SAAON,MAAP;AACA,CAPqB,EAOnB,EAPmB,CAAtB;;AASA,MAAMiB,WAAW,GAAG,OAAQ;AAC3B3B,EAAAA,OAD2B;AAE3BE,EAAAA,OAAO,EAAE,EAAE,GAAGA,OAAL;AAAc,OAAGsB,aAAjB;AAAgC,OAAGpB,kBAAkB;AAArD,GAFkB;AAG3BH,EAAAA,SAAS,EAAE,EAAE,GAAGA,SAAL;AAAgB,OAAGO;AAAnB,GAHgB;AAI3BL,EAAAA,SAAS,EAAE,EAAE,GAAGA,SAAL;AAAgB,OAAGiB;AAAnB,GAJgB;AAK3BQ,EAAAA,uBAAuB,EAAE;AALE,CAAR,CAApB;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,OAAO,MAAMC,KAAK,GAAG/B,gBAAgB,CAAES,UAAF,EAAcoB,WAAW,EAAzB,CAA9B;AAEP5B,QAAQ,CAAE8B,KAAF,CAAR;AAEA,SAASC,OAAO,IAAIC,cAApB,QAA0C,mBAA1C;AACA,cAAc,mBAAd;AACA,cAAc,SAAd","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createReduxStore, register } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport reducer from './reducer';\nimport * as selectors from './selectors';\nimport * as actions from './actions';\nimport * as resolvers from './resolvers';\nimport createLocksActions from './locks/actions';\nimport { defaultEntities, getMethodName } from './entities';\nimport { STORE_NAME } from './name';\n\n// The entity selectors/resolvers and actions are shortcuts to their generic equivalents\n// (getEntityRecord, getEntityRecords, updateEntityRecord, updateEntityRecordss)\n// Instead of getEntityRecord, the consumer could use more user-frieldly named selector: getPostType, getTaxonomy...\n// The \"kind\" and the \"name\" of the entity are combined to generate these shortcuts.\n\nconst entitySelectors = defaultEntities.reduce( ( result, entity ) => {\n\tconst { kind, name } = entity;\n\tresult[ getMethodName( kind, name ) ] = ( state, key, query ) =>\n\t\tselectors.getEntityRecord( state, kind, name, key, query );\n\tresult[ getMethodName( kind, name, 'get', true ) ] = ( state, ...args ) =>\n\t\tselectors.getEntityRecords( state, kind, name, ...args );\n\treturn result;\n}, {} );\n\nconst entityResolvers = defaultEntities.reduce( ( result, entity ) => {\n\tconst { kind, name } = entity;\n\tresult[ getMethodName( kind, name ) ] = ( key, query ) =>\n\t\tresolvers.getEntityRecord( kind, name, key, query );\n\tconst pluralMethodName = getMethodName( kind, name, 'get', true );\n\tresult[ pluralMethodName ] = ( ...args ) =>\n\t\tresolvers.getEntityRecords( kind, name, ...args );\n\tresult[ pluralMethodName ].shouldInvalidate = ( action, ...args ) =>\n\t\tresolvers.getEntityRecords.shouldInvalidate(\n\t\t\taction,\n\t\t\tkind,\n\t\t\tname,\n\t\t\t...args\n\t\t);\n\treturn result;\n}, {} );\n\nconst entityActions = defaultEntities.reduce( ( result, entity ) => {\n\tconst { kind, name } = entity;\n\tresult[ getMethodName( kind, name, 'save' ) ] = ( key ) =>\n\t\tactions.saveEntityRecord( kind, name, key );\n\tresult[ getMethodName( kind, name, 'delete' ) ] = ( key, query ) =>\n\t\tactions.deleteEntityRecord( kind, name, key, query );\n\treturn result;\n}, {} );\n\nconst storeConfig = () => ( {\n\treducer,\n\tactions: { ...actions, ...entityActions, ...createLocksActions() },\n\tselectors: { ...selectors, ...entitySelectors },\n\tresolvers: { ...resolvers, ...entityResolvers },\n\t__experimentalUseThunks: true,\n} );\n\n/**\n * Store definition for the code data namespace.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore\n *\n * @type {Object}\n */\nexport const store = createReduxStore( STORE_NAME, storeConfig() );\n\nregister( store );\n\nexport { default as EntityProvider } from './entity-provider';\nexport * from './entity-provider';\nexport * from './fetch';\n"]}
|
|
@@ -19,6 +19,8 @@ import { withWeakMapCache, getNormalizedCommaSeparable } from '../utils';
|
|
|
19
19
|
* @property {?(string[])} fields Target subset of fields to derive from
|
|
20
20
|
* item objects.
|
|
21
21
|
* @property {?(number[])} include Specific item IDs to include.
|
|
22
|
+
* @property {string} context Scope under which the request is made;
|
|
23
|
+
* determines returned fields in response.
|
|
22
24
|
*/
|
|
23
25
|
|
|
24
26
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/core-data/src/queried-data/get-query-parts.js"],"names":["addQueryArgs","withWeakMapCache","getNormalizedCommaSeparable","getQueryParts","query","parts","stableKey","page","perPage","fields","include","context","keys","Object","sort","i","length","key","value","Number","join","map","slice"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,YAAT,QAA6B,gBAA7B;AAEA;AACA;AACA;;AACA,SAASC,gBAAT,EAA2BC,2BAA3B,QAA8D,UAA9D;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,aAAT,CAAwBC,KAAxB,EAAgC;AACtC;AACD;AACA;AACC,QAAMC,KAAK,GAAG;AACbC,IAAAA,SAAS,EAAE,EADE;AAEbC,IAAAA,IAAI,EAAE,CAFO;AAGbC,IAAAA,OAAO,EAAE,EAHI;AAIbC,IAAAA,MAAM,EAAE,IAJK;AAKbC,IAAAA,OAAO,EAAE,IALI;AAMbC,IAAAA,OAAO,EAAE;AANI,GAAd,CAJsC,CAatC;;AACA,QAAMC,IAAI,GAAGC,MAAM,CAACD,IAAP,CAAaR,KAAb,EAAqBU,IAArB,EAAb;;AAEA,OAAM,IAAIC,CAAC,GAAG,CAAd,EAAiBA,CAAC,GAAGH,IAAI,CAACI,MAA1B,EAAkCD,CAAC,EAAnC,EAAwC;AACvC,UAAME,GAAG,GAAGL,IAAI,CAAEG,CAAF,CAAhB;AACA,QAAIG,KAAK,GAAGd,KAAK,CAAEa,GAAF,CAAjB;;AAEA,YAASA,GAAT;AACC,WAAK,MAAL;AACCZ,QAAAA,KAAK,CAAEY,GAAF,CAAL,GAAeE,MAAM,CAAED,KAAF,CAArB;AACA;;AAED,WAAK,UAAL;AACCb,QAAAA,KAAK,CAACG,OAAN,GAAgBW,MAAM,CAAED,KAAF,CAAtB;AACA;;AAED,WAAK,SAAL;AACCb,QAAAA,KAAK,CAACM,OAAN,GAAgBO,KAAhB;AACA;;AAED;AACC;AACA;AACA;AACA;AACA;AACA,YAAKD,GAAG,KAAK,SAAb,EAAyB;AACxBZ,UAAAA,KAAK,CAACI,MAAN,GAAeP,2BAA2B,CAAEgB,KAAF,CAA1C,CADwB,CAExB;;AACAA,UAAAA,KAAK,GAAGb,KAAK,CAACI,MAAN,CAAaW,IAAb,EAAR;AACA,SAVF,CAYC;;;AACA,YAAKH,GAAG,KAAK,SAAb,EAAyB;AACxBZ,UAAAA,KAAK,CAACK,OAAN,GAAgBR,2BAA2B,CAAEgB,KAAF,CAA3B,CAAqCG,GAArC,CACfF,MADe,CAAhB,CADwB,CAIxB;;AACAD,UAAAA,KAAK,GAAGb,KAAK,CAACK,OAAN,CAAcU,IAAd,EAAR;AACA,SAnBF,CAqBC;AACA;AACA;AACA;AACA;AACA;AACA;;;AACAf,QAAAA,KAAK,CAACC,SAAN,IACC,CAAED,KAAK,CAACC,SAAN,GAAkB,GAAlB,GAAwB,EAA1B,IACAN,YAAY,CAAE,EAAF,EAAM;AAAE,WAAEiB,GAAF,GAASC;AAAX,SAAN,CAAZ,CAAuCI,KAAvC,CAA8C,CAA9C,CAFD;AAzCF;AA6CA;;AAED,SAAOjB,KAAP;AACA;AAED,eAAeJ,gBAAgB,CAAEE,aAAF,CAA/B","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { addQueryArgs } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { withWeakMapCache, getNormalizedCommaSeparable } from '../utils';\n\n/**\n * An object of properties describing a specific query.\n *\n * @typedef {Object} WPQueriedDataQueryParts\n *\n * @property {number} page The query page (1-based index, default 1).\n * @property {number} perPage Items per page for query (default 10).\n * @property {string} stableKey An encoded stable string of all non-\n * pagination, non-fields query parameters.\n * @property {?(string[])} fields Target subset of fields to derive from\n * item objects.\n * @property {?(number[])} include Specific item IDs to include.\n */\n\n/**\n * Given a query object, returns an object of parts, including pagination\n * details (`page` and `perPage`, or default values). All other properties are\n * encoded into a stable (idempotent) `stableKey` value.\n *\n * @param {Object} query Optional query object.\n *\n * @return {WPQueriedDataQueryParts} Query parts.\n */\nexport function getQueryParts( query ) {\n\t/**\n\t * @type {WPQueriedDataQueryParts}\n\t */\n\tconst parts = {\n\t\tstableKey: '',\n\t\tpage: 1,\n\t\tperPage: 10,\n\t\tfields: null,\n\t\tinclude: null,\n\t\tcontext: 'default',\n\t};\n\n\t// Ensure stable key by sorting keys. Also more efficient for iterating.\n\tconst keys = Object.keys( query ).sort();\n\n\tfor ( let i = 0; i < keys.length; i++ ) {\n\t\tconst key = keys[ i ];\n\t\tlet value = query[ key ];\n\n\t\tswitch ( key ) {\n\t\t\tcase 'page':\n\t\t\t\tparts[ key ] = Number( value );\n\t\t\t\tbreak;\n\n\t\t\tcase 'per_page':\n\t\t\t\tparts.perPage = Number( value );\n\t\t\t\tbreak;\n\n\t\t\tcase 'context':\n\t\t\t\tparts.context = value;\n\t\t\t\tbreak;\n\n\t\t\tdefault:\n\t\t\t\t// While in theory, we could exclude \"_fields\" from the stableKey\n\t\t\t\t// because two request with different fields have the same results\n\t\t\t\t// We're not able to ensure that because the server can decide to omit\n\t\t\t\t// fields from the response even if we explicitely asked for it.\n\t\t\t\t// Example: Asking for titles in posts without title support.\n\t\t\t\tif ( key === '_fields' ) {\n\t\t\t\t\tparts.fields = getNormalizedCommaSeparable( value );\n\t\t\t\t\t// Make sure to normalize value for `stableKey`\n\t\t\t\t\tvalue = parts.fields.join();\n\t\t\t\t}\n\n\t\t\t\t// Two requests with different include values cannot have same results.\n\t\t\t\tif ( key === 'include' ) {\n\t\t\t\t\tparts.include = getNormalizedCommaSeparable( value ).map(\n\t\t\t\t\t\tNumber\n\t\t\t\t\t);\n\t\t\t\t\t// Normalize value for `stableKey`.\n\t\t\t\t\tvalue = parts.include.join();\n\t\t\t\t}\n\n\t\t\t\t// While it could be any deterministic string, for simplicity's\n\t\t\t\t// sake mimic querystring encoding for stable key.\n\t\t\t\t//\n\t\t\t\t// TODO: For consistency with PHP implementation, addQueryArgs\n\t\t\t\t// should accept a key value pair, which may optimize its\n\t\t\t\t// implementation for our use here, vs. iterating an object\n\t\t\t\t// with only a single key.\n\t\t\t\tparts.stableKey +=\n\t\t\t\t\t( parts.stableKey ? '&' : '' ) +\n\t\t\t\t\taddQueryArgs( '', { [ key ]: value } ).slice( 1 );\n\t\t}\n\t}\n\n\treturn parts;\n}\n\nexport default withWeakMapCache( getQueryParts );\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/core-data/src/queried-data/get-query-parts.js"],"names":["addQueryArgs","withWeakMapCache","getNormalizedCommaSeparable","getQueryParts","query","parts","stableKey","page","perPage","fields","include","context","keys","Object","sort","i","length","key","value","Number","join","map","slice"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,YAAT,QAA6B,gBAA7B;AAEA;AACA;AACA;;AACA,SAASC,gBAAT,EAA2BC,2BAA3B,QAA8D,UAA9D;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,aAAT,CAAwBC,KAAxB,EAAgC;AACtC;AACD;AACA;AACC,QAAMC,KAAK,GAAG;AACbC,IAAAA,SAAS,EAAE,EADE;AAEbC,IAAAA,IAAI,EAAE,CAFO;AAGbC,IAAAA,OAAO,EAAE,EAHI;AAIbC,IAAAA,MAAM,EAAE,IAJK;AAKbC,IAAAA,OAAO,EAAE,IALI;AAMbC,IAAAA,OAAO,EAAE;AANI,GAAd,CAJsC,CAatC;;AACA,QAAMC,IAAI,GAAGC,MAAM,CAACD,IAAP,CAAaR,KAAb,EAAqBU,IAArB,EAAb;;AAEA,OAAM,IAAI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AAEE,aAAF,CAA/B","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { addQueryArgs } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { withWeakMapCache, getNormalizedCommaSeparable } from '../utils';\n\n/**\n * An object of properties describing a specific query.\n *\n * @typedef {Object} WPQueriedDataQueryParts\n *\n * @property {number} page The query page (1-based index, default 1).\n * @property {number} perPage Items per page for query (default 10).\n * @property {string} stableKey An encoded stable string of all non-\n * pagination, non-fields query parameters.\n * @property {?(string[])} fields Target subset of fields to derive from\n * item objects.\n * @property {?(number[])} include Specific item IDs to include.\n * @property {string} context Scope under which the request is made;\n * determines returned fields in response.\n */\n\n/**\n * Given a query object, returns an object of parts, including pagination\n * details (`page` and `perPage`, or default values). All other properties are\n * encoded into a stable (idempotent) `stableKey` value.\n *\n * @param {Object} query Optional query object.\n *\n * @return {WPQueriedDataQueryParts} Query parts.\n */\nexport function getQueryParts( query ) {\n\t/**\n\t * @type {WPQueriedDataQueryParts}\n\t */\n\tconst parts = {\n\t\tstableKey: '',\n\t\tpage: 1,\n\t\tperPage: 10,\n\t\tfields: null,\n\t\tinclude: null,\n\t\tcontext: 'default',\n\t};\n\n\t// Ensure stable key by sorting keys. Also more efficient for iterating.\n\tconst keys = Object.keys( query ).sort();\n\n\tfor ( let i = 0; i < keys.length; i++ ) {\n\t\tconst key = keys[ i ];\n\t\tlet value = query[ key ];\n\n\t\tswitch ( key ) {\n\t\t\tcase 'page':\n\t\t\t\tparts[ key ] = Number( value );\n\t\t\t\tbreak;\n\n\t\t\tcase 'per_page':\n\t\t\t\tparts.perPage = Number( value );\n\t\t\t\tbreak;\n\n\t\t\tcase 'context':\n\t\t\t\tparts.context = value;\n\t\t\t\tbreak;\n\n\t\t\tdefault:\n\t\t\t\t// While in theory, we could exclude \"_fields\" from the stableKey\n\t\t\t\t// because two request with different fields have the same results\n\t\t\t\t// We're not able to ensure that because the server can decide to omit\n\t\t\t\t// fields from the response even if we explicitely asked for it.\n\t\t\t\t// Example: Asking for titles in posts without title support.\n\t\t\t\tif ( key === '_fields' ) {\n\t\t\t\t\tparts.fields = getNormalizedCommaSeparable( value );\n\t\t\t\t\t// Make sure to normalize value for `stableKey`\n\t\t\t\t\tvalue = parts.fields.join();\n\t\t\t\t}\n\n\t\t\t\t// Two requests with different include values cannot have same results.\n\t\t\t\tif ( key === 'include' ) {\n\t\t\t\t\tparts.include = getNormalizedCommaSeparable( value ).map(\n\t\t\t\t\t\tNumber\n\t\t\t\t\t);\n\t\t\t\t\t// Normalize value for `stableKey`.\n\t\t\t\t\tvalue = parts.include.join();\n\t\t\t\t}\n\n\t\t\t\t// While it could be any deterministic string, for simplicity's\n\t\t\t\t// sake mimic querystring encoding for stable key.\n\t\t\t\t//\n\t\t\t\t// TODO: For consistency with PHP implementation, addQueryArgs\n\t\t\t\t// should accept a key value pair, which may optimize its\n\t\t\t\t// implementation for our use here, vs. iterating an object\n\t\t\t\t// with only a single key.\n\t\t\t\tparts.stableKey +=\n\t\t\t\t\t( parts.stableKey ? '&' : '' ) +\n\t\t\t\t\taddQueryArgs( '', { [ key ]: value } ).slice( 1 );\n\t\t}\n\t}\n\n\treturn parts;\n}\n\nexport default withWeakMapCache( getQueryParts );\n"]}
|
package/build-module/reducer.js
CHANGED
|
@@ -116,38 +116,36 @@ export function currentTheme(state = undefined, action) {
|
|
|
116
116
|
return state;
|
|
117
117
|
}
|
|
118
118
|
/**
|
|
119
|
-
* Reducer managing
|
|
119
|
+
* Reducer managing the current global styles id.
|
|
120
120
|
*
|
|
121
|
-
* @param {
|
|
121
|
+
* @param {string} state Current state.
|
|
122
122
|
* @param {Object} action Dispatched action.
|
|
123
123
|
*
|
|
124
|
-
* @return {
|
|
124
|
+
* @return {string} Updated state.
|
|
125
125
|
*/
|
|
126
126
|
|
|
127
|
-
export function
|
|
127
|
+
export function currentGlobalStylesId(state = undefined, action) {
|
|
128
128
|
switch (action.type) {
|
|
129
|
-
case '
|
|
130
|
-
return
|
|
131
|
-
[action.currentTheme.stylesheet]: action.currentTheme
|
|
132
|
-
};
|
|
129
|
+
case 'RECEIVE_CURRENT_GLOBAL_STYLES_ID':
|
|
130
|
+
return action.id;
|
|
133
131
|
}
|
|
134
132
|
|
|
135
133
|
return state;
|
|
136
134
|
}
|
|
137
135
|
/**
|
|
138
|
-
* Reducer managing theme
|
|
136
|
+
* Reducer managing the theme base global styles.
|
|
139
137
|
*
|
|
140
|
-
* @param {
|
|
138
|
+
* @param {string} state Current state.
|
|
141
139
|
* @param {Object} action Dispatched action.
|
|
142
140
|
*
|
|
143
|
-
* @return {
|
|
141
|
+
* @return {string} Updated state.
|
|
144
142
|
*/
|
|
145
143
|
|
|
146
|
-
export function
|
|
144
|
+
export function themeBaseGlobalStyles(state = {}, action) {
|
|
147
145
|
switch (action.type) {
|
|
148
|
-
case '
|
|
146
|
+
case 'RECEIVE_THEME_GLOBAL_STYLES':
|
|
149
147
|
return { ...state,
|
|
150
|
-
|
|
148
|
+
[action.stylesheet]: action.globalStyles
|
|
151
149
|
};
|
|
152
150
|
}
|
|
153
151
|
|
|
@@ -503,10 +501,10 @@ export default combineReducers({
|
|
|
503
501
|
terms,
|
|
504
502
|
users,
|
|
505
503
|
currentTheme,
|
|
504
|
+
currentGlobalStylesId,
|
|
506
505
|
currentUser,
|
|
506
|
+
themeBaseGlobalStyles,
|
|
507
507
|
taxonomies,
|
|
508
|
-
themes,
|
|
509
|
-
themeSupports,
|
|
510
508
|
entities,
|
|
511
509
|
undo,
|
|
512
510
|
embedPreviews,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/core-data/src/reducer.js"],"names":["keyBy","map","groupBy","flowRight","isEqual","get","combineReducers","isShallowEqual","ifMatchingAction","replaceAction","reducer","queriedDataReducer","defaultEntities","DEFAULT_ENTITY_KEY","terms","state","action","type","taxonomy","users","byId","queries","queryID","user","id","currentUser","taxonomies","currentTheme","undefined","stylesheet","themes","themeSupports","entity","entityConfig","name","kind","key","queriedData","edits","context","query","nextState","record","items","recordId","nextEdits","Object","keys","reduce","acc","persistedEdits","length","forEach","saving","pending","error","isAutosave","deleting","entitiesConfig","entities","newConfig","config","entitiesDataReducer","entitiesByKind","entries","memo","subEntities","kindReducer","kindMemo","newData","data","UNDO_INITIAL_STATE","offset","lastEditAction","undo","isCreateUndoLevel","isUndoOrRedo","meta","isUndo","isRedo","some","transientEdits","flattenedUndo","slice","pop","push","comparisonUndoEdits","values","filter","edit","comparisonEdits","embedPreviews","url","preview","userPermissions","isAllowed","autosaves","postId","autosavesData"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,KAAT,EAAgBC,GAAhB,EAAqBC,OAArB,EAA8BC,SAA9B,EAAyCC,OAAzC,EAAkDC,GAAlD,QAA6D,QAA7D;AAEA;AACA;AACA;;AACA,SAASC,eAAT,QAAgC,iBAAhC;AACA,OAAOC,cAAP,MAA2B,6BAA3B;AAEA;AACA;AACA;;AACA,SAASC,gBAAT,EAA2BC,aAA3B,QAAgD,SAAhD;AACA,SAASC,OAAO,IAAIC,kBAApB,QAA8C,gBAA9C;AACA,SAASC,eAAT,EAA0BC,kBAA1B,QAAoD,YAApD;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,KAAT,CAAgBC,KAAK,GAAG,EAAxB,EAA4BC,MAA5B,EAAqC;AAC3C,UAASA,MAAM,CAACC,IAAhB;AACC,SAAK,eAAL;AACC,aAAO,EACN,GAAGF,KADG;AAEN,SAAEC,MAAM,CAACE,QAAT,GAAqBF,MAAM,CAACF;AAFtB,OAAP;AAFF;;AAQA,SAAOC,KAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASI,KAAT,CAAgBJ,KAAK,GAAG;AAAEK,EAAAA,IAAI,EAAE,EAAR;AAAYC,EAAAA,OAAO,EAAE;AAArB,CAAxB,EAAmDL,MAAnD,EAA4D;AAClE,UAASA,MAAM,CAACC,IAAhB;AACC,SAAK,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AAA,UAL+B;AAM/BI,EAAAA,MAN+B;AAO/BC,EAAAA,aAP+B;AAQ/B4B,EAAAA,QAR+B;AAS/Be,EAAAA,IAT+B;AAU/BiB,EAAAA,aAV+B;AAW/BG,EAAAA,eAX+B;AAY/BE,EAAAA;AAZ+B,CAAF,CAA9B","sourcesContent":["/**\n * External dependencies\n */\nimport { keyBy, map, groupBy, flowRight, isEqual, get } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { combineReducers } from '@wordpress/data';\nimport isShallowEqual from '@wordpress/is-shallow-equal';\n\n/**\n * Internal dependencies\n */\nimport { ifMatchingAction, replaceAction } from './utils';\nimport { reducer as queriedDataReducer } from './queried-data';\nimport { defaultEntities, DEFAULT_ENTITY_KEY } from './entities';\n\n/**\n * Reducer managing terms state. Keyed by taxonomy slug, the value is either\n * undefined (if no request has been made for given taxonomy), null (if a\n * request is in-flight for given taxonomy), or the array of terms for the\n * taxonomy.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function terms( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_TERMS':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.taxonomy ]: action.terms,\n\t\t\t};\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer managing authors state. Keyed by id.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function users( state = { byId: {}, queries: {} }, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_USER_QUERY':\n\t\t\treturn {\n\t\t\t\tbyId: {\n\t\t\t\t\t...state.byId,\n\t\t\t\t\t...keyBy( action.users, 'id' ),\n\t\t\t\t},\n\t\t\t\tqueries: {\n\t\t\t\t\t...state.queries,\n\t\t\t\t\t[ action.queryID ]: map(\n\t\t\t\t\t\taction.users,\n\t\t\t\t\t\t( user ) => user.id\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t};\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer managing current user state.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function currentUser( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_CURRENT_USER':\n\t\t\treturn action.currentUser;\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer managing taxonomies.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function taxonomies( state = [], action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_TAXONOMIES':\n\t\t\treturn action.taxonomies;\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer managing the current theme.\n *\n * @param {string} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {string} Updated state.\n */\nexport function currentTheme( state = undefined, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_CURRENT_THEME':\n\t\t\treturn action.currentTheme.stylesheet;\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer managing installed themes.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function themes( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_CURRENT_THEME':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.currentTheme.stylesheet ]: action.currentTheme,\n\t\t\t};\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer managing theme supports data.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function themeSupports( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_THEME_SUPPORTS':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t...action.themeSupports,\n\t\t\t};\n\t}\n\n\treturn state;\n}\n\n/**\n * Higher Order Reducer for a given entity config. It supports:\n *\n * - Fetching\n * - Editing\n * - Saving\n *\n * @param {Object} entityConfig Entity config.\n *\n * @return {Function} Reducer.\n */\nfunction entity( entityConfig ) {\n\treturn flowRight( [\n\t\t// Limit to matching action type so we don't attempt to replace action on\n\t\t// an unhandled action.\n\t\tifMatchingAction(\n\t\t\t( action ) =>\n\t\t\t\taction.name &&\n\t\t\t\taction.kind &&\n\t\t\t\taction.name === entityConfig.name &&\n\t\t\t\taction.kind === entityConfig.kind\n\t\t),\n\n\t\t// Inject the entity config into the action.\n\t\treplaceAction( ( action ) => {\n\t\t\treturn {\n\t\t\t\t...action,\n\t\t\t\tkey: entityConfig.key || DEFAULT_ENTITY_KEY,\n\t\t\t};\n\t\t} ),\n\t] )(\n\t\tcombineReducers( {\n\t\t\tqueriedData: queriedDataReducer,\n\n\t\t\tedits: ( state = {}, action ) => {\n\t\t\t\tswitch ( action.type ) {\n\t\t\t\t\tcase 'RECEIVE_ITEMS':\n\t\t\t\t\t\tconst context = action?.query?.context ?? 'default';\n\t\t\t\t\t\tif ( context !== 'default' ) {\n\t\t\t\t\t\t\treturn state;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst nextState = { ...state };\n\n\t\t\t\t\t\tfor ( const record of action.items ) {\n\t\t\t\t\t\t\tconst recordId = record[ action.key ];\n\t\t\t\t\t\t\tconst edits = nextState[ recordId ];\n\t\t\t\t\t\t\tif ( ! edits ) {\n\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tconst nextEdits = Object.keys( edits ).reduce(\n\t\t\t\t\t\t\t\t( acc, key ) => {\n\t\t\t\t\t\t\t\t\t// If the edited value is still different to the persisted value,\n\t\t\t\t\t\t\t\t\t// keep the edited value in edits.\n\t\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t\t// Edits are the \"raw\" attribute values, but records may have\n\t\t\t\t\t\t\t\t\t\t// objects with more properties, so we use `get` here for the\n\t\t\t\t\t\t\t\t\t\t// comparison.\n\t\t\t\t\t\t\t\t\t\t! isEqual(\n\t\t\t\t\t\t\t\t\t\t\tedits[ key ],\n\t\t\t\t\t\t\t\t\t\t\tget(\n\t\t\t\t\t\t\t\t\t\t\t\trecord[ key ],\n\t\t\t\t\t\t\t\t\t\t\t\t'raw',\n\t\t\t\t\t\t\t\t\t\t\t\trecord[ key ]\n\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t) &&\n\t\t\t\t\t\t\t\t\t\t// Sometimes the server alters the sent value which means\n\t\t\t\t\t\t\t\t\t\t// we need to also remove the edits before the api request.\n\t\t\t\t\t\t\t\t\t\t( ! action.persistedEdits ||\n\t\t\t\t\t\t\t\t\t\t\t! isEqual(\n\t\t\t\t\t\t\t\t\t\t\t\tedits[ key ],\n\t\t\t\t\t\t\t\t\t\t\t\taction.persistedEdits[ key ]\n\t\t\t\t\t\t\t\t\t\t\t) )\n\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\tacc[ key ] = edits[ key ];\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\treturn acc;\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t{}\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\tif ( Object.keys( nextEdits ).length ) {\n\t\t\t\t\t\t\t\tnextState[ recordId ] = nextEdits;\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tdelete nextState[ recordId ];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn nextState;\n\n\t\t\t\t\tcase 'EDIT_ENTITY_RECORD':\n\t\t\t\t\t\tconst nextEdits = {\n\t\t\t\t\t\t\t...state[ action.recordId ],\n\t\t\t\t\t\t\t...action.edits,\n\t\t\t\t\t\t};\n\t\t\t\t\t\tObject.keys( nextEdits ).forEach( ( key ) => {\n\t\t\t\t\t\t\t// Delete cleared edits so that the properties\n\t\t\t\t\t\t\t// are not considered dirty.\n\t\t\t\t\t\t\tif ( nextEdits[ key ] === undefined ) {\n\t\t\t\t\t\t\t\tdelete nextEdits[ key ];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} );\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t...state,\n\t\t\t\t\t\t\t[ action.recordId ]: nextEdits,\n\t\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\treturn state;\n\t\t\t},\n\n\t\t\tsaving: ( state = {}, action ) => {\n\t\t\t\tswitch ( action.type ) {\n\t\t\t\t\tcase 'SAVE_ENTITY_RECORD_START':\n\t\t\t\t\tcase 'SAVE_ENTITY_RECORD_FINISH':\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t...state,\n\t\t\t\t\t\t\t[ action.recordId ]: {\n\t\t\t\t\t\t\t\tpending:\n\t\t\t\t\t\t\t\t\taction.type === 'SAVE_ENTITY_RECORD_START',\n\t\t\t\t\t\t\t\terror: action.error,\n\t\t\t\t\t\t\t\tisAutosave: action.isAutosave,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\treturn state;\n\t\t\t},\n\n\t\t\tdeleting: ( state = {}, action ) => {\n\t\t\t\tswitch ( action.type ) {\n\t\t\t\t\tcase 'DELETE_ENTITY_RECORD_START':\n\t\t\t\t\tcase 'DELETE_ENTITY_RECORD_FINISH':\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t...state,\n\t\t\t\t\t\t\t[ action.recordId ]: {\n\t\t\t\t\t\t\t\tpending:\n\t\t\t\t\t\t\t\t\taction.type ===\n\t\t\t\t\t\t\t\t\t'DELETE_ENTITY_RECORD_START',\n\t\t\t\t\t\t\t\terror: action.error,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\treturn state;\n\t\t\t},\n\t\t} )\n\t);\n}\n\n/**\n * Reducer keeping track of the registered entities.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function entitiesConfig( state = defaultEntities, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'ADD_ENTITIES':\n\t\t\treturn [ ...state, ...action.entities ];\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer keeping track of the registered entities config and data.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport const entities = ( state = {}, action ) => {\n\tconst newConfig = entitiesConfig( state.config, action );\n\n\t// Generates a dynamic reducer for the entities\n\tlet entitiesDataReducer = state.reducer;\n\tif ( ! entitiesDataReducer || newConfig !== state.config ) {\n\t\tconst entitiesByKind = groupBy( newConfig, 'kind' );\n\t\tentitiesDataReducer = combineReducers(\n\t\t\tObject.entries( entitiesByKind ).reduce(\n\t\t\t\t( memo, [ kind, subEntities ] ) => {\n\t\t\t\t\tconst kindReducer = combineReducers(\n\t\t\t\t\t\tsubEntities.reduce(\n\t\t\t\t\t\t\t( kindMemo, entityConfig ) => ( {\n\t\t\t\t\t\t\t\t...kindMemo,\n\t\t\t\t\t\t\t\t[ entityConfig.name ]: entity( entityConfig ),\n\t\t\t\t\t\t\t} ),\n\t\t\t\t\t\t\t{}\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\n\t\t\t\t\tmemo[ kind ] = kindReducer;\n\t\t\t\t\treturn memo;\n\t\t\t\t},\n\t\t\t\t{}\n\t\t\t)\n\t\t);\n\t}\n\n\tconst newData = entitiesDataReducer( state.data, action );\n\n\tif (\n\t\tnewData === state.data &&\n\t\tnewConfig === state.config &&\n\t\tentitiesDataReducer === state.reducer\n\t) {\n\t\treturn state;\n\t}\n\n\treturn {\n\t\treducer: entitiesDataReducer,\n\t\tdata: newData,\n\t\tconfig: newConfig,\n\t};\n};\n\n/**\n * Reducer keeping track of entity edit undo history.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nconst UNDO_INITIAL_STATE = [];\nUNDO_INITIAL_STATE.offset = 0;\nlet lastEditAction;\nexport function undo( state = UNDO_INITIAL_STATE, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'EDIT_ENTITY_RECORD':\n\t\tcase 'CREATE_UNDO_LEVEL':\n\t\t\tlet isCreateUndoLevel = action.type === 'CREATE_UNDO_LEVEL';\n\t\t\tconst isUndoOrRedo =\n\t\t\t\t! isCreateUndoLevel &&\n\t\t\t\t( action.meta.isUndo || action.meta.isRedo );\n\t\t\tif ( isCreateUndoLevel ) {\n\t\t\t\taction = lastEditAction;\n\t\t\t} else if ( ! isUndoOrRedo ) {\n\t\t\t\t// Don't lose the last edit cache if the new one only has transient edits.\n\t\t\t\t// Transient edits don't create new levels so updating the cache would make\n\t\t\t\t// us skip an edit later when creating levels explicitly.\n\t\t\t\tif (\n\t\t\t\t\tObject.keys( action.edits ).some(\n\t\t\t\t\t\t( key ) => ! action.transientEdits[ key ]\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\tlastEditAction = action;\n\t\t\t\t} else {\n\t\t\t\t\tlastEditAction = {\n\t\t\t\t\t\t...action,\n\t\t\t\t\t\tedits: {\n\t\t\t\t\t\t\t...( lastEditAction && lastEditAction.edits ),\n\t\t\t\t\t\t\t...action.edits,\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlet nextState;\n\t\t\tif ( isUndoOrRedo ) {\n\t\t\t\tnextState = [ ...state ];\n\t\t\t\tnextState.offset =\n\t\t\t\t\tstate.offset + ( action.meta.isUndo ? -1 : 1 );\n\n\t\t\t\tif ( state.flattenedUndo ) {\n\t\t\t\t\t// The first undo in a sequence of undos might happen while we have\n\t\t\t\t\t// flattened undos in state. If this is the case, we want execution\n\t\t\t\t\t// to continue as if we were creating an explicit undo level. This\n\t\t\t\t\t// will result in an extra undo level being appended with the flattened\n\t\t\t\t\t// undo values.\n\t\t\t\t\tisCreateUndoLevel = true;\n\t\t\t\t\taction = lastEditAction;\n\t\t\t\t} else {\n\t\t\t\t\treturn nextState;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif ( ! action.meta.undo ) {\n\t\t\t\treturn state;\n\t\t\t}\n\n\t\t\t// Transient edits don't create an undo level, but are\n\t\t\t// reachable in the next meaningful edit to which they\n\t\t\t// are merged. They are defined in the entity's config.\n\t\t\tif (\n\t\t\t\t! isCreateUndoLevel &&\n\t\t\t\t! Object.keys( action.edits ).some(\n\t\t\t\t\t( key ) => ! action.transientEdits[ key ]\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\tnextState = [ ...state ];\n\t\t\t\tnextState.flattenedUndo = {\n\t\t\t\t\t...state.flattenedUndo,\n\t\t\t\t\t...action.edits,\n\t\t\t\t};\n\t\t\t\tnextState.offset = state.offset;\n\t\t\t\treturn nextState;\n\t\t\t}\n\n\t\t\t// Clear potential redos, because this only supports linear history.\n\t\t\tnextState =\n\t\t\t\tnextState || state.slice( 0, state.offset || undefined );\n\t\t\tnextState.offset = nextState.offset || 0;\n\t\t\tnextState.pop();\n\t\t\tif ( ! isCreateUndoLevel ) {\n\t\t\t\tnextState.push( {\n\t\t\t\t\tkind: action.meta.undo.kind,\n\t\t\t\t\tname: action.meta.undo.name,\n\t\t\t\t\trecordId: action.meta.undo.recordId,\n\t\t\t\t\tedits: {\n\t\t\t\t\t\t...state.flattenedUndo,\n\t\t\t\t\t\t...action.meta.undo.edits,\n\t\t\t\t\t},\n\t\t\t\t} );\n\t\t\t}\n\t\t\t// When an edit is a function it's an optimization to avoid running some expensive operation.\n\t\t\t// We can't rely on the function references being the same so we opt out of comparing them here.\n\t\t\tconst comparisonUndoEdits = Object.values(\n\t\t\t\taction.meta.undo.edits\n\t\t\t).filter( ( edit ) => typeof edit !== 'function' );\n\t\t\tconst comparisonEdits = Object.values( action.edits ).filter(\n\t\t\t\t( edit ) => typeof edit !== 'function'\n\t\t\t);\n\t\t\tif ( ! isShallowEqual( comparisonUndoEdits, comparisonEdits ) ) {\n\t\t\t\tnextState.push( {\n\t\t\t\t\tkind: action.kind,\n\t\t\t\t\tname: action.name,\n\t\t\t\t\trecordId: action.recordId,\n\t\t\t\t\tedits: isCreateUndoLevel\n\t\t\t\t\t\t? { ...state.flattenedUndo, ...action.edits }\n\t\t\t\t\t\t: action.edits,\n\t\t\t\t} );\n\t\t\t}\n\t\t\treturn nextState;\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer managing embed preview data.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function embedPreviews( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_EMBED_PREVIEW':\n\t\t\tconst { url, preview } = action;\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ url ]: preview,\n\t\t\t};\n\t}\n\treturn state;\n}\n\n/**\n * State which tracks whether the user can perform an action on a REST\n * resource.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function userPermissions( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_USER_PERMISSION':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.key ]: action.isAllowed,\n\t\t\t};\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer returning autosaves keyed by their parent's post id.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function autosaves( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_AUTOSAVES':\n\t\t\tconst { postId, autosaves: autosavesData } = action;\n\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ postId ]: autosavesData,\n\t\t\t};\n\t}\n\n\treturn state;\n}\n\nexport default combineReducers( {\n\tterms,\n\tusers,\n\tcurrentTheme,\n\tcurrentUser,\n\ttaxonomies,\n\tthemes,\n\tthemeSupports,\n\tentities,\n\tundo,\n\tembedPreviews,\n\tuserPermissions,\n\tautosaves,\n} );\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/core-data/src/reducer.js"],"names":["keyBy","map","groupBy","flowRight","isEqual","get","combineReducers","isShallowEqual","ifMatchingAction","replaceAction","reducer","queriedDataReducer","defaultEntities","DEFAULT_ENTITY_KEY","terms","state","action","type","taxonomy","users","byId","queries","queryID","user","id","currentUser","taxonomies","currentTheme","undefined","stylesheet","currentGlobalStylesId","themeBaseGlobalStyles","globalStyles","entity","entityConfig","name","kind","key","queriedData","edits","context","query","nextState","record","items","recordId","nextEdits","Object","keys","reduce","acc","persistedEdits","length","forEach","saving","pending","error","isAutosave","deleting","entitiesConfig","entities","newConfig","config","entitiesDataReducer","entitiesByKind","entries","memo","subEntities","kindReducer","kindMemo","newData","data","UNDO_INITIAL_STATE","offset","lastEditAction","undo","isCreateUndoLevel","isUndoOrRedo","meta","isUndo","isRedo","some","transientEdits","flattenedUndo","slice","pop","push","comparisonUndoEdits","values","filter","edit","comparisonEdits","embedPreviews","url","preview","userPermissions","isAllowed","autosaves","postId","autosavesData"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,KAAT,EAAgBC,GAAhB,EAAqBC,OAArB,EAA8BC,SAA9B,EAAyCC,OAAzC,EAAkDC,GAAlD,QAA6D,QAA7D;AAEA;AACA;AACA;;AACA,SAASC,eAAT,QAAgC,iBAAhC;AACA,OAAOC,cAAP,MAA2B,6BAA3B;AAEA;AACA;AACA;;AACA,SAASC,gBAAT,EAA2BC,aAA3B,QAAgD,SAAhD;AACA,SAASC,OAAO,IAAIC,kBAApB,QAA8C,gBAA9C;AACA,SAASC,eAAT,EAA0BC,kBAA1B,QAAoD,YAApD;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,KAAT,CAAgBC,KAAK,GAAG,EAAxB,EAA4BC,MAA5B,EAAqC;AAC3C,UAASA,MAAM,CAACC,IAAhB;AACC,SAAK,eAAL;AACC,aAAO,EACN,GAAGF,KADG;AAEN,SAAEC,MAAM,CAACE,QAAT,GAAqBF,MAAM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,aAAO,EACN,GAAGD,KADG;AAEN,SAAEmF,MAAF,GAAYC;AAFN,OAAP;AAJF;;AAUA,SAAOpF,KAAP;AACA;AAED,eAAeT,eAAe,CAAE;AAC/BQ,EAAAA,KAD+B;AAE/BK,EAAAA,KAF+B;AAG/BQ,EAAAA,YAH+B;AAI/BG,EAAAA,qBAJ+B;AAK/BL,EAAAA,WAL+B;AAM/BM,EAAAA,qBAN+B;AAO/BL,EAAAA,UAP+B;AAQ/BkC,EAAAA,QAR+B;AAS/Be,EAAAA,IAT+B;AAU/BiB,EAAAA,aAV+B;AAW/BG,EAAAA,eAX+B;AAY/BE,EAAAA;AAZ+B,CAAF,CAA9B","sourcesContent":["/**\n * External dependencies\n */\nimport { keyBy, map, groupBy, flowRight, isEqual, get } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { combineReducers } from '@wordpress/data';\nimport isShallowEqual from '@wordpress/is-shallow-equal';\n\n/**\n * Internal dependencies\n */\nimport { ifMatchingAction, replaceAction } from './utils';\nimport { reducer as queriedDataReducer } from './queried-data';\nimport { defaultEntities, DEFAULT_ENTITY_KEY } from './entities';\n\n/**\n * Reducer managing terms state. Keyed by taxonomy slug, the value is either\n * undefined (if no request has been made for given taxonomy), null (if a\n * request is in-flight for given taxonomy), or the array of terms for the\n * taxonomy.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function terms( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_TERMS':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.taxonomy ]: action.terms,\n\t\t\t};\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer managing authors state. Keyed by id.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function users( state = { byId: {}, queries: {} }, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_USER_QUERY':\n\t\t\treturn {\n\t\t\t\tbyId: {\n\t\t\t\t\t...state.byId,\n\t\t\t\t\t...keyBy( action.users, 'id' ),\n\t\t\t\t},\n\t\t\t\tqueries: {\n\t\t\t\t\t...state.queries,\n\t\t\t\t\t[ action.queryID ]: map(\n\t\t\t\t\t\taction.users,\n\t\t\t\t\t\t( user ) => user.id\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t};\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer managing current user state.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function currentUser( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_CURRENT_USER':\n\t\t\treturn action.currentUser;\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer managing taxonomies.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function taxonomies( state = [], action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_TAXONOMIES':\n\t\t\treturn action.taxonomies;\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer managing the current theme.\n *\n * @param {string} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {string} Updated state.\n */\nexport function currentTheme( state = undefined, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_CURRENT_THEME':\n\t\t\treturn action.currentTheme.stylesheet;\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer managing the current global styles id.\n *\n * @param {string} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {string} Updated state.\n */\nexport function currentGlobalStylesId( state = undefined, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_CURRENT_GLOBAL_STYLES_ID':\n\t\t\treturn action.id;\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer managing the theme base global styles.\n *\n * @param {string} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {string} Updated state.\n */\nexport function themeBaseGlobalStyles( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_THEME_GLOBAL_STYLES':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.stylesheet ]: action.globalStyles,\n\t\t\t};\n\t}\n\n\treturn state;\n}\n\n/**\n * Higher Order Reducer for a given entity config. It supports:\n *\n * - Fetching\n * - Editing\n * - Saving\n *\n * @param {Object} entityConfig Entity config.\n *\n * @return {Function} Reducer.\n */\nfunction entity( entityConfig ) {\n\treturn flowRight( [\n\t\t// Limit to matching action type so we don't attempt to replace action on\n\t\t// an unhandled action.\n\t\tifMatchingAction(\n\t\t\t( action ) =>\n\t\t\t\taction.name &&\n\t\t\t\taction.kind &&\n\t\t\t\taction.name === entityConfig.name &&\n\t\t\t\taction.kind === entityConfig.kind\n\t\t),\n\n\t\t// Inject the entity config into the action.\n\t\treplaceAction( ( action ) => {\n\t\t\treturn {\n\t\t\t\t...action,\n\t\t\t\tkey: entityConfig.key || DEFAULT_ENTITY_KEY,\n\t\t\t};\n\t\t} ),\n\t] )(\n\t\tcombineReducers( {\n\t\t\tqueriedData: queriedDataReducer,\n\n\t\t\tedits: ( state = {}, action ) => {\n\t\t\t\tswitch ( action.type ) {\n\t\t\t\t\tcase 'RECEIVE_ITEMS':\n\t\t\t\t\t\tconst context = action?.query?.context ?? 'default';\n\t\t\t\t\t\tif ( context !== 'default' ) {\n\t\t\t\t\t\t\treturn state;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst nextState = { ...state };\n\n\t\t\t\t\t\tfor ( const record of action.items ) {\n\t\t\t\t\t\t\tconst recordId = record[ action.key ];\n\t\t\t\t\t\t\tconst edits = nextState[ recordId ];\n\t\t\t\t\t\t\tif ( ! edits ) {\n\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tconst nextEdits = Object.keys( edits ).reduce(\n\t\t\t\t\t\t\t\t( acc, key ) => {\n\t\t\t\t\t\t\t\t\t// If the edited value is still different to the persisted value,\n\t\t\t\t\t\t\t\t\t// keep the edited value in edits.\n\t\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t\t// Edits are the \"raw\" attribute values, but records may have\n\t\t\t\t\t\t\t\t\t\t// objects with more properties, so we use `get` here for the\n\t\t\t\t\t\t\t\t\t\t// comparison.\n\t\t\t\t\t\t\t\t\t\t! isEqual(\n\t\t\t\t\t\t\t\t\t\t\tedits[ key ],\n\t\t\t\t\t\t\t\t\t\t\tget(\n\t\t\t\t\t\t\t\t\t\t\t\trecord[ key ],\n\t\t\t\t\t\t\t\t\t\t\t\t'raw',\n\t\t\t\t\t\t\t\t\t\t\t\trecord[ key ]\n\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t) &&\n\t\t\t\t\t\t\t\t\t\t// Sometimes the server alters the sent value which means\n\t\t\t\t\t\t\t\t\t\t// we need to also remove the edits before the api request.\n\t\t\t\t\t\t\t\t\t\t( ! action.persistedEdits ||\n\t\t\t\t\t\t\t\t\t\t\t! isEqual(\n\t\t\t\t\t\t\t\t\t\t\t\tedits[ key ],\n\t\t\t\t\t\t\t\t\t\t\t\taction.persistedEdits[ key ]\n\t\t\t\t\t\t\t\t\t\t\t) )\n\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\tacc[ key ] = edits[ key ];\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\treturn acc;\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t{}\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\tif ( Object.keys( nextEdits ).length ) {\n\t\t\t\t\t\t\t\tnextState[ recordId ] = nextEdits;\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tdelete nextState[ recordId ];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn nextState;\n\n\t\t\t\t\tcase 'EDIT_ENTITY_RECORD':\n\t\t\t\t\t\tconst nextEdits = {\n\t\t\t\t\t\t\t...state[ action.recordId ],\n\t\t\t\t\t\t\t...action.edits,\n\t\t\t\t\t\t};\n\t\t\t\t\t\tObject.keys( nextEdits ).forEach( ( key ) => {\n\t\t\t\t\t\t\t// Delete cleared edits so that the properties\n\t\t\t\t\t\t\t// are not considered dirty.\n\t\t\t\t\t\t\tif ( nextEdits[ key ] === undefined ) {\n\t\t\t\t\t\t\t\tdelete nextEdits[ key ];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} );\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t...state,\n\t\t\t\t\t\t\t[ action.recordId ]: nextEdits,\n\t\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\treturn state;\n\t\t\t},\n\n\t\t\tsaving: ( state = {}, action ) => {\n\t\t\t\tswitch ( action.type ) {\n\t\t\t\t\tcase 'SAVE_ENTITY_RECORD_START':\n\t\t\t\t\tcase 'SAVE_ENTITY_RECORD_FINISH':\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t...state,\n\t\t\t\t\t\t\t[ action.recordId ]: {\n\t\t\t\t\t\t\t\tpending:\n\t\t\t\t\t\t\t\t\taction.type === 'SAVE_ENTITY_RECORD_START',\n\t\t\t\t\t\t\t\terror: action.error,\n\t\t\t\t\t\t\t\tisAutosave: action.isAutosave,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\treturn state;\n\t\t\t},\n\n\t\t\tdeleting: ( state = {}, action ) => {\n\t\t\t\tswitch ( action.type ) {\n\t\t\t\t\tcase 'DELETE_ENTITY_RECORD_START':\n\t\t\t\t\tcase 'DELETE_ENTITY_RECORD_FINISH':\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t...state,\n\t\t\t\t\t\t\t[ action.recordId ]: {\n\t\t\t\t\t\t\t\tpending:\n\t\t\t\t\t\t\t\t\taction.type ===\n\t\t\t\t\t\t\t\t\t'DELETE_ENTITY_RECORD_START',\n\t\t\t\t\t\t\t\terror: action.error,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\treturn state;\n\t\t\t},\n\t\t} )\n\t);\n}\n\n/**\n * Reducer keeping track of the registered entities.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function entitiesConfig( state = defaultEntities, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'ADD_ENTITIES':\n\t\t\treturn [ ...state, ...action.entities ];\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer keeping track of the registered entities config and data.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport const entities = ( state = {}, action ) => {\n\tconst newConfig = entitiesConfig( state.config, action );\n\n\t// Generates a dynamic reducer for the entities\n\tlet entitiesDataReducer = state.reducer;\n\tif ( ! entitiesDataReducer || newConfig !== state.config ) {\n\t\tconst entitiesByKind = groupBy( newConfig, 'kind' );\n\t\tentitiesDataReducer = combineReducers(\n\t\t\tObject.entries( entitiesByKind ).reduce(\n\t\t\t\t( memo, [ kind, subEntities ] ) => {\n\t\t\t\t\tconst kindReducer = combineReducers(\n\t\t\t\t\t\tsubEntities.reduce(\n\t\t\t\t\t\t\t( kindMemo, entityConfig ) => ( {\n\t\t\t\t\t\t\t\t...kindMemo,\n\t\t\t\t\t\t\t\t[ entityConfig.name ]: entity( entityConfig ),\n\t\t\t\t\t\t\t} ),\n\t\t\t\t\t\t\t{}\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\n\t\t\t\t\tmemo[ kind ] = kindReducer;\n\t\t\t\t\treturn memo;\n\t\t\t\t},\n\t\t\t\t{}\n\t\t\t)\n\t\t);\n\t}\n\n\tconst newData = entitiesDataReducer( state.data, action );\n\n\tif (\n\t\tnewData === state.data &&\n\t\tnewConfig === state.config &&\n\t\tentitiesDataReducer === state.reducer\n\t) {\n\t\treturn state;\n\t}\n\n\treturn {\n\t\treducer: entitiesDataReducer,\n\t\tdata: newData,\n\t\tconfig: newConfig,\n\t};\n};\n\n/**\n * Reducer keeping track of entity edit undo history.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nconst UNDO_INITIAL_STATE = [];\nUNDO_INITIAL_STATE.offset = 0;\nlet lastEditAction;\nexport function undo( state = UNDO_INITIAL_STATE, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'EDIT_ENTITY_RECORD':\n\t\tcase 'CREATE_UNDO_LEVEL':\n\t\t\tlet isCreateUndoLevel = action.type === 'CREATE_UNDO_LEVEL';\n\t\t\tconst isUndoOrRedo =\n\t\t\t\t! isCreateUndoLevel &&\n\t\t\t\t( action.meta.isUndo || action.meta.isRedo );\n\t\t\tif ( isCreateUndoLevel ) {\n\t\t\t\taction = lastEditAction;\n\t\t\t} else if ( ! isUndoOrRedo ) {\n\t\t\t\t// Don't lose the last edit cache if the new one only has transient edits.\n\t\t\t\t// Transient edits don't create new levels so updating the cache would make\n\t\t\t\t// us skip an edit later when creating levels explicitly.\n\t\t\t\tif (\n\t\t\t\t\tObject.keys( action.edits ).some(\n\t\t\t\t\t\t( key ) => ! action.transientEdits[ key ]\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\tlastEditAction = action;\n\t\t\t\t} else {\n\t\t\t\t\tlastEditAction = {\n\t\t\t\t\t\t...action,\n\t\t\t\t\t\tedits: {\n\t\t\t\t\t\t\t...( lastEditAction && lastEditAction.edits ),\n\t\t\t\t\t\t\t...action.edits,\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlet nextState;\n\t\t\tif ( isUndoOrRedo ) {\n\t\t\t\tnextState = [ ...state ];\n\t\t\t\tnextState.offset =\n\t\t\t\t\tstate.offset + ( action.meta.isUndo ? -1 : 1 );\n\n\t\t\t\tif ( state.flattenedUndo ) {\n\t\t\t\t\t// The first undo in a sequence of undos might happen while we have\n\t\t\t\t\t// flattened undos in state. If this is the case, we want execution\n\t\t\t\t\t// to continue as if we were creating an explicit undo level. This\n\t\t\t\t\t// will result in an extra undo level being appended with the flattened\n\t\t\t\t\t// undo values.\n\t\t\t\t\tisCreateUndoLevel = true;\n\t\t\t\t\taction = lastEditAction;\n\t\t\t\t} else {\n\t\t\t\t\treturn nextState;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif ( ! action.meta.undo ) {\n\t\t\t\treturn state;\n\t\t\t}\n\n\t\t\t// Transient edits don't create an undo level, but are\n\t\t\t// reachable in the next meaningful edit to which they\n\t\t\t// are merged. They are defined in the entity's config.\n\t\t\tif (\n\t\t\t\t! isCreateUndoLevel &&\n\t\t\t\t! Object.keys( action.edits ).some(\n\t\t\t\t\t( key ) => ! action.transientEdits[ key ]\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\tnextState = [ ...state ];\n\t\t\t\tnextState.flattenedUndo = {\n\t\t\t\t\t...state.flattenedUndo,\n\t\t\t\t\t...action.edits,\n\t\t\t\t};\n\t\t\t\tnextState.offset = state.offset;\n\t\t\t\treturn nextState;\n\t\t\t}\n\n\t\t\t// Clear potential redos, because this only supports linear history.\n\t\t\tnextState =\n\t\t\t\tnextState || state.slice( 0, state.offset || undefined );\n\t\t\tnextState.offset = nextState.offset || 0;\n\t\t\tnextState.pop();\n\t\t\tif ( ! isCreateUndoLevel ) {\n\t\t\t\tnextState.push( {\n\t\t\t\t\tkind: action.meta.undo.kind,\n\t\t\t\t\tname: action.meta.undo.name,\n\t\t\t\t\trecordId: action.meta.undo.recordId,\n\t\t\t\t\tedits: {\n\t\t\t\t\t\t...state.flattenedUndo,\n\t\t\t\t\t\t...action.meta.undo.edits,\n\t\t\t\t\t},\n\t\t\t\t} );\n\t\t\t}\n\t\t\t// When an edit is a function it's an optimization to avoid running some expensive operation.\n\t\t\t// We can't rely on the function references being the same so we opt out of comparing them here.\n\t\t\tconst comparisonUndoEdits = Object.values(\n\t\t\t\taction.meta.undo.edits\n\t\t\t).filter( ( edit ) => typeof edit !== 'function' );\n\t\t\tconst comparisonEdits = Object.values( action.edits ).filter(\n\t\t\t\t( edit ) => typeof edit !== 'function'\n\t\t\t);\n\t\t\tif ( ! isShallowEqual( comparisonUndoEdits, comparisonEdits ) ) {\n\t\t\t\tnextState.push( {\n\t\t\t\t\tkind: action.kind,\n\t\t\t\t\tname: action.name,\n\t\t\t\t\trecordId: action.recordId,\n\t\t\t\t\tedits: isCreateUndoLevel\n\t\t\t\t\t\t? { ...state.flattenedUndo, ...action.edits }\n\t\t\t\t\t\t: action.edits,\n\t\t\t\t} );\n\t\t\t}\n\t\t\treturn nextState;\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer managing embed preview data.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function embedPreviews( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_EMBED_PREVIEW':\n\t\t\tconst { url, preview } = action;\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ url ]: preview,\n\t\t\t};\n\t}\n\treturn state;\n}\n\n/**\n * State which tracks whether the user can perform an action on a REST\n * resource.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function userPermissions( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_USER_PERMISSION':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.key ]: action.isAllowed,\n\t\t\t};\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer returning autosaves keyed by their parent's post id.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function autosaves( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_AUTOSAVES':\n\t\t\tconst { postId, autosaves: autosavesData } = action;\n\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ postId ]: autosavesData,\n\t\t\t};\n\t}\n\n\treturn state;\n}\n\nexport default combineReducers( {\n\tterms,\n\tusers,\n\tcurrentTheme,\n\tcurrentGlobalStylesId,\n\tcurrentUser,\n\tthemeBaseGlobalStyles,\n\ttaxonomies,\n\tentities,\n\tundo,\n\tembedPreviews,\n\tuserPermissions,\n\tautosaves,\n} );\n"]}
|
|
@@ -7,18 +7,14 @@ import { find, includes, get, hasIn, compact, uniq } from 'lodash';
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import { addQueryArgs } from '@wordpress/url';
|
|
10
|
-
import
|
|
10
|
+
import apiFetch from '@wordpress/api-fetch';
|
|
11
11
|
/**
|
|
12
12
|
* Internal dependencies
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
import { STORE_NAME } from './name';
|
|
16
|
-
/**
|
|
17
|
-
* Internal dependencies
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
16
|
import { getKindEntities, DEFAULT_ENTITY_KEY } from './entities';
|
|
21
|
-
import {
|
|
17
|
+
import { forwardResolver, getNormalizedCommaSeparable } from './utils';
|
|
22
18
|
/**
|
|
23
19
|
* Requests authors from the REST API.
|
|
24
20
|
*
|
|
@@ -30,7 +26,7 @@ export const getAuthors = query => async ({
|
|
|
30
26
|
dispatch
|
|
31
27
|
}) => {
|
|
32
28
|
const path = addQueryArgs('/wp/v2/users/?who=authors&per_page=100', query);
|
|
33
|
-
const users = await
|
|
29
|
+
const users = await apiFetch({
|
|
34
30
|
path
|
|
35
31
|
});
|
|
36
32
|
dispatch.receiveUserQuery(path, users);
|
|
@@ -42,7 +38,7 @@ export const getAuthors = query => async ({
|
|
|
42
38
|
export const getCurrentUser = () => async ({
|
|
43
39
|
dispatch
|
|
44
40
|
}) => {
|
|
45
|
-
const currentUser = await
|
|
41
|
+
const currentUser = await apiFetch({
|
|
46
42
|
path: '/wp/v2/users/me'
|
|
47
43
|
});
|
|
48
44
|
dispatch.receiveCurrentUser(currentUser);
|
|
@@ -67,7 +63,7 @@ export const getEntityRecord = (kind, name, key = '', query) => async ({
|
|
|
67
63
|
name
|
|
68
64
|
});
|
|
69
65
|
|
|
70
|
-
if (!entity) {
|
|
66
|
+
if (!entity || entity !== null && entity !== void 0 && entity.__experimentalNoFetch) {
|
|
71
67
|
return;
|
|
72
68
|
}
|
|
73
69
|
|
|
@@ -91,7 +87,7 @@ export const getEntityRecord = (kind, name, key = '', query) => async ({
|
|
|
91
87
|
// eslint-disable-next-line @wordpress/no-unused-vars-before-return
|
|
92
88
|
|
|
93
89
|
|
|
94
|
-
const path = addQueryArgs(entity.baseURL + '/' + key, { ...entity.baseURLParams,
|
|
90
|
+
const path = addQueryArgs(entity.baseURL + (key ? '/' + key : ''), { ...entity.baseURLParams,
|
|
95
91
|
...query
|
|
96
92
|
});
|
|
97
93
|
|
|
@@ -109,12 +105,13 @@ export const getEntityRecord = (kind, name, key = '', query) => async ({
|
|
|
109
105
|
}
|
|
110
106
|
}
|
|
111
107
|
|
|
112
|
-
const record = await
|
|
108
|
+
const record = await apiFetch({
|
|
113
109
|
path
|
|
114
110
|
});
|
|
115
111
|
dispatch.receiveEntityRecords(kind, name, record, query);
|
|
116
112
|
} catch (error) {// We need a way to handle and access REST API errors in state
|
|
117
113
|
// Until then, catching the error ensures the resolver is marked as resolved.
|
|
114
|
+
// See similar implementation in `getEntityRecords()`.
|
|
118
115
|
} finally {
|
|
119
116
|
dispatch.__unstableReleaseStoreLock(lock);
|
|
120
117
|
}
|
|
@@ -123,20 +120,12 @@ export const getEntityRecord = (kind, name, key = '', query) => async ({
|
|
|
123
120
|
* Requests an entity's record from the REST API.
|
|
124
121
|
*/
|
|
125
122
|
|
|
126
|
-
export const getRawEntityRecord =
|
|
123
|
+
export const getRawEntityRecord = forwardResolver('getEntityRecord');
|
|
127
124
|
/**
|
|
128
125
|
* Requests an entity's record from the REST API.
|
|
129
126
|
*/
|
|
130
127
|
|
|
131
|
-
export const getEditedEntityRecord =
|
|
132
|
-
/**
|
|
133
|
-
* Requests the entity's records from the REST API.
|
|
134
|
-
*
|
|
135
|
-
* @param {string} kind Entity kind.
|
|
136
|
-
* @param {string} name Entity name.
|
|
137
|
-
* @param {Object?} query Query Object.
|
|
138
|
-
*/
|
|
139
|
-
|
|
128
|
+
export const getEditedEntityRecord = forwardResolver('getEntityRecord');
|
|
140
129
|
/**
|
|
141
130
|
* Requests the entity's records from the REST API.
|
|
142
131
|
*
|
|
@@ -154,7 +143,7 @@ export const getEntityRecords = (kind, name, query = {}) => async ({
|
|
|
154
143
|
name
|
|
155
144
|
});
|
|
156
145
|
|
|
157
|
-
if (!entity) {
|
|
146
|
+
if (!entity || entity !== null && entity !== void 0 && entity.__experimentalNoFetch) {
|
|
158
147
|
return;
|
|
159
148
|
}
|
|
160
149
|
|
|
@@ -177,7 +166,7 @@ export const getEntityRecords = (kind, name, query = {}) => async ({
|
|
|
177
166
|
const path = addQueryArgs(entity.baseURL, { ...entity.baseURLParams,
|
|
178
167
|
...query
|
|
179
168
|
});
|
|
180
|
-
let records = Object.values(await
|
|
169
|
+
let records = Object.values(await apiFetch({
|
|
181
170
|
path
|
|
182
171
|
})); // If we request fields but the result doesn't contain the fields,
|
|
183
172
|
// explicitely set these fields as "undefined"
|
|
@@ -213,6 +202,9 @@ export const getEntityRecords = (kind, name, query = {}) => async ({
|
|
|
213
202
|
args: resolutionsArgs
|
|
214
203
|
});
|
|
215
204
|
}
|
|
205
|
+
} catch (error) {// We need a way to handle and access REST API errors in state
|
|
206
|
+
// Until then, catching the error ensures the resolver is marked as resolved.
|
|
207
|
+
// See similar implementation in `getEntityRecord()`.
|
|
216
208
|
} finally {
|
|
217
209
|
dispatch.__unstableReleaseStoreLock(lock);
|
|
218
210
|
}
|
|
@@ -227,10 +219,11 @@ getEntityRecords.shouldInvalidate = (action, kind, name) => {
|
|
|
227
219
|
|
|
228
220
|
|
|
229
221
|
export const getCurrentTheme = () => async ({
|
|
230
|
-
dispatch
|
|
222
|
+
dispatch,
|
|
223
|
+
resolveSelect
|
|
231
224
|
}) => {
|
|
232
|
-
const activeThemes = await
|
|
233
|
-
|
|
225
|
+
const activeThemes = await resolveSelect.getEntityRecords('root', 'theme', {
|
|
226
|
+
status: 'active'
|
|
234
227
|
});
|
|
235
228
|
dispatch.receiveCurrentTheme(activeThemes[0]);
|
|
236
229
|
};
|
|
@@ -238,14 +231,7 @@ export const getCurrentTheme = () => async ({
|
|
|
238
231
|
* Requests theme supports data from the index.
|
|
239
232
|
*/
|
|
240
233
|
|
|
241
|
-
export const getThemeSupports = ()
|
|
242
|
-
dispatch
|
|
243
|
-
}) => {
|
|
244
|
-
const activeThemes = await triggerFetch({
|
|
245
|
-
path: '/wp/v2/themes?status=active'
|
|
246
|
-
});
|
|
247
|
-
dispatch.receiveThemeSupports(activeThemes[0].theme_supports);
|
|
248
|
-
};
|
|
234
|
+
export const getThemeSupports = forwardResolver('getCurrentTheme');
|
|
249
235
|
/**
|
|
250
236
|
* Requests a preview from the from the Embed API.
|
|
251
237
|
*
|
|
@@ -256,7 +242,7 @@ export const getEmbedPreview = url => async ({
|
|
|
256
242
|
dispatch
|
|
257
243
|
}) => {
|
|
258
244
|
try {
|
|
259
|
-
const embedProxyResponse = await
|
|
245
|
+
const embedProxyResponse = await apiFetch({
|
|
260
246
|
path: addQueryArgs('/oembed/1.0/proxy', {
|
|
261
247
|
url
|
|
262
248
|
})
|
|
@@ -296,7 +282,7 @@ export const canUser = (action, resource, id) => async ({
|
|
|
296
282
|
let response;
|
|
297
283
|
|
|
298
284
|
try {
|
|
299
|
-
response = await
|
|
285
|
+
response = await apiFetch({
|
|
300
286
|
path,
|
|
301
287
|
// Ideally this would always be an OPTIONS request, but unfortunately there's
|
|
302
288
|
// a bug in the REST API which causes the Allow header to not be sent on
|
|
@@ -366,7 +352,7 @@ export const getAutosaves = (postType, postId) => async ({
|
|
|
366
352
|
const {
|
|
367
353
|
rest_base: restBase
|
|
368
354
|
} = await resolveSelect.getPostType(postType);
|
|
369
|
-
const autosaves = await
|
|
355
|
+
const autosaves = await apiFetch({
|
|
370
356
|
path: `/wp/v2/${restBase}/${postId}/autosaves?context=edit`
|
|
371
357
|
});
|
|
372
358
|
|
|
@@ -429,4 +415,32 @@ export const __experimentalGetTemplateForLink = link => async ({
|
|
|
429
415
|
__experimentalGetTemplateForLink.shouldInvalidate = action => {
|
|
430
416
|
return (action.type === 'RECEIVE_ITEMS' || action.type === 'REMOVE_ITEMS') && action.invalidateCache && action.kind === 'postType' && action.name === 'wp_template';
|
|
431
417
|
};
|
|
418
|
+
|
|
419
|
+
export const __experimentalGetCurrentGlobalStylesId = () => async ({
|
|
420
|
+
dispatch,
|
|
421
|
+
resolveSelect
|
|
422
|
+
}) => {
|
|
423
|
+
const activeThemes = await resolveSelect.getEntityRecords('root', 'theme', {
|
|
424
|
+
status: 'active'
|
|
425
|
+
});
|
|
426
|
+
const globalStylesURL = get(activeThemes, [0, '_links', 'wp:user-global-styles', 0, 'href']);
|
|
427
|
+
|
|
428
|
+
if (globalStylesURL) {
|
|
429
|
+
const globalStylesObject = await apiFetch({
|
|
430
|
+
url: globalStylesURL
|
|
431
|
+
});
|
|
432
|
+
|
|
433
|
+
dispatch.__experimentalReceiveCurrentGlobalStylesId(globalStylesObject.id);
|
|
434
|
+
}
|
|
435
|
+
};
|
|
436
|
+
export const __experimentalGetCurrentThemeBaseGlobalStyles = () => async ({
|
|
437
|
+
resolveSelect,
|
|
438
|
+
dispatch
|
|
439
|
+
}) => {
|
|
440
|
+
const currentTheme = await resolveSelect.getCurrentTheme();
|
|
441
|
+
const themeGlobalStyles = await apiFetch({
|
|
442
|
+
path: `/wp/v2/global-styles/themes/${currentTheme.stylesheet}`
|
|
443
|
+
});
|
|
444
|
+
await dispatch.__experimentalReceiveThemeBaseGlobalStyles(currentTheme.stylesheet, themeGlobalStyles);
|
|
445
|
+
};
|
|
432
446
|
//# sourceMappingURL=resolvers.js.map
|