cloudcommerce 0.8.4 → 0.8.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.
- package/CHANGELOG.md +15 -0
- package/ecomplus-stores/monocard/functions/core/package.json +1 -1
- package/ecomplus-stores/monocard/functions/events/package.json +2 -2
- package/ecomplus-stores/monocard/functions/modules/package.json +2 -2
- package/ecomplus-stores/monocard/functions/passport/package.json +2 -2
- package/ecomplus-stores/monocard/functions/ssr/package.json +7 -7
- package/ecomplus-stores/monocard/functions/ssr/scripts/build.sh +12 -0
- package/ecomplus-stores/monocard/functions/ssr/src/components/CasesGrid.astro +1 -1
- package/ecomplus-stores/monocard/functions/ssr/src/components/FeatureTabs.astro +2 -4
- package/ecomplus-stores/monocard/package.json +1 -1
- package/package.json +9 -9
- package/packages/api/package.json +1 -1
- package/packages/apps/correios/lib-mjs/calculate-correios.mjs +3 -3
- package/packages/apps/correios/package.json +1 -1
- package/packages/apps/custom-payment/package.json +1 -1
- package/packages/apps/custom-shipping/package.json +1 -1
- package/packages/apps/datafrete/package.json +1 -1
- package/packages/apps/discounts/package.json +1 -1
- package/packages/apps/emails/package.json +2 -2
- package/packages/apps/fb-conversions/package.json +1 -1
- package/packages/apps/frenet/package.json +1 -1
- package/packages/apps/galaxpay/package.json +1 -1
- package/packages/apps/google-analytics/package.json +1 -1
- package/packages/apps/infinitepay/package.json +1 -1
- package/packages/apps/jadlog/package.json +1 -1
- package/packages/apps/loyalty-points/package.json +1 -1
- package/packages/apps/melhor-envio/package.json +1 -1
- package/packages/apps/mercadopago/package.json +1 -1
- package/packages/apps/pagarme/package.json +1 -1
- package/packages/apps/paghiper/package.json +1 -1
- package/packages/apps/pix/package.json +1 -1
- package/packages/apps/tiny-erp/package.json +1 -1
- package/packages/apps/webhooks/package.json +1 -1
- package/packages/cli/package.json +2 -2
- package/packages/config/package.json +1 -1
- package/packages/emails/package.json +1 -1
- package/packages/events/package.json +1 -1
- package/packages/firebase/package.json +1 -1
- package/packages/i18n/package.json +1 -1
- package/packages/modules/package.json +1 -1
- package/packages/passport/package.json +1 -1
- package/packages/ssr/package.json +1 -1
- package/packages/storefront/astro.config.mjs +1 -1
- package/packages/storefront/dist/client/_astro/{PitchBar.db7cd775.js → PitchBar.5d55c359.js} +1 -1
- package/packages/storefront/dist/client/_astro/{ShopHeader.e93c8274.js → ShopHeader.6bbe1a17.js} +1 -1
- package/packages/storefront/dist/client/_astro/_...slug_.3beb11c8.css +1 -0
- package/packages/storefront/dist/client/_astro/{firebase-app.72e91a3e.js → firebase-app.d090c84e.js} +5 -5
- package/packages/storefront/dist/client/_astro/{hoisted.721ad75d.js → hoisted.541b5c05.js} +1 -1
- package/packages/storefront/dist/client/_astro/index.ff4f0b30.js +1 -0
- package/packages/storefront/dist/client/_astro/{workbox-window.prod.es5.295a6886.js → workbox-window.prod.es5.dc90f814.js} +1 -1
- package/packages/storefront/dist/client/sw.js +1 -1
- package/packages/storefront/dist/server/chunks/pages/{all.090434f8.mjs → all.857ce59d.mjs} +108 -37
- package/packages/storefront/dist/server/entry.mjs +2 -2
- package/packages/storefront/package.json +6 -6
- package/packages/storefront/scripts/build-prod.sh +18 -6
- package/packages/storefront/src/images/Picture.runtime.astro +52 -0
- package/packages/storefront/src/{serverless/get-image.ts → images/get-built-image.ts} +3 -3
- package/packages/storefront/src/{serverless/get-picture.ts → images/get-built-picture.ts} +3 -3
- package/packages/storefront/src/images/use-ssr-picture.ts +138 -0
- package/packages/storefront/src/lib/assets/base.css +0 -5
- package/packages/storefront/src/lib/components/Picture.astro +21 -73
- package/packages/types/package.json +1 -1
- package/packages/storefront/dist/client/_astro/_...slug_.0607a6ef.css +0 -1
- package/packages/storefront/dist/client/_astro/index.16f33784.js +0 -1
- package/packages/storefront/src/serverless/Picture.runtime.astro +0 -102
|
@@ -17,8 +17,7 @@ import { ssrRenderAttrs, ssrRenderSlot, ssrRenderClass, ssrRenderVNode, ssrRende
|
|
|
17
17
|
/* empty css */import { EventEmitter } from 'node:events';
|
|
18
18
|
import fs, { readFileSync } from 'node:fs';
|
|
19
19
|
import config from '@cloudcommerce/config';
|
|
20
|
-
/* empty css */import {
|
|
21
|
-
import { useScroll, useElementHover, useDebounceFn, useTimeout, promiseTimeout } from '@vueuse/core';
|
|
20
|
+
/* empty css */import { useScroll, useElementHover, useDebounceFn, useTimeout, promiseTimeout } from '@vueuse/core';
|
|
22
21
|
import { Popover, PopoverButton, PopoverPanel, Menu, MenuButton, MenuItems, MenuItem } from '@headlessui/vue';
|
|
23
22
|
|
|
24
23
|
const _export_sfc = (sfc, props) => {
|
|
@@ -791,35 +790,19 @@ async function getPicture(params) {
|
|
|
791
790
|
};
|
|
792
791
|
}
|
|
793
792
|
|
|
794
|
-
const
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
dimensions = sizeOf(resolve$1(STOREFRONT_BASE_DIR, `public${src2}`));
|
|
804
|
-
} catch (e) {
|
|
805
|
-
dimensions = {};
|
|
806
|
-
}
|
|
807
|
-
}
|
|
808
|
-
return dimensions;
|
|
809
|
-
};
|
|
810
|
-
const getAspectRatio = (src2) => {
|
|
811
|
-
if (typeof src2 === "string") {
|
|
812
|
-
src2 = tryImageSize(src2);
|
|
813
|
-
}
|
|
814
|
-
if (src2.width) {
|
|
815
|
-
return src2.height ? src2.width / src2.height : 1;
|
|
816
|
-
}
|
|
817
|
-
return 0;
|
|
818
|
-
};
|
|
793
|
+
const getAspectRatio = (src, tryImageSize) => {
|
|
794
|
+
if (typeof src === "string") {
|
|
795
|
+
src = tryImageSize(src);
|
|
796
|
+
} else if (src.width) {
|
|
797
|
+
return src.height ? src.width / src.height : 1;
|
|
798
|
+
}
|
|
799
|
+
return 0;
|
|
800
|
+
};
|
|
801
|
+
const useSSRPicture = async (params) => {
|
|
819
802
|
const {
|
|
820
803
|
src,
|
|
821
804
|
alt,
|
|
822
|
-
sizes,
|
|
805
|
+
sizes: propSizes,
|
|
823
806
|
widths,
|
|
824
807
|
aspectRatio: propAspectRatio,
|
|
825
808
|
fit,
|
|
@@ -829,17 +812,60 @@ const $$Picture = createComponent(async ($$result, $$props, $$slots) => {
|
|
|
829
812
|
loading = "lazy",
|
|
830
813
|
decoding = "async",
|
|
831
814
|
hasImg = true,
|
|
815
|
+
tryImageSize,
|
|
816
|
+
getPicture,
|
|
832
817
|
...attrs
|
|
833
|
-
} =
|
|
834
|
-
let aspectRatio
|
|
835
|
-
if (
|
|
818
|
+
} = params;
|
|
819
|
+
let aspectRatio;
|
|
820
|
+
if (propAspectRatio) {
|
|
821
|
+
if (typeof propAspectRatio === "number") {
|
|
822
|
+
aspectRatio = propAspectRatio;
|
|
823
|
+
} else {
|
|
824
|
+
const [width, height] = propAspectRatio.split(":");
|
|
825
|
+
aspectRatio = Number(width) / Number(height);
|
|
826
|
+
}
|
|
827
|
+
} else if ((!attrs.width || !attrs.height) && typeof src === "string") {
|
|
836
828
|
const { width, height } = tryImageSize(src);
|
|
837
829
|
if (height) {
|
|
838
|
-
aspectRatio = getAspectRatio({ width, height });
|
|
830
|
+
aspectRatio = getAspectRatio({ width, height }, tryImageSize);
|
|
839
831
|
attrs.width = width;
|
|
840
832
|
attrs.height = height;
|
|
841
833
|
}
|
|
842
834
|
}
|
|
835
|
+
let sizes = propSizes || "";
|
|
836
|
+
if (!sizes && attrs.class) {
|
|
837
|
+
const classNames = attrs.class.split(" ");
|
|
838
|
+
const classRegex = /^(\w+:)?max-w-\[(\w+)\]$/;
|
|
839
|
+
let nextSize;
|
|
840
|
+
[
|
|
841
|
+
[""],
|
|
842
|
+
["sm", 640],
|
|
843
|
+
["md", 768],
|
|
844
|
+
["lg", 1024],
|
|
845
|
+
["xl", 1280],
|
|
846
|
+
["2xl", 1536]
|
|
847
|
+
].forEach(([breakpoint, minWidth]) => {
|
|
848
|
+
const className = classNames.find((_class) => {
|
|
849
|
+
return _class.startsWith(breakpoint ? `${breakpoint}:max-w-[` : "max-w-[");
|
|
850
|
+
});
|
|
851
|
+
if (className) {
|
|
852
|
+
if (nextSize) {
|
|
853
|
+
if (sizes)
|
|
854
|
+
sizes += ", ";
|
|
855
|
+
sizes += `(max-width: ${minWidth - 1}px) ${nextSize}`;
|
|
856
|
+
}
|
|
857
|
+
nextSize = className.replace(classRegex, "$2");
|
|
858
|
+
}
|
|
859
|
+
});
|
|
860
|
+
if (nextSize) {
|
|
861
|
+
if (sizes)
|
|
862
|
+
sizes += ", ";
|
|
863
|
+
sizes += nextSize;
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
if (!sizes && widths.length === 1) {
|
|
867
|
+
sizes = `${widths[0] / 2}px`;
|
|
868
|
+
}
|
|
843
869
|
const { image, sources } = await getPicture({
|
|
844
870
|
src,
|
|
845
871
|
widths,
|
|
@@ -850,8 +876,6 @@ const $$Picture = createComponent(async ($$result, $$props, $$slots) => {
|
|
|
850
876
|
position,
|
|
851
877
|
alt
|
|
852
878
|
});
|
|
853
|
-
const imgSrc = `${image.src}&V=${process.env.DEPLOY_RAND}`;
|
|
854
|
-
delete image.src;
|
|
855
879
|
delete image.width;
|
|
856
880
|
delete image.height;
|
|
857
881
|
const pictureAttrs = {};
|
|
@@ -861,9 +885,56 @@ const $$Picture = createComponent(async ($$result, $$props, $$slots) => {
|
|
|
861
885
|
delete pictureAttrs.width;
|
|
862
886
|
delete pictureAttrs.height;
|
|
863
887
|
}
|
|
888
|
+
return {
|
|
889
|
+
sizes,
|
|
890
|
+
aspectRatio,
|
|
891
|
+
sources,
|
|
892
|
+
pictureAttrs,
|
|
893
|
+
imgAttrs: !hasImg ? null : {
|
|
894
|
+
...image,
|
|
895
|
+
loading,
|
|
896
|
+
decoding,
|
|
897
|
+
...attrs
|
|
898
|
+
}
|
|
899
|
+
};
|
|
900
|
+
};
|
|
901
|
+
|
|
902
|
+
const $$Astro$e = createAstro("https://ecom2-002.web.app");
|
|
903
|
+
const $$Picture = createComponent(async ($$result, $$props, $$slots) => {
|
|
904
|
+
const Astro2 = $$result.createAstro($$Astro$e, $$props, $$slots);
|
|
905
|
+
Astro2.self = $$Picture;
|
|
906
|
+
const deployRand = process.env.DEPLOY_RAND || "_";
|
|
907
|
+
const getImageFilepath = (src) => {
|
|
908
|
+
const { STOREFRONT_BASE_DIR } = (Object.assign({"BASE_URL":"/","MODE":"production","DEV":false,"PROD":true,"SSR":true,"SITE":"\"https://ecom2-002.web.app\""},{STOREFRONT_BASE_DIR:process.env.STOREFRONT_BASE_DIR,SSR:true,}));
|
|
909
|
+
return resolve(STOREFRONT_BASE_DIR, `public${src}`);
|
|
910
|
+
};
|
|
911
|
+
const tryImageSize = (src) => {
|
|
912
|
+
let dimensions = {};
|
|
913
|
+
if (typeof src === "string" && src.startsWith("/")) {
|
|
914
|
+
try {
|
|
915
|
+
dimensions = sizeOf(getImageFilepath(src));
|
|
916
|
+
} catch (e) {
|
|
917
|
+
dimensions = {};
|
|
918
|
+
}
|
|
919
|
+
}
|
|
920
|
+
return dimensions;
|
|
921
|
+
};
|
|
922
|
+
const {
|
|
923
|
+
sizes,
|
|
924
|
+
sources,
|
|
925
|
+
pictureAttrs,
|
|
926
|
+
imgAttrs
|
|
927
|
+
} = await useSSRPicture({
|
|
928
|
+
...Astro2.props,
|
|
929
|
+
tryImageSize,
|
|
930
|
+
getPicture
|
|
931
|
+
});
|
|
932
|
+
if (imgAttrs) {
|
|
933
|
+
imgAttrs.src += `&V=${deployRand}`;
|
|
934
|
+
}
|
|
864
935
|
return renderTemplate`${maybeRenderHead($$result)}<picture${spreadAttributes(pictureAttrs)}>
|
|
865
|
-
${sources.map((
|
|
866
|
-
${
|
|
936
|
+
${sources.map((attrs) => renderTemplate`<source${addAttribute(attrs.type, "type")}${addAttribute(attrs.srcset.replace(/\s(\w+)$/, `&V=${deployRand} $1`), "srcset")}${addAttribute(sizes, "sizes")}>`)}
|
|
937
|
+
${imgAttrs && renderTemplate`<img${spreadAttributes(imgAttrs)}>`}
|
|
867
938
|
</picture>`;
|
|
868
939
|
}, "/home/leo/code/ecomplus/cloud-commerce/packages/storefront/src/lib/components/Picture.astro");
|
|
869
940
|
|
|
@@ -3246,7 +3317,7 @@ const $$Pages = createComponent(async ($$result, $$props, $$slots) => {
|
|
|
3246
3317
|
const { pageContext, title } = Astro2.props;
|
|
3247
3318
|
const { settings } = pageContext;
|
|
3248
3319
|
return renderTemplate`${renderComponent($$result, "Base", $$Base, { "pageContext": pageContext, "title": title }, { "default": ($$result2) => renderTemplate`${renderSlot($$result2, $$slots["header"], renderTemplate`
|
|
3249
|
-
${renderComponent($$result2, "Header", $$PagesHeader, { "pageContext": pageContext }, { "logo-picture": ($$result3) => renderTemplate`${renderComponent($$result3, "Picture", $$Picture, { "slot": "logo-picture", "src": settings.logo, "alt": settings.name, "widths": [300], "
|
|
3320
|
+
${renderComponent($$result2, "Header", $$PagesHeader, { "pageContext": pageContext }, { "logo-picture": ($$result3) => renderTemplate`${renderComponent($$result3, "Picture", $$Picture, { "slot": "logo-picture", "src": settings.logo, "alt": settings.name, "widths": [300], "fetchpriority": "high", "loading": "eager", "class": "hover:drop-shadow-sm max-w-[150px]" })}` })}
|
|
3250
3321
|
`)}${renderSlot($$result2, $$slots["default"])}` })}`;
|
|
3251
3322
|
}, "/home/leo/code/ecomplus/cloud-commerce/packages/storefront/src/layouts/Pages.astro");
|
|
3252
3323
|
|
|
@@ -14,7 +14,7 @@ import enableDestroy from 'server-destroy';
|
|
|
14
14
|
import { defineComponent, computed, useSSRContext, mergeProps, h as h$1, createSSRApp } from 'vue';
|
|
15
15
|
import { ssrRenderSlotInner, ssrRenderAttrs, ssrRenderSlot, renderToString } from 'vue/server-renderer';
|
|
16
16
|
import { img, imgSizes, i18n, formatMoney } from '@ecomplus/utils';
|
|
17
|
-
/* empty css */import { _ as _export_sfc, a as _page0, b as _page1, c as _page2, d as _page3, e as _page4, f as _page5 } from './chunks/pages/all.
|
|
17
|
+
/* empty css */import { _ as _export_sfc, a as _page0, b as _page1, c as _page2, d as _page3, e as _page4, f as _page5 } from './chunks/pages/all.857ce59d.mjs';
|
|
18
18
|
import 'mime';
|
|
19
19
|
import 'cookie';
|
|
20
20
|
import 'kleur/colors';
|
|
@@ -3062,7 +3062,7 @@ const _renderer1 = {
|
|
|
3062
3062
|
const pageMap = new Map([["../../node_modules/.pnpm/@astrojs+image@0.16.0_astro@2.1.2+sharp@0.31.3/node_modules/@astrojs/image/dist/endpoint.js", _page0],["src/pages/index.astro", _page1],["src/pages/fallback.astro", _page2],["src/pages/app/index.astro", _page3],["src/pages/app/account.astro", _page4],["src/pages/[...slug].astro", _page5],]);
|
|
3063
3063
|
const renderers = [Object.assign({"name":"astro:jsx","serverEntrypoint":"astro/jsx/server.js","jsxImportSource":"astro"}, { ssr: server_default }),Object.assign({"name":"@astrojs/vue","clientEntrypoint":"@astrojs/vue/client.js","serverEntrypoint":"@astrojs/vue/server.js"}, { ssr: _renderer1 }),];
|
|
3064
3064
|
|
|
3065
|
-
const _manifest = Object.assign(deserializeManifest({"adapterName":"@astrojs/node","routes":[{"file":"","links":[],"scripts":[],"routeData":{"type":"endpoint","route":"/_image","pattern":"^\\/_image$","segments":[[{"content":"_image","dynamic":false,"spread":false}]],"params":[],"component":"../../node_modules/.pnpm/@astrojs+image@0.16.0_astro@2.1.2+sharp@0.31.3/node_modules/@astrojs/image/dist/endpoint.js","pathname":"/_image","prerender":false,"_meta":{"trailingSlash":"ignore"}}},{"file":"","links":["_astro/_...slug_.
|
|
3065
|
+
const _manifest = Object.assign(deserializeManifest({"adapterName":"@astrojs/node","routes":[{"file":"","links":[],"scripts":[],"routeData":{"type":"endpoint","route":"/_image","pattern":"^\\/_image$","segments":[[{"content":"_image","dynamic":false,"spread":false}]],"params":[],"component":"../../node_modules/.pnpm/@astrojs+image@0.16.0_astro@2.1.2+sharp@0.31.3/node_modules/@astrojs/image/dist/endpoint.js","pathname":"/_image","prerender":false,"_meta":{"trailingSlash":"ignore"}}},{"file":"","links":["_astro/_...slug_.3beb11c8.css","_astro/index.0c833781.css"],"scripts":[{"type":"external","value":"_astro/hoisted.541b5c05.js"}],"routeData":{"route":"/","type":"page","pattern":"^\\/$","segments":[],"params":[],"component":"src/pages/index.astro","pathname":"/","prerender":false,"_meta":{"trailingSlash":"ignore"}}},{"file":"","links":["_astro/_...slug_.3beb11c8.css"],"scripts":[{"type":"external","value":"_astro/hoisted.541b5c05.js"}],"routeData":{"route":"/fallback","type":"page","pattern":"^\\/fallback\\/?$","segments":[[{"content":"fallback","dynamic":false,"spread":false}]],"params":[],"component":"src/pages/fallback.astro","pathname":"/fallback","prerender":false,"_meta":{"trailingSlash":"ignore"}}},{"file":"","links":[],"scripts":[],"routeData":{"route":"/app","type":"page","pattern":"^\\/app\\/?$","segments":[[{"content":"app","dynamic":false,"spread":false}]],"params":[],"component":"src/pages/app/index.astro","pathname":"/app","prerender":false,"_meta":{"trailingSlash":"ignore"}}},{"file":"","links":[],"scripts":[],"routeData":{"route":"/app/account","type":"page","pattern":"^\\/app\\/account\\/?$","segments":[[{"content":"app","dynamic":false,"spread":false}],[{"content":"account","dynamic":false,"spread":false}]],"params":[],"component":"src/pages/app/account.astro","pathname":"/app/account","prerender":false,"_meta":{"trailingSlash":"ignore"}}},{"file":"","links":["_astro/_...slug_.3beb11c8.css"],"scripts":[{"type":"external","value":"_astro/hoisted.541b5c05.js"}],"routeData":{"route":"/[...slug]","type":"page","pattern":"^(?:\\/(.*?))?\\/?$","segments":[[{"content":"...slug","dynamic":true,"spread":true}]],"params":["...slug"],"component":"src/pages/[...slug].astro","prerender":false,"_meta":{"trailingSlash":"ignore"}}}],"site":"https://ecom2-002.web.app","base":"/","markdown":{"drafts":false,"syntaxHighlight":"shiki","shikiConfig":{"langs":[],"theme":"github-dark","wrap":false},"remarkPlugins":[],"rehypePlugins":[],"remarkRehype":{},"gfm":true,"smartypants":true},"pageMap":null,"propagation":[],"renderers":[],"entryModules":{"\u0000@astrojs-ssr-virtual-entry":"_@astrojs-ssr-virtual-entry.mjs","@@sf/components/ProductCard.vue":"_astro/ProductCard.7e891c08.js","~/components/Prices.vue":"_astro/Prices.55399c72.js","~/components/PitchBar.vue":"_astro/PitchBar.5d55c359.js","/astro/hoisted.js?q=0":"_astro/hoisted.541b5c05.js","@astrojs/vue/client.js":"_astro/client.0de2f274.js","/home/leo/code/ecomplus/cloud-commerce/node_modules/workbox-window/build/workbox-window.prod.es5.mjs":"_astro/workbox-window.prod.es5.dc90f814.js","~/components/ShopHeader.vue":"_astro/ShopHeader.6bbe1a17.js","/home/leo/code/ecomplus/cloud-commerce/packages/storefront/src/lib/scripts/firebase-app.ts":"_astro/firebase-app.d090c84e.js","astro:scripts/before-hydration.js":""},"assets":["/_astro/index.0c833781.css","/_astro/server.1bc2fa51.css","/_astro/_...slug_.3beb11c8.css","/manifest.webmanifest","/robots.txt","/sw.js","/workbox-e0d788d4.js","/_astro/PitchBar.5d55c359.js","/_astro/Prices.55399c72.js","/_astro/ProductCard.7e891c08.js","/_astro/ShopHeader.6bbe1a17.js","/_astro/_plugin-vue_export-helper.77ed7c18.js","/_astro/client.0de2f274.js","/_astro/firebase-app.d090c84e.js","/_astro/format-money.ab6b71eb.js","/_astro/hoisted.541b5c05.js","/_astro/idle-callback.889bf0ea.js","/_astro/index.ff4f0b30.js","/_astro/modules-info.06ac0727.js","/_astro/preload-helper.101896b7.js","/_astro/runtime-dom.esm-bundler.d2f39f33.js","/_astro/session-utm.72684b84.js","/_astro/workbox-window.prod.es5.dc90f814.js","/admin/config.json","/assets/cms-preview.css","/assets/cms.css","/assets/cvv.png","/assets/img-placeholder.png","/assets/payments.png","/assets/ssl-safe.png","/img/icon.png","/img/large-icon.png","/img/uploads/banner1.png","/img/uploads/banner2.png","/img/uploads/banner2.webp","/img/uploads/favicon.png","/img/uploads/headless.png","/img/uploads/headphone.png","/img/uploads/headphone.webp","/img/uploads/icon.png","/img/uploads/large-icon.png","/img/uploads/logo.png","/img/uploads/logo.webp","/img/uploads/og-image.png","/img/uploads/passion.png","/img/uploads/passion.webp","/img/uploads/pwa-reliable.png","/img/uploads/rect8589.png","/img/uploads/rect859.png","/img/uploads/rect89.png","/img/uploads/rect89.webp","/img/uploads/ssl-safe.png"]}), {
|
|
3066
3066
|
pageMap: pageMap,
|
|
3067
3067
|
renderers: renderers
|
|
3068
3068
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudcommerce/storefront",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.8.
|
|
4
|
+
"version": "0.8.5",
|
|
5
5
|
"description": "E-Com Plus Cloud Commerce storefront with Astro",
|
|
6
6
|
"bin": {
|
|
7
7
|
"storefront": "./scripts/build-prod.sh"
|
|
@@ -46,19 +46,19 @@
|
|
|
46
46
|
"astro": "2.1.2",
|
|
47
47
|
"chroma-js": "^2.4.2",
|
|
48
48
|
"dotenv": "^16.0.3",
|
|
49
|
-
"firebase": "^9.
|
|
49
|
+
"firebase": "^9.18.0",
|
|
50
50
|
"image-size": "^1.0.2",
|
|
51
51
|
"mime": "^3.0.0",
|
|
52
52
|
"semver": "^7.3.8",
|
|
53
53
|
"sharp": "^0.31.3",
|
|
54
54
|
"tailwindcss": "^3.2.7",
|
|
55
|
-
"unocss": "^0.50.
|
|
56
|
-
"vite": "^4.1
|
|
57
|
-
"vite-plugin-pwa": "^0.14.
|
|
55
|
+
"unocss": "^0.50.6",
|
|
56
|
+
"vite": "^4.2.1",
|
|
57
|
+
"vite-plugin-pwa": "^0.14.5",
|
|
58
58
|
"vue": "^3.2.47"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
|
-
"@babel/core": "^7.21.
|
|
61
|
+
"@babel/core": "^7.21.3",
|
|
62
62
|
"@cloudcommerce/types": "workspace:*"
|
|
63
63
|
}
|
|
64
64
|
}
|
|
@@ -1,19 +1,31 @@
|
|
|
1
1
|
#!/bin/bash
|
|
2
2
|
|
|
3
|
-
BUILD_OUTPUT=static
|
|
3
|
+
BUILD_OUTPUT=static \
|
|
4
|
+
BUILD_OUT_DIR=./.cloudcommerce/sf-tmp-dist \
|
|
5
|
+
npx astro build
|
|
4
6
|
DEPLOY_RUNTIME=serverless npx astro build
|
|
5
7
|
|
|
6
|
-
mv ./.cloudcommerce/sf-tmp-dist/_astro/*.{png,jpg,jpeg,webp,avif,svg}
|
|
8
|
+
mv ./.cloudcommerce/sf-tmp-dist/_astro/*.{png,jpg,jpeg,webp,avif,svg} \
|
|
9
|
+
./dist/client/_astro/ \
|
|
10
|
+
2>/dev/null
|
|
7
11
|
rm -rf ./.cloudcommerce/sf-tmp-dist
|
|
8
12
|
|
|
9
13
|
identify -format "%f,%w,%h\n" \
|
|
10
|
-
./dist/client/_astro/*.{png,jpg,jpeg,webp,avif,svg}
|
|
14
|
+
./dist/client/_astro/*.{png,jpg,jpeg,webp,avif,svg} \
|
|
15
|
+
> ./dist/server/images.dist.csv \
|
|
16
|
+
2>/dev/null
|
|
11
17
|
|
|
12
18
|
identify -format "assets/%f,%w,%h\n" \
|
|
13
|
-
./public/assets/*.{png,jpg,jpeg,webp,avif,svg}
|
|
19
|
+
./public/assets/*.{png,jpg,jpeg,webp,avif,svg} \
|
|
20
|
+
> ./dist/server/images.src.csv \
|
|
21
|
+
2>/dev/null
|
|
14
22
|
identify -format "img/%f,%w,%h\n" \
|
|
15
|
-
./public/img/*.{png,jpg,jpeg,webp,avif,svg}
|
|
23
|
+
./public/img/*.{png,jpg,jpeg,webp,avif,svg} \
|
|
24
|
+
>> ./dist/server/images.src.csv \
|
|
25
|
+
2>/dev/null
|
|
16
26
|
identify -format "img/uploads/%f,%w,%h\n" \
|
|
17
|
-
./public/img/uploads/*.{png,jpg,jpeg,webp,avif,svg}
|
|
27
|
+
./public/img/uploads/*.{png,jpg,jpeg,webp,avif,svg} \
|
|
28
|
+
>> ./dist/server/images.src.csv \
|
|
29
|
+
2>/dev/null
|
|
18
30
|
|
|
19
31
|
exit 0
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { join as joinPath } from 'node:path';
|
|
3
|
+
import { readFileSync } from 'node:fs';
|
|
4
|
+
import { getBuiltPicture } from './get-built-picture';
|
|
5
|
+
import { type PictureProps, useSSRPicture } from './use-ssr-picture';
|
|
6
|
+
|
|
7
|
+
export type Props = PictureProps;
|
|
8
|
+
|
|
9
|
+
const { STOREFRONT_BASE_DIR } = process.env;
|
|
10
|
+
const baseDir = STOREFRONT_BASE_DIR || process.cwd();
|
|
11
|
+
type OriginalImage = { filepath: string, width: number, height: number };
|
|
12
|
+
const originalImages: OriginalImage[] = [];
|
|
13
|
+
const manifestFilepath = joinPath(baseDir, 'dist/server/images.src.csv');
|
|
14
|
+
readFileSync(manifestFilepath, 'utf-8').split(/\n/).forEach((line) => {
|
|
15
|
+
const [filepath, width, height] = line.split(',');
|
|
16
|
+
originalImages.push({
|
|
17
|
+
filepath,
|
|
18
|
+
width: Number(width),
|
|
19
|
+
height: Number(height),
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
const tryImageSize = (src: string) => {
|
|
24
|
+
let dimensions: { width?: number, height?: number } = {};
|
|
25
|
+
if (typeof src === 'string' && src.startsWith('/')) {
|
|
26
|
+
const originalImage = originalImages.find(({ filepath }) => {
|
|
27
|
+
return new RegExp(`^/${filepath}\\??.*`).test(src);
|
|
28
|
+
});
|
|
29
|
+
if (originalImage) {
|
|
30
|
+
const { width, height } = originalImage;
|
|
31
|
+
dimensions = { width, height };
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return dimensions;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const {
|
|
38
|
+
sizes,
|
|
39
|
+
sources,
|
|
40
|
+
pictureAttrs,
|
|
41
|
+
imgAttrs,
|
|
42
|
+
} = await useSSRPicture({
|
|
43
|
+
...Astro.props,
|
|
44
|
+
tryImageSize,
|
|
45
|
+
getPicture: getBuiltPicture,
|
|
46
|
+
});
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
<picture {...pictureAttrs}>
|
|
50
|
+
{sources.map((attrs) => <source {...attrs} sizes={sizes} />)}
|
|
51
|
+
{imgAttrs && <img {...imgAttrs} />}
|
|
52
|
+
</picture>
|
|
@@ -25,7 +25,7 @@ type ImageOptions = Record<string, any> & {
|
|
|
25
25
|
width: number,
|
|
26
26
|
format: OutputFormat,
|
|
27
27
|
};
|
|
28
|
-
const
|
|
28
|
+
const getBuiltImage = async ({ src, width, format }: ImageOptions) => {
|
|
29
29
|
const filename = src.replace(/^.*\//, '').replace(/.\w+(\?.*)?$/, '');
|
|
30
30
|
const filenameRegExp = new RegExp(`[_.][a-z0-9]+\\.${format}$`, 'i');
|
|
31
31
|
const matchFilename = (_builtImage: BuiltImage) => {
|
|
@@ -48,6 +48,6 @@ const getImage = async ({ src, width, format }: ImageOptions) => {
|
|
|
48
48
|
return { src, width };
|
|
49
49
|
};
|
|
50
50
|
|
|
51
|
-
export default
|
|
51
|
+
export default getBuiltImage;
|
|
52
52
|
|
|
53
|
-
export {
|
|
53
|
+
export { getBuiltImage };
|
|
@@ -2,7 +2,7 @@ import type { HTMLAttributes } from 'astro/types';
|
|
|
2
2
|
// import type { ImageMetadata } from '@astrojs/image/dist/vite-plugin-astro-image';
|
|
3
3
|
import type { OutputFormat, TransformOptions } from '@astrojs/image/dist/loaders/';
|
|
4
4
|
import mime from 'mime';
|
|
5
|
-
import
|
|
5
|
+
import getBuiltImage from './get-built-image';
|
|
6
6
|
|
|
7
7
|
function removeQueryString(src: string) {
|
|
8
8
|
const index = src.lastIndexOf('?');
|
|
@@ -76,7 +76,7 @@ async function resolveFormats({ src, formats }: GetPictureParams) {
|
|
|
76
76
|
return Array.from(unique).filter(Boolean);
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
export async function
|
|
79
|
+
export async function getBuiltPicture(params: GetPictureParams): Promise<GetPictureResult> {
|
|
80
80
|
const {
|
|
81
81
|
src,
|
|
82
82
|
alt,
|
|
@@ -103,7 +103,7 @@ export async function getPicture(params: GetPictureParams): Promise<GetPictureRe
|
|
|
103
103
|
async function getSource(format: OutputFormat) {
|
|
104
104
|
const imgs = await Promise.all(
|
|
105
105
|
widths.map(async (width) => {
|
|
106
|
-
const img = await
|
|
106
|
+
const img = await getBuiltImage({
|
|
107
107
|
src,
|
|
108
108
|
alt,
|
|
109
109
|
format,
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import type { PictureComponentRemoteImageProps } from '@astrojs/image/components/';
|
|
2
|
+
import type {
|
|
3
|
+
GetPictureParams,
|
|
4
|
+
GetPictureResult,
|
|
5
|
+
} from '@astrojs/image/dist/lib/get-picture';
|
|
6
|
+
|
|
7
|
+
export type PictureProps = Omit<PictureComponentRemoteImageProps, 'aspectRatio' | 'sizes'> & {
|
|
8
|
+
sizes?: string;
|
|
9
|
+
aspectRatio?: PictureComponentRemoteImageProps['aspectRatio'];
|
|
10
|
+
fetchpriority?: 'high' | 'low' | 'auto';
|
|
11
|
+
hasImg?: boolean;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export type ImageSize = { width?: number, height?: number };
|
|
15
|
+
|
|
16
|
+
export type TryImageSize = (src: string) => ImageSize;
|
|
17
|
+
|
|
18
|
+
const getAspectRatio = (src: string | ImageSize, tryImageSize: TryImageSize) => {
|
|
19
|
+
if (typeof src === 'string') {
|
|
20
|
+
src = tryImageSize(src);
|
|
21
|
+
} else if (src.width) {
|
|
22
|
+
return src.height ? src.width / src.height : 1;
|
|
23
|
+
}
|
|
24
|
+
return 0;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export type UsePictureParams = PictureProps & {
|
|
28
|
+
tryImageSize: TryImageSize;
|
|
29
|
+
getPicture: (params: GetPictureParams) => Promise<GetPictureResult>;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const useSSRPicture = async (params: UsePictureParams) => {
|
|
33
|
+
const {
|
|
34
|
+
src,
|
|
35
|
+
alt,
|
|
36
|
+
sizes: propSizes,
|
|
37
|
+
widths,
|
|
38
|
+
aspectRatio: propAspectRatio,
|
|
39
|
+
fit,
|
|
40
|
+
background,
|
|
41
|
+
position,
|
|
42
|
+
formats = ['avif', 'webp'],
|
|
43
|
+
loading = 'lazy',
|
|
44
|
+
decoding = 'async',
|
|
45
|
+
hasImg = true,
|
|
46
|
+
tryImageSize,
|
|
47
|
+
getPicture,
|
|
48
|
+
...attrs
|
|
49
|
+
} = params;
|
|
50
|
+
|
|
51
|
+
let aspectRatio: number;
|
|
52
|
+
if (propAspectRatio) {
|
|
53
|
+
if (typeof propAspectRatio === 'number') {
|
|
54
|
+
aspectRatio = propAspectRatio;
|
|
55
|
+
} else {
|
|
56
|
+
const [width, height] = propAspectRatio.split(':');
|
|
57
|
+
aspectRatio = Number(width) / Number(height);
|
|
58
|
+
}
|
|
59
|
+
} else if ((!attrs.width || !attrs.height) && typeof src === 'string') {
|
|
60
|
+
const { width, height } = tryImageSize(src);
|
|
61
|
+
if (height) {
|
|
62
|
+
aspectRatio = getAspectRatio({ width, height }, tryImageSize);
|
|
63
|
+
attrs.width = width;
|
|
64
|
+
attrs.height = height;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
let sizes: string = propSizes || '';
|
|
68
|
+
if (!sizes && attrs.class) {
|
|
69
|
+
const classNames = attrs.class.split(' ');
|
|
70
|
+
const classRegex = /^(\w+:)?max-w-\[(\w+)\]$/;
|
|
71
|
+
let nextSize: string;
|
|
72
|
+
[
|
|
73
|
+
[''],
|
|
74
|
+
['sm', 640],
|
|
75
|
+
['md', 768],
|
|
76
|
+
['lg', 1024],
|
|
77
|
+
['xl', 1280],
|
|
78
|
+
['2xl', 1536],
|
|
79
|
+
].forEach(([breakpoint, minWidth]: [string, number | undefined]) => {
|
|
80
|
+
const className = classNames.find((_class) => {
|
|
81
|
+
return _class.startsWith(breakpoint ? `${breakpoint}:max-w-[` : 'max-w-[');
|
|
82
|
+
});
|
|
83
|
+
if (className) {
|
|
84
|
+
if (nextSize) {
|
|
85
|
+
// max-w-50px sm:max-w-[... => (max-width: 639px) 50px...
|
|
86
|
+
if (sizes) sizes += ', ';
|
|
87
|
+
sizes += `(max-width: ${(minWidth - 1)}px) ${nextSize}`;
|
|
88
|
+
}
|
|
89
|
+
nextSize = className.replace(classRegex, '$2');
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
if (nextSize) {
|
|
93
|
+
if (sizes) sizes += ', ';
|
|
94
|
+
sizes += nextSize;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
if (!sizes && widths.length === 1) {
|
|
98
|
+
sizes = `${(widths[0] / 2)}px`;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const { image, sources } = await getPicture({
|
|
102
|
+
src,
|
|
103
|
+
widths,
|
|
104
|
+
formats,
|
|
105
|
+
aspectRatio,
|
|
106
|
+
fit,
|
|
107
|
+
background,
|
|
108
|
+
position,
|
|
109
|
+
alt,
|
|
110
|
+
});
|
|
111
|
+
delete image.width;
|
|
112
|
+
delete image.height;
|
|
113
|
+
|
|
114
|
+
const pictureAttrs: Partial<typeof attrs & { alt: string }> = {};
|
|
115
|
+
if (!hasImg) {
|
|
116
|
+
pictureAttrs['data-alt'] = alt;
|
|
117
|
+
Object.assign(pictureAttrs, attrs);
|
|
118
|
+
delete pictureAttrs.width;
|
|
119
|
+
delete pictureAttrs.height;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return {
|
|
123
|
+
sizes,
|
|
124
|
+
aspectRatio,
|
|
125
|
+
sources,
|
|
126
|
+
pictureAttrs,
|
|
127
|
+
imgAttrs: !hasImg ? null : {
|
|
128
|
+
...image,
|
|
129
|
+
loading,
|
|
130
|
+
decoding,
|
|
131
|
+
...attrs,
|
|
132
|
+
},
|
|
133
|
+
};
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
export default useSSRPicture;
|
|
137
|
+
|
|
138
|
+
export { useSSRPicture };
|
|
@@ -101,11 +101,6 @@ d-md {
|
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
-
/* Preset width auto for responsive images (for Astro <Picture/>) */
|
|
105
|
-
:where(img[sizes], source[sizes] + img) {
|
|
106
|
-
width: auto;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
104
|
/* Fix Safari issue related to <summary> / <details> arrow */
|
|
110
105
|
details > summary.list-none::-webkit-details-marker,
|
|
111
106
|
details > summary.list-none::marker {
|