@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 +1,7 @@
1
- {"version":3,"names":["reducer","isLockAvailable","getPendingLockRequests","createLocks","state","undefined","type","processPendingLockRequests","request","store","path","exclusive","notifyAcquired","lock","acquire","Promise","resolve","release"],"sources":["@wordpress/core-data/src/locks/engine.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport reducer from './reducer';\nimport { isLockAvailable, getPendingLockRequests } from './selectors';\n\nexport default function createLocks() {\n\tlet state = reducer( undefined, { type: '@@INIT' } );\n\n\tfunction processPendingLockRequests() {\n\t\tfor ( const request of getPendingLockRequests( state ) ) {\n\t\t\tconst { store, path, exclusive, notifyAcquired } = request;\n\t\t\tif ( isLockAvailable( state, store, path, { exclusive } ) ) {\n\t\t\t\tconst lock = { store, path, exclusive };\n\t\t\t\tstate = reducer( state, {\n\t\t\t\t\ttype: 'GRANT_LOCK_REQUEST',\n\t\t\t\t\tlock,\n\t\t\t\t\trequest,\n\t\t\t\t} );\n\t\t\t\tnotifyAcquired( lock );\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction acquire( store, path, exclusive ) {\n\t\treturn new Promise( ( resolve ) => {\n\t\t\tstate = reducer( state, {\n\t\t\t\ttype: 'ENQUEUE_LOCK_REQUEST',\n\t\t\t\trequest: { store, path, exclusive, notifyAcquired: resolve },\n\t\t\t} );\n\t\t\tprocessPendingLockRequests();\n\t\t} );\n\t}\n\tfunction release( lock ) {\n\t\tstate = reducer( state, {\n\t\t\ttype: 'RELEASE_LOCK',\n\t\t\tlock,\n\t\t} );\n\t\tprocessPendingLockRequests();\n\t}\n\n\treturn { acquire, release };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,OAAO,MAAM,WAAW;AAC/B,SAASC,eAAe,EAAEC,sBAAsB,QAAQ,aAAa;AAErE,eAAe,SAASC,WAAWA,CAAA,EAAG;EACrC,IAAIC,KAAK,GAAGJ,OAAO,CAAEK,SAAS,EAAE;IAAEC,IAAI,EAAE;EAAS,CAAE,CAAC;EAEpD,SAASC,0BAA0BA,CAAA,EAAG;IACrC,KAAM,MAAMC,OAAO,IAAIN,sBAAsB,CAAEE,KAAM,CAAC,EAAG;MACxD,MAAM;QAAEK,KAAK;QAAEC,IAAI;QAAEC,SAAS;QAAEC;MAAe,CAAC,GAAGJ,OAAO;MAC1D,IAAKP,eAAe,CAAEG,KAAK,EAAEK,KAAK,EAAEC,IAAI,EAAE;QAAEC;MAAU,CAAE,CAAC,EAAG;QAC3D,MAAME,IAAI,GAAG;UAAEJ,KAAK;UAAEC,IAAI;UAAEC;QAAU,CAAC;QACvCP,KAAK,GAAGJ,OAAO,CAAEI,KAAK,EAAE;UACvBE,IAAI,EAAE,oBAAoB;UAC1BO,IAAI;UACJL;QACD,CAAE,CAAC;QACHI,cAAc,CAAEC,IAAK,CAAC;MACvB;IACD;EACD;EAEA,SAASC,OAAOA,CAAEL,KAAK,EAAEC,IAAI,EAAEC,SAAS,EAAG;IAC1C,OAAO,IAAII,OAAO,CAAIC,OAAO,IAAM;MAClCZ,KAAK,GAAGJ,OAAO,CAAEI,KAAK,EAAE;QACvBE,IAAI,EAAE,sBAAsB;QAC5BE,OAAO,EAAE;UAAEC,KAAK;UAAEC,IAAI;UAAEC,SAAS;UAAEC,cAAc,EAAEI;QAAQ;MAC5D,CAAE,CAAC;MACHT,0BAA0B,CAAC,CAAC;IAC7B,CAAE,CAAC;EACJ;EACA,SAASU,OAAOA,CAAEJ,IAAI,EAAG;IACxBT,KAAK,GAAGJ,OAAO,CAAEI,KAAK,EAAE;MACvBE,IAAI,EAAE,cAAc;MACpBO;IACD,CAAE,CAAC;IACHN,0BAA0B,CAAC,CAAC;EAC7B;EAEA,OAAO;IAAEO,OAAO;IAAEG;EAAQ,CAAC;AAC5B","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/locks/engine.js"],
4
+ "sourcesContent": ["/**\n * Internal dependencies\n */\nimport reducer from './reducer';\nimport { isLockAvailable, getPendingLockRequests } from './selectors';\n\nexport default function createLocks() {\n\tlet state = reducer( undefined, { type: '@@INIT' } );\n\n\tfunction processPendingLockRequests() {\n\t\tfor ( const request of getPendingLockRequests( state ) ) {\n\t\t\tconst { store, path, exclusive, notifyAcquired } = request;\n\t\t\tif ( isLockAvailable( state, store, path, { exclusive } ) ) {\n\t\t\t\tconst lock = { store, path, exclusive };\n\t\t\t\tstate = reducer( state, {\n\t\t\t\t\ttype: 'GRANT_LOCK_REQUEST',\n\t\t\t\t\tlock,\n\t\t\t\t\trequest,\n\t\t\t\t} );\n\t\t\t\tnotifyAcquired( lock );\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction acquire( store, path, exclusive ) {\n\t\treturn new Promise( ( resolve ) => {\n\t\t\tstate = reducer( state, {\n\t\t\t\ttype: 'ENQUEUE_LOCK_REQUEST',\n\t\t\t\trequest: { store, path, exclusive, notifyAcquired: resolve },\n\t\t\t} );\n\t\t\tprocessPendingLockRequests();\n\t\t} );\n\t}\n\tfunction release( lock ) {\n\t\tstate = reducer( state, {\n\t\t\ttype: 'RELEASE_LOCK',\n\t\t\tlock,\n\t\t} );\n\t\tprocessPendingLockRequests();\n\t}\n\n\treturn { acquire, release };\n}\n"],
5
+ "mappings": "AAGA,OAAO,aAAa;AACpB,SAAS,iBAAiB,8BAA8B;AAEzC,SAAR,cAA+B;AACrC,MAAI,QAAQ,QAAS,QAAW,EAAE,MAAM,SAAS,CAAE;AAEnD,WAAS,6BAA6B;AACrC,eAAY,WAAW,uBAAwB,KAAM,GAAI;AACxD,YAAM,EAAE,OAAO,MAAM,WAAW,eAAe,IAAI;AACnD,UAAK,gBAAiB,OAAO,OAAO,MAAM,EAAE,UAAU,CAAE,GAAI;AAC3D,cAAM,OAAO,EAAE,OAAO,MAAM,UAAU;AACtC,gBAAQ,QAAS,OAAO;AAAA,UACvB,MAAM;AAAA,UACN;AAAA,UACA;AAAA,QACD,CAAE;AACF,uBAAgB,IAAK;AAAA,MACtB;AAAA,IACD;AAAA,EACD;AAEA,WAAS,QAAS,OAAO,MAAM,WAAY;AAC1C,WAAO,IAAI,QAAS,CAAE,YAAa;AAClC,cAAQ,QAAS,OAAO;AAAA,QACvB,MAAM;AAAA,QACN,SAAS,EAAE,OAAO,MAAM,WAAW,gBAAgB,QAAQ;AAAA,MAC5D,CAAE;AACF,iCAA2B;AAAA,IAC5B,CAAE;AAAA,EACH;AACA,WAAS,QAAS,MAAO;AACxB,YAAQ,QAAS,OAAO;AAAA,MACvB,MAAM;AAAA,MACN;AAAA,IACD,CAAE;AACF,+BAA2B;AAAA,EAC5B;AAEA,SAAO,EAAE,SAAS,QAAQ;AAC3B;",
6
+ "names": []
7
+ }
@@ -1,7 +1,4 @@
1
- /**
2
- * Internal dependencies
3
- */
4
- import { getNode, deepCopyLocksTreePath } from './utils';
1
+ import { getNode, deepCopyLocksTreePath } from "./utils";
5
2
  const DEFAULT_STATE = {
6
3
  requests: [],
7
4
  tree: {
@@ -9,62 +6,43 @@ const DEFAULT_STATE = {
9
6
  children: {}
10
7
  }
11
8
  };
12
-
13
- /**
14
- * Reducer returning locks.
15
- *
16
- * @param {Object} state Current state.
17
- * @param {Object} action Dispatched action.
18
- *
19
- * @return {Object} Updated state.
20
- */
21
- export default function locks(state = DEFAULT_STATE, action) {
9
+ function locks(state = DEFAULT_STATE, action) {
22
10
  switch (action.type) {
23
- case 'ENQUEUE_LOCK_REQUEST':
24
- {
25
- const {
26
- request
27
- } = action;
28
- return {
29
- ...state,
30
- requests: [request, ...state.requests]
31
- };
32
- }
33
- case 'GRANT_LOCK_REQUEST':
34
- {
35
- const {
36
- lock,
37
- request
38
- } = action;
39
- const {
40
- store,
41
- path
42
- } = request;
43
- const storePath = [store, ...path];
44
- const newTree = deepCopyLocksTreePath(state.tree, storePath);
45
- const node = getNode(newTree, storePath);
46
- node.locks = [...node.locks, lock];
47
- return {
48
- ...state,
49
- requests: state.requests.filter(r => r !== request),
50
- tree: newTree
51
- };
52
- }
53
- case 'RELEASE_LOCK':
54
- {
55
- const {
56
- lock
57
- } = action;
58
- const storePath = [lock.store, ...lock.path];
59
- const newTree = deepCopyLocksTreePath(state.tree, storePath);
60
- const node = getNode(newTree, storePath);
61
- node.locks = node.locks.filter(l => l !== lock);
62
- return {
63
- ...state,
64
- tree: newTree
65
- };
66
- }
11
+ case "ENQUEUE_LOCK_REQUEST": {
12
+ const { request } = action;
13
+ return {
14
+ ...state,
15
+ requests: [request, ...state.requests]
16
+ };
17
+ }
18
+ case "GRANT_LOCK_REQUEST": {
19
+ const { lock, request } = action;
20
+ const { store, path } = request;
21
+ const storePath = [store, ...path];
22
+ const newTree = deepCopyLocksTreePath(state.tree, storePath);
23
+ const node = getNode(newTree, storePath);
24
+ node.locks = [...node.locks, lock];
25
+ return {
26
+ ...state,
27
+ requests: state.requests.filter((r) => r !== request),
28
+ tree: newTree
29
+ };
30
+ }
31
+ case "RELEASE_LOCK": {
32
+ const { lock } = action;
33
+ const storePath = [lock.store, ...lock.path];
34
+ const newTree = deepCopyLocksTreePath(state.tree, storePath);
35
+ const node = getNode(newTree, storePath);
36
+ node.locks = node.locks.filter((l) => l !== lock);
37
+ return {
38
+ ...state,
39
+ tree: newTree
40
+ };
41
+ }
67
42
  }
68
43
  return state;
69
44
  }
70
- //# sourceMappingURL=reducer.js.map
45
+ export {
46
+ locks as default
47
+ };
48
+ //# sourceMappingURL=reducer.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["getNode","deepCopyLocksTreePath","DEFAULT_STATE","requests","tree","locks","children","state","action","type","request","lock","store","path","storePath","newTree","node","filter","r","l"],"sources":["@wordpress/core-data/src/locks/reducer.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport { getNode, deepCopyLocksTreePath } from './utils';\n\nconst DEFAULT_STATE = {\n\trequests: [],\n\ttree: {\n\t\tlocks: [],\n\t\tchildren: {},\n\t},\n};\n\n/**\n * Reducer returning locks.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport default function locks( state = DEFAULT_STATE, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'ENQUEUE_LOCK_REQUEST': {\n\t\t\tconst { request } = action;\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\trequests: [ request, ...state.requests ],\n\t\t\t};\n\t\t}\n\t\tcase 'GRANT_LOCK_REQUEST': {\n\t\t\tconst { lock, request } = action;\n\t\t\tconst { store, path } = request;\n\t\t\tconst storePath = [ store, ...path ];\n\n\t\t\tconst newTree = deepCopyLocksTreePath( state.tree, storePath );\n\t\t\tconst node = getNode( newTree, storePath );\n\t\t\tnode.locks = [ ...node.locks, lock ];\n\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\trequests: state.requests.filter( ( r ) => r !== request ),\n\t\t\t\ttree: newTree,\n\t\t\t};\n\t\t}\n\t\tcase 'RELEASE_LOCK': {\n\t\t\tconst { lock } = action;\n\t\t\tconst storePath = [ lock.store, ...lock.path ];\n\n\t\t\tconst newTree = deepCopyLocksTreePath( state.tree, storePath );\n\t\t\tconst node = getNode( newTree, storePath );\n\t\t\tnode.locks = node.locks.filter( ( l ) => l !== lock );\n\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\ttree: newTree,\n\t\t\t};\n\t\t}\n\t}\n\n\treturn state;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,OAAO,EAAEC,qBAAqB,QAAQ,SAAS;AAExD,MAAMC,aAAa,GAAG;EACrBC,QAAQ,EAAE,EAAE;EACZC,IAAI,EAAE;IACLC,KAAK,EAAE,EAAE;IACTC,QAAQ,EAAE,CAAC;EACZ;AACD,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASD,KAAKA,CAAEE,KAAK,GAAGL,aAAa,EAAEM,MAAM,EAAG;EAC9D,QAASA,MAAM,CAACC,IAAI;IACnB,KAAK,sBAAsB;MAAE;QAC5B,MAAM;UAAEC;QAAQ,CAAC,GAAGF,MAAM;QAC1B,OAAO;UACN,GAAGD,KAAK;UACRJ,QAAQ,EAAE,CAAEO,OAAO,EAAE,GAAGH,KAAK,CAACJ,QAAQ;QACvC,CAAC;MACF;IACA,KAAK,oBAAoB;MAAE;QAC1B,MAAM;UAAEQ,IAAI;UAAED;QAAQ,CAAC,GAAGF,MAAM;QAChC,MAAM;UAAEI,KAAK;UAAEC;QAAK,CAAC,GAAGH,OAAO;QAC/B,MAAMI,SAAS,GAAG,CAAEF,KAAK,EAAE,GAAGC,IAAI,CAAE;QAEpC,MAAME,OAAO,GAAGd,qBAAqB,CAAEM,KAAK,CAACH,IAAI,EAAEU,SAAU,CAAC;QAC9D,MAAME,IAAI,GAAGhB,OAAO,CAAEe,OAAO,EAAED,SAAU,CAAC;QAC1CE,IAAI,CAACX,KAAK,GAAG,CAAE,GAAGW,IAAI,CAACX,KAAK,EAAEM,IAAI,CAAE;QAEpC,OAAO;UACN,GAAGJ,KAAK;UACRJ,QAAQ,EAAEI,KAAK,CAACJ,QAAQ,CAACc,MAAM,CAAIC,CAAC,IAAMA,CAAC,KAAKR,OAAQ,CAAC;UACzDN,IAAI,EAAEW;QACP,CAAC;MACF;IACA,KAAK,cAAc;MAAE;QACpB,MAAM;UAAEJ;QAAK,CAAC,GAAGH,MAAM;QACvB,MAAMM,SAAS,GAAG,CAAEH,IAAI,CAACC,KAAK,EAAE,GAAGD,IAAI,CAACE,IAAI,CAAE;QAE9C,MAAME,OAAO,GAAGd,qBAAqB,CAAEM,KAAK,CAACH,IAAI,EAAEU,SAAU,CAAC;QAC9D,MAAME,IAAI,GAAGhB,OAAO,CAAEe,OAAO,EAAED,SAAU,CAAC;QAC1CE,IAAI,CAACX,KAAK,GAAGW,IAAI,CAACX,KAAK,CAACY,MAAM,CAAIE,CAAC,IAAMA,CAAC,KAAKR,IAAK,CAAC;QAErD,OAAO;UACN,GAAGJ,KAAK;UACRH,IAAI,EAAEW;QACP,CAAC;MACF;EACD;EAEA,OAAOR,KAAK;AACb","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/locks/reducer.js"],
4
+ "sourcesContent": ["/**\n * Internal dependencies\n */\nimport { getNode, deepCopyLocksTreePath } from './utils';\n\nconst DEFAULT_STATE = {\n\trequests: [],\n\ttree: {\n\t\tlocks: [],\n\t\tchildren: {},\n\t},\n};\n\n/**\n * Reducer returning locks.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport default function locks( state = DEFAULT_STATE, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'ENQUEUE_LOCK_REQUEST': {\n\t\t\tconst { request } = action;\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\trequests: [ request, ...state.requests ],\n\t\t\t};\n\t\t}\n\t\tcase 'GRANT_LOCK_REQUEST': {\n\t\t\tconst { lock, request } = action;\n\t\t\tconst { store, path } = request;\n\t\t\tconst storePath = [ store, ...path ];\n\n\t\t\tconst newTree = deepCopyLocksTreePath( state.tree, storePath );\n\t\t\tconst node = getNode( newTree, storePath );\n\t\t\tnode.locks = [ ...node.locks, lock ];\n\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\trequests: state.requests.filter( ( r ) => r !== request ),\n\t\t\t\ttree: newTree,\n\t\t\t};\n\t\t}\n\t\tcase 'RELEASE_LOCK': {\n\t\t\tconst { lock } = action;\n\t\t\tconst storePath = [ lock.store, ...lock.path ];\n\n\t\t\tconst newTree = deepCopyLocksTreePath( state.tree, storePath );\n\t\t\tconst node = getNode( newTree, storePath );\n\t\t\tnode.locks = node.locks.filter( ( l ) => l !== lock );\n\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\ttree: newTree,\n\t\t\t};\n\t\t}\n\t}\n\n\treturn state;\n}\n"],
5
+ "mappings": "AAGA,SAAS,SAAS,6BAA6B;AAE/C,MAAM,gBAAgB;AAAA,EACrB,UAAU,CAAC;AAAA,EACX,MAAM;AAAA,IACL,OAAO,CAAC;AAAA,IACR,UAAU,CAAC;AAAA,EACZ;AACD;AAUe,SAAR,MAAwB,QAAQ,eAAe,QAAS;AAC9D,UAAS,OAAO,MAAO;AAAA,IACtB,KAAK,wBAAwB;AAC5B,YAAM,EAAE,QAAQ,IAAI;AACpB,aAAO;AAAA,QACN,GAAG;AAAA,QACH,UAAU,CAAE,SAAS,GAAG,MAAM,QAAS;AAAA,MACxC;AAAA,IACD;AAAA,IACA,KAAK,sBAAsB;AAC1B,YAAM,EAAE,MAAM,QAAQ,IAAI;AAC1B,YAAM,EAAE,OAAO,KAAK,IAAI;AACxB,YAAM,YAAY,CAAE,OAAO,GAAG,IAAK;AAEnC,YAAM,UAAU,sBAAuB,MAAM,MAAM,SAAU;AAC7D,YAAM,OAAO,QAAS,SAAS,SAAU;AACzC,WAAK,QAAQ,CAAE,GAAG,KAAK,OAAO,IAAK;AAEnC,aAAO;AAAA,QACN,GAAG;AAAA,QACH,UAAU,MAAM,SAAS,OAAQ,CAAE,MAAO,MAAM,OAAQ;AAAA,QACxD,MAAM;AAAA,MACP;AAAA,IACD;AAAA,IACA,KAAK,gBAAgB;AACpB,YAAM,EAAE,KAAK,IAAI;AACjB,YAAM,YAAY,CAAE,KAAK,OAAO,GAAG,KAAK,IAAK;AAE7C,YAAM,UAAU,sBAAuB,MAAM,MAAM,SAAU;AAC7D,YAAM,OAAO,QAAS,SAAS,SAAU;AACzC,WAAK,QAAQ,KAAK,MAAM,OAAQ,CAAE,MAAO,MAAM,IAAK;AAEpD,aAAO;AAAA,QACN,GAAG;AAAA,QACH,MAAM;AAAA,MACP;AAAA,IACD;AAAA,EACD;AAEA,SAAO;AACR;",
6
+ "names": []
7
+ }
@@ -1,40 +1,33 @@
1
- /**
2
- * Internal dependencies
3
- */
4
- import { iterateDescendants, iteratePath, hasConflictingLock, getNode } from './utils';
5
- export function getPendingLockRequests(state) {
1
+ import {
2
+ iterateDescendants,
3
+ iteratePath,
4
+ hasConflictingLock,
5
+ getNode
6
+ } from "./utils";
7
+ function getPendingLockRequests(state) {
6
8
  return state.requests;
7
9
  }
8
- export function isLockAvailable(state, store, path, {
9
- exclusive
10
- }) {
10
+ function isLockAvailable(state, store, path, { exclusive }) {
11
11
  const storePath = [store, ...path];
12
12
  const locks = state.tree;
13
-
14
- // Validate all parents and the node itself
15
- for (const node of iteratePath(locks, storePath)) {
16
- if (hasConflictingLock({
17
- exclusive
18
- }, node.locks)) {
13
+ for (const node2 of iteratePath(locks, storePath)) {
14
+ if (hasConflictingLock({ exclusive }, node2.locks)) {
19
15
  return false;
20
16
  }
21
17
  }
22
-
23
- // iteratePath terminates early if path is unreachable, let's
24
- // re-fetch the node and check it exists in the tree.
25
18
  const node = getNode(locks, storePath);
26
19
  if (!node) {
27
20
  return true;
28
21
  }
29
-
30
- // Validate all nested nodes
31
22
  for (const descendant of iterateDescendants(node)) {
32
- if (hasConflictingLock({
33
- exclusive
34
- }, descendant.locks)) {
23
+ if (hasConflictingLock({ exclusive }, descendant.locks)) {
35
24
  return false;
36
25
  }
37
26
  }
38
27
  return true;
39
28
  }
40
- //# sourceMappingURL=selectors.js.map
29
+ export {
30
+ getPendingLockRequests,
31
+ isLockAvailable
32
+ };
33
+ //# sourceMappingURL=selectors.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["iterateDescendants","iteratePath","hasConflictingLock","getNode","getPendingLockRequests","state","requests","isLockAvailable","store","path","exclusive","storePath","locks","tree","node","descendant"],"sources":["@wordpress/core-data/src/locks/selectors.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport {\n\titerateDescendants,\n\titeratePath,\n\thasConflictingLock,\n\tgetNode,\n} from './utils';\n\nexport function getPendingLockRequests( state ) {\n\treturn state.requests;\n}\n\nexport function isLockAvailable( state, store, path, { exclusive } ) {\n\tconst storePath = [ store, ...path ];\n\tconst locks = state.tree;\n\n\t// Validate all parents and the node itself\n\tfor ( const node of iteratePath( locks, storePath ) ) {\n\t\tif ( hasConflictingLock( { exclusive }, node.locks ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t// iteratePath terminates early if path is unreachable, let's\n\t// re-fetch the node and check it exists in the tree.\n\tconst node = getNode( locks, storePath );\n\tif ( ! node ) {\n\t\treturn true;\n\t}\n\n\t// Validate all nested nodes\n\tfor ( const descendant of iterateDescendants( node ) ) {\n\t\tif ( hasConflictingLock( { exclusive }, descendant.locks ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\treturn true;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SACCA,kBAAkB,EAClBC,WAAW,EACXC,kBAAkB,EAClBC,OAAO,QACD,SAAS;AAEhB,OAAO,SAASC,sBAAsBA,CAAEC,KAAK,EAAG;EAC/C,OAAOA,KAAK,CAACC,QAAQ;AACtB;AAEA,OAAO,SAASC,eAAeA,CAAEF,KAAK,EAAEG,KAAK,EAAEC,IAAI,EAAE;EAAEC;AAAU,CAAC,EAAG;EACpE,MAAMC,SAAS,GAAG,CAAEH,KAAK,EAAE,GAAGC,IAAI,CAAE;EACpC,MAAMG,KAAK,GAAGP,KAAK,CAACQ,IAAI;;EAExB;EACA,KAAM,MAAMC,IAAI,IAAIb,WAAW,CAAEW,KAAK,EAAED,SAAU,CAAC,EAAG;IACrD,IAAKT,kBAAkB,CAAE;MAAEQ;IAAU,CAAC,EAAEI,IAAI,CAACF,KAAM,CAAC,EAAG;MACtD,OAAO,KAAK;IACb;EACD;;EAEA;EACA;EACA,MAAME,IAAI,GAAGX,OAAO,CAAES,KAAK,EAAED,SAAU,CAAC;EACxC,IAAK,CAAEG,IAAI,EAAG;IACb,OAAO,IAAI;EACZ;;EAEA;EACA,KAAM,MAAMC,UAAU,IAAIf,kBAAkB,CAAEc,IAAK,CAAC,EAAG;IACtD,IAAKZ,kBAAkB,CAAE;MAAEQ;IAAU,CAAC,EAAEK,UAAU,CAACH,KAAM,CAAC,EAAG;MAC5D,OAAO,KAAK;IACb;EACD;EAEA,OAAO,IAAI;AACZ","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/locks/selectors.js"],
4
+ "sourcesContent": ["/**\n * Internal dependencies\n */\nimport {\n\titerateDescendants,\n\titeratePath,\n\thasConflictingLock,\n\tgetNode,\n} from './utils';\n\nexport function getPendingLockRequests( state ) {\n\treturn state.requests;\n}\n\nexport function isLockAvailable( state, store, path, { exclusive } ) {\n\tconst storePath = [ store, ...path ];\n\tconst locks = state.tree;\n\n\t// Validate all parents and the node itself\n\tfor ( const node of iteratePath( locks, storePath ) ) {\n\t\tif ( hasConflictingLock( { exclusive }, node.locks ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t// iteratePath terminates early if path is unreachable, let's\n\t// re-fetch the node and check it exists in the tree.\n\tconst node = getNode( locks, storePath );\n\tif ( ! node ) {\n\t\treturn true;\n\t}\n\n\t// Validate all nested nodes\n\tfor ( const descendant of iterateDescendants( node ) ) {\n\t\tif ( hasConflictingLock( { exclusive }, descendant.locks ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\treturn true;\n}\n"],
5
+ "mappings": "AAGA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAEA,SAAS,uBAAwB,OAAQ;AAC/C,SAAO,MAAM;AACd;AAEO,SAAS,gBAAiB,OAAO,OAAO,MAAM,EAAE,UAAU,GAAI;AACpE,QAAM,YAAY,CAAE,OAAO,GAAG,IAAK;AACnC,QAAM,QAAQ,MAAM;AAGpB,aAAYA,SAAQ,YAAa,OAAO,SAAU,GAAI;AACrD,QAAK,mBAAoB,EAAE,UAAU,GAAGA,MAAK,KAAM,GAAI;AACtD,aAAO;AAAA,IACR;AAAA,EACD;AAIA,QAAM,OAAO,QAAS,OAAO,SAAU;AACvC,MAAK,CAAE,MAAO;AACb,WAAO;AAAA,EACR;AAGA,aAAY,cAAc,mBAAoB,IAAK,GAAI;AACtD,QAAK,mBAAoB,EAAE,UAAU,GAAG,WAAW,KAAM,GAAI;AAC5D,aAAO;AAAA,IACR;AAAA,EACD;AAEA,SAAO;AACR;",
6
+ "names": ["node"]
7
+ }
@@ -1,7 +1,5 @@
1
- export function deepCopyLocksTreePath(tree, path) {
2
- const newTree = {
3
- ...tree
4
- };
1
+ function deepCopyLocksTreePath(tree, path) {
2
+ const newTree = { ...tree };
5
3
  let currentNode = newTree;
6
4
  for (const branchName of path) {
7
5
  currentNode.children = {
@@ -16,7 +14,7 @@ export function deepCopyLocksTreePath(tree, path) {
16
14
  }
17
15
  return newTree;
18
16
  }
19
- export function getNode(tree, path) {
17
+ function getNode(tree, path) {
20
18
  let currentNode = tree;
21
19
  for (const branchName of path) {
22
20
  const nextNode = currentNode.children[branchName];
@@ -27,7 +25,7 @@ export function getNode(tree, path) {
27
25
  }
28
26
  return currentNode;
29
27
  }
30
- export function* iteratePath(tree, path) {
28
+ function* iteratePath(tree, path) {
31
29
  let currentNode = tree;
32
30
  yield currentNode;
33
31
  for (const branchName of path) {
@@ -39,7 +37,7 @@ export function* iteratePath(tree, path) {
39
37
  currentNode = nextNode;
40
38
  }
41
39
  }
42
- export function* iterateDescendants(node) {
40
+ function* iterateDescendants(node) {
43
41
  const stack = Object.values(node.children);
44
42
  while (stack.length) {
45
43
  const childNode = stack.pop();
@@ -47,15 +45,20 @@ export function* iterateDescendants(node) {
47
45
  stack.push(...Object.values(childNode.children));
48
46
  }
49
47
  }
50
- export function hasConflictingLock({
51
- exclusive
52
- }, locks) {
48
+ function hasConflictingLock({ exclusive }, locks) {
53
49
  if (exclusive && locks.length) {
54
50
  return true;
55
51
  }
56
- if (!exclusive && locks.filter(lock => lock.exclusive).length) {
52
+ if (!exclusive && locks.filter((lock) => lock.exclusive).length) {
57
53
  return true;
58
54
  }
59
55
  return false;
60
56
  }
61
- //# sourceMappingURL=utils.js.map
57
+ export {
58
+ deepCopyLocksTreePath,
59
+ getNode,
60
+ hasConflictingLock,
61
+ iterateDescendants,
62
+ iteratePath
63
+ };
64
+ //# sourceMappingURL=utils.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["deepCopyLocksTreePath","tree","path","newTree","currentNode","branchName","children","locks","getNode","nextNode","iteratePath","iterateDescendants","node","stack","Object","values","length","childNode","pop","push","hasConflictingLock","exclusive","filter","lock"],"sources":["@wordpress/core-data/src/locks/utils.js"],"sourcesContent":["export function deepCopyLocksTreePath( tree, path ) {\n\tconst newTree = { ...tree };\n\tlet currentNode = newTree;\n\tfor ( const branchName of path ) {\n\t\tcurrentNode.children = {\n\t\t\t...currentNode.children,\n\t\t\t[ branchName ]: {\n\t\t\t\tlocks: [],\n\t\t\t\tchildren: {},\n\t\t\t\t...currentNode.children[ branchName ],\n\t\t\t},\n\t\t};\n\t\tcurrentNode = currentNode.children[ branchName ];\n\t}\n\treturn newTree;\n}\n\nexport function getNode( tree, path ) {\n\tlet currentNode = tree;\n\tfor ( const branchName of path ) {\n\t\tconst nextNode = currentNode.children[ branchName ];\n\t\tif ( ! nextNode ) {\n\t\t\treturn null;\n\t\t}\n\t\tcurrentNode = nextNode;\n\t}\n\treturn currentNode;\n}\n\nexport function* iteratePath( tree, path ) {\n\tlet currentNode = tree;\n\tyield currentNode;\n\tfor ( const branchName of path ) {\n\t\tconst nextNode = currentNode.children[ branchName ];\n\t\tif ( ! nextNode ) {\n\t\t\tbreak;\n\t\t}\n\t\tyield nextNode;\n\t\tcurrentNode = nextNode;\n\t}\n}\n\nexport function* iterateDescendants( node ) {\n\tconst stack = Object.values( node.children );\n\twhile ( stack.length ) {\n\t\tconst childNode = stack.pop();\n\t\tyield childNode;\n\t\tstack.push( ...Object.values( childNode.children ) );\n\t}\n}\n\nexport function hasConflictingLock( { exclusive }, locks ) {\n\tif ( exclusive && locks.length ) {\n\t\treturn true;\n\t}\n\n\tif ( ! exclusive && locks.filter( ( lock ) => lock.exclusive ).length ) {\n\t\treturn true;\n\t}\n\n\treturn false;\n}\n"],"mappings":"AAAA,OAAO,SAASA,qBAAqBA,CAAEC,IAAI,EAAEC,IAAI,EAAG;EACnD,MAAMC,OAAO,GAAG;IAAE,GAAGF;EAAK,CAAC;EAC3B,IAAIG,WAAW,GAAGD,OAAO;EACzB,KAAM,MAAME,UAAU,IAAIH,IAAI,EAAG;IAChCE,WAAW,CAACE,QAAQ,GAAG;MACtB,GAAGF,WAAW,CAACE,QAAQ;MACvB,CAAED,UAAU,GAAI;QACfE,KAAK,EAAE,EAAE;QACTD,QAAQ,EAAE,CAAC,CAAC;QACZ,GAAGF,WAAW,CAACE,QAAQ,CAAED,UAAU;MACpC;IACD,CAAC;IACDD,WAAW,GAAGA,WAAW,CAACE,QAAQ,CAAED,UAAU,CAAE;EACjD;EACA,OAAOF,OAAO;AACf;AAEA,OAAO,SAASK,OAAOA,CAAEP,IAAI,EAAEC,IAAI,EAAG;EACrC,IAAIE,WAAW,GAAGH,IAAI;EACtB,KAAM,MAAMI,UAAU,IAAIH,IAAI,EAAG;IAChC,MAAMO,QAAQ,GAAGL,WAAW,CAACE,QAAQ,CAAED,UAAU,CAAE;IACnD,IAAK,CAAEI,QAAQ,EAAG;MACjB,OAAO,IAAI;IACZ;IACAL,WAAW,GAAGK,QAAQ;EACvB;EACA,OAAOL,WAAW;AACnB;AAEA,OAAO,UAAUM,WAAWA,CAAET,IAAI,EAAEC,IAAI,EAAG;EAC1C,IAAIE,WAAW,GAAGH,IAAI;EACtB,MAAMG,WAAW;EACjB,KAAM,MAAMC,UAAU,IAAIH,IAAI,EAAG;IAChC,MAAMO,QAAQ,GAAGL,WAAW,CAACE,QAAQ,CAAED,UAAU,CAAE;IACnD,IAAK,CAAEI,QAAQ,EAAG;MACjB;IACD;IACA,MAAMA,QAAQ;IACdL,WAAW,GAAGK,QAAQ;EACvB;AACD;AAEA,OAAO,UAAUE,kBAAkBA,CAAEC,IAAI,EAAG;EAC3C,MAAMC,KAAK,GAAGC,MAAM,CAACC,MAAM,CAAEH,IAAI,CAACN,QAAS,CAAC;EAC5C,OAAQO,KAAK,CAACG,MAAM,EAAG;IACtB,MAAMC,SAAS,GAAGJ,KAAK,CAACK,GAAG,CAAC,CAAC;IAC7B,MAAMD,SAAS;IACfJ,KAAK,CAACM,IAAI,CAAE,GAAGL,MAAM,CAACC,MAAM,CAAEE,SAAS,CAACX,QAAS,CAAE,CAAC;EACrD;AACD;AAEA,OAAO,SAASc,kBAAkBA,CAAE;EAAEC;AAAU,CAAC,EAAEd,KAAK,EAAG;EAC1D,IAAKc,SAAS,IAAId,KAAK,CAACS,MAAM,EAAG;IAChC,OAAO,IAAI;EACZ;EAEA,IAAK,CAAEK,SAAS,IAAId,KAAK,CAACe,MAAM,CAAIC,IAAI,IAAMA,IAAI,CAACF,SAAU,CAAC,CAACL,MAAM,EAAG;IACvE,OAAO,IAAI;EACZ;EAEA,OAAO,KAAK;AACb","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/locks/utils.js"],
4
+ "sourcesContent": ["export function deepCopyLocksTreePath( tree, path ) {\n\tconst newTree = { ...tree };\n\tlet currentNode = newTree;\n\tfor ( const branchName of path ) {\n\t\tcurrentNode.children = {\n\t\t\t...currentNode.children,\n\t\t\t[ branchName ]: {\n\t\t\t\tlocks: [],\n\t\t\t\tchildren: {},\n\t\t\t\t...currentNode.children[ branchName ],\n\t\t\t},\n\t\t};\n\t\tcurrentNode = currentNode.children[ branchName ];\n\t}\n\treturn newTree;\n}\n\nexport function getNode( tree, path ) {\n\tlet currentNode = tree;\n\tfor ( const branchName of path ) {\n\t\tconst nextNode = currentNode.children[ branchName ];\n\t\tif ( ! nextNode ) {\n\t\t\treturn null;\n\t\t}\n\t\tcurrentNode = nextNode;\n\t}\n\treturn currentNode;\n}\n\nexport function* iteratePath( tree, path ) {\n\tlet currentNode = tree;\n\tyield currentNode;\n\tfor ( const branchName of path ) {\n\t\tconst nextNode = currentNode.children[ branchName ];\n\t\tif ( ! nextNode ) {\n\t\t\tbreak;\n\t\t}\n\t\tyield nextNode;\n\t\tcurrentNode = nextNode;\n\t}\n}\n\nexport function* iterateDescendants( node ) {\n\tconst stack = Object.values( node.children );\n\twhile ( stack.length ) {\n\t\tconst childNode = stack.pop();\n\t\tyield childNode;\n\t\tstack.push( ...Object.values( childNode.children ) );\n\t}\n}\n\nexport function hasConflictingLock( { exclusive }, locks ) {\n\tif ( exclusive && locks.length ) {\n\t\treturn true;\n\t}\n\n\tif ( ! exclusive && locks.filter( ( lock ) => lock.exclusive ).length ) {\n\t\treturn true;\n\t}\n\n\treturn false;\n}\n"],
5
+ "mappings": "AAAO,SAAS,sBAAuB,MAAM,MAAO;AACnD,QAAM,UAAU,EAAE,GAAG,KAAK;AAC1B,MAAI,cAAc;AAClB,aAAY,cAAc,MAAO;AAChC,gBAAY,WAAW;AAAA,MACtB,GAAG,YAAY;AAAA,MACf,CAAE,UAAW,GAAG;AAAA,QACf,OAAO,CAAC;AAAA,QACR,UAAU,CAAC;AAAA,QACX,GAAG,YAAY,SAAU,UAAW;AAAA,MACrC;AAAA,IACD;AACA,kBAAc,YAAY,SAAU,UAAW;AAAA,EAChD;AACA,SAAO;AACR;AAEO,SAAS,QAAS,MAAM,MAAO;AACrC,MAAI,cAAc;AAClB,aAAY,cAAc,MAAO;AAChC,UAAM,WAAW,YAAY,SAAU,UAAW;AAClD,QAAK,CAAE,UAAW;AACjB,aAAO;AAAA,IACR;AACA,kBAAc;AAAA,EACf;AACA,SAAO;AACR;AAEO,UAAU,YAAa,MAAM,MAAO;AAC1C,MAAI,cAAc;AAClB,QAAM;AACN,aAAY,cAAc,MAAO;AAChC,UAAM,WAAW,YAAY,SAAU,UAAW;AAClD,QAAK,CAAE,UAAW;AACjB;AAAA,IACD;AACA,UAAM;AACN,kBAAc;AAAA,EACf;AACD;AAEO,UAAU,mBAAoB,MAAO;AAC3C,QAAM,QAAQ,OAAO,OAAQ,KAAK,QAAS;AAC3C,SAAQ,MAAM,QAAS;AACtB,UAAM,YAAY,MAAM,IAAI;AAC5B,UAAM;AACN,UAAM,KAAM,GAAG,OAAO,OAAQ,UAAU,QAAS,CAAE;AAAA,EACpD;AACD;AAEO,SAAS,mBAAoB,EAAE,UAAU,GAAG,OAAQ;AAC1D,MAAK,aAAa,MAAM,QAAS;AAChC,WAAO;AAAA,EACR;AAEA,MAAK,CAAE,aAAa,MAAM,OAAQ,CAAE,SAAU,KAAK,SAAU,EAAE,QAAS;AACvE,WAAO;AAAA,EACR;AAEA,SAAO;AACR;",
6
+ "names": []
7
+ }
@@ -1,8 +1,5 @@
1
- /**
2
- * The reducer key used by core data in store registration.
3
- * This is defined in a separate file to avoid cycle-dependency
4
- *
5
- * @type {string}
6
- */
7
- export const STORE_NAME = 'core';
8
- //# sourceMappingURL=name.js.map
1
+ const STORE_NAME = "core";
2
+ export {
3
+ STORE_NAME
4
+ };
5
+ //# sourceMappingURL=name.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["STORE_NAME"],"sources":["@wordpress/core-data/src/name.js"],"sourcesContent":["/**\n * The reducer key used by core data in store registration.\n * This is defined in a separate file to avoid cycle-dependency\n *\n * @type {string}\n */\nexport const STORE_NAME = 'core';\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMA,UAAU,GAAG,MAAM","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/name.js"],
4
+ "sourcesContent": ["/**\n * The reducer key used by core data in store registration.\n * This is defined in a separate file to avoid cycle-dependency\n *\n * @type {string}\n */\nexport const STORE_NAME = 'core';\n"],
5
+ "mappings": "AAMO,MAAM,aAAa;",
6
+ "names": []
7
+ }
@@ -1,79 +1,36 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import apiFetch from '@wordpress/api-fetch';
5
-
6
- /**
7
- * Internal dependencies
8
- */
9
- import { STORE_NAME } from './name';
10
-
11
- /**
12
- * Returns an action object used in signalling that the registered post meta
13
- * fields for a post type have been received.
14
- *
15
- * @param {string} postType Post type slug.
16
- * @param {Object} registeredPostMeta Registered post meta.
17
- *
18
- * @return {Object} Action object.
19
- */
20
- export function receiveRegisteredPostMeta(postType, registeredPostMeta) {
1
+ import apiFetch from "@wordpress/api-fetch";
2
+ import { STORE_NAME } from "./name";
3
+ function receiveRegisteredPostMeta(postType, registeredPostMeta) {
21
4
  return {
22
- type: 'RECEIVE_REGISTERED_POST_META',
5
+ type: "RECEIVE_REGISTERED_POST_META",
23
6
  postType,
24
7
  registeredPostMeta
25
8
  };
26
9
  }
27
-
28
- /**
29
- * @typedef {Object} Modifier
30
- * @property {string} [type] - The type of modifier.
31
- * @property {Object} [args] - The arguments of the modifier.
32
- */
33
-
34
- /**
35
- * @typedef {Object} Edits
36
- * @property {string} [src] - The URL of the media item.
37
- * @property {Modifier[]} [modifiers] - The modifiers to apply to the media item.
38
- */
39
-
40
- /**
41
- * Duplicates a media (attachment) entity record and, optionally, modifies it.
42
- *
43
- * @param {string} recordId Entity record ID.
44
- * @param {Edits} edits Edits to apply to the record.
45
- * @param {Object} options Options object.
46
- * @param {Function} options.__unstableFetch Custom fetch function.
47
- * @param {boolean} options.throwOnError Whether to throw an error if the request fails.
48
- *
49
- * @return {Promise} Promise resolving to the updated record.
50
- */
51
- export const editMediaEntity = (recordId, edits = {}, {
52
- __unstableFetch = apiFetch,
53
- throwOnError = false
54
- } = {}) => async ({
55
- dispatch,
56
- resolveSelect
57
- }) => {
10
+ const editMediaEntity = (recordId, edits = {}, { __unstableFetch = apiFetch, throwOnError = false } = {}) => async ({ dispatch, resolveSelect }) => {
58
11
  if (!recordId) {
59
12
  return;
60
13
  }
61
- const kind = 'postType';
62
- const name = 'attachment';
14
+ const kind = "postType";
15
+ const name = "attachment";
63
16
  const configs = await resolveSelect.getEntitiesConfig(kind);
64
- const entityConfig = configs.find(config => config.kind === kind && config.name === name);
17
+ const entityConfig = configs.find(
18
+ (config) => config.kind === kind && config.name === name
19
+ );
65
20
  if (!entityConfig) {
66
21
  return;
67
22
  }
68
- const lock = await dispatch.__unstableAcquireStoreLock(STORE_NAME, ['entities', 'records', kind, name, recordId], {
69
- exclusive: true
70
- });
23
+ const lock = await dispatch.__unstableAcquireStoreLock(
24
+ STORE_NAME,
25
+ ["entities", "records", kind, name, recordId],
26
+ { exclusive: true }
27
+ );
71
28
  let updatedRecord;
72
29
  let error;
73
30
  let hasError = false;
74
31
  try {
75
32
  dispatch({
76
- type: 'SAVE_ENTITY_RECORD_START',
33
+ type: "SAVE_ENTITY_RECORD_START",
77
34
  kind,
78
35
  name,
79
36
  recordId
@@ -82,13 +39,21 @@ export const editMediaEntity = (recordId, edits = {}, {
82
39
  const path = `${entityConfig.baseURL}/${recordId}/edit`;
83
40
  const newRecord = await __unstableFetch({
84
41
  path,
85
- method: 'POST',
42
+ method: "POST",
86
43
  data: {
87
44
  ...edits
88
45
  }
89
46
  });
90
47
  if (newRecord) {
91
- dispatch.receiveEntityRecords(kind, name, [newRecord], undefined, true, undefined, undefined);
48
+ dispatch.receiveEntityRecords(
49
+ kind,
50
+ name,
51
+ [newRecord],
52
+ void 0,
53
+ true,
54
+ void 0,
55
+ void 0
56
+ );
92
57
  updatedRecord = newRecord;
93
58
  }
94
59
  } catch (e) {
@@ -96,7 +61,7 @@ export const editMediaEntity = (recordId, edits = {}, {
96
61
  hasError = true;
97
62
  }
98
63
  dispatch({
99
- type: 'SAVE_ENTITY_RECORD_FINISH',
64
+ type: "SAVE_ENTITY_RECORD_FINISH",
100
65
  kind,
101
66
  name,
102
67
  recordId,
@@ -110,11 +75,12 @@ export const editMediaEntity = (recordId, edits = {}, {
110
75
  dispatch.__unstableReleaseStoreLock(lock);
111
76
  }
112
77
  };
113
- export function receiveTemplateAutoDraftId(target, id) {
114
- return {
115
- type: 'RECEIVE_TEMPLATE_AUTO_DRAFT_ID',
116
- target,
117
- id
118
- };
78
+ function receiveTemplateAutoDraftId(target, id) {
79
+ return { type: "RECEIVE_TEMPLATE_AUTO_DRAFT_ID", target, id };
119
80
  }
120
- //# sourceMappingURL=private-actions.js.map
81
+ export {
82
+ editMediaEntity,
83
+ receiveRegisteredPostMeta,
84
+ receiveTemplateAutoDraftId
85
+ };
86
+ //# sourceMappingURL=private-actions.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["apiFetch","STORE_NAME","receiveRegisteredPostMeta","postType","registeredPostMeta","type","editMediaEntity","recordId","edits","__unstableFetch","throwOnError","dispatch","resolveSelect","kind","name","configs","getEntitiesConfig","entityConfig","find","config","lock","__unstableAcquireStoreLock","exclusive","updatedRecord","error","hasError","path","baseURL","newRecord","method","data","receiveEntityRecords","undefined","e","__unstableReleaseStoreLock","receiveTemplateAutoDraftId","target","id"],"sources":["@wordpress/core-data/src/private-actions.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport apiFetch from '@wordpress/api-fetch';\n\n/**\n * Internal dependencies\n */\nimport { STORE_NAME } from './name';\n\n/**\n * Returns an action object used in signalling that the registered post meta\n * fields for a post type have been received.\n *\n * @param {string} postType Post type slug.\n * @param {Object} registeredPostMeta Registered post meta.\n *\n * @return {Object} Action object.\n */\nexport function receiveRegisteredPostMeta( postType, registeredPostMeta ) {\n\treturn {\n\t\ttype: 'RECEIVE_REGISTERED_POST_META',\n\t\tpostType,\n\t\tregisteredPostMeta,\n\t};\n}\n\n/**\n * @typedef {Object} Modifier\n * @property {string} [type] - The type of modifier.\n * @property {Object} [args] - The arguments of the modifier.\n */\n\n/**\n * @typedef {Object} Edits\n * @property {string} [src] - The URL of the media item.\n * @property {Modifier[]} [modifiers] - The modifiers to apply to the media item.\n */\n\n/**\n * Duplicates a media (attachment) entity record and, optionally, modifies it.\n *\n * @param {string} recordId Entity record ID.\n * @param {Edits} edits Edits to apply to the record.\n * @param {Object} options Options object.\n * @param {Function} options.__unstableFetch Custom fetch function.\n * @param {boolean} options.throwOnError Whether to throw an error if the request fails.\n *\n * @return {Promise} Promise resolving to the updated record.\n */\nexport const editMediaEntity =\n\t(\n\t\trecordId,\n\t\tedits = {},\n\t\t{ __unstableFetch = apiFetch, throwOnError = false } = {}\n\t) =>\n\tasync ( { dispatch, resolveSelect } ) => {\n\t\tif ( ! recordId ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst kind = 'postType';\n\t\tconst name = 'attachment';\n\n\t\tconst configs = await resolveSelect.getEntitiesConfig( kind );\n\t\tconst entityConfig = configs.find(\n\t\t\t( config ) => config.kind === kind && config.name === name\n\t\t);\n\n\t\tif ( ! entityConfig ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst lock = await dispatch.__unstableAcquireStoreLock(\n\t\t\tSTORE_NAME,\n\t\t\t[ 'entities', 'records', kind, name, recordId ],\n\t\t\t{ exclusive: true }\n\t\t);\n\n\t\tlet updatedRecord;\n\t\tlet error;\n\t\tlet hasError = false;\n\n\t\ttry {\n\t\t\tdispatch( {\n\t\t\t\ttype: 'SAVE_ENTITY_RECORD_START',\n\t\t\t\tkind,\n\t\t\t\tname,\n\t\t\t\trecordId,\n\t\t\t} );\n\n\t\t\ttry {\n\t\t\t\tconst path = `${ entityConfig.baseURL }/${ recordId }/edit`;\n\t\t\t\tconst newRecord = await __unstableFetch( {\n\t\t\t\t\tpath,\n\t\t\t\t\tmethod: 'POST',\n\t\t\t\t\tdata: {\n\t\t\t\t\t\t...edits,\n\t\t\t\t\t},\n\t\t\t\t} );\n\n\t\t\t\tif ( newRecord ) {\n\t\t\t\t\tdispatch.receiveEntityRecords(\n\t\t\t\t\t\tkind,\n\t\t\t\t\t\tname,\n\t\t\t\t\t\t[ newRecord ],\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\tundefined\n\t\t\t\t\t);\n\t\t\t\t\tupdatedRecord = newRecord;\n\t\t\t\t}\n\t\t\t} catch ( e ) {\n\t\t\t\terror = e;\n\t\t\t\thasError = true;\n\t\t\t}\n\n\t\t\tdispatch( {\n\t\t\t\ttype: 'SAVE_ENTITY_RECORD_FINISH',\n\t\t\t\tkind,\n\t\t\t\tname,\n\t\t\t\trecordId,\n\t\t\t\terror,\n\t\t\t} );\n\n\t\t\tif ( hasError && throwOnError ) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\treturn updatedRecord;\n\t\t} finally {\n\t\t\tdispatch.__unstableReleaseStoreLock( lock );\n\t\t}\n\t};\n\nexport function receiveTemplateAutoDraftId( target, id ) {\n\treturn { type: 'RECEIVE_TEMPLATE_AUTO_DRAFT_ID', target, id };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,QAAQ,MAAM,sBAAsB;;AAE3C;AACA;AACA;AACA,SAASC,UAAU,QAAQ,QAAQ;;AAEnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,yBAAyBA,CAAEC,QAAQ,EAAEC,kBAAkB,EAAG;EACzE,OAAO;IACNC,IAAI,EAAE,8BAA8B;IACpCF,QAAQ;IACRC;EACD,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAME,eAAe,GAC3BA,CACCC,QAAQ,EACRC,KAAK,GAAG,CAAC,CAAC,EACV;EAAEC,eAAe,GAAGT,QAAQ;EAAEU,YAAY,GAAG;AAAM,CAAC,GAAG,CAAC,CAAC,KAE1D,OAAQ;EAAEC,QAAQ;EAAEC;AAAc,CAAC,KAAM;EACxC,IAAK,CAAEL,QAAQ,EAAG;IACjB;EACD;EAEA,MAAMM,IAAI,GAAG,UAAU;EACvB,MAAMC,IAAI,GAAG,YAAY;EAEzB,MAAMC,OAAO,GAAG,MAAMH,aAAa,CAACI,iBAAiB,CAAEH,IAAK,CAAC;EAC7D,MAAMI,YAAY,GAAGF,OAAO,CAACG,IAAI,CAC9BC,MAAM,IAAMA,MAAM,CAACN,IAAI,KAAKA,IAAI,IAAIM,MAAM,CAACL,IAAI,KAAKA,IACvD,CAAC;EAED,IAAK,CAAEG,YAAY,EAAG;IACrB;EACD;EAEA,MAAMG,IAAI,GAAG,MAAMT,QAAQ,CAACU,0BAA0B,CACrDpB,UAAU,EACV,CAAE,UAAU,EAAE,SAAS,EAAEY,IAAI,EAAEC,IAAI,EAAEP,QAAQ,CAAE,EAC/C;IAAEe,SAAS,EAAE;EAAK,CACnB,CAAC;EAED,IAAIC,aAAa;EACjB,IAAIC,KAAK;EACT,IAAIC,QAAQ,GAAG,KAAK;EAEpB,IAAI;IACHd,QAAQ,CAAE;MACTN,IAAI,EAAE,0BAA0B;MAChCQ,IAAI;MACJC,IAAI;MACJP;IACD,CAAE,CAAC;IAEH,IAAI;MACH,MAAMmB,IAAI,GAAG,GAAIT,YAAY,CAACU,OAAO,IAAMpB,QAAQ,OAAQ;MAC3D,MAAMqB,SAAS,GAAG,MAAMnB,eAAe,CAAE;QACxCiB,IAAI;QACJG,MAAM,EAAE,MAAM;QACdC,IAAI,EAAE;UACL,GAAGtB;QACJ;MACD,CAAE,CAAC;MAEH,IAAKoB,SAAS,EAAG;QAChBjB,QAAQ,CAACoB,oBAAoB,CAC5BlB,IAAI,EACJC,IAAI,EACJ,CAAEc,SAAS,CAAE,EACbI,SAAS,EACT,IAAI,EACJA,SAAS,EACTA,SACD,CAAC;QACDT,aAAa,GAAGK,SAAS;MAC1B;IACD,CAAC,CAAC,OAAQK,CAAC,EAAG;MACbT,KAAK,GAAGS,CAAC;MACTR,QAAQ,GAAG,IAAI;IAChB;IAEAd,QAAQ,CAAE;MACTN,IAAI,EAAE,2BAA2B;MACjCQ,IAAI;MACJC,IAAI;MACJP,QAAQ;MACRiB;IACD,CAAE,CAAC;IAEH,IAAKC,QAAQ,IAAIf,YAAY,EAAG;MAC/B,MAAMc,KAAK;IACZ;IACA,OAAOD,aAAa;EACrB,CAAC,SAAS;IACTZ,QAAQ,CAACuB,0BAA0B,CAAEd,IAAK,CAAC;EAC5C;AACD,CAAC;AAEF,OAAO,SAASe,0BAA0BA,CAAEC,MAAM,EAAEC,EAAE,EAAG;EACxD,OAAO;IAAEhC,IAAI,EAAE,gCAAgC;IAAE+B,MAAM;IAAEC;EAAG,CAAC;AAC9D","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/private-actions.js"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport apiFetch from '@wordpress/api-fetch';\n\n/**\n * Internal dependencies\n */\nimport { STORE_NAME } from './name';\n\n/**\n * Returns an action object used in signalling that the registered post meta\n * fields for a post type have been received.\n *\n * @param {string} postType Post type slug.\n * @param {Object} registeredPostMeta Registered post meta.\n *\n * @return {Object} Action object.\n */\nexport function receiveRegisteredPostMeta( postType, registeredPostMeta ) {\n\treturn {\n\t\ttype: 'RECEIVE_REGISTERED_POST_META',\n\t\tpostType,\n\t\tregisteredPostMeta,\n\t};\n}\n\n/**\n * @typedef {Object} Modifier\n * @property {string} [type] - The type of modifier.\n * @property {Object} [args] - The arguments of the modifier.\n */\n\n/**\n * @typedef {Object} Edits\n * @property {string} [src] - The URL of the media item.\n * @property {Modifier[]} [modifiers] - The modifiers to apply to the media item.\n */\n\n/**\n * Duplicates a media (attachment) entity record and, optionally, modifies it.\n *\n * @param {string} recordId Entity record ID.\n * @param {Edits} edits Edits to apply to the record.\n * @param {Object} options Options object.\n * @param {Function} options.__unstableFetch Custom fetch function.\n * @param {boolean} options.throwOnError Whether to throw an error if the request fails.\n *\n * @return {Promise} Promise resolving to the updated record.\n */\nexport const editMediaEntity =\n\t(\n\t\trecordId,\n\t\tedits = {},\n\t\t{ __unstableFetch = apiFetch, throwOnError = false } = {}\n\t) =>\n\tasync ( { dispatch, resolveSelect } ) => {\n\t\tif ( ! recordId ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst kind = 'postType';\n\t\tconst name = 'attachment';\n\n\t\tconst configs = await resolveSelect.getEntitiesConfig( kind );\n\t\tconst entityConfig = configs.find(\n\t\t\t( config ) => config.kind === kind && config.name === name\n\t\t);\n\n\t\tif ( ! entityConfig ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst lock = await dispatch.__unstableAcquireStoreLock(\n\t\t\tSTORE_NAME,\n\t\t\t[ 'entities', 'records', kind, name, recordId ],\n\t\t\t{ exclusive: true }\n\t\t);\n\n\t\tlet updatedRecord;\n\t\tlet error;\n\t\tlet hasError = false;\n\n\t\ttry {\n\t\t\tdispatch( {\n\t\t\t\ttype: 'SAVE_ENTITY_RECORD_START',\n\t\t\t\tkind,\n\t\t\t\tname,\n\t\t\t\trecordId,\n\t\t\t} );\n\n\t\t\ttry {\n\t\t\t\tconst path = `${ entityConfig.baseURL }/${ recordId }/edit`;\n\t\t\t\tconst newRecord = await __unstableFetch( {\n\t\t\t\t\tpath,\n\t\t\t\t\tmethod: 'POST',\n\t\t\t\t\tdata: {\n\t\t\t\t\t\t...edits,\n\t\t\t\t\t},\n\t\t\t\t} );\n\n\t\t\t\tif ( newRecord ) {\n\t\t\t\t\tdispatch.receiveEntityRecords(\n\t\t\t\t\t\tkind,\n\t\t\t\t\t\tname,\n\t\t\t\t\t\t[ newRecord ],\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\tundefined\n\t\t\t\t\t);\n\t\t\t\t\tupdatedRecord = newRecord;\n\t\t\t\t}\n\t\t\t} catch ( e ) {\n\t\t\t\terror = e;\n\t\t\t\thasError = true;\n\t\t\t}\n\n\t\t\tdispatch( {\n\t\t\t\ttype: 'SAVE_ENTITY_RECORD_FINISH',\n\t\t\t\tkind,\n\t\t\t\tname,\n\t\t\t\trecordId,\n\t\t\t\terror,\n\t\t\t} );\n\n\t\t\tif ( hasError && throwOnError ) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\treturn updatedRecord;\n\t\t} finally {\n\t\t\tdispatch.__unstableReleaseStoreLock( lock );\n\t\t}\n\t};\n\nexport function receiveTemplateAutoDraftId( target, id ) {\n\treturn { type: 'RECEIVE_TEMPLATE_AUTO_DRAFT_ID', target, id };\n}\n"],
5
+ "mappings": "AAGA,OAAO,cAAc;AAKrB,SAAS,kBAAkB;AAWpB,SAAS,0BAA2B,UAAU,oBAAqB;AACzE,SAAO;AAAA,IACN,MAAM;AAAA,IACN;AAAA,IACA;AAAA,EACD;AACD;AAyBO,MAAM,kBACZ,CACC,UACA,QAAQ,CAAC,GACT,EAAE,kBAAkB,UAAU,eAAe,MAAM,IAAI,CAAC,MAEzD,OAAQ,EAAE,UAAU,cAAc,MAAO;AACxC,MAAK,CAAE,UAAW;AACjB;AAAA,EACD;AAEA,QAAM,OAAO;AACb,QAAM,OAAO;AAEb,QAAM,UAAU,MAAM,cAAc,kBAAmB,IAAK;AAC5D,QAAM,eAAe,QAAQ;AAAA,IAC5B,CAAE,WAAY,OAAO,SAAS,QAAQ,OAAO,SAAS;AAAA,EACvD;AAEA,MAAK,CAAE,cAAe;AACrB;AAAA,EACD;AAEA,QAAM,OAAO,MAAM,SAAS;AAAA,IAC3B;AAAA,IACA,CAAE,YAAY,WAAW,MAAM,MAAM,QAAS;AAAA,IAC9C,EAAE,WAAW,KAAK;AAAA,EACnB;AAEA,MAAI;AACJ,MAAI;AACJ,MAAI,WAAW;AAEf,MAAI;AACH,aAAU;AAAA,MACT,MAAM;AAAA,MACN;AAAA,MACA;AAAA,MACA;AAAA,IACD,CAAE;AAEF,QAAI;AACH,YAAM,OAAO,GAAI,aAAa,OAAQ,IAAK,QAAS;AACpD,YAAM,YAAY,MAAM,gBAAiB;AAAA,QACxC;AAAA,QACA,QAAQ;AAAA,QACR,MAAM;AAAA,UACL,GAAG;AAAA,QACJ;AAAA,MACD,CAAE;AAEF,UAAK,WAAY;AAChB,iBAAS;AAAA,UACR;AAAA,UACA;AAAA,UACA,CAAE,SAAU;AAAA,UACZ;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,QACD;AACA,wBAAgB;AAAA,MACjB;AAAA,IACD,SAAU,GAAI;AACb,cAAQ;AACR,iBAAW;AAAA,IACZ;AAEA,aAAU;AAAA,MACT,MAAM;AAAA,MACN;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD,CAAE;AAEF,QAAK,YAAY,cAAe;AAC/B,YAAM;AAAA,IACP;AACA,WAAO;AAAA,EACR,UAAE;AACD,aAAS,2BAA4B,IAAK;AAAA,EAC3C;AACD;AAEM,SAAS,2BAA4B,QAAQ,IAAK;AACxD,SAAO,EAAE,MAAM,kCAAkC,QAAQ,GAAG;AAC7D;",
6
+ "names": []
7
+ }
@@ -1,12 +1,12 @@
1
- /**
2
- * Internal dependencies
3
- */
4
- import { useEntityRecordsWithPermissions } from './hooks/use-entity-records';
5
- import { RECEIVE_INTERMEDIATE_RESULTS } from './utils';
6
- import { lock } from './lock-unlock';
7
- export const privateApis = {};
1
+ import { useEntityRecordsWithPermissions } from "./hooks/use-entity-records";
2
+ import { RECEIVE_INTERMEDIATE_RESULTS } from "./utils";
3
+ import { lock } from "./lock-unlock";
4
+ const privateApis = {};
8
5
  lock(privateApis, {
9
6
  useEntityRecordsWithPermissions,
10
7
  RECEIVE_INTERMEDIATE_RESULTS
11
8
  });
12
- //# sourceMappingURL=private-apis.js.map
9
+ export {
10
+ privateApis
11
+ };
12
+ //# sourceMappingURL=private-apis.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["useEntityRecordsWithPermissions","RECEIVE_INTERMEDIATE_RESULTS","lock","privateApis"],"sources":["@wordpress/core-data/src/private-apis.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport { useEntityRecordsWithPermissions } from './hooks/use-entity-records';\nimport { RECEIVE_INTERMEDIATE_RESULTS } from './utils';\nimport { lock } from './lock-unlock';\n\nexport const privateApis = {};\nlock( privateApis, {\n\tuseEntityRecordsWithPermissions,\n\tRECEIVE_INTERMEDIATE_RESULTS,\n} );\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,+BAA+B,QAAQ,4BAA4B;AAC5E,SAASC,4BAA4B,QAAQ,SAAS;AACtD,SAASC,IAAI,QAAQ,eAAe;AAEpC,OAAO,MAAMC,WAAW,GAAG,CAAC,CAAC;AAC7BD,IAAI,CAAEC,WAAW,EAAE;EAClBH,+BAA+B;EAC/BC;AACD,CAAE,CAAC","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/private-apis.js"],
4
+ "sourcesContent": ["/**\n * Internal dependencies\n */\nimport { useEntityRecordsWithPermissions } from './hooks/use-entity-records';\nimport { RECEIVE_INTERMEDIATE_RESULTS } from './utils';\nimport { lock } from './lock-unlock';\n\nexport const privateApis = {};\nlock( privateApis, {\n\tuseEntityRecordsWithPermissions,\n\tRECEIVE_INTERMEDIATE_RESULTS,\n} );\n"],
5
+ "mappings": "AAGA,SAAS,uCAAuC;AAChD,SAAS,oCAAoC;AAC7C,SAAS,YAAY;AAEd,MAAM,cAAc,CAAC;AAC5B,KAAM,aAAa;AAAA,EAClB;AAAA,EACA;AACD,CAAE;",
6
+ "names": []
7
+ }