@arkitektio/bsx 6.8.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 (155) hide show
  1. package/dist/bsx/declared.d.ts +25 -0
  2. package/dist/bsx/declared.d.ts.map +1 -1
  3. package/dist/bsx/declared.js +59 -0
  4. package/dist/bsx/declared.js.map +1 -1
  5. package/dist/bsx/infer.d.ts.map +1 -1
  6. package/dist/bsx/infer.js +4 -2
  7. package/dist/bsx/infer.js.map +1 -1
  8. package/dist/bsx/language.d.ts.map +1 -1
  9. package/dist/bsx/language.js +17 -12
  10. package/dist/bsx/language.js.map +1 -1
  11. package/dist/bsx/references.d.ts.map +1 -1
  12. package/dist/bsx/references.js +139 -37
  13. package/dist/bsx/references.js.map +1 -1
  14. package/dist/catalogs/index.d.ts +191 -98
  15. package/dist/catalogs/index.d.ts.map +1 -1
  16. package/dist/catalogs/parts/data.d.ts +2 -2
  17. package/dist/catalogs/parts/data.d.ts.map +1 -1
  18. package/dist/catalogs/parts/data.js +2 -3
  19. package/dist/catalogs/parts/data.js.map +1 -1
  20. package/dist/catalogs/parts/feedback.d.ts +6 -6
  21. package/dist/catalogs/parts/forms.d.ts +8 -8
  22. package/dist/catalogs/parts/icons.d.ts +4 -4
  23. package/dist/catalogs/parts/index.d.ts +48 -48
  24. package/dist/catalogs/parts/navigation.d.ts +8 -8
  25. package/dist/catalogs/parts/overlays.d.ts +22 -22
  26. package/dist/catalogs/parts/run.d.ts.map +1 -1
  27. package/dist/catalogs/parts/run.js +4 -5
  28. package/dist/catalogs/parts/run.js.map +1 -1
  29. package/dist/catalogs/parts/scene.d.ts.map +1 -1
  30. package/dist/catalogs/parts/scene.js +7 -14
  31. package/dist/catalogs/parts/scene.js.map +1 -1
  32. package/dist/catalogs/parts/structure.d.ts.map +1 -1
  33. package/dist/catalogs/parts/structure.js +2 -3
  34. package/dist/catalogs/parts/structure.js.map +1 -1
  35. package/dist/catalogs/parts/toast.d.ts.map +1 -1
  36. package/dist/catalogs/parts/toast.js +2 -1
  37. package/dist/catalogs/parts/toast.js.map +1 -1
  38. package/dist/catalogs/props.d.ts +23 -0
  39. package/dist/catalogs/props.d.ts.map +1 -1
  40. package/dist/catalogs/props.js +56 -4
  41. package/dist/catalogs/props.js.map +1 -1
  42. package/dist/catalogs/scene.d.ts +134 -127
  43. package/dist/catalogs/scene.d.ts.map +1 -1
  44. package/dist/catalogs/scene.js +5 -3
  45. package/dist/catalogs/scene.js.map +1 -1
  46. package/dist/catalogs/shadcn.d.ts +79 -41
  47. package/dist/catalogs/shadcn.d.ts.map +1 -1
  48. package/dist/catalogs/shadcn.js +13 -13
  49. package/dist/catalogs/shadcn.js.map +1 -1
  50. package/dist/catalogs/structure.d.ts +9 -2
  51. package/dist/catalogs/structure.d.ts.map +1 -1
  52. package/dist/catalogs/structure.js +1 -1
  53. package/dist/catalogs/structure.js.map +1 -1
  54. package/dist/catalogs/ui.d.ts +935 -892
  55. package/dist/catalogs/ui.d.ts.map +1 -1
  56. package/dist/catalogs/ui.js +16 -14
  57. package/dist/catalogs/ui.js.map +1 -1
  58. package/dist/catalogs/zodToPort.d.ts +9 -0
  59. package/dist/catalogs/zodToPort.d.ts.map +1 -0
  60. package/dist/catalogs/zodToPort.js +156 -0
  61. package/dist/catalogs/zodToPort.js.map +1 -0
  62. package/dist/catalogs.d.ts +4 -1
  63. package/dist/catalogs.d.ts.map +1 -1
  64. package/dist/catalogs.js +3 -0
  65. package/dist/catalogs.js.map +1 -1
  66. package/dist/index.d.ts +2 -0
  67. package/dist/index.d.ts.map +1 -1
  68. package/dist/index.js +2 -0
  69. package/dist/index.js.map +1 -1
  70. package/dist/ports/rekuest.d.ts +6 -0
  71. package/dist/ports/rekuest.d.ts.map +1 -1
  72. package/dist/ports/rekuest.js +6 -0
  73. package/dist/ports/rekuest.js.map +1 -1
  74. package/dist/renderer/bloks/control.d.ts +7 -1
  75. package/dist/renderer/bloks/control.d.ts.map +1 -1
  76. package/dist/renderer/bloks/control.js +20 -2
  77. package/dist/renderer/bloks/control.js.map +1 -1
  78. package/dist/renderer/bloks/data.d.ts +2 -2
  79. package/dist/renderer/bloks/feedback.d.ts +6 -6
  80. package/dist/renderer/bloks/forms.d.ts +8 -8
  81. package/dist/renderer/bloks/icons.d.ts +2 -2
  82. package/dist/renderer/bloks/index.d.ts +48 -48
  83. package/dist/renderer/bloks/navigation.d.ts +8 -8
  84. package/dist/renderer/bloks/overlays.d.ts +22 -22
  85. package/dist/renderer/runtime/components.d.ts +6 -8
  86. package/dist/renderer/runtime/components.d.ts.map +1 -1
  87. package/dist/renderer/runtime/components.js.map +1 -1
  88. package/dist/renderer/runtime/describe.d.ts +5 -12
  89. package/dist/renderer/runtime/describe.d.ts.map +1 -1
  90. package/dist/renderer/runtime/describe.js +25 -89
  91. package/dist/renderer/runtime/describe.js.map +1 -1
  92. package/dist/renderer/runtime/hooks.d.ts.map +1 -1
  93. package/dist/renderer/runtime/hooks.js +3 -1
  94. package/dist/renderer/runtime/hooks.js.map +1 -1
  95. package/dist/renderer/runtime/schemas.d.ts +8 -6
  96. package/dist/renderer/runtime/schemas.d.ts.map +1 -1
  97. package/dist/renderer/runtime/schemas.js +40 -16
  98. package/dist/renderer/runtime/schemas.js.map +1 -1
  99. package/dist/shadcn.d.ts +48 -48
  100. package/dist/spec/bsx_v2.json +1421 -19
  101. package/dist/spec/catalogs/base@4.json +18738 -5273
  102. package/dist/spec/catalogs/base@4.json.js +18738 -5273
  103. package/dist/spec/catalogs/orkestrator@1.json +532 -126
  104. package/dist/spec/catalogs/orkestrator@1.json.js +532 -126
  105. package/dist/spec/catalogs.d.ts +3 -11
  106. package/dist/spec/catalogs.d.ts.map +1 -1
  107. package/dist/spec/catalogs.js +13 -11
  108. package/dist/spec/catalogs.js.map +1 -1
  109. package/dist/spec/fit.d.ts +21 -0
  110. package/dist/spec/fit.d.ts.map +1 -0
  111. package/dist/spec/fit.js +114 -0
  112. package/dist/spec/fit.js.map +1 -0
  113. package/dist/spec/ports.d.ts +56 -0
  114. package/dist/spec/ports.d.ts.map +1 -0
  115. package/dist/spec/ports.js +174 -0
  116. package/dist/spec/ports.js.map +1 -0
  117. package/dist/spec/vocabulary.json +12 -5
  118. package/dist/spec/vocabulary.json.js +12 -5
  119. package/package.json +1 -1
  120. package/src/bsx/declared.ts +60 -0
  121. package/src/bsx/infer.test.ts +1 -1
  122. package/src/bsx/infer.ts +4 -2
  123. package/src/bsx/language.ts +16 -11
  124. package/src/bsx/logo.test.ts +47 -0
  125. package/src/bsx/references.ts +170 -39
  126. package/src/catalogs/parts/data.ts +3 -2
  127. package/src/catalogs/parts/run.ts +9 -7
  128. package/src/catalogs/parts/scene.ts +7 -14
  129. package/src/catalogs/parts/structure.ts +2 -3
  130. package/src/catalogs/parts/toast.ts +5 -1
  131. package/src/catalogs/props.ts +64 -4
  132. package/src/catalogs/scene.ts +5 -3
  133. package/src/catalogs/shadcn.ts +13 -13
  134. package/src/catalogs/structure.ts +1 -1
  135. package/src/catalogs/ui.ts +16 -14
  136. package/src/catalogs/zodToPort.test.ts +96 -0
  137. package/src/catalogs/zodToPort.ts +177 -0
  138. package/src/catalogs.ts +4 -1
  139. package/src/index.ts +2 -0
  140. package/src/ports/rekuest.ts +6 -0
  141. package/src/renderer/bloks/control.tsx +26 -2
  142. package/src/renderer/runtime/catalog.test.ts +12 -8
  143. package/src/renderer/runtime/components.tsx +5 -8
  144. package/src/renderer/runtime/describe.ts +25 -100
  145. package/src/renderer/runtime/hooks.ts +3 -1
  146. package/src/renderer/runtime/schemas.ts +51 -17
  147. package/src/spec/bsx_v2.json +1421 -19
  148. package/src/spec/catalogs/base@4.json +18738 -5273
  149. package/src/spec/catalogs/orkestrator@1.json +532 -126
  150. package/src/spec/catalogs.ts +14 -19
  151. package/src/spec/fit.test.ts +65 -0
  152. package/src/spec/fit.ts +114 -0
  153. package/src/spec/ports.ts +172 -0
  154. package/src/spec/spec.test.ts +5 -2
  155. package/src/spec/vocabulary.json +12 -5
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "vocab": 2,
3
- "minor": 7,
3
+ "minor": 9,
4
4
  "description": "The blok language, version 2: what a blok may read, call and store. The spec's parser, the server (rekuest_core, takt) and the renderer (orkestrator) load this file or are generated from it. The design is the blok-vocab-v2 proposal of 2026-10-25. Three layers, each versioned on its own: this language (vocab, and minor for what it gained since); the base catalog, everything every renderer draws; and the app catalogs that extend it with what one frontend draws beyond (see catalogs). A server holds a blok to the language alone, never to a catalog: whoever draws a blok checks it against the catalog it has, and an author's tooling checks it when asked.",
