qumra-engine 2.0.137 → 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.
|
@@ -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 = [
|
|
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,
|
|
12
|
+
return new nodes.CallExtension(this, 'run', null);
|
|
13
13
|
}
|
|
14
14
|
run({ env }) {
|
|
15
|
-
const injectionCode = (0, globals_1.getGlobal)(
|
|
16
|
-
const isIframe = !!env.getGlobal(
|
|
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 (
|
|
21
|
-
scripts +=
|
|
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
|
})();
|
|
@@ -4,7 +4,6 @@ exports.mergeDataMiddleware = void 0;
|
|
|
4
4
|
const globals_1 = require("../store/globals");
|
|
5
5
|
const mergeDataMiddleware = async (req, res, next) => {
|
|
6
6
|
try {
|
|
7
|
-
console.log("res.locals.render.engine", res.locals.render.engine);
|
|
8
7
|
if ((res.locals.preview && res.locals.themeWidget) || (req.query.widgetId)) {
|
|
9
8
|
res.locals.env.addGlobal("widget", res.locals.render.engine?.widget ?? []);
|
|
10
9
|
}
|
|
@@ -35,6 +34,7 @@ const mergeDataMiddleware = async (req, res, next) => {
|
|
|
35
34
|
});
|
|
36
35
|
const settingsData = res.locals.render.engine?.settings;
|
|
37
36
|
res.locals.env.addGlobal("settings", settingsData);
|
|
37
|
+
res.locals.env.addGlobal("themeVersion", res.locals.render.globals?.themeVersion);
|
|
38
38
|
next();
|
|
39
39
|
}
|
|
40
40
|
catch (err) {
|
package/dist/middleware.js
CHANGED
|
@@ -43,7 +43,6 @@ const startEngine = async ({ renderApi, mode, getRender, setRender, port = 3000,
|
|
|
43
43
|
res.locals.showDevTools = req.query.showDevTools ?? false;
|
|
44
44
|
const isIframe = req.query.iframe === "1" || req.headers["sec-fetch-dest"] === "iframe";
|
|
45
45
|
if (isIframe) {
|
|
46
|
-
console.log("🚀 هذا الطلب جاي من iframe");
|
|
47
46
|
res.locals.isIframe = true;
|
|
48
47
|
}
|
|
49
48
|
next();
|