@shotstack/shotstack-studio 2.17.0 → 2.19.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,5 @@
1
1
  import { components } from '@shotstack/schemas';
2
+ import { operations } from '@shotstack/schemas';
2
3
 
3
4
  /** Passed to the host handler for one generation. */
4
5
  export declare interface AssetGenerationRequest {
@@ -18,6 +19,11 @@ export declare type AssetGeneratorHandler = (request: AssetGenerationRequest) =>
18
19
  url: string;
19
20
  }>;
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
+ }
26
+
21
27
  /**
22
28
  * Payload passed to button click handlers.
23
29
  */
@@ -231,7 +237,17 @@ export declare class Edit {
231
237
  * URL back to the clip; the host owns how generation happens and what a failure
232
238
  * message says. Without a handler, no generate affordance is shown.
233
239
  */
234
- registerAssetGenerator(handler: AssetGeneratorHandler): void;
240
+ registerAssetGenerator(handler: AssetGeneratorHandler, options?: AssetGeneratorOptions): void;
241
+ /**
242
+ * Generate the asset for a prompt-bearing clip and write the result to it.
243
+ *
244
+ * Rejects only when no generator is registered or the clip has nothing to generate from.
245
+ * A generation failure resolves and surfaces as a `clip:generationFailed` event. Removing
246
+ * the clip, reloading the edit or disposing it resolves writing nothing, and no completed
247
+ * or failed event follows the `clip:generationStarted` already emitted. A second call while
248
+ * one is in flight for the same clip is ignored.
249
+ */
250
+ generateClip(clipId: string): Promise<void>;
235
251
  private applyGeneratedSrc;
236
252
  /**
237
253
  * Look up the (trackIndex, clipIndex) position of a clip by its stable ID.
@@ -491,6 +507,9 @@ declare const EditEvent: {
491
507
  readonly ClipCaptureStarted: "clip:captureStarted";
492
508
  readonly ClipCaptureCompleted: "clip:captureCompleted";
493
509
  readonly ClipCaptureFailed: "clip:captureFailed";
510
+ readonly ClipGenerationStarted: "clip:generationStarted";
511
+ readonly ClipGenerationCompleted: "clip:generationCompleted";
512
+ readonly ClipGenerationFailed: "clip:generationFailed";
494
513
  readonly ClipUnresolved: "clip:unresolved";
495
514
  readonly SelectionCleared: "selection:cleared";
496
515
  readonly EditChanged: "edit:changed";
@@ -547,6 +566,16 @@ declare type EditEventMap = {
547
566
  error: string;
548
567
  fallback: string;
549
568
  };
569
+ [EditEvent.ClipGenerationStarted]: {
570
+ clipId: string;
571
+ };
572
+ [EditEvent.ClipGenerationCompleted]: {
573
+ clipId: string;
574
+ };
575
+ [EditEvent.ClipGenerationFailed]: {
576
+ clipId: string;
577
+ error: string;
578
+ };
550
579
  [EditEvent.ClipUnresolved]: ClipLocation & {
551
580
  assetType: string;
552
581
  clipId: string;
@@ -601,6 +630,8 @@ declare type EditEventMap = {
601
630
 
602
631
  declare type EventPayloadMap<TPayload = any> = Record<string, TPayload>;
603
632
 
633
+ declare type GenerationModelCatalogueResponse = operations["getModels"]["responses"][200]["content"]["application/json"];
634
+
604
635
  declare type Listener<TPayload = any> = (payload: TPayload) => void;
605
636
 
606
637
  /**
@@ -1,4 +1,5 @@
1
1
  import { components } from '@shotstack/schemas';
2
+ import { operations } from '@shotstack/schemas';
2
3
 
3
4
  /** Passed to the host handler for one generation. */
4
5
  declare interface AssetGenerationRequest {
@@ -18,6 +19,11 @@ declare type AssetGeneratorHandler = (request: AssetGenerationRequest) => Promis
18
19
  url: string;
19
20
  }>;
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
+ }
26
+
21
27
  declare type Clip = components["schemas"]["Clip"];
22
28
 
23
29
  declare type ClipLocation = {
@@ -120,7 +126,17 @@ export declare class Edit {
120
126
  * URL back to the clip; the host owns how generation happens and what a failure
121
127
  * message says. Without a handler, no generate affordance is shown.
122
128
  */
123
- registerAssetGenerator(handler: AssetGeneratorHandler): void;
129
+ registerAssetGenerator(handler: AssetGeneratorHandler, options?: AssetGeneratorOptions): void;
130
+ /**
131
+ * Generate the asset for a prompt-bearing clip and write the result to it.
132
+ *
133
+ * Rejects only when no generator is registered or the clip has nothing to generate from.
134
+ * A generation failure resolves and surfaces as a `clip:generationFailed` event. Removing
135
+ * the clip, reloading the edit or disposing it resolves writing nothing, and no completed
136
+ * or failed event follows the `clip:generationStarted` already emitted. A second call while
137
+ * one is in flight for the same clip is ignored.
138
+ */
139
+ generateClip(clipId: string): Promise<void>;
124
140
  private applyGeneratedSrc;
125
141
  /**
126
142
  * Look up the (trackIndex, clipIndex) position of a clip by its stable ID.
@@ -377,6 +393,9 @@ declare const EditEvent: {
377
393
  readonly ClipCaptureStarted: "clip:captureStarted";
378
394
  readonly ClipCaptureCompleted: "clip:captureCompleted";
379
395
  readonly ClipCaptureFailed: "clip:captureFailed";
396
+ readonly ClipGenerationStarted: "clip:generationStarted";
397
+ readonly ClipGenerationCompleted: "clip:generationCompleted";
398
+ readonly ClipGenerationFailed: "clip:generationFailed";
380
399
  readonly ClipUnresolved: "clip:unresolved";
381
400
  readonly SelectionCleared: "selection:cleared";
382
401
  readonly EditChanged: "edit:changed";
@@ -433,6 +452,16 @@ declare type EditEventMap = {
433
452
  error: string;
434
453
  fallback: string;
435
454
  };
455
+ [EditEvent.ClipGenerationStarted]: {
456
+ clipId: string;
457
+ };
458
+ [EditEvent.ClipGenerationCompleted]: {
459
+ clipId: string;
460
+ };
461
+ [EditEvent.ClipGenerationFailed]: {
462
+ clipId: string;
463
+ error: string;
464
+ };
436
465
  [EditEvent.ClipUnresolved]: ClipLocation & {
437
466
  assetType: string;
438
467
  clipId: string;
@@ -495,6 +524,8 @@ declare class EventEmitter<TEventPayloadMap extends EventPayloadMap = EventPaylo
495
524
 
496
525
  declare type EventPayloadMap<TPayload = any> = Record<string, TPayload>;
497
526
 
527
+ declare type GenerationModelCatalogueResponse = operations["getModels"]["responses"][200]["content"]["application/json"];
528
+
498
529
  /**
499
530
  * Thrown by mutation methods (addClip, addTrack, addFont, setFonts) when a
500
531
  * referenced asset/font URL fails preflight.