@vibecodeapp/sdk 0.4.4 → 0.4.6
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.
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Web version of Screenshot - listens for screenshot requests from parent iframe
|
|
3
3
|
*
|
|
4
4
|
* On web, this component listens for postMessage requests and captures
|
|
5
|
-
* the current page using
|
|
5
|
+
* the current page using html2canvas, then sends the result back.
|
|
6
6
|
*/
|
|
7
7
|
export declare function VibeScreenshot(): null;
|
|
8
8
|
//# sourceMappingURL=Screenshot.web.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Screenshot.web.d.ts","sourceRoot":"","sources":["../../src/dev/Screenshot.web.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"Screenshot.web.d.ts","sourceRoot":"","sources":["../../src/dev/Screenshot.web.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AA6DH,wBAAgB,cAAc,SA2B7B"}
|
|
@@ -2,30 +2,39 @@
|
|
|
2
2
|
* Web version of Screenshot - listens for screenshot requests from parent iframe
|
|
3
3
|
*
|
|
4
4
|
* On web, this component listens for postMessage requests and captures
|
|
5
|
-
* the current page using
|
|
5
|
+
* the current page using html2canvas, then sends the result back.
|
|
6
6
|
*/
|
|
7
7
|
import { useEffect } from 'react';
|
|
8
|
-
import
|
|
8
|
+
import html2canvas from 'html2canvas';
|
|
9
9
|
async function captureScreenshot() {
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
const canvas = await html2canvas(document.body, {
|
|
11
|
+
useCORS: true,
|
|
12
|
+
allowTaint: true,
|
|
13
|
+
backgroundColor: null,
|
|
14
|
+
scale: window.devicePixelRatio || 1,
|
|
15
|
+
});
|
|
16
|
+
return new Promise((resolve, reject) => {
|
|
17
|
+
canvas.toBlob((blob) => {
|
|
18
|
+
if (!blob) {
|
|
19
|
+
reject(new Error('Failed to create blob from canvas'));
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
blob.arrayBuffer().then((buffer) => {
|
|
23
|
+
resolve({
|
|
24
|
+
image: buffer,
|
|
25
|
+
width: canvas.width,
|
|
26
|
+
height: canvas.height,
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
}, 'image/png');
|
|
16
30
|
});
|
|
17
|
-
return {
|
|
18
|
-
image,
|
|
19
|
-
width: width * scale,
|
|
20
|
-
height: height * scale,
|
|
21
|
-
};
|
|
22
31
|
}
|
|
23
32
|
function postScreenshotToParent(data) {
|
|
24
33
|
try {
|
|
25
34
|
if (typeof window !== 'undefined' &&
|
|
26
35
|
window.parent &&
|
|
27
36
|
window.parent !== window) {
|
|
28
|
-
window.parent.postMessage(data, '*');
|
|
37
|
+
window.parent.postMessage(data, '*', [data.image]);
|
|
29
38
|
}
|
|
30
39
|
}
|
|
31
40
|
catch {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Screenshot.web.js","sourceRoot":"","sources":["../../src/dev/Screenshot.web.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACjC,OAAO,
|
|
1
|
+
{"version":3,"file":"Screenshot.web.js","sourceRoot":"","sources":["../../src/dev/Screenshot.web.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACjC,OAAO,WAAW,MAAM,aAAa,CAAA;AAgBrC,KAAK,UAAU,iBAAiB;IAC/B,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,QAAQ,CAAC,IAAI,EAAE;QAC/C,OAAO,EAAE,IAAI;QACb,UAAU,EAAE,IAAI;QAChB,eAAe,EAAE,IAAI;QACrB,KAAK,EAAE,MAAM,CAAC,gBAAgB,IAAI,CAAC;KACnC,CAAC,CAAA;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,KAAK,CAAC,IAAI,CAAC,SAAS;wBAC/B,KAAK;wBACL,KAAK;wBACL,MAAM;wBACN,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;qBACrB,CAAC,CAAA;gBACH,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBAChB,+CAA+C;oBAC/C,OAAO,CAAC,IAAI,CAAC,uCAAuC,EAAE,KAAK,CAAC,CAAA;gBAC7D,CAAC;YACF,CAAC;QACF,CAAC,CAAA;QAED,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,aAAa,CAAC,CAAA;QACjD,OAAO,GAAG,EAAE,CAAC,MAAM,CAAC,mBAAmB,CAAC,SAAS,EAAE,aAAa,CAAC,CAAA;IAClE,CAAC,EAAE,EAAE,CAAC,CAAA;IAEN,iCAAiC;IACjC,OAAO,IAAI,CAAA;AACZ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vibecodeapp/sdk",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.6",
|
|
4
4
|
"description": "SDK for Vibecodeapp.com - Web polyfills and Metro configuration for React Native",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"@teovilla/react-native-web-maps": "^0.9.5",
|
|
41
41
|
"@stardazed/streams-text-encoding": "^1.0.2",
|
|
42
42
|
"assert": "^2.1.0",
|
|
43
|
-
"
|
|
43
|
+
"html2canvas": "^1.4.1",
|
|
44
44
|
"p-limit": "^3.1.0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|