@arkitektio/bsx 4.3.0 → 5.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 (253) hide show
  1. package/README.md +39 -18
  2. package/dist/bsx/parse.d.ts +13 -7
  3. package/dist/bsx/parse.d.ts.map +1 -1
  4. package/dist/bsx/parse.js +18 -57
  5. package/dist/bsx/parse.js.map +1 -1
  6. package/dist/bsx/print.d.ts.map +1 -1
  7. package/dist/bsx/print.js +22 -35
  8. package/dist/bsx/print.js.map +1 -1
  9. package/dist/bsx/references.d.ts +5 -5
  10. package/dist/bsx/references.d.ts.map +1 -1
  11. package/dist/bsx/references.js +106 -33
  12. package/dist/bsx/references.js.map +1 -1
  13. package/dist/catalogs/html.d.ts +1 -1
  14. package/dist/catalogs/html.d.ts.map +1 -1
  15. package/dist/catalogs/html.js +3 -3
  16. package/dist/catalogs/html.js.map +1 -1
  17. package/dist/catalogs/index.d.ts +126 -112
  18. package/dist/catalogs/index.d.ts.map +1 -1
  19. package/dist/catalogs/index.js +6 -2
  20. package/dist/catalogs/index.js.map +1 -1
  21. package/dist/catalogs/logo.d.ts +5 -5
  22. package/dist/catalogs/logo.d.ts.map +1 -1
  23. package/dist/catalogs/logo.js +3 -3
  24. package/dist/catalogs/logo.js.map +1 -1
  25. package/dist/catalogs/parts/data.d.ts +5 -5
  26. package/dist/catalogs/parts/feedback.d.ts +12 -12
  27. package/dist/catalogs/parts/forms.d.ts +20 -20
  28. package/dist/catalogs/parts/html.d.ts +1 -1
  29. package/dist/catalogs/parts/html.d.ts.map +1 -1
  30. package/dist/catalogs/parts/html.js +1 -1
  31. package/dist/catalogs/parts/html.js.map +1 -1
  32. package/dist/catalogs/parts/icons.d.ts +9 -9
  33. package/dist/catalogs/parts/icons.js +1 -1
  34. package/dist/catalogs/parts/index.d.ts +120 -110
  35. package/dist/catalogs/parts/index.d.ts.map +1 -1
  36. package/dist/catalogs/parts/layout.d.ts +11 -1
  37. package/dist/catalogs/parts/layout.d.ts.map +1 -1
  38. package/dist/catalogs/parts/layout.js +9 -0
  39. package/dist/catalogs/parts/layout.js.map +1 -1
  40. package/dist/catalogs/parts/logo.d.ts +8 -8
  41. package/dist/catalogs/parts/logo.d.ts.map +1 -1
  42. package/dist/catalogs/parts/logo.js +2 -2
  43. package/dist/catalogs/parts/logo.js.map +1 -1
  44. package/dist/catalogs/parts/navigation.d.ts +16 -16
  45. package/dist/catalogs/parts/overlays.d.ts +44 -44
  46. package/dist/catalogs/parts/run.d.ts +5 -5
  47. package/dist/catalogs/parts/run.js +1 -1
  48. package/dist/catalogs/parts/scene.d.ts +4 -4
  49. package/dist/catalogs/parts/structure.js +2 -2
  50. package/dist/catalogs/parts/toast.js +1 -1
  51. package/dist/catalogs/parts/toast.js.map +1 -1
  52. package/dist/catalogs/parts/typography.js +1 -1
  53. package/dist/catalogs/parts/typography.js.map +1 -1
  54. package/dist/catalogs/props.d.ts +2 -2
  55. package/dist/catalogs/scene.d.ts +5 -5
  56. package/dist/catalogs/scene.d.ts.map +1 -1
  57. package/dist/catalogs/scene.js +3 -3
  58. package/dist/catalogs/scene.js.map +1 -1
  59. package/dist/catalogs/shadcn.d.ts +47 -47
  60. package/dist/catalogs/shadcn.d.ts.map +1 -1
  61. package/dist/catalogs/shadcn.js +4 -4
  62. package/dist/catalogs/shadcn.js.map +1 -1
  63. package/dist/catalogs/structure.d.ts +1 -1
  64. package/dist/catalogs/structure.d.ts.map +1 -1
  65. package/dist/catalogs/structure.js +3 -3
  66. package/dist/catalogs/structure.js.map +1 -1
  67. package/dist/catalogs/ui.d.ts +67 -57
  68. package/dist/catalogs/ui.d.ts.map +1 -1
  69. package/dist/catalogs/ui.js +4 -3
  70. package/dist/catalogs/ui.js.map +1 -1
  71. package/dist/catalogs.d.ts +1 -1
  72. package/dist/catalogs.d.ts.map +1 -1
  73. package/dist/catalogs.js +2 -2
  74. package/dist/catalogs.js.map +1 -1
  75. package/dist/ports.js +1 -1
  76. package/dist/ports.js.map +1 -1
  77. package/dist/renderer/baseCatalog.d.ts +8 -6
  78. package/dist/renderer/baseCatalog.d.ts.map +1 -1
  79. package/dist/renderer/baseCatalog.js +7 -5
  80. package/dist/renderer/baseCatalog.js.map +1 -1
  81. package/dist/renderer/bloks/control.d.ts +2 -0
  82. package/dist/renderer/bloks/control.d.ts.map +1 -1
  83. package/dist/renderer/bloks/control.js +13 -1
  84. package/dist/renderer/bloks/control.js.map +1 -1
  85. package/dist/renderer/bloks/data.d.ts +5 -5
  86. package/dist/renderer/bloks/feedback.d.ts +12 -12
  87. package/dist/renderer/bloks/forms.d.ts +20 -20
  88. package/dist/renderer/bloks/html.js +2 -2
  89. package/dist/renderer/bloks/icons.d.ts +4 -4
  90. package/dist/renderer/bloks/index.d.ts +115 -107
  91. package/dist/renderer/bloks/index.d.ts.map +1 -1
  92. package/dist/renderer/bloks/index.js +1 -1
  93. package/dist/renderer/bloks/layout.d.ts +9 -1
  94. package/dist/renderer/bloks/layout.d.ts.map +1 -1
  95. package/dist/renderer/bloks/layout.js +15 -0
  96. package/dist/renderer/bloks/layout.js.map +1 -1
  97. package/dist/renderer/bloks/logo/index.d.ts +5 -5
  98. package/dist/renderer/bloks/logo/index.d.ts.map +1 -1
  99. package/dist/renderer/bloks/logo/index.js +2 -2
  100. package/dist/renderer/bloks/logo/index.js.map +1 -1
  101. package/dist/renderer/bloks/navigation.d.ts +16 -16
  102. package/dist/renderer/bloks/overlays.d.ts +44 -44
  103. package/dist/renderer/bloks/run/components.d.ts +2 -2
  104. package/dist/renderer/bloks/run/components.js +1 -1
  105. package/dist/renderer/bloks/scene/index.d.ts +2 -2
  106. package/dist/renderer/bloks/toast.d.ts +1 -1
  107. package/dist/renderer/bloks/typography.js +1 -1
  108. package/dist/renderer/catalog.d.ts +4 -7
  109. package/dist/renderer/catalog.d.ts.map +1 -1
  110. package/dist/renderer/catalog.js +7 -31
  111. package/dist/renderer/catalog.js.map +1 -1
  112. package/dist/renderer/declare.d.ts +31 -19
  113. package/dist/renderer/declare.d.ts.map +1 -1
  114. package/dist/renderer/declare.js +44 -18
  115. package/dist/renderer/declare.js.map +1 -1
  116. package/dist/renderer/runtime/catalog.d.ts +27 -7
  117. package/dist/renderer/runtime/catalog.d.ts.map +1 -1
  118. package/dist/renderer/runtime/catalog.js +30 -3
  119. package/dist/renderer/runtime/catalog.js.map +1 -1
  120. package/dist/renderer/runtime/components.d.ts +7 -1
  121. package/dist/renderer/runtime/components.d.ts.map +1 -1
  122. package/dist/renderer/runtime/components.js +3 -0
  123. package/dist/renderer/runtime/components.js.map +1 -1
  124. package/dist/renderer/runtime/describe.d.ts +14 -4
  125. package/dist/renderer/runtime/describe.d.ts.map +1 -1
  126. package/dist/renderer/runtime/describe.js +3 -0
  127. package/dist/renderer/runtime/describe.js.map +1 -1
  128. package/dist/renderer/runtime/index.d.ts +1 -0
  129. package/dist/renderer/runtime/index.d.ts.map +1 -1
  130. package/dist/renderer/runtime/index.js +1 -0
  131. package/dist/renderer/runtime/index.js.map +1 -1
  132. package/dist/renderer/runtime/preflight.d.ts.map +1 -1
  133. package/dist/renderer/runtime/preflight.js +5 -2
  134. package/dist/renderer/runtime/preflight.js.map +1 -1
  135. package/dist/renderer/runtime/text.d.ts +28 -0
  136. package/dist/renderer/runtime/text.d.ts.map +1 -0
  137. package/dist/renderer/runtime/text.js +82 -0
  138. package/dist/renderer/runtime/text.js.map +1 -0
  139. package/dist/runtime.d.ts +0 -1
  140. package/dist/runtime.d.ts.map +1 -1
  141. package/dist/runtime.js +0 -1
  142. package/dist/runtime.js.map +1 -1
  143. package/dist/scene.d.ts +1 -1
  144. package/dist/scene.d.ts.map +1 -1
  145. package/dist/scene.js +2 -2
  146. package/dist/scene.js.map +1 -1
  147. package/dist/shadcn.d.ts +118 -110
  148. package/dist/shadcn.d.ts.map +1 -1
  149. package/dist/shadcn.js +6 -5
  150. package/dist/shadcn.js.map +1 -1
  151. package/dist/spec/bsx_v2.json +3080 -2436
  152. package/dist/spec/catalogs/base@3.json +13029 -0
  153. package/dist/spec/catalogs/base@3.json.js +13029 -0
  154. package/dist/spec/catalogs/orkestrator@1.json +489 -0
  155. package/dist/spec/catalogs/orkestrator@1.json.js +489 -0
  156. package/dist/spec/catalogs.d.ts +109 -46
  157. package/dist/spec/catalogs.d.ts.map +1 -1
  158. package/dist/spec/catalogs.js +241 -73
  159. package/dist/spec/catalogs.js.map +1 -1
  160. package/dist/spec/vocabulary.d.ts +19 -3
  161. package/dist/spec/vocabulary.d.ts.map +1 -1
  162. package/dist/spec/vocabulary.js +15 -2
  163. package/dist/spec/vocabulary.js.map +1 -1
  164. package/dist/spec/vocabulary.json +30 -16
  165. package/dist/spec/vocabulary.json.js +30 -16
  166. package/dist/vendor/core/ui/button-group.d.ts +1 -1
  167. package/dist/vendor/core/ui/button.d.ts +1 -1
  168. package/dist/vendor/core/ui/field.d.ts +1 -1
  169. package/package.json +1 -1
  170. package/src/bsx/infer.test.ts +18 -26
  171. package/src/bsx/language.test.ts +1 -1
  172. package/src/bsx/parse.ts +18 -62
  173. package/src/bsx/partial.test.ts +1 -1
  174. package/src/bsx/print.ts +24 -34
  175. package/src/bsx/references.test.ts +16 -14
  176. package/src/bsx/references.ts +96 -38
  177. package/src/catalogs/catalogs.test.ts +45 -14
  178. package/src/catalogs/html.ts +3 -3
  179. package/src/catalogs/index.ts +6 -2
  180. package/src/catalogs/logo.ts +3 -3
  181. package/src/catalogs/parts/html.ts +1 -1
  182. package/src/catalogs/parts/icons.ts +1 -1
  183. package/src/catalogs/parts/layout.ts +11 -0
  184. package/src/catalogs/parts/logo.ts +2 -2
  185. package/src/catalogs/parts/run.ts +1 -1
  186. package/src/catalogs/parts/structure.ts +2 -2
  187. package/src/catalogs/parts/toast.ts +1 -1
  188. package/src/catalogs/parts/typography.ts +1 -1
  189. package/src/catalogs/scene.ts +3 -3
  190. package/src/catalogs/shadcn.ts +4 -4
  191. package/src/catalogs/structure.ts +3 -3
  192. package/src/catalogs/ui.ts +4 -3
  193. package/src/catalogs.ts +9 -2
  194. package/src/ports.ts +1 -1
  195. package/src/renderer/addBlokComponents.test.tsx +8 -22
  196. package/src/renderer/baseCatalog.ts +7 -5
  197. package/src/renderer/bloks/components.test.tsx +2 -2
  198. package/src/renderer/bloks/control.tsx +17 -1
  199. package/src/renderer/bloks/flow.test.tsx +1 -1
  200. package/src/renderer/bloks/html.tsx +2 -2
  201. package/src/renderer/bloks/index.ts +1 -1
  202. package/src/renderer/bloks/layout.tsx +28 -0
  203. package/src/renderer/bloks/logo/index.tsx +2 -2
  204. package/src/renderer/bloks/run/components.tsx +1 -1
  205. package/src/renderer/bloks/time.test.tsx +1 -1
  206. package/src/renderer/bloks/toast.tsx +1 -1
  207. package/src/renderer/bloks/typography.tsx +1 -1
  208. package/src/renderer/catalog.tsx +7 -31
  209. package/src/renderer/declare.test.ts +41 -0
  210. package/src/renderer/declare.ts +70 -32
  211. package/src/renderer/runtime/catalog.ts +35 -10
  212. package/src/renderer/runtime/components.tsx +10 -1
  213. package/src/renderer/runtime/describe.ts +17 -4
  214. package/src/renderer/runtime/index.ts +1 -0
  215. package/src/renderer/runtime/preflight.ts +5 -2
  216. package/src/renderer/runtime/text.test.tsx +65 -0
  217. package/src/renderer/runtime/text.ts +88 -0
  218. package/src/runtime.ts +0 -1
  219. package/src/scene.ts +2 -2
  220. package/src/shadcn.ts +6 -5
  221. package/src/spec/bsx_v2.json +3080 -2436
  222. package/src/spec/catalogs/base@3.json +13029 -0
  223. package/src/spec/catalogs/orkestrator@1.json +489 -0
  224. package/src/spec/catalogs.ts +257 -101
  225. package/src/spec/spec.test.ts +87 -21
  226. package/src/spec/vocabulary.json +30 -16
  227. package/src/spec/vocabulary.ts +33 -7
  228. package/dist/renderer/modules.d.ts +0 -4
  229. package/dist/renderer/modules.d.ts.map +0 -1
  230. package/dist/renderer/modules.js +0 -11
  231. package/dist/renderer/modules.js.map +0 -1
  232. package/dist/spec/catalogs/base@2.json +0 -355
  233. package/dist/spec/catalogs/base@2.json.js +0 -355
  234. package/dist/spec/catalogs/html@1.json +0 -308
  235. package/dist/spec/catalogs/html@1.json.js +0 -308
  236. package/dist/spec/catalogs/logo@1.json +0 -1687
  237. package/dist/spec/catalogs/logo@1.json.js +0 -1687
  238. package/dist/spec/catalogs/scene@1.json +0 -878
  239. package/dist/spec/catalogs/scene@1.json.js +0 -878
  240. package/dist/spec/catalogs/shadcn@1.json +0 -4002
  241. package/dist/spec/catalogs/shadcn@1.json.js +0 -4002
  242. package/dist/spec/catalogs/structure@1.json +0 -185
  243. package/dist/spec/catalogs/structure@1.json.js +0 -185
  244. package/dist/spec/catalogs/ui@1.json +0 -5349
  245. package/dist/spec/catalogs/ui@1.json.js +0 -5349
  246. package/src/renderer/modules.ts +0 -12
  247. package/src/spec/catalogs/base@2.json +0 -355
  248. package/src/spec/catalogs/html@1.json +0 -308
  249. package/src/spec/catalogs/logo@1.json +0 -1687
  250. package/src/spec/catalogs/scene@1.json +0 -878
  251. package/src/spec/catalogs/shadcn@1.json +0 -4002
  252. package/src/spec/catalogs/structure@1.json +0 -185
  253. package/src/spec/catalogs/ui@1.json +0 -5349