5
5
  "roots": {
6
6
  "data": {
@@ -99,6 +99,7 @@
99
99
  "query": "<query name=\"x\" service=\"mikro\" document=\"query (...) {...}\" poll={5} more=\"items\"><var key=\"k\" value={...} /></query>: a declared read, queries.<name>. A child of <Blok>, before its content.",
100
100
  "subscription": "<subscription name=\"x\" service=\"mikro\" document=\"subscription (...) {...}\" keep={10} history=\"q\"><var key=\"k\" value={...} /></subscription>: a declared stream, subscriptions.<name>. A child of <Blok>, before its content.",
101
101
  "dependencies": "<dependencies key=\"cells\" like=\"self.<action>\" />: the dependencies of one of the app's own actions, for an agent blok to read, call and hand to a run of it. A custom blok declares those of an action of an agent it is bound to: like=\"agents.<name>.<action>\" (stored deps.<name>.<action>). Each is read through the key, bare: cells.<dependency>.<state>.<field>, cells.<dependency>.<action>(...), cells.<dependency>.connected (stored as the blok's dependency deps.cells__<dependency>). cells.options.<dependency> lists the agents that fit one ({id, name, connected, picked}) and cells.pick(<dependency>: <agent id>) binds it; <deppicker key=\"cells.<dependency>\" /> is the ready-made picker. Which agent each is bound to is the viewer's own choice, kept on their device and never on a server; until they choose it is seeded once, with the agent the latest run of the action had, else the only one that fits. A child of <Blok>, after its locals and before what reads through it; an agent blok only. An action whose dependency is called options or pick cannot be read through one.",
102
+ "logo": "<logo title=\"Microscope\"><Circle cx=\"12\" cy=\"12\" r=\"7\" /></logo>: the blok's own logo, standing for it in lists, pins and tabs. A child of <Blok>, one, in a blok that is no logo. It holds a drawing of the logo catalog on a 24-unit grid (viewBox=\"0 0 24 24\" unless it says otherwise), painted with the logo pens and drawn with the action logos' pen (fill none, stroke ink, round) unless a shape says otherwise. title and viewBox are literals, and so is everything it draws: a fixed drawing that reads nothing. It is checked and drawn as a logo blok of its own.",
102
103
  "var": "<var key=\"k\" value={expression or literal} />: one variable of a query or subscription; an expression over args, blok-level locals and agents."
103
104
  }
104
105
  },
@@ -388,7 +389,7 @@
388
389
  "any": "ANY is a local's kind only (no action port is ever ANY): an untyped value. It is never an error and gets no warning; it skips the bind_kinds and arg_kinds checks and a path below it is taken as written. A renderer treats it as an untyped value.",
389
390
  "kind_inference": ["A given kind (ANY included) is kept; only a left-out kind is inferred, by the first rule that gives one:", "1. the default: a bool BOOL, an integer INT, any other number FLOAT, a string STRING; a non-empty list of one scalar kind LIST of it, a non-empty object of one scalar kind DICT of it (the item port keyed ...); null, [], {} and mixed items tell nothing;", "2. the port of the task argument the local is passed to whole (an argument whose value is exactly the local's path), at the first such call in tree order whose arg port is known and makes a valid local: its kind, identifier, nullable, choices, reference_unit, proposed_units, dimension and children (from a demand's arg match: kind, identifier, nullable and children, every child with a kind);", "3. the bind kind of the first control bound to the local whole, when it is STRING, INT, FLOAT or BOOL (LIST, DICT and ANY controls tell too little);", "4. else ANY.", "A given kind and like= come before rule 1. Only uses inside the local's scope (its parent's subtree) count. Tree order is the walk order: nodes depth first, each node's props in order, a call's arguments in order. Every field the local sets (choices, nullable, widget, identifier, children, description, ...) wins over the inferred type, which only fills what it leaves out; a candidate whose merge is no valid port is skipped. The other call sites and binds are then checked against the kind found (local.arg_kind, local.bind_kind). A left-out kind stays distinguishable from a given ANY until inference ran (no default filled in at deserialization; null is left out)."],
