@pixerate/editor 0.232.0 → 0.233.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 (47) hide show
  1. package/dist/animation-editor/compile.d.cts +3 -0
  2. package/dist/animation-editor/compile.d.ts +3 -0
  3. package/dist/animation-editor/controller.d.cts +67 -2
  4. package/dist/animation-editor/controller.d.ts +67 -2
  5. package/dist/animation-editor/edit.d.cts +1 -1
  6. package/dist/animation-editor/edit.d.ts +1 -1
  7. package/dist/animation-editor/evaluate.d.cts +8 -1
  8. package/dist/animation-editor/evaluate.d.ts +8 -1
  9. package/dist/animation-editor/index.cjs +1202 -371
  10. package/dist/animation-editor/index.d.cts +3 -0
  11. package/dist/animation-editor/index.d.ts +3 -0
  12. package/dist/animation-editor/index.js +1032 -201
  13. package/dist/animation-editor/issues.d.cts +28 -0
  14. package/dist/animation-editor/issues.d.ts +28 -0
  15. package/dist/animation-editor/layer-edit.d.cts +55 -0
  16. package/dist/animation-editor/layer-edit.d.ts +55 -0
  17. package/dist/animation-editor/layer-tools.d.cts +11 -0
  18. package/dist/animation-editor/layer-tools.d.ts +11 -0
  19. package/dist/animation-editor/layers.d.cts +166 -0
  20. package/dist/animation-editor/layers.d.ts +166 -0
  21. package/dist/animation-editor/parse.d.cts +2 -0
  22. package/dist/animation-editor/parse.d.ts +2 -0
  23. package/dist/animation-editor/types.d.cts +44 -1
  24. package/dist/animation-editor/types.d.ts +44 -1
  25. package/dist/canvas/index.cjs +10 -10
  26. package/dist/canvas/index.js +4 -4
  27. package/dist/chunk-6RZVFYGJ.cjs +255 -0
  28. package/dist/{chunk-RG4O6K2A.cjs → chunk-A7PQNIBX.cjs} +14 -14
  29. package/dist/{chunk-ERJA5CGT.cjs → chunk-DGWOGQJ5.cjs} +8 -1
  30. package/dist/{chunk-TYCJGFCF.js → chunk-EUKY4KFX.js} +8 -1
  31. package/dist/chunk-I277KJLQ.js +255 -0
  32. package/dist/{chunk-2K5TELHV.cjs → chunk-JAOSL334.cjs} +10 -10
  33. package/dist/{chunk-MUSZYMBX.js → chunk-TEFQISBY.js} +1 -1
  34. package/dist/{chunk-6QLTUGMO.js → chunk-WDDUPWVG.js} +1 -1
  35. package/dist/{chunk-A653N65Q.cjs → chunk-ZQIWBJGH.cjs} +7 -7
  36. package/dist/effects/index.cjs +114 -322
  37. package/dist/effects/index.js +23 -231
  38. package/dist/image-editor/index.cjs +16 -16
  39. package/dist/image-editor/index.js +4 -4
  40. package/dist/paint-editor/index.cjs +10 -10
  41. package/dist/paint-editor/index.js +5 -5
  42. package/dist/vector/index.cjs +6 -6
  43. package/dist/vector/index.js +1 -1
  44. package/dist/video-editor/index.cjs +339 -339
  45. package/dist/video-editor/index.js +5 -5
  46. package/package.json +1 -1
  47. package/dist/{chunk-PQYDJ2AV.js → chunk-SIK3LT6M.js} +16 -16
@@ -75,6 +75,9 @@ export interface MotionShotTiming {
75
75
  cameraIn?: string;
76
76
  /** The provider camera move it plays while it holds (`camera.during`), from `commandsEnd` to `end`. */
77
77
  cameraDuring?: string;
78
+ /** The provider transition into it (`transition.effect`), played from `start` to `transitionEnd`. Never on the first shot. */
79
+ transition?: string;
80
+ transitionEnd?: number;
78
81
  }
