@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,147 @@
1
+ /**
2
+ * Block Props Validation
3
+ *
4
+ * Runtime validation of block props using injected Zod schemas.
5
+ * the legacy `blockSchemas` map is gone — production
6
+ * callers supply a schema map sourced from the install pipeline (per-atom
7
+ * `manifest.definition.props[*].jsonSchema` rebuilt into Zod). Without a
8
+ * schema map the validator runs in lenient mode and passes everything
9
+ * through.
10
+ *
11
+ * @module @pwfabric/runtime/surface/validation
12
+ */
13
+ // ============================================================
14
+ // VALIDATION FUNCTIONS
15
+ // ============================================================
16
+ /**
17
+ * Validate block props against the known Zod schema for the given block type.
18
+ *
19
+ * - Known block types are validated against the schema from @pwfabric/core.
20
+ * - Unknown block types pass through in lenient mode (default) and fail in strict mode.
21
+ * - On success, returns coerced data (with defaults applied by Zod).
22
+ */
23
+ export function validateBlockProps(type, props, options = {}) {
24
+ const { strict = false, schemas } = options;
25
+ const schema = schemas?.[type];
26
+ if (!schema) {
27
+ if (strict) {
28
+ return {
29
+ valid: false,
30
+ errors: [`Unknown block type: ${type}`],
31
+ };
32
+ }
33
+ // Lenient mode: unknown / unsupplied types pass through
34
+ return { valid: true, errors: [] };
35
+ }
36
+ const result = schema.safeParse(props);
37
+ if (result.success) {
38
+ return {
39
+ valid: true,
40
+ errors: [],
41
+ coerced: result.data,
42
+ };
43
+ }
44
+ return {
45
+ valid: false,
46
+ errors: result.error.issues.map((i) => `${i.path.join('.')}: ${i.message}`),
47
+ };
48
+ }
49
+ /**
50
+ * Validate all block props in a layout tree recursively.
51
+ *
52
+ * Returns a flat list of validation issues with path context.
53
+ */
54
+ export function validateLayoutProps(layout, options = {}, path = 'root') {
55
+ const issues = [];
56
+ const result = validateBlockProps(layout.type, layout.props ?? {}, options);
57
+ if (!result.valid) {
58
+ issues.push({
59
+ path,
60
+ type: layout.type,
61
+ errors: result.errors,
62
+ });
63
+ }
64
+ if (layout.children) {
65
+ for (let i = 0; i < layout.children.length; i++) {
66
+ const child = layout.children[i];
67
+ if (child) {
68
+ const childIssues = validateLayoutProps(child, options, `${path}.children[${i}]`);
69
+ issues.push(...childIssues);
70
+ }
71
+ }
72
+ }
73
+ return issues;
74
+ }
75
+ function carriesTemplate(value, depth = 0) {
76
+ if (depth > 8)
77
+ return false;
78
+ if (typeof value === 'string')
79
+ return value.includes('{{');
80
+ if (Array.isArray(value))
81
+ return value.some((v) => carriesTemplate(v, depth + 1));
82
+ if (value && typeof value === 'object') {
83
+ return Object.values(value).some((v) => carriesTemplate(v, depth + 1));
84
+ }
85
+ return false;
86
+ }
87
+ /**
88
+ * The props of ONE block that its manifest does not allow.
89
+ *
90
+ * WHY: a prop the manifest does not declare was
91
+ * accepted silently. The schema check rebuilds each prop's JSON schema into a
92
+ * passthrough object, so a misspelt or invented prop (`tone` on a block that
93
+ * has none, `paddingY` where the block reads `padding`) validated clean and
94
+ * did nothing on screen. And a `{{ }}` template on a `bindable: false` prop was
95
+ * shown to the visitor as literal braces. Both are now named.
96
+ *
97
+ * @param specs the block's declared props; `undefined` (block not in the map)
98
+ * yields nothing, because an unknown block type is a different finding.
99
+ */
100
+ export function blockManifestPropFindings(type, props, specs, path = 'root') {
101
+ if (!specs || !props)
102
+ return [];
103
+ const byName = new Map(specs.map((s) => [s.name, s]));
104
+ const out = [];
105
+ for (const [prop, value] of Object.entries(props)) {
106
+ if (value === undefined)
107
+ continue;
108
+ const spec = byName.get(prop);
109
+ if (!spec) {
110
+ out.push({
111
+ path,
112
+ type,
113
+ prop,
114
+ code: 'UNKNOWN_PROP',
115
+ severity: 'warning',
116
+ message: `"${prop}" is not a prop of ${type}; the block ignores it.`,
117
+ });
118
+ continue;
119
+ }
120
+ if (spec.bindable === false && carriesTemplate(value)) {
121
+ out.push({
122
+ path,
123
+ type,
124
+ prop,
125
+ code: 'TEMPLATE_ON_UNBINDABLE',
126
+ severity: 'warning',
127
+ message: `"${prop}" on ${type} takes a literal value; its {{ }} template is shown as written.`,
128
+ });
129
+ }
130
+ }
131
+ return out;
132
+ }
133
+ /**
134
+ * Every manifest finding in a layout tree, with path context. Blocks whose
135
+ * type is not in `manifests` are skipped.
136
+ */
137
+ export function manifestPropFindings(layout, manifests, path = 'root') {
138
+ const out = blockManifestPropFindings(layout.type, layout.props, manifests[layout.type], path);
139
+ if (layout.children) {
140
+ layout.children.forEach((child, i) => {
141
+ if (child)
142
+ out.push(...manifestPropFindings(child, manifests, `${path}.children[${i}]`));
143
+ });
144
+ }
145
+ return out;
146
+ }
147
+ //# sourceMappingURL=validation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.js","sourceRoot":"","sources":["../../src/surface/validation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AA6CH,+DAA+D;AAC/D,uBAAuB;AACvB,+DAA+D;AAE/D;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB,CAChC,IAAY,EACZ,KAA8B,EAC9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EAClB,SAAgC,EAChC,IAAI,GAAG,MAAM;IAEb,MAAM,GAAG,GAAG,yBAAyB,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,KAAK,EAAE,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,CAAA;IAC9F,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;QACpB,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE;YACnC,IAAI,KAAK;gBAAE,GAAG,CAAC,IAAI,CAAC,GAAG,oBAAoB,CAAC,KAAK,EAAE,SAAS,EAAE,GAAG,IAAI,aAAa,CAAC,GAAG,CAAC,CAAC,CAAA;QAC1F,CAAC,CAAC,CAAA;IACJ,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC","sourcesContent":["/**\n * Block Props Validation\n *\n * Runtime validation of block props using injected Zod schemas.\n * the legacy `blockSchemas` map is gone — production\n * callers supply a schema map sourced from the install pipeline (per-atom\n * `manifest.definition.props[*].jsonSchema` rebuilt into Zod). Without a\n * schema map the validator runs in lenient mode and passes everything\n * through.\n *\n * @module @pwfabric/runtime/surface/validation\n */\n\nimport type { ZodSchema } from 'zod'\n\n/** Map of block type → Zod schema. Supply via options to enable strict checks. */\nexport type BlockSchemaMap = Readonly<Record<string, ZodSchema>>\n\n// ============================================================\n// VALIDATION TYPES\n// ============================================================\n\n/**\n * Options for block props validation\n */\nexport interface BlockPropsValidationOptions {\n /**\n * When true, unknown block types cause validation failure.\n * When false (default), unknown block types pass through.\n */\n readonly strict?: boolean\n /**\n * Per-block-type Zod schemas. the runtime no longer\n * ships a built-in schema map — callers that want prop validation\n * supply their own (typically rebuilt from\n * each installed block manifest's `definition.props[*].jsonSchema`).\n * Omitting the map yields lenient pass-through behaviour.\n */\n readonly schemas?: BlockSchemaMap\n /**\n * Per-block-type manifest props. When supplied, props a manifest\n * does not declare and templates on `bindable: false` props are reported as\n * WARNINGS (`manifestPropFindings`); they never fail validation.\n */\n readonly manifests?: BlockManifestPropsMap\n}\n\n/**\n * Result of validating block props against the schema\n */\nexport interface BlockPropsValidationResult {\n readonly valid: boolean\n readonly errors: readonly string[]\n readonly coerced?: Record<string, unknown>\n}\n\n// ============================================================\n// VALIDATION FUNCTIONS\n// ============================================================\n\n/**\n * Validate block props against the known Zod schema for the given block type.\n *\n * - Known block types are validated against the schema from @pwfabric/core.\n * - Unknown block types pass through in lenient mode (default) and fail in strict mode.\n * - On success, returns coerced data (with defaults applied by Zod).\n */\nexport function validateBlockProps(\n type: string,\n props: Record<string, unknown>,\n options: BlockPropsValidationOptions = {}\n): BlockPropsValidationResult {\n const { strict = false, schemas } = options\n\n const schema = schemas?.[type]\n\n if (!schema) {\n if (strict) {\n return {\n valid: false,\n errors: [`Unknown block type: ${type}`],\n }\n }\n // Lenient mode: unknown / unsupplied types pass through\n return { valid: true, errors: [] }\n }\n\n const result = schema.safeParse(props)\n\n if (result.success) {\n return {\n valid: true,\n errors: [],\n coerced: result.data as Record<string, unknown>,\n }\n }\n\n return {\n valid: false,\n errors: result.error.issues.map(\n (i: { path: (string | number)[]; message: string }) => `${i.path.join('.')}: ${i.message}`\n ),\n }\n}\n\n/**\n * Layout node shape for recursive validation.\n * Matches LayoutJSON structure without importing it to avoid circular deps.\n */\ninterface LayoutNode {\n readonly type: string\n readonly props?: Record<string, unknown>\n readonly children?: readonly LayoutNode[]\n}\n\n/**\n * A single validation issue with path context\n */\nexport interface LayoutPropsIssue {\n readonly path: string\n readonly type: string\n readonly errors: readonly string[]\n}\n\n/**\n * Validate all block props in a layout tree recursively.\n *\n * Returns a flat list of validation issues with path context.\n */\nexport function validateLayoutProps(\n layout: LayoutNode,\n options: BlockPropsValidationOptions = {},\n path = 'root'\n): readonly LayoutPropsIssue[] {\n const issues: LayoutPropsIssue[] = []\n\n const result = validateBlockProps(layout.type, layout.props ?? {}, options)\n if (!result.valid) {\n issues.push({\n path,\n type: layout.type,\n errors: result.errors,\n })\n }\n\n if (layout.children) {\n for (let i = 0; i < layout.children.length; i++) {\n const child = layout.children[i]\n if (child) {\n const childIssues = validateLayoutProps(child, options, `${path}.children[${i}]`)\n issues.push(...childIssues)\n }\n }\n }\n\n return issues\n}\n\n// ============================================================\n// PACK MANIFEST ENFORCEMENT\n// ============================================================\n\n/**\n * One prop a pack manifest declares: `manifest.definition.props[*]`. Only the\n * two fields the check reads; a full manifest entry passes as it is.\n */\nexport interface ManifestPropSpec {\n readonly name: string\n /** `false` = the prop takes a literal only; a `{{ }}` template is not resolved for it. */\n readonly bindable?: boolean\n}\n\n/** Block type → the props its manifest declares. */\nexport type BlockManifestPropsMap = Readonly<Record<string, readonly ManifestPropSpec[]>>\n\nexport type ManifestPropFindingCode = 'UNKNOWN_PROP' | 'TEMPLATE_ON_UNBINDABLE'\n\n/**\n * A prop that does not match its block's manifest. Always a WARNING:\n * existing apps carry such props and must keep rendering; a caller\n * decides whether to show, count or (later) refuse them.\n */\nexport interface ManifestPropFinding {\n readonly path: string\n readonly type: string\n readonly prop: string\n readonly code: ManifestPropFindingCode\n readonly severity: 'warning'\n readonly message: string\n}\n\nfunction carriesTemplate(value: unknown, depth = 0): boolean {\n if (depth > 8) return false\n if (typeof value === 'string') return value.includes('{{')\n if (Array.isArray(value)) return value.some((v) => carriesTemplate(v, depth + 1))\n if (value && typeof value === 'object') {\n return Object.values(value as Record<string, unknown>).some((v) => carriesTemplate(v, depth + 1))\n }\n return false\n}\n\n/**\n * The props of ONE block that its manifest does not allow.\n *\n * WHY: a prop the manifest does not declare was\n * accepted silently. The schema check rebuilds each prop's JSON schema into a\n * passthrough object, so a misspelt or invented prop (`tone` on a block that\n * has none, `paddingY` where the block reads `padding`) validated clean and\n * did nothing on screen. And a `{{ }}` template on a `bindable: false` prop was\n * shown to the visitor as literal braces. Both are now named.\n *\n * @param specs the block's declared props; `undefined` (block not in the map)\n * yields nothing, because an unknown block type is a different finding.\n */\nexport function blockManifestPropFindings(\n type: string,\n props: Record<string, unknown> | undefined,\n specs: readonly ManifestPropSpec[] | undefined,\n path = 'root'\n): ManifestPropFinding[] {\n if (!specs || !props) return []\n const byName = new Map(specs.map((s) => [s.name, s]))\n const out: ManifestPropFinding[] = []\n for (const [prop, value] of Object.entries(props)) {\n if (value === undefined) continue\n const spec = byName.get(prop)\n if (!spec) {\n out.push({\n path,\n type,\n prop,\n code: 'UNKNOWN_PROP',\n severity: 'warning',\n message: `\"${prop}\" is not a prop of ${type}; the block ignores it.`,\n })\n continue\n }\n if (spec.bindable === false && carriesTemplate(value)) {\n out.push({\n path,\n type,\n prop,\n code: 'TEMPLATE_ON_UNBINDABLE',\n severity: 'warning',\n message: `\"${prop}\" on ${type} takes a literal value; its {{ }} template is shown as written.`,\n })\n }\n }\n return out\n}\n\n/**\n * Every manifest finding in a layout tree, with path context. Blocks whose\n * type is not in `manifests` are skipped.\n */\nexport function manifestPropFindings(\n layout: LayoutNode,\n manifests: BlockManifestPropsMap,\n path = 'root'\n): ManifestPropFinding[] {\n const out = blockManifestPropFindings(layout.type, layout.props, manifests[layout.type], path)\n if (layout.children) {\n layout.children.forEach((child, i) => {\n if (child) out.push(...manifestPropFindings(child, manifests, `${path}.children[${i}]`))\n })\n }\n return out\n}\n"]}
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Contract Validator
3
+ *
4
+ * Runtime validation for contracts
5
+ *
6
+ * @module @pwfabric/runtime/validator
7
+ */
8
+ import type { Contract, Capability, ValidationResult, ValidationError } from '@pwfabric/contracts';
9
+ /**
10
+ * Contract validator interface
11
+ */
12
+ export interface ContractValidator {
13
+ /**
14
+ * Validate input against a contract
15
+ */
16
+ validateInput<T>(contract: Contract<T, unknown>, data: unknown): ValidationResult<T>;
17
+ /**
18
+ * Validate output against a contract
19
+ */
20
+ validateOutput<T>(contract: Contract<unknown, T>, data: unknown): ValidationResult<T>;
21
+ /**
22
+ * Validate a capability's contract
23
+ */
24
+ validateCapability(capability: Capability): ValidationResult<void>;
25
+ }
26
+ /**
27
+ * Runtime contract validator
28
+ */
29
+ export declare class RuntimeContractValidator implements ContractValidator {
30
+ validateInput<T>(contract: Contract<T, unknown>, data: unknown): ValidationResult<T>;
31
+ validateOutput<T>(contract: Contract<unknown, T>, data: unknown): ValidationResult<T>;
32
+ validateCapability(capability: Capability): ValidationResult<void>;
33
+ }
34
+ /**
35
+ * Create a contract validator
36
+ */
37
+ export declare function createValidator(): ContractValidator;
38
+ /**
39
+ * Validation result type guard
40
+ */
41
+ export declare function isValidationSuccess<T>(result: ValidationResult<T>): result is {
42
+ success: true;
43
+ data: T;
44
+ };
45
+ /**
46
+ * Validation result type guard for errors
47
+ */
48
+ export declare function isValidationFailure<T>(result: ValidationResult<T>): result is {
49
+ success: false;
50
+ error: ValidationError[];
51
+ };
52
+ /**
53
+ * Format validation errors as a string
54
+ */
55
+ export declare function formatValidationErrors(errors: ValidationError[]): string;
@@ -0,0 +1,100 @@
1
+ /**
2
+ * Contract Validator
3
+ *
4
+ * Runtime validation for contracts
5
+ *
6
+ * @module @pwfabric/runtime/validator
7
+ */
8
+ import { ok, err, validationError } from '@pwfabric/contracts';
9
+ // ============================================================
10
+ // RUNTIME VALIDATOR IMPLEMENTATION
11
+ // ============================================================
12
+ /**
13
+ * Runtime contract validator
14
+ */
15
+ export class RuntimeContractValidator {
16
+ validateInput(contract, data) {
17
+ try {
18
+ return contract.validateInput(data);
19
+ }
20
+ catch (error) {
21
+ const errors = [
22
+ validationError([], error instanceof Error ? error.message : 'Unknown validation error', 'validation_error'),
23
+ ];
24
+ return err(errors);
25
+ }
26
+ }
27
+ validateOutput(contract, data) {
28
+ try {
29
+ return contract.validateOutput(data);
30
+ }
31
+ catch (error) {
32
+ const errors = [
33
+ validationError([], error instanceof Error ? error.message : 'Unknown validation error', 'validation_error'),
34
+ ];
35
+ return err(errors);
36
+ }
37
+ }
38
+ validateCapability(capability) {
39
+ const errors = [];
40
+ // Validate capability has required fields
41
+ if (!capability.id) {
42
+ errors.push(validationError(['id'], 'Capability ID is required', 'required'));
43
+ }
44
+ if (!capability.version) {
45
+ errors.push(validationError(['version'], 'Capability version is required', 'required'));
46
+ }
47
+ if (!capability.contract) {
48
+ errors.push(validationError(['contract'], 'Capability contract is required', 'required'));
49
+ }
50
+ if (!capability.execute) {
51
+ errors.push(validationError(['execute'], 'Capability execute function is required', 'required'));
52
+ }
53
+ // Validate contract exists and has required methods
54
+ if (capability.contract) {
55
+ if (!capability.contract.validateInput) {
56
+ errors.push(validationError(['contract', 'validateInput'], 'Contract validateInput method is required', 'required'));
57
+ }
58
+ if (!capability.contract.validateOutput) {
59
+ errors.push(validationError(['contract', 'validateOutput'], 'Contract validateOutput method is required', 'required'));
60
+ }
61
+ }
62
+ if (errors.length > 0) {
63
+ return err(errors);
64
+ }
65
+ return ok(undefined);
66
+ }
67
+ }
68
+ // ============================================================
69
+ // VALIDATION UTILITIES
70
+ // ============================================================
71
+ /**
72
+ * Create a contract validator
73
+ */
74
+ export function createValidator() {
75
+ return new RuntimeContractValidator();
76
+ }
77
+ /**
78
+ * Validation result type guard
79
+ */
80
+ export function isValidationSuccess(result) {
81
+ return result.success === true;
82
+ }
83
+ /**
84
+ * Validation result type guard for errors
85
+ */
86
+ export function isValidationFailure(result) {
87
+ return result.success === false;
88
+ }
89
+ /**
90
+ * Format validation errors as a string
91
+ */
92
+ export function formatValidationErrors(errors) {
93
+ return errors
94
+ .map((e) => {
95
+ const path = e.path.length > 0 ? `${e.path.join('.')}: ` : '';
96
+ return `${path}${e.message} (${e.code})`;
97
+ })
98
+ .join('\n');
99
+ }
100
+ //# sourceMappingURL=validator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validator.js","sourceRoot":"","sources":["../src/validator.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,EAAE,EAAE,GAAG,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AA0B9D,+DAA+D;AAC/D,mCAAmC;AACnC,+DAA+D;AAE/D;;GAEG;AACH,MAAM,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A;AACjC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,sBAAsB,CAAC,MAAyB;IAC9D,OAAO,MAAM;SACV,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;QACT,MAAM,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAA;QAC7D,OAAO,GAAG,IAAI,GAAG,CAAC,CAAC,OAAO,KAAK,CAAC,CAAC,IAAI,GAAG,CAAA;IAC1C,CAAC,CAAC;SACD,IAAI,CAAC,IAAI,CAAC,CAAA;AACf,CAAC","sourcesContent":["/**\n * Contract Validator\n *\n * Runtime validation for contracts\n *\n * @module @pwfabric/runtime/validator\n */\n\nimport type { Contract, Capability, ValidationResult, ValidationError } from '@pwfabric/contracts'\nimport { ok, err, validationError } from '@pwfabric/contracts'\n\n// ============================================================\n// VALIDATOR INTERFACE\n// ============================================================\n\n/**\n * Contract validator interface\n */\nexport interface ContractValidator {\n /**\n * Validate input against a contract\n */\n validateInput<T>(contract: Contract<T, unknown>, data: unknown): ValidationResult<T>\n\n /**\n * Validate output against a contract\n */\n validateOutput<T>(contract: Contract<unknown, T>, data: unknown): ValidationResult<T>\n\n /**\n * Validate a capability's contract\n */\n validateCapability(capability: Capability): ValidationResult<void>\n}\n\n// ============================================================\n// RUNTIME VALIDATOR IMPLEMENTATION\n// ============================================================\n\n/**\n * Runtime contract validator\n */\nexport class RuntimeContractValidator implements ContractValidator {\n validateInput<T>(contract: Contract<T, unknown>, data: unknown): ValidationResult<T> {\n try {\n return contract.validateInput(data)\n } catch (error) {\n const errors: ValidationError[] = [\n validationError(\n [],\n error instanceof Error ? error.message : 'Unknown validation error',\n 'validation_error'\n ),\n ]\n return err(errors)\n }\n }\n\n validateOutput<T>(contract: Contract<unknown, T>, data: unknown): ValidationResult<T> {\n try {\n return contract.validateOutput(data)\n } catch (error) {\n const errors: ValidationError[] = [\n validationError(\n [],\n error instanceof Error ? error.message : 'Unknown validation error',\n 'validation_error'\n ),\n ]\n return err(errors)\n }\n }\n\n validateCapability(capability: Capability): ValidationResult<void> {\n const errors: ValidationError[] = []\n\n // Validate capability has required fields\n if (!capability.id) {\n errors.push(validationError(['id'], 'Capability ID is required', 'required'))\n }\n\n if (!capability.version) {\n errors.push(validationError(['version'], 'Capability version is required', 'required'))\n }\n\n if (!capability.contract) {\n errors.push(validationError(['contract'], 'Capability contract is required', 'required'))\n }\n\n if (!capability.execute) {\n errors.push(\n validationError(['execute'], 'Capability execute function is required', 'required')\n )\n }\n\n // Validate contract exists and has required methods\n if (capability.contract) {\n if (!capability.contract.validateInput) {\n errors.push(\n validationError(\n ['contract', 'validateInput'],\n 'Contract validateInput method is required',\n 'required'\n )\n )\n }\n\n if (!capability.contract.validateOutput) {\n errors.push(\n validationError(\n ['contract', 'validateOutput'],\n 'Contract validateOutput method is required',\n 'required'\n )\n )\n }\n }\n\n if (errors.length > 0) {\n return err(errors)\n }\n\n return ok(undefined)\n }\n}\n\n// ============================================================\n// VALIDATION UTILITIES\n// ============================================================\n\n/**\n * Create a contract validator\n */\nexport function createValidator(): ContractValidator {\n return new RuntimeContractValidator()\n}\n\n/**\n * Validation result type guard\n */\nexport function isValidationSuccess<T>(\n result: ValidationResult<T>\n): result is { success: true; data: T } {\n return result.success === true\n}\n\n/**\n * Validation result type guard for errors\n */\nexport function isValidationFailure<T>(\n result: ValidationResult<T>\n): result is { success: false; error: ValidationError[] } {\n return result.success === false\n}\n\n/**\n * Format validation errors as a string\n */\nexport function formatValidationErrors(errors: ValidationError[]): string {\n return errors\n .map((e) => {\n const path = e.path.length > 0 ? `${e.path.join('.')}: ` : ''\n return `${path}${e.message} (${e.code})`\n })\n .join('\\n')\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,109 @@
1
1
  {
2
2
  "name": "@pwfabric/runtime",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "1.0.0-rc.1",
4
+ "description": "PWFabric runtime and execution engine",
5
+ "type": "module",
6
+ "license": "BUSL-1.1",
7
+ "author": "PhiMajor Solutions",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/pwfabric/pwfabric.git",
11
+ "directory": "packages/runtime"
12
+ },
13
+ "homepage": "https://github.com/pwfabric/pwfabric#readme",
14
+ "bugs": {
15
+ "url": "https://github.com/pwfabric/pwfabric/issues"
16
+ },
17
+ "main": "./dist/index.js",
18
+ "types": "./dist/index.d.ts",
19
+ "exports": {
20
+ ".": {
21
+ "types": "./dist/index.d.ts",
22
+ "import": "./dist/index.js",
23
+ "default": "./dist/index.js"
24
+ },
25
+ "./adapters": {
26
+ "types": "./dist/adapters/index.d.ts",
27
+ "import": "./dist/adapters/index.js",
28
+ "default": "./dist/adapters/index.js"
29
+ },
30
+ "./capability": {
31
+ "types": "./dist/capability/index.d.ts",
32
+ "import": "./dist/capability/index.js",
33
+ "default": "./dist/capability/index.js"
34
+ },
35
+ "./blocks": {
36
+ "types": "./dist/blocks/index.d.ts",
37
+ "import": "./dist/blocks/index.js",
38
+ "default": "./dist/blocks/index.js"
39
+ },
40
+ "./auth": {
41
+ "types": "./dist/auth/index.d.ts",
42
+ "import": "./dist/auth/index.js",
43
+ "default": "./dist/auth/index.js"
44
+ },
45
+ "./data": {
46
+ "types": "./dist/data/index.d.ts",
47
+ "import": "./dist/data/index.js",
48
+ "default": "./dist/data/index.js"
49
+ },
50
+ "./blocks/*": {
51
+ "types": "./dist/blocks/*.d.ts",
52
+ "import": "./dist/blocks/*.js",
53
+ "default": "./dist/blocks/*.js"
54
+ },
55
+ "./render/*": {
56
+ "types": "./dist/render/*.d.ts",
57
+ "import": "./dist/render/*.js",
58
+ "default": "./dist/render/*.js"
59
+ }
60
+ },
61
+ "files": [
62
+ "dist",
63
+ "!dist/**/__tests__",
64
+ "!dist/**/__test-fixtures__",
65
+ "LICENSE",
66
+ "README.md"
67
+ ],
68
+ "engines": {
69
+ "node": ">=22"
70
+ },
71
+ "dependencies": {
72
+ "@pwfabric/contracts": "1.0.0-rc.1",
73
+ "@pwfabric/core": "1.0.0-rc.1"
74
+ },
75
+ "peerDependencies": {
76
+ "react": "^18.0.0 || ^19.0.0",
77
+ "zod": "^3.23.0"
78
+ },
79
+ "devDependencies": {
80
+ "@testing-library/jest-dom": "^6.9.1",
81
+ "@testing-library/react": "^16.3.1",
82
+ "@testing-library/user-event": "^14.6.1",
83
+ "@types/node": "^22.0.0",
84
+ "@types/react": "^19.0.0",
85
+ "@types/react-dom": "^19.0.0",
86
+ "@vitest/coverage-v8": "^2.1.9",
87
+ "jsdom": "^26.0.0",
88
+ "next": "^16.1.5",
89
+ "react": "^19.0.0",
90
+ "react-dom": "^19.0.0",
91
+ "typescript": "^5.4.0",
92
+ "vitest": "^2.0.0",
93
+ "zod": "^3.25.76"
94
+ },
95
+ "publishConfig": {
96
+ "access": "public"
97
+ },
98
+ "scripts": {
99
+ "build": "rm -rf dist tsconfig.tsbuildinfo && tsc",
100
+ "dev": "tsc --watch",
101
+ "test": "vitest run",
102
+ "test:watch": "vitest",
103
+ "test:coverage": "vitest run --coverage",
104
+ "lint": "eslint src",
105
+ "lint:fix": "eslint src --fix",
106
+ "typecheck": "tsc --noEmit",
107
+ "clean": "rm -rf dist"
108
+ }
6
109
  }