@wordpress/core-data 7.32.0 → 7.32.1-next.ff1cebbba.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 (383) hide show
  1. package/build/actions.js +375 -632
  2. package/build/actions.js.map +7 -1
  3. package/build/batch/create-batch.js +49 -62
  4. package/build/batch/create-batch.js.map +7 -1
  5. package/build/batch/default-processor.js +43 -39
  6. package/build/batch/default-processor.js.map +7 -1
  7. package/build/batch/index.js +38 -17
  8. package/build/batch/index.js.map +7 -1
  9. package/build/dynamic-entities.js +30 -32
  10. package/build/dynamic-entities.js.map +7 -1
  11. package/build/entities.js +298 -410
  12. package/build/entities.js.map +7 -1
  13. package/build/entity-context.js +29 -12
  14. package/build/entity-context.js.map +7 -1
  15. package/build/entity-provider.js +38 -46
  16. package/build/entity-provider.js.map +7 -1
  17. package/build/entity-types/attachment.js +16 -5
  18. package/build/entity-types/attachment.js.map +7 -1
  19. package/build/entity-types/base-entity-records.js +16 -42
  20. package/build/entity-types/base-entity-records.js.map +7 -1
  21. package/build/entity-types/base.js +16 -5
  22. package/build/entity-types/base.js.map +7 -1
  23. package/build/entity-types/comment.js +16 -5
  24. package/build/entity-types/comment.js.map +7 -1
  25. package/build/entity-types/global-styles-revision.js +16 -5
  26. package/build/entity-types/global-styles-revision.js.map +7 -1
  27. package/build/entity-types/helpers.js +16 -5
  28. package/build/entity-types/helpers.js.map +7 -1
  29. package/build/entity-types/index.js +16 -5
  30. package/build/entity-types/index.js.map +7 -1
  31. package/build/entity-types/menu-location.js +16 -5
  32. package/build/entity-types/menu-location.js.map +7 -1
  33. package/build/entity-types/nav-menu-item.js +16 -5
  34. package/build/entity-types/nav-menu-item.js.map +7 -1
  35. package/build/entity-types/nav-menu.js +16 -5
  36. package/build/entity-types/nav-menu.js.map +7 -1
  37. package/build/entity-types/page.js +16 -5
  38. package/build/entity-types/page.js.map +7 -1
  39. package/build/entity-types/plugin.js +16 -5
  40. package/build/entity-types/plugin.js.map +7 -1
  41. package/build/entity-types/post-revision.js +16 -5
  42. package/build/entity-types/post-revision.js.map +7 -1
  43. package/build/entity-types/post-status.js +16 -5
  44. package/build/entity-types/post-status.js.map +7 -1
  45. package/build/entity-types/post.js +16 -5
  46. package/build/entity-types/post.js.map +7 -1
  47. package/build/entity-types/settings.js +16 -5
  48. package/build/entity-types/settings.js.map +7 -1
  49. package/build/entity-types/sidebar.js +16 -5
  50. package/build/entity-types/sidebar.js.map +7 -1
  51. package/build/entity-types/taxonomy.js +16 -5
  52. package/build/entity-types/taxonomy.js.map +7 -1
  53. package/build/entity-types/term.js +16 -5
  54. package/build/entity-types/term.js.map +7 -1
  55. package/build/entity-types/theme.js +16 -5
  56. package/build/entity-types/theme.js.map +7 -1
  57. package/build/entity-types/type.js +16 -5
  58. package/build/entity-types/type.js.map +7 -1
  59. package/build/entity-types/user.js +16 -5
  60. package/build/entity-types/user.js.map +7 -1
  61. package/build/entity-types/widget-type.js +16 -5
  62. package/build/entity-types/widget-type.js.map +7 -1
  63. package/build/entity-types/widget.js +16 -5
  64. package/build/entity-types/widget.js.map +7 -1
  65. package/build/entity-types/wp-template-part.js +16 -5
  66. package/build/entity-types/wp-template-part.js.map +7 -1
  67. package/build/entity-types/wp-template.js +16 -5
  68. package/build/entity-types/wp-template.js.map +7 -1
  69. package/build/fetch/__experimental-fetch-link-suggestions.js +141 -154
  70. package/build/fetch/__experimental-fetch-link-suggestions.js.map +7 -1
  71. package/build/fetch/__experimental-fetch-url-data.js +47 -59
  72. package/build/fetch/__experimental-fetch-url-data.js.map +7 -1
  73. package/build/fetch/index.js +53 -32
  74. package/build/fetch/index.js.map +7 -1
  75. package/build/footnotes/get-footnotes-order.js +38 -25
  76. package/build/footnotes/get-footnotes-order.js.map +7 -1
  77. package/build/footnotes/get-rich-text-values-cached.js +26 -27
  78. package/build/footnotes/get-rich-text-values-cached.js.map +7 -1
  79. package/build/footnotes/index.js +68 -55
  80. package/build/footnotes/index.js.map +7 -1
  81. package/build/hooks/constants.js +33 -12
  82. package/build/hooks/constants.js.map +7 -1
  83. package/build/hooks/index.js +59 -68
  84. package/build/hooks/index.js.map +7 -1
  85. package/build/hooks/memoize.js +34 -12
  86. package/build/hooks/memoize.js.map +7 -1
  87. package/build/hooks/use-entity-block-editor.js +111 -119
  88. package/build/hooks/use-entity-block-editor.js.map +7 -1
  89. package/build/hooks/use-entity-id.js +25 -23
  90. package/build/hooks/use-entity-id.js.map +7 -1
  91. package/build/hooks/use-entity-prop.js +59 -60
  92. package/build/hooks/use-entity-prop.js.map +7 -1
  93. package/build/hooks/use-entity-record.js +95 -155
  94. package/build/hooks/use-entity-record.js.map +7 -1
  95. package/build/hooks/use-entity-records.js +131 -139
  96. package/build/hooks/use-entity-records.js.map +7 -1
  97. package/build/hooks/use-query-select.js +65 -84
  98. package/build/hooks/use-query-select.js.map +7 -1
  99. package/build/hooks/use-resource-permissions.js +92 -145
  100. package/build/hooks/use-resource-permissions.js.map +7 -1
  101. package/build/index.js +96 -153
  102. package/build/index.js.map +7 -1
  103. package/build/lock-unlock.js +31 -14
  104. package/build/lock-unlock.js.map +7 -1
  105. package/build/locks/actions.js +36 -19
  106. package/build/locks/actions.js.map +7 -1
  107. package/build/locks/engine.js +48 -47
  108. package/build/locks/engine.js.map +7 -1
  109. package/build/locks/reducer.js +54 -63
  110. package/build/locks/reducer.js.map +7 -1
  111. package/build/locks/selectors.js +35 -30
  112. package/build/locks/selectors.js.map +7 -1
  113. package/build/locks/utils.js +37 -16
  114. package/build/locks/utils.js.map +7 -1
  115. package/build/name.js +27 -12
  116. package/build/name.js.map +7 -1
  117. package/build/private-actions.js +67 -75
  118. package/build/private-actions.js.map +7 -1
  119. package/build/private-apis.js +33 -16
  120. package/build/private-apis.js.map +7 -1
  121. package/build/private-selectors.js +204 -184
  122. package/build/private-selectors.js.map +7 -1
  123. package/build/queried-data/actions.js +32 -41
  124. package/build/queried-data/actions.js.map +7 -1
  125. package/build/queried-data/get-query-parts.js +41 -79
  126. package/build/queried-data/get-query-parts.js.map +7 -1
  127. package/build/queried-data/index.js +39 -36
  128. package/build/queried-data/index.js.map +7 -1
  129. package/build/queried-data/reducer.js +162 -193
  130. package/build/queried-data/reducer.js.map +7 -1
  131. package/build/queried-data/selectors.js +57 -85
  132. package/build/queried-data/selectors.js.map +7 -1
  133. package/build/reducer.js +279 -404
  134. package/build/reducer.js.map +7 -1
  135. package/build/resolvers.js +553 -600
  136. package/build/resolvers.js.map +7 -1
  137. package/build/selectors.js +456 -981
  138. package/build/selectors.js.map +7 -1
  139. package/build/sync.js +34 -22
  140. package/build/sync.js.map +7 -1
  141. package/build/types.js +16 -5
  142. package/build/types.js.map +7 -1
  143. package/build/utils/conservative-map-item.js +34 -27
  144. package/build/utils/conservative-map-item.js.map +7 -1
  145. package/build/utils/crdt-blocks.js +289 -0
  146. package/build/utils/crdt-blocks.js.map +7 -0
  147. package/build/utils/crdt.js +202 -0
  148. package/build/utils/crdt.js.map +7 -0
  149. package/build/utils/forward-resolver.js +24 -16
  150. package/build/utils/forward-resolver.js.map +7 -1
  151. package/build/utils/get-nested-value.js +26 -21
  152. package/build/utils/get-nested-value.js.map +7 -1
  153. package/build/utils/get-normalized-comma-separable.js +25 -17
  154. package/build/utils/get-normalized-comma-separable.js.map +7 -1
  155. package/build/utils/if-matching-action.js +25 -19
  156. package/build/utils/if-matching-action.js.map +7 -1
  157. package/build/utils/index.js +77 -108
  158. package/build/utils/index.js.map +7 -1
  159. package/build/utils/is-numeric-id.js +22 -12
  160. package/build/utils/is-numeric-id.js.map +7 -1
  161. package/build/utils/is-raw-attribute.js +22 -13
  162. package/build/utils/is-raw-attribute.js.map +7 -1
  163. package/build/utils/log-entity-deprecation.js +37 -38
  164. package/build/utils/log-entity-deprecation.js.map +7 -1
  165. package/build/utils/on-sub-key.js +30 -24
  166. package/build/utils/on-sub-key.js.map +7 -1
  167. package/build/utils/receive-intermediate-results.js +29 -6
  168. package/build/utils/receive-intermediate-results.js.map +7 -1
  169. package/build/utils/replace-action.js +24 -17
  170. package/build/utils/replace-action.js.map +7 -1
  171. package/build/utils/set-nested-value.js +25 -30
  172. package/build/utils/set-nested-value.js.map +7 -1
  173. package/build/utils/user-permissions.js +41 -13
  174. package/build/utils/user-permissions.js.map +7 -1
  175. package/build/utils/with-weak-map-cache.js +26 -22
  176. package/build/utils/with-weak-map-cache.js.map +7 -1
  177. package/build-module/actions.js +322 -601
  178. package/build-module/actions.js.map +7 -1
  179. package/build-module/batch/create-batch.js +21 -57
  180. package/build-module/batch/create-batch.js.map +7 -1
  181. package/build-module/batch/default-processor.js +14 -33
  182. package/build-module/batch/default-processor.js.map +7 -1
  183. package/build-module/batch/index.js +7 -3
  184. package/build-module/batch/index.js.map +7 -1
  185. package/build-module/dynamic-entities.js +7 -28
  186. package/build-module/dynamic-entities.js.map +7 -1
  187. package/build-module/entities.js +263 -399
  188. package/build-module/entities.js.map +7 -1
  189. package/build-module/entity-context.js +7 -7
  190. package/build-module/entity-context.js.map +7 -1
  191. package/build-module/entity-provider.js +19 -42
  192. package/build-module/entity-provider.js.map +7 -1
  193. package/build-module/entity-types/attachment.js +1 -2
  194. package/build-module/entity-types/attachment.js.map +7 -1
  195. package/build-module/entity-types/base-entity-records.js +1 -37
  196. package/build-module/entity-types/base-entity-records.js.map +7 -1
  197. package/build-module/entity-types/base.js +1 -2
  198. package/build-module/entity-types/base.js.map +7 -1
  199. package/build-module/entity-types/comment.js +1 -2
  200. package/build-module/entity-types/comment.js.map +7 -1
  201. package/build-module/entity-types/global-styles-revision.js +1 -2
  202. package/build-module/entity-types/global-styles-revision.js.map +7 -1
  203. package/build-module/entity-types/helpers.js +1 -2
  204. package/build-module/entity-types/helpers.js.map +7 -1
  205. package/build-module/entity-types/index.js +1 -2
  206. package/build-module/entity-types/index.js.map +7 -1
  207. package/build-module/entity-types/menu-location.js +1 -2
  208. package/build-module/entity-types/menu-location.js.map +7 -1
  209. package/build-module/entity-types/nav-menu-item.js +1 -2
  210. package/build-module/entity-types/nav-menu-item.js.map +7 -1
  211. package/build-module/entity-types/nav-menu.js +1 -2
  212. package/build-module/entity-types/nav-menu.js.map +7 -1
  213. package/build-module/entity-types/page.js +1 -2
  214. package/build-module/entity-types/page.js.map +7 -1
  215. package/build-module/entity-types/plugin.js +1 -2
  216. package/build-module/entity-types/plugin.js.map +7 -1
  217. package/build-module/entity-types/post-revision.js +1 -2
  218. package/build-module/entity-types/post-revision.js.map +7 -1
  219. package/build-module/entity-types/post-status.js +1 -2
  220. package/build-module/entity-types/post-status.js.map +7 -1
  221. package/build-module/entity-types/post.js +1 -2
  222. package/build-module/entity-types/post.js.map +7 -1
  223. package/build-module/entity-types/settings.js +1 -2
  224. package/build-module/entity-types/settings.js.map +7 -1
  225. package/build-module/entity-types/sidebar.js +1 -2
  226. package/build-module/entity-types/sidebar.js.map +7 -1
  227. package/build-module/entity-types/taxonomy.js +1 -2
  228. package/build-module/entity-types/taxonomy.js.map +7 -1
  229. package/build-module/entity-types/term.js +1 -2
  230. package/build-module/entity-types/term.js.map +7 -1
  231. package/build-module/entity-types/theme.js +1 -2
  232. package/build-module/entity-types/theme.js.map +7 -1
  233. package/build-module/entity-types/type.js +1 -2
  234. package/build-module/entity-types/type.js.map +7 -1
  235. package/build-module/entity-types/user.js +1 -2
  236. package/build-module/entity-types/user.js.map +7 -1
  237. package/build-module/entity-types/widget-type.js +1 -2
  238. package/build-module/entity-types/widget-type.js.map +7 -1
  239. package/build-module/entity-types/widget.js +1 -2
  240. package/build-module/entity-types/widget.js.map +7 -1
  241. package/build-module/entity-types/wp-template-part.js +1 -2
  242. package/build-module/entity-types/wp-template-part.js.map +7 -1
  243. package/build-module/entity-types/wp-template.js +1 -2
  244. package/build-module/entity-types/wp-template.js.map +7 -1
  245. package/build-module/fetch/__experimental-fetch-link-suggestions.js +111 -149
  246. package/build-module/fetch/__experimental-fetch-link-suggestions.js.map +7 -1
  247. package/build-module/fetch/__experimental-fetch-url-data.js +20 -49
  248. package/build-module/fetch/__experimental-fetch-url-data.js.map +7 -1
  249. package/build-module/fetch/index.js +20 -15
  250. package/build-module/fetch/index.js.map +7 -1
  251. package/build-module/footnotes/get-footnotes-order.js +10 -19
  252. package/build-module/footnotes/get-footnotes-order.js.map +7 -1
  253. package/build-module/footnotes/get-rich-text-values-cached.js +8 -23
  254. package/build-module/footnotes/get-rich-text-values-cached.js.map +7 -1
  255. package/build-module/footnotes/index.js +34 -47
  256. package/build-module/footnotes/index.js.map +7 -1
  257. package/build-module/hooks/constants.js +11 -8
  258. package/build-module/hooks/constants.js.map +7 -1
  259. package/build-module/hooks/index.js +27 -15
  260. package/build-module/hooks/index.js.map +7 -1
  261. package/build-module/hooks/memoize.js +6 -8
  262. package/build-module/hooks/memoize.js.map +7 -1
  263. package/build-module/hooks/use-entity-block-editor.js +80 -110
  264. package/build-module/hooks/use-entity-block-editor.js.map +7 -1
  265. package/build-module/hooks/use-entity-id.js +7 -19
  266. package/build-module/hooks/use-entity-id.js.map +7 -1
  267. package/build-module/hooks/use-entity-prop.js +31 -55
  268. package/build-module/hooks/use-entity-prop.js.map +7 -1
  269. package/build-module/hooks/use-entity-record.js +63 -148
  270. package/build-module/hooks/use-entity-record.js.map +7 -1
  271. package/build-module/hooks/use-entity-records.js +98 -131
  272. package/build-module/hooks/use-entity-records.js.map +7 -1
  273. package/build-module/hooks/use-query-select.js +27 -71
  274. package/build-module/hooks/use-query-select.js.map +7 -1
  275. package/build-module/hooks/use-resource-permissions.js +57 -136
  276. package/build-module/hooks/use-resource-permissions.js.map +7 -1
  277. package/build-module/index.js +49 -71
  278. package/build-module/index.js.map +7 -1
  279. package/build-module/lock-unlock.js +8 -7
  280. package/build-module/lock-unlock.js.map +7 -1
  281. package/build-module/locks/actions.js +8 -13
  282. package/build-module/locks/actions.js.map +7 -1
  283. package/build-module/locks/engine.js +17 -38
  284. package/build-module/locks/engine.js.map +7 -1
  285. package/build-module/locks/reducer.js +37 -59
  286. package/build-module/locks/reducer.js.map +7 -1
  287. package/build-module/locks/selectors.js +16 -23
  288. package/build-module/locks/selectors.js.map +7 -1
  289. package/build-module/locks/utils.js +15 -12
  290. package/build-module/locks/utils.js.map +7 -1
  291. package/build-module/name.js +5 -8
  292. package/build-module/name.js.map +7 -1
  293. package/build-module/private-actions.js +35 -69
  294. package/build-module/private-actions.js.map +7 -1
  295. package/build-module/private-apis.js +8 -8
  296. package/build-module/private-apis.js.map +7 -1
  297. package/build-module/private-selectors.js +167 -174
  298. package/build-module/private-selectors.js.map +7 -1
  299. package/build-module/queried-data/actions.js +11 -38
  300. package/build-module/queried-data/actions.js.map +7 -1
  301. package/build-module/queried-data/get-query-parts.js +20 -75
  302. package/build-module/queried-data/get-query-parts.js.map +7 -1
  303. package/build-module/queried-data/index.js +7 -4
  304. package/build-module/queried-data/index.js.map +7 -1
  305. package/build-module/queried-data/reducer.js +134 -185
  306. package/build-module/queried-data/reducer.js.map +7 -1
  307. package/build-module/queried-data/selectors.js +23 -78
  308. package/build-module/queried-data/selectors.js.map +7 -1
  309. package/build-module/reducer.js +243 -393
  310. package/build-module/reducer.js.map +7 -1
  311. package/build-module/resolvers.js +478 -549
  312. package/build-module/resolvers.js.map +7 -1
  313. package/build-module/selectors.js +410 -953
  314. package/build-module/selectors.js.map +7 -1
  315. package/build-module/sync.js +14 -17
  316. package/build-module/sync.js.map +7 -1
  317. package/build-module/types.js +1 -2
  318. package/build-module/types.js.map +7 -1
  319. package/build-module/utils/conservative-map-item.js +6 -22
  320. package/build-module/utils/conservative-map-item.js.map +7 -1
  321. package/build-module/utils/crdt-blocks.js +255 -0
  322. package/build-module/utils/crdt-blocks.js.map +7 -0
  323. package/build-module/utils/crdt.js +167 -0
  324. package/build-module/utils/crdt.js.map +7 -0
  325. package/build-module/utils/forward-resolver.js +6 -12
  326. package/build-module/utils/forward-resolver.js.map +7 -1
  327. package/build-module/utils/get-nested-value.js +9 -18
  328. package/build-module/utils/get-nested-value.js.map +7 -1
  329. package/build-module/utils/get-normalized-comma-separable.js +7 -13
  330. package/build-module/utils/get-normalized-comma-separable.js.map +7 -1
  331. package/build-module/utils/if-matching-action.js +7 -15
  332. package/build-module/utils/if-matching-action.js.map +7 -1
  333. package/build-module/utils/index.js +35 -14
  334. package/build-module/utils/index.js.map +7 -1
  335. package/build-module/utils/is-numeric-id.js +5 -9
  336. package/build-module/utils/is-numeric-id.js.map +7 -1
  337. package/build-module/utils/is-raw-attribute.js +5 -10
  338. package/build-module/utils/is-raw-attribute.js.map +7 -1
  339. package/build-module/utils/log-entity-deprecation.js +8 -31
  340. package/build-module/utils/log-entity-deprecation.js.map +7 -1
  341. package/build-module/utils/on-sub-key.js +8 -19
  342. package/build-module/utils/on-sub-key.js.map +7 -1
  343. package/build-module/utils/receive-intermediate-results.js +7 -2
  344. package/build-module/utils/receive-intermediate-results.js.map +7 -1
  345. package/build-module/utils/replace-action.js +6 -13
  346. package/build-module/utils/replace-action.js.map +7 -1
  347. package/build-module/utils/set-nested-value.js +8 -27
  348. package/build-module/utils/set-nested-value.js.map +7 -1
  349. package/build-module/utils/user-permissions.js +19 -9
  350. package/build-module/utils/user-permissions.js.map +7 -1
  351. package/build-module/utils/with-weak-map-cache.js +8 -18
  352. package/build-module/utils/with-weak-map-cache.js.map +7 -1
  353. package/build-types/actions.d.ts.map +1 -1
  354. package/build-types/entities.d.ts +0 -56
  355. package/build-types/entities.d.ts.map +1 -1
  356. package/build-types/index.d.ts.map +1 -1
  357. package/build-types/private-selectors.d.ts.map +1 -1
  358. package/build-types/resolvers.d.ts +3 -0
  359. package/build-types/resolvers.d.ts.map +1 -1
  360. package/build-types/selectors.d.ts.map +1 -1
  361. package/build-types/sync.d.ts +6 -1
  362. package/build-types/sync.d.ts.map +1 -1
  363. package/build-types/types.d.ts +9 -0
  364. package/build-types/types.d.ts.map +1 -1
  365. package/build-types/utils/crdt-blocks.d.ts +30 -0
  366. package/build-types/utils/crdt-blocks.d.ts.map +1 -0
  367. package/build-types/utils/crdt.d.ts +49 -0
  368. package/build-types/utils/crdt.d.ts.map +1 -0
  369. package/package.json +26 -19
  370. package/src/actions.js +56 -74
  371. package/src/entities.js +59 -113
  372. package/src/private-selectors.ts +32 -7
  373. package/src/resolvers.js +173 -120
  374. package/src/selectors.ts +0 -13
  375. package/src/sync.ts +12 -0
  376. package/src/test/resolvers.js +183 -0
  377. package/src/types.ts +12 -0
  378. package/src/utils/crdt-blocks.ts +503 -0
  379. package/src/utils/crdt.ts +310 -0
  380. package/src/utils/test/crdt-blocks.ts +375 -0
  381. package/src/utils/test/crdt.ts +254 -0
  382. package/tsconfig.tsbuildinfo +1 -1
  383. package/src/sync.js +0 -27
