@pixerate/editor 0.124.1 → 0.125.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.
- package/dist/agent/index.cjs +3 -3
- package/dist/agent/index.cjs.map +1 -1
- package/dist/agent/index.js +3 -3
- package/dist/animation-editor/index.cjs +424 -85
- package/dist/animation-editor/index.cjs.map +1 -1
- package/dist/animation-editor/index.d.cts +174 -7
- package/dist/animation-editor/index.d.ts +174 -7
- package/dist/animation-editor/index.js +348 -9
- package/dist/animation-editor/index.js.map +1 -1
- package/dist/chunk-FJ3324TZ.js +59 -0
- package/dist/chunk-FJ3324TZ.js.map +1 -0
- package/dist/{chunk-5EO2IXQE.js → chunk-FPRIUR4T.js} +1 -1
- package/dist/chunk-FPRIUR4T.js.map +1 -0
- package/dist/{chunk-ORHMVUR6.js → chunk-G6WXWS4Y.js} +5 -3
- package/dist/{chunk-ORHMVUR6.js.map → chunk-G6WXWS4Y.js.map} +1 -1
- package/dist/{chunk-CN4PJHUG.cjs → chunk-IOXKXQNW.cjs} +3 -59
- package/dist/chunk-IOXKXQNW.cjs.map +1 -0
- package/dist/{chunk-NGYD3AMN.js → chunk-MPQAO33O.js} +2 -2
- package/dist/{chunk-PEHYWUVV.cjs → chunk-O5RVCDEC.cjs} +82 -82
- package/dist/{chunk-PEHYWUVV.cjs.map → chunk-O5RVCDEC.cjs.map} +1 -1
- package/dist/{chunk-FHYDQOPC.cjs → chunk-QDJKUBWE.cjs} +5 -5
- package/dist/{chunk-FHYDQOPC.cjs.map → chunk-QDJKUBWE.cjs.map} +1 -1
- package/dist/{chunk-5XXMLBH4.cjs → chunk-QQKTOA4U.cjs} +1 -1
- package/dist/chunk-QQKTOA4U.cjs.map +1 -0
- package/dist/{chunk-QEG3GRN2.js → chunk-TGKT5QAB.js} +2 -58
- package/dist/chunk-TGKT5QAB.js.map +1 -0
- package/dist/{chunk-4QQZV5Y5.cjs → chunk-UXFI3CDZ.cjs} +11 -9
- package/dist/chunk-UXFI3CDZ.cjs.map +1 -0
- package/dist/{chunk-WE25VLCO.cjs → chunk-V5YGPRCZ.cjs} +36 -36
- package/dist/{chunk-WE25VLCO.cjs.map → chunk-V5YGPRCZ.cjs.map} +1 -1
- package/dist/chunk-W6QTLHZ3.cjs +59 -0
- package/dist/chunk-W6QTLHZ3.cjs.map +1 -0
- package/dist/{chunk-WATAQ2Z2.js → chunk-WUDPFWAN.js} +2 -2
- package/dist/{chunk-JRXJTPES.js → chunk-XZWOLXWA.js} +4 -4
- package/dist/{chunk-JRXJTPES.js.map → chunk-XZWOLXWA.js.map} +1 -1
- package/dist/effects/index.cjs +61 -33
- package/dist/effects/index.cjs.map +1 -1
- package/dist/effects/index.d.cts +4 -5
- package/dist/effects/index.d.ts +4 -5
- package/dist/effects/index.js +32 -4
- package/dist/effects/index.js.map +1 -1
- package/dist/{export-WmYoWmLM.d.cts → export-Bp7ji2r4.d.cts} +1 -2
- package/dist/{export-BdfY_lH0.d.ts → export-C1s4eolZ.d.ts} +1 -1
- package/dist/{export-BGtXgMJ3.d.ts → export-DAyPY94f.d.ts} +1 -2
- package/dist/{export-CbpjwxaI.d.cts → export-DVl4fWy5.d.cts} +1 -1
- package/dist/generation/index.cjs +3 -3
- package/dist/generation/index.cjs.map +1 -1
- package/dist/generation/index.js +3 -3
- package/dist/helpers-BBLlekuM.d.ts +2009 -0
- package/dist/helpers-i95Ob6Vi.d.cts +2009 -0
- package/dist/image-editor/index.cjs +629 -627
- package/dist/image-editor/index.cjs.map +1 -1
- package/dist/image-editor/index.d.cts +5 -7
- package/dist/image-editor/index.d.ts +5 -7
- package/dist/image-editor/index.js +15 -13
- package/dist/image-editor/index.js.map +1 -1
- package/dist/paint-editor/index.cjs +12 -11
- package/dist/paint-editor/index.cjs.map +1 -1
- package/dist/paint-editor/index.d.cts +3 -5
- package/dist/paint-editor/index.d.ts +3 -5
- package/dist/paint-editor/index.js +6 -5
- package/dist/paint-editor/index.js.map +1 -1
- package/dist/{svg-BDrjRnL1.d.cts → svg-BkRL-fZJ.d.cts} +1 -1
- package/dist/{svg-C-vZ3q50.d.ts → svg-DJKriJ4A.d.ts} +1 -1
- package/dist/tools/index.cjs +2 -2
- package/dist/tools/index.cjs.map +1 -1
- package/dist/tools/index.js +3 -3
- package/dist/{tools-C7JtLYzo.d.ts → tools-CM8Oe8F3.d.ts} +1 -1
- package/dist/{tools-DHKGHiSK.d.cts → tools-DZCv2kX1.d.cts} +1 -1
- package/dist/vector/index.cjs +1032 -883
- package/dist/vector/index.cjs.map +1 -1
- package/dist/vector/index.d.cts +61 -6
- package/dist/vector/index.d.ts +61 -6
- package/dist/vector/index.js +155 -6
- package/dist/vector/index.js.map +1 -1
- package/dist/video-editor/index.cjs +273 -272
- package/dist/video-editor/index.cjs.map +1 -1
- package/dist/video-editor/index.d.cts +4 -6
- package/dist/video-editor/index.d.ts +4 -6
- package/dist/video-editor/index.js +7 -6
- package/dist/video-editor/index.js.map +1 -1
- package/package.json +1 -1
- package/skills/pixerate-animation-editor/SKILL.md +24 -1
- package/skills/pixerate-vector/SKILL.md +15 -0
- package/dist/chunk-4QQZV5Y5.cjs.map +0 -1
- package/dist/chunk-5EO2IXQE.js.map +0 -1
- package/dist/chunk-5XXMLBH4.cjs.map +0 -1
- package/dist/chunk-CN4PJHUG.cjs.map +0 -1
- package/dist/chunk-QEG3GRN2.js.map +0 -1
- package/dist/flair-CxB3fOcU.d.ts +0 -739
- package/dist/flair-D7BxyBwL.d.cts +0 -739
- package/dist/helpers-777mC6dc.d.cts +0 -253
- package/dist/helpers-DX2_7L5t.d.ts +0 -253
- package/dist/types-BcX7sCsn.d.ts +0 -993
- package/dist/types-CznabG7m.d.cts +0 -993
- /package/dist/{chunk-NGYD3AMN.js.map → chunk-MPQAO33O.js.map} +0 -0
- /package/dist/{chunk-WATAQ2Z2.js.map → chunk-WUDPFWAN.js.map} +0 -0
|
@@ -1,253 +0,0 @@
|
|
|
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 };
|
|
@@ -1,253 +0,0 @@
|
|
|
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 };
|