@arkitektio/bsx 4.0.1 → 4.1.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/references.d.ts.map +1 -1
- package/dist/bsx/references.js +17 -4
- package/dist/bsx/references.js.map +1 -1
- package/dist/renderer/BlokRenderer.d.ts +3 -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 +1 -0
- package/dist/renderer/bloks/control.d.ts.map +1 -1
- package/dist/renderer/bloks/control.js +10 -0
- package/dist/renderer/bloks/control.js.map +1 -1
- package/dist/renderer/bloks/run/host.d.ts +2 -0
- package/dist/renderer/bloks/run/host.d.ts.map +1 -1
- package/dist/renderer/bloks/run/host.js.map +1 -1
- package/dist/renderer/runtime/context.d.ts +1 -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 +1 -0
- package/dist/renderer/runtime/resolution.d.ts.map +1 -1
- package/dist/renderer/runtime/resolution.js +13 -2
- package/dist/renderer/runtime/resolution.js.map +1 -1
- package/dist/renderer/runtime/types.d.ts +5 -0
- package/dist/renderer/runtime/types.d.ts.map +1 -1
- package/dist/spec/bsx_v2.json +287 -0
- package/dist/spec/catalogs/base@2.json +12 -0
- package/dist/spec/catalogs/base@2.json.js +12 -0
- package/dist/spec/vocabulary.d.ts +1 -1
- package/dist/spec/vocabulary.d.ts.map +1 -1
- package/dist/spec/vocabulary.js +1 -1
- package/dist/spec/vocabulary.js.map +1 -1
- package/dist/spec/vocabulary.json +11 -3
- package/dist/spec/vocabulary.json.js +11 -3
- package/package.json +1 -1
- package/src/bsx/references.ts +18 -4
- package/src/renderer/BlokRenderer.tsx +8 -0
- package/src/renderer/bloks/control.tsx +15 -0
- package/src/renderer/bloks/run/host.tsx +2 -0
- package/src/renderer/bloks/run/space.test.tsx +17 -1
- package/src/renderer/runtime/context.tsx +5 -0
- package/src/renderer/runtime/hooks.ts +1 -0
- package/src/renderer/runtime/resolution.test.ts +8 -0
- package/src/renderer/runtime/resolution.ts +11 -2
- package/src/renderer/runtime/types.ts +5 -0
- package/src/spec/bsx_v2.json +287 -0
- package/src/spec/catalogs/base@2.json +12 -0
- package/src/spec/vocabulary.json +11 -3
- package/src/spec/vocabulary.ts +2 -2
package/src/bsx/references.ts
CHANGED
|
@@ -170,6 +170,14 @@ export const blokContextOf = (component: string): string | null => loadVocabular
|
|
|
170
170
|
/** Props whose value is the blok's dependency keys, written out (not paths): each must be a dependency. */
|
|
171
171
|
const DEPENDENCY_KEY_PROPS = new Set(['Placed.dep', 'Route.through']);
|
|
172
172
|
|
|
173
|
+
/** The kinds that have a run's dependencies: an action's own bloks, for a run and for starting one. */
|
|
174
|
+
const RUN_KINDS: readonly string[] = ['action', 'assign'];
|
|
175
|
+
const ASSIGN_KIND = 'assign';
|
|
176
|
+
/** The form of the run's arguments, placed by an assign blok. */
|
|
177
|
+
const ARGS_COMPONENT = 'args';
|
|
178
|
+
/** Starts the run an assign blok prepares. */
|
|
179
|
+
const START_EFFECT = 'assign.start';
|
|
180
|
+
|
|
173
181
|
const OPEN_IDENTIFIER = '*';
|
|
174
182
|
const ITEM = '...';
|
|
175
183
|
const TOAST_COMPONENT = 'Toast';
|
|
@@ -313,7 +321,7 @@ const DIGITS = /^[0-9]+$/;
|
|
|
313
321
|
* - an agent blok has none: ``agent bloks read only `self` ``.
|
|
314
322
|
*/
|
|
315
323
|
export const dependencyHint = (key: string, kind: BlokKind): string => {
|
|
316
|
-
if (kind === 'action' || kind === 'action_logo') return `add a dependency parameter \`${key}\` to the action`;
|
|
324
|
+
if (kind === 'action' || kind === 'assign' || kind === 'action_logo') return `add a dependency parameter \`${key}\` to the action`;
|
|
317
325
|
if (kind === 'agent') return 'agent bloks read only `self`';
|
|
318
326
|
return `dependencies=[AgentDependencyInput(key="${key}")]`;
|
|
319
327
|
};
|
|
@@ -567,6 +575,9 @@ class Checker {
|
|
|
567
575
|
this.shadowed.add(node.component);
|
|
568
576
|
this.add('catalog.shadow', node.id, {component: node.component, catalog: shadow.catalog, module: shadow.module, winner: shadow.winner});
|
|
569
577
|
}
|
|
578
|
+
if (node.component === ARGS_COMPONENT && this.scope.kind !== ASSIGN_KIND) {
|
|
579
|
+
this.add('assign.kind', node.id, {what: '<args>', n: article(this.scope.kind), kind: this.scope.kind});
|
|
580
|
+
}
|
|
570
581
|
for (const prop of node.props ?? []) this.checkProp(node, prop, spec);
|
|
571
582
|
}
|
|
572
583
|
|
|
@@ -609,7 +620,7 @@ class Checker {
|
|
|
609
620
|
|
|
610
621
|
/** A ``Placed dep`` or ``Route through`` names dependencies of the blok, written out as keys. */
|
|
611
622
|
private checkDependencyKeys(node: BlokComponentNode, prop: BlokComponentProp): void {
|
|
612
|
-
if (this.scope.kind
|
|
623
|
+
if (!RUN_KINDS.includes(this.scope.kind)) {
|
|
613
624
|
this.add('space.kind', node.id, {component: node.component, n: article(this.scope.kind), kind: this.scope.kind}, prop.key);
|
|
614
625
|
return;
|
|
615
626
|
}
|
|
@@ -672,9 +683,12 @@ class Checker {
|
|
|
672
683
|
}
|
|
673
684
|
}
|
|
674
685
|
}
|
|
686
|
+
if (prop.util_call?.operation === START_EFFECT && this.scope.kind !== ASSIGN_KIND) {
|
|
687
|
+
this.add('assign.kind', node.id, {what: 'assign.start()', n: article(this.scope.kind), kind: this.scope.kind}, prop.key);
|
|
688
|
+
}
|
|
675
689
|
if (DEPENDENCY_KEY_PROPS.has(`${node.component}.${prop.key}`)) this.checkDependencyKeys(node, prop);
|
|
676
|
-
if (node.component === 'Space' && prop.key === 'room' && this.scope.kind
|
|
677
|
-
// A Space places the run's dependencies: only an action's own blok
|
|
690
|
+
if (node.component === 'Space' && prop.key === 'room' && !RUN_KINDS.includes(this.scope.kind)) {
|
|
691
|
+
// A Space places the run's dependencies: only an action's own blok (for a run, or for starting one) has them.
|
|
678
692
|
this.add('space.kind', node.id, {component: node.component, n: article(this.scope.kind), kind: this.scope.kind}, prop.key);
|
|
679
693
|
}
|
|
680
694
|
if (node.component === TOAST_COMPONENT && prop.key === TOAST_TASK_PROP) {
|
|
@@ -82,6 +82,8 @@ type BlokRendererProps = {
|
|
|
82
82
|
readExecutor?: BlokReadExecutor;
|
|
83
83
|
/** Answers the open ask of `task` (`task.answer(values)`). */
|
|
84
84
|
answerTask?: (values: Record<string, unknown>) => unknown;
|
|
85
|
+
/** Starts the run an assign blok prepares (`assign.start()`). */
|
|
86
|
+
startRun?: () => unknown;
|
|
85
87
|
/** Where `persist` components keep their state by id; none: they keep nothing. */
|
|
86
88
|
componentState?: BlokComponentStateStore | null;
|
|
87
89
|
children?: React.ReactNode;
|
|
@@ -145,6 +147,7 @@ export default function BlokRenderer({
|
|
|
145
147
|
subscriptions = NO_SUBSCRIPTIONS,
|
|
146
148
|
readExecutor,
|
|
147
149
|
answerTask,
|
|
150
|
+
startRun,
|
|
148
151
|
componentState = null,
|
|
149
152
|
children,
|
|
150
153
|
}: BlokRendererProps) {
|
|
@@ -198,6 +201,7 @@ export default function BlokRenderer({
|
|
|
198
201
|
statuses: unboundDependencies?.length ? {...statuses, ...unboundDependencyStatuses(unboundDependencies)} : statuses,
|
|
199
202
|
travelAt,
|
|
200
203
|
answerTask,
|
|
204
|
+
startRun,
|
|
201
205
|
});
|
|
202
206
|
return store;
|
|
203
207
|
});
|
|
@@ -221,6 +225,10 @@ export default function BlokRenderer({
|
|
|
221
225
|
runtimeStore.getState().setAnswerTask(answerTask);
|
|
222
226
|
}, [answerTask, runtimeStore]);
|
|
223
227
|
|
|
228
|
+
useEffect(() => {
|
|
229
|
+
runtimeStore.getState().setStartRun(startRun);
|
|
230
|
+
}, [startRun, runtimeStore]);
|
|
231
|
+
|
|
224
232
|
useEffect(() => {
|
|
225
233
|
if (keptRoots) runtimeStore.getState().setKeptRoots(keptRoots);
|
|
226
234
|
}, [keptRoots, runtimeStore]);
|
|
@@ -420,6 +420,20 @@ export const Ask = createBlokComponent(
|
|
|
420
420
|
() => <>{useBlokRunHost().renderAsk()}</>,
|
|
421
421
|
);
|
|
422
422
|
|
|
423
|
+
/* -------------------------------------------------------------------------- */
|
|
424
|
+
/* args */
|
|
425
|
+
/* -------------------------------------------------------------------------- */
|
|
426
|
+
|
|
427
|
+
export const Args = createBlokComponent(
|
|
428
|
+
{
|
|
429
|
+
name: 'args',
|
|
430
|
+
schema: z
|
|
431
|
+
.object({})
|
|
432
|
+
.describe("The arguments of the run an assign blok starts, as a form generated from the action's ports: filled in right here, read as `args.<key>`."),
|
|
433
|
+
},
|
|
434
|
+
() => <>{useBlokRunHost().renderArgs?.() ?? null}</>,
|
|
435
|
+
);
|
|
436
|
+
|
|
423
437
|
export const controlBlokComponents = [
|
|
424
438
|
Foreach,
|
|
425
439
|
If,
|
|
@@ -433,4 +447,5 @@ export const controlBlokComponents = [
|
|
|
433
447
|
Fallback,
|
|
434
448
|
ErrorSlot,
|
|
435
449
|
Ask,
|
|
450
|
+
Args,
|
|
436
451
|
];
|
|
@@ -21,6 +21,8 @@ export type BlokRunHost = {
|
|
|
21
21
|
agentsFor: (key: string) => readonly BlokRunAgent[];
|
|
22
22
|
/** The run's open ask, answered in place (answering resumes the run); nothing while none is open. */
|
|
23
23
|
renderAsk: () => React.ReactNode;
|
|
24
|
+
/** The form of the arguments of the run an assign blok starts (`<args />`); absent where no run is being started. */
|
|
25
|
+
renderArgs?: () => React.ReactNode;
|
|
24
26
|
};
|
|
25
27
|
|
|
26
28
|
const NO_AGENTS: readonly BlokRunAgent[] = Object.freeze([]);
|
|
@@ -3,7 +3,7 @@ import * as React from 'react';
|
|
|
3
3
|
import {render, screen} from '@testing-library/react';
|
|
4
4
|
import {describe, expect, it, vi} from 'vitest';
|
|
5
5
|
import BlokRenderer from '../../BlokRenderer';
|
|
6
|
-
import {BlokSpaceHostProvider, type BlokSpaceHost} from './host';
|
|
6
|
+
import {BlokRunHostProvider, BlokSpaceHostProvider, type BlokRunHost, type BlokSpaceHost} from './host';
|
|
7
7
|
import {testCatalog} from '../testing';
|
|
8
8
|
|
|
9
9
|
// No WebGL in jsdom: the canvas holds nothing here. What is checked is the frame
|
|
@@ -49,3 +49,19 @@ describe('a space shown on its own', () => {
|
|
|
49
49
|
expect(screen.getByTestId('canvas')).toBeTruthy();
|
|
50
50
|
});
|
|
51
51
|
});
|
|
52
|
+
|
|
53
|
+
describe('the argument form an assign blok places', () => {
|
|
54
|
+
it('draws what the host gives for <args />, and nothing without a host', () => {
|
|
55
|
+
const tree = [{id: 'root', component: 'Html', children: [{id: 'form', component: 'args'}]}];
|
|
56
|
+
const run: BlokRunHost = {agentsFor: () => [], renderAsk: () => null, renderArgs: () => <div data-testid="args-form" />};
|
|
57
|
+
const hosted = render(
|
|
58
|
+
<BlokRunHostProvider value={run}>
|
|
59
|
+
<BlokRenderer catalog={testCatalog()} uiComponents={tree} />
|
|
60
|
+
</BlokRunHostProvider>,
|
|
61
|
+
);
|
|
62
|
+
expect(hosted.getByTestId('args-form')).toBeTruthy();
|
|
63
|
+
hosted.unmount();
|
|
64
|
+
const bare = render(<BlokRenderer catalog={testCatalog()} uiComponents={tree} />);
|
|
65
|
+
expect(bare.queryByTestId('args-form')).toBeNull();
|
|
66
|
+
});
|
|
67
|
+
});
|
|
@@ -150,6 +150,7 @@ export const createBlokRuntimeStore = (config?: {
|
|
|
150
150
|
statuses?: Readonly<Record<string, BlokSourceStatus>>;
|
|
151
151
|
travelAt?: string | null;
|
|
152
152
|
answerTask?: (values: Record<string, unknown>) => unknown;
|
|
153
|
+
startRun?: () => unknown;
|
|
153
154
|
}): BlokRuntimeStore => {
|
|
154
155
|
const initialDataModel = config?.initialDataModel;
|
|
155
156
|
const keptValues = config?.keptValues ?? {};
|
|
@@ -173,6 +174,7 @@ export const createBlokRuntimeStore = (config?: {
|
|
|
173
174
|
refetchQuery: undefined,
|
|
174
175
|
fetchMoreQuery: undefined,
|
|
175
176
|
answerTask: config?.answerTask,
|
|
177
|
+
startRun: config?.startRun,
|
|
176
178
|
setStatus: (path, status) => {
|
|
177
179
|
const key = canonicalStatusPath(path);
|
|
178
180
|
set(currentState => {
|
|
@@ -209,6 +211,9 @@ export const createBlokRuntimeStore = (config?: {
|
|
|
209
211
|
setAnswerTask: answer => {
|
|
210
212
|
set({answerTask: answer});
|
|
211
213
|
},
|
|
214
|
+
setStartRun: start => {
|
|
215
|
+
set({startRun: start});
|
|
216
|
+
},
|
|
212
217
|
setInitialDataModel: nextInitialDataModel => {
|
|
213
218
|
set(currentState => {
|
|
214
219
|
if (Object.is(currentState.initialDataModel, nextInitialDataModel)) {
|
|
@@ -194,6 +194,7 @@ const createLiveResolutionContext = (
|
|
|
194
194
|
refetchQuery: name => store.getState().refetchQuery?.(name),
|
|
195
195
|
fetchMoreQuery: (name, variables) => store.getState().fetchMoreQuery?.(name, variables),
|
|
196
196
|
answerTask: values => store.getState().answerTask?.(values),
|
|
197
|
+
startRun: () => store.getState().startRun?.(),
|
|
197
198
|
travelling: store.getState().travelAt !== null,
|
|
198
199
|
invokeFunction: (name, args, options) => store.getState().invokeFunction(name, args, options),
|
|
199
200
|
dispatchAction: (action, component, observe) =>
|
|
@@ -433,6 +433,14 @@ describe("a callback does exactly one thing (v2)", () => {
|
|
|
433
433
|
expect(answerTask).toHaveBeenCalledWith({image: "7"});
|
|
434
434
|
});
|
|
435
435
|
|
|
436
|
+
it("starts the run an assign blok prepares with assign.start, where a host starts one", () => {
|
|
437
|
+
const startRun = vi.fn(() => "starting");
|
|
438
|
+
const call = {type: "util" as const, call: {operation: "assign.start", arguments: []}};
|
|
439
|
+
expect(runActionCall(call, createContext({}, {startRun}), component)).toEqual({ok: true, value: "starting"});
|
|
440
|
+
expect(startRun).toHaveBeenCalledTimes(1);
|
|
441
|
+
expect(runActionCall(call, createContext({}), component).ok).toBe(false);
|
|
442
|
+
});
|
|
443
|
+
|
|
436
444
|
it("refuses a pure function as a callback", () => {
|
|
437
445
|
const result = runActionCall({type: "util", call: {operation: "str.upper", arguments: []}}, createContext({}), component);
|
|
438
446
|
expect(result.ok).toBe(false);
|
|
@@ -390,6 +390,7 @@ const resolvePropValue = (
|
|
|
390
390
|
/** The effects a callback may hold besides a task call (vocabulary functions flagged `effect`). */
|
|
391
391
|
export const COPY_EFFECT = 'ui.copy';
|
|
392
392
|
export const ANSWER_EFFECT = 'task.answer';
|
|
393
|
+
export const START_EFFECT = 'assign.start';
|
|
393
394
|
export const REFETCH_EFFECT = 'query.refetch';
|
|
394
395
|
export const FETCH_MORE_EFFECT = 'query.fetch_more';
|
|
395
396
|
|
|
@@ -414,7 +415,9 @@ const getPropActionCall = (
|
|
|
414
415
|
|
|
415
416
|
/** Whether a callback is a command: it is refused while the blok shows the past. */
|
|
416
417
|
export const isCommand = (actionCall: BlokActionCall | undefined): boolean =>
|
|
417
|
-
actionCall !== undefined &&
|
|
418
|
+
actionCall !== undefined &&
|
|
419
|
+
(actionCall.type === 'agent' ||
|
|
420
|
+
(actionCall.type === 'util' && (actionCall.call.operation === ANSWER_EFFECT || actionCall.call.operation === START_EFFECT)));
|
|
418
421
|
|
|
419
422
|
const copyToClipboard = (value: unknown): void => {
|
|
420
423
|
const text = value === null || value === undefined ? '' : typeof value === 'string' ? value : JSON.stringify(value);
|
|
@@ -506,9 +509,15 @@ const runActionCall = (
|
|
|
506
509
|
);
|
|
507
510
|
return {ok: true, value: answered};
|
|
508
511
|
}
|
|
512
|
+
if (operation === START_EFFECT) {
|
|
513
|
+
if (context.travelling) return {ok: true, value: undefined};
|
|
514
|
+
if (!context.startRun) return {ok: false, error: 'assign.start: nothing here starts a run.'};
|
|
515
|
+
// What the host returns (a promise, while the run is being started) keeps the control busy.
|
|
516
|
+
return {ok: true, value: context.startRun()};
|
|
517
|
+
}
|
|
509
518
|
return {
|
|
510
519
|
ok: false,
|
|
511
|
-
error: `${operation} is not a callback's one thing: a callback holds one task call or one effect (queries.<name>.refetch(), queries.<name>.fetch_more(...), ui.copy, task.answer).`,
|
|
520
|
+
error: `${operation} is not a callback's one thing: a callback holds one task call or one effect (queries.<name>.refetch(), queries.<name>.fetch_more(...), ui.copy, task.answer, assign.start).`,
|
|
512
521
|
};
|
|
513
522
|
};
|
|
514
523
|
|
|
@@ -214,6 +214,8 @@ export type BlokResolutionContext = {
|
|
|
214
214
|
fetchMoreQuery?: (name: string, variables: Record<string, unknown>) => void;
|
|
215
215
|
/** Answers the open ask of `task` (`task.answer(values)`). */
|
|
216
216
|
answerTask?: (values: Record<string, unknown>) => unknown;
|
|
217
|
+
/** Starts the run an assign blok prepares (`assign.start()`); undefined where the host starts none. */
|
|
218
|
+
startRun?: () => unknown;
|
|
217
219
|
/** Set while the blok shows a moment in the past: no command runs. */
|
|
218
220
|
travelling?: boolean;
|
|
219
221
|
resolvePath: (path: string) => string;
|
|
@@ -248,11 +250,14 @@ export type BlokRuntimeContext = {
|
|
|
248
250
|
fetchMoreQuery: ((name: string, variables: Record<string, unknown>) => void) | undefined;
|
|
249
251
|
/** Answers the open ask of `task`; set by a host that holds one. */
|
|
250
252
|
answerTask: ((values: Record<string, unknown>) => unknown) | undefined;
|
|
253
|
+
/** Starts the run an assign blok prepares; set by a host that can start one. */
|
|
254
|
+
startRun: (() => unknown) | undefined;
|
|
251
255
|
setStatus: (path: string, status: BlokSourceStatus | null) => void;
|
|
252
256
|
setTravelAt: (at: string | null) => void;
|
|
253
257
|
setRefetchQuery: (refetch: ((name: string) => void) | undefined) => void;
|
|
254
258
|
setFetchMoreQuery: (fetchMore: ((name: string, variables: Record<string, unknown>) => void) | undefined) => void;
|
|
255
259
|
setAnswerTask: (answer: ((values: Record<string, unknown>) => unknown) | undefined) => void;
|
|
260
|
+
setStartRun: (start: (() => unknown) | undefined) => void;
|
|
256
261
|
agentMappingStateUpdates: BlokAgentMappingStateUpdates;
|
|
257
262
|
invokeFunction: BlokInvokeFunctionHandler;
|
|
258
263
|
dispatchAction: BlokDispatchActionHandler;
|
package/src/spec/bsx_v2.json
CHANGED
|
@@ -1490,6 +1490,14 @@
|
|
|
1490
1490
|
"accepts_children": false,
|
|
1491
1491
|
"catalog": "scene@1"
|
|
1492
1492
|
},
|
|
1493
|
+
"args": {
|
|
1494
|
+
"text_prop": null,
|
|
1495
|
+
"context": "HTML",
|
|
1496
|
+
"children_context": null,
|
|
1497
|
+
"inherits_context": false,
|
|
1498
|
+
"accepts_children": false,
|
|
1499
|
+
"catalog": "base@2"
|
|
1500
|
+
},
|
|
1493
1501
|
"ask": {
|
|
1494
1502
|
"text_prop": null,
|
|
1495
1503
|
"context": "HTML",
|
|
@@ -8659,6 +8667,285 @@
|
|
|
8659
8667
|
"space.kind"
|
|
8660
8668
|
]
|
|
8661
8669
|
},
|
|
8670
|
+
{
|
|
8671
|
+
"name": "an assign blok",
|
|
8672
|
+
"source": "<Html><Card><Text>{args.slides}</Text><args /><Button onClick={assign.start()}>Start</Button></Card></Html>",
|
|
8673
|
+
"tree": {
|
|
8674
|
+
"id": "Html[0]",
|
|
8675
|
+
"component": "Html",
|
|
8676
|
+
"children": [
|
|
8677
|
+
{
|
|
8678
|
+
"id": "Html[0]/Card[0]",
|
|
8679
|
+
"component": "Card",
|
|
8680
|
+
"children": [
|
|
8681
|
+
{
|
|
8682
|
+
"id": "Html[0]/Card[0]/Text[0]",
|
|
8683
|
+
"component": "Text",
|
|
8684
|
+
"props": [
|
|
8685
|
+
{
|
|
8686
|
+
"key": "text",
|
|
8687
|
+
"dynamic_value": {
|
|
8688
|
+
"path": "args.slides"
|
|
8689
|
+
}
|
|
8690
|
+
}
|
|
8691
|
+
]
|
|
8692
|
+
},
|
|
8693
|
+
{
|
|
8694
|
+
"id": "Html[0]/Card[0]/args[0]",
|
|
8695
|
+
"component": "args"
|
|
8696
|
+
},
|
|
8697
|
+
{
|
|
8698
|
+
"id": "Html[0]/Card[0]/Button[0]",
|
|
8699
|
+
"component": "Button",
|
|
8700
|
+
"props": [
|
|
8701
|
+
{
|
|
8702
|
+
"key": "onClick",
|
|
8703
|
+
"util_call": {
|
|
8704
|
+
"operation": "assign.start"
|
|
8705
|
+
}
|
|
8706
|
+
},
|
|
8707
|
+
{
|
|
8708
|
+
"key": "label",
|
|
8709
|
+
"static_value": "Start"
|
|
8710
|
+
}
|
|
8711
|
+
]
|
|
8712
|
+
}
|
|
8713
|
+
]
|
|
8714
|
+
}
|
|
8715
|
+
]
|
|
8716
|
+
},
|
|
8717
|
+
"scope": {
|
|
8718
|
+
"kind": "assign",
|
|
8719
|
+
"context": "HTML",
|
|
8720
|
+
"dependencies": [
|
|
8721
|
+
{
|
|
8722
|
+
"key": "robot",
|
|
8723
|
+
"action_dependencies": [
|
|
8724
|
+
{
|
|
8725
|
+
"key": "move_to",
|
|
8726
|
+
"demand": {
|
|
8727
|
+
"arg_matches": [
|
|
8728
|
+
{
|
|
8729
|
+
"key": "position"
|
|
8730
|
+
}
|
|
8731
|
+
],
|
|
8732
|
+
"return_matches": [
|
|
8733
|
+
{
|
|
8734
|
+
"key": "arrived"
|
|
8735
|
+
}
|
|
8736
|
+
]
|
|
8737
|
+
}
|
|
8738
|
+
}
|
|
8739
|
+
],
|
|
8740
|
+
"state_dependencies": [
|
|
8741
|
+
{
|
|
8742
|
+
"key": "arm",
|
|
8743
|
+
"demand": {
|
|
8744
|
+
"matches": [
|
|
8745
|
+
{
|
|
8746
|
+
"key": "joints",
|
|
8747
|
+
"kind": "LIST"
|
|
8748
|
+
},
|
|
8749
|
+
{
|
|
8750
|
+
"key": "mode",
|
|
8751
|
+
"kind": "STRING"
|
|
8752
|
+
}
|
|
8753
|
+
]
|
|
8754
|
+
}
|
|
8755
|
+
}
|
|
8756
|
+
]
|
|
8757
|
+
}
|
|
8758
|
+
],
|
|
8759
|
+
"locals": [],
|
|
8760
|
+
"queries": [],
|
|
8761
|
+
"subscriptions": [],
|
|
8762
|
+
"args": [
|
|
8763
|
+
"slides"
|
|
8764
|
+
],
|
|
8765
|
+
"catalogs": [],
|
|
8766
|
+
"catalog": true,
|
|
8767
|
+
"module": null
|
|
8768
|
+
},
|
|
8769
|
+
"resolved": {
|
|
8770
|
+
"locals": []
|
|
8771
|
+
},
|
|
8772
|
+
"codes": []
|
|
8773
|
+
},
|
|
8774
|
+
{
|
|
8775
|
+
"name": "an assign blok places the run's dependencies",
|
|
8776
|
+
"source": "<Html><Space room=\"room:lab\"><Placed dep=\"robot\" /></Space></Html>",
|
|
8777
|
+
"tree": {
|
|
8778
|
+
"id": "Html[0]",
|
|
8779
|
+
"component": "Html",
|
|
8780
|
+
"children": [
|
|
8781
|
+
{
|
|
8782
|
+
"id": "Html[0]/Space[0]",
|
|
8783
|
+
"component": "Space",
|
|
8784
|
+
"props": [
|
|
8785
|
+
{
|
|
8786
|
+
"key": "room",
|
|
8787
|
+
"static_value": "room:lab"
|
|
8788
|
+
}
|
|
8789
|
+
],
|
|
8790
|
+
"children": [
|
|
8791
|
+
{
|
|
8792
|
+
"id": "Html[0]/Space[0]/Placed[0]",
|
|
8793
|
+
"component": "Placed",
|
|
8794
|
+
"props": [
|
|
8795
|
+
{
|
|
8796
|
+
"key": "dep",
|
|
8797
|
+
"static_value": "robot"
|
|
8798
|
+
}
|
|
8799
|
+
]
|
|
8800
|
+
}
|
|
8801
|
+
]
|
|
8802
|
+
}
|
|
8803
|
+
]
|
|
8804
|
+
},
|
|
8805
|
+
"scope": {
|
|
8806
|
+
"kind": "assign",
|
|
8807
|
+
"context": "HTML",
|
|
8808
|
+
"dependencies": [
|
|
8809
|
+
{
|
|
8810
|
+
"key": "robot",
|
|
8811
|
+
"action_dependencies": [
|
|
8812
|
+
{
|
|
8813
|
+
"key": "move_to",
|
|
8814
|
+
"demand": {
|
|
8815
|
+
"arg_matches": [
|
|
8816
|
+
{
|
|
8817
|
+
"key": "position"
|
|
8818
|
+
}
|
|
8819
|
+
],
|
|
8820
|
+
"return_matches": [
|
|
8821
|
+
{
|
|
8822
|
+
"key": "arrived"
|
|
8823
|
+
}
|
|
8824
|
+
]
|
|
8825
|
+
}
|
|
8826
|
+
}
|
|
8827
|
+
],
|
|
8828
|
+
"state_dependencies": [
|
|
8829
|
+
{
|
|
8830
|
+
"key": "arm",
|
|
8831
|
+
"demand": {
|
|
8832
|
+
"matches": [
|
|
8833
|
+
{
|
|
8834
|
+
"key": "joints",
|
|
8835
|
+
"kind": "LIST"
|
|
8836
|
+
},
|
|
8837
|
+
{
|
|
8838
|
+
"key": "mode",
|
|
8839
|
+
"kind": "STRING"
|
|
8840
|
+
}
|
|
8841
|
+
]
|
|
8842
|
+
}
|
|
8843
|
+
}
|
|
8844
|
+
]
|
|
8845
|
+
}
|
|
8846
|
+
],
|
|
8847
|
+
"locals": [],
|
|
8848
|
+
"queries": [],
|
|
8849
|
+
"subscriptions": [],
|
|
8850
|
+
"args": null,
|
|
8851
|
+
"catalogs": [],
|
|
8852
|
+
"catalog": true,
|
|
8853
|
+
"module": null
|
|
8854
|
+
},
|
|
8855
|
+
"resolved": {
|
|
8856
|
+
"locals": []
|
|
8857
|
+
},
|
|
8858
|
+
"codes": []
|
|
8859
|
+
},
|
|
8860
|
+
{
|
|
8861
|
+
"name": "an assign blok has no task",
|
|
8862
|
+
"source": "<Html><Text>{task.status}</Text></Html>",
|
|
8863
|
+
"tree": {
|
|
8864
|
+
"id": "Html[0]",
|
|
8865
|
+
"component": "Html",
|
|
8866
|
+
"children": [
|
|
8867
|
+
{
|
|
8868
|
+
"id": "Html[0]/Text[0]",
|
|
8869
|
+
"component": "Text",
|
|
8870
|
+
"props": [
|
|
8871
|
+
{
|
|
8872
|
+
"key": "text",
|
|
8873
|
+
"dynamic_value": {
|
|
8874
|
+
"path": "task.status"
|
|
8875
|
+
}
|
|
8876
|
+
}
|
|
8877
|
+
]
|
|
8878
|
+
}
|
|
8879
|
+
]
|
|
8880
|
+
},
|
|
8881
|
+
"scope": {
|
|
8882
|
+
"kind": "assign",
|
|
8883
|
+
"context": "HTML",
|
|
8884
|
+
"dependencies": [],
|
|
8885
|
+
"locals": [],
|
|
8886
|
+
"queries": [],
|
|
8887
|
+
"subscriptions": [],
|
|
8888
|
+
"args": null,
|
|
8889
|
+
"catalogs": [],
|
|
8890
|
+
"catalog": true,
|
|
8891
|
+
"module": null
|
|
8892
|
+
},
|
|
8893
|
+
"resolved": {
|
|
8894
|
+
"locals": []
|
|
8895
|
+
},
|
|
8896
|
+
"codes": [
|
|
8897
|
+
"roots.not_in_kind"
|
|
8898
|
+
]
|
|
8899
|
+
},
|
|
8900
|
+
{
|
|
8901
|
+
"name": "starting a run is an assign blok's",
|
|
8902
|
+
"source": "<Html><args /><Button onClick={assign.start()}>Start</Button></Html>",
|
|
8903
|
+
"tree": {
|
|
8904
|
+
"id": "Html[0]",
|
|
8905
|
+
"component": "Html",
|
|
8906
|
+
"children": [
|
|
8907
|
+
{
|
|
8908
|
+
"id": "Html[0]/args[0]",
|
|
8909
|
+
"component": "args"
|
|
8910
|
+
},
|
|
8911
|
+
{
|
|
8912
|
+
"id": "Html[0]/Button[0]",
|
|
8913
|
+
"component": "Button",
|
|
8914
|
+
"props": [
|
|
8915
|
+
{
|
|
8916
|
+
"key": "onClick",
|
|
8917
|
+
"util_call": {
|
|
8918
|
+
"operation": "assign.start"
|
|
8919
|
+
}
|
|
8920
|
+
},
|
|
8921
|
+
{
|
|
8922
|
+
"key": "label",
|
|
8923
|
+
"static_value": "Start"
|
|
8924
|
+
}
|
|
8925
|
+
]
|
|
8926
|
+
}
|
|
8927
|
+
]
|
|
8928
|
+
},
|
|
8929
|
+
"scope": {
|
|
8930
|
+
"kind": "action",
|
|
8931
|
+
"context": "HTML",
|
|
8932
|
+
"dependencies": [],
|
|
8933
|
+
"locals": [],
|
|
8934
|
+
"queries": [],
|
|
8935
|
+
"subscriptions": [],
|
|
8936
|
+
"args": null,
|
|
8937
|
+
"catalogs": [],
|
|
8938
|
+
"catalog": true,
|
|
8939
|
+
"module": null
|
|
8940
|
+
},
|
|
8941
|
+
"resolved": {
|
|
8942
|
+
"locals": []
|
|
8943
|
+
},
|
|
8944
|
+
"codes": [
|
|
8945
|
+
"assign.kind",
|
|
8946
|
+
"assign.kind"
|
|
8947
|
+
]
|
|
8948
|
+
},
|
|
8662
8949
|
{
|
|
8663
8950
|
"name": "an unknown component",
|
|
8664
8951
|
"source": "<Html><Frobnicator /></Html>",
|
|
@@ -17,6 +17,18 @@
|
|
|
17
17
|
"text_prop": null,
|
|
18
18
|
"props": []
|
|
19
19
|
},
|
|
20
|
+
{
|
|
21
|
+
"name": "args",
|
|
22
|
+
"description": "The arguments of the run an assign blok starts, as the form the action's ports generate: filled in right here, and read as `args.<key>`. Without it the host shows the form beside the blok. An assign blok only.",
|
|
23
|
+
"context": "HTML",
|
|
24
|
+
"children_context": null,
|
|
25
|
+
"inherits_context": false,
|
|
26
|
+
"accepts_children": false,
|
|
27
|
+
"downstream_of": [],
|
|
28
|
+
"not_downstream_of": [],
|
|
29
|
+
"text_prop": null,
|
|
30
|
+
"props": []
|
|
31
|
+
},
|
|
20
32
|
{
|
|
21
33
|
"name": "ask",
|
|
22
34
|
"description": "The open ask of the task this blok is about (`task.ask`), as the form its ports generate: answered right here, which resumes the task. Shows nothing while no ask is open. Replaces TaskAsk.",
|
package/src/spec/vocabulary.json
CHANGED
|
@@ -53,6 +53,12 @@
|
|
|
53
53
|
"locals": true,
|
|
54
54
|
"contexts": ["HTML", "SCENE"]
|
|
55
55
|
},
|
|
56
|
+
"assign": {
|
|
57
|
+
"description": "An action's own blok for starting a run of it (assign_bloks): shown before there is a task, with the arguments being filled in as args and the agents a run would get as deps.",
|
|
58
|
+
"roots": ["self", "deps", "args", "queries", "subscriptions", "viewer"],
|
|
59
|
+
"locals": true,
|
|
60
|
+
"contexts": ["HTML", "SCENE"]
|
|
61
|
+
},
|
|
56
62
|
"action_logo": {
|
|
57
63
|
"description": "An action's logo, drawn against the task the viewer last ran of it (null until then).",
|
|
58
64
|
"roots": ["task"],
|
|
@@ -141,7 +147,7 @@
|
|
|
141
147
|
]
|
|
142
148
|
},
|
|
143
149
|
"functions": {
|
|
144
|
-
"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.answer, query.*). `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.",
|
|
150
|
+
"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.answer, assign.start, query.*). `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.",
|
|
145
151
|
"cmp.eq": {"params": [["a", "ANY"], ["b", "ANY"]], "returns": "BOOL", "description": "Deep JSON equality.", "null": "null equals only null"},
|
|
146
152
|
"cmp.ne": {"params": [["a", "ANY"], ["b", "ANY"]], "returns": "BOOL", "description": "Not deep-equal.", "null": "null equals only null"},
|
|
147
153
|
"cmp.gt": {"params": [["a", "ANY"], ["b", "ANY"]], "returns": "BOOL", "description": "a > b, numbers or strings.", "null": "false"},
|
|
@@ -251,6 +257,7 @@
|
|
|
251
257
|
"time.diff": {"params": [["start", "STRING"], ["end", "STRING"]], "returns": "FLOAT", "description": "Seconds from start to end (ISO 8601 datetimes); negative when end is earlier. Pure: relative time to the viewed moment is the <Time> component's.", "null": "null"},
|
|
252
258
|
"ui.copy": {"params": [["text", "ANY"]], "returns": "ANY", "effect": true, "description": "Copies text to the viewer's clipboard: the only non-task effect.", "null": "copies an empty string"},
|
|
253
259
|
"task.answer": {"params": [["values", "DICT"]], "returns": "ANY", "effect": true, "task_operation": true, "description": "Answers the open ask of `task`. Counts as a task operation.", "null": "answers with no values"},
|
|
260
|
+
"assign.start": {"params": [], "returns": "ANY", "effect": 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"},
|
|
254
261
|
"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"},
|
|
255
262
|
"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"}
|
|
256
263
|
},
|
|
@@ -265,7 +272,7 @@
|
|
|
265
272
|
"description": "What a prop or an argument may hold besides a literal, a path or a util call.",
|
|
266
273
|
"kinds": {
|
|
267
274
|
"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).",
|
|
268
|
-
"util_call": "A pure function, or an effect (ui.copy, task.answer, query.refetch, query.fetch_more) as a callback's one thing."
|
|
275
|
+
"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."
|
|
269
276
|
},
|
|
270
277
|
"reserved_kinds": {
|
|
271
278
|
"service_call": "Reserved for mutations, should they ever exist. Renderers refuse a call kind they do not know."
|
|
@@ -370,7 +377,7 @@
|
|
|
370
377
|
"callback.positional": {"level": "error", "message": "{call}: a task call names its arguments (name: value)."},
|
|
371
378
|
"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>."},
|
|
372
379
|
"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."},
|
|
373
|
-
"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).", "hint": "Give {key} a task call (deps.<key>.<action>(name: value)) or one effect, not a value."},
|
|
380
|
+
"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."},
|
|
374
381
|
"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}."},
|
|
375
382
|
"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."},
|
|
376
383
|
"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."},
|
|
@@ -416,6 +423,7 @@
|
|
|
416
423
|
"context.root": {"level": "error", "message": "The root of a {context} blok is <{root}>, not <{component}>.", "hint": "Make <{root}> the root and put <{component}> inside it."},
|
|
417
424
|
"context.root_unknown": {"level": "error", "message": "A blok's root names its context ({roots}), not <{component}>.", "hint": "Make the root one of {roots} and put <{component}> inside it."},
|
|
418
425
|
"context.kind": {"level": "error", "message": "A{n} {kind} blok is drawn in {contexts}, not {context}."},
|
|
426
|
+
"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": "Declare it with the action: @app.workflow(assign_bloks=[...])."},
|
|
419
427
|
"space.kind": {"level": "error", "message": "<{component}> places the run's dependencies, so only an action's own blok holds it, not a{n} {kind} blok.", "hint": "Declare it with the action: @app.workflow(bloks=[...])."},
|
|
420
428
|
"logo.complexity": {"level": "error", "message": "{detail}"},
|
|
421
429
|
"catalog.unknown_component": {"level": "warning", "message": "<{component}> is in no catalog in force ({catalogs}).", "hint": "Look the component up in the catalog; names are case-sensitive."},
|
package/src/spec/vocabulary.ts
CHANGED
|
@@ -8,8 +8,8 @@ import vocabularyJson from './vocabulary.json';
|
|
|
8
8
|
* diagnostics is read from this one file, never restated.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
export type BlokKind = 'agent' | 'custom' | 'task' | 'action' | 'action_logo';
|
|
12
|
-
export const BLOK_KINDS: readonly BlokKind[] = ['agent', 'custom', 'task', 'action', 'action_logo'];
|
|
11
|
+
export type BlokKind = 'agent' | 'custom' | 'task' | 'action' | 'assign' | 'action_logo';
|
|
12
|
+
export const BLOK_KINDS: readonly BlokKind[] = ['agent', 'custom', 'task', 'action', 'assign', 'action_logo'];
|
|
13
13
|
|
|
14
14
|
export type BlokContextName = 'HTML' | 'SCENE' | 'LOGO';
|
|
15
15
|
|