@@ -1,333 +1,203 @@
1
1
  "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var selectors_exports = {};
30
+ __export(selectors_exports, {
31
+ __experimentalGetCurrentGlobalStylesId: () => __experimentalGetCurrentGlobalStylesId,
32
+ __experimentalGetCurrentThemeBaseGlobalStyles: () => __experimentalGetCurrentThemeBaseGlobalStyles,
33
+ __experimentalGetCurrentThemeGlobalStylesVariations: () => __experimentalGetCurrentThemeGlobalStylesVariations,
34
+ __experimentalGetDirtyEntityRecords: () => __experimentalGetDirtyEntityRecords,
35
+ __experimentalGetEntitiesBeingSaved: () => __experimentalGetEntitiesBeingSaved,
36
+ __experimentalGetEntityRecordNoResolver: () => __experimentalGetEntityRecordNoResolver,
37
+ canUser: () => canUser,
38
+ canUserEditEntityRecord: () => canUserEditEntityRecord,
39
+ getAuthors: () => getAuthors,
40
+ getAutosave: () => getAutosave,
41
+ getAutosaves: () => getAutosaves,
42
+ getBlockPatternCategories: () => getBlockPatternCategories,
43
+ getBlockPatterns: () => getBlockPatterns,
44
+ getCurrentTheme: () => getCurrentTheme,
45
+ getCurrentThemeGlobalStylesRevisions: () => getCurrentThemeGlobalStylesRevisions,
46
+ getCurrentUser: () => getCurrentUser,
47
+ getDefaultTemplateId: () => getDefaultTemplateId,
48
+ getEditedEntityRecord: () => getEditedEntityRecord,
49
+ getEmbedPreview: () => getEmbedPreview,
50
+ getEntitiesByKind: () => getEntitiesByKind,
51
+ getEntitiesConfig: () => getEntitiesConfig,
52
+ getEntity: () => getEntity,
53
+ getEntityConfig: () => getEntityConfig,
54
+ getEntityRecord: () => getEntityRecord,
55
+ getEntityRecordEdits: () => getEntityRecordEdits,
56
+ getEntityRecordNonTransientEdits: () => getEntityRecordNonTransientEdits,
57
+ getEntityRecords: () => getEntityRecords,
58
+ getEntityRecordsTotalItems: () => getEntityRecordsTotalItems,
59
+ getEntityRecordsTotalPages: () => getEntityRecordsTotalPages,
60
+ getLastEntityDeleteError: () => getLastEntityDeleteError,
61
+ getLastEntitySaveError: () => getLastEntitySaveError,
62
+ getRawEntityRecord: () => getRawEntityRecord,
63
+ getRedoEdit: () => getRedoEdit,
64
+ getReferenceByDistinctEdits: () => getReferenceByDistinctEdits,
65
+ getRevision: () => getRevision,
66
+ getRevisions: () => getRevisions,
67
+ getThemeSupports: () => getThemeSupports,
68
+ getUndoEdit: () => getUndoEdit,
69
+ getUserPatternCategories: () => getUserPatternCategories,
70
+ getUserQueryResults: () => getUserQueryResults,
71
+ hasEditsForEntityRecord: () => hasEditsForEntityRecord,
72
+ hasEntityRecord: () => hasEntityRecord,
73
+ hasEntityRecords: () => hasEntityRecords,
74
+ hasFetchedAutosaves: () => hasFetchedAutosaves,
75
+ hasRedo: () => hasRedo,
76
+ hasUndo: () => hasUndo,
77
+ isAutosavingEntityRecord: () => isAutosavingEntityRecord,
78
+ isDeletingEntityRecord: () => isDeletingEntityRecord,
79
+ isPreviewEmbedFallback: () => isPreviewEmbedFallback,
80
+ isRequestingEmbedPreview: () => isRequestingEmbedPreview,
81
+ isSavingEntityRecord: () => isSavingEntityRecord
6
82
  });
