|
| 1 | +import { ComponentContext } from './component-context'; |
1 | 2 | import { Vector } from './core';
|
2 | 3 | import { Branches, ComponentType, Sequence, Step } from './definition';
|
3 | 4 | import { DesignerContext } from './designer-context';
|
4 |
| -import { ComponentContext, StepComponent } from './workspace'; |
| 5 | +import { StepComponent, Component } from './workspace'; |
5 | 6 |
|
6 | 7 | export interface DesignerExtension {
|
7 | 8 | steps?: StepExtension[];
|
8 | 9 | uiComponents?: UiComponentExtension[];
|
9 | 10 | wheelController?: WheelControllerExtension;
|
| 11 | + placeholderController?: PlaceholderControllerExtension; |
| 12 | + rootComponent?: RootComponentExtension; |
10 | 13 | }
|
11 | 14 |
|
12 | 15 | // StepExtension
|
13 | 16 |
|
14 | 17 | export interface StepExtension<S extends Step = Step> {
|
15 | 18 | componentType: ComponentType;
|
16 |
| - createComponent(parentElement: SVGElement, step: S, parentSequence: Sequence, componentContext: ComponentContext): StepComponent; |
| 19 | + createComponent(parentElement: SVGElement, stepContext: StepContext<S>, componentContext: ComponentContext): StepComponent; |
17 | 20 | getChildren(step: S): StepChildren | null;
|
18 | 21 | }
|
19 | 22 |
|
| 23 | +export interface StepContext<S extends Step = Step> { |
| 24 | + parentSequence: Sequence; |
| 25 | + step: S; |
| 26 | + depth: number; |
| 27 | + position: number; |
| 28 | + isInputConnected: boolean; |
| 29 | + isOutputConnected: boolean; |
| 30 | +} |
| 31 | + |
20 | 32 | export interface StepChildren {
|
21 | 33 | type: StepChildrenType;
|
22 | 34 | sequences: Sequence | Branches;
|
@@ -51,3 +63,29 @@ export interface UiComponentExtension {
|
51 | 63 | export interface UiComponent {
|
52 | 64 | destroy(): void;
|
53 | 65 | }
|
| 66 | + |
| 67 | +// RootComponentExtension |
| 68 | + |
| 69 | +export interface RootComponentExtension { |
| 70 | + create( |
| 71 | + parentElement: SVGElement, |
| 72 | + sequence: Sequence, |
| 73 | + parentSequencePlaceIndicator: SequencePlaceIndicator | null, |
| 74 | + context: ComponentContext |
| 75 | + ): Component; |
| 76 | +} |
| 77 | + |
| 78 | +export interface SequencePlaceIndicator { |
| 79 | + sequence: Sequence; |
| 80 | + index: number; |
| 81 | +} |
| 82 | + |
| 83 | +// PlaceholderController |
| 84 | + |
| 85 | +export interface PlaceholderControllerExtension { |
| 86 | + create(): PlaceholderController; |
| 87 | +} |
| 88 | + |
| 89 | +export interface PlaceholderController { |
| 90 | + canCreate(sequence: Sequence, index: number): boolean; |
| 91 | +} |
0 commit comments