390
391
  "bind": "bind={<local>} or bind={<local>.<field>...}: the control writes the local; nothing else does. The catalog's kind of the bind prop is what the control writes: the local (or the field of it bound) must be a port kind bind_kinds lists for it.",
391
- "bind_kinds": {"description": "Per catalog kind of a bind prop, the port kinds of the locals it may write. A kind not listed (ANY) writes any local.", "STRING": ["STRING", "ENUM", "DATE"], "FLOAT": ["FLOAT", "INT", "QUANTITY"], "INT": ["INT"], "BOOL": ["BOOL"], "LIST": ["LIST"], "DICT": ["DICT", "MODEL"]},
392
+ "bind_kinds": {"description": "Per kind a control writes (the one child of its bind prop's BINDING port), the port kinds of the locals it may write. A kind not listed writes a local of its own kind; an open child writes any local.", "STRING": ["STRING", "ENUM", "DATE"], "FLOAT": ["FLOAT", "INT", "QUANTITY"], "INT": ["INT"], "BOOL": ["BOOL"], "LIST": ["LIST"], "DICT": ["DICT", "MODEL"]},
392
393
  "arg_kinds": {"description": "Per port kind of a local passed whole as a task call's argument, the kinds of the action's arg port that take it, where the action is known (agent self.<action> demands, an action's dependencies). STRUCTURE also needs the same identifier. An ANY local is not checked.", "STRING": ["STRING"], "INT": ["INT", "FLOAT"], "FLOAT": ["FLOAT"], "BOOL": ["BOOL"], "ENUM": ["ENUM", "STRING"], "DATE": ["DATE", "STRING"], "QUANTITY": ["QUANTITY", "FLOAT"], "LIST": ["LIST"], "DICT": ["DICT"], "MODEL": ["MODEL", "DICT"], "STRUCTURE": ["STRUCTURE"]}
393
394
  },
394
395
  "theme": {
@@ -429,7 +430,7 @@
429
430
  "logo_path_data_props": ["d", "points"]
430
431
  },
