@pronto-tools-and-more/pronto 11.4.0 → 11.6.0

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pronto-tools-and-more/pronto",
3
- "version": "11.4.0",
3
+ "version": "11.6.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.4.0",
21
- "@pronto-tools-and-more/files": "11.4.0",
22
- "@pronto-tools-and-more/network-process": "11.4.0",
23
- "@pronto-tools-and-more/sass-compiler": "11.4.0",
24
- "@pronto-tools-and-more/components-renderer": "11.4.0",
25
- "@pronto-tools-and-more/components": "11.4.0",
26
- "@pronto-tools-and-more/schema-process": "11.4.0",
27
- "@pronto-tools-and-more/diff-process": "11.4.0",
28
- "@pronto-tools-and-more/type-checker": "11.4.0",
29
- "@pronto-tools-and-more/custom-js-functions": "11.4.0",
20
+ "@pronto-tools-and-more/file-watcher": "11.6.0",
21
+ "@pronto-tools-and-more/files": "11.6.0",
22
+ "@pronto-tools-and-more/network-process": "11.6.0",
23
+ "@pronto-tools-and-more/sass-compiler": "11.6.0",
24
+ "@pronto-tools-and-more/components-renderer": "11.6.0",
25
+ "@pronto-tools-and-more/components": "11.6.0",
26
+ "@pronto-tools-and-more/schema-process": "11.6.0",
27
+ "@pronto-tools-and-more/diff-process": "11.6.0",
28
+ "@pronto-tools-and-more/type-checker": "11.6.0",
29
+ "@pronto-tools-and-more/custom-js-functions": "11.6.0",
30
30
  "execa": "^9.5.2",
31
31
  "express": "^4.21.2"
32
32
  },
