@arkitektio/bsx 4.3.0 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (349) hide show
  1. package/README.md +39 -18
  2. package/dist/bsx/analyze.d.ts +6 -5
  3. package/dist/bsx/analyze.d.ts.map +1 -1
  4. package/dist/bsx/analyze.js +12 -10
  5. package/dist/bsx/analyze.js.map +1 -1
  6. package/dist/bsx/declared.d.ts +111 -0
  7. package/dist/bsx/declared.d.ts.map +1 -0
  8. package/dist/bsx/declared.js +311 -0
  9. package/dist/bsx/declared.js.map +1 -0
  10. package/dist/bsx/index.d.ts +1 -0
  11. package/dist/bsx/index.d.ts.map +1 -1
  12. package/dist/bsx/index.js +1 -0
  13. package/dist/bsx/index.js.map +1 -1
  14. package/dist/bsx/infer.d.ts +40 -17
  15. package/dist/bsx/infer.d.ts.map +1 -1
  16. package/dist/bsx/infer.js +105 -49
  17. package/dist/bsx/infer.js.map +1 -1
  18. package/dist/bsx/language.d.ts +6 -2
  19. package/dist/bsx/language.d.ts.map +1 -1
  20. package/dist/bsx/language.js +65 -21
  21. package/dist/bsx/language.js.map +1 -1
  22. package/dist/bsx/parse.d.ts +19 -8
  23. package/dist/bsx/parse.d.ts.map +1 -1
  24. package/dist/bsx/parse.js +49 -59
  25. package/dist/bsx/parse.js.map +1 -1
  26. package/dist/bsx/print.d.ts.map +1 -1
  27. package/dist/bsx/print.js +25 -35
  28. package/dist/bsx/print.js.map +1 -1
  29. package/dist/bsx/references.d.ts +48 -54
  30. package/dist/bsx/references.d.ts.map +1 -1
  31. package/dist/bsx/references.js +359 -159
  32. package/dist/bsx/references.js.map +1 -1
  33. package/dist/catalogs/html.d.ts +3 -3
  34. package/dist/catalogs/html.d.ts.map +1 -1
  35. package/dist/catalogs/html.js +3 -3
  36. package/dist/catalogs/html.js.map +1 -1
  37. package/dist/catalogs/index.d.ts +172 -180
  38. package/dist/catalogs/index.d.ts.map +1 -1
  39. package/dist/catalogs/index.js +6 -2
  40. package/dist/catalogs/index.js.map +1 -1
  41. package/dist/catalogs/logo.d.ts +19 -33
  42. package/dist/catalogs/logo.d.ts.map +1 -1
  43. package/dist/catalogs/logo.js +4 -5
  44. package/dist/catalogs/logo.js.map +1 -1
  45. package/dist/catalogs/parts/data.d.ts +6 -6
  46. package/dist/catalogs/parts/feedback.d.ts +15 -15
  47. package/dist/catalogs/parts/forms.d.ts +24 -24
  48. package/dist/catalogs/parts/html.d.ts +3 -3
  49. package/dist/catalogs/parts/html.d.ts.map +1 -1
  50. package/dist/catalogs/parts/html.js +1 -1
  51. package/dist/catalogs/parts/html.js.map +1 -1
  52. package/dist/catalogs/parts/icons.d.ts +11 -11
  53. package/dist/catalogs/parts/icons.js +1 -1
  54. package/dist/catalogs/parts/index.d.ts +153 -165
  55. package/dist/catalogs/parts/index.d.ts.map +1 -1
  56. package/dist/catalogs/parts/layout.d.ts +11 -1
  57. package/dist/catalogs/parts/layout.d.ts.map +1 -1
  58. package/dist/catalogs/parts/layout.js +9 -0
  59. package/dist/catalogs/parts/layout.js.map +1 -1
  60. package/dist/catalogs/parts/logo.d.ts +17 -32
  61. package/dist/catalogs/parts/logo.d.ts.map +1 -1
  62. package/dist/catalogs/parts/logo.js +13 -15
  63. package/dist/catalogs/parts/logo.js.map +1 -1
  64. package/dist/catalogs/parts/navigation.d.ts +20 -20
  65. package/dist/catalogs/parts/overlays.d.ts +55 -55
  66. package/dist/catalogs/parts/run.d.ts +5 -13
  67. package/dist/catalogs/parts/run.d.ts.map +1 -1
  68. package/dist/catalogs/parts/run.js +1 -1
  69. package/dist/catalogs/parts/scene.d.ts +9 -17
  70. package/dist/catalogs/parts/scene.d.ts.map +1 -1
  71. package/dist/catalogs/parts/scene.js +1 -5
  72. package/dist/catalogs/parts/scene.js.map +1 -1
  73. package/dist/catalogs/parts/structure.js +2 -2
  74. package/dist/catalogs/parts/toast.js +1 -1
  75. package/dist/catalogs/parts/toast.js.map +1 -1
  76. package/dist/catalogs/parts/typography.d.ts +3 -3
  77. package/dist/catalogs/parts/typography.js +1 -1
  78. package/dist/catalogs/parts/typography.js.map +1 -1
  79. package/dist/catalogs/props.d.ts +4 -4
  80. package/dist/catalogs/scene.d.ts +8 -16
  81. package/dist/catalogs/scene.d.ts.map +1 -1
  82. package/dist/catalogs/scene.js +3 -3
  83. package/dist/catalogs/scene.js.map +1 -1
  84. package/dist/catalogs/shadcn.d.ts +58 -58
  85. package/dist/catalogs/shadcn.d.ts.map +1 -1
  86. package/dist/catalogs/shadcn.js +4 -4
  87. package/dist/catalogs/shadcn.js.map +1 -1
  88. package/dist/catalogs/structure.d.ts +1 -1
  89. package/dist/catalogs/structure.d.ts.map +1 -1
  90. package/dist/catalogs/structure.js +3 -3
  91. package/dist/catalogs/structure.js.map +1 -1
  92. package/dist/catalogs/ui.d.ts +83 -73
  93. package/dist/catalogs/ui.d.ts.map +1 -1
  94. package/dist/catalogs/ui.js +4 -3
  95. package/dist/catalogs/ui.js.map +1 -1
  96. package/dist/catalogs.d.ts +1 -1
  97. package/dist/catalogs.d.ts.map +1 -1
  98. package/dist/catalogs.js +2 -2
  99. package/dist/catalogs.js.map +1 -1
  100. package/dist/logo/actionLogoSource.d.ts +3 -3
  101. package/dist/logo/actionLogoSource.d.ts.map +1 -1
  102. package/dist/logo/actionLogoSource.js +4 -4
  103. package/dist/logo/actionLogoSource.js.map +1 -1
  104. package/dist/ports.js +1 -1
  105. package/dist/ports.js.map +1 -1
  106. package/dist/renderer/BlokRenderer.d.ts +10 -6
  107. package/dist/renderer/BlokRenderer.d.ts.map +1 -1
  108. package/dist/renderer/BlokRenderer.js +23 -9
  109. package/dist/renderer/BlokRenderer.js.map +1 -1
  110. package/dist/renderer/baseCatalog.d.ts +8 -6
  111. package/dist/renderer/baseCatalog.d.ts.map +1 -1
  112. package/dist/renderer/baseCatalog.js +7 -5
  113. package/dist/renderer/baseCatalog.js.map +1 -1
  114. package/dist/renderer/bloks/control.d.ts +20 -2
  115. package/dist/renderer/bloks/control.d.ts.map +1 -1
  116. package/dist/renderer/bloks/control.js +98 -15
  117. package/dist/renderer/bloks/control.js.map +1 -1
  118. package/dist/renderer/bloks/data.d.ts +6 -6
  119. package/dist/renderer/bloks/feedback.d.ts +15 -15
  120. package/dist/renderer/bloks/forms.d.ts +24 -24
  121. package/dist/renderer/bloks/html.d.ts +2 -2
  122. package/dist/renderer/bloks/html.js +2 -2
  123. package/dist/renderer/bloks/icons.d.ts +5 -5
  124. package/dist/renderer/bloks/index.d.ts +145 -144
  125. package/dist/renderer/bloks/index.d.ts.map +1 -1
  126. package/dist/renderer/bloks/index.js +1 -1
  127. package/dist/renderer/bloks/layout.d.ts +9 -1
  128. package/dist/renderer/bloks/layout.d.ts.map +1 -1
  129. package/dist/renderer/bloks/layout.js +15 -0
  130. package/dist/renderer/bloks/layout.js.map +1 -1
  131. package/dist/renderer/bloks/logo/index.d.ts +6 -13
  132. package/dist/renderer/bloks/logo/index.d.ts.map +1 -1
  133. package/dist/renderer/bloks/logo/index.js +3 -4
  134. package/dist/renderer/bloks/logo/index.js.map +1 -1
  135. package/dist/renderer/bloks/logo/logo.fixture.json +266 -250
  136. package/dist/renderer/bloks/navigation.d.ts +20 -20
  137. package/dist/renderer/bloks/overlays.d.ts +55 -55
  138. package/dist/renderer/bloks/run/components.d.ts +2 -6
  139. package/dist/renderer/bloks/run/components.d.ts.map +1 -1
  140. package/dist/renderer/bloks/run/components.js +1 -1
  141. package/dist/renderer/bloks/scene/index.d.ts +5 -9
  142. package/dist/renderer/bloks/scene/index.d.ts.map +1 -1
  143. package/dist/renderer/bloks/scene/interaction.d.ts.map +1 -1
  144. package/dist/renderer/bloks/scene/interaction.js +3 -2
  145. package/dist/renderer/bloks/scene/interaction.js.map +1 -1
  146. package/dist/renderer/bloks/shared/props.d.ts +2 -2
  147. package/dist/renderer/bloks/toast.d.ts +1 -1
  148. package/dist/renderer/bloks/typography.d.ts +3 -3
  149. package/dist/renderer/bloks/typography.js +1 -1
  150. package/dist/renderer/catalog.d.ts +4 -7
  151. package/dist/renderer/catalog.d.ts.map +1 -1
  152. package/dist/renderer/catalog.js +7 -31
  153. package/dist/renderer/catalog.js.map +1 -1
  154. package/dist/renderer/declarations.d.ts +40 -33
  155. package/dist/renderer/declarations.d.ts.map +1 -1
  156. package/dist/renderer/declarations.js +41 -56
  157. package/dist/renderer/declarations.js.map +1 -1
  158. package/dist/renderer/declare.d.ts +31 -19
  159. package/dist/renderer/declare.d.ts.map +1 -1
  160. package/dist/renderer/declare.js +44 -18
  161. package/dist/renderer/declare.js.map +1 -1
  162. package/dist/renderer/persist.d.ts +22 -13
  163. package/dist/renderer/persist.d.ts.map +1 -1
  164. package/dist/renderer/persist.js +40 -21
  165. package/dist/renderer/persist.js.map +1 -1
  166. package/dist/renderer/runtime/catalog.d.ts +27 -7
  167. package/dist/renderer/runtime/catalog.d.ts.map +1 -1
  168. package/dist/renderer/runtime/catalog.js +30 -3
  169. package/dist/renderer/runtime/catalog.js.map +1 -1
  170. package/dist/renderer/runtime/components.d.ts +10 -4
  171. package/dist/renderer/runtime/components.d.ts.map +1 -1
  172. package/dist/renderer/runtime/components.js +8 -5
  173. package/dist/renderer/runtime/components.js.map +1 -1
  174. package/dist/renderer/runtime/context.d.ts +5 -5
  175. package/dist/renderer/runtime/context.d.ts.map +1 -1
  176. package/dist/renderer/runtime/context.js +11 -5
  177. package/dist/renderer/runtime/context.js.map +1 -1
  178. package/dist/renderer/runtime/describe.d.ts +16 -6
  179. package/dist/renderer/runtime/describe.d.ts.map +1 -1
  180. package/dist/renderer/runtime/describe.js +5 -2
  181. package/dist/renderer/runtime/describe.js.map +1 -1
  182. package/dist/renderer/runtime/hooks.d.ts.map +1 -1
  183. package/dist/renderer/runtime/hooks.js +8 -4
  184. package/dist/renderer/runtime/hooks.js.map +1 -1
  185. package/dist/renderer/runtime/index.d.ts +2 -0
  186. package/dist/renderer/runtime/index.d.ts.map +1 -1
  187. package/dist/renderer/runtime/index.js +2 -0
  188. package/dist/renderer/runtime/index.js.map +1 -1
  189. package/dist/renderer/runtime/locals.d.ts +57 -0
  190. package/dist/renderer/runtime/locals.d.ts.map +1 -0
  191. package/dist/renderer/runtime/locals.js +87 -0
  192. package/dist/renderer/runtime/locals.js.map +1 -0
  193. package/dist/renderer/runtime/preflight.d.ts.map +1 -1
  194. package/dist/renderer/runtime/preflight.js +5 -2
  195. package/dist/renderer/runtime/preflight.js.map +1 -1
  196. package/dist/renderer/runtime/scope.d.ts +14 -0
  197. package/dist/renderer/runtime/scope.d.ts.map +1 -1
  198. package/dist/renderer/runtime/scope.js +25 -3
  199. package/dist/renderer/runtime/scope.js.map +1 -1
  200. package/dist/renderer/runtime/text.d.ts +28 -0
  201. package/dist/renderer/runtime/text.d.ts.map +1 -0
  202. package/dist/renderer/runtime/text.js +82 -0
  203. package/dist/renderer/runtime/text.js.map +1 -0
  204. package/dist/renderer/runtime/tree.d.ts.map +1 -1
  205. package/dist/renderer/runtime/tree.js +7 -1
  206. package/dist/renderer/runtime/tree.js.map +1 -1
  207. package/dist/renderer/runtime/types.d.ts +8 -3
  208. package/dist/renderer/runtime/types.d.ts.map +1 -1
  209. package/dist/runtime.d.ts +0 -1
  210. package/dist/runtime.d.ts.map +1 -1
  211. package/dist/runtime.js +0 -1
  212. package/dist/runtime.js.map +1 -1
  213. package/dist/scene.d.ts +1 -1
  214. package/dist/scene.d.ts.map +1 -1
  215. package/dist/scene.js +2 -2
  216. package/dist/scene.js.map +1 -1
  217. package/dist/shadcn.d.ts +154 -153
  218. package/dist/shadcn.d.ts.map +1 -1
  219. package/dist/shadcn.js +7 -7
  220. package/dist/shadcn.js.map +1 -1
  221. package/dist/spec/bsx_v2.json +12324 -6934
  222. package/dist/spec/catalogs/base@4.json +13175 -0
  223. package/dist/spec/catalogs/base@4.json.js +13175 -0
  224. package/dist/spec/catalogs/orkestrator@1.json +489 -0
  225. package/dist/spec/catalogs/orkestrator@1.json.js +489 -0
  226. package/dist/spec/catalogs.d.ts +109 -46
  227. package/dist/spec/catalogs.d.ts.map +1 -1
  228. package/dist/spec/catalogs.js +243 -75
  229. package/dist/spec/catalogs.js.map +1 -1
  230. package/dist/spec/vocabulary.d.ts +44 -7
  231. package/dist/spec/vocabulary.d.ts.map +1 -1
  232. package/dist/spec/vocabulary.js +65 -7
  233. package/dist/spec/vocabulary.js.map +1 -1
  234. package/dist/spec/vocabulary.json +83 -43
  235. package/dist/spec/vocabulary.json.js +83 -43
  236. package/dist/vendor/core/ui/button-group.d.ts +1 -1
  237. package/dist/vendor/core/ui/button.d.ts +1 -1
  238. package/dist/vendor/core/ui/field.d.ts +1 -1
  239. package/package.json +1 -1
  240. package/src/bsx/analyze.ts +14 -12
  241. package/src/bsx/bsx.test.ts +4 -4
  242. package/src/bsx/declared.ts +346 -0
  243. package/src/bsx/index.ts +1 -0
  244. package/src/bsx/infer.test.ts +54 -52
  245. package/src/bsx/infer.ts +128 -71
  246. package/src/bsx/language.test.ts +37 -25
  247. package/src/bsx/language.ts +72 -25
  248. package/src/bsx/parse.ts +51 -64
  249. package/src/bsx/partial.test.ts +1 -1
  250. package/src/bsx/print.ts +27 -34
  251. package/src/bsx/references.test.ts +86 -83
  252. package/src/bsx/references.ts +391 -198
  253. package/src/catalogs/catalogs.test.ts +46 -14
  254. package/src/catalogs/html.ts +3 -3
  255. package/src/catalogs/index.ts +6 -2
  256. package/src/catalogs/logo.ts +4 -5
  257. package/src/catalogs/parts/html.ts +1 -1
  258. package/src/catalogs/parts/icons.ts +1 -1
  259. package/src/catalogs/parts/layout.ts +11 -0
  260. package/src/catalogs/parts/logo.ts +14 -18
  261. package/src/catalogs/parts/run.ts +1 -1
  262. package/src/catalogs/parts/scene.ts +1 -7
  263. package/src/catalogs/parts/structure.ts +2 -2
  264. package/src/catalogs/parts/toast.ts +1 -1
  265. package/src/catalogs/parts/typography.ts +1 -1
  266. package/src/catalogs/scene.ts +3 -3
  267. package/src/catalogs/shadcn.ts +4 -4
  268. package/src/catalogs/structure.ts +3 -3
  269. package/src/catalogs/ui.ts +4 -3
  270. package/src/catalogs.ts +9 -2
  271. package/src/logo/actionLogoSource.ts +4 -4
  272. package/src/ports.ts +1 -1
  273. package/src/renderer/BlokComponentHost.test.tsx +5 -5
  274. package/src/renderer/BlokRenderer.tsx +46 -14
  275. package/src/renderer/addBlokComponents.test.tsx +8 -22
  276. package/src/renderer/baseCatalog.ts +7 -5
  277. package/src/renderer/bloks/components.test.tsx +2 -2
  278. package/src/renderer/bloks/control.tsx +136 -17
  279. package/src/renderer/bloks/flow.test.tsx +1 -1
  280. package/src/renderer/bloks/html.tsx +2 -2
  281. package/src/renderer/bloks/index.ts +1 -1
  282. package/src/renderer/bloks/layout.tsx +28 -0
  283. package/src/renderer/bloks/logo/index.tsx +4 -5
  284. package/src/renderer/bloks/logo/logo.fixture.json +266 -250
  285. package/src/renderer/bloks/logo/logo.test.tsx +18 -7
  286. package/src/renderer/bloks/run/components.tsx +1 -1
  287. package/src/renderer/bloks/run/space.test.tsx +12 -4
  288. package/src/renderer/bloks/scene/interaction.tsx +11 -6
  289. package/src/renderer/bloks/scene/transform.test.ts +8 -7
  290. package/src/renderer/bloks/time.test.tsx +1 -1
  291. package/src/renderer/bloks/toast.tsx +1 -1
  292. package/src/renderer/bloks/typography.tsx +1 -1
  293. package/src/renderer/catalog.tsx +7 -31
  294. package/src/renderer/declarations.test.ts +38 -51
  295. package/src/renderer/declarations.ts +67 -88
  296. package/src/renderer/declare.test.ts +41 -0
  297. package/src/renderer/declare.ts +70 -32
  298. package/src/renderer/persist.test.ts +70 -49
  299. package/src/renderer/persist.ts +57 -34
  300. package/src/renderer/runtime/catalog.test.ts +2 -2
  301. package/src/renderer/runtime/catalog.ts +35 -10
  302. package/src/renderer/runtime/components.tsx +17 -8
  303. package/src/renderer/runtime/context.tsx +17 -10
  304. package/src/renderer/runtime/describe.ts +21 -8
  305. package/src/renderer/runtime/hooks.ts +6 -4
  306. package/src/renderer/runtime/index.ts +2 -0
  307. package/src/renderer/runtime/locals.tsx +105 -0
  308. package/src/renderer/runtime/preflight.ts +5 -2
  309. package/src/renderer/runtime/scope.tsx +31 -3
  310. package/src/renderer/runtime/text.test.tsx +65 -0
  311. package/src/renderer/runtime/text.ts +88 -0
  312. package/src/renderer/runtime/tree.tsx +16 -4
  313. package/src/renderer/runtime/types.ts +8 -3
  314. package/src/runtime.ts +0 -1
  315. package/src/scene.ts +2 -2
  316. package/src/shadcn.ts +7 -7
  317. package/src/spec/bsx_v2.json +12324 -6934
  318. package/src/spec/catalogs/base@4.json +13175 -0
  319. package/src/spec/catalogs/orkestrator@1.json +489 -0
  320. package/src/spec/catalogs.ts +259 -103
  321. package/src/spec/spec.test.ts +93 -24
  322. package/src/spec/vocabulary.json +83 -43
  323. package/src/spec/vocabulary.ts +102 -17
  324. package/dist/renderer/modules.d.ts +0 -4
  325. package/dist/renderer/modules.d.ts.map +0 -1
  326. package/dist/renderer/modules.js +0 -11
  327. package/dist/renderer/modules.js.map +0 -1
  328. package/dist/spec/catalogs/base@2.json +0 -355
  329. package/dist/spec/catalogs/base@2.json.js +0 -355
  330. package/dist/spec/catalogs/html@1.json +0 -308
  331. package/dist/spec/catalogs/html@1.json.js +0 -308
  332. package/dist/spec/catalogs/logo@1.json +0 -1687
  333. package/dist/spec/catalogs/logo@1.json.js +0 -1687
  334. package/dist/spec/catalogs/scene@1.json +0 -878
  335. package/dist/spec/catalogs/scene@1.json.js +0 -878
  336. package/dist/spec/catalogs/shadcn@1.json +0 -4002
  337. package/dist/spec/catalogs/shadcn@1.json.js +0 -4002
  338. package/dist/spec/catalogs/structure@1.json +0 -185
  339. package/dist/spec/catalogs/structure@1.json.js +0 -185
  340. package/dist/spec/catalogs/ui@1.json +0 -5349
  341. package/dist/spec/catalogs/ui@1.json.js +0 -5349
  342. package/src/renderer/modules.ts +0 -12
  343. package/src/spec/catalogs/base@2.json +0 -355
  344. package/src/spec/catalogs/html@1.json +0 -308
  345. package/src/spec/catalogs/logo@1.json +0 -1687
  346. package/src/spec/catalogs/scene@1.json +0 -878
  347. package/src/spec/catalogs/shadcn@1.json +0 -4002
  348. package/src/spec/catalogs/structure@1.json +0 -185
  349. package/src/spec/catalogs/ui@1.json +0 -5349
