@shotstack/shotstack-studio 2.16.2 → 2.17.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,5 +1,23 @@
1
1
  import { components } from '@shotstack/schemas';
2
2
 
3
+ /** Passed to the host handler for one generation. */
4
+ export declare interface AssetGenerationRequest {
5
+ clipId: string;
6
+ /** Snapshot of the clip's asset when generation started. */
7
+ asset: Record<string, unknown>;
8
+ /**
9
+ * Signalled when the SDK stops waiting for this generation — the clip was removed, or the
10
+ * edit was reloaded or disposed. Cancel the underlying request if the provider supports it;
11
+ * otherwise ignore it and let the request finish. Either way the SDK discards the result.
12
+ */
13
+ signal: AbortSignal;
14
+ }
15
+
16
+ /** Resolves with the URL of the generated asset. */
17
+ export declare type AssetGeneratorHandler = (request: AssetGenerationRequest) => Promise<{
18
+ url: string;
19
+ }>;
20
+
3
21
  /**
4
22
  * Payload passed to button click handlers.
5
23
  */
@@ -154,6 +172,7 @@ export declare class Edit {
154
172
  private timingManager;
155
173
  private lumaMaskController;
156
174
  private playerReconciler;
175
+ private assetGenerator;
157
176
  private outputSettings;
158
177
  private selectionManager;
159
178
  private commandHistory;
@@ -167,6 +186,11 @@ export declare class Edit {
167
186
  private isBatchingEvents;
168
187
  private isExporting;
169
188
  private lastResolved;
189
+ /**
190
+ * Clip removal reaches the generator the way it reaches the reconciler: from resolved state,
191
+ * once the mutation is committed. Bookkeeping only — emitting from here re-enters the command queue.
192
+ */
193
+ private readonly onResolvedForGeneration;
170
194
  /**
171
195
  * Create an Edit instance from a template configuration.
172
196
  */
@@ -200,6 +224,15 @@ export declare class Edit {
200
224
  * returned object has no effect on the edit — use `updateClipById` to make changes.
201
225
  */
202
226
  getClipById(clipId: string): Clip | null;
227
+ /**
228
+ * Register the handler that turns a prompt-bearing clip into a generated asset.
229
+ *
230
+ * The SDK owns the pending, generating and failed states and writes the returned
231
+ * URL back to the clip; the host owns how generation happens and what a failure
232
+ * message says. Without a handler, no generate affordance is shown.
233
+ */
234
+ registerAssetGenerator(handler: AssetGeneratorHandler): void;
235
+ private applyGeneratedSrc;
203
236
  /**
204
237
  * Look up the (trackIndex, clipIndex) position of a clip by its stable ID.
205
238
  */
@@ -434,6 +467,7 @@ export declare class Edit {
434
467
  private findBestContentMatch;
435
468
  private lastClipClick;
436
469
  private static readonly DoubleClickThresholdMs;
470
+ private setupGenerationListeners;
437
471
  private setupIntentListeners;
438
472
  }
439
473
 
@@ -639,6 +673,7 @@ export declare class Timeline {
639
673
  private readonly handlePlaybackPause;
640
674
  private readonly handleClipSelected;
641
675
  private readonly handleClipLoadFailed;
676
+ private readonly handleClipGeneration;
642
677
  private readonly handleClipUpdated;
643
678
  private readonly handleClipFocusChanged;
644
679
  private readonly handleRulerMouseMove;
@@ -715,7 +750,9 @@ export declare class UIController {
715
750
  /** Maximum total pixels for resolution picker (undefined = unlimited) */
716
751
  private readonly maxPixels?;
717
752
  private clipToolbar;
753
+ private generateToolbar;
718
754
  private toolbarMode;
755
+ private generationListeners;
719
756
  private currentAssetType;
720
757
  private currentTrackIndex;
721
758
  private currentClipIndex;
@@ -845,6 +882,15 @@ export declare class UIController {
845
882
  * Update toolbar visibility based on current mode and selection.
846
883
  */
847
884
  private updateToolbarVisibility;
885
+ private isGenerateModeAvailable;
886
+ /**
887
+ * The mode actually shown. `generate` is intent rather than state: selecting a clip
888
+ * that cannot be generated falls back to `asset` without discarding the choice, so
889
+ * returning to a generative clip lands back on generate.
890
+ */
891
+ private effectiveMode;
892
+ /** Queries the document because toolbar mode toggles mount outside this.container. */
893
+ private syncGenerateSegments;
848
894
  /**
849
895
  * Check if any toolbar is currently visible (clip is selected).
850
896
  */
@@ -1,5 +1,23 @@
1
1
  import { components } from '@shotstack/schemas';
2
2
 
3
+ /** Passed to the host handler for one generation. */
4
+ declare interface AssetGenerationRequest {
5
+ clipId: string;
6
+ /** Snapshot of the clip's asset when generation started. */
7
+ asset: Record<string, unknown>;
8
+ /**
9
+ * Signalled when the SDK stops waiting for this generation — the clip was removed, or the
10
+ * edit was reloaded or disposed. Cancel the underlying request if the provider supports it;
11
+ * otherwise ignore it and let the request finish. Either way the SDK discards the result.
12
+ */
13
+ signal: AbortSignal;
14
+ }
15
+
16
+ /** Resolves with the URL of the generated asset. */
17
+ declare type AssetGeneratorHandler = (request: AssetGenerationRequest) => Promise<{
18
+ url: string;
19
+ }>;
20
+
3
21
  declare type Clip = components["schemas"]["Clip"];
4
22
 
5
23
  declare type ClipLocation = {
@@ -43,6 +61,7 @@ export declare class Edit {
43
61
  private timingManager;
44
62
  private lumaMaskController;
45
63
  private playerReconciler;
64
+ private assetGenerator;
46
65
  private outputSettings;
47
66
  private selectionManager;
48
67
  private commandHistory;
@@ -56,6 +75,11 @@ export declare class Edit {
56
75
  private isBatchingEvents;
57
76
  private isExporting;
58
77
  private lastResolved;
78
+ /**
79
+ * Clip removal reaches the generator the way it reaches the reconciler: from resolved state,
80
+ * once the mutation is committed. Bookkeeping only — emitting from here re-enters the command queue.
81
+ */
82
+ private readonly onResolvedForGeneration;
59
83
  /**
60
84
  * Create an Edit instance from a template configuration.
61
85
  */
@@ -89,6 +113,15 @@ export declare class Edit {
89
113
  * returned object has no effect on the edit — use `updateClipById` to make changes.
90
114
  */
91
115
  getClipById(clipId: string): Clip | null;
116
+ /**
117
+ * Register the handler that turns a prompt-bearing clip into a generated asset.
118
+ *
119
+ * The SDK owns the pending, generating and failed states and writes the returned
120
+ * URL back to the clip; the host owns how generation happens and what a failure
121
+ * message says. Without a handler, no generate affordance is shown.
122
+ */
123
+ registerAssetGenerator(handler: AssetGeneratorHandler): void;
124
+ private applyGeneratedSrc;
92
125
  /**
93
126
  * Look up the (trackIndex, clipIndex) position of a clip by its stable ID.
94
127
  */
@@ -323,6 +356,7 @@ export declare class Edit {
323
356
  private findBestContentMatch;
324
357
  private lastClipClick;
325
358
  private static readonly DoubleClickThresholdMs;
359
+ private setupGenerationListeners;
326
360
  private setupIntentListeners;
327
361
  }
328
362