@@ -14,6 +14,7 @@ export const create = ({
14
14
  root,
15
15
  appId,
16
16
  baseUrl,
17
+ rootSassFile,
17
18
  contentUrl,
18
19
  platform,
19
20
  managerBaseUrl,
@@ -26,6 +27,7 @@ export const create = ({
26
27
  managerWebUrl,
27
28
  resourceDynamicUrlsInViewsJson,
28
29
  injectCustomJs,
30
+ shimConfigLoader,
29
31
  }) => {
30
32
  const app = express();
31
33
  const storeFrontPath = join(root, "src", "default", "storefront");
@@ -43,10 +45,13 @@ export const create = ({
43
45
  filesPath: FilesPath.filesPath,
44
46
  })
45
47
  );
46
- app.get(
47
- "/assets/scripts/configLoader.js",
48
- HandleConfigLoader.handleConfigLoader
49
- );
48
+
49
+ if (shimConfigLoader) {
50
+ app.get(
51
+ "/assets/scripts/configLoader.js",
52
+ HandleConfigLoader.handleConfigLoader
53
+ );
54
+ }
50
55
  app.get(
51
56
  "/modules/main.js",
52
57
  HandleMainJs.handleMainJs({
@@ -84,7 +89,7 @@ export const create = ({
84
89
  injectCustomJs,
85
90
  })
86
91
  );
87
- app.use("*", HandleCss.handleCss(storeFrontPath));
92
+ app.use("*", HandleCss.handleCss(storeFrontPath, rootSassFile));
88
93
  app.use(express.static(FilesPath.filesPath));
89
94
  if (mode === "slim") {
90
95
  app.use(
@@ -115,3 +115,5 @@ export const resourceDynamicUrlsInViewsJson =
115
115
  config.resourceDynamicUrlsInViewsJson || false;
116
116
 
117
117
  export const injectCustomJs = config.injectCustomJs || false;
118
+
119
+ export const shimConfigLoader = config.shimConfigLoader || false;
@@ -12,6 +12,7 @@ export const createServer = async (root, errorColor) => {
12
12
  Assert.string(root);
13
13
  const app = App.create({
14
14
  root,
15
+ rootSassFile: Config.rootSassFile,
15
16
  appId: Config.appId,
16
17
  baseUrl: Config.baseUrl,
17
18
  contentUrl: Config.contentUrl,
@@ -26,6 +27,7 @@ export const createServer = async (root, errorColor) => {
26
27
  splitViews: Config.splitViews,
27
28
  resourceDynamicUrlsInViewsJson: Config.resourceDynamicUrlsInViewsJson,
28
29
  injectCustomJs: Config.injectCustomJs,
30
+ shimConfigLoader: Config.shimConfigLoader,
29
31
  });
30
32
  const server = http.createServer(app);
31
33
  const webSocketServer = new ws.WebSocketServer({
@@ -1,10 +1,10 @@
1
1
  import { readdir, stat } from "fs/promises";
2
- import { join } from "path";
2
+ import { dirname, join } from "path";
3
3
  import * as Etag from "../Etag/Etag.js";
4
4
 
5
- export const getCssEtag = async (storefrontPath) => {
5
+ export const getCssEtag = async (storefrontPath, rootSassFile) => {
6
6
  try {
7
- const scssPath = join(storefrontPath, "assets", "scss");
7
+ const scssPath = dirname(rootSassFile);
8
8
  const dirents = await readdir(scssPath, {
9
9
  recursive: true,
10
10
  });
@@ -21,7 +21,7 @@ export const getCssEtag = async (storefrontPath) => {
21
21
  );
22
22
  return Etag.fromStats(stats);
23
23
  } catch (error) {
24
- console.warn(`Failed to compute css etag ${error}`);
24
+ console.warn(`[server] Failed to compute css etag ${error}`);
25
25
  return `css-${Math.random()}`;
26
26
  }
27
27
  };
@@ -6,35 +6,39 @@ import * as Config from "../Config/Config.js";
6
6
  import * as GetCssEtag from "../GetCssEtag/GetCssEtag.js";
7
7
  import * as UpdateCss from "../UpdateCss/UpdateCss.js";
8
8
 
9
- export const handleCss = (storeFrontPath) => async (req, res, next) => {
10
- const pathName = req._parsedUrl.pathname;
11
- if (!pathName.endsWith(".css")) {
12
- return next();
13
- }
14
- res.setHeader("content-type", "text/css");
15
- if (pathName === "/assets/custom.css") {
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;
9
+ export const handleCss =
10
+ (storeFrontPath, rootSassFile) => async (req, res, next) => {
11
+ const pathName = req._parsedUrl.pathname;
12
+ if (!pathName.endsWith(".css")) {
13
+ return next();
14
+ }
15
+ res.setHeader("content-type", "text/css");
16
+ if (pathName === "/assets/custom.css") {
17
+ try {
18
+ const ifNoneMatch = req.headers["if-none-match"];
19
+ const cssEtag = await GetCssEtag.getCssEtag(
20
+ storeFrontPath,
21
+ rootSassFile
22
+ );
23
+ if (ifNoneMatch && ifNoneMatch === cssEtag) {
24
+ res.statusCode = 304;
25
+ res.end();
26
+ return;
27
+ }
28
+ const result = await CompileSass.compileSass(Config.rootSassFile);
29
+ res.setHeader("Etag", cssEtag);
30
+ res.end(result.css);
31
+ } catch (error) {
32
+ console.warn(error);
33
+ res.end(`css error: ${error}`);
23
34
  }
24
- const result = await CompileSass.compileSass(Config.rootSassFile);
25
- res.setHeader("Etag", cssEtag);
26
- res.end(result.css);
27
- } catch (error) {
28
- console.warn(error);
29
- res.end(`css error: ${error}`);
35
+ return;
36
+ }
37
+ const cssPath = join(storeFrontPath, pathName);
38
+ if (!existsSync(cssPath)) {
39
+ return next();
30
40
  }
31
- return;
32
- }
33
- const cssPath = join(storeFrontPath, pathName);
34
- if (!existsSync(cssPath)) {
35
- return next();
36
- }
37
- const cssContent = await readFile(cssPath, "utf8");
38
- const newCss = UpdateCss.updateCss(cssContent);
39
- res.end(newCss);
40
- };
41
+ const cssContent = await readFile(cssPath, "utf8");
42
+ const newCss = UpdateCss.updateCss(cssContent);
43
+ res.end(newCss);
44
+ };
@@ -1 +1 @@
1
- export const version = '11.4.0'
1
+ export const version = '11.6.0'