@weasel-js/diagram 1.10.1 → 1.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1160 -26
- package/dist/chunk-43LDZ6L4.js +2053 -0
- package/dist/chunk-43LDZ6L4.js.map +1 -0
- package/dist/chunk-CI3I3I6T.js +3600 -0
- package/dist/chunk-CI3I3I6T.js.map +1 -0
- package/dist/chunk-IM6DHWZO.js +3220 -0
- package/dist/chunk-IM6DHWZO.js.map +1 -0
- package/dist/chunk-QKSWZEJH.js +312 -0
- package/dist/chunk-QKSWZEJH.js.map +1 -0
- package/dist/chunk-T6DQT553.js +1431 -0
- package/dist/chunk-T6DQT553.js.map +1 -0
- package/dist/chunk-WDIE35AK.js +3 -0
- package/dist/chunk-WDIE35AK.js.map +1 -0
- package/dist/dataTypes-B-iEwKZp.d.ts +553 -0
- package/dist/effect-audio.d.ts +138 -0
- package/dist/effect-audio.js +527 -0
- package/dist/effect-audio.js.map +1 -0
- package/dist/effect.d.ts +782 -0
- package/dist/effect.js +2542 -0
- package/dist/effect.js.map +1 -0
- package/dist/icons.table.d.ts +6 -0
- package/dist/icons.table.js +32 -0
- package/dist/icons.table.js.map +1 -0
- package/dist/icons.table.json +24 -0
- package/dist/index.d.ts +2270 -355
- package/dist/index.js +953 -1331
- package/dist/index.js.map +1 -1
- package/dist/layout.d.ts +3 -2
- package/dist/layout.entry-CH9gc0CY.d.ts +512 -0
- package/dist/layout.js +3 -1
- package/dist/stageTypes-DvnR8cKQ.d.ts +189 -0
- package/dist/{layout.entry-BUkiRKuX.d.ts → types-BbHunLXm.d.ts} +382 -261
- package/package.json +32 -7
- package/dist/chunk-JZ4CVLAB.js +0 -1247
- package/dist/chunk-JZ4CVLAB.js.map +0 -1
package/dist/effect.d.ts
ADDED
|
@@ -0,0 +1,782 @@
|
|
|
1
|
+
import { c as EffectDoc, E as EffectPipeline, d as EffectWire, e as EffectStage, f as EffectPort, g as EffectGroup, a as EffectRun, b as EffectStageType, L as LookRoutes, h as EffectParamControl, i as EffectBox } from './stageTypes-DvnR8cKQ.js';
|
|
2
|
+
export { j as EffectParam, k as EffectPlaces, l as EffectStageRun, m as EffectType, n as LookRoute, o as formatParam, s as stageFromType } from './stageTypes-DvnR8cKQ.js';
|
|
3
|
+
import { D as DiagramTheme, a as DiagramData, b as DiagramSceneOptions, N as NodeStyle, c as DataEdge, E as EdgeStyle, d as DataNode, e as DiagramRouter, f as DiagramSpec } from './dataTypes-B-iEwKZp.js';
|
|
4
|
+
import { a as Row, M as MeasureRowText } from './types-BbHunLXm.js';
|
|
5
|
+
import * as react from 'react';
|
|
6
|
+
import { Paint } from '@weasel-js/core';
|
|
7
|
+
import { Vec2 } from '@weasel-js/core/math';
|
|
8
|
+
import { VisibleRafOptions } from '@weasel-js/react';
|
|
9
|
+
import '@weasel-js/geom';
|
|
10
|
+
|
|
11
|
+
/** How the stages of a chain are joined. */
|
|
12
|
+
interface ChainLinks {
|
|
13
|
+
/** By stage id: the input the main signal arrives on. */
|
|
14
|
+
mainIn: ReadonlyMap<string, string>;
|
|
15
|
+
/** By stage id: the output the main signal leaves by. */
|
|
16
|
+
mainOut: ReadonlyMap<string, string>;
|
|
17
|
+
/** By `k`: the index into `pipeline.wires` of the wire from `chain[k]` to
|
|
18
|
+
* `chain[k + 1]`, or `undefined` where no data wire joins them. */
|
|
19
|
+
between: readonly (number | undefined)[];
|
|
20
|
+
}
|
|
21
|
+
/** The first data wire from each chain stage to the next, and the ports it joins. */
|
|
22
|
+
declare function chainLinks(pipeline: EffectPipeline, chain: readonly string[]): ChainLinks;
|
|
23
|
+
/**
|
|
24
|
+
* The doc with `stage`, which must be on `mainChain`, moved to gap `to` of
|
|
25
|
+
* that chain: 0 before its first stage, `chain.length` after its last. Its
|
|
26
|
+
* main input and output wires come off and its old neighbors are wired to
|
|
27
|
+
* each other; the wire between its new neighbors comes off and it is wired
|
|
28
|
+
* between them. Side wires, control wires, and params stay with it. `null`
|
|
29
|
+
* where a new wire would join unlike types or a fed input, where `to` leaves
|
|
30
|
+
* it where it is, or where the rewired pipeline's main line would not read
|
|
31
|
+
* in the new order.
|
|
32
|
+
*/
|
|
33
|
+
declare function moveInChain(doc: EffectDoc, stage: string, to: number): EffectDoc | null;
|
|
34
|
+
/** Whether `moveInChain` would make the move. */
|
|
35
|
+
declare function canMoveInChain(doc: EffectDoc, stage: string, to: number): boolean;
|
|
36
|
+
|
|
37
|
+
/** One thing wrong with a pipeline, and where. */
|
|
38
|
+
interface EffectProblem {
|
|
39
|
+
kind: 'missing-stage' | 'missing-port' | 'wrong-direction' | 'type-mismatch' | 'duplicate-stage' | 'duplicate-port' | 'duplicate-group' | 'missing-member' | 'bad-split';
|
|
40
|
+
message: string;
|
|
41
|
+
stage?: string;
|
|
42
|
+
port?: string;
|
|
43
|
+
/** Index into `pipeline.wires`. */
|
|
44
|
+
wire?: number;
|
|
45
|
+
group?: string;
|
|
46
|
+
}
|
|
47
|
+
/** Everything wrong with `pipeline`. Never throws. */
|
|
48
|
+
declare function checkPipeline(pipeline: EffectPipeline): EffectProblem[];
|
|
49
|
+
|
|
50
|
+
/** What every look shares: how a type is colored, how a stage and a wire are
|
|
51
|
+
* styled, and the lookups a look does over a pipeline. */
|
|
52
|
+
|
|
53
|
+
/** The color of a value type, for a port or a wire. Answers `undefined`, a
|
|
54
|
+
* port with no type, with a neutral color. */
|
|
55
|
+
type TypeColor = (type: string | undefined) => string;
|
|
56
|
+
/** What a look hands back: `diagramScene`'s two arguments, and its colors. */
|
|
57
|
+
interface EffectLookResult {
|
|
58
|
+
data: DiagramData;
|
|
59
|
+
scene: DiagramSceneOptions;
|
|
60
|
+
color: TypeColor;
|
|
61
|
+
/** Edges standing in for a decision's exits where the look draws no
|
|
62
|
+
* decision, keyed by edge id: which stage chose, and by which output. A
|
|
63
|
+
* run reads that stage's `taken` for them. */
|
|
64
|
+
exits?: ReadonlyMap<string, {
|
|
65
|
+
stage: string;
|
|
66
|
+
port: string;
|
|
67
|
+
}>;
|
|
68
|
+
/** The stages on the main line, in the order the look draws them, for a
|
|
69
|
+
* reorder to drag along. Looks that place stages freely leave it out. */
|
|
70
|
+
order?: LookOrder;
|
|
71
|
+
/** The lanes, top down, where the look draws lanes. */
|
|
72
|
+
laneOrder?: LookOrder;
|
|
73
|
+
}
|
|
74
|
+
/** A sequence a look draws: the scene node ids of its items in order along
|
|
75
|
+
* `axis`. `reorder`'s `sequenceSlots` turns it into slots once the items
|
|
76
|
+
* have drawn boxes. */
|
|
77
|
+
interface LookOrder {
|
|
78
|
+
axis: 'x' | 'y';
|
|
79
|
+
/** `grip` is where a press picks the item up, in world units; default its drawn box. */
|
|
80
|
+
items: readonly {
|
|
81
|
+
id: string;
|
|
82
|
+
grip?: {
|
|
83
|
+
x: number;
|
|
84
|
+
y: number;
|
|
85
|
+
width: number;
|
|
86
|
+
height: number;
|
|
87
|
+
};
|
|
88
|
+
}[];
|
|
89
|
+
}
|
|
90
|
+
/** One way of drawing a pipeline. Unparameterized, a look whose options are
|
|
91
|
+
* not known: any look fits it, and it is called with none. */
|
|
92
|
+
type EffectLook<TOptions = never> = (pipeline: EffectPipeline, options?: TOptions) => EffectLookResult;
|
|
93
|
+
/** The theme the shipped looks draw in when their options name none. */
|
|
94
|
+
declare const LOOK_THEME: DiagramTheme;
|
|
95
|
+
/** The option every shipped look takes for its colors. */
|
|
96
|
+
interface LookThemeOptions {
|
|
97
|
+
/** Stages take its default role, bypassed ones its muted role; value types its `series` in
|
|
98
|
+
* turn; groups its container; lanes its lane bodies. Default `night`. */
|
|
99
|
+
theme?: DiagramTheme;
|
|
100
|
+
}
|
|
101
|
+
/** The color `wireStyle` draws a wire in when `checkPipeline` reported it. */
|
|
102
|
+
declare const PROBLEM_COLOR = "#ff5d5d";
|
|
103
|
+
/** A color per type: the one given, or the next in `series` in the order
|
|
104
|
+
* types first appear on the pipeline's ports. */
|
|
105
|
+
declare function typeColors(pipeline: EffectPipeline, given?: Readonly<Record<string, string>>, series?: readonly string[]): TypeColor;
|
|
106
|
+
/** Whether `type` is one the pipeline's `types` mark as `control`. */
|
|
107
|
+
declare function isControl(pipeline: EffectPipeline, type: string | undefined): boolean;
|
|
108
|
+
/** The node style the shipped looks give a stage: the theme's default role, or dashed in its
|
|
109
|
+
* muted role when the stage is bypassed. */
|
|
110
|
+
declare function stageStyle(stage: EffectStage, theme?: DiagramTheme): NodeStyle;
|
|
111
|
+
/** The edge style the shipped looks give a wire: `color`, dashed for a
|
|
112
|
+
* control wire, and `PROBLEM_COLOR` in place of `color` for a flagged one. */
|
|
113
|
+
declare function wireStyle(color: string, control: boolean, problem: boolean): EdgeStyle;
|
|
114
|
+
/** Stages with the repeats dropped, first one kept. `diagramScene` throws on
|
|
115
|
+
* a repeated id, so a look builds its nodes from these. */
|
|
116
|
+
declare function uniqueStages(pipeline: EffectPipeline): EffectStage[];
|
|
117
|
+
/** Groups with the repeats dropped, first one kept, and none that has the id
|
|
118
|
+
* of a stage: `diagramScene` throws on an id that names two things. */
|
|
119
|
+
declare function uniqueGroups(pipeline: EffectPipeline): EffectGroup[];
|
|
120
|
+
/** The port called `id` among a stage's inputs and outputs, inputs first. */
|
|
121
|
+
declare function portOn(stage: EffectStage | undefined, id: string): EffectPort | undefined;
|
|
122
|
+
/** A stage's `kind` as the shipped looks read it: any value they do not know is `'stage'`. */
|
|
123
|
+
declare function kindOf(stage: EffectStage): 'stage' | 'decision' | 'source' | 'sink';
|
|
124
|
+
/** A wire with both ends present, and what a look needs to draw it. */
|
|
125
|
+
interface DrawableWire {
|
|
126
|
+
wire: EffectWire;
|
|
127
|
+
/** Index into `pipeline.wires`. */
|
|
128
|
+
index: number;
|
|
129
|
+
/** The value type of the port the wire leaves. */
|
|
130
|
+
type: string | undefined;
|
|
131
|
+
/** `checkPipeline` reported it. */
|
|
132
|
+
problem: boolean;
|
|
133
|
+
fromStage: EffectStage;
|
|
134
|
+
toStage: EffectStage;
|
|
135
|
+
}
|
|
136
|
+
/** The wires a look can draw: each one whose two stages and two ports exist,
|
|
137
|
+
* in the pipeline's order. A wire `checkPipeline` reported and that still has
|
|
138
|
+
* both ends is kept, with `problem` set. */
|
|
139
|
+
declare function drawableWires(pipeline: EffectPipeline): DrawableWire[];
|
|
140
|
+
/** What a value row shows before a run fills it in. */
|
|
141
|
+
declare const NO_VALUE = "\u2013";
|
|
142
|
+
/** The ports a run shows values and previews on: a stage's outputs, or for a
|
|
143
|
+
* stage with none, such as a sink, its inputs, so the end of a pipeline
|
|
144
|
+
* shows what reached it. */
|
|
145
|
+
declare function shownPorts(stage: EffectStage): readonly EffectPort[];
|
|
146
|
+
/** The row id of the value row for an output, under its stage's body. */
|
|
147
|
+
declare const valueRowId: (port: string) => string;
|
|
148
|
+
/** The row id of the preview slot for an output, under its stage's body. */
|
|
149
|
+
declare const previewRowId: (port: string) => string;
|
|
150
|
+
/** `RunRowOptions.previewSize`'s default: a 48-unit square. */
|
|
151
|
+
declare const PREVIEW_SIZE = 48;
|
|
152
|
+
/** The rows a look keeps on each stage for what an `EffectRun` shows there.
|
|
153
|
+
* Kept from the start, so a run fills them in without the chart laying out
|
|
154
|
+
* again. A decision's symbol keeps neither. */
|
|
155
|
+
interface RunRowOptions {
|
|
156
|
+
/** A row per output for its value. Default false. */
|
|
157
|
+
showValues?: boolean;
|
|
158
|
+
/** A slot per output for its preview, after its value row. Default false. */
|
|
159
|
+
showPreviews?: boolean;
|
|
160
|
+
/** The preview slot's size: a square's side, or a width and height. A
|
|
161
|
+
* preview is stretched to fill it. Default `PREVIEW_SIZE`. */
|
|
162
|
+
previewSize?: number | {
|
|
163
|
+
width: number;
|
|
164
|
+
height: number;
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
/** The body rows of an ordinary stage: its title, a row of its ports when
|
|
168
|
+
* `withPorts` (inputs left, outputs right), then for each of its
|
|
169
|
+
* `shownPorts` its value row when `showValues` and its preview slot when
|
|
170
|
+
* `showPreviews`, then its
|
|
171
|
+
* params when `showParams`. */
|
|
172
|
+
declare function stageRows(stage: EffectStage, opts: {
|
|
173
|
+
showParams: boolean;
|
|
174
|
+
withPorts: boolean;
|
|
175
|
+
} & RunRowOptions): Row[];
|
|
176
|
+
/** What a wire is called: its own label, or for a wire leaving a decision the
|
|
177
|
+
* exit's label, which defaults to the exit's id. Any other wire has no name. */
|
|
178
|
+
declare function exitLabel(d: DrawableWire): string | undefined;
|
|
179
|
+
/** One edge per drawable wire, from port to port, named by `exitLabel` and
|
|
180
|
+
* styled by `wireStyle` in its type's color. */
|
|
181
|
+
declare function wireEdges(pipeline: EffectPipeline, color: TypeColor): {
|
|
182
|
+
edge: DataEdge;
|
|
183
|
+
style: EdgeStyle;
|
|
184
|
+
}[];
|
|
185
|
+
|
|
186
|
+
/** What every branch symbol is built from: its types, where its ports go, and
|
|
187
|
+
* the diamond each one falls back to. */
|
|
188
|
+
|
|
189
|
+
/** What a branch symbol draws: a data node without its id or style, which the look adds. */
|
|
190
|
+
type BranchNode = Pick<DataNode, 'outline' | 'lines' | 'rows' | 'ports' | 'marks' | 'width' | 'height' | 'padding'>;
|
|
191
|
+
/** How a look wants a branch symbol drawn. */
|
|
192
|
+
interface BranchOptions {
|
|
193
|
+
/** The edge control inputs enter by: the side the stages driving them sit
|
|
194
|
+
* on. Default `'top'`. */
|
|
195
|
+
controlSide?: 'top' | 'bottom';
|
|
196
|
+
/** The style the look draws the stage's node in: lines, dots and ticks
|
|
197
|
+
* take its `text` color. Default `stageStyle(stage)`. */
|
|
198
|
+
style?: NodeStyle;
|
|
199
|
+
/** The colors of a `bar`'s bands and a `crossover`'s curves, lowest
|
|
200
|
+
* first, repeating. Default a palette of four, or for a bypassed stage
|
|
201
|
+
* `style.stroke` for every band. */
|
|
202
|
+
tints?: readonly string[];
|
|
203
|
+
}
|
|
204
|
+
/** Draws one decision stage, with a port for each of its inputs and outputs. */
|
|
205
|
+
type BranchSymbol = (stage: EffectStage, pipeline: EffectPipeline, options?: BranchOptions) => BranchNode;
|
|
206
|
+
|
|
207
|
+
/** Which symbol a decision draws as: one by name, or `'auto'` for a bar when
|
|
208
|
+
* the stage has a sound `split` and a diamond otherwise. */
|
|
209
|
+
type BranchChoice = 'auto' | 'diamond' | 'bar' | 'demux' | 'switch' | 'hexagon' | 'step' | 'comparator' | 'crossover' | 'fork';
|
|
210
|
+
/** Each branch symbol by name. One called on a stage it cannot draw draws
|
|
211
|
+
* the `diamond` instead: a `bar`, `step` or `crossover` with no sound split,
|
|
212
|
+
* or a `switch` or `comparator` without exactly two exits. */
|
|
213
|
+
declare const BRANCH_SYMBOLS: Readonly<Record<Exclude<BranchChoice, 'auto'>, BranchSymbol>>;
|
|
214
|
+
/** The symbol `choice` comes to for `stage`: `'auto'` a bar for a sound
|
|
215
|
+
* split, and any symbol that cannot draw the stage the diamond. */
|
|
216
|
+
declare function symbolNameFor(stage: EffectStage, choice?: BranchChoice): Exclude<BranchChoice, 'auto'>;
|
|
217
|
+
/** The node a decision stage draws as, by the symbol `choice` comes to. */
|
|
218
|
+
declare function branchNode(stage: EffectStage, pipeline: EffectPipeline, choice?: BranchChoice, options?: BranchOptions): BranchNode;
|
|
219
|
+
|
|
220
|
+
/** Options for the `compact` look. */
|
|
221
|
+
interface CompactOptions extends LookThemeOptions {
|
|
222
|
+
/** Default `'bezier'`. */
|
|
223
|
+
router?: DiagramRouter;
|
|
224
|
+
/** Default 16. */
|
|
225
|
+
nodeGap?: number;
|
|
226
|
+
/** Default 48. */
|
|
227
|
+
rankGap?: number;
|
|
228
|
+
/** A color per value type, over the palette's own. */
|
|
229
|
+
colors?: Readonly<Record<string, string>>;
|
|
230
|
+
/** Default `'hexagon'`, the one symbol that keeps a decision one row tall. */
|
|
231
|
+
branch?: BranchChoice;
|
|
232
|
+
}
|
|
233
|
+
/** Between a compact stage's outline and its title. */
|
|
234
|
+
declare const COMPACT_PADDING = 4;
|
|
235
|
+
/** The compact look: each stage one line, its title alone, and no ports
|
|
236
|
+
* drawn; the wires between two stages one line between them. For a
|
|
237
|
+
* pipeline too big to read as a node graph. */
|
|
238
|
+
declare const compact: EffectLook<CompactOptions>;
|
|
239
|
+
|
|
240
|
+
/** Props for `EffectChart`. */
|
|
241
|
+
interface EffectChartProps<TOptions = never> {
|
|
242
|
+
/** Compared by its JSON, so it may be rebuilt on every render: the chart
|
|
243
|
+
* lays out again only when that changes. A value JSON drops or flattens
|
|
244
|
+
* in a stage's `data` (a function, a `Map`) is not seen changing. */
|
|
245
|
+
pipeline: EffectPipeline;
|
|
246
|
+
/** One run of the pipeline, drawn over it: stages it never reached and
|
|
247
|
+
* branches it did not take faded, each stage's cost above its corner, and
|
|
248
|
+
* each output's value and preview in the rows a look keeps for them
|
|
249
|
+
* (`showValues`, `showPreviews`). It may change every frame: the chart
|
|
250
|
+
* neither lays out again nor refits, and repaints only what changed. A
|
|
251
|
+
* preview the next run no longer shows has its texture freed then. */
|
|
252
|
+
run?: EffectRun;
|
|
253
|
+
/** How the pipeline is drawn. Default `nodeGraph`. */
|
|
254
|
+
look?: EffectLook<TOptions>;
|
|
255
|
+
/** The look's options. Keep the object's identity steady between renders,
|
|
256
|
+
* or the chart lays out again on each one. */
|
|
257
|
+
options?: TOptions;
|
|
258
|
+
/** CSS pixels. Omit both to fill the parent, which then needs a size of
|
|
259
|
+
* its own. The chart refits when its size changes, until the user pans or
|
|
260
|
+
* zooms. */
|
|
261
|
+
width?: number;
|
|
262
|
+
height?: number;
|
|
263
|
+
/** The smallest scale the chart opens at. A chart that does not fit whole
|
|
264
|
+
* at it opens at it anyway, anchored at its start, and the rest is a pan
|
|
265
|
+
* away. Default `EFFECT_MIN_SCALE`. */
|
|
266
|
+
minScale?: number;
|
|
267
|
+
/** What the canvas paints behind the chart. Unset, it is transparent; the
|
|
268
|
+
* shipped looks are drawn for a dark ground. */
|
|
269
|
+
background?: Paint;
|
|
270
|
+
/** A stage id, or null for none. */
|
|
271
|
+
selected?: string | null;
|
|
272
|
+
/** Hears each pick: a stage's id, or `null` for anything else. Only a
|
|
273
|
+
* stage can be picked: a click on a group box or a lane lands on the
|
|
274
|
+
* canvas behind it. The canvas keeps its own highlight on the stage picked;
|
|
275
|
+
* only a change to `selected` moves it. */
|
|
276
|
+
onSelect?: (stage: string | null) => void;
|
|
277
|
+
/** What `checkPipeline` found. Called once on mount, and again each time
|
|
278
|
+
* the pipeline's content changes. */
|
|
279
|
+
onProblems?: (problems: readonly EffectProblem[]) => void;
|
|
280
|
+
/** A class for the canvas element. */
|
|
281
|
+
className?: string;
|
|
282
|
+
}
|
|
283
|
+
/** `EffectChart`'s default `minScale`: the shipped looks' 12px titles at 6px, the smallest still legible. */
|
|
284
|
+
declare const EFFECT_MIN_SCALE = 0.5;
|
|
285
|
+
/** A chart of an effects pipeline: pan, zoom, and pick a stage. Text paints
|
|
286
|
+
* only in a registered font family, so call `registerCanvasFont('sans-serif')`
|
|
287
|
+
* once before mounting one. */
|
|
288
|
+
declare function EffectChart<TOptions = never>({ pipeline: given, run, look, options, width, height, minScale, background, selected, onSelect, onProblems, className, }: EffectChartProps<TOptions>): react.JSX.Element;
|
|
289
|
+
|
|
290
|
+
/** Options for the `lanes` look. */
|
|
291
|
+
interface LanesOptions extends RunRowOptions, LookThemeOptions {
|
|
292
|
+
/** The value types whose lanes come first, top down. The rest follow in
|
|
293
|
+
* the order their types first appear on the pipeline's ports. */
|
|
294
|
+
lanes?: readonly string[];
|
|
295
|
+
/** The least height of a lane. A lane grows past it until what stands in
|
|
296
|
+
* it fits. Default 48. */
|
|
297
|
+
laneHeight?: number;
|
|
298
|
+
/** Between one column of stages and the next. Default 40. */
|
|
299
|
+
rankGap?: number;
|
|
300
|
+
/** Default `'bezier'`. */
|
|
301
|
+
router?: DiagramRouter;
|
|
302
|
+
/** A color per value type, over the palette's own. */
|
|
303
|
+
colors?: Readonly<Record<string, string>>;
|
|
304
|
+
/** Whether a stage lists its `params`. Default true. */
|
|
305
|
+
showParams?: boolean;
|
|
306
|
+
/** Default `'auto'`. */
|
|
307
|
+
branch?: BranchChoice;
|
|
308
|
+
/** Measures text, as `diagramScene` takes it, for sizing stages before
|
|
309
|
+
* the lanes are cut to fit them. It is handed on in the look's `scene`. */
|
|
310
|
+
measure?: MeasureRowText;
|
|
311
|
+
}
|
|
312
|
+
/** How far a stage stands inside the first and last lane it touches, at
|
|
313
|
+
* least: more beside a lane edge that wires run along on several tracks. */
|
|
314
|
+
declare const LANE_INSET = 6;
|
|
315
|
+
/** The node id of the lane for a value type. */
|
|
316
|
+
declare const laneId: (type: string) => string;
|
|
317
|
+
/** The value type of the lane `laneId` named, or `undefined` for any other id. */
|
|
318
|
+
declare const laneTypeOf: (id: string) => string | undefined;
|
|
319
|
+
/** The lanes look: a horizontal lane per value type, and each stage standing
|
|
320
|
+
* across the lanes of the types it reads and writes, as tall as they are,
|
|
321
|
+
* its ports in their own lanes. A decision keeps its symbol's size, centered
|
|
322
|
+
* across its lanes. Columns run left to right in the order the signal flows,
|
|
323
|
+
* and a group's members hold columns no other stage stands in. A wire runs around the stages between its ends along the lane edges, each
|
|
324
|
+
* sharing one on a track of its own. */
|
|
325
|
+
declare const lanes: EffectLook<LanesOptions>;
|
|
326
|
+
|
|
327
|
+
/** Options for the `nodeGraph` look. */
|
|
328
|
+
interface NodeGraphOptions extends RunRowOptions, LookThemeOptions {
|
|
329
|
+
/** Default `'bezier'`. */
|
|
330
|
+
router?: DiagramRouter;
|
|
331
|
+
nodeGap?: number;
|
|
332
|
+
rankGap?: number;
|
|
333
|
+
/** A color per value type, over the palette's own. */
|
|
334
|
+
colors?: Readonly<Record<string, string>>;
|
|
335
|
+
/** Whether a stage lists its `params`. Default true. A decision's symbol
|
|
336
|
+
* does not show params either way. */
|
|
337
|
+
showParams?: boolean;
|
|
338
|
+
/** Default `'auto'`. */
|
|
339
|
+
branch?: BranchChoice;
|
|
340
|
+
}
|
|
341
|
+
/** The node-graph look: every port a named row on its stage, a wire from port
|
|
342
|
+
* to port in the color of what it carries, flowing left to right. */
|
|
343
|
+
declare const nodeGraph: EffectLook<NodeGraphOptions>;
|
|
344
|
+
|
|
345
|
+
/** Options for the `rack` look. */
|
|
346
|
+
interface RackOptions extends RunRowOptions, LookThemeOptions {
|
|
347
|
+
/** The stage ids on the line, in order. Default the longest path over data wires. */
|
|
348
|
+
chain?: readonly string[];
|
|
349
|
+
/** Where what feeds the chain from the side sits. Default `'below'`. */
|
|
350
|
+
side?: 'below' | 'above';
|
|
351
|
+
nodeGap?: number;
|
|
352
|
+
rankGap?: number;
|
|
353
|
+
/** A color per value type, over the palette's own. */
|
|
354
|
+
colors?: Readonly<Record<string, string>>;
|
|
355
|
+
/** Whether a stage lists its `params`. Default true. A decision's symbol
|
|
356
|
+
* does not show params either way. */
|
|
357
|
+
showParams?: boolean;
|
|
358
|
+
/** Default `'auto'`. */
|
|
359
|
+
branch?: BranchChoice;
|
|
360
|
+
/** Draw a decision that only skips ahead as an arc over what it skips. Default true. */
|
|
361
|
+
collapseSkips?: boolean;
|
|
362
|
+
}
|
|
363
|
+
/** The rack look: the main signal on one straight line with its stages in
|
|
364
|
+
* order, and whatever feeds a stage from the side hung beside it. */
|
|
365
|
+
declare const rack: EffectLook<RackOptions>;
|
|
366
|
+
|
|
367
|
+
/** The looks an editor draws a doc in. */
|
|
368
|
+
type EditorLook = 'nodeGraph' | 'rack' | 'lanes';
|
|
369
|
+
/** Each editor look's options. Rack's `chain` is left out: a reorder follows
|
|
370
|
+
* the wiring, and a chain given here would draw some other order. */
|
|
371
|
+
interface EditorLookOptions {
|
|
372
|
+
nodeGraph: NodeGraphOptions;
|
|
373
|
+
rack: Omit<RackOptions, 'chain'>;
|
|
374
|
+
lanes: LanesOptions;
|
|
375
|
+
}
|
|
376
|
+
/** A look's drawing of a doc, and the way back from what the drawing reports
|
|
377
|
+
* to the doc. A port id needs no mapping: box stages and decision symbols
|
|
378
|
+
* both give each port its `EffectPort` id. */
|
|
379
|
+
interface EditorScene extends EffectLookResult {
|
|
380
|
+
/** The stage a scene node is, or `undefined` for a group box, a lane, or anything else. */
|
|
381
|
+
stageOf(node: string): string | undefined;
|
|
382
|
+
/** The group a scene node is: a container under `nodeGraph`, a group box under the others. */
|
|
383
|
+
groupOf(node: string): string | undefined;
|
|
384
|
+
/** The wire a data edge id (`edgeIdOf`) draws, by its id in
|
|
385
|
+
* `ensureWireIds(doc)`, so an id-less wire is found by the id it will get.
|
|
386
|
+
* `undefined` for an edge standing in for more than one wire, such as
|
|
387
|
+
* rack's arc over a skip. */
|
|
388
|
+
wireOf(edge: string): string | undefined;
|
|
389
|
+
}
|
|
390
|
+
/** The look's drawing of the doc's pipeline. Under `nodeGraph` every placed
|
|
391
|
+
* stage is pinned at its place, so layered layout places only the stages
|
|
392
|
+
* that have none, and each group is a container, at its `groupBoxes` box or
|
|
393
|
+
* fitting its members; the other looks place every stage themselves and draw
|
|
394
|
+
* groups as boxes around their members. `lanes` takes the doc's `laneOrder`
|
|
395
|
+
* over its options' `lanes`. */
|
|
396
|
+
declare function editorScene<L extends EditorLook = 'nodeGraph'>(doc: EffectDoc, look?: L, options?: EditorLookOptions[L]): EditorScene;
|
|
397
|
+
|
|
398
|
+
/** Which look `EffectEditor` draws in, and that look's options. Keep the
|
|
399
|
+
* options object's identity steady between renders. */
|
|
400
|
+
type EffectEditorLookProps = {
|
|
401
|
+
look?: 'nodeGraph';
|
|
402
|
+
options?: NodeGraphOptions;
|
|
403
|
+
} | {
|
|
404
|
+
look: 'rack';
|
|
405
|
+
options?: EditorLookOptions['rack'];
|
|
406
|
+
} | {
|
|
407
|
+
look: 'lanes';
|
|
408
|
+
options?: LanesOptions;
|
|
409
|
+
};
|
|
410
|
+
/** Props for `EffectEditor`. */
|
|
411
|
+
type EffectEditorProps = EffectEditorBaseProps & EffectEditorLookProps;
|
|
412
|
+
/** `EffectEditor`'s props apart from its look. */
|
|
413
|
+
interface EffectEditorBaseProps {
|
|
414
|
+
/** The pipeline and where its stages sit. The editor keeps none of it:
|
|
415
|
+
* every edit comes back through `onChange` and shows once `doc` follows. */
|
|
416
|
+
doc: EffectDoc;
|
|
417
|
+
/** Hears each edit as the doc it makes, and a name for it fit for an undo
|
|
418
|
+
* entry: 'Move', 'Connect', 'Delete', 'Reconnect', 'Edit route', 'Add stage',
|
|
419
|
+
* 'Reorder', 'Reorder lanes', 'Resize group', 'Group', 'Ungroup' or 'Rename group'. */
|
|
420
|
+
onChange: (next: EffectDoc, label: string) => void;
|
|
421
|
+
/** One run of the pipeline, drawn over it as `EffectChart` draws its
|
|
422
|
+
* `run`, with the stage it is `at` outlined. */
|
|
423
|
+
run?: EffectRun;
|
|
424
|
+
/** A stage id, or null for none. */
|
|
425
|
+
selected?: string | null;
|
|
426
|
+
/** Hears each pick: a stage's id, or `null` for anything else, a wire included. */
|
|
427
|
+
onSelect?: (stage: string | null) => void;
|
|
428
|
+
/** A group id, or null for none: drawn picked while no stage is. */
|
|
429
|
+
selectedGroup?: string | null;
|
|
430
|
+
/** Hears each pick: a group's id, or `null` for anything else. */
|
|
431
|
+
onSelectGroup?: (group: string | null) => void;
|
|
432
|
+
/** CSS pixels. Omit both to fill the parent. */
|
|
433
|
+
width?: number;
|
|
434
|
+
height?: number;
|
|
435
|
+
background?: Paint;
|
|
436
|
+
className?: string;
|
|
437
|
+
}
|
|
438
|
+
/** What a `ref` on `EffectEditor` holds. */
|
|
439
|
+
interface EffectEditorApi {
|
|
440
|
+
/** Adds a stage of type `type`. Under `nodeGraph` its top-left goes at the
|
|
441
|
+
* world point under `client` when given, or in the first free spot in view
|
|
442
|
+
* (`freeSpot`), and like a drag it pins every stage layout placed where it
|
|
443
|
+
* shows, so nothing moves under it; the other looks place it themselves.
|
|
444
|
+
* Returns the new stage's id. */
|
|
445
|
+
addStage(type: EffectStageType, client?: {
|
|
446
|
+
x: number;
|
|
447
|
+
y: number;
|
|
448
|
+
}): string;
|
|
449
|
+
/** Groups stages and groups, as `groupStages` does, and reports it as 'Group'.
|
|
450
|
+
* Under `nodeGraph` it first pins every stage where it shows, as a drag
|
|
451
|
+
* does. Returns the new group's id, or `null` for no ids. */
|
|
452
|
+
group(ids: readonly string[]): string | null;
|
|
453
|
+
/** Dissolves a group, as `ungroup` does, and reports it as 'Ungroup'. */
|
|
454
|
+
ungroup(id: string): void;
|
|
455
|
+
/** Opens the field a group's title is renamed in, over its title, or above
|
|
456
|
+
* its box where it has none; a double-click on the title does
|
|
457
|
+
* the same. Renaming reports 'Rename group'. */
|
|
458
|
+
renameGroup(id: string): void;
|
|
459
|
+
}
|
|
460
|
+
/** The pipeline-mode editor: a look's drawing of an effect pipeline, whose
|
|
461
|
+
* ports wire output to input, and whose wires and stages reconnect and
|
|
462
|
+
* delete. Under `nodeGraph` stages drag freely, and each group is a titled
|
|
463
|
+
* box: drag a stage into or out of it, drag the box to carry what it holds,
|
|
464
|
+
* resize it, or double-click its title to rename it; under `rack` and `lanes` a
|
|
465
|
+
* stage on the main line drags along it to another place, rewiring the
|
|
466
|
+
* pipeline, a group drags along it by its title, and a double-click on that
|
|
467
|
+
* title renames it; under `lanes` a lane drags by its header. A selected
|
|
468
|
+
* wire's route drags under every look: into `routes` under `nodeGraph`, and
|
|
469
|
+
* into `lookRoutes` under the others, where it holds only while the wire's
|
|
470
|
+
* ends stay put. Every edit is a doc handed to `onChange`. Text paints only in a registered font family,
|
|
471
|
+
* as with `EffectChart`. */
|
|
472
|
+
declare const EffectEditor: react.ForwardRefExoticComponent<EffectEditorProps & react.RefAttributes<EffectEditorApi>>;
|
|
473
|
+
|
|
474
|
+
/** The reorders an editor installs under a look that places stages itself:
|
|
475
|
+
* a main-line stage dragged along the line, a lane dragged by its header,
|
|
476
|
+
* and a group dragged along the line by its title. */
|
|
477
|
+
|
|
478
|
+
/** The action that drags a lane to another place among the lanes. */
|
|
479
|
+
declare const REORDER_LANES_ACTION_ID = "diagram.reorderLanes";
|
|
480
|
+
|
|
481
|
+
/** Routes a person drew under `rack` and `lanes`, which place every stage
|
|
482
|
+
* themselves: each holds only while its wire's ends are where they were
|
|
483
|
+
* drawn from. */
|
|
484
|
+
|
|
485
|
+
/** The looks whose routes `lookRoutes` keeps. */
|
|
486
|
+
type RoutedLook = keyof LookRoutes;
|
|
487
|
+
/** Routes wire `wire` through `waypoints` under `look`, for as long as its
|
|
488
|
+
* ends stay at `ends`, its from end first. No waypoints gives the wire back
|
|
489
|
+
* to the look. */
|
|
490
|
+
declare function setLookRoute(doc: EffectDoc, look: RoutedLook, wire: string, waypoints: readonly Vec2[], ends: readonly [Vec2, Vec2]): EffectDoc;
|
|
491
|
+
/** `doc` without the look routes of wires it no longer has, or of the
|
|
492
|
+
* `rewired` ones, whose ends now join other ports. */
|
|
493
|
+
declare function pruneLookRoutes(doc: EffectDoc, rewired?: Iterable<string>): EffectDoc;
|
|
494
|
+
/** The points of the ports edge `edge` joins as `specs` draw it, from end
|
|
495
|
+
* first, or `undefined` when either end names no port. */
|
|
496
|
+
declare function wireEnds(specs: readonly DiagramSpec[], edge: string): [Vec2, Vec2] | undefined;
|
|
497
|
+
/** `specs`, drawn from `built`, with each wire `doc` routed under `look`
|
|
498
|
+
* drawn through its waypoints where its ends are still where they were. An
|
|
499
|
+
* edge's own waypoints win over the route a look worked out (`routed`), as
|
|
500
|
+
* for any `DataEdge`. `specs` itself when no route holds. */
|
|
501
|
+
declare function applyLookRoutes(specs: readonly DiagramSpec[], doc: EffectDoc, look: EditorLook, built: EditorScene): readonly DiagramSpec[];
|
|
502
|
+
|
|
503
|
+
type Ref = {
|
|
504
|
+
stage: string;
|
|
505
|
+
port: string;
|
|
506
|
+
};
|
|
507
|
+
/** `base` if no stage has it, else `base-2`, `base-3`, … */
|
|
508
|
+
declare function nextStageId(p: EffectPipeline, base: string): string;
|
|
509
|
+
/** The first of `w1`, `w2`, … no wire has. */
|
|
510
|
+
declare function nextWireId(p: EffectPipeline): string;
|
|
511
|
+
/** Appends the stage, pinning it at `at` when given. */
|
|
512
|
+
declare function addStage(doc: EffectDoc, stage: EffectStage, at?: Vec2): EffectDoc;
|
|
513
|
+
/** Drops the stages with their wires, places, routes and group memberships,
|
|
514
|
+
* and any group that leaves empty, with its box. */
|
|
515
|
+
declare function removeStages(doc: EffectDoc, ids: readonly string[]): EffectDoc;
|
|
516
|
+
/** Routes wire `wire` through `points`; none clears its route. */
|
|
517
|
+
declare function setWireRoute(doc: EffectDoc, wire: string, points: readonly Vec2[]): EffectDoc;
|
|
518
|
+
/** Mints an id when the wire has none. */
|
|
519
|
+
declare function addWire(doc: EffectDoc, wire: EffectWire): EffectDoc;
|
|
520
|
+
/** An id-less wire is never matched: run `ensureWireIds` first. */
|
|
521
|
+
declare function removeWires(doc: EffectDoc, ids: readonly string[]): EffectDoc;
|
|
522
|
+
/** An id-less wire is never matched: run `ensureWireIds` first. */
|
|
523
|
+
declare function reconnectWire(doc: EffectDoc, id: string, end: 'from' | 'to', to: Ref): EffectDoc;
|
|
524
|
+
/** Replaces a param's control and re-formats its display value. */
|
|
525
|
+
declare function setParam(doc: EffectDoc, stage: string, param: string, control: EffectParamControl): EffectDoc;
|
|
526
|
+
/** Pins each stage at its new position. */
|
|
527
|
+
declare function moveStages(doc: EffectDoc, moves: readonly {
|
|
528
|
+
id: string;
|
|
529
|
+
x: number;
|
|
530
|
+
y: number;
|
|
531
|
+
}[]): EffectDoc;
|
|
532
|
+
/** Sets the value types whose lanes `lanes` draws first, top down. */
|
|
533
|
+
declare function setLaneOrder(doc: EffectDoc, order: readonly string[]): EffectDoc;
|
|
534
|
+
/** Mints ids for id-less wires; returns `doc` itself when none lacks one. */
|
|
535
|
+
declare function ensureWireIds(doc: EffectDoc): EffectDoc;
|
|
536
|
+
/** An output into an input of the same type, both existing, on different stages. */
|
|
537
|
+
declare function canWire(p: EffectPipeline, from: Ref, to: Ref): boolean;
|
|
538
|
+
|
|
539
|
+
/** Edits to a pipeline's groups: what each holds, its label, and its box under `nodeGraph`. */
|
|
540
|
+
|
|
541
|
+
/** `group` if no stage or group has it, else `group-2`, `group-3`, … */
|
|
542
|
+
declare function nextGroupId(p: EffectPipeline): string;
|
|
543
|
+
/**
|
|
544
|
+
* Groups `ids`, stages or groups, in a new group whose id is
|
|
545
|
+
* {@link nextGroupId}'s. It nests inside the group all of them share, where
|
|
546
|
+
* the first of them was; otherwise it goes at the top level, taking them out
|
|
547
|
+
* of the groups they were in.
|
|
548
|
+
*/
|
|
549
|
+
declare function groupStages(doc: EffectDoc, ids: readonly string[], label?: string): EffectDoc;
|
|
550
|
+
/** Dissolves group `id`: its members go to its parent group, in its place, or to the top level. */
|
|
551
|
+
declare function ungroup(doc: EffectDoc, id: string): EffectDoc;
|
|
552
|
+
/** Sets group `id`'s label; an empty one removes it. */
|
|
553
|
+
declare function renameGroup(doc: EffectDoc, id: string, label: string): EffectDoc;
|
|
554
|
+
/**
|
|
555
|
+
* Moves `ids`, stages or groups, into group `group`, or to the top level for
|
|
556
|
+
* `null`, out of the groups they were in. A group left empty goes too unless
|
|
557
|
+
* it has a box. `doc` itself when `group` is unknown or inside one of `ids`.
|
|
558
|
+
*/
|
|
559
|
+
declare function moveToGroup(doc: EffectDoc, ids: readonly string[], group: string | null): EffectDoc;
|
|
560
|
+
/** Sets group `id`'s box under `nodeGraph`; `null` has it fit its members again. */
|
|
561
|
+
declare function setGroupBox(doc: EffectDoc, id: string, box: EffectBox | null): EffectDoc;
|
|
562
|
+
/** Group `id` and every stage and group inside it. */
|
|
563
|
+
declare function groupContents(doc: EffectDoc, id: string): {
|
|
564
|
+
stages: Set<string>;
|
|
565
|
+
groups: Set<string>;
|
|
566
|
+
};
|
|
567
|
+
/**
|
|
568
|
+
* Moves group `id` by `offset`: the places of the stages inside it, its box
|
|
569
|
+
* and the boxes inside it, and the routes of wires with both ends inside it.
|
|
570
|
+
* A stage with no place stays where layout puts it.
|
|
571
|
+
*/
|
|
572
|
+
declare function moveGroup(doc: EffectDoc, id: string, offset: Vec2): EffectDoc;
|
|
573
|
+
|
|
574
|
+
/** What an evaluator is handed for one stage of one run. */
|
|
575
|
+
interface EffectEvalContext {
|
|
576
|
+
stage: EffectStage;
|
|
577
|
+
/** The value on each input a wire feeds, by port id. An input no reached
|
|
578
|
+
* wire feeds is absent. */
|
|
579
|
+
inputs: Readonly<Record<string, unknown>>;
|
|
580
|
+
/** Each param's control value (its display string when it has no
|
|
581
|
+
* control), by param id, or by label for a param without one. */
|
|
582
|
+
params: Readonly<Record<string, unknown>>;
|
|
583
|
+
/** The values the run was handed (`RunPipelineOptions.sources`), for a
|
|
584
|
+
* source stage to read. */
|
|
585
|
+
sources: Readonly<Record<string, unknown>>;
|
|
586
|
+
/** Seconds of play time. */
|
|
587
|
+
time: number;
|
|
588
|
+
/** Aborted when the run is abandoned. */
|
|
589
|
+
signal: AbortSignal;
|
|
590
|
+
}
|
|
591
|
+
/** What one stage produced: a value per output it fed, by port id, and for a
|
|
592
|
+
* decision the output it chose. An output left out feeds nothing. */
|
|
593
|
+
interface EffectEvalResult {
|
|
594
|
+
outputs: Readonly<Record<string, unknown>>;
|
|
595
|
+
taken?: string;
|
|
596
|
+
}
|
|
597
|
+
/** Evaluates one stage. Throw to fail it: the run records the message as the
|
|
598
|
+
* stage's `error` and leaves what it feeds unreached. */
|
|
599
|
+
type EffectEvaluator = (ctx: EffectEvalContext) => EffectEvalResult | Promise<EffectEvalResult>;
|
|
600
|
+
/** Evaluators by stage `type`. */
|
|
601
|
+
type EffectEvaluators = Readonly<Record<string, EffectEvaluator>>;
|
|
602
|
+
/** How a run shows, previews, and lets go of the values of one value type. */
|
|
603
|
+
interface EffectValueKind {
|
|
604
|
+
/** The value as text for a value row. Default `String(value)` for a
|
|
605
|
+
* number, string, or boolean, and nothing for anything else. */
|
|
606
|
+
show?(value: unknown): string;
|
|
607
|
+
/** The value as a picture of `size`, for a preview slot. */
|
|
608
|
+
preview?(value: unknown, size: {
|
|
609
|
+
width: number;
|
|
610
|
+
height: number;
|
|
611
|
+
}): ImageBitmap | Promise<ImageBitmap> | undefined;
|
|
612
|
+
/** Frees what the value holds, once nothing reads it again. */
|
|
613
|
+
dispose?(value: unknown): void;
|
|
614
|
+
}
|
|
615
|
+
/** Value kinds by value type. */
|
|
616
|
+
type EffectValueKinds = Readonly<Record<string, EffectValueKind>>;
|
|
617
|
+
|
|
618
|
+
/** Evaluators for `IMAGE_STAGE_TYPES`, drawing on `OffscreenCanvas` 2D. An
|
|
619
|
+
* image or mask is an `ImageBitmap`; a source puts out `sources.image`. */
|
|
620
|
+
declare const imageEvaluators: EffectEvaluators;
|
|
621
|
+
|
|
622
|
+
/** Stage types over images, each with an evaluator in `imageEvaluators`.
|
|
623
|
+
* Ports carry `image`, `number`, or `mask`, and a wire joins only like to
|
|
624
|
+
* like. Mark `number` as control in a pipeline's `types`. */
|
|
625
|
+
declare const IMAGE_STAGE_TYPES: readonly EffectStageType[];
|
|
626
|
+
|
|
627
|
+
/** A test card of `size` (a square's side, or a width and height): color bars
|
|
628
|
+
* over a gray ramp, with a white ring in the middle, so every stage has edges,
|
|
629
|
+
* hues, and levels to work on. */
|
|
630
|
+
declare function testCard(size: number | {
|
|
631
|
+
width: number;
|
|
632
|
+
height: number;
|
|
633
|
+
}): ImageBitmap;
|
|
634
|
+
|
|
635
|
+
/** Value kinds for `IMAGE_STAGE_TYPES`: an image or mask shows as its size and
|
|
636
|
+
* previews as a copy scaled to the slot; a number shows to three places. */
|
|
637
|
+
declare const imageValueKinds: EffectValueKinds;
|
|
638
|
+
|
|
639
|
+
/** The looks that ship, by name. */
|
|
640
|
+
declare const EFFECT_LOOKS: Readonly<{
|
|
641
|
+
nodeGraph: EffectLook<NodeGraphOptions>;
|
|
642
|
+
rack: EffectLook<RackOptions>;
|
|
643
|
+
lanes: EffectLook<LanesOptions>;
|
|
644
|
+
compact: EffectLook<CompactOptions>;
|
|
645
|
+
}>;
|
|
646
|
+
|
|
647
|
+
/** Which stages a pipeline's main signal runs through, and which decisions on
|
|
648
|
+
* that run only choose between going on and skipping ahead. */
|
|
649
|
+
|
|
650
|
+
/** Stage ids of the longest path over data wires, sources first. */
|
|
651
|
+
declare function mainChain(pipeline: EffectPipeline): string[];
|
|
652
|
+
|
|
653
|
+
/** The outline of the stage a run taken a step at a time is `at`. */
|
|
654
|
+
declare const AT_COLOR = "#ffc94d";
|
|
655
|
+
/**
|
|
656
|
+
* `specs` as `run` leaves them: a stage the run never reached faded, with its
|
|
657
|
+
* wires; a decision's wires to the outputs it did not take faded; each value
|
|
658
|
+
* row a look kept filled in; a `switch` thrown to the output its decision
|
|
659
|
+
* took; each stage's cost, or its error in `PROBLEM_COLOR`, written above
|
|
660
|
+
* its corner; and the stage the run is `at` outlined in `AT_COLOR`.
|
|
661
|
+
* No run, no change.
|
|
662
|
+
*/
|
|
663
|
+
declare function paintRun(pipeline: EffectPipeline, specs: readonly DiagramSpec[], run: EffectRun | undefined, exits?: EffectLookResult['exits']): DiagramSpec[];
|
|
664
|
+
/** A cost in milliseconds, to three figures. */
|
|
665
|
+
declare function costText(ms: number): string;
|
|
666
|
+
|
|
667
|
+
/** The order a run evaluates stages in, and the stages it never can. */
|
|
668
|
+
interface RunOrder {
|
|
669
|
+
/** Every stage outside a cycle, each after every stage that feeds it. */
|
|
670
|
+
order: string[];
|
|
671
|
+
/** The stages on a cycle of wires, in stage order. */
|
|
672
|
+
cyclic: string[];
|
|
673
|
+
}
|
|
674
|
+
/** The stages topologically over data and control wires alike, stable by
|
|
675
|
+
* stage order: of the stages ready to go, the earliest goes first. A stage on
|
|
676
|
+
* a cycle is left out, and so are its wires. */
|
|
677
|
+
declare function runOrder(pipeline: EffectPipeline): RunOrder;
|
|
678
|
+
|
|
679
|
+
/** Options for `runPipeline` and `createEffectRunner`. */
|
|
680
|
+
interface RunPipelineOptions {
|
|
681
|
+
/** By stage `type`. A stage whose type has none fails. */
|
|
682
|
+
evaluators: EffectEvaluators;
|
|
683
|
+
/** By value type. A value whose type has none shows as text when it is a
|
|
684
|
+
* number, string, or boolean, and has no preview. */
|
|
685
|
+
kinds?: EffectValueKinds;
|
|
686
|
+
/** Handed to every evaluator, for source stages. The run never disposes them. */
|
|
687
|
+
sources?: Readonly<Record<string, unknown>>;
|
|
688
|
+
/** Seconds of play time. Default 0. */
|
|
689
|
+
time?: number;
|
|
690
|
+
signal?: AbortSignal;
|
|
691
|
+
/** Make a preview of each output whose kind can. Default true. */
|
|
692
|
+
previews?: boolean;
|
|
693
|
+
/** The size previews are made at: `RunRowOptions.previewSize`. Default `PREVIEW_SIZE`. */
|
|
694
|
+
previewSize?: number | {
|
|
695
|
+
width: number;
|
|
696
|
+
height: number;
|
|
697
|
+
};
|
|
698
|
+
}
|
|
699
|
+
/** A run taken a stage at a time. */
|
|
700
|
+
interface EffectPass {
|
|
701
|
+
/** Evaluates the next stage the run reaches, passing over those it does
|
|
702
|
+
* not, and returns its id; `undefined` once none is left. */
|
|
703
|
+
step(): Promise<string | undefined>;
|
|
704
|
+
/** The run so far: a new object after each step. */
|
|
705
|
+
readonly run: EffectRun;
|
|
706
|
+
/** Disposes every value the pass made. Its previews are the caller's. */
|
|
707
|
+
dispose(): void;
|
|
708
|
+
}
|
|
709
|
+
/** A pass over `pipeline` that has evaluated nothing yet. */
|
|
710
|
+
declare function createPass(pipeline: EffectPipeline, opts: RunPipelineOptions): EffectPass;
|
|
711
|
+
|
|
712
|
+
/**
|
|
713
|
+
* One whole run of `pipeline`, stage by stage in `runOrder`. A stage with
|
|
714
|
+
* inputs none of which a value reaches is skipped; a bypassed stage passes its
|
|
715
|
+
* first input of each output's type through; a throwing evaluator sets the
|
|
716
|
+
* stage's `error` and leaves what it feeds unreached; stages on a cycle never
|
|
717
|
+
* run. Every value the run made is disposed before it resolves; the previews
|
|
718
|
+
* in the run are the caller's to close. Rejects once `signal` aborts.
|
|
719
|
+
*/
|
|
720
|
+
declare function runPipeline(pipeline: EffectPipeline, opts: RunPipelineOptions): Promise<EffectRun>;
|
|
721
|
+
|
|
722
|
+
/** What `createEffectRunner` is made with. */
|
|
723
|
+
interface EffectRunnerOptions extends Omit<RunPipelineOptions, 'time' | 'signal'> {
|
|
724
|
+
pipeline: EffectPipeline;
|
|
725
|
+
}
|
|
726
|
+
/** What a runner shows now. A new object whenever any of it changes. */
|
|
727
|
+
interface EffectRunnerState {
|
|
728
|
+
/** The run to draw: the last whole run, or the step run so far. */
|
|
729
|
+
run: EffectRun | undefined;
|
|
730
|
+
playing: boolean;
|
|
731
|
+
/** Seconds of play time. */
|
|
732
|
+
time: number;
|
|
733
|
+
}
|
|
734
|
+
/** Runs one pipeline over and over: whole, a stage at a time, or every frame
|
|
735
|
+
* while playing. It owns the values its runs make and the previews in them. */
|
|
736
|
+
interface EffectRunner {
|
|
737
|
+
readonly state: EffectRunnerState;
|
|
738
|
+
/** One whole run at the current play time. */
|
|
739
|
+
run(): Promise<void>;
|
|
740
|
+
/** Evaluates the next stage the run reaches and makes it the run's `at`;
|
|
741
|
+
* after the last stage, starts over. */
|
|
742
|
+
step(): Promise<void>;
|
|
743
|
+
play(): void;
|
|
744
|
+
pause(): void;
|
|
745
|
+
/** Pauses, drops the run, and sets the clock back to zero. */
|
|
746
|
+
reset(): void;
|
|
747
|
+
/** Moves the play clock on by `seconds` while playing, and starts a run
|
|
748
|
+
* unless one is still going. A frame source calls it once a frame. */
|
|
749
|
+
advance(seconds: number): void;
|
|
750
|
+
/** The next run, step, or played frame follows `pipeline`. A step run under
|
|
751
|
+
* way starts over. */
|
|
752
|
+
setPipeline(pipeline: EffectPipeline): void;
|
|
753
|
+
setSources(sources: Readonly<Record<string, unknown>>): void;
|
|
754
|
+
setOptions(opts: Partial<Omit<EffectRunnerOptions, 'pipeline' | 'sources'>>): void;
|
|
755
|
+
/** Says `run` is on screen: every preview of an older run that `run` does
|
|
756
|
+
* not show is closed. */
|
|
757
|
+
drawn(run: EffectRun | undefined): void;
|
|
758
|
+
subscribe(listener: () => void): () => void;
|
|
759
|
+
/** Resets and closes every preview it still holds. The runner stays usable. */
|
|
760
|
+
dispose(): void;
|
|
761
|
+
}
|
|
762
|
+
/** A runner over `opts.pipeline`, with nothing run yet. */
|
|
763
|
+
declare function createEffectRunner(opts: EffectRunnerOptions): EffectRunner;
|
|
764
|
+
|
|
765
|
+
/** Options for `useEffectRunner`: the runner's, which it follows as they
|
|
766
|
+
* change, and how its play loop is gated and clocked. */
|
|
767
|
+
interface UseEffectRunnerOptions extends EffectRunnerOptions, Pick<VisibleRafOptions, 'target' | 'requestFrame' | 'cancelFrame'> {
|
|
768
|
+
}
|
|
769
|
+
/** What `useEffectRunner` returns: the runner's state, and the runner to drive. */
|
|
770
|
+
interface EffectRunnerHandle extends EffectRunnerState {
|
|
771
|
+
runner: EffectRunner;
|
|
772
|
+
}
|
|
773
|
+
/**
|
|
774
|
+
* A runner for the life of the component. While it plays, every visible frame
|
|
775
|
+
* advances its clock by the time since the last and starts a run once the last
|
|
776
|
+
* has finished; time spent hidden does not count. Each run it hands back is
|
|
777
|
+
* taken as drawn after the render that shows it, so the previews of the runs
|
|
778
|
+
* before it are closed then.
|
|
779
|
+
*/
|
|
780
|
+
declare function useEffectRunner(opts: UseEffectRunnerOptions): EffectRunnerHandle;
|
|
781
|
+
|
|
782
|
+
export { AT_COLOR, BRANCH_SYMBOLS, type BranchChoice, type BranchNode, type BranchOptions, type BranchSymbol, COMPACT_PADDING, type ChainLinks, type CompactOptions, type DrawableWire, EFFECT_LOOKS, EFFECT_MIN_SCALE, type EditorLook, type EditorLookOptions, type EditorScene, EffectBox, EffectChart, type EffectChartProps, EffectDoc, EffectEditor, type EffectEditorApi, type EffectEditorBaseProps, type EffectEditorLookProps, type EffectEditorProps, type EffectEvalContext, type EffectEvalResult, type EffectEvaluator, type EffectEvaluators, EffectGroup, type EffectLook, type EffectLookResult, EffectParamControl, type EffectPass, EffectPipeline, EffectPort, type EffectProblem, EffectRun, type EffectRunner, type EffectRunnerHandle, type EffectRunnerOptions, type EffectRunnerState, EffectStage, EffectStageType, type EffectValueKind, type EffectValueKinds, EffectWire, IMAGE_STAGE_TYPES, LANE_INSET, LOOK_THEME, type LanesOptions, type LookOrder, LookRoutes, type LookThemeOptions, NO_VALUE, type NodeGraphOptions, PREVIEW_SIZE, PROBLEM_COLOR, REORDER_LANES_ACTION_ID, type RackOptions, type RoutedLook, type RunOrder, type RunPipelineOptions, type RunRowOptions, type TypeColor, type UseEffectRunnerOptions, addStage, addWire, applyLookRoutes, branchNode, canMoveInChain, canWire, chainLinks, checkPipeline, compact, costText, createEffectRunner, createPass, drawableWires, editorScene, ensureWireIds, exitLabel, groupContents, groupStages, imageEvaluators, imageValueKinds, isControl, kindOf, laneId, laneTypeOf, lanes, mainChain, moveGroup, moveInChain, moveStages, moveToGroup, nextGroupId, nextStageId, nextWireId, nodeGraph, paintRun, portOn, previewRowId, pruneLookRoutes, rack, reconnectWire, removeStages, removeWires, renameGroup, runOrder, runPipeline, setGroupBox, setLaneOrder, setLookRoute, setParam, setWireRoute, shownPorts, stageRows, stageStyle, symbolNameFor, testCard, typeColors, ungroup, uniqueGroups, uniqueStages, useEffectRunner, valueRowId, wireEdges, wireEnds, wireStyle };
|