cloudcommerce 0.7.0 → 0.8.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/.github/renovate.json +34 -2
- package/CHANGELOG.md +23 -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 +8 -9
- package/ecomplus-stores/monocard/package.json +1 -1
- package/package.json +1 -1
- package/packages/api/package.json +1 -1
- 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 +1 -1
- 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/config/firebase.json +10 -5
- package/packages/cli/package.json +1 -1
- 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 +3 -5
- package/packages/storefront/astro.config.mjs +58 -44
- package/packages/storefront/dist/server/chunks/pages/{all.3a2f4354.mjs → all.d97031a1.mjs} +58 -172
- package/packages/storefront/dist/server/entry.mjs +6 -5
- package/packages/storefront/package.json +11 -7
- package/packages/storefront/scripts/build-prod.sh +14 -2
- package/packages/storefront/src/lib/components/Picture.astro +3 -8
- package/packages/storefront/src/serverless/Picture.runtime.astro +90 -0
- package/packages/storefront/src/serverless/get-image.ts +47 -0
- package/packages/storefront/{ssr-runtime → src/serverless}/get-picture.ts +9 -3
- package/packages/types/package.json +1 -1
- package/packages/storefront/dist/server/chunks/avif/avif_node_dec.wasm +0 -0
- package/packages/storefront/dist/server/chunks/avif/avif_node_enc.wasm +0 -0
- package/packages/storefront/dist/server/chunks/image-pool.c24d15b2.mjs +0 -10645
- package/packages/storefront/dist/server/chunks/mozjpeg/mozjpeg_node_dec.wasm +0 -0
- package/packages/storefront/dist/server/chunks/mozjpeg/mozjpeg_node_enc.wasm +0 -0
- package/packages/storefront/dist/server/chunks/png/squoosh_oxipng_bg.wasm +0 -0
- package/packages/storefront/dist/server/chunks/png/squoosh_png_bg.wasm +0 -0
- package/packages/storefront/dist/server/chunks/resize/squoosh_resize_bg.wasm +0 -0
- package/packages/storefront/dist/server/chunks/rotate/rotate.wasm +0 -0
- package/packages/storefront/dist/server/chunks/webp/webp_node_dec.wasm +0 -0
- package/packages/storefront/dist/server/chunks/webp/webp_node_enc.wasm +0 -0
- package/packages/storefront/ssr-runtime/Picture.ssr.astro +0 -0
- package/packages/storefront/ssr-runtime/get-image.ts +0 -4
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
---
|
|
2
|
+
import type { PictureComponentRemoteImageProps } from '@astrojs/image/components/';
|
|
3
|
+
import { join as joinPath } from 'node:path';
|
|
4
|
+
import { readFileSync } from 'node:fs';
|
|
5
|
+
import { getPicture } from './get-picture';
|
|
6
|
+
|
|
7
|
+
export type Props = Omit<PictureComponentRemoteImageProps, 'aspectRatio'> & {
|
|
8
|
+
aspectRatio?: PictureComponentRemoteImageProps['aspectRatio'],
|
|
9
|
+
fetchpriority?: 'high' | 'low' | 'auto',
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
type OriginalImage = { filepath: string, width: number, height: number };
|
|
13
|
+
const originalImages: OriginalImage[] = [];
|
|
14
|
+
const manifestFilepath = joinPath(process.cwd(), 'dist/server/images.src.csv');
|
|
15
|
+
readFileSync(manifestFilepath, 'utf-8').split(/\n/).forEach((line) => {
|
|
16
|
+
const [filepath, width, height] = line.split(',');
|
|
17
|
+
originalImages.push({
|
|
18
|
+
filepath,
|
|
19
|
+
width: Number(width),
|
|
20
|
+
height: Number(height),
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
const tryImageSize = (src: string) => {
|
|
25
|
+
let dimensions: { width?: number, height?: number } = {};
|
|
26
|
+
if (typeof src === 'string' && src.startsWith('/')) {
|
|
27
|
+
const originalImage = originalImages.find(({ filepath }) => {
|
|
28
|
+
return new RegExp(`^/${filepath}\\??.*`).test(src);
|
|
29
|
+
});
|
|
30
|
+
if (originalImage) {
|
|
31
|
+
const { width, height } = originalImage;
|
|
32
|
+
dimensions = { width, height };
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return dimensions;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const getAspectRatio = (src: string | { width?: number, height?: number }) => {
|
|
39
|
+
if (typeof src === 'string') {
|
|
40
|
+
src = tryImageSize(src);
|
|
41
|
+
}
|
|
42
|
+
if (src.width) {
|
|
43
|
+
return src.height ? src.width / src.height : 1;
|
|
44
|
+
}
|
|
45
|
+
return 0;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const {
|
|
49
|
+
src,
|
|
50
|
+
alt,
|
|
51
|
+
sizes,
|
|
52
|
+
widths,
|
|
53
|
+
aspectRatio: propAspectRatio,
|
|
54
|
+
fit,
|
|
55
|
+
background,
|
|
56
|
+
position,
|
|
57
|
+
formats = ['avif', 'webp'],
|
|
58
|
+
loading = 'lazy',
|
|
59
|
+
decoding = 'async',
|
|
60
|
+
...attrs
|
|
61
|
+
} = Astro.props;
|
|
62
|
+
|
|
63
|
+
let aspectRatio = propAspectRatio;
|
|
64
|
+
if ((!attrs.width || !attrs.height) && !aspectRatio && typeof src === 'string') {
|
|
65
|
+
const { width, height } = tryImageSize(src);
|
|
66
|
+
if (height) {
|
|
67
|
+
aspectRatio = getAspectRatio({ width, height });
|
|
68
|
+
attrs.width = width;
|
|
69
|
+
attrs.height = height;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const { image, sources } = await getPicture({
|
|
74
|
+
src,
|
|
75
|
+
widths,
|
|
76
|
+
formats,
|
|
77
|
+
aspectRatio,
|
|
78
|
+
fit,
|
|
79
|
+
background,
|
|
80
|
+
position,
|
|
81
|
+
alt,
|
|
82
|
+
});
|
|
83
|
+
delete image.width;
|
|
84
|
+
delete image.height;
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
<picture>
|
|
88
|
+
{sources.map((attrs) => <source {...attrs} sizes={sizes} />)}
|
|
89
|
+
<img {...image} loading={loading} decoding={decoding} {...attrs} />
|
|
90
|
+
</picture>
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { OutputFormat } from '@astrojs/image/dist/loaders/';
|
|
2
|
+
import { join as joinPath } from 'node:path';
|
|
3
|
+
import { readFileSync } from 'node:fs';
|
|
4
|
+
|
|
5
|
+
type BuiltImage = { filename: string, width: number, height: number };
|
|
6
|
+
const builtImages: BuiltImage[] = [];
|
|
7
|
+
const manifestFilepath = joinPath(process.cwd(), 'dist/server/images.dist.csv');
|
|
8
|
+
readFileSync(manifestFilepath, 'utf-8').split(/\n/).forEach((line) => {
|
|
9
|
+
const [filename, width, height] = line.split(',');
|
|
10
|
+
builtImages.push({
|
|
11
|
+
filename,
|
|
12
|
+
width: Number(width),
|
|
13
|
+
height: Number(height),
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
builtImages.sort((a, b) => {
|
|
17
|
+
if (a.width < b.width) return -1;
|
|
18
|
+
return 1;
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
type ImageOptions = Record<string, any> & {
|
|
22
|
+
src: string,
|
|
23
|
+
width: number,
|
|
24
|
+
format: OutputFormat,
|
|
25
|
+
};
|
|
26
|
+
const getImage = async ({ src, width, format }: ImageOptions) => {
|
|
27
|
+
const filename = src.replace(/^.*\//, '').replace(/.\w+(\?.*)?$/, '');
|
|
28
|
+
const matchFilename = (_builtImage: BuiltImage) => {
|
|
29
|
+
return filename === _builtImage.filename
|
|
30
|
+
.replace(new RegExp(`[_.][a-z0-9]+\\.${format}$`, 'i'), '');
|
|
31
|
+
};
|
|
32
|
+
let builtImage = builtImages.find((_builtImage) => {
|
|
33
|
+
return _builtImage.width >= width && matchFilename(_builtImage);
|
|
34
|
+
});
|
|
35
|
+
if (!builtImage) {
|
|
36
|
+
builtImage = builtImages.find(matchFilename);
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
src: `/_astro/${builtImage.filename}`,
|
|
40
|
+
width: builtImage.width,
|
|
41
|
+
height: builtImage.height,
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export default getImage;
|
|
46
|
+
|
|
47
|
+
export { getImage };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { HTMLAttributes } from 'astro/types';
|
|
2
|
-
import type { ImageMetadata } from '@astrojs/image/dist/vite-plugin-astro-image';
|
|
2
|
+
// import type { ImageMetadata } from '@astrojs/image/dist/vite-plugin-astro-image';
|
|
3
3
|
import type { OutputFormat, TransformOptions } from '@astrojs/image/dist/loaders/';
|
|
4
|
-
// eslint-disable-next-line
|
|
5
4
|
import mime from 'mime';
|
|
5
|
+
import getImage from './get-image';
|
|
6
6
|
|
|
7
7
|
function removeQueryString(src: string) {
|
|
8
8
|
const index = src.lastIndexOf('?');
|
|
@@ -36,7 +36,7 @@ function parseAspectRatio(aspectRatio: TransformOptions['aspectRatio']) {
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
export interface GetPictureParams {
|
|
39
|
-
src: string | ImageMetadata | Promise<{ default: ImageMetadata }
|
|
39
|
+
src: string /* | ImageMetadata | Promise<{ default: ImageMetadata }> */;
|
|
40
40
|
alt: string;
|
|
41
41
|
widths: number[];
|
|
42
42
|
formats: OutputFormat[];
|
|
@@ -55,8 +55,11 @@ async function resolveAspectRatio({ src, aspectRatio }: GetPictureParams) {
|
|
|
55
55
|
if (typeof src === 'string') {
|
|
56
56
|
return parseAspectRatio(aspectRatio);
|
|
57
57
|
}
|
|
58
|
+
throw new Error('Custom (faster) `Picture.ssr.astro` works only with string ("remote") src');
|
|
59
|
+
/*
|
|
58
60
|
const metadata = 'then' in src ? (await src).default : src;
|
|
59
61
|
return parseAspectRatio(aspectRatio) || metadata.width / metadata.height;
|
|
62
|
+
*/
|
|
60
63
|
}
|
|
61
64
|
|
|
62
65
|
async function resolveFormats({ src, formats }: GetPictureParams) {
|
|
@@ -64,8 +67,11 @@ async function resolveFormats({ src, formats }: GetPictureParams) {
|
|
|
64
67
|
if (typeof src === 'string') {
|
|
65
68
|
unique.add(extname(src).replace('.', '') as OutputFormat);
|
|
66
69
|
} else {
|
|
70
|
+
throw new Error('Custom `Picture.ssr.astro` works only with string src');
|
|
71
|
+
/*
|
|
67
72
|
const metadata = 'then' in src ? (await src).default : src;
|
|
68
73
|
unique.add(extname(metadata.src).replace('.', '') as OutputFormat);
|
|
74
|
+
*/
|
|
69
75
|
}
|
|
70
76
|
return Array.from(unique).filter(Boolean);
|
|
71
77
|
}
|
|
Binary file
|
|
Binary file
|