@jetshop/ui 6.5.4 → 6.5.5
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.
|
@@ -1,25 +1,18 @@
|
|
|
1
1
|
import { getImageWidth } from './getImageWidth';
|
|
2
2
|
import { remToPx } from './remToPx';
|
|
3
3
|
import { getSizeForBreakpoint } from './getSizeForBreakpoint';
|
|
4
|
-
// Snap responsive widths to this ladder so srcsets from different
|
|
4
|
+
// Snap responsive widths up to this ladder so srcsets from different
|
|
5
5
|
// (breakpoint × DPR × sizes-fraction) products collapse onto a shared finite
|
|
6
|
-
// set of URLs.
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
// bypass the ladder; their literal pixel intent is
|
|
6
|
+
// set of URLs. Snap-up (not nearest) guarantees the served image is at least
|
|
7
|
+
// the requested width — no quality regression, at the cost of some bandwidth
|
|
8
|
+
// on widths that fall just above a rung. Fixed-pixel `sizes` (e.g.
|
|
9
|
+
// sizes={[200]} for a logo) bypass the ladder; their literal pixel intent is
|
|
10
|
+
// preserved.
|
|
10
11
|
const WIDTH_LADDER = [160, 320, 640, 960, 1280, 1600, 2560];
|
|
11
12
|
function snapToLadder(width) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
return WIDTH_LADDER[WIDTH_LADDER.length - 1];
|
|
16
|
-
for (let i = 0; i < WIDTH_LADDER.length - 1; i++) {
|
|
17
|
-
const lo = WIDTH_LADDER[i];
|
|
18
|
-
const hi = WIDTH_LADDER[i + 1];
|
|
19
|
-
if (width >= lo && width <= hi) {
|
|
20
|
-
// Nearest in log space — picks the entry with smaller proportional gap.
|
|
21
|
-
return width / lo < hi / width ? lo : hi;
|
|
22
|
-
}
|
|
13
|
+
for (const rung of WIDTH_LADDER) {
|
|
14
|
+
if (width <= rung)
|
|
15
|
+
return rung;
|
|
23
16
|
}
|
|
24
17
|
return WIDTH_LADDER[WIDTH_LADDER.length - 1];
|
|
25
18
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getImageWidths.js","sourceRoot":"","sources":["getImageWidths.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAG9D,
|
|
1
|
+
{"version":3,"file":"getImageWidths.js","sourceRoot":"","sources":["getImageWidths.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAG9D,qEAAqE;AACrE,6EAA6E;AAC7E,6EAA6E;AAC7E,6EAA6E;AAC7E,mEAAmE;AACnE,6EAA6E;AAC7E,aAAa;AACb,MAAM,YAAY,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAU,CAAC;AAErE,SAAS,YAAY,CAAC,KAAa;IACjC,KAAK,MAAM,IAAI,IAAI,YAAY,EAAE;QAC/B,IAAI,KAAK,IAAI,IAAI;YAAE,OAAO,IAAI,CAAC;KAChC;IACD,OAAO,YAAY,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AAC/C,CAAC;AAED,MAAM,CAAC,MAAM,cAAc,GAAG,CAC5B,WAAmC,EACnC,KAA2B,EAC3B,MAAM,GAAG,KAAK,EACd,EAAE;IACF,MAAM,GAAG,GAAG,IAAI,GAAG,EAAU,CAAC;IAE9B,MAAM,eAAe,GAAG,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC;QACzE,GAAG;QACH,KAAK;KACN,CAAC,CAAC,CAAC;IAEJ,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,eAAe,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QAE/C,MAAM,MAAM,GAAG,oBAAoB,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QAC9C,MAAM,EAAE,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;QAE7C,MAAM,EAAE,GAAG,aAAa,CAAC,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;QACxC,MAAM,EAAE,GAAG,aAAa,CAAC,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;QAExC,uEAAuE;QACvE,uEAAuE;QACvE,oEAAoE;QACpE,MAAM,OAAO,GAAG,MAAM,GAAG,CAAC,CAAC;QAC3B,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC,CAAC;QACzC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC,CAAC;QAEzC,IAAI,MAAM,IAAI,eAAe,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,IAAI,EAAE;YAC7C,MAAM;SACP;KACF;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;AAChC,CAAC,CAAC"}
|
|
@@ -18,20 +18,22 @@ src,
|
|
|
18
18
|
includeViewportSize = true, options = { crop: false },
|
|
19
19
|
// @ts-ignore
|
|
20
20
|
timestamp) {
|
|
21
|
-
//
|
|
22
|
-
// `
|
|
23
|
-
//
|
|
24
|
-
//
|
|
21
|
+
// fit=cover when the caller opts into crop, fit=contain otherwise — mirrors
|
|
22
|
+
// the Akamai port's `options.crop ? 'crop' : 'fit'` toggle. Cloudflare has
|
|
23
|
+
// no analogue of Akamai's edge-pixel-sampling `extend=copy`; for
|
|
24
|
+
// non-transparent JPEGs, CF's contain mode pads white, which matches
|
|
25
|
+
// Akamai's behavior on white-background product photography.
|
|
26
|
+
const fit = options.crop ? 'cover' : 'contain';
|
|
25
27
|
const quality = options.quality;
|
|
26
28
|
const height = aspect
|
|
27
29
|
? Math.round(width * aspectRatioToFraction(aspect))
|
|
28
30
|
: null;
|
|
29
31
|
const properties = [];
|
|
30
32
|
if (height) {
|
|
31
|
-
properties.push(`width=${width},height=${height},fit
|
|
33
|
+
properties.push(`width=${width},height=${height},fit=${fit}`);
|
|
32
34
|
}
|
|
33
35
|
else {
|
|
34
|
-
properties.push(`width=${width},fit
|
|
36
|
+
properties.push(`width=${width},fit=${fit}`);
|
|
35
37
|
}
|
|
36
38
|
// Gravity (and focal-point override) only meaningful when aspect-driven height is
|
|
37
39
|
// set — mirrors Akamai's helper. Focal points trump the keyword since Cloudflare
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getSrcWithParams.js","sourceRoot":"","sources":["getSrcWithParams.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAIhE,uEAAuE;AAEvE,uDAAuD;AACvD,sFAAsF;AACtF,wDAAwD;AACxD,MAAM,WAAW,GAA4B;IAC3C,KAAK,EAAE,KAAK;IACZ,KAAK,EAAE,QAAQ;IACf,IAAI,EAAE,OAAO;IACb,IAAI,EAAE,MAAM;IACZ,MAAM,EAAE,SAAS;IACjB,KAAK,EAAE,MAAM;CACd,CAAC;AAEF,MAAM,UAAU,uBAAuB,CACrC,KAAa,EACb,MAAmB;AACnB,aAAa;AACb,GAAW;AACX,aAAa;AACb,mBAAmB,GAAG,IAAI,EAC1B,UAA6B,EAAE,IAAI,EAAE,KAAK,EAAE;AAC5C,aAAa;AACb,SAAkB;IAElB
|
|
1
|
+
{"version":3,"file":"getSrcWithParams.js","sourceRoot":"","sources":["getSrcWithParams.ts"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;YAC9C,UAAU,CAAC,IAAI,CACb,WAAW,OAAO,CAAC,WAAW,IAAI,OAAO,CAAC,WAAW,EAAE,CACxD,CAAC;SACH;aAAM,IAAI,OAAO,CAAC,OAAO,EAAE;YAC1B,UAAU,CAAC,IAAI,CAAC,WAAW,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;SAC5D;KACF;IAED,mFAAmF;IACnF,oFAAoF;IACpF,IAAI,OAAO,EAAE;QACX,UAAU,CAAC,IAAI,CAAC,WAAW,OAAO,EAAE,CAAC,CAAC;KACvC;IAED,mFAAmF;IACnF,kFAAkF;IAClF,0EAA0E;IAC1E,gFAAgF;IAChF,8CAA8C;IAC9C,UAAU,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IAE/B,OAAO,UAAU,CAAC,QAAQ,EAAE,CAAC;AAC/B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jetshop/ui",
|
|
3
|
-
"version": "6.5.
|
|
3
|
+
"version": "6.5.5",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"files": [
|
|
6
6
|
"**/*.js",
|
|
@@ -61,5 +61,5 @@
|
|
|
61
61
|
"react": "^18",
|
|
62
62
|
"react-dom": "^18"
|
|
63
63
|
},
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "62775314498852c9efef190bd8d90c8d3543e980"
|
|
65
65
|
}
|