@wardic/solid 2.2.0 → 3.0.0-next.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 (475) hide show
  1. package/README.md +22 -18
  2. package/dist/browser/config-view.js +33 -5
  3. package/dist/browser/config-view.js.map +1 -1
  4. package/dist/browser/create-batch.js +1 -1
  5. package/dist/browser/element-style.js +61 -7
  6. package/dist/browser/element-style.js.map +1 -1
  7. package/dist/browser/element.js +19 -2
  8. package/dist/browser/element.js.map +1 -1
  9. package/dist/browser/feature-section.js +5 -13
  10. package/dist/browser/feature-section.js.map +1 -1
  11. package/dist/browser/hooks/auto.js +270 -0
  12. package/dist/browser/hooks/auto.js.map +1 -0
  13. package/dist/browser/hooks/config-scope.js +120 -0
  14. package/dist/browser/hooks/config-scope.js.map +1 -0
  15. package/dist/browser/hooks/config.js +37 -0
  16. package/dist/browser/hooks/config.js.map +1 -0
  17. package/dist/browser/hooks/drag.js +632 -0
  18. package/dist/browser/hooks/drag.js.map +1 -0
  19. package/dist/browser/hooks/elements.js +183 -0
  20. package/dist/browser/hooks/elements.js.map +1 -0
  21. package/dist/browser/hooks/group.js +28 -0
  22. package/dist/browser/hooks/group.js.map +1 -0
  23. package/dist/browser/hooks/index.js +10 -0
  24. package/dist/browser/hooks/index.js.map +1 -0
  25. package/dist/browser/hooks/kept.js +32 -0
  26. package/dist/browser/hooks/kept.js.map +1 -0
  27. package/dist/browser/hooks/layout-group-of.js +39 -0
  28. package/dist/browser/hooks/layout-group-of.js.map +1 -0
  29. package/dist/browser/hooks/layout-group.js +92 -0
  30. package/dist/browser/hooks/layout-group.js.map +1 -0
  31. package/dist/browser/hooks/make-ward.js +157 -0
  32. package/dist/browser/hooks/make-ward.js.map +1 -0
  33. package/dist/browser/hooks/presence-scope.js +87 -0
  34. package/dist/browser/hooks/presence-scope.js.map +1 -0
  35. package/dist/browser/hooks/presence.js +24 -0
  36. package/dist/browser/hooks/presence.js.map +1 -0
  37. package/dist/browser/hooks/props.js +148 -0
  38. package/dist/browser/hooks/props.js.map +1 -0
  39. package/dist/browser/hooks/reads.js +241 -0
  40. package/dist/browser/hooks/reads.js.map +1 -0
  41. package/dist/browser/hooks/refs.js +87 -0
  42. package/dist/browser/hooks/refs.js.map +1 -0
  43. package/dist/browser/hooks/reorder-elements.js +268 -0
  44. package/dist/browser/hooks/reorder-elements.js.map +1 -0
  45. package/dist/browser/hooks/reorder.js +176 -0
  46. package/dist/browser/hooks/reorder.js.map +1 -0
  47. package/dist/browser/hooks/rune.js +799 -0
  48. package/dist/browser/hooks/rune.js.map +1 -0
  49. package/dist/browser/hooks/server-features.client.js +2 -0
  50. package/dist/browser/hooks/server-features.client.js.map +1 -0
  51. package/dist/browser/hooks/server-features.js +13 -0
  52. package/dist/browser/hooks/server-features.js.map +1 -0
  53. package/dist/browser/hooks/settings.js +29 -0
  54. package/dist/browser/hooks/settings.js.map +1 -0
  55. package/dist/browser/hooks/setup.js +154 -0
  56. package/dist/browser/hooks/setup.js.map +1 -0
  57. package/dist/browser/hooks/stage.js +117 -0
  58. package/dist/browser/hooks/stage.js.map +1 -0
  59. package/dist/browser/hooks/ward.js +2193 -0
  60. package/dist/browser/hooks/ward.js.map +1 -0
  61. package/dist/browser/hooks/wardic-provider.js +29 -0
  62. package/dist/browser/hooks/wardic-provider.js.map +1 -0
  63. package/dist/browser/hooks/wardic-scope.js +68 -0
  64. package/dist/browser/hooks/wardic-scope.js.map +1 -0
  65. package/dist/browser/hooks/wards.js +562 -0
  66. package/dist/browser/hooks/wards.js.map +1 -0
  67. package/dist/browser/index.js +23 -11
  68. package/dist/browser/index.js.map +1 -1
  69. package/dist/browser/layout.js +7 -58
  70. package/dist/browser/layout.js.map +1 -1
  71. package/dist/browser/lazy-batch-gestures.js +1 -1
  72. package/dist/browser/lifecycle.js +37 -0
  73. package/dist/browser/lifecycle.js.map +1 -1
  74. package/dist/browser/presence-handle.js +28 -12
  75. package/dist/browser/presence-handle.js.map +1 -1
  76. package/dist/browser/presence.js +3 -1
  77. package/dist/browser/presence.js.map +1 -1
  78. package/dist/browser/provider.js +85 -70
  79. package/dist/browser/provider.js.map +1 -1
  80. package/dist/browser/reorder-components.js +50 -0
  81. package/dist/browser/reorder-components.js.map +1 -0
  82. package/dist/browser/reorder.js +46 -274
  83. package/dist/browser/reorder.js.map +1 -1
  84. package/dist/browser/stage.js.map +1 -1
  85. package/dist/browser/unstable/v2/index.js +0 -8
  86. package/dist/browser/unstable/v2/index.js.map +1 -1
  87. package/dist/browser/v1/index.js +1 -1
  88. package/dist/browser/v1/index.js.map +1 -1
  89. package/dist/browser/variant-node.js +4 -2
  90. package/dist/browser/variant-node.js.map +1 -1
  91. package/dist/browser/w.js +33 -3
  92. package/dist/browser/w.js.map +1 -1
  93. package/dist/browser/ward.js +576 -49
  94. package/dist/browser/ward.js.map +1 -1
  95. package/dist/browser/wardic-config.js +62 -29
  96. package/dist/browser/wardic-config.js.map +1 -1
  97. package/dist/browser/wardic-context.js +23 -0
  98. package/dist/browser/wardic-context.js.map +1 -0
  99. package/dist/browser/wardic.js +3 -0
  100. package/dist/browser/wardic.js.map +1 -1
  101. package/dist/server/config-view.js +33 -5
  102. package/dist/server/config-view.js.map +1 -1
  103. package/dist/server/create-batch.js +1 -1
  104. package/dist/server/element-style.js +61 -7
  105. package/dist/server/element-style.js.map +1 -1
  106. package/dist/server/element.js +19 -2
  107. package/dist/server/element.js.map +1 -1
  108. package/dist/server/feature-section.js +5 -13
  109. package/dist/server/feature-section.js.map +1 -1
  110. package/dist/server/hooks/auto.js +270 -0
  111. package/dist/server/hooks/auto.js.map +1 -0
  112. package/dist/server/hooks/config-scope.js +120 -0
  113. package/dist/server/hooks/config-scope.js.map +1 -0
  114. package/dist/server/hooks/config.js +37 -0
  115. package/dist/server/hooks/config.js.map +1 -0
  116. package/dist/server/hooks/drag.js +632 -0
  117. package/dist/server/hooks/drag.js.map +1 -0
  118. package/dist/server/hooks/elements.js +192 -0
  119. package/dist/server/hooks/elements.js.map +1 -0
  120. package/dist/server/hooks/group.js +28 -0
  121. package/dist/server/hooks/group.js.map +1 -0
  122. package/dist/server/hooks/index.js +10 -0
  123. package/dist/server/hooks/index.js.map +1 -0
  124. package/dist/server/hooks/kept.js +32 -0
  125. package/dist/server/hooks/kept.js.map +1 -0
  126. package/dist/server/hooks/layout-group-of.js +39 -0
  127. package/dist/server/hooks/layout-group-of.js.map +1 -0
  128. package/dist/server/hooks/layout-group.js +109 -0
  129. package/dist/server/hooks/layout-group.js.map +1 -0
  130. package/dist/server/hooks/make-ward.js +157 -0
  131. package/dist/server/hooks/make-ward.js.map +1 -0
  132. package/dist/server/hooks/presence-scope.js +86 -0
  133. package/dist/server/hooks/presence-scope.js.map +1 -0
  134. package/dist/server/hooks/presence.js +24 -0
  135. package/dist/server/hooks/presence.js.map +1 -0
  136. package/dist/server/hooks/props.js +148 -0
  137. package/dist/server/hooks/props.js.map +1 -0
  138. package/dist/server/hooks/reads.js +241 -0
  139. package/dist/server/hooks/reads.js.map +1 -0
  140. package/dist/server/hooks/refs.js +87 -0
  141. package/dist/server/hooks/refs.js.map +1 -0
  142. package/dist/server/hooks/reorder-elements.js +308 -0
  143. package/dist/server/hooks/reorder-elements.js.map +1 -0
  144. package/dist/server/hooks/reorder.js +176 -0
  145. package/dist/server/hooks/reorder.js.map +1 -0
  146. package/dist/server/hooks/rune.js +799 -0
  147. package/dist/server/hooks/rune.js.map +1 -0
  148. package/dist/server/hooks/server-features.client.js +2 -0
  149. package/dist/server/hooks/server-features.client.js.map +1 -0
  150. package/dist/server/hooks/server-features.js +13 -0
  151. package/dist/server/hooks/server-features.js.map +1 -0
  152. package/dist/server/hooks/settings.js +29 -0
  153. package/dist/server/hooks/settings.js.map +1 -0
  154. package/dist/server/hooks/setup.js +154 -0
  155. package/dist/server/hooks/setup.js.map +1 -0
  156. package/dist/server/hooks/stage.js +117 -0
  157. package/dist/server/hooks/stage.js.map +1 -0
  158. package/dist/server/hooks/ward.js +2193 -0
  159. package/dist/server/hooks/ward.js.map +1 -0
  160. package/dist/server/hooks/wardic-provider.js +29 -0
  161. package/dist/server/hooks/wardic-provider.js.map +1 -0
  162. package/dist/server/hooks/wardic-scope.js +68 -0
  163. package/dist/server/hooks/wardic-scope.js.map +1 -0
  164. package/dist/server/hooks/wards.js +562 -0
  165. package/dist/server/hooks/wards.js.map +1 -0
  166. package/dist/server/index.js +23 -11
  167. package/dist/server/index.js.map +1 -1
  168. package/dist/server/layout.js +7 -75
  169. package/dist/server/layout.js.map +1 -1
  170. package/dist/server/lazy-batch-gestures.js +1 -1
  171. package/dist/server/lifecycle.js +37 -0
  172. package/dist/server/lifecycle.js.map +1 -1
  173. package/dist/server/presence-handle.js +28 -12
  174. package/dist/server/presence-handle.js.map +1 -1
  175. package/dist/server/presence.js +3 -1
  176. package/dist/server/presence.js.map +1 -1
  177. package/dist/server/provider.js +86 -80
  178. package/dist/server/provider.js.map +1 -1
  179. package/dist/server/reorder-components.js +50 -0
  180. package/dist/server/reorder-components.js.map +1 -0
  181. package/dist/server/reorder.js +46 -344
  182. package/dist/server/reorder.js.map +1 -1
  183. package/dist/server/stage.js.map +1 -1
  184. package/dist/server/unstable/v2/index.js +0 -8
  185. package/dist/server/unstable/v2/index.js.map +1 -1
  186. package/dist/server/v1/index.js +1 -1
  187. package/dist/server/v1/index.js.map +1 -1
  188. package/dist/server/variant-node.js +4 -2
  189. package/dist/server/variant-node.js.map +1 -1
  190. package/dist/server/w.js +33 -3
  191. package/dist/server/w.js.map +1 -1
  192. package/dist/server/ward.js +576 -49
  193. package/dist/server/ward.js.map +1 -1
  194. package/dist/server/wardic-config.js +63 -30
  195. package/dist/server/wardic-config.js.map +1 -1
  196. package/dist/server/wardic-context.js +23 -0
  197. package/dist/server/wardic-context.js.map +1 -0
  198. package/dist/server/wardic.js +3 -0
  199. package/dist/server/wardic.js.map +1 -1
  200. package/dist/solid/batch-reorder-group.d.ts +1 -1
  201. package/dist/solid/batch-reorder.d.ts +1 -1
  202. package/dist/solid/batch-reorder.d.ts.map +1 -1
  203. package/dist/solid/config-view.d.ts +11 -0
  204. package/dist/solid/config-view.d.ts.map +1 -1
  205. package/dist/solid/config-view.js +29 -6
  206. package/dist/solid/config-view.js.map +1 -1
  207. package/dist/solid/create-batch.jsx +1 -1
  208. package/dist/solid/element-style.d.ts +16 -2
  209. package/dist/solid/element-style.d.ts.map +1 -1
  210. package/dist/solid/element-style.js +61 -7
  211. package/dist/solid/element-style.js.map +1 -1
  212. package/dist/solid/element.d.ts +3 -1
  213. package/dist/solid/element.d.ts.map +1 -1
  214. package/dist/solid/element.jsx +21 -2
  215. package/dist/solid/element.jsx.map +1 -1
  216. package/dist/solid/feature-section.d.ts +0 -7
  217. package/dist/solid/feature-section.d.ts.map +1 -1
  218. package/dist/solid/feature-section.js +5 -13
  219. package/dist/solid/feature-section.js.map +1 -1
  220. package/dist/solid/hooks/auto.d.ts +44 -0
  221. package/dist/solid/hooks/auto.d.ts.map +1 -0
  222. package/dist/solid/hooks/auto.js +269 -0
  223. package/dist/solid/hooks/auto.js.map +1 -0
  224. package/dist/solid/hooks/config-scope.d.ts +84 -0
  225. package/dist/solid/hooks/config-scope.d.ts.map +1 -0
  226. package/dist/solid/hooks/config-scope.jsx +128 -0
  227. package/dist/solid/hooks/config-scope.jsx.map +1 -0
  228. package/dist/solid/hooks/config.d.ts +28 -0
  229. package/dist/solid/hooks/config.d.ts.map +1 -0
  230. package/dist/solid/hooks/config.jsx +37 -0
  231. package/dist/solid/hooks/config.jsx.map +1 -0
  232. package/dist/solid/hooks/drag.d.ts +220 -0
  233. package/dist/solid/hooks/drag.d.ts.map +1 -0
  234. package/dist/solid/hooks/drag.js +585 -0
  235. package/dist/solid/hooks/drag.js.map +1 -0
  236. package/dist/solid/hooks/elements.d.ts +11 -0
  237. package/dist/solid/hooks/elements.d.ts.map +1 -0
  238. package/dist/solid/hooks/elements.jsx +218 -0
  239. package/dist/solid/hooks/elements.jsx.map +1 -0
  240. package/dist/solid/hooks/group.d.ts +46 -0
  241. package/dist/solid/hooks/group.d.ts.map +1 -0
  242. package/dist/solid/hooks/group.jsx +25 -0
  243. package/dist/solid/hooks/group.jsx.map +1 -0
  244. package/dist/solid/hooks/index.d.ts +28 -0
  245. package/dist/solid/hooks/index.d.ts.map +1 -0
  246. package/dist/solid/hooks/index.js +10 -0
  247. package/dist/solid/hooks/index.js.map +1 -0
  248. package/dist/solid/hooks/kept.d.ts +60 -0
  249. package/dist/solid/hooks/kept.d.ts.map +1 -0
  250. package/dist/solid/hooks/kept.js +33 -0
  251. package/dist/solid/hooks/kept.js.map +1 -0
  252. package/dist/solid/hooks/layout-group-of.d.ts +27 -0
  253. package/dist/solid/hooks/layout-group-of.d.ts.map +1 -0
  254. package/dist/solid/hooks/layout-group-of.js +39 -0
  255. package/dist/solid/hooks/layout-group-of.js.map +1 -0
  256. package/dist/solid/hooks/layout-group.d.ts +60 -0
  257. package/dist/solid/hooks/layout-group.d.ts.map +1 -0
  258. package/dist/solid/hooks/layout-group.jsx +80 -0
  259. package/dist/solid/hooks/layout-group.jsx.map +1 -0
  260. package/dist/solid/hooks/make-ward.d.ts +123 -0
  261. package/dist/solid/hooks/make-ward.d.ts.map +1 -0
  262. package/dist/solid/hooks/make-ward.js +147 -0
  263. package/dist/solid/hooks/make-ward.js.map +1 -0
  264. package/dist/solid/hooks/presence-scope.d.ts +84 -0
  265. package/dist/solid/hooks/presence-scope.d.ts.map +1 -0
  266. package/dist/solid/hooks/presence-scope.jsx +62 -0
  267. package/dist/solid/hooks/presence-scope.jsx.map +1 -0
  268. package/dist/solid/hooks/presence.d.ts +51 -0
  269. package/dist/solid/hooks/presence.d.ts.map +1 -0
  270. package/dist/solid/hooks/presence.jsx +26 -0
  271. package/dist/solid/hooks/presence.jsx.map +1 -0
  272. package/dist/solid/hooks/props.d.ts +52 -0
  273. package/dist/solid/hooks/props.d.ts.map +1 -0
  274. package/dist/solid/hooks/props.js +140 -0
  275. package/dist/solid/hooks/props.js.map +1 -0
  276. package/dist/solid/hooks/reads.d.ts +38 -0
  277. package/dist/solid/hooks/reads.d.ts.map +1 -0
  278. package/dist/solid/hooks/reads.js +218 -0
  279. package/dist/solid/hooks/reads.js.map +1 -0
  280. package/dist/solid/hooks/refs.d.ts +25 -0
  281. package/dist/solid/hooks/refs.d.ts.map +1 -0
  282. package/dist/solid/hooks/refs.js +89 -0
  283. package/dist/solid/hooks/refs.js.map +1 -0
  284. package/dist/solid/hooks/reorder-elements.d.ts +23 -0
  285. package/dist/solid/hooks/reorder-elements.d.ts.map +1 -0
  286. package/dist/solid/hooks/reorder-elements.jsx +273 -0
  287. package/dist/solid/hooks/reorder-elements.jsx.map +1 -0
  288. package/dist/solid/hooks/reorder.d.ts +55 -0
  289. package/dist/solid/hooks/reorder.d.ts.map +1 -0
  290. package/dist/solid/hooks/reorder.js +152 -0
  291. package/dist/solid/hooks/reorder.js.map +1 -0
  292. package/dist/solid/hooks/rune.d.ts +885 -0
  293. package/dist/solid/hooks/rune.d.ts.map +1 -0
  294. package/dist/solid/hooks/rune.js +816 -0
  295. package/dist/solid/hooks/rune.js.map +1 -0
  296. package/dist/solid/hooks/server-features.client.d.ts +10 -0
  297. package/dist/solid/hooks/server-features.client.d.ts.map +1 -0
  298. package/dist/solid/hooks/server-features.client.js +2 -0
  299. package/dist/solid/hooks/server-features.client.js.map +1 -0
  300. package/dist/solid/hooks/server-features.d.ts +10 -0
  301. package/dist/solid/hooks/server-features.d.ts.map +1 -0
  302. package/dist/solid/hooks/server-features.js +13 -0
  303. package/dist/solid/hooks/server-features.js.map +1 -0
  304. package/dist/solid/hooks/settings.d.ts +11 -0
  305. package/dist/solid/hooks/settings.d.ts.map +1 -0
  306. package/dist/solid/hooks/settings.js +31 -0
  307. package/dist/solid/hooks/settings.js.map +1 -0
  308. package/dist/solid/hooks/setup.d.ts +31 -0
  309. package/dist/solid/hooks/setup.d.ts.map +1 -0
  310. package/dist/solid/hooks/setup.js +155 -0
  311. package/dist/solid/hooks/setup.js.map +1 -0
  312. package/dist/solid/hooks/stage.d.ts +187 -0
  313. package/dist/solid/hooks/stage.d.ts.map +1 -0
  314. package/dist/solid/hooks/stage.js +117 -0
  315. package/dist/solid/hooks/stage.js.map +1 -0
  316. package/dist/solid/hooks/ward.d.ts +394 -0
  317. package/dist/solid/hooks/ward.d.ts.map +1 -0
  318. package/dist/solid/hooks/ward.js +2237 -0
  319. package/dist/solid/hooks/ward.js.map +1 -0
  320. package/dist/solid/hooks/wardic-provider.d.ts +32 -0
  321. package/dist/solid/hooks/wardic-provider.d.ts.map +1 -0
  322. package/dist/solid/hooks/wardic-provider.jsx +29 -0
  323. package/dist/solid/hooks/wardic-provider.jsx.map +1 -0
  324. package/dist/solid/hooks/wardic-scope.d.ts +49 -0
  325. package/dist/solid/hooks/wardic-scope.d.ts.map +1 -0
  326. package/dist/solid/hooks/wardic-scope.jsx +63 -0
  327. package/dist/solid/hooks/wardic-scope.jsx.map +1 -0
  328. package/dist/solid/hooks/wards.d.ts +157 -0
  329. package/dist/solid/hooks/wards.d.ts.map +1 -0
  330. package/dist/solid/hooks/wards.js +522 -0
  331. package/dist/solid/hooks/wards.js.map +1 -0
  332. package/dist/solid/index.d.ts +21 -14
  333. package/dist/solid/index.d.ts.map +1 -1
  334. package/dist/solid/index.jsx +23 -11
  335. package/dist/solid/index.jsx.map +1 -1
  336. package/dist/solid/layout.d.ts +2 -44
  337. package/dist/solid/layout.d.ts.map +1 -1
  338. package/dist/solid/layout.jsx +7 -49
  339. package/dist/solid/layout.jsx.map +1 -1
  340. package/dist/solid/lazy-batch-gestures.js +1 -1
  341. package/dist/solid/lazy-batch-gestures.js.map +1 -1
  342. package/dist/solid/lifecycle.d.ts +19 -0
  343. package/dist/solid/lifecycle.d.ts.map +1 -1
  344. package/dist/solid/lifecycle.js +40 -0
  345. package/dist/solid/lifecycle.js.map +1 -1
  346. package/dist/solid/presence-handle.d.ts +13 -6
  347. package/dist/solid/presence-handle.d.ts.map +1 -1
  348. package/dist/solid/presence-handle.js +30 -12
  349. package/dist/solid/presence-handle.js.map +1 -1
  350. package/dist/solid/presence.d.ts +3 -1
  351. package/dist/solid/presence.d.ts.map +1 -1
  352. package/dist/solid/presence.jsx +3 -1
  353. package/dist/solid/presence.jsx.map +1 -1
  354. package/dist/solid/provider.d.ts +25 -32
  355. package/dist/solid/provider.d.ts.map +1 -1
  356. package/dist/solid/provider.jsx +86 -62
  357. package/dist/solid/provider.jsx.map +1 -1
  358. package/dist/solid/reorder-components.d.ts +32 -0
  359. package/dist/solid/reorder-components.d.ts.map +1 -0
  360. package/dist/solid/reorder-components.jsx +49 -0
  361. package/dist/solid/reorder-components.jsx.map +1 -0
  362. package/dist/solid/reorder.d.ts +50 -76
  363. package/dist/solid/reorder.d.ts.map +1 -1
  364. package/dist/solid/reorder.jsx +40 -202
  365. package/dist/solid/reorder.jsx.map +1 -1
  366. package/dist/solid/stage.d.ts +14 -0
  367. package/dist/solid/stage.d.ts.map +1 -1
  368. package/dist/solid/stage.js.map +1 -1
  369. package/dist/solid/unstable/v2/index.d.ts +2 -26
  370. package/dist/solid/unstable/v2/index.d.ts.map +1 -1
  371. package/dist/solid/unstable/v2/index.jsx +0 -16
  372. package/dist/solid/unstable/v2/index.jsx.map +1 -1
  373. package/dist/solid/v1/index.d.ts +1 -1
  374. package/dist/solid/v1/index.d.ts.map +1 -1
  375. package/dist/solid/v1/index.jsx +1 -1
  376. package/dist/solid/v1/index.jsx.map +1 -1
  377. package/dist/solid/variant-node.d.ts +6 -0
  378. package/dist/solid/variant-node.d.ts.map +1 -1
  379. package/dist/solid/variant-node.js +2 -0
  380. package/dist/solid/variant-node.js.map +1 -1
  381. package/dist/solid/w.d.ts +9 -3
  382. package/dist/solid/w.d.ts.map +1 -1
  383. package/dist/solid/w.jsx +36 -3
  384. package/dist/solid/w.jsx.map +1 -1
  385. package/dist/solid/ward.d.ts +134 -7
  386. package/dist/solid/ward.d.ts.map +1 -1
  387. package/dist/solid/ward.jsx +546 -48
  388. package/dist/solid/ward.jsx.map +1 -1
  389. package/dist/solid/wardic-config.d.ts +17 -12
  390. package/dist/solid/wardic-config.d.ts.map +1 -1
  391. package/dist/solid/wardic-config.jsx +68 -22
  392. package/dist/solid/wardic-config.jsx.map +1 -1
  393. package/dist/solid/wardic-context.d.ts +15 -0
  394. package/dist/solid/wardic-context.d.ts.map +1 -0
  395. package/dist/solid/wardic-context.js +23 -0
  396. package/dist/solid/wardic-context.js.map +1 -0
  397. package/dist/solid/wardic-instance.d.ts +6 -4
  398. package/dist/solid/wardic-instance.d.ts.map +1 -1
  399. package/dist/solid/wardic.d.ts +3 -0
  400. package/dist/solid/wardic.d.ts.map +1 -1
  401. package/dist/solid/wardic.jsx +3 -0
  402. package/dist/solid/wardic.jsx.map +1 -1
  403. package/package.json +26 -6
  404. package/src/batch-reorder-group.tsx +1 -1
  405. package/src/batch-reorder.ts +1 -1
  406. package/src/config-view.ts +30 -6
  407. package/src/create-batch.tsx +1 -1
  408. package/src/element-style.ts +77 -9
  409. package/src/element.tsx +25 -4
  410. package/src/feature-section.ts +5 -15
  411. package/src/hooks/auto.ts +303 -0
  412. package/src/hooks/config-scope.tsx +215 -0
  413. package/src/hooks/config.tsx +54 -0
  414. package/src/hooks/drag.ts +740 -0
  415. package/src/hooks/elements.tsx +234 -0
  416. package/src/hooks/group.tsx +55 -0
  417. package/src/hooks/index.ts +41 -0
  418. package/src/hooks/kept.ts +89 -0
  419. package/src/hooks/layout-group-of.ts +46 -0
  420. package/src/hooks/layout-group.tsx +111 -0
  421. package/src/hooks/make-ward.ts +218 -0
  422. package/src/hooks/presence-scope.tsx +155 -0
  423. package/src/hooks/presence.tsx +67 -0
  424. package/src/hooks/props.ts +190 -0
  425. package/src/hooks/reads.ts +258 -0
  426. package/src/hooks/refs.ts +114 -0
  427. package/src/hooks/reorder-elements.tsx +321 -0
  428. package/src/hooks/reorder.ts +205 -0
  429. package/src/hooks/rune.ts +1755 -0
  430. package/src/hooks/server-features.client.ts +10 -0
  431. package/src/hooks/server-features.ts +12 -0
  432. package/src/hooks/settings.ts +44 -0
  433. package/src/hooks/setup.ts +184 -0
  434. package/src/hooks/stage.ts +359 -0
  435. package/src/hooks/ward.ts +2563 -0
  436. package/src/hooks/wardic-provider.tsx +51 -0
  437. package/src/hooks/wardic-scope.tsx +112 -0
  438. package/src/hooks/wards.ts +679 -0
  439. package/src/index.tsx +27 -15
  440. package/src/layout.tsx +7 -74
  441. package/src/lazy-batch-gestures.ts +1 -1
  442. package/src/lifecycle.ts +40 -0
  443. package/src/presence-handle.ts +39 -20
  444. package/src/presence.tsx +3 -1
  445. package/src/provider.tsx +96 -71
  446. package/src/reorder-components.tsx +61 -0
  447. package/src/reorder.tsx +84 -303
  448. package/src/stage.ts +15 -0
  449. package/src/unstable/v2/index.tsx +2 -26
  450. package/src/v1/index.tsx +1 -1
  451. package/src/variant-node.ts +8 -0
  452. package/src/w.tsx +38 -5
  453. package/src/ward.tsx +674 -48
  454. package/src/wardic-config.tsx +68 -21
  455. package/src/wardic-context.ts +26 -0
  456. package/src/wardic-instance.ts +6 -4
  457. package/src/wardic.tsx +3 -0
  458. package/dist/browser/create-wardic.js +0 -36
  459. package/dist/browser/create-wardic.js.map +0 -1
  460. package/dist/browser/presence-hooks.js +0 -144
  461. package/dist/browser/presence-hooks.js.map +0 -1
  462. package/dist/server/create-wardic.js +0 -36
  463. package/dist/server/create-wardic.js.map +0 -1
  464. package/dist/server/presence-hooks.js +0 -144
  465. package/dist/server/presence-hooks.js.map +0 -1
  466. package/dist/solid/create-wardic.d.ts +0 -25
  467. package/dist/solid/create-wardic.d.ts.map +0 -1
  468. package/dist/solid/create-wardic.jsx +0 -34
  469. package/dist/solid/create-wardic.jsx.map +0 -1
  470. package/dist/solid/presence-hooks.d.ts +0 -53
  471. package/dist/solid/presence-hooks.d.ts.map +0 -1
  472. package/dist/solid/presence-hooks.jsx +0 -117
  473. package/dist/solid/presence-hooks.jsx.map +0 -1
  474. package/src/create-wardic.tsx +0 -46
  475. package/src/presence-hooks.tsx +0 -159
