@wardic/solid 2.2.0 → 3.0.0-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (541) hide show
  1. package/README.md +39 -18
  2. package/dist/browser/animation-frame.js +1 -1
  3. package/dist/browser/animation-frame.js.map +1 -1
  4. package/dist/browser/config-view.js +35 -6
  5. package/dist/browser/config-view.js.map +1 -1
  6. package/dist/browser/create-batch.js +1 -1
  7. package/dist/browser/diagnostic-codes.js +216 -0
  8. package/dist/browser/diagnostic-codes.js.map +1 -0
  9. package/dist/browser/diagnostics.js +79 -0
  10. package/dist/browser/diagnostics.js.map +1 -0
  11. package/dist/browser/element-style.js +61 -7
  12. package/dist/browser/element-style.js.map +1 -1
  13. package/dist/browser/element.js +24 -6
  14. package/dist/browser/element.js.map +1 -1
  15. package/dist/browser/feature-section.js +5 -13
  16. package/dist/browser/feature-section.js.map +1 -1
  17. package/dist/browser/frame-effect.js +1 -1
  18. package/dist/browser/frame-effect.js.map +1 -1
  19. package/dist/browser/gesture-callbacks.js +1 -1
  20. package/dist/browser/gesture-callbacks.js.map +1 -1
  21. package/dist/browser/hooks/auto.js +270 -0
  22. package/dist/browser/hooks/auto.js.map +1 -0
  23. package/dist/browser/hooks/config-scope.js +120 -0
  24. package/dist/browser/hooks/config-scope.js.map +1 -0
  25. package/dist/browser/hooks/config.js +37 -0
  26. package/dist/browser/hooks/config.js.map +1 -0
  27. package/dist/browser/hooks/drag.js +633 -0
  28. package/dist/browser/hooks/drag.js.map +1 -0
  29. package/dist/browser/hooks/elements.js +183 -0
  30. package/dist/browser/hooks/elements.js.map +1 -0
  31. package/dist/browser/hooks/group.js +28 -0
  32. package/dist/browser/hooks/group.js.map +1 -0
  33. package/dist/browser/hooks/index.js +10 -0
  34. package/dist/browser/hooks/index.js.map +1 -0
  35. package/dist/browser/hooks/kept.js +32 -0
  36. package/dist/browser/hooks/kept.js.map +1 -0
  37. package/dist/browser/hooks/layout-group-of.js +39 -0
  38. package/dist/browser/hooks/layout-group-of.js.map +1 -0
  39. package/dist/browser/hooks/layout-group.js +92 -0
  40. package/dist/browser/hooks/layout-group.js.map +1 -0
  41. package/dist/browser/hooks/make-ward.js +157 -0
  42. package/dist/browser/hooks/make-ward.js.map +1 -0
  43. package/dist/browser/hooks/presence-scope.js +88 -0
  44. package/dist/browser/hooks/presence-scope.js.map +1 -0
  45. package/dist/browser/hooks/presence.js +24 -0
  46. package/dist/browser/hooks/presence.js.map +1 -0
  47. package/dist/browser/hooks/props.js +148 -0
  48. package/dist/browser/hooks/props.js.map +1 -0
  49. package/dist/browser/hooks/reads.js +241 -0
  50. package/dist/browser/hooks/reads.js.map +1 -0
  51. package/dist/browser/hooks/refs.js +87 -0
  52. package/dist/browser/hooks/refs.js.map +1 -0
  53. package/dist/browser/hooks/reorder-elements.js +269 -0
  54. package/dist/browser/hooks/reorder-elements.js.map +1 -0
  55. package/dist/browser/hooks/reorder.js +176 -0
  56. package/dist/browser/hooks/reorder.js.map +1 -0
  57. package/dist/browser/hooks/rune.js +800 -0
  58. package/dist/browser/hooks/rune.js.map +1 -0
  59. package/dist/browser/hooks/server-features.client.js +2 -0
  60. package/dist/browser/hooks/server-features.client.js.map +1 -0
  61. package/dist/browser/hooks/server-features.js +13 -0
  62. package/dist/browser/hooks/server-features.js.map +1 -0
  63. package/dist/browser/hooks/settings.js +29 -0
  64. package/dist/browser/hooks/settings.js.map +1 -0
  65. package/dist/browser/hooks/setup.js +154 -0
  66. package/dist/browser/hooks/setup.js.map +1 -0
  67. package/dist/browser/hooks/stage.js +117 -0
  68. package/dist/browser/hooks/stage.js.map +1 -0
  69. package/dist/browser/hooks/ward.js +2212 -0
  70. package/dist/browser/hooks/ward.js.map +1 -0
  71. package/dist/browser/hooks/wardic-provider.js +29 -0
  72. package/dist/browser/hooks/wardic-provider.js.map +1 -0
  73. package/dist/browser/hooks/wardic-scope.js +68 -0
  74. package/dist/browser/hooks/wardic-scope.js.map +1 -0
  75. package/dist/browser/hooks/wards.js +563 -0
  76. package/dist/browser/hooks/wards.js.map +1 -0
  77. package/dist/browser/index.js +23 -11
  78. package/dist/browser/index.js.map +1 -1
  79. package/dist/browser/layout.js +7 -58
  80. package/dist/browser/layout.js.map +1 -1
  81. package/dist/browser/lazy-batch-gestures.js +1 -1
  82. package/dist/browser/lifecycle.js +37 -0
  83. package/dist/browser/lifecycle.js.map +1 -1
  84. package/dist/browser/presence-handle.js +28 -12
  85. package/dist/browser/presence-handle.js.map +1 -1
  86. package/dist/browser/presence.js +3 -1
  87. package/dist/browser/presence.js.map +1 -1
  88. package/dist/browser/provider.js +124 -90
  89. package/dist/browser/provider.js.map +1 -1
  90. package/dist/browser/reorder-components.js +50 -0
  91. package/dist/browser/reorder-components.js.map +1 -0
  92. package/dist/browser/reorder.js +51 -278
  93. package/dist/browser/reorder.js.map +1 -1
  94. package/dist/browser/runtime.js +26 -15
  95. package/dist/browser/runtime.js.map +1 -1
  96. package/dist/browser/spans-check.js +8 -3
  97. package/dist/browser/spans-check.js.map +1 -1
  98. package/dist/browser/stage.js.map +1 -1
  99. package/dist/browser/unstable/v2/index.js +0 -8
  100. package/dist/browser/unstable/v2/index.js.map +1 -1
  101. package/dist/browser/v1/index.js +1 -1
  102. package/dist/browser/v1/index.js.map +1 -1
  103. package/dist/browser/variant-node.js +4 -2
  104. package/dist/browser/variant-node.js.map +1 -1
  105. package/dist/browser/w.js +33 -3
  106. package/dist/browser/w.js.map +1 -1
  107. package/dist/browser/ward.js +594 -61
  108. package/dist/browser/ward.js.map +1 -1
  109. package/dist/browser/wardic-config.js +62 -29
  110. package/dist/browser/wardic-config.js.map +1 -1
  111. package/dist/browser/wardic-context.js +23 -0
  112. package/dist/browser/wardic-context.js.map +1 -0
  113. package/dist/browser/wardic.js +3 -0
  114. package/dist/browser/wardic.js.map +1 -1
  115. package/dist/server/animation-frame.js +1 -1
  116. package/dist/server/animation-frame.js.map +1 -1
  117. package/dist/server/config-view.js +35 -6
  118. package/dist/server/config-view.js.map +1 -1
  119. package/dist/server/create-batch.js +1 -1
  120. package/dist/server/diagnostic-codes.js +216 -0
  121. package/dist/server/diagnostic-codes.js.map +1 -0
  122. package/dist/server/diagnostics.js +79 -0
  123. package/dist/server/diagnostics.js.map +1 -0
  124. package/dist/server/element-style.js +61 -7
  125. package/dist/server/element-style.js.map +1 -1
  126. package/dist/server/element.js +24 -6
  127. package/dist/server/element.js.map +1 -1
  128. package/dist/server/feature-section.js +5 -13
  129. package/dist/server/feature-section.js.map +1 -1
  130. package/dist/server/frame-effect.js +1 -1
  131. package/dist/server/frame-effect.js.map +1 -1
  132. package/dist/server/gesture-callbacks.js +1 -1
  133. package/dist/server/gesture-callbacks.js.map +1 -1
  134. package/dist/server/hooks/auto.js +270 -0
  135. package/dist/server/hooks/auto.js.map +1 -0
  136. package/dist/server/hooks/config-scope.js +120 -0
  137. package/dist/server/hooks/config-scope.js.map +1 -0
  138. package/dist/server/hooks/config.js +37 -0
  139. package/dist/server/hooks/config.js.map +1 -0
  140. package/dist/server/hooks/drag.js +633 -0
  141. package/dist/server/hooks/drag.js.map +1 -0
  142. package/dist/server/hooks/elements.js +192 -0
  143. package/dist/server/hooks/elements.js.map +1 -0
  144. package/dist/server/hooks/group.js +28 -0
  145. package/dist/server/hooks/group.js.map +1 -0
  146. package/dist/server/hooks/index.js +10 -0
  147. package/dist/server/hooks/index.js.map +1 -0
  148. package/dist/server/hooks/kept.js +32 -0
  149. package/dist/server/hooks/kept.js.map +1 -0
  150. package/dist/server/hooks/layout-group-of.js +39 -0
  151. package/dist/server/hooks/layout-group-of.js.map +1 -0
  152. package/dist/server/hooks/layout-group.js +109 -0
  153. package/dist/server/hooks/layout-group.js.map +1 -0
  154. package/dist/server/hooks/make-ward.js +157 -0
  155. package/dist/server/hooks/make-ward.js.map +1 -0
  156. package/dist/server/hooks/presence-scope.js +87 -0
  157. package/dist/server/hooks/presence-scope.js.map +1 -0
  158. package/dist/server/hooks/presence.js +24 -0
  159. package/dist/server/hooks/presence.js.map +1 -0
  160. package/dist/server/hooks/props.js +148 -0
  161. package/dist/server/hooks/props.js.map +1 -0
  162. package/dist/server/hooks/reads.js +241 -0
  163. package/dist/server/hooks/reads.js.map +1 -0
  164. package/dist/server/hooks/refs.js +87 -0
  165. package/dist/server/hooks/refs.js.map +1 -0
  166. package/dist/server/hooks/reorder-elements.js +309 -0
  167. package/dist/server/hooks/reorder-elements.js.map +1 -0
  168. package/dist/server/hooks/reorder.js +176 -0
  169. package/dist/server/hooks/reorder.js.map +1 -0
  170. package/dist/server/hooks/rune.js +800 -0
  171. package/dist/server/hooks/rune.js.map +1 -0
  172. package/dist/server/hooks/server-features.client.js +2 -0
  173. package/dist/server/hooks/server-features.client.js.map +1 -0
  174. package/dist/server/hooks/server-features.js +13 -0
  175. package/dist/server/hooks/server-features.js.map +1 -0
  176. package/dist/server/hooks/settings.js +29 -0
  177. package/dist/server/hooks/settings.js.map +1 -0
  178. package/dist/server/hooks/setup.js +154 -0
  179. package/dist/server/hooks/setup.js.map +1 -0
  180. package/dist/server/hooks/stage.js +117 -0
  181. package/dist/server/hooks/stage.js.map +1 -0
  182. package/dist/server/hooks/ward.js +2212 -0
  183. package/dist/server/hooks/ward.js.map +1 -0
  184. package/dist/server/hooks/wardic-provider.js +29 -0
  185. package/dist/server/hooks/wardic-provider.js.map +1 -0
  186. package/dist/server/hooks/wardic-scope.js +68 -0
  187. package/dist/server/hooks/wardic-scope.js.map +1 -0
  188. package/dist/server/hooks/wards.js +563 -0
  189. package/dist/server/hooks/wards.js.map +1 -0
  190. package/dist/server/index.js +23 -11
  191. package/dist/server/index.js.map +1 -1
  192. package/dist/server/layout.js +7 -75
  193. package/dist/server/layout.js.map +1 -1
  194. package/dist/server/lazy-batch-gestures.js +1 -1
  195. package/dist/server/lifecycle.js +37 -0
  196. package/dist/server/lifecycle.js.map +1 -1
  197. package/dist/server/presence-handle.js +28 -12
  198. package/dist/server/presence-handle.js.map +1 -1
  199. package/dist/server/presence.js +3 -1
  200. package/dist/server/presence.js.map +1 -1
  201. package/dist/server/provider.js +125 -100
  202. package/dist/server/provider.js.map +1 -1
  203. package/dist/server/reorder-components.js +50 -0
  204. package/dist/server/reorder-components.js.map +1 -0
  205. package/dist/server/reorder.js +51 -348
  206. package/dist/server/reorder.js.map +1 -1
  207. package/dist/server/runtime.js +26 -15
  208. package/dist/server/runtime.js.map +1 -1
  209. package/dist/server/spans-check.js +8 -3
  210. package/dist/server/spans-check.js.map +1 -1
  211. package/dist/server/stage.js.map +1 -1
  212. package/dist/server/unstable/v2/index.js +0 -8
  213. package/dist/server/unstable/v2/index.js.map +1 -1
  214. package/dist/server/v1/index.js +1 -1
  215. package/dist/server/v1/index.js.map +1 -1
  216. package/dist/server/variant-node.js +4 -2
  217. package/dist/server/variant-node.js.map +1 -1
  218. package/dist/server/w.js +33 -3
  219. package/dist/server/w.js.map +1 -1
  220. package/dist/server/ward.js +594 -61
  221. package/dist/server/ward.js.map +1 -1
  222. package/dist/server/wardic-config.js +63 -30
  223. package/dist/server/wardic-config.js.map +1 -1
  224. package/dist/server/wardic-context.js +23 -0
  225. package/dist/server/wardic-context.js.map +1 -0
  226. package/dist/server/wardic.js +3 -0
  227. package/dist/server/wardic.js.map +1 -1
  228. package/dist/solid/animation-frame.js +1 -1
  229. package/dist/solid/animation-frame.js.map +1 -1
  230. package/dist/solid/batch-reorder-group.d.ts +1 -1
  231. package/dist/solid/batch-reorder.d.ts +1 -1
  232. package/dist/solid/batch-reorder.d.ts.map +1 -1
  233. package/dist/solid/config-view.d.ts +11 -0
  234. package/dist/solid/config-view.d.ts.map +1 -1
  235. package/dist/solid/config-view.js +31 -7
  236. package/dist/solid/config-view.js.map +1 -1
  237. package/dist/solid/create-batch.jsx +1 -1
  238. package/dist/solid/diagnostic-codes.d.ts +10 -0
  239. package/dist/solid/diagnostic-codes.d.ts.map +1 -0
  240. package/dist/solid/diagnostic-codes.js +246 -0
  241. package/dist/solid/diagnostic-codes.js.map +1 -0
  242. package/dist/solid/diagnostics.d.ts +33 -0
  243. package/dist/solid/diagnostics.d.ts.map +1 -0
  244. package/dist/solid/diagnostics.js +76 -0
  245. package/dist/solid/diagnostics.js.map +1 -0
  246. package/dist/solid/element-style.d.ts +16 -2
  247. package/dist/solid/element-style.d.ts.map +1 -1
  248. package/dist/solid/element-style.js +61 -7
  249. package/dist/solid/element-style.js.map +1 -1
  250. package/dist/solid/element.d.ts +3 -1
  251. package/dist/solid/element.d.ts.map +1 -1
  252. package/dist/solid/element.jsx +27 -8
  253. package/dist/solid/element.jsx.map +1 -1
  254. package/dist/solid/feature-section.d.ts +0 -7
  255. package/dist/solid/feature-section.d.ts.map +1 -1
  256. package/dist/solid/feature-section.js +5 -13
  257. package/dist/solid/feature-section.js.map +1 -1
  258. package/dist/solid/frame-effect.jsx +1 -1
  259. package/dist/solid/frame-effect.jsx.map +1 -1
  260. package/dist/solid/gesture-callbacks.js +1 -1
  261. package/dist/solid/gesture-callbacks.js.map +1 -1
  262. package/dist/solid/hooks/auto.d.ts +44 -0
  263. package/dist/solid/hooks/auto.d.ts.map +1 -0
  264. package/dist/solid/hooks/auto.js +269 -0
  265. package/dist/solid/hooks/auto.js.map +1 -0
  266. package/dist/solid/hooks/config-scope.d.ts +84 -0
  267. package/dist/solid/hooks/config-scope.d.ts.map +1 -0
  268. package/dist/solid/hooks/config-scope.jsx +128 -0
  269. package/dist/solid/hooks/config-scope.jsx.map +1 -0
  270. package/dist/solid/hooks/config.d.ts +28 -0
  271. package/dist/solid/hooks/config.d.ts.map +1 -0
  272. package/dist/solid/hooks/config.jsx +37 -0
  273. package/dist/solid/hooks/config.jsx.map +1 -0
  274. package/dist/solid/hooks/drag.d.ts +220 -0
  275. package/dist/solid/hooks/drag.d.ts.map +1 -0
  276. package/dist/solid/hooks/drag.js +586 -0
  277. package/dist/solid/hooks/drag.js.map +1 -0
  278. package/dist/solid/hooks/elements.d.ts +11 -0
  279. package/dist/solid/hooks/elements.d.ts.map +1 -0
  280. package/dist/solid/hooks/elements.jsx +218 -0
  281. package/dist/solid/hooks/elements.jsx.map +1 -0
  282. package/dist/solid/hooks/group.d.ts +46 -0
  283. package/dist/solid/hooks/group.d.ts.map +1 -0
  284. package/dist/solid/hooks/group.jsx +25 -0
  285. package/dist/solid/hooks/group.jsx.map +1 -0
  286. package/dist/solid/hooks/index.d.ts +28 -0
  287. package/dist/solid/hooks/index.d.ts.map +1 -0
  288. package/dist/solid/hooks/index.js +10 -0
  289. package/dist/solid/hooks/index.js.map +1 -0
  290. package/dist/solid/hooks/kept.d.ts +60 -0
  291. package/dist/solid/hooks/kept.d.ts.map +1 -0
  292. package/dist/solid/hooks/kept.js +33 -0
  293. package/dist/solid/hooks/kept.js.map +1 -0
  294. package/dist/solid/hooks/layout-group-of.d.ts +27 -0
  295. package/dist/solid/hooks/layout-group-of.d.ts.map +1 -0
  296. package/dist/solid/hooks/layout-group-of.js +39 -0
  297. package/dist/solid/hooks/layout-group-of.js.map +1 -0
  298. package/dist/solid/hooks/layout-group.d.ts +60 -0
  299. package/dist/solid/hooks/layout-group.d.ts.map +1 -0
  300. package/dist/solid/hooks/layout-group.jsx +80 -0
  301. package/dist/solid/hooks/layout-group.jsx.map +1 -0
  302. package/dist/solid/hooks/make-ward.d.ts +123 -0
  303. package/dist/solid/hooks/make-ward.d.ts.map +1 -0
  304. package/dist/solid/hooks/make-ward.js +147 -0
  305. package/dist/solid/hooks/make-ward.js.map +1 -0
  306. package/dist/solid/hooks/presence-scope.d.ts +84 -0
  307. package/dist/solid/hooks/presence-scope.d.ts.map +1 -0
  308. package/dist/solid/hooks/presence-scope.jsx +63 -0
  309. package/dist/solid/hooks/presence-scope.jsx.map +1 -0
  310. package/dist/solid/hooks/presence.d.ts +51 -0
  311. package/dist/solid/hooks/presence.d.ts.map +1 -0
  312. package/dist/solid/hooks/presence.jsx +26 -0
  313. package/dist/solid/hooks/presence.jsx.map +1 -0
  314. package/dist/solid/hooks/props.d.ts +52 -0
  315. package/dist/solid/hooks/props.d.ts.map +1 -0
  316. package/dist/solid/hooks/props.js +140 -0
  317. package/dist/solid/hooks/props.js.map +1 -0
  318. package/dist/solid/hooks/reads.d.ts +38 -0
  319. package/dist/solid/hooks/reads.d.ts.map +1 -0
  320. package/dist/solid/hooks/reads.js +218 -0
  321. package/dist/solid/hooks/reads.js.map +1 -0
  322. package/dist/solid/hooks/refs.d.ts +25 -0
  323. package/dist/solid/hooks/refs.d.ts.map +1 -0
  324. package/dist/solid/hooks/refs.js +89 -0
  325. package/dist/solid/hooks/refs.js.map +1 -0
  326. package/dist/solid/hooks/reorder-elements.d.ts +23 -0
  327. package/dist/solid/hooks/reorder-elements.d.ts.map +1 -0
  328. package/dist/solid/hooks/reorder-elements.jsx +274 -0
  329. package/dist/solid/hooks/reorder-elements.jsx.map +1 -0
  330. package/dist/solid/hooks/reorder.d.ts +55 -0
  331. package/dist/solid/hooks/reorder.d.ts.map +1 -0
  332. package/dist/solid/hooks/reorder.js +152 -0
  333. package/dist/solid/hooks/reorder.js.map +1 -0
  334. package/dist/solid/hooks/rune.d.ts +885 -0
  335. package/dist/solid/hooks/rune.d.ts.map +1 -0
  336. package/dist/solid/hooks/rune.js +817 -0
  337. package/dist/solid/hooks/rune.js.map +1 -0
  338. package/dist/solid/hooks/server-features.client.d.ts +10 -0
  339. package/dist/solid/hooks/server-features.client.d.ts.map +1 -0
  340. package/dist/solid/hooks/server-features.client.js +2 -0
  341. package/dist/solid/hooks/server-features.client.js.map +1 -0
  342. package/dist/solid/hooks/server-features.d.ts +10 -0
  343. package/dist/solid/hooks/server-features.d.ts.map +1 -0
  344. package/dist/solid/hooks/server-features.js +13 -0
  345. package/dist/solid/hooks/server-features.js.map +1 -0
  346. package/dist/solid/hooks/settings.d.ts +11 -0
  347. package/dist/solid/hooks/settings.d.ts.map +1 -0
  348. package/dist/solid/hooks/settings.js +31 -0
  349. package/dist/solid/hooks/settings.js.map +1 -0
  350. package/dist/solid/hooks/setup.d.ts +31 -0
  351. package/dist/solid/hooks/setup.d.ts.map +1 -0
  352. package/dist/solid/hooks/setup.js +155 -0
  353. package/dist/solid/hooks/setup.js.map +1 -0
  354. package/dist/solid/hooks/stage.d.ts +187 -0
  355. package/dist/solid/hooks/stage.d.ts.map +1 -0
  356. package/dist/solid/hooks/stage.js +117 -0
  357. package/dist/solid/hooks/stage.js.map +1 -0
  358. package/dist/solid/hooks/ward.d.ts +394 -0
  359. package/dist/solid/hooks/ward.d.ts.map +1 -0
  360. package/dist/solid/hooks/ward.js +2258 -0
  361. package/dist/solid/hooks/ward.js.map +1 -0
  362. package/dist/solid/hooks/wardic-provider.d.ts +32 -0
  363. package/dist/solid/hooks/wardic-provider.d.ts.map +1 -0
  364. package/dist/solid/hooks/wardic-provider.jsx +29 -0
  365. package/dist/solid/hooks/wardic-provider.jsx.map +1 -0
  366. package/dist/solid/hooks/wardic-scope.d.ts +49 -0
  367. package/dist/solid/hooks/wardic-scope.d.ts.map +1 -0
  368. package/dist/solid/hooks/wardic-scope.jsx +63 -0
  369. package/dist/solid/hooks/wardic-scope.jsx.map +1 -0
  370. package/dist/solid/hooks/wards.d.ts +157 -0
  371. package/dist/solid/hooks/wards.d.ts.map +1 -0
  372. package/dist/solid/hooks/wards.js +523 -0
  373. package/dist/solid/hooks/wards.js.map +1 -0
  374. package/dist/solid/index.d.ts +21 -14
  375. package/dist/solid/index.d.ts.map +1 -1
  376. package/dist/solid/index.jsx +23 -11
  377. package/dist/solid/index.jsx.map +1 -1
  378. package/dist/solid/layout.d.ts +2 -44
  379. package/dist/solid/layout.d.ts.map +1 -1
  380. package/dist/solid/layout.jsx +7 -49
  381. package/dist/solid/layout.jsx.map +1 -1
  382. package/dist/solid/lazy-batch-gestures.js +1 -1
  383. package/dist/solid/lazy-batch-gestures.js.map +1 -1
  384. package/dist/solid/lifecycle.d.ts +19 -0
  385. package/dist/solid/lifecycle.d.ts.map +1 -1
  386. package/dist/solid/lifecycle.js +40 -0
  387. package/dist/solid/lifecycle.js.map +1 -1
  388. package/dist/solid/presence-handle.d.ts +13 -6
  389. package/dist/solid/presence-handle.d.ts.map +1 -1
  390. package/dist/solid/presence-handle.js +30 -12
  391. package/dist/solid/presence-handle.js.map +1 -1
  392. package/dist/solid/presence.d.ts +3 -1
  393. package/dist/solid/presence.d.ts.map +1 -1
  394. package/dist/solid/presence.jsx +3 -1
  395. package/dist/solid/presence.jsx.map +1 -1
  396. package/dist/solid/provider.d.ts +25 -32
  397. package/dist/solid/provider.d.ts.map +1 -1
  398. package/dist/solid/provider.jsx +126 -82
  399. package/dist/solid/provider.jsx.map +1 -1
  400. package/dist/solid/reorder-components.d.ts +32 -0
  401. package/dist/solid/reorder-components.d.ts.map +1 -0
  402. package/dist/solid/reorder-components.jsx +49 -0
  403. package/dist/solid/reorder-components.jsx.map +1 -0
  404. package/dist/solid/reorder.d.ts +50 -76
  405. package/dist/solid/reorder.d.ts.map +1 -1
  406. package/dist/solid/reorder.jsx +45 -206
  407. package/dist/solid/reorder.jsx.map +1 -1
  408. package/dist/solid/runtime.d.ts +20 -7
  409. package/dist/solid/runtime.d.ts.map +1 -1
  410. package/dist/solid/runtime.js +25 -14
  411. package/dist/solid/runtime.js.map +1 -1
  412. package/dist/solid/spans-check.d.ts +5 -1
  413. package/dist/solid/spans-check.d.ts.map +1 -1
  414. package/dist/solid/spans-check.js +8 -3
  415. package/dist/solid/spans-check.js.map +1 -1
  416. package/dist/solid/stage.d.ts +14 -0
  417. package/dist/solid/stage.d.ts.map +1 -1
  418. package/dist/solid/stage.js.map +1 -1
  419. package/dist/solid/unstable/v2/index.d.ts +2 -26
  420. package/dist/solid/unstable/v2/index.d.ts.map +1 -1
  421. package/dist/solid/unstable/v2/index.jsx +0 -16
  422. package/dist/solid/unstable/v2/index.jsx.map +1 -1
  423. package/dist/solid/v1/index.d.ts +1 -1
  424. package/dist/solid/v1/index.d.ts.map +1 -1
  425. package/dist/solid/v1/index.jsx +1 -1
  426. package/dist/solid/v1/index.jsx.map +1 -1
  427. package/dist/solid/variant-node.d.ts +6 -0
  428. package/dist/solid/variant-node.d.ts.map +1 -1
  429. package/dist/solid/variant-node.js +2 -0
  430. package/dist/solid/variant-node.js.map +1 -1
  431. package/dist/solid/w.d.ts +9 -3
  432. package/dist/solid/w.d.ts.map +1 -1
  433. package/dist/solid/w.jsx +36 -3
  434. package/dist/solid/w.jsx.map +1 -1
  435. package/dist/solid/ward.d.ts +134 -7
  436. package/dist/solid/ward.d.ts.map +1 -1
  437. package/dist/solid/ward.jsx +564 -60
  438. package/dist/solid/ward.jsx.map +1 -1
  439. package/dist/solid/wardic-config.d.ts +17 -12
  440. package/dist/solid/wardic-config.d.ts.map +1 -1
  441. package/dist/solid/wardic-config.jsx +68 -22
  442. package/dist/solid/wardic-config.jsx.map +1 -1
  443. package/dist/solid/wardic-context.d.ts +15 -0
  444. package/dist/solid/wardic-context.d.ts.map +1 -0
  445. package/dist/solid/wardic-context.js +23 -0
  446. package/dist/solid/wardic-context.js.map +1 -0
  447. package/dist/solid/wardic-instance.d.ts +6 -4
  448. package/dist/solid/wardic-instance.d.ts.map +1 -1
  449. package/dist/solid/wardic.d.ts +3 -0
  450. package/dist/solid/wardic.d.ts.map +1 -1
  451. package/dist/solid/wardic.jsx +3 -0
  452. package/dist/solid/wardic.jsx.map +1 -1
  453. package/package.json +29 -7
  454. package/skills/wardic-diagnostics/SKILL.md +472 -0
  455. package/skills/wardic-migrate/SKILL.md +204 -0
  456. package/skills/wardic-solid/SKILL.md +60 -0
  457. package/skills/wardic-solid/events.md +70 -0
  458. package/skills/wardic-solid/from-motion.md +59 -0
  459. package/skills/wardic-solid/lists-and-presence.md +110 -0
  460. package/skills/wardic-solid/reorder-and-grips.md +88 -0
  461. package/skills/wardic-solid/runes.md +151 -0
  462. package/skills/wardic-solid/scopes-and-settings.md +75 -0
  463. package/src/animation-frame.ts +1 -1
  464. package/src/batch-reorder-group.tsx +1 -1
  465. package/src/batch-reorder.ts +1 -1
  466. package/src/config-view.ts +35 -7
  467. package/src/create-batch.tsx +1 -1
  468. package/src/diagnostic-codes.ts +254 -0
  469. package/src/diagnostics.ts +88 -0
  470. package/src/element-style.ts +77 -9
  471. package/src/element.tsx +36 -12
  472. package/src/feature-section.ts +5 -15
  473. package/src/frame-effect.tsx +1 -1
  474. package/src/gesture-callbacks.ts +1 -1
  475. package/src/hooks/auto.ts +303 -0
  476. package/src/hooks/config-scope.tsx +215 -0
  477. package/src/hooks/config.tsx +54 -0
  478. package/src/hooks/drag.ts +741 -0
  479. package/src/hooks/elements.tsx +234 -0
  480. package/src/hooks/group.tsx +55 -0
  481. package/src/hooks/index.ts +41 -0
  482. package/src/hooks/kept.ts +89 -0
  483. package/src/hooks/layout-group-of.ts +46 -0
  484. package/src/hooks/layout-group.tsx +111 -0
  485. package/src/hooks/make-ward.ts +218 -0
  486. package/src/hooks/presence-scope.tsx +156 -0
  487. package/src/hooks/presence.tsx +67 -0
  488. package/src/hooks/props.ts +190 -0
  489. package/src/hooks/reads.ts +258 -0
  490. package/src/hooks/refs.ts +114 -0
  491. package/src/hooks/reorder-elements.tsx +323 -0
  492. package/src/hooks/reorder.ts +205 -0
  493. package/src/hooks/rune.ts +1756 -0
  494. package/src/hooks/server-features.client.ts +10 -0
  495. package/src/hooks/server-features.ts +12 -0
  496. package/src/hooks/settings.ts +44 -0
  497. package/src/hooks/setup.ts +184 -0
  498. package/src/hooks/stage.ts +359 -0
  499. package/src/hooks/ward.ts +2587 -0
  500. package/src/hooks/wardic-provider.tsx +51 -0
  501. package/src/hooks/wardic-scope.tsx +112 -0
  502. package/src/hooks/wards.ts +681 -0
  503. package/src/index.tsx +27 -15
  504. package/src/layout.tsx +7 -74
  505. package/src/lazy-batch-gestures.ts +1 -1
  506. package/src/lifecycle.ts +40 -0
  507. package/src/presence-handle.ts +39 -20
  508. package/src/presence.tsx +3 -1
  509. package/src/provider.tsx +136 -88
  510. package/src/reorder-components.tsx +61 -0
  511. package/src/reorder.tsx +89 -307
  512. package/src/runtime.ts +43 -13
  513. package/src/spans-check.ts +12 -3
  514. package/src/stage.ts +15 -0
  515. package/src/unstable/v2/index.tsx +2 -26
  516. package/src/v1/index.tsx +1 -1
  517. package/src/variant-node.ts +8 -0
  518. package/src/w.tsx +38 -5
  519. package/src/ward.tsx +694 -60
  520. package/src/wardic-config.tsx +68 -21
  521. package/src/wardic-context.ts +26 -0
  522. package/src/wardic-instance.ts +6 -4
  523. package/src/wardic.tsx +3 -0
  524. package/dist/browser/create-wardic.js +0 -36
  525. package/dist/browser/create-wardic.js.map +0 -1
  526. package/dist/browser/presence-hooks.js +0 -144
  527. package/dist/browser/presence-hooks.js.map +0 -1
  528. package/dist/server/create-wardic.js +0 -36
  529. package/dist/server/create-wardic.js.map +0 -1
  530. package/dist/server/presence-hooks.js +0 -144
  531. package/dist/server/presence-hooks.js.map +0 -1
  532. package/dist/solid/create-wardic.d.ts +0 -25
  533. package/dist/solid/create-wardic.d.ts.map +0 -1
  534. package/dist/solid/create-wardic.jsx +0 -34
  535. package/dist/solid/create-wardic.jsx.map +0 -1
  536. package/dist/solid/presence-hooks.d.ts +0 -53
  537. package/dist/solid/presence-hooks.d.ts.map +0 -1
  538. package/dist/solid/presence-hooks.jsx +0 -117
  539. package/dist/solid/presence-hooks.jsx.map +0 -1
  540. package/src/create-wardic.tsx +0 -46
  541. package/src/presence-hooks.tsx +0 -159
