@wordpress/core-data 6.18.1-next.5a1d1283.0 → 6.19.1
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 +2 -0
- package/README.md +13 -1
- package/build/actions.js +38 -32
- package/build/actions.js.map +1 -1
- package/build/entities.js +10 -2
- package/build/entities.js.map +1 -1
- package/build/entity-provider.js +2 -99
- package/build/entity-provider.js.map +1 -1
- package/build/entity-types/helpers.js.map +1 -1
- package/build/footnotes/get-footnotes-order.js +35 -0
- package/build/footnotes/get-footnotes-order.js.map +1 -0
- package/build/footnotes/get-rich-text-values-cached.js +39 -0
- package/build/footnotes/get-rich-text-values-cached.js.map +1 -0
- package/build/footnotes/index.js +96 -0
- package/build/footnotes/index.js.map +1 -0
- package/build/hooks/use-entity-record.js +6 -3
- package/build/hooks/use-entity-record.js.map +1 -1
- package/build/hooks/use-resource-permissions.js.map +1 -1
- package/build/private-selectors.js +4 -17
- package/build/private-selectors.js.map +1 -1
- package/build/reducer.js +33 -145
- package/build/reducer.js.map +1 -1
- package/build/resolvers.js +39 -18
- package/build/resolvers.js.map +1 -1
- package/build/selectors.js +21 -25
- package/build/selectors.js.map +1 -1
- package/build/utils/get-nested-value.js +30 -0
- package/build/utils/get-nested-value.js.map +1 -0
- package/build/utils/index.js +7 -0
- package/build/utils/index.js.map +1 -1
- package/build/utils/set-nested-value.js +11 -6
- package/build/utils/set-nested-value.js.map +1 -1
- package/build-module/actions.js +36 -30
- package/build-module/actions.js.map +1 -1
- package/build-module/entities.js +10 -2
- package/build-module/entities.js.map +1 -1
- package/build-module/entity-provider.js +2 -99
- package/build-module/entity-provider.js.map +1 -1
- package/build-module/entity-types/helpers.js.map +1 -1
- package/build-module/footnotes/get-footnotes-order.js +27 -0
- package/build-module/footnotes/get-footnotes-order.js.map +1 -0
- package/build-module/footnotes/get-rich-text-values-cached.js +33 -0
- package/build-module/footnotes/get-rich-text-values-cached.js.map +1 -0
- package/build-module/footnotes/index.js +88 -0
- package/build-module/footnotes/index.js.map +1 -0
- package/build-module/hooks/use-entity-record.js +6 -3
- package/build-module/hooks/use-entity-record.js.map +1 -1
- package/build-module/hooks/use-resource-permissions.js.map +1 -1
- package/build-module/private-selectors.js +3 -15
- package/build-module/private-selectors.js.map +1 -1
- package/build-module/reducer.js +30 -144
- package/build-module/reducer.js.map +1 -1
- package/build-module/resolvers.js +37 -17
- package/build-module/resolvers.js.map +1 -1
- package/build-module/selectors.js +19 -29
- package/build-module/selectors.js.map +1 -1
- package/build-module/utils/get-nested-value.js +24 -0
- package/build-module/utils/get-nested-value.js.map +1 -0
- package/build-module/utils/index.js +1 -0
- package/build-module/utils/index.js.map +1 -1
- package/build-module/utils/set-nested-value.js +11 -6
- package/build-module/utils/set-nested-value.js.map +1 -1
- package/build-types/actions.d.ts +1 -6
- package/build-types/actions.d.ts.map +1 -1
- package/build-types/entities.d.ts.map +1 -1
- package/build-types/entity-provider.d.ts.map +1 -1
- package/build-types/footnotes/get-footnotes-order.d.ts +2 -0
- package/build-types/footnotes/get-footnotes-order.d.ts.map +1 -0
- package/build-types/footnotes/get-rich-text-values-cached.d.ts +2 -0
- package/build-types/footnotes/get-rich-text-values-cached.d.ts.map +1 -0
- package/build-types/footnotes/index.d.ts +4 -0
- package/build-types/footnotes/index.d.ts.map +1 -0
- package/build-types/hooks/use-entity-record.d.ts +2 -0
- package/build-types/hooks/use-entity-record.d.ts.map +1 -1
- package/build-types/index.d.ts +3 -2
- package/build-types/index.d.ts.map +1 -1
- package/build-types/private-selectors.d.ts +3 -13
- package/build-types/private-selectors.d.ts.map +1 -1
- package/build-types/reducer.d.ts +7 -23
- package/build-types/reducer.d.ts.map +1 -1
- package/build-types/resolvers.d.ts +4 -0
- package/build-types/resolvers.d.ts.map +1 -1
- package/build-types/selectors.d.ts +19 -14
- package/build-types/selectors.d.ts.map +1 -1
- package/build-types/utils/get-nested-value.d.ts +14 -0
- package/build-types/utils/get-nested-value.d.ts.map +1 -0
- package/build-types/utils/index.d.ts +1 -0
- package/build-types/utils/set-nested-value.d.ts +8 -4
- package/build-types/utils/set-nested-value.d.ts.map +1 -1
- package/package.json +17 -16
- package/src/actions.js +44 -32
- package/src/entities.js +12 -2
- package/src/entity-provider.js +2 -134
- package/src/entity-types/helpers.ts +2 -2
- package/src/footnotes/get-footnotes-order.js +30 -0
- package/src/footnotes/get-rich-text-values-cached.js +35 -0
- package/src/footnotes/index.js +119 -0
- package/src/hooks/test/use-entity-record.js +4 -0
- package/src/hooks/use-entity-record.ts +12 -3
- package/src/hooks/use-resource-permissions.ts +1 -1
- package/src/private-selectors.ts +4 -17
- package/src/reducer.js +36 -155
- package/src/resolvers.js +59 -32
- package/src/selectors.ts +39 -51
- package/src/test/reducer.js +0 -233
- package/src/test/selectors.js +0 -54
- package/src/utils/get-nested-value.js +27 -0
- package/src/utils/index.js +1 -0
- package/src/utils/set-nested-value.js +12 -6
- package/src/utils/test/get-nested-value.js +61 -0
- package/src/utils/test/set-nested-value.js +7 -0
- package/tsconfig.json +1 -0
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["deprecated","store","coreStore","Status","useQuerySelect","useResourcePermissions","resource","id","resolve","canUser","create","read","isResolving","hasResolved","status","Idle","Resolving","Success","canCreate","data","canRead","update","_delete","canUpdate","canDelete","__experimentalUseResourcePermissions","alternative","since"],"sources":["@wordpress/core-data/src/hooks/use-resource-permissions.ts"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport { store as coreStore } from '../';\nimport { Status } from './constants';\nimport useQuerySelect from './use-query-select';\n\ninterface GlobalResourcePermissionsResolution {\n\t/** Can the current user create new resources of this type? */\n\tcanCreate: boolean;\n}\ninterface SpecificResourcePermissionsResolution {\n\t/** Can the current user update resources of this type? */\n\tcanUpdate: boolean;\n\t/** Can the current user delete resources of this type? */\n\tcanDelete: boolean;\n}\ninterface ResolutionDetails {\n\t/** Resolution status */\n\tstatus: Status;\n\t/**\n\t * Is the data still being resolved?\n\t */\n\tisResolving: boolean;\n}\n\n/**\n * Is the data resolved by now?\n */\ntype HasResolved = boolean;\n\ntype ResourcePermissionsResolution< IdType > = [\n\tHasResolved,\n\tResolutionDetails &\n\t\tGlobalResourcePermissionsResolution &\n\t\t( IdType extends void ? SpecificResourcePermissionsResolution : {} )
|
|
1
|
+
{"version":3,"names":["deprecated","store","coreStore","Status","useQuerySelect","useResourcePermissions","resource","id","resolve","canUser","create","read","isResolving","hasResolved","status","Idle","Resolving","Success","canCreate","data","canRead","update","_delete","canUpdate","canDelete","__experimentalUseResourcePermissions","alternative","since"],"sources":["@wordpress/core-data/src/hooks/use-resource-permissions.ts"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport { store as coreStore } from '../';\nimport { Status } from './constants';\nimport useQuerySelect from './use-query-select';\n\ninterface GlobalResourcePermissionsResolution {\n\t/** Can the current user create new resources of this type? */\n\tcanCreate: boolean;\n}\ninterface SpecificResourcePermissionsResolution {\n\t/** Can the current user update resources of this type? */\n\tcanUpdate: boolean;\n\t/** Can the current user delete resources of this type? */\n\tcanDelete: boolean;\n}\ninterface ResolutionDetails {\n\t/** Resolution status */\n\tstatus: Status;\n\t/**\n\t * Is the data still being resolved?\n\t */\n\tisResolving: boolean;\n}\n\n/**\n * Is the data resolved by now?\n */\ntype HasResolved = boolean;\n\ntype ResourcePermissionsResolution< IdType > = [\n\tHasResolved,\n\tResolutionDetails &\n\t\tGlobalResourcePermissionsResolution &\n\t\t( IdType extends void ? SpecificResourcePermissionsResolution : {} ),\n];\n\n/**\n * Resolves resource permissions.\n *\n * @since 6.1.0 Introduced in WordPress core.\n *\n * @param resource The resource in question, e.g. media.\n * @param id ID of a specific resource entry, if needed, e.g. 10.\n *\n * @example\n * ```js\n * import { useResourcePermissions } from '@wordpress/core-data';\n *\n * function PagesList() {\n * const { canCreate, isResolving } = useResourcePermissions( 'pages' );\n *\n * if ( isResolving ) {\n * return 'Loading ...';\n * }\n *\n * return (\n * <div>\n * {canCreate ? (<button>+ Create a new page</button>) : false}\n * // ...\n * </div>\n * );\n * }\n *\n * // Rendered in the application:\n * // <PagesList />\n * ```\n *\n * @example\n * ```js\n * import { useResourcePermissions } from '@wordpress/core-data';\n *\n * function Page({ pageId }) {\n * const {\n * canCreate,\n * canUpdate,\n * canDelete,\n * isResolving\n * } = useResourcePermissions( 'pages', pageId );\n *\n * if ( isResolving ) {\n * return 'Loading ...';\n * }\n *\n * return (\n * <div>\n * {canCreate ? (<button>+ Create a new page</button>) : false}\n * {canUpdate ? (<button>Edit page</button>) : false}\n * {canDelete ? (<button>Delete page</button>) : false}\n * // ...\n * </div>\n * );\n * }\n *\n * // Rendered in the application:\n * // <Page pageId={ 15 } />\n * ```\n *\n * In the above example, when `PagesList` is rendered into an\n * application, the appropriate permissions and the resolution details will be retrieved from\n * the store state using `canUser()`, or resolved if missing.\n *\n * @return Entity records data.\n * @template IdType\n */\nexport default function useResourcePermissions< IdType = void >(\n\tresource: string,\n\tid?: IdType\n): ResourcePermissionsResolution< IdType > {\n\treturn useQuerySelect(\n\t\t( resolve ) => {\n\t\t\tconst { canUser } = resolve( coreStore );\n\t\t\tconst create = canUser( 'create', resource );\n\t\t\tif ( ! id ) {\n\t\t\t\tconst read = canUser( 'read', resource );\n\n\t\t\t\tconst isResolving = create.isResolving || read.isResolving;\n\t\t\t\tconst hasResolved = create.hasResolved && read.hasResolved;\n\t\t\t\tlet status = Status.Idle;\n\t\t\t\tif ( isResolving ) {\n\t\t\t\t\tstatus = Status.Resolving;\n\t\t\t\t} else if ( hasResolved ) {\n\t\t\t\t\tstatus = Status.Success;\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\tstatus,\n\t\t\t\t\tisResolving,\n\t\t\t\t\thasResolved,\n\t\t\t\t\tcanCreate: create.hasResolved && create.data,\n\t\t\t\t\tcanRead: read.hasResolved && read.data,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst read = canUser( 'read', resource, id );\n\t\t\tconst update = canUser( 'update', resource, id );\n\t\t\tconst _delete = canUser( 'delete', resource, id );\n\t\t\tconst isResolving =\n\t\t\t\tread.isResolving ||\n\t\t\t\tcreate.isResolving ||\n\t\t\t\tupdate.isResolving ||\n\t\t\t\t_delete.isResolving;\n\t\t\tconst hasResolved =\n\t\t\t\tread.hasResolved &&\n\t\t\t\tcreate.hasResolved &&\n\t\t\t\tupdate.hasResolved &&\n\t\t\t\t_delete.hasResolved;\n\n\t\t\tlet status = Status.Idle;\n\t\t\tif ( isResolving ) {\n\t\t\t\tstatus = Status.Resolving;\n\t\t\t} else if ( hasResolved ) {\n\t\t\t\tstatus = Status.Success;\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tstatus,\n\t\t\t\tisResolving,\n\t\t\t\thasResolved,\n\t\t\t\tcanRead: hasResolved && read.data,\n\t\t\t\tcanCreate: hasResolved && create.data,\n\t\t\t\tcanUpdate: hasResolved && update.data,\n\t\t\t\tcanDelete: hasResolved && _delete.data,\n\t\t\t};\n\t\t},\n\t\t[ resource, id ]\n\t);\n}\n\nexport function __experimentalUseResourcePermissions(\n\tresource: string,\n\tid?: unknown\n) {\n\tdeprecated( `wp.data.__experimentalUseResourcePermissions`, {\n\t\talternative: 'wp.data.useResourcePermissions',\n\t\tsince: '6.1',\n\t} );\n\treturn useResourcePermissions( resource, id );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,uBAAuB;;AAE9C;AACA;AACA;AACA,SAASC,KAAK,IAAIC,SAAS,QAAQ,KAAK;AACxC,SAASC,MAAM,QAAQ,aAAa;AACpC,OAAOC,cAAc,MAAM,oBAAoB;AAiC/C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAC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OAAO,GAAGb,OAAO,CAAE,QAAQ,EAAEH,QAAQ,EAAEC,EAAG,CAAC;IACjD,MAAMK,WAAW,GAChBD,IAAI,CAACC,WAAW,IAChBF,MAAM,CAACE,WAAW,IAClBS,MAAM,CAACT,WAAW,IAClBU,OAAO,CAACV,WAAW;IACpB,MAAMC,WAAW,GAChBF,IAAI,CAACE,WAAW,IAChBH,MAAM,CAACG,WAAW,IAClBQ,MAAM,CAACR,WAAW,IAClBS,OAAO,CAACT,WAAW;IAEpB,IAAIC,MAAM,GAAGX,MAAM,CAACY,IAAI;IACxB,IAAKH,WAAW,EAAG;MAClBE,MAAM,GAAGX,MAAM,CAACa,SAAS;IAC1B,CAAC,MAAM,IAAKH,WAAW,EAAG;MACzBC,MAAM,GAAGX,MAAM,CAACc,OAAO;IACxB;IACA,OAAO;MACNH,MAAM;MACNF,WAAW;MACXC,WAAW;MACXO,OAAO,EAAEP,WAAW,IAAIF,IAAI,CAACQ,IAAI;MACjCD,SAAS,EAAEL,WAAW,IAAIH,MAAM,CAACS,IAAI;MACrCI,SAAS,EAAEV,WAAW,IAAIQ,MAAM,CAACF,IAAI;MACrCK,SAAS,EAAEX,WAAW,IAAIS,OAAO,CAACH;IACnC,CAAC;EACF,CAAC,EACD,CAAEb,QAAQ,EAAEC,EAAE,CACf,CAAC;AACF;AAEA,OAAO,SAASkB,oCAAoCA,CACnDnB,QAAgB,EAChBC,EAAY,EACX;EACDP,UAAU,CAAG,8CAA6C,EAAE;IAC3D0B,WAAW,EAAE,gCAAgC;IAC7CC,KAAK,EAAE;EACR,CAAE,CAAC;EACH,OAAOtB,sBAAsB,CAAEC,QAAQ,EAAEC,EAAG,CAAC;AAC9C"}
|
|
@@ -8,22 +8,10 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @param state State tree.
|
|
10
10
|
*
|
|
11
|
-
* @return The
|
|
11
|
+
* @return The undo manager.
|
|
12
12
|
*/
|
|
13
|
-
export function
|
|
14
|
-
return state.
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Returns the next edit from the current undo offset
|
|
19
|
-
* for the entity records edits history, if any.
|
|
20
|
-
*
|
|
21
|
-
* @param state State tree.
|
|
22
|
-
*
|
|
23
|
-
* @return The edit.
|
|
24
|
-
*/
|
|
25
|
-
export function getRedoEdits(state) {
|
|
26
|
-
return state.undo.list[state.undo.list.length + state.undo.offset];
|
|
13
|
+
export function getUndoManager(state) {
|
|
14
|
+
return state.undoManager;
|
|
27
15
|
}
|
|
28
16
|
|
|
29
17
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["getUndoManager","state","undoManager","getNavigationFallbackId","navigationFallbackId"],"sources":["@wordpress/core-data/src/private-selectors.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport type { State } from './selectors';\n\ntype EntityRecordKey = string | number;\n\n/**\n * Returns the previous edit from the current undo offset\n * for the entity records edits history, if any.\n *\n * @param state State tree.\n *\n * @return The undo manager.\n */\nexport function getUndoManager( state: State ) {\n\treturn state.undoManager;\n}\n\n/**\n * Retrieve the fallback Navigation.\n *\n * @param state Data state.\n * @return The ID for the fallback Navigation post.\n */\nexport function getNavigationFallbackId(\n\tstate: State\n): EntityRecordKey | undefined {\n\treturn state.navigationFallbackId;\n}\n"],"mappings":"AAAA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,cAAcA,CAAEC,KAAY,EAAG;EAC9C,OAAOA,KAAK,CAACC,WAAW;AACzB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,uBAAuBA,CACtCF,KAAY,EACkB;EAC9B,OAAOA,KAAK,CAACG,oBAAoB;AAClC"}
|
package/build-module/reducer.js
CHANGED
|
@@ -8,7 +8,7 @@ import fastDeepEqual from 'fast-deep-equal/es6';
|
|
|
8
8
|
*/
|
|
9
9
|
import { compose } from '@wordpress/compose';
|
|
10
10
|
import { combineReducers } from '@wordpress/data';
|
|
11
|
-
import
|
|
11
|
+
import { createUndoManager } from '@wordpress/undo-manager';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Internal dependencies
|
|
@@ -177,25 +177,26 @@ export function themeGlobalStyleVariations(state = {}, action) {
|
|
|
177
177
|
const withMultiEntityRecordEdits = reducer => (state, action) => {
|
|
178
178
|
if (action.type === 'UNDO' || action.type === 'REDO') {
|
|
179
179
|
const {
|
|
180
|
-
|
|
180
|
+
record
|
|
181
181
|
} = action;
|
|
182
182
|
let newState = state;
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
183
|
+
record.forEach(({
|
|
184
|
+
id: {
|
|
185
|
+
kind,
|
|
186
|
+
name,
|
|
187
|
+
recordId
|
|
188
|
+
},
|
|
189
|
+
changes
|
|
190
190
|
}) => {
|
|
191
191
|
newState = reducer(newState, {
|
|
192
192
|
type: 'EDIT_ENTITY_RECORD',
|
|
193
193
|
kind,
|
|
194
194
|
name,
|
|
195
195
|
recordId,
|
|
196
|
-
edits: {
|
|
197
|
-
[
|
|
198
|
-
|
|
196
|
+
edits: Object.entries(changes).reduce((acc, [key, value]) => {
|
|
197
|
+
acc[key] = action.type === 'UNDO' ? value.from : value.to;
|
|
198
|
+
return acc;
|
|
199
|
+
}, {})
|
|
199
200
|
});
|
|
200
201
|
});
|
|
201
202
|
return newState;
|
|
@@ -379,141 +380,17 @@ export const entities = (state = {}, action) => {
|
|
|
379
380
|
};
|
|
380
381
|
|
|
381
382
|
/**
|
|
382
|
-
* @
|
|
383
|
-
*
|
|
384
|
-
* @property {number} list The undo stack.
|
|
385
|
-
* @property {number} offset Where in the undo stack we are.
|
|
386
|
-
* @property {Object} cache Cache of unpersisted edits.
|
|
383
|
+
* @type {UndoManager}
|
|
387
384
|
*/
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
* @type {UndoState}
|
|
393
|
-
*
|
|
394
|
-
* @todo Given how we use this we might want to make a custom class for it.
|
|
395
|
-
*/
|
|
396
|
-
const UNDO_INITIAL_STATE = {
|
|
397
|
-
list: [],
|
|
398
|
-
offset: 0
|
|
399
|
-
};
|
|
400
|
-
|
|
401
|
-
/**
|
|
402
|
-
* Reducer keeping track of entity edit undo history.
|
|
403
|
-
*
|
|
404
|
-
* @param {UndoState} state Current state.
|
|
405
|
-
* @param {Object} action Dispatched action.
|
|
406
|
-
*
|
|
407
|
-
* @return {UndoState} Updated state.
|
|
408
|
-
*/
|
|
409
|
-
export function undo(state = UNDO_INITIAL_STATE, action) {
|
|
410
|
-
const omitPendingRedos = currentState => {
|
|
411
|
-
return {
|
|
412
|
-
...currentState,
|
|
413
|
-
list: currentState.list.slice(0, currentState.offset || undefined),
|
|
414
|
-
offset: 0
|
|
415
|
-
};
|
|
416
|
-
};
|
|
417
|
-
const appendCachedEditsToLastUndo = currentState => {
|
|
418
|
-
if (!currentState.cache) {
|
|
419
|
-
return currentState;
|
|
420
|
-
}
|
|
421
|
-
let nextState = {
|
|
422
|
-
...currentState,
|
|
423
|
-
list: [...currentState.list]
|
|
424
|
-
};
|
|
425
|
-
nextState = omitPendingRedos(nextState);
|
|
426
|
-
const previousUndoState = nextState.list.pop();
|
|
427
|
-
const updatedUndoState = currentState.cache.reduce(appendEditToStack, previousUndoState);
|
|
428
|
-
nextState.list.push(updatedUndoState);
|
|
429
|
-
return {
|
|
430
|
-
...nextState,
|
|
431
|
-
cache: undefined
|
|
432
|
-
};
|
|
433
|
-
};
|
|
434
|
-
const appendEditToStack = (stack = [], {
|
|
435
|
-
kind,
|
|
436
|
-
name,
|
|
437
|
-
recordId,
|
|
438
|
-
property,
|
|
439
|
-
from,
|
|
440
|
-
to
|
|
441
|
-
}) => {
|
|
442
|
-
const existingEditIndex = stack?.findIndex(({
|
|
443
|
-
kind: k,
|
|
444
|
-
name: n,
|
|
445
|
-
recordId: r,
|
|
446
|
-
property: p
|
|
447
|
-
}) => {
|
|
448
|
-
return k === kind && n === name && r === recordId && p === property;
|
|
449
|
-
});
|
|
450
|
-
const nextStack = [...stack];
|
|
451
|
-
if (existingEditIndex !== -1) {
|
|
452
|
-
// If the edit is already in the stack leave the initial "from" value.
|
|
453
|
-
nextStack[existingEditIndex] = {
|
|
454
|
-
...nextStack[existingEditIndex],
|
|
455
|
-
to
|
|
456
|
-
};
|
|
457
|
-
} else {
|
|
458
|
-
nextStack.push({
|
|
459
|
-
kind,
|
|
460
|
-
name,
|
|
461
|
-
recordId,
|
|
462
|
-
property,
|
|
463
|
-
from,
|
|
464
|
-
to
|
|
465
|
-
});
|
|
466
|
-
}
|
|
467
|
-
return nextStack;
|
|
468
|
-
};
|
|
385
|
+
export function undoManager(state = createUndoManager()) {
|
|
386
|
+
return state;
|
|
387
|
+
}
|
|
388
|
+
export function editsReference(state = {}, action) {
|
|
469
389
|
switch (action.type) {
|
|
470
|
-
case '
|
|
471
|
-
return appendCachedEditsToLastUndo(state);
|
|
390
|
+
case 'EDIT_ENTITY_RECORD':
|
|
472
391
|
case 'UNDO':
|
|
473
392
|
case 'REDO':
|
|
474
|
-
{
|
|
475
|
-
const nextState = appendCachedEditsToLastUndo(state);
|
|
476
|
-
return {
|
|
477
|
-
...nextState,
|
|
478
|
-
offset: state.offset + (action.type === 'UNDO' ? -1 : 1)
|
|
479
|
-
};
|
|
480
|
-
}
|
|
481
|
-
case 'EDIT_ENTITY_RECORD':
|
|
482
|
-
{
|
|
483
|
-
if (!action.meta.undo) {
|
|
484
|
-
return state;
|
|
485
|
-
}
|
|
486
|
-
const edits = Object.keys(action.edits).map(key => {
|
|
487
|
-
return {
|
|
488
|
-
kind: action.kind,
|
|
489
|
-
name: action.name,
|
|
490
|
-
recordId: action.recordId,
|
|
491
|
-
property: key,
|
|
492
|
-
from: action.meta.undo.edits[key],
|
|
493
|
-
to: action.edits[key]
|
|
494
|
-
};
|
|
495
|
-
});
|
|
496
|
-
if (action.meta.undo.isCached) {
|
|
497
|
-
return {
|
|
498
|
-
...state,
|
|
499
|
-
cache: edits.reduce(appendEditToStack, state.cache)
|
|
500
|
-
};
|
|
501
|
-
}
|
|
502
|
-
let nextState = omitPendingRedos(state);
|
|
503
|
-
nextState = appendCachedEditsToLastUndo(nextState);
|
|
504
|
-
nextState = {
|
|
505
|
-
...nextState,
|
|
506
|
-
list: [...nextState.list]
|
|
507
|
-
};
|
|
508
|
-
// When an edit is a function it's an optimization to avoid running some expensive operation.
|
|
509
|
-
// We can't rely on the function references being the same so we opt out of comparing them here.
|
|
510
|
-
const comparisonUndoEdits = Object.values(action.meta.undo.edits).filter(edit => typeof edit !== 'function');
|
|
511
|
-
const comparisonEdits = Object.values(action.edits).filter(edit => typeof edit !== 'function');
|
|
512
|
-
if (!isShallowEqual(comparisonUndoEdits, comparisonEdits)) {
|
|
513
|
-
nextState.list.push(edits);
|
|
514
|
-
}
|
|
515
|
-
return nextState;
|
|
516
|
-
}
|
|
393
|
+
return {};
|
|
517
394
|
}
|
|
518
395
|
return state;
|
|
519
396
|
}
|
|
@@ -597,6 +474,13 @@ export function blockPatternCategories(state = [], action) {
|
|
|
597
474
|
}
|
|
598
475
|
return state;
|
|
599
476
|
}
|
|
477
|
+
export function userPatternCategories(state = [], action) {
|
|
478
|
+
switch (action.type) {
|
|
479
|
+
case 'RECEIVE_USER_PATTERN_CATEGORIES':
|
|
480
|
+
return action.patternCategories;
|
|
481
|
+
}
|
|
482
|
+
return state;
|
|
483
|
+
}
|
|
600
484
|
export function navigationFallbackId(state = null, action) {
|
|
601
485
|
switch (action.type) {
|
|
602
486
|
case 'RECEIVE_NAVIGATION_FALLBACK_ID':
|
|
@@ -634,12 +518,14 @@ export default combineReducers({
|
|
|
634
518
|
themeGlobalStyleRevisions,
|
|
635
519
|
taxonomies,
|
|
636
520
|
entities,
|
|
637
|
-
|
|
521
|
+
editsReference,
|
|
522
|
+
undoManager,
|
|
638
523
|
embedPreviews,
|
|
639
524
|
userPermissions,
|
|
640
525
|
autosaves,
|
|
641
526
|
blockPatterns,
|
|
642
527
|
blockPatternCategories,
|
|
528
|
+
userPatternCategories,
|
|
643
529
|
navigationFallbackId
|
|
644
530
|
});
|
|
645
531
|
//# sourceMappingURL=reducer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["fastDeepEqual","compose","combineReducers","isShallowEqual","ifMatchingAction","replaceAction","reducer","queriedDataReducer","rootEntitiesConfig","DEFAULT_ENTITY_KEY","terms","state","action","type","taxonomy","users","byId","queries","reduce","newUsers","user","id","queryID","map","currentUser","taxonomies","currentTheme","undefined","stylesheet","currentGlobalStylesId","themeBaseGlobalStyles","globalStyles","themeGlobalStyleVariations","variations","withMultiEntityRecordEdits","stackedEdits","newState","forEach","kind","name","recordId","property","from","to","edits","entity","entityConfig","key","queriedData","_action$query$context","context","query","nextState","record","items","nextEdits","Object","keys","acc","_record$key$raw","raw","persistedEdits","length","saving","pending","error","isAutosave","deleting","entitiesConfig","entities","newConfig","config","entitiesDataReducer","entitiesByKind","push","entries","memo","subEntities","kindReducer","kindMemo","newData","records","UNDO_INITIAL_STATE","list","offset","undo","omitPendingRedos","currentState","slice","appendCachedEditsToLastUndo","cache","previousUndoState","pop","updatedUndoState","appendEditToStack","stack","existingEditIndex","findIndex","k","n","r","p","nextStack","meta","isCached","comparisonUndoEdits","values","filter","edit","comparisonEdits","embedPreviews","url","preview","userPermissions","isAllowed","autosaves","postId","autosavesData","blockPatterns","patterns","blockPatternCategories","categories","navigationFallbackId","fallbackId","themeGlobalStyleRevisions","currentId","revisions"],"sources":["@wordpress/core-data/src/reducer.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport fastDeepEqual from 'fast-deep-equal/es6';\n\n/**\n * WordPress dependencies\n */\nimport { compose } from '@wordpress/compose';\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 { rootEntitiesConfig, DEFAULT_ENTITY_KEY } from './entities';\n\n/** @typedef {import('./types').AnyFunction} AnyFunction */\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// Key users by their ID.\n\t\t\t\t\t...action.users.reduce(\n\t\t\t\t\t\t( newUsers, user ) => ( {\n\t\t\t\t\t\t\t...newUsers,\n\t\t\t\t\t\t\t[ user.id ]: user,\n\t\t\t\t\t\t} ),\n\t\t\t\t\t\t{}\n\t\t\t\t\t),\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 ]: action.users.map( ( user ) => user.id ),\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|undefined} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {string|undefined} 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|undefined} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {string|undefined} 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 {Record<string, object>} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Record<string, object>} 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 * Reducer managing the theme global styles variations.\n *\n * @param {Record<string, object>} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Record<string, object>} Updated state.\n */\nexport function themeGlobalStyleVariations( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_THEME_GLOBAL_STYLE_VARIATIONS':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.stylesheet ]: action.variations,\n\t\t\t};\n\t}\n\n\treturn state;\n}\n\nconst withMultiEntityRecordEdits = ( reducer ) => ( state, action ) => {\n\tif ( action.type === 'UNDO' || action.type === 'REDO' ) {\n\t\tconst { stackedEdits } = action;\n\n\t\tlet newState = state;\n\t\tstackedEdits.forEach(\n\t\t\t( { kind, name, recordId, property, from, to } ) => {\n\t\t\t\tnewState = reducer( newState, {\n\t\t\t\t\ttype: 'EDIT_ENTITY_RECORD',\n\t\t\t\t\tkind,\n\t\t\t\t\tname,\n\t\t\t\t\trecordId,\n\t\t\t\t\tedits: {\n\t\t\t\t\t\t[ property ]: action.type === 'UNDO' ? from : to,\n\t\t\t\t\t},\n\t\t\t\t} );\n\t\t\t}\n\t\t);\n\t\treturn newState;\n\t}\n\n\treturn reducer( state, action );\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 {AnyFunction} Reducer.\n */\nfunction entity( entityConfig ) {\n\treturn compose( [\n\t\twithMultiEntityRecordEdits,\n\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! fastDeepEqual(\n\t\t\t\t\t\t\t\t\t\t\tedits[ key ],\n\t\t\t\t\t\t\t\t\t\t\trecord[ key ]?.raw ?? record[ key ]\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! fastDeepEqual(\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 = rootEntitiesConfig, 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 = newConfig.reduce( ( acc, record ) => {\n\t\t\tconst { kind } = record;\n\t\t\tif ( ! acc[ kind ] ) {\n\t\t\t\tacc[ kind ] = [];\n\t\t\t}\n\t\t\tacc[ kind ].push( record );\n\t\t\treturn acc;\n\t\t}, {} );\n\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.records, action );\n\n\tif (\n\t\tnewData === state.records &&\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\trecords: newData,\n\t\tconfig: newConfig,\n\t};\n};\n\n/**\n * @typedef {Object} UndoStateMeta\n *\n * @property {number} list The undo stack.\n * @property {number} offset Where in the undo stack we are.\n * @property {Object} cache Cache of unpersisted edits.\n */\n\n/** @typedef {Array<Object> & UndoStateMeta} UndoState */\n\n/**\n * @type {UndoState}\n *\n * @todo Given how we use this we might want to make a custom class for it.\n */\nconst UNDO_INITIAL_STATE = { list: [], offset: 0 };\n\n/**\n * Reducer keeping track of entity edit undo history.\n *\n * @param {UndoState} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {UndoState} Updated state.\n */\nexport function undo( state = UNDO_INITIAL_STATE, action ) {\n\tconst omitPendingRedos = ( currentState ) => {\n\t\treturn {\n\t\t\t...currentState,\n\t\t\tlist: currentState.list.slice(\n\t\t\t\t0,\n\t\t\t\tcurrentState.offset || undefined\n\t\t\t),\n\t\t\toffset: 0,\n\t\t};\n\t};\n\n\tconst appendCachedEditsToLastUndo = ( currentState ) => {\n\t\tif ( ! currentState.cache ) {\n\t\t\treturn currentState;\n\t\t}\n\n\t\tlet nextState = {\n\t\t\t...currentState,\n\t\t\tlist: [ ...currentState.list ],\n\t\t};\n\t\tnextState = omitPendingRedos( nextState );\n\t\tconst previousUndoState = nextState.list.pop();\n\t\tconst updatedUndoState = currentState.cache.reduce(\n\t\t\tappendEditToStack,\n\t\t\tpreviousUndoState\n\t\t);\n\t\tnextState.list.push( updatedUndoState );\n\n\t\treturn {\n\t\t\t...nextState,\n\t\t\tcache: undefined,\n\t\t};\n\t};\n\n\tconst appendEditToStack = (\n\t\tstack = [],\n\t\t{ kind, name, recordId, property, from, to }\n\t) => {\n\t\tconst existingEditIndex = stack?.findIndex(\n\t\t\t( { kind: k, name: n, recordId: r, property: p } ) => {\n\t\t\t\treturn (\n\t\t\t\t\tk === kind && n === name && r === recordId && p === property\n\t\t\t\t);\n\t\t\t}\n\t\t);\n\t\tconst nextStack = [ ...stack ];\n\t\tif ( existingEditIndex !== -1 ) {\n\t\t\t// If the edit is already in the stack leave the initial \"from\" value.\n\t\t\tnextStack[ existingEditIndex ] = {\n\t\t\t\t...nextStack[ existingEditIndex ],\n\t\t\t\tto,\n\t\t\t};\n\t\t} else {\n\t\t\tnextStack.push( {\n\t\t\t\tkind,\n\t\t\t\tname,\n\t\t\t\trecordId,\n\t\t\t\tproperty,\n\t\t\t\tfrom,\n\t\t\t\tto,\n\t\t\t} );\n\t\t}\n\t\treturn nextStack;\n\t};\n\n\tswitch ( action.type ) {\n\t\tcase 'CREATE_UNDO_LEVEL':\n\t\t\treturn appendCachedEditsToLastUndo( state );\n\n\t\tcase 'UNDO':\n\t\tcase 'REDO': {\n\t\t\tconst nextState = appendCachedEditsToLastUndo( state );\n\t\t\treturn {\n\t\t\t\t...nextState,\n\t\t\t\toffset: state.offset + ( action.type === 'UNDO' ? -1 : 1 ),\n\t\t\t};\n\t\t}\n\n\t\tcase 'EDIT_ENTITY_RECORD': {\n\t\t\tif ( ! action.meta.undo ) {\n\t\t\t\treturn state;\n\t\t\t}\n\n\t\t\tconst edits = Object.keys( action.edits ).map( ( key ) => {\n\t\t\t\treturn {\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\tproperty: key,\n\t\t\t\t\tfrom: action.meta.undo.edits[ key ],\n\t\t\t\t\tto: action.edits[ key ],\n\t\t\t\t};\n\t\t\t} );\n\n\t\t\tif ( action.meta.undo.isCached ) {\n\t\t\t\treturn {\n\t\t\t\t\t...state,\n\t\t\t\t\tcache: edits.reduce( appendEditToStack, state.cache ),\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tlet nextState = omitPendingRedos( state );\n\t\t\tnextState = appendCachedEditsToLastUndo( nextState );\n\t\t\tnextState = { ...nextState, list: [ ...nextState.list ] };\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.list.push( edits );\n\t\t\t}\n\n\t\t\treturn nextState;\n\t\t}\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 function blockPatterns( state = [], action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_BLOCK_PATTERNS':\n\t\t\treturn action.patterns;\n\t}\n\n\treturn state;\n}\n\nexport function blockPatternCategories( state = [], action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_BLOCK_PATTERN_CATEGORIES':\n\t\t\treturn action.categories;\n\t}\n\n\treturn state;\n}\n\nexport function navigationFallbackId( state = null, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_NAVIGATION_FALLBACK_ID':\n\t\t\treturn action.fallbackId;\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer managing the theme global styles revisions.\n *\n * @param {Record<string, object>} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Record<string, object>} Updated state.\n */\nexport function themeGlobalStyleRevisions( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_THEME_GLOBAL_STYLE_REVISIONS':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.currentId ]: action.revisions,\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\tthemeGlobalStyleVariations,\n\tthemeBaseGlobalStyles,\n\tthemeGlobalStyleRevisions,\n\ttaxonomies,\n\tentities,\n\tundo,\n\tembedPreviews,\n\tuserPermissions,\n\tautosaves,\n\tblockPatterns,\n\tblockPatternCategories,\n\tnavigationFallback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AEA,OAAO5G,KAAK;AACb;AAEA,OAAO,SAAS6G,sBAAsBA,CAAE7G,KAAK,GAAG,EAAE,EAAEC,MAAM,EAAG;EAC5D,QAASA,MAAM,CAACC,IAAI;IACnB,KAAK,kCAAkC;MACtC,OAAOD,MAAM,CAAC6G,UAAU;EAC1B;EAEA,OAAO9G,KAAK;AACb;AAEA,OAAO,SAAS+G,oBAAoBA,CAAE/G,KAAK,GAAG,IAAI,EAAEC,MAAM,EAAG;EAC5D,QAASA,MAAM,CAACC,IAAI;IACnB,KAAK,gCAAgC;MACpC,OAAOD,MAAM,CAAC+G,UAAU;EAC1B;EAEA,OAAOhH,KAAK;AACb;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASiH,yBAAyBA,CAAEjH,KAAK,GAAG,CAAC,CAAC,EAAEC,MAAM,EAAG;EAC/D,QAASA,MAAM,CAACC,IAAI;IACnB,KAAK,sCAAsC;MAC1C,OAAO;QACN,GAAGF,KAAK;QACR,CAAEC,MAAM,CAACiH,SAAS,GAAIjH,MAAM,CAACkH;MAC9B,CAAC;EACH;EAEA,OAAOnH,KAAK;AACb;AAEA,eAAeT,eAAe,CAAE;EAC/BQ,KAAK;EACLK,KAAK;EACLW,YAAY;EACZG,qBAAqB;EACrBL,WAAW;EACXQ,0BAA0B;EAC1BF,qBAAqB;EACrB8F,yBAAyB;EACzBnG,UAAU;EACV4C,QAAQ;EACRgB,IAAI;EACJyB,aAAa;EACbG,eAAe;EACfE,SAAS;EACTG,aAAa;EACbE,sBAAsB;EACtBE;AACD,CAAE,CAAC"}
|
|
1
|
+
{"version":3,"names":["fastDeepEqual","compose","combineReducers","createUndoManager","ifMatchingAction","replaceAction","reducer","queriedDataReducer","rootEntitiesConfig","DEFAULT_ENTITY_KEY","terms","state","action","type","taxonomy","users","byId","queries","reduce","newUsers","user","id","queryID","map","currentUser","taxonomies","currentTheme","undefined","stylesheet","currentGlobalStylesId","themeBaseGlobalStyles","globalStyles","themeGlobalStyleVariations","variations","withMultiEntityRecordEdits","record","newState","forEach","kind","name","recordId","changes","edits","Object","entries","acc","key","value","from","to","entity","entityConfig","queriedData","_action$query$context","context","query","nextState","items","nextEdits","keys","_record$key$raw","raw","persistedEdits","length","saving","pending","error","isAutosave","deleting","entitiesConfig","entities","newConfig","config","entitiesDataReducer","entitiesByKind","push","memo","subEntities","kindReducer","kindMemo","newData","records","undoManager","editsReference","embedPreviews","url","preview","userPermissions","isAllowed","autosaves","postId","autosavesData","blockPatterns","patterns","blockPatternCategories","categories","userPatternCategories","patternCategories","navigationFallbackId","fallbackId","themeGlobalStyleRevisions","currentId","revisions"],"sources":["@wordpress/core-data/src/reducer.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport fastDeepEqual from 'fast-deep-equal/es6';\n\n/**\n * WordPress dependencies\n */\nimport { compose } from '@wordpress/compose';\nimport { combineReducers } from '@wordpress/data';\nimport { createUndoManager } from '@wordpress/undo-manager';\n\n/**\n * Internal dependencies\n */\nimport { ifMatchingAction, replaceAction } from './utils';\nimport { reducer as queriedDataReducer } from './queried-data';\nimport { rootEntitiesConfig, DEFAULT_ENTITY_KEY } from './entities';\n\n/** @typedef {import('./types').AnyFunction} AnyFunction */\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// Key users by their ID.\n\t\t\t\t\t...action.users.reduce(\n\t\t\t\t\t\t( newUsers, user ) => ( {\n\t\t\t\t\t\t\t...newUsers,\n\t\t\t\t\t\t\t[ user.id ]: user,\n\t\t\t\t\t\t} ),\n\t\t\t\t\t\t{}\n\t\t\t\t\t),\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 ]: action.users.map( ( user ) => user.id ),\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|undefined} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {string|undefined} 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|undefined} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {string|undefined} 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 {Record<string, object>} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Record<string, object>} 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 * Reducer managing the theme global styles variations.\n *\n * @param {Record<string, object>} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Record<string, object>} Updated state.\n */\nexport function themeGlobalStyleVariations( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_THEME_GLOBAL_STYLE_VARIATIONS':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.stylesheet ]: action.variations,\n\t\t\t};\n\t}\n\n\treturn state;\n}\n\nconst withMultiEntityRecordEdits = ( reducer ) => ( state, action ) => {\n\tif ( action.type === 'UNDO' || action.type === 'REDO' ) {\n\t\tconst { record } = action;\n\n\t\tlet newState = state;\n\t\trecord.forEach( ( { id: { kind, name, recordId }, changes } ) => {\n\t\t\tnewState = reducer( newState, {\n\t\t\t\ttype: 'EDIT_ENTITY_RECORD',\n\t\t\t\tkind,\n\t\t\t\tname,\n\t\t\t\trecordId,\n\t\t\t\tedits: Object.entries( changes ).reduce(\n\t\t\t\t\t( acc, [ key, value ] ) => {\n\t\t\t\t\t\tacc[ key ] =\n\t\t\t\t\t\t\taction.type === 'UNDO' ? value.from : value.to;\n\t\t\t\t\t\treturn acc;\n\t\t\t\t\t},\n\t\t\t\t\t{}\n\t\t\t\t),\n\t\t\t} );\n\t\t} );\n\t\treturn newState;\n\t}\n\n\treturn reducer( state, action );\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 {AnyFunction} Reducer.\n */\nfunction entity( entityConfig ) {\n\treturn compose( [\n\t\twithMultiEntityRecordEdits,\n\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! fastDeepEqual(\n\t\t\t\t\t\t\t\t\t\t\tedits[ key ],\n\t\t\t\t\t\t\t\t\t\t\trecord[ key ]?.raw ?? record[ key ]\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! fastDeepEqual(\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 = rootEntitiesConfig, 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 = newConfig.reduce( ( acc, record ) => {\n\t\t\tconst { kind } = record;\n\t\t\tif ( ! acc[ kind ] ) {\n\t\t\t\tacc[ kind ] = [];\n\t\t\t}\n\t\t\tacc[ kind ].push( record );\n\t\t\treturn acc;\n\t\t}, {} );\n\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.records, action );\n\n\tif (\n\t\tnewData === state.records &&\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\trecords: newData,\n\t\tconfig: newConfig,\n\t};\n};\n\n/**\n * @type {UndoManager}\n */\nexport function undoManager( state = createUndoManager() ) {\n\treturn state;\n}\n\nexport function editsReference( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'EDIT_ENTITY_RECORD':\n\t\tcase 'UNDO':\n\t\tcase 'REDO':\n\t\t\treturn {};\n\t}\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 function blockPatterns( state = [], action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_BLOCK_PATTERNS':\n\t\t\treturn action.patterns;\n\t}\n\n\treturn state;\n}\n\nexport function blockPatternCategories( state = [], action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_BLOCK_PATTERN_CATEGORIES':\n\t\t\treturn action.categories;\n\t}\n\n\treturn state;\n}\n\nexport function userPatternCategories( state = [], action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_USER_PATTERN_CATEGORIES':\n\t\t\treturn action.patternCategories;\n\t}\n\treturn state;\n}\n\nexport function navigationFallbackId( state = null, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_NAVIGATION_FALLBACK_ID':\n\t\t\treturn action.fallbackId;\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer managing the theme global styles revisions.\n *\n * @param {Record<string, object>} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Record<string, object>} Updated state.\n */\nexport function themeGlobalStyleRevisions( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_THEME_GLOBAL_STYLE_REVISIONS':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.currentId ]: action.revisions,\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\tthemeGlobalStyleVariations,\n\tthemeBaseGlobalStyles,\n\tthemeGlobalStyleRevisions,\n\ttaxonomies,\n\tentities,\n\teditsReference,\n\tundoManager,\n\tembedPreviews,\n\tuserPermissions,\n\tautosaves,\n\tblockPatterns,\n\tblockPatternCategories,\n\tuserPatternCategories,\n\tnavigationFallbackId,\n} );\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,aAAa,MAAM,qBAAqB;;AAE/C;AACA;AACA;AACA,SAASC,OAAO,QAAQ,oBAAoB;AAC5C,SAASC,eAAe,QAAQ,iBAAiB;AACjD,SAASC,iBAAiB,QAAQ,yBAAyB;;AAE3D;AACA;AACA;AACA,SAASC,gBAAgB,EAAEC,aAAa,QAAQ,SAAS;AACzD,SAASC,OAAO,IAAIC,kBAAkB,QAAQ,gBAAgB;AAC9D,SAASC,kBAAkB,EAAEC,kBAAkB,QAAQ,YAAY;;AAEnE;;AAEA;AACA;AACA;AACA;AACA;AAC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qB;EACrBE;AACD,CAAE,CAAC"}
|
|
@@ -71,26 +71,28 @@ export const getEntityRecord = (kind, name, key = '', query) => async ({
|
|
|
71
71
|
// Entity supports configs,
|
|
72
72
|
// use the sync algorithm instead of the old fetch behavior.
|
|
73
73
|
if (window.__experimentalEnableSync && entityConfig.syncConfig && !query) {
|
|
74
|
-
|
|
74
|
+
if (process.env.IS_GUTENBERG_PLUGIN) {
|
|
75
|
+
const objectId = entityConfig.getSyncObjectId(key);
|
|
75
76
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
77
|
+
// Loads the persisted document.
|
|
78
|
+
await getSyncProvider().bootstrap(entityConfig.syncObjectType, objectId, record => {
|
|
79
|
+
dispatch.receiveEntityRecords(kind, name, record, query);
|
|
80
|
+
});
|
|
80
81
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
82
|
+
// Boostraps the edited document as well (and load from peers).
|
|
83
|
+
await getSyncProvider().bootstrap(entityConfig.syncObjectType + '--edit', objectId, record => {
|
|
84
|
+
dispatch({
|
|
85
|
+
type: 'EDIT_ENTITY_RECORD',
|
|
86
|
+
kind,
|
|
87
|
+
name,
|
|
88
|
+
recordId: key,
|
|
89
|
+
edits: record,
|
|
90
|
+
meta: {
|
|
91
|
+
undo: undefined
|
|
92
|
+
}
|
|
93
|
+
});
|
|
92
94
|
});
|
|
93
|
-
}
|
|
95
|
+
}
|
|
94
96
|
} else {
|
|
95
97
|
if (query !== undefined && query._fields) {
|
|
96
98
|
// If requesting specific fields, items and query association to said
|
|
@@ -500,6 +502,24 @@ export const getBlockPatternCategories = () => async ({
|
|
|
500
502
|
categories
|
|
501
503
|
});
|
|
502
504
|
};
|
|
505
|
+
export const getUserPatternCategories = () => async ({
|
|
506
|
+
dispatch,
|
|
507
|
+
resolveSelect
|
|
508
|
+
}) => {
|
|
509
|
+
const patternCategories = await resolveSelect.getEntityRecords('taxonomy', 'wp_pattern_category', {
|
|
510
|
+
per_page: -1,
|
|
511
|
+
_fields: 'id,name,description,slug'
|
|
512
|
+
});
|
|
513
|
+
const mappedPatternCategories = patternCategories?.map(userCategory => ({
|
|
514
|
+
...userCategory,
|
|
515
|
+
label: userCategory.name,
|
|
516
|
+
name: userCategory.slug
|
|
517
|
+
})) || [];
|
|
518
|
+
dispatch({
|
|
519
|
+
type: 'RECEIVE_USER_PATTERN_CATEGORIES',
|
|
520
|
+
patternCategories: mappedPatternCategories
|
|
521
|
+
});
|
|
522
|
+
};
|
|
503
523
|
export const getNavigationFallbackId = () => async ({
|
|
504
524
|
dispatch,
|
|
505
525
|
select
|