@@ -0,0 +1,1755 @@
1
+ /**
2
+ * Runes (probe: hooks-first): the pieces `createWard(...runes)` is made of, and how they join into the one
3
+ * config a ward reads.
4
+ *
5
+ * - **A rune** is a config object, or `createRune((ward) => config)` for one that listens to the ward
6
+ * it's part of. A bare function isn't a rune: the ward's own error for a whole config given as an
7
+ * accessor still catches it (ADR-0045 *Amendment (#259)*). `createRune(config)` is the config itself,
8
+ * checked where it's written.
9
+ * - **Its keys are Wardic's, and its Environment's.** Wardic's own say motion, whatever is moved
10
+ * ({@link WardicKeys}); each Environment takes those its ward carries and adds its own, the page
11
+ * here ({@link PageKeys}) and a Stage in `stage.ts`. A rune's type is the keys it has and no
12
+ * others ({@link MadeRune}), so one of Wardic's keys alone fits both, and a key a ward doesn't take
13
+ * is an error at the `createWard` that's given it, which names the key ({@link GivenRune}).
14
+ * - **They join key by key**, a later rune winning: `initial`, `animate`, `exit` and the `while*`
15
+ * targets, `transition` and `style` merge their keys when both are objects; `variants` merge by
16
+ * name, then key by key; anything else is the later rune's. But a `ref`: every rune's runs, and
17
+ * none wins ({@link RuneRef}). And its `props` join name by name, a later rune's winning a name
18
+ * and a list of ids joining, onto the ward's own spread ({@link RuneProps}, `props.ts`).
19
+ * - **`followers`** (`{ stagger, delay, from, order }`), on a ward or inside one variant, is its
20
+ * followers' timing: read into `transition`'s `staggerChildren`, `delayChildren`,
21
+ * `staggerDirection` and `when`.
22
+ * - **A follower's own names are resolved here** (`follow` given): `animate: "open"` becomes its
23
+ * `variants.open`, so it stays a Variant child, following its leader for every prop it doesn't set
24
+ * itself and keeping its stagger slot. A gesture's name is kept, `whileTap: "pressed"` as it is, and
25
+ * the follower is a Variant child by its own word (core's `variantChild`, through its ward's
26
+ * internals; the gap grill's Q26): it joins its leader all the same, and hands the name down to
27
+ * followers of its own, as a `w.*` child does.
28
+ *
29
+ * Throwaway code: quick where it isn't on a frame's path. Nothing here runs per frame.
30
+ *
31
+ * @module
32
+ */
33
+ import type { JSX } from "@solidjs/web"
34
+ import * as AnimationControls from "@wardic/core/unstable/AnimationControls"
35
+ import type * as Config from "@wardic/core/unstable/Config"
36
+ import type * as ReducedMotion from "@wardic/core/ReducedMotion"
37
+ import * as Arr from "effect/Array"
38
+ import * as Bool from "effect/Boolean"
39
+ import * as Iter from "effect/Iterable"
40
+ import * as Match from "effect/Match"
41
+ import * as Option from "effect/Option"
42
+ import * as Predicate from "effect/Predicate"
43
+ import * as Rec from "effect/Record"
44
+ import * as UndefinedOr from "effect/UndefinedOr"
45
+ import { $PROXY, DEV, untrack } from "solid-js"
46
+ import type { Accessor } from "solid-js"
47
+ import type { AnyWard, WardConfig } from "../ward.tsx"
48
+ import type { HookWard } from "./ward.ts"
49
+ import type { Drags, WardDrag } from "./drag.ts"
50
+
51
+ /** How a leader times its followers: `followers` on a ward, or inside one of its variants. */
52
+ export interface Followers {
53
+ /** Seconds between one follower's start and the next's (`staggerChildren`). */
54
+ readonly stagger?: number | undefined
55
+ /** Seconds before the first follower starts, or a `stagger()` function for each one's whole delay (`delayChildren`). */
56
+ readonly delay?: Config.WardicVariantTransition["delayChildren"] | undefined
57
+ /** Which follower starts first: `"last"` runs them back to front (`staggerDirection: -1`). */
58
+ readonly from?: "first" | "last" | undefined
59
+ /** Who goes first (`when`): the leader, its followers, or all together (the default). */
60
+ readonly order?: "together" | "leader-first" | "followers-first" | undefined
61
+ }
62
+
63
+ /** The corner a popped ward is pinned by. */
64
+ export type PopCorner = "top-left" | "top-right" | "bottom-left" | "bottom-right"
65
+
66
+ /**
67
+ * A rune's `ref` (probe: hooks-first): a function handed its ward's Subject, for what a rune does to
68
+ * it that isn't motion. Listening to it, giving it the focus, measuring it.
69
+ *
70
+ * - **Handed its Subject, and nothing else,** once it's on the page: there to be measured and
71
+ * focused, where Solid's own `ref` has it before it's in the page. On the page a ward's `ref`s
72
+ * begin once it has settled, where Solid has such work begin (`onSettled`).
73
+ * - **Its life is the time its Subject is on show** (the ward's `mounted()`). What it returns undoes
74
+ * it: called once a `show` ward's or a row's exit has landed, hidden or taken away alike, when the
75
+ * ward moves to another Subject, and when the ward ends. Shown again, it runs again.
76
+ * - **Every rune's runs,** in the order the runes were given, and each one's undoing in the reverse.
77
+ * None replaces another, nor a `ref` written on the element itself.
78
+ * - **It isn't tracked and owns nothing,** as Solid's isn't. A signal read as it runs is read once
79
+ * and never followed, and Solid reports the read, as it reports one in a `ref` of its own: what's
80
+ * to follow a signal is an effect, made in a function rune's body, once for its ward. A value
81
+ * meant to be read once is read outside the `ref`: a row's `item` in the row's function, which a
82
+ * list calls untracked. And a signal it writes is best written from a listener it adds: written
83
+ * as the `ref` itself runs, it costs its ward's own effect a second run, which Solid reports too.
84
+ *
85
+ * **A listener it adds** with `addEventListener` hears a click, a key or a pointer's event before
86
+ * any handler written in the page's markup does, the Subject's own and those inside it: Solid hears
87
+ * those, the twenty-two events it delegates, from the root, once they've passed every element. So:
88
+ *
89
+ * - it takes an event with `preventDefault()`, which those handlers then see;
90
+ * - never with `stopPropagation()`, which would keep the event from every one of them;
91
+ * - and it leaves alone an event that began in a child which should keep it, a field's key say
92
+ * (`event.target !== subject`).
93
+ *
94
+ * A handler for an event Solid doesn't delegate (`onScroll`, `onFocus`, `onPointerEnter`) is on its
95
+ * element from the start, and hears it first there.
96
+ *
97
+ * **Where its ward's life isn't a `show`'s,** it's told less:
98
+ *
99
+ * - A ward with no `show`, whose Subject a `<Show>` of the app's own takes away, isn't told: Solid
100
+ * tells a `ref` nothing of a removal. Its undoing waits for the ward's next Subject, or its end.
101
+ * - A ward made inside what a `<Presence>` takes away ends as its exit starts, as a framework ends
102
+ * it, so its `ref` is undone then, its Subject still leaving.
103
+ * - Under `<Presence wait>` the next child is built while the last one leaves, and its `ref` runs
104
+ * then, before the boundary has put its Subject on the page.
105
+ */
106
+ export type RuneRef<Subject> = (subject: Subject) => void | (() => void)
107
+
108
+ /** What every element takes in its markup, as Solid's own types say it: an app adds a new attribute there, once. */
109
+ type ElementAttributes = JSX.HTMLAttributes<HTMLElement>
110
+
111
+ /**
112
+ * What an element takes in its markup that's no prop of a rune's: its handlers, a rune's own `ref`
113
+ * and `style`, a `class`, its content, a property set past its attribute, and Solid's own two.
114
+ */
115
+ type NotAnAttribute = `on${string}` | "ref" | "style" | "class" | "children" | "innerHTML" | "innerText" | "textContent" | `prop:${string}` | "$ServerOnly" | "$key"
116
+
117
+ /** What a prop is given: its value, or an accessor of it, read where its element reads it. */
118
+ export type PropValue<V> = V | Accessor<V>
119
+
120
+ /**
121
+ * A rune's `props` (probe: hooks-first): what it sets on its ward's Subject beside moving it. On the
122
+ * page, an element's attributes: its `role`, its `tabindex`, an `aria-` state, a `data-` mark of the
123
+ * rune's own.
124
+ *
125
+ * - **Every element's attributes, and no others,** each typed as Solid types it, with any `data-*`.
126
+ * One only some elements have (`disabled`, `href`) says what an element is, which its markup says.
127
+ * An attribute Solid's types don't know yet is declared once, where an app's own markup learns it
128
+ * (`JSX.HTMLAttributes`), and read here too.
129
+ * - **Set through the ward's spread,** beside its `ref` and `style`: so they're in a server's markup,
130
+ * and a component the ward is spread on takes them as props of its own. A ward given its Subject
131
+ * (`subject`) is never spread by its author: the hooks write them on that element themselves, and
132
+ * put back what was there as the ward lets go.
133
+ * - **A value may follow a signal:** an accessor of it, read where the element reads it. `false` and
134
+ * `undefined` leave the attribute off, as Solid does. `props` itself is a plain object, so what a
135
+ * ward sets is known as it's made.
136
+ * - **On the element for as long as it's rendered,** leaving included, where a `ref` is undone once
137
+ * an exit has landed. One that should come off as it leaves says so in its value.
138
+ * - **Across a ward's runes a later one wins,** but a list of ids (`aria-describedby` and its five
139
+ * fellows) joins, in the runes' order: one rune describing its Subject doesn't take another's away.
140
+ * Beside what the element's own markup says, Solid's rule holds: what's written after the spread
141
+ * wins, and what's written before it is replaced.
142
+ *
143
+ * **What's no prop,** each an error where it's written, told the way out ({@link NotAProp}):
144
+ *
145
+ * - A handler (`onClick`). In a spread, the element's own of the same name would replace it, or be
146
+ * replaced, with nothing said. A rune listens in its `ref`.
147
+ * - `style` and `ref`, a rune's own keys beside `props`: the ward animates the one and runs the other.
148
+ * - `class`. A spread's replaces the element's own, or is replaced by it. A rune marks a state with a
149
+ * `data-` attribute, which a stylesheet reads as it is.
150
+ */
151
+ export type RuneProps = RunePropsOf<undefined>
152
+
153
+ /** An element's tag, HTML's or SVG's: what a rune's `tag` names. */
154
+ export type ElementTag = keyof HTMLElementTagNameMap | keyof SVGElementTagNameMap
155
+
156
+ /** The element `Tag` names, HTML's where both name one (`a`): any HTML element where there's no tag. */
157
+ export type ElementOf<Tag> = Tag extends keyof HTMLElementTagNameMap ? HTMLElementTagNameMap[Tag] : Tag extends keyof SVGElementTagNameMap ? SVGElementTagNameMap[Tag] : HTMLElement
158
+
159
+ /** What the element `Tag` names takes in its markup, as Solid types it: what every element takes, where there's no tag. */
160
+ type AttributesOf<Tag> = Tag extends keyof JSX.IntrinsicElements ? JSX.IntrinsicElements[Tag] : ElementAttributes
161
+
162
+ /** A rune's `props` ({@link RuneProps}) on the element `Tag` names: that element's attributes, a circle's `fill`, a link's `href`. */
163
+ export type RunePropsOf<Tag> = { readonly [K in Exclude<keyof AttributesOf<Tag>, NotAnAttribute>]?: PropValue<AttributesOf<Tag>[K]> }
164
+
165
+ /** One variant of a rune: a target that may carry its followers' timing, or a function of `custom`. */
166
+ export type RuneVariant = (Config.WardicVariant & { readonly followers?: Followers | undefined }) | Config.WardicVariantResolver
167
+
168
+ /** Wardic's keys a ward's config already has. */
169
+ type WardicConfigKey = "initial" | "animate" | "exit" | "transition" | "custom" | "inherit" | "whileHover" | "whileTap" | "whileFocus" | "whileInView" | "whileDrag"
170
+
171
+ /**
172
+ * Wardic's keys (probe: hooks-first): what a rune says of motion, whatever it moves. Every
173
+ * Environment's rune is some of these with its own beside them: the page's takes them all
174
+ * ({@link RuneConfig}), a Stage's those its ward carries (`StageRune`, `stage.ts`). So a rune of these
175
+ * alone fits any ward that takes each key it has.
176
+ *
177
+ * A target's values are its Environment's too, by their names: an element's here, and on a Stage
178
+ * what its Subject takes (`StageRuneWith`, `stage.ts`). So one of these keys fits both when every
179
+ * value it names is one both animate ({@link CheckedTarget}), each as the other takes it: `x`,
180
+ * `opacity`, `scale`. What a value means is its author's to know: a page's `y` is in pixels, a
181
+ * scene's in its own units.
182
+ */
183
+ export interface WardicKeys extends Pick<WardConfig, WardicConfigKey> {
184
+ readonly variants?: Readonly<Record<string, RuneVariant>> | undefined
185
+ /**
186
+ * The ward this one follows: it takes that ward's variant names for every prop it doesn't set itself.
187
+ * The ward it follows may name its states in place (`animate: "open"`), through a function (a signal
188
+ * of the names, `animate: state`, or `() => …`, one name or several), or by a function rune's: a hook
189
+ * ward carries its variants whatever it sets. Following one that names no state at all, a ward with
190
+ * variants of its own can never be given one, which development says once for that leader; a ward with
191
+ * none may follow it only to leave with it.
192
+ *
193
+ * @example
194
+ * const turns = createRune({ variants: { open: { rotate: 180 }, closed: { rotate: 0 } } })
195
+ *
196
+ * // In the component: `setState("open")` opens the panel, and turns the chevron with it.
197
+ * const [state, setState] = createSignal<"open" | "closed">("closed")
198
+ * const panel = createWard({ initial: "closed", animate: state })
199
+ * const chevron = createWard({ follow: panel }, turns)
200
+ */
201
+ readonly follow?: AnyWard | undefined
202
+ /** Whether it's shown: it enters from `initial` when true; when false it leaves by `exit`, then hides. */
203
+ readonly show?: Accessor<boolean> | undefined
204
+ /** Its followers' timing, for every variant that sets none of its own. */
205
+ readonly followers?: Followers | undefined
206
+ /**
207
+ * `false` starts it at its `animate`, with no entrance, while its `initial` is still where it enters
208
+ * from later and where it leaves to. What `createWards` gives the rows of its first list, with `initial: false`.
209
+ */
210
+ readonly enter?: false | undefined
211
+ }
212
+
213
+ /**
214
+ * The page's own keys, beside Wardic's: the rest of a ward's config on an element. Its `style`, its
215
+ * layout and `layoutId`, its `viewport`, `appear`, and an element's drag and how that's set. A Stage
216
+ * has a drag and a `subject` by the same names, typed as its own (`StageKeys`, `stage.ts`).
217
+ */
218
+ // `dragListener` and `dragControls` aren't the hooks' (probe: behaviour-runes, Q15, Q30): a grip,
219
+ // `createGrip(ward)`, is their way, and a hooks ward's drag is its grips' own.
220
+ export interface PageKeys extends Omit<WardConfig, keyof WardicKeys | "dragListener" | "dragControls"> {
221
+ /**
222
+ * A `show` ward popped as it leaves: taken out of the flow where it is as it starts to go
223
+ * (`position: absolute`, its size kept), so what's after it takes its place at once. `true` pins it
224
+ * by its top left; a corner's name pins it by that corner, for a container that resizes as it goes
225
+ * and keeps another corner still, as a stack in the bottom right does.
226
+ */
227
+ readonly pop?: boolean | PopCorner | undefined
228
+ /**
229
+ * Whether it's lifted (probe: behaviour-runes, Q9): a behaviour's word, as a keyboard lift is. A
230
+ * `layout` ward is raised over the rest while it's lifted, and from then until it lands, and its
231
+ * `whileDrag` is on.
232
+ */
233
+ readonly lifted?: Accessor<boolean> | boolean | undefined
234
+ /**
235
+ * The Subject it moves, or an accessor of it: an element another renders, a router's page for its
236
+ * layout, in place of a spread. With none, its element comes by its `ref`, as a spread gives it.
237
+ */
238
+ readonly subject?: unknown
239
+ /** What this rune does to its Subject beside moving it ({@link RuneRef}): on the page, an element. */
240
+ readonly ref?: RuneRef<HTMLElement> | undefined
241
+ /** What this rune sets on its Subject beside moving it ({@link RuneProps}): on the page, an element's attributes. */
242
+ readonly props?: RuneProps | undefined
243
+ /**
244
+ * The tag of its Subject on the page (the gap grill's Q22). An SVG element's (`"circle"`, `"path"`)
245
+ * has its attribute keys (`cx`, `d`, `pathLength`) render as attributes, on a server and in its first
246
+ * frame, as a `wardic.*` component's own tag has them. Any tag types this rune's `ref` and `props` for
247
+ * that element, and the ward's spread: a ward whose runes name none is an HTML element's. Not the
248
+ * other runes of the call, which TypeScript can't type by it. The last rune to give one wins.
249
+ */
250
+ readonly tag?: ElementTag | undefined
251
+ /**
252
+ * How it honours the visitor's reduced-motion setting (probe: behaviour-runes, the scopes round's Q10):
253
+ * `"user"` follows it, `"always"` reduces its motion, `"never"` animates whatever it is. Over the
254
+ * config around it, read as each of its animations starts. A config scope given to a ward gives it.
255
+ */
256
+ readonly reducedMotion?: ReducedMotion.Config | Accessor<ReducedMotion.Config | undefined> | undefined
257
+ /**
258
+ * Its animations land at their ends on the next frame (the scopes round's Q10): for end-to-end and
259
+ * visual-regression tests. Over the config around it, read as each of its animations starts.
260
+ */
261
+ readonly skipAnimations?: boolean | Accessor<boolean | undefined> | undefined
262
+ /**
263
+ * Where the points its drag or pan uses are (the scopes round's Q10, the gap grill's Q42): handed each
264
+ * in the viewport's coordinates, it gives the one the gesture uses. The function itself, called at each
265
+ * drag or pan start, so it follows what it reads. Over the config around it.
266
+ */
267
+ readonly transformPagePoint?: Config.WardicTransformPoint | undefined
268
+ }
269
+
270
+ /**
271
+ * A rune's config on the page where its Subject is the element `Tag` names: its `ref` handed that
272
+ * Subject, and its `props` its attributes. Every other key a {@link RuneConfig}'s.
273
+ */
274
+ export interface RuneConfigOn<Tag> extends WardicKeys, Omit<PageKeys, "ref" | "props"> {
275
+ readonly ref?: RuneRef<ElementOf<Tag>> | undefined
276
+ readonly props?: RunePropsOf<Tag> | undefined
277
+ }
278
+
279
+ /**
280
+ * A rune's config on the page: Wardic's keys, and the page's own. `popBox` is left out of the type:
281
+ * where a popped ward was before the change that made it leave, which `createWards` gives each of its
282
+ * rows as a rune of its own and the hooks read by its name, so it's no key for an app to write.
283
+ */
284
+ export interface RuneConfig extends WardicKeys, PageKeys {}
285
+
286
+ /**
287
+ * The ward a function rune is handed: its ward, by its type too (`HookWard`, `ward.ts`). What it
288
+ * listens to and reads is the finished ward's own, the two sharing one lifecycle: its gestures and
289
+ * its motion (`ward.hovering()`, `reads.ts`); whether it's shown, on the page and leaving
290
+ * (`ward.shown()`, `ward.mounted()`, `ward.exiting()`); and its exits and its readiness
291
+ * (`ward.when("exitComplete")`, `ward.next("ready")`).
292
+ *
293
+ * - **Read where it's followed:** in a value (a `props`', a target's accessor), a memo, an effect.
294
+ * One made in the rune's own body runs at once, before the ward is finished, and is still right:
295
+ * from its first read where the ward's `show` is a plain rune's, and once the page has settled
296
+ * where a presence takes the ward later, or its `show` is a function rune's, whichever comes first
297
+ * among its runes. On a server nothing settles: there, a memo made in the body is right for a
298
+ * plain rune's `show` alone, and a value read as it's rendered is right for any.
299
+ * - **Read bare in the body,** it's read once, and Solid says so, as it does of a signal read at the
300
+ * top of a component's body. Its `ref` is handed its Subject: the ward has no read of that.
301
+ */
302
+ export type RuneWard = HookWard & {
303
+ /** What it hears of its ward's drag (probe: behaviour-runes): a function rune's ward's alone (Q34). */
304
+ readonly drag: WardDrag
305
+ }
306
+
307
+ const RUNE: unique symbol = Symbol("wardic.rune")
308
+
309
+ /** A rune made of a function of its ward. */
310
+ export interface FunctionRune {
311
+ readonly [RUNE]: (ward: RuneWard) => RuneConfig
312
+ }
313
+
314
+ /** A rune of a ward: a config, or `createRune(fn)`. */
315
+ export type Rune = RuneConfig | FunctionRune
316
+
317
+ const CARRIED: unique symbol = Symbol("wardic.carriedRune")
318
+
319
+ /**
320
+ * A value that's a rune as it is, beside what else it is: a Reorder list (`createReorder`), whose
321
+ * group gives the ward it's given to its `ref` and its style, the keys a spread of it gives, and keeps
322
+ * its reads to itself. A ward takes it as it is: its keys are its maker's to check, where a config's
323
+ * are the ward's. Not enumerable, so a spread never sees the mark.
324
+ */
325
+ // The Reorder round's LW2 (2026-11-30): the owner chose a mark any value can carry over a check that
326
+ // knows a Reorder list by name.
327
+ export interface CarriedRune {
328
+ readonly [CARRIED]: true
329
+ }
330
+
331
+ /** The mark of a carried rune that's the page's ({@link PageOnly}): in a type alone, never on a value. */
332
+ declare const PAGE_ONLY: unique symbol
333
+
334
+ /**
335
+ * A carried rune that's the page's alone (probe: behaviour-runes, the scopes round's Q23): a config scope,
336
+ * a layout group. A mark in its type alone, which a Stage's ward refuses ({@link NotOnAStage}): a carried
337
+ * rune is taken as it is, its keys its maker's to check, and these give what only the page has.
338
+ */
339
+ export interface PageOnly {
340
+ readonly [PAGE_ONLY]: true
341
+ }
342
+
343
+ /** What a page-only carried rune ({@link PageOnly}) is told where a ward on a Stage is given it. */
344
+ export type NotOnAStage = "a config scope or a layout group is the page's: a ward on a Stage takes none"
345
+
346
+ /** A carried rune `X` where `Taken` is: as it is, unless it's the page's alone and `Taken` isn't the page. */
347
+ type FitCarried<X, Taken extends RunesTaken> = [X, Taken["whose"]] extends [PageOnly, "a ward on a Stage"] ? NotOnAStage : X
348
+
349
+ /** `value` marked a {@link CarriedRune}: a rune as it is wherever a ward is given it. */
350
+ export const carriedRune = <A extends object>(value: A): A & CarriedRune => Object.defineProperty(value, CARRIED, { value: true }) as A & CarriedRune
351
+
352
+ /** What `createRuneWith(rune, api)` gives back: the rune, and its API beside it. */
353
+ export type RuneWith<R, Api> = R & Readonly<Api>
354
+
355
+ /** The mark on a value that carries an API ({@link createRuneWith}): not enumerable, so a spread never sees it. */
356
+ const RUNE_API: unique symbol = Symbol("wardic.runeApi")
357
+
358
+ /**
359
+ * `api`'s own members as a value carrying them has them: hidden, not enumerable, so a ward and a spread never
360
+ * see them, and read-only, as the API it is; and the mark that says the value carries one.
361
+ */
362
+ const hiddenMembersOf = (api: object): PropertyDescriptorMap => ({
363
+ ...Rec.map(Object.getOwnPropertyDescriptors(api), (member): PropertyDescriptor => ({
364
+ ...member,
365
+ enumerable: false,
366
+ configurable: false,
367
+ ...Bool.match("value" in member, { onTrue: () => ({ writable: false }), onFalse: () => ({}) }),
368
+ })),
369
+ [RUNE_API]: { value: true },
370
+ })
371
+
372
+ /** What an API member named like a rune's key is told, where `createRuneWith` is given one (the rune-with grill's Q10). */
373
+ export type ApiClash<K> = `"${K & string}" is a rune's key: an API member can't share its name`
374
+
375
+ /**
376
+ * An API as `createRuneWith` takes it where `Taken` is: its members as they are, one named like a key of
377
+ * `Taken`'s runes told {@link ApiClash}, which the API's own would hide from the ward. `& A` is what `A` is
378
+ * inferred from.
379
+ */
380
+ export type ApiFor<A, Taken extends RunesTaken> = A & { readonly [K in keyof A & keyof Taken["config"]]: ApiClash<K> }
381
+
382
+ /**
383
+ * `rune` carrying `api` (probe: behaviour-runes, the rune-with grill): one value that's a rune where a ward
384
+ * is given it, and an API where an app calls it, as a utility of an app's own hands one back. The rune is
385
+ * a config, checked where it's written as `createRune(config)`'s is, or a behaviour (`createRune(fn)`). A
386
+ * config's keys are the ones it has as `createRuneWith` is called, and a ward reads each one live. The API's
387
+ * members are invisible to a ward and to a spread, and read-only; one named like a rune's key is refused. A
388
+ * rune given to it is never changed.
389
+ *
390
+ * ```tsx
391
+ * const createCarousel = (count: number) => {
392
+ * const [index, setIndex] = createSignal(0)
393
+ * return createRuneWith(
394
+ * { get animate() { return { x: `${-index() * 100}%` } }, transition: { type: "spring", bounce: 0 } },
395
+ * { index, next: () => setIndex((i) => Math.min(i + 1, count - 1)), prev: () => setIndex((i) => Math.max(i - 1, 0)) },
396
+ * )
397
+ * }
398
+ *
399
+ * const carousel = createCarousel(slides.length)
400
+ * const track = createWard({ drag: "x" }, carousel) // a rune, beside the app's own
401
+ * <div {...track}>…</div>
402
+ * <button onClick={carousel.next}>Next</button> // and its API
403
+ * ```
404
+ */
405
+ export function createRuneWith<F extends FunctionRune, A extends object>(behaviour: F, api: ApiFor<A, OnThePage>): RuneWith<F, A>
406
+ /**
407
+ * A function that's a ref carrying its props, its keys its maker's to check (a Reorder group): given its API as
408
+ * it is, so it's still a ref. One with no `ref` of its own isn't one: a behaviour is `createRune(fn)`.
409
+ */
410
+ export function createRuneWith<F extends ((...args: never) => unknown) & { readonly ref: unknown }, A extends object>(ref: F, api: ApiFor<A, OnThePage>): RuneWith<F, A> & CarriedRune
411
+ export function createRuneWith<P extends { readonly tag: ElementTag }, A extends object>(rune: GivenRune<P, PageTaken<P["tag"]>>, api: ApiFor<A, OnThePage>): RuneWith<MadeRune<P, PageTaken<P["tag"]>>, A> & CarriedRune
412
+ export function createRuneWith<P extends object, A extends object>(rune: GivenRune<P, OnThePage>, api: ApiFor<A, OnThePage>): RuneWith<MadeRune<P, OnThePage>, A> & CarriedRune
413
+ export function createRuneWith(rune: object, api: object): object {
414
+ if (DEV) refusedInDevelopment(rune, api)
415
+ return carrierOf(rune)(hiddenMembersOf(api))
416
+ }
417
+
418
+ /** What development says of `key`, an API member named like one of its rune's keys (the rune-with grill's Q10). */
419
+ const clashOf = (key: string): string =>
420
+ `createRuneWith(rune, api): "${key}" is one of its rune's keys, and the API's would hide it from the ward. Give the API member another name.`
421
+
422
+ /** What development says of an API given to a value that carries one already (the rune-with grill's Q8). */
423
+ const SECOND_API = "createRuneWith(rune, api): this rune already carries an API. Give its rune as it was written, with one API that has every member."
424
+
425
+ /** What development says of a function that's no ref carrying its props, a behaviour written without `createRune` (the review of Q8). */
426
+ const BARE_FUNCTION = "createRuneWith(rune, api): a bare function isn't a rune, and a ward would read nothing of it. A behaviour is `createRune((ward) => …)`."
427
+
428
+ /** Whether `key` is one of `value`'s own keys a ward or a spread reads: an enumerable one. */
429
+ const isOwnKeyOf =
430
+ (value: object) =>
431
+ (key: string): boolean =>
432
+ Object.prototype.propertyIsEnumerable.call(value, key)
433
+
434
+ /** Whether `rune` is a function that's no ref carrying its props, nor a behaviour. */
435
+ const isBareFunction = (rune: object): boolean => {
436
+ if (!Predicate.isFunction(rune)) return false
437
+ return Bool.not(isOwnKeyOf(rune)("ref"))
438
+ }
439
+
440
+ /**
441
+ * Development's word on `rune` given `api`: refused where it carries one already, where it's a bare function,
442
+ * or where the API would hide one of its keys.
443
+ */
444
+ const refusedInDevelopment = (rune: object, api: object): void => {
445
+ if (RUNE_API in rune) throw new Error(SECOND_API)
446
+ if (isBareFunction(rune)) throw new Error(BARE_FUNCTION)
447
+ const clash = Arr.findFirst(Object.keys(api), isOwnKeyOf(rune))
448
+ if (Option.isSome(clash)) throw new Error(clashOf(clash.value))
449
+ }
450
+
451
+ /**
452
+ * What a ward takes where it is, which the hooks' types check its runes by: the page's here
453
+ * ({@link OnThePage}), a Stage's in `stage.ts`. One for each place a ward can be, so a check is
454
+ * written once and holds in both: a ward's runes ({@link RunesGiven}) and a list's rows'
455
+ * (`RowRunesGiven`, `wards.ts`).
456
+ */
457
+ export interface RunesTaken {
458
+ /** A rune's config there: the keys of Wardic's its ward carries, and its own. */
459
+ readonly config: object
460
+ /** Whose ward it is, as an error names it: "a ward on the page". */
461
+ readonly whose: string
462
+ /** `true` where its ward carries a function rune (`createRune(fn)`); else what one is told where it's given. */
463
+ readonly functionRune: true | string
464
+ /**
465
+ * What each value takes in a target there, by its name: what a ward there animates. Any name at
466
+ * all (a string index) where nothing says what its Subject takes.
467
+ */
468
+ readonly values: object
469
+ /**
470
+ * Every name some Subject there takes, where a ward's own Subject takes only some of them: a name
471
+ * among these and not in `values` is another Subject's. None where every ward takes the same.
472
+ */
473
+ readonly everyName: PropertyKey
474
+ }
475
+
476
+ /** What a ward on the page takes: every key of a rune's, a function rune, and an element's values. */
477
+ export interface OnThePage extends RunesTaken {
478
+ readonly config: RuneConfig
479
+ readonly whose: "a ward on the page"
480
+ readonly functionRune: true
481
+ readonly values: Config.ValueKeys
482
+ readonly everyName: never
483
+ }
484
+
485
+ /** What a ward on the page takes where its Subject is the element `Tag` names ({@link RuneConfigOn}). */
486
+ export interface OnThePageOf<Tag> extends RunesTaken {
487
+ readonly config: RuneConfigOn<Tag>
488
+ readonly whose: "a ward on the page"
489
+ readonly functionRune: true
490
+ readonly values: Config.ValueKeys
491
+ readonly everyName: never
492
+ }
493
+
494
+ /** What a ward on the page takes, given the tag its runes name: any HTML element's where they name none. */
495
+ export type PageTaken<Tag> = [Tag] extends [undefined] ? OnThePage : OnThePageOf<Tag>
496
+
497
+ /** `Taken` given the tag its runes name: the page's for a Subject that element; a Stage's as it is, which takes no tag. */
498
+ export type TakenWithTag<Taken extends RunesTaken, Tag> = [Tag] extends [undefined] ? Taken : Taken extends OnThePage ? OnThePageOf<Tag> : Taken
499
+
500
+ declare const GIVES: unique symbol
501
+
502
+ /** A function rune, with the config its function gives in its type alone: so a ward knows the tag it names. */
503
+ export interface FunctionRuneOf<G> extends FunctionRune {
504
+ readonly [GIVES]?: G
505
+ }
506
+
507
+ /**
508
+ * The tag rune `X` names: its `tag`, or a function rune's as its function gives it. None where it
509
+ * names none, or where its type is as wide as any tag's (a rune passed on as a `Rune`). A rune with
510
+ * no `tag` is told apart by its keys first: inferring an optional `tag` out of every rune cost a ward
511
+ * a fifth again of what its runes' check costs the checker.
512
+ */
513
+ export type TagIn<X> = X extends FunctionRune
514
+ ? X extends FunctionRuneOf<infer G>
515
+ ? TagIn<G>
516
+ : never
517
+ : "tag" extends keyof X
518
+ ? X extends { readonly tag: infer T }
519
+ ? ElementTag extends T
520
+ ? never
521
+ : Extract<T, ElementTag>
522
+ : never
523
+ : never
524
+
525
+ /**
526
+ * The tag the runes `A` name, which their ward's spread is typed for: none where none does. Read
527
+ * over the runes as one union, not rune by rune from the last: where two name different tags, the
528
+ * spread is either element's, where the ward itself takes the last one's.
529
+ */
530
+ export type TagGiven<A extends ReadonlyArray<unknown>> = [TagIn<A[number]>] extends [never] ? undefined : TagIn<A[number]>
531
+
532
+ /**
533
+ * Whether rune `X` gives a `drag` (probe: behaviour-runes, Q20): a function rune's as its function
534
+ * gives it. The key, given at all: whether it's on now is the drag's to say.
535
+ */
536
+ export type DragIn<X> = X extends FunctionRune ? (X extends FunctionRuneOf<infer G> ? DragIn<G> : never) : "drag" extends keyof X ? true : never
537
+
538
+ /** The mark of a ward that drags where one of `A`'s runes gives a `drag`, and nothing where none does (Q20). */
539
+ export type DragsGiven<A extends ReadonlyArray<unknown>> = [DragIn<A[number]>] extends [never] ? unknown : Drags
540
+
541
+ /** What a key is told where a ward that doesn't take it is given it: the key, and `Whose` ward that is. Where the key's value was. */
542
+ export type NotAKey<Key, Whose extends string> = `"${Key & string}" isn't a key ${Whose} takes`
543
+
544
+ /** A rune's keys that take a target: its values, each under its name. */
545
+ type TargetKey = "initial" | "animate" | "exit" | "whileHover" | "whileTap" | "whileFocus" | "whileInView" | "whileDrag"
546
+
547
+ /** A rune's keys that name values: a target, each variant, and a transition's entry for one value. */
548
+ type ValuedKey = TargetKey | "variants" | "transition"
549
+
550
+ /**
551
+ * What a value's name is told where a ward that doesn't animate it is given it: the name, and whose
552
+ * ward that is, or that its own Subject hasn't it where another there has. Where the value was.
553
+ */
554
+ export type NotAValue<Name, Taken extends RunesTaken> = Name extends Taken["everyName"]
555
+ ? `"${Name & string}" isn't a value this Subject animates`
556
+ : `"${Name & string}" isn't a value ${Taken["whose"]} animates`
557
+
558
+ /** What a name in a transition is told that's neither one of its own keys nor a value's, for that value's entry: as {@link NotAValue} tells a value. */
559
+ export type NotInATransition<Name, Taken extends RunesTaken> = Name extends Taken["everyName"]
560
+ ? `"${Name & string}" isn't a transition's key, nor a value this Subject animates`
561
+ : `"${Name & string}" isn't a transition's key, nor a value ${Taken["whose"]} animates`
562
+
563
+ /** Whether `T`'s names aren't known: a map built as the page runs, typed by a string index. Left as it is. */
564
+ type IsWide<T> = string extends keyof T ? true : false
565
+
566
+ /** Each key of each member of a union. */
567
+ type KeyOfEach<U> = U extends unknown ? keyof U : never
568
+
569
+ /**
570
+ * A transition's own keys: a spring's, a tween's and an inertia's, and what every one of them takes.
571
+ * A value of the same name as one of them (a spring's `mass`, an inertia's `power`) has no entry in
572
+ * a transition: the name is the transition's there.
573
+ */
574
+ export type TransitionKey = KeyOfEach<Config.WardicTransitionWith<Config.WardicInherit>> | "default" | "layout"
575
+
576
+ /** What a value takes in a target: itself, or its Keyframes. */
577
+ type OrKeyframes<V> = V | Config.WardicKeyframes<Exclude<V, undefined>>
578
+
579
+ /** A variant's `followers` where `Taken`'s ward times followers, and the key's own error where it takes none. */
580
+ type FollowersIn<T, Taken extends RunesTaken> = "followers" extends keyof Taken["config"] ? T : NotAKey<"followers", Taken["whose"]>
581
+
582
+ /** What has no names to check: a variant's name, `false`, a CSS value written whole. `string & {}` is an object to the checker. */
583
+ type Nameless = string | number | boolean | null | undefined
584
+
585
+ /** A Transition end as it's written, each of its names one of `Taken`'s values. */
586
+ type CheckedEnd<T, Taken extends RunesTaken> = T extends Nameless
587
+ ? T
588
+ : T extends object
589
+ ? IsWide<T> extends true
590
+ ? T
591
+ : { readonly [N in keyof T]: N extends keyof Taken["values"] ? Taken["values"][N] : NotAValue<N, Taken> }
592
+ : T
593
+
594
+ /** A transition as it's written, each of its keys its own or the entry of one of `Taken`'s values. */
595
+ type CheckedTransition<T, Taken extends RunesTaken> = T extends Nameless
596
+ ? T
597
+ : T extends (...args: infer Args) => infer Gives
598
+ ? (...args: Args) => CheckedTransition<Gives, Taken>
599
+ : T extends object
600
+ ? IsWide<T> extends true
601
+ ? T
602
+ : { readonly [F in keyof T]: F extends TransitionKey ? T[F] : F extends keyof Taken["values"] ? Config.WardicValueTransition | undefined : NotInATransition<F, Taken> }
603
+ : T
604
+
605
+ /**
606
+ * A target as it's written, each of its names one of `Taken`'s values: what a ward there animates. A
607
+ * name that isn't is the error's text ({@link NotAValue}), where its value was. Read through a
608
+ * function, an accessor's or a dynamic variant's, into what that gives; a variant's name, a list of
609
+ * them, `false` and Animation controls are left as they are, having no names.
610
+ */
611
+ type CheckedTarget<T, Taken extends RunesTaken> = T extends Nameless
612
+ ? T
613
+ : T extends (...args: infer Args) => infer Gives
614
+ ? (...args: Args) => CheckedTarget<Gives, Taken>
615
+ : T extends object
616
+ ? T extends ReadonlyArray<unknown> | Config.WardicAnimationControls
617
+ ? T
618
+ : IsWide<T> extends true
619
+ ? T
620
+ : {
621
+ readonly [N in keyof T]: N extends "transition"
622
+ ? CheckedTransition<T[N], Taken>
623
+ : N extends "transitionEnd"
624
+ ? CheckedEnd<T[N], Taken>
625
+ : N extends "followers"
626
+ ? FollowersIn<T[N], Taken>
627
+ : N extends keyof Taken["values"]
628
+ ? OrKeyframes<Taken["values"][N]>
629
+ : NotAValue<N, Taken>
630
+ }
631
+ : T
632
+
633
+ /** A variants map as it's written, each variant checked as a target is. */
634
+ type CheckedVariants<T, Taken extends RunesTaken> = T extends object ? (IsWide<T> extends true ? T : { readonly [Name in keyof T]: CheckedTarget<T[Name], Taken> }) : T
635
+
636
+ /**
637
+ * A target's keys that aren't a value's name where `Taken` is: its own transition, its Transition
638
+ * end, and a variant's `followers` where its ward times followers.
639
+ */
640
+ type TargetOwnKey<Taken extends RunesTaken> = "transition" | "transitionEnd" | ("followers" extends keyof Taken["config"] ? "followers" : never)
641
+
642
+ /** The names in a map of values `T` that aren't among `Allowed`: none for what has no names, or whose names aren't known. */
643
+ type StrayIn<T, Allowed> = T extends Nameless ? never : T extends object ? (IsWide<T> extends true ? never : Exclude<keyof T, Allowed>) : never
644
+
645
+ /** The keys of a transition `T` that are neither its own nor the entry of one of `Taken`'s values. */
646
+ type StrayInTransition<T, Taken extends RunesTaken> = T extends Nameless
647
+ ? never
648
+ : T extends (...args: never) => infer Gives
649
+ ? StrayInTransition<Gives, Taken>
650
+ : StrayIn<T, TransitionKey | keyof Taken["values"]>
651
+
652
+ /**
653
+ * The names a target `T` has that `Taken`'s ward doesn't animate: among its values, in its
654
+ * Transition end, and among its own transition's entries. Read through a function into what it
655
+ * gives, and each member of a union on its own.
656
+ */
657
+ type StrayInTarget<T, Taken extends RunesTaken> = T extends Nameless
658
+ ? never
659
+ : T extends (...args: never) => infer Gives
660
+ ? StrayInTarget<Gives, Taken>
661
+ : T extends ReadonlyArray<unknown> | Config.WardicAnimationControls
662
+ ? never
663
+ :
664
+ | StrayIn<T, keyof Taken["values"] | TargetOwnKey<Taken>>
665
+ | (T extends { readonly transitionEnd?: infer End } ? StrayIn<End, keyof Taken["values"]> : never)
666
+ | (T extends { readonly transition?: infer Own } ? StrayInTransition<Own, Taken> : never)
667
+
668
+ /** The same of each variant in a variants map. */
669
+ type StrayInVariants<T, Taken extends RunesTaken> = T extends object ? (string extends keyof T ? never : { readonly [Name in keyof T]: StrayInTarget<T[Name], Taken> }[keyof T]) : never
670
+
671
+ /** The names one of a rune's keys that name values has that `Taken`'s ward doesn't animate. None where it fits. */
672
+ type Stray<K, T, Taken extends RunesTaken> = K extends TargetKey ? StrayInTarget<T, Taken> : K extends "variants" ? StrayInVariants<T, Taken> : StrayInTransition<T, Taken>
673
+
674
+ /** One of a rune's keys that name values, written out again with each name checked, the error where a wrong one's value was. */
675
+ type Rewritten<K, T, Taken extends RunesTaken> = K extends TargetKey ? CheckedTarget<T, Taken> : K extends "variants" ? CheckedVariants<T, Taken> : CheckedTransition<T, Taken>
676
+
677
+ /**
678
+ * One of a rune's keys that name values, as it's written, checked by the values `Taken`'s ward
679
+ * animates; `Own` is the key's own type there.
680
+ *
681
+ * - **Where every name fits,** nothing more than `Own` asks: looking the names up is all it costs.
682
+ * Laid over every key of every rune, written out again, the check cost the checker four times
683
+ * the work for each ward, and a file of them four times as long.
684
+ * - **Where one doesn't,** the key is written out again with the error where that name's value was
685
+ * ({@link CheckedTarget}). Unless it's typed as wide as `Own` itself: a rune passed on as a
686
+ * `Rune`, or a target as a Stage's own type, with no literal behind it, says nothing of which
687
+ * values it names, and fits by its types alone.
688
+ * - **Where any name goes,** a Subject nothing says anything of, there's no name to look up, and
689
+ * the key is written out again all the same: it's what tells a transition's entry for a value
690
+ * from one of its own keys misspelt.
691
+ */
692
+ type CheckedValues<K, T, Taken extends RunesTaken, Own> = string extends keyof Taken["values"]
693
+ ? Rewritten<K, T, Taken>
694
+ : [Stray<K, T, Taken>] extends [never]
695
+ ? unknown
696
+ : [Own] extends [T]
697
+ ? unknown
698
+ : Rewritten<K, T, Taken>
699
+
700
+ /**
701
+ * What a name in a rune's `props` is told that's no prop: where its value was. Three have a way out,
702
+ * and are told it: a handler, a rune's own key, and a class. Anything else is a name no element
703
+ * takes: a misspelling, its content, an attribute only some elements have.
704
+ */
705
+ export type NotAProp<Name, Whose extends string> = Name extends `on${string}`
706
+ ? `"${Name}" isn't a prop a rune sets: a rune listens in its ref`
707
+ : Name extends "style" | "ref"
708
+ ? `"${Name}" isn't a prop a rune sets: it's the rune's own key, beside props`
709
+ : Name extends "class"
710
+ ? `"class" isn't a prop a rune sets: mark a state with a data- attribute`
711
+ : `"${Name & string}" isn't a prop ${Whose} sets`
712
+
713
+ /** What a rune's `props` is told given as an accessor: its values follow a signal, not the object. */
714
+ export type PropsNotAnAccessor = "a rune's props is an object as it's written: an accessor goes on a value in it"
715
+
716
+ /** The names in a `props` `T` that `Own`, the key's own type, doesn't have. None where it has no names. */
717
+ type StrayProps<T, Own> = T extends object ? Exclude<keyof T, keyof NonNullable<Own>> : never
718
+
719
+ /** A `props` as it's written, each of its names one of `Own`'s, or the error's text where its value was. */
720
+ type RewrittenProps<T, Own, Whose extends string> = T extends object ? { readonly [N in keyof T]: N extends keyof NonNullable<Own> ? NonNullable<Own>[N] : NotAProp<N, Whose> } : T
721
+
722
+ /**
723
+ * A rune's `props` as it's written, checked by the names its Environment's `props` has, `Own`: as
724
+ * a target's values are ({@link CheckedValues}), and for its reason. Where every name fits, nothing
725
+ * more than `Own` asks. Where one doesn't, `props` is written out again with the error where that
726
+ * name's value was ({@link NotAProp}): so it's told wherever `props` was written, a constant and what
727
+ * a function gives among them, where the checker's own rule for a name that's extra looks only at an
728
+ * object written in place. An accessor is told apart first: with no names, it passed.
729
+ */
730
+ type CheckedProps<T, Own, Whose extends string> = T extends (...args: never) => unknown ? PropsNotAnAccessor : [StrayProps<T, Own>] extends [never] ? unknown : RewrittenProps<T, Own, Whose>
731
+
732
+ /**
733
+ * A rune as a `createRune` gives it back: the keys it was given, those of `P`'s that are a rune's
734
+ * where `Taken` is, and no others. Its keys are in its type, so a ward can check them
735
+ * ({@link GivenRune}). A key that names values (a target, `variants`, `transition`) keeps what was
736
+ * written, so the ward a rune is later given to knows each value it names: one written for the page
737
+ * fits a Stage's ward when that Subject animates each of them. So does its `subject`, by which that
738
+ * ward knows whose values they are. Every other key is typed as a rune there types it, not as its
739
+ * literal.
740
+ *
741
+ * Two other shapes were tried, and each lost one of the two things a rune written in a constant is
742
+ * for. The literal's own type lost the check inside a key's value: a key a transition doesn't have
743
+ * (`stiffnes`) was part of the type being inferred, so nothing called it extra. The keys alone,
744
+ * inferred as a union, lost an editor's completions: with a rune's keys taken from those written so
745
+ * far, there were no others to offer.
746
+ */
747
+ // A key the config has as optional reads as its type `| undefined` (`Config["viewport"]`), which a
748
+ // key the rune has isn't: under `exactOptionalPropertyTypes` a ward refused a rune made of one.
749
+ export type MadeRune<P, Taken extends RunesTaken> = { readonly [K in keyof P & keyof Taken["config"]]: K extends ValuedKey | "subject" | "tag" ? P[K] : Exclude<Taken["config"][K], undefined> }
750
+
751
+ /**
752
+ * A config as a `createWard` takes it given, and a `createRune` written: a rune's where `Taken` is,
753
+ * each key `P` has typed by it, and a key that isn't one of its keys the error's text. A rune is
754
+ * checked by the ward that takes it, since a rune's own type holds only the keys it has: one written
755
+ * for another place fits wherever every key it has is taken. A function has no keys, so it's told
756
+ * apart first ({@link NotAConfig}): with none to check, it passed. `& P` there is what `P` is
757
+ * inferred from: by its keys alone, a function was inferred as an empty rune.
758
+ *
759
+ * The values it names are checked the same way, a level down ({@link CheckedTarget}): each name in
760
+ * a target, a variant, a Transition end and a transition's entries is one `Taken`'s ward animates,
761
+ * or the error's text where its value was.
762
+ */
763
+ export type GivenRune<P, Taken extends RunesTaken> = P extends (...args: never) => unknown
764
+ ? NotAConfig & P
765
+ : Taken["config"] & {
766
+ readonly [K in keyof P]: K extends keyof Taken["config"]
767
+ ? K extends ValuedKey
768
+ ? CheckedValues<K, P[K], Taken, Taken["config"][K]>
769
+ : K extends "props"
770
+ ? Taken["config"][K] & CheckedProps<P[K], Taken["config"][K], Taken["whose"]>
771
+ : Taken["config"][K]
772
+ : NotAKey<K, Taken["whose"]>
773
+ }
774
+
775
+ /**
776
+ * What a bare function is told where a config is taken: by a ward, whose rune is a config or
777
+ * `createRune(fn)`, and by `createRune(config)`, where it's what a function rune reads as once its own
778
+ * config has an error.
779
+ */
780
+ export type NotAConfig = "a function isn't a config"
781
+
782
+ /**
783
+ * One rune as a ward is given it: a config, checked key by key ({@link GivenRune}); a function rune
784
+ * as it is where `Taken`'s ward carries one, and what it's told there where it doesn't; a carried one
785
+ * as it is ({@link CarriedRune}), unless it's the page's alone ({@link PageOnly}) and `Taken` isn't the
786
+ * page. Anything that's no object is no rune: it's told the rune it should have been.
787
+ */
788
+ export type FitRune<X, Taken extends RunesTaken> = X extends CarriedRune
789
+ ? FitCarried<X, Taken>
790
+ : X extends FunctionRune
791
+ ? Taken["functionRune"] extends true
792
+ ? X
793
+ : Taken["functionRune"]
794
+ : X extends object
795
+ ? GivenRune<X, Taken>
796
+ : RuneIn<Taken>
797
+
798
+ /**
799
+ * The runes a ward is given, each checked as {@link FitRune}. A rune's type is the keys it has, so
800
+ * one written for another place with a key that's only that place's is an error here that names it.
801
+ */
802
+ export type RunesGiven<A extends ReadonlyArray<unknown>, Taken extends RunesTaken> = { readonly [I in keyof A]: FitRune<A[I], Taken> }
803
+
804
+ /**
805
+ * The runes a ward on the page is given, each checked for the element its own `tag` names (the gap
806
+ * grill's Q22): a tag types the rune it's in. Not one rune by another's, which TypeScript can't do
807
+ * for a `ref` written in place: the list's tag isn't known until each rune is, that `ref` among them,
808
+ * and the `ref` lost its type. While a rune is still being worked out it's any HTML element's, as before.
809
+ */
810
+ export type PageRunesGiven<A extends ReadonlyArray<unknown>> = { readonly [I in keyof A]: FitTaggedRune<A[I], OnThePage> }
811
+
812
+ /**
813
+ * One rune as {@link FitRune} has it, a config checked for the element its own `tag` names where
814
+ * `Taken` is the page ({@link TakenWithTag}), a carried one as it is. What's no rune is told `Taken`'s plain rune: that branch
815
+ * is also what a rune still being worked out, a `ref` alone in it, is typed by, so it names no tag.
816
+ */
817
+ export type FitTaggedRune<X, Taken extends RunesTaken> = X extends CarriedRune
818
+ ? FitCarried<X, Taken>
819
+ : X extends FunctionRune
820
+ ? Taken["functionRune"] extends true
821
+ ? X
822
+ : Taken["functionRune"]
823
+ : X extends object
824
+ ? GivenRune<X, TakenWithTag<Taken, TagIn<X>>>
825
+ : RuneIn<Taken>
826
+
827
+ /** A rune where `Taken` is, before any check: its config, or a function rune where its ward carries one. */
828
+ export type RuneIn<Taken extends RunesTaken> = Taken["config"] | (Taken["functionRune"] extends true ? FunctionRune : never)
829
+
830
+ type Make = (ward: RuneWard) => RuneConfig
831
+
832
+ const isMake = (given: RuneConfig | Make): given is Make => Predicate.isFunction(given)
833
+
834
+ /**
835
+ * A rune, written apart from the wards that take it.
836
+ *
837
+ * **A rune is made once, for what it describes:** in a module if it depends on nothing, once in a hook
838
+ * if it depends on that hook's state, and by a function, once for each element, if it depends on
839
+ * which element it's on. Never in JSX or in a spread. Runes are what a hook of an app's gives, where
840
+ * the ward is the component's ({@link createWard}): a hook that reads or listens to its own ward gives
841
+ * a function rune, as `dragToClose` below does, rather than making the ward itself.
842
+ *
843
+ * **Given a function of its ward,** it's a rune that listens to the ward it's part of. `make` is a
844
+ * hook's body: it's called once for each ward the rune is given to, as that ward is made and under its
845
+ * owner, with a ward whose events and reads are the finished ward's. So the rune is written once and
846
+ * every ward that takes it has its own run.
847
+ *
848
+ * const dragToClose = (close: () => void) =>
849
+ * createRune((sheet) => {
850
+ * createEffect(sheet.when("dragEnd"), (release) => {
851
+ * if (release.offset.y > 120) close()
852
+ * })
853
+ * return { drag: "y", dragSnapToOrigin: true }
854
+ * })
855
+ *
856
+ * **Given a config,** it's that config and nothing more, checked where it's written: its keys complete
857
+ * there, a misspelt one is an error there, and a literal needs no `as const`. Its type is the keys it
858
+ * has and no others ({@link MadeRune}). It's how a rune kept in a constant is written, since nothing
859
+ * else checks one there. A rune written in a ward's own call is checked by that call, and a plain
860
+ * object is still a rune.
861
+ *
862
+ * const lift = createRune({ whileHover: { y: -4 } })
863
+ * const spring = (stiffness: number) => createRune({ transition: { type: "spring", stiffness, damping: 28 } })
864
+ *
865
+ * **A rune is fixed once made.** Its keys are the ones it has as it's made, and a plain value in it
866
+ * (a target, a transition, its variants) can't change: the object given is frozen, and setting,
867
+ * adding or deleting a key throws. In development the data inside it is frozen too, so changing a
868
+ * value inside a target throws there; a build doesn't ship that walk. What changes is an accessor, a function or a
869
+ * getter, read where the ward reads it (`animate: () => ({ x: x() })`), or a store, whose keys are
870
+ * the ones it has as the rune is made, each read through the store. What depends on the ward itself
871
+ * is a function rune. What's under `custom`, `layoutDependency`, `dragControls` and `subject` is the
872
+ * app's own: the key is fixed, and what's inside it isn't touched.
873
+ *
874
+ * So what every ward that takes it would work out of it is worked out once, here ({@link factsOf}),
875
+ * and a ward of runes made this way reads none of them: a list's rows, a component used many times.
876
+ *
877
+ * **A key is best given by one rune.** A key several of a ward's runes give is merged across them
878
+ * (a target's values joined, a later rune's winning) each time it changes: both its accessors called
879
+ * and their objects merged, where one rune's is read as it is. A ward whose `animate` two runes give
880
+ * retargets several per cent slower for it.
881
+ */
882
+ // A tagged config is checked for the element its tag names, on overloads of its own: so an untagged
883
+ // one is checked as it was, at what it cost (a tag read through a type parameter of its own cost every
884
+ // rune three times its check). Its tag is known before a `ref` written beside it, which is handed that
885
+ // element. The untagged config's comes last, whose error is the one told.
886
+ //
887
+ // A function's untagged overload comes before its tagged one: a function's body is typed under the
888
+ // first overload tried, and a `ref` in it, typed under the tagged one before its tag was known, was
889
+ // `any` for good. So a function rune's `ref` is handed any HTML element unless it says which.
890
+ export function createRune<G extends object>(make: (ward: RuneWard) => GivenRune<G, OnThePage>): FunctionRuneOf<G>
891
+ export function createRune<G extends { readonly tag: ElementTag }>(make: (ward: RuneWard) => GivenRune<G, PageTaken<G["tag"]>>): FunctionRuneOf<G>
892
+ export function createRune<P extends { readonly tag: ElementTag }>(config: GivenRune<P, PageTaken<P["tag"]>>): MadeRune<P, PageTaken<P["tag"]>>
893
+ export function createRune<P extends object>(config: GivenRune<P, OnThePage>): MadeRune<P, OnThePage>
894
+ // Its own signature gives back an object: a rune made of a config keeps what its targets were written as.
895
+ export function createRune(given: RuneConfig | Make): object {
896
+ if (isMake(given)) return Object.freeze({ [RUNE]: given })
897
+ return madeRune(given)
898
+ }
899
+
900
+ /**
901
+ * `config` made a rune ({@link createRune}): fixed, the data inside it too, and what a ward works out
902
+ * of it worked out now and kept with it. Read untracked, as it may be made in a component's body: its
903
+ * getters, and a store's keys, are read for what they are, not followed. A Stage's `createRune` too.
904
+ */
905
+ export const madeRune = (config: object): object =>
906
+ untrack(() => {
907
+ // The data inside it frozen in development, as an object given straight to `createWard` is: in
908
+ // a build the rune itself is frozen and its keys fixed, and the walk isn't shipped.
909
+ if (DEV) freezeIfPlain(config)
910
+ const rune = fixedRune(config) as Loose
911
+ FACTS.set(rune, factsOf(rune, true))
912
+ return rune
913
+ })
914
+
915
+ /**
916
+ * Each of `runes` fixed as a ward is made of them ({@link fixedRune}), one `createRune` made as it is:
917
+ * an object given straight to `createWard`, a function rune's config, a list's row's own. Frozen, the
918
+ * plain data inside it too, in development alone: a write to one throws there, where an app is made,
919
+ * and a build doesn't pay to freeze a literal for every ward. A rune `createRune` made is frozen in
920
+ * a build too, once. The runes themselves, but for a store or Solid's merged props, which are read
921
+ * through an object of their keys as they are now, in a build as in development.
922
+ */
923
+ export const fixedRunes = <R extends ReadonlyArray<unknown>>(runes: R): R => {
924
+ if (DEV) Arr.forEach(runes, fixInPlace)
925
+ if (!Arr.some(runes, readsThrough)) return runes
926
+ return untrack(() => Arr.map(runes, fixedRune)) as unknown as R
927
+ }
928
+
929
+ /**
930
+ * Keys whose values are the app's own: a rune fixes the key, and leaves what's inside it to the app.
931
+ * `custom` is handed to its variants, `layoutDependency` compared, `dragControls` driven, and a
932
+ * Subject is the app's object.
933
+ */
934
+ const KEPT_AS_GIVEN: ReadonlySet<string> = new Set(["custom", "layoutDependency", "dragControls", "subject"])
935
+
936
+ /** A store, or Solid's merged or omitted props: read through, never frozen. */
937
+ const isProxied = (value: unknown): boolean => Predicate.isObject(value) && $PROXY in value
938
+
939
+ /**
940
+ * A carried rune ({@link CarriedRune}), a Reorder list, a function whose own keys are what it gives: an
941
+ * object or a function (`isObjectKeyword`, where `isObject` is no function). Composed once, here: asked of
942
+ * every rune of every ward as it's made, it makes no `dual` call there.
943
+ */
944
+ const isCarried: Predicate.Predicate<unknown> = Predicate.and(Predicate.isObjectKeyword, (value: unknown) => CARRIED in (value as object))
945
+
946
+ /**
947
+ * A rune read through an object of its keys as they are now: a store, Solid's merged props, or a
948
+ * carried rune, which as itself was taken for a ward's config where it alone gave the ward keys, and a
949
+ * function is no config (the Reorder round's utilities: a group with no motion props of its own).
950
+ */
951
+ const readsThrough: Predicate.Predicate<unknown> = Predicate.or(isProxied, isCarried)
952
+
953
+ /** Plain data a rune holds: an array, or an object of no class, and no store or Solid's merged props. */
954
+ const isPlainData = (value: unknown): value is Readonly<Record<string, unknown>> => {
955
+ if (!Predicate.isObject(value)) return false
956
+ if (Predicate.isFunction(value)) return false
957
+ if ($PROXY in value) return false
958
+ if (Array.isArray(value)) return true
959
+ const prototype: unknown = Object.getPrototypeOf(value)
960
+ if (prototype === Object.prototype) return true
961
+ return prototype === null
962
+ }
963
+
964
+ /** `value` frozen, and every piece of plain data under it: a getter's value isn't read. */
965
+ const freezeData = (value: unknown): void => {
966
+ if (!isPlainData(value)) return
967
+ if (Object.isFrozen(value)) return
968
+ Object.freeze(value)
969
+ Arr.forEach(Object.values(Object.getOwnPropertyDescriptors(value)), freezeHeld)
970
+ }
971
+
972
+ const freezeHeld = (descriptor: PropertyDescriptor): void => freezeData(descriptor.value)
973
+
974
+ /** The plain data under each of `rune`'s keys frozen, but for what's the app's own ({@link KEPT_AS_GIVEN}). */
975
+ const freezeValues = (rune: Readonly<Record<string, unknown>>): void => {
976
+ Arr.forEach(Object.keys(rune), (key) => {
977
+ if (KEPT_AS_GIVEN.has(key)) return
978
+ const descriptor = Object.getOwnPropertyDescriptor(rune, key)
979
+ if (Predicate.isUndefined(descriptor)) return
980
+ freezeData(descriptor.value)
981
+ })
982
+ }
983
+
984
+ /**
985
+ * `rune` fixed: frozen, and given back. A store or Solid's merged props, which change by their own
986
+ * rules and aren't ours to freeze, and a carried rune, as an object of the keys they have now, frozen,
987
+ * each a getter read through them. An object of a class is given back as it is.
988
+ */
989
+ const fixedRune = (rune: unknown): unknown => {
990
+ if (readsThrough(rune)) return keysThrough(rune as Readonly<Record<string, unknown>>)
991
+ if (!isPlainData(rune)) return rune
992
+ if (!Object.isFrozen(rune)) Object.freeze(rune)
993
+ return rune
994
+ }
995
+
996
+ /** The plain data under `rune`'s keys frozen, where it's a plain object: what development checks ({@link freezeValues}). */
997
+ const freezeIfPlain = (rune: unknown): void => {
998
+ if (!isPlainData(rune)) return
999
+ freezeValues(rune)
1000
+ }
1001
+
1002
+ /** One of a ward's runes fixed as it's made, where it isn't one {@link createRune} made: frozen where it's plain, the data inside it too. In development ({@link fixedRunes}). */
1003
+ const fixInPlace = (rune: unknown): void => {
1004
+ if (!isPlainData(rune)) return
1005
+ if (FACTS.has(rune)) return
1006
+ freezeValues(rune)
1007
+ if (!Object.isFrozen(rune)) Object.freeze(rune)
1008
+ }
1009
+
1010
+ /** The descriptors of `source`'s keys as they are now, each a getter read through `source` where it's read. */
1011
+ const descriptorsThrough = (source: Readonly<Record<string, unknown>>): PropertyDescriptorMap => {
1012
+ const through: PropertyDescriptorMap = {}
1013
+ Arr.forEach(Object.keys(source), (key) => {
1014
+ through[key] = { enumerable: true, get: () => source[key] }
1015
+ })
1016
+ return through
1017
+ }
1018
+
1019
+ /** `source`'s keys as they are now, frozen, each read through `source` where it's read. Called untracked. */
1020
+ const keysThrough = (source: Readonly<Record<string, unknown>>): Readonly<Record<string, unknown>> =>
1021
+ Object.freeze(Object.defineProperties({}, descriptorsThrough(source)))
1022
+
1023
+ /**
1024
+ * What a ward works out of one rune of its own, the same for every ward that takes it: worked out
1025
+ * once for a rune `createRune` made, and kept with it ({@link FACTS}), and for any other as a ward is
1026
+ * made of it.
1027
+ */
1028
+ export interface RuneFacts {
1029
+ /** Whether it can be a ward's config as it is, alone ({@link isPlainConfig}): worked out for a rune kept, and `false` for any other, which is asked where it's alone. */
1030
+ readonly plain: boolean
1031
+ /** Whether it gives the ward a key: one of the ward config's, and not the hooks' own. */
1032
+ readonly givesTheWard: boolean
1033
+ /**
1034
+ * Whether it has to be joined, key by key ({@link joined}): it follows, or times its followers; or
1035
+ * its `variants` carry timing, or are an accessor's or a getter's ({@link variantsNeedJoining}).
1036
+ */
1037
+ readonly joins: boolean
1038
+ /** Whether it gives a callback, which the ward calls with what it tells: joined where it's beside another rune. */
1039
+ readonly callback: boolean
1040
+ /** Which of {@link SEEN}'s keys it gives, a bit for each. */
1041
+ readonly seen: number
1042
+ /** Its own keys, in the order it has them: the hooks' own among them, which give the ward nothing. */
1043
+ readonly keys: ReadonlyArray<string>
1044
+ /**
1045
+ * What each of {@link keys} is fixed as over another rune's, where this one gives it alone: its
1046
+ * value, or its accessor, or {@link ACROSS} for a getter's, read across the runes. Kept for a rune
1047
+ * `createRune` made; for any other it's looked up as it's needed ({@link besideOf}).
1048
+ */
1049
+ readonly fixes: Readonly<Record<string, unknown>> | undefined
1050
+ }
1051
+
1052
+ /** What's fixed for a getter's key: read across the runes, where it's read. */
1053
+ const ACROSS: unique symbol = Symbol("wardic.rune.across")
1054
+
1055
+ /**
1056
+ * What's worked out of each rune `createRune` made, held by the rune: the same for every ward made of it.
1057
+ *
1058
+ * Module state (#460, Q7): a cache held weakly by the rune it's for, so it goes with it.
1059
+ */
1060
+ const FACTS = new WeakMap<object, RuneFacts>()
1061
+
1062
+ /**
1063
+ * `rune`'s facts ({@link RuneFacts}), worked out of its keys, each read once. Read untracked: a getter
1064
+ * read here isn't followed. With `fixes` for a rune that keeps them.
1065
+ */
1066
+ const factsOf = (rune: Loose, kept: boolean): RuneFacts => {
1067
+ const keys = Object.keys(rune)
1068
+ let fixes: Record<string, unknown> | undefined
1069
+ if (kept) fixes = {}
1070
+ let seen = 0
1071
+ let joins = false
1072
+ let callback = false
1073
+ let gives = false
1074
+ Arr.forEach(keys, (key) => {
1075
+ const bit = SEEN_BIT.get(key)
1076
+ if (Predicate.isNotUndefined(bit)) seen |= bit
1077
+ if (key === "follow") joins = true
1078
+ if (key === "followers") joins = true
1079
+ // The hooks' own: never the ward's config's.
1080
+ if (OWN_KEYS.has(key)) return
1081
+ gives = true
1082
+ if (key === "variants") {
1083
+ if (variantsNeedJoining(rune)) joins = true
1084
+ }
1085
+ if (AS_GIVEN.has(key)) callback = true
1086
+ if (Predicate.isNotUndefined(fixes)) fixes[key] = fixOf(rune, key)
1087
+ })
1088
+ // Whether it's a ward's config alone is asked of a rune kept, as a ward may be made of it alone;
1089
+ // of any other it's asked where it is, so it isn't worked out here for every rune of every ward.
1090
+ let plain = false
1091
+ if (kept) plain = isPlainConfig(rune)
1092
+ return { plain, givesTheWard: gives, joins, callback, seen, keys, fixes }
1093
+ }
1094
+
1095
+ /** What's fixed for `key` of `rune` over another rune's, where it alone gives it: its value, or its accessor, or {@link ACROSS} for a getter's. */
1096
+ const fixOf = (rune: Loose, key: string): unknown => {
1097
+ const descriptor = Object.getOwnPropertyDescriptor(rune, key)
1098
+ if (Predicate.isUndefined(descriptor)) return ACROSS
1099
+ if (Predicate.isNotUndefined(descriptor.get)) return ACROSS
1100
+ return descriptor.value
1101
+ }
1102
+
1103
+ /** A rune's facts: kept, for one `createRune` made, or worked out now, as a ward is made of it. */
1104
+ const factsFor = (rune: Loose): RuneFacts => {
1105
+ const kept = FACTS.get(rune)
1106
+ if (Predicate.isNotUndefined(kept)) return kept
1107
+ return factsOf(rune, false)
1108
+ }
1109
+
1110
+ /** Whether one rune can be a ward's config as it is ({@link isPlainConfig}): kept, for one `createRune` made, or worked out now, untracked. */
1111
+ export const isPlainRune = (rune: RuneConfig): boolean => {
1112
+ const kept = FACTS.get(rune)
1113
+ if (Predicate.isNotUndefined(kept)) return kept.plain
1114
+ return untrack(() => isPlainConfig(rune))
1115
+ }
1116
+
1117
+ /** Whether `value` is a `createRune(fn)`. */
1118
+ export const isFunctionRune = (value: unknown): value is FunctionRune => {
1119
+ // Asked of every rune of every ward as it's made: plain checks, where `Predicate.hasProperty` is a
1120
+ // `dual` call with what it allocates for one (188 bytes a ward of five runes, by a heap profile).
1121
+ if (!Predicate.isObject(value)) return false
1122
+ return RUNE in value
1123
+ }
1124
+
1125
+ /** `value`'s function: what `createRune(fn)` holds. */
1126
+ export const functionOf = (value: FunctionRune): ((ward: RuneWard) => RuneConfig) => value[RUNE]
1127
+
1128
+ /**
1129
+ * The value that carries an API's `members` beside `rune` (the rune-with grill's Q8), by what the rune is:
1130
+ * a behaviour, frozen, in a new one of its own; a function (a ref carrying its props, a Reorder group) as it
1131
+ * is, so it's still called as a ref; a plain rune, a fresh value read through it, so a rune shared between
1132
+ * calls is never changed, its keys as they are now, each read live (Q3). Built once, at module load: after
1133
+ * {@link isFunctionRune}, which it reads.
1134
+ */
1135
+ const carrierOf: (rune: object) => (members: PropertyDescriptorMap) => object = Match.type<object>().pipe(
1136
+ Match.when(isFunctionRune, (behaviour) => (members: PropertyDescriptorMap): object => Object.freeze(Object.defineProperties({ [RUNE]: functionOf(behaviour) }, members))),
1137
+ Match.when(Predicate.isFunction, (ref) => (members: PropertyDescriptorMap): object => carriedRune(Object.defineProperties(ref, members))),
1138
+ // Its keys read untracked, as `createRune(config)` reads them: a store's are what they are, not followed.
1139
+ Match.orElse((plain) => (members: PropertyDescriptorMap): object => Object.freeze(carriedRune(Object.defineProperties({}, { ...untrack(() => descriptorsThrough(plain as Loose)), ...members })))),
1140
+ )
1141
+
1142
+ type Loose = Readonly<Record<string, unknown>>
1143
+
1144
+ /** The keys whose values are targets: two objects merge their keys. */
1145
+ const TARGET_KEYS: ReadonlySet<string> = new Set(["initial", "animate", "exit", "whileHover", "whileTap", "whileFocus", "whileInView", "whileDrag"])
1146
+ /** The keys whose objects merge their keys. */
1147
+ const OBJECT_KEYS: ReadonlySet<string> = new Set([...TARGET_KEYS, "transition", "style", "viewport", "followers"])
1148
+ /** The keys a function is the value of, never an accessor: the ward's callbacks, and the hooks' own. */
1149
+ const AS_GIVEN: ReadonlySet<string> = new Set(["onUpdate", "dragConstraints", "onMeasureDragConstraints", "transformTemplate", "onBeforeLayoutMeasure", "onLayoutMeasure", "follow", "show", "popBox", "subject", "ref", "lifted", "transformPagePoint"])
1150
+ /**
1151
+ * The keys the hooks read themselves, which the ward's config never carries. A `ref` is every rune's
1152
+ * own: none wins (`refs.ts`). Its `props` are joined name by name, onto the ward's spread (`props.ts`).
1153
+ */
1154
+ const OWN_KEYS: ReadonlySet<string> = new Set(["follow", "show", "followers", "pop", "enter", "popBox", "subject", "ref", "props", "tag", "lifted"])
1155
+
1156
+ const isPlain = (value: unknown): value is Loose => Predicate.isObject(value) && !Array.isArray(value) && !Predicate.isFunction(value)
1157
+
1158
+ /** A rune's value for `key`: an accessor called, as the ward itself reads one. */
1159
+ const read = (config: Loose, key: string): unknown => {
1160
+ const value = config[key]
1161
+ if (AS_GIVEN.has(key)) return value
1162
+ if (Predicate.isFunction(value)) return (value as () => unknown)()
1163
+ return value
1164
+ }
1165
+
1166
+ const mergeObjects = (earlier: unknown, later: unknown): unknown => {
1167
+ if (Predicate.isUndefined(later)) return earlier
1168
+ if (isPlain(earlier) && isPlain(later)) return { ...earlier, ...later }
1169
+ return later
1170
+ }
1171
+
1172
+ /** A variant as its target: a function of `custom` called with it. */
1173
+ const variantWith = (variant: unknown, custom: unknown): unknown => {
1174
+ if (Predicate.isFunction(variant)) return (variant as (custom: unknown) => unknown)(custom)
1175
+ return variant
1176
+ }
1177
+
1178
+ /**
1179
+ * One rune's variant over another's, under one name. Two targets merge their keys. With a function of
1180
+ * `custom` among them the two still join, as a function of it: each is resolved with the `custom` it's
1181
+ * called with, and their targets merge. So a rune that says where a name puts a ward by its `custom`
1182
+ * and a rune that says how the name fades it are one variant, where the later one replaced the other.
1183
+ */
1184
+ const mergeVariant = (earlier: unknown, later: unknown): unknown => {
1185
+ if (Predicate.isUndefined(later)) return earlier
1186
+ if (Predicate.isUndefined(earlier)) return later
1187
+ if (!Predicate.isFunction(earlier) && !Predicate.isFunction(later)) return mergeObjects(earlier, later)
1188
+ return (custom: unknown): unknown => mergeObjects(variantWith(earlier, custom), variantWith(later, custom))
1189
+ }
1190
+
1191
+ const mergeVariants = (earlier: unknown, later: unknown): unknown => {
1192
+ if (Predicate.isUndefined(later)) return earlier
1193
+ if (!isPlain(earlier) || !isPlain(later)) return later
1194
+ return { ...earlier, ...Rec.map(later, (variant, name) => mergeVariant(earlier[name], variant)) }
1195
+ }
1196
+
1197
+ /** `followers`' timing as the transition keys core reads. */
1198
+ const timingOf = (followers: Followers): Loose => {
1199
+ const timing: Record<string, unknown> = {}
1200
+ if (Predicate.isNotUndefined(followers.stagger)) timing.staggerChildren = followers.stagger
1201
+ if (Predicate.isNotUndefined(followers.delay)) timing.delayChildren = followers.delay
1202
+ if (followers.from === "last") timing.staggerDirection = -1
1203
+ if (followers.order === "leader-first") timing.when = "beforeChildren"
1204
+ if (followers.order === "followers-first") timing.when = "afterChildren"
1205
+ return timing
1206
+ }
1207
+
1208
+ /** `transition` with `followers`' timing under its own keys. */
1209
+ const withTiming = (transition: unknown, followers: unknown): unknown => {
1210
+ if (!isPlain(followers)) return transition
1211
+ if (isPlain(transition)) return { ...timingOf(followers as Followers), ...transition }
1212
+ return timingOf(followers as Followers)
1213
+ }
1214
+
1215
+ /** A variant without its `followers`, its timing in its `transition`. */
1216
+ const variantWithTiming = (variant: unknown): unknown => {
1217
+ if (!isPlain(variant)) return variant
1218
+ if (!("followers" in variant)) return variant
1219
+ const { followers, transition, ...target } = variant
1220
+ return { ...target, transition: withTiming(transition, followers) }
1221
+ }
1222
+
1223
+ /** Whether a variant carries `followers`. */
1224
+ const hasFollowers = (variant: unknown): boolean => isPlain(variant) && "followers" in variant
1225
+
1226
+ /** Whether any variant in `variants` carries `followers`. */
1227
+ const anyTiming = (variants: unknown): boolean => {
1228
+ if (!isPlain(variants)) return false
1229
+ return Rec.some(variants, hasFollowers)
1230
+ }
1231
+
1232
+ const variantsWithTiming = (variants: unknown): unknown => {
1233
+ if (!anyTiming(variants)) return variants
1234
+ return Rec.map(variants as Loose, variantWithTiming)
1235
+ }
1236
+
1237
+ const isLabels = (value: unknown): value is string | ReadonlyArray<string> => Predicate.isString(value) || Array.isArray(value)
1238
+
1239
+ /** A follower's own names as targets: each name's variant, a function's called with `custom`, merged in order. */
1240
+ const targetOf = (labels: string | ReadonlyArray<string>, variants: unknown, custom: unknown): unknown => {
1241
+ if (!isPlain(variants)) return undefined
1242
+ return Arr.reduce(Arr.ensure(labels), undefined as unknown, (target, name) => mergeObjects(target, variantWith(variants[name], custom)))
1243
+ }
1244
+
1245
+ /** Whether a value written at a target key may name a state: a name, a function, or Animation controls, which can start one. */
1246
+ const mayNameBy = (value: unknown): boolean => Bool.or(Bool.or(isLabels(value), Predicate.isFunction(value)), AnimationControls.isAnimationControls(value))
1247
+
1248
+ /** Whether `rune`'s `key`, as it's written, may name a state ({@link mayNameBy}), or is a getter's, which isn't called here. */
1249
+ const mayNameAt = (rune: Loose, key: string): boolean => {
1250
+ const descriptor = Object.getOwnPropertyDescriptor(rune, key)
1251
+ if (Predicate.isUndefined(descriptor)) return false
1252
+ if (Predicate.isNotUndefined(descriptor.get)) return true
1253
+ return mayNameBy(descriptor.value)
1254
+ }
1255
+
1256
+ /** The keys that give a ward names whatever its targets say: its own `variants`, its `inherit`, or a ward it follows, whose it hands on. */
1257
+ const NAMES_GIVEN_BY: ReadonlySet<string> = new Set(["variants", "inherit", "follow"])
1258
+
1259
+ /**
1260
+ * Whether a ward of `rune` may name a state a follower takes: one that sets a key of
1261
+ * {@link NAMES_GIVEN_BY}, or at any target key may name one ({@link mayNameAt}). A function rune, and any
1262
+ * value that isn't a plain rune, may: neither is read here.
1263
+ */
1264
+ const mayName = (rune: Rune): boolean => {
1265
+ if (isFunctionRune(rune)) return true
1266
+ if (!isPlain(rune)) return true
1267
+ if (Iter.some(NAMES_GIVEN_BY, (key) => key in rune)) return true
1268
+ return Iter.some(TARGET_KEYS, (key) => mayNameAt(rune, key))
1269
+ }
1270
+
1271
+ /**
1272
+ * Whether a ward of `runes` names no state at all, as they're written (the follow grill's Q2): what a ward
1273
+ * that follows it is warned of in development. Nothing is read to say so: a function, a getter or a
1274
+ * function rune may name one, and isn't called.
1275
+ */
1276
+ export const namesNothing = (runes: ReadonlyArray<Rune>): boolean => !Arr.some(runes, mayName)
1277
+
1278
+ /** Whether `rune` sets `variants` of its own, as it's written: a function rune's aren't read here. */
1279
+ const setsVariants = (rune: Rune): boolean => {
1280
+ if (isFunctionRune(rune)) return false
1281
+ if (!isPlain(rune)) return false
1282
+ return "variants" in rune
1283
+ }
1284
+
1285
+ /**
1286
+ * Whether a ward of `runes` has `variants` of its own, as they're written (the follow grill's Q12): one a
1287
+ * follower is warned for, where the ward it follows names no state, since none of its variants can ever be
1288
+ * chosen. One with none follows only to leave with its leader (Q12, Q20), and isn't.
1289
+ */
1290
+ export const hasOwnVariants = (runes: ReadonlyArray<Rune>): boolean => Arr.some(runes, setsVariants)
1291
+
1292
+ /** The gesture keys: a follower keeps its own names in these (the gap grill's Q26). */
1293
+ const GESTURE_KEYS: ReadonlyArray<string> = ["whileHover", "whileTap", "whileFocus", "whileInView", "whileDrag"]
1294
+
1295
+ /** Whether `key` is a gesture's. */
1296
+ const isGestureKey = (key: string): boolean => Arr.contains(GESTURE_KEYS, key)
1297
+
1298
+ /**
1299
+ * Whether `config` names a gesture of its own, as it's written (Q26). A follower that does keeps the
1300
+ * name and is a Variant child by its own word (core's `variantChild`): it joins its leader, and hands
1301
+ * the name down to followers of its own. One behind an accessor isn't seen here.
1302
+ */
1303
+ const namesGesture = (config: Loose): boolean => Arr.some(GESTURE_KEYS, (key) => isLabels(config[key]))
1304
+
1305
+ /** Whether one config alone needs none of the hooks' own work: it can be the ward's config as it is. */
1306
+ export const isPlainConfig = (config: RuneConfig): boolean => {
1307
+ const loose = config as Loose
1308
+ if (Iter.some(OWN_KEYS, (key) => key in loose)) return false
1309
+ // A getter's variants are read where the ward reads them; a plain object is checked here.
1310
+ const descriptor = Object.getOwnPropertyDescriptor(loose, "variants")
1311
+ if (Predicate.isUndefined(descriptor)) return true
1312
+ if (Predicate.isNotUndefined(descriptor.get)) return false
1313
+ return !anyTiming(descriptor.value)
1314
+ }
1315
+
1316
+ /** A config read by its keys alone, each as it reads now: no `in` and no list of its keys is answered by one that's a view. */
1317
+ export type ReadByKey = Readonly<Record<string, unknown>>
1318
+
1319
+ /** What {@link joined} and {@link joinedOver} give: the ward's config, and what the hooks read of the runes themselves. */
1320
+ export interface Joined {
1321
+ /**
1322
+ * The ward's config, read where the ward reads it: joined, each key a getter over the runes'; read
1323
+ * through ({@link joinedOver}), one of the runes itself, with its `wired` keys to fix over it.
1324
+ */
1325
+ readonly config: WardConfig
1326
+ /** Its `follow`, read once. */
1327
+ readonly follow: AnyWard | undefined
1328
+ /** Its `show`, read once. */
1329
+ readonly show: Accessor<boolean> | undefined
1330
+ /** A key's joined value, as the ward would read it now. */
1331
+ readonly value: (key: string) => unknown
1332
+ /** One of the hooks' own keys (`pop`, `popBox`, `subject`), read once. */
1333
+ readonly own: (key: "pop" | "popBox" | "subject" | "lifted") => unknown
1334
+ /** Whether any rune gives `key`. */
1335
+ readonly has: (key: string) => boolean
1336
+ /** Whether it has no entrance (`enter: false`): its `initial` is then one of its wired keys ({@link wiredOf}). */
1337
+ readonly unentered: boolean
1338
+ /**
1339
+ * Whether it's a **Variant child** by its own word: a follower that names a gesture of its own,
1340
+ * which keeps the name (the gap grill's Q26). Its ward's internals tell core so (`variantChild`).
1341
+ */
1342
+ readonly variantChild: boolean
1343
+ /**
1344
+ * The keys to be read from somewhere other than `config`, for the ward to fix over it (its
1345
+ * internals' `fixed`): where `config` is a rune read through as it's written, which gets no getter
1346
+ * of its own. What the runes beside it give, and what the ward's wiring reads ({@link wiredOf}).
1347
+ * None where the runes were joined, whose config's getters read both ways.
1348
+ */
1349
+ readonly wired?: Wired | undefined
1350
+ /**
1351
+ * Its config as its keys read now, an accessor's called: what a ward's Features are found by
1352
+ * (`auto.ts`). A joined config, whose getters read that way; a rune read through, read key by key.
1353
+ */
1354
+ readonly asRead: () => ReadByKey
1355
+ }
1356
+
1357
+ /**
1358
+ * A ward's wired keys, each as it's fixed over the ward's config: a function the ward calls for the
1359
+ * key's value (how it's read through its wiring, or across its runes), or a rune's own value for it.
1360
+ */
1361
+ export type Wired = Readonly<Record<string, unknown>>
1362
+
1363
+ /** What a `show` ward's `animate` and `style` are read through. */
1364
+ export interface Shown {
1365
+ /** `animate`, given what the runes say it is while shown. */
1366
+ readonly animate: (shown: unknown) => unknown
1367
+ /** `style`, given the runes': how the page hides it. None where there's no style to hide by, on a Stage. */
1368
+ readonly style?: ((style: unknown) => unknown) | undefined
1369
+ /**
1370
+ * Whether an element it's given now enters from its `initial`, whatever `enter: false` said of its
1371
+ * first: a presence's ward, once its value came after the page opened or after another. Read where
1372
+ * the ward reads its `initial`, as it's made and as an element enters afresh (#414).
1373
+ */
1374
+ readonly reenters?: (() => boolean) | undefined
1375
+ /**
1376
+ * `exit` as the ward's own config gives it, given the runes': none, for a ward that comes and goes
1377
+ * by a hook. Its exit is that hook's to run; left in its config, a component presence above it ran
1378
+ * it too as what's around it left, as a nested presence's child doesn't unless it's told to.
1379
+ */
1380
+ readonly exit?: ((exit: unknown) => unknown) | undefined
1381
+ /**
1382
+ * `custom` as the ward reads it, given the runes' own, read when it's called: the one it started to
1383
+ * leave with, while it leaves. A presence reads its `custom` as each child leaves (Motion's); a ward
1384
+ * that's still there as it leaves would go on reading it, and turn round when the page's changed.
1385
+ */
1386
+ readonly custom?: ((own: () => unknown) => unknown) | undefined
1387
+ }
1388
+
1389
+ /** No key left out of a joined config: the page's wards. */
1390
+ const NONE_OMITTED: ReadonlySet<string> = new Set()
1391
+
1392
+ /**
1393
+ * Whether a rune's `variants` have to be joined ({@link joined}), and can't be read as they're
1394
+ * written: they carry timing for its followers, or they're an accessor's or a getter's, where that's
1395
+ * found as they're read.
1396
+ */
1397
+ const variantsNeedJoining = (config: Loose): boolean => {
1398
+ const descriptor = Object.getOwnPropertyDescriptor(config, "variants")
1399
+ if (Predicate.isUndefined(descriptor)) return false
1400
+ if (Predicate.isNotUndefined(descriptor.get)) return true
1401
+ if (Predicate.isFunction(descriptor.value)) return true
1402
+ return anyTiming(descriptor.value)
1403
+ }
1404
+
1405
+ /** Whether `config` gives `key`: one of its own, as its keys are listed, with no list made of them. */
1406
+ const givenBy = (config: Loose, key: string): boolean => Object.prototype.propertyIsEnumerable.call(config, key)
1407
+
1408
+ /**
1409
+ * What's fixed over the source for `key`, which `config` gives beside it.
1410
+ *
1411
+ * Where no rune before it gives the key and it's written plainly, that's the rune's own: its value,
1412
+ * or its accessor, called as the ward calls the source's own. Nothing stands between the ward and
1413
+ * it: a function for each, read at every read, cost a ward of five runes a microsecond as it
1414
+ * mounted. Otherwise it's a function that reads the key across the runes as it's read: one several
1415
+ * of them give (a later one wins, objects merge, their `variants` name by name), and a getter's,
1416
+ * which is read where the ward reads it and not here. A key across the runes is the runes' own:
1417
+ * none of them follows, times its followers or carries timing in its variants, which is all a joined
1418
+ * read adds.
1419
+ *
1420
+ * One rune's `variants` are its own, as written, as any key it alone gives is: merged across the
1421
+ * runes with nothing beside them, they were the same object, found by a pass over every rune at each
1422
+ * read, which a ward of ten runes paid for a point or two at its Retarget. Ones that are an accessor's,
1423
+ * a getter's or carry timing never come here: such a rune is joined.
1424
+ *
1425
+ * A key a later rune gives too is found as that rune is read, and fixed again, across them.
1426
+ */
1427
+ const besideOf = (runes: ReadonlyArray<Loose>, source: Loose, beside: Record<string, unknown>, config: Loose, facts: RuneFacts, key: string): unknown => {
1428
+ if (key in source) return () => acrossIn(runes, key)
1429
+ if (key in beside) return () => acrossIn(runes, key)
1430
+ // A store is read through an object of its keys' getters (`fixedRunes`), so its keys are getters
1431
+ // here: read as the ward reads them, through the store (HY7).
1432
+ const fixed = fixedIn(facts, config, key)
1433
+ if (fixed === ACROSS) return () => acrossIn(runes, key)
1434
+ return fixed
1435
+ }
1436
+
1437
+ /** What's fixed for `key` of `config`: kept in its facts, for a rune `createRune` made, else looked up now. */
1438
+ const fixedIn = (facts: RuneFacts, config: Loose, key: string): unknown => {
1439
+ const fixes = facts.fixes
1440
+ if (Predicate.isUndefined(fixes)) return fixOf(config, key)
1441
+ return fixes[key]
1442
+ }
1443
+
1444
+ /** Runes that need no joining: `source`, the first that gives the ward a key, and all of them, which the rest of what they give is read across. */
1445
+ export interface ReadThrough {
1446
+ readonly source: RuneConfig
1447
+ readonly configs: ReadonlyArray<RuneConfig>
1448
+ /**
1449
+ * What the runes beside the source give the ward, to fix over the source's own ({@link besideOf}):
1450
+ * a key's value, an accessor of it, or a function that reads it across the runes. None where they
1451
+ * give it nothing: a list's row, a ward with a `show` and one rune more.
1452
+ */
1453
+ readonly beside: Record<string, unknown> | undefined
1454
+ /** Which of {@link SEEN}'s keys any of the runes gives, a bit for each. */
1455
+ readonly seen: number
1456
+ }
1457
+
1458
+ /**
1459
+ * Keys only some wards' runes give, each with work of the hooks' own behind it: a rune's `props`
1460
+ * and `ref`, a ward's `subject`, a twin's `layoutId`, the `animate` a presence takes a ward by, a
1461
+ * ward's `show` and `enter`, and its Subject's `tag`. The pass that reads a ward's runes notes which it saw ({@link ReadThrough.seen}), so each needn't
1462
+ * be looked for across the runes again: a pass apiece, for every ward, most with none of them.
1463
+ */
1464
+ export const SEEN = { props: 1, ref: 2, subject: 4, layoutId: 8, animate: 16, show: 32, enter: 64, exit: 128, tag: 256 } as const
1465
+ const SEEN_BIT: ReadonlyMap<string, number> = new Map(Object.entries(SEEN))
1466
+
1467
+ /** What one pass over a ward's runes has found so far ({@link readThroughOf}). */
1468
+ interface Reading {
1469
+ source: Loose | undefined
1470
+ beside: Record<string, unknown> | undefined
1471
+ seen: number
1472
+ /** One of them has to be joined, key by key. */
1473
+ joined: boolean
1474
+ /** Whether each so far is one `createRune` made, whose facts are kept: the answer for them all can be kept too. */
1475
+ made: boolean
1476
+ }
1477
+
1478
+ /**
1479
+ * What runes `createRune` made are read through as, given together in this order: the same for every
1480
+ * ward made of them, so kept, a step a rune ({@link readThroughOf}). `known` once it's been worked out;
1481
+ * `through` is then the answer, none where they're joined.
1482
+ */
1483
+ interface Combined {
1484
+ known: boolean
1485
+ through: ReadThrough | undefined
1486
+ readonly next: WeakMap<object, Combined>
1487
+ }
1488
+
1489
+ /**
1490
+ * The answers for runes `createRune` made, by the runes in the order they're given, from the first.
1491
+ *
1492
+ * Module state (#460, Q7): a cache held weakly by the runes it's for, so it goes with them.
1493
+ */
1494
+ const COMBINED = new WeakMap<object, Combined>()
1495
+
1496
+ /** The step for `configs` from `at` on, made as it's first asked for; none where one isn't a rune `createRune` made. */
1497
+ const combinedAt = (configs: ReadonlyArray<object>, at: number, steps: WeakMap<object, Combined>): Combined | undefined => {
1498
+ const rune = configs[at] as object
1499
+ if (!FACTS.has(rune)) return undefined
1500
+ let step = steps.get(rune)
1501
+ if (Predicate.isUndefined(step)) {
1502
+ step = { known: false, through: undefined, next: new WeakMap() }
1503
+ steps.set(rune, step)
1504
+ }
1505
+ if (at === configs.length - 1) return step
1506
+ return combinedAt(configs, at + 1, step.next)
1507
+ }
1508
+
1509
+ /**
1510
+ * `configs` as runes read through as they're written ({@link joinedOver}), when they can be: one
1511
+ * gives the ward a key, and none has to be joined key by key ({@link joined}). A list's row
1512
+ * (`{ show }`, the row's own runes, and where it popped), a ward of one rune, a ward of several.
1513
+ *
1514
+ * A rune has to be joined that follows, or times its followers, whose names and timing are
1515
+ * resolved as each key is read; whose `variants` carry timing, or are an accessor's or a getter's
1516
+ * ({@link variantsNeedJoining}); or that gives a
1517
+ * callback beside the source. What's fixed over a config is a function the ward calls for a key's
1518
+ * value, and a callback's value is the function itself, which the ward calls with what it tells:
1519
+ * fixed that way, `onUpdate` was asked for and never told (HY5). A callback of the source's own is
1520
+ * the ward's as it's written.
1521
+ *
1522
+ * In one pass over the runes, each one's facts read once ({@link readRune}): kept with a rune
1523
+ * `createRune` made, and worked out for any other. Where every rune is one `createRune` made, the
1524
+ * answer is the same each time they're given together in that order, and kept too ({@link COMBINED}):
1525
+ * a component that makes its ward of runes kept in constants works none of it out again.
1526
+ */
1527
+ export const readThroughOf = (configs: ReadonlyArray<RuneConfig>): ReadThrough | undefined => {
1528
+ const step = combinedAt(configs, 0, COMBINED)
1529
+ if (Predicate.isUndefined(step)) return untrack(() => readAll(configs))
1530
+ if (step.known) return step.through
1531
+ const through = readAll(configs)
1532
+ step.through = through
1533
+ step.known = true
1534
+ return through
1535
+ }
1536
+
1537
+ /** {@link readThroughOf}, worked out: one pass over `configs`. */
1538
+ const readAll = (configs: ReadonlyArray<RuneConfig>): ReadThrough | undefined => {
1539
+ const runes = configs as ReadonlyArray<Loose>
1540
+ const reading: Reading = { source: undefined, beside: undefined, seen: 0, joined: false, made: true }
1541
+ Arr.forEach(runes, (config) => readRune(reading, runes, config))
1542
+ if (reading.joined) return undefined
1543
+ const source = reading.source
1544
+ if (Predicate.isUndefined(source)) return undefined
1545
+ return { source, configs, beside: reading.beside, seen: reading.seen }
1546
+ }
1547
+
1548
+ /** Where what's beside the source is kept, made at the first key there. */
1549
+ const besideIn = (reading: Reading): Record<string, unknown> => {
1550
+ const made = reading.beside
1551
+ if (Predicate.isNotUndefined(made)) return made
1552
+ const beside: Record<string, unknown> = {}
1553
+ reading.beside = beside
1554
+ return beside
1555
+ }
1556
+
1557
+ /**
1558
+ * One rune, by its facts ({@link readThroughOf}): whether it has to be joined, whether it's the
1559
+ * source, the first to give the ward a key, and what it gives beside the source.
1560
+ */
1561
+ const readRune = (reading: Reading, runes: ReadonlyArray<Loose>, config: Loose): void => {
1562
+ if (reading.joined) return
1563
+ const facts = factsFor(config)
1564
+ reading.seen |= facts.seen
1565
+ if (facts.joins) {
1566
+ reading.joined = true
1567
+ return
1568
+ }
1569
+ if (!facts.givesTheWard) return
1570
+ const source = reading.source
1571
+ if (Predicate.isUndefined(source)) {
1572
+ reading.source = config
1573
+ return
1574
+ }
1575
+ if (facts.callback) {
1576
+ reading.joined = true
1577
+ return
1578
+ }
1579
+ const beside = besideIn(reading)
1580
+ Arr.forEach(facts.keys, (key) => {
1581
+ // The hooks' own give the ward nothing.
1582
+ if (OWN_KEYS.has(key)) return
1583
+ beside[key] = besideOf(runes, source, beside, config, facts, key)
1584
+ })
1585
+ }
1586
+
1587
+ /** What a rune read through is viewed over, for its keys as they read ({@link Joined.asRead}): every answer is the view's. */
1588
+ const NO_KEYS: ReadByKey = {}
1589
+
1590
+ /**
1591
+ * One plain rune's keys as its ward reads them, an accessor's as its result: what {@link Joined.asRead}
1592
+ * is for runes that are joined, for a rune that's its ward's config as it is.
1593
+ */
1594
+ export const asReadOf = (config: RuneConfig): ReadByKey => new Proxy(NO_KEYS, { get: (_none, key) => read(config as Loose, key as string) })
1595
+
1596
+ /**
1597
+ * The keys a ward's wiring reads, each as how it's read through that wiring: `initial` where the
1598
+ * ward has no entrance, `animate`, and `exit`, `custom` and `style` where the wiring has one for it
1599
+ * and, for the first two, a rune gives the key (`has`). The one set, for a joined config's getters
1600
+ * and for a rune read through.
1601
+ */
1602
+ export const wiredOf = (wiring: Shown | undefined, unentered: boolean, value: (key: string) => unknown, has: (key: string) => boolean): Wired => {
1603
+ const wired: Record<string, () => unknown> = {}
1604
+ // No entrance: none, so it starts at its `animate`; its own `initial` for an element that enters afresh later.
1605
+ if (unentered) {
1606
+ wired["initial"] = () => {
1607
+ if (Predicate.isUndefined(wiring)) return false
1608
+ if (Predicate.isUndefined(wiring.reenters)) return false
1609
+ if (wiring.reenters()) return value("initial")
1610
+ return false
1611
+ }
1612
+ }
1613
+ if (Predicate.isUndefined(wiring)) return wired
1614
+ wired["animate"] = () => wiring.animate(value("animate"))
1615
+ const hidden = wiring.exit
1616
+ if (Predicate.isNotUndefined(hidden) && has("exit")) wired["exit"] = () => hidden(value("exit"))
1617
+ const kept = wiring.custom
1618
+ if (Predicate.isNotUndefined(kept) && has("custom")) wired["custom"] = () => kept(() => value("custom"))
1619
+ const styled = wiring.style
1620
+ if (Predicate.isNotUndefined(styled)) wired["style"] = () => styled(value("style"))
1621
+ return wired
1622
+ }
1623
+
1624
+ /**
1625
+ * Runes as a ward's config with no key joined: what {@link joined} gives for them, where none of
1626
+ * them needs it ({@link readThroughOf}). The config is one of the runes itself, the first that
1627
+ * gives the ward a key, read as a ward reads any config. Whatever else is to be read from somewhere
1628
+ * other than that rune is handed back (`wired`) for the ward to fix over it, its own way to read a
1629
+ * key from elsewhere: a key another rune gives, read across them all as joined; a key the ward's
1630
+ * wiring reads. So nothing is copied, no getter is made, and no rune is an object's prototype: one
1631
+ * over each rune was tried first, and a ward's reads of its config cost more through it than the
1632
+ * join had (`docs/research/hooks-first-probe.md`, *The trims*).
1633
+ */
1634
+ export const joinedOver = ({ source, configs, beside, seen }: ReadThrough, shown: (runes: Joined) => Shown | undefined): Joined => {
1635
+ const loose = configs as ReadonlyArray<Loose>
1636
+ const first = source as Loose
1637
+ const own = (key: string): unknown => acrossIn(loose, key)
1638
+ const has = (key: string): boolean => Arr.some(loose, (config) => givenBy(config, key))
1639
+ // A key of the ward's that no rune beside the source gives is the source's own, read straight
1640
+ // from it: a list's row, whose other runes give keys of the hooks' own alone.
1641
+ const value = (key: string): unknown => {
1642
+ if (OWN_KEYS.has(key)) return own(key)
1643
+ if (Predicate.isUndefined(beside)) return read(first, key)
1644
+ if (Object.hasOwn(beside, key)) return own(key)
1645
+ return read(first, key)
1646
+ }
1647
+ // Made when it's asked for: only a ward whose Features are found by its config asks. A key fixed
1648
+ // over the source reads as it's fixed, as a joined config's getter does. Over an object with no
1649
+ // keys, not over the rune: a view must answer a frozen object's key with that object's own value,
1650
+ // and a frozen rune's accessor reads as its result.
1651
+ const asRead = (): ReadByKey =>
1652
+ new Proxy(NO_KEYS, {
1653
+ get: (_rune, key) => {
1654
+ const wired = self.wired
1655
+ if (Predicate.isUndefined(wired)) return value(key as string)
1656
+ if (!Object.hasOwn(wired, key)) return value(key as string)
1657
+ // As the ward reads what's fixed: a value, or a function called for it.
1658
+ const fixed = wired[key as string]
1659
+ if (Predicate.isFunction(fixed)) return (fixed as () => unknown)()
1660
+ return fixed
1661
+ },
1662
+ })
1663
+ // Its `enter` and its `show`, looked for across the runes only where one of them gives it.
1664
+ let enter: unknown
1665
+ if ((seen & SEEN.enter) !== 0) enter = own("enter")
1666
+ const unentered = enter === false
1667
+ let show: Accessor<boolean> | undefined
1668
+ if ((seen & SEEN.show) !== 0) show = own("show") as Accessor<boolean> | undefined
1669
+ // One record, its `wired` said once its wiring is known: what reads it later reads this one.
1670
+ const self: { -readonly [K in keyof Joined]: Joined[K] } = { config: source as WardConfig, follow: undefined, show, value, own, has, unentered, variantChild: false, asRead }
1671
+ const wiring = shown(self)
1672
+ // No wiring of its own, and an entrance: what's fixed over it is what the runes beside the source
1673
+ // give, as it is. A ward of several runes with no `show`, most of them.
1674
+ if (Predicate.isUndefined(wiring) && !unentered) {
1675
+ self.wired = beside
1676
+ return self
1677
+ }
1678
+ self.wired = { ...beside, ...wiredOf(wiring, unentered, value, has) }
1679
+ return self
1680
+ }
1681
+
1682
+ /** What a `show`'s wiring gives a ward's `style`, where it gives one. */
1683
+ const styleOfShown = (shown: Shown): Shown["style"] => shown.style
1684
+
1685
+ /** `key` across `runes`, a later one winning, objects merged where the key takes them: how a ward's config reads a key that several runes give. */
1686
+ const acrossIn = (runes: ReadonlyArray<Loose>, key: string): unknown =>
1687
+ Arr.reduce(runes, undefined as unknown, (value, config) => {
1688
+ if (!(key in config)) return value
1689
+ return overIn(key, value, read(config, key))
1690
+ })
1691
+
1692
+ /** `next`, a later rune's `key`, over `value`, what the runes before it gave: variants and objects merged, else the later one's where it gives one. */
1693
+ const overIn = (key: string, value: unknown, next: unknown): unknown => {
1694
+ if (key === "variants") return mergeVariants(value, next)
1695
+ if (OBJECT_KEYS.has(key)) return mergeObjects(value, next)
1696
+ if (Predicate.isNotUndefined(next)) return next
1697
+ return value
1698
+ }
1699
+
1700
+ /**
1701
+ * `configs` as one ward's config. Each key is a getter that reads the runes' as the ward reads it, so
1702
+ * a rune's accessor or getter is tracked there, and nothing is read before the ward asks. `omitted`
1703
+ * are keys its ward doesn't take, though the hooks still read them: a Stage ward's `exit`.
1704
+ */
1705
+ export const joined = (configs: ReadonlyArray<RuneConfig>, shown: (runes: Joined) => Shown | undefined, omitted: ReadonlySet<string> = NONE_OMITTED): Joined => {
1706
+ const loose = configs as ReadonlyArray<Loose>
1707
+ const keys = new Set<string>(Arr.flatMap(loose, (config) => Object.keys(config)))
1708
+
1709
+ /** `key` across the runes, a later one winning, objects merged where the key takes them. */
1710
+ const across = (key: string): unknown => acrossIn(loose, key)
1711
+
1712
+ const follow = across("follow") as AnyWard | undefined
1713
+ const show = across("show") as Accessor<boolean> | undefined
1714
+ const following = Predicate.isNotUndefined(follow)
1715
+ // A follower that names a gesture of its own keeps the name, and is a Variant child by its own word (Q26).
1716
+ const variantChild = following && Arr.some(loose, namesGesture)
1717
+
1718
+ // A leader that names its states and has no `variants` needs none to be followed: every hook ward
1719
+ // carries its variants (`HOOK_TOLD`, the follow grill's Q1).
1720
+ const variants = (): unknown => variantsWithTiming(across("variants"))
1721
+ /** A target key's value: a follower's own names resolved against its variants, but a gesture's, which it keeps (Q26). */
1722
+ const target = (key: string): unknown => {
1723
+ const value = across(key)
1724
+ if (following && isLabels(value) && !isGestureKey(key)) return targetOf(value, variants(), across("custom"))
1725
+ return value
1726
+ }
1727
+
1728
+ const value = (key: string): unknown => {
1729
+ if (key === "variants") return variants()
1730
+ if (key === "transition") return withTiming(across("transition"), across("followers"))
1731
+ if (TARGET_KEYS.has(key)) return target(key)
1732
+ return across(key)
1733
+ }
1734
+
1735
+ const config: Record<string, unknown> = {}
1736
+ // No entrance: its Starting style is its `animate`, though its `initial` is still read above.
1737
+ const unentered = across("enter") === false
1738
+ const self: Joined = { config: config as WardConfig, follow, show, value, own: across, has: (key) => keys.has(key), unentered, variantChild, asRead: () => config }
1739
+ const wiring = shown(self)
1740
+ if (keys.has("followers")) keys.add("transition")
1741
+ if (unentered) keys.add("initial")
1742
+ const styled = UndefinedOr.map(wiring, styleOfShown)
1743
+ if (Predicate.isNotUndefined(wiring)) keys.add("animate")
1744
+ if (Predicate.isNotUndefined(styled)) keys.add("style")
1745
+ // The keys its wiring reads are read through it; every other, as the runes give it.
1746
+ const wired = wiredOf(wiring, unentered, value, self.has)
1747
+ Iter.forEach(keys, (key) => {
1748
+ if (OWN_KEYS.has(key)) return
1749
+ if (omitted.has(key)) return
1750
+ let get = (): unknown => value(key)
1751
+ if (Object.hasOwn(wired, key)) get = wired[key] as () => unknown
1752
+ Object.defineProperty(config, key, { get, enumerable: true })
1753
+ })
1754
+ return self
1755
+ }