@pixerate/editor 0.123.0 → 0.124.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 (116) hide show
  1. package/dist/agent/index.cjs +2 -2
  2. package/dist/agent/index.cjs.map +1 -1
  3. package/dist/agent/index.js +3 -3
  4. package/dist/animation/index.d.cts +2 -1
  5. package/dist/animation/index.d.ts +2 -1
  6. package/dist/animation-editor/index.cjs.map +1 -1
  7. package/dist/animation-editor/index.d.cts +11 -733
  8. package/dist/animation-editor/index.d.ts +11 -733
  9. package/dist/animation-editor/index.js.map +1 -1
  10. package/dist/{bezier-C-W9LFyD.d.cts → bezier-CBzKKDjl.d.cts} +2 -66
  11. package/dist/{bezier-DQZE5dxA.d.ts → bezier-CWv6LQal.d.ts} +2 -66
  12. package/dist/{brushstrokeRender-M4S65DHT.cjs → brushstrokeRender-EELTV7U4.cjs} +8 -8
  13. package/dist/{brushstrokeRender-M4S65DHT.cjs.map → brushstrokeRender-EELTV7U4.cjs.map} +1 -1
  14. package/dist/{brushstrokeRender-CDDRSV2W.js → brushstrokeRender-LRV7GXGD.js} +3 -3
  15. package/dist/canvas/index.cjs +6 -6
  16. package/dist/canvas/index.d.cts +10 -6
  17. package/dist/canvas/index.d.ts +10 -6
  18. package/dist/canvas/index.js +1 -1
  19. package/dist/{chunk-TVXFHE4T.js → chunk-64PYNEHJ.js} +45 -12
  20. package/dist/chunk-64PYNEHJ.js.map +1 -0
  21. package/dist/{chunk-2IW3BWRT.cjs → chunk-7LQO6OHH.cjs} +2 -2
  22. package/dist/{chunk-2IW3BWRT.cjs.map → chunk-7LQO6OHH.cjs.map} +1 -1
  23. package/dist/chunk-IOXKXQNW.cjs +178 -0
  24. package/dist/chunk-IOXKXQNW.cjs.map +1 -0
  25. package/dist/{chunk-SMJGE7HM.cjs → chunk-IWSMDQE5.cjs} +523 -39
  26. package/dist/chunk-IWSMDQE5.cjs.map +1 -0
  27. package/dist/{chunk-KMBC4HNV.js → chunk-J67OLQUQ.js} +2 -2
  28. package/dist/{chunk-6CJRDJCU.cjs → chunk-PEHYWUVV.cjs} +176 -111
  29. package/dist/chunk-PEHYWUVV.cjs.map +1 -0
  30. package/dist/chunk-TGKT5QAB.js +178 -0
  31. package/dist/chunk-TGKT5QAB.js.map +1 -0
  32. package/dist/chunk-TK53AB4Q.cjs +215 -0
  33. package/dist/chunk-TK53AB4Q.cjs.map +1 -0
  34. package/dist/chunk-VFAKN46Z.js +215 -0
  35. package/dist/chunk-VFAKN46Z.js.map +1 -0
  36. package/dist/{chunk-6ZBR4J62.js → chunk-WATAQ2Z2.js} +79 -14
  37. package/dist/chunk-WATAQ2Z2.js.map +1 -0
  38. package/dist/{chunk-IPFRWILU.js → chunk-YVVSTD3B.js} +499 -15
  39. package/dist/chunk-YVVSTD3B.js.map +1 -0
  40. package/dist/{chunk-RLRUAPBJ.cjs → chunk-Z6OUCS2K.cjs} +47 -14
  41. package/dist/chunk-Z6OUCS2K.cjs.map +1 -0
  42. package/dist/effects/index.cjs +588 -0
  43. package/dist/effects/index.cjs.map +1 -0
  44. package/dist/effects/index.d.cts +131 -0
  45. package/dist/effects/index.d.ts +131 -0
  46. package/dist/effects/index.js +588 -0
  47. package/dist/effects/index.js.map +1 -0
  48. package/dist/evaluate-2S3vSPLy.d.cts +55 -0
  49. package/dist/evaluate-CfmT6xA3.d.ts +55 -0
  50. package/dist/{export-DfjzHAJI.d.ts → export-8RnlngAv.d.ts} +534 -128
  51. package/dist/{export-Dv0-ZVrV.d.ts → export-BzSRXyH6.d.cts} +390 -5
  52. package/dist/{export-Dv0-ZVrV.d.cts → export-DM3h7QEI.d.ts} +390 -5
  53. package/dist/{export-lU5qSpHE.d.cts → export-TqXMOlDt.d.cts} +534 -128
  54. package/dist/flair-CxB3fOcU.d.ts +739 -0
  55. package/dist/flair-D7BxyBwL.d.cts +739 -0
  56. package/dist/gradient-KDfCvhuj.d.cts +66 -0
  57. package/dist/gradient-KDfCvhuj.d.ts +66 -0
  58. package/dist/helpers-777mC6dc.d.cts +253 -0
  59. package/dist/helpers-DX2_7L5t.d.ts +253 -0
  60. package/dist/image-editor/index.cjs +1307 -805
  61. package/dist/image-editor/index.cjs.map +1 -1
  62. package/dist/image-editor/index.d.cts +39 -182
  63. package/dist/image-editor/index.d.ts +39 -182
  64. package/dist/image-editor/index.js +508 -6
  65. package/dist/image-editor/index.js.map +1 -1
  66. package/dist/{opentype-p8Xxf-Wh.d.ts → opentype-14PDI5D2.d.ts} +1 -1
  67. package/dist/{opentype-BV7wWatY.d.cts → opentype-D80AVmMu.d.cts} +1 -1
  68. package/dist/paint/index.cjs +2 -2
  69. package/dist/paint/index.d.cts +32 -10
  70. package/dist/paint/index.d.ts +32 -10
  71. package/dist/paint/index.js +1 -1
  72. package/dist/paint-editor/index.cjs +10 -8
  73. package/dist/paint-editor/index.cjs.map +1 -1
  74. package/dist/paint-editor/index.d.cts +11 -5
  75. package/dist/paint-editor/index.d.ts +11 -5
  76. package/dist/paint-editor/index.js +4 -2
  77. package/dist/paint-editor/index.js.map +1 -1
  78. package/dist/parameters/index.d.cts +4 -184
  79. package/dist/parameters/index.d.ts +4 -184
  80. package/dist/{pathfinder-IxcyhO00.d.cts → pathfinder-C0UoFypx.d.cts} +1 -1
  81. package/dist/{pathfinder-StVChJOT.d.ts → pathfinder-DjISxkUv.d.ts} +1 -1
  82. package/dist/{player-DrcP2xqj.d.cts → player-CBtEoU2x.d.cts} +2 -54
  83. package/dist/{player-DV4Jujdq.d.ts → player-cGLrngL_.d.ts} +2 -54
  84. package/dist/{svg-BtND4TJu.d.cts → svg-BDrjRnL1.d.cts} +3 -2
  85. package/dist/{svg-BfVXG7hL.d.ts → svg-C-vZ3q50.d.ts} +3 -2
  86. package/dist/tools/index.cjs +2 -2
  87. package/dist/tools/index.cjs.map +1 -1
  88. package/dist/tools/index.js +3 -3
  89. package/dist/tools-C7JtLYzo.d.ts +126 -0
  90. package/dist/tools-DHKGHiSK.d.cts +126 -0
  91. package/dist/{types-fuXEme9j.d.ts → types-BcX7sCsn.d.ts} +2 -2
  92. package/dist/{types-DJF3Ghn5.d.cts → types-CznabG7m.d.cts} +2 -2
  93. package/dist/types-D3-J3TFf.d.ts +185 -0
  94. package/dist/types-DMcf_z4J.d.cts +185 -0
  95. package/dist/vector/index.d.cts +10 -10
  96. package/dist/vector/index.d.ts +10 -10
  97. package/dist/video-editor/index.cjs +749 -277
  98. package/dist/video-editor/index.cjs.map +1 -1
  99. package/dist/video-editor/index.d.cts +265 -138
  100. package/dist/video-editor/index.d.ts +265 -138
  101. package/dist/video-editor/index.js +490 -18
  102. package/dist/video-editor/index.js.map +1 -1
  103. package/dist/{warp-BjmAgQwq.d.cts → warp-CH9MM435.d.cts} +1 -1
  104. package/dist/{warp-Ca5fedzS.d.ts → warp-k_PdtXOG.d.ts} +1 -1
  105. package/package.json +6 -1
  106. package/skills/pixerate-image-editor/SKILL.md +7 -0
  107. package/skills/pixerate-image-editor/references/provider-effects.md +35 -0
  108. package/skills/pixerate-video-editor/SKILL.md +39 -1
  109. package/dist/chunk-6CJRDJCU.cjs.map +0 -1
  110. package/dist/chunk-6ZBR4J62.js.map +0 -1
  111. package/dist/chunk-IPFRWILU.js.map +0 -1
  112. package/dist/chunk-RLRUAPBJ.cjs.map +0 -1
  113. package/dist/chunk-SMJGE7HM.cjs.map +0 -1
  114. package/dist/chunk-TVXFHE4T.js.map +0 -1
  115. /package/dist/{brushstrokeRender-CDDRSV2W.js.map → brushstrokeRender-LRV7GXGD.js.map} +0 -0
  116. /package/dist/{chunk-KMBC4HNV.js.map → chunk-J67OLQUQ.js.map} +0 -0
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Canvas gradient models, parsing, presets, and SVG defs generation.
3
+ * Supports linear and radial gradients for shape fills, strokes, and freehand drawing.
4
+ */
5
+ interface GradientStop {
6
+ offset: number;
7
+ color: string;
8
+ opacity?: number;
9
+ }
10
+ interface CanvasLinearGradient {
11
+ type: 'linear';
12
+ angle?: number;
13
+ stops: GradientStop[];
14
+ }
15
+ interface CanvasRadialGradient {
16
+ type: 'radial';
17
+ cx?: number;
18
+ cy?: number;
19
+ r?: number;
20
+ stops: GradientStop[];
21
+ }
22
+ type CanvasGradientDef = CanvasLinearGradient | CanvasRadialGradient;
23
+ interface SvgGradientStop {
24
+ offset: string;
25
+ stopColor: string;
26
+ stopOpacity?: number;
27
+ }
28
+ interface SvgGradientDef {
29
+ id: string;
30
+ type: 'linear' | 'radial';
31
+ attrs: Record<string, string | number>;
32
+ stops: SvgGradientStop[];
33
+ }
34
+ declare const PIXERATE_BRAND_GRADIENT: CanvasLinearGradient;
35
+ declare const CANVAS_GRADIENT_PRESETS: Record<string, CanvasLinearGradient>;
36
+ /** Whether an arbitrary value matches a CanvasGradientDef object. */
37
+ declare function isCanvasGradient(value: unknown): value is CanvasGradientDef;
38
+ /**
39
+ * Parses CSS linear-gradient or radial-gradient strings into CanvasGradientDef.
40
+ * Supports forms like:
41
+ * - linear-gradient(90deg, #ff0000 0%, #0000ff 100%)
42
+ * - linear-gradient(to right, red, blue)
43
+ * - radial-gradient(circle, red 0%, blue 100%)
44
+ */
45
+ declare function parseCssGradient(css: string): CanvasGradientDef | null;
46
+ /**
47
+ * Resolves a paint value (which could be a CSS color, preset name, CSS gradient string, or CanvasGradientDef)
48
+ * into either a CanvasGradientDef (if gradient) or null (if solid color or invalid).
49
+ */
50
+ declare function resolveCanvasGradient(value: unknown): CanvasGradientDef | null;
51
+ /**
52
+ * Converts degrees clockwise (CSS angle: 0 = top, 90 = right, 180 = bottom, 270 = left)
53
+ * to SVG linearGradient vector coordinates (x1, y1, x2, y2) normalized [0, 1].
54
+ */
55
+ declare function angleToSvgLinearCoords(angleDeg?: number): {
56
+ x1: number;
57
+ y1: number;
58
+ x2: number;
59
+ y2: number;
60
+ };
61
+ /**
62
+ * Converts a CanvasGradientDef to an SvgGradientDef descriptor ready for rendering `<linearGradient>` / `<radialGradient>`.
63
+ */
64
+ declare function gradientToSvgDef(gradient: CanvasGradientDef, id: string): SvgGradientDef;
65
+
66
+ export { type CanvasGradientDef as C, type GradientStop as G, PIXERATE_BRAND_GRADIENT as P, type SvgGradientDef as S, CANVAS_GRADIENT_PRESETS as a, type CanvasLinearGradient as b, type CanvasRadialGradient as c, type SvgGradientStop as d, angleToSvgLinearCoords as e, gradientToSvgDef as g, isCanvasGradient as i, parseCssGradient as p, resolveCanvasGradient as r };
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Canvas gradient models, parsing, presets, and SVG defs generation.
3
+ * Supports linear and radial gradients for shape fills, strokes, and freehand drawing.
4
+ */
5
+ interface GradientStop {
6
+ offset: number;
7
+ color: string;
8
+ opacity?: number;
9
+ }
10
+ interface CanvasLinearGradient {
11
+ type: 'linear';
12
+ angle?: number;
13
+ stops: GradientStop[];
14
+ }
15
+ interface CanvasRadialGradient {
16
+ type: 'radial';
17
+ cx?: number;
18
+ cy?: number;
19
+ r?: number;
20
+ stops: GradientStop[];
21
+ }
22
+ type CanvasGradientDef = CanvasLinearGradient | CanvasRadialGradient;
23
+ interface SvgGradientStop {
24
+ offset: string;
25
+ stopColor: string;
26
+ stopOpacity?: number;
27
+ }
28
+ interface SvgGradientDef {
29
+ id: string;
30
+ type: 'linear' | 'radial';
31
+ attrs: Record<string, string | number>;
32
+ stops: SvgGradientStop[];
33
+ }
34
+ declare const PIXERATE_BRAND_GRADIENT: CanvasLinearGradient;
35
+ declare const CANVAS_GRADIENT_PRESETS: Record<string, CanvasLinearGradient>;
36
+ /** Whether an arbitrary value matches a CanvasGradientDef object. */
37
+ declare function isCanvasGradient(value: unknown): value is CanvasGradientDef;
38
+ /**
39
+ * Parses CSS linear-gradient or radial-gradient strings into CanvasGradientDef.
40
+ * Supports forms like:
41
+ * - linear-gradient(90deg, #ff0000 0%, #0000ff 100%)
42
+ * - linear-gradient(to right, red, blue)
43
+ * - radial-gradient(circle, red 0%, blue 100%)
44
+ */
45
+ declare function parseCssGradient(css: string): CanvasGradientDef | null;
46
+ /**
47
+ * Resolves a paint value (which could be a CSS color, preset name, CSS gradient string, or CanvasGradientDef)
48
+ * into either a CanvasGradientDef (if gradient) or null (if solid color or invalid).
49
+ */
50
+ declare function resolveCanvasGradient(value: unknown): CanvasGradientDef | null;
51
+ /**
52
+ * Converts degrees clockwise (CSS angle: 0 = top, 90 = right, 180 = bottom, 270 = left)
53
+ * to SVG linearGradient vector coordinates (x1, y1, x2, y2) normalized [0, 1].
54
+ */
55
+ declare function angleToSvgLinearCoords(angleDeg?: number): {
56
+ x1: number;
57
+ y1: number;
58
+ x2: number;
59
+ y2: number;
60
+ };
61
+ /**
62
+ * Converts a CanvasGradientDef to an SvgGradientDef descriptor ready for rendering `<linearGradient>` / `<radialGradient>`.
63
+ */
64
+ declare function gradientToSvgDef(gradient: CanvasGradientDef, id: string): SvgGradientDef;
65
+
66
+ export { type CanvasGradientDef as C, type GradientStop as G, PIXERATE_BRAND_GRADIENT as P, type SvgGradientDef as S, CANVAS_GRADIENT_PRESETS as a, type CanvasLinearGradient as b, type CanvasRadialGradient as c, type SvgGradientStop as d, angleToSvgLinearCoords as e, gradientToSvgDef as g, isCanvasGradient as i, parseCssGradient as p, resolveCanvasGradient as r };
@@ -0,0 +1,253 @@
1
+ import { J as JsonSchema, S as SchemaValidationError } from './schema-Di0CS6Pe.cjs';
2
+ import { F as FlairSvgAnimation } from './flair-D7BxyBwL.cjs';
3
+
4
+ /**
5
+ * The effects contract: how an editor finds, describes and renders effects that live in another
6
+ * package. This library ships no effects of its own here, only the shapes a provider fills in;
7
+ * a host passes a provider to an editor (`setEffectsProvider`) and the editor degrades to its
8
+ * old behaviour without one.
9
+ *
10
+ * Every time is in milliseconds. Pixels are straight-alpha RGBA rows, top to bottom.
11
+ */
12
+
13
+ /** How an effect is drawn: a pixel shader, an animated vector picture, or motion applied to someone else's vector art. */
14
+ type EffectKind = 'shader' | 'vector' | 'motion';
15
+ /**
16
+ * What an effect is for. An effect may have several uses.
17
+ *
18
+ * - `filter`: changes an input picture (`inputs.source`).
19
+ * - `transition`: blends `inputs.from` into `inputs.to`; `progress` runs 0 → 1.
20
+ * - `generator`: draws a picture from nothing (a background, a texture).
21
+ * - `overlay`: draws something meant to sit over other content, usually with transparency.
22
+ * - `title`: draws type or a graphic meant as a title.
23
+ * - `motion`: animates vector art (`applyVectorEffect`).
24
+ * - `interactive`: reacts to pointer, scroll or audio input at run time.
25
+ */
26
+ type EffectUse = 'filter' | 'transition' | 'generator' | 'overlay' | 'title' | 'motion' | 'interactive';
27
+ declare const EFFECT_KINDS: readonly EffectKind[];
28
+ declare const EFFECT_USES: readonly EffectUse[];
29
+ /** One entry of a provider's catalog. */
30
+ interface EffectSummary {
31
+ /** Stable id, saved in documents. Never reused for a different effect. */
32
+ id: string;
33
+ name: string;
34
+ kind: EffectKind;
35
+ /** The provider's own grouping (e.g. `gradient`, `light`, `transition`). */
36
+ category: string;
37
+ uses: readonly EffectUse[];
38
+ description?: string;
39
+ tags?: readonly string[];
40
+ /** True when the effect's output has transparent pixels (it can sit over other content). */
41
+ transparent: boolean;
42
+ /** True when the effect loops; its `duration` is then one cycle. */
43
+ loop: boolean;
44
+ /** Length of one play (ms). Absent for effects that do not change over time. */
45
+ duration?: number;
46
+ }
47
+ interface EffectSearchOptions {
48
+ kind?: EffectKind;
49
+ category?: string;
50
+ use?: EffectUse;
51
+ /** Most results to return. */
52
+ limit?: number;
53
+ }
54
+ /** One control value: a number, a `#rrggbb` colour or other string, a switch, or a vector of numbers. */
55
+ type EffectValue = number | string | boolean | readonly number[];
56
+ type EffectValues = Readonly<Record<string, EffectValue>>;
57
+ /**
58
+ * The controls of an effect as a strict JSON Schema: `type: 'object'`, `additionalProperties:
59
+ * false`, and a `description` on every property (with units and range). `checkEffectProvider`
60
+ * checks this.
61
+ */
62
+ type EffectControlSchema = JsonSchema & {
63
+ type: 'object';
64
+ properties: {
65
+ readonly [control: string]: JsonSchema;
66
+ };
67
+ additionalProperties: false;
68
+ };
69
+ interface EffectPreset {
70
+ name: string;
71
+ /** Values to apply over the defaults. */
72
+ values: EffectValues;
73
+ }
74
+ /**
75
+ * A named input the effect reads. Filters read `source`, transitions `from` and `to`; a mask is
76
+ * passed separately (`EffectRenderRequest.mask`), not as an input.
77
+ */
78
+ interface EffectInputSpec {
79
+ name: string;
80
+ kind: 'image' | 'audio';
81
+ description: string;
82
+ required: boolean;
83
+ }
84
+ /** Everything an editor needs to show an effect's controls and render it. */
85
+ interface EffectDescription extends EffectSummary {
86
+ controls: EffectControlSchema;
87
+ /** A value for every control. */
88
+ defaults: EffectValues;
89
+ presets: readonly EffectPreset[];
90
+ inputs: readonly EffectInputSpec[];
91
+ }
92
+ /**
93
+ * Pixels in and out of a renderer, shaped like `ImageData`.
94
+ *
95
+ * `data` is 8-bit sRGB with straight alpha and is always present. `float`, when present, is the
96
+ * same picture as 32-bit floats in **linear light** (sRGB primaries), straight alpha, where colour
97
+ * may exceed 1. Renderers created with `depth` 16 or 32 return `float` when the provider
98
+ * `supportsFloat`; `data` is then its clamped sRGB encoding.
99
+ */
100
+ interface EffectPixels {
101
+ width: number;
102
+ height: number;
103
+ data: Uint8ClampedArray;
104
+ float?: Float32Array;
105
+ }
106
+ /**
107
+ * An input picture. Always accepted as `EffectPixels`; a provider whose capabilities include
108
+ * `supportsHostImages` also takes the host's own image objects, which saves a read back.
109
+ */
110
+ type EffectImageSource = EffectPixels | ImageBitmap | OffscreenCanvas | VideoFrame;
111
+ interface EffectRendererOptions {
112
+ /** Output size in pixels. */
113
+ width: number;
114
+ height: number;
115
+ /** Bits per channel of the target (default 8). 16 and 32 ask for `float` output. */
116
+ depth?: 8 | 16 | 32;
117
+ }
118
+ interface EffectRenderRequest {
119
+ /** Effect time (ms), from the start of the effect. */
120
+ time: number;
121
+ /** Control values; missing controls take their defaults. Invalid values reject with `EffectControlError`. */
122
+ values?: EffectValues;
123
+ /** Pictures for the effect's named inputs (see `EffectDescription.inputs`). */
124
+ inputs?: Readonly<Record<string, EffectImageSource>>;
125
+ /** Coverage (alpha channel, 0 = untouched) limiting where the effect applies. Only with `supportsMask`. */
126
+ mask?: EffectImageSource;
127
+ /** Transitions: how far from `from` to `to`, 0–1. Defaults to `time / duration`. */
128
+ progress?: number;
129
+ }
130
+ /** A live renderer for one effect at one size. Not safe for concurrent `render` calls. */
131
+ interface EffectRenderer {
132
+ readonly effectId: string;
133
+ readonly width: number;
134
+ readonly height: number;
135
+ readonly depth: 8 | 16 | 32;
136
+ render(request: EffectRenderRequest): Promise<EffectPixels>;
137
+ /** Frees GPU or worker resources. Rendering afterwards rejects. */
138
+ dispose(): void;
139
+ }
140
+ /** One change of an animated SVG (the shape of Flair's `SvgAnimation`). */
141
+ type EffectSvgAnimation = FlairSvgAnimation;
142
+ /** An animated SVG: markup plus changes to its elements (the shape of Flair's `SvgMotion`). */
143
+ interface EffectVectorMotion {
144
+ svg: string;
145
+ animate?: readonly EffectSvgAnimation[];
146
+ /** Length of one play (ms). */
147
+ duration: number;
148
+ loop: boolean;
149
+ /** Ms held on the last frame before looping. */
150
+ hold?: number;
151
+ }
152
+ /** What a vector or motion effect is applied to: SVG markup, optionally with the ids of the elements to animate (default: all). */
153
+ type EffectVectorTarget = string | {
154
+ svg: string;
155
+ nodeIds?: readonly string[];
156
+ };
157
+ /** What a provider can do, so editors can degrade cleanly. */
158
+ interface EffectProviderCapabilities {
159
+ /** Renders off the main thread. */
160
+ supportsWorker: boolean;
161
+ /** Returns `float` pixels for depth 16 and 32 renderers. */
162
+ supportsFloat: boolean;
163
+ /** Honours `EffectRenderRequest.mask`; otherwise the editor masks the result itself. */
164
+ supportsMask: boolean;
165
+ /** Takes `ImageBitmap`, `OffscreenCanvas` or `VideoFrame` inputs, not only `EffectPixels`. */
166
+ supportsHostImages: boolean;
167
+ /** Implements `applyVectorEffect`. */
168
+ supportsVector: boolean;
169
+ /** Largest width or height a renderer accepts (px). */
170
+ maxSize?: number;
171
+ }
172
+ type MaybePromise<T> = T | Promise<T>;
173
+ /**
174
+ * A source of effects. Implementations live outside this library (for example Flair's
175
+ * `flairEffects()`); `createFakeEffectProvider` is a small reference implementation.
176
+ *
177
+ * Unknown ids reject or throw `UnknownEffectError`, invalid values `EffectControlError`, and an
178
+ * operation the provider cannot do `EffectUnsupportedError`.
179
+ */
180
+ interface EffectProvider {
181
+ /** Stable id of the provider, saved next to effect ids (e.g. `flair`). */
182
+ readonly id: string;
183
+ readonly name: string;
184
+ readonly version?: string;
185
+ readonly capabilities: EffectProviderCapabilities;
186
+ list(options?: EffectSearchOptions): MaybePromise<readonly EffectSummary[]>;
187
+ /** Effects matching every word of `query` (in name, id, category, tags or description), best first. */
188
+ search(query: string, options?: EffectSearchOptions): MaybePromise<readonly EffectSummary[]>;
189
+ describe(id: string): MaybePromise<EffectDescription>;
190
+ /** A pixel renderer. A `vector` effect may refuse with `EffectUnsupportedError` where it cannot lay out SVG (a Worker). */
191
+ createRenderer(id: string, options: EffectRendererOptions): MaybePromise<EffectRenderer>;
192
+ /**
193
+ * Vector and motion effects as an animated SVG. Present when `capabilities.supportsVector`. A
194
+ * `motion` effect animates the target's elements (`nodeIds`, else each top-level element with an
195
+ * id); a `vector` effect brings its own picture and ignores the target. Refuse a target the
196
+ * effect cannot use with `EffectUnsupportedError`.
197
+ */
198
+ applyVectorEffect?(id: string, target: EffectVectorTarget, values?: EffectValues): MaybePromise<EffectVectorMotion>;
199
+ }
200
+
201
+ /**
202
+ * Helpers for providers and editors: value validation, catalog search, pixel buffers, masking,
203
+ * and a provider slot editors hold.
204
+ */
205
+
206
+ /** Problems with `values` against an effect's control schema (unknown controls, types, ranges). Partial values are fine. */
207
+ declare function effectValueErrors(description: Pick<EffectDescription, 'controls'>, values: unknown): SchemaValidationError[];
208
+ /**
209
+ * `values` over the effect's defaults, validated against its control schema. Throws
210
+ * `EffectControlError` naming every bad control. Providers call this in `render`; editors call
211
+ * it before saving values.
212
+ */
213
+ declare function resolveEffectValues(description: Pick<EffectDescription, 'id' | 'controls' | 'defaults'>, values?: EffectValues): Record<string, EffectValues[string]>;
214
+ /**
215
+ * Filters a catalog and ranks it against `query` (every word must appear in the id, name,
216
+ * category, tags or description; name matches rank first). An empty query keeps catalog order.
217
+ * Providers can implement `list` and `search` with it.
218
+ */
219
+ declare function searchEffectSummaries<T extends EffectSummary>(catalog: readonly T[], query?: string, options?: EffectSearchOptions): T[];
220
+ /** A transparent picture, with float samples when `float` is set. */
221
+ declare function createEffectPixels(width: number, height: number, float?: boolean): EffectPixels;
222
+ /** True for an `EffectPixels` (rather than a host image object). */
223
+ declare function isEffectPixels(source: EffectImageSource | unknown): source is EffectPixels;
224
+ /** sRGB-encoded 0–1 to linear light. */
225
+ declare const srgbToLinear: (v: number) => number;
226
+ /** Linear light to sRGB-encoded (clamped below at 0; may exceed 1). */
227
+ declare const linearToSrgb: (v: number) => number;
228
+ /** Fills `pixels.data` from `pixels.float` (linear float to clamped 8-bit sRGB). */
229
+ declare function encodeEffectFloat(pixels: EffectPixels): EffectPixels;
230
+ /**
231
+ * Blends an effect `result` back over its `source` by `mask` coverage (alpha channel), in place
232
+ * on `result`: where the mask is 0 the source shows, where it is 255 the result. Without a
233
+ * source (generators), the result's alpha is multiplied by coverage. Editors use it when the
234
+ * provider does not `supportsMask`. All three must have the same size.
235
+ */
236
+ declare function applyEffectMask(result: EffectPixels, mask: EffectPixels, source?: EffectPixels): EffectPixels;
237
+ /**
238
+ * Holds an editor's effects provider. Controllers expose it as `effectsProvider`,
239
+ * `setEffectsProvider(provider | null)` and `useEffects(provider)`; listeners hear every change.
240
+ */
241
+ declare class EffectsSlot {
242
+ private current;
243
+ private readonly listeners;
244
+ get provider(): EffectProvider | null;
245
+ set(provider: EffectProvider | null): void;
246
+ /** Sets `provider` and returns a function that clears it again (if it is still the one set). */
247
+ use(provider: EffectProvider): () => void;
248
+ /** The provider, or a `NoEffectsProviderError`. */
249
+ require(): EffectProvider;
250
+ subscribe(listener: (provider: EffectProvider | null) => void): () => void;
251
+ }
252
+
253
+ export { isEffectPixels as A, linearToSrgb as B, resolveEffectValues as C, searchEffectSummaries as D, type EffectProvider as E, srgbToLinear as F, type EffectUse as a, type EffectProviderCapabilities as b, type EffectRenderRequest as c, type EffectValue as d, type EffectDescription as e, type EffectPixels as f, type EffectSummary as g, EFFECT_KINDS as h, EFFECT_USES as i, type EffectControlSchema as j, type EffectImageSource as k, type EffectInputSpec as l, type EffectKind as m, type EffectPreset as n, type EffectRenderer as o, type EffectRendererOptions as p, type EffectSearchOptions as q, type EffectSvgAnimation as r, type EffectValues as s, type EffectVectorMotion as t, type EffectVectorTarget as u, EffectsSlot as v, applyEffectMask as w, createEffectPixels as x, effectValueErrors as y, encodeEffectFloat as z };
@@ -0,0 +1,253 @@
1
+ import { J as JsonSchema, S as SchemaValidationError } from './schema-Di0CS6Pe.js';
2
+ import { F as FlairSvgAnimation } from './flair-CxB3fOcU.js';
3
+
4
+ /**
5
+ * The effects contract: how an editor finds, describes and renders effects that live in another
6
+ * package. This library ships no effects of its own here, only the shapes a provider fills in;
7
+ * a host passes a provider to an editor (`setEffectsProvider`) and the editor degrades to its
8
+ * old behaviour without one.
9
+ *
10
+ * Every time is in milliseconds. Pixels are straight-alpha RGBA rows, top to bottom.
11
+ */
12
+
13
+ /** How an effect is drawn: a pixel shader, an animated vector picture, or motion applied to someone else's vector art. */
14
+ type EffectKind = 'shader' | 'vector' | 'motion';
15
+ /**
16
+ * What an effect is for. An effect may have several uses.
17
+ *
18
+ * - `filter`: changes an input picture (`inputs.source`).
19
+ * - `transition`: blends `inputs.from` into `inputs.to`; `progress` runs 0 → 1.
20
+ * - `generator`: draws a picture from nothing (a background, a texture).
21
+ * - `overlay`: draws something meant to sit over other content, usually with transparency.
22
+ * - `title`: draws type or a graphic meant as a title.
23
+ * - `motion`: animates vector art (`applyVectorEffect`).
24
+ * - `interactive`: reacts to pointer, scroll or audio input at run time.
25
+ */
26
+ type EffectUse = 'filter' | 'transition' | 'generator' | 'overlay' | 'title' | 'motion' | 'interactive';
27
+ declare const EFFECT_KINDS: readonly EffectKind[];
28
+ declare const EFFECT_USES: readonly EffectUse[];
29
+ /** One entry of a provider's catalog. */
30
+ interface EffectSummary {
31
+ /** Stable id, saved in documents. Never reused for a different effect. */
32
+ id: string;
33
+ name: string;
34
+ kind: EffectKind;
35
+ /** The provider's own grouping (e.g. `gradient`, `light`, `transition`). */
36
+ category: string;
37
+ uses: readonly EffectUse[];
38
+ description?: string;
39
+ tags?: readonly string[];
40
+ /** True when the effect's output has transparent pixels (it can sit over other content). */
41
+ transparent: boolean;
42
+ /** True when the effect loops; its `duration` is then one cycle. */
43
+ loop: boolean;
44
+ /** Length of one play (ms). Absent for effects that do not change over time. */
45
+ duration?: number;
46
+ }
47
+ interface EffectSearchOptions {
48
+ kind?: EffectKind;
49
+ category?: string;
50
+ use?: EffectUse;
51
+ /** Most results to return. */
52
+ limit?: number;
53
+ }
54
+ /** One control value: a number, a `#rrggbb` colour or other string, a switch, or a vector of numbers. */
55
+ type EffectValue = number | string | boolean | readonly number[];
56
+ type EffectValues = Readonly<Record<string, EffectValue>>;
57
+ /**
58
+ * The controls of an effect as a strict JSON Schema: `type: 'object'`, `additionalProperties:
59
+ * false`, and a `description` on every property (with units and range). `checkEffectProvider`
60
+ * checks this.
61
+ */
62
+ type EffectControlSchema = JsonSchema & {
63
+ type: 'object';
64
+ properties: {
65
+ readonly [control: string]: JsonSchema;
66
+ };
67
+ additionalProperties: false;
68
+ };
69
+ interface EffectPreset {
70
+ name: string;
71
+ /** Values to apply over the defaults. */
72
+ values: EffectValues;
73
+ }
74
+ /**
75
+ * A named input the effect reads. Filters read `source`, transitions `from` and `to`; a mask is
76
+ * passed separately (`EffectRenderRequest.mask`), not as an input.
77
+ */
78
+ interface EffectInputSpec {
79
+ name: string;
80
+ kind: 'image' | 'audio';
81
+ description: string;
82
+ required: boolean;
83
+ }
84
+ /** Everything an editor needs to show an effect's controls and render it. */
85
+ interface EffectDescription extends EffectSummary {
86
+ controls: EffectControlSchema;
87
+ /** A value for every control. */
88
+ defaults: EffectValues;
89
+ presets: readonly EffectPreset[];
90
+ inputs: readonly EffectInputSpec[];
91
+ }
92
+ /**
93
+ * Pixels in and out of a renderer, shaped like `ImageData`.
94
+ *
95
+ * `data` is 8-bit sRGB with straight alpha and is always present. `float`, when present, is the
96
+ * same picture as 32-bit floats in **linear light** (sRGB primaries), straight alpha, where colour
97
+ * may exceed 1. Renderers created with `depth` 16 or 32 return `float` when the provider
98
+ * `supportsFloat`; `data` is then its clamped sRGB encoding.
99
+ */
100
+ interface EffectPixels {
101
+ width: number;
102
+ height: number;
103
+ data: Uint8ClampedArray;
104
+ float?: Float32Array;
105
+ }
106
+ /**
107
+ * An input picture. Always accepted as `EffectPixels`; a provider whose capabilities include
108
+ * `supportsHostImages` also takes the host's own image objects, which saves a read back.
109
+ */
110
+ type EffectImageSource = EffectPixels | ImageBitmap | OffscreenCanvas | VideoFrame;
111
+ interface EffectRendererOptions {
112
+ /** Output size in pixels. */
113
+ width: number;
114
+ height: number;
115
+ /** Bits per channel of the target (default 8). 16 and 32 ask for `float` output. */
116
+ depth?: 8 | 16 | 32;
117
+ }
118
+ interface EffectRenderRequest {
119
+ /** Effect time (ms), from the start of the effect. */
120
+ time: number;
121
+ /** Control values; missing controls take their defaults. Invalid values reject with `EffectControlError`. */
122
+ values?: EffectValues;
123
+ /** Pictures for the effect's named inputs (see `EffectDescription.inputs`). */
124
+ inputs?: Readonly<Record<string, EffectImageSource>>;
125
+ /** Coverage (alpha channel, 0 = untouched) limiting where the effect applies. Only with `supportsMask`. */
126
+ mask?: EffectImageSource;
127
+ /** Transitions: how far from `from` to `to`, 0–1. Defaults to `time / duration`. */
128
+ progress?: number;
129
+ }
130
+ /** A live renderer for one effect at one size. Not safe for concurrent `render` calls. */
131
+ interface EffectRenderer {
132
+ readonly effectId: string;
133
+ readonly width: number;
134
+ readonly height: number;
135
+ readonly depth: 8 | 16 | 32;
136
+ render(request: EffectRenderRequest): Promise<EffectPixels>;
137
+ /** Frees GPU or worker resources. Rendering afterwards rejects. */
138
+ dispose(): void;
139
+ }
140
+ /** One change of an animated SVG (the shape of Flair's `SvgAnimation`). */
141
+ type EffectSvgAnimation = FlairSvgAnimation;
142
+ /** An animated SVG: markup plus changes to its elements (the shape of Flair's `SvgMotion`). */
143
+ interface EffectVectorMotion {
144
+ svg: string;
145
+ animate?: readonly EffectSvgAnimation[];
146
+ /** Length of one play (ms). */
147
+ duration: number;
148
+ loop: boolean;
149
+ /** Ms held on the last frame before looping. */
150
+ hold?: number;
151
+ }
152
+ /** What a vector or motion effect is applied to: SVG markup, optionally with the ids of the elements to animate (default: all). */
153
+ type EffectVectorTarget = string | {
154
+ svg: string;
155
+ nodeIds?: readonly string[];
156
+ };
157
+ /** What a provider can do, so editors can degrade cleanly. */
158
+ interface EffectProviderCapabilities {
159
+ /** Renders off the main thread. */
160
+ supportsWorker: boolean;
161
+ /** Returns `float` pixels for depth 16 and 32 renderers. */
162
+ supportsFloat: boolean;
163
+ /** Honours `EffectRenderRequest.mask`; otherwise the editor masks the result itself. */
164
+ supportsMask: boolean;
165
+ /** Takes `ImageBitmap`, `OffscreenCanvas` or `VideoFrame` inputs, not only `EffectPixels`. */
166
+ supportsHostImages: boolean;
167
+ /** Implements `applyVectorEffect`. */
168
+ supportsVector: boolean;
169
+ /** Largest width or height a renderer accepts (px). */
170
+ maxSize?: number;
171
+ }
172
+ type MaybePromise<T> = T | Promise<T>;
173
+ /**
174
+ * A source of effects. Implementations live outside this library (for example Flair's
175
+ * `flairEffects()`); `createFakeEffectProvider` is a small reference implementation.
176
+ *
177
+ * Unknown ids reject or throw `UnknownEffectError`, invalid values `EffectControlError`, and an
178
+ * operation the provider cannot do `EffectUnsupportedError`.
179
+ */
180
+ interface EffectProvider {
181
+ /** Stable id of the provider, saved next to effect ids (e.g. `flair`). */
182
+ readonly id: string;
183
+ readonly name: string;
184
+ readonly version?: string;
185
+ readonly capabilities: EffectProviderCapabilities;
186
+ list(options?: EffectSearchOptions): MaybePromise<readonly EffectSummary[]>;
187
+ /** Effects matching every word of `query` (in name, id, category, tags or description), best first. */
188
+ search(query: string, options?: EffectSearchOptions): MaybePromise<readonly EffectSummary[]>;
189
+ describe(id: string): MaybePromise<EffectDescription>;
190
+ /** A pixel renderer. A `vector` effect may refuse with `EffectUnsupportedError` where it cannot lay out SVG (a Worker). */
191
+ createRenderer(id: string, options: EffectRendererOptions): MaybePromise<EffectRenderer>;
192
+ /**
193
+ * Vector and motion effects as an animated SVG. Present when `capabilities.supportsVector`. A
194
+ * `motion` effect animates the target's elements (`nodeIds`, else each top-level element with an
195
+ * id); a `vector` effect brings its own picture and ignores the target. Refuse a target the
196
+ * effect cannot use with `EffectUnsupportedError`.
197
+ */
198
+ applyVectorEffect?(id: string, target: EffectVectorTarget, values?: EffectValues): MaybePromise<EffectVectorMotion>;
199
+ }
200
+
201
+ /**
202
+ * Helpers for providers and editors: value validation, catalog search, pixel buffers, masking,
203
+ * and a provider slot editors hold.
204
+ */
205
+
206
+ /** Problems with `values` against an effect's control schema (unknown controls, types, ranges). Partial values are fine. */
207
+ declare function effectValueErrors(description: Pick<EffectDescription, 'controls'>, values: unknown): SchemaValidationError[];
208
+ /**
209
+ * `values` over the effect's defaults, validated against its control schema. Throws
210
+ * `EffectControlError` naming every bad control. Providers call this in `render`; editors call
211
+ * it before saving values.
212
+ */
213
+ declare function resolveEffectValues(description: Pick<EffectDescription, 'id' | 'controls' | 'defaults'>, values?: EffectValues): Record<string, EffectValues[string]>;
214
+ /**
215
+ * Filters a catalog and ranks it against `query` (every word must appear in the id, name,
216
+ * category, tags or description; name matches rank first). An empty query keeps catalog order.
217
+ * Providers can implement `list` and `search` with it.
218
+ */
219
+ declare function searchEffectSummaries<T extends EffectSummary>(catalog: readonly T[], query?: string, options?: EffectSearchOptions): T[];
220
+ /** A transparent picture, with float samples when `float` is set. */
221
+ declare function createEffectPixels(width: number, height: number, float?: boolean): EffectPixels;
222
+ /** True for an `EffectPixels` (rather than a host image object). */
223
+ declare function isEffectPixels(source: EffectImageSource | unknown): source is EffectPixels;
224
+ /** sRGB-encoded 0–1 to linear light. */
225
+ declare const srgbToLinear: (v: number) => number;
226
+ /** Linear light to sRGB-encoded (clamped below at 0; may exceed 1). */
227
+ declare const linearToSrgb: (v: number) => number;
228
+ /** Fills `pixels.data` from `pixels.float` (linear float to clamped 8-bit sRGB). */
229
+ declare function encodeEffectFloat(pixels: EffectPixels): EffectPixels;
230
+ /**
231
+ * Blends an effect `result` back over its `source` by `mask` coverage (alpha channel), in place
232
+ * on `result`: where the mask is 0 the source shows, where it is 255 the result. Without a
233
+ * source (generators), the result's alpha is multiplied by coverage. Editors use it when the
234
+ * provider does not `supportsMask`. All three must have the same size.
235
+ */
236
+ declare function applyEffectMask(result: EffectPixels, mask: EffectPixels, source?: EffectPixels): EffectPixels;
237
+ /**
238
+ * Holds an editor's effects provider. Controllers expose it as `effectsProvider`,
239
+ * `setEffectsProvider(provider | null)` and `useEffects(provider)`; listeners hear every change.
240
+ */
241
+ declare class EffectsSlot {
242
+ private current;
243
+ private readonly listeners;
244
+ get provider(): EffectProvider | null;
245
+ set(provider: EffectProvider | null): void;
246
+ /** Sets `provider` and returns a function that clears it again (if it is still the one set). */
247
+ use(provider: EffectProvider): () => void;
248
+ /** The provider, or a `NoEffectsProviderError`. */
249
+ require(): EffectProvider;
250
+ subscribe(listener: (provider: EffectProvider | null) => void): () => void;
251
+ }
252
+
253
+ export { isEffectPixels as A, linearToSrgb as B, resolveEffectValues as C, searchEffectSummaries as D, type EffectProvider as E, srgbToLinear as F, type EffectUse as a, type EffectProviderCapabilities as b, type EffectRenderRequest as c, type EffectValue as d, type EffectDescription as e, type EffectPixels as f, type EffectSummary as g, EFFECT_KINDS as h, EFFECT_USES as i, type EffectControlSchema as j, type EffectImageSource as k, type EffectInputSpec as l, type EffectKind as m, type EffectPreset as n, type EffectRenderer as o, type EffectRendererOptions as p, type EffectSearchOptions as q, type EffectSvgAnimation as r, type EffectValues as s, type EffectVectorMotion as t, type EffectVectorTarget as u, EffectsSlot as v, applyEffectMask as w, createEffectPixels as x, effectValueErrors as y, encodeEffectFloat as z };