@wordpress/core-data 7.48.0 → 7.48.2-next.v.202606191442.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 (148) hide show
  1. package/CHANGELOG.md +7 -1
  2. package/build/actions.cjs +1 -7
  3. package/build/actions.cjs.map +3 -3
  4. package/build/awareness/block-lookup.cjs +14 -26
  5. package/build/awareness/block-lookup.cjs.map +2 -2
  6. package/build/awareness/post-editor-awareness.cjs +4 -3
  7. package/build/awareness/post-editor-awareness.cjs.map +2 -2
  8. package/build/entities.cjs +6 -3
  9. package/build/entities.cjs.map +2 -2
  10. package/build/entity-types/helpers.cjs.map +1 -1
  11. package/build/hooks/use-entity-record.cjs +21 -19
  12. package/build/hooks/use-entity-record.cjs.map +3 -3
  13. package/build/hooks/use-entity-records.cjs +22 -20
  14. package/build/hooks/use-entity-records.cjs.map +3 -3
  15. package/build/hooks/use-post-editor-awareness-state.cjs +8 -2
  16. package/build/hooks/use-post-editor-awareness-state.cjs.map +2 -2
  17. package/build/hooks/use-query-select.cjs +2 -20
  18. package/build/hooks/use-query-select.cjs.map +2 -2
  19. package/build/hooks/utils.cjs +53 -0
  20. package/build/hooks/utils.cjs.map +7 -0
  21. package/build/private-actions.cjs +8 -0
  22. package/build/private-actions.cjs.map +2 -2
  23. package/build/private-selectors.cjs.map +2 -2
  24. package/build/reducer.cjs +23 -7
  25. package/build/reducer.cjs.map +2 -2
  26. package/build/resolvers.cjs +13 -8
  27. package/build/resolvers.cjs.map +2 -2
  28. package/build/selectors.cjs +7 -0
  29. package/build/selectors.cjs.map +2 -2
  30. package/build/types.cjs.map +1 -1
  31. package/build/utils/clear-unchanged-edits.cjs +51 -0
  32. package/build/utils/clear-unchanged-edits.cjs.map +7 -0
  33. package/build/utils/crdt-blocks.cjs +12 -2
  34. package/build/utils/crdt-blocks.cjs.map +2 -2
  35. package/build/utils/crdt-user-selections.cjs.map +1 -1
  36. package/build/utils/crdt-utils.cjs.map +1 -1
  37. package/build/utils/crdt.cjs +2 -1
  38. package/build/utils/crdt.cjs.map +2 -2
  39. package/build/utils/index.cjs +6 -0
  40. package/build/utils/index.cjs.map +2 -2
  41. package/build/utils/save-crdt-doc.cjs +75 -0
  42. package/build/utils/save-crdt-doc.cjs.map +7 -0
  43. package/build/utils/set-nested-value.cjs.map +1 -1
  44. package/build-module/actions.mjs +2 -8
  45. package/build-module/actions.mjs.map +2 -2
  46. package/build-module/awareness/block-lookup.mjs +13 -26
  47. package/build-module/awareness/block-lookup.mjs.map +2 -2
  48. package/build-module/awareness/post-editor-awareness.mjs +4 -3
  49. package/build-module/awareness/post-editor-awareness.mjs.map +2 -2
  50. package/build-module/entities.mjs +6 -3
  51. package/build-module/entities.mjs.map +2 -2
  52. package/build-module/hooks/use-entity-record.mjs +21 -19
  53. package/build-module/hooks/use-entity-record.mjs.map +2 -2
  54. package/build-module/hooks/use-entity-records.mjs +20 -18
  55. package/build-module/hooks/use-entity-records.mjs.map +2 -2
  56. package/build-module/hooks/use-post-editor-awareness-state.mjs +9 -3
  57. package/build-module/hooks/use-post-editor-awareness-state.mjs.map +2 -2
  58. package/build-module/hooks/use-query-select.mjs +2 -20
  59. package/build-module/hooks/use-query-select.mjs.map +2 -2
  60. package/build-module/hooks/utils.mjs +28 -0
  61. package/build-module/hooks/utils.mjs.map +7 -0
  62. package/build-module/private-actions.mjs +7 -0
  63. package/build-module/private-actions.mjs.map +2 -2
  64. package/build-module/private-selectors.mjs.map +2 -2
  65. package/build-module/reducer.mjs +23 -8
  66. package/build-module/reducer.mjs.map +2 -2
  67. package/build-module/resolvers.mjs +15 -9
  68. package/build-module/resolvers.mjs.map +2 -2
  69. package/build-module/selectors.mjs +7 -0
  70. package/build-module/selectors.mjs.map +2 -2
  71. package/build-module/utils/clear-unchanged-edits.mjs +20 -0
  72. package/build-module/utils/clear-unchanged-edits.mjs.map +7 -0
  73. package/build-module/utils/crdt-blocks.mjs +12 -2
  74. package/build-module/utils/crdt-blocks.mjs.map +2 -2
  75. package/build-module/utils/crdt-user-selections.mjs.map +1 -1
  76. package/build-module/utils/crdt-utils.mjs.map +1 -1
  77. package/build-module/utils/crdt.mjs +2 -1
  78. package/build-module/utils/crdt.mjs.map +2 -2
  79. package/build-module/utils/index.mjs +24 -20
  80. package/build-module/utils/index.mjs.map +2 -2
  81. package/build-module/utils/save-crdt-doc.mjs +40 -0
  82. package/build-module/utils/save-crdt-doc.mjs.map +7 -0
  83. package/build-module/utils/set-nested-value.mjs.map +1 -1
  84. package/build-types/actions.d.ts.map +1 -1
  85. package/build-types/awareness/block-lookup.d.ts +27 -7
  86. package/build-types/awareness/block-lookup.d.ts.map +1 -1
  87. package/build-types/awareness/post-editor-awareness.d.ts +3 -1
  88. package/build-types/awareness/post-editor-awareness.d.ts.map +1 -1
  89. package/build-types/entities.d.ts.map +1 -1
  90. package/build-types/hooks/use-entity-record.d.ts +4 -0
  91. package/build-types/hooks/use-entity-record.d.ts.map +1 -1
  92. package/build-types/hooks/use-entity-records.d.ts +5 -1
  93. package/build-types/hooks/use-entity-records.d.ts.map +1 -1
  94. package/build-types/hooks/use-post-editor-awareness-state.d.ts.map +1 -1
  95. package/build-types/hooks/utils.d.ts +22 -0
  96. package/build-types/hooks/utils.d.ts.map +1 -0
  97. package/build-types/index.d.ts +8 -8
  98. package/build-types/private-actions.d.ts +15 -0
  99. package/build-types/private-actions.d.ts.map +1 -1
  100. package/build-types/private-selectors.d.ts +0 -12
  101. package/build-types/private-selectors.d.ts.map +1 -1
  102. package/build-types/reducer.d.ts +15 -0
  103. package/build-types/reducer.d.ts.map +1 -1
  104. package/build-types/resolvers.d.ts.map +1 -1
  105. package/build-types/selectors.d.ts +12 -8
  106. package/build-types/selectors.d.ts.map +1 -1
  107. package/build-types/utils/clear-unchanged-edits.d.ts +12 -0
  108. package/build-types/utils/clear-unchanged-edits.d.ts.map +1 -0
  109. package/build-types/utils/crdt-blocks.d.ts +5 -1
  110. package/build-types/utils/crdt-blocks.d.ts.map +1 -1
  111. package/build-types/utils/crdt.d.ts.map +1 -1
  112. package/build-types/utils/index.d.ts +2 -0
  113. package/build-types/utils/index.d.ts.map +1 -1
  114. package/build-types/utils/save-crdt-doc.d.ts +8 -0
  115. package/build-types/utils/save-crdt-doc.d.ts.map +1 -0
  116. package/package.json +27 -20
  117. package/src/actions.js +2 -10
  118. package/src/awareness/block-lookup.ts +21 -62
  119. package/src/awareness/post-editor-awareness.ts +8 -3
  120. package/src/awareness/test/block-lookup.ts +98 -94
  121. package/src/awareness/test/post-editor-awareness.ts +177 -180
  122. package/src/entities.js +14 -3
  123. package/src/hooks/test/use-entity-record.js +5 -1
  124. package/src/hooks/test/use-post-editor-awareness-state.ts +10 -2
  125. package/src/hooks/use-entity-record.ts +26 -19
  126. package/src/hooks/use-entity-records.ts +26 -18
  127. package/src/hooks/use-post-editor-awareness-state.ts +20 -7
  128. package/src/hooks/use-query-select.ts +2 -23
  129. package/src/hooks/utils.ts +40 -0
  130. package/src/private-actions.js +18 -0
  131. package/src/private-selectors.ts +0 -12
  132. package/src/reducer.js +30 -9
  133. package/src/resolvers.js +20 -13
  134. package/src/selectors.ts +11 -0
  135. package/src/test/entities.js +51 -0
  136. package/src/test/private-selectors.js +66 -0
  137. package/src/test/reducer.js +44 -0
  138. package/src/test/resolvers.js +121 -113
  139. package/src/test/selectors.js +48 -0
  140. package/src/utils/clear-unchanged-edits.ts +34 -0
  141. package/src/utils/crdt-blocks.ts +27 -22
  142. package/src/utils/crdt.ts +2 -1
  143. package/src/utils/index.js +2 -0
  144. package/src/utils/save-crdt-doc.js +64 -0
  145. package/src/utils/test/clear-unchanged-edits.js +42 -0
  146. package/src/utils/test/crdt-blocks.ts +57 -2
  147. package/src/utils/test/rtc-rich-text-cursor-scope.test.js +2 -2
  148. package/src/utils/test/save-crdt-doc.js +185 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clear-unchanged-edits.d.ts","sourceRoot":"","sources":["../../src/utils/clear-unchanged-edits.ts"],"names":[],"mappings":"AAKA;;;;;;;;;GASG;AACH,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAC1C,KAAK,EAAE,MAAM,CAAE,MAAM,EAAE,OAAO,CAAE,EAChC,eAAe,EAAE,MAAM,CAAE,MAAM,EAAE,GAAG,CAAE,GAAG,SAAS,GAChD,MAAM,CAAE,MAAM,EAAE,OAAO,CAAE,CAe3B"}
