@arkitektio/bsx 6.3.0 → 6.5.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.
- package/dist/bsx/infer.d.ts.map +1 -1
- package/dist/bsx/infer.js +4 -0
- package/dist/bsx/infer.js.map +1 -1
- package/dist/bsx/language.js +3 -3
- package/dist/bsx/language.js.map +1 -1
- package/dist/bsx/parse.d.ts +1 -0
- package/dist/bsx/parse.d.ts.map +1 -1
- package/dist/bsx/parse.js +8 -1
- package/dist/bsx/parse.js.map +1 -1
- package/dist/bsx/print.d.ts.map +1 -1
- package/dist/bsx/print.js +2 -2
- package/dist/bsx/print.js.map +1 -1
- package/dist/bsx/references.d.ts +4 -0
- package/dist/bsx/references.d.ts.map +1 -1
- package/dist/bsx/references.js +47 -2
- package/dist/bsx/references.js.map +1 -1
- package/dist/ports/engine/defaultRegistry.d.ts.map +1 -1
- package/dist/ports/engine/defaultRegistry.js +2 -0
- package/dist/ports/engine/defaultRegistry.js.map +1 -1
- package/dist/ports/host.d.ts +6 -0
- package/dist/ports/host.d.ts.map +1 -1
- package/dist/ports/host.js.map +1 -1
- package/dist/ports/rekuest.d.ts +14 -1
- package/dist/ports/rekuest.d.ts.map +1 -1
- package/dist/ports/rekuest.js +1 -0
- package/dist/ports/rekuest.js.map +1 -1
- package/dist/ports/widgets/custom/PortBlokWidget.d.ts +30 -0
- package/dist/ports/widgets/custom/PortBlokWidget.d.ts.map +1 -0
- package/dist/ports/widgets/custom/PortBlokWidget.js +210 -0
- package/dist/ports/widgets/custom/PortBlokWidget.js.map +1 -0
- package/dist/ports.d.ts +2 -0
- package/dist/ports.d.ts.map +1 -1
- package/dist/ports.js +4 -0
- package/dist/ports.js.map +1 -1
- package/dist/renderer/BlokRenderer.d.ts +4 -1
- package/dist/renderer/BlokRenderer.d.ts.map +1 -1
- package/dist/renderer/BlokRenderer.js +5 -1
- package/dist/renderer/BlokRenderer.js.map +1 -1
- package/dist/renderer/bloks/control.d.ts +5 -0
- package/dist/renderer/bloks/control.d.ts.map +1 -1
- package/dist/renderer/bloks/control.js +41 -6
- package/dist/renderer/bloks/control.js.map +1 -1
- package/dist/renderer/bloks/port/host.d.ts +32 -0
- package/dist/renderer/bloks/port/host.d.ts.map +1 -0
- package/dist/renderer/bloks/port/host.js +14 -0
- package/dist/renderer/bloks/port/host.js.map +1 -0
- package/dist/renderer/runtime/context.d.ts +2 -0
- package/dist/renderer/runtime/context.d.ts.map +1 -1
- package/dist/renderer/runtime/context.js +4 -0
- package/dist/renderer/runtime/context.js.map +1 -1
- package/dist/renderer/runtime/hooks.d.ts.map +1 -1
- package/dist/renderer/runtime/hooks.js +1 -0
- package/dist/renderer/runtime/hooks.js.map +1 -1
- package/dist/renderer/runtime/resolution.d.ts +3 -0
- package/dist/renderer/runtime/resolution.d.ts.map +1 -1
- package/dist/renderer/runtime/resolution.js +17 -1
- package/dist/renderer/runtime/resolution.js.map +1 -1
- package/dist/renderer/runtime/types.d.ts +6 -0
- package/dist/renderer/runtime/types.d.ts.map +1 -1
- package/dist/renderer/runtime/types.js.map +1 -1
- package/dist/spec/bsx_v2.json +1517 -179
- package/dist/spec/catalogs/base@4.json +103 -3
- package/dist/spec/catalogs/base@4.json.js +103 -3
- package/dist/spec/vocabulary.d.ts +5 -1
- package/dist/spec/vocabulary.d.ts.map +1 -1
- package/dist/spec/vocabulary.js +4 -1
- package/dist/spec/vocabulary.js.map +1 -1
- package/dist/spec/vocabulary.json +50 -15
- package/dist/spec/vocabulary.json.js +50 -15
- package/package.json +1 -1
- package/src/bsx/infer.ts +4 -0
- package/src/bsx/language.ts +3 -3
- package/src/bsx/parse.ts +7 -1
- package/src/bsx/print.ts +2 -1
- package/src/bsx/references.test.ts +1 -1
- package/src/bsx/references.ts +45 -2
- package/src/ports/engine/defaultRegistry.tsx +2 -0
- package/src/ports/host.tsx +6 -0
- package/src/ports/rekuest.ts +7 -1
- package/src/ports/widgets/custom/PortBlokWidget.test.tsx +88 -0
- package/src/ports/widgets/custom/PortBlokWidget.tsx +268 -0
- package/src/ports.ts +4 -0
- package/src/renderer/BlokRenderer.tsx +9 -0
- package/src/renderer/bloks/control.tsx +65 -5
- package/src/renderer/bloks/flow.test.tsx +11 -0
- package/src/renderer/bloks/port/host.tsx +46 -0
- package/src/renderer/runtime/context.tsx +6 -0
- package/src/renderer/runtime/hooks.ts +1 -0
- package/src/renderer/runtime/resolution.ts +16 -1
- package/src/renderer/runtime/types.ts +6 -0
- package/src/spec/bsx_v2.json +1517 -179
- package/src/spec/catalogs/base@4.json +103 -3
- package/src/spec/spec.test.ts +8 -4
- package/src/spec/vocabulary.json +50 -15
- package/src/spec/vocabulary.ts +9 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"vocab": 2,
|
|
3
|
-
"minor":
|
|
3
|
+
"minor": 5,
|
|
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": {
|
|
@@ -8,9 +8,10 @@
|
|
|
8
8
|
"deps": "deps.<key>: an agent bound to a dependency of the blok, a custom blok or an action.",
|
|
9
9
|
"queries": "queries.<name>: a declared query's record (status, value, error, refetching, fetching_more).",
|
|
10
10
|
"subscriptions": "subscriptions.<name>: a declared subscription's record (status, value, error); value is the latest payload, or the last `keep` payloads.",
|
|
11
|
-
"args": "args.<key>: what the blok is opened on: the item for an agent or custom blok, the task's args for a task or action blok.",
|
|
11
|
+
"args": "args.<key>: what the blok is opened on: the item for an agent or custom blok, the task's args for a task or action blok, the form's other arguments as they are filled in for a port blok (read only).",
|
|
12
12
|
"task": "The task this blok is about: the sending task, or the run. A task record.",
|
|
13
13
|
"assign": "The run an assign blok prepares: assign.given.<key> (true for an argument the caller decided, which is locked), assign.missing (the keys of required arguments still empty) and assign.ready (nothing is missing).",
|
|
14
|
+
"port": "The port a port blok is the widget of: its value (port.value, which a control writes through bind) and what the form knows of it. A port record.",
|
|
14
15
|
"event": "The payload a component hands its callback. Only inside a callback.",
|
|
15
16
|
"viewer": "{user, org, roles} of whoever is looking.",
|
|
16
17
|
"then": "The moment being viewed while time-travelling (an ISO 8601 datetime), null while live. A blok never reads the wall clock: a query passes then as an ordinary variable (variables={at: \"then\"}), <Time> measures relative time from it, and while it is set subscriptions pause (their history query, or the value at travel start, stale)."
|
|
@@ -22,7 +23,7 @@
|
|
|
22
23
|
"functions": ["cmp", "logic", "math", "str", "list", "obj", "val", "fmt", "time", "ui", "query"],
|
|
23
24
|
"future": ["mutations"]
|
|
24
25
|
},
|
|
25
|
-
"reserved": ["self", "deps", "queries", "subscriptions", "args", "task", "assign", "event", "viewer", "then", "error", "cmp", "logic", "math", "str", "list", "obj", "val", "fmt", "time", "ui", "query", "mutations"],
|
|
26
|
+
"reserved": ["self", "deps", "queries", "subscriptions", "args", "task", "assign", "port", "event", "viewer", "then", "error", "cmp", "logic", "math", "str", "list", "obj", "val", "fmt", "time", "ui", "query", "mutations"],
|
|
26
27
|
"agent_segments": {
|
|
27
28
|
"description": "What follows an agent (self or deps.<key>): .<state>.<field> is state, .tasks.<action> the latest task of that action, .assets.<name> one of the agent's assets; deps.<key>.<action>(...) calls it.",
|
|
28
29
|
"tasks": "tasks",
|
|
@@ -61,6 +62,13 @@
|
|
|
61
62
|
"roots": ["self", "deps", "args", "assign", "queries", "subscriptions", "viewer"],
|
|
62
63
|
"locals": true,
|
|
63
64
|
"contexts": ["PANEL", "SCENE"]
|
|
65
|
+
},
|
|
66
|
+
"port": {
|
|
67
|
+
"description": "A port's own widget, declared with the port: drawn in the action's form where the port's control would be. It is a field of that form: it reads the port, the form's other arguments as args and the state of the agents a run would get, and writes the port's value and nothing else. It calls no agent.",
|
|
68
|
+
"roots": ["self", "deps", "args", "port", "queries", "subscriptions", "viewer"],
|
|
69
|
+
"locals": true,
|
|
70
|
+
"contexts": ["PANEL"],
|
|
71
|
+
"calls": false
|
|
64
72
|
}
|
|
65
73
|
},
|
|
66
74
|
"contexts": {
|
|
@@ -72,7 +80,7 @@
|
|
|
72
80
|
"description": "Every blok is one <Blok> element that says what it is: its kind (what it reads, and where it may be mounted), its context (what host draws it), the catalog it is written for and whether the host draws its own chrome around it. What the blok owns is declared inside it (<local>, <query>, <subscription>); what its mount provides (deps, args, task, self's actions) is checked only where it is mounted.",
|
|
73
81
|
"component": "Blok",
|
|
74
82
|
"attributes": {
|
|
75
|
-
"kind": "Required: agent, custom, task, action or
|
|
83
|
+
"kind": "Required: agent, custom, task, action, assign or port (a row of kinds).",
|
|
76
84
|
"context": "Required: panel, scene or logo.",
|
|
77
85
|
"catalog": "The catalog it is written for (the address it is published at, or the name of one registered in the organization); the base catalog when left out.",
|
|
78
86
|
"chrome": "\"none\": the host draws none of its own interface around the blok (panel and scene only)."
|
|
@@ -152,6 +160,26 @@
|
|
|
152
160
|
{"key": "blocked", "kind": "STRING", "nullable": true, "description": "Why the run cannot start now, as a sentence (a dependency is not met, no agent fits); null when it can."}
|
|
153
161
|
]
|
|
154
162
|
},
|
|
163
|
+
"port": {
|
|
164
|
+
"description": "What a port blok knows of the port it draws: its value, what the port declares, and where it stands in the form. Everything but value is the form's to say: a port blok sets no error and no flag.",
|
|
165
|
+
"fields": [
|
|
166
|
+
{"key": "value", "kind": "ANY", "nullable": true, "description": "The port's value as the form holds it, typed as the port; null while nothing is given. The one thing a port blok writes: a control through bind={port.value}, a callback with port.set(...)."},
|
|
167
|
+
{"key": "key", "kind": "STRING", "description": "The port's key."},
|
|
168
|
+
{"key": "label", "kind": "STRING", "nullable": true, "description": "What the form calls the port."},
|
|
169
|
+
{"key": "description", "kind": "STRING", "nullable": true},
|
|
170
|
+
{"key": "kind", "kind": "STRING", "description": "The port's kind (FLOAT, STRUCTURE, ...)."},
|
|
171
|
+
{"key": "identifier", "kind": "STRING", "nullable": true, "description": "The structure's identifier, for a STRUCTURE port."},
|
|
172
|
+
{"key": "nullable", "kind": "BOOL", "description": "Whether the port may be left empty."},
|
|
173
|
+
{"key": "default", "kind": "ANY", "nullable": true, "description": "What port.reset() goes back to."},
|
|
174
|
+
{"key": "choices", "kind": "LIST", "description": "The choices the port declares, each {value, label, description}; empty when it declares none."},
|
|
175
|
+
{"key": "unit", "kind": "STRING", "nullable": true, "description": "The unit a QUANTITY port's value is in."},
|
|
176
|
+
{"key": "editable", "kind": "BOOL", "description": "False where the value is only shown: the caller decided it, the form is locked or sent. A control bound to the port is then disabled, and port.set does nothing."},
|
|
177
|
+
{"key": "error", "kind": "STRING", "nullable": true, "description": "What the form says is wrong with the value, by the port's own rules (required, its kind, its validators); null when nothing is, or nothing was checked yet."},
|
|
178
|
+
{"key": "invalid", "kind": "BOOL", "description": "True while error is set."},
|
|
179
|
+
{"key": "touched", "kind": "BOOL", "description": "True once the viewer left the field (a bound control lost focus, or port.touch())."},
|
|
180
|
+
{"key": "dirty", "kind": "BOOL", "description": "True once the value differs from what the form opened with."}
|
|
181
|
+
]
|
|
182
|
+
},
|
|
155
183
|
"viewer": {
|
|
156
184
|
"description": "Exposes nothing beyond what the viewer's own token says.",
|
|
157
185
|
"fields": [
|
|
@@ -175,7 +203,7 @@
|
|
|
175
203
|
"stale": "Known, but the source stopped updating (agent offline): the last value, flagged.",
|
|
176
204
|
"failed": "Cannot be known (no access, agent gone, query error), with an error."
|
|
177
205
|
},
|
|
178
|
-
"always_ready": ["locals", "event", "let", "literals"],
|
|
206
|
+
"always_ready": ["locals", "event", "let", "index", "literals"],
|
|
179
207
|
"propagation": [
|
|
180
208
|
"If any input of an expression is pending, the result is pending; else if any failed, the result is failed; else if any is stale, the result is stale.",
|
|
181
209
|
"logic.choose and <if> read only the branch taken; logic.all and logic.any stop at the first operand that decides them.",
|
|
@@ -187,7 +215,7 @@
|
|
|
187
215
|
]
|
|
188
216
|
},
|
|
189
217
|
"functions": {
|
|
190
|
-
"description": "Pure functions by namespace, snake_case. Positional arguments map onto params in order. `lazy`: arguments are read only as needed. `effect`: allowed only as a callback's one thing (ui.*, task.*, assign.start, query.*). `command`: an effect that changes the world (it acts on a task or starts one, and is recorded with it); an effect without it only changes what the viewer sees. A blok does nothing else: every other function is pure. `sees_status`: sees pending/failed instead of suspending. No function reads the wall clock. `null` says what the function does with a null argument (known absence); a missing path reads as null.",
|
|
218
|
+
"description": "Pure functions by namespace, snake_case. Positional arguments map onto params in order. `lazy`: arguments are read only as needed. `effect`: allowed only as a callback's one thing (ui.*, task.*, assign.start, port.*, query.*). `needs`: the root a blok's kind must read to hold the effect (port.set needs port). `command`: an effect that changes the world (it acts on a task or starts one, and is recorded with it); an effect without it only changes what the viewer sees. A blok does nothing else: every other function is pure. `sees_status`: sees pending/failed instead of suspending. No function reads the wall clock. `null` says what the function does with a null argument (known absence); a missing path reads as null.",
|
|
191
219
|
"cmp.eq": {"params": [["a", "ANY"], ["b", "ANY"]], "returns": "BOOL", "description": "Deep JSON equality.", "null": "null equals only null"},
|
|
192
220
|
"cmp.ne": {"params": [["a", "ANY"], ["b", "ANY"]], "returns": "BOOL", "description": "Not deep-equal.", "null": "null equals only null"},
|
|
193
221
|
"cmp.gt": {"params": [["a", "ANY"], ["b", "ANY"]], "returns": "BOOL", "description": "a > b, numbers or strings.", "null": "false"},
|
|
@@ -313,6 +341,10 @@
|
|
|
313
341
|
"task.step": {"params": [], "returns": "ANY", "effect": true, "command": true, "task_operation": true, "description": "Resumes the run `task` is about until its next breakpoint. Refused while `task.can.step` is false, and while the blok shows the past. Counts as a task operation.", "null": "takes no arguments"},
|
|
314
342
|
"task.interrupt": {"params": [], "returns": "ANY", "effect": true, "command": true, "task_operation": true, "description": "Interrupts the run `task` is about: stopped at once, without waiting for it to wind down. Refused while `task.can.interrupt` is false, and while the blok shows the past. Counts as a task operation.", "null": "takes no arguments"},
|
|
315
343
|
"assign.start": {"params": [], "returns": "ANY", "effect": true, "command": true, "description": "Starts the run an assign blok prepares, with the arguments as they are filled in and the agents the blok was shown (deps) pinned. An assign blok only.", "null": "starts the run"},
|
|
344
|
+
"port.set": {"params": [["value", "ANY"]], "returns": "ANY", "effect": true, "needs": "port", "description": "Sets the port's value, as a control bound to it would: the form marks it dirty and checks it. A port blok only.", "null": "sets the port to empty, as port.clear() does"},
|
|
345
|
+
"port.clear": {"params": [], "returns": "ANY", "effect": true, "needs": "port", "description": "Empties the port: nothing is given for it. A port blok only.", "null": "takes no arguments"},
|
|
346
|
+
"port.reset": {"params": [], "returns": "ANY", "effect": true, "needs": "port", "description": "Puts the port back to what the form opened with (port.default when nothing was given), and clears touched and dirty. A port blok only.", "null": "takes no arguments"},
|
|
347
|
+
"port.touch": {"params": [], "returns": "ANY", "effect": true, "needs": "port", "description": "Says the viewer left the field: what a bound control says itself when it loses focus, for a control drawn by hand. A port blok only.", "null": "takes no arguments"},
|
|
316
348
|
"query.refetch": {"params": [["query", "STRING"]], "returns": "ANY", "effect": true, "description": "Re-reads the declared query named by the literal `query`; never suspends, queries.<name>.refetching is true meanwhile. BSX writes it queries.<name>.refetch().", "null": "refused: the query is named by a literal"},
|
|
317
349
|
"query.fetch_more": {"params": [["query", "STRING"], ["variables", "DICT", false]], "returns": "ANY", "effect": true, "description": "Reads the next page of the declared query named by the literal `query`, its variables overridden by `variables`, and appends the page's list at the query's `more` field to what is shown; queries.<name>.fetching_more is true meanwhile. BSX writes it queries.<name>.fetch_more(name: value, ...). Refused on a query without `more`.", "null": "refused: the query is named by a literal; null variables fetch with the query's own"}
|
|
318
350
|
},
|
|
@@ -326,8 +358,8 @@
|
|
|
326
358
|
"calls": {
|
|
327
359
|
"description": "What a prop or an argument may hold besides a literal, a path or a util call.",
|
|
328
360
|
"kinds": {
|
|
329
|
-
"agent_call": "A task call: self.<action>(...) or deps.<key>.<action>(...), only as a callback's one thing, optionally named with `into <name>` (stored as the prop's declares_value).",
|
|
330
|
-
"util_call": "A pure function, or an effect (ui.copy, task.answer, assign.start, query.refetch, query.fetch_more) as a callback's one thing."
|
|
361
|
+
"agent_call": "A task call: self.<action>(...) or deps.<key>.<action>(...), only as a callback's one thing, optionally named with `into <name>` (stored as the prop's declares_value). A kind that says calls: false (a port blok) holds none.",
|
|
362
|
+
"util_call": "A pure function, or an effect (ui.copy, task.answer, assign.start, port.set, query.refetch, query.fetch_more) as a callback's one thing."
|
|
331
363
|
},
|
|
332
364
|
"reserved_kinds": {
|
|
333
365
|
"service_call": "Reserved for mutations, should they ever exist. Renderers refuse a call kind they do not know."
|
|
@@ -340,7 +372,7 @@
|
|
|
340
372
|
"description": "How a v2 blok is stored: ComponentNodeInput {id, component, props?, children?}; ComponentPropInput {key, static_value? | dynamic_value {path} | util_call | agent_call (+ declares_value)}; ActionArgumentInput {key?, value_literal? | value_path? | util_call? | value_list? | value_dict?}. A prop or argument with no value field is null.",
|
|
341
373
|
"ids": "An explicit id matches explicit_id; a derived id is the parent's id plus /<Component>[<n>] (n: occurrence among same-named siblings), the root's <Component>[0]. A derived id always ends in ']'. A text node is <parent>/#<n> (n: text-run index) and nothing may target it.",
|
|
342
374
|
"explicit_id": "^[A-Za-z_][A-Za-z0-9_.:-]*$",
|
|
343
|
-
"foreach": "foreach props: items (expression), let (static_value and declares_value the name), key (expression, optional). With a key each item's subtree takes its runtime ids from it: <id>@<key>; without one, from its position: <id>@#<n> (n: the 0-based index). A foreach without key is stored with no key prop at all; the validator warns foreach.position_key when its items are known not to be scalars.",
|
|
375
|
+
"foreach": "foreach props: items (expression), let (static_value and declares_value the name), index (optional; static_value and declares_value the name: an INT, the item's 0-based position in items, in scope where let is), key (expression, optional). With a key each item's subtree takes its runtime ids from it: <id>@<key>; without one, from its position: <id>@#<n> (n: the 0-based index). A foreach without key is stored with no key prop at all; the validator warns foreach.position_key when its items are known not to be scalars.",
|
|
344
376
|
"if": "if props: when; children: the then-branch, then the else nodes (component else, an else-if with a when prop; only the last else may lack when).",
|
|
345
377
|
"into": "agent_call prop with declares_value <name>: a task record only that call writes. Allowed inside foreach; one name is written by one call site.",
|
|
346
378
|
"text": "Text is a child like any other: each run of text between elements is stored as a node {id: <parent>/#<n>, component: \"#text\", props: [value]}, its value a literal or an expression; several parts of one run desugar to str.template(template, values). No element can be called #text, so only text makes one. Parsing needs no catalog. What a component does with its text is its renderer's: one with a text_prop makes its text children that prop (a Button its label), any other that takes children draws them in place; a component that sets its text_prop as an attribute too, or takes neither text nor children, is a catalog finding (catalog.text). A tree stored before text was a node holds the text_prop itself, and implicit Text or span nodes under the same ids: a renderer draws both."
|
|
@@ -401,7 +433,7 @@
|
|
|
401
433
|
"name": "^[A-Za-z_][A-Za-z0-9_.-]*$",
|
|
402
434
|
"host_parts": {
|
|
403
435
|
"description": "Parts of the host's own interface a blok may place itself: placing one anywhere in the tree claims it, and the host then draws none of its own. The claim is read off the stored tree, so a part inside an inactive <if> still claims it (part.conditional). What a blok does not place, the host still draws, unless its root says chrome=\"none\".",
|
|
404
|
-
"parts": ["args", "arg", "deps", "dep", "ask", "returns", "status", "timeline"]
|
|
436
|
+
"parts": ["args", "arg", "deps", "dep", "ask", "returns", "status", "timeline", "label", "description", "message", "control", "field"]
|
|
405
437
|
}
|
|
406
438
|
},
|
|
407
439
|
"classes": {
|
|
@@ -424,7 +456,8 @@
|
|
|
424
456
|
"bsx.text_callback": {"level": "error", "message": "Text holds a call or an effect; only a callback prop may.", "hint": "Put the call in a callback prop (onClick={{...}}), never between tags."},
|
|
425
457
|
"bsx.else_outside_if": {"level": "error", "message": "<else> is a child of <if>, after its then-branch.", "hint": "Move the <else> inside its <if>, after the then-branch children."},
|
|
426
458
|
"bsx.else_order": {"level": "error", "message": "<else> comes after the then-branch, and only the last <else> may lack when.", "hint": "Put the <else> branches last in the <if>; only the final one may leave out when."},
|
|
427
|
-
"bsx.foreach": {"level": "error", "message": "<foreach> needs items={{...}} and let=\"name\" (key={{...}}
|
|
459
|
+
"bsx.foreach": {"level": "error", "message": "<foreach> needs items={{...}} and let=\"name\" (key={{...}} and index=\"name\" are optional): {missing}."},
|
|
460
|
+
"bsx.index": {"level": "error", "message": "index={index!r} is not a name.", "hint": "Write index=\"i\": a plain identifier the children read as the item's position, from 0."},
|
|
428
461
|
"bsx.let": {"level": "error", "message": "let={let!r} is not a name.", "hint": "Write let=\"name\": a plain identifier the children read as name.field."},
|
|
429
462
|
"expr.syntax": {"level": "error", "message": "{detail}", "hint": "Expressions are a JavaScript subset: paths, literals, calls with name: value arguments, == != > >= < <=, && || !, ?? and c ? a : b."},
|
|
430
463
|
"expr.arithmetic": {"level": "error", "message": "{operator} is not an operator of the blok language; call math.{function}(a, b)."},
|
|
@@ -443,11 +476,11 @@
|
|
|
443
476
|
"callback.positional": {"level": "error", "message": "{call}: a task call names its arguments (name: value)."},
|
|
444
477
|
"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>."},
|
|
445
478
|
"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."},
|
|
446
|
-
"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).", "hint": "Give {key} a task call (deps.<key>.<action>(name: value)) or one effect, not a value."},
|
|
479
|
+
"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."},
|
|
447
480
|
"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}."},
|
|
448
|
-
"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 an into record."},
|
|
481
|
+
"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."},
|
|
449
482
|
"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."},
|
|
450
|
-
"roots.reserved": {"level": "error", "message": "{name!r} is reserved: no local, let or into may use it."},
|
|
483
|
+
"roots.reserved": {"level": "error", "message": "{name!r} is reserved: no local, let, index or into may use it."},
|
|
451
484
|
"roots.shadow": {"level": "error", "message": "{name!r} is declared twice: as {first} and as {second}."},
|
|
452
485
|
"roots.event_outside_callback": {"level": "error", "message": "{path} reads event outside a callback.", "hint": "Read event only inside a callback prop; outside one, bind a control to a local and read the local."},
|
|
453
486
|
"roots.error_outside_boundary": {"level": "error", "message": "{path} reads error outside an <error> slot.", "hint": "Read error only inside the <error> slot of a <suspense>."},
|
|
@@ -461,6 +494,7 @@
|
|
|
461
494
|
"args.unknown": {"level": "error", "message": "{path} reads args.{key}, which the blok does not declare (declared: {keys}).", "hint": "Read one of the declared args, or declare args.{key} (only when the user asks what the blok is opened for)."},
|
|
462
495
|
"into.twice": {"level": "error", "message": "{name!r} is written by two calls: {first} and {second}. Each call site needs a record of its own."},
|
|
463
496
|
"local.unknown": {"level": "error", "message": "bind={{{path}}} writes {root!r}, which is no declared local.", "hint": "Declare {root!r} in locals (its default, or null), then bind it."},
|
|
497
|
+
"port.bind": {"level": "error", "message": "bind={{{path}}}: a port blok writes port.value and nothing else of its port.", "hint": "Write bind={{port.value}}; what the form knows of the port (its label, its error) is the form's to say."},
|
|
464
498
|
"local.bind": {"level": "error", "message": "bind holds a local's path ({{name}} or {{name.field}}), not {what}.", "hint": "Write bind={{name}} with a declared local's name."},
|
|
465
499
|
"local.default": {"level": "error", "message": "local {name!r}: its default {default!r} is not a {kind}.", "hint": "Give a default of that kind, or leave the kind out so the default sets it."},
|
|
466
500
|
"local.kind": {"level": "error", "message": "local {name!r}: type={type!r} is a name, not an annotation; give the type itself (int, list[str], a registered structure)."},
|
|
@@ -493,11 +527,12 @@
|
|
|
493
527
|
"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}})."},
|
|
494
528
|
"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."},
|
|
495
529
|
"blok.root": {"level": "error", "message": "A blok is one <Blok kind=... context=...> element, not <{component}>.", "hint": "Wrap it: <Blok kind=\"agent\" context=\"panel\">...</Blok>."},
|
|
496
|
-
"blok.attribute": {"level": "error", "message": "<Blok> {problem}.", "hint": "Write kind=\"agent|custom|task|action|assign\" and context=\"panel|scene|logo\" as literals."},
|
|
530
|
+
"blok.attribute": {"level": "error", "message": "<Blok> {problem}.", "hint": "Write kind=\"agent|custom|task|action|assign|port\" and context=\"panel|scene|logo\" as literals."},
|
|
497
531
|
"blok.content": {"level": "error", "message": "A {context} blok holds {expected} beside its declarations, not {found}.", "hint": "Put everything inside one {expected}."},
|
|
498
532
|
"context.kind": {"level": "error", "message": "A{n} {kind} blok is drawn in {contexts}, not {context}."},
|
|
499
533
|
"kind.placement": {"level": "error", "message": "This is a{n} {kind} blok, but it is mounted as a{m} {expected} blok ({where}).", "hint": "Write kind=\"{expected}\" on its <Blok>, or mount it where a{n} {kind} blok goes."},
|
|
500
534
|
"chrome.context": {"level": "error", "message": "chrome is the host's interface around a panel or a scene, not a {context} blok's.", "hint": "Drop chrome."},
|
|
535
|
+
"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."},
|
|
501
536
|
"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=[...]."},
|
|
502
537
|
"logo.complexity": {"level": "error", "message": "{detail}"},
|
|
503
538
|
"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."},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export default {
|
|
2
2
|
"vocab": 2,
|
|
3
|
-
"minor":
|
|
3
|
+
"minor": 5,
|
|
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": {
|
|
@@ -8,9 +8,10 @@ export default {
|
|
|
8
8
|
"deps": "deps.<key>: an agent bound to a dependency of the blok, a custom blok or an action.",
|
|
9
9
|
"queries": "queries.<name>: a declared query's record (status, value, error, refetching, fetching_more).",
|
|
10
10
|
"subscriptions": "subscriptions.<name>: a declared subscription's record (status, value, error); value is the latest payload, or the last `keep` payloads.",
|
|
11
|
-
"args": "args.<key>: what the blok is opened on: the item for an agent or custom blok, the task's args for a task or action blok.",
|
|
11
|
+
"args": "args.<key>: what the blok is opened on: the item for an agent or custom blok, the task's args for a task or action blok, the form's other arguments as they are filled in for a port blok (read only).",
|
|
12
12
|
"task": "The task this blok is about: the sending task, or the run. A task record.",
|
|
13
13
|
"assign": "The run an assign blok prepares: assign.given.<key> (true for an argument the caller decided, which is locked), assign.missing (the keys of required arguments still empty) and assign.ready (nothing is missing).",
|
|
14
|
+
"port": "The port a port blok is the widget of: its value (port.value, which a control writes through bind) and what the form knows of it. A port record.",
|
|
14
15
|
"event": "The payload a component hands its callback. Only inside a callback.",
|
|
15
16
|
"viewer": "{user, org, roles} of whoever is looking.",
|
|
16
17
|
"then": "The moment being viewed while time-travelling (an ISO 8601 datetime), null while live. A blok never reads the wall clock: a query passes then as an ordinary variable (variables={at: \"then\"}), <Time> measures relative time from it, and while it is set subscriptions pause (their history query, or the value at travel start, stale)."
|
|
@@ -22,7 +23,7 @@ export default {
|
|
|
22
23
|
"functions": ["cmp", "logic", "math", "str", "list", "obj", "val", "fmt", "time", "ui", "query"],
|
|
23
24
|
"future": ["mutations"]
|
|
24
25
|
},
|
|
25
|
-
"reserved": ["self", "deps", "queries", "subscriptions", "args", "task", "assign", "event", "viewer", "then", "error", "cmp", "logic", "math", "str", "list", "obj", "val", "fmt", "time", "ui", "query", "mutations"],
|
|
26
|
+
"reserved": ["self", "deps", "queries", "subscriptions", "args", "task", "assign", "port", "event", "viewer", "then", "error", "cmp", "logic", "math", "str", "list", "obj", "val", "fmt", "time", "ui", "query", "mutations"],
|
|
26
27
|
"agent_segments": {
|
|
27
28
|
"description": "What follows an agent (self or deps.<key>): .<state>.<field> is state, .tasks.<action> the latest task of that action, .assets.<name> one of the agent's assets; deps.<key>.<action>(...) calls it.",
|
|
28
29
|
"tasks": "tasks",
|
|
@@ -61,6 +62,13 @@ export default {
|
|
|
61
62
|
"roots": ["self", "deps", "args", "assign", "queries", "subscriptions", "viewer"],
|
|
62
63
|
"locals": true,
|
|
63
64
|
"contexts": ["PANEL", "SCENE"]
|
|
65
|
+
},
|
|
66
|
+
"port": {
|
|
67
|
+
"description": "A port's own widget, declared with the port: drawn in the action's form where the port's control would be. It is a field of that form: it reads the port, the form's other arguments as args and the state of the agents a run would get, and writes the port's value and nothing else. It calls no agent.",
|
|
68
|
+
"roots": ["self", "deps", "args", "port", "queries", "subscriptions", "viewer"],
|
|
69
|
+
"locals": true,
|
|
70
|
+
"contexts": ["PANEL"],
|
|
71
|
+
"calls": false
|
|
64
72
|
}
|
|
65
73
|
},
|
|
66
74
|
"contexts": {
|
|
@@ -72,7 +80,7 @@ export default {
|
|
|
72
80
|
"description": "Every blok is one <Blok> element that says what it is: its kind (what it reads, and where it may be mounted), its context (what host draws it), the catalog it is written for and whether the host draws its own chrome around it. What the blok owns is declared inside it (<local>, <query>, <subscription>); what its mount provides (deps, args, task, self's actions) is checked only where it is mounted.",
|
|
73
81
|
"component": "Blok",
|
|
74
82
|
"attributes": {
|
|
75
|
-
"kind": "Required: agent, custom, task, action or
|
|
83
|
+
"kind": "Required: agent, custom, task, action, assign or port (a row of kinds).",
|
|
76
84
|
"context": "Required: panel, scene or logo.",
|
|
77
85
|
"catalog": "The catalog it is written for (the address it is published at, or the name of one registered in the organization); the base catalog when left out.",
|
|
78
86
|
"chrome": "\"none\": the host draws none of its own interface around the blok (panel and scene only)."
|
|
@@ -152,6 +160,26 @@ export default {
|
|
|
152
160
|
{"key": "blocked", "kind": "STRING", "nullable": true, "description": "Why the run cannot start now, as a sentence (a dependency is not met, no agent fits); null when it can."}
|
|
153
161
|
]
|
|
154
162
|
},
|
|
163
|
+
"port": {
|
|
164
|
+
"description": "What a port blok knows of the port it draws: its value, what the port declares, and where it stands in the form. Everything but value is the form's to say: a port blok sets no error and no flag.",
|
|
165
|
+
"fields": [
|
|
166
|
+
{"key": "value", "kind": "ANY", "nullable": true, "description": "The port's value as the form holds it, typed as the port; null while nothing is given. The one thing a port blok writes: a control through bind={port.value}, a callback with port.set(...)."},
|
|
167
|
+
{"key": "key", "kind": "STRING", "description": "The port's key."},
|
|
168
|
+
{"key": "label", "kind": "STRING", "nullable": true, "description": "What the form calls the port."},
|
|
169
|
+
{"key": "description", "kind": "STRING", "nullable": true},
|
|
170
|
+
{"key": "kind", "kind": "STRING", "description": "The port's kind (FLOAT, STRUCTURE, ...)."},
|
|
171
|
+
{"key": "identifier", "kind": "STRING", "nullable": true, "description": "The structure's identifier, for a STRUCTURE port."},
|
|
172
|
+
{"key": "nullable", "kind": "BOOL", "description": "Whether the port may be left empty."},
|
|
173
|
+
{"key": "default", "kind": "ANY", "nullable": true, "description": "What port.reset() goes back to."},
|
|
174
|
+
{"key": "choices", "kind": "LIST", "description": "The choices the port declares, each {value, label, description}; empty when it declares none."},
|
|
175
|
+
{"key": "unit", "kind": "STRING", "nullable": true, "description": "The unit a QUANTITY port's value is in."},
|
|
176
|
+
{"key": "editable", "kind": "BOOL", "description": "False where the value is only shown: the caller decided it, the form is locked or sent. A control bound to the port is then disabled, and port.set does nothing."},
|
|
177
|
+
{"key": "error", "kind": "STRING", "nullable": true, "description": "What the form says is wrong with the value, by the port's own rules (required, its kind, its validators); null when nothing is, or nothing was checked yet."},
|
|
178
|
+
{"key": "invalid", "kind": "BOOL", "description": "True while error is set."},
|
|
179
|
+
{"key": "touched", "kind": "BOOL", "description": "True once the viewer left the field (a bound control lost focus, or port.touch())."},
|
|
180
|
+
{"key": "dirty", "kind": "BOOL", "description": "True once the value differs from what the form opened with."}
|
|
181
|
+
]
|
|
182
|
+
},
|
|
155
183
|
"viewer": {
|
|
156
184
|
"description": "Exposes nothing beyond what the viewer's own token says.",
|
|
157
185
|
"fields": [
|
|
@@ -175,7 +203,7 @@ export default {
|
|
|
175
203
|
"stale": "Known, but the source stopped updating (agent offline): the last value, flagged.",
|
|
176
204
|
"failed": "Cannot be known (no access, agent gone, query error), with an error."
|
|
177
205
|
},
|
|
178
|
-
"always_ready": ["locals", "event", "let", "literals"],
|
|
206
|
+
"always_ready": ["locals", "event", "let", "index", "literals"],
|
|
179
207
|
"propagation": [
|
|
180
208
|
"If any input of an expression is pending, the result is pending; else if any failed, the result is failed; else if any is stale, the result is stale.",
|
|
181
209
|
"logic.choose and <if> read only the branch taken; logic.all and logic.any stop at the first operand that decides them.",
|
|
@@ -187,7 +215,7 @@ export default {
|
|
|
187
215
|
]
|
|
188
216
|
},
|
|
189
217
|
"functions": {
|
|
190
|
-
"description": "Pure functions by namespace, snake_case. Positional arguments map onto params in order. `lazy`: arguments are read only as needed. `effect`: allowed only as a callback's one thing (ui.*, task.*, assign.start, query.*). `command`: an effect that changes the world (it acts on a task or starts one, and is recorded with it); an effect without it only changes what the viewer sees. A blok does nothing else: every other function is pure. `sees_status`: sees pending/failed instead of suspending. No function reads the wall clock. `null` says what the function does with a null argument (known absence); a missing path reads as null.",
|
|
218
|
+
"description": "Pure functions by namespace, snake_case. Positional arguments map onto params in order. `lazy`: arguments are read only as needed. `effect`: allowed only as a callback's one thing (ui.*, task.*, assign.start, port.*, query.*). `needs`: the root a blok's kind must read to hold the effect (port.set needs port). `command`: an effect that changes the world (it acts on a task or starts one, and is recorded with it); an effect without it only changes what the viewer sees. A blok does nothing else: every other function is pure. `sees_status`: sees pending/failed instead of suspending. No function reads the wall clock. `null` says what the function does with a null argument (known absence); a missing path reads as null.",
|
|
191
219
|
"cmp.eq": {"params": [["a", "ANY"], ["b", "ANY"]], "returns": "BOOL", "description": "Deep JSON equality.", "null": "null equals only null"},
|
|
192
220
|
"cmp.ne": {"params": [["a", "ANY"], ["b", "ANY"]], "returns": "BOOL", "description": "Not deep-equal.", "null": "null equals only null"},
|
|
193
221
|
"cmp.gt": {"params": [["a", "ANY"], ["b", "ANY"]], "returns": "BOOL", "description": "a > b, numbers or strings.", "null": "false"},
|
|
@@ -313,6 +341,10 @@ export default {
|
|
|
313
341
|
"task.step": {"params": [], "returns": "ANY", "effect": true, "command": true, "task_operation": true, "description": "Resumes the run `task` is about until its next breakpoint. Refused while `task.can.step` is false, and while the blok shows the past. Counts as a task operation.", "null": "takes no arguments"},
|
|
314
342
|
"task.interrupt": {"params": [], "returns": "ANY", "effect": true, "command": true, "task_operation": true, "description": "Interrupts the run `task` is about: stopped at once, without waiting for it to wind down. Refused while `task.can.interrupt` is false, and while the blok shows the past. Counts as a task operation.", "null": "takes no arguments"},
|
|
315
343
|
"assign.start": {"params": [], "returns": "ANY", "effect": true, "command": true, "description": "Starts the run an assign blok prepares, with the arguments as they are filled in and the agents the blok was shown (deps) pinned. An assign blok only.", "null": "starts the run"},
|
|
344
|
+
"port.set": {"params": [["value", "ANY"]], "returns": "ANY", "effect": true, "needs": "port", "description": "Sets the port's value, as a control bound to it would: the form marks it dirty and checks it. A port blok only.", "null": "sets the port to empty, as port.clear() does"},
|
|
345
|
+
"port.clear": {"params": [], "returns": "ANY", "effect": true, "needs": "port", "description": "Empties the port: nothing is given for it. A port blok only.", "null": "takes no arguments"},
|
|
346
|
+
"port.reset": {"params": [], "returns": "ANY", "effect": true, "needs": "port", "description": "Puts the port back to what the form opened with (port.default when nothing was given), and clears touched and dirty. A port blok only.", "null": "takes no arguments"},
|
|
347
|
+
"port.touch": {"params": [], "returns": "ANY", "effect": true, "needs": "port", "description": "Says the viewer left the field: what a bound control says itself when it loses focus, for a control drawn by hand. A port blok only.", "null": "takes no arguments"},
|
|
316
348
|
"query.refetch": {"params": [["query", "STRING"]], "returns": "ANY", "effect": true, "description": "Re-reads the declared query named by the literal `query`; never suspends, queries.<name>.refetching is true meanwhile. BSX writes it queries.<name>.refetch().", "null": "refused: the query is named by a literal"},
|
|
317
349
|
"query.fetch_more": {"params": [["query", "STRING"], ["variables", "DICT", false]], "returns": "ANY", "effect": true, "description": "Reads the next page of the declared query named by the literal `query`, its variables overridden by `variables`, and appends the page's list at the query's `more` field to what is shown; queries.<name>.fetching_more is true meanwhile. BSX writes it queries.<name>.fetch_more(name: value, ...). Refused on a query without `more`.", "null": "refused: the query is named by a literal; null variables fetch with the query's own"}
|
|
318
350
|
},
|
|
@@ -326,8 +358,8 @@ export default {
|
|
|
326
358
|
"calls": {
|
|
327
359
|
"description": "What a prop or an argument may hold besides a literal, a path or a util call.",
|
|
328
360
|
"kinds": {
|
|
329
|
-
"agent_call": "A task call: self.<action>(...) or deps.<key>.<action>(...), only as a callback's one thing, optionally named with `into <name>` (stored as the prop's declares_value).",
|
|
330
|
-
"util_call": "A pure function, or an effect (ui.copy, task.answer, assign.start, query.refetch, query.fetch_more) as a callback's one thing."
|
|
361
|
+
"agent_call": "A task call: self.<action>(...) or deps.<key>.<action>(...), only as a callback's one thing, optionally named with `into <name>` (stored as the prop's declares_value). A kind that says calls: false (a port blok) holds none.",
|
|
362
|
+
"util_call": "A pure function, or an effect (ui.copy, task.answer, assign.start, port.set, query.refetch, query.fetch_more) as a callback's one thing."
|
|
331
363
|
},
|
|
332
364
|
"reserved_kinds": {
|
|
333
365
|
"service_call": "Reserved for mutations, should they ever exist. Renderers refuse a call kind they do not know."
|
|
@@ -340,7 +372,7 @@ export default {
|
|
|
340
372
|
"description": "How a v2 blok is stored: ComponentNodeInput {id, component, props?, children?}; ComponentPropInput {key, static_value? | dynamic_value {path} | util_call | agent_call (+ declares_value)}; ActionArgumentInput {key?, value_literal? | value_path? | util_call? | value_list? | value_dict?}. A prop or argument with no value field is null.",
|
|
341
373
|
"ids": "An explicit id matches explicit_id; a derived id is the parent's id plus /<Component>[<n>] (n: occurrence among same-named siblings), the root's <Component>[0]. A derived id always ends in ']'. A text node is <parent>/#<n> (n: text-run index) and nothing may target it.",
|
|
342
374
|
"explicit_id": "^[A-Za-z_][A-Za-z0-9_.:-]*$",
|
|
343
|
-
"foreach": "foreach props: items (expression), let (static_value and declares_value the name), key (expression, optional). With a key each item's subtree takes its runtime ids from it: <id>@<key>; without one, from its position: <id>@#<n> (n: the 0-based index). A foreach without key is stored with no key prop at all; the validator warns foreach.position_key when its items are known not to be scalars.",
|
|
375
|
+
"foreach": "foreach props: items (expression), let (static_value and declares_value the name), index (optional; static_value and declares_value the name: an INT, the item's 0-based position in items, in scope where let is), key (expression, optional). With a key each item's subtree takes its runtime ids from it: <id>@<key>; without one, from its position: <id>@#<n> (n: the 0-based index). A foreach without key is stored with no key prop at all; the validator warns foreach.position_key when its items are known not to be scalars.",
|
|
344
376
|
"if": "if props: when; children: the then-branch, then the else nodes (component else, an else-if with a when prop; only the last else may lack when).",
|
|
345
377
|
"into": "agent_call prop with declares_value <name>: a task record only that call writes. Allowed inside foreach; one name is written by one call site.",
|
|
346
378
|
"text": "Text is a child like any other: each run of text between elements is stored as a node {id: <parent>/#<n>, component: \"#text\", props: [value]}, its value a literal or an expression; several parts of one run desugar to str.template(template, values). No element can be called #text, so only text makes one. Parsing needs no catalog. What a component does with its text is its renderer's: one with a text_prop makes its text children that prop (a Button its label), any other that takes children draws them in place; a component that sets its text_prop as an attribute too, or takes neither text nor children, is a catalog finding (catalog.text). A tree stored before text was a node holds the text_prop itself, and implicit Text or span nodes under the same ids: a renderer draws both."
|
|
@@ -401,7 +433,7 @@ export default {
|
|
|
401
433
|
"name": "^[A-Za-z_][A-Za-z0-9_.-]*$",
|
|
402
434
|
"host_parts": {
|
|
403
435
|
"description": "Parts of the host's own interface a blok may place itself: placing one anywhere in the tree claims it, and the host then draws none of its own. The claim is read off the stored tree, so a part inside an inactive <if> still claims it (part.conditional). What a blok does not place, the host still draws, unless its root says chrome=\"none\".",
|
|
404
|
-
"parts": ["args", "arg", "deps", "dep", "ask", "returns", "status", "timeline"]
|
|
436
|
+
"parts": ["args", "arg", "deps", "dep", "ask", "returns", "status", "timeline", "label", "description", "message", "control", "field"]
|
|
405
437
|
}
|
|
406
438
|
},
|
|
407
439
|
"classes": {
|
|
@@ -424,7 +456,8 @@ export default {
|
|
|
424
456
|
"bsx.text_callback": {"level": "error", "message": "Text holds a call or an effect; only a callback prop may.", "hint": "Put the call in a callback prop (onClick={{...}}), never between tags."},
|
|
425
457
|
"bsx.else_outside_if": {"level": "error", "message": "<else> is a child of <if>, after its then-branch.", "hint": "Move the <else> inside its <if>, after the then-branch children."},
|
|
426
458
|
"bsx.else_order": {"level": "error", "message": "<else> comes after the then-branch, and only the last <else> may lack when.", "hint": "Put the <else> branches last in the <if>; only the final one may leave out when."},
|
|
427
|
-
"bsx.foreach": {"level": "error", "message": "<foreach> needs items={{...}} and let=\"name\" (key={{...}}
|
|
459
|
+
"bsx.foreach": {"level": "error", "message": "<foreach> needs items={{...}} and let=\"name\" (key={{...}} and index=\"name\" are optional): {missing}."},
|
|
460
|
+
"bsx.index": {"level": "error", "message": "index={index!r} is not a name.", "hint": "Write index=\"i\": a plain identifier the children read as the item's position, from 0."},
|
|
428
461
|
"bsx.let": {"level": "error", "message": "let={let!r} is not a name.", "hint": "Write let=\"name\": a plain identifier the children read as name.field."},
|
|
429
462
|
"expr.syntax": {"level": "error", "message": "{detail}", "hint": "Expressions are a JavaScript subset: paths, literals, calls with name: value arguments, == != > >= < <=, && || !, ?? and c ? a : b."},
|
|
430
463
|
"expr.arithmetic": {"level": "error", "message": "{operator} is not an operator of the blok language; call math.{function}(a, b)."},
|
|
@@ -443,11 +476,11 @@ export default {
|
|
|
443
476
|
"callback.positional": {"level": "error", "message": "{call}: a task call names its arguments (name: value)."},
|
|
444
477
|
"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>."},
|
|
445
478
|
"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."},
|
|
446
|
-
"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).", "hint": "Give {key} a task call (deps.<key>.<action>(name: value)) or one effect, not a value."},
|
|
479
|
+
"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."},
|
|
447
480
|
"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}."},
|
|
448
|
-
"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 an into record."},
|
|
481
|
+
"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."},
|
|
449
482
|
"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."},
|
|
450
|
-
"roots.reserved": {"level": "error", "message": "{name!r} is reserved: no local, let or into may use it."},
|
|
483
|
+
"roots.reserved": {"level": "error", "message": "{name!r} is reserved: no local, let, index or into may use it."},
|
|
451
484
|
"roots.shadow": {"level": "error", "message": "{name!r} is declared twice: as {first} and as {second}."},
|
|
452
485
|
"roots.event_outside_callback": {"level": "error", "message": "{path} reads event outside a callback.", "hint": "Read event only inside a callback prop; outside one, bind a control to a local and read the local."},
|
|
453
486
|
"roots.error_outside_boundary": {"level": "error", "message": "{path} reads error outside an <error> slot.", "hint": "Read error only inside the <error> slot of a <suspense>."},
|
|
@@ -461,6 +494,7 @@ export default {
|
|
|
461
494
|
"args.unknown": {"level": "error", "message": "{path} reads args.{key}, which the blok does not declare (declared: {keys}).", "hint": "Read one of the declared args, or declare args.{key} (only when the user asks what the blok is opened for)."},
|
|
462
495
|
"into.twice": {"level": "error", "message": "{name!r} is written by two calls: {first} and {second}. Each call site needs a record of its own."},
|
|
463
496
|
"local.unknown": {"level": "error", "message": "bind={{{path}}} writes {root!r}, which is no declared local.", "hint": "Declare {root!r} in locals (its default, or null), then bind it."},
|
|
497
|
+
"port.bind": {"level": "error", "message": "bind={{{path}}}: a port blok writes port.value and nothing else of its port.", "hint": "Write bind={{port.value}}; what the form knows of the port (its label, its error) is the form's to say."},
|
|
464
498
|
"local.bind": {"level": "error", "message": "bind holds a local's path ({{name}} or {{name.field}}), not {what}.", "hint": "Write bind={{name}} with a declared local's name."},
|
|
465
499
|
"local.default": {"level": "error", "message": "local {name!r}: its default {default!r} is not a {kind}.", "hint": "Give a default of that kind, or leave the kind out so the default sets it."},
|
|
466
500
|
"local.kind": {"level": "error", "message": "local {name!r}: type={type!r} is a name, not an annotation; give the type itself (int, list[str], a registered structure)."},
|
|
@@ -493,11 +527,12 @@ export default {
|
|
|
493
527
|
"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}})."},
|
|
494
528
|
"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."},
|
|
495
529
|
"blok.root": {"level": "error", "message": "A blok is one <Blok kind=... context=...> element, not <{component}>.", "hint": "Wrap it: <Blok kind=\"agent\" context=\"panel\">...</Blok>."},
|
|
496
|
-
"blok.attribute": {"level": "error", "message": "<Blok> {problem}.", "hint": "Write kind=\"agent|custom|task|action|assign\" and context=\"panel|scene|logo\" as literals."},
|
|
530
|
+
"blok.attribute": {"level": "error", "message": "<Blok> {problem}.", "hint": "Write kind=\"agent|custom|task|action|assign|port\" and context=\"panel|scene|logo\" as literals."},
|
|
497
531
|
"blok.content": {"level": "error", "message": "A {context} blok holds {expected} beside its declarations, not {found}.", "hint": "Put everything inside one {expected}."},
|
|
498
532
|
"context.kind": {"level": "error", "message": "A{n} {kind} blok is drawn in {contexts}, not {context}."},
|
|
499
533
|
"kind.placement": {"level": "error", "message": "This is a{n} {kind} blok, but it is mounted as a{m} {expected} blok ({where}).", "hint": "Write kind=\"{expected}\" on its <Blok>, or mount it where a{n} {kind} blok goes."},
|
|
500
534
|
"chrome.context": {"level": "error", "message": "chrome is the host's interface around a panel or a scene, not a {context} blok's.", "hint": "Drop chrome."},
|
|
535
|
+
"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."},
|
|
501
536
|
"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=[...]."},
|
|
502
537
|
"logo.complexity": {"level": "error", "message": "{detail}"},
|
|
503
538
|
"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."},
|
package/package.json
CHANGED
package/src/bsx/infer.ts
CHANGED
|
@@ -37,6 +37,7 @@ const ITEM_KEY = '...';
|
|
|
37
37
|
const BIND_PROP = 'bind';
|
|
38
38
|
const FOREACH = 'foreach';
|
|
39
39
|
const FOREACH_LET = 'let';
|
|
40
|
+
const FOREACH_INDEX = 'index';
|
|
40
41
|
const FOREACH_ITEMS = 'items';
|
|
41
42
|
/** The bind kinds a local takes from its control; a LIST, DICT or ANY control tells too little. */
|
|
42
43
|
const BIND_INFERRED: ReadonlySet<string> = new Set(['STRING', 'INT', 'FLOAT', 'BOOL']);
|
|
@@ -260,8 +261,11 @@ class Uses {
|
|
|
260
261
|
this.component(node, scope);
|
|
261
262
|
const declared =
|
|
262
263
|
node.component === FOREACH ? node.props?.find(prop => prop.key === FOREACH_LET && prop.declares_value)?.declares_value ?? null : null;
|
|
264
|
+
const index =
|
|
265
|
+
node.component === FOREACH ? node.props?.find(prop => prop.key === FOREACH_INDEX && prop.declares_value)?.declares_value ?? null : null;
|
|
263
266
|
const inner = new Map(scope);
|
|
264
267
|
if (declared !== null) inner.set(declared, null);
|
|
268
|
+
if (index !== null) inner.set(index, null);
|
|
265
269
|
for (const prop of node.props ?? []) this.prop(prop, declared !== null && prop.key === FOREACH_ITEMS ? scope : inner);
|
|
266
270
|
// Every local of a node is in scope in all of its children.
|
|
267
271
|
for (const child of node.children ?? []) {
|
package/src/bsx/language.ts
CHANGED
|
@@ -2,7 +2,7 @@ import {defaultBlokView, innerContext, type BlokView, type SpecComponent, type S
|
|
|
2
2
|
import {BLOK_KINDS, kindIn, loadVocabulary, type BlokContextName, type BlokKind, type VocabFunction, type VocabRecordField} from '../spec/vocabulary';
|
|
3
3
|
import {BLOK_COMPONENT, declaredQueries, declaredSubscriptions, QUERY_COMPONENT, SUBSCRIPTION_COMPONENT} from './declared';
|
|
4
4
|
import {resolveLocals} from './infer';
|
|
5
|
-
import {FOREACH_COMPONENT, FOREACH_LET_PROP, INTO_KEYWORD} from './parse';
|
|
5
|
+
import {FOREACH_COMPONENT, FOREACH_INDEX_PROP, FOREACH_LET_PROP, INTO_KEYWORD} from './parse';
|
|
6
6
|
import {parseBsxPartial} from './partial';
|
|
7
7
|
import {type BlokCheckScope, type BlokPortMatch, type BlokScopeDependency, type BlokScopeLocalPort, type ResolvedBlokLocal} from './references';
|
|
8
8
|
import type {BsxRange} from './source';
|
|
@@ -488,7 +488,7 @@ const intoNames = (text: string): string[] => [...new Set([...text.matchAll(new
|
|
|
488
488
|
const foreachLets = (stack: readonly OpenElement[]): string[] =>
|
|
489
489
|
stack
|
|
490
490
|
.filter(element => element.tag === FOREACH_COMPONENT)
|
|
491
|
-
.
|
|
491
|
+
.flatMap(element => [element.attributes.get(FOREACH_LET_PROP) ?? '', element.attributes.get(FOREACH_INDEX_PROP) ?? ''])
|
|
492
492
|
.filter(Boolean);
|
|
493
493
|
|
|
494
494
|
const dependencyOf = (env: BsxEnvironment, key: string): BlokScopeDependency | undefined =>
|
|
@@ -704,7 +704,7 @@ export const completeBsx = (text: string, offset: number, env: BsxEnvironment):
|
|
|
704
704
|
return cursor.attr === 'className' ? classCompletions(cursor.value, cursor.from + cursor.value.length) : [];
|
|
705
705
|
case 'attrExpression': {
|
|
706
706
|
const end = cursor.from + cursor.expression.length;
|
|
707
|
-
if (cursor.tag === FOREACH_COMPONENT && cursor.attr === FOREACH_LET_PROP) return [];
|
|
707
|
+
if (cursor.tag === FOREACH_COMPONENT && (cursor.attr === FOREACH_LET_PROP || cursor.attr === FOREACH_INDEX_PROP)) return [];
|
|
708
708
|
if (cursor.attr === 'className' && inString(cursor.expression)) {
|
|
709
709
|
const quote = Math.max(cursor.expression.lastIndexOf('"'), cursor.expression.lastIndexOf("'"));
|
|
710
710
|
return classCompletions(cursor.expression.slice(quote + 1), end);
|
package/src/bsx/parse.ts
CHANGED
|
@@ -60,6 +60,7 @@ export const IF_COMPONENT = 'if';
|
|
|
60
60
|
export const ELSE_COMPONENT = 'else';
|
|
61
61
|
export const FOREACH_COMPONENT = 'foreach';
|
|
62
62
|
export const FOREACH_LET_PROP = 'let';
|
|
63
|
+
export const FOREACH_INDEX_PROP = 'index';
|
|
63
64
|
export const FOREACH_ITEMS_PROP = 'items';
|
|
64
65
|
export const FOREACH_KEY_PROP = 'key';
|
|
65
66
|
const LOCAL_COMPONENT = 'local';
|
|
@@ -468,6 +469,10 @@ class Lowering {
|
|
|
468
469
|
if (declared && (typeof declared.value !== 'string' || !isLocalName(declared.value))) {
|
|
469
470
|
throw this.fail('bsx.let', declared.offset, {let: typeof declared.value === 'string' ? declared.value : '{...}'});
|
|
470
471
|
}
|
|
472
|
+
const index = attributes.get(FOREACH_INDEX_PROP);
|
|
473
|
+
if (index && (typeof index.value !== 'string' || !isLocalName(index.value))) {
|
|
474
|
+
throw this.fail('bsx.index', index.offset, {index: typeof index.value === 'string' ? index.value : '{...}'});
|
|
475
|
+
}
|
|
471
476
|
for (const name of ['items', 'key']) {
|
|
472
477
|
const attribute = attributes.get(name);
|
|
473
478
|
if (attribute && (typeof attribute.value === 'string' || attribute.value === true)) {
|
|
@@ -554,12 +559,13 @@ class Lowering {
|
|
|
554
559
|
}
|
|
555
560
|
if (value === true) return {key: attribute.name, static_value: true};
|
|
556
561
|
if (typeof value === 'string') {
|
|
557
|
-
if (attribute.name === FOREACH_LET_PROP && component === FOREACH_COMPONENT) {
|
|
562
|
+
if ((attribute.name === FOREACH_LET_PROP || attribute.name === FOREACH_INDEX_PROP) && component === FOREACH_COMPONENT) {
|
|
558
563
|
return {key: attribute.name, static_value: value, declares_value: value};
|
|
559
564
|
}
|
|
560
565
|
return {key: attribute.name, static_value: value};
|
|
561
566
|
}
|
|
562
567
|
if (attribute.name === FOREACH_LET_PROP && component === FOREACH_COMPONENT) throw this.fail('bsx.let', attribute.offset, {let: '{...}'});
|
|
568
|
+
if (attribute.name === FOREACH_INDEX_PROP && component === FOREACH_COMPONENT) throw this.fail('bsx.index', attribute.offset, {index: '{...}'});
|
|
563
569
|
return this.value(attribute.name, value, attribute.offset);
|
|
564
570
|
}
|
|
565
571
|
|
package/src/bsx/print.ts
CHANGED
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
CLASSES_FUNCTION,
|
|
13
13
|
FETCH_MORE_FUNCTION,
|
|
14
14
|
FOREACH_COMPONENT,
|
|
15
|
+
FOREACH_INDEX_PROP,
|
|
15
16
|
FOREACH_LET_PROP,
|
|
16
17
|
LEGACY_IMPLICIT_TEXTS,
|
|
17
18
|
TEXT_NODE,
|
|
@@ -253,7 +254,7 @@ class Printer {
|
|
|
253
254
|
return `${key}={${this.agentCall(prop.agent_call)}${into}}`;
|
|
254
255
|
}
|
|
255
256
|
if (prop.declares_value != null) {
|
|
256
|
-
if (node.component === FOREACH_COMPONENT && key === FOREACH_LET_PROP && prop.static_value === prop.declares_value) {
|
|
257
|
+
if (node.component === FOREACH_COMPONENT && (key === FOREACH_LET_PROP || key === FOREACH_INDEX_PROP) && prop.static_value === prop.declares_value) {
|
|
257
258
|
return `${key}=${quoted(prop.declares_value)}`;
|
|
258
259
|
}
|
|
259
260
|
if (node.component === 'local' && key === 'name' && prop.static_value === prop.declares_value) {
|
|
@@ -10,7 +10,7 @@ import type {BlokComponentNode} from '../renderer/runtime/types';
|
|
|
10
10
|
/** Where a corpus case is checked: the spec's `mount`, and whether a catalog is read at all. */
|
|
11
11
|
type CorpusMount = Omit<BlokCheckScope, 'catalog'> & {catalog: boolean};
|
|
12
12
|
|
|
13
|
-
const scopeOf = (mount: CorpusMount): BlokCheckScope => ({kinds: mount.kinds, dependencies: mount.dependencies, args: mount.args});
|
|
13
|
+
const scopeOf = (mount: CorpusMount): BlokCheckScope => ({kinds: mount.kinds, dependencies: mount.dependencies, args: mount.args, port: mount.port ?? null});
|
|
14
14
|
type CheckedCase = {
|
|
15
15
|
name: string;
|
|
16
16
|
source: string;
|