@arkitektio/bsx 6.9.0 → 7.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 (144) hide show
  1. package/dist/bsx/infer.d.ts.map +1 -1
  2. package/dist/bsx/infer.js +4 -2
  3. package/dist/bsx/infer.js.map +1 -1
  4. package/dist/bsx/language.d.ts.map +1 -1
  5. package/dist/bsx/language.js +14 -10
  6. package/dist/bsx/language.js.map +1 -1
  7. package/dist/bsx/references.d.ts.map +1 -1
  8. package/dist/bsx/references.js +94 -35
  9. package/dist/bsx/references.js.map +1 -1
  10. package/dist/catalogs/index.d.ts +191 -98
  11. package/dist/catalogs/index.d.ts.map +1 -1
  12. package/dist/catalogs/parts/data.d.ts +2 -2
  13. package/dist/catalogs/parts/data.d.ts.map +1 -1
  14. package/dist/catalogs/parts/data.js +2 -3
  15. package/dist/catalogs/parts/data.js.map +1 -1
  16. package/dist/catalogs/parts/feedback.d.ts +6 -6
  17. package/dist/catalogs/parts/forms.d.ts +8 -8
  18. package/dist/catalogs/parts/icons.d.ts +4 -4
  19. package/dist/catalogs/parts/index.d.ts +48 -48
  20. package/dist/catalogs/parts/navigation.d.ts +8 -8
  21. package/dist/catalogs/parts/overlays.d.ts +22 -22
  22. package/dist/catalogs/parts/run.d.ts.map +1 -1
  23. package/dist/catalogs/parts/run.js +4 -5
  24. package/dist/catalogs/parts/run.js.map +1 -1
  25. package/dist/catalogs/parts/scene.d.ts.map +1 -1
  26. package/dist/catalogs/parts/scene.js +7 -14
  27. package/dist/catalogs/parts/scene.js.map +1 -1
  28. package/dist/catalogs/parts/structure.d.ts.map +1 -1
  29. package/dist/catalogs/parts/structure.js +2 -3
  30. package/dist/catalogs/parts/structure.js.map +1 -1
  31. package/dist/catalogs/parts/toast.d.ts.map +1 -1
  32. package/dist/catalogs/parts/toast.js +2 -1
  33. package/dist/catalogs/parts/toast.js.map +1 -1
  34. package/dist/catalogs/props.d.ts +23 -0
  35. package/dist/catalogs/props.d.ts.map +1 -1
  36. package/dist/catalogs/props.js +56 -4
  37. package/dist/catalogs/props.js.map +1 -1
  38. package/dist/catalogs/scene.d.ts +134 -127
  39. package/dist/catalogs/scene.d.ts.map +1 -1
  40. package/dist/catalogs/scene.js +5 -3
  41. package/dist/catalogs/scene.js.map +1 -1
  42. package/dist/catalogs/shadcn.d.ts +79 -41
  43. package/dist/catalogs/shadcn.d.ts.map +1 -1
  44. package/dist/catalogs/shadcn.js +13 -13
  45. package/dist/catalogs/shadcn.js.map +1 -1
  46. package/dist/catalogs/structure.d.ts +9 -2
  47. package/dist/catalogs/structure.d.ts.map +1 -1
  48. package/dist/catalogs/structure.js +1 -1
  49. package/dist/catalogs/structure.js.map +1 -1
  50. package/dist/catalogs/ui.d.ts +935 -892
  51. package/dist/catalogs/ui.d.ts.map +1 -1
  52. package/dist/catalogs/ui.js +16 -14
  53. package/dist/catalogs/ui.js.map +1 -1
  54. package/dist/catalogs/zodToPort.d.ts +9 -0
  55. package/dist/catalogs/zodToPort.d.ts.map +1 -0
  56. package/dist/catalogs/zodToPort.js +156 -0
  57. package/dist/catalogs/zodToPort.js.map +1 -0
  58. package/dist/catalogs.d.ts +4 -1
  59. package/dist/catalogs.d.ts.map +1 -1
  60. package/dist/catalogs.js +3 -0
  61. package/dist/catalogs.js.map +1 -1
  62. package/dist/index.d.ts +2 -0
  63. package/dist/index.d.ts.map +1 -1
  64. package/dist/index.js +2 -0
  65. package/dist/index.js.map +1 -1
  66. package/dist/ports/rekuest.d.ts +6 -0
  67. package/dist/ports/rekuest.d.ts.map +1 -1
  68. package/dist/ports/rekuest.js +6 -0
  69. package/dist/ports/rekuest.js.map +1 -1
  70. package/dist/renderer/bloks/data.d.ts +2 -2
  71. package/dist/renderer/bloks/feedback.d.ts +6 -6
  72. package/dist/renderer/bloks/forms.d.ts +8 -8
  73. package/dist/renderer/bloks/icons.d.ts +2 -2
  74. package/dist/renderer/bloks/index.d.ts +48 -48
  75. package/dist/renderer/bloks/navigation.d.ts +8 -8
  76. package/dist/renderer/bloks/overlays.d.ts +22 -22
  77. package/dist/renderer/runtime/components.d.ts +6 -8
  78. package/dist/renderer/runtime/components.d.ts.map +1 -1
  79. package/dist/renderer/runtime/components.js.map +1 -1
  80. package/dist/renderer/runtime/describe.d.ts +5 -12
  81. package/dist/renderer/runtime/describe.d.ts.map +1 -1
  82. package/dist/renderer/runtime/describe.js +25 -89
  83. package/dist/renderer/runtime/describe.js.map +1 -1
  84. package/dist/renderer/runtime/hooks.d.ts.map +1 -1
  85. package/dist/renderer/runtime/hooks.js +3 -1
  86. package/dist/renderer/runtime/hooks.js.map +1 -1
  87. package/dist/renderer/runtime/schemas.d.ts +8 -6
  88. package/dist/renderer/runtime/schemas.d.ts.map +1 -1
  89. package/dist/renderer/runtime/schemas.js +40 -16
  90. package/dist/renderer/runtime/schemas.js.map +1 -1
  91. package/dist/shadcn.d.ts +48 -48
  92. package/dist/spec/bsx_v2.json +917 -15
  93. package/dist/spec/catalogs/base@4.json +18712 -5274
  94. package/dist/spec/catalogs/base@4.json.js +18712 -5274
  95. package/dist/spec/catalogs/orkestrator@1.json +532 -126
  96. package/dist/spec/catalogs/orkestrator@1.json.js +532 -126
  97. package/dist/spec/catalogs.d.ts +3 -11
  98. package/dist/spec/catalogs.d.ts.map +1 -1
  99. package/dist/spec/catalogs.js +13 -11
  100. package/dist/spec/catalogs.js.map +1 -1
  101. package/dist/spec/fit.d.ts +21 -0
  102. package/dist/spec/fit.d.ts.map +1 -0
  103. package/dist/spec/fit.js +114 -0
  104. package/dist/spec/fit.js.map +1 -0
  105. package/dist/spec/ports.d.ts +56 -0
  106. package/dist/spec/ports.d.ts.map +1 -0
  107. package/dist/spec/ports.js +174 -0
  108. package/dist/spec/ports.js.map +1 -0
  109. package/dist/spec/vocabulary.json +7 -5
  110. package/dist/spec/vocabulary.json.js +7 -5
  111. package/package.json +1 -1
  112. package/src/bsx/infer.test.ts +1 -1
  113. package/src/bsx/infer.ts +4 -2
  114. package/src/bsx/language.ts +13 -9
  115. package/src/bsx/references.ts +125 -38
  116. package/src/catalogs/parts/data.ts +3 -2
  117. package/src/catalogs/parts/run.ts +9 -7
  118. package/src/catalogs/parts/scene.ts +7 -14
  119. package/src/catalogs/parts/structure.ts +2 -3
  120. package/src/catalogs/parts/toast.ts +5 -1
  121. package/src/catalogs/props.ts +64 -4
  122. package/src/catalogs/scene.ts +5 -3
  123. package/src/catalogs/shadcn.ts +13 -13
  124. package/src/catalogs/structure.ts +1 -1
  125. package/src/catalogs/ui.ts +16 -14
  126. package/src/catalogs/zodToPort.test.ts +96 -0
  127. package/src/catalogs/zodToPort.ts +177 -0
  128. package/src/catalogs.ts +4 -1
  129. package/src/index.ts +2 -0
  130. package/src/ports/rekuest.ts +6 -0
  131. package/src/renderer/runtime/catalog.test.ts +12 -8
  132. package/src/renderer/runtime/components.tsx +5 -8
  133. package/src/renderer/runtime/describe.ts +25 -100
  134. package/src/renderer/runtime/hooks.ts +3 -1
  135. package/src/renderer/runtime/schemas.ts +51 -17
  136. package/src/spec/bsx_v2.json +917 -15
  137. package/src/spec/catalogs/base@4.json +18712 -5274
  138. package/src/spec/catalogs/orkestrator@1.json +532 -126
  139. package/src/spec/catalogs.ts +14 -19
  140. package/src/spec/fit.test.ts +65 -0
  141. package/src/spec/fit.ts +114 -0
  142. package/src/spec/ports.ts +172 -0
  143. package/src/spec/spec.test.ts +5 -2
  144. package/src/spec/vocabulary.json +7 -5