@@ -1,28 +1,59 @@
1
- import {readFileSync} from 'node:fs';
2
1
  import {describe, expect, it} from 'vitest';
3
- import {catalogRef, describeBlokContract, specJsonText} from '../renderer/runtime';
4
- import {globalCatalogs} from './index';
2
+ import {controlBlokComponents} from '../renderer/bloks/control';
3
+ import {BASE_CATALOG_REF, describeBlokContract, type SpecComponentJson} from '../renderer/runtime';
4
+ import baseCatalogJson from '../spec/catalogs/base@3.json';
5
+ import {baseFamilies} from './index';
5
6
  import {parts} from './parts';
6
- import baseCatalogJson from '../spec/catalogs/base@2.json';
7
7
 
8
- const shipped = (ref: string): string => readFileSync(new URL(`../spec/catalogs/${ref}.json`, import.meta.url), 'utf-8');
8
+ /** What the spec adds to an entry beside what its contract says: where it is listed, and what the spec alone knows of it. */
9
+ const SPEC_OWNED = ['group', 'kinds', 'touch', 'since', 'service'] as const;
9
10
 
10
- describe('the global catalogs', () => {
11
- it('are what the shipped spec JSON says, so `pnpm spec:export` has run', () => {
12
- for (const contract of globalCatalogs) {
13
- expect(shipped(catalogRef(contract)), catalogRef(contract)).toBe(specJsonText(describeBlokContract(contract)));
11
+ type BaseEntry = SpecComponentJson & {group: string};
12
+
13
+ const shipped = new Map((baseCatalogJson.components as unknown as BaseEntry[]).map(component => [component.name, component]));
14
+
15
+ const asContract = (entry: BaseEntry): SpecComponentJson =>
16
+ Object.fromEntries(Object.entries(entry).filter(([key]) => !(SPEC_OWNED as readonly string[]).includes(key))) as SpecComponentJson;
17
+
18
+ describe('the families of the base catalog', () => {
19
+ it('are what the spec\'s base catalog says, component for component', () => {
20
+ for (const family of baseFamilies) {
21
+ expect(family.partOf, family.name).toBe(BASE_CATALOG_REF);
22
+ for (const described of describeBlokContract(family).components) {
23
+ const entry = shipped.get(described.name);
24
+ expect(entry, `<${described.name}> is not in the base catalog: rebuild it from \`pnpm spec:export\``).toBeDefined();
25
+ if (!entry) continue;
26
+ expect(entry.group, described.name).toBe(family.name);
27
+ expect(asContract(entry), described.name).toEqual(described);
28
+ }
14
29
  }
15
30
  });
16
31
 
17
- it('hold each component once, and never one of base@2', () => {
18
- const base = new Set(baseCatalogJson.components.map(component => component.name));
19
- const names = globalCatalogs.flatMap(contract => Object.keys(contract.components));
32
+ it('hold each component once, and never one the renderer draws itself', () => {
33
+ const own = new Set(controlBlokComponents.map(component => component.name));
34
+ const names = baseFamilies.flatMap(family => Object.keys(family.components));
20
35
  expect(names.filter((name, index) => names.indexOf(name) !== index)).toEqual([]);
21
- expect(names.filter(name => base.has(name))).toEqual([]);
36
+ expect(names.filter(name => own.has(name))).toEqual([]);
37
+ });
38
+
39
+ it('are, with what the renderer draws itself, the whole base catalog', () => {
40
+ const drawn = new Set([...baseFamilies.flatMap(family => Object.keys(family.components)), ...controlBlokComponents.map(component => component.name)]);
41
+ expect([...shipped.keys()].filter(name => !drawn.has(name))).toEqual([]);
42
+ expect([...drawn].filter(name => !shipped.has(name))).toEqual([]);
43
+ });
44
+
45
+ it('take, where the renderer draws a component itself, the props the base catalog lists', () => {
46
+ for (const component of controlBlokComponents) {
47
+ const entry = shipped.get(component.name);
48
+ expect(entry, component.name).toBeDefined();
49
+ expect(entry?.group === 'language' || entry?.group === 'run', component.name).toBe(true);
50
+ const props = Object.keys(component.schema.shape).filter(key => key !== 'children').sort();
51
+ expect(props, component.name).toEqual((entry?.props ?? []).map(prop => prop.key).sort());
52
+ }
22
53
  });
23
54
 
24
55
  it('use every contract the package defines', () => {
25
- const used = new Set(globalCatalogs.flatMap(contract => Object.keys(contract.components)));
56
+ const used = new Set(baseFamilies.flatMap(family => Object.keys(family.components)));
26
57
  expect(Object.keys(parts).filter(name => !used.has(name))).toEqual([]);
27
58
  });
28
59
  });
@@ -1,10 +1,10 @@
1
- import {defineBlokCatalog} from '../renderer/runtime/catalog';
1
+ import {BASE_CATALOG_REF, defineBlokCatalog} from '../renderer/runtime/catalog';
2
2
  import {parts} from './parts';
3
3
 
4
- /** `html@1`. */
4
+ /** The `html` family of the base catalog. */
5
5
  export const htmlCatalog = defineBlokCatalog({
6
6
  name: "html",
7
- version: 1,
7
+ partOf: BASE_CATALOG_REF,
8
8
  description: "Plain containers that translate directly to React Native: div (View), p and span (Text).",
9
9
  components: {
10
10
  div: parts.div,
@@ -8,5 +8,9 @@ import {uiCatalog} from './ui';
8
8
  export {htmlCatalog, logoCatalog, sceneCatalog, shadcnCatalog, structureCatalog, uiCatalog};
9
9
  export * from './props';
10
10
 
11
- /** The global catalogs this package defines: what the spec publishes, every UI may claim. */
12
- export const globalCatalogs = [uiCatalog, htmlCatalog, logoCatalog, sceneCatalog, structureCatalog, shadcnCatalog] as const;
11
+ /**
12
+ * The families of the base catalog this package holds contracts for: every
13
+ * component of it that is not the language's own (`renderer/bloks/control`).
14
+ * The spec's `catalogs/base@3.json` is what they say (`catalogs.test.ts`).
15
+ */
16
+ export const baseFamilies = [uiCatalog, htmlCatalog, logoCatalog, sceneCatalog, structureCatalog, shadcnCatalog] as const;
@@ -1,10 +1,10 @@
1
- import {defineBlokCatalog} from '../renderer/runtime/catalog';
1
+ import {BASE_CATALOG_REF, defineBlokCatalog} from '../renderer/runtime/catalog';
2
2
  import {parts} from './parts';
3
3
 
4
- /** `logo@1`. */
4
+ /** The `logo` family of the base catalog. */
5
5
  export const logoCatalog = defineBlokCatalog({
6
6
  name: "logo",
7
- version: 1,
7
+ partOf: BASE_CATALOG_REF,
8
8
  description: "SVG drawing for logos and action logos; the palette is restricted to the logo pens.",
9
9
  components: {
10
10
  ActionLogo: parts.ActionLogo,
@@ -3,7 +3,7 @@ import type {BlokComponentContracts} from '../../renderer/runtime/catalog';
3
3
  import {BlokPropSchemas} from '../../renderer/runtime/schemas';
4
4
  import {actionProp, boolSchema, classNameSchema, contentSchema, layoutFields, textFields} from '../props';
5
5
 
6
- /** ui@1's links and media: `Link`, `Image` and `Code`. */
6
+ /** the ui family's links and media: `Link`, `Image` and `Code`. */
7
7
 
8
8
  export const htmlContracts = {
9
9
  Link: {
@@ -3,7 +3,7 @@ import type {BlokComponentContracts} from '../../renderer/runtime/catalog';
3
3
  import {classNameSchema, numberSchema} from '../props';
4
4
 
5
5
  /**
6
- * The icons a blok payload may name, and `Icon` (ui@1).
6
+ * The icons a blok payload may name, and `Icon` (the ui family).
7
7
  *
8
8
  * The names are spelled out here so the contract carries no icon set: the
9
9
  * renderer's `BLOK_ICONS` map is typed against this tuple, so a name without a
@@ -152,6 +152,17 @@ export const layoutContracts = {
152
152
  })
153
153
  .describe('A scrollable region with styled scrollbars.'),
154
154
  },
155
+ List: {
156
+ schema: z
157
+ .object({
158
+ children: childListSchema,
159
+ className: classNameSchema,
160
+ height: sizeSchema.describe('CSS height of the list; it scrolls inside it. Fills its parent when left out.'),
161
+ })
162
+ .describe(
163
+ 'A long list: a `<foreach>` placed directly inside it is drawn row by row as it scrolls into view, so thousands of items cost what a screenful does. Anything else inside it is drawn as a Column would.',
164
+ ),
165
+ },
155
166
  Resizable: {
156
167
  schema: z
157
168
  .object({
@@ -5,7 +5,7 @@ import {loadVocabulary} from '../../spec/vocabulary';
5
5
  import {actionProp, describedString} from '../props';
6
6
 
7
7
  /**
8
- * The `logo@1` module of the blok language: the `AgentLogo` and `ActionLogo`
8
+ * The `logo` family of the blok language: the `AgentLogo` and `ActionLogo`
9
9
  * roots and the classic SVG elements as components.
10
10
  *
11
11
  * A logo root sits in html like `Scene` does and opens the `logo` context, so a
@@ -156,7 +156,7 @@ const gradientUnits = z
156
156
  .optional()
157
157
  .describe('Whether the coordinates are fractions of the shape (the default) or user units.');
158
158
 
159
- /** The `logo@1` module: the root, seven shapes, text, and what shapes reference. */
159
+ /** The `logo` family: the root, seven shapes, text, and what shapes reference. */
160
160
  export const logoContracts = {
161
161
  [AGENT_LOGO_ROOT]: logoRoot(
162
162
  "The root of an agent's logo: a drawing in the viewer's pens. Its children are SVG shapes.",
@@ -4,7 +4,7 @@ import {describedString} from '../props';
4
4
  import {sceneSchema} from './scene';
5
5
 
6
6
  /**
7
- * The components that place an action's dependencies in 3D (scene@1). `Space`
7
+ * The components that place an action's dependencies in 3D (the scene family). `Space`
8
8
  * is a scene whose layout is shared: a room the whole organization arranges,
9
9
  * found again by its `room` (not `id`: that is every node's own explicit id). `Placed` draws the agent a dependency is bound to
10
10
  * with that agent's own scene blok, where the room keeps it, and `Route` draws
@@ -4,9 +4,9 @@ import {BlokPropSchemas} from '../../renderer/runtime/schemas';
4
4
  import {actionProp, bindSchema, boolSchema, classNameSchema, disabledSchema, sizeSchema, structureValueSchema} from '../props';
5
5
 
6
6
  /**
7
- * structure@1: bloks over other modules' objects, by structure identifier. The
7
+ * the structure family: bloks over other modules' objects, by structure identifier. The
8
8
  * contract only: drawing one needs the app's smart system (its option sources,
9
- * displays and viewers), so every app that claims structure@1 draws it itself.
9
+ * displays and viewers), so every app that claims the structure family draws it itself.
10
10
  */
11
11
 
12
12
  const emptyTextSchema = BlokPropSchemas.DynamicString.optional().describe(
@@ -2,7 +2,7 @@ import * as z from 'zod';
2
2
  import type {BlokComponentContracts} from '../../renderer/runtime/catalog';
3
3
  import {BlokPropSchemas} from '../../renderer/runtime/schemas';
4
4
 
5
- /** `<Toast task={move}>` (ui@1) and its outcome slots `done`, `failed`, `cancelled`. */
5
+ /** `<Toast task={move}>` (the ui family) and its outcome slots `done`, `failed`, `cancelled`. */
6
6
 
7
7
  const toastSchema = z
8
8
  .object({
@@ -3,7 +3,7 @@ import type {BlokComponentContracts} from '../../renderer/runtime/catalog';
3
3
  import {BlokPropSchemas} from '../../renderer/runtime/schemas';
4
4
  import {classNameSchema, contentSchema, headingLevelSchema, textAlignSchema, textFields} from '../props';
5
5
 
6
- /** Text-bearing components: `Text` (ui@1), `p` and `span` (html@1), `Heading`, `Kbd`, `Markdown`, `Time`. */
6
+ /** Text-bearing components: `Text` (the ui family), `p` and `span` (the html family), `Heading`, `Kbd`, `Markdown`, `Time`. */
7
7
 
8
8
  /** `Text` and `p`/`span` differ only in the element they render: one schema. */
9
9
  const textComponentSchema = z
@@ -1,10 +1,10 @@
1
- import {defineBlokCatalog} from '../renderer/runtime/catalog';
1
+ import {BASE_CATALOG_REF, defineBlokCatalog} from '../renderer/runtime/catalog';
2
2
  import {parts} from './parts';
3
3
 
4
- /** `scene@1`. */
4
+ /** The `scene` family of the base catalog. */
5
5
  export const sceneCatalog = defineBlokCatalog({
6
6
  name: "scene",
7
- version: 1,
7
+ partOf: BASE_CATALOG_REF,
8
8
  description: "3D components: the Scene and Space roots, models, verb modifiers on a model's nodes, the HTML bridge (Popout), and the placed dependencies of a Space.",
9
9
  components: {
10
10
  Animate: parts.Animate,
@@ -1,11 +1,11 @@
1
- import {defineBlokCatalog} from '../renderer/runtime/catalog';
1
+ import {BASE_CATALOG_REF, defineBlokCatalog} from '../renderer/runtime/catalog';
2
2
  import {parts} from './parts';
3
3
 
4
- /** `shadcn@1`. */
4
+ /** The `shadcn` family of the base catalog. */
5
5
  export const shadcnCatalog = defineBlokCatalog({
6
6
  name: "shadcn",
7
- version: 1,
8
- description: "The shadcn families beyond ui@1 (alert dialogs, sheets, drawers, menus, calendars, carousels, resizable panels, bento grids ...), charts and the raw inspector.",
7
+ partOf: BASE_CATALOG_REF,
8
+ description: "The shadcn families beyond the ui family (alert dialogs, sheets, drawers, menus, calendars, carousels, resizable panels, bento grids ...), charts and the raw inspector.",
9
9
  components: {
10
10
  AlertDialog: {...parts.AlertDialog, events: {onOpenChange: [{key: "value", kind: "BOOL", description: "Whether it is open now."}]}},
11
11
  AlertDialogAction: parts.AlertDialogAction,
@@ -1,10 +1,10 @@
1
- import {defineBlokCatalog} from '../renderer/runtime/catalog';
1
+ import {BASE_CATALOG_REF, defineBlokCatalog} from '../renderer/runtime/catalog';
2
2
  import {parts} from './parts';
3
3
 
4
- /** `structure@1`. */
4
+ /** The `structure` family of the base catalog. */
5
5
  export const structureCatalog = defineBlokCatalog({
6
6
  name: "structure",
7
- version: 1,
7
+ partOf: BASE_CATALOG_REF,
8
8
  description: "Pick, show and view structures, typed by `\"@package/key\"`.",
9
9
  components: {
10
10
  StructureDisplay: parts.StructureDisplay,
@@ -1,10 +1,10 @@
1
- import {defineBlokCatalog} from '../renderer/runtime/catalog';
1
+ import {BASE_CATALOG_REF, defineBlokCatalog} from '../renderer/runtime/catalog';
2
2
  import {parts} from './parts';
3
3
 
4
- /** `ui@1`. */
4
+ /** The `ui` family of the base catalog. */
5
5
  export const uiCatalog = defineBlokCatalog({
6
6
  name: "ui",
7
- version: 1,
7
+ partOf: BASE_CATALOG_REF,
8
8
  description: "Standard HTML components: layout, text, feedback, forms, data and overlays (shadcn-based).",
9
9
  components: {
10
10
  Accordion: {...parts.Accordion, events: {onChange: [{key: "value", kind: "ANY", description: "The open/pressed value(s): a string, or a list when multiple."}]}},
@@ -50,6 +50,7 @@ export const uiCatalog = defineBlokCatalog({
50
50
  RadioGroup: {...parts.RadioGroup, events: {onChange: [{key: "value", kind: "STRING", description: "The value now chosen."}]}, bindKinds: {bind: "STRING"}},
51
51
  RadioGroupItem: {...parts.RadioGroupItem, textProp: "label"},
52
52
  Row: parts.Row,
53
+ List: parts.List,
53
54
  ScrollArea: parts.ScrollArea,
54
55
  Select: {...parts.Select, events: {onChange: [{key: "value", kind: "STRING", description: "The value now chosen."}]}, bindKinds: {bind: "STRING"}},
55
56
  SelectContent: parts.SelectContent,
package/src/catalogs.ts CHANGED
@@ -1,6 +1,13 @@
1
- // @arkitektio/bsx/catalogs: the global catalog contracts (ui@1, html@1, logo@1, scene@1, structure@1, shadcn@1)
1
+ // @arkitektio/bsx/catalogs: the contracts of the base catalog's families (ui, html, logo, scene, structure, shadcn)
2
2
  // and the prop-schema vocabulary to define a UI's own. zod only: no React, no DOM.
3
3
  export * from './catalogs/index';
4
- export {catalogRef, defineBlokCatalog, type BlokCatalogContract, type BlokComponentContracts} from './renderer/runtime/catalog';
4
+ export {
5
+ BASE_CATALOG_ADDRESS,
6
+ BASE_CATALOG_REF,
7
+ catalogRef,
8
+ defineBlokCatalog,
9
+ type BlokCatalogContract,
10
+ type BlokComponentContracts,
11
+ } from './renderer/runtime/catalog';
5
12
  export type {BlokComponentContract} from './renderer/runtime/components';
6
13
  export {describeBlokContract, specJsonText, type SpecCatalogJson} from './renderer/runtime/describe';
package/src/ports.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  // @arkitektio/bsx/ports: an action's form, the port engine and its widgets. What the app gives it is
2
- // `configurePortHost`; `hostedStructure` draws structure@1 with the same host. A form needs the
2
+ // `configurePortHost`; `hostedStructure` draws the structure family with the same host. A form needs the
3
3
  // optional peers react-hook-form, @hookform/resolvers, cmdk and date-fns.
4
4
  export * from './ports/engine/DependencyContext';
5
5
  export * from './ports/engine/EffectWrapper';
@@ -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@3" });
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
+ * context root `Html`, 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 = 3;
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);
@@ -22,7 +22,7 @@ import {useBlokRunHost} from './run/host';
22
22
  import {blokPlatform} from '../../platform';
23
23
 
24
24
  /**
25
- * The language of base@2 (`core/blok/spec/base_v2.json`): components that
25
+ * The language of the base catalog (`core/blok/spec/base_v2.json`): components that
26
26
  * decide *whether* and *how often* their children render, rather than drawing
27
27
  * anything themselves. Lowercase names are reserved for language.
28
28
  *
@@ -228,6 +228,21 @@ export const Else = createBlokComponent(
228
228
  ({buildChild, component}) => renderDeclaredChildren(component, buildChild),
229
229
  );
230
230
 
231
+ /** A run of text, as the parser stores it: drawn as it stands where no component took it (`runtime/text`). */
232
+ export const TextNode = createBlokComponent(
233
+ {
234
+ name: '#text',
235
+ schema: z
236
+ .object({value: z.unknown().describe('The text: a literal, or an expression whose value is shown as text.')})
237
+ .describe('A run of text between elements: what the parser stores it as (no element can be called this).'),
238
+ },
239
+ ({component, schema}) => {
240
+ const blok = useBlok(component, schema);
241
+ const value = useValue(blok.value);
242
+ return <>{value === null || value === undefined ? null : typeof value === 'string' ? value : String(value)}</>;
243
+ },
244
+ );
245
+
231
246
  export const Fragment = createBlokComponent(
232
247
  {
233
248
  name: 'fragment',
@@ -540,6 +555,7 @@ export const Timeline = createBlokComponent(
540
555
  );
541
556
 
542
557
  export const controlBlokComponents = [
558
+ TextNode,
543
559
  Foreach,
544
560
  If,
545
561
  Else,
@@ -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.
@@ -265,7 +265,7 @@ 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
270
  AgentLogo: LogoRootRender,
271
271
  ActionLogo: LogoRootRender,
@@ -16,7 +16,7 @@ import {progressFraction, routePoints, splitRoute, throughKeys} from './math';
16
16
  type Contracts = typeof runContracts;
17
17
 
18
18
  /**
19
- * The components that place an action's dependencies in 3D (scene@1). `Space`
19
+ * The components that place an action's dependencies in 3D (the scene family). `Space`
20
20
  * is a scene whose layout is a shared room, `Placed` draws the agent a
21
21
  * dependency is bound to with that agent's own scene blok where the room keeps
22
22
  * it, and `Route` draws a line through several.
@@ -4,7 +4,7 @@ import {afterEach, beforeEach, describe, expect, it, vi} from 'vitest';
4
4
  import {renderBsx, testCatalog} from './testing';
5
5
 
6
6
  /**
7
- * `<Time value relative? format?>` (ui@1): a moment, absolute or relative.
7
+ * `<Time value relative? format?>` (the ui family): a moment, absolute or relative.
8
8
  * Relative time ticks inside the component, against the wall clock live and
9
9
  * against `then` while travelling; a blok never reads the clock itself.
10
10
  */
@@ -16,7 +16,7 @@ type Contracts = typeof toastContracts;
16
16
 
17
17
  /**
18
18
  * `<Toast task={move}>`: a notification when a task settles, once per task
19
- * (ui@1). Each outcome slot (`done`, `failed`, `cancelled`) is optional and
19
+ * (the ui family). Each outcome slot (`done`, `failed`, `cancelled`) is optional and
20
20
  * holds the text shown for it:
21
21
  *
22
22
  * <Toast task={move}>
@@ -115,7 +115,7 @@ const useClock = (active: boolean, target: number | null): number => {
115
115
  };
116
116
 
117
117
  /**
118
- * `<Time value relative? format?>` (ui@1): a moment, absolute or relative.
118
+ * `<Time value relative? format?>` (the ui family): a moment, absolute or relative.
119
119
  * Relative time is measured from the viewed moment: the wall clock live
120
120
  * (ticking here), `then` while travelling, so the past renders as it did.
121
121
  */