@numueg/theme-sdk 0.2.1 → 0.2.2

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/index.cjs CHANGED
@@ -3334,6 +3334,23 @@ function assetUrl(name) {
3334
3334
  return `${cleanBase}${filename}`;
3335
3335
  }
3336
3336
 
3337
+ // src/utils/imageTransform.ts
3338
+ var clamp01 = (n) => Math.min(1, Math.max(0, n));
3339
+ function focalSrc(url, options = {}) {
3340
+ if (!url) return "";
3341
+ if (url.startsWith("data:") || /[?&](fp-x|fp-y)=/.test(url)) return url;
3342
+ const p = new URLSearchParams();
3343
+ p.set("url", url);
3344
+ if (options.width) p.set("w", String(Math.round(options.width)));
3345
+ if (options.focal?.x != null) p.set("fp-x", String(clamp01(options.focal.x)));
3346
+ if (options.focal?.y != null) p.set("fp-y", String(clamp01(options.focal.y)));
3347
+ if (options.aspect) p.set("ar", options.aspect);
3348
+ if (options.fit) p.set("fit", options.fit);
3349
+ if (options.quality) p.set("q", String(Math.min(100, Math.max(1, Math.round(options.quality)))));
3350
+ if (options.format) p.set("f", options.format.toLowerCase());
3351
+ return `/api/image-transform?${p.toString()}`;
3352
+ }
3353
+
3337
3354
  // src/utils/locales.ts
3338
3355
  function flattenMessages(source, prefix = "") {
3339
3356
  const out = {};
@@ -3422,6 +3439,7 @@ exports.defineSection = defineSection;
3422
3439
  exports.dynamicSource = dynamicSource;
3423
3440
  exports.findVariantByOptions = findVariantByOptions;
3424
3441
  exports.flattenMessages = flattenMessages;
3442
+ exports.focalSrc = focalSrc;
3425
3443
  exports.getReactSingleton = getReactSingleton;
3426
3444
  exports.getSdkSingleton = getSdkSingleton;
3427
3445
  exports.isDefinedBlock = isDefinedBlock;