@shotstack/shotstack-studio 2.16.3 → 2.18.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
@@ -1,4 +1,28 @@
1
1
  import { components } from '@shotstack/schemas';
2
+ import { operations } from '@shotstack/schemas';
3
+
4
+ /** Passed to the host handler for one generation. */
5
+ export declare interface AssetGenerationRequest {
6
+ clipId: string;
7
+ /** Snapshot of the clip's asset when generation started. */
8
+ asset: Record<string, unknown>;
9
+ /**
10
+ * Signalled when the SDK stops waiting for this generation — the clip was removed, or the
11
+ * edit was reloaded or disposed. Cancel the underlying request if the provider supports it;
12
+ * otherwise ignore it and let the request finish. Either way the SDK discards the result.
13
+ */
14
+ signal: AbortSignal;
15
+ }
16
+
17
+ /** Resolves with the URL of the generated asset. */
18
+ export declare type AssetGeneratorHandler = (request: AssetGenerationRequest) => Promise<{
19
+ url: string;
20
+ }>;
21
+
22
+ export declare interface AssetGeneratorOptions {
23
+ /** Model catalogue with each entry's option schema included. Entries without one are ignored. */
24
+ catalogue?: GenerationModelCatalogueResponse;
25
+ }
2
26
 
3
27
  /**
4
28
  * Payload passed to button click handlers.
@@ -154,6 +178,7 @@ export declare class Edit {
154
178
  private timingManager;
155
179
  private lumaMaskController;
156
180
  private playerReconciler;
181
+ private assetGenerator;
157
182
  private outputSettings;
158
183
  private selectionManager;
159
184
  private commandHistory;
@@ -167,6 +192,11 @@ export declare class Edit {
167
192
  private isBatchingEvents;
168
193
  private isExporting;
169
194
  private lastResolved;
195
+ /**
196
+ * Clip removal reaches the generator the way it reaches the reconciler: from resolved state,
197
+ * once the mutation is committed. Bookkeeping only — emitting from here re-enters the command queue.
198
+ */
199
+ private readonly onResolvedForGeneration;
170
200
  /**
171
201
  * Create an Edit instance from a template configuration.
172
202
  */
