dreep 0.2.0 → 0.4.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 (34) hide show
  1. package/README.md +31 -0
  2. package/dist/cjs/constants/transform.d.ts +3 -0
  3. package/dist/cjs/constants/transform.d.ts.map +1 -1
  4. package/dist/cjs/constants/transform.js +9 -1
  5. package/dist/cjs/constants/transform.js.map +1 -1
  6. package/dist/cjs/index.d.ts +2 -0
  7. package/dist/cjs/index.d.ts.map +1 -1
  8. package/dist/cjs/index.js +3 -1
  9. package/dist/cjs/index.js.map +1 -1
  10. package/dist/cjs/url/toDreepUrl/index.d.ts +38 -0
  11. package/dist/cjs/url/toDreepUrl/index.d.ts.map +1 -0
  12. package/dist/cjs/url/toDreepUrl/index.js +43 -0
  13. package/dist/cjs/url/toDreepUrl/index.js.map +1 -0
  14. package/dist/cjs/url/toDreepUrl/matchFrom/index.d.ts +16 -0
  15. package/dist/cjs/url/toDreepUrl/matchFrom/index.d.ts.map +1 -0
  16. package/dist/cjs/url/toDreepUrl/matchFrom/index.js +34 -0
  17. package/dist/cjs/url/toDreepUrl/matchFrom/index.js.map +1 -0
  18. package/dist/esm/constants/transform.d.ts +3 -0
  19. package/dist/esm/constants/transform.d.ts.map +1 -1
  20. package/dist/esm/constants/transform.js +8 -0
  21. package/dist/esm/constants/transform.js.map +1 -1
  22. package/dist/esm/index.d.ts +2 -0
  23. package/dist/esm/index.d.ts.map +1 -1
  24. package/dist/esm/index.js +1 -0
  25. package/dist/esm/index.js.map +1 -1
  26. package/dist/esm/url/toDreepUrl/index.d.ts +38 -0
  27. package/dist/esm/url/toDreepUrl/index.d.ts.map +1 -0
  28. package/dist/esm/url/toDreepUrl/index.js +38 -0
  29. package/dist/esm/url/toDreepUrl/index.js.map +1 -0
  30. package/dist/esm/url/toDreepUrl/matchFrom/index.d.ts +16 -0
  31. package/dist/esm/url/toDreepUrl/matchFrom/index.d.ts.map +1 -0
  32. package/dist/esm/url/toDreepUrl/matchFrom/index.js +32 -0
  33. package/dist/esm/url/toDreepUrl/matchFrom/index.js.map +1 -0
  34. package/package.json +1 -1
package/README.md CHANGED
@@ -233,6 +233,37 @@ dreep.signedUrl(asset, { expiresIn: 900, transform: { width: 800 } });
233
233
  The link stops working at `exp`. Anyone holding it can fetch the asset until then — no
234
234
  API key needed — so treat a signed URL as a bearer token and keep expiries short.
235
235
 
236
+ ### `toDreepUrl(url, { from, to, presets?, transform? })`
237
+
238
+ Moving from R2 or Cloudflare Images with your bucket connected? Swap your image URLs over.
239
+ The file's path and transform options stay the same, and `/cdn-cgi/image/` becomes `/_img/`:
240
+
241
+ ```ts
242
+ import { toDreepUrl } from "dreep";
243
+
244
+ toDreepUrl("https://images.example.com/cdn-cgi/image/width=400/products/1.jpg", {
245
+ from: "https://images.example.com",
246
+ to: "https://cdn.dreep.cloud/your-project",
247
+ });
248
+ // https://cdn.dreep.cloud/your-project/_img/width=400/products/1.jpg
249
+ ```
250
+
251
+ If your own image worker puts a size preset in the path, mark it with `:preset`. Presets
252
+ listed in `presets` get those settings; any other becomes `?p=<name>`, for a Dreep preset
253
+ with the same name:
254
+
255
+ ```ts
256
+ toDreepUrl("https://r2.example.com/i/lightbox/events/1.jpg", {
257
+ from: "https://r2.example.com/i/:preset",
258
+ to: "https://images.example.com",
259
+ presets: { lightbox: { width: 1600, format: "webp" } },
260
+ });
261
+ // https://images.example.com/events/1.jpg?format=webp&width=1600
262
+ ```
263
+
264
+ `transform` adds options to every converted URL; a preset's settings win where both set one.
265
+ URLs that don't match `from` come back unchanged. No API key or client needed.
266
+
236
267
  ### Transform parameters
237
268
 
238
269
  Accepted by `url()`, `signedUrl()`, `upload()` and `confirmUpload()`:
@@ -95,4 +95,7 @@ export declare const DPR_BREAKPOINTS: readonly [1, 2, 3];
95
95
  * our payload byte-identical to the server's.
96
96
  */
97
97
  export declare const CANONICAL_PARAM_ORDER: readonly ["format", "width", "height", "fit", "quality", "gravity", "dpr", "rotate", "blur", "bg", "radius"];