431
432
  "catalogs": {
432
- "description": "A catalog is a versioned set of components. The base catalog is what every renderer draws, whole, in the contexts it draws (PANEL, SCENE, LOGO): a blok written for it runs everywhere. An app catalog extends another (in the end the base) with what one frontend draws beyond it; it is that frontend's to publish. A catalog is named by the address it is published at (its id); a blok names the one catalog it is written for (catalog), the base when it names none, and may record the minor it needs (catalog_minor). A version only ever gains components and props: each says the minor that added it (since), so a blok valid at v1.2 stays valid. A renderer reports the catalogs and minors it speaks; what it lacks it draws as a placeholder, and reports. A catalog never redefines a component of the one it extends. Nobody's server fetches a catalog: it holds what a frontend registered under the id, and an author's tooling resolves an id from what ships with it, from its cache, or by fetching it.",
433
+ "description": "A catalog is a versioned set of components. The base catalog is what every renderer draws, whole, in the contexts it draws (PANEL, SCENE, LOGO): a blok written for it runs everywhere. An app catalog extends another (in the end the base) with what one frontend draws beyond it; it is that frontend's to publish. A catalog is named by the address it is published at (its id); a blok names the one catalog it is written for (catalog), the base when it names none, and may record the minor it needs (catalog_minor). A version only ever gains components and props: each says the minor that added it (since), so a blok valid at v1.2 stays valid. A renderer reports the catalogs and minors it speaks; what it lacks it draws as a placeholder, and reports. A catalog never redefines a component of the one it extends. Nobody's server fetches a catalog: it holds what a frontend registered under the id, and an author's tooling resolves an id from what ships with it, from its cache, or by fetching it. Every prop, and every argument and result of an operation, is typed by a port: the port of an action's argument (kind, identifier, nullable, choices, children), plus three kinds only a catalog types by -- CALLBACK (its children are the payload, event.<key>), ASSET (a file an app registered) and BINDING (its one child, keyed '...', is what the control writes). A port of no kind is open: only the language's own props and generic operations are.",
433
434
  "base": "https://arkitekt.live/catalogs/base/v4",
434
435
  "bundled": {"https://arkitekt.live/catalogs/base/v4": "catalogs/base@4.json", "https://arkitekt.live/catalogs/orkestrator/v1": "catalogs/orkestrator@1.json"},
435
436
  "id": "^https://[^\\s/]+(/[^\\s/]+)*/v[0-9]+$",
@@ -479,9 +480,9 @@
479
480
  "callback.positional": {"level": "error", "message": "{call}: a task call names its arguments (name: value)."},
480
481
  "callback.with": {"level": "error", "message": "with hands a task call the dependencies the blok declares for that action: `self.<action>(...) with <key>`, in a custom blok `agents.<name>.<action>(...) with <key>`.", "hint": "Write `self.<action>(name: value) with cells into run`, where the blok declares <dependencies key=\"cells\" like=\"self.<action>\" />."},
481
482
  "callback.into": {"level": "error", "message": "into names the record of a task call: `<call> into <name>`.", "hint": "Write `deps.<key>.<action>(name: value) into run`, then read run.running, run.returns.<port>."},
482
- "callback.not_callback": {"level": "error", "message": "{key} of <{component}> is not a callback prop, so it cannot hold {what}.", "hint": "Use a callback prop of <{component}> (the catalog lists them as CALLBACK), or compute {key} without a call."},
483
+ "callback.not_callback": {"level": "error", "message": "{key} of <{component}> is not a callback prop, so it cannot hold {what}.", "hint": "Use a callback prop of <{component}> (the catalog types them CALLBACK), or compute {key} without a call."},
483
484
  "callback.unbound": {"level": "error", "message": "{key} of <{component}> is a callback prop: it holds one task call or one effect (queries.<name>.refetch(), queries.<name>.fetch_more(...), ui.copy, task.answer, assign.start, port.set).", "hint": "Give {key} a task call (deps.<key>.<action>(name: value)) or one effect, not a value."},
484
- "callback.event_field": {"level": "error", "message": "event has no field {field!r} in {key} of <{component}> (its fields: {fields}).", "hint": "Read one of the fields listed for {key}: {fields}."},
485
+ "callback.event_field": {"level": "error", "message": "event has no field {field!r} in {key} of <{component}> (its fields: {fields}).", "hint": "Read one of the fields its CALLBACK port lists for {key}: {fields}."},
485
486
  "roots.unknown": {"level": "error", "message": "{path} reads {root!r}, which is no root, local, loop variable or record of this blok.", "hint": "Read a root this blok has (deps.<key>, args.<key>, queries.<name>, ...), a declared local, a foreach let or index, or an into record."},
486
487
  "roots.not_in_kind": {"level": "error", "message": "{path}: a{n} {kind} blok has no {root!r} (it reads {roots}).", "hint": "Read one of {roots} instead."},
487
488
  "roots.custom_deps": {"level": "error", "message": "{path}: a custom blok reads an agent it is bound to as agents.<key>, not deps.<key>.", "hint": "Write agents.<key> instead: the same path, from agents."},
@@ -532,6 +533,8 @@
532
533
  "palette.raw_colour": {"level": "warning", "message": "{token}: a blok picks a colour role, not a colour; try {suggestion}."},
533
534
  "palette.logo_paint": {"level": "error", "message": "<{component}> paints {prop}={value!r}; a logo paints with {pens} or url(#id)."},
534
535
  "palette.scene_colour": {"level": "warning", "message": "<{component}> {prop}={value!r} is no colour of the theme; a scene picks a colour role ({roles}).", "hint": "Pick one of the colour roles listed."},
536
+ "props.type": {"level": "warning", "message": "{key} of <{component}> takes {expected}, but {value} does not fit: {reason}.", "hint": "Give {key} a value of the type the catalog lists for it ({expected})."},
537
+ "port.catalog_only": {"level": "error", "message": "{path} is a {kind} port: CALLBACK, ASSET and BINDING type a catalog's props, never an action's, a state's or a local's.", "hint": "Type the port by the value it holds (a STRING, a STRUCTURE, ...)."},
535
538
  "props.literal_type": {"level": "error", "message": "<{component}> {key}={value!r} is a string, but {key} takes a {kind}; write {hint}.", "hint": "Write the value as an expression in braces: {key}={{...}}."},
536
539
  "foreach.position_key": {"level": "warning", "message": "<foreach let=\"{let}\"> has no key, so its items are keyed by their position; they are not scalars, so key them by a stable field (key={{{let}.id}})."},
537
540
  "returns.unnamed": {"level": "warning", "message": "{path} reads {port}, a return the action left unnamed; name it in the action, as Annotated[T, Key(\"name\")] or as a field of a NamedTuple return, and read it by that name."},
@@ -544,6 +547,10 @@
544
547
  "calls.not_in_kind": {"level": "error", "message": "{path}: a{n} {kind} blok calls no agent.", "hint": "A port blok is a field of a form: read the agent's state and write the port (port.set(...), bind={{port.value}}). What starts a task belongs in the action's assign blok."},
545
548
  "assign.kind": {"level": "error", "message": "{what} belongs to starting a run, so only an action's assign blok holds it, not a{n} {kind} blok.", "hint": "Make it <Blok kind=\"assign\"> in the action's bloks=[...]."},
546
549
  "logo.complexity": {"level": "error", "message": "{detail}"},
550
+ "logo.misplaced": {"level": "error", "message": "A <logo> is a child of the <Blok> it stands for, not inside another element.", "hint": "Move it to the top of the blok, beside its queries."},
551
+ "logo.twice": {"level": "error", "message": "A blok has one <logo>; this is a second one."},
552
+ "logo.in_logo": {"level": "error", "message": "A logo blok is a logo already: it declares no <logo> of its own.", "hint": "Draw it in the blok's <Logo> instead."},
553
+ "logo.dynamic": {"level": "warning", "message": "<{component}> sets {prop} with an expression; a <logo> is a fixed drawing that reads nothing, so it is drawn without it.", "hint": "Write the value as a literal."},
547
554
  "catalog.unknown_component": {"level": "warning", "message": "<{component}> is not in the catalog the blok is written for ({catalogs}).", "hint": "Look the component up in the catalog; names are case-sensitive."},
548
555
  "catalog.children": {"level": "warning", "message": "<{component}> takes no children.", "hint": "Close <{component}> without children (<{component} ... />), or put them beside it."},
549
556
  "catalog.text": {"level": "warning", "message": "<{component}> {detail}", "hint": "Put the text in a component that draws it (<Text>, <p>, <span>), or set it once."},
@@ -1,6 +1,6 @@
1
1
  export default {
2
2
  "vocab": 2,
3
- "minor": 7,
3
+ "minor": 9,
4
4
  "description": "The blok language, version 2: what a blok may read, call and store. The spec's parser, the server (rekuest_core, takt) and the renderer (orkestrator) load this file or are generated from it. The design is the blok-vocab-v2 proposal of 2026-10-25. Three layers, each versioned on its own: this language (vocab, and minor for what it gained since); the base catalog, everything every renderer draws; and the app catalogs that extend it with what one frontend draws beyond (see catalogs). A server holds a blok to the language alone, never to a catalog: whoever draws a blok checks it against the catalog it has, and an author's tooling checks it when asked.",
5
5
  "roots": {
6
6
  "data": {
@@ -99,6 +99,7 @@ export default {
99
99
  "query": "<query name=\"x\" service=\"mikro\" document=\"query (...) {...}\" poll={5} more=\"items\"><var key=\"k\" value={...} /></query>: a declared read, queries.<name>. A child of <Blok>, before its content.",
100
100
  "subscription": "<subscription name=\"x\" service=\"mikro\" document=\"subscription (...) {...}\" keep={10} history=\"q\"><var key=\"k\" value={...} /></subscription>: a declared stream, subscriptions.<name>. A child of <Blok>, before its content.",
101
101
  "dependencies": "<dependencies key=\"cells\" like=\"self.<action>\" />: the dependencies of one of the app's own actions, for an agent blok to read, call and hand to a run of it. A custom blok declares those of an action of an agent it is bound to: like=\"agents.<name>.<action>\" (stored deps.<name>.<action>). Each is read through the key, bare: cells.<dependency>.<state>.<field>, cells.<dependency>.<action>(...), cells.<dependency>.connected (stored as the blok's dependency deps.cells__<dependency>). cells.options.<dependency> lists the agents that fit one ({id, name, connected, picked}) and cells.pick(<dependency>: <agent id>) binds it; <deppicker key=\"cells.<dependency>\" /> is the ready-made picker. Which agent each is bound to is the viewer's own choice, kept on their device and never on a server; until they choose it is seeded once, with the agent the latest run of the action had, else the only one that fits. A child of <Blok>, after its locals and before what reads through it; an agent blok only. An action whose dependency is called options or pick cannot be read through one.",
102
+ "logo": "<logo title=\"Microscope\"><Circle cx=\"12\" cy=\"12\" r=\"7\" /></logo>: the blok's own logo, standing for it in lists, pins and tabs. A child of <Blok>, one, in a blok that is no logo. It holds a drawing of the logo catalog on a 24-unit grid (viewBox=\"0 0 24 24\" unless it says otherwise), painted with the logo pens and drawn with the action logos' pen (fill none, stroke ink, round) unless a shape says otherwise. title and viewBox are literals, and so is everything it draws: a fixed drawing that reads nothing. It is checked and drawn as a logo blok of its own.",
102
103
  "var": "<var key=\"k\" value={expression or literal} />: one variable of a query or subscription; an expression over args, blok-level locals and agents."
103
104
  }
104
105
  },
@@ -388,7 +389,7 @@ export default {
388
389
  "any": "ANY is a local's kind only (no action port is ever ANY): an untyped value. It is never an error and gets no warning; it skips the bind_kinds and arg_kinds checks and a path below it is taken as written. A renderer treats it as an untyped value.",
389
390
  "kind_inference": ["A given kind (ANY included) is kept; only a left-out kind is inferred, by the first rule that gives one:", "1. the default: a bool BOOL, an integer INT, any other number FLOAT, a string STRING; a non-empty list of one scalar kind LIST of it, a non-empty object of one scalar kind DICT of it (the item port keyed ...); null, [], {} and mixed items tell nothing;", "2. the port of the task argument the local is passed to whole (an argument whose value is exactly the local's path), at the first such call in tree order whose arg port is known and makes a valid local: its kind, identifier, nullable, choices, reference_unit, proposed_units, dimension and children (from a demand's arg match: kind, identifier, nullable and children, every child with a kind);", "3. the bind kind of the first control bound to the local whole, when it is STRING, INT, FLOAT or BOOL (LIST, DICT and ANY controls tell too little);", "4. else ANY.", "A given kind and like= come before rule 1. Only uses inside the local's scope (its parent's subtree) count. Tree order is the walk order: nodes depth first, each node's props in order, a call's arguments in order. Every field the local sets (choices, nullable, widget, identifier, children, description, ...) wins over the inferred type, which only fills what it leaves out; a candidate whose merge is no valid port is skipped. The other call sites and binds are then checked against the kind found (local.arg_kind, local.bind_kind). A left-out kind stays distinguishable from a given ANY until inference ran (no default filled in at deserialization; null is left out)."],
390
391
  "bind": "bind={<local>} or bind={<local>.<field>...}: the control writes the local; nothing else does. The catalog's kind of the bind prop is what the control writes: the local (or the field of it bound) must be a port kind bind_kinds lists for it.",
391
- "bind_kinds": {"description": "Per catalog kind of a bind prop, the port kinds of the locals it may write. A kind not listed (ANY) writes any local.", "STRING": ["STRING", "ENUM", "DATE"], "FLOAT": ["FLOAT", "INT", "QUANTITY"], "INT": ["INT"], "BOOL": ["BOOL"], "LIST": ["LIST"], "DICT": ["DICT", "MODEL"]},
392
+ "bind_kinds": {"description": "Per kind a control writes (the one child of its bind prop's BINDING port), the port kinds of the locals it may write. A kind not listed writes a local of its own kind; an open child writes any local.", "STRING": ["STRING", "ENUM", "DATE"], "FLOAT": ["FLOAT", "INT", "QUANTITY"], "INT": ["INT"], "BOOL": ["BOOL"], "LIST": ["LIST"], "DICT": ["DICT", "MODEL"]},
392
393
  "arg_kinds": {"description": "Per port kind of a local passed whole as a task call's argument, the kinds of the action's arg port that take it, where the action is known (agent self.<action> demands, an action's dependencies). STRUCTURE also needs the same identifier. An ANY local is not checked.", "STRING": ["STRING"], "INT": ["INT", "FLOAT"], "FLOAT": ["FLOAT"], "BOOL": ["BOOL"], "ENUM": ["ENUM", "STRING"], "DATE": ["DATE", "STRING"], "QUANTITY": ["QUANTITY", "FLOAT"], "LIST": ["LIST"], "DICT": ["DICT"], "MODEL": ["MODEL", "DICT"], "STRUCTURE": ["STRUCTURE"]}
393
394
  },
394
395
  "theme": {
@@ -429,7 +430,7 @@ export default {
429
430
  "logo_path_data_props": ["d", "points"]
430
431
  },
431
432
  "catalogs": {
432
- "description": "A catalog is a versioned set of components. The base catalog is what every renderer draws, whole, in the contexts it draws (PANEL, SCENE, LOGO): a blok written for it runs everywhere. An app catalog extends another (in the end the base) with what one frontend draws beyond it; it is that frontend's to publish. A catalog is named by the address it is published at (its id); a blok names the one catalog it is written for (catalog), the base when it names none, and may record the minor it needs (catalog_minor). A version only ever gains components and props: each says the minor that added it (since), so a blok valid at v1.2 stays valid. A renderer reports the catalogs and minors it speaks; what it lacks it draws as a placeholder, and reports. A catalog never redefines a component of the one it extends. Nobody's server fetches a catalog: it holds what a frontend registered under the id, and an author's tooling resolves an id from what ships with it, from its cache, or by fetching it.",
433
+ "description": "A catalog is a versioned set of components. The base catalog is what every renderer draws, whole, in the contexts it draws (PANEL, SCENE, LOGO): a blok written for it runs everywhere. An app catalog extends another (in the end the base) with what one frontend draws beyond it; it is that frontend's to publish. A catalog is named by the address it is published at (its id); a blok names the one catalog it is written for (catalog), the base when it names none, and may record the minor it needs (catalog_minor). A version only ever gains components and props: each says the minor that added it (since), so a blok valid at v1.2 stays valid. A renderer reports the catalogs and minors it speaks; what it lacks it draws as a placeholder, and reports. A catalog never redefines a component of the one it extends. Nobody's server fetches a catalog: it holds what a frontend registered under the id, and an author's tooling resolves an id from what ships with it, from its cache, or by fetching it. Every prop, and every argument and result of an operation, is typed by a port: the port of an action's argument (kind, identifier, nullable, choices, children), plus three kinds only a catalog types by -- CALLBACK (its children are the payload, event.<key>), ASSET (a file an app registered) and BINDING (its one child, keyed '...', is what the control writes). A port of no kind is open: only the language's own props and generic operations are.",
433
434
  "base": "https://arkitekt.live/catalogs/base/v4",
434
435
  "bundled": {"https://arkitekt.live/catalogs/base/v4": "catalogs/base@4.json", "https://arkitekt.live/catalogs/orkestrator/v1": "catalogs/orkestrator@1.json"},
435
436
  "id": "^https://[^\\s/]+(/[^\\s/]+)*/v[0-9]+$",
@@ -479,9 +480,9 @@ export default {
479
480
  "callback.positional": {"level": "error", "message": "{call}: a task call names its arguments (name: value)."},
480
481
  "callback.with": {"level": "error", "message": "with hands a task call the dependencies the blok declares for that action: `self.<action>(...) with <key>`, in a custom blok `agents.<name>.<action>(...) with <key>`.", "hint": "Write `self.<action>(name: value) with cells into run`, where the blok declares <dependencies key=\"cells\" like=\"self.<action>\" />."},
481
482
  "callback.into": {"level": "error", "message": "into names the record of a task call: `<call> into <name>`.", "hint": "Write `deps.<key>.<action>(name: value) into run`, then read run.running, run.returns.<port>."},
482
- "callback.not_callback": {"level": "error", "message": "{key} of <{component}> is not a callback prop, so it cannot hold {what}.", "hint": "Use a callback prop of <{component}> (the catalog lists them as CALLBACK), or compute {key} without a call."},
483
+ "callback.not_callback": {"level": "error", "message": "{key} of <{component}> is not a callback prop, so it cannot hold {what}.", "hint": "Use a callback prop of <{component}> (the catalog types them CALLBACK), or compute {key} without a call."},
483
484
  "callback.unbound": {"level": "error", "message": "{key} of <{component}> is a callback prop: it holds one task call or one effect (queries.<name>.refetch(), queries.<name>.fetch_more(...), ui.copy, task.answer, assign.start, port.set).", "hint": "Give {key} a task call (deps.<key>.<action>(name: value)) or one effect, not a value."},
484
- "callback.event_field": {"level": "error", "message": "event has no field {field!r} in {key} of <{component}> (its fields: {fields}).", "hint": "Read one of the fields listed for {key}: {fields}."},
485
+ "callback.event_field": {"level": "error", "message": "event has no field {field!r} in {key} of <{component}> (its fields: {fields}).", "hint": "Read one of the fields its CALLBACK port lists for {key}: {fields}."},
485
486
  "roots.unknown": {"level": "error", "message": "{path} reads {root!r}, which is no root, local, loop variable or record of this blok.", "hint": "Read a root this blok has (deps.<key>, args.<key>, queries.<name>, ...), a declared local, a foreach let or index, or an into record."},
486
487
  "roots.not_in_kind": {"level": "error", "message": "{path}: a{n} {kind} blok has no {root!r} (it reads {roots}).", "hint": "Read one of {roots} instead."},
487
488
  "roots.custom_deps": {"level": "error", "message": "{path}: a custom blok reads an agent it is bound to as agents.<key>, not deps.<key>.", "hint": "Write agents.<key> instead: the same path, from agents."},
@@ -532,6 +533,8 @@ export default {
532
533
  "palette.raw_colour": {"level": "warning", "message": "{token}: a blok picks a colour role, not a colour; try {suggestion}."},
533
534
  "palette.logo_paint": {"level": "error", "message": "<{component}> paints {prop}={value!r}; a logo paints with {pens} or url(#id)."},
534
535
  "palette.scene_colour": {"level": "warning", "message": "<{component}> {prop}={value!r} is no colour of the theme; a scene picks a colour role ({roles}).", "hint": "Pick one of the colour roles listed."},
536
+ "props.type": {"level": "warning", "message": "{key} of <{component}> takes {expected}, but {value} does not fit: {reason}.", "hint": "Give {key} a value of the type the catalog lists for it ({expected})."},
537
+ "port.catalog_only": {"level": "error", "message": "{path} is a {kind} port: CALLBACK, ASSET and BINDING type a catalog's props, never an action's, a state's or a local's.", "hint": "Type the port by the value it holds (a STRING, a STRUCTURE, ...)."},
535
538
  "props.literal_type": {"level": "error", "message": "<{component}> {key}={value!r} is a string, but {key} takes a {kind}; write {hint}.", "hint": "Write the value as an expression in braces: {key}={{...}}."},
536
539
  "foreach.position_key": {"level": "warning", "message": "<foreach let=\"{let}\"> has no key, so its items are keyed by their position; they are not scalars, so key them by a stable field (key={{{let}.id}})."},
537
540
  "returns.unnamed": {"level": "warning", "message": "{path} reads {port}, a return the action left unnamed; name it in the action, as Annotated[T, Key(\"name\")] or as a field of a NamedTuple return, and read it by that name."},
@@ -544,6 +547,10 @@ export default {
544
547
  "calls.not_in_kind": {"level": "error", "message": "{path}: a{n} {kind} blok calls no agent.", "hint": "A port blok is a field of a form: read the agent's state and write the port (port.set(...), bind={{port.value}}). What starts a task belongs in the action's assign blok."},
545
548
  "assign.kind": {"level": "error", "message": "{what} belongs to starting a run, so only an action's assign blok holds it, not a{n} {kind} blok.", "hint": "Make it <Blok kind=\"assign\"> in the action's bloks=[...]."},
546
549
  "logo.complexity": {"level": "error", "message": "{detail}"},
550
+ "logo.misplaced": {"level": "error", "message": "A <logo> is a child of the <Blok> it stands for, not inside another element.", "hint": "Move it to the top of the blok, beside its queries."},
551
+ "logo.twice": {"level": "error", "message": "A blok has one <logo>; this is a second one."},
552
+ "logo.in_logo": {"level": "error", "message": "A logo blok is a logo already: it declares no <logo> of its own.", "hint": "Draw it in the blok's <Logo> instead."},
553
+ "logo.dynamic": {"level": "warning", "message": "<{component}> sets {prop} with an expression; a <logo> is a fixed drawing that reads nothing, so it is drawn without it.", "hint": "Write the value as a literal."},
547
554
  "catalog.unknown_component": {"level": "warning", "message": "<{component}> is not in the catalog the blok is written for ({catalogs}).", "hint": "Look the component up in the catalog; names are case-sensitive."},
548
555
  "catalog.children": {"level": "warning", "message": "<{component}> takes no children.", "hint": "Close <{component}> without children (<{component} ... />), or put them beside it."},
549
556
  "catalog.text": {"level": "warning", "message": "<{component}> {detail}", "hint": "Put the text in a component that draws it (<Text>, <p>, <span>), or set it once."},
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arkitektio/bsx",
3
- "version": "6.8.0",
3
+ "version": "7.0.0",
4
4
  "description": "The BSX language, the blok spec, runtime and React renderer: one copy for every Arkitekt frontend.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -26,6 +26,8 @@ export const QUERY_COMPONENT = 'query';
26
26
  export const SUBSCRIPTION_COMPONENT = 'subscription';
27
27
  export const VAR_COMPONENT = 'var';
28
28
  export const DEPENDENCIES_COMPONENT = 'dependencies';
29
+ /** A blok's own logo: a child of its `<Blok>` holding a drawing of the logo catalog. */
30
+ export const LOGO_COMPONENT = 'logo';
29
31
  /** The components that declare what a blok owns and draw nothing. */
30
32
  export const DECLARATION_COMPONENTS: ReadonlySet<string> = new Set([
31
33
  LOCAL_COMPONENT,
@@ -33,7 +35,22 @@ export const DECLARATION_COMPONENTS: ReadonlySet<string> = new Set([
33
35
  SUBSCRIPTION_COMPONENT,
34
36
  VAR_COMPONENT,
35
37
  DEPENDENCIES_COMPONENT,
38
+ LOGO_COMPONENT,
36
39
  ]);
40
+ const LOGO_TITLE_PROP = 'title';
41
+ const LOGO_VIEW_BOX_PROP = 'viewBox';
42
+ /** A logo's grid when its `<logo>` names none: 24 units, the grid of the action logos. */
43
+ export const LOGO_VIEW_BOX = '0 0 24 24';
44
+ /** The pen a `<logo>` draws with unless a shape says otherwise: the action logos' pen. */
45
+ export const LOGO_PEN: ReadonlyArray<readonly [string, string]> = [
46
+ ['fill', 'none'],
47
+ ['stroke', 'ink'],
48
+ ['strokeWidth', '1.8'],
49
+ ['strokeLinecap', 'round'],
50
+ ['strokeLinejoin', 'round'],
51
+ ];
52
+ /** The kind a `<logo>` is drawn as (`blokLogoTree`): one drawn in the logo context. */
53
+ export const LOGO_KIND = 'agent';
37
54
  /** The name a local, a query or a subscription is read by. */
38
55
  export const NAME_PROP = 'name';
39
56
  /** A local's borrowed port: `self.<action>.<arg>` or `deps.<key>.<action>.<arg>`. */
@@ -224,6 +241,49 @@ export const declaredLocal = (node: BlokComponentNode): DeclaredLocal | null =>
224
241
  };
225
242
 
226
243
  /** Every node of `tree` with its ancestors, depth first. */
244
+ /**
245
+ * The blok's own `<logo>`: the first among the children of its `<Blok>`, or
246
+ * null. A `<logo>` anywhere else, or a second one, stands for nothing (the
247
+ * checker says so: `logo.misplaced`, `logo.twice`). The port of the spec's
248
+ * `declared_logo`.
249
+ */
250
+ export const declaredLogo = (tree: BlokComponentNode | null | undefined): BlokComponentNode | null =>
251
+ (tree?.children ?? []).find(child => child.component === LOGO_COMPONENT) ?? null;
252
+
253
+ /**
254
+ * The blok's `<logo>` as a logo blok of its own, or null when it declares
255
+ * none: `<Blok kind="agent" context="logo"><Logo viewBox title><G pen>...`.
256
+ * What is checked (pens, the logo catalog, the logo limits) and drawn for it,
257
+ * in lists, pins and tabs. Its kind is `agent` whatever the blok's: a `<logo>`
258
+ * is literals only and reads nothing. The drawing's nodes are the `<logo>`'s
259
+ * own; the frame takes its id (and two made from it). The port of the spec's
260
+ * `blok_logo_tree`.
261
+ */
262
+ export const blokLogoTree = (tree: BlokComponentNode | null | undefined): BlokComponentNode | null => {
263
+ const logo = declaredLogo(tree);
264
+ if (logo === null) return null;
265
+ const props = new Map((logo.props ?? []).map(prop => [prop.key, prop]));
266
+ const title = props.get(LOGO_TITLE_PROP);
267
+ const drawingProps = [props.get(LOGO_VIEW_BOX_PROP) ?? {key: LOGO_VIEW_BOX_PROP, static_value: LOGO_VIEW_BOX}];
268
+ if (title) drawingProps.push(title);
269
+ const pen: BlokComponentNode = {
270
+ id: `${logo.id}.pen`,
271
+ component: 'G',
272
+ props: LOGO_PEN.map(([key, value]) => ({key, static_value: value})),
273
+ children: logo.children ?? [],
274
+ };
275
+ const drawing: BlokComponentNode = {id: `${logo.id}.drawing`, component: 'Logo', props: drawingProps, children: [pen]};
276
+ return {
277
+ id: logo.id,
278
+ component: BLOK_COMPONENT,
279
+ props: [
280
+ {key: KIND_ATTRIBUTE, static_value: LOGO_KIND},
281
+ {key: CONTEXT_ATTRIBUTE, static_value: 'logo'},
282
+ ],
283
+ children: [drawing],
284
+ };
285
+ };
286
+
227
287
  export const iterWithParents = (tree: BlokComponentNode): Array<[BlokComponentNode, readonly BlokComponentNode[]]> => {
228
288
  const found: Array<[BlokComponentNode, readonly BlokComponentNode[]]> = [];
229
289
  const visit = (node: BlokComponentNode, ancestors: readonly BlokComponentNode[]) => {
@@ -116,7 +116,7 @@ describe('new warnings', () => {
116
116
 
117
117
  describe('a catalog only adds', () => {
118
118
  it('refuses one that redefines a component of the base catalog, the language included', () => {
119
- const redefining = (name: string) => parseSpecCatalog({name: 'mine', components: [{name, context: 'PANEL', props: [{key: 'bind', kind: 'STRING'}]}]}, 'mine');
119
+ const redefining = (name: string) => parseSpecCatalog({name: 'mine', components: [{name, context: 'PANEL', props: [{key: 'bind', port: {kind: 'BINDING', children: [{key: '...', kind: 'STRING'}]}}]}]}, 'mine');
120
120
  expect(() => blokView(redefining('Slider'))).toThrow(/redefines <Slider> of base@4: a catalog only adds/);
121
121
  expect(() => blokView(redefining('foreach'))).toThrow(/redefines <foreach>/);
122
122
  });
package/src/bsx/infer.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import {bindingWrites} from '../spec/ports';
1
2
  import type {BlokActionArgument, BlokAgentCall, BlokComponentNode, BlokComponentProp} from '../renderer/runtime/types';
2
3
  import type {BlokView} from '../spec/catalogs';
3
4
  import {LOCAL_ANY_KIND} from '../spec/vocabulary';
@@ -281,9 +282,10 @@ class Uses {
281
282
  for (const prop of node.props ?? []) {
282
283
  const path = prop.key === BIND_PROP ? prop.dynamic_value?.path ?? null : null;
283
284
  const local = path !== null ? scope.get(path) ?? null : null;
284
- if (local !== null) {
285
+ const writes = bindingWrites(bind.port).kind;
286
+ if (local !== null && writes !== null) {
285
287
  const binds = this.binds.get(local) ?? [];
286
- binds.push(bind.kind);
288
+ binds.push(writes);
287
289
  this.binds.set(local, binds);
288
290
  }
289
291
  }
@@ -1,6 +1,7 @@
1
+ import {CALLBACK, portSummary} from '../spec/ports';
1
2
  import {defaultBlokView, innerContext, type BlokView, type SpecComponent, type SpecProp} from '../spec/catalogs';
2
3
  import {BLOK_KINDS, kindIn, loadVocabulary, type BlokContextName, type BlokKind, type VocabFunction, type VocabRecordField} from '../spec/vocabulary';
3
- import {BLOK_COMPONENT, declaredQueries, declaredSubscriptions, QUERY_COMPONENT, SUBSCRIPTION_COMPONENT} from './declared';
4
+ import {BLOK_COMPONENT, declaredQueries, declaredSubscriptions, LOGO_COMPONENT, QUERY_COMPONENT, SUBSCRIPTION_COMPONENT} from './declared';
4
5
  import {resolveLocals} from './infer';
5
6
  import {FOREACH_COMPONENT, FOREACH_INDEX_PROP, FOREACH_LET_PROP, INTO_KEYWORD} from './parse';
6
7
  import {parseBsxPartial} from './partial';
@@ -236,10 +237,11 @@ export const scanCursor = (text: string, offset: number): BsxCursor => {
236
237
 
237
238
  export const describeProp = (prop: SpecProp): string =>
238
239
  [
239
- `**${prop.key}**: ${prop.kind.toLowerCase()}${prop.required ? ' (required)' : ''}`,
240
+ `**${prop.key}**: \`${portSummary(prop.port)}\`${prop.required ? ' (required)' : ''}`,
240
241
  prop.description ?? '',
241
- prop.values ? `one of: ${prop.values.map(value => `\`"${value}"\``).join(', ')}` : '',
242
- prop.event && prop.event.length ? `event: ${prop.event.map(field => `\`event.${field.key}\` (${field.kind.toLowerCase()})`).join(', ')}` : '',
242
+ prop.port.kind === CALLBACK && prop.port.children?.length
243
+ ? `event: ${prop.port.children.map(field => `\`event.${field.key}\` (${portSummary(field)})`).join(', ')}`
244
+ : '',
243
245
  ]
244
246
  .filter(Boolean)
245
247
  .join('\n\n');
@@ -302,9 +304,11 @@ const fitsUnder = (component: SpecComponent, ancestors: readonly string[], conte
302
304
  };
303
305
 
304
306
  const snippetValue = (prop: SpecProp, index: number): string => {
305
- if (prop.kind === 'STRING' && prop.values?.length) return `"\${${index}|${prop.values.join(',')}|}"`;
306
- if (prop.kind === 'STRING') return `"\${${index}}"`;
307
- if (prop.kind === 'BOOL') return `{\${${index}|true,false|}}`;
307
+ const {port} = prop;
308
+ if (port.kind === 'STRING' && port.choices?.length) return `"\${${index}|${port.choices.map(choice => String(choice.value)).join(',')}|}"`;
309
+ // A text prop is a union holding STRING: written as a string.
310
+ if (port.kind === 'STRING' || (port.kind === 'UNION' && port.children?.some(child => child.kind === 'STRING'))) return `"\${${index}}"`;
311
+ if (port.kind === 'BOOL') return `{\${${index}|true,false|}}`;
308
312
  return `{\${${index}}}`;
309
313
  };
310
314
 
@@ -333,7 +337,8 @@ const completeTag = (env: BsxEnvironment, cursor: Extract<BsxCursor, {kind: 'tag
333
337
  if (stack.length === 0) return [blokCompletion(from)];
334
338
  const parent = view.components.get(stack[stack.length - 1].tag);
335
339
  if (parent && !parent.acceptsChildren) return [];
336
- const ancestors = stack.map(element => element.tag);
340
+ // A blok's own <logo> is drawn inside a <Logo> (`blokLogoTree`): what may sit in one may sit in it.
341
+ const ancestors = stack.flatMap(element => (element.tag === LOGO_COMPONENT ? [element.tag, 'Logo'] : [element.tag]));
337
342
  const header = headerAt(stack);
338
343
  const atRoot = stack.length === 1 && stack[0].tag === BLOK_COMPONENT;
339
344
  const declarations = new Set(Object.keys(loadVocabulary().blok.declarations));
@@ -361,7 +366,7 @@ const completeAttributeName = (env: BsxEnvironment, cursor: Extract<BsxCursor, {
361
366
  insertText: `${prop.key}=${snippetValue(prop, 1)}`,
362
367
  snippet: true,
363
368
  kind: 'prop' as const,
364
- detail: `${prop.kind.toLowerCase()}${prop.required ? ' · required' : ''}`,
369
+ detail: `${portSummary(prop.port)}${prop.required ? ' · required' : ''}`,
365
370
  documentation: describeProp(prop),
366
371
  from: cursor.from,
367
372
  sortText: `${prop.required ? '0' : '1'}${String(index).padStart(3, '0')}`,
@@ -635,7 +640,7 @@ const completeExpression = (env: BsxEnvironment, text: string, expression: strin
635
640
  }
636
641
  if (first === 'event') {
637
642
  if (!calls || !place.callback) return [];
638
- return rest.length === 0 ? (place.callback.event ?? []).map(field => item(field.key, 'path', `event · ${field.kind.toLowerCase()}`, field.description ?? undefined)) : [];
643
+ return rest.length === 0 ? (place.callback.port.children ?? []).map(field => item(field.key, 'path', `event · ${portSummary(field)}`, field.description ?? undefined)) : [];
639
644
  }
640
645
  if (first === 'error') return place.inErrorSlot && rest.length === 0 ? fieldItems(recordFields('error'), 'error') : [];
641
646
  if (!roots.includes(first)) return [];
@@ -683,7 +688,7 @@ const placeOf = (env: BsxEnvironment, tag: string | null, attr: string | null, s
683
688
  const tags = stack.map(element => element.tag);
684
689
  const errorAt = tags.lastIndexOf('error');
685
690
  return {
686
- callback: prop?.kind === 'CALLBACK' ? prop : null,
691
+ callback: prop?.port.kind === CALLBACK ? prop : null,
687
692
  tag,
688
693
  stack,
689
694
  inErrorSlot: errorAt > 0 && tags[errorAt - 1] === 'suspense',
@@ -0,0 +1,47 @@
1
+ import {describe, expect, it} from 'vitest';
2
+ import {drawnChildren} from '../renderer/bloks/control';
3
+ import {blokLogoTree, content, declaredLogo, LOGO_VIEW_BOX} from './declared';
4
+ import {completeBsx} from './language';
5
+ import {parseBsx} from './parse';
6
+
7
+ const PANEL =
8
+ '<Blok kind="agent" context="panel"><logo title="Scope"><Circle cx="12" cy="12" r="7" /><Path d="M12 5v14" /></logo><Card><Text text="hi" /></Card></Blok>';
9
+
10
+ const props = (node: {props?: Array<{key: string; static_value?: unknown}> | null}) =>
11
+ Object.fromEntries((node.props ?? []).map(prop => [prop.key, prop.static_value]));
12
+
13
+ describe("a blok's own logo", () => {
14
+ it('draws nothing in the blok', () => {
15
+ const {tree} = parseBsx(PANEL);
16
+ expect(content(tree).map(node => node.component)).toEqual(['Card']);
17
+ expect(drawnChildren(tree).map(node => node.component)).toEqual(['Card']);
18
+ expect(declaredLogo(tree)?.component).toBe('logo');
19
+ });
20
+
21
+ it('is drawn as a logo blok of its own, with the action logos pen', () => {
22
+ const logo = blokLogoTree(parseBsx(PANEL).tree);
23
+ expect(logo).not.toBeNull();
24
+ expect(props(logo!)).toEqual({kind: 'agent', context: 'logo'});
25
+ const [drawing] = logo!.children ?? [];
26
+ expect(drawing.component).toBe('Logo');
27
+ expect(props(drawing)).toEqual({viewBox: LOGO_VIEW_BOX, title: 'Scope'});
28
+ const [pen] = drawing.children ?? [];
29
+ expect(pen.component).toBe('G');
30
+ expect(props(pen)).toMatchObject({fill: 'none', stroke: 'ink'});
31
+ expect((pen.children ?? []).map(node => node.component)).toEqual(['Circle', 'Path']);
32
+ });
33
+
34
+ it('is none when the blok declares none', () => {
35
+ expect(blokLogoTree(parseBsx('<Blok kind="agent" context="panel"><Card /></Blok>').tree)).toBeNull();
36
+ });
37
+
38
+ it('is offered at the top of a blok, and the logo shapes inside it', () => {
39
+ const atRoot = '<Blok kind="agent" context="panel"><|';
40
+ const top = completeBsx(atRoot.replace('|', ''), atRoot.indexOf('|'), {}).map(item => item.label);
41
+ expect(top).toContain('logo');
42
+ const inside = '<Blok kind="agent" context="panel"><logo><|';
43
+ const shapes = completeBsx(inside.replace('|', ''), inside.indexOf('|'), {}).map(item => item.label);
44
+ expect(shapes).toEqual(expect.arrayContaining(['Circle', 'Path']));
45
+ expect(shapes).not.toContain('Card');
46
+ });
47
+ });