79
82
  export interface MotionCommandTiming {
80
83
  shot: string;
@@ -75,6 +75,9 @@ export interface MotionShotTiming {
75
75
  cameraIn?: string;
76
76
  /** The provider camera move it plays while it holds (`camera.during`), from `commandsEnd` to `end`. */
77
77
  cameraDuring?: string;
78
+ /** The provider transition into it (`transition.effect`), played from `start` to `transitionEnd`. Never on the first shot. */
79
+ transition?: string;
80
+ transitionEnd?: number;
78
81
  }
79
82
  export interface MotionCommandTiming {
80
83
  shot: string;
@@ -9,10 +9,12 @@ import { type MotionEdit, type MotionEditResult } from './edit.cjs';
9
9
  import { type MotionFrame, type MotionFrameOptions, type MotionSvgOptions } from './evaluate.cjs';
10
10
  import { type FlairEffectOptions, type FlairExportOptions } from './flair.cjs';
11
11
  import type { MotionIssue } from './issues.cjs';
12
- import { type MotionCamera, type MotionScene } from './types.cjs';
12
+ import { type MotionCamera, type MotionScene, type MotionShotLayer, type MotionShotTransition } from './types.cjs';
13
13
  import { EffectsSlot } from '../effects/helpers.cjs';
14
14
  import type { CameraMoveRole, CameraMoveSpec, EffectProvider, EffectSummary, EffectValue } from '../effects/types.cjs';
15
15
  import { type MotionNodePose, type MotionTake, type MotionTakeOptions, type MotionTakeResult, type MotionTakeSample } from './record.cjs';
16
+ import { MotionLayersEngine, type MotionLayerHost } from './layers.cjs';
17
+ import { type MotionShotLayerInfo, type MotionShotLayersInfo } from './layer-edit.cjs';
16
18
  import { type AppliedMotionEffect } from './effects.cjs';
17
19
  export interface AnimationEditorOptions {
18
20
  /** The scene to open (default: an empty one over a blank 800 × 450 artwork). */
@@ -30,6 +32,12 @@ export interface AnimationEditorOptions {
30
32
  * scenes keep the commands effects made. Change it later with `setEffectsProvider`.
31
33
  */
32
34
  effects?: EffectProvider | null;
35
+ /**
36
+ * Makes shot layer and transition pictures (see `MotionLayersEngine`). Default: the browser's
37
+ * canvas (`browserMotionLayerHost`), or none outside a browser, where effect layers are left
38
+ * out of frames and transitions crossfade.
39
+ */
40
+ layerHost?: MotionLayerHost | null;
33
41
  }
34
42
  /** What the effect edits return. */
35
43
  export type MotionEffectResult = {
@@ -54,6 +62,23 @@ export type MotionCameraMoveResult = {
54
62
  ok: false;
55
63
  error: string;
56
64
  };
65
+ /** What a shot layer or transition edit did: the layer it added or changed (when there is one) and the shot's layers and transition afterwards. */
66
+ export type MotionShotLayerResult = ({
67
+ ok: true;
68
+ layer?: MotionShotLayerInfo;
69
+ notes: string[];
70
+ } & MotionShotLayersInfo) | {
71
+ ok: false;
72
+ error: string;
73
+ };
74
+ /** A layer as `addShotLayer` takes it: its id is made when left out. */
75
+ export type MotionShotLayerInput = Omit<MotionShotLayer, 'id' | 'provider' | 'name'> & {
76
+ id?: string;
77
+ };
78
+ /** Changes to a layer: fields to set, and `null` to clear an optional one. */
79
+ export type MotionShotLayerChanges = {
80
+ [K in Exclude<keyof MotionShotLayer, 'id' | 'provider' | 'name'>]?: MotionShotLayer[K] | null;
81
+ };
57
82
  /** What is selected on the timeline: a shot, and optionally one of its commands. */
58
83
  export interface AnimationEditorSelection {
59
84
  shot: string;
@@ -133,6 +158,8 @@ export declare class AnimationEditorController {
133
158
  readonly player: AnimationPlayer;
134
159
  /** The effects provider slot (see `setEffectsProvider`). */
135
160
  readonly effects: EffectsSlot;
161
+ /** Renders shot layer and transition pictures for frames (see `MotionLayersEngine`). */
162
+ readonly layers: MotionLayersEngine;
136
163
  private scene;
137
164
  private issues;
138
165
  private selection;
@@ -256,8 +283,46 @@ export declare class AnimationEditorController {
256
283
  viewScene(): MotionScene;
257
284
  /** The scene at `time` (default: the playhead). */
258
285
  frame(time?: number, options?: MotionFrameOptions): MotionFrame;
259
- /** The scene at `time` (default: the playhead) as SVG. */
286
+ /**
287
+ * The scene at `time` (default: the playhead) as SVG. Shot layer and transition pictures that
288
+ * are not rendered yet are left out (a transition crossfades) and come in on a later frame;
289
+ * `toSvgExact` waits for them.
290
+ */
260
291
  toSvg(time?: number, options?: MotionSvgOptions & MotionOverlayOptions): string;
292
+ /** Like `toSvg`, once every shot layer and transition picture of the frame is rendered (or has failed). */
293
+ toSvgExact(time?: number, options?: MotionSvgOptions & MotionOverlayOptions): Promise<string>;
294
+ /** Every shot's layers and transition (or one shot's). Throws for an unknown shot, naming the shots. */
295
+ shotLayers(shot?: string): MotionShotLayersInfo[];
296
+ private noShot;
297
+ private noLayer;
298
+ private layerResult;
299
+ private layerEdit;
300
+ /**
301
+ * Adds a layer to a shot: a provider effect (a generator, filter, overlay or title), optionally
302
+ * applied to a `subject`, or a bare subject. Checked against the provider first; at `index`
303
+ * (default the top). One undo step. Returns the layer (with its id) and the shot's layers.
304
+ */
305
+ addShotLayer(shot: string, layer: MotionShotLayerInput, options?: {
306
+ index?: number;
307
+ }): Promise<MotionShotLayerResult>;
308
+ /** Changes a layer's fields (`null` clears an optional one); the result is checked against the provider. One undo step (`merge` folds a slider drag into one). */
309
+ updateShotLayer(layer: string, changes: MotionShotLayerChanges, options?: {
310
+ merge?: string;
311
+ }): Promise<MotionShotLayerResult>;
312
+ /** Removes a layer. One undo step. Works without a provider. */
313
+ removeShotLayer(layer: string): Promise<MotionShotLayerResult>;
314
+ /** Moves a layer to `index` in its shot (0 = bottom). One undo step. */
315
+ moveShotLayer(layer: string, index: number): Promise<MotionShotLayerResult>;
316
+ /**
317
+ * Sets the provider transition into a shot from the shot before (not the first shot). Checked
318
+ * against the provider (its use, preset and values; its length is written out). With no camera
319
+ * move in, the camera cuts. One undo step (`merge` folds a slider drag into one).
320
+ */
321
+ setShotTransition(shot: string, transition: MotionShotTransition, options?: {
322
+ merge?: string;
323
+ }): Promise<MotionShotLayerResult>;
324
+ /** Removes a shot's transition. One undo step. Works without a provider. */
325
+ clearShotTransition(shot: string): MotionShotLayerResult;
261
326
  /**
262
327
  * Starts recording a take: the playhead goes to where the take's shot will start (default:
263
328
  * the end of the scene) and plays on, and every `recordSample` (or stage gesture) is a value
@@ -9,10 +9,12 @@ import { type MotionEdit, type MotionEditResult } from './edit.js';
9
9
  import { type MotionFrame, type MotionFrameOptions, type MotionSvgOptions } from './evaluate.js';
10
10
  import { type FlairEffectOptions, type FlairExportOptions } from './flair.js';
11
11
  import type { MotionIssue } from './issues.js';
12
- import { type MotionCamera, type MotionScene } from './types.js';
12
+ import { type MotionCamera, type MotionScene, type MotionShotLayer, type MotionShotTransition } from './types.js';
13
13
  import { EffectsSlot } from '../effects/helpers.js';
14
14
  import type { CameraMoveRole, CameraMoveSpec, EffectProvider, EffectSummary, EffectValue } from '../effects/types.js';
15
15
  import { type MotionNodePose, type MotionTake, type MotionTakeOptions, type MotionTakeResult, type MotionTakeSample } from './record.js';
16
+ import { MotionLayersEngine, type MotionLayerHost } from './layers.js';
17
+ import { type MotionShotLayerInfo, type MotionShotLayersInfo } from './layer-edit.js';
16
18
  import { type AppliedMotionEffect } from './effects.js';
17
19
  export interface AnimationEditorOptions {
18
20
  /** The scene to open (default: an empty one over a blank 800 × 450 artwork). */
@@ -30,6 +32,12 @@ export interface AnimationEditorOptions {
30
32
  * scenes keep the commands effects made. Change it later with `setEffectsProvider`.
31
33
  */
32
34
  effects?: EffectProvider | null;
35
+ /**
36
+ * Makes shot layer and transition pictures (see `MotionLayersEngine`). Default: the browser's
37
+ * canvas (`browserMotionLayerHost`), or none outside a browser, where effect layers are left
38
+ * out of frames and transitions crossfade.
39
+ */
40
+ layerHost?: MotionLayerHost | null;
33
41
  }
34
42
  /** What the effect edits return. */
35
43
  export type MotionEffectResult = {
@@ -54,6 +62,23 @@ export type MotionCameraMoveResult = {
54
62
  ok: false;
55
63
  error: string;
56
64
  };
65
+ /** What a shot layer or transition edit did: the layer it added or changed (when there is one) and the shot's layers and transition afterwards. */
66
+ export type MotionShotLayerResult = ({
67
+ ok: true;
68
+ layer?: MotionShotLayerInfo;
69
+ notes: string[];
70
+ } & MotionShotLayersInfo) | {
71
+ ok: false;
72
+ error: string;
73
+ };
74
+ /** A layer as `addShotLayer` takes it: its id is made when left out. */
75
+ export type MotionShotLayerInput = Omit<MotionShotLayer, 'id' | 'provider' | 'name'> & {
76
+ id?: string;
77
+ };
78
+ /** Changes to a layer: fields to set, and `null` to clear an optional one. */
79
+ export type MotionShotLayerChanges = {
80
+ [K in Exclude<keyof MotionShotLayer, 'id' | 'provider' | 'name'>]?: MotionShotLayer[K] | null;
81
+ };
57
82
  /** What is selected on the timeline: a shot, and optionally one of its commands. */
58
83
  export interface AnimationEditorSelection {
59
84
  shot: string;
@@ -133,6 +158,8 @@ export declare class AnimationEditorController {
133
158
  readonly player: AnimationPlayer;
134
159
  /** The effects provider slot (see `setEffectsProvider`). */
135
160
  readonly effects: EffectsSlot;
161
+ /** Renders shot layer and transition pictures for frames (see `MotionLayersEngine`). */
162
+ readonly layers: MotionLayersEngine;
136
163
  private scene;
137
164
  private issues;
138
165
  private selection;
@@ -256,8 +283,46 @@ export declare class AnimationEditorController {
256
283
  viewScene(): MotionScene;
257
284
  /** The scene at `time` (default: the playhead). */
258
285
  frame(time?: number, options?: MotionFrameOptions): MotionFrame;
259
- /** The scene at `time` (default: the playhead) as SVG. */
286
+ /**
287
+ * The scene at `time` (default: the playhead) as SVG. Shot layer and transition pictures that
288
+ * are not rendered yet are left out (a transition crossfades) and come in on a later frame;
289
+ * `toSvgExact` waits for them.
290
+ */
260
291
  toSvg(time?: number, options?: MotionSvgOptions & MotionOverlayOptions): string;
292
+ /** Like `toSvg`, once every shot layer and transition picture of the frame is rendered (or has failed). */
293
+ toSvgExact(time?: number, options?: MotionSvgOptions & MotionOverlayOptions): Promise<string>;
294
+ /** Every shot's layers and transition (or one shot's). Throws for an unknown shot, naming the shots. */
295
+ shotLayers(shot?: string): MotionShotLayersInfo[];
296
+ private noShot;
297
+ private noLayer;
298
+ private layerResult;
299
+ private layerEdit;
300
+ /**
301
+ * Adds a layer to a shot: a provider effect (a generator, filter, overlay or title), optionally
302
+ * applied to a `subject`, or a bare subject. Checked against the provider first; at `index`
303
+ * (default the top). One undo step. Returns the layer (with its id) and the shot's layers.
304
+ */
305
+ addShotLayer(shot: string, layer: MotionShotLayerInput, options?: {
306
+ index?: number;
307
+ }): Promise<MotionShotLayerResult>;
308
+ /** Changes a layer's fields (`null` clears an optional one); the result is checked against the provider. One undo step (`merge` folds a slider drag into one). */
309
+ updateShotLayer(layer: string, changes: MotionShotLayerChanges, options?: {
310
+ merge?: string;
311
+ }): Promise<MotionShotLayerResult>;
312
+ /** Removes a layer. One undo step. Works without a provider. */
313
+ removeShotLayer(layer: string): Promise<MotionShotLayerResult>;
314
+ /** Moves a layer to `index` in its shot (0 = bottom). One undo step. */
315
+ moveShotLayer(layer: string, index: number): Promise<MotionShotLayerResult>;
316
+ /**
317
+ * Sets the provider transition into a shot from the shot before (not the first shot). Checked
318
+ * against the provider (its use, preset and values; its length is written out). With no camera
319
+ * move in, the camera cuts. One undo step (`merge` folds a slider drag into one).
320
+ */
321
+ setShotTransition(shot: string, transition: MotionShotTransition, options?: {
322
+ merge?: string;
323
+ }): Promise<MotionShotLayerResult>;
324
+ /** Removes a shot's transition. One undo step. Works without a provider. */
325
+ clearShotTransition(shot: string): MotionShotLayerResult;
261
326
  /**
262
327
  * Starts recording a take: the playhead goes to where the take's shot will start (default:
263
328
  * the end of the scene) and plays on, and every `recordSample` (or stage gesture) is a value
@@ -27,7 +27,7 @@ export type MotionEdit = {
27
27
  op: 'update_shot';
28
28
  shot: string;
29
29
  set?: Partial<MotionShot>;
30
- remove?: ('label' | 'camera' | 'hold' | 'speed' | 'at')[];
30
+ remove?: ('label' | 'camera' | 'hold' | 'speed' | 'at' | 'layers' | 'transition')[];
31
31
  } | {
32
32
  op: 'delete_shots';
33
33
  shots: string[];
@@ -27,7 +27,7 @@ export type MotionEdit = {
27
27
  op: 'update_shot';
28
28
  shot: string;
29
29
  set?: Partial<MotionShot>;
30
- remove?: ('label' | 'camera' | 'hold' | 'speed' | 'at')[];
30
+ remove?: ('label' | 'camera' | 'hold' | 'speed' | 'at' | 'layers' | 'transition')[];
31
31
  } | {
32
32
  op: 'delete_shots';
33
33
  shots: string[];
@@ -4,6 +4,7 @@ import { type VectorSvgExportOptions } from '../vector/svg.cjs';
4
4
  import type { VectorDocument } from '../vector/types.cjs';
5
5
  import { type MotionNodeEntry, type MotionTimeline } from './compile.cjs';
6
6
  import type { CameraView, EffectProvider } from '../effects/types.cjs';
7
+ import { type MotionLayerPictures } from './layers.cjs';
7
8
  import type { MotionRect, MotionScene } from './types.cjs';
8
9
  /**
9
10
  * A reveal clip (`wipe`, `iris`, `split`) in the units of the node's own box: 0–1 across it,
@@ -48,6 +49,12 @@ export interface MotionFrameOptions {
48
49
  /** An effects provider to play the shots' camera moves (`MotionCamera.in` / `during`); without one the camera eases between framings. */
49
50
  effects?: EffectProvider | null;
50
51
  }
52
+ export interface MotionLayerFrameOptions {
53
+ /** Where shot layer and transition pictures come from (the controller's `MotionLayersEngine`). Without it, effect layers are left out and transitions crossfade. */
54
+ layers?: MotionLayerPictures;
55
+ /** Play shot transitions (default true). Off draws each shot's own frame. */
56
+ transitions?: boolean;
57
+ }
51
58
  /** Id of the trim effect that draws strokes on. */
52
59
  export declare const MOTION_DRAW_EFFECT_ID = "~draw";
53
60
  /** A copy of the scene with each control's default colour replaced by its value (exact, case-insensitive matches). */
@@ -84,7 +91,7 @@ export declare function motionNodeClips(id: string, timeline: MotionTimeline, ti
84
91
  * function of time, so frames can be drawn in any order (and the same frames come out every time).
85
92
  */
86
93
  export declare function motionFrameAt(scene: MotionScene, time: number, options?: MotionFrameOptions): MotionFrame;
87
- export interface MotionSvgOptions extends MotionFrameOptions, VectorSvgExportOptions {
94
+ export interface MotionSvgOptions extends MotionFrameOptions, MotionLayerFrameOptions, VectorSvgExportOptions {
88
95
  }
89
96
  /** A clip shape's SVG attributes. */
90
97
  export declare function motionClipAttrs(clip: MotionClipShape): Record<string, number>;
@@ -4,6 +4,7 @@ import { type VectorSvgExportOptions } from '../vector/svg.js';
4
4
  import type { VectorDocument } from '../vector/types.js';
5
5
  import { type MotionNodeEntry, type MotionTimeline } from './compile.js';
6
6
  import type { CameraView, EffectProvider } from '../effects/types.js';
7
+ import { type MotionLayerPictures } from './layers.js';
7
8
  import type { MotionRect, MotionScene } from './types.js';
8
9
  /**
9
10
  * A reveal clip (`wipe`, `iris`, `split`) in the units of the node's own box: 0–1 across it,
@@ -48,6 +49,12 @@ export interface MotionFrameOptions {
48
49
  /** An effects provider to play the shots' camera moves (`MotionCamera.in` / `during`); without one the camera eases between framings. */
49
50
  effects?: EffectProvider | null;
50
51
  }
52
+ export interface MotionLayerFrameOptions {
53
+ /** Where shot layer and transition pictures come from (the controller's `MotionLayersEngine`). Without it, effect layers are left out and transitions crossfade. */
54
+ layers?: MotionLayerPictures;
55
+ /** Play shot transitions (default true). Off draws each shot's own frame. */
56
+ transitions?: boolean;
57
+ }
51
58
  /** Id of the trim effect that draws strokes on. */
52
59
  export declare const MOTION_DRAW_EFFECT_ID = "~draw";
53
60
  /** A copy of the scene with each control's default colour replaced by its value (exact, case-insensitive matches). */
@@ -84,7 +91,7 @@ export declare function motionNodeClips(id: string, timeline: MotionTimeline, ti
84
91
  * function of time, so frames can be drawn in any order (and the same frames come out every time).
85
92
  */
86
93
  export declare function motionFrameAt(scene: MotionScene, time: number, options?: MotionFrameOptions): MotionFrame;
87
- export interface MotionSvgOptions extends MotionFrameOptions, VectorSvgExportOptions {
94
+ export interface MotionSvgOptions extends MotionFrameOptions, MotionLayerFrameOptions, VectorSvgExportOptions {
88
95
  }
89
96
  /** A clip shape's SVG attributes. */
90
97
  export declare function motionClipAttrs(clip: MotionClipShape): Record<string, number>;