@@ -1,16 +1,29 @@
1
1
  import { type BlokContextName, type VocabFunction } from './vocabulary';
2
2
  /**
3
- * What a v2 blok is parsed and checked against, in the spec's terms. base@2
4
- * (the language) is the spec's; the global catalogs (`ui@1`, `scene@1`,
5
- * `logo@1`, `structure@1`, `html@1`, `shadcn@1`) are written from this
6
- * package's contracts (`catalogs/`, `pnpm spec:export`). A *module* is a UI's
7
- * own unversioned catalog, registered by that UI (the server's `Module`): an
8
- * app adds its own to the default view with `registerBlokModules`. The port
9
- * of arkitekt-spec's `blok/catalogs` (`BlokView`, `default_view`).
3
+ * The catalogs a blok is drawn with, in the spec's terms: the port of
4
+ * arkitekt-spec's `blok/catalogs`.
5
+ *
6
+ * A *catalog* is a versioned set of components, named by the address it is
7
+ * published at (its `id`).
8
+ *
9
+ * - The **base catalog** (`catalogs/base@4.json`,
10
+ * `https://arkitekt.live/catalogs/base/v4`): everything every renderer draws.
11
+ * The language's own elements, the html components, the structure and run
12
+ * parts a host supplies, the scene and the logo shapes. The spec owns it; this
13
+ * package's contracts (`catalogs/`) are held to it by a test.
14
+ * - An **app catalog** extends another (in the end the base) with what one
15
+ * frontend draws beyond it. A snapshot of the Orkestrator's ships
16
+ * (`catalogs/orkestrator@1.json`); any other is registered by the app that
17
+ * draws it (`registerBlokCatalog`).
18
+ *
19
+ * A blok names the one catalog it is written for; the base when it names none.
20
+ * A catalog only ever adds to what it extends.
10
21
  */