@@ -0,0 +1,218 @@
1
+ /**
2
+ * The hooks, and `makeWard` (probe: hooks-first).
3
+ *
4
+ * **The hooks need nothing set up.** `createWard`, `createWards` and `createPresence` are imported and
5
+ * called: the page's Environment is the DOM's, and each ward brings the Features its own config uses,
6
+ * loaded the first time one is asked for (`auto.ts`). No provider, no list of Features.
7
+ *
8
+ * **`makeWard(options)` is for a page that gives its Features at once,** in its own bundle, with
9
+ * nothing loaded later, and with them its own Environment or a setting a `<WardicProvider>` took
10
+ * (`strict`, `reducedMotion`, `appear`, `nonce`, `scaleCorrectors`). It returns `createWard` and
11
+ * `createWards` bringing those Features, the layout hooks with `layout`, and `w` when it's given
12
+ * {@link elements}. `createPresence` brings no Features of its own, so it's imported by name, as the
13
+ * page with nothing set up does.
14
+ *
15
+ * Its Features are asked for, not left out for the hooks' own: a `makeWard` that could be given none
16
+ * would hand back the hooks that load a Feature at its first use, and every app that called one would
17
+ * ship that loading, Features given or not (probe: hooks-first, 4.1 KB gzip).
18
+ *
19
+ * `make*` is called once, in a module, as `Wardic.make` is; `create*` in a component, where Solid's own
20
+ * primitives are. It took the place of the binding's own `createWardic`, deleted from Solid 2 (probe:
21
+ * behaviour-runes, after the scopes round).
22
+ *
23
+ * @module
24
+ */
25
+ import { DomLive } from "@wardic/dom"
26
+ import type * as Feature from "@wardic/dom/unstable/Feature"
27
+ import { instanceFeaturesOf } from "@wardic/dom/unstable/InstanceFeatures"
28
+ import { identity } from "effect/Function"
29
+ import * as Predicate from "effect/Predicate"
30
+ import * as UndefinedOr from "effect/UndefinedOr"
31
+ import { createInstantLayoutTransition as instantLayoutTransition, createResetProjection as resetProjection, useAnimateLayout as animateLayout, useInstanceBrought } from "../provider.tsx"
32
+ import { type W, withTags, wOf } from "../w.tsx"
33
+ import { elementsOf } from "./elements.tsx"
34
+ import { SLIM, type WardInternals } from "../ward.tsx"
35
+ import type { WardicInstance } from "../wardic-instance.ts"
36
+ import { bringing } from "./auto.ts"
37
+ import { type PageConfigSettings, type PageOptions, setupDefaultPage, setupPage } from "./setup.ts"
38
+ import { auto, fixed, type HookWardOf, hookWardOf, rawWardOf } from "./ward.ts"
39
+ import { hookPresence, type HookPresenceOf, type HookWardsOf, hookWardsOf } from "./wards.ts"
40
+
41
+ /** What gives a `makeWard` its `w`: {@link elements}, and nothing else. */
42
+ export type Elements = (kind: WardInternals, createWard: HookWardOf) => W
43
+
44
+ /**
45
+ * Today's elements, for a `makeWard` that returns `w` as well: `makeWard({ features, elements })`.
46
+ * A value to import, not a flag, so a page that renders no `w.*` element ships none of their code.
47
+ * Its `w.<tag>` is the hooks' utility (the gap grill's Q27), each element's ward the `makeWard`'s own
48
+ * `createWard`; its `w.create` and `w.ward` are today's, of the `makeWard`'s Features.
49
+ */
50
+ export const elements: Elements = (kind, createWard) => withTags(wOf(kind), elementsOf(createWard))
51
+
52
+ /**
53
+ * A page's settings as `makeWard` takes them: a provider's, its `env` the DOM's unless given, and its
54
+ * wards' `transition`, `skipAnimations` and `transformPagePoint`, a `WardicConfig`'s for the page.
55
+ */
56
+ export type MakeWardSettings = Omit<PageOptions, "env"> & { readonly env?: PageOptions["env"] | undefined } & PageConfigSettings
57
+
58
+ /** What `makeWard` takes: a page's settings, the Features its wards bring, and `elements` for a `w`. */
59
+ export type MakeWardOptions<F> = MakeWardSettings & {
60
+ /**
61
+ * The Features every ward, row and element it makes brings, wherever it's made: one, or a list, a
62
+ * load among them (`() => import("./drag.ts").then((m) => m.drag)`). Given at once, they're in the
63
+ * module's own bundle. Always given: the hooks with nothing given are the package's own `createWard`,
64
+ * each ward bringing what its own config uses, so a `makeWard` never ships that loading.
65
+ */
66
+ readonly features: F
67
+ /** {@link elements}, for a `w` whose elements bring the same Features. */
68
+ readonly elements?: Elements | undefined
69
+ }
70
+
71
+ /**
72
+ * What `makeWard` returns for Features `F`: the hooks a component calls, the layout hooks when `F` has
73
+ * `layout`, `w` when it was given `elements`, and `with`, the same again with more Features.
74
+ */
75
+ export type MadeWard<F, E extends boolean = false> = Omit<WardicInstance<F>, "w"> & {
76
+ /** One element's motion, made of runes: spread it on the element. */
77
+ readonly createWard: HookWardOf
78
+ /** A ward for each item of a list, kept until its exit has landed. */
79
+ readonly createWards: HookWardsOf
80
+ /**
81
+ * The same hooks with `features` beside its own, on the same page: for a module only the pages that
82
+ * lay out or drag import, so the rest ship neither.
83
+ *
84
+ * // src/lib/wardic-layout.ts
85
+ * export const { createWard, createWards, useAnimateLayout } = wardic.with(layout)
86
+ */
87
+ readonly with: <const G extends Feature.InstanceFeaturesProp>(features: G) => MadeWard<readonly [F, G], E>
88
+ } & ElementsFor<F, E>
89
+
90
+ /** `w`, for a `makeWard` given `elements`; else nothing. */
91
+ type ElementsFor<F, E extends boolean> = E extends true ? { readonly w: W<F> } : unknown
92
+
93
+ /**
94
+ * The page's settings out of `options`: its Features are its wards' to bring, not the page's section's.
95
+ * `reducedMotion` stays a read, as a provider's prop is, so a getter given for it is still followed.
96
+ */
97
+ const pageOf = (options: MakeWardSettings): PageOptions => ({
98
+ env: UndefinedOr.match(options.env, { onUndefined: () => DomLive, onDefined: identity }),
99
+ appear: options.appear,
100
+ nonce: options.nonce,
101
+ scaleCorrectors: options.scaleCorrectors,
102
+ strict: options.strict,
103
+ get reducedMotion() {
104
+ return options.reducedMotion
105
+ },
106
+ })
107
+
108
+ /** The hooks that bring `features`, and `w` when `given` makes one. */
109
+ const madeOf = (features: Feature.InstanceFeaturesProp, given: Elements | undefined): object => {
110
+ const instance = instanceFeaturesOf(features)
111
+ /** `hook`, its instance's Features brought first. */
112
+ const brought =
113
+ <A>(hook: () => A) =>
114
+ (): A => {
115
+ useInstanceBrought(instance)
116
+ return hook()
117
+ }
118
+ // A list's rows are made by `rawWardOf`: only a ward an app is handed is one a presence may take.
119
+ const begin = fixed({ ...SLIM, instance })
120
+ // The layout hooks are there at runtime whatever its Features: its type shows them only with `layout`.
121
+ const hooks = {
122
+ createWard: hookWardOf(begin),
123
+ createWards: hookWardsOf(rawWardOf(begin)),
124
+ useAnimateLayout: brought(animateLayout),
125
+ createInstantLayoutTransition: brought(instantLayoutTransition),
126
+ createResetProjection: brought(resetProjection),
127
+ with: (more: Feature.InstanceFeaturesProp) => madeOf([features, more], given),
128
+ }
129
+ if (Predicate.isUndefined(given)) return hooks
130
+ return { ...hooks, w: given({ instance }, hooks.createWard) }
131
+ }
132
+
133
+ /** What a layout hook brings when nothing lists a page's Features: `layout`, loaded at its first call. */
134
+ const LAYOUT = /*#__PURE__*/ bringing(["layout"])
135
+
136
+ /** `hook`, `layout` brought first: a layout hook, where nothing lists a page's Features. */
137
+ const broughtLayout =
138
+ <A>(hook: () => A) =>
139
+ (): A => {
140
+ useInstanceBrought(LAYOUT)
141
+ return hook()
142
+ }
143
+
144
+ /**
145
+ * Makes the hooks for a page that gives its Features at once, with its Environment or a provider's
146
+ * settings beside them. Call it once, in a module of its own; a module that needs more Features asks
147
+ * the one it made, `wardic.with(layout)`.
148
+ *
149
+ * // src/lib/wardic.ts
150
+ * export const wardic = makeWard({ features: domAnimation, strict: true })
151
+ * export const { createWard, createWards } = wardic
152
+ */
153
+ export function makeWard<const F extends Feature.InstanceFeaturesProp>(options: MakeWardOptions<F> & { readonly elements: Elements }): MadeWard<F, true>
154
+ export function makeWard<const F extends Feature.InstanceFeaturesProp>(options: MakeWardOptions<F>): MadeWard<F>
155
+ export function makeWard(options: MakeWardOptions<Feature.InstanceFeaturesProp>): unknown {
156
+ setupPage(pageOf(options), options)
157
+ return madeOf(options.features, options.elements)
158
+ }
159
+
160
+ /**
161
+ * Gives the page its own Environment or a setting a `<WardicProvider>` took, where its wards still
162
+ * bring the Features their own configs use: the hooks imported by name, nothing listed. Call it once,
163
+ * in a module that loads before anything renders, as a `makeWard` is. A page that sets nothing calls
164
+ * nothing; one that gives its Features at once gives them to `makeWard` with its settings instead.
165
+ *
166
+ * // src/lib/wardic.ts
167
+ * setupWard({ strict: true, reducedMotion: "user" })
168
+ */
169
+ export const setupWard = (settings: MakeWardSettings): void => setupPage(pageOf(settings), settings)
170
+
171
+ // As this module loads: a page that only imports the hooks below has its context, the DOM's
172
+ // Environment. A `setupWard` or a `makeWard` called after it gives the page's own.
173
+ setupDefaultPage()
174
+
175
+ /**
176
+ * The hooks, with nothing to set up: each ward brings the Features its own config uses.
177
+ *
178
+ * import { createWard } from "@wardic/solid/hooks"
179
+ *
180
+ * const card = createWard({ initial: { opacity: 0 }, animate: { opacity: 1 }, whileHover: { y: -4 } })
181
+ * return <article {...card} />
182
+ *
183
+ * **A ward is made where its Subject is drawn:** in a component's body, or a row's callback, beside
184
+ * the markup it's spread on. A ward is one Subject, so a hook that handed one out would fix which
185
+ * elements there are, and the line that says what moves would sit away from what it moves. So an
186
+ * app's hooks hold state and give runes ({@link createRune}): runes that close over that state,
187
+ * functions that make one for each element, and `createRuneWith` values. Never a ward. A follower is
188
+ * written out where it's made, beside its leader:
189
+ *
190
+ * const opens = createRune({ initial: "closed", animate: "open" })
191
+ * const turns = createRune({ variants: { open: { rotate: 180 }, closed: { rotate: 0 } } })
192
+ *
193
+ * // In the component:
194
+ * const panel = createWard(opens)
195
+ * const chevron = createWard({ follow: panel }, turns)
196
+ *
197
+ * Each its own export, so an app ships only the ones it imports: one object of them all, taken apart
198
+ * as they're exported, kept every hook in every app that imported any (probe: hooks-first), a
199
+ * presence's taking and the layout hooks among them.
200
+ */
201
+ export const createWard: HookWardOf = /*#__PURE__*/ hookWardOf(auto)
202
+
203
+ /**
204
+ * A ward for each item of a list, kept until its exit has landed: {@link createWard}'s, for a list.
205
+ * Made where the list is drawn, as a ward is, from runes made once.
206
+ */
207
+ export const createWards: HookWardsOf = /*#__PURE__*/ hookWardsOf(/*#__PURE__*/ rawWardOf(auto))
208
+
209
+ /**
210
+ * One ward at a time, for a value that changes: the last one leaves, then the new one enters. Made
211
+ * where its ward is, in the component that draws it, beside that ward.
212
+ */
213
+ export const createPresence: HookPresenceOf = hookPresence
214
+
215
+ /** The layout hooks, `layout` brought at the first call of one. */
216
+ export const useAnimateLayout = /*#__PURE__*/ broughtLayout(animateLayout)
217
+ export const createInstantLayoutTransition = /*#__PURE__*/ broughtLayout(instantLayoutTransition)
218
+ export const createResetProjection = /*#__PURE__*/ broughtLayout(resetProjection)
@@ -0,0 +1,156 @@
1
+ /**
2
+ * `createPresenceScope(options)` (probe: hooks-first, the gap grill's Q9): the boundary round what its
3
+ * author doesn't take away themselves, a router's page or children handed in, as a value an app holds.
4
+ *
5
+ * ```tsx
6
+ * const pages = createPresenceScope({ pop: true })
7
+ * // The layout: a navigation ends the page it hands over.
8
+ * pages.within(() => props.children)
9
+ * // Anywhere:
10
+ * createEffect(pages.when("exitComplete"), () => window.scrollTo(0, 0))
11
+ * ```
12
+ *
13
+ * `within(build)` builds what it's given under the scope, and keeps a child that leaves on the page
14
+ * until the exits of the wards inside it have landed. Each ward made there, at any depth, registers
15
+ * its exit with the scope as it mounts; once its child leaves, the scope runs that exit itself, from
16
+ * what the ward registered, so it runs after Solid has ended the child and the ward with it. Code
17
+ * inside a leaving child can't hear its own leave, then: the scope does, by `exiting()` and its
18
+ * `"exitStart"` and `"exitComplete"`, as a ward hears its own.
19
+ *
20
+ * The value is a presence handle, so it can be a `<Presence>`'s own, or another's `ref`. It's
21
+ * today's presence controller as a hook: `within` is `<AnimatePresence>` round what it builds, its
22
+ * exits told to the scope. `<AnimatePresence>` is internal now, its export deleted (after the scopes
23
+ * round); its body may come here.
24
+ *
25
+ * @module
26
+ */
27
+ import type { JSX } from "@solidjs/web"
28
+ import type { PopAnchors, PresenceMode } from "@wardic/dom/unstable/PresenceController"
29
+ import * as Predicate from "effect/Predicate"
30
+ import { DEV, getOwner, onCleanup } from "solid-js"
31
+ import { AnimatePresence } from "../presence.tsx"
32
+ import { report } from "../diagnostics.ts"
33
+ import { createPresence as makeRef, ownPresenceHandle, type Presence as Handle } from "../presence-handle.ts"
34
+ import type { PopCorner } from "./rune.ts"
35
+ import { popAnchorsOf } from "./ward.ts"
36
+
37
+ /**
38
+ * A presence's exits, heard: `exiting()`, and `next`, `each` and `when` of `"exitStart"` and
39
+ * `"exitComplete"`, a ward's own words for its own exit.
40
+ */
41
+ export type PresenceRef = Handle
42
+
43
+ /**
44
+ * A handle for a `<Presence>`'s `ref`, made before the boundary is: it hears that boundary's exits
45
+ * from then on. A presence scope is one already.
46
+ */
47
+ export const createPresenceRef: () => PresenceRef = makeRef
48
+
49
+ /** What a presence scope takes, however its children come and go. */
50
+ interface ScopeShared {
51
+ /**
52
+ * `false`: what's there as the boundary is made has no entrance, and starts at its `animate`. What
53
+ * comes later enters from its `initial`. A ward's own `enter: false`, said for everything inside.
54
+ */
55
+ readonly enter?: false | undefined
56
+ /** What a leaving child's dynamic `exit` resolves with: it has left, and can't be handed anything new. */
57
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
58
+ readonly custom?: any
59
+ /** Inside another boundary's child: as that child leaves, this one's children leave too, each by its exit. */
60
+ readonly propagate?: boolean | undefined
61
+ /** `false`: its children's coming and going moves no `layout` element around them. */
62
+ readonly affectsLayout?: boolean | undefined
63
+ }
64
+
65
+ /**
66
+ * What {@link createPresenceScope} takes. With neither `pop` nor `wait`, a child enters at once,
67
+ * beside the one leaving. One or the other, not both.
68
+ */
69
+ export type PresenceScopeOptions = ScopeShared &
70
+ (
71
+ | {
72
+ /**
73
+ * A leaving child is taken out of the flow where it was, so the next is in its place at once: a
74
+ * ward's `pop`, said for whatever leaves here. `true` pins it by its top left; a corner, by that.
75
+ */
76
+ readonly pop?: boolean | PopCorner | undefined
77
+ readonly wait?: never
78
+ }
79
+ | {
80
+ /** A child enters once the one before it has gone: one thing at a time, `createPresence`'s. */
81
+ readonly wait?: boolean | undefined
82
+ readonly pop?: never
83
+ }
84
+ )
85
+
86
+ /** A presence scope: its exits heard, as a presence handle's, and `within`, the boundary itself. */
87
+ export type PresenceScope = PresenceRef & {
88
+ /**
89
+ * The boundary: `build`'s children, built under this scope, each one that leaves kept on the page
90
+ * until the wards inside it have run their exits. One boundary a scope.
91
+ */
92
+ readonly within: (build: () => JSX.Element) => JSX.Element
93
+ }
94
+
95
+ /** How a child enters while another leaves: `wait`, else `pop`, else beside it. */
96
+ const modeOf = (wait: boolean | undefined, anchors: PopAnchors | undefined): PresenceMode => {
97
+ if (wait === true) return "wait"
98
+ if (Predicate.isNotUndefined(anchors)) return "popLayout"
99
+ return "sync"
100
+ }
101
+
102
+ /** The inline edge a popped child is pinned by: none without a `pop`. */
103
+ const xOf = (anchors: PopAnchors | undefined): PopAnchors["x"] | undefined => {
104
+ if (Predicate.isUndefined(anchors)) return undefined
105
+ return anchors.x
106
+ }
107
+
108
+ /** The block edge a popped child is pinned by: none without a `pop`. */
109
+ const yOf = (anchors: PopAnchors | undefined): PopAnchors["y"] | undefined => {
110
+ if (Predicate.isUndefined(anchors)) return undefined
111
+ return anchors.y
112
+ }
113
+
114
+ /**
115
+ * A presence scope, with `options`: what its boundary keeps on the page while it leaves, and what's
116
+ * heard of it. See the module.
117
+ */
118
+ export const createPresenceScope = (options: PresenceScopeOptions = {}): PresenceScope => {
119
+ const scope = ownPresenceHandle()
120
+ // Its boundaries on the page now, for the warning in development: one a scope (Q9). One made again,
121
+ // its old one ended by its owner, is still one.
122
+ let live = 0
123
+ let warned = false
124
+ const counted = (): void => {
125
+ live += 1
126
+ if (Predicate.isNotNull(getOwner())) onCleanup(() => void (live -= 1))
127
+ if (!DEV || warned || live < 2) return
128
+ warned = true
129
+ report("WARDIC_PRESENCE_SCOPE_REUSED", ONE_BOUNDARY)
130
+ }
131
+ // Read where the boundary reads each: `options` may be a component's props.
132
+ const within = (build: () => JSX.Element): JSX.Element => {
133
+ counted()
134
+ return withinOf(scope, options, build)
135
+ }
136
+ return Object.defineProperty(scope, "within", { value: within }) as PresenceScope
137
+ }
138
+
139
+ const ONE_BOUNDARY =
140
+ "createPresenceScope: a scope is one boundary, and this one's `within` is round a second while the first is on the page. Its `exiting()`, `next` and `when` are told of both as one: make a scope for each boundary."
141
+
142
+ /** The boundary `within` puts round what `build` builds: `<AnimatePresence>`'s controller, telling `scope`. */
143
+ const withinOf = (scope: Handle, options: PresenceScopeOptions, build: () => JSX.Element): JSX.Element => (
144
+ <AnimatePresence
145
+ mode={modeOf(options.wait, popAnchorsOf(options.pop))}
146
+ anchorX={xOf(popAnchorsOf(options.pop))}
147
+ anchorY={yOf(popAnchorsOf(options.pop))}
148
+ initial={options.enter !== false}
149
+ custom={options.custom}
150
+ propagate={options.propagate === true}
151
+ presenceAffectsLayout={options.affectsLayout}
152
+ ref={scope}
153
+ >
154
+ {build()}
155
+ </AnimatePresence>
156
+ )
@@ -0,0 +1,67 @@
1
+ /**
2
+ * `<Presence>` (probe: hooks-first): the hooks' one boundary, for what its author doesn't take away
3
+ * themselves. A hook covers a thing whose coming and going its author writes (`show`, `createWards`,
4
+ * `createPresence(ward, value)`): the ward is made where the decision is. A router's page, children
5
+ * handed to a component, another library's component are ended by someone else, and everything made
6
+ * inside them with it, so what keeps them on the page while they leave has to be above them.
7
+ *
8
+ * ```tsx
9
+ * // The layout: a navigation ends the page it hands over.
10
+ * <Presence pop>{props.children}</Presence>
11
+ *
12
+ * // A page: its motion is its own, a ward on its own root.
13
+ * const page = createWard(fade)
14
+ * <ul {...page}>…</ul>
15
+ * ```
16
+ *
17
+ * A utility over {@link createPresenceScope}, and built from the hooks' public names alone, as an app
18
+ * could write it (the gap grill's Q6, HU1): its props are the scope's options. A ward under it, a
19
+ * hook's or a component's, leaves by its own `exit`.
20
+ *
21
+ * @module
22
+ */
23
+ import type { JSX } from "@solidjs/web"
24
+ import * as Predicate from "effect/Predicate"
25
+ import { untrack } from "solid-js"
26
+ import { createPresenceScope, type PresenceRef, type PresenceScope, type PresenceScopeOptions } from "./presence-scope.tsx"
27
+
28
+ /** {@link Presence}'s props: a presence scope's options, its children, and a `ref` for its exits. */
29
+ export type PresenceProps = PresenceScopeOptions & {
30
+ readonly children?: JSX.Element
31
+ /** Its exits, heard: a `createPresenceRef()` handle, or a callback handed the boundary's own. Read once. */
32
+ readonly ref?: ((presence: PresenceRef) => void) | undefined
33
+ /**
34
+ * A scope made elsewhere, a module's for one: this boundary is its `within`, and its options are its
35
+ * own, so the ones here go unread. Read once.
36
+ *
37
+ * ```tsx
38
+ * // src/lib/pages.ts
39
+ * export const pages = createPresenceScope({ pop: true })
40
+ * // The layout:
41
+ * <Presence scope={pages}>{props.children}</Presence>
42
+ * ```
43
+ */
44
+ readonly scope?: PresenceScope | undefined
45
+ }
46
+
47
+ /** The scope a `<Presence>` is the boundary of: the one it's given, else one of its own, by its props. */
48
+ const scopeOf = (props: PresenceProps): PresenceScope => {
49
+ const given = untrack(() => props.scope)
50
+ if (Predicate.isNotUndefined(given)) return given
51
+ return createPresenceScope(props)
52
+ }
53
+
54
+ /**
55
+ * The boundary round what its author doesn't take away: each child that leaves stays until its
56
+ * wards' exits have landed. See the module.
57
+ *
58
+ * @example
59
+ * <Presence pop>{props.children}</Presence>
60
+ */
61
+ export function Presence(props: PresenceProps): JSX.Element {
62
+ const scope = scopeOf(props)
63
+ const ref = untrack(() => props.ref)
64
+ if (Predicate.isNotUndefined(ref)) ref(scope)
65
+ // eslint-disable-next-line solid/reactivity -- its children read under the scope as they're made, which Solid tracks as any children
66
+ return scope.within(() => props.children)
67
+ }
@@ -0,0 +1,190 @@
1
+ /**
2
+ * A rune's `props` at work (probe: hooks-first): what a ward's runes set on its Subject beside moving
3
+ * it, carried on the ward's own spread (`RuneProps`, `rune.ts`). The page's alone: a Stage's Subject
4
+ * is its app's own object, with no markup to spread into.
5
+ *
6
+ * - **Each name is one key of the ward's spread, and of the ward,** a getter over the runes that give
7
+ * it, read where the element reads it: so a value that's an accessor is followed there, by Solid's
8
+ * own spread. On the ward itself as its `style` is, for a component it's spread on, which is handed
9
+ * the ward as its props. No attribute's name is one of a ward's own members (T12 pins it).
10
+ * - **A later rune's wins a name two give,** as every other key of a rune's does: its `undefined`
11
+ * says nothing of the name, and its `false` says none. But a list of ids ({@link ID_LISTS}) joins,
12
+ * in the runes' order: one rune describing its Subject doesn't take another's description away.
13
+ * - **Where the binding sets a name itself, it keeps it** ({@link addedTo}): a ward that drags is
14
+ * `draggable="false"`, which its drag needs. A Reorder row's `tabindex` and `aria-describedby` are
15
+ * the binding's too, and take a rune's the way they take the row's own: handed to its config
16
+ * (`reorder.ts`).
17
+ * - **A ward's spread is one object, made at its first spread and kept** (`ward.tsx`'s, #495): Solid
18
+ * calls the ward for it, wherever it's spread. The names are added to that object, so nothing of
19
+ * the binding's own changes; a ward whose runes give no `props` is left as it was, its spread not
20
+ * made until something spreads it.
21
+ * - **A server's too:** its ward has a spread of the same kind, read as its markup is rendered, and
22
+ * its `ward.with()` carries them as a browser's does ({@link withCarrying}).
23
+ * - **A ward given its Subject has them written by the hooks,** not by a spread
24
+ * ({@link settingOn}): Solid's writes no attribute on a server's element as the page hydrates.
25
+ *
26
+ * Nothing here runs per frame, and nothing writes a signal.
27
+ *
28
+ * @module
29
+ */
30
+ import * as Arr from "effect/Array"
31
+ import * as Bool from "effect/Boolean"
32
+ import { constUndefined } from "effect/Function"
33
+ import * as Option from "effect/Option"
34
+ import * as Predicate from "effect/Predicate"
35
+ import * as Rec from "effect/Record"
36
+ import * as Str from "effect/String"
37
+ import { createRenderEffect, onCleanup } from "solid-js"
38
+ import { CLIENT_ONLY } from "../solid-reactivity.ts"
39
+
40
+ /** One rune's `props` as it was written, read loosely: each name's value, or an accessor of it. Typed where it's written (`RuneProps`, `rune.ts`). */
41
+ type Written = Readonly<Record<string, unknown>>
42
+
43
+ /**
44
+ * The names a ward's runes set on its Subject, as the keys a spread reads: each a getter over the
45
+ * runes that give it, enumerable. What a ward carries ({@link carrying}).
46
+ */
47
+ export type PropKeys = PropertyDescriptorMap
48
+
49
+ /**
50
+ * ARIA's attributes whose value is a list of ids, by its spec: what describes an element, labels it,
51
+ * or is controlled, owned or followed by it. Several runes' join, where any other name is the last's.
52
+ */
53
+ const ID_LISTS: ReadonlySet<string> = new Set(["aria-describedby", "aria-labelledby", "aria-controls", "aria-owns", "aria-flowto", "aria-details"])
54
+
55
+ /** Every rune's `props` among a ward's `configs`, in the order its runes were given. */
56
+ export const runePropsOf = (configs: ReadonlyArray<object>): ReadonlyArray<Written> =>
57
+ Arr.filter(
58
+ Arr.map(configs, (config) => (config as { readonly props?: unknown }).props),
59
+ Predicate.isReadonlyObject,
60
+ )
61
+
62
+ /** A prop as it's read: an accessor called, where its element reads it. */
63
+ const valueOf = (given: unknown): unknown =>
64
+ Bool.match(Predicate.isFunction(given), {
65
+ onTrue: () => (given as () => unknown)(),
66
+ onFalse: () => given,
67
+ })
68
+
69
+ /** Each rune's value for `name`, in the runes' order, as it reads now. */
70
+ const valuesOf = (runes: ReadonlyArray<Written>, name: string): ReadonlyArray<unknown> => Arr.map(runes, (each) => valueOf(each[name]))
71
+
72
+ /** `name` across the runes: the last one's that says anything of it, `undefined` saying nothing. */
73
+ const lastOf = (runes: ReadonlyArray<Written>, name: string) => (): unknown => Option.getOrUndefined(Arr.findLast(valuesOf(runes, name), Predicate.isNotUndefined))
74
+
75
+ /** `name` across the runes, a list of ids: every rune's, in order, and none where no rune gives one. */
76
+ const idsOf = (runes: ReadonlyArray<Written>, name: string) => (): string | undefined => {
77
+ const ids = Arr.filter(Arr.filter(valuesOf(runes, name), Predicate.isString), Str.isNonEmpty)
78
+ return Bool.match(Arr.isReadonlyArrayEmpty(ids), { onTrue: constUndefined, onFalse: () => Arr.join(ids, " ") })
79
+ }
80
+
81
+ const readerOf = (runes: ReadonlyArray<Written>, name: string): (() => unknown) =>
82
+ Bool.match(ID_LISTS.has(name), {
83
+ onTrue: () => idsOf(runes, name),
84
+ onFalse: () => lastOf(runes, name),
85
+ })
86
+
87
+ /** Every rune's `props` as one set of keys: each name a getter over the runes that give it. None for a ward whose runes give no `props`. */
88
+ export const propKeysOf = (runes: ReadonlyArray<Written>): PropKeys =>
89
+ Rec.fromIterableWith(Arr.dedupe(Arr.flatMap(runes, (each) => Rec.keys(each))), (name) => [name, { get: readerOf(runes, name), enumerable: true }])
90
+
91
+ const none = (keys: PropKeys): boolean => Rec.isEmptyRecord(keys)
92
+
93
+ /**
94
+ * The names among `keys` that `ward` doesn't have already: what the hooks add to it. One it has is
95
+ * the binding's own to set (a drag's `draggable`, a Reorder row's two) or a member of the ward's,
96
+ * and a rune's of that name is left out. Called before anything else of the hooks' is put on the ward.
97
+ */
98
+ export const addedTo = (ward: object, keys: PropKeys): PropKeys => Rec.filter(keys, (_, name) => !(name in ward))
99
+
100
+ /** The ward's own spread: what Solid reads wherever it's spread on an element, a function source being called for it. */
101
+ const spreadOf = (ward: object): object => (ward as () => object)()
102
+
103
+ /**
104
+ * `ward` carrying `keys` ({@link addedTo}'s): on its spread, what a spread of it sets on its element
105
+ * beside its `ref` and `style`; and on itself, as its `style` and Starting attributes are, which is
106
+ * what a component the ward is spread on reads as its props.
107
+ */
108
+ export const carrying = <W extends object>(ward: W, keys: PropKeys): W => {
109
+ if (none(keys)) return ward
110
+ Object.defineProperties(spreadOf(ward), keys)
111
+ return Object.defineProperties(ward, keys)
112
+ }
113
+
114
+ /** A ward's `with`: the element's own `ref` and `style` in, a spread out. */
115
+ type With = (own: unknown) => object
116
+
117
+ /**
118
+ * `ward.with(own)` carrying `keys` too ({@link addedTo}'s): its own `with`, over the binding's, whose
119
+ * spread is made anew at each call with the ward's `ref`, `style` and Starting attributes alone.
120
+ *
121
+ * On a server as in a browser. A browser's `with` is a member every ward shares, which a key of the
122
+ * ward's own goes over; a server's is a key of its own, left configurable for this (`ward.tsx`). It
123
+ * matters most there: Solid takes a server's attributes as they are when it hydrates, so one left
124
+ * out of a server's markup would stay out.
125
+ *
126
+ * A Reorder row's two attributes aren't among `keys`, being the binding's, and its `with` leaves
127
+ * them out: a rune's go where the row's own do, with or without them.
128
+ */
129
+ export const withCarrying = <W extends object>(ward: W, keys: PropKeys): W => {
130
+ if (none(keys)) return ward
131
+ // The binding's own, read once: a browser's off what every ward shares, a server's off the ward.
132
+ const binding = (ward as { readonly with: With }).with
133
+ // Not enumerable, so a spread never sees it.
134
+ return Object.defineProperty(ward, "with", { value: (own: unknown): object => Object.defineProperties(binding(own), keys) })
135
+ }
136
+
137
+ /** Whether `name` is one of `keys`: what Solid's spread of a ward given its Subject is told to leave to the hooks. */
138
+ export const isOneOf =
139
+ (keys: PropKeys) =>
140
+ (name: string): boolean =>
141
+ Rec.has(keys, name)
142
+
143
+ /** One attribute of an element's: its name, and a value for it. */
144
+ type Attribute<Value> = readonly [name: string, value: Value]
145
+
146
+ /** What Solid writes for a value: none for `false` and for nothing, an empty attribute for `true`. */
147
+ const isOff = (value: unknown): boolean => Bool.or(value === false, Predicate.isNullish(value))
148
+
149
+ const textOf = (value: unknown): string => Bool.match(value === true, { onTrue: () => "", onFalse: () => String(value) })
150
+
151
+ const write =
152
+ (el: Element) =>
153
+ ([name, value]: Attribute<unknown>): void =>
154
+ Bool.match(isOff(value), {
155
+ onTrue: () => el.removeAttribute(name),
156
+ onFalse: () => el.setAttribute(name, textOf(value)),
157
+ })
158
+
159
+ /** What an element had under a name before a ward set it, put back: its value, or none. */
160
+ const putBack =
161
+ (el: Element) =>
162
+ ([name, was]: Attribute<string | null>): void =>
163
+ Option.match(Option.fromNullOr(was), {
164
+ onNone: () => el.removeAttribute(name),
165
+ onSome: (value) => el.setAttribute(name, value),
166
+ })
167
+
168
+ /**
169
+ * `keys` set on `el`, the Subject a ward was given: an element another renders, which the ward is
170
+ * never spread on and which outlives it. Each name written as any of them changes, and what `el` had
171
+ * under each put back once the owner this is called under ends.
172
+ *
173
+ * By the hooks themselves, where a spread ward's are Solid's to write. Solid's spread writes no
174
+ * attribute on a connected element while the page hydrates, taking a server's markup as it is, and a
175
+ * ward given its Subject put nothing in that markup: its runes' attributes were never set. What
176
+ * `el` had is read as this is called; changed since by whoever renders it, it's that older value
177
+ * that's put back.
178
+ */
179
+ export const settingOn = (el: Element, keys: PropKeys): void => {
180
+ if (none(keys)) return
181
+ const names = Rec.keys(keys)
182
+ const before = Arr.map(names, (name): Attribute<string | null> => [name, el.getAttribute(name)])
183
+ const now = Object.defineProperties({}, keys) as Readonly<Record<string, unknown>>
184
+ createRenderEffect(
185
+ () => Arr.map(names, (name): Attribute<unknown> => [name, now[name]]),
186
+ (attributes) => Arr.forEach(attributes, write(el)),
187
+ CLIENT_ONLY,
188
+ )
189
+ onCleanup(() => Arr.forEach(before, putBack(el)))
190
+ }