@wordpress/core-data 7.40.1 → 7.40.2-next.v.202602271551.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 (136) hide show
  1. package/build/actions.cjs +23 -29
  2. package/build/actions.cjs.map +2 -2
  3. package/build/awareness/block-lookup.cjs +103 -0
  4. package/build/awareness/block-lookup.cjs.map +7 -0
  5. package/build/awareness/post-editor-awareness.cjs +45 -7
  6. package/build/awareness/post-editor-awareness.cjs.map +3 -3
  7. package/build/entities.cjs +63 -59
  8. package/build/entities.cjs.map +2 -2
  9. package/build/entity-types/icon.cjs +19 -0
  10. package/build/entity-types/icon.cjs.map +7 -0
  11. package/build/entity-types/index.cjs.map +1 -1
  12. package/build/hooks/use-post-editor-awareness-state.cjs +12 -8
  13. package/build/hooks/use-post-editor-awareness-state.cjs.map +2 -2
  14. package/build/private-actions.cjs +0 -8
  15. package/build/private-actions.cjs.map +2 -2
  16. package/build/private-apis.cjs +1 -1
  17. package/build/private-apis.cjs.map +1 -1
  18. package/build/private-selectors.cjs +1 -9
  19. package/build/private-selectors.cjs.map +2 -2
  20. package/build/reducer.cjs +0 -10
  21. package/build/reducer.cjs.map +2 -2
  22. package/build/resolvers.cjs +116 -125
  23. package/build/resolvers.cjs.map +2 -2
  24. package/build/selectors.cjs.map +2 -2
  25. package/build/sync.cjs +1 -7
  26. package/build/sync.cjs.map +2 -2
  27. package/build/types.cjs.map +1 -1
  28. package/build/utils/crdt-blocks.cjs +50 -31
  29. package/build/utils/crdt-blocks.cjs.map +2 -2
  30. package/build/utils/crdt-selection.cjs +47 -19
  31. package/build/utils/crdt-selection.cjs.map +2 -2
  32. package/build/utils/crdt-user-selections.cjs +78 -22
  33. package/build/utils/crdt-user-selections.cjs.map +3 -3
  34. package/build/utils/crdt.cjs +12 -1
  35. package/build/utils/crdt.cjs.map +2 -2
  36. package/build-module/actions.mjs +23 -29
  37. package/build-module/actions.mjs.map +2 -2
  38. package/build-module/awareness/block-lookup.mjs +77 -0
  39. package/build-module/awareness/block-lookup.mjs.map +7 -0
  40. package/build-module/awareness/post-editor-awareness.mjs +47 -8
  41. package/build-module/awareness/post-editor-awareness.mjs.map +3 -3
  42. package/build-module/entities.mjs +65 -60
  43. package/build-module/entities.mjs.map +2 -2
  44. package/build-module/entity-types/icon.mjs +1 -0
  45. package/build-module/entity-types/icon.mjs.map +7 -0
  46. package/build-module/hooks/use-post-editor-awareness-state.mjs +10 -6
  47. package/build-module/hooks/use-post-editor-awareness-state.mjs.map +2 -2
  48. package/build-module/private-actions.mjs +0 -7
  49. package/build-module/private-actions.mjs.map +2 -2
  50. package/build-module/private-apis.mjs +2 -2
  51. package/build-module/private-apis.mjs.map +1 -1
  52. package/build-module/private-selectors.mjs +2 -12
  53. package/build-module/private-selectors.mjs.map +2 -2
  54. package/build-module/reducer.mjs +0 -9
  55. package/build-module/reducer.mjs.map +2 -2
  56. package/build-module/resolvers.mjs +116 -124
  57. package/build-module/resolvers.mjs.map +2 -2
  58. package/build-module/selectors.mjs.map +2 -2
  59. package/build-module/sync.mjs +1 -5
  60. package/build-module/sync.mjs.map +2 -2
  61. package/build-module/utils/crdt-blocks.mjs +50 -31
  62. package/build-module/utils/crdt-blocks.mjs.map +2 -2
  63. package/build-module/utils/crdt-selection.mjs +46 -19
  64. package/build-module/utils/crdt-selection.mjs.map +2 -2
  65. package/build-module/utils/crdt-user-selections.mjs +77 -22
  66. package/build-module/utils/crdt-user-selections.mjs.map +2 -2
  67. package/build-module/utils/crdt.mjs +16 -6
  68. package/build-module/utils/crdt.mjs.map +2 -2
  69. package/build-types/actions.d.ts.map +1 -1
  70. package/build-types/awareness/block-lookup.d.ts +29 -0
  71. package/build-types/awareness/block-lookup.d.ts.map +1 -0
  72. package/build-types/awareness/post-editor-awareness.d.ts +18 -5
  73. package/build-types/awareness/post-editor-awareness.d.ts.map +1 -1
  74. package/build-types/awareness/test/block-lookup.d.ts +2 -0
  75. package/build-types/awareness/test/block-lookup.d.ts.map +1 -0
  76. package/build-types/entities.d.ts +16 -0
  77. package/build-types/entities.d.ts.map +1 -1
  78. package/build-types/entity-types/icon.d.ts +25 -0
  79. package/build-types/entity-types/icon.d.ts.map +1 -0
  80. package/build-types/entity-types/index.d.ts +3 -2
  81. package/build-types/entity-types/index.d.ts.map +1 -1
  82. package/build-types/hooks/use-post-editor-awareness-state.d.ts +11 -6
  83. package/build-types/hooks/use-post-editor-awareness-state.d.ts.map +1 -1
  84. package/build-types/index.d.ts.map +1 -1
  85. package/build-types/private-actions.d.ts +0 -8
  86. package/build-types/private-actions.d.ts.map +1 -1
  87. package/build-types/private-selectors.d.ts +1 -8
  88. package/build-types/private-selectors.d.ts.map +1 -1
  89. package/build-types/reducer.d.ts +0 -11
  90. package/build-types/reducer.d.ts.map +1 -1
  91. package/build-types/resolvers.d.ts +0 -3
  92. package/build-types/resolvers.d.ts.map +1 -1
  93. package/build-types/selectors.d.ts +0 -6
  94. package/build-types/selectors.d.ts.map +1 -1
  95. package/build-types/sync.d.ts +2 -2
  96. package/build-types/sync.d.ts.map +1 -1
  97. package/build-types/types.d.ts +14 -5
  98. package/build-types/types.d.ts.map +1 -1
  99. package/build-types/utils/crdt-blocks.d.ts +1 -1
  100. package/build-types/utils/crdt-blocks.d.ts.map +1 -1
  101. package/build-types/utils/crdt-selection.d.ts +10 -0
  102. package/build-types/utils/crdt-selection.d.ts.map +1 -1
  103. package/build-types/utils/crdt-user-selections.d.ts +21 -4
  104. package/build-types/utils/crdt-user-selections.d.ts.map +1 -1
  105. package/build-types/utils/crdt.d.ts +1 -0
  106. package/build-types/utils/crdt.d.ts.map +1 -1
  107. package/build-types/utils/test/crdt-user-selections.d.ts +2 -0
  108. package/build-types/utils/test/crdt-user-selections.d.ts.map +1 -0
  109. package/package.json +18 -18
  110. package/src/actions.js +39 -45
  111. package/src/awareness/block-lookup.ts +169 -0
  112. package/src/awareness/post-editor-awareness.ts +68 -11
  113. package/src/awareness/test/block-lookup.ts +504 -0
  114. package/src/awareness/test/post-editor-awareness.ts +662 -38
  115. package/src/entities.js +71 -62
  116. package/src/entity-types/icon.ts +30 -0
  117. package/src/entity-types/index.ts +3 -0
  118. package/src/hooks/test/use-post-editor-awareness-state.ts +21 -14
  119. package/src/hooks/use-post-editor-awareness-state.ts +22 -13
  120. package/src/private-actions.js +0 -14
  121. package/src/private-apis.js +2 -2
  122. package/src/private-selectors.ts +3 -22
  123. package/src/reducer.js +0 -17
  124. package/src/resolvers.js +158 -171
  125. package/src/selectors.ts +0 -7
  126. package/src/sync.ts +0 -4
  127. package/src/test/entities.js +39 -10
  128. package/src/test/resolvers.js +155 -81
  129. package/src/types.ts +23 -5
  130. package/src/utils/crdt-blocks.ts +113 -47
  131. package/src/utils/crdt-selection.ts +87 -25
  132. package/src/utils/crdt-user-selections.ts +129 -47
  133. package/src/utils/crdt.ts +23 -7
  134. package/src/utils/test/crdt-blocks.ts +591 -0
  135. package/src/utils/test/crdt-user-selections.ts +894 -0
  136. package/src/utils/test/crdt.ts +136 -10
package/build/actions.cjs CHANGED
@@ -204,12 +204,10 @@ var deleteEntityRecord = (kind, name, recordId, query, { __unstableFetch = impor
204
204
  method: "DELETE"
205
205
  });
206
206
  await dispatch((0, import_queried_data.removeItems)(kind, name, recordId, true));
207
- if (globalThis.IS_GUTENBERG_PLUGIN) {
208
- if (entityConfig.syncConfig) {
209
- const objectType = `${kind}/${name}`;
210
- const objectId = recordId;
211
- (0, import_sync.getSyncManager)()?.unload(objectType, objectId);
212
- }
207
+ if (entityConfig.syncConfig) {
208
+ const objectType = `${kind}/${name}`;
209
+ const objectId = recordId;
210
+ (0, import_sync.getSyncManager)()?.unload(objectType, objectId);
213
211
  }
214
212
  } catch (_error) {
215
213
  hasError = true;
@@ -262,19 +260,17 @@ var editEntityRecord = (kind, name, recordId, edits, options = {}) => ({ select,
262
260
  return acc;
263
261
  }, {})
264
262
  };
