@pwfabric/runtime 0.0.0-stage → 1.0.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (447) hide show
  1. package/LICENSE +90 -0
  2. package/README.md +43 -2
  3. package/dist/a11y/announcer.d.ts +65 -0
  4. package/dist/a11y/announcer.js +140 -0
  5. package/dist/a11y/announcer.js.map +1 -0
  6. package/dist/a11y/contrast.d.ts +54 -0
  7. package/dist/a11y/contrast.js +93 -0
  8. package/dist/a11y/contrast.js.map +1 -0
  9. package/dist/a11y/focus.d.ts +123 -0
  10. package/dist/a11y/focus.js +282 -0
  11. package/dist/a11y/focus.js.map +1 -0
  12. package/dist/a11y/index.d.ts +21 -0
  13. package/dist/a11y/index.js +18 -0
  14. package/dist/a11y/index.js.map +1 -0
  15. package/dist/a11y/keyboard.d.ts +144 -0
  16. package/dist/a11y/keyboard.js +317 -0
  17. package/dist/a11y/keyboard.js.map +1 -0
  18. package/dist/adapters/default-image.d.ts +25 -0
  19. package/dist/adapters/default-image.js +37 -0
  20. package/dist/adapters/default-image.js.map +1 -0
  21. package/dist/adapters/index.d.ts +27 -0
  22. package/dist/adapters/index.js +28 -0
  23. package/dist/adapters/index.js.map +1 -0
  24. package/dist/adapters/next-image.d.ts +38 -0
  25. package/dist/adapters/next-image.js +124 -0
  26. package/dist/adapters/next-image.js.map +1 -0
  27. package/dist/adapters/types.d.ts +61 -0
  28. package/dist/adapters/types.js +11 -0
  29. package/dist/adapters/types.js.map +1 -0
  30. package/dist/analytics/index.d.ts +14 -0
  31. package/dist/analytics/index.js +15 -0
  32. package/dist/analytics/index.js.map +1 -0
  33. package/dist/analytics/tracker.d.ts +65 -0
  34. package/dist/analytics/tracker.js +251 -0
  35. package/dist/analytics/tracker.js.map +1 -0
  36. package/dist/analytics/types.d.ts +130 -0
  37. package/dist/analytics/types.js +11 -0
  38. package/dist/analytics/types.js.map +1 -0
  39. package/dist/auth/index.d.ts +15 -0
  40. package/dist/auth/index.js +14 -0
  41. package/dist/auth/index.js.map +1 -0
  42. package/dist/auth/provider.d.ts +132 -0
  43. package/dist/auth/provider.js +473 -0
  44. package/dist/auth/provider.js.map +1 -0
  45. package/dist/auth/types.d.ts +117 -0
  46. package/dist/auth/types.js +9 -0
  47. package/dist/auth/types.js.map +1 -0
  48. package/dist/binding/collection.d.ts +190 -0
  49. package/dist/binding/collection.js +358 -0
  50. package/dist/binding/collection.js.map +1 -0
  51. package/dist/binding/datasource.d.ts +319 -0
  52. package/dist/binding/datasource.js +556 -0
  53. package/dist/binding/datasource.js.map +1 -0
  54. package/dist/binding/engine.d.ts +65 -0
  55. package/dist/binding/engine.js +268 -0
  56. package/dist/binding/engine.js.map +1 -0
  57. package/dist/binding/expression.d.ts +150 -0
  58. package/dist/binding/expression.js +787 -0
  59. package/dist/binding/expression.js.map +1 -0
  60. package/dist/binding/index.d.ts +19 -0
  61. package/dist/binding/index.js +14 -0
  62. package/dist/binding/index.js.map +1 -0
  63. package/dist/binding/two-way.d.ts +149 -0
  64. package/dist/binding/two-way.js +462 -0
  65. package/dist/binding/two-way.js.map +1 -0
  66. package/dist/binding/types.d.ts +119 -0
  67. package/dist/binding/types.js +9 -0
  68. package/dist/binding/types.js.map +1 -0
  69. package/dist/blocks/component-types.d.ts +81 -0
  70. package/dist/blocks/component-types.js +11 -0
  71. package/dist/blocks/component-types.js.map +1 -0
  72. package/dist/blocks/composition-rules.d.ts +168 -0
  73. package/dist/blocks/composition-rules.js +391 -0
  74. package/dist/blocks/composition-rules.js.map +1 -0
  75. package/dist/blocks/hooks.d.ts +31 -0
  76. package/dist/blocks/hooks.js +42 -0
  77. package/dist/blocks/hooks.js.map +1 -0
  78. package/dist/blocks/index.d.ts +14 -0
  79. package/dist/blocks/index.js +23 -0
  80. package/dist/blocks/index.js.map +1 -0
  81. package/dist/blocks/registry.d.ts +84 -0
  82. package/dist/blocks/registry.js +136 -0
  83. package/dist/blocks/registry.js.map +1 -0
  84. package/dist/blocks/rule-engine.d.ts +131 -0
  85. package/dist/blocks/rule-engine.js +321 -0
  86. package/dist/blocks/rule-engine.js.map +1 -0
  87. package/dist/blocks/surface-event-context.d.ts +13 -0
  88. package/dist/blocks/surface-event-context.js +14 -0
  89. package/dist/blocks/surface-event-context.js.map +1 -0
  90. package/dist/blocks/surface-id-context.d.ts +13 -0
  91. package/dist/blocks/surface-id-context.js +15 -0
  92. package/dist/blocks/surface-id-context.js.map +1 -0
  93. package/dist/bus.d.ts +41 -0
  94. package/dist/bus.js +158 -0
  95. package/dist/bus.js.map +1 -0
  96. package/dist/cache/index.d.ts +9 -0
  97. package/dist/cache/index.js +10 -0
  98. package/dist/cache/index.js.map +1 -0
  99. package/dist/cache/memory.d.ts +32 -0
  100. package/dist/cache/memory.js +138 -0
  101. package/dist/cache/memory.js.map +1 -0
  102. package/dist/cache/types.d.ts +62 -0
  103. package/dist/cache/types.js +9 -0
  104. package/dist/cache/types.js.map +1 -0
  105. package/dist/capability/index.d.ts +72 -0
  106. package/dist/capability/index.js +87 -0
  107. package/dist/capability/index.js.map +1 -0
  108. package/dist/capability/kernel-capabilities.d.ts +31 -0
  109. package/dist/capability/kernel-capabilities.js +36 -0
  110. package/dist/capability/kernel-capabilities.js.map +1 -0
  111. package/dist/capability/platform-capabilities.d.ts +71 -0
  112. package/dist/capability/platform-capabilities.js +267 -0
  113. package/dist/capability/platform-capabilities.js.map +1 -0
  114. package/dist/capability/type-mapping.d.ts +70 -0
  115. package/dist/capability/type-mapping.js +107 -0
  116. package/dist/capability/type-mapping.js.map +1 -0
  117. package/dist/capability/validation.d.ts +46 -0
  118. package/dist/capability/validation.js +54 -0
  119. package/dist/capability/validation.js.map +1 -0
  120. package/dist/connectors/declared-connector.d.ts +48 -0
  121. package/dist/connectors/declared-connector.js +333 -0
  122. package/dist/connectors/declared-connector.js.map +1 -0
  123. package/dist/connectors/engine-registry.d.ts +50 -0
  124. package/dist/connectors/engine-registry.js +135 -0
  125. package/dist/connectors/engine-registry.js.map +1 -0
  126. package/dist/connectors/index.d.ts +14 -0
  127. package/dist/connectors/index.js +14 -0
  128. package/dist/connectors/index.js.map +1 -0
  129. package/dist/connectors/module-loader.d.ts +70 -0
  130. package/dist/connectors/module-loader.js +143 -0
  131. package/dist/connectors/module-loader.js.map +1 -0
  132. package/dist/connectors/types.d.ts +174 -0
  133. package/dist/connectors/types.js +23 -0
  134. package/dist/connectors/types.js.map +1 -0
  135. package/dist/context.d.ts +27 -0
  136. package/dist/context.js +38 -0
  137. package/dist/context.js.map +1 -0
  138. package/dist/data/DataCapabilityProvider.d.ts +39 -0
  139. package/dist/data/DataCapabilityProvider.js +58 -0
  140. package/dist/data/DataCapabilityProvider.js.map +1 -0
  141. package/dist/data/index.d.ts +17 -0
  142. package/dist/data/index.js +18 -0
  143. package/dist/data/index.js.map +1 -0
  144. package/dist/data/manager.d.ts +40 -0
  145. package/dist/data/manager.js +442 -0
  146. package/dist/data/manager.js.map +1 -0
  147. package/dist/data/types.d.ts +218 -0
  148. package/dist/data/types.js +2 -0
  149. package/dist/data/types.js.map +1 -0
  150. package/dist/entity/aggregate.d.ts +8 -0
  151. package/dist/entity/aggregate.js +24 -0
  152. package/dist/entity/aggregate.js.map +1 -0
  153. package/dist/entity/apply-query.d.ts +58 -0
  154. package/dist/entity/apply-query.js +264 -0
  155. package/dist/entity/apply-query.js.map +1 -0
  156. package/dist/entity/behavior.d.ts +94 -0
  157. package/dist/entity/behavior.js +78 -0
  158. package/dist/entity/behavior.js.map +1 -0
  159. package/dist/entity/connector.d.ts +141 -0
  160. package/dist/entity/connector.js +89 -0
  161. package/dist/entity/connector.js.map +1 -0
  162. package/dist/entity/connectors/index.d.ts +12 -0
  163. package/dist/entity/connectors/index.js +11 -0
  164. package/dist/entity/connectors/index.js.map +1 -0
  165. package/dist/entity/connectors/static.d.ts +51 -0
  166. package/dist/entity/connectors/static.js +245 -0
  167. package/dist/entity/connectors/static.js.map +1 -0
  168. package/dist/entity/entity-datasource.d.ts +50 -0
  169. package/dist/entity/entity-datasource.js +33 -0
  170. package/dist/entity/entity-datasource.js.map +1 -0
  171. package/dist/entity/facade.d.ts +70 -0
  172. package/dist/entity/facade.js +70 -0
  173. package/dist/entity/facade.js.map +1 -0
  174. package/dist/entity/http-connector.d.ts +123 -0
  175. package/dist/entity/http-connector.js +295 -0
  176. package/dist/entity/http-connector.js.map +1 -0
  177. package/dist/entity/index.d.ts +38 -0
  178. package/dist/entity/index.js +31 -0
  179. package/dist/entity/index.js.map +1 -0
  180. package/dist/entity/postgres-connector.d.ts +64 -0
  181. package/dist/entity/postgres-connector.js +239 -0
  182. package/dist/entity/postgres-connector.js.map +1 -0
  183. package/dist/entity/registry.d.ts +59 -0
  184. package/dist/entity/registry.js +90 -0
  185. package/dist/entity/registry.js.map +1 -0
  186. package/dist/entity/store.d.ts +66 -0
  187. package/dist/entity/store.js +349 -0
  188. package/dist/entity/store.js.map +1 -0
  189. package/dist/entity/types.d.ts +180 -0
  190. package/dist/entity/types.js +10 -0
  191. package/dist/entity/types.js.map +1 -0
  192. package/dist/execution-context.d.ts +88 -0
  193. package/dist/execution-context.js +146 -0
  194. package/dist/execution-context.js.map +1 -0
  195. package/dist/executor.d.ts +27 -0
  196. package/dist/executor.js +33 -0
  197. package/dist/executor.js.map +1 -0
  198. package/dist/forms/form-entity-bridge.d.ts +94 -0
  199. package/dist/forms/form-entity-bridge.js +96 -0
  200. package/dist/forms/form-entity-bridge.js.map +1 -0
  201. package/dist/forms/form-write-target.d.ts +34 -0
  202. package/dist/forms/form-write-target.js +81 -0
  203. package/dist/forms/form-write-target.js.map +1 -0
  204. package/dist/forms/index.d.ts +22 -0
  205. package/dist/forms/index.js +25 -0
  206. package/dist/forms/index.js.map +1 -0
  207. package/dist/forms/named-control-values.d.ts +27 -0
  208. package/dist/forms/named-control-values.js +42 -0
  209. package/dist/forms/named-control-values.js.map +1 -0
  210. package/dist/forms/processor.d.ts +55 -0
  211. package/dist/forms/processor.js +154 -0
  212. package/dist/forms/processor.js.map +1 -0
  213. package/dist/forms/types.d.ts +174 -0
  214. package/dist/forms/types.js +33 -0
  215. package/dist/forms/types.js.map +1 -0
  216. package/dist/forms/validator.d.ts +61 -0
  217. package/dist/forms/validator.js +218 -0
  218. package/dist/forms/validator.js.map +1 -0
  219. package/dist/graph/index.d.ts +10 -0
  220. package/dist/graph/index.js +9 -0
  221. package/dist/graph/index.js.map +1 -0
  222. package/dist/graph/resolver.d.ts +66 -0
  223. package/dist/graph/resolver.js +243 -0
  224. package/dist/graph/resolver.js.map +1 -0
  225. package/dist/graph/types.d.ts +125 -0
  226. package/dist/graph/types.js +9 -0
  227. package/dist/graph/types.js.map +1 -0
  228. package/dist/hooks/useInstalledAtoms.d.ts +96 -0
  229. package/dist/hooks/useInstalledAtoms.js +92 -0
  230. package/dist/hooks/useInstalledAtoms.js.map +1 -0
  231. package/dist/i18n/index.d.ts +15 -0
  232. package/dist/i18n/index.js +14 -0
  233. package/dist/i18n/index.js.map +1 -0
  234. package/dist/i18n/translator.d.ts +76 -0
  235. package/dist/i18n/translator.js +357 -0
  236. package/dist/i18n/translator.js.map +1 -0
  237. package/dist/i18n/types.d.ts +93 -0
  238. package/dist/i18n/types.js +9 -0
  239. package/dist/i18n/types.js.map +1 -0
  240. package/dist/index.d.ts +64 -0
  241. package/dist/index.js +95 -0
  242. package/dist/index.js.map +1 -0
  243. package/dist/kernel.d.ts +47 -0
  244. package/dist/kernel.js +258 -0
  245. package/dist/kernel.js.map +1 -0
  246. package/dist/perf/budget.d.ts +92 -0
  247. package/dist/perf/budget.js +122 -0
  248. package/dist/perf/budget.js.map +1 -0
  249. package/dist/perf/index.d.ts +16 -0
  250. package/dist/perf/index.js +13 -0
  251. package/dist/perf/index.js.map +1 -0
  252. package/dist/perf/render-timer.d.ts +90 -0
  253. package/dist/perf/render-timer.js +136 -0
  254. package/dist/perf/render-timer.js.map +1 -0
  255. package/dist/perf/reporter.d.ts +126 -0
  256. package/dist/perf/reporter.js +241 -0
  257. package/dist/perf/reporter.js.map +1 -0
  258. package/dist/perf/web-vitals.d.ts +111 -0
  259. package/dist/perf/web-vitals.js +268 -0
  260. package/dist/perf/web-vitals.js.map +1 -0
  261. package/dist/registry.d.ts +63 -0
  262. package/dist/registry.js +126 -0
  263. package/dist/registry.js.map +1 -0
  264. package/dist/render/BehaviorSurfaceProvider.d.ts +65 -0
  265. package/dist/render/BehaviorSurfaceProvider.js +185 -0
  266. package/dist/render/BehaviorSurfaceProvider.js.map +1 -0
  267. package/dist/render/BlockErrorBoundary.d.ts +26 -0
  268. package/dist/render/BlockErrorBoundary.js +41 -0
  269. package/dist/render/BlockErrorBoundary.js.map +1 -0
  270. package/dist/render/DataBoundSurfaceRenderer.d.ts +78 -0
  271. package/dist/render/DataBoundSurfaceRenderer.js +998 -0
  272. package/dist/render/DataBoundSurfaceRenderer.js.map +1 -0
  273. package/dist/render/DynamicBlockWrapper.d.ts +23 -0
  274. package/dist/render/DynamicBlockWrapper.js +117 -0
  275. package/dist/render/DynamicBlockWrapper.js.map +1 -0
  276. package/dist/render/appearance-resolver.d.ts +50 -0
  277. package/dist/render/appearance-resolver.js +78 -0
  278. package/dist/render/appearance-resolver.js.map +1 -0
  279. package/dist/render/capability-gate.d.ts +69 -0
  280. package/dist/render/capability-gate.js +94 -0
  281. package/dist/render/capability-gate.js.map +1 -0
  282. package/dist/render/conditional-states-css.d.ts +41 -0
  283. package/dist/render/conditional-states-css.js +82 -0
  284. package/dist/render/conditional-states-css.js.map +1 -0
  285. package/dist/render/connections-context.d.ts +31 -0
  286. package/dist/render/connections-context.js +34 -0
  287. package/dist/render/connections-context.js.map +1 -0
  288. package/dist/render/dark-theme-css.d.ts +36 -0
  289. package/dist/render/dark-theme-css.js +67 -0
  290. package/dist/render/dark-theme-css.js.map +1 -0
  291. package/dist/render/data-binding-types.d.ts +191 -0
  292. package/dist/render/data-binding-types.js +11 -0
  293. package/dist/render/data-binding-types.js.map +1 -0
  294. package/dist/render/data-cache.d.ts +30 -0
  295. package/dist/render/data-cache.js +37 -0
  296. package/dist/render/data-cache.js.map +1 -0
  297. package/dist/render/derive-dark-theme.d.ts +17 -0
  298. package/dist/render/derive-dark-theme.js +18 -0
  299. package/dist/render/derive-dark-theme.js.map +1 -0
  300. package/dist/render/dynamic-artifact-context.d.ts +77 -0
  301. package/dist/render/dynamic-artifact-context.js +89 -0
  302. package/dist/render/dynamic-artifact-context.js.map +1 -0
  303. package/dist/render/dynamic-block-loader.d.ts +80 -0
  304. package/dist/render/dynamic-block-loader.js +197 -0
  305. package/dist/render/dynamic-block-loader.js.map +1 -0
  306. package/dist/render/endpoint.d.ts +18 -0
  307. package/dist/render/endpoint.js +109 -0
  308. package/dist/render/endpoint.js.map +1 -0
  309. package/dist/render/entity-facade-context.d.ts +34 -0
  310. package/dist/render/entity-facade-context.js +37 -0
  311. package/dist/render/entity-facade-context.js.map +1 -0
  312. package/dist/render/group-states-css.d.ts +41 -0
  313. package/dist/render/group-states-css.js +73 -0
  314. package/dist/render/group-states-css.js.map +1 -0
  315. package/dist/render/hooks/useSurfaceEvents.d.ts +8 -0
  316. package/dist/render/hooks/useSurfaceEvents.js +9 -0
  317. package/dist/render/hooks/useSurfaceEvents.js.map +1 -0
  318. package/dist/render/hooks/useSurfaceId.d.ts +8 -0
  319. package/dist/render/hooks/useSurfaceId.js +9 -0
  320. package/dist/render/hooks/useSurfaceId.js.map +1 -0
  321. package/dist/render/index.d.ts +48 -0
  322. package/dist/render/index.js +61 -0
  323. package/dist/render/index.js.map +1 -0
  324. package/dist/render/interaction-rule-engine.d.ts +12 -0
  325. package/dist/render/interaction-rule-engine.js +47 -0
  326. package/dist/render/interaction-rule-engine.js.map +1 -0
  327. package/dist/render/keyframes-css.d.ts +31 -0
  328. package/dist/render/keyframes-css.js +44 -0
  329. package/dist/render/keyframes-css.js.map +1 -0
  330. package/dist/render/query-state.d.ts +3 -0
  331. package/dist/render/query-state.js +70 -0
  332. package/dist/render/query-state.js.map +1 -0
  333. package/dist/render/renderer.d.ts +44 -0
  334. package/dist/render/renderer.js +937 -0
  335. package/dist/render/renderer.js.map +1 -0
  336. package/dist/render/resolve-expressions.d.ts +37 -0
  337. package/dist/render/resolve-expressions.js +309 -0
  338. package/dist/render/resolve-expressions.js.map +1 -0
  339. package/dist/render/responsive-style-css.d.ts +42 -0
  340. package/dist/render/responsive-style-css.js +123 -0
  341. package/dist/render/responsive-style-css.js.map +1 -0
  342. package/dist/render/responsive.d.ts +49 -0
  343. package/dist/render/responsive.js +99 -0
  344. package/dist/render/responsive.js.map +1 -0
  345. package/dist/render/scoped-css.d.ts +71 -0
  346. package/dist/render/scoped-css.js +102 -0
  347. package/dist/render/scoped-css.js.map +1 -0
  348. package/dist/render/shell-selection.d.ts +69 -0
  349. package/dist/render/shell-selection.js +117 -0
  350. package/dist/render/shell-selection.js.map +1 -0
  351. package/dist/render/states-css.d.ts +32 -0
  352. package/dist/render/states-css.js +63 -0
  353. package/dist/render/states-css.js.map +1 -0
  354. package/dist/render/surface-data-context.d.ts +18 -0
  355. package/dist/render/surface-data-context.js +21 -0
  356. package/dist/render/surface-data-context.js.map +1 -0
  357. package/dist/render/surface-event-bus.d.ts +19 -0
  358. package/dist/render/surface-event-bus.js +68 -0
  359. package/dist/render/surface-event-bus.js.map +1 -0
  360. package/dist/render/surface-event-context.d.ts +11 -0
  361. package/dist/render/surface-event-context.js +12 -0
  362. package/dist/render/surface-event-context.js.map +1 -0
  363. package/dist/render/surface-id-context.d.ts +8 -0
  364. package/dist/render/surface-id-context.js +9 -0
  365. package/dist/render/surface-id-context.js.map +1 -0
  366. package/dist/render/theme-utils.d.ts +14 -0
  367. package/dist/render/theme-utils.js +15 -0
  368. package/dist/render/theme-utils.js.map +1 -0
  369. package/dist/render/types.d.ts +282 -0
  370. package/dist/render/types.js +9 -0
  371. package/dist/render/types.js.map +1 -0
  372. package/dist/render/visibility-css.d.ts +42 -0
  373. package/dist/render/visibility-css.js +119 -0
  374. package/dist/render/visibility-css.js.map +1 -0
  375. package/dist/render/width-scope.d.ts +34 -0
  376. package/dist/render/width-scope.js +44 -0
  377. package/dist/render/width-scope.js.map +1 -0
  378. package/dist/render/write-only-sources.d.ts +33 -0
  379. package/dist/render/write-only-sources.js +99 -0
  380. package/dist/render/write-only-sources.js.map +1 -0
  381. package/dist/routing/index.d.ts +14 -0
  382. package/dist/routing/index.js +15 -0
  383. package/dist/routing/index.js.map +1 -0
  384. package/dist/routing/router.d.ts +42 -0
  385. package/dist/routing/router.js +218 -0
  386. package/dist/routing/router.js.map +1 -0
  387. package/dist/routing/types.d.ts +124 -0
  388. package/dist/routing/types.js +9 -0
  389. package/dist/routing/types.js.map +1 -0
  390. package/dist/seo/generator.d.ts +39 -0
  391. package/dist/seo/generator.js +236 -0
  392. package/dist/seo/generator.js.map +1 -0
  393. package/dist/seo/index.d.ts +14 -0
  394. package/dist/seo/index.js +15 -0
  395. package/dist/seo/index.js.map +1 -0
  396. package/dist/seo/types.d.ts +181 -0
  397. package/dist/seo/types.js +9 -0
  398. package/dist/seo/types.js.map +1 -0
  399. package/dist/state/index.d.ts +15 -0
  400. package/dist/state/index.js +16 -0
  401. package/dist/state/index.js.map +1 -0
  402. package/dist/state/manager.d.ts +33 -0
  403. package/dist/state/manager.js +81 -0
  404. package/dist/state/manager.js.map +1 -0
  405. package/dist/state/store.d.ts +40 -0
  406. package/dist/state/store.js +145 -0
  407. package/dist/state/store.js.map +1 -0
  408. package/dist/state/types.d.ts +107 -0
  409. package/dist/state/types.js +9 -0
  410. package/dist/state/types.js.map +1 -0
  411. package/dist/surface/expression.d.ts +65 -0
  412. package/dist/surface/expression.js +179 -0
  413. package/dist/surface/expression.js.map +1 -0
  414. package/dist/surface/index.d.ts +32 -0
  415. package/dist/surface/index.js +25 -0
  416. package/dist/surface/index.js.map +1 -0
  417. package/dist/surface/interpreter.d.ts +96 -0
  418. package/dist/surface/interpreter.js +231 -0
  419. package/dist/surface/interpreter.js.map +1 -0
  420. package/dist/surface/layout.d.ts +54 -0
  421. package/dist/surface/layout.js +288 -0
  422. package/dist/surface/layout.js.map +1 -0
  423. package/dist/surface/output.d.ts +90 -0
  424. package/dist/surface/output.js +104 -0
  425. package/dist/surface/output.js.map +1 -0
  426. package/dist/surface/primitives.d.ts +180 -0
  427. package/dist/surface/primitives.js +339 -0
  428. package/dist/surface/primitives.js.map +1 -0
  429. package/dist/surface/renderer.d.ts +96 -0
  430. package/dist/surface/renderer.js +190 -0
  431. package/dist/surface/renderer.js.map +1 -0
  432. package/dist/surface/schemas.d.ts +181 -0
  433. package/dist/surface/schemas.js +142 -0
  434. package/dist/surface/schemas.js.map +1 -0
  435. package/dist/surface/transforms.d.ts +144 -0
  436. package/dist/surface/transforms.js +120 -0
  437. package/dist/surface/transforms.js.map +1 -0
  438. package/dist/surface/types.d.ts +160 -0
  439. package/dist/surface/types.js +51 -0
  440. package/dist/surface/types.js.map +1 -0
  441. package/dist/surface/validation.d.ts +123 -0
  442. package/dist/surface/validation.js +147 -0
  443. package/dist/surface/validation.js.map +1 -0
  444. package/dist/validator.d.ts +55 -0
  445. package/dist/validator.js +100 -0
  446. package/dist/validator.js.map +1 -0
  447. package/package.json +106 -3
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderer.js","sourceRoot":"","sources":["../../src/render/renderer.tsx"],"names":[],"mappings":";AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AAcpE,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,uBAAuB,EACvB,WAAW,EACX,sBAAsB,GACvB,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AACvE,OAAO,EACL,qBAAqB,EACrB,yBAAyB,EACzB,0BAA0B,GAC3B,MAAM,0BAA0B,CAAA;AACjC,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CA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,aAAa,CAAC,MAAwB,EAAE,EAAU;IAChE,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,IAAI,KAAK,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC;YACpB,OAAO,KAAK,CAAA;QACd,CAAC;QACD,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;YACnB,MAAM,KAAK,GAAG,aAAa,CAAC,KAAK,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAA;YAC/C,IAAI,KAAK,EAAE,CAAC;gBACV,OAAO,KAAK,CAAA;YACd,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAA;AAClB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAC7B,MAAwB,EACxB,EAAU,EACV,OAAuB;IAEvB,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;QAC1B,IAAI,KAAK,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC;YACpB,OAAO,EAAE,GAAG,KAAK,EAAE,GAAG,OAAO,EAAE,CAAA;QACjC,CAAC;QACD,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;YACnB,OAAO;gBACL,GAAG,KAAK;gBACR,QAAQ,EAAE,eAAe,CAAC,KAAK,CAAC,QAAQ,EAAE,EAAE,EAAE,OAAO,CAAC;aACvD,CAAA;QACH,CAAC;QACD,OAAO,KAAK,CAAA;IACd,CAAC,CAAC,CAAA;AACJ,CAAC","sourcesContent":["/**\n * Surface Renderer\n *\n * Phase 2A.1: Main Surface-to-React rendering component\n *\n * @module @pwfabric/runtime/render/renderer\n */\n\nimport * as React from 'react'\nimport type { Block } from '@pwfabric/core'\nimport { FLEX_HOIST_KEYS, LAYOUT_HOIST_KEYS } from './scoped-css.js'\nimport type {\n SurfaceRendererProps,\n BlockRendererProps,\n BlockContext,\n BlockComponentRegistry,\n BlockComponent,\n BlockWrapperProps,\n BlockWrapperRenderArgs,\n CapabilityProvider,\n CapabilityType,\n ImageAdapter,\n BlockSizing,\n} from './types.js'\nimport {\n resolveBlockLayout,\n resolveMeasureStyle,\n resolveSurfaceRootStyle,\n useViewport,\n getColumnsAtBreakpoint,\n} from './responsive.js'\nimport { chunkByWidthScope, resolveWidthScope } from './width-scope.js'\nimport {\n resolveAppearanceVars,\n resolveAppearanceDarkVars,\n resolveAppearanceKeyframes,\n} from './appearance-resolver.js'\nimport { collectVisibilityCss } from './visibility-css.js'\nimport { collectStatesCss } from './states-css.js'\nimport { collectConditionalStatesCss } from './conditional-states-css.js'\nimport { collectResponsiveStyleCss } from './responsive-style-css.js'\nimport { collectGroupStatesCss } from './group-states-css.js'\nimport { buildDarkThemeCss } from './dark-theme-css.js'\nimport { resolveAppearanceMode } from '@pwfabric/contracts'\nimport { buildKeyframesCss } from './keyframes-css.js'\nimport { DEFAULT_BLOCK_LAYOUT } from '@pwfabric/core'\nimport type { BreakpointName } from '@pwfabric/core'\nimport type { ImageAdapterProps } from '../adapters/types.js'\nimport type {\n DynamicBlockDescriptor,\n SurfaceEventDescriptor,\n} from '@pwfabric/contracts'\nimport type { SurfaceEvent } from './types.js'\n// `defaultBlockComponents` retired. Production render\n// path goes exclusively through the install pipeline — `customComponents`\n// (typically wired from `useDynamicArtifacts`) supplies the runtime\n// component map; blocks without a descriptor render as\n// \"Unknown block\" placeholders.\nimport { useEntitlements, GatedBlockPlaceholder } from './capability-gate.js'\nimport { useDynamicBlocks } from './dynamic-artifact-context.js'\nimport { DynamicBlockWrapper } from './DynamicBlockWrapper.js'\nimport { BlockErrorBoundary } from './BlockErrorBoundary.js'\nimport { BehaviorSurfaceProvider } from './BehaviorSurfaceProvider.js'\nimport { isCapability } from '../capability/type-mapping.js'\nimport type { SurfaceDataSourceDefinition } from './data-binding-types.js'\nimport { EntityFacadeContext } from './entity-facade-context.js'\nimport { SurfaceConnectionsContext } from './connections-context.js'\nimport { ShellSelectionProvider } from './shell-selection.js'\nimport type { FormEntityBridgeConfig } from '../forms/form-entity-bridge.js'\nimport { isRepeatExpanded } from './resolve-expressions.js'\n\n// ============================================================\n// HELPERS\n// ============================================================\n\n/**\n * Merge component registries, filtering out undefined values\n */\nfunction mergeComponentRegistries(\n base: BlockComponentRegistry | Partial<BlockComponentRegistry> = {},\n overrides?: Partial<BlockComponentRegistry>\n): BlockComponentRegistry {\n const merged: BlockComponentRegistry = {}\n for (const [key, value] of Object.entries(base)) {\n if (value !== undefined) merged[key] = value\n }\n if (overrides) {\n for (const [key, value] of Object.entries(overrides)) {\n if (value !== undefined) merged[key] = value\n }\n }\n return merged\n}\n\n/**\n * Project a canonical `SurfaceEventDescriptor.type` (contracts vocabulary, e.g.\n * `'block:click'`, `'form:submit'`, `'input:change'`) onto the renderer's legacy\n * `SurfaceEvent['type']` enum. Anything without a direct legacy equivalent\n * collapses to `'custom'`. Only used to satisfy the `onEvent` handler's shape —\n * the dispatcher reads `blockId`/`payload`, not the projected `type`.\n */\nfunction mapCanonicalEventType(type: string): SurfaceEvent['type'] {\n switch (type) {\n case 'block:click':\n return 'click'\n case 'form:submit':\n return 'submit'\n case 'form:change':\n case 'input:change':\n return 'change'\n default:\n return 'custom'\n }\n}\n\n/**\n * Create an ImageBlock component that uses the provided adapter\n */\nfunction createImageBlockWithAdapter(adapter: ImageAdapter): BlockComponent {\n return ({ props, block }): React.ReactNode => {\n // Build adapter props, only including defined values\n const adapterProps: ImageAdapterProps = {\n src: (props.src as string) || '/placeholder.png',\n alt: (props.alt as string) ?? '',\n blockId: block.id,\n }\n\n // Add optional props only if they have values\n if (props.width !== undefined) {\n ;(adapterProps as { width: number | string }).width = props.width as number | string\n }\n if (props.height !== undefined) {\n ;(adapterProps as { height: number | string }).height = props.height as number | string\n }\n if (props.loading !== undefined) {\n ;(adapterProps as { loading: 'lazy' | 'eager' }).loading = props.loading as 'lazy' | 'eager'\n ;(adapterProps as { priority: boolean }).priority = props.loading === 'eager'\n }\n if (props.objectFit !== undefined) {\n ;(adapterProps as { objectFit: ImageAdapterProps['objectFit'] }).objectFit =\n props.objectFit as ImageAdapterProps['objectFit']\n }\n if (props.aspectRatio !== undefined) {\n ;(adapterProps as { aspectRatio: string }).aspectRatio = props.aspectRatio as string\n }\n if (props.borderRadius !== undefined) {\n ;(adapterProps as { borderRadius: number | string }).borderRadius = props.borderRadius as\n | number\n | string\n }\n if (props.placeholder !== undefined) {\n ;(adapterProps as { placeholder: 'blur' | 'empty' }).placeholder = props.placeholder as\n | 'blur'\n | 'empty'\n }\n if (props.blurDataURL !== undefined) {\n ;(adapterProps as { blurDataURL: string }).blurDataURL = props.blurDataURL as string\n }\n\n return React.createElement(adapter, adapterProps)\n }\n}\n\n// ============================================================\n// BLOCK WRAPPER SEAM (ADR render-unification)\n// ============================================================\n\ntype RenderBlockWrapperFn = (args: BlockWrapperRenderArgs) => React.ReactNode\n\n/**\n * Emit a block's outermost wrapper. When `renderBlockWrapper` is provided\n * (editor seam) the decorator owns the wrapper element and receives the\n * runtime-computed `wrapperProps` (layout style + selectors). Otherwise the\n * default `<div {...wrapperProps}>` is rendered — byte-identical to the\n * pre-seam runtime (modulo the unified `data-block-id`).\n */\n/**\n * The attributes EVERY wrapper must carry — in one place.\n *\n * `states-css.ts` and `conditional-states-css.ts` EXCLUDE the wrapper from\n * their state rules with `:not([data-block-wrapper])`. Without the attribute\n * there is no exclusion: a rule matches both the wrapper and the component\n * root, and the defect described in states-css comes back (\"the square\n * wrapper takes the hover box-shadow, corners show under the rounded card,\n * transforms stack\") — on every block, including blocks installed from a pack.\n *\n * All four call sites derive from this base, so they cannot drift apart.\n */\nfunction baseWrapperProps(\n block: { id: string },\n layoutStyle: React.CSSProperties | undefined,\n scopeAttr: Record<string, string>\n): BlockWrapperProps {\n return {\n // `exactOptionalPropertyTypes`: an optional field cannot be given an\n // explicit `undefined`; when absent it is left out.\n ...(layoutStyle ? { style: layoutStyle } : {}),\n id: block.id,\n 'data-block-id': block.id,\n ...scopeAttr,\n // `data-block-wrapper`: an ALIAS carrying the same value as `data-block-id`\n // but with a separate job — the one marker that tells the wrapper apart\n // from the component root.\n 'data-block-wrapper': block.id,\n }\n}\n\nfunction emitBlockWrapper(\n block: Block,\n wrapperProps: BlockWrapperProps,\n inner: React.ReactNode,\n parentBlock: Block | undefined,\n renderBlockWrapper: RenderBlockWrapperFn | undefined\n): React.ReactNode {\n if (renderBlockWrapper) {\n return (\n <React.Fragment key={block.id}>\n {renderBlockWrapper({\n block,\n children: inner,\n wrapperProps,\n ...(parentBlock !== undefined ? { parentBlock } : {}),\n })}\n </React.Fragment>\n )\n }\n return (\n <div key={block.id} {...wrapperProps}>\n {inner}\n </div>\n )\n}\n\n// ============================================================\n// RESPONSIVE STYLE FLATTENING\n// ============================================================\n\n/**\n * Strip a block's responsive (`{ xs?, sm?, … }`) `style` prop values for INLINE\n * application: those are emitted ENTIRELY as scoped stylesheet rules by\n * `collectResponsiveStyleCss` (base as a non-media rule + larger breakpoints as\n * `@media`). They must NOT be applied inline — inline declarations beat\n * stylesheet/@media rules, so an inline base would pin the value and the\n * responsive overrides would never take effect. Flat string values pass through\n * untouched. Returns the SAME block object when no responsive value is present\n * (zero allocation for existing surfaces).\n */\nfunction flattenResponsiveStyle(block: Block): Block {\n const style = block.style\n if (!style) return block\n let hasResponsive = false\n const flat: Record<string, string> = {}\n for (const [prop, value] of Object.entries(style)) {\n if (typeof value === 'string') {\n flat[prop] = value\n continue\n }\n if (value === null || value === undefined) continue\n // Responsive value map → handled ENTIRELY by responsive-style-css (base as a\n // non-media scoped rule + larger breakpoints as @media). It must NOT be\n // applied inline: inline declarations beat stylesheet/@media rules, so an\n // inline base would pin the value and the responsive overrides would never\n // take effect. Strip it from the inline style here.\n hasResponsive = true\n }\n if (!hasResponsive) return block\n return { ...block, style: flat }\n}\n\n// ============================================================\n// BLOCK RENDERER\n// ============================================================\n\n/**\n * Compute a block's grid/flex layout style. Applied to EVERY render path\n * (static, dynamic, unknown, gated) so installed dynamic blocks lay out\n * identically to static ones — otherwise full-span dynamic sections auto-place\n * side-by-side instead of stacking.\n */\n/**\n * CHROME IS DECLARED, NOT HARD-CODED.\n *\n * The engine keeps no list of chrome block names (navbar, rail, bottom bar…):\n * such a list would be one pack's vocabulary, and a second pack could not\n * express its own chrome. Instead a block declares its own\n * `layout.widthScope` and the engine applies it. That a piece of chrome\n * inside a row is not stretched to an equal column also follows from that\n * declaration (see `resolveWidthScope` below).\n *\n * The one name kept below, `split-view`, is not pack vocabulary: it is a\n * LAYOUT block that places its own children and keeps the selection in\n * surface-owned state (see `shell-selection`).\n */\nconst CHILD_LAYOUT_OWNER = 'split-view'\n\n// Style keys hoisted from block.style to the WRAPPER div (the flex/grid item).\n// Module-scoped because renderBlock must strip the SAME keys from the style the\n// component receives — otherwise a margin is applied twice (wrapper + inner):\n// marginTop:'-40%' would move content by -335px AND -256px.\n// FLEX_HOIST_KEYS / LAYOUT_HOIST_KEYS live in scoped-css.ts — the responsive\n// CSS generator must read the SAME list (one hoisting rule, one place).\n\n/** block.style minus the hoisted keys — what the component itself may apply. */\nfunction stripHoistedStyle(block: Block): Block {\n const style = block.style as Record<string, unknown> | undefined\n if (!style) return block\n let has = false\n for (const key of LAYOUT_HOIST_KEYS) if (style[key] !== undefined) { has = true; break }\n if (!has) return block\n const rest: Record<string, unknown> = { ...style }\n for (const key of LAYOUT_HOIST_KEYS) delete rest[key]\n return { ...block, style: rest } as Block\n}\n\n/**\n * ROW STACKING LAW.\n *\n * A `container` with `direction: 'row'` is a flex row with `nowrap`; without\n * this rule nothing turns it into a column on a phone, so on xs a heading\n * sits squeezed beside a segmented control that overflows, navbar pills run\n * off the edge, and a two-column body becomes two 190px columns.\n *\n * The law: at the `xs` breakpoint a row container whose children include at\n * least TWO non-intrinsic blocks renders as a column. Rows made of intrinsic\n * blocks (avatar + name, icon + label, a button pair) are content rows and\n * keep their direction. Authors opt out with `keepRow: true`; a row that\n * already declares `wrap: true` handles itself. The stacked container carries\n * `stackedFromRow: true` so child layout does not apply column-mode\n * partial-span widths to what used to be row cells.\n */\nconst ROW_DIRECTIONS = new Set(['row', 'row-reverse'])\nfunction applyRowStacking(\n block: Block,\n viewport: BreakpointName,\n components: BlockComponentRegistry\n): Block {\n if (viewport !== 'xs' || block.type !== 'container') return block\n const props = (block.props ?? {}) as Record<string, unknown>\n if (!ROW_DIRECTIONS.has(String(props.direction))) return block\n if (props.keepRow === true || props.wrap === true) return block\n const children = block.children ?? []\n const fluid = children.filter((c) => components[c.type]?.sizing !== 'intrinsic').length\n if (fluid < 2) return block\n return { ...block, props: { ...props, direction: 'column', stackedFromRow: true } }\n}\n\nconst FIXED_PX_WIDTH = /^\\s*\\d+(?:\\.\\d+)?\\s*px\\s*$/i\n\n/**\n * A width that is a fixed length — a finite number (px, the props unit) or a\n * `px` string. Percentages, `auto`, `fit-content`, theme vars and\n * responsive maps are NOT fixed: they say nothing about the block keeping\n * its own size in a row.\n */\nfunction isFixedWidth(value: unknown): boolean {\n if (typeof value === 'number') return Number.isFinite(value) && value > 0\n return typeof value === 'string' && FIXED_PX_WIDTH.test(value) && parseFloat(value) > 0\n}\n\n/** The instance states a fixed width in `props.width` or `style.width`. */\nfunction hasFixedWidth(block: Block): boolean {\n const props = block.props as Record<string, unknown> | undefined\n const style = block.style as Record<string, unknown> | undefined\n return isFixedWidth(props?.width) || isFixedWidth(style?.width)\n}\n\nfunction computeBlockLayoutStyle(\n block: Block,\n parentBlock: Block | undefined,\n viewport: BreakpointName,\n sizing?: BlockSizing\n): React.CSSProperties {\n // Skip grid-column when parent manages its own layout (grid, container, form, etc.)\n const parentType = parentBlock?.type\n // A child that EXPLICITLY declares layout.span keeps it inside a grid parent.\n // Otherwise asymmetric 12-col layouts are impossible: the declaration would\n // be silently swallowed. Grid stays the owner only for span-less children\n // (equal auto columns, the default).\n const childDeclaresSpan = block.layout?.span !== undefined\n // A parent that expanded a `repeat` (the repeater family, or any block that\n // repeats) lays its clones out with its own grid/columns — the clones must\n // not carry the surface's 12-column span into it. A grid\n // parent keeps its own rule above.\n const parentRepeats = parentType !== 'grid' && isRepeatExpanded(parentBlock)\n const parentOwnsLayout =\n parentRepeats ||\n (parentType === 'grid' && !childDeclaresSpan) ||\n parentType === 'container' ||\n parentType === 'section' ||\n parentType === 'form' ||\n parentType === 'tabs' ||\n parentType === 'tooltip' ||\n parentType === CHILD_LAYOUT_OWNER\n\n const layout = block.layout ?? DEFAULT_BLOCK_LAYOUT\n const resolved = resolveBlockLayout(layout, viewport)\n\n // Column container children: apply explicit width when span < surface columns\n const parentDirection = parentBlock?.props?.direction as string | undefined\n // A row stacked by the ROW STACKING LAW is not an authored column: its\n // children were row cells, so their partial spans must not become widths.\n const parentStackedFromRow = parentBlock?.props?.stackedFromRow === true\n const isColumnContainer =\n parentType === 'container' &&\n (parentDirection === 'column' || parentDirection === undefined) &&\n !parentStackedFromRow\n\n let columnChildWidth: string | undefined\n if (isColumnContainer && parentBlock) {\n const surfaceCols = getColumnsAtBreakpoint(viewport)\n const parentCols = resolveBlockLayout(parentBlock.layout ?? DEFAULT_BLOCK_LAYOUT, viewport).span\n if (resolved.span < surfaceCols) {\n columnChildWidth = `${(resolved.span / parentCols) * 100}%`\n }\n }\n\n // Row container children: apply flexBasis so spans translate to proportional widths.\n //\n // Weighted columns: a child's OWN `block.style` flex hints win over the span-derived\n // default. The wrapper is the flex item — so `flex`/`flexGrow`/`flexBasis`/`flexShrink`\n // declared on a child must land on the wrapper, not the inner block. When present they\n // fully replace the default span/equal distribution, letting an author express an\n // arbitrary ratio (e.g. `flex:\"1.62 1 0\"` + `flex:\"1 1 0\"` → exact 1.62:1 columns)\n // that the integer-span model cannot. `layout.span` remains the default when no flex\n // hint is given.\n const childStyle = block.style as React.CSSProperties | undefined\n const childHasFlexHint =\n childStyle !== undefined && FLEX_HOIST_KEYS.some((k) => childStyle[k] !== undefined)\n\n const isRowContainer = parentType === 'container' && parentDirection === 'row'\n\n let rowChildStyle: React.CSSProperties | undefined\n // A rail beside a row is NOT one of two equal columns. The default below\n // gives every row child `flex: 1 1 0` — right for two content columns,\n // wrong for chrome: it would stretch a 76px rail to half the row and squeeze\n // the body it exists to sit beside. The block DECLARES its own scope.\n if (isRowContainer && resolveWidthScope(block, viewport) === 'viewport' && !childHasFlexHint) {\n rowChildStyle = { flexGrow: 0, flexShrink: 0, flexBasis: 'auto', alignSelf: 'stretch' }\n } else if (\n isRowContainer &&\n (sizing === 'intrinsic' || hasFixedWidth(block)) &&\n !childHasFlexHint\n ) {\n // The block declared its width is its content (avatar, badge, button…):\n // it keeps that width; whatever sits beside it takes the rest. Without\n // this every such block would take half the row.\n //\n // The same holds for an INSTANCE that states a fixed width (a 56px\n // thumbnail beside a product title). `sizing` is static per block type,\n // so a fluid-by-default block (image) cannot declare it; the instance's\n // own numeric/px width is the declaration. Without it a 56px image took\n // the equal share and squeezed the text beside it into two lines.\n rowChildStyle = { flexGrow: 0, flexShrink: 0, flexBasis: 'auto' }\n } else if (isRowContainer && parentBlock && !childHasFlexHint) {\n // No author flex hint → derive proportional width from the integer span.\n const surfaceCols = getColumnsAtBreakpoint(viewport)\n const parentCols = resolveBlockLayout(parentBlock.layout ?? DEFAULT_BLOCK_LAYOUT, viewport).span\n if (resolved.span < surfaceCols) {\n // Explicit partial span → proportional width\n rowChildStyle = {\n flexBasis: `${(resolved.span / parentCols) * 100}%`,\n flexGrow: 0,\n flexShrink: 0,\n }\n } else {\n // Default/full-width span → equal distribution\n rowChildStyle = { flexGrow: 1, flexShrink: 1, flexBasis: '0' }\n }\n }\n\n // Hoist layout-positioning props (margin/maxWidth/minWidth) to the wrapper div so\n // grid-item centering works (the inner block element is usually width:100%). Flex\n // hints hoist here too so a row-container child's authored ratio reaches the flex\n // item (the wrapper) rather than the inner block.\n const hoistedStyle: React.CSSProperties = {}\n if (block.style) {\n for (const key of LAYOUT_HOIST_KEYS) {\n const val = (block.style as React.CSSProperties)[key]\n if (val !== undefined) {\n ;(hoistedStyle as Record<string, unknown>)[key] = val\n }\n }\n }\n // Auto-center when maxWidth is set without an explicit margin.\n if (\n hoistedStyle.maxWidth !== undefined &&\n hoistedStyle.margin === undefined &&\n hoistedStyle.marginLeft === undefined &&\n hoistedStyle.marginRight === undefined\n ) {\n hoistedStyle.margin = '0 auto'\n // An auto-centred max-width block FILLS up to its max width, as a block\n // box with `max-width` + `margin: 0 auto` does in normal flow. Inside a\n // flex column or a grid cell, auto inline margins cancel `stretch`, so\n // without an explicit width the wrapper shrank to its content and the\n // inner `width:100%` resolved against that shrunken box (\n // a two-pane doc shell collapsed to 307 px and the panes stacked unless\n // the selected text was long, and content columns narrowed).\n // Not applied where the block keeps its own width: an intrinsic block\n // (button, badge), a row cell (its flex basis is the width), a column\n // child with a span-derived width, or an authored non-100% width.\n const authoredWidth = (block.style as React.CSSProperties | undefined)?.width\n if (\n sizing !== 'intrinsic' &&\n !isRowContainer &&\n columnChildWidth === undefined &&\n (authoredWidth === undefined || authoredWidth === '100%')\n ) {\n hoistedStyle.width = '100%'\n }\n }\n\n // Interaction states (block.states) are rendered as scoped `:hover`/`:active`/\n // `:focus-visible` CSS rules elsewhere; here we add a default `transition` to\n // the base wrapper style so the state change animates. Authors can still\n // override via `block.style.transition`, and `prefers-reduced-motion`\n // (SURFACE_BASE_CSS) neutralises it for users who opt out.\n const hasStates = block.states !== undefined && block.states !== null\n const transitionStyle: React.CSSProperties =\n hasStates && (block.style as React.CSSProperties | undefined)?.transition === undefined\n ? { transition: 'all var(--pw-duration-fast, 150ms) var(--pw-easing, ease)' }\n : {}\n\n // GRID items default to min-width:auto, which lets nowrap/max-content content\n // leak its intrinsic width into track sizing even under overflow:hidden\n // (measured: a marquee pushed the whole page 63px). Zero it for grid items\n // only — on FLEX children min-width:auto is load-bearing (equal-distribution\n // rows keep children at least min-content wide; zeroing it made a highlighted\n // word stretch to half the row). An author's own minWidth (hoisted) wins.\n const isGridItem = !parentOwnsLayout || parentType === 'grid'\n return {\n ...(isGridItem ? { minWidth: 0 } : {}),\n ...(!parentOwnsLayout ? { gridColumn: `span ${resolved.span} / span ${resolved.span}` } : {}),\n ...(resolved.offset !== undefined && !parentOwnsLayout\n ? { gridColumnStart: resolved.offset + 1 }\n : {}),\n ...(columnChildWidth !== undefined ? { width: columnChildWidth } : {}),\n ...(rowChildStyle ?? {}),\n ...(resolved.order !== undefined ? { order: resolved.order } : {}),\n ...(resolved.hidden ? { display: 'none' } : {}),\n ...transitionStyle,\n ...hoistedStyle,\n }\n}\n\n/**\n * Render a single block recursively.\n * parentBlock is used to determine the CSS strategy for nested blocks.\n * entitlementCheck gates unentitled blocks.\n * dynamicBlocks provides dynamic block descriptors for fallback rendering.\n */\nfunction renderBlock(\n { block: rawBlock, context, components }: BlockRendererProps,\n parentBlock?: Block,\n entitlementCheck?: (blockType: string) => boolean,\n dynamicBlocks?: ReadonlyMap<string, DynamicBlockDescriptor>,\n renderBlockWrapper?: RenderBlockWrapperFn\n): React.ReactNode {\n // Per-prop responsive styles (block.style values that are `{ xs?, … }` maps)\n // can't be expressed inline as media queries — flatten them to their base\n // value here so the inline path (this block + computeBlockLayoutStyle hoists)\n // sees a flat `Record<string,string>`; the larger-breakpoint values are\n // emitted as scoped media-query CSS by collectResponsiveStyleCss.\n const block = applyRowStacking(\n flattenResponsiveStyle(rawBlock),\n (context.viewport ?? 'lg') as BreakpointName,\n components\n )\n // Layout applies to EVERY path below (static/dynamic/unknown/gated) so installed\n // dynamic blocks get the same grid span/width/centering as static ones. Previously\n // only the static path applied it → full-span dynamic sections collapsed side-by-side.\n const layoutStyle = computeBlockLayoutStyle(\n block,\n parentBlock,\n (context.viewport ?? 'lg') as BreakpointName,\n components[block.type]?.sizing\n )\n\n // Scope stamp. A viewport audit needs to see the declaration in the DOM to\n // say \"viewport was declared but the block does not reach the edge\"; the\n // style alone carries the result, not the declaration.\n const scopeAttr =\n resolveWidthScope(block, (context.viewport ?? 'lg') as BreakpointName) === 'viewport'\n ? { 'data-pw-width-scope': 'viewport' }\n : {}\n\n // Gate check — show placeholder for unentitled blocks\n // Dynamic blocks with descriptors are entitled (installed + built)\n if (entitlementCheck && !entitlementCheck(block.type) && !dynamicBlocks?.has(block.type)) {\n return emitBlockWrapper(\n block,\n baseWrapperProps(block, layoutStyle, scopeAttr),\n <GatedBlockPlaceholder blockId={block.id} blockType={block.type} />,\n parentBlock,\n renderBlockWrapper\n )\n }\n\n // Install-only render — when the world has the atom\n // installed (CDN bundle URL on the descriptor) the dynamic wrapper\n // takes over. `customComponents` may still supply test/preview-time\n // component overrides, but the legacy `defaultBlockComponents` map is\n // gone; unmatched block types render as \"Unknown block\" placeholders.\n const dynamicDescriptor = dynamicBlocks?.get(block.type)\n if (dynamicDescriptor) {\n let dynamicChildren: React.ReactNode = null\n if (block.children && block.children.length > 0) {\n dynamicChildren = block.children.map((child) =>\n renderBlock(\n { block: child, context, components },\n block,\n entitlementCheck,\n dynamicBlocks,\n renderBlockWrapper\n )\n )\n }\n return emitBlockWrapper(\n block,\n { ...baseWrapperProps(block, layoutStyle, scopeAttr), 'data-dynamic-block': block.type },\n <BlockErrorBoundary blockId={block.id} blockType={block.type}>\n <DynamicBlockWrapper descriptor={dynamicDescriptor} block={stripHoistedStyle(block)} context={context}>\n {dynamicChildren}\n </DynamicBlockWrapper>\n </BlockErrorBoundary>,\n parentBlock,\n renderBlockWrapper\n )\n }\n\n const Component = components[block.type]\n\n if (!Component) {\n console.warn(`Unknown block type: ${block.type}`)\n // Render children so a partial subtree still shows when a block type isn't\n // installed (e.g. an uninstalled \"Container\" wrapper), but DON'T surface a\n // visible \"Unknown block: <type>\" placeholder to end users on published /\n // preview surfaces — that read as a broken page. The console.warn above and\n // the `data-unknown-type` attribute keep it diagnosable, and the authoring\n // editor uses its own EditableBlock placeholder, so nothing is lost there.\n let unknownChildren: React.ReactNode = null\n if (block.children && block.children.length > 0) {\n unknownChildren = block.children.map((child) =>\n renderBlock(\n { block: child, context, components },\n block,\n entitlementCheck,\n dynamicBlocks,\n renderBlockWrapper\n )\n )\n }\n return emitBlockWrapper(\n block,\n { ...baseWrapperProps(block, layoutStyle, scopeAttr), 'data-unknown-type': block.type },\n <>{unknownChildren}</>,\n parentBlock,\n renderBlockWrapper\n )\n }\n\n // Recursively render children — current block becomes the parent\n let children: React.ReactNode = null\n if (block.children && block.children.length > 0) {\n children = block.children.map((child) =>\n renderBlock(\n { block: child, context, components },\n block,\n entitlementCheck,\n dynamicBlocks,\n renderBlockWrapper\n )\n )\n }\n\n // TODO: When FormBlock contract includes `bindToEntity` prop,\n // call attachFormEntityBridge(bus, entityStore, { formId: block.id, ...block.props.bindToEntity })\n // Requires: platform/entities capability active (platform/input retired).\n // See packages/runtime/src/forms/form-entity-bridge.ts for the bridge implementation.\n\n return emitBlockWrapper(\n block,\n baseWrapperProps(block, layoutStyle, scopeAttr),\n <BlockErrorBoundary blockId={block.id} blockType={block.type}>\n <Component block={stripHoistedStyle(block)} props={block.props ?? {}} context={context}>\n {children}\n </Component>\n </BlockErrorBoundary>,\n parentBlock,\n renderBlockWrapper\n )\n}\n\n// ============================================================\n// BASE CSS STANDARD (box-sizing reset)\n// ============================================================\n\n/**\n * Scoped box-sizing reset injected at the surface render root.\n *\n * `box-sizing` is NOT an inherited CSS property, so setting it only on the\n * `[data-pw-surface]` root would leave every descendant at the browser\n * default `content-box`. Under `content-box`, a block declared `width:100%`\n * with padding (e.g. `layout/section` padding:80) computes its border-box\n * width as `100% + padding` and overflows its parent → horizontal scroll.\n * A descendant selector (`[data-pw-surface] *`) is therefore required so\n * every block inside the surface respects its declared width.\n *\n * The reset is scoped to the `[data-pw-surface]` subtree (root + descendants\n * + their generated `::before`/`::after` boxes) rather than emitted as a\n * global `*{}` rule so it cannot leak into and reset a host page that embeds\n * the surface. This makes the standard ship from the runtime itself — a host\n * app, the embed bundle, and a preview tool all inherit it for free.\n */\nconst SURFACE_BASE_CSS =\n '[data-pw-surface],' +\n '[data-pw-surface] *,' +\n '[data-pw-surface] *::before,' +\n '[data-pw-surface] *::after{box-sizing:border-box}' +\n // Horizontal-overflow guard. Reference pages protect themselves with\n // body{overflow-x:hidden}; a surface must not rely on its host for that.\n // `clip` (not `hidden`) so no scroll container is created and position:sticky\n // descendants keep working.\n '[data-pw-surface]{overflow-x:clip}' +\n // Surface root paints the THEME ground (light/dark). Without this the\n // root stays transparent and content OUTSIDE a card (a bare heading/section)\n // shows the host page's own background — fine in light mode, but in dark mode\n // (derived dark vars) it left light text on a white page → unreadable. Painting\n // background+color from the tokens makes the whole surface follow the mode\n // (the dark <style> block re-resolves --pw-color-* under [data-pw-theme]/@media).\n // Scoped to the root only (not descendants) so blocks still set their own.\n '[data-pw-surface]{background:var(--pw-color-background);color:var(--pw-color-text);' +\n // The BODY FONT, bound on the root like the ground. Only the published\n // theme.css bound it (on html,body), so a serif-bodied theme (rose) read\n // serif on the published page and in the host font on the canvas and in an\n // embed. Blocks inherit it; a block that sets its own font still wins.\n // `inherit` keeps the host font when a theme declares none.\n 'font-family:var(--pw-font-family,inherit);font-size:var(--pw-font-size-base,inherit);' +\n 'line-height:var(--pw-line-height-body,inherit)}' +\n // Controls take the surface font. Browsers give button, input,\n // select and textarea their OWN system font instead of inheriting, so a\n // themed page showed its body face everywhere except in its controls (a\n // serif theme rendered sans-serif buttons). Family only: sizes and colours stay the\n // block's. :where() keeps specificity at zero so a block's own font wins.\n '[data-pw-surface] :where(button,input,select,textarea,optgroup){font-family:inherit}' +\n // Centralised keyboard focus ring (WCAG 2.4.7/2.4.11) — every focusable element\n // inside the surface gets the theme's --pw-focus-ring-* (with on-brand AA fallbacks)\n // instead of each block hard-coding (or dropping) a ring. :where() = zero\n // specificity so a block can still override. A tenant re-skin changes the ring in\n // one place; it can never silently lose focus visibility.\n '[data-pw-surface] :where(a,button,input,select,textarea,[tabindex]:not([tabindex=\"-1\"])):focus-visible{' +\n 'outline:var(--pw-focus-ring-width,2px) solid var(--pw-focus-ring-color,#4f46e5);' +\n 'outline-offset:var(--pw-focus-ring-offset,2px)}' +\n // Named animation keyframes shipped from the runtime so a block can drive\n // motion via `block.style.animation: 'pw-pulse 1.5s ease-in-out infinite'` (or\n // pw-marquee / pw-fade-in) WITHOUT each surface defining @keyframes (block.style\n // can't). Names are pw-* to avoid host-page collision. Covers the soundwave-pulse\n // / logo-marquee patterns that previously had no offline-capable expression.\n '@keyframes pw-pulse{0%,100%{opacity:1}50%{opacity:.45}}' +\n '@keyframes pw-fade-in{from{opacity:0}to{opacity:1}}' +\n '@keyframes pw-marquee{from{transform:translateX(0)}to{transform:translateX(-50%)}}' +\n // Batch-1 animation library — entrance/loop motion blocks can drive via\n // block.style.animation without defining @keyframes.\n '@keyframes pw-slide-up{from{transform:translateY(8px);opacity:0}to{transform:translateY(0);opacity:1}}' +\n '@keyframes pw-slide-down{from{transform:translateY(-8px);opacity:0}to{transform:translateY(0);opacity:1}}' +\n '@keyframes pw-scale-in{from{transform:scale(.96);opacity:0}to{transform:scale(1);opacity:1}}' +\n '@keyframes pw-spin{from{transform:rotate(0deg)}to{transform:rotate(360deg)}}' +\n '@keyframes pw-bounce{0%,100%{transform:translateY(0)}50%{transform:translateY(-25%)}}' +\n // Spring ENTRANCE (Dalga 1, core (d)). pw-bounce is a vertical loop and the\n // theme's --pw-easing-bounce token had no entrance keyframe to ride on, so\n // delivered apps reached for pw-pulse. The overshoot is the keyframe's own\n // timing function: `animation: pw-spring-in .4s` springs with no easing\n // named, a theme re-tunes it through the token, and the fallback is the\n // token's canonical default (surface-theme.ts). Reduced-motion gated below.\n '@keyframes pw-spring-in{from{transform:scale(.9);opacity:0;' +\n 'animation-timing-function:var(--pw-easing-bounce,cubic-bezier(0.34, 1.56, 0.64, 1))}' +\n 'to{transform:scale(1);opacity:1}}' +\n // Interaction-state transitions (theme motion tokens): every interactive\n // element eases its colour/elevation changes instead of snapping — the\n // micro-polish half of hover/focus/pressed feedback that inline block\n // styles cannot express (pseudo-states need a stylesheet). :where() keeps\n // specificity at zero so any block's own transition wins; the property\n // list is colour/elevation-only (no `all`) so layout-affecting properties\n // never animate by accident. Durations/easing come from the theme's motion\n // tokens with the old instant behaviour recoverable per-theme by setting\n // them to 0ms. The reduced-motion rule below already neutralises these.\n '[data-pw-surface] :where(a,button,input,select,textarea,[role=\"button\"]):not(:disabled){' +\n 'transition:background-color var(--pw-duration-fast,150ms) var(--pw-easing,ease),' +\n 'color var(--pw-duration-fast,150ms) var(--pw-easing,ease),' +\n 'border-color var(--pw-duration-fast,150ms) var(--pw-easing,ease),' +\n 'box-shadow var(--pw-duration-fast,150ms) var(--pw-easing,ease),' +\n 'opacity var(--pw-duration-fast,150ms) var(--pw-easing,ease),' +\n 'filter var(--pw-duration-fast,150ms) var(--pw-easing,ease)}' +\n // Honour reduced-motion: neutralise pw-* animations + transitions for users who\n // opt out (a11y). Covers pseudo-elements too.\n '@media (prefers-reduced-motion:reduce){[data-pw-surface] *,[data-pw-surface] *::before,[data-pw-surface] *::after{animation-duration:.01ms!important;animation-iteration-count:1!important;transition-duration:.01ms!important}}' +\n // iOS safe-area insets. Host apps already set `viewport-fit=cover`, so\n // env(safe-area-inset-*) is live but nothing consumed it → on notch /\n // Dynamic-Island / home-indicator devices sticky navbars tuck under the notch\n // and trailing footers/bottom bars sit under the home indicator. These rules\n // make EVERY published surface (embed, preview, host app) inset-aware at a\n // single point. The surface root takes the horizontal insets; navbar/footer\n // block roots (which emit data-block-type) take the vertical ones. max(N,env)\n // keeps each ≥ its normal value when no inset exists (env resolves to 0px),\n // so a static mid-page navbar only ever gains pad on an actual inset device.\n '[data-pw-surface]{' +\n 'padding-left:max(0px,env(safe-area-inset-left));' +\n 'padding-right:max(0px,env(safe-area-inset-right))}' +\n '[data-pw-surface] [data-block-type=\"navbar\"]{' +\n 'padding-top:max(12px,env(safe-area-inset-top))}' +\n '[data-pw-surface] [data-block-type=\"footer\"]{' +\n 'padding-bottom:max(48px,env(safe-area-inset-bottom))}'\n\n// ============================================================\n// SURFACE RENDERER COMPONENT\n// ============================================================\n\n/**\n * SurfaceRenderer component\n *\n * Renders a surface definition to React components. surface\n * definitions come from the pack-derived registry (the host's installed\n * blocks and receipts) rather than hardcoded starter exports.\n */\nexport function SurfaceRenderer({\n surface,\n capabilities = [],\n theme = 'light',\n projectTheme,\n projectDarkTheme,\n basePath = '',\n onEvent,\n components: customComponents,\n className,\n viewport: viewportProp,\n gap,\n padding,\n imageAdapter,\n entityFacade,\n connections,\n renderBlockWrapper,\n interactionMode = 'live',\n}: SurfaceRendererProps): React.ReactElement {\n // Use explicit viewport or auto-detect\n const autoViewport = useViewport()\n const viewport = viewportProp ?? autoViewport\n // `onEvent` is a pure notification — it ALWAYS flows, even in inert mode, so\n // the host (editor/preview) can observe interactions and give feedback. The\n // `interactionMode` flag (threaded into BlockContext below) is what gates real\n // side-effects: blocks must skip navigation / data writes when `inert`.\n const effectiveOnEvent = onEvent\n\n // Canonical bus → renderer `onEvent` bridge. The `BehaviorSurfaceProvider`\n // subscribes this to the bus' global `*` wildcard, so every block-emitted\n // `SurfaceEventDescriptor` (contracts vocabulary: namespaced `type` string +\n // `surfaceId`/`payload`/`timestamp`) reaches the renderer's `onEvent` handler\n // — i.e. `DataBoundSurfaceRenderer.handleEvent`, which dispatches a form's\n // `payload.action` setState and a block's `action` prop. The handler consumes\n // the legacy `SurfaceEvent` shape (`{type, blockId, payload}`), so we project\n // the descriptor onto it: the canonical namespaced type maps to its legacy\n // equivalent, with anything else collapsing to `'custom'` (blockId/payload pass\n // through unchanged — that is all the dispatcher reads).\n const busOnEvent = React.useMemo(() => {\n if (!effectiveOnEvent) return undefined\n return (event: SurfaceEventDescriptor): void => {\n // Surface lifecycle events (`surface:load`/`surface:unload`) are bus-internal\n // and were never part of the legacy `onEvent` host/dispatcher contract — only\n // block interactions flow to the renderer's handler. Skip them so the host\n // callback (and the DataBound dispatcher) see exactly the block-level events\n // they saw under the retired `context.onEvent` path.\n if (event.type.startsWith('surface:')) return\n effectiveOnEvent({\n type: mapCanonicalEventType(event.type),\n blockId: event.blockId ?? '',\n ...(event.payload !== undefined ? { payload: event.payload } : {}),\n canonicalType: event.type,\n })\n }\n }, [effectiveOnEvent])\n // Build capability map\n const capabilityMap = React.useMemo(() => {\n const map = new Map<CapabilityType, CapabilityProvider>()\n for (const cap of capabilities) {\n map.set(cap.type, cap)\n }\n return map\n }, [capabilities])\n\n // Build block context (theme removed from BlockContext)\n const context: BlockContext = React.useMemo(\n () => ({\n capabilities: capabilityMap,\n basePath,\n onEvent: effectiveOnEvent,\n imageAdapter,\n viewport,\n interactionMode,\n }),\n [capabilityMap, basePath, effectiveOnEvent, imageAdapter, viewport, interactionMode]\n )\n\n // Create image component override if adapter is provided\n const imageComponentOverride = React.useMemo(() => {\n if (!imageAdapter) return undefined\n return { image: createImageBlockWithAdapter(imageAdapter) }\n }, [imageAdapter])\n\n // Merge component registries (image adapter takes precedence over custom components)\n // `defaultBlockComponents` removed; `customComponents`\n // is now the only static seed for the registry alongside the image override.\n const componentRegistry = React.useMemo(\n () => mergeComponentRegistries(customComponents, imageComponentOverride),\n [customComponents, imageComponentOverride]\n )\n\n // Read entitlements from context\n const { isBlockEntitled, loaded: entitlementsLoaded } = useEntitlements()\n const entitlementCheck = entitlementsLoaded ? isBlockEntitled : undefined\n\n // Read dynamic block descriptors\n const { blocks: dynamicBlockMap } = useDynamicBlocks()\n\n // The root FLOWS; the measure lives in an INNER container.\n //\n // If the root carried grid + `maxWidth` + `margin:0 auto`, persistent\n // navigation chrome would sit inside the centred box too (at 1536px a rail\n // would start 218px in from the screen edge). The rule: chrome belongs to\n // the viewport, the body to the measure.\n //\n // Gap/padding come from CSS variables so the `surface.theme.layout` tokens\n // take effect; the variables are set on this element through `themeVars`.\n const rootLayoutStyle = resolveSurfaceRootStyle(gap ?? 'var(--pw-layout-surface-gap)', 0)\n const measureStyle = resolveMeasureStyle(\n viewport,\n gap ?? 'var(--pw-layout-surface-gap)',\n padding ?? 'var(--pw-layout-surface-padding)'\n )\n\n // Resolve appearance atom (theme + layout + styleVariables unified).\n // Theme tokens + custom CSS vars both live inside surface.appearance.config.\n const appearanceVars = React.useMemo(\n () => resolveAppearanceVars(surface.appearance, projectTheme),\n [surface.appearance, projectTheme]\n )\n\n const rootStyle = React.useMemo(\n () => ({\n ...rootLayoutStyle,\n ...appearanceVars,\n }),\n [rootLayoutStyle, appearanceVars]\n )\n\n // Surface-scope key for every emitted <style> rule. The embed autoloader\n // hydrates EVERY [data-pw-surface] element in a document, so a host page can\n // hold several surfaces at once; scoping by the ATTRIBUTE VALUE keeps each\n // surface's rules off its siblings. Undefined only when a surface has no id\n // (isolated test renders), where the historical value-less selector is fine.\n const scopeId = surface.id || undefined\n\n // Per-breakpoint visibility (hideOn/showOn). Media queries can't be\n // expressed inline, so the runtime emits scoped CSS rules — keyed by each\n // block's `data-block-id` — into the surface stylesheet (alongside the\n // box-sizing reset). Empty string when no block uses hideOn/showOn → existing\n // surfaces emit zero extra bytes.\n const visibilityCss = React.useMemo(\n () => collectVisibilityCss(surface.blocks, scopeId),\n [surface.blocks, scopeId]\n )\n\n // Interaction-state styling (block.states). Pseudo-classes (:hover/:active/\n // :focus-visible) can't be expressed inline, so the runtime emits scoped CSS\n // rules — keyed by each block's `data-block-id` — alongside the visibility CSS.\n // Empty string when no block uses `states` → existing surfaces emit zero bytes.\n const statesCss = React.useMemo(\n () => collectStatesCss(surface.blocks, scopeId),\n [surface.blocks, scopeId]\n )\n\n // Conditional-state styling (block.conditionalStates) — aria/data/disabled/\n // checked/:has variants. Attribute selectors and these pseudo-classes can't be\n // expressed inline, so the runtime emits scoped `[data-block-id]<selector>`\n // rules (with `!important` to beat component inline defaults). Empty string\n // when no block uses `conditionalStates` → existing surfaces emit zero bytes.\n const conditionalStatesCss = React.useMemo(\n () => collectConditionalStatesCss(surface.blocks, scopeId),\n [surface.blocks, scopeId]\n )\n\n // Per-prop responsive styles (block.style values that vary by breakpoint).\n // The base (xs) value is applied inline by the renderer (flattenResponsiveStyle);\n // the larger breakpoints are emitted here as scoped min-width media-query rules\n // keyed by each block's `data-block-id`. Empty string when no block uses a\n // responsive style value → existing surfaces emit zero bytes.\n const responsiveStyleCss = React.useMemo(\n () => collectResponsiveStyleCss(surface.blocks, scopeId),\n [surface.blocks, scopeId]\n )\n\n // Group-hover styling (block.groupRoot + descendant block.groupStates.hover) —\n // a parent marked groupRoot, on :hover, restyles descendants declaring\n // groupStates. The ancestor `:hover` + descendant relationship can't be\n // expressed inline, so the runtime emits scoped\n // `[data-block-id=\"<root>\"]:hover [data-block-id=\"<desc>\"]{…}` rules keyed by\n // both block ids. Empty string when no block uses groupStates under a\n // groupRoot → existing surfaces emit zero bytes.\n const groupStatesCss = React.useMemo(\n () => collectGroupStatesCss(surface.blocks, scopeId),\n [surface.blocks, scopeId]\n )\n\n // Dark theme variant (appearance.config.darkTheme). Light vars stay inline on\n // the root; the dark vars override under BOTH `[data-pw-theme=\"dark\"]` (manual\n // force) AND `@media (prefers-color-scheme:dark)` (auto). Empty string when no\n // darkTheme is declared.\n const darkThemeCss = React.useMemo(() => {\n // Same `projectTheme` middle layer the light vars above resolve with —\n // otherwise a project-themed page is on-brand in light and platform-default\n // in dark.\n const darkVars = resolveAppearanceDarkVars(surface.appearance, projectTheme, projectDarkTheme)\n // `appearance.config.mode.policy` decides whether the dark rule\n // exists at all (light), always applies (dark) or follows the device.\n return buildDarkThemeCss(darkVars, scopeId, resolveAppearanceMode(surface.appearance?.config).policy)\n }, [surface.appearance, projectTheme, projectDarkTheme, scopeId])\n\n // Surface keyframe registry (appearance.config.keyframes) — arbitrary named\n // @keyframes a block can reference via `block.style.animation: 'pw-kf-<name> …'`\n // (each declared name is prefixed `pw-kf-`). Empty string when no registry is\n // declared. The prefers-reduced-motion gate in SURFACE_BASE_CSS neutralises\n // these for users who opt out (it matches by animation, not keyframe name).\n const keyframesCss = React.useMemo(\n () => buildKeyframesCss(resolveAppearanceKeyframes(surface.appearance)),\n [surface.appearance]\n )\n\n // extract form→entity bridge configs from surface capabilities\n const entityFormBindings = React.useMemo<readonly FormEntityBridgeConfig[] | undefined>(() => {\n // NO LONGER GATED ON THE ENTITY FACADE. A form now writes to a SOURCE, and\n // a rest-backed source has no facade behind it — requiring one here meant\n // a form pointed at anyone else's endpoint silently never attached.\n if (!surface.capabilities?.length) return undefined\n const entityCap = surface.capabilities.find((c) => isCapability(c, 'platform/entities'))\n const formBindings = entityCap?.config?.formBindings\n if (!Array.isArray(formBindings) || formBindings.length === 0) return undefined\n return formBindings as readonly FormEntityBridgeConfig[]\n }, [surface.capabilities])\n\n /**\n * The read sources, so a form binding's `sourceId` can be resolved.\n *\n * The same declaration the persistence capability already carries — a form\n * writes to something the page also knows how to read, which is what makes\n * \"refresh after write\" meaningful.\n */\n const formWriteSources = React.useMemo<readonly SurfaceDataSourceDefinition[] | undefined>(() => {\n const cap = surface.capabilities?.find((c) => isCapability(c, 'platform/persistence'))\n const sources = cap?.config?.dataSources\n return Array.isArray(sources) && sources.length > 0\n ? (sources as readonly SurfaceDataSourceDefinition[])\n : undefined\n }, [surface.capabilities])\n\n // Render blocks — in scope groups, keeping source order.\n //\n // `container` groups are wrapped in the measured container; `viewport`\n // groups become DIRECT children of the root. The escape is PLACEMENT, not a\n // CSS trick: `width:100vw` counts the scrollbar too and would produce ~15px\n // of horizontal overflow on every page with a vertical scrollbar.\n const renderOne = (block: Block) =>\n renderBlock(\n {\n block,\n context,\n components: componentRegistry,\n },\n undefined,\n entitlementCheck,\n dynamicBlockMap,\n renderBlockWrapper\n )\n\n const renderedBlocks = chunkByWidthScope(surface.blocks, viewport).map((chunk, i) =>\n chunk.scope === 'viewport' ? (\n <React.Fragment key={`pw-vp-${i}`}>{chunk.blocks.map(renderOne)}</React.Fragment>\n ) : (\n <div key={`pw-ct-${i}`} data-pw-measure=\"\" style={measureStyle}>\n {chunk.blocks.map(renderOne)}\n </div>\n )\n )\n\n return (\n // SurfaceConnectionsContext carries the connections\n // context (world connections + engine registry) to blocks on the\n // engine-bridge path. null (host didn't opt in) = today's behavior.\n <SurfaceConnectionsContext.Provider value={connections ?? null}>\n {/*. EntityFacadeContext.Provider wraps the entire render tree */}\n <EntityFacadeContext.Provider value={entityFacade ?? null}>\n <BehaviorSurfaceProvider\n surfaceId={surface.id ?? ''}\n {...(entityFormBindings ? { entityFormBindings } : {})}\n {...(formWriteSources ? { dataSources: formWriteSources } : {})}\n {...(busOnEvent ? { onEvent: busOnEvent } : {})}\n blocks={surface.blocks}\n >\n {/* Shell selection (split shells) — ONE store per surface, so a list, a\n detail pane and any header reading the same key agree. `syncUrl`\n follows interactionMode: an inert canvas selects without moving the\n host's address bar. */}\n <ShellSelectionProvider syncUrl={interactionMode !== 'inert'}>\n <div\n className={className}\n style={rootStyle}\n // Carries the surface id so scoped rules can target THIS surface only.\n // Empty string when the surface has no id — still matches the bare\n // `[data-pw-surface]` selector the base CSS and the embed autoloader use.\n data-pw-surface={scopeId ?? ''}\n data-surface-renderer\n data-theme={theme}\n data-viewport={viewport}\n >\n {/* BASE CSS standard: scoped box-sizing reset, first child so it\n applies before any block paints. Scoped to [data-pw-surface] so\n it cannot leak to a host page. */}\n <style data-pw-base-css>{SURFACE_BASE_CSS}</style>\n {/* Per-breakpoint visibility (hideOn/showOn) — media-query rules\n keyed by block id. Only present when a block opts in. */}\n {visibilityCss ? (\n <style data-pw-visibility-css>{visibilityCss}</style>\n ) : null}\n {/* Interaction-state styling (block.states) — scoped\n :hover/:active/:focus-visible rules keyed by block id. Only\n present when a block opts in. */}\n {statesCss ? <style data-pw-states-css>{statesCss}</style> : null}\n {/* Conditional-state styling (block.conditionalStates) — scoped\n aria/data/disabled/checked/:has rules keyed by block id. Only\n present when a block opts in. */}\n {conditionalStatesCss ? (\n <style data-pw-conditional-states-css>{conditionalStatesCss}</style>\n ) : null}\n {/* Per-prop responsive styles (block.style breakpoint maps) —\n min-width media-query rules keyed by block id. Only present when a\n block opts in; base value stays inline. */}\n {responsiveStyleCss ? (\n <style data-pw-responsive-style-css>{responsiveStyleCss}</style>\n ) : null}\n {/* Group-hover styling (block.groupRoot + descendant\n block.groupStates) — scoped\n `[data-block-id=\"<root>\"]:hover [data-block-id=\"<desc>\"]` rules.\n Only present when a block opts in. */}\n {groupStatesCss ? (\n <style data-pw-group-states-css>{groupStatesCss}</style>\n ) : null}\n {/* Dark theme variant (appearance.config.darkTheme) — scoped\n force-dark + prefers-color-scheme:dark var overrides. Only present\n when a darkTheme is declared. */}\n {darkThemeCss ? <style data-pw-dark-theme-css>{darkThemeCss}</style> : null}\n {/* Surface keyframe registry (appearance.config.keyframes) — arbitrary\n @keyframes pw-kf-<name> a block can reference via\n block.style.animation. Only present when a registry is declared. */}\n {keyframesCss ? <style data-pw-keyframes-css>{keyframesCss}</style> : null}\n {renderedBlocks}\n </div>\n </ShellSelectionProvider>\n </BehaviorSurfaceProvider>\n </EntityFacadeContext.Provider>\n </SurfaceConnectionsContext.Provider>\n )\n}\n\n// ============================================================\n// BLOCK RENDERER (STANDALONE)\n// ============================================================\n\n/**\n * Standalone block renderer\n *\n * Renders a single block without a surface wrapper.\n */\nexport function BlockRenderer({\n block,\n capabilities = [],\n theme: _theme = 'light',\n basePath = '',\n onEvent,\n components: customComponents,\n imageAdapter,\n}: {\n block: Block\n capabilities?: CapabilityProvider[]\n theme?: 'light' | 'dark'\n basePath?: string\n onEvent?: SurfaceRendererProps['onEvent']\n components?: Partial<BlockComponentRegistry>\n imageAdapter?: ImageAdapter\n}): React.ReactElement {\n // Build capability map\n const capabilityMap = React.useMemo(() => {\n const map = new Map<CapabilityType, CapabilityProvider>()\n for (const cap of capabilities) {\n map.set(cap.type, cap)\n }\n return map\n }, [capabilities])\n\n // Build block context (theme removed from BlockContext)\n const context: BlockContext = React.useMemo(\n () => ({\n capabilities: capabilityMap,\n basePath,\n onEvent,\n imageAdapter,\n }),\n [capabilityMap, basePath, onEvent, imageAdapter]\n )\n\n // Create image component override if adapter is provided\n const imageComponentOverride = React.useMemo(() => {\n if (!imageAdapter) return undefined\n return { image: createImageBlockWithAdapter(imageAdapter) }\n }, [imageAdapter])\n\n // Merge component registries\n // `defaultBlockComponents` retired; `customComponents`\n // is the only static seed (defaulted to {}) alongside the image override.\n const componentRegistry = React.useMemo(\n () => mergeComponentRegistries(customComponents, imageComponentOverride),\n [customComponents, imageComponentOverride]\n )\n\n return renderBlock({ block, context, components: componentRegistry }) as React.ReactElement\n}\n\n// ============================================================\n// UTILITY FUNCTIONS\n// ============================================================\n\n/**\n * Get all block IDs from a surface\n */\nexport function getBlockIds(blocks: readonly Block[]): string[] {\n const ids: string[] = []\n\n function collectIds(block: Block): void {\n ids.push(block.id)\n if (block.children) {\n for (const child of block.children) {\n collectIds(child)\n }\n }\n }\n\n for (const block of blocks) {\n collectIds(block)\n }\n\n return ids\n}\n\n/**\n * Find a block by ID in a surface\n */\nexport function findBlockById(blocks: readonly Block[], id: string): Block | undefined {\n for (const block of blocks) {\n if (block.id === id) {\n return block\n }\n if (block.children) {\n const found = findBlockById(block.children, id)\n if (found) {\n return found\n }\n }\n }\n return undefined\n}\n\n/**\n * Update a block by ID in a surface\n */\nexport function updateBlockById(\n blocks: readonly Block[],\n id: string,\n updates: Partial<Block>\n): Block[] {\n return blocks.map((block) => {\n if (block.id === id) {\n return { ...block, ...updates }\n }\n if (block.children) {\n return {\n ...block,\n children: updateBlockById(block.children, id, updates),\n }\n }\n return block\n })\n}\n"]}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Expression Resolution for Block Props
3
+ *
4
+ * Resolves {{expression}} placeholders in block prop values.
5
+ * Uses the existing expression engine (evaluate/interpolate) from surface/expression.
6
+ *
7
+ * Key behavior:
8
+ * - Whole-value: "{{items}}" returns raw value (array, object, etc.)
9
+ * - String interpolation: "Total: {{count}}" returns interpolated string
10
+ * - Recursively walks block tree and nested objects/arrays in props
11
+ *
12
+ * @module @pwfabric/runtime/render/resolve-expressions
13
+ */
14
+ import type { Block } from '@pwfabric/core';
15
+ import type { ExpressionContext } from '../surface/expression.js';
16
+ /**
17
+ * Resolve a single string value.
18
+ *
19
+ * - If the string is exactly "{{expr}}", evaluate and return the raw value (preserving type).
20
+ * - If the string contains embedded "{{expr}}", interpolate and return a string.
21
+ * - Otherwise return as-is.
22
+ */
23
+ export declare function resolveString(value: string, context: ExpressionContext): unknown;
24
+ /**
25
+ * Resolve all {{expression}} placeholders in a block tree.
26
+ *
27
+ * Creates a deep copy of the blocks with all string prop values
28
+ * containing expressions resolved against the provided data context.
29
+ *
30
+ * @param blocks - Block array to resolve
31
+ * @param data - Data context (keyed by source ID, plus 'state')
32
+ * @param helpers - Optional additional helper functions
33
+ * @returns New block array with resolved prop values
34
+ */
35
+ export declare function resolveBlockExpressions(blocks: readonly Block[], data: Record<string, unknown>, helpers?: Record<string, (...args: unknown[]) => unknown>): Block[];
36
+ /** True when this resolved block expanded a `repeat` — its children are clones. */
37
+ export declare function isRepeatExpanded(block: Block | undefined): boolean;
@@ -0,0 +1,309 @@
1
+ /**
2
+ * Expression Resolution for Block Props
3
+ *
4
+ * Resolves {{expression}} placeholders in block prop values.
5
+ * Uses the existing expression engine (evaluate/interpolate) from surface/expression.
6
+ *
7
+ * Key behavior:
8
+ * - Whole-value: "{{items}}" returns raw value (array, object, etc.)
9
+ * - String interpolation: "Total: {{count}}" returns interpolated string
10
+ * - Recursively walks block tree and nested objects/arrays in props
11
+ *
12
+ * @module @pwfabric/runtime/render/resolve-expressions
13
+ */
14
+ import { BREAKPOINT_ORDER } from '@pwfabric/core';
15
+ import { evaluate, interpolate, createExpressionContext } from '../surface/expression.js';
16
+ // ============================================================
17
+ // WHOLE-VALUE PATTERN
18
+ // ============================================================
19
+ /**
20
+ * Matches a string that is exactly one expression placeholder with no surrounding text.
21
+ * e.g. "{{products}}" or "{{ state.x === 'a' ? 'primary' : 'outline' }}"
22
+ * The inner capture uses a negative lookahead to prevent matching across }} boundaries,
23
+ * so "{{a}} · {{b}}" is NOT treated as a whole-value expression.
24
+ */
25
+ const WHOLE_VALUE_PATTERN = /^\{\{((?:(?!\}\}).)+)\}\}$/s;
26
+ /**
27
+ * Matches strings that contain at least one expression placeholder.
28
+ */
29
+ const HAS_EXPRESSION_PATTERN = /\{\{.+?\}\}/;
30
+ // ============================================================
31
+ // STRING RESOLUTION
32
+ // ============================================================
33
+ /**
34
+ * Resolve a single string value.
35
+ *
36
+ * - If the string is exactly "{{expr}}", evaluate and return the raw value (preserving type).
37
+ * - If the string contains embedded "{{expr}}", interpolate and return a string.
38
+ * - Otherwise return as-is.
39
+ */
40
+ export function resolveString(value, context) {
41
+ // Check for whole-value expression first
42
+ const wholeMatch = WHOLE_VALUE_PATTERN.exec(value);
43
+ if (wholeMatch) {
44
+ const expr = (wholeMatch[1] ?? '').trim();
45
+ const result = evaluate(expr, context);
46
+ if (result.success) {
47
+ return result.value;
48
+ }
49
+ // On failure, return original string as fallback
50
+ return value;
51
+ }
52
+ // Check for embedded expressions
53
+ if (HAS_EXPRESSION_PATTERN.test(value)) {
54
+ const result = interpolate(value, context);
55
+ if (result.success) {
56
+ return result.value;
57
+ }
58
+ // On failure, return original string as fallback
59
+ return value;
60
+ }
61
+ // No expressions, return as-is
62
+ return value;
63
+ }
64
+ // ============================================================
65
+ // PROP VALUE RESOLUTION
66
+ // ============================================================
67
+ /**
68
+ * Recursively resolve expressions in a prop value.
69
+ * - Strings are checked for expressions
70
+ * - Arrays and plain objects are traversed
71
+ * - Other types pass through unchanged
72
+ */
73
+ function resolveValue(value, context) {
74
+ if (typeof value === 'string') {
75
+ return resolveString(value, context);
76
+ }
77
+ if (Array.isArray(value)) {
78
+ return value.map((item) => resolveValue(item, context));
79
+ }
80
+ if (value !== null && typeof value === 'object') {
81
+ const resolved = {};
82
+ for (const [key, val] of Object.entries(value)) {
83
+ resolved[key] = resolveValue(val, context);
84
+ }
85
+ return resolved;
86
+ }
87
+ return value;
88
+ }
89
+ // ============================================================
90
+ // BLOCK EXPRESSION RESOLUTION
91
+ // ============================================================
92
+ /**
93
+ * Resolve all {{expression}} placeholders in a block tree.
94
+ *
95
+ * Creates a deep copy of the blocks with all string prop values
96
+ * containing expressions resolved against the provided data context.
97
+ *
98
+ * @param blocks - Block array to resolve
99
+ * @param data - Data context (keyed by source ID, plus 'state')
100
+ * @param helpers - Optional additional helper functions
101
+ * @returns New block array with resolved prop values
102
+ */
103
+ export function resolveBlockExpressions(blocks, data, helpers) {
104
+ const context = createExpressionContext(data, helpers);
105
+ return blocks
106
+ .map((block) => resolveBlock(block, context, false))
107
+ .filter((b) => b !== null);
108
+ }
109
+ /**
110
+ * A block may carry a conditional-visibility expression — `visibleWhen` (or the
111
+ * shorthand `if`) — a template string evaluated against surface state/data. When
112
+ * it resolves falsy the block (and its subtree) is omitted from the render
113
+ * entirely. This drives state-driven UI in the blocks-array receipt path:
114
+ * form↔success toggles, wizard steps, "show X only when {{state.y}}". The
115
+ * companion is a `setState` action (e.g. a form's onSubmitAction) flipping state.
116
+ *
117
+ * Falsy = empty string, 'false', 'undefined', 'null', '0', NaN or a falsy primitive.
118
+ */
119
+ function isFalsyCondition(value) {
120
+ if (value == null || value === false)
121
+ return true;
122
+ if (typeof value === 'string') {
123
+ const t = value.trim().toLowerCase();
124
+ return t === '' || t === 'false' || t === 'undefined' || t === 'null' || t === '0';
125
+ }
126
+ if (typeof value === 'number')
127
+ return value === 0 || Number.isNaN(value);
128
+ return false;
129
+ }
130
+ /**
131
+ * Evaluate a `visibleWhen` / `if` condition. Unlike a prop, a condition that
132
+ * cannot be evaluated has NO fallback value: a prop keeps its raw template so
133
+ * the author can see it, but a raw template in a condition is a non-empty
134
+ * string — truthy — and the block would show forever (a "no results" empty
135
+ * state beside the results). FAIL CLOSED: not evaluable means hidden.
136
+ */
137
+ function evaluateCondition(condition, context) {
138
+ const whole = WHOLE_VALUE_PATTERN.exec(condition);
139
+ if (whole) {
140
+ const r = evaluate((whole[1] ?? '').trim(), context);
141
+ return r.success ? { ok: true, value: r.value } : { ok: false, error: r.error };
142
+ }
143
+ if (HAS_EXPRESSION_PATTERN.test(condition)) {
144
+ const r = interpolate(condition, context);
145
+ return r.success ? { ok: true, value: r.value } : { ok: false, error: r.error };
146
+ }
147
+ return { ok: true, value: condition };
148
+ }
149
+ /** One warning per block + condition, not one per render. */
150
+ const warnedConditions = new Set();
151
+ function warnUnevaluable(blockId, condition, error) {
152
+ const nodeEnv = typeof process !== 'undefined' ? process.env?.['NODE_ENV'] : undefined;
153
+ if (nodeEnv === 'production')
154
+ return;
155
+ const key = `${blockId}|${condition}`;
156
+ if (warnedConditions.has(key))
157
+ return;
158
+ if (warnedConditions.size > 500)
159
+ warnedConditions.clear();
160
+ warnedConditions.add(key);
161
+ console.warn(`[surface] block "${blockId}": visibleWhen ${JSON.stringify(condition)} could not be evaluated, so the block is HIDDEN. ${error}`);
162
+ }
163
+ /** The block that gathers its descendants' fields into one submission. */
164
+ function isFormBlock(block) {
165
+ const type = String(block.type ?? '');
166
+ return type === 'form' || type.endsWith('/form');
167
+ }
168
+ /** `layout.hidden` is responsive; every breakpoint, so no authored one wins. */
169
+ const HIDDEN_AT_EVERY_BREAKPOINT = Object.freeze(Object.fromEntries(BREAKPOINT_ORDER.map((bp) => [bp, true])));
170
+ /**
171
+ * Hidden but still mounted: the wrapper gets `display: none` through the
172
+ * block's own layout (`layout.hidden`, the same switch the responsive layout
173
+ * uses), so the renderer keeps the subtree — and its inputs — in the DOM.
174
+ */
175
+ function hideInPlace(block) {
176
+ const layout = block.layout;
177
+ return { ...block, layout: { ...(layout ?? {}), hidden: HIDDEN_AT_EVERY_BREAKPOINT } };
178
+ }
179
+ /**
180
+ * Resolve expressions in a single block and its children recursively.
181
+ * Returns null when the block's `visibleWhen`/`if` condition resolves falsy
182
+ * (or cannot be evaluated — see evaluateCondition).
183
+ *
184
+ * A reserved surface-state key `__show:<blockId>` (written by `showBlock`/
185
+ * `hideBlock` actions) acts as a visibility OVERRIDE that is checked BEFORE
186
+ * the `visibleWhen`/`if` template evaluation:
187
+ * - `true` → block is forced VISIBLE (visibleWhen/if skipped)
188
+ * - `false` → block is forced HIDDEN
189
+ * - absent → fall through to the visibleWhen/if logic
190
+ *
191
+ * The key is read directly from the context data (not via the template
192
+ * evaluator) because the colon in `__show:<id>` breaks the path grammar.
193
+ *
194
+ * INSIDE A FORM, HIDDEN MEANS HIDDEN — NOT UNMOUNTED. A wizard is
195
+ * one `form` whose steps are sections gated by `visibleWhen: {{state.step == N}}`.
196
+ * The form block gathers its values from the DOM (`new FormData(form)`), so an
197
+ * unmounted step contributed nothing: the RSVP wizard submitted an empty
198
+ * record, and going "back" remounted step 1 with empty inputs. A block under a
199
+ * form is therefore kept in the tree with `layout.hidden` (display:none) — its
200
+ * inputs keep their values and stay part of the submission. The form itself,
201
+ * and everything outside forms, still unmounts as before.
202
+ */
203
+ function resolveBlock(block, context, insideForm) {
204
+ const stateMap = context.data['state'];
205
+ const override = stateMap?.[`__show:${block.id}`];
206
+ let hidden = override === false;
207
+ if (override !== true && override !== false) {
208
+ const condition = block.visibleWhen
209
+ ?? block.if;
210
+ if (typeof condition === 'string' && condition.trim()) {
211
+ const r = evaluateCondition(condition, context);
212
+ if (!r.ok) {
213
+ warnUnevaluable(block.id, condition, r.error);
214
+ hidden = true;
215
+ }
216
+ else if (isFalsyCondition(r.value)) {
217
+ hidden = true;
218
+ }
219
+ }
220
+ }
221
+ if (hidden && !insideForm)
222
+ return null;
223
+ const resolved = resolveVisibleBlock(block, context, insideForm || isFormBlock(block));
224
+ return hidden ? hideInPlace(resolved) : resolved;
225
+ }
226
+ function resolveVisibleBlock(block, context, insideForm) {
227
+ const resolvedProps = block.props
228
+ ? resolveValue(block.props, context)
229
+ : block.props;
230
+ // Item-template expansion (repeat + {{item.*}} scope): a block carrying a
231
+ // block-level `repeat` expression treats its authored children as a PER-ITEM
232
+ // TEMPLATE. The binding resolves to an array; for each element the template
233
+ // subtree is cloned and re-resolved with `item` and `index` added to the
234
+ // expression context — so `{{item.Title}}` / `{{index}}` resolve per row.
235
+ // Cloned block ids get a `--<index>` suffix (unique React keys /
236
+ // data-block-id). Without `repeat` nothing changes (children resolve
237
+ // normally, byte-identical to the previous behavior); a non-array binding
238
+ // (source still loading) expands to zero children rather than leaking the
239
+ // raw template. First consumer: the repeater block family — but the
240
+ // contract is deliberately block-agnostic (a plain container can repeat).
241
+ const repeatExpr = block.repeat;
242
+ if (typeof repeatExpr === 'string' && repeatExpr.trim() && block.children?.length) {
243
+ const resolved = resolveValue(repeatExpr, context);
244
+ const items = Array.isArray(resolved) ? resolved : [];
245
+ const template = block.children;
246
+ const expanded = [];
247
+ for (let index = 0; index < items.length; index++) {
248
+ const itemContext = {
249
+ ...context,
250
+ data: { ...context.data, item: items[index], index },
251
+ };
252
+ for (const child of template) {
253
+ const clone = resolveBlock(suffixIds(child, index), itemContext, insideForm);
254
+ if (clone)
255
+ expanded.push(clone);
256
+ }
257
+ }
258
+ const { repeat: _repeat, ...rest } = block;
259
+ return markRepeatExpanded({ ...rest, props: resolvedProps, children: expanded });
260
+ }
261
+ if (block.children) {
262
+ return {
263
+ ...block,
264
+ props: resolvedProps,
265
+ children: block.children
266
+ .map((child) => resolveBlock(child, context, insideForm))
267
+ .filter((b) => b !== null),
268
+ };
269
+ }
270
+ return {
271
+ ...block,
272
+ props: resolvedProps,
273
+ };
274
+ }
275
+ /**
276
+ * THE BLOCK THAT EXPANDED A REPEAT OWNS ITS CLONES' LAYOUT.
277
+ *
278
+ * `repeat` is stripped from the resolved block, so the renderer could no
279
+ * longer tell a repeater from any other parent: every clone got the surface
280
+ * default `gridColumn: span 12`, and inside the repeater's own grid
281
+ * (`repeat(auto-fit, minmax(…))`) a 12-column span put each item on a row of
282
+ * its own — every repeater wall rendered as one column. The mark survives
283
+ * object spread (an own enumerable symbol key) and never reaches JSON, so the
284
+ * surface document is unchanged; the renderer reads it through
285
+ * `isRepeatExpanded` and leaves the clones to the parent's own grid.
286
+ */
287
+ const REPEAT_EXPANDED = Symbol.for('pwfabric.repeatExpanded');
288
+ function markRepeatExpanded(block) {
289
+ return { ...block, [REPEAT_EXPANDED]: true };
290
+ }
291
+ /** True when this resolved block expanded a `repeat` — its children are clones. */
292
+ export function isRepeatExpanded(block) {
293
+ return block?.[REPEAT_EXPANDED] === true;
294
+ }
295
+ /**
296
+ * Deep-clone a template subtree, suffixing every block id with `--<index>` so
297
+ * expanded clones stay unique across rows (React keys, data-block-id lookups,
298
+ * label htmlFor targets).
299
+ */
300
+ function suffixIds(block, index) {
301
+ return {
302
+ ...block,
303
+ id: `${block.id}--${index}`,
304
+ ...(block.children
305
+ ? { children: block.children.map((c) => suffixIds(c, index)) }
306
+ : {}),
307
+ };
308
+ }
309
+ //# sourceMappingURL=resolve-expressions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve-expressions.js","sourceRoot":"","sources":["../../src/render/resolve-expressions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AACjD,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAA;AAGzF,+DAA+D;AAC/D,sBAAsB;AACtB,+DAA+D;AAE/D;;;;;GAKG;AACH,MAAM,mBAAmB,GAAG,6BAA6B,CAAA;AAEzD;;GAEG;AACH,MAAM,sBAAsB,GAAG,aAAa,CAAA;AAE5C,+DAA+D;AAC/D,oBAAoB;AACpB,+DAA+D;AAE/D;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,KAAa,EAAE,OAA0B;IACrE,yCAAyC;IACzC,MAAM,UAAU,GAAG,mBAAmB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IAClD,IAAI,UAAU,EAAE,CAAC;QACf,MAAM,IAAI,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAA;QACzC,MAAM,MAAM,GAAG,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;QACtC,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;YACnB,OAAO,MAAM,CAAC,KAAK,CAAA;QACrB,CAAC;QACD,iDAAiD;QACjD,OAAO,KAAK,CAAA;IACd,CAAC;IAED,iCAAiC;IACjC,IAAI,sBAAsB,CAA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AG,KAAK;QACR,KAAK,EAAE,aAAa;KACrB,CAAA;AACH,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,eAAe,GAAkB,MAAM,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAA;AAE5E,SAAS,kBAAkB,CAAC,KAAY;IACtC,OAAO,EAAE,GAAG,KAAK,EAAE,CAAC,eAAe,CAAC,EAAE,IAAI,EAAW,CAAA;AACvD,CAAC;AAED,mFAAmF;AACnF,MAAM,UAAU,gBAAgB,CAAC,KAAwB;IACvD,OAAQ,KAAqD,EAAE,CAAC,eAAe,CAAC,KAAK,IAAI,CAAA;AAC3F,CAAC;AAED;;;;GAIG;AACH,SAAS,SAAS,CAAC,KAAY,EAAE,KAAa;IAC5C,OAAO;QACL,GAAG,KAAK;QACR,EAAE,EAAE,GAAG,KAAK,CAAC,EAAE,KAAK,KAAK,EAAE;QAC3B,GAAG,CAAC,KAAK,CAAC,QAAQ;YAChB,CAAC,CAAC,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE;YAC9D,CAAC,CAAC,EAAE,CAAC;KACR,CAAA;AACH,CAAC","sourcesContent":["/**\n * Expression Resolution for Block Props\n *\n * Resolves {{expression}} placeholders in block prop values.\n * Uses the existing expression engine (evaluate/interpolate) from surface/expression.\n *\n * Key behavior:\n * - Whole-value: \"{{items}}\" returns raw value (array, object, etc.)\n * - String interpolation: \"Total: {{count}}\" returns interpolated string\n * - Recursively walks block tree and nested objects/arrays in props\n *\n * @module @pwfabric/runtime/render/resolve-expressions\n */\n\nimport type { Block } from '@pwfabric/core'\nimport { BREAKPOINT_ORDER } from '@pwfabric/core'\nimport { evaluate, interpolate, createExpressionContext } from '../surface/expression.js'\nimport type { ExpressionContext } from '../surface/expression.js'\n\n// ============================================================\n// WHOLE-VALUE PATTERN\n// ============================================================\n\n/**\n * Matches a string that is exactly one expression placeholder with no surrounding text.\n * e.g. \"{{products}}\" or \"{{ state.x === 'a' ? 'primary' : 'outline' }}\"\n * The inner capture uses a negative lookahead to prevent matching across }} boundaries,\n * so \"{{a}} · {{b}}\" is NOT treated as a whole-value expression.\n */\nconst WHOLE_VALUE_PATTERN = /^\\{\\{((?:(?!\\}\\}).)+)\\}\\}$/s\n\n/**\n * Matches strings that contain at least one expression placeholder.\n */\nconst HAS_EXPRESSION_PATTERN = /\\{\\{.+?\\}\\}/\n\n// ============================================================\n// STRING RESOLUTION\n// ============================================================\n\n/**\n * Resolve a single string value.\n *\n * - If the string is exactly \"{{expr}}\", evaluate and return the raw value (preserving type).\n * - If the string contains embedded \"{{expr}}\", interpolate and return a string.\n * - Otherwise return as-is.\n */\nexport function resolveString(value: string, context: ExpressionContext): unknown {\n // Check for whole-value expression first\n const wholeMatch = WHOLE_VALUE_PATTERN.exec(value)\n if (wholeMatch) {\n const expr = (wholeMatch[1] ?? '').trim()\n const result = evaluate(expr, context)\n if (result.success) {\n return result.value\n }\n // On failure, return original string as fallback\n return value\n }\n\n // Check for embedded expressions\n if (HAS_EXPRESSION_PATTERN.test(value)) {\n const result = interpolate(value, context)\n if (result.success) {\n return result.value\n }\n // On failure, return original string as fallback\n return value\n }\n\n // No expressions, return as-is\n return value\n}\n\n// ============================================================\n// PROP VALUE RESOLUTION\n// ============================================================\n\n/**\n * Recursively resolve expressions in a prop value.\n * - Strings are checked for expressions\n * - Arrays and plain objects are traversed\n * - Other types pass through unchanged\n */\nfunction resolveValue(value: unknown, context: ExpressionContext): unknown {\n if (typeof value === 'string') {\n return resolveString(value, context)\n }\n\n if (Array.isArray(value)) {\n return value.map((item) => resolveValue(item, context))\n }\n\n if (value !== null && typeof value === 'object') {\n const resolved: Record<string, unknown> = {}\n for (const [key, val] of Object.entries(value)) {\n resolved[key] = resolveValue(val, context)\n }\n return resolved\n }\n\n return value\n}\n\n// ============================================================\n// BLOCK EXPRESSION RESOLUTION\n// ============================================================\n\n/**\n * Resolve all {{expression}} placeholders in a block tree.\n *\n * Creates a deep copy of the blocks with all string prop values\n * containing expressions resolved against the provided data context.\n *\n * @param blocks - Block array to resolve\n * @param data - Data context (keyed by source ID, plus 'state')\n * @param helpers - Optional additional helper functions\n * @returns New block array with resolved prop values\n */\nexport function resolveBlockExpressions(\n blocks: readonly Block[],\n data: Record<string, unknown>,\n helpers?: Record<string, (...args: unknown[]) => unknown>\n): Block[] {\n const context = createExpressionContext(data, helpers)\n return blocks\n .map((block) => resolveBlock(block, context, false))\n .filter((b): b is Block => b !== null)\n}\n\n/**\n * A block may carry a conditional-visibility expression — `visibleWhen` (or the\n * shorthand `if`) — a template string evaluated against surface state/data. When\n * it resolves falsy the block (and its subtree) is omitted from the render\n * entirely. This drives state-driven UI in the blocks-array receipt path:\n * form↔success toggles, wizard steps, \"show X only when {{state.y}}\". The\n * companion is a `setState` action (e.g. a form's onSubmitAction) flipping state.\n *\n * Falsy = empty string, 'false', 'undefined', 'null', '0', NaN or a falsy primitive.\n */\nfunction isFalsyCondition(value: unknown): boolean {\n if (value == null || value === false) return true\n if (typeof value === 'string') {\n const t = value.trim().toLowerCase()\n return t === '' || t === 'false' || t === 'undefined' || t === 'null' || t === '0'\n }\n if (typeof value === 'number') return value === 0 || Number.isNaN(value)\n return false\n}\n\n/**\n * Evaluate a `visibleWhen` / `if` condition. Unlike a prop, a condition that\n * cannot be evaluated has NO fallback value: a prop keeps its raw template so\n * the author can see it, but a raw template in a condition is a non-empty\n * string — truthy — and the block would show forever (a \"no results\" empty\n * state beside the results). FAIL CLOSED: not evaluable means hidden.\n */\nfunction evaluateCondition(\n condition: string,\n context: ExpressionContext\n): { ok: true; value: unknown } | { ok: false; error: string } {\n const whole = WHOLE_VALUE_PATTERN.exec(condition)\n if (whole) {\n const r = evaluate((whole[1] ?? '').trim(), context)\n return r.success ? { ok: true, value: r.value } : { ok: false, error: r.error }\n }\n if (HAS_EXPRESSION_PATTERN.test(condition)) {\n const r = interpolate(condition, context)\n return r.success ? { ok: true, value: r.value } : { ok: false, error: r.error }\n }\n return { ok: true, value: condition }\n}\n\n/** One warning per block + condition, not one per render. */\nconst warnedConditions = new Set<string>()\n\nfunction warnUnevaluable(blockId: string, condition: string, error: string): void {\n const nodeEnv = typeof process !== 'undefined' ? process.env?.['NODE_ENV'] : undefined\n if (nodeEnv === 'production') return\n const key = `${blockId}|${condition}`\n if (warnedConditions.has(key)) return\n if (warnedConditions.size > 500) warnedConditions.clear()\n warnedConditions.add(key)\n console.warn(\n `[surface] block \"${blockId}\": visibleWhen ${JSON.stringify(condition)} could not be evaluated, so the block is HIDDEN. ${error}`\n )\n}\n\n/** The block that gathers its descendants' fields into one submission. */\nfunction isFormBlock(block: Block): boolean {\n const type = String((block as { type?: unknown }).type ?? '')\n return type === 'form' || type.endsWith('/form')\n}\n\n/** `layout.hidden` is responsive; every breakpoint, so no authored one wins. */\nconst HIDDEN_AT_EVERY_BREAKPOINT: Readonly<Record<string, boolean>> = Object.freeze(\n Object.fromEntries(BREAKPOINT_ORDER.map((bp) => [bp, true]))\n)\n\n/**\n * Hidden but still mounted: the wrapper gets `display: none` through the\n * block's own layout (`layout.hidden`, the same switch the responsive layout\n * uses), so the renderer keeps the subtree — and its inputs — in the DOM.\n */\nfunction hideInPlace(block: Block): Block {\n const layout = block.layout as unknown as Record<string, unknown> | undefined\n return { ...block, layout: { ...(layout ?? {}), hidden: HIDDEN_AT_EVERY_BREAKPOINT } } as Block\n}\n\n/**\n * Resolve expressions in a single block and its children recursively.\n * Returns null when the block's `visibleWhen`/`if` condition resolves falsy\n * (or cannot be evaluated — see evaluateCondition).\n *\n * A reserved surface-state key `__show:<blockId>` (written by `showBlock`/\n * `hideBlock` actions) acts as a visibility OVERRIDE that is checked BEFORE\n * the `visibleWhen`/`if` template evaluation:\n * - `true` → block is forced VISIBLE (visibleWhen/if skipped)\n * - `false` → block is forced HIDDEN\n * - absent → fall through to the visibleWhen/if logic\n *\n * The key is read directly from the context data (not via the template\n * evaluator) because the colon in `__show:<id>` breaks the path grammar.\n *\n * INSIDE A FORM, HIDDEN MEANS HIDDEN — NOT UNMOUNTED. A wizard is\n * one `form` whose steps are sections gated by `visibleWhen: {{state.step == N}}`.\n * The form block gathers its values from the DOM (`new FormData(form)`), so an\n * unmounted step contributed nothing: the RSVP wizard submitted an empty\n * record, and going \"back\" remounted step 1 with empty inputs. A block under a\n * form is therefore kept in the tree with `layout.hidden` (display:none) — its\n * inputs keep their values and stay part of the submission. The form itself,\n * and everything outside forms, still unmounts as before.\n */\nfunction resolveBlock(block: Block, context: ExpressionContext, insideForm: boolean): Block | null {\n const stateMap = context.data['state'] as Record<string, unknown> | undefined\n const override = stateMap?.[`__show:${block.id}`]\n let hidden = override === false\n if (override !== true && override !== false) {\n const condition = (block as { visibleWhen?: unknown; if?: unknown }).visibleWhen\n ?? (block as { visibleWhen?: unknown; if?: unknown }).if\n if (typeof condition === 'string' && condition.trim()) {\n const r = evaluateCondition(condition, context)\n if (!r.ok) {\n warnUnevaluable(block.id, condition, r.error)\n hidden = true\n } else if (isFalsyCondition(r.value)) {\n hidden = true\n }\n }\n }\n if (hidden && !insideForm) return null\n\n const resolved = resolveVisibleBlock(block, context, insideForm || isFormBlock(block))\n return hidden ? hideInPlace(resolved) : resolved\n}\n\nfunction resolveVisibleBlock(block: Block, context: ExpressionContext, insideForm: boolean): Block {\n const resolvedProps = block.props\n ? (resolveValue(block.props, context) as Record<string, unknown>)\n : block.props\n\n // Item-template expansion (repeat + {{item.*}} scope): a block carrying a\n // block-level `repeat` expression treats its authored children as a PER-ITEM\n // TEMPLATE. The binding resolves to an array; for each element the template\n // subtree is cloned and re-resolved with `item` and `index` added to the\n // expression context — so `{{item.Title}}` / `{{index}}` resolve per row.\n // Cloned block ids get a `--<index>` suffix (unique React keys /\n // data-block-id). Without `repeat` nothing changes (children resolve\n // normally, byte-identical to the previous behavior); a non-array binding\n // (source still loading) expands to zero children rather than leaking the\n // raw template. First consumer: the repeater block family — but the\n // contract is deliberately block-agnostic (a plain container can repeat).\n const repeatExpr = (block as { repeat?: unknown }).repeat\n if (typeof repeatExpr === 'string' && repeatExpr.trim() && block.children?.length) {\n const resolved = resolveValue(repeatExpr, context)\n const items = Array.isArray(resolved) ? resolved : []\n const template = block.children\n const expanded: Block[] = []\n for (let index = 0; index < items.length; index++) {\n const itemContext: ExpressionContext = {\n ...context,\n data: { ...context.data, item: items[index], index },\n }\n for (const child of template) {\n const clone = resolveBlock(suffixIds(child, index), itemContext, insideForm)\n if (clone) expanded.push(clone)\n }\n }\n const { repeat: _repeat, ...rest } = block as Block & { repeat?: unknown }\n return markRepeatExpanded({ ...(rest as Block), props: resolvedProps, children: expanded })\n }\n\n if (block.children) {\n return {\n ...block,\n props: resolvedProps,\n children: block.children\n .map((child) => resolveBlock(child, context, insideForm))\n .filter((b): b is Block => b !== null),\n }\n }\n\n return {\n ...block,\n props: resolvedProps,\n }\n}\n\n/**\n * THE BLOCK THAT EXPANDED A REPEAT OWNS ITS CLONES' LAYOUT.\n *\n * `repeat` is stripped from the resolved block, so the renderer could no\n * longer tell a repeater from any other parent: every clone got the surface\n * default `gridColumn: span 12`, and inside the repeater's own grid\n * (`repeat(auto-fit, minmax(…))`) a 12-column span put each item on a row of\n * its own — every repeater wall rendered as one column. The mark survives\n * object spread (an own enumerable symbol key) and never reaches JSON, so the\n * surface document is unchanged; the renderer reads it through\n * `isRepeatExpanded` and leaves the clones to the parent's own grid.\n */\nconst REPEAT_EXPANDED: unique symbol = Symbol.for('pwfabric.repeatExpanded')\n\nfunction markRepeatExpanded(block: Block): Block {\n return { ...block, [REPEAT_EXPANDED]: true } as Block\n}\n\n/** True when this resolved block expanded a `repeat` — its children are clones. */\nexport function isRepeatExpanded(block: Block | undefined): boolean {\n return (block as { [REPEAT_EXPANDED]?: unknown } | undefined)?.[REPEAT_EXPANDED] === true\n}\n\n/**\n * Deep-clone a template subtree, suffixing every block id with `--<index>` so\n * expanded clones stay unique across rows (React keys, data-block-id lookups,\n * label htmlFor targets).\n */\nfunction suffixIds(block: Block, index: number): Block {\n return {\n ...block,\n id: `${block.id}--${index}`,\n ...(block.children\n ? { children: block.children.map((c) => suffixIds(c, index)) }\n : {}),\n }\n}\n"]}