@fractal-io-technology/spec 0.0.0-stage → 2.2.2

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 (323) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +165 -2
  3. package/conformance/1.0/action-cases.json +227 -0
  4. package/conformance/1.0/bind-cases.json +768 -0
  5. package/conformance/1.0/cases.json +25139 -0
  6. package/conformance/1.0/layout/01-onboarding-start.json +95 -0
  7. package/conformance/1.0/layout/02-home-discover.json +177 -0
  8. package/conformance/1.0/layout/03-filters.json +186 -0
  9. package/conformance/1.0/layout/README.md +145 -0
  10. package/conformance/1.0/layout/REPORT.md +222 -0
  11. package/conformance/1.0/layout/alert.json +22 -0
  12. package/conformance/1.0/layout/iphone-14-15-pro-107.json +272 -0
  13. package/conformance/1.0/layout/live_status_on_its_way_4.ios.json +100 -0
  14. package/conformance/1.0/layout/lucy-booking-mobile.json +261 -0
  15. package/conformance/1.0/layout/lucy-booking-tablet.json +817 -0
  16. package/conformance/1.0/layout/lucy-booking.json +185 -0
  17. package/conformance/1.0/layout/lucy-header.json +84 -0
  18. package/conformance/1.0/layout/lucy-welcome-pin-mobile.json +31 -0
  19. package/conformance/1.0/layout/lucy-welcome-pin.json +31 -0
  20. package/conformance/1.0/layout/measured/android/01-onboarding-start.json +95 -0
  21. package/conformance/1.0/layout/measured/android/02-home-discover.json +177 -0
  22. package/conformance/1.0/layout/measured/android/03-filters.json +186 -0
  23. package/conformance/1.0/layout/measured/android/alert.json +22 -0
  24. package/conformance/1.0/layout/measured/android/iphone-14-15-pro-107.json +272 -0
  25. package/conformance/1.0/layout/measured/android/live_status_on_its_way_4.ios.json +100 -0
  26. package/conformance/1.0/layout/measured/android/lucy-booking-mobile.json +261 -0
  27. package/conformance/1.0/layout/measured/android/lucy-booking-tablet.json +817 -0
  28. package/conformance/1.0/layout/measured/android/lucy-booking.json +185 -0
  29. package/conformance/1.0/layout/measured/android/lucy-header.json +84 -0
  30. package/conformance/1.0/layout/measured/android/lucy-welcome-pin-mobile.json +31 -0
  31. package/conformance/1.0/layout/measured/android/lucy-welcome-pin.json +31 -0
  32. package/conformance/1.0/layout/measured/android/navigation-bar.json +46 -0
  33. package/conformance/1.0/layout/measured/android/probe-alert-banner-flutter.json +37 -0
  34. package/conformance/1.0/layout/measured/android/probe-alert-banner-regression-flutter.json +51 -0
  35. package/conformance/1.0/layout/measured/android/probe-alert-banner-stack-flutter.json +29 -0
  36. package/conformance/1.0/layout/measured/android/probe-card.json +35 -0
  37. package/conformance/1.0/layout/measured/android/probe-check-box-flutter.json +20 -0
  38. package/conformance/1.0/layout/measured/android/probe-container-height.json +21 -0
  39. package/conformance/1.0/layout/measured/android/probe-divider.json +55 -0
  40. package/conformance/1.0/layout/measured/android/probe-dropdown-menu-flutter.json +24 -0
  41. package/conformance/1.0/layout/measured/android/probe-dropdown-menu-max-lines.json +11 -0
  42. package/conformance/1.0/layout/measured/android/probe-expanded.json +31 -0
  43. package/conformance/1.0/layout/measured/android/probe-failed-decode.json +11 -0
  44. package/conformance/1.0/layout/measured/android/probe-flex.json +43 -0
  45. package/conformance/1.0/layout/measured/android/probe-grid-flutter.json +78 -0
  46. package/conformance/1.0/layout/measured/android/probe-grid.json +29 -0
  47. package/conformance/1.0/layout/measured/android/probe-icon-button-flutter.json +25 -0
  48. package/conformance/1.0/layout/measured/android/probe-icon-flutter.json +19 -0
  49. package/conformance/1.0/layout/measured/android/probe-icon-sizing.json +36 -0
  50. package/conformance/1.0/layout/measured/android/probe-image-flutter.json +24 -0
  51. package/conformance/1.0/layout/measured/android/probe-list-flutter.json +79 -0
  52. package/conformance/1.0/layout/measured/android/probe-list-regression-flutter.json +94 -0
  53. package/conformance/1.0/layout/measured/android/probe-list-row-flutter.json +86 -0
  54. package/conformance/1.0/layout/measured/android/probe-list-styles.json +45 -0
  55. package/conformance/1.0/layout/measured/android/probe-pin-input-parity.json +18 -0
  56. package/conformance/1.0/layout/measured/android/probe-progress-track-flutter.json +41 -0
  57. package/conformance/1.0/layout/measured/android/probe-progress-track-regression-flutter.json +57 -0
  58. package/conformance/1.0/layout/measured/android/probe-row-column.json +84 -0
  59. package/conformance/1.0/layout/measured/android/probe-scroll.json +54 -0
  60. package/conformance/1.0/layout/measured/android/probe-search-flutter.json +22 -0
  61. package/conformance/1.0/layout/measured/android/probe-size-constraints.json +20 -0
  62. package/conformance/1.0/layout/measured/android/probe-spacer.json +43 -0
  63. package/conformance/1.0/layout/measured/android/probe-stat-progress-track.json +14 -0
  64. package/conformance/1.0/layout/measured/android/probe-text-button-flutter.json +27 -0
  65. package/conformance/1.0/layout/measured/android/probe-text-field-flutter.json +28 -0
  66. package/conformance/1.0/layout/measured/android/probe-text.json +30 -0
  67. package/conformance/1.0/layout/measured/android/wallet-home.json +127 -0
  68. package/conformance/1.0/layout/measured/web/01-onboarding-start.json +95 -0
  69. package/conformance/1.0/layout/measured/web/02-home-discover.json +177 -0
  70. package/conformance/1.0/layout/measured/web/03-filters.json +186 -0
  71. package/conformance/1.0/layout/measured/web/alert.json +22 -0
  72. package/conformance/1.0/layout/measured/web/iphone-14-15-pro-107.json +272 -0
  73. package/conformance/1.0/layout/measured/web/live_status_on_its_way_4.ios.json +100 -0
  74. package/conformance/1.0/layout/measured/web/lucy-booking-mobile.json +261 -0
  75. package/conformance/1.0/layout/measured/web/lucy-booking-tablet.json +817 -0
  76. package/conformance/1.0/layout/measured/web/lucy-booking.json +185 -0
  77. package/conformance/1.0/layout/measured/web/lucy-header.json +84 -0
  78. package/conformance/1.0/layout/measured/web/lucy-welcome-pin-mobile.json +31 -0
  79. package/conformance/1.0/layout/measured/web/lucy-welcome-pin.json +31 -0
  80. package/conformance/1.0/layout/measured/web/navigation-bar.json +46 -0
  81. package/conformance/1.0/layout/measured/web/probe-alert-banner-flutter.json +37 -0
  82. package/conformance/1.0/layout/measured/web/probe-alert-banner-regression-flutter.json +51 -0
  83. package/conformance/1.0/layout/measured/web/probe-alert-banner-stack-flutter.json +29 -0
  84. package/conformance/1.0/layout/measured/web/probe-card.json +35 -0
  85. package/conformance/1.0/layout/measured/web/probe-check-box-flutter.json +20 -0
  86. package/conformance/1.0/layout/measured/web/probe-container-height.json +21 -0
  87. package/conformance/1.0/layout/measured/web/probe-divider.json +55 -0
  88. package/conformance/1.0/layout/measured/web/probe-dropdown-menu-flutter.json +24 -0
  89. package/conformance/1.0/layout/measured/web/probe-dropdown-menu-max-lines.json +11 -0
  90. package/conformance/1.0/layout/measured/web/probe-expanded.json +31 -0
  91. package/conformance/1.0/layout/measured/web/probe-failed-decode.json +15 -0
  92. package/conformance/1.0/layout/measured/web/probe-flex.json +43 -0
  93. package/conformance/1.0/layout/measured/web/probe-grid-flutter.json +78 -0
  94. package/conformance/1.0/layout/measured/web/probe-grid.json +29 -0
  95. package/conformance/1.0/layout/measured/web/probe-icon-button-flutter.json +25 -0
  96. package/conformance/1.0/layout/measured/web/probe-icon-flutter.json +19 -0
  97. package/conformance/1.0/layout/measured/web/probe-icon-sizing.json +36 -0
  98. package/conformance/1.0/layout/measured/web/probe-image-flutter.json +24 -0
  99. package/conformance/1.0/layout/measured/web/probe-list-flutter.json +79 -0
  100. package/conformance/1.0/layout/measured/web/probe-list-regression-flutter.json +94 -0
  101. package/conformance/1.0/layout/measured/web/probe-list-row-flutter.json +86 -0
  102. package/conformance/1.0/layout/measured/web/probe-list-styles.json +45 -0
  103. package/conformance/1.0/layout/measured/web/probe-pin-input-parity.json +18 -0
  104. package/conformance/1.0/layout/measured/web/probe-progress-track-flutter.json +41 -0
  105. package/conformance/1.0/layout/measured/web/probe-progress-track-regression-flutter.json +57 -0
  106. package/conformance/1.0/layout/measured/web/probe-row-column.json +84 -0
  107. package/conformance/1.0/layout/measured/web/probe-scroll.json +54 -0
  108. package/conformance/1.0/layout/measured/web/probe-search-flutter.json +22 -0
  109. package/conformance/1.0/layout/measured/web/probe-size-constraints.json +20 -0
  110. package/conformance/1.0/layout/measured/web/probe-spacer.json +43 -0
  111. package/conformance/1.0/layout/measured/web/probe-stat-progress-track.json +14 -0
  112. package/conformance/1.0/layout/measured/web/probe-text-button-flutter.json +27 -0
  113. package/conformance/1.0/layout/measured/web/probe-text-field-flutter.json +28 -0
  114. package/conformance/1.0/layout/measured/web/probe-text.json +30 -0
  115. package/conformance/1.0/layout/measured/web/wallet-home.json +127 -0
  116. package/conformance/1.0/layout/navigation-bar.json +46 -0
  117. package/conformance/1.0/layout/probe-alert-banner-flutter.json +37 -0
  118. package/conformance/1.0/layout/probe-alert-banner-regression-flutter.json +51 -0
  119. package/conformance/1.0/layout/probe-alert-banner-stack-flutter.json +29 -0
  120. package/conformance/1.0/layout/probe-card.json +35 -0
  121. package/conformance/1.0/layout/probe-check-box-flutter.json +20 -0
  122. package/conformance/1.0/layout/probe-container-height.json +21 -0
  123. package/conformance/1.0/layout/probe-divider.json +55 -0
  124. package/conformance/1.0/layout/probe-dropdown-menu-flutter.json +24 -0
  125. package/conformance/1.0/layout/probe-dropdown-menu-max-lines.json +11 -0
  126. package/conformance/1.0/layout/probe-expanded.json +31 -0
  127. package/conformance/1.0/layout/probe-failed-decode.json +13 -0
  128. package/conformance/1.0/layout/probe-flex.json +43 -0
  129. package/conformance/1.0/layout/probe-grid-flutter.json +78 -0
  130. package/conformance/1.0/layout/probe-grid.json +29 -0
  131. package/conformance/1.0/layout/probe-icon-button-flutter.json +25 -0
  132. package/conformance/1.0/layout/probe-icon-flutter.json +19 -0
  133. package/conformance/1.0/layout/probe-icon-sizing.json +36 -0
  134. package/conformance/1.0/layout/probe-image-flutter.json +24 -0
  135. package/conformance/1.0/layout/probe-list-flutter.json +79 -0
  136. package/conformance/1.0/layout/probe-list-regression-flutter.json +94 -0
  137. package/conformance/1.0/layout/probe-list-row-flutter.json +86 -0
  138. package/conformance/1.0/layout/probe-list-styles.json +45 -0
  139. package/conformance/1.0/layout/probe-pin-input-parity.json +18 -0
  140. package/conformance/1.0/layout/probe-progress-track-flutter.json +41 -0
  141. package/conformance/1.0/layout/probe-progress-track-regression-flutter.json +57 -0
  142. package/conformance/1.0/layout/probe-row-column.json +84 -0
  143. package/conformance/1.0/layout/probe-scroll.json +54 -0
  144. package/conformance/1.0/layout/probe-search-flutter.json +22 -0
  145. package/conformance/1.0/layout/probe-size-constraints.json +20 -0
  146. package/conformance/1.0/layout/probe-spacer.json +43 -0
  147. package/conformance/1.0/layout/probe-stat-progress-track.json +14 -0
  148. package/conformance/1.0/layout/probe-text-button-flutter.json +27 -0
  149. package/conformance/1.0/layout/probe-text-field-flutter.json +28 -0
  150. package/conformance/1.0/layout/probe-text.json +30 -0
  151. package/conformance/1.0/layout/probes/probe-alert-banner-flutter.json +296 -0
  152. package/conformance/1.0/layout/probes/probe-alert-banner-regression-flutter.json +1 -0
  153. package/conformance/1.0/layout/probes/probe-alert-banner-stack-flutter.json +219 -0
  154. package/conformance/1.0/layout/probes/probe-card.json +252 -0
  155. package/conformance/1.0/layout/probes/probe-check-box-flutter.json +86 -0
  156. package/conformance/1.0/layout/probes/probe-container-height.json +147 -0
  157. package/conformance/1.0/layout/probes/probe-divider.json +469 -0
  158. package/conformance/1.0/layout/probes/probe-dropdown-menu-flutter.json +293 -0
  159. package/conformance/1.0/layout/probes/probe-dropdown-menu-max-lines.json +54 -0
  160. package/conformance/1.0/layout/probes/probe-expanded.json +208 -0
  161. package/conformance/1.0/layout/probes/probe-failed-decode.json +96 -0
  162. package/conformance/1.0/layout/probes/probe-flex.json +353 -0
  163. package/conformance/1.0/layout/probes/probe-grid-flutter.json +584 -0
  164. package/conformance/1.0/layout/probes/probe-grid.json +209 -0
  165. package/conformance/1.0/layout/probes/probe-icon-button-flutter.json +143 -0
  166. package/conformance/1.0/layout/probes/probe-icon-flutter.json +89 -0
  167. package/conformance/1.0/layout/probes/probe-icon-sizing.json +219 -0
  168. package/conformance/1.0/layout/probes/probe-image-flutter.json +130 -0
  169. package/conformance/1.0/layout/probes/probe-list-flutter.json +732 -0
  170. package/conformance/1.0/layout/probes/probe-list-regression-flutter.json +815 -0
  171. package/conformance/1.0/layout/probes/probe-list-row-flutter.json +734 -0
  172. package/conformance/1.0/layout/probes/probe-list-styles.json +332 -0
  173. package/conformance/1.0/layout/probes/probe-pin-input-parity.json +87 -0
  174. package/conformance/1.0/layout/probes/probe-progress-track-flutter.json +298 -0
  175. package/conformance/1.0/layout/probes/probe-progress-track-regression-flutter.json +525 -0
  176. package/conformance/1.0/layout/probes/probe-row-column.json +784 -0
  177. package/conformance/1.0/layout/probes/probe-scroll.json +378 -0
  178. package/conformance/1.0/layout/probes/probe-search-flutter.json +138 -0
  179. package/conformance/1.0/layout/probes/probe-size-constraints.json +157 -0
  180. package/conformance/1.0/layout/probes/probe-spacer.json +291 -0
  181. package/conformance/1.0/layout/probes/probe-stat-progress-track.json +87 -0
  182. package/conformance/1.0/layout/probes/probe-text-button-flutter.json +163 -0
  183. package/conformance/1.0/layout/probes/probe-text-field-flutter.json +170 -0
  184. package/conformance/1.0/layout/probes/probe-text.json +202 -0
  185. package/conformance/1.0/layout/report/01-onboarding-start.md +49 -0
  186. package/conformance/1.0/layout/report/02-home-discover.md +98 -0
  187. package/conformance/1.0/layout/report/03-filters.md +85 -0
  188. package/conformance/1.0/layout/report/alert.md +27 -0
  189. package/conformance/1.0/layout/report/iphone-14-15-pro-107.md +47 -0
  190. package/conformance/1.0/layout/report/live_status_on_its_way_4.ios.md +60 -0
  191. package/conformance/1.0/layout/report/lucy-booking-mobile.md +81 -0
  192. package/conformance/1.0/layout/report/lucy-booking-tablet.md +279 -0
  193. package/conformance/1.0/layout/report/lucy-booking.md +117 -0
  194. package/conformance/1.0/layout/report/lucy-header.md +64 -0
  195. package/conformance/1.0/layout/report/lucy-welcome-pin-mobile.md +15 -0
  196. package/conformance/1.0/layout/report/lucy-welcome-pin.md +11 -0
  197. package/conformance/1.0/layout/report/navigation-bar.md +23 -0
  198. package/conformance/1.0/layout/report/probe-alert-banner-flutter.md +11 -0
  199. package/conformance/1.0/layout/report/probe-alert-banner-regression-flutter.md +27 -0
  200. package/conformance/1.0/layout/report/probe-alert-banner-stack-flutter.md +11 -0
  201. package/conformance/1.0/layout/report/probe-card.md +11 -0
  202. package/conformance/1.0/layout/report/probe-check-box-flutter.md +17 -0
  203. package/conformance/1.0/layout/report/probe-divider.md +11 -0
  204. package/conformance/1.0/layout/report/probe-dropdown-menu-flutter.md +15 -0
  205. package/conformance/1.0/layout/report/probe-dropdown-menu-max-lines.md +15 -0
  206. package/conformance/1.0/layout/report/probe-flex.md +23 -0
  207. package/conformance/1.0/layout/report/probe-grid-flutter.md +11 -0
  208. package/conformance/1.0/layout/report/probe-icon-button-flutter.md +11 -0
  209. package/conformance/1.0/layout/report/probe-icon-flutter.md +11 -0
  210. package/conformance/1.0/layout/report/probe-image-flutter.md +11 -0
  211. package/conformance/1.0/layout/report/probe-list-flutter.md +11 -0
  212. package/conformance/1.0/layout/report/probe-list-regression-flutter.md +27 -0
  213. package/conformance/1.0/layout/report/probe-list-row-flutter.md +11 -0
  214. package/conformance/1.0/layout/report/probe-pin-input-parity.md +11 -0
  215. package/conformance/1.0/layout/report/probe-progress-track-flutter.md +11 -0
  216. package/conformance/1.0/layout/report/probe-progress-track-regression-flutter.md +20 -0
  217. package/conformance/1.0/layout/report/probe-row-column.md +20 -0
  218. package/conformance/1.0/layout/report/probe-scroll.md +11 -0
  219. package/conformance/1.0/layout/report/probe-search-flutter.md +11 -0
  220. package/conformance/1.0/layout/report/probe-spacer.md +11 -0
  221. package/conformance/1.0/layout/report/probe-text-button-flutter.md +22 -0
  222. package/conformance/1.0/layout/report/probe-text-field-flutter.md +11 -0
  223. package/conformance/1.0/layout/report/probe-text.md +31 -0
  224. package/conformance/1.0/layout/report/wallet-home.md +35 -0
  225. package/conformance/1.0/layout/tolerance.json +12 -0
  226. package/conformance/1.0/layout/wallet-home.json +127 -0
  227. package/conformance/1.0/response-cases.json +228 -0
  228. package/conformance/1.0/screen-cases.json +198 -0
  229. package/conformance/1.0/screens/01-onboarding-start.json +994 -0
  230. package/conformance/1.0/screens/02-home-discover.json +2165 -0
  231. package/conformance/1.0/screens/03-filters.json +2290 -0
  232. package/conformance/1.0/screens/alert.json +231 -0
  233. package/conformance/1.0/screens/iphone-14-15-pro-107.json +3149 -0
  234. package/conformance/1.0/screens/live_status_on_its_way_4.ios.json +1313 -0
  235. package/conformance/1.0/screens/lucy-booking-mobile.json +3063 -0
  236. package/conformance/1.0/screens/lucy-booking-tablet.json +10371 -0
  237. package/conformance/1.0/screens/lucy-booking.json +2130 -0
  238. package/conformance/1.0/screens/lucy-header.json +1201 -0
  239. package/conformance/1.0/screens/lucy-welcome-pin-mobile.json +417 -0
  240. package/conformance/1.0/screens/lucy-welcome-pin.json +409 -0
  241. package/conformance/1.0/screens/navigation-bar.json +542 -0
  242. package/conformance/1.0/screens/wallet-home.json +1585 -0
  243. package/dist/action.d.ts +10616 -0
  244. package/dist/action.d.ts.map +1 -0
  245. package/dist/action.js +92 -0
  246. package/dist/action.js.map +1 -0
  247. package/dist/bind.d.ts +32 -0
  248. package/dist/bind.d.ts.map +1 -0
  249. package/dist/bind.js +102 -0
  250. package/dist/bind.js.map +1 -0
  251. package/dist/block-ref.d.ts +17 -0
  252. package/dist/block-ref.d.ts.map +1 -0
  253. package/dist/block-ref.js +17 -0
  254. package/dist/block-ref.js.map +1 -0
  255. package/dist/block-types.d.ts +26 -0
  256. package/dist/block-types.d.ts.map +1 -0
  257. package/dist/block-types.js +39 -0
  258. package/dist/block-types.js.map +1 -0
  259. package/dist/block.d.ts +20908 -0
  260. package/dist/block.d.ts.map +1 -0
  261. package/dist/block.js +81 -0
  262. package/dist/block.js.map +1 -0
  263. package/dist/blocks/display.d.ts +1915 -0
  264. package/dist/blocks/display.d.ts.map +1 -0
  265. package/dist/blocks/display.js +433 -0
  266. package/dist/blocks/display.js.map +1 -0
  267. package/dist/blocks/input.d.ts +7148 -0
  268. package/dist/blocks/input.d.ts.map +1 -0
  269. package/dist/blocks/input.js +855 -0
  270. package/dist/blocks/input.js.map +1 -0
  271. package/dist/blocks/layout.d.ts +2482 -0
  272. package/dist/blocks/layout.d.ts.map +1 -0
  273. package/dist/blocks/layout.js +266 -0
  274. package/dist/blocks/layout.js.map +1 -0
  275. package/dist/blocks/list.d.ts +980 -0
  276. package/dist/blocks/list.d.ts.map +1 -0
  277. package/dist/blocks/list.js +286 -0
  278. package/dist/blocks/list.js.map +1 -0
  279. package/dist/common.d.ts +958 -0
  280. package/dist/common.d.ts.map +1 -0
  281. package/dist/common.js +108 -0
  282. package/dist/common.js.map +1 -0
  283. package/dist/deprecated.d.ts +11 -0
  284. package/dist/deprecated.d.ts.map +1 -0
  285. package/dist/deprecated.js +26 -0
  286. package/dist/deprecated.js.map +1 -0
  287. package/dist/index.d.ts +20 -0
  288. package/dist/index.d.ts.map +1 -0
  289. package/dist/index.js +15 -0
  290. package/dist/index.js.map +1 -0
  291. package/dist/layout.d.ts +103 -0
  292. package/dist/layout.d.ts.map +1 -0
  293. package/dist/layout.js +113 -0
  294. package/dist/layout.js.map +1 -0
  295. package/dist/properties.d.ts +787 -0
  296. package/dist/properties.d.ts.map +1 -0
  297. package/dist/properties.js +447 -0
  298. package/dist/properties.js.map +1 -0
  299. package/dist/screen.d.ts +10494 -0
  300. package/dist/screen.d.ts.map +1 -0
  301. package/dist/screen.js +32 -0
  302. package/dist/screen.js.map +1 -0
  303. package/package.json +57 -4
  304. package/schema/1.0/action.json +109 -0
  305. package/schema/1.0/block.json +5886 -0
  306. package/schema/1.0/response.json +91 -0
  307. package/schema/1.0/screen.json +22 -0
  308. package/src/README.md +135 -0
  309. package/src/action.ts +119 -0
  310. package/src/bind.ts +114 -0
  311. package/src/block-ref.ts +18 -0
  312. package/src/block-types.ts +55 -0
  313. package/src/block.ts +116 -0
  314. package/src/blocks/display.ts +543 -0
  315. package/src/blocks/input.ts +1031 -0
  316. package/src/blocks/layout.ts +322 -0
  317. package/src/blocks/list.ts +355 -0
  318. package/src/common.ts +133 -0
  319. package/src/deprecated.ts +40 -0
  320. package/src/index.ts +31 -0
  321. package/src/layout.ts +194 -0
  322. package/src/properties.ts +516 -0
  323. package/src/screen.ts +39 -0
