@pixerate/editor 0.27.0 → 0.29.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 (112) hide show
  1. package/README.md +44 -2
  2. package/dist/HistoryManager-DWSLd6Tf.d.ts +150 -0
  3. package/dist/HistoryManager-DeQQMBCj.d.cts +150 -0
  4. package/dist/agent/index.cjs +20 -427
  5. package/dist/agent/index.cjs.map +1 -1
  6. package/dist/agent/index.d.cts +4 -342
  7. package/dist/agent/index.d.ts +4 -342
  8. package/dist/agent/index.js +14 -421
  9. package/dist/agent/index.js.map +1 -1
  10. package/dist/animation/index.cjs +62 -0
  11. package/dist/animation/index.cjs.map +1 -0
  12. package/dist/animation/index.d.cts +226 -0
  13. package/dist/animation/index.d.ts +226 -0
  14. package/dist/animation/index.js +62 -0
  15. package/dist/animation/index.js.map +1 -0
  16. package/dist/{builtins-nMXh9sT3.d.cts → builtins-DxC3aUR2.d.cts} +2 -2
  17. package/dist/{builtins-haN82vjT.d.ts → builtins-NGxNxQfJ.d.ts} +2 -2
  18. package/dist/canvas/index.cjs +177 -743
  19. package/dist/canvas/index.cjs.map +1 -1
  20. package/dist/canvas/index.d.cts +6 -289
  21. package/dist/canvas/index.d.ts +6 -289
  22. package/dist/canvas/index.js +49 -615
  23. package/dist/canvas/index.js.map +1 -1
  24. package/dist/chunk-36BLROHV.js +438 -0
  25. package/dist/chunk-36BLROHV.js.map +1 -0
  26. package/dist/{chunk-JT7AXQTE.js → chunk-3RPOW4CS.js} +7 -7
  27. package/dist/{chunk-AGR7EVRW.cjs → chunk-6MDQKHRH.cjs} +6 -6
  28. package/dist/{chunk-AGR7EVRW.cjs.map → chunk-6MDQKHRH.cjs.map} +1 -1
  29. package/dist/chunk-A6PHCAGX.cjs +87 -0
  30. package/dist/chunk-A6PHCAGX.cjs.map +1 -0
  31. package/dist/{chunk-HRMEDT2L.js → chunk-D6AVOTSD.js} +6 -85
  32. package/dist/chunk-D6AVOTSD.js.map +1 -0
  33. package/dist/{chunk-ARRTP33I.js → chunk-D6S5M7HV.js} +2 -2
  34. package/dist/{chunk-ARRTP33I.js.map → chunk-D6S5M7HV.js.map} +1 -1
  35. package/dist/{chunk-6IO7WUSU.js → chunk-DDADOHJW.js} +17 -17
  36. package/dist/{chunk-CPOKFNBG.cjs → chunk-I6BZB5ZH.cjs} +2 -2
  37. package/dist/{chunk-CPOKFNBG.cjs.map → chunk-I6BZB5ZH.cjs.map} +1 -1
  38. package/dist/{chunk-4BVP64JJ.cjs → chunk-K2UYKJ6M.cjs} +24 -103
  39. package/dist/chunk-K2UYKJ6M.cjs.map +1 -0
  40. package/dist/chunk-PIIAZV3L.cjs +244 -0
  41. package/dist/chunk-PIIAZV3L.cjs.map +1 -0
  42. package/dist/chunk-PWJARCI4.js +637 -0
  43. package/dist/chunk-PWJARCI4.js.map +1 -0
  44. package/dist/{chunk-G2I4QJOT.cjs → chunk-QKLRAA4T.cjs} +3 -244
  45. package/dist/chunk-QKLRAA4T.cjs.map +1 -0
  46. package/dist/{chunk-2H7ZHPEJ.js → chunk-QVZZGT4X.js} +1 -242
  47. package/dist/chunk-QVZZGT4X.js.map +1 -0
  48. package/dist/chunk-TGD52FEZ.js +87 -0
  49. package/dist/chunk-TGD52FEZ.js.map +1 -0
  50. package/dist/chunk-TTYCN6ZH.cjs +637 -0
  51. package/dist/chunk-TTYCN6ZH.cjs.map +1 -0
  52. package/dist/{chunk-YK5TATOF.cjs → chunk-U7VGDSNY.cjs} +3 -3
  53. package/dist/{chunk-YK5TATOF.cjs.map → chunk-U7VGDSNY.cjs.map} +1 -1
  54. package/dist/chunk-V7CC7RZ6.cjs +438 -0
  55. package/dist/chunk-V7CC7RZ6.cjs.map +1 -0
  56. package/dist/chunk-YK57D7PW.js +244 -0
  57. package/dist/chunk-YK57D7PW.js.map +1 -0
  58. package/dist/commands/index.cjs +2 -2
  59. package/dist/commands/index.cjs.map +1 -1
  60. package/dist/commands/index.d.cts +2 -2
  61. package/dist/commands/index.d.ts +2 -2
  62. package/dist/commands/index.js +1 -1
  63. package/dist/commands/index.js.map +1 -1
  64. package/dist/easing-B6iAnJHk.d.cts +74 -0
  65. package/dist/easing-B6iAnJHk.d.ts +74 -0
  66. package/dist/extensions/index.cjs +5 -5
  67. package/dist/extensions/index.cjs.map +1 -1
  68. package/dist/extensions/index.js +4 -4
  69. package/dist/generation/index.cjs +4 -4
  70. package/dist/generation/index.cjs.map +1 -1
  71. package/dist/generation/index.js +3 -3
  72. package/dist/generation/index.js.map +1 -1
  73. package/dist/history/index.cjs +4 -2
  74. package/dist/history/index.cjs.map +1 -1
  75. package/dist/history/index.d.cts +3 -149
  76. package/dist/history/index.d.ts +3 -149
  77. package/dist/history/index.js +5 -3
  78. package/dist/image-editor/index.cjs.map +1 -1
  79. package/dist/image-editor/index.js.map +1 -1
  80. package/dist/index.cjs +24 -22
  81. package/dist/index.cjs.map +1 -1
  82. package/dist/index.d.cts +3 -2
  83. package/dist/index.d.ts +3 -2
  84. package/dist/index.js +112 -110
  85. package/dist/index.js.map +1 -1
  86. package/dist/parameters/index.cjs +1283 -0
  87. package/dist/parameters/index.cjs.map +1 -0
  88. package/dist/parameters/index.d.cts +595 -0
  89. package/dist/parameters/index.d.ts +595 -0
  90. package/dist/parameters/index.js +1283 -0
  91. package/dist/parameters/index.js.map +1 -0
  92. package/dist/spreadsheet/index.cjs +4 -4
  93. package/dist/spreadsheet/index.cjs.map +1 -1
  94. package/dist/spreadsheet/index.js +8 -8
  95. package/dist/tokens/index.cjs +4 -2
  96. package/dist/tokens/index.cjs.map +1 -1
  97. package/dist/tokens/index.js +6 -4
  98. package/dist/tools/index.cjs +31 -0
  99. package/dist/tools/index.cjs.map +1 -0
  100. package/dist/tools/index.d.cts +343 -0
  101. package/dist/tools/index.d.ts +343 -0
  102. package/dist/tools/index.js +31 -0
  103. package/dist/tools/index.js.map +1 -0
  104. package/dist/{types-GT5a5YAX.d.cts → types-DsiXGmjo.d.cts} +1 -1
  105. package/dist/{types-GT5a5YAX.d.ts → types-DsiXGmjo.d.ts} +1 -1
  106. package/package.json +16 -1
  107. package/dist/chunk-2H7ZHPEJ.js.map +0 -1
  108. package/dist/chunk-4BVP64JJ.cjs.map +0 -1
  109. package/dist/chunk-G2I4QJOT.cjs.map +0 -1
  110. package/dist/chunk-HRMEDT2L.js.map +0 -1
  111. /package/dist/{chunk-JT7AXQTE.js.map → chunk-3RPOW4CS.js.map} +0 -0
  112. /package/dist/{chunk-6IO7WUSU.js.map → chunk-DDADOHJW.js.map} +0 -0
