@wordpress/core-data 7.6.0 → 7.7.1-next.1f6eadc42.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/README.md +2 -2
  3. package/build/actions.js +39 -16
  4. package/build/actions.js.map +1 -1
  5. package/build/footnotes/index.js +5 -1
  6. package/build/footnotes/index.js.map +1 -1
  7. package/build/hooks/use-entity-prop.js +4 -4
  8. package/build/hooks/use-entity-prop.js.map +1 -1
  9. package/build/reducer.js +5 -0
  10. package/build/reducer.js.map +1 -1
  11. package/build/resolvers.js +77 -36
  12. package/build/resolvers.js.map +1 -1
  13. package/build/utils/index.js +2 -2
  14. package/build/utils/index.js.map +1 -1
  15. package/build/utils/user-permissions.js +5 -7
  16. package/build/utils/user-permissions.js.map +1 -1
  17. package/build-module/actions.js +38 -16
  18. package/build-module/actions.js.map +1 -1
  19. package/build-module/footnotes/index.js +5 -1
  20. package/build-module/footnotes/index.js.map +1 -1
  21. package/build-module/hooks/use-entity-prop.js +4 -4
  22. package/build-module/hooks/use-entity-prop.js.map +1 -1
  23. package/build-module/reducer.js +5 -0
  24. package/build-module/reducer.js.map +1 -1
  25. package/build-module/resolvers.js +78 -37
  26. package/build-module/resolvers.js.map +1 -1
  27. package/build-module/utils/index.js +1 -1
  28. package/build-module/utils/index.js.map +1 -1
  29. package/build-module/utils/user-permissions.js +4 -6
  30. package/build-module/utils/user-permissions.js.map +1 -1
  31. package/build-types/actions.d.ts +20 -2
  32. package/build-types/actions.d.ts.map +1 -1
  33. package/build-types/footnotes/index.d.ts.map +1 -1
  34. package/build-types/hooks/use-entity-prop.d.ts +5 -5
  35. package/build-types/hooks/use-entity-prop.d.ts.map +1 -1
  36. package/build-types/index.d.ts +5 -2
  37. package/build-types/index.d.ts.map +1 -1
  38. package/build-types/reducer.d.ts.map +1 -1
  39. package/build-types/resolvers.d.ts +5 -3
  40. package/build-types/resolvers.d.ts.map +1 -1
  41. package/build-types/utils/index.d.ts +1 -1
  42. package/build-types/utils/user-permissions.d.ts +1 -1
  43. package/build-types/utils/user-permissions.d.ts.map +1 -1
  44. package/package.json +18 -18
  45. package/src/actions.js +38 -16
  46. package/src/footnotes/index.js +9 -4
  47. package/src/hooks/test/use-entity-records.js +2 -2
  48. package/src/hooks/use-entity-prop.js +4 -4
  49. package/src/reducer.js +5 -0
  50. package/src/resolvers.js +117 -54
  51. package/src/test/resolvers.js +5 -12
  52. package/src/utils/index.js +1 -1
  53. package/src/utils/user-permissions.js +4 -6
  54. package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 7.7.0 (2024-09-05)
6
+
5
7
  ## 7.6.0 (2024-08-21)
6
8
 
7
9
  ## 7.5.0 (2024-08-07)
package/README.md CHANGED
@@ -182,7 +182,7 @@ _Parameters_
182
182
 
183
183
  - _kind_ `string`: Kind of the deleted entity.
184
184
  - _name_ `string`: Name of the deleted entity.
185
- - _recordId_ `string`: Record ID of the deleted entity.
185
+ - _recordId_ `number|string`: Record ID of the deleted entity.
186
186
  - _query_ `?Object`: Special query parameters for the DELETE API call.
187
187
  - _options_ `[Object]`: Delete options.
188
188
  - _options.\_\_unstableFetch_ `[Function]`: Internal use only. Function to call instead of `apiFetch()`. Must return a promise.
@@ -1011,7 +1011,7 @@ _Parameters_
1011
1011
  - _kind_ `string`: The entity kind.
1012
1012
  - _name_ `string`: The entity name.
1013
1013
  - _prop_ `string`: The property name.
1014
- - _\_id_ `[string]`: An entity ID to use instead of the context-provided one.
1014
+ - _\_id_ `[number|string]`: An entity ID to use instead of the context-provided one.
1015
1015
 
1016
1016
  _Returns_
1017
1017
 
package/build/actions.js CHANGED
@@ -23,6 +23,7 @@ exports.receiveThemeGlobalStyleRevisions = receiveThemeGlobalStyleRevisions;
23
23
  exports.receiveThemeSupports = receiveThemeSupports;
24
24
  exports.receiveUploadPermissions = receiveUploadPermissions;
25
25
  exports.receiveUserPermission = receiveUserPermission;
26
+ exports.receiveUserPermissions = receiveUserPermissions;
26
27
  exports.receiveUserQuery = receiveUserQuery;
27
28
  exports.undo = exports.saveEntityRecord = exports.saveEditedEntityRecord = exports.redo = void 0;
28
29
  var _es = _interopRequireDefault(require("fast-deep-equal/es6"));
