@pixerate/editor 0.231.0 → 0.232.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/animation-editor/index.cjs +25 -25
- package/dist/animation-editor/index.js +1 -1
- package/dist/canvas/index.cjs +7 -7
- package/dist/canvas/index.js +1 -1
- package/dist/{chunk-OPSK22DL.cjs → chunk-2K5TELHV.cjs} +19 -2
- package/dist/{chunk-CSM5T6SE.js → chunk-6QLTUGMO.js} +1 -1
- package/dist/{chunk-5T3H7CGG.cjs → chunk-A653N65Q.cjs} +7 -7
- package/dist/{chunk-SBPGIZQN.js → chunk-MUSZYMBX.js} +1 -1
- package/dist/{chunk-TCZ2J7PR.js → chunk-PQYDJ2AV.js} +18 -1
- package/dist/{chunk-C73U5UI3.cjs → chunk-RG4O6K2A.cjs} +14 -14
- package/dist/effects/conformance.d.cts +4 -1
- package/dist/effects/conformance.d.ts +4 -1
- package/dist/effects/errors.d.cts +6 -1
- package/dist/effects/errors.d.ts +6 -1
- package/dist/effects/fake-templates.d.cts +17 -0
- package/dist/effects/fake-templates.d.ts +17 -0
- package/dist/effects/fake.d.cts +6 -1
- package/dist/effects/fake.d.ts +6 -1
- package/dist/effects/index.cjs +537 -74
- package/dist/effects/index.d.cts +1 -0
- package/dist/effects/index.d.ts +1 -0
- package/dist/effects/index.js +466 -3
- package/dist/effects/templates.d.cts +56 -0
- package/dist/effects/templates.d.ts +56 -0
- package/dist/effects/types.d.cts +212 -0
- package/dist/effects/types.d.ts +212 -0
- package/dist/image-editor/controller.d.cts +12 -0
- package/dist/image-editor/controller.d.ts +12 -0
- package/dist/image-editor/index.cjs +189 -144
- package/dist/image-editor/index.js +48 -3
- package/dist/paint-editor/index.cjs +7 -7
- package/dist/paint-editor/index.js +2 -2
- package/dist/vector/index.cjs +6 -6
- package/dist/vector/index.js +1 -1
- package/dist/video-editor/index.cjs +329 -329
- package/dist/video-editor/index.js +3 -3
- package/package.json +1 -1
- package/skills/pixerate-animation-editor/SKILL.md +37 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helpers for sequence templates and the sequences they fill to (see `EffectSequence`): the
|
|
3
|
+
* values a template takes as a JSON Schema, checking values before asking the provider, checking
|
|
4
|
+
* a sequence before loading it, and which input a layer's subject feeds. Dependency-free.
|
|
5
|
+
*/
|
|
6
|
+
import type { JsonSchema } from '../tools/schema.js';
|
|
7
|
+
import { type EffectDescription, type EffectLayer, type EffectLayerRole, type EffectSequence, type EffectSubjectKind, type EffectSummary, type EffectTemplateSearchOptions, type EffectTemplateSlot, type EffectTemplateSummary } from './types.js';
|
|
8
|
+
export declare const EFFECT_SEQUENCE_NAME: RegExp;
|
|
9
|
+
/** True for a subject slot (`image`, `video`, `svg`). */
|
|
10
|
+
export declare const isSubjectTemplateSlot: (slot: Pick<EffectTemplateSlot, "type">) => boolean;
|
|
11
|
+
/** The kind of a subject (`image`, `video`, `svg`, `text`, `slot`), or undefined when it is none of them. */
|
|
12
|
+
export declare function effectSubjectKind(subject: unknown): EffectSubjectKind | undefined;
|
|
13
|
+
/** What a slot takes, in a few words ("words (up to 40 characters)", "a colour like #FF5A36"). */
|
|
14
|
+
export declare function templateSlotTakes(slot: EffectTemplateSlot): string;
|
|
15
|
+
/** The problem with one value for a slot, as a sentence, or undefined when it fits. */
|
|
16
|
+
export declare function templateValueProblem(slot: EffectTemplateSlot, value: unknown): string | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* Every problem with `values` for a template's slots, as sentences: unknown slots, wrong types,
|
|
19
|
+
* out-of-range numbers, text too long. Empty when they fit. Slots left out take their defaults.
|
|
20
|
+
*/
|
|
21
|
+
export declare function checkTemplateValues(slots: readonly EffectTemplateSlot[], values: unknown): string[];
|
|
22
|
+
/** One slot's value as a JSON Schema. */
|
|
23
|
+
export declare function templateSlotSchema(slot: EffectTemplateSlot): JsonSchema;
|
|
24
|
+
/** The values a template takes as a strict JSON Schema (every slot optional; `additionalProperties: false`). */
|
|
25
|
+
export declare function templateValuesSchema(slots: readonly EffectTemplateSlot[]): JsonSchema & {
|
|
26
|
+
type: 'object';
|
|
27
|
+
};
|
|
28
|
+
/** The defaults of a template's text, colour and number slots: an example `values` object to change. */
|
|
29
|
+
export declare function templateDefaultValues(slots: readonly EffectTemplateSlot[]): Record<string, string | number>;
|
|
30
|
+
/** One line on a slot: its name, type, what it takes and its default. */
|
|
31
|
+
export declare function templateSlotSummary(slot: EffectTemplateSlot): string;
|
|
32
|
+
/** Templates matching every word of `query` (in name, id, tags or description) and every tag, best first. */
|
|
33
|
+
export declare function searchTemplateSummaries<T extends EffectTemplateSummary>(catalog: readonly T[], options?: EffectTemplateSearchOptions): T[];
|
|
34
|
+
/** Where a layer sits: its `role`, else `subject` when it has a `rect`, else `background`. */
|
|
35
|
+
export declare const effectLayerRole: (layer: Pick<EffectLayer, "role" | "rect">) => EffectLayerRole;
|
|
36
|
+
/**
|
|
37
|
+
* The image input a layer's subject feeds: `source` when the effect has it, else its first image
|
|
38
|
+
* input; undefined when it takes no picture (a generator: then the layer cannot have a subject).
|
|
39
|
+
*/
|
|
40
|
+
export declare function effectLayerInput(description: Pick<EffectDescription, 'inputs'>): string | undefined;
|
|
41
|
+
/** The uses a layer's effect may have (a transition belongs on `EffectSequenceShot.transition`, a camera move on `camera`). */
|
|
42
|
+
export declare const EFFECT_LAYER_USES: readonly ["generator", "filter", "overlay", "title"];
|
|
43
|
+
/** True for an effect a layer can show. */
|
|
44
|
+
export declare const effectLayerOffered: (e: Pick<EffectSummary, "kind" | "uses">) => boolean;
|
|
45
|
+
/** Problems with one subject, or undefined when it is sound. */
|
|
46
|
+
export declare function effectSubjectProblem(subject: unknown): string | undefined;
|
|
47
|
+
/**
|
|
48
|
+
* Every problem with a sequence's shape, as sentences ("shot 2, layer 1: …"). With `catalog`, also
|
|
49
|
+
* effect ids it does not list, layer effects that cannot be layers and transitions without the
|
|
50
|
+
* use `transition`. Empty when the sequence is sound.
|
|
51
|
+
*/
|
|
52
|
+
export declare function checkEffectSequence(sequence: unknown, catalog?: readonly Pick<EffectSummary, 'id' | 'kind' | 'uses'>[]): string[];
|
|
53
|
+
/** Every effect id a sequence names (layers and transitions), each once. */
|
|
54
|
+
export declare function effectSequenceEffects(sequence: EffectSequence): string[];
|
|
55
|
+
/** Subject slots a sequence leaves for the host (`{ slot }` subjects), each once. */
|
|
56
|
+
export declare function effectSequenceSlots(sequence: EffectSequence): string[];
|
package/dist/effects/types.d.cts
CHANGED
|
@@ -275,6 +275,204 @@ export interface CameraMoveSample {
|
|
|
275
275
|
/** Ms of the cut, when the move has one. */
|
|
276
276
|
cut?: number;
|
|
277
277
|
}
|
|
278
|
+
/** A box in a sequence's stage units (pixels of `EffectSequence.stage`). */
|
|
279
|
+
export interface EffectRect {
|
|
280
|
+
x: number;
|
|
281
|
+
y: number;
|
|
282
|
+
width: number;
|
|
283
|
+
height: number;
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Something a layer shows or applies its effect to: a picture or SVG (a URL, a `data:` URL or
|
|
287
|
+
* `<svg>` markup), a video by URL, words, or `{ slot }`: a subject the host fills in by name.
|
|
288
|
+
*/
|
|
289
|
+
export type EffectSubject = {
|
|
290
|
+
image: string;
|
|
291
|
+
} | {
|
|
292
|
+
video: string;
|
|
293
|
+
} | {
|
|
294
|
+
svg: string;
|
|
295
|
+
} | {
|
|
296
|
+
text: string;
|
|
297
|
+
font?: string;
|
|
298
|
+
weight?: number | string;
|
|
299
|
+
} | {
|
|
300
|
+
slot: string;
|
|
301
|
+
};
|
|
302
|
+
/** The kinds of subject, as `EffectSubject` keys. */
|
|
303
|
+
export declare const EFFECT_SUBJECT_KINDS: readonly ["image", "video", "svg", "text", "slot"];
|
|
304
|
+
export type EffectSubjectKind = (typeof EFFECT_SUBJECT_KINDS)[number];
|
|
305
|
+
/**
|
|
306
|
+
* Where a layer sits in a shot's stack: `background` under the shot's own content, `subject`
|
|
307
|
+
* with it, `overlay` above everything.
|
|
308
|
+
*/
|
|
309
|
+
export type EffectLayerRole = 'background' | 'subject' | 'overlay';
|
|
310
|
+
export declare const EFFECT_LAYER_ROLES: readonly EffectLayerRole[];
|
|
311
|
+
/** When a layer starts or stops: ms after its shot starts, or `{ shots: n }` for when the n-th shot after its own begins. */
|
|
312
|
+
export type EffectLayerTime = number | {
|
|
313
|
+
shots: number;
|
|
314
|
+
};
|
|
315
|
+
/**
|
|
316
|
+
* One layer of a shot (the shape of Flair's `SceneLayer`): a catalog effect, optionally applied
|
|
317
|
+
* to a subject, or a bare subject (no `effect`), placed on the stage for a stretch of time.
|
|
318
|
+
* The subject feeds the effect's `source` input, else its first image input.
|
|
319
|
+
*/
|
|
320
|
+
export interface EffectLayer {
|
|
321
|
+
/** A name unique in the sequence. */
|
|
322
|
+
id?: string;
|
|
323
|
+
/** The effect's id (a generator, filter, overlay or title). Absent for a bare subject. */
|
|
324
|
+
effect?: string;
|
|
325
|
+
/** A preset of the effect's, by name; its values are written out in `values` too. */
|
|
326
|
+
preset?: string;
|
|
327
|
+
/** Control values over the effect's defaults. */
|
|
328
|
+
values?: Record<string, EffectValue>;
|
|
329
|
+
subject?: EffectSubject;
|
|
330
|
+
/** Default `subject` when placed with `rect`, else `background`. */
|
|
331
|
+
role?: EffectLayerRole;
|
|
332
|
+
/** Where it sits, in stage units; it moves with the camera. Absent: it fills the screen. */
|
|
333
|
+
rect?: EffectRect;
|
|
334
|
+
/** When it starts (default 0: as its shot starts). */
|
|
335
|
+
from?: EffectLayerTime;
|
|
336
|
+
/** When it stops (default `{ shots: 1 }`: as the next shot starts). */
|
|
337
|
+
until?: EffectLayerTime;
|
|
338
|
+
/** 0–1 (default 1). */
|
|
339
|
+
opacity?: number;
|
|
340
|
+
/** Ms it fades in and out over (default 0: it cuts). */
|
|
341
|
+
fade?: number;
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* A transition into a shot (the shape of Flair's `ShotTransition`): an effect with the use
|
|
345
|
+
* `transition` blends the outgoing shot's last frame (`from`) into the incoming shot (`to`) as
|
|
346
|
+
* `progress` runs 0 → 1 over `ms`.
|
|
347
|
+
*/
|
|
348
|
+
export interface EffectShotTransition {
|
|
349
|
+
effect: string;
|
|
350
|
+
/** Length (ms), default `EFFECT_TRANSITION_MS`. */
|
|
351
|
+
ms?: number;
|
|
352
|
+
preset?: string;
|
|
353
|
+
values?: Record<string, EffectValue>;
|
|
354
|
+
}
|
|
355
|
+
/** How long a shot transition takes when it does not say (ms). */
|
|
356
|
+
export declare const EFFECT_TRANSITION_MS = 800;
|
|
357
|
+
/** One shot of a sequence. */
|
|
358
|
+
export interface EffectSequenceShot {
|
|
359
|
+
/** Ms the shot holds after its lead-in (the longer of its camera move and its transition). */
|
|
360
|
+
hold: number;
|
|
361
|
+
/** Words shown large over the shot. */
|
|
362
|
+
title?: string;
|
|
363
|
+
/** Words shown small at the foot of the shot. */
|
|
364
|
+
caption?: string;
|
|
365
|
+
camera?: {
|
|
366
|
+
/** What the camera frames, in stage units (default the whole stage). */
|
|
367
|
+
framing?: EffectRect;
|
|
368
|
+
/** A `transition` camera move into this framing. */
|
|
369
|
+
in?: CameraMoveSpec;
|
|
370
|
+
/** A `hold` camera move while the shot holds. */
|
|
371
|
+
during?: CameraMoveSpec;
|
|
372
|
+
};
|
|
373
|
+
/** Bottom to top. */
|
|
374
|
+
layers: EffectLayer[];
|
|
375
|
+
/** How the shot before gives way to this one; absent on the first shot. */
|
|
376
|
+
transition?: EffectShotTransition;
|
|
377
|
+
}
|
|
378
|
+
/**
|
|
379
|
+
* A sequence of shots built from catalog effects: what a template fills to. Renderer-neutral;
|
|
380
|
+
* editors load it into their own documents (an animation's shots, a video's clips).
|
|
381
|
+
*/
|
|
382
|
+
export interface EffectSequence {
|
|
383
|
+
name: string;
|
|
384
|
+
title?: string;
|
|
385
|
+
/** Stage size in pixels; rects and framings are in these units. */
|
|
386
|
+
stage: CameraStage;
|
|
387
|
+
shots: EffectSequenceShot[];
|
|
388
|
+
}
|
|
389
|
+
/** One template of a provider's catalog. */
|
|
390
|
+
export interface EffectTemplateSummary {
|
|
391
|
+
/** Stable id. */
|
|
392
|
+
id: string;
|
|
393
|
+
name: string;
|
|
394
|
+
description: string;
|
|
395
|
+
tags?: readonly string[];
|
|
396
|
+
/** How many shots it fills to. */
|
|
397
|
+
shots: number;
|
|
398
|
+
/** Length with its defaults (ms), when the provider knows it. */
|
|
399
|
+
durationMs?: number;
|
|
400
|
+
}
|
|
401
|
+
/** The kinds of template slot: a subject (`image`, `video`, `svg`), `text`, `color` or `number`. */
|
|
402
|
+
export declare const EFFECT_TEMPLATE_SLOT_TYPES: readonly ["image", "video", "svg", "text", "color", "number"];
|
|
403
|
+
export type EffectTemplateSlotType = (typeof EFFECT_TEMPLATE_SLOT_TYPES)[number];
|
|
404
|
+
interface EffectTemplateSlotBase {
|
|
405
|
+
/** Letters, digits, `-` and `_`, starting with a letter. */
|
|
406
|
+
name: string;
|
|
407
|
+
/** What a form shows for it. */
|
|
408
|
+
label: string;
|
|
409
|
+
/** A sentence on what it is for. */
|
|
410
|
+
description?: string;
|
|
411
|
+
}
|
|
412
|
+
/**
|
|
413
|
+
* A slot for a picture, SVG or video. Its default (which may be large) is not described, only
|
|
414
|
+
* whether there is one; with none, an unfilled slot is left for the host (`openSlots`).
|
|
415
|
+
*/
|
|
416
|
+
export interface EffectTemplateSubjectSlot extends EffectTemplateSlotBase {
|
|
417
|
+
type: 'image' | 'video' | 'svg';
|
|
418
|
+
hasDefault: boolean;
|
|
419
|
+
}
|
|
420
|
+
export interface EffectTemplateTextSlot extends EffectTemplateSlotBase {
|
|
421
|
+
type: 'text';
|
|
422
|
+
default: string;
|
|
423
|
+
/** The most characters it takes. */
|
|
424
|
+
maxLength?: number;
|
|
425
|
+
}
|
|
426
|
+
/** A colour, `#RRGGBB`. */
|
|
427
|
+
export interface EffectTemplateColorSlot extends EffectTemplateSlotBase {
|
|
428
|
+
type: 'color';
|
|
429
|
+
default: string;
|
|
430
|
+
}
|
|
431
|
+
export interface EffectTemplateNumberSlot extends EffectTemplateSlotBase {
|
|
432
|
+
type: 'number';
|
|
433
|
+
default: number;
|
|
434
|
+
min?: number;
|
|
435
|
+
max?: number;
|
|
436
|
+
/** Whole numbers only. */
|
|
437
|
+
integer?: boolean;
|
|
438
|
+
}
|
|
439
|
+
/** A slot of a template, shaped for a form (Flair's `describeTemplateSlots`). */
|
|
440
|
+
export type EffectTemplateSlot = EffectTemplateSubjectSlot | EffectTemplateTextSlot | EffectTemplateColorSlot | EffectTemplateNumberSlot;
|
|
441
|
+
/** A template with its slots, in the order a form shows them. */
|
|
442
|
+
export interface EffectTemplateDescription extends EffectTemplateSummary {
|
|
443
|
+
slots: readonly EffectTemplateSlot[];
|
|
444
|
+
}
|
|
445
|
+
/**
|
|
446
|
+
* What fills a slot: words, a colour or a number; for a subject slot a URL or markup, a subject
|
|
447
|
+
* object, or `{ slot: name }` to leave it for the host.
|
|
448
|
+
*/
|
|
449
|
+
export type EffectTemplateValue = string | number | EffectSubject;
|
|
450
|
+
export type EffectTemplateValues = Readonly<Record<string, EffectTemplateValue>>;
|
|
451
|
+
export interface EffectTemplateSearchOptions {
|
|
452
|
+
/** Only templates matching every word (in name, id, tags or description). */
|
|
453
|
+
query?: string;
|
|
454
|
+
/** Only templates carrying every one of these tags. */
|
|
455
|
+
tags?: readonly string[];
|
|
456
|
+
/** Most results to return. */
|
|
457
|
+
limit?: number;
|
|
458
|
+
}
|
|
459
|
+
export interface EffectTemplateOptions {
|
|
460
|
+
/** The sequence's name: lowercase words and dashes (default the template's id). */
|
|
461
|
+
name?: string;
|
|
462
|
+
}
|
|
463
|
+
/** What `instantiateTemplate` gives. Values that do not fit are refused all at once, never in part. */
|
|
464
|
+
export type EffectTemplateResult = {
|
|
465
|
+
ok: true;
|
|
466
|
+
sequence: EffectSequence;
|
|
467
|
+
/** Subject slots left for the host to fill (no value and no default, or `{ slot }`). */
|
|
468
|
+
openSlots: readonly string[];
|
|
469
|
+
/** What the provider left out or changed, in sentences (empty when nothing was). */
|
|
470
|
+
notes: readonly string[];
|
|
471
|
+
} | {
|
|
472
|
+
ok: false;
|
|
473
|
+
/** Each a sentence naming the slot and what it takes. */
|
|
474
|
+
errors: readonly string[];
|
|
475
|
+
};
|
|
278
476
|
/** What a provider can do, so editors can degrade cleanly. */
|
|
279
477
|
export interface EffectProviderCapabilities {
|
|
280
478
|
/** Renders off the main thread. */
|
|
@@ -293,6 +491,8 @@ export interface EffectProviderCapabilities {
|
|
|
293
491
|
supportsAuthoring?: boolean;
|
|
294
492
|
/** Lists `camera` effects and implements `cameraView` (and maybe `sampleCameraMove`). */
|
|
295
493
|
supportsCamera?: boolean;
|
|
494
|
+
/** Implements `listTemplates`, `describeTemplate` and `instantiateTemplate`. */
|
|
495
|
+
supportsTemplates?: boolean;
|
|
296
496
|
}
|
|
297
497
|
export type MaybePromise<T> = T | Promise<T>;
|
|
298
498
|
/**
|
|
@@ -342,4 +542,16 @@ export interface EffectProvider {
|
|
|
342
542
|
* `sampleEffectCameraMove` falls back to `cameraView` per frame. Errors as for `cameraView`.
|
|
343
543
|
*/
|
|
344
544
|
sampleCameraMove?(id: string, request: CameraMoveSampleRequest): MaybePromise<CameraMoveSample>;
|
|
545
|
+
/** Sequence templates, best match first. Present when `capabilities.supportsTemplates`. */
|
|
546
|
+
listTemplates?(options?: EffectTemplateSearchOptions): MaybePromise<readonly EffectTemplateSummary[]>;
|
|
547
|
+
/** A template with its slots. Unknown ids throw `UnknownTemplateError`. */
|
|
548
|
+
describeTemplate?(id: string): MaybePromise<EffectTemplateDescription>;
|
|
549
|
+
/**
|
|
550
|
+
* Fills a template's slots and returns the sequence. Slots left out take their defaults.
|
|
551
|
+
* Values that do not fit (an unknown slot, a wrong type, out of range) give `{ ok: false,
|
|
552
|
+
* errors }`, each error a sentence. Unknown ids throw `UnknownTemplateError`. Every effect
|
|
553
|
+
* the sequence names is in the provider's `list()`.
|
|
554
|
+
*/
|
|
555
|
+
instantiateTemplate?(id: string, values?: EffectTemplateValues, options?: EffectTemplateOptions): MaybePromise<EffectTemplateResult>;
|
|
345
556
|
}
|
|
557
|
+
export {};
|
package/dist/effects/types.d.ts
CHANGED
|
@@ -275,6 +275,204 @@ export interface CameraMoveSample {
|
|
|
275
275
|
/** Ms of the cut, when the move has one. */
|
|
276
276
|
cut?: number;
|
|
277
277
|
}
|
|
278
|
+
/** A box in a sequence's stage units (pixels of `EffectSequence.stage`). */
|
|
279
|
+
export interface EffectRect {
|
|
280
|
+
x: number;
|
|
281
|
+
y: number;
|
|
282
|
+
width: number;
|
|
283
|
+
height: number;
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Something a layer shows or applies its effect to: a picture or SVG (a URL, a `data:` URL or
|
|
287
|
+
* `<svg>` markup), a video by URL, words, or `{ slot }`: a subject the host fills in by name.
|
|
288
|
+
*/
|
|
289
|
+
export type EffectSubject = {
|
|
290
|
+
image: string;
|
|
291
|
+
} | {
|
|
292
|
+
video: string;
|
|
293
|
+
} | {
|
|
294
|
+
svg: string;
|
|
295
|
+
} | {
|
|
296
|
+
text: string;
|
|
297
|
+
font?: string;
|
|
298
|
+
weight?: number | string;
|
|
299
|
+
} | {
|
|
300
|
+
slot: string;
|
|
301
|
+
};
|
|
302
|
+
/** The kinds of subject, as `EffectSubject` keys. */
|
|
303
|
+
export declare const EFFECT_SUBJECT_KINDS: readonly ["image", "video", "svg", "text", "slot"];
|
|
304
|
+
export type EffectSubjectKind = (typeof EFFECT_SUBJECT_KINDS)[number];
|
|
305
|
+
/**
|
|
306
|
+
* Where a layer sits in a shot's stack: `background` under the shot's own content, `subject`
|
|
307
|
+
* with it, `overlay` above everything.
|
|
308
|
+
*/
|
|
309
|
+
export type EffectLayerRole = 'background' | 'subject' | 'overlay';
|
|
310
|
+
export declare const EFFECT_LAYER_ROLES: readonly EffectLayerRole[];
|
|
311
|
+
/** When a layer starts or stops: ms after its shot starts, or `{ shots: n }` for when the n-th shot after its own begins. */
|
|
312
|
+
export type EffectLayerTime = number | {
|
|
313
|
+
shots: number;
|
|
314
|
+
};
|
|
315
|
+
/**
|
|
316
|
+
* One layer of a shot (the shape of Flair's `SceneLayer`): a catalog effect, optionally applied
|
|
317
|
+
* to a subject, or a bare subject (no `effect`), placed on the stage for a stretch of time.
|
|
318
|
+
* The subject feeds the effect's `source` input, else its first image input.
|
|
319
|
+
*/
|
|
320
|
+
export interface EffectLayer {
|
|
321
|
+
/** A name unique in the sequence. */
|
|
322
|
+
id?: string;
|
|
323
|
+
/** The effect's id (a generator, filter, overlay or title). Absent for a bare subject. */
|
|
324
|
+
effect?: string;
|
|
325
|
+
/** A preset of the effect's, by name; its values are written out in `values` too. */
|
|
326
|
+
preset?: string;
|
|
327
|
+
/** Control values over the effect's defaults. */
|
|
328
|
+
values?: Record<string, EffectValue>;
|
|
329
|
+
subject?: EffectSubject;
|
|
330
|
+
/** Default `subject` when placed with `rect`, else `background`. */
|
|
331
|
+
role?: EffectLayerRole;
|
|
332
|
+
/** Where it sits, in stage units; it moves with the camera. Absent: it fills the screen. */
|
|
333
|
+
rect?: EffectRect;
|
|
334
|
+
/** When it starts (default 0: as its shot starts). */
|
|
335
|
+
from?: EffectLayerTime;
|
|
336
|
+
/** When it stops (default `{ shots: 1 }`: as the next shot starts). */
|
|
337
|
+
until?: EffectLayerTime;
|
|
338
|
+
/** 0–1 (default 1). */
|
|
339
|
+
opacity?: number;
|
|
340
|
+
/** Ms it fades in and out over (default 0: it cuts). */
|
|
341
|
+
fade?: number;
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* A transition into a shot (the shape of Flair's `ShotTransition`): an effect with the use
|
|
345
|
+
* `transition` blends the outgoing shot's last frame (`from`) into the incoming shot (`to`) as
|
|
346
|
+
* `progress` runs 0 → 1 over `ms`.
|
|
347
|
+
*/
|
|
348
|
+
export interface EffectShotTransition {
|
|
349
|
+
effect: string;
|
|
350
|
+
/** Length (ms), default `EFFECT_TRANSITION_MS`. */
|
|
351
|
+
ms?: number;
|
|
352
|
+
preset?: string;
|
|
353
|
+
values?: Record<string, EffectValue>;
|
|
354
|
+
}
|
|
355
|
+
/** How long a shot transition takes when it does not say (ms). */
|
|
356
|
+
export declare const EFFECT_TRANSITION_MS = 800;
|
|
357
|
+
/** One shot of a sequence. */
|
|
358
|
+
export interface EffectSequenceShot {
|
|
359
|
+
/** Ms the shot holds after its lead-in (the longer of its camera move and its transition). */
|
|
360
|
+
hold: number;
|
|
361
|
+
/** Words shown large over the shot. */
|
|
362
|
+
title?: string;
|
|
363
|
+
/** Words shown small at the foot of the shot. */
|
|
364
|
+
caption?: string;
|
|
365
|
+
camera?: {
|
|
366
|
+
/** What the camera frames, in stage units (default the whole stage). */
|
|
367
|
+
framing?: EffectRect;
|
|
368
|
+
/** A `transition` camera move into this framing. */
|
|
369
|
+
in?: CameraMoveSpec;
|
|
370
|
+
/** A `hold` camera move while the shot holds. */
|
|
371
|
+
during?: CameraMoveSpec;
|
|
372
|
+
};
|
|
373
|
+
/** Bottom to top. */
|
|
374
|
+
layers: EffectLayer[];
|
|
375
|
+
/** How the shot before gives way to this one; absent on the first shot. */
|
|
376
|
+
transition?: EffectShotTransition;
|
|
377
|
+
}
|
|
378
|
+
/**
|
|
379
|
+
* A sequence of shots built from catalog effects: what a template fills to. Renderer-neutral;
|
|
380
|
+
* editors load it into their own documents (an animation's shots, a video's clips).
|
|
381
|
+
*/
|
|
382
|
+
export interface EffectSequence {
|
|
383
|
+
name: string;
|
|
384
|
+
title?: string;
|
|
385
|
+
/** Stage size in pixels; rects and framings are in these units. */
|
|
386
|
+
stage: CameraStage;
|
|
387
|
+
shots: EffectSequenceShot[];
|
|
388
|
+
}
|
|
389
|
+
/** One template of a provider's catalog. */
|
|
390
|
+
export interface EffectTemplateSummary {
|
|
391
|
+
/** Stable id. */
|
|
392
|
+
id: string;
|
|
393
|
+
name: string;
|
|
394
|
+
description: string;
|
|
395
|
+
tags?: readonly string[];
|
|
396
|
+
/** How many shots it fills to. */
|
|
397
|
+
shots: number;
|
|
398
|
+
/** Length with its defaults (ms), when the provider knows it. */
|
|
399
|
+
durationMs?: number;
|
|
400
|
+
}
|
|
401
|
+
/** The kinds of template slot: a subject (`image`, `video`, `svg`), `text`, `color` or `number`. */
|
|
402
|
+
export declare const EFFECT_TEMPLATE_SLOT_TYPES: readonly ["image", "video", "svg", "text", "color", "number"];
|
|
403
|
+
export type EffectTemplateSlotType = (typeof EFFECT_TEMPLATE_SLOT_TYPES)[number];
|
|
404
|
+
interface EffectTemplateSlotBase {
|
|
405
|
+
/** Letters, digits, `-` and `_`, starting with a letter. */
|
|
406
|
+
name: string;
|
|
407
|
+
/** What a form shows for it. */
|
|
408
|
+
label: string;
|
|
409
|
+
/** A sentence on what it is for. */
|
|
410
|
+
description?: string;
|
|
411
|
+
}
|
|
412
|
+
/**
|
|
413
|
+
* A slot for a picture, SVG or video. Its default (which may be large) is not described, only
|
|
414
|
+
* whether there is one; with none, an unfilled slot is left for the host (`openSlots`).
|
|
415
|
+
*/
|
|
416
|
+
export interface EffectTemplateSubjectSlot extends EffectTemplateSlotBase {
|
|
417
|
+
type: 'image' | 'video' | 'svg';
|
|
418
|
+
hasDefault: boolean;
|
|
419
|
+
}
|
|
420
|
+
export interface EffectTemplateTextSlot extends EffectTemplateSlotBase {
|
|
421
|
+
type: 'text';
|
|
422
|
+
default: string;
|
|
423
|
+
/** The most characters it takes. */
|
|
424
|
+
maxLength?: number;
|
|
425
|
+
}
|
|
426
|
+
/** A colour, `#RRGGBB`. */
|
|
427
|
+
export interface EffectTemplateColorSlot extends EffectTemplateSlotBase {
|
|
428
|
+
type: 'color';
|
|
429
|
+
default: string;
|
|
430
|
+
}
|
|
431
|
+
export interface EffectTemplateNumberSlot extends EffectTemplateSlotBase {
|
|
432
|
+
type: 'number';
|
|
433
|
+
default: number;
|
|
434
|
+
min?: number;
|
|
435
|
+
max?: number;
|
|
436
|
+
/** Whole numbers only. */
|
|
437
|
+
integer?: boolean;
|
|
438
|
+
}
|
|
439
|
+
/** A slot of a template, shaped for a form (Flair's `describeTemplateSlots`). */
|
|
440
|
+
export type EffectTemplateSlot = EffectTemplateSubjectSlot | EffectTemplateTextSlot | EffectTemplateColorSlot | EffectTemplateNumberSlot;
|
|
441
|
+
/** A template with its slots, in the order a form shows them. */
|
|
442
|
+
export interface EffectTemplateDescription extends EffectTemplateSummary {
|
|
443
|
+
slots: readonly EffectTemplateSlot[];
|
|
444
|
+
}
|
|
445
|
+
/**
|
|
446
|
+
* What fills a slot: words, a colour or a number; for a subject slot a URL or markup, a subject
|
|
447
|
+
* object, or `{ slot: name }` to leave it for the host.
|
|
448
|
+
*/
|
|
449
|
+
export type EffectTemplateValue = string | number | EffectSubject;
|
|
450
|
+
export type EffectTemplateValues = Readonly<Record<string, EffectTemplateValue>>;
|
|
451
|
+
export interface EffectTemplateSearchOptions {
|
|
452
|
+
/** Only templates matching every word (in name, id, tags or description). */
|
|
453
|
+
query?: string;
|
|
454
|
+
/** Only templates carrying every one of these tags. */
|
|
455
|
+
tags?: readonly string[];
|
|
456
|
+
/** Most results to return. */
|
|
457
|
+
limit?: number;
|
|
458
|
+
}
|
|
459
|
+
export interface EffectTemplateOptions {
|
|
460
|
+
/** The sequence's name: lowercase words and dashes (default the template's id). */
|
|
461
|
+
name?: string;
|
|
462
|
+
}
|
|
463
|
+
/** What `instantiateTemplate` gives. Values that do not fit are refused all at once, never in part. */
|
|
464
|
+
export type EffectTemplateResult = {
|
|
465
|
+
ok: true;
|
|
466
|
+
sequence: EffectSequence;
|
|
467
|
+
/** Subject slots left for the host to fill (no value and no default, or `{ slot }`). */
|
|
468
|
+
openSlots: readonly string[];
|
|
469
|
+
/** What the provider left out or changed, in sentences (empty when nothing was). */
|
|
470
|
+
notes: readonly string[];
|
|
471
|
+
} | {
|
|
472
|
+
ok: false;
|
|
473
|
+
/** Each a sentence naming the slot and what it takes. */
|
|
474
|
+
errors: readonly string[];
|
|
475
|
+
};
|
|
278
476
|
/** What a provider can do, so editors can degrade cleanly. */
|
|
279
477
|
export interface EffectProviderCapabilities {
|
|
280
478
|
/** Renders off the main thread. */
|
|
@@ -293,6 +491,8 @@ export interface EffectProviderCapabilities {
|
|
|
293
491
|
supportsAuthoring?: boolean;
|
|
294
492
|
/** Lists `camera` effects and implements `cameraView` (and maybe `sampleCameraMove`). */
|
|
295
493
|
supportsCamera?: boolean;
|
|
494
|
+
/** Implements `listTemplates`, `describeTemplate` and `instantiateTemplate`. */
|
|
495
|
+
supportsTemplates?: boolean;
|
|
296
496
|
}
|
|
297
497
|
export type MaybePromise<T> = T | Promise<T>;
|
|
298
498
|
/**
|
|
@@ -342,4 +542,16 @@ export interface EffectProvider {
|
|
|
342
542
|
* `sampleEffectCameraMove` falls back to `cameraView` per frame. Errors as for `cameraView`.
|
|
343
543
|
*/
|
|
344
544
|
sampleCameraMove?(id: string, request: CameraMoveSampleRequest): MaybePromise<CameraMoveSample>;
|
|
545
|
+
/** Sequence templates, best match first. Present when `capabilities.supportsTemplates`. */
|
|
546
|
+
listTemplates?(options?: EffectTemplateSearchOptions): MaybePromise<readonly EffectTemplateSummary[]>;
|
|
547
|
+
/** A template with its slots. Unknown ids throw `UnknownTemplateError`. */
|
|
548
|
+
describeTemplate?(id: string): MaybePromise<EffectTemplateDescription>;
|
|
549
|
+
/**
|
|
550
|
+
* Fills a template's slots and returns the sequence. Slots left out take their defaults.
|
|
551
|
+
* Values that do not fit (an unknown slot, a wrong type, out of range) give `{ ok: false,
|
|
552
|
+
* errors }`, each error a sentence. Unknown ids throw `UnknownTemplateError`. Every effect
|
|
553
|
+
* the sequence names is in the provider's `list()`.
|
|
554
|
+
*/
|
|
555
|
+
instantiateTemplate?(id: string, values?: EffectTemplateValues, options?: EffectTemplateOptions): MaybePromise<EffectTemplateResult>;
|
|
345
556
|
}
|
|
557
|
+
export {};
|
|
@@ -1023,6 +1023,18 @@ export declare class ImageEditorController {
|
|
|
1023
1023
|
* non-pixel layer, or when the layer is completely transparent.
|
|
1024
1024
|
*/
|
|
1025
1025
|
getLayerDataURL(id: string): string | null;
|
|
1026
|
+
private maskedImageCache;
|
|
1027
|
+
/**
|
|
1028
|
+
* A pixel layer's own pixels with its raster and vector masks applied, cropped to what shows: a
|
|
1029
|
+
* PNG data URL and its document bounds, or `null` for an unknown or non-pixel layer, or when
|
|
1030
|
+
* nothing shows. Opacity, blending, filters and effects are left out, as in `getLayerDataURL`.
|
|
1031
|
+
* Use it for a masked layer, whose stored pixels (a whole copy, for Separate Subject's subject)
|
|
1032
|
+
* are not what it shows.
|
|
1033
|
+
*/
|
|
1034
|
+
getMaskedLayerImage(id: string): {
|
|
1035
|
+
url: string;
|
|
1036
|
+
bounds: CropBox;
|
|
1037
|
+
} | null;
|
|
1026
1038
|
/**
|
|
1027
1039
|
* Composites the layer stack in document space without a canvas (annotation layers need one
|
|
1028
1040
|
* and are left out): `rect` (default: the canvas) as RGBA, straight alpha. Crop, rotation and
|
|
@@ -1023,6 +1023,18 @@ export declare class ImageEditorController {
|
|
|
1023
1023
|
* non-pixel layer, or when the layer is completely transparent.
|
|
1024
1024
|
*/
|
|
1025
1025
|
getLayerDataURL(id: string): string | null;
|
|
1026
|
+
private maskedImageCache;
|
|
1027
|
+
/**
|
|
1028
|
+
* A pixel layer's own pixels with its raster and vector masks applied, cropped to what shows: a
|
|
1029
|
+
* PNG data URL and its document bounds, or `null` for an unknown or non-pixel layer, or when
|
|
1030
|
+
* nothing shows. Opacity, blending, filters and effects are left out, as in `getLayerDataURL`.
|
|
1031
|
+
* Use it for a masked layer, whose stored pixels (a whole copy, for Separate Subject's subject)
|
|
1032
|
+
* are not what it shows.
|
|
1033
|
+
*/
|
|
1034
|
+
getMaskedLayerImage(id: string): {
|
|
1035
|
+
url: string;
|
|
1036
|
+
bounds: CropBox;
|
|
1037
|
+
} | null;
|
|
1026
1038
|
/**
|
|
1027
1039
|
* Composites the layer stack in document space without a canvas (annotation layers need one
|
|
1028
1040
|
* and are left out): `rect` (default: the canvas) as RGBA, straight alpha. Crop, rotation and
|