@cratis/stage.runtime 4.216.1 → 4.218.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/src/index.d.ts +1 -1
- package/dist/src/index.js +1204 -1198
- package/dist/src/screenplayGuard.d.ts +11 -0
- package/dist/src/stageActionSubject.d.ts +2 -0
- package/dist/src/stageData.d.ts +9 -1
- package/dist/src/stageRowInteractions.d.ts +2 -3
- package/package.json +18 -18
- package/dist/src/StageGuardedAction.d.ts +0 -20
- package/dist/src/stageGuards.d.ts +0 -88
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { runBindings } from '@cratis/scene.engine';
|
|
2
|
+
/** Runs every Stage-owned interaction through Screenplay admission before native Scene selection. */
|
|
3
|
+
export declare function runScreenplayBindings(...[bindings, dispatcher, context]: Parameters<typeof runBindings>): ReturnType<typeof runBindings>;
|
|
4
|
+
/** Restricts native Scene guards to Screenplay's string-only contains contract before branch selection. */
|
|
5
|
+
export declare function screenplayGuard<Condition>(condition: Condition, item: unknown): Condition;
|
|
6
|
+
/** Applies the same admission rule to every alternative, including those native selection would not reach. */
|
|
7
|
+
export declare function screenplayGuardAlternatives(alternatives: unknown, item: unknown): unknown;
|
|
8
|
+
/** Restricts a binding without changing its native Scene sequencing or fallback actions. */
|
|
9
|
+
export declare function screenplayGuardBinding<Binding extends {
|
|
10
|
+
alternatives?: unknown;
|
|
11
|
+
}>(binding: Binding, item: unknown): Binding;
|
|
@@ -18,6 +18,8 @@ export interface SubjectForm extends ScreenRows {
|
|
|
18
18
|
}
|
|
19
19
|
/** The explicit subject an action element names, or nothing when the subject was omitted. */
|
|
20
20
|
export declare function actionSubjectOf(element: ExternalComponent): ActionSubject | undefined;
|
|
21
|
+
/** Semantic schema intent beats advisory row/creation hints; explicit subjects retain their own binding semantics. */
|
|
22
|
+
export declare function actionCreatesEntity(element: ExternalComponent, schema: string | undefined): boolean;
|
|
21
23
|
/** The one selected row an `item` subject acts on; no subject, a `screen` subject and two or more selected rows name none. */
|
|
22
24
|
export declare function subjectRowOf(subject: ActionSubject | undefined, selectedRows: Record<string, unknown>[]): Record<string, unknown> | undefined;
|
|
23
25
|
/** Whether an action waits, visible and disabled: a `for item` action without its one selected row. */
|
package/dist/src/stageData.d.ts
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import type React from 'react';
|
|
2
|
-
import type
|
|
2
|
+
import { type BindingExpression } from '@cratis/scene.model';
|
|
3
3
|
import type { StageRoutes } from './stageRoutes';
|
|
4
|
+
import { type RegisteredComponentProps } from '@cratis/scene.react';
|
|
5
|
+
import type { ExternalComponent } from '@cratis/scene.model';
|
|
6
|
+
/** Whether the component uses Scene's guarded-action contract. */
|
|
7
|
+
export declare function isGuardedAction(element: ExternalComponent): boolean;
|
|
8
|
+
/** Supplies Stage's nearest-data subject to Scene; Scene alone selects and executes the branch. */
|
|
9
|
+
export declare function StageSceneGuardedAction(props: Omit<RegisteredComponentProps, 'slots'> & {
|
|
10
|
+
slots?: RegisteredComponentProps['slots'];
|
|
11
|
+
}): React.JSX.Element;
|
|
4
12
|
interface QueryState {
|
|
5
13
|
name?: string;
|
|
6
14
|
/** The read model's name, under which the rows are published to the binding scope as well - where a summary looks them up. */
|
|
@@ -12,9 +12,8 @@ export interface RowInteractions {
|
|
|
12
12
|
* Runs a table's `on double click` bindings for the row that was double clicked.
|
|
13
13
|
*
|
|
14
14
|
* The bindings are the table's own, resolved and run by the Scene interaction engine - the same engine that runs
|
|
15
|
-
* every other interaction - with
|
|
16
|
-
*
|
|
17
|
-
* row runs, and the `otherwise` branch runs when none does.
|
|
15
|
+
* every other interaction - with the subject meaning the row. Scene selects the first matching alternative
|
|
16
|
+
* and runs the otherwise actions only when none match.
|
|
18
17
|
*
|
|
19
18
|
* A row's single click (selection, or navigation to the row) would otherwise always win the race with a double
|
|
20
19
|
* click, because a double click starts with a click. When the table declares a double click, a single click waits
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cratis/stage.runtime",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.218.0",
|
|
4
4
|
"description": "The Cratis Stage application runtime for Arc and Scene",
|
|
5
5
|
"author": "Cratis",
|
|
6
6
|
"type": "module",
|
|
@@ -44,19 +44,19 @@
|
|
|
44
44
|
"@cratis/arc": "22.146.0",
|
|
45
45
|
"@cratis/arc.react": "22.146.0",
|
|
46
46
|
"@cratis/components": "4.38.1",
|
|
47
|
-
"@cratis/fundamentals": "7.27.
|
|
48
|
-
"@cratis/scene.blueprint.default": "4.
|
|
49
|
-
"@cratis/scene.components": "4.
|
|
50
|
-
"@cratis/scene.engine": "4.
|
|
51
|
-
"@cratis/scene.model": "4.
|
|
52
|
-
"@cratis/scene.primereact": "4.
|
|
53
|
-
"@cratis/scene.react": "4.
|
|
54
|
-
"@primereact/ui": "11.2.
|
|
47
|
+
"@cratis/fundamentals": "7.27.1",
|
|
48
|
+
"@cratis/scene.blueprint.default": "4.87.0",
|
|
49
|
+
"@cratis/scene.components": "4.87.0",
|
|
50
|
+
"@cratis/scene.engine": "4.87.0",
|
|
51
|
+
"@cratis/scene.model": "4.87.0",
|
|
52
|
+
"@cratis/scene.primereact": "4.87.0",
|
|
53
|
+
"@cratis/scene.react": "4.87.0",
|
|
54
|
+
"@primereact/ui": "11.2.2",
|
|
55
55
|
"@primeuix/themes": "3.0.1",
|
|
56
56
|
"lucide-react": "1.52.0",
|
|
57
|
-
"primereact": "11.2.
|
|
58
|
-
"react": "19.3.
|
|
59
|
-
"react-dom": "19.3.
|
|
57
|
+
"primereact": "11.2.2",
|
|
58
|
+
"react": "19.3.1",
|
|
59
|
+
"react-dom": "19.3.1",
|
|
60
60
|
"vite": "8.3.5"
|
|
61
61
|
},
|
|
62
62
|
"peerDependenciesMeta": {
|
|
@@ -74,15 +74,15 @@
|
|
|
74
74
|
}
|
|
75
75
|
},
|
|
76
76
|
"devDependencies": {
|
|
77
|
-
"@primereact/core": "11.2.
|
|
77
|
+
"@primereact/core": "11.2.2",
|
|
78
78
|
"@testing-library/react": "16.3.3",
|
|
79
|
-
"@types/node": "26.6.
|
|
79
|
+
"@types/node": "26.6.6",
|
|
80
80
|
"@types/react": "19.3.0",
|
|
81
81
|
"@types/react-dom": "19.3.0",
|
|
82
|
-
"@vitejs/plugin-react": "6.1.
|
|
83
|
-
"jsdom": "30.1.
|
|
84
|
-
"react-dom": "19.3.
|
|
82
|
+
"@vitejs/plugin-react": "6.1.2",
|
|
83
|
+
"jsdom": "30.1.3",
|
|
84
|
+
"react-dom": "19.3.1",
|
|
85
85
|
"typescript": "6.0.3",
|
|
86
|
-
"vitest": "5.0.
|
|
86
|
+
"vitest": "5.0.5"
|
|
87
87
|
}
|
|
88
88
|
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { ExternalComponent } from '@cratis/scene.model';
|
|
2
|
-
import type { InteractionHandlers } from '@cratis/scene.react';
|
|
3
|
-
export interface StageGuardedActionProps {
|
|
4
|
-
element: ExternalComponent;
|
|
5
|
-
interactions?: InteractionHandlers;
|
|
6
|
-
}
|
|
7
|
-
/** Whether an element is an action authored with `when ... otherwise`. */
|
|
8
|
-
export declare function isGuardedAction(element: ExternalComponent): boolean;
|
|
9
|
-
/**
|
|
10
|
-
* Renders an action authored with `when <guard> execute <command> ... otherwise ...`.
|
|
11
|
-
*
|
|
12
|
-
* The guard is evaluated against the item on every render, so the action follows the data: a work item that is
|
|
13
|
-
* closed while the screen is open stops offering Close. The first alternative that holds is the command the action
|
|
14
|
-
* executes; when none holds, the authored `otherwise` decides - `hidden` renders nothing, `execute` offers its
|
|
15
|
-
* command instead. Without an item there is nothing to decide about, so nothing is offered.
|
|
16
|
-
*
|
|
17
|
-
* A guard this runtime cannot evaluate never lets a command through: the action is shown disabled with the
|
|
18
|
-
* diagnostic, which is the same refusal Stage reports when it admits the Scene.
|
|
19
|
-
*/
|
|
20
|
-
export declare function StageGuardedAction({ element, interactions }: StageGuardedActionProps): import("react").JSX.Element | null;
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Evaluates the guards a Screenplay `when ... otherwise` carries.
|
|
3
|
-
*
|
|
4
|
-
* A guard compares a field of the subject - `item`, the record the nearest `data` declaration reads, or the row an
|
|
5
|
-
* interaction happened on - with a literal, and combines comparisons with `and` and `or`. That is the whole guard
|
|
6
|
-
* language Screenplay admits, and the same shape Stage emits into the Scene for a guarded action and for a guarded
|
|
7
|
-
* interaction. Anything else is not evaluable: the answer is then `undefined`, never `true`, so a guard the runtime
|
|
8
|
-
* does not understand can never let a command through.
|
|
9
|
-
*/
|
|
10
|
-
/** The binding path a guarded interaction binding's condition carries; its `value` is a {@link GuardSelection}. */
|
|
11
|
-
export declare const guardPath = "$guard";
|
|
12
|
-
/** One condition of a guard. */
|
|
13
|
-
export type GuardCondition = ComparisonCondition | LogicalCondition;
|
|
14
|
-
/**
|
|
15
|
-
* A field of the guard's subject, such as `{ subject: 'item.status' }`.
|
|
16
|
-
*
|
|
17
|
-
* It is deliberately not a binding: Scene resolves every `{ path }` object in a component's properties against the
|
|
18
|
-
* data context before the component renders, which would replace the reference with a value. A `path` is still read,
|
|
19
|
-
* for guards written directly as Scene JSON or carried where Scene does not resolve them.
|
|
20
|
-
*/
|
|
21
|
-
export interface SubjectReference {
|
|
22
|
-
subject?: string;
|
|
23
|
-
path?: string;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Reads the subject path a reference names.
|
|
27
|
-
* @param reference The reference.
|
|
28
|
-
* @returns The path, or `undefined` when it names none.
|
|
29
|
-
*/
|
|
30
|
-
export declare function subjectPath(reference: unknown): string | undefined;
|
|
31
|
-
/** Compares a field of the subject with a literal. */
|
|
32
|
-
export interface ComparisonCondition {
|
|
33
|
-
kind: 'comparison';
|
|
34
|
-
left: SubjectReference;
|
|
35
|
-
operator: string;
|
|
36
|
-
right: unknown;
|
|
37
|
-
/** The members of the enumeration the field is, in declared order, when it is one. */
|
|
38
|
-
enumeration?: string[];
|
|
39
|
-
}
|
|
40
|
-
/** Combines two conditions. */
|
|
41
|
-
export interface LogicalCondition {
|
|
42
|
-
kind: 'logical';
|
|
43
|
-
left: GuardCondition;
|
|
44
|
-
operator: string;
|
|
45
|
-
right: GuardCondition;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Which branch of an ordered first-match guard a binding is: alternative `index`, or the `otherwise` that runs when
|
|
49
|
-
* there is a subject and no alternative holds.
|
|
50
|
-
*/
|
|
51
|
-
export interface GuardSelection {
|
|
52
|
-
kind: 'firstMatch' | 'otherwise';
|
|
53
|
-
index?: number;
|
|
54
|
-
alternatives: unknown[];
|
|
55
|
-
}
|
|
56
|
-
/** The diagnostic a guard the runtime cannot evaluate is reported with. */
|
|
57
|
-
export declare const unevaluableGuardCode = "STAGE-SCENE-ACTION-001";
|
|
58
|
-
/**
|
|
59
|
-
* Evaluates one condition against a subject.
|
|
60
|
-
*
|
|
61
|
-
* A missing or null field does not match - `item.status == "open"` is false for an item without a status - because
|
|
62
|
-
* that is what Screenplay specifies and because the alternative, matching on absence, would run a command against
|
|
63
|
-
* data that never said it could.
|
|
64
|
-
*
|
|
65
|
-
* @param condition The condition as the Scene carries it.
|
|
66
|
-
* @param subject The record the condition is about.
|
|
67
|
-
* @returns Whether it holds, or `undefined` when it is not a condition this runtime can evaluate.
|
|
68
|
-
*/
|
|
69
|
-
export declare function evaluateCondition(condition: unknown, subject: Record<string, unknown>): boolean | undefined;
|
|
70
|
-
/** Whether every condition can be evaluated, independently of any subject. */
|
|
71
|
-
export declare function canEvaluate(conditions: unknown[]): boolean;
|
|
72
|
-
/**
|
|
73
|
-
* Picks the first alternative whose condition holds.
|
|
74
|
-
* @param conditions The alternatives' conditions, in authored order.
|
|
75
|
-
* @param subject The record they are about.
|
|
76
|
-
* @returns The index of the first that holds, -1 when none does, or `undefined` when any is not evaluable.
|
|
77
|
-
*/
|
|
78
|
-
export declare function firstMatch(conditions: unknown[], subject: Record<string, unknown>): number | undefined;
|
|
79
|
-
/**
|
|
80
|
-
* Resolves a guarded interaction binding's condition: whether its branch is the one that runs for this subject.
|
|
81
|
-
* @param selection The {@link GuardSelection} the binding carries.
|
|
82
|
-
* @param subject The record the interaction is about, when there is one.
|
|
83
|
-
* @returns Whether the branch runs, or `undefined` when there is no subject or the guard is not evaluable - which
|
|
84
|
-
* the interaction engine reports and treats as not running.
|
|
85
|
-
*/
|
|
86
|
-
export declare function resolveGuard(selection: unknown, subject: unknown): boolean | undefined;
|
|
87
|
-
/** Resolves a binding path against a subject, for paths that start with `item.`. */
|
|
88
|
-
export declare function subjectValue(path: string, subject: unknown): unknown;
|