7
- exports.__experimentalGetCurrentGlobalStylesId = __experimentalGetCurrentGlobalStylesId;
8
- exports.__experimentalGetCurrentThemeBaseGlobalStyles = __experimentalGetCurrentThemeBaseGlobalStyles;
9
- exports.__experimentalGetCurrentThemeGlobalStylesVariations = __experimentalGetCurrentThemeGlobalStylesVariations;
10
- exports.__experimentalGetEntitiesBeingSaved = exports.__experimentalGetDirtyEntityRecords = void 0;
11
- exports.__experimentalGetEntityRecordNoResolver = __experimentalGetEntityRecordNoResolver;
12
- exports.canUser = canUser;
13
- exports.canUserEditEntityRecord = canUserEditEntityRecord;
14
- exports.getAuthors = getAuthors;
15
- exports.getAutosave = getAutosave;
16
- exports.getAutosaves = getAutosaves;
17
- exports.getBlockPatternCategories = getBlockPatternCategories;
18
- exports.getBlockPatterns = getBlockPatterns;
19
- exports.getCurrentTheme = getCurrentTheme;
20
- exports.getCurrentThemeGlobalStylesRevisions = getCurrentThemeGlobalStylesRevisions;
21
- exports.getCurrentUser = getCurrentUser;
22
- exports.getDefaultTemplateId = getDefaultTemplateId;
23
- exports.getEditedEntityRecord = void 0;
24
- exports.getEmbedPreview = getEmbedPreview;
25
- exports.getEntitiesByKind = getEntitiesByKind;
26
- exports.getEntitiesConfig = void 0;
27
- exports.getEntity = getEntity;
28
- exports.getEntityConfig = getEntityConfig;
29
- exports.getEntityRecord = void 0;
30
- exports.getEntityRecordEdits = getEntityRecordEdits;
31
- exports.getEntityRecordsTotalPages = exports.getEntityRecordsTotalItems = exports.getEntityRecords = exports.getEntityRecordNonTransientEdits = void 0;
32
- exports.getLastEntityDeleteError = getLastEntityDeleteError;
33
- exports.getLastEntitySaveError = getLastEntitySaveError;
34
- exports.getRawEntityRecord = void 0;
35
- exports.getRedoEdit = getRedoEdit;
36
- exports.getReferenceByDistinctEdits = getReferenceByDistinctEdits;
37
- exports.getRevisions = exports.getRevision = void 0;
38
- exports.getThemeSupports = getThemeSupports;
39
- exports.getUndoEdit = getUndoEdit;
40
- exports.getUserPatternCategories = getUserPatternCategories;
41
- exports.getUserQueryResults = void 0;
42
- exports.hasEditsForEntityRecord = hasEditsForEntityRecord;
43
- exports.hasEntityRecord = hasEntityRecord;
44
- exports.hasEntityRecords = hasEntityRecords;
45
- exports.hasFetchedAutosaves = void 0;
46
- exports.hasRedo = hasRedo;
47
- exports.hasUndo = hasUndo;
48
- exports.isAutosavingEntityRecord = isAutosavingEntityRecord;
49
- exports.isDeletingEntityRecord = isDeletingEntityRecord;
50
- exports.isPreviewEmbedFallback = isPreviewEmbedFallback;
51
- exports.isRequestingEmbedPreview = void 0;
52
- exports.isSavingEntityRecord = isSavingEntityRecord;
53
- var _data = require("@wordpress/data");
54
- var _url = require("@wordpress/url");
55
- var _deprecated = _interopRequireDefault(require("@wordpress/deprecated"));
56
- var _name = require("./name");
57
- var _queriedData = require("./queried-data");
58
- var _entities = require("./entities");
59
- var _utils = require("./utils");
60
- var _logEntityDeprecation = _interopRequireDefault(require("./utils/log-entity-deprecation"));
61
- /**
62
- * WordPress dependencies
63
- */
64
-
65
- /**
66
- * Internal dependencies
67
- */
68
-
69
- // This is an incomplete, high-level approximation of the State type.
70
- // It makes the selectors slightly more safe, but is intended to evolve
71
- // into a more detailed representation over time.
72
- // See https://github.com/WordPress/gutenberg/pull/40025#discussion_r865410589 for more context.
73
-
74
- /**
75
- * HTTP Query parameters sent with the API request to fetch the entity records.
76
- */
77
-
78
- /**
79
- * Arguments for EntityRecord selectors.
80
- */
81
-
82
- /**
83
- * Shared reference to an empty object for cases where it is important to avoid
84
- * returning a new object reference on every invocation, as in a connected or
85
- * other pure component which performs `shouldComponentUpdate` check on props.
86
- * This should be used as a last resort, since the normalized data should be
87
- * maintained by the reducer result in state.
88
- */
83
+ module.exports = __toCommonJS(selectors_exports);
84
+ var import_data = require("@wordpress/data");
85
+ var import_url = require("@wordpress/url");
86
+ var import_deprecated = __toESM(require("@wordpress/deprecated"));
87
+ var import_name = require("./name");
88
+ var import_queried_data = require("./queried-data");
89
+ var import_entities = require("./entities");
90
+ var import_utils = require("./utils");
91
+ var import_log_entity_deprecation = __toESM(require("./utils/log-entity-deprecation"));
89
92
  const EMPTY_OBJECT = {};
