@arkitektio/bsx 6.9.0 → 7.0.1
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.
- package/dist/bsx/infer.d.ts.map +1 -1
- package/dist/bsx/infer.js +4 -2
- package/dist/bsx/infer.js.map +1 -1
- package/dist/bsx/language.d.ts.map +1 -1
- package/dist/bsx/language.js +14 -10
- package/dist/bsx/language.js.map +1 -1
- package/dist/bsx/references.d.ts.map +1 -1
- package/dist/bsx/references.js +94 -35
- package/dist/bsx/references.js.map +1 -1
- package/dist/catalogs/index.d.ts +191 -98
- package/dist/catalogs/index.d.ts.map +1 -1
- package/dist/catalogs/parts/data.d.ts +2 -2
- package/dist/catalogs/parts/data.d.ts.map +1 -1
- package/dist/catalogs/parts/data.js +2 -3
- package/dist/catalogs/parts/data.js.map +1 -1
- package/dist/catalogs/parts/feedback.d.ts +6 -6
- package/dist/catalogs/parts/forms.d.ts +8 -8
- package/dist/catalogs/parts/icons.d.ts +4 -4
- package/dist/catalogs/parts/index.d.ts +48 -48
- package/dist/catalogs/parts/navigation.d.ts +8 -8
- package/dist/catalogs/parts/overlays.d.ts +22 -22
- package/dist/catalogs/parts/run.d.ts.map +1 -1
- package/dist/catalogs/parts/run.js +4 -5
- package/dist/catalogs/parts/run.js.map +1 -1
- package/dist/catalogs/parts/scene.d.ts.map +1 -1
- package/dist/catalogs/parts/scene.js +7 -14
- package/dist/catalogs/parts/scene.js.map +1 -1
- package/dist/catalogs/parts/structure.d.ts.map +1 -1
- package/dist/catalogs/parts/structure.js +2 -3
- package/dist/catalogs/parts/structure.js.map +1 -1
- package/dist/catalogs/parts/toast.d.ts.map +1 -1
- package/dist/catalogs/parts/toast.js +2 -1
- package/dist/catalogs/parts/toast.js.map +1 -1
- package/dist/catalogs/props.d.ts +23 -0
- package/dist/catalogs/props.d.ts.map +1 -1
- package/dist/catalogs/props.js +56 -4
- package/dist/catalogs/props.js.map +1 -1
- package/dist/catalogs/scene.d.ts +134 -127
- package/dist/catalogs/scene.d.ts.map +1 -1
- package/dist/catalogs/scene.js +5 -3
- package/dist/catalogs/scene.js.map +1 -1
- package/dist/catalogs/shadcn.d.ts +79 -41
- package/dist/catalogs/shadcn.d.ts.map +1 -1
- package/dist/catalogs/shadcn.js +13 -13
- package/dist/catalogs/shadcn.js.map +1 -1
- package/dist/catalogs/structure.d.ts +9 -2
- package/dist/catalogs/structure.d.ts.map +1 -1
- package/dist/catalogs/structure.js +1 -1
- package/dist/catalogs/structure.js.map +1 -1
- package/dist/catalogs/ui.d.ts +935 -892
- package/dist/catalogs/ui.d.ts.map +1 -1
- package/dist/catalogs/ui.js +16 -14
- package/dist/catalogs/ui.js.map +1 -1
- package/dist/catalogs/zodToPort.d.ts +9 -0
- package/dist/catalogs/zodToPort.d.ts.map +1 -0
- package/dist/catalogs/zodToPort.js +156 -0
- package/dist/catalogs/zodToPort.js.map +1 -0
- package/dist/catalogs.d.ts +4 -1
- package/dist/catalogs.d.ts.map +1 -1
- package/dist/catalogs.js +3 -0
- package/dist/catalogs.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/ports/rekuest.d.ts +6 -0
- package/dist/ports/rekuest.d.ts.map +1 -1
- package/dist/ports/rekuest.js +6 -0
- package/dist/ports/rekuest.js.map +1 -1
- package/dist/renderer/bloks/data.d.ts +2 -2
- package/dist/renderer/bloks/feedback.d.ts +6 -6
- package/dist/renderer/bloks/forms.d.ts +8 -8
- package/dist/renderer/bloks/icons.d.ts +2 -2
- package/dist/renderer/bloks/index.d.ts +48 -48
- package/dist/renderer/bloks/navigation.d.ts +8 -8
- package/dist/renderer/bloks/overlays.d.ts +22 -22
- package/dist/renderer/runtime/components.d.ts +6 -8
- package/dist/renderer/runtime/components.d.ts.map +1 -1
- package/dist/renderer/runtime/components.js.map +1 -1
- package/dist/renderer/runtime/describe.d.ts +5 -12
- package/dist/renderer/runtime/describe.d.ts.map +1 -1
- package/dist/renderer/runtime/describe.js +25 -89
- package/dist/renderer/runtime/describe.js.map +1 -1
- package/dist/renderer/runtime/hooks.d.ts.map +1 -1
- package/dist/renderer/runtime/hooks.js +3 -1
- package/dist/renderer/runtime/hooks.js.map +1 -1
- package/dist/renderer/runtime/schemas.d.ts +8 -6
- package/dist/renderer/runtime/schemas.d.ts.map +1 -1
- package/dist/renderer/runtime/schemas.js +40 -16
- package/dist/renderer/runtime/schemas.js.map +1 -1
- package/dist/shadcn.d.ts +48 -48
- package/dist/spec/bsx_v2.json +917 -15
- package/dist/spec/catalogs/base@4.json +18712 -5274
- package/dist/spec/catalogs/base@4.json.js +18712 -5274
- package/dist/spec/catalogs/orkestrator@1.json +6132 -127
- package/dist/spec/catalogs/orkestrator@1.json.js +6132 -127
- package/dist/spec/catalogs.d.ts +3 -11
- package/dist/spec/catalogs.d.ts.map +1 -1
- package/dist/spec/catalogs.js +13 -11
- package/dist/spec/catalogs.js.map +1 -1
- package/dist/spec/fit.d.ts +21 -0
- package/dist/spec/fit.d.ts.map +1 -0
- package/dist/spec/fit.js +114 -0
- package/dist/spec/fit.js.map +1 -0
- package/dist/spec/ports.d.ts +56 -0
- package/dist/spec/ports.d.ts.map +1 -0
- package/dist/spec/ports.js +174 -0
- package/dist/spec/ports.js.map +1 -0
- package/dist/spec/vocabulary.json +7 -5
- package/dist/spec/vocabulary.json.js +7 -5
- package/package.json +1 -1
- package/src/bsx/infer.test.ts +1 -1
- package/src/bsx/infer.ts +4 -2
- package/src/bsx/language.ts +13 -9
- package/src/bsx/references.ts +125 -38
- package/src/catalogs/parts/data.ts +3 -2
- package/src/catalogs/parts/run.ts +9 -7
- package/src/catalogs/parts/scene.ts +7 -14
- package/src/catalogs/parts/structure.ts +2 -3
- package/src/catalogs/parts/toast.ts +5 -1
- package/src/catalogs/props.ts +64 -4
- package/src/catalogs/scene.ts +5 -3
- package/src/catalogs/shadcn.ts +13 -13
- package/src/catalogs/structure.ts +1 -1
- package/src/catalogs/ui.ts +16 -14
- package/src/catalogs/zodToPort.test.ts +96 -0
- package/src/catalogs/zodToPort.ts +177 -0
- package/src/catalogs.ts +4 -1
- package/src/index.ts +2 -0
- package/src/ports/rekuest.ts +6 -0
- package/src/renderer/runtime/catalog.test.ts +12 -8
- package/src/renderer/runtime/components.tsx +5 -8
- package/src/renderer/runtime/describe.ts +25 -100
- package/src/renderer/runtime/hooks.ts +3 -1
- package/src/renderer/runtime/schemas.ts +51 -17
- package/src/spec/bsx_v2.json +917 -15
- package/src/spec/catalogs/base@4.json +18712 -5274
- package/src/spec/catalogs/orkestrator@1.json +6132 -127
- package/src/spec/catalogs.ts +14 -19
- package/src/spec/fit.test.ts +65 -0
- package/src/spec/fit.ts +114 -0
- package/src/spec/ports.ts +172 -0
- package/src/spec/spec.test.ts +5 -2
- package/src/spec/vocabulary.json +7 -5
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"vocab": 2,
|
|
3
|
-
"minor":
|
|
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": {
|
|
@@ -389,7 +389,7 @@
|
|
|
389
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.",
|
|
390
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)."],
|
|
391
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.",
|
|
392
|
-
"bind_kinds": {"description": "Per
|
|
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"]},
|
|
393
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"]}
|
|
394
394
|
},
|
|
395
395
|
"theme": {
|
|
@@ -430,7 +430,7 @@
|
|
|
430
430
|
"logo_path_data_props": ["d", "points"]
|
|
431
431
|
},
|
|
432
432
|
"catalogs": {
|
|
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.",
|
|
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.",
|
|
434
434
|
"base": "https://arkitekt.live/catalogs/base/v4",
|
|
435
435
|
"bundled": {"https://arkitekt.live/catalogs/base/v4": "catalogs/base@4.json", "https://arkitekt.live/catalogs/orkestrator/v1": "catalogs/orkestrator@1.json"},
|
|
436
436
|
"id": "^https://[^\\s/]+(/[^\\s/]+)*/v[0-9]+$",
|
|
@@ -480,9 +480,9 @@
|
|
|
480
480
|
"callback.positional": {"level": "error", "message": "{call}: a task call names its arguments (name: value)."},
|
|
481
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>\" />."},
|
|
482
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>."},
|
|
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
|
|
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."},
|
|
484
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."},
|
|
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
|
|
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}."},
|
|
486
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."},
|
|
487
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."},
|
|
488
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."},
|
|
@@ -533,6 +533,8 @@
|
|
|
533
533
|
"palette.raw_colour": {"level": "warning", "message": "{token}: a blok picks a colour role, not a colour; try {suggestion}."},
|
|
534
534
|
"palette.logo_paint": {"level": "error", "message": "<{component}> paints {prop}={value!r}; a logo paints with {pens} or url(#id)."},
|
|
535
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, ...)."},
|
|
536
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}={{...}}."},
|
|
537
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}})."},
|
|
538
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."},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export default {
|
|
2
2
|
"vocab": 2,
|
|
3
|
-
"minor":
|
|
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": {
|
|
@@ -389,7 +389,7 @@ export default {
|
|
|
389
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.",
|
|
390
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)."],
|
|
391
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.",
|
|
392
|
-
"bind_kinds": {"description": "Per
|
|
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"]},
|
|
393
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"]}
|
|
394
394
|
},
|
|
395
395
|
"theme": {
|
|
@@ -430,7 +430,7 @@ export default {
|
|
|
430
430
|
"logo_path_data_props": ["d", "points"]
|
|
431
431
|
},
|
|
432
432
|
"catalogs": {
|
|
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.",
|
|
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.",
|
|
434
434
|
"base": "https://arkitekt.live/catalogs/base/v4",
|
|
435
435
|
"bundled": {"https://arkitekt.live/catalogs/base/v4": "catalogs/base@4.json", "https://arkitekt.live/catalogs/orkestrator/v1": "catalogs/orkestrator@1.json"},
|
|
436
436
|
"id": "^https://[^\\s/]+(/[^\\s/]+)*/v[0-9]+$",
|
|
@@ -480,9 +480,9 @@ export default {
|
|
|
480
480
|
"callback.positional": {"level": "error", "message": "{call}: a task call names its arguments (name: value)."},
|
|
481
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>\" />."},
|
|
482
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>."},
|
|
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
|
|
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."},
|
|
484
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."},
|
|
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
|
|
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}."},
|
|
486
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."},
|
|
487
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."},
|
|
488
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."},
|
|
@@ -533,6 +533,8 @@ export default {
|
|
|
533
533
|
"palette.raw_colour": {"level": "warning", "message": "{token}: a blok picks a colour role, not a colour; try {suggestion}."},
|
|
534
534
|
"palette.logo_paint": {"level": "error", "message": "<{component}> paints {prop}={value!r}; a logo paints with {pens} or url(#id)."},
|
|
535
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, ...)."},
|
|
536
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}={{...}}."},
|
|
537
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}})."},
|
|
538
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."},
|
package/package.json
CHANGED
package/src/bsx/infer.test.ts
CHANGED
|
@@ -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
|
-
|
|
285
|
+
const writes = bindingWrites(bind.port).kind;
|
|
286
|
+
if (local !== null && writes !== null) {
|
|
285
287
|
const binds = this.binds.get(local) ?? [];
|
|
286
|
-
binds.push(
|
|
288
|
+
binds.push(writes);
|
|
287
289
|
this.binds.set(local, binds);
|
|
288
290
|
}
|
|
289
291
|
}
|
package/src/bsx/language.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
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
4
|
import {BLOK_COMPONENT, declaredQueries, declaredSubscriptions, LOGO_COMPONENT, QUERY_COMPONENT, SUBSCRIPTION_COMPONENT} from './declared';
|
|
@@ -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}**:
|
|
240
|
+
`**${prop.key}**: \`${portSummary(prop.port)}\`${prop.required ? ' (required)' : ''}`,
|
|
240
241
|
prop.description ?? '',
|
|
241
|
-
prop.
|
|
242
|
-
|
|
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
|
-
|
|
306
|
-
if (
|
|
307
|
-
|
|
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
|
|
|
@@ -362,7 +366,7 @@ const completeAttributeName = (env: BsxEnvironment, cursor: Extract<BsxCursor, {
|
|
|
362
366
|
insertText: `${prop.key}=${snippetValue(prop, 1)}`,
|
|
363
367
|
snippet: true,
|
|
364
368
|
kind: 'prop' as const,
|
|
365
|
-
detail: `${prop.
|
|
369
|
+
detail: `${portSummary(prop.port)}${prop.required ? ' · required' : ''}`,
|
|
366
370
|
documentation: describeProp(prop),
|
|
367
371
|
from: cursor.from,
|
|
368
372
|
sortText: `${prop.required ? '0' : '1'}${String(index).padStart(3, '0')}`,
|
|
@@ -636,7 +640,7 @@ const completeExpression = (env: BsxEnvironment, text: string, expression: strin
|
|
|
636
640
|
}
|
|
637
641
|
if (first === 'event') {
|
|
638
642
|
if (!calls || !place.callback) return [];
|
|
639
|
-
return rest.length === 0 ? (place.callback.
|
|
643
|
+
return rest.length === 0 ? (place.callback.port.children ?? []).map(field => item(field.key, 'path', `event · ${portSummary(field)}`, field.description ?? undefined)) : [];
|
|
640
644
|
}
|
|
641
645
|
if (first === 'error') return place.inErrorSlot && rest.length === 0 ? fieldItems(recordFields('error'), 'error') : [];
|
|
642
646
|
if (!roots.includes(first)) return [];
|
|
@@ -684,7 +688,7 @@ const placeOf = (env: BsxEnvironment, tag: string | null, attr: string | null, s
|
|
|
684
688
|
const tags = stack.map(element => element.tag);
|
|
685
689
|
const errorAt = tags.lastIndexOf('error');
|
|
686
690
|
return {
|
|
687
|
-
callback: prop?.kind ===
|
|
691
|
+
callback: prop?.port.kind === CALLBACK ? prop : null,
|
|
688
692
|
tag,
|
|
689
693
|
stack,
|
|
690
694
|
inErrorSlot: errorAt > 0 && tags[errorAt - 1] === 'suspense',
|
package/src/bsx/references.ts
CHANGED
|
@@ -9,6 +9,18 @@ import {blokViewFor, defaultBlokView, type BlokView, type SpecComponent} from '.
|
|
|
9
9
|
import {PICK_FUNCTION, TEXT_NODE} from './parse';
|
|
10
10
|
import {AGENTS_ROOT, PICK_VERB, REFERENCE_SEPARATOR} from './expr';
|
|
11
11
|
import {valueFitsPort} from '../spec/locals';
|
|
12
|
+
import {bindingFits, fitOk, fits, literalPort} from '../spec/fit';
|
|
13
|
+
import {
|
|
14
|
+
ASSET,
|
|
15
|
+
bindingWrites,
|
|
16
|
+
CALLBACK,
|
|
17
|
+
CATALOG_ONLY_KINDS,
|
|
18
|
+
OPEN_PORT,
|
|
19
|
+
PORT_KINDS,
|
|
20
|
+
portSummary,
|
|
21
|
+
pythonRepr,
|
|
22
|
+
type SpecPort,
|
|
23
|
+
} from '../spec/ports';
|
|
12
24
|
import {LOCAL_ANY, localDeclared, resolveLocals, type ResolvedLocal} from './infer';
|
|
13
25
|
import {
|
|
14
26
|
blokCatalog,
|
|
@@ -330,8 +342,6 @@ const SUSPENSE = 'suspense';
|
|
|
330
342
|
const ERROR_SLOT = 'error';
|
|
331
343
|
const WHEN_PROP = 'when';
|
|
332
344
|
const BIND_PROP = 'bind';
|
|
333
|
-
const CALLBACK_KIND = 'CALLBACK';
|
|
334
|
-
const ASSET_KIND = 'ASSET';
|
|
335
345
|
const REFETCH_FUNCTION = 'query.refetch';
|
|
336
346
|
const FETCH_MORE_FUNCTION = 'query.fetch_more';
|
|
337
347
|
/** Per query effect, the method BSX writes it as. */
|
|
@@ -367,6 +377,39 @@ const structureMatch = (structure: BlokPortMatch): BlokPortMatch => ({
|
|
|
367
377
|
nullable: structure.nullable ?? null,
|
|
368
378
|
});
|
|
369
379
|
|
|
380
|
+
/** What a resolved path holds, as a catalog port: open where its shape is not known (`match_port`). */
|
|
381
|
+
const matchPort = (match: Match): SpecPort => {
|
|
382
|
+
if (match === null || isOpen(match) || match.kind == null) return OPEN_PORT;
|
|
383
|
+
return {
|
|
384
|
+
kind: match.kind,
|
|
385
|
+
...(match.identifier ? {identifier: match.identifier} : {}),
|
|
386
|
+
...(match.nullable ? {nullable: true} : {}),
|
|
387
|
+
...(match.children?.length ? {children: match.children.map(child => ({key: child.key || ITEM, ...matchPort(child)}))} : {}),
|
|
388
|
+
};
|
|
389
|
+
};
|
|
390
|
+
|
|
391
|
+
/** A local's port (or a field's) as a catalog port; open for ANY or none (`arg_port`). */
|
|
392
|
+
const localSpecPort = (port: BlokScopeLocalPort | null): SpecPort => {
|
|
393
|
+
if (port === null || port.kind === LOCAL_ANY) return OPEN_PORT;
|
|
394
|
+
return {
|
|
395
|
+
kind: port.kind,
|
|
396
|
+
...(port.identifier ? {identifier: port.identifier} : {}),
|
|
397
|
+
...(port.nullable ? {nullable: true} : {}),
|
|
398
|
+
...(port.choices?.length ? {choices: port.choices.map(choice => ({value: choice.value}))} : {}),
|
|
399
|
+
...(port.children?.length ? {children: port.children.map(child => ({key: child.key, ...localSpecPort(child)}))} : {}),
|
|
400
|
+
};
|
|
401
|
+
};
|
|
402
|
+
|
|
403
|
+
/** A catalog port as what a path below it may read: an event's payload field (`catalog_match`). */
|
|
404
|
+
const catalogMatch = (key: string, port: SpecPort): BlokPortMatch => {
|
|
405
|
+
if (port.kind === null || !PORT_KINDS.includes(port.kind) || CATALOG_ONLY_KINDS.has(port.kind)) return openMatch(key);
|
|
406
|
+
if (OPAQUE_KINDS.has(port.kind) && port.kind !== 'UNION') {
|
|
407
|
+
return {key, kind: port.kind, identifier: port.identifier ?? null, nullable: port.nullable || null};
|
|
408
|
+
}
|
|
409
|
+
const children = (port.children ?? []).map(child => catalogMatch(child.key, child));
|
|
410
|
+
return {key, kind: port.kind, nullable: port.nullable || null, children: children.length ? children : null};
|
|
411
|
+
};
|
|
412
|
+
|
|
370
413
|
const taskRecordMatch = (key: string, returns?: readonly BlokPortMatch[] | null): BlokPortMatch =>
|
|
371
414
|
recordMatch(
|
|
372
415
|
key,
|
|
@@ -506,14 +549,6 @@ const pythonFloat = (value: number): string => {
|
|
|
506
549
|
|
|
507
550
|
const article = (kind: string): string => ('aeiou'.includes(kind[0] ?? '') ? 'n' : '');
|
|
508
551
|
|
|
509
|
-
const pythonRepr = (value: unknown): string => {
|
|
510
|
-
if (typeof value === 'string') return `'${value}'`;
|
|
511
|
-
if (value === null || value === undefined) return 'None';
|
|
512
|
-
if (value === true) return 'True';
|
|
513
|
-
if (value === false) return 'False';
|
|
514
|
-
return JSON.stringify(value);
|
|
515
|
-
};
|
|
516
|
-
|
|
517
552
|
const what = (prop: BlokComponentProp): string => {
|
|
518
553
|
if (prop.agent_call) return 'a task call';
|
|
519
554
|
if (prop.util_call) return prop.util_call.operation;
|
|
@@ -983,7 +1018,8 @@ class Checker {
|
|
|
983
1018
|
|
|
984
1019
|
private walkProp(node: BlokComponentNode, prop: BlokComponentProp, scope: Scope, inError: boolean): void {
|
|
985
1020
|
const where: Where = {node, key: prop.key, callback: isCallbackValue(prop), inError};
|
|
986
|
-
|
|
1021
|
+
const path = prop.dynamic_value?.path;
|
|
1022
|
+
if (path != null) this.checkValueType(where, path, this.resolve(path, where, scope, whereText(where)));
|
|
987
1023
|
if (prop.agent_call) {
|
|
988
1024
|
this.visitAgentCall(prop.agent_call, where, scope);
|
|
989
1025
|
prop.agent_call.arguments?.forEach(argument => this.walkArgument(argument, scope, where));
|
|
@@ -1110,20 +1146,14 @@ class Checker {
|
|
|
1110
1146
|
const hasValue =
|
|
1111
1147
|
prop.static_value != null || prop.dynamic_value != null || prop.util_call != null || prop.agent_call != null;
|
|
1112
1148
|
if (propSpec) {
|
|
1113
|
-
|
|
1149
|
+
const kind = propSpec.port.kind;
|
|
1150
|
+
if (kind === CALLBACK && hasValue && !holds) {
|
|
1114
1151
|
this.add('callback.unbound', node.id, {key: prop.key, component: node.component}, prop.key);
|
|
1115
|
-
} else if (
|
|
1152
|
+
} else if (kind !== CALLBACK && holds) {
|
|
1116
1153
|
this.add('callback.not_callback', node.id, {key: prop.key, component: node.component, what: what(prop)}, prop.key);
|
|
1117
1154
|
}
|
|
1118
|
-
if (
|
|
1119
|
-
|
|
1120
|
-
'props.literal_type',
|
|
1121
|
-
node.id,
|
|
1122
|
-
{component: node.component, key: prop.key, value: prop.static_value, kind: propSpec.kind, hint: literalHint(prop.key, prop.static_value, propSpec.kind)},
|
|
1123
|
-
prop.key,
|
|
1124
|
-
);
|
|
1125
|
-
}
|
|
1126
|
-
if (propSpec.kind === ASSET_KIND) {
|
|
1155
|
+
if (prop.static_value != null && prop.key !== BIND_PROP && !CATALOG_ONLY_KINDS.has(kind ?? '')) this.checkLiteral(node, prop, propSpec.port);
|
|
1156
|
+
if (kind === ASSET) {
|
|
1127
1157
|
const parts = (prop.dynamic_value?.path ?? '').split('.');
|
|
1128
1158
|
const agent = parts[0] === 'self' ? parts.slice(1) : parts[0] === 'deps' ? parts.slice(2) : [];
|
|
1129
1159
|
if (agent.length !== 2 || agent[0] !== vocabulary.agentSegments.assets) {
|
|
@@ -1155,7 +1185,7 @@ class Checker {
|
|
|
1155
1185
|
} else if (!isLocalBinding(binding)) this.add('local.unknown', node.id, {path, root}, prop.key);
|
|
1156
1186
|
else {
|
|
1157
1187
|
this.boundLocals.add(binding.node);
|
|
1158
|
-
if (propSpec) this.checkBindKind(node, propSpec.
|
|
1188
|
+
if (propSpec) this.checkBindKind(node, bindingWrites(propSpec.port), binding, path);
|
|
1159
1189
|
}
|
|
1160
1190
|
}
|
|
1161
1191
|
}
|
|
@@ -1177,17 +1207,72 @@ class Checker {
|
|
|
1177
1207
|
}
|
|
1178
1208
|
}
|
|
1179
1209
|
|
|
1180
|
-
/** The local a control writes
|
|
1181
|
-
private checkBindKind(node: BlokComponentNode,
|
|
1182
|
-
const
|
|
1183
|
-
const
|
|
1184
|
-
if (
|
|
1185
|
-
|
|
1210
|
+
/** The local a control writes takes what the control writes (`Slider`: FLOAT or INT). */
|
|
1211
|
+
private checkBindKind(node: BlokComponentNode, writes: SpecPort, binding: LocalBinding, path: string): void {
|
|
1212
|
+
const local = localSpecPort(this.localPort(binding, path));
|
|
1213
|
+
const {bindKinds} = this.vocabulary.locals;
|
|
1214
|
+
if (fitOk(bindingFits(local, writes, bindKinds))) return;
|
|
1215
|
+
const allowed = bindKinds[writes.kind ?? ''];
|
|
1216
|
+
this.add(
|
|
1217
|
+
'local.bind_kind',
|
|
1218
|
+
node.id,
|
|
1219
|
+
{
|
|
1220
|
+
key: BIND_PROP,
|
|
1221
|
+
component: node.component,
|
|
1222
|
+
prop_kind: portSummary(writes),
|
|
1223
|
+
path,
|
|
1224
|
+
kind: portSummary(local),
|
|
1225
|
+
kinds: allowed ? [...allowed].sort().join(', ') : portSummary(writes),
|
|
1226
|
+
},
|
|
1227
|
+
BIND_PROP,
|
|
1228
|
+
);
|
|
1229
|
+
}
|
|
1230
|
+
|
|
1231
|
+
/** A literal fits the prop's port: its kind (`fullWidth="true"` is a string), then its choices. */
|
|
1232
|
+
private checkLiteral(node: BlokComponentNode, prop: BlokComponentProp, target: SpecPort): void {
|
|
1233
|
+
const value = prop.static_value;
|
|
1234
|
+
const literal = literalPort(value);
|
|
1235
|
+
const kindOnly: SpecPort = {kind: literal.kind, ...(literal.nullable ? {nullable: true} : {})};
|
|
1236
|
+
const kindFit = fits(kindOnly, target);
|
|
1237
|
+
if (fitOk(kindFit)) {
|
|
1238
|
+
if (!fitOk(fits(literal, target)) && target.choices) {
|
|
1239
|
+
this.add(
|
|
1240
|
+
'catalog.value',
|
|
1241
|
+
node.id,
|
|
1242
|
+
{component: node.component, key: prop.key, value: value as string, values: target.choices.map(choice => String(choice.value)).join(', ')},
|
|
1243
|
+
prop.key,
|
|
1244
|
+
);
|
|
1245
|
+
}
|
|
1246
|
+
return;
|
|
1247
|
+
}
|
|
1248
|
+
if (typeof value === 'string' && target.kind !== null && LITERAL_KINDS.includes(target.kind)) {
|
|
1186
1249
|
this.add(
|
|
1187
|
-
'
|
|
1250
|
+
'props.literal_type',
|
|
1188
1251
|
node.id,
|
|
1189
|
-
{
|
|
1190
|
-
|
|
1252
|
+
{component: node.component, key: prop.key, value, kind: target.kind, hint: literalHint(prop.key, value, target.kind)},
|
|
1253
|
+
prop.key,
|
|
1254
|
+
);
|
|
1255
|
+
return;
|
|
1256
|
+
}
|
|
1257
|
+
this.add(
|
|
1258
|
+
'props.type',
|
|
1259
|
+
node.id,
|
|
1260
|
+
{component: node.component, key: prop.key, value: pythonRepr(value), expected: portSummary(target), reason: kindFit.reason ?? ''},
|
|
1261
|
+
prop.key,
|
|
1262
|
+
);
|
|
1263
|
+
}
|
|
1264
|
+
|
|
1265
|
+
/** A path that is a prop's whole value holds what the prop takes. */
|
|
1266
|
+
private checkValueType(where: Where, path: string, match: Match): void {
|
|
1267
|
+
const propSpec = this.view?.components.get(where.node.component)?.props.find(candidate => candidate.key === where.key);
|
|
1268
|
+
if (!propSpec || match === null || where.key === BIND_PROP || CATALOG_ONLY_KINDS.has(propSpec.port.kind ?? '')) return;
|
|
1269
|
+
const fit = fits(matchPort(match), propSpec.port);
|
|
1270
|
+
if (fit.status === 'mismatch') {
|
|
1271
|
+
this.add(
|
|
1272
|
+
'props.type',
|
|
1273
|
+
where.node.id,
|
|
1274
|
+
{component: where.node.component, key: where.key, value: path, expected: portSummary(propSpec.port), reason: fit.reason ?? ''},
|
|
1275
|
+
where.key,
|
|
1191
1276
|
);
|
|
1192
1277
|
}
|
|
1193
1278
|
}
|
|
@@ -1444,7 +1529,7 @@ class Checker {
|
|
|
1444
1529
|
report('roots.event_outside_callback', {path});
|
|
1445
1530
|
return null;
|
|
1446
1531
|
}
|
|
1447
|
-
return this.eventField(rest, where);
|
|
1532
|
+
return this.eventField(rest, path, where);
|
|
1448
1533
|
}
|
|
1449
1534
|
if (root === 'error') {
|
|
1450
1535
|
if (!where || !where.inError) {
|
|
@@ -1562,11 +1647,13 @@ class Checker {
|
|
|
1562
1647
|
}
|
|
1563
1648
|
}
|
|
1564
1649
|
|
|
1565
|
-
private eventField(rest: readonly string[], where: Where): Match {
|
|
1650
|
+
private eventField(rest: readonly string[], path: string, where: Where): Match {
|
|
1566
1651
|
const prop = this.view?.components.get(where.node.component)?.props.find(candidate => candidate.key === where.key);
|
|
1567
|
-
if (!prop || prop.
|
|
1568
|
-
const
|
|
1569
|
-
|
|
1652
|
+
if (!prop || prop.port.kind !== CALLBACK || !rest.length) return openMatch('event');
|
|
1653
|
+
const children = prop.port.children ?? [];
|
|
1654
|
+
const fields = children.map(field => field.key);
|
|
1655
|
+
const field = children.find(candidate => candidate.key === rest[0]);
|
|
1656
|
+
if (!field) {
|
|
1570
1657
|
this.add(
|
|
1571
1658
|
'callback.event_field',
|
|
1572
1659
|
where.node.id,
|
|
@@ -1575,7 +1662,7 @@ class Checker {
|
|
|
1575
1662
|
);
|
|
1576
1663
|
return null;
|
|
1577
1664
|
}
|
|
1578
|
-
return
|
|
1665
|
+
return this.descend(catalogMatch(field.key, field), rest.slice(1), path, where.node.id, where.key);
|
|
1579
1666
|
}
|
|
1580
1667
|
|
|
1581
1668
|
/** What a path below an agent (`self`, `deps.<key>`) holds. */
|
|
@@ -13,6 +13,8 @@ import {
|
|
|
13
13
|
numberSchema,
|
|
14
14
|
spacingSchema,
|
|
15
15
|
textAlignSchema,
|
|
16
|
+
CHART_ROWS_PORT,
|
|
17
|
+
typedAs,
|
|
16
18
|
} from '../props';
|
|
17
19
|
import {iconNameSchema} from './icons';
|
|
18
20
|
|
|
@@ -205,8 +207,7 @@ export const dataContracts = {
|
|
|
205
207
|
.enum(['line', 'bar', 'area', 'pie'])
|
|
206
208
|
.optional()
|
|
207
209
|
.describe('Chart kind. Defaults to "line".'),
|
|
208
|
-
data: z
|
|
209
|
-
.array(z.record(z.string(), z.unknown()))
|
|
210
|
+
data: typedAs(z.array(z.record(z.string(), z.unknown())), CHART_ROWS_PORT)
|
|
210
211
|
.optional()
|
|
211
212
|
.describe('One object per point, keyed by category and series key.'),
|
|
212
213
|
categoryKey: z
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as z from 'zod';
|
|
2
2
|
import type {BlokComponentContracts} from '../../renderer/runtime/catalog';
|
|
3
|
-
import {describedString} from '../props';
|
|
3
|
+
import {describedString, KEYS_PORT, MATRIX_PORT, typedAs} from '../props';
|
|
4
4
|
import {sceneSchema} from './scene';
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -35,8 +35,7 @@ export const placedSchema = z
|
|
|
35
35
|
blok: describedString(
|
|
36
36
|
'The scene blok of that agent to draw it with, by name. Its default scene blok when left out.',
|
|
37
37
|
),
|
|
38
|
-
matrix: z
|
|
39
|
-
.unknown()
|
|
38
|
+
matrix: typedAs(z.unknown(), MATRIX_PORT)
|
|
40
39
|
.optional()
|
|
41
40
|
.describe(
|
|
42
41
|
'Where it stands until someone moves it: a 4x4 affine matrix as four rows, in meters with Y up. The room\'s origin when left out.',
|
|
@@ -48,10 +47,13 @@ export const placedSchema = z
|
|
|
48
47
|
|
|
49
48
|
export const routeSchema = z
|
|
50
49
|
.object({
|
|
51
|
-
through:
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
50
|
+
through: typedAs(
|
|
51
|
+
z
|
|
52
|
+
.unknown()
|
|
53
|
+
.refine(value => value !== undefined, 'A Route runs through dependencies.')
|
|
54
|
+
.describe('The dependency keys the line runs through, in order: `through={["robot", "frame", "robot"]}`.'),
|
|
55
|
+
KEYS_PORT,
|
|
56
|
+
),
|
|
55
57
|
progress: z
|
|
56
58
|
.number()
|
|
57
59
|
.nullish()
|
|
@@ -2,7 +2,7 @@ import * as z from 'zod';
|
|
|
2
2
|
import type {BlokComponentContracts} from '../../renderer/runtime/catalog';
|
|
3
3
|
import type {BlokComponentPlacement} from '../../renderer/runtime/components';
|
|
4
4
|
import {markBindSchema} from '../../renderer/runtime/schemas';
|
|
5
|
-
import {actionProp, bindSchema, describedString} from '../props';
|
|
5
|
+
import {actionProp, AMOUNT_PORT, bindSchema, describedString, JOINTS_PORT, MATRIX_PORT, PER_JOINT_PORT, typedAs} from '../props';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* The 3D vocabulary: three containers place models, a transform places what
|
|
@@ -55,9 +55,7 @@ export const modelSchema = z
|
|
|
55
55
|
'Places one GLB model in the scene. Its children bind the model\'s named nodes to state. A model that is missing or refused renders a placeholder that says why.',
|
|
56
56
|
);
|
|
57
57
|
|
|
58
|
-
const jointValues = z
|
|
59
|
-
.record(z.string(), z.unknown())
|
|
60
|
-
.optional();
|
|
58
|
+
const jointValues = typedAs(z.record(z.string(), z.unknown()), JOINTS_PORT).optional();
|
|
61
59
|
|
|
62
60
|
export const robotSchema = z
|
|
63
61
|
.object({
|
|
@@ -66,12 +64,10 @@ export const robotSchema = z
|
|
|
66
64
|
'Where each joint is: a map of joint name to radians (revolute, continuous) or meters (prismatic). A joint left out keeps its last value.',
|
|
67
65
|
),
|
|
68
66
|
animateTo: jointValues.describe('Where each joint is going. Joints named here move at speed, or over duration.'),
|
|
69
|
-
speed: z
|
|
70
|
-
.unknown()
|
|
67
|
+
speed: typedAs(z.unknown(), PER_JOINT_PORT)
|
|
71
68
|
.optional()
|
|
72
69
|
.describe('How fast joints move to animateTo, in rad/s or m/s: one number for all joints or a map by joint name.'),
|
|
73
|
-
duration: z
|
|
74
|
-
.unknown()
|
|
70
|
+
duration: typedAs(z.unknown(), PER_JOINT_PORT)
|
|
75
71
|
.optional()
|
|
76
72
|
.describe('How long a move to animateTo takes, in seconds: one number or a map by joint name. Ignored where speed is given.'),
|
|
77
73
|
onJointChange: actionProp(
|
|
@@ -90,8 +86,7 @@ const MODEL_PROP_KINDS = {src: 'ASSET'} as const;
|
|
|
90
86
|
|
|
91
87
|
export const transformSchema = z
|
|
92
88
|
.object({
|
|
93
|
-
matrix: z
|
|
94
|
-
.unknown()
|
|
89
|
+
matrix: typedAs(z.unknown(), MATRIX_PORT)
|
|
95
90
|
.optional()
|
|
96
91
|
.describe(
|
|
97
92
|
'Where the children stand: a 4x4 affine matrix as four rows, in meters with Y up (as a space placement keeps it). The identity when absent or malformed.',
|
|
@@ -131,12 +126,10 @@ const motionShape = (unit: string, rate: string) => ({
|
|
|
131
126
|
axis: z
|
|
132
127
|
.string()
|
|
133
128
|
.describe('The axis in the node\'s own frame: "x", "y", "z" or a vector as "x y z".'),
|
|
134
|
-
value: z
|
|
135
|
-
.unknown()
|
|
129
|
+
value: typedAs(z.unknown(), AMOUNT_PORT)
|
|
136
130
|
.optional()
|
|
137
131
|
.describe(`Where the part is, in ${unit} from the pose the model was authored in. A quantity ({magnitude, unit}) is converted.`),
|
|
138
|
-
animateTo: z
|
|
139
|
-
.unknown()
|
|
132
|
+
animateTo: typedAs(z.unknown(), AMOUNT_PORT)
|
|
140
133
|
.optional()
|
|
141
134
|
.describe('Where the part is going. With it, the view moves there at speed (or over duration) and value corrects it.'),
|
|
142
135
|
speed: z.number().optional().describe(`How fast it moves to animateTo, in ${rate}.`),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as z from 'zod';
|
|
2
2
|
import type {BlokComponentContracts} from '../../renderer/runtime/catalog';
|
|
3
3
|
import {BlokPropSchemas} from '../../renderer/runtime/schemas';
|
|
4
|
-
import {actionProp, bindSchema, boolSchema, classNameSchema, disabledSchema, sizeSchema, structureValueSchema} from '../props';
|
|
4
|
+
import {actionProp, bindSchema, boolSchema, classNameSchema, disabledSchema, sizeSchema, structureValueSchema, typedAs, VARIABLES_PORT} from '../props';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* the structure family: bloks over other modules' objects, by structure identifier. The
|
|
@@ -35,8 +35,7 @@ export const structureContracts = {
|
|
|
35
35
|
.string()
|
|
36
36
|
.optional()
|
|
37
37
|
.describe('The service that runs `query`, by its key, e.g. "mikro".'),
|
|
38
|
-
variables: z
|
|
39
|
-
.record(z.string(), z.unknown())
|
|
38
|
+
variables: typedAs(z.record(z.string(), z.unknown()), VARIABLES_PORT)
|
|
40
39
|
.nullish()
|
|
41
40
|
.describe('Values for the variables `query` declares beyond the ones the picker supplies.'),
|
|
42
41
|
placeholder: BlokPropSchemas.DynamicString.optional().describe(
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import * as z from 'zod';
|
|
2
2
|
import type {BlokComponentContracts} from '../../renderer/runtime/catalog';
|
|
3
3
|
import {BlokPropSchemas} from '../../renderer/runtime/schemas';
|
|
4
|
+
import {TASK_PORT, typedAs} from '../props';
|
|
4
5
|
|
|
5
6
|
/** `<Toast task={move}>` (the ui family) and its outcome slots `done`, `failed`, `cancelled`. */
|
|
6
7
|
|
|
7
8
|
const toastSchema = z
|
|
8
9
|
.object({
|
|
9
|
-
task:
|
|
10
|
+
task: typedAs(
|
|
11
|
+
z.unknown().refine(value => value !== undefined, 'A Toast follows a task.').describe('The task record to follow: an `into` name of this blok (`task={move}`), or `task`.'),
|
|
12
|
+
TASK_PORT,
|
|
13
|
+
),
|
|
10
14
|
})
|
|
11
15
|
.describe('A notification when a task settles, once per task: its `done`, `failed` and `cancelled` slots hold the text.');
|
|
12
16
|
|