@necto/image 1.0.12 → 1.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/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +8 -3
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var t,e=Object.defineProperty,i=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,n={};((t,i)=>{for(var r in i)e(t,r,{get:i[r],enumerable:!0})})(n,{getImageSizes:()=>d,getImageStyle:()=>u,inferDimensions:()=>h,parseDimension:()=>s,transformProps:()=>g}),module.exports=(t=n,((t,n,a,c)=>{if(n&&"object"==typeof n||"function"==typeof n)for(let u of r(n))o.call(t,u)||u===a||e(t,u,{get:()=>n[u],enumerable:!(c=i(n,u))||c.enumerable});return t})(e({},"__esModule",{value:!0}),t));var a=require("@necto/dom"),c=require("@necto/url");function u({width:t,height:e,aspectRatio:i,layout:r,objectFit:o,background:n}){const u={};return o&&(u["object-fit"]=o),(0,c.isUrl)(n)?(u["background-image"]=`url(${n})`,u["background-size"]="cover",u["background-repeat"]="no-repeat"):n&&(u.background=n),"fixed"===r?(void 0!==t&&(u.width=(0,a.toPx)(t)),void 0!==e&&(u.height=(0,a.toPx)(e))):"constrained"===r?(u.width="100%",void 0!==t&&(u["max-width"]=(0,a.toPx)(t)),void 0!==e&&(u["max-height"]=(0,a.toPx)(e)),i&&(u["aspect-ratio"]=String(i))):"fullWidth"===r&&(u.width="100%",void 0!==e&&(u.height=(0,a.toPx)(e)),i&&(u["aspect-ratio"]=String(i))),Object.keys(u).length>0?u:void 0}function d(t,e){if(t&&e)switch(e){case"constrained":return`(min-width: ${t}px) ${t}px, 100vw`;case"fixed":return`${t}px`;case"fullWidth":return"100vw";default:return}}function s(t){if(void 0===t)return;if("number"==typeof t)return t;const e=Number.parseInt(t,10);return Number.isNaN(e)?void 0:e}function h(t){let e=s(t.width),i=s(t.height);return t.aspectRatio&&(e&&!i?i=Math.round(e/t.aspectRatio):i&&!e&&(e=Math.round(i*t.aspectRatio))),{width:e,height:i}}function g(t){const{src:e,width:i,height:r,aspectRatio:o,layout:n,priority:a=!1,background:c,objectFit:d,unstyled:s=!1}=t,h={src:e,loading:a?"eager":"lazy",decoding:a?"sync":"async",fetchpriority:a?"high":void 0};if(!s){const t=u({width:i,height:r,aspectRatio:o,layout:n,objectFit:d,background:c});t&&(h.style=t)}return"fixed"===n&&(h.width=i,h.height=r),h}
|
|
1
|
+
"use strict";var t,e=Object.defineProperty,i=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,n={};((t,i)=>{for(var r in i)e(t,r,{get:i[r],enumerable:!0})})(n,{getImageSizes:()=>d,getImageStyle:()=>u,inferDimensions:()=>h,parseDimension:()=>s,transformProps:()=>g}),module.exports=(t=n,((t,n,a,c)=>{if(n&&"object"==typeof n||"function"==typeof n)for(let u of r(n))o.call(t,u)||u===a||e(t,u,{get:()=>n[u],enumerable:!(c=i(n,u))||c.enumerable});return t})(e({},"__esModule",{value:!0}),t));var a=require("@necto/dom"),c=require("@necto/url");function u({width:t,height:e,aspectRatio:i,layout:r,objectFit:o,background:n}){const u={};return o&&(u["object-fit"]=o),(0,c.isUrl)(n)?(u["background-image"]=`url(${n})`,u["background-size"]="cover",u["background-repeat"]="no-repeat"):n&&(u.background=n),"fixed"===r?(void 0!==t&&(u.width=(0,a.toPx)(t)??""),void 0!==e&&(u.height=(0,a.toPx)(e)??"")):"constrained"===r?(u.width="100%",void 0!==t&&(u["max-width"]=(0,a.toPx)(t)??""),void 0!==e&&(u["max-height"]=(0,a.toPx)(e)??""),i&&(u["aspect-ratio"]=String(i))):"fullWidth"===r&&(u.width="100%",void 0!==e&&(u.height=(0,a.toPx)(e)??""),i&&(u["aspect-ratio"]=String(i))),Object.keys(u).length>0?u:void 0}function d(t,e){if(t&&e)switch(e){case"constrained":return`(min-width: ${t}px) ${t}px, 100vw`;case"fixed":return`${t}px`;case"fullWidth":return"100vw";default:return}}function s(t){if(void 0===t)return;if("number"==typeof t)return t;const e=Number.parseInt(t,10);return Number.isNaN(e)?void 0:e}function h(t){let e=s(t.width),i=s(t.height);return t.aspectRatio&&(e&&!i?i=Math.round(e/t.aspectRatio):i&&!e&&(e=Math.round(i*t.aspectRatio))),{width:e,height:i}}function g(t){const{src:e,width:i,height:r,aspectRatio:o,layout:n,priority:a=!1,background:c,objectFit:d,unstyled:s=!1}=t,h={src:e,loading:a?"eager":"lazy",decoding:a?"sync":"async",fetchpriority:a?"high":void 0};if(!s){const t=u({width:i,height:r,aspectRatio:o,layout:n,objectFit:d,background:c});t&&(h.style=t)}return"fixed"===n&&(h.width=i,h.height=r),h}
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{toPx as t}from"@necto/dom";import{isUrl as i}from"@necto/url";function e({width:e,height:o,aspectRatio:r,layout:n,objectFit:a,background:c}){const d={};return a&&(d["object-fit"]=a),i(c)?(d["background-image"]=`url(${c})`,d["background-size"]="cover",d["background-repeat"]="no-repeat"):c&&(d.background=c),"fixed"===n?(void 0!==e&&(d.width=t(e)),void 0!==o&&(d.height=t(o))):"constrained"===n?(d.width="100%",void 0!==e&&(d["max-width"]=t(e)),void 0!==o&&(d["max-height"]=t(o)),r&&(d["aspect-ratio"]=String(r))):"fullWidth"===n&&(d.width="100%",void 0!==o&&(d.height=t(o)),r&&(d["aspect-ratio"]=String(r))),Object.keys(d).length>0?d:void 0}function o(t,i){if(t&&i)switch(i){case"constrained":return`(min-width: ${t}px) ${t}px, 100vw`;case"fixed":return`${t}px`;case"fullWidth":return"100vw";default:return}}function r(t){if(void 0===t)return;if("number"==typeof t)return t;const i=Number.parseInt(t,10);return Number.isNaN(i)?void 0:i}function n(t){let i=r(t.width),e=r(t.height);return t.aspectRatio&&(i&&!e?e=Math.round(i/t.aspectRatio):e&&!i&&(i=Math.round(e*t.aspectRatio))),{width:i,height:e}}function a(t){const{src:i,width:o,height:r,aspectRatio:n,layout:a,priority:c=!1,background:d,objectFit:h,unstyled:u=!1}=t,s={src:i,loading:c?"eager":"lazy",decoding:c?"sync":"async",fetchpriority:c?"high":void 0};if(!u){const t=e({width:o,height:r,aspectRatio:n,layout:a,objectFit:h,background:d});t&&(s.style=t)}return"fixed"===a&&(s.width=o,s.height=r),s}export{o as getImageSizes,e as getImageStyle,n as inferDimensions,r as parseDimension,a as transformProps};
|
|
1
|
+
import{toPx as t}from"@necto/dom";import{isUrl as i}from"@necto/url";function e({width:e,height:o,aspectRatio:r,layout:n,objectFit:a,background:c}){const d={};return a&&(d["object-fit"]=a),i(c)?(d["background-image"]=`url(${c})`,d["background-size"]="cover",d["background-repeat"]="no-repeat"):c&&(d.background=c),"fixed"===n?(void 0!==e&&(d.width=t(e)??""),void 0!==o&&(d.height=t(o)??"")):"constrained"===n?(d.width="100%",void 0!==e&&(d["max-width"]=t(e)??""),void 0!==o&&(d["max-height"]=t(o)??""),r&&(d["aspect-ratio"]=String(r))):"fullWidth"===n&&(d.width="100%",void 0!==o&&(d.height=t(o)??""),r&&(d["aspect-ratio"]=String(r))),Object.keys(d).length>0?d:void 0}function o(t,i){if(t&&i)switch(i){case"constrained":return`(min-width: ${t}px) ${t}px, 100vw`;case"fixed":return`${t}px`;case"fullWidth":return"100vw";default:return}}function r(t){if(void 0===t)return;if("number"==typeof t)return t;const i=Number.parseInt(t,10);return Number.isNaN(i)?void 0:i}function n(t){let i=r(t.width),e=r(t.height);return t.aspectRatio&&(i&&!e?e=Math.round(i/t.aspectRatio):e&&!i&&(i=Math.round(e*t.aspectRatio))),{width:i,height:e}}function a(t){const{src:i,width:o,height:r,aspectRatio:n,layout:a,priority:c=!1,background:d,objectFit:h,unstyled:u=!1}=t,s={src:i,loading:c?"eager":"lazy",decoding:c?"sync":"async",fetchpriority:c?"high":void 0};if(!u){const t=e({width:o,height:r,aspectRatio:n,layout:a,objectFit:h,background:d});t&&(s.style=t)}return"fixed"===a&&(s.width=o,s.height=r),s}export{o as getImageSizes,e as getImageStyle,n as inferDimensions,r as parseDimension,a as transformProps};
|
package/package.json
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@necto/image",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.13",
|
|
4
4
|
"description": "Framework-agnostic image transformation utilities for CDN providers",
|
|
5
5
|
"author": "Corinvo OSS Team",
|
|
6
6
|
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/nectoutil/NodeKit",
|
|
10
|
+
"directory": "packages/@necto/necto-image"
|
|
11
|
+
},
|
|
7
12
|
"dependencies": {
|
|
8
|
-
"@necto/
|
|
9
|
-
"@necto/
|
|
13
|
+
"@necto/dom": "1.7.3",
|
|
14
|
+
"@necto/url": "1.0.0"
|
|
10
15
|
},
|
|
11
16
|
"devDependencies": {
|
|
12
17
|
"@types/node": "^22.14.1",
|