imgix-url-builder 0.0.4 → 0.0.6
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/Client.cjs +143 -0
- package/dist/Client.cjs.map +1 -0
- package/dist/Client.d.ts +145 -0
- package/dist/{index.mjs → Client.js} +11 -41
- package/dist/Client.js.map +1 -0
- package/dist/buildPixelDensitySrcSet.cjs +10 -0
- package/dist/buildPixelDensitySrcSet.cjs.map +1 -0
- package/dist/buildPixelDensitySrcSet.d.ts +58 -0
- package/dist/buildPixelDensitySrcSet.js +10 -0
- package/dist/buildPixelDensitySrcSet.js.map +1 -0
- package/dist/buildURL.cjs +29 -0
- package/dist/buildURL.cjs.map +1 -0
- package/dist/buildURL.d.ts +36 -0
- package/dist/buildURL.js +29 -0
- package/dist/buildURL.js.map +1 -0
- package/dist/buildWidthSrcSet.cjs +10 -0
- package/dist/buildWidthSrcSet.cjs.map +1 -0
- package/dist/buildWidthSrcSet.d.ts +56 -0
- package/dist/buildWidthSrcSet.js +10 -0
- package/dist/buildWidthSrcSet.js.map +1 -0
- package/dist/index.cjs +10 -179
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +8 -2734
- package/dist/index.js +11 -173
- package/dist/index.js.map +1 -0
- package/dist/node/{index.cjs → SecureClient.cjs} +31 -98
- package/dist/node/SecureClient.cjs.map +1 -0
- package/dist/node/SecureClient.d.ts +502 -0
- package/dist/node/{index.mjs → SecureClient.js} +25 -83
- package/dist/node/SecureClient.js.map +1 -0
- package/dist/node/buildSignedPixelDensitySrcSet.cjs +13 -0
- package/dist/node/buildSignedPixelDensitySrcSet.cjs.map +1 -0
- package/dist/node/buildSignedPixelDensitySrcSet.d.ts +54 -0
- package/dist/node/buildSignedPixelDensitySrcSet.js +13 -0
- package/dist/node/buildSignedPixelDensitySrcSet.js.map +1 -0
- package/dist/node/buildSignedURL.cjs +9 -0
- package/dist/node/buildSignedURL.cjs.map +1 -0
- package/dist/node/buildSignedURL.d.ts +49 -0
- package/dist/node/buildSignedURL.js +9 -0
- package/dist/node/buildSignedURL.js.map +1 -0
- package/dist/node/buildSignedWidthSrcSet.cjs +14 -0
- package/dist/node/buildSignedWidthSrcSet.cjs.map +1 -0
- package/dist/node/buildSignedWidthSrcSet.d.ts +54 -0
- package/dist/node/buildSignedWidthSrcSet.js +14 -0
- package/dist/node/buildSignedWidthSrcSet.js.map +1 -0
- package/dist/node/index.d.ts +7 -3196
- package/dist/node/signURL.cjs +12 -0
- package/dist/node/signURL.cjs.map +1 -0
- package/dist/node/signURL.d.ts +27 -0
- package/dist/node/signURL.js +12 -0
- package/dist/node/signURL.js.map +1 -0
- package/dist/node.cjs +15 -0
- package/dist/node.cjs.map +1 -0
- package/dist/node.js +15 -0
- package/dist/node.js.map +1 -0
- package/dist/types.generated.d.ts +2746 -0
- package/package.json +57 -33
- package/src/buildWidthSrcSet.ts +7 -3
- package/src/types.generated.ts +1243 -480
- package/dist/index.mjs.map +0 -1
- package/dist/node/index.cjs.map +0 -1
- package/dist/node/index.d.ts.map +0 -1
- package/dist/node/index.mjs.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,173 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
instance.searchParams.delete(paramKey);
|
|
13
|
-
} else if (Array.isArray(paramValue)) {
|
|
14
|
-
instance.searchParams.set(paramKey, paramValue.join(","));
|
|
15
|
-
} else {
|
|
16
|
-
instance.searchParams.set(paramKey, `${paramValue}`);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
const s = instance.searchParams.get("s");
|
|
20
|
-
if (s) {
|
|
21
|
-
instance.searchParams.delete("s");
|
|
22
|
-
instance.searchParams.append("s", s);
|
|
23
|
-
}
|
|
24
|
-
return instance.toString();
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
const buildPixelDensitySrcSet = (url, { pixelDensities, ...params }) => {
|
|
28
|
-
return pixelDensities.map((dpr) => {
|
|
29
|
-
return `${buildURL(url, { ...params, dpr })} ${dpr}x`;
|
|
30
|
-
}).join(", ");
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
const buildWidthSrcSet = (url, { widths, ...params }) => {
|
|
34
|
-
return widths.map((width) => {
|
|
35
|
-
return `${buildURL(url, { ...params, w: void 0, width })} ${width}w`;
|
|
36
|
-
}).join(", ");
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
class Client {
|
|
40
|
-
/**
|
|
41
|
-
* Creates a new `Client` instance for an Imgix domain.
|
|
42
|
-
*
|
|
43
|
-
* @param options - Options to instantiate a new client.
|
|
44
|
-
*
|
|
45
|
-
* @returns A `Client` instance for the given Imgix domain.
|
|
46
|
-
*/
|
|
47
|
-
constructor(options) {
|
|
48
|
-
this.baseURL = options.baseURL;
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Builds a URL to an Imgix image with Imgix URL API parameters for the
|
|
52
|
-
* client's base URL.
|
|
53
|
-
*
|
|
54
|
-
* @example
|
|
55
|
-
*
|
|
56
|
-
* ```ts
|
|
57
|
-
* const client = new Client({ baseURL: "https://example.imgix.net" });
|
|
58
|
-
* const url = client.buildURLForPath("/image.png", { width: 400 });
|
|
59
|
-
* // => https://example.imgix.net/image.png?width=400
|
|
60
|
-
* ```
|
|
61
|
-
*
|
|
62
|
-
* @example
|
|
63
|
-
*
|
|
64
|
-
* ```ts
|
|
65
|
-
* const client = new Client({
|
|
66
|
-
* baseURL: "https://example.imgix.net/folder",
|
|
67
|
-
* });
|
|
68
|
-
* const url = client.buildURLForPath("./image.png", { width: 400 });
|
|
69
|
-
* // => https://example.imgix.net/folder/image.png?width=400
|
|
70
|
-
* ```
|
|
71
|
-
*
|
|
72
|
-
* @param path - Path to the image relative to the client's base URL.
|
|
73
|
-
* @param params - An object of Imgix URL API parameters.
|
|
74
|
-
*
|
|
75
|
-
* @returns The full absolute URL to the image with the given Imgix URL API
|
|
76
|
-
* parameters applied.
|
|
77
|
-
*/
|
|
78
|
-
buildURLForPath(path, params = {}) {
|
|
79
|
-
return buildURL(`${new URL(path, this.baseURL)}`, params);
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Builds an `<img>` `srcset` attribute value for a given set of widths for
|
|
83
|
-
* the client's base URL. It can also optinally apply Imgix URL API parameters
|
|
84
|
-
* to the URLs.
|
|
85
|
-
*
|
|
86
|
-
* The `width` URL parameter will be applied for each `srcset` entry. If a
|
|
87
|
-
* `width` or `w` parameter is provided to the `params` parameter, it will be
|
|
88
|
-
* ignored.
|
|
89
|
-
*
|
|
90
|
-
* @example
|
|
91
|
-
*
|
|
92
|
-
* ```ts
|
|
93
|
-
* const client = new Client({ baseURL: "https://example.imgix.net" });
|
|
94
|
-
* const srcset = client.buildWidthSrcSetForPath("/image.png", {
|
|
95
|
-
* widths: [400, 800, 1600],
|
|
96
|
-
* });
|
|
97
|
-
* // => https://example.imgix.net/image.png?width=400 400w,
|
|
98
|
-
* // https://example.imgix.net/image.png?width=800 800w,
|
|
99
|
-
* // https://example.imgix.net/image.png?width=1600 1600w
|
|
100
|
-
* ```
|
|
101
|
-
*
|
|
102
|
-
* @example
|
|
103
|
-
*
|
|
104
|
-
* ```ts
|
|
105
|
-
* const client = new Client({
|
|
106
|
-
* baseURL: "https://example.imgix.net",
|
|
107
|
-
* });
|
|
108
|
-
* const srcset = client.buildWidthSrcSetForPath("/image.png", {
|
|
109
|
-
* widths: [400, 800, 1600],
|
|
110
|
-
* sat: -100,
|
|
111
|
-
* });
|
|
112
|
-
* // => https://example.imgix.net/image.png?width=400&sat=-100 400w,
|
|
113
|
-
* // https://example.imgix.net/image.png?width=800&sat=-100 800w,
|
|
114
|
-
* // https://example.imgix.net/image.png?width=1600&sat=-100 1600w
|
|
115
|
-
* ```
|
|
116
|
-
*
|
|
117
|
-
* @param path - Path to the image relative to the client's base URL.
|
|
118
|
-
* @param params - An object of Imgix URL API parameters. The `widths`
|
|
119
|
-
* parameter defines the resulting `srcset` widths.
|
|
120
|
-
*
|
|
121
|
-
* @returns A `srcset` attribute value for `url` with the given Imgix URL API
|
|
122
|
-
* parameters applied.
|
|
123
|
-
*/
|
|
124
|
-
buildWidthSrcSetForPath(path, params) {
|
|
125
|
-
return buildWidthSrcSet(`${new URL(path, this.baseURL)}`, params);
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* Builds an `<img>` `srcset` attribute value for a given set of pixel
|
|
129
|
-
* densities for the client's base URL. It can also optinally apply Imgix URL
|
|
130
|
-
* API parameters to the URLs.
|
|
131
|
-
*
|
|
132
|
-
* The `dpr` URL parameter will be applied for each `srcset` entry. If a `dpr`
|
|
133
|
-
* parameter is provided to the `params` parameter, it will be ignored.
|
|
134
|
-
*
|
|
135
|
-
* @example
|
|
136
|
-
*
|
|
137
|
-
* ```ts
|
|
138
|
-
* const client = new Client({ baseURL: "https://example.imgix.net" });
|
|
139
|
-
* const srcset = client.buildPixelDensitySrcSetForPath("/image.png", {
|
|
140
|
-
* pixelDensities: [1, 2, 3],
|
|
141
|
-
* });
|
|
142
|
-
* // => https://example.imgix.net/image.png?dpr=1 1x,
|
|
143
|
-
* // https://example.imgix.net/image.png?dpr=2 2x,
|
|
144
|
-
* // https://example.imgix.net/image.png?dpr=3 3x
|
|
145
|
-
* ```
|
|
146
|
-
*
|
|
147
|
-
* @example
|
|
148
|
-
*
|
|
149
|
-
* ```ts
|
|
150
|
-
* const client = new Client({ baseURL: "https://example.imgix.net" });
|
|
151
|
-
* const srcset = client.buildPixelDensitySrcSetForPath("/image.png", {
|
|
152
|
-
* pixelDensities: [1, 2, 3],
|
|
153
|
-
* sat: -100,
|
|
154
|
-
* });
|
|
155
|
-
* // => https://example.imgix.net/image.png?dpr=1&sat=-100 1x,
|
|
156
|
-
* // https://example.imgix.net/image.png?dpr=2&sat=-100 2x,
|
|
157
|
-
* // https://example.imgix.net/image.png?dpr=3&sat=-100 3x
|
|
158
|
-
* ```
|
|
159
|
-
*
|
|
160
|
-
* @param path - Path to the image relative to the client's base URL.
|
|
161
|
-
* @param params - An object of Imgix URL API parameters. The `pixelDensities`
|
|
162
|
-
* parameter defines the resulting `srcset` widths.
|
|
163
|
-
*
|
|
164
|
-
* @returns A `srcset` attribute value for `url` with the given Imgix URL API
|
|
165
|
-
* parameters applied.
|
|
166
|
-
*/
|
|
167
|
-
buildPixelDensitySrcSetForPath(path, params) {
|
|
168
|
-
return buildPixelDensitySrcSet(`${new URL(path, this.baseURL)}`, params);
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
export { Client, buildPixelDensitySrcSet, buildURL, buildWidthSrcSet };
|
|
173
|
-
//# sourceMappingURL=index.mjs.map
|
|
1
|
+
import { Client } from "./Client.js";
|
|
2
|
+
import { buildURL } from "./buildURL.js";
|
|
3
|
+
import { buildWidthSrcSet } from "./buildWidthSrcSet.js";
|
|
4
|
+
import { buildPixelDensitySrcSet } from "./buildPixelDensitySrcSet.js";
|
|
5
|
+
export {
|
|
6
|
+
Client,
|
|
7
|
+
buildPixelDensitySrcSet,
|
|
8
|
+
buildURL,
|
|
9
|
+
buildWidthSrcSet
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|
|
@@ -1,78 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
const instance = new URL(url);
|
|
14
|
-
for (const camelCasedParamKey in params) {
|
|
15
|
-
const paramKey = camelCaseToParamCase(camelCasedParamKey);
|
|
16
|
-
const paramValue = params[camelCasedParamKey];
|
|
17
|
-
if (paramValue === void 0) {
|
|
18
|
-
instance.searchParams.delete(paramKey);
|
|
19
|
-
} else if (Array.isArray(paramValue)) {
|
|
20
|
-
instance.searchParams.set(paramKey, paramValue.join(","));
|
|
21
|
-
} else {
|
|
22
|
-
instance.searchParams.set(paramKey, `${paramValue}`);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
const s = instance.searchParams.get("s");
|
|
26
|
-
if (s) {
|
|
27
|
-
instance.searchParams.delete("s");
|
|
28
|
-
instance.searchParams.append("s", s);
|
|
29
|
-
}
|
|
30
|
-
return instance.toString();
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
const buildPixelDensitySrcSet = (url, { pixelDensities, ...params }) => {
|
|
34
|
-
return pixelDensities.map((dpr) => {
|
|
35
|
-
return `${buildURL(url, { ...params, dpr })} ${dpr}x`;
|
|
36
|
-
}).join(", ");
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
const signURL = (url, secureURLToken) => {
|
|
40
|
-
const instance = new URL(url);
|
|
41
|
-
instance.searchParams.delete("s");
|
|
42
|
-
const signature = crypto.createHash("md5").update(secureURLToken + instance.pathname + instance.search).digest("hex");
|
|
43
|
-
instance.searchParams.append("s", signature);
|
|
44
|
-
return instance.toString();
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
const buildSignedURL = (url, secureURLToken, params) => {
|
|
48
|
-
return signURL(buildURL(url, params), secureURLToken);
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
const buildSignedPixelDensitySrcSet = (url, secureURLToken, { pixelDensities, ...params }) => {
|
|
52
|
-
return pixelDensities.map((dpr) => {
|
|
53
|
-
return `${buildSignedURL(url, secureURLToken, {
|
|
54
|
-
...params,
|
|
55
|
-
dpr
|
|
56
|
-
})} ${dpr}x`;
|
|
57
|
-
}).join(", ");
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
const buildSignedWidthSrcSet = (url, secureURLToken, { widths, ...params }) => {
|
|
61
|
-
return widths.map((width) => {
|
|
62
|
-
return `${buildSignedURL(url, secureURLToken, {
|
|
63
|
-
...params,
|
|
64
|
-
w: void 0,
|
|
65
|
-
width
|
|
66
|
-
})} ${width}w`;
|
|
67
|
-
}).join(", ");
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
const buildWidthSrcSet = (url, { widths, ...params }) => {
|
|
71
|
-
return widths.map((width) => {
|
|
72
|
-
return `${buildURL(url, { ...params, w: void 0, width })} ${width}w`;
|
|
73
|
-
}).join(", ");
|
|
74
|
-
};
|
|
75
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
6
|
+
const buildPixelDensitySrcSet = require("../buildPixelDensitySrcSet.cjs");
|
|
7
|
+
const buildSignedPixelDensitySrcSet = require("./buildSignedPixelDensitySrcSet.cjs");
|
|
8
|
+
const buildSignedURL = require("./buildSignedURL.cjs");
|
|
9
|
+
const buildSignedWidthSrcSet = require("./buildSignedWidthSrcSet.cjs");
|
|
10
|
+
const buildURL = require("../buildURL.cjs");
|
|
11
|
+
const buildWidthSrcSet = require("../buildWidthSrcSet.cjs");
|
|
12
|
+
const signURL = require("./signURL.cjs");
|
|
76
13
|
class SecureClient {
|
|
77
14
|
/**
|
|
78
15
|
* Creates a new `SecureClient` instance for an Imgix domain.
|
|
@@ -82,6 +19,15 @@ class SecureClient {
|
|
|
82
19
|
* @returns A `SecureClient` instance for the given Imgix domain.
|
|
83
20
|
*/
|
|
84
21
|
constructor(options) {
|
|
22
|
+
/**
|
|
23
|
+
* The base URL used to construct image URLs from a path. The base URL must
|
|
24
|
+
* include the protocol, domain, and optionally a path.
|
|
25
|
+
*/
|
|
26
|
+
__publicField(this, "baseURL");
|
|
27
|
+
/**
|
|
28
|
+
* The secret secure URL token for the configured Imgix domain.
|
|
29
|
+
*/
|
|
30
|
+
__publicField(this, "secureURLToken");
|
|
85
31
|
this.baseURL = options.baseURL;
|
|
86
32
|
this.secureURLToken = options.secureURLToken;
|
|
87
33
|
}
|
|
@@ -185,7 +131,7 @@ class SecureClient {
|
|
|
185
131
|
* parameters applied.
|
|
186
132
|
*/
|
|
187
133
|
buildURLForPath(path, params = {}) {
|
|
188
|
-
return buildURL(`${new URL(path, this.baseURL)}`, params);
|
|
134
|
+
return buildURL.buildURL(`${new URL(path, this.baseURL)}`, params);
|
|
189
135
|
}
|
|
190
136
|
/**
|
|
191
137
|
* Builds a URL to an Imgix image with Imgix URL API parameters. The URL is
|
|
@@ -228,7 +174,7 @@ class SecureClient {
|
|
|
228
174
|
* @see Details on securing Imgix images: https://docs.imgix.com/setup/securing-images
|
|
229
175
|
*/
|
|
230
176
|
buildSignedURL(url, params = {}) {
|
|
231
|
-
return buildSignedURL(url, this.secureURLToken, params);
|
|
177
|
+
return buildSignedURL.buildSignedURL(url, this.secureURLToken, params);
|
|
232
178
|
}
|
|
233
179
|
/**
|
|
234
180
|
* Signs an Imgix image URL by appending a signature to the URL parameters.
|
|
@@ -251,7 +197,7 @@ class SecureClient {
|
|
|
251
197
|
* @see Details on securing Imgix images: https://docs.imgix.com/setup/securing-images
|
|
252
198
|
*/
|
|
253
199
|
signURL(url) {
|
|
254
|
-
return signURL(url, this.secureURLToken);
|
|
200
|
+
return signURL.signURL(url, this.secureURLToken);
|
|
255
201
|
}
|
|
256
202
|
/**
|
|
257
203
|
* Builds an `<img>` `srcset` attribute value for a given set of widths. It
|
|
@@ -298,7 +244,7 @@ class SecureClient {
|
|
|
298
244
|
* parameters applied.
|
|
299
245
|
*/
|
|
300
246
|
buildSignedWidthSrcSet(url, params) {
|
|
301
|
-
return buildSignedWidthSrcSet(url, this.secureURLToken, params);
|
|
247
|
+
return buildSignedWidthSrcSet.buildSignedWidthSrcSet(url, this.secureURLToken, params);
|
|
302
248
|
}
|
|
303
249
|
/**
|
|
304
250
|
* Builds an `<img>` `srcset` attribute value for a given set of widths for
|
|
@@ -351,7 +297,7 @@ class SecureClient {
|
|
|
351
297
|
* parameters applied.
|
|
352
298
|
*/
|
|
353
299
|
buildWidthSrcSetForPath(path, params) {
|
|
354
|
-
return buildWidthSrcSet(`${new URL(path, this.baseURL)}`, params);
|
|
300
|
+
return buildWidthSrcSet.buildWidthSrcSet(`${new URL(path, this.baseURL)}`, params);
|
|
355
301
|
}
|
|
356
302
|
/**
|
|
357
303
|
* Builds an `<img>` `srcset` attribute value for a given set of widths for
|
|
@@ -403,10 +349,7 @@ class SecureClient {
|
|
|
403
349
|
* parameters applied.
|
|
404
350
|
*/
|
|
405
351
|
buildSignedWidthSrcSetForPath(path, params) {
|
|
406
|
-
return this.buildSignedWidthSrcSet(
|
|
407
|
-
`${new URL(path, this.baseURL)}`,
|
|
408
|
-
params
|
|
409
|
-
);
|
|
352
|
+
return this.buildSignedWidthSrcSet(`${new URL(path, this.baseURL)}`, params);
|
|
410
353
|
}
|
|
411
354
|
/**
|
|
412
355
|
* Builds an `<img>` `srcset` attribute value for a given set of pixel
|
|
@@ -453,7 +396,7 @@ class SecureClient {
|
|
|
453
396
|
* parameters applied.
|
|
454
397
|
*/
|
|
455
398
|
buildSignedPixelDensitySrcSet(url, params) {
|
|
456
|
-
return buildSignedPixelDensitySrcSet(url, this.secureURLToken, params);
|
|
399
|
+
return buildSignedPixelDensitySrcSet.buildSignedPixelDensitySrcSet(url, this.secureURLToken, params);
|
|
457
400
|
}
|
|
458
401
|
/**
|
|
459
402
|
* Builds an `<img>` `srcset` attribute value for a given set of pixel
|
|
@@ -505,7 +448,7 @@ class SecureClient {
|
|
|
505
448
|
* parameters applied.
|
|
506
449
|
*/
|
|
507
450
|
buildPixelDensitySrcSetForPath(path, params) {
|
|
508
|
-
return buildPixelDensitySrcSet(`${new URL(path, this.baseURL)}`, params);
|
|
451
|
+
return buildPixelDensitySrcSet.buildPixelDensitySrcSet(`${new URL(path, this.baseURL)}`, params);
|
|
509
452
|
}
|
|
510
453
|
/**
|
|
511
454
|
* Builds an `<img>` `srcset` attribute value for a given set of pixel
|
|
@@ -560,18 +503,8 @@ class SecureClient {
|
|
|
560
503
|
* parameters applied.
|
|
561
504
|
*/
|
|
562
505
|
buildSignedPixelDensitySrcSetForPath(path, params) {
|
|
563
|
-
return buildSignedPixelDensitySrcSet(
|
|
564
|
-
`${new URL(path, this.baseURL)}`,
|
|
565
|
-
this.secureURLToken,
|
|
566
|
-
params
|
|
567
|
-
);
|
|
506
|
+
return buildSignedPixelDensitySrcSet.buildSignedPixelDensitySrcSet(`${new URL(path, this.baseURL)}`, this.secureURLToken, params);
|
|
568
507
|
}
|
|
569
508
|
}
|
|
570
|
-
|
|
571
509
|
exports.SecureClient = SecureClient;
|
|
572
|
-
|
|
573
|
-
exports.buildSignedURL = buildSignedURL;
|
|
574
|
-
exports.buildSignedWidthSrcSet = buildSignedWidthSrcSet;
|
|
575
|
-
exports.buildURL = buildURL;
|
|
576
|
-
exports.signURL = signURL;
|
|
577
|
-
//# sourceMappingURL=index.cjs.map
|
|
510
|
+
//# sourceMappingURL=SecureClient.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SecureClient.cjs","sources":["../../../src/node/SecureClient.ts"],"sourcesContent":["import type { BuildPixelDensitySrcSetParams } from \"../buildPixelDensitySrcSet\";\nimport type { BuildWidthSrcSetParams } from \"../buildWidthSrcSet\";\nimport type { ImgixURLParams } from \"../types.generated\";\nimport { buildPixelDensitySrcSet } from \"../buildPixelDensitySrcSet\";\nimport { buildSignedPixelDensitySrcSet } from \"./buildSignedPixelDensitySrcSet\";\nimport { buildSignedURL } from \"./buildSignedURL\";\nimport { buildSignedWidthSrcSet } from \"./buildSignedWidthSrcSet\";\nimport { buildURL } from \"../buildURL\";\nimport { buildWidthSrcSet } from \"../buildWidthSrcSet\";\nimport { signURL } from \"./signURL\";\n\n/**\n * Options to instantiate a new secure client.\n */\nexport type SecureClientOptions = {\n\t/**\n\t * The base URL used to construct image URLs from a path. The base URL must\n\t * include the protocol, domain, and optionally a path.\n\t *\n\t * @example `https://example.imgix.net`\n\t *\n\t * @example `https://example.imgix.net/folder`\n\t */\n\tbaseURL: string;\n\n\t/**\n\t * The secret secure URL token for the configured Imgix domain.\n\t *\n\t * @see How to get a token: https://docs.imgix.com/setup/securing-images\n\t */\n\tsecureURLToken: string;\n};\n\n/**\n * An Imgix Rendering API client with automatic URL signing. A client is paired\n * to a single Imgix domain and secure URL token.\n *\n * **Important**: This client should only be used in a trusted environment and\n * never in a browser. The `secureURLToken` parameter is a secret and should not\n * be exposed to the public.\n */\nexport class SecureClient {\n\t/**\n\t * The base URL used to construct image URLs from a path. The base URL must\n\t * include the protocol, domain, and optionally a path.\n\t */\n\tbaseURL: string;\n\n\t/**\n\t * The secret secure URL token for the configured Imgix domain.\n\t */\n\tsecureURLToken: string;\n\n\t/**\n\t * Creates a new `SecureClient` instance for an Imgix domain.\n\t *\n\t * @param options - Options to instantiate a new client.\n\t *\n\t * @returns A `SecureClient` instance for the given Imgix domain.\n\t */\n\tconstructor(options: SecureClientOptions) {\n\t\tthis.baseURL = options.baseURL;\n\t\tthis.secureURLToken = options.secureURLToken;\n\t}\n\n\t/**\n\t * Builds a Web Proxy URL that proxies a non-Imgix URL to Imgix. The client's\n\t * Imgix domain must be configured as a Web Proxy source. All Web Proxy URLs\n\t * will be signed automatically.\n\t *\n\t * **Important**: The given URL must not be URI encoded. If it is, decode it\n\t * before passing it to `buildWebProxyURL()`.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const client = new SecureClient({\n\t * \tbaseURL: \"https://example.imgix.net\",\n\t * \tsecureURLToken: \"example-token\",\n\t * });\n\t * const url = client.buildWebProxyURL(\"https://www.this.com/pic.jpg\", {\n\t * \twidth: 400,\n\t * });\n\t * // => https://example.imgix.net/https%3A%2F%2Fwww.this.com%2Fpic.jpg?width=400&s=def3e221c3f4c4debda091b8e49420ea\n\t * ```\n\t *\n\t * @param url - Full absolute URL to the source image to proxy.\n\t * @param params - An object of Imgix URL API parameters.\n\t *\n\t * @returns An Imgix url proxying `url` to the client's Imgix domain.\n\t */\n\tbuildWebProxyURL(url: string, params: ImgixURLParams = {}): string {\n\t\treturn this.buildSignedURLForPath(encodeURIComponent(url), params);\n\t}\n\n\t/**\n\t * Builds a URL to an Imgix image with Imgix URL API parameters for the\n\t * client's base URL.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const client = new SecureClient({\n\t * \tbaseURL: \"https://example.imgix.net\",\n\t * \tsecureURLToken: \"example-token\",\n\t * });\n\t * const url = client.buildURLForPath(\"/image.png\", { width: 400 });\n\t * // => https://example.imgix.net/image.png?width=400&s=def3e221c3f4c4debda091b8e49420ea\n\t * ```\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const client = new SecureClient({\n\t * \tbaseURL: \"https://example.imgix.net/folder\",\n\t * \tsecureURLToken: \"example-token\",\n\t * });\n\t * const url = client.buildURLForPath(\"./image.png\", { width: 400 });\n\t * // => https://example.imgix.net/folder/image.png?width=400&s=f12c7c39333410c10c2930b57116a943\n\t * ```\n\t *\n\t * @param path - Path to the image relative to the client's base URL.\n\t * @param params - An object of Imgix URL API parameters.\n\t *\n\t * @returns The full absolute URL to the image with the given Imgix URL API\n\t * parameters applied.\n\t */\n\tbuildSignedURLForPath(path: string, params: ImgixURLParams = {}): string {\n\t\treturn this.signURL(this.buildURLForPath(path, params));\n\t}\n\n\t/**\n\t * Builds a URL to an Imgix image with Imgix URL API parameters for the\n\t * client's base URL.\n\t *\n\t * Note: The returned URL is not signed. See `buildSignedURL` if a signature\n\t * is required.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const client = new SecureClient({\n\t * \tbaseURL: \"https://example.imgix.net\",\n\t * \tsecureURLToken: \"example-token\",\n\t * });\n\t * const url = client.buildURLForPath(\"/image.png\", { width: 400 });\n\t * // => https://example.imgix.net/image.png?width=400\n\t * ```\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const client = new SecureClient({\n\t * \tbaseURL: \"https://example.imgix.net/folder\",\n\t * \tsecureURLToken: \"example-token\",\n\t * });\n\t * const url = client.buildURLForPath(\"./image.png\", { width: 400 });\n\t * // => https://example.imgix.net/folder/image.png?width=400\n\t * ```\n\t *\n\t * @param path - Path to the image relative to the client's base URL.\n\t * @param params - An object of Imgix URL API parameters.\n\t *\n\t * @returns The full absolute URL to the image with the given Imgix URL API\n\t * parameters applied.\n\t */\n\tbuildURLForPath(path: string, params: ImgixURLParams = {}): string {\n\t\treturn buildURL(`${new URL(path, this.baseURL)}`, params);\n\t}\n\n\t/**\n\t * Builds a URL to an Imgix image with Imgix URL API parameters. The URL is\n\t * signed by appending a signature to the URL parameters. This locks the URL\n\t * and its parameters to the signature to prevent URL tampering.\n\t *\n\t * The given URL must be a full absolute URL containing the protocol and\n\t * domain.\n\t *\n\t * URL parameters already applied to the image will be retained. To remove\n\t * existing parameters, set the parameter to `undefined` in the `params`\n\t * argument.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const url = client.buildSignedURL(\n\t * \t\"https://example.imgix.net/image.png\",\n\t * \t{ width: 400 },\n\t * );\n\t * // => https://example.imgix.net/image.png?width=400&s=def3e221c3f4c4debda091b8e49420ea\n\t * ```\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const url = client.buildSignedURL(\n\t * \t\"https://example.imgix.net/image.png?width=400\",\n\t * \t{ height: 300 },\n\t * );\n\t * // => https://example.imgix.net/image.png?width=400&height=300&s=f12c7c39333410c10c2930b57116a943\n\t * ```\n\t *\n\t * @param url - Full absolute URL to the Imgix image.\n\t * @param params - An object of Imgix URL API parameters.\n\t *\n\t * @returns `url` with the given Imgix URL API parameters applied.\n\t *\n\t * @see Imgix URL API reference: https://docs.imgix.com/apis/rendering\n\t * @see Details on securing Imgix images: https://docs.imgix.com/setup/securing-images\n\t */\n\tbuildSignedURL(url: string, params: ImgixURLParams = {}): string {\n\t\treturn buildSignedURL(url, this.secureURLToken, params);\n\t}\n\n\t/**\n\t * Signs an Imgix image URL by appending a signature to the URL parameters.\n\t * This locks the URL and its parameters to the signature to prevent URL\n\t * tampering.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const url = client.signURL(\n\t * \t\"https://example.imgix.net/image.png?width=400\",\n\t * );\n\t * // => https://example.imgix.net/image.png?width=400&s=def3e221c3f4c4debda091b8e49420ea\n\t * ```\n\t *\n\t * @param url - Full absolute URL to the Imgix image to sign.\n\t *\n\t * @returns `url` with a signature appended via an `s` URL parameter.\n\t *\n\t * @see Details on securing Imgix images: https://docs.imgix.com/setup/securing-images\n\t */\n\tsignURL(url: string): string {\n\t\treturn signURL(url, this.secureURLToken);\n\t}\n\n\t/**\n\t * Builds an `<img>` `srcset` attribute value for a given set of widths. It\n\t * can also optinally apply Imgix URL API parameters to the URLs. The URLs are\n\t * signed by appending a signature to their URL parameters. This locks the\n\t * URLs and their parameters to the signature to prevent URL tampering.\n\t *\n\t * The `width` URL parameter will be applied for each `srcset` entry. If a\n\t * `width` or `w` parameter is provided to the `params` parameter, it will be\n\t * ignored.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const srcset = client.buildSignedWidthSrcSet(\n\t * \t\"https://example.imgix.net/image.png\",\n\t * \t{ widths: [400, 800, 1600] },\n\t * );\n\t * // => https://example.imgix.net/image.png?width=400&s=def3e221c3f4c4debda091b8e49420ea 400w,\n\t * // https://example.imgix.net/image.png?width=800&s=f12c7c39333410c10c2930b57116a943 800w,\n\t * // https://example.imgix.net/image.png?width=1600&s=3a975b5087ab7ad2ab91fe66072fd628 1600w\n\t * ```\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const srcset = client.buildSignedWidthSrcSet(\n\t * \t\"https://example.imgix.net/image.png\",\n\t * \t{\n\t * \t\twidths: [400, 800, 1600],\n\t * \t\tsat: -100,\n\t * \t},\n\t * );\n\t * // => https://example.imgix.net/image.png?width=400&sat=-100&s=def3e221c3f4c4debda091b8e49420ea 400w,\n\t * // https://example.imgix.net/image.png?width=800&sat=-100&s=f12c7c39333410c10c2930b57116a943 800w,\n\t * // https://example.imgix.net/image.png?width=1600&sat=-100&s=3a975b5087ab7ad2ab91fe66072fd628 1600w\n\t * ```\n\t *\n\t * @param url - Full absolute URL to the Imgix image.\n\t * @param params - An object of Imgix URL API parameters. The `widths`\n\t * parameter defines the resulting `srcset` widths.\n\t *\n\t * @returns A `srcset` attribute value for `url` with the given Imgix URL API\n\t * parameters applied.\n\t */\n\tbuildSignedWidthSrcSet(url: string, params: BuildWidthSrcSetParams): string {\n\t\treturn buildSignedWidthSrcSet(url, this.secureURLToken, params);\n\t}\n\n\t/**\n\t * Builds an `<img>` `srcset` attribute value for a given set of widths for\n\t * the client's base URL. It can also optinally apply Imgix URL API parameters\n\t * to the URLs.\n\t *\n\t * The `width` URL parameter will be applied for each `srcset` entry. If a\n\t * `width` or `w` parameter is provided to the `params` parameter, it will be\n\t * ignored.\n\t *\n\t * Note: The returned URLs are not signed. See `buildSignedWidthSrcSet` if\n\t * signatures are required.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const client = new SecureClient({\n\t * \tbaseURL: \"https://example.imgix.net\",\n\t * \tsecureURLToken: \"example-token\",\n\t * });\n\t * const srcset = client.buildWidthSrcSetForPath(\"/image.png\", {\n\t * \twidths: [400, 800, 1600],\n\t * });\n\t * // => https://example.imgix.net/image.png?width=400 400w,\n\t * // https://example.imgix.net/image.png?width=800 800w,\n\t * // https://example.imgix.net/image.png?width=1600 1600w\n\t * ```\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const client = new SecureClient({\n\t * \tbaseURL: \"https://example.imgix.net\",\n\t * \tsecureURLToken: \"example-token\",\n\t * });\n\t * const srcset = client.buildWidthSrcSetForPath(\"/image.png\", {\n\t * \twidths: [400, 800, 1600],\n\t * \tsat: -100,\n\t * });\n\t * // => https://example.imgix.net/image.png?width=400&sat=-100 400w,\n\t * // https://example.imgix.net/image.png?width=800&sat=-100 800w,\n\t * // https://example.imgix.net/image.png?width=1600&sat=-100 1600w\n\t * ```\n\t *\n\t * @param path - Path to the image relative to the client's base URL.\n\t * @param params - An object of Imgix URL API parameters. The `widths`\n\t * parameter defines the resulting `srcset` widths.\n\t *\n\t * @returns A `srcset` attribute value for `url` with the given Imgix URL API\n\t * parameters applied.\n\t */\n\tbuildWidthSrcSetForPath(\n\t\tpath: string,\n\t\tparams: BuildWidthSrcSetParams,\n\t): string {\n\t\treturn buildWidthSrcSet(`${new URL(path, this.baseURL)}`, params);\n\t}\n\n\t/**\n\t * Builds an `<img>` `srcset` attribute value for a given set of widths for\n\t * the client's base URL. It can also optinally apply Imgix URL API parameters\n\t * to the URLs. The URLs are signed by appending a signature to their URL\n\t * parameters. This locks the URLs and their parameters to the signature to\n\t * prevent URL tampering.\n\t *\n\t * The `width` URL parameter will be applied for each `srcset` entry. If a\n\t * `width` or `w` parameter is provided to the `params` parameter, it will be\n\t * ignored.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const client = new SecureClient({\n\t * \tbaseURL: \"https://example.imgix.net\",\n\t * \tsecureURLToken: \"example-token\",\n\t * });\n\t * const srcset = client.buildSignedWidthSrcSetForPath(\"/image.png\", {\n\t * \twidths: [400, 800, 1600],\n\t * });\n\t * // => https://example.imgix.net/image.png?width=400&s=def3e221c3f4c4debda091b8e49420ea 400w,\n\t * // https://example.imgix.net/image.png?width=800&s=f12c7c39333410c10c2930b57116a943 800w,\n\t * // https://example.imgix.net/image.png?width=1600&s=3a975b5087ab7ad2ab91fe66072fd628 1600w\n\t * ```\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const client = new SecureClient({\n\t * \tbaseURL: \"https://example.imgix.net\",\n\t * \tsecureURLToken: \"example-token\",\n\t * });\n\t * const srcset = client.buildSignedWidthSrcSetForPath(\"/image.png\", {\n\t * \twidths: [400, 800, 1600],\n\t * \tsat: -100,\n\t * });\n\t * // => https://example.imgix.net/image.png?width=400&sat=-100&s=def3e221c3f4c4debda091b8e49420ea 400w,\n\t * // https://example.imgix.net/image.png?width=800&sat=-100&s=f12c7c39333410c10c2930b57116a943 800w,\n\t * // https://example.imgix.net/image.png?width=1600&sat=-100&s=3a975b5087ab7ad2ab91fe66072fd628 1600w\n\t * ```\n\t *\n\t * @param path - Path to the image relative to the client's base URL.\n\t * @param params - An object of Imgix URL API parameters. The `widths`\n\t * parameter defines the resulting `srcset` widths.\n\t *\n\t * @returns A `srcset` attribute value for `url` with the given Imgix URL API\n\t * parameters applied.\n\t */\n\tbuildSignedWidthSrcSetForPath(\n\t\tpath: string,\n\t\tparams: BuildWidthSrcSetParams,\n\t): string {\n\t\treturn this.buildSignedWidthSrcSet(\n\t\t\t`${new URL(path, this.baseURL)}`,\n\t\t\tparams,\n\t\t);\n\t}\n\n\t/**\n\t * Builds an `<img>` `srcset` attribute value for a given set of pixel\n\t * densities. It can also optinally apply Imgix URL API parameters to the\n\t * URLs. The URLs are signed by appending a signature to their URL parameters.\n\t * This locks the URLs and their parameters to the signature to prevent URL\n\t * tampering.\n\t *\n\t * The `dpr` URL parameter will be applied for each `srcset` entry. If a `dpr`\n\t * parameter is provided to the `params` parameter, it will be ignored.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const srcset = client.buildSignedPixelDensitySrcSet(\n\t * \t\"https://example.imgix.net/image.png\",\n\t * \t{ pixelDensities: [1, 2, 3] },\n\t * );\n\t * // => https://example.imgix.net/image.png?dpr=1&s=def3e221c3f4c4debda091b8e49420ea 1x,\n\t * // https://example.imgix.net/image.png?dpr=2&s=f12c7c39333410c10c2930b57116a943 2x,\n\t * // https://example.imgix.net/image.png?dpr=3&s=3a975b5087ab7ad2ab91fe66072fd628 3x\n\t * ```\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const srcset = client.buildSignedPixelDensitySrcSet(\n\t * \t\"https://example.imgix.net/image.png\",\n\t * \t{\n\t * \t\tpixelDensities: [1, 2, 3],\n\t * \t\tsat: -100,\n\t * \t},\n\t * );\n\t * // => https://example.imgix.net/image.png?dpr=1&sat=-100&s=def3e221c3f4c4debda091b8e49420ea 1x,\n\t * // https://example.imgix.net/image.png?dpr=2&sat=-100&s=f12c7c39333410c10c2930b57116a943 2x,\n\t * // https://example.imgix.net/image.png?dpr=3&sat=-100&s=3a975b5087ab7ad2ab91fe66072fd628 3x\n\t * ```\n\t *\n\t * @param url - Full absolute URL to the Imgix image.\n\t * @param params - An object of Imgix URL API parameters. The `pixelDensities`\n\t * parameter defines the resulting `srcset` widths.\n\t *\n\t * @returns A `srcset` attribute value for `url` with the given Imgix URL API\n\t * parameters applied.\n\t */\n\tbuildSignedPixelDensitySrcSet(\n\t\turl: string,\n\t\tparams: BuildPixelDensitySrcSetParams,\n\t): string {\n\t\treturn buildSignedPixelDensitySrcSet(url, this.secureURLToken, params);\n\t}\n\n\t/**\n\t * Builds an `<img>` `srcset` attribute value for a given set of pixel\n\t * densities for the client's base URL. It can also optinally apply Imgix URL\n\t * API parameters to the URLs.\n\t *\n\t * The `dpr` URL parameter will be applied for each `srcset` entry. If a `dpr`\n\t * parameter is provided to the `params` parameter, it will be ignored.\n\t *\n\t * Note: The returned URLs are not signed. See `buildSignedPixelDensitySrcSet`\n\t * if signatures are required.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const client = new SecureClient({\n\t * \tbaseURL: \"https://example.imgix.net\",\n\t * \tsecureURLToken: \"example-token\",\n\t * });\n\t * const srcset = client.buildPixelDensitySrcSetForPath(\"/image.png\", {\n\t * \tpixelDensities: [1, 2, 3],\n\t * });\n\t * // => https://example.imgix.net/image.png?dpr=1 1x,\n\t * // https://example.imgix.net/image.png?dpr=2 2x,\n\t * // https://example.imgix.net/image.png?dpr=3 3x\n\t * ```\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const client = new SecureClient({\n\t * \tbaseURL: \"https://example.imgix.net\",\n\t * \tsecureURLToken: \"example-token\",\n\t * });\n\t * const srcset = client.buildPixelDensitySrcSetForPath(\"/image.png\", {\n\t * \tpixelDensities: [1, 2, 3],\n\t * \tsat: -100,\n\t * });\n\t * // => https://example.imgix.net/image.png?dpr=1&sat=-100 1x,\n\t * // https://example.imgix.net/image.png?dpr=2&sat=-100 2x,\n\t * // https://example.imgix.net/image.png?dpr=3&sat=-100 3x\n\t * ```\n\t *\n\t * @param path - Path to the image relative to the client's base URL.\n\t * @param params - An object of Imgix URL API parameters. The `pixelDensities`\n\t * parameter defines the resulting `srcset` widths.\n\t *\n\t * @returns A `srcset` attribute value for `url` with the given Imgix URL API\n\t * parameters applied.\n\t */\n\tbuildPixelDensitySrcSetForPath(\n\t\tpath: string,\n\t\tparams: BuildPixelDensitySrcSetParams,\n\t): string {\n\t\treturn buildPixelDensitySrcSet(`${new URL(path, this.baseURL)}`, params);\n\t}\n\n\t/**\n\t * Builds an `<img>` `srcset` attribute value for a given set of pixel\n\t * densities for the client's base URL. It can also optinally apply Imgix URL\n\t * API parameters to the URLs. The URLs are signed by appending a signature to\n\t * their URL parameters. This locks the URLs and their parameters to the\n\t * signature to prevent URL tampering.\n\t *\n\t * The `dpr` URL parameter will be applied for each `srcset` entry. If a `dpr`\n\t * parameter is provided to the `params` parameter, it will be ignored.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const client = new SecureClient({\n\t * \tbaseURL: \"https://example.imgix.net\",\n\t * \tsecureURLToken: \"example-token\",\n\t * });\n\t * const srcset = client.buildSignedPixelDensitySrcSetForPath(\n\t * \t\"/image.png\",\n\t * \t{ pixelDensities: [1, 2, 3] },\n\t * );\n\t * // => https://example.imgix.net/image.png?dpr=1&s=def3e221c3f4c4debda091b8e49420ea 1x,\n\t * // https://example.imgix.net/image.png?dpr=2&s=f12c7c39333410c10c2930b57116a943 2x,\n\t * // https://example.imgix.net/image.png?dpr=3&s=3a975b5087ab7ad2ab91fe66072fd628 3x\n\t * ```\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const client = new SecureClient({\n\t * \tbaseURL: \"https://example.imgix.net\",\n\t * \tsecureURLToken: \"example-token\",\n\t * });\n\t * const srcset = client.buildSignedPixelDensitySrcSetForPath(\n\t * \t\"/image.png\",\n\t * \t{\n\t * \t\tpixelDensities: [1, 2, 3],\n\t * \t\tsat: -100,\n\t * \t},\n\t * );\n\t * // => https://example.imgix.net/image.png?dpr=1&sat=-100&s=def3e221c3f4c4debda091b8e49420ea 1x,\n\t * // https://example.imgix.net/image.png?dpr=2&sat=-100&s=f12c7c39333410c10c2930b57116a943 2x,\n\t * // https://example.imgix.net/image.png?dpr=3&sat=-100&s=3a975b5087ab7ad2ab91fe66072fd628 3x\n\t * ```\n\t *\n\t * @param path - Path to the image relative to the client's base URL.\n\t * @param params - An object of Imgix URL API parameters. The `pixelDensities`\n\t * parameter defines the resulting `srcset` widths.\n\t *\n\t * @returns A `srcset` attribute value for `url` with the given Imgix URL API\n\t * parameters applied.\n\t */\n\tbuildSignedPixelDensitySrcSetForPath(\n\t\tpath: string,\n\t\tparams: BuildPixelDensitySrcSetParams,\n\t): string {\n\t\treturn buildSignedPixelDensitySrcSet(\n\t\t\t`${new URL(path, this.baseURL)}`,\n\t\t\tthis.secureURLToken,\n\t\t\tparams,\n\t\t);\n\t}\n}\n"],"names":["buildURL","buildSignedURL","signURL","buildSignedWidthSrcSet","buildWidthSrcSet","buildSignedPixelDensitySrcSet","buildPixelDensitySrcSet"],"mappings":";;;;;;;;;;;;MAyCa,aAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAmBxB,YAAY,SAA4B;AAdxC;AAAA;AAAA;AAAA;AAAA;AAKA;AAAA;AAAA;AAAA;AAUC,SAAK,UAAU,QAAQ;AACvB,SAAK,iBAAiB,QAAQ;AAAA,EAC/B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA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