@@ -27,6 +27,9 @@ export interface YBlockRecord extends YMapRecord {
27
27
  export type YBlock = YMapWrap<YBlockRecord>;
28
28
  export type YBlocks = Y.Array<YBlock>;
29
29
  export type YBlockAttributes = Y.Map<Y.Text | unknown>;
30
+ interface MergeCrdtBlocksOptions {
31
+ preserveClientIds?: boolean;
32
+ }
30
33
  /**
31
34
  * Optional description of where a cursor falls.
32
35
  *
@@ -54,8 +57,9 @@ export declare function deserializeBlockAttributes(blocks: Block[]): Block[];
54
57
  * @param attributeCursor When provided, describes a selection cursor falling within a
55
58
  * RichText field associated with a specific block and attribute.
56
59
  * Derived from the changes that produced the blocks.
60
+ * @param options Optional settings for the merge operation.
57
61
  */
58
- export declare function mergeCrdtBlocks(yblocks: YBlocks, incomingBlocks: Block[], attributeCursor: MergeCursorPosition): void;
62
+ export declare function mergeCrdtBlocks(yblocks: YBlocks, incomingBlocks: Block[], attributeCursor: MergeCursorPosition, options?: MergeCrdtBlocksOptions): void;
59
63
  /**
60
64
  * Given a Y.Text object and an updated string value, diff the new value and
61
65
  * apply the delta to the Y.Text.
@@ -1 +1 @@
1
- {"version":3,"file":"crdt-blocks.d.ts","sourceRoot":"","sources":["../../src/utils/crdt-blocks.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,CAAC,EAAE,MAAM,iBAAiB,CAAC;AAEpC;;GAEG;AACH,OAAO,EAIN,KAAK,eAAe,EACpB,KAAK,UAAU,EACf,KAAK,QAAQ,EACb,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAEjD,UAAU,e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G,IAAI,CAAC;IACpB,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC;IAChB,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,QAAQ,CAAE,UAAU,CAAE,CAAC;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,OAAO,CAAC;IAChB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC;CACd;AAED,eAAO,MAAM,sCAAsC,mBAAmB,CAAC;AAsCvE;;;;;;;;GAQG;AACH,wBAAgB,yBAAyB,CACxC,IAAI,EAAE,OAAO,EACb,OAAO,EAAE,WAAW,EACpB,gBAAgB,EAAE,GAAG,CAAE,MAAM,CAAE,GAC7B,IAAI,CAuJN;AA4DD;;;;;;;;;GASG;AACH,wBAAgB,yBAAyB,CACxC,IAAI,EAAE,OAAO,EACb,YAAY,EAAE,IAAI,EAClB,gBAAgB,EAAE,GAAG,CAAE,MAAM,CAAE,GAC7B,WAAW,CAsKb;AAED;;;GAGG;AACH,eAAO,MAAM,iBAAiB,EAAE,UAI/B,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,2BAA2B,EAAE,UAKzC,CAAC"}
@@ -1,3 +1,4 @@
1
+ export { default as clearUnchangedEdits } from './clear-unchanged-edits';
1
2
  export { default as conservativeMapItem } from './conservative-map-item';
2
3
  export { default as getNormalizedCommaSeparable } from './get-normalized-comma-separable';
3
4
  export { default as ifMatchingAction } from './if-matching-action';
@@ -10,4 +11,5 @@ export { default as isNumericID } from './is-numeric-id';
10
11
  export { getUserPermissionCacheKey, getUserPermissionsFromAllowHeader, ALLOWED_RESOURCE_ACTIONS, } from './user-permissions';
11
12
  export { RECEIVE_INTERMEDIATE_RESULTS } from './receive-intermediate-results';
12
13
  export { default as normalizeQueryForResolution } from './normalize-query-for-resolution';
14
+ export { saveCRDTDoc } from './save-crdt-doc';
13
15
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AACzE,OAAO,EAAE,OAAO,IAAI,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAC1F,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACpE,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EACN,yBAAyB,EACzB,iCAAiC,EACjC,wBAAwB,GACxB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAC9E,OAAO,EAAE,OAAO,IAAI,2BAA2B,EAAE,MAAM,kCAAkC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AACzE,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AACzE,OAAO,EAAE,OAAO,IAAI,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAC1F,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACpE,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EACN,yBAAyB,EACzB,iCAAiC,EACjC,wBAAwB,GACxB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAC9E,OAAO,EAAE,OAAO,IAAI,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAC1F,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Persist the current CRDT document through the sync /save endpoint.
3
+ *
4
+ * @param {import('@wordpress/sync').ObjectType} objectType Object type.
5
+ * @param {import('@wordpress/sync').ObjectID} objectId Object ID.
6
+ */
7
+ export declare function saveCRDTDoc(objectType: import('@wordpress/sync').ObjectType, objectId: import('@wordpress/sync').ObjectID): Promise<void>;
8
+ //# sourceMappingURL=save-crdt-doc.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"save-crdt-doc.d.ts","sourceRoot":"","sources":["../../src/utils/save-crdt-doc.js"],"names":[],"mappings":"AAiCA;;;;;GAKG;AACH,wBAAsB,WAAW,CAAE,UAAU,EAHlC,OAAO,iBAAiB,EAAE,UAGQ,EAAE,QAAQ,EAF5C,OAAO,iBAAiB,EAAE,QAEkB,iBAwBtD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/core-data",
3
- "version": "7.48.0",
3
+ "version": "7.48.2-next.v.202606191442.0+17fe7db8a",
4
4
  "description": "Access to and manipulation of core WordPress entities.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -40,7 +40,6 @@
40
40
  },