@@ -0,0 +1,595 @@
1
+ import { A as AnimationEasing } from '../easing-B6iAnJHk.js';
2
+ import { J as JsonSchema } from '../schema-DYDGdYL9.js';
3
+ import { H as HistoryManager } from '../HistoryManager-DWSLd6Tf.js';
4
+ import { C as CommandSpec } from '../registry-DhVUZioj.js';
5
+ import '../types-DsiXGmjo.js';
6
+
7
+ /**
8
+ * Types for the schema-driven parameters editor: the control panel of an effect, shader,
9
+ * generator or component. A `ParameterSchema` lists fields (optionally in groups); a
10
+ * `ParametersController` holds their values with validation, undo, presets and keyframes.
11
+ */
12
+ /** A parameter's value. `number` / `int`: a number; `boolean`; `choice`: an option value;
13
+ * `color`: `#rrggbb` (or `#rrggbbaa` with `alpha`); `vector`: 2–4 numbers; `image` / `text`: a string. */
14
+ type ParameterValue = number | boolean | string | number[];
15
+ /** Parameter id → value. */
16
+ type ParameterValues = Record<string, ParameterValue>;
17
+ type ParameterFieldType = 'number' | 'int' | 'boolean' | 'choice' | 'color' | 'vector' | 'image' | 'text';
18
+ /**
19
+ * One test in a `showIf` condition: a literal (equal to), an array (one of), or an object
20
+ * whose keys must all hold.
21
+ */
22
+ type ParameterConditionTest = string | number | boolean | readonly (string | number | boolean)[] | {
23
+ eq?: ParameterValue;
24
+ ne?: ParameterValue;
25
+ in?: readonly (string | number | boolean)[];
26
+ notIn?: readonly (string | number | boolean)[];
27
+ gt?: number;
28
+ gte?: number;
29
+ lt?: number;
30
+ lte?: number;
31
+ /** `true`: the value is truthy (non-zero, non-empty); `false`: falsy. */
32
+ truthy?: boolean;
33
+ };
34
+ /**
35
+ * When a field or group is shown. An object maps other parameter ids to tests, all of which
36
+ * must hold (`{ mode: 'advanced', count: { gte: 2 } }`); a function gets every value.
37
+ * Hidden fields keep their values.
38
+ */
39
+ type ParameterCondition = {
40
+ readonly [id: string]: ParameterConditionTest;
41
+ } | ((values: Readonly<ParameterValues>) => boolean);
42
+ interface ParameterFieldBase<TValue extends ParameterValue> {
43
+ /** Unique id across the schema (also the key in `values`). */
44
+ id: string;
45
+ /** Display name (default: the id made readable, `flowSpeed` → "Flow speed"). */
46
+ label?: string;
47
+ /** Help text shown under the label and given to agents. */
48
+ description?: string;
49
+ default: TValue;
50
+ showIf?: ParameterCondition;
51
+ /** Include in `randomize()` (default `true`; image and text fields are never randomised). */
52
+ randomize?: boolean;
53
+ /** Shown but not editable from the panel (agents and code can still set it). */
54
+ readOnly?: boolean;
55
+ }
56
+ interface NumberParameterField extends ParameterFieldBase<number> {
57
+ type: 'number' | 'int';
58
+ min?: number;
59
+ max?: number;
60
+ /** Slider / spinner step (default: 1 for `int`, 1/100 of the range otherwise). */
61
+ step?: number;
62
+ /** Unit shown after the value (`px`, `%`, `°`, `ms`). */
63
+ unit?: string;
64
+ /** `slider` (slider plus number box; the default when `min` and `max` are set) or `input` (number box only). */
65
+ control?: 'slider' | 'input';
66
+ /** Decimal places shown (default: from `step`). */
67
+ decimals?: number;
68
+ }
69
+ interface BooleanParameterField extends ParameterFieldBase<boolean> {
70
+ type: 'boolean';
71
+ }
72
+ interface ParameterChoiceOption {
73
+ value: string | number;
74
+ label?: string;
75
+ description?: string;
76
+ }
77
+ interface ChoiceParameterField extends ParameterFieldBase<string | number> {
78
+ type: 'choice';
79
+ options: readonly (string | number | ParameterChoiceOption)[];
80
+ /** `select` (dropdown, the default) or `segmented` (buttons; best for 2–4 options). */
81
+ control?: 'select' | 'segmented';
82
+ }
83
+ interface ColorParameterField extends ParameterFieldBase<string> {
84
+ type: 'color';
85
+ /** Values carry alpha as `#rrggbbaa` (default `false`: `#rrggbb`). */
86
+ alpha?: boolean;
87
+ /** Colours offered as swatches. */
88
+ swatches?: readonly string[];
89
+ }
90
+ interface VectorParameterField extends ParameterFieldBase<number[]> {
91
+ type: 'vector';
92
+ /** Number of components, 2–4 (default: the default's length). */
93
+ size?: 2 | 3 | 4;
94
+ /** Bounds for every component, or one per component. */
95
+ min?: number | readonly number[];
96
+ max?: number | readonly number[];
97
+ step?: number;
98
+ unit?: string;
99
+ /** Component labels (default `x`, `y`, `z`, `w`). */
100
+ labels?: readonly string[];
101
+ decimals?: number;
102
+ }
103
+ interface ParameterImageOption {
104
+ url: string;
105
+ label?: string;
106
+ }
107
+ interface ImageParameterField extends ParameterFieldBase<string> {
108
+ type: 'image';
109
+ /** Suggested assets shown as thumbnails. */
110
+ options?: readonly ParameterImageOption[];
111
+ /** File types offered by the picker's file button, e.g. `image/*`. */
112
+ accept?: string;
113
+ }
114
+ interface TextParameterField extends ParameterFieldBase<string> {
115
+ type: 'text';
116
+ multiline?: boolean;
117
+ maxLength?: number;
118
+ minLength?: number;
119
+ /** Regular expression (unicode) the whole value must match. */
120
+ pattern?: string;
121
+ placeholder?: string;
122
+ }
123
+ type ParameterField = NumberParameterField | BooleanParameterField | ChoiceParameterField | ColorParameterField | VectorParameterField | ImageParameterField | TextParameterField;
124
+ /** A collapsible group of fields (groups may nest). */
125
+ interface ParameterGroup {
126
+ type: 'group';
127
+ /** Unique id (used for its collapsed state). */
128
+ id: string;
129
+ label?: string;
130
+ description?: string;
131
+ /** Starts collapsed (default `false`). */
132
+ collapsed?: boolean;
133
+ showIf?: ParameterCondition;
134
+ fields: readonly ParameterSchemaItem[];
135
+ }
136
+ type ParameterSchemaItem = ParameterField | ParameterGroup;
137
+ /** A named set of values. Fields a preset leaves out go back to their defaults when applied. */
138
+ interface ParameterPreset {
139
+ name: string;
140
+ values: Partial<ParameterValues>;
141
+ description?: string;
142
+ /** Comes from the schema: cannot be overwritten or deleted. */
143
+ builtIn?: boolean;
144
+ }
145
+ interface ParameterSchema {
146
+ title?: string;
147
+ fields: readonly ParameterSchemaItem[];
148
+ /** Built-in presets. */
149
+ presets?: readonly ParameterPreset[];
150
+ }
151
+ /** One error, shaped like `validateJsonSchema`'s: `path` is `/<id>` (or `/<id>/<index>`). */
152
+ interface ParameterError {
153
+ path: string;
154
+ /** The parameter's id. */
155
+ id: string;
156
+ /** A sentence naming the field, e.g. "Speed must be at most 4." */
157
+ message: string;
158
+ }
159
+ /** Easing of a keyframe segment (the `AnimationEasing` of `@pixerate/editor/animation`). */
160
+ type ParameterEasing = AnimationEasing;
161
+ /** One keyframe, shaped like `AnimationKeyframe` from `@pixerate/editor/animation`. */
162
+ interface ParameterKeyframe<TValue = ParameterValue> {
163
+ /** Time in milliseconds. */
164
+ time: number;
165
+ value: TValue;
166
+ /** Easing of the segment leaving this keyframe. */
167
+ easing?: ParameterEasing;
168
+ }
169
+ /** A parameter's keyframes, shaped like `AnimationTrack` from `@pixerate/editor/animation` (which it accepts). */
170
+ interface ParameterTrack<TValue = ParameterValue> {
171
+ keyframes: ParameterKeyframe<TValue>[];
172
+ enabled?: boolean;
173
+ }
174
+ /**
175
+ * Where a parameter's keyframes live: an effect document, a canvas node, or
176
+ * `createParameterKeyframeStore()`. The controller reads and writes whole tracks so a
177
+ * keyframe toggle is one undo step.
178
+ */
179
+ interface ParameterKeyframes {
180
+ getTrack(id: string): ParameterTrack<any> | undefined;
181
+ /** Replaces a track; `undefined` (or no keyframes) removes it. */
182
+ setTrack(id: string, track: ParameterTrack<any> | undefined): void;
183
+ /** Called when tracks change from outside the controller. */
184
+ subscribe?(listener: () => void): () => void;
185
+ }
186
+ /** `keyed`: a keyframe sits at the current time; `animated`: keyframes elsewhere; `none`. */
187
+ type ParameterKeyState = 'none' | 'animated' | 'keyed';
188
+
189
+ /** `flowSpeed`, `flow_speed` or `uFlowSpeed` → "Flow speed". */
190
+ declare function humanizeParameterId(id: string): string;
191
+ /** The label shown for a field or group. */
192
+ declare function parameterLabel(item: {
193
+ id: string;
194
+ label?: string;
195
+ }): string;
196
+ /**
197
+ * Normalises a hex colour to lower-case `#rrggbb`, or `#rrggbbaa` when `alpha` is true
198
+ * (opaque colours get `ff`). Accepts 3, 4, 6 and 8 digits with or without `#`; returns
199
+ * `null` for anything else. Without `alpha`, a colour's alpha is dropped.
200
+ */
201
+ declare function normalizeHexColor(input: string, alpha?: boolean): string | null;
202
+ /** `#77c16a` → `[0.467, 0.757, 0.416]` (0–1 components; four with `alpha`). `null` if not a colour. */
203
+ declare function hexToRgba01(hex: string, alpha?: boolean): number[] | null;
204
+ /** `[0.467, 0.757, 0.416]` → `#77c16a`; a fourth component becomes alpha when `alpha` is true. Clamped to 0–1. */
205
+ declare function rgba01ToHex(components: readonly number[], alpha?: boolean): string;
206
+ declare const isParameterGroup: (item: ParameterSchemaItem) => item is ParameterGroup;
207
+ /** Every field in schema order, groups flattened. */
208
+ declare function getParameterFields(schema: ParameterSchema | readonly ParameterSchemaItem[]): ParameterField[];
209
+ /** Every group in schema order (nested groups after their parent). */
210
+ declare function getParameterGroups(schema: ParameterSchema): ParameterGroup[];
211
+ declare class ParameterSchemaError extends Error {
212
+ constructor(message: string);
213
+ }
214
+ /**
215
+ * Checks a schema's structure: unique ids, known types, choice options, vector sizes and
216
+ * defaults that pass validation. Returns sentences; an empty array means the schema is fine.
217
+ */
218
+ declare function checkParameterSchema(schema: ParameterSchema): string[];
219
+ /** The defaults of every field (colours normalised to lower-case hex, `int`s rounded). */
220
+ declare function getParameterDefaults(schema: ParameterSchema): ParameterValues;
221
+ declare const cloneValue: <T extends ParameterValue>(value: T) => T;
222
+ /** Value equality (vectors compare component-wise). */
223
+ declare function parameterValuesEqual(a: ParameterValue | undefined, b: ParameterValue | undefined): boolean;
224
+ /** Whether a `showIf` condition holds for `values` (no condition: `true`). */
225
+ declare function evaluateParameterCondition(condition: ParameterCondition | undefined, values: Readonly<ParameterValues>): boolean;
226
+ /**
227
+ * Field and group id → shown. An item is hidden when its own `showIf` fails or any
228
+ * enclosing group is hidden.
229
+ */
230
+ declare function getParameterVisibility(schema: ParameterSchema, values: Readonly<ParameterValues>): Record<string, boolean>;
231
+ /** A choice field's options as objects. */
232
+ declare function getChoiceOptions(field: ChoiceParameterField): ParameterChoiceOption[];
233
+ /** An option's label (default: the value made readable). */
234
+ declare const choiceOptionLabel: (option: ParameterChoiceOption) => string;
235
+ declare function vectorSize(field: VectorParameterField): number;
236
+ /** A vector component as a number field (its bounds, step, unit and label). */
237
+ declare function vectorComponentField(field: VectorParameterField, index: number): NumberParameterField;
238
+ /** The step a number field moves by: `step`, else 1 for `int`, else 1/100 of the range (0.01 without one). */
239
+ declare function parameterStep(field: NumberParameterField): number;
240
+ /** Decimal places to show: `decimals`, else enough for the step (at most 4). */
241
+ declare function parameterDecimals(field: NumberParameterField): number;
242
+ /** Whether a number field renders a slider (`control`, else when it has both bounds). */
243
+ declare const isSliderField: (field: NumberParameterField) => boolean;
244
+ /** A number as shown for a field: fixed decimals, trailing zeros trimmed, plus the unit. */
245
+ declare function formatParameterNumber(field: NumberParameterField, value: number): string;
246
+ /** Clamps into the field's bounds, rounds `int`s and snaps float noise (for UI inputs). */
247
+ declare function clampParameterNumber(field: NumberParameterField, value: number): number;
248
+ /**
249
+ * Parses what someone typed into a number box ("2.5", "2.5x", "-1e2") and clamps it into
250
+ * the field's bounds. Returns `null` when it is not a number.
251
+ */
252
+ declare function parseParameterNumberInput(field: NumberParameterField, text: string): number | null;
253
+ /** A value as short display text (numbers formatted, vectors comma-separated, booleans On/Off). */
254
+ declare function formatParameterValue(field: ParameterField, value: ParameterValue | undefined): string;
255
+ /**
256
+ * Checks a value against a field. Returns `null` when it is valid, else one error whose
257
+ * message is a sentence naming the field ("Speed must be at most 4.").
258
+ */
259
+ declare function validateParameterValue(field: ParameterField, value: unknown): ParameterError | null;
260
+ type ParameterCoercion = {
261
+ ok: true;
262
+ value: ParameterValue;
263
+ } | {
264
+ ok: false;
265
+ error: ParameterError;
266
+ };
267
+ /**
268
+ * Checks a value from outside (an agent's tool call, a URL, a form) and returns the value to
269
+ * store. Coercion is narrow: `int`s are rounded, colours normalised to lower-case hex.
270
+ */
271
+ declare function coerceParameterValue(field: ParameterField, raw: unknown): ParameterCoercion;
272
+ /** Every error for `values` (missing values are reported too). */
273
+ declare function validateParameterValues(schema: ParameterSchema, values: Readonly<Partial<ParameterValues>>): ParameterError[];
274
+ /** One field as JSON Schema (for agent tool parameters). */
275
+ declare function parameterFieldToJsonSchema(field: ParameterField): JsonSchema;
276
+ /** The schema's values as one object JSON Schema (every property optional). */
277
+ declare function parameterSchemaToJsonSchema(schema: ParameterSchema): JsonSchema & {
278
+ type: 'object';
279
+ };
280
+
281
+ /** Keyframes closer than this (ms) to the playhead count as "at" it (default for the controller). */
282
+ declare const PARAMETER_KEY_TOLERANCE = 0.5;
283
+ /** Whether a track has a keyframe within `tolerance` ms of `time`. */
284
+ declare function findParameterKeyframe(track: ParameterTrack<any> | undefined, time: number, tolerance?: number): number;
285
+ /** `keyed` (a key at `time`), `animated` (keys elsewhere) or `none`. */
286
+ declare function getParameterKeyState(track: ParameterTrack<any> | undefined, time: number, tolerance?: number): ParameterKeyState;
287
+ /** A copy of `track` with a key at `time` holding `value` (replacing one already there). */
288
+ declare function withParameterKeyframe<T>(track: ParameterTrack<T> | undefined, key: ParameterKeyframe<T>, tolerance?: number): ParameterTrack<T>;
289
+ /** A copy of `track` without the key at `time`; `undefined` when no keys remain. */
290
+ declare function withoutParameterKeyframe<T>(track: ParameterTrack<T> | undefined, time: number, tolerance?: number): ParameterTrack<T> | undefined;
291
+ interface ParameterKeyframeStore extends ParameterKeyframes {
292
+ /** Every track (id → track). Stable between changes. */
293
+ getTracks(): Readonly<Record<string, ParameterTrack<any>>>;
294
+ /** Replaces every track (no notification when `silent`). */
295
+ setTracks(tracks: Record<string, ParameterTrack<any>>, silent?: boolean): void;
296
+ subscribe(listener: () => void): () => void;
297
+ }
298
+ /**
299
+ * An in-memory `ParameterKeyframes` adapter for apps that keep tracks next to their values
300
+ * (an effect document can implement the interface over its own storage instead).
301
+ */
302
+ declare function createParameterKeyframeStore(initial?: Record<string, ParameterTrack<any>>): ParameterKeyframeStore;
303
+
304
+ interface ParametersControllerOptions {
305
+ schema: ParameterSchema;
306
+ /** Starting values (missing or invalid ones use the default; invalid ones are reported in `errors`). */
307
+ values?: Partial<ParameterValues>;
308
+ /** User presets (the schema's presets are added as built-in). */
309
+ presets?: readonly ParameterPreset[];
310
+ /** History to record into, e.g. one shared with the rest of the app (default: a new one). */
311
+ history?: HistoryManager;
312
+ /** Where keyframes live. Without it, keyframe methods do nothing. */
313
+ keyframes?: ParameterKeyframes;
314
+ /** Starting playhead time in ms (default 0). */
315
+ time?: number;
316
+ /** Keys within this many ms of the playhead count as "at" it (default 0.5). */
317
+ keyTolerance?: number;
318
+ /** Random source for `randomize` (default `Math.random`). */
319
+ random?: () => number;
320
+ /** Called after values change (set, undo, preset, load, …) with the ids that changed. */
321
+ onChange?: (values: Readonly<ParameterValues>, changed: readonly string[]) => void;
322
+ }
323
+ /** A snapshot of the controller. The same object is returned until something changes. */
324
+ interface ParametersState {
325
+ schema: ParameterSchema;
326
+ /** Every field in schema order (groups flattened). */
327
+ fields: readonly ParameterField[];
328
+ values: Readonly<ParameterValues>;
329
+ defaults: Readonly<ParameterValues>;
330
+ /** Field and group id → shown (see `showIf`). */
331
+ visible: Readonly<Record<string, boolean>>;
332
+ /** Group id → collapsed. */
333
+ collapsed: Readonly<Record<string, boolean>>;
334
+ /** Field id → the last rejected value's error (cleared when the field is next set). */
335
+ errors: Readonly<Record<string, string>>;
336
+ /** Built-in presets first, then user presets. */
337
+ presets: readonly ParameterPreset[];
338
+ /** The first preset whose values match the current values, if any. */
339
+ activePreset: string | null;
340
+ /** Any value differs from its default. */
341
+ modified: boolean;
342
+ /** Playhead time in ms (for keyframes). */
343
+ time: number;
344
+ /** Whether a keyframes adapter is attached. */
345
+ keyframesEnabled: boolean;
346
+ /** Field id → keyframe state at `time`. */
347
+ keys: Readonly<Record<string, ParameterKeyState>>;
348
+ /** The gesture in progress (a field id), if any. */
349
+ gesture: string | null;
350
+ canUndo: boolean;
351
+ canRedo: boolean;
352
+ undoLabel: string;
353
+ redoLabel: string;
354
+ /** Bumped on every change. */
355
+ revision: number;
356
+ }
357
+ type ParameterSetResult = {
358
+ ok: true;
359
+ value: ParameterValue;
360
+ } | {
361
+ ok: false;
362
+ error: ParameterError;
363
+ message: string;
364
+ };
365
+ type ParameterSetValuesResult = {
366
+ ok: true;
367
+ values: Partial<ParameterValues>;
368
+ changed: string[];
369
+ } | {
370
+ ok: false;
371
+ errors: ParameterError[];
372
+ message: string;
373
+ };
374
+ type ParameterActionResult = {
375
+ ok: true;
376
+ } | {
377
+ ok: false;
378
+ message: string;
379
+ };
380
+ interface SetParameterOptions {
381
+ /** Undo step label (default "Change <label>"). */
382
+ label?: string;
383
+ }
384
+ interface RandomizeParametersOptions {
385
+ /** Only these fields (default: every visible field that allows it). */
386
+ ids?: readonly string[];
387
+ /** Seed for a repeatable result. */
388
+ seed?: number;
389
+ /** Random source (default: the controller's). */
390
+ random?: () => number;
391
+ }
392
+ interface ApplyPresetOptions {
393
+ /** Keep values the preset leaves out (default: they go back to their defaults). */
394
+ merge?: boolean;
395
+ }
396
+ /** What `toJSON` returns and `load` takes. */
397
+ interface ParametersSnapshot {
398
+ values: Partial<ParameterValues>;
399
+ /** User presets. */
400
+ presets?: ParameterPreset[];
401
+ }
402
+ /** A repeatable random source (mulberry32). */
403
+ declare function seededRandom(seed: number): () => number;
404
+ /**
405
+ * Headless state for a parameters panel: values with validation, undo (slider drags merge
406
+ * into one step), reset, randomize, presets and optional keyframe hooks. `getState()` returns
407
+ * the same object until something changes, so it works with `useSyncExternalStore`.
408
+ */
409
+ declare class ParametersController {
410
+ readonly history: HistoryManager;
411
+ private schema;
412
+ private fields;
413
+ private fieldMap;
414
+ private defaults;
415
+ private values;
416
+ private userPresets;
417
+ private collapsed;
418
+ private errors;
419
+ private time;
420
+ private keyframes?;
421
+ private readonly keyTolerance;
422
+ private readonly random;
423
+ private readonly onChange?;
424
+ private readonly listeners;
425
+ private readonly cleanups;
426
+ private gestureId;
427
+ private gestureCount;
428
+ private revision;
429
+ private applying;
430
+ private state;
431
+ constructor(options: ParametersControllerOptions);
432
+ private unwatchKeyframes?;
433
+ private watchKeyframes;
434
+ /** The current snapshot (stable until the next change). */
435
+ getState: () => ParametersState;
436
+ /** Calls `listener` after every change. Returns an unsubscribe function. */
437
+ subscribe: (listener: (state: ParametersState) => void) => (() => void);
438
+ getSchema(): ParameterSchema;
439
+ getField(id: string): ParameterField | undefined;
440
+ getValue(id: string): ParameterValue | undefined;
441
+ getValues(): Readonly<ParameterValues>;
442
+ private indexSchema;
443
+ /** Values for every field: valid entries of `values`, else `fallback`. Invalid ones are reported. */
444
+ private adopt;
445
+ private allPresets;
446
+ private presetValues;
447
+ private computeState;
448
+ private notify;
449
+ private apply;
450
+ private command;
451
+ /** Track updates that keep keys at the playhead in step with new values. */
452
+ private keyUpdates;
453
+ private record;
454
+ private reject;
455
+ /** Only the entries of `values` that differ from the current values. */
456
+ private diff;
457
+ private clearErrors;
458
+ /**
459
+ * Sets one value after validating it (`int`s round, colours normalise). Invalid values are
460
+ * not stored; the error is returned and shown in `state.errors`. One undo step, or part of
461
+ * the current gesture (see `beginGesture`).
462
+ */
463
+ setValue(id: string, value: unknown, options?: SetParameterOptions): ParameterSetResult;
464
+ /**
465
+ * Sets several values as one undo step. All-or-nothing: if any id is unknown or any value
466
+ * invalid, nothing changes and every error is returned.
467
+ */
468
+ setValues(values: Partial<ParameterValues> | Record<string, unknown>, options?: SetParameterOptions): ParameterSetValuesResult;
469
+ /**
470
+ * Starts a continuous edit of `id` (a slider drag): every `setValue` until `endGesture()`
471
+ * merges into one undo step.
472
+ */
473
+ beginGesture(id: string): void;
474
+ /** Ends the current gesture; the next change is a new undo step. */
475
+ endGesture(): void;
476
+ /** Puts fields (default: all) back to their defaults as one undo step. */
477
+ reset(ids?: readonly string[]): ParameterActionResult;
478
+ /**
479
+ * Picks random values within each field's range, snapped to its step, as one undo step.
480
+ * Skips hidden fields, `randomize: false`, `readOnly`, image and text fields, and numbers
481
+ * without both `min` and `max`.
482
+ */
483
+ randomize(options?: RandomizeParametersOptions): ParameterSetValuesResult;
484
+ /** Applies a preset as one undo step. Fields it leaves out return to their defaults unless `merge`. */
485
+ applyPreset(name: string, options?: ApplyPresetOptions): ParameterActionResult;
486
+ /** Saves the current values (all fields) as a user preset, replacing one with the same name. Undoable. */
487
+ savePreset(name: string, options?: {
488
+ description?: string;
489
+ }): ParameterActionResult;
490
+ /** Deletes a user preset (built-in presets cannot be deleted). Undoable. */
491
+ deletePreset(name: string): ParameterActionResult;
492
+ private unknownPreset;
493
+ /** Moves the playhead. `values` (e.g. evaluated from the tracks) are shown without an undo step. */
494
+ setTime(time: number, values?: Partial<ParameterValues>): void;
495
+ /** `keyed`, `animated` or `none` for a field at `time` (default: the playhead). */
496
+ keyState(id: string, time?: number): ParameterKeyState;
497
+ /** Attaches (or with `undefined` detaches) a keyframes adapter. */
498
+ setKeyframes(keyframes: ParameterKeyframes | undefined): void;
499
+ /**
500
+ * Adds a keyframe with the field's current value at `time` (default: the playhead), or
501
+ * removes the one already there. One undo step.
502
+ */
503
+ toggleKeyframe(id: string, time?: number): {
504
+ ok: true;
505
+ keyed: boolean;
506
+ } | {
507
+ ok: false;
508
+ message: string;
509
+ };
510
+ /** Collapses or expands a group (view state; not an undo step). */
511
+ setCollapsed(groupId: string, collapsed: boolean): void;
512
+ toggleCollapsed(groupId: string): void;
513
+ /**
514
+ * Replaces the schema (e.g. after a shader recompiles). Values that still fit their field
515
+ * are kept; others reset to the new default. Not an undo step; throws a
516
+ * `ParameterSchemaError` for an invalid schema.
517
+ */
518
+ setSchema(schema: ParameterSchema): void;
519
+ /** Values and user presets, for saving. */
520
+ toJSON(): ParametersSnapshot;
521
+ /**
522
+ * Replaces values (and user presets, when given) without an undo step, e.g. when opening a
523
+ * document. Missing values use defaults; invalid ones use defaults and are reported in
524
+ * `state.errors`. Clears the history when `clearHistory` is true.
525
+ */
526
+ load(snapshot: ParametersSnapshot, options?: {
527
+ clearHistory?: boolean;
528
+ }): void;
529
+ undo(): boolean;
530
+ redo(): boolean;
531
+ /** Stops listening to the history and keyframes adapter. */
532
+ destroy(): void;
533
+ }
534
+ declare function createParametersController(options: ParametersControllerOptions): ParametersController;
535
+
536
+ interface ParameterCommandOptions {
537
+ /** Id prefix (default `parameters.`); use one per panel when several are registered. */
538
+ prefix?: string;
539
+ /** Palette group (default `Parameters`, or the schema's title). */
540
+ group?: string;
541
+ /** Command scope. Omit for global commands. */
542
+ scope?: string;
543
+ }
544
+ /** A field as listed for agents: its JSON Schema plus current value and visibility. */
545
+ interface ParameterListing {
546
+ id: string;
547
+ label: string;
548
+ type: ParameterField['type'];
549
+ description?: string;
550
+ value: ParameterValue;
551
+ default: ParameterValue;
552
+ visible: boolean;
553
+ keyframe?: 'none' | 'animated' | 'keyed';
554
+ schema: Record<string, unknown>;
555
+ }
556
+ /**
557
+ * Palette and agent commands for a parameters panel: list, set (validated, one undo step),
558
+ * reset, randomize, presets and keyframe toggles. Register them in a `CommandRegistry` and
559
+ * agents get them through `createCommandToolProvider`. Failures throw sentences, which the
560
+ * registry returns as `{ ok: false, code: 'failed', message }`.
561
+ */
562
+ declare function createParameterCommands(controller: ParametersController, options?: ParameterCommandOptions): CommandSpec[];
563
+
564
+ /** A shader uniform type that can be a control (Flair's `@control` uniforms). */
565
+ type ShaderControlType = 'float' | 'int' | 'bool' | 'vec2' | 'vec3' | 'vec4' | 'sampler2D';
566
+ /** A shader control value: a number, a boolean, vector components (colours are 0–1) or an image URL. */
567
+ type ShaderControlValue = number | boolean | number[] | string;
568
+ /**
569
+ * The shape of a parsed shader control, e.g. Flair's `ControlDef`
570
+ * (`uniform vec3 uTint; // @control color default=#77C16A`).
571
+ */
572
+ interface ShaderControlLike {
573
+ name: string;
574
+ type: ShaderControlType;
575
+ label?: string;
576
+ /** A `vec3` / `vec4` shown as a colour picker. */
577
+ color?: boolean;
578
+ min?: number;
579
+ max?: number;
580
+ step?: number;
581
+ default: ShaderControlValue;
582
+ description?: string;
583
+ }
584
+ /** One shader control as a parameter field (colour vectors become hex `color` fields). */
585
+ declare function parameterFieldFromShaderControl(control: ShaderControlLike): ParameterField;
586
+ /** A parameter schema for a shader's controls, in source order. */
587
+ declare function parameterSchemaFromShaderControls(controls: readonly ShaderControlLike[], options?: {
588
+ title?: string;
589
+ }): ParameterSchema;
590
+ /** A parameter value as the shader takes it: hex colours become 0–1 RGB(A) arrays. */
591
+ declare function shaderControlValue(control: ShaderControlLike, value: ParameterValue): ShaderControlValue;
592
+ /** A shader control value as a parameter value: colour arrays become hex. */
593
+ declare function parameterValueFromShaderControl(control: ShaderControlLike, value: ShaderControlValue): ParameterValue;
594
+
595
+ export { type ApplyPresetOptions, type BooleanParameterField, type ChoiceParameterField, type ColorParameterField, type ImageParameterField, type NumberParameterField, PARAMETER_KEY_TOLERANCE, type ParameterActionResult, type ParameterChoiceOption, type ParameterCoercion, type ParameterCommandOptions, type ParameterCondition, type ParameterConditionTest, type ParameterEasing, type ParameterError, type ParameterField, type ParameterFieldType, type ParameterGroup, type ParameterImageOption, type ParameterKeyState, type ParameterKeyframe, type ParameterKeyframeStore, type ParameterKeyframes, type ParameterListing, type ParameterPreset, type ParameterSchema, ParameterSchemaError, type ParameterSchemaItem, type ParameterSetResult, type ParameterSetValuesResult, type ParameterTrack, type ParameterValue, type ParameterValues, ParametersController, type ParametersControllerOptions, type ParametersSnapshot, type ParametersState, type RandomizeParametersOptions, type SetParameterOptions, type ShaderControlLike, type ShaderControlType, type ShaderControlValue, type TextParameterField, type VectorParameterField, checkParameterSchema, choiceOptionLabel, clampParameterNumber, cloneValue, coerceParameterValue, createParameterCommands, createParameterKeyframeStore, createParametersController, evaluateParameterCondition, findParameterKeyframe, formatParameterNumber, formatParameterValue, getChoiceOptions, getParameterDefaults, getParameterFields, getParameterGroups, getParameterKeyState, getParameterVisibility, hexToRgba01, humanizeParameterId, isParameterGroup, isSliderField, normalizeHexColor, parameterDecimals, parameterFieldFromShaderControl, parameterFieldToJsonSchema, parameterLabel, parameterSchemaFromShaderControls, parameterSchemaToJsonSchema, parameterStep, parameterValueFromShaderControl, parameterValuesEqual, parseParameterNumberInput, rgba01ToHex, seededRandom, shaderControlValue, validateParameterValue, validateParameterValues, vectorComponentField, vectorSize, withParameterKeyframe, withoutParameterKeyframe };