@canva/intents 2.1.3-beta.0 → 2.2.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 (36) hide show
  1. package/CHANGELOG.md +23 -11
  2. package/asset/index.d.ts +1 -1
  3. package/content/index.d.ts +1510 -1
  4. package/data/index.d.ts +1229 -1
  5. package/design/index.d.ts +41 -1
  6. package/index.d.ts +2895 -1
  7. package/lib/cjs/sdk/intents/asset/index.js +1 -15
  8. package/lib/cjs/sdk/intents/fake/{create_beta.js → create.js} +6 -9
  9. package/lib/cjs/sdk/intents/index.js +4 -2
  10. package/lib/cjs/sdk/intents/test/index.js +14 -13
  11. package/lib/cjs/sdk/intents/version.js +1 -1
  12. package/lib/esm/sdk/intents/asset/index.js +1 -1
  13. package/lib/esm/sdk/intents/fake/{create_beta.js → create.js} +4 -7
  14. package/lib/esm/sdk/intents/index.js +3 -1
  15. package/lib/esm/sdk/intents/test/index.js +9 -1
  16. package/lib/esm/sdk/intents/version.js +1 -1
  17. package/package.json +23 -23
  18. package/test/index.d.ts +11 -1
  19. package/asset/beta.d.ts +0 -190
  20. package/beta.d.ts +0 -2995
  21. package/content/beta.d.ts +0 -1606
  22. package/data/beta.d.ts +0 -1229
  23. package/design/beta.d.ts +0 -41
  24. package/lib/cjs/sdk/intents/asset/beta.js +0 -14
  25. package/lib/cjs/sdk/intents/beta.js +0 -20
  26. package/lib/cjs/sdk/intents/content/beta.js +0 -20
  27. package/lib/cjs/sdk/intents/data/beta.js +0 -20
  28. package/lib/cjs/sdk/intents/design/beta.js +0 -20
  29. package/lib/cjs/sdk/intents/test/beta.js +0 -19
  30. package/lib/esm/sdk/intents/asset/beta.js +0 -4
  31. package/lib/esm/sdk/intents/beta.js +0 -3
  32. package/lib/esm/sdk/intents/content/beta.js +0 -3
  33. package/lib/esm/sdk/intents/data/beta.js +0 -3
  34. package/lib/esm/sdk/intents/design/beta.js +0 -3
  35. package/lib/esm/sdk/intents/test/beta.js +0 -9
  36. package/test/beta.d.ts +0 -11
