@numueg/theme-sdk 0.5.2 → 0.6.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.
- package/dist/index.cjs +111 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +71 -6
- package/dist/index.d.ts +71 -6
- package/dist/index.mjs +111 -3
- package/dist/index.mjs.map +1 -1
- package/dist/{mount-DH9dz3dq.d.mts → mount-BGumg1JM.d.mts} +1 -1
- package/dist/{mount-BN2mz_wx.d.ts → mount-Bt-4ken5.d.ts} +1 -1
- package/dist/normalize.d.mts +1 -1
- package/dist/normalize.d.ts +1 -1
- package/dist/{theme-D0QybTQS.d.mts → theme-D8MOopvi.d.mts} +2 -0
- package/dist/{theme-D0QybTQS.d.ts → theme-D8MOopvi.d.ts} +2 -0
- package/dist/types.d.mts +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/validation.cjs +1 -1
- package/dist/validation.d.mts +1 -1
- package/dist/validation.d.ts +1 -1
- package/dist/validation.mjs +1 -1
- package/dist/verify.d.mts +2 -2
- package/dist/verify.d.ts +2 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -9,7 +9,7 @@ var MAX_BLOCK_DEPTH = 5;
|
|
|
9
9
|
|
|
10
10
|
// src/validation/index.ts
|
|
11
11
|
var THEME_CONTRACT_VERSION = 1;
|
|
12
|
-
var SDK_VERSION = "0.
|
|
12
|
+
var SDK_VERSION = "0.6.0" ;
|
|
13
13
|
var REQUIRED_TEMPLATES = [
|
|
14
14
|
"home",
|
|
15
15
|
"product",
|
|
@@ -2742,6 +2742,7 @@ function Image({
|
|
|
2742
2742
|
sizes = "(min-width: 1024px) 25vw, (min-width: 640px) 50vw, 100vw",
|
|
2743
2743
|
responsive = true,
|
|
2744
2744
|
loading = "lazy",
|
|
2745
|
+
priority = false,
|
|
2745
2746
|
aspectRatio,
|
|
2746
2747
|
objectFit,
|
|
2747
2748
|
objectPosition,
|
|
@@ -2778,6 +2779,7 @@ function Image({
|
|
|
2778
2779
|
);
|
|
2779
2780
|
}
|
|
2780
2781
|
const srcSet = responsive ? buildSrcSet(src) : void 0;
|
|
2782
|
+
const effLoading = priority ? "eager" : loading;
|
|
2781
2783
|
const effFit = objectFit ?? (framed ? "cover" : void 0);
|
|
2782
2784
|
const fitStyle = transform ? applyImageTransform(transform, effFit === "contain" ? "contain" : "cover") : {
|
|
2783
2785
|
...effFit ? { objectFit: effFit } : {},
|
|
@@ -2790,7 +2792,8 @@ function Image({
|
|
|
2790
2792
|
alt,
|
|
2791
2793
|
srcSet: srcSet || void 0,
|
|
2792
2794
|
sizes: srcSet ? sizes : void 0,
|
|
2793
|
-
loading,
|
|
2795
|
+
loading: effLoading,
|
|
2796
|
+
fetchPriority: priority ? "high" : void 0,
|
|
2794
2797
|
decoding: "async",
|
|
2795
2798
|
className: framed ? void 0 : className,
|
|
2796
2799
|
style: framed ? { width: "100%", height: "100%", display: "block", ...fitStyle } : { ...fitStyle, ...style },
|
|
@@ -2814,6 +2817,111 @@ function Image({
|
|
|
2814
2817
|
}
|
|
2815
2818
|
);
|
|
2816
2819
|
}
|
|
2820
|
+
var HERO_WIDTHS = [640, 768, 1024, 1280, 1920];
|
|
2821
|
+
var DEFAULT_BREAKPOINT = 768;
|
|
2822
|
+
var DESKTOP_BASE_WIDTH = 1920;
|
|
2823
|
+
var MOBILE_BASE_WIDTH = 1280;
|
|
2824
|
+
function heroSrcSet(url, opts) {
|
|
2825
|
+
return HERO_WIDTHS.map((w) => `${focalSrc(url, { width: w, ...opts })} ${w}w`).join(", ");
|
|
2826
|
+
}
|
|
2827
|
+
function HeroMedia({
|
|
2828
|
+
src,
|
|
2829
|
+
alt,
|
|
2830
|
+
transform,
|
|
2831
|
+
mobileSrc,
|
|
2832
|
+
mobileTransform,
|
|
2833
|
+
desktopAspect,
|
|
2834
|
+
mobileAspect,
|
|
2835
|
+
fit = "cover",
|
|
2836
|
+
priority = true,
|
|
2837
|
+
sizes = "100vw",
|
|
2838
|
+
breakpoint = DEFAULT_BREAKPOINT,
|
|
2839
|
+
preloadAlternate = true,
|
|
2840
|
+
className,
|
|
2841
|
+
style,
|
|
2842
|
+
...rest
|
|
2843
|
+
}) {
|
|
2844
|
+
const hasMobile = !!mobileSrc;
|
|
2845
|
+
const mobileQuery = `(max-width: ${breakpoint - 1}px)`;
|
|
2846
|
+
const [isMobile, setIsMobile] = react.useState(
|
|
2847
|
+
() => hasMobile && typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia(mobileQuery).matches
|
|
2848
|
+
);
|
|
2849
|
+
const [rawFallback, setRawFallback] = react.useState(false);
|
|
2850
|
+
const { onError: themeOnError, ...imgRest } = rest;
|
|
2851
|
+
const handleError = (e) => {
|
|
2852
|
+
if (!rawFallback) setRawFallback(true);
|
|
2853
|
+
else themeOnError?.(e);
|
|
2854
|
+
};
|
|
2855
|
+
react.useEffect(() => {
|
|
2856
|
+
if (!hasMobile || typeof window === "undefined" || typeof window.matchMedia !== "function") {
|
|
2857
|
+
return;
|
|
2858
|
+
}
|
|
2859
|
+
const mq = window.matchMedia(mobileQuery);
|
|
2860
|
+
const sync = () => setIsMobile(mq.matches);
|
|
2861
|
+
sync();
|
|
2862
|
+
mq.addEventListener?.("change", sync);
|
|
2863
|
+
return () => mq.removeEventListener?.("change", sync);
|
|
2864
|
+
}, [hasMobile, mobileQuery]);
|
|
2865
|
+
const desktopFocal = transform?.focal;
|
|
2866
|
+
const mobileFocal = mobileTransform?.focal ?? desktopFocal;
|
|
2867
|
+
const desktopCrop = desktopAspect ? { focal: desktopFocal, aspect: desktopAspect, fit } : {};
|
|
2868
|
+
const mobileCrop = {
|
|
2869
|
+
focal: mobileFocal,
|
|
2870
|
+
aspect: mobileAspect,
|
|
2871
|
+
fit
|
|
2872
|
+
};
|
|
2873
|
+
react.useEffect(() => {
|
|
2874
|
+
if (!preloadAlternate || !hasMobile || !src || !mobileSrc) return;
|
|
2875
|
+
if (typeof window === "undefined" || typeof window.Image !== "function") return;
|
|
2876
|
+
const altUrl = isMobile ? rawFallback ? src : focalSrc(src, { width: DESKTOP_BASE_WIDTH, ...desktopCrop }) : rawFallback ? mobileSrc : focalSrc(mobileSrc, { width: MOBILE_BASE_WIDTH, ...mobileCrop });
|
|
2877
|
+
if (!altUrl) return;
|
|
2878
|
+
const im = new window.Image();
|
|
2879
|
+
im.onerror = () => {
|
|
2880
|
+
};
|
|
2881
|
+
try {
|
|
2882
|
+
im.fetchPriority = "low";
|
|
2883
|
+
} catch {
|
|
2884
|
+
}
|
|
2885
|
+
im.decoding = "async";
|
|
2886
|
+
im.src = altUrl;
|
|
2887
|
+
if (typeof im.decode === "function") im.decode().catch(() => {
|
|
2888
|
+
});
|
|
2889
|
+
}, [preloadAlternate, hasMobile, src, mobileSrc, isMobile, rawFallback]);
|
|
2890
|
+
if (!src) {
|
|
2891
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2892
|
+
"div",
|
|
2893
|
+
{
|
|
2894
|
+
className,
|
|
2895
|
+
role: "img",
|
|
2896
|
+
"aria-label": alt,
|
|
2897
|
+
style: { width: "100%", height: "100%", backgroundColor: "rgba(0,0,0,0.05)", ...style }
|
|
2898
|
+
}
|
|
2899
|
+
);
|
|
2900
|
+
}
|
|
2901
|
+
const useMobile = hasMobile && isMobile;
|
|
2902
|
+
const activeUrl = useMobile ? mobileSrc : src;
|
|
2903
|
+
const activeCrop = useMobile ? mobileCrop : desktopCrop;
|
|
2904
|
+
const activeBase = useMobile ? MOBILE_BASE_WIDTH : DESKTOP_BASE_WIDTH;
|
|
2905
|
+
const activeSrc = rawFallback ? activeUrl : focalSrc(activeUrl, { width: activeBase, ...activeCrop });
|
|
2906
|
+
const activeSrcSet = rawFallback ? void 0 : heroSrcSet(activeUrl, activeCrop);
|
|
2907
|
+
const fitStyle = applyImageTransform(useMobile ? mobileTransform ?? transform : transform, fit);
|
|
2908
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2909
|
+
"img",
|
|
2910
|
+
{
|
|
2911
|
+
src: activeSrc,
|
|
2912
|
+
srcSet: activeSrcSet,
|
|
2913
|
+
sizes: activeSrcSet ? sizes : void 0,
|
|
2914
|
+
alt,
|
|
2915
|
+
loading: priority ? "eager" : "lazy",
|
|
2916
|
+
fetchPriority: priority ? "high" : void 0,
|
|
2917
|
+
decoding: "async",
|
|
2918
|
+
onError: handleError,
|
|
2919
|
+
className,
|
|
2920
|
+
style: { width: "100%", height: "100%", display: "block", ...fitStyle, ...style },
|
|
2921
|
+
...imgRest
|
|
2922
|
+
}
|
|
2923
|
+
);
|
|
2924
|
+
}
|
|
2817
2925
|
var str = (v) => typeof v === "string" ? v : "";
|
|
2818
2926
|
var NONE_HEIGHT = { small: 28, medium: 36, large: 48 };
|
|
2819
2927
|
function Logo({
|
|
@@ -4072,6 +4180,7 @@ exports.CustomerContext = CustomerContext;
|
|
|
4072
4180
|
exports.EditableImage = EditableImage;
|
|
4073
4181
|
exports.EditableText = EditableText;
|
|
4074
4182
|
exports.Form = Form;
|
|
4183
|
+
exports.HeroMedia = HeroMedia;
|
|
4075
4184
|
exports.ICON_NAMES = ICON_NAMES;
|
|
4076
4185
|
exports.Icon = Icon;
|
|
4077
4186
|
exports.IconMap = IconMap;
|