41
41
  "./package.json": "./package.json"
42
42
  },
43
- "react-native": "src/index",
44
43
  "wpScript": true,
45
44
  "types": "build-types",
46
45
  "sideEffects": [
@@ -49,22 +48,22 @@
49
48
  "build-module/index.mjs"
50
49
  ],
51
50
  "dependencies": {
52
- "@wordpress/api-fetch": "^7.48.0",
53
- "@wordpress/block-editor": "^15.21.0",
54
- "@wordpress/blocks": "^15.21.0",
55
- "@wordpress/compose": "^8.1.0",
56
- "@wordpress/data": "^10.48.0",
57
- "@wordpress/deprecated": "^4.48.0",
58
- "@wordpress/element": "^8.0.0",
59
- "@wordpress/html-entities": "^4.48.0",
60
- "@wordpress/i18n": "^6.21.0",
61
- "@wordpress/is-shallow-equal": "^5.48.0",
62
- "@wordpress/private-apis": "^1.48.0",
63
- "@wordpress/rich-text": "^7.48.0",
64
- "@wordpress/sync": "^1.48.0",
65
- "@wordpress/undo-manager": "^1.48.0",
66
- "@wordpress/url": "^4.48.0",
67
- "@wordpress/warning": "^3.48.0",
51
+ "@wordpress/api-fetch": "^7.48.2-next.v.202606191442.0+17fe7db8a",
52
+ "@wordpress/block-editor": "^15.22.1-next.v.202606191442.0+17fe7db8a",
53
+ "@wordpress/blocks": "^15.21.3-next.v.202606191442.0+17fe7db8a",
54
+ "@wordpress/compose": "^8.1.2-next.v.202606191442.0+17fe7db8a",
55
+ "@wordpress/data": "^10.48.2-next.v.202606191442.0+17fe7db8a",
56
+ "@wordpress/deprecated": "^4.48.2-next.v.202606191442.0+17fe7db8a",
57
+ "@wordpress/element": "^8.0.2-next.v.202606191442.0+17fe7db8a",
58
+ "@wordpress/html-entities": "^4.48.2-next.v.202606191442.0+17fe7db8a",
59
+ "@wordpress/i18n": "^6.21.2-next.v.202606191442.0+17fe7db8a",
60
+ "@wordpress/is-shallow-equal": "^5.48.2-next.v.202606191442.0+17fe7db8a",
61
+ "@wordpress/private-apis": "^1.48.2-next.v.202606191442.0+17fe7db8a",
62
+ "@wordpress/rich-text": "^7.48.2-next.v.202606191442.0+17fe7db8a",
63
+ "@wordpress/sync": "^1.48.2-next.v.202606191442.0+17fe7db8a",
64
+ "@wordpress/undo-manager": "^1.48.2-next.v.202606191442.0+17fe7db8a",
65
+ "@wordpress/url": "^4.48.2-next.v.202606191442.0+17fe7db8a",
66
+ "@wordpress/warning": "^3.48.2-next.v.202606191442.0+17fe7db8a",
68
67
  "change-case": "^4.1.2",
69
68
  "equivalent-key-map": "^0.2.2",
70
69
  "fast-deep-equal": "^3.1.3",
@@ -73,16 +72,24 @@
73
72
  },
