@transloadit/utils 4.5.0 → 4.5.1
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/README.md +5 -1
- package/dist/node.d.ts +17 -4
- package/dist/node.d.ts.map +1 -1
- package/dist/node.js +4 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -47,6 +47,10 @@ const imageCandidates = getSignedSmartCdnImageCandidates({
|
|
|
47
47
|
widths: [320, 640, 960],
|
|
48
48
|
workspace,
|
|
49
49
|
})
|
|
50
|
+
|
|
51
|
+
for (const source of imageCandidates.sources) {
|
|
52
|
+
console.log(source.format, source.quality, source.candidates)
|
|
53
|
+
}
|
|
50
54
|
```
|
|
51
55
|
|
|
52
56
|
## API
|
|
@@ -55,5 +59,5 @@ const imageCandidates = getSignedSmartCdnImageCandidates({
|
|
|
55
59
|
- `verifyWebhookSignature({ rawBody, signatureHeader, authSecret })`: validates webhook signatures.
|
|
56
60
|
- `signParamsSync(paramsString, authSecret, algorithm?)`: Node-only sync signature helper.
|
|
57
61
|
- `getSignedSmartCdnUrl(options)`: Node-only Smart CDN URL signer.
|
|
58
|
-
- `getSignedSmartCdnImageCandidates(options)`: deterministic signed AVIF and WebP
|
|
62
|
+
- `getSignedSmartCdnImageCandidates(options)`: deterministic structured, signed AVIF and WebP
|
|
59
63
|
candidates plus the original fallback URL.
|
package/dist/node.d.ts
CHANGED
|
@@ -1,10 +1,23 @@
|
|
|
1
1
|
import type { SignatureAlgorithm } from './index.ts';
|
|
2
2
|
export type { SignatureAlgorithm } from './index.ts';
|
|
3
3
|
export type SignatureAlgorithmInput = SignatureAlgorithm | (string & {});
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
/** Image formats supported by the responsive-image Built-in. */
|
|
5
|
+
export type SmartCdnImageFormat = 'avif' | 'png' | 'webp';
|
|
6
|
+
/** One signed Smart CDN rendition at a specific intrinsic width. */
|
|
7
|
+
export interface SmartCdnImageCandidate {
|
|
8
|
+
url: string;
|
|
9
|
+
width: number;
|
|
10
|
+
}
|
|
11
|
+
/** Ordered candidates for one image format and quality. */
|
|
12
|
+
export interface SmartCdnImageSource {
|
|
13
|
+
candidates: readonly SmartCdnImageCandidate[];
|
|
14
|
+
format: SmartCdnImageFormat;
|
|
15
|
+
quality: number;
|
|
16
|
+
}
|
|
17
|
+
/** Structured data for rendering a responsive image. */
|
|
18
|
+
export interface SmartCdnImageCandidates {
|
|
19
|
+
fallbackUrl: string;
|
|
20
|
+
sources: readonly SmartCdnImageSource[];
|
|
8
21
|
}
|
|
9
22
|
/** Options for deterministic, server-generated Smart CDN image candidates. */
|
|
10
23
|
export interface SmartCdnImageCandidatesOptions {
|
package/dist/node.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAIpD,YAAY,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAEpD,MAAM,MAAM,uBAAuB,GAAG,kBAAkB,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAA;AAExE,
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAIpD,YAAY,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAEpD,MAAM,MAAM,uBAAuB,GAAG,kBAAkB,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAA;AAExE,gEAAgE;AAChE,MAAM,MAAM,mBAAmB,GAAG,MAAM,GAAG,KAAK,GAAG,MAAM,CAAA;AAEzD,oEAAoE;AACpE,MAAM,WAAW,sBAAsB;IACrC,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,CAAA;CACd;AAED,2DAA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,eAAO,MAAM,cAAc,GACzB,cAAc,MAAM,EACpB,YAAY,MAAM,EAClB,YAAW,uBAAkC,KAC5C,MAKF,CAAA;AAED,eAAO,MAAM,oBAAoB,GAAI,MAAM,kBAAkB,KAAG,MA8B/D,CAAA;AAED;;;;;GAKG;AACH,wBAAgB,gCAAgC,CAC9C,IAAI,EAAE,8BAA8B,GACnC,uBAAuB,CAsDzB"}
|
package/dist/node.js
CHANGED
|
@@ -120,7 +120,7 @@ export function getSignedSmartCdnImageCandidates(opts) {
|
|
|
120
120
|
const formats = opts.formats ?? defaultSmartCdnImageFormats;
|
|
121
121
|
validateSmartCdnImageFormats(formats);
|
|
122
122
|
widths.sort((left, right) => left - right);
|
|
123
|
-
const sources =
|
|
123
|
+
const sources = [];
|
|
124
124
|
for (const format of smartCdnImageFormats) {
|
|
125
125
|
const quality = formats[format];
|
|
126
126
|
if (quality == null) {
|
|
@@ -137,9 +137,9 @@ export function getSignedSmartCdnImageCandidates(opts) {
|
|
|
137
137
|
urlParams: { f: format, q: quality, r: 'fit', w: width },
|
|
138
138
|
workspace: opts.workspace,
|
|
139
139
|
});
|
|
140
|
-
candidates.push(
|
|
140
|
+
candidates.push({ url, width });
|
|
141
141
|
}
|
|
142
|
-
sources
|
|
142
|
+
sources.push({ candidates, format, quality });
|
|
143
143
|
}
|
|
144
|
-
return {
|
|
144
|
+
return { fallbackUrl: opts.input, sources };
|
|
145
145
|
}
|