@wordpress/core-data 7.48.1 → 7.49.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 (96) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/README.md +0 -1
  3. package/build/actions.cjs +1 -7
  4. package/build/actions.cjs.map +3 -3
  5. package/build/entities.cjs +2 -1
  6. package/build/entities.cjs.map +2 -2
  7. package/build/entity-types/helpers.cjs.map +1 -1
  8. package/build/hooks/use-entity-record.cjs +21 -19
  9. package/build/hooks/use-entity-record.cjs.map +3 -3
  10. package/build/hooks/use-entity-records.cjs +22 -20
  11. package/build/hooks/use-entity-records.cjs.map +3 -3
  12. package/build/hooks/use-post-editor-awareness-state.cjs.map +1 -1
  13. package/build/hooks/use-query-select.cjs +2 -20
  14. package/build/hooks/use-query-select.cjs.map +2 -2
  15. package/build/hooks/utils.cjs +53 -0
  16. package/build/hooks/utils.cjs.map +7 -0
  17. package/build/private-selectors.cjs.map +2 -2
  18. package/build/reducer.cjs +17 -9
  19. package/build/reducer.cjs.map +2 -2
  20. package/build/resolvers.cjs +7 -2
  21. package/build/resolvers.cjs.map +2 -2
  22. package/build/types.cjs.map +1 -1
  23. package/build/utils/clear-unchanged-edits.cjs +51 -0
  24. package/build/utils/clear-unchanged-edits.cjs.map +7 -0
  25. package/build/utils/crdt-blocks.cjs.map +1 -1
  26. package/build/utils/crdt-user-selections.cjs.map +1 -1
  27. package/build/utils/crdt-utils.cjs.map +1 -1
  28. package/build/utils/crdt.cjs.map +1 -1
  29. package/build/utils/index.cjs +3 -0
  30. package/build/utils/index.cjs.map +2 -2
  31. package/build/utils/set-nested-value.cjs.map +1 -1
  32. package/build-module/actions.mjs +2 -8
  33. package/build-module/actions.mjs.map +2 -2
  34. package/build-module/entities.mjs +2 -1
  35. package/build-module/entities.mjs.map +2 -2
  36. package/build-module/hooks/use-entity-record.mjs +21 -19
  37. package/build-module/hooks/use-entity-record.mjs.map +2 -2
  38. package/build-module/hooks/use-entity-records.mjs +20 -18
  39. package/build-module/hooks/use-entity-records.mjs.map +2 -2
  40. package/build-module/hooks/use-post-editor-awareness-state.mjs.map +1 -1
  41. package/build-module/hooks/use-query-select.mjs +2 -20
  42. package/build-module/hooks/use-query-select.mjs.map +2 -2
  43. package/build-module/hooks/utils.mjs +28 -0
  44. package/build-module/hooks/utils.mjs.map +7 -0
  45. package/build-module/private-selectors.mjs.map +2 -2
  46. package/build-module/reducer.mjs +18 -10
  47. package/build-module/reducer.mjs.map +2 -2
  48. package/build-module/resolvers.mjs +7 -2
  49. package/build-module/resolvers.mjs.map +2 -2
  50. package/build-module/utils/clear-unchanged-edits.mjs +20 -0
  51. package/build-module/utils/clear-unchanged-edits.mjs.map +7 -0
  52. package/build-module/utils/crdt-blocks.mjs.map +1 -1
  53. package/build-module/utils/crdt-user-selections.mjs.map +1 -1
  54. package/build-module/utils/crdt-utils.mjs.map +1 -1
  55. package/build-module/utils/crdt.mjs.map +1 -1
  56. package/build-module/utils/index.mjs +22 -20
  57. package/build-module/utils/index.mjs.map +2 -2
  58. package/build-module/utils/set-nested-value.mjs.map +1 -1
  59. package/build-types/actions.d.ts.map +1 -1
  60. package/build-types/entities.d.ts.map +1 -1
  61. package/build-types/hooks/use-entity-record.d.ts +4 -1
  62. package/build-types/hooks/use-entity-record.d.ts.map +1 -1
  63. package/build-types/hooks/use-entity-records.d.ts +5 -1
  64. package/build-types/hooks/use-entity-records.d.ts.map +1 -1
  65. package/build-types/hooks/utils.d.ts +22 -0
  66. package/build-types/hooks/utils.d.ts.map +1 -0
  67. package/build-types/index.d.ts +8 -8
  68. package/build-types/private-actions.d.ts.map +1 -1
  69. package/build-types/private-selectors.d.ts +6 -0
  70. package/build-types/private-selectors.d.ts.map +1 -1
  71. package/build-types/reducer.d.ts.map +1 -1
  72. package/build-types/resolvers.d.ts +9 -4
  73. package/build-types/resolvers.d.ts.map +1 -1
  74. package/build-types/selectors.d.ts +8 -8
  75. package/build-types/selectors.d.ts.map +1 -1
  76. package/build-types/utils/clear-unchanged-edits.d.ts +12 -0
  77. package/build-types/utils/clear-unchanged-edits.d.ts.map +1 -0
  78. package/build-types/utils/index.d.ts +1 -0
  79. package/build-types/utils/index.d.ts.map +1 -1
  80. package/package.json +24 -19
  81. package/src/actions.js +2 -10
  82. package/src/entities.js +5 -0
  83. package/src/hooks/test/use-entity-record.js +5 -1
  84. package/src/hooks/use-entity-record.ts +26 -20
  85. package/src/hooks/use-entity-records.ts +26 -18
  86. package/src/hooks/use-query-select.ts +2 -23
  87. package/src/hooks/utils.ts +40 -0
  88. package/src/private-selectors.ts +6 -0
  89. package/src/reducer.js +22 -11
  90. package/src/resolvers.js +14 -4
  91. package/src/test/entities.js +51 -0
  92. package/src/utils/clear-unchanged-edits.ts +34 -0
  93. package/src/utils/index.js +1 -0
  94. package/src/utils/test/clear-unchanged-edits.js +42 -0
  95. package/build-types/utils/on-sub-key.d.ts +0 -4
  96. package/build-types/utils/on-sub-key.d.ts.map +0 -1
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/utils/crdt-user-selections.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 { CRDT_RECORD_MAP_KEY } from '../sync';\nimport type { YPostRecord } from './crdt';\nimport type { YBlock, YBlocks } from './crdt-blocks';\nimport {\n\tasRichTextOffset,\n\tgetRootMap,\n\tgetYTextByAttributeKey,\n\trichTextOffsetToHtmlIndex,\n} from './crdt-utils';\nimport type {\n\tAbsoluteBlockIndexPath,\n\tWPBlockSelection,\n\tSelectionState,\n\tSelectionNone,\n\tSelectionCursor,\n\tSelectionInOneBlock,\n\tSelectionInMultipleBlocks,\n\tSelectionWholeBlock,\n\tCursorPosition,\n} from '../types';\n\n/**\n * The type of selection.\n */\nexport enum SelectionType {\n\tNone = 'none',\n\tCursor = 'cursor',\n\tSelectionInOneBlock = 'selection-in-one-block',\n\tSelectionInMultipleBlocks = 'selection-in-multiple-blocks',\n\tWholeBlock = 'whole-block',\n}\n\n/**\n * The direction of a text selection, indicating where the caret sits.\n */\nexport enum SelectionDirection {\n\t/** The caret is at the end of the selection (default / left-to-right). */\n\tForward = 'f',\n\t/** The caret is at the start of the selection (right-to-left). */\n\tBackward = 'b',\n}\n\n/**\n * Converts WordPress block editor selection to a SelectionState.\n *\n * Uses getBlockPathForLocalClientId to locate blocks in the Yjs document by\n * their tree position (index path) rather than clientId, since clientIds may\n * differ between the block-editor store and the Yjs document (e.g. in \"Show\n * Template\" mode).\n *\n * @param selectionStart - The start position of the selection\n * @param selectionEnd - The end position of the selection\n * @param yDoc - The Yjs document\n * @param options - Optional parameters\n * @param options.selectionDirection - The direction of the selection (forward or backward)\n * @return The SelectionState\n */\nexport function getSelectionState(\n\tselectionStart: WPBlockSelection,\n\tselectionEnd: WPBlockSelection,\n\tyDoc: Y.Doc,\n\toptions?: { selectionDirection?: SelectionDirection }\n): SelectionState {\n\tconst { selectionDirection } = options ?? {};\n\tconst ymap = getRootMap< YPostRecord >( yDoc, CRDT_RECORD_MAP_KEY );\n\tconst yBlocks = ymap.get( 'blocks' );\n\n\tconst isSelectionEmpty = Object.keys( selectionStart ).length === 0;\n\tconst noSelection: SelectionNone = {\n\t\ttype: SelectionType.None,\n\t};\n\n\tif ( isSelectionEmpty || ! yBlocks ) {\n\t\t// Case 1: No selection, or no blocks in the document.\n\t\treturn noSelection;\n\t}\n\n\t// When the page initially loads, selectionStart can contain an empty object `{}`.\n\tconst isSelectionInOneBlock =\n\t\tselectionStart.clientId === selectionEnd.clientId;\n\tconst isCursorOnly =\n\t\tisSelectionInOneBlock && selectionStart.offset === selectionEnd.offset;\n\tconst isSelectionAWholeBlock =\n\t\tisSelectionInOneBlock &&\n\t\tselectionStart.offset === undefined &&\n\t\tselectionEnd.offset === undefined;\n\n\tif ( isSelectionAWholeBlock ) {\n\t\t// Case 2: A whole block is selected.\n\t\tconst path = getBlockPathForLocalClientId( selectionStart.clientId );\n\t\tconst blockPosition = path\n\t\t\t? createRelativePositionForBlockPath( path, yBlocks )\n\t\t\t: null;\n\n\t\tif ( ! blockPosition ) {\n\t\t\treturn noSelection;\n\t\t}\n\n\t\treturn {\n\t\t\ttype: SelectionType.WholeBlock,\n\t\t\tblockPosition,\n\t\t};\n\t} else if ( isCursorOnly ) {\n\t\t// Case 3: Cursor only, no text selected\n\t\tconst cursorPosition = getCursorPosition( selectionStart, yBlocks );\n\n\t\tif ( ! cursorPosition ) {\n\t\t\t// If we can't find the cursor position in block text, treat it as a non-selection.\n\t\t\treturn noSelection;\n\t\t}\n\n\t\treturn {\n\t\t\ttype: SelectionType.Cursor,\n\t\t\tcursorPosition,\n\t\t};\n\t} else if ( isSelectionInOneBlock ) {\n\t\t// Case 4: Selection in a single block\n\t\tconst cursorStartPosition = getCursorPosition(\n\t\t\tselectionStart,\n\t\t\tyBlocks\n\t\t);\n\t\tconst cursorEndPosition = getCursorPosition( selectionEnd, yBlocks );\n\n\t\tif ( ! cursorStartPosition || ! cursorEndPosition ) {\n\t\t\t// If we can't find the cursor positions in block text, treat it as a non-selection.\n\t\t\treturn noSelection;\n\t\t}\n\n\t\treturn {\n\t\t\ttype: SelectionType.SelectionInOneBlock,\n\t\t\tcursorStartPosition,\n\t\t\tcursorEndPosition,\n\t\t\tselectionDirection,\n\t\t};\n\t}\n\n\t// Case 5: Selection in multiple blocks\n\tconst cursorStartPosition = getCursorPosition( selectionStart, yBlocks );\n\tconst cursorEndPosition = getCursorPosition( selectionEnd, yBlocks );\n\tif ( ! cursorStartPosition || ! cursorEndPosition ) {\n\t\t// If we can't find the cursor positions in block text, treat it as a non-selection.\n\t\treturn noSelection;\n\t}\n\n\treturn {\n\t\ttype: SelectionType.SelectionInMultipleBlocks,\n\t\tcursorStartPosition,\n\t\tcursorEndPosition,\n\t\tselectionDirection,\n\t};\n}\n\n/**\n * Get the cursor position from a selection.\n *\n * @param selection - The selection.\n * @param blocks - The blocks to search through.\n * @return The cursor position, or null if not found.\n */\nfunction getCursorPosition(\n\tselection: WPBlockSelection,\n\tblocks: YBlocks\n): CursorPosition | null {\n\tconst path = getBlockPathForLocalClientId( selection.clientId );\n\tconst block = path ? findBlockByPath( path, blocks ) : null;\n\tif (\n\t\t! block ||\n\t\t! selection.attributeKey ||\n\t\tundefined === selection.offset\n\t) {\n\t\treturn null;\n\t}\n\n\tconst attributes = block.get( 'attributes' );\n\tconst currentYText = attributes\n\t\t? getYTextByAttributeKey( attributes, selection.attributeKey )\n\t\t: null;\n\n\t// If the attribute is not a Y.Text, return null.\n\tif ( ! ( currentYText instanceof Y.Text ) ) {\n\t\treturn null;\n\t}\n\n\tconst relativePosition = Y.createRelativePositionFromTypeIndex(\n\t\tcurrentYText,\n\t\trichTextOffsetToHtmlIndex(\n\t\t\tcurrentYText.toString(),\n\t\t\tasRichTextOffset( selection.offset )\n\t\t)\n\t);\n\n\treturn {\n\t\trelativePosition,\n\t\tabsoluteOffset: selection.offset,\n\t\tattributeKey: selection.attributeKey,\n\t};\n}\n\n/**\n * Resolves a local block-editor clientId to its index path relative to the\n * post content blocks. This allows finding the corresponding block in the Yjs\n * document even when clientIds differ (e.g. in \"Show Template\" mode where\n * blocks are cloned).\n *\n * In template mode, the block tree includes template parts and wrapper blocks\n * around a core/post-content block. The Yjs document only contains the post\n * content blocks, so we stop the upward walk when the parent is\n * core/post-content (its inner blocks correspond to the Yjs root blocks).\n *\n * @param clientId - The local block-editor clientId to resolve.\n * @return The index path from root, or null if not resolvable.\n */\nexport function getBlockPathForLocalClientId(\n\tclientId: string\n): AbsoluteBlockIndexPath | null {\n\tconst { getBlockIndex, getBlockRootClientId, getBlockName } =\n\t\tselect( blockEditorStore );\n\n\tconst path: AbsoluteBlockIndexPath = [];\n\tlet current: string | null = clientId;\n\twhile ( current ) {\n\t\tconst index = getBlockIndex( current );\n\t\tif ( index === -1 ) {\n\t\t\treturn null;\n\t\t}\n\t\tpath.unshift( index );\n\t\tconst parent = getBlockRootClientId( current );\n\t\tif ( ! parent ) {\n\t\t\tbreak;\n\t\t}\n\t\t// If the parent is core/post-content, stop here \u2014 the Yjs doc\n\t\t// root blocks correspond to post-content's inner blocks.\n\t\tconst parentName = getBlockName( parent );\n\t\tif ( parentName === 'core/post-content' ) {\n\t\t\tbreak;\n\t\t}\n\t\tcurrent = parent;\n\t}\n\treturn path.length > 0 ? path : null;\n}\n\n/**\n * Find a block by navigating a tree index path in the Yjs block hierarchy.\n *\n * @param path - The index path, e.g. [0, 1] for blocks[0].innerBlocks[1].\n * @param blocks - The root-level Yjs blocks array.\n * @return The block Y.Map if found, null otherwise.\n */\nfunction findBlockByPath(\n\tpath: AbsoluteBlockIndexPath,\n\tblocks: YBlocks\n): YBlock | null {\n\tlet currentBlocks = blocks;\n\tfor ( let i = 0; i < path.length; i++ ) {\n\t\tif ( path[ i ] >= currentBlocks.length ) {\n\t\t\treturn null;\n\t\t}\n\t\tconst block = currentBlocks.get( 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;\n\t\t}\n\t\tcurrentBlocks =\n\t\t\tblock.get( 'innerBlocks' ) ?? ( new Y.Array() as YBlocks );\n\t}\n\treturn null;\n}\n\n/**\n * Create a Y.RelativePosition for a block by navigating a tree index path.\n *\n * @param path - The index path, e.g. [0, 1] for blocks[0].innerBlocks[1].\n * @param blocks - The root-level Yjs blocks array.\n * @return A Y.RelativePosition for the block, or null if the path is invalid.\n */\nfunction createRelativePositionForBlockPath(\n\tpath: AbsoluteBlockIndexPath,\n\tblocks: YBlocks\n): Y.RelativePosition | null {\n\tlet currentBlocks = blocks;\n\tfor ( let i = 0; i < path.length; i++ ) {\n\t\tif ( path[ i ] >= currentBlocks.length ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( i === path.length - 1 ) {\n\t\t\treturn Y.createRelativePositionFromTypeIndex(\n\t\t\t\tcurrentBlocks,\n\t\t\t\tpath[ i ]\n\t\t\t);\n\t\t}\n\t\tconst block = currentBlocks.get( path[ i ] );\n\t\tcurrentBlocks =\n\t\t\tblock?.get( 'innerBlocks' ) ?? ( new Y.Array() as YBlocks );\n\t}\n\treturn null;\n}\n\n/**\n * Check if two selection states are equal.\n *\n * @param selection1 - The first selection state.\n * @param selection2 - The second selection state.\n * @return True if the selection states are equal, false otherwise.\n */\nexport function areSelectionsStatesEqual(\n\tselection1: SelectionState,\n\tselection2: SelectionState\n): boolean {\n\tif ( selection1.type !== selection2.type ) {\n\t\treturn false;\n\t}\n\n\tswitch ( selection1.type ) {\n\t\tcase SelectionType.None:\n\t\t\treturn true;\n\n\t\tcase SelectionType.Cursor:\n\t\t\treturn areCursorPositionsEqual(\n\t\t\t\tselection1.cursorPosition,\n\t\t\t\t( selection2 as SelectionCursor ).cursorPosition\n\t\t\t);\n\n\t\tcase SelectionType.SelectionInOneBlock:\n\t\t\treturn (\n\t\t\t\tareCursorPositionsEqual(\n\t\t\t\t\tselection1.cursorStartPosition,\n\t\t\t\t\t( selection2 as SelectionInOneBlock ).cursorStartPosition\n\t\t\t\t) &&\n\t\t\t\tareCursorPositionsEqual(\n\t\t\t\t\tselection1.cursorEndPosition,\n\t\t\t\t\t( selection2 as SelectionInOneBlock ).cursorEndPosition\n\t\t\t\t) &&\n\t\t\t\tselection1.selectionDirection ===\n\t\t\t\t\t( selection2 as SelectionInOneBlock ).selectionDirection\n\t\t\t);\n\n\t\tcase SelectionType.SelectionInMultipleBlocks:\n\t\t\treturn (\n\t\t\t\tareCursorPositionsEqual(\n\t\t\t\t\tselection1.cursorStartPosition,\n\t\t\t\t\t( selection2 as SelectionInMultipleBlocks )\n\t\t\t\t\t\t.cursorStartPosition\n\t\t\t\t) &&\n\t\t\t\tareCursorPositionsEqual(\n\t\t\t\t\tselection1.cursorEndPosition,\n\t\t\t\t\t( selection2 as SelectionInMultipleBlocks )\n\t\t\t\t\t\t.cursorEndPosition\n\t\t\t\t) &&\n\t\t\t\tselection1.selectionDirection ===\n\t\t\t\t\t( selection2 as SelectionInMultipleBlocks )\n\t\t\t\t\t\t.selectionDirection\n\t\t\t);\n\t\tcase SelectionType.WholeBlock:\n\t\t\treturn Y.compareRelativePositions(\n\t\t\t\tselection1.blockPosition,\n\t\t\t\t( selection2 as SelectionWholeBlock ).blockPosition\n\t\t\t);\n\n\t\tdefault:\n\t\t\treturn false;\n\t}\n}\n\n/**\n * Check if two cursor positions are equal.\n *\n * @param cursorPosition1 - The first cursor position.\n * @param cursorPosition2 - The second cursor position.\n * @return True if the cursor positions are equal, false otherwise.\n */\nfunction areCursorPositionsEqual(\n\tcursorPosition1: CursorPosition,\n\tcursorPosition2: CursorPosition\n): boolean {\n\tconst isRelativePositionEqual = Y.compareRelativePositions(\n\t\tcursorPosition1.relativePosition,\n\t\tcursorPosition2.relativePosition\n\t);\n\n\t// Ensure a change in calculated absolute offset results in a treating the cursor as modified.\n\t// This is necessary because Y.Text relative positions can remain the same after text changes.\n\tconst isAbsoluteOffsetEqual =\n\t\tcursorPosition1.absoluteOffset === cursorPosition2.absoluteOffset;\n\n\treturn isRelativePositionEqual && isAbsoluteOffsetEqual;\n}\n"],
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 { CRDT_RECORD_MAP_KEY } from '../sync';\nimport type { YPostRecord } from './crdt';\nimport type { YBlock, YBlocks } from './crdt-blocks';\nimport {\n\tasRichTextOffset,\n\tgetRootMap,\n\tgetYTextByAttributeKey,\n\trichTextOffsetToHtmlIndex,\n} from './crdt-utils';\nimport type {\n\tAbsoluteBlockIndexPath,\n\tWPBlockSelection,\n\tSelectionState,\n\tSelectionNone,\n\tSelectionCursor,\n\tSelectionInOneBlock,\n\tSelectionInMultipleBlocks,\n\tSelectionWholeBlock,\n\tCursorPosition,\n} from '../types';\n\n/**\n * The type of selection.\n */\nexport enum SelectionType {\n\tNone = 'none',\n\tCursor = 'cursor',\n\tSelectionInOneBlock = 'selection-in-one-block',\n\tSelectionInMultipleBlocks = 'selection-in-multiple-blocks',\n\tWholeBlock = 'whole-block',\n}\n\n/**\n * The direction of a text selection, indicating where the caret sits.\n */\nexport enum SelectionDirection {\n\t/** The caret is at the end of the selection (default / left-to-right). */\n\tForward = 'f',\n\t/** The caret is at the start of the selection (right-to-left). */\n\tBackward = 'b',\n}\n\n/**\n * Converts WordPress block editor selection to a SelectionState.\n *\n * Uses getBlockPathForLocalClientId to locate blocks in the Yjs document by\n * their tree position (index path) rather than clientId, since clientIds may\n * differ between the block-editor store and the Yjs document (e.g. in \"Show\n * Template\" mode).\n *\n * @param selectionStart - The start position of the selection\n * @param selectionEnd - The end position of the selection\n * @param yDoc - The Yjs document\n * @param options - Optional parameters\n * @param options.selectionDirection - The direction of the selection (forward or backward)\n * @return The SelectionState\n */\nexport function getSelectionState(\n\tselectionStart: WPBlockSelection,\n\tselectionEnd: WPBlockSelection,\n\tyDoc: Y.Doc,\n\toptions?: { selectionDirection?: SelectionDirection }\n): SelectionState {\n\tconst { selectionDirection } = options ?? {};\n\tconst ymap = getRootMap< YPostRecord >( yDoc, CRDT_RECORD_MAP_KEY );\n\tconst yBlocks = ymap.get( 'blocks' );\n\n\tconst isSelectionEmpty = Object.keys( selectionStart ).length === 0;\n\tconst noSelection: SelectionNone = {\n\t\ttype: SelectionType.None,\n\t};\n\n\tif ( isSelectionEmpty || ! yBlocks ) {\n\t\t// Case 1: No selection, or no blocks in the document.\n\t\treturn noSelection;\n\t}\n\n\t// When the page initially loads, selectionStart can contain an empty object `{}`.\n\tconst isSelectionInOneBlock =\n\t\tselectionStart.clientId === selectionEnd.clientId;\n\tconst isCursorOnly =\n\t\tisSelectionInOneBlock && selectionStart.offset === selectionEnd.offset;\n\tconst isSelectionAWholeBlock =\n\t\tisSelectionInOneBlock &&\n\t\tselectionStart.offset === undefined &&\n\t\tselectionEnd.offset === undefined;\n\n\tif ( isSelectionAWholeBlock ) {\n\t\t// Case 2: A whole block is selected.\n\t\tconst path = getBlockPathForLocalClientId( selectionStart.clientId );\n\t\tconst blockPosition = path\n\t\t\t? createRelativePositionForBlockPath( path, yBlocks )\n\t\t\t: null;\n\n\t\tif ( ! blockPosition ) {\n\t\t\treturn noSelection;\n\t\t}\n\n\t\treturn {\n\t\t\ttype: SelectionType.WholeBlock,\n\t\t\tblockPosition,\n\t\t};\n\t} else if ( isCursorOnly ) {\n\t\t// Case 3: Cursor only, no text selected\n\t\tconst cursorPosition = getCursorPosition( selectionStart, yBlocks );\n\n\t\tif ( ! cursorPosition ) {\n\t\t\t// If we can't find the cursor position in block text, treat it as a non-selection.\n\t\t\treturn noSelection;\n\t\t}\n\n\t\treturn {\n\t\t\ttype: SelectionType.Cursor,\n\t\t\tcursorPosition,\n\t\t};\n\t} else if ( isSelectionInOneBlock ) {\n\t\t// Case 4: Selection in a single block\n\t\tconst cursorStartPosition = getCursorPosition(\n\t\t\tselectionStart,\n\t\t\tyBlocks\n\t\t);\n\t\tconst cursorEndPosition = getCursorPosition( selectionEnd, yBlocks );\n\n\t\tif ( ! cursorStartPosition || ! cursorEndPosition ) {\n\t\t\t// If we can't find the cursor positions in block text, treat it as a non-selection.\n\t\t\treturn noSelection;\n\t\t}\n\n\t\treturn {\n\t\t\ttype: SelectionType.SelectionInOneBlock,\n\t\t\tcursorStartPosition,\n\t\t\tcursorEndPosition,\n\t\t\tselectionDirection,\n\t\t};\n\t}\n\n\t// Case 5: Selection in multiple blocks\n\tconst cursorStartPosition = getCursorPosition( selectionStart, yBlocks );\n\tconst cursorEndPosition = getCursorPosition( selectionEnd, yBlocks );\n\tif ( ! cursorStartPosition || ! cursorEndPosition ) {\n\t\t// If we can't find the cursor positions in block text, treat it as a non-selection.\n\t\treturn noSelection;\n\t}\n\n\treturn {\n\t\ttype: SelectionType.SelectionInMultipleBlocks,\n\t\tcursorStartPosition,\n\t\tcursorEndPosition,\n\t\tselectionDirection,\n\t};\n}\n\n/**\n * Get the cursor position from a selection.\n *\n * @param selection - The selection.\n * @param blocks - The blocks to search through.\n * @return The cursor position, or null if not found.\n */\nfunction getCursorPosition(\n\tselection: WPBlockSelection,\n\tblocks: YBlocks\n): CursorPosition | null {\n\tconst path = getBlockPathForLocalClientId( selection.clientId );\n\tconst block = path ? findBlockByPath( path, blocks ) : null;\n\tif (\n\t\t! block ||\n\t\t! selection.attributeKey ||\n\t\tundefined === selection.offset\n\t) {\n\t\treturn null;\n\t}\n\n\tconst attributes = block.get( 'attributes' );\n\tconst currentYText = attributes\n\t\t? getYTextByAttributeKey( attributes, selection.attributeKey )\n\t\t: null;\n\n\t// If the attribute is not a Y.Text, return null.\n\tif ( ! ( currentYText instanceof Y.Text ) ) {\n\t\treturn null;\n\t}\n\n\tconst relativePosition = Y.createRelativePositionFromTypeIndex(\n\t\tcurrentYText,\n\t\trichTextOffsetToHtmlIndex(\n\t\t\tcurrentYText.toString(),\n\t\t\tasRichTextOffset( selection.offset )\n\t\t)\n\t);\n\n\treturn {\n\t\trelativePosition,\n\t\tabsoluteOffset: selection.offset,\n\t\tattributeKey: selection.attributeKey,\n\t};\n}\n\n/**\n * Resolves a local block-editor clientId to its index path relative to the\n * post content blocks. This allows finding the corresponding block in the Yjs\n * document even when clientIds differ (e.g. in \"Show Template\" mode where\n * blocks are cloned).\n *\n * In template mode, the block tree includes template parts and wrapper blocks\n * around a core/post-content block. The Yjs document only contains the post\n * content blocks, so we stop the upward walk when the parent is\n * core/post-content (its inner blocks correspond to the Yjs root blocks).\n *\n * @param clientId - The local block-editor clientId to resolve.\n * @return The index path from root, or null if not resolvable.\n */\nexport function getBlockPathForLocalClientId(\n\tclientId: string\n): AbsoluteBlockIndexPath | null {\n\tconst { getBlockIndex, getBlockRootClientId, getBlockName } =\n\t\tselect( blockEditorStore );\n\n\tconst path: AbsoluteBlockIndexPath = [];\n\tlet current: string | null = clientId;\n\twhile ( current ) {\n\t\tconst index = getBlockIndex( current );\n\t\tif ( index === -1 ) {\n\t\t\treturn null;\n\t\t}\n\t\tpath.unshift( index );\n\t\tconst parent = getBlockRootClientId( current );\n\t\tif ( ! parent ) {\n\t\t\tbreak;\n\t\t}\n\t\t// If the parent is core/post-content, stop here — the Yjs doc\n\t\t// root blocks correspond to post-content's inner blocks.\n\t\tconst parentName = getBlockName( parent );\n\t\tif ( parentName === 'core/post-content' ) {\n\t\t\tbreak;\n\t\t}\n\t\tcurrent = parent;\n\t}\n\treturn path.length > 0 ? path : null;\n}\n\n/**\n * Find a block by navigating a tree index path in the Yjs block hierarchy.\n *\n * @param path - The index path, e.g. [0, 1] for blocks[0].innerBlocks[1].\n * @param blocks - The root-level Yjs blocks array.\n * @return The block Y.Map if found, null otherwise.\n */\nfunction findBlockByPath(\n\tpath: AbsoluteBlockIndexPath,\n\tblocks: YBlocks\n): YBlock | null {\n\tlet currentBlocks = blocks;\n\tfor ( let i = 0; i < path.length; i++ ) {\n\t\tif ( path[ i ] >= currentBlocks.length ) {\n\t\t\treturn null;\n\t\t}\n\t\tconst block = currentBlocks.get( 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;\n\t\t}\n\t\tcurrentBlocks =\n\t\t\tblock.get( 'innerBlocks' ) ?? ( new Y.Array() as YBlocks );\n\t}\n\treturn null;\n}\n\n/**\n * Create a Y.RelativePosition for a block by navigating a tree index path.\n *\n * @param path - The index path, e.g. [0, 1] for blocks[0].innerBlocks[1].\n * @param blocks - The root-level Yjs blocks array.\n * @return A Y.RelativePosition for the block, or null if the path is invalid.\n */\nfunction createRelativePositionForBlockPath(\n\tpath: AbsoluteBlockIndexPath,\n\tblocks: YBlocks\n): Y.RelativePosition | null {\n\tlet currentBlocks = blocks;\n\tfor ( let i = 0; i < path.length; i++ ) {\n\t\tif ( path[ i ] >= currentBlocks.length ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( i === path.length - 1 ) {\n\t\t\treturn Y.createRelativePositionFromTypeIndex(\n\t\t\t\tcurrentBlocks,\n\t\t\t\tpath[ i ]\n\t\t\t);\n\t\t}\n\t\tconst block = currentBlocks.get( path[ i ] );\n\t\tcurrentBlocks =\n\t\t\tblock?.get( 'innerBlocks' ) ?? ( new Y.Array() as YBlocks );\n\t}\n\treturn null;\n}\n\n/**\n * Check if two selection states are equal.\n *\n * @param selection1 - The first selection state.\n * @param selection2 - The second selection state.\n * @return True if the selection states are equal, false otherwise.\n */\nexport function areSelectionsStatesEqual(\n\tselection1: SelectionState,\n\tselection2: SelectionState\n): boolean {\n\tif ( selection1.type !== selection2.type ) {\n\t\treturn false;\n\t}\n\n\tswitch ( selection1.type ) {\n\t\tcase SelectionType.None:\n\t\t\treturn true;\n\n\t\tcase SelectionType.Cursor:\n\t\t\treturn areCursorPositionsEqual(\n\t\t\t\tselection1.cursorPosition,\n\t\t\t\t( selection2 as SelectionCursor ).cursorPosition\n\t\t\t);\n\n\t\tcase SelectionType.SelectionInOneBlock:\n\t\t\treturn (\n\t\t\t\tareCursorPositionsEqual(\n\t\t\t\t\tselection1.cursorStartPosition,\n\t\t\t\t\t( selection2 as SelectionInOneBlock ).cursorStartPosition\n\t\t\t\t) &&\n\t\t\t\tareCursorPositionsEqual(\n\t\t\t\t\tselection1.cursorEndPosition,\n\t\t\t\t\t( selection2 as SelectionInOneBlock ).cursorEndPosition\n\t\t\t\t) &&\n\t\t\t\tselection1.selectionDirection ===\n\t\t\t\t\t( selection2 as SelectionInOneBlock ).selectionDirection\n\t\t\t);\n\n\t\tcase SelectionType.SelectionInMultipleBlocks:\n\t\t\treturn (\n\t\t\t\tareCursorPositionsEqual(\n\t\t\t\t\tselection1.cursorStartPosition,\n\t\t\t\t\t( selection2 as SelectionInMultipleBlocks )\n\t\t\t\t\t\t.cursorStartPosition\n\t\t\t\t) &&\n\t\t\t\tareCursorPositionsEqual(\n\t\t\t\t\tselection1.cursorEndPosition,\n\t\t\t\t\t( selection2 as SelectionInMultipleBlocks )\n\t\t\t\t\t\t.cursorEndPosition\n\t\t\t\t) &&\n\t\t\t\tselection1.selectionDirection ===\n\t\t\t\t\t( selection2 as SelectionInMultipleBlocks )\n\t\t\t\t\t\t.selectionDirection\n\t\t\t);\n\t\tcase SelectionType.WholeBlock:\n\t\t\treturn Y.compareRelativePositions(\n\t\t\t\tselection1.blockPosition,\n\t\t\t\t( selection2 as SelectionWholeBlock ).blockPosition\n\t\t\t);\n\n\t\tdefault:\n\t\t\treturn false;\n\t}\n}\n\n/**\n * Check if two cursor positions are equal.\n *\n * @param cursorPosition1 - The first cursor position.\n * @param cursorPosition2 - The second cursor position.\n * @return True if the cursor positions are equal, false otherwise.\n */\nfunction areCursorPositionsEqual(\n\tcursorPosition1: CursorPosition,\n\tcursorPosition2: CursorPosition\n): boolean {\n\tconst isRelativePositionEqual = Y.compareRelativePositions(\n\t\tcursorPosition1.relativePosition,\n\t\tcursorPosition2.relativePosition\n\t);\n\n\t// Ensure a change in calculated absolute offset results in a treating the cursor as modified.\n\t// This is necessary because Y.Text relative positions can remain the same after text changes.\n\tconst isAbsoluteOffsetEqual =\n\t\tcursorPosition1.absoluteOffset === cursorPosition2.absoluteOffset;\n\n\treturn isRelativePositionEqual && isAbsoluteOffsetEqual;\n}\n"],
5
5
  "mappings": ";AAGA,SAAS,cAAc;AACvB,SAAS,SAAS;AAElB,SAAS,SAAS,wBAAwB;AAK1C,SAAS,2BAA2B;AAGpC;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAgBA,IAAK,gBAAL,kBAAKA,mBAAL;AACN,EAAAA,eAAA,UAAO;AACP,EAAAA,eAAA,YAAS;AACT,EAAAA,eAAA,yBAAsB;AACtB,EAAAA,eAAA,+BAA4B;AAC5B,EAAAA,eAAA,gBAAa;AALF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ACR,WAAoC;AAAA,IAGzC,KAAK;AACJ,aACC;AAAA,QACC,WAAW;AAAA,QACT,WACA;AAAA,MACH,KACA;AAAA,QACC,WAAW;AAAA,QACT,WACA;AAAA,MACH,KACA,WAAW,uBACR,WACA;AAAA,IAEL,KAAK;AACJ,aAAO,EAAE;AAAA,QACR,WAAW;AAAA,QACT,WAAoC;AAAA,MACvC;AAAA,IAED;AACC,aAAO;AAAA,EACT;AACD;AASA,SAAS,wBACR,iBACA,iBACU;AACV,QAAM,0BAA0B,EAAE;AAAA,IACjC,gBAAgB;AAAA,IAChB,gBAAgB;AAAA,EACjB;AAIA,QAAM,wBACL,gBAAgB,mBAAmB,gBAAgB;AAEpD,SAAO,2BAA2B;AACnC;",
6
6
  "names": ["SelectionType", "SelectionDirection", "cursorStartPosition", "cursorEndPosition"]
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/utils/crdt-utils.ts"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { Y } from '@wordpress/sync';\nimport { create, insert, toHTMLString } from '@wordpress/rich-text';\n\n/**\n * Internal dependencies\n */\nimport type { YBlock, YBlocks } from './crdt-blocks';\nimport type { YPostRecord } from './crdt';\nimport { CRDT_RECORD_MAP_KEY } from '../sync';\n\n/**\n * A YMapRecord represents the shape of the data stored in a Y.Map.\n */\nexport type YMapRecord = Record< string, unknown >;\n\n/**\n * A wrapper around Y.Map to provide type safety. The generic type accepted by\n * Y.Map represents the union of possible values of the map, which are varied in\n * many cases. This type is accurate, but its non-specificity requires aggressive\n * type narrowing or type casting / destruction with `as`.\n *\n * This type provides type enhancements so that the correct value type can be\n * inferred based on the provided key. It is just a type wrap / overlay, and\n * does not change the runtime behavior of Y.Map.\n *\n * This interface cannot extend Y.Map directly due to the limitations of\n * TypeScript's structural typing. One negative consequence of this is that\n * `instanceof` checks against Y.Map continue to work at runtime but will blur\n * the type at compile time. To navigate this, use the `isYMap` function below.\n */\nexport interface YMapWrap< T extends YMapRecord > extends Y.AbstractType< T > {\n\tdelete: < K extends keyof T >( key: K ) => void;\n\tforEach: (\n\t\tcallback: (\n\t\t\tvalue: T[ keyof T ],\n\t\t\tkey: keyof T,\n\t\t\tmap: YMapWrap< T >\n\t\t) => void\n\t) => void;\n\thas: < K extends keyof T >( key: K ) => boolean;\n\tget: < K extends keyof T >( key: K ) => T[ K ] | undefined;\n\tset: < K extends keyof T >( key: K, value: T[ K ] ) => void;\n\ttoJSON: () => T;\n\t// add types for other Y.Map methods as needed\n}\n\n/**\n * Get or create a root-level Map for the given Y.Doc. Use this instead of\n * doc.getMap() for additional type safety.\n *\n * @param doc Y.Doc\n * @param key Map key\n */\nexport function getRootMap< T extends YMapRecord >(\n\tdoc: Y.Doc,\n\tkey: string\n): YMapWrap< T > {\n\treturn doc.getMap< T >( key ) as unknown as YMapWrap< T >;\n}\n\n/**\n * Create a new Y.Map (provided with YMapWrap type), optionally initialized with\n * data. Use this instead of `new Y.Map()` for additional type safety.\n *\n * @param partial Partial data to initialize the map with.\n */\nexport function createYMap< T extends YMapRecord >(\n\tpartial: Partial< T > = {}\n): YMapWrap< T > {\n\treturn new Y.Map( Object.entries( partial ) ) as unknown as YMapWrap< T >;\n}\n\n/**\n * Type guard to check if a value is a Y.Map without losing type information.\n *\n * @param value Value to check.\n */\nexport function isYMap< T extends YMapRecord >(\n\tvalue: YMapWrap< T > | undefined\n): value is YMapWrap< T > {\n\treturn value instanceof Y.Map;\n}\n\ndeclare const richTextOffsetBrand: unique symbol;\ndeclare const htmlStringIndexBrand: unique symbol;\n\n/**\n * Branded type to prevent confusion between HTML string indices and RichText offsets.\n *\n * @see asRichTextOffset()\n */\nexport type RichTextOffset = number & {\n\treadonly [ richTextOffsetBrand ]: 'RichTextOffset';\n};\n\n/**\n * Branded type to prevent confusion between HTML string indices and RichText offsets.\n *\n * @see asHtmlStringIndex()\n */\nexport type HtmlStringIndex = number & {\n\treadonly [ htmlStringIndexBrand ]: 'HtmlStringIndex';\n};\n\n/**\n * Brand a number as an offset into a RichText\u2019s text content.\n *\n * @param offset The rich-text offset to brand.\n * @return The branded rich-text offset.\n */\nexport function asRichTextOffset( offset: number ): RichTextOffset {\n\treturn offset as RichTextOffset;\n}\n\n/**\n * Brand a number as a string index into serialized HTML.\n *\n * @param index The HTML string index to brand.\n * @return The branded HTML string index.\n */\nexport function asHtmlStringIndex( index: number ): HtmlStringIndex {\n\treturn index as HtmlStringIndex;\n}\n\n/**\n * Resolve a selection attribute key to a Y.Text value.\n *\n * RichText identifiers are normally top-level block attribute keys, but nested\n * rich-text fields can provide a dot path such as `body.0.cells.0.content`.\n *\n * @param attributes The block attributes map.\n * @param attributeKey The top-level attribute key or nested attribute path.\n * @return The matching Y.Text, or null if the path is not a rich-text field.\n */\nexport function getYTextByAttributeKey(\n\tattributes: Y.Map< unknown >,\n\tattributeKey: string\n): Y.Text | null {\n\tconst directValue = attributes.get( attributeKey );\n\tif ( directValue instanceof Y.Text ) {\n\t\treturn directValue;\n\t}\n\n\tlet value: unknown = attributes;\n\tfor ( const pathPart of attributeKey.split( '.' ) ) {\n\t\tif ( value instanceof Y.Map ) {\n\t\t\tvalue = value.get( pathPart );\n\t\t} else if ( value instanceof Y.Array ) {\n\t\t\tconst index = Number.parseInt( pathPart, 10 );\n\t\t\tif (\n\t\t\t\t! Number.isSafeInteger( index ) ||\n\t\t\t\tindex < 0 ||\n\t\t\t\tindex.toString() !== pathPart\n\t\t\t) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tvalue = value.get( index );\n\t\t} else {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\treturn value instanceof Y.Text ? value : null;\n}\n\n/**\n * Given a block ID and a Y.Doc, find the block in the document.\n *\n * @param blockId The block ID to find\n * @param ydoc The Y.Doc to find the block in\n * @return The block, or null if the block is not found\n */\nexport function findBlockByClientIdInDoc(\n\tblockId: string,\n\tydoc: Y.Doc\n): YBlock | null {\n\tconst ymap = getRootMap< YPostRecord >( ydoc, CRDT_RECORD_MAP_KEY );\n\tconst blocks = ymap.get( 'blocks' );\n\n\tif ( ! ( blocks instanceof Y.Array ) ) {\n\t\treturn null;\n\t}\n\n\treturn findBlockByClientIdInBlocks( blockId, blocks );\n}\n\n// Marker for insertion.\nconst MARKER_START = 0xe000;\n\n/**\n * Pick a marker character that does not appear in `text`. Returns the marker\n * or `null` if all candidates are present (extremely unlikely in practice).\n *\n * @param text The string to check for existing marker characters.\n */\nfunction pickMarker( text: string ): string | null {\n\tconst tryCount = 0x10;\n\n\t// Scan the unicode private use area for the first code point not present\n\t// in the text.\n\tfor ( let code = MARKER_START; code < MARKER_START + tryCount; code++ ) {\n\t\tconst candidate = String.fromCharCode( code );\n\n\t\tif ( ! text.includes( candidate ) ) {\n\t\t\treturn candidate;\n\t\t}\n\t}\n\n\treturn null;\n}\n\n/**\n * Convert an HTML character index (counting tag characters) to a rich-text\n * offset (counting only text characters). Used on read paths where Y.Text\n * resolves to an HTML index but the block editor expects a text offset.\n *\n * @param html The full HTML string from Y.Text.\n * @param htmlIndex The HTML character index.\n * @return The corresponding rich-text offset.\n */\nexport function htmlIndexToRichTextOffset(\n\thtml: string,\n\thtmlIndex: HtmlStringIndex\n): RichTextOffset {\n\tif ( ! html.includes( '<' ) && ! html.includes( '&' ) ) {\n\t\treturn asRichTextOffset( htmlIndex );\n\t}\n\n\tconst marker = pickMarker( html );\n\tif ( ! marker ) {\n\t\treturn asRichTextOffset( htmlIndex );\n\t}\n\n\t// Insert marker and let create() do the parsing.\n\tconst withMarker =\n\t\thtml.slice( 0, htmlIndex ) + marker + html.slice( htmlIndex );\n\tconst value = create( { html: withMarker } );\n\tconst markerPos = value.text.indexOf( marker );\n\n\treturn asRichTextOffset( markerPos === -1 ? htmlIndex : markerPos );\n}\n\n/**\n * Convert a rich-text offset (counting only text characters) to an HTML\n * character index (counting tag characters). Used on write paths where the\n * block editor provides a text offset but Y.Text expects an HTML index.\n *\n * @param html The full HTML string from Y.Text.\n * @param richTextOffset The rich-text text offset.\n * @return The corresponding HTML character index.\n */\nexport function richTextOffsetToHtmlIndex(\n\thtml: string,\n\trichTextOffset: RichTextOffset\n): HtmlStringIndex {\n\tif ( ! html.includes( '<' ) && ! html.includes( '&' ) ) {\n\t\treturn asHtmlStringIndex( richTextOffset );\n\t}\n\n\tconst marker = pickMarker( html );\n\tif ( ! marker ) {\n\t\treturn asHtmlStringIndex( richTextOffset );\n\t}\n\n\tconst value = create( { html } );\n\tconst markerValue = create( { text: marker } );\n\t// The marker must inherit the formatting at the insertion point so that\n\t// toHTMLString does not split surrounding tags (e.g. <strong>) around it.\n\tif ( value.formats[ richTextOffset ] ) {\n\t\tmarkerValue.formats[ 0 ] = value.formats[ richTextOffset ];\n\t}\n\n\tconst withMarker = insert(\n\t\tvalue,\n\t\tmarkerValue,\n\t\trichTextOffset,\n\t\trichTextOffset\n\t);\n\n\tconst htmlWithMarker = toHTMLString( { value: withMarker } );\n\tconst markerIndex = htmlWithMarker.indexOf( marker );\n\treturn asHtmlStringIndex(\n\t\tmarkerIndex === -1 ? richTextOffset : markerIndex\n\t);\n}\n\nfunction findBlockByClientIdInBlocks(\n\tblockId: string,\n\tblocks: YBlocks\n): YBlock | null {\n\tfor ( const block of blocks ) {\n\t\tif ( block.get( 'clientId' ) === blockId ) {\n\t\t\treturn block;\n\t\t}\n\n\t\tconst innerBlocks = block.get( 'innerBlocks' );\n\n\t\tif ( innerBlocks && innerBlocks.length > 0 ) {\n\t\t\tconst innerBlock = findBlockByClientIdInBlocks(\n\t\t\t\tblockId,\n\t\t\t\tinnerBlocks\n\t\t\t);\n\n\t\t\tif ( innerBlock ) {\n\t\t\t\treturn innerBlock;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn null;\n}\n"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { Y } from '@wordpress/sync';\nimport { create, insert, toHTMLString } from '@wordpress/rich-text';\n\n/**\n * Internal dependencies\n */\nimport type { YBlock, YBlocks } from './crdt-blocks';\nimport type { YPostRecord } from './crdt';\nimport { CRDT_RECORD_MAP_KEY } from '../sync';\n\n/**\n * A YMapRecord represents the shape of the data stored in a Y.Map.\n */\nexport type YMapRecord = Record< string, unknown >;\n\n/**\n * A wrapper around Y.Map to provide type safety. The generic type accepted by\n * Y.Map represents the union of possible values of the map, which are varied in\n * many cases. This type is accurate, but its non-specificity requires aggressive\n * type narrowing or type casting / destruction with `as`.\n *\n * This type provides type enhancements so that the correct value type can be\n * inferred based on the provided key. It is just a type wrap / overlay, and\n * does not change the runtime behavior of Y.Map.\n *\n * This interface cannot extend Y.Map directly due to the limitations of\n * TypeScript's structural typing. One negative consequence of this is that\n * `instanceof` checks against Y.Map continue to work at runtime but will blur\n * the type at compile time. To navigate this, use the `isYMap` function below.\n */\nexport interface YMapWrap< T extends YMapRecord > extends Y.AbstractType< T > {\n\tdelete: < K extends keyof T >( key: K ) => void;\n\tforEach: (\n\t\tcallback: (\n\t\t\tvalue: T[ keyof T ],\n\t\t\tkey: keyof T,\n\t\t\tmap: YMapWrap< T >\n\t\t) => void\n\t) => void;\n\thas: < K extends keyof T >( key: K ) => boolean;\n\tget: < K extends keyof T >( key: K ) => T[ K ] | undefined;\n\tset: < K extends keyof T >( key: K, value: T[ K ] ) => void;\n\ttoJSON: () => T;\n\t// add types for other Y.Map methods as needed\n}\n\n/**\n * Get or create a root-level Map for the given Y.Doc. Use this instead of\n * doc.getMap() for additional type safety.\n *\n * @param doc Y.Doc\n * @param key Map key\n */\nexport function getRootMap< T extends YMapRecord >(\n\tdoc: Y.Doc,\n\tkey: string\n): YMapWrap< T > {\n\treturn doc.getMap< T >( key ) as unknown as YMapWrap< T >;\n}\n\n/**\n * Create a new Y.Map (provided with YMapWrap type), optionally initialized with\n * data. Use this instead of `new Y.Map()` for additional type safety.\n *\n * @param partial Partial data to initialize the map with.\n */\nexport function createYMap< T extends YMapRecord >(\n\tpartial: Partial< T > = {}\n): YMapWrap< T > {\n\treturn new Y.Map( Object.entries( partial ) ) as unknown as YMapWrap< T >;\n}\n\n/**\n * Type guard to check if a value is a Y.Map without losing type information.\n *\n * @param value Value to check.\n */\nexport function isYMap< T extends YMapRecord >(\n\tvalue: YMapWrap< T > | undefined\n): value is YMapWrap< T > {\n\treturn value instanceof Y.Map;\n}\n\ndeclare const richTextOffsetBrand: unique symbol;\ndeclare const htmlStringIndexBrand: unique symbol;\n\n/**\n * Branded type to prevent confusion between HTML string indices and RichText offsets.\n *\n * @see asRichTextOffset()\n */\nexport type RichTextOffset = number & {\n\treadonly [ richTextOffsetBrand ]: 'RichTextOffset';\n};\n\n/**\n * Branded type to prevent confusion between HTML string indices and RichText offsets.\n *\n * @see asHtmlStringIndex()\n */\nexport type HtmlStringIndex = number & {\n\treadonly [ htmlStringIndexBrand ]: 'HtmlStringIndex';\n};\n\n/**\n * Brand a number as an offset into a RichText’s text content.\n *\n * @param offset The rich-text offset to brand.\n * @return The branded rich-text offset.\n */\nexport function asRichTextOffset( offset: number ): RichTextOffset {\n\treturn offset as RichTextOffset;\n}\n\n/**\n * Brand a number as a string index into serialized HTML.\n *\n * @param index The HTML string index to brand.\n * @return The branded HTML string index.\n */\nexport function asHtmlStringIndex( index: number ): HtmlStringIndex {\n\treturn index as HtmlStringIndex;\n}\n\n/**\n * Resolve a selection attribute key to a Y.Text value.\n *\n * RichText identifiers are normally top-level block attribute keys, but nested\n * rich-text fields can provide a dot path such as `body.0.cells.0.content`.\n *\n * @param attributes The block attributes map.\n * @param attributeKey The top-level attribute key or nested attribute path.\n * @return The matching Y.Text, or null if the path is not a rich-text field.\n */\nexport function getYTextByAttributeKey(\n\tattributes: Y.Map< unknown >,\n\tattributeKey: string\n): Y.Text | null {\n\tconst directValue = attributes.get( attributeKey );\n\tif ( directValue instanceof Y.Text ) {\n\t\treturn directValue;\n\t}\n\n\tlet value: unknown = attributes;\n\tfor ( const pathPart of attributeKey.split( '.' ) ) {\n\t\tif ( value instanceof Y.Map ) {\n\t\t\tvalue = value.get( pathPart );\n\t\t} else if ( value instanceof Y.Array ) {\n\t\t\tconst index = Number.parseInt( pathPart, 10 );\n\t\t\tif (\n\t\t\t\t! Number.isSafeInteger( index ) ||\n\t\t\t\tindex < 0 ||\n\t\t\t\tindex.toString() !== pathPart\n\t\t\t) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tvalue = value.get( index );\n\t\t} else {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\treturn value instanceof Y.Text ? value : null;\n}\n\n/**\n * Given a block ID and a Y.Doc, find the block in the document.\n *\n * @param blockId The block ID to find\n * @param ydoc The Y.Doc to find the block in\n * @return The block, or null if the block is not found\n */\nexport function findBlockByClientIdInDoc(\n\tblockId: string,\n\tydoc: Y.Doc\n): YBlock | null {\n\tconst ymap = getRootMap< YPostRecord >( ydoc, CRDT_RECORD_MAP_KEY );\n\tconst blocks = ymap.get( 'blocks' );\n\n\tif ( ! ( blocks instanceof Y.Array ) ) {\n\t\treturn null;\n\t}\n\n\treturn findBlockByClientIdInBlocks( blockId, blocks );\n}\n\n// Marker for insertion.\nconst MARKER_START = 0xe000;\n\n/**\n * Pick a marker character that does not appear in `text`. Returns the marker\n * or `null` if all candidates are present (extremely unlikely in practice).\n *\n * @param text The string to check for existing marker characters.\n */\nfunction pickMarker( text: string ): string | null {\n\tconst tryCount = 0x10;\n\n\t// Scan the unicode private use area for the first code point not present\n\t// in the text.\n\tfor ( let code = MARKER_START; code < MARKER_START + tryCount; code++ ) {\n\t\tconst candidate = String.fromCharCode( code );\n\n\t\tif ( ! text.includes( candidate ) ) {\n\t\t\treturn candidate;\n\t\t}\n\t}\n\n\treturn null;\n}\n\n/**\n * Convert an HTML character index (counting tag characters) to a rich-text\n * offset (counting only text characters). Used on read paths where Y.Text\n * resolves to an HTML index but the block editor expects a text offset.\n *\n * @param html The full HTML string from Y.Text.\n * @param htmlIndex The HTML character index.\n * @return The corresponding rich-text offset.\n */\nexport function htmlIndexToRichTextOffset(\n\thtml: string,\n\thtmlIndex: HtmlStringIndex\n): RichTextOffset {\n\tif ( ! html.includes( '<' ) && ! html.includes( '&' ) ) {\n\t\treturn asRichTextOffset( htmlIndex );\n\t}\n\n\tconst marker = pickMarker( html );\n\tif ( ! marker ) {\n\t\treturn asRichTextOffset( htmlIndex );\n\t}\n\n\t// Insert marker and let create() do the parsing.\n\tconst withMarker =\n\t\thtml.slice( 0, htmlIndex ) + marker + html.slice( htmlIndex );\n\tconst value = create( { html: withMarker } );\n\tconst markerPos = value.text.indexOf( marker );\n\n\treturn asRichTextOffset( markerPos === -1 ? htmlIndex : markerPos );\n}\n\n/**\n * Convert a rich-text offset (counting only text characters) to an HTML\n * character index (counting tag characters). Used on write paths where the\n * block editor provides a text offset but Y.Text expects an HTML index.\n *\n * @param html The full HTML string from Y.Text.\n * @param richTextOffset The rich-text text offset.\n * @return The corresponding HTML character index.\n */\nexport function richTextOffsetToHtmlIndex(\n\thtml: string,\n\trichTextOffset: RichTextOffset\n): HtmlStringIndex {\n\tif ( ! html.includes( '<' ) && ! html.includes( '&' ) ) {\n\t\treturn asHtmlStringIndex( richTextOffset );\n\t}\n\n\tconst marker = pickMarker( html );\n\tif ( ! marker ) {\n\t\treturn asHtmlStringIndex( richTextOffset );\n\t}\n\n\tconst value = create( { html } );\n\tconst markerValue = create( { text: marker } );\n\t// The marker must inherit the formatting at the insertion point so that\n\t// toHTMLString does not split surrounding tags (e.g. <strong>) around it.\n\tif ( value.formats[ richTextOffset ] ) {\n\t\tmarkerValue.formats[ 0 ] = value.formats[ richTextOffset ];\n\t}\n\n\tconst withMarker = insert(\n\t\tvalue,\n\t\tmarkerValue,\n\t\trichTextOffset,\n\t\trichTextOffset\n\t);\n\n\tconst htmlWithMarker = toHTMLString( { value: withMarker } );\n\tconst markerIndex = htmlWithMarker.indexOf( marker );\n\treturn asHtmlStringIndex(\n\t\tmarkerIndex === -1 ? richTextOffset : markerIndex\n\t);\n}\n\nfunction findBlockByClientIdInBlocks(\n\tblockId: string,\n\tblocks: YBlocks\n): YBlock | null {\n\tfor ( const block of blocks ) {\n\t\tif ( block.get( 'clientId' ) === blockId ) {\n\t\t\treturn block;\n\t\t}\n\n\t\tconst innerBlocks = block.get( 'innerBlocks' );\n\n\t\tif ( innerBlocks && innerBlocks.length > 0 ) {\n\t\t\tconst innerBlock = findBlockByClientIdInBlocks(\n\t\t\t\tblockId,\n\t\t\t\tinnerBlocks\n\t\t\t);\n\n\t\t\tif ( innerBlock ) {\n\t\t\t\treturn innerBlock;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn null;\n}\n"],
5
5
  "mappings": ";AAGA,SAAS,SAAS;AAClB,SAAS,QAAQ,QAAQ,oBAAoB;AAO7C,SAAS,2BAA2B;AA6C7B,SAAS,WACf,KACA,KACgB;AAChB,SAAO,IAAI,OAAa,GAAI;AAC7B;AAQO,SAAS,WACf,UAAwB,CAAC,GACT;AAChB,SAAO,IAAI,EAAE,IAAK,OAAO,QAAS,OAAQ,CAAE;AAC7C;AAOO,SAAS,OACf,OACyB;AACzB,SAAO,iBAAiB,EAAE;AAC3B;AA6BO,SAAS,iBAAkB,QAAiC;AAClE,SAAO;AACR;AAQO,SAAS,kBAAmB,OAAiC;AACnE,SAAO;AACR;AAYO,SAAS,uBACf,YACA,cACgB;AAChB,QAAM,cAAc,WAAW,IAAK,YAAa;AACjD,MAAK,uBAAuB,EAAE,MAAO;AACpC,WAAO;AAAA,EACR;AAEA,MAAI,QAAiB;AACrB,aAAY,YAAY,aAAa,MAAO,GAAI,GAAI;AACnD,QAAK,iBAAiB,EAAE,KAAM;AAC7B,cAAQ,MAAM,IAAK,QAAS;AAAA,IAC7B,WAAY,iBAAiB,EAAE,OAAQ;AACtC,YAAM,QAAQ,OAAO,SAAU,UAAU,EAAG;AAC5C,UACC,CAAE,OAAO,cAAe,KAAM,KAC9B,QAAQ,KACR,MAAM,SAAS,MAAM,UACpB;AACD,eAAO;AAAA,MACR;AACA,cAAQ,MAAM,IAAK,KAAM;AAAA,IAC1B,OAAO;AACN,aAAO;AAAA,IACR;AAAA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,QAAM,cAAc,OAAQ,EAAE,MAAM,OAAO,CAAE;AAG7C,MAAK,MAAM,QAAS,cAAe,GAAI;AACtC,gBAAY,QAAS,CAAE,IAAI,MAAM,QAAS,cAAe;AAAA,EAC1D;AAEA,QAAM,aAAa;AAAA,IAClB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AAEA,QAAM,iBAAiB,aAAc,EAAE,OAAO,WAAW,CAAE;AAC3D,QAAM,cAAc,eAAe,QAAS,MAAO;AACnD,SAAO;AAAA,IACN,gBAAgB,KAAK,iBAAiB;AAAA,EACvC;AACD;AAEA,SAAS,4BACR,SACA,QACgB;AAChB,aAAY,SAAS,QAAS;AAC7B,QAAK,MAAM,IAAK,UAAW,MAAM,SAAU;AAC1C,aAAO;AAAA,IACR;AAEA,UAAM,cAAc,MAAM,IAAK,aAAc;AAE7C,QAAK,eAAe,YAAY,SAAS,GAAI;AAC5C,YAAM,aAAa;AAAA,QAClB;AAAA,QACA;AAAA,MACD;AAEA,UAAK,YAAa;AACjB,eAAO;AAAA,MACR;AAAA,IACD;AAAA,EACD;AAEA,SAAO;AACR;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/utils/crdt.ts"],
4
- "sourcesContent": ["/**\n * External dependencies\n */\nimport fastDeepEqual from 'fast-deep-equal/es6/index.js';\n\n/**\n * WordPress dependencies\n */\nimport {\n\t__unstableSerializeAndClean,\n\tparse,\n\ttype Block as WPBlock,\n} from '@wordpress/blocks';\nimport {\n\ttype CRDTDoc,\n\ttype ObjectData,\n\ttype ObjectID,\n\ttype ObjectType,\n\ttype SyncConfig,\n\tY,\n} from '@wordpress/sync';\n\n/**\n * Internal dependencies\n */\nimport { BaseAwareness } from '../awareness/base-awareness';\nimport {\n\ttype Block,\n\tdeserializeBlockAttributes,\n\tmergeCrdtBlocks,\n\ttype MergeCursorPosition,\n\tmergeRichTextUpdate,\n\ttype YBlock,\n\ttype YBlocks,\n} from './crdt-blocks';\nimport { type Post } from '../entity-types/post';\nimport { CRDT_DOC_META_PERSISTENCE_KEY, CRDT_RECORD_MAP_KEY } from '../sync';\nimport type { WPSelection } from '../types';\nimport {\n\tgetSelectionHistory,\n\tgetShiftedSelection,\n\tupdateSelectionHistory,\n} from './crdt-selection';\nimport {\n\tasRichTextOffset,\n\tcreateYMap,\n\tgetRootMap,\n\tisYMap,\n\ttype YMapRecord,\n\ttype YMapWrap,\n} from './crdt-utils';\n\n// A function that derives content from blocks. Two callers produce this:\n// `useEntityBlockEditor` reads blocks from its argument (so the optional arg\n// lets it accept whatever caller is invoked with), and the receiver-side\n// injection in this file captures blocks in a closure and ignores the arg.\ntype ContentFromBlocksFn = ( args?: { blocks: Block[] } ) => string;\n\n// Changes that can be applied to a post entity record.\nexport type PostChanges = Partial< Post > & {\n\tblocks?: Block[];\n\tcontent?: Post[ 'content' ] | string | ContentFromBlocksFn;\n\texcerpt?: Post[ 'excerpt' ] | string;\n\tselection?: WPSelection;\n\ttitle?: Post[ 'title' ] | string;\n};\n\n// A post record as represented in the CRDT document (Y.Map).\nexport interface YPostRecord extends YMapRecord {\n\tauthor: number;\n\t// Blocks are undefined when they need to be re-parsed from content.\n\tblocks: YBlocks | undefined;\n\tcontent: Y.Text;\n\tcategories: number[];\n\tcomment_status: string;\n\tdate: string | null;\n\texcerpt: Y.Text;\n\tfeatured_media: number;\n\tformat: string;\n\tmeta: YMapWrap< YMapRecord >;\n\tping_status: string;\n\tslug: string;\n\tstatus: string;\n\tsticky: boolean;\n\ttags: number[];\n\ttemplate: string;\n\ttitle: Y.Text;\n}\n\nexport const POST_META_KEY_FOR_CRDT_DOC_PERSISTENCE = '_crdt_document';\n\n// Post meta keys that should *not* be synced.\nconst disallowedPostMetaKeys = new Set< string >( [\n\tPOST_META_KEY_FOR_CRDT_DOC_PERSISTENCE,\n] );\n\n/**\n * Given a set of local changes to a generic entity record, apply those changes\n * to the local Y.Doc.\n *\n * @param {CRDTDoc} ydoc\n * @param {Partial< ObjectData >} changes\n * @return {void}\n */\nfunction defaultApplyChangesToCRDTDoc(\n\tydoc: CRDTDoc,\n\tchanges: ObjectData\n): void {\n\tconst ymap = getRootMap( ydoc, CRDT_RECORD_MAP_KEY );\n\n\tObject.entries( changes ).forEach( ( [ key, newValue ] ) => {\n\t\t// Cannot serialize function values, so cannot sync them.\n\t\tif ( 'function' === typeof newValue ) {\n\t\t\treturn;\n\t\t}\n\n\t\tswitch ( key ) {\n\t\t\t// Add support for additional data types here.\n\n\t\t\tdefault: {\n\t\t\t\tconst currentValue = ymap.get( key );\n\t\t\t\tupdateMapValue( ymap, key, currentValue, newValue );\n\t\t\t}\n\t\t}\n\t} );\n}\n\n/**\n * Given a set of local changes to a post record, apply those changes to the\n * local Y.Doc.\n *\n * @param {CRDTDoc} ydoc\n * @param {PostChanges} changes\n * @param {Set<string>} syncedProperties\n * @return {void}\n */\nexport function applyPostChangesToCRDTDoc(\n\tydoc: CRDTDoc,\n\tchanges: PostChanges,\n\tsyncedProperties: Set< string >\n): void {\n\tconst ymap = getRootMap< YPostRecord >( ydoc, CRDT_RECORD_MAP_KEY );\n\n\tObject.keys( changes ).forEach( ( key ) => {\n\t\tif ( ! syncedProperties.has( key ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst newValue = changes[ key ];\n\n\t\t// Cannot serialize function values, so cannot sync them. `content` is\n\t\t// often passed as a lazy serializer by `useEntityBlockEditor`; the\n\t\t// receiver re-derives it from the synced blocks (see\n\t\t// getPostChangesFromCRDTDoc), so dropping it here is intentional.\n\t\tif ( 'function' === typeof newValue ) {\n\t\t\treturn;\n\t\t}\n\n\t\tswitch ( key ) {\n\t\t\tcase 'blocks': {\n\t\t\t\t// Block changes from typing are bundled with a 'selection' update.\n\t\t\t\t// Use the resulting cursor position for block merging.\n\t\t\t\tconst newCursorPosition = parseCursorSelection(\n\t\t\t\t\tchanges.selection\n\t\t\t\t);\n\n\t\t\t\t// Blocks are undefined when they need to be re-parsed from content.\n\t\t\t\t// When new content is also part of this change (e.g. the Code\n\t\t\t\t// Editor dispatching `{ content, blocks: undefined }` on every\n\t\t\t\t// keystroke), derive blocks from content so the merge keeps\n\t\t\t\t// stable YBlock identities for unchanged blocks.\n\n\t\t\t\tconst rawContent = getRawValue( changes.content );\n\t\t\t\tif ( ! newValue && typeof rawContent === 'string' ) {\n\t\t\t\t\t// We have no blocks but an updated content string.\n\t\t\t\t\tmergeContentWithoutBlocks(\n\t\t\t\t\t\tymap,\n\t\t\t\t\t\trawContent,\n\t\t\t\t\t\tnewCursorPosition\n\t\t\t\t\t);\n\t\t\t\t\tbreak;\n\t\t\t\t} else if ( ! newValue ) {\n\t\t\t\t\t// We have an update containing empty blocks and content.\n\t\t\t\t\t// Set to undefined instead of deleting the key. This is important\n\t\t\t\t\t// since we iterate over the Y.Map keys in getPostChangesFromCRDTDoc.\n\t\t\t\t\tymap.set( key, undefined );\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tlet currentBlocks = ymap.get( key );\n\n\t\t\t\t// Initialize.\n\t\t\t\tif ( ! ( currentBlocks instanceof Y.Array ) ) {\n\t\t\t\t\tcurrentBlocks = new Y.Array< YBlock >();\n\t\t\t\t\tymap.set( key, currentBlocks );\n\t\t\t\t}\n\n\t\t\t\t// Merge blocks does not need `setValue` because it is operating on a\n\t\t\t\t// Yjs type that is already in the Y.Doc.\n\t\t\t\tmergeCrdtBlocks( currentBlocks, newValue, newCursorPosition );\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase 'content':\n\t\t\tcase 'excerpt':\n\t\t\tcase 'title': {\n\t\t\t\tconst currentValue = ymap.get( key );\n\t\t\t\tlet rawValue = getRawValue( newValue );\n\n\t\t\t\t// Copy logic from prePersistPostType to ensure that the \"Auto\n\t\t\t\t// Draft\" template title is not synced.\n\t\t\t\tif (\n\t\t\t\t\tkey === 'title' &&\n\t\t\t\t\t! currentValue?.toString() &&\n\t\t\t\t\t'Auto Draft' === rawValue\n\t\t\t\t) {\n\t\t\t\t\trawValue = '';\n\t\t\t\t}\n\n\t\t\t\tif ( currentValue instanceof Y.Text ) {\n\t\t\t\t\tmergeRichTextUpdate( currentValue, rawValue ?? '' );\n\t\t\t\t} else {\n\t\t\t\t\tconst newYText = new Y.Text( rawValue ?? '' );\n\t\t\t\t\tymap.set( key, newYText );\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\t// \"Meta\" is overloaded term; here, it refers to post meta.\n\t\t\tcase 'meta': {\n\t\t\t\tlet metaMap = ymap.get( 'meta' );\n\n\t\t\t\t// Initialize.\n\t\t\t\tif ( ! isYMap( metaMap ) ) {\n\t\t\t\t\tmetaMap = createYMap< YMapRecord >();\n\t\t\t\t\tymap.set( 'meta', metaMap );\n\t\t\t\t}\n\n\t\t\t\t// Iterate over each meta property in the new value and merge it if it\n\t\t\t\t// should be synced.\n\t\t\t\tObject.entries( newValue ?? {} ).forEach(\n\t\t\t\t\t( [ metaKey, metaValue ] ) => {\n\t\t\t\t\t\tif ( disallowedPostMetaKeys.has( metaKey ) ) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tupdateMapValue(\n\t\t\t\t\t\t\tmetaMap,\n\t\t\t\t\t\t\tmetaKey,\n\t\t\t\t\t\t\tmetaMap.get( metaKey ), // current value in CRDT\n\t\t\t\t\t\t\tmetaValue // new value from changes\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase 'slug': {\n\t\t\t\t// Do not sync an empty slug. This indicates that the post is using\n\t\t\t\t// the default auto-generated slug.\n\t\t\t\tif ( ! newValue ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tconst currentValue = ymap.get( key );\n\t\t\t\tupdateMapValue( ymap, key, currentValue, newValue );\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\t// Add support for additional properties here.\n\n\t\t\tdefault: {\n\t\t\t\tconst currentValue = ymap.get( key );\n\t\t\t\tupdateMapValue( ymap, key, currentValue, newValue );\n\t\t\t}\n\t\t}\n\t} );\n\n\t// Process changes that we don't want to persist to the CRDT document.\n\tif ( changes.selection ) {\n\t\tconst selection = changes.selection;\n\t\t// Persist selection changes at the end of the current event loop.\n\t\t// This allows undo meta to be saved with the current selection before\n\t\t// it is overwritten by the new selection from Gutenberg.\n\t\t// Without this, selection history will already contain the latest\n\t\t// selection (after this change) when the undo stack is saved.\n\t\tsetTimeout( () => {\n\t\t\tupdateSelectionHistory( ydoc, selection );\n\t\t}, 0 );\n\t}\n}\n\n/**\n * Derive blocks from a raw content string and merge them into the post's\n * blocks Y.Array. Used when a caller dispatches a change with `blocks:\n * undefined` alongside new content, most notably the Code Editor's\n * per-keystroke dispatch.\n *\n * @param ymap The post's root Y.Map.\n * @param rawContent The raw HTML content to parse.\n * @param cursorPosition Cursor position derived from the change's selection,\n * used by mergeCrdtBlocks for rich-text cursor hints.\n */\nfunction mergeContentWithoutBlocks(\n\tymap: YMapWrap< YPostRecord >,\n\trawContent: string,\n\tcursorPosition: MergeCursorPosition\n): void {\n\tlet currentBlocks = ymap.get( 'blocks' );\n\n\tif ( ! ( currentBlocks instanceof Y.Array ) ) {\n\t\tcurrentBlocks = new Y.Array< YBlock >();\n\t\tymap.set( 'blocks', currentBlocks );\n\t}\n\n\tmergeCrdtBlocks(\n\t\tcurrentBlocks,\n\t\tparse( rawContent ) as Block[],\n\t\tcursorPosition,\n\t\t{ preserveClientIds: true }\n\t);\n}\n\n/**\n * Only returns a selection object if it describes a selection within a block, with\n * a cursor inside a RichText field associated with one of that block\u2019s attributes.\n *\n * @param selection Selection object which might represent a selection within a block,\n * within a RichText field associated with a particular attribute of\n * that block, or none at all.\n */\nfunction parseCursorSelection( selection?: WPSelection ): MergeCursorPosition {\n\tconst selectionStart = selection?.selectionStart;\n\n\treturn selectionStart?.clientId &&\n\t\tselectionStart.attributeKey &&\n\t\t'number' === typeof selectionStart.offset &&\n\t\tNumber.isInteger( selectionStart.offset )\n\t\t? {\n\t\t\t\tattributeKey: selectionStart.attributeKey,\n\t\t\t\tclientId: selectionStart.clientId,\n\t\t\t\toffset: asRichTextOffset( selectionStart.offset ),\n\t\t }\n\t\t: null;\n}\n\nfunction defaultGetChangesFromCRDTDoc( crdtDoc: CRDTDoc ): ObjectData {\n\treturn getRootMap( crdtDoc, CRDT_RECORD_MAP_KEY ).toJSON();\n}\n\n/**\n * Given a local Y.Doc that *may* contain changes from remote peers, compare\n * against the local record and determine if there are changes (edits) we want\n * to dispatch.\n *\n * @param {CRDTDoc} ydoc\n * @param {Post} editedRecord\n * @param {Set<string>} syncedProperties\n * @return {Partial<PostChanges>} The changes that should be applied to the local record.\n */\nexport function getPostChangesFromCRDTDoc(\n\tydoc: CRDTDoc,\n\teditedRecord: Post,\n\tsyncedProperties: Set< string >\n): PostChanges {\n\tconst ymap = getRootMap< YPostRecord >( ydoc, CRDT_RECORD_MAP_KEY );\n\n\tlet allowedMetaChanges: Post[ 'meta' ] = {};\n\n\tconst changes = Object.fromEntries(\n\t\tObject.entries( ymap.toJSON() ).filter( ( [ key, newValue ] ) => {\n\t\t\tif ( ! syncedProperties.has( key ) ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tconst currentValue = editedRecord[ key ];\n\n\t\t\tswitch ( key ) {\n\t\t\t\tcase 'blocks': {\n\t\t\t\t\t// When we are passed a persisted CRDT document, make a special\n\t\t\t\t\t// comparison of the content and blocks.\n\t\t\t\t\t//\n\t\t\t\t\t// When other fields (besides `blocks`) are mutated outside the block\n\t\t\t\t\t// editor, the change is caught by an equality check (see other cases\n\t\t\t\t\t// in this `switch` statement). As a transient property, `blocks`\n\t\t\t\t\t// cannot be directly mutated outside the block editor -- only\n\t\t\t\t\t// `content` can.\n\t\t\t\t\t//\n\t\t\t\t\t// Therefore, for this special comparison, we serialize the `blocks`\n\t\t\t\t\t// from the persisted CRDT document and compare that to the content\n\t\t\t\t\t// from the persisted record. If they differ, we know that the content\n\t\t\t\t\t// in the database has changed, and therefore the blocks have changed.\n\t\t\t\t\t//\n\t\t\t\t\t// We cannot directly compare the `blocks` from the CRDT document to\n\t\t\t\t\t// the `blocks` derived from the `content` in the persisted record,\n\t\t\t\t\t// because the latter will have different client IDs.\n\t\t\t\t\tif (\n\t\t\t\t\t\tydoc.meta?.get( CRDT_DOC_META_PERSISTENCE_KEY ) &&\n\t\t\t\t\t\teditedRecord.content\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst blocksJson = ymap.get( 'blocks' )?.toJSON() ?? [];\n\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t__unstableSerializeAndClean( blocksJson ).trim() !==\n\t\t\t\t\t\t\tgetRawValue( editedRecord.content )\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\n\t\t\t\tcase 'date': {\n\t\t\t\t\t// Do not overwrite a \"floating\" date. Borrowing logic from the\n\t\t\t\t\t// isEditedPostDateFloating selector.\n\t\t\t\t\tconst currentDateIsFloating =\n\t\t\t\t\t\tnull === currentValue ||\n\t\t\t\t\t\teditedRecord.modified === currentValue;\n\n\t\t\t\t\tif ( currentDateIsFloating ) {\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn haveValuesChanged( currentValue, newValue );\n\t\t\t\t}\n\n\t\t\t\tcase 'meta': {\n\t\t\t\t\tconst currentMeta =\n\t\t\t\t\t\t( currentValue as PostChanges[ 'meta' ] ) ?? {};\n\n\t\t\t\t\tallowedMetaChanges = Object.fromEntries(\n\t\t\t\t\t\tObject.entries( newValue ?? {} ).filter(\n\t\t\t\t\t\t\t( [ metaKey ] ) => {\n\t\t\t\t\t\t\t\tif ( disallowedPostMetaKeys.has( metaKey ) ) {\n\t\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t// Ignore meta keys that are no longer registered\n\t\t\t\t\t\t\t\t// for this post (absent from the REST response).\n\t\t\t\t\t\t\t\t// Without this, orphaned CRDT meta would mark\n\t\t\t\t\t\t\t\t// the post permanently dirty.\n\t\t\t\t\t\t\t\treturn metaKey in currentMeta;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\n\t\t\t\t\t// Merge the allowed meta changes with the current meta values since\n\t\t\t\t\t// not all meta properties are synced.\n\t\t\t\t\tconst mergedValue = {\n\t\t\t\t\t\t...currentMeta,\n\t\t\t\t\t\t...allowedMetaChanges,\n\t\t\t\t\t};\n\n\t\t\t\t\treturn haveValuesChanged( currentValue, mergedValue );\n\t\t\t\t}\n\n\t\t\t\tcase 'status': {\n\t\t\t\t\t// Do not sync an invalid status.\n\t\t\t\t\tif ( 'auto-draft' === newValue ) {\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn haveValuesChanged( currentValue, newValue );\n\t\t\t\t}\n\n\t\t\t\tcase 'content':\n\t\t\t\tcase 'excerpt':\n\t\t\t\tcase 'title': {\n\t\t\t\t\treturn haveValuesChanged(\n\t\t\t\t\t\tgetRawValue( currentValue ),\n\t\t\t\t\t\tnewValue\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\t// Add support for additional data types here.\n\n\t\t\t\tdefault: {\n\t\t\t\t\treturn haveValuesChanged( currentValue, newValue );\n\t\t\t\t}\n\t\t\t}\n\t\t} )\n\t);\n\n\t// Blocks extracted from the CRDT document have rich-text attributes as\n\t// plain strings (from Y.Text.toJSON()). Convert them back to RichTextData\n\t// so block edit components receive the same types as locally-created blocks.\n\tif ( changes.blocks ) {\n\t\tchanges.blocks = deserializeBlockAttributes(\n\t\t\tchanges.blocks as Block[]\n\t\t);\n\t}\n\n\t// When blocks changed but content didn't (the sender internally used a lazy\n\t// serializer function), inject a closure that captures the synced blocks\n\t// and serializes them on demand. Mirrors what useEntityBlockEditor does\n\t// locally. A fresh function on every persistent edit marks the entity\n\t// dirty (so the save button reactivates for peers), while serialization\n\t// stays lazy (only runs when getEditedPostContent reads it). The closure\n\t// captures `capturedBlocks` so the right content is returned even if the\n\t// caller later clears `record.blocks` (e.g. the Code Editor re-parsing\n\t// from content).\n\tif ( changes.blocks && ! changes.content ) {\n\t\tconst capturedBlocks = changes.blocks;\n\t\tchanges.content = () =>\n\t\t\t__unstableSerializeAndClean( capturedBlocks as WPBlock[] );\n\t}\n\n\t// Meta changes must be merged with the edited record since not all meta\n\t// properties are synced.\n\tif ( 'object' === typeof changes.meta ) {\n\t\tchanges.meta = {\n\t\t\t...editedRecord.meta,\n\t\t\t...allowedMetaChanges,\n\t\t};\n\t}\n\n\t// When remote content changes are detected, recalculate the local user's\n\t// selection using Y.RelativePosition to account for text shifts. The ydoc\n\t// has already been updated with remote content at this point, so converting\n\t// relative positions to absolute gives corrected offsets. Including the\n\t// selection in PostChanges ensures it dispatches atomically with content.\n\tconst selectionHistory = getSelectionHistory( ydoc );\n\tconst shiftedSelection = getShiftedSelection( ydoc, selectionHistory );\n\tif ( shiftedSelection ) {\n\t\tchanges.selection = {\n\t\t\t...shiftedSelection,\n\t\t\tinitialPosition: 0,\n\t\t};\n\t}\n\n\treturn changes;\n}\n\n/**\n * This default sync config can be used for entities that are flat maps of\n * primitive values and do not require custom logic to merge changes.\n */\nexport const defaultSyncConfig: SyncConfig = {\n\tapplyChangesToCRDTDoc: defaultApplyChangesToCRDTDoc,\n\tcreateAwareness: ( ydoc: CRDTDoc ) => new BaseAwareness( ydoc ),\n\tgetChangesFromCRDTDoc: defaultGetChangesFromCRDTDoc,\n};\n\n/**\n * This default collection sync config can be used to sync entity collections\n * (e.g., block comments) where we are not interested in merging changes at the\n * individual record level, but instead want to replace the entire collection\n * when changes are detected.\n */\nexport const defaultCollectionSyncConfig: SyncConfig = {\n\tapplyChangesToCRDTDoc: () => {},\n\tgetChangesFromCRDTDoc: () => ( {} ),\n\tshouldSync: ( _: ObjectType, objectId: ObjectID | null ) =>\n\t\tnull === objectId,\n};\n\n/**\n * Extract the raw string value from a property that may be a string or an object\n * with a `raw` property (`RenderedText`).\n *\n * @param {unknown} value The value to extract from.\n * @return {string|undefined} The raw string value, or undefined if it could not be determined.\n */\nfunction getRawValue( value?: unknown ): string | undefined {\n\t// Value may be a string property or a nested object with a `raw` property.\n\tif ( 'string' === typeof value ) {\n\t\treturn value;\n\t}\n\n\tif (\n\t\tvalue &&\n\t\t'object' === typeof value &&\n\t\t'raw' in value &&\n\t\t'string' === typeof value.raw\n\t) {\n\t\treturn value.raw;\n\t}\n\n\treturn undefined;\n}\n\nfunction haveValuesChanged< ValueType >(\n\tcurrentValue: ValueType | undefined,\n\tnewValue: ValueType | undefined\n): boolean {\n\treturn ! fastDeepEqual( currentValue, newValue );\n}\n\nfunction updateMapValue< T extends YMapRecord, K extends keyof T >(\n\tmap: YMapWrap< T >,\n\tkey: K,\n\tcurrentValue: T[ K ] | undefined,\n\tnewValue: T[ K ] | undefined\n): void {\n\tif ( undefined === newValue ) {\n\t\tmap.delete( key );\n\t\treturn;\n\t}\n\n\tif ( haveValuesChanged< T[ K ] >( currentValue, newValue ) ) {\n\t\tmap.set( key, newValue );\n\t}\n}\n"],
4
+ "sourcesContent": ["/**\n * External dependencies\n */\nimport fastDeepEqual from 'fast-deep-equal/es6/index.js';\n\n/**\n * WordPress dependencies\n */\nimport {\n\t__unstableSerializeAndClean,\n\tparse,\n\ttype Block as WPBlock,\n} from '@wordpress/blocks';\nimport {\n\ttype CRDTDoc,\n\ttype ObjectData,\n\ttype ObjectID,\n\ttype ObjectType,\n\ttype SyncConfig,\n\tY,\n} from '@wordpress/sync';\n\n/**\n * Internal dependencies\n */\nimport { BaseAwareness } from '../awareness/base-awareness';\nimport {\n\ttype Block,\n\tdeserializeBlockAttributes,\n\tmergeCrdtBlocks,\n\ttype MergeCursorPosition,\n\tmergeRichTextUpdate,\n\ttype YBlock,\n\ttype YBlocks,\n} from './crdt-blocks';\nimport { type Post } from '../entity-types/post';\nimport { CRDT_DOC_META_PERSISTENCE_KEY, CRDT_RECORD_MAP_KEY } from '../sync';\nimport type { WPSelection } from '../types';\nimport {\n\tgetSelectionHistory,\n\tgetShiftedSelection,\n\tupdateSelectionHistory,\n} from './crdt-selection';\nimport {\n\tasRichTextOffset,\n\tcreateYMap,\n\tgetRootMap,\n\tisYMap,\n\ttype YMapRecord,\n\ttype YMapWrap,\n} from './crdt-utils';\n\n// A function that derives content from blocks. Two callers produce this:\n// `useEntityBlockEditor` reads blocks from its argument (so the optional arg\n// lets it accept whatever caller is invoked with), and the receiver-side\n// injection in this file captures blocks in a closure and ignores the arg.\ntype ContentFromBlocksFn = ( args?: { blocks: Block[] } ) => string;\n\n// Changes that can be applied to a post entity record.\nexport type PostChanges = Partial< Post > & {\n\tblocks?: Block[];\n\tcontent?: Post[ 'content' ] | string | ContentFromBlocksFn;\n\texcerpt?: Post[ 'excerpt' ] | string;\n\tselection?: WPSelection;\n\ttitle?: Post[ 'title' ] | string;\n};\n\n// A post record as represented in the CRDT document (Y.Map).\nexport interface YPostRecord extends YMapRecord {\n\tauthor: number;\n\t// Blocks are undefined when they need to be re-parsed from content.\n\tblocks: YBlocks | undefined;\n\tcontent: Y.Text;\n\tcategories: number[];\n\tcomment_status: string;\n\tdate: string | null;\n\texcerpt: Y.Text;\n\tfeatured_media: number;\n\tformat: string;\n\tmeta: YMapWrap< YMapRecord >;\n\tping_status: string;\n\tslug: string;\n\tstatus: string;\n\tsticky: boolean;\n\ttags: number[];\n\ttemplate: string;\n\ttitle: Y.Text;\n}\n\nexport const POST_META_KEY_FOR_CRDT_DOC_PERSISTENCE = '_crdt_document';\n\n// Post meta keys that should *not* be synced.\nconst disallowedPostMetaKeys = new Set< string >( [\n\tPOST_META_KEY_FOR_CRDT_DOC_PERSISTENCE,\n] );\n\n/**\n * Given a set of local changes to a generic entity record, apply those changes\n * to the local Y.Doc.\n *\n * @param {CRDTDoc} ydoc\n * @param {Partial< ObjectData >} changes\n * @return {void}\n */\nfunction defaultApplyChangesToCRDTDoc(\n\tydoc: CRDTDoc,\n\tchanges: ObjectData\n): void {\n\tconst ymap = getRootMap( ydoc, CRDT_RECORD_MAP_KEY );\n\n\tObject.entries( changes ).forEach( ( [ key, newValue ] ) => {\n\t\t// Cannot serialize function values, so cannot sync them.\n\t\tif ( 'function' === typeof newValue ) {\n\t\t\treturn;\n\t\t}\n\n\t\tswitch ( key ) {\n\t\t\t// Add support for additional data types here.\n\n\t\t\tdefault: {\n\t\t\t\tconst currentValue = ymap.get( key );\n\t\t\t\tupdateMapValue( ymap, key, currentValue, newValue );\n\t\t\t}\n\t\t}\n\t} );\n}\n\n/**\n * Given a set of local changes to a post record, apply those changes to the\n * local Y.Doc.\n *\n * @param {CRDTDoc} ydoc\n * @param {PostChanges} changes\n * @param {Set<string>} syncedProperties\n * @return {void}\n */\nexport function applyPostChangesToCRDTDoc(\n\tydoc: CRDTDoc,\n\tchanges: PostChanges,\n\tsyncedProperties: Set< string >\n): void {\n\tconst ymap = getRootMap< YPostRecord >( ydoc, CRDT_RECORD_MAP_KEY );\n\n\tObject.keys( changes ).forEach( ( key ) => {\n\t\tif ( ! syncedProperties.has( key ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst newValue = changes[ key ];\n\n\t\t// Cannot serialize function values, so cannot sync them. `content` is\n\t\t// often passed as a lazy serializer by `useEntityBlockEditor`; the\n\t\t// receiver re-derives it from the synced blocks (see\n\t\t// getPostChangesFromCRDTDoc), so dropping it here is intentional.\n\t\tif ( 'function' === typeof newValue ) {\n\t\t\treturn;\n\t\t}\n\n\t\tswitch ( key ) {\n\t\t\tcase 'blocks': {\n\t\t\t\t// Block changes from typing are bundled with a 'selection' update.\n\t\t\t\t// Use the resulting cursor position for block merging.\n\t\t\t\tconst newCursorPosition = parseCursorSelection(\n\t\t\t\t\tchanges.selection\n\t\t\t\t);\n\n\t\t\t\t// Blocks are undefined when they need to be re-parsed from content.\n\t\t\t\t// When new content is also part of this change (e.g. the Code\n\t\t\t\t// Editor dispatching `{ content, blocks: undefined }` on every\n\t\t\t\t// keystroke), derive blocks from content so the merge keeps\n\t\t\t\t// stable YBlock identities for unchanged blocks.\n\n\t\t\t\tconst rawContent = getRawValue( changes.content );\n\t\t\t\tif ( ! newValue && typeof rawContent === 'string' ) {\n\t\t\t\t\t// We have no blocks but an updated content string.\n\t\t\t\t\tmergeContentWithoutBlocks(\n\t\t\t\t\t\tymap,\n\t\t\t\t\t\trawContent,\n\t\t\t\t\t\tnewCursorPosition\n\t\t\t\t\t);\n\t\t\t\t\tbreak;\n\t\t\t\t} else if ( ! newValue ) {\n\t\t\t\t\t// We have an update containing empty blocks and content.\n\t\t\t\t\t// Set to undefined instead of deleting the key. This is important\n\t\t\t\t\t// since we iterate over the Y.Map keys in getPostChangesFromCRDTDoc.\n\t\t\t\t\tymap.set( key, undefined );\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tlet currentBlocks = ymap.get( key );\n\n\t\t\t\t// Initialize.\n\t\t\t\tif ( ! ( currentBlocks instanceof Y.Array ) ) {\n\t\t\t\t\tcurrentBlocks = new Y.Array< YBlock >();\n\t\t\t\t\tymap.set( key, currentBlocks );\n\t\t\t\t}\n\n\t\t\t\t// Merge blocks does not need `setValue` because it is operating on a\n\t\t\t\t// Yjs type that is already in the Y.Doc.\n\t\t\t\tmergeCrdtBlocks( currentBlocks, newValue, newCursorPosition );\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase 'content':\n\t\t\tcase 'excerpt':\n\t\t\tcase 'title': {\n\t\t\t\tconst currentValue = ymap.get( key );\n\t\t\t\tlet rawValue = getRawValue( newValue );\n\n\t\t\t\t// Copy logic from prePersistPostType to ensure that the \"Auto\n\t\t\t\t// Draft\" template title is not synced.\n\t\t\t\tif (\n\t\t\t\t\tkey === 'title' &&\n\t\t\t\t\t! currentValue?.toString() &&\n\t\t\t\t\t'Auto Draft' === rawValue\n\t\t\t\t) {\n\t\t\t\t\trawValue = '';\n\t\t\t\t}\n\n\t\t\t\tif ( currentValue instanceof Y.Text ) {\n\t\t\t\t\tmergeRichTextUpdate( currentValue, rawValue ?? '' );\n\t\t\t\t} else {\n\t\t\t\t\tconst newYText = new Y.Text( rawValue ?? '' );\n\t\t\t\t\tymap.set( key, newYText );\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\t// \"Meta\" is overloaded term; here, it refers to post meta.\n\t\t\tcase 'meta': {\n\t\t\t\tlet metaMap = ymap.get( 'meta' );\n\n\t\t\t\t// Initialize.\n\t\t\t\tif ( ! isYMap( metaMap ) ) {\n\t\t\t\t\tmetaMap = createYMap< YMapRecord >();\n\t\t\t\t\tymap.set( 'meta', metaMap );\n\t\t\t\t}\n\n\t\t\t\t// Iterate over each meta property in the new value and merge it if it\n\t\t\t\t// should be synced.\n\t\t\t\tObject.entries( newValue ?? {} ).forEach(\n\t\t\t\t\t( [ metaKey, metaValue ] ) => {\n\t\t\t\t\t\tif ( disallowedPostMetaKeys.has( metaKey ) ) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tupdateMapValue(\n\t\t\t\t\t\t\tmetaMap,\n\t\t\t\t\t\t\tmetaKey,\n\t\t\t\t\t\t\tmetaMap.get( metaKey ), // current value in CRDT\n\t\t\t\t\t\t\tmetaValue // new value from changes\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase 'slug': {\n\t\t\t\t// Do not sync an empty slug. This indicates that the post is using\n\t\t\t\t// the default auto-generated slug.\n\t\t\t\tif ( ! newValue ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tconst currentValue = ymap.get( key );\n\t\t\t\tupdateMapValue( ymap, key, currentValue, newValue );\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\t// Add support for additional properties here.\n\n\t\t\tdefault: {\n\t\t\t\tconst currentValue = ymap.get( key );\n\t\t\t\tupdateMapValue( ymap, key, currentValue, newValue );\n\t\t\t}\n\t\t}\n\t} );\n\n\t// Process changes that we don't want to persist to the CRDT document.\n\tif ( changes.selection ) {\n\t\tconst selection = changes.selection;\n\t\t// Persist selection changes at the end of the current event loop.\n\t\t// This allows undo meta to be saved with the current selection before\n\t\t// it is overwritten by the new selection from Gutenberg.\n\t\t// Without this, selection history will already contain the latest\n\t\t// selection (after this change) when the undo stack is saved.\n\t\tsetTimeout( () => {\n\t\t\tupdateSelectionHistory( ydoc, selection );\n\t\t}, 0 );\n\t}\n}\n\n/**\n * Derive blocks from a raw content string and merge them into the post's\n * blocks Y.Array. Used when a caller dispatches a change with `blocks:\n * undefined` alongside new content, most notably the Code Editor's\n * per-keystroke dispatch.\n *\n * @param ymap The post's root Y.Map.\n * @param rawContent The raw HTML content to parse.\n * @param cursorPosition Cursor position derived from the change's selection,\n * used by mergeCrdtBlocks for rich-text cursor hints.\n */\nfunction mergeContentWithoutBlocks(\n\tymap: YMapWrap< YPostRecord >,\n\trawContent: string,\n\tcursorPosition: MergeCursorPosition\n): void {\n\tlet currentBlocks = ymap.get( 'blocks' );\n\n\tif ( ! ( currentBlocks instanceof Y.Array ) ) {\n\t\tcurrentBlocks = new Y.Array< YBlock >();\n\t\tymap.set( 'blocks', currentBlocks );\n\t}\n\n\tmergeCrdtBlocks(\n\t\tcurrentBlocks,\n\t\tparse( rawContent ) as Block[],\n\t\tcursorPosition,\n\t\t{ preserveClientIds: true }\n\t);\n}\n\n/**\n * Only returns a selection object if it describes a selection within a block, with\n * a cursor inside a RichText field associated with one of that block’s attributes.\n *\n * @param selection Selection object which might represent a selection within a block,\n * within a RichText field associated with a particular attribute of\n * that block, or none at all.\n */\nfunction parseCursorSelection( selection?: WPSelection ): MergeCursorPosition {\n\tconst selectionStart = selection?.selectionStart;\n\n\treturn selectionStart?.clientId &&\n\t\tselectionStart.attributeKey &&\n\t\t'number' === typeof selectionStart.offset &&\n\t\tNumber.isInteger( selectionStart.offset )\n\t\t? {\n\t\t\t\tattributeKey: selectionStart.attributeKey,\n\t\t\t\tclientId: selectionStart.clientId,\n\t\t\t\toffset: asRichTextOffset( selectionStart.offset ),\n\t\t }\n\t\t: null;\n}\n\nfunction defaultGetChangesFromCRDTDoc( crdtDoc: CRDTDoc ): ObjectData {\n\treturn getRootMap( crdtDoc, CRDT_RECORD_MAP_KEY ).toJSON();\n}\n\n/**\n * Given a local Y.Doc that *may* contain changes from remote peers, compare\n * against the local record and determine if there are changes (edits) we want\n * to dispatch.\n *\n * @param {CRDTDoc} ydoc\n * @param {Post} editedRecord\n * @param {Set<string>} syncedProperties\n * @return {Partial<PostChanges>} The changes that should be applied to the local record.\n */\nexport function getPostChangesFromCRDTDoc(\n\tydoc: CRDTDoc,\n\teditedRecord: Post,\n\tsyncedProperties: Set< string >\n): PostChanges {\n\tconst ymap = getRootMap< YPostRecord >( ydoc, CRDT_RECORD_MAP_KEY );\n\n\tlet allowedMetaChanges: Post[ 'meta' ] = {};\n\n\tconst changes = Object.fromEntries(\n\t\tObject.entries( ymap.toJSON() ).filter( ( [ key, newValue ] ) => {\n\t\t\tif ( ! syncedProperties.has( key ) ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tconst currentValue = editedRecord[ key ];\n\n\t\t\tswitch ( key ) {\n\t\t\t\tcase 'blocks': {\n\t\t\t\t\t// When we are passed a persisted CRDT document, make a special\n\t\t\t\t\t// comparison of the content and blocks.\n\t\t\t\t\t//\n\t\t\t\t\t// When other fields (besides `blocks`) are mutated outside the block\n\t\t\t\t\t// editor, the change is caught by an equality check (see other cases\n\t\t\t\t\t// in this `switch` statement). As a transient property, `blocks`\n\t\t\t\t\t// cannot be directly mutated outside the block editor -- only\n\t\t\t\t\t// `content` can.\n\t\t\t\t\t//\n\t\t\t\t\t// Therefore, for this special comparison, we serialize the `blocks`\n\t\t\t\t\t// from the persisted CRDT document and compare that to the content\n\t\t\t\t\t// from the persisted record. If they differ, we know that the content\n\t\t\t\t\t// in the database has changed, and therefore the blocks have changed.\n\t\t\t\t\t//\n\t\t\t\t\t// We cannot directly compare the `blocks` from the CRDT document to\n\t\t\t\t\t// the `blocks` derived from the `content` in the persisted record,\n\t\t\t\t\t// because the latter will have different client IDs.\n\t\t\t\t\tif (\n\t\t\t\t\t\tydoc.meta?.get( CRDT_DOC_META_PERSISTENCE_KEY ) &&\n\t\t\t\t\t\teditedRecord.content\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst blocksJson = ymap.get( 'blocks' )?.toJSON() ?? [];\n\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t__unstableSerializeAndClean( blocksJson ).trim() !==\n\t\t\t\t\t\t\tgetRawValue( editedRecord.content )\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\n\t\t\t\tcase 'date': {\n\t\t\t\t\t// Do not overwrite a \"floating\" date. Borrowing logic from the\n\t\t\t\t\t// isEditedPostDateFloating selector.\n\t\t\t\t\tconst currentDateIsFloating =\n\t\t\t\t\t\tnull === currentValue ||\n\t\t\t\t\t\teditedRecord.modified === currentValue;\n\n\t\t\t\t\tif ( currentDateIsFloating ) {\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn haveValuesChanged( currentValue, newValue );\n\t\t\t\t}\n\n\t\t\t\tcase 'meta': {\n\t\t\t\t\tconst currentMeta =\n\t\t\t\t\t\t( currentValue as PostChanges[ 'meta' ] ) ?? {};\n\n\t\t\t\t\tallowedMetaChanges = Object.fromEntries(\n\t\t\t\t\t\tObject.entries( newValue ?? {} ).filter(\n\t\t\t\t\t\t\t( [ metaKey ] ) => {\n\t\t\t\t\t\t\t\tif ( disallowedPostMetaKeys.has( metaKey ) ) {\n\t\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t// Ignore meta keys that are no longer registered\n\t\t\t\t\t\t\t\t// for this post (absent from the REST response).\n\t\t\t\t\t\t\t\t// Without this, orphaned CRDT meta would mark\n\t\t\t\t\t\t\t\t// the post permanently dirty.\n\t\t\t\t\t\t\t\treturn metaKey in currentMeta;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\n\t\t\t\t\t// Merge the allowed meta changes with the current meta values since\n\t\t\t\t\t// not all meta properties are synced.\n\t\t\t\t\tconst mergedValue = {\n\t\t\t\t\t\t...currentMeta,\n\t\t\t\t\t\t...allowedMetaChanges,\n\t\t\t\t\t};\n\n\t\t\t\t\treturn haveValuesChanged( currentValue, mergedValue );\n\t\t\t\t}\n\n\t\t\t\tcase 'status': {\n\t\t\t\t\t// Do not sync an invalid status.\n\t\t\t\t\tif ( 'auto-draft' === newValue ) {\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn haveValuesChanged( currentValue, newValue );\n\t\t\t\t}\n\n\t\t\t\tcase 'content':\n\t\t\t\tcase 'excerpt':\n\t\t\t\tcase 'title': {\n\t\t\t\t\treturn haveValuesChanged(\n\t\t\t\t\t\tgetRawValue( currentValue ),\n\t\t\t\t\t\tnewValue\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\t// Add support for additional data types here.\n\n\t\t\t\tdefault: {\n\t\t\t\t\treturn haveValuesChanged( currentValue, newValue );\n\t\t\t\t}\n\t\t\t}\n\t\t} )\n\t);\n\n\t// Blocks extracted from the CRDT document have rich-text attributes as\n\t// plain strings (from Y.Text.toJSON()). Convert them back to RichTextData\n\t// so block edit components receive the same types as locally-created blocks.\n\tif ( changes.blocks ) {\n\t\tchanges.blocks = deserializeBlockAttributes(\n\t\t\tchanges.blocks as Block[]\n\t\t);\n\t}\n\n\t// When blocks changed but content didn't (the sender internally used a lazy\n\t// serializer function), inject a closure that captures the synced blocks\n\t// and serializes them on demand. Mirrors what useEntityBlockEditor does\n\t// locally. A fresh function on every persistent edit marks the entity\n\t// dirty (so the save button reactivates for peers), while serialization\n\t// stays lazy (only runs when getEditedPostContent reads it). The closure\n\t// captures `capturedBlocks` so the right content is returned even if the\n\t// caller later clears `record.blocks` (e.g. the Code Editor re-parsing\n\t// from content).\n\tif ( changes.blocks && ! changes.content ) {\n\t\tconst capturedBlocks = changes.blocks;\n\t\tchanges.content = () =>\n\t\t\t__unstableSerializeAndClean( capturedBlocks as WPBlock[] );\n\t}\n\n\t// Meta changes must be merged with the edited record since not all meta\n\t// properties are synced.\n\tif ( 'object' === typeof changes.meta ) {\n\t\tchanges.meta = {\n\t\t\t...editedRecord.meta,\n\t\t\t...allowedMetaChanges,\n\t\t};\n\t}\n\n\t// When remote content changes are detected, recalculate the local user's\n\t// selection using Y.RelativePosition to account for text shifts. The ydoc\n\t// has already been updated with remote content at this point, so converting\n\t// relative positions to absolute gives corrected offsets. Including the\n\t// selection in PostChanges ensures it dispatches atomically with content.\n\tconst selectionHistory = getSelectionHistory( ydoc );\n\tconst shiftedSelection = getShiftedSelection( ydoc, selectionHistory );\n\tif ( shiftedSelection ) {\n\t\tchanges.selection = {\n\t\t\t...shiftedSelection,\n\t\t\tinitialPosition: 0,\n\t\t};\n\t}\n\n\treturn changes;\n}\n\n/**\n * This default sync config can be used for entities that are flat maps of\n * primitive values and do not require custom logic to merge changes.\n */\nexport const defaultSyncConfig: SyncConfig = {\n\tapplyChangesToCRDTDoc: defaultApplyChangesToCRDTDoc,\n\tcreateAwareness: ( ydoc: CRDTDoc ) => new BaseAwareness( ydoc ),\n\tgetChangesFromCRDTDoc: defaultGetChangesFromCRDTDoc,\n};\n\n/**\n * This default collection sync config can be used to sync entity collections\n * (e.g., block comments) where we are not interested in merging changes at the\n * individual record level, but instead want to replace the entire collection\n * when changes are detected.\n */\nexport const defaultCollectionSyncConfig: SyncConfig = {\n\tapplyChangesToCRDTDoc: () => {},\n\tgetChangesFromCRDTDoc: () => ( {} ),\n\tshouldSync: ( _: ObjectType, objectId: ObjectID | null ) =>\n\t\tnull === objectId,\n};\n\n/**\n * Extract the raw string value from a property that may be a string or an object\n * with a `raw` property (`RenderedText`).\n *\n * @param {unknown} value The value to extract from.\n * @return {string|undefined} The raw string value, or undefined if it could not be determined.\n */\nfunction getRawValue( value?: unknown ): string | undefined {\n\t// Value may be a string property or a nested object with a `raw` property.\n\tif ( 'string' === typeof value ) {\n\t\treturn value;\n\t}\n\n\tif (\n\t\tvalue &&\n\t\t'object' === typeof value &&\n\t\t'raw' in value &&\n\t\t'string' === typeof value.raw\n\t) {\n\t\treturn value.raw;\n\t}\n\n\treturn undefined;\n}\n\nfunction haveValuesChanged< ValueType >(\n\tcurrentValue: ValueType | undefined,\n\tnewValue: ValueType | undefined\n): boolean {\n\treturn ! fastDeepEqual( currentValue, newValue );\n}\n\nfunction updateMapValue< T extends YMapRecord, K extends keyof T >(\n\tmap: YMapWrap< T >,\n\tkey: K,\n\tcurrentValue: T[ K ] | undefined,\n\tnewValue: T[ K ] | undefined\n): void {\n\tif ( undefined === newValue ) {\n\t\tmap.delete( key );\n\t\treturn;\n\t}\n\n\tif ( haveValuesChanged< T[ K ] >( currentValue, newValue ) ) {\n\t\tmap.set( key, newValue );\n\t}\n}\n"],
5
5
  "mappings": ";AAGA,OAAO,mBAAmB;AAK1B;AAAA,EACC;AAAA,EACA;AAAA,OAEM;AACP;AAAA,EAMC;AAAA,OACM;AAKP,SAAS,qBAAqB;AAC9B;AAAA,EAEC;AAAA,EACA;AAAA,EAEA;AAAA,OAGM;AAEP,SAAS,+BAA+B,2BAA2B;AAEnE;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAGM;AAuCA,IAAM,yCAAyC;AAGtD,IAAM,yBAAyB,oBAAI,IAAe;AAAA,EACjD;AACD,CAAE;AAUF,SAAS,6BACR,MACA,SACO;AACP,QAAM,OAAO,WAAY,MAAM,mBAAoB;AAEnD,SAAO,QAAS,OAAQ,EAAE,QAAS,CAAE,CAAE,KAAK,QAAS,MAAO;AAE3D,QAAK,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,uBAAuB;AAAA,EACvB,iBAAiB,CAAE,SAAmB,IAAI,cAAe,IAAK;AAAA,EAC9D,uBAAuB;AACxB;AAQO,IAAM,8BAA0C;AAAA,EACtD,uBAAuB,MAAM;AAAA,EAAC;AAAA,EAC9B,uBAAuB,OAAQ,CAAC;AAAA,EAChC,YAAY,CAAE,GAAe,aAC5B,SAAS;AACX;AASA,SAAS,YAAa,OAAsC;AAE3D,MAAK,aAAa,OAAO,OAAQ;AAChC,WAAO;AAAA,EACR;AAEA,MACC,SACA,aAAa,OAAO,SACpB,SAAS,SACT,aAAa,OAAO,MAAM,KACzB;AACD,WAAO,MAAM;AAAA,EACd;AAEA,SAAO;AACR;AAEA,SAAS,kBACR,cACA,UACU;AACV,SAAO,CAAE,cAAe,cAAc,QAAS;AAChD;AAEA,SAAS,eACR,KACA,KACA,cACA,UACO;AACP,MAAK,WAAc,UAAW;AAC7B,QAAI,OAAQ,GAAI;AAChB;AAAA,EACD;AAEA,MAAK,kBAA6B,cAAc,QAAS,GAAI;AAC5D,QAAI,IAAK,KAAK,QAAS;AAAA,EACxB;AACD;",
6
6
  "names": []
7
7
  }
@@ -1,36 +1,38 @@
1
1
  // packages/core-data/src/utils/index.js
2
- import { default as default2 } from "./conservative-map-item.mjs";
3
- import { default as default3 } from "./get-normalized-comma-separable.mjs";
4
- import { default as default4 } from "./if-matching-action.mjs";
5
- import { default as default5 } from "./forward-resolver.mjs";
6
- import { default as default6 } from "./replace-action.mjs";
7
- import { default as default7 } from "./with-weak-map-cache.mjs";
8
- import { default as default8 } from "./set-nested-value.mjs";
9
- import { default as default9 } from "./get-nested-value.mjs";
10
- import { default as default10 } from "./is-numeric-id.mjs";
2
+ import { default as default2 } from "./clear-unchanged-edits.mjs";
3
+ import { default as default3 } from "./conservative-map-item.mjs";
4
+ import { default as default4 } from "./get-normalized-comma-separable.mjs";
5
+ import { default as default5 } from "./if-matching-action.mjs";
6
+ import { default as default6 } from "./forward-resolver.mjs";
7
+ import { default as default7 } from "./replace-action.mjs";
8
+ import { default as default8 } from "./with-weak-map-cache.mjs";
9
+ import { default as default9 } from "./set-nested-value.mjs";
10
+ import { default as default10 } from "./get-nested-value.mjs";
11
+ import { default as default11 } from "./is-numeric-id.mjs";
11
12
  import {
12
13
  getUserPermissionCacheKey,
13
14
  getUserPermissionsFromAllowHeader,
14
15
  ALLOWED_RESOURCE_ACTIONS
15
16
  } from "./user-permissions.mjs";
16
17
  import { RECEIVE_INTERMEDIATE_RESULTS } from "./receive-intermediate-results.mjs";
17
- import { default as default11 } from "./normalize-query-for-resolution.mjs";
18
+ import { default as default12 } from "./normalize-query-for-resolution.mjs";
18
19
  import { saveCRDTDoc } from "./save-crdt-doc.mjs";
19
20
  export {
20
21
  ALLOWED_RESOURCE_ACTIONS,
21
22
  RECEIVE_INTERMEDIATE_RESULTS,
22
- default2 as conservativeMapItem,
23
- default5 as forwardResolver,
24
- default9 as getNestedValue,
25
- default3 as getNormalizedCommaSeparable,
23
+ default2 as clearUnchangedEdits,
24
+ default3 as conservativeMapItem,
25
+ default6 as forwardResolver,
26
+ default10 as getNestedValue,
27
+ default4 as getNormalizedCommaSeparable,
26
28
  getUserPermissionCacheKey,
27
29
  getUserPermissionsFromAllowHeader,
28
- default4 as ifMatchingAction,
29
- default10 as isNumericID,
30
- default11 as normalizeQueryForResolution,
31
- default6 as replaceAction,
30
+ default5 as ifMatchingAction,
31
+ default11 as isNumericID,
32
+ default12 as normalizeQueryForResolution,
33
+ default7 as replaceAction,
32
34
  saveCRDTDoc,
33
- default8 as setNestedValue,
34
- default7 as withWeakMapCache
35
+ default9 as setNestedValue,
36
+ default8 as withWeakMapCache
35
37
  };
36
38
  //# sourceMappingURL=index.mjs.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/utils/index.js"],
4
- "sourcesContent": ["export { default as conservativeMapItem } from './conservative-map-item';\nexport { default as getNormalizedCommaSeparable } from './get-normalized-comma-separable';\nexport { default as ifMatchingAction } from './if-matching-action';\nexport { default as forwardResolver } from './forward-resolver';\nexport { default as replaceAction } from './replace-action';\nexport { default as withWeakMapCache } from './with-weak-map-cache';\nexport { default as setNestedValue } from './set-nested-value';\nexport { default as getNestedValue } from './get-nested-value';\nexport { default as isNumericID } from './is-numeric-id';\nexport {\n\tgetUserPermissionCacheKey,\n\tgetUserPermissionsFromAllowHeader,\n\tALLOWED_RESOURCE_ACTIONS,\n} from './user-permissions';\nexport { RECEIVE_INTERMEDIATE_RESULTS } from './receive-intermediate-results';\nexport { default as normalizeQueryForResolution } from './normalize-query-for-resolution';\nexport { saveCRDTDoc } from './save-crdt-doc';\n"],
5
- "mappings": ";AAAA,SAAoB,WAAXA,gBAAsC;AAC/C,SAAoB,WAAXA,gBAA8C;AACvD,SAAoB,WAAXA,gBAAmC;AAC5C,SAAoB,WAAXA,gBAAkC;AAC3C,SAAoB,WAAXA,gBAAgC;AACzC,SAAoB,WAAXA,gBAAmC;AAC5C,SAAoB,WAAXA,gBAAiC;AAC1C,SAAoB,WAAXA,gBAAiC;AAC1C,SAAoB,WAAXA,iBAA8B;AACvC;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,oCAAoC;AAC7C,SAAoB,WAAXA,iBAA8C;AACvD,SAAS,mBAAmB;",
4
+ "sourcesContent": ["export { default as clearUnchangedEdits } from './clear-unchanged-edits';\nexport { default as conservativeMapItem } from './conservative-map-item';\nexport { default as getNormalizedCommaSeparable } from './get-normalized-comma-separable';\nexport { default as ifMatchingAction } from './if-matching-action';\nexport { default as forwardResolver } from './forward-resolver';\nexport { default as replaceAction } from './replace-action';\nexport { default as withWeakMapCache } from './with-weak-map-cache';\nexport { default as setNestedValue } from './set-nested-value';\nexport { default as getNestedValue } from './get-nested-value';\nexport { default as isNumericID } from './is-numeric-id';\nexport {\n\tgetUserPermissionCacheKey,\n\tgetUserPermissionsFromAllowHeader,\n\tALLOWED_RESOURCE_ACTIONS,\n} from './user-permissions';\nexport { RECEIVE_INTERMEDIATE_RESULTS } from './receive-intermediate-results';\nexport { default as normalizeQueryForResolution } from './normalize-query-for-resolution';\nexport { saveCRDTDoc } from './save-crdt-doc';\n"],
5
+ "mappings": ";AAAA,SAAoB,WAAXA,gBAAsC;AAC/C,SAAoB,WAAXA,gBAAsC;AAC/C,SAAoB,WAAXA,gBAA8C;AACvD,SAAoB,WAAXA,gBAAmC;AAC5C,SAAoB,WAAXA,gBAAkC;AAC3C,SAAoB,WAAXA,gBAAgC;AACzC,SAAoB,WAAXA,gBAAmC;AAC5C,SAAoB,WAAXA,gBAAiC;AAC1C,SAAoB,WAAXA,iBAAiC;AAC1C,SAAoB,WAAXA,iBAA8B;AACvC;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,oCAAoC;AAC7C,SAAoB,WAAXA,iBAA8C;AACvD,SAAS,mBAAmB;",
6
6
  "names": ["default"]
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/utils/set-nested-value.js"],
4
- "sourcesContent": ["/**\n * Sets the value at path of object.\n * If a portion of path doesn\u2019t exist, it\u2019s created.\n * Arrays are created for missing index properties while objects are created\n * for all other missing properties.\n *\n * Path is specified as either:\n * - a string of properties, separated by dots, for example: \"x.y\".\n * - an array of properties, for example `[ 'x', 'y' ]`.\n *\n * This function intentionally mutates the input object.\n *\n * Inspired by _.set().\n *\n * @see https://lodash.com/docs/4.17.15#set\n *\n * @todo Needs to be deduplicated with its copy in `@wordpress/edit-site`.\n *\n * @param {Object} object Object to modify\n * @param {Array|string} path Path of the property to set.\n * @param {*} value Value to set.\n */\nexport default function setNestedValue( object, path, value ) {\n\tif ( ! object || typeof object !== 'object' ) {\n\t\treturn object;\n\t}\n\n\tconst normalizedPath = Array.isArray( path ) ? path : path.split( '.' );\n\n\tnormalizedPath.reduce( ( acc, key, idx ) => {\n\t\tif ( acc[ key ] === undefined ) {\n\t\t\tif ( Number.isInteger( normalizedPath[ idx + 1 ] ) ) {\n\t\t\t\tacc[ key ] = [];\n\t\t\t} else {\n\t\t\t\tacc[ key ] = {};\n\t\t\t}\n\t\t}\n\t\tif ( idx === normalizedPath.length - 1 ) {\n\t\t\tacc[ key ] = value;\n\t\t}\n\t\treturn acc[ key ];\n\t}, object );\n\n\treturn object;\n}\n"],
4
+ "sourcesContent": ["/**\n * Sets the value at path of object.\n * If a portion of path doesn’t exist, it’s created.\n * Arrays are created for missing index properties while objects are created\n * for all other missing properties.\n *\n * Path is specified as either:\n * - a string of properties, separated by dots, for example: \"x.y\".\n * - an array of properties, for example `[ 'x', 'y' ]`.\n *\n * This function intentionally mutates the input object.\n *\n * Inspired by _.set().\n *\n * @see https://lodash.com/docs/4.17.15#set\n *\n * @todo Needs to be deduplicated with its copy in `@wordpress/edit-site`.\n *\n * @param {Object} object Object to modify\n * @param {Array|string} path Path of the property to set.\n * @param {*} value Value to set.\n */\nexport default function setNestedValue( object, path, value ) {\n\tif ( ! object || typeof object !== 'object' ) {\n\t\treturn object;\n\t}\n\n\tconst normalizedPath = Array.isArray( path ) ? path : path.split( '.' );\n\n\tnormalizedPath.reduce( ( acc, key, idx ) => {\n\t\tif ( acc[ key ] === undefined ) {\n\t\t\tif ( Number.isInteger( normalizedPath[ idx + 1 ] ) ) {\n\t\t\t\tacc[ key ] = [];\n\t\t\t} else {\n\t\t\t\tacc[ key ] = {};\n\t\t\t}\n\t\t}\n\t\tif ( idx === normalizedPath.length - 1 ) {\n\t\t\tacc[ key ] = value;\n\t\t}\n\t\treturn acc[ key ];\n\t}, object );\n\n\treturn object;\n}\n"],
5
5
  "mappings": ";AAsBe,SAAR,eAAiC,QAAQ,MAAM,OAAQ;AAC7D,MAAK,CAAE,UAAU,OAAO,WAAW,UAAW;AAC7C,WAAO;AAAA,EACR;AAEA,QAAM,iBAAiB,MAAM,QAAS,IAAK,IAAI,OAAO,KAAK,MAAO,GAAI;AAEtE,iBAAe,OAAQ,CAAE,KAAK,KAAK,QAAS;AAC3C,QAAK,IAAK,GAAI,MAAM,QAAY;AAC/B,UAAK,OAAO,UAAW,eAAgB,MAAM,CAAE,CAAE,GAAI;AACpD,YAAK,GAAI,IAAI,CAAC;AAAA,MACf,OAAO;AACN,YAAK,GAAI,IAAI,CAAC;AAAA,MACf;AAAA,IACD;AACA,QAAK,QAAQ,eAAe,SAAS,GAAI;AACxC,UAAK,GAAI,IAAI;AAAA,IACd;AACA,WAAO,IAAK,GAAI;AAAA,EACjB,GAAG,MAAO;AAEV,SAAO;AACR;",
6
6
  "names": []
7
7
  }
@@ -1 +1 @@
1
- {"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../src/actions.js"],"names":[],"mappings":"AAgCA;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAE,OAAO,EAL9B,MAK8B,EAAE,KAAK,EAJrC,WAIqC,OAM/C;AAED;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAAE,WAAW,KAAA,OAK9C;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAE,QAAQ,OAAA,OAKpC;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CACnC,IAAI,EAVM,MAUN,EACJ,IAAI,EAVM,MAUN,EACJ,OAAO,EAVG,WAUH,EACP,KAAK,GAVK,UAUO,EACjB,eAAe,GAVJ,OAAO,OAUK,EACvB,KAAK,GAVK,UAUO,EACjB,IAAI,GAVM,UAUM,OAsBhB;AAED;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CAAE,YAAY,KAAA,OAKhD;AAED;;;;;;;;;GASG;AACH,wBAAgB,0CAA0C,CACzD,qBAAqB,EALX,MAKW,OAMrB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,0CAA0C,CACzD,UAAU,EANA,MAMA,EACV,YAAY,KAAA,OAOZ;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,+CAA+C,CAC9D,UAAU,EANA,MAMA,EACV,UAAU,OAAA,OAOV;AAED;;;;;;GAMG;AACH,wBAAg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AM,KAEL,MAMX,CAAC"}
1
+ {"version":3,"file":"entities.d.ts","sourceRoot":"","sources":["../src/entities.js"],"names":[],"mappings":"AAyBA,eAAO,MAAM,kBAAkB,OAAO,CAAC;AAYvC,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAoEX,MAAM;;;;;;;;;;;;;;;;;;;QAUN,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAsIzB,CAAC;AAEF,eAAO,MAAM,kBAAkB;IAC9B,IAAI;QACH,KAAK;YACJ,KAAK;YACL,WAAW;gBACV,IAAI;gBACJ,IAAI;;;;CAIP,CAAC;AAEF,eAAO,MAAM,6BAA6B;;;;;;;;;;IASzC,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB,2CAJpB,MAAM,cACN,OAAO,KACN,OAAO,KAgDlB,CAAC;AAEF;;;;GAIG;AACH,iBAAe,oBAAoB,IAFvB,OAAO,CA6IlB;AA6BD;;;;GAIG;AACH,iBAAe,cAAc,IAFjB,OAAO,CA6BlB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,aAAa,SANf,MAAM,QACN,MAAM,WACN,MAAM,KAEL,MAMX,CAAC"}
@@ -18,6 +18,10 @@ export interface EntityRecordResolution<RecordType> {
18
18
  * Does the record have any local edits?
19
19
  */
20
20
  hasEdits: boolean;
21
+ /**
22
+ * Has the resolution started?
23
+ */
24
+ hasStarted: boolean;
21
25
  /**
22
26
  * Is the record resolved by now?
23
27
  */
@@ -101,7 +105,6 @@ export interface Options {
101
105
  * return (
102
106
  * <form onSubmit={ onRename }>
103
107
  * <TextControl
104
- * __next40pxDefaultSize
105
108
  * label={ __( 'Name' ) }
106
109
  * value={ page.editedRecord.title }
107
110
  * onChange={ setTitle }
@@ -1 +1 @@
1
- {"version":3,"file":"use-entity-record.d.ts","sourceRoot":"","sources":["../../src/hooks/use-entity-record.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C,MAAM,WAAW,sBAAsB,CAAE,UAAU;IAClD,kCAAkC;IAClC,MAAM,EAAE,UAAU,GAAG,IAAI,CAAC;IAE1B,+BAA+B;IAC/B,YAAY,EAAE,OAAO,CAAE,UAAU,CAAE,CAAC;IAEpC,4CAA4C;IAC5C,KAAK,EAAE,OAAO,CAAE,UAAU,CAAE,CAAC;IAE7B,iEAAiE;IACjE,IAAI,EAAE,CAAE,IAAI,EAAE,OAAO,CAAE,UAAU,CAAE,KAAM,IAAI,CAAC;IAE9C,sCAAsC;IACtC,IAAI,EAAE,MAAM,OAAO,CAAE,IAAI,CAAE,CAAC;IAE5B;;OAEG;IACH,WAAW,EAAE,OAAO,CAAC;IAErB;;OAEG;IACH,QAAQ,EAAE,OAAO,CAAC;IAElB;;OAEG;IACH,WAAW,EAAE,OAAO,CAAC;IAErB,wBAAwB;IACxB,MAAM,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,OAAO;IACvB;;;;OAIG;IACH,OAAO,EAAE,OAAO,CAAC;CACjB;AAID;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwFG;AACH,MAAM,CAAC,OAAO,UAAU,eAAe,CAAE,UAAU,EAClD,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,GAAG,MAAM,EACzB,OAAO,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E,MAAM,GAAG,MAAM,EACzB,OAAO,GAAE,OAA2B,GAClC,sBAAsB,CAAE,UAAU,CAAE,CAsEtC;AAED,wBAAgB,yBAAyB,CACxC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,GAAG,EACb,OAAO,EAAE,GAAG,mCAOZ"}
@@ -1,12 +1,16 @@
1
1
  import type { Options } from './use-entity-record';
2
2
  import type { Status } from './constants';
3
- interface EntityRecordsResolution<RecordType> {
3
+ export interface EntityRecordsResolution<RecordType> {
4
4
  /** The requested entity records */
5
5
  records: RecordType[] | null;
6
6
  /**
7
7
  * Is the record still being resolved?
8
8
  */
9
9
  isResolving: boolean;
10
+ /**
11
+ * Has the resolution started?
12
+ */
13
+ hasStarted: boolean;
10
14
  /**
11
15
  * Is the record resolved by now?
12
16
  */
@@ -1 +1 @@
1
- {"version":3,"file":"use-entity-records.d.ts","sourceRoot":"","sources":["../../src/hooks/use-entity-records.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAI1C,UAAU,uBAAuB,CAAE,UAAU;IAC5C,mCAAmC;IACnC,OAAO,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC;IAE7B;;OAEG;IACH,WAAW,EAAE,OAAO,CAAC;IAErB;;OAEG;IACH,WAAW,EAAE,OAAO,CAAC;IAErB,wBAAwB;IACxB,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAE1B;;OAEG;IACH,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAED,MAAM,MAAM,eAAe,CAAE,UAAU,IAAK,UAAU,GAAG;IACxD,WAAW,EAAE;QAAE,MAAM,EAAE,OAAO,CAAC;QAAC,MAAM,EAAE,OAAO,CAAA;KAAE,CAAC;CAClD,CAAC;AAE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IACxB,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAE1B;;OAEG;IACH,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAED,MAAM,MAAM,eAAe,CAAE,UAAU,IAAK,UAAU,GAAG;IACxD,WAAW,EAAE;QAAE,MAAM,EAAE,OAAO,CAAC;QAAC,MAAM,EAAE,OAAO,CAAA;KAAE,CAAC;CAClD,CAAC;AAEF,UAAU,sCAAsC,CAAE,UAAU,CAC3D,SAAQ,IAAI,CAAE,uBAAuB,CAAE,UAAU,CAAE,EAAE,SAAS,CAAE;IAChE,oDAAoD;IACpD,OAAO,EAAE,eAAe,CAAE,UAAU,CAAE,EAAE,GAAG,IAAI,CAAC;CAChD;AAID;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAE,UAAU,EACnD,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,SAAS,GAAE,MAAM,CAAE,MAAM,EAAE,OAAO,CAAO,EACzC,OAAO,GAAE,OAA2B,GAClC,uBAAuB,CAAE,UAAU,CAAE,CAqDvC;AAED,wBAAgB,0BAA0B,CACzC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,GAAG,EACd,OAAO,EAAE,GAAG,oCAOZ;AAED,wBAAgB,+BAA+B,CAAE,UAAU,EAC1D,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,SAAS,GAAE,MAAM,CAAE,MAAM,EAAE,OAAO,CAAO,EACzC,OAAO,GAAE,OAA2B,GAClC,sCAAsC,CAAE,UAAU,CAAE,CAwDtD"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import type { ResolutionStatus } from '@wordpress/data';
5
+ /**
6
+ * Internal dependencies
7
+ */
8
+ import { Status } from './constants';
9
+ /**
10
+ * Normalizes a resolution status from the store into the resolution info
11
+ * shared by the entity record hooks and `useQuerySelect`.
12
+ *
13
+ * @param resolutionStatus Status returned by the `getResolutionState` selector.
14
+ * @return Resolution info object.
15
+ */
16
+ export declare function getResolutionStatus(resolutionStatus?: ResolutionStatus): {
17
+ status: Status;
18
+ isResolving: boolean;
19
+ hasStarted: boolean;
20
+ hasResolved: boolean;
21
+ };
22
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/hooks/utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAExD;;GAEG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAE,gBAAgB,CAAC,EAAE,gBAAgB;;;;;EAsBvE"}
@@ -230,15 +230,15 @@ export declare const store: import("@wordpress/data").StoreDescriptor<import("@w
230
230
  };
231
231
  getAuthors(state: selectors.State, query?: selectors.GetRecordsHttpQuery): import("./entity-types").User[];
232
232
  getCurrentUser(state: selectors.State): import("./entity-types").User<'view'>;
233
- getUserQueryResults: ((state: selectors.State, queryID: string) => import("./entity-types").User<'edit'>[]) & import("rememo").EnhancedSelector;
233
+ getUserQueryResults: ((state: selectors.State, queryID: string) => import("./entity-types").User<'edit'>[]) & import("@wordpress/data").EnhancedSelector;
234
234
  getEntitiesByKind(state: selectors.State, kind: string): Array<any>;
235
- getEntitiesConfig: ((state: selectors.State, kind: string) => Array<any>) & import("rememo").EnhancedSelector;
235
+ getEntitiesConfig: ((state: selectors.State, kind: string) => Array<any>) & import("@wordpress/data").EnhancedSelector;
236
236
  getEntity(state: selectors.State, kind: string, name: string): any;
237
237
  getEntityConfig(state: selectors.State, kind: string, name: string): any;
238
238
  getEntityRecord: selectors.GetEntityRecord;
239
239
  hasEntityRecord(state: selectors.State, kind: string, name: string, key?: string | number, query?: selectors.GetRecordsHttpQuery): boolean;
240
240
  __experimentalGetEntityRecordNoResolver<EntityRecord extends import("./entity-types").EntityRecord<any>>(state: selectors.State, kind: string, name: string, key: string | number): EntityRecord | undefined;
241
- getRawEntityRecord: (<EntityRecord extends import("./entity-types").EntityRecord<any>>(state: selectors.State, kind: string, name: string, key: string | number) => EntityRecord | undefined) & import("rememo").EnhancedSelector;
241
+ getRawEntityRecord: (<EntityRecord extends import("./entity-types").EntityRecord<any>>(state: selectors.State, kind: string, name: string, key: string | number) => EntityRecord | undefined) & import("@wordpress/data").EnhancedSelector;
242
242
  hasEntityRecords(state: selectors.State, kind: string, name: string, query?: selectors.GetRecordsHttpQuery): boolean;
243
243
  getEntityRecords: selectors.GetEntityRecords;
244
244
  getEntityRecordsTotalItems: (state: selectors.State, kind: string, name: string, query: selectors.GetRecordsHttpQuery) => number | null;
@@ -248,17 +248,17 @@ export declare const store: import("@wordpress/data").StoreDescriptor<import("@w
248
248
  key: string | number;
249
249
  name: string;
250
250
  kind: string;
251
- }>) & import("rememo").EnhancedSelector;
251
+ }>) & import("@wordpress/data").EnhancedSelector;
252
252
  __experimentalGetEntitiesBeingSaved: ((state: selectors.State) => Array<{
253
253
  title: string;
254
254
  key: string | number;
255
255
  name: string;
256
256
  kind: string;
257
- }>) & import("rememo").EnhancedSelector;
257
+ }>) & import("@wordpress/data").EnhancedSelector;
258
258
  getEntityRecordEdits(state: selectors.State, kind: string, name: string, recordId: string | number): any;
259
- getEntityRecordNonTransientEdits: ((state: selectors.State, kind: string, name: string, recordId: string | number) => any) & import("rememo").EnhancedSelector;
259
+ getEntityRecordNonTransientEdits: ((state: selectors.State, kind: string, name: string, recordId: string | number) => any) & import("@wordpress/data").EnhancedSelector;
260
260
  hasEditsForEntityRecord(state: selectors.State, kind: string, name: string, recordId: string | number): boolean;
261
- getEditedEntityRecord: (<EntityRecord extends import("./entity-types").EntityRecord<any>>(state: selectors.State, kind: string, name: string, recordId: string | number) => import("./entity-types").Updatable<EntityRecord> | false) & import("rememo").EnhancedSelector;
261
+ getEditedEntityRecord: (<EntityRecord extends import("./entity-types").EntityRecord<any>>(state: selectors.State, kind: string, name: string, recordId: string | number) => import("./entity-types").Updatable<EntityRecord> | false) & import("@wordpress/data").EnhancedSelector;
262
262
  isAutosavingEntityRecord(state: selectors.State, kind: string, name: string, recordId: string | number): boolean;
263
263
  isSavingEntityRecord(state: selectors.State, kind: string, name: string, recordId: string | number): boolean;
264
264
  isDeletingEntityRecord(state: selectors.State, kind: string, name: string, recordId: string | number): boolean;
@@ -300,7 +300,7 @@ export declare const store: import("@wordpress/data").StoreDescriptor<import("@w
300
300
  }): string;
301
301
  getRevisions: (state: selectors.State, kind: string, name: string, recordKey: string | number, query?: selectors.GetRecordsHttpQuery) => (Record<import("./entity-types").Context, Record<number, import("./entity-types").GlobalStylesRevision>> | Record<import("./entity-types").Context, Record<number, import("./entity-types").PostRevision>>)[] | null;
302
302
  hasRevision(state: selectors.State, kind: string, name: string, recordKey: string | number, revisionKey: string | number, query?: selectors.GetRecordsHttpQuery): boolean;
303
- getRevision: ((state: selectors.State, kind: string, name: string, recordKey: string | number, revisionKey: string | number, query?: selectors.GetRecordsHttpQuery) => (Record<import("./entity-types").Context, Record<number, import("./entity-types").GlobalStylesRevision>> | Record<import("./entity-types").Context, Record<number, import("./entity-types").PostRevision>>) | Record<PropertyKey, never> | undefined) & import("rememo").EnhancedSelector;
303
+ getRevision: ((state: selectors.State, kind: string, name: string, recordKey: string | number, revisionKey: string | number, query?: selectors.GetRecordsHttpQuery) => (Record<import("./entity-types").Context, Record<number, import("./entity-types").GlobalStylesRevision>> | Record<import("./entity-types").Context, Record<number, import("./entity-types").PostRevision>>) | Record<PropertyKey, never> | undefined) & import("@wordpress/data").EnhancedSelector;
304
304
  getComment: (state: selectors.State, id: number | string, query?: selectors.GetRecordsHttpQuery) => import("./entity-types").Comment<"edit"> | undefined;
305
305
  getComments: (state: selectors.State, query?: selectors.GetRecordsHttpQuery) => import("./entity-types").Comment<"edit">[] | null;
306
306
  getGlobalStyles: (state: selectors.State, id: number | string, query?: selectors.GetRecordsHttpQuery) => import("./entity-types").GlobalStylesRevision<"edit"> | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"private-actions.d.ts","sourceRoot":"","sources":["../src/private-actions.js"],"names":[],"mappings":"AAWA;;;;;;;;GAQG;AACH,wBAAgB,yBAAyB,CAAE,QAAQ,EALxC,MAKwC,EAAE,kBAAkB,KAAA,OAMtE;AAGE,YAAkB,QAAQ,GAC1B;IAAoB,IAAI,AAAxB,CACA,EADW,MAAM,CACjB;IAAoB,IAAI,AAAxB,CACF,MAAA;CAAA,CAAA;AAGE,YAAkB,KAAK,GACvB;IAAwB,GAAG,AAA3B,CACA,EADW,MAAM,CACjB;IAAwB,SAAS,AAAjC,CACF,EADa,QAAQ,EAAE,CACvB;CAAA,CAAA;AAVD;;;;GAIG;AAEH;;;;GAIG;AAEH;;;;;;;;;;GAUG;AACH,eAAO,MAAM,eAAe,aARjB,MAAM,UACN,KAAK,sCAEb;IAA0B,eAAe,WACzC;IAA0B,YAAY,EAA9B,OAAO,CAEf;CAAA,KAAS,OAqFV,CAAC;AAEH;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAE,QAAQ,KAAA,OAK9C;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAE,MAAM,KAAA,OAK1C;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,yBAAyB,cAJ3B,OAAO,QAWhB,CAAC;AAEH;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAE,IAAI,EAN5B,MAM4B,EAAE,IAAI,EALlC,MAKkC,EAAE,MAAM,KAAA,OAOpD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,qCAAqC,CAAE,KAAK,EALzD;IAAuB,OAAO,EAAtB,OAAO,CACf;IAAuB,OAAO,EAAtB,OAAO,CAEf;CAEyD,OAK3D;AAED;;;;;;;;;GASG;AACH,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wBAAgB,uBAAuB,CAAE,IAAI,EAPlC,MAOkC,EAAE,IAAI,EANxC,MAMwC,EAAE,GAAG,EAL7C,MAAM,GAAC,MAAM,GAAC,IAK+B,EAAE,MAAM,EAJrD,MAAO,IAI8C,OAiB/D"}
@@ -98,6 +98,12 @@ export declare function isCollaborationSupported(state: State): boolean;
98
98
  /**
99
99
  * Returns the view configuration for the given entity type.
100
100
  *
101
+ * An optional fourth argument (e.g. `{ fields }`) may be passed when selecting;
102
+ * it is consumed by the `getViewConfig` resolver to request a subset of the
103
+ * config via the REST API `_fields` parameter and does not affect what is read
104
+ * here. Partial responses are merged in the reducer, so the returned object may
105
+ * accumulate properties across requests for the same entity.
106
+ *
101
107
  * @param state Data state.
102
108
  * @param kind Entity kind.
103
109
  * @param name Entity name.
@@ -1 +1 @@
1
- {"version":3,"file":"private-selectors.d.ts","sourceRoot":"","sources":["../src/private-selectors.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAExD;;GAEG;AACH,OAAO,EAAyC,KAAK,KAAK,EAAE,MAAM,aAAa,CAAC;AAMhF,KAAK,eAAe,GAAG,MAAM,GAAG,MAAM,CAAC;AAIvC;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAE,KAAK,EAAE,KAAK,6FAG3C;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CACtC,KAAK,EAAE,KAAK,GACV,eAAe,GAAG,SAAS,CAE7B;AAED,eAAO,MAAM,2BAA2B;;;;CAcvC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,2BAA2B;;;;;;;CAwBvC,CAAC;AAEF;;;;;;;;;GASG;AACH,wBAAgB,0BAA0B,CACzC,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM;;;EAIV;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAE,KAAK,EAAE,KAAK,EA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M,KAAA,OAelD;AAED;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAE,KAAK,KAAK,EAAE,MAAM,KAAA,OAY5C;AAED,wBAAgB,aAAa,CAAE,KAAK,iCAAK,EAAE,MAAM,KAAA,OAOhD;AAED,wBAAgB,sBAAsB,CAAE,KAAK,iCAAK,EAAE,MAAM,KAAA,OAOzD;AAED,wBAAgB,qBAAqB,CAAE,KAAK,iCAAK,EAAE,MAAM,KAAA,OAMxD;AAED,wBAAgB,oBAAoB,CAAE,KAAK,kBAAO,EAAE,MAAM,KAAA,OAOzD;AAED;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CAAE,KAAK,EALrC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,YAKoB,EAAE,MAAM,KAAA,0BAU5D;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAE,KAAK,EAL5B,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,YAKW,EAAE,MAAM,KAAA,0BAUnD;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAE,KAAK,KAAK,EAAE,MAAM,KAAA,OASrD;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAE,KAAK,KAAO,EAAE,MAAM,KAAA,OAMnD;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAE,KAAK,KAAO,EAAE,MAAM,KAAA,OAMjD;AAED;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CAAE,KAAK,KAAK,EAAE,MAAM,KAAA,OAgBzD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,sBAAsB,CAAE,KAAK,EALlC,OAAO,YAKkC,EAAE,MAAM,KAAA,GAFhD,OAAO,CAkBlB;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAE,KAAK,KAAK,EAAE,MAAM,KAAA,OAgB9C"}
@@ -211,10 +211,15 @@ export declare const getEditorAssets: () => ({ dispatch }: {
211
211
  /**
212
212
  * Requests view config for a given entity type from the REST API.
213
213
  *
214
- * @param {string} kind Entity kind.
215
- * @param {string} name Entity name.
216
- */
217
- export declare const getViewConfig: (kind: string, name: string) => ({ dispatch }: {
214
+ * @param {string} kind Entity kind.
215
+ * @param {string} name Entity name.
216
+ * @param {?Object} options Optional options.
217
+ * @param {?string[]} options.fields Optional subset of top-level config
218
+ * properties to request, mapped to the REST
219
+ * API `_fields` parameter. When omitted, the
220
+ * full config is requested.
221
+ */
222
+ export declare const getViewConfig: (kind: string, name: string, options?: any | null) => ({ dispatch }: {
218
223
  dispatch: any;
219
224
  }) => Promise<void>;
220
225
  //# sourceMappingURL=resolvers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"resolvers.d.ts","sourceRoot":"","sources":["../src/resolvers.js"],"names":[],"mappings":"AAiCA;;;;;GAKG;AACH,eAAO,MAAM,UAAU,UAHZ,MAAO,SAAS;;mBAYzB,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,cAAc;;mBAKzB,CAAC;wCAaA,IAAI,EARI,MAQJ,EAAE,IAAI,EAPF,MAOE,EAAE,GAAG,GANP,MAAM,GAAC,MAAM,aAMD,EAAE,KAAK,EALnB,MAAO,SAKY;;;;;;;;;AAiR9B;;GAEG;AACH,eAAO,MAAM,kBAAkB,UAAuC,CAAC;AAEvE;;GAEG;AACH,eAAO,MAAM,qBAAqB,UAAuC,CAAC;yCAWvE,IAAI,EANI,MAMJ,EAAE,IAAI,EALF,MAKE,EAAE,KAAK,GAJT,UAIc;;;;;;;;AAiQzB;;GAEG;AACH,eAAO,MAAM,0BAA0B,UAAwC,CAAC;AAEhF;;GAEG;AACH,eAAO,MAAM,0BAA0B,UAAwC,CAAC;AAEhF;;GAEG;AACH,eAAO,MAAM,eAAe;;;mBAU1B,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,gBAAgB,UAAuC,CAAC;AAErE;;;;GAIG;AACH,eAAO,MAAM,eAAe,QAFjB,MAAM;;mBAcf,CAAC;AAEH;;;;;;;;;GASG;AACH,eAAO,MAAM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