@pixerate/editor 0.147.0 → 0.148.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.
@@ -8,6 +8,7 @@
8
8
  */
9
9
  import type { JsonSchema } from '../tools/schema.cjs';
10
10
  import type { FlairSvgAnimation } from '../animation-editor/flair.cjs';
11
+ import type { EffectAuthoringSession, EffectAuthoringSource } from './authoring.cjs';
11
12
  /** How an effect is drawn: a pixel shader, an animated vector picture, or motion applied to someone else's vector art. */
12
13
  export type EffectKind = 'shader' | 'vector' | 'motion';
13
14
  /**
@@ -166,8 +167,10 @@ export interface EffectProviderCapabilities {
166
167
  supportsVector: boolean;
167
168
  /** Largest width or height a renderer accepts (px). */
168
169
  maxSize?: number;
170
+ /** Implements `openAuthoring`: effects can be edited, not only used. */
171
+ supportsAuthoring?: boolean;
169
172
  }
170
- type MaybePromise<T> = T | Promise<T>;
173
+ export type MaybePromise<T> = T | Promise<T>;
171
174
  /**
172
175
  * A source of effects. Implementations live outside this library (for example Flair's
173
176
  * `flairEffects()`); `createFakeEffectProvider` is a small reference implementation.
@@ -194,5 +197,9 @@ export interface EffectProvider {
194
197
  * effect cannot use with `EffectUnsupportedError`.
195
198
  */
196
199
  applyVectorEffect?(id: string, target: EffectVectorTarget, values?: EffectValues): MaybePromise<EffectVectorMotion>;
200
+ /**
201
+ * Opens an effect for editing. Present when `capabilities.supportsAuthoring`. Unknown ids throw
202
+ * `UnknownEffectError`; an effect the provider cannot edit throws `EffectUnsupportedError`.
203
+ */
204
+ openAuthoring?(from: EffectAuthoringSource): MaybePromise<EffectAuthoringSession>;
197
205
  }
198
- export {};
@@ -8,6 +8,7 @@
8
8
  */
9
9
  import type { JsonSchema } from '../tools/schema.js';
10
10
  import type { FlairSvgAnimation } from '../animation-editor/flair.js';
11
+ import type { EffectAuthoringSession, EffectAuthoringSource } from './authoring.js';
11
12
  /** How an effect is drawn: a pixel shader, an animated vector picture, or motion applied to someone else's vector art. */
12
13
  export type EffectKind = 'shader' | 'vector' | 'motion';
13
14
  /**
@@ -166,8 +167,10 @@ export interface EffectProviderCapabilities {
166
167
  supportsVector: boolean;
167
168
  /** Largest width or height a renderer accepts (px). */
168
169
  maxSize?: number;
170
+ /** Implements `openAuthoring`: effects can be edited, not only used. */
171
+ supportsAuthoring?: boolean;
169
172
  }
170
- type MaybePromise<T> = T | Promise<T>;
173
+ export type MaybePromise<T> = T | Promise<T>;
171
174
  /**
172
175
  * A source of effects. Implementations live outside this library (for example Flair's
173
176
  * `flairEffects()`); `createFakeEffectProvider` is a small reference implementation.
@@ -194,5 +197,9 @@ export interface EffectProvider {
194
197
  * effect cannot use with `EffectUnsupportedError`.
195
198
  */
196
199
  applyVectorEffect?(id: string, target: EffectVectorTarget, values?: EffectValues): MaybePromise<EffectVectorMotion>;
200
+ /**
201
+ * Opens an effect for editing. Present when `capabilities.supportsAuthoring`. Unknown ids throw
202
+ * `UnknownEffectError`; an effect the provider cannot edit throws `EffectUnsupportedError`.
203
+ */
204
+ openAuthoring?(from: EffectAuthoringSource): MaybePromise<EffectAuthoringSession>;
197
205
  }
198
- export {};
@@ -23,6 +23,14 @@ export declare const effectFieldValue: (field: ParameterField, value: unknown) =
23
23
  * differ, for a transition's two sides).
24
24
  */
25
25
  export declare function effectSamplePicture(width: number, height: number, variant?: number): EffectPixels;
