|
1 | 1 | import { ImageKitOptions, UrlOptions } from "../interfaces"; |
2 | | -import { Transformation } from "../interfaces/Transformation"; |
3 | | -import transformationUtils from "../utils/transformation"; |
4 | | -import { safeBtoa } from "../utils/transformation"; |
| 2 | +import { ImageOverlay, SolidColorOverlay, SubtitleOverlay, TextOverlay, Transformation, VideoOverlay } from "../interfaces/Transformation"; |
| 3 | +import transformationUtils, { safeBtoa } from "../utils/transformation"; |
5 | 4 | const TRANSFORMATION_PARAMETER = "tr"; |
6 | 5 |
|
7 | 6 | function removeTrailingSlash(str: string) { |
@@ -89,33 +88,48 @@ function processOverlay(overlay: Transformation["overlay"]): string | undefined |
89 | 88 | switch (type) { |
90 | 89 | case "text": |
91 | 90 | entries.push("l-text"); |
92 | | - if (overlay.text) { |
93 | | - entries.push(`ie-${encodeURIComponent(safeBtoa(overlay.text))}`); |
| 91 | + { |
| 92 | + const textOverlay = overlay as TextOverlay; |
| 93 | + if (textOverlay.text) { |
| 94 | + entries.push(`ie-${encodeURIComponent(safeBtoa(textOverlay.text))}`); |
| 95 | + } |
94 | 96 | } |
95 | 97 | break; |
96 | 98 | case "image": |
97 | 99 | entries.push("l-image"); |
98 | | - if (overlay.input) { |
99 | | - entries.push(`i-${overlay.input}`); |
| 100 | + { |
| 101 | + const imageOverlay = overlay as ImageOverlay; |
| 102 | + if (imageOverlay.input) { |
| 103 | + entries.push(`i-${imageOverlay.input}`); |
| 104 | + } |
100 | 105 | } |
101 | 106 | break; |
102 | 107 | case "video": |
103 | 108 | entries.push("l-video"); |
104 | | - if (overlay.input) { |
105 | | - entries.push(`i-${overlay.input}`); |
| 109 | + { |
| 110 | + const videoOverlay = overlay as VideoOverlay; |
| 111 | + if (videoOverlay.input) { |
| 112 | + entries.push(`i-${videoOverlay.input}`); |
| 113 | + } |
106 | 114 | } |
107 | 115 | break; |
108 | 116 | case "subtitle": |
109 | 117 | entries.push("l-subtitle"); |
110 | | - if (overlay.input) { |
111 | | - entries.push(`i-${overlay.input}`); |
| 118 | + { |
| 119 | + const subtitleOverlay = overlay as SubtitleOverlay; |
| 120 | + if (subtitleOverlay.input) { |
| 121 | + entries.push(`i-${subtitleOverlay.input}`); |
| 122 | + } |
112 | 123 | } |
113 | 124 | break; |
114 | 125 | case "solidColor": |
115 | 126 | entries.push("l-image"); |
116 | 127 | entries.push(`i-ik_canvas`); |
117 | | - if (overlay.color) { |
118 | | - entries.push(`bg-${overlay.color}`); |
| 128 | + { |
| 129 | + const solidColorOverlay = overlay as SolidColorOverlay; |
| 130 | + if (solidColorOverlay.color) { |
| 131 | + entries.push(`bg-${solidColorOverlay.color}`); |
| 132 | + } |
119 | 133 | } |
120 | 134 | break; |
121 | 135 | } |
|
0 commit comments