11
22
  export declare const BASE_NAME = "base";
12
- export declare const STANDARD_CATALOGS: readonly ["ui", "scene", "logo", "structure", "html", "shadcn"];
13
- export type StandardCatalog = (typeof STANDARD_CATALOGS)[number];
23
+ /** The family of the language's own elements (control flow, async boundaries, the Blok element, the declarations, text). */
24
+ export declare const LANGUAGE_GROUP = "language";
25
+ /** The Orkestrator's catalog: what it draws beyond the base. */
26
+ export declare const ORKESTRATOR_CATALOG_ID = "https://arkitekt.live/catalogs/orkestrator/v1";
14
27
  export type SpecEventField = {
15
28
  key: string;
16
29
  kind: string;
@@ -26,6 +39,8 @@ export type SpecProp = {
26
39
  event: readonly SpecEventField[] | null;
27
40
  /** For a `STRING`, the closed set of literals the component draws; null: any string. */
28
41
  values: readonly string[] | null;
42
+ /** The minor of its catalog that added the prop; 0: there from the start. */
43
+ since: number;
29
44
  };
30
45
  export type SpecComponent = {
31
46
  name: string;
@@ -36,10 +51,20 @@ export type SpecComponent = {
36
51
  acceptsChildren: boolean;
37
52
  downstreamOf: readonly string[];
38
53
  notDownstreamOf: readonly string[];
39
- /** The prop text children fill (`<Button>Grip</Button>` sets `label`); null: it takes no text. */
54
+ /** The prop its text children fill when it draws them (`<Button>Grip</Button>` is its `label`); null: it has none. */
40
55
  textProp: string | null;
41
56
  props: readonly SpecProp[];
42
- /** The catalog it is from, `name@version` (`ui@1`), or the module's name (`orkestrator`). */
57
+ /** The blok kinds it may be placed in (`assign`); empty: any kind. */
58
+ kinds: readonly string[];
59
+ /** The service it needs where it is drawn (`mikro`); null: none beyond the host's own. */
60
+ service: string | null;
61
+ /** The minor of its catalog that added it; 0: there from the start. */
62
+ since: number;
63
+ /** The family it is listed under (`language`, `ui`, `html`, `run`, `scene`, `logo`). */
64
+ group: string | null;
65
+ /** How it is drawn where there is no pointer, when that differs. */
66
+ touch: string | null;
67
+ /** The catalog it is from, `name@version` (`base@4`), or the bare name of one nothing published. */
43
68
  catalog: string;
44
69
  };
45
70
  export type SpecCatalog = {
@@ -47,57 +72,95 @@ export type SpecCatalog = {
47
72
  version: number | null;
48
73
  description: string | null;
49
74
  components: readonly SpecComponent[];
75
+ /** What a blok names it by: the address it is published at. Null for a catalog nothing targets. */
76
+ id: string | null;
77
+ /** How far it has grown within its version. */
78
+ minor: number;
79
+ /** The id of the catalog it adds to; null for the base catalog, and for one that adds to the base without saying so. */
80
+ extends: string | null;
50
81
  };
82
+ /**
83
+ * A catalog file (`{id, name, version, minor, extends, components}`) as a
84
+ * `SpecCatalog`. Only data is read, field by field; nothing is ever executed.
85
+ */
51
86
  export declare const parseSpecCatalog: (raw: unknown, file: string) => SpecCatalog;
52
- /** base@2: the language components. */
87
+ export declare const catalogLabel: (catalog: SpecCatalog) => string;
88
+ /** The base catalog: what every renderer draws. */
53
89
  export declare const baseCatalog: () => SpecCatalog;
54
- /** A standard catalog at the version the vocabulary names. */
55
- export declare const standardCatalog: (name: StandardCatalog) => SpecCatalog;
56
- export declare const standardCatalogs: () => SpecCatalog[];
90
+ /** The Orkestrator's catalog, as the snapshot this package ships. */
91
+ export declare const orkestratorCatalog: () => SpecCatalog;
57
92
  /**
58
- * A component name two sources define differently, and which definition is
59
- * drawn: a module's beats a standard catalog's (the app draws its own
60
- * `Slider`), base's is never shadowed, and between two standard catalogs the
61
- * first is kept. The validator warns `catalog.shadow` where a tree uses it.
93
+ * The catalog called `id`: one an app registered, or one that ships; undefined
94
+ * when unknown. What an app registers under the id of a shipped snapshot is
95
+ * that catalog here (the app that draws it knows it best); the base catalog
96
+ * is never replaced.
62
97
  */
63
- export type CatalogShadow = {
64
- component: string;
65
- /** The source that defines it first: base or a standard catalog (`ui@1`). */
66
- catalog: string;
67
- /** The source that defines it again: a module, or a later standard catalog. */
68
- module: string;
69
- /** Whose definition is used. */
70
- winner: string;
71
- };
72
- /** What a v2 blok is parsed and checked against. */
98
+ export declare const knownCatalog: (id: string) => SpecCatalog | undefined;
99
+ /** Every catalog known here: those that ship (the base first; a registered one in its snapshot's place), then those registered. */
100
+ export declare const knownCatalogs: () => SpecCatalog[];
101
+ /** Two definitions of a component are the same when everything but where they come from is. */
102
+ export declare const sameComponent: (a: SpecComponent, b: SpecComponent) => boolean;
103
+ /**
104
+ * The catalogs a blok written for `target` is drawn with, the base first.
105
+ * `target` is a catalog's id, a catalog (one nothing published: it extends the
106
+ * base unless it says otherwise), or null for the base alone. Throws when the
107
+ * target or a catalog it extends is not known, or a catalog redefines a
108
+ * component of one it extends.
109
+ */
110
+ export declare const catalogChain: (target?: string | SpecCatalog | null) => SpecCatalog[];
111
+ /** What a blok is drawn with: the components of the catalog it is written for, and of those that one extends, down to the base. */
73
112
  export type BlokView = {
74
113
  components: ReadonlyMap<string, SpecComponent>;
75
114
  functions: ReadonlyMap<string, VocabFunction>;
76
115
  label: string;
77
- /** Whether the components are every one the renderer draws, so an unknown one is a finding. */
116
+ /** Whether the components are every one the target draws, so an unknown one is a finding. */
78
117
  complete: boolean;
79
- /** The names two sources define differently, by name (`catalog.shadow`). */
80
- shadows: ReadonlyMap<string, CatalogShadow>;
118
+ /** The id of the catalog the view is of; null for one nothing published. */
119
+ target: string | null;
120
+ /** Per component of a known catalog the view is NOT of, that catalog's id (`catalog.target`). */
121
+ foreign: ReadonlyMap<string, string>;
81
122
  };
82
- /** Two definitions of a component are the same when everything but the catalog they come from is. */
83
- export declare const sameComponent: (a: SpecComponent, b: SpecComponent) => boolean;
84
- /**
85
- * The view base, the standard catalogs and `extra` ones (modules: the
86
- * Orkestrator's, an app's) give; the port of the spec's `blok_view`.
87
- */
88
- export declare const blokView: (extra?: readonly SpecCatalog[], options?: {
89
- standard?: boolean;
123
+ /** The view of a blok written for `target` (see `catalogChain`); the base's when null. */
124
+ export declare const blokView: (target?: string | SpecCatalog | null, options?: {
90
125
  complete?: boolean;
91
126
  }) => BlokView;
127
+ /** The view of a blok that names no catalog: the base catalog's. */
128
+ export declare const baseBlokView: () => BlokView;
129
+ /**
130
+ * Make a catalog known here, so a blok written for it is checked against it:
131
+ * what an app does with the catalog of what it draws beyond the base
132
+ * (`blokCatalogSpec` of its own contracts). Registered under the id of a
133
+ * snapshot that ships, it stands in its place; the base catalog is never
134
+ * replaced. Throws when it redefines a component of what it extends.
135
+ */
136
+ export declare const registerBlokCatalog: (catalog: SpecCatalog) => void;
137
+ /** Forget every catalog `registerBlokCatalog` was handed, and the app's own view (for tests). */
138
+ export declare const forgetBlokCatalogs: () => void;
92
139
  /**
93
- * The app's own catalogs, as its UI registers them (`describeBlokContract` of
94
- * each unversioned contract it implements): part of the default view from now
95
- * on, so the parser, the checks and the editor know its components. Call it
96
- * once at start, beside `configureBlokPlatform`.
140
+ * The catalog this app draws: the one its own editor, checks and renderer
141
+ * read a blok against when the blok names none of its own. An app that draws
142
+ * only the base leaves it unset. Call it once at start, beside
143
+ * `configureBlokPlatform`.
97
144
  */
98
- export declare const registerBlokModules: (modules: readonly SpecCatalog[]) => void;
99
- /** The app's view: base, every global catalog and its own (`registerBlokModules`). */
145
+ export declare const setAppBlokCatalog: (target: string | SpecCatalog | null) => void;
146
+ /** The app's own view: everything it draws (`setAppBlokCatalog`), the base catalog's when it set none. */
100
147
  export declare const defaultBlokView: () => BlokView;
148
+ /**
149
+ * The view a blok that names `catalog` is read against: that catalog's when it
150
+ * is known here, the app's own when the blok names none, and the base's,
151
+ * incomplete (nothing is reported unknown), for a catalog nobody here knows.
152
+ */
153
+ export declare const blokViewFor: (catalog: string | null | undefined) => BlokView;
154
+ /** Whether `target` can name a catalog at all: a published one's address, or the name of one registered in an organization. */
155
+ export declare const isCatalogTarget: (target: string) => boolean;
156
+ /** The minor of the catalog the view is of that `tree` needs: the newest `since` among the components and props of that catalog it uses. */
157
+ export declare const minorNeeded: (tree: {
158
+ component: string;
159
+ props?: ReadonlyArray<{
160
+ key: string;
161
+ }> | null;
162
+ children?: readonly unknown[] | null;
163
+ }, view: BlokView) => number;
101
164
  /** Whether a component is a language one that holds others in whatever context (`if`, `foreach`, `fragment`). */
102
165
  export declare const isLanguageContainer: (component: SpecComponent | undefined) => boolean;
103
166
  /** The context a component's children are in, given the one it sits in. */
@@ -1 +1 @@
1
- {"version":3,"file":"catalogs.d.ts","sourceRoot":"","sources":["../../src/spec/catalogs.ts"],"names":[],"mappings":"AAOA,OAAO,EAAiB,KAAK,eAAe,EAAE,KAAK,aAAa,EAAC,MAAM,cAAc,CAAC;AAEtF;;;;;;;;GAQG;AAEH,eAA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G,WAAW,GAAG,IAAI,KAAG,IAIvE,CAAC;AAEF,0GAA0G;AAC1G,eAAO,MAAM,eAAe,QAAO,QAGlC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,WAAW,GAAI,SAAS,MAAM,GAAG,IAAI,GAAG,SAAS,KAAG,QAIhE,CAAC;AAEF,+HAA+H;AAC/H,eAAO,MAAM,eAAe,GAAI,QAAQ,MAAM,KAAG,OAGhD,CAAC;AAEF,4IAA4I;AAC5I,eAAO,MAAM,WAAW,GAAI,MAAM;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,aAAa,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAC,CAAC,GAAG,IAAI,CAAC;IAAC,QAAQ,CAAC,EAAE,SAAS,OAAO,EAAE,GAAG,IAAI,CAAA;CAAC,EAAE,MAAM,QAAQ,KAAG,MAa1J,CAAC;AAEF,iHAAiH;AACjH,eAAO,MAAM,mBAAmB,GAAI,WAAW,aAAa,GAAG,SAAS,KAAG,OAC8C,CAAC;AAE1H,2EAA2E;AAC3E,eAAO,MAAM,YAAY,GAAI,WAAW,aAAa,GAAG,SAAS,EAAE,SAAS,eAAe,KAAG,eAG7F,CAAC"}
@@ -1,36 +1,58 @@
1
- import baseCatalogJson from './catalogs/base@2.json.js';
2
- import htmlCatalogJson from './catalogs/html@1.json.js';
3
- import logoCatalogJson from './catalogs/logo@1.json.js';
4
- import sceneCatalogJson from './catalogs/scene@1.json.js';
5
- import structureCatalogJson from './catalogs/structure@1.json.js';
6
- import shadcnCatalogJson from './catalogs/shadcn@1.json.js';
7
- import uiCatalogJson from './catalogs/ui@1.json.js';
1
+ import baseCatalogJson from './catalogs/base@4.json.js';
2
+ import orkestratorCatalogJson from './catalogs/orkestrator@1.json.js';
8
3
  import { loadVocabulary } from './vocabulary.js';
9
4
  /**
10
- * What a v2 blok is parsed and checked against, in the spec's terms. base@2
11
- * (the language) is the spec's; the global catalogs (`ui@1`, `scene@1`,
12
- * `logo@1`, `structure@1`, `html@1`, `shadcn@1`) are written from this
13
- * package's contracts (`catalogs/`, `pnpm spec:export`). A *module* is a UI's
14
- * own unversioned catalog, registered by that UI (the server's `Module`): an
15
- * app adds its own to the default view with `registerBlokModules`. The port
16
- * of arkitekt-spec's `blok/catalogs` (`BlokView`, `default_view`).
5
+ * The catalogs a blok is drawn with, in the spec's terms: the port of
6
+ * arkitekt-spec's `blok/catalogs`.
7
+ *
8
+ * A *catalog* is a versioned set of components, named by the address it is
9
+ * published at (its `id`).
10
+ *
11
+ * - The **base catalog** (`catalogs/base@4.json`,
12
+ * `https://arkitekt.live/catalogs/base/v4`): everything every renderer draws.
13
+ * The language's own elements, the html components, the structure and run
14
+ * parts a host supplies, the scene and the logo shapes. The spec owns it; this
15
+ * package's contracts (`catalogs/`) are held to it by a test.
16
+ * - An **app catalog** extends another (in the end the base) with what one
17
+ * frontend draws beyond it. A snapshot of the Orkestrator's ships
18
+ * (`catalogs/orkestrator@1.json`); any other is registered by the app that
19
+ * draws it (`registerBlokCatalog`).
20
+ *
21
+ * A blok names the one catalog it is written for; the base when it names none.
22
+ * A catalog only ever adds to what it extends.
17
23
  */
18
24
  export const BASE_NAME = 'base';
19
- export const STANDARD_CATALOGS = ['ui', 'scene', 'logo', 'structure', 'html', 'shadcn'];
25
+ /** The family of the language's own elements (control flow, async boundaries, the Blok element, the declarations, text). */
26
+ export const LANGUAGE_GROUP = 'language';
27
+ /** The Orkestrator's catalog: what it draws beyond the base. */
28
+ export const ORKESTRATOR_CATALOG_ID = 'https://arkitekt.live/catalogs/orkestrator/v1';
20
29
  const isRaw = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
21
30
  const rawList = (value) => (Array.isArray(value) ? value : []);
22
31
  const text = (value) => (typeof value === 'string' ? value : null);
23
32
  const texts = (value) => rawList(value).filter((item) => typeof item === 'string');
24
- const contextOf = (value) => value === 'HTML' || value === 'SCENE' || value === 'LOGO' ? value : null;
33
+ const count = (value) => (typeof value === 'number' && Number.isInteger(value) && value >= 0 ? value : 0);
34
+ const contextOf = (value) => value === 'PANEL' || value === 'SCENE' || value === 'LOGO' ? value : null;
35
+ /**
36
+ * A catalog file (`{id, name, version, minor, extends, components}`) as a
37
+ * `SpecCatalog`. Only data is read, field by field; nothing is ever executed.
38
+ */
25
39
  export const parseSpecCatalog = (raw, file) => {
26
40
  if (!isRaw(raw) || typeof raw.name !== 'string')
27
41
  throw new Error(`${file} is not a catalog`);
42
+ const vocabulary = loadVocabulary();
28
43
  const version = typeof raw.version === 'number' ? raw.version : null;
44
+ const address = (value, what) => {
45
+ if (value === undefined || value === null)
46
+ return null;
47
+ if (typeof value !== 'string' || !vocabulary.catalogId.test(value))
48
+ throw new Error(`${file} has an ${what} that is not the address of a catalog`);
49
+ return value;
50
+ };
29
51
  const catalog = version === null ? raw.name : `${raw.name}@${version}`;
30
52
  const components = rawList(raw.components).filter(isRaw).map((entry) => ({
31
53
  name: String(entry.name),
32
54
  description: text(entry.description),
33
- context: contextOf(entry.context) ?? 'HTML',
55
+ context: contextOf(entry.context) ?? 'PANEL',
34
56
  childrenContext: contextOf(entry.children_context),
35
57
  inheritsContext: entry.inherits_context === true,
36
58
  acceptsChildren: entry.accepts_children === true,
@@ -46,90 +68,236 @@ export const parseSpecCatalog = (raw, file) => {
46
68
  ? prop.event.filter(isRaw).map(field => ({ key: String(field.key), kind: String(field.kind), description: text(field.description) }))
47
69
  : null,
48
70
  values: Array.isArray(prop.values) ? prop.values.map(String) : null,
71
+ since: count(prop.since),
49
72
  })),
73
+ kinds: texts(entry.kinds),
74
+ service: text(entry.service) || null,
75
+ since: count(entry.since),
76
+ group: text(entry.group) || null,
77
+ touch: text(entry.touch) || null,
50
78
  catalog,
51
79
  }));
52
- return { name: raw.name, version, description: text(raw.description), components };
80
+ return {
81
+ name: raw.name,
82
+ version,
83
+ description: text(raw.description),
84
+ components,
85
+ id: address(raw.id, 'id'),
86
+ minor: count(raw.minor),
87
+ extends: address(raw.extends, 'extends'),
88
+ };
89
+ };
90
+ export const catalogLabel = (catalog) => (catalog.version === null ? catalog.name : `${catalog.name}@${catalog.version}`);
91
+ const BUNDLED = {
92
+ 'catalogs/base@4.json': baseCatalogJson,
93
+ 'catalogs/orkestrator@1.json': orkestratorCatalogJson,
53
94
  };
54
- let parsed = null;
55
- const catalogs = () => {
56
- if (!parsed) {
57
- parsed = {
58
- base: parseSpecCatalog(baseCatalogJson, 'catalogs/base@2.json'),
59
- standard: {
60
- ui: parseSpecCatalog(uiCatalogJson, 'catalogs/ui@1.json'),
61
- scene: parseSpecCatalog(sceneCatalogJson, 'catalogs/scene@1.json'),
62
- logo: parseSpecCatalog(logoCatalogJson, 'catalogs/logo@1.json'),
63
- structure: parseSpecCatalog(structureCatalogJson, 'catalogs/structure@1.json'),
64
- html: parseSpecCatalog(htmlCatalogJson, 'catalogs/html@1.json'),
65
- shadcn: parseSpecCatalog(shadcnCatalogJson, 'catalogs/shadcn@1.json'),
66
- },
67
- };
95
+ let bundled = null;
96
+ const bundledCatalogs = () => {
97
+ if (!bundled) {
98
+ bundled = new Map();
99
+ for (const [id, file] of Object.entries(loadVocabulary().bundledCatalogs)) {
100
+ const raw = BUNDLED[file];
101
+ if (raw === undefined)
102
+ throw new Error(`${file} does not ship with this package`);
103
+ const catalog = parseSpecCatalog(raw, file);
104
+ if (catalog.id !== id)
105
+ throw new Error(`${file} is ${catalog.id}, not ${id}`);
106
+ bundled.set(id, catalog);
107
+ }
68
108
  }
69
- return parsed;
109
+ return bundled;
70
110
  };
71
- /** base@2: the language components. */
72
- export const baseCatalog = () => catalogs().base;
73
- /** A standard catalog at the version the vocabulary names. */
74
- export const standardCatalog = (name) => catalogs().standard[name];
75
- export const standardCatalogs = () => STANDARD_CATALOGS.map(name => standardCatalog(name));
76
- const catalogLabel = (catalog) => (catalog.version === null ? catalog.name : `${catalog.name}@${catalog.version}`);
77
- /** Two definitions of a component are the same when everything but the catalog they come from is. */
111
+ /** Catalogs an app handed over (`registerBlokCatalog`), by id. */
112
+ const registered = new Map();
113
+ let defaultTarget = null;
114
+ let defaultView = null;
115
+ /** The base catalog: what every renderer draws. */
116
+ export const baseCatalog = () => bundledCatalogs().get(loadVocabulary().baseCatalog);
117
+ /** The Orkestrator's catalog, as the snapshot this package ships. */
118
+ export const orkestratorCatalog = () => bundledCatalogs().get(ORKESTRATOR_CATALOG_ID);
119
+ /**
120
+ * The catalog called `id`: one an app registered, or one that ships; undefined
121
+ * when unknown. What an app registers under the id of a shipped snapshot is
122
+ * that catalog here (the app that draws it knows it best); the base catalog
123
+ * is never replaced.
124
+ */
125
+ export const knownCatalog = (id) => registered.get(id) ?? bundledCatalogs().get(id);
126
+ /** Every catalog known here: those that ship (the base first; a registered one in its snapshot's place), then those registered. */
127
+ export const knownCatalogs = () => [
128
+ ...[...bundledCatalogs().values()].map(catalog => (catalog.id !== null ? registered.get(catalog.id) : undefined) ?? catalog),
129
+ ...[...registered.values()].filter(catalog => catalog.id === null || !bundledCatalogs().has(catalog.id)),
130
+ ];
131
+ /** Two definitions of a component are the same when everything but where they come from is. */
78
132
  export const sameComponent = (a, b) => {
79
- const withoutCatalog = (component) => JSON.stringify(component, (key, value) => (key === 'catalog' ? undefined : value));
80
- return withoutCatalog(a) === withoutCatalog(b);
133
+ const comparable = (component) => JSON.stringify(component, (key, value) => (key === 'catalog' || key === 'group' || key === 'touch' ? undefined : value));
134
+ return comparable(a) === comparable(b);
81
135
  };
82
136
  /**
83
- * The view base, the standard catalogs and `extra` ones (modules: the
84
- * Orkestrator's, an app's) give; the port of the spec's `blok_view`.
137
+ * The catalogs a blok written for `target` is drawn with, the base first.
138
+ * `target` is a catalog's id, a catalog (one nothing published: it extends the
139
+ * base unless it says otherwise), or null for the base alone. Throws when the
140
+ * target or a catalog it extends is not known, or a catalog redefines a
141
+ * component of one it extends.
85
142
  */
86
- export const blokView = (extra = [], options = {}) => {
143
+ export const catalogChain = (target = null) => {
87
144
  const base = baseCatalog();
88
- const sources = [base, ...(options.standard === false ? [] : standardCatalogs()), ...extra];
89
- const modules = new Set(extra);
90
- const baseLabel = catalogLabel(base);
91
- const components = new Map();
92
- const shadows = new Map();
93
- for (const catalog of sources) {
145
+ let current;
146
+ if (target === null)
147
+ current = base;
148
+ else if (typeof target === 'string') {
149
+ const named = knownCatalog(target);
150
+ if (!named)
151
+ throw new Error(`the catalog '${target}' is not known here`);
152
+ current = named;
153
+ }
154
+ else
155
+ current = target;
156
+ const chain = [];
157
+ const seen = new Set();
158
+ while (current !== base && current.id !== base.id) {
159
+ if (current.id !== null) {
160
+ if (seen.has(current.id))
161
+ throw new Error(`the catalog '${current.id}' extends itself`);
162
+ seen.add(current.id);
163
+ }
164
+ chain.push(current);
165
+ if (current.extends === null)
166
+ break;
167
+ const parent = knownCatalog(current.extends);
168
+ if (!parent)
169
+ throw new Error(`the catalog ${catalogLabel(current)} extends '${current.extends}', which is not known here`);
170
+ current = parent;
171
+ }
172
+ const ordered = [base, ...chain.reverse()];
173
+ const owner = new Map();
174
+ for (const catalog of ordered) {
94
175
  for (const component of catalog.components) {
95
- const previous = components.get(component.name);
96
- if (!previous) {
97
- components.set(component.name, component);
98
- continue;
176
+ const previous = owner.get(component.name);
177
+ if (previous && !sameComponent(previous[0], component)) {
178
+ throw new Error(`the catalog ${catalogLabel(catalog)} redefines <${component.name}> of ${previous[1]}: a catalog only adds`);
99
179
  }
100
- if (sameComponent(previous, component))
101
- continue;
102
- const kept = previous.catalog;
103
- const other = component.catalog || catalog.name;
104
- const wins = modules.has(catalog) && kept !== baseLabel;
105
- if (wins)
180
+ if (!previous)
181
+ owner.set(component.name, [component, catalogLabel(catalog)]);
182
+ }
183
+ }
184
+ return ordered;
185
+ };
186
+ /** The view of a blok written for `target` (see `catalogChain`); the base's when null. */
187
+ export const blokView = (target = null, options = {}) => {
188
+ const chain = catalogChain(target);
189
+ const components = new Map();
190
+ for (const catalog of chain) {
191
+ for (const component of catalog.components)
192
+ if (!components.has(component.name))
106
193
  components.set(component.name, component);
107
- shadows.set(component.name, { component: component.name, catalog: kept, module: other, winner: wins ? other : kept });
194
+ }
195
+ const foreign = new Map();
196
+ for (const catalog of knownCatalogs()) {
197
+ if (chain.includes(catalog) || catalog.id === null)
198
+ continue;
199
+ for (const component of catalog.components) {
200
+ if (!components.has(component.name) && !foreign.has(component.name))
201
+ foreign.set(component.name, catalog.id);
108
202
  }
109
203
  }
110
- const label = sources.map(catalogLabel).join(' + ');
111
- return { components, functions: loadVocabulary().functions, label, complete: options.complete ?? true, shadows };
204
+ return {
205
+ components,
206
+ functions: loadVocabulary().functions,
207
+ label: chain.map(catalogLabel).join(' + '),
208
+ complete: options.complete ?? true,
209
+ target: chain[chain.length - 1].id,
210
+ foreign,
211
+ };
212
+ };
213
+ /** The view of a blok that names no catalog: the base catalog's. */
214
+ export const baseBlokView = () => blokView();
215
+ /**
216
+ * Make a catalog known here, so a blok written for it is checked against it:
217
+ * what an app does with the catalog of what it draws beyond the base
218
+ * (`blokCatalogSpec` of its own contracts). Registered under the id of a
219
+ * snapshot that ships, it stands in its place; the base catalog is never
220
+ * replaced. Throws when it redefines a component of what it extends.
221
+ */
222
+ export const registerBlokCatalog = (catalog) => {
223
+ if (catalog.id === null)
224
+ throw new Error(`the catalog '${catalog.name}' has no id to be known by`);
225
+ if (catalog.id === loadVocabulary().baseCatalog)
226
+ return;
227
+ const previous = registered.get(catalog.id);
228
+ registered.set(catalog.id, catalog);
229
+ defaultView = null;
230
+ try {
231
+ catalogChain(catalog.id);
232
+ }
233
+ catch (error) {
234
+ if (previous)
235
+ registered.set(catalog.id, previous);
236
+ else
237
+ registered.delete(catalog.id);
238
+ throw error;
239
+ }
240
+ };
241
+ /** Forget every catalog `registerBlokCatalog` was handed, and the app's own view (for tests). */
242
+ export const forgetBlokCatalogs = () => {
243
+ registered.clear();
244
+ defaultTarget = null;
245
+ defaultView = null;
112
246
  };
113
- let defaultView = null;
114
- let defaultModules = [];
115
247
  /**
116
- * The app's own catalogs, as its UI registers them (`describeBlokContract` of
117
- * each unversioned contract it implements): part of the default view from now
118
- * on, so the parser, the checks and the editor know its components. Call it
119
- * once at start, beside `configureBlokPlatform`.
248
+ * The catalog this app draws: the one its own editor, checks and renderer
249
+ * read a blok against when the blok names none of its own. An app that draws
250
+ * only the base leaves it unset. Call it once at start, beside
251
+ * `configureBlokPlatform`.
120
252
  */
121
- export const registerBlokModules = (modules) => {
122
- defaultModules = modules;
253
+ export const setAppBlokCatalog = (target) => {
254
+ if (target !== null && typeof target !== 'string' && target.id !== null)
255
+ registerBlokCatalog(target);
256
+ defaultTarget = target !== null && typeof target !== 'string' && target.id !== null ? target.id : target;
123
257
  defaultView = null;
124
258
  };
125
- /** The app's view: base, every global catalog and its own (`registerBlokModules`). */
259
+ /** The app's own view: everything it draws (`setAppBlokCatalog`), the base catalog's when it set none. */
126
260
  export const defaultBlokView = () => {
127
261
  if (!defaultView)
128
- defaultView = blokView(defaultModules);
262
+ defaultView = blokView(defaultTarget);
129
263
  return defaultView;
130
264
  };
265
+ /**
266
+ * The view a blok that names `catalog` is read against: that catalog's when it
267
+ * is known here, the app's own when the blok names none, and the base's,
268
+ * incomplete (nothing is reported unknown), for a catalog nobody here knows.
269
+ */
270
+ export const blokViewFor = (catalog) => {
271
+ if (catalog === null || catalog === undefined)
272
+ return baseBlokView();
273
+ if (knownCatalog(catalog))
274
+ return blokView(catalog);
275
+ return blokView(null, { complete: false });
276
+ };
277
+ /** Whether `target` can name a catalog at all: a published one's address, or the name of one registered in an organization. */
278
+ export const isCatalogTarget = (target) => {
279
+ const vocabulary = loadVocabulary();
280
+ return vocabulary.catalogId.test(target) || vocabulary.catalogName.test(target);
281
+ };
282
+ /** The minor of the catalog the view is of that `tree` needs: the newest `since` among the components and props of that catalog it uses. */
283
+ export const minorNeeded = (tree, view) => {
284
+ const target = view.label.split(' + ').pop();
285
+ let needed = 0;
286
+ const visit = (node) => {
287
+ const spec = view.components.get(node.component);
288
+ if (spec && spec.catalog === target) {
289
+ needed = Math.max(needed, spec.since);
290
+ for (const prop of node.props ?? [])
291
+ needed = Math.max(needed, spec.props.find(candidate => candidate.key === prop.key)?.since ?? 0);
292
+ }
293
+ for (const child of node.children ?? [])
294
+ visit(child);
295
+ };
296
+ visit(tree);
297
+ return needed;
298
+ };
131
299
  /** Whether a component is a language one that holds others in whatever context (`if`, `foreach`, `fragment`). */
132
- export const isLanguageContainer = (component) => component !== undefined && component.catalog.startsWith(`${BASE_NAME}@`) && component.inheritsContext && component.acceptsChildren;
300
+ export const isLanguageContainer = (component) => component !== undefined && component.group === LANGUAGE_GROUP && component.inheritsContext && component.acceptsChildren;
133
301
  /** The context a component's children are in, given the one it sits in. */
134
302
  export const innerContext = (component, context) => {
135
303
  if (!component)