@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
@@ -5,12 +5,11 @@ import * as z from "zod";
5
5
  import { cleanup, screen } from "@testing-library/react";
6
6
  import { renderBsx, testCatalog} from "./bloks/testing";
7
7
  import { addBlokComponents } from "./catalog";
8
- import { moduleShadowsOf } from "./modules";
9
8
  import { createBlokCatalog, createBlokComponent } from "./runtime";
10
9
 
11
10
  const part = (name: string) => createBlokComponent({ name, schema: z.object({}) }, () => null);
12
- /** A component of a global catalog, as `implementBlokCatalog` tags it. */
13
- const global = (name: string) => ({ ...part(name), origin: "ui@1" });
11
+ /** A component of the base catalog, as `implementBlokCatalog` tags one of its families'. */
12
+ const base = (name: string) => ({ ...part(name), origin: "base@4" });
14
13
 
15
14
  describe("addBlokComponents", () => {
16
15
  it("adds a module's components and takes them back out", () => {
@@ -29,36 +28,23 @@ describe("addBlokComponents", () => {
29
28
  expect([...catalog.components.keys()]).toEqual(["Card", "foreach", "MikroScene"]);
30
29
  });
31
30
 
32
- it("lets a module draw over a standard component, once, and puts it back", () => {
33
- const standard = global("Slider");
34
- const mine = part("Slider");
31
+ it("never draws over a component of the base catalog: a catalog only adds", () => {
32
+ const standard = base("Slider");
35
33
  const catalog = createBlokCatalog("test", [standard]);
36
- const undo = addBlokComponents([mine], catalog);
37
- expect(catalog.components.get("Slider")).toBe(mine);
38
- // A second module cannot draw over it again.
39
34
  expect(() => addBlokComponents([part("Slider")], catalog)).toThrow(/Slider/);
40
- undo();
41
35
  expect(catalog.components.get("Slider")).toBe(standard);
42
36
  });
43
37
 
44
38
  it("renders the module's component where a blok uses the name", () => {
45
- const mine = createBlokComponent({ name: "Slider", schema: z.object({}) }, () => <span>my slider</span>);
39
+ const mine = createBlokComponent({ name: "Gauge", schema: z.object({}) }, () => <span>my gauge</span>);
46
40
  const undo = addBlokComponents([mine], testCatalog());
47
41
  try {
48
- renderBsx(testCatalog(), "<Card><Slider /></Card>");
49
- expect(screen.queryByText("my slider")).not.toBeNull();
42
+ renderBsx(testCatalog(), "<Card><Gauge /></Card>");
43
+ expect(screen.queryByText("my gauge")).not.toBeNull();
50
44
  } finally {
51
45
  cleanup();
52
46
  undo();
53
47
  }
54
- });
55
-
56
- it("records a drawn-over global component as the module's own until undone", () => {
57
- const catalog = createBlokCatalog("test", [global("Slider")]);
58
- expect(moduleShadowsOf(catalog).has("Slider")).toBe(false);
59
- const undo = addBlokComponents([part("Slider")], catalog);
60
- expect(moduleShadowsOf(catalog).has("Slider")).toBe(true);
61
- undo();
62
- expect(moduleShadowsOf(catalog).has("Slider")).toBe(false);
48
+ expect(testCatalog().components.has("Gauge")).toBe(false);
63
49
  });
64
50
  });
@@ -2,13 +2,15 @@ import {controlBlokComponents} from './bloks/control';
2
2
  import {createBlokCatalog, type BlokCatalog} from './runtime';
3
3
 
4
4
  /**
5
- * The base catalog, base@2 (`core/blok/spec/base_v2.json`): the language
6
- * every renderer implements (`if`/`else`, `foreach`, `match`/`case`/`default`,
7
- * `fragment`, `suspense`/`fallback`/`error`, `ask`). Its functions are the
8
- * vocabulary's (`functions/v2`), evaluated by the renderer.
5
+ * The part of the base catalog the renderer itself draws, whatever toolkit
6
+ * draws the rest: the language's elements (`if`/`else`, `foreach`,
7
+ * `match`/`case`/`default`, `fragment`, `suspense`/`fallback`/`error`, the
8
+ * the `Blok` element, the declarations, text) and the parts of a host's interface a blok may
9
+ * place (`ask`, `args`, `timeline`, ...), which the host supplies. Its
10
+ * functions are the vocabulary's (`functions/v2`), evaluated by the renderer.
9
11
  */
10
12
  export const BASE_CATALOG_NAME = 'base';
11
- export const BASE_CATALOG_VERSION = 2;
13
+ export const BASE_CATALOG_VERSION = 4;
12
14
  export const BASE_CATALOG_ID = `${BASE_CATALOG_NAME}@${BASE_CATALOG_VERSION}`;
13
15
 
14
16
  export const baseBlokCatalog: BlokCatalog = createBlokCatalog(BASE_CATALOG_ID, controlBlokComponents);
@@ -8,7 +8,7 @@ afterEach(cleanup);
8
8
  const render = (roots: unknown[], initialState?: unknown) =>
9
9
  renderBlokDocument(testCatalog(), roots, initialState);
10
10
 
11
- describe('links and media (ui@1)', () => {
11
+ describe('links and media (the ui family)', () => {
12
12
  it('renders a link, inline code and a heading', () => {
13
13
  const {errors} = render([
14
14
  {
@@ -33,7 +33,7 @@ describe('links and media (ui@1)', () => {
33
33
  expect(screen.getByRole('heading', {level: 2}).textContent).toBe('Overview');
34
34
  });
35
35
 
36
- it('keeps raw html to the three containers html@1 has', () => {
36
+ it('keeps raw html to the three containers the html family has', () => {
37
37
  expect(testCatalog().components.has('div')).toBe(true);
38
38
  expect(testCatalog().components.has('p')).toBe(true);
39
39
  expect(testCatalog().components.has('span')).toBe(true);
@@ -1,6 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import * as z from 'zod';
3
3
  import {
4
+ BlokItemKeyProvider,
4
5
  BlokScopeProvider,
5
6
  BlokSuspenseContext,
6
7
  createBlokComponent,
@@ -16,13 +17,14 @@ import {
16
17
  type BlokComponentNode,
17
18
  type BlokSourceStatus,
18
19
  type BlokScope,
20
+ type BlokObjectSchema,
19
21
  type BlokSuspenseReporter,
20
22
  } from '../runtime';
21
23
  import {useBlokRunHost} from './run/host';
22
24
  import {blokPlatform} from '../../platform';
23
25
 
24
26
  /**
25
- * The language of base@2 (`core/blok/spec/base_v2.json`): components that
27
+ * The language of the base catalog (`core/blok/spec/base_v2.json`): components that
26
28
  * decide *whether* and *how often* their children render, rather than drawing
27
29
  * anything themselves. Lowercase names are reserved for language.
28
30
  *
@@ -53,6 +55,8 @@ const renderDeclaredChildren = (component: BlokComponentNode, buildChild: (id: s
53
55
  /* -------------------------------------------------------------------------- */
54
56
 
55
57
  const ForeachIteration = (props: {
58
+ /** The item's key, as its runtime ids carry it (`7`, `#2`). */
59
+ itemKey: string;
56
60
  scopeName: string;
57
61
  /** Absolute path of this item, when the items came from a data binding. */
58
62
  itemPath?: string;
@@ -61,7 +65,7 @@ const ForeachIteration = (props: {
61
65
  childIds: string[];
62
66
  buildChild: (id: string, basePath?: string) => React.ReactNode;
63
67
  }) => {
64
- const {buildChild, childIds, item, itemPath, scopeName} = props;
68
+ const {buildChild, childIds, item, itemKey, itemPath, scopeName} = props;
65
69
 
66
70
  // A path-backed item aliases to its path, so a bound control inside the loop
67
71
  // writes the real backing list. Without a path the item is handed down by value.
@@ -69,11 +73,13 @@ const ForeachIteration = (props: {
69
73
  const values = React.useMemo(() => (itemPath ? undefined : {[scopeName]: item}), [item, itemPath, scopeName]);
70
74
 
71
75
  return (
72
- <BlokScopeProvider aliases={aliases} values={values}>
73
- {childIds.map(childId => (
74
- <React.Fragment key={childId}>{buildChild(childId)}</React.Fragment>
75
- ))}
76
- </BlokScopeProvider>
76
+ <BlokItemKeyProvider itemKey={itemKey}>
77
+ <BlokScopeProvider aliases={aliases} values={values}>
78
+ {childIds.map(childId => (
79
+ <React.Fragment key={childId}>{buildChild(childId)}</React.Fragment>
80
+ ))}
81
+ </BlokScopeProvider>
82
+ </BlokItemKeyProvider>
77
83
  );
78
84
  };
79
85
 
@@ -155,6 +161,7 @@ export const Foreach = createBlokComponent(
155
161
  return (
156
162
  <ForeachIteration
157
163
  key={ids[index]}
164
+ itemKey={ids[index].slice(component.id.length + 1)}
158
165
  scopeName={scopeName}
159
166
  itemPath={itemPath(index)}
160
167
  item={item}
@@ -228,6 +235,21 @@ export const Else = createBlokComponent(
228
235
  ({buildChild, component}) => renderDeclaredChildren(component, buildChild),
229
236
  );
230
237
 
238
+ /** A run of text, as the parser stores it: drawn as it stands where no component took it (`runtime/text`). */
239
+ export const TextNode = createBlokComponent(
240
+ {
241
+ name: '#text',
242
+ schema: z
243
+ .object({value: z.unknown().describe('The text: a literal, or an expression whose value is shown as text.')})
244
+ .describe('A run of text between elements: what the parser stores it as (no element can be called this).'),
245
+ },
246
+ ({component, schema}) => {
247
+ const blok = useBlok(component, schema);
248
+ const value = useValue(blok.value);
249
+ return <>{value === null || value === undefined ? null : typeof value === 'string' ? value : String(value)}</>;
250
+ },
251
+ );
252
+
231
253
  export const Fragment = createBlokComponent(
232
254
  {
233
255
  name: 'fragment',
@@ -238,24 +260,116 @@ export const Fragment = createBlokComponent(
238
260
  ({buildChild, component}) => renderDeclaredChildren(component, buildChild),
239
261
  );
240
262
 
241
- /** What the host adds around a blok; read by the host off the root, the blok itself draws the same either way. */
263
+ /** What the host adds around a blok; read by the host off its `<Blok>`, the blok itself draws the same either way. */
242
264
  export const chromeSchema = z
243
265
  .enum(['auto', 'none'])
244
266
  .optional()
245
267
  .describe(
246
- "What the host draws around the blok of its own: `auto` (the default) adds what the blok does not place (the time slider, the open ask, the rest of the argument form, its buttons); `none` adds nothing, the blok places what it wants.",
268
+ "What the host draws around the blok of its own (panel and scene): `auto` (the default) adds what the blok does not place (the time slider, the open ask, the rest of the argument form, its buttons); `none` adds nothing, the blok places what it wants.",
247
269
  );
248
270
 
249
- export const Html = createBlokComponent(
271
+ const BLOK_COMPONENT = 'Blok';
272
+ const DECLARATIONS: ReadonlySet<string> = new Set(['local', 'query', 'subscription', 'var']);
273
+
274
+ /** The children of a node that draw: its declarations (`local`, `query`, `subscription`, `var`) left out. */
275
+ export const drawnChildren = (component: BlokComponentNode): BlokComponentNode[] =>
276
+ (component.children ?? []).filter(child => !DECLARATIONS.has(child.component));
277
+
278
+ /**
279
+ * The one element every blok is (vocabulary `blok`). In a panel it lays its
280
+ * children out as a fragment does; in a scene or a logo it draws its one
281
+ * element (a `Scene` or `Space`, a `Logo`). Its declarations draw nothing.
282
+ */
283
+ export const Blok = createBlokComponent(
250
284
  {
251
- name: 'Html',
285
+ name: BLOK_COMPONENT,
252
286
  acceptsChildren: true,
253
- placement: {childrenContext: 'html', notDownstreamOf: ['Html']},
287
+ placement: {notDownstreamOf: [BLOK_COMPONENT]},
254
288
  schema: z
255
- .object({chrome: chromeSchema})
256
- .describe("The root of an html blok (a panel, a dashboard, a popout's page): lays its children out as a fragment does, and names the blok's context."),
289
+ .object({
290
+ kind: z.enum(['agent', 'custom', 'task', 'action', 'assign']).describe('What the blok is: what it reads, and where it may be mounted.'),
291
+ context: z
292
+ .enum(['panel', 'scene', 'logo'])
293
+ .describe('What draws it: a panel (a flat rectangle the host lays out), a scene (a 3D view) or a logo (an SVG drawing).'),
294
+ catalog: z
295
+ .string()
296
+ .optional()
297
+ .describe('The catalog it is written for (the address it is published at, or the name of one registered in the organization); the base catalog when left out.'),
298
+ chrome: chromeSchema,
299
+ })
300
+ .describe(
301
+ "Every blok is one: it says its kind (what it reads, where it may be mounted), its context (what host draws it), the catalog it is written for and the host's chrome. A panel lays its children out as a fragment does; a scene holds one Scene or Space, a logo one Logo, besides its declarations.",
302
+ ),
257
303
  },
258
- ({buildChild, component}) => renderDeclaredChildren(component, buildChild),
304
+ ({buildChild, component}) => {
305
+ const context = component.props?.find(prop => prop.key === 'context')?.static_value;
306
+ const drawn = drawnChildren(component);
307
+ return renderNodes(context === 'scene' || context === 'logo' ? drawn.slice(0, 1) : drawn, buildChild);
308
+ },
309
+ );
310
+
311
+ const declaration = <T extends BlokObjectSchema>(name: string, schema: T, acceptsChildren = false) =>
312
+ createBlokComponent({name, acceptsChildren, placement: {inheritsContext: true}, schema}, () => null);
313
+
314
+ /** `<local name="x" default={...} persist />`: draws nothing; its parent provides it to its children (`runtime/locals`). */
315
+ export const Local = declaration(
316
+ 'local',
317
+ z
318
+ .object({
319
+ name: z.string().describe("The name the subtree reads it by, bare (never a reserved root)."),
320
+ default: z.unknown().optional().describe('The value it starts with: a literal.'),
321
+ kind: z.string().optional().describe('Its port kind (INT, FLOAT, STRING, BOOL, ENUM, DATE, QUANTITY, LIST, DICT, MODEL, STRUCTURE, ...) or ANY; inferred when left out.'),
322
+ identifier: z.string().optional().describe("A structure local's identifier (@mikro/image)."),
323
+ nullable: z.boolean().optional().describe('Whether it may be null.'),
324
+ choices: z.unknown().optional().describe("An ENUM local's choices: [{value, label}, ...]."),
325
+ children: z.unknown().optional().describe("A LIST, DICT or MODEL local's child ports, as ports."),
326
+ label: z.string().optional().describe('What a form shows it as.'),
327
+ description: z.string().optional().describe('What it is for.'),
328
+ persist: z.boolean().optional().describe('Remember the last input on this device (never on a server).'),
329
+ like: z.string().optional().describe("Take the port of an action's argument: self.<action>.<arg> or deps.<key>.<action>.<arg>."),
330
+ })
331
+ .describe("Declares a local: form state controls write through bind, read bare in its parent's subtree; inside a foreach, one per item. It comes first among its parent's children and draws nothing."),
332
+ );
333
+
334
+ /** `<query name service document>`: draws nothing; the host runs it (`declaredQueries`). */
335
+ export const Query = declaration(
336
+ 'query',
337
+ z
338
+ .object({
339
+ name: z.string().describe('Its name: read as queries.<name>.'),
340
+ service: z.string().describe('The service it runs on, by key (mikro).'),
341
+ document: z.string().describe('One GraphQL query operation, never a mutation.'),
342
+ poll: z.number().optional().describe('Also re-run every this many seconds.'),
343
+ more: z.string().optional().describe('The list field of its result new pages append to (queries.<name>.fetch_more).'),
344
+ })
345
+ .describe('Declares a read, queries.<name>: one GraphQL query on a service, re-run when its variables (its <var> children) change. A child of <Blok>; draws nothing.'),
346
+ true,
347
+ );
348
+
349
+ /** `<subscription name service document>`: draws nothing; the host runs it (`declaredSubscriptions`). */
350
+ export const Subscription = declaration(
351
+ 'subscription',
352
+ z
353
+ .object({
354
+ name: z.string().describe('Its name: read as subscriptions.<name>.'),
355
+ service: z.string().describe('The service it runs on, by key.'),
356
+ document: z.string().describe('One GraphQL subscription operation.'),
357
+ keep: z.number().optional().describe('Keep the last this many payloads as a list; the latest only when absent.'),
358
+ history: z.string().optional().describe('A declared query to replay from while travelling.'),
359
+ })
360
+ .describe('Declares a stream, subscriptions.<name>: one GraphQL subscription on a service, re-subscribed when its variables (its <var> children) change. A child of <Blok>; draws nothing.'),
361
+ true,
362
+ );
363
+
364
+ /** `<var key value>`: one variable of its query or subscription. */
365
+ export const Var = declaration(
366
+ 'var',
367
+ z
368
+ .object({
369
+ key: z.string().describe("The variable's name in the document."),
370
+ value: z.unknown().optional().describe('Its value.'),
371
+ })
372
+ .describe('One variable of its query or subscription: an expression over args, blok-level locals and agents, or a literal.'),
259
373
  );
260
374
 
261
375
  /* -------------------------------------------------------------------------- */
@@ -343,7 +457,7 @@ const DomHidden = ({hidden, children}: {hidden: boolean; children?: React.ReactN
343
457
  /** Outside html (a scene, a logo) nothing can hold a box: hidden is not drawn. In html, the platform's (a native view), or a DOM `div`. */
344
458
  const Hidden = ({hidden, children}: {hidden: boolean; children: React.ReactNode}) => {
345
459
  const draw = useBlokDrawContext();
346
- if (draw !== 'html') return hidden ? null : <>{children}</>;
460
+ if (draw !== 'panel') return hidden ? null : <>{children}</>;
347
461
  const Primitive = blokPlatform().primitives.Hidden ?? DomHidden;
348
462
  return <Primitive hidden={hidden}>{children}</Primitive>;
349
463
  };
@@ -540,11 +654,16 @@ export const Timeline = createBlokComponent(
540
654
  );
541
655
 
542
656
  export const controlBlokComponents = [
657
+ TextNode,
543
658
  Foreach,
544
659
  If,
545
660
  Else,
546
661
  Fragment,
547
- Html,
662
+ Blok,
663
+ Local,
664
+ Query,
665
+ Subscription,
666
+ Var,
548
667
  Match,
549
668
  Case,
550
669
  Default,
@@ -5,7 +5,7 @@ import {foreachItemIds} from './control';
5
5
  import {renderBsx, testCatalog} from './testing';
6
6
 
7
7
  /**
8
- * The language of base@2 rendered end to end, from BSX: branches, loops, the
8
+ * The language of the base catalog rendered end to end, from BSX: branches, loops, the
9
9
  * `when` guard, and the async model (suspense, fallback, error, stale).
10
10
  */
11
11
 
@@ -8,8 +8,8 @@ import {renderContent, textPresentationClasses, useTextPresentationProps} from '
8
8
  type Contracts = typeof htmlContracts;
9
9
 
10
10
  /**
11
- * ui@1's links and media: `Link`, `Image` and `Code`. Raw HTML tags are not
12
- * part of the language; html@1 keeps only `div`, `p` and `span`, the
11
+ * The ui family's links and media: `Link`, `Image` and `Code`. Raw HTML tags are not
12
+ * part of the language; the html family keeps only `div`, `p` and `span`, the
13
13
  * containers that translate directly to React Native (View, Text).
14
14
  */
15
15
 
@@ -13,7 +13,7 @@ import {typographyRenders} from './typography';
13
13
 
14
14
  /**
15
15
  * The shadcn/HTML/SVG renders, by component name: what `@arkitektio/bsx/shadcn`
16
- * implements ui@1, html@1, logo@1 and shadcn@1 with. Grouped by family as the
16
+ * implements the ui family, the html family, the logo family and the shadcn family with. Grouped by family as the
17
17
  * contracts are (`catalogs/parts`).
18
18
  */
19
19
  export const domRenders = {
@@ -166,6 +166,33 @@ const ScrollAreaRender: BlokRender<Contracts['ScrollArea']> = ({buildChild, comp
166
166
  );
167
167
  };
168
168
 
169
+ /**
170
+ * A long list. Its rows are the children a `foreach` draws straight into it:
171
+ * each is left unlaid and unpainted until it scrolls near the view
172
+ * (`content-visibility`), so a list of thousands costs what a screenful does
173
+ * to draw. The rows are still mounted, as a renderer without a window of its
174
+ * own would mount them.
175
+ */
176
+ const ListRender: BlokRender<Contracts['List']> = ({buildChild, component, schema}) => {
177
+ const blok = useBlok(component, schema);
178
+ const children = useValue(blok.children);
179
+ const className = useValue(blok.className);
180
+ const height = useValue(blok.height);
181
+
182
+ return (
183
+ <div
184
+ className={cn(
185
+ 'flex min-h-0 min-w-0 flex-col overflow-y-auto [&>*]:shrink-0 [&>*]:[contain-intrinsic-size:auto_2.5rem] [&>*]:[content-visibility:auto]',
186
+ !height && 'h-full',
187
+ className,
188
+ )}
189
+ style={{height}}
190
+ >
191
+ {renderChildList(children, buildChild)}
192
+ </div>
193
+ );
194
+ };
195
+
169
196
  const ResizableRender: BlokRender<Contracts['Resizable']> = ({buildChild, component, schema}) => {
170
197
  const blok = useBlok(component, schema);
171
198
  const children = useValue(blok.children);
@@ -293,6 +320,7 @@ export const layoutRenders = {
293
320
  Separator: SeparatorRender,
294
321
  AspectRatio: AspectRatioRender,
295
322
  ScrollArea: ScrollAreaRender,
323
+ List: ListRender,
296
324
  Resizable: ResizableRender,
297
325
  ResizablePanel: ResizablePanelRender,
298
326
  ResizableHandle: ResizableHandleRender,
@@ -22,7 +22,7 @@ import {
22
22
  type Contracts = typeof logoContracts;
23
23
 
24
24
  /**
25
- * The `logo@1` module drawn: see the contract for the language. A node's id is
25
+ * The `logo` family drawn: see the contract for the language. A node's id is
26
26
  * the BSX `id`, and that is what a gradient or a clip path is referenced by.
27
27
  * Ids are made unique per drawing, so two logos on one page never share a
28
28
  * gradient.
@@ -146,7 +146,7 @@ const SvgNodeError = ({componentId, title, detail}: BlokNodeErrorProps) => (
146
146
  );
147
147
 
148
148
  /** A drawing's root: an `<svg>` whose shapes paint with the pens. */
149
- const LogoRootRender: BlokRender<Contracts['AgentLogo']> = args => {
149
+ const LogoRootRender: BlokRender<Contracts['Logo']> = args => {
150
150
  const blok = useBlok(args.component, args.schema);
151
151
  const viewBox = useValue(blok.viewBox);
152
152
  const width = useValue(blok.width);
@@ -265,10 +265,9 @@ const ClipPathRender: BlokRender<Contracts['ClipPath']> = args => {
265
265
  );
266
266
  };
267
267
 
268
- /** The `logo@1` module: the root, seven shapes, text, and what shapes reference. */
268
+ /** The `logo` family: the root, seven shapes, text, and what shapes reference. */
269
269
  export const logoRenders = {
270
- AgentLogo: LogoRootRender,
271
- ActionLogo: LogoRootRender,
270
+ Logo: LogoRootRender,
272
271
  Path: shapeRender('path', shapeGeometry.Path),
273
272
  Circle: shapeRender('circle', shapeGeometry.Circle),
274
273
  Ellipse: shapeRender('ellipse', shapeGeometry.Ellipse),