@onreza/adapter-astro 0.5.0 → 0.5.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/image/index.js +1 -1
- package/dist/image/service.d.ts +2 -2
- package/package.json +1 -1
package/dist/image/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../chunk-934ybxvc.js";
|
|
1
|
+
import"../chunk-934ybxvc.js";function J(z){return(typeof z==="object"||typeof z==="function")&&z!==null&&"src"in z}function K(z){if(typeof z==="string")return z;if(J(z))return z.src;throw Error(`[onreza:image] Invalid image src: expected a string or ImageMetadata, got ${typeof z}. Make sure you're passing an imported image or a URL string to <Image>.`)}function G(z,k){if(z<1||z>8192)return console.warn(`[onreza:image] ${k} ${z} is out of range (1-8192). Clamping.`),Math.max(1,Math.min(8192,z));return z}var L={getHTMLAttributes(z,k){let{src:x,width:O,height:f,format:j,quality:E,...Z}=z,N=O,A=f;if((typeof x==="object"||typeof x==="function")&&x!==null&&"width"in x&&"height"in x){let B=x;if(B.width>0&&B.height>0){let F=B.width/B.height;if(A&&!N)N=Math.round(A*F);else if(N&&!A)A=Math.round(N/F)}}return{...Z,decoding:Z.decoding??"async",loading:Z.loading??"lazy",...N&&{width:N},...A&&{height:A}}},getSrcSet(z,k){if(z.width===void 0)return[];let x=z.width,O=Math.min(x*2,8192),f=[{descriptor:"1x",transform:{...z}}];if(O>x)f.push({descriptor:"2x",transform:{...z,width:O}});return f},getURL(z,k){let O=k.service.config?.quality??75,f=K(z.src);if(f.startsWith("http://")||f.startsWith("https://")||f.startsWith("//"))console.warn(`[onreza:image] External URL detected: "${f}". Platform will validate against allowed domains at runtime.`);let j=new URLSearchParams;if(j.set("url",f),z.width!==void 0)j.set("w",z.width.toString());if(z.height!==void 0)j.set("h",z.height.toString());let E=z.quality??O;if(j.set("q",E.toString()),z.format!==void 0)j.set("f",z.format);if(z.fit!==void 0)j.set("fit",z.fit);else if(z.position!==void 0){let N={bottom:"cover",center:"cover",entropy:"cover",left:"cover",right:"cover",top:"cover"}[z.position];if(N)j.set("fit",N)}if(z.blur!==void 0&&typeof z.blur==="number"){let Z=Math.max(0,Math.min(250,z.blur));j.set("blur",Z.toString())}if(z.dpr!==void 0&&typeof z.dpr==="number"){let Z=Math.max(1,Math.min(5,z.dpr));j.set("dpr",Z.toString())}return`/_onreza/image?${j.toString()}`},validateOptions(z,k){let O=k.service.config?.quality??75,f={...z};if(f.width!==void 0)f.width=G(f.width,"Width");if(f.height!==void 0)f.height=G(f.height,"Height");if(f.quality!==void 0&&typeof f.quality==="number"){if(f.quality<1||f.quality>100)console.warn(`[onreza:image] Quality ${f.quality} is out of range (1-100). Using default: ${O}`),f.quality=O}if(f.format!==void 0){if(!["webp","avif","jpg","jpeg","png","gif"].includes(f.format))console.warn(`[onreza:image] Format "${f.format}" may not be supported by platform.`)}if(f.blur!==void 0&&typeof f.blur==="number"){if(f.blur<0||f.blur>250)console.warn(`[onreza:image] Blur ${f.blur} is out of range (0-250). Clamping.`),f.blur=Math.max(0,Math.min(250,f.blur))}if(f.dpr!==void 0&&typeof f.dpr==="number"){if(f.dpr<1||f.dpr>5)console.warn(`[onreza:image] DPR ${f.dpr} is out of range (1-5). Clamping.`),f.dpr=Math.max(1,Math.min(5,f.dpr))}return f}},S=L;export{S as default};
|
package/dist/image/service.d.ts
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
* service: {
|
|
18
18
|
* entrypoint: '@onreza/adapter-astro/image',
|
|
19
19
|
* config: {
|
|
20
|
-
* // Optional:
|
|
20
|
+
* // Optional: sizes for srcset generation
|
|
21
21
|
* sizes: [640, 750, 828, 1080, 1200, 1920, 2048, 3840],
|
|
22
22
|
* // Optional: default quality
|
|
23
23
|
* quality: 75,
|
|
@@ -32,7 +32,7 @@ import type { ExternalImageService } from "astro";
|
|
|
32
32
|
* Configuration options for ONREZA image service
|
|
33
33
|
*/
|
|
34
34
|
export interface OnrezaImageServiceConfig {
|
|
35
|
-
/**
|
|
35
|
+
/** Image widths for srcset generation (does not restrict allowed widths) */
|
|
36
36
|
sizes?: number[];
|
|
37
37
|
/** Default quality (1-100, default: 75) */
|
|
38
38
|
quality?: number;
|