@pronto-tools-and-more/pronto 9.17.0 → 9.19.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": "9.17.0",
3
+ "version": "9.19.0",
4
4
  "description": "",
5
5
  "main": "src/main.js",
6
6
  "type": "module",
@@ -17,15 +17,15 @@
17
17
  "@lvce-editor/ipc": "^11.1.0",
18
18
  "@lvce-editor/json-rpc": "^5.0.0",
19
19
  "@lvce-editor/verror": "^1.5.0",
20
- "@pronto-tools-and-more/file-watcher": "9.17.0",
21
- "@pronto-tools-and-more/files": "9.17.0",
22
- "@pronto-tools-and-more/network-process": "9.17.0",
23
- "@pronto-tools-and-more/sass-compiler": "9.17.0",
24
- "@pronto-tools-and-more/components-renderer": "9.17.0",
25
- "@pronto-tools-and-more/components": "9.17.0",
26
- "@pronto-tools-and-more/schema-process": "9.17.0",
27
- "@pronto-tools-and-more/diff-process": "9.17.0",
28
- "@pronto-tools-and-more/type-checker": "9.17.0",
20
+ "@pronto-tools-and-more/file-watcher": "9.19.0",
21
+ "@pronto-tools-and-more/files": "9.19.0",
22
+ "@pronto-tools-and-more/network-process": "9.19.0",
23
+ "@pronto-tools-and-more/sass-compiler": "9.19.0",
24
+ "@pronto-tools-and-more/components-renderer": "9.19.0",
25
+ "@pronto-tools-and-more/components": "9.19.0",
26
+ "@pronto-tools-and-more/schema-process": "9.19.0",
27
+ "@pronto-tools-and-more/diff-process": "9.19.0",
28
+ "@pronto-tools-and-more/type-checker": "9.19.0",
29
29
  "execa": "^9.5.1",
30
30
  "express": "^4.21.1"
31
31
  },
@@ -2,6 +2,7 @@ import express from "express";
2
2
  import { join } from "node:path";
3
3
  import * as FilesPath from "../FilesPath/FilesPath.js";
4
4
  import * as HandleCss from "../HandleCss/HandleCss.js";
5
+ import * as HandleFeaturesJson from "../HandleFeaturesJson/HandleFeaturesJson.js";
5
6
  import * as HandleIndex from "../HandleIndex/HandleIndex.js";
6
7
  import * as HandleMainJs from "../HandleMainJs/HandleMainJs.js";
7
8
  import * as HandleViews from "../HandleViews/HandleViews.js";
@@ -21,6 +22,7 @@ export const create = ({
21
22
  splitViews,
22
23
  reactComponents,
23
24
  managerWebUrl,
25
+ resourceDynamicUrlsInViewsJson,
24
26
  }) => {
25
27
  const app = express();
26
28
  const storeFrontPath = join(root, "src", "default", "storefront");
@@ -57,6 +59,14 @@ export const create = ({
57
59
  storeFrontPath,
58
60
  splitViews,
59
61
  reactComponents,
62
+ resourceDynamicUrlsInViewsJson,
63
+ })
64
+ );
65
+ app.get(
66
+ "/assets/features.json",
67
+ HandleFeaturesJson.handleFeaturesJson({
68
+ storeFrontPath,
69
+ filesPath: FilesPath.filesPath,
60
70
  })
61
71
  );
62
72
  app.use("*", HandleCss.handleCss(storeFrontPath));
@@ -51,6 +51,7 @@ export const build = async () => {
51
51
  pathPrefix: Config.pathPrefix,
52
52
  isBuild: true,
53
53
  hotReload: false,
54
+ resourceDynamicUrlsInViewsJson: false,
54
55
  });
55
56
  const viewsPath = join(
56
57
  dist,
@@ -110,3 +110,6 @@ export const reactComponents = config.reactComponents || false;
110
110
  export const pushToReleaseOnGitTag = config.pushToReleaseOnGitTag || false;
111
111
 
112
112
  export const hotReload = config.hotReload || false;
113
+
114
+ export const resourceDynamicUrlsInViewsJson =
115
+ config.resourceDynamicUrlsInViewsJson || false;
@@ -24,6 +24,7 @@ export const createServer = async (root, errorColor) => {
24
24
  managerWebUrl: Config.managerWebUrl,
25
25
  reactComponents: Config.reactComponents,
26
26
  splitViews: Config.splitViews,
27
+ resourceDynamicUrlsInViewsJson: Config.resourceDynamicUrlsInViewsJson,
27
28
  });
28
29
  const server = http.createServer(app);
29
30
  const webSocketServer = new ws.WebSocketServer({
@@ -11,6 +11,7 @@ export const getViewsResponse = async ({
11
11
  pathPrefix,
12
12
  isBuild,
13
13
  hotReload,
14
+ resourceDynamicUrlsInViewsJson,
14
15
  }) => {
15
16
  if (reactComponents) {
16
17
  const content = await HandleViewsReactComponents.handleViewsReactComponents(
@@ -26,9 +27,18 @@ export const getViewsResponse = async ({
26
27
  }
27
28
  if (splitViews) {
28
29
  const content = await HandleViewsSplit.handleViewsSplit(storeFrontPath);
30
+ if (resourceDynamicUrlsInViewsJson && !isBuild) {
31
+ const replacement = "";
32
+ const actualContent = content.replaceAll(
33
+ "resource://dynamic",
34
+ replacement
35
+ );
36
+ return actualContent;
37
+ }
29
38
  return content;
30
39
  }
31
40
  const viewsFilePath = join(storeFrontPath, "assets", "views.json");
32
41
  const content = await readFile(viewsFilePath, "utf8");
42
+
33
43
  return content;
34
44
  };
@@ -0,0 +1,29 @@
1
+ import { existsSync } from "fs";
2
+ import { readFile } from "fs/promises";
3
+ import { join } from "path";
4
+
5
+ export const handleFeaturesJson =
6
+ ({ storeFrontPath, filesPath }) =>
7
+ async (req, res) => {
8
+ res.setHeader("Content-Type", "application/json");
9
+ const pathsToTry = [
10
+ join(storeFrontPath, "assets", "features.json"),
11
+ join(
12
+ filesPath,
13
+ "framework",
14
+ "src",
15
+ "default",
16
+ "storefront",
17
+ "assets",
18
+ "features.json"
19
+ ),
20
+ ];
21
+ for (const pathToTry of pathsToTry) {
22
+ if (existsSync(pathToTry)) {
23
+ const content = await readFile(pathToTry);
24
+ res.end(content);
25
+ return;
26
+ }
27
+ }
28
+ res.end("not-found");
29
+ };
@@ -1,7 +1,12 @@
1
1
  import * as GetViewsResponse from "../GetViewsResponse/GetViewsResponse.js";
2
2
 
3
3
  export const handleViews =
4
- ({ storeFrontPath, splitViews, reactComponents }) =>
4
+ ({
5
+ storeFrontPath,
6
+ splitViews,
7
+ reactComponents,
8
+ resourceDynamicUrlsInViewsJson,
9
+ }) =>
5
10
  async (req, res) => {
6
11
  res.setHeader("Content-Type", "application/json");
7
12
  const content = await GetViewsResponse.getViewsResponse({
@@ -11,6 +16,7 @@ export const handleViews =
11
16
  pathPrefix: "",
12
17
  isBuild: false,
13
18
  hotReload: false,
19
+ resourceDynamicUrlsInViewsJson,
14
20
  });
15
21
  res.end(content);
16
22
  };
@@ -1 +1 @@
1
- export const version = '9.17.0'
1
+ export const version = '9.19.0'