@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,6 +1,5 @@
1
1
  import * as React from 'react';
2
2
  import {baseBlokCatalog} from './baseCatalog';
3
- import {moduleShadowsOf} from './modules';
4
3
  import {blokPlatform} from '../platform';
5
4
  import type {BlokCatalog, BlokComponentDefinition} from './runtime';
6
5
 
@@ -18,57 +17,34 @@ export const BlokCatalogProvider = ({catalog, children}: {catalog: BlokCatalog;
18
17
  <BlokCatalogContext.Provider value={catalog}>{children}</BlokCatalogContext.Provider>
19
18
  );
20
19
 
21
- /** The app's catalog when no provider says otherwise: the platform's, or base@2 alone. */
20
+ /** The app's catalog when no provider says otherwise: the platform's, or the language's own elements alone. */
22
21
  export const appBlokCatalog = (): BlokCatalog => blokPlatform().catalog ?? baseBlokCatalog;
23
22
 
24
23
  /** The catalog the app provides here, or the app's. */
25
24
  export const useBlokCatalog = (): BlokCatalog => React.useContext(BlokCatalogContext) ?? appBlokCatalog();
26
25
 
27
- /** A component of a global catalog (`ui@1`, `scene@1`): what a module may draw over. */
28
- const isGlobal = (component: BlokComponentDefinition | undefined): boolean => component?.origin?.includes('@') === true;
29
-
30
26
  /**
31
27
  * Adds components a module brings (`ModuleBuiltins.bloks`) to the catalog, so
32
28
  * everything that reads the app's catalog (the renderer, the registrar, the
33
29
  * export) offers them. Called once, by the composition root that installs the
34
30
  * modules; core never imports a module.
35
31
  *
36
- * A module may draw over a global catalog's component (its own `Slider`):
37
- * the module's is rendered, as the spec's `blok_view` says, and the validator
38
- * warns `catalog.shadow` where a blok uses it. Any other name the catalog
39
- * already holds (base's, the app's own, another module's) is refused, whoever
40
- * brought it. Returns the undo, which puts a drawn-over component back (a dev
41
- * hot reload installs the modules again).
32
+ * A catalog only adds: a name the catalog already holds (the language's, the
33
+ * base catalog's, the app's own, another module's) is refused, whoever brought
34
+ * it. Returns the undo (a dev hot reload installs the modules again).
42
35
  */
43
36
  export const addBlokComponents = (
44
37
  components: readonly BlokComponentDefinition[],
45
38
  catalog: BlokCatalog,
46
39
  ): (() => void) => {
47
- const shadows = moduleShadowsOf(catalog);
48
- const taken = components.filter(component => {
49
- const held = catalog.components.get(component.name);
50
- return held !== undefined && (!isGlobal(held) || shadows.has(component.name));
51
- });
40
+ const taken = components.filter(component => catalog.components.has(component.name));
52
41
  if (taken.length > 0) {
53
42
  throw new Error(`Blok components already in the catalog: ${taken.map(component => component.name).join(', ')}`);
54
43
  }
55
- const previous = new Map<string, BlokComponentDefinition>();
56
- for (const component of components) {
57
- const drawnOver = catalog.components.get(component.name);
58
- if (drawnOver) {
59
- previous.set(component.name, drawnOver);
60
- shadows.add(component.name);
61
- }
62
- catalog.components.set(component.name, component);
63
- }
44
+ for (const component of components) catalog.components.set(component.name, component);
64
45
  return () => {
65
46
  for (const component of components) {
66
- if (catalog.components.get(component.name) !== component) continue;
67
- const restored = previous.get(component.name);
68
- if (restored) {
69
- catalog.components.set(component.name, restored);
70
- shadows.delete(component.name);
71
- } else catalog.components.delete(component.name);
47
+ if (catalog.components.get(component.name) === component) catalog.components.delete(component.name);
72
48
  }
73
49
  };
74
50
  };
@@ -0,0 +1,41 @@
1
+ import {describe, expect, it} from 'vitest';
2
+ import * as z from 'zod';
3
+ import {threeScene} from '../scene';
4
+ import {shadcnExtras, shadcnHtml, shadcnLogo, shadcnUi} from '../shadcn';
5
+ import {hostedStructure} from '../ports/structure/index';
6
+ import {ORKESTRATOR_CATALOG_ID, parseSpecCatalog} from '../spec/catalogs';
7
+ import {addBlokComponents} from './catalog';
8
+ import {blokCatalogSpec, declareBlokUi, ownComponentsOf} from './declare';
9
+ import {BASE_CATALOG_ADDRESS, createBlokComponent, ownBlokCatalog} from './runtime';
10
+
11
+ const gauge = createBlokComponent({name: 'Gauge', service: 'lab', schema: z.object({value: z.number().optional().describe('What it reads.')}).describe('A gauge.')}, () => null);
12
+
13
+ describe('declareBlokUi', () => {
14
+ it('speaks the base catalog in the contexts it draws whole', () => {
15
+ const whole = declareBlokUi({name: 'whole', implements: [shadcnUi, shadcnHtml, shadcnLogo, shadcnExtras, threeScene, hostedStructure]});
16
+ expect(whole.contexts).toEqual(['HTML', 'SCENE', 'LOGO']);
17
+ expect(whole.claims).toEqual(['base@3']);
18
+ const flat = declareBlokUi({name: 'flat', implements: [shadcnUi, shadcnHtml, shadcnLogo, shadcnExtras, hostedStructure]});
19
+ expect(flat.contexts).toEqual(['HTML', 'LOGO']);
20
+ const logos = declareBlokUi({name: 'logos', implements: [shadcnLogo]});
21
+ expect([logos.contexts, logos.claims]).toEqual([['LOGO'], ['base@3']]);
22
+ expect(declareBlokUi({name: 'none', implements: []}).claims).toEqual([]);
23
+ });
24
+
25
+ it('publishes what it draws beyond the base catalog as an app catalog', () => {
26
+ const ui = declareBlokUi({
27
+ name: 'lab',
28
+ implements: [shadcnUi, ownBlokCatalog({name: 'lab', version: 1, description: 'A lab.'}, [gauge])],
29
+ });
30
+ expect(ui.claims).toEqual(['lab@1']);
31
+ expect(ownComponentsOf(ui.catalog).map(component => component.name)).toEqual(['Gauge']);
32
+ const undo = addBlokComponents([createBlokComponent({name: 'Dial', schema: z.object({})}, () => null)], ui.catalog);
33
+ const spec = blokCatalogSpec({id: 'https://acme.example/catalogs/lab/v1', name: 'lab', version: 1, description: 'A lab.'}, ui.catalog);
34
+ undo();
35
+ expect([spec.id, spec.version, spec.minor, spec.extends]).toEqual(['https://acme.example/catalogs/lab/v1', 1, 0, BASE_CATALOG_ADDRESS]);
36
+ expect(spec.components.map(component => [component.name, component.service])).toEqual([['Dial', undefined], ['Gauge', 'lab']]);
37
+ const parsed = parseSpecCatalog(spec, 'lab');
38
+ expect(parsed.components.find(component => component.name === 'Gauge')?.service).toBe('lab');
39
+ expect(blokCatalogSpec({id: ORKESTRATOR_CATALOG_ID, name: 'orkestrator', version: 1, extends: BASE_CATALOG_ADDRESS, description: ''}, ui.catalog).extends).toBe(BASE_CATALOG_ADDRESS);
40
+ });
41
+ });
@@ -1,5 +1,7 @@
1
1
  import {baseBlokCatalog} from './baseCatalog';
2
2
  import {
3
+ BASE_CATALOG_ADDRESS,
4
+ BASE_CATALOG_REF,
3
5
  catalogRef,
4
6
  describeBlokComponent,
5
7
  extendBlokCatalog,
@@ -8,28 +10,51 @@ import {
8
10
  type BlokComponentDefinition,
9
11
  type SpecCatalogJson,
10
12
  } from './runtime';
13
+ import {baseCatalog} from '../spec/catalogs';
14
+ import type {BlokContextName} from '../spec/vocabulary';
11
15
 
12
16
  /**
13
- * A UI's catalog, declared: the catalogs it implements and nothing inferred.
17
+ * A UI's catalog, declared: what it draws, and nothing inferred.
14
18
  *
15
- * - `catalog` is what its renderers draw: base@2 and every implementation.
16
- * - `claims` are the global catalogs it implements whole (`ui@1`, `scene@1`):
17
- * the server resolves their components from the spec, so a blok that uses
18
- * only claimed catalogs is known to render here.
19
- * - Its own catalogs (unversioned contracts) are part of `catalog`; what it
20
- * registers as its module is `moduleComponentsOf(catalog)`, which also counts
21
- * what its modules add later (`addBlokComponents`).
22
- *
23
- * A global catalog implemented `partial`ly is drawn but not claimed.
19
+ * - `catalog` is what its renderers draw: the language's own elements and every
20
+ * implementation.
21
+ * - `contexts` are the contexts in which it draws the base catalog whole
22
+ * (`HTML`, `SCENE`, `LOGO`): a blok written for the base catalog and drawn in
23
+ * one of them is known to render here.
24
+ * - `claims` are the catalogs it speaks: the base catalog when it draws it
25
+ * whole in at least one context, and each published catalog of its own.
26
+ * - Its own catalogs are part of `catalog`; what it publishes as its app
27
+ * catalog is `ownComponentsOf(catalog)`, which also counts what its modules
28
+ * add later (`addBlokComponents`).
24
29
  */
25
30
  export type BlokUi = {
26
31
  name: string;
27
32
  description: string | null;
28
33
  catalog: BlokCatalog;
29
34
  implementations: readonly BlokCatalogImplementation[];
35
+ contexts: readonly BlokContextName[];
30
36
  claims: readonly string[];
31
37
  };
32
38
 
39
+ const CONTEXTS: readonly BlokContextName[] = ['HTML', 'SCENE', 'LOGO'];
40
+
41
+ /**
42
+ * The context a base component counts towards: its own, and for one that
43
+ * bridges html and another context (`Scene` opens a scene inside html), the
44
+ * other one: a renderer that draws no 3D still draws html whole.
45
+ */
46
+ const contextOf = (component: {context: BlokContextName; childrenContext: BlokContextName | null}): BlokContextName =>
47
+ component.context !== 'HTML' ? component.context : (component.childrenContext ?? 'HTML');
48
+
49
+ /** The contexts in which `catalog` draws every component of the base catalog. */
50
+ export const baseContextsOf = (catalog: BlokCatalog): BlokContextName[] => {
51
+ const components = baseCatalog().components;
52
+ return CONTEXTS.filter(context => {
53
+ const drawn = components.filter(component => !component.inheritsContext && contextOf(component) === context);
54
+ return drawn.length > 0 && drawn.every(component => catalog.components.has(component.name));
55
+ });
56
+ };
57
+
33
58
  export const declareBlokUi = (declaration: {
34
59
  name: string;
35
60
  description?: string;
@@ -41,42 +66,55 @@ export const declareBlokUi = (declaration: {
41
66
  if (twice.length > 0) {
42
67
  throw new Error(`${declaration.name} implements ${[...new Set(twice)].join(', ')} twice`);
43
68
  }
69
+ const catalog = extendBlokCatalog(
70
+ baseBlokCatalog,
71
+ declaration.name,
72
+ implementations.flatMap(implementation => implementation.components),
73
+ );
74
+ const contexts = baseContextsOf(catalog);
44
75
  return {
45
76
  name: declaration.name,
46
77
  description: declaration.description ?? null,
47
- catalog: extendBlokCatalog(
48
- baseBlokCatalog,
49
- declaration.name,
50
- implementations.flatMap(implementation => implementation.components),
51
- ),
78
+ catalog,
52
79
  implementations,
53
- claims: implementations
54
- .filter(implementation => implementation.contract.version !== null && implementation.whole)
55
- .map(implementation => catalogRef(implementation.contract))
56
- .sort(),
80
+ contexts,
81
+ claims: [
82
+ ...(contexts.length > 0 ? [BASE_CATALOG_REF] : []),
83
+ ...implementations
84
+ .filter(implementation => implementation.contract.partOf === null && implementation.contract.version !== null && implementation.whole)
85
+ .map(implementation => catalogRef(implementation.contract))
86
+ .sort(),
87
+ ],
57
88
  };
58
89
  };
59
90
 
60
91
  /**
61
- * What a UI registers as its module (the server's `Module.components`): every
62
- * component of its catalog that is neither base@2's nor a global catalog's. Its
63
- * own catalogs' components, what its modules added since (`addBlokComponents`),
64
- * and a global component a module drew over (it is the module's now).
92
+ * What a UI draws beyond the base catalog: every component of its catalog
93
+ * that is neither the language's own nor one of the base catalog's. Its own
94
+ * catalogs' components, and what its modules added since (`addBlokComponents`).
65
95
  */
66
- export const moduleComponentsOf = (catalog: BlokCatalog): BlokComponentDefinition[] =>
96
+ export const ownComponentsOf = (catalog: BlokCatalog): BlokComponentDefinition[] =>
67
97
  [...catalog.components.values()].filter(
68
- component => catalog.base?.components.get(component.name) !== component && component.origin?.includes('@') !== true,
98
+ component => catalog.base?.components.get(component.name) !== component && component.origin !== BASE_CATALOG_REF,
69
99
  );
70
100
 
71
101
  /**
72
- * A UI's module as the spec writes a catalog: for the language's default view
73
- * (`registerBlokModules([parseSpecCatalog(blokModuleSpec(...), ...)])`), so the
74
- * parser and the checks know the components only this UI draws.
102
+ * A UI's app catalog as the spec writes one (`{id, name, version, minor,
103
+ * extends, components}`): what it publishes at `id`, registers with the
104
+ * server, and hands the language (`setAppBlokCatalog(parseSpecCatalog(...))`)
105
+ * so its own parser, checks and editor know the components only it draws.
75
106
  */
76
- export const blokModuleSpec = (name: string, description: string, catalog: BlokCatalog): SpecCatalogJson => ({
77
- name,
78
- description,
79
- components: moduleComponentsOf(catalog)
107
+ export const blokCatalogSpec = (
108
+ meta: {id: string; name: string; version: number; minor?: number; extends?: string; description: string},
109
+ catalog: BlokCatalog,
110
+ ): SpecCatalogJson => ({
111
+ id: meta.id,
112
+ name: meta.name,
113
+ version: meta.version,
114
+ minor: meta.minor ?? 0,
115
+ extends: meta.extends ?? BASE_CATALOG_ADDRESS,
116
+ description: meta.description,
117
+ components: ownComponentsOf(catalog)
80
118
  .map(component => describeBlokComponent(component.name, component))
81
119
  .sort((left, right) => (left.name < right.name ? -1 : left.name > right.name ? 1 : 0)),
82
120
  });
@@ -4,24 +4,40 @@ import type {BlokComponentContract, BlokComponentDefinition, BlokRenderArgs} fro
4
4
  /**
5
5
  * Catalogs as the UI defines them.
6
6
  *
7
- * A *contract* (`defineBlokCatalog`) says which components a catalog holds and
8
- * what each takes: name, schema, placement. It draws nothing. A versioned one
9
- * (`ui@1`, `scene@1`) is global: every UI that implements it whole draws the
10
- * same bloks, and the spec publishes it. An unversioned one is a UI's own (the
11
- * `newswitch` catalog, orkestrator's MikroScene parts), registered with that UI.
7
+ * A *contract* (`defineBlokCatalog`) says which components a set holds and what
8
+ * each takes: name, schema, placement. It draws nothing. There are two sorts:
9
+ *
10
+ * - A *family* of the base catalog (`ui`, `html`, `shadcn`, `structure`,
11
+ * `scene`, `logo`): `partOf` names the catalog it is part of (`base@3`). The
12
+ * base catalog is the spec's, and every renderer draws it whole; the families
13
+ * are how this package holds its contracts, one toolkit at a time.
14
+ * - A UI's *own* catalog (the Orkestrator's MikroScene parts): what it draws
15
+ * beyond the base. Given an `id` (the address it is published at) and a
16
+ * version it is an app catalog a blok can be written for.
12
17
  *
13
18
  * An *implementation* (`implementBlokCatalog`) is the app's: one render per
14
19
  * component of a contract, a map the compiler checks against the contract.
15
20
  */
16
21
 
22
+ /** The base catalog, as components of it are tagged (`origin`). */
23
+ export const BASE_CATALOG_REF = 'base@3';
24
+ /** The address the base catalog is published at: what a blok is written for when it names none. */
25
+ export const BASE_CATALOG_ADDRESS = 'https://arkitekt.live/catalogs/base/v3';
26
+
17
27
  export type BlokComponentContracts = Record<string, BlokComponentContract<any>>;
18
28
 
19
29
  export type BlokCatalogContract<TComponents extends BlokComponentContracts = BlokComponentContracts> = {
20
30
  name: string;
21
- /** Set on a global catalog (`ui@1`); null on a UI's own. */
31
+ /** Set on a published catalog (an app catalog's `1`); null on a family, and on a UI's own that nothing publishes. */
22
32
  version: number | null;
23
33
  description: string;
24
34
  components: TComponents;
35
+ /** For a family: the catalog it is part of (`base@3`). Null on a catalog of its own. */
36
+ partOf: string | null;
37
+ /** For a published catalog: the address it is published at, which is what a blok names it by. */
38
+ id: string | null;
39
+ /** The id of the catalog it adds to; the base catalog's when left out. */
40
+ extends: string | null;
25
41
  };
26
42
 
27
43
  export const defineBlokCatalog = <const TComponents extends BlokComponentContracts>(contract: {
@@ -29,9 +45,18 @@ export const defineBlokCatalog = <const TComponents extends BlokComponentContrac
29
45
  version?: number;
30
46
  description: string;
31
47
  components: TComponents;
32
- }): BlokCatalogContract<TComponents> => ({...contract, version: contract.version ?? null});
48
+ partOf?: string;
49
+ id?: string;
50
+ extends?: string;
51
+ }): BlokCatalogContract<TComponents> => ({
52
+ ...contract,
53
+ version: contract.version ?? null,
54
+ partOf: contract.partOf ?? null,
55
+ id: contract.id ?? null,
56
+ extends: contract.extends ?? null,
57
+ });
33
58
 
34
- /** How a catalog is named on the wire: `name@version`, or a UI's own catalog's bare name. */
59
+ /** How a contract is named: `name@version`, or the bare name of a family or of a UI's own unpublished catalog. */
35
60
  export const catalogRef = (contract: Pick<BlokCatalogContract, 'name' | 'version'>): string =>
36
61
  contract.version === null ? contract.name : `${contract.name}@${contract.version}`;
37
62
 
@@ -83,7 +108,7 @@ export function implementBlokCatalog(
83
108
  }
84
109
  const components = Object.entries(contract.components).flatMap(([name, component]): BlokComponentDefinition[] => {
85
110
  const render = renders[name];
86
- return render ? [{...component, name, render: render as React.ComponentType<BlokRenderArgs>, origin: ref}] : [];
111
+ return render ? [{...component, name, render: render as React.ComponentType<BlokRenderArgs>, origin: contract.partOf ?? ref}] : [];
87
112
  });
88
113
  return {contract, components, whole: missing.length === 0};
89
114
  }
@@ -94,7 +119,7 @@ export function implementBlokCatalog(
94
119
  * once. The UI owns both, so there is nothing to check one against.
95
120
  */
96
121
  export const ownBlokCatalog = (
97
- meta: {name: string; version?: number; description: string},
122
+ meta: {name: string; version?: number; description: string; id?: string; extends?: string},
98
123
  components: readonly BlokComponentDefinition[],
99
124
  ): BlokCatalogImplementation => {
100
125
  const contract = defineBlokCatalog({
@@ -67,6 +67,12 @@ type BlokComponentApi = {
67
67
  * where the schema itself only says "a path".
68
68
  */
69
69
  bindKinds?: Readonly<Record<string, string>>;
70
+ /** The blok kinds it may be placed in (`assign`); any kind when left out. */
71
+ kinds?: readonly string[];
72
+ /** The service it needs where it is drawn (`mikro`): without it a notice shows in its place. */
73
+ service?: string;
74
+ /** The minor of its catalog that added it; the first when left out. */
75
+ since?: number;
70
76
  };
71
77
 
72
78
  /**
@@ -82,7 +88,7 @@ export type BlokComponentDefinition = BlokComponentApi & {
82
88
  name: string;
83
89
  schema: BlokObjectSchema;
84
90
  render: React.ComponentType<BlokRenderArgs>;
85
- /** The catalog contract it implements (`ui@1`, `newswitch`); unset for one built on its own. */
91
+ /** The catalog it is of (`base@3` for a component of one of its families, `newswitch`); unset for one built on its own. */
86
92
  origin?: string;
87
93
  };
88
94
 
@@ -99,6 +105,9 @@ export const createBlokComponent = <TSchema extends BlokObjectSchema>(
99
105
  textProp: api.textProp,
100
106
  events: api.events,
101
107
  bindKinds: api.bindKinds,
108
+ kinds: api.kinds,
109
+ service: api.service,
110
+ since: api.since,
102
111
  render: render as React.ComponentType<BlokRenderArgs>,
103
112
  });
104
113
 
@@ -5,10 +5,12 @@ import {isRequiredField} from './preflight';
5
5
  import {isActionSchema, isBindSchema, unwrapSchema} from './schemas';
6
6
 
7
7
  /**
8
- * A contract as the spec publishes it (`spec/catalogs/ui@1.json`, arkitekt-spec's
9
- * `blok/catalogs/`): the JSON the server and `arkitekt check` validate bloks
10
- * against. Written from the contract, never by hand: the zod schemas are the
11
- * source, the JSON what they say in the spec's terms.
8
+ * A contract in the spec's terms: what a catalog file (`spec/catalogs/base@3.json`,
9
+ * arkitekt-spec's `blok/catalogs/`) says of each component. Written from the
10
+ * contract, never by hand: the zod schemas are the source of a component's
11
+ * props and documentation, the JSON what they say in the spec's terms. The
12
+ * spec's base catalog is built from it (`pnpm spec:export`), and an app
13
+ * catalog is published as it (`blokCatalogSpec`).
12
14
  */
13
15
 
14
16
  export type SpecValueKind = 'STRING' | 'INT' | 'FLOAT' | 'BOOL' | 'DICT' | 'LIST' | 'ANY' | 'CALLBACK' | 'ASSET';
@@ -33,11 +35,19 @@ export type SpecComponentJson = {
33
35
  not_downstream_of: string[];
34
36
  text_prop: string | null;
35
37
  props: SpecPropJson[];
38
+ kinds?: string[];
39
+ service?: string;
40
+ since?: number;
36
41
  };
37
42
 
38
43
  export type SpecCatalogJson = {
44
+ /** The address a published catalog is known by. */
45
+ id?: string;
39
46
  name: string;
40
47
  version?: number;
48
+ minor?: number;
49
+ /** The id of the catalog it adds to. */
50
+ extends?: string;
41
51
  description: string;
42
52
  components: SpecComponentJson[];
43
53
  };
@@ -163,6 +173,9 @@ export const describeBlokComponent = (name: string, component: BlokComponentCont
163
173
  not_downstream_of: [...(placement.notDownstreamOf ?? [])],
164
174
  text_prop: component.textProp ?? null,
165
175
  props,
176
+ ...(component.kinds?.length ? {kinds: [...component.kinds]} : {}),
177
+ ...(component.service ? {service: component.service} : {}),
178
+ ...(component.since ? {since: component.since} : {}),
166
179
  };
167
180
  };
168
181
 
@@ -15,6 +15,7 @@ export * from './status';
15
15
  export * from './resource';
16
16
  export * from './reads';
17
17
  export * from './task';
18
+ export * from './text';
18
19
  export * from './tree';
19
20
  export * from './types';
20
21
  export * from './viewer';
@@ -3,6 +3,7 @@ import type {BlokCatalog} from './functions';
3
3
  import {BlokSchemas, isActionSchema} from './schemas';
4
4
  import type {PreparedBlokNode} from './tree';
5
5
  import type {BlokActionArgument, BlokComponentNode, BlokComponentProp} from './types';
6
+ import {lowerBlokText} from './text';
6
7
  import {extractUiComponents, isRecord} from './utils';
7
8
  import {loadVocabulary} from '../../spec/vocabulary';
8
9
 
@@ -192,7 +193,9 @@ export const preflightBlokDocument = (
192
193
  const invalidNodes = new Map<string, string[]>();
193
194
  const rootIds: string[] = [];
194
195
  const unknownKinds = new Map<string, string[]>();
195
- extractUiComponents(uiComponents).forEach(raw => unknownCallKinds(raw, unknownKinds));
196
+ // Text is stored as nodes; what each component does with it is the catalog's to say.
197
+ const roots = extractUiComponents(uiComponents).map(raw => lowerBlokText(raw, catalog));
198
+ roots.forEach(raw => unknownCallKinds(raw, unknownKinds));
196
199
 
197
200
  const pushError = (error: BlokValidationError) => {
198
201
  errors.push(error);
@@ -242,7 +245,7 @@ export const preflightBlokDocument = (
242
245
  });
243
246
  };
244
247
 
245
- extractUiComponents(uiComponents).forEach((rawComponent, componentIndex) => {
248
+ roots.forEach((rawComponent, componentIndex) => {
246
249
  const basePath = `uiComponents[${componentIndex}]`;
247
250
  const parsed = BlokSchemas.ComponentNode.safeParse(rawComponent);
248
251
 
@@ -0,0 +1,65 @@
1
+ // @vitest-environment jsdom
2
+ import {cleanup, screen} from '@testing-library/react';
3
+ import {afterEach, describe, expect, it} from 'vitest';
4
+ import {parseBsx} from '../../bsx/parse';
5
+ import {renderBsx, testCatalog} from '../bloks/testing';
6
+ import {baseBlokCatalog} from '../baseCatalog';
7
+ import {lowerBlokText} from './text';
8
+
9
+ afterEach(cleanup);
10
+
11
+ type Lowered = {component: string; props?: Array<Record<string, unknown>>; children?: Lowered[]};
12
+
13
+ const lowered = (source: string, catalog = testCatalog()): Lowered => lowerBlokText(parseBsx(source).tree, catalog) as Lowered;
14
+
15
+ describe('text, as the renderer draws it', () => {
16
+ it('is the text prop of a component that has one', () => {
17
+ const button = lowered('<Button>Go</Button>');
18
+ expect(button.children).toBeUndefined();
19
+ expect(button.props).toEqual([{key: 'label', static_value: 'Go'}]);
20
+ const badge = lowered('<Badge>{task.status}</Badge>');
21
+ expect(badge.props).toEqual([{key: 'text', dynamic_value: {path: 'task.status'}}]);
22
+ });
23
+
24
+ it('is a Text among other children, a span inside a plain html element', () => {
25
+ const card = lowered('<Card>Hello <Badge>new</Badge> there</Card>');
26
+ expect(card.children?.map(child => child.component)).toEqual(['Text', 'Badge', 'Text']);
27
+ expect(card.children?.[0].props).toEqual([{key: 'text', static_value: 'Hello '}]);
28
+ expect(card.children?.[1].props).toEqual([{key: 'text', static_value: 'new'}]);
29
+ expect(lowered('<div>plain</div>').children?.map(child => child.component)).toEqual(['span']);
30
+ // A language element is no place of its own: the text takes after what is around it.
31
+ const within = lowered('<div><if when={args.x}>shown</if></div>');
32
+ expect(within.children?.[0].children?.map(child => child.component)).toEqual(['span']);
33
+ });
34
+
35
+ it('leaves a component alone that sets the prop itself, and a tree with no text', () => {
36
+ const both = lowered('<Button label="a">b</Button>');
37
+ expect(both.props).toEqual([{key: 'label', static_value: 'a'}]);
38
+ expect(both.children?.map(child => child.component)).toEqual(['Text']);
39
+ const {tree} = parseBsx('<Card><Button label="Go" /></Card>');
40
+ expect(lowerBlokText(tree, testCatalog())).toBe(tree);
41
+ });
42
+
43
+ it('passes a tree stored before text was a node through as it is', () => {
44
+ const stored = {
45
+ id: 'Card[0]',
46
+ component: 'Card',
47
+ children: [
48
+ {id: 'Card[0]/#0', component: 'Text', props: [{key: 'text', static_value: 'Hello'}]},
49
+ {id: 'Card[0]/Button[0]', component: 'Button', props: [{key: 'label', static_value: 'Go'}]},
50
+ ],
51
+ };
52
+ expect(lowerBlokText(stored, testCatalog())).toBe(stored);
53
+ });
54
+
55
+ it('is the text node itself where the catalog draws nothing else with it', () => {
56
+ const fragment = lowered('<fragment>bare</fragment>', baseBlokCatalog);
57
+ expect(fragment.children?.map(child => child.component)).toEqual(['#text']);
58
+ });
59
+
60
+ it('shows on the page, whichever way it was written', () => {
61
+ renderBsx(testCatalog(), '<Card><Button>Go</Button><Text>Arrived</Text>and done<div>in a div</div></Card>');
62
+ expect(screen.getByRole('button').textContent).toBe('Go');
63
+ for (const shown of ['Arrived', 'and done', 'in a div']) expect(screen.queryByText(shown)).not.toBeNull();
64
+ });
65
+ });
@@ -0,0 +1,88 @@
1
+ import {baseCatalog} from '../../spec/catalogs';
2
+ import type {BlokCatalog} from './functions';
3
+ import {isRecord} from './utils';
4
+
5
+ /**
6
+ * Text as a renderer draws it.
7
+ *
8
+ * The parser stores every run of text as a `#text` node under the component
9
+ * it stands in, and knows no catalog. What a component does with its text is
10
+ * said here, by the renderer, which has the catalog:
11
+ *
12
+ * - A component with a `textProp` whose one child is a run of text takes that
13
+ * text as the prop (`<Button>Go</Button>` is a `Button` with `label="Go"`).
14
+ * - Any other run of text becomes the component text is drawn with in that
15
+ * place: a `span` inside a plain html element, a `Text` anywhere else.
16
+ *
17
+ * A tree stored before text was a node holds the prop, or the `Text`/`span`,
18
+ * already: it passes through as it is. A renderer on another toolkit (React
19
+ * Native) uses the same pass, so every run of text arrives as a component it
20
+ * can wrap.
21
+ */
22
+
23
+ /** The node a run of text is stored as (`bsx/parse`'s `TEXT_NODE`). */
24
+ export const BLOK_TEXT_NODE = '#text';
25
+ /** The prop of a text node that holds its text. */
26
+ export const BLOK_TEXT_VALUE = 'value';
27
+ /** What a run of text is drawn with among other children, and inside a plain html element. */
28
+ const LOOSE_TEXT = 'Text';
29
+ const LOOSE_HTML_TEXT = 'span';
30
+ /** The prop `Text` and `span` take their text as. */
31
+ const LOOSE_TEXT_PROP = 'text';
32
+
33
+ let groups: Map<string, string | null> | null = null;
34
+
35
+ /** The family of a base component (`language`, `html`, ...), by name. */
36
+ const groupOf = (component: string): string | null | undefined => {
37
+ groups ??= new Map(baseCatalog().components.map(entry => [entry.name, entry.group]));
38
+ return groups.get(component);
39
+ };
40
+
41
+ type RawNode = Record<string, unknown> & {component: string};
42
+
43
+ const isNode = (value: unknown): value is RawNode => isRecord(value) && !Array.isArray(value) && typeof value.component === 'string';
44
+ const isTextNode = (value: unknown): value is RawNode => isNode(value) && value.component === BLOK_TEXT_NODE;
45
+
46
+ /** The one prop of a text node, under another key; null when the node holds anything else. */
47
+ const valueAs = (node: RawNode, key: string): Record<string, unknown> | null => {
48
+ const props = Array.isArray(node.props) ? node.props : [];
49
+ const value = props.length === 1 && isRecord(props[0]) && props[0].key === BLOK_TEXT_VALUE ? props[0] : null;
50
+ return value ? {...value, key} : null;
51
+ };
52
+
53
+ /**
54
+ * `raw` with every run of text made what `catalog` draws it as. Nodes without
55
+ * text among their children are returned as they are (the same object).
56
+ */
57
+ export const lowerBlokText = (raw: unknown, catalog: BlokCatalog, looseText: string = LOOSE_TEXT): unknown => {
58
+ if (!isNode(raw)) return raw;
59
+ const group = groupOf(raw.component);
60
+ // The component loose text becomes here, from the nearest ancestor that is no language element.
61
+ const loose = group === 'html' ? LOOSE_HTML_TEXT : group === 'language' ? looseText : LOOSE_TEXT;
62
+ const children = Array.isArray(raw.children) ? raw.children : null;
63
+ if (!children) return raw;
64
+ const texts = children.filter(isTextNode);
65
+ if (texts.length === 0) {
66
+ const lowered = children.map(child => lowerBlokText(child, catalog, loose));
67
+ return lowered.some((child, index) => child !== children[index]) ? {...raw, children: lowered} : raw;
68
+ }
69
+ const props = Array.isArray(raw.props) ? raw.props : [];
70
+ const textProp = catalog.components.get(raw.component)?.textProp;
71
+ if (textProp && children.length === 1 && !props.some(prop => isRecord(prop) && prop.key === textProp)) {
72
+ const value = valueAs(texts[0], textProp);
73
+ if (value) {
74
+ const {children: _children, ...rest} = raw;
75
+ return {...rest, props: [...props, value]};
76
+ }
77
+ }
78
+ const drawnWith = catalog.components.has(loose) ? loose : null;
79
+ return {
80
+ ...raw,
81
+ children: children.map(child => {
82
+ if (!isTextNode(child)) return lowerBlokText(child, catalog, loose);
83
+ const value = drawnWith ? valueAs(child, LOOSE_TEXT_PROP) : null;
84
+ // A catalog without it draws the text node itself (the language's own `#text`).
85
+ return value ? {id: child.id, component: drawnWith, props: [value]} : child;
86
+ }),
87
+ };
88
+ };
package/src/runtime.ts CHANGED
@@ -3,7 +3,6 @@ export * from './renderer/runtime';
3
3
  export * from './renderer/functions';
4
4
  export * from './renderer/declarations';
5
5
  export * from './renderer/persist';
6
- export * from './renderer/modules';
7
6
  export * from './renderer/baseCatalog';
8
7
  export * from './renderer/declare';
9
8
  export * from './cache/keyedStore';
package/src/scene.ts CHANGED
@@ -1,4 +1,4 @@
1
- // @arkitektio/bsx/scene: scene@1 drawn with three, @react-three/fiber and drei (opt-in: an app passes
1
+ // @arkitektio/bsx/scene: the scene family drawn with three, @react-three/fiber and drei (opt-in: an app passes
2
2
  // threeScene to declareBlokUi), and the scene and run hosts the renderer mounts.
3
3
  import {sceneCatalog} from './catalogs/index';
4
4
  import {runRenders} from './renderer/bloks/run';
@@ -10,7 +10,7 @@ export * from './renderer/bloks/run';
10
10
 
11
11
  const renders = {...sceneRenders, ...runRenders};
12
12
 
13
- /** scene@1, drawn with three. */
13
+ /** the scene family, drawn with three. */
14
14
  export const threeScene = implementBlokCatalog(sceneCatalog, {
15
15
  Animate: renders.Animate,
16
16
  Attach: renders.Attach,