@shotstack/shotstack-studio 2.10.1 → 2.11.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/index.d.ts CHANGED
@@ -47,6 +47,13 @@ export declare class Canvas {
47
47
  resize(): void;
48
48
  setZoom(zoom: number): void;
49
49
  getZoom(): number;
50
+ /**
51
+ * Capture the current canvas content as a base64-encoded data URL.
52
+ */
53
+ captureFrame(options?: {
54
+ format?: "png" | "jpeg" | "webp";
55
+ quality?: number;
56
+ }): Promise<string>;
50
57
  /**
51
58
  * Sync overlay container and toolbar positions after content transforms change.
52
59
  * Single point of update for all position-dependent UI elements.
@@ -155,8 +162,37 @@ export declare class Edit {
155
162
  */
156
163
  loadEdit(edit: Edit_2): Promise<void>;
157
164
  private loadSoundtrack;
158
- getEdit(): Edit_2;
159
- addClip(trackIdx: number, clip: Clip): void | Promise<void>;
165
+ /**
166
+ * Serialise the current edit to plain JSON.
167
+ */
168
+ getEdit(options?: {
169
+ includeIds?: boolean;
170
+ }): Edit_2;
171
+ /**
172
+ * Look up a clip by its stable ID.
173
+ * @returns The clip or null if no clip with that ID exists.
174
+ */
175
+ getClipById(clipId: string): Clip | null;
176
+ /**
177
+ * Look up the (trackIndex, clipIndex) position of a clip by its stable ID.
178
+ */
179
+ getClipPositionById(clipId: string): {
180
+ trackIndex: number;
181
+ clipIndex: number;
182
+ } | null;
183
+ /**
184
+ * Patch fields on a clip identified by stable ID.
185
+ */
186
+ updateClipById(clipId: string, updates: Partial<Clip>): Promise<void>;
187
+ /**
188
+ * Remove a clip identified by stable ID.
189
+ */
190
+ deleteClipById(clipId: string): Promise<void>;
191
+ /**
192
+ * Move a clip identified by stable ID to a different track and/or start time.
193
+ */
194
+ moveClipById(clipId: string, toTrackIndex: number, newStart?: Seconds): Promise<void>;
195
+ addClip(trackIdx: number, clip: Clip): Promise<void>;
160
196
  addSvgClip(svgMarkup: string, opts?: {
161
197
  trackIndex?: number;
162
198
  start?: Seconds;
@@ -183,6 +219,16 @@ export declare class Edit {
183
219
  canDeleteClip(trackIdx: number, clipIdx: number): boolean;
184
220
  deleteClip(trackIdx: number, clipIdx: number): Promise<void>;
185
221
  addTrack(trackIdx: number, track: Track): Promise<void>;
222
+ /**
223
+ * Add a font to the timeline.
224
+ */
225
+ addFont(src: string): Promise<void>;
226
+ /**
227
+ * Replace timeline fonts wholesale.
228
+ */
229
+ setFonts(fonts: Array<{
230
+ src: string;
231
+ }>): Promise<void>;
186
232
  /**
187
233
  * Auto-link rich-caption clips to the first eligible source clip.
188
234
  * If an alias reference in the caption's src can't be resolved, link it automatically.
@@ -197,6 +243,10 @@ export declare class Edit {
197
243
  */
198
244
  private addCommandToHistory;
199
245
  updateClip(trackIdx: number, clipIdx: number, updates: Partial<Clip>): Promise<void>;
246
+ /**
247
+ * HEAD-check every external http(s) URL in a payload
248
+ */
249
+ private preflightAssetUrls;
200
250
  /**
201
251
  * Handle command result - only add to history if successful.
202
252
  */
@@ -253,6 +303,27 @@ export declare class Edit {
253
303
  setOutputResolution(resolution: string): Promise<void>;
254
304
  getOutputResolution(): string | undefined;
255
305
  setOutputAspectRatio(aspectRatio: string): Promise<void>;
306
+ /**
307
+ * Capture the current canvas as a base64 data URL.
308
+ */
309
+ captureFrame(options?: {
310
+ time?: number;
311
+ format?: "png" | "jpeg" | "webp";
312
+ quality?: number;
313
+ }): Promise<string>;
314
+ /**
315
+ * Atomically apply multiple output settings.
316
+ */
317
+ setOutput(options: {
318
+ size?: {
319
+ width: number;
320
+ height: number;
321
+ };
322
+ resolution?: string;
323
+ format?: string;
324
+ fps?: number;
325
+ aspectRatio?: string;
326
+ }): Promise<void>;
256
327
  getOutputAspectRatio(): string | undefined;
257
328
  setTimelineBackground(color: string): Promise<void>;
258
329
  private setTimelineBackgroundInternal;
@@ -67,8 +67,37 @@ export declare class Edit {
67
67
  */
68
68
  loadEdit(edit: Edit_2): Promise<void>;
69
69
  private loadSoundtrack;
70
- getEdit(): Edit_2;
71
- addClip(trackIdx: number, clip: Clip): void | Promise<void>;
70
+ /**
71
+ * Serialise the current edit to plain JSON.
72
+ */
73
+ getEdit(options?: {
74
+ includeIds?: boolean;
75
+ }): Edit_2;
76
+ /**
77
+ * Look up a clip by its stable ID.
78
+ * @returns The clip or null if no clip with that ID exists.
79
+ */
80
+ getClipById(clipId: string): Clip | null;
81
+ /**
82
+ * Look up the (trackIndex, clipIndex) position of a clip by its stable ID.
83
+ */
84
+ getClipPositionById(clipId: string): {
85
+ trackIndex: number;
86
+ clipIndex: number;
87
+ } | null;
88
+ /**
89
+ * Patch fields on a clip identified by stable ID.
90
+ */
91
+ updateClipById(clipId: string, updates: Partial<Clip>): Promise<void>;
92
+ /**
93
+ * Remove a clip identified by stable ID.
94
+ */
95
+ deleteClipById(clipId: string): Promise<void>;
96
+ /**
97
+ * Move a clip identified by stable ID to a different track and/or start time.
98
+ */
99
+ moveClipById(clipId: string, toTrackIndex: number, newStart?: Seconds): Promise<void>;
100
+ addClip(trackIdx: number, clip: Clip): Promise<void>;
72
101
  addSvgClip(svgMarkup: string, opts?: {
73
102
  trackIndex?: number;
74
103
  start?: Seconds;
@@ -95,6 +124,16 @@ export declare class Edit {
95
124
  canDeleteClip(trackIdx: number, clipIdx: number): boolean;
96
125
  deleteClip(trackIdx: number, clipIdx: number): Promise<void>;
97
126
  addTrack(trackIdx: number, track: Track): Promise<void>;
127
+ /**
128
+ * Add a font to the timeline.
129
+ */
130
+ addFont(src: string): Promise<void>;
131
+ /**
132
+ * Replace timeline fonts wholesale.
133
+ */
134
+ setFonts(fonts: Array<{
135
+ src: string;
136
+ }>): Promise<void>;
98
137
  /**
99
138
  * Auto-link rich-caption clips to the first eligible source clip.
100
139
  * If an alias reference in the caption's src can't be resolved, link it automatically.
@@ -109,6 +148,10 @@ export declare class Edit {
109
148
  */
110
149
  private addCommandToHistory;
111
150
  updateClip(trackIdx: number, clipIdx: number, updates: Partial<Clip>): Promise<void>;
151
+ /**
152
+ * HEAD-check every external http(s) URL in a payload
153
+ */
154
+ private preflightAssetUrls;
112
155
  /**
113
156
  * Handle command result - only add to history if successful.
114
157
  */
@@ -165,6 +208,27 @@ export declare class Edit {
165
208
  setOutputResolution(resolution: string): Promise<void>;
166
209
  getOutputResolution(): string | undefined;
167
210
  setOutputAspectRatio(aspectRatio: string): Promise<void>;
211
+ /**
212
+ * Capture the current canvas as a base64 data URL.
213
+ */
214
+ captureFrame(options?: {
215
+ time?: number;
216
+ format?: "png" | "jpeg" | "webp";
217
+ quality?: number;
218
+ }): Promise<string>;
219
+ /**
220
+ * Atomically apply multiple output settings.
221
+ */
222
+ setOutput(options: {
223
+ size?: {
224
+ width: number;
225
+ height: number;
226
+ };
227
+ resolution?: string;
228
+ format?: string;
229
+ fps?: number;
230
+ aspectRatio?: string;
231
+ }): Promise<void>;
168
232
  getOutputAspectRatio(): string | undefined;
169
233
  setTimelineBackground(color: string): Promise<void>;
170
234
  private setTimelineBackgroundInternal;
@@ -313,6 +377,18 @@ declare class EventEmitter<TEventPayloadMap extends EventPayloadMap = EventPaylo
313
377
 
314
378
  declare type EventPayloadMap<TPayload = any> = Record<string, TPayload>;
315
379
 
380
+ /**
381
+ * Thrown by mutation methods (addClip, addTrack, addFont, setFonts) when a
382
+ * referenced asset/font URL fails preflight.
383
+ */
384
+ export declare class InvalidAssetUrlError extends Error {
385
+ readonly code: "INVALID_ASSET_URL";
386
+ readonly url: string;
387
+ readonly status: number | undefined;
388
+ readonly reason: string;
389
+ constructor(url: string, status: number | undefined, reason: string);
390
+ }
391
+
316
392
  declare type Listener<TPayload = any> = (payload: TPayload) => void;
317
393
 
318
394
  /**