@wordpress/core-data 6.16.0 → 6.17.1

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 (236) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/actions.js +69 -134
  3. package/build/actions.js.map +1 -1
  4. package/build/batch/create-batch.js +0 -22
  5. package/build/batch/create-batch.js.map +1 -1
  6. package/build/batch/default-processor.js +3 -15
  7. package/build/batch/default-processor.js.map +1 -1
  8. package/build/batch/index.js +0 -3
  9. package/build/batch/index.js.map +1 -1
  10. package/build/entities.js +109 -36
  11. package/build/entities.js.map +1 -1
  12. package/build/entity-provider.js +34 -53
  13. package/build/entity-provider.js.map +1 -1
  14. package/build/entity-types/attachment.js.map +1 -1
  15. package/build/entity-types/base-entity-records.js +0 -3
  16. package/build/entity-types/base-entity-records.js.map +1 -1
  17. package/build/entity-types/comment.js.map +1 -1
  18. package/build/entity-types/helpers.js.map +1 -1
  19. package/build/entity-types/index.js.map +1 -1
  20. package/build/entity-types/menu-location.js.map +1 -1
  21. package/build/entity-types/nav-menu-item.js.map +1 -1
  22. package/build/entity-types/nav-menu.js.map +1 -1
  23. package/build/entity-types/page.js.map +1 -1
  24. package/build/entity-types/plugin.js.map +1 -1
  25. package/build/entity-types/post.js.map +1 -1
  26. package/build/entity-types/settings.js.map +1 -1
  27. package/build/entity-types/sidebar.js.map +1 -1
  28. package/build/entity-types/taxonomy.js.map +1 -1
  29. package/build/entity-types/theme.js.map +1 -1
  30. package/build/entity-types/type.js.map +1 -1
  31. package/build/entity-types/user.js.map +1 -1
  32. package/build/entity-types/widget-type.js.map +1 -1
  33. package/build/entity-types/widget.js.map +1 -1
  34. package/build/entity-types/wp-template-part.js.map +1 -1
  35. package/build/entity-types/wp-template.js.map +1 -1
  36. package/build/fetch/__experimental-fetch-link-suggestions.js +14 -20
  37. package/build/fetch/__experimental-fetch-link-suggestions.js.map +1 -1
  38. package/build/fetch/__experimental-fetch-url-data.js +4 -13
  39. package/build/fetch/__experimental-fetch-url-data.js.map +1 -1
  40. package/build/fetch/index.js +0 -3
  41. package/build/fetch/index.js.map +1 -1
  42. package/build/hooks/constants.js +4 -5
  43. package/build/hooks/constants.js.map +1 -1
  44. package/build/hooks/index.js +0 -5
  45. package/build/hooks/index.js.map +1 -1
  46. package/build/hooks/memoize.js +0 -3
  47. package/build/hooks/memoize.js.map +1 -1
  48. package/build/hooks/use-entity-record.js +0 -9
  49. package/build/hooks/use-entity-record.js.map +1 -1
  50. package/build/hooks/use-entity-records.js +2 -9
  51. package/build/hooks/use-entity-records.js.map +1 -1
  52. package/build/hooks/use-query-select.js +1 -13
  53. package/build/hooks/use-query-select.js.map +1 -1
  54. package/build/hooks/use-resource-permissions.js +0 -15
  55. package/build/hooks/use-resource-permissions.js.map +1 -1
  56. package/build/index.js +9 -41
  57. package/build/index.js.map +1 -1
  58. package/build/locks/actions.js +1 -6
  59. package/build/locks/actions.js.map +1 -1
  60. package/build/locks/engine.js +1 -9
  61. package/build/locks/engine.js.map +1 -1
  62. package/build/locks/reducer.js +8 -9
  63. package/build/locks/reducer.js.map +1 -1
  64. package/build/locks/selectors.js +8 -11
  65. package/build/locks/selectors.js.map +1 -1
  66. package/build/locks/utils.js +4 -19
  67. package/build/locks/utils.js.map +1 -1
  68. package/build/name.js +0 -1
  69. package/build/name.js.map +1 -1
  70. package/build/private-apis.js +1 -2
  71. package/build/private-apis.js.map +1 -1
  72. package/build/private-selectors.js +2 -5
  73. package/build/private-selectors.js.map +1 -1
  74. package/build/queried-data/actions.js +4 -6
  75. package/build/queried-data/actions.js.map +1 -1
  76. package/build/queried-data/get-query-parts.js +11 -24
  77. package/build/queried-data/get-query-parts.js.map +1 -1
  78. package/build/queried-data/index.js +0 -6
  79. package/build/queried-data/index.js.map +1 -1
  80. package/build/queried-data/reducer.js +33 -51
  81. package/build/queried-data/reducer.js.map +1 -1
  82. package/build/queried-data/selectors.js +4 -25
  83. package/build/queried-data/selectors.js.map +1 -1
  84. package/build/reducer.js +76 -128
  85. package/build/reducer.js.map +1 -1
  86. package/build/resolvers.js +91 -133
  87. package/build/resolvers.js.map +1 -1
  88. package/build/selectors.js +51 -145
  89. package/build/selectors.js.map +1 -1
  90. package/build/sync.js +19 -0
  91. package/build/sync.js.map +1 -0
  92. package/build/types.js.map +1 -1
  93. package/build/utils/conservative-map-item.js +3 -10
  94. package/build/utils/conservative-map-item.js.map +1 -1
  95. package/build/utils/forward-resolver.js +0 -2
  96. package/build/utils/forward-resolver.js.map +1 -1
  97. package/build/utils/get-normalized-comma-separable.js +0 -3
  98. package/build/utils/get-normalized-comma-separable.js.map +1 -1
  99. package/build/utils/if-matching-action.js +0 -3
  100. package/build/utils/if-matching-action.js.map +1 -1
  101. package/build/utils/index.js +0 -10
  102. package/build/utils/index.js.map +1 -1
  103. package/build/utils/is-raw-attribute.js +0 -1
  104. package/build/utils/is-raw-attribute.js.map +1 -1
  105. package/build/utils/on-sub-key.js +5 -9
  106. package/build/utils/on-sub-key.js.map +1 -1
  107. package/build/utils/replace-action.js +0 -2
  108. package/build/utils/replace-action.js.map +1 -1
  109. package/build/utils/set-nested-value.js +0 -4
  110. package/build/utils/set-nested-value.js.map +1 -1
  111. package/build/utils/with-weak-map-cache.js +3 -6
  112. package/build/utils/with-weak-map-cache.js.map +1 -1
  113. package/build-module/actions.js +72 -95
  114. package/build-module/actions.js.map +1 -1
  115. package/build-module/batch/create-batch.js +1 -20
  116. package/build-module/batch/create-batch.js.map +1 -1
  117. package/build-module/batch/default-processor.js +4 -13
  118. package/build-module/batch/default-processor.js.map +1 -1
  119. package/build-module/batch/index.js.map +1 -1
  120. package/build-module/entities.js +109 -25
  121. package/build-module/entities.js.map +1 -1
  122. package/build-module/entity-provider.js +35 -45
  123. package/build-module/entity-provider.js.map +1 -1
  124. package/build-module/entity-types/attachment.js.map +1 -1
  125. package/build-module/entity-types/base-entity-records.js +0 -2
  126. package/build-module/entity-types/base-entity-records.js.map +1 -1
  127. package/build-module/entity-types/comment.js.map +1 -1
  128. package/build-module/entity-types/helpers.js.map +1 -1
  129. package/build-module/entity-types/index.js.map +1 -1
  130. package/build-module/entity-types/menu-location.js.map +1 -1
  131. package/build-module/entity-types/nav-menu-item.js.map +1 -1
  132. package/build-module/entity-types/nav-menu.js.map +1 -1
  133. package/build-module/entity-types/page.js.map +1 -1
  134. package/build-module/entity-types/plugin.js.map +1 -1
  135. package/build-module/entity-types/post.js.map +1 -1
  136. package/build-module/entity-types/settings.js.map +1 -1
  137. package/build-module/entity-types/sidebar.js.map +1 -1
  138. package/build-module/entity-types/taxonomy.js.map +1 -1
  139. package/build-module/entity-types/theme.js.map +1 -1
  140. package/build-module/entity-types/type.js.map +1 -1
  141. package/build-module/entity-types/user.js.map +1 -1
  142. package/build-module/entity-types/widget-type.js.map +1 -1
  143. package/build-module/entity-types/widget.js.map +1 -1
  144. package/build-module/entity-types/wp-template-part.js.map +1 -1
  145. package/build-module/entity-types/wp-template.js.map +1 -1
  146. package/build-module/fetch/__experimental-fetch-link-suggestions.js +15 -15
  147. package/build-module/fetch/__experimental-fetch-link-suggestions.js.map +1 -1
  148. package/build-module/fetch/__experimental-fetch-url-data.js +5 -10
  149. package/build-module/fetch/__experimental-fetch-url-data.js.map +1 -1
  150. package/build-module/fetch/index.js.map +1 -1
  151. package/build-module/hooks/constants.js +3 -4
  152. package/build-module/hooks/constants.js.map +1 -1
  153. package/build-module/hooks/index.js.map +1 -1
  154. package/build-module/hooks/memoize.js +2 -1
  155. package/build-module/hooks/memoize.js.map +1 -1
  156. package/build-module/hooks/use-entity-record.js +1 -3
  157. package/build-module/hooks/use-entity-record.js.map +1 -1
  158. package/build-module/hooks/use-entity-records.js +2 -3
  159. package/build-module/hooks/use-entity-records.js.map +1 -1
  160. package/build-module/hooks/use-query-select.js +1 -9
  161. package/build-module/hooks/use-query-select.js.map +1 -1
  162. package/build-module/hooks/use-resource-permissions.js +1 -10
  163. package/build-module/hooks/use-resource-permissions.js.map +1 -1
  164. package/build-module/index.js +11 -19
  165. package/build-module/index.js.map +1 -1
  166. package/build-module/locks/actions.js +0 -3
  167. package/build-module/locks/actions.js.map +1 -1
  168. package/build-module/locks/engine.js +0 -5
  169. package/build-module/locks/engine.js.map +1 -1
  170. package/build-module/locks/reducer.js +7 -7
  171. package/build-module/locks/reducer.js.map +1 -1
  172. package/build-module/locks/selectors.js +7 -8
  173. package/build-module/locks/selectors.js.map +1 -1
  174. package/build-module/locks/utils.js +4 -14
  175. package/build-module/locks/utils.js.map +1 -1
  176. package/build-module/name.js.map +1 -1
  177. package/build-module/private-apis.js.map +1 -1
  178. package/build-module/private-selectors.js +2 -2
  179. package/build-module/private-selectors.js.map +1 -1
  180. package/build-module/queried-data/actions.js +4 -3
  181. package/build-module/queried-data/actions.js.map +1 -1
  182. package/build-module/queried-data/get-query-parts.js +13 -21
  183. package/build-module/queried-data/get-query-parts.js.map +1 -1
  184. package/build-module/queried-data/index.js.map +1 -1
  185. package/build-module/queried-data/reducer.js +33 -42
  186. package/build-module/queried-data/reducer.js.map +1 -1
  187. package/build-module/queried-data/selectors.js +6 -21
  188. package/build-module/queried-data/selectors.js.map +1 -1
  189. package/build-module/reducer.js +79 -104
  190. package/build-module/reducer.js.map +1 -1
  191. package/build-module/resolvers.js +94 -96
  192. package/build-module/resolvers.js.map +1 -1
  193. package/build-module/selectors.js +56 -92
  194. package/build-module/selectors.js.map +1 -1
  195. package/build-module/sync.js +12 -0
  196. package/build-module/sync.js.map +1 -0
  197. package/build-module/types.js.map +1 -1
  198. package/build-module/utils/conservative-map-item.js +4 -8
  199. package/build-module/utils/conservative-map-item.js.map +1 -1
  200. package/build-module/utils/forward-resolver.js +0 -1
  201. package/build-module/utils/forward-resolver.js.map +1 -1
  202. package/build-module/utils/get-normalized-comma-separable.js +0 -2
  203. package/build-module/utils/get-normalized-comma-separable.js.map +1 -1
  204. package/build-module/utils/if-matching-action.js +0 -2
  205. package/build-module/utils/if-matching-action.js.map +1 -1
  206. package/build-module/utils/index.js.map +1 -1
  207. package/build-module/utils/is-raw-attribute.js.map +1 -1
  208. package/build-module/utils/on-sub-key.js +5 -7
  209. package/build-module/utils/on-sub-key.js.map +1 -1
  210. package/build-module/utils/replace-action.js +0 -1
  211. package/build-module/utils/replace-action.js.map +1 -1
  212. package/build-module/utils/set-nested-value.js +0 -3
  213. package/build-module/utils/set-nested-value.js.map +1 -1
  214. package/build-module/utils/with-weak-map-cache.js +3 -5
  215. package/build-module/utils/with-weak-map-cache.js.map +1 -1
  216. package/build-types/actions.d.ts.map +1 -1
  217. package/build-types/entities.d.ts +53 -0
  218. package/build-types/entities.d.ts.map +1 -1
  219. package/build-types/entity-provider.d.ts +1 -1
  220. package/build-types/entity-provider.d.ts.map +1 -1
  221. package/build-types/hooks/memoize.d.ts +1 -1
  222. package/build-types/hooks/memoize.d.ts.map +1 -1
  223. package/build-types/index.d.ts +3 -3
  224. package/build-types/index.d.ts.map +1 -1
  225. package/build-types/resolvers.d.ts.map +1 -1
  226. package/build-types/sync.d.ts +2 -0
  227. package/build-types/sync.d.ts.map +1 -0
  228. package/package.json +17 -15
  229. package/src/actions.js +24 -14
  230. package/src/entities.js +91 -0
  231. package/src/entity-provider.js +11 -2
  232. package/src/resolvers.js +89 -41
  233. package/src/sync.js +18 -0
  234. package/src/test/entity-provider.js +272 -0
  235. package/tsconfig.json +1 -0
  236. package/tsconfig.tsbuildinfo +1 -1
