cloudcommerce 0.7.1 → 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 +16 -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 -8
- 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 +7 -1
- 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
|
@@ -5,8 +5,6 @@ import { defineConfig } from 'astro/config';
|
|
|
5
5
|
import node from '@astrojs/node';
|
|
6
6
|
import vue from '@astrojs/vue';
|
|
7
7
|
import image from '@astrojs/image';
|
|
8
|
-
// import partytown from '@astrojs/partytown';
|
|
9
|
-
// import prefetch from '@astrojs/prefetch';
|
|
10
8
|
import UnoCSS from 'unocss/astro';
|
|
11
9
|
import AstroPWA from '@vite-pwa/astro';
|
|
12
10
|
import dictionaryDir from '@cloudcommerce/i18n/lib/dirname';
|
|
@@ -16,6 +14,8 @@ const __dirname = new URL('.', import.meta.url).pathname;
|
|
|
16
14
|
dotenv.config();
|
|
17
15
|
|
|
18
16
|
const isSSG = process.env.BUILD_OUTPUT === 'static';
|
|
17
|
+
const outDir = process.env.BUILD_OUT_DIR || (isSSG ? './dist/client' : './dist');
|
|
18
|
+
const isToServerless = !isSSG && process.env.DEPLOY_RUNTIME === 'serverless';
|
|
19
19
|
const deployRand = process.env.DEPLOY_RAND || '_';
|
|
20
20
|
|
|
21
21
|
const {
|
|
@@ -136,17 +136,27 @@ const _vitePWAOptions = {
|
|
|
136
136
|
},
|
|
137
137
|
};
|
|
138
138
|
|
|
139
|
+
const viteAlias = [];
|
|
140
|
+
if (isToServerless) {
|
|
141
|
+
viteAlias.push({
|
|
142
|
+
find: '@@sf/components/Picture.astro',
|
|
143
|
+
replacement: joinPath(__dirname, 'src/serverless/Picture.runtime.astro'),
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
viteAlias.push(
|
|
147
|
+
{ find: '@@i18n', replacement: `@cloudcommerce/i18n/src/${lang}.ts` },
|
|
148
|
+
{ find: '@@sf', replacement: joinPath(__dirname, 'src/lib') },
|
|
149
|
+
{ find: '~', replacement: joinPath(process.cwd(), 'src') },
|
|
150
|
+
{ find: 'content', replacement: joinPath(process.cwd(), 'content') },
|
|
151
|
+
{ find: '/img', replacement: joinPath(process.cwd(), 'public/img') },
|
|
152
|
+
{ find: '/assets', replacement: joinPath(process.cwd(), 'public/assets') },
|
|
153
|
+
);
|
|
154
|
+
|
|
139
155
|
const genAstroConfig = ({
|
|
140
156
|
site = `https://${domain}`,
|
|
141
157
|
vitePWAOptions = _vitePWAOptions,
|
|
142
|
-
} = {}) =>
|
|
143
|
-
|
|
144
|
-
adapter: isSSG ? undefined : node({
|
|
145
|
-
mode: 'middleware',
|
|
146
|
-
}),
|
|
147
|
-
outDir: process.env.BUILD_OUT_DIR || (isSSG ? './dist/client' : './dist'),
|
|
148
|
-
integrations: [
|
|
149
|
-
image(),
|
|
158
|
+
} = {}) => {
|
|
159
|
+
const integrations = [
|
|
150
160
|
vue({
|
|
151
161
|
appEntrypoint: '/src/pages/_vue',
|
|
152
162
|
template: {
|
|
@@ -155,49 +165,53 @@ const genAstroConfig = ({
|
|
|
155
165
|
},
|
|
156
166
|
},
|
|
157
167
|
}),
|
|
158
|
-
// partytown(),
|
|
159
|
-
// prefetch(),
|
|
160
168
|
UnoCSS({
|
|
161
169
|
injectReset: false,
|
|
162
170
|
injectEntry: false,
|
|
163
171
|
}),
|
|
164
172
|
AstroPWA(vitePWAOptions),
|
|
165
|
-
]
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
173
|
+
];
|
|
174
|
+
if (!isToServerless) {
|
|
175
|
+
integrations.push(image({
|
|
176
|
+
serviceEntryPoint: '@astrojs/image/sharp',
|
|
177
|
+
}));
|
|
178
|
+
}
|
|
179
|
+
return {
|
|
180
|
+
output: isSSG ? 'static' : 'server',
|
|
181
|
+
adapter: isSSG ? undefined : node({
|
|
182
|
+
mode: 'middleware',
|
|
183
|
+
}),
|
|
184
|
+
outDir,
|
|
185
|
+
integrations,
|
|
186
|
+
site,
|
|
187
|
+
vite: {
|
|
188
|
+
plugins: [
|
|
189
|
+
{
|
|
190
|
+
name: 'vue-i18n',
|
|
191
|
+
transform(code, id) {
|
|
192
|
+
if (!/\.vue$/.test(id)) {
|
|
193
|
+
return;
|
|
183
194
|
}
|
|
184
|
-
|
|
195
|
+
// eslint-disable-next-line consistent-return
|
|
196
|
+
return code.replace(/\$t\.i19([a-z][\w$]+)/g, (match, p1) => {
|
|
197
|
+
try {
|
|
198
|
+
const text = readFileSync(joinPath(dictionaryDir, lang, `i19${p1}.txt`));
|
|
199
|
+
return `'${text}'`;
|
|
200
|
+
} catch (e) {
|
|
201
|
+
console.error(e);
|
|
202
|
+
return match;
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
},
|
|
185
206
|
},
|
|
186
|
-
},
|
|
187
|
-
],
|
|
188
|
-
resolve: {
|
|
189
|
-
preserveSymlinks: lstatSync(joinPath(process.cwd(), 'src/components')).isSymbolicLink(),
|
|
190
|
-
alias: [
|
|
191
|
-
{ find: '@@i18n', replacement: `@cloudcommerce/i18n/src/${lang}.ts` },
|
|
192
|
-
{ find: '@@sf', replacement: joinPath(__dirname, 'src/lib') },
|
|
193
|
-
{ find: '~', replacement: joinPath(process.cwd(), 'src') },
|
|
194
|
-
{ find: 'content', replacement: joinPath(process.cwd(), 'content') },
|
|
195
|
-
{ find: '/img', replacement: joinPath(process.cwd(), 'public/img') },
|
|
196
|
-
{ find: '/assets', replacement: joinPath(process.cwd(), 'public/assets') },
|
|
197
207
|
],
|
|
208
|
+
resolve: {
|
|
209
|
+
preserveSymlinks: lstatSync(joinPath(process.cwd(), 'src/components')).isSymbolicLink(),
|
|
210
|
+
alias: viteAlias,
|
|
211
|
+
},
|
|
198
212
|
},
|
|
199
|
-
}
|
|
200
|
-
}
|
|
213
|
+
};
|
|
214
|
+
};
|
|
201
215
|
|
|
202
216
|
const astroConfig = genAstroConfig();
|
|
203
217
|
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import mime from 'mime';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import { fileURLToPath } from 'node:url';
|
|
2
|
+
import sharp$1 from 'sharp';
|
|
3
|
+
import 'kleur/colors';
|
|
4
|
+
import 'node:fs/promises';
|
|
6
5
|
import { resolve, join } from 'node:path';
|
|
6
|
+
import 'node:url';
|
|
7
7
|
import 'http-cache-semantics';
|
|
8
8
|
import 'node:os';
|
|
9
|
+
import sizeOf from 'image-size';
|
|
9
10
|
import 'magic-string';
|
|
10
11
|
import 'node:stream';
|
|
11
12
|
import { c as createAstro, a as createComponent, r as renderTemplate, b as addAttribute, d as renderComponent, u as unescapeHTML, F as Fragment, m as maybeRenderHead, e as renderSlot, f as renderHead, s as spreadAttributes } from '../astro.9781c0a7.mjs';
|
|
@@ -14,7 +15,7 @@ import { reactive, computed, defineComponent, inject, useSSRContext, mergeProps,
|
|
|
14
15
|
import { img, price, formatMoney, nickname, onPromotion } from '@ecomplus/utils';
|
|
15
16
|
import { ssrRenderAttrs, ssrRenderSlot, ssrRenderClass, ssrRenderVNode, ssrRenderComponent, ssrRenderStyle, ssrRenderList, ssrIncludeBooleanAttr, ssrRenderAttr, ssrRenderTeleport, ssrInterpolate } from 'vue/server-renderer';
|
|
16
17
|
/* empty css */import { EventEmitter } from 'node:events';
|
|
17
|
-
import fs
|
|
18
|
+
import fs, { readFileSync } from 'node:fs';
|
|
18
19
|
import config from '@cloudcommerce/config';
|
|
19
20
|
/* empty css */import { resolve as resolve$1 } from 'path';
|
|
20
21
|
import { useScroll, useElementHover, useDebounceFn, useTimeout, promiseTimeout } from '@vueuse/core';
|
|
@@ -28,85 +29,12 @@ const _export_sfc = (sfc, props) => {
|
|
|
28
29
|
return target;
|
|
29
30
|
};
|
|
30
31
|
|
|
31
|
-
const PREFIX = "@astrojs/image";
|
|
32
|
-
const dateTimeFormat = new Intl.DateTimeFormat([], {
|
|
33
|
-
hour: "2-digit",
|
|
34
|
-
minute: "2-digit",
|
|
35
|
-
second: "2-digit"
|
|
36
|
-
});
|
|
37
|
-
const levels = {
|
|
38
|
-
debug: 20,
|
|
39
|
-
info: 30,
|
|
40
|
-
warn: 40,
|
|
41
|
-
error: 50,
|
|
42
|
-
silent: 90
|
|
43
|
-
};
|
|
44
|
-
function getPrefix(level, timestamp) {
|
|
45
|
-
let prefix = "";
|
|
46
|
-
if (timestamp) {
|
|
47
|
-
prefix += dim(dateTimeFormat.format(new Date()) + " ");
|
|
48
|
-
}
|
|
49
|
-
switch (level) {
|
|
50
|
-
case "debug":
|
|
51
|
-
prefix += bold(green(`[${PREFIX}] `));
|
|
52
|
-
break;
|
|
53
|
-
case "info":
|
|
54
|
-
prefix += bold(cyan(`[${PREFIX}] `));
|
|
55
|
-
break;
|
|
56
|
-
case "warn":
|
|
57
|
-
prefix += bold(yellow(`[${PREFIX}] `));
|
|
58
|
-
break;
|
|
59
|
-
case "error":
|
|
60
|
-
prefix += bold(red(`[${PREFIX}] `));
|
|
61
|
-
break;
|
|
62
|
-
}
|
|
63
|
-
return prefix;
|
|
64
|
-
}
|
|
65
|
-
const log = (_level, dest) => ({ message, level, prefix = true, timestamp = true }) => {
|
|
66
|
-
if (levels[_level] >= levels[level]) {
|
|
67
|
-
dest(`${prefix ? getPrefix(level, timestamp) : ""}${message}`);
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
const error = log("error", console.error);
|
|
71
|
-
|
|
72
|
-
async function metadata(src, data) {
|
|
73
|
-
const file = data || await fs.readFile(src);
|
|
74
|
-
const { width, height, type, orientation } = await sizeOf(file);
|
|
75
|
-
const isPortrait = (orientation || 0) >= 5;
|
|
76
|
-
if (!width || !height || !type) {
|
|
77
|
-
return void 0;
|
|
78
|
-
}
|
|
79
|
-
return {
|
|
80
|
-
src: fileURLToPath(src),
|
|
81
|
-
width: isPortrait ? height : width,
|
|
82
|
-
height: isPortrait ? width : height,
|
|
83
|
-
format: type,
|
|
84
|
-
orientation
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
function isRemoteImage$1(src) {
|
|
89
|
-
return /^(https?:)?\/\//.test(src);
|
|
90
|
-
}
|
|
91
|
-
function removeQueryString(src) {
|
|
92
|
-
const index = src.lastIndexOf("?");
|
|
93
|
-
return index > 0 ? src.substring(0, index) : src;
|
|
94
|
-
}
|
|
95
|
-
function extname(src) {
|
|
96
|
-
const base = basename(src);
|
|
97
|
-
const index = base.lastIndexOf(".");
|
|
98
|
-
if (index <= 0) {
|
|
99
|
-
return "";
|
|
100
|
-
}
|
|
101
|
-
return base.substring(index);
|
|
102
|
-
}
|
|
103
|
-
function basename(src) {
|
|
104
|
-
return removeQueryString(src.replace(/^.*[\\\/]/, ""));
|
|
105
|
-
}
|
|
106
|
-
|
|
107
32
|
function isOutputFormat(value) {
|
|
108
33
|
return ["avif", "jpeg", "jpg", "png", "webp", "svg"].includes(value);
|
|
109
34
|
}
|
|
35
|
+
function isOutputFormatSupportsAlpha(value) {
|
|
36
|
+
return ["avif", "png", "webp"].includes(value);
|
|
37
|
+
}
|
|
110
38
|
function isAspectRatioString(value) {
|
|
111
39
|
return /^\d*:\d*$/.test(value);
|
|
112
40
|
}
|
|
@@ -203,60 +131,7 @@ class BaseSSRService {
|
|
|
203
131
|
}
|
|
204
132
|
}
|
|
205
133
|
|
|
206
|
-
|
|
207
|
-
class SquooshService extends BaseSSRService {
|
|
208
|
-
async processAvif(image, transform) {
|
|
209
|
-
const encodeOptions = transform.quality ? { avif: { quality: transform.quality } } : { avif: {} };
|
|
210
|
-
await image.encode(encodeOptions);
|
|
211
|
-
const data = await image.encodedWith.avif;
|
|
212
|
-
return {
|
|
213
|
-
data: data.binary,
|
|
214
|
-
format: "avif"
|
|
215
|
-
};
|
|
216
|
-
}
|
|
217
|
-
async processJpeg(image, transform) {
|
|
218
|
-
const encodeOptions = transform.quality ? { mozjpeg: { quality: transform.quality } } : { mozjpeg: {} };
|
|
219
|
-
await image.encode(encodeOptions);
|
|
220
|
-
const data = await image.encodedWith.mozjpeg;
|
|
221
|
-
return {
|
|
222
|
-
data: data.binary,
|
|
223
|
-
format: "jpeg"
|
|
224
|
-
};
|
|
225
|
-
}
|
|
226
|
-
async processPng(image, transform) {
|
|
227
|
-
await image.encode({ oxipng: {} });
|
|
228
|
-
const data = await image.encodedWith.oxipng;
|
|
229
|
-
return {
|
|
230
|
-
data: data.binary,
|
|
231
|
-
format: "png"
|
|
232
|
-
};
|
|
233
|
-
}
|
|
234
|
-
async processWebp(image, transform) {
|
|
235
|
-
const encodeOptions = transform.quality ? { webp: { quality: transform.quality } } : { webp: {} };
|
|
236
|
-
await image.encode(encodeOptions);
|
|
237
|
-
const data = await image.encodedWith.webp;
|
|
238
|
-
return {
|
|
239
|
-
data: data.binary,
|
|
240
|
-
format: "webp"
|
|
241
|
-
};
|
|
242
|
-
}
|
|
243
|
-
async autorotate(transform, inputBuffer) {
|
|
244
|
-
try {
|
|
245
|
-
const meta = await metadata(transform.src, inputBuffer);
|
|
246
|
-
switch (meta == null ? void 0 : meta.orientation) {
|
|
247
|
-
case 3:
|
|
248
|
-
case 4:
|
|
249
|
-
return { type: "rotate", numRotations: 2 };
|
|
250
|
-
case 5:
|
|
251
|
-
case 6:
|
|
252
|
-
return { type: "rotate", numRotations: 1 };
|
|
253
|
-
case 7:
|
|
254
|
-
case 8:
|
|
255
|
-
return { type: "rotate", numRotations: 3 };
|
|
256
|
-
}
|
|
257
|
-
} catch {
|
|
258
|
-
}
|
|
259
|
-
}
|
|
134
|
+
class SharpService extends BaseSSRService {
|
|
260
135
|
async transform(inputBuffer, transform) {
|
|
261
136
|
if (transform.format === "svg") {
|
|
262
137
|
return {
|
|
@@ -264,46 +139,38 @@ class SquooshService extends BaseSSRService {
|
|
|
264
139
|
format: transform.format
|
|
265
140
|
};
|
|
266
141
|
}
|
|
267
|
-
const
|
|
268
|
-
|
|
269
|
-
const autorotate = await this.autorotate(transform, inputBuffer);
|
|
270
|
-
if (autorotate) {
|
|
271
|
-
operations.push(autorotate);
|
|
272
|
-
}
|
|
273
|
-
} else if (transform.src.startsWith("//")) {
|
|
274
|
-
transform.src = `https:${transform.src}`;
|
|
275
|
-
}
|
|
142
|
+
const sharpImage = sharp$1(inputBuffer, { failOnError: false, pages: -1 });
|
|
143
|
+
sharpImage.rotate();
|
|
276
144
|
if (transform.width || transform.height) {
|
|
277
145
|
const width = transform.width && Math.round(transform.width);
|
|
278
146
|
const height = transform.height && Math.round(transform.height);
|
|
279
|
-
|
|
280
|
-
type: "resize",
|
|
147
|
+
sharpImage.resize({
|
|
281
148
|
width,
|
|
282
|
-
height
|
|
149
|
+
height,
|
|
150
|
+
fit: transform.fit,
|
|
151
|
+
position: transform.position,
|
|
152
|
+
background: transform.background
|
|
283
153
|
});
|
|
284
154
|
}
|
|
285
|
-
if (
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
});
|
|
291
|
-
throw new Error(`Unknown image output: "${transform.format}" used for ${transform.src}`);
|
|
155
|
+
if (transform.format) {
|
|
156
|
+
sharpImage.toFormat(transform.format, { quality: transform.quality });
|
|
157
|
+
if (transform.background && !isOutputFormatSupportsAlpha(transform.format)) {
|
|
158
|
+
sharpImage.flatten({ background: transform.background });
|
|
159
|
+
}
|
|
292
160
|
}
|
|
293
|
-
const {
|
|
294
|
-
const data = await processBuffer(inputBuffer, operations, transform.format, transform.quality);
|
|
161
|
+
const { data, info } = await sharpImage.toBuffer({ resolveWithObject: true });
|
|
295
162
|
return {
|
|
296
|
-
data
|
|
297
|
-
format:
|
|
163
|
+
data,
|
|
164
|
+
format: info.format
|
|
298
165
|
};
|
|
299
166
|
}
|
|
300
167
|
}
|
|
301
|
-
const service = new
|
|
302
|
-
var
|
|
168
|
+
const service = new SharpService();
|
|
169
|
+
var sharp_default = service;
|
|
303
170
|
|
|
304
|
-
const
|
|
171
|
+
const sharp = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
|
|
305
172
|
__proto__: null,
|
|
306
|
-
default:
|
|
173
|
+
default: sharp_default
|
|
307
174
|
}, Symbol.toStringTag, { value: 'Module' }));
|
|
308
175
|
|
|
309
176
|
const fnv1a52 = (str) => {
|
|
@@ -331,7 +198,7 @@ const etag = (payload, weak = false) => {
|
|
|
331
198
|
return prefix + fnv1a52(payload).toString(36) + payload.length.toString(36) + '"';
|
|
332
199
|
};
|
|
333
200
|
|
|
334
|
-
function isRemoteImage(src) {
|
|
201
|
+
function isRemoteImage$1(src) {
|
|
335
202
|
return /^(https?:)?\/\//.test(src);
|
|
336
203
|
}
|
|
337
204
|
|
|
@@ -350,14 +217,14 @@ async function loadRemoteImage(src) {
|
|
|
350
217
|
const get = async ({ request }) => {
|
|
351
218
|
try {
|
|
352
219
|
const url = new URL(request.url);
|
|
353
|
-
const transform =
|
|
220
|
+
const transform = sharp_default.parseTransform(url.searchParams);
|
|
354
221
|
let inputBuffer = void 0;
|
|
355
|
-
const sourceUrl = isRemoteImage(transform.src) ? new URL(transform.src) : new URL(transform.src, url.origin);
|
|
222
|
+
const sourceUrl = isRemoteImage$1(transform.src) ? new URL(transform.src) : new URL(transform.src, url.origin);
|
|
356
223
|
inputBuffer = await loadRemoteImage(sourceUrl);
|
|
357
224
|
if (!inputBuffer) {
|
|
358
225
|
return new Response("Not Found", { status: 404 });
|
|
359
226
|
}
|
|
360
|
-
const { data, format } = await
|
|
227
|
+
const { data, format } = await sharp_default.transform(inputBuffer, transform);
|
|
361
228
|
return new Response(data, {
|
|
362
229
|
status: 200,
|
|
363
230
|
headers: {
|
|
@@ -396,15 +263,15 @@ const getCMS = () => {
|
|
|
396
263
|
if (filename.endsWith('/')) {
|
|
397
264
|
const dirColl = resolve(dirContent, filename);
|
|
398
265
|
return new Promise((resolve) => {
|
|
399
|
-
const slugs = fs
|
|
400
|
-
? fs
|
|
266
|
+
const slugs = fs.existsSync(dirColl)
|
|
267
|
+
? fs.readdirSync(dirColl).map((file) => file.replace('.json', ''))
|
|
401
268
|
: [];
|
|
402
269
|
resolve(slugs);
|
|
403
270
|
});
|
|
404
271
|
}
|
|
405
272
|
const filepath = resolve(dirContent, `${filename}.json`);
|
|
406
|
-
const content = fs
|
|
407
|
-
? JSON.parse(fs
|
|
273
|
+
const content = fs.existsSync(filepath)
|
|
274
|
+
? JSON.parse(fs.readFileSync(filepath, 'utf8'))
|
|
408
275
|
: null;
|
|
409
276
|
return filename === 'settings'
|
|
410
277
|
? content
|
|
@@ -782,6 +649,25 @@ const $$Base = createComponent(async ($$result, $$props, $$slots) => {
|
|
|
782
649
|
return renderTemplate`${renderComponent($$result, "Base", $$Base$1, { "pageContext": pageContext, "title": title }, { "before-head-end": ($$result2) => renderTemplate`${renderComponent($$result2, "InlineScripts", $$InlineScripts, { "slot": "before-head-end" })}`, "default": ($$result2) => renderTemplate`${renderSlot($$result2, $$slots["default"])}` })}`;
|
|
783
650
|
}, "/home/leo/code/ecomplus/cloud-commerce/packages/storefront/src/layouts/Base.astro");
|
|
784
651
|
|
|
652
|
+
function isRemoteImage(src) {
|
|
653
|
+
return /^(https?:)?\/\//.test(src);
|
|
654
|
+
}
|
|
655
|
+
function removeQueryString(src) {
|
|
656
|
+
const index = src.lastIndexOf("?");
|
|
657
|
+
return index > 0 ? src.substring(0, index) : src;
|
|
658
|
+
}
|
|
659
|
+
function extname(src) {
|
|
660
|
+
const base = basename(src);
|
|
661
|
+
const index = base.lastIndexOf(".");
|
|
662
|
+
if (index <= 0) {
|
|
663
|
+
return "";
|
|
664
|
+
}
|
|
665
|
+
return base.substring(index);
|
|
666
|
+
}
|
|
667
|
+
function basename(src) {
|
|
668
|
+
return removeQueryString(src.replace(/^.*[\\\/]/, ""));
|
|
669
|
+
}
|
|
670
|
+
|
|
785
671
|
function resolveSize(transform) {
|
|
786
672
|
if (transform.width && transform.height) {
|
|
787
673
|
return transform;
|
|
@@ -849,7 +735,7 @@ async function getImage(transform) {
|
|
|
849
735
|
}
|
|
850
736
|
let loader = (_a = globalThis.astroImage) == null ? void 0 : _a.loader;
|
|
851
737
|
if (!loader) {
|
|
852
|
-
const { default: mod } = await Promise.resolve().then(() =>
|
|
738
|
+
const { default: mod } = await Promise.resolve().then(() => sharp).catch(() => {
|
|
853
739
|
throw new Error(
|
|
854
740
|
"[@astrojs/image] Builtin image loader not found. (Did you remember to add the integration to your Astro config?)"
|
|
855
741
|
);
|
|
@@ -861,7 +747,7 @@ async function getImage(transform) {
|
|
|
861
747
|
const resolved = await resolveTransform(transform);
|
|
862
748
|
const attributes = await loader.getImageAttributes(resolved);
|
|
863
749
|
const isDev = (_b = (Object.assign({"BASE_URL":"/","MODE":"production","DEV":false,"PROD":true,"SSR":true,"SITE":"\"https://ecom2-002.web.app\""},{SSR:true,}))) == null ? void 0 : _b.DEV;
|
|
864
|
-
const isLocalImage = !isRemoteImage
|
|
750
|
+
const isLocalImage = !isRemoteImage(resolved.src);
|
|
865
751
|
const _loader = isDev && isLocalImage ? globalThis.astroImage.defaultLoader : loader;
|
|
866
752
|
if (!_loader) {
|
|
867
753
|
throw new Error("@astrojs/image: loader not found!");
|
|
@@ -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.d97031a1.mjs';
|
|
18
18
|
import 'mime';
|
|
19
19
|
import 'cookie';
|
|
20
20
|
import 'kleur/colors';
|
|
@@ -23,12 +23,13 @@ import 'path-to-regexp';
|
|
|
23
23
|
import 'tls';
|
|
24
24
|
import 'string-width';
|
|
25
25
|
import 'html-escaper';
|
|
26
|
-
import '
|
|
26
|
+
import 'sharp';
|
|
27
27
|
import 'node:fs/promises';
|
|
28
|
-
import 'node:url';
|
|
29
28
|
import 'node:path';
|
|
29
|
+
import 'node:url';
|
|
30
30
|
import 'http-cache-semantics';
|
|
31
31
|
import 'node:os';
|
|
32
|
+
import 'image-size';
|
|
32
33
|
import 'magic-string';
|
|
33
34
|
import 'node:stream';
|
|
34
35
|
import '@cloudcommerce/api';
|
|
@@ -3058,10 +3059,10 @@ const _renderer1 = {
|
|
|
3058
3059
|
renderToStaticMarkup,
|
|
3059
3060
|
};
|
|
3060
3061
|
|
|
3061
|
-
const pageMap = new Map([["../../node_modules/.pnpm/@astrojs+image@0.16.0_astro@2.1.2/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],]);
|
|
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],]);
|
|
3062
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 }),];
|
|
3063
3064
|
|
|
3064
|
-
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/node_modules/@astrojs/image/dist/endpoint.js","pathname":"/_image","prerender":false,"_meta":{"trailingSlash":"ignore"}}},{"file":"","links":["_astro/_...slug_.0607a6ef.css","_astro/index.0c833781.css"],"scripts":[{"type":"external","value":"_astro/hoisted.721ad75d.js"}],"routeData":{"route":"/","type":"page","pattern":"^\\/$","segments":[],"params":[],"component":"src/pages/index.astro","pathname":"/","prerender":false,"_meta":{"trailingSlash":"ignore"}}},{"file":"","links":["_astro/_...slug_.0607a6ef.css"],"scripts":[{"type":"external","value":"_astro/hoisted.721ad75d.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_.0607a6ef.css"],"scripts":[{"type":"external","value":"_astro/hoisted.721ad75d.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","
|
|
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_.0607a6ef.css","_astro/index.0c833781.css"],"scripts":[{"type":"external","value":"_astro/hoisted.721ad75d.js"}],"routeData":{"route":"/","type":"page","pattern":"^\\/$","segments":[],"params":[],"component":"src/pages/index.astro","pathname":"/","prerender":false,"_meta":{"trailingSlash":"ignore"}}},{"file":"","links":["_astro/_...slug_.0607a6ef.css"],"scripts":[{"type":"external","value":"_astro/hoisted.721ad75d.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_.0607a6ef.css"],"scripts":[{"type":"external","value":"_astro/hoisted.721ad75d.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","@astrojs/vue/client.js":"_astro/client.0de2f274.js","~/components/PitchBar.vue":"_astro/PitchBar.db7cd775.js","~/components/Prices.vue":"_astro/Prices.55399c72.js","/astro/hoisted.js?q=0":"_astro/hoisted.721ad75d.js","/home/leo/code/ecomplus/cloud-commerce/node_modules/workbox-window/build/workbox-window.prod.es5.mjs":"_astro/workbox-window.prod.es5.295a6886.js","~/components/ShopHeader.vue":"_astro/ShopHeader.e93c8274.js","/home/leo/code/ecomplus/cloud-commerce/packages/storefront/src/lib/scripts/firebase-app.ts":"_astro/firebase-app.72e91a3e.js","astro:scripts/before-hydration.js":""},"assets":["/_astro/index.0c833781.css","/_astro/server.1bc2fa51.css","/_astro/_...slug_.0607a6ef.css","/manifest.webmanifest","/robots.txt","/sw.js","/workbox-e0d788d4.js","/_astro/PitchBar.db7cd775.js","/_astro/Prices.55399c72.js","/_astro/ProductCard.7e891c08.js","/_astro/ShopHeader.e93c8274.js","/_astro/_plugin-vue_export-helper.77ed7c18.js","/_astro/client.0de2f274.js","/_astro/firebase-app.72e91a3e.js","/_astro/format-money.ab6b71eb.js","/_astro/hoisted.721ad75d.js","/_astro/idle-callback.889bf0ea.js","/_astro/index.16f33784.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.295a6886.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"]}), {
|
|
3065
3066
|
pageMap: pageMap,
|
|
3066
3067
|
renderers: renderers
|
|
3067
3068
|
});
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudcommerce/storefront",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.8.0",
|
|
5
5
|
"description": "E-Com Plus Cloud Commerce storefront with Astro",
|
|
6
|
+
"bin": {
|
|
7
|
+
"storefront": "./scripts/build-prod.sh"
|
|
8
|
+
},
|
|
6
9
|
"main": "src/index.js",
|
|
7
10
|
"repository": {
|
|
8
11
|
"type": "git",
|
|
@@ -20,16 +23,15 @@
|
|
|
20
23
|
"start": "astro dev --host",
|
|
21
24
|
"build": "astro build",
|
|
22
25
|
"build:static": "BUILD_OUTPUT=static astro build",
|
|
26
|
+
"build:prod": "sh scripts/build-prod.sh",
|
|
23
27
|
"preview": "astro preview",
|
|
24
28
|
"astro": "astro",
|
|
25
29
|
"prepare-monorepo": "sh scripts/prepare-monorepo.sh"
|
|
26
30
|
},
|
|
27
31
|
"dependencies": {
|
|
28
|
-
"@astrojs/image": "
|
|
29
|
-
"@astrojs/node": "
|
|
30
|
-
"@astrojs/
|
|
31
|
-
"@astrojs/prefetch": "^0.2.0",
|
|
32
|
-
"@astrojs/vue": "^2.1.0",
|
|
32
|
+
"@astrojs/image": "0.16.0",
|
|
33
|
+
"@astrojs/node": "5.1.0",
|
|
34
|
+
"@astrojs/vue": "2.1.0",
|
|
33
35
|
"@cloudcommerce/api": "workspace:*",
|
|
34
36
|
"@cloudcommerce/config": "workspace:*",
|
|
35
37
|
"@cloudcommerce/i18n": "workspace:*",
|
|
@@ -41,12 +43,14 @@
|
|
|
41
43
|
"@iconify-json/logos": "^1.1.23",
|
|
42
44
|
"@vite-pwa/astro": "^0.0.5",
|
|
43
45
|
"@vueuse/core": "9.12.0",
|
|
44
|
-
"astro": "
|
|
46
|
+
"astro": "2.1.2",
|
|
45
47
|
"chroma-js": "^2.4.2",
|
|
46
48
|
"dotenv": "^16.0.3",
|
|
47
49
|
"firebase": "^9.17.2",
|
|
48
50
|
"image-size": "^1.0.2",
|
|
51
|
+
"mime": "^3.0.0",
|
|
49
52
|
"semver": "^7.3.8",
|
|
53
|
+
"sharp": "^0.31.3",
|
|
50
54
|
"tailwindcss": "^3.2.7",
|
|
51
55
|
"unocss": "^0.50.4",
|
|
52
56
|
"vite": "^4.1.4",
|
|
@@ -1,7 +1,19 @@
|
|
|
1
1
|
#!/bin/bash
|
|
2
2
|
|
|
3
3
|
BUILD_OUTPUT=static BUILD_OUT_DIR=./.cloudcommerce/sf-tmp-dist npx astro build
|
|
4
|
-
npx astro build
|
|
4
|
+
DEPLOY_RUNTIME=serverless npx astro build
|
|
5
|
+
|
|
5
6
|
mv ./.cloudcommerce/sf-tmp-dist/_astro/*.{webp,avif} ./dist/client/_astro/
|
|
6
7
|
rm -rf ./.cloudcommerce/sf-tmp-dist
|
|
7
|
-
|
|
8
|
+
|
|
9
|
+
identify -format "%f,%w,%h\n" \
|
|
10
|
+
./dist/client/_astro/*.{webp,avif} > ./dist/server/images.dist.csv
|
|
11
|
+
|
|
12
|
+
identify -format "assets/%f,%w,%h\n" \
|
|
13
|
+
./public/assets/*.{png,jpg,jpeg,gif,ico,webp,avif} > ./dist/server/images.src.csv 2>/dev/null
|
|
14
|
+
identify -format "img/%f,%w,%h\n" \
|
|
15
|
+
./public/img/*.{png,jpg,jpeg,gif,ico,webp,avif} >> ./dist/server/images.src.csv 2>/dev/null
|
|
16
|
+
identify -format "img/uploads/%f,%w,%h\n" \
|
|
17
|
+
./public/img/uploads/*.{png,jpg,jpeg,gif,ico,webp,avif} >> ./dist/server/images.src.csv 2>/dev/null
|
|
18
|
+
|
|
19
|
+
exit 0
|
|
@@ -1,16 +1,11 @@
|
|
|
1
1
|
---
|
|
2
|
-
import type {
|
|
3
|
-
PictureComponentLocalImageProps,
|
|
4
|
-
PictureComponentRemoteImageProps,
|
|
5
|
-
} from '@astrojs/image/components/';
|
|
2
|
+
import type { PictureComponentRemoteImageProps } from '@astrojs/image/components/';
|
|
6
3
|
import { resolve as resolvePath } from 'path';
|
|
7
4
|
import imageSize from 'image-size';
|
|
8
5
|
import { getPicture } from '@astrojs/image';
|
|
9
6
|
|
|
10
|
-
type
|
|
11
|
-
|
|
12
|
-
export type Props = Omit<PictureProps, 'aspectRatio'> & {
|
|
13
|
-
aspectRatio?: PictureProps['aspectRatio'],
|
|
7
|
+
export type Props = Omit<PictureComponentRemoteImageProps, 'aspectRatio'> & {
|
|
8
|
+
aspectRatio?: PictureComponentRemoteImageProps['aspectRatio'],
|
|
14
9
|
fetchpriority?: 'high' | 'low' | 'auto',
|
|
15
10
|
};
|
|
16
11
|
|