74
73
  "devDependencies": {
75
74
  "@jest/globals": "^30.2.0",
75
+ "@testing-library/dom": "^10.4.1",
76
+ "@testing-library/react": "^16.3.2",
76
77
  "@types/jest": "^29.5.14",
77
78
  "@types/node": "^20.19.39",
78
- "deep-freeze": "0.0.1"
79
+ "deep-freeze": "^0.0.1"
79
80
  },
80
81
  "peerDependencies": {
82
+ "@types/react": "^18.3.27",
81
83
  "react": "^18.0.0",
82
84
  "react-dom": "^18.0.0"
83
85
  },
86
+ "peerDependenciesMeta": {
87
+ "@types/react": {
88
+ "optional": true
89
+ }
90
+ },
84
91
  "publishConfig": {
85
92
  "access": "public"
86
93
  },
87
- "gitHead": "e7856693aeb4e2522d13608cd32c994e4a97cb9c"
94
+ "gitHead": "1b6a19222df5a88f161880b5789efb3171d8f425"
88
95
  }
package/src/actions.js CHANGED
@@ -1,7 +1,6 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- import fastDeepEqual from 'fast-deep-equal/es6/index.js';
5
4
  import { v4 as uuid } from 'uuid';
6
5
 
7
6
  /**
@@ -14,7 +13,7 @@ import deprecated from '@wordpress/deprecated';
14
13
  /**
15
14
  * Internal dependencies
16
15
  */
