@wordpress/block-library 8.13.0 → 8.14.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 (366) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/archives/index.js +5 -1
  3. package/build/archives/index.js.map +1 -1
  4. package/build/audio/index.js +5 -1
  5. package/build/audio/index.js.map +1 -1
  6. package/build/avatar/index.js +1 -1
  7. package/build/block/edit.js +1 -1
  8. package/build/block/edit.js.map +1 -1
  9. package/build/block/edit.native.js +6 -9
  10. package/build/block/edit.native.js.map +1 -1
  11. package/build/buttons/edit.js +5 -1
  12. package/build/buttons/edit.js.map +1 -1
  13. package/build/categories/index.js +5 -1
  14. package/build/categories/index.js.map +1 -1
  15. package/build/code/index.js +5 -1
  16. package/build/code/index.js.map +1 -1
  17. package/build/column/index.js +1 -0
  18. package/build/column/index.js.map +1 -1
  19. package/build/comments/index.js +1 -0
  20. package/build/comments/index.js.map +1 -1
  21. package/build/cover/edit/inspector-controls.js +2 -1
  22. package/build/cover/edit/inspector-controls.js.map +1 -1
  23. package/build/cover/index.js +1 -0
  24. package/build/cover/index.js.map +1 -1
  25. package/build/details/index.js +5 -1
  26. package/build/details/index.js.map +1 -1
  27. package/build/embed/util.js +9 -8
  28. package/build/embed/util.js.map +1 -1
  29. package/build/file/index.js +2 -1
  30. package/build/file/index.js.map +1 -1
  31. package/build/file/view.js +15 -1
  32. package/build/file/view.js.map +1 -1
  33. package/build/gallery/index.js +3 -1
  34. package/build/gallery/index.js.map +1 -1
  35. package/build/group/index.js +1 -0
  36. package/build/group/index.js.map +1 -1
  37. package/build/heading/index.js +5 -1
  38. package/build/heading/index.js.map +1 -1
  39. package/build/heading/transforms.js +5 -1
  40. package/build/heading/transforms.js.map +1 -1
  41. package/build/image/deprecated.js +453 -175
  42. package/build/image/deprecated.js.map +1 -1
  43. package/build/image/edit.js +0 -4
  44. package/build/image/edit.js.map +1 -1
  45. package/build/image/image.js +96 -43
  46. package/build/image/image.js.map +1 -1
  47. package/build/image/index.js +6 -0
  48. package/build/image/index.js.map +1 -1
  49. package/build/image/save.js +8 -1
  50. package/build/image/save.js.map +1 -1
  51. package/build/image/utils.js +18 -0
  52. package/build/image/utils.js.map +1 -1
  53. package/build/image/{interactivity.js → view-interactivity.js} +86 -44
  54. package/build/image/view-interactivity.js.map +1 -0
  55. package/build/index.js +12 -3
  56. package/build/index.js.map +1 -1
  57. package/build/list/index.js +5 -1
  58. package/build/list/index.js.map +1 -1
  59. package/build/list-item/utils.js +6 -1
  60. package/build/list-item/utils.js.map +1 -1
  61. package/build/media-text/index.js +1 -0
  62. package/build/media-text/index.js.map +1 -1
  63. package/build/missing/edit.js +22 -8
  64. package/build/missing/edit.js.map +1 -1
  65. package/build/navigation/edit/index.js +1 -1
  66. package/build/navigation/edit/index.js.map +1 -1
  67. package/build/navigation/edit/menu-inspector-controls.js +0 -1
  68. package/build/navigation/edit/menu-inspector-controls.js.map +1 -1
  69. package/build/navigation/index.js +3 -2
  70. package/build/navigation/index.js.map +1 -1
  71. package/build/navigation/view.js +174 -50
  72. package/build/navigation/view.js.map +1 -1
  73. package/build/navigation-link/edit.js +0 -11
  74. package/build/navigation-link/edit.js.map +1 -1
  75. package/build/navigation-link/link-ui.js +12 -2
  76. package/build/navigation-link/link-ui.js.map +1 -1
  77. package/build/page-list/convert-to-links-modal.js +3 -3
  78. package/build/page-list/convert-to-links-modal.js.map +1 -1
  79. package/build/page-list/edit.js +34 -39
  80. package/build/page-list/edit.js.map +1 -1
  81. package/build/page-list/use-convert-to-navigation-links.js +2 -15
  82. package/build/page-list/use-convert-to-navigation-links.js.map +1 -1
  83. package/build/paragraph/index.js +1 -0
  84. package/build/paragraph/index.js.map +1 -1
  85. package/build/paragraph/transforms.js +1 -0
  86. package/build/paragraph/transforms.js.map +1 -1
  87. package/build/post-comments-form/index.js +1 -0
  88. package/build/post-comments-form/index.js.map +1 -1
  89. package/build/post-navigation-link/index.js +1 -0
  90. package/build/post-navigation-link/index.js.map +1 -1
  91. package/build/post-time-to-read/index.js +5 -1
  92. package/build/post-time-to-read/index.js.map +1 -1
  93. package/build/query-pagination-numbers/index.js +1 -1
  94. package/build/quote/index.js +1 -0
  95. package/build/quote/index.js.map +1 -1
  96. package/build/site-logo/index.js +5 -1
  97. package/build/site-logo/index.js.map +1 -1
  98. package/build/site-tagline/icon.js +1 -1
  99. package/build/site-tagline/icon.js.map +1 -1
  100. package/build/site-tagline/index.js +5 -1
  101. package/build/site-tagline/index.js.map +1 -1
  102. package/build/site-title/index.js +5 -1
  103. package/build/site-title/index.js.map +1 -1
  104. package/build/social-links/index.js +3 -1
  105. package/build/social-links/index.js.map +1 -1
  106. package/build/table/index.js +5 -1
  107. package/build/table/index.js.map +1 -1
  108. package/build/term-description/index.js +1 -0
  109. package/build/term-description/index.js.map +1 -1
  110. package/build/verse/index.js +5 -1
  111. package/build/verse/index.js.map +1 -1
  112. package/build/video/deprecated.js +5 -1
  113. package/build/video/deprecated.js.map +1 -1
  114. package/build/video/index.js +5 -1
  115. package/build/video/index.js.map +1 -1
  116. package/build-module/archives/index.js +5 -1
  117. package/build-module/archives/index.js.map +1 -1
  118. package/build-module/audio/index.js +5 -1
  119. package/build-module/audio/index.js.map +1 -1
  120. package/build-module/avatar/index.js +1 -1
  121. package/build-module/block/edit.js +1 -1
  122. package/build-module/block/edit.js.map +1 -1
  123. package/build-module/block/edit.native.js +7 -9
  124. package/build-module/block/edit.native.js.map +1 -1
  125. package/build-module/buttons/edit.js +5 -1
  126. package/build-module/buttons/edit.js.map +1 -1
  127. package/build-module/categories/index.js +5 -1
  128. package/build-module/categories/index.js.map +1 -1
  129. package/build-module/code/index.js +5 -1
  130. package/build-module/code/index.js.map +1 -1
  131. package/build-module/column/index.js +1 -0
  132. package/build-module/column/index.js.map +1 -1
  133. package/build-module/comments/index.js +1 -0
  134. package/build-module/comments/index.js.map +1 -1
  135. package/build-module/cover/edit/inspector-controls.js +2 -1
  136. package/build-module/cover/edit/inspector-controls.js.map +1 -1
  137. package/build-module/cover/index.js +1 -0
  138. package/build-module/cover/index.js.map +1 -1
  139. package/build-module/details/index.js +5 -1
  140. package/build-module/details/index.js.map +1 -1
  141. package/build-module/embed/util.js +6 -6
  142. package/build-module/embed/util.js.map +1 -1
  143. package/build-module/file/index.js +2 -1
  144. package/build-module/file/index.js.map +1 -1
  145. package/build-module/file/view.js +15 -2
  146. package/build-module/file/view.js.map +1 -1
  147. package/build-module/gallery/index.js +3 -1
  148. package/build-module/gallery/index.js.map +1 -1
  149. package/build-module/group/index.js +1 -0
  150. package/build-module/group/index.js.map +1 -1
  151. package/build-module/heading/index.js +5 -1
  152. package/build-module/heading/index.js.map +1 -1
  153. package/build-module/heading/transforms.js +5 -1
  154. package/build-module/heading/transforms.js.map +1 -1
  155. package/build-module/image/deprecated.js +454 -176
  156. package/build-module/image/deprecated.js.map +1 -1
  157. package/build-module/image/edit.js +0 -4
  158. package/build-module/image/edit.js.map +1 -1
  159. package/build-module/image/image.js +96 -46
  160. package/build-module/image/image.js.map +1 -1
  161. package/build-module/image/index.js +6 -0
  162. package/build-module/image/index.js.map +1 -1
  163. package/build-module/image/save.js +8 -1
  164. package/build-module/image/save.js.map +1 -1
  165. package/build-module/image/utils.js +16 -0
  166. package/build-module/image/utils.js.map +1 -1
  167. package/build-module/image/{interactivity.js → view-interactivity.js} +86 -44
  168. package/build-module/image/view-interactivity.js.map +1 -0
  169. package/build-module/index.js +12 -3
  170. package/build-module/index.js.map +1 -1
  171. package/build-module/list/index.js +5 -1
  172. package/build-module/list/index.js.map +1 -1
  173. package/build-module/list-item/utils.js +6 -1
  174. package/build-module/list-item/utils.js.map +1 -1
  175. package/build-module/media-text/index.js +1 -0
  176. package/build-module/media-text/index.js.map +1 -1
  177. package/build-module/missing/edit.js +22 -8
  178. package/build-module/missing/edit.js.map +1 -1
  179. package/build-module/navigation/edit/index.js +1 -1
  180. package/build-module/navigation/edit/index.js.map +1 -1
  181. package/build-module/navigation/edit/menu-inspector-controls.js +0 -1
  182. package/build-module/navigation/edit/menu-inspector-controls.js.map +1 -1
  183. package/build-module/navigation/index.js +3 -2
  184. package/build-module/navigation/index.js.map +1 -1
  185. package/build-module/navigation/view.js +173 -50
  186. package/build-module/navigation/view.js.map +1 -1
  187. package/build-module/navigation-link/edit.js +1 -12
  188. package/build-module/navigation-link/edit.js.map +1 -1
  189. package/build-module/navigation-link/link-ui.js +13 -3
  190. package/build-module/navigation-link/link-ui.js.map +1 -1
  191. package/build-module/page-list/convert-to-links-modal.js +3 -3
  192. package/build-module/page-list/convert-to-links-modal.js.map +1 -1
  193. package/build-module/page-list/edit.js +34 -39
  194. package/build-module/page-list/edit.js.map +1 -1
  195. package/build-module/page-list/use-convert-to-navigation-links.js +3 -16
  196. package/build-module/page-list/use-convert-to-navigation-links.js.map +1 -1
  197. package/build-module/paragraph/index.js +1 -0
  198. package/build-module/paragraph/index.js.map +1 -1
  199. package/build-module/paragraph/transforms.js +1 -0
  200. package/build-module/paragraph/transforms.js.map +1 -1
  201. package/build-module/post-comments-form/index.js +1 -0
  202. package/build-module/post-comments-form/index.js.map +1 -1
  203. package/build-module/post-navigation-link/index.js +1 -0
  204. package/build-module/post-navigation-link/index.js.map +1 -1
  205. package/build-module/post-time-to-read/index.js +5 -1
  206. package/build-module/post-time-to-read/index.js.map +1 -1
  207. package/build-module/query-pagination-numbers/index.js +1 -1
  208. package/build-module/quote/index.js +1 -0
  209. package/build-module/quote/index.js.map +1 -1
  210. package/build-module/site-logo/index.js +5 -1
  211. package/build-module/site-logo/index.js.map +1 -1
  212. package/build-module/site-tagline/icon.js +1 -1
  213. package/build-module/site-tagline/icon.js.map +1 -1
  214. package/build-module/site-tagline/index.js +5 -1
  215. package/build-module/site-tagline/index.js.map +1 -1
  216. package/build-module/site-title/index.js +5 -1
  217. package/build-module/site-title/index.js.map +1 -1
  218. package/build-module/social-links/index.js +3 -1
  219. package/build-module/social-links/index.js.map +1 -1
  220. package/build-module/table/index.js +5 -1
  221. package/build-module/table/index.js.map +1 -1
  222. package/build-module/term-description/index.js +1 -0
  223. package/build-module/term-description/index.js.map +1 -1
  224. package/build-module/verse/index.js +5 -1
  225. package/build-module/verse/index.js.map +1 -1
  226. package/build-module/video/deprecated.js +5 -1
  227. package/build-module/video/deprecated.js.map +1 -1
  228. package/build-module/video/index.js +5 -1
  229. package/build-module/video/index.js.map +1 -1
  230. package/build-style/footnotes/style-rtl.css +2 -2
  231. package/build-style/footnotes/style.css +2 -2
  232. package/build-style/image/style-rtl.css +16 -2
  233. package/build-style/image/style.css +16 -2
  234. package/build-style/style-rtl.css +18 -4
  235. package/build-style/style.css +18 -4
  236. package/package.json +33 -38
  237. package/src/archives/block.json +5 -1
  238. package/src/audio/block.json +5 -1
  239. package/src/avatar/block.json +1 -1
  240. package/src/block/edit.js +2 -2
  241. package/src/block/edit.native.js +8 -12
  242. package/src/block/test/edit.native.js +4 -4
  243. package/src/buttons/edit.js +2 -2
  244. package/src/categories/block.json +5 -1
  245. package/src/code/block.json +5 -1
  246. package/src/column/block.json +1 -0
  247. package/src/comments/block.json +1 -0
  248. package/src/cover/block.json +1 -0
  249. package/src/cover/edit/inspector-controls.js +1 -0
  250. package/src/details/block.json +5 -1
  251. package/src/embed/util.js +4 -6
  252. package/src/file/block.json +2 -1
  253. package/src/file/index.php +0 -17
  254. package/src/file/view.js +14 -5
  255. package/src/footnotes/index.php +11 -9
  256. package/src/footnotes/style.scss +2 -2
  257. package/src/gallery/block.json +3 -1
  258. package/src/group/block.json +1 -0
  259. package/src/heading/block.json +5 -1
  260. package/src/heading/test/index.native.js +18 -0
  261. package/src/image/block.json +6 -0
  262. package/src/image/deprecated.js +597 -320
  263. package/src/image/edit.js +0 -4
  264. package/src/image/image.js +131 -62
  265. package/src/image/save.js +9 -1
  266. package/src/image/style.scss +15 -2
  267. package/src/image/utils.js +16 -0
  268. package/src/image/{interactivity.js → view-interactivity.js} +99 -50
  269. package/src/index.js +18 -1
  270. package/src/latest-posts/index.php +1 -1
  271. package/src/list/block.json +5 -1
  272. package/src/media-text/block.json +1 -0
  273. package/src/missing/edit.js +31 -11
  274. package/src/navigation/block.json +3 -2
  275. package/src/navigation/edit/index.js +1 -2
  276. package/src/navigation/edit/menu-inspector-controls.js +0 -1
  277. package/src/navigation/index.php +39 -30
  278. package/src/navigation/view.js +189 -67
  279. package/src/navigation-link/edit.js +1 -15
  280. package/src/navigation-link/link-ui.js +14 -2
  281. package/src/navigation-submenu/index.php +2 -12
  282. package/src/page-list/convert-to-links-modal.js +3 -3
  283. package/src/page-list/edit.js +65 -62
  284. package/src/page-list/use-convert-to-navigation-links.js +3 -20
  285. package/src/paragraph/block.json +1 -0
  286. package/src/post-comments-form/block.json +1 -0
  287. package/src/post-navigation-link/block.json +1 -0
  288. package/src/post-time-to-read/block.json +5 -1
  289. package/src/query-pagination-numbers/block.json +1 -1
  290. package/src/quote/block.json +1 -0
  291. package/src/site-logo/block.json +5 -1
  292. package/src/site-tagline/block.json +5 -1
  293. package/src/site-tagline/icon.js +1 -1
  294. package/src/site-title/block.json +5 -1
  295. package/src/social-links/block.json +3 -1
  296. package/src/table/block.json +5 -1
  297. package/src/term-description/block.json +1 -0
  298. package/src/verse/block.json +5 -1
  299. package/src/video/block.json +5 -1
  300. package/build/file/interactivity.js +0 -19
  301. package/build/file/interactivity.js.map +0 -1
  302. package/build/heading/heading-level-icon.js +0 -61
  303. package/build/heading/heading-level-icon.js.map +0 -1
  304. package/build/image/interactivity.js.map +0 -1
  305. package/build/navigation/interactivity.js +0 -167
  306. package/build/navigation/interactivity.js.map +0 -1
  307. package/build/navigation/view-modal.js +0 -64
  308. package/build/navigation/view-modal.js.map +0 -1
  309. package/build/utils/interactivity/constants.js +0 -9
  310. package/build/utils/interactivity/constants.js.map +0 -1
  311. package/build/utils/interactivity/directives.js +0 -222
  312. package/build/utils/interactivity/directives.js.map +0 -1
  313. package/build/utils/interactivity/hooks.js +0 -159
  314. package/build/utils/interactivity/hooks.js.map +0 -1
  315. package/build/utils/interactivity/hydration.js +0 -34
  316. package/build/utils/interactivity/hydration.js.map +0 -1
  317. package/build/utils/interactivity/index.js +0 -32
  318. package/build/utils/interactivity/index.js.map +0 -1
  319. package/build/utils/interactivity/portals.js +0 -108
  320. package/build/utils/interactivity/portals.js.map +0 -1
  321. package/build/utils/interactivity/store.js +0 -66
  322. package/build/utils/interactivity/store.js.map +0 -1
  323. package/build/utils/interactivity/utils.js +0 -87
  324. package/build/utils/interactivity/utils.js.map +0 -1
  325. package/build/utils/interactivity/vdom.js +0 -119
  326. package/build/utils/interactivity/vdom.js.map +0 -1
  327. package/build-module/file/interactivity.js +0 -15
  328. package/build-module/file/interactivity.js.map +0 -1
  329. package/build-module/heading/heading-level-icon.js +0 -53
  330. package/build-module/heading/heading-level-icon.js.map +0 -1
  331. package/build-module/image/interactivity.js.map +0 -1
  332. package/build-module/navigation/interactivity.js +0 -164
  333. package/build-module/navigation/interactivity.js.map +0 -1
  334. package/build-module/navigation/view-modal.js +0 -58
  335. package/build-module/navigation/view-modal.js.map +0 -1
  336. package/build-module/utils/interactivity/constants.js +0 -2
  337. package/build-module/utils/interactivity/constants.js.map +0 -1
  338. package/build-module/utils/interactivity/directives.js +0 -209
  339. package/build-module/utils/interactivity/directives.js.map +0 -1
  340. package/build-module/utils/interactivity/hooks.js +0 -145
  341. package/build-module/utils/interactivity/hooks.js.map +0 -1
  342. package/build-module/utils/interactivity/hydration.js +0 -21
  343. package/build-module/utils/interactivity/hydration.js.map +0 -1
  344. package/build-module/utils/interactivity/index.js +0 -15
  345. package/build-module/utils/interactivity/index.js.map +0 -1
  346. package/build-module/utils/interactivity/portals.js +0 -100
  347. package/build-module/utils/interactivity/portals.js.map +0 -1
  348. package/build-module/utils/interactivity/store.js +0 -55
  349. package/build-module/utils/interactivity/store.js.map +0 -1
  350. package/build-module/utils/interactivity/utils.js +0 -75
  351. package/build-module/utils/interactivity/utils.js.map +0 -1
  352. package/build-module/utils/interactivity/vdom.js +0 -107
  353. package/build-module/utils/interactivity/vdom.js.map +0 -1
  354. package/src/file/interactivity.js +0 -15
  355. package/src/heading/heading-level-icon.js +0 -48
  356. package/src/navigation/interactivity.js +0 -169
  357. package/src/navigation/view-modal.js +0 -78
  358. package/src/utils/interactivity/constants.js +0 -1
  359. package/src/utils/interactivity/directives.js +0 -200
  360. package/src/utils/interactivity/hooks.js +0 -145
  361. package/src/utils/interactivity/hydration.js +0 -22
  362. package/src/utils/interactivity/index.js +0 -15
  363. package/src/utils/interactivity/portals.js +0 -98
  364. package/src/utils/interactivity/store.js +0 -45
  365. package/src/utils/interactivity/utils.js +0 -66
  366. package/src/utils/interactivity/vdom.js +0 -111
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/utils/interactivity/directives.js"],"names":["useContext","useMemo","useEffect","deepSignal","peek","createPortal","useSignalEffect","directive","isObject","item","Array","isArray","mergeDeepSignals","target","source","k","directives","context","default","props","children","inherited","Provider","inheritedValue","value","localValue","priority","document","body","effect","evaluate","contextValue","Object","values","forEach","path","init","on","element","entries","name","event","class","className","keys","filter","n","result","currentClass","classFinder","RegExp","replace","trim","test","ref","current","classList","remove","add","bind","attribute","removeAttribute","setAttribute","type","Type","innerHTML","rest","cached","__html"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,UAAT,EAAqBC,OAArB,EAA8BC,SAA9B,QAA+C,cAA/C;AACA,SAASC,UAAT,EAAqBC,IAArB,QAAiC,YAAjC;AACA;AACA;AACA;;AACA,SAASC,YAAT,QAA6B,cAA7B;AAEA;AACA;AACA;;AACA,SAASC,eAAT,QAAgC,SAAhC;AACA,SAASC,SAAT,QAA0B,SAA1B;;AAEA,MAAMC,QAAQ,GAAKC,IAAF,IAChBA,IAAI,IAAI,OAAOA,IAAP,KAAgB,QAAxB,IAAoC,CAAEC,KAAK,CAACC,OAAN,CAAeF,IAAf,CADvC;;AAGA,MAAMG,gBAAgB,GAAG,CAAEC,MAAF,EAAUC,MAAV,KAAsB;AAC9C,OAAM,MAA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ependencies\n */\nimport { useContext, useMemo, useEffect } from 'preact/hooks';\nimport { deepSignal, peek } from 'deepsignal';\n/**\n * Internal dependencies\n */\nimport { createPortal } from './portals.js';\n\n/**\n * Internal dependencies\n */\nimport { useSignalEffect } from './utils';\nimport { directive } from './hooks';\n\nconst isObject = ( item ) =>\n\titem && typeof item === 'object' && ! Array.isArray( item );\n\nconst mergeDeepSignals = ( target, source ) => {\n\tfor ( const k in source ) {\n\t\tif ( typeof peek( target, k ) === 'undefined' ) {\n\t\t\ttarget[ `$${ k }` ] = source[ `$${ k }` ];\n\t\t} else if (\n\t\t\tisObject( peek( target, k ) ) &&\n\t\t\tisObject( peek( source, k ) )\n\t\t) {\n\t\t\tmergeDeepSignals(\n\t\t\t\ttarget[ `$${ k }` ].peek(),\n\t\t\t\tsource[ `$${ k }` ].peek()\n\t\t\t);\n\t\t}\n\t}\n};\n\nexport default () => {\n\t// data-wp-context\n\tdirective(\n\t\t'context',\n\t\t( {\n\t\t\tdirectives: {\n\t\t\t\tcontext: { default: context },\n\t\t\t},\n\t\t\tprops: { children },\n\t\t\tcontext: inherited,\n\t\t} ) => {\n\t\t\tconst { Provider } = inherited;\n\t\t\tconst inheritedValue = useContext( inherited );\n\t\t\tconst value = useMemo( () => {\n\t\t\t\tconst localValue = deepSignal( context );\n\t\t\t\tmergeDeepSignals( localValue, inheritedValue );\n\t\t\t\treturn localValue;\n\t\t\t}, [ context, inheritedValue ] );\n\n\t\t\treturn <Provider value={ value }>{ children }</Provider>;\n\t\t},\n\t\t{ priority: 5 }\n\t);\n\n\t// data-wp-body\n\tdirective( 'body', ( { props: { children }, context: inherited } ) => {\n\t\tconst { Provider } = inherited;\n\t\tconst inheritedValue = useContext( inherited );\n\t\treturn createPortal(\n\t\t\t<Provider value={ inheritedValue }>{ children }</Provider>,\n\t\t\tdocument.body\n\t\t);\n\t} );\n\n\t// data-wp-effect--[name]\n\tdirective( 'effect', ( { directives: { effect }, context, evaluate } ) => {\n\t\tconst contextValue = useContext( context );\n\t\tObject.values( effect ).forEach( ( path ) => {\n\t\t\tuseSignalEffect( () => {\n\t\t\t\treturn evaluate( path, { context: contextValue } );\n\t\t\t} );\n\t\t} );\n\t} );\n\n\t// data-wp-init--[name]\n\tdirective( 'init', ( { directives: { init }, context, evaluate } ) => {\n\t\tconst contextValue = useContext( context );\n\t\tObject.values( init ).forEach( ( path ) => {\n\t\t\tuseEffect( () => {\n\t\t\t\treturn evaluate( path, { context: contextValue } );\n\t\t\t}, [] );\n\t\t} );\n\t} );\n\n\t// data-wp-on--[event]\n\tdirective( 'on', ( { directives: { on }, element, evaluate, context } ) => {\n\t\tconst contextValue = useContext( context );\n\t\tObject.entries( on ).forEach( ( [ name, path ] ) => {\n\t\t\telement.props[ `on${ name }` ] = ( event ) => {\n\t\t\t\tevaluate( path, { event, context: contextValue } );\n\t\t\t};\n\t\t} );\n\t} );\n\n\t// data-wp-class--[classname]\n\tdirective(\n\t\t'class',\n\t\t( {\n\t\t\tdirectives: { class: className },\n\t\t\telement,\n\t\t\tevaluate,\n\t\t\tcontext,\n\t\t} ) => {\n\t\t\tconst contextValue = useContext( context );\n\t\t\tObject.keys( className )\n\t\t\t\t.filter( ( n ) => n !== 'default' )\n\t\t\t\t.forEach( ( name ) => {\n\t\t\t\t\tconst result = evaluate( className[ name ], {\n\t\t\t\t\t\tclassName: name,\n\t\t\t\t\t\tcontext: contextValue,\n\t\t\t\t\t} );\n\t\t\t\t\tconst currentClass = element.props.class || '';\n\t\t\t\t\tconst classFinder = new RegExp(\n\t\t\t\t\t\t`(^|\\\\s)${ name }(\\\\s|$)`,\n\t\t\t\t\t\t'g'\n\t\t\t\t\t);\n\t\t\t\t\tif ( ! result )\n\t\t\t\t\t\telement.props.class = currentClass\n\t\t\t\t\t\t\t.replace( classFinder, ' ' )\n\t\t\t\t\t\t\t.trim();\n\t\t\t\t\telse if ( ! classFinder.test( currentClass ) )\n\t\t\t\t\t\telement.props.class = currentClass\n\t\t\t\t\t\t\t? `${ currentClass } ${ name }`\n\t\t\t\t\t\t\t: name;\n\n\t\t\t\t\tuseEffect( () => {\n\t\t\t\t\t\t// This seems necessary because Preact doesn't change the class\n\t\t\t\t\t\t// names on the hydration, so we have to do it manually. It doesn't\n\t\t\t\t\t\t// need deps because it only needs to do it the first time.\n\t\t\t\t\t\tif ( ! result ) {\n\t\t\t\t\t\t\telement.ref.current.classList.remove( name );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\telement.ref.current.classList.add( name );\n\t\t\t\t\t\t}\n\t\t\t\t\t}, [] );\n\t\t\t\t} );\n\t\t}\n\t);\n\n\t// data-wp-bind--[attribute]\n\tdirective(\n\t\t'bind',\n\t\t( { directives: { bind }, element, context, evaluate } ) => {\n\t\t\tconst contextValue = useContext( context );\n\t\t\tObject.entries( bind )\n\t\t\t\t.filter( ( n ) => n !== 'default' )\n\t\t\t\t.forEach( ( [ attribute, path ] ) => {\n\t\t\t\t\tconst result = evaluate( path, {\n\t\t\t\t\t\tcontext: contextValue,\n\t\t\t\t\t} );\n\t\t\t\t\telement.props[ attribute ] = result;\n\n\t\t\t\t\t// This seems necessary because Preact doesn't change the attributes\n\t\t\t\t\t// on the hydration, so we have to do it manually. It doesn't need\n\t\t\t\t\t// deps because it only needs to do it the first time.\n\t\t\t\t\tuseEffect( () => {\n\t\t\t\t\t\t// aria- and data- attributes have no boolean representation.\n\t\t\t\t\t\t// A `false` value is different from the attribute not being\n\t\t\t\t\t\t// present, so we can't remove it.\n\t\t\t\t\t\t// We follow Preact's logic: https://github.com/preactjs/preact/blob/ea49f7a0f9d1ff2c98c0bdd66aa0cbc583055246/src/diff/props.js#L131C24-L136\n\t\t\t\t\t\tif ( result === false && attribute[ 4 ] !== '-' ) {\n\t\t\t\t\t\t\telement.ref.current.removeAttribute( attribute );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\telement.ref.current.setAttribute(\n\t\t\t\t\t\t\t\tattribute,\n\t\t\t\t\t\t\t\tresult === true && attribute[ 4 ] !== '-'\n\t\t\t\t\t\t\t\t\t? ''\n\t\t\t\t\t\t\t\t\t: result\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}, [] );\n\t\t\t\t} );\n\t\t}\n\t);\n\n\t// data-wp-ignore\n\tdirective(\n\t\t'ignore',\n\t\t( {\n\t\t\telement: {\n\t\t\t\ttype: Type,\n\t\t\t\tprops: { innerHTML, ...rest },\n\t\t\t},\n\t\t} ) => {\n\t\t\t// Preserve the initial inner HTML.\n\t\t\tconst cached = useMemo( () => innerHTML, [] );\n\t\t\treturn (\n\t\t\t\t<Type\n\t\t\t\t\tdangerouslySetInnerHTML={ { __html: cached } }\n\t\t\t\t\t{ ...rest }\n\t\t\t\t/>\n\t\t\t);\n\t\t}\n\t);\n};\n"]}
@@ -1,145 +0,0 @@
1
- import { createElement } from "@wordpress/element";
2
-
3
- /**
4
- * External dependencies
5
- */
6
- import { h, options, createContext, cloneElement } from 'preact';
7
- import { useRef, useMemo } from 'preact/hooks';
8
- /**
9
- * Internal dependencies
10
- */
11
-
12
- import { rawStore as store } from './store'; // Main context.
13
-
14
- const context = createContext({}); // WordPress Directives.
15
-
16
- const directiveMap = {};
17
- const directivePriorities = {};
18
- export const directive = (name, cb, {
19
- priority = 10
20
- } = {}) => {
21
- directiveMap[name] = cb;
22
- directivePriorities[name] = priority;
23
- }; // Resolve the path to some property of the store object.
24
-
25
- const resolve = (path, ctx) => {
26
- let current = { ...store,
27
- context: ctx
28
- };
29
- path.split('.').forEach(p => current = current[p]);
30
- return current;
31
- }; // Generate the evaluate function.
32
-
33
-
34
- const getEvaluate = ({
35
- ref
36
- } = {}) => (path, extraArgs = {}) => {
37
- // If path starts with !, remove it and save a flag.
38
- const hasNegationOperator = path[0] === '!' && !!(path = path.slice(1));
39
- const value = resolve(path, extraArgs.context);
40
- const returnValue = typeof value === 'function' ? value({
41
- ref: ref.current,
42
- ...store,
43
- ...extraArgs
44
- }) : value;
45
- return hasNegationOperator ? !returnValue : returnValue;
46
- }; // Separate directives by priority. The resulting array contains objects
47
- // of directives grouped by same priority, and sorted in ascending order.
48
-
49
-
50
- const usePriorityLevels = directives => useMemo(() => {
51
- const byPriority = Object.entries(directives).reduce((acc, [name, values]) => {
52
- const priority = directivePriorities[name];
53
- if (!acc[priority]) acc[priority] = {};
54
- acc[priority][name] = values;
55
- return acc;
56
- }, {});
57
- return Object.entries(byPriority).sort(([p1], [p2]) => p1 - p2).map(([, obj]) => obj);
58
- }, [directives]); // Directive wrapper.
59
-
60
-
61
- const Directive = ({
62
- type,
63
- directives,
64
- props: originalProps
65
- }) => {
66
- const ref = useRef(null);
67
- const element = h(type, { ...originalProps,
68
- ref
69
- });
70
- const evaluate = useMemo(() => getEvaluate({
71
- ref
72
- }), []); // Add wrappers recursively for each priority level.
73
-
74
- const byPriorityLevel = usePriorityLevels(directives);
75
- return createElement(RecursivePriorityLevel, {
76
- directives: byPriorityLevel,
77
- element: element,
78
- evaluate: evaluate,
79
- originalProps: originalProps
80
- });
81
- }; // Priority level wrapper.
82
-
83
-
84
- const RecursivePriorityLevel = ({
85
- directives: [directives, ...rest],
86
- element,
87
- evaluate,
88
- originalProps
89
- }) => {
90
- // This element needs to be a fresh copy so we are not modifying an already
91
- // rendered element with Preact's internal properties initialized. This
92
- // prevents an error with changes in `element.props.children` not being
93
- // reflected in `element.__k`.
94
- element = cloneElement(element); // Recursively render the wrapper for the next priority level.
95
- //
96
- // Note that, even though we're instantiating a vnode with a
97
- // `RecursivePriorityLevel` here, its render function will not be executed
98
- // just yet. Actually, it will be delayed until the current render function
99
- // has finished. That ensures directives in the current priorty level have
100
- // run (and thus modified the passed `element`) before the next level.
101
-
102
- const children = rest.length > 0 ? createElement(RecursivePriorityLevel, {
103
- directives: rest,
104
- element: element,
105
- evaluate: evaluate,
106
- originalProps: originalProps
107
- }) : element;
108
- const props = { ...originalProps,
109
- children
110
- };
111
- const directiveArgs = {
112
- directives,
113
- props,
114
- element,
115
- context,
116
- evaluate
117
- };
118
-
119
- for (const d in directives) {
120
- const wrapper = directiveMap[d]?.(directiveArgs);
121
- if (wrapper !== undefined) props.children = wrapper;
122
- }
123
-
124
- return props.children;
125
- }; // Preact Options Hook called each time a vnode is created.
126
-
127
-
128
- const old = options.vnode;
129
-
130
- options.vnode = vnode => {
131
- if (vnode.props.__directives) {
132
- const props = vnode.props;
133
- const directives = props.__directives;
134
- delete props.__directives;
135
- vnode.props = {
136
- type: vnode.type,
137
- directives,
138
- props
139
- };
140
- vnode.type = Directive;
141
- }
142
-
143
- if (old) old(vnode);
144
- };
145
- //# sourceMappingURL=hooks.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/utils/interactivity/hooks.js"],"names":["h","options","createContext","cloneElement","useRef","useMemo","rawStore","store","context","directiveMap","directivePriorities","directive","name","cb","priority","resolve","path","ctx","current","split","forEach","p","getEvaluate","ref","extraArgs","hasNegationOperator","slice","value","returnValue","usePriorityLevels","directives","byPriority","Object","entries","reduce","acc","values","sort","p1","p2","map","obj","Directive","type","props","originalProps","element","evaluate","byPriorityLevel","RecursivePriorityLevel","rest","children","length","directiveArgs","d","wrapper","undefined","old","vnode","__directives"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,CAAT,EAAYC,OAAZ,EAAqBC,aAArB,EAAoCC,YAApC,QAAwD,QAAxD;AACA,SAASC,MAAT,EAAiBC,OAAjB,QAAgC,cAAhC;AACA;AACA;AACA;;AACA,SAASC,QAAQ,IAAIC,KAArB,QAAkC,SAAlC,C,CAEA;;AACA,MAAMC,OAAO,GAAGN,aAAa,CAAE,EAAF,CAA7B,C,CAEA;;AACA,MAAMO,YAAY,GAAG,EAArB;AACA,MAAMC,mBAAmB,GAAG,EAA5B;AACA,OAAO,MAAMC,SAAS,GAAG,CAAEC,IAAF,EAAQC,EAAR,EAAY;AAAEC,EAAAA,QAAQ,GAAG;AAAb,IAAoB,EAAhC,KAAwC;AAChEL,EAAAA,YAAY,CAAEG,IAAF,CAAZ,GAAuBC,E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GAAc;AACbD,MAAAA,IAAI,EAAEe,KAAK,CAACf,IADC;AAEbb,MAAAA,UAFa;AAGbc,MAAAA;AAHa,KAAd;AAKAc,IAAAA,KAAK,CAACf,IAAN,GAAaD,SAAb;AACA;;AAED,MAAKe,GAAL,EAAWA,GAAG,CAAEC,KAAF,CAAH;AACX,CAdD","sourcesContent":["/**\n * External dependencies\n */\nimport { h, options, createContext, cloneElement } from 'preact';\nimport { useRef, useMemo } from 'preact/hooks';\n/**\n * Internal dependencies\n */\nimport { rawStore as store } from './store';\n\n// Main context.\nconst context = createContext( {} );\n\n// WordPress Directives.\nconst directiveMap = {};\nconst directivePriorities = {};\nexport const directive = ( name, cb, { priority = 10 } = {} ) => {\n\tdirectiveMap[ name ] = cb;\n\tdirectivePriorities[ name ] = priority;\n};\n\n// Resolve the path to some property of the store object.\nconst resolve = ( path, ctx ) => {\n\tlet current = { ...store, context: ctx };\n\tpath.split( '.' ).forEach( ( p ) => ( current = current[ p ] ) );\n\treturn current;\n};\n\n// Generate the evaluate function.\nconst getEvaluate =\n\t( { ref } = {} ) =>\n\t( path, extraArgs = {} ) => {\n\t\t// If path starts with !, remove it and save a flag.\n\t\tconst hasNegationOperator =\n\t\t\tpath[ 0 ] === '!' && !! ( path = path.slice( 1 ) );\n\t\tconst value = resolve( path, extraArgs.context );\n\t\tconst returnValue =\n\t\t\ttypeof value === 'function'\n\t\t\t\t? value( {\n\t\t\t\t\t\tref: ref.current,\n\t\t\t\t\t\t...store,\n\t\t\t\t\t\t...extraArgs,\n\t\t\t\t } )\n\t\t\t\t: value;\n\t\treturn hasNegationOperator ? ! returnValue : returnValue;\n\t};\n\n// Separate directives by priority. The resulting array contains objects\n// of directives grouped by same priority, and sorted in ascending order.\nconst usePriorityLevels = ( directives ) =>\n\tuseMemo( () => {\n\t\tconst byPriority = Object.entries( directives ).reduce(\n\t\t\t( acc, [ name, values ] ) => {\n\t\t\t\tconst priority = directivePriorities[ name ];\n\t\t\t\tif ( ! acc[ priority ] ) acc[ priority ] = {};\n\t\t\t\tacc[ priority ][ name ] = values;\n\n\t\t\t\treturn acc;\n\t\t\t},\n\t\t\t{}\n\t\t);\n\n\t\treturn Object.entries( byPriority )\n\t\t\t.sort( ( [ p1 ], [ p2 ] ) => p1 - p2 )\n\t\t\t.map( ( [ , obj ] ) => obj );\n\t}, [ directives ] );\n\n// Directive wrapper.\nconst Directive = ( { type, directives, props: originalProps } ) => {\n\tconst ref = useRef( null );\n\tconst element = h( type, { ...originalProps, ref } );\n\tconst evaluate = useMemo( () => getEvaluate( { ref } ), [] );\n\n\t// Add wrappers recursively for each priority level.\n\tconst byPriorityLevel = usePriorityLevels( directives );\n\treturn (\n\t\t<RecursivePriorityLevel\n\t\t\tdirectives={ byPriorityLevel }\n\t\t\telement={ element }\n\t\t\tevaluate={ evaluate }\n\t\t\toriginalProps={ originalProps }\n\t\t/>\n\t);\n};\n\n// Priority level wrapper.\nconst RecursivePriorityLevel = ( {\n\tdirectives: [ directives, ...rest ],\n\telement,\n\tevaluate,\n\toriginalProps,\n} ) => {\n\t// This element needs to be a fresh copy so we are not modifying an already\n\t// rendered element with Preact's internal properties initialized. This\n\t// prevents an error with changes in `element.props.children` not being\n\t// reflected in `element.__k`.\n\telement = cloneElement( element );\n\n\t// Recursively render the wrapper for the next priority level.\n\t//\n\t// Note that, even though we're instantiating a vnode with a\n\t// `RecursivePriorityLevel` here, its render function will not be executed\n\t// just yet. Actually, it will be delayed until the current render function\n\t// has finished. That ensures directives in the current priorty level have\n\t// run (and thus modified the passed `element`) before the next level.\n\tconst children =\n\t\trest.length > 0 ? (\n\t\t\t<RecursivePriorityLevel\n\t\t\t\tdirectives={ rest }\n\t\t\t\telement={ element }\n\t\t\t\tevaluate={ evaluate }\n\t\t\t\toriginalProps={ originalProps }\n\t\t\t/>\n\t\t) : (\n\t\t\telement\n\t\t);\n\n\tconst props = { ...originalProps, children };\n\tconst directiveArgs = { directives, props, element, context, evaluate };\n\n\tfor ( const d in directives ) {\n\t\tconst wrapper = directiveMap[ d ]?.( directiveArgs );\n\t\tif ( wrapper !== undefined ) props.children = wrapper;\n\t}\n\n\treturn props.children;\n};\n\n// Preact Options Hook called each time a vnode is created.\nconst old = options.vnode;\noptions.vnode = ( vnode ) => {\n\tif ( vnode.props.__directives ) {\n\t\tconst props = vnode.props;\n\t\tconst directives = props.__directives;\n\t\tdelete props.__directives;\n\t\tvnode.props = {\n\t\t\ttype: vnode.type,\n\t\t\tdirectives,\n\t\t\tprops,\n\t\t};\n\t\tvnode.type = Directive;\n\t}\n\n\tif ( old ) old( vnode );\n};\n"]}
@@ -1,21 +0,0 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { hydrate } from 'preact';
5
- /**
6
- * Internal dependencies
7
- */
8
-
9
- import { toVdom, hydratedIslands } from './vdom';
10
- import { createRootFragment } from './utils';
11
- import { directivePrefix } from './constants';
12
- export const init = async () => {
13
- document.querySelectorAll(`[data-${directivePrefix}-interactive]`).forEach(node => {
14
- if (!hydratedIslands.has(node)) {
15
- const fragment = createRootFragment(node.parentNode, node);
16
- const vdom = toVdom(node);
17
- hydrate(vdom, fragment);
18
- }
19
- });
20
- };
21
- //# sourceMappingURL=hydration.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/utils/interactivity/hydration.js"],"names":["hydrate","toVdom","hydratedIslands","createRootFragment","directivePrefix","init","document","querySelectorAll","forEach","node","has","fragment","parentNode","vdom"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,OAAT,QAAwB,QAAxB;AACA;AACA;AACA;;AACA,SAASC,MAAT,EAAiBC,eAAjB,QAAwC,QAAxC;AACA,SAASC,kBAAT,QAAmC,SAAnC;AACA,SAASC,eAAT,QAAgC,aAAhC;AAEA,OAAO,MAAMC,IAAI,GAAG,YAAY;AAC/BC,EAAAA,QAAQ,CACNC,gBADF,CACqB,SAASH,eAAiB,eAD/C,EAEEI,OAFF,CAEaC,IAAF,IAAY;AACrB,QAAK,CAAEP,eAAe,CAACQ,GAAhB,CAAqBD,IAArB,CAAP,EAAqC;AACpC,YAAME,QAAQ,GAAGR,kBAAkB,CAAEM,IAAI,CAACG,UAAP,EAAmBH,IAAnB,CAAnC;AACA,YAAMI,IAAI,GAAGZ,MAAM,CAAEQ,IAAF,CAAnB;AACAT,MAAAA,OAAO,CAAEa,IAAF,EAAQF,QAAR,CAAP;AACA;AACD,GARF;AASA,CAVM","sourcesContent":["/**\n * External dependencies\n */\nimport { hydrate } from 'preact';\n/**\n * Internal dependencies\n */\nimport { toVdom, hydratedIslands } from './vdom';\nimport { createRootFragment } from './utils';\nimport { directivePrefix } from './constants';\n\nexport const init = async () => {\n\tdocument\n\t\t.querySelectorAll( `[data-${ directivePrefix }-interactive]` )\n\t\t.forEach( ( node ) => {\n\t\t\tif ( ! hydratedIslands.has( node ) ) {\n\t\t\t\tconst fragment = createRootFragment( node.parentNode, node );\n\t\t\t\tconst vdom = toVdom( node );\n\t\t\t\thydrate( vdom, fragment );\n\t\t\t}\n\t\t} );\n};\n"]}
@@ -1,15 +0,0 @@
1
- /**
2
- * Internal dependencies
3
- */
4
- import registerDirectives from './directives';
5
- import { init } from './hydration';
6
- export { store } from './store';
7
- /**
8
- * Initialize the Interactivity API.
9
- */
10
-
11
- registerDirectives();
12
- document.addEventListener('DOMContentLoaded', async () => {
13
- await init();
14
- });
15
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/utils/interactivity/index.js"],"names":["registerDirectives","init","store","document","addEventListener"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,kBAAP,MAA+B,cAA/B;AACA,SAASC,IAAT,QAAqB,aAArB;AACA,SAASC,KAAT,QAAsB,SAAtB;AAEA;AACA;AACA;;AACAF,kBAAkB;AAElBG,QAAQ,CAACC,gBAAT,CAA2B,kBAA3B,EAA+C,YAAY;AAC1D,QAAMH,IAAI,EAAV;AACA,CAFD","sourcesContent":["/**\n * Internal dependencies\n */\nimport registerDirectives from './directives';\nimport { init } from './hydration';\nexport { store } from './store';\n\n/**\n * Initialize the Interactivity API.\n */\nregisterDirectives();\n\ndocument.addEventListener( 'DOMContentLoaded', async () => {\n\tawait init();\n} );\n"]}
@@ -1,100 +0,0 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { createElement, render } from 'preact';
5
- /**
6
- * @param {import('../../src/index').RenderableProps<{ context: any }>} props
7
- */
8
-
9
- function ContextProvider(props) {
10
- this.getChildContext = () => props.context;
11
-
12
- return props.children;
13
- }
14
- /**
15
- * Portal component
16
- *
17
- * @this {import('./internal').Component}
18
- * @param {object | null | undefined} props
19
- *
20
- * TODO: use createRoot() instead of fake root
21
- */
22
-
23
-
24
- function Portal(props) {
25
- const _this = this;
26
-
27
- const container = props._container;
28
-
29
- _this.componentWillUnmount = function () {
30
- render(null, _this._temp);
31
- _this._temp = null;
32
- _this._container = null;
33
- }; // When we change container we should clear our old container and
34
- // indicate a new mount.
35
-
36
-
37
- if (_this._container && _this._container !== container) {
38
- _this.componentWillUnmount();
39
- } // When props.vnode is undefined/false/null we are dealing with some kind of
40
- // conditional vnode. This should not trigger a render.
41
-
42
-
43
- if (props._vnode) {
44
- if (!_this._temp) {
45
- _this._container = container; // Create a fake DOM parent node that manages a subset of `container`'s children:
46
-
47
- _this._temp = {
48
- nodeType: 1,
49
- parentNode: container,
50
- childNodes: [],
51
-
52
- appendChild(child) {
53
- this.childNodes.push(child);
54
-
55
- _this._container.appendChild(child);
56
- },
57
-
58
- insertBefore(child) {
59
- this.childNodes.push(child);
60
-
61
- _this._container.appendChild(child);
62
- },
63
-
64
- removeChild(child) {
65
- this.childNodes.splice( // eslint-disable-next-line no-bitwise
66
- this.childNodes.indexOf(child) >>> 1, 1);
67
-
68
- _this._container.removeChild(child);
69
- }
70
-
71
- };
72
- } // Render our wrapping element into temp.
73
-
74
-
75
- render(createElement(ContextProvider, {
76
- context: _this.context
77
- }, props._vnode), _this._temp);
78
- } // When we come from a conditional render, on a mounted
79
- // portal we should clear the DOM.
80
- else if (_this._temp) {
81
- _this.componentWillUnmount();
82
- }
83
- }
84
- /**
85
- * Create a `Portal` to continue rendering the vnode tree at a different DOM node
86
- *
87
- * @param {import('./internal').VNode} vnode The vnode to render
88
- * @param {import('./internal').PreactElement} container The DOM node to continue rendering in to.
89
- */
90
-
91
-
92
- export function createPortal(vnode, container) {
93
- const el = createElement(Portal, {
94
- _vnode: vnode,
95
- _container: container
96
- });
97
- el.containerInfo = container;
98
- return el;
99
- }
100
- //# sourceMappingURL=portals.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/utils/interactivity/portals.js"],"names":["createElement","render","ContextProvider","props","getChildContext","context","children","Portal","_this","container","_container","componentWillUnmount","_temp","_vnode","nodeType","parentNode","childNodes","appendChild","child","push","insertBefore","removeChild","splice","indexOf","createPortal","vnode","el","containerInfo"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,aAAT,EAAwBC,MAAxB,QAAsC,QAAtC;AAEA;AACA;AACA;;AACA,SAASC,eAAT,CAA0BC,KAA1B,EAAkC;AACjC,OAAKC,eAAL,GAAuB,MAAMD,KAAK,CAACE,OAAnC;;AACA,SAAOF,KAAK,CAACG,QAAb;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASC,MAAT,CAAiBJ,KAAjB,EAAyB;AACxB,QAAMK,KAAK,GAAG,IAAd;;AACA,QAAMC,SAAS,GAAGN,KAAK,CAACO,UAAxB;;AAEAF,EAAAA,KAAK,CAACG,oBAAN,GAA6B,YAAY;AACxCV,IAAAA,MAAM,CAAE,IAAF,EAAQO,KAAK,CAACI,KAAd,CAAN;AACAJ,IAAAA,KAAK,CAACI,KAAN,GAAc,IAAd;AACAJ,IAAAA,KAAK,CAACE,UAAN,GAAmB,IAAnB;AACA,GAJD,CAJwB,CAUxB;AACA;;;AACA,MAAKF,KAAK,CAACE,UAAN,IAAoBF,KAAK,CAACE,UAAN,KAAqBD,SAA9C,EAA0D;AACzDD,IA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A;AACA;;;AACA,OAAO,SAASa,YAAT,CAAuBC,KAAvB,EAA8BhB,SAA9B,EAA0C;AAChD,QAAMiB,EAAE,GAAG1B,aAAa,CAAEO,MAAF,EAAU;AACjCM,IAAAA,MAAM,EAAEY,KADyB;AAEjCf,IAAAA,UAAU,EAAED;AAFqB,GAAV,CAAxB;AAIAiB,EAAAA,EAAE,CAACC,aAAH,GAAmBlB,SAAnB;AACA,SAAOiB,EAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { createElement, render } from 'preact';\n\n/**\n * @param {import('../../src/index').RenderableProps<{ context: any }>} props\n */\nfunction ContextProvider( props ) {\n\tthis.getChildContext = () => props.context;\n\treturn props.children;\n}\n\n/**\n * Portal component\n *\n * @this {import('./internal').Component}\n * @param {object | null | undefined} props\n *\n * TODO: use createRoot() instead of fake root\n */\nfunction Portal( props ) {\n\tconst _this = this;\n\tconst container = props._container;\n\n\t_this.componentWillUnmount = function () {\n\t\trender( null, _this._temp );\n\t\t_this._temp = null;\n\t\t_this._container = null;\n\t};\n\n\t// When we change container we should clear our old container and\n\t// indicate a new mount.\n\tif ( _this._container && _this._container !== container ) {\n\t\t_this.componentWillUnmount();\n\t}\n\n\t// When props.vnode is undefined/false/null we are dealing with some kind of\n\t// conditional vnode. This should not trigger a render.\n\tif ( props._vnode ) {\n\t\tif ( ! _this._temp ) {\n\t\t\t_this._container = container;\n\n\t\t\t// Create a fake DOM parent node that manages a subset of `container`'s children:\n\t\t\t_this._temp = {\n\t\t\t\tnodeType: 1,\n\t\t\t\tparentNode: container,\n\t\t\t\tchildNodes: [],\n\t\t\t\tappendChild( child ) {\n\t\t\t\t\tthis.childNodes.push( child );\n\t\t\t\t\t_this._container.appendChild( child );\n\t\t\t\t},\n\t\t\t\tinsertBefore( child ) {\n\t\t\t\t\tthis.childNodes.push( child );\n\t\t\t\t\t_this._container.appendChild( child );\n\t\t\t\t},\n\t\t\t\tremoveChild( child ) {\n\t\t\t\t\tthis.childNodes.splice(\n\t\t\t\t\t\t// eslint-disable-next-line no-bitwise\n\t\t\t\t\t\tthis.childNodes.indexOf( child ) >>> 1,\n\t\t\t\t\t\t1\n\t\t\t\t\t);\n\t\t\t\t\t_this._container.removeChild( child );\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\n\t\t// Render our wrapping element into temp.\n\t\trender(\n\t\t\tcreateElement(\n\t\t\t\tContextProvider,\n\t\t\t\t{ context: _this.context },\n\t\t\t\tprops._vnode\n\t\t\t),\n\t\t\t_this._temp\n\t\t);\n\t}\n\t// When we come from a conditional render, on a mounted\n\t// portal we should clear the DOM.\n\telse if ( _this._temp ) {\n\t\t_this.componentWillUnmount();\n\t}\n}\n\n/**\n * Create a `Portal` to continue rendering the vnode tree at a different DOM node\n *\n * @param {import('./internal').VNode} vnode The vnode to render\n * @param {import('./internal').PreactElement} container The DOM node to continue rendering in to.\n */\nexport function createPortal( vnode, container ) {\n\tconst el = createElement( Portal, {\n\t\t_vnode: vnode,\n\t\t_container: container,\n\t} );\n\tel.containerInfo = container;\n\treturn el;\n}\n"]}
@@ -1,55 +0,0 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { deepSignal } from 'deepsignal';
5
-
6
- const isObject = item => item && typeof item === 'object' && !Array.isArray(item);
7
-
8
- const deepMerge = (target, source) => {
9
- if (isObject(target) && isObject(source)) {
10
- for (const key in source) {
11
- if (isObject(source[key])) {
12
- if (!target[key]) Object.assign(target, {
13
- [key]: {}
14
- });
15
- deepMerge(target[key], source[key]);
16
- } else {
17
- Object.assign(target, {
18
- [key]: source[key]
19
- });
20
- }
21
- }
22
- }
23
- };
24
-
25
- const getSerializedState = () => {
26
- // TODO: change the store tag ID for a better one.
27
- const storeTag = document.querySelector(`script[type="application/json"]#store`);
28
- if (!storeTag) return {};
29
-
30
- try {
31
- const {
32
- state
33
- } = JSON.parse(storeTag.textContent);
34
- if (isObject(state)) return state;
35
- throw Error('Parsed state is not an object');
36
- } catch (e) {
37
- // eslint-disable-next-line no-console
38
- console.log(e);
39
- }
40
-
41
- return {};
42
- };
43
-
44
- const rawState = getSerializedState();
45
- export const rawStore = {
46
- state: deepSignal(rawState)
47
- };
48
- export const store = ({
49
- state,
50
- ...block
51
- }) => {
52
- deepMerge(rawStore, block);
53
- deepMerge(rawState, state);
54
- };
55
- //# sourceMappingURL=store.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/utils/interactivity/store.js"],"names":["deepSignal","isObject","item","Array","isArray","deepMerge","target","source","key","Object","assign","getSerializedState","storeTag","document","querySelector","state","JSON","parse","textContent","Error","e","console","log","rawState","rawStore","store","block"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,UAAT,QAA2B,YAA3B;;AAEA,MAAMC,QAAQ,GAAKC,IAAF,IAChBA,IAAI,IAAI,OAAOA,IAAP,KAAgB,QAAxB,IAAoC,CAAEC,KAAK,CAACC,OAAN,CAAeF,IAAf,CADvC;;AAGA,MAAMG,SAAS,GAAG,CAAEC,MAAF,EAAUC,MAAV,KAAsB;AACvC,MAAKN,QAAQ,CAAEK,MAAF,CAAR,IAAsBL,QAAQ,CAAEM,MAAF,CAAnC,EAAgD;AAC/C,SAAM,MAAMC,GAAZ,IAAmBD,MAAnB,EAA4B;AAC3B,UAAKN,QAAQ,CAAEM,MAAM,CAAEC,GAAF,CAAR,CAAb,EAAiC;AAChC,YAAK,CAAEF,MAAM,CAAEE,GAAF,CAAb,EAAuBC,MAAM,CAACC,MAAP,CAAeJ,MAAf,EAAuB;AAAE,WAAEE,GAAF,GAAS;AAAX,SAAvB;AACvBH,QAAAA,SAAS,CAAEC,MAAM,CAAEE,GAAF,CAAR,EAAiBD,MAAM,CAAEC,GAAF,CAAvB,CAAT;AACA,OAHD,MAGO;AACNC,QAAAA,MAAM,CAACC,MAAP,CAAeJ,MAAf,EAAuB;AAAE,WAAEE,GAAF,GAASD,MAAM,CAAEC,GAAF;AAAjB,SAAvB;AACA;AACD;AACD;AACD,CAXD;;AAaA,MAAMG,kBAAkB,GAAG,MAAM;AAChC;AACA,QAAMC,QAAQ,GAAGC,QAAQ,CAACC,aAAT,CACf,uCADe,CAAjB;AAGA,MAAK,CAAEF,QAAP,EAAkB,OAAO,EAAP;;AAClB,MAAI;AACH,UAAM;AAAEG,MAAAA;AAAF,QAAYC,IAAI,CAACC,KAAL,CAAYL,QAAQ,CAACM,WAArB,CAAlB;AACA,QAAKjB,QAAQ,CAAEc,KAAF,CAAb,EAAyB,OAAOA,KAAP;AACzB,UAAMI,KAAK,CAAE,+BAAF,CAAX;AACA,GAJD,CAIE,OAAQC,CAAR,EAAY;AACb;AACAC,IAAAA,OAAO,CAACC,GAAR,CAAaF,CAAb;AACA;;AACD,SAAO,EAAP;AACA,CAfD;;AAiBA,MAAMG,QAAQ,GAAGZ,kBAAkB,EAAnC;AACA,OAAO,MAAMa,QAAQ,GAAG;AAAET,EAAAA,KAAK,EAAEf,UAAU,CAAEuB,QAAF;AAAnB,CAAjB;AAEP,OAAO,MAAME,KAAK,GAAG,CAAE;AAAEV,EAAAA,KAAF;AAAS,KAAGW;AAAZ,CAAF,KAA2B;AAC/CrB,EAAAA,SAAS,CAAEmB,QAAF,EAAYE,KAAZ,CAAT;AACArB,EAAAA,SAAS,CAAEkB,QAAF,EAAYR,KAAZ,CAAT;AACA,CAHM","sourcesContent":["/**\n * External dependencies\n */\nimport { deepSignal } from 'deepsignal';\n\nconst isObject = ( item ) =>\n\titem && typeof item === 'object' && ! Array.isArray( item );\n\nconst deepMerge = ( target, source ) => {\n\tif ( isObject( target ) && isObject( source ) ) {\n\t\tfor ( const key in source ) {\n\t\t\tif ( isObject( source[ key ] ) ) {\n\t\t\t\tif ( ! target[ key ] ) Object.assign( target, { [ key ]: {} } );\n\t\t\t\tdeepMerge( target[ key ], source[ key ] );\n\t\t\t} else {\n\t\t\t\tObject.assign( target, { [ key ]: source[ key ] } );\n\t\t\t}\n\t\t}\n\t}\n};\n\nconst getSerializedState = () => {\n\t// TODO: change the store tag ID for a better one.\n\tconst storeTag = document.querySelector(\n\t\t`script[type=\"application/json\"]#store`\n\t);\n\tif ( ! storeTag ) return {};\n\ttry {\n\t\tconst { state } = JSON.parse( storeTag.textContent );\n\t\tif ( isObject( state ) ) return state;\n\t\tthrow Error( 'Parsed state is not an object' );\n\t} catch ( e ) {\n\t\t// eslint-disable-next-line no-console\n\t\tconsole.log( e );\n\t}\n\treturn {};\n};\n\nconst rawState = getSerializedState();\nexport const rawStore = { state: deepSignal( rawState ) };\n\nexport const store = ( { state, ...block } ) => {\n\tdeepMerge( rawStore, block );\n\tdeepMerge( rawState, state );\n};\n"]}
@@ -1,75 +0,0 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { useRef, useEffect } from 'preact/hooks';
5
- import { effect } from '@preact/signals';
6
-
7
- function afterNextFrame(callback) {
8
- const done = () => {
9
- window.cancelAnimationFrame(raf);
10
- setTimeout(callback);
11
- };
12
-
13
- const raf = window.requestAnimationFrame(done);
14
- } // Using the mangled properties:
15
- // this.c: this._callback
16
- // this.x: this._compute
17
- // https://github.com/preactjs/signals/blob/main/mangle.json
18
-
19
-
20
- function createFlusher(compute, notify) {
21
- let flush;
22
- const dispose = effect(function () {
23
- flush = this.c.bind(this);
24
- this.x = compute;
25
- this.c = notify;
26
- return compute();
27
- });
28
- return {
29
- flush,
30
- dispose
31
- };
32
- } // Version of `useSignalEffect` with a `useEffect`-like execution. This hook
33
- // implementation comes from this PR:
34
- // https://github.com/preactjs/signals/pull/290.
35
- //
36
- // We need to include it here in this repo until the mentioned PR is merged.
37
-
38
-
39
- export function useSignalEffect(cb) {
40
- const callback = useRef(cb);
41
- callback.current = cb;
42
- useEffect(() => {
43
- const execute = () => callback.current();
44
-
45
- const notify = () => afterNextFrame(eff.flush);
46
-
47
- const eff = createFlusher(execute, notify);
48
- return eff.dispose;
49
- }, []);
50
- } // For wrapperless hydration.
51
- // See https://gist.github.com/developit/f4c67a2ede71dc2fab7f357f39cff28c
52
-
53
- export const createRootFragment = (parent, replaceNode) => {
54
- replaceNode = [].concat(replaceNode);
55
- const s = replaceNode[replaceNode.length - 1].nextSibling;
56
-
57
- function insert(c, r) {
58
- parent.insertBefore(c, r || s);
59
- }
60
-
61
- return parent.__k = {
62
- nodeType: 1,
63
- parentNode: parent,
64
- firstChild: replaceNode[0],
65
- childNodes: replaceNode,
66
- insertBefore: insert,
67
- appendChild: insert,
68
-
69
- removeChild(c) {
70
- parent.removeChild(c);
71
- }
72
-
73
- };
74
- };
75
- //# sourceMappingURL=utils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/utils/interactivity/utils.js"],"names":["useRef","useEffect","effect","afterNextFrame","callback","done","window","cancelAnimationFrame","raf","setTimeout","requestAnimationFrame","createFlusher","compute","notify","flush","dispose","c","bind","x","useSignalEffect","cb","current","execute","eff","createRootFragment","parent","replaceNode","concat","s","length","nextSibling","insert","r","insertBefore","__k","nodeType","parentNode","firstChild","childNodes","appendChild","removeChild"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,MAAT,EAAiBC,SAAjB,QAAkC,cAAlC;AACA,SAASC,MAAT,QAAuB,iBAAvB;;AAEA,SAASC,cAAT,CAAyBC,QAAzB,EAAoC;AACnC,QAAMC,IAAI,GAAG,MAAM;AAClBC,IAAAA,MAAM,CAACC,oBAAP,CAA6BC,GAA7B;AACAC,IAAAA,UAAU,CAAEL,QAAF,CAAV;AACA,GAHD;;AAIA,QAAMI,GAAG,GAAGF,MAAM,CAACI,qBAAP,CAA8BL,IAA9B,CAAZ;AACA,C,CAED;AACA;AACA;AACA;;;AACA,SAASM,aAAT,CAAwBC,OAAxB,EAAiCC,MAAjC,EAA0C;AACzC,MAAIC,KAAJ;AACA,QAAMC,OAAO,GAAGb,MAAM,CAAE,YAAY;AACnCY,IAAAA,KAAK,GAAG,KAAKE,CAAL,CAAOC,IAAP,CAAa,IAAb,CAAR;AACA,SAAKC,CAAL,GAASN,OAAT;AACA,SAAKI,CAAL,GAASH,MAAT;AACA,WAAOD,OAAO,EAAd;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,EAAM;AAChBS,MAAAA,MAAM,CAACe,WAAP,CAAoBxB,CAApB;AACA;;AAToB,GAAtB;AAWA,CAjBM","sourcesContent":["/**\n * External dependencies\n */\nimport { useRef, useEffect } from 'preact/hooks';\nimport { effect } from '@preact/signals';\n\nfunction afterNextFrame( callback ) {\n\tconst done = () => {\n\t\twindow.cancelAnimationFrame( raf );\n\t\tsetTimeout( callback );\n\t};\n\tconst raf = window.requestAnimationFrame( done );\n}\n\n// Using the mangled properties:\n// this.c: this._callback\n// this.x: this._compute\n// https://github.com/preactjs/signals/blob/main/mangle.json\nfunction createFlusher( compute, notify ) {\n\tlet flush;\n\tconst dispose = effect( function () {\n\t\tflush = this.c.bind( this );\n\t\tthis.x = compute;\n\t\tthis.c = notify;\n\t\treturn compute();\n\t} );\n\treturn { flush, dispose };\n}\n\n// Version of `useSignalEffect` with a `useEffect`-like execution. This hook\n// implementation comes from this PR:\n// https://github.com/preactjs/signals/pull/290.\n//\n// We need to include it here in this repo until the mentioned PR is merged.\nexport function useSignalEffect( cb ) {\n\tconst callback = useRef( cb );\n\tcallback.current = cb;\n\n\tuseEffect( () => {\n\t\tconst execute = () => callback.current();\n\t\tconst notify = () => afterNextFrame( eff.flush );\n\t\tconst eff = createFlusher( execute, notify );\n\t\treturn eff.dispose;\n\t}, [] );\n}\n\n// For wrapperless hydration.\n// See https://gist.github.com/developit/f4c67a2ede71dc2fab7f357f39cff28c\nexport const createRootFragment = ( parent, replaceNode ) => {\n\treplaceNode = [].concat( replaceNode );\n\tconst s = replaceNode[ replaceNode.length - 1 ].nextSibling;\n\tfunction insert( c, r ) {\n\t\tparent.insertBefore( c, r || s );\n\t}\n\treturn ( parent.__k = {\n\t\tnodeType: 1,\n\t\tparentNode: parent,\n\t\tfirstChild: replaceNode[ 0 ],\n\t\tchildNodes: replaceNode,\n\t\tinsertBefore: insert,\n\t\tappendChild: insert,\n\t\tremoveChild( c ) {\n\t\t\tparent.removeChild( c );\n\t\t},\n\t} );\n};\n"]}
@@ -1,107 +0,0 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { h } from 'preact';
5
- /**
6
- * Internal dependencies
7
- */
8
-
9
- import { directivePrefix as p } from './constants';
10
- const ignoreAttr = `data-${p}-ignore`;
11
- const islandAttr = `data-${p}-interactive`;
12
- const fullPrefix = `data-${p}-`; // Regular expression for directive parsing.
13
-
14
- const directiveParser = new RegExp(`^data-${p}-` + // ${p} must be a prefix string, like 'wp'.
15
- // Match alphanumeric characters including hyphen-separated
16
- // segments. It excludes underscore intentionally to prevent confusion.
17
- // E.g., "custom-directive".
18
- '([a-z0-9]+(?:-[a-z0-9]+)*)' + // (Optional) Match '--' followed by any alphanumeric charachters. It
19
- // excludes underscore intentionally to prevent confusion, but it can
20
- // contain multiple hyphens. E.g., "--custom-prefix--with-more-info".
21
- '(?:--([a-z0-9][a-z0-9-]+))?$', 'i' // Case insensitive.
22
- );
23
- export const hydratedIslands = new WeakSet(); // Recursive function that transforms a DOM tree into vDOM.
24
-
25
- export function toVdom(root) {
26
- const treeWalker = document.createTreeWalker(root, 205 // ELEMENT + TEXT + COMMENT + CDATA_SECTION + PROCESSING_INSTRUCTION
27
- );
28
-
29
- function walk(node) {
30
- const {
31
- attributes,
32
- nodeType
33
- } = node;
34
- if (nodeType === 3) return [node.data];
35
-
36
- if (nodeType === 4) {
37
- const next = treeWalker.nextSibling();
38
- node.replaceWith(new window.Text(node.nodeValue));
39
- return [node.nodeValue, next];
40
- }
41
-
42
- if (nodeType === 8 || nodeType === 7) {
43
- const next = treeWalker.nextSibling();
44
- node.remove();
45
- return [null, next];
46
- }
47
-
48
- const props = {};
49
- const children = [];
50
- const directives = {};
51
- let hasDirectives = false;
52
- let ignore = false;
53
- let island = false;
54
-
55
- for (let i = 0; i < attributes.length; i++) {
56
- const n = attributes[i].name;
57
-
58
- if (n[fullPrefix.length] && n.slice(0, fullPrefix.length) === fullPrefix) {
59
- if (n === ignoreAttr) {
60
- ignore = true;
61
- } else if (n === islandAttr) {
62
- island = true;
63
- } else {
64
- hasDirectives = true;
65
- let val = attributes[i].value;
66
-
67
- try {
68
- val = JSON.parse(val);
69
- } catch (e) {}
70
-
71
- const [, prefix, suffix] = directiveParser.exec(n);
72
- directives[prefix] = directives[prefix] || {};
73
- directives[prefix][suffix || 'default'] = val;
74
- }
75
- } else if (n === 'ref') {
76
- continue;
77
- }
78
-
79
- props[n] = attributes[i].value;
80
- }
81
-
82
- if (ignore && !island) return [h(node.localName, { ...props,
83
- innerHTML: node.innerHTML,
84
- __directives: {
85
- ignore: true
86
- }
87
- })];
88
- if (island) hydratedIslands.add(node);
89
- if (hasDirectives) props.__directives = directives;
90
- let child = treeWalker.firstChild();
91
-
92
- if (child) {
93
- while (child) {
94
- const [vnode, nextChild] = walk(child);
95
- if (vnode) children.push(vnode);
96
- child = nextChild || treeWalker.nextSibling();
97
- }
98
-
99
- treeWalker.parentNode();
100
- }
101
-
102
- return [h(node.localName, props, children)];
103
- }
104
-
105
- return walk(treeWalker.currentNode);
106
- }
107
- //# sourceMappingURL=vdom.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/utils/interactivity/vdom.js"],"names":["h","directivePrefix","p","ignoreAttr","islandAttr","fullPrefix","directiveParser","RegExp","hydratedIslands","WeakSet","toVdom","root","treeWalker","document","createTreeWalker","walk","node","attributes","nodeType","data","next","nextSibling","replaceWith","window","Text","nodeValue","remove","props","children","directives","hasDirectives","ignore","island","i","length","n","name","slice","val","value","JSON","parse","e","prefix","suffix","exec","localName","innerHTML","__directives","add","child","firstChild","vnode","nextChild","push","parentNode","currentNode"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,CAAT,QAAkB,QAAlB;AACA;AACA;AACA;;AACA,SAASC,eAAe,IAAIC,CAA5B,QAAqC,aAArC;AAEA,MAAMC,UAAU,GAAI,QAAQD,CAAG,SAA/B;AACA,MAAME,UAAU,GAAI,QAAQF,CAAG,cAA/B;AACA,MAAMG,UAAU,GAAI,QAAQH,CAAG,GAA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AElBoB,MAAAA,SAAS,EAAE/B,IAAI,CAAC+B,SAFE;AAGlBC,MAAAA,YAAY,EAAE;AAAEjB,QAAAA,MAAM,EAAE;AAAV;AAHI,KAAlB,CADK,CAAP;AAOD,QAAKC,MAAL,EAAcxB,eAAe,CAACyC,GAAhB,CAAqBjC,IAArB;AAEd,QAAKc,aAAL,EAAqBH,KAAK,CAACqB,YAAN,GAAqBnB,UAArB;AAErB,QAAIqB,KAAK,GAAGtC,UAAU,CAACuC,UAAX,EAAZ;;AACA,QAAKD,KAAL,EAAa;AACZ,aAAQA,KAAR,EAAgB;AACf,cAAM,CAAEE,KAAF,EAASC,SAAT,IAAuBtC,IAAI,CAAEmC,KAAF,CAAjC;AACA,YAAKE,KAAL,EAAaxB,QAAQ,CAAC0B,IAAT,CAAeF,KAAf;AACbF,QAAAA,KAAK,GAAGG,SAAS,IAAIzC,UAAU,CAACS,WAAX,EAArB;AACA;;AACDT,MAAAA,UAAU,CAAC2C,UAAX;AACA;;AAED,WAAO,CAAEvD,CAAC,CAAEgB,IAAI,CAAC8B,SAAP,EAAkBnB,KAAlB,EAAyBC,QAAzB,CAAH,CAAP;AACA;;AAED,SAAOb,IAAI,CAAEH,UAAU,CAAC4C,WAAb,CAAX;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { h } from 'preact';\n/**\n * Internal dependencies\n */\nimport { directivePrefix as p } from './constants';\n\nconst ignoreAttr = `data-${ p }-ignore`;\nconst islandAttr = `data-${ p }-interactive`;\nconst fullPrefix = `data-${ p }-`;\n\n// Regular expression for directive parsing.\nconst directiveParser = new RegExp(\n\t`^data-${ p }-` + // ${p} must be a prefix string, like 'wp'.\n\t\t// Match alphanumeric characters including hyphen-separated\n\t\t// segments. It excludes underscore intentionally to prevent confusion.\n\t\t// E.g., \"custom-directive\".\n\t\t'([a-z0-9]+(?:-[a-z0-9]+)*)' +\n\t\t// (Optional) Match '--' followed by any alphanumeric charachters. It\n\t\t// excludes underscore intentionally to prevent confusion, but it can\n\t\t// contain multiple hyphens. E.g., \"--custom-prefix--with-more-info\".\n\t\t'(?:--([a-z0-9][a-z0-9-]+))?$',\n\t'i' // Case insensitive.\n);\n\nexport const hydratedIslands = new WeakSet();\n\n// Recursive function that transforms a DOM tree into vDOM.\nexport function toVdom( root ) {\n\tconst treeWalker = document.createTreeWalker(\n\t\troot,\n\t\t205 // ELEMENT + TEXT + COMMENT + CDATA_SECTION + PROCESSING_INSTRUCTION\n\t);\n\n\tfunction walk( node ) {\n\t\tconst { attributes, nodeType } = node;\n\n\t\tif ( nodeType === 3 ) return [ node.data ];\n\t\tif ( nodeType === 4 ) {\n\t\t\tconst next = treeWalker.nextSibling();\n\t\t\tnode.replaceWith( new window.Text( node.nodeValue ) );\n\t\t\treturn [ node.nodeValue, next ];\n\t\t}\n\t\tif ( nodeType === 8 || nodeType === 7 ) {\n\t\t\tconst next = treeWalker.nextSibling();\n\t\t\tnode.remove();\n\t\t\treturn [ null, next ];\n\t\t}\n\n\t\tconst props = {};\n\t\tconst children = [];\n\t\tconst directives = {};\n\t\tlet hasDirectives = false;\n\t\tlet ignore = false;\n\t\tlet island = false;\n\n\t\tfor ( let i = 0; i < attributes.length; i++ ) {\n\t\t\tconst n = attributes[ i ].name;\n\t\t\tif (\n\t\t\t\tn[ fullPrefix.length ] &&\n\t\t\t\tn.slice( 0, fullPrefix.length ) === fullPrefix\n\t\t\t) {\n\t\t\t\tif ( n === ignoreAttr ) {\n\t\t\t\t\tignore = true;\n\t\t\t\t} else if ( n === islandAttr ) {\n\t\t\t\t\tisland = true;\n\t\t\t\t} else {\n\t\t\t\t\thasDirectives = true;\n\t\t\t\t\tlet val = attributes[ i ].value;\n\t\t\t\t\ttry {\n\t\t\t\t\t\tval = JSON.parse( val );\n\t\t\t\t\t} catch ( e ) {}\n\t\t\t\t\tconst [ , prefix, suffix ] = directiveParser.exec( n );\n\t\t\t\t\tdirectives[ prefix ] = directives[ prefix ] || {};\n\t\t\t\t\tdirectives[ prefix ][ suffix || 'default' ] = val;\n\t\t\t\t}\n\t\t\t} else if ( n === 'ref' ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tprops[ n ] = attributes[ i ].value;\n\t\t}\n\n\t\tif ( ignore && ! island )\n\t\t\treturn [\n\t\t\t\th( node.localName, {\n\t\t\t\t\t...props,\n\t\t\t\t\tinnerHTML: node.innerHTML,\n\t\t\t\t\t__directives: { ignore: true },\n\t\t\t\t} ),\n\t\t\t];\n\t\tif ( island ) hydratedIslands.add( node );\n\n\t\tif ( hasDirectives ) props.__directives = directives;\n\n\t\tlet child = treeWalker.firstChild();\n\t\tif ( child ) {\n\t\t\twhile ( child ) {\n\t\t\t\tconst [ vnode, nextChild ] = walk( child );\n\t\t\t\tif ( vnode ) children.push( vnode );\n\t\t\t\tchild = nextChild || treeWalker.nextSibling();\n\t\t\t}\n\t\t\ttreeWalker.parentNode();\n\t\t}\n\n\t\treturn [ h( node.localName, props, children ) ];\n\t}\n\n\treturn walk( treeWalker.currentNode );\n}\n"]}
@@ -1,15 +0,0 @@
1
- /**
2
- * Internal dependencies
3
- */
4
- import { store } from '../utils/interactivity';
5
- import { browserSupportsPdfs as hasPdfPreview } from './utils';
6
-
7
- store( {
8
- selectors: {
9
- core: {
10
- file: {
11
- hasPdfPreview,
12
- },
13
- },
14
- },
15
- } );