@weasel-js/diagram 1.11.0 → 1.12.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.
Files changed (37) hide show
  1. package/README.md +696 -4
  2. package/dist/chunk-2SYY4W3B.js +2055 -0
  3. package/dist/chunk-2SYY4W3B.js.map +1 -0
  4. package/dist/chunk-5GIP2LA6.js +312 -0
  5. package/dist/chunk-5GIP2LA6.js.map +1 -0
  6. package/dist/chunk-DYDX6EJC.js +3653 -0
  7. package/dist/chunk-DYDX6EJC.js.map +1 -0
  8. package/dist/chunk-GA4BX7SH.js +1431 -0
  9. package/dist/chunk-GA4BX7SH.js.map +1 -0
  10. package/dist/{chunk-NUMMW5BI.js → chunk-R2XB6D32.js} +416 -36
  11. package/dist/chunk-R2XB6D32.js.map +1 -0
  12. package/dist/chunk-WDIE35AK.js +3 -0
  13. package/dist/chunk-WDIE35AK.js.map +1 -0
  14. package/dist/{fromData-GKqRgPFs.d.ts → dataTypes-DHdkzCL8.d.ts} +238 -59
  15. package/dist/effect-audio.d.ts +139 -0
  16. package/dist/effect-audio.js +533 -0
  17. package/dist/effect-audio.js.map +1 -0
  18. package/dist/effect.d.ts +486 -121
  19. package/dist/effect.js +1632 -347
  20. package/dist/effect.js.map +1 -1
  21. package/dist/icons.table.d.ts +6 -0
  22. package/dist/icons.table.js +32 -0
  23. package/dist/icons.table.js.map +1 -0
  24. package/dist/icons.table.json +24 -0
  25. package/dist/index.d.ts +2159 -92
  26. package/dist/index.js +1056 -2
  27. package/dist/index.js.map +1 -1
  28. package/dist/layout.d.ts +3 -3
  29. package/dist/layout.entry-B-jJMc50.d.ts +617 -0
  30. package/dist/layout.js +3 -1
  31. package/dist/stageTypes-DvnR8cKQ.d.ts +189 -0
  32. package/dist/{body-2lC7IiIA.d.ts → types-M_ccNAlk.d.ts} +221 -182
  33. package/package.json +28 -7
  34. package/dist/chunk-C4NAI6NV.js +0 -2041
  35. package/dist/chunk-C4NAI6NV.js.map +0 -1
  36. package/dist/chunk-NUMMW5BI.js.map +0 -1
  37. package/dist/layout.entry-BoWFcR4G.d.ts +0 -285
