@puckeditor/plugin-ai 0.3.2-canary.dfd28529 → 0.4.0-canary.d4331212
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.
- package/dist/index.d.mts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +38 -1
- package/dist/index.mjs +38 -1
- package/package.json +4 -3
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1506,6 +1506,7 @@ var dispatchOp = (operation, {
|
|
|
1506
1506
|
};
|
|
1507
1507
|
|
|
1508
1508
|
// src/components/Chat/index.tsx
|
|
1509
|
+
var import_html2canvas_pro = __toESM(require("html2canvas-pro"));
|
|
1509
1510
|
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
1510
1511
|
var q = (0, import_qler.default)();
|
|
1511
1512
|
var BENCHMARK = false;
|
|
@@ -1521,6 +1522,34 @@ function Chat2({ chat, host = "/api/puck/chat" }) {
|
|
|
1521
1522
|
const pluginRef = (0, import_react22.useRef)(null);
|
|
1522
1523
|
const [error, setError] = (0, import_react22.useState)();
|
|
1523
1524
|
const [toolStatus, setToolStatus] = (0, import_react22.useState)({});
|
|
1525
|
+
const uploadScreenshot = (0, import_react22.useCallback)(
|
|
1526
|
+
async (width, bucketUrl) => {
|
|
1527
|
+
const iframeDocument = document?.getElementById("preview-frame")?.contentDocument?.documentElement ?? null;
|
|
1528
|
+
if (!iframeDocument) return;
|
|
1529
|
+
const canvas = await (0, import_html2canvas_pro.default)(iframeDocument, {
|
|
1530
|
+
scale: 2,
|
|
1531
|
+
backgroundColor: "#ffffff",
|
|
1532
|
+
width,
|
|
1533
|
+
windowWidth: width,
|
|
1534
|
+
foreignObjectRendering: false,
|
|
1535
|
+
imageTimeout: 3e4,
|
|
1536
|
+
logging: false,
|
|
1537
|
+
allowTaint: false,
|
|
1538
|
+
useCORS: true,
|
|
1539
|
+
scrollY: 0,
|
|
1540
|
+
ignoreElements: (el) => Array.from(el.classList).some(
|
|
1541
|
+
(c) => c.startsWith("_DraggableComponent--hover") || c.startsWith("_ActionBar")
|
|
1542
|
+
)
|
|
1543
|
+
});
|
|
1544
|
+
const image = canvas.toDataURL("image/webp", 0.8);
|
|
1545
|
+
const blob = await (await fetch(image)).blob();
|
|
1546
|
+
await fetch(bucketUrl, {
|
|
1547
|
+
method: "PUT",
|
|
1548
|
+
body: blob
|
|
1549
|
+
});
|
|
1550
|
+
},
|
|
1551
|
+
[]
|
|
1552
|
+
);
|
|
1524
1553
|
const processData = (0, import_react22.useCallback)(
|
|
1525
1554
|
(dataPart) => {
|
|
1526
1555
|
switch (dataPart.type) {
|
|
@@ -1561,6 +1590,14 @@ function Chat2({ chat, host = "/api/puck/chat" }) {
|
|
|
1561
1590
|
}));
|
|
1562
1591
|
return;
|
|
1563
1592
|
}
|
|
1593
|
+
case "data-send-screenshot": {
|
|
1594
|
+
dataPart.data.urls.map((obj) => {
|
|
1595
|
+
const [[key, value]] = Object.entries(obj);
|
|
1596
|
+
const breakpoint = Number(key);
|
|
1597
|
+
uploadScreenshot(breakpoint, value);
|
|
1598
|
+
});
|
|
1599
|
+
return;
|
|
1600
|
+
}
|
|
1564
1601
|
default:
|
|
1565
1602
|
console.warn("dataPart without case:", dataPart);
|
|
1566
1603
|
return;
|
|
@@ -1713,7 +1750,7 @@ function Placeholder({
|
|
|
1713
1750
|
};
|
|
1714
1751
|
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: getClassName17("placeholder"), children: [
|
|
1715
1752
|
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Bot, { size: "24" }),
|
|
1716
|
-
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { children: "Use AI to build a page using
|
|
1753
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { children: "Use AI to build a page using the available blocks" }),
|
|
1717
1754
|
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: getClassName17("actions"), children: [
|
|
1718
1755
|
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
1719
1756
|
"button",
|
package/dist/index.mjs
CHANGED
|
@@ -1504,6 +1504,7 @@ var dispatchOp = (operation, {
|
|
|
1504
1504
|
};
|
|
1505
1505
|
|
|
1506
1506
|
// src/components/Chat/index.tsx
|
|
1507
|
+
import html2canvas from "html2canvas-pro";
|
|
1507
1508
|
import { jsx as jsx27, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
1508
1509
|
var q = qler();
|
|
1509
1510
|
var BENCHMARK = false;
|
|
@@ -1519,6 +1520,34 @@ function Chat2({ chat, host = "/api/puck/chat" }) {
|
|
|
1519
1520
|
const pluginRef = useRef8(null);
|
|
1520
1521
|
const [error, setError] = useState12();
|
|
1521
1522
|
const [toolStatus, setToolStatus] = useState12({});
|
|
1523
|
+
const uploadScreenshot = useCallback4(
|
|
1524
|
+
async (width, bucketUrl) => {
|
|
1525
|
+
const iframeDocument = document?.getElementById("preview-frame")?.contentDocument?.documentElement ?? null;
|
|
1526
|
+
if (!iframeDocument) return;
|
|
1527
|
+
const canvas = await html2canvas(iframeDocument, {
|
|
1528
|
+
scale: 2,
|
|
1529
|
+
backgroundColor: "#ffffff",
|
|
1530
|
+
width,
|
|
1531
|
+
windowWidth: width,
|
|
1532
|
+
foreignObjectRendering: false,
|
|
1533
|
+
imageTimeout: 3e4,
|
|
1534
|
+
logging: false,
|
|
1535
|
+
allowTaint: false,
|
|
1536
|
+
useCORS: true,
|
|
1537
|
+
scrollY: 0,
|
|
1538
|
+
ignoreElements: (el) => Array.from(el.classList).some(
|
|
1539
|
+
(c) => c.startsWith("_DraggableComponent--hover") || c.startsWith("_ActionBar")
|
|
1540
|
+
)
|
|
1541
|
+
});
|
|
1542
|
+
const image = canvas.toDataURL("image/webp", 0.8);
|
|
1543
|
+
const blob = await (await fetch(image)).blob();
|
|
1544
|
+
await fetch(bucketUrl, {
|
|
1545
|
+
method: "PUT",
|
|
1546
|
+
body: blob
|
|
1547
|
+
});
|
|
1548
|
+
},
|
|
1549
|
+
[]
|
|
1550
|
+
);
|
|
1522
1551
|
const processData = useCallback4(
|
|
1523
1552
|
(dataPart) => {
|
|
1524
1553
|
switch (dataPart.type) {
|
|
@@ -1559,6 +1588,14 @@ function Chat2({ chat, host = "/api/puck/chat" }) {
|
|
|
1559
1588
|
}));
|
|
1560
1589
|
return;
|
|
1561
1590
|
}
|
|
1591
|
+
case "data-send-screenshot": {
|
|
1592
|
+
dataPart.data.urls.map((obj) => {
|
|
1593
|
+
const [[key, value]] = Object.entries(obj);
|
|
1594
|
+
const breakpoint = Number(key);
|
|
1595
|
+
uploadScreenshot(breakpoint, value);
|
|
1596
|
+
});
|
|
1597
|
+
return;
|
|
1598
|
+
}
|
|
1562
1599
|
default:
|
|
1563
1600
|
console.warn("dataPart without case:", dataPart);
|
|
1564
1601
|
return;
|
|
@@ -1711,7 +1748,7 @@ function Placeholder({
|
|
|
1711
1748
|
};
|
|
1712
1749
|
return /* @__PURE__ */ jsxs14("div", { className: getClassName17("placeholder"), children: [
|
|
1713
1750
|
/* @__PURE__ */ jsx27(Bot, { size: "24" }),
|
|
1714
|
-
/* @__PURE__ */ jsx27("div", { children: "Use AI to build a page using
|
|
1751
|
+
/* @__PURE__ */ jsx27("div", { children: "Use AI to build a page using the available blocks" }),
|
|
1715
1752
|
/* @__PURE__ */ jsxs14("div", { className: getClassName17("actions"), children: [
|
|
1716
1753
|
/* @__PURE__ */ jsx27(
|
|
1717
1754
|
"button",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@puckeditor/plugin-ai",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0-canary.d4331212",
|
|
4
4
|
"author": "Chris Villa <chris@puckeditor.com>",
|
|
5
5
|
"repository": "puckeditor/puck",
|
|
6
6
|
"bugs": "https://github.com/puckeditor/puck/issues",
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
],
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"ai": "^5.0.29",
|
|
31
|
+
"html2canvas-pro": "^1.5.13",
|
|
31
32
|
"qler": "^0.6.2",
|
|
32
33
|
"react-markdown": "^10.1.0",
|
|
33
34
|
"react-textarea-autosize": "^8.5.9",
|
|
@@ -36,7 +37,7 @@
|
|
|
36
37
|
},
|
|
37
38
|
"devDependencies": {
|
|
38
39
|
"@ai-sdk/react": "^2.0.29",
|
|
39
|
-
"@measured/puck": "0.21.0-canary.
|
|
40
|
+
"@measured/puck": "0.21.0-canary.17395b2c",
|
|
40
41
|
"@puckeditor/ai-types": "workspace:*",
|
|
41
42
|
"@puckeditor/platform-types": "workspace:*",
|
|
42
43
|
"@types/jest": "^30.0.0",
|
|
@@ -53,7 +54,7 @@
|
|
|
53
54
|
"typescript": "^5.5.4"
|
|
54
55
|
},
|
|
55
56
|
"peerDependencies": {
|
|
56
|
-
"@measured/puck": "0.21.0-canary.
|
|
57
|
+
"@measured/puck": "0.21.0-canary.17395b2c",
|
|
57
58
|
"react": "^18.0.0 || ^19.0.0"
|
|
58
59
|
}
|
|
59
60
|
}
|