@wordpress/core-data 6.18.0 → 6.19.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 (107) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/README.md +13 -1
  3. package/build/actions.js +34 -30
  4. package/build/actions.js.map +1 -1
  5. package/build/entity-provider.js +2 -99
  6. package/build/entity-provider.js.map +1 -1
  7. package/build/entity-types/helpers.js.map +1 -1
  8. package/build/footnotes/get-footnotes-order.js +35 -0
  9. package/build/footnotes/get-footnotes-order.js.map +1 -0
  10. package/build/footnotes/get-rich-text-values-cached.js +39 -0
  11. package/build/footnotes/get-rich-text-values-cached.js.map +1 -0
  12. package/build/footnotes/index.js +96 -0
  13. package/build/footnotes/index.js.map +1 -0
  14. package/build/hooks/use-entity-record.js +6 -3
  15. package/build/hooks/use-entity-record.js.map +1 -1
  16. package/build/hooks/use-resource-permissions.js.map +1 -1
  17. package/build/private-selectors.js +4 -17
  18. package/build/private-selectors.js.map +1 -1
  19. package/build/reducer.js +33 -145
  20. package/build/reducer.js.map +1 -1
  21. package/build/resolvers.js +20 -1
  22. package/build/resolvers.js.map +1 -1
  23. package/build/selectors.js +21 -25
  24. package/build/selectors.js.map +1 -1
  25. package/build/utils/get-nested-value.js +30 -0
  26. package/build/utils/get-nested-value.js.map +1 -0
  27. package/build/utils/index.js +7 -0
  28. package/build/utils/index.js.map +1 -1
  29. package/build/utils/set-nested-value.js +11 -6
  30. package/build/utils/set-nested-value.js.map +1 -1
  31. package/build-module/actions.js +32 -28
  32. package/build-module/actions.js.map +1 -1
  33. package/build-module/entity-provider.js +2 -99
  34. package/build-module/entity-provider.js.map +1 -1
  35. package/build-module/entity-types/helpers.js.map +1 -1
  36. package/build-module/footnotes/get-footnotes-order.js +27 -0
  37. package/build-module/footnotes/get-footnotes-order.js.map +1 -0
  38. package/build-module/footnotes/get-rich-text-values-cached.js +33 -0
  39. package/build-module/footnotes/get-rich-text-values-cached.js.map +1 -0
  40. package/build-module/footnotes/index.js +88 -0
  41. package/build-module/footnotes/index.js.map +1 -0
  42. package/build-module/hooks/use-entity-record.js +6 -3
  43. package/build-module/hooks/use-entity-record.js.map +1 -1
  44. package/build-module/hooks/use-resource-permissions.js.map +1 -1
  45. package/build-module/private-selectors.js +3 -15
  46. package/build-module/private-selectors.js.map +1 -1
  47. package/build-module/reducer.js +30 -144
  48. package/build-module/reducer.js.map +1 -1
  49. package/build-module/resolvers.js +18 -0
  50. package/build-module/resolvers.js.map +1 -1
  51. package/build-module/selectors.js +19 -29
  52. package/build-module/selectors.js.map +1 -1
  53. package/build-module/utils/get-nested-value.js +24 -0
  54. package/build-module/utils/get-nested-value.js.map +1 -0
  55. package/build-module/utils/index.js +1 -0
  56. package/build-module/utils/index.js.map +1 -1
  57. package/build-module/utils/set-nested-value.js +11 -6
  58. package/build-module/utils/set-nested-value.js.map +1 -1
  59. package/build-types/actions.d.ts +1 -6
  60. package/build-types/actions.d.ts.map +1 -1
  61. package/build-types/entity-provider.d.ts.map +1 -1
  62. package/build-types/footnotes/get-footnotes-order.d.ts +2 -0
  63. package/build-types/footnotes/get-footnotes-order.d.ts.map +1 -0
  64. package/build-types/footnotes/get-rich-text-values-cached.d.ts +2 -0
  65. package/build-types/footnotes/get-rich-text-values-cached.d.ts.map +1 -0
  66. package/build-types/footnotes/index.d.ts +4 -0
  67. package/build-types/footnotes/index.d.ts.map +1 -0
  68. package/build-types/hooks/use-entity-record.d.ts +2 -0
  69. package/build-types/hooks/use-entity-record.d.ts.map +1 -1
  70. package/build-types/index.d.ts +3 -2
  71. package/build-types/index.d.ts.map +1 -1
  72. package/build-types/private-selectors.d.ts +3 -13
  73. package/build-types/private-selectors.d.ts.map +1 -1
  74. package/build-types/reducer.d.ts +7 -23
  75. package/build-types/reducer.d.ts.map +1 -1
  76. package/build-types/resolvers.d.ts +4 -0
  77. package/build-types/resolvers.d.ts.map +1 -1
  78. package/build-types/selectors.d.ts +19 -14
  79. package/build-types/selectors.d.ts.map +1 -1
  80. package/build-types/utils/get-nested-value.d.ts +14 -0
  81. package/build-types/utils/get-nested-value.d.ts.map +1 -0
  82. package/build-types/utils/index.d.ts +1 -0
  83. package/build-types/utils/set-nested-value.d.ts +8 -4
  84. package/build-types/utils/set-nested-value.d.ts.map +1 -1
  85. package/package.json +16 -15
  86. package/src/actions.js +36 -26
  87. package/src/entity-provider.js +2 -134
  88. package/src/entity-types/helpers.ts +2 -2
  89. package/src/footnotes/get-footnotes-order.js +30 -0
  90. package/src/footnotes/get-rich-text-values-cached.js +35 -0
  91. package/src/footnotes/index.js +119 -0
  92. package/src/hooks/test/use-entity-record.js +4 -0
  93. package/src/hooks/use-entity-record.ts +12 -3
  94. package/src/hooks/use-resource-permissions.ts +1 -1
  95. package/src/private-selectors.ts +4 -17
  96. package/src/reducer.js +36 -155
  97. package/src/resolvers.js +25 -0
  98. package/src/selectors.ts +39 -51
  99. package/src/test/reducer.js +0 -233
  100. package/src/test/selectors.js +0 -54
  101. package/src/utils/get-nested-value.js +27 -0
  102. package/src/utils/index.js +1 -0
  103. package/src/utils/set-nested-value.js +12 -6
  104. package/src/utils/test/get-nested-value.js +61 -0
  105. package/src/utils/test/set-nested-value.js +7 -0
  106. package/tsconfig.json +1 -0
  107. package/tsconfig.tsbuildinfo +1 -1