@@ -1,4 +1,5 @@
1
- import {BlokPropSchemas, markBindSchema} from '../renderer/runtime/schemas';
1
+ import {BlokPropSchemas, markBindSchema, markPortSchema, markStructureSchema} from '../renderer/runtime/schemas';
2
+ import {ITEM_KEY, TEXT_PORT, type SpecPort} from '../spec/ports';
2
3
  import * as z from 'zod';
3
4
 
4
5
  /**
@@ -166,11 +167,13 @@ export const bindSchema = markBindSchema(
166
167
  * A reference to one object of some module, the shape structure ports carry.
167
168
  * Nullish: an unset state field or form value is `null`, not absent.
168
169
  */
169
- export const structureValueSchema = z
170
- .object({
170
+ export const structureValueSchema = markStructureSchema(
171
+ z.object({
171
172
  object: z.union([z.string(), z.number()]),
172
173
  __identifier: z.string(),
173
- })
174
+ }),
175
+ '*',
176
+ )
174
177
  .nullish()
175
178
  .describe('A structure reference: {"object": "<id>", "__identifier": "@mikro/arraydataset"}.');
176
179
 
@@ -212,3 +215,60 @@ export const textFields = {
212
215
  italic: boolSchema.describe('Render italic.'),
213
216
  truncate: boolSchema.describe('Truncate to a single line with an ellipsis.'),
214
217
  };
218
+
219
+ /** What an accordion or a toggle group has open or pressed: one value, or a list when multiple. */
220
+ export const openValuesSchema = z.union([z.string(), z.array(z.string())]);
221
+
222
+ /** A 4x4 affine matrix as four rows. */
223
+ export const matrixSchema = z.array(z.array(z.number()));
224
+
225
+ const listOf = (item: SpecPort): SpecPort => ({kind: 'LIST', children: [{key: ITEM_KEY, ...item}]});
226
+ const dictOf = (item: SpecPort): SpecPort => ({kind: 'DICT', children: [{key: ITEM_KEY, ...item}]});
227
+ const FLOAT: SpecPort = {kind: 'FLOAT'};
228
+
229
+ /** A matrix as four rows, read leniently: a malformed one is the identity. */
230
+ export const MATRIX_PORT: SpecPort = listOf(listOf(FLOAT));
231
+ /** Dependency keys, in order. */
232
+ export const KEYS_PORT: SpecPort = listOf({kind: 'STRING'});
233
+ /** A number, or a quantity (`{magnitude, unit}`) that is converted. */
234
+ export const AMOUNT_PORT: SpecPort = {
235
+ kind: 'UNION',
236
+ children: [
237
+ {key: '0', kind: 'FLOAT'},
238
+ {key: '1', kind: 'DICT', children: [{key: 'magnitude', kind: 'FLOAT'}, {key: 'unit', kind: 'STRING'}]},
239
+ ],
240
+ };
241
+ /** A value per joint name. */
242
+ export const JOINTS_PORT: SpecPort = dictOf(FLOAT);
243
+ /** One number for all joints, or one per joint name. */
244
+ export const PER_JOINT_PORT: SpecPort = {kind: 'UNION', children: [{key: '0', ...FLOAT}, {key: '1', ...JOINTS_PORT}]};
245
+ /** What a blok reads of a task record: its scalar fields (a DICT, so a record path fits). */
246
+ export const TASK_PORT: SpecPort = {
247
+ kind: 'DICT',
248
+ children: [
249
+ {key: 'id', kind: 'STRING', nullable: true},
250
+ {key: 'status', kind: 'STRING', choices: ['idle', 'queued', 'running', 'asking', 'paused', 'done', 'failed', 'cancelled'].map(value => ({value}))},
251
+ {key: 'running', kind: 'BOOL'},
252
+ {key: 'paused', kind: 'BOOL'},
253
+ {key: 'done', kind: 'BOOL'},
254
+ {key: 'failed', kind: 'BOOL'},
255
+ {key: 'progress', kind: 'INT'},
256
+ {key: 'message', kind: 'STRING', nullable: true},
257
+ {key: 'error', kind: 'STRING', nullable: true},
258
+ ],
259
+ };
260
+ /** Values of GraphQL variables: scalars, ids, lists of ids, structures. */
261
+ export const VARIABLES_PORT: SpecPort = dictOf({
262
+ kind: 'UNION',
263
+ nullable: true,
264
+ children: [
265
+ ...(TEXT_PORT.children ?? []),
266
+ {key: '4', ...listOf({kind: 'STRING'})},
267
+ {key: '5', kind: 'STRUCTURE', identifier: '*'},
268
+ ],
269
+ });
270
+ /** Chart rows: a category label and numbers by series key. */
271
+ export const CHART_ROWS_PORT: SpecPort = listOf(dictOf({kind: 'UNION', nullable: true, children: [{key: '0', kind: 'STRING'}, {key: '1', ...FLOAT}]}));
272
+
273
+ /** `schema` as it parses, published as `port`: a value the renderer reads leniently. Mark last: `.refine()`/`.describe()` clone. */
274
+ export const typedAs = <TSchema extends z.ZodTypeAny>(schema: TSchema, port: SpecPort): TSchema => markPortSchema(schema, port);
@@ -1,5 +1,7 @@
1
1
  import {BASE_CATALOG_REF, defineBlokCatalog} from '../renderer/runtime/catalog';