@@ -0,0 +1,189 @@
1
+ import { Page } from '@weasel-js/core';
2
+ import { Vec2 } from '@weasel-js/core/math';
3
+
4
+ /** An effects pipeline as plain data. It says what is wired to what and
5
+ * nothing about how any of it is drawn. */
6
+ interface EffectPipeline {
7
+ stages: readonly EffectStage[];
8
+ wires: readonly EffectWire[];
9
+ groups?: readonly EffectGroup[];
10
+ /** What the value types mean. A type no entry names is plain data. */
11
+ types?: Readonly<Record<string, EffectType>>;
12
+ }
13
+ /** One step of a pipeline: what it reads and writes, and what its box shows. */
14
+ interface EffectStage {
15
+ id: string;
16
+ title: string;
17
+ /** What sort of stage this is, for a look to read. The shipped looks know
18
+ * 'stage' (default), 'decision', 'source' and 'sink', and draw any other
19
+ * value as 'stage'. */
20
+ kind?: string;
21
+ /** Which palette entry or template made this stage. A tag for an editor to
22
+ * read: no shipped look draws differently for it. */
23
+ type?: string;
24
+ inputs?: readonly EffectPort[];
25
+ outputs?: readonly EffectPort[];
26
+ /** Settings worth showing, in order. */
27
+ params?: readonly EffectParam[];
28
+ /** For a decision that splits on a number: the input it compares, and the
29
+ * cut points in ascending order. N cuts need N + 1 outputs, the lowest
30
+ * band first. */
31
+ split?: {
32
+ input: string;
33
+ at: readonly number[];
34
+ };
35
+ /** The stage is in the pipeline and switched off. */
36
+ bypassed?: boolean;
37
+ /** Anything else a look wants. No shipped look reads it. */
38
+ data?: Readonly<Record<string, unknown>>;
39
+ }
40
+ /** One input or output of a stage, carrying a value of one type. */
41
+ interface EffectPort {
42
+ /** Unique among the stage's inputs and outputs together. */
43
+ id: string;
44
+ /** Default the id. */
45
+ label?: string;
46
+ type: string;
47
+ }
48
+ /** A connection from one stage's output to another stage's input. */
49
+ interface EffectWire {
50
+ /** Carried to the drawn edge's `DataEdge.id`, so the wire can be found again. */
51
+ id?: string;
52
+ from: {
53
+ stage: string;
54
+ port: string;
55
+ };
56
+ to: {
57
+ stage: string;
58
+ port: string;
59
+ };
60
+ /** Drawn on the wire. */
61
+ label?: string;
62
+ }
63
+ /** A box drawn around some stages, and around other groups. */
64
+ interface EffectGroup {
65
+ id: string;
66
+ label?: string;
67
+ /** Stage ids and group ids. */
68
+ members: readonly string[];
69
+ }
70
+ /** One run of a pipeline: what happened, beside the pipeline rather than in
71
+ * it, so it can change every frame while the pipeline and its layout stay
72
+ * put. A stage the run has no entry for is one it never reached. */
73
+ interface EffectRun {
74
+ stages: Readonly<Record<string, EffectStageRun>>;
75
+ /** The stage a run taken a step at a time is on, drawn outlined. */
76
+ at?: string;
77
+ }
78
+ /** What one stage did in a run. */
79
+ interface EffectStageRun {
80
+ /** How long it took, in milliseconds. */
81
+ cost?: number;
82
+ /** For a decision: the output it chose. */
83
+ taken?: string;
84
+ /** What each output carried, by port id, as text to show; for a stage with
85
+ * no outputs, what reached each input. */
86
+ values?: Readonly<Record<string, string>>;
87
+ /** What each port `values` covers carried, by port id, as a picture, drawn in the slot a
88
+ * look keeps for it (`showPreviews`). A bitmap rather than a canvas
89
+ * because its pixels cannot change: hand back the same one and nothing is
90
+ * uploaded again; draw new pixels into a new one. */
91
+ previews?: Readonly<Record<string, ImageBitmap>>;
92
+ /** Why the stage failed, written where its cost goes. What it feeds is
93
+ * left unreached. */
94
+ error?: string;
95
+ }
96
+ /** What a value type means, as `EffectPipeline.types` records it. */
97
+ interface EffectType {
98
+ /** A control value: a condition, a gate, a modulation source. Looks draw
99
+ * its wires apart from data wires. */
100
+ control?: boolean;
101
+ }
102
+ /** How a param is edited, and the value it holds. */
103
+ type EffectParamControl = {
104
+ kind: 'number';
105
+ value: number;
106
+ min?: number;
107
+ max?: number;
108
+ step?: number;
109
+ unit?: string;
110
+ } | {
111
+ kind: 'enum';
112
+ value: string;
113
+ options: readonly {
114
+ value: string;
115
+ label?: string;
116
+ }[];
117
+ } | {
118
+ kind: 'boolean';
119
+ value: boolean;
120
+ } | {
121
+ kind: 'string';
122
+ value: string;
123
+ };
124
+ /** One setting a stage shows. `value` is the display string; `control`, when
125
+ * present, is what an editor changes and `value` is its formatted form. */
126
+ interface EffectParam {
127
+ /** Addresses the param when labels repeat; the label stands in when absent. */
128
+ id?: string;
129
+ label: string;
130
+ value: string;
131
+ control?: EffectParamControl;
132
+ }
133
+ /** Where each stage sits, by stage id, beside the pipeline rather than in it. */
134
+ type EffectPlaces = Readonly<Record<string, Vec2>>;
135
+ /** A pipeline and where its stages sit: what an editor holds and changes. */
136
+ interface EffectDoc {
137
+ pipeline: EffectPipeline;
138
+ places: EffectPlaces;
139
+ /** The pages the stages are drawn across under `nodeGraph`, beside the
140
+ * pipeline as `places` is. A wire between stages on different pages is
141
+ * drawn as two stubs with off-page tags. The other looks ignore them. */
142
+ pages?: readonly Page[];
143
+ /** The value types whose lanes the `lanes` look draws first, top down. */
144
+ laneOrder?: readonly string[];
145
+ /** The waypoints a person routed each wire through under `nodeGraph`, by
146
+ * wire id, beside the pipeline as `places` is. */
147
+ routes?: Readonly<Record<string, readonly Vec2[]>>;
148
+ /** The routes a person drew under `rack` and `lanes`, by look, then by wire id. */
149
+ lookRoutes?: LookRoutes;
150
+ /** Each group's box under `nodeGraph`, by group id, beside the pipeline as
151
+ * `places` is. A group with none fits its members. */
152
+ groupBoxes?: Readonly<Record<string, EffectBox>>;
153
+ }
154
+ /** A box on the page, in world units. */
155
+ interface EffectBox {
156
+ x: number;
157
+ y: number;
158
+ width: number;
159
+ height: number;
160
+ }
161
+ /** A wire's route under a look that places its stages itself. */
162
+ interface LookRoute {
163
+ waypoints: readonly Vec2[];
164
+ /** Where the wire's from and to ports were when it was routed. The route
165
+ * is drawn only while they are still there: a reorder or an added stage
166
+ * moves stages, and a route drawn for one arrangement means nothing in another. */
167
+ ends: readonly [Vec2, Vec2];
168
+ }
169
+ /** `EffectDoc.lookRoutes`. */
170
+ interface LookRoutes {
171
+ rack?: Readonly<Record<string, LookRoute>>;
172
+ lanes?: Readonly<Record<string, LookRoute>>;
173
+ }
174
+
175
+ /** A palette entry: a stage's ports and params, ready to be copied into a pipeline. */
176
+ interface EffectStageType {
177
+ type: string;
178
+ title: string;
179
+ kind?: string;
180
+ inputs?: readonly EffectPort[];
181
+ outputs?: readonly EffectPort[];
182
+ params?: readonly EffectParam[];
183
+ }
184
+ /** A stage of type `t` with its own copy of the ports and params; no link back. */
185
+ declare function stageFromType(t: EffectStageType, id: string): EffectStage;
186
+ /** The display string for a control's value, to as many places as its `step` has (one without a step). */
187
+ declare function formatParam(control: EffectParamControl): string;
188
+
189
+ export { type EffectPipeline as E, type LookRoutes as L, type EffectRun as a, type EffectStageType as b, type EffectDoc as c, type EffectWire as d, type EffectStage as e, type EffectPort as f, type EffectGroup as g, type EffectParamControl as h, type EffectBox as i, type EffectParam as j, type EffectPlaces as k, type EffectStageRun as l, type EffectType as m, type LookRoute as n, formatParam as o, stageFromType as s };