qumra-engine 2.0.138 → 2.0.139

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.
@@ -1,4 +1,4 @@
1
- import { runtime } from "nunjucks";
1
+ import { runtime } from 'nunjucks';
2
2
  declare const _default: {
3
3
  tags: string[];
4
4
  parse(parser: any, nodes: any): any;
@@ -4,22 +4,40 @@ const nunjucks_1 = require("nunjucks");
4
4
  const globals_1 = require("../../store/globals");
5
5
  exports.default = new (class SeoExtension {
6
6
  constructor() {
7
- this.tags = ["qumra_scripts"];
7
+ this.tags = ['qumra_scripts'];
8
8
  }
9
9
  parse(parser, nodes) {
10
10
  const tok = parser.nextToken();
11
11
  parser.advanceAfterBlockEnd(tok.value);
12
- return new nodes.CallExtension(this, "run", null);
12
+ return new nodes.CallExtension(this, 'run', null);
13
13
  }
14
14
  run({ env }) {
15
- const injectionCode = (0, globals_1.getGlobal)("injectionCode");
16
- const isIframe = !!env.getGlobal("isIframe");
15
+ const injectionCode = (0, globals_1.getGlobal)('injectionCode');
16
+ const isIframe = !!env.getGlobal('isIframe');
17
+ const themeVersion = env.getGlobal('themeVersion');
17
18
  let scripts = `
18
19
  ${injectionCode.body}
19
20
  `;
20
- if (isIframe) {
21
- scripts += `<qumra-selector></qumra-selector>`;
21
+ if (themeVersion) {
22
+ scripts += `
23
+ <script src="https://cdn.socket.io/4.7.2/socket.io.min.js"></script>
24
+ <script>
25
+ const socket = io("wss://realtime.qumra.cloud");
26
+ const appThemeId = '${themeVersion}'
27
+
28
+ // Join room
29
+ socket.emit("join", appThemeId);
30
+
31
+ // Listen for refresh event
32
+ socket.on(appThemeId, () => {
33
+ window.location.reload();
34
+ });
35
+ </script>
36
+ `;
22
37
  }
38
+ // if (isIframe) {
39
+ // scripts += `<qumra-selector></qumra-selector>`;
40
+ // }
23
41
  return new nunjucks_1.runtime.SafeString(scripts);
24
42
  }
25
43
  })();
@@ -34,6 +34,7 @@ const mergeDataMiddleware = async (req, res, next) => {
34
34
  });
35
35
  const settingsData = res.locals.render.engine?.settings;
36
36
  res.locals.env.addGlobal("settings", settingsData);
37
+ res.locals.env.addGlobal("themeVersion", res.locals.render.globals?.themeVersion);
37
38
  next();
38
39
  }
39
40
  catch (err) {
@@ -8,6 +8,9 @@ export interface Globals {
8
8
  Setting: any;
9
9
  assets: string;
10
10
  currency: Currency;
11
+ cart?: any;
12
+ devMode?: boolean;
13
+ themeVersion?: boolean;
11
14
  }
12
15
  export interface RenderContext {
13
16
  page: Page;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qumra-engine",
3
- "version": "2.0.138",
3
+ "version": "2.0.139",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "scripts": {