@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":"composition-rules.js","sourceRoot":"","sources":["../../src/blocks/composition-rules.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAElD,+DAA+D;AAC/D,iBAAiB;AACjB,+DAA+D;AAE/D;;;;GAIG;AACH,MAAM,CAAC,MAAM,YAAY,GAAoB;IAC3C,IAAI,EAAE,WAAW;IACjB,WAAW,EAAE,qCAAqC,iBAAiB,cAAc;IACjF,SAAS,EAAE,GAAG;IACd,MAAM,EAAE;QACN,QAAQ,EAAE,iBAAiB;KAC5B;CACF,CAAA;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAoB;IAC/C,IAAI,EAAE,kBAAkB;IACxB,WAAW,EACT,iHAAiH;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CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,KAAK,GAAG,IAAI,IAAI,CAAC,SAAS,KAAK,SAAS,CAAC,CAAA;AAClG,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,QAAiC;IAC9D,OAAO,gBAAgB,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAA;AAClE,CAAC;AAED,+DAA+D;AAC/D,gDAAgD;AAChD,wDAAwD;AACxD,+DAA+D;AAE/D,8CAA8C;AAC9C,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,GAAG,CAAC,gBAAgB,CAAC,MAAM,CAAC,eAA2B,CAAC,CAAA;AAEjG,8CAA8C;AAC9C,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,GAAG,CAAC,gBAAgB,CAAC,MAAM,CAAC,eAA2B,CAAC,CAAA","sourcesContent":["/**\n * Composition Rules\n *\n * CP7: Rules defining valid block compositions\n *\n * @module @pwfabric/core/blocks/composition-rules\n */\n\nimport type { CompositionRule } from '@pwfabric/core'\nimport { MAX_NESTING_DEPTH } from '@pwfabric/core'\n\n// ============================================================\n// BUILT-IN RULES\n// ============================================================\n\n/**\n * Maximum nesting depth rule\n *\n * Prevents blocks from being nested too deeply.\n */\nexport const maxDepthRule: CompositionRule = {\n type: 'max_depth',\n description: `Blocks cannot be nested more than ${MAX_NESTING_DEPTH} levels deep`,\n appliesTo: '*',\n config: {\n maxDepth: MAX_NESTING_DEPTH,\n },\n}\n\n/**\n * Form children rule\n *\n * Forms can contain all form input elements plus structural/content blocks.\n */\nexport const formChildrenRule: CompositionRule = {\n type: 'allowed_children',\n description:\n 'Forms can contain form input elements and structural/content blocks (text, heading, container, divider, button)',\n appliesTo: 'form',\n config: {\n allowedChildren: [\n // Form input elements — the form family of the first-party base pack as\n // shipped, so every field a form pattern uses passes validation.\n 'input',\n 'textarea',\n 'select',\n 'checkbox',\n 'radio',\n 'toggle',\n 'slider',\n 'combobox',\n 'date-input',\n 'file-dropzone',\n 'number-stepper',\n 'otp-input',\n 'rich-text-editor',\n 'segmented-control',\n 'tag-input',\n // legacy names kept so older documents keep validating\n 'switch',\n 'file-upload',\n // Structural / content blocks valid inside forms\n 'button',\n 'text',\n 'heading',\n 'container',\n 'divider',\n 'badge',\n 'icon',\n 'link',\n 'alert',\n ],\n },\n}\n\n/**\n * Grid children rule\n *\n * Grids cannot have nested grids as direct children.\n */\nexport const gridChildrenRule: CompositionRule = {\n type: 'allowed_children',\n description: 'Grids cannot contain other grids as direct children',\n appliesTo: 'grid',\n config: {\n disallowedChildren: ['grid'],\n },\n}\n\n/**\n * Button no children rule\n *\n * Buttons cannot have children.\n */\nexport const buttonNoChildrenRule: CompositionRule = {\n type: 'no_children',\n description: 'Buttons cannot have children',\n appliesTo: 'button',\n config: {},\n}\n\n/**\n * Text no children rule\n *\n * Text blocks cannot have children.\n */\nexport const textNoChildrenRule: CompositionRule = {\n type: 'no_children',\n description: 'Text blocks cannot have children',\n appliesTo: 'text',\n config: {},\n}\n\n/**\n * Heading no children rule\n *\n * Heading blocks cannot have children.\n */\nexport const headingNoChildrenRule: CompositionRule = {\n type: 'no_children',\n description: 'Heading blocks cannot have children',\n appliesTo: 'heading',\n config: {},\n}\n\n/**\n * Image no children rule\n *\n * Image blocks cannot have children.\n */\nexport const imageNoChildrenRule: CompositionRule = {\n type: 'no_children',\n description: 'Image blocks cannot have children',\n appliesTo: 'image',\n config: {},\n}\n\n/**\n * Input no children rule\n *\n * Input blocks cannot have children.\n */\nexport const inputNoChildrenRule: CompositionRule = {\n type: 'no_children',\n description: 'Input blocks cannot have children',\n appliesTo: 'input',\n config: {},\n}\n\n/**\n * Input required parent rule\n *\n * Inputs should be inside forms or containers.\n */\nexport const inputParentRule: CompositionRule = {\n type: 'allowed_parents',\n description: 'Inputs should be placed inside forms or containers',\n appliesTo: 'input',\n config: {\n allowedParents: ['form', 'container'],\n severity: 'warning',\n },\n}\n\n/**\n * Link no children rule\n *\n * Link blocks cannot have children.\n */\nexport const linkNoChildrenRule: CompositionRule = {\n type: 'no_children',\n description: 'Link blocks cannot have children',\n appliesTo: 'link',\n config: {},\n}\n\n/**\n * Icon no children rule\n *\n * Icon blocks cannot have children.\n */\nexport const iconNoChildrenRule: CompositionRule = {\n type: 'no_children',\n description: 'Icon blocks cannot have children',\n appliesTo: 'icon',\n config: {},\n}\n\n/**\n * Badge no children rule\n *\n * Badge blocks cannot have children.\n */\nexport const badgeNoChildrenRule: CompositionRule = {\n type: 'no_children',\n description: 'Badge blocks cannot have children',\n appliesTo: 'badge',\n config: {},\n}\n\n/**\n * Code no children rule\n *\n * Code blocks cannot have children.\n */\nexport const codeNoChildrenRule: CompositionRule = {\n type: 'no_children',\n description: 'Code blocks cannot have children',\n appliesTo: 'code',\n config: {},\n}\n\n/**\n * Divider no children rule\n *\n * Divider blocks cannot have children.\n */\nexport const dividerNoChildrenRule: CompositionRule = {\n type: 'no_children',\n description: 'Divider blocks cannot have children',\n appliesTo: 'divider',\n config: {},\n}\n\n/**\n * List no children rule\n *\n * List blocks cannot have children.\n */\nexport const listNoChildrenRule: CompositionRule = {\n type: 'no_children',\n description: 'List blocks cannot have children',\n appliesTo: 'list',\n config: {},\n}\n\n/**\n * Table no children rule\n *\n * Table blocks cannot have children.\n */\nexport const tableNoChildrenRule: CompositionRule = {\n type: 'no_children',\n description: 'Table blocks cannot have children',\n appliesTo: 'table',\n config: {},\n}\n\n// ============================================================\n// INTERACTIVE BLOCK RULES\n// ============================================================\n\n/**\n * Accordion no children rule\n *\n * Accordion items are defined via props, not children.\n */\nexport const accordionNoChildrenRule: CompositionRule = {\n type: 'no_children',\n description: 'Accordion items are defined via props, not as children blocks',\n appliesTo: 'accordion',\n config: {},\n}\n\n/**\n * Dropdown no children rule\n *\n * Dropdown items are defined via props, not children.\n */\nexport const dropdownNoChildrenRule: CompositionRule = {\n type: 'no_children',\n description: 'Dropdown items are defined via props, not as children blocks',\n appliesTo: 'dropdown',\n config: {},\n}\n\n/**\n * Avatar no children rule\n *\n * Avatar is a leaf block with no children.\n */\nexport const avatarNoChildrenRule: CompositionRule = {\n type: 'no_children',\n description: 'Avatar blocks cannot have children',\n appliesTo: 'avatar',\n config: {},\n}\n\n/**\n * Tooltip children rule\n *\n * Tooltip can wrap specific inline/interactive blocks.\n */\nexport const tooltipChildrenRule: CompositionRule = {\n type: 'allowed_children',\n description: 'Tooltips can only wrap text, buttons, icons, badges, and links',\n appliesTo: 'tooltip',\n config: {\n allowedChildren: ['text', 'button', 'icon', 'badge', 'link'],\n },\n}\n\n/**\n * Tabs children rule\n *\n * Tabs can contain containers as tab panels.\n */\nexport const tabsChildrenRule: CompositionRule = {\n type: 'allowed_children',\n description: 'Tabs can only contain containers as tab panel content',\n appliesTo: 'tabs',\n config: {\n allowedChildren: ['container'],\n },\n}\n\n/**\n * Modal children rule\n *\n * Modal can contain layout and content blocks.\n */\nexport const modalChildrenRule: CompositionRule = {\n type: 'allowed_children',\n description: 'Modals can contain layout and content blocks',\n appliesTo: 'modal',\n config: {\n allowedChildren: [\n 'container',\n 'grid',\n 'text',\n 'heading',\n 'button',\n 'image',\n 'form',\n 'input',\n 'list',\n 'table',\n 'divider',\n 'icon',\n 'badge',\n ],\n },\n}\n\n/**\n * No self nesting rule\n *\n * Blocks cannot be nested inside themselves.\n */\nexport const noSelfNestingRule: CompositionRule = {\n type: 'no_self_nesting',\n description: 'Blocks cannot be nested inside themselves',\n appliesTo: '*',\n config: {},\n}\n\n// ============================================================\n// ALL RULES\n// ============================================================\n\n/**\n * All composition rules\n */\nexport const compositionRules: readonly CompositionRule[] = [\n maxDepthRule,\n formChildrenRule,\n gridChildrenRule,\n // Content blocks - no children\n buttonNoChildrenRule,\n textNoChildrenRule,\n headingNoChildrenRule,\n linkNoChildrenRule,\n iconNoChildrenRule,\n badgeNoChildrenRule,\n codeNoChildrenRule,\n dividerNoChildrenRule,\n // Layout blocks - no children (leaf)\n listNoChildrenRule,\n tableNoChildrenRule,\n // Media blocks - no children\n imageNoChildrenRule,\n // Form blocks - no children\n inputNoChildrenRule,\n inputParentRule,\n // Interactive blocks\n accordionNoChildrenRule,\n dropdownNoChildrenRule,\n avatarNoChildrenRule,\n tooltipChildrenRule,\n tabsChildrenRule,\n modalChildrenRule,\n // Universal rules\n noSelfNestingRule,\n] as const\n\n/**\n * Get rules that apply to a specific block type\n *\n * @param blockType - Block type to get rules for\n * @returns Array of applicable rules\n */\nexport function getRulesForBlockType(blockType: string): readonly CompositionRule[] {\n return compositionRules.filter((rule) => rule.appliesTo === '*' || rule.appliesTo === blockType)\n}\n\n/**\n * Get rules by type\n *\n * @param ruleType - Rule type to filter by\n * @returns Array of matching rules\n */\nexport function getRulesByType(ruleType: CompositionRule['type']): readonly CompositionRule[] {\n return compositionRules.filter((rule) => rule.type === ruleType)\n}\n\n// ============================================================\n// CANONICAL CHILD SETS (single source of truth)\n// Import these in API validator instead of redeclaring.\n// ============================================================\n\n/** Allowed direct children of a tabs block */\nexport const TABS_ALLOWED_CHILDREN = new Set(tabsChildrenRule.config.allowedChildren as string[])\n\n/** Allowed direct children of a form block */\nexport const FORM_ALLOWED_CHILDREN = new Set(formChildrenRule.config.allowedChildren as string[])\n"]}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Block Component Hooks
3
+ *
4
+ * React hooks used by block components for event emission and surface ID access.
5
+ *
6
+ * @module @pwfabric/runtime/blocks/hooks
7
+ */
8
+ import type { SurfaceEventDescriptor } from '@pwfabric/contracts';
9
+ /**
10
+ * Hook for block components to emit surface events.
11
+ *
12
+ * When the context is absent (no bus provided by the surface renderer)
13
+ * the hook returns a no-op `emit` so callers need no guard code.
14
+ *
15
+ * @example
16
+ * ```tsx
17
+ * const { emit } = useSurfaceEvents()
18
+ *
19
+ * const handleClick = () => {
20
+ * emit({ type: SURFACE_EVENTS.BLOCK_CLICK, surfaceId, blockId: block.id })
21
+ * }
22
+ * ```
23
+ */
24
+ export declare function useSurfaceEvents(): {
25
+ emit: (partial: Omit<SurfaceEventDescriptor, 'timestamp'>) => void;
26
+ };
27
+ /**
28
+ * Hook that returns the current surface ID from `SurfaceIdContext`.
29
+ * Returns an empty string when no `BehaviorSurfaceProvider` is in the tree.
30
+ */
31
+ export declare function useSurfaceId(): string;
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Block Component Hooks
3
+ *
4
+ * React hooks used by block components for event emission and surface ID access.
5
+ *
6
+ * @module @pwfabric/runtime/blocks/hooks
7
+ */
8
+ import { useContext } from 'react';
9
+ import { SurfaceEventContext } from './surface-event-context.js';
10
+ import { SurfaceIdContext } from './surface-id-context.js';
11
+ /**
12
+ * Hook for block components to emit surface events.
13
+ *
14
+ * When the context is absent (no bus provided by the surface renderer)
15
+ * the hook returns a no-op `emit` so callers need no guard code.
16
+ *
17
+ * @example
18
+ * ```tsx
19
+ * const { emit } = useSurfaceEvents()
20
+ *
21
+ * const handleClick = () => {
22
+ * emit({ type: SURFACE_EVENTS.BLOCK_CLICK, surfaceId, blockId: block.id })
23
+ * }
24
+ * ```
25
+ */
26
+ export function useSurfaceEvents() {
27
+ const bus = useContext(SurfaceEventContext);
28
+ const emit = (partial) => {
29
+ if (!bus)
30
+ return;
31
+ bus.emit({ ...partial, timestamp: Date.now() });
32
+ };
33
+ return { emit };
34
+ }
35
+ /**
36
+ * Hook that returns the current surface ID from `SurfaceIdContext`.
37
+ * Returns an empty string when no `BehaviorSurfaceProvider` is in the tree.
38
+ */
39
+ export function useSurfaceId() {
40
+ return useContext(SurfaceIdContext);
41
+ }
42
+ //# sourceMappingURL=hooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hooks.js","sourceRoot":"","sources":["../../src/blocks/hooks.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAElC,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAA;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAE1D;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,gBAAgB;IAG9B,MAAM,GAAG,GAAG,UAAU,CAAC,mBAAmB,CAAC,CAAA;IAE3C,MAAM,IAAI,GAAG,CAAC,OAAkD,EAAQ,EAAE;QACxE,IAAI,CAAC,GAAG;YAAE,OAAM;QAChB,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,OAAO,EAAE,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC,CAAA;IACjD,CAAC,CAAA;IAED,OAAO,EAAE,IAAI,EAAE,CAAA;AACjB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY;IAC1B,OAAO,UAAU,CAAC,gBAAgB,CAAC,CAAA;AACrC,CAAC","sourcesContent":["/**\n * Block Component Hooks\n *\n * React hooks used by block components for event emission and surface ID access.\n *\n * @module @pwfabric/runtime/blocks/hooks\n */\n\nimport { useContext } from 'react'\nimport type { SurfaceEventDescriptor } from '@pwfabric/contracts'\nimport { SurfaceEventContext } from './surface-event-context.js'\nimport { SurfaceIdContext } from './surface-id-context.js'\n\n/**\n * Hook for block components to emit surface events.\n *\n * When the context is absent (no bus provided by the surface renderer)\n * the hook returns a no-op `emit` so callers need no guard code.\n *\n * @example\n * ```tsx\n * const { emit } = useSurfaceEvents()\n *\n * const handleClick = () => {\n * emit({ type: SURFACE_EVENTS.BLOCK_CLICK, surfaceId, blockId: block.id })\n * }\n * ```\n */\nexport function useSurfaceEvents(): {\n emit: (partial: Omit<SurfaceEventDescriptor, 'timestamp'>) => void\n} {\n const bus = useContext(SurfaceEventContext)\n\n const emit = (partial: Omit<SurfaceEventDescriptor, 'timestamp'>): void => {\n if (!bus) return\n bus.emit({ ...partial, timestamp: Date.now() })\n }\n\n return { emit }\n}\n\n/**\n * Hook that returns the current surface ID from `SurfaceIdContext`.\n * Returns an empty string when no `BehaviorSurfaceProvider` is in the tree.\n */\nexport function useSurfaceId(): string {\n return useContext(SurfaceIdContext)\n}\n"]}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * @pwfabric/runtime/blocks
3
+ *
4
+ * Core UI block schemas, definitions, and React components for the PWFabric platform.
5
+ *
6
+ * @module @pwfabric/runtime/blocks
7
+ */
8
+ export * from './registry.js';
9
+ export * from './composition-rules.js';
10
+ export * from './rule-engine.js';
11
+ export * from './component-types.js';
12
+ export { SurfaceEventContext } from './surface-event-context.js';
13
+ export { SurfaceIdContext } from './surface-id-context.js';
14
+ export { useSurfaceEvents, useSurfaceId } from './hooks.js';
@@ -0,0 +1,23 @@
1
+ /**
2
+ * @pwfabric/runtime/blocks
3
+ *
4
+ * Core UI block schemas, definitions, and React components for the PWFabric platform.
5
+ *
6
+ * @module @pwfabric/runtime/blocks
7
+ */
8
+ // `./blocks/*` directory deleted — first-party block
9
+ // components live exclusively in `pwpack-source/<pack>/blocks/<cat>/<name>/component.tsx`
10
+ // and are loaded at runtime through the dynamic install pipeline.
11
+ export * from './registry.js';
12
+ export * from './composition-rules.js';
13
+ export * from './rule-engine.js';
14
+ export * from './component-types.js';
15
+ export { SurfaceEventContext } from './surface-event-context.js';
16
+ export { SurfaceIdContext } from './surface-id-context.js';
17
+ export { useSurfaceEvents, useSurfaceId } from './hooks.js';
18
+ // The test fixtures (populateTestBlocks, TEST_BLOCK_DEFINITIONS) are NOT
19
+ // exported: tests import ./__test-fixtures__/block-fixtures.js directly, and
20
+ // the published package does not ship that folder. Block metadata reaches a
21
+ // running app through the install pipeline (`useInstalledAtoms` in the
22
+ // browser, `installedBlocksOverride` on the server).
23
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/blocks/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,qDAAqD;AACrD,0FAA0F;AAC1F,kEAAkE;AAClE,cAAc,eAAe,CAAA;AAC7B,cAAc,wBAAwB,CAAA;AACtC,cAAc,kBAAkB,CAAA;AAChC,cAAc,sBAAsB,CAAA;AACpC,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAA;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAC1D,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAE3D,yEAAyE;AACzE,6EAA6E;AAC7E,4EAA4E;AAC5E,uEAAuE;AACvE,qDAAqD","sourcesContent":["/**\n * @pwfabric/runtime/blocks\n *\n * Core UI block schemas, definitions, and React components for the PWFabric platform.\n *\n * @module @pwfabric/runtime/blocks\n */\n\n// `./blocks/*` directory deleted — first-party block\n// components live exclusively in `pwpack-source/<pack>/blocks/<cat>/<name>/component.tsx`\n// and are loaded at runtime through the dynamic install pipeline.\nexport * from './registry.js'\nexport * from './composition-rules.js'\nexport * from './rule-engine.js'\nexport * from './component-types.js'\nexport { SurfaceEventContext } from './surface-event-context.js'\nexport { SurfaceIdContext } from './surface-id-context.js'\nexport { useSurfaceEvents, useSurfaceId } from './hooks.js'\n\n// The test fixtures (populateTestBlocks, TEST_BLOCK_DEFINITIONS) are NOT\n// exported: tests import ./__test-fixtures__/block-fixtures.js directly, and\n// the published package does not ship that folder. Block metadata reaches a\n// running app through the install pipeline (`useInstalledAtoms` in the\n// browser, `installedBlocksOverride` on the server).\n"]}
@@ -0,0 +1,84 @@
1
+ /**
2
+ * Block Registry
3
+ *
4
+ * CP7: Central registry for block type definitions
5
+ *
6
+ * @module @pwfabric/core/blocks/registry
7
+ */
8
+ import type { BlockDefinition, BlockCategory } from '@pwfabric/core';
9
+ /**
10
+ * Block Registry
11
+ *
12
+ * Manages registration and retrieval of block definitions.
13
+ */
14
+ export declare class BlockRegistry {
15
+ private readonly definitions;
16
+ /**
17
+ * Register a block definition
18
+ *
19
+ * @param definition - Block definition to register
20
+ * @throws Error if block type already registered
21
+ */
22
+ register(definition: BlockDefinition): void;
23
+ /**
24
+ * Get a block definition by type
25
+ *
26
+ * @param type - Block type identifier
27
+ * @returns Block definition or undefined
28
+ */
29
+ get(type: string): BlockDefinition | undefined;
30
+ /**
31
+ * Check if a block type is registered
32
+ *
33
+ * @param type - Block type identifier
34
+ * @returns True if registered
35
+ */
36
+ has(type: string): boolean;
37
+ /**
38
+ * Get all registered block definitions
39
+ *
40
+ * @returns Array of all block definitions
41
+ */
42
+ list(): readonly BlockDefinition[];
43
+ /**
44
+ * Get block definitions by category
45
+ *
46
+ * @param category - Block category
47
+ * @returns Array of block definitions in category
48
+ */
49
+ getByCategory(category: BlockCategory): readonly BlockDefinition[];
50
+ /**
51
+ * Get all registered block types
52
+ *
53
+ * @returns Array of block type identifiers
54
+ */
55
+ types(): readonly string[];
56
+ /**
57
+ * Unregister a block definition
58
+ *
59
+ * @param type - Block type identifier
60
+ * @returns True if block was unregistered
61
+ */
62
+ unregister(type: string): boolean;
63
+ /**
64
+ * Clear all registrations
65
+ */
66
+ clear(): void;
67
+ }
68
+ /**
69
+ * Default block registry singleton (intentionally empty post-).
70
+ */
71
+ export declare const blockRegistry: BlockRegistry;
72
+ /**
73
+ * Get the default block registry
74
+ *
75
+ * @returns The default block registry instance
76
+ */
77
+ export declare function getBlockRegistry(): BlockRegistry;
78
+ /**
79
+ * Create a new block registry
80
+ *
81
+ * @param populate - Whether to populate with default blocks
82
+ * @returns New block registry instance
83
+ */
84
+ export declare function createBlockRegistry(populate?: boolean): BlockRegistry;
@@ -0,0 +1,136 @@
1
+ /**
2
+ * Block Registry
3
+ *
4
+ * CP7: Central registry for block type definitions
5
+ *
6
+ * @module @pwfabric/core/blocks/registry
7
+ */
8
+ // legacy first-party `BlockDefinition` imports moved
9
+ // to the `__test-fixtures__/block-fixtures.ts` module so this
10
+ // production registry file no longer pulls the 45 hardcoded blocks
11
+ // into its bundle. Block authoring is canonical in
12
+ // `pwpack-source/<pack>/.../component.tsx`; the runtime registry is
13
+ // populated per world via `getBlockRegistryForWorld` (browser) or
14
+ // `assembleCanonicalRegistry({installedBlocksOverride})` (server).
15
+ // Tests that need a populated singleton must explicitly import
16
+ // `populateTestBlocks` from the fixtures module.
17
+ // ============================================================
18
+ // BLOCK REGISTRY CLASS
19
+ // ============================================================
20
+ /**
21
+ * Block Registry
22
+ *
23
+ * Manages registration and retrieval of block definitions.
24
+ */
25
+ export class BlockRegistry {
26
+ definitions = new Map();
27
+ /**
28
+ * Register a block definition
29
+ *
30
+ * @param definition - Block definition to register
31
+ * @throws Error if block type already registered
32
+ */
33
+ register(definition) {
34
+ if (this.definitions.has(definition.type)) {
35
+ throw new Error(`Block type "${definition.type}" is already registered`);
36
+ }
37
+ this.definitions.set(definition.type, definition);
38
+ }
39
+ /**
40
+ * Get a block definition by type
41
+ *
42
+ * @param type - Block type identifier
43
+ * @returns Block definition or undefined
44
+ */
45
+ get(type) {
46
+ return this.definitions.get(type);
47
+ }
48
+ /**
49
+ * Check if a block type is registered
50
+ *
51
+ * @param type - Block type identifier
52
+ * @returns True if registered
53
+ */
54
+ has(type) {
55
+ return this.definitions.has(type);
56
+ }
57
+ /**
58
+ * Get all registered block definitions
59
+ *
60
+ * @returns Array of all block definitions
61
+ */
62
+ list() {
63
+ return Array.from(this.definitions.values());
64
+ }
65
+ /**
66
+ * Get block definitions by category
67
+ *
68
+ * @param category - Block category
69
+ * @returns Array of block definitions in category
70
+ */
71
+ getByCategory(category) {
72
+ return this.list().filter((def) => def.category === category);
73
+ }
74
+ /**
75
+ * Get all registered block types
76
+ *
77
+ * @returns Array of block type identifiers
78
+ */
79
+ types() {
80
+ return Array.from(this.definitions.keys());
81
+ }
82
+ /**
83
+ * Unregister a block definition
84
+ *
85
+ * @param type - Block type identifier
86
+ * @returns True if block was unregistered
87
+ */
88
+ unregister(type) {
89
+ return this.definitions.delete(type);
90
+ }
91
+ /**
92
+ * Clear all registrations
93
+ */
94
+ clear() {
95
+ this.definitions.clear();
96
+ }
97
+ }
98
+ // ============================================================
99
+ // REGISTRY SINGLETON
100
+ // ============================================================
101
+ /**
102
+ * the default block registry is empty. Per-world content
103
+ * comes through the dynamic install pipeline — see
104
+ * `getBlockRegistryForWorld` (browser) / `loadInstalledBlocksForWorld`
105
+ * (server). The empty singleton is kept for legacy callers that just
106
+ * type-check against `BlockRegistry`; production code paths must NOT
107
+ * depend on it being pre-populated.
108
+ */
109
+ function createDefaultRegistry() {
110
+ return new BlockRegistry();
111
+ }
112
+ /**
113
+ * Default block registry singleton (intentionally empty post-).
114
+ */
115
+ export const blockRegistry = createDefaultRegistry();
116
+ /**
117
+ * Get the default block registry
118
+ *
119
+ * @returns The default block registry instance
120
+ */
121
+ export function getBlockRegistry() {
122
+ return blockRegistry;
123
+ }
124
+ /**
125
+ * Create a new block registry
126
+ *
127
+ * @param populate - Whether to populate with default blocks
128
+ * @returns New block registry instance
129
+ */
130
+ export function createBlockRegistry(populate = false) {
131
+ if (populate) {
132
+ return createDefaultRegistry();
133
+ }
134
+ return new BlockRegistry();
135
+ }
136
+ //# sourceMappingURL=registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/blocks/registry.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,qDAAqD;AACrD,8DAA8D;AAC9D,mEAAmE;AACnE,mDAAmD;AACnD,oEAAoE;AACpE,kEAAkE;AAClE,mEAAmE;AACnE,+DAA+D;AAC/D,iDAAiD;AAEjD,+DAA+D;AAC/D,uBAAuB;AACvB,+DAA+D;AAE/D;;;;GAIG;AACH,MAAM,OAAO,aAAa;IACP,WAAW,GAAG,IAAI,GAAG,EAA2B,CAAA;IAEjE;;;;;OAKG;IACH,QAAQ,CAAC,UAA2B;QAClC,IAAI,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;YAC1C,MAAM,IAAI,KAAK,CAAC,eAAe,UAAU,CAAC,IAAI,yBAAyB,CAAC,CAAA;QAC1E,CAAC;QACD,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC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AAQ,GAAG,KAAK;IAClD,IAAI,QAAQ,EAAE,CAAC;QACb,OAAO,qBAAqB,EAAE,CAAA;IAChC,CAAC;IACD,OAAO,IAAI,aAAa,EAAE,CAAA;AAC5B,CAAC","sourcesContent":["/**\n * Block Registry\n *\n * CP7: Central registry for block type definitions\n *\n * @module @pwfabric/core/blocks/registry\n */\n\nimport type { BlockDefinition, BlockCategory } from '@pwfabric/core'\n// legacy first-party `BlockDefinition` imports moved\n// to the `__test-fixtures__/block-fixtures.ts` module so this\n// production registry file no longer pulls the 45 hardcoded blocks\n// into its bundle. Block authoring is canonical in\n// `pwpack-source/<pack>/.../component.tsx`; the runtime registry is\n// populated per world via `getBlockRegistryForWorld` (browser) or\n// `assembleCanonicalRegistry({installedBlocksOverride})` (server).\n// Tests that need a populated singleton must explicitly import\n// `populateTestBlocks` from the fixtures module.\n\n// ============================================================\n// BLOCK REGISTRY CLASS\n// ============================================================\n\n/**\n * Block Registry\n *\n * Manages registration and retrieval of block definitions.\n */\nexport class BlockRegistry {\n private readonly definitions = new Map<string, BlockDefinition>()\n\n /**\n * Register a block definition\n *\n * @param definition - Block definition to register\n * @throws Error if block type already registered\n */\n register(definition: BlockDefinition): void {\n if (this.definitions.has(definition.type)) {\n throw new Error(`Block type \"${definition.type}\" is already registered`)\n }\n this.definitions.set(definition.type, definition)\n }\n\n /**\n * Get a block definition by type\n *\n * @param type - Block type identifier\n * @returns Block definition or undefined\n */\n get(type: string): BlockDefinition | undefined {\n return this.definitions.get(type)\n }\n\n /**\n * Check if a block type is registered\n *\n * @param type - Block type identifier\n * @returns True if registered\n */\n has(type: string): boolean {\n return this.definitions.has(type)\n }\n\n /**\n * Get all registered block definitions\n *\n * @returns Array of all block definitions\n */\n list(): readonly BlockDefinition[] {\n return Array.from(this.definitions.values())\n }\n\n /**\n * Get block definitions by category\n *\n * @param category - Block category\n * @returns Array of block definitions in category\n */\n getByCategory(category: BlockCategory): readonly BlockDefinition[] {\n return this.list().filter((def) => def.category === category)\n }\n\n /**\n * Get all registered block types\n *\n * @returns Array of block type identifiers\n */\n types(): readonly string[] {\n return Array.from(this.definitions.keys())\n }\n\n /**\n * Unregister a block definition\n *\n * @param type - Block type identifier\n * @returns True if block was unregistered\n */\n unregister(type: string): boolean {\n return this.definitions.delete(type)\n }\n\n /**\n * Clear all registrations\n */\n clear(): void {\n this.definitions.clear()\n }\n}\n\n// ============================================================\n// REGISTRY SINGLETON\n// ============================================================\n\n/**\n * the default block registry is empty. Per-world content\n * comes through the dynamic install pipeline — see\n * `getBlockRegistryForWorld` (browser) / `loadInstalledBlocksForWorld`\n * (server). The empty singleton is kept for legacy callers that just\n * type-check against `BlockRegistry`; production code paths must NOT\n * depend on it being pre-populated.\n */\nfunction createDefaultRegistry(): BlockRegistry {\n return new BlockRegistry()\n}\n\n/**\n * Default block registry singleton (intentionally empty post-).\n */\nexport const blockRegistry = createDefaultRegistry()\n\n/**\n * Get the default block registry\n *\n * @returns The default block registry instance\n */\nexport function getBlockRegistry(): BlockRegistry {\n return blockRegistry\n}\n\n/**\n * Create a new block registry\n *\n * @param populate - Whether to populate with default blocks\n * @returns New block registry instance\n */\nexport function createBlockRegistry(populate = false): BlockRegistry {\n if (populate) {\n return createDefaultRegistry()\n }\n return new BlockRegistry()\n}\n"]}
@@ -0,0 +1,131 @@
1
+ /**
2
+ * Composition Rule Engine
3
+ *
4
+ * CP7: Validation engine for block compositions
5
+ * Block metadata accessor is now an injectable provider so
6
+ * web-side editor flows can supply install-aware data without depending on
7
+ * the populated runtime singleton.
8
+ *
9
+ * @module @pwfabric/core/blocks/rule-engine
10
+ */
11
+ import type { Block, BlockValidationResult as ValidationResult, CompositionRule } from '@pwfabric/core';
12
+ /**
13
+ * Snapshot of the block metadata the rule engine consults during
14
+ * validation. A subset of `BlockDefinition` — only the fields that
15
+ * affect composition decisions (name + child/parent rules).
16
+ */
17
+ export interface BlockMetaSnapshot {
18
+ readonly type: string;
19
+ readonly name: string;
20
+ readonly canHaveChildren: boolean;
21
+ readonly allowedChildren?: readonly string[];
22
+ readonly allowedParents?: readonly string[];
23
+ }
24
+ /**
25
+ * Pluggable block metadata accessor. The default implementation is a
26
+ * thin adapter over the legacy `blockRegistry` singleton; install-aware
27
+ * editor flows construct their own provider that wraps
28
+ * `useInstalledAtoms` data.
29
+ */
30
+ export interface BlockMetaProvider {
31
+ get(type: string): BlockMetaSnapshot | undefined;
32
+ }
33
+ /**
34
+ * Default provider — reads from the runtime `blockRegistry` singleton.
35
+ * Returns `undefined` for types absent from the singleton (post-
36
+ * the singleton is empty by default).
37
+ */
38
+ export declare const defaultBlockMetaProvider: BlockMetaProvider;
39
+ export declare const CompositionErrorCode: {
40
+ readonly MAX_DEPTH_EXCEEDED: "MAX_DEPTH_EXCEEDED";
41
+ readonly INVALID_CHILD: "INVALID_CHILD";
42
+ readonly INVALID_PARENT: "INVALID_PARENT";
43
+ readonly NO_CHILDREN_ALLOWED: "NO_CHILDREN_ALLOWED";
44
+ readonly SELF_NESTING: "SELF_NESTING";
45
+ readonly UNKNOWN_BLOCK_TYPE: "UNKNOWN_BLOCK_TYPE";
46
+ readonly ORPHANED_BLOCK: "ORPHANED_BLOCK";
47
+ };
48
+ export type CompositionErrorCodeType = (typeof CompositionErrorCode)[keyof typeof CompositionErrorCode];
49
+ /**
50
+ * Composition Rule Engine
51
+ *
52
+ * Validates block compositions against defined rules.
53
+ */
54
+ export declare class CompositionRuleEngine {
55
+ /** Rules for this engine instance (reserved for future custom rule support) */
56
+ readonly rules: readonly CompositionRule[];
57
+ /** Block metadata accessor */
58
+ readonly meta: BlockMetaProvider;
59
+ constructor(rules?: readonly CompositionRule[], meta?: BlockMetaProvider);
60
+ /**
61
+ * Check if a child can be inserted into a parent
62
+ *
63
+ * @param parent - Parent block (null for root level)
64
+ * @param childType - Type of child block to insert
65
+ * @param currentDepth - Current nesting depth
66
+ * @returns Validation result
67
+ */
68
+ canInsert(parent: Block | null, childType: string, currentDepth?: number): ValidationResult;
69
+ /**
70
+ * Check if a block can be moved to a new parent
71
+ *
72
+ * @param block - Block to move
73
+ * @param newParent - New parent block (null for root level)
74
+ * @param currentDepth - Current nesting depth
75
+ * @returns Validation result
76
+ */
77
+ canMove(block: Block, newParent: Block | null, currentDepth?: number): ValidationResult;
78
+ /**
79
+ * Validate an entire block tree
80
+ *
81
+ * @param blocks - Root level blocks to validate
82
+ * @returns Array of validation errors
83
+ */
84
+ validateTree(blocks: readonly Block[]): ValidationResult;
85
+ /**
86
+ * Get the depth of a block in a tree
87
+ *
88
+ * @param blocks - Root level blocks
89
+ * @param targetId - ID of block to find
90
+ * @returns Depth of block or -1 if not found
91
+ */
92
+ getBlockDepth(blocks: readonly Block[], targetId: string): number;
93
+ /**
94
+ * Check if a block is a descendant of another block
95
+ *
96
+ * @param block - Block to check descendants of
97
+ * @param potentialAncestor - Potential ancestor block
98
+ * @returns True if block is a descendant
99
+ */
100
+ private isDescendantOf;
101
+ }
102
+ /**
103
+ * Default composition rule engine singleton
104
+ */
105
+ export declare const compositionRuleEngine: CompositionRuleEngine;
106
+ /**
107
+ * Get the default composition rule engine
108
+ *
109
+ * @returns The default rule engine instance
110
+ */
111
+ export declare function getCompositionRuleEngine(): CompositionRuleEngine;
112
+ /**
113
+ * Create a new composition rule engine
114
+ *
115
+ * @param rules - Optional custom rules
116
+ * @param meta - Optional block metadata provider
117
+ * @returns New rule engine instance
118
+ */
119
+ export declare function createCompositionRuleEngine(rules?: readonly CompositionRule[], meta?: BlockMetaProvider): CompositionRuleEngine;
120
+ /**
121
+ * Check if a block can be inserted (convenience function)
122
+ */
123
+ export declare function canInsertBlock(parent: Block | null, childType: string, currentDepth?: number): ValidationResult;
124
+ /**
125
+ * Check if a block can be moved (convenience function)
126
+ */
127
+ export declare function canMoveBlock(block: Block, newParent: Block | null, currentDepth?: number): ValidationResult;
128
+ /**
129
+ * Validate a block tree (convenience function)
130
+ */
131
+ export declare function validateBlockTree(blocks: readonly Block[]): ValidationResult;