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