@drawbridge/drawbridge-utils 0.0.12 → 0.0.13

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/cdn.cjs ADDED
@@ -0,0 +1,37 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // cdn.js
20
+ var cdn_exports = {};
21
+ __export(cdn_exports, {
22
+ cdnSrc: () => cdnSrc
23
+ });
24
+ module.exports = __toCommonJS(cdn_exports);
25
+ var cdnSrc = (asset, size, timestamp) => {
26
+ var _a;
27
+ const src = (_a = asset == null ? void 0 : asset.sizes) == null ? void 0 : _a[size];
28
+ if (!src || !timestamp) return void 0;
29
+ return [
30
+ src,
31
+ "?query=" + timestamp
32
+ ].join("");
33
+ };
34
+ // Annotate the CommonJS export names for ESM import in node:
35
+ 0 && (module.exports = {
36
+ cdnSrc
37
+ });
package/dist/cdn.d.cts ADDED
@@ -0,0 +1,20 @@
1
+ // Build a DigitalOcean Spaces CDN URL with a cache-busting query string.
2
+ // `asset` is any object with a `sizes` map. `size` is the sizes key (e.g.
3
+ // '100x100', 'original', 'hsl'). `timestamp` is required — without it the
4
+ // URL would never change across uploads and the CDN/browser would serve a
5
+ // stale asset. Pass the asset's own `updatedAt` when it has one, or the
6
+ // parent document's `updatedAt` for embedded assets like `user.image`.
7
+ const cdnSrc = ( asset, size, timestamp ) => {
8
+
9
+ const src = asset?.sizes?.[ size ];
10
+
11
+ if( ! src || ! timestamp ) return undefined;
12
+
13
+ return [
14
+ src,
15
+ '?query=' + timestamp
16
+ ].join( '' );
17
+
18
+ };
19
+
20
+ export { cdnSrc };
package/dist/cdn.d.ts ADDED
@@ -0,0 +1,20 @@
1
+ // Build a DigitalOcean Spaces CDN URL with a cache-busting query string.
2
+ // `asset` is any object with a `sizes` map. `size` is the sizes key (e.g.
3
+ // '100x100', 'original', 'hsl'). `timestamp` is required — without it the
4
+ // URL would never change across uploads and the CDN/browser would serve a
5
+ // stale asset. Pass the asset's own `updatedAt` when it has one, or the
6
+ // parent document's `updatedAt` for embedded assets like `user.image`.
7
+ const cdnSrc = ( asset, size, timestamp ) => {
8
+
9
+ const src = asset?.sizes?.[ size ];
10
+
11
+ if( ! src || ! timestamp ) return undefined;
12
+
13
+ return [
14
+ src,
15
+ '?query=' + timestamp
16
+ ].join( '' );
17
+
18
+ };
19
+
20
+ export { cdnSrc };
package/dist/cdn.js ADDED
@@ -0,0 +1,13 @@
1
+ // cdn.js
2
+ var cdnSrc = (asset, size, timestamp) => {
3
+ var _a;
4
+ const src = (_a = asset == null ? void 0 : asset.sizes) == null ? void 0 : _a[size];
5
+ if (!src || !timestamp) return void 0;
6
+ return [
7
+ src,
8
+ "?query=" + timestamp
9
+ ].join("");
10
+ };
11
+ export {
12
+ cdnSrc
13
+ };
package/package.json CHANGED
@@ -42,6 +42,11 @@
42
42
  "types": "./dist/redirect.d.ts",
43
43
  "import": "./dist/redirect.js",
44
44
  "require": "./dist/redirect.cjs"
45
+ },
46
+ "./cdn": {
47
+ "types": "./dist/cdn.d.ts",
48
+ "import": "./dist/cdn.js",
49
+ "require": "./dist/cdn.cjs"
45
50
  }
46
51
  },
47
52
  "files": [
@@ -58,5 +63,5 @@
58
63
  "build": "tsup && npm publish"
59
64
  },
60
65
  "types": "dist/index.d.ts",
61
- "version": "0.0.12"
66
+ "version": "0.0.13"
62
67
  }