@wardic/solid 2.1.2 → 3.0.0-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (530) hide show
  1. package/README.md +22 -18
  2. package/dist/browser/batch-reorder-places.js +3 -3
  3. package/dist/browser/batch-reorder.js +8 -5
  4. package/dist/browser/batch-reorder.js.map +1 -1
  5. package/dist/browser/config-view.js +33 -5
  6. package/dist/browser/config-view.js.map +1 -1
  7. package/dist/browser/create-animation-controls.js +22 -0
  8. package/dist/browser/create-animation-controls.js.map +1 -0
  9. package/dist/browser/create-batch.js +1 -1
  10. package/dist/browser/element-style.js +61 -7
  11. package/dist/browser/element-style.js.map +1 -1
  12. package/dist/browser/element.js +19 -2
  13. package/dist/browser/element.js.map +1 -1
  14. package/dist/browser/feature-section.js +5 -13
  15. package/dist/browser/feature-section.js.map +1 -1
  16. package/dist/browser/gesture-callbacks.js +3 -1
  17. package/dist/browser/gesture-callbacks.js.map +1 -1
  18. package/dist/browser/hooks/auto.js +270 -0
  19. package/dist/browser/hooks/auto.js.map +1 -0
  20. package/dist/browser/hooks/config-scope.js +120 -0
  21. package/dist/browser/hooks/config-scope.js.map +1 -0
  22. package/dist/browser/hooks/config.js +37 -0
  23. package/dist/browser/hooks/config.js.map +1 -0
  24. package/dist/browser/hooks/drag.js +632 -0
  25. package/dist/browser/hooks/drag.js.map +1 -0
  26. package/dist/browser/hooks/elements.js +183 -0
  27. package/dist/browser/hooks/elements.js.map +1 -0
  28. package/dist/browser/hooks/group.js +28 -0
  29. package/dist/browser/hooks/group.js.map +1 -0
  30. package/dist/browser/hooks/index.js +10 -0
  31. package/dist/browser/hooks/index.js.map +1 -0
  32. package/dist/browser/hooks/kept.js +32 -0
  33. package/dist/browser/hooks/kept.js.map +1 -0
  34. package/dist/browser/hooks/layout-group-of.js +39 -0
  35. package/dist/browser/hooks/layout-group-of.js.map +1 -0
  36. package/dist/browser/hooks/layout-group.js +92 -0
  37. package/dist/browser/hooks/layout-group.js.map +1 -0
  38. package/dist/browser/hooks/make-ward.js +157 -0
  39. package/dist/browser/hooks/make-ward.js.map +1 -0
  40. package/dist/browser/hooks/presence-scope.js +87 -0
  41. package/dist/browser/hooks/presence-scope.js.map +1 -0
  42. package/dist/browser/hooks/presence.js +24 -0
  43. package/dist/browser/hooks/presence.js.map +1 -0
  44. package/dist/browser/hooks/props.js +148 -0
  45. package/dist/browser/hooks/props.js.map +1 -0
  46. package/dist/browser/hooks/reads.js +241 -0
  47. package/dist/browser/hooks/reads.js.map +1 -0
  48. package/dist/browser/hooks/refs.js +87 -0
  49. package/dist/browser/hooks/refs.js.map +1 -0
  50. package/dist/browser/hooks/reorder-elements.js +268 -0
  51. package/dist/browser/hooks/reorder-elements.js.map +1 -0
  52. package/dist/browser/hooks/reorder.js +176 -0
  53. package/dist/browser/hooks/reorder.js.map +1 -0
  54. package/dist/browser/hooks/rune.js +799 -0
  55. package/dist/browser/hooks/rune.js.map +1 -0
  56. package/dist/browser/hooks/server-features.client.js +2 -0
  57. package/dist/browser/hooks/server-features.client.js.map +1 -0
  58. package/dist/browser/hooks/server-features.js +13 -0
  59. package/dist/browser/hooks/server-features.js.map +1 -0
  60. package/dist/browser/hooks/settings.js +29 -0
  61. package/dist/browser/hooks/settings.js.map +1 -0
  62. package/dist/browser/hooks/setup.js +154 -0
  63. package/dist/browser/hooks/setup.js.map +1 -0
  64. package/dist/browser/hooks/stage.js +117 -0
  65. package/dist/browser/hooks/stage.js.map +1 -0
  66. package/dist/browser/hooks/ward.js +2193 -0
  67. package/dist/browser/hooks/ward.js.map +1 -0
  68. package/dist/browser/hooks/wardic-provider.js +29 -0
  69. package/dist/browser/hooks/wardic-provider.js.map +1 -0
  70. package/dist/browser/hooks/wardic-scope.js +68 -0
  71. package/dist/browser/hooks/wardic-scope.js.map +1 -0
  72. package/dist/browser/hooks/wards.js +562 -0
  73. package/dist/browser/hooks/wards.js.map +1 -0
  74. package/dist/browser/index.js +24 -12
  75. package/dist/browser/index.js.map +1 -1
  76. package/dist/browser/layout.js +7 -58
  77. package/dist/browser/layout.js.map +1 -1
  78. package/dist/browser/lazy-batch-gestures.js +1 -1
  79. package/dist/browser/lifecycle.js +59 -13
  80. package/dist/browser/lifecycle.js.map +1 -1
  81. package/dist/browser/motion-props.js +1 -1
  82. package/dist/browser/presence-handle.js +28 -12
  83. package/dist/browser/presence-handle.js.map +1 -1
  84. package/dist/browser/presence.js +3 -1
  85. package/dist/browser/presence.js.map +1 -1
  86. package/dist/browser/provider.js +85 -70
  87. package/dist/browser/provider.js.map +1 -1
  88. package/dist/browser/reorder-components.js +50 -0
  89. package/dist/browser/reorder-components.js.map +1 -0
  90. package/dist/browser/reorder.js +46 -274
  91. package/dist/browser/reorder.js.map +1 -1
  92. package/dist/browser/stage-ward.js +2 -2
  93. package/dist/browser/stage-ward.js.map +1 -1
  94. package/dist/browser/stage.js.map +1 -1
  95. package/dist/browser/unstable/v2/index.js +0 -8
  96. package/dist/browser/unstable/v2/index.js.map +1 -1
  97. package/dist/browser/v1/batch-reorder-group.js +4 -4
  98. package/dist/browser/v1/create-ward.js +3 -3
  99. package/dist/browser/v1/create-ward.js.map +1 -1
  100. package/dist/browser/v1/index.js +1 -1
  101. package/dist/browser/v1/index.js.map +1 -1
  102. package/dist/browser/v1/presence.js +1 -1
  103. package/dist/browser/v1/presence.js.map +1 -1
  104. package/dist/browser/variant-node.js +4 -2
  105. package/dist/browser/variant-node.js.map +1 -1
  106. package/dist/browser/w.js +33 -3
  107. package/dist/browser/w.js.map +1 -1
  108. package/dist/browser/ward.js +579 -52
  109. package/dist/browser/ward.js.map +1 -1
  110. package/dist/browser/wardic-config.js +62 -29
  111. package/dist/browser/wardic-config.js.map +1 -1
  112. package/dist/browser/wardic-context.js +23 -0
  113. package/dist/browser/wardic-context.js.map +1 -0
  114. package/dist/browser/wardic.js +3 -0
  115. package/dist/browser/wardic.js.map +1 -1
  116. package/dist/server/batch-reorder-places.js +3 -3
  117. package/dist/server/batch-reorder.js +8 -5
  118. package/dist/server/batch-reorder.js.map +1 -1
  119. package/dist/server/config-view.js +33 -5
  120. package/dist/server/config-view.js.map +1 -1
  121. package/dist/server/create-animation-controls.js +22 -0
  122. package/dist/server/create-animation-controls.js.map +1 -0
  123. package/dist/server/create-batch.js +1 -1
  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 +19 -2
  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/gesture-callbacks.js +3 -1
  131. package/dist/server/gesture-callbacks.js.map +1 -1
  132. package/dist/server/hooks/auto.js +270 -0
  133. package/dist/server/hooks/auto.js.map +1 -0
  134. package/dist/server/hooks/config-scope.js +120 -0
  135. package/dist/server/hooks/config-scope.js.map +1 -0
  136. package/dist/server/hooks/config.js +37 -0
  137. package/dist/server/hooks/config.js.map +1 -0
  138. package/dist/server/hooks/drag.js +632 -0
  139. package/dist/server/hooks/drag.js.map +1 -0
  140. package/dist/server/hooks/elements.js +192 -0
  141. package/dist/server/hooks/elements.js.map +1 -0
  142. package/dist/server/hooks/group.js +28 -0
  143. package/dist/server/hooks/group.js.map +1 -0
  144. package/dist/server/hooks/index.js +10 -0
  145. package/dist/server/hooks/index.js.map +1 -0
  146. package/dist/server/hooks/kept.js +32 -0
  147. package/dist/server/hooks/kept.js.map +1 -0
  148. package/dist/server/hooks/layout-group-of.js +39 -0
  149. package/dist/server/hooks/layout-group-of.js.map +1 -0
  150. package/dist/server/hooks/layout-group.js +109 -0
  151. package/dist/server/hooks/layout-group.js.map +1 -0
  152. package/dist/server/hooks/make-ward.js +157 -0
  153. package/dist/server/hooks/make-ward.js.map +1 -0
  154. package/dist/server/hooks/presence-scope.js +86 -0
  155. package/dist/server/hooks/presence-scope.js.map +1 -0
  156. package/dist/server/hooks/presence.js +24 -0
  157. package/dist/server/hooks/presence.js.map +1 -0
  158. package/dist/server/hooks/props.js +148 -0
  159. package/dist/server/hooks/props.js.map +1 -0
  160. package/dist/server/hooks/reads.js +241 -0
  161. package/dist/server/hooks/reads.js.map +1 -0
  162. package/dist/server/hooks/refs.js +87 -0
  163. package/dist/server/hooks/refs.js.map +1 -0
  164. package/dist/server/hooks/reorder-elements.js +308 -0
  165. package/dist/server/hooks/reorder-elements.js.map +1 -0
  166. package/dist/server/hooks/reorder.js +176 -0
  167. package/dist/server/hooks/reorder.js.map +1 -0
  168. package/dist/server/hooks/rune.js +799 -0
  169. package/dist/server/hooks/rune.js.map +1 -0
  170. package/dist/server/hooks/server-features.client.js +2 -0
  171. package/dist/server/hooks/server-features.client.js.map +1 -0
  172. package/dist/server/hooks/server-features.js +13 -0
  173. package/dist/server/hooks/server-features.js.map +1 -0
  174. package/dist/server/hooks/settings.js +29 -0
  175. package/dist/server/hooks/settings.js.map +1 -0
  176. package/dist/server/hooks/setup.js +154 -0
  177. package/dist/server/hooks/setup.js.map +1 -0
  178. package/dist/server/hooks/stage.js +117 -0
  179. package/dist/server/hooks/stage.js.map +1 -0
  180. package/dist/server/hooks/ward.js +2193 -0
  181. package/dist/server/hooks/ward.js.map +1 -0
  182. package/dist/server/hooks/wardic-provider.js +29 -0
  183. package/dist/server/hooks/wardic-provider.js.map +1 -0
  184. package/dist/server/hooks/wardic-scope.js +68 -0
  185. package/dist/server/hooks/wardic-scope.js.map +1 -0
  186. package/dist/server/hooks/wards.js +562 -0
  187. package/dist/server/hooks/wards.js.map +1 -0
  188. package/dist/server/index.js +24 -12
  189. package/dist/server/index.js.map +1 -1
  190. package/dist/server/layout.js +7 -75
  191. package/dist/server/layout.js.map +1 -1
  192. package/dist/server/lazy-batch-gestures.js +1 -1
  193. package/dist/server/lifecycle.js +59 -13
  194. package/dist/server/lifecycle.js.map +1 -1
  195. package/dist/server/motion-props.js +1 -1
  196. package/dist/server/presence-handle.js +28 -12
  197. package/dist/server/presence-handle.js.map +1 -1
  198. package/dist/server/presence.js +3 -1
  199. package/dist/server/presence.js.map +1 -1
  200. package/dist/server/provider.js +86 -80
  201. package/dist/server/provider.js.map +1 -1
  202. package/dist/server/reorder-components.js +50 -0
  203. package/dist/server/reorder-components.js.map +1 -0
  204. package/dist/server/reorder.js +46 -344
  205. package/dist/server/reorder.js.map +1 -1
  206. package/dist/server/stage-ward.js +2 -2
  207. package/dist/server/stage-ward.js.map +1 -1
  208. package/dist/server/stage.js.map +1 -1
  209. package/dist/server/unstable/v2/index.js +0 -8
  210. package/dist/server/unstable/v2/index.js.map +1 -1
  211. package/dist/server/v1/batch-reorder-group.js +4 -4
  212. package/dist/server/v1/create-ward.js +3 -3
  213. package/dist/server/v1/create-ward.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/v1/presence.js +1 -1
  217. package/dist/server/v1/presence.js.map +1 -1
  218. package/dist/server/variant-node.js +4 -2
  219. package/dist/server/variant-node.js.map +1 -1
  220. package/dist/server/w.js +33 -3
  221. package/dist/server/w.js.map +1 -1
  222. package/dist/server/ward.js +579 -52
  223. package/dist/server/ward.js.map +1 -1
  224. package/dist/server/wardic-config.js +63 -30
  225. package/dist/server/wardic-config.js.map +1 -1
  226. package/dist/server/wardic-context.js +23 -0
  227. package/dist/server/wardic-context.js.map +1 -0
  228. package/dist/server/wardic.js +3 -0
  229. package/dist/server/wardic.js.map +1 -1
  230. package/dist/solid/batch-reorder-group.d.ts +1 -1
  231. package/dist/solid/batch-reorder-places.js +3 -3
  232. package/dist/solid/batch-reorder.d.ts +1 -1
  233. package/dist/solid/batch-reorder.d.ts.map +1 -1
  234. package/dist/solid/batch-reorder.js +8 -5
  235. package/dist/solid/batch-reorder.js.map +1 -1
  236. package/dist/solid/config-view.d.ts +11 -0
  237. package/dist/solid/config-view.d.ts.map +1 -1
  238. package/dist/solid/config-view.js +29 -6
  239. package/dist/solid/config-view.js.map +1 -1
  240. package/dist/solid/create-animation-controls.d.ts +20 -0
  241. package/dist/solid/create-animation-controls.d.ts.map +1 -0
  242. package/dist/solid/create-animation-controls.js +22 -0
  243. package/dist/solid/create-animation-controls.js.map +1 -0
  244. package/dist/solid/create-batch.jsx +1 -1
  245. package/dist/solid/element-style.d.ts +16 -2
  246. package/dist/solid/element-style.d.ts.map +1 -1
  247. package/dist/solid/element-style.js +61 -7
  248. package/dist/solid/element-style.js.map +1 -1
  249. package/dist/solid/element.d.ts +3 -1
  250. package/dist/solid/element.d.ts.map +1 -1
  251. package/dist/solid/element.jsx +21 -2
  252. package/dist/solid/element.jsx.map +1 -1
  253. package/dist/solid/feature-section.d.ts +0 -7
  254. package/dist/solid/feature-section.d.ts.map +1 -1
  255. package/dist/solid/feature-section.js +5 -13
  256. package/dist/solid/feature-section.js.map +1 -1
  257. package/dist/solid/gesture-callbacks.d.ts.map +1 -1
  258. package/dist/solid/gesture-callbacks.js +2 -0
  259. package/dist/solid/gesture-callbacks.js.map +1 -1
  260. package/dist/solid/hooks/auto.d.ts +44 -0
  261. package/dist/solid/hooks/auto.d.ts.map +1 -0
  262. package/dist/solid/hooks/auto.js +269 -0
  263. package/dist/solid/hooks/auto.js.map +1 -0
  264. package/dist/solid/hooks/config-scope.d.ts +84 -0
  265. package/dist/solid/hooks/config-scope.d.ts.map +1 -0
  266. package/dist/solid/hooks/config-scope.jsx +128 -0
  267. package/dist/solid/hooks/config-scope.jsx.map +1 -0
  268. package/dist/solid/hooks/config.d.ts +28 -0
  269. package/dist/solid/hooks/config.d.ts.map +1 -0
  270. package/dist/solid/hooks/config.jsx +37 -0
  271. package/dist/solid/hooks/config.jsx.map +1 -0
  272. package/dist/solid/hooks/drag.d.ts +220 -0
  273. package/dist/solid/hooks/drag.d.ts.map +1 -0
  274. package/dist/solid/hooks/drag.js +585 -0
  275. package/dist/solid/hooks/drag.js.map +1 -0
  276. package/dist/solid/hooks/elements.d.ts +11 -0
  277. package/dist/solid/hooks/elements.d.ts.map +1 -0
  278. package/dist/solid/hooks/elements.jsx +218 -0
  279. package/dist/solid/hooks/elements.jsx.map +1 -0
  280. package/dist/solid/hooks/group.d.ts +46 -0
  281. package/dist/solid/hooks/group.d.ts.map +1 -0
  282. package/dist/solid/hooks/group.jsx +25 -0
  283. package/dist/solid/hooks/group.jsx.map +1 -0
  284. package/dist/solid/hooks/index.d.ts +28 -0
  285. package/dist/solid/hooks/index.d.ts.map +1 -0
  286. package/dist/solid/hooks/index.js +10 -0
  287. package/dist/solid/hooks/index.js.map +1 -0
  288. package/dist/solid/hooks/kept.d.ts +60 -0
  289. package/dist/solid/hooks/kept.d.ts.map +1 -0
  290. package/dist/solid/hooks/kept.js +33 -0
  291. package/dist/solid/hooks/kept.js.map +1 -0
  292. package/dist/solid/hooks/layout-group-of.d.ts +27 -0
  293. package/dist/solid/hooks/layout-group-of.d.ts.map +1 -0
  294. package/dist/solid/hooks/layout-group-of.js +39 -0
  295. package/dist/solid/hooks/layout-group-of.js.map +1 -0
  296. package/dist/solid/hooks/layout-group.d.ts +60 -0
  297. package/dist/solid/hooks/layout-group.d.ts.map +1 -0
  298. package/dist/solid/hooks/layout-group.jsx +80 -0
  299. package/dist/solid/hooks/layout-group.jsx.map +1 -0
  300. package/dist/solid/hooks/make-ward.d.ts +123 -0
  301. package/dist/solid/hooks/make-ward.d.ts.map +1 -0
  302. package/dist/solid/hooks/make-ward.js +147 -0
  303. package/dist/solid/hooks/make-ward.js.map +1 -0
  304. package/dist/solid/hooks/presence-scope.d.ts +84 -0
  305. package/dist/solid/hooks/presence-scope.d.ts.map +1 -0
  306. package/dist/solid/hooks/presence-scope.jsx +62 -0
  307. package/dist/solid/hooks/presence-scope.jsx.map +1 -0
  308. package/dist/solid/hooks/presence.d.ts +51 -0
  309. package/dist/solid/hooks/presence.d.ts.map +1 -0
  310. package/dist/solid/hooks/presence.jsx +26 -0
  311. package/dist/solid/hooks/presence.jsx.map +1 -0
  312. package/dist/solid/hooks/props.d.ts +52 -0
  313. package/dist/solid/hooks/props.d.ts.map +1 -0
  314. package/dist/solid/hooks/props.js +140 -0
  315. package/dist/solid/hooks/props.js.map +1 -0
  316. package/dist/solid/hooks/reads.d.ts +38 -0
  317. package/dist/solid/hooks/reads.d.ts.map +1 -0
  318. package/dist/solid/hooks/reads.js +218 -0
  319. package/dist/solid/hooks/reads.js.map +1 -0
  320. package/dist/solid/hooks/refs.d.ts +25 -0
  321. package/dist/solid/hooks/refs.d.ts.map +1 -0
  322. package/dist/solid/hooks/refs.js +89 -0
  323. package/dist/solid/hooks/refs.js.map +1 -0
  324. package/dist/solid/hooks/reorder-elements.d.ts +23 -0
  325. package/dist/solid/hooks/reorder-elements.d.ts.map +1 -0
  326. package/dist/solid/hooks/reorder-elements.jsx +273 -0
  327. package/dist/solid/hooks/reorder-elements.jsx.map +1 -0
  328. package/dist/solid/hooks/reorder.d.ts +55 -0
  329. package/dist/solid/hooks/reorder.d.ts.map +1 -0
  330. package/dist/solid/hooks/reorder.js +152 -0
  331. package/dist/solid/hooks/reorder.js.map +1 -0
  332. package/dist/solid/hooks/rune.d.ts +885 -0
  333. package/dist/solid/hooks/rune.d.ts.map +1 -0
  334. package/dist/solid/hooks/rune.js +816 -0
  335. package/dist/solid/hooks/rune.js.map +1 -0
  336. package/dist/solid/hooks/server-features.client.d.ts +10 -0
  337. package/dist/solid/hooks/server-features.client.d.ts.map +1 -0
  338. package/dist/solid/hooks/server-features.client.js +2 -0
  339. package/dist/solid/hooks/server-features.client.js.map +1 -0
  340. package/dist/solid/hooks/server-features.d.ts +10 -0
  341. package/dist/solid/hooks/server-features.d.ts.map +1 -0
  342. package/dist/solid/hooks/server-features.js +13 -0
  343. package/dist/solid/hooks/server-features.js.map +1 -0
  344. package/dist/solid/hooks/settings.d.ts +11 -0
  345. package/dist/solid/hooks/settings.d.ts.map +1 -0
  346. package/dist/solid/hooks/settings.js +31 -0
  347. package/dist/solid/hooks/settings.js.map +1 -0
  348. package/dist/solid/hooks/setup.d.ts +31 -0
  349. package/dist/solid/hooks/setup.d.ts.map +1 -0
  350. package/dist/solid/hooks/setup.js +155 -0
  351. package/dist/solid/hooks/setup.js.map +1 -0
  352. package/dist/solid/hooks/stage.d.ts +187 -0
  353. package/dist/solid/hooks/stage.d.ts.map +1 -0
  354. package/dist/solid/hooks/stage.js +117 -0
  355. package/dist/solid/hooks/stage.js.map +1 -0
  356. package/dist/solid/hooks/ward.d.ts +394 -0
  357. package/dist/solid/hooks/ward.d.ts.map +1 -0
  358. package/dist/solid/hooks/ward.js +2237 -0
  359. package/dist/solid/hooks/ward.js.map +1 -0
  360. package/dist/solid/hooks/wardic-provider.d.ts +32 -0
  361. package/dist/solid/hooks/wardic-provider.d.ts.map +1 -0
  362. package/dist/solid/hooks/wardic-provider.jsx +29 -0
  363. package/dist/solid/hooks/wardic-provider.jsx.map +1 -0
  364. package/dist/solid/hooks/wardic-scope.d.ts +49 -0
  365. package/dist/solid/hooks/wardic-scope.d.ts.map +1 -0
  366. package/dist/solid/hooks/wardic-scope.jsx +63 -0
  367. package/dist/solid/hooks/wardic-scope.jsx.map +1 -0
  368. package/dist/solid/hooks/wards.d.ts +157 -0
  369. package/dist/solid/hooks/wards.d.ts.map +1 -0
  370. package/dist/solid/hooks/wards.js +522 -0
  371. package/dist/solid/hooks/wards.js.map +1 -0
  372. package/dist/solid/index.d.ts +25 -17
  373. package/dist/solid/index.d.ts.map +1 -1
  374. package/dist/solid/index.jsx +24 -12
  375. package/dist/solid/index.jsx.map +1 -1
  376. package/dist/solid/layout.d.ts +2 -44
  377. package/dist/solid/layout.d.ts.map +1 -1
  378. package/dist/solid/layout.jsx +7 -49
  379. package/dist/solid/layout.jsx.map +1 -1
  380. package/dist/solid/lazy-batch-gestures.js +1 -1
  381. package/dist/solid/lazy-batch-gestures.js.map +1 -1
  382. package/dist/solid/lifecycle.d.ts +32 -5
  383. package/dist/solid/lifecycle.d.ts.map +1 -1
  384. package/dist/solid/lifecycle.js +60 -21
  385. package/dist/solid/lifecycle.js.map +1 -1
  386. package/dist/solid/motion-props.js +1 -1
  387. package/dist/solid/presence-handle.d.ts +13 -6
  388. package/dist/solid/presence-handle.d.ts.map +1 -1
  389. package/dist/solid/presence-handle.js +30 -12
  390. package/dist/solid/presence-handle.js.map +1 -1
  391. package/dist/solid/presence.d.ts +3 -1
  392. package/dist/solid/presence.d.ts.map +1 -1
  393. package/dist/solid/presence.jsx +3 -1
  394. package/dist/solid/presence.jsx.map +1 -1
  395. package/dist/solid/provider.d.ts +25 -32
  396. package/dist/solid/provider.d.ts.map +1 -1
  397. package/dist/solid/provider.jsx +86 -62
  398. package/dist/solid/provider.jsx.map +1 -1
  399. package/dist/solid/reorder-components.d.ts +32 -0
  400. package/dist/solid/reorder-components.d.ts.map +1 -0
  401. package/dist/solid/reorder-components.jsx +49 -0
  402. package/dist/solid/reorder-components.jsx.map +1 -0
  403. package/dist/solid/reorder.d.ts +50 -76
  404. package/dist/solid/reorder.d.ts.map +1 -1
  405. package/dist/solid/reorder.jsx +40 -202
  406. package/dist/solid/reorder.jsx.map +1 -1
  407. package/dist/solid/stage-ward.jsx +2 -2
  408. package/dist/solid/stage-ward.jsx.map +1 -1
  409. package/dist/solid/stage.d.ts +14 -0
  410. package/dist/solid/stage.d.ts.map +1 -1
  411. package/dist/solid/stage.js.map +1 -1
  412. package/dist/solid/unstable/v2/index.d.ts +6 -26
  413. package/dist/solid/unstable/v2/index.d.ts.map +1 -1
  414. package/dist/solid/unstable/v2/index.jsx +0 -16
  415. package/dist/solid/unstable/v2/index.jsx.map +1 -1
  416. package/dist/solid/v1/batch-reorder-group.jsx +4 -4
  417. package/dist/solid/v1/create-ward.jsx +3 -3
  418. package/dist/solid/v1/create-ward.jsx.map +1 -1
  419. package/dist/solid/v1/index.d.ts +3 -1
  420. package/dist/solid/v1/index.d.ts.map +1 -1
  421. package/dist/solid/v1/index.jsx +1 -1
  422. package/dist/solid/v1/index.jsx.map +1 -1
  423. package/dist/solid/v1/presence.jsx +1 -1
  424. package/dist/solid/variant-node.d.ts +6 -0
  425. package/dist/solid/variant-node.d.ts.map +1 -1
  426. package/dist/solid/variant-node.js +2 -0
  427. package/dist/solid/variant-node.js.map +1 -1
  428. package/dist/solid/w.d.ts +9 -3
  429. package/dist/solid/w.d.ts.map +1 -1
  430. package/dist/solid/w.jsx +36 -3
  431. package/dist/solid/w.jsx.map +1 -1
  432. package/dist/solid/ward.d.ts +134 -7
  433. package/dist/solid/ward.d.ts.map +1 -1
  434. package/dist/solid/ward.jsx +549 -51
  435. package/dist/solid/ward.jsx.map +1 -1
  436. package/dist/solid/wardic-config.d.ts +17 -12
  437. package/dist/solid/wardic-config.d.ts.map +1 -1
  438. package/dist/solid/wardic-config.jsx +68 -22
  439. package/dist/solid/wardic-config.jsx.map +1 -1
  440. package/dist/solid/wardic-context.d.ts +15 -0
  441. package/dist/solid/wardic-context.d.ts.map +1 -0
  442. package/dist/solid/wardic-context.js +23 -0
  443. package/dist/solid/wardic-context.js.map +1 -0
  444. package/dist/solid/wardic-instance.d.ts +6 -4
  445. package/dist/solid/wardic-instance.d.ts.map +1 -1
  446. package/dist/solid/wardic.d.ts +3 -0
  447. package/dist/solid/wardic.d.ts.map +1 -1
  448. package/dist/solid/wardic.jsx +3 -0
  449. package/dist/solid/wardic.jsx.map +1 -1
  450. package/package.json +26 -6
  451. package/src/batch-reorder-group.tsx +1 -1
  452. package/src/batch-reorder-places.ts +3 -3
  453. package/src/batch-reorder.ts +9 -6
  454. package/src/config-view.ts +30 -6
  455. package/src/create-animation-controls.ts +22 -0
  456. package/src/create-batch.tsx +1 -1
  457. package/src/element-style.ts +77 -9
  458. package/src/element.tsx +25 -4
  459. package/src/feature-section.ts +5 -15
  460. package/src/gesture-callbacks.ts +2 -0
  461. package/src/hooks/auto.ts +303 -0
  462. package/src/hooks/config-scope.tsx +215 -0
  463. package/src/hooks/config.tsx +54 -0
  464. package/src/hooks/drag.ts +740 -0
  465. package/src/hooks/elements.tsx +234 -0
  466. package/src/hooks/group.tsx +55 -0
  467. package/src/hooks/index.ts +41 -0
  468. package/src/hooks/kept.ts +89 -0
  469. package/src/hooks/layout-group-of.ts +46 -0
  470. package/src/hooks/layout-group.tsx +111 -0
  471. package/src/hooks/make-ward.ts +218 -0
  472. package/src/hooks/presence-scope.tsx +155 -0
  473. package/src/hooks/presence.tsx +67 -0
  474. package/src/hooks/props.ts +190 -0
  475. package/src/hooks/reads.ts +258 -0
  476. package/src/hooks/refs.ts +114 -0
  477. package/src/hooks/reorder-elements.tsx +321 -0
  478. package/src/hooks/reorder.ts +205 -0
  479. package/src/hooks/rune.ts +1755 -0
  480. package/src/hooks/server-features.client.ts +10 -0
  481. package/src/hooks/server-features.ts +12 -0
  482. package/src/hooks/settings.ts +44 -0
  483. package/src/hooks/setup.ts +184 -0
  484. package/src/hooks/stage.ts +359 -0
  485. package/src/hooks/ward.ts +2563 -0
  486. package/src/hooks/wardic-provider.tsx +51 -0
  487. package/src/hooks/wardic-scope.tsx +112 -0
  488. package/src/hooks/wards.ts +679 -0
  489. package/src/index.tsx +31 -17
  490. package/src/layout.tsx +7 -74
  491. package/src/lazy-batch-gestures.ts +1 -1
  492. package/src/lifecycle.ts +72 -24
  493. package/src/motion-props.ts +1 -1
  494. package/src/presence-handle.ts +39 -20
  495. package/src/presence.tsx +3 -1
  496. package/src/provider.tsx +96 -71
  497. package/src/reorder-components.tsx +61 -0
  498. package/src/reorder.tsx +84 -303
  499. package/src/stage-ward.tsx +3 -3
  500. package/src/stage.ts +15 -0
  501. package/src/unstable/v2/index.tsx +6 -26
  502. package/src/v1/batch-reorder-group.tsx +4 -4
  503. package/src/v1/create-ward.tsx +4 -4
  504. package/src/v1/index.tsx +3 -1
  505. package/src/v1/presence.tsx +1 -1
  506. package/src/variant-node.ts +8 -0
  507. package/src/w.tsx +38 -5
  508. package/src/ward.tsx +679 -53
  509. package/src/wardic-config.tsx +68 -21
  510. package/src/wardic-context.ts +26 -0
  511. package/src/wardic-instance.ts +6 -4
  512. package/src/wardic.tsx +3 -0
  513. package/dist/browser/create-wardic.js +0 -36
  514. package/dist/browser/create-wardic.js.map +0 -1
  515. package/dist/browser/presence-hooks.js +0 -144
  516. package/dist/browser/presence-hooks.js.map +0 -1
  517. package/dist/server/create-wardic.js +0 -36
  518. package/dist/server/create-wardic.js.map +0 -1
  519. package/dist/server/presence-hooks.js +0 -144
  520. package/dist/server/presence-hooks.js.map +0 -1
  521. package/dist/solid/create-wardic.d.ts +0 -25
  522. package/dist/solid/create-wardic.d.ts.map +0 -1
  523. package/dist/solid/create-wardic.jsx +0 -34
  524. package/dist/solid/create-wardic.jsx.map +0 -1
  525. package/dist/solid/presence-hooks.d.ts +0 -53
  526. package/dist/solid/presence-hooks.d.ts.map +0 -1
  527. package/dist/solid/presence-hooks.jsx +0 -117
  528. package/dist/solid/presence-hooks.jsx.map +0 -1
  529. package/src/create-wardic.tsx +0 -46
  530. package/src/presence-hooks.tsx +0 -159