2
+ import * as z from 'zod';
2
3
  import {parts} from './parts';
4
+ import {matrixSchema} from './props';
3
5
 
4
6
  /** The `scene` family of the base catalog. */
5
7
  export const sceneCatalog = defineBlokCatalog({
@@ -13,16 +15,16 @@ export const sceneCatalog = defineBlokCatalog({
13
15
  Glow: parts.Glow,
14
16
  Model: parts.Model,
15
17
  Move: parts.Move,
16
- OnClick: {...parts.OnClick, events: {onClick: [{key: "node", kind: "STRING", description: "The node that was clicked."}, {key: "point", kind: "LIST", description: "Where it was hit: [x, y, z] in meters."}]}},
18
+ OnClick: {...parts.OnClick, events: {onClick: [{key: "node", port: {kind: "STRING"}, description: "The node that was clicked."}, {key: "point", port: z.array(z.number()), description: "Where it was hit: [x, y, z] in meters."}]}},
17
19
  Placed: parts.Placed,
18
20
  Popout: parts.Popout,
19
- Robot: {...parts.Robot, events: {onJointChange: [{key: "name", kind: "STRING", description: "The joint the viewer set."}, {key: "value", kind: "FLOAT", description: "Its new value."}]}},
21
+ Robot: {...parts.Robot, events: {onJointChange: [{key: "name", port: {kind: "STRING"}, description: "The joint the viewer set."}, {key: "value", port: {kind: "FLOAT"}, description: "Its new value."}]}},
20
22
  Rotate: parts.Rotate,
21
23
  Route: parts.Route,
22
24
  Scene: parts.Scene,
23
25
  Space: parts.Space,
24
26
  Tint: parts.Tint,
25
- Transform: {...parts.Transform, bindKinds: {bind: "ANY"}},
27
+ Transform: {...parts.Transform, bindKinds: {bind: matrixSchema}},
26
28
  Visible: parts.Visible,
27
29
  },
28
30
  });
@@ -7,7 +7,7 @@ export const shadcnCatalog = defineBlokCatalog({
7
7
  partOf: BASE_CATALOG_REF,
8
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
- AlertDialog: {...parts.AlertDialog, events: {onOpenChange: [{key: "value", kind: "BOOL", description: "Whether it is open now."}]}},
10
+ AlertDialog: {...parts.AlertDialog, events: {onOpenChange: [{key: "value", port: {kind: "BOOL"}, description: "Whether it is open now."}]}},
11
11
  AlertDialogAction: parts.AlertDialogAction,
12
12
  AlertDialogCancel: parts.AlertDialogCancel,
13
13
  AlertDialogContent: parts.AlertDialogContent,
@@ -24,42 +24,42 @@ export const shadcnCatalog = defineBlokCatalog({
24
24
  BreadcrumbItem: parts.BreadcrumbItem,
25
25
  BreadcrumbSeparator: parts.BreadcrumbSeparator,
26
26
  ButtonGroup: parts.ButtonGroup,
27
- Calendar: {...parts.Calendar, events: {onChange: [{key: "value", kind: "STRING", description: "The date picked, as an ISO date (YYYY-MM-DD)."}]}, bindKinds: {bind: "STRING"}},
27
+ Calendar: {...parts.Calendar, events: {onChange: [{key: "value", port: {kind: "STRING"}, description: "The date picked, as an ISO date (YYYY-MM-DD)."}]}, bindKinds: {bind: {kind: "STRING"}}},
28
28
  Carousel: parts.Carousel,
29
- Combobox: {...parts.Combobox, events: {onChange: [{key: "value", kind: "STRING", description: "The value picked."}]}, bindKinds: {bind: "STRING"}},
30
- DatePicker: {...parts.DatePicker, events: {onChange: [{key: "value", kind: "STRING", description: "The date picked, as an ISO date (YYYY-MM-DD)."}]}, bindKinds: {bind: "STRING"}},
29
+ Combobox: {...parts.Combobox, events: {onChange: [{key: "value", port: {kind: "STRING"}, description: "The value picked."}]}, bindKinds: {bind: {kind: "STRING"}}},
30
+ DatePicker: {...parts.DatePicker, events: {onChange: [{key: "value", port: {kind: "STRING"}, description: "The date picked, as an ISO date (YYYY-MM-DD)."}]}, bindKinds: {bind: {kind: "STRING"}}},
31
31
  CarouselItem: parts.CarouselItem,
32
32
  Chart: parts.Chart,
33
- Collapsible: {...parts.Collapsible, events: {onChange: [{key: "value", kind: "BOOL", description: "Whether it is open now."}]}},
33
+ Collapsible: {...parts.Collapsible, events: {onChange: [{key: "value", port: {kind: "BOOL"}, description: "Whether it is open now."}]}},
34
34
  CollapsibleContent: parts.CollapsibleContent,
35
35
  CollapsibleTrigger: parts.CollapsibleTrigger,
36
- ContextMenu: {...parts.ContextMenu, events: {onOpenChange: [{key: "value", kind: "BOOL", description: "Whether it is open now."}]}},
37
- ContextMenuCheckboxItem: {...parts.ContextMenuCheckboxItem, events: {onChange: [{key: "value", kind: "BOOL", description: "The new checked state."}]}, bindKinds: {bind: "BOOL"}},
36
+ ContextMenu: {...parts.ContextMenu, events: {onOpenChange: [{key: "value", port: {kind: "BOOL"}, description: "Whether it is open now."}]}},
37
+ ContextMenuCheckboxItem: {...parts.ContextMenuCheckboxItem, events: {onChange: [{key: "value", port: {kind: "BOOL"}, description: "The new checked state."}]}, bindKinds: {bind: {kind: "BOOL"}}},
38
38
  ContextMenuContent: parts.ContextMenuContent,
39
39
  ContextMenuItem: parts.ContextMenuItem,
40
40
  ContextMenuLabel: parts.ContextMenuLabel,
41
41
  ContextMenuSeparator: parts.ContextMenuSeparator,
42
42
  ContextMenuTrigger: parts.ContextMenuTrigger,
43
- Drawer: {...parts.Drawer, events: {onOpenChange: [{key: "value", kind: "BOOL", description: "Whether it is open now."}]}},
43
+ Drawer: {...parts.Drawer, events: {onOpenChange: [{key: "value", port: {kind: "BOOL"}, description: "Whether it is open now."}]}},
44
44
  DrawerContent: parts.DrawerContent,
45
45
  DrawerDescription: parts.DrawerDescription,
46
46
  DrawerFooter: parts.DrawerFooter,
47
47
  DrawerHeader: parts.DrawerHeader,
48
48
  DrawerTitle: parts.DrawerTitle,
49
49
  DrawerTrigger: parts.DrawerTrigger,
50
- DropdownMenu: {...parts.DropdownMenu, events: {onOpenChange: [{key: "value", kind: "BOOL", description: "Whether it is open now."}]}},
51
- DropdownMenuCheckboxItem: {...parts.DropdownMenuCheckboxItem, events: {onChange: [{key: "value", kind: "BOOL", description: "The new checked state."}]}, bindKinds: {bind: "BOOL"}},
50
+ DropdownMenu: {...parts.DropdownMenu, events: {onOpenChange: [{key: "value", port: {kind: "BOOL"}, description: "Whether it is open now."}]}},
51
+ DropdownMenuCheckboxItem: {...parts.DropdownMenuCheckboxItem, events: {onChange: [{key: "value", port: {kind: "BOOL"}, description: "The new checked state."}]}, bindKinds: {bind: {kind: "BOOL"}}},
52
52
  DropdownMenuContent: parts.DropdownMenuContent,
53
53
  DropdownMenuItem: parts.DropdownMenuItem,
54
54
  DropdownMenuLabel: parts.DropdownMenuLabel,
55
55
  DropdownMenuSeparator: parts.DropdownMenuSeparator,
56
56
  DropdownMenuTrigger: parts.DropdownMenuTrigger,
57
- HoverCard: {...parts.HoverCard, events: {onOpenChange: [{key: "value", kind: "BOOL", description: "Whether it is open now."}]}},
57
+ HoverCard: {...parts.HoverCard, events: {onOpenChange: [{key: "value", port: {kind: "BOOL"}, description: "Whether it is open now."}]}},
58
58
  HoverCardContent: parts.HoverCardContent,
59
59
  HoverCardTrigger: parts.HoverCardTrigger,
60
60
  InputGroup: parts.InputGroup,
61
61
  InputGroupAddon: parts.InputGroupAddon,
62
- InputOTP: {...parts.InputOTP, events: {onComplete: [{key: "value", kind: "STRING", description: "The code entered."}]}, bindKinds: {bind: "STRING"}},
62
+ InputOTP: {...parts.InputOTP, events: {onComplete: [{key: "value", port: {kind: "STRING"}, description: "The code entered."}]}, bindKinds: {bind: {kind: "STRING"}}},
63
63
  Item: parts.Item,
64
64
  ItemGroup: parts.ItemGroup,
65
65
  Kbd: parts.Kbd,
@@ -73,7 +73,7 @@ export const shadcnCatalog = defineBlokCatalog({
73
73
  Resizable: parts.Resizable,
74
74
  ResizableHandle: parts.ResizableHandle,
75
75
  ResizablePanel: parts.ResizablePanel,
76
- Sheet: {...parts.Sheet, events: {onOpenChange: [{key: "value", kind: "BOOL", description: "Whether it is open now."}]}},
76
+ Sheet: {...parts.Sheet, events: {onOpenChange: [{key: "value", port: {kind: "BOOL"}, description: "Whether it is open now."}]}},
77
77
  SheetContent: parts.SheetContent,
78
78
  SheetDescription: parts.SheetDescription,
79
79
  SheetFooter: parts.SheetFooter,
@@ -8,7 +8,7 @@ export const structureCatalog = defineBlokCatalog({
8
8
  description: "Pick, show and view structures, typed by `\"@package/key\"`.",
9
9
  components: {
10
10
  StructureDisplay: parts.StructureDisplay,
11
- StructurePicker: {...parts.StructurePicker, events: {onChange: [{key: "value", kind: "DICT", description: "The structure reference picked, or null when cleared."}]}, bindKinds: {bind: "ANY"}},
11
+ StructurePicker: {...parts.StructurePicker, events: {onChange: [{key: "value", port: {kind: "STRUCTURE", identifier: "*", nullable: true}, description: "The structure reference picked, or null when cleared."}]}, bindKinds: {bind: {kind: "STRUCTURE", identifier: "*"}}},
12
12
  StructureViewer: parts.StructureViewer,
13
13
  },
14
14
  });
@@ -1,5 +1,7 @@
1
1
  import {BASE_CATALOG_REF, defineBlokCatalog} from '../renderer/runtime/catalog';
2
+ import * as z from 'zod';
2
3
  import {parts} from './parts';
4
+ import {openValuesSchema} from './props';
3
5
 
4
6
  /** The `ui` family of the base catalog. */
5
7
  export const uiCatalog = defineBlokCatalog({
@@ -7,7 +9,7 @@ export const uiCatalog = defineBlokCatalog({
7
9
  partOf: BASE_CATALOG_REF,
8
10
  description: "Standard HTML components: layout, text, feedback, forms, data and overlays (shadcn-based).",
9
11
  components: {
10
- Accordion: {...parts.Accordion, events: {onChange: [{key: "value", kind: "ANY", description: "The open/pressed value(s): a string, or a list when multiple."}]}},
12
+ Accordion: {...parts.Accordion, events: {onChange: [{key: "value", port: openValuesSchema, description: "The open/pressed value(s): a string, or a list when multiple."}]}},
11
13
  AccordionContent: parts.AccordionContent,
12
14
  AccordionItem: parts.AccordionItem,
13
15
  AccordionTrigger: {...parts.AccordionTrigger, textProp: "label"},
@@ -20,10 +22,10 @@ export const uiCatalog = defineBlokCatalog({
20
22
  CardFooter: parts.CardFooter,
21
23
  CardHeader: parts.CardHeader,
22
24
  CardTitle: {...parts.CardTitle, textProp: "text"},
23
- Checkbox: {...parts.Checkbox, textProp: "label", events: {onChange: [{key: "value", kind: "BOOL", description: "The new checked state."}]}, bindKinds: {bind: "BOOL"}},
25
+ Checkbox: {...parts.Checkbox, textProp: "label", events: {onChange: [{key: "value", port: {kind: "BOOL"}, description: "The new checked state."}]}, bindKinds: {bind: {kind: "BOOL"}}},
24
26
  Code: {...parts.Code, textProp: "text"},
25
27
  Column: parts.Column,
26
- Dialog: {...parts.Dialog, events: {onOpenChange: [{key: "value", kind: "BOOL", description: "Whether it is open now."}]}},
28
+ Dialog: {...parts.Dialog, events: {onOpenChange: [{key: "value", port: {kind: "BOOL"}, description: "Whether it is open now."}]}},
27
29
  DialogClose: parts.DialogClose,
28
30
  DialogContent: parts.DialogContent,
29
31
  DialogDescription: {...parts.DialogDescription, textProp: "text"},
@@ -39,20 +41,20 @@ export const uiCatalog = defineBlokCatalog({
39
41
  Heading: {...parts.Heading, textProp: "text"},
40
42
  Icon: parts.Icon,
41
43
  Image: parts.Image,
42
- Input: {...parts.Input, events: {action: [{key: "value", kind: "STRING", description: "The text after the edit."}]}, bindKinds: {bind: "STRING"}},
44
+ Input: {...parts.Input, events: {action: [{key: "value", port: {kind: "STRING"}, description: "The text after the edit."}]}, bindKinds: {bind: {kind: "STRING"}}},
43
45
  Label: {...parts.Label, textProp: "text"},
44
46
  Link: {...parts.Link, textProp: "text"},
45
47
  Markdown: {...parts.Markdown, textProp: "content"},
46
- Popover: {...parts.Popover, events: {onOpenChange: [{key: "value", kind: "BOOL", description: "Whether it is open now."}]}},
48
+ Popover: {...parts.Popover, events: {onOpenChange: [{key: "value", port: {kind: "BOOL"}, description: "Whether it is open now."}]}},
47
49
  PopoverContent: parts.PopoverContent,
48
50
  PopoverTrigger: {...parts.PopoverTrigger, textProp: "label"},
49
51
  Progress: parts.Progress,
50
- RadioGroup: {...parts.RadioGroup, events: {onChange: [{key: "value", kind: "STRING", description: "The value now chosen."}]}, bindKinds: {bind: "STRING"}},
52
+ RadioGroup: {...parts.RadioGroup, events: {onChange: [{key: "value", port: {kind: "STRING"}, description: "The value now chosen."}]}, bindKinds: {bind: {kind: "STRING"}}},
51
53
  RadioGroupItem: {...parts.RadioGroupItem, textProp: "label"},
52
54
  Row: parts.Row,
53
55
  List: parts.List,
54
56
  ScrollArea: parts.ScrollArea,
55
- Select: {...parts.Select, events: {onChange: [{key: "value", kind: "STRING", description: "The value now chosen."}]}, bindKinds: {bind: "STRING"}},
57
+ Select: {...parts.Select, events: {onChange: [{key: "value", port: {kind: "STRING"}, description: "The value now chosen."}]}, bindKinds: {bind: {kind: "STRING"}}},
56
58
  SelectContent: parts.SelectContent,
57
59
  SelectGroup: parts.SelectGroup,
58
60
  SelectItem: {...parts.SelectItem, textProp: "label"},
@@ -60,10 +62,10 @@ export const uiCatalog = defineBlokCatalog({
60
62
  SelectTrigger: parts.SelectTrigger,
61
63
  Separator: parts.Separator,
62
64
  Skeleton: parts.Skeleton,
63
- Slider: {...parts.Slider, events: {onChange: [{key: "value", kind: "FLOAT", description: "The value."}], onCommit: [{key: "value", kind: "FLOAT", description: "Where the drag ended."}]}, bindKinds: {bind: "FLOAT"}},
65
+ Slider: {...parts.Slider, events: {onChange: [{key: "value", port: {kind: "FLOAT"}, description: "The value."}], onCommit: [{key: "value", port: {kind: "FLOAT"}, description: "Where the drag ended."}]}, bindKinds: {bind: {kind: "FLOAT"}}},
64
66
  Spacer: parts.Spacer,
65
67
  Spinner: parts.Spinner,
66
- Switch: {...parts.Switch, textProp: "label", events: {onChange: [{key: "value", kind: "BOOL", description: "The new checked state."}]}, bindKinds: {bind: "BOOL"}},
68
+ Switch: {...parts.Switch, textProp: "label", events: {onChange: [{key: "value", port: {kind: "BOOL"}, description: "The new checked state."}]}, bindKinds: {bind: {kind: "BOOL"}}},
67
69
  Table: parts.Table,
68
70
  TableBody: parts.TableBody,
69
71
  TableCell: {...parts.TableCell, textProp: "text"},
@@ -71,18 +73,18 @@ export const uiCatalog = defineBlokCatalog({
71
73
  TableHead: {...parts.TableHead, textProp: "text"},
72
74
  TableHeader: parts.TableHeader,
73
75
  TableRow: parts.TableRow,
74
- Tabs: {...parts.Tabs, events: {onChange: [{key: "value", kind: "STRING", description: "The value now chosen."}]}},
76
+ Tabs: {...parts.Tabs, events: {onChange: [{key: "value", port: {kind: "STRING"}, description: "The value now chosen."}]}},
75
77
  TabsContent: parts.TabsContent,
76
78
  TabsList: parts.TabsList,
77
79
  TabsTrigger: {...parts.TabsTrigger, textProp: "label"},
78
80
  Text: {...parts.Text, textProp: "text"},
79
- Textarea: {...parts.Textarea, events: {onChange: [{key: "value", kind: "STRING", description: "The text after the edit."}]}, bindKinds: {bind: "STRING"}},
81
+ Textarea: {...parts.Textarea, events: {onChange: [{key: "value", port: {kind: "STRING"}, description: "The text after the edit."}]}, bindKinds: {bind: {kind: "STRING"}}},
80
82
  Time: parts.Time,
81
83
  Toast: parts.Toast,
82
- Toggle: {...parts.Toggle, textProp: "label", events: {onChange: [{key: "value", kind: "BOOL", description: "The new checked state."}]}, bindKinds: {bind: "BOOL"}},
83
- ToggleGroup: {...parts.ToggleGroup, events: {onChange: [{key: "value", kind: "ANY", description: "The open/pressed value(s): a string, or a list when multiple."}]}, bindKinds: {bind: "ANY"}},
84
+ Toggle: {...parts.Toggle, textProp: "label", events: {onChange: [{key: "value", port: {kind: "BOOL"}, description: "The new checked state."}]}, bindKinds: {bind: {kind: "BOOL"}}},
85
+ ToggleGroup: {...parts.ToggleGroup, events: {onChange: [{key: "value", port: openValuesSchema, description: "The open/pressed value(s): a string, or a list when multiple."}]}, bindKinds: {bind: z.union([z.string(), z.array(z.string())])}},
84
86
  ToggleGroupItem: {...parts.ToggleGroupItem, textProp: "label"},
85
- Tooltip: {...parts.Tooltip, events: {onOpenChange: [{key: "value", kind: "BOOL", description: "Whether it is open now."}]}},
87
+ Tooltip: {...parts.Tooltip, events: {onOpenChange: [{key: "value", port: {kind: "BOOL"}, description: "Whether it is open now."}]}},
86
88
  TooltipContent: parts.TooltipContent,
87
89
  TooltipTrigger: {...parts.TooltipTrigger, textProp: "label"},
88
90
  cancelled: {...parts.cancelled, textProp: "text"},
@@ -0,0 +1,96 @@
1
+ import {describe, expect, it} from 'vitest';
2
+ import * as z from 'zod';
3
+ import {portToZod} from '../ports/engine/utils';
4
+ import {blokPropPort} from '../renderer/runtime/describe';
5
+ import {markStructureSchema, markTextSchema} from '../renderer/runtime/schemas';
6
+ import {fits} from '../spec/fit';
7
+ import {hasOpenNode, portJson, TEXT_PORT, type SpecPort} from '../spec/ports';
8
+ import {baseFamilies} from './index';
9
+ import {zodToPort} from './zodToPort';
10
+
11
+ const port = (schema: z.ZodTypeAny): Record<string, unknown> | null => portJson(zodToPort(schema, 'test'));
12
+
13
+ describe('zodToPort', () => {
14
+ it('reads scalars, choices and dates', () => {
15
+ expect(port(z.string())).toEqual({kind: 'STRING'});
16
+ expect(port(z.number())).toEqual({kind: 'FLOAT'});
17
+ expect(port(z.number().int())).toEqual({kind: 'INT'});
18
+ expect(port(z.int())).toEqual({kind: 'INT'});
19
+ expect(port(z.boolean().optional())).toEqual({kind: 'BOOL'});
20
+ expect(port(z.string().nullable())).toEqual({kind: 'STRING', nullable: true});
21
+ expect(port(z.enum(['a', 'b']))).toEqual({kind: 'STRING', choices: [{value: 'a'}, {value: 'b'}]});
22
+ expect(port(z.literal(3))).toEqual({kind: 'INT', choices: [{value: 3}]});
23
+ expect(port(z.iso.date())).toEqual({kind: 'DATE'});
24
+ });
25
+
26
+ it('reads containers', () => {
27
+ expect(port(z.array(z.number()))).toEqual({kind: 'LIST', children: [{key: '...', kind: 'FLOAT'}]});
28
+ expect(port(z.record(z.string(), z.boolean()))).toEqual({kind: 'DICT', children: [{key: '...', kind: 'BOOL'}]});
29
+ expect(port(z.object({a: z.string().describe('A.'), b: z.number().optional()}))).toEqual({
30
+ kind: 'MODEL',
31
+ children: [
32
+ {key: 'a', kind: 'STRING', description: 'A.'},
33
+ {key: 'b', kind: 'FLOAT', nullable: true},
34
+ ],
35
+ });
36
+ expect(port(z.tuple([z.string(), z.number()]))).toEqual({
37
+ kind: 'LIST',
38
+ children: [{key: '...', kind: 'UNION', children: [{key: '0', kind: 'STRING'}, {key: '1', kind: 'FLOAT'}]}],
39
+ });
40
+ });
41
+
42
+ it('flattens unions, merges literals and collapses one variant', () => {
43
+ expect(port(z.union([z.string(), z.union([z.number(), z.string()])]))).toEqual({
44
+ kind: 'UNION',
45
+ children: [{key: '0', kind: 'STRING'}, {key: '1', kind: 'FLOAT'}],
46
+ });
47
+ expect(port(z.union([z.literal('a'), z.literal('b')]))).toEqual({kind: 'STRING', choices: [{value: 'a'}, {value: 'b'}]});
48
+ expect(port(z.union([z.string(), z.string()]))).toEqual({kind: 'STRING'});
49
+ expect(port(z.union([z.string(), z.null()]))).toEqual({kind: 'STRING', nullable: true});
50
+ });
51
+
52
+ it('takes a mark before the shape', () => {
53
+ expect(port(markTextSchema(z.string().transform(String)).optional().describe('x'))).toEqual(portJson(TEXT_PORT));
54
+ expect(port(markStructureSchema(z.object({object: z.string()}), '*').nullish())).toEqual({kind: 'STRUCTURE', identifier: '*', nullable: true});
55
+ });
56
+
57
+ it('throws on a shape no port says, naming where', () => {
58
+ expect(() => zodToPort(z.unknown(), '<X> y')).toThrow(/<X> y/);
59
+ expect(() => zodToPort(z.object({a: z.any()}), '<X> y')).toThrow(/<X> y\.a/);
60
+ expect(() => zodToPort(z.custom(() => true), 'z')).toThrow();
61
+ });
62
+
63
+ it('round-trips the ports a form builds (list and dict forms wrap their items: not here)', () => {
64
+ const cases: SpecPort[] = [
65
+ {kind: 'STRING'},
66
+ {kind: 'BOOL', nullable: true},
67
+ {kind: 'INT'},
68
+ {kind: 'FLOAT'},
69
+ {kind: 'MODEL', children: [{key: 'a', kind: 'STRING'}, {key: 'b', kind: 'INT'}]},
70
+ ];
71
+ for (const original of cases) {
72
+ const back = zodToPort(portToZod({key: 'x', ...original} as never), 'round trip');
73
+ expect(fits(back, original).status, JSON.stringify(original)).toBe('ok');
74
+ expect(fits(original, back).status, JSON.stringify(original)).toBe('ok');
75
+ }
76
+ });
77
+ });
78
+
79
+ describe('the families of the base catalog', () => {
80
+ it('type every prop, with no open node anywhere', () => {
81
+ const problems: string[] = [];
82
+ for (const family of baseFamilies) {
83
+ for (const [name, component] of Object.entries(family.components)) {
84
+ for (const [key, schema] of Object.entries(component.schema.shape as Record<string, z.ZodTypeAny>)) {
85
+ if (key === 'children') continue;
86
+ try {
87
+ if (hasOpenNode(blokPropPort(name, key, schema, component))) problems.push(`<${name}> ${key}: open`);
88
+ } catch (error) {
89
+ problems.push((error as Error).message);
90
+ }
91
+ }
92
+ }
93
+ }
94
+ expect(problems).toEqual([]);
95
+ });
96
+ });
@@ -0,0 +1,177 @@
1
+ import type * as z from 'zod';
2
+ import {markedPort} from '../renderer/runtime/schemas';
3
+ import {checkShape, ITEM_KEY, portJson, type SpecChildPort, type SpecPort} from '../spec/ports';
4
+
5
+ /**
6
+ * The port a zod schema publishes as a catalog prop (arkitekt-spec's
7
+ * `CatalogPort`). A marked schema (`markPortSchema`, `markTextSchema`,
8
+ * `markStructureSchema`) is its mark; any other is read by its shape. A shape
9
+ * no port says (`unknown`, `any`, `custom`, ...) throws, naming `where`: every
10
+ * drawn prop is typed.
11
+ */
12
+
13
+ type ZodDef = {
14
+ type?: string;
15
+ format?: string;
16
+ innerType?: z.ZodTypeAny;
17
+ in?: z.ZodTypeAny;
18
+ out?: z.ZodTypeAny;
19
+ options?: z.ZodTypeAny[];
20
+ values?: unknown[];
21
+ entries?: Record<string, unknown>;
22
+ element?: z.ZodTypeAny;
23
+ valueType?: z.ZodTypeAny;
24
+ items?: z.ZodTypeAny[];
25
+ rest?: z.ZodTypeAny | null;
26
+ shape?: Record<string, z.ZodTypeAny>;
27
+ catchall?: z.ZodTypeAny;
28
+ getter?: () => z.ZodTypeAny;
29
+ };
30
+
31
+ const defOf = (schema: z.ZodTypeAny): ZodDef => (schema as unknown as {def?: ZodDef}).def ?? {};
32
+ const formatOf = (schema: z.ZodTypeAny): string | undefined =>
33
+ (schema as unknown as {format?: string | null}).format ?? defOf(schema).format ?? undefined;
34
+
35
+ const INT_FORMATS = new Set(['safeint', 'int32', 'uint32', 'int64', 'uint64']);
36
+ const DATE_FORMATS = new Set(['date', 'datetime']);
37
+ const WRAPPERS = new Set(['optional', 'default', 'prefault', 'readonly', 'catch', 'nonoptional']);
38
+
39
+ const describedAs = (schema: z.ZodTypeAny): string | null => (schema as unknown as {description?: string}).description ?? null;
40
+
41
+ /** The port of `schema`; throws, naming `where`, on a shape no port says. */
42
+ export const zodToPort = (schema: z.ZodTypeAny, where: string): SpecPort => {
43
+ let current = schema;
44
+ let nullable = false;
45
+ const lazies = new Set<object>();
46
+ for (let depth = 0; depth < 64; depth += 1) {
47
+ const marked = markedPort(current);
48
+ if (marked) return nullable ? {...marked, nullable: true} : marked;
49
+ const def = defOf(current);
50
+ if (def.type && WRAPPERS.has(def.type) && def.innerType) current = def.innerType;
51
+ else if (def.type === 'nullable' && def.innerType) {
52
+ nullable = true;
53
+ current = def.innerType;
54
+ } else if (def.type === 'pipe' && def.in && def.out) current = defOf(def.in).type === 'transform' ? def.out : def.in;
55
+ else if (def.type === 'lazy' && def.getter) {
56
+ if (lazies.has(current)) throw new Error(`${where}: a recursive schema has no port; mark it (markPortSchema)`);
57
+ lazies.add(current);
58
+ current = def.getter();
59
+ } else break;
60
+ }
61
+ const port = shapePort(current, where);
62
+ return nullable ? {...port, nullable: true} : port;
63
+ };
64
+
65
+ const child = (key: string, port: SpecPort, description?: string | null): SpecChildPort => ({
66
+ key,
67
+ ...port,
68
+ ...(description ? {description} : {}),
69
+ });
70
+
71
+ const scalarKind = (values: readonly unknown[], where: string): string => {
72
+ if (values.every(value => typeof value === 'string')) return 'STRING';
73
+ if (values.every(value => typeof value === 'boolean')) return 'BOOL';
74
+ if (values.every(value => typeof value === 'number')) return values.every(value => Number.isInteger(value)) ? 'INT' : 'FLOAT';
75
+ throw new Error(`${where}: literals of mixed kinds have no port; use a union`);
76
+ };
77
+
78
+ const shapePort = (schema: z.ZodTypeAny, where: string): SpecPort => {
79
+ const def = defOf(schema);
80
+ switch (def.type) {
81
+ case 'string':
82
+ return {kind: DATE_FORMATS.has(formatOf(schema) ?? '') ? 'DATE' : 'STRING'};
83
+ case 'template_literal':
84
+ return {kind: 'STRING'};
85
+ case 'enum': {
86
+ const values = Object.values(def.entries ?? {});
87
+ return {kind: scalarKind(values, where), choices: values.map(value => ({value}))};
88
+ }
89
+ case 'literal': {
90
+ const values = def.values ?? [];
91
+ return {kind: scalarKind(values, where), choices: values.map(value => ({value}))};
92
+ }
93
+ case 'number':
94
+ return {kind: INT_FORMATS.has(formatOf(schema) ?? '') ? 'INT' : 'FLOAT'};
95
+ case 'nan':
96
+ return {kind: 'FLOAT'};
97
+ case 'bigint':
98
+ return {kind: 'INT'};
99
+ case 'boolean':
100
+ return {kind: 'BOOL'};
101
+ case 'date':
102
+ return {kind: 'DATE'};
103
+ case 'array':
104
+ case 'set':
105
+ return {kind: 'LIST', children: [child(ITEM_KEY, zodToPort((def.element ?? def.valueType) as z.ZodTypeAny, `${where}[]`))]};
106
+ case 'tuple': {
107
+ const items = [...(def.items ?? []), ...(def.rest ? [def.rest] : [])];
108
+ return {kind: 'LIST', children: [child(ITEM_KEY, unionOf(items.map((item, index) => zodToPort(item, `${where}[${index}]`)), where))]};
109
+ }
110
+ case 'record':
111
+ case 'map':
112
+ return {kind: 'DICT', children: [child(ITEM_KEY, zodToPort(def.valueType as z.ZodTypeAny, `${where}{}`))]};
113
+ case 'object': {
114
+ const shape = Object.entries(def.shape ?? {});
115
+ if (!shape.length) {
116
+ const catchall = def.catchall && defOf(def.catchall).type !== 'never' ? def.catchall : null;
117
+ if (!catchall) throw new Error(`${where}: an empty object has no port; say what it holds (z.record)`);
118
+ return {kind: 'DICT', children: [child(ITEM_KEY, zodToPort(catchall, `${where}{}`))]};
119
+ }
120
+ return {
121
+ kind: 'MODEL',
122
+ children: shape.map(([key, field]) => {
123
+ const port = zodToPort(field, `${where}.${key}`);
124
+ return child(key, field.safeParse(undefined).success ? {...port, nullable: true} : port, describedAs(field));
125
+ }),
126
+ };
127
+ }
128
+ case 'union': {
129
+ const isNull = (option: z.ZodTypeAny) => ['null', 'undefined'].includes(defOf(option).type ?? '');
130
+ const options = def.options ?? [];
131
+ const port = unionOf(options.filter(option => !isNull(option)).map((option, index) => zodToPort(option, `${where}|${index}`)), where);
132
+ return options.some(isNull) ? {...port, nullable: true} : port;
133
+ }
134
+ case 'null':
135
+ case 'undefined':
136
+ throw new Error(`${where}: null alone has no port; make a typed schema nullable`);
137
+ default:
138
+ throw new Error(`${where}: a ${def.type ?? 'schema'} has no port; type it (or mark it: markPortSchema)`);
139
+ }
140
+ };
141
+
142
+ const LEAF_CHOICES = new Set(['STRING', 'INT', 'FLOAT', 'BOOL']);
143
+
144
+ /** Variants as one port: nested unions flattened, the same variant once, literals of one kind merged; one variant is itself. */
145
+ export const unionOf = (variants: readonly SpecPort[], where: string): SpecPort => {
146
+ const flat: SpecPort[] = [];
147
+ for (const variant of variants) {
148
+ if (variant.kind === 'UNION') flat.push(...(variant.children ?? []).map(({key: _key, description: _description, ...port}) => port));
149
+ else flat.push(variant);
150
+ }
151
+ const merged: SpecPort[] = [];
152
+ for (const variant of flat) {
153
+ const same = merged.findIndex(other => other.kind === variant.kind && LEAF_CHOICES.has(variant.kind ?? '') && other.choices && variant.choices);
154
+ if (same >= 0 && variant.choices) {
155
+ const other = merged[same];
156
+ const values = new Set((other.choices ?? []).map(choice => choice.value));
157
+ merged[same] = {...other, choices: [...(other.choices ?? []), ...variant.choices.filter(choice => !values.has(choice.value))]};
158
+ } else merged.push(variant);
159
+ }
160
+ const seen = new Set<string>();
161
+ const unique = merged.filter(variant => {
162
+ const text = JSON.stringify(portJson(variant));
163
+ if (seen.has(text)) return false;
164
+ seen.add(text);
165
+ return true;
166
+ });
167
+ // A plain variant takes every literal of its kind: the literals add nothing.
168
+ const kept = unique.filter(variant => !(variant.choices && unique.some(other => other !== variant && other.kind === variant.kind && !other.choices)));
169
+ if (kept.length === 1) return kept[0];
170
+ const port: SpecPort = {kind: 'UNION', children: kept.map((variant, index) => child(String(index), variant))};
171
+ checkShape(port, where);
172
+ return port;
173
+ };
174
+
175
+ /** A hand-written port or a zod schema, as a port. */
176
+ export const asPort = (value: SpecPort | z.ZodTypeAny, where: string): SpecPort =>
177
+ typeof value === 'object' && value !== null && '_zod' in value ? zodToPort(value as z.ZodTypeAny, where) : (value as SpecPort);
package/src/catalogs.ts CHANGED
@@ -9,5 +9,8 @@ export {
9
9
  type BlokCatalogContract,
10
10
  type BlokComponentContracts,
11
11
  } from './renderer/runtime/catalog';
12
- export type {BlokComponentContract} from './renderer/runtime/components';
12
+ export type {BlokComponentContract, BlokEventField} from './renderer/runtime/components';
13
+ export {markPortSchema, markStructureSchema, markTextSchema} from './renderer/runtime/schemas';
14
+ export {asPort, zodToPort} from './catalogs/zodToPort';
15
+ export {portJson, portSummary, TEXT_PORT, type SpecChildPort, type SpecPort} from './spec/ports';
13
16
  export {describeBlokContract, specJsonText, type SpecCatalogJson} from './renderer/runtime/describe';
package/src/index.ts CHANGED
@@ -3,4 +3,6 @@ export * from './bsx';
3
3
  export * from './spec/vocabulary';
4
4
  export * from './spec/catalogs';
5
5
  export * from './spec/locals';
6
+ export * from './spec/ports';
7
+ export * from './spec/fit';
6
8
  export type * from './renderer/runtime/types';
@@ -48,7 +48,13 @@ export type OptionKey = (typeof OptionKey)[keyof typeof OptionKey];
48
48
 
49
49
  /** The kind of a port: its structural type. Decides which of children, identifier and choices the port must, may or must not carry (see docs/design/ports.md). */
50
50
  export const PortKind = {
51
+ /** Catalog only: a file an app registered. */
52
+ Asset: 'ASSET',
53
+ /** Catalog only: the local a control writes; its one child is the value. */
54
+ Binding: 'BINDING',
51
55
  Bool: 'BOOL',
56
+ /** Catalog only: a callback; its children are the payload. */
57
+ Callback: 'CALLBACK',
52
58
  Date: 'DATE',
53
59
  Dict: 'DICT',
54
60
  Enum: 'ENUM',