90
-
91
- /**
92
- * Returns true if a request is in progress for embed preview data, or false
93
- * otherwise.
94
- *
95
- * @param state Data state.
96
- * @param url URL the preview would be for.
97
- *
98
- * @return Whether a request is in progress for an embed preview.
99
- */
100
- const isRequestingEmbedPreview = exports.isRequestingEmbedPreview = (0, _data.createRegistrySelector)(select => (state, url) => {
101
- return select(_name.STORE_NAME).isResolving('getEmbedPreview', [url]);
102
- });
103
-
104
- /**
105
- * Returns all available authors.
106
- *
107
- * @deprecated since 11.3. Callers should use `select( 'core' ).getUsers({ who: 'authors' })` instead.
108
- *
109
- * @param state Data state.
110
- * @param query Optional object of query parameters to
111
- * include with request. For valid query parameters see the [Users page](https://developer.wordpress.org/rest-api/reference/users/) in the REST API Handbook and see the arguments for [List Users](https://developer.wordpress.org/rest-api/reference/users/#list-users) and [Retrieve a User](https://developer.wordpress.org/rest-api/reference/users/#retrieve-a-user).
112
- * @return Authors list.
113
- */
93
+ const isRequestingEmbedPreview = (0, import_data.createRegistrySelector)(
94
+ (select) => (state, url) => {
95
+ return select(import_name.STORE_NAME).isResolving("getEmbedPreview", [
96
+ url
97
+ ]);
98
+ }
99
+ );
114
100
  function getAuthors(state, query) {
115
- (0, _deprecated.default)("select( 'core' ).getAuthors()", {
116
- since: '5.9',
101
+ (0, import_deprecated.default)("select( 'core' ).getAuthors()", {
102
+ since: "5.9",
117
103
  alternative: "select( 'core' ).getUsers({ who: 'authors' })"
118
104
  });
119
- const path = (0, _url.addQueryArgs)('/wp/v2/users/?who=authors&per_page=100', query);
105
+ const path = (0, import_url.addQueryArgs)(
106
+ "/wp/v2/users/?who=authors&per_page=100",
107
+ query
108
+ );
120
109
  return getUserQueryResults(state, path);
121
110
  }
122
-
123
- /**
124
- * Returns the current user.
125
- *
126
- * @param state Data state.
127
- *
128
- * @return Current user object.
129
- */
130
111
  function getCurrentUser(state) {
131
112
  return state.currentUser;
132
113
  }
133
-
134
- /**
135
- * Returns all the users returned by a query ID.
136
- *
137
- * @param state Data state.
138
- * @param queryID Query ID.
139
- *
140
- * @return Users list.
141
- */
142
- const getUserQueryResults = exports.getUserQueryResults = (0, _data.createSelector)((state, queryID) => {
143
- var _state$users$queries$;
144
- const queryResults = (_state$users$queries$ = state.users.queries[queryID]) !== null && _state$users$queries$ !== void 0 ? _state$users$queries$ : [];
145
- return queryResults.map(id => state.users.byId[id]);
146
- }, (state, queryID) => [state.users.queries[queryID], state.users.byId]);
147
-
148
- /**
149
- * Returns the loaded entities for the given kind.
150
- *
151
- * @deprecated since WordPress 6.0. Use getEntitiesConfig instead
152
- * @param state Data state.
153
- * @param kind Entity kind.
154
- *
155
- * @return Array of entities with config matching kind.
156
- */
114
+ const getUserQueryResults = (0, import_data.createSelector)(
115
+ (state, queryID) => {
116
+ const queryResults = state.users.queries[queryID] ?? [];
117
+ return queryResults.map((id) => state.users.byId[id]);
118
+ },
119
+ (state, queryID) => [
120
+ state.users.queries[queryID],
121
+ state.users.byId
122
+ ]
123
+ );
157
124
  function getEntitiesByKind(state, kind) {
158
- (0, _deprecated.default)("wp.data.select( 'core' ).getEntitiesByKind()", {
159
- since: '6.0',
125
+ (0, import_deprecated.default)("wp.data.select( 'core' ).getEntitiesByKind()", {
126
+ since: "6.0",
160
127
  alternative: "wp.data.select( 'core' ).getEntitiesConfig()"
161
128
  });
162
129
  return getEntitiesConfig(state, kind);
163
130
  }
164
-
165
- /**
166
- * Returns the loaded entities for the given kind.
167
- *
168
- * @param state Data state.
169
- * @param kind Entity kind.
170
- *
171
- * @return Array of entities with config matching kind.
172
- */
173
- const getEntitiesConfig = exports.getEntitiesConfig = (0, _data.createSelector)((state, kind) => state.entities.config.filter(entity => entity.kind === kind), /* eslint-disable @typescript-eslint/no-unused-vars */
174
- (state, kind) => state.entities.config
175
- /* eslint-enable @typescript-eslint/no-unused-vars */);
176
- /**
177
- * Returns the entity config given its kind and name.
178
- *
179
- * @deprecated since WordPress 6.0. Use getEntityConfig instead
180
- * @param state Data state.
181
- * @param kind Entity kind.
182
- * @param name Entity name.
183
- *
184
- * @return Entity config
185
- */
131
+ const getEntitiesConfig = (0, import_data.createSelector)(
132
+ (state, kind) => state.entities.config.filter((entity) => entity.kind === kind),
133
+ /* eslint-disable @typescript-eslint/no-unused-vars */
134
+ (state, kind) => state.entities.config
135
+ /* eslint-enable @typescript-eslint/no-unused-vars */
136
+ );
186
137
  function getEntity(state, kind, name) {
187
- (0, _deprecated.default)("wp.data.select( 'core' ).getEntity()", {
188
- since: '6.0',
138
+ (0, import_deprecated.default)("wp.data.select( 'core' ).getEntity()", {
139
+ since: "6.0",
189
140
  alternative: "wp.data.select( 'core' ).getEntityConfig()"
190
141
  });
191
142
  return getEntityConfig(state, kind, name);
192
143
  }
193
-
194
- /**
195
- * Returns the entity config given its kind and name.
196
- *
197
- * @param state Data state.
198
- * @param kind Entity kind.
199
- * @param name Entity name.
200
- *
201
- * @return Entity config
202
- */
203
144
  function getEntityConfig(state, kind, name) {
204
- (0, _logEntityDeprecation.default)(kind, name, 'getEntityConfig');
205
- return state.entities.config?.find(config => config.kind === kind && config.name === name);
206
- }
207
-
208
- /**
209
- * GetEntityRecord is declared as a *callable interface* with
210
- * two signatures to work around the fact that TypeScript doesn't
211
- * allow currying generic functions:
212
- *
213
- * ```ts
214
- * type CurriedState = F extends ( state: any, ...args: infer P ) => infer R
215
- * ? ( ...args: P ) => R
216
- * : F;
217
- * type Selector = <K extends string | number>(
218
- * state: any,
219
- * kind: K,
220
- * key: K extends string ? 'string value' : false
221
- * ) => K;
222
- * type BadlyInferredSignature = CurriedState< Selector >
223
- * // BadlyInferredSignature evaluates to:
224
- * // (kind: string number, key: false | "string value") => string number
225
- * ```
226
- *
227
- * The signature without the state parameter shipped as CurriedSignature
228
- * is used in the return value of `select( coreStore )`.
229
- *
230
- * See https://github.com/WordPress/gutenberg/pull/41578 for more details.
231
- */
232
-
233
- /**
234
- * Returns the Entity's record object by key. Returns `null` if the value is not
235
- * yet received, undefined if the value entity is known to not exist, or the
236
- * entity object if it exists and is received.
237
- *
238
- * @param state State tree
239
- * @param kind Entity kind.
240
- * @param name Entity name.
241
- * @param key Optional record's key. If requesting a global record (e.g. site settings), the key can be omitted. If requesting a specific item, the key must always be included.
242
- * @param query Optional query. If requesting specific
243
- * fields, fields must always include the ID. For valid query parameters see the [Reference](https://developer.wordpress.org/rest-api/reference/) in the REST API Handbook and select the entity kind. Then see the arguments available "Retrieve a [Entity kind]".
244
- *
245
- * @return Record.
246
- */
247
- const getEntityRecord = exports.getEntityRecord = (0, _data.createSelector)((state, kind, name, key, query) => {
248
- var _query$context, _getNormalizedCommaSe;
249
- (0, _logEntityDeprecation.default)(kind, name, 'getEntityRecord');
250
-
251
- // For back-compat, we allow querying for static templates through
252
- // wp_template.
253
- if (kind === 'postType' && name === 'wp_template' && typeof key === 'string' &&
254
- // __experimentalGetDirtyEntityRecords always calls getEntityRecord
255
- // with a string key, so we need that it's not a numeric ID.
256
- !/^\d+$/.test(key)) {
257
- name = 'wp_registered_template';
258
- }
259
- const queriedState = state.entities.records?.[kind]?.[name]?.queriedData;
260
- if (!queriedState) {
261
- return undefined;
262
- }
263
- const context = (_query$context = query?.context) !== null && _query$context !== void 0 ? _query$context : 'default';
264
- if (!query || !query._fields) {
265
- // If expecting a complete item, validate that completeness.
266
- if (!queriedState.itemIsComplete[context]?.[key]) {
267
- return undefined;
145
+ (0, import_log_entity_deprecation.default)(kind, name, "getEntityConfig");
146
+ return state.entities.config?.find(
147
+ (config) => config.kind === kind && config.name === name
148
+ );
149
+ }
150
+ const getEntityRecord = (0, import_data.createSelector)(
151
+ ((state, kind, name, key, query) => {
152
+ (0, import_log_entity_deprecation.default)(kind, name, "getEntityRecord");
153
+ const queriedState = state.entities.records?.[kind]?.[name]?.queriedData;
154
+ if (!queriedState) {
155
+ return void 0;
268
156
  }
269
- return queriedState.items[context][key];
270
- }
271
- const item = queriedState.items[context]?.[key];
272
- if (!item) {
273
- return item;
274
- }
275
- const filteredItem = {};
276
- const fields = (_getNormalizedCommaSe = (0, _utils.getNormalizedCommaSeparable)(query._fields)) !== null && _getNormalizedCommaSe !== void 0 ? _getNormalizedCommaSe : [];
277
- for (let f = 0; f < fields.length; f++) {
278
- const field = fields[f].split('.');
279
- let value = item;
280
- field.forEach(fieldName => {
281
- value = value?.[fieldName];
282
- });
283
- (0, _utils.setNestedValue)(filteredItem, field, value);
157
+ const context = query?.context ?? "default";
158
+ if (!query || !query._fields) {
159
+ if (!queriedState.itemIsComplete[context]?.[key]) {
160
+ return void 0;
161
+ }
162
+ return queriedState.items[context][key];
163
+ }
164
+ const item = queriedState.items[context]?.[key];
165
+ if (!item) {
166
+ return item;
167
+ }
168
+ const filteredItem = {};
169
+ const fields = (0, import_utils.getNormalizedCommaSeparable)(query._fields) ?? [];
170
+ for (let f = 0; f < fields.length; f++) {
171
+ const field = fields[f].split(".");
172
+ let value = item;
173
+ field.forEach((fieldName) => {
174
+ value = value?.[fieldName];
175
+ });
176
+ (0, import_utils.setNestedValue)(filteredItem, field, value);
177
+ }
178
+ return filteredItem;
179
+ }),
180
+ (state, kind, name, recordId, query) => {
181
+ const context = query?.context ?? "default";
182
+ const queriedState = state.entities.records?.[kind]?.[name]?.queriedData;
183
+ return [
184
+ queriedState?.items[context]?.[recordId],
185
+ queriedState?.itemIsComplete[context]?.[recordId]
186
+ ];
284
187
  }
285
- return filteredItem;
286
- }, (state, kind, name, recordId, query) => {
287
- var _query$context2;
288
- const context = (_query$context2 = query?.context) !== null && _query$context2 !== void 0 ? _query$context2 : 'default';
289
- const queriedState = state.entities.records?.[kind]?.[name]?.queriedData;
290
- return [queriedState?.items[context]?.[recordId], queriedState?.itemIsComplete[context]?.[recordId]];
291
- });
292
-
293
- /**
294
- * Normalizes `recordKey`s that look like numeric IDs to numbers.
295
- *
296
- * @param args EntityRecordArgs the selector arguments.
297
- * @return EntityRecordArgs the normalized arguments.
298
- */
299
- getEntityRecord.__unstableNormalizeArgs = args => {
188
+ );
189
+ getEntityRecord.__unstableNormalizeArgs = (args) => {
300
190
  const newArgs = [...args];
301
191
  const recordKey = newArgs?.[2];
302
-
303
- // If recordKey looks to be a numeric ID then coerce to number.
304
- newArgs[2] = (0, _utils.isNumericID)(recordKey) ? Number(recordKey) : recordKey;
192
+ newArgs[2] = (0, import_utils.isNumericID)(recordKey) ? Number(recordKey) : recordKey;
305
193
  return newArgs;
306
194
  };
307
-
308
- /**
309
- * Returns true if a record has been received for the given set of parameters, or false otherwise.
310
- *
311
- * Note: This action does not trigger a request for the entity record from the API
312
- * if it's not available in the local state.
313
- *
314
- * @param state State tree
315
- * @param kind Entity kind.
316
- * @param name Entity name.
317
- * @param key Record's key.
318
- * @param query Optional query.
319
- *
320
- * @return Whether an entity record has been received.
321
- */
322
195
  function hasEntityRecord(state, kind, name, key, query) {
323
- var _query$context3, _getNormalizedCommaSe2;
324
196
  const queriedState = state.entities.records?.[kind]?.[name]?.queriedData;
325
197
  if (!queriedState) {
326
198
  return false;
327
199
  }
328
- const context = (_query$context3 = query?.context) !== null && _query$context3 !== void 0 ? _query$context3 : 'default';
329
-
330
- // If expecting a complete item, validate that completeness.
200
+ const context = query?.context ?? "default";
331
201
  if (!query || !query._fields) {
332
202
  return !!queriedState.itemIsComplete[context]?.[key];
333
203
  }
@@ -335,12 +205,9 @@ function hasEntityRecord(state, kind, name, key, query) {
335
205
  if (!item) {
336
206
  return false;
337
207
  }
338
-
339
- // When `query._fields` is provided, check that each requested field exists,
340
- // including any nested paths, on the item; return false if any part is missing.
341
- const fields = (_getNormalizedCommaSe2 = (0, _utils.getNormalizedCommaSeparable)(query._fields)) !== null && _getNormalizedCommaSe2 !== void 0 ? _getNormalizedCommaSe2 : [];
208
+ const fields = (0, import_utils.getNormalizedCommaSeparable)(query._fields) ?? [];
342
209
  for (let i = 0; i < fields.length; i++) {
343
- const path = fields[i].split('.');
210
+ const path = fields[i].split(".");
344
211
  let value = item;
345
212
  for (let p = 0; p < path.length; p++) {
346
213
  const part = path[p];
@@ -352,141 +219,58 @@ function hasEntityRecord(state, kind, name, key, query) {
352
219
  }
353
220
  return true;
354
221
  }
355
-
356
- /**
357
- * Returns the Entity's record object by key. Doesn't trigger a resolver nor requests the entity records from the API if the entity record isn't available in the local state.
358
- *
359
- * @param state State tree
360
- * @param kind Entity kind.
361
- * @param name Entity name.
362
- * @param key Record's key
363
- *
364
- * @return Record.
365
- */
366
222
  function __experimentalGetEntityRecordNoResolver(state, kind, name, key) {
367
223
  return getEntityRecord(state, kind, name, key);
368
224
  }
369
-
370
- /**
371
- * Returns the entity's record object by key,
372
- * with its attributes mapped to their raw values.
373
- *
374
- * @param state State tree.
375
- * @param kind Entity kind.
376
- * @param name Entity name.
377
- * @param key Record's key.
378
- *
379
- * @return Object with the entity's raw attributes.
380
- */
381
- const getRawEntityRecord = exports.getRawEntityRecord = (0, _data.createSelector)((state, kind, name, key) => {
382
- (0, _logEntityDeprecation.default)(kind, name, 'getRawEntityRecord');
383
- const record = getEntityRecord(state, kind, name, key);
384
- return record && Object.keys(record).reduce((accumulator, _key) => {
385
- if ((0, _utils.isRawAttribute)(getEntityConfig(state, kind, name), _key)) {
386
- // Because edits are the "raw" attribute values,
387
- // we return those from record selectors to make rendering,
388
- // comparisons, and joins with edits easier.
389
- accumulator[_key] = record[_key]?.raw !== undefined ? record[_key]?.raw : record[_key];
390
- } else {
391
- accumulator[_key] = record[_key];
392
- }
393
- return accumulator;
394
- }, {});
395
- }, (state, kind, name, recordId, query) => {
396
- var _query$context4;
397
- const context = (_query$context4 = query?.context) !== null && _query$context4 !== void 0 ? _query$context4 : 'default';
398
- return [state.entities.config, state.entities.records?.[kind]?.[name]?.queriedData?.items[context]?.[recordId], state.entities.records?.[kind]?.[name]?.queriedData?.itemIsComplete[context]?.[recordId]];
399
- });
400
-
401
- /**
402
- * Returns true if records have been received for the given set of parameters,
403
- * or false otherwise.
404
- *
405
- * @param state State tree
406
- * @param kind Entity kind.
407
- * @param name Entity name.
408
- * @param query Optional terms query. For valid query parameters see the [Reference](https://developer.wordpress.org/rest-api/reference/) in the REST API Handbook and select the entity kind. Then see the arguments available for "List [Entity kind]s".
409
- *
410
- * @return Whether entity records have been received.
411
- */
225
+ const getRawEntityRecord = (0, import_data.createSelector)(
226
+ (state, kind, name, key) => {
227
+ (0, import_log_entity_deprecation.default)(kind, name, "getRawEntityRecord");
228
+ const record = getEntityRecord(
229
+ state,
230
+ kind,
231
+ name,
232
+ key
233
+ );
234
+ return record && Object.keys(record).reduce((accumulator, _key) => {
235
+ if ((0, import_utils.isRawAttribute)(getEntityConfig(state, kind, name), _key)) {
236
+ accumulator[_key] = record[_key]?.raw !== void 0 ? record[_key]?.raw : record[_key];
237
+ } else {
238
+ accumulator[_key] = record[_key];
239
+ }
240
+ return accumulator;
241
+ }, {});
242
+ },
243
+ (state, kind, name, recordId, query) => {
244
+ const context = query?.context ?? "default";
245
+ return [
246
+ state.entities.config,
247
+ state.entities.records?.[kind]?.[name]?.queriedData?.items[context]?.[recordId],
248
+ state.entities.records?.[kind]?.[name]?.queriedData?.itemIsComplete[context]?.[recordId]
249
+ ];
250
+ }
251
+ );
412
252
  function hasEntityRecords(state, kind, name, query) {
413
- (0, _logEntityDeprecation.default)(kind, name, 'hasEntityRecords');
253
+ (0, import_log_entity_deprecation.default)(kind, name, "hasEntityRecords");
414
254
  return Array.isArray(getEntityRecords(state, kind, name, query));
415
255
  }
416
-
417
- /**
418
- * GetEntityRecord is declared as a *callable interface* with
419
- * two signatures to work around the fact that TypeScript doesn't
420
- * allow currying generic functions.
421
- *
422
- * @see GetEntityRecord
423
- * @see https://github.com/WordPress/gutenberg/pull/41578
424
- */
425
-
426
- /**
427
- * Returns the Entity's records.
428
- *
429
- * @param state State tree
430
- * @param kind Entity kind.
431
- * @param name Entity name.
432
- * @param query Optional terms query. If requesting specific
433
- * fields, fields must always include the ID. For valid query parameters see the [Reference](https://developer.wordpress.org/rest-api/reference/) in the REST API Handbook and select the entity kind. Then see the arguments available for "List [Entity kind]s".
434
- *
435
- * @return Records.
436
- */
437
- const getEntityRecords = (state, kind, name, query) => {
438
- (0, _logEntityDeprecation.default)(kind, name, 'getEntityRecords');
439
-
440
- // Queried data state is prepopulated for all known entities. If this is not
441
- // assigned for the given parameters, then it is known to not exist.
256
+ const getEntityRecords = ((state, kind, name, query) => {
257
+ (0, import_log_entity_deprecation.default)(kind, name, "getEntityRecords");
442
258
  const queriedState = state.entities.records?.[kind]?.[name]?.queriedData;
443
259
  if (!queriedState) {
444
260
  return null;
445
261
  }
446
- return (0, _queriedData.getQueriedItems)(queriedState, query);
447
- };
448
-
449
- /**
450
- * Returns the Entity's total available records for a given query (ignoring pagination).
451
- *
452
- * @param state State tree
453
- * @param kind Entity kind.
454
- * @param name Entity name.
455
- * @param query Optional terms query. If requesting specific
456
- * fields, fields must always include the ID. For valid query parameters see the [Reference](https://developer.wordpress.org/rest-api/reference/) in the REST API Handbook and select the entity kind. Then see the arguments available for "List [Entity kind]s".
457
- *
458
- * @return number | null.
459
- */
460
- exports.getEntityRecords = getEntityRecords;
262
+ return (0, import_queried_data.getQueriedItems)(queriedState, query);
263
+ });
461
264
  const getEntityRecordsTotalItems = (state, kind, name, query) => {
462
- (0, _logEntityDeprecation.default)(kind, name, 'getEntityRecordsTotalItems');
463
-
464
- // Queried data state is prepopulated for all known entities. If this is not
465
- // assigned for the given parameters, then it is known to not exist.
265
+ (0, import_log_entity_deprecation.default)(kind, name, "getEntityRecordsTotalItems");
466
266
  const queriedState = state.entities.records?.[kind]?.[name]?.queriedData;
467
267
  if (!queriedState) {
468
268
  return null;
469
269
  }
470
- return (0, _queriedData.getQueriedTotalItems)(queriedState, query);
270
+ return (0, import_queried_data.getQueriedTotalItems)(queriedState, query);
471
271
  };
472
-
473
- /**
474
- * Returns the number of available pages for the given query.
475
- *
476
- * @param state State tree
477
- * @param kind Entity kind.
478
- * @param name Entity name.
479
- * @param query Optional terms query. If requesting specific
480
- * fields, fields must always include the ID. For valid query parameters see the [Reference](https://developer.wordpress.org/rest-api/reference/) in the REST API Handbook and select the entity kind. Then see the arguments available for "List [Entity kind]s".
481
- *
482
- * @return number | null.
483
- */
484
- exports.getEntityRecordsTotalItems = getEntityRecordsTotalItems;
485
272
  const getEntityRecordsTotalPages = (state, kind, name, query) => {
486
- (0, _logEntityDeprecation.default)(kind, name, 'getEntityRecordsTotalPages');
487
-
488
- // Queried data state is prepopulated for all known entities. If this is not
489
- // assigned for the given parameters, then it is known to not exist.
273
+ (0, import_log_entity_deprecation.default)(kind, name, "getEntityRecordsTotalPages");
490
274
  const queriedState = state.entities.records?.[kind]?.[name]?.queriedData;
491
275
  if (!queriedState) {
492
276
  return null;
@@ -494,533 +278,247 @@ const getEntityRecordsTotalPages = (state, kind, name, query) => {
494
278
  if (query?.per_page === -1) {
495
279
  return 1;
496
280
  }
497
- const totalItems = (0, _queriedData.getQueriedTotalItems)(queriedState, query);
281
+ const totalItems = (0, import_queried_data.getQueriedTotalItems)(queriedState, query);
498
282
  if (!totalItems) {
499
283
  return totalItems;
500
284
  }
501
- // If `per_page` is not set and the query relies on the defaults of the
502
- // REST endpoint, get the info from query's meta.
503
285
  if (!query?.per_page) {
504
- return (0, _queriedData.getQueriedTotalPages)(queriedState, query);
286
+ return (0, import_queried_data.getQueriedTotalPages)(queriedState, query);
505
287
  }
506
288
  return Math.ceil(totalItems / query.per_page);
507
289
  };
508
- exports.getEntityRecordsTotalPages = getEntityRecordsTotalPages;
509
- /**
510
- * Returns the list of dirty entity records.
511
- *
512
- * @param state State tree.
513
- *
514
- * @return The list of updated records
515
- */
516
- const __experimentalGetDirtyEntityRecords = exports.__experimentalGetDirtyEntityRecords = (0, _data.createSelector)(state => {
517
- const {
518
- entities: {
519
- records
520
- }
521
- } = state;
522
- const dirtyRecords = [];
523
- Object.keys(records).forEach(kind => {
524
- Object.keys(records[kind]).forEach(name => {
525
- const primaryKeys = Object.keys(records[kind][name].edits).filter(primaryKey =>
526
- // The entity record must exist (not be deleted),
527
- // and it must have edits.
528
- getEntityRecord(state, kind, name, primaryKey) && hasEditsForEntityRecord(state, kind, name, primaryKey));
529
- if (primaryKeys.length) {
530
- const entityConfig = getEntityConfig(state, kind, name);
531
- primaryKeys.forEach(primaryKey => {
532
- const entityRecord = getEditedEntityRecord(state, kind, name, primaryKey);
533
- dirtyRecords.push({
534
- // We avoid using primaryKey because it's transformed into a string
535
- // when it's used as an object key.
536
- key: entityRecord ? entityRecord[entityConfig.key || _entities.DEFAULT_ENTITY_KEY] : undefined,
537
- title: entityConfig?.getTitle?.(entityRecord) || '',
538
- name,
539
- kind
290
+ const __experimentalGetDirtyEntityRecords = (0, import_data.createSelector)(
291
+ (state) => {
292
+ const {
293
+ entities: { records }
294
+ } = state;
295
+ const dirtyRecords = [];
296
+ Object.keys(records).forEach((kind) => {
297
+ Object.keys(records[kind]).forEach((name) => {
298
+ const primaryKeys = Object.keys(records[kind][name].edits).filter(
299
+ (primaryKey) => (
300
+ // The entity record must exist (not be deleted),
301
+ // and it must have edits.
302
+ getEntityRecord(state, kind, name, primaryKey) && hasEditsForEntityRecord(state, kind, name, primaryKey)
303
+ )
304
+ );
305
+ if (primaryKeys.length) {
306
+ const entityConfig = getEntityConfig(state, kind, name);
307
+ primaryKeys.forEach((primaryKey) => {
308
+ const entityRecord = getEditedEntityRecord(
309
+ state,
310
+ kind,
311
+ name,
312
+ primaryKey
313
+ );
314
+ dirtyRecords.push({
315
+ // We avoid using primaryKey because it's transformed into a string
316
+ // when it's used as an object key.
317
+ key: entityRecord ? entityRecord[entityConfig.key || import_entities.DEFAULT_ENTITY_KEY] : void 0,
318
+ title: entityConfig?.getTitle?.(entityRecord) || "",
319
+ name,
320
+ kind
321
+ });
540
322
  });
541
- });
542
- }
323
+ }
324
+ });
543
325
  });
544
- });
545
- return dirtyRecords;
546
- }, state => [state.entities.records]);
547
-
548
- /**
549
- * Returns the list of entities currently being saved.
550
- *
551
- * @param state State tree.
552
- *
553
- * @return The list of records being saved.
554
- */
555
- const __experimentalGetEntitiesBeingSaved = exports.__experimentalGetEntitiesBeingSaved = (0, _data.createSelector)(state => {
556
- const {
557
- entities: {
558
- records
559
- }
560
- } = state;
561
- const recordsBeingSaved = [];
562
- Object.keys(records).forEach(kind => {
563
- Object.keys(records[kind]).forEach(name => {
564
- const primaryKeys = Object.keys(records[kind][name].saving).filter(primaryKey => isSavingEntityRecord(state, kind, name, primaryKey));
565
- if (primaryKeys.length) {
566
- const entityConfig = getEntityConfig(state, kind, name);
567
- primaryKeys.forEach(primaryKey => {
568
- const entityRecord = getEditedEntityRecord(state, kind, name, primaryKey);
569
- recordsBeingSaved.push({
570
- // We avoid using primaryKey because it's transformed into a string
571
- // when it's used as an object key.
572
- key: entityRecord ? entityRecord[entityConfig.key || _entities.DEFAULT_ENTITY_KEY] : undefined,
573
- title: entityConfig?.getTitle?.(entityRecord) || '',
574
- name,
575
- kind
326
+ return dirtyRecords;
327
+ },
328
+ (state) => [state.entities.records]
329
+ );
330
+ const __experimentalGetEntitiesBeingSaved = (0, import_data.createSelector)(
331
+ (state) => {
332
+ const {
333
+ entities: { records }
334
+ } = state;
335
+ const recordsBeingSaved = [];
336
+ Object.keys(records).forEach((kind) => {
337
+ Object.keys(records[kind]).forEach((name) => {
338
+ const primaryKeys = Object.keys(records[kind][name].saving).filter(
339
+ (primaryKey) => isSavingEntityRecord(state, kind, name, primaryKey)
340
+ );
341
+ if (primaryKeys.length) {
342
+ const entityConfig = getEntityConfig(state, kind, name);
343
+ primaryKeys.forEach((primaryKey) => {
344
+ const entityRecord = getEditedEntityRecord(
345
+ state,
346
+ kind,
347
+ name,
348
+ primaryKey
349
+ );
350
+ recordsBeingSaved.push({
351
+ // We avoid using primaryKey because it's transformed into a string
352
+ // when it's used as an object key.
353
+ key: entityRecord ? entityRecord[entityConfig.key || import_entities.DEFAULT_ENTITY_KEY] : void 0,
354
+ title: entityConfig?.getTitle?.(entityRecord) || "",
355
+ name,
356
+ kind
357
+ });
576
358
  });
577
- });
578
- }
359
+ }
360
+ });
579
361
  });
580
- });
581
- return recordsBeingSaved;
582
- }, state => [state.entities.records]);
583
-
584
- /**
585
- * Returns the specified entity record's edits.
586
- *
587
- * @param state State tree.
588
- * @param kind Entity kind.
589
- * @param name Entity name.
590
- * @param recordId Record ID.
591
- *
592
- * @return The entity record's edits.
593
- */
362
+ return recordsBeingSaved;
363
+ },
364
+ (state) => [state.entities.records]
365
+ );
594
366
  function getEntityRecordEdits(state, kind, name, recordId) {
595
- (0, _logEntityDeprecation.default)(kind, name, 'getEntityRecordEdits');
367
+ (0, import_log_entity_deprecation.default)(kind, name, "getEntityRecordEdits");
596
368
  return state.entities.records?.[kind]?.[name]?.edits?.[recordId];
597
369
  }
598
-
599
- /**
600
- * Returns the specified entity record's non transient edits.
601
- *
602
- * Transient edits don't create an undo level, and
603
- * are not considered for change detection.
604
- * They are defined in the entity's config.
605
- *
606
- * @param state State tree.
607
- * @param kind Entity kind.
608
- * @param name Entity name.
609
- * @param recordId Record ID.
610
- *
611
- * @return The entity record's non transient edits.
612
- */
613
- const getEntityRecordNonTransientEdits = exports.getEntityRecordNonTransientEdits = (0, _data.createSelector)((state, kind, name, recordId) => {
614
- (0, _logEntityDeprecation.default)(kind, name, 'getEntityRecordNonTransientEdits');
615
- const {
616
- transientEdits
617
- } = getEntityConfig(state, kind, name) || {};
618
- const edits = getEntityRecordEdits(state, kind, name, recordId) || {};
619
- if (!transientEdits) {
620
- return edits;
621
- }
622
- return Object.keys(edits).reduce((acc, key) => {
623
- if (!transientEdits[key]) {
624
- acc[key] = edits[key];
370
+ const getEntityRecordNonTransientEdits = (0, import_data.createSelector)(
371
+ (state, kind, name, recordId) => {
372
+ (0, import_log_entity_deprecation.default)(kind, name, "getEntityRecordNonTransientEdits");
373
+ const { transientEdits } = getEntityConfig(state, kind, name) || {};
374
+ const edits = getEntityRecordEdits(state, kind, name, recordId) || {};
375
+ if (!transientEdits) {
376
+ return edits;
625
377
  }
626
- return acc;
627
- }, {});
628
- }, (state, kind, name, recordId) => [state.entities.config, state.entities.records?.[kind]?.[name]?.edits?.[recordId]]);
629
-
630
- /**
631
- * Returns true if the specified entity record has edits,
632
- * and false otherwise.
633
- *
634
- * @param state State tree.
635
- * @param kind Entity kind.
636
- * @param name Entity name.
637
- * @param recordId Record ID.
638
- *
639
- * @return Whether the entity record has edits or not.
640
- */
378
+ return Object.keys(edits).reduce((acc, key) => {
379
+ if (!transientEdits[key]) {
380
+ acc[key] = edits[key];
381
+ }
382
+ return acc;
383
+ }, {});
384
+ },
385
+ (state, kind, name, recordId) => [
386
+ state.entities.config,
387
+ state.entities.records?.[kind]?.[name]?.edits?.[recordId]
388
+ ]
389
+ );
641
390
  function hasEditsForEntityRecord(state, kind, name, recordId) {
642
- (0, _logEntityDeprecation.default)(kind, name, 'hasEditsForEntityRecord');
643
- return isSavingEntityRecord(state, kind, name, recordId) || Object.keys(getEntityRecordNonTransientEdits(state, kind, name, recordId)).length > 0;
644
- }
645
-
646
- /**
647
- * Returns the specified entity record, merged with its edits.
648
- *
649
- * @param state State tree.
650
- * @param kind Entity kind.
651
- * @param name Entity name.
652
- * @param recordId Record ID.
653
- *
654
- * @return The entity record, merged with its edits.
655
- */
656
- const getEditedEntityRecord = exports.getEditedEntityRecord = (0, _data.createSelector)((state, kind, name, recordId) => {
657
- (0, _logEntityDeprecation.default)(kind, name, 'getEditedEntityRecord');
658
- const raw = getRawEntityRecord(state, kind, name, recordId);
659
- const edited = getEntityRecordEdits(state, kind, name, recordId);
660
- // Never return a non-falsy empty object. Unfortunately we can't return
661
- // undefined or null because we were previously returning an empty
662
- // object, so trying to read properties from the result would throw.
663
- // Using false here is a workaround to avoid breaking changes.
664
- if (!raw && !edited) {
665
- return false;
391
+ (0, import_log_entity_deprecation.default)(kind, name, "hasEditsForEntityRecord");
392
+ return isSavingEntityRecord(state, kind, name, recordId) || Object.keys(
393
+ getEntityRecordNonTransientEdits(state, kind, name, recordId)
394
+ ).length > 0;
395
+ }
396
+ const getEditedEntityRecord = (0, import_data.createSelector)(
397
+ (state, kind, name, recordId) => {
398
+ (0, import_log_entity_deprecation.default)(kind, name, "getEditedEntityRecord");
399
+ const raw = getRawEntityRecord(state, kind, name, recordId);
400
+ const edited = getEntityRecordEdits(state, kind, name, recordId);
401
+ if (!raw && !edited) {
402
+ return false;
403
+ }
404
+ return {
405
+ ...raw,
406
+ ...edited
407
+ };
408
+ },
409
+ (state, kind, name, recordId, query) => {
410
+ const context = query?.context ?? "default";
411
+ return [
412
+ state.entities.config,
413
+ state.entities.records?.[kind]?.[name]?.queriedData.items[context]?.[recordId],
414
+ state.entities.records?.[kind]?.[name]?.queriedData.itemIsComplete[context]?.[recordId],
415
+ state.entities.records?.[kind]?.[name]?.edits?.[recordId]
416
+ ];
666
417
  }
667
- return {
668
- ...raw,
669
- ...edited
670
- };
671
- }, (state, kind, name, recordId, query) => {
672
- var _query$context5;
673
- const context = (_query$context5 = query?.context) !== null && _query$context5 !== void 0 ? _query$context5 : 'default';
674
- return [state.entities.config, state.entities.records?.[kind]?.[name]?.queriedData.items[context]?.[recordId], state.entities.records?.[kind]?.[name]?.queriedData.itemIsComplete[context]?.[recordId], state.entities.records?.[kind]?.[name]?.edits?.[recordId]];
675
- });
676
-
677
- /**
678
- * Returns true if the specified entity record is autosaving, and false otherwise.
679
- *
680
- * @param state State tree.
681
- * @param kind Entity kind.
682
- * @param name Entity name.
683
- * @param recordId Record ID.
684
- *
685
- * @return Whether the entity record is autosaving or not.
686
- */
418
+ );
687
419
  function isAutosavingEntityRecord(state, kind, name, recordId) {
688
- var _state$entities$recor;
689
- (0, _logEntityDeprecation.default)(kind, name, 'isAutosavingEntityRecord');
690
- const {
691
- pending,
692
- isAutosave
693
- } = (_state$entities$recor = state.entities.records?.[kind]?.[name]?.saving?.[recordId]) !== null && _state$entities$recor !== void 0 ? _state$entities$recor : {};
420
+ (0, import_log_entity_deprecation.default)(kind, name, "isAutosavingEntityRecord");
421
+ const { pending, isAutosave } = state.entities.records?.[kind]?.[name]?.saving?.[recordId] ?? {};
694
422
  return Boolean(pending && isAutosave);
695
423
  }
696
-
697
- /**
698
- * Returns true if the specified entity record is saving, and false otherwise.
699
- *
700
- * @param state State tree.
701
- * @param kind Entity kind.
702
- * @param name Entity name.
703
- * @param recordId Record ID.
704
- *
705
- * @return Whether the entity record is saving or not.
706
- */
707
424
  function isSavingEntityRecord(state, kind, name, recordId) {
708
- var _state$entities$recor2;
709
- (0, _logEntityDeprecation.default)(kind, name, 'isSavingEntityRecord');
710
- return (_state$entities$recor2 = state.entities.records?.[kind]?.[name]?.saving?.[recordId]?.pending) !== null && _state$entities$recor2 !== void 0 ? _state$entities$recor2 : false;
425
+ (0, import_log_entity_deprecation.default)(kind, name, "isSavingEntityRecord");
426
+ return state.entities.records?.[kind]?.[name]?.saving?.[recordId]?.pending ?? false;
711
427
  }
712
-
713
- /**
714
- * Returns true if the specified entity record is deleting, and false otherwise.
715
- *
716
- * @param state State tree.
717
- * @param kind Entity kind.
718
- * @param name Entity name.
719
- * @param recordId Record ID.
720
- *
721
- * @return Whether the entity record is deleting or not.
722
- */
723
428
  function isDeletingEntityRecord(state, kind, name, recordId) {
724
- var _state$entities$recor3;
725
- (0, _logEntityDeprecation.default)(kind, name, 'isDeletingEntityRecord');
726
- return (_state$entities$recor3 = state.entities.records?.[kind]?.[name]?.deleting?.[recordId]?.pending) !== null && _state$entities$recor3 !== void 0 ? _state$entities$recor3 : false;
429
+ (0, import_log_entity_deprecation.default)(kind, name, "isDeletingEntityRecord");
430
+ return state.entities.records?.[kind]?.[name]?.deleting?.[recordId]?.pending ?? false;
727
431
  }
728
-
729
- /**
730
- * Returns the specified entity record's last save error.
731
- *
732
- * @param state State tree.
733
- * @param kind Entity kind.
734
- * @param name Entity name.
735
- * @param recordId Record ID.
736
- *
737
- * @return The entity record's save error.
738
- */
739
432
  function getLastEntitySaveError(state, kind, name, recordId) {
740
- (0, _logEntityDeprecation.default)(kind, name, 'getLastEntitySaveError');
433
+ (0, import_log_entity_deprecation.default)(kind, name, "getLastEntitySaveError");
741
434
  return state.entities.records?.[kind]?.[name]?.saving?.[recordId]?.error;
742
435
  }
743
-
744
- /**
745
- * Returns the specified entity record's last delete error.
746
- *
747
- * @param state State tree.
748
- * @param kind Entity kind.
749
- * @param name Entity name.
750
- * @param recordId Record ID.
751
- *
752
- * @return The entity record's save error.
753
- */
754
436
  function getLastEntityDeleteError(state, kind, name, recordId) {
755
- (0, _logEntityDeprecation.default)(kind, name, 'getLastEntityDeleteError');
437
+ (0, import_log_entity_deprecation.default)(kind, name, "getLastEntityDeleteError");
756
438
  return state.entities.records?.[kind]?.[name]?.deleting?.[recordId]?.error;
757
439
  }
758
-
759
- /* eslint-disable @typescript-eslint/no-unused-vars */
760
- /**
761
- * Returns the previous edit from the current undo offset
762
- * for the entity records edits history, if any.
763
- *
764
- * @deprecated since 6.3
765
- *
766
- * @param state State tree.
767
- *
768
- * @return The edit.
769
- */
770
440
  function getUndoEdit(state) {
771
- (0, _deprecated.default)("select( 'core' ).getUndoEdit()", {
772
- since: '6.3'
441
+ (0, import_deprecated.default)("select( 'core' ).getUndoEdit()", {
442
+ since: "6.3"
773
443
  });
774
- return undefined;
444
+ return void 0;
775
445
  }
776
- /* eslint-enable @typescript-eslint/no-unused-vars */
777
-
778
- /* eslint-disable @typescript-eslint/no-unused-vars */
779
- /**
780
- * Returns the next edit from the current undo offset
781
- * for the entity records edits history, if any.
782
- *
783
- * @deprecated since 6.3
784
- *
785
- * @param state State tree.
786
- *
787
- * @return The edit.
788
- */
789
446
  function getRedoEdit(state) {
790
- (0, _deprecated.default)("select( 'core' ).getRedoEdit()", {
791
- since: '6.3'
447
+ (0, import_deprecated.default)("select( 'core' ).getRedoEdit()", {
448
+ since: "6.3"
792
449
  });
793
- return undefined;
450
+ return void 0;
794
451
  }
795
- /* eslint-enable @typescript-eslint/no-unused-vars */
796
-
797
- /**
798
- * Returns true if there is a previous edit from the current undo offset
799
- * for the entity records edits history, and false otherwise.
800
- *
801
- * @param state State tree.
802
- *
803
- * @return Whether there is a previous edit or not.
804
- */
805
452
  function hasUndo(state) {
806
453
  return state.undoManager.hasUndo();
807
454
  }
808
-
809
- /**
810
- * Returns true if there is a next edit from the current undo offset
811
- * for the entity records edits history, and false otherwise.
812
- *
813
- * @param state State tree.
814
- *
815
- * @return Whether there is a next edit or not.
816
- */
817
455
  function hasRedo(state) {
818
456
  return state.undoManager.hasRedo();
819
457
  }
820
-
821
- /**
822
- * Return the current theme.
823
- *
824
- * @param state Data state.
825
- *
826
- * @return The current theme.
827
- */
828
458
  function getCurrentTheme(state) {
829
459
  if (!state.currentTheme) {
830
460
  return null;
831
461
  }
832
- return getEntityRecord(state, 'root', 'theme', state.currentTheme);
462
+ return getEntityRecord(state, "root", "theme", state.currentTheme);
833
463
  }
834
-
835
- /**
836
- * Return the ID of the current global styles object.
837
- *
838
- * @param state Data state.
839
- *
840
- * @return The current global styles ID.
841
- */
842
464
  function __experimentalGetCurrentGlobalStylesId(state) {
843
465
  return state.currentGlobalStylesId;
844
466
  }
845
-
846
- /**
847
- * Return theme supports data in the index.
848
- *
849
- * @param state Data state.
850
- *
851
- * @return Index data.
852
- */
853
467
  function getThemeSupports(state) {
854
- var _getCurrentTheme$them;
855
- return (_getCurrentTheme$them = getCurrentTheme(state)?.theme_supports) !== null && _getCurrentTheme$them !== void 0 ? _getCurrentTheme$them : EMPTY_OBJECT;
468
+ return getCurrentTheme(state)?.theme_supports ?? EMPTY_OBJECT;
856
469
  }
857
-
858
- /**
859
- * Returns the embed preview for the given URL.
860
- *
861
- * @param state Data state.
862
- * @param url Embedded URL.
863
- *
864
- * @return Undefined if the preview has not been fetched, otherwise, the preview fetched from the embed preview API.
865
- */
866
470
  function getEmbedPreview(state, url) {
867
471
  return state.embedPreviews[url];
868
472
  }
869
-
870
- /**
871
- * Determines if the returned preview is an oEmbed link fallback.
872
- *
873
- * WordPress can be configured to return a simple link to a URL if it is not embeddable.
874
- * We need to be able to determine if a URL is embeddable or not, based on what we
875
- * get back from the oEmbed preview API.
876
- *
877
- * @param state Data state.
878
- * @param url Embedded URL.
879
- *
880
- * @return Is the preview for the URL an oEmbed link fallback.
881
- */
882
473
  function isPreviewEmbedFallback(state, url) {
883
474
  const preview = state.embedPreviews[url];
884
- const oEmbedLinkCheck = '<a href="' + url + '">' + url + '</a>';
475
+ const oEmbedLinkCheck = '<a href="' + url + '">' + url + "</a>";
885
476
  if (!preview) {
886
477
  return false;
887
478
  }
888
479
  return preview.html === oEmbedLinkCheck;
889
480
  }
890
-
891
- /**
892
- * Returns whether the current user can perform the given action on the given
893
- * REST resource.
894
- *
895
- * Calling this may trigger an OPTIONS request to the REST API via the
896
- * `canUser()` resolver.
897
- *
898
- * https://developer.wordpress.org/rest-api/reference/
899
- *
900
- * @param state Data state.
901
- * @param action Action to check. One of: 'create', 'read', 'update', 'delete'.
902
- * @param resource Entity resource to check. Accepts entity object `{ kind: 'postType', name: 'attachment', id: 1 }`
903
- * or REST base as a string - `media`.
904
- * @param id Optional ID of the rest resource to check.
905
- *
906
- * @return Whether or not the user can perform the action,
907
- * or `undefined` if the OPTIONS request is still being made.
908
- */
909
481
  function canUser(state, action, resource, id) {
910
- const isEntity = typeof resource === 'object';
482
+ const isEntity = typeof resource === "object";
911
483
  if (isEntity && (!resource.kind || !resource.name)) {
912
484
  return false;
913
485
  }
914
486
  if (isEntity) {
915
- (0, _logEntityDeprecation.default)(resource.kind, resource.name, 'canUser');
487
+ (0, import_log_entity_deprecation.default)(resource.kind, resource.name, "canUser");
916
488
  }
917
- const key = (0, _utils.getUserPermissionCacheKey)(action, resource, id);
489
+ const key = (0, import_utils.getUserPermissionCacheKey)(action, resource, id);
918
490
  return state.userPermissions[key];
919
491
  }
920
-
921
- /**
922
- * Returns whether the current user can edit the given entity.
923
- *
924
- * Calling this may trigger an OPTIONS request to the REST API via the
925
- * `canUser()` resolver.
926
- *
927
- * https://developer.wordpress.org/rest-api/reference/
928
- *
929
- * @param state Data state.
930
- * @param kind Entity kind.
931
- * @param name Entity name.
932
- * @param recordId Record's id.
933
- * @return Whether or not the user can edit,
934
- * or `undefined` if the OPTIONS request is still being made.
935
- */
936
492
  function canUserEditEntityRecord(state, kind, name, recordId) {
937
- (0, _deprecated.default)(`wp.data.select( 'core' ).canUserEditEntityRecord()`, {
938
- since: '6.7',
493
+ (0, import_deprecated.default)(`wp.data.select( 'core' ).canUserEditEntityRecord()`, {
494
+ since: "6.7",
939
495
  alternative: `wp.data.select( 'core' ).canUser( 'update', { kind, name, id } )`
940
496
  });
941
- return canUser(state, 'update', {
942
- kind,
943
- name,
944
- id: recordId
945
- });
497
+ return canUser(state, "update", { kind, name, id: recordId });
946
498
  }
947
-
948
- /**
949
- * Returns the latest autosaves for the post.
950
- *
951
- * May return multiple autosaves since the backend stores one autosave per
952
- * author for each post.
953
- *
954
- * @param state State tree.
955
- * @param postType The type of the parent post.
956
- * @param postId The id of the parent post.
957
- *
958
- * @return An array of autosaves for the post, or undefined if there is none.
959
- */
960
499
  function getAutosaves(state, postType, postId) {
961
500
  return state.autosaves[postId];
962
501
  }
963
-
964
- /**
965
- * Returns the autosave for the post and author.
966
- *
967
- * @param state State tree.
968
- * @param postType The type of the parent post.
969
- * @param postId The id of the parent post.
970
- * @param authorId The id of the author.
971
- *
972
- * @return The autosave for the post and author.
973
- */
974
502
  function getAutosave(state, postType, postId, authorId) {
975
- if (authorId === undefined) {
503
+ if (authorId === void 0) {
976
504
  return;
977
505
  }
978
506
  const autosaves = state.autosaves[postId];
979
- return autosaves?.find(autosave => autosave.author === authorId);
980
- }
981
-
982
- /**
983
- * Returns true if the REST request for autosaves has completed.
984
- *
985
- * @param state State tree.
986
- * @param postType The type of the parent post.
987
- * @param postId The id of the parent post.
988
- *
989
- * @return True if the REST request was completed. False otherwise.
990
- */
991
- const hasFetchedAutosaves = exports.hasFetchedAutosaves = (0, _data.createRegistrySelector)(select => (state, postType, postId) => {
992
- return select(_name.STORE_NAME).hasFinishedResolution('getAutosaves', [postType, postId]);
993
- });
994
-
995
- /**
996
- * Returns a new reference when edited values have changed. This is useful in
997
- * inferring where an edit has been made between states by comparison of the
998
- * return values using strict equality.
999
- *
1000
- * @example
1001
- *
1002
- * ```
1003
- * const hasEditOccurred = (
1004
- * getReferenceByDistinctEdits( beforeState ) !==
1005
- * getReferenceByDistinctEdits( afterState )
1006
- * );
1007
- * ```
1008
- *
1009
- * @param state Editor state.
1010
- *
1011
- * @return A value whose reference will change only when an edit occurs.
1012
- */
507
+ return autosaves?.find(
508
+ (autosave) => autosave.author === authorId
509
+ );
510
+ }
511
+ const hasFetchedAutosaves = (0, import_data.createRegistrySelector)(
512
+ (select) => (state, postType, postId) => {
513
+ return select(import_name.STORE_NAME).hasFinishedResolution("getAutosaves", [
514
+ postType,
515
+ postId
516
+ ]);
517
+ }
518
+ );
1013
519
  function getReferenceByDistinctEdits(state) {
1014
520
  return state.editsReference;
1015
521
  }
1016
-
1017
- /**
1018
- * Retrieve the current theme's base global styles
1019
- *
1020
- * @param state Editor state.
1021
- *
1022
- * @return The Global Styles object.
1023
- */
1024
522
  function __experimentalGetCurrentThemeBaseGlobalStyles(state) {
1025
523
  const currentTheme = getCurrentTheme(state);
1026
524
  if (!currentTheme) {
@@ -1028,14 +526,6 @@ function __experimentalGetCurrentThemeBaseGlobalStyles(state) {
1028
526
  }
1029
527
  return state.themeBaseGlobalStyles[currentTheme.stylesheet];
1030
528
  }
1031
-
1032
- /**
1033
- * Return the ID of the current global styles object.
1034
- *
1035
- * @param state Data state.
1036
- *
1037
- * @return The current global styles ID.
1038
- */
1039
529
  function __experimentalGetCurrentThemeGlobalStylesVariations(state) {
1040
530
  const currentTheme = getCurrentTheme(state);
1041
531
  if (!currentTheme) {
@@ -1043,53 +533,18 @@ function __experimentalGetCurrentThemeGlobalStylesVariations(state) {
1043
533
  }
1044
534
  return state.themeGlobalStyleVariations[currentTheme.stylesheet];
1045
535
  }
1046
-
1047
- /**
1048
- * Retrieve the list of registered block patterns.
1049
- *
1050
- * @param state Data state.
1051
- *
1052
- * @return Block pattern list.
1053
- */
1054
536
  function getBlockPatterns(state) {
1055
537
  return state.blockPatterns;
1056
538
  }
1057
-
1058
- /**
1059
- * Retrieve the list of registered block pattern categories.
1060
- *
1061
- * @param state Data state.
1062
- *
1063
- * @return Block pattern category list.
1064
- */
1065
539
  function getBlockPatternCategories(state) {
1066
540
  return state.blockPatternCategories;
1067
541
  }
1068
-
1069
- /**
1070
- * Retrieve the registered user pattern categories.
1071
- *
1072
- * @param state Data state.
1073
- *
1074
- * @return User patterns category array.
1075
- */
1076
-
1077
542
  function getUserPatternCategories(state) {
1078
543
  return state.userPatternCategories;
1079
544
  }
1080
-
1081
- /**
1082
- * Returns the revisions of the current global styles theme.
1083
- *
1084
- * @deprecated since WordPress 6.5.0. Callers should use `select( 'core' ).getRevisions( 'root', 'globalStyles', ${ recordKey } )` instead, where `recordKey` is the id of the global styles parent post.
1085
- *
1086
- * @param state Data state.
1087
- *
1088
- * @return The current global styles.
1089
- */
1090
545
  function getCurrentThemeGlobalStylesRevisions(state) {
1091
- (0, _deprecated.default)("select( 'core' ).getCurrentThemeGlobalStylesRevisions()", {
1092
- since: '6.5.0',
546
+ (0, import_deprecated.default)("select( 'core' ).getCurrentThemeGlobalStylesRevisions()", {
547
+ since: "6.5.0",
1093
548
  alternative: "select( 'core' ).getRevisions( 'root', 'globalStyles', ${ recordKey } )"
1094
549
  });
1095
550
  const currentGlobalStylesId = __experimentalGetCurrentGlobalStylesId(state);
@@ -1098,88 +553,108 @@ function getCurrentThemeGlobalStylesRevisions(state) {
1098
553
  }
1099
554
  return state.themeGlobalStyleRevisions[currentGlobalStylesId];
1100
555
  }
1101
-
1102
- /**
1103
- * Returns the default template use to render a given query.
1104
- *
1105
- * @param state Data state.
1106
- * @param query Query.
1107
- *
1108
- * @return The default template id for the given query.
1109
- */
1110
556
  function getDefaultTemplateId(state, query) {
1111
557
  return state.defaultTemplates[JSON.stringify(query)];
1112
558
  }
1113
-
1114
- /**
1115
- * Returns an entity's revisions.
1116
- *
1117
- * @param state State tree
1118
- * @param kind Entity kind.
1119
- * @param name Entity name.
1120
- * @param recordKey The key of the entity record whose revisions you want to fetch.
1121
- * @param query Optional query. If requesting specific
1122
- * fields, fields must always include the ID. For valid query parameters see revisions schema in [the REST API Handbook](https://developer.wordpress.org/rest-api/reference/). Then see the arguments available "Retrieve a [Entity kind]".
1123
- *
1124
- * @return Record.
1125
- */
1126
559
  const getRevisions = (state, kind, name, recordKey, query) => {
1127
- (0, _logEntityDeprecation.default)(kind, name, 'getRevisions');
560
+ (0, import_log_entity_deprecation.default)(kind, name, "getRevisions");
1128
561
  const queriedStateRevisions = state.entities.records?.[kind]?.[name]?.revisions?.[recordKey];
1129
562
  if (!queriedStateRevisions) {
1130
563
  return null;
1131
564
  }
1132
- return (0, _queriedData.getQueriedItems)(queriedStateRevisions, query);
565
+ return (0, import_queried_data.getQueriedItems)(queriedStateRevisions, query);
1133
566
  };
1134
-
1135
- /**
1136
- * Returns a single, specific revision of a parent entity.
1137
- *
1138
- * @param state State tree
1139
- * @param kind Entity kind.
1140
- * @param name Entity name.
1141
- * @param recordKey The key of the entity record whose revisions you want to fetch.
1142
- * @param revisionKey The revision's key.
1143
- * @param query Optional query. If requesting specific
1144
- * fields, fields must always include the ID. For valid query parameters see revisions schema in [the REST API Handbook](https://developer.wordpress.org/rest-api/reference/). Then see the arguments available "Retrieve a [entity kind]".
1145
- *
1146
- * @return Record.
1147
- */
1148
- exports.getRevisions = getRevisions;
1149
- const getRevision = exports.getRevision = (0, _data.createSelector)((state, kind, name, recordKey, revisionKey, query) => {
1150
- var _query$context6, _getNormalizedCommaSe3;
1151
- (0, _logEntityDeprecation.default)(kind, name, 'getRevision');
1152
- const queriedState = state.entities.records?.[kind]?.[name]?.revisions?.[recordKey];
1153
- if (!queriedState) {
1154
- return undefined;
1155
- }
1156
- const context = (_query$context6 = query?.context) !== null && _query$context6 !== void 0 ? _query$context6 : 'default';
1157
- if (!query || !query._fields) {
1158
- // If expecting a complete item, validate that completeness.
1159
- if (!queriedState.itemIsComplete[context]?.[revisionKey]) {
1160
- return undefined;
567
+ const getRevision = (0, import_data.createSelector)(
568
+ (state, kind, name, recordKey, revisionKey, query) => {
569
+ (0, import_log_entity_deprecation.default)(kind, name, "getRevision");
570
+ const queriedState = state.entities.records?.[kind]?.[name]?.revisions?.[recordKey];
571
+ if (!queriedState) {
572
+ return void 0;
1161
573
  }
1162
- return queriedState.items[context][revisionKey];
1163
- }
1164
- const item = queriedState.items[context]?.[revisionKey];
1165
- if (!item) {
1166
- return item;
1167
- }
1168
- const filteredItem = {};
1169
- const fields = (_getNormalizedCommaSe3 = (0, _utils.getNormalizedCommaSeparable)(query._fields)) !== null && _getNormalizedCommaSe3 !== void 0 ? _getNormalizedCommaSe3 : [];
1170
- for (let f = 0; f < fields.length; f++) {
1171
- const field = fields[f].split('.');
1172
- let value = item;
1173
- field.forEach(fieldName => {
1174
- value = value?.[fieldName];
1175
- });
1176
- (0, _utils.setNestedValue)(filteredItem, field, value);
574
+ const context = query?.context ?? "default";
575
+ if (!query || !query._fields) {
576
+ if (!queriedState.itemIsComplete[context]?.[revisionKey]) {
577
+ return void 0;
578
+ }
579
+ return queriedState.items[context][revisionKey];
580
+ }
581
+ const item = queriedState.items[context]?.[revisionKey];
582
+ if (!item) {
583
+ return item;
584
+ }
585
+ const filteredItem = {};
586
+ const fields = (0, import_utils.getNormalizedCommaSeparable)(query._fields) ?? [];
587
+ for (let f = 0; f < fields.length; f++) {
588
+ const field = fields[f].split(".");
589
+ let value = item;
590
+ field.forEach((fieldName) => {
591
+ value = value?.[fieldName];
592
+ });
593
+ (0, import_utils.setNestedValue)(filteredItem, field, value);
594
+ }
595
+ return filteredItem;
596
+ },
597
+ (state, kind, name, recordKey, revisionKey, query) => {
598
+ const context = query?.context ?? "default";
599
+ const queriedState = state.entities.records?.[kind]?.[name]?.revisions?.[recordKey];
600
+ return [
601
+ queriedState?.items?.[context]?.[revisionKey],
602
+ queriedState?.itemIsComplete?.[context]?.[revisionKey]
603
+ ];
1177
604
  }
1178
- return filteredItem;
1179
- }, (state, kind, name, recordKey, revisionKey, query) => {
1180
- var _query$context7;
1181
- const context = (_query$context7 = query?.context) !== null && _query$context7 !== void 0 ? _query$context7 : 'default';
1182
- const queriedState = state.entities.records?.[kind]?.[name]?.revisions?.[recordKey];
1183
- return [queriedState?.items?.[context]?.[revisionKey], queriedState?.itemIsComplete?.[context]?.[revisionKey]];
605
+ );
606
+ // Annotate the CommonJS export names for ESM import in node:
607
+ 0 && (module.exports = {
608
+ __experimentalGetCurrentGlobalStylesId,
609
+ __experimentalGetCurrentThemeBaseGlobalStyles,
610
+ __experimentalGetCurrentThemeGlobalStylesVariations,
611
+ __experimentalGetDirtyEntityRecords,
612
+ __experimentalGetEntitiesBeingSaved,
613
+ __experimentalGetEntityRecordNoResolver,
614
+ canUser,
615
+ canUserEditEntityRecord,
616
+ getAuthors,
617
+ getAutosave,
618
+ getAutosaves,
619
+ getBlockPatternCategories,
620
+ getBlockPatterns,
621
+ getCurrentTheme,
622
+ getCurrentThemeGlobalStylesRevisions,
623
+ getCurrentUser,
624
+ getDefaultTemplateId,
625
+ getEditedEntityRecord,
626
+ getEmbedPreview,
627
+ getEntitiesByKind,
628
+ getEntitiesConfig,
629
+ getEntity,
630
+ getEntityConfig,
631
+ getEntityRecord,
632
+ getEntityRecordEdits,
633
+ getEntityRecordNonTransientEdits,
634
+ getEntityRecords,
635
+ getEntityRecordsTotalItems,
636
+ getEntityRecordsTotalPages,
637
+ getLastEntityDeleteError,
638
+ getLastEntitySaveError,
639
+ getRawEntityRecord,
640
+ getRedoEdit,
641
+ getReferenceByDistinctEdits,
642
+ getRevision,
643
+ getRevisions,
644
+ getThemeSupports,
645
+ getUndoEdit,
646
+ getUserPatternCategories,
647
+ getUserQueryResults,
648
+ hasEditsForEntityRecord,
649
+ hasEntityRecord,
650
+ hasEntityRecords,
651
+ hasFetchedAutosaves,
652
+ hasRedo,
653
+ hasUndo,
654
+ isAutosavingEntityRecord,
655
+ isDeletingEntityRecord,
656
+ isPreviewEmbedFallback,
657
+ isRequestingEmbedPreview,
658
+ isSavingEntityRecord
1184
659
  });
1185
- //# sourceMappingURL=selectors.js.map
660
+ //# sourceMappingURL=selectors.js.map