@@ -0,0 +1,91 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "urn:fractal-io:schema:response:1.0",
4
+ "title": "Fractal IO response",
5
+ "description": "A response of protocol version 1.x: what a backend returns for an action message. Other top-level keys are transport data, not protocol; backends may send them and renderers ignore them.",
6
+ "type": "object",
7
+ "required": [
8
+ "fractal",
9
+ "messages"
10
+ ],
11
+ "properties": {
12
+ "fractal": {
13
+ "description": "Protocol version the backend speaks, as MAJOR.MINOR. A renderer rejects a response whose major version it does not support and accepts a higher minor of a supported major.",
14
+ "type": "string",
15
+ "pattern": "^1\\.(0|[1-9][0-9]*)$"
16
+ },
17
+ "messages": {
18
+ "description": "What the backend answers to the action: at least one message. Each message is an object with exactly one of the keys `screen`, `navigate` or `error`.",
19
+ "minItems": 1,
20
+ "type": "array",
21
+ "items": {
22
+ "anyOf": [
23
+ {
24
+ "type": "object",
25
+ "properties": {
26
+ "screen": {
27
+ "description": "A whole screen document, built by the backend, that the renderer draws.",
28
+ "$ref": "urn:fractal-io:schema:screen:1.0"
29
+ }
30
+ },
31
+ "required": [
32
+ "screen"
33
+ ],
34
+ "additionalProperties": false
35
+ },
36
+ {
37
+ "type": "object",
38
+ "properties": {
39
+ "navigate": {
40
+ "type": "object",
41
+ "properties": {
42
+ "screen_id": {
43
+ "type": "string",
44
+ "description": "Identifier of the screen to open, chosen by the backend."
45
+ }
46
+ },
47
+ "required": [
48
+ "screen_id"
49
+ ],
50
+ "additionalProperties": false,
51
+ "description": "Tells the renderer to open another screen."
52
+ }
53
+ },
54
+ "required": [
55
+ "navigate"
56
+ ],
57
+ "additionalProperties": false
58
+ },
59
+ {
60
+ "type": "object",
61
+ "properties": {
62
+ "error": {
63
+ "type": "object",
64
+ "properties": {
65
+ "code": {
66
+ "type": "string",
67
+ "description": "Machine-readable identifier of the failure, defined by the backend (for example `sold_out`)."
68
+ },
69
+ "message": {
70
+ "type": "string",
71
+ "description": "Human-readable explanation of the failure, written by the backend."
72
+ }
73
+ },
74
+ "required": [
75
+ "code",
76
+ "message"
77
+ ],
78
+ "additionalProperties": false,
79
+ "description": "Tells the renderer that the backend could not carry out the action."
80
+ }
81
+ },
82
+ "required": [
83
+ "error"
84
+ ],
85
+ "additionalProperties": false
86
+ }
87
+ ]
88
+ }
89
+ }
90
+ }
91
+ }
@@ -0,0 +1,22 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "urn:fractal-io:schema:screen:1.0",
4
+ "title": "Fractal IO screen",
5
+ "description": "A screen document of protocol version 1.x: the protocol version it speaks and its root block. Other top-level keys (for example status, statusCode, message, meta) are transport data, not protocol; producers may send them and receivers ignore them.",
6
+ "type": "object",
7
+ "required": [
8
+ "fractal",
9
+ "data"
10
+ ],
11
+ "properties": {
12
+ "fractal": {
13
+ "description": "Protocol version as MAJOR.MINOR. A receiver rejects a screen whose major version it does not support and accepts a higher minor of a supported major.",
14
+ "type": "string",
15
+ "pattern": "^1\\.(0|[1-9][0-9]*)$"
16
+ },
17
+ "data": {
18
+ "description": "The root block of the screen.",
19
+ "$ref": "urn:fractal-io:schema:block:1.0"
20
+ }
21
+ }
22
+ }
package/src/README.md ADDED
@@ -0,0 +1,135 @@
1
+ # Zod contract
2
+
3
+ The Fractal IO protocol, written as Zod schemas: the 26 block types, their
4
+ `data` payloads, nested blocks and the screen document. `schema/<version>/*.json`
5
+ is generated from these files (`npm run schema`); see the repository README for
6
+ how a change flows. Every schema carries a comment naming the Swift file it
7
+ mirrors.
8
+
9
+ Always import through `index.ts`. The block schemas are mutually recursive, so
10
+ the modules form an import cycle that only resolves when evaluation starts at
11
+ `block.ts` (see `block-ref.ts`). The contract uses only what JSON Schema can
12
+ express: no `.refine`, `.transform`, `.pipe` or `z.custom`
13
+ (`scripts/check-contract.ts` enforces it). The one exception is a refine that
14
+ carries its JSON Schema twin in its own metadata (`.meta({ not: ... })`, which
15
+ `npm run schema` exports), so both say the same: `grid` rejects `columns`
16
+ together with `max_cross_axis_extent` that way (Flutter `GridView.count` vs
17
+ `GridView.extent`), and `text_field.config` rejects `max_lines` / `min_lines` with
18
+ `expands` and a multi-line `is_password` field (Flutter `TextField` asserts), and
19
+ `check_box` rejects a null `is_checked` without `tristate` (Flutter `Checkbox`
20
+ asserts `tristate || value != null`), and `list_row` rejects `is_three_line`
21
+ without a `subtitle_block` (Flutter `ListTile` asserts
22
+ `isThreeLine != true || subtitle != null`); the
23
+ conformance suite checks both verdicts agree.
24
+
25
+ ## Layout
26
+
27
+ | File | Contents |
28
+ | --- | --- |
29
+ | `block-types.ts` | `IOS_BLOCK_TYPES` (26 names, registration order), `IosBlockType`, `IosBlockNode` |
30
+ | `properties.ts` | Color, alignment, size, padding, gradient, overlay, shadow, border, text style, events |
31
+ | `common.ts` | Shapes shared by blocks: common properties, `id`/`events`, `child`, `children` |
32
+ | `blocks/layout.ts` | container, padding, expanded, spacer, single_child_scroll, card, divider, column, row, grid |
33
+ | `blocks/display.ts` | text, icon, icon_button, image, alert_banner, stat_progress_track |
34
+ | `blocks/input.ts` | text_button, text_field, dropdown_menu, pin_input, check_box, search |
35
+ | `blocks/list.ts` | list, list_section, list_row |
36
+ | `block-ref.ts`, `block.ts` | Lazy recursion point and the discriminated union over the 26 types |
37
+ | `screen.ts` | `FRACTAL_PROTOCOL_VERSION`, `fractalVersionSchema` and the screen document `screenSchema` (`{ fractal, data }`, open) |
38
+ | `index.ts` | The package entry point; always import through it |
39
+
40
+ ## Conventions
41
+
42
+ - JSON keys are snake_case, the names from the Swift `CodingKeys`.
43
+ - `decodeIfPresent` and Swift optionals are `.optional()`. Fields that iOS
44
+ decodes with a default (for example `alert_banner.regular_text`) are optional too.
45
+ - Swift `Double` is a number; Swift `Int` (`columns`, `max_lines`, shadow `x`/`y`)
46
+ is an integer.
47
+ - `divider` extends `FIOCoreGenericBlockData` directly: it does not accept
48
+ `id`, `events` or any other common key.
49
+ - `child` and `children` hold full `{ type, data }` blocks. `children` is
50
+ required (it may be empty) on column, row, grid, list and list_section;
51
+ `child` is optional. `list_row` has four optional block slots:
52
+ `start_block`, `title_block`, `subtitle_block`, `end_block`.
53
+ - `GestureDetector` exists in the Swift sources but is not registered, so it is
54
+ not part of the contract.
55
+
56
+ ## Neutral vocabulary
57
+
58
+ The wire names are platform neutral; the old iOS-shaped names were removed with no
59
+ aliases, so a screen that still uses them fails validation:
60
+
61
+ - Horizontal direction is `start` / `end` (never `left` / `right` / `leading` /
62
+ `trailing`). It follows the layout direction.
63
+ - Alignment (`alignment_geometry`, layout-size `alignment`, text `alignment`,
64
+ gradient `start` / `end`, `background_image.anchor`) is one 9-value type:
65
+ `top_start`, `top_center`, `top_end`, `center_start`, `center`, `center_end`,
66
+ `bottom_start`, `bottom_center`, `bottom_end`.
67
+ - Stack `alignment` (the cross axis of `row`, `column`, `grid` and the list family) is
68
+ `start`, `center` or `end`; `row` and `column` (Flutter `CrossAxisAlignment`, 2.0) also
69
+ take `stretch` and `baseline`. `text_alignment` (Flutter `TextAlign`, 2.0) is `start`,
70
+ `center`, `end`, `left`, `right` or `justify`: `start` / `end` follow the text direction,
71
+ `left` / `right` are absolute (an exception to the rule above).
72
+ - Every padding list (`padding`, `margin`, `list_row.content_padding`,
73
+ `text_field.decoration.content_padding`) uses the anchors `top`, `bottom`,
74
+ `start`, `end` and `all`.
75
+ - `list_row` slots are `start_block` / `end_block` with `start_dimension` /
76
+ `end_dimension`.
77
+ - A gradient lists its colors in `stops` only; a stop without `location` is placed
78
+ at `i / (n - 1)` by its index (a single stop at 0).
79
+ - A color is `{ "color": "#RRGGBB", "alpha": 0..1 }`: transparency never goes in
80
+ the hex, so `#RGB`, `#RGBA` and `#RRGGBBAA` are rejected.
81
+ - Font weights are snake_case (`ultra_light`, `semi_bold`, ...), with no `normal`;
82
+ `icon` / `icon_button` take the weight in `font_weight` (Flutter `Icon.weight`).
83
+ - `icon` (Flutter `Icon`, 2.0) defaults `icon_size` to 24 and `color` to the M3
84
+ `ThemeData.iconTheme` color (`#000000` at alpha 0xDD); `shadows` reuses the text
85
+ `Shadow` schema. Its common keys, `id` and `events` are deprecated and ignored.
86
+ - `icon_button` (Flutter `IconButton` / `.filled` / `.filledTonal` / `.outlined`, 2.0) takes
87
+ the `icon` glyph keys (`icon_size` default 24) plus `variant` (`standard`, `filled`,
88
+ `filled_tonal`, `outlined`), `constraints` (the `container` schema; default min 40 × 40),
89
+ `corner_radii`, `is_selected`, `selected_system_name`, `disabled_color`, `tooltip`,
90
+ `tap_target_size` (`padded` default, `shrink_wrap`) and `visual_density` (`standard`
91
+ default, `comfortable`, `compact`). `padding` defaults to all 8, `shape` to `capsule`;
92
+ `size` is Flutter `fixedSize`. `foreground_color`, `margin`, `gradient`, `fixed_size`,
93
+ `background_image` and `background_overlays` are deprecated and ignored.
94
+ - `text_button` (Flutter `TextButton` / `TextButton.icon` and the M3 `FilledButton`,
95
+ `FilledButton.tonal`, `ElevatedButton`, `OutlinedButton`, 2.0) gains `variant` (`text`
96
+ default, `filled`, `filled_tonal`, `elevated`, `outlined`), `overlay_color`, `elevation`,
97
+ `shadow_color`, `border`, `corner_radii`, `minimum_size` (default 64 × 40), `maximum_size`
98
+ (default unbounded), `tap_target_size` (`padded` default), `visual_density`, `icon` (the
99
+ `icon` glyph keys; size 18, gap 8), `icon_alignment` (`start` default, `end`) and
100
+ `clip_behavior` (`none` default). `shape` defaults to `capsule`, `style` to M3 `labelLarge`;
101
+ `padding` defaults by variant (text 12 / 8, others 24 / 0); `size` is Flutter `fixedSize`;
102
+ `gradient` is kept as an extension. `fixed_size`, `margin`, `background_image` and
103
+ `background_overlays` are deprecated and ignored.
104
+
105
+ ## Strict, not loose
106
+
107
+ Every block object is `z.strictObject`, including the `{ type, data }` wrapper.
108
+ The screen document is the exception: it is open, because its other top-level
109
+ keys are transport data. The iOS decoders ignore unknown keys and silently replace a block that
110
+ fails to decode with an empty one, so a typo (`corner_radiu`) would render
111
+ wrong with no error. Failing at validation time is the point. The 17 sample
112
+ screens use no key outside the Swift `CodingKeys`, so nothing is lost.
113
+
114
+ The same reasoning narrows a few fields below what Swift accepts:
115
+
116
+ - Free `String` fields that a view model only acts on in a closed set are enums:
117
+ `distribution`, image and background `content_mode`, `list_row.content_alignment`
118
+ and padding `anchor`.
119
+ - Enums that iOS resolves to a default for unknown strings (blend mode, keyboard
120
+ type, ...) reject unknown values.
121
+ - Values iOS clamps or traps on are range-checked: `alpha`, `opacity`,
122
+ `fill_fraction` (0...1), `grid.columns` and `pin_input.length` (at least 1),
123
+ `icon.icon_size` and `icon_button.icon_size` (at least 0), `text_button.elevation`,
124
+ `minimum_size` and `maximum_size` (at least 0).
125
+ - JSON `null` is rejected, except for `id`. iOS treats a null as absent, but
126
+ the real screens only emit `"id": null`, so only that key tolerates it.
127
+
128
+
129
+ ## Adding or changing a block
130
+
131
+ 1. Read the block's `*DataBlock.swift` and the Swift classes it inherits from.
132
+ 2. Add its name to `IOS_BLOCK_TYPES` and its schema to the right `blocks/*.ts` file.
133
+ 3. Register it in `iosBlockDataSchemas` and the union in `block.ts`. TypeScript
134
+ fails if the record and the type list disagree.
135
+ 4. Run `npm run schema`, add conformance cases and run `npm run check`.
package/src/action.ts ADDED
@@ -0,0 +1,119 @@
1
+ import { z } from "zod";
2
+ import { eventDataValueSchema, eventTypeSchema } from "./properties.ts";
3
+ import { fractalVersionSchema, screenSchema } from "./screen.ts";
4
+
5
+ /**
6
+ * An instant in ISO 8601, always in UTC: `YYYY-MM-DDTHH:MM:SSZ` with optional
7
+ * fractional seconds (`2026-11-17T03:45:00Z`, `2026-11-17T03:45:00.123Z`). An
8
+ * offset (`+00:00`) or a missing `Z` is invalid. Written as a pattern, not as a
9
+ * JSON Schema `format`, so every validator enforces it.
10
+ */
11
+ const utcTimestampSchema = z
12
+ .string()
13
+ .regex(
14
+ /^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])T([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](\.[0-9]+)?Z$/,
15
+ 'Expected an ISO 8601 UTC date-time ending in "Z", such as "2026-11-17T03:45:00Z"',
16
+ );
17
+
18
+ /** What happened on the renderer: the event that fired and the state it fired in. */
19
+ const actionSchema = z.strictObject({
20
+ name: z
21
+ .string()
22
+ .min(1)
23
+ .describe("The action the backend handles. The renderer copies it from the `event_id` of the block event that fired."),
24
+ screen_id: z
25
+ .string()
26
+ .optional()
27
+ .describe("Identifier of the screen the event fired on, supplied by the renderer when it knows one. A screen document carries no id, so the key is optional."),
28
+ source_block_id: z
29
+ .string()
30
+ .optional()
31
+ .describe("The `id` of the block whose event fired. Absent when that block has no `id`."),
32
+ event_type: eventTypeSchema.describe(
33
+ "The gesture or change that fired the event. The renderer copies it from the `event_type` of the block event.",
34
+ ),
35
+ timestamp: utcTimestampSchema.describe(
36
+ "When the event fired, read from the renderer's clock: ISO 8601 in UTC, ending in `Z`, with optional fractional seconds.",
37
+ ),
38
+ context: z
39
+ .record(z.string(), eventDataValueSchema)
40
+ .optional()
41
+ .describe("The `event_data` of the block event that fired, unchanged. Absent when the event has no `event_data`."),
42
+ values: z
43
+ .record(z.string(), eventDataValueSchema)
44
+ .optional()
45
+ .describe(
46
+ "The current value of every input block that has an `id`, keyed by that `id`, read from the screen when the event fires.",
47
+ ),
48
+ });
49
+
50
+ /**
51
+ * An action message: what a renderer posts to the backend when a block event
52
+ * fires. Like the screen document, every other top-level key is transport
53
+ * data, so the object is open; `action` itself is closed.
54
+ */
55
+ export const actionMessageSchema = z
56
+ .looseObject({
57
+ fractal: fractalVersionSchema.describe(
58
+ "Protocol version the renderer speaks, as MAJOR.MINOR. A backend rejects an action message whose major version it does not support and accepts a higher minor of a supported major.",
59
+ ),
60
+ action: actionSchema.describe("The event that fired and the state of the screen it fired on."),
61
+ })
62
+ .meta({
63
+ title: "Fractal IO action message",
64
+ description:
65
+ "An action message of protocol version 1.x: what a renderer posts to the backend when a block event fires. Other top-level keys are transport data, not protocol; renderers may send them and backends ignore them.",
66
+ });
67
+
68
+ export type ActionMessage = z.infer<typeof actionMessageSchema>;
69
+
70
+ /** Replaces what the renderer shows with a new screen. */
71
+ const screenMessageSchema = z.strictObject({
72
+ screen: screenSchema.describe("A whole screen document, built by the backend, that the renderer draws."),
73
+ });
74
+
75
+ /** Sends the renderer to another screen. */
76
+ const navigateMessageSchema = z.strictObject({
77
+ navigate: z
78
+ .strictObject({
79
+ screen_id: z
80
+ .string()
81
+ .describe("Identifier of the screen to open, chosen by the backend."),
82
+ })
83
+ .describe("Tells the renderer to open another screen."),
84
+ });
85
+
86
+ /** Reports that the backend could not carry out the action. */
87
+ const errorMessageSchema = z.strictObject({
88
+ error: z
89
+ .strictObject({
90
+ code: z.string().describe("Machine-readable identifier of the failure, defined by the backend (for example `sold_out`)."),
91
+ message: z.string().describe("Human-readable explanation of the failure, written by the backend."),
92
+ })
93
+ .describe("Tells the renderer that the backend could not carry out the action."),
94
+ });
95
+
96
+ /**
97
+ * A response: what the backend returns for an action message. It carries one
98
+ * or more messages, each of exactly one kind. Like the screen document, every
99
+ * other top-level key is transport data, so the object is open.
100
+ */
101
+ export const responseSchema = z
102
+ .looseObject({
103
+ fractal: fractalVersionSchema.describe(
104
+ "Protocol version the backend speaks, as MAJOR.MINOR. A renderer rejects a response whose major version it does not support and accepts a higher minor of a supported major.",
105
+ ),
106
+ messages: z
107
+ .array(z.union([screenMessageSchema, navigateMessageSchema, errorMessageSchema]))
108
+ .min(1)
109
+ .describe(
110
+ "What the backend answers to the action: at least one message. Each message is an object with exactly one of the keys `screen`, `navigate` or `error`.",
111
+ ),
112
+ })
113
+ .meta({
114
+ title: "Fractal IO response",
115
+ description:
116
+ "A response of protocol version 1.x: what a backend returns for an action message. Other top-level keys are transport data, not protocol; backends may send them and renderers ignore them.",
117
+ });
118
+
119
+ export type ResponseDocument = z.infer<typeof responseSchema>;
package/src/bind.ts ADDED
@@ -0,0 +1,114 @@
1
+ /**
2
+ * Binding: how a template becomes a screen document.
3
+ *
4
+ * A template is a screen document in which any value, at any depth, may be a
5
+ * binding: an object whose only key is `$bind` and whose value is a string, the
6
+ * path of a value in the data. There is no separate template schema; a template
7
+ * is judged by what it resolves to.
8
+ *
9
+ * `resolve(template, data)`:
10
+ *
11
+ * 1. Replaces every binding with the value at its path, unchanged (no coercion,
12
+ * no default). The inserted value is not scanned for bindings again.
13
+ * 2. Fails with `BIND_PATH_NOT_FOUND` when a path does not lead to a value.
14
+ * 3. Fails with `BIND_TYPE_MISMATCH` when the substituted document is not a
15
+ * valid screen document (`screen.json`).
16
+ *
17
+ * A path is one or more segments separated by `.`. On an object a segment is an
18
+ * own key; on an array it is an index in canonical decimal form (`0`, `12`).
19
+ * Anything else, an inherited key or a step through a scalar or `null`, does not
20
+ * lead to a value. A key that contains `.` cannot be addressed.
21
+ *
22
+ * An object that has `$bind` next to other keys, or whose `$bind` is not a
23
+ * string, is not a binding and is left as it is.
24
+ *
25
+ * `conformance/<version>/bind-cases.json` pins these rules for every
26
+ * implementation; this file is the reference one.
27
+ */
28
+ import { screenSchema } from "./screen.ts";
29
+ import type { Screen } from "./screen.ts";
30
+
31
+ export const BIND_KEY = "$bind";
32
+
33
+ export const BIND_ERROR_CODES = ["BIND_PATH_NOT_FOUND", "BIND_TYPE_MISMATCH"] as const;
34
+ export type BindErrorCode = (typeof BIND_ERROR_CODES)[number];
35
+
36
+ export interface BindError {
37
+ code: BindErrorCode;
38
+ message: string;
39
+ /** The `$bind` path that did not lead to a value (`BIND_PATH_NOT_FOUND` only). */
40
+ bind_path?: string;
41
+ }
42
+
43
+ export type SubstituteResult = { ok: true; document: unknown } | { ok: false; error: BindError };
44
+ export type ResolveResult = { ok: true; screen: Screen } | { ok: false; error: BindError };
45
+
46
+ const ARRAY_INDEX = /^(0|[1-9][0-9]*)$/;
47
+ const NOT_FOUND = Symbol("not found");
48
+
49
+ function isRecord(value: unknown): value is Record<string, unknown> {
50
+ return typeof value === "object" && value !== null && !Array.isArray(value);
51
+ }
52
+
53
+ function bindPathOf(value: unknown): string | undefined {
54
+ if (!isRecord(value)) return undefined;
55
+ const keys = Object.keys(value);
56
+ const path = value[BIND_KEY];
57
+ return keys.length === 1 && keys[0] === BIND_KEY && typeof path === "string" ? path : undefined;
58
+ }
59
+
60
+ function lookup(data: unknown, path: string): unknown {
61
+ let current = data;
62
+ for (const segment of path.split(".")) {
63
+ if (Array.isArray(current)) {
64
+ if (!ARRAY_INDEX.test(segment) || Number(segment) >= current.length) return NOT_FOUND;
65
+ current = current[Number(segment)];
66
+ } else if (isRecord(current) && Object.hasOwn(current, segment)) {
67
+ current = current[segment];
68
+ } else {
69
+ return NOT_FOUND;
70
+ }
71
+ }
72
+ return current;
73
+ }
74
+
75
+ /**
76
+ * Step 1 and 2 of `resolve`: replaces every binding of `template` with its value
77
+ * in `data`, without validating the result. Neither argument is modified.
78
+ */
79
+ export function substituteBindings(template: unknown, data: unknown): SubstituteResult {
80
+ let error: BindError | undefined;
81
+
82
+ const walk = (node: unknown): unknown => {
83
+ if (error) return node;
84
+ const path = bindPathOf(node);
85
+ if (path !== undefined) {
86
+ const value = lookup(data, path);
87
+ if (value === NOT_FOUND) {
88
+ error = { code: "BIND_PATH_NOT_FOUND", message: `No value at "${path}" in the data.`, bind_path: path };
89
+ return node;
90
+ }
91
+ return structuredClone(value);
92
+ }
93
+ if (Array.isArray(node)) return node.map(walk);
94
+ if (isRecord(node)) return Object.fromEntries(Object.entries(node).map(([key, value]) => [key, walk(value)]));
95
+ return node;
96
+ };
97
+
98
+ const document = walk(template);
99
+ return error ? { ok: false, error } : { ok: true, document };
100
+ }
101
+
102
+ /** Turns a template and its data into a screen document, or fails with a bind error. */
103
+ export function resolve(template: unknown, data: unknown): ResolveResult {
104
+ const substituted = substituteBindings(template, data);
105
+ if (!substituted.ok) return substituted;
106
+ const parsed = screenSchema.safeParse(substituted.document);
107
+ if (parsed.success) return { ok: true, screen: parsed.data };
108
+ const [issue] = parsed.error.issues;
109
+ const at = issue?.path.join("/") || "/";
110
+ return {
111
+ ok: false,
112
+ error: { code: "BIND_TYPE_MISMATCH", message: `The resolved document is not a valid screen at ${at}: ${issue?.message ?? ""}`.trim() },
113
+ };
114
+ }
@@ -0,0 +1,18 @@
1
+ import { z } from "zod";
2
+ import { iosBlockSchema } from "./block.ts";
3
+ import type { IosBlockNode } from "./block-types.ts";
4
+
5
+ /**
6
+ * Recursion point of the block tree.
7
+ *
8
+ * Every container-like block embeds other blocks (`child`, `children`,
9
+ * `start_block`, ...), and the block union is built from those same schemas.
10
+ * `blockRef` defers the lookup of `iosBlockSchema` until validation time, which
11
+ * closes the loop without evaluating anything during module load. The explicit
12
+ * `IosBlockNode` type is what lets TypeScript accept the cycle.
13
+ *
14
+ * The modules form an import cycle (`block.ts` -> `blocks/*` -> `block-ref.ts` ->
15
+ * `block.ts`) that only resolves when evaluation starts at `block.ts`. Always
16
+ * import the module through `index.ts` (or `block.ts`), never `blocks/*` alone.
17
+ */
18
+ export const blockRef: z.ZodType<IosBlockNode> = z.lazy(() => iosBlockSchema);
@@ -0,0 +1,55 @@
1
+ /**
2
+ * The 26 block types registered by the iOS runtime, in registration order.
3
+ *
4
+ * Source of truth: `FIOCoreBlockClassesStore.defaultBlocks` in
5
+ * fractal_core_blocks-ios (`Sources/Store/FIOCoreBlockClassesStore.swift`).
6
+ * Keep this list in sync with that array. `GestureDetector` exists in the
7
+ * Swift sources but is not registered, so iOS never decodes it and it is
8
+ * deliberately absent here.
9
+ */
10
+ export const IOS_BLOCK_TYPES = [
11
+ "container",
12
+ "text",
13
+ "column",
14
+ "row",
15
+ "single_child_scroll",
16
+ "icon",
17
+ "icon_button",
18
+ "padding",
19
+ "divider",
20
+ "card",
21
+ "expanded",
22
+ "flexible",
23
+ "spacer",
24
+ "image",
25
+ "grid",
26
+ "check_box",
27
+ "list_row",
28
+ "list",
29
+ "list_section",
30
+ "text_button",
31
+ "text_field",
32
+ "dropdown_menu",
33
+ "pin_input",
34
+ "alert_banner",
35
+ "stat_progress_track",
36
+ "search",
37
+ "bell_toggle",
38
+ ] as const;
39
+
40
+ export type IosBlockType = (typeof IOS_BLOCK_TYPES)[number];
41
+
42
+ /**
43
+ * Structural type of a nested block (`child`, `children`, `start_block`, ...).
44
+ *
45
+ * Block schemas are mutually recursive (a container holds blocks that can be
46
+ * containers), so the recursion point needs an explicit type: TypeScript cannot
47
+ * infer a type that refers to itself through 26 separate modules. Nested blocks
48
+ * are therefore typed as `{ type, data }` here, while the runtime schema
49
+ * (`blockRef` in `block-ref.ts`) still validates them in full. The top-level
50
+ * `IosBlock` type from `block.ts` is the precise discriminated union.
51
+ */
52
+ export interface IosBlockNode {
53
+ type: IosBlockType;
54
+ data: object;
55
+ }
package/src/block.ts ADDED
@@ -0,0 +1,116 @@
1
+ import { z } from "zod";
2
+ import type { IosBlockType } from "./block-types.ts";
3
+ import {
4
+ cardDataSchema,
5
+ columnDataSchema,
6
+ containerDataSchema,
7
+ dividerDataSchema,
8
+ expandedDataSchema,
9
+ flexibleDataSchema,
10
+ gridDataSchema,
11
+ paddingDataSchema,
12
+ rowDataSchema,
13
+ singleChildScrollDataSchema,
14
+ spacerDataSchema,
15
+ } from "./blocks/layout.ts";
16
+ import {
17
+ alertBannerDataSchema,
18
+ iconButtonDataSchema,
19
+ iconDataSchema,
20
+ imageDataSchema,
21
+ statProgressTrackDataSchema,
22
+ textDataSchema,
23
+ } from "./blocks/display.ts";
24
+ import {
25
+ bellToggleDataSchema,
26
+ checkBoxDataSchema,
27
+ dropdownMenuDataSchema,
28
+ pinInputDataSchema,
29
+ searchDataSchema,
30
+ textButtonDataSchema,
31
+ textFieldDataSchema,
32
+ } from "./blocks/input.ts";
33
+ import { listDataSchema, listRowDataSchema, listSectionDataSchema } from "./blocks/list.ts";
34
+
35
+ /**
36
+ * `data` schema of every registered block type. The `satisfies` clause makes
37
+ * TypeScript fail when a type is added to `IOS_BLOCK_TYPES` without a schema
38
+ * (and the other way around).
39
+ */
40
+ export const iosBlockDataSchemas = {
41
+ container: containerDataSchema,
42
+ text: textDataSchema,
43
+ column: columnDataSchema,
44
+ row: rowDataSchema,
45
+ single_child_scroll: singleChildScrollDataSchema,
46
+ icon: iconDataSchema,
47
+ icon_button: iconButtonDataSchema,
48
+ padding: paddingDataSchema,
49
+ divider: dividerDataSchema,
50
+ card: cardDataSchema,
51
+ expanded: expandedDataSchema,
52
+ flexible: flexibleDataSchema,
53
+ spacer: spacerDataSchema,
54
+ image: imageDataSchema,
55
+ grid: gridDataSchema,
56
+ check_box: checkBoxDataSchema,
57
+ list_row: listRowDataSchema,
58
+ list: listDataSchema,
59
+ list_section: listSectionDataSchema,
60
+ text_button: textButtonDataSchema,
61
+ text_field: textFieldDataSchema,
62
+ dropdown_menu: dropdownMenuDataSchema,
63
+ pin_input: pinInputDataSchema,
64
+ alert_banner: alertBannerDataSchema,
65
+ stat_progress_track: statProgressTrackDataSchema,
66
+ search: searchDataSchema,
67
+ bell_toggle: bellToggleDataSchema,
68
+ } as const satisfies Record<IosBlockType, z.ZodType>;
69
+
70
+ /** One `{ type, data }` variant of the block union. */
71
+ function blockVariant<T extends IosBlockType, D extends z.ZodType>(type: T, data: D) {
72
+ return z.strictObject({ type: z.literal(type), data });
73
+ }
74
+
75
+ /**
76
+ * A block: `{ type, data }` where `type` is one of the 26 registered names and
77
+ * `data` is validated against that type's schema. Unknown types are rejected
78
+ * (iOS would silently render nothing for them).
79
+ *
80
+ * Swift: FIOCoreBaseBlock (Sources/Base/FIOCoreBaseBlock.swift) decodes `type`
81
+ * then `data`; `data` is mandatory even for blocks without own keys (`{}`).
82
+ */
83
+ export const iosBlockSchema = z.discriminatedUnion("type", [
84
+ blockVariant("container", iosBlockDataSchemas.container),
85
+ blockVariant("text", iosBlockDataSchemas.text),
86
+ blockVariant("column", iosBlockDataSchemas.column),
87
+ blockVariant("row", iosBlockDataSchemas.row),
88
+ blockVariant("single_child_scroll", iosBlockDataSchemas.single_child_scroll),
89
+ blockVariant("icon", iosBlockDataSchemas.icon),
90
+ blockVariant("icon_button", iosBlockDataSchemas.icon_button),
91
+ blockVariant("padding", iosBlockDataSchemas.padding),
92
+ blockVariant("divider", iosBlockDataSchemas.divider),
93
+ blockVariant("card", iosBlockDataSchemas.card),
94
+ blockVariant("expanded", iosBlockDataSchemas.expanded),
95
+ blockVariant("flexible", iosBlockDataSchemas.flexible),
96
+ blockVariant("spacer", iosBlockDataSchemas.spacer),
97
+ blockVariant("image", iosBlockDataSchemas.image),
98
+ blockVariant("grid", iosBlockDataSchemas.grid),
99
+ blockVariant("check_box", iosBlockDataSchemas.check_box),
100
+ blockVariant("list_row", iosBlockDataSchemas.list_row),
101
+ blockVariant("list", iosBlockDataSchemas.list),
102
+ blockVariant("list_section", iosBlockDataSchemas.list_section),
103
+ blockVariant("text_button", iosBlockDataSchemas.text_button),
104
+ blockVariant("text_field", iosBlockDataSchemas.text_field),
105
+ blockVariant("dropdown_menu", iosBlockDataSchemas.dropdown_menu),
106
+ blockVariant("pin_input", iosBlockDataSchemas.pin_input),
107
+ blockVariant("alert_banner", iosBlockDataSchemas.alert_banner),
108
+ blockVariant("stat_progress_track", iosBlockDataSchemas.stat_progress_track),
109
+ blockVariant("search", iosBlockDataSchemas.search),
110
+ blockVariant("bell_toggle", iosBlockDataSchemas.bell_toggle),
111
+ ]);
112
+
113
+ export type IosBlock = z.infer<typeof iosBlockSchema>;
114
+
115
+ /** The validated `data` payload of one block type, e.g. `IosBlockData<"text">`. */
116
+ export type IosBlockData<T extends IosBlockType> = z.infer<(typeof iosBlockDataSchemas)[T]>;