265
- if (globalThis.IS_GUTENBERG_PLUGIN) {
266
- if (entityConfig.syncConfig) {
267
- const objectType = `${kind}/${name}`;
268
- const objectId = recordId;
269
- const isNewUndoLevel = options.undoIgnore ? false : !options.isCached;
270
- (0, import_sync.getSyncManager)()?.update(
271
- objectType,
272
- objectId,
273
- editsWithMerges,
274
- import_sync.LOCAL_EDITOR_ORIGIN,
275
- { isNewUndoLevel }
276
- );
277
- }
263
+ if (entityConfig.syncConfig) {
264
+ const objectType = `${kind}/${name}`;
265
+ const objectId = recordId;
266
+ const isNewUndoLevel = options.undoIgnore ? false : !options.isCached;
267
+ (0, import_sync.getSyncManager)()?.update(
268
+ objectType,
269
+ objectId,
270
+ editsWithMerges,
271
+ import_sync.LOCAL_EDITOR_ORIGIN,
272
+ { isNewUndoLevel }
273
+ );
278
274
  }
279
275
  if (!options.undoIgnore) {
280
276
  select.getUndoManager().addRecord(
@@ -504,16 +500,14 @@ var saveEntityRecord = (kind, name, record, {
504
500
  true,
505
501
  edits
506
502
  );
507
- if (globalThis.IS_GUTENBERG_PLUGIN) {
508
- if (entityConfig.syncConfig) {
509
- (0, import_sync.getSyncManager)()?.update(
510
- `${kind}/${name}`,
511
- recordId,
512
- updatedRecord,
513
- import_sync.LOCAL_EDITOR_ORIGIN,
514
- { isSave: true }
515
- );
516
- }
503
+ if (entityConfig.syncConfig) {
504
+ (0, import_sync.getSyncManager)()?.update(
505
+ `${kind}/${name}`,
506
+ recordId,
507
+ updatedRecord,
508
+ import_sync.LOCAL_EDITOR_ORIGIN,
509
+ { isSave: true }
510
+ );
517
511
  }
518
512
  }
519
513
  } catch (_error) {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/actions.js"],
4
- "sourcesContent": ["/**\n * External dependencies\n */\nimport fastDeepEqual from 'fast-deep-equal/es6/index.js';\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 { DEFAULT_ENTITY_KEY } from './entities';\nimport { createBatch } from './batch';\nimport { STORE_NAME } from './name';\nimport { LOCAL_EDITOR_ORIGIN, getSyncManager } from './sync';\nimport logEntityDeprecation from './utils/log-entity-deprecation';\n\n/**\n * Returns an action object used in signalling that authors have been received.\n * Ignored from documentation as it's internal to the data store.\n *\n * @ignore\n *\n * @param {string} queryID Query ID.\n * @param {Array|Object} users Users received.\n *\n * @return {Object} Action object.\n */\nexport function receiveUserQuery( queryID, users ) {\n\treturn {\n\t\ttype: 'RECEIVE_USER_QUERY',\n\t\tusers: Array.isArray( users ) ? users : [ users ],\n\t\tqueryID,\n\t};\n}\n\n/**\n * Returns an action used in signalling that the current user has been received.\n * Ignored from documentation as it's internal to the data store.\n *\n * @ignore\n *\n * @param {Object} currentUser Current user object.\n *\n * @return {Object} Action object.\n */\nexport function receiveCurrentUser( currentUser ) {\n\treturn {\n\t\ttype: 'RECEIVE_CURRENT_USER',\n\t\tcurrentUser,\n\t};\n}\n\n/**\n * Returns an action object used in adding new entities.\n *\n * @param {Array} entities Entities received.\n *\n * @return {Object} Action object.\n */\nexport function addEntities( entities ) {\n\treturn {\n\t\ttype: 'ADD_ENTITIES',\n\t\tentities,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that entity records have been received.\n *\n * @param {string} kind Kind of the received entity record.\n * @param {string} name Name of the received entity record.\n * @param {Array|Object} records Records received.\n * @param {?Object} query Query Object.\n * @param {?boolean} invalidateCache Should invalidate query caches.\n * @param {?Object} edits Edits to reset.\n * @param {?Object} meta Meta information about pagination.\n * @return {Object} Action object.\n */\nexport function receiveEntityRecords(\n\tkind,\n\tname,\n\trecords,\n\tquery = undefined,\n\tinvalidateCache = false,\n\tedits = undefined,\n\tmeta = undefined\n) {\n\t// Auto drafts should not have titles, but some plugins rely on them so we can't filter this\n\t// on the server.\n\tif ( kind === 'postType' ) {\n\t\trecords = ( Array.isArray( records ) ? records : [ records ] ).map(\n\t\t\t( record ) =>\n\t\t\t\trecord.status === 'auto-draft'\n\t\t\t\t\t? { ...record, title: '' }\n\t\t\t\t\t: record\n\t\t);\n\t}\n\tlet action;\n\tif ( query ) {\n\t\taction = receiveQueriedItems( records, query, edits, meta );\n\t} else {\n\t\taction = receiveItems( records, edits, meta );\n\t}\n\n\treturn {\n\t\t...action,\n\t\tkind,\n\t\tname,\n\t\tinvalidateCache,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that the current theme has been received.\n * Ignored from documentation as it's internal to the data store.\n *\n * @ignore\n *\n * @param {Object} currentTheme The current theme.\n *\n * @return {Object} Action object.\n */\nexport function receiveCurrentTheme( currentTheme ) {\n\treturn {\n\t\ttype: 'RECEIVE_CURRENT_THEME',\n\t\tcurrentTheme,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that the current global styles id has been received.\n * Ignored from documentation as it's internal to the data store.\n *\n * @ignore\n *\n * @param {string} currentGlobalStylesId The current global styles id.\n *\n * @return {Object} Action object.\n */\nexport function __experimentalReceiveCurrentGlobalStylesId(\n\tcurrentGlobalStylesId\n) {\n\treturn {\n\t\ttype: 'RECEIVE_CURRENT_GLOBAL_STYLES_ID',\n\t\tid: currentGlobalStylesId,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that the theme base global styles have been received\n * Ignored from documentation as it's internal to the data store.\n *\n * @ignore\n *\n * @param {string} stylesheet The theme's identifier\n * @param {Object} globalStyles The global styles object.\n *\n * @return {Object} Action object.\n */\nexport function __experimentalReceiveThemeBaseGlobalStyles(\n\tstylesheet,\n\tglobalStyles\n) {\n\treturn {\n\t\ttype: 'RECEIVE_THEME_GLOBAL_STYLES',\n\t\tstylesheet,\n\t\tglobalStyles,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that the theme global styles variations have been received.\n * Ignored from documentation as it's internal to the data store.\n *\n * @ignore\n *\n * @param {string} stylesheet The theme's identifier\n * @param {Array} variations The global styles variations.\n *\n * @return {Object} Action object.\n */\nexport function __experimentalReceiveThemeGlobalStyleVariations(\n\tstylesheet,\n\tvariations\n) {\n\treturn {\n\t\ttype: 'RECEIVE_THEME_GLOBAL_STYLE_VARIATIONS',\n\t\tstylesheet,\n\t\tvariations,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that the index has been received.\n *\n * @deprecated since WP 5.9, this is not useful anymore, use the selector directly.\n *\n * @return {Object} Action object.\n */\nexport function receiveThemeSupports() {\n\tdeprecated( \"wp.data.dispatch( 'core' ).receiveThemeSupports\", {\n\t\tsince: '5.9',\n\t} );\n\n\treturn {\n\t\ttype: 'DO_NOTHING',\n\t};\n}\n\n/**\n * Returns an action object used in signalling that the theme global styles CPT post revisions have been received.\n * Ignored from documentation as it's internal to the data store.\n *\n * @deprecated since WordPress 6.5.0. Callers should use `dispatch( 'core' ).receiveRevision` instead.\n *\n * @ignore\n *\n * @param {number} currentId The post id.\n * @param {Array} revisions The global styles revisions.\n *\n * @return {Object} Action object.\n */\nexport function receiveThemeGlobalStyleRevisions( currentId, revisions ) {\n\tdeprecated(\n\t\t\"wp.data.dispatch( 'core' ).receiveThemeGlobalStyleRevisions()\",\n\t\t{\n\t\t\tsince: '6.5.0',\n\t\t\talternative: \"wp.data.dispatch( 'core' ).receiveRevisions\",\n\t\t}\n\t);\n\treturn {\n\t\ttype: 'RECEIVE_THEME_GLOBAL_STYLE_REVISIONS',\n\t\tcurrentId,\n\t\trevisions,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that the preview data for\n * a given URl has been received.\n * Ignored from documentation as it's internal to the data store.\n *\n * @ignore\n *\n * @param {string} url URL to preview the embed for.\n * @param {*} preview Preview data.\n *\n * @return {Object} Action object.\n */\nexport function receiveEmbedPreview( url, preview ) {\n\treturn {\n\t\ttype: 'RECEIVE_EMBED_PREVIEW',\n\t\turl,\n\t\tpreview,\n\t};\n}\n\n/**\n * Action triggered to delete an entity record.\n *\n * @param {string} kind Kind of the deleted entity.\n * @param {string} name Name of the deleted entity.\n * @param {number|string} recordId Record ID of the deleted entity.\n * @param {?Object} query Special query parameters for the\n * DELETE API call.\n * @param {Object} [options] Delete options.\n * @param {Function} [options.__unstableFetch] Internal use only. Function to\n * call instead of `apiFetch()`.\n * Must return a promise.\n * @param {boolean} [options.throwOnError=false] If false, this action suppresses all\n * the exceptions. Defaults to false.\n */\nexport const deleteEntityRecord =\n\t(\n\t\tkind,\n\t\tname,\n\t\trecordId,\n\t\tquery,\n\t\t{ __unstableFetch = apiFetch, throwOnError = false } = {}\n\t) =>\n\tasync ( { dispatch, resolveSelect } ) => {\n\t\tlogEntityDeprecation( kind, name, 'deleteEntityRecord' );\n\t\tconst configs = await resolveSelect.getEntitiesConfig( 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 ) {\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\tlet { baseURL } = entityConfig;\n\t\t\tif (\n\t\t\t\tkind === 'postType' &&\n\t\t\t\tname === 'wp_template' &&\n\t\t\t\t( ( recordId &&\n\t\t\t\t\ttypeof recordId === 'string' &&\n\t\t\t\t\t! /^\\d+$/.test( recordId ) ) ||\n\t\t\t\t\t! window?.__experimentalTemplateActivate )\n\t\t\t) {\n\t\t\t\tbaseURL =\n\t\t\t\t\tbaseURL.slice( 0, baseURL.lastIndexOf( '/' ) ) +\n\t\t\t\t\t'/templates';\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tlet path = `${ 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\n\t\t\t\tif ( globalThis.IS_GUTENBERG_PLUGIN ) {\n\t\t\t\t\tif ( entityConfig.syncConfig ) {\n\t\t\t\t\t\tconst objectType = `${ kind }/${ name }`;\n\t\t\t\t\t\tconst objectId = recordId;\n\n\t\t\t\t\t\tgetSyncManager()?.unload( objectType, objectId );\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\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\tlogEntityDeprecation( kind, name, 'editEntityRecord' );\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\t// Some fields are merged with the existing value instead of replaced.\n\t\t// See `mergedEdits` definition on the entity config.\n\t\tconst editsWithMerges = Object.keys( edits ).reduce( ( acc, key ) => {\n\t\t\tacc[ key ] = mergedEdits[ key ]\n\t\t\t\t? { ...editedRecord[ key ], ...edits[ key ] }\n\t\t\t\t: edits[ key ];\n\n\t\t\treturn acc;\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 value = editsWithMerges[ 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 ( globalThis.IS_GUTENBERG_PLUGIN ) {\n\t\t\tif ( entityConfig.syncConfig ) {\n\t\t\t\tconst objectType = `${ kind }/${ name }`;\n\t\t\t\tconst objectId = recordId;\n\n\t\t\t\t// Determine whether this edit should create a new undo level.\n\t\t\t\t//\n\t\t\t\t// In Gutenberg, block changes flow through two callbacks:\n\t\t\t\t// - `onInput`: For transient/in-progress changes (e.g., typing each\n\t\t\t\t// character). These use `isCached: true` and get merged into\n\t\t\t\t// the current undo item.\n\t\t\t\t// - `onChange`: For persistent/completed changes (e.g., formatting\n\t\t\t\t// transforms, block insertions). These use `isCached: false` and\n\t\t\t\t// should create a new undo level.\n\t\t\t\t//\n\t\t\t\t// Additionally, `undoIgnore: true` means the change should not\n\t\t\t\t// affect the undo history at all (e.g., selection-only changes).\n\t\t\t\tconst isNewUndoLevel = options.undoIgnore\n\t\t\t\t\t? false\n\t\t\t\t\t: ! options.isCached;\n\n\t\t\t\tgetSyncManager()?.update(\n\t\t\t\t\tobjectType,\n\t\t\t\t\tobjectId,\n\t\t\t\t\teditsWithMerges,\n\t\t\t\t\tLOCAL_EDITOR_ORIGIN,\n\t\t\t\t\t{ isNewUndoLevel }\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\tif ( ! options.undoIgnore ) {\n\t\t\tselect.getUndoManager().addRecord(\n\t\t\t\t[\n\t\t\t\t\t{\n\t\t\t\t\t\tid: { kind, name, recordId },\n\t\t\t\t\t\tchanges: Object.keys( edits ).reduce( ( acc, key ) => {\n\t\t\t\t\t\t\tacc[ key ] = {\n\t\t\t\t\t\t\t\tfrom: editedRecord[ key ],\n\t\t\t\t\t\t\t\tto: edits[ 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},\n\t\t\t\t],\n\t\t\t\toptions.isCached\n\t\t\t);\n\t\t}\n\t\tdispatch( {\n\t\t\ttype: 'EDIT_ENTITY_RECORD',\n\t\t\t...edit,\n\t\t} );\n\t};\n\n/**\n * Action triggered to clear all edits from\n * an entity record.\n *\n * @param {string} kind Kind of the entity.\n * @param {string} name Name of the entity.\n * @param {number|string} recordId Record ID of the entity record.\n *\n * @return {Object} Action object.\n */\nexport const clearEntityRecordEdits =\n\t( kind, name, recordId ) =>\n\t( { select, dispatch } ) => {\n\t\tconst entityConfig = select.getEntityConfig( kind, name );\n\t\tlogEntityDeprecation( kind, name, 'clearEntityRecordEdits' );\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\n\t\tconst currentEdits = select.getEntityRecordEdits(\n\t\t\tkind,\n\t\t\tname,\n\t\t\trecordId\n\t\t);\n\t\tif ( ! currentEdits ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Build an edits object with all current edit keys set to undefined\n\t\t// so the reducer removes them.\n\t\tconst clearedEdits = Object.keys( currentEdits ).reduce(\n\t\t\t( acc, key ) => {\n\t\t\t\tacc[ key ] = undefined;\n\t\t\t\treturn acc;\n\t\t\t},\n\t\t\t{}\n\t\t);\n\n\t\tdispatch( {\n\t\t\ttype: 'EDIT_ENTITY_RECORD',\n\t\t\tkind,\n\t\t\tname,\n\t\t\trecordId,\n\t\t\tedits: clearedEdits,\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 undone\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\tlogEntityDeprecation( kind, name, 'saveEntityRecord' );\n\t\tconst configs = await resolveSelect.getEntitiesConfig( 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\t\tconst recordId = record[ entityIdKey ];\n\t\tconst isNewRecord = !! entityIdKey && ! recordId;\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\tlet { baseURL } = entityConfig;\n\t\t\t// For \"string\" IDs, use the old templates endpoint.\n\t\t\tif (\n\t\t\t\tkind === 'postType' &&\n\t\t\t\tname === 'wp_template' &&\n\t\t\t\t( ( recordId &&\n\t\t\t\t\ttypeof recordId === 'string' &&\n\t\t\t\t\t! /^\\d+$/.test( recordId ) ) ||\n\t\t\t\t\t! window?.__experimentalTemplateActivate )\n\t\t\t) {\n\t\t\t\tbaseURL =\n\t\t\t\t\tbaseURL.slice( 0, baseURL.lastIndexOf( '/' ) ) +\n\t\t\t\t\t'/templates';\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tconst path = `${ baseURL }${ recordId ? '/' + recordId : '' }`;\n\t\t\t\t// Skip the raw values check when creating a new record; they don't exist yet.\n\t\t\t\tconst persistedRecord = ! isNewRecord\n\t\t\t\t\t? select.getRawEntityRecord( kind, name, recordId )\n\t\t\t\t\t: {};\n\n\t\t\t\tif ( isAutosave ) {\n\t\t\t\t\t// Most of this autosave logic is very specific to posts.\n\t\t\t\t\t// This is fine for now as it is the only supported autosave,\n\t\t\t\t\t// but ideally this should all be handled in the back end,\n\t\t\t\t\t// so the client just sends and receives objects.\n\t\t\t\t\tconst currentUser = select.getCurrentUser();\n\t\t\t\t\tconst currentUserId = currentUser\n\t\t\t\t\t\t? currentUser.id\n\t\t\t\t\t\t: undefined;\n\t\t\t\t\tconst autosavePost = await resolveSelect.getAutosave(\n\t\t\t\t\t\tpersistedRecord.type,\n\t\t\t\t\t\tpersistedRecord.id,\n\t\t\t\t\t\tcurrentUserId\n\t\t\t\t\t);\n\t\t\t\t\t// Autosaves need all expected fields to be present.\n\t\t\t\t\t// So we fallback to the previous autosave and then\n\t\t\t\t\t// to the actual persisted entity if the edits don't\n\t\t\t\t\t// have a value.\n\t\t\t\t\tlet data = {\n\t\t\t\t\t\t...persistedRecord,\n\t\t\t\t\t\t...autosavePost,\n\t\t\t\t\t\t...record,\n\t\t\t\t\t};\n\t\t\t\t\tdata = Object.keys( data ).reduce(\n\t\t\t\t\t\t( acc, key ) => {\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t\t'title',\n\t\t\t\t\t\t\t\t\t'excerpt',\n\t\t\t\t\t\t\t\t\t'content',\n\t\t\t\t\t\t\t\t\t'meta',\n\t\t\t\t\t\t\t\t].includes( key )\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tacc[ key ] = data[ key ];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn acc;\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t// Do not update the `status` if we have edited it when auto saving.\n\t\t\t\t\t\t\t// It's very important to let the user explicitly save this change,\n\t\t\t\t\t\t\t// because it can lead to unexpected results. An example would be to\n\t\t\t\t\t\t\t// have a draft post and change the status to publish.\n\t\t\t\t\t\t\tstatus:\n\t\t\t\t\t\t\t\tdata.status === 'auto-draft'\n\t\t\t\t\t\t\t\t\t? 'draft'\n\t\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t\t\tupdatedRecord = await __unstableFetch( {\n\t\t\t\t\t\tpath: `${ path }/autosaves`,\n\t\t\t\t\t\tmethod: 'POST',\n\t\t\t\t\t\tdata,\n\t\t\t\t\t} );\n\n\t\t\t\t\t// An autosave may be processed by the server as a regular save\n\t\t\t\t\t// when its update is requested by the author and the post had\n\t\t\t\t\t// draft or auto-draft status.\n\t\t\t\t\tif ( persistedRecord.id === updatedRecord.id ) {\n\t\t\t\t\t\tlet newRecord = {\n\t\t\t\t\t\t\t...persistedRecord,\n\t\t\t\t\t\t\t...data,\n\t\t\t\t\t\t\t...updatedRecord,\n\t\t\t\t\t\t};\n\t\t\t\t\t\tnewRecord = Object.keys( newRecord ).reduce(\n\t\t\t\t\t\t\t( acc, key ) => {\n\t\t\t\t\t\t\t\t// These properties are persisted in autosaves.\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t[ 'title', 'excerpt', 'content' ].includes(\n\t\t\t\t\t\t\t\t\t\tkey\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\tacc[ key ] = newRecord[ key ];\n\t\t\t\t\t\t\t\t} else if ( key === 'status' ) {\n\t\t\t\t\t\t\t\t\t// Status is only persisted in autosaves when going from\n\t\t\t\t\t\t\t\t\t// \"auto-draft\" to \"draft\".\n\t\t\t\t\t\t\t\t\tacc[ key ] =\n\t\t\t\t\t\t\t\t\t\tpersistedRecord.status ===\n\t\t\t\t\t\t\t\t\t\t\t'auto-draft' &&\n\t\t\t\t\t\t\t\t\t\tnewRecord.status === 'draft'\n\t\t\t\t\t\t\t\t\t\t\t? newRecord.status\n\t\t\t\t\t\t\t\t\t\t\t: persistedRecord.status;\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t// These properties are not persisted in autosaves.\n\t\t\t\t\t\t\t\t\tacc[ key ] = persistedRecord[ key ];\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\treturn acc;\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{}\n\t\t\t\t\t\t);\n\t\t\t\t\t\tdispatch.receiveEntityRecords(\n\t\t\t\t\t\t\tkind,\n\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\tnewRecord,\n\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\ttrue\n\t\t\t\t\t\t);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tdispatch.receiveAutosaves(\n\t\t\t\t\t\t\tpersistedRecord.id,\n\t\t\t\t\t\t\tupdatedRecord\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tlet edits = record;\n\t\t\t\t\tif ( entityConfig.__unstablePrePersist ) {\n\t\t\t\t\t\tedits = {\n\t\t\t\t\t\t\t...edits,\n\t\t\t\t\t\t\t...entityConfig.__unstablePrePersist(\n\t\t\t\t\t\t\t\tpersistedRecord,\n\t\t\t\t\t\t\t\tedits\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\tupdatedRecord = await __unstableFetch( {\n\t\t\t\t\t\tpath,\n\t\t\t\t\t\tmethod: recordId ? 'PUT' : 'POST',\n\t\t\t\t\t\tdata: edits,\n\t\t\t\t\t} );\n\t\t\t\t\tdispatch.receiveEntityRecords(\n\t\t\t\t\t\tkind,\n\t\t\t\t\t\tname,\n\t\t\t\t\t\tupdatedRecord,\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t\tedits\n\t\t\t\t\t);\n\t\t\t\t\tif ( globalThis.IS_GUTENBERG_PLUGIN ) {\n\t\t\t\t\t\tif ( entityConfig.syncConfig ) {\n\t\t\t\t\t\t\tgetSyncManager()?.update(\n\t\t\t\t\t\t\t\t`${ kind }/${ name }`,\n\t\t\t\t\t\t\t\trecordId,\n\t\t\t\t\t\t\t\tupdatedRecord,\n\t\t\t\t\t\t\t\tLOCAL_EDITOR_ORIGIN,\n\t\t\t\t\t\t\t\t{ isSave: true }\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}\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, resolveSelect } ) => {\n\t\tlogEntityDeprecation( kind, name, 'saveEditedEntityRecord' );\n\t\tif ( ! select.hasEditsForEntityRecord( kind, name, recordId ) ) {\n\t\t\treturn;\n\t\t}\n\t\tconst configs = await resolveSelect.getEntitiesConfig( 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 {number|string} recordId ID of the record.\n * @param {Array} itemsToSave List of entity properties or property paths to save.\n * @param {Object} options Saving options.\n */\nexport const __experimentalSaveSpecifiedEntityEdits =\n\t( kind, name, recordId, itemsToSave, options ) =>\n\tasync ( { select, dispatch, resolveSelect } ) => {\n\t\tlogEntityDeprecation(\n\t\t\tkind,\n\t\t\tname,\n\t\t\t'__experimentalSaveSpecifiedEntityEdits'\n\t\t);\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 resolveSelect.getEntitiesConfig( 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 current user has\n * permission to perform an action on a REST resource. Ignored from\n * documentation as it's internal to the data store.\n *\n * @ignore\n *\n * @param {Object<string, boolean>} permissions An object where keys represent\n * actions and REST resources, and\n * values indicate whether the user\n * is allowed to perform the\n * action.\n *\n * @return {Object} Action object.\n */\nexport function receiveUserPermissions( permissions ) {\n\treturn {\n\t\ttype: 'RECEIVE_USER_PERMISSIONS',\n\t\tpermissions,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that the autosaves for a\n * post have been received.\n * Ignored from documentation as it's internal to the data store.\n *\n * @ignore\n *\n * @param {number} postId The id of the post that is parent to the autosave.\n * @param {Array|Object} autosaves An array of autosaves or singular autosave object.\n *\n * @return {Object} Action object.\n */\nexport function receiveAutosaves( postId, autosaves ) {\n\treturn {\n\t\ttype: 'RECEIVE_AUTOSAVES',\n\t\tpostId,\n\t\tautosaves: Array.isArray( autosaves ) ? autosaves : [ autosaves ],\n\t};\n}\n\n/**\n * Returns an action object signalling that the fallback Navigation\n * Menu id has been received.\n *\n * @param {integer} fallbackId the id of the fallback Navigation Menu\n * @return {Object} Action object.\n */\nexport function receiveNavigationFallbackId( fallbackId ) {\n\treturn {\n\t\ttype: 'RECEIVE_NAVIGATION_FALLBACK_ID',\n\t\tfallbackId,\n\t};\n}\n\n/**\n * Returns an action object used to set the template for a given query.\n *\n * @param {Object} query The lookup query.\n * @param {string} templateId The resolved template id.\n *\n * @return {Object} Action object.\n */\nexport function receiveDefaultTemplateId( query, templateId ) {\n\treturn {\n\t\ttype: 'RECEIVE_DEFAULT_TEMPLATE',\n\t\tquery,\n\t\ttemplateId,\n\t};\n}\n\n/**\n * Action triggered to receive revision items.\n *\n * @param {string} kind Kind of the received entity record revisions.\n * @param {string} name Name of the received entity record revisions.\n * @param {number|string} recordKey The key of the entity record whose revisions you want to fetch.\n * @param {Array|Object} records Revisions received.\n * @param {?Object} query Query Object.\n * @param {?boolean} invalidateCache Should invalidate query caches.\n * @param {?Object} meta Meta information about pagination.\n */\nexport const receiveRevisions =\n\t( kind, name, recordKey, records, query, invalidateCache = false, meta ) =>\n\tasync ( { dispatch, resolveSelect } ) => {\n\t\tlogEntityDeprecation( kind, name, 'receiveRevisions' );\n\t\tconst configs = await resolveSelect.getEntitiesConfig( kind );\n\t\tconst entityConfig = configs.find(\n\t\t\t( config ) => config.kind === kind && config.name === name\n\t\t);\n\t\tconst key =\n\t\t\tentityConfig && entityConfig?.revisionKey\n\t\t\t\t? entityConfig.revisionKey\n\t\t\t\t: DEFAULT_ENTITY_KEY;\n\n\t\tdispatch( {\n\t\t\ttype: 'RECEIVE_ITEM_REVISIONS',\n\t\t\tkey,\n\t\t\titems: Array.isArray( records ) ? records : [ records ],\n\t\t\trecordKey,\n\t\t\tmeta,\n\t\t\tquery,\n\t\t\tkind,\n\t\t\tname,\n\t\t\tinvalidateCache,\n\t\t} );\n\t};\n\n/**\n * Returns an action object used to set the sync connection status for an entity or collection.\n *\n * @param {string} kind Kind of the entity.\n * @param {string} name Name of the entity.\n * @param {number|string|null} key The entity key, or null for collections.\n * @param {Object|null} status The connection state object or null on unload.\n *\n * @return {Object} Action object.\n */\nexport function setSyncConnectionStatus( kind, name, key, status ) {\n\tif ( ! status ) {\n\t\treturn {\n\t\t\ttype: 'CLEAR_SYNC_CONNECTION_STATUS',\n\t\t\tkind,\n\t\t\tname,\n\t\t\tkey,\n\t\t};\n\t}\n\n\treturn {\n\t\ttype: 'SET_SYNC_CONNECTION_STATUS',\n\t\tkind,\n\t\tname,\n\t\tkey,\n\t\tstatus,\n\t};\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,iBAA0B;AAC1B,kBAA2B;AAK3B,uBAAqB;AACrB,iBAA6B;AAC7B,wBAAuB;AAKvB,mBAA+C;AAC/C,0BAA+D;AAC/D,sBAAmC;AACnC,mB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QAAQ,WAAY;AACrD,SAAO;AAAA,IACN,MAAM;AAAA,IACN;AAAA,IACA,WAAW,MAAM,QAAS,SAAU,IAAI,YAAY,CAAE,SAAU;AAAA,EACjE;AACD;AASO,SAAS,4BAA6B,YAAa;AACzD,SAAO;AAAA,IACN,MAAM;AAAA,IACN;AAAA,EACD;AACD;AAUO,SAAS,yBAA0B,OAAO,YAAa;AAC7D,SAAO;AAAA,IACN,MAAM;AAAA,IACN;AAAA,IACA;AAAA,EACD;AACD;AAaO,IAAM,mBACZ,CAAE,MAAM,MAAM,WAAW,SAAS,OAAO,kBAAkB,OAAO,SAClE,OAAQ,EAAE,UAAU,cAAc,MAAO;AACxC,oCAAAE,SAAsB,MAAM,MAAM,kBAAmB;AACrD,QAAM,UAAU,MAAM,cAAc,kBAAmB,IAAK;AAC5D,QAAM,eAAe,QAAQ;AAAA,IAC5B,CAAE,WAAY,OAAO,SAAS,QAAQ,OAAO,SAAS;AAAA,EACvD;AACA,QAAM,MACL,gBAAgB,cAAc,cAC3B,aAAa,cACb;AAEJ,WAAU;AAAA,IACT,MAAM;AAAA,IACN;AAAA,IACA,OAAO,MAAM,QAAS,OAAQ,IAAI,UAAU,CAAE,OAAQ;AAAA,IACtD;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,CAAE;AACH;AAYM,SAAS,wBAAyB,MAAM,MAAM,KAAK,QAAS;AAClE,MAAK,CAAE,QAAS;AACf,WAAO;AAAA,MACN,MAAM;AAAA,MACN;AAAA,MACA;AAAA,MACA;AAAA,IACD;AAAA,EACD;AAEA,SAAO;AAAA,IACN,MAAM;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACD;",
4
+ "sourcesContent": ["/**\n * External dependencies\n */\nimport fastDeepEqual from 'fast-deep-equal/es6/index.js';\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 { DEFAULT_ENTITY_KEY } from './entities';\nimport { createBatch } from './batch';\nimport { STORE_NAME } from './name';\nimport { LOCAL_EDITOR_ORIGIN, getSyncManager } from './sync';\nimport logEntityDeprecation from './utils/log-entity-deprecation';\n\n/**\n * Returns an action object used in signalling that authors have been received.\n * Ignored from documentation as it's internal to the data store.\n *\n * @ignore\n *\n * @param {string} queryID Query ID.\n * @param {Array|Object} users Users received.\n *\n * @return {Object} Action object.\n */\nexport function receiveUserQuery( queryID, users ) {\n\treturn {\n\t\ttype: 'RECEIVE_USER_QUERY',\n\t\tusers: Array.isArray( users ) ? users : [ users ],\n\t\tqueryID,\n\t};\n}\n\n/**\n * Returns an action used in signalling that the current user has been received.\n * Ignored from documentation as it's internal to the data store.\n *\n * @ignore\n *\n * @param {Object} currentUser Current user object.\n *\n * @return {Object} Action object.\n */\nexport function receiveCurrentUser( currentUser ) {\n\treturn {\n\t\ttype: 'RECEIVE_CURRENT_USER',\n\t\tcurrentUser,\n\t};\n}\n\n/**\n * Returns an action object used in adding new entities.\n *\n * @param {Array} entities Entities received.\n *\n * @return {Object} Action object.\n */\nexport function addEntities( entities ) {\n\treturn {\n\t\ttype: 'ADD_ENTITIES',\n\t\tentities,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that entity records have been received.\n *\n * @param {string} kind Kind of the received entity record.\n * @param {string} name Name of the received entity record.\n * @param {Array|Object} records Records received.\n * @param {?Object} query Query Object.\n * @param {?boolean} invalidateCache Should invalidate query caches.\n * @param {?Object} edits Edits to reset.\n * @param {?Object} meta Meta information about pagination.\n * @return {Object} Action object.\n */\nexport function receiveEntityRecords(\n\tkind,\n\tname,\n\trecords,\n\tquery = undefined,\n\tinvalidateCache = false,\n\tedits = undefined,\n\tmeta = undefined\n) {\n\t// Auto drafts should not have titles, but some plugins rely on them so we can't filter this\n\t// on the server.\n\tif ( kind === 'postType' ) {\n\t\trecords = ( Array.isArray( records ) ? records : [ records ] ).map(\n\t\t\t( record ) =>\n\t\t\t\trecord.status === 'auto-draft'\n\t\t\t\t\t? { ...record, title: '' }\n\t\t\t\t\t: record\n\t\t);\n\t}\n\tlet action;\n\tif ( query ) {\n\t\taction = receiveQueriedItems( records, query, edits, meta );\n\t} else {\n\t\taction = receiveItems( records, edits, meta );\n\t}\n\n\treturn {\n\t\t...action,\n\t\tkind,\n\t\tname,\n\t\tinvalidateCache,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that the current theme has been received.\n * Ignored from documentation as it's internal to the data store.\n *\n * @ignore\n *\n * @param {Object} currentTheme The current theme.\n *\n * @return {Object} Action object.\n */\nexport function receiveCurrentTheme( currentTheme ) {\n\treturn {\n\t\ttype: 'RECEIVE_CURRENT_THEME',\n\t\tcurrentTheme,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that the current global styles id has been received.\n * Ignored from documentation as it's internal to the data store.\n *\n * @ignore\n *\n * @param {string} currentGlobalStylesId The current global styles id.\n *\n * @return {Object} Action object.\n */\nexport function __experimentalReceiveCurrentGlobalStylesId(\n\tcurrentGlobalStylesId\n) {\n\treturn {\n\t\ttype: 'RECEIVE_CURRENT_GLOBAL_STYLES_ID',\n\t\tid: currentGlobalStylesId,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that the theme base global styles have been received\n * Ignored from documentation as it's internal to the data store.\n *\n * @ignore\n *\n * @param {string} stylesheet The theme's identifier\n * @param {Object} globalStyles The global styles object.\n *\n * @return {Object} Action object.\n */\nexport function __experimentalReceiveThemeBaseGlobalStyles(\n\tstylesheet,\n\tglobalStyles\n) {\n\treturn {\n\t\ttype: 'RECEIVE_THEME_GLOBAL_STYLES',\n\t\tstylesheet,\n\t\tglobalStyles,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that the theme global styles variations have been received.\n * Ignored from documentation as it's internal to the data store.\n *\n * @ignore\n *\n * @param {string} stylesheet The theme's identifier\n * @param {Array} variations The global styles variations.\n *\n * @return {Object} Action object.\n */\nexport function __experimentalReceiveThemeGlobalStyleVariations(\n\tstylesheet,\n\tvariations\n) {\n\treturn {\n\t\ttype: 'RECEIVE_THEME_GLOBAL_STYLE_VARIATIONS',\n\t\tstylesheet,\n\t\tvariations,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that the index has been received.\n *\n * @deprecated since WP 5.9, this is not useful anymore, use the selector directly.\n *\n * @return {Object} Action object.\n */\nexport function receiveThemeSupports() {\n\tdeprecated( \"wp.data.dispatch( 'core' ).receiveThemeSupports\", {\n\t\tsince: '5.9',\n\t} );\n\n\treturn {\n\t\ttype: 'DO_NOTHING',\n\t};\n}\n\n/**\n * Returns an action object used in signalling that the theme global styles CPT post revisions have been received.\n * Ignored from documentation as it's internal to the data store.\n *\n * @deprecated since WordPress 6.5.0. Callers should use `dispatch( 'core' ).receiveRevision` instead.\n *\n * @ignore\n *\n * @param {number} currentId The post id.\n * @param {Array} revisions The global styles revisions.\n *\n * @return {Object} Action object.\n */\nexport function receiveThemeGlobalStyleRevisions( currentId, revisions ) {\n\tdeprecated(\n\t\t\"wp.data.dispatch( 'core' ).receiveThemeGlobalStyleRevisions()\",\n\t\t{\n\t\t\tsince: '6.5.0',\n\t\t\talternative: \"wp.data.dispatch( 'core' ).receiveRevisions\",\n\t\t}\n\t);\n\treturn {\n\t\ttype: 'RECEIVE_THEME_GLOBAL_STYLE_REVISIONS',\n\t\tcurrentId,\n\t\trevisions,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that the preview data for\n * a given URl has been received.\n * Ignored from documentation as it's internal to the data store.\n *\n * @ignore\n *\n * @param {string} url URL to preview the embed for.\n * @param {*} preview Preview data.\n *\n * @return {Object} Action object.\n */\nexport function receiveEmbedPreview( url, preview ) {\n\treturn {\n\t\ttype: 'RECEIVE_EMBED_PREVIEW',\n\t\turl,\n\t\tpreview,\n\t};\n}\n\n/**\n * Action triggered to delete an entity record.\n *\n * @param {string} kind Kind of the deleted entity.\n * @param {string} name Name of the deleted entity.\n * @param {number|string} recordId Record ID of the deleted entity.\n * @param {?Object} query Special query parameters for the\n * DELETE API call.\n * @param {Object} [options] Delete options.\n * @param {Function} [options.__unstableFetch] Internal use only. Function to\n * call instead of `apiFetch()`.\n * Must return a promise.\n * @param {boolean} [options.throwOnError=false] If false, this action suppresses all\n * the exceptions. Defaults to false.\n */\nexport const deleteEntityRecord =\n\t(\n\t\tkind,\n\t\tname,\n\t\trecordId,\n\t\tquery,\n\t\t{ __unstableFetch = apiFetch, throwOnError = false } = {}\n\t) =>\n\tasync ( { dispatch, resolveSelect } ) => {\n\t\tlogEntityDeprecation( kind, name, 'deleteEntityRecord' );\n\t\tconst configs = await resolveSelect.getEntitiesConfig( 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 ) {\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\tlet { baseURL } = entityConfig;\n\t\t\tif (\n\t\t\t\tkind === 'postType' &&\n\t\t\t\tname === 'wp_template' &&\n\t\t\t\t( ( recordId &&\n\t\t\t\t\ttypeof recordId === 'string' &&\n\t\t\t\t\t! /^\\d+$/.test( recordId ) ) ||\n\t\t\t\t\t! window?.__experimentalTemplateActivate )\n\t\t\t) {\n\t\t\t\tbaseURL =\n\t\t\t\t\tbaseURL.slice( 0, baseURL.lastIndexOf( '/' ) ) +\n\t\t\t\t\t'/templates';\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tlet path = `${ 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\n\t\t\t\tif ( entityConfig.syncConfig ) {\n\t\t\t\t\tconst objectType = `${ kind }/${ name }`;\n\t\t\t\t\tconst objectId = recordId;\n\n\t\t\t\t\tgetSyncManager()?.unload( objectType, objectId );\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\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\tlogEntityDeprecation( kind, name, 'editEntityRecord' );\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\t// Some fields are merged with the existing value instead of replaced.\n\t\t// See `mergedEdits` definition on the entity config.\n\t\tconst editsWithMerges = Object.keys( edits ).reduce( ( acc, key ) => {\n\t\t\tacc[ key ] = mergedEdits[ key ]\n\t\t\t\t? { ...editedRecord[ key ], ...edits[ key ] }\n\t\t\t\t: edits[ key ];\n\n\t\t\treturn acc;\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 value = editsWithMerges[ 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 ( entityConfig.syncConfig ) {\n\t\t\tconst objectType = `${ kind }/${ name }`;\n\t\t\tconst objectId = recordId;\n\n\t\t\t// Determine whether this edit should create a new undo level.\n\t\t\t//\n\t\t\t// In Gutenberg, block changes flow through two callbacks:\n\t\t\t// - `onInput`: For transient/in-progress changes (e.g., typing each\n\t\t\t// character). These use `isCached: true` and get merged into\n\t\t\t// the current undo item.\n\t\t\t// - `onChange`: For persistent/completed changes (e.g., formatting\n\t\t\t// transforms, block insertions). These use `isCached: false` and\n\t\t\t// should create a new undo level.\n\t\t\t//\n\t\t\t// Additionally, `undoIgnore: true` means the change should not\n\t\t\t// affect the undo history at all (e.g., selection-only changes).\n\t\t\tconst isNewUndoLevel = options.undoIgnore\n\t\t\t\t? false\n\t\t\t\t: ! options.isCached;\n\n\t\t\tgetSyncManager()?.update(\n\t\t\t\tobjectType,\n\t\t\t\tobjectId,\n\t\t\t\teditsWithMerges,\n\t\t\t\tLOCAL_EDITOR_ORIGIN,\n\t\t\t\t{ isNewUndoLevel }\n\t\t\t);\n\t\t}\n\t\tif ( ! options.undoIgnore ) {\n\t\t\tselect.getUndoManager().addRecord(\n\t\t\t\t[\n\t\t\t\t\t{\n\t\t\t\t\t\tid: { kind, name, recordId },\n\t\t\t\t\t\tchanges: Object.keys( edits ).reduce( ( acc, key ) => {\n\t\t\t\t\t\t\tacc[ key ] = {\n\t\t\t\t\t\t\t\tfrom: editedRecord[ key ],\n\t\t\t\t\t\t\t\tto: edits[ 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},\n\t\t\t\t],\n\t\t\t\toptions.isCached\n\t\t\t);\n\t\t}\n\t\tdispatch( {\n\t\t\ttype: 'EDIT_ENTITY_RECORD',\n\t\t\t...edit,\n\t\t} );\n\t};\n\n/**\n * Action triggered to clear all edits from\n * an entity record.\n *\n * @param {string} kind Kind of the entity.\n * @param {string} name Name of the entity.\n * @param {number|string} recordId Record ID of the entity record.\n *\n * @return {Object} Action object.\n */\nexport const clearEntityRecordEdits =\n\t( kind, name, recordId ) =>\n\t( { select, dispatch } ) => {\n\t\tconst entityConfig = select.getEntityConfig( kind, name );\n\t\tlogEntityDeprecation( kind, name, 'clearEntityRecordEdits' );\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\n\t\tconst currentEdits = select.getEntityRecordEdits(\n\t\t\tkind,\n\t\t\tname,\n\t\t\trecordId\n\t\t);\n\t\tif ( ! currentEdits ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Build an edits object with all current edit keys set to undefined\n\t\t// so the reducer removes them.\n\t\tconst clearedEdits = Object.keys( currentEdits ).reduce(\n\t\t\t( acc, key ) => {\n\t\t\t\tacc[ key ] = undefined;\n\t\t\t\treturn acc;\n\t\t\t},\n\t\t\t{}\n\t\t);\n\n\t\tdispatch( {\n\t\t\ttype: 'EDIT_ENTITY_RECORD',\n\t\t\tkind,\n\t\t\tname,\n\t\t\trecordId,\n\t\t\tedits: clearedEdits,\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 undone\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\tlogEntityDeprecation( kind, name, 'saveEntityRecord' );\n\t\tconst configs = await resolveSelect.getEntitiesConfig( 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\t\tconst recordId = record[ entityIdKey ];\n\t\tconst isNewRecord = !! entityIdKey && ! recordId;\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\tlet { baseURL } = entityConfig;\n\t\t\t// For \"string\" IDs, use the old templates endpoint.\n\t\t\tif (\n\t\t\t\tkind === 'postType' &&\n\t\t\t\tname === 'wp_template' &&\n\t\t\t\t( ( recordId &&\n\t\t\t\t\ttypeof recordId === 'string' &&\n\t\t\t\t\t! /^\\d+$/.test( recordId ) ) ||\n\t\t\t\t\t! window?.__experimentalTemplateActivate )\n\t\t\t) {\n\t\t\t\tbaseURL =\n\t\t\t\t\tbaseURL.slice( 0, baseURL.lastIndexOf( '/' ) ) +\n\t\t\t\t\t'/templates';\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tconst path = `${ baseURL }${ recordId ? '/' + recordId : '' }`;\n\t\t\t\t// Skip the raw values check when creating a new record; they don't exist yet.\n\t\t\t\tconst persistedRecord = ! isNewRecord\n\t\t\t\t\t? select.getRawEntityRecord( kind, name, recordId )\n\t\t\t\t\t: {};\n\n\t\t\t\tif ( isAutosave ) {\n\t\t\t\t\t// Most of this autosave logic is very specific to posts.\n\t\t\t\t\t// This is fine for now as it is the only supported autosave,\n\t\t\t\t\t// but ideally this should all be handled in the back end,\n\t\t\t\t\t// so the client just sends and receives objects.\n\t\t\t\t\tconst currentUser = select.getCurrentUser();\n\t\t\t\t\tconst currentUserId = currentUser\n\t\t\t\t\t\t? currentUser.id\n\t\t\t\t\t\t: undefined;\n\t\t\t\t\tconst autosavePost = await resolveSelect.getAutosave(\n\t\t\t\t\t\tpersistedRecord.type,\n\t\t\t\t\t\tpersistedRecord.id,\n\t\t\t\t\t\tcurrentUserId\n\t\t\t\t\t);\n\t\t\t\t\t// Autosaves need all expected fields to be present.\n\t\t\t\t\t// So we fallback to the previous autosave and then\n\t\t\t\t\t// to the actual persisted entity if the edits don't\n\t\t\t\t\t// have a value.\n\t\t\t\t\tlet data = {\n\t\t\t\t\t\t...persistedRecord,\n\t\t\t\t\t\t...autosavePost,\n\t\t\t\t\t\t...record,\n\t\t\t\t\t};\n\t\t\t\t\tdata = Object.keys( data ).reduce(\n\t\t\t\t\t\t( acc, key ) => {\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t\t'title',\n\t\t\t\t\t\t\t\t\t'excerpt',\n\t\t\t\t\t\t\t\t\t'content',\n\t\t\t\t\t\t\t\t\t'meta',\n\t\t\t\t\t\t\t\t].includes( key )\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tacc[ key ] = data[ key ];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn acc;\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t// Do not update the `status` if we have edited it when auto saving.\n\t\t\t\t\t\t\t// It's very important to let the user explicitly save this change,\n\t\t\t\t\t\t\t// because it can lead to unexpected results. An example would be to\n\t\t\t\t\t\t\t// have a draft post and change the status to publish.\n\t\t\t\t\t\t\tstatus:\n\t\t\t\t\t\t\t\tdata.status === 'auto-draft'\n\t\t\t\t\t\t\t\t\t? 'draft'\n\t\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t\t\tupdatedRecord = await __unstableFetch( {\n\t\t\t\t\t\tpath: `${ path }/autosaves`,\n\t\t\t\t\t\tmethod: 'POST',\n\t\t\t\t\t\tdata,\n\t\t\t\t\t} );\n\n\t\t\t\t\t// An autosave may be processed by the server as a regular save\n\t\t\t\t\t// when its update is requested by the author and the post had\n\t\t\t\t\t// draft or auto-draft status.\n\t\t\t\t\tif ( persistedRecord.id === updatedRecord.id ) {\n\t\t\t\t\t\tlet newRecord = {\n\t\t\t\t\t\t\t...persistedRecord,\n\t\t\t\t\t\t\t...data,\n\t\t\t\t\t\t\t...updatedRecord,\n\t\t\t\t\t\t};\n\t\t\t\t\t\tnewRecord = Object.keys( newRecord ).reduce(\n\t\t\t\t\t\t\t( acc, key ) => {\n\t\t\t\t\t\t\t\t// These properties are persisted in autosaves.\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t[ 'title', 'excerpt', 'content' ].includes(\n\t\t\t\t\t\t\t\t\t\tkey\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\tacc[ key ] = newRecord[ key ];\n\t\t\t\t\t\t\t\t} else if ( key === 'status' ) {\n\t\t\t\t\t\t\t\t\t// Status is only persisted in autosaves when going from\n\t\t\t\t\t\t\t\t\t// \"auto-draft\" to \"draft\".\n\t\t\t\t\t\t\t\t\tacc[ key ] =\n\t\t\t\t\t\t\t\t\t\tpersistedRecord.status ===\n\t\t\t\t\t\t\t\t\t\t\t'auto-draft' &&\n\t\t\t\t\t\t\t\t\t\tnewRecord.status === 'draft'\n\t\t\t\t\t\t\t\t\t\t\t? newRecord.status\n\t\t\t\t\t\t\t\t\t\t\t: persistedRecord.status;\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t// These properties are not persisted in autosaves.\n\t\t\t\t\t\t\t\t\tacc[ key ] = persistedRecord[ key ];\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\treturn acc;\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{}\n\t\t\t\t\t\t);\n\t\t\t\t\t\tdispatch.receiveEntityRecords(\n\t\t\t\t\t\t\tkind,\n\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\tnewRecord,\n\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\ttrue\n\t\t\t\t\t\t);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tdispatch.receiveAutosaves(\n\t\t\t\t\t\t\tpersistedRecord.id,\n\t\t\t\t\t\t\tupdatedRecord\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tlet edits = record;\n\t\t\t\t\tif ( entityConfig.__unstablePrePersist ) {\n\t\t\t\t\t\tedits = {\n\t\t\t\t\t\t\t...edits,\n\t\t\t\t\t\t\t...entityConfig.__unstablePrePersist(\n\t\t\t\t\t\t\t\tpersistedRecord,\n\t\t\t\t\t\t\t\tedits\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\tupdatedRecord = await __unstableFetch( {\n\t\t\t\t\t\tpath,\n\t\t\t\t\t\tmethod: recordId ? 'PUT' : 'POST',\n\t\t\t\t\t\tdata: edits,\n\t\t\t\t\t} );\n\t\t\t\t\tdispatch.receiveEntityRecords(\n\t\t\t\t\t\tkind,\n\t\t\t\t\t\tname,\n\t\t\t\t\t\tupdatedRecord,\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t\tedits\n\t\t\t\t\t);\n\t\t\t\t\tif ( entityConfig.syncConfig ) {\n\t\t\t\t\t\tgetSyncManager()?.update(\n\t\t\t\t\t\t\t`${ kind }/${ name }`,\n\t\t\t\t\t\t\trecordId,\n\t\t\t\t\t\t\tupdatedRecord,\n\t\t\t\t\t\t\tLOCAL_EDITOR_ORIGIN,\n\t\t\t\t\t\t\t{ isSave: true }\n\t\t\t\t\t\t);\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, resolveSelect } ) => {\n\t\tlogEntityDeprecation( kind, name, 'saveEditedEntityRecord' );\n\t\tif ( ! select.hasEditsForEntityRecord( kind, name, recordId ) ) {\n\t\t\treturn;\n\t\t}\n\t\tconst configs = await resolveSelect.getEntitiesConfig( 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 {number|string} recordId ID of the record.\n * @param {Array} itemsToSave List of entity properties or property paths to save.\n * @param {Object} options Saving options.\n */\nexport const __experimentalSaveSpecifiedEntityEdits =\n\t( kind, name, recordId, itemsToSave, options ) =>\n\tasync ( { select, dispatch, resolveSelect } ) => {\n\t\tlogEntityDeprecation(\n\t\t\tkind,\n\t\t\tname,\n\t\t\t'__experimentalSaveSpecifiedEntityEdits'\n\t\t);\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 resolveSelect.getEntitiesConfig( 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 current user has\n * permission to perform an action on a REST resource. Ignored from\n * documentation as it's internal to the data store.\n *\n * @ignore\n *\n * @param {Object<string, boolean>} permissions An object where keys represent\n * actions and REST resources, and\n * values indicate whether the user\n * is allowed to perform the\n * action.\n *\n * @return {Object} Action object.\n */\nexport function receiveUserPermissions( permissions ) {\n\treturn {\n\t\ttype: 'RECEIVE_USER_PERMISSIONS',\n\t\tpermissions,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that the autosaves for a\n * post have been received.\n * Ignored from documentation as it's internal to the data store.\n *\n * @ignore\n *\n * @param {number} postId The id of the post that is parent to the autosave.\n * @param {Array|Object} autosaves An array of autosaves or singular autosave object.\n *\n * @return {Object} Action object.\n */\nexport function receiveAutosaves( postId, autosaves ) {\n\treturn {\n\t\ttype: 'RECEIVE_AUTOSAVES',\n\t\tpostId,\n\t\tautosaves: Array.isArray( autosaves ) ? autosaves : [ autosaves ],\n\t};\n}\n\n/**\n * Returns an action object signalling that the fallback Navigation\n * Menu id has been received.\n *\n * @param {integer} fallbackId the id of the fallback Navigation Menu\n * @return {Object} Action object.\n */\nexport function receiveNavigationFallbackId( fallbackId ) {\n\treturn {\n\t\ttype: 'RECEIVE_NAVIGATION_FALLBACK_ID',\n\t\tfallbackId,\n\t};\n}\n\n/**\n * Returns an action object used to set the template for a given query.\n *\n * @param {Object} query The lookup query.\n * @param {string} templateId The resolved template id.\n *\n * @return {Object} Action object.\n */\nexport function receiveDefaultTemplateId( query, templateId ) {\n\treturn {\n\t\ttype: 'RECEIVE_DEFAULT_TEMPLATE',\n\t\tquery,\n\t\ttemplateId,\n\t};\n}\n\n/**\n * Action triggered to receive revision items.\n *\n * @param {string} kind Kind of the received entity record revisions.\n * @param {string} name Name of the received entity record revisions.\n * @param {number|string} recordKey The key of the entity record whose revisions you want to fetch.\n * @param {Array|Object} records Revisions received.\n * @param {?Object} query Query Object.\n * @param {?boolean} invalidateCache Should invalidate query caches.\n * @param {?Object} meta Meta information about pagination.\n */\nexport const receiveRevisions =\n\t( kind, name, recordKey, records, query, invalidateCache = false, meta ) =>\n\tasync ( { dispatch, resolveSelect } ) => {\n\t\tlogEntityDeprecation( kind, name, 'receiveRevisions' );\n\t\tconst configs = await resolveSelect.getEntitiesConfig( kind );\n\t\tconst entityConfig = configs.find(\n\t\t\t( config ) => config.kind === kind && config.name === name\n\t\t);\n\t\tconst key =\n\t\t\tentityConfig && entityConfig?.revisionKey\n\t\t\t\t? entityConfig.revisionKey\n\t\t\t\t: DEFAULT_ENTITY_KEY;\n\n\t\tdispatch( {\n\t\t\ttype: 'RECEIVE_ITEM_REVISIONS',\n\t\t\tkey,\n\t\t\titems: Array.isArray( records ) ? records : [ records ],\n\t\t\trecordKey,\n\t\t\tmeta,\n\t\t\tquery,\n\t\t\tkind,\n\t\t\tname,\n\t\t\tinvalidateCache,\n\t\t} );\n\t};\n\n/**\n * Returns an action object used to set the sync connection status for an entity or collection.\n *\n * @param {string} kind Kind of the entity.\n * @param {string} name Name of the entity.\n * @param {number|string|null} key The entity key, or null for collections.\n * @param {Object|null} status The connection state object or null on unload.\n *\n * @return {Object} Action object.\n */\nexport function setSyncConnectionStatus( kind, name, key, status ) {\n\tif ( ! status ) {\n\t\treturn {\n\t\t\ttype: 'CLEAR_SYNC_CONNECTION_STATUS',\n\t\t\tkind,\n\t\t\tname,\n\t\t\tkey,\n\t\t};\n\t}\n\n\treturn {\n\t\ttype: 'SET_SYNC_CONNECTION_STATUS',\n\t\tkind,\n\t\tname,\n\t\tkey,\n\t\tstatus,\n\t};\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,iBAA0B;AAC1B,kBAA2B;AAK3B,uBAAqB;AACrB,iBAA6B;AAC7B,wBAAuB;AAKvB,mBAA+C;AAC/C,0BAA+D;AAC/D,sBAAmC;AACnC,mBAA4B;AAC5B,kBAA2B;AAC3B,kBAAoD;AACpD,oCAAiC;AAa1B,SAAS,iBAAkB,SAAS,OAAQ;AAClD,SAAO;AAAA,IACN,MAAM;AAAA,IACN,OAAO,MAAM,QAAS,KAAM,IAAI,QAAQ,CAAE,KAAM;AAAA,IAChD;AAAA,EACD;A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,IAAM,mBACZ,CAAE,MAAM,MAAM,WAAW,SAAS,OAAO,kBAAkB,OAAO,SAClE,OAAQ,EAAE,UAAU,cAAc,MAAO;AACxC,oCAAAE,SAAsB,MAAM,MAAM,kBAAmB;AACrD,QAAM,UAAU,MAAM,cAAc,kBAAmB,IAAK;AAC5D,QAAM,eAAe,QAAQ;AAAA,IAC5B,CAAE,WAAY,OAAO,SAAS,QAAQ,OAAO,SAAS;AAAA,EACvD;AACA,QAAM,MACL,gBAAgB,cAAc,cAC3B,aAAa,cACb;AAEJ,WAAU;AAAA,IACT,MAAM;AAAA,IACN;AAAA,IACA,OAAO,MAAM,QAAS,OAAQ,IAAI,UAAU,CAAE,OAAQ;AAAA,IACtD;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,CAAE;AACH;AAYM,SAAS,wBAAyB,MAAM,MAAM,KAAK,QAAS;AAClE,MAAK,CAAE,QAAS;AACf,WAAO;AAAA,MACN,MAAM;AAAA,MACN;AAAA,MACA;AAAA,MACA;AAAA,IACD;AAAA,EACD;AAEA,SAAO;AAAA,IACN,MAAM;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACD;",
6
6
  "names": ["deprecated", "apiFetch", "logEntityDeprecation", "fastDeepEqual", "uuid"]
7
7
  }
@@ -0,0 +1,103 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // packages/core-data/src/awareness/block-lookup.ts
21
+ var block_lookup_exports = {};
22
+ __export(block_lookup_exports, {
23
+ getBlockPathInYdoc: () => getBlockPathInYdoc,
24
+ resolveBlockClientIdByPath: () => resolveBlockClientIdByPath
25
+ });
26
+ module.exports = __toCommonJS(block_lookup_exports);
27
+ var import_data = require("@wordpress/data");
28
+ var import_sync = require("@wordpress/sync");
29
+ var import_block_editor = require("@wordpress/block-editor");
30
+ function getBlockPathInYdoc(yType) {
31
+ const path = [];
32
+ let current = yType;
33
+ while (current) {
34
+ const parentArray = current.parent;
35
+ if (!parentArray || !(parentArray instanceof import_sync.Y.Array)) {
36
+ return null;
37
+ }
38
+ let index = -1;
39
+ for (let i = 0; i < parentArray.length; i++) {
40
+ if (parentArray.get(i) === current) {
41
+ index = i;
42
+ break;
43
+ }
44
+ }
45
+ if (index === -1) {
46
+ return null;
47
+ }
48
+ path.unshift(index);
49
+ const grandparent = parentArray.parent;
50
+ if (grandparent instanceof import_sync.Y.Map && grandparent.get("clientId") !== void 0) {
51
+ current = grandparent;
52
+ } else {
53
+ break;
54
+ }
55
+ }
56
+ return path;
57
+ }
58
+ function resolveBlockClientIdByPath(path) {
59
+ if (path.length === 0) {
60
+ return null;
61
+ }
62
+ const { getBlocks } = (0, import_data.select)(import_block_editor.store);
63
+ const postContentBlocks = getPostContentBlocks(getBlocks(), getBlocks);
64
+ let blocks = postContentBlocks;
65
+ for (let i = 0; i < path.length; i++) {
66
+ const block = blocks[path[i]];
67
+ if (!block) {
68
+ return null;
69
+ }
70
+ if (i === path.length - 1) {
71
+ return block.clientId;
72
+ }
73
+ blocks = block.innerBlocks;
74
+ }
75
+ return null;
76
+ }
77
+ function getPostContentBlocks(rootBlocks, getBlocks) {
78
+ const postContentBlock = findBlockByName(rootBlocks, "core/post-content");
79
+ if (postContentBlock) {
80
+ return getBlocks(postContentBlock.clientId);
81
+ }
82
+ return rootBlocks;
83
+ }
84
+ function findBlockByName(blocks, name) {
85
+ for (const block of blocks) {
86
+ if (block.name === name) {
87
+ return block;
88
+ }
89
+ if (block.innerBlocks?.length) {
90
+ const found = findBlockByName(block.innerBlocks, name);
91
+ if (found) {
92
+ return found;
93
+ }
94
+ }
95
+ }
96
+ return null;
97
+ }
98
+ // Annotate the CommonJS export names for ESM import in node:
99
+ 0 && (module.exports = {
100
+ getBlockPathInYdoc,
101
+ resolveBlockClientIdByPath
102
+ });
103
+ //# sourceMappingURL=block-lookup.cjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/awareness/block-lookup.ts"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { select } from '@wordpress/data';\nimport { Y } from '@wordpress/sync';\n// @ts-ignore No exported types for block editor store selectors.\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport type { AbsoluteBlockIndexPath } from '../types';\n\n/**\n * A block as represented in the block-editor store (from `getBlocks()`).\n *\n * This is a minimal interface covering only the fields used by RTC awareness.\n */\ninterface EditorStoreBlock {\n\tclientId: string;\n\tname: string;\n\tinnerBlocks: EditorStoreBlock[];\n}\n\n/**\n * Given a Y.Map within a Ydoc, traverse up the Yjs block tree to compute the\n * index path from the root.\n *\n * For example, the second inner block of the first root block returns [0, 1].\n *\n * @param yType - The Yjs block Y.Map to start from.\n * @return The index path from root, or null if traversal fails.\n */\nexport function getBlockPathInYdoc(\n\tyType: Y.Map< unknown >\n): AbsoluteBlockIndexPath | null {\n\tconst path: AbsoluteBlockIndexPath = [];\n\tlet current: Y.Map< unknown > = yType;\n\n\twhile ( current ) {\n\t\tconst parentArray = current.parent;\n\n\t\tif ( ! parentArray || ! ( parentArray instanceof Y.Array ) ) {\n\t\t\treturn null;\n\t\t}\n\n\t\t// Find index of current block in its parent array.\n\t\tlet index = -1;\n\t\tfor ( let i = 0; i < parentArray.length; i++ ) {\n\t\t\tif ( parentArray.get( i ) === current ) {\n\t\t\t\tindex = i;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tif ( index === -1 ) {\n\t\t\treturn null;\n\t\t}\n\n\t\tpath.unshift( index );\n\n\t\t// Walk up: is the parent array's parent a block Y.Map or the root?\n\t\tconst grandparent = parentArray.parent;\n\t\tif (\n\t\t\tgrandparent instanceof Y.Map &&\n\t\t\tgrandparent.get( 'clientId' ) !== undefined\n\t\t) {\n\t\t\tcurrent = grandparent; // It's a block, keep going.\n\t\t} else {\n\t\t\tbreak; // It's the root map, done.\n\t\t}\n\t}\n\n\treturn path;\n}\n\n/**\n * Navigate the block-editor store's block tree by an index path\n * and return the local block's clientId.\n *\n * In template mode, getBlocks() returns the full template tree, but Yjs\n * paths are relative to the post content. This method finds the\n * core/post-content block (if present) and uses its inner blocks as the\n * navigation root, so paths align with the Yjs document structure.\n *\n * @param path - The index path, e.g. [0, 1] for blocks[0].innerBlocks[1].\n * @return The local block clientId, or null if the path is invalid.\n */\nexport function resolveBlockClientIdByPath(\n\tpath: AbsoluteBlockIndexPath\n): string | null {\n\tif ( path.length === 0 ) {\n\t\treturn null;\n\t}\n\n\tconst { getBlocks } = select( blockEditorStore );\n\tconst postContentBlocks = getPostContentBlocks( getBlocks(), getBlocks );\n\n\tlet blocks = postContentBlocks;\n\n\tfor ( let i = 0; i < path.length; i++ ) {\n\t\tconst block = blocks[ path[ i ] ];\n\t\tif ( ! block ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( i === path.length - 1 ) {\n\t\t\treturn block.clientId;\n\t\t}\n\t\tblocks = block.innerBlocks;\n\t}\n\treturn null;\n}\n\n/**\n * Find the post content blocks to use as the navigation root.\n *\n * In template mode, the block tree contains template parts wrapping a\n * core/post-content block. The Yjs document only stores the post content\n * blocks, so we need to find the core/post-content block and use\n * getBlocks(clientId) to retrieve its inner blocks from the store.\n *\n * We must use getBlocks(clientId) rather than reading .innerBlocks from\n * the block object because useBlockSync() injects post content as\n * controlled inner blocks \u2014 they exist in the store's block order map\n * but are not populated in the .innerBlocks property of the tree\n * returned by getBlocks().\n *\n * @param rootBlocks - The root-level blocks from getBlocks().\n * @param getBlocks - The getBlocks selector.\n * @return The blocks that correspond to the Yjs document root.\n */\nfunction getPostContentBlocks(\n\trootBlocks: EditorStoreBlock[],\n\tgetBlocks: ( rootClientId?: string ) => EditorStoreBlock[]\n): EditorStoreBlock[] {\n\tconst postContentBlock = findBlockByName( rootBlocks, 'core/post-content' );\n\tif ( postContentBlock ) {\n\t\t// Use getBlocks(clientId) to read controlled inner blocks from\n\t\t// the store, since postContentBlock.innerBlocks is empty.\n\t\treturn getBlocks( postContentBlock.clientId );\n\t}\n\n\treturn rootBlocks;\n}\n\n/**\n * Recursively search the block tree for a block with a given name.\n *\n * @param blocks - The blocks to search.\n * @param name - The block name to find.\n * @return The first matching block, or null if not found.\n */\nfunction findBlockByName(\n\tblocks: EditorStoreBlock[],\n\tname: string\n): EditorStoreBlock | null {\n\tfor ( const block of blocks ) {\n\t\tif ( block.name === name ) {\n\t\t\treturn block;\n\t\t}\n\t\tif ( block.innerBlocks?.length ) {\n\t\t\tconst found = findBlockByName( block.innerBlocks, name );\n\t\t\tif ( found ) {\n\t\t\t\treturn found;\n\t\t\t}\n\t\t}\n\t}\n\treturn null;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAuB;AACvB,kBAAkB;AAElB,0BAA0C;AA2BnC,SAAS,mBACf,OACgC;AAChC,QAAM,OAA+B,CAAC;AACtC,MAAI,UAA4B;AAEhC,SAAQ,SAAU;AACjB,UAAM,cAAc,QAAQ;AAE5B,QAAK,CAAE,eAAe,EAAI,uBAAuB,cAAE,QAAU;AAC5D,aAAO;AAAA,IACR;AAGA,QAAI,QAAQ;AACZ,aAAU,IAAI,GAAG,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"]
7
+ }
@@ -27,6 +27,7 @@ var import_data = require("@wordpress/data");
27
27
  var import_sync = require("@wordpress/sync");
28
28
  var import_block_editor = require("@wordpress/block-editor");
29
29
  var import_base_awareness = require("./base-awareness.cjs");
30
+ var import_block_lookup = require("./block-lookup.cjs");
30
31
  var import_config = require("./config.cjs");
31
32
  var import_name = require("../name.cjs");
32
33
  var import_crdt_user_selections = require("../utils/crdt-user-selections.cjs");
@@ -124,16 +125,53 @@ var PostEditorAwareness = class extends import_base_awareness.BaseAwarenessState
124
125
  return (0, import_crdt_user_selections.areSelectionsStatesEqual)(state1.selection, state2.selection);
125
126
  }
126
127
  /**
127
- * Get the absolute position index from a selection cursor.
128
+ * Resolve a selection state to a text index and block client ID.
128
129
  *
129
- * @param selection - The selection cursor.
130
- * @return The absolute position index, or null if not found.
130
+ * For text-based selections, navigates up from the resolved Y.Text via
131
+ * AbstractType.parent to find the containing block, then resolves the
132
+ * local clientId via the block's tree path.
133
+ * For WholeBlock selections, resolves the block's relative position and
134
+ * then finds the local clientId via tree path.
135
+ *
136
+ * Tree-path resolution is used instead of reading the clientId directly
137
+ * from the Yjs block because the local block-editor store may use different
138
+ * clientIds (e.g. in "Show Template" mode where blocks are cloned).
139
+ *
140
+ * @param selection - The selection state.
141
+ * @return The text index and block client ID, or nulls if not resolvable.
131
142
  */
132
- getAbsolutePositionIndex(selection) {
133
- return import_sync.Y.createAbsolutePositionFromRelativePosition(
134
- selection.cursorPosition.relativePosition,
143
+ convertSelectionStateToAbsolute(selection) {
144
+ if (selection.type === import_crdt_user_selections.SelectionType.None) {
145
+ return { textIndex: null, localClientId: null };
146
+ }
147
+ if (selection.type === import_crdt_user_selections.SelectionType.WholeBlock) {
148
+ const absolutePos = import_sync.Y.createAbsolutePositionFromRelativePosition(
149
+ selection.blockPosition,
150
+ this.doc
151
+ );
152
+ let localClientId2 = null;
153
+ if (absolutePos && absolutePos.type instanceof import_sync.Y.Array) {
154
+ const parentArray = absolutePos.type;
155
+ const block = parentArray.get(absolutePos.index);
156
+ if (block instanceof import_sync.Y.Map) {
157
+ const path2 = (0, import_block_lookup.getBlockPathInYdoc)(block);
158
+ localClientId2 = path2 ? (0, import_block_lookup.resolveBlockClientIdByPath)(path2) : null;
159
+ }
160
+ }
161
+ return { textIndex: null, localClientId: localClientId2 };
162
+ }
163
+ const cursorPos = "cursorPosition" in selection ? selection.cursorPosition : selection.cursorStartPosition;
164
+ const absolutePosition = import_sync.Y.createAbsolutePositionFromRelativePosition(
165
+ cursorPos.relativePosition,
135
166
  this.doc
136
- )?.index ?? null;
167
+ );
168
+ if (!absolutePosition) {
169
+ return { textIndex: null, localClientId: null };
170
+ }
171
+ const yType = absolutePosition.type.parent?.parent;
172
+ const path = yType instanceof import_sync.Y.Map ? (0, import_block_lookup.getBlockPathInYdoc)(yType) : null;
173
+ const localClientId = path ? (0, import_block_lookup.resolveBlockClientIdByPath)(path) : null;
174
+ return { textIndex: absolutePosition.index, localClientId };
137
175
  }
138
176
  /**
139
177
  * Type guard to check if a struct is a Y.Item (not Y.GC)
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/awareness/post-editor-awareness.ts"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { dispatch, select, subscribe } from '@wordpress/data';\nimport { Y } from '@wordpress/sync';\n// @ts-ignore No exported types for block editor store selectors.\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { BaseAwarenessState, baseEqualityFieldChecks } from './base-awareness';\nimport {\n\tAWARENESS_CURSOR_UPDATE_THROTTLE_IN_MS,\n\tLOCAL_CURSOR_UPDATE_DEBOUNCE_IN_MS,\n} from './config';\nimport { STORE_NAME as coreStore } from '../name';\nimport {\n\tareSelectionsStatesEqual,\n\tgetSelectionState,\n} from '../utils/crdt-user-selections';\n\nimport type { SelectionCursor, WPBlockSelection } from '../types';\nimport type {\n\tDebugCollaboratorData,\n\tEditorState,\n\tPostEditorState,\n\tSerializableYItem,\n\tYDocDebugData,\n} from './types';\n\nexport class PostEditorAwareness extends BaseAwarenessState< PostEditorState > {\n\tprotected equalityFieldChecks = {\n\t\t...baseEqualityFieldChecks,\n\t\teditorState: this.areEditorStatesEqual,\n\t};\n\n\tpublic constructor(\n\t\tdoc: Y.Doc,\n\t\tprivate kind: string,\n\t\tprivate name: string,\n\t\tprivate postId: number\n\t) {\n\t\tsuper( doc );\n\t}\n\n\tprotected onSetUp(): void {\n\t\tsuper.onSetUp();\n\n\t\tthis.subscribeToCollaboratorSelectionChanges();\n\t}\n\n\t/**\n\t * Subscribe to collaborator selection changes and update the selection state.\n\t */\n\tprivate subscribeToCollaboratorSelectionChanges(): void {\n\t\tconst {\n\t\t\tgetSelectionStart,\n\t\t\tgetSelectionEnd,\n\t\t\tgetSelectedBlocksInitialCaretPosition,\n\t\t} = select( blockEditorStore );\n\n\t\t// Keep track of the current selection in the outer scope so we can compare\n\t\t// in the subscription.\n\t\tlet selectionStart = getSelectionStart();\n\t\tlet selectionEnd = getSelectionEnd();\n\t\tlet localCursorTimeout: NodeJS.Timeout | null = null;\n\n\t\tsubscribe( () => {\n\t\t\tconst newSelectionStart = getSelectionStart();\n\t\t\tconst newSelectionEnd = getSelectionEnd();\n\n\t\t\tif (\n\t\t\t\tnewSelectionStart === selectionStart &&\n\t\t\t\tnewSelectionEnd === selectionEnd\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tselectionStart = newSelectionStart;\n\t\t\tselectionEnd = newSelectionEnd;\n\n\t\t\t// Typically selection position is only persisted after typing in a block, which\n\t\t\t// can cause selection position to be reset by other users making block updates.\n\t\t\t// Ensure we update the controlled selection right away, persisting our cursor position locally.\n\t\t\tconst initialPosition = getSelectedBlocksInitialCaretPosition();\n\t\t\tvoid this.updateSelectionInEntityRecord(\n\t\t\t\tselectionStart,\n\t\t\t\tselectionEnd,\n\t\t\t\tinitialPosition\n\t\t\t);\n\n\t\t\t// We receive two selection changes in quick succession\n\t\t\t// from local selection events:\n\t\t\t// { clientId: \"123...\", attributeKey: \"content\", offset: undefined }\n\t\t\t// { clientId: \"123...\", attributeKey: \"content\", offset: 554 }\n\t\t\t// Add a short debounce to avoid sending the first selection change.\n\t\t\tif ( localCursorTimeout ) {\n\t\t\t\tclearTimeout( localCursorTimeout );\n\t\t\t}\n\n\t\t\tlocalCursorTimeout = setTimeout( () => {\n\t\t\t\tconst selectionState = getSelectionState(\n\t\t\t\t\tselectionStart,\n\t\t\t\t\tselectionEnd,\n\t\t\t\t\tthis.doc\n\t\t\t\t);\n\n\t\t\t\tthis.setThrottledLocalStateField(\n\t\t\t\t\t'editorState',\n\t\t\t\t\t{ selection: selectionState },\n\t\t\t\t\tAWARENESS_CURSOR_UPDATE_THROTTLE_IN_MS\n\t\t\t\t);\n\t\t\t}, LOCAL_CURSOR_UPDATE_DEBOUNCE_IN_MS );\n\t\t} );\n\t}\n\n\t/**\n\t * Update the entity record with the current collaborator's selection.\n\t *\n\t * @param selectionStart - The start position of the selection.\n\t * @param selectionEnd - The end position of the selection.\n\t * @param initialPosition - The initial position of the selection.\n\t */\n\tprivate async updateSelectionInEntityRecord(\n\t\tselectionStart: WPBlockSelection,\n\t\tselectionEnd: WPBlockSelection,\n\t\tinitialPosition: number | null\n\t): Promise< void > {\n\t\t// Send an entityRecord `selection` update if we have a selection.\n\t\t//\n\t\t// Normally WordPress updates the `selection` property of the post when changes are made to blocks.\n\t\t// In a multi-user setup, block changes can occur from other users. When an entity is updated from another\n\t\t// user's changes, useBlockSync() in Gutenberg will reset the user's selection to the last saved selection.\n\t\t//\n\t\t// Manually adding an edit for each movement ensures that other user's changes to the document will\n\t\t// not cause the local user's selection to reset to the last local change location.\n\t\tconst edits = {\n\t\t\tselection: { selectionStart, selectionEnd, initialPosition },\n\t\t};\n\n\t\tconst options = {\n\t\t\tundoIgnore: true,\n\t\t};\n\n\t\t// @ts-ignore Types are not provided when using store name instead of store instance.\n\t\tdispatch( coreStore ).editEntityRecord(\n\t\t\tthis.kind,\n\t\t\tthis.name,\n\t\t\tthis.postId,\n\t\t\tedits,\n\t\t\toptions\n\t\t);\n\t}\n\n\t/**\n\t * Check if two editor states are equal.\n\t *\n\t * @param state1 - The first editor state.\n\t * @param state2 - The second editor state.\n\t * @return True if the editor states are equal, false otherwise.\n\t */\n\tprivate areEditorStatesEqual(\n\t\tstate1?: EditorState,\n\t\tstate2?: EditorState\n\t): boolean {\n\t\tif ( ! state1 || ! state2 ) {\n\t\t\treturn state1 === state2;\n\t\t}\n\n\t\treturn areSelectionsStatesEqual( state1.selection, state2.selection );\n\t}\n\n\t/**\n\t * Get the absolute position index from a selection cursor.\n\t *\n\t * @param selection - The selection cursor.\n\t * @return The absolute position index, or null if not found.\n\t */\n\tpublic getAbsolutePositionIndex(\n\t\tselection: SelectionCursor\n\t): number | null {\n\t\treturn (\n\t\t\tY.createAbsolutePositionFromRelativePosition(\n\t\t\t\tselection.cursorPosition.relativePosition,\n\t\t\t\tthis.doc\n\t\t\t)?.index ?? null\n\t\t);\n\t}\n\n\t/**\n\t * Type guard to check if a struct is a Y.Item (not Y.GC)\n\t * @param struct - The struct to check.\n\t * @return True if the struct is a Y.Item, false otherwise.\n\t */\n\tprivate isYItem( struct: Y.Item | Y.GC ): struct is Y.Item {\n\t\treturn 'content' in struct;\n\t}\n\n\t/**\n\t * Get data for debugging, using the awareness state.\n\t *\n\t * @return {YDocDebugData} The debug data.\n\t */\n\tpublic getDebugData(): YDocDebugData {\n\t\tconst ydoc = this.doc;\n\n\t\t// Manually extract doc data to avoid deprecated toJSON method\n\t\tconst docData: Record< string, unknown > = Object.fromEntries(\n\t\t\tArray.from( ydoc.share, ( [ key, value ] ) => [\n\t\t\t\tkey,\n\t\t\t\tvalue.toJSON(),\n\t\t\t] )\n\t\t);\n\n\t\t// Build collaboratorMap from awareness store (all collaborators seen this session)\n\t\tconst collaboratorMapData = new Map< string, DebugCollaboratorData >(\n\t\t\tArray.from( this.getSeenStates().entries() ).map(\n\t\t\t\t( [ clientId, collaboratorState ] ) => [\n\t\t\t\t\tString( clientId ),\n\t\t\t\t\t{\n\t\t\t\t\t\tname: collaboratorState.collaboratorInfo.name,\n\t\t\t\t\t\twpUserId: collaboratorState.collaboratorInfo.id,\n\t\t\t\t\t},\n\t\t\t\t]\n\t\t\t)\n\t\t);\n\n\t\t// Serialize Yjs client items to avoid deep nesting\n\t\tconst serializableClientItems: Record<\n\t\t\tnumber,\n\t\t\tArray< SerializableYItem >\n\t\t> = {};\n\n\t\tydoc.store.clients.forEach( ( structs, clientId ) => {\n\t\t\t// Filter for Y.Item only (skip Y.GC garbage collection structs)\n\t\t\tconst items = structs.filter( this.isYItem );\n\n\t\t\tserializableClientItems[ clientId ] = items.map( ( item ) => {\n\t\t\t\tconst { left, right, ...rest } = item;\n\n\t\t\t\treturn {\n\t\t\t\t\t...rest,\n\t\t\t\t\tleft: left\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tid: left.id,\n\t\t\t\t\t\t\t\tlength: left.length,\n\t\t\t\t\t\t\t\torigin: left.origin,\n\t\t\t\t\t\t\t\tcontent: left.content,\n\t\t\t\t\t\t }\n\t\t\t\t\t\t: null,\n\t\t\t\t\tright: right\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tid: right.id,\n\t\t\t\t\t\t\t\tlength: right.length,\n\t\t\t\t\t\t\t\torigin: right.origin,\n\t\t\t\t\t\t\t\tcontent: right.content,\n\t\t\t\t\t\t }\n\t\t\t\t\t\t: null,\n\t\t\t\t};\n\t\t\t} );\n\t\t} );\n\n\t\treturn {\n\t\t\tdoc: docData,\n\t\t\tclients: serializableClientItems,\n\t\t\tcollaboratorMap: Object.fromEntries( collaboratorMapData ),\n\t\t};\n\t}\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAA4C;AAC5C,kBAAkB;AAElB,0BAA0C;AAK1C,4BAA4D;AAC5D,oBAGO;AACP,kBAAw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K,CAAE,SAAU;AAC5D,cAAM,EAAE,MAAM,OAAO,GAAG,KAAK,IAAI;AAEjC,eAAO;AAAA,UACN,GAAG;AAAA,UACH,MAAM,OACH;AAAA,YACA,IAAI,KAAK;AAAA,YACT,QAAQ,KAAK;AAAA,YACb,QAAQ,KAAK;AAAA,YACb,SAAS,KAAK;AAAA,UACd,IACA;AAAA,UACH,OAAO,QACJ;AAAA,YACA,IAAI,MAAM;AAAA,YACV,QAAQ,MAAM;AAAA,YACd,QAAQ,MAAM;AAAA,YACd,SAAS,MAAM;AAAA,UACf,IACA;AAAA,QACJ;AAAA,MACD,CAAE;AAAA,IACH,CAAE;AAEF,WAAO;AAAA,MACN,KAAK;AAAA,MACL,SAAS;AAAA,MACT,iBAAiB,OAAO,YAAa,mBAAoB;AAAA,IAC1D;AAAA,EACD;AACD;",
6
- "names": ["blockEditorStore", "coreStore"]
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { dispatch, select, subscribe } from '@wordpress/data';\nimport { Y } from '@wordpress/sync';\n// @ts-ignore No exported types for block editor store selectors.\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { BaseAwarenessState, baseEqualityFieldChecks } from './base-awareness';\nimport { getBlockPathInYdoc, resolveBlockClientIdByPath } from './block-lookup';\nimport {\n\tAWARENESS_CURSOR_UPDATE_THROTTLE_IN_MS,\n\tLOCAL_CURSOR_UPDATE_DEBOUNCE_IN_MS,\n} from './config';\nimport { STORE_NAME as coreStore } from '../name';\nimport {\n\tareSelectionsStatesEqual,\n\tgetSelectionState,\n\tSelectionType,\n} from '../utils/crdt-user-selections';\n\nimport type { SelectionState, WPBlockSelection } from '../types';\nimport type { YBlocks } from '../utils/crdt-blocks';\nimport type {\n\tDebugCollaboratorData,\n\tEditorState,\n\tPostEditorState,\n\tSerializableYItem,\n\tYDocDebugData,\n} from './types';\n\nexport class PostEditorAwareness extends BaseAwarenessState< PostEditorState > {\n\tprotected equalityFieldChecks = {\n\t\t...baseEqualityFieldChecks,\n\t\teditorState: this.areEditorStatesEqual,\n\t};\n\n\tpublic constructor(\n\t\tdoc: Y.Doc,\n\t\tprivate kind: string,\n\t\tprivate name: string,\n\t\tprivate postId: number\n\t) {\n\t\tsuper( doc );\n\t}\n\n\tprotected onSetUp(): void {\n\t\tsuper.onSetUp();\n\n\t\tthis.subscribeToCollaboratorSelectionChanges();\n\t}\n\n\t/**\n\t * Subscribe to collaborator selection changes and update the selection state.\n\t */\n\tprivate subscribeToCollaboratorSelectionChanges(): void {\n\t\tconst {\n\t\t\tgetSelectionStart,\n\t\t\tgetSelectionEnd,\n\t\t\tgetSelectedBlocksInitialCaretPosition,\n\t\t} = select( blockEditorStore );\n\n\t\t// Keep track of the current selection in the outer scope so we can compare\n\t\t// in the subscription.\n\t\tlet selectionStart = getSelectionStart();\n\t\tlet selectionEnd = getSelectionEnd();\n\t\tlet localCursorTimeout: NodeJS.Timeout | null = null;\n\n\t\tsubscribe( () => {\n\t\t\tconst newSelectionStart = getSelectionStart();\n\t\t\tconst newSelectionEnd = getSelectionEnd();\n\n\t\t\tif (\n\t\t\t\tnewSelectionStart === selectionStart &&\n\t\t\t\tnewSelectionEnd === selectionEnd\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tselectionStart = newSelectionStart;\n\t\t\tselectionEnd = newSelectionEnd;\n\n\t\t\t// Typically selection position is only persisted after typing in a block, which\n\t\t\t// can cause selection position to be reset by other users making block updates.\n\t\t\t// Ensure we update the controlled selection right away, persisting our cursor position locally.\n\t\t\tconst initialPosition = getSelectedBlocksInitialCaretPosition();\n\t\t\tvoid this.updateSelectionInEntityRecord(\n\t\t\t\tselectionStart,\n\t\t\t\tselectionEnd,\n\t\t\t\tinitialPosition\n\t\t\t);\n\n\t\t\t// We receive two selection changes in quick succession\n\t\t\t// from local selection events:\n\t\t\t// { clientId: \"123...\", attributeKey: \"content\", offset: undefined }\n\t\t\t// { clientId: \"123...\", attributeKey: \"content\", offset: 554 }\n\t\t\t// Add a short debounce to avoid sending the first selection change.\n\t\t\tif ( localCursorTimeout ) {\n\t\t\t\tclearTimeout( localCursorTimeout );\n\t\t\t}\n\n\t\t\tlocalCursorTimeout = setTimeout( () => {\n\t\t\t\tconst selectionState = getSelectionState(\n\t\t\t\t\tselectionStart,\n\t\t\t\t\tselectionEnd,\n\t\t\t\t\tthis.doc\n\t\t\t\t);\n\n\t\t\t\tthis.setThrottledLocalStateField(\n\t\t\t\t\t'editorState',\n\t\t\t\t\t{ selection: selectionState },\n\t\t\t\t\tAWARENESS_CURSOR_UPDATE_THROTTLE_IN_MS\n\t\t\t\t);\n\t\t\t}, LOCAL_CURSOR_UPDATE_DEBOUNCE_IN_MS );\n\t\t} );\n\t}\n\n\t/**\n\t * Update the entity record with the current collaborator's selection.\n\t *\n\t * @param selectionStart - The start position of the selection.\n\t * @param selectionEnd - The end position of the selection.\n\t * @param initialPosition - The initial position of the selection.\n\t */\n\tprivate async updateSelectionInEntityRecord(\n\t\tselectionStart: WPBlockSelection,\n\t\tselectionEnd: WPBlockSelection,\n\t\tinitialPosition: number | null\n\t): Promise< void > {\n\t\t// Send an entityRecord `selection` update if we have a selection.\n\t\t//\n\t\t// Normally WordPress updates the `selection` property of the post when changes are made to blocks.\n\t\t// In a multi-user setup, block changes can occur from other users. When an entity is updated from another\n\t\t// user's changes, useBlockSync() in Gutenberg will reset the user's selection to the last saved selection.\n\t\t//\n\t\t// Manually adding an edit for each movement ensures that other user's changes to the document will\n\t\t// not cause the local user's selection to reset to the last local change location.\n\t\tconst edits = {\n\t\t\tselection: { selectionStart, selectionEnd, initialPosition },\n\t\t};\n\n\t\tconst options = {\n\t\t\tundoIgnore: true,\n\t\t};\n\n\t\t// @ts-ignore Types are not provided when using store name instead of store instance.\n\t\tdispatch( coreStore ).editEntityRecord(\n\t\t\tthis.kind,\n\t\t\tthis.name,\n\t\t\tthis.postId,\n\t\t\tedits,\n\t\t\toptions\n\t\t);\n\t}\n\n\t/**\n\t * Check if two editor states are equal.\n\t *\n\t * @param state1 - The first editor state.\n\t * @param state2 - The second editor state.\n\t * @return True if the editor states are equal, false otherwise.\n\t */\n\tprivate areEditorStatesEqual(\n\t\tstate1?: EditorState,\n\t\tstate2?: EditorState\n\t): boolean {\n\t\tif ( ! state1 || ! state2 ) {\n\t\t\treturn state1 === state2;\n\t\t}\n\n\t\treturn areSelectionsStatesEqual( state1.selection, state2.selection );\n\t}\n\n\t/**\n\t * Resolve a selection state to a text index and block client ID.\n\t *\n\t * For text-based selections, navigates up from the resolved Y.Text via\n\t * AbstractType.parent to find the containing block, then resolves the\n\t * local clientId via the block's tree path.\n\t * For WholeBlock selections, resolves the block's relative position and\n\t * then finds the local clientId via tree path.\n\t *\n\t * Tree-path resolution is used instead of reading the clientId directly\n\t * from the Yjs block because the local block-editor store may use different\n\t * clientIds (e.g. in \"Show Template\" mode where blocks are cloned).\n\t *\n\t * @param selection - The selection state.\n\t * @return The text index and block client ID, or nulls if not resolvable.\n\t */\n\tpublic convertSelectionStateToAbsolute( selection: SelectionState ): {\n\t\ttextIndex: number | null;\n\t\tlocalClientId: string | null;\n\t} {\n\t\tif ( selection.type === SelectionType.None ) {\n\t\t\treturn { textIndex: null, localClientId: null };\n\t\t}\n\n\t\tif ( selection.type === SelectionType.WholeBlock ) {\n\t\t\tconst absolutePos = Y.createAbsolutePositionFromRelativePosition(\n\t\t\t\tselection.blockPosition,\n\t\t\t\tthis.doc\n\t\t\t);\n\n\t\t\tlet localClientId: string | null = null;\n\n\t\t\tif ( absolutePos && absolutePos.type instanceof Y.Array ) {\n\t\t\t\tconst parentArray = absolutePos.type as YBlocks;\n\t\t\t\tconst block = parentArray.get( absolutePos.index );\n\n\t\t\t\tif ( block instanceof Y.Map ) {\n\t\t\t\t\tconst path = getBlockPathInYdoc( block );\n\t\t\t\t\tlocalClientId = path\n\t\t\t\t\t\t? resolveBlockClientIdByPath( path )\n\t\t\t\t\t\t: null;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn { textIndex: null, localClientId };\n\t\t}\n\n\t\t// Text-based selections: resolve cursor position and navigate up.\n\t\tconst cursorPos =\n\t\t\t'cursorPosition' in selection\n\t\t\t\t? selection.cursorPosition\n\t\t\t\t: selection.cursorStartPosition;\n\n\t\tconst absolutePosition = Y.createAbsolutePositionFromRelativePosition(\n\t\t\tcursorPos.relativePosition,\n\t\t\tthis.doc\n\t\t);\n\n\t\tif ( ! absolutePosition ) {\n\t\t\treturn { textIndex: null, localClientId: null };\n\t\t}\n\n\t\t// Navigate up: Y.Text -> attributes Y.Map -> block Y.Map\n\t\tconst yType = absolutePosition.type.parent?.parent;\n\t\tconst path =\n\t\t\tyType instanceof Y.Map ? getBlockPathInYdoc( yType ) : null;\n\t\tconst localClientId = path ? resolveBlockClientIdByPath( path ) : null;\n\n\t\treturn { textIndex: absolutePosition.index, localClientId };\n\t}\n\n\t/**\n\t * Type guard to check if a struct is a Y.Item (not Y.GC)\n\t * @param struct - The struct to check.\n\t * @return True if the struct is a Y.Item, false otherwise.\n\t */\n\tprivate isYItem( struct: Y.Item | Y.GC ): struct is Y.Item {\n\t\treturn 'content' in struct;\n\t}\n\n\t/**\n\t * Get data for debugging, using the awareness state.\n\t *\n\t * @return {YDocDebugData} The debug data.\n\t */\n\tpublic getDebugData(): YDocDebugData {\n\t\tconst ydoc = this.doc;\n\n\t\t// Manually extract doc data to avoid deprecated toJSON method\n\t\tconst docData: Record< string, unknown > = Object.fromEntries(\n\t\t\tArray.from( ydoc.share, ( [ key, value ] ) => [\n\t\t\t\tkey,\n\t\t\t\tvalue.toJSON(),\n\t\t\t] )\n\t\t);\n\n\t\t// Build collaboratorMap from awareness store (all collaborators seen this session)\n\t\tconst collaboratorMapData = new Map< string, DebugCollaboratorData >(\n\t\t\tArray.from( this.getSeenStates().entries() ).map(\n\t\t\t\t( [ clientId, collaboratorState ] ) => [\n\t\t\t\t\tString( clientId ),\n\t\t\t\t\t{\n\t\t\t\t\t\tname: collaboratorState.collaboratorInfo.name,\n\t\t\t\t\t\twpUserId: collaboratorState.collaboratorInfo.id,\n\t\t\t\t\t},\n\t\t\t\t]\n\t\t\t)\n\t\t);\n\n\t\t// Serialize Yjs client items to avoid deep nesting\n\t\tconst serializableClientItems: Record<\n\t\t\tnumber,\n\t\t\tArray< SerializableYItem >\n\t\t> = {};\n\n\t\tydoc.store.clients.forEach( ( structs, clientId ) => {\n\t\t\t// Filter for Y.Item only (skip Y.GC garbage collection structs)\n\t\t\tconst items = structs.filter( this.isYItem );\n\n\t\t\tserializableClientItems[ clientId ] = items.map( ( item ) => {\n\t\t\t\tconst { left, right, ...rest } = item;\n\n\t\t\t\treturn {\n\t\t\t\t\t...rest,\n\t\t\t\t\tleft: left\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tid: left.id,\n\t\t\t\t\t\t\t\tlength: left.length,\n\t\t\t\t\t\t\t\torigin: left.origin,\n\t\t\t\t\t\t\t\tcontent: left.content,\n\t\t\t\t\t\t }\n\t\t\t\t\t\t: null,\n\t\t\t\t\tright: right\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tid: right.id,\n\t\t\t\t\t\t\t\tlength: right.length,\n\t\t\t\t\t\t\t\torigin: right.origin,\n\t\t\t\t\t\t\t\tcontent: right.content,\n\t\t\t\t\t\t }\n\t\t\t\t\t\t: null,\n\t\t\t\t};\n\t\t\t} );\n\t\t} );\n\n\t\treturn {\n\t\t\tdoc: docData,\n\t\t\tclients: serializableClientItems,\n\t\t\tcollaboratorMap: Object.fromEntries( collaboratorMapData ),\n\t\t};\n\t}\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAA4C;AAC5C,kBAAkB;AAElB,0BAA0C;AAK1C,4BAA4D;AAC5D,0BAA+D;AAC/D,oBAGO;AACP,kBAAwC;AACxC,kCAIO;AAYA,IAAM,sBAAN,cAAkC,yCAAsC;AAAA,EAMvE,YACN,KACQ,MACA,M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