17
- import { getNestedValue, setNestedValue } from './utils';
16
+ import { clearUnchangedEdits, getNestedValue, setNestedValue } from './utils';
18
17
  import { receiveItems, removeItems, receiveQueriedItems } from './queried-data';
19
18
  import { DEFAULT_ENTITY_KEY } from './entities';
20
19
  import { createBatch } from './batch';
@@ -421,14 +420,7 @@ export const editEntityRecord =
421
420
  recordId,
422
421
  // Clear edits when they are equal to their persisted counterparts
423
422
  // so that the property is not considered dirty.
424
- edits: Object.keys( edits ).reduce( ( acc, key ) => {
425
- const recordValue = record[ key ];
426
- const value = editsWithMerges[ key ];
427
- acc[ key ] = fastDeepEqual( recordValue, value )
428
- ? undefined
429
- : value;
430
- return acc;
431
- }, {} ),
423
+ edits: clearUnchangedEdits( editsWithMerges, record ),
432
424
  };
433
425
  if ( entityConfig.syncConfig ) {
434
426
  const objectType = `${ kind }/${ name }`;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
- import { select } from '@wordpress/data';
4
+ import { useSelect } from '@wordpress/data';
5
5
  import { Y } from '@wordpress/sync';
6
6
  // @ts-ignore No exported types for block editor store selectors.
7
7
  import { store as blockEditorStore } from '@wordpress/block-editor';
@@ -10,17 +10,17 @@ import { store as blockEditorStore } from '@wordpress/block-editor';
10
10
  * Internal dependencies
11
11
  */
12
12
  import type { AbsoluteBlockIndexPath } from '../types';
13
+ import { unlock } from '../lock-unlock';
13
14
 
14
15
  /**
15
- * A block as represented in the block-editor store (from `getBlocks()`).
16
+ * A block as represented in the block-editor store's client ID tree.
16
17
  *
17
18
  * This is a minimal interface covering only the fields used by RTC awareness.
18
19
  */
19
- interface EditorStoreBlock {
20
+ export type EditorStoreBlock = {
20
21
  clientId: string;
21
- name: string;
22
22
  innerBlocks: EditorStoreBlock[];
23
- }
23
+ };
24
24
 
25
25
  /**
26
26
  * Find the block Y.Map that contains a nested Yjs type.
@@ -112,26 +112,18 @@ export function getBlockPathInYdoc(
112
112
  * Navigate the block-editor store's block tree by an index path
113
113
  * and return the local block's clientId.
114
114
  *
115
- * In template mode, getBlocks() returns the full template tree, but Yjs
116
- * paths are relative to the post content. This method finds the
117
- * core/post-content block (if present) and uses its inner blocks as the
118
- * navigation root, so paths align with the Yjs document structure.
119
- *
120
- * @param path - The index path, e.g. [0, 1] for blocks[0].innerBlocks[1].
115
+ * @param path - The index path, e.g. [0, 1] for blocks[0].innerBlocks[1].
116
+ * @param blocks - The tree of block-editor store post contentblocks.
121
117
  * @return The local block clientId, or null if the path is invalid.
122
118
  */
123
119
  export function resolveBlockClientIdByPath(
124
- path: AbsoluteBlockIndexPath
120
+ path: AbsoluteBlockIndexPath,
121
+ blocks: EditorStoreBlock[]
125
122
  ): string | null {
126
123
  if ( path.length === 0 ) {
127
124
  return null;
128
125
  }
129
126
 
130
- const { getBlocks } = select( blockEditorStore );
131
- const postContentBlocks = getPostContentBlocks( getBlocks(), getBlocks );
132
-
133
- let blocks = postContentBlocks;
134
-
135
127
  for ( let i = 0; i < path.length; i++ ) {
136
128
  const block = blocks[ path[ i ] ];
137
129
  if ( ! block ) {
@@ -151,53 +143,20 @@ export function resolveBlockClientIdByPath(
151
143
  * In template mode, the block tree contains template parts wrapping a
152
144
  * core/post-content block. The Yjs document only stores the post content
153
145
  * blocks, so we need to find the core/post-content block and use
154
- * getBlocks(clientId) to retrieve its inner blocks from the store.
146
+ * getClientIdsTree(clientId) to retrieve its inner blocks from the store.
155
147
  *
156
- * We must use getBlocks(clientId) rather than reading .innerBlocks from
157
- * the block object because useBlockSync() injects post content as
158
- * controlled inner blocks they exist in the store's block order map
159
- * but are not populated in the .innerBlocks property of the tree
160
- * returned by getBlocks().
148
+ * Uses the private getClientIdsTree selector which depends only on
149
+ * state.blocks.order, avoiding unnecessary re-renders when block
150
+ * attributes change (which would happen with getBlocks()).
161
151
  *
162
- * @param rootBlocks - The root-level blocks from getBlocks().
163
- * @param getBlocks - The getBlocks selector.
164
152
  * @return The blocks that correspond to the Yjs document root.
165
153
  */
166
- function getPostContentBlocks(
167
- rootBlocks: EditorStoreBlock[],
168
- getBlocks: ( rootClientId?: string ) => EditorStoreBlock[]
169
- ): EditorStoreBlock[] {
170
- const postContentBlock = findBlockByName( rootBlocks, 'core/post-content' );
171
- if ( postContentBlock ) {
172
- // Use getBlocks(clientId) to read controlled inner blocks from
173
- // the store, since postContentBlock.innerBlocks is empty.
174
- return getBlocks( postContentBlock.clientId );
175
- }
176
-
177
- return rootBlocks;
178
- }
179
-
180
- /**
181
- * Recursively search the block tree for a block with a given name.
182
- *
183
- * @param blocks - The blocks to search.
184
- * @param name - The block name to find.
185
- * @return The first matching block, or null if not found.
186
- */
187
- function findBlockByName(
188
- blocks: EditorStoreBlock[],
189
- name: string
190
- ): EditorStoreBlock | null {
191
- for ( const block of blocks ) {
192
- if ( block.name === name ) {
193
- return block;
194
- }
195
- if ( block.innerBlocks?.length ) {
196
- const found = findBlockByName( block.innerBlocks, name );
197
- if ( found ) {
198
- return found;
199
- }
200
- }
201
- }
202
- return null;
154
+ export function usePostContentBlocks(): EditorStoreBlock[] {
155
+ return useSelect( ( select ) => {
156
+ const { getBlocksByName, getClientIdsTree } = unlock(
157
+ select( blockEditorStore )
158
+ );
159
+ const [ postContentClientId ] = getBlocksByName( 'core/post-content' );
160
+ return getClientIdsTree( postContentClientId ?? '' );
161
+ }, [] );
203
162
  }
@@ -37,6 +37,7 @@ import type {
37
37
  WPBlockSelection,
38
38
  } from '../types';
39
39
  import type { YBlocks } from '../utils/crdt-blocks';
40
+ import type { EditorStoreBlock } from './block-lookup';
40
41
  import type {
41
42
  DebugCollaboratorData,
42
43
  EditorState,
@@ -245,10 +246,12 @@ export class PostEditorAwareness extends BaseAwarenessState< PostEditorState > {
245
246
  * clientIds (e.g. in "Show Template" mode where blocks are cloned).
246
247
  *
247
248
  * @param selection - The selection state.
249
+ * @param blocks - The tree of block-editor store post content blocks.
248
250
  * @return The rich-text offset and block client ID, or nulls if not resolvable.
249
251
  */
250
252
  public convertSelectionStateToAbsolute(
251
- selection: SelectionState
253
+ selection: SelectionState,
254
+ blocks: EditorStoreBlock[]
252
255
  ): ResolvedSelection {
253
256
  if ( selection.type === SelectionType.None ) {
254
257
  return {
@@ -273,7 +276,7 @@ export class PostEditorAwareness extends BaseAwarenessState< PostEditorState > {
273
276
  if ( block instanceof Y.Map ) {
274
277
  const path = getBlockPathInYdoc( block );
275
278
  localClientId = path
276
- ? resolveBlockClientIdByPath( path )
279
+ ? resolveBlockClientIdByPath( path, blocks )
277
280
  : null;
278
281
  }
279
282
  }
@@ -306,7 +309,9 @@ export class PostEditorAwareness extends BaseAwarenessState< PostEditorState > {
306
309
 
307
310
  const yType = getContainingBlockYMap( absolutePosition.type );
308
311
  const path = yType ? getBlockPathInYdoc( yType ) : null;
309
- const localClientId = path ? resolveBlockClientIdByPath( path ) : null;
312
+ const localClientId = path
313
+ ? resolveBlockClientIdByPath( path, blocks )
314
+ : null;
310
315
 
311
316
  return {
312
317
  richTextOffset: htmlIndexToRichTextOffset(