98
+ export declare const CLOUDFLARE_IMAGE_SEGMENT = "/cdn-cgi/image/";
99
+ export declare const DREEP_IMAGE_SEGMENT = "/_img/";
100
+ export declare const PRESET_PLACEHOLDER = ":preset";
98
101
  //# sourceMappingURL=transform.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../../src/constants/transform.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY;aACrB,IAAI,EAAE,MAAM;aACZ,GAAG,EAAE,KAAK;aACV,IAAI,EAAE,MAAM;aACZ,IAAI,EAAE,MAAM;aACZ,GAAG,EAAE,KAAK;aACV,IAAI,EAAE,MAAM;aACZ,IAAI,EAAE,MAAM;aACZ,IAAI,EAAE,MAAM;CACN,CAAC;AAEX,eAAO,MAAM,YAAY;aACrB,GAAG,EAAE,KAAK;aACV,IAAI,EAAE,MAAM;aACZ,GAAG,EAAE,KAAK;aACV,GAAG,EAAE,KAAK;aACV,IAAI,EAAE,MAAM;aACZ,GAAG,EAAE,KAAK;CACJ,CAAC;AAEX,eAAO,MAAM,YAAY;aACrB,GAAG,EAAE,KAAK;aACV,GAAG,EAAE,KAAK;aACV,GAAG,EAAE,KAAK;CACJ,CAAC;AAEX;;;;GAIG;AACH,eAAO,MAAM,eAAe;aACxB,GAAG,EAAE,KAAK;aACV,IAAI,EAAE,MAAM;aACZ,GAAG,EAAE,KAAK;aACV,GAAG,EAAE,KAAK;aACV,IAAI,EAAE,MAAM;aACZ,GAAG,EAAE,KAAK;aACV,GAAG,EAAE,KAAK;aACV,IAAI,EAAE,MAAM;aACZ,GAAG,EAAE,KAAK;CACJ,CAAC;AAEX,qFAAqF;AACrF,eAAO,MAAM,WAAW;aACpB,GAAG,EAAE,KAAK;aACV,IAAI,EAAE,MAAM;CACN,CAAC;AAEX,eAAO,MAAM,GAAG;aACZ,KAAK,EAAE,OAAO;aACd,OAAO,EAAE,SAAS;aAClB,IAAI,EAAE,MAAM;aACZ,MAAM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C1D,eAAO,MAAM,mBAAmB,WAAW,CAAC;AAI5C,eAAO,MAAM,kBAAkB,YAAY,CAAC"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CANONICAL_PARAM_ORDER = exports.DPR_BREAKPOINTS = exports.QUALITY_BREAKPOINTS = exports.WIDTH_BREAKPOINTS = exports.MAX_DPR = exports.MAX_DIMENSION = exports.RADIUS_MAX = exports.VIDEO_CODEC = exports.ROTATE = exports.GRAVITY = exports.FIT = exports.TEXT_FORMAT = exports.DOCUMENT_FORMAT = exports.AUDIO_FORMAT = exports.VIDEO_FORMAT = exports.IMAGE_FORMAT = void 0;
