@pronto-tools-and-more/pronto 11.2.0 → 11.3.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pronto-tools-and-more/pronto",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.3.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "src/main.js",
|
|
6
6
|
"type": "module",
|
|
@@ -17,16 +17,16 @@
|
|
|
17
17
|
"@lvce-editor/ipc": "^11.7.0",
|
|
18
18
|
"@lvce-editor/json-rpc": "^5.3.0",
|
|
19
19
|
"@lvce-editor/verror": "^1.6.0",
|
|
20
|
-
"@pronto-tools-and-more/file-watcher": "11.
|
|
21
|
-
"@pronto-tools-and-more/files": "11.
|
|
22
|
-
"@pronto-tools-and-more/network-process": "11.
|
|
23
|
-
"@pronto-tools-and-more/sass-compiler": "11.
|
|
24
|
-
"@pronto-tools-and-more/components-renderer": "11.
|
|
25
|
-
"@pronto-tools-and-more/components": "11.
|
|
26
|
-
"@pronto-tools-and-more/schema-process": "11.
|
|
27
|
-
"@pronto-tools-and-more/diff-process": "11.
|
|
28
|
-
"@pronto-tools-and-more/type-checker": "11.
|
|
29
|
-
"@pronto-tools-and-more/custom-js-functions": "11.
|
|
20
|
+
"@pronto-tools-and-more/file-watcher": "11.3.0",
|
|
21
|
+
"@pronto-tools-and-more/files": "11.3.0",
|
|
22
|
+
"@pronto-tools-and-more/network-process": "11.3.0",
|
|
23
|
+
"@pronto-tools-and-more/sass-compiler": "11.3.0",
|
|
24
|
+
"@pronto-tools-and-more/components-renderer": "11.3.0",
|
|
25
|
+
"@pronto-tools-and-more/components": "11.3.0",
|
|
26
|
+
"@pronto-tools-and-more/schema-process": "11.3.0",
|
|
27
|
+
"@pronto-tools-and-more/diff-process": "11.3.0",
|
|
28
|
+
"@pronto-tools-and-more/type-checker": "11.3.0",
|
|
29
|
+
"@pronto-tools-and-more/custom-js-functions": "11.3.0",
|
|
30
30
|
"execa": "^9.5.2",
|
|
31
31
|
"express": "^4.21.2"
|
|
32
32
|
},
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as crypto from "node:crypto";
|
|
2
|
+
|
|
3
|
+
export const fromStats = (stats) => {
|
|
4
|
+
let hash = crypto.createHash("sha1");
|
|
5
|
+
for (const stat of stats) {
|
|
6
|
+
hash.update(`${stat.ino}`);
|
|
7
|
+
hash.update(`${stat.size}`);
|
|
8
|
+
hash.update(`${stat.mtime}`);
|
|
9
|
+
}
|
|
10
|
+
return hash.digest("base64");
|
|
11
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { readdir, stat } from "fs/promises";
|
|
2
|
+
import { join } from "path";
|
|
3
|
+
import * as Etag from "../Etag/Etag.js";
|
|
4
|
+
|
|
5
|
+
export const getCssEtag = async (storefrontPath) => {
|
|
6
|
+
try {
|
|
7
|
+
const scssPath = join(storefrontPath, "assets", "scss");
|
|
8
|
+
const dirents = await readdir(scssPath, {
|
|
9
|
+
recursive: true,
|
|
10
|
+
});
|
|
11
|
+
const stats = await Promise.all(
|
|
12
|
+
dirents.map(async (dirent) => {
|
|
13
|
+
const absolutePath = join(scssPath, dirent);
|
|
14
|
+
const info = await stat(absolutePath);
|
|
15
|
+
return {
|
|
16
|
+
size: info.size,
|
|
17
|
+
mtime: info.mtime,
|
|
18
|
+
ino: info.ino,
|
|
19
|
+
};
|
|
20
|
+
})
|
|
21
|
+
);
|
|
22
|
+
return Etag.fromStats(stats);
|
|
23
|
+
} catch (error) {
|
|
24
|
+
console.warn(`Failed to compute css etag ${error}`);
|
|
25
|
+
return `css-${Math.random()}`;
|
|
26
|
+
}
|
|
27
|
+
};
|
|
@@ -3,6 +3,7 @@ import { readFile } from "node:fs/promises";
|
|
|
3
3
|
import { join } from "node:path";
|
|
4
4
|
import * as CompileSass from "../CompileSass/CompileSass.js";
|
|
5
5
|
import * as Config from "../Config/Config.js";
|
|
6
|
+
import * as GetCssEtag from "../GetCssEtag/GetCssEtag.js";
|
|
6
7
|
import * as UpdateCss from "../UpdateCss/UpdateCss.js";
|
|
7
8
|
|
|
8
9
|
export const handleCss = (storeFrontPath) => async (req, res, next) => {
|
|
@@ -13,7 +14,15 @@ export const handleCss = (storeFrontPath) => async (req, res, next) => {
|
|
|
13
14
|
res.setHeader("content-type", "text/css");
|
|
14
15
|
if (pathName === "/assets/custom.css") {
|
|
15
16
|
try {
|
|
17
|
+
const ifNoneMatch = req.headers["if-none-match"];
|
|
18
|
+
const cssEtag = await GetCssEtag.getCssEtag(storeFrontPath);
|
|
19
|
+
if (ifNoneMatch && ifNoneMatch === cssEtag) {
|
|
20
|
+
res.statusCode = 304;
|
|
21
|
+
res.end();
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
16
24
|
const result = await CompileSass.compileSass(Config.rootSassFile);
|
|
25
|
+
res.setHeader("Etag", cssEtag);
|
|
17
26
|
res.end(result.css);
|
|
18
27
|
} catch (error) {
|
|
19
28
|
console.warn(error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '11.
|
|
1
|
+
export const version = '11.3.0'
|