puckeditor-plugin-ai 0.6.5 → 0.6.7
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 +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +80 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +80 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -189,6 +189,11 @@ type AiSettings = {
|
|
|
189
189
|
urlContext: boolean;
|
|
190
190
|
googleSearch: boolean;
|
|
191
191
|
enterpriseWebSearch: boolean;
|
|
192
|
+
/**
|
|
193
|
+
* When migrating from a page URL, run the full browser pipeline (DOM bundle + structured IR).
|
|
194
|
+
* Slower and uses more Worker time; leave off for screenshot-only + Vertex url_context.
|
|
195
|
+
*/
|
|
196
|
+
pageMigrationIr: boolean;
|
|
192
197
|
figmaToken: string;
|
|
193
198
|
};
|
|
194
199
|
type AiPluginProps = {
|
package/dist/index.d.ts
CHANGED
|
@@ -189,6 +189,11 @@ type AiSettings = {
|
|
|
189
189
|
urlContext: boolean;
|
|
190
190
|
googleSearch: boolean;
|
|
191
191
|
enterpriseWebSearch: boolean;
|
|
192
|
+
/**
|
|
193
|
+
* When migrating from a page URL, run the full browser pipeline (DOM bundle + structured IR).
|
|
194
|
+
* Slower and uses more Worker time; leave off for screenshot-only + Vertex url_context.
|
|
195
|
+
*/
|
|
196
|
+
pageMigrationIr: boolean;
|
|
192
197
|
figmaToken: string;
|
|
193
198
|
};
|
|
194
199
|
type AiPluginProps = {
|
package/dist/index.js
CHANGED
|
@@ -323,11 +323,29 @@ function filesToAttachedImages(files) {
|
|
|
323
323
|
return results;
|
|
324
324
|
});
|
|
325
325
|
}
|
|
326
|
+
function mediaTypeFromDataUrl(dataUrl) {
|
|
327
|
+
if (!dataUrl.startsWith("data:")) return "application/octet-stream";
|
|
328
|
+
const rest = dataUrl.slice(5);
|
|
329
|
+
const semi = rest.indexOf(";");
|
|
330
|
+
const comma = rest.indexOf(",");
|
|
331
|
+
const end = semi === -1 ? comma : semi;
|
|
332
|
+
if (end <= 0) return "application/octet-stream";
|
|
333
|
+
return rest.slice(0, end) || "application/octet-stream";
|
|
334
|
+
}
|
|
335
|
+
function attachedImageToFileUIPart(img) {
|
|
336
|
+
return {
|
|
337
|
+
type: "file",
|
|
338
|
+
mediaType: mediaTypeFromDataUrl(img.dataUrl),
|
|
339
|
+
url: img.dataUrl,
|
|
340
|
+
filename: img.name
|
|
341
|
+
};
|
|
342
|
+
}
|
|
326
343
|
var DEFAULT_AI_SETTINGS = {
|
|
327
344
|
thinkingLevel: "none",
|
|
328
345
|
urlContext: false,
|
|
329
346
|
googleSearch: false,
|
|
330
347
|
enterpriseWebSearch: false,
|
|
348
|
+
pageMigrationIr: false,
|
|
331
349
|
figmaToken: ""
|
|
332
350
|
};
|
|
333
351
|
var AI_SETTINGS_STORAGE_KEY = "puck-ai-settings";
|
|
@@ -589,14 +607,32 @@ function FileMessagePart({
|
|
|
589
607
|
}
|
|
590
608
|
);
|
|
591
609
|
}
|
|
592
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "puck-ai-chat-message-file puck-ai-chat-message-file--document", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
610
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "puck-ai-chat-message-file puck-ai-chat-message-file--document", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
611
|
+
"a",
|
|
612
|
+
{
|
|
613
|
+
href: part.url,
|
|
614
|
+
target: "_blank",
|
|
615
|
+
rel: "noopener noreferrer",
|
|
616
|
+
download: part.filename,
|
|
617
|
+
children: (_b = part.filename) != null ? _b : part.mediaType
|
|
618
|
+
}
|
|
619
|
+
) });
|
|
593
620
|
}
|
|
594
|
-
function ReasoningMessagePart({
|
|
621
|
+
function ReasoningMessagePart({
|
|
622
|
+
part
|
|
623
|
+
}) {
|
|
595
624
|
const streaming = part.state === "streaming";
|
|
596
625
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("details", { className: "puck-ai-chat-message-reasoning", open: streaming, children: [
|
|
597
626
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("summary", { className: "puck-ai-chat-message-reasoning-summary", children: [
|
|
598
627
|
"Reasoning",
|
|
599
|
-
streaming ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
628
|
+
streaming ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
629
|
+
"span",
|
|
630
|
+
{
|
|
631
|
+
className: "puck-ai-chat-message-reasoning-streaming",
|
|
632
|
+
"aria-live": "polite",
|
|
633
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Loader, { size: 12 })
|
|
634
|
+
}
|
|
635
|
+
) : null
|
|
600
636
|
] }),
|
|
601
637
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "puck-ai-chat-message-reasoning-body", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_markdown.default, { children: part.text }) })
|
|
602
638
|
] });
|
|
@@ -657,7 +693,8 @@ function DataMessagePart({ part }) {
|
|
|
657
693
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "puck-ai-chat-message-data-summary", children: [
|
|
658
694
|
"Tokens: in ",
|
|
659
695
|
(_b = (_a = d.tokenUsage) == null ? void 0 : _a.inputTokens) != null ? _b : "\u2014",
|
|
660
|
-
" \xB7 out
|
|
696
|
+
" \xB7 out",
|
|
697
|
+
" ",
|
|
661
698
|
(_d = (_c = d.tokenUsage) == null ? void 0 : _c.outputTokens) != null ? _d : "\u2014",
|
|
662
699
|
d.totalCost !== void 0 ? ` \xB7 cost ${d.totalCost}` : ""
|
|
663
700
|
] });
|
|
@@ -1234,6 +1271,27 @@ function SettingsPanel({
|
|
|
1234
1271
|
}
|
|
1235
1272
|
)
|
|
1236
1273
|
] }),
|
|
1274
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "puck-ai-settings-row", children: [
|
|
1275
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
1276
|
+
"label",
|
|
1277
|
+
{
|
|
1278
|
+
className: "puck-ai-settings-label",
|
|
1279
|
+
htmlFor: "puck-ai-page-migration-ir",
|
|
1280
|
+
children: [
|
|
1281
|
+
"Page migration IR",
|
|
1282
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "puck-ai-settings-hint", children: "Full DOM bundle + structured plan when a source URL is captured (slower; screenshot-only when off)" })
|
|
1283
|
+
]
|
|
1284
|
+
}
|
|
1285
|
+
),
|
|
1286
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1287
|
+
Toggle,
|
|
1288
|
+
{
|
|
1289
|
+
id: "puck-ai-page-migration-ir",
|
|
1290
|
+
checked: settings.pageMigrationIr,
|
|
1291
|
+
onChange: (v) => onChange({ pageMigrationIr: v })
|
|
1292
|
+
}
|
|
1293
|
+
)
|
|
1294
|
+
] }),
|
|
1237
1295
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "puck-ai-settings-row", children: [
|
|
1238
1296
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
1239
1297
|
"label",
|
|
@@ -1329,10 +1387,17 @@ function SettingsPanel({
|
|
|
1329
1387
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "puck-ai-settings-section", children: [
|
|
1330
1388
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "puck-ai-settings-section-title", children: "Chat" }),
|
|
1331
1389
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "puck-ai-settings-row puck-ai-settings-row--column", children: [
|
|
1332
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
1333
|
-
"
|
|
1334
|
-
|
|
1335
|
-
|
|
1390
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
1391
|
+
"label",
|
|
1392
|
+
{
|
|
1393
|
+
className: "puck-ai-settings-label",
|
|
1394
|
+
htmlFor: "puck-ai-clear-chat",
|
|
1395
|
+
children: [
|
|
1396
|
+
"Clear chat history",
|
|
1397
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "puck-ai-settings-hint", children: "Remove all messages and reset the conversation context for this session." })
|
|
1398
|
+
]
|
|
1399
|
+
}
|
|
1400
|
+
),
|
|
1336
1401
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
1337
1402
|
"button",
|
|
1338
1403
|
{
|
|
@@ -1481,6 +1546,8 @@ function Chat({
|
|
|
1481
1546
|
if (currentSettings.thinkingLevel !== "none")
|
|
1482
1547
|
geminiConfig.thinkingLevel = currentSettings.thinkingLevel;
|
|
1483
1548
|
if (currentSettings.urlContext) geminiConfig.urlContext = true;
|
|
1549
|
+
if (currentSettings.pageMigrationIr)
|
|
1550
|
+
geminiConfig.pageMigrationIr = true;
|
|
1484
1551
|
if (currentSettings.googleSearch) geminiConfig.googleSearch = true;
|
|
1485
1552
|
if (currentSettings.enterpriseWebSearch)
|
|
1486
1553
|
geminiConfig.enterpriseWebSearch = true;
|
|
@@ -1574,8 +1641,12 @@ function Chat({
|
|
|
1574
1641
|
setError("");
|
|
1575
1642
|
setPromptValue("");
|
|
1576
1643
|
pendingSendImagesRef.current = attachedImages.map((img) => img.dataUrl);
|
|
1644
|
+
const fileParts = attachedImages.map(attachedImageToFileUIPart);
|
|
1577
1645
|
setAttachedImages([]);
|
|
1578
|
-
|
|
1646
|
+
const sendPayload = {};
|
|
1647
|
+
if (text) sendPayload.text = text;
|
|
1648
|
+
if (fileParts.length > 0) sendPayload.files = fileParts;
|
|
1649
|
+
sendMessage(sendPayload).catch((e) => {
|
|
1579
1650
|
console.error(e);
|
|
1580
1651
|
});
|
|
1581
1652
|
};
|