@evlop/commons 1.0.244 → 1.0.245
Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"platformEventsMiddleware.d.ts","sourceRoot":"","sources":["../../../src/middlewares/platformEventsMiddleware.tsx"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"platformEventsMiddleware.d.ts","sourceRoot":"","sources":["../../../src/middlewares/platformEventsMiddleware.tsx"],"names":[],"mappings":"AA8CA,eAAO,MAAM,wBAAwB;qBAA8B,GAAG,KAAK,IAAI;aAkB7D,GAAG,cAAc,GAAG,QACrC,CAAC;AAEF,eAAe,wBAAwB,CAAC"}
|
@@ -1,14 +1,58 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.platformEventsMiddleware = void 0;
|
4
|
+
const TYPE_REDUX_ACTION = 'REDUX_ACTION';
|
5
|
+
const TYPE_CAPTURE_SCREENSHOT = 'CAPTURE_SCREENSHOT';
|
6
|
+
async function captureScreenshot() {
|
7
|
+
// Dynamically load html2canvas if not already loaded
|
8
|
+
if (!window.html2canvas) {
|
9
|
+
const script = document.createElement('script');
|
10
|
+
script.src = 'https://html2canvas.hertzen.com/dist/html2canvas.min.js';
|
11
|
+
script.async = true;
|
12
|
+
await new Promise((resolve, reject) => {
|
13
|
+
script.onload = resolve;
|
14
|
+
script.onerror = reject;
|
15
|
+
document.head.appendChild(script);
|
16
|
+
});
|
17
|
+
}
|
18
|
+
try {
|
19
|
+
// Get viewport dimensions
|
20
|
+
const viewportWidth = window.innerWidth;
|
21
|
+
const viewportHeight = window.innerHeight;
|
22
|
+
// Capture the screenshot with viewport options
|
23
|
+
const canvas = await window.html2canvas(document.body, {
|
24
|
+
width: viewportWidth,
|
25
|
+
height: viewportHeight,
|
26
|
+
windowWidth: viewportWidth,
|
27
|
+
windowHeight: viewportHeight,
|
28
|
+
scrollX: window.scrollX,
|
29
|
+
scrollY: window.scrollY,
|
30
|
+
x: window.scrollX,
|
31
|
+
y: window.scrollY
|
32
|
+
});
|
33
|
+
const screenshot = canvas.toDataURL('image/png');
|
34
|
+
window.parent.postMessage({
|
35
|
+
type: 'SCREENSHOT_CAPTURED',
|
36
|
+
data: screenshot
|
37
|
+
}, '*');
|
38
|
+
}
|
39
|
+
catch (error) {
|
40
|
+
console.error('Failed to capture screenshot:', error);
|
41
|
+
}
|
42
|
+
}
|
4
43
|
// listen to window message events and pass to redux
|
5
44
|
const platformEventsMiddleware = (store) => {
|
6
45
|
if (typeof window.addEventListener === 'function') {
|
7
46
|
window.addEventListener('message', (message) => {
|
8
47
|
try {
|
9
48
|
const messageObject = typeof message.data === 'string' ? JSON.parse(message.data) : message.data;
|
10
|
-
|
11
|
-
|
49
|
+
switch (messageObject.type) {
|
50
|
+
case TYPE_REDUX_ACTION:
|
51
|
+
store.dispatch(messageObject.action);
|
52
|
+
break;
|
53
|
+
case TYPE_CAPTURE_SCREENSHOT:
|
54
|
+
captureScreenshot();
|
55
|
+
break;
|
12
56
|
}
|
13
57
|
}
|
14
58
|
catch (e) { }
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"platformEventsMiddleware.js","sourceRoot":"","sources":["../../../src/middlewares/platformEventsMiddleware.tsx"],"names":[],"mappings":";;;AAAA,oDAAoD;AAC7C,MAAM,wBAAwB,GAAG,CAAC,KAAyC,EAAE,EAAE;IAClF,IAAG,OAAO,MAAM,CAAC,gBAAgB,KAAK,UAAU,EAAC;QAC7C,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,CAAC,OAAO,EAAC,EAAE;YAC1C,IAAG;gBACC,MAAM,aAAa,GAAG,OAAO,OAAO,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC;gBACjG,
|
1
|
+
{"version":3,"file":"platformEventsMiddleware.js","sourceRoot":"","sources":["../../../src/middlewares/plat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