@wardic/solid 2.2.0 → 3.0.0-next.1

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