cloudcommerce 0.0.80 → 0.0.82
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 +19 -0
- package/package.json +1 -1
- package/packages/api/package.json +1 -1
- package/packages/apps/correios/package.json +1 -1
- package/packages/apps/custom-shipping/package.json +1 -1
- package/packages/apps/discounts/package.json +1 -1
- package/packages/apps/frenet/package.json +1 -1
- package/packages/apps/tiny-erp/package.json +1 -1
- package/packages/cli/package.json +1 -1
- package/packages/config/package.json +1 -1
- package/packages/events/package.json +1 -1
- package/packages/firebase/package.json +1 -1
- package/packages/modules/package.json +1 -1
- package/packages/passport/package.json +1 -1
- package/packages/ssr/lib/firebase/serve-storefront.js +22 -40
- package/packages/ssr/lib/firebase/serve-storefront.js.map +1 -1
- package/packages/ssr/package.json +2 -1
- package/packages/ssr/src/firebase/serve-storefront.ts +27 -59
- package/packages/storefront/astro.config.mjs +4 -0
- package/packages/storefront/dist/client/hoisted.f0efb207.js +272 -0
- package/packages/storefront/dist/client/manifest.webmanifest +1 -0
- package/packages/storefront/dist/client/sw.js +1 -0
- package/packages/storefront/dist/client/workbox-70b8fbb9.js +1 -0
- package/packages/storefront/dist/server/entry.mjs +10 -2
- package/packages/storefront/dist/server/manifest.webmanifest +1 -0
- package/packages/storefront/dist/server/registerSW.js +1 -0
- package/packages/storefront/package.json +1 -1
- package/packages/storefront/src/lib/components/LoginModal.vue +0 -1
- package/packages/storefront/src/lib/layouts/Base.astro +8 -0
- package/packages/storefront/src/lib/ssr-context.ts +1 -1
- package/packages/storefront/src/vite-env.d.ts +13 -0
- package/packages/types/package.json +1 -1
- package/packages/storefront/dist/client/hoisted.31e23ac0.js +0 -271
- package/packages/storefront/src/assets/firebaseui.css +0 -648
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,25 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [0.0.82](https://github.com/ecomplus/cloud-commerce/compare/v0.0.81...v0.0.82) (2022-09-17)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* **storefront:** Trying basic PWA setup with `vite-plugin-pwa` ([5ddab09](https://github.com/ecomplus/cloud-commerce/commit/5ddab09679d979e4cd52fc0ba1c8e9845178e521))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* **storefront:** Add `must-revalidate` cache control to prevent browsers using stale ([bdaca35](https://github.com/ecomplus/cloud-commerce/commit/bdaca3548a8709590368565735c4cf02e20b2d5c))
|
|
16
|
+
|
|
17
|
+
### [0.0.81](https://github.com/ecomplus/cloud-commerce/compare/v0.0.80...v0.0.81) (2022-09-16)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
* **ssr:** Use `compression` pkg (middleware) to gzip ([714c8b3](https://github.com/ecomplus/cloud-commerce/commit/714c8b3f502082a6a395b40e7a792540cd9af861))
|
|
23
|
+
|
|
5
24
|
### [0.0.80](https://github.com/ecomplus/cloud-commerce/compare/v0.0.79...v0.0.80) (2022-09-16)
|
|
6
25
|
|
|
7
26
|
### [0.0.79](https://github.com/ecomplus/cloud-commerce/compare/v0.0.78...v0.0.79) (2022-09-16)
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cloudcommerce",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.82",
|
|
5
5
|
"description": "Open fair-code headless commerce platform: API-first, microservices based, event driven and cloud native",
|
|
6
6
|
"main": "packages/api/lib/index.js",
|
|
7
7
|
"author": "E-Com Club Softwares para E-commerce <ti@e-com.club>",
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import { join as joinPath } from 'path';
|
|
2
2
|
import { readFile } from 'fs/promises';
|
|
3
|
-
import
|
|
4
|
-
import logger from 'firebase-functions/lib/logger';
|
|
3
|
+
import compression from 'compression';
|
|
5
4
|
|
|
6
5
|
const { STOREFRONT_BASE_DIR } = process.env;
|
|
7
6
|
const baseDir = STOREFRONT_BASE_DIR || process.cwd();
|
|
8
7
|
const clientRoot = new URL(joinPath(baseDir, 'dist/client/'), import.meta.url);
|
|
8
|
+
const compress = compression();
|
|
9
9
|
|
|
10
10
|
export default (req, res) => {
|
|
11
|
-
logger.info('Serving storefront');
|
|
12
11
|
const url = req.url.replace(/\?.*$/, '').replace(/\.html$/, '');
|
|
13
12
|
const setStatusAndCache = (status, defaultCache) => {
|
|
14
|
-
return res.status(status)
|
|
13
|
+
return res.status(status)
|
|
14
|
+
.set('X-SSR-ID', `v1/${Date.now()}`)
|
|
15
|
+
.set('Cache-Control', (typeof global.cache_control === 'function' && global.cache_control(status))
|
|
15
16
|
|| defaultCache);
|
|
16
17
|
};
|
|
17
18
|
const fallback = (err, status = 500) => {
|
|
@@ -26,46 +27,27 @@ export default (req, res) => {
|
|
|
26
27
|
.send(err.toString());
|
|
27
28
|
}
|
|
28
29
|
};
|
|
29
|
-
res
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
return res.WRITEHEAD(statusCode, headers);
|
|
37
|
-
};
|
|
38
|
-
res.WRITE = res.write;
|
|
39
|
-
res.write = (chunk) => {
|
|
40
|
-
gzip(chunk, (err, data) => {
|
|
30
|
+
compress(req, res, async () => {
|
|
31
|
+
/*
|
|
32
|
+
https://github.com/withastro/astro/blob/main/examples/ssr/server/server.mjs
|
|
33
|
+
import { handler as ssrHandler } from '../dist/server/entry.mjs';
|
|
34
|
+
global.ssr_handler = ssrHandler;
|
|
35
|
+
*/
|
|
36
|
+
global.ssr_handler(req, res, async (err) => {
|
|
41
37
|
if (err) {
|
|
42
|
-
|
|
38
|
+
res.set('X-SSR-Error', err.message);
|
|
43
39
|
fallback(err);
|
|
44
|
-
|
|
45
|
-
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
const local = new URL(`.${url}`, clientRoot);
|
|
43
|
+
try {
|
|
44
|
+
const data = await readFile(local);
|
|
45
|
+
setStatusAndCache(200, 'public, max-age=60, s-maxage=600')
|
|
46
|
+
.send(data);
|
|
47
|
+
} catch {
|
|
48
|
+
fallback(err, 404);
|
|
46
49
|
}
|
|
47
50
|
});
|
|
48
|
-
return true;
|
|
49
|
-
};
|
|
50
|
-
/*
|
|
51
|
-
https://github.com/withastro/astro/blob/main/examples/ssr/server/server.mjs
|
|
52
|
-
import { handler as ssrHandler } from '../dist/server/entry.mjs';
|
|
53
|
-
global.ssr_handler = ssrHandler;
|
|
54
|
-
*/
|
|
55
|
-
global.ssr_handler(req, res, async (err) => {
|
|
56
|
-
if (err) {
|
|
57
|
-
res.set('X-SSR-Error', err.message);
|
|
58
|
-
fallback(err);
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
const local = new URL(`.${url}`, clientRoot);
|
|
62
|
-
try {
|
|
63
|
-
const data = await readFile(local);
|
|
64
|
-
setStatusAndCache(200, 'public, max-age=60, s-maxage=600')
|
|
65
|
-
.send(data);
|
|
66
|
-
} catch {
|
|
67
|
-
fallback(err, 404);
|
|
68
|
-
}
|
|
69
51
|
});
|
|
70
52
|
};
|
|
71
53
|
// # sourceMappingURL=serve-storefront.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serve-storefront.js","sourceRoot":"","sources":["../../src/firebase/serve-storefront.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"serve-storefront.js","sourceRoot":"","sources":["../../src/firebase/serve-storefront.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,IAAI,QAAQ,EAAE,MAAM,MAAM,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,WAAW,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CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAC;SACvD;aAAM;YACL,iBAAiB,CAAC,MAAM,EAAE,mCAAmC,CAAC;iBAC3D,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC;SACzB;IACH,CAAC,CAAC;IAEF,QAAQ,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,IAAI,EAAE;QAC5B;;;;UAIE;QACF,MAAM,CAAC,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,GAAQ,EAAE,EAAE;YAC9C,IAAI,GAAG,EAAE;gBACP,GAAG,CAAC,GAAG,CAAC,aAAa,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;gBACpC,QAAQ,CAAC,GAAG,CAAC,CAAC;gBACd,OAAO;aACR;YACD,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,IAAI,GAAG,EAAE,EAAE,UAAU,CAAC,CAAC;YAC7C,IAAI;gBACF,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,KAAK,CAAC,CAAC;gBACnC,iBAAiB,CAAC,GAAG,EAAE,kCAAkC,CAAC;qBACvD,IAAI,CAAC,IAAI,CAAC,CAAC;aACf;YAAC,MAAM;gBACN,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;aACpB;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudcommerce/ssr",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.82",
|
|
5
5
|
"description": "E-Com Plus Cloud Commerce storefront SSR",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"exports": {
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@cloudcommerce/api": "workspace:*",
|
|
27
27
|
"@cloudcommerce/firebase": "workspace:*",
|
|
28
|
+
"compression": "^1.7.4",
|
|
28
29
|
"firebase-admin": "^11.0.1",
|
|
29
30
|
"firebase-functions": "^3.23.0",
|
|
30
31
|
"source-map-support": "^0.5.21"
|
|
@@ -1,29 +1,24 @@
|
|
|
1
1
|
import type { Request, Response } from 'firebase-functions';
|
|
2
|
-
import type { OutgoingHttpHeaders, OutgoingHttpHeader } from 'http';
|
|
3
2
|
import { join as joinPath } from 'path';
|
|
4
3
|
import { readFile } from 'fs/promises';
|
|
5
|
-
import
|
|
6
|
-
import logger from 'firebase-functions/lib/logger';
|
|
4
|
+
import compression from 'compression';
|
|
7
5
|
|
|
8
6
|
const { STOREFRONT_BASE_DIR } = process.env;
|
|
9
7
|
const baseDir = STOREFRONT_BASE_DIR || process.cwd();
|
|
10
8
|
const clientRoot = new URL(joinPath(baseDir, 'dist/client/'), import.meta.url);
|
|
9
|
+
const compress = compression();
|
|
11
10
|
|
|
12
|
-
|
|
13
|
-
WRITEHEAD?: Response['writeHead'],
|
|
14
|
-
WRITE?: Response['write'],
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export default (req: Request, res: InterceptedResponse) => {
|
|
18
|
-
logger.info('Serving storefront');
|
|
11
|
+
export default (req: Request, res: Response) => {
|
|
19
12
|
const url = req.url.replace(/\?.*$/, '').replace(/\.html$/, '');
|
|
20
13
|
|
|
21
14
|
const setStatusAndCache = (status: number, defaultCache: string) => {
|
|
22
|
-
return res.status(status)
|
|
23
|
-
'
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
15
|
+
return res.status(status)
|
|
16
|
+
.set('X-SSR-ID', `v1/${Date.now()}`)
|
|
17
|
+
.set(
|
|
18
|
+
'Cache-Control',
|
|
19
|
+
(typeof global.cache_control === 'function' && global.cache_control(status))
|
|
20
|
+
|| defaultCache,
|
|
21
|
+
);
|
|
27
22
|
};
|
|
28
23
|
|
|
29
24
|
const fallback = (err: any, status = 500) => {
|
|
@@ -39,53 +34,26 @@ export default (req: Request, res: InterceptedResponse) => {
|
|
|
39
34
|
}
|
|
40
35
|
};
|
|
41
36
|
|
|
42
|
-
res
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
headers['Transfer-Encoding'] = 'gzip, chunked';
|
|
50
|
-
headers['X-SSR-ID'] = `v1/${Date.now()}`;
|
|
51
|
-
}
|
|
52
|
-
return (res.WRITEHEAD as Response['writeHead'])(
|
|
53
|
-
statusCode,
|
|
54
|
-
headers as OutgoingHttpHeaders,
|
|
55
|
-
);
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
res.WRITE = res.write;
|
|
59
|
-
res.write = (chunk: any) => {
|
|
60
|
-
gzip(chunk, (err, data) => {
|
|
37
|
+
compress(req, res, async () => {
|
|
38
|
+
/*
|
|
39
|
+
https://github.com/withastro/astro/blob/main/examples/ssr/server/server.mjs
|
|
40
|
+
import { handler as ssrHandler } from '../dist/server/entry.mjs';
|
|
41
|
+
global.ssr_handler = ssrHandler;
|
|
42
|
+
*/
|
|
43
|
+
global.ssr_handler(req, res, async (err: any) => {
|
|
61
44
|
if (err) {
|
|
62
|
-
|
|
45
|
+
res.set('X-SSR-Error', err.message);
|
|
63
46
|
fallback(err);
|
|
64
|
-
|
|
65
|
-
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const local = new URL(`.${url}`, clientRoot);
|
|
50
|
+
try {
|
|
51
|
+
const data = await readFile(local);
|
|
52
|
+
setStatusAndCache(200, 'public, max-age=60, s-maxage=600')
|
|
53
|
+
.send(data);
|
|
54
|
+
} catch {
|
|
55
|
+
fallback(err, 404);
|
|
66
56
|
}
|
|
67
57
|
});
|
|
68
|
-
return true;
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
/*
|
|
72
|
-
https://github.com/withastro/astro/blob/main/examples/ssr/server/server.mjs
|
|
73
|
-
import { handler as ssrHandler } from '../dist/server/entry.mjs';
|
|
74
|
-
global.ssr_handler = ssrHandler;
|
|
75
|
-
*/
|
|
76
|
-
global.ssr_handler(req, res, async (err: any) => {
|
|
77
|
-
if (err) {
|
|
78
|
-
res.set('X-SSR-Error', err.message);
|
|
79
|
-
fallback(err);
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
const local = new URL(`.${url}`, clientRoot);
|
|
83
|
-
try {
|
|
84
|
-
const data = await readFile(local);
|
|
85
|
-
setStatusAndCache(200, 'public, max-age=60, s-maxage=600')
|
|
86
|
-
.send(data);
|
|
87
|
-
} catch {
|
|
88
|
-
fallback(err, 404);
|
|
89
|
-
}
|
|
90
58
|
});
|
|
91
59
|
};
|
|
@@ -9,6 +9,7 @@ import partytown from '@astrojs/partytown';
|
|
|
9
9
|
import prefetch from '@astrojs/prefetch';
|
|
10
10
|
import sitemap from '@astrojs/sitemap';
|
|
11
11
|
import UnoCSS from 'unocss/astro';
|
|
12
|
+
import { VitePWA } from 'vite-plugin-pwa';
|
|
12
13
|
import getConfig from './storefront.config.mjs';
|
|
13
14
|
|
|
14
15
|
dotenv.config();
|
|
@@ -24,6 +25,9 @@ const astroConfig = {
|
|
|
24
25
|
sitemap(),
|
|
25
26
|
UnoCSS(),
|
|
26
27
|
],
|
|
28
|
+
vite: {
|
|
29
|
+
plugins: [VitePWA()],
|
|
30
|
+
},
|
|
27
31
|
site: `https://${getConfig().domain}`,
|
|
28
32
|
};
|
|
29
33
|
|