@@ -200,6 +230,15 @@ export declare class Edit {
200
230
  * returned object has no effect on the edit — use `updateClipById` to make changes.
201
231
  */
202
232
  getClipById(clipId: string): Clip | null;
233
+ /**
234
+ * Register the handler that turns a prompt-bearing clip into a generated asset.
235
+ *
236
+ * The SDK owns the pending, generating and failed states and writes the returned
237
+ * URL back to the clip; the host owns how generation happens and what a failure
238
+ * message says. Without a handler, no generate affordance is shown.
239
+ */
240
+ registerAssetGenerator(handler: AssetGeneratorHandler, options?: AssetGeneratorOptions): void;
241
+ private applyGeneratedSrc;
203
242
  /**
204
243
  * Look up the (trackIndex, clipIndex) position of a clip by its stable ID.
205
244
  */
@@ -434,6 +473,7 @@ export declare class Edit {
434
473
  private findBestContentMatch;
435
474
  private lastClipClick;
436
475
  private static readonly DoubleClickThresholdMs;
476
+ private setupGenerationListeners;
437
477
  private setupIntentListeners;
438
478
  }
439
479
 
@@ -567,6 +607,8 @@ declare type EditEventMap = {
567
607
 
568
608
  declare type EventPayloadMap<TPayload = any> = Record<string, TPayload>;
569
609
 
610
+ declare type GenerationModelCatalogueResponse = operations["getModels"]["responses"][200]["content"]["application/json"];
611
+
570
612
  declare type Listener<TPayload = any> = (payload: TPayload) => void;
571
613
 
572
614
  /**
@@ -639,6 +681,7 @@ export declare class Timeline {
639
681
  private readonly handlePlaybackPause;
640
682
  private readonly handleClipSelected;
641
683
  private readonly handleClipLoadFailed;
684
+ private readonly handleClipGeneration;
642
685
  private readonly handleClipUpdated;
643
686
  private readonly handleClipFocusChanged;
644
687
  private readonly handleRulerMouseMove;
@@ -715,7 +758,9 @@ export declare class UIController {
715
758
  /** Maximum total pixels for resolution picker (undefined = unlimited) */
716
759
  private readonly maxPixels?;
717
760
  private clipToolbar;
761
+ private generateToolbar;
718
762
  private toolbarMode;
763
+ private generationListeners;
719
764
  private currentAssetType;
720
765
  private currentTrackIndex;
721
766
  private currentClipIndex;
@@ -845,6 +890,15 @@ export declare class UIController {
845
890
  * Update toolbar visibility based on current mode and selection.
846
891
  */
847
892
  private updateToolbarVisibility;
893
+ private isGenerateModeAvailable;
894
+ /**
895
+ * The mode actually shown. `generate` is intent rather than state: selecting a clip
896
+ * that cannot be generated falls back to `asset` without discarding the choice, so
897
+ * returning to a generative clip lands back on generate.
898
+ */
899
+ private effectiveMode;
900
+ /** Queries the document because toolbar mode toggles mount outside this.container. */
901
+ private syncGenerateSegments;
848
902
  /**
849
903
  * Check if any toolbar is currently visible (clip is selected).
850
904
  */
@@ -1,4 +1,28 @@
1
1
  import { components } from '@shotstack/schemas';
2
+ import { operations } from '@shotstack/schemas';
3
+
4
+ /** Passed to the host handler for one generation. */
5
+ declare interface AssetGenerationRequest {
6
+ clipId: string;
7
+ /** Snapshot of the clip's asset when generation started. */
8
+ asset: Record<string, unknown>;
9
+ /**
10
+ * Signalled when the SDK stops waiting for this generation — the clip was removed, or the
11
+ * edit was reloaded or disposed. Cancel the underlying request if the provider supports it;
12
+ * otherwise ignore it and let the request finish. Either way the SDK discards the result.
13
+ */
14
+ signal: AbortSignal;
15
+ }
16
+
17
+ /** Resolves with the URL of the generated asset. */
18
+ declare type AssetGeneratorHandler = (request: AssetGenerationRequest) => Promise<{
19
+ url: string;
20
+ }>;
21
+
22
+ declare interface AssetGeneratorOptions {
23
+ /** Model catalogue with each entry's option schema included. Entries without one are ignored. */
24
+ catalogue?: GenerationModelCatalogueResponse;
25
+ }
2
26
 
3
27
  declare type Clip = components["schemas"]["Clip"];
4
28
 
@@ -43,6 +67,7 @@ export declare class Edit {
43
67
  private timingManager;
44
68
  private lumaMaskController;
45
69
  private playerReconciler;
70
+ private assetGenerator;
46
71
  private outputSettings;
47
72
  private selectionManager;
48
73
  private commandHistory;
@@ -56,6 +81,11 @@ export declare class Edit {
56
81
  private isBatchingEvents;
57
82
  private isExporting;
58
83
  private lastResolved;
84
+ /**
85
+ * Clip removal reaches the generator the way it reaches the reconciler: from resolved state,
86
+ * once the mutation is committed. Bookkeeping only — emitting from here re-enters the command queue.
87
+ */
88
+ private readonly onResolvedForGeneration;
59
89
  /**
60
90
  * Create an Edit instance from a template configuration.
61
91
  */
@@ -89,6 +119,15 @@ export declare class Edit {
89
119
  * returned object has no effect on the edit — use `updateClipById` to make changes.
90
120
  */
91
121
  getClipById(clipId: string): Clip | null;
122
+ /**
123
+ * Register the handler that turns a prompt-bearing clip into a generated asset.
124
+ *
125
+ * The SDK owns the pending, generating and failed states and writes the returned
126
+ * URL back to the clip; the host owns how generation happens and what a failure
127
+ * message says. Without a handler, no generate affordance is shown.
128
+ */
129
+ registerAssetGenerator(handler: AssetGeneratorHandler, options?: AssetGeneratorOptions): void;
130
+ private applyGeneratedSrc;
92
131
  /**
93
132
  * Look up the (trackIndex, clipIndex) position of a clip by its stable ID.
94
133
  */
@@ -323,6 +362,7 @@ export declare class Edit {
323
362
  private findBestContentMatch;
324
363
  private lastClipClick;
325
364
  private static readonly DoubleClickThresholdMs;
365
+ private setupGenerationListeners;
326
366
  private setupIntentListeners;
327
367
  }
328
368
 
@@ -461,6 +501,8 @@ declare class EventEmitter<TEventPayloadMap extends EventPayloadMap = EventPaylo
461
501
 
462
502
  declare type EventPayloadMap<TPayload = any> = Record<string, TPayload>;
463
503
 
504
+ declare type GenerationModelCatalogueResponse = operations["getModels"]["responses"][200]["content"]["application/json"];
505
+
464
506
  /**
465
507
  * Thrown by mutation methods (addClip, addTrack, addFont, setFonts) when a
466
508
  * referenced asset/font URL fails preflight.