@@ -1 +1 @@
1
- {"version":3,"names":["fastDeepEqual","v4","uuid","apiFetch","addQueryArgs","deprecated","receiveItems","removeItems","receiveQueriedItems","getOrLoadEntitiesConfig","DEFAULT_ENTITY_KEY","createBatch","STORE_NAME","getSyncProvider","receiveUserQuery","queryID","users","type","Array","isArray","receiveCurrentUser","currentUser","addEntities","entities","receiveEntityRecords","kind","name","records","query","invalidateCache","edits","map","record","status","title","action","receiveCurrentTheme","currentTheme","__experimentalReceiveCurrentGlobalStylesId","currentGlobalStylesId","id","__experimentalReceiveThemeBaseGlobalStyles","stylesheet","globalStyles","__experimentalReceiveThemeGlobalStyleVariations","variations","receiveThemeSupports","since","receiveThemeGlobalStyleRevisions","currentId","revisions","receiveEmbedPreview","url","preview","deleteEntityRecord","recordId","__unstableFetch","throwOnError","dispatch","configs","entityConfig","find","config","error","deletedRecord","__experimentalNoFetch","lock","__unstableAcquireStoreLock","exclusive","hasError","path","baseURL","method","_error","__unstableReleaseStoreLock","editEntityRecord","options","select","getEntityConfig","Error","mergedEdits","getRawEntityRecord","editedRecord","getEditedEntityRecord","edit","Object","keys","reduce","acc","key","recordValue","editedRecordValue","value","undefined","window","__experimentalEnableSync","syncConfig","objectId","getSyncObjectId","update","syncObjectType","meta","undo","undoIgnore","isCached","undoEdit","getUndoEdits","stackedEdits","redo","redoEdit","getRedoEdits","__unstableCreateUndoLevel","saveEntityRecord","isAutosave","resolveSelect","entityIdKey","entries","evaluatedValue","updatedRecord","persistedRecord","getCurrentUser","currentUserId","autosavePost","getAutosave","data","includes","newRecord","receiveAutosaves","__unstablePrePersist","__experimentalBatch","requests","batch","api","add","saveEditedEntityRecord","resultPromises","request","results","Promise","all","run","hasEditsForEntityRecord","getEntityRecordNonTransientEdits","__experimentalSaveSpecifiedEntityEdits","itemsToSave","editsToSave","some","item","receiveUploadPermissions","hasUploadPermissions","alternative","receiveUserPermission","isAllowed","postId","autosaves","receiveNavigationFallbackId","fallbackId"],"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 { 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 * @return {Object} Action object.\n */\nexport function receiveEntityRecords(\n\tkind,\n\tname,\n\trecords,\n\tquery,\n\tinvalidateCache = false,\n\tedits\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 );\n\t} else {\n\t\taction = receiveItems( records, edits );\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 direclty.\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 * @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\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 ) );\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 || entityConfig?.__experimentalNoFetch ) {\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\tconst objectId = entityConfig.getSyncObjectId( recordId );\n\t\t\tgetSyncProvider().update(\n\t\t\t\tentityConfig.syncObjectType + '--edit',\n\t\t\t\tobjectId,\n\t\t\t\tedit.edits\n\t\t\t);\n\t\t} else {\n\t\t\tdispatch( {\n\t\t\t\ttype: 'EDIT_ENTITY_RECORD',\n\t\t\t\t...edit,\n\t\t\t\tmeta: {\n\t\t\t\t\tundo: ! options.undoIgnore && {\n\t\t\t\t\t\t...edit,\n\t\t\t\t\t\t// Send the current values for things like the first undo stack entry.\n\t\t\t\t\t\tedits: Object.keys( edits ).reduce( ( acc, key ) => {\n\t\t\t\t\t\t\tacc[ key ] = editedRecord[ key ];\n\t\t\t\t\t\t\treturn acc;\n\t\t\t\t\t\t}, {} ),\n\t\t\t\t\t\tisCached: options.isCached,\n\t\t\t\t\t},\n\t\t\t\t},\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 undoEdit = select.getUndoEdits();\n\t\tif ( ! undoEdit ) {\n\t\t\treturn;\n\t\t}\n\t\tdispatch( {\n\t\t\ttype: 'UNDO',\n\t\t\tstackedEdits: undoEdit,\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 redoEdit = select.getRedoEdits();\n\t\tif ( ! redoEdit ) {\n\t\t\treturn;\n\t\t}\n\t\tdispatch( {\n\t\t\ttype: 'REDO',\n\t\t\tstackedEdits: redoEdit,\n\t\t} );\n\t};\n\n/**\n * Forces the creation of a new undo level.\n *\n * @return {Object} Action object.\n */\nexport function __unstableCreateUndoLevel() {\n\treturn { type: 'CREATE_UNDO_LEVEL' };\n}\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 ) );\n\t\tconst entityConfig = configs.find(\n\t\t\t( config ) => config.kind === kind && config.name === name\n\t\t);\n\t\tif ( ! entityConfig || entityConfig?.__experimentalNoFetch ) {\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\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: data.status,\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 ) );\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 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\t\tfor ( const edit in edits ) {\n\t\t\tif ( itemsToSave.some( ( item ) => item === edit ) ) {\n\t\t\t\teditsToSave[ edit ] = edits[ edit ];\n\t\t\t}\n\t\t}\n\n\t\tconst configs = await dispatch( getOrLoadEntitiesConfig( kind ) );\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\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"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,aAAa,MAAM,qBAAqB;AAC/C,SAASC,EAAE,IAAIC,IAAI,QAAQ,MAAM;;AAEjC;AACA;AACA;AACA,OAAOC,QAAQ,MAAM,sBAAsB;AAC3C,SAASC,YAAY,QAAQ,gBAAgB;AAC7C,OAAOC,UAAU,MAAM,uBAAuB;;AAE9C;AACA;AACA;AACA,SAASC,YAAY,EAAEC,WAAW,EAAEC,mBAAmB,QAAQ,gBAAgB;AAC/E,SAASC,uBAAuB,EAAEC,kBAAkB,QAAQ,YAAY;AACxE,SAASC,WAAW,QAAQ,SAAS;AACrC,SAASC,UAAU,QAAQ,QAAQ;AACnC,SAASC,eAAe,QAAQ,QAAQ;;AAExC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,gBAAgBA,CAAEC,OAAO,EAAEC,KAAK,EAAG;EAClD,OAAO;IACNC,IAAI,EAAE,oBAAoB;IAC1BD,KAAK,EAAEE,KAAK,CAACC,OAAO,CAAEH,KAAM,CAAC,GAAGA,KAAK,GAAG,CAAEA,KAAK,CAAE;IACjDD;EACD,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASK,kBAAkBA,CAAEC,WAAW,EAAG;EACjD,OAAO;IACNJ,IAAI,EAAE,sBAAsB;IAC5BI;EACD,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,WA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C;EAEA,OAAO,MAAMG,QAAQ,CAACsD,gBAAgB,CACrCvF,IAAI,EACJC,IAAI,EACJuH,WAAW,EACXrE,OACD,CAAC;AACF,CAAC;;AAEF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASwE,wBAAwBA,CAAEC,oBAAoB,EAAG;EAChEhJ,UAAU,CAAE,qDAAqD,EAAE;IAClE0C,KAAK,EAAE,KAAK;IACZuG,WAAW,EAAE;EACd,CAAE,CAAC;EAEH,OAAOC,qBAAqB,CAAE,cAAc,EAAEF,oBAAqB,CAAC;AACrE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASE,qBAAqBA,CAAE9D,GAAG,EAAE+D,SAAS,EAAG;EACvD,OAAO;IACNvI,IAAI,EAAE,yBAAyB;IAC/BwE,GAAG;IACH+D;EACD,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASzB,gBAAgBA,CAAE0B,MAAM,EAAEC,SAAS,EAAG;EACrD,OAAO;IACNzI,IAAI,EAAE,mBAAmB;IACzBwI,MAAM;IACNC,SAAS,EAAExI,KAAK,CAACC,OAAO,CAAEuI,SAAU,CAAC,GAAGA,SAAS,GAAG,CAAEA,SAAS;EAChE,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,2BAA2BA,CAAEC,UAAU,EAAG;EACzD,OAAO;IACN3I,IAAI,EAAE,gCAAgC;IACtC2I;EACD,CAAC;AACF"}
1
+ {"version":3,"names":["fastDeepEqual","v4","uuid","apiFetch","addQueryArgs","deprecated","getNestedValue","setNestedValue","receiveItems","removeItems","receiveQueriedItems","getOrLoadEntitiesConfig","DEFAULT_ENTITY_KEY","createBatch","STORE_NAME","getSyncProvider","receiveUserQuery","queryID","users","type","Array","isArray","receiveCurrentUser","currentUser","addEntities","entities","receiveEntityRecords","kind","name","records","query","invalidateCache","edits","map","record","status","title","action","receiveCurrentTheme","currentTheme","__experimentalReceiveCurrentGlobalStylesId","currentGlobalStylesId","id","__experimentalReceiveThemeBaseGlobalStyles","stylesheet","globalStyles","__experimentalReceiveThemeGlobalStyleVariations","variations","receiveThemeSupports","since","receiveThemeGlobalStyleRevisions","currentId","revisions","receiveEmbedPreview","url","preview","deleteEntityRecord","recordId","__unstableFetch","throwOnError","dispatch","configs","entityConfig","find","config","error","deletedRecord","__experimentalNoFetch","lock","__unstableAcquireStoreLock","exclusive","hasError","path","baseURL","method","_error","__unstableReleaseStoreLock","editEntityRecord","options","select","getEntityConfig","Error","mergedEdits","getRawEntityRecord","editedRecord","getEditedEntityRecord","edit","Object","keys","reduce","acc","key","recordValue","editedRecordValue","value","undefined","window","__experimentalEnableSync","syncConfig","objectId","getSyncObjectId","update","syncObjectType","undoIgnore","getUndoManager","addRecord","changes","from","to","isCached","undo","undoRecord","redo","redoRecord","__unstableCreateUndoLevel","saveEntityRecord","isAutosave","resolveSelect","entityIdKey","entries","evaluatedValue","updatedRecord","persistedRecord","getCurrentUser","currentUserId","autosavePost","getAutosave","data","includes","newRecord","receiveAutosaves","__unstablePrePersist","__experimentalBatch","requests","batch","api","add","saveEditedEntityRecord","resultPromises","request","results","Promise","all","run","hasEditsForEntityRecord","getEntityRecordNonTransientEdits","__experimentalSaveSpecifiedEntityEdits","itemsToSave","editsToSave","item","receiveUploadPermissions","hasUploadPermissions","alternative","receiveUserPermission","isAllowed","postId","autosaves","receiveNavigationFallbackId","fallbackId"],"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 * @return {Object} Action object.\n */\nexport function receiveEntityRecords(\n\tkind,\n\tname,\n\trecords,\n\tquery,\n\tinvalidateCache = false,\n\tedits\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 );\n\t} else {\n\t\taction = receiveItems( records, edits );\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 direclty.\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 * @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\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 ) );\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 || entityConfig?.__experimentalNoFetch ) {\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\tconst objectId = entityConfig.getSyncObjectId( recordId );\n\t\t\tgetSyncProvider().update(\n\t\t\t\tentityConfig.syncObjectType + '--edit',\n\t\t\t\tobjectId,\n\t\t\t\tedit.edits\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 ) );\n\t\tconst entityConfig = configs.find(\n\t\t\t( config ) => config.kind === kind && config.name === name\n\t\t);\n\t\tif ( ! entityConfig || entityConfig?.__experimentalNoFetch ) {\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\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: data.status,\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 ) );\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 ) );\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"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,aAAa,MAAM,qBAAqB;AAC/C,SAASC,EAAE,IAAIC,IAAI,QAAQ,MAAM;;AAEjC;AACA;AACA;AACA,OAAOC,QAAQ,MAAM,sBAAsB;AAC3C,SAASC,YAAY,QAAQ,gBAAgB;AAC7C,OAAOC,UAAU,MAAM,uBAAuB;;AAE9C;AACA;AACA;AACA,SAASC,cAAc,EAAEC,cAAc,QAAQ,SAAS;AACxD,SAASC,YAAY,EAAEC,WAAW,EAAEC,mBAAmB,QAAQ,gBAAgB;AAC/E,SAASC,uBAAuB,EAAEC,kBAAkB,QAAQ,YAAY;AACxE,SAASC,WAAW,QAAQ,SAAS;AACrC,SAASC,UAAU,QAAQ,QAAQ;AACnC,SAASC,eAAe,QAAQ,QAAQ;;AAExC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA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AAI;IACJC,IAAI;IACJG;EACD,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASO,mBAAmBA,CAAEC,YAAY,EAAG;EACnD,OAAO;IACNpB,IAAI,EAAE,uBAAuB;IAC7BoB;EACD,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,0CAA0CA,CACzDC,qBAAqB,EACpB;EACD,OAAO;IACNtB,IAAI,EAAE,kCAAkC;IACxCuB,EAAE,EAAED;EACL,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASE,0CAA0CA,CACzDC,UAAU,EACVC,YAAY,EACX;EACD,OAAO;IACN1B,IAAI,EAAE,6BAA6B;IACnCyB,UAAU;IACVC;EACD,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,+CAA+CA,CAC9DF,UAAU,EACVG,UAAU,EACT;EACD,OAAO;IACN5B,IAAI,EAAE,uCAAuC;IAC7CyB,UAAU;IACVG;EACD,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,oBAAoBA,CAAA,EAAG;EACtC3C,UAAU,CAAE,iDAAiD,EAAE;IAC9D4C,KAAK,EAAE;EACR,CAAE,CAAC;EAEH,OAAO;IACN9B,IAAI,EAAE;EACP,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAAS+B,gCAAgCA,CAAEC,SAAS,EAAEC,SAAS,EAAG;EACxE,OAAO;IACNjC,IAAI,EAAE,sCAAsC;IAC5CgC,SAAS;IACTC;EACD,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,mBAAmBA,CAAEC,G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AACA;AACA,OAAO,SAASxB,gBAAgBA,CAAEyB,MAAM,EAAEC,SAAS,EAAG;EACrD,OAAO;IACNzI,IAAI,EAAE,mBAAmB;IACzBwI,MAAM;IACNC,SAAS,EAAExI,KAAK,CAACC,OAAO,CAAEuI,SAAU,CAAC,GAAGA,SAAS,GAAG,CAAEA,SAAS;EAChE,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,2BAA2BA,CAAEC,UAAU,EAAG;EACzD,OAAO;IACN3I,IAAI,EAAE,gCAAgC;IACtC2I;EACD,CAAC;AACF"}
@@ -5,18 +5,16 @@ import { createElement } from "@wordpress/element";
5
5
  import { createContext, useContext, useCallback, useMemo } from '@wordpress/element';
6
6
  import { useSelect, useDispatch } from '@wordpress/data';
7
7
  import { parse, __unstableSerializeAndClean } from '@wordpress/blocks';
8
- import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
9
8
 
10
9
  /**
11
10
  * Internal dependencies
12
11
  */
13
12
  import { STORE_NAME } from './name';
14
- import { unlock } from './private-apis';
13
+ import { updateFootnotesFromMeta } from './footnotes';
15
14
 
16
15
  /** @typedef {import('@wordpress/blocks').WPBlock} WPBlock */
17
16
 
18
17
  const EMPTY_ARRAY = [];
19
- let oldFootnotes = {};
20
18
 
21
19
  /**
22
20
  * Internal dependencies
@@ -179,102 +177,7 @@ export function useEntityBlockEditor(kind, name, {
179
177
  }
180
178
  return content && typeof content !== 'function' ? parse(content) : EMPTY_ARRAY;
181
179
  }, [editedBlocks, content]);
182
- const updateFootnotes = useCallback(_blocks => {
183
- const output = {
184
- blocks: _blocks
185
- };
186
- if (!meta) return output;
187
- // If meta.footnotes is empty, it means the meta is not registered.
188
- if (meta.footnotes === undefined) return output;
189
- const {
190
- getRichTextValues
191
- } = unlock(blockEditorPrivateApis);
192
- const _content = getRichTextValues(_blocks).join('') || '';
193
- const newOrder = [];
194
-
195
- // This can be avoided when
196
- // https://github.com/WordPress/gutenberg/pull/43204 lands. We can then
197
- // get the order directly from the rich text values.
198
- if (_content.indexOf('data-fn') !== -1) {
199
- const regex = /data-fn="([^"]+)"/g;
200
- let match;
201
- while ((match = regex.exec(_content)) !== null) {
202
- newOrder.push(match[1]);
203
- }
204
- }
205
- const footnotes = meta.footnotes ? JSON.parse(meta.footnotes) : [];
206
- const currentOrder = footnotes.map(fn => fn.id);
207
- if (currentOrder.join('') === newOrder.join('')) return output;
208
- const newFootnotes = newOrder.map(fnId => footnotes.find(fn => fn.id === fnId) || oldFootnotes[fnId] || {
209
- id: fnId,
210
- content: ''
211
- });
212
- function updateAttributes(attributes) {
213
- // Only attempt to update attributes, if attributes is an object.
214
- if (!attributes || Array.isArray(attributes) || typeof attributes !== 'object') {
215
- return attributes;
216
- }
217
- attributes = {
218
- ...attributes
219
- };
220
- for (const key in attributes) {
221
- const value = attributes[key];
222
- if (Array.isArray(value)) {
223
- attributes[key] = value.map(updateAttributes);
224
- continue;
225
- }
226
- if (typeof value !== 'string') {
227
- continue;
228
- }
229
- if (value.indexOf('data-fn') === -1) {
230
- continue;
231
- }
232
-
233
- // When we store rich text values, this would no longer
234
- // require a regex.
235
- const regex = /(<sup[^>]+data-fn="([^"]+)"[^>]*><a[^>]*>)[\d*]*<\/a><\/sup>/g;
236
- attributes[key] = value.replace(regex, (match, opening, fnId) => {
237
- const index = newOrder.indexOf(fnId);
238
- return `${opening}${index + 1}</a></sup>`;
239
- });
240
- const compatRegex = /<a[^>]+data-fn="([^"]+)"[^>]*>\*<\/a>/g;
241
- attributes[key] = attributes[key].replace(compatRegex, (match, fnId) => {
242
- const index = newOrder.indexOf(fnId);
243
- return `<sup data-fn="${fnId}" class="fn"><a href="#${fnId}" id="${fnId}-link">${index + 1}</a></sup>`;
244
- });
245
- }
246
- return attributes;
247
- }
248
- function updateBlocksAttributes(__blocks) {
249
- return __blocks.map(block => {
250
- return {
251
- ...block,
252
- attributes: updateAttributes(block.attributes),
253
- innerBlocks: updateBlocksAttributes(block.innerBlocks)
254
- };
255
- });
256
- }
257
-
258
- // We need to go through all block attributes deeply and update the
259
- // footnote anchor numbering (textContent) to match the new order.
260
- const newBlocks = updateBlocksAttributes(_blocks);
261
- oldFootnotes = {
262
- ...oldFootnotes,
263
- ...footnotes.reduce((acc, fn) => {
264
- if (!newOrder.includes(fn.id)) {
265
- acc[fn.id] = fn;
266
- }
267
- return acc;
268
- }, {})
269
- };
270
- return {
271
- meta: {
272
- ...meta,
273
- footnotes: JSON.stringify(newFootnotes)
274
- },
275
- blocks: newBlocks
276
- };
277
- }, [meta]);
180
+ const updateFootnotes = useCallback(_blocks => updateFootnotesFromMeta(_blocks, meta), [meta]);
278
181
  const onChange = useCallback((newBlocks, options) => {
279
182
  const noChange = blocks === newBlocks;
280
183
  if (noChange) {
@@ -1 +1 @@
1
- {"version":3,"names":["createContext","useContext","useCallback","useMemo","useSelect","useDispatch","parse","__unstableSerializeAndClean","privateApis","blockEditorPrivateApis","STORE_NAME","unlock","EMPTY_ARRAY","oldFootnotes","rootEntitiesConfig","additionalEntityConfigLoaders","entityContexts","reduce","acc","loader","kind","name","context","undefined","getEntityContext","Error","EntityProvider","type","id","children","Provider","createElement","value","useEntityId","useEntityProp","prop","_id","providerId","fullValue","select","getEntityRecord","getEditedEntityRecord","record","editedRecord","editEntityRecord","setValue","newValue","useEntityBlockEditor","content","editedBlocks","meta","blocks","__unstableCreateUndoLevel","updateFootnotes","_blocks","output","footnotes","getRichTextValues","_content","join","newOrder","indexOf","regex","match","exec","push","JSON","currentOrder","map","fn","newFootnotes","fnId","find","updateAttributes","attributes","Array","isArray","key","replace","opening","index","compatRegex","updateBlocksAttributes","__blocks","block","innerBlocks","newBlocks","includes","stringify","onChange","options","noChange","selection","edits","blocksForSerialization","isCached","onInput","footnotesChanges"],"sources":["@wordpress/core-data/src/entity-provider.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tcreateContext,\n\tuseContext,\n\tuseCallback,\n\tuseMemo,\n} from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { parse, __unstableSerializeAndClean } from '@wordpress/blocks';\nimport { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { STORE_NAME } from './name';\nimport { unlock } from './private-apis';\n\n/** @typedef {import('@wordpress/blocks').WPBlock} WPBlock */\n\nconst EMPTY_ARRAY = [];\n\nlet oldFootnotes = {};\n\n/**\n * Internal dependencies\n */\nimport { rootEntitiesConfig, additionalEntityConfigLoaders } from './entities';\n\nconst entityContexts = {\n\t...rootEntitiesConfig.reduce( ( acc, loader ) => {\n\t\tif ( ! acc[ loader.kind ] ) {\n\t\t\tacc[ loader.kind ] = {};\n\t\t}\n\t\tacc[ loader.kind ][ loader.name ] = {\n\t\t\tcontext: createContext( undefined ),\n\t\t};\n\t\treturn acc;\n\t}, {} ),\n\t...additionalEntityConfigLoaders.reduce( ( acc, loader ) => {\n\t\tacc[ loader.kind ] = {};\n\t\treturn acc;\n\t}, {} ),\n};\nconst getEntityContext = ( kind, name ) => {\n\tif ( ! entityContexts[ kind ] ) {\n\t\tthrow new Error( `Missing entity config for kind: ${ kind }.` );\n\t}\n\n\tif ( ! entityContexts[ kind ][ name ] ) {\n\t\tentityContexts[ kind ][ name ] = {\n\t\t\tcontext: createContext( undefined ),\n\t\t};\n\t}\n\n\treturn entityContexts[ kind ][ name ].context;\n};\n\n/**\n * Context provider component for providing\n * an entity for a specific entity.\n *\n * @param {Object} props The component's props.\n * @param {string} props.kind The entity kind.\n * @param {string} props.type The entity name.\n * @param {number} props.id The entity ID.\n * @param {*} props.children The children to wrap.\n *\n * @return {Object} The provided children, wrapped with\n * the entity's context provider.\n */\nexport default function EntityProvider( { kind, type: name, id, children } ) {\n\tconst Provider = getEntityContext( kind, name ).Provider;\n\treturn <Provider value={ id }>{ children }</Provider>;\n}\n\n/**\n * Hook that returns the ID for the nearest\n * provided entity of the specified type.\n *\n * @param {string} kind The entity kind.\n * @param {string} name The entity name.\n */\nexport function useEntityId( kind, name ) {\n\treturn useContext( getEntityContext( kind, name ) );\n}\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 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\n/**\n * Hook that returns block content getters and setters for\n * the nearest provided entity of the specified type.\n *\n * The return value has the shape `[ blocks, onInput, onChange ]`.\n * `onInput` is for block changes that don't create undo levels\n * or dirty the post, non-persistent changes, and `onChange` is for\n * persistent changes. They map directly to the props of a\n * `BlockEditorProvider` and are intended to be used with it,\n * or similar components or hooks.\n *\n * @param {string} kind The entity kind.\n * @param {string} name The entity name.\n * @param {Object} options\n * @param {string} [options.id] An entity ID to use instead of the context-provided one.\n *\n * @return {[WPBlock[], Function, Function]} The block array and setters.\n */\nexport function useEntityBlockEditor( kind, name, { id: _id } = {} ) {\n\tconst providerId = useEntityId( kind, name );\n\tconst id = _id ?? providerId;\n\tconst { content, editedBlocks, meta } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEditedEntityRecord } = select( STORE_NAME );\n\t\t\tconst editedRecord = getEditedEntityRecord( kind, name, id );\n\t\t\treturn {\n\t\t\t\teditedBlocks: editedRecord.blocks,\n\t\t\t\tcontent: editedRecord.content,\n\t\t\t\tmeta: editedRecord.meta,\n\t\t\t};\n\t\t},\n\t\t[ kind, name, id ]\n\t);\n\tconst { __unstableCreateUndoLevel, editEntityRecord } =\n\t\tuseDispatch( STORE_NAME );\n\n\tconst blocks = useMemo( () => {\n\t\tif ( editedBlocks ) {\n\t\t\treturn editedBlocks;\n\t\t}\n\n\t\treturn content && typeof content !== 'function'\n\t\t\t? parse( content )\n\t\t\t: EMPTY_ARRAY;\n\t}, [ editedBlocks, content ] );\n\n\tconst updateFootnotes = useCallback(\n\t\t( _blocks ) => {\n\t\t\tconst output = { blocks: _blocks };\n\t\t\tif ( ! meta ) return output;\n\t\t\t// If meta.footnotes is empty, it means the meta is not registered.\n\t\t\tif ( meta.footnotes === undefined ) return output;\n\n\t\t\tconst { getRichTextValues } = unlock( blockEditorPrivateApis );\n\t\t\tconst _content = getRichTextValues( _blocks ).join( '' ) || '';\n\t\t\tconst newOrder = [];\n\n\t\t\t// This can be avoided when\n\t\t\t// https://github.com/WordPress/gutenberg/pull/43204 lands. We can then\n\t\t\t// get the order directly from the rich text values.\n\t\t\tif ( _content.indexOf( 'data-fn' ) !== -1 ) {\n\t\t\t\tconst regex = /data-fn=\"([^\"]+)\"/g;\n\t\t\t\tlet match;\n\t\t\t\twhile ( ( match = regex.exec( _content ) ) !== null ) {\n\t\t\t\t\tnewOrder.push( match[ 1 ] );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst footnotes = meta.footnotes\n\t\t\t\t? JSON.parse( meta.footnotes )\n\t\t\t\t: [];\n\t\t\tconst currentOrder = footnotes.map( ( fn ) => fn.id );\n\n\t\t\tif ( currentOrder.join( '' ) === newOrder.join( '' ) )\n\t\t\t\treturn output;\n\n\t\t\tconst newFootnotes = newOrder.map(\n\t\t\t\t( fnId ) =>\n\t\t\t\t\tfootnotes.find( ( fn ) => fn.id === fnId ) ||\n\t\t\t\t\toldFootnotes[ fnId ] || {\n\t\t\t\t\t\tid: fnId,\n\t\t\t\t\t\tcontent: '',\n\t\t\t\t\t}\n\t\t\t);\n\n\t\t\tfunction updateAttributes( attributes ) {\n\t\t\t\t// Only attempt to update attributes, if attributes is an object.\n\t\t\t\tif (\n\t\t\t\t\t! attributes ||\n\t\t\t\t\tArray.isArray( attributes ) ||\n\t\t\t\t\ttypeof attributes !== 'object'\n\t\t\t\t) {\n\t\t\t\t\treturn attributes;\n\t\t\t\t}\n\n\t\t\t\tattributes = { ...attributes };\n\n\t\t\t\tfor ( const key in attributes ) {\n\t\t\t\t\tconst value = attributes[ key ];\n\n\t\t\t\t\tif ( Array.isArray( value ) ) {\n\t\t\t\t\t\tattributes[ key ] = value.map( updateAttributes );\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( typeof value !== 'string' ) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( value.indexOf( 'data-fn' ) === -1 ) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\t// When we store rich text values, this would no longer\n\t\t\t\t\t// require a regex.\n\t\t\t\t\tconst regex =\n\t\t\t\t\t\t/(<sup[^>]+data-fn=\"([^\"]+)\"[^>]*><a[^>]*>)[\\d*]*<\\/a><\\/sup>/g;\n\n\t\t\t\t\tattributes[ key ] = value.replace(\n\t\t\t\t\t\tregex,\n\t\t\t\t\t\t( match, opening, fnId ) => {\n\t\t\t\t\t\t\tconst index = newOrder.indexOf( fnId );\n\t\t\t\t\t\t\treturn `${ opening }${ index + 1 }</a></sup>`;\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\n\t\t\t\t\tconst compatRegex =\n\t\t\t\t\t\t/<a[^>]+data-fn=\"([^\"]+)\"[^>]*>\\*<\\/a>/g;\n\n\t\t\t\t\tattributes[ key ] = attributes[ key ].replace(\n\t\t\t\t\t\tcompatRegex,\n\t\t\t\t\t\t( match, fnId ) => {\n\t\t\t\t\t\t\tconst index = newOrder.indexOf( fnId );\n\t\t\t\t\t\t\treturn `<sup data-fn=\"${ fnId }\" class=\"fn\"><a href=\"#${ fnId }\" id=\"${ fnId }-link\">${\n\t\t\t\t\t\t\t\tindex + 1\n\t\t\t\t\t\t\t}</a></sup>`;\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn attributes;\n\t\t\t}\n\n\t\t\tfunction updateBlocksAttributes( __blocks ) {\n\t\t\t\treturn __blocks.map( ( block ) => {\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...block,\n\t\t\t\t\t\tattributes: updateAttributes( block.attributes ),\n\t\t\t\t\t\tinnerBlocks: updateBlocksAttributes(\n\t\t\t\t\t\t\tblock.innerBlocks\n\t\t\t\t\t\t),\n\t\t\t\t\t};\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\t// We need to go through all block attributes deeply and update the\n\t\t\t// footnote anchor numbering (textContent) to match the new order.\n\t\t\tconst newBlocks = updateBlocksAttributes( _blocks );\n\n\t\t\toldFootnotes = {\n\t\t\t\t...oldFootnotes,\n\t\t\t\t...footnotes.reduce( ( acc, fn ) => {\n\t\t\t\t\tif ( ! newOrder.includes( fn.id ) ) {\n\t\t\t\t\t\tacc[ fn.id ] = fn;\n\t\t\t\t\t}\n\t\t\t\t\treturn acc;\n\t\t\t\t}, {} ),\n\t\t\t};\n\n\t\t\treturn {\n\t\t\t\tmeta: {\n\t\t\t\t\t...meta,\n\t\t\t\t\tfootnotes: JSON.stringify( newFootnotes ),\n\t\t\t\t},\n\t\t\t\tblocks: newBlocks,\n\t\t\t};\n\t\t},\n\t\t[ meta ]\n\t);\n\n\tconst onChange = useCallback(\n\t\t( newBlocks, options ) => {\n\t\t\tconst noChange = blocks === newBlocks;\n\t\t\tif ( noChange ) {\n\t\t\t\treturn __unstableCreateUndoLevel( kind, name, id );\n\t\t\t}\n\t\t\tconst { selection } = options;\n\n\t\t\t// We create a new function here on every persistent edit\n\t\t\t// to make sure the edit makes the post dirty and creates\n\t\t\t// a new undo level.\n\t\t\tconst edits = {\n\t\t\t\tselection,\n\t\t\t\tcontent: ( { blocks: blocksForSerialization = [] } ) =>\n\t\t\t\t\t__unstableSerializeAndClean( blocksForSerialization ),\n\t\t\t\t...updateFootnotes( newBlocks ),\n\t\t\t};\n\n\t\t\teditEntityRecord( kind, name, id, edits, { isCached: false } );\n\t\t},\n\t\t[\n\t\t\tkind,\n\t\t\tname,\n\t\t\tid,\n\t\t\tblocks,\n\t\t\tupdateFootnotes,\n\t\t\t__unstableCreateUndoLevel,\n\t\t\teditEntityRecord,\n\t\t]\n\t);\n\n\tconst onInput = useCallback(\n\t\t( newBlocks, options ) => {\n\t\t\tconst { selection } = options;\n\t\t\tconst footnotesChanges = updateFootnotes( newBlocks );\n\t\t\tconst edits = { selection, ...footnotesChanges };\n\n\t\t\teditEntityRecord( kind, name, id, edits, { isCached: true } );\n\t\t},\n\t\t[ kind, name, id, updateFootnotes, editEntityRecord ]\n\t);\n\n\treturn [ blocks, onInput, onChange ];\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SACCA,aAAa,EACbC,UAAU,EACVC,WAAW,EACXC,OAAO,QACD,oBAAoB;AAC3B,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,KAAK,EAAEC,2BAA2B,QAAQ,mBAAmB;AACtE,SAASC,WAAW,IAAIC,sBAAsB,QAAQ,yBAAyB;;AA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;IAEhDrD,gBAAgB,CAAExB,IAAI,EAAEC,IAAI,EAAEO,EAAE,EAAEiE,KAAK,EAAE;MAAEE,QAAQ,EAAE;IAAK,CAAE,CAAC;EAC9D,CAAC,EACD,CAAE3E,IAAI,EAAEC,IAAI,EAAEO,EAAE,EAAEyB,eAAe,EAAET,gBAAgB,CACpD,CAAC;EAED,OAAO,CAAEO,MAAM,EAAE6C,OAAO,EAAEP,QAAQ,CAAE;AACrC"}
1
+ {"version":3,"names":["createContext","useContext","useCallback","useMemo","useSelect","useDispatch","parse","__unstableSerializeAndClean","STORE_NAME","updateFootnotesFromMeta","EMPTY_ARRAY","rootEntitiesConfig","additionalEntityConfigLoaders","entityContexts","reduce","acc","loader","kind","name","context","undefined","getEntityContext","Error","EntityProvider","type","id","children","Provider","createElement","value","useEntityId","useEntityProp","prop","_id","providerId","fullValue","select","getEntityRecord","getEditedEntityRecord","record","editedRecord","editEntityRecord","setValue","newValue","useEntityBlockEditor","content","editedBlocks","meta","blocks","__unstableCreateUndoLevel","updateFootnotes","_blocks","onChange","newBlocks","options","noChange","selection","edits","blocksForSerialization","isCached","onInput","footnotesChanges"],"sources":["@wordpress/core-data/src/entity-provider.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tcreateContext,\n\tuseContext,\n\tuseCallback,\n\tuseMemo,\n} from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { parse, __unstableSerializeAndClean } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { STORE_NAME } from './name';\nimport { updateFootnotesFromMeta } from './footnotes';\n\n/** @typedef {import('@wordpress/blocks').WPBlock} WPBlock */\n\nconst EMPTY_ARRAY = [];\n\n/**\n * Internal dependencies\n */\nimport { rootEntitiesConfig, additionalEntityConfigLoaders } from './entities';\n\nconst entityContexts = {\n\t...rootEntitiesConfig.reduce( ( acc, loader ) => {\n\t\tif ( ! acc[ loader.kind ] ) {\n\t\t\tacc[ loader.kind ] = {};\n\t\t}\n\t\tacc[ loader.kind ][ loader.name ] = {\n\t\t\tcontext: createContext( undefined ),\n\t\t};\n\t\treturn acc;\n\t}, {} ),\n\t...additionalEntityConfigLoaders.reduce( ( acc, loader ) => {\n\t\tacc[ loader.kind ] = {};\n\t\treturn acc;\n\t}, {} ),\n};\nconst getEntityContext = ( kind, name ) => {\n\tif ( ! entityContexts[ kind ] ) {\n\t\tthrow new Error( `Missing entity config for kind: ${ kind }.` );\n\t}\n\n\tif ( ! entityContexts[ kind ][ name ] ) {\n\t\tentityContexts[ kind ][ name ] = {\n\t\t\tcontext: createContext( undefined ),\n\t\t};\n\t}\n\n\treturn entityContexts[ kind ][ name ].context;\n};\n\n/**\n * Context provider component for providing\n * an entity for a specific entity.\n *\n * @param {Object} props The component's props.\n * @param {string} props.kind The entity kind.\n * @param {string} props.type The entity name.\n * @param {number} props.id The entity ID.\n * @param {*} props.children The children to wrap.\n *\n * @return {Object} The provided children, wrapped with\n * the entity's context provider.\n */\nexport default function EntityProvider( { kind, type: name, id, children } ) {\n\tconst Provider = getEntityContext( kind, name ).Provider;\n\treturn <Provider value={ id }>{ children }</Provider>;\n}\n\n/**\n * Hook that returns the ID for the nearest\n * provided entity of the specified type.\n *\n * @param {string} kind The entity kind.\n * @param {string} name The entity name.\n */\nexport function useEntityId( kind, name ) {\n\treturn useContext( getEntityContext( kind, name ) );\n}\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 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\n/**\n * Hook that returns block content getters and setters for\n * the nearest provided entity of the specified type.\n *\n * The return value has the shape `[ blocks, onInput, onChange ]`.\n * `onInput` is for block changes that don't create undo levels\n * or dirty the post, non-persistent changes, and `onChange` is for\n * persistent changes. They map directly to the props of a\n * `BlockEditorProvider` and are intended to be used with it,\n * or similar components or hooks.\n *\n * @param {string} kind The entity kind.\n * @param {string} name The entity name.\n * @param {Object} options\n * @param {string} [options.id] An entity ID to use instead of the context-provided one.\n *\n * @return {[WPBlock[], Function, Function]} The block array and setters.\n */\nexport function useEntityBlockEditor( kind, name, { id: _id } = {} ) {\n\tconst providerId = useEntityId( kind, name );\n\tconst id = _id ?? providerId;\n\tconst { content, editedBlocks, meta } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEditedEntityRecord } = select( STORE_NAME );\n\t\t\tconst editedRecord = getEditedEntityRecord( kind, name, id );\n\t\t\treturn {\n\t\t\t\teditedBlocks: editedRecord.blocks,\n\t\t\t\tcontent: editedRecord.content,\n\t\t\t\tmeta: editedRecord.meta,\n\t\t\t};\n\t\t},\n\t\t[ kind, name, id ]\n\t);\n\tconst { __unstableCreateUndoLevel, editEntityRecord } =\n\t\tuseDispatch( STORE_NAME );\n\n\tconst blocks = useMemo( () => {\n\t\tif ( editedBlocks ) {\n\t\t\treturn editedBlocks;\n\t\t}\n\n\t\treturn content && typeof content !== 'function'\n\t\t\t? parse( content )\n\t\t\t: EMPTY_ARRAY;\n\t}, [ editedBlocks, content ] );\n\n\tconst updateFootnotes = useCallback(\n\t\t( _blocks ) => updateFootnotesFromMeta( _blocks, meta ),\n\t\t[ meta ]\n\t);\n\n\tconst onChange = useCallback(\n\t\t( newBlocks, options ) => {\n\t\t\tconst noChange = blocks === newBlocks;\n\t\t\tif ( noChange ) {\n\t\t\t\treturn __unstableCreateUndoLevel( kind, name, id );\n\t\t\t}\n\t\t\tconst { selection } = options;\n\n\t\t\t// We create a new function here on every persistent edit\n\t\t\t// to make sure the edit makes the post dirty and creates\n\t\t\t// a new undo level.\n\t\t\tconst edits = {\n\t\t\t\tselection,\n\t\t\t\tcontent: ( { blocks: blocksForSerialization = [] } ) =>\n\t\t\t\t\t__unstableSerializeAndClean( blocksForSerialization ),\n\t\t\t\t...updateFootnotes( newBlocks ),\n\t\t\t};\n\n\t\t\teditEntityRecord( kind, name, id, edits, { isCached: false } );\n\t\t},\n\t\t[\n\t\t\tkind,\n\t\t\tname,\n\t\t\tid,\n\t\t\tblocks,\n\t\t\tupdateFootnotes,\n\t\t\t__unstableCreateUndoLevel,\n\t\t\teditEntityRecord,\n\t\t]\n\t);\n\n\tconst onInput = useCallback(\n\t\t( newBlocks, options ) => {\n\t\t\tconst { selection } = options;\n\t\t\tconst footnotesChanges = updateFootnotes( newBlocks );\n\t\t\tconst edits = { selection, ...footnotesChanges };\n\n\t\t\teditEntityRecord( kind, name, id, edits, { isCached: true } );\n\t\t},\n\t\t[ kind, name, id, updateFootnotes, editEntityRecord ]\n\t);\n\n\treturn [ blocks, onInput, onChange ];\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SACCA,a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,gBAAgB,CAAExB,IAAI,EAAEC,IAAI,EAAEO,EAAE,EAAEgC,KAAK,EAAE;MAAEE,QAAQ,EAAE;IAAM,CAAE,CAAC;EAC/D,CAAC,EACD,CACC1C,IAAI,EACJC,IAAI,EACJO,EAAE,EACFuB,MAAM,EACNE,eAAe,EACfD,yBAAyB,EACzBR,gBAAgB,CAElB,CAAC;EAED,MAAMmB,OAAO,GAAG1D,WAAW,CAC1B,CAAEmD,SAAS,EAAEC,OAAO,KAAM;IACzB,MAAM;MAAEE;IAAU,CAAC,GAAGF,OAAO;IAC7B,MAAMO,gBAAgB,GAAGX,eAAe,CAAEG,SAAU,CAAC;IACrD,MAAMI,KAAK,GAAG;MAAED,SAAS;MAAE,GAAGK;IAAiB,CAAC;IAEhDpB,gBAAgB,CAAExB,IAAI,EAAEC,IAAI,EAAEO,EAAE,EAAEgC,KAAK,EAAE;MAAEE,QAAQ,EAAE;IAAK,CAAE,CAAC;EAC9D,CAAC,EACD,CAAE1C,IAAI,EAAEC,IAAI,EAAEO,EAAE,EAAEyB,eAAe,EAAET,gBAAgB,CACpD,CAAC;EAED,OAAO,CAAEO,MAAM,EAAEY,OAAO,EAAER,QAAQ,CAAE;AACrC"}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["@wordpress/core-data/src/entity-types/helpers.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport type { EntityRecord } from './index';\n\nexport interface AvatarUrls {\n\t/**\n\t * Avatar URL with image size of 24 pixels.\n\t */\n\t'24': string;\n\t/**\n\t * Avatar URL with image size of 48 pixels.\n\t */\n\t'48': string;\n\t/**\n\t * Avatar URL with image size of 96 pixels.\n\t */\n\t'96': string;\n}\n\nexport type MediaType = 'image' | 'file';\nexport type CommentingStatus = 'open' | 'closed';\nexport type PingStatus = 'open' | 'closed';\nexport type PostStatus = 'publish' | 'future' | 'draft' | 'pending' | 'private';\nexport type PostFormat =\n\t| 'standard'\n\t| 'aside'\n\t| 'chat'\n\t| 'gallery'\n\t| 'link'\n\t| 'image'\n\t| 'quote'\n\t| 'status'\n\t| 'video'\n\t| 'audio';\n\n/**\n * The REST API context parameter.\n */\nexport type Context = 'view' | 'edit' | 'embed';\n\n/**\n * ContextualField makes the field available only in the specified given contexts,\n * and ensure the field is absent from the object when in a different context.\n *\n * @example\n * ```ts\n * interface Post< C extends Context > {\n * \t…\n * \tmodified: ContextualField< string, 'edit' | 'view', C >;\n * \tpassword: ContextualField< string, 'edit', C >;\n * \t…\n * }\n *\n * const post: Post<'edit'> = …\n * // post.modified exists as a string\n * // post.password exists as a string\n *\n * const post: Post<'view'> = …\n * // post.modified still exists as a string\n * // post.password is missing, undefined, because we're not in the `edit` context.\n * ```\n */\nexport type ContextualField<\n\tFieldType,\n\tAvailableInContexts extends Context,\n\tC extends Context\n> = AvailableInContexts extends C ? FieldType : never;\n\n/**\n * Removes all the properties of type never, even the deeply nested ones.\n *\n * @example\n * ```ts\n * type MyType = {\n * foo: string;\n * bar: never;\n * nested: {\n * foo: string;\n * bar: never;\n * }\n * }\n * const x = {} as OmitNevers<MyType>;\n * // x is of type { foo: string; nested: { foo: string; }}\n * // The `never` properties were removed entirely\n * ```\n */\nexport type OmitNevers<\n\tT,\n\tNevers = {\n\t\t[ K in keyof T ]: Exclude< T[ K ], undefined > extends never\n\t\t\t? never\n\t\t\t: T[ K ] extends Record< string, unknown >\n\t\t\t? OmitNevers< T[ K ] >\n\t\t\t: T[ K ];\n\t}\n> = Pick<\n\tNevers,\n\t{\n\t\t[ K in keyof Nevers ]: Nevers[ K ] extends never ? never : K;\n\t}[ keyof Nevers ]\n>;\n\n/**\n * A string that the server renders which often involves\n * modifications from the raw source string.\n *\n * For example, block HTML with the comment delimiters exists\n * in `post_content` but those comments are stripped out when\n * rendering to a page view. Similarly, plugins might modify\n * content or replace shortcodes.\n */\nexport interface RenderedText< C extends Context > {\n\t/**\n\t * The source string which will be rendered on page views.\n\t */\n\traw: ContextualField< string, 'edit', C >;\n\t/**\n\t * The output of the raw source after processing and filtering on the server.\n\t */\n\trendered: string;\n}\n\n/**\n * Updatable<EntityRecord> is a type describing Edited Entity Records. They are like\n * regular Entity Records, but they have all the local edits applied on top of the REST API data.\n *\n * This turns certain field from an object into a string.\n *\n * Entities like Post have fields that only be rendered on the server, like title, excerpt,\n * and content. The REST API exposes both the raw markup and the rendered version of those fields.\n * For example, in the block editor, content.rendered could used as a visual preview, and\n * content.raw could be used to populate the code editor.\n *\n * When updating these rendered fields, Javascript is not be able to properly render arbitrary block\n * markup. Therefore, it stores only the raw markup without the rendered part. And since that's a string,\n * the entire field becomes a string.\n *\n * @example\n * ```ts\n * type Post< C extends Context > {\n * title: RenderedText< C >;\n * }\n * const post = {} as Post;\n * // post.title is an object with raw and rendered properties\n *\n * const updatablePost = {} as Updatable< Post >;\n * // updatablePost.title is a string\n * ```\n */\nexport type Updatable< T extends EntityRecord< 'edit' > > = {\n\t[ K in keyof T ]: T[ K ] extends RenderedText< any > ? string : T[ K ];\n};\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["@wordpress/core-data/src/entity-types/helpers.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport type { EntityRecord } from './index';\n\nexport interface AvatarUrls {\n\t/**\n\t * Avatar URL with image size of 24 pixels.\n\t */\n\t'24': string;\n\t/**\n\t * Avatar URL with image size of 48 pixels.\n\t */\n\t'48': string;\n\t/**\n\t * Avatar URL with image size of 96 pixels.\n\t */\n\t'96': string;\n}\n\nexport type MediaType = 'image' | 'file';\nexport type CommentingStatus = 'open' | 'closed';\nexport type PingStatus = 'open' | 'closed';\nexport type PostStatus = 'publish' | 'future' | 'draft' | 'pending' | 'private';\nexport type PostFormat =\n\t| 'standard'\n\t| 'aside'\n\t| 'chat'\n\t| 'gallery'\n\t| 'link'\n\t| 'image'\n\t| 'quote'\n\t| 'status'\n\t| 'video'\n\t| 'audio';\n\n/**\n * The REST API context parameter.\n */\nexport type Context = 'view' | 'edit' | 'embed';\n\n/**\n * ContextualField makes the field available only in the specified given contexts,\n * and ensure the field is absent from the object when in a different context.\n *\n * @example\n * ```ts\n * interface Post< C extends Context > {\n * \t…\n * \tmodified: ContextualField< string, 'edit' | 'view', C >;\n * \tpassword: ContextualField< string, 'edit', C >;\n * \t…\n * }\n *\n * const post: Post<'edit'> = …\n * // post.modified exists as a string\n * // post.password exists as a string\n *\n * const post: Post<'view'> = …\n * // post.modified still exists as a string\n * // post.password is missing, undefined, because we're not in the `edit` context.\n * ```\n */\nexport type ContextualField<\n\tFieldType,\n\tAvailableInContexts extends Context,\n\tC extends Context,\n> = AvailableInContexts extends C ? FieldType : never;\n\n/**\n * Removes all the properties of type never, even the deeply nested ones.\n *\n * @example\n * ```ts\n * type MyType = {\n * foo: string;\n * bar: never;\n * nested: {\n * foo: string;\n * bar: never;\n * }\n * }\n * const x = {} as OmitNevers<MyType>;\n * // x is of type { foo: string; nested: { foo: string; }}\n * // The `never` properties were removed entirely\n * ```\n */\nexport type OmitNevers<\n\tT,\n\tNevers = {\n\t\t[ K in keyof T ]: Exclude< T[ K ], undefined > extends never\n\t\t\t? never\n\t\t\t: T[ K ] extends Record< string, unknown >\n\t\t\t? OmitNevers< T[ K ] >\n\t\t\t: T[ K ];\n\t},\n> = Pick<\n\tNevers,\n\t{\n\t\t[ K in keyof Nevers ]: Nevers[ K ] extends never ? never : K;\n\t}[ keyof Nevers ]\n>;\n\n/**\n * A string that the server renders which often involves\n * modifications from the raw source string.\n *\n * For example, block HTML with the comment delimiters exists\n * in `post_content` but those comments are stripped out when\n * rendering to a page view. Similarly, plugins might modify\n * content or replace shortcodes.\n */\nexport interface RenderedText< C extends Context > {\n\t/**\n\t * The source string which will be rendered on page views.\n\t */\n\traw: ContextualField< string, 'edit', C >;\n\t/**\n\t * The output of the raw source after processing and filtering on the server.\n\t */\n\trendered: string;\n}\n\n/**\n * Updatable<EntityRecord> is a type describing Edited Entity Records. They are like\n * regular Entity Records, but they have all the local edits applied on top of the REST API data.\n *\n * This turns certain field from an object into a string.\n *\n * Entities like Post have fields that only be rendered on the server, like title, excerpt,\n * and content. The REST API exposes both the raw markup and the rendered version of those fields.\n * For example, in the block editor, content.rendered could used as a visual preview, and\n * content.raw could be used to populate the code editor.\n *\n * When updating these rendered fields, Javascript is not be able to properly render arbitrary block\n * markup. Therefore, it stores only the raw markup without the rendered part. And since that's a string,\n * the entire field becomes a string.\n *\n * @example\n * ```ts\n * type Post< C extends Context > {\n * title: RenderedText< C >;\n * }\n * const post = {} as Post;\n * // post.title is an object with raw and rendered properties\n *\n * const updatablePost = {} as Updatable< Post >;\n * // updatablePost.title is a string\n * ```\n */\nexport type Updatable< T extends EntityRecord< 'edit' > > = {\n\t[ K in keyof T ]: T[ K ] extends RenderedText< any > ? string : T[ K ];\n};\n"],"mappings":""}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Internal dependencies
3
+ */
4
+ import getRichTextValuesCached from './get-rich-text-values-cached';
5
+ const cache = new WeakMap();
6
+ function getBlockFootnotesOrder(block) {
7
+ if (!cache.has(block)) {
8
+ const content = getRichTextValuesCached(block).join('');
9
+ const newOrder = [];
10
+
11
+ // https://github.com/WordPress/gutenberg/pull/43204 lands. We can then
12
+ // get the order directly from the rich text values.
13
+ if (content.indexOf('data-fn') !== -1) {
14
+ const regex = /data-fn="([^"]+)"/g;
15
+ let match;
16
+ while ((match = regex.exec(content)) !== null) {
17
+ newOrder.push(match[1]);
18
+ }
19
+ }
20
+ cache.set(block, newOrder);
21
+ }
22
+ return cache.get(block);
23
+ }
24
+ export default function getFootnotesOrder(blocks) {
25
+ return blocks.flatMap(getBlockFootnotesOrder);
26
+ }
27
+ //# sourceMappingURL=get-footnotes-order.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["getRichTextValuesCached","cache","WeakMap","getBlockFootnotesOrder","block","has","content","join","newOrder","indexOf","regex","match","exec","push","set","get","getFootnotesOrder","blocks","flatMap"],"sources":["@wordpress/core-data/src/footnotes/get-footnotes-order.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport getRichTextValuesCached from './get-rich-text-values-cached';\n\nconst cache = new WeakMap();\n\nfunction getBlockFootnotesOrder( block ) {\n\tif ( ! cache.has( block ) ) {\n\t\tconst content = getRichTextValuesCached( block ).join( '' );\n\t\tconst newOrder = [];\n\n\t\t// https://github.com/WordPress/gutenberg/pull/43204 lands. We can then\n\t\t// get the order directly from the rich text values.\n\t\tif ( content.indexOf( 'data-fn' ) !== -1 ) {\n\t\t\tconst regex = /data-fn=\"([^\"]+)\"/g;\n\t\t\tlet match;\n\t\t\twhile ( ( match = regex.exec( content ) ) !== null ) {\n\t\t\t\tnewOrder.push( match[ 1 ] );\n\t\t\t}\n\t\t}\n\t\tcache.set( block, newOrder );\n\t}\n\n\treturn cache.get( block );\n}\n\nexport default function getFootnotesOrder( blocks ) {\n\treturn blocks.flatMap( getBlockFootnotesOrder );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,uBAAuB,MAAM,+BAA+B;AAEnE,MAAMC,KAAK,GAAG,IAAIC,OAAO,CAAC,CAAC;AAE3B,SAASC,sBAAsBA,CAAEC,KAAK,EAAG;EACxC,IAAK,CAAEH,KAAK,CAACI,GAAG,CAAED,KAAM,CAAC,EAAG;IAC3B,MAAME,OAAO,GAAGN,uBAAuB,CAAEI,KAAM,CAAC,CAACG,IAAI,CAAE,EAAG,CAAC;IAC3D,MAAMC,QAAQ,GAAG,EAAE;;IAEnB;IACA;IACA,IAAKF,OAAO,CAACG,OAAO,CAAE,SAAU,CAAC,KAAK,CAAC,CAAC,EAAG;MAC1C,MAAMC,KAAK,GAAG,oBAAoB;MAClC,IAAIC,KAAK;MACT,OAAQ,CAAEA,KAAK,GAAGD,KAAK,CAACE,IAAI,CAAEN,OAAQ,CAAC,MAAO,IAAI,EAAG;QACpDE,QAAQ,CAACK,IAAI,CAAEF,KAAK,CAAE,CAAC,CAAG,CAAC;MAC5B;IACD;IACAV,KAAK,CAACa,GAAG,CAAEV,KAAK,EAAEI,QAAS,CAAC;EAC7B;EAEA,OAAOP,KAAK,CAACc,GAAG,CAAEX,KAAM,CAAC;AAC1B;AAEA,eAAe,SAASY,iBAAiBA,CAAEC,MAAM,EAAG;EACnD,OAAOA,MAAM,CAACC,OAAO,CAAEf,sBAAuB,CAAC;AAChD"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
5
+
6
+ /**
7
+ * Internal dependencies
8
+ */
9
+ import { unlock } from '../private-apis';
10
+
11
+ // TODO: The following line should have been:
12
+ //
13
+ // const unlockedApis = unlock( blockEditorPrivateApis );
14
+ //
15
+ // But there are hidden circular dependencies in RNMobile code, specifically in
16
+ // certain native components in the `components` package that depend on
17
+ // `block-editor`. What follows is a workaround that defers the `unlock` call
18
+ // to prevent native code from failing.
19
+ //
20
+ // Fix once https://github.com/WordPress/gutenberg/issues/52692 is closed.
21
+ let unlockedApis;
22
+ const cache = new WeakMap();
23
+ export default function getRichTextValuesCached(block) {
24
+ if (!unlockedApis) {
25
+ unlockedApis = unlock(blockEditorPrivateApis);
26
+ }
27
+ if (!cache.has(block)) {
28
+ const values = unlockedApis.getRichTextValues([block]);
29
+ cache.set(block, values);
30
+ }
31
+ return cache.get(block);
32
+ }
33
+ //# sourceMappingURL=get-rich-text-values-cached.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["privateApis","blockEditorPrivateApis","unlock","unlockedApis","cache","WeakMap","getRichTextValuesCached","block","has","values","getRichTextValues","set","get"],"sources":["@wordpress/core-data/src/footnotes/get-rich-text-values-cached.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../private-apis';\n\n// TODO: The following line should have been:\n//\n// const unlockedApis = unlock( blockEditorPrivateApis );\n//\n// But there are hidden circular dependencies in RNMobile code, specifically in\n// certain native components in the `components` package that depend on\n// `block-editor`. What follows is a workaround that defers the `unlock` call\n// to prevent native code from failing.\n//\n// Fix once https://github.com/WordPress/gutenberg/issues/52692 is closed.\nlet unlockedApis;\n\nconst cache = new WeakMap();\n\nexport default function getRichTextValuesCached( block ) {\n\tif ( ! unlockedApis ) {\n\t\tunlockedApis = unlock( blockEditorPrivateApis );\n\t}\n\n\tif ( ! cache.has( block ) ) {\n\t\tconst values = unlockedApis.getRichTextValues( [ block ] );\n\t\tcache.set( block, values );\n\t}\n\treturn cache.get( block );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,WAAW,IAAIC,sBAAsB,QAAQ,yBAAyB;;AAE/E;AACA;AACA;AACA,SAASC,MAAM,QAAQ,iBAAiB;;AAExC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAIC,YAAY;AAEhB,MAAMC,KAAK,GAAG,IAAIC,OAAO,CAAC,CAAC;AAE3B,eAAe,SAASC,uBAAuBA,CAAEC,KAAK,EAAG;EACxD,IAAK,CAAEJ,YAAY,EAAG;IACrBA,YAAY,GAAGD,MAAM,CAAED,sBAAuB,CAAC;EAChD;EAEA,IAAK,CAAEG,KAAK,CAACI,GAAG,CAAED,KAAM,CAAC,EAAG;IAC3B,MAAME,MAAM,GAAGN,YAAY,CAACO,iBAAiB,CAAE,CAAEH,KAAK,CAAG,CAAC;IAC1DH,KAAK,CAACO,GAAG,CAAEJ,KAAK,EAAEE,MAAO,CAAC;EAC3B;EACA,OAAOL,KAAK,CAACQ,GAAG,CAAEL,KAAM,CAAC;AAC1B"}
@@ -0,0 +1,88 @@
1
+ /**
2
+ * Internal dependencies
3
+ */
4
+ import getFootnotesOrder from './get-footnotes-order';
5
+ let oldFootnotes = {};
6
+ export function updateFootnotesFromMeta(blocks, meta) {
7
+ const output = {
8
+ blocks
9
+ };
10
+ if (!meta) return output;
11
+
12
+ // If meta.footnotes is empty, it means the meta is not registered.
13
+ if (meta.footnotes === undefined) return output;
14
+ const newOrder = getFootnotesOrder(blocks);
15
+ const footnotes = meta.footnotes ? JSON.parse(meta.footnotes) : [];
16
+ const currentOrder = footnotes.map(fn => fn.id);
17
+ if (currentOrder.join('') === newOrder.join('')) return output;
18
+ const newFootnotes = newOrder.map(fnId => footnotes.find(fn => fn.id === fnId) || oldFootnotes[fnId] || {
19
+ id: fnId,
20
+ content: ''
21
+ });
22
+ function updateAttributes(attributes) {
23
+ // Only attempt to update attributes, if attributes is an object.
24
+ if (!attributes || Array.isArray(attributes) || typeof attributes !== 'object') {
25
+ return attributes;
26
+ }
27
+ attributes = {
28
+ ...attributes
29
+ };
30
+ for (const key in attributes) {
31
+ const value = attributes[key];
32
+ if (Array.isArray(value)) {
33
+ attributes[key] = value.map(updateAttributes);
34
+ continue;
35
+ }
36
+ if (typeof value !== 'string') {
37
+ continue;
38
+ }
39
+ if (value.indexOf('data-fn') === -1) {
40
+ continue;
41
+ }
42
+
43
+ // When we store rich text values, this would no longer
44
+ // require a regex.
45
+ const regex = /(<sup[^>]+data-fn="([^"]+)"[^>]*><a[^>]*>)[\d*]*<\/a><\/sup>/g;
46
+ attributes[key] = value.replace(regex, (match, opening, fnId) => {
47
+ const index = newOrder.indexOf(fnId);
48
+ return `${opening}${index + 1}</a></sup>`;
49
+ });
50
+ const compatRegex = /<a[^>]+data-fn="([^"]+)"[^>]*>\*<\/a>/g;
51
+ attributes[key] = attributes[key].replace(compatRegex, (match, fnId) => {
52
+ const index = newOrder.indexOf(fnId);
53
+ return `<sup data-fn="${fnId}" class="fn"><a href="#${fnId}" id="${fnId}-link">${index + 1}</a></sup>`;
54
+ });
55
+ }
56
+ return attributes;
57
+ }
58
+ function updateBlocksAttributes(__blocks) {
59
+ return __blocks.map(block => {
60
+ return {
61
+ ...block,
62
+ attributes: updateAttributes(block.attributes),
63
+ innerBlocks: updateBlocksAttributes(block.innerBlocks)
64
+ };
65
+ });
66
+ }
67
+
68
+ // We need to go through all block attributes deeply and update the
69
+ // footnote anchor numbering (textContent) to match the new order.
70
+ const newBlocks = updateBlocksAttributes(blocks);
71
+ oldFootnotes = {
72
+ ...oldFootnotes,
73
+ ...footnotes.reduce((acc, fn) => {
74
+ if (!newOrder.includes(fn.id)) {
75
+ acc[fn.id] = fn;
76
+ }
77
+ return acc;
78
+ }, {})
79
+ };
80
+ return {
81
+ meta: {
82
+ ...meta,
83
+ footnotes: JSON.stringify(newFootnotes)
84
+ },
85
+ blocks: newBlocks
86
+ };
87
+ }
88
+ //# sourceMappingURL=index.js.map