@@ -0,0 +1,10 @@
1
+ /**
2
+ * `#server-features` in a browser build (solid-next): no Feature. A client render never reads it, as
3
+ * `auto.ts` gives every Feature on a server alone; its own are each loaded the first time a ward asks
4
+ * for one. See `server-features.ts`.
5
+ *
6
+ * @module
7
+ */
8
+ import type * as Feature from "@wardic/dom/unstable/Feature"
9
+
10
+ export const ALL: ReadonlyArray<Feature.Feature> = []
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Every Feature, for a server render of the hooks (solid-next): what `#server-features` is in any build
3
+ * but a browser's (`package.json`'s `imports`). A browser build resolves it to
4
+ * `server-features.client.ts`, which has none, so no Feature is in a page's first chunk: each is a chunk of
5
+ * its own, fetched the first time a ward asks for it (`auto.ts`).
6
+ *
7
+ * @module
8
+ */
9
+ // A bundler that keeps a module a dead branch imports (Vite 8's Rolldown, where `isServer` folds after
10
+ // the chunks are made) put every Feature in the first chunk when `auto.ts` imported `features/All` itself:
11
+ // 133.5 KB gzip against 109.7 for the pack check's compiled fixture. Vite 6's Rollup drops it first.
12
+ export { ALL } from "@wardic/dom/unstable/features/All"
@@ -0,0 +1,44 @@
1
+ /**
2
+ * A hook ward's own config settings (probe: behaviour-runes, the scopes round's Q10): `reducedMotion`,
3
+ * `skipAnimations` and `transformPagePoint`, given by its runes, a config scope's among them, laid over
4
+ * the config around it as one core `WardicConfigValue`, which the base ward reads in that config's
5
+ * place (`WardInternals.wardicConfig`). Its `transition` is a ward's key already, read by its view.
6
+ *
7
+ * @module
8
+ */
9
+ import type * as ReducedMotion from "@wardic/core/ReducedMotion"
10
+ import type * as Config from "@wardic/core/unstable/Config"
11
+ import * as WardicConfigValue from "@wardic/core/unstable/WardicConfigValue"
12
+ import * as Arr from "effect/Array"
13
+ import * as Predicate from "effect/Predicate"
14
+
15
+ /** The keys a ward's own settings are given under. */
16
+ const SETTING_KEYS = ["reducedMotion", "skipAnimations", "transformPagePoint"] as const
17
+
18
+ /** Whether any of a ward's runes gives one of its own settings, asked of them by `has`. */
19
+ export const givesSettings = (has: (key: string) => boolean): boolean => Arr.some(SETTING_KEYS, has)
20
+
21
+ /** Whether one plain rune gives one of a ward's own settings. */
22
+ export const runeGivesSettings = (rune: object): boolean => Arr.some(SETTING_KEYS, (key) => key in rune)
23
+
24
+ const transitionOf = (parent: WardicConfigValue.WardicConfigValue | undefined): Config.WardicTransition | undefined => {
25
+ if (Predicate.isUndefined(parent)) return undefined
26
+ return parent.transition()
27
+ }
28
+
29
+ const isValidPropOf = (parent: WardicConfigValue.WardicConfigValue | undefined): ((key: string) => boolean) | undefined => {
30
+ if (Predicate.isUndefined(parent)) return undefined
31
+ return parent.isValidProp()
32
+ }
33
+
34
+ /**
35
+ * A ward's own settings, `value` of each as its runes join it now, laid over `parent`: each its own,
36
+ * else the config's around it, read where that config's would be.
37
+ */
38
+ export const settingsOver = (parent: WardicConfigValue.WardicConfigValue | undefined, value: (key: string) => unknown): WardicConfigValue.WardicConfigValue => ({
39
+ transition: () => transitionOf(parent),
40
+ reducedMotion: () => WardicConfigValue.configReducedMotionOf(value("reducedMotion") as ReducedMotion.Config | undefined, parent),
41
+ skipAnimations: () => WardicConfigValue.configSkipAnimationsOf(value("skipAnimations") as boolean | undefined, parent),
42
+ isValidProp: () => isValidPropOf(parent),
43
+ transformPagePoint: () => WardicConfigValue.configTransformPagePointOf(value("transformPagePoint") as Config.WardicTransformPoint | undefined, parent),
44
+ })
@@ -0,0 +1,184 @@
1
+ /**
2
+ * The page's context (probe: hooks-first): Wardic for a page with no `<WardicProvider>`. With nothing
3
+ * set up it is the DOM's Environment, `DomLive`, and every setting at its default; `makeWard` gives
4
+ * its own, with what the provider took: its `env`, and `strict`, `reducedMotion`, `appear`, `nonce` or
5
+ * `scaleCorrectors`. Every hook, `w.*` element and presence with no provider above it then
6
+ * runs on the page's one runtime, built the first time one of them asks and kept for the page's life.
7
+ * A provider above still wins, so a test or a second Environment keeps its own.
8
+ *
9
+ * On a server:
10
+ *
11
+ * - **Each render gets its own context**, keyed on the render's own hydration writer
12
+ * (`@solidjs/web`'s `getHydrationWriter`, one a render), so two requests never share their Appear
13
+ * animations' rules. A render with none (no hydration) plays no Appear animation.
14
+ * - **The head's `<style>` is registered where each ward is made.** A provider registers it once,
15
+ * at the shell, where it renders; a page with none has no such place, and the render's first ward
16
+ * may be under a `<Loading>` still waiting, whose head tags wait with it. So each owner that asks
17
+ * registers the same style, in `useHead`'s function form, and the first one the server writes gets
18
+ * it: the shell's own, when it has one, since the shell is written first.
19
+ *
20
+ * @module
21
+ */
22
+ import { getHydrationWriter, type HeadTag, isServer, useHead } from "@solidjs/web"
23
+ import * as WardicConfigValue from "@wardic/core/unstable/WardicConfigValue"
24
+ import { DomLive } from "@wardic/dom"
25
+ import type * as WardConfig from "@wardic/dom/unstable/WardConfig"
26
+ import * as Bool from "effect/Boolean"
27
+ import { constUndefined, constVoid } from "effect/Function"
28
+ import * as Predicate from "effect/Predicate"
29
+ import { DEV, getOwner } from "solid-js"
30
+ import { appearStyle, pageContextOf, setPageContext } from "../provider.tsx"
31
+ import { setPageConfig } from "../wardic-config.tsx"
32
+ import { type WardicContextValue, whenIdle } from "../runtime.ts"
33
+ import { warnWithoutSpans } from "../spans-check.ts"
34
+
35
+ /**
36
+ * A page's settings: `<WardicProvider>`'s props, without its children and its `features`, which a
37
+ * `makeWard`'s wards bring themselves.
38
+ */
39
+ export type PageOptions = Omit<Parameters<typeof pageContextOf>[0], "features">
40
+
41
+ /** One server render's context, and what registers its Appear `<style>` where it's asked from. */
42
+ interface Render {
43
+ readonly value: WardicContextValue
44
+ readonly register: () => void
45
+ }
46
+
47
+ const NO_TAGS: Array<HeadTag> = []
48
+
49
+ /** A server render's context: its Appear `<style>` registered by each owner that reads it, written once. */
50
+ const renderOf = (options: PageOptions): Render => {
51
+ const value = pageContextOf(options)
52
+ const appear = value.appear
53
+ if (Predicate.isUndefined(appear)) return { value, register: constVoid }
54
+ const style = appearStyle(() => appear.css(), options.nonce)
55
+ // Written by the first registration the server commits; the rest give nothing.
56
+ let written = false
57
+ const once = (): Array<HeadTag> => {
58
+ if (written) return NO_TAGS
59
+ written = true
60
+ return style()
61
+ }
62
+ let last: unknown
63
+ return {
64
+ value,
65
+ register: () => {
66
+ if (written) return
67
+ const owner = getOwner()
68
+ if (owner === last) return
69
+ last = owner
70
+ useHead(once)
71
+ },
72
+ }
73
+ }
74
+
75
+ // Module state (#460, Q7): whether the page has a context to fall back to, a `makeWard`'s or the default.
76
+ let set = false
77
+
78
+ /**
79
+ * A page's settings for its wards (probe: behaviour-runes, the scopes round's Q41), read where a
80
+ * `WardicConfig`'s are: the outermost config, under every one an app nests. `transition` and
81
+ * `skipAnimations` are a value or an accessor, read at each animation's start. `transformPagePoint` is
82
+ * the function itself, called at each drag or pan start, so it follows whatever it reads: an accessor
83
+ * of one would be a function too, and couldn't be told from it.
84
+ */
85
+ export interface PageConfigSettings {
86
+ /** The **Config transition** of every ward on the page that gives none of its own. */
87
+ readonly transition?: WardConfig.WardicVariantTransition | (() => WardConfig.WardicVariantTransition | undefined) | undefined
88
+ /** Every animation on the page lands at its end on the next frame: for end-to-end and visual tests. */
89
+ readonly skipAnimations?: boolean | (() => boolean | undefined) | undefined
90
+ /** Where the points a drag or a pan on the page uses are: handed each in the viewport's coordinates. */
91
+ readonly transformPagePoint?: WardConfig.WardicTransformPoint | undefined
92
+ }
93
+
94
+ const NO_CONFIG: PageConfigSettings = {}
95
+
96
+ /** A setting given as a value or an accessor, as it is now. */
97
+ const settingOf = <A>(given: A | (() => A | undefined) | undefined): A | undefined => {
98
+ if (Predicate.isFunction(given)) return (given as () => A | undefined)()
99
+ return given as A | undefined
100
+ }
101
+
102
+ /**
103
+ * The page's config out of its settings, each read at its use: none when none is given, so a page that
104
+ * sets none reads as it did. Its transition is worked out again only when what's given changes, so
105
+ * the wards on the page share one, as a `WardicConfig`'s memo has them do.
106
+ */
107
+ const pageConfigOf = (settings: PageConfigSettings): WardicConfigValue.WardicConfigValue | undefined => {
108
+ const given = Bool.or(Predicate.isNotUndefined(settings.transition), Bool.or(Predicate.isNotUndefined(settings.skipAnimations), Predicate.isNotUndefined(settings.transformPagePoint)))
109
+ if (Bool.not(given)) return undefined
110
+ let from: WardConfig.WardicVariantTransition | undefined
111
+ let made: ReturnType<typeof WardicConfigValue.configTransitionOf>
112
+ return {
113
+ transition: () => {
114
+ const now = settingOf(settings.transition)
115
+ if (now !== from) {
116
+ from = now
117
+ made = WardicConfigValue.configTransitionOf(now, undefined)
118
+ }
119
+ return made
120
+ },
121
+ reducedMotion: constUndefined,
122
+ skipAnimations: () => settingOf(settings.skipAnimations),
123
+ isValidProp: constUndefined,
124
+ transformPagePoint: () => settings.transformPagePoint,
125
+ }
126
+ }
127
+
128
+ /** Sets Wardic up for the page: its Environment and settings, with no provider to render. */
129
+ export const setupPage = (options: PageOptions, config: PageConfigSettings = NO_CONFIG): void => {
130
+ set = true
131
+ const value = pageConfigOf(config)
132
+ setPageConfig(() => value)
133
+ install(options)
134
+ }
135
+
136
+ /**
137
+ * The page's context when no `makeWard` gave one: the DOM's Environment, and every setting at its
138
+ * default. Called as the hooks' module loads, so a page that only imports `createWard` has nothing to
139
+ * set up; a `makeWard` after it gives its own.
140
+ */
141
+ export const setupDefaultPage = (): void => {
142
+ if (set) return
143
+ setupPage({ env: DomLive })
144
+ }
145
+
146
+ const install = (options: PageOptions): void => {
147
+ // A build-time flag in a plain `if`: a client build drops the server's half.
148
+ if (isServer) {
149
+ // Module state (#460, Q7): each render's context, held weakly by the render's writer.
150
+ const renders = new WeakMap<object, Render>()
151
+ let plain: WardicContextValue | undefined
152
+ setPageContext(() => {
153
+ const writer = getHydrationWriter()
154
+ if (Predicate.isUndefined(writer)) {
155
+ if (Predicate.isUndefined(plain)) plain = pageContextOf({ ...options, appear: false })
156
+ return plain
157
+ }
158
+ let render = renders.get(writer)
159
+ if (Predicate.isUndefined(render)) {
160
+ render = renderOf(options)
161
+ renders.set(writer, render)
162
+ }
163
+ render.register()
164
+ return render.value
165
+ })
166
+ return
167
+ }
168
+ let page: WardicContextValue | undefined
169
+ setPageContext(() => {
170
+ if (Predicate.isUndefined(page)) {
171
+ page = pageContextOf(options)
172
+ // A tracer that reads no Wardic span, development's word at the page as at a scope (the gap grill's
173
+ // Q45), at the browser's idle time once the page's first ward has asked. The page lives as long as
174
+ // the page: nothing cancels it.
175
+ if (DEV) warnAtIdle(page)
176
+ }
177
+ return page
178
+ })
179
+ }
180
+
181
+ /** Development's word on `value`'s tracer, at the browser's idle time. */
182
+ const warnAtIdle = (value: WardicContextValue): void => {
183
+ whenIdle(() => warnWithoutSpans(value.runtime))
184
+ }
@@ -0,0 +1,359 @@
1
+ /**
2
+ * The hooks over a Stage (probe: hooks-first): `createWard`, `createWards` and `createPresence` whose
3
+ * wards are a Stage's, on its Subjects, where the page's are on elements. What says the hooks aren't
4
+ * the DOM's alone: a second Environment gets the same hooks by handing them the thing that makes its
5
+ * wards. Nothing here is the page's: no element, no style, no Feature, no server render.
6
+ *
7
+ * const { createWard, createWards } = stageHooksOf(stage)
8
+ * const crate = createWard(mesh, lift, { animate: { x: 2 } })
9
+ *
10
+ * - **What carries over as it is:** runes and how they join, `show` with its exit and `mounted()`,
11
+ * `enter: false`, a list's rows kept until their exit lands, and one value at a time.
12
+ * - **A Subject is a rune's `subject`,** or given first. A row's is a function of the row, since each
13
+ * item has its own: `createWards(list, (row) => ({ subject: row.item.mesh }), config)`.
14
+ * - **What doesn't:** `follow` (a Stage's variants pass down its scene's graph, and its ward takes no
15
+ * parent), `pop` and hiding (the page's CSS), a function rune (`createRune(fn)`), and `props`
16
+ * (a Subject is its app's own object, with no markup to spread into: a rune's `ref` sets what it
17
+ * sets on one).
18
+ * - **Its types say which:** a Stage's rune is the keys of Wardic's its ward carries, its drag and its
19
+ * Subject ({@link StageRune}). A rune written for the page fits when every key it has is one of
20
+ * those; a key that isn't, a focus's or a view's or one of the page's own, is an error where the
21
+ * rune is given, as most are errors already when the ward is made.
22
+ * - **A target names what its Subject takes.** Its values are its Environment's, by their names,
23
+ * each with what it takes: a material's `roughness`, a light's `intensity`, and no element's
24
+ * `width`. An Environment's package says what each Subject takes (`StageTargetValues`, in the
25
+ * Stage's own types) and every name at once (`StageValues`). A ward given its Subject is checked
26
+ * by that Subject's own ({@link SubjectValues}): one that may be either of two kinds takes what
27
+ * both do, and one no Environment says anything of takes any name. A rune written alone may name
28
+ * what any Stage's Subject takes, and is checked again by the ward it's given to. An editor
29
+ * offers a ward's Subject's own names inside a target; in what a function of a row gives, every
30
+ * Stage's, though a name its row's Subject hasn't is still an error there.
31
+ * - **A presence takes runes here, not a ward.** A Stage's ward moves its Subject from the moment it's
32
+ * made, with no element to wait to be given, so one made only to be a pattern would move it too.
33
+ * - **A rune's `ref` is handed its Subject** while that's on show (`refs.ts`), as on the page: at
34
+ * once, the ward having it from the start, and again for each one an accessor gives.
35
+ *
36
+ * @module
37
+ */
38
+ import * as Predicate from "effect/Predicate"
39
+ import { type Accessor, createEffect } from "solid-js"
40
+ import type * as Config from "@wardic/core/unstable/Config"
41
+ import type { Stage, StageDragConfig, StageSubject, StageSubjectOf, StageTargetValues, StageValues, StageWardConfig } from "../stage.ts"
42
+ import type { Ward } from "../ward.tsx"
43
+ import {
44
+ type ApiFor,
45
+ type CarriedRune,
46
+ createRuneWith,
47
+ fixedRunes,
48
+ type FitRune,
49
+ type GivenRune,
50
+ isFunctionRune,
51
+ joined,
52
+ madeRune,
53
+ type MadeRune,
54
+ type Rune,
55
+ type RuneConfig,
56
+ type RuneRef,
57
+ type RunesGiven,
58
+ type RunesTaken,
59
+ type RuneWith,
60
+ type TransitionKey,
61
+ type WardicKeys,
62
+ } from "./rune.ts"
63
+ import { attending, runeRefsOf } from "./refs.ts"
64
+ import { type HookWard, type HookWardOf, showing, type ShowState, showState, type WardMaker, withMounted } from "./ward.ts"
65
+ import { hookWardsOf, oneAtATime, type RowRune, type RowRunesGiven, type RowWard, type StagePresenceSource, type WardsSource, type WardsValue } from "./wards.ts"
66
+
67
+ /** What of a Stage its hooks need: what makes its wards, and what tells a Subject from a rune. */
68
+ export type HookStage = Pick<Stage, "ward" | "isSubject">
69
+
70
+ /**
71
+ * Wardic's keys a Stage's ward carries: all but a focus's and a view's, which no scene tells of, and
72
+ * `follow` with `followers`, since a scene's variants pass down its graph. With a Stage's own they're
73
+ * the keys its ward takes (`stage-ward.tsx`'s), and the three the hooks read for it: `exit`, `show`
74
+ * and `enter`.
75
+ */
76
+ type CarriedKey = Exclude<keyof WardicKeys, "whileFocus" | "whileInView" | "follow" | "followers">
77
+
78
+ /**
79
+ * A Stage's own keys, beside Wardic's: a scene's drag and how that's set, in the page's place, with
80
+ * what its Environment adds to them (`@wardic/three/solid`'s `dragPlane`), and its Subject.
81
+ */
82
+ export interface StageKeys extends Pick<StageWardConfig, keyof StageDragConfig> {
83
+ /** The Subject it moves, or an accessor of it: a mesh, an object, what its Environment draws. */
84
+ readonly subject?: StageSubject | Accessor<StageSubject | undefined> | undefined
85
+ /** What this rune does to its Subject beside moving it (`RuneRef`): on a Stage, what its Environment draws. */
86
+ readonly ref?: RuneRef<StageSubject> | undefined
87
+ }
88
+
89
+ /** Each of a union's members, as one: `{ a } | { b }` as `{ a } & { b }`. */
90
+ type Intersected<U> = (U extends unknown ? (each: U) => void : never) extends (all: infer I) => void ? I : never
91
+
92
+ /** Any name at all: the values of a Subject nothing says anything of. */
93
+ type AnyValues = Readonly<Record<string, unknown>>
94
+
95
+ /** What the Environments say one kind of Subject takes in a target, as one (`StageTargetValues`). */
96
+ type Declared<S> = [keyof StageTargetValues<S>] extends [never] ? {} : Intersected<StageTargetValues<S>[keyof StageTargetValues<S>]>
97
+
98
+ /** One kind of Subject's values: what's said of it, and any name where nothing is. */
99
+ type KindValues<S> = [keyof Declared<S>] extends [never] ? AnyValues : Declared<S>
100
+
101
+ /** Each kind's values, of a Subject that may be one of several. */
102
+ type EachKind<S> = S extends unknown ? KindValues<S> : never
103
+
104
+ /** What each kind takes for one name, each held apart: a kind's own choice of two isn't taken apart with the kinds'. */
105
+ type HeldFor<S, Name extends PropertyKey> = S extends unknown ? readonly [KindValues<S>[Name & keyof KindValues<S>]] : never
106
+
107
+ /**
108
+ * What a Stage's Subject `S` takes in a target, by name: what its Environment says of it. Given a
109
+ * Subject that may be one of several kinds, only the names every kind takes, each with only what
110
+ * every kind takes for it: a ward moves whichever it's handed. Any name where no Environment says
111
+ * anything of it.
112
+ */
113
+ export type SubjectValues<S, Name extends PropertyKey = keyof EachKind<S>> = {
114
+ readonly [N in Name]: Intersected<HeldFor<S, N>> extends infer Every ? Every[0 & keyof Every] : never
115
+ }
116
+
117
+ /**
118
+ * Every name some Stage's Subject takes, each with what it takes (`StageValues`): what a rune
119
+ * written with no Subject may name. Any name where no Environment has said.
120
+ */
121
+ export type EveryStageValue = [keyof StageValues] extends [never] ? AnyValues : StageValues
122
+
123
+ /** A value, or an accessor of it: how a ward's config gives each key. */
124
+ type OrAccessor<T> = T | Accessor<T>
125
+
126
+ /** A target's values over `V`, what each name takes: each a value or its Keyframes. */
127
+ type TargetValues<V> = { readonly [K in keyof V]?: V[K] | Config.WardicKeyframes<Exclude<V[K], undefined>> }
128
+
129
+ /** An entry under any name: a transition's, for a Subject that takes any name. What's under one is checked where it's written (`rune.ts`'s `CheckedTransition`). */
130
+ type AnyEntry = { readonly [name: string]: unknown }
131
+
132
+ /**
133
+ * A transition with an entry for each of `V`'s names, and `default`. Not for a name that's one of a
134
+ * transition's own keys: an inertia has a `power`, as a three.js light has, and in a transition
135
+ * it's the inertia's. Where `V` is any name, any entry: typed as one for every name, it was one
136
+ * for a transition's own keys too.
137
+ */
138
+ type TransitionOver<V> = string extends keyof V
139
+ ? Config.WardicTransitionWith<{ readonly default?: Config.WardicValueTransition }> & AnyEntry
140
+ : Config.WardicTransitionWith<Config.WardicValueEntries<Exclude<keyof V & string, TransitionKey>>>
141
+
142
+ /** A target on a Stage, over the values `V`: each under its name, the transition it runs on, and its Transition end. */
143
+ export type StageTarget<V> = TargetValues<V> & {
144
+ readonly transition?: (TransitionOver<V> & Config.WardicInherit) | undefined
145
+ readonly transitionEnd?: { readonly [K in keyof V]?: V[K] } | undefined
146
+ }
147
+
148
+ /**
149
+ * One variant on a Stage: a target, or a function of `custom` that gives one, or another's name. As
150
+ * core's `WardicVariantResolver`, over a Stage's values.
151
+ */
152
+ // `custom` is `any` as core's and Motion's is: a resolver declares its own (`(angle: number) => …`).
153
+ export type StageVariant<V> = StageTarget<V> | ((custom: any, current: Readonly<Record<string, number | string>>, velocity: Readonly<Record<string, number>>) => StageTarget<V> | string)
154
+
155
+ /** A target, or the name of a variant, or a list of them. */
156
+ type TargetOrNames<V> = StageTarget<V> | Config.WardicVariantLabels
157
+
158
+ /**
159
+ * Wardic's keys that name values, as a Stage's ward takes them: each target's names are its
160
+ * Subject's, `V`, where the page's are an element's.
161
+ */
162
+ interface StageValued<V> {
163
+ readonly initial?: OrAccessor<TargetOrNames<V> | false | undefined> | undefined
164
+ readonly animate?: OrAccessor<TargetOrNames<V> | Config.WardicAnimationControls | undefined> | undefined
165
+ readonly exit?: OrAccessor<TargetOrNames<V> | undefined> | undefined
166
+ readonly whileHover?: OrAccessor<TargetOrNames<V> | undefined> | undefined
167
+ readonly whileTap?: OrAccessor<TargetOrNames<V> | undefined> | undefined
168
+ readonly whileDrag?: OrAccessor<TargetOrNames<V> | undefined> | undefined
169
+ readonly transition?: OrAccessor<TransitionOver<V> | undefined> | undefined
170
+ readonly variants?: Readonly<Record<string, StageVariant<V>>> | undefined
171
+ }
172
+
173
+ /**
174
+ * A rune's config on a Stage, over the values `V` its Subject takes: the keys of Wardic's its ward
175
+ * carries, those that name values typed by `V`, and a Stage's own.
176
+ */
177
+ export interface StageRuneWith<V> extends StageValued<V>, Pick<WardicKeys, Exclude<CarriedKey, keyof StageValued<unknown>>>, StageKeys {}
178
+
179
+ /** A rune's config on a Stage, written with no Subject: it may name what any Stage's Subject takes. */
180
+ export type StageRune = StageRuneWith<EveryStageValue>
181
+
182
+ /** What a function rune is told where a Stage's ward is given one, as its `createWard` throws for one. */
183
+ export type NoFunctionRune = "a function rune (`createRune(fn)`) isn't carried on a Stage"
184
+
185
+ /** What a ward on a Stage takes, over the values `V` its Subject does: a Stage's rune, and no function rune. */
186
+ interface OnAStageWith<V extends object, EveryName extends PropertyKey> extends RunesTaken {
187
+ readonly config: StageRuneWith<V>
188
+ readonly whose: "a ward on a Stage"
189
+ readonly functionRune: NoFunctionRune
190
+ readonly values: V
191
+ readonly everyName: EveryName
192
+ }
193
+
194
+ /** What a ward on a Stage takes where its Subject isn't known: a rune written alone, checked by every Stage's values. */
195
+ export type OnAStage = OnAStageWith<EveryStageValue, never>
196
+
197
+ /** Every Stage value's name, for telling one a Subject hasn't from one no Stage has; none where any name goes. */
198
+ type EveryStageName = string extends keyof EveryStageValue ? never : keyof EveryStageValue
199
+
200
+ /** What a ward on a Stage takes where its Subject is `S`: its runes checked by what `S` takes. */
201
+ export type OnAStageOf<S> = OnAStageWith<SubjectValues<S>, EveryStageName>
202
+
203
+ /**
204
+ * `createRune(config)` on a Stage: a rune of a Stage's keys, checked where it's written, its type the
205
+ * keys it has. It takes no function of its ward: a Stage's ward carries none.
206
+ */
207
+ export type StageRuneOf = <P extends object>(config: GivenRune<P, OnAStage>) => MadeRune<P, OnAStage>
208
+
209
+ /** The config itself, fixed once made, as the page's `createRune(config)` is: only its type is a Stage's. */
210
+ const stageRune = ((config: object): object => madeRune(config)) as StageRuneOf
211
+
212
+ /**
213
+ * `createRuneWith(rune, api)` on a Stage (the rune-with grill's Q14): a rune of a Stage's keys, checked where
214
+ * it's written, carrying an API, its members named like none of a Stage's rune keys. A config alone: a
215
+ * Stage's ward carries no function rune.
216
+ */
217
+ export type StageRuneWithApiOf = <P extends object, A extends object>(rune: GivenRune<P, OnAStage>, api: ApiFor<A, OnAStage>) => RuneWith<MadeRune<P, OnAStage>, A> & CarriedRune
218
+
219
+ /** The page's own: only its type is a Stage's. */
220
+ const stageRuneWithApi = createRuneWith as unknown as StageRuneWithApiOf
221
+
222
+ /**
223
+ * What a Stage's ward is given first: its Subject as it is, else a rune. Not an accessor of its
224
+ * Subject, which is a rune's `subject`: a Stage tells a Subject from a rune (`isSubject`), and a
225
+ * function is neither to it.
226
+ */
227
+ type SubjectOrFit<X, Taken extends RunesTaken> = X extends StageSubject ? X : FitRune<X, Taken>
228
+
229
+ /** The Subject a rune gives as its `subject`: itself, or what an accessor of it gives. None for a rune with no `subject`. */
230
+ type SubjectIn<X> = X extends { readonly subject: infer Given } ? NonNullable<StageSubjectOf<Given>> : never
231
+
232
+ /** The Subject a ward is given: first, as it is; else as one of its runes' `subject`. */
233
+ type SubjectGiven<A extends ReadonlyArray<unknown>> = A extends readonly [infer First, ...ReadonlyArray<unknown>]
234
+ ? First extends StageSubject
235
+ ? First
236
+ : { readonly [I in keyof A]: SubjectIn<A[I]> }[number]
237
+ : never
238
+
239
+ /** What a ward on a Stage takes, given its Subject: that Subject's values, and every Stage's where it has none in its types. */
240
+ type TakenBy<Subject> = [Subject] extends [never] ? OnAStage : OnAStageOf<Subject>
241
+
242
+ /**
243
+ * `createWard(subject, ...runes)` on a Stage: its Subject first, or as a rune's `subject`, so it's
244
+ * given one thing at least. One signature for both, so an error is the rune's own: with one overload
245
+ * for each, the checker told only the last one's, which blamed the Subject for a rune's key.
246
+ *
247
+ * What's given first is a type of its own, apart from the runes after it: an editor asked what a
248
+ * target may name knows the Subject by then, and offers that Subject's values. With the Subject and
249
+ * its runes one list, the list wasn't known until the rune being written was, and every Stage's
250
+ * values were offered for any Subject.
251
+ */
252
+ export type StageWardOf = <First extends object, Rest extends ReadonlyArray<object>>(
253
+ first: SubjectOrFit<First, TakenBy<SubjectGiven<readonly [First, ...Rest]>>>,
254
+ ...runes: RunesGiven<Rest, TakenBy<SubjectGiven<readonly [First, ...Rest]>>>
255
+ ) => HookWard
256
+
257
+ /**
258
+ * The Subject a list's rows are given: a rune's own `subject`, or the one in what a function of the
259
+ * row gives. None where neither says, and the rows take what any Stage's Subject does.
260
+ */
261
+ type RowSubject<A extends ReadonlyArray<unknown>> = { readonly [I in keyof A]: A[I] extends (...args: never) => infer Gives ? SubjectIn<Gives> : SubjectIn<A[I]> }[number]
262
+
263
+ /**
264
+ * `createWards(list, ...runes)` on a Stage: its rows' runes checked as its ward's are, key by key,
265
+ * and the values they name by their rows' Subject.
266
+ */
267
+ export type StageWardsOf = <T, A extends ReadonlyArray<unknown>>(
268
+ source: Accessor<ReadonlyArray<T>> | WardsSource<T> | WardsValue<T>,
269
+ ...runes: RowRunesGiven<T, A, TakenBy<RowSubject<A>>>
270
+ ) => Accessor<ReadonlyArray<RowWard<T>>>
271
+
272
+ /**
273
+ * `createPresence(value, ...runes)` on a Stage: the ward of the value there, the one leaving until it
274
+ * has gone. Its runes are a row's, checked as a list's are.
275
+ */
276
+ export type StagePresenceOf = <T, A extends ReadonlyArray<unknown>>(
277
+ source: Accessor<T> | StagePresenceSource<T>,
278
+ ...runes: RowRunesGiven<NonNullable<T>, A, TakenBy<RowSubject<A>>>
279
+ ) => Accessor<RowWard<NonNullable<T>> | undefined>
280
+
281
+ /** The keys a Stage's ward doesn't take, which the hooks read for it: where a `show` ward leaves to. */
282
+ const OMITTED: ReadonlySet<string> = new Set(["exit"])
283
+
284
+ const NO_SUBJECT = "createWard on a Stage: give it its Subject, first (`createWard(mesh, …)`) or as a rune's `subject`."
285
+ const NO_FOLLOW = "createWard on a Stage: `follow` isn't carried there. A Stage's variants pass down its scene's graph, to the ward nearest above a Subject."
286
+ const NO_FUNCTION_RUNE = "createWard on a Stage: a function rune (`createRune(fn)`) isn't carried there in this probe."
287
+ const NO_PROPS = "createWard on a Stage: `props` isn't carried there. A Stage's Subject is its app's own object, with nothing to spread into: a rune sets what it sets on one in its `ref`."
288
+ const NO_TAG = "createWard on a Stage: `tag` isn't carried there. It names the element a page's ward is spread on, and a Stage's Subject is no element."
289
+
290
+ /**
291
+ * A Stage ward's Subject while it's on show, followed: the one it was given, or what its accessor
292
+ * gives now, and none once its exit has landed. What its runes' `ref`s go by (`refs.ts`). A Subject
293
+ * is told from an accessor of one as the Stage's ward tells them, a function being an accessor.
294
+ */
295
+ const subjectOnShow =
296
+ (given: unknown, state: ShowState) =>
297
+ (): object | undefined => {
298
+ if (!state.mounted()) return undefined
299
+ if (Predicate.isFunction(given)) return (given as Accessor<object | undefined>)()
300
+ return given as object
301
+ }
302
+
303
+ /** `createWard(...runes)` over `stage`'s own ward, a rune's `subject` its Subject. */
304
+ const stageWardOf =
305
+ (stage: HookStage): WardMaker =>
306
+ (...written) => {
307
+ // Each rune fixed as the ward is made of it, as the page's are.
308
+ const runes = fixedRunes(written)
309
+ if (runes.some(isFunctionRune)) throw new Error(NO_FUNCTION_RUNE)
310
+ const state = showState()
311
+ // `show`'s wiring without the page's half: a Stage's Subject has no style to hide by.
312
+ const made = joined(
313
+ runes as ReadonlyArray<RuneConfig>,
314
+ (all) => {
315
+ const wiring = showing(state)(all)
316
+ if (Predicate.isUndefined(wiring)) return undefined
317
+ return { animate: wiring.animate }
318
+ },
319
+ OMITTED,
320
+ )
321
+ if (Predicate.isNotUndefined(made.follow)) throw new Error(NO_FOLLOW)
322
+ if (made.has("props")) throw new Error(NO_PROPS)
323
+ if (made.has("tag")) throw new Error(NO_TAG)
324
+ const subject = made.own("subject")
325
+ if (Predicate.isUndefined(subject)) throw new Error(NO_SUBJECT)
326
+ const ward = stage.ward(subject, made.config as StageWardConfig) as unknown as Ward
327
+ if (Predicate.isNotUndefined(made.show)) createEffect(ward.when("settled"), state.landed)
328
+ // Each rune's `ref`, handed its Subject while that's on show.
329
+ attending(runeRefsOf(runes), subjectOnShow(subject, state))
330
+ return withMounted(ward, state.mounted, state.shown)
331
+ }
332
+
333
+ /** The hooks whose wards are `stage`'s. */
334
+ export const stageHooksOf = (
335
+ stage: HookStage,
336
+ ): {
337
+ readonly createRune: StageRuneOf
338
+ readonly createRuneWith: StageRuneWithApiOf
339
+ readonly createWard: StageWardOf
340
+ readonly createWards: StageWardsOf
341
+ readonly createPresence: StagePresenceOf
342
+ } => {
343
+ const raw = stageWardOf(stage) as HookWardOf
344
+ // Its Subject first, as `ward(subject, config)` takes it: read as the rune that gives it. What's
345
+ // given after it are runes, a Stage's by their types, and joined as every rune is, by their keys.
346
+ const createWard = ((...given: ReadonlyArray<object>): HookWard => {
347
+ const [first, ...rest] = given
348
+ const runes = rest as ReadonlyArray<Rune>
349
+ if (stage.isSubject(first)) return raw({ subject: first }, ...runes)
350
+ return raw(first as Rune, ...runes)
351
+ }) as StageWardOf
352
+ // Its rows' runes are a Stage's by their types too: the list's own helpers join them by their keys.
353
+ const createPresence = <T>(source: Accessor<T> | StagePresenceSource<T>, ...runes: ReadonlyArray<unknown>): Accessor<RowWard<NonNullable<T>> | undefined> => {
354
+ const rows = oneAtATime(raw, source, runes as ReadonlyArray<RowRune<NonNullable<T>>>)
355
+ return () => rows()[0]
356
+ }
357
+ // The list's own hook, its rows' runes typed by their Subject where the page's are by the page.
358
+ return { createRune: stageRune, createRuneWith: stageRuneWithApi, createWard, createWards: hookWardsOf<OnAStage>(raw) as StageWardsOf, createPresence }
359
+ }