@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":[],"sources":["@wordpress/core-data/src/entity-types/settings.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport type {\n\tCommentingStatus,\n\tContext,\n\tOmitNevers,\n\tPingStatus,\n} from './helpers';\n\nimport type { BaseEntityRecords as _BaseEntityRecords } from './base-entity-records';\n\ndeclare module './base-entity-records' {\n\texport namespace BaseEntityRecords {\n\t\t/* eslint-disable-next-line @typescript-eslint/no-unused-vars */\n\t\texport interface Settings< C extends Context > {\n\t\t\t/**\n\t\t\t * What to show on the front page\n\t\t\t */\n\t\t\tshow_on_front: string;\n\t\t\t/**\n\t\t\t * The ID of the page that should be displayed on the front page\n\t\t\t */\n\t\t\tpage_on_front: number;\n\t\t\t/**\n\t\t\t * The ID of the page that should display the latest posts\n\t\t\t */\n\t\t\tpage_for_posts: number;\n\t\t\t/**\n\t\t\t * Site title.\n\t\t\t */\n\t\t\ttitle: string;\n\t\t\t/**\n\t\t\t * Site tagline.\n\t\t\t */\n\t\t\tdescription: string;\n\t\t\t/**\n\t\t\t * Site URL.\n\t\t\t */\n\t\t\turl: string;\n\t\t\t/**\n\t\t\t * This address is used for admin purposes, like new user notification.\n\t\t\t */\n\t\t\temail: string;\n\t\t\t/**\n\t\t\t * A city in the same timezone as you.\n\t\t\t */\n\t\t\ttimezone: string;\n\t\t\t/**\n\t\t\t * A date format for all date strings.\n\t\t\t */\n\t\t\tdate_format: string;\n\t\t\t/**\n\t\t\t * A time format for all time strings.\n\t\t\t */\n\t\t\ttime_format: string;\n\t\t\t/**\n\t\t\t * A day number of the week that the week should start on.\n\t\t\t */\n\t\t\tstart_of_week: number;\n\t\t\t/**\n\t\t\t * WordPress locale code.\n\t\t\t */\n\t\t\tlanguage: string;\n\t\t\t/**\n\t\t\t * Convert emoticons like :-) and :-P to graphics on display.\n\t\t\t */\n\t\t\tuse_smilies: boolean;\n\t\t\t/**\n\t\t\t * Default post category.\n\t\t\t */\n\t\t\tdefault_category: number;\n\t\t\t/**\n\t\t\t * Default post format.\n\t\t\t */\n\t\t\tdefault_post_format: string;\n\t\t\t/**\n\t\t\t * Blog pages show at most.\n\t\t\t */\n\t\t\tposts_per_page: number;\n\t\t\t/**\n\t\t\t * Allow link notifications from other blogs (pingbacks and trackbacks) on new articles.\n\t\t\t */\n\t\t\tdefault_ping_status: PingStatus;\n\t\t\t/**\n\t\t\t * Allow people to submit comments on new posts.\n\t\t\t */\n\t\t\tdefault_comment_status: CommentingStatus;\n\t\t\t/**\n\t\t\t * Site logo.\n\t\t\t */\n\t\t\tsite_logo: number;\n\t\t\t/**\n\t\t\t * Site icon.\n\t\t\t */\n\t\t\tsite_icon: number;\n\t\t}\n\t}\n}\n\nexport type Settings< C extends Context = 'view' > = OmitNevers<\n\t_BaseEntityRecords.Settings< C >\n>;\n"],"mappings":"","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -1,2 +1 @@
1
- export {};
2
- //# sourceMappingURL=sidebar.js.map
1
+ //# sourceMappingURL=sidebar.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":[],"sources":["@wordpress/core-data/src/entity-types/sidebar.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport type { Context, OmitNevers } from './helpers';\n\nimport type { BaseEntityRecords as _BaseEntityRecords } from './base-entity-records';\n\ndeclare module './base-entity-records' {\n\texport namespace BaseEntityRecords {\n\t\texport interface Sidebar< C extends Context > {\n\t\t\t/**\n\t\t\t * ID of sidebar.\n\t\t\t */\n\t\t\tid: string;\n\t\t\t/**\n\t\t\t * Unique name identifying the sidebar.\n\t\t\t */\n\t\t\tname: string;\n\t\t\t/**\n\t\t\t * Description of sidebar.\n\t\t\t */\n\t\t\tdescription: string;\n\t\t\t/**\n\t\t\t * Extra CSS class to assign to the sidebar in the Widgets interface.\n\t\t\t */\n\t\t\tclass: string;\n\t\t\t/**\n\t\t\t * HTML content to prepend to each widget's HTML output when assigned to this sidebar. Default is an opening list item element.\n\t\t\t */\n\t\t\tbefore_widget: string;\n\t\t\t/**\n\t\t\t * HTML content to append to each widget's HTML output when assigned to this sidebar. Default is a closing list item element.\n\t\t\t */\n\t\t\tafter_widget: string;\n\t\t\t/**\n\t\t\t * HTML content to prepend to the sidebar title when displayed. Default is an opening h2 element.\n\t\t\t */\n\t\t\tbefore_title: string;\n\t\t\t/**\n\t\t\t * HTML content to append to the sidebar title when displayed. Default is a closing h2 element.\n\t\t\t */\n\t\t\tafter_title: string;\n\t\t\t/**\n\t\t\t * Status of sidebar.\n\t\t\t */\n\t\t\tstatus: SidebarStatus;\n\t\t\t/**\n\t\t\t * Nested widgets.\n\t\t\t */\n\t\t\twidgets: ( BaseEntityRecords.Widget< C > | string )[];\n\t\t}\n\t}\n}\n\ntype SidebarStatus = 'active' | 'inactive';\n\nexport type Sidebar< C extends Context = 'edit' > = OmitNevers<\n\t_BaseEntityRecords.Sidebar< C >\n>;\n"],"mappings":"","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -1,2 +1 @@
1
- export {};
2
- //# sourceMappingURL=taxonomy.js.map
1
+ //# sourceMappingURL=taxonomy.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":[],"sources":["@wordpress/core-data/src/entity-types/taxonomy.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport type { Context, ContextualField, OmitNevers } from './helpers';\n\nimport type { BaseEntityRecords as _BaseEntityRecords } from './base-entity-records';\n\ndeclare module './base-entity-records' {\n\texport namespace BaseEntityRecords {\n\t\texport interface Taxonomy< C extends Context > {\n\t\t\t/**\n\t\t\t * All capabilities used by the taxonomy.\n\t\t\t */\n\t\t\tcapabilities: ContextualField<\n\t\t\t\tRecord< string, string >,\n\t\t\t\t'edit',\n\t\t\t\tC\n\t\t\t>;\n\t\t\t/**\n\t\t\t * A human-readable description of the taxonomy.\n\t\t\t */\n\t\t\tdescription: ContextualField< string, 'view' | 'edit', C >;\n\t\t\t/**\n\t\t\t * Whether or not the taxonomy should have children.\n\t\t\t */\n\t\t\thierarchical: ContextualField< boolean, 'view' | 'edit', C >;\n\t\t\t/**\n\t\t\t * Human-readable labels for the taxonomy for various contexts.\n\t\t\t */\n\t\t\tlabels: ContextualField< Record< string, string >, 'edit', C >;\n\t\t\t/**\n\t\t\t * The title for the taxonomy.\n\t\t\t */\n\t\t\tname: string;\n\t\t\t/**\n\t\t\t * An alphanumeric identifier for the taxonomy.\n\t\t\t */\n\t\t\tslug: string;\n\t\t\t/**\n\t\t\t * Whether or not the term cloud should be displayed.\n\t\t\t */\n\t\t\tshow_cloud: ContextualField< boolean, 'edit', C >;\n\t\t\t/**\n\t\t\t * Types associated with the taxonomy.\n\t\t\t */\n\t\t\ttypes: ContextualField< string[], 'view' | 'edit', C >;\n\t\t\t/**\n\t\t\t * REST base route for the taxonomy.\n\t\t\t */\n\t\t\trest_base: string;\n\t\t\t/**\n\t\t\t * REST namespace route for the taxonomy.\n\t\t\t */\n\t\t\trest_namespace: string;\n\t\t\t/**\n\t\t\t * The visibility settings for the taxonomy.\n\t\t\t */\n\t\t\tvisibility: TaxonomyVisibility;\n\t\t}\n\n\t\texport interface TaxonomyVisibility {\n\t\t\t/**\n\t\t\t * Whether a taxonomy is intended for use publicly either via the admin interface or by front-end users.\n\t\t\t */\n\t\t\tpublic: boolean;\n\t\t\t/**\n\t\t\t * Whether the taxonomy is publicly queryable.\n\t\t\t */\n\t\t\tpublicly_queryable: boolean;\n\t\t\t/**\n\t\t\t * Whether to generate a default UI for managing this taxonomy.\n\t\t\t */\n\t\t\tshow_ui: boolean;\n\t\t\t/**\n\t\t\t * Whether to allow automatic creation of taxonomy columns on associated post-types table.\n\t\t\t */\n\t\t\tshow_admin_column: boolean;\n\t\t\t/**\n\t\t\t * Whether to make the taxonomy available for selection in navigation menus.\n\t\t\t */\n\t\t\tshow_in_nav_menus: boolean;\n\t\t\t/**\n\t\t\t * Whether to show the taxonomy in the quick/bulk edit panel.\n\t\t\t */\n\t\t\tshow_in_quick_edit: boolean;\n\t\t}\n\t}\n}\n\nexport type Taxonomy< C extends Context = 'edit' > = OmitNevers<\n\t_BaseEntityRecords.Taxonomy< C >\n>;\n"],"mappings":"","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -1,2 +1 @@
1
- export {};
2
- //# sourceMappingURL=term.js.map
1
+ //# sourceMappingURL=term.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":[],"sources":["@wordpress/core-data/src/entity-types/term.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport type { Context, ContextualField, OmitNevers } from './helpers';\n\nimport type { BaseEntityRecords as _BaseEntityRecords } from './base-entity-records';\n\ndeclare module './base-entity-records' {\n\texport namespace BaseEntityRecords {\n\t\texport interface Term< C extends Context > {\n\t\t\t/**\n\t\t\t * Unique identifier for the term.\n\t\t\t */\n\t\t\tid: number;\n\t\t\t/**\n\t\t\t * Number of published posts for the term.\n\t\t\t */\n\t\t\tcount: ContextualField< number, 'view' | 'edit', C >;\n\t\t\t/**\n\t\t\t * HTML description of the term.\n\t\t\t */\n\t\t\tdescription: ContextualField< string, 'view' | 'edit', C >;\n\t\t\t/**\n\t\t\t * URL of the term.\n\t\t\t */\n\t\t\tlink: string;\n\t\t\t/**\n\t\t\t * HTML title for the term.\n\t\t\t */\n\t\t\tname: string;\n\t\t\t/**\n\t\t\t * An alphanumeric identifier for the term unique to its type.\n\t\t\t */\n\t\t\tslug: string;\n\t\t\t/**\n\t\t\t * Type attribution for the term.\n\t\t\t */\n\t\t\ttaxonomy: string;\n\t\t\t/**\n\t\t\t * The parent term ID. Only present for hierarchical taxonomies.\n\t\t\t */\n\t\t\tparent?: number;\n\t\t\t/**\n\t\t\t * Meta fields.\n\t\t\t */\n\t\t\tmeta: ContextualField<\n\t\t\t\tRecord< string, unknown >,\n\t\t\t\t'view' | 'edit',\n\t\t\t\tC\n\t\t\t>;\n\t\t}\n\t}\n}\n\nexport type Term< C extends Context = 'edit' > = OmitNevers<\n\t_BaseEntityRecords.Term< C >\n>;\n"],"mappings":"","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -1,2 +1 @@
1
- export {};
2
- //# sourceMappingURL=theme.js.map
1
+ //# sourceMappingURL=theme.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":[],"sources":["@wordpress/core-data/src/entity-types/theme.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport type { Context, PostFormat, RenderedText, OmitNevers } from './helpers';\n\nimport type { BaseEntityRecords as _BaseEntityRecords } from './base-entity-records';\n\ndeclare module './base-entity-records' {\n\texport namespace BaseEntityRecords {\n\t\t/* eslint-disable-next-line @typescript-eslint/no-unused-vars */\n\t\texport interface Theme< C extends Context > {\n\t\t\t/**\n\t\t\t * The theme's stylesheet. This uniquely identifies the theme.\n\t\t\t */\n\t\t\tstylesheet: string;\n\t\t\t/**\n\t\t\t * The theme's template. If this is a child theme, this refers to the parent theme, otherwise this is the same as the theme's stylesheet.\n\t\t\t */\n\t\t\ttemplate: string;\n\t\t\t/**\n\t\t\t * The theme author.\n\t\t\t */\n\t\t\tauthor: RenderedText< 'edit' >;\n\t\t\t/**\n\t\t\t * The website of the theme author.\n\t\t\t */\n\t\t\tauthor_uri: RenderedText< 'edit' >;\n\t\t\t/**\n\t\t\t * A description of the theme.\n\t\t\t */\n\t\t\tdescription: RenderedText< 'edit' >;\n\t\t\t/**\n\t\t\t * The name of the theme.\n\t\t\t */\n\t\t\tname: RenderedText< 'edit' >;\n\t\t\t/**\n\t\t\t * The minimum PHP version required for the theme to work.\n\t\t\t */\n\t\t\trequires_php: string;\n\t\t\t/**\n\t\t\t * The minimum WordPress version required for the theme to work.\n\t\t\t */\n\t\t\trequires_wp: string;\n\t\t\t/**\n\t\t\t * The theme's screenshot URL.\n\t\t\t */\n\t\t\tscreenshot: string;\n\t\t\t/**\n\t\t\t * Tags indicating styles and features of the theme.\n\t\t\t */\n\t\t\ttags: RenderedText< 'edit' >;\n\t\t\t/**\n\t\t\t * The theme's text domain.\n\t\t\t */\n\t\t\ttextdomain: string;\n\t\t\t/**\n\t\t\t * Features supported by this theme.\n\t\t\t */\n\t\t\ttheme_supports: ThemeSupports;\n\t\t\t/**\n\t\t\t * The URI of the theme's webpage.\n\t\t\t */\n\t\t\ttheme_uri: RenderedText< 'edit' >;\n\t\t\t/**\n\t\t\t * The theme's current version.\n\t\t\t */\n\t\t\tversion: string;\n\t\t\t/**\n\t\t\t * A named status for the theme.\n\t\t\t */\n\t\t\tstatus: ThemeStatus;\n\t\t}\n\n\t\texport type ThemeStatus = 'active' | 'inactive';\n\n\t\texport interface ThemeSupports {\n\t\t\t/**\n\t\t\t * Whether theme opts in to wide alignment CSS class.\n\t\t\t */\n\t\t\t'align-wide': boolean;\n\t\t\t/**\n\t\t\t * Whether appearanceTools are enabled in Global Styles.\n\t\t\t */\n\t\t\t'appearance-tools': boolean;\n\t\t\t/**\n\t\t\t * Whether posts and comments RSS feed links are added to head.\n\t\t\t */\n\t\t\t'automatic-feed-links': boolean;\n\t\t\t/**\n\t\t\t * Whether border settings are enabled.\n\t\t\t */\n\t\t\tborder: boolean;\n\t\t\t/**\n\t\t\t * Custom background if defined by the theme.\n\t\t\t */\n\t\t\t'custom-background': boolean | CustomBackground;\n\t\t\t/**\n\t\t\t * Custom header if defined by the theme.\n\t\t\t */\n\t\t\t'custom-header': boolean | CustomHeader;\n\t\t\t/**\n\t\t\t * Custom logo if defined by the theme.\n\t\t\t */\n\t\t\t'custom-logo': boolean | CustomLogo;\n\t\t\t/**\n\t\t\t * Whether the theme enables Selective Refresh for Widgets being managed with the Customizer.\n\t\t\t */\n\t\t\t'customize-selective-refresh-widgets': boolean;\n\t\t\t/**\n\t\t\t * Whether theme opts in to the dark editor style UI.\n\t\t\t */\n\t\t\t'dark-editor-style': boolean;\n\t\t\t/**\n\t\t\t * Whether the theme disables custom colors.\n\t\t\t */\n\t\t\t'disable-custom-colors': boolean;\n\t\t\t/**\n\t\t\t * Whether the theme disables custom font sizes.\n\t\t\t */\n\t\t\t'disable-custom-font-sizes': boolean;\n\t\t\t/**\n\t\t\t * Whether the theme disables custom gradients.\n\t\t\t */\n\t\t\t'disable-custom-gradients': boolean;\n\t\t\t/**\n\t\t\t * Custom color palette if defined by the theme.\n\t\t\t */\n\t\t\t'editor-color-palette': boolean | Color[];\n\t\t\t/**\n\t\t\t * Custom font sizes if defined by the theme.\n\t\t\t */\n\t\t\t'editor-font-sizes': boolean | FontSize[];\n\t\t\t/**\n\t\t\t * Custom spacing sizes if defined by the theme.\n\t\t\t */\n\t\t\t'editor-spacing-sizes': boolean | SpacingSize[];\n\t\t\t/**\n\t\t\t * Custom gradient presets if defined by the theme.\n\t\t\t */\n\t\t\t'editor-gradient-presets': boolean | GradientPreset[];\n\t\t\t/**\n\t\t\t * Whether theme opts in to the editor styles CSS wrapper.\n\t\t\t */\n\t\t\t'editor-styles': boolean;\n\t\t\t/**\n\t\t\t * Allows use of HTML5 markup for search forms, comment forms, comment lists, gallery, and caption.\n\t\t\t */\n\t\t\thtml5: boolean | Html5Option[];\n\t\t\t/**\n\t\t\t * Post formats supported.\n\t\t\t */\n\t\t\tformats: PostFormat[];\n\t\t\t/**\n\t\t\t * Whether link colors are enabled.\n\t\t\t */\n\t\t\t'link-color': boolean;\n\t\t\t/**\n\t\t\t * The post types that support thumbnails or true if all post types are supported.\n\t\t\t */\n\t\t\t'post-thumbnails': boolean | string[];\n\t\t\t/**\n\t\t\t * Whether the theme supports responsive embedded content.\n\t\t\t */\n\t\t\t'responsive-embeds': boolean;\n\t\t\t/**\n\t\t\t * Whether the theme can manage the document title tag.\n\t\t\t */\n\t\t\t'title-tag': boolean;\n\t\t\t/**\n\t\t\t * Whether theme opts in to default WordPress block styles for viewing.\n\t\t\t */\n\t\t\t'wp-block-styles': boolean;\n\t\t}\n\n\t\texport interface CustomBackground {\n\t\t\t'default-image': string;\n\t\t\t'default-preset': 'default' | 'fill' | 'fit' | 'repeat' | 'custom';\n\t\t\t'default-position-x': 'left' | 'center' | 'right';\n\t\t\t'default-position-y': 'left' | 'center' | 'right';\n\t\t\t'default-size': 'auto' | 'contain' | 'cover';\n\t\t\t'default-repeat': 'repeat-x' | 'repeat-y' | 'repeat' | 'no-repeat';\n\t\t\t'default-attachment': 'scroll' | 'fixed';\n\t\t\t'default-color': string;\n\t\t}\n\n\t\texport interface CustomHeader {\n\t\t\t'default-image': string;\n\t\t\t'random-default': boolean;\n\t\t\twidth: number;\n\t\t\theight: number;\n\t\t\t'flex-height': boolean;\n\t\t\t'flex-width': boolean;\n\t\t\t'default-text-color': string;\n\t\t\t'header-text': boolean;\n\t\t\tuploads: boolean;\n\t\t\tvideo: boolean;\n\t\t}\n\n\t\texport interface CustomLogo {\n\t\t\twidth: number;\n\t\t\theight: number;\n\t\t\t'flex-width': boolean;\n\t\t\t'flex-height': boolean;\n\t\t\t'header-text': string[];\n\t\t\t'unlink-homepage-logo': boolean;\n\t\t}\n\n\t\texport interface Color {\n\t\t\tname: string;\n\t\t\tslug: string;\n\t\t\tcolor: string;\n\t\t}\n\n\t\texport interface FontSize {\n\t\t\tname: string;\n\t\t\tsize: number;\n\t\t\tslug: string;\n\t\t}\n\n\t\texport interface SpacingSize {\n\t\t\tname: string;\n\t\t\tsize: number;\n\t\t\tslug: string;\n\t\t}\n\n\t\texport interface GradientPreset {\n\t\t\tname: string;\n\t\t\tgradient: string;\n\t\t\tslug: string;\n\t\t}\n\n\t\texport type Html5Option =\n\t\t\t| 'search-form'\n\t\t\t| 'comment-form'\n\t\t\t| 'comment-list'\n\t\t\t| 'gallery'\n\t\t\t| 'caption'\n\t\t\t| 'script'\n\t\t\t| 'style';\n\t}\n}\n\nexport type Theme< C extends Context = 'edit' > = OmitNevers<\n\t_BaseEntityRecords.Theme< C >\n>;\n"],"mappings":"","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -1,2 +1 @@
1
- export {};
2
- //# sourceMappingURL=type.js.map
1
+ //# sourceMappingURL=type.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":[],"sources":["@wordpress/core-data/src/entity-types/type.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport type { Context, ContextualField, OmitNevers } from './helpers';\n\nimport type { BaseEntityRecords as _BaseEntityRecords } from './base-entity-records';\n\ndeclare module './base-entity-records' {\n\texport namespace BaseEntityRecords {\n\t\texport interface Type< C extends Context > {\n\t\t\t/**\n\t\t\t * All capabilities used by the post type.\n\t\t\t */\n\t\t\tcapabilities: ContextualField<\n\t\t\t\tRecord< string, string >,\n\t\t\t\t'edit',\n\t\t\t\tC\n\t\t\t>;\n\t\t\t/**\n\t\t\t * A human-readable description of the post type.\n\t\t\t */\n\t\t\tdescription: ContextualField< string, 'view' | 'edit', C >;\n\t\t\t/**\n\t\t\t * Whether or not the post type should have children.\n\t\t\t */\n\t\t\thierarchical: ContextualField< boolean, 'view' | 'edit', C >;\n\t\t\t/**\n\t\t\t * Whether or not the post type can be viewed.\n\t\t\t */\n\t\t\tviewable: ContextualField< boolean, 'edit', C >;\n\t\t\t/**\n\t\t\t * Human-readable labels for the post type for various contexts.\n\t\t\t */\n\t\t\tlabels: ContextualField< Record< string, string >, 'edit', C >;\n\t\t\t/**\n\t\t\t * The title for the post type.\n\t\t\t */\n\t\t\tname: string;\n\t\t\t/**\n\t\t\t * An alphanumeric identifier for the post type.\n\t\t\t */\n\t\t\tslug: string;\n\t\t\t/**\n\t\t\t * All features, supported by the post type.\n\t\t\t */\n\t\t\tsupports: ContextualField< Record< string, string >, 'edit', C >;\n\t\t\t/**\n\t\t\t * Taxonomies associated with post type.\n\t\t\t */\n\t\t\ttaxonomies: ContextualField< string[], 'view' | 'edit', C >;\n\t\t\t/**\n\t\t\t * REST base route for the post type.\n\t\t\t */\n\t\t\trest_base: string;\n\t\t\t/**\n\t\t\t * REST route's namespace for the post type.\n\t\t\t */\n\t\t\trest_namespace: string;\n\t\t\t/**\n\t\t\t * The visibility settings for the post type.\n\t\t\t */\n\t\t\tvisibility: ContextualField< TypeVisibility, 'edit', C >;\n\t\t}\n\n\t\tinterface TypeVisibility {\n\t\t\t/**\n\t\t\t * Whether to generate a default UI for managing this post type.\n\t\t\t */\n\t\t\tshow_ui: boolean;\n\t\t\t/**\n\t\t\t * Whether to make the post type is available for selection in navigation menus.\n\t\t\t */\n\t\t\tshow_in_nav_menus: boolean;\n\t\t}\n\t}\n}\n\nexport type Type< C extends Context = 'edit' > = OmitNevers<\n\t_BaseEntityRecords.Type< C >\n>;\n"],"mappings":"","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -1,2 +1 @@
1
- export {};
2
- //# sourceMappingURL=user.js.map
1
+ //# sourceMappingURL=user.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":[],"sources":["@wordpress/core-data/src/entity-types/user.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport type {\n\tAvatarUrls,\n\tContext,\n\tContextualField,\n\tOmitNevers,\n} from './helpers';\n\nimport type { BaseEntityRecords as _BaseEntityRecords } from './base-entity-records';\n\ndeclare module './base-entity-records' {\n\texport namespace BaseEntityRecords {\n\t\texport interface User< C extends Context > {\n\t\t\t/**\n\t\t\t * Unique identifier for the user.\n\t\t\t */\n\t\t\tid: number;\n\t\t\t/**\n\t\t\t * Login name for the user.\n\t\t\t */\n\t\t\tusername: ContextualField< string, 'edit', C >;\n\t\t\t/**\n\t\t\t * Display name for the user.\n\t\t\t */\n\t\t\tname: string;\n\t\t\t/**\n\t\t\t * First name for the user.\n\t\t\t */\n\t\t\tfirst_name: ContextualField< string, 'edit', C >;\n\t\t\t/**\n\t\t\t * Last name for the user.\n\t\t\t */\n\t\t\tlast_name: ContextualField< string, 'edit', C >;\n\t\t\t/**\n\t\t\t * The email address for the user.\n\t\t\t */\n\t\t\temail: ContextualField< string, 'edit', C >;\n\t\t\t/**\n\t\t\t * URL of the user.\n\t\t\t */\n\t\t\turl: string;\n\t\t\t/**\n\t\t\t * Description of the user.\n\t\t\t */\n\t\t\tdescription: string;\n\t\t\t/**\n\t\t\t * Author URL of the user.\n\t\t\t */\n\t\t\tlink: string;\n\t\t\t/**\n\t\t\t * Locale for the user.\n\t\t\t */\n\t\t\tlocale: ContextualField< string, 'edit', C >;\n\t\t\t/**\n\t\t\t * The nickname for the user.\n\t\t\t */\n\t\t\tnickname: ContextualField< string, 'edit', C >;\n\t\t\t/**\n\t\t\t * An alphanumeric identifier for the user.\n\t\t\t */\n\t\t\tslug: string;\n\t\t\t/**\n\t\t\t * Registration date for the user.\n\t\t\t */\n\t\t\tregistered_date: ContextualField< string, 'edit', C >;\n\t\t\t/**\n\t\t\t * Roles assigned to the user.\n\t\t\t */\n\t\t\troles: ContextualField< string[], 'edit', C >;\n\t\t\t/**\n\t\t\t * Password for the user.\n\t\t\t *\n\t\t\t * This is never sent from the server to the client\n\t\t\t * but exists because we might send an update to the\n\t\t\t * server with a new password to set.\n\t\t\t */\n\t\t\tpassword?: string;\n\t\t\t/**\n\t\t\t * All capabilities assigned to the user.\n\t\t\t */\n\t\t\tcapabilities: ContextualField<\n\t\t\t\tRecord< string, boolean >,\n\t\t\t\t'edit',\n\t\t\t\tC\n\t\t\t>;\n\t\t\t/**\n\t\t\t * Any extra capabilities assigned to the user.\n\t\t\t */\n\t\t\textra_capabilities: ContextualField<\n\t\t\t\tRecord< string, boolean >,\n\t\t\t\t'edit',\n\t\t\t\tC\n\t\t\t>;\n\t\t\t/**\n\t\t\t * Avatar URLs for the user.\n\t\t\t */\n\t\t\tavatar_urls: AvatarUrls;\n\t\t\t/**\n\t\t\t * Meta fields.\n\t\t\t */\n\t\t\tmeta: ContextualField<\n\t\t\t\tRecord< string, unknown >,\n\t\t\t\t'view' | 'edit',\n\t\t\t\tC\n\t\t\t>;\n\t\t}\n\t}\n}\n\nexport type User< C extends Context = 'edit' > = OmitNevers<\n\t_BaseEntityRecords.User< C >\n>;\n"],"mappings":"","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -1,2 +1 @@
1
- export {};
2
- //# sourceMappingURL=widget-type.js.map
1
+ //# sourceMappingURL=widget-type.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":[],"sources":["@wordpress/core-data/src/entity-types/widget-type.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport type { Context, OmitNevers } from './helpers';\n\nimport type { BaseEntityRecords as _BaseEntityRecords } from './base-entity-records';\n\ndeclare module './base-entity-records' {\n\texport namespace BaseEntityRecords {\n\t\t/* eslint-disable-next-line @typescript-eslint/no-unused-vars */\n\t\texport interface WidgetType< C extends Context > {\n\t\t\t/**\n\t\t\t * Unique slug identifying the widget type.\n\t\t\t */\n\t\t\tid: string;\n\t\t\t/**\n\t\t\t * Human-readable name identifying the widget type.\n\t\t\t */\n\t\t\tname: string;\n\t\t\t/**\n\t\t\t * Description of the widget.\n\t\t\t */\n\t\t\tdescription: string;\n\t\t\t/**\n\t\t\t * Whether the widget supports multiple instances\n\t\t\t */\n\t\t\tis_multi: boolean;\n\t\t\t/**\n\t\t\t * Class name\n\t\t\t */\n\t\t\tclassname: string;\n\t\t}\n\t}\n}\n\nexport type WidgetType< C extends Context = 'edit' > = OmitNevers<\n\t_BaseEntityRecords.WidgetType< C >\n>;\n"],"mappings":"","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -1,2 +1 @@
1
- export {};
2
- //# sourceMappingURL=widget.js.map
1
+ //# sourceMappingURL=widget.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":[],"sources":["@wordpress/core-data/src/entity-types/widget.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport type { Context, ContextualField, OmitNevers } from './helpers';\n\nimport type { BaseEntityRecords as _BaseEntityRecords } from './base-entity-records';\n\ndeclare module './base-entity-records' {\n\texport namespace BaseEntityRecords {\n\t\texport interface Widget< C extends Context > {\n\t\t\t/**\n\t\t\t * Unique identifier for the widget.\n\t\t\t */\n\t\t\tid: string;\n\t\t\t/**\n\t\t\t * The type of the widget. Corresponds to ID in widget-types endpoint.\n\t\t\t */\n\t\t\tid_base: string;\n\t\t\t/**\n\t\t\t * The sidebar the widget belongs to.\n\t\t\t */\n\t\t\tsidebar: string;\n\t\t\t/**\n\t\t\t * HTML representation of the widget.\n\t\t\t */\n\t\t\trendered: string;\n\t\t\t/**\n\t\t\t * HTML representation of the widget admin form.\n\t\t\t */\n\t\t\trendered_form: ContextualField< string, 'edit', C >;\n\t\t\t/**\n\t\t\t * Instance settings of the widget, if supported.\n\t\t\t */\n\t\t\tinstance: ContextualField< WidgetInstance, 'edit', C >;\n\t\t\t/**\n\t\t\t * URL-encoded form data from the widget admin form. Used\n\t\t\t * to update a widget that does not support instance.\n\t\t\t *\n\t\t\t * This is never sent from the server to the client but exists\n\t\t\t * because we might send an update.\n\t\t\t */\n\t\t\tform_data?: string;\n\t\t}\n\n\t\tinterface WidgetInstance {\n\t\t\t/**\n\t\t\t * Base64 encoded representation of the instance settings.\n\t\t\t */\n\t\t\tencoded: string;\n\t\t\t/**\n\t\t\t * Cryptographic hash of the instance settings.\n\t\t\t */\n\t\t\thash: string;\n\t\t\t/**\n\t\t\t * Unencoded instance settings, if supported.\n\t\t\t */\n\t\t\traw: Record< string, string >;\n\t\t}\n\t}\n}\n\nexport type Widget< C extends Context = 'edit' > = OmitNevers<\n\t_BaseEntityRecords.Widget< C >\n>;\n"],"mappings":"","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -1,2 +1 @@
1
- export {};
2
- //# sourceMappingURL=wp-template-part.js.map
1
+ //# sourceMappingURL=wp-template-part.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":[],"sources":["@wordpress/core-data/src/entity-types/wp-template-part.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport type {\n\tContext,\n\tPostStatus,\n\tRenderedText,\n\tOmitNevers,\n\tContextualField,\n} from './helpers';\n\nimport type { BaseEntityRecords as _BaseEntityRecords } from './base-entity-records';\n\ndeclare module './base-entity-records' {\n\texport namespace BaseEntityRecords {\n\t\texport interface WpTemplatePart< C extends Context > {\n\t\t\t/**\n\t\t\t * ID of template.\n\t\t\t */\n\t\t\tid: string;\n\t\t\t/**\n\t\t\t * Unique slug identifying the template.\n\t\t\t */\n\t\t\tslug: string;\n\t\t\t/**\n\t\t\t * Theme identifier for the template.\n\t\t\t */\n\t\t\ttheme: string;\n\t\t\t/**\n\t\t\t * Type of template.\n\t\t\t */\n\t\t\ttype: string;\n\t\t\t/**\n\t\t\t * Source of template\n\t\t\t */\n\t\t\tsource: string;\n\t\t\t/**\n\t\t\t * Source of a customized template\n\t\t\t */\n\t\t\torigin: string;\n\t\t\t/**\n\t\t\t * Content of template.\n\t\t\t *\n\t\t\t * This field never has a `rendered` property when reading but still uses\n\t\t\t * the RenderedText type so it can be set as a string when sending updates to\n\t\t\t * the server.\n\t\t\t *\n\t\t\t * TODO: Figure out how to mesh this with `RenderedText<C>`\n\t\t\t */\n\t\t\tcontent: ContextualField<\n\t\t\t\tRenderedText< C > & {\n\t\t\t\t\t/**\n\t\t\t\t\t * Version of the content block format used by the template.\n\t\t\t\t\t */\n\t\t\t\t\tblock_version: ContextualField< number, 'edit', C >;\n\t\t\t\t},\n\t\t\t\t'view' | 'edit',\n\t\t\t\tC\n\t\t\t>;\n\t\t\t/**\n\t\t\t * Title of template.\n\t\t\t */\n\t\t\ttitle: RenderedText< 'edit' >;\n\t\t\t/**\n\t\t\t * Description of template.\n\t\t\t */\n\t\t\tdescription: string;\n\t\t\t/**\n\t\t\t * Status of template.\n\t\t\t */\n\t\t\tstatus: PostStatus;\n\t\t\t/**\n\t\t\t * Post ID.\n\t\t\t */\n\t\t\twp_id: number;\n\t\t\t/**\n\t\t\t * Theme file exists.\n\t\t\t */\n\t\t\thas_theme_file: Record< string, string >;\n\t\t\t/**\n\t\t\t * The ID for the author of the template.\n\t\t\t */\n\t\t\tauthor: number;\n\t\t\t/**\n\t\t\t * Where the template part is intended for use (header, footer, etc.)\n\t\t\t */\n\t\t\tarea: string;\n\t\t}\n\t}\n}\n\nexport type WpTemplatePart< C extends Context = 'edit' > = OmitNevers<\n\t_BaseEntityRecords.WpTemplatePart< C >\n>;\n"],"mappings":"","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -1,2 +1 @@
1
- export {};
2
- //# sourceMappingURL=wp-template.js.map
1
+ //# sourceMappingURL=wp-template.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":[],"sources":["@wordpress/core-data/src/entity-types/wp-template.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport type {\n\tContext,\n\tPostStatus,\n\tRenderedText,\n\tOmitNevers,\n\tContextualField,\n} from './helpers';\n\nimport type { BaseEntityRecords as _BaseEntityRecords } from './base-entity-records';\n\ndeclare module './base-entity-records' {\n\texport namespace BaseEntityRecords {\n\t\texport interface WpTemplate< C extends Context > {\n\t\t\t/**\n\t\t\t * ID of template.\n\t\t\t */\n\t\t\tid: string;\n\t\t\t/**\n\t\t\t * Unique slug identifying the template.\n\t\t\t */\n\t\t\tslug: string;\n\t\t\t/**\n\t\t\t * Theme identifier for the template.\n\t\t\t */\n\t\t\ttheme: string;\n\t\t\t/**\n\t\t\t * Type of template.\n\t\t\t */\n\t\t\ttype: string;\n\t\t\t/**\n\t\t\t * Source of template\n\t\t\t */\n\t\t\tsource: string;\n\t\t\t/**\n\t\t\t * Source of a customized template\n\t\t\t */\n\t\t\torigin: string;\n\t\t\t/**\n\t\t\t * Content of template.\n\t\t\t *\n\t\t\t * This field never has a `rendered` property when reading but still uses\n\t\t\t * the RenderedText type so it can be set as a string when sending updates to\n\t\t\t * the server.\n\t\t\t *\n\t\t\t * TODO: Figure out how to mesh this with `RenderedText<C>`\n\t\t\t */\n\t\t\tcontent: ContextualField<\n\t\t\t\tRenderedText< C > & {\n\t\t\t\t\t/**\n\t\t\t\t\t * Version of the content block format used by the template.\n\t\t\t\t\t */\n\t\t\t\t\tblock_version: ContextualField< number, 'edit', C >;\n\t\t\t\t},\n\t\t\t\t'view' | 'edit',\n\t\t\t\tC\n\t\t\t>;\n\t\t\t/**\n\t\t\t * Title of template.\n\t\t\t */\n\t\t\ttitle: RenderedText< 'edit' >;\n\t\t\t/**\n\t\t\t * Description of template.\n\t\t\t */\n\t\t\tdescription: string;\n\t\t\t/**\n\t\t\t * Status of template.\n\t\t\t */\n\t\t\tstatus: PostStatus;\n\t\t\t/**\n\t\t\t * Post ID.\n\t\t\t */\n\t\t\twp_id: number;\n\t\t\t/**\n\t\t\t * Plugin that registered the template.\n\t\t\t */\n\t\t\tplugin?: string;\n\t\t\t/**\n\t\t\t * Theme file exists.\n\t\t\t */\n\t\t\thas_theme_file: Record< string, string >;\n\t\t\t/**\n\t\t\t * The ID for the author of the template.\n\t\t\t */\n\t\t\tauthor: number;\n\t\t\t/**\n\t\t\t * Whether a template is a custom template.\n\t\t\t */\n\t\t\tis_custom: Record< string, string >;\n\t\t\t/**\n\t\t\t * The date the template was last modified, in the site's timezone.\n\t\t\t */\n\t\t\tmodified: ContextualField< string, 'view' | 'edit', C >;\n\t\t}\n\t}\n}\n\nexport type WpTemplate< C extends Context = 'edit' > = OmitNevers<\n\t_BaseEntityRecords.WpTemplate< C >\n>;\n"],"mappings":"","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -1,35 +1,8 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import apiFetch from '@wordpress/api-fetch';
5
- import { addQueryArgs } from '@wordpress/url';
6
- import { decodeEntities } from '@wordpress/html-entities';
7
- import { __ } from '@wordpress/i18n';
8
- /**
9
- * Fetches link suggestions from the WordPress API.
10
- *
11
- * WordPress does not support searching multiple tables at once, e.g. posts and terms, so we
12
- * perform multiple queries at the same time and then merge the results together.
13
- *
14
- * @param search
15
- * @param searchOptions
16
- * @param editorSettings
17
- *
18
- * @example
19
- * ```js
20
- * import { __experimentalFetchLinkSuggestions as fetchLinkSuggestions } from '@wordpress/core-data';
21
- *
22
- * //...
23
- *
24
- * export function initialize( id, settings ) {
25
- *
26
- * settings.__experimentalFetchLinkSuggestions = (
27
- * search,
28
- * searchOptions
29
- * ) => fetchLinkSuggestions( search, searchOptions, settings );
30
- * ```
31
- */
32
- export default async function fetchLinkSuggestions(search, searchOptions = {}, editorSettings = {}) {
1
+ import apiFetch from "@wordpress/api-fetch";
2
+ import { addQueryArgs } from "@wordpress/url";
3
+ import { decodeEntities } from "@wordpress/html-entities";
4
+ import { __ } from "@wordpress/i18n";
5
+ async function fetchLinkSuggestions(search, searchOptions = {}, editorSettings = {}) {
33
6
  const searchOptionsToUse = searchOptions.isInitialSuggestions && searchOptions.initialSuggestionsSearchOptions ? {
34
7
  ...searchOptions,
35
8
  ...searchOptions.initialSuggestionsSearchOptions
@@ -40,131 +13,125 @@ export default async function fetchLinkSuggestions(search, searchOptions = {}, e
40
13
  page,
41
14
  perPage = searchOptions.isInitialSuggestions ? 3 : 20
42
15
  } = searchOptionsToUse;
43
- const {
44
- disablePostFormats = false
45
- } = editorSettings;
16
+ const { disablePostFormats = false } = editorSettings;
46
17
  const queries = [];
47
- if (!type || type === 'post') {
48
- queries.push(apiFetch({
49
- path: addQueryArgs('/wp/v2/search', {
50
- search,
51
- page,
52
- per_page: perPage,
53
- type: 'post',
54
- subtype
55
- })
56
- }).then(results => {
57
- return results.map(result => {
58
- return {
59
- id: result.id,
60
- url: result.url,
61
- title: decodeEntities(result.title || '') || __('(no title)'),
62
- type: result.subtype || result.type,
63
- kind: 'post-type'
64
- };
65
- });
66
- }).catch(() => []) // Fail by returning no results.
18
+ if (!type || type === "post") {
19
+ queries.push(
20
+ apiFetch({
21
+ path: addQueryArgs("/wp/v2/search", {
22
+ search,
23
+ page,
24
+ per_page: perPage,
25
+ type: "post",
26
+ subtype
27
+ })
28
+ }).then((results2) => {
29
+ return results2.map((result) => {
30
+ return {
31
+ id: result.id,
32
+ url: result.url,
33
+ title: decodeEntities(result.title || "") || __("(no title)"),
34
+ type: result.subtype || result.type,
35
+ kind: "post-type"
36
+ };
37
+ });
38
+ }).catch(() => [])
39
+ // Fail by returning no results.
67
40
  );
68
41
  }
69
- if (!type || type === 'term') {
70
- queries.push(apiFetch({
71
- path: addQueryArgs('/wp/v2/search', {
72
- search,
73
- page,
74
- per_page: perPage,
75
- type: 'term',
76
- subtype
77
- })
78
- }).then(results => {
79
- return results.map(result => {
80
- return {
81
- id: result.id,
82
- url: result.url,
83
- title: decodeEntities(result.title || '') || __('(no title)'),
84
- type: result.subtype || result.type,
85
- kind: 'taxonomy'
86
- };
87
- });
88
- }).catch(() => []) // Fail by returning no results.
42
+ if (!type || type === "term") {
43
+ queries.push(
44
+ apiFetch({
45
+ path: addQueryArgs("/wp/v2/search", {
46
+ search,
47
+ page,
48
+ per_page: perPage,
49
+ type: "term",
50
+ subtype
51
+ })
52
+ }).then((results2) => {
53
+ return results2.map((result) => {
54
+ return {
55
+ id: result.id,
56
+ url: result.url,
57
+ title: decodeEntities(result.title || "") || __("(no title)"),
58
+ type: result.subtype || result.type,
59
+ kind: "taxonomy"
60
+ };
61
+ });
62
+ }).catch(() => [])
63
+ // Fail by returning no results.
89
64
  );
90
65
  }
91
- if (!disablePostFormats && (!type || type === 'post-format')) {
92
- queries.push(apiFetch({
93
- path: addQueryArgs('/wp/v2/search', {
94
- search,
95
- page,
96
- per_page: perPage,
97
- type: 'post-format',
98
- subtype
99
- })
100
- }).then(results => {
101
- return results.map(result => {
102
- return {
103
- id: result.id,
104
- url: result.url,
105
- title: decodeEntities(result.title || '') || __('(no title)'),
106
- type: result.subtype || result.type,
107
- kind: 'taxonomy'
108
- };
109
- });
110
- }).catch(() => []) // Fail by returning no results.
66
+ if (!disablePostFormats && (!type || type === "post-format")) {
67
+ queries.push(
68
+ apiFetch({
69
+ path: addQueryArgs("/wp/v2/search", {
70
+ search,
71
+ page,
72
+ per_page: perPage,
73
+ type: "post-format",
74
+ subtype
75
+ })
76
+ }).then((results2) => {
77
+ return results2.map((result) => {
78
+ return {
79
+ id: result.id,
80
+ url: result.url,
81
+ title: decodeEntities(result.title || "") || __("(no title)"),
82
+ type: result.subtype || result.type,
83
+ kind: "taxonomy"
84
+ };
85
+ });
86
+ }).catch(() => [])
87
+ // Fail by returning no results.
111
88
  );
112
89
  }
113
- if (!type || type === 'attachment') {
114
- queries.push(apiFetch({
115
- path: addQueryArgs('/wp/v2/media', {
116
- search,
117
- page,
118
- per_page: perPage
119
- })
120
- }).then(results => {
121
- return results.map(result => {
122
- return {
123
- id: result.id,
124
- url: result.source_url,
125
- title: decodeEntities(result.title.rendered || '') || __('(no title)'),
126
- type: result.type,
127
- kind: 'media'
128
- };
129
- });
130
- }).catch(() => []) // Fail by returning no results.
90
+ if (!type || type === "attachment") {
91
+ queries.push(
92
+ apiFetch({
93
+ path: addQueryArgs("/wp/v2/media", {
94
+ search,
95
+ page,
96
+ per_page: perPage
97
+ })
98
+ }).then((results2) => {
99
+ return results2.map((result) => {
100
+ return {
101
+ id: result.id,
102
+ url: result.source_url,
103
+ title: decodeEntities(result.title.rendered || "") || __("(no title)"),
104
+ type: result.type,
105
+ kind: "media"
106
+ };
107
+ });
108
+ }).catch(() => [])
109
+ // Fail by returning no results.
131
110
  );
132
111
  }
133
112
  const responses = await Promise.all(queries);
134
113
  let results = responses.flat();
135
- results = results.filter(result => !!result.id);
114
+ results = results.filter((result) => !!result.id);
136
115
  results = sortResults(results, search);
137
116
  results = results.slice(0, perPage);
138
117
  return results;
139
118
  }
140
-
141
- /**
142
- * Sort search results by relevance to the given query.
143
- *
144
- * Sorting is necessary as we're querying multiple endpoints and merging the results. For example
145
- * a taxonomy title might be more relevant than a post title, but by default taxonomy results will
146
- * be ordered after all the (potentially irrelevant) post results.
147
- *
148
- * We sort by scoring each result, where the score is the number of tokens in the title that are
149
- * also in the search query, divided by the total number of tokens in the title. This gives us a
150
- * score between 0 and 1, where 1 is a perfect match.
151
- *
152
- * @param results
153
- * @param search
154
- */
155
- export function sortResults(results, search) {
119
+ function sortResults(results, search) {
156
120
  const searchTokens = tokenize(search);
157
121
  const scores = {};
158
122
  for (const result of results) {
159
123
  if (result.title) {
160
124
  const titleTokens = tokenize(result.title);
161
- const exactMatchingTokens = titleTokens.filter(titleToken => searchTokens.some(searchToken => titleToken === searchToken));
162
- const subMatchingTokens = titleTokens.filter(titleToken => searchTokens.some(searchToken => titleToken !== searchToken && titleToken.includes(searchToken)));
163
-
164
- // The score is a combination of exact matches and sub-matches.
165
- // More weight is given to exact matches, as they are more relevant (e.g. "cat" vs "caterpillar").
166
- // Diving by the total number of tokens in the title normalizes the score and skews
167
- // the results towards shorter titles.
125
+ const exactMatchingTokens = titleTokens.filter(
126
+ (titleToken) => searchTokens.some(
127
+ (searchToken) => titleToken === searchToken
128
+ )
129
+ );
130
+ const subMatchingTokens = titleTokens.filter(
131
+ (titleToken) => searchTokens.some(
132
+ (searchToken) => titleToken !== searchToken && titleToken.includes(searchToken)
133
+ )
134
+ );
168
135
  const exactMatchScore = exactMatchingTokens.length / titleTokens.length * 10;
169
136
  const subMatchScore = subMatchingTokens.length / titleTokens.length;
170
137
  scores[result.id] = exactMatchScore + subMatchScore;
@@ -174,17 +141,12 @@ export function sortResults(results, search) {
174
141
  }
175
142
  return results.sort((a, b) => scores[b.id] - scores[a.id]);
176
143
  }
177
-
178
- /**
179
- * Turns text into an array of tokens, with whitespace and punctuation removed.
180
- *
181
- * For example, `"I'm having a ball."` becomes `[ "im", "having", "a", "ball" ]`.
182
- *
183
- * @param text
184
- */
185
- export function tokenize(text) {
186
- // \p{L} matches any kind of letter from any language.
187
- // \p{N} matches any kind of numeric character.
144
+ function tokenize(text) {
188
145
  return text.toLowerCase().match(/[\p{L}\p{N}]+/gu) || [];
189
146
  }
190
- //# sourceMappingURL=__experimental-fetch-link-suggestions.js.map
147
+ export {
148
+ fetchLinkSuggestions as default,
149
+ sortResults,
150
+ tokenize
151
+ };
152
+ //# sourceMappingURL=__experimental-fetch-link-suggestions.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["apiFetch","addQueryArgs","decodeEntities","__","fetchLinkSuggestions","search","searchOptions","editorSettings","searchOptionsToUse","isInitialSuggestions","initialSuggestionsSearchOptions","type","subtype","page","perPage","disablePostFormats","queries","push","path","per_page","then","results","map","result","id","url","title","kind","catch","source_url","rendered","responses","Promise","all","flat","filter","sortResults","slice","searchTokens","tokenize","scores","titleTokens","exactMatchingTokens","titleToken","some","searchToken","subMatchingTokens","includes","exactMatchScore","length","subMatchScore","sort","a","b","text","toLowerCase","match"],"sources":["@wordpress/core-data/src/fetch/__experimental-fetch-link-suggestions.ts"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport apiFetch from '@wordpress/api-fetch';\nimport { addQueryArgs } from '@wordpress/url';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { __ } from '@wordpress/i18n';\n\nexport type SearchOptions = {\n\t/**\n\t * Displays initial search suggestions, when true.\n\t */\n\tisInitialSuggestions?: boolean;\n\t/**\n\t * Search options for initial suggestions.\n\t */\n\tinitialSuggestionsSearchOptions?: Omit<\n\t\tSearchOptions,\n\t\t'isInitialSuggestions' | 'initialSuggestionsSearchOptions'\n\t>;\n\t/**\n\t * Filters by search type.\n\t */\n\ttype?: 'attachment' | 'post' | 'term' | 'post-format';\n\t/**\n\t * Slug of the post-type or taxonomy.\n\t */\n\tsubtype?: string;\n\t/**\n\t * Which page of results to return.\n\t */\n\tpage?: number;\n\t/**\n\t * Search results per page.\n\t */\n\tperPage?: number;\n};\n\nexport type EditorSettings = {\n\t/**\n\t * Disables post formats, when true.\n\t */\n\tdisablePostFormats?: boolean;\n};\n\ntype SearchAPIResult = {\n\tid: number;\n\ttitle: string;\n\turl: string;\n\ttype: string;\n\tsubtype: string;\n};\n\ntype MediaAPIResult = {\n\tid: number;\n\ttitle: { rendered: string };\n\tsource_url: string;\n\ttype: string;\n};\n\nexport type SearchResult = {\n\t/**\n\t * Post or term id.\n\t */\n\tid: number;\n\t/**\n\t * Link url.\n\t */\n\turl: string;\n\t/**\n\t * Title of the link.\n\t */\n\ttitle: string;\n\t/**\n\t * The taxonomy or post type slug or type URL.\n\t */\n\ttype: string;\n\t/**\n\t * Link kind of post-type or taxonomy\n\t */\n\tkind?: string;\n};\n\n/**\n * Fetches link suggestions from the WordPress API.\n *\n * WordPress does not support searching multiple tables at once, e.g. posts and terms, so we\n * perform multiple queries at the same time and then merge the results together.\n *\n * @param search\n * @param searchOptions\n * @param editorSettings\n *\n * @example\n * ```js\n * import { __experimentalFetchLinkSuggestions as fetchLinkSuggestions } from '@wordpress/core-data';\n *\n * //...\n *\n * export function initialize( id, settings ) {\n *\n * settings.__experimentalFetchLinkSuggestions = (\n * search,\n * searchOptions\n * ) => fetchLinkSuggestions( search, searchOptions, settings );\n * ```\n */\nexport default async function fetchLinkSuggestions(\n\tsearch: string,\n\tsearchOptions: SearchOptions = {},\n\teditorSettings: EditorSettings = {}\n): Promise< SearchResult[] > {\n\tconst searchOptionsToUse =\n\t\tsearchOptions.isInitialSuggestions &&\n\t\tsearchOptions.initialSuggestionsSearchOptions\n\t\t\t? {\n\t\t\t\t\t...searchOptions,\n\t\t\t\t\t...searchOptions.initialSuggestionsSearchOptions,\n\t\t\t }\n\t\t\t: searchOptions;\n\n\tconst {\n\t\ttype,\n\t\tsubtype,\n\t\tpage,\n\t\tperPage = searchOptions.isInitialSuggestions ? 3 : 20,\n\t} = searchOptionsToUse;\n\n\tconst { disablePostFormats = false } = editorSettings;\n\n\tconst queries: Promise< SearchResult[] >[] = [];\n\n\tif ( ! type || type === 'post' ) {\n\t\tqueries.push(\n\t\t\tapiFetch< SearchAPIResult[] >( {\n\t\t\t\tpath: addQueryArgs( '/wp/v2/search', {\n\t\t\t\t\tsearch,\n\t\t\t\t\tpage,\n\t\t\t\t\tper_page: perPage,\n\t\t\t\t\ttype: 'post',\n\t\t\t\t\tsubtype,\n\t\t\t\t} ),\n\t\t\t} )\n\t\t\t\t.then( ( results ) => {\n\t\t\t\t\treturn results.map( ( result ) => {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tid: result.id,\n\t\t\t\t\t\t\turl: result.url,\n\t\t\t\t\t\t\ttitle:\n\t\t\t\t\t\t\t\tdecodeEntities( result.title || '' ) ||\n\t\t\t\t\t\t\t\t__( '(no title)' ),\n\t\t\t\t\t\t\ttype: result.subtype || result.type,\n\t\t\t\t\t\t\tkind: 'post-type',\n\t\t\t\t\t\t};\n\t\t\t\t\t} );\n\t\t\t\t} )\n\t\t\t\t.catch( () => [] ) // Fail by returning no results.\n\t\t);\n\t}\n\n\tif ( ! type || type === 'term' ) {\n\t\tqueries.push(\n\t\t\tapiFetch< SearchAPIResult[] >( {\n\t\t\t\tpath: addQueryArgs( '/wp/v2/search', {\n\t\t\t\t\tsearch,\n\t\t\t\t\tpage,\n\t\t\t\t\tper_page: perPage,\n\t\t\t\t\ttype: 'term',\n\t\t\t\t\tsubtype,\n\t\t\t\t} ),\n\t\t\t} )\n\t\t\t\t.then( ( results ) => {\n\t\t\t\t\treturn results.map( ( result ) => {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tid: result.id,\n\t\t\t\t\t\t\turl: result.url,\n\t\t\t\t\t\t\ttitle:\n\t\t\t\t\t\t\t\tdecodeEntities( result.title || '' ) ||\n\t\t\t\t\t\t\t\t__( '(no title)' ),\n\t\t\t\t\t\t\ttype: result.subtype || result.type,\n\t\t\t\t\t\t\tkind: 'taxonomy',\n\t\t\t\t\t\t};\n\t\t\t\t\t} );\n\t\t\t\t} )\n\t\t\t\t.catch( () => [] ) // Fail by returning no results.\n\t\t);\n\t}\n\n\tif ( ! disablePostFormats && ( ! type || type === 'post-format' ) ) {\n\t\tqueries.push(\n\t\t\tapiFetch< SearchAPIResult[] >( {\n\t\t\t\tpath: addQueryArgs( '/wp/v2/search', {\n\t\t\t\t\tsearch,\n\t\t\t\t\tpage,\n\t\t\t\t\tper_page: perPage,\n\t\t\t\t\ttype: 'post-format',\n\t\t\t\t\tsubtype,\n\t\t\t\t} ),\n\t\t\t} )\n\t\t\t\t.then( ( results ) => {\n\t\t\t\t\treturn results.map( ( result ) => {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tid: result.id,\n\t\t\t\t\t\t\turl: result.url,\n\t\t\t\t\t\t\ttitle:\n\t\t\t\t\t\t\t\tdecodeEntities( result.title || '' ) ||\n\t\t\t\t\t\t\t\t__( '(no title)' ),\n\t\t\t\t\t\t\ttype: result.subtype || result.type,\n\t\t\t\t\t\t\tkind: 'taxonomy',\n\t\t\t\t\t\t};\n\t\t\t\t\t} );\n\t\t\t\t} )\n\t\t\t\t.catch( () => [] ) // Fail by returning no results.\n\t\t);\n\t}\n\n\tif ( ! type || type === 'attachment' ) {\n\t\tqueries.push(\n\t\t\tapiFetch< MediaAPIResult[] >( {\n\t\t\t\tpath: addQueryArgs( '/wp/v2/media', {\n\t\t\t\t\tsearch,\n\t\t\t\t\tpage,\n\t\t\t\t\tper_page: perPage,\n\t\t\t\t} ),\n\t\t\t} )\n\t\t\t\t.then( ( results ) => {\n\t\t\t\t\treturn results.map( ( result ) => {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tid: result.id,\n\t\t\t\t\t\t\turl: result.source_url,\n\t\t\t\t\t\t\ttitle:\n\t\t\t\t\t\t\t\tdecodeEntities( result.title.rendered || '' ) ||\n\t\t\t\t\t\t\t\t__( '(no title)' ),\n\t\t\t\t\t\t\ttype: result.type,\n\t\t\t\t\t\t\tkind: 'media',\n\t\t\t\t\t\t};\n\t\t\t\t\t} );\n\t\t\t\t} )\n\t\t\t\t.catch( () => [] ) // Fail by returning no results.\n\t\t);\n\t}\n\n\tconst responses = await Promise.all( queries );\n\n\tlet results = responses.flat();\n\tresults = results.filter( ( result ) => !! result.id );\n\tresults = sortResults( results, search );\n\tresults = results.slice( 0, perPage );\n\treturn results;\n}\n\n/**\n * Sort search results by relevance to the given query.\n *\n * Sorting is necessary as we're querying multiple endpoints and merging the results. For example\n * a taxonomy title might be more relevant than a post title, but by default taxonomy results will\n * be ordered after all the (potentially irrelevant) post results.\n *\n * We sort by scoring each result, where the score is the number of tokens in the title that are\n * also in the search query, divided by the total number of tokens in the title. This gives us a\n * score between 0 and 1, where 1 is a perfect match.\n *\n * @param results\n * @param search\n */\nexport function sortResults( results: SearchResult[], search: string ) {\n\tconst searchTokens = tokenize( search );\n\n\tconst scores = {};\n\tfor ( const result of results ) {\n\t\tif ( result.title ) {\n\t\t\tconst titleTokens = tokenize( result.title );\n\t\t\tconst exactMatchingTokens = titleTokens.filter( ( titleToken ) =>\n\t\t\t\tsearchTokens.some(\n\t\t\t\t\t( searchToken ) => titleToken === searchToken\n\t\t\t\t)\n\t\t\t);\n\t\t\tconst subMatchingTokens = titleTokens.filter( ( titleToken ) =>\n\t\t\t\tsearchTokens.some(\n\t\t\t\t\t( searchToken ) =>\n\t\t\t\t\t\ttitleToken !== searchToken &&\n\t\t\t\t\t\ttitleToken.includes( searchToken )\n\t\t\t\t)\n\t\t\t);\n\n\t\t\t// The score is a combination of exact matches and sub-matches.\n\t\t\t// More weight is given to exact matches, as they are more relevant (e.g. \"cat\" vs \"caterpillar\").\n\t\t\t// Diving by the total number of tokens in the title normalizes the score and skews\n\t\t\t// the results towards shorter titles.\n\t\t\tconst exactMatchScore =\n\t\t\t\t( exactMatchingTokens.length / titleTokens.length ) * 10;\n\n\t\t\tconst subMatchScore = subMatchingTokens.length / titleTokens.length;\n\n\t\t\tscores[ result.id ] = exactMatchScore + subMatchScore;\n\t\t} else {\n\t\t\tscores[ result.id ] = 0;\n\t\t}\n\t}\n\n\treturn results.sort( ( a, b ) => scores[ b.id ] - scores[ a.id ] );\n}\n\n/**\n * Turns text into an array of tokens, with whitespace and punctuation removed.\n *\n * For example, `\"I'm having a ball.\"` becomes `[ \"im\", \"having\", \"a\", \"ball\" ]`.\n *\n * @param text\n */\nexport function tokenize( text: string ): string[] {\n\t// \\p{L} matches any kind of letter from any language.\n\t// \\p{N} matches any kind of numeric character.\n\treturn text.toLowerCase().match( /[\\p{L}\\p{N}]+/gu ) || [];\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,QAAQ,MAAM,sBAAsB;AAC3C,SAASC,YAAY,QAAQ,gBAAgB;AAC7C,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,EAAE,QAAQ,iBAAiB;AA6EpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,eAAeC,oBAAoBA,CACjDC,MAAc,EACdC,aAA4B,GAAG,CAAC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;AACA;AACA;AACA;AACA,OAAO,SAASe,QAAQA,CAAEe,IAAY,EAAa;EAClD;EACA;EACA,OAAOA,IAAI,CAACC,WAAW,CAAC,CAAC,CAACC,KAAK,CAAE,iBAAkB,CAAC,IAAI,EAAE;AAC3D","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/fetch/__experimental-fetch-link-suggestions.ts"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport apiFetch from '@wordpress/api-fetch';\nimport { addQueryArgs } from '@wordpress/url';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { __ } from '@wordpress/i18n';\n\nexport type SearchOptions = {\n\t/**\n\t * Displays initial search suggestions, when true.\n\t */\n\tisInitialSuggestions?: boolean;\n\t/**\n\t * Search options for initial suggestions.\n\t */\n\tinitialSuggestionsSearchOptions?: Omit<\n\t\tSearchOptions,\n\t\t'isInitialSuggestions' | 'initialSuggestionsSearchOptions'\n\t>;\n\t/**\n\t * Filters by search type.\n\t */\n\ttype?: 'attachment' | 'post' | 'term' | 'post-format';\n\t/**\n\t * Slug of the post-type or taxonomy.\n\t */\n\tsubtype?: string;\n\t/**\n\t * Which page of results to return.\n\t */\n\tpage?: number;\n\t/**\n\t * Search results per page.\n\t */\n\tperPage?: number;\n};\n\nexport type EditorSettings = {\n\t/**\n\t * Disables post formats, when true.\n\t */\n\tdisablePostFormats?: boolean;\n};\n\ntype SearchAPIResult = {\n\tid: number;\n\ttitle: string;\n\turl: string;\n\ttype: string;\n\tsubtype: string;\n};\n\ntype MediaAPIResult = {\n\tid: number;\n\ttitle: { rendered: string };\n\tsource_url: string;\n\ttype: string;\n};\n\nexport type SearchResult = {\n\t/**\n\t * Post or term id.\n\t */\n\tid: number;\n\t/**\n\t * Link url.\n\t */\n\turl: string;\n\t/**\n\t * Title of the link.\n\t */\n\ttitle: string;\n\t/**\n\t * The taxonomy or post type slug or type URL.\n\t */\n\ttype: string;\n\t/**\n\t * Link kind of post-type or taxonomy\n\t */\n\tkind?: string;\n};\n\n/**\n * Fetches link suggestions from the WordPress API.\n *\n * WordPress does not support searching multiple tables at once, e.g. posts and terms, so we\n * perform multiple queries at the same time and then merge the results together.\n *\n * @param search\n * @param searchOptions\n * @param editorSettings\n *\n * @example\n * ```js\n * import { __experimentalFetchLinkSuggestions as fetchLinkSuggestions } from '@wordpress/core-data';\n *\n * //...\n *\n * export function initialize( id, settings ) {\n *\n * settings.__experimentalFetchLinkSuggestions = (\n * search,\n * searchOptions\n * ) => fetchLinkSuggestions( search, searchOptions, settings );\n * ```\n */\nexport default async function fetchLinkSuggestions(\n\tsearch: string,\n\tsearchOptions: SearchOptions = {},\n\teditorSettings: EditorSettings = {}\n): Promise< SearchResult[] > {\n\tconst searchOptionsToUse =\n\t\tsearchOptions.isInitialSuggestions &&\n\t\tsearchOptions.initialSuggestionsSearchOptions\n\t\t\t? {\n\t\t\t\t\t...searchOptions,\n\t\t\t\t\t...searchOptions.initialSuggestionsSearchOptions,\n\t\t\t }\n\t\t\t: searchOptions;\n\n\tconst {\n\t\ttype,\n\t\tsubtype,\n\t\tpage,\n\t\tperPage = searchOptions.isInitialSuggestions ? 3 : 20,\n\t} = searchOptionsToUse;\n\n\tconst { disablePostFormats = false } = editorSettings;\n\n\tconst queries: Promise< SearchResult[] >[] = [];\n\n\tif ( ! type || type === 'post' ) {\n\t\tqueries.push(\n\t\t\tapiFetch< SearchAPIResult[] >( {\n\t\t\t\tpath: addQueryArgs( '/wp/v2/search', {\n\t\t\t\t\tsearch,\n\t\t\t\t\tpage,\n\t\t\t\t\tper_page: perPage,\n\t\t\t\t\ttype: 'post',\n\t\t\t\t\tsubtype,\n\t\t\t\t} ),\n\t\t\t} )\n\t\t\t\t.then( ( results ) => {\n\t\t\t\t\treturn results.map( ( result ) => {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tid: result.id,\n\t\t\t\t\t\t\turl: result.url,\n\t\t\t\t\t\t\ttitle:\n\t\t\t\t\t\t\t\tdecodeEntities( result.title || '' ) ||\n\t\t\t\t\t\t\t\t__( '(no title)' ),\n\t\t\t\t\t\t\ttype: result.subtype || result.type,\n\t\t\t\t\t\t\tkind: 'post-type',\n\t\t\t\t\t\t};\n\t\t\t\t\t} );\n\t\t\t\t} )\n\t\t\t\t.catch( () => [] ) // Fail by returning no results.\n\t\t);\n\t}\n\n\tif ( ! type || type === 'term' ) {\n\t\tqueries.push(\n\t\t\tapiFetch< SearchAPIResult[] >( {\n\t\t\t\tpath: addQueryArgs( '/wp/v2/search', {\n\t\t\t\t\tsearch,\n\t\t\t\t\tpage,\n\t\t\t\t\tper_page: perPage,\n\t\t\t\t\ttype: 'term',\n\t\t\t\t\tsubtype,\n\t\t\t\t} ),\n\t\t\t} )\n\t\t\t\t.then( ( results ) => {\n\t\t\t\t\treturn results.map( ( result ) => {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tid: result.id,\n\t\t\t\t\t\t\turl: result.url,\n\t\t\t\t\t\t\ttitle:\n\t\t\t\t\t\t\t\tdecodeEntities( result.title || '' ) ||\n\t\t\t\t\t\t\t\t__( '(no title)' ),\n\t\t\t\t\t\t\ttype: result.subtype || result.type,\n\t\t\t\t\t\t\tkind: 'taxonomy',\n\t\t\t\t\t\t};\n\t\t\t\t\t} );\n\t\t\t\t} )\n\t\t\t\t.catch( () => [] ) // Fail by returning no results.\n\t\t);\n\t}\n\n\tif ( ! disablePostFormats && ( ! type || type === 'post-format' ) ) {\n\t\tqueries.push(\n\t\t\tapiFetch< SearchAPIResult[] >( {\n\t\t\t\tpath: addQueryArgs( '/wp/v2/search', {\n\t\t\t\t\tsearch,\n\t\t\t\t\tpage,\n\t\t\t\t\tper_page: perPage,\n\t\t\t\t\ttype: 'post-format',\n\t\t\t\t\tsubtype,\n\t\t\t\t} ),\n\t\t\t} )\n\t\t\t\t.then( ( results ) => {\n\t\t\t\t\treturn results.map( ( result ) => {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tid: result.id,\n\t\t\t\t\t\t\turl: result.url,\n\t\t\t\t\t\t\ttitle:\n\t\t\t\t\t\t\t\tdecodeEntities( result.title || '' ) ||\n\t\t\t\t\t\t\t\t__( '(no title)' ),\n\t\t\t\t\t\t\ttype: result.subtype || result.type,\n\t\t\t\t\t\t\tkind: 'taxonomy',\n\t\t\t\t\t\t};\n\t\t\t\t\t} );\n\t\t\t\t} )\n\t\t\t\t.catch( () => [] ) // Fail by returning no results.\n\t\t);\n\t}\n\n\tif ( ! type || type === 'attachment' ) {\n\t\tqueries.push(\n\t\t\tapiFetch< MediaAPIResult[] >( {\n\t\t\t\tpath: addQueryArgs( '/wp/v2/media', {\n\t\t\t\t\tsearch,\n\t\t\t\t\tpage,\n\t\t\t\t\tper_page: perPage,\n\t\t\t\t} ),\n\t\t\t} )\n\t\t\t\t.then( ( results ) => {\n\t\t\t\t\treturn results.map( ( result ) => {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tid: result.id,\n\t\t\t\t\t\t\turl: result.source_url,\n\t\t\t\t\t\t\ttitle:\n\t\t\t\t\t\t\t\tdecodeEntities( result.title.rendered || '' ) ||\n\t\t\t\t\t\t\t\t__( '(no title)' ),\n\t\t\t\t\t\t\ttype: result.type,\n\t\t\t\t\t\t\tkind: 'media',\n\t\t\t\t\t\t};\n\t\t\t\t\t} );\n\t\t\t\t} )\n\t\t\t\t.catch( () => [] ) // Fail by returning no results.\n\t\t);\n\t}\n\n\tconst responses = await Promise.all( queries );\n\n\tlet results = responses.flat();\n\tresults = results.filter( ( result ) => !! result.id );\n\tresults = sortResults( results, search );\n\tresults = results.slice( 0, perPage );\n\treturn results;\n}\n\n/**\n * Sort search results by relevance to the given query.\n *\n * Sorting is necessary as we're querying multiple endpoints and merging the results. For example\n * a taxonomy title might be more relevant than a post title, but by default taxonomy results will\n * be ordered after all the (potentially irrelevant) post results.\n *\n * We sort by scoring each result, where the score is the number of tokens in the title that are\n * also in the search query, divided by the total number of tokens in the title. This gives us a\n * score between 0 and 1, where 1 is a perfect match.\n *\n * @param results\n * @param search\n */\nexport function sortResults( results: SearchResult[], search: string ) {\n\tconst searchTokens = tokenize( search );\n\n\tconst scores = {};\n\tfor ( const result of results ) {\n\t\tif ( result.title ) {\n\t\t\tconst titleTokens = tokenize( result.title );\n\t\t\tconst exactMatchingTokens = titleTokens.filter( ( titleToken ) =>\n\t\t\t\tsearchTokens.some(\n\t\t\t\t\t( searchToken ) => titleToken === searchToken\n\t\t\t\t)\n\t\t\t);\n\t\t\tconst subMatchingTokens = titleTokens.filter( ( titleToken ) =>\n\t\t\t\tsearchTokens.some(\n\t\t\t\t\t( searchToken ) =>\n\t\t\t\t\t\ttitleToken !== searchToken &&\n\t\t\t\t\t\ttitleToken.includes( searchToken )\n\t\t\t\t)\n\t\t\t);\n\n\t\t\t// The score is a combination of exact matches and sub-matches.\n\t\t\t// More weight is given to exact matches, as they are more relevant (e.g. \"cat\" vs \"caterpillar\").\n\t\t\t// Diving by the total number of tokens in the title normalizes the score and skews\n\t\t\t// the results towards shorter titles.\n\t\t\tconst exactMatchScore =\n\t\t\t\t( exactMatchingTokens.length / titleTokens.length ) * 10;\n\n\t\t\tconst subMatchScore = subMatchingTokens.length / titleTokens.length;\n\n\t\t\tscores[ result.id ] = exactMatchScore + subMatchScore;\n\t\t} else {\n\t\t\tscores[ result.id ] = 0;\n\t\t}\n\t}\n\n\treturn results.sort( ( a, b ) => scores[ b.id ] - scores[ a.id ] );\n}\n\n/**\n * Turns text into an array of tokens, with whitespace and punctuation removed.\n *\n * For example, `\"I'm having a ball.\"` becomes `[ \"im\", \"having\", \"a\", \"ball\" ]`.\n *\n * @param text\n */\nexport function tokenize( text: string ): string[] {\n\t// \\p{L} matches any kind of letter from any language.\n\t// \\p{N} matches any kind of numeric character.\n\treturn text.toLowerCase().match( /[\\p{L}\\p{N}]+/gu ) || [];\n}\n"],
5
+ "mappings": "AAGA,OAAO,cAAc;AACrB,SAAS,oBAAoB;AAC7B,SAAS,sBAAsB;AAC/B,SAAS,UAAU;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