package/content/beta.d.ts DELETED
@@ -1,1606 +0,0 @@
1
- /**
2
- * @public
3
- * {@link PublishContentError} indicating a custom error occurred in your app's implementation.
4
- *
5
- * Return this for application-specific errors such as:
6
- *
7
- * - Validation failures
8
- * - Authentication errors
9
- * - Rate limiting
10
- * - Platform-specific restrictions
11
- *
12
- * @example Returning custom error with message
13
- * ```ts
14
- * if (userQuotaExceeded) {
15
- * return {
16
- * status: 'app_error',
17
- * message: 'You have reached your monthly publish limit. Please upgrade your plan.'
18
- * };
19
- * }
20
- * ```
21
- */
22
- export declare type AppError = {
23
- status: 'app_error';
24
- /**
25
- * (required) The raw error message, for logging purposes. It will not display in the UI.
26
- * To display custom error messages in the UI use `localizedMessageId`.
27
- *
28
- * This should typically be the javascript error.message or a REST JSON error message
29
- * body passed without modification.
30
- *
31
- * WARNING: Do not include personally identifiable information (PII) in this
32
- * message, such as names, emails, usernames, etc.
33
- */
34
- message: string;
35
- /**
36
- * (optional) Message ID of the translated error message that will be
37
- * displayed to the user. The message ID should be present and uploaded in
38
- * your translation file. If omitted, Canva will display a generic error
39
- * message.
40
- */
41
- localizedMessageId?: string;
42
- /** HTTP status code, if applicable */
43
- httpCode?: number;
44
- /**
45
- * Used only by app developer. Canva does not use this value. Use this to pass
46
- * additional information like JSON to your settings frame.
47
- */
48
- appDefinedPayload?: string;
49
- /**
50
- * (optional) Source of the error if it relates to a component on the Canva
51
- * UI. When present, the error may render near a relevant Canva component.
52
- * When omitted, the cause is considered unspecified or "generic".
53
- */
54
- errorCause?: ErrorCause;
55
- };
56
-
57
- /**
58
- * @public
59
- * Base file requirement interface.
60
- */
61
- declare interface BaseFileRequirement {
62
- /**
63
- * File format for this requirement.
64
- */
65
- format: PublishFileFormat;
66
-
67
- }
68
-
69
- /**
70
- * @public
71
- * Base interface for exported files.
72
- */
73
- export declare interface BaseOutputFile {
74
- /**
75
- * File format.
76
- */
77
- format: PublishFileFormat;
78
- /**
79
- * URL to download the exported file.
80
- *
81
- * Your app should download from this URL and upload to your platform.
82
- */
83
- url: string;
84
- /**
85
- * Metadata about the source content used to create this exported file.
86
- */
87
- contentMetadata: ContentMetadata;
88
- }
89
-
90
- /**
91
- * @public
92
- * Base interface for all preview types.
93
- *
94
- * Contains common properties shared by all preview types.
95
- */
96
- export declare interface BasePreview {
97
- /**
98
- * Unique identifier for this preview.
99
- *
100
- * Use this ID with `requestPreviewUpgrade` to upgrade video thumbnails.
101
- */
102
- id: string;
103
- /**
104
- * Type of media in this preview.
105
- */
106
- kind: PreviewKind;
107
- /**
108
- * Current state of the preview.
109
- */
110
- status: PreviewStatus;
111
- }
112
-
113
- /**
114
- * @beta
115
- * Beta preview in various states.
116
- */
117
- declare type BetaPreview = ImagePreview | VideoPreview | DocumentPreview | EmailPreview;
118
- export { BetaPreview }
119
- export { BetaPreview as Preview }
120
-
121
- /**
122
- * @beta
123
- * Preview media for a specific media slot.
124
- *
125
- * Contains preview URLs and metadata for images or videos in the design.
126
- * Made for beta preview types.
127
- */
128
- declare type BetaPreviewMedia = {
129
- mediaSlotId: string;
130
- previews: BetaPreview[];
131
- };
132
- export { BetaPreviewMedia }
133
- export { BetaPreviewMedia as PreviewMedia }
134
-
135
- /**
136
- * @public
137
- * Metadata about the source content used to create an exported file.
138
- */
139
- export declare type ContentMetadata = DesignContentMetadata;
140
-
141
- /**
142
- * @public
143
- * Main interface for implementing the ContentPublisher intent.
144
- *
145
- * Implementing the ContentPublisher intent enables apps to publish contents to external platforms.
146
- * This allows users to configure publish settings, preview their designs, and share with others.
147
- *
148
- * The publishing flow follows this process:
149
- *
150
- * 1. User initiates publish action
151
- * 2. Your app provides publish configuration via `getPublishConfiguration`
152
- * 3. User selects an output type
153
- * 4. Your app renders settings UI via `renderSettingsUi`
154
- * 5. Your app renders preview UI via `renderPreviewUi`
155
- * 6. User reviews settings and preview
156
- * 7. Your app publishes the content via `publishContent`
157
- */
158
- export declare type ContentPublisherIntent = {
159
- /**
160
- * Provides the configuration for the publishing platform.
161
- *
162
- * This action is called when the user initiates the publish flow and needs to
163
- * select an output type for the target platform.
164
- *
165
- * Use this to define different publishing configurations for your platform,
166
- * such as social media posts, videos, or other output types.
167
- *
168
- * @returns A promise resolving to the publish configuration or an error
169
- *
170
- * @example Defining publish configuration for a social media platform
171
- * ```ts
172
- * import type { GetPublishConfigurationResponse } from '@canva/intents/content';
173
- *
174
- * async function getPublishConfiguration(): Promise<GetPublishConfigurationResponse> {
175
- * return {
176
- * status: 'completed',
177
- * outputTypes: [
178
- * {
179
- * id: 'instagram_post',
180
- * displayName: 'Instagram Post',
181
- * mediaSlots: [
182
- * {
183
- * id: 'main_image',
184
- * displayName: 'Post Image',
185
- * fileCount: { min: 1, max: 10 },
186
- * accepts: {
187
- * image: { format: 'jpg', aspectRatio: { min: 0.8, max: 1.91 } }
188
- * }
189
- * }
190
- * ]
191
- * }
192
- * ]
193
- * };
194
- * }
195
- * ```
196
- */
197
- getPublishConfiguration: () => Promise<GetPublishConfigurationResponse>;
198
-
199
- /**
200
- * Renders a user interface for configuring publish settings.
201
- *
202
- * This action is called after the user selects an output type. Your UI should
203
- * allow users to configure platform-specific settings such as captions, tags,
204
- * privacy settings, or publishing destinations.
205
- *
206
- * Use the `updatePublishSettings` callback to save user settings and validate them.
207
- * Settings are stored in the `publishRef` string (maximum 5KB).
208
- *
209
- * @param request - Configuration and callbacks for the publish settings UI.
210
- *
211
- * @example Rendering a settings UI with publish configuration
212
- * ```ts
213
- * import { createRoot } from 'react-dom/client';
214
- * import type { RenderSettingsUiRequest } from '@canva/intents/content';
215
- *
216
- * function renderSettingsUi(request: RenderSettingsUiRequest): void {
217
- * const SettingsUiApp = () => (
218
- * <AppUiProvider>
219
- * <SettingsUi request={request} />
220
- * </AppUiProvider>
221
- * );
222
- *
223
- * createRoot().render(<SettingsUiApp />)
224
- * }
225
- * ```
226
- */
227
- renderSettingsUi: (request: RenderSettingsUiRequest) => void;
228
- /**
229
- * Renders a user interface for previewing the content.
230
- *
231
- * This action is called after the settings UI is rendered. Your UI should display
232
- * a preview of how the content will appear on the target platform.
233
- *
234
- * Previews update dynamically as users modify their content or settings. For videos,
235
- * start with lightweight thumbnails and use `requestPreviewUpgrade` to load full
236
- * video previews on demand to optimize performance.
237
- *
238
- * @param request - Configuration and callbacks for the preview UI.
239
- *
240
- * @example Rendering a preview UI with video optimization
241
- * ```ts
242
- * import { createRoot } from 'react-dom/client';
243
- * import type { RenderPreviewUiRequest } from '@canva/intents/content';
244
- *
245
- * function renderPreviewUi(request: RenderPreviewUiRequest): void {
246
- * const PreviewUiApp = () => (
247
- * <AppUiProvider>
248
- * <PreviewUi request={request} />
249
- * </AppUiProvider>
250
- * );
251
- *
252
- * createRoot().render(<PreviewUiApp />)
253
- * }
254
- * ```
255
- */
256
- renderPreviewUi: (request: RenderPreviewUiRequest) => void;
257
- /**
258
- * Publishes the content to the external platform.
259
- *
260
- * This action is called when the user confirms the publish action after reviewing
261
- * settings and preview. Your implementation should send the exported files
262
- * to your platform's API.
263
- *
264
- * The `outputMedia` contains production-ready files that match the requirements
265
- * specified in your output types. The `publishRef` contains the user's settings
266
- * from the settings UI.
267
- *
268
- * @param request - Parameters for the publish operation.
269
- * @returns A promise resolving to either a successful result with the published content details or an error.
270
- *
271
- * @example Publishing content to an external platform
272
- * ```ts
273
- * import type { PublishContentRequest, PublishContentResponse } from '@canva/intents/content';
274
- *
275
- * async function publishContent(request: PublishContentRequest): Promise<PublishContentResponse> {
276
- * const { publishRef, outputType, outputMedia } = request;
277
- *
278
- * try {
279
- * // Parse settings from publishRef
280
- * const settings = publishRef ? JSON.parse(publishRef) : {};
281
- *
282
- * // Upload files to your platform
283
- * const uploadedFiles = await Promise.all(
284
- * outputMedia.flatMap(media =>
285
- * media.files.map(file => uploadFile(file.url))
286
- * )
287
- * );
288
- *
289
- * // Create post on your platform
290
- * const result = await createPost({
291
- * files: uploadedFiles,
292
- * caption: settings.caption
293
- * });
294
- *
295
- * return {
296
- * status: 'completed',
297
- * externalId: result.id,
298
- * externalUrl: result.url
299
- * };
300
- * } catch (error) {
301
- * return {
302
- * status: 'remote_request_failed'
303
- * };
304
- * }
305
- * }
306
- * ```
307
- */
308
- publishContent: (request: PublishContentRequest) => Promise<PublishContentResponse>;
309
-
310
- };
311
-
312
- /**
313
- * @public
314
- * Metadata specific to design content.
315
- */
316
- export declare interface DesignContentMetadata {
317
- type: 'design';
318
- /**
319
- * A signed JWT token containing the design id
320
- */
321
- designToken: string;
322
- /**
323
- * The user given title of the design
324
- */
325
- title: string | undefined;
326
- /**
327
- * The pages that make up the exported metadata
328
- */
329
- pages: OutputPageMetadata[];
330
- }
331
-
332
- /**
333
- * @public
334
- * A function that can be called to dispose of a callback.
335
- */
336
- export declare type Disposer = () => void;
337
-
338
- /**
339
- * @public
340
- * Exported PDF file ready for publishing.
341
- *
342
- * Contains the final PDF document that should be uploaded to your platform.
343
- * The document format is `pdf_standard` and the file is ready to use.
344
- */
345
- export declare type DocumentOutputFile = BaseOutputFile;
346
-
347
- /**
348
- * @public
349
- * Document preview in various states.
350
- *
351
- * Documents transition through states: `"loading"` → `"thumbnail"`.
352
- * Start with a lightweight thumbnail of the first page for quick preview rendering.
353
- */
354
- export declare type DocumentPreview = DocumentPreviewLoading | DocumentPreviewThumbnail | DocumentPreviewError;
355
-
356
- /**
357
- * @public
358
- * Document preview that failed to generate.
359
- *
360
- * Display an error state to the user.
361
- */
362
- export declare interface DocumentPreviewError extends SizedPreview {
363
- kind: 'document';
364
- status: 'error';
365
- /**
366
- * The error message to display to the user.
367
- */
368
- message: string;
369
- }
370
-
371
- /**
372
- * @public
373
- * Document preview that is currently being generated.
374
- *
375
- * Display a loading state until the preview transitions to `"thumbnail"` or `"error"`.
376
- */
377
- export declare interface DocumentPreviewLoading extends SizedPreview {
378
- kind: 'document';
379
- status: 'loading';
380
- }
381
-
382
- /**
383
- * @public
384
- * Document preview with first page thumbnail available.
385
- *
386
- * This is the initial state for document previews. Show the thumbnail image
387
- * of the first page along with the page count to give users a preview of
388
- * the document before publishing.
389
- */
390
- export declare interface DocumentPreviewThumbnail extends SizedPreview {
391
- kind: 'document';
392
- status: 'thumbnail';
393
- /**
394
- * Format of the thumbnail image.
395
- */
396
- thumbnailFormat: 'png' | 'jpg';
397
- /**
398
- * URL to the first page thumbnail.
399
- *
400
- * Display this lightweight image to preview the document content.
401
- */
402
- thumbnailUrl: string;
403
- }
404
-
405
- /**
406
- * @public
407
- * Document file requirements for a media slot.
408
- *
409
- * Note: Document output types use image previews (PNG thumbnails) in the preview UI.
410
- * The actual document file is only generated for the final output in OutputMedia.
411
- *
412
- * @example Document requirements
413
- * ```ts
414
- * const documentReq: DocumentRequirement = {
415
- * format: 'pdf_standard',
416
- * size: 'a4',
417
- * };
418
- * ```
419
- */
420
- export declare interface DocumentRequirement extends BaseFileRequirement {
421
- /**
422
- * Supported document export format.
423
- * Currently supports PDF standard format.
424
- */
425
- format: 'pdf_standard';
426
- /**
427
- * The document size of the export file.
428
- */
429
- size: DocumentSize;
430
- }
431
-
432
- /**
433
- * @public
434
- * Document size for document exports.
435
- */
436
- export declare type DocumentSize = 'a4' | 'a3' | 'letter' | 'legal';
437
-
438
- /**
439
- * @beta
440
- * Exported email file ready for publishing.
441
- *
442
- * Contains the final HTML bundle that should be uploaded to your platform.
443
- */
444
- export declare type EmailOutputFile = BaseOutputFile;
445
-
446
- /**
447
- * @beta
448
- * Email preview in various states.
449
- *
450
- * Display a loading state until the preview transitions to `"ready"` or `"error"`.
451
- */
452
- export declare type EmailPreview = EmailPreviewLoading | EmailPreviewReady | EmailPreviewError;
453
-
454
- /**
455
- * @beta
456
- * Email preview in an error state.
457
- *
458
- * Display an error state to the user.
459
- */
460
- export declare interface EmailPreviewError extends BasePreview {
461
- kind: 'email';
462
- status: 'error';
463
- message: string;
464
- }
465
-
466
- /**
467
- * @beta
468
- * Email preview in a loading state.
469
- *
470
- * Display a loading spinner until the preview transitions to `"ready"` or `"error"`.
471
- */
472
- export declare interface EmailPreviewLoading extends BasePreview {
473
- kind: 'email';
474
- status: 'loading';
475
- }
476
-
477
- /**
478
- * @beta
479
- * Email preview in a ready state.
480
- *
481
- * Display the email preview.
482
- */
483
- export declare interface EmailPreviewReady extends BasePreview {
484
- kind: 'email';
485
- status: 'ready';
486
- /**
487
- * URL to the single html file that represents the email.
488
- */
489
- url: string;
490
- }
491
-
492
- /**
493
- * Email preview stub used before beta preview type is fully supported.
494
- */
495
- declare interface EmailPreviewStub extends BasePreview {
496
- kind: 'email';
497
- }
498
-
499
- /**
500
- * @beta
501
- * Email file requirements for a media slot, currently only supports HTML bundle format.
502
- *
503
- *
504
- * @example Email bundle requirements
505
- * ```ts
506
- * const emailReq: EmailRequirement = {
507
- * format: 'html_bundle',
508
- * };
509
- * ```
510
- */
511
- export declare interface EmailRequirement extends BaseFileRequirement {
512
- format: 'html_bundle';
513
- }
514
-
515
- /**
516
- * @public
517
- *
518
- * The cause of an error
519
- */
520
- export declare type ErrorCause = 'invalid_selection' | 'invalid_format';
521
-
522
- /**
523
- * @public
524
- * Exact value range constraint.
525
- * @example Exact value range
526
- * ```ts
527
- * const exactValue: ValueRange = { exact: 1 }; // Must be exactly 1
528
- * ```
529
- */
530
- export declare type ExactValueRange = {
531
- exact: number;
532
- };
533
-
534
- /**
535
- * @public
536
- * Successful response from getting publish configuration.
537
- */
538
- export declare type GetPublishConfigurationCompleted = {
539
- status: 'completed';
540
- /**
541
- * Array of available output types for your platform.
542
- *
543
- * Define different output types for various content formats that
544
- * your platform supports (e.g., posts, stories, videos).
545
- */
546
- outputTypes: OutputType[];
547
- };
548
-
549
- /**
550
- * @public
551
- * {@link GetPublishConfigurationError} error indicating a custom error occurred.
552
- */
553
- export declare type GetPublishConfigurationError = AppError;
554
-
555
- /**
556
- * @public
557
- * Response from getting publish configuration.
558
- */
559
- export declare type GetPublishConfigurationResponse = GetPublishConfigurationCompleted | GetPublishConfigurationError;
560
-
561
- /**
562
- * @public
563
- * Exported image file ready for publishing.
564
- */
565
- export declare interface ImageOutputFile extends BaseOutputFile {
566
- /**
567
- * Width of the image in pixels.
568
- */
569
- widthPx: number;
570
- /**
571
- * Height of the image in pixels.
572
- */
573
- heightPx: number;
574
- }
575
-
576
- /**
577
- * @public
578
- * Image preview in various states.
579
- */
580
- export declare type ImagePreview = ImagePreviewLoading | ImagePreviewReady | ImagePreviewError;
581
-
582
- /**
583
- * @public
584
- * Image preview that failed to generate.
585
- *
586
- * Display an error state to the user.
587
- */
588
- export declare interface ImagePreviewError extends SizedPreview {
589
- kind: 'image';
590
- status: 'error';
591
-
592
- /**
593
- * The error message to display to the user.
594
- */
595
- message: string;
596
- }
597
-
598
- /**
599
- * @public
600
- * Image preview that is currently being generated.
601
- *
602
- * Display a loading state until the preview transitions to `"ready"` or `"error"`.
603
- */
604
- export declare interface ImagePreviewLoading extends SizedPreview {
605
- kind: 'image';
606
- status: 'loading';
607
- }
608
-
609
- /**
610
- * @public
611
- * Image preview that is ready to display.
612
- *
613
- * Contains the URL to the preview image.
614
- */
615
- export declare interface ImagePreviewReady extends SizedPreview {
616
- kind: 'image';
617
- status: 'ready';
618
- /**
619
- * Image format of the preview.
620
- */
621
- format: 'png' | 'jpg';
622
- /**
623
- * URL to the preview image.
624
- *
625
- * Use this URL to display the preview to users.
626
- */
627
- url: string;
628
- }
629
-
630
- /**
631
- * @public
632
- * Image file requirements for a media slot.
633
- *
634
- * Specifies format, aspect ratio, and size constraints for images.
635
- *
636
- * @example Image requirements for social media post
637
- * ```ts
638
- * const imageReq: ImageRequirement = {
639
- * format: 'jpg',
640
- * aspectRatio: { min: 0.8, max: 1.91 },
641
- * };
642
- * ```
643
- */
644
- export declare interface ImageRequirement extends BaseFileRequirement {
645
- /**
646
- * Supported image format.
647
- */
648
- format: 'png' | 'jpg';
649
- /**
650
- * Aspect ratio constraint (width / height).
651
- *
652
- * Examples:
653
- * - `{ exact: 16/9 }`: Widescreen (16:9)
654
- * - `{ min: 0.8, max: 1.91 }`: Instagram range
655
- */
656
- aspectRatio?: ValueRange;
657
- }
658
-
659
- /**
660
- * @public
661
- * Maximum value range constraint.
662
- * @example Maximum value range
663
- * ```ts
664
- * const maxValue: ValueRange = { max: 10 }; // At most 10
665
- * ```
666
- */
667
- export declare type MaxValueRange = {
668
- max: number;
669
- };
670
-
671
- /**
672
- * @public
673
- * Configuration for a media slot within an output type.
674
- *
675
- * Defines what type of media is accepted, requirements, and constraints.
676
- *
677
- * @example Image slot with aspect ratio requirements
678
- * ```ts
679
- * const thumbnailSlot: MediaSlot = {
680
- * id: 'thumbnail',
681
- * displayName: 'Video Thumbnail',
682
- * fileCount: { exact: 1 },
683
- * accepts: {
684
- * image: {
685
- * format: 'jpg',
686
- * aspectRatio: { exact: 16/9 },
687
- * }
688
- * }
689
- * };
690
- * ```
691
- */
692
- export declare type MediaSlot = {
693
- /**
694
- * Unique identifier for this media slot within the output type.
695
- */
696
- id: string;
697
- /**
698
- * User-facing name for this media slot.
699
- *
700
- * Examples: `"Post Image"`, `"Video Thumbnail"`, `"Main Video"`.
701
- */
702
- displayName: string;
703
- /**
704
- * Number of files accepted in this slot.
705
- *
706
- * Use this to specify single or multiple file requirements.
707
- * Examples:
708
- * - `{ exact: 1 }`: Exactly one file
709
- * - `{ min: 1, max: 10 }`: Between 1 and 10 files
710
- * - undefined: Any number of files
711
- */
712
- fileCount?: ValueRange;
713
- /**
714
- * File type requirements for this slot.
715
- *
716
- * Note the following behavior:
717
- *
718
- * - Provide at least one of `image` or `video`
719
- * - If both are provided, files for this slot may be either images or videos; each file
720
- * must satisfy the corresponding requirement for its media type
721
- * - To restrict the slot to a single media type, provide only that requirement
722
- * - `fileCount` applies across all files accepted by the slot regardless of media type
723
- * - Document output types will show image previews (PNG thumbnail) in preview UI
724
- */
725
- accepts: {
726
- image?: ImageRequirement;
727
- video?: VideoRequirement;
728
- document?: DocumentRequirement;
729
- /**
730
- * @beta
731
- * Email output types will show a single html file (canva hosted assets) preview in preview UI
732
- */
733
- email?: EmailRequirement;
734
- };
735
- };
736
-
737
- /**
738
- * @public
739
- * Minimum and maximum value range constraint.
740
- * Ranges are inclusive `(min ≤ value ≤ max)`.
741
- * @example Minimum and maximum value range
742
- * ```ts
743
- * const minMaxValue: ValueRange = { min: 1, max: 10 }; // Between 1 and 10
744
- * ```
745
- */
746
- export declare type MinMaxValueRange = {
747
- min: number;
748
- max: number;
749
- };
750
-
751
- /**
752
- * @public
753
- * Minimum value range constraint.
754
- * @example Minimum value range
755
- * ```ts
756
- * const minValue: ValueRange = { min: 3 }; // At least 3
757
- * ```
758
- */
759
- export declare type MinValueRange = {
760
- min: number;
761
- };
762
-
763
- /** @public */
764
- export declare type OnContextChange = (context: SettingsUiContext) => void;
765
-
766
- /**
767
- * @public
768
- * Exported file ready for publishing.
769
- */
770
- export declare type OutputFile = ImageOutputFile | VideoOutputFile | DocumentOutputFile;
771
-
772
- /**
773
- * @public
774
- * Production-ready exported files for a specific media slot.
775
- *
776
- * These are the final files that should be uploaded to your platform.
777
- */
778
- export declare type OutputMedia = {
779
- /**
780
- * ID of the media slot these files belong to.
781
- *
782
- * Matches a media slot ID from your output type definition.
783
- */
784
- mediaSlotId: string;
785
- /**
786
- * Array of exported files for this media slot.
787
- *
788
- * Files match the requirements specified in your media slot configuration.
789
- */
790
- files: OutputFile[];
791
- };
792
-
793
- /**
794
- * @public
795
- * Metadata about a specific page in the exported content.
796
- */
797
- export declare type OutputPageMetadata = {
798
- /**
799
- * The unique identifier for the page.
800
- */
801
- pageId: string | undefined;
802
- /**
803
- * The position of the page within the design, starting from 1 for the first page.
804
- */
805
- pageNumber: number;
806
- };
807
-
808
- /**
809
- * @public
810
- * Configuration for an output type.
811
- *
812
- * Defines a specific publishing format your platform supports,
813
- * including what media is required and accepted file types.
814
- *
815
- * @example Defining an Instagram post output type
816
- * ```ts
817
- * const instagramPost: OutputType = {
818
- * id: 'instagram_post',
819
- * displayName: 'Instagram Post',
820
- * mediaSlots: [
821
- * {
822
- * id: 'main_image',
823
- * displayName: 'Post Image',
824
- * fileCount: { min: 1, max: 10 },
825
- * accepts: {
826
- * image: {
827
- * format: 'jpg',
828
- * aspectRatio: { min: 0.8, max: 1.91 },
829
- * }
830
- * }
831
- * }
832
- * ]
833
- * };
834
- * ```
835
- */
836
- export declare type OutputType = {
837
- /**
838
- * Unique identifier for this output type.
839
- *
840
- * Use descriptive IDs like `"instagram_post"` or `"youtube_video"`.
841
- */
842
- id: string;
843
- /**
844
- * User-facing name for this output type.
845
- *
846
- * This is displayed to users when selecting where to publish.
847
- * Examples: `"Instagram Post"`, `"YouTube Video"`, `"Twitter Post"`.
848
- */
849
- displayName: string;
850
- /**
851
- * Array of media slots defining what content is needed.
852
- *
853
- * Each slot represents a piece of media required for publishing,
854
- * such as a main image, thumbnail, or video.
855
- */
856
- mediaSlots: MediaSlot[];
857
- };
858
-
859
- /**
860
- * @public
861
- * Action to be taken after publishing completes successfully.
862
- */
863
- export declare type PostPublishAction = PostPublishActionRedirect;
864
-
865
- /**
866
- * @public
867
- * Redirect action to navigate the user to a URL after publishing.
868
- *
869
- * @example Redirecting to content editor
870
- * ```ts
871
- * const postPublishAction: PostPublishActionRedirect = {
872
- * type: 'redirect',
873
- * url: 'https://example.com/posts/12345/edit'
874
- * };
875
- * ```
876
- */
877
- export declare type PostPublishActionRedirect = {
878
- type: 'redirect';
879
- /**
880
- * The URL to redirect the user to after publishing.
881
- */
882
- url: string;
883
- };
884
-
885
- /**
886
- * @public
887
- *
888
- * Prepares a {@link ContentPublisherIntent|Content Publisher Intent}.
889
- *
890
- * @example
891
- * ```tsx
892
- * import { prepareContentPublisher } from "@canva/intents/content";
893
- *
894
- * prepareContentPublisher({
895
- * getPublishConfiguration: async (params) => {
896
- * // Implement the logic to get the publish configuration
897
- * },
898
- * renderSettingsUi: (params) => {
899
- * // Implement the UI for settings view
900
- * },
901
- * renderPreviewUi: (params) => {
902
- * // Implement the UI for preview view
903
- * },
904
- * publishContent: async (params) => {
905
- * // Implement the logic to publish the content
906
- * },
907
- * });
908
- * ```
909
- */
910
- export declare const prepareContentPublisher: (implementation: ContentPublisherIntent) => void;
911
-
912
- /**
913
- * @public
914
- * Preview item for an image or video.
915
- *
916
- * Check the `kind` and `status` properties to determine the type and state.
917
- */
918
- declare type Preview_2 = ImagePreview | VideoPreview | DocumentPreview | EmailPreviewStub;
919
-
920
- /**
921
- * @public
922
- * Type of preview media.
923
- */
924
- export declare type PreviewKind = 'image' | 'video' | 'document' | 'email';
925
-
926
- /**
927
- * @public
928
- * Preview media for a specific media slot.
929
- *
930
- * Contains preview URLs and metadata for images or videos in the design.
931
- */
932
- declare type PreviewMedia_2 = {
933
- /**
934
- * ID of the media slot this preview belongs to.
935
- *
936
- * Matches a media slot ID from your output type definition.
937
- */
938
- mediaSlotId: string;
939
- /**
940
- * Array of preview items for this media slot.
941
- *
942
- * May contain multiple previews if the media slot accepts multiple files.
943
- */
944
- previews: Preview_2[];
945
- };
946
-
947
- /**
948
- * @public
949
- * State of a preview item.
950
- */
951
- export declare type PreviewStatus = 'loading' | 'thumbnail' | 'upgrading' | 'ready' | 'error';
952
-
953
- /**
954
- * @public
955
- * Successful response from publishing a content.
956
- *
957
- * @example Basic successful publish
958
- * ```ts
959
- * return {
960
- * status: 'completed',
961
- * externalId: 'post_12345',
962
- * externalUrl: 'https://example.com/posts/12345'
963
- * };
964
- * ```
965
- *
966
- * @example Successful publish with redirect
967
- * ```ts
968
- * return {
969
- * status: 'completed',
970
- * externalId: 'video_67890',
971
- * externalUrl: 'https://example.com/videos/67890',
972
- * postPublishAction: {
973
- * type: 'redirect',
974
- * url: 'https://example.com/videos/67890/edit'
975
- * }
976
- * };
977
- * ```
978
- */
979
- export declare type PublishContentCompleted = {
980
- status: 'completed';
981
- /**
982
- * Unique identifier returned from your external platform. You can use this for:
983
- *
984
- * - Tracking published content
985
- * - Fetching insights data for the published content
986
- * - Linking back to the content in future operations
987
- */
988
- externalId?: string;
989
- /**
990
- * Direct URL to the published content on your platform.
991
- *
992
- * Users can visit this URL to view their published content.
993
- * This may be displayed to users or used for sharing.
994
- */
995
- externalUrl?: string;
996
- /**
997
- * Optional action to perform after publishing completes.
998
- *
999
- * Currently supports redirecting users to a specific URL after publishing.
1000
- */
1001
- postPublishAction?: PostPublishAction;
1002
- };
1003
-
1004
- /**
1005
- * @public
1006
- * Error response from publishing a content.
1007
- *
1008
- * Return the appropriate error type based on the failure:
1009
- *
1010
- * - `"remote_request_failed"`: Network or API errors with your platform
1011
- * - `"app_error"`: Custom application errors with optional message
1012
- */
1013
- export declare type PublishContentError = RemoteRequestFailedError | AppError;
1014
-
1015
- /**
1016
- * @public
1017
- * Parameters required for publishing the content.
1018
- * Contains all the information needed to send the content to your external platform.
1019
- */
1020
- export declare type PublishContentRequest = {
1021
- /**
1022
- * Platform-specific settings reference containing user configurations.
1023
- *
1024
- * This is the same reference you saved via `updatePublishSettings` in the settings UI.
1025
- * Parse this string to retrieve the user's publish settings (e.g., captions, tags, privacy).
1026
- *
1027
- * Maximum size: 5KB
1028
- */
1029
- publishRef?: string;
1030
- /**
1031
- * The output type selected by the user for this publish operation.
1032
- *
1033
- * This matches one of the output types you provided in `getPublishConfiguration`.
1034
- */
1035
- outputType: OutputType;
1036
- /**
1037
- * Production-ready exported files matching the requirements from your output type.
1038
- *
1039
- * These files are ready to upload to your platform and match the format, size,
1040
- * and aspect ratio requirements specified in your media slots.
1041
- */
1042
- outputMedia: OutputMedia[];
1043
- };
1044
-
1045
- /**
1046
- * @public
1047
- * Response from a publish content operation.
1048
- *
1049
- * This can be either a successful completion or an error response.
1050
- */
1051
- export declare type PublishContentResponse = PublishContentCompleted | PublishContentError;
1052
-
1053
- /** @public */
1054
- export declare type PublishError = {
1055
- appDefinedPayload?: string;
1056
- };
1057
-
1058
- /**
1059
- * @public
1060
- * Signals that the publish error was cleared.
1061
- */
1062
- export declare type PublishErrorClearedSettingsUiContext = {
1063
- reason: 'publish_error_cleared';
1064
- };
1065
-
1066
- /**
1067
- * @public
1068
- * Provides information about an error that occurred in publishContent.
1069
- */
1070
- export declare type PublishErrorSettingsUiContext = {
1071
- reason: 'publish_error';
1072
- /**
1073
- * The error that occurred. Undefined means no error occurred or the previous
1074
- * error was cleared by Canva.
1075
- */
1076
- error: PublishError;
1077
- };
1078
-
1079
- /**
1080
- * @public
1081
- * Supported file formats for publishing.
1082
- */
1083
- export declare type PublishFileFormat = 'png' | 'jpg' | 'mp4' | 'pdf_standard' | 'html_bundle';
1084
-
1085
- /**
1086
- * @beta
1087
- * Initial payload provided from cache.
1088
- */
1089
- export declare type PublishPreviewUiInvocationContext = {
1090
- /**
1091
- * Initial preview data and context provided when the preview UI is rendered.
1092
- */
1093
- reason: 'publish';
1094
- /**
1095
- * Initial preview media to display
1096
- * This will only be used for scheduling and not caching
1097
- */
1098
- previewMedia?: PreviewMedia_2[];
1099
- /** Information about the current output type being previewed */
1100
- outputType?: OutputType;
1101
- /** Current publish reference, if available */
1102
- publishRef?: string;
1103
- };
1104
-
1105
- /**
1106
- * @public
1107
- * Validation state indicating whether publish settings are complete and valid.
1108
- */
1109
- export declare type PublishRefValidityState = 'valid' | 'invalid_missing_required_fields' | 'invalid_authentication_required';
1110
-
1111
- /**
1112
- * @public
1113
- * Configuration for publish settings.
1114
- *
1115
- * Contains the user's settings and their validation state. Use this to
1116
- * control whether the publish button is enabled.
1117
- */
1118
- export declare type PublishSettings = {
1119
- /**
1120
- * Serialized platform-specific settings for publishing.
1121
- *
1122
- * Store all information your app needs to publish the content in this string.
1123
- * This might include:
1124
- *
1125
- * - Captions or descriptions
1126
- * - Tags or hashtags
1127
- * - Privacy settings
1128
- * - Publishing destination (account, page, etc.)
1129
- * - Scheduling information
1130
- *
1131
- * This reference will be provided to your `publishContent` method when publishing.
1132
- *
1133
- * Maximum size: 5KB
1134
- *
1135
- * @example Serializing settings
1136
- * ```ts
1137
- * const settings = {
1138
- * caption: 'Check out my design!',
1139
- * tags: ['design', 'creative'],
1140
- * privacy: 'public'
1141
- * };
1142
- * const publishRef = JSON.stringify(settings);
1143
- * ```
1144
- */
1145
- publishRef?: string;
1146
- /**
1147
- * Validation state of the publish settings.
1148
- *
1149
- * Controls whether the publish button is enabled:
1150
- *
1151
- * - `"valid"`: Settings are complete and valid, publish button is enabled
1152
- * - `"invalid_missing_required_fields"`: Required settings are missing, publish button is disabled
1153
- * - `"invalid_authentication_required"`: User must authenticate before publishing can proceed
1154
- */
1155
- validityState: PublishRefValidityState;
1156
- };
1157
-
1158
- /**
1159
- * @public
1160
- * Provides information about the current state of the settings UI to help
1161
- * you adapt the interface based on the selected output type.
1162
- */
1163
- export declare type PublishSettingsSettingsUiContext = {
1164
- reason: 'publish_settings';
1165
- /**
1166
- * The currently selected output type.
1167
- *
1168
- * Use this to customize your settings UI based on the requirements
1169
- * of different output types.
1170
- */
1171
- outputType: OutputType;
1172
- };
1173
-
1174
- /**
1175
- * @beta
1176
- * Initial payload provided from cache.
1177
- */
1178
- export declare type PublishSettingsUiInvocationContext = {
1179
- /**
1180
- * Initial settings and context provided when the settings UI is rendered.
1181
- */
1182
- reason: 'publish';
1183
- /** Current publish reference to populate the UI, if any exist */
1184
- publishRef?: string;
1185
- /** Information about the current output type being configured */
1186
- outputType?: OutputType;
1187
- };
1188
-
1189
- /**
1190
- * @public
1191
- * {@link PublishContentError} indicating failure of the remote request to the external platform.
1192
- *
1193
- * Return this error for:
1194
- *
1195
- * - Network connectivity issues
1196
- * - API endpoint failures
1197
- * - HTTP errors from your platform
1198
- * - Timeout errors
1199
- *
1200
- * @example Handling network errors
1201
- * ```ts
1202
- * try {
1203
- * await uploadToExternalPlatform(file);
1204
- * } catch (error) {
1205
- * return { status: 'remote_request_failed' };
1206
- * }
1207
- * ```
1208
- */
1209
- export declare type RemoteRequestFailedError = {
1210
- status: 'remote_request_failed';
1211
- };
1212
-
1213
- /**
1214
- * @beta
1215
- * Initial payload provided when the preview UI is rendered.
1216
- * Contains the preview data and settings needed to initialize the preview interface.
1217
- */
1218
- export declare type RenderPreviewUiInvocationContext = PublishPreviewUiInvocationContext;
1219
-
1220
- /**
1221
- * @public
1222
- * Configuration required for rendering the preview UI.
1223
- *
1224
- * Provides callbacks for managing preview media and responding to preview updates.
1225
- */
1226
- export declare type RenderPreviewUiRequest = {
1227
- /**
1228
- * @beta
1229
- * The initial preview data and context provided when the preview UI is rendered.
1230
- *
1231
- * Contains the initial preview media, output type information, and any existing
1232
- * publish settings needed to properly display the preview interface.
1233
- */
1234
- invocationContext: RenderPreviewUiInvocationContext;
1235
- /**
1236
- * Callback to upgrade video thumbnail previews to full video media.
1237
- *
1238
- * Call this function when you need full video previews instead of lightweight thumbnails.
1239
- * This helps optimize performance by deferring full video loading until needed.
1240
- *
1241
- * Upgrades may complete asynchronously; listen to `registerOnPreviewChange` for updates
1242
- * to receive the upgraded video previews.
1243
- *
1244
- * @param previewIds - Array of preview IDs to upgrade from thumbnail to full video
1245
- *
1246
- * @example Upgrading video previews on user interaction
1247
- * ```ts
1248
- * // When user clicks on a video thumbnail, upgrade to full video
1249
- * if (preview.kind === 'video' && preview.status === 'thumbnail') {
1250
- * requestPreviewUpgrade([preview.id]);
1251
- * }
1252
- * ```
1253
- */
1254
- requestPreviewUpgrade: (previewIds: string[]) => void;
1255
- /**
1256
- * Registers a callback to be invoked when preview data changes.
1257
- *
1258
- * This callback is triggered when:
1259
- *
1260
- * - The design content changes
1261
- * - The output type changes
1262
- * - Preview media is upgraded from thumbnail to full video
1263
- * - Export settings are modified
1264
- *
1265
- * Use this to update your preview UI in real-time as users modify their design.
1266
- *
1267
- * @param callback - The callback invoked when preview data is updated
1268
- * @returns A disposer function that cleans up the registered callback
1269
- *
1270
- * @example Handling preview updates
1271
- * ```ts
1272
- * const disposer = registerOnPreviewChange(({ previewMedia, outputType, publishRef }) => {
1273
- * // Update your preview UI with the new preview media
1274
- * previewMedia.forEach((media) => {
1275
- * media.previews.forEach((preview) => {
1276
- * if (preview.status === 'ready') {
1277
- * displayPreview(preview);
1278
- * }
1279
- * });
1280
- * });
1281
- * });
1282
- *
1283
- * // Clean up when preview UI is unmounted
1284
- * onUnmount(() => disposer());
1285
- * ```
1286
- */
1287
- registerOnPreviewChange: (callback: (opts: {
1288
- previewMedia: PreviewMedia_2[];
1289
- /** The output type that the preview data is for */
1290
- outputType: OutputType;
1291
- /** The current publish settings reference, if available */
1292
- publishRef?: string;
1293
- }) => void) => Disposer;
1294
- };
1295
-
1296
- /**
1297
- * @beta
1298
- * Initial payload provided when the publish settings UI is rendered.
1299
- * Contains the current settings state needed to initialize the settings interface.
1300
- */
1301
- export declare type RenderSettingsUiInvocationContext = PublishSettingsUiInvocationContext;
1302
-
1303
- /**
1304
- * @public
1305
- * Configuration for the publish settings UI.
1306
- *
1307
- * This type provides the necessary callbacks and configuration for rendering
1308
- * a custom publish settings interface where users configure platform-specific options.
1309
- */
1310
- export declare type RenderSettingsUiRequest = {
1311
- /**
1312
- * @beta
1313
- * The initial settings and context provided when the settings UI is rendered.
1314
- *
1315
- * Contains any previously saved publish settings and information about the current output type being configured.
1316
- * Use this to restore the UI to its previous state or initialise it with appropriate defaults.
1317
- */
1318
- invocationContext: RenderSettingsUiInvocationContext;
1319
- /**
1320
- * Callback to save and validate the user's publish settings.
1321
- *
1322
- * Call this function whenever the user modifies their settings to:
1323
- *
1324
- * - Save the settings for later use in `publishContent`
1325
- * - Validate that required fields are filled
1326
- * - Enable or disable the publish button based on validity
1327
- *
1328
- * Store all necessary publishing information in the `publishRef` string.
1329
- * This will be provided to your `publishContent` method when the user publishes.
1330
- *
1331
- * @param settings - The new publish settings to save
1332
- * @returns A promise that resolves when the settings are successfully saved
1333
- * @throws Will throw `CanvaError('bad_request')` if {@link PublishSettings.publishRef} exceeds 5KB.
1334
- *
1335
- * @example Updating settings as user types
1336
- * ```ts
1337
- * // As user fills in form fields, update settings
1338
- * function handleCaptionChange(caption: string) {
1339
- * const settings = { caption, tags: currentTags };
1340
- * const publishRef = JSON.stringify(settings);
1341
- *
1342
- * updatePublishSettings({
1343
- * publishRef,
1344
- * validityState: caption ? 'valid' : 'invalid_missing_required_fields'
1345
- * });
1346
- * }
1347
- * ```
1348
- */
1349
- updatePublishSettings: (publishSettings: PublishSettings) => Promise<UpdatePublishSettingsResponse>;
1350
-
1351
- /**
1352
- * Registers a callback to be invoked when the settings UI context changes.
1353
- *
1354
- * This callback is triggered when:
1355
- * - the user changes the output type in the publish flow.
1356
- * - an error occurs in the publish flow.
1357
- *
1358
- * Use this to respond to Canva changes and update your settings UI accordingly.
1359
- *
1360
- * @param opts - The options for registering a callback.
1361
- * @returns A disposer function that cleans up the registered callback.
1362
- *
1363
- * @example Adapting UI for different output types
1364
- * ```ts
1365
- * registerOnContextChange({
1366
- * onContextChange: (ctx) => {
1367
- * if (ctx.reason === 'publish_settings') {
1368
- * if (ctx.outputType.id === 'instagram_post') {
1369
- * showHashtagField();
1370
- * }
1371
- * }
1372
- * if (ctx.reason === 'publish_error') {
1373
- * setError(ctx.error);
1374
- * }
1375
- * }
1376
- * });
1377
- * ```
1378
- */
1379
- registerOnContextChange: (opts: {
1380
- onContextChange: OnContextChange;
1381
- }) => Disposer;
1382
- };
1383
-
1384
- /**
1385
- * @public
1386
- * Context information for the publish settings UI.
1387
- */
1388
- export declare type SettingsUiContext = PublishSettingsSettingsUiContext | PublishErrorSettingsUiContext | PublishErrorClearedSettingsUiContext;
1389
-
1390
- /**
1391
- * @public
1392
- * Base interface for all preview types that have a fixed width and height.
1393
- */
1394
- export declare interface SizedPreview extends BasePreview {
1395
- /**
1396
- * Width of the preview in pixels.
1397
- */
1398
- widthPx: number;
1399
- /**
1400
- * Height of the preview in pixels.
1401
- */
1402
- heightPx: number;
1403
- }
1404
-
1405
- /**
1406
- * @public
1407
- * Successful response from updating the publish settings.
1408
- */
1409
- export declare type UpdatePublishSettingsCompleted = {
1410
- status: 'completed';
1411
- };
1412
-
1413
- /**
1414
- * @public
1415
- * Response from updating the publish settings.
1416
- */
1417
- export declare type UpdatePublishSettingsResponse = UpdatePublishSettingsCompleted;
1418
-
1419
- /**
1420
- * @public
1421
- * Numeric value range constraint.
1422
- * Used to specify requirements for aspect ratios, durations, file counts, etc.
1423
- */
1424
- export declare type ValueRange = ExactValueRange | MinValueRange | MaxValueRange | MinMaxValueRange;
1425
-
1426
- /**
1427
- * @public
1428
- * Exported video file ready for publishing.
1429
- */
1430
- export declare interface VideoOutputFile extends BaseOutputFile {
1431
- /**
1432
- * Width of the video in pixels.
1433
- */
1434
- widthPx: number;
1435
- /**
1436
- * Height of the video in pixels.
1437
- */
1438
- heightPx: number;
1439
- }
1440
-
1441
- /**
1442
- * @public
1443
- * Video preview in various states.
1444
- *
1445
- * Videos transition through states: `"loading"` → `"thumbnail"` → `"upgrading"` → `"ready"`.
1446
- * Start with thumbnails for better performance, then upgrade to full video using `requestPreviewUpgrade`.
1447
- */
1448
- export declare type VideoPreview = VideoPreviewLoading | VideoPreviewThumbnail | VideoPreviewUpgrading | VideoPreviewReady | VideoPreviewError;
1449
-
1450
- /**
1451
- * @public
1452
- * Video preview that failed to generate.
1453
- *
1454
- * Display an error state to the user.
1455
- */
1456
- export declare interface VideoPreviewError extends SizedPreview {
1457
- kind: 'video';
1458
- status: 'error';
1459
-
1460
- /**
1461
- * The error message to display to the user.
1462
- */
1463
- message: string;
1464
- }
1465
-
1466
- /**
1467
- * @public
1468
- * Video preview that is currently being generated.
1469
- *
1470
- * Display a loading state until the preview transitions to `"thumbnail"` or `"error"`.
1471
- */
1472
- export declare interface VideoPreviewLoading extends SizedPreview {
1473
- kind: 'video';
1474
- status: 'loading';
1475
- /**
1476
- * Video duration in milliseconds.
1477
- */
1478
- durationMs?: number;
1479
- }
1480
-
1481
- /**
1482
- * @public
1483
- * Video preview with full video ready to play.
1484
- *
1485
- * Contains URLs for both the video and thumbnail.
1486
- */
1487
- export declare interface VideoPreviewReady extends SizedPreview {
1488
- kind: 'video';
1489
- status: 'ready';
1490
- /**
1491
- * Video format.
1492
- */
1493
- format: 'mp4';
1494
- /**
1495
- * URL to the full video.
1496
- *
1497
- * Use this URL in a video player.
1498
- */
1499
- url: string;
1500
- /**
1501
- * Format of the thumbnail image.
1502
- */
1503
- thumbnailFormat: 'png' | 'jpg';
1504
- /**
1505
- * URL to the thumbnail image.
1506
- *
1507
- * Can be used as a poster image for the video player.
1508
- */
1509
- thumbnailUrl: string;
1510
- /**
1511
- * Video duration in milliseconds.
1512
- */
1513
- durationMs?: number;
1514
- }
1515
-
1516
- /**
1517
- * @public
1518
- * Video preview with lightweight thumbnail available.
1519
- *
1520
- * This is the initial state for video previews. Show the thumbnail image
1521
- * and call `requestPreviewUpgrade` when the user needs the full video.
1522
- */
1523
- export declare interface VideoPreviewThumbnail extends SizedPreview {
1524
- kind: 'video';
1525
- status: 'thumbnail';
1526
- /**
1527
- * Format of the thumbnail image.
1528
- */
1529
- thumbnailFormat: 'png' | 'jpg';
1530
- /**
1531
- * URL to the thumbnail image.
1532
- *
1533
- * Display this lightweight image until full video is needed.
1534
- */
1535
- thumbnailUrl: string;
1536
- /**
1537
- * Video duration in milliseconds.
1538
- */
1539
- durationMs?: number;
1540
- }
1541
-
1542
- /**
1543
- * @public
1544
- * Video preview that is being upgraded from thumbnail to full video.
1545
- *
1546
- * Display the thumbnail with a loading indicator until the video is ready.
1547
- */
1548
- export declare interface VideoPreviewUpgrading extends SizedPreview {
1549
- kind: 'video';
1550
- status: 'upgrading';
1551
- /**
1552
- * Format of the thumbnail image.
1553
- */
1554
- thumbnailFormat: 'png' | 'jpg';
1555
- /**
1556
- * URL to the thumbnail image.
1557
- *
1558
- * Continue showing the thumbnail while the full video loads.
1559
- */
1560
- thumbnailUrl: string;
1561
- /**
1562
- * Video duration in milliseconds.
1563
- */
1564
- durationMs?: number;
1565
- }
1566
-
1567
- /**
1568
- * @public
1569
- * Video file requirements for a media slot.
1570
- *
1571
- * Specifies format, aspect ratio, duration, and size constraints for videos.
1572
- *
1573
- * @example Video requirements for YouTube
1574
- * ```ts
1575
- * const videoReq: VideoRequirement = {
1576
- * format: 'mp4',
1577
- * aspectRatio: { exact: 16/9 },
1578
- * durationMs: { min: 1000, max: 600000 },
1579
- * };
1580
- * ```
1581
- */
1582
- export declare interface VideoRequirement extends BaseFileRequirement {
1583
- /**
1584
- * Supported video format.
1585
- */
1586
- format: 'mp4';
1587
- /**
1588
- * Aspect ratio constraint (width / height).
1589
- *
1590
- * Examples:
1591
- * - `{ exact: 16/9 }`: Widescreen
1592
- * - `{ exact: 9/16 }`: Vertical/Story format
1593
- */
1594
- aspectRatio?: ValueRange;
1595
- /**
1596
- * Duration constraint in milliseconds.
1597
- *
1598
- * Examples:
1599
- * - `{ max: 60000 }`: Maximum 60 seconds
1600
- * - `{ min: 3000, max: 600000 }`: Between 3 seconds and 10 minutes
1601
- */
1602
- durationMs?: ValueRange;
1603
-
1604
- }
1605
-
1606
- export { }