3
+ exports.PRESET_PLACEHOLDER = exports.DREEP_IMAGE_SEGMENT = exports.CLOUDFLARE_IMAGE_SEGMENT = exports.CANONICAL_PARAM_ORDER = exports.DPR_BREAKPOINTS = exports.QUALITY_BREAKPOINTS = exports.WIDTH_BREAKPOINTS = exports.MAX_DPR = exports.MAX_DIMENSION = exports.RADIUS_MAX = exports.VIDEO_CODEC = exports.ROTATE = exports.GRAVITY = exports.FIT = exports.TEXT_FORMAT = exports.DOCUMENT_FORMAT = exports.AUDIO_FORMAT = exports.VIDEO_FORMAT = exports.IMAGE_FORMAT = void 0;
4
4
  exports.IMAGE_FORMAT = {
5
5
  JPEG: "jpeg",
6
6
  PNG: "png",
@@ -113,4 +113,12 @@ exports.CANONICAL_PARAM_ORDER = [
113
113
  "bg",
114
114
  "radius",
115
115
  ];
116
+ // Cloudflare Images puts transform options under /cdn-cgi/image/, which
117
+ // Cloudflare reserves on every domain it serves. Dreep reads the same
118
+ // options under /_img/, which works on Dreep's domain and on your own.
119
+ exports.CLOUDFLARE_IMAGE_SEGMENT = "/cdn-cgi/image/";
120
+ exports.DREEP_IMAGE_SEGMENT = "/_img/";
121
+ // Marks the path segment of `toDreepUrl`'s `from` that holds a preset name,
122
+ // as in `https://images.example.com/i/:preset`.
123
+ exports.PRESET_PLACEHOLDER = ":preset";
116
124
  //# sourceMappingURL=transform.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"transform.js","sourceRoot":"","sources":["../../../src/constants/transform.ts"],"names":[],"mappings":";;;AAAa,QAAA,YAAY,GAAG;IACxB,IAAI,EAAE,MAAM;IACZ,GAAG,EAAE,KAAK;IACV,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,MAAM;IACZ,GAAG,EAAE,KAAK;IACV,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,MAAM;CACN,CAAC;AAEE,QAAA,YAAY,GAAG;IACxB,GAAG,EAAE,KAAK;IACV,IAAI,EAAE,MAAM;IACZ,GAAG,EAAE,KAAK;IACV,GAAG,EAAE,KAAK;IACV,IAAI,EAAE,MAAM;IACZ,GAAG,EAAE,KAAK;CACJ,CAAC;AAEE,QAAA,YAAY,GAAG;IACxB,GAAG,EAAE,KAAK;IACV,GAAG,EAAE,KAAK;IACV,GAAG,EAAE,KAAK;CACJ,CAAC;AAEX;;;;GAIG;AACU,QAAA,eAAe,GAAG;IAC3B,GAAG,EAAE,KAAK;IACV,IAAI,EAAE,MAAM;IACZ,GAAG,EAAE,KAAK;IACV,GAAG,EAAE,KAAK;IACV,IAAI,EAAE,MAAM;IACZ,GAAG,EAAE,KAAK;IACV,GAAG,EAAE,KAAK;IACV,IAAI,EAAE,MAAM;IACZ,GAAG,EAAE,KAAK;CACJ,CAAC;AAEX,qFAAqF;AACxE,QAAA,WAAW,GAAG;IACvB,GAAG,EAAE,KAAK;IACV,IAAI,EAAE,MAAM;CACN,CAAC;AAEE,QAAA,GAAG,GAAG;IACf,KAAK,EAAE,OAAO;IACd,OAAO,EAAE,SAAS;IAClB,IAAI,EAAE,MAAM;IACZ,MAAM,EAAE,QAAQ;IAChB,OAAO,EAAE,SAAS;CACZ,CAAC;AAEE,QAAA,OAAO,GAAG;IACnB,MAAM,EAAE,QAAQ;IAChB,KAAK,EAAE,OAAO;IACd,SAAS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AG,SAAS,CAAC"}
@@ -1,4 +1,5 @@
1
1
  export { default as Dreep } from "./Dreep";
2
+ export { default as toDreepUrl } from "./url/toDreepUrl";
2
3
  export { default as DreepError } from "./errors/DreepError";
3
4
  export { default as DreepAuthError } from "./errors/DreepAuthError";
4
5
  export { default as DreepConflictError } from "./errors/DreepConflictError";
@@ -7,6 +8,7 @@ export { default as DreepLimitError } from "./errors/DreepLimitError";
7
8
  export { default as DreepNotFoundError } from "./errors/DreepNotFoundError";
8
9
  export { default as DreepValidationError } from "./errors/DreepValidationError";
9
10
  export type { SignedUrlOptions } from "./Dreep";
11
+ export type { ToDreepUrlOptions } from "./url/toDreepUrl";
10
12
  export type { ValidationIssue } from "./errors/DreepError";
11
13
  export type { ExtractedText } from "./resources/extractText";
12
14
  export type { AccessControlType, AssetStatus } from "./constants/storage";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,SAAS,CAAC;AAE3C,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAC5E,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAChF,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAC5E,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAEhF,YAAY,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAChD,YAAY,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,YAAY,EAAE,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C;AAC1D,YAAY,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,YAAY,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,YAAY,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAC1E,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAClE,YAAY,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,YAAY,EACV,KAAK,EACL,sBAAsB,EACtB,iBAAiB,EACjB,aAAa,EACb,cAAc,EACd,WAAW,EACX,MAAM,EACN,aAAa,EACb,aAAa,EACb,YAAY,EACZ,MAAM,EACN,eAAe,EACf,eAAe,EACf,KAAK,EACL,YAAY,EACZ,UAAU,EACV,GAAG,EACH,OAAO,EACP,MAAM,EACN,MAAM,EACN,UAAU,GACX,MAAM,SAAS,CAAC"}
package/dist/cjs/index.js CHANGED
@@ -3,9 +3,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.DreepValidationError = exports.DreepNotFoundError = exports.DreepLimitError = exports.DreepConnectionError = exports.DreepConflictError = exports.DreepAuthError = exports.DreepError = exports.Dreep = void 0;
6
+ exports.DreepValidationError = exports.DreepNotFoundError = exports.DreepLimitError = exports.DreepConnectionError = exports.DreepConflictError = exports.DreepAuthError = exports.DreepError = exports.toDreepUrl = exports.Dreep = void 0;
7
7
  var Dreep_1 = require("./Dreep");
8
8
  Object.defineProperty(exports, "Dreep", { enumerable: true, get: function () { return __importDefault(Dreep_1).default; } });
9
+ var toDreepUrl_1 = require("./url/toDreepUrl");
10
+ Object.defineProperty(exports, "toDreepUrl", { enumerable: true, get: function () { return __importDefault(toDreepUrl_1).default; } });
9
11
  var DreepError_1 = require("./errors/DreepError");
10
12
  Object.defineProperty(exports, "DreepError", { enumerable: true, get: function () { return __importDefault(DreepError_1).default; } });
11
13
  var DreepAuthError_1 = require("./errors/DreepAuthError");
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,iCAA2C;AAAlC,+GAAA,OAAO,OAAS;AAEzB,kDAA4D;AAAnD,yHAAA,OAAO,OAAc;AAC9B,0DAAoE;AAA3D,iIAAA,OAAO,OAAkB;AAClC,kEAA4E;AAAnE,yIAAA,OAAO,OAAsB;AACtC,sEAAgF;AAAvE,6IAAA,OAAO,OAAwB;AACxC,4DAAsE;AAA7D,mIAAA,OAAO,OAAmB;AACnC,kEAA4E;AAAnE,yIAAA,OAAO,OAAsB;AACtC,sEAAgF;AAAvE,6IAAA,OAAO,OAAwB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,iCAA2C;AAAlC,+GAAA,OAAO,OAAS;AACzB,+CAAyD;AAAhD,yHAAA,OAAO,OAAc;AAE9B,kDAA4D;AAAnD,yHAAA,OAAO,OAAc;AAC9B,0DAAoE;AAA3D,iIAAA,OAAO,OAAkB;AAClC,kEAA4E;AAAnE,yIAAA,OAAO,OAAsB;AACtC,sEAAgF;AAAvE,6IAAA,OAAO,OAAwB;AACxC,4DAAsE;AAA7D,mIAAA,OAAO,OAAmB;AACnC,kEAA4E;AAAnE,yIAAA,OAAO,OAAsB;AACtC,sEAAgF;AAAvE,6IAAA,OAAO,OAAwB"}
@@ -0,0 +1,38 @@
1
+ import type { TransformParams } from "../../types/transform";
2
+ interface ToDreepUrlOptions {
3
+ /**
4
+ * Where the image is served today, e.g. `https://images.example.com`.
5
+ * Mark a preset in the path with `:preset`: `https://images.example.com/i/:preset`.
6
+ */
7
+ from: string;
8
+ /** Where Dreep serves it, e.g. `https://cdn.dreep.cloud/your-project`. */
9
+ to: string;
10
+ /**
11
+ * Settings for presets found in the path. A preset not listed here becomes
12
+ * `?p=<name>`, so it needs a Dreep preset with the same name.
13
+ */
14
+ presets?: Record<string, TransformParams>;
15
+ /** Options for every converted URL. A preset's settings win where both set one. */
16
+ transform?: TransformParams;
17
+ }
18
+ /**
19
+ * Moves an image URL from R2, Cloudflare Images or your own image worker to
20
+ * Dreep. It swaps the base, turns `/cdn-cgi/image/` into `/_img/`, and turns
21
+ * a preset in the path into Dreep options. The file's path stays the same.
22
+ * A URL that doesn't match `from` comes back unchanged, so it's safe to run
23
+ * over every URL you store.
24
+ *
25
+ * Pure string work, no API key, so it fits a one-off migration script.
26
+ *
27
+ * @example
28
+ * toDreepUrl("https://r2.example.com/i/lightbox/events/1.jpg", {
29
+ * from: "https://r2.example.com/i/:preset",
30
+ * to: "https://images.example.com",
31
+ * presets: { lightbox: { width: 1600, format: "webp" } },
32
+ * })
33
+ * // https://images.example.com/events/1.jpg?format=webp&width=1600
34
+ */
35
+ declare const toDreepUrl: (url: string, { from, to, presets, transform }: ToDreepUrlOptions) => string;
36
+ export type { ToDreepUrlOptions };
37
+ export default toDreepUrl;
38
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/url/toDreepUrl/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGzD,UAAU,iBAAiB;IACzB;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;IACb,0EAA0E;IAC1E,EAAE,EAAE,MAAM,CAAC;IACX;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IAC1C,mFAAmF;IACnF,SAAS,CAAC,EAAE,eAAe,CAAC;CAC7B;AAID;;;;;;;;;;;;;;;;GAgBG;AACH,QAAA,MAAM,UAAU,QAAS,MAAM,oCAAoC,iBAAiB,KAAG,MAiBtF,CAAC;AAEF,YAAY,EAAE,iBAAiB,EAAE,CAAC;eACnB,UAAU"}
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const transform_1 = require("../../constants/transform");
7
+ const buildAssetUrl_1 = __importDefault(require("../../url/buildAssetUrl"));
8
+ const matchFrom_1 = __importDefault(require("../../url/toDreepUrl/matchFrom"));
9
+ const withoutTrailingSlash = (base) => base.replace(/\/+$/, "");
10
+ /**
11
+ * Moves an image URL from R2, Cloudflare Images or your own image worker to
12
+ * Dreep. It swaps the base, turns `/cdn-cgi/image/` into `/_img/`, and turns
13
+ * a preset in the path into Dreep options. The file's path stays the same.
14
+ * A URL that doesn't match `from` comes back unchanged, so it's safe to run
15
+ * over every URL you store.
16
+ *
17
+ * Pure string work, no API key, so it fits a one-off migration script.
18
+ *
19
+ * @example
20
+ * toDreepUrl("https://r2.example.com/i/lightbox/events/1.jpg", {
21
+ * from: "https://r2.example.com/i/:preset",
22
+ * to: "https://images.example.com",
23
+ * presets: { lightbox: { width: 1600, format: "webp" } },
24
+ * })
25
+ * // https://images.example.com/events/1.jpg?format=webp&width=1600
26
+ */
27
+ const toDreepUrl = (url, { from, to, presets, transform }) => {
28
+ const match = (0, matchFrom_1.default)(url, from);
29
+ if (!match) {
30
+ return url;
31
+ }
32
+ const path = match.rest.startsWith(transform_1.CLOUDFLARE_IMAGE_SEGMENT)
33
+ ? `${transform_1.DREEP_IMAGE_SEGMENT}${match.rest.slice(transform_1.CLOUDFLARE_IMAGE_SEGMENT.length)}`
34
+ : match.rest;
35
+ const converted = `${withoutTrailingSlash(to)}${path}`;
36
+ const presetTransform = match.preset ? (presets?.[match.preset] ?? { preset: match.preset }) : undefined;
37
+ if (!presetTransform && !transform) {
38
+ return converted;
39
+ }
40
+ return (0, buildAssetUrl_1.default)({ target: converted, transform: { ...transform, ...presetTransform } });
41
+ };
42
+ exports.default = toDreepUrl;
43
+ //# sourceMappingURL=index.js.map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,eAAe,EAAE,EAAE,CAAC,CAAC;AAC/F,CAAC,CAAC;kBAGa,UAAU"}
@@ -0,0 +1,16 @@
1
+ interface FromMatch {
2
+ /** The path segment in the `:preset` position, when `from` has one. */
3
+ preset?: string;
4
+ /** Everything after `from`: the file's path, query and hash. */
5
+ rest: string;
6
+ }
7
+ /**
8
+ * Whether `url` starts with `from`, and what's left after it. `from` may
9
+ * hold one `:preset` segment, e.g. `https://images.example.com/i/:preset`,
10
+ * which matches any single path segment and reports it as the preset.
11
+ * Null when the URL doesn't match.
12
+ */
13
+ declare const matchFrom: (url: string, from: string) => FromMatch | null;
14
+ export type { FromMatch };
15
+ export default matchFrom;
16
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/url/toDreepUrl/matchFrom/index.ts"],"names":[],"mappings":"AAEA,UAAU,SAAS;IACjB,uEAAuE;IACvE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,gEAAgE;IAChE,IAAI,EAAE,MAAM,CAAC;CACd;AAQD;;;;;GAKG;AACH,QAAA,MAAM,SAAS,QAAS,MAAM,QAAQ,MAAM,KAAG,SAAS,GAAG,IAoB1D,CAAC;AAEF,YAAY,EAAE,SAAS,EAAE,CAAC;eACX,SAAS"}
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const transform_1 = require("../../../constants/transform");
4
+ const withoutTrailingSlash = (base) => base.replace(/\/+$/, "");
5
+ // The rest must start a new path segment (or the query/hash), so
6
+ // `images.example.com` never matches `images.example.com.evil.net`.
7
+ const isBoundary = (rest) => rest === "" || /^[/?#]/.test(rest);
8
+ /**
9
+ * Whether `url` starts with `from`, and what's left after it. `from` may
10
+ * hold one `:preset` segment, e.g. `https://images.example.com/i/:preset`,
11
+ * which matches any single path segment and reports it as the preset.
12
+ * Null when the URL doesn't match.
13
+ */
14
+ const matchFrom = (url, from) => {
15
+ const placeholderIndex = from.indexOf(transform_1.PRESET_PLACEHOLDER);
16
+ if (placeholderIndex === -1) {
17
+ const base = withoutTrailingSlash(from);
18
+ const rest = url.slice(base.length);
19
+ return url.startsWith(base) && isBoundary(rest) ? { rest } : null;
20
+ }
21
+ const before = from.slice(0, placeholderIndex);
22
+ const after = withoutTrailingSlash(from.slice(placeholderIndex + transform_1.PRESET_PLACEHOLDER.length));
23
+ if (!url.startsWith(before))
24
+ return null;
25
+ const [preset = ""] = url.slice(before.length).split(/[/?#]/, 1);
26
+ const afterPreset = url.slice(before.length + preset.length);
27
+ if (!preset || !afterPreset.startsWith(after))
28
+ return null;
29
+ // A preset needs a file after it: `/i/lightbox` alone isn't an image.
30
+ const rest = afterPreset.slice(after.length);
31
+ return rest.startsWith("/") && rest.length > 1 ? { preset, rest } : null;
32
+ };
33
+ exports.default = matchFrom;
34
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/url/toDreepUrl/matchFrom/index.ts"],"names":[],"mappings":";;AAAA,qDAA2D;AAS3D,MAAM,oBAAoB,GAAG,CAAC,IAAY,EAAU,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AAEhF,iEAAiE;AACjE,oEAAoE;AACpE,MAAM,UAAU,GAAG,CAAC,IAAY,EAAW,EAAE,CAAC,IAAI,KAAK,EAAE,IAAI,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAEjF;;;;;GAKG;AACH,MAAM,SAAS,GAAG,CAAC,GAAW,EAAE,IAAY,EAAoB,EAAE;IAChE,MAAM,gBAAgB,GAAG,IAAI,CAAC,OAAO,CAAC,8BAAkB,CAAC,CAAC;IAE1D,IAAI,gBAAgB,KAAK,CAAC,CAAC,EAAE,CAAC;QAC5B,MAAM,IAAI,GAAG,oBAAoB,CAAC,IAAI,CAAC,CAAC;QACxC,MAAM,IAAI,GAAG,GAAG,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ORDER: readonly ["format", "width", "height", "fit", "quality", "gravity", "dpr", "rotate", "blur", "bg", "radius"];
98
+ export declare const CLOUDFLARE_IMAGE_SEGMENT = "/cdn-cgi/image/";
99
+ export declare const DREEP_IMAGE_SEGMENT = "/_img/";
100
+ export declare const PRESET_PLACEHOLDER = ":preset";
98
101
  //# sourceMappingURL=transform.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../../src/constants/transform.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY;aACrB,IAAI,EAAE,MAAM;aACZ,GAAG,EAAE,KAAK;aACV,IAAI,EAAE,MAAM;aACZ,IAAI,EAAE,MAAM;aACZ,GAAG,EAAE,KAAK;aACV,IAAI,EAAE,MAAM;aACZ,IAAI,EAAE,MAAM;aACZ,IAAI,EAAE,MAAM;CACN,CAAC;AAEX,eAAO,MAAM,YAAY;aACrB,GAAG,EAAE,KAAK;aACV,IAAI,EAAE,MAAM;aACZ,GAAG,EAAE,KAAK;aACV,GAAG,EAAE,KAAK;aACV,IAAI,EAAE,MAAM;aACZ,GAAG,EAAE,KAAK;CACJ,CAAC;AAEX,eAAO,MAAM,YAAY;aACrB,GAAG,EAAE,KAAK;aACV,GAAG,EAAE,KAAK;aACV,GAAG,EAAE,KAAK;CACJ,CAAC;AAEX;;;;GAIG;AACH,eAAO,MAAM,eAAe;aACxB,GAAG,EAAE,KAAK;aACV,IAAI,EAAE,MAAM;aACZ,GAAG,EAAE,KAAK;aACV,GAAG,EAAE,KAAK;aACV,IAAI,EAAE,MAAM;aACZ,GAAG,EAAE,KAAK;aACV,GAAG,EAAE,KAAK;aACV,IAAI,EAAE,MAAM;aACZ,GAAG,EAAE,KAAK;CACJ,CAAC;AAEX,qFAAqF;AACrF,eAAO,MAAM,WAAW;aACpB,GAAG,EAAE,KAAK;aACV,IAAI,EAAE,MAAM;CACN,CAAC;AAEX,eAAO,MAAM,GAAG;aACZ,KAAK,EAAE,OAAO;aACd,O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F,CAAC;AAKX,eAAO,MAAM,wBAAwB,oBAAoB,CAAC;AAC1D,eAAO,MAAM,mBAAmB,WAAW,CAAC;AAI5C,eAAO,MAAM,kBAAkB,YAAY,CAAC"}
@@ -110,4 +110,12 @@ export const CANONICAL_PARAM_ORDER = [
110
110
  "bg",
111
111
  "radius",
112
112
  ];
113
+ // Cloudflare Images puts transform options under /cdn-cgi/image/, which
114
+ // Cloudflare reserves on every domain it serves. Dreep reads the same
115
+ // options under /_img/, which works on Dreep's domain and on your own.
116
+ export const CLOUDFLARE_IMAGE_SEGMENT = "/cdn-cgi/image/";
117
+ export const DREEP_IMAGE_SEGMENT = "/_img/";
118
+ // Marks the path segment of `toDreepUrl`'s `from` that holds a preset name,
119
+ // as in `https://images.example.com/i/:preset`.
120
+ export const PRESET_PLACEHOLDER = ":preset";
113
121
  //# sourceMappingURL=transform.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"transform.js","sourceRoot":"","sources":["../../../src/constants/transform.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,YAAY,GAAG;IACxB,IAAI,EAAE,MAAM;IACZ,GAAG,EAAE,KAAK;IACV,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,MAAM;IACZ,GAAG,EAAE,KAAK;IACV,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,MAAM;CACN,CAAC;AAEX,MAAM,CAAC,MAAM,YAAY,GAAG;IACxB,GAAG,EAAE,KAAK;IACV,IAAI,EAAE,MAAM;IACZ,GAAG,EAAE,KAAK;IACV,GAAG,EAAE,KAAK;IACV,IAAI,EAAE,MAAM;IACZ,GAAG,EAAE,KAAK;CACJ,CAAC;AAEX,MAAM,CAAC,MAAM,YAAY,GAAG;IACxB,GAAG,EAAE,KAAK;IACV,GAAG,EAAE,KAAK;IACV,GAAG,EAAE,KAAK;CACJ,CAAC;AAEX;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;IAC3B,GAAG,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AC,CAAC;AAEzB;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC7B,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI;IAC1E,IAAI,EAAE,IAAI,EAAE,IAAI;CACV,CAAC;AAEX,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,CAAU,CAAC;AAEtE,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAU,CAAC;AAElD;;;;GAIG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACjC,QAAQ;IACR,OAAO;IACP,QAAQ;IACR,KAAK;IACL,SAAS;IACT,SAAS;IACT,KAAK;IACL,QAAQ;IACR,MAAM;IACN,IAAI;IACJ,QAAQ;CACF,CAAC;AAEX,wEAAwE;AACxE,sEAAsE;AACtE,uEAAuE;AACvE,MAAM,CAAC,MAAM,wBAAwB,GAAG,iBAAiB,CAAC;AAC1D,MAAM,CAAC,MAAM,mBAAmB,GAAG,QAAQ,CAAC;AAE5C,4EAA4E;AAC5E,gDAAgD;AAChD,MAAM,CAAC,MAAM,kBAAkB,GAAG,SAAS,CAAC"}
@@ -1,4 +1,5 @@
1
1
  export { default as Dreep } from "./Dreep/index.js";
2
+ export { default as toDreepUrl } from "./url/toDreepUrl/index.js";
2
3
  export { default as DreepError } from "./errors/DreepError/index.js";
3
4
  export { default as DreepAuthError } from "./errors/DreepAuthError/index.js";
4
5
  export { default as DreepConflictError } from "./errors/DreepConflictError/index.js";
@@ -7,6 +8,7 @@ export { default as DreepLimitError } from "./errors/DreepLimitError/index.js";
7
8
  export { default as DreepNotFoundError } from "./errors/DreepNotFoundError/index.js";
8
9
  export { default as DreepValidationError } from "./errors/DreepValidationError/index.js";
9
10
  export type { SignedUrlOptions } from "./Dreep/index.js";
11
+ export type { ToDreepUrlOptions } from "./url/toDreepUrl/index.js";
10
12
  export type { ValidationIssue } from "./errors/DreepError/index.js";
11
13
  export type { ExtractedText } from "./resources/extractText/index.js";
12
14
  export type { AccessControlType, AssetStatus } from "./constants/storage.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,SAAS,CAAC;AAE3C,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAC5E,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAChF,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAC5E,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAEhF,YAAY,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAChD,YAAY,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,YAAY,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,YAAY,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAC1E,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAClE,YAAY,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,YAAY,EACV,KAAK,EACL,sBAAsB,EACtB,iB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U,EAAE,MAAM,gBAAgB,CAAC;AACjD,YAAY,EACV,KAAK,EACL,sBAAsB,EACtB,iBAAiB,EACjB,aAAa,EACb,cAAc,EACd,WAAW,EACX,MAAM,EACN,aAAa,EACb,aAAa,EACb,YAAY,EACZ,MAAM,EACN,eAAe,EACf,eAAe,EACf,KAAK,EACL,YAAY,EACZ,UAAU,EACV,GAAG,EACH,OAAO,EACP,MAAM,EACN,MAAM,EACN,UAAU,GACX,MAAM,SAAS,CAAC"}
package/dist/esm/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  export { default as Dreep } from "./Dreep/index.js";
2
+ export { default as toDreepUrl } from "./url/toDreepUrl/index.js";
2
3
  export { default as DreepError } from "./errors/DreepError/index.js";
3
4
  export { default as DreepAuthError } from "./errors/DreepAuthError/index.js";
4
5
  export { default as DreepConflictError } from "./errors/DreepConflictError/index.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,SAAS,CAAC;AAE3C,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAC5E,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAChF,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAC5E,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,+BAA+B,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEzD,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAC5E,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAChF,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAC5E,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,+BAA+B,CAAC"}
@@ -0,0 +1,38 @@
1
+ import type { TransformParams } from "../../types/transform.js";
2
+ interface ToDreepUrlOptions {
3
+ /**
4
+ * Where the image is served today, e.g. `https://images.example.com`.
5
+ * Mark a preset in the path with `:preset`: `https://images.example.com/i/:preset`.
6
+ */
7
+ from: string;
8
+ /** Where Dreep serves it, e.g. `https://cdn.dreep.cloud/your-project`. */
9
+ to: string;
10
+ /**
11
+ * Settings for presets found in the path. A preset not listed here becomes
12
+ * `?p=<name>`, so it needs a Dreep preset with the same name.
13
+ */
14
+ presets?: Record<string, TransformParams>;
15
+ /** Options for every converted URL. A preset's settings win where both set one. */
16
+ transform?: TransformParams;
17
+ }
18
+ /**
19
+ * Moves an image URL from R2, Cloudflare Images or your own image worker to
20
+ * Dreep. It swaps the base, turns `/cdn-cgi/image/` into `/_img/`, and turns
21
+ * a preset in the path into Dreep options. The file's path stays the same.
22
+ * A URL that doesn't match `from` comes back unchanged, so it's safe to run
23
+ * over every URL you store.
24
+ *
25
+ * Pure string work, no API key, so it fits a one-off migration script.
26
+ *
27
+ * @example
28
+ * toDreepUrl("https://r2.example.com/i/lightbox/events/1.jpg", {
29
+ * from: "https://r2.example.com/i/:preset",
30
+ * to: "https://images.example.com",
31
+ * presets: { lightbox: { width: 1600, format: "webp" } },
32
+ * })
33
+ * // https://images.example.com/events/1.jpg?format=webp&width=1600
34
+ */
35
+ declare const toDreepUrl: (url: string, { from, to, presets, transform }: ToDreepUrlOptions) => string;
36
+ export type { ToDreepUrlOptions };
37
+ export default toDreepUrl;
38
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/url/toDreepUrl/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGzD,UAAU,iBAAiB;IACzB;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;IACb,0EAA0E;IAC1E,EAAE,EAAE,MAAM,CAAC;IACX;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IAC1C,mFAAmF;IACnF,SAAS,CAAC,EAAE,eAAe,CAAC;CAC7B;AAID;;;;;;;;;;;;;;;;GAgBG;AACH,QAAA,MAAM,UAAU,QAAS,MAAM,oCAAoC,iBAAiB,KAAG,MAiBtF,CAAC;AAEF,YAAY,EAAE,iBAAiB,EAAE,CAAC;eACnB,UAAU"}
@@ -0,0 +1,38 @@
1
+ import { CLOUDFLARE_IMAGE_SEGMENT, DREEP_IMAGE_SEGMENT } from "../../constants/transform.js";
2
+ import buildAssetUrl from "../../url/buildAssetUrl/index.js";
3
+ import matchFrom from "../../url/toDreepUrl/matchFrom/index.js";
4
+ const withoutTrailingSlash = (base) => base.replace(/\/+$/, "");
5
+ /**
6
+ * Moves an image URL from R2, Cloudflare Images or your own image worker to
7
+ * Dreep. It swaps the base, turns `/cdn-cgi/image/` into `/_img/`, and turns
8
+ * a preset in the path into Dreep options. The file's path stays the same.
9
+ * A URL that doesn't match `from` comes back unchanged, so it's safe to run
10
+ * over every URL you store.
11
+ *
12
+ * Pure string work, no API key, so it fits a one-off migration script.
13
+ *
14
+ * @example
15
+ * toDreepUrl("https://r2.example.com/i/lightbox/events/1.jpg", {
16
+ * from: "https://r2.example.com/i/:preset",
17
+ * to: "https://images.example.com",
18
+ * presets: { lightbox: { width: 1600, format: "webp" } },
19
+ * })
20
+ * // https://images.example.com/events/1.jpg?format=webp&width=1600
21
+ */
22
+ const toDreepUrl = (url, { from, to, presets, transform }) => {
23
+ const match = matchFrom(url, from);
24
+ if (!match) {
25
+ return url;
26
+ }
27
+ const path = match.rest.startsWith(CLOUDFLARE_IMAGE_SEGMENT)
28
+ ? `${DREEP_IMAGE_SEGMENT}${match.rest.slice(CLOUDFLARE_IMAGE_SEGMENT.length)}`
29
+ : match.rest;
30
+ const converted = `${withoutTrailingSlash(to)}${path}`;
31
+ const presetTransform = match.preset ? (presets?.[match.preset] ?? { preset: match.preset }) : undefined;
32
+ if (!presetTransform && !transform) {
33
+ return converted;
34
+ }
35
+ return buildAssetUrl({ target: converted, transform: { ...transform, ...presetTransform } });
36
+ };
37
+ export default toDreepUrl;
38
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/url/toDreepUrl/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AACtF,OAAO,aAAa,MAAM,qBAAqB,CAAC;AAEhD,OAAO,SAAS,MAAM,4BAA4B,CAAC;AAmBnD,MAAM,oBAAoB,GAAG,CAAC,IAAY,EAAU,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AAEhF;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,GAAG,CAAC,GAAW,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE,SAAS,EAAqB,EAAU,EAAE;IAC9F,MAAM,KAAK,GAAG,SAAS,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IACnC,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,GAAG,CAAC;IACb,CAAC;IAED,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,wBAAwB,CAAC;QAC1D,CAAC,CAAC,GAAG,mBAAmB,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,wBAAwB,CAAC,MAAM,CAAC,EAAE;QAC9E,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC;IACf,MAAM,SAAS,GAAG,GAAG,oBAAoB,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC;IAEvD,MAAM,eAAe,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACzG,IAAI,CAAC,eAAe,IAAI,CAAC,SAAS,EAAE,CAAC;QACnC,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,OAAO,aAAa,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,EAAE,GAAG,SAAS,EAAE,GAAG,eAAe,EAAE,EAAE,CAAC,CAAC;AAC/F,CAAC,CAAC;AAGF,eAAe,UAAU,CAAC"}
@@ -0,0 +1,16 @@
1
+ interface FromMatch {
2
+ /** The path segment in the `:preset` position, when `from` has one. */
3
+ preset?: string;
4
+ /** Everything after `from`: the file's path, query and hash. */
5
+ rest: string;
6
+ }
7
+ /**
8
+ * Whether `url` starts with `from`, and what's left after it. `from` may
9
+ * hold one `:preset` segment, e.g. `https://images.example.com/i/:preset`,
10
+ * which matches any single path segment and reports it as the preset.
11
+ * Null when the URL doesn't match.
12
+ */
13
+ declare const matchFrom: (url: string, from: string) => FromMatch | null;
14
+ export type { FromMatch };
15
+ export default matchFrom;
16
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/url/toDreepUrl/matchFrom/index.ts"],"names":[],"mappings":"AAEA,UAAU,SAAS;IACjB,uEAAuE;IACvE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,gEAAgE;IAChE,IAAI,EAAE,MAAM,CAAC;CACd;AAQD;;;;;GAKG;AACH,QAAA,MAAM,SAAS,QAAS,MAAM,QAAQ,MAAM,KAAG,SAAS,GAAG,IAoB1D,CAAC;AAEF,YAAY,EAAE,SAAS,EAAE,CAAC;eACX,SAAS"}
@@ -0,0 +1,32 @@
1
+ import { PRESET_PLACEHOLDER } from "../../../constants/transform.js";
2
+ const withoutTrailingSlash = (base) => base.replace(/\/+$/, "");
3
+ // The rest must start a new path segment (or the query/hash), so
4
+ // `images.example.com` never matches `images.example.com.evil.net`.
5
+ const isBoundary = (rest) => rest === "" || /^[/?#]/.test(rest);
6
+ /**
7
+ * Whether `url` starts with `from`, and what's left after it. `from` may
8
+ * hold one `:preset` segment, e.g. `https://images.example.com/i/:preset`,
9
+ * which matches any single path segment and reports it as the preset.
10
+ * Null when the URL doesn't match.
11
+ */
12
+ const matchFrom = (url, from) => {
13
+ const placeholderIndex = from.indexOf(PRESET_PLACEHOLDER);
14
+ if (placeholderIndex === -1) {
15
+ const base = withoutTrailingSlash(from);
16
+ const rest = url.slice(base.length);
17
+ return url.startsWith(base) && isBoundary(rest) ? { rest } : null;
18
+ }
19
+ const before = from.slice(0, placeholderIndex);
20
+ const after = withoutTrailingSlash(from.slice(placeholderIndex + PRESET_PLACEHOLDER.length));
21
+ if (!url.startsWith(before))
22
+ return null;
23
+ const [preset = ""] = url.slice(before.length).split(/[/?#]/, 1);
24
+ const afterPreset = url.slice(before.length + preset.length);
25
+ if (!preset || !afterPreset.startsWith(after))
26
+ return null;
27
+ // A preset needs a file after it: `/i/lightbox` alone isn't an image.
28
+ const rest = afterPreset.slice(after.length);
29
+ return rest.startsWith("/") && rest.length > 1 ? { preset, rest } : null;
30
+ };
31
+ export default matchFrom;
32
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/url/toDreepUrl/matchFrom/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAS3D,MAAM,oBAAoB,GAAG,CAAC,IAAY,EAAU,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AAEhF,iEAAiE;AACjE,oEAAoE;AACpE,MAAM,UAAU,GAAG,CAAC,IAAY,EAAW,EAAE,CAAC,IAAI,KAAK,EAAE,IAAI,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAEjF;;;;;GAKG;AACH,MAAM,SAAS,GAAG,CAAC,GAAW,EAAE,IAAY,EAAoB,EAAE;IAChE,MAAM,gBAAgB,GAAG,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC;IAE1D,IAAI,gBAAgB,KAAK,CAAC,CAAC,EAAE,CAAC;QAC5B,MAAM,IAAI,GAAG,oBAAoB,CAAC,IAAI,CAAC,CAAC;QACxC,MAAM,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACpC,OAAO,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IACpE,CAAC;IAED,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,gBAAgB,CAAC,CAAC;IAC/C,MAAM,KAAK,GAAG,oBAAoB,CAAC,IAAI,CAAC,KAAK,CAAC,gBAAgB,GAAG,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAAC;IAC7F,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC;QAAE,OAAO,IAAI,CAAC;IAEzC,MAAM,CAAC,MAAM,GAAG,EAAE,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;IACjE,MAAM,WAAW,GAAG,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;IAC7D,IAAI,CAAC,MAAM,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IAE3D,sEAAsE;IACtE,MAAM,IAAI,GAAG,WAAW,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAC7C,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AAC3E,CAAC,CAAC;AAGF,eAAe,SAAS,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dreep",
3
- "version": "0.2.0",
3
+ "version": "0.4.0",
4
4
  "description": "The official Node.js SDK for Dreep — media storage, image and video transformation, document conversion, OCR, and background removal.",
5
5
  "type": "module",
6
6
  "main": "./dist/cjs/index.js",