@@ -9,6 +9,7 @@ const DEFAULT_STATE = {
9
9
  children: {}
10
10
  }
11
11
  };
12
+
12
13
  /**
13
14
  * Reducer returning locks.
14
15
  *
@@ -17,7 +18,6 @@ const DEFAULT_STATE = {
17
18
  *
18
19
  * @return {Object} Updated state.
19
20
  */
20
-
21
21
  export default function locks(state = DEFAULT_STATE, action) {
22
22
  switch (action.type) {
23
23
  case 'ENQUEUE_LOCK_REQUEST':
@@ -25,11 +25,11 @@ export default function locks(state = DEFAULT_STATE, action) {
25
25
  const {
26
26
  request
27
27
  } = action;
28
- return { ...state,
28
+ return {
29
+ ...state,
29
30
  requests: [request, ...state.requests]
30
31
  };
31
32
  }
32
-
33
33
  case 'GRANT_LOCK_REQUEST':
34
34
  {
35
35
  const {
@@ -44,12 +44,12 @@ export default function locks(state = DEFAULT_STATE, action) {
44
44
  const newTree = deepCopyLocksTreePath(state.tree, storePath);
45
45
  const node = getNode(newTree, storePath);
46
46
  node.locks = [...node.locks, lock];
47
- return { ...state,
47
+ return {
48
+ ...state,
48
49
  requests: state.requests.filter(r => r !== request),
49
50
  tree: newTree
50
51
  };
51
52
  }
52
-
53
53
  case 'RELEASE_LOCK':
54
54
  {
55
55
  const {
@@ -59,12 +59,12 @@ export default function locks(state = DEFAULT_STATE, action) {
59
59
  const newTree = deepCopyLocksTreePath(state.tree, storePath);
60
60
  const node = getNode(newTree, storePath);
61
61
  node.locks = node.locks.filter(l => l !== lock);
62
- return { ...state,
62
+ return {
63
+ ...state,
63
64
  tree: newTree
64
65
  };
65
66
  }
66
67
  }
67
-
68
68
  return state;
69
69
  }
70
70
  //# sourceMappingURL=reducer.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/core-data/src/locks/reducer.js"],"names":["getNode","deepCopyLocksTreePath","DEFAULT_STATE","requests","tree","locks","children","state","action","type","request","lock","store","path","storePath","newTree","node","filter","r","l"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,OAAT,EAAkBC,qBAAlB,QAA+C,SAA/C;AAEA,MAAMC,aAAa,GAAG;AACrBC,EAAAA,QAAQ,EAAE,EADW;AAErBC,EAAAA,IAAI,EAAE;AACLC,IAAAA,KAAK,EAAE,EADF;AAELC,IAAAA,QAAQ,EAAE;AAFL;AAFe,CAAtB;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASD,KAAT,CAAgBE,KAAK,GAAGL,aAAxB,EAAuCM,MAAvC,EAAgD;AAC9D,UAASA,MAAM,CAACC,IAAhB;AACC,SAAK,sBAAL;AAA6B;AAC5B,cAAM;AAAEC,UAAAA;AAAF,Y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H,UAAAA,IAAI,EAAEW;AAFA,SAAP;AAIA;AAnCF;;AAsCA,SAAOR,KAAP;AACA","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"]}
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;A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,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"}
@@ -9,25 +9,25 @@ export function isLockAvailable(state, store, path, {
9
9
  exclusive
10
10
  }) {
11
11
  const storePath = [store, ...path];
12
- const locks = state.tree; // Validate all parents and the node itself
12
+ const locks = state.tree;
13
13
 
14
+ // Validate all parents and the node itself
14
15
  for (const node of iteratePath(locks, storePath)) {
15
16
  if (hasConflictingLock({
16
17
  exclusive
17
18
  }, node.locks)) {
18
19
  return false;
19
20
  }
20
- } // iteratePath terminates early if path is unreachable, let's
21
- // re-fetch the node and check it exists in the tree.
22
-
21
+ }
23
22
 
23
+ // iteratePath terminates early if path is unreachable, let's
24
+ // re-fetch the node and check it exists in the tree.
24
25
  const node = getNode(locks, storePath);
25
-
26
26
  if (!node) {
27
27
  return true;
28
- } // Validate all nested nodes
29
-
28
+ }
30
29
 
30
+ // Validate all nested nodes
31
31
  for (const descendant of iterateDescendants(node)) {
32
32
  if (hasConflictingLock({
33
33
  exclusive
@@ -35,7 +35,6 @@ export function isLockAvailable(state, store, path, {
35
35
  return false;
36
36
  }
37
37
  }
38
-
39
38
  return true;
40
39
  }
41
40
  //# sourceMappingURL=selectors.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/core-data/src/locks/selectors.js"],"names":["iterateDescendants","iteratePath","hasConflictingLock","getNode","getPendingLockRequests","state","requests","isLockAvailable","store","path","exclusive","storePath","locks","tree","node","descendant"],"mappings":"AAAA;AACA;AACA;AACA,SACCA,kBADD,EAECC,WAFD,EAGCC,kBAHD,EAICC,OAJD,QAKO,SALP;AAOA,OAAO,SAASC,sBAAT,CAAiCC,KAAjC,EAAyC;AAC/C,SAAOA,KAAK,CAACC,QAAb;AACA;AAED,OAAO,SAASC,eAAT,CAA0BF,KAA1B,EAAiCG,KAAjC,EAAwCC,IAAxC,EAA8C;AAAEC,EAAAA;AAAF,CAA9C,EAA8D;AACpE,QAAMC,SAAS,GAAG,CAAEH,KAAF,EAAS,GAAGC,IAAZ,CAAlB;AACA,QAAMG,KAAK,GAAGP,KAAK,CAACQ,IAApB,CAFoE,CAIpE;;AACA,OAAM,MAAMC,IAAZ,IAAoBb,WAAW,CAAEW,KAAF,EAASD,SAAT,CAA/B,EAAsD;AACrD,QAAKT,kBAAkB,CAAE;AAAEQ,MAAAA;AAAF,KAAF,EAAiBI,IAAI,CAACF,KAAtB,CAAvB,EAAuD;AACtD,aAAO,KAAP;AACA;AACD,GATmE,CAWpE;AACA;;;AACA,QAAME,IAAI,GAAGX,OAAO,CAAES,KAAF,EAASD,SAAT,CAApB;;AACA,MAAK,CAAEG,IAAP,EAAc;AACb,WAAO,IAAP;AACA,GAhBmE,CAkBpE;;;AACA,OAAM,MAAMC,UAAZ,IAA0Bf,kBAAkB,CAAEc,IAAF,CAA5C,EAAuD;AACtD,QAAKZ,kBAAkB,CAAE;AAAEQ,MAAAA;AAAF,KAAF,EAAiBK,UAAU,CAACH,KAA5B,CAAvB,EAA6D;AAC5D,aAAO,KAAP;AACA;AACD;;AAED,SAAO,IAAP;AACA","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"]}
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"}
@@ -1,10 +1,11 @@
1
1
  export function deepCopyLocksTreePath(tree, path) {
2
- const newTree = { ...tree
2
+ const newTree = {
3
+ ...tree
3
4
  };
4
5
  let currentNode = newTree;
5
-
6
6
  for (const branchName of path) {
7
- currentNode.children = { ...currentNode.children,
7
+ currentNode.children = {
8
+ ...currentNode.children,
8
9
  [branchName]: {
9
10
  locks: [],
10
11
  children: {},
@@ -13,42 +14,33 @@ export function deepCopyLocksTreePath(tree, path) {
13
14
  };
14
15
  currentNode = currentNode.children[branchName];
15
16
  }
16
-
17
17
  return newTree;
18
18
  }
19
19
  export function getNode(tree, path) {
20
20
  let currentNode = tree;
21
-
22
21
  for (const branchName of path) {
23
22
  const nextNode = currentNode.children[branchName];
24
-
25
23
  if (!nextNode) {
26
24
  return null;
27
25
  }
28
-
29
26
  currentNode = nextNode;
30
27
  }
31
-
32
28
  return currentNode;
33
29
  }
34
30
  export function* iteratePath(tree, path) {
35
31
  let currentNode = tree;
36
32
  yield currentNode;
37
-
38
33
  for (const branchName of path) {
39
34
  const nextNode = currentNode.children[branchName];
40
-
41
35
  if (!nextNode) {
42
36
  break;
43
37
  }
44
-
45
38
  yield nextNode;
46
39
  currentNode = nextNode;
47
40
  }
48
41
  }
49
42
  export function* iterateDescendants(node) {
50
43
  const stack = Object.values(node.children);
51
-
52
44
  while (stack.length) {
53
45
  const childNode = stack.pop();
54
46
  yield childNode;
@@ -61,11 +53,9 @@ export function hasConflictingLock({
61
53
  if (exclusive && locks.length) {
62
54
  return true;
63
55
  }
64
-
65
56
  if (!exclusive && locks.filter(lock => lock.exclusive).length) {
66
57
  return true;
67
58
  }
68
-
69
59
  return false;
70
60
  }
71
61
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/core-data/src/locks/utils.js"],"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"],"mappings":"AAAA,OAAO,SAASA,qBAAT,CAAgCC,IAAhC,EAAsCC,IAAtC,EAA6C;AACnD,QAAMC,OAAO,GAAG,EAAE,GAAGF;AAAL,GAAhB;AACA,MAAIG,WAAW,GAAGD,OAAlB;;AACA,OAAM,MAAME,UAAZ,IAA0BH,IAA1B,EAAiC;AAChCE,IAAAA,WAAW,CAACE,QAAZ,GAAuB,EACtB,GAAGF,WAAW,CAACE,QADO;AAEtB,OAAED,UAAF,GAAgB;AACfE,QAAAA,KAAK,EAAE,EADQ;AAEfD,QAAAA,QAAQ,EAAE,EAFK;AAGf,WAAGF,WAAW,CAACE,QAAZ,CAAsBD,UAAtB;AAHY;AAFM,KAAvB;AAQAD,IAAAA,WAAW,GAAGA,WAAW,CAACE,QAAZ,CAAsBD,UAAtB,CAAd;AACA;;AACD,SAAOF,OAAP;AACA;AAED,OAAO,SAASK,OAAT,CAAkBP,IAAlB,EAAwBC,IAAxB,EAA+B;AACrC,MAAIE,WAAW,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SAAO,KAAP;AACA","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"]}
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,EAA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,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"}
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/core-data/src/name.js"],"names":["STORE_NAME"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMA,UAAU,GAAG,MAAnB","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"]}
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"}
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/core-data/src/private-apis.js"],"names":["__dangerousOptInToUnstableAPIsOnlyForCoreModules","lock","unlock"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,gDAAT,QAAiE,yBAAjE;AAEA,OAAO,MAAM;AAAEC,EAAAA,IAAF;AAAQC,EAAAA;AAAR,IACZF,gDAAgD,CAC/C,8GAD+C,EAE/C,sBAF+C,CAD1C","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis';\n\nexport const { lock, unlock } =\n\t__dangerousOptInToUnstableAPIsOnlyForCoreModules(\n\t\t'I know using unstable features means my plugin or theme will inevitably break on the next WordPress release.',\n\t\t'@wordpress/core-data'\n\t);\n"]}
1
+ {"version":3,"names":["__dangerousOptInToUnstableAPIsOnlyForCoreModules","lock","unlock"],"sources":["@wordpress/core-data/src/private-apis.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis';\n\nexport const { lock, unlock } =\n\t__dangerousOptInToUnstableAPIsOnlyForCoreModules(\n\t\t'I know using unstable features means my plugin or theme will inevitably break on the next WordPress release.',\n\t\t'@wordpress/core-data'\n\t);\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,gDAAgD,QAAQ,yBAAyB;AAE1F,OAAO,MAAM;EAAEC,IAAI;EAAEC;AAAO,CAAC,GAC5BF,gDAAgD,CAC/C,8GAA8G,EAC9G,sBACD,CAAC"}
@@ -13,6 +13,7 @@
13
13
  export function getUndoEdits(state) {
14
14
  return state.undo.list[state.undo.list.length - 1 + state.undo.offset];
15
15
  }
16
+
16
17
  /**
17
18
  * Returns the next edit from the current undo offset
18
19
  * for the entity records edits history, if any.
@@ -21,17 +22,16 @@ export function getUndoEdits(state) {
21
22
  *
22
23
  * @return The edit.
23
24
  */
24
-
25
25
  export function getRedoEdits(state) {
26
26
  return state.undo.list[state.undo.list.length + state.undo.offset];
27
27
  }
28
+
28
29
  /**
29
30
  * Retrieve the fallback Navigation.
30
31
  *
31
32
  * @param state Data state.
32
33
  * @return The ID for the fallback Navigation post.
33
34
  */
34
-
35
35
  export function getNavigationFallbackId(state) {
36
36
  return state.navigationFallbackId;
37
37
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/core-data/src/private-selectors.ts"],"names":["getUndoEdits","state","undo","list","length","offset","getRedoEdits","getNavigationFallbackId","navigationFallbackId"],"mappings":"AAAA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,YAAT,CAAuBC,KAAvB,EAA8D;AACpE,SAAOA,KAAK,CAACC,IAAN,CAAWC,IAAX,CAAiBF,KAAK,CAACC,IAAN,CAAWC,IAAX,CAAgBC,MAAhB,GAAyB,CAAzB,GAA6BH,KAAK,CAACC,IAAN,CAAWG,MAAzD,CAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,YAAT,CAAuBL,KAAvB,EAA8D;AACpE,SAAOA,KAAK,CAACC,IAAN,CAAWC,IAAX,CAAiBF,KAAK,CAACC,IAAN,CAAWC,IAAX,CAAgBC,MAAhB,GAAyBH,KAAK,CAACC,IAAN,CAAWG,MAArD,CAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASE,uBAAT,CACNN,KADM,EAEwB;AAC9B,SAAOA,KAAK,CAACO,oBAAb;AACA","sourcesContent":["/**\n * Internal dependencies\n */\nimport type { State, UndoEdit } from './selectors';\n\ntype Optional< T > = T | undefined;\ntype EntityRecordKey = string | number;\n\n/**\n * Returns the previous edit from the current undo offset\n * for the entity records edits history, if any.\n *\n * @param state State tree.\n *\n * @return The edit.\n */\nexport function getUndoEdits( state: State ): Optional< UndoEdit[] > {\n\treturn state.undo.list[ state.undo.list.length - 1 + state.undo.offset ];\n}\n\n/**\n * Returns the next edit from the current undo offset\n * for the entity records edits history, if any.\n *\n * @param state State tree.\n *\n * @return The edit.\n */\nexport function getRedoEdits( state: State ): Optional< UndoEdit[] > {\n\treturn state.undo.list[ state.undo.list.length + state.undo.offset ];\n}\n\n/**\n * Retrieve the fallback Navigation.\n *\n * @param state Data state.\n * @return The ID for the fallback Navigation post.\n */\nexport function getNavigationFallbackId(\n\tstate: State\n): EntityRecordKey | undefined {\n\treturn state.navigationFallbackId;\n}\n"]}
1
+ {"version":3,"names":["getUndoEdits","state","undo","list","length","offset","getRedoEdits","getNavigationFallbackId","navigationFallbackId"],"sources":["@wordpress/core-data/src/private-selectors.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport type { State, UndoEdit } from './selectors';\n\ntype Optional< T > = T | undefined;\ntype EntityRecordKey = string | number;\n\n/**\n * Returns the previous edit from the current undo offset\n * for the entity records edits history, if any.\n *\n * @param state State tree.\n *\n * @return The edit.\n */\nexport function getUndoEdits( state: State ): Optional< UndoEdit[] > {\n\treturn state.undo.list[ state.undo.list.length - 1 + state.undo.offset ];\n}\n\n/**\n * Returns the next edit from the current undo offset\n * for the entity records edits history, if any.\n *\n * @param state State tree.\n *\n * @return The edit.\n */\nexport function getRedoEdits( state: State ): Optional< UndoEdit[] > {\n\treturn state.undo.list[ state.undo.list.length + state.undo.offset ];\n}\n\n/**\n * Retrieve the fallback Navigation.\n *\n * @param state Data state.\n * @return The ID for the fallback Navigation post.\n */\nexport function getNavigationFallbackId(\n\tstate: State\n): EntityRecordKey | undefined {\n\treturn state.navigationFallbackId;\n}\n"],"mappings":"AAAA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,YAAYA,CAAEC,KAAY,EAA2B;EACpE,OAAOA,KAAK,CAACC,IAAI,CAACC,IAAI,CAAEF,KAAK,CAACC,IAAI,CAACC,IAAI,CAACC,MAAM,GAAG,CAAC,GAAGH,KAAK,CAACC,IAAI,CAACG,MAAM,CAAE;AACzE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,YAAYA,CAAEL,KAAY,EAA2B;EACpE,OAAOA,KAAK,CAACC,IAAI,CAACC,IAAI,CAAEF,KAAK,CAACC,IAAI,CAACC,IAAI,CAACC,MAAM,GAAGH,KAAK,CAACC,IAAI,CAACG,MAAM,CAAE;AACrE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASE,uBAAuBA,CACtCN,KAAY,EACkB;EAC9B,OAAOA,KAAK,CAACO,oBAAoB;AAClC"}
@@ -13,6 +13,7 @@ export function receiveItems(items, edits) {
13
13
  persistedEdits: edits
14
14
  };
15
15
  }
16
+
16
17
  /**
17
18
  * Returns an action object used in signalling that entity records have been
18
19
  * deleted and they need to be removed from entities state.
@@ -23,7 +24,6 @@ export function receiveItems(items, edits) {
23
24
  * @param {boolean} invalidateCache Controls whether we want to invalidate the cache.
24
25
  * @return {Object} Action object.
25
26
  */
26
-
27
27
  export function removeItems(kind, name, records, invalidateCache = false) {
28
28
  return {
29
29
  type: 'REMOVE_ITEMS',
@@ -33,6 +33,7 @@ export function removeItems(kind, name, records, invalidateCache = false) {
33
33
  invalidateCache
34
34
  };
35
35
  }
36
+
36
37
  /**
37
38
  * Returns an action object used in signalling that queried data has been
38
39
  * received.
@@ -43,9 +44,9 @@ export function removeItems(kind, name, records, invalidateCache = false) {
43
44
  *
44
45
  * @return {Object} Action object.
45
46
  */
46
-
47
47
  export function receiveQueriedItems(items, query = {}, edits) {
48
- return { ...receiveItems(items, edits),
48
+ return {
49
+ ...receiveItems(items, edits),
49
50
  query
50
51
  };
51
52
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/core-data/src/queried-data/actions.js"],"names":["receiveItems","items","edits","type","Array","isArray","persistedEdits","removeItems","kind","name","records","invalidateCache","itemIds","receiveQueriedItems","query"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,YAAT,CAAuBC,KAAvB,EAA8BC,KAA9B,EAAsC;AAC5C,SAAO;AACNC,IAAAA,IAAI,EAAE,eADA;AAENF,IAAAA,KAAK,EAAEG,KAAK,CAACC,OAAN,CAAeJ,KAAf,IAAyBA,KAAzB,GAAiC,CAAEA,KAAF,CAFlC;AAGNK,IAAAA,cAAc,EAAEJ;AAHV,GAAP;AAKA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASK,WAAT,CAAsBC,IAAtB,EAA4BC,IAA5B,EAAkCC,OAAlC,EAA2CC,eAAe,GAAG,KAA7D,EAAqE;AAC3E,SAAO;AACNR,IAAAA,IAAI,EAAE,cADA;AAENS,IAAAA,OAAO,EAAER,KAAK,CAACC,OAAN,CAAeK,OAAf,IAA2BA,OAA3B,GAAqC,CAAEA,OAAF,CAFxC;AAGNF,IAAAA,IAHM;AAINC,IAAAA,IAJM;AAKNE,IAAAA;AALM,GAAP;AAOA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASE,mBAAT,CAA8BZ,KAA9B,EAAqCa,KAAK,GAAG,EAA7C,EAAiDZ,KAAjD,EAAyD;AAC/D,SAAO,EACN,GAAGF,YAAY,CAAEC,KAAF,EAASC,KAAT,CADT;AAENY,IAAAA;AAFM,GAAP;AAIA","sourcesContent":["/**\n * Returns an action object used in signalling that items have been received.\n *\n * @param {Array} items Items received.\n * @param {?Object} edits Optional edits to reset.\n *\n * @return {Object} Action object.\n */\nexport function receiveItems( items, edits ) {\n\treturn {\n\t\ttype: 'RECEIVE_ITEMS',\n\t\titems: Array.isArray( items ) ? items : [ items ],\n\t\tpersistedEdits: edits,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that entity records have been\n * deleted and they need to be removed from entities state.\n *\n * @param {string} kind Kind of the removed entities.\n * @param {string} name Name of the removed entities.\n * @param {Array|number|string} records Record IDs of the removed entities.\n * @param {boolean} invalidateCache Controls whether we want to invalidate the cache.\n * @return {Object} Action object.\n */\nexport function removeItems( kind, name, records, invalidateCache = false ) {\n\treturn {\n\t\ttype: 'REMOVE_ITEMS',\n\t\titemIds: Array.isArray( records ) ? records : [ records ],\n\t\tkind,\n\t\tname,\n\t\tinvalidateCache,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that queried data has been\n * received.\n *\n * @param {Array} items Queried items received.\n * @param {?Object} query Optional query object.\n * @param {?Object} edits Optional edits to reset.\n *\n * @return {Object} Action object.\n */\nexport function receiveQueriedItems( items, query = {}, edits ) {\n\treturn {\n\t\t...receiveItems( items, edits ),\n\t\tquery,\n\t};\n}\n"]}
1
+ {"version":3,"names":["receiveItems","items","edits","type","Array","isArray","persistedEdits","removeItems","kind","name","records","invalidateCache","itemIds","receiveQueriedItems","query"],"sources":["@wordpress/core-data/src/queried-data/actions.js"],"sourcesContent":["/**\n * Returns an action object used in signalling that items have been received.\n *\n * @param {Array} items Items received.\n * @param {?Object} edits Optional edits to reset.\n *\n * @return {Object} Action object.\n */\nexport function receiveItems( items, edits ) {\n\treturn {\n\t\ttype: 'RECEIVE_ITEMS',\n\t\titems: Array.isArray( items ) ? items : [ items ],\n\t\tpersistedEdits: edits,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that entity records have been\n * deleted and they need to be removed from entities state.\n *\n * @param {string} kind Kind of the removed entities.\n * @param {string} name Name of the removed entities.\n * @param {Array|number|string} records Record IDs of the removed entities.\n * @param {boolean} invalidateCache Controls whether we want to invalidate the cache.\n * @return {Object} Action object.\n */\nexport function removeItems( kind, name, records, invalidateCache = false ) {\n\treturn {\n\t\ttype: 'REMOVE_ITEMS',\n\t\titemIds: Array.isArray( records ) ? records : [ records ],\n\t\tkind,\n\t\tname,\n\t\tinvalidateCache,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that queried data has been\n * received.\n *\n * @param {Array} items Queried items received.\n * @param {?Object} query Optional query object.\n * @param {?Object} edits Optional edits to reset.\n *\n * @return {Object} Action object.\n */\nexport function receiveQueriedItems( items, query = {}, edits ) {\n\treturn {\n\t\t...receiveItems( items, edits ),\n\t\tquery,\n\t};\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,YAAYA,CAAEC,KAAK,EAAEC,KAAK,EAAG;EAC5C,OAAO;IACNC,IAAI,EAAE,eAAe;IACrBF,KAAK,EAAEG,KAAK,CAACC,OAAO,CAAEJ,KAAM,CAAC,GAAGA,KAAK,GAAG,CAAEA,KAAK,CAAE;IACjDK,cAAc,EAAEJ;EACjB,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASK,WAAWA,CAAEC,IAAI,EAAEC,IAAI,EAAEC,OAAO,EAAEC,eAAe,GAAG,KAAK,EAAG;EAC3E,OAAO;IACNR,IAAI,EAAE,cAAc;IACpBS,OAAO,EAAER,KAAK,CAACC,OAAO,CAAEK,OAAQ,CAAC,GAAGA,OAAO,GAAG,CAAEA,OAAO,CAAE;IACzDF,IAAI;IACJC,IAAI;IACJE;EACD,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASE,mBAAmBA,CAAEZ,KAAK,EAAEa,KAAK,GAAG,CAAC,CAAC,EAAEZ,KAAK,EAAG;EAC/D,OAAO;IACN,GAAGF,YAAY,CAAEC,KAAK,EAAEC,KAAM,CAAC;IAC/BY;EACD,CAAC;AACF"}
@@ -2,11 +2,12 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { addQueryArgs } from '@wordpress/url';
5
+
5
6
  /**
6
7
  * Internal dependencies
7
8
  */
8
-
9
9
  import { withWeakMapCache, getNormalizedCommaSeparable } from '../utils';
10
+
10
11
  /**
11
12
  * An object of properties describing a specific query.
12
13
  *
@@ -32,7 +33,6 @@ import { withWeakMapCache, getNormalizedCommaSeparable } from '../utils';
32
33
  *
33
34
  * @return {WPQueriedDataQueryParts} Query parts.
34
35
  */
35
-
36
36
  export function getQueryParts(query) {
37
37
  /**
38
38
  * @type {WPQueriedDataQueryParts}
@@ -44,27 +44,23 @@ export function getQueryParts(query) {
44
44
  fields: null,
45
45
  include: null,
46
46
  context: 'default'
47
- }; // Ensure stable key by sorting keys. Also more efficient for iterating.
47
+ };
48
48
 
49
+ // Ensure stable key by sorting keys. Also more efficient for iterating.
49
50
  const keys = Object.keys(query).sort();
50
-
51
51
  for (let i = 0; i < keys.length; i++) {
52
52
  const key = keys[i];
53
53
  let value = query[key];
54
-
55
54
  switch (key) {
56
55
  case 'page':
57
56
  parts[key] = Number(value);
58
57
  break;
59
-
60
58
  case 'per_page':
61
59
  parts.perPage = Number(value);
62
60
  break;
63
-
64
61
  case 'context':
65
62
  parts.context = value;
66
63
  break;
67
-
68
64
  default:
69
65
  // While in theory, we could exclude "_fields" from the stableKey
70
66
  // because two request with different fields have the same results
@@ -73,38 +69,34 @@ export function getQueryParts(query) {
73
69
  // Example: Asking for titles in posts without title support.
74
70
  if (key === '_fields') {
75
71
  var _getNormalizedCommaSe;
76
-
77
- parts.fields = (_getNormalizedCommaSe = getNormalizedCommaSeparable(value)) !== null && _getNormalizedCommaSe !== void 0 ? _getNormalizedCommaSe : []; // Make sure to normalize value for `stableKey`
78
-
72
+ parts.fields = (_getNormalizedCommaSe = getNormalizedCommaSeparable(value)) !== null && _getNormalizedCommaSe !== void 0 ? _getNormalizedCommaSe : [];
73
+ // Make sure to normalize value for `stableKey`
79
74
  value = parts.fields.join();
80
- } // Two requests with different include values cannot have same results.
81
-
75
+ }
82
76
 
77
+ // Two requests with different include values cannot have same results.
83
78
  if (key === 'include') {
84
79
  var _getNormalizedCommaSe2;
85
-
86
80
  if (typeof value === 'number') {
87
81
  value = value.toString();
88
82
  }
89
-
90
- parts.include = ((_getNormalizedCommaSe2 = getNormalizedCommaSeparable(value)) !== null && _getNormalizedCommaSe2 !== void 0 ? _getNormalizedCommaSe2 : []).map(Number); // Normalize value for `stableKey`.
91
-
83
+ parts.include = ((_getNormalizedCommaSe2 = getNormalizedCommaSeparable(value)) !== null && _getNormalizedCommaSe2 !== void 0 ? _getNormalizedCommaSe2 : []).map(Number);
84
+ // Normalize value for `stableKey`.
92
85
  value = parts.include.join();
93
- } // While it could be any deterministic string, for simplicity's
86
+ }
87
+
88
+ // While it could be any deterministic string, for simplicity's
94
89
  // sake mimic querystring encoding for stable key.
95
90
  //
96
91
  // TODO: For consistency with PHP implementation, addQueryArgs
97
92
  // should accept a key value pair, which may optimize its
98
93
  // implementation for our use here, vs. iterating an object
99
94
  // with only a single key.
100
-
101
-
102
95
  parts.stableKey += (parts.stableKey ? '&' : '') + addQueryArgs('', {
103
96
  [key]: value
104
97
  }).slice(1);
105
98
  }
106
99
  }
107
-
108
100
  return parts;
109
101
  }
110
102
  export default withWeakMapCache(getQueryParts);
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/core-data/src/queried-data/get-query-parts.js"],"names":["addQueryArgs","withWeakMapCache","getNormalizedCommaSeparable","getQueryParts","query","parts","stableKey","page","perPage","fields","include","context","keys","Object","sort","i","length","key","value","Number","join","toString","map","slice"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,YAAT,QAA6B,gBAA7B;AAEA;AACA;AACA;;AACA,SAASC,gBAAT,EAA2BC,2BAA3B,QAA8D,UAA9D;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,aAAT,CAAwBC,KAAxB,EAAgC;AACtC;AACD;AACA;AACC,QAAMC,KAAK,GAAG;AACbC,IAAAA,SAAS,EAAE,EADE;AAEbC,IAAAA,IAAI,EAAE,CAFO;AAGbC,IAAAA,OAAO,EAAE,EAHI;AAIbC,IAAAA,MAAM,EAAE,IAJK;AAKbC,IAAAA,OAAO,EAAE,IALI;AAMbC,IAAAA,OAAO,EAAE;AANI,GAAd,CAJsC,CAatC;;AACA,QAAMC,IAAI,GAAGC,MAAM,CAACD,IAAP,CAAaR,KAAb,EAAqBU,IAArB,EAAb;;AAEA,OAAM,IAAIC,CAAC,GAAG,CAAd,EAAiBA,CAAC,GAAGH,IAAI,CAACI,MAA1B,EAAkCD,CAAC,EAAnC,EAAwC;AACvC,UAAME,GAAG,GAAGL,IAAI,CAAEG,CAAF,CAAhB;AACA,QAAIG,KAAK,GAAGd,KAAK,CAAEa,GAAF,CAAjB;;AAEA,YAASA,GAAT;AACC,WAAK,MAAL;AACCZ,QAAAA,KAAK,CAAEY,GAAF,CAAL,GAAeE,MAAM,CAAED,KAAF,CAArB;AACA;;AAED,WAAK,UAAL;AACCb,QAAAA,KAAK,CAACG,OAAN,GAAgBW,MAAM,CAAED,KAAF,CAAtB;AACA;;AAED,WAAK,SAAL;AACCb,QAAAA,KAAK,CAACM,OAAN,GAAgBO,KAAhB;AACA;;AAED;AACC;AACA;AACA;AACA;AACA;AACA,YAAKD,GAAG,KAAK,SAAb,EAAyB;AAAA;;AACxBZ,UAAAA,KAAK,CAACI,MAAN,4BAAeP,2BAA2B,CAAEgB,KAAF,CAA1C,yEAAuD,EAAvD,CADwB,CAExB;;AACAA,UAAAA,KAAK,GAAGb,KAAK,CAACI,MAAN,CAAaW,IAAb,EAAR;AACA,SAVF,CAYC;;;AACA,YAAKH,GAAG,KAAK,SAAb,EAAyB;AAAA;;AACxB,cAAK,OAAOC,KAAP,KAAiB,QAAtB,EAAiC;AAChCA,YAAAA,KAAK,GAAGA,KAAK,CAACG,QAAN,EAAR;AACA;;AACDhB,UAAAA,KAAK,CAACK,OAAN,GAAgB,2BACfR,2BAA2B,CAAEgB,KAAF,CADZ,2EACyB,EADzB,EAEdI,GAFc,CAETH,MAFS,CAAhB,CAJwB,CAOxB;;AACAD,UAAAA,KAAK,GAAGb,KAAK,CAACK,OAAN,CAAcU,IAAd,EAAR;AACA,SAtBF,CAwBC;AACA;AACA;AACA;AACA;AACA;AACA;;;AACAf,QAAAA,KAAK,CAACC,SAAN,IACC,CAAED,KAAK,CAACC,SAAN,GAAkB,GAAlB,GAAwB,EAA1B,IACAN,YAAY,CAAE,EAAF,EAAM;AAAE,WAAEiB,GAAF,GAASC;AAAX,SAAN,CAAZ,CAAuCK,KAAvC,CAA8C,CAA9C,CAFD;AA5CF;AAgDA;;AAED,SAAOlB,KAAP;AACA;AAED,eAAeJ,gBAAgB,CAAEE,aAAF,CAA/B","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { addQueryArgs } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { withWeakMapCache, getNormalizedCommaSeparable } from '../utils';\n\n/**\n * An object of properties describing a specific query.\n *\n * @typedef {Object} WPQueriedDataQueryParts\n *\n * @property {number} page The query page (1-based index, default 1).\n * @property {number} perPage Items per page for query (default 10).\n * @property {string} stableKey An encoded stable string of all non-\n * pagination, non-fields query parameters.\n * @property {?(string[])} fields Target subset of fields to derive from\n * item objects.\n * @property {?(number[])} include Specific item IDs to include.\n * @property {string} context Scope under which the request is made;\n * determines returned fields in response.\n */\n\n/**\n * Given a query object, returns an object of parts, including pagination\n * details (`page` and `perPage`, or default values). All other properties are\n * encoded into a stable (idempotent) `stableKey` value.\n *\n * @param {Object} query Optional query object.\n *\n * @return {WPQueriedDataQueryParts} Query parts.\n */\nexport function getQueryParts( query ) {\n\t/**\n\t * @type {WPQueriedDataQueryParts}\n\t */\n\tconst parts = {\n\t\tstableKey: '',\n\t\tpage: 1,\n\t\tperPage: 10,\n\t\tfields: null,\n\t\tinclude: null,\n\t\tcontext: 'default',\n\t};\n\n\t// Ensure stable key by sorting keys. Also more efficient for iterating.\n\tconst keys = Object.keys( query ).sort();\n\n\tfor ( let i = 0; i < keys.length; i++ ) {\n\t\tconst key = keys[ i ];\n\t\tlet value = query[ key ];\n\n\t\tswitch ( key ) {\n\t\t\tcase 'page':\n\t\t\t\tparts[ key ] = Number( value );\n\t\t\t\tbreak;\n\n\t\t\tcase 'per_page':\n\t\t\t\tparts.perPage = Number( value );\n\t\t\t\tbreak;\n\n\t\t\tcase 'context':\n\t\t\t\tparts.context = value;\n\t\t\t\tbreak;\n\n\t\t\tdefault:\n\t\t\t\t// While in theory, we could exclude \"_fields\" from the stableKey\n\t\t\t\t// because two request with different fields have the same results\n\t\t\t\t// We're not able to ensure that because the server can decide to omit\n\t\t\t\t// fields from the response even if we explicitly asked for it.\n\t\t\t\t// Example: Asking for titles in posts without title support.\n\t\t\t\tif ( key === '_fields' ) {\n\t\t\t\t\tparts.fields = getNormalizedCommaSeparable( value ) ?? [];\n\t\t\t\t\t// Make sure to normalize value for `stableKey`\n\t\t\t\t\tvalue = parts.fields.join();\n\t\t\t\t}\n\n\t\t\t\t// Two requests with different include values cannot have same results.\n\t\t\t\tif ( key === 'include' ) {\n\t\t\t\t\tif ( typeof value === 'number' ) {\n\t\t\t\t\t\tvalue = value.toString();\n\t\t\t\t\t}\n\t\t\t\t\tparts.include = (\n\t\t\t\t\t\tgetNormalizedCommaSeparable( value ) ?? []\n\t\t\t\t\t).map( Number );\n\t\t\t\t\t// Normalize value for `stableKey`.\n\t\t\t\t\tvalue = parts.include.join();\n\t\t\t\t}\n\n\t\t\t\t// While it could be any deterministic string, for simplicity's\n\t\t\t\t// sake mimic querystring encoding for stable key.\n\t\t\t\t//\n\t\t\t\t// TODO: For consistency with PHP implementation, addQueryArgs\n\t\t\t\t// should accept a key value pair, which may optimize its\n\t\t\t\t// implementation for our use here, vs. iterating an object\n\t\t\t\t// with only a single key.\n\t\t\t\tparts.stableKey +=\n\t\t\t\t\t( parts.stableKey ? '&' : '' ) +\n\t\t\t\t\taddQueryArgs( '', { [ key ]: value } ).slice( 1 );\n\t\t}\n\t}\n\n\treturn parts;\n}\n\nexport default withWeakMapCache( getQueryParts );\n"]}
1
+ {"version":3,"names":["addQueryArgs","withWeakMapCache","getNormalizedCommaSeparable","getQueryParts","query","parts","stableKey","page","perPage","fields","include","context","keys","Object","sort","i","length","key","value","Number","_getNormalizedCommaSe","join","_getNormalizedCommaSe2","toString","map","slice"],"sources":["@wordpress/core-data/src/queried-data/get-query-parts.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { addQueryArgs } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { withWeakMapCache, getNormalizedCommaSeparable } from '../utils';\n\n/**\n * An object of properties describing a specific query.\n *\n * @typedef {Object} WPQueriedDataQueryParts\n *\n * @property {number} page The query page (1-based index, default 1).\n * @property {number} perPage Items per page for query (default 10).\n * @property {string} stableKey An encoded stable string of all non-\n * pagination, non-fields query parameters.\n * @property {?(string[])} fields Target subset of fields to derive from\n * item objects.\n * @property {?(number[])} include Specific item IDs to include.\n * @property {string} context Scope under which the request is made;\n * determines returned fields in response.\n */\n\n/**\n * Given a query object, returns an object of parts, including pagination\n * details (`page` and `perPage`, or default values). All other properties are\n * encoded into a stable (idempotent) `stableKey` value.\n *\n * @param {Object} query Optional query object.\n *\n * @return {WPQueriedDataQueryParts} Query parts.\n */\nexport function getQueryParts( query ) {\n\t/**\n\t * @type {WPQueriedDataQueryParts}\n\t */\n\tconst parts = {\n\t\tstableKey: '',\n\t\tpage: 1,\n\t\tperPage: 10,\n\t\tfields: null,\n\t\tinclude: null,\n\t\tcontext: 'default',\n\t};\n\n\t// Ensure stable key by sorting keys. Also more efficient for iterating.\n\tconst keys = Object.keys( query ).sort();\n\n\tfor ( let i = 0; i < keys.length; i++ ) {\n\t\tconst key = keys[ i ];\n\t\tlet value = query[ key ];\n\n\t\tswitch ( key ) {\n\t\t\tcase 'page':\n\t\t\t\tparts[ key ] = Number( value );\n\t\t\t\tbreak;\n\n\t\t\tcase 'per_page':\n\t\t\t\tparts.perPage = Number( value );\n\t\t\t\tbreak;\n\n\t\t\tcase 'context':\n\t\t\t\tparts.context = value;\n\t\t\t\tbreak;\n\n\t\t\tdefault:\n\t\t\t\t// While in theory, we could exclude \"_fields\" from the stableKey\n\t\t\t\t// because two request with different fields have the same results\n\t\t\t\t// We're not able to ensure that because the server can decide to omit\n\t\t\t\t// fields from the response even if we explicitly asked for it.\n\t\t\t\t// Example: Asking for titles in posts without title support.\n\t\t\t\tif ( key === '_fields' ) {\n\t\t\t\t\tparts.fields = getNormalizedCommaSeparable( value ) ?? [];\n\t\t\t\t\t// Make sure to normalize value for `stableKey`\n\t\t\t\t\tvalue = parts.fields.join();\n\t\t\t\t}\n\n\t\t\t\t// Two requests with different include values cannot have same results.\n\t\t\t\tif ( key === 'include' ) {\n\t\t\t\t\tif ( typeof value === 'number' ) {\n\t\t\t\t\t\tvalue = value.toString();\n\t\t\t\t\t}\n\t\t\t\t\tparts.include = (\n\t\t\t\t\t\tgetNormalizedCommaSeparable( value ) ?? []\n\t\t\t\t\t).map( Number );\n\t\t\t\t\t// Normalize value for `stableKey`.\n\t\t\t\t\tvalue = parts.include.join();\n\t\t\t\t}\n\n\t\t\t\t// While it could be any deterministic string, for simplicity's\n\t\t\t\t// sake mimic querystring encoding for stable key.\n\t\t\t\t//\n\t\t\t\t// TODO: For consistency with PHP implementation, addQueryArgs\n\t\t\t\t// should accept a key value pair, which may optimize its\n\t\t\t\t// implementation for our use here, vs. iterating an object\n\t\t\t\t// with only a single key.\n\t\t\t\tparts.stableKey +=\n\t\t\t\t\t( parts.stableKey ? '&' : '' ) +\n\t\t\t\t\taddQueryArgs( '', { [ key ]: value } ).slice( 1 );\n\t\t}\n\t}\n\n\treturn parts;\n}\n\nexport default withWeakMapCache( getQueryParts );\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,YAAY,QAAQ,gBAAgB;;AAE7C;AACA;AACA;AACA,SAASC,gBAAgB,EAAEC,2BAA2B,QAAQ,UAAU;;AAExE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,aAAaA,CAAEC,KAAK,EAAG;EACtC;AACD;AACA;EACC,MAAMC,KAAK,GAAG;IACbC,SAAS,EAAE,EAAE;IACbC,IAAI,EAAE,CAAC;IACPC,OAAO,EAAE,EAAE;IACXC,MAAM,EAAE,IAAI;IACZC,OAAO,EAAE,IAAI;IACbC,OAAO,EAAE;EACV,CAAC;;EAED;EACA,MAAMC,IAAI,GAAGC,MAAM,CAACD,IAAI,CAAER,KAAM,CAAC,CAACU,IAAI,CAAC,CAAC;EAExC,KAAM,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGH,IAAI,CAACI,MAAM,EAAED,CAAC,EAAE,EAAG;IACvC,MAAME,GAAG,GAAGL,IAAI,CAAEG,CAAC,CAAE;IACrB,IAAIG,KAAK,GAAGd,KAAK,CAAEa,GAAG,CAAE;IAExB,QAASA,GAAG;MACX,KAAK,MAAM;QACVZ,KAAK,CAAEY,GAAG,CAAE,GAAGE,MAAM,CAAED,KAAM,CAAC;QAC9B;MAED,KAAK,UAAU;QACdb,KAAK,CAACG,OAAO,GAAGW,MAAM,CAAED,KAAM,CAAC;QAC/B;MAED,KAAK,SAAS;QACbb,KAAK,CAACM,OAAO,GAAGO,KAAK;QACrB;MAED;QACC;QACA;QACA;QACA;QACA;QACA,IAAKD,GAAG,KAAK,SAAS,EAAG;UAAA,IAAAG,qBAAA;UACxBf,KAAK,CAACI,MAAM,IAAAW,qBAAA,GAAGlB,2BAA2B,CAAEgB,KAAM,CAAC,cAAAE,qBAAA,cAAAA,qBAAA,GAAI,EAAE;UACzD;UACAF,KAAK,GAAGb,KAAK,CAACI,MAAM,CAACY,IAAI,CAAC,CAAC;QAC5B;;QAEA;QACA,IAAKJ,GAAG,KAAK,SAAS,EAAG;UAAA,IAAAK,sBAAA;UACxB,IAAK,OAAOJ,KAAK,KAAK,QAAQ,EAAG;YAChCA,KAAK,GAAGA,KAAK,CAACK,QAAQ,CAAC,CAAC;UACzB;UACAlB,KAAK,CAACK,OAAO,GAAG,EAAAY,sBAAA,GACfpB,2BAA2B,CAAEgB,KAAM,CAAC,cAAAI,sBAAA,cAAAA,sBAAA,GAAI,EAAE,EACzCE,GAAG,CAAEL,MAAO,CAAC;UACf;UACAD,KAAK,GAAGb,KAAK,CAACK,OAAO,CAACW,IAAI,CAAC,CAAC;QAC7B;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACAhB,KAAK,CAACC,SAAS,IACd,CAAED,KAAK,CAACC,SAAS,GAAG,GAAG,GAAG,EAAE,IAC5BN,YAAY,CAAE,EAAE,EAAE;UAAE,CAAEiB,GAAG,GAAIC;QAAM,CAAE,CAAC,CAACO,KAAK,CAAE,CAAE,CAAC;IACpD;EACD;EAEA,OAAOpB,KAAK;AACb;AAEA,eAAeJ,gBAAgB,CAAEE,aAAc,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/core-data/src/queried-data/index.js"],"names":["default","reducer"],"mappings":"AAAA,cAAc,WAAd;AACA,cAAc,aAAd;AACA,SAASA,OAAO,IAAIC,OAApB,QAAmC,WAAnC","sourcesContent":["export * from './actions';\nexport * from './selectors';\nexport { default as reducer } from './reducer';\n"]}
1
+ {"version":3,"names":["default","reducer"],"sources":["@wordpress/core-data/src/queried-data/index.js"],"sourcesContent":["export * from './actions';\nexport * from './selectors';\nexport { default as reducer } from './reducer';\n"],"mappings":"AAAA,cAAc,WAAW;AACzB,cAAc,aAAa;AAC3B,SAASA,OAAO,IAAIC,OAAO,QAAQ,WAAW"}