26
+ /**
27
+ * Sample pictures for an effect's image inputs (`effectSamplePicture`; a transition's `to` gets
28
+ * the second variant), so previews of filters and transitions have something to change.
29
+ */
30
+ export declare function effectSampleInputs(description: Pick<EffectDescription, 'inputs'>, size: {
31
+ width: number;
32
+ height: number;
33
+ }): Record<string, EffectPixels>;
26
34
  /**
27
35
  * A small preview of an effect from the provider's own renderer: filters run on a sample picture,
28
36
  * transitions go half way between two, generators and overlays draw at `time` (default half
@@ -23,6 +23,14 @@ export declare const effectFieldValue: (field: ParameterField, value: unknown) =
23
23
  * differ, for a transition's two sides).
24
24
  */
25
25
  export declare function effectSamplePicture(width: number, height: number, variant?: number): EffectPixels;
26
+ /**
27
+ * Sample pictures for an effect's image inputs (`effectSamplePicture`; a transition's `to` gets
28
+ * the second variant), so previews of filters and transitions have something to change.
29
+ */
30
+ export declare function effectSampleInputs(description: Pick<EffectDescription, 'inputs'>, size: {
31
+ width: number;
32
+ height: number;
33
+ }): Record<string, EffectPixels>;
26
34
  /**
27
35
  * A small preview of an effect from the provider's own renderer: filters run on a sample picture,
28
36
  * transitions go half way between two, generators and overlays draw at `time` (default half
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pixerate/editor",
3
- "version": "0.147.0",
3
+ "version": "0.148.0",
4
4
  "description": "UI-agnostic rich text and media editing core library",
5
5
  "author": "Pixerate",
6
6
  "license": "MIT",
package/skills/README.md CHANGED
@@ -20,6 +20,7 @@ that uses the tools can load the matching skill.
20
20
  | [`pixerate-video-editor`](pixerate-video-editor/SKILL.md) | Non-linear video editing: tracks, clips, transitions, export. |
21
21
  | [`pixerate-generation`](pixerate-generation/SKILL.md) | Planning, estimating and running paid media generation. |
22
22
  | [`pixerate-parameters`](pixerate-parameters/SKILL.md) | Effect parameters, presets and keyframes. |
23
+ | [`pixerate-effect-authoring`](pixerate-effect-authoring/SKILL.md) | Authoring shaders and procedural effects: inspecting parameters and source code, setting values and presets, keyframing animation tracks, playback timing, and previewing. |
23
24
  | [`pixerate-color`](pixerate-color/SKILL.md) | Colour inspection, WCAG accessibility and contrast optimization, CVD simulation, palette audits, harmonies, and OKLab/OKLCH blends. |
24
25
 
25
26
  ## Using them
@@ -0,0 +1,80 @@
1
+ ---
2
+ name: pixerate-effect-authoring
3
+ description: How to author and edit procedural effects, shaders, and filters through the effect authoring agent tools - inspecting effect schemas and current control values, reading and compiling shader source code, adjusting parameters with all-or-nothing validation, applying and saving presets, keyframing animation tracks with easing, configuring timeline playback duration and looping, scrubbing the playhead, and capturing visual previews. Use when asked to author, modify, or debug shaders or procedural effects, animate effect parameters over time, or when effect_authoring tools are available.
4
+ ---
5
+
6
+ # Pixerate effect authoring
7
+
8
+ An effect authoring session hosts an active effect definition (shader or procedural filter) and
9
+ exposes its controls, animated tracks, compile status, playback timing, and visual preview.
10
+ Control values can be static or animated via keyframes along a timeline. Each edit creates a
11
+ single undoable history step.
12
+
13
+ When an effect session is opened, tools allow inspecting the control schema, updating control
14
+ values, modifying shader code (for code-backed effects), saving and loading presets, managing
15
+ keyframe animation tracks with interpolation easing, seeking the playhead, and capturing rendered
16
+ preview frames.
17
+
18
+ For general error reporting and undo conventions, see `pixerate-agent-tools`.
19
+
20
+ ## Working method
21
+
22
+ 1. **Inspect first.** Run `effect_authoring_describe` to inspect the effect name, kind, source
23
+ language (`glsl`, `svg`, or null when the effect has no source to edit), control parameter schemas, current
24
+ values, existing tracks, and compile issues.
25
+ 2. **Read or update source code.** If `sourceLanguage` is non-null, use `effect_authoring_get_source`
26
+ to read the shader or script code. Use `effect_authoring_set_source` to recompile with new code
27
+ and immediately inspect any reported syntax or compilation issues with line numbers.
28
+ 3. **Adjust parameters.** Use `effect_authoring_set_values` to set one or more controls at once.
29
+ This runs all-or-nothing validation: any invalid control name or out-of-range value cancels the
30
+ change and returns a helpful error.
31
+ 4. **Animate with keyframes.** For controls that change over time, set keyframes using
32
+ `effect_authoring_set_keyframe` specifying `control`, `time` (ms), optional `value`, and `easing` (a preset name such as `ease-in-out`, or a `cubic-bezier`, `spring` or `elastic` curve object).
33
+ Use `effect_authoring_seek` to move the playhead across the timeline and check resolved values.
34
+ Use `effect_authoring_remove_keyframe` to delete specific points, or `effect_authoring_clear_track`
35
+ to revert a parameter to static behavior (both refuse a control that has no keyframes, and say which controls are animated).
36
+ 5. **Tune timing.** Use `effect_authoring_set_timing` to configure total `duration` in ms and
37
+ whether playback loops.
38
+ 6. **Save presets.** When an interesting look is achieved, save it with `effect_authoring_save_preset`
39
+ or restore known presets with `effect_authoring_apply_preset`.
40
+ 7. **Verify visually.** When `effect_authoring_view` is available, capture rendered preview frames
41
+ at specific times to visually confirm effect appearance.
42
+
43
+ ## Best practices
44
+
45
+ - **Batch parameter changes.** Set all related control values in a single `effect_authoring_set_values`
46
+ call so they apply cleanly in a single undo step.
47
+ - **Check compile issues.** When editing source code via `effect_authoring_set_source`, always verify
48
+ the returned `issues` array. Fix errors before attempting to preview or set controls.
49
+ - **Keyframe animation tracks.** Controls with active keyframes calculate their values dynamically
50
+ based on the playhead time. Setting a value on an animated control at the current playhead updates
51
+ or adds a keyframe at that time.
52
+ - **Safe exploration.** Use `effect_authoring_save_preset` before major shader or parameter
53
+ refactoring, and use `effect_authoring_undo` / `effect_authoring_redo` to step through changes.
54
+
55
+ ## Tools
56
+
57
+ | Tool | Description and usage |
58
+ | --- | --- |
59
+ | `effect_authoring_describe` | Reads the currently open effect session: name, kind, source language, controls schema and current values, presets, animated tracks with keyframe counts, duration, loop, and compile issues. |
60
+ | `effect_authoring_get_source` | Retrieves shader or script source code and language for code-backed effects. Refused if `sourceLanguage` is null. |
61
+ | `effect_authoring_set_source` | Recompiles the effect with new shader or script source code. Returns compiler issues with line numbers and messages. Available only when supported by the session. |
62
+ | `effect_authoring_set_values` | Sets one or more control values at the current playhead time as a single undo step. Rejects all changes if any control name or value is invalid. |
63
+ | `effect_authoring_reset_values` | Resets specified controls (or all controls if omitted) back to their schema defaults in a single undo step. |
64
+ | `effect_authoring_apply_preset` | Applies a built-in or user-saved preset by name, updating current control values in one undo step. |
65
+ | `effect_authoring_save_preset` | Saves the current control values as a user preset under the given name. Replaces an existing preset with the same name. |
66
+ | `effect_authoring_set_keyframe` | Adds or replaces a keyframe on a control track at a specific time in milliseconds, with optional value and easing curve. |
67
+ | `effect_authoring_remove_keyframe` | Deletes a keyframe at the exact millisecond timestamp from a control animation track. |
68
+ | `effect_authoring_clear_track` | Removes all keyframes from an animated control track. The control's value at the playhead becomes its static value. |
69
+ | `effect_authoring_set_timing` | Configures the effect's timeline duration in milliseconds and whether playback loops. |
70
+ | `effect_authoring_seek` | Moves the preview playhead to a specific timeline position in milliseconds (clamped to 0..duration) and returns values at that time. |
71
+ | `effect_authoring_undo` | Undoes the most recent edit in the authoring session. |
72
+ | `effect_authoring_redo` | Redoes the most recently undone edit in the authoring session. |
73
+ | `effect_authoring_view` | Captures a preview image of the effect at the current playhead or a specified timestamp. Available when preview capture is supported. |
74
+
75
+ ## Pitfalls
76
+
77
+ - Calling authoring tools when no authoring session is open returns an error explaining that a session must be opened first.
78
+ - Animated controls calculate their values dynamically from keyframes; clearing a track reverts the parameter to static behavior.
79
+ - Compiling invalid shader code produces issues in `effect_authoring_set_source`; inspect the line numbers and messages to correct syntax.
80
+ - Control values must match their schema types and bounds; colours must be `#rrggbb` (or `#rrggbbaa`), and numbers must fall within `[min, max]`.