@@ -269,17 +270,17 @@ function receiveEmbedPreview(url, preview) {
269
270
  /**
270
271
  * Action triggered to delete an entity record.
271
272
  *
272
- * @param {string} kind Kind of the deleted entity.
273
- * @param {string} name Name of the deleted entity.
274
- * @param {string} recordId Record ID of the deleted entity.
275
- * @param {?Object} query Special query parameters for the
276
- * DELETE API call.
277
- * @param {Object} [options] Delete options.
278
- * @param {Function} [options.__unstableFetch] Internal use only. Function to
279
- * call instead of `apiFetch()`.
280
- * Must return a promise.
281
- * @param {boolean} [options.throwOnError=false] If false, this action suppresses all
282
- * the exceptions. Defaults to false.
273
+ * @param {string} kind Kind of the deleted entity.
274
+ * @param {string} name Name of the deleted entity.
275
+ * @param {number|string} recordId Record ID of the deleted entity.
276
+ * @param {?Object} query Special query parameters for the
277
+ * DELETE API call.
278
+ * @param {Object} [options] Delete options.
279
+ * @param {Function} [options.__unstableFetch] Internal use only. Function to
280
+ * call instead of `apiFetch()`.
281
+ * Must return a promise.
282
+ * @param {boolean} [options.throwOnError=false] If false, this action suppresses all
283
+ * the exceptions. Defaults to false.
283
284
  */
284
285
  const deleteEntityRecord = (kind, name, recordId, query, {
285
286
  __unstableFetch = _apiFetch.default,
@@ -702,11 +703,11 @@ const saveEditedEntityRecord = (kind, name, recordId, options) => async ({
702
703
  /**
703
704
  * Action triggered to save only specified properties for the entity.
704
705
  *
705
- * @param {string} kind Kind of the entity.
706
- * @param {string} name Name of the entity.
707
- * @param {Object} recordId ID of the record.
708
- * @param {Array} itemsToSave List of entity properties or property paths to save.
709
- * @param {Object} options Saving options.
706
+ * @param {string} kind Kind of the entity.
707
+ * @param {string} name Name of the entity.
708
+ * @param {number|string} recordId ID of the record.
709
+ * @param {Array} itemsToSave List of entity properties or property paths to save.
710
+ * @param {Object} options Saving options.
710
711
  */
711
712
  exports.saveEditedEntityRecord = saveEditedEntityRecord;
712
713
  const __experimentalSaveSpecifiedEntityEdits = (kind, name, recordId, itemsToSave, options) => async ({
@@ -773,6 +774,28 @@ function receiveUserPermission(key, isAllowed) {
773
774
  };
774
775
  }
775
776
 
777
+ /**
778
+ * Returns an action object used in signalling that the current user has
779
+ * permission to perform an action on a REST resource. Ignored from
780
+ * documentation as it's internal to the data store.
781
+ *
782
+ * @ignore
783
+ *
784
+ * @param {Object<string, boolean>} permissions An object where keys represent
785
+ * actions and REST resources, and
786
+ * values indicate whether the user
787
+ * is allowed to perform the
788
+ * action.
789
+ *
790
+ * @return {Object} Action object.
791
+ */
792
+ function receiveUserPermissions(permissions) {
793
+ return {
794
+ type: 'RECEIVE_USER_PERMISSIONS',
795
+ permissions
796
+ };
797
+ }
798
+
776
799
  /**
777
800
  * Returns an action object used in signalling that the autosaves for a
778
801
  * post have been received.
@@ -1 +1 @@
1
- {"version":3,"names":["_es","_interopRequireDefault","require","_uuid","_apiFetch","_url","_deprecated","_utils","_queriedData","_entities","_batch","_name","_sync","receiveUserQuery","queryID","users","type","Array","isArray","receiveCurrentUser","currentUser","addEntities","entities","receiveEntityRecords","kind","name","records","query","invalidateCache","edits","meta","map","record","status","title","action","receiveQueriedItems","receiveItems","receiveCurrentTheme","currentTheme","__experimentalReceiveCurrentGlobalStylesId","currentGlobalStylesId","id","__experimentalReceiveThemeBaseGlobalStyles","stylesheet","globalStyles","__experimentalReceiveThemeGlobalStyleVariations","variations","receiveThemeSupports","deprecated","since","receiveThemeGlobalStyleRevisions","currentId","revisions","alternative","receiveEmbedPreview","url","preview","deleteEntityRecord","recordId","__unstableFetch","apiFetch","throwOnError","dispatch","configs","getOrLoadEntitiesConfig","entityConfig","find","config","error","deletedRecord","lock","__unstableAcquireStoreLock","STORE_NAME","exclusive","hasError","path","baseURL","addQueryArgs","method","removeItems","_error","__unstableReleaseStoreLock","exports","editEntityRecord","options","select","getEntityConfig","Error","mergedEdits","getRawEntityRecord","editedRecord","getEditedEntityRecord","edit","Object","keys","reduce","acc","key","recordValue","editedRecordValue","value","fastDeepEqual","undefined","window","__experimentalEnableSync","syncConfig","globalThis","IS_GUTENBERG_PLUGIN","objectId","getSyncObjectId","getSyncProvider","update","syncObjectType","undoIgnore","getUndoManager","addRecord","changes","from","to","isCached","undo","undoRecord","redo","redoRecord","__unstableCreateUndoLevel","saveEntityRecord","isAutosave","resolveSelect","entityIdKey","DEFAULT_ENTITY_KEY","uuid","entries","evaluatedValue","updatedRecord","persistedRecord","getCurrentUser","currentUserId","autosavePost","getAutosave","data","includes","newRecord","receiveAutosaves","__unstablePrePersist","__experimentalBatch","requests","batch","createBatch","api","add","saveEditedEntityRecord","resultPromises","request","results","Promise","all","run","hasEditsForEntityRecord","getEntityRecordNonTransientEdits","__experimentalSaveSpecifiedEntityEdits","itemsToSave","editsToSave","item","setNestedValue","getNestedValue","receiveUploadPermissions","hasUploadPermissions","receiveUserPermission","isAllowed","postId","autosaves","receiveNavigationFallbackId","fallbackId","receiveDefaultTemplateId","templateId","receiveRevisions","recordKey","revisionKey","items"],"sources":["@wordpress/core-data/src/actions.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport fastDeepEqual from 'fast-deep-equal/es6';\nimport { v4 as uuid } from 'uuid';\n\n/**\n * WordPress dependencies\n */\nimport apiFetch from '@wordpress/api-fetch';\nimport { addQueryArgs } from '@wordpress/url';\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport { getNestedValue, setNestedValue } from './utils';\nimport { receiveItems, removeItems, receiveQueriedItems } from './queried-data';\nimport { getOrLoadEntitiesConfig, DEFAULT_ENTITY_KEY } from './entities';\nimport { createBatch } from './batch';\nimport { STORE_NAME } from './name';\nimport { getSyncProvider } from './sync';\n\n/**\n * Returns an action object used in signalling that authors have been received.\n * Ignored from documentation as it's internal to the data store.\n *\n * @ignore\n *\n * @param {string} queryID Query ID.\n * @param {Array|Object} users Users received.\n *\n * @return {Object} Action object.\n */\nexport function receiveUserQuery( queryID, users ) {\n\treturn {\n\t\ttype: 'RECEIVE_USER_QUERY',\n\t\tusers: Array.isArray( users ) ? users : [ users ],\n\t\tqueryID,\n\t};\n}\n\n/**\n * Returns an action used in signalling that the current user has been received.\n * Ignored from documentation as it's internal to the data store.\n *\n * @ignore\n *\n * @param {Object} currentUser Current user object.\n *\n * @return {Object} Action object.\n */\nexport function receiveCurrentUser( currentUser ) {\n\treturn {\n\t\ttype: 'RECEIVE_CURRENT_USER',\n\t\tcurrentUser,\n\t};\n}\n\n/**\n * Returns an action object used in adding new entities.\n *\n * @param {Array} entities Entities received.\n *\n * @return {Object} Action object.\n */\nexport function addEntities( entities ) {\n\treturn {\n\t\ttype: 'ADD_ENTITIES',\n\t\tentities,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that entity records have been received.\n *\n * @param {string} kind Kind of the received entity record.\n * @param {string} name Name of the received entity record.\n * @param {Array|Object} records Records received.\n * @param {?Object} query Query Object.\n * @param {?boolean} invalidateCache Should invalidate query caches.\n * @param {?Object} edits Edits to reset.\n * @param {?Object} meta Meta information about pagination.\n * @return {Object} Action object.\n */\nexport function receiveEntityRecords(\n\tkind,\n\tname,\n\trecords,\n\tquery,\n\tinvalidateCache = false,\n\tedits,\n\tmeta\n) {\n\t// Auto drafts should not have titles, but some plugins rely on them so we can't filter this\n\t// on the server.\n\tif ( kind === 'postType' ) {\n\t\trecords = ( Array.isArray( records ) ? records : [ records ] ).map(\n\t\t\t( record ) =>\n\t\t\t\trecord.status === 'auto-draft'\n\t\t\t\t\t? { ...record, title: '' }\n\t\t\t\t\t: record\n\t\t);\n\t}\n\tlet action;\n\tif ( query ) {\n\t\taction = receiveQueriedItems( records, query, edits, meta );\n\t} else {\n\t\taction = receiveItems( records, edits, meta );\n\t}\n\n\treturn {\n\t\t...action,\n\t\tkind,\n\t\tname,\n\t\tinvalidateCache,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that the current theme has been received.\n * Ignored from documentation as it's internal to the data store.\n *\n * @ignore\n *\n * @param {Object} currentTheme The current theme.\n *\n * @return {Object} Action object.\n */\nexport function receiveCurrentTheme( currentTheme ) {\n\treturn {\n\t\ttype: 'RECEIVE_CURRENT_THEME',\n\t\tcurrentTheme,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that the current global styles id has been received.\n * Ignored from documentation as it's internal to the data store.\n *\n * @ignore\n *\n * @param {string} currentGlobalStylesId The current global styles id.\n *\n * @return {Object} Action object.\n */\nexport function __experimentalReceiveCurrentGlobalStylesId(\n\tcurrentGlobalStylesId\n) {\n\treturn {\n\t\ttype: 'RECEIVE_CURRENT_GLOBAL_STYLES_ID',\n\t\tid: currentGlobalStylesId,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that the theme base global styles have been received\n * Ignored from documentation as it's internal to the data store.\n *\n * @ignore\n *\n * @param {string} stylesheet The theme's identifier\n * @param {Object} globalStyles The global styles object.\n *\n * @return {Object} Action object.\n */\nexport function __experimentalReceiveThemeBaseGlobalStyles(\n\tstylesheet,\n\tglobalStyles\n) {\n\treturn {\n\t\ttype: 'RECEIVE_THEME_GLOBAL_STYLES',\n\t\tstylesheet,\n\t\tglobalStyles,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that the theme global styles variations have been received.\n * Ignored from documentation as it's internal to the data store.\n *\n * @ignore\n *\n * @param {string} stylesheet The theme's identifier\n * @param {Array} variations The global styles variations.\n *\n * @return {Object} Action object.\n */\nexport function __experimentalReceiveThemeGlobalStyleVariations(\n\tstylesheet,\n\tvariations\n) {\n\treturn {\n\t\ttype: 'RECEIVE_THEME_GLOBAL_STYLE_VARIATIONS',\n\t\tstylesheet,\n\t\tvariations,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that the index has been received.\n *\n * @deprecated since WP 5.9, this is not useful anymore, use the selector directly.\n *\n * @return {Object} Action object.\n */\nexport function receiveThemeSupports() {\n\tdeprecated( \"wp.data.dispatch( 'core' ).receiveThemeSupports\", {\n\t\tsince: '5.9',\n\t} );\n\n\treturn {\n\t\ttype: 'DO_NOTHING',\n\t};\n}\n\n/**\n * Returns an action object used in signalling that the theme global styles CPT post revisions have been received.\n * Ignored from documentation as it's internal to the data store.\n *\n * @deprecated since WordPress 6.5.0. Callers should use `dispatch( 'core' ).receiveRevision` instead.\n *\n * @ignore\n *\n * @param {number} currentId The post id.\n * @param {Array} revisions The global styles revisions.\n *\n * @return {Object} Action object.\n */\nexport function receiveThemeGlobalStyleRevisions( currentId, revisions ) {\n\tdeprecated(\n\t\t\"wp.data.dispatch( 'core' ).receiveThemeGlobalStyleRevisions()\",\n\t\t{\n\t\t\tsince: '6.5.0',\n\t\t\talternative: \"wp.data.dispatch( 'core' ).receiveRevisions\",\n\t\t}\n\t);\n\treturn {\n\t\ttype: 'RECEIVE_THEME_GLOBAL_STYLE_REVISIONS',\n\t\tcurrentId,\n\t\trevisions,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that the preview data for\n * a given URl has been received.\n * Ignored from documentation as it's internal to the data store.\n *\n * @ignore\n *\n * @param {string} url URL to preview the embed for.\n * @param {*} preview Preview data.\n *\n * @return {Object} Action object.\n */\nexport function receiveEmbedPreview( url, preview ) {\n\treturn {\n\t\ttype: 'RECEIVE_EMBED_PREVIEW',\n\t\turl,\n\t\tpreview,\n\t};\n}\n\n/**\n * Action triggered to delete an entity record.\n *\n * @param {string} kind Kind of the deleted entity.\n * @param {string} name Name of the deleted entity.\n * @param {string} recordId Record ID of the deleted entity.\n * @param {?Object} query Special query parameters for the\n * DELETE API call.\n * @param {Object} [options] Delete options.\n * @param {Function} [options.__unstableFetch] Internal use only. Function to\n * call instead of `apiFetch()`.\n * Must return a promise.\n * @param {boolean} [options.throwOnError=false] If false, this action suppresses all\n * the exceptions. Defaults to false.\n */\nexport const deleteEntityRecord =\n\t(\n\t\tkind,\n\t\tname,\n\t\trecordId,\n\t\tquery,\n\t\t{ __unstableFetch = apiFetch, throwOnError = false } = {}\n\t) =>\n\tasync ( { dispatch } ) => {\n\t\tconst configs = await dispatch( getOrLoadEntitiesConfig( kind, name ) );\n\t\tconst entityConfig = configs.find(\n\t\t\t( config ) => config.kind === kind && config.name === name\n\t\t);\n\t\tlet error;\n\t\tlet deletedRecord = false;\n\t\tif ( ! entityConfig ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst lock = await dispatch.__unstableAcquireStoreLock(\n\t\t\tSTORE_NAME,\n\t\t\t[ 'entities', 'records', kind, name, recordId ],\n\t\t\t{ exclusive: true }\n\t\t);\n\n\t\ttry {\n\t\t\tdispatch( {\n\t\t\t\ttype: 'DELETE_ENTITY_RECORD_START',\n\t\t\t\tkind,\n\t\t\t\tname,\n\t\t\t\trecordId,\n\t\t\t} );\n\n\t\t\tlet hasError = false;\n\t\t\ttry {\n\t\t\t\tlet path = `${ entityConfig.baseURL }/${ recordId }`;\n\n\t\t\t\tif ( query ) {\n\t\t\t\t\tpath = addQueryArgs( path, query );\n\t\t\t\t}\n\n\t\t\t\tdeletedRecord = await __unstableFetch( {\n\t\t\t\t\tpath,\n\t\t\t\t\tmethod: 'DELETE',\n\t\t\t\t} );\n\n\t\t\t\tawait dispatch( removeItems( kind, name, recordId, true ) );\n\t\t\t} catch ( _error ) {\n\t\t\t\thasError = true;\n\t\t\t\terror = _error;\n\t\t\t}\n\n\t\t\tdispatch( {\n\t\t\t\ttype: 'DELETE_ENTITY_RECORD_FINISH',\n\t\t\t\tkind,\n\t\t\t\tname,\n\t\t\t\trecordId,\n\t\t\t\terror,\n\t\t\t} );\n\n\t\t\tif ( hasError && throwOnError ) {\n\t\t\t\tthrow error;\n\t\t\t}\n\n\t\t\treturn deletedRecord;\n\t\t} finally {\n\t\t\tdispatch.__unstableReleaseStoreLock( lock );\n\t\t}\n\t};\n\n/**\n * Returns an action object that triggers an\n * edit to an entity record.\n *\n * @param {string} kind Kind of the edited entity record.\n * @param {string} name Name of the edited entity record.\n * @param {number|string} recordId Record ID of the edited entity record.\n * @param {Object} edits The edits.\n * @param {Object} options Options for the edit.\n * @param {boolean} [options.undoIgnore] Whether to ignore the edit in undo history or not.\n *\n * @return {Object} Action object.\n */\nexport const editEntityRecord =\n\t( kind, name, recordId, edits, options = {} ) =>\n\t( { select, dispatch } ) => {\n\t\tconst entityConfig = select.getEntityConfig( kind, name );\n\t\tif ( ! entityConfig ) {\n\t\t\tthrow new Error(\n\t\t\t\t`The entity being edited (${ kind }, ${ name }) does not have a loaded config.`\n\t\t\t);\n\t\t}\n\t\tconst { mergedEdits = {} } = entityConfig;\n\t\tconst record = select.getRawEntityRecord( kind, name, recordId );\n\t\tconst editedRecord = select.getEditedEntityRecord(\n\t\t\tkind,\n\t\t\tname,\n\t\t\trecordId\n\t\t);\n\n\t\tconst edit = {\n\t\t\tkind,\n\t\t\tname,\n\t\t\trecordId,\n\t\t\t// Clear edits when they are equal to their persisted counterparts\n\t\t\t// so that the property is not considered dirty.\n\t\t\tedits: Object.keys( edits ).reduce( ( acc, key ) => {\n\t\t\t\tconst recordValue = record[ key ];\n\t\t\t\tconst editedRecordValue = editedRecord[ key ];\n\t\t\t\tconst value = mergedEdits[ key ]\n\t\t\t\t\t? { ...editedRecordValue, ...edits[ key ] }\n\t\t\t\t\t: edits[ key ];\n\t\t\t\tacc[ key ] = fastDeepEqual( recordValue, value )\n\t\t\t\t\t? undefined\n\t\t\t\t\t: value;\n\t\t\t\treturn acc;\n\t\t\t}, {} ),\n\t\t};\n\t\tif ( window.__experimentalEnableSync && entityConfig.syncConfig ) {\n\t\t\tif ( globalThis.IS_GUTENBERG_PLUGIN ) {\n\t\t\t\tconst objectId = entityConfig.getSyncObjectId( recordId );\n\t\t\t\tgetSyncProvider().update(\n\t\t\t\t\tentityConfig.syncObjectType + '--edit',\n\t\t\t\t\tobjectId,\n\t\t\t\t\tedit.edits\n\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\tif ( ! options.undoIgnore ) {\n\t\t\t\tselect.getUndoManager().addRecord(\n\t\t\t\t\t[\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tid: { kind, name, recordId },\n\t\t\t\t\t\t\tchanges: Object.keys( edits ).reduce(\n\t\t\t\t\t\t\t\t( acc, key ) => {\n\t\t\t\t\t\t\t\t\tacc[ key ] = {\n\t\t\t\t\t\t\t\t\t\tfrom: editedRecord[ key ],\n\t\t\t\t\t\t\t\t\t\tto: 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\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t\toptions.isCached\n\t\t\t\t);\n\t\t\t}\n\t\t\tdispatch( {\n\t\t\t\ttype: 'EDIT_ENTITY_RECORD',\n\t\t\t\t...edit,\n\t\t\t} );\n\t\t}\n\t};\n\n/**\n * Action triggered to undo the last edit to\n * an entity record, if any.\n */\nexport const undo =\n\t() =>\n\t( { select, dispatch } ) => {\n\t\tconst undoRecord = select.getUndoManager().undo();\n\t\tif ( ! undoRecord ) {\n\t\t\treturn;\n\t\t}\n\t\tdispatch( {\n\t\t\ttype: 'UNDO',\n\t\t\trecord: undoRecord,\n\t\t} );\n\t};\n\n/**\n * Action triggered to redo the last undoed\n * edit to an entity record, if any.\n */\nexport const redo =\n\t() =>\n\t( { select, dispatch } ) => {\n\t\tconst redoRecord = select.getUndoManager().redo();\n\t\tif ( ! redoRecord ) {\n\t\t\treturn;\n\t\t}\n\t\tdispatch( {\n\t\t\ttype: 'REDO',\n\t\t\trecord: redoRecord,\n\t\t} );\n\t};\n\n/**\n * Forces the creation of a new undo level.\n *\n * @return {Object} Action object.\n */\nexport const __unstableCreateUndoLevel =\n\t() =>\n\t( { select } ) => {\n\t\tselect.getUndoManager().addRecord();\n\t};\n\n/**\n * Action triggered to save an entity record.\n *\n * @param {string} kind Kind of the received entity.\n * @param {string} name Name of the received entity.\n * @param {Object} record Record to be saved.\n * @param {Object} options Saving options.\n * @param {boolean} [options.isAutosave=false] Whether this is an autosave.\n * @param {Function} [options.__unstableFetch] Internal use only. Function to\n * call instead of `apiFetch()`.\n * Must return a promise.\n * @param {boolean} [options.throwOnError=false] If false, this action suppresses all\n * the exceptions. Defaults to false.\n */\nexport const saveEntityRecord =\n\t(\n\t\tkind,\n\t\tname,\n\t\trecord,\n\t\t{\n\t\t\tisAutosave = false,\n\t\t\t__unstableFetch = apiFetch,\n\t\t\tthrowOnError = false,\n\t\t} = {}\n\t) =>\n\tasync ( { select, resolveSelect, dispatch } ) => {\n\t\tconst configs = await dispatch( getOrLoadEntitiesConfig( kind, name ) );\n\t\tconst entityConfig = configs.find(\n\t\t\t( config ) => config.kind === kind && config.name === name\n\t\t);\n\t\tif ( ! entityConfig ) {\n\t\t\treturn;\n\t\t}\n\t\tconst entityIdKey = entityConfig.key || DEFAULT_ENTITY_KEY;\n\t\tconst recordId = record[ entityIdKey ];\n\n\t\tconst lock = await dispatch.__unstableAcquireStoreLock(\n\t\t\tSTORE_NAME,\n\t\t\t[ 'entities', 'records', kind, name, recordId || uuid() ],\n\t\t\t{ exclusive: true }\n\t\t);\n\n\t\ttry {\n\t\t\t// Evaluate optimized edits.\n\t\t\t// (Function edits that should be evaluated on save to avoid expensive computations on every edit.)\n\t\t\tfor ( const [ key, value ] of Object.entries( record ) ) {\n\t\t\t\tif ( typeof value === 'function' ) {\n\t\t\t\t\tconst evaluatedValue = value(\n\t\t\t\t\t\tselect.getEditedEntityRecord( kind, name, recordId )\n\t\t\t\t\t);\n\t\t\t\t\tdispatch.editEntityRecord(\n\t\t\t\t\t\tkind,\n\t\t\t\t\t\tname,\n\t\t\t\t\t\trecordId,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t[ key ]: evaluatedValue,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{ undoIgnore: true }\n\t\t\t\t\t);\n\t\t\t\t\trecord[ key ] = evaluatedValue;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tdispatch( {\n\t\t\t\ttype: 'SAVE_ENTITY_RECORD_START',\n\t\t\t\tkind,\n\t\t\t\tname,\n\t\t\t\trecordId,\n\t\t\t\tisAutosave,\n\t\t\t} );\n\t\t\tlet updatedRecord;\n\t\t\tlet error;\n\t\t\tlet hasError = false;\n\t\t\ttry {\n\t\t\t\tconst path = `${ entityConfig.baseURL }${\n\t\t\t\t\trecordId ? '/' + recordId : ''\n\t\t\t\t}`;\n\t\t\t\tconst persistedRecord = select.getRawEntityRecord(\n\t\t\t\t\tkind,\n\t\t\t\t\tname,\n\t\t\t\t\trecordId\n\t\t\t\t);\n\n\t\t\t\tif ( isAutosave ) {\n\t\t\t\t\t// Most of this autosave logic is very specific to posts.\n\t\t\t\t\t// This is fine for now as it is the only supported autosave,\n\t\t\t\t\t// but ideally this should all be handled in the back end,\n\t\t\t\t\t// so the client just sends and receives objects.\n\t\t\t\t\tconst currentUser = select.getCurrentUser();\n\t\t\t\t\tconst currentUserId = currentUser\n\t\t\t\t\t\t? currentUser.id\n\t\t\t\t\t\t: undefined;\n\t\t\t\t\tconst autosavePost = await resolveSelect.getAutosave(\n\t\t\t\t\t\tpersistedRecord.type,\n\t\t\t\t\t\tpersistedRecord.id,\n\t\t\t\t\t\tcurrentUserId\n\t\t\t\t\t);\n\t\t\t\t\t// Autosaves need all expected fields to be present.\n\t\t\t\t\t// So we fallback to the previous autosave and then\n\t\t\t\t\t// to the actual persisted entity if the edits don't\n\t\t\t\t\t// have a value.\n\t\t\t\t\tlet data = {\n\t\t\t\t\t\t...persistedRecord,\n\t\t\t\t\t\t...autosavePost,\n\t\t\t\t\t\t...record,\n\t\t\t\t\t};\n\t\t\t\t\tdata = Object.keys( data ).reduce(\n\t\t\t\t\t\t( acc, key ) => {\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t\t'title',\n\t\t\t\t\t\t\t\t\t'excerpt',\n\t\t\t\t\t\t\t\t\t'content',\n\t\t\t\t\t\t\t\t\t'meta',\n\t\t\t\t\t\t\t\t].includes( key )\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tacc[ key ] = data[ key ];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn acc;\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t// Do not update the `status` if we have edited it when auto saving.\n\t\t\t\t\t\t\t// It's very important to let the user explicitly save this change,\n\t\t\t\t\t\t\t// because it can lead to unexpected results. An example would be to\n\t\t\t\t\t\t\t// have a draft post and change the status to publish.\n\t\t\t\t\t\t\tstatus:\n\t\t\t\t\t\t\t\tdata.status === 'auto-draft'\n\t\t\t\t\t\t\t\t\t? 'draft'\n\t\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t\t\tupdatedRecord = await __unstableFetch( {\n\t\t\t\t\t\tpath: `${ path }/autosaves`,\n\t\t\t\t\t\tmethod: 'POST',\n\t\t\t\t\t\tdata,\n\t\t\t\t\t} );\n\n\t\t\t\t\t// An autosave may be processed by the server as a regular save\n\t\t\t\t\t// when its update is requested by the author and the post had\n\t\t\t\t\t// draft or auto-draft status.\n\t\t\t\t\tif ( persistedRecord.id === updatedRecord.id ) {\n\t\t\t\t\t\tlet newRecord = {\n\t\t\t\t\t\t\t...persistedRecord,\n\t\t\t\t\t\t\t...data,\n\t\t\t\t\t\t\t...updatedRecord,\n\t\t\t\t\t\t};\n\t\t\t\t\t\tnewRecord = Object.keys( newRecord ).reduce(\n\t\t\t\t\t\t\t( acc, key ) => {\n\t\t\t\t\t\t\t\t// These properties are persisted in autosaves.\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t[ 'title', 'excerpt', 'content' ].includes(\n\t\t\t\t\t\t\t\t\t\tkey\n\t\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\t\tacc[ key ] = newRecord[ key ];\n\t\t\t\t\t\t\t\t} else if ( key === 'status' ) {\n\t\t\t\t\t\t\t\t\t// Status is only persisted in autosaves when going from\n\t\t\t\t\t\t\t\t\t// \"auto-draft\" to \"draft\".\n\t\t\t\t\t\t\t\t\tacc[ key ] =\n\t\t\t\t\t\t\t\t\t\tpersistedRecord.status ===\n\t\t\t\t\t\t\t\t\t\t\t'auto-draft' &&\n\t\t\t\t\t\t\t\t\t\tnewRecord.status === 'draft'\n\t\t\t\t\t\t\t\t\t\t\t? newRecord.status\n\t\t\t\t\t\t\t\t\t\t\t: persistedRecord.status;\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t// These properties are not persisted in autosaves.\n\t\t\t\t\t\t\t\t\tacc[ key ] = persistedRecord[ key ];\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\treturn acc;\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\tdispatch.receiveEntityRecords(\n\t\t\t\t\t\t\tkind,\n\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\tnewRecord,\n\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\ttrue\n\t\t\t\t\t\t);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tdispatch.receiveAutosaves(\n\t\t\t\t\t\t\tpersistedRecord.id,\n\t\t\t\t\t\t\tupdatedRecord\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tlet edits = record;\n\t\t\t\t\tif ( entityConfig.__unstablePrePersist ) {\n\t\t\t\t\t\tedits = {\n\t\t\t\t\t\t\t...edits,\n\t\t\t\t\t\t\t...entityConfig.__unstablePrePersist(\n\t\t\t\t\t\t\t\tpersistedRecord,\n\t\t\t\t\t\t\t\tedits\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\tupdatedRecord = await __unstableFetch( {\n\t\t\t\t\t\tpath,\n\t\t\t\t\t\tmethod: recordId ? 'PUT' : 'POST',\n\t\t\t\t\t\tdata: edits,\n\t\t\t\t\t} );\n\t\t\t\t\tdispatch.receiveEntityRecords(\n\t\t\t\t\t\tkind,\n\t\t\t\t\t\tname,\n\t\t\t\t\t\tupdatedRecord,\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t\tedits\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} catch ( _error ) {\n\t\t\t\thasError = true;\n\t\t\t\terror = _error;\n\t\t\t}\n\t\t\tdispatch( {\n\t\t\t\ttype: 'SAVE_ENTITY_RECORD_FINISH',\n\t\t\t\tkind,\n\t\t\t\tname,\n\t\t\t\trecordId,\n\t\t\t\terror,\n\t\t\t\tisAutosave,\n\t\t\t} );\n\n\t\t\tif ( hasError && throwOnError ) {\n\t\t\t\tthrow error;\n\t\t\t}\n\n\t\t\treturn updatedRecord;\n\t\t} finally {\n\t\t\tdispatch.__unstableReleaseStoreLock( lock );\n\t\t}\n\t};\n\n/**\n * Runs multiple core-data actions at the same time using one API request.\n *\n * Example:\n *\n * ```\n * const [ savedRecord, updatedRecord, deletedRecord ] =\n * await dispatch( 'core' ).__experimentalBatch( [\n * ( { saveEntityRecord } ) => saveEntityRecord( 'root', 'widget', widget ),\n * ( { saveEditedEntityRecord } ) => saveEntityRecord( 'root', 'widget', 123 ),\n * ( { deleteEntityRecord } ) => deleteEntityRecord( 'root', 'widget', 123, null ),\n * ] );\n * ```\n *\n * @param {Array} requests Array of functions which are invoked simultaneously.\n * Each function is passed an object containing\n * `saveEntityRecord`, `saveEditedEntityRecord`, and\n * `deleteEntityRecord`.\n *\n * @return {(thunkArgs: Object) => Promise} A promise that resolves to an array containing the return\n * values of each function given in `requests`.\n */\nexport const __experimentalBatch =\n\t( requests ) =>\n\tasync ( { dispatch } ) => {\n\t\tconst batch = createBatch();\n\t\tconst api = {\n\t\t\tsaveEntityRecord( kind, name, record, options ) {\n\t\t\t\treturn batch.add( ( add ) =>\n\t\t\t\t\tdispatch.saveEntityRecord( kind, name, record, {\n\t\t\t\t\t\t...options,\n\t\t\t\t\t\t__unstableFetch: add,\n\t\t\t\t\t} )\n\t\t\t\t);\n\t\t\t},\n\t\t\tsaveEditedEntityRecord( kind, name, recordId, options ) {\n\t\t\t\treturn batch.add( ( add ) =>\n\t\t\t\t\tdispatch.saveEditedEntityRecord( kind, name, recordId, {\n\t\t\t\t\t\t...options,\n\t\t\t\t\t\t__unstableFetch: add,\n\t\t\t\t\t} )\n\t\t\t\t);\n\t\t\t},\n\t\t\tdeleteEntityRecord( kind, name, recordId, query, options ) {\n\t\t\t\treturn batch.add( ( add ) =>\n\t\t\t\t\tdispatch.deleteEntityRecord( kind, name, recordId, query, {\n\t\t\t\t\t\t...options,\n\t\t\t\t\t\t__unstableFetch: add,\n\t\t\t\t\t} )\n\t\t\t\t);\n\t\t\t},\n\t\t};\n\t\tconst resultPromises = requests.map( ( request ) => request( api ) );\n\t\tconst [ , ...results ] = await Promise.all( [\n\t\t\tbatch.run(),\n\t\t\t...resultPromises,\n\t\t] );\n\t\treturn results;\n\t};\n\n/**\n * Action triggered to save an entity record's edits.\n *\n * @param {string} kind Kind of the entity.\n * @param {string} name Name of the entity.\n * @param {Object} recordId ID of the record.\n * @param {Object=} options Saving options.\n */\nexport const saveEditedEntityRecord =\n\t( kind, name, recordId, options ) =>\n\tasync ( { select, dispatch } ) => {\n\t\tif ( ! select.hasEditsForEntityRecord( kind, name, recordId ) ) {\n\t\t\treturn;\n\t\t}\n\t\tconst configs = await dispatch( getOrLoadEntitiesConfig( kind, name ) );\n\t\tconst entityConfig = configs.find(\n\t\t\t( config ) => config.kind === kind && config.name === name\n\t\t);\n\t\tif ( ! entityConfig ) {\n\t\t\treturn;\n\t\t}\n\t\tconst entityIdKey = entityConfig.key || DEFAULT_ENTITY_KEY;\n\n\t\tconst edits = select.getEntityRecordNonTransientEdits(\n\t\t\tkind,\n\t\t\tname,\n\t\t\trecordId\n\t\t);\n\t\tconst record = { [ entityIdKey ]: recordId, ...edits };\n\t\treturn await dispatch.saveEntityRecord( kind, name, record, options );\n\t};\n\n/**\n * Action triggered to save only specified properties for the entity.\n *\n * @param {string} kind Kind of the entity.\n * @param {string} name Name of the entity.\n * @param {Object} recordId ID of the record.\n * @param {Array} itemsToSave List of entity properties or property paths to save.\n * @param {Object} options Saving options.\n */\nexport const __experimentalSaveSpecifiedEntityEdits =\n\t( kind, name, recordId, itemsToSave, options ) =>\n\tasync ( { select, dispatch } ) => {\n\t\tif ( ! select.hasEditsForEntityRecord( kind, name, recordId ) ) {\n\t\t\treturn;\n\t\t}\n\t\tconst edits = select.getEntityRecordNonTransientEdits(\n\t\t\tkind,\n\t\t\tname,\n\t\t\trecordId\n\t\t);\n\t\tconst editsToSave = {};\n\n\t\tfor ( const item of itemsToSave ) {\n\t\t\tsetNestedValue( editsToSave, item, getNestedValue( edits, item ) );\n\t\t}\n\n\t\tconst configs = await dispatch( getOrLoadEntitiesConfig( kind, name ) );\n\t\tconst entityConfig = configs.find(\n\t\t\t( config ) => config.kind === kind && config.name === name\n\t\t);\n\n\t\tconst entityIdKey = entityConfig?.key || DEFAULT_ENTITY_KEY;\n\n\t\t// If a record key is provided then update the existing record.\n\t\t// This necessitates providing `recordKey` to saveEntityRecord as part of the\n\t\t// `record` argument (here called `editsToSave`) to stop that action creating\n\t\t// a new record and instead cause it to update the existing record.\n\t\tif ( recordId ) {\n\t\t\teditsToSave[ entityIdKey ] = recordId;\n\t\t}\n\t\treturn await dispatch.saveEntityRecord(\n\t\t\tkind,\n\t\t\tname,\n\t\t\teditsToSave,\n\t\t\toptions\n\t\t);\n\t};\n\n/**\n * Returns an action object used in signalling that Upload permissions have been received.\n *\n * @deprecated since WP 5.9, use receiveUserPermission instead.\n *\n * @param {boolean} hasUploadPermissions Does the user have permission to upload files?\n *\n * @return {Object} Action object.\n */\nexport function receiveUploadPermissions( hasUploadPermissions ) {\n\tdeprecated( \"wp.data.dispatch( 'core' ).receiveUploadPermissions\", {\n\t\tsince: '5.9',\n\t\talternative: 'receiveUserPermission',\n\t} );\n\n\treturn receiveUserPermission( 'create/media', hasUploadPermissions );\n}\n\n/**\n * Returns an action object used in signalling that the current user has\n * permission to perform an action on a REST resource.\n * Ignored from documentation as it's internal to the data store.\n *\n * @ignore\n *\n * @param {string} key A key that represents the action and REST resource.\n * @param {boolean} isAllowed Whether or not the user can perform the action.\n *\n * @return {Object} Action object.\n */\nexport function receiveUserPermission( key, isAllowed ) {\n\treturn {\n\t\ttype: 'RECEIVE_USER_PERMISSION',\n\t\tkey,\n\t\tisAllowed,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that the autosaves for a\n * post have been received.\n * Ignored from documentation as it's internal to the data store.\n *\n * @ignore\n *\n * @param {number} postId The id of the post that is parent to the autosave.\n * @param {Array|Object} autosaves An array of autosaves or singular autosave object.\n *\n * @return {Object} Action object.\n */\nexport function receiveAutosaves( postId, autosaves ) {\n\treturn {\n\t\ttype: 'RECEIVE_AUTOSAVES',\n\t\tpostId,\n\t\tautosaves: Array.isArray( autosaves ) ? autosaves : [ autosaves ],\n\t};\n}\n\n/**\n * Returns an action object signalling that the fallback Navigation\n * Menu id has been received.\n *\n * @param {integer} fallbackId the id of the fallback Navigation Menu\n * @return {Object} Action object.\n */\nexport function receiveNavigationFallbackId( fallbackId ) {\n\treturn {\n\t\ttype: 'RECEIVE_NAVIGATION_FALLBACK_ID',\n\t\tfallbackId,\n\t};\n}\n\n/**\n * Returns an action object used to set the template for a given query.\n *\n * @param {Object} query The lookup query.\n * @param {string} templateId The resolved template id.\n *\n * @return {Object} Action object.\n */\nexport function receiveDefaultTemplateId( query, templateId ) {\n\treturn {\n\t\ttype: 'RECEIVE_DEFAULT_TEMPLATE',\n\t\tquery,\n\t\ttemplateId,\n\t};\n}\n\n/**\n * Action triggered to receive revision items.\n *\n * @param {string} kind Kind of the received entity record revisions.\n * @param {string} name Name of the received entity record revisions.\n * @param {number|string} recordKey The key of the entity record whose revisions you want to fetch.\n * @param {Array|Object} records Revisions received.\n * @param {?Object} query Query Object.\n * @param {?boolean} invalidateCache Should invalidate query caches.\n * @param {?Object} meta Meta information about pagination.\n */\nexport const receiveRevisions =\n\t( kind, name, recordKey, records, query, invalidateCache = false, meta ) =>\n\tasync ( { dispatch } ) => {\n\t\tconst configs = await dispatch( getOrLoadEntitiesConfig( kind, name ) );\n\t\tconst entityConfig = configs.find(\n\t\t\t( config ) => config.kind === kind && config.name === name\n\t\t);\n\t\tconst key =\n\t\t\tentityConfig && entityConfig?.revisionKey\n\t\t\t\t? entityConfig.revisionKey\n\t\t\t\t: DEFAULT_ENTITY_KEY;\n\n\t\tdispatch( {\n\t\t\ttype: 'RECEIVE_ITEM_REVISIONS',\n\t\t\tkey,\n\t\t\titems: Array.isArray( records ) ? records : [ records ],\n\t\t\trecordKey,\n\t\t\tmeta,\n\t\t\tquery,\n\t\t\tkind,\n\t\t\tname,\n\t\t\tinvalidateCache,\n\t\t} );\n\t};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,IAAAA,GAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AAKA,IAAAE,SAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,IAAA,GAAAH,OAAA;AACA,IAAAI,WAAA,GAAAL,sBAAA,CAAAC,OAAA;AAKA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,YAAA,GAAAN,OAAA;AACA,IAAAO,SAAA,GAAAP,OAAA;AACA,IAAAQ,MAAA,GAAAR,OAAA;AACA,IAAAS,KAAA,GAAAT,OAAA;AACA,IAAAU,KAAA,GAAAV,OAAA;AArBA;AACA;AACA;;AAIA;AACA;AACA;;AAKA;AACA;AACA;;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASW,gBAAgBA,CAAEC,OAAO,EAA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AI;IACJG;EACD,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASU,mBAAmBA,CAAEC,YAAY,EAAG;EACnD,OAAO;IACNvB,IAAI,EAAE,uBAAuB;IAC7BuB;EACD,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,0CAA0CA,CACzDC,qBAAqB,EACpB;EACD,OAAO;IACNzB,IAAI,EAAE,kCAAkC;IACxC0B,EAAE,EAAED;EACL,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASE,0CAA0CA,CACzDC,UAAU,EACVC,YAAY,EACX;EACD,OAAO;IACN7B,IAAI,EAAE,6BAA6B;IACnC4B,UAAU;IACVC;EACD,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,+CAA+CA,CAC9DF,UAAU,EACVG,UAAU,EACT;EACD,OAAO;IACN/B,IAAI,EAAE,uCAAuC;IAC7C4B,UAAU;IACVG;EACD,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,oBAAoBA,CAAA,EAAG;EACtC,IAAAC,mBAAU,EAAE,iDAAiD,EAAE;IAC9DC,KAAK,EAAE;EACR,CAAE,CAAC;EAEH,OAAO;IACNlC,IAAI,EAAE;EACP,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASmC,gCAAgCA,CAAEC,SAAS,EAAEC,SAAS,EAAG;EACxE,IAAAJ,mBAAU,EACT,+DAA+D,EAC/D;IACCC,KAAK,EAAE,OAAO;IACdI,WAAW,EAAE;EACd,CACD,CAAC;EACD,OAAO;IACNtC,IAAI,EAAE,sCAAsC;IAC5CoC,SAAS;IACTC;EACD,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;A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KAAK,EAAEE,IAAI,KACtE,OAAQ;EAAEiC;AAAS,CAAC,KAAM;EACzB,MAAMC,OAAO,GAAG,MAAMD,QAAQ,CAAE,IAAAE,iCAAuB,EAAEzC,IAAI,EAAEC,IAAK,CAAE,CAAC;EACvE,MAAMyC,YAAY,GAAGF,OAAO,CAACG,IAAI,CAC9BC,MAAM,IAAMA,MAAM,CAAC5C,IAAI,KAAKA,IAAI,IAAI4C,MAAM,CAAC3C,IAAI,KAAKA,IACvD,CAAC;EACD,MAAMyE,GAAG,GACRhC,YAAY,IAAIA,YAAY,EAAEgH,WAAW,GACtChH,YAAY,CAACgH,WAAW,GACxBhD,4BAAkB;EAEtBnE,QAAQ,CAAE;IACT/C,IAAI,EAAE,wBAAwB;IAC9BkF,GAAG;IACHiF,KAAK,EAAElK,KAAK,CAACC,OAAO,CAAEQ,OAAQ,CAAC,GAAGA,OAAO,GAAG,CAAEA,OAAO,CAAE;IACvDuJ,SAAS;IACTnJ,IAAI;IACJH,KAAK;IACLH,IAAI;IACJC,IAAI;IACJG;EACD,CAAE,CAAC;AACJ,CAAC;AAACuD,OAAA,CAAA6F,gBAAA,GAAAA,gBAAA","ignoreList":[]}
1
+ {"version":3,"names":["_es","_interopRequireDefault","require","_uuid","_apiFetch","_url","_deprecated","_utils","_queriedData","_entities","_batch","_name","_sync","receiveUserQuery","queryID","users","type","Array","isArray","receiveCurrentUser","currentUser","addEntities","entities","receiveEntityRecords","kind","name","records","query","invalidateCache","edits","meta","map","record","status","title","action","receiveQueriedItems","receiveItems","receiveCurrentTheme","currentTheme","__experimentalReceiveCurrentGlobalStylesId","currentGlobalStylesId","id","__experimentalReceiveThemeBaseGlobalStyles","stylesheet","globalStyles","__experimentalReceiveThemeGlobalStyleVariations","variations","receiveThemeSupports","deprecated","since","receiveThemeGlobalStyleRevisions","currentId","revisions","alternative","receiveEmbedPreview","url","preview","deleteEntityRecord","recordId","__unstableFetch","apiFetch","throwOnError","dispatch","configs","getOrLoadEntitiesConfig","entityConfig","find","config","error","deletedRecord","lock","__unstableAcquireStoreLock","STORE_NAME","exclusive","hasError","path","baseURL","addQueryArgs","method","removeItems","_error","__unstableReleaseStoreLock","exports","editEntityRecord","options","select","getEntityConfig","Error","mergedEdits","getRawEntityRecord","editedRecord","getEditedEntityRecord","edit","Object","keys","reduce","acc","key","recordValue","editedRecordValue","value","fastDeepEqual","undefined","window","__experimentalEnableSync","syncConfig","globalThis","IS_GUTENBERG_PLUGIN","objectId","getSyncObjectId","getSyncProvider","update","syncObjectType","undoIgnore","getUndoManager","addRecord","changes","from","to","isCached","undo","undoRecord","redo","redoRecord","__unstableCreateUndoLevel","saveEntityRecord","isAutosave","resolveSelect","entityIdKey","DEFAULT_ENTITY_KEY","uuid","entries","evaluatedValue","updatedRecord","persistedRecord","getCurrentUser","currentUserId","autosavePost","getAutosave","data","includes","newRecord","receiveAutosaves","__unstablePrePersist","__experimentalBatch","requests","batch","createBatch","api","add","saveEditedEntityRecord","resultPromises","request","results","Promise","all","run","hasEditsForEntityRecord","getEntityRecordNonTransientEdits","__experimentalSaveSpecifiedEntityEdits","itemsToSave","editsToSave","item","setNestedValue","getNestedValue","receiveUploadPermissions","hasUploadPermissions","receiveUserPermission","isAllowed","receiveUserPermissions","permissions","postId","autosaves","receiveNavigationFallbackId","fallbackId","receiveDefaultTemplateId","templateId","receiveRevisions","recordKey","revisionKey","items"],"sources":["@wordpress/core-data/src/actions.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport fastDeepEqual from 'fast-deep-equal/es6';\nimport { v4 as uuid } from 'uuid';\n\n/**\n * WordPress dependencies\n */\nimport apiFetch from '@wordpress/api-fetch';\nimport { addQueryArgs } from '@wordpress/url';\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport { getNestedValue, setNestedValue } from './utils';\nimport { receiveItems, removeItems, receiveQueriedItems } from './queried-data';\nimport { getOrLoadEntitiesConfig, DEFAULT_ENTITY_KEY } from './entities';\nimport { createBatch } from './batch';\nimport { STORE_NAME } from './name';\nimport { getSyncProvider } from './sync';\n\n/**\n * Returns an action object used in signalling that authors have been received.\n * Ignored from documentation as it's internal to the data store.\n *\n * @ignore\n *\n * @param {string} queryID Query ID.\n * @param {Array|Object} users Users received.\n *\n * @return {Object} Action object.\n */\nexport function receiveUserQuery( queryID, users ) {\n\treturn {\n\t\ttype: 'RECEIVE_USER_QUERY',\n\t\tusers: Array.isArray( users ) ? users : [ users ],\n\t\tqueryID,\n\t};\n}\n\n/**\n * Returns an action used in signalling that the current user has been received.\n * Ignored from documentation as it's internal to the data store.\n *\n * @ignore\n *\n * @param {Object} currentUser Current user object.\n *\n * @return {Object} Action object.\n */\nexport function receiveCurrentUser( currentUser ) {\n\treturn {\n\t\ttype: 'RECEIVE_CURRENT_USER',\n\t\tcurrentUser,\n\t};\n}\n\n/**\n * Returns an action object used in adding new entities.\n *\n * @param {Array} entities Entities received.\n *\n * @return {Object} Action object.\n */\nexport function addEntities( entities ) {\n\treturn {\n\t\ttype: 'ADD_ENTITIES',\n\t\tentities,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that entity records have been received.\n *\n * @param {string} kind Kind of the received entity record.\n * @param {string} name Name of the received entity record.\n * @param {Array|Object} records Records received.\n * @param {?Object} query Query Object.\n * @param {?boolean} invalidateCache Should invalidate query caches.\n * @param {?Object} edits Edits to reset.\n * @param {?Object} meta Meta information about pagination.\n * @return {Object} Action object.\n */\nexport function receiveEntityRecords(\n\tkind,\n\tname,\n\trecords,\n\tquery,\n\tinvalidateCache = false,\n\tedits,\n\tmeta\n) {\n\t// Auto drafts should not have titles, but some plugins rely on them so we can't filter this\n\t// on the server.\n\tif ( kind === 'postType' ) {\n\t\trecords = ( Array.isArray( records ) ? records : [ records ] ).map(\n\t\t\t( record ) =>\n\t\t\t\trecord.status === 'auto-draft'\n\t\t\t\t\t? { ...record, title: '' }\n\t\t\t\t\t: record\n\t\t);\n\t}\n\tlet action;\n\tif ( query ) {\n\t\taction = receiveQueriedItems( records, query, edits, meta );\n\t} else {\n\t\taction = receiveItems( records, edits, meta );\n\t}\n\n\treturn {\n\t\t...action,\n\t\tkind,\n\t\tname,\n\t\tinvalidateCache,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that the current theme has been received.\n * Ignored from documentation as it's internal to the data store.\n *\n * @ignore\n *\n * @param {Object} currentTheme The current theme.\n *\n * @return {Object} Action object.\n */\nexport function receiveCurrentTheme( currentTheme ) {\n\treturn {\n\t\ttype: 'RECEIVE_CURRENT_THEME',\n\t\tcurrentTheme,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that the current global styles id has been received.\n * Ignored from documentation as it's internal to the data store.\n *\n * @ignore\n *\n * @param {string} currentGlobalStylesId The current global styles id.\n *\n * @return {Object} Action object.\n */\nexport function __experimentalReceiveCurrentGlobalStylesId(\n\tcurrentGlobalStylesId\n) {\n\treturn {\n\t\ttype: 'RECEIVE_CURRENT_GLOBAL_STYLES_ID',\n\t\tid: currentGlobalStylesId,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that the theme base global styles have been received\n * Ignored from documentation as it's internal to the data store.\n *\n * @ignore\n *\n * @param {string} stylesheet The theme's identifier\n * @param {Object} globalStyles The global styles object.\n *\n * @return {Object} Action object.\n */\nexport function __experimentalReceiveThemeBaseGlobalStyles(\n\tstylesheet,\n\tglobalStyles\n) {\n\treturn {\n\t\ttype: 'RECEIVE_THEME_GLOBAL_STYLES',\n\t\tstylesheet,\n\t\tglobalStyles,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that the theme global styles variations have been received.\n * Ignored from documentation as it's internal to the data store.\n *\n * @ignore\n *\n * @param {string} stylesheet The theme's identifier\n * @param {Array} variations The global styles variations.\n *\n * @return {Object} Action object.\n */\nexport function __experimentalReceiveThemeGlobalStyleVariations(\n\tstylesheet,\n\tvariations\n) {\n\treturn {\n\t\ttype: 'RECEIVE_THEME_GLOBAL_STYLE_VARIATIONS',\n\t\tstylesheet,\n\t\tvariations,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that the index has been received.\n *\n * @deprecated since WP 5.9, this is not useful anymore, use the selector directly.\n *\n * @return {Object} Action object.\n */\nexport function receiveThemeSupports() {\n\tdeprecated( \"wp.data.dispatch( 'core' ).receiveThemeSupports\", {\n\t\tsince: '5.9',\n\t} );\n\n\treturn {\n\t\ttype: 'DO_NOTHING',\n\t};\n}\n\n/**\n * Returns an action object used in signalling that the theme global styles CPT post revisions have been received.\n * Ignored from documentation as it's internal to the data store.\n *\n * @deprecated since WordPress 6.5.0. Callers should use `dispatch( 'core' ).receiveRevision` instead.\n *\n * @ignore\n *\n * @param {number} currentId The post id.\n * @param {Array} revisions The global styles revisions.\n *\n * @return {Object} Action object.\n */\nexport function receiveThemeGlobalStyleRevisions( currentId, revisions ) {\n\tdeprecated(\n\t\t\"wp.data.dispatch( 'core' ).receiveThemeGlobalStyleRevisions()\",\n\t\t{\n\t\t\tsince: '6.5.0',\n\t\t\talternative: \"wp.data.dispatch( 'core' ).receiveRevisions\",\n\t\t}\n\t);\n\treturn {\n\t\ttype: 'RECEIVE_THEME_GLOBAL_STYLE_REVISIONS',\n\t\tcurrentId,\n\t\trevisions,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that the preview data for\n * a given URl has been received.\n * Ignored from documentation as it's internal to the data store.\n *\n * @ignore\n *\n * @param {string} url URL to preview the embed for.\n * @param {*} preview Preview data.\n *\n * @return {Object} Action object.\n */\nexport function receiveEmbedPreview( url, preview ) {\n\treturn {\n\t\ttype: 'RECEIVE_EMBED_PREVIEW',\n\t\turl,\n\t\tpreview,\n\t};\n}\n\n/**\n * Action triggered to delete an entity record.\n *\n * @param {string} kind Kind of the deleted entity.\n * @param {string} name Name of the deleted entity.\n * @param {number|string} recordId Record ID of the deleted entity.\n * @param {?Object} query Special query parameters for the\n * DELETE API call.\n * @param {Object} [options] Delete options.\n * @param {Function} [options.__unstableFetch] Internal use only. Function to\n * call instead of `apiFetch()`.\n * Must return a promise.\n * @param {boolean} [options.throwOnError=false] If false, this action suppresses all\n * the exceptions. Defaults to false.\n */\nexport const deleteEntityRecord =\n\t(\n\t\tkind,\n\t\tname,\n\t\trecordId,\n\t\tquery,\n\t\t{ __unstableFetch = apiFetch, throwOnError = false } = {}\n\t) =>\n\tasync ( { dispatch } ) => {\n\t\tconst configs = await dispatch( getOrLoadEntitiesConfig( kind, name ) );\n\t\tconst entityConfig = configs.find(\n\t\t\t( config ) => config.kind === kind && config.name === name\n\t\t);\n\t\tlet error;\n\t\tlet deletedRecord = false;\n\t\tif ( ! entityConfig ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst lock = await dispatch.__unstableAcquireStoreLock(\n\t\t\tSTORE_NAME,\n\t\t\t[ 'entities', 'records', kind, name, recordId ],\n\t\t\t{ exclusive: true }\n\t\t);\n\n\t\ttry {\n\t\t\tdispatch( {\n\t\t\t\ttype: 'DELETE_ENTITY_RECORD_START',\n\t\t\t\tkind,\n\t\t\t\tname,\n\t\t\t\trecordId,\n\t\t\t} );\n\n\t\t\tlet hasError = false;\n\t\t\ttry {\n\t\t\t\tlet path = `${ entityConfig.baseURL }/${ recordId }`;\n\n\t\t\t\tif ( query ) {\n\t\t\t\t\tpath = addQueryArgs( path, query );\n\t\t\t\t}\n\n\t\t\t\tdeletedRecord = await __unstableFetch( {\n\t\t\t\t\tpath,\n\t\t\t\t\tmethod: 'DELETE',\n\t\t\t\t} );\n\n\t\t\t\tawait dispatch( removeItems( kind, name, recordId, true ) );\n\t\t\t} catch ( _error ) {\n\t\t\t\thasError = true;\n\t\t\t\terror = _error;\n\t\t\t}\n\n\t\t\tdispatch( {\n\t\t\t\ttype: 'DELETE_ENTITY_RECORD_FINISH',\n\t\t\t\tkind,\n\t\t\t\tname,\n\t\t\t\trecordId,\n\t\t\t\terror,\n\t\t\t} );\n\n\t\t\tif ( hasError && throwOnError ) {\n\t\t\t\tthrow error;\n\t\t\t}\n\n\t\t\treturn deletedRecord;\n\t\t} finally {\n\t\t\tdispatch.__unstableReleaseStoreLock( lock );\n\t\t}\n\t};\n\n/**\n * Returns an action object that triggers an\n * edit to an entity record.\n *\n * @param {string} kind Kind of the edited entity record.\n * @param {string} name Name of the edited entity record.\n * @param {number|string} recordId Record ID of the edited entity record.\n * @param {Object} edits The edits.\n * @param {Object} options Options for the edit.\n * @param {boolean} [options.undoIgnore] Whether to ignore the edit in undo history or not.\n *\n * @return {Object} Action object.\n */\nexport const editEntityRecord =\n\t( kind, name, recordId, edits, options = {} ) =>\n\t( { select, dispatch } ) => {\n\t\tconst entityConfig = select.getEntityConfig( kind, name );\n\t\tif ( ! entityConfig ) {\n\t\t\tthrow new Error(\n\t\t\t\t`The entity being edited (${ kind }, ${ name }) does not have a loaded config.`\n\t\t\t);\n\t\t}\n\t\tconst { mergedEdits = {} } = entityConfig;\n\t\tconst record = select.getRawEntityRecord( kind, name, recordId );\n\t\tconst editedRecord = select.getEditedEntityRecord(\n\t\t\tkind,\n\t\t\tname,\n\t\t\trecordId\n\t\t);\n\n\t\tconst edit = {\n\t\t\tkind,\n\t\t\tname,\n\t\t\trecordId,\n\t\t\t// Clear edits when they are equal to their persisted counterparts\n\t\t\t// so that the property is not considered dirty.\n\t\t\tedits: Object.keys( edits ).reduce( ( acc, key ) => {\n\t\t\t\tconst recordValue = record[ key ];\n\t\t\t\tconst editedRecordValue = editedRecord[ key ];\n\t\t\t\tconst value = mergedEdits[ key ]\n\t\t\t\t\t? { ...editedRecordValue, ...edits[ key ] }\n\t\t\t\t\t: edits[ key ];\n\t\t\t\tacc[ key ] = fastDeepEqual( recordValue, value )\n\t\t\t\t\t? undefined\n\t\t\t\t\t: value;\n\t\t\t\treturn acc;\n\t\t\t}, {} ),\n\t\t};\n\t\tif ( window.__experimentalEnableSync && entityConfig.syncConfig ) {\n\t\t\tif ( globalThis.IS_GUTENBERG_PLUGIN ) {\n\t\t\t\tconst objectId = entityConfig.getSyncObjectId( recordId );\n\t\t\t\tgetSyncProvider().update(\n\t\t\t\t\tentityConfig.syncObjectType + '--edit',\n\t\t\t\t\tobjectId,\n\t\t\t\t\tedit.edits\n\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\tif ( ! options.undoIgnore ) {\n\t\t\t\tselect.getUndoManager().addRecord(\n\t\t\t\t\t[\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tid: { kind, name, recordId },\n\t\t\t\t\t\t\tchanges: Object.keys( edits ).reduce(\n\t\t\t\t\t\t\t\t( acc, key ) => {\n\t\t\t\t\t\t\t\t\tacc[ key ] = {\n\t\t\t\t\t\t\t\t\t\tfrom: editedRecord[ key ],\n\t\t\t\t\t\t\t\t\t\tto: 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\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t\toptions.isCached\n\t\t\t\t);\n\t\t\t}\n\t\t\tdispatch( {\n\t\t\t\ttype: 'EDIT_ENTITY_RECORD',\n\t\t\t\t...edit,\n\t\t\t} );\n\t\t}\n\t};\n\n/**\n * Action triggered to undo the last edit to\n * an entity record, if any.\n */\nexport const undo =\n\t() =>\n\t( { select, dispatch } ) => {\n\t\tconst undoRecord = select.getUndoManager().undo();\n\t\tif ( ! undoRecord ) {\n\t\t\treturn;\n\t\t}\n\t\tdispatch( {\n\t\t\ttype: 'UNDO',\n\t\t\trecord: undoRecord,\n\t\t} );\n\t};\n\n/**\n * Action triggered to redo the last undoed\n * edit to an entity record, if any.\n */\nexport const redo =\n\t() =>\n\t( { select, dispatch } ) => {\n\t\tconst redoRecord = select.getUndoManager().redo();\n\t\tif ( ! redoRecord ) {\n\t\t\treturn;\n\t\t}\n\t\tdispatch( {\n\t\t\ttype: 'REDO',\n\t\t\trecord: redoRecord,\n\t\t} );\n\t};\n\n/**\n * Forces the creation of a new undo level.\n *\n * @return {Object} Action object.\n */\nexport const __unstableCreateUndoLevel =\n\t() =>\n\t( { select } ) => {\n\t\tselect.getUndoManager().addRecord();\n\t};\n\n/**\n * Action triggered to save an entity record.\n *\n * @param {string} kind Kind of the received entity.\n * @param {string} name Name of the received entity.\n * @param {Object} record Record to be saved.\n * @param {Object} options Saving options.\n * @param {boolean} [options.isAutosave=false] Whether this is an autosave.\n * @param {Function} [options.__unstableFetch] Internal use only. Function to\n * call instead of `apiFetch()`.\n * Must return a promise.\n * @param {boolean} [options.throwOnError=false] If false, this action suppresses all\n * the exceptions. Defaults to false.\n */\nexport const saveEntityRecord =\n\t(\n\t\tkind,\n\t\tname,\n\t\trecord,\n\t\t{\n\t\t\tisAutosave = false,\n\t\t\t__unstableFetch = apiFetch,\n\t\t\tthrowOnError = false,\n\t\t} = {}\n\t) =>\n\tasync ( { select, resolveSelect, dispatch } ) => {\n\t\tconst configs = await dispatch( getOrLoadEntitiesConfig( kind, name ) );\n\t\tconst entityConfig = configs.find(\n\t\t\t( config ) => config.kind === kind && config.name === name\n\t\t);\n\t\tif ( ! entityConfig ) {\n\t\t\treturn;\n\t\t}\n\t\tconst entityIdKey = entityConfig.key || DEFAULT_ENTITY_KEY;\n\t\tconst recordId = record[ entityIdKey ];\n\n\t\tconst lock = await dispatch.__unstableAcquireStoreLock(\n\t\t\tSTORE_NAME,\n\t\t\t[ 'entities', 'records', kind, name, recordId || uuid() ],\n\t\t\t{ exclusive: true }\n\t\t);\n\n\t\ttry {\n\t\t\t// Evaluate optimized edits.\n\t\t\t// (Function edits that should be evaluated on save to avoid expensive computations on every edit.)\n\t\t\tfor ( const [ key, value ] of Object.entries( record ) ) {\n\t\t\t\tif ( typeof value === 'function' ) {\n\t\t\t\t\tconst evaluatedValue = value(\n\t\t\t\t\t\tselect.getEditedEntityRecord( kind, name, recordId )\n\t\t\t\t\t);\n\t\t\t\t\tdispatch.editEntityRecord(\n\t\t\t\t\t\tkind,\n\t\t\t\t\t\tname,\n\t\t\t\t\t\trecordId,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t[ key ]: evaluatedValue,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{ undoIgnore: true }\n\t\t\t\t\t);\n\t\t\t\t\trecord[ key ] = evaluatedValue;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tdispatch( {\n\t\t\t\ttype: 'SAVE_ENTITY_RECORD_START',\n\t\t\t\tkind,\n\t\t\t\tname,\n\t\t\t\trecordId,\n\t\t\t\tisAutosave,\n\t\t\t} );\n\t\t\tlet updatedRecord;\n\t\t\tlet error;\n\t\t\tlet hasError = false;\n\t\t\ttry {\n\t\t\t\tconst path = `${ entityConfig.baseURL }${\n\t\t\t\t\trecordId ? '/' + recordId : ''\n\t\t\t\t}`;\n\t\t\t\tconst persistedRecord = select.getRawEntityRecord(\n\t\t\t\t\tkind,\n\t\t\t\t\tname,\n\t\t\t\t\trecordId\n\t\t\t\t);\n\n\t\t\t\tif ( isAutosave ) {\n\t\t\t\t\t// Most of this autosave logic is very specific to posts.\n\t\t\t\t\t// This is fine for now as it is the only supported autosave,\n\t\t\t\t\t// but ideally this should all be handled in the back end,\n\t\t\t\t\t// so the client just sends and receives objects.\n\t\t\t\t\tconst currentUser = select.getCurrentUser();\n\t\t\t\t\tconst currentUserId = currentUser\n\t\t\t\t\t\t? currentUser.id\n\t\t\t\t\t\t: undefined;\n\t\t\t\t\tconst autosavePost = await resolveSelect.getAutosave(\n\t\t\t\t\t\tpersistedRecord.type,\n\t\t\t\t\t\tpersistedRecord.id,\n\t\t\t\t\t\tcurrentUserId\n\t\t\t\t\t);\n\t\t\t\t\t// Autosaves need all expected fields to be present.\n\t\t\t\t\t// So we fallback to the previous autosave and then\n\t\t\t\t\t// to the actual persisted entity if the edits don't\n\t\t\t\t\t// have a value.\n\t\t\t\t\tlet data = {\n\t\t\t\t\t\t...persistedRecord,\n\t\t\t\t\t\t...autosavePost,\n\t\t\t\t\t\t...record,\n\t\t\t\t\t};\n\t\t\t\t\tdata = Object.keys( data ).reduce(\n\t\t\t\t\t\t( acc, key ) => {\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t\t'title',\n\t\t\t\t\t\t\t\t\t'excerpt',\n\t\t\t\t\t\t\t\t\t'content',\n\t\t\t\t\t\t\t\t\t'meta',\n\t\t\t\t\t\t\t\t].includes( key )\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tacc[ key ] = data[ key ];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn acc;\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t// Do not update the `status` if we have edited it when auto saving.\n\t\t\t\t\t\t\t// It's very important to let the user explicitly save this change,\n\t\t\t\t\t\t\t// because it can lead to unexpected results. An example would be to\n\t\t\t\t\t\t\t// have a draft post and change the status to publish.\n\t\t\t\t\t\t\tstatus:\n\t\t\t\t\t\t\t\tdata.status === 'auto-draft'\n\t\t\t\t\t\t\t\t\t? 'draft'\n\t\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t\t\tupdatedRecord = await __unstableFetch( {\n\t\t\t\t\t\tpath: `${ path }/autosaves`,\n\t\t\t\t\t\tmethod: 'POST',\n\t\t\t\t\t\tdata,\n\t\t\t\t\t} );\n\n\t\t\t\t\t// An autosave may be processed by the server as a regular save\n\t\t\t\t\t// when its update is requested by the author and the post had\n\t\t\t\t\t// draft or auto-draft status.\n\t\t\t\t\tif ( persistedRecord.id === updatedRecord.id ) {\n\t\t\t\t\t\tlet newRecord = {\n\t\t\t\t\t\t\t...persistedRecord,\n\t\t\t\t\t\t\t...data,\n\t\t\t\t\t\t\t...updatedRecord,\n\t\t\t\t\t\t};\n\t\t\t\t\t\tnewRecord = Object.keys( newRecord ).reduce(\n\t\t\t\t\t\t\t( acc, key ) => {\n\t\t\t\t\t\t\t\t// These properties are persisted in autosaves.\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t[ 'title', 'excerpt', 'content' ].includes(\n\t\t\t\t\t\t\t\t\t\tkey\n\t\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\t\tacc[ key ] = newRecord[ key ];\n\t\t\t\t\t\t\t\t} else if ( key === 'status' ) {\n\t\t\t\t\t\t\t\t\t// Status is only persisted in autosaves when going from\n\t\t\t\t\t\t\t\t\t// \"auto-draft\" to \"draft\".\n\t\t\t\t\t\t\t\t\tacc[ key ] =\n\t\t\t\t\t\t\t\t\t\tpersistedRecord.status ===\n\t\t\t\t\t\t\t\t\t\t\t'auto-draft' &&\n\t\t\t\t\t\t\t\t\t\tnewRecord.status === 'draft'\n\t\t\t\t\t\t\t\t\t\t\t? newRecord.status\n\t\t\t\t\t\t\t\t\t\t\t: persistedRecord.status;\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t// These properties are not persisted in autosaves.\n\t\t\t\t\t\t\t\t\tacc[ key ] = persistedRecord[ key ];\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\treturn acc;\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\tdispatch.receiveEntityRecords(\n\t\t\t\t\t\t\tkind,\n\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\tnewRecord,\n\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\ttrue\n\t\t\t\t\t\t);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tdispatch.receiveAutosaves(\n\t\t\t\t\t\t\tpersistedRecord.id,\n\t\t\t\t\t\t\tupdatedRecord\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tlet edits = record;\n\t\t\t\t\tif ( entityConfig.__unstablePrePersist ) {\n\t\t\t\t\t\tedits = {\n\t\t\t\t\t\t\t...edits,\n\t\t\t\t\t\t\t...entityConfig.__unstablePrePersist(\n\t\t\t\t\t\t\t\tpersistedRecord,\n\t\t\t\t\t\t\t\tedits\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\tupdatedRecord = await __unstableFetch( {\n\t\t\t\t\t\tpath,\n\t\t\t\t\t\tmethod: recordId ? 'PUT' : 'POST',\n\t\t\t\t\t\tdata: edits,\n\t\t\t\t\t} );\n\t\t\t\t\tdispatch.receiveEntityRecords(\n\t\t\t\t\t\tkind,\n\t\t\t\t\t\tname,\n\t\t\t\t\t\tupdatedRecord,\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t\tedits\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} catch ( _error ) {\n\t\t\t\thasError = true;\n\t\t\t\terror = _error;\n\t\t\t}\n\t\t\tdispatch( {\n\t\t\t\ttype: 'SAVE_ENTITY_RECORD_FINISH',\n\t\t\t\tkind,\n\t\t\t\tname,\n\t\t\t\trecordId,\n\t\t\t\terror,\n\t\t\t\tisAutosave,\n\t\t\t} );\n\n\t\t\tif ( hasError && throwOnError ) {\n\t\t\t\tthrow error;\n\t\t\t}\n\n\t\t\treturn updatedRecord;\n\t\t} finally {\n\t\t\tdispatch.__unstableReleaseStoreLock( lock );\n\t\t}\n\t};\n\n/**\n * Runs multiple core-data actions at the same time using one API request.\n *\n * Example:\n *\n * ```\n * const [ savedRecord, updatedRecord, deletedRecord ] =\n * await dispatch( 'core' ).__experimentalBatch( [\n * ( { saveEntityRecord } ) => saveEntityRecord( 'root', 'widget', widget ),\n * ( { saveEditedEntityRecord } ) => saveEntityRecord( 'root', 'widget', 123 ),\n * ( { deleteEntityRecord } ) => deleteEntityRecord( 'root', 'widget', 123, null ),\n * ] );\n * ```\n *\n * @param {Array} requests Array of functions which are invoked simultaneously.\n * Each function is passed an object containing\n * `saveEntityRecord`, `saveEditedEntityRecord`, and\n * `deleteEntityRecord`.\n *\n * @return {(thunkArgs: Object) => Promise} A promise that resolves to an array containing the return\n * values of each function given in `requests`.\n */\nexport const __experimentalBatch =\n\t( requests ) =>\n\tasync ( { dispatch } ) => {\n\t\tconst batch = createBatch();\n\t\tconst api = {\n\t\t\tsaveEntityRecord( kind, name, record, options ) {\n\t\t\t\treturn batch.add( ( add ) =>\n\t\t\t\t\tdispatch.saveEntityRecord( kind, name, record, {\n\t\t\t\t\t\t...options,\n\t\t\t\t\t\t__unstableFetch: add,\n\t\t\t\t\t} )\n\t\t\t\t);\n\t\t\t},\n\t\t\tsaveEditedEntityRecord( kind, name, recordId, options ) {\n\t\t\t\treturn batch.add( ( add ) =>\n\t\t\t\t\tdispatch.saveEditedEntityRecord( kind, name, recordId, {\n\t\t\t\t\t\t...options,\n\t\t\t\t\t\t__unstableFetch: add,\n\t\t\t\t\t} )\n\t\t\t\t);\n\t\t\t},\n\t\t\tdeleteEntityRecord( kind, name, recordId, query, options ) {\n\t\t\t\treturn batch.add( ( add ) =>\n\t\t\t\t\tdispatch.deleteEntityRecord( kind, name, recordId, query, {\n\t\t\t\t\t\t...options,\n\t\t\t\t\t\t__unstableFetch: add,\n\t\t\t\t\t} )\n\t\t\t\t);\n\t\t\t},\n\t\t};\n\t\tconst resultPromises = requests.map( ( request ) => request( api ) );\n\t\tconst [ , ...results ] = await Promise.all( [\n\t\t\tbatch.run(),\n\t\t\t...resultPromises,\n\t\t] );\n\t\treturn results;\n\t};\n\n/**\n * Action triggered to save an entity record's edits.\n *\n * @param {string} kind Kind of the entity.\n * @param {string} name Name of the entity.\n * @param {Object} recordId ID of the record.\n * @param {Object=} options Saving options.\n */\nexport const saveEditedEntityRecord =\n\t( kind, name, recordId, options ) =>\n\tasync ( { select, dispatch } ) => {\n\t\tif ( ! select.hasEditsForEntityRecord( kind, name, recordId ) ) {\n\t\t\treturn;\n\t\t}\n\t\tconst configs = await dispatch( getOrLoadEntitiesConfig( kind, name ) );\n\t\tconst entityConfig = configs.find(\n\t\t\t( config ) => config.kind === kind && config.name === name\n\t\t);\n\t\tif ( ! entityConfig ) {\n\t\t\treturn;\n\t\t}\n\t\tconst entityIdKey = entityConfig.key || DEFAULT_ENTITY_KEY;\n\n\t\tconst edits = select.getEntityRecordNonTransientEdits(\n\t\t\tkind,\n\t\t\tname,\n\t\t\trecordId\n\t\t);\n\t\tconst record = { [ entityIdKey ]: recordId, ...edits };\n\t\treturn await dispatch.saveEntityRecord( kind, name, record, options );\n\t};\n\n/**\n * Action triggered to save only specified properties for the entity.\n *\n * @param {string} kind Kind of the entity.\n * @param {string} name Name of the entity.\n * @param {number|string} recordId ID of the record.\n * @param {Array} itemsToSave List of entity properties or property paths to save.\n * @param {Object} options Saving options.\n */\nexport const __experimentalSaveSpecifiedEntityEdits =\n\t( kind, name, recordId, itemsToSave, options ) =>\n\tasync ( { select, dispatch } ) => {\n\t\tif ( ! select.hasEditsForEntityRecord( kind, name, recordId ) ) {\n\t\t\treturn;\n\t\t}\n\t\tconst edits = select.getEntityRecordNonTransientEdits(\n\t\t\tkind,\n\t\t\tname,\n\t\t\trecordId\n\t\t);\n\t\tconst editsToSave = {};\n\n\t\tfor ( const item of itemsToSave ) {\n\t\t\tsetNestedValue( editsToSave, item, getNestedValue( edits, item ) );\n\t\t}\n\n\t\tconst configs = await dispatch( getOrLoadEntitiesConfig( kind, name ) );\n\t\tconst entityConfig = configs.find(\n\t\t\t( config ) => config.kind === kind && config.name === name\n\t\t);\n\n\t\tconst entityIdKey = entityConfig?.key || DEFAULT_ENTITY_KEY;\n\n\t\t// If a record key is provided then update the existing record.\n\t\t// This necessitates providing `recordKey` to saveEntityRecord as part of the\n\t\t// `record` argument (here called `editsToSave`) to stop that action creating\n\t\t// a new record and instead cause it to update the existing record.\n\t\tif ( recordId ) {\n\t\t\teditsToSave[ entityIdKey ] = recordId;\n\t\t}\n\t\treturn await dispatch.saveEntityRecord(\n\t\t\tkind,\n\t\t\tname,\n\t\t\teditsToSave,\n\t\t\toptions\n\t\t);\n\t};\n\n/**\n * Returns an action object used in signalling that Upload permissions have been received.\n *\n * @deprecated since WP 5.9, use receiveUserPermission instead.\n *\n * @param {boolean} hasUploadPermissions Does the user have permission to upload files?\n *\n * @return {Object} Action object.\n */\nexport function receiveUploadPermissions( hasUploadPermissions ) {\n\tdeprecated( \"wp.data.dispatch( 'core' ).receiveUploadPermissions\", {\n\t\tsince: '5.9',\n\t\talternative: 'receiveUserPermission',\n\t} );\n\n\treturn receiveUserPermission( 'create/media', hasUploadPermissions );\n}\n\n/**\n * Returns an action object used in signalling that the current user has\n * permission to perform an action on a REST resource.\n * Ignored from documentation as it's internal to the data store.\n *\n * @ignore\n *\n * @param {string} key A key that represents the action and REST resource.\n * @param {boolean} isAllowed Whether or not the user can perform the action.\n *\n * @return {Object} Action object.\n */\nexport function receiveUserPermission( key, isAllowed ) {\n\treturn {\n\t\ttype: 'RECEIVE_USER_PERMISSION',\n\t\tkey,\n\t\tisAllowed,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that the current user has\n * permission to perform an action on a REST resource. Ignored from\n * documentation as it's internal to the data store.\n *\n * @ignore\n *\n * @param {Object<string, boolean>} permissions An object where keys represent\n * actions and REST resources, and\n * values indicate whether the user\n * is allowed to perform the\n * action.\n *\n * @return {Object} Action object.\n */\nexport function receiveUserPermissions( permissions ) {\n\treturn {\n\t\ttype: 'RECEIVE_USER_PERMISSIONS',\n\t\tpermissions,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that the autosaves for a\n * post have been received.\n * Ignored from documentation as it's internal to the data store.\n *\n * @ignore\n *\n * @param {number} postId The id of the post that is parent to the autosave.\n * @param {Array|Object} autosaves An array of autosaves or singular autosave object.\n *\n * @return {Object} Action object.\n */\nexport function receiveAutosaves( postId, autosaves ) {\n\treturn {\n\t\ttype: 'RECEIVE_AUTOSAVES',\n\t\tpostId,\n\t\tautosaves: Array.isArray( autosaves ) ? autosaves : [ autosaves ],\n\t};\n}\n\n/**\n * Returns an action object signalling that the fallback Navigation\n * Menu id has been received.\n *\n * @param {integer} fallbackId the id of the fallback Navigation Menu\n * @return {Object} Action object.\n */\nexport function receiveNavigationFallbackId( fallbackId ) {\n\treturn {\n\t\ttype: 'RECEIVE_NAVIGATION_FALLBACK_ID',\n\t\tfallbackId,\n\t};\n}\n\n/**\n * Returns an action object used to set the template for a given query.\n *\n * @param {Object} query The lookup query.\n * @param {string} templateId The resolved template id.\n *\n * @return {Object} Action object.\n */\nexport function receiveDefaultTemplateId( query, templateId ) {\n\treturn {\n\t\ttype: 'RECEIVE_DEFAULT_TEMPLATE',\n\t\tquery,\n\t\ttemplateId,\n\t};\n}\n\n/**\n * Action triggered to receive revision items.\n *\n * @param {string} kind Kind of the received entity record revisions.\n * @param {string} name Name of the received entity record revisions.\n * @param {number|string} recordKey The key of the entity record whose revisions you want to fetch.\n * @param {Array|Object} records Revisions received.\n * @param {?Object} query Query Object.\n * @param {?boolean} invalidateCache Should invalidate query caches.\n * @param {?Object} meta Meta information about pagination.\n */\nexport const receiveRevisions =\n\t( kind, name, recordKey, records, query, invalidateCache = false, meta ) =>\n\tasync ( { dispatch } ) => {\n\t\tconst configs = await dispatch( getOrLoadEntitiesConfig( kind, name ) );\n\t\tconst entityConfig = configs.find(\n\t\t\t( config ) => config.kind === kind && config.name === name\n\t\t);\n\t\tconst key =\n\t\t\tentityConfig && entityConfig?.revisionKey\n\t\t\t\t? entityConfig.revisionKey\n\t\t\t\t: DEFAULT_ENTITY_KEY;\n\n\t\tdispatch( {\n\t\t\ttype: 'RECEIVE_ITEM_REVISIONS',\n\t\t\tkey,\n\t\t\titems: Array.isArray( records ) ? records : [ records ],\n\t\t\trecordKey,\n\t\t\tmeta,\n\t\t\tquery,\n\t\t\tkind,\n\t\t\tname,\n\t\t\tinvalidateCache,\n\t\t} );\n\t};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,IAAAA,GAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AAKA,IAAAE,SAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,IAAA,GAAAH,OAAA;AACA,IAAAI,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,CAAA+F,gBAAA,GAAAA,gBAAA","ignoreList":[]}
@@ -58,6 +58,7 @@ function updateFootnotesFromMeta(blocks, meta) {
58
58
  continue;
59
59
  }
60
60
  const richTextValue = typeof value === 'string' ? _richText.RichTextData.fromHTMLString(value) : new _richText.RichTextData(value);
61
+ let hasFootnotes = false;
61
62
  richTextValue.replacements.forEach(replacement => {
62
63
  if (replacement.type === 'core/footnote') {
63
64
  const id = replacement.attributes['data-fn'];
@@ -76,9 +77,12 @@ function updateFootnotesFromMeta(blocks, meta) {
76
77
  replacement.innerHTML = (0, _richText.toHTMLString)({
77
78
  value: countValue
78
79
  });
80
+ hasFootnotes = true;
79
81
  }
80
82
  });
81
- attributes[key] = typeof value === 'string' ? richTextValue.toHTMLString() : richTextValue;
83
+ if (hasFootnotes) {
84
+ attributes[key] = typeof value === 'string' ? richTextValue.toHTMLString() : richTextValue;
85
+ }
82
86
  }
83
87
  return attributes;
84
88
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_richText","require","_getFootnotesOrder","_interopRequireDefault","oldFootnotes","updateFootnotesFromMeta","blocks","meta","output","footnotes","undefined","newOrder","getFootnotesOrder","JSON","parse","currentOrder","map","fn","id","join","newFootnotes","fnId","find","content","updateAttributes","attributes","Array","isArray","key","value","RichTextData","richTextValue","fromHTMLString","replacements","forEach","replacement","type","index","indexOf","countValue","create","html","innerHTML","text","String","formats","from","length","toHTMLString","updateBlocksAttributes","__blocks","block","innerBlocks","newBlocks","reduce","acc","includes","stringify"],"sources":["@wordpress/core-data/src/footnotes/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { RichTextData, create, toHTMLString } from '@wordpress/rich-text';\n\n/**\n * Internal dependencies\n */\nimport getFootnotesOrder from './get-footnotes-order';\n\nlet oldFootnotes = {};\n\nexport function updateFootnotesFromMeta( blocks, meta ) {\n\tconst output = { blocks };\n\tif ( ! meta ) {\n\t\treturn output;\n\t}\n\n\t// If meta.footnotes is empty, it means the meta is not registered.\n\tif ( meta.footnotes === undefined ) {\n\t\treturn output;\n\t}\n\n\tconst newOrder = getFootnotesOrder( blocks );\n\n\tconst footnotes = meta.footnotes ? JSON.parse( meta.footnotes ) : [];\n\tconst currentOrder = footnotes.map( ( fn ) => fn.id );\n\n\tif ( currentOrder.join( '' ) === newOrder.join( '' ) ) {\n\t\treturn output;\n\t}\n\n\tconst newFootnotes = newOrder.map(\n\t\t( fnId ) =>\n\t\t\tfootnotes.find( ( fn ) => fn.id === fnId ) ||\n\t\t\toldFootnotes[ fnId ] || {\n\t\t\t\tid: fnId,\n\t\t\t\tcontent: '',\n\t\t\t}\n\t);\n\n\tfunction updateAttributes( attributes ) {\n\t\t// Only attempt to update attributes, if attributes is an object.\n\t\tif (\n\t\t\t! attributes ||\n\t\t\tArray.isArray( attributes ) ||\n\t\t\ttypeof attributes !== 'object'\n\t\t) {\n\t\t\treturn attributes;\n\t\t}\n\n\t\tattributes = { ...attributes };\n\n\t\tfor ( const key in attributes ) {\n\t\t\tconst value = attributes[ key ];\n\n\t\t\tif ( Array.isArray( value ) ) {\n\t\t\t\tattributes[ key ] = value.map( updateAttributes );\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// To do, remove support for string values?\n\t\t\tif (\n\t\t\t\ttypeof value !== 'string' &&\n\t\t\t\t! ( value instanceof RichTextData )\n\t\t\t) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst richTextValue =\n\t\t\t\ttypeof value === 'string'\n\t\t\t\t\t? RichTextData.fromHTMLString( value )\n\t\t\t\t\t: new RichTextData( value );\n\n\t\t\trichTextValue.replacements.forEach( ( replacement ) => {\n\t\t\t\tif ( replacement.type === 'core/footnote' ) {\n\t\t\t\t\tconst id = replacement.attributes[ 'data-fn' ];\n\t\t\t\t\tconst index = newOrder.indexOf( id );\n\t\t\t\t\t// The innerHTML contains the count wrapped in a link.\n\t\t\t\t\tconst countValue = create( {\n\t\t\t\t\t\thtml: replacement.innerHTML,\n\t\t\t\t\t} );\n\t\t\t\t\tcountValue.text = String( index + 1 );\n\t\t\t\t\tcountValue.formats = Array.from(\n\t\t\t\t\t\t{ length: countValue.text.length },\n\t\t\t\t\t\t() => countValue.formats[ 0 ]\n\t\t\t\t\t);\n\t\t\t\t\tcountValue.replacements = Array.from(\n\t\t\t\t\t\t{ length: countValue.text.length },\n\t\t\t\t\t\t() => countValue.replacements[ 0 ]\n\t\t\t\t\t);\n\t\t\t\t\treplacement.innerHTML = toHTMLString( {\n\t\t\t\t\t\tvalue: countValue,\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t} );\n\n\t\t\tattributes[ key ] =\n\t\t\t\ttypeof value === 'string'\n\t\t\t\t\t? richTextValue.toHTMLString()\n\t\t\t\t\t: richTextValue;\n\t\t}\n\n\t\treturn attributes;\n\t}\n\n\tfunction updateBlocksAttributes( __blocks ) {\n\t\treturn __blocks.map( ( block ) => {\n\t\t\treturn {\n\t\t\t\t...block,\n\t\t\t\tattributes: updateAttributes( block.attributes ),\n\t\t\t\tinnerBlocks: updateBlocksAttributes( block.innerBlocks ),\n\t\t\t};\n\t\t} );\n\t}\n\n\t// We need to go through all block attributes deeply and update the\n\t// footnote anchor numbering (textContent) to match the new order.\n\tconst newBlocks = updateBlocksAttributes( blocks );\n\n\toldFootnotes = {\n\t\t...oldFootnotes,\n\t\t...footnotes.reduce( ( acc, fn ) => {\n\t\t\tif ( ! newOrder.includes( fn.id ) ) {\n\t\t\t\tacc[ fn.id ] = fn;\n\t\t\t}\n\t\t\treturn acc;\n\t\t}, {} ),\n\t};\n\n\treturn {\n\t\tmeta: {\n\t\t\t...meta,\n\t\t\tfootnotes: JSON.stringify( newFootnotes ),\n\t\t},\n\t\tblocks: newBlocks,\n\t};\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,SAAA,GAAAC,OAAA;AAKA,IAAAC,kBAAA,GAAAC,sBAAA,CAAAF,OAAA;AARA;AACA;AACA;;AAGA;AACA;AACA;;AAGA,IAAIG,YAAY,GAAG,CAAC,CAAC;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GAAG,CAAE,GAChB,OAAOC,KAAK,KAAK,QAAQ,GACtBE,aAAa,CAACiB,YAAY,CAAC,CAAC,GAC5BjB,aAAa;IAClB;IAEA,OAAON,UAAU;EAClB;EAEA,SAASwB,sBAAsBA,CAAEC,QAAQ,EAAG;IAC3C,OAAOA,QAAQ,CAAClC,GAAG,CAAImC,KAAK,IAAM;MACjC,OAAO;QACN,GAAGA,KAAK;QACR1B,UAAU,EAAED,gBAAgB,CAAE2B,KAAK,CAAC1B,UAAW,CAAC;QAChD2B,WAAW,EAAEH,sBAAsB,CAAEE,KAAK,CAACC,WAAY;MACxD,CAAC;IACF,CAAE,CAAC;EACJ;;EAEA;EACA;EACA,MAAMC,SAAS,GAAGJ,sBAAsB,CAAE3C,MAAO,CAAC;EAElDF,YAAY,GAAG;IACd,GAAGA,YAAY;IACf,GAAGK,SAAS,CAAC6C,MAAM,CAAE,CAAEC,GAAG,EAAEtC,EAAE,KAAM;MACnC,IAAK,CAAEN,QAAQ,CAAC6C,QAAQ,CAAEvC,EAAE,CAACC,EAAG,CAAC,EAAG;QACnCqC,GAAG,CAAEtC,EAAE,CAACC,EAAE,CAAE,GAAGD,EAAE;MAClB;MACA,OAAOsC,GAAG;IACX,CAAC,EAAE,CAAC,CAAE;EACP,CAAC;EAED,OAAO;IACNhD,IAAI,EAAE;MACL,GAAGA,IAAI;MACPE,SAAS,EAAEI,IAAI,CAAC4C,SAAS,CAAErC,YAAa;IACzC,CAAC;IACDd,MAAM,EAAE+C;EACT,CAAC;AACF","ignoreList":[]}
1
+ {"version":3,"names":["_richText","require","_getFootnotesOrder","_interopRequireDefault","oldFootnotes","updateFootnotesFromMeta","blocks","meta","output","footnotes","undefined","newOrder","getFootnotesOrder","JSON","parse","currentOrder","map","fn","id","join","newFootnotes","fnId","find","content","updateAttributes","attributes","Array","isArray","key","value","RichTextData","richTextValue","fromHTMLString","hasFootnotes","replacements","forEach","replacement","type","index","indexOf","countValue","create","html","innerHTML","text","String","formats","from","length","toHTMLString","updateBlocksAttributes","__blocks","block","innerBlocks","newBlocks","reduce","acc","includes","stringify"],"sources":["@wordpress/core-data/src/footnotes/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { RichTextData, create, toHTMLString } from '@wordpress/rich-text';\n\n/**\n * Internal dependencies\n */\nimport getFootnotesOrder from './get-footnotes-order';\n\nlet oldFootnotes = {};\n\nexport function updateFootnotesFromMeta( blocks, meta ) {\n\tconst output = { blocks };\n\tif ( ! meta ) {\n\t\treturn output;\n\t}\n\n\t// If meta.footnotes is empty, it means the meta is not registered.\n\tif ( meta.footnotes === undefined ) {\n\t\treturn output;\n\t}\n\n\tconst newOrder = getFootnotesOrder( blocks );\n\n\tconst footnotes = meta.footnotes ? JSON.parse( meta.footnotes ) : [];\n\tconst currentOrder = footnotes.map( ( fn ) => fn.id );\n\n\tif ( currentOrder.join( '' ) === newOrder.join( '' ) ) {\n\t\treturn output;\n\t}\n\n\tconst newFootnotes = newOrder.map(\n\t\t( fnId ) =>\n\t\t\tfootnotes.find( ( fn ) => fn.id === fnId ) ||\n\t\t\toldFootnotes[ fnId ] || {\n\t\t\t\tid: fnId,\n\t\t\t\tcontent: '',\n\t\t\t}\n\t);\n\n\tfunction updateAttributes( attributes ) {\n\t\t// Only attempt to update attributes, if attributes is an object.\n\t\tif (\n\t\t\t! attributes ||\n\t\t\tArray.isArray( attributes ) ||\n\t\t\ttypeof attributes !== 'object'\n\t\t) {\n\t\t\treturn attributes;\n\t\t}\n\n\t\tattributes = { ...attributes };\n\n\t\tfor ( const key in attributes ) {\n\t\t\tconst value = attributes[ key ];\n\n\t\t\tif ( Array.isArray( value ) ) {\n\t\t\t\tattributes[ key ] = value.map( updateAttributes );\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// To do, remove support for string values?\n\t\t\tif (\n\t\t\t\ttypeof value !== 'string' &&\n\t\t\t\t! ( value instanceof RichTextData )\n\t\t\t) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst richTextValue =\n\t\t\t\ttypeof value === 'string'\n\t\t\t\t\t? RichTextData.fromHTMLString( value )\n\t\t\t\t\t: new RichTextData( value );\n\n\t\t\tlet hasFootnotes = false;\n\n\t\t\trichTextValue.replacements.forEach( ( replacement ) => {\n\t\t\t\tif ( replacement.type === 'core/footnote' ) {\n\t\t\t\t\tconst id = replacement.attributes[ 'data-fn' ];\n\t\t\t\t\tconst index = newOrder.indexOf( id );\n\t\t\t\t\t// The innerHTML contains the count wrapped in a link.\n\t\t\t\t\tconst countValue = create( {\n\t\t\t\t\t\thtml: replacement.innerHTML,\n\t\t\t\t\t} );\n\t\t\t\t\tcountValue.text = String( index + 1 );\n\t\t\t\t\tcountValue.formats = Array.from(\n\t\t\t\t\t\t{ length: countValue.text.length },\n\t\t\t\t\t\t() => countValue.formats[ 0 ]\n\t\t\t\t\t);\n\t\t\t\t\tcountValue.replacements = Array.from(\n\t\t\t\t\t\t{ length: countValue.text.length },\n\t\t\t\t\t\t() => countValue.replacements[ 0 ]\n\t\t\t\t\t);\n\t\t\t\t\treplacement.innerHTML = toHTMLString( {\n\t\t\t\t\t\tvalue: countValue,\n\t\t\t\t\t} );\n\t\t\t\t\thasFootnotes = true;\n\t\t\t\t}\n\t\t\t} );\n\n\t\t\tif ( hasFootnotes ) {\n\t\t\t\tattributes[ key ] =\n\t\t\t\t\ttypeof value === 'string'\n\t\t\t\t\t\t? richTextValue.toHTMLString()\n\t\t\t\t\t\t: richTextValue;\n\t\t\t}\n\t\t}\n\n\t\treturn attributes;\n\t}\n\n\tfunction updateBlocksAttributes( __blocks ) {\n\t\treturn __blocks.map( ( block ) => {\n\t\t\treturn {\n\t\t\t\t...block,\n\t\t\t\tattributes: updateAttributes( block.attributes ),\n\t\t\t\tinnerBlocks: updateBlocksAttributes( block.innerBlocks ),\n\t\t\t};\n\t\t} );\n\t}\n\n\t// We need to go through all block attributes deeply and update the\n\t// footnote anchor numbering (textContent) to match the new order.\n\tconst newBlocks = updateBlocksAttributes( blocks );\n\n\toldFootnotes = {\n\t\t...oldFootnotes,\n\t\t...footnotes.reduce( ( acc, fn ) => {\n\t\t\tif ( ! newOrder.includes( fn.id ) ) {\n\t\t\t\tacc[ fn.id ] = fn;\n\t\t\t}\n\t\t\treturn acc;\n\t\t}, {} ),\n\t};\n\n\treturn {\n\t\tmeta: {\n\t\t\t...meta,\n\t\t\tfootnotes: JSON.stringify( newFootnotes ),\n\t\t},\n\t\tblocks: newBlocks,\n\t};\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,SAAA,GAAAC,OAAA;AAKA,IAAAC,kBAAA,GAAAC,sBAAA,CAAAF,OAAA;AARA;AACA;AACA;;AAGA;AACA;AACA;;AAGA,IAAIG,YAAY,GAAG,CAAC,CAAC;AAEd,SAASC,uBAAuBA,CAAEC,MAAM,EAAEC,IAAI,EAAG;EACvD,MAAMC,MAAM,GAAG;IAAEF;EAAO,CAAC;EACzB,IAAK,CAAEC,IAAI,EAAG;IACb,OAAOC,MAAM;EACd;;EAEA;EACA,IAAKD,IAAI,CAACE,SAAS,KAAKC,SAAS,EAAG;IACnC,OAAOF,MAAM;EACd;EAEA,MAAMG,QAAQ,GAAG,IAAAC,0BAAiB,EAAEN,MAAO,CAAC;EAE5C,MAAMG,SAAS,GAAGF,IAAI,CAACE,SAAS,GAAGI,IAAI,CAACC,KAAK,CAAEP,IAAI,CAACE,SAAU,CAAC,GAAG,EAAE;EACpE,MAAMM,YAAY,GAAGN,SAAS,CAACO,GAAG,CAAIC,EAAE,IAAMA,EAAE,CAACC,EAAG,CAAC;EAErD,IAAKH,YAAY,CAACI,IAAI,CAAE,EAAG,CAAC,KAAKR,QAAQ,CAACQ,IAAI,CAAE,EAAG,CAAC,EAAG;IACtD,OAAOX,MAAM;EACd;EAEA,MAAMY,YAAY,GAAGT,QAAQ,CAACK,GAAG,CAC9BK,IAAI,IACLZ,SAAS,CAACa,IAAI,CAAIL,EAAE,IAAMA,EAAE,CAACC,EAAE,KAAKG,IAAK,CAAC,IA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vC,EAAE,CAACC,EAAE,CAAE,GAAGD,EAAE;MAClB;MACA,OAAOuC,GAAG;IACX,CAAC,EAAE,CAAC,CAAE;EACP,CAAC;EAED,OAAO;IACNjD,IAAI,EAAE;MACL,GAAGA,IAAI;MACPE,SAAS,EAAEI,IAAI,CAAC6C,SAAS,CAAEtC,YAAa;IACzC,CAAC;IACDd,MAAM,EAAEgD;EACT,CAAC;AACF","ignoreList":[]}
@@ -22,10 +22,10 @@ var _useEntityId = _interopRequireDefault(require("./use-entity-id"));
22
22
  * specified property of the nearest provided
23
23
  * entity of the specified type.
24
24
  *
25
- * @param {string} kind The entity kind.
26
- * @param {string} name The entity name.
27
- * @param {string} prop The property name.
28
- * @param {string} [_id] An entity ID to use instead of the context-provided one.
25
+ * @param {string} kind The entity kind.
26
+ * @param {string} name The entity name.
27
+ * @param {string} prop The property name.
28
+ * @param {number|string} [_id] An entity ID to use instead of the context-provided one.
29
29
  *
30
30
  * @return {[*, Function, *]} An array where the first item is the
31
31
  * property value, the second is the
@@ -1 +1 @@
1
- {"version":3,"names":["_element","require","_data","_name","_useEntityId","_interopRequireDefault","useEntityProp","kind","name","prop","_id","providerId","useEntityId","id","value","fullValue","useSelect","select","getEntityRecord","getEditedEntityRecord","STORE_NAME","record","editedRecord","editEntityRecord","useDispatch","setValue","useCallback","newValue"],"sources":["@wordpress/core-data/src/hooks/use-entity-prop.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useCallback } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { STORE_NAME } from '../name';\nimport useEntityId from './use-entity-id';\n\n/**\n * Hook that returns the value and a setter for the\n * specified property of the nearest provided\n * entity of the specified type.\n *\n * @param {string} kind The entity kind.\n * @param {string} name The entity name.\n * @param {string} prop The property name.\n * @param {string} [_id] An entity ID to use instead of the context-provided one.\n *\n * @return {[*, Function, *]} An array where the first item is the\n * property value, the second is the\n * setter and the third is the full value\n * \t\t\t\t\t\t\t object from REST API containing more\n * \t\t\t\t\t\t\t information like `raw`, `rendered` and\n * \t\t\t\t\t\t\t `protected` props.\n */\nexport default function useEntityProp( kind, name, prop, _id ) {\n\tconst providerId = useEntityId( kind, name );\n\tconst id = _id ?? providerId;\n\n\tconst { value, fullValue } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecord, getEditedEntityRecord } =\n\t\t\t\tselect( STORE_NAME );\n\t\t\tconst record = getEntityRecord( kind, name, id ); // Trigger resolver.\n\t\t\tconst editedRecord = getEditedEntityRecord( kind, name, id );\n\t\t\treturn record && editedRecord\n\t\t\t\t? {\n\t\t\t\t\t\tvalue: editedRecord[ prop ],\n\t\t\t\t\t\tfullValue: record[ prop ],\n\t\t\t\t }\n\t\t\t\t: {};\n\t\t},\n\t\t[ kind, name, id, prop ]\n\t);\n\tconst { editEntityRecord } = useDispatch( STORE_NAME );\n\tconst setValue = useCallback(\n\t\t( newValue ) => {\n\t\t\teditEntityRecord( kind, name, id, {\n\t\t\t\t[ prop ]: newValue,\n\t\t\t} );\n\t\t},\n\t\t[ editEntityRecord, kind, name, id, prop ]\n\t);\n\n\treturn [ value, setValue, fullValue ];\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AAKA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAC,sBAAA,CAAAJ,OAAA;AAVA;AACA;AACA;;AAIA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASK,aAAaA,CAAEC,IAAI,EAAEC,IAAI,EAAEC,IAAI,EAAEC,GAAG,EAAG;EAC9D,MAAMC,UAAU,GAAG,IAAAC,oBAAW,EAAEL,IAAI,EAAEC,IAAK,CAAC;EAC5C,MAAMK,EAAE,GAAGH,GAAG,aAAHA,GAAG,cAAHA,GAAG,GAAIC,UAAU;EAE5B,MAAM;IAAEG,KAAK;IAAEC;EAAU,CAAC,GAAG,IAAAC,eAAS,EACnCC,MAAM,IAAM;IACb,MAAM;MAAEC,eAAe;MAAEC;IAAsB,CAAC,GAC/CF,MAAM,CAAEG,gBAAW,CAAC;IACrB,MAAMC,MAAM,GAAGH,eAAe,CAAEX,IAAI,EAAEC,IAAI,EAAEK,EAAG,CAAC,CAAC,CAAC;IAClD,MAAMS,YAAY,GAAGH,qBAAqB,CAAEZ,IAAI,EAAEC,IAAI,EAAEK,EAAG,CAAC;IAC5D,OAAOQ,MAAM,IAAIC,YAAY,GAC1B;MACAR,KAAK,EAAEQ,YAAY,CAAEb,IAAI,CAAE;MAC3BM,SAAS,EAAEM,MAAM,CAAEZ,IAAI;IACvB,CAAC,GACD,CAAC,CAAC;EACN,CAAC,EACD,CAAEF,IAAI,EAAEC,IAAI,EAAEK,EAAE,EAAEJ,IAAI,CACvB,CAAC;EACD,MAAM;IAAEc;EAAiB,CAAC,GAAG,IAAAC,iBAAW,EAAEJ,gBAAW,CAAC;EACtD,MAAMK,QAAQ,GAAG,IAAAC,oBAAW,EACzBC,QAAQ,IAAM;IACfJ,gBAAgB,CAAEhB,IAAI,EAAEC,IAAI,EAAEK,EAAE,EAAE;MACjC,CAAEJ,IAAI,GAAIkB;IACX,CAAE,CAAC;EACJ,CAAC,EACD,CAAEJ,gBAAgB,EAAEhB,IAAI,EAAEC,IAAI,EAAEK,EAAE,EAAEJ,IAAI,CACzC,CAAC;EAED,OAAO,CAAEK,KAAK,EAAEW,QAAQ,EAAEV,SAAS,CAAE;AACtC","ignoreList":[]}
1
+ {"version":3,"names":["_element","require","_data","_name","_useEntityId","_interopRequireDefault","useEntityProp","kind","name","prop","_id","providerId","useEntityId","id","value","fullValue","useSelect","select","getEntityRecord","getEditedEntityRecord","STORE_NAME","record","editedRecord","editEntityRecord","useDispatch","setValue","useCallback","newValue"],"sources":["@wordpress/core-data/src/hooks/use-entity-prop.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useCallback } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { STORE_NAME } from '../name';\nimport useEntityId from './use-entity-id';\n\n/**\n * Hook that returns the value and a setter for the\n * specified property of the nearest provided\n * entity of the specified type.\n *\n * @param {string} kind The entity kind.\n * @param {string} name The entity name.\n * @param {string} prop The property name.\n * @param {number|string} [_id] An entity ID to use instead of the context-provided one.\n *\n * @return {[*, Function, *]} An array where the first item is the\n * property value, the second is the\n * setter and the third is the full value\n * \t\t\t\t\t\t\t object from REST API containing more\n * \t\t\t\t\t\t\t information like `raw`, `rendered` and\n * \t\t\t\t\t\t\t `protected` props.\n */\nexport default function useEntityProp( kind, name, prop, _id ) {\n\tconst providerId = useEntityId( kind, name );\n\tconst id = _id ?? providerId;\n\n\tconst { value, fullValue } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecord, getEditedEntityRecord } =\n\t\t\t\tselect( STORE_NAME );\n\t\t\tconst record = getEntityRecord( kind, name, id ); // Trigger resolver.\n\t\t\tconst editedRecord = getEditedEntityRecord( kind, name, id );\n\t\t\treturn record && editedRecord\n\t\t\t\t? {\n\t\t\t\t\t\tvalue: editedRecord[ prop ],\n\t\t\t\t\t\tfullValue: record[ prop ],\n\t\t\t\t }\n\t\t\t\t: {};\n\t\t},\n\t\t[ kind, name, id, prop ]\n\t);\n\tconst { editEntityRecord } = useDispatch( STORE_NAME );\n\tconst setValue = useCallback(\n\t\t( newValue ) => {\n\t\t\teditEntityRecord( kind, name, id, {\n\t\t\t\t[ prop ]: newValue,\n\t\t\t} );\n\t\t},\n\t\t[ editEntityRecord, kind, name, id, prop ]\n\t);\n\n\treturn [ value, setValue, fullValue ];\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AAKA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAC,sB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C,IAAI,EAAEK,EAAE,EAAEJ,IAAI,CACzC,CAAC;EAED,OAAO,CAAEK,KAAK,EAAEW,QAAQ,EAAEV,SAAS,CAAE;AACtC","ignoreList":[]}
package/build/reducer.js CHANGED
@@ -487,6 +487,11 @@ function userPermissions(state = {}, action) {
487
487
  ...state,
488
488
  [action.key]: action.isAllowed
489
489
  };
490
+ case 'RECEIVE_USER_PERMISSIONS':
491
+ return {
492
+ ...state,
493
+ ...action.permissions
494
+ };
490
495
  }
491
496
  return state;
492
497
  }