@puckeditor/plugin-ai 0.1.0-canary.4aba31f4 → 0.1.0-canary.4eacddeb
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.css +81 -123
- package/dist/index.js +89 -110
- package/dist/index.mjs +77 -98
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -20672,7 +20672,7 @@ function useChat(_a17 = {}) {
|
|
|
20672
20672
|
|
|
20673
20673
|
// src/components/Chat/index.tsx
|
|
20674
20674
|
import { createUsePuck, useGetPuck } from "@measured/puck";
|
|
20675
|
-
import { useMemo
|
|
20675
|
+
import { useMemo, useRef as useRef6, useState as useState10 } from "react";
|
|
20676
20676
|
import { ulid as ulid3 } from "ulid";
|
|
20677
20677
|
|
|
20678
20678
|
// ../utils/lib/get-class-name-factory.ts
|
|
@@ -21173,28 +21173,12 @@ init_react_import();
|
|
|
21173
21173
|
|
|
21174
21174
|
// css-module:/home/runner/work/puck-platform/puck-platform/packages/platform-client/components/Page/Page.module.css#css-module
|
|
21175
21175
|
init_react_import();
|
|
21176
|
-
var Page_module_default = { "Page": "
|
|
21176
|
+
var Page_module_default = { "Page": "_Page_1uz1e_1", "Page-masthead": "_Page-masthead_1uz1e_8", "Page-crumbs": "_Page-crumbs_1uz1e_18", "Page-crumb": "_Page-crumb_1uz1e_18", "Page-crumbLink": "_Page-crumbLink_1uz1e_28", "Page-actions": "_Page-actions_1uz1e_60" };
|
|
21177
21177
|
|
|
21178
21178
|
// ../platform-client/components/Page/Page.tsx
|
|
21179
21179
|
import { jsx as jsx14, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
21180
21180
|
var cx2 = getClassNameFactory2("Page", Page_module_default);
|
|
21181
21181
|
|
|
21182
|
-
// ../platform-client/components/Pagination/index.ts
|
|
21183
|
-
init_react_import();
|
|
21184
|
-
|
|
21185
|
-
// ../platform-client/components/Pagination/Pagination.tsx
|
|
21186
|
-
init_react_import();
|
|
21187
|
-
import { useMemo } from "react";
|
|
21188
|
-
|
|
21189
|
-
// css-module:/home/runner/work/puck-platform/puck-platform/packages/platform-client/components/Pagination/Pagination.module.css#css-module
|
|
21190
|
-
init_react_import();
|
|
21191
|
-
var Pagination_module_default = { "Pagination": "_Pagination_1okv2_1", "PaginationButton": "_PaginationButton_1okv2_8", "PaginationButton--isActive": "_PaginationButton--isActive_1okv2_20", "Pagination-ellipsis": "_Pagination-ellipsis_1okv2_30" };
|
|
21192
|
-
|
|
21193
|
-
// ../platform-client/components/Pagination/Pagination.tsx
|
|
21194
|
-
import { jsx as jsx15 } from "react/jsx-runtime";
|
|
21195
|
-
var cx3 = getClassNameFactory2("Pagination", Pagination_module_default);
|
|
21196
|
-
var cxButton = getClassNameFactory2("PaginationButton", Pagination_module_default);
|
|
21197
|
-
|
|
21198
21182
|
// ../platform-client/components/Section/index.ts
|
|
21199
21183
|
init_react_import();
|
|
21200
21184
|
|
|
@@ -21206,7 +21190,7 @@ init_react_import();
|
|
|
21206
21190
|
var Section_module_default = { "Section-inner": "_Section-inner_1uwo0_1", "Section--flush": "_Section--flush_1uwo0_8", "Section": "_Section_1uwo0_1", "Section--full": "_Section--full_1uwo0_17" };
|
|
21207
21191
|
|
|
21208
21192
|
// ../platform-client/components/Section/Section.tsx
|
|
21209
|
-
import { jsx as
|
|
21193
|
+
import { jsx as jsx15 } from "react/jsx-runtime";
|
|
21210
21194
|
var getClassName12 = getClassNameFactory2("Section", Section_module_default);
|
|
21211
21195
|
|
|
21212
21196
|
// ../platform-client/components/StatusTag/index.ts
|
|
@@ -21226,25 +21210,25 @@ init_react_import();
|
|
|
21226
21210
|
var Tag_module_default = { "Tag": "_Tag_1baze_1", "Tag--colorBlue": "_Tag--colorBlue_1baze_19", "Tag--colorGreen": "_Tag--colorGreen_1baze_23", "Tag--colorRed": "_Tag--colorRed_1baze_27", "Tag--colorMuted": "_Tag--colorMuted_1baze_31", "Tag-sprite": "_Tag-sprite_1baze_35", "Tag--pulse": "_Tag--pulse_1baze_39", "pulse": "_pulse_1baze_1" };
|
|
21227
21211
|
|
|
21228
21212
|
// ../platform-client/components/Tag/Tag.tsx
|
|
21229
|
-
import { jsx as
|
|
21213
|
+
import { jsx as jsx16, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
21230
21214
|
var getClassName13 = getClassNameFactory2("Tag", Tag_module_default);
|
|
21231
21215
|
|
|
21232
21216
|
// ../platform-client/components/StatusTag/StatusTag.tsx
|
|
21233
|
-
import { jsx as
|
|
21217
|
+
import { jsx as jsx17 } from "react/jsx-runtime";
|
|
21234
21218
|
|
|
21235
21219
|
// ../platform-client/components/Table/index.ts
|
|
21236
21220
|
init_react_import();
|
|
21237
21221
|
|
|
21238
21222
|
// ../platform-client/components/Table/Table.tsx
|
|
21239
21223
|
init_react_import();
|
|
21240
|
-
import {
|
|
21224
|
+
import { useState as useState7 } from "react";
|
|
21241
21225
|
|
|
21242
21226
|
// css-module:/home/runner/work/puck-platform/puck-platform/packages/platform-client/components/Table/Table.module.css#css-module
|
|
21243
21227
|
init_react_import();
|
|
21244
|
-
var Table_module_default = { "Table": "
|
|
21228
|
+
var Table_module_default = { "Table": "_Table_1t44j_1", "Table-filters": "_Table-filters_1t44j_8", "Table-inner": "_Table-inner_1t44j_12", "Table-table": "_Table-table_1t44j_16", "Table-footer": "_Table-footer_1t44j_78", "Table--clickableRows": "_Table--clickableRows_1t44j_82", "Table-placeholder": "_Table-placeholder_1t44j_87" };
|
|
21245
21229
|
|
|
21246
21230
|
// ../platform-client/components/Table/Table.tsx
|
|
21247
|
-
import { jsx as
|
|
21231
|
+
import { jsx as jsx18, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
21248
21232
|
var getClassName14 = get_class_name_factory_default("Table", Table_module_default);
|
|
21249
21233
|
|
|
21250
21234
|
// ../platform-client/components/Textarea/index.tsx
|
|
@@ -21262,24 +21246,24 @@ init_react_import();
|
|
|
21262
21246
|
var VerticalSpace_module_default = { "VerticalSpace": "_VerticalSpace_1tjaw_1", "VerticalSpace--size4": "_VerticalSpace--size4_1tjaw_5", "VerticalSpace--size8": "_VerticalSpace--size8_1tjaw_9", "VerticalSpace--size16": "_VerticalSpace--size16_1tjaw_13", "VerticalSpace--size32": "_VerticalSpace--size32_1tjaw_17", "VerticalSpace--size40": "_VerticalSpace--size40_1tjaw_21", "VerticalSpace--size48": "_VerticalSpace--size48_1tjaw_25", "VerticalSpace--size56": "_VerticalSpace--size56_1tjaw_29", "VerticalSpace--size96": "_VerticalSpace--size96_1tjaw_33", "VerticalSpace--size128": "_VerticalSpace--size128_1tjaw_37" };
|
|
21263
21247
|
|
|
21264
21248
|
// ../platform-client/components/VerticalSpace/VerticalSpace.tsx
|
|
21265
|
-
import { jsx as
|
|
21249
|
+
import { jsx as jsx19 } from "react/jsx-runtime";
|
|
21266
21250
|
var getClassName15 = get_class_name_factory_default("VerticalSpace", VerticalSpace_module_default);
|
|
21267
21251
|
|
|
21268
21252
|
// ../platform-client/context/editor.tsx
|
|
21269
21253
|
init_react_import();
|
|
21270
21254
|
import { createContext as createContext2, useContext as useContext2, useState as useState8 } from "react";
|
|
21271
|
-
import { jsx as
|
|
21255
|
+
import { jsx as jsx20 } from "react/jsx-runtime";
|
|
21272
21256
|
var ctx = createContext2({});
|
|
21273
21257
|
|
|
21274
21258
|
// css-module:/home/runner/work/puck-platform/puck-platform/packages/plugin-ai/src/components/ChatBody/styles.module.css#css-module
|
|
21275
21259
|
init_react_import();
|
|
21276
|
-
var styles_module_default3 = { "Chat": "
|
|
21260
|
+
var styles_module_default3 = { "Chat": "_Chat_14j71_1", "Chat-inner": "_Chat-inner_14j71_17", "Chat--hasMessages": "_Chat--hasMessages_14j71_25", "Chat--hasChildren": "_Chat--hasChildren_14j71_29", "Chat-messages": "_Chat-messages_14j71_34", "Chat-form": "_Chat-form_14j71_41", "Chat--hideInput": "_Chat--hideInput_14j71_46", "Chat-formHelper": "_Chat-formHelper_14j71_60", "Chat-examplePrompts": "_Chat-examplePrompts_14j71_75", "Chat-examplePrompt": "_Chat-examplePrompt_14j71_75", "Chat-examplePromptArrow": "_Chat-examplePromptArrow_14j71_103", "Chat-default": "_Chat-default_14j71_107", "ChatMessage": "_ChatMessage_14j71_124", "ChatMessage--userRole": "_ChatMessage--userRole_14j71_129", "ChatMessage-text": "_ChatMessage-text_14j71_129", "ChatMessage-data": "_ChatMessage-data_14j71_219", "ChatMessage-dataInner": "_ChatMessage-dataInner_14j71_230", "ChatMessage-dataIcon": "_ChatMessage-dataIcon_14j71_236", "Chat-loader": "_Chat-loader_14j71_240", "Chat-error": "_Chat-error_14j71_245", "Chat-errorLabel": "_Chat-errorLabel_14j71_254", "Chat-errorAction": "_Chat-errorAction_14j71_258" };
|
|
21277
21261
|
|
|
21278
21262
|
// src/components/PromptForm/index.tsx
|
|
21279
21263
|
init_react_import();
|
|
21280
21264
|
import {
|
|
21281
|
-
useEffect as
|
|
21282
|
-
useRef as
|
|
21265
|
+
useEffect as useEffect6,
|
|
21266
|
+
useRef as useRef5,
|
|
21283
21267
|
useState as useState9
|
|
21284
21268
|
} from "react";
|
|
21285
21269
|
|
|
@@ -21288,8 +21272,8 @@ init_react_import();
|
|
|
21288
21272
|
var styles_module_default4 = { "PromptForm": "_PromptForm_136g1_1", "PromptForm-inner": "_PromptForm-inner_136g1_8", "PromptForm--dark": "_PromptForm--dark_136g1_14", "PromptForm--glow": "_PromptForm--glow_136g1_19", "PromptForm-glow": "_PromptForm-glow_136g1_19", "loop": "_loop_136g1_1", "PromptForm-formInner": "_PromptForm-formInner_136g1_60", "PromptForm-input": "_PromptForm-input_136g1_64", "PromptForm--disabled": "_PromptForm--disabled_136g1_92", "PromptForm-helper": "_PromptForm-helper_136g1_97", "PromptForm-actions": "_PromptForm-actions_136g1_107", "PromptForm-actionsLeft": "_PromptForm-actionsLeft_136g1_118", "PromptForm-actionsRight": "_PromptForm-actionsRight_136g1_124", "PromptForm-actionSubmit": "_PromptForm-actionSubmit_136g1_128", "PromptForm--isDisabled": "_PromptForm--isDisabled_136g1_147", "PromptForm--isLoading": "_PromptForm--isLoading_136g1_152" };
|
|
21289
21273
|
|
|
21290
21274
|
// src/components/PromptForm/index.tsx
|
|
21291
|
-
import { jsx as
|
|
21292
|
-
var
|
|
21275
|
+
import { jsx as jsx21, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
21276
|
+
var cx3 = getClassNameFactory2("PromptForm", styles_module_default4);
|
|
21293
21277
|
function PromptForm({
|
|
21294
21278
|
actions,
|
|
21295
21279
|
colorScheme = "light",
|
|
@@ -21301,7 +21285,7 @@ function PromptForm({
|
|
|
21301
21285
|
isLoading,
|
|
21302
21286
|
placeholder = "Create a page for..."
|
|
21303
21287
|
}) {
|
|
21304
|
-
const hasSetInitialPrompt =
|
|
21288
|
+
const hasSetInitialPrompt = useRef5(false);
|
|
21305
21289
|
const [prompt, setPrompt] = useState9("");
|
|
21306
21290
|
const sendPrompt = () => {
|
|
21307
21291
|
if (isLoading || isDisabled) return;
|
|
@@ -21310,7 +21294,7 @@ function PromptForm({
|
|
|
21310
21294
|
}
|
|
21311
21295
|
setPrompt("");
|
|
21312
21296
|
};
|
|
21313
|
-
|
|
21297
|
+
useEffect6(() => {
|
|
21314
21298
|
const currentUrl = new URL(location.href);
|
|
21315
21299
|
const initialPrompt = currentUrl.searchParams.get("initialPrompt");
|
|
21316
21300
|
if (!hasSetInitialPrompt.current && initialPrompt && prompt === "") {
|
|
@@ -21321,28 +21305,28 @@ function PromptForm({
|
|
|
21321
21305
|
return /* @__PURE__ */ jsxs11(
|
|
21322
21306
|
"div",
|
|
21323
21307
|
{
|
|
21324
|
-
className:
|
|
21308
|
+
className: cx3({
|
|
21325
21309
|
isDisabled,
|
|
21326
21310
|
isLoading,
|
|
21327
21311
|
dark: colorScheme === "dark",
|
|
21328
21312
|
glow
|
|
21329
21313
|
}),
|
|
21330
21314
|
children: [
|
|
21331
|
-
helperText ? /* @__PURE__ */
|
|
21332
|
-
/* @__PURE__ */ jsxs11("div", { className:
|
|
21333
|
-
/* @__PURE__ */
|
|
21334
|
-
/* @__PURE__ */
|
|
21315
|
+
helperText ? /* @__PURE__ */ jsx21("div", { className: cx3("helper"), children: helperText }) : null,
|
|
21316
|
+
/* @__PURE__ */ jsxs11("div", { className: cx3("inner"), children: [
|
|
21317
|
+
/* @__PURE__ */ jsx21("span", { className: cx3("glow") }),
|
|
21318
|
+
/* @__PURE__ */ jsx21(
|
|
21335
21319
|
"form",
|
|
21336
21320
|
{
|
|
21337
21321
|
onSubmit: (e) => {
|
|
21338
21322
|
e.preventDefault();
|
|
21339
21323
|
sendPrompt();
|
|
21340
21324
|
},
|
|
21341
|
-
children: /* @__PURE__ */ jsxs11("div", { className:
|
|
21342
|
-
/* @__PURE__ */
|
|
21325
|
+
children: /* @__PURE__ */ jsxs11("div", { className: cx3("formInner"), children: [
|
|
21326
|
+
/* @__PURE__ */ jsx21(
|
|
21343
21327
|
default2,
|
|
21344
21328
|
{
|
|
21345
|
-
className:
|
|
21329
|
+
className: cx3("input"),
|
|
21346
21330
|
name: "prompt",
|
|
21347
21331
|
minRows: 2,
|
|
21348
21332
|
placeholder,
|
|
@@ -21363,15 +21347,15 @@ function PromptForm({
|
|
|
21363
21347
|
}
|
|
21364
21348
|
}
|
|
21365
21349
|
),
|
|
21366
|
-
/* @__PURE__ */ jsxs11("div", { className:
|
|
21367
|
-
/* @__PURE__ */
|
|
21368
|
-
/* @__PURE__ */
|
|
21350
|
+
/* @__PURE__ */ jsxs11("div", { className: cx3("actions"), children: [
|
|
21351
|
+
/* @__PURE__ */ jsx21("div", { className: cx3("actionsLeft"), children: actions }),
|
|
21352
|
+
/* @__PURE__ */ jsx21("div", { className: cx3("actionsRight"), children: /* @__PURE__ */ jsx21(
|
|
21369
21353
|
"button",
|
|
21370
21354
|
{
|
|
21371
|
-
className:
|
|
21355
|
+
className: cx3("actionSubmit"),
|
|
21372
21356
|
type: "submit",
|
|
21373
21357
|
disabled: isLoading,
|
|
21374
|
-
children: /* @__PURE__ */
|
|
21358
|
+
children: /* @__PURE__ */ jsx21(ArrowUp, {})
|
|
21375
21359
|
}
|
|
21376
21360
|
) })
|
|
21377
21361
|
] })
|
|
@@ -21391,8 +21375,8 @@ var toolStatusContext = createContext3({});
|
|
|
21391
21375
|
var ToolStatusProvider = toolStatusContext.Provider;
|
|
21392
21376
|
|
|
21393
21377
|
// src/components/ChatBody/index.tsx
|
|
21394
|
-
import { jsx as
|
|
21395
|
-
var
|
|
21378
|
+
import { jsx as jsx22, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
21379
|
+
var cx4 = getClassNameFactory2("Chat", styles_module_default3);
|
|
21396
21380
|
var cxMessage = getClassNameFactory2("ChatMessage", styles_module_default3);
|
|
21397
21381
|
function ChatBody({
|
|
21398
21382
|
children,
|
|
@@ -21407,17 +21391,17 @@ function ChatBody({
|
|
|
21407
21391
|
}) {
|
|
21408
21392
|
const { scrollRef, contentRef } = useStickToBottom();
|
|
21409
21393
|
const hasMessages = messages && messages.length > 0;
|
|
21410
|
-
return /* @__PURE__ */ jsxs12("div", { className:
|
|
21411
|
-
children ? /* @__PURE__ */
|
|
21412
|
-
/* @__PURE__ */ jsxs12("div", { className:
|
|
21413
|
-
/* @__PURE__ */
|
|
21414
|
-
status === "submitted" && /* @__PURE__ */
|
|
21415
|
-
error45 && /* @__PURE__ */ jsxs12("div", { className:
|
|
21416
|
-
/* @__PURE__ */
|
|
21417
|
-
handleRetry && /* @__PURE__ */
|
|
21394
|
+
return /* @__PURE__ */ jsxs12("div", { className: cx4({ hasMessages, hasChildren: !!children, hideInput }), children: [
|
|
21395
|
+
children ? /* @__PURE__ */ jsx22("div", { className: cx4("default"), children }) : null,
|
|
21396
|
+
/* @__PURE__ */ jsxs12("div", { className: cx4("inner"), ref: scrollRef, children: [
|
|
21397
|
+
/* @__PURE__ */ jsx22("div", { className: cx4("messages"), ref: contentRef, children: messages.toReversed().map((message) => /* @__PURE__ */ jsx22(ChatMessage, { message }, message.id)) }),
|
|
21398
|
+
status === "submitted" && /* @__PURE__ */ jsx22("div", { className: cx4("loader"), children: /* @__PURE__ */ jsx22(Loader, { size: 14 }) }),
|
|
21399
|
+
error45 && /* @__PURE__ */ jsxs12("div", { className: cx4("error"), children: [
|
|
21400
|
+
/* @__PURE__ */ jsx22("div", { className: cx4("errorLabel"), children: "Something went wrong." }),
|
|
21401
|
+
handleRetry && /* @__PURE__ */ jsx22("div", { className: cx4("errorAction"), children: /* @__PURE__ */ jsx22(IconButton, { title: "Retry", onClick: handleRetry, children: /* @__PURE__ */ jsx22(RotateCcw, { size: "14" }) }) })
|
|
21418
21402
|
] }),
|
|
21419
|
-
/* @__PURE__ */ jsxs12("div", { className:
|
|
21420
|
-
/* @__PURE__ */
|
|
21403
|
+
/* @__PURE__ */ jsxs12("div", { className: cx4("form"), children: [
|
|
21404
|
+
/* @__PURE__ */ jsx22(
|
|
21421
21405
|
PromptForm,
|
|
21422
21406
|
{
|
|
21423
21407
|
glow: !hasMessages,
|
|
@@ -21427,19 +21411,19 @@ function ChatBody({
|
|
|
21427
21411
|
placeholder: "What do you want to build?"
|
|
21428
21412
|
}
|
|
21429
21413
|
),
|
|
21430
|
-
examplePrompts ? /* @__PURE__ */
|
|
21414
|
+
examplePrompts ? /* @__PURE__ */ jsx22("div", { className: cx4("examplePrompts"), children: examplePrompts }) : null
|
|
21431
21415
|
] })
|
|
21432
21416
|
] })
|
|
21433
21417
|
] });
|
|
21434
21418
|
}
|
|
21435
21419
|
function ChatMessage({ message }) {
|
|
21436
21420
|
const { role, parts } = message;
|
|
21437
|
-
return /* @__PURE__ */
|
|
21421
|
+
return /* @__PURE__ */ jsx22(
|
|
21438
21422
|
"div",
|
|
21439
21423
|
{
|
|
21440
21424
|
className: cxMessage({ [`${role}Role`]: true }),
|
|
21441
21425
|
"data-message-id": message.id,
|
|
21442
|
-
children: parts.map((part, i) => /* @__PURE__ */
|
|
21426
|
+
children: parts.map((part, i) => /* @__PURE__ */ jsx22(
|
|
21443
21427
|
ChatMessagePart,
|
|
21444
21428
|
{
|
|
21445
21429
|
part,
|
|
@@ -21455,25 +21439,25 @@ function ChatMessageWrapper({
|
|
|
21455
21439
|
role
|
|
21456
21440
|
}) {
|
|
21457
21441
|
if (role === "assistant") {
|
|
21458
|
-
return /* @__PURE__ */
|
|
21442
|
+
return /* @__PURE__ */ jsx22(Markdown, { children });
|
|
21459
21443
|
}
|
|
21460
|
-
return /* @__PURE__ */
|
|
21444
|
+
return /* @__PURE__ */ jsx22("span", { children });
|
|
21461
21445
|
}
|
|
21462
21446
|
function ChatMessagePart({
|
|
21463
21447
|
part,
|
|
21464
21448
|
role
|
|
21465
21449
|
}) {
|
|
21466
21450
|
if (part.type === "text") {
|
|
21467
|
-
return /* @__PURE__ */
|
|
21451
|
+
return /* @__PURE__ */ jsx22("div", { className: cxMessage("text"), children: /* @__PURE__ */ jsx22(ChatMessageWrapper, { role, children: part.text }) });
|
|
21468
21452
|
}
|
|
21469
21453
|
if (part.type === "tool-createPage") {
|
|
21470
|
-
return /* @__PURE__ */
|
|
21454
|
+
return /* @__PURE__ */ jsx22(PuckTool, __spreadValues({}, part));
|
|
21471
21455
|
}
|
|
21472
21456
|
if (part.type === "tool-updatePage") {
|
|
21473
|
-
return /* @__PURE__ */
|
|
21457
|
+
return /* @__PURE__ */ jsx22(PuckTool, __spreadValues({}, part));
|
|
21474
21458
|
}
|
|
21475
21459
|
if (part.type === "tool-userTool") {
|
|
21476
|
-
return /* @__PURE__ */
|
|
21460
|
+
return /* @__PURE__ */ jsx22(PuckTool, __spreadValues({}, part));
|
|
21477
21461
|
}
|
|
21478
21462
|
return null;
|
|
21479
21463
|
}
|
|
@@ -21485,27 +21469,27 @@ function PuckTool({
|
|
|
21485
21469
|
const toolStatus = useContext3(toolStatusContext)[toolCallId];
|
|
21486
21470
|
const outputObj = output;
|
|
21487
21471
|
const status = outputObj && "status" in outputObj ? outputObj.status : toolStatus != null ? toolStatus : { loading: true, label: defaultLabel };
|
|
21488
|
-
return /* @__PURE__ */
|
|
21472
|
+
return /* @__PURE__ */ jsx22(ToolStatus, { status });
|
|
21489
21473
|
}
|
|
21490
21474
|
function ToolStatus({ status }) {
|
|
21491
|
-
return /* @__PURE__ */
|
|
21492
|
-
/* @__PURE__ */
|
|
21493
|
-
/* @__PURE__ */
|
|
21475
|
+
return /* @__PURE__ */ jsx22("div", { className: cxMessage("data"), children: /* @__PURE__ */ jsxs12("div", { className: cxMessage("dataInner"), children: [
|
|
21476
|
+
/* @__PURE__ */ jsx22("div", { className: cxMessage("dataIcon"), children: status.error ? /* @__PURE__ */ jsx22(TriangleAlert, { size: 18 }) : status.loading ? /* @__PURE__ */ jsx22(Loader, { size: 16 }) : /* @__PURE__ */ jsx22(Check, { size: 18 }) }),
|
|
21477
|
+
/* @__PURE__ */ jsx22("div", { children: status.label })
|
|
21494
21478
|
] }) });
|
|
21495
21479
|
}
|
|
21496
21480
|
function ExamplePrompt({
|
|
21497
21481
|
label,
|
|
21498
21482
|
href
|
|
21499
21483
|
}) {
|
|
21500
|
-
return /* @__PURE__ */ jsxs12("a", { className:
|
|
21501
|
-
/* @__PURE__ */
|
|
21502
|
-
/* @__PURE__ */
|
|
21484
|
+
return /* @__PURE__ */ jsxs12("a", { className: cx4("examplePrompt"), href, children: [
|
|
21485
|
+
/* @__PURE__ */ jsx22("div", { children: label }),
|
|
21486
|
+
/* @__PURE__ */ jsx22("div", { className: cx4("examplePromptArrow"), children: /* @__PURE__ */ jsx22(ArrowRight, { size: "16" }) })
|
|
21503
21487
|
] });
|
|
21504
21488
|
}
|
|
21505
21489
|
|
|
21506
21490
|
// src/components/Chat/index.tsx
|
|
21507
21491
|
import qler from "qler";
|
|
21508
|
-
import { jsx as
|
|
21492
|
+
import { jsx as jsx23, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
21509
21493
|
var q = qler();
|
|
21510
21494
|
var BENCHMARK = false;
|
|
21511
21495
|
var prefixedUlid = (prefix = "") => `${prefix ? `${prefix}_` : ""}${ulid3()}`;
|
|
@@ -21519,9 +21503,9 @@ function Chat2({
|
|
|
21519
21503
|
}) {
|
|
21520
21504
|
const puckDispatch = usePuck((s) => s.dispatch);
|
|
21521
21505
|
const getPuck = useGetPuck();
|
|
21522
|
-
const localChatId =
|
|
21523
|
-
const inputRef =
|
|
21524
|
-
const pluginRef =
|
|
21506
|
+
const localChatId = useRef6(chatId);
|
|
21507
|
+
const inputRef = useRef6(null);
|
|
21508
|
+
const pluginRef = useRef6(null);
|
|
21525
21509
|
const [error45, setError] = useState10();
|
|
21526
21510
|
const [toolStatus, setToolStatus] = useState10({});
|
|
21527
21511
|
const { messages, status, sendMessage, regenerate } = useChat({
|
|
@@ -21577,7 +21561,6 @@ function Chat2({
|
|
|
21577
21561
|
case "data-build-op": {
|
|
21578
21562
|
const data = dataPart.data;
|
|
21579
21563
|
q.queue(() => {
|
|
21580
|
-
var _a17, _b, _c, _d;
|
|
21581
21564
|
const puckDispatch2 = getPuck().dispatch;
|
|
21582
21565
|
try {
|
|
21583
21566
|
if (data.op === "add") {
|
|
@@ -21624,13 +21607,11 @@ function Chat2({
|
|
|
21624
21607
|
recordHistory: false
|
|
21625
21608
|
});
|
|
21626
21609
|
} else if (data.op === "updateRoot") {
|
|
21627
|
-
const
|
|
21628
|
-
const existing = appState.data.root;
|
|
21629
|
-
const defaultProps = (_b = (_a17 = config2.root) == null ? void 0 : _a17.defaultProps) != null ? _b : {};
|
|
21610
|
+
const existing = getPuck().appState.data.root;
|
|
21630
21611
|
puckDispatch2({
|
|
21631
21612
|
type: "replaceRoot",
|
|
21632
21613
|
root: __spreadProps(__spreadValues({}, existing), {
|
|
21633
|
-
props: __spreadValues(__spreadValues(
|
|
21614
|
+
props: __spreadValues(__spreadValues({}, existing.props), data.props)
|
|
21634
21615
|
}),
|
|
21635
21616
|
recordHistory: false
|
|
21636
21617
|
});
|
|
@@ -21676,11 +21657,9 @@ function Chat2({
|
|
|
21676
21657
|
recordHistory: false
|
|
21677
21658
|
});
|
|
21678
21659
|
} else if (data.op === "reset") {
|
|
21679
|
-
const { config: config2 } = getPuck();
|
|
21680
|
-
const defaultRootProps = (_d = (_c = config2.root) == null ? void 0 : _c.defaultProps) != null ? _d : {};
|
|
21681
21660
|
puckDispatch2({
|
|
21682
21661
|
type: "setData",
|
|
21683
|
-
data: { content: [], root:
|
|
21662
|
+
data: { content: [], root: {} },
|
|
21684
21663
|
recordHistory: false
|
|
21685
21664
|
});
|
|
21686
21665
|
} else {
|
|
@@ -21733,7 +21712,7 @@ function Chat2({
|
|
|
21733
21712
|
console.error(e);
|
|
21734
21713
|
});
|
|
21735
21714
|
};
|
|
21736
|
-
const messagesWithStatuses =
|
|
21715
|
+
const messagesWithStatuses = useMemo(() => {
|
|
21737
21716
|
return messages.map((msg) => {
|
|
21738
21717
|
return __spreadProps(__spreadValues({}, msg), {
|
|
21739
21718
|
parts: msg.parts.map((part) => {
|
|
@@ -21746,21 +21725,21 @@ function Chat2({
|
|
|
21746
21725
|
});
|
|
21747
21726
|
}, [messages, toolStatus]);
|
|
21748
21727
|
return /* @__PURE__ */ jsxs13("div", { className: getClassName16(), ref: pluginRef, children: [
|
|
21749
|
-
/* @__PURE__ */
|
|
21750
|
-
/* @__PURE__ */
|
|
21728
|
+
/* @__PURE__ */ jsx23("div", { className: getClassName16("header"), children: "AI page builder" }),
|
|
21729
|
+
/* @__PURE__ */ jsx23(ToolStatusProvider, { value: toolStatus, children: /* @__PURE__ */ jsx23(
|
|
21751
21730
|
ChatBody,
|
|
21752
21731
|
{
|
|
21753
21732
|
messages: messagesWithStatuses,
|
|
21754
21733
|
handleSubmit,
|
|
21755
21734
|
inputRef,
|
|
21756
21735
|
status,
|
|
21757
|
-
examplePrompts: examplePrompts == null ? void 0 : examplePrompts.map(({ label, href }) => /* @__PURE__ */
|
|
21736
|
+
examplePrompts: examplePrompts == null ? void 0 : examplePrompts.map(({ label, href }) => /* @__PURE__ */ jsx23(ExamplePrompt, { label, href }, label)),
|
|
21758
21737
|
error: error45,
|
|
21759
21738
|
handleRetry: () => {
|
|
21760
21739
|
setError("");
|
|
21761
21740
|
regenerate();
|
|
21762
21741
|
},
|
|
21763
|
-
children: /* @__PURE__ */
|
|
21742
|
+
children: /* @__PURE__ */ jsx23(
|
|
21764
21743
|
Placeholder,
|
|
21765
21744
|
{
|
|
21766
21745
|
dispatch: puckDispatch,
|
|
@@ -21792,10 +21771,10 @@ function Placeholder({
|
|
|
21792
21771
|
}, 10);
|
|
21793
21772
|
};
|
|
21794
21773
|
return /* @__PURE__ */ jsxs13("div", { className: getClassName16("placeholder"), children: [
|
|
21795
|
-
/* @__PURE__ */
|
|
21796
|
-
/* @__PURE__ */
|
|
21774
|
+
/* @__PURE__ */ jsx23(Bot, { size: "24" }),
|
|
21775
|
+
/* @__PURE__ */ jsx23("div", { children: "Use AI to build a page using your own components" }),
|
|
21797
21776
|
/* @__PURE__ */ jsxs13("div", { className: getClassName16("actions"), children: [
|
|
21798
|
-
/* @__PURE__ */
|
|
21777
|
+
/* @__PURE__ */ jsx23(
|
|
21799
21778
|
"button",
|
|
21800
21779
|
{
|
|
21801
21780
|
className: getClassName16("action"),
|
|
@@ -21803,7 +21782,7 @@ function Placeholder({
|
|
|
21803
21782
|
children: "Enter prompt"
|
|
21804
21783
|
}
|
|
21805
21784
|
),
|
|
21806
|
-
/* @__PURE__ */
|
|
21785
|
+
/* @__PURE__ */ jsx23(
|
|
21807
21786
|
"button",
|
|
21808
21787
|
{
|
|
21809
21788
|
className: getClassName16("actionOutlined"),
|
|
@@ -21827,13 +21806,13 @@ function isScrolledIntoView(el) {
|
|
|
21827
21806
|
}
|
|
21828
21807
|
|
|
21829
21808
|
// src/index.tsx
|
|
21830
|
-
import { jsx as
|
|
21809
|
+
import { jsx as jsx24 } from "react/jsx-runtime";
|
|
21831
21810
|
function createAIPlugin(opts) {
|
|
21832
21811
|
return {
|
|
21833
21812
|
label: "AI",
|
|
21834
21813
|
name: "ai",
|
|
21835
|
-
render: () => /* @__PURE__ */
|
|
21836
|
-
icon: /* @__PURE__ */
|
|
21814
|
+
render: () => /* @__PURE__ */ jsx24(Chat2, __spreadValues({}, opts)),
|
|
21815
|
+
icon: /* @__PURE__ */ jsx24(Bot, {}),
|
|
21837
21816
|
mobilePanelHeight: "min-content"
|
|
21838
21817
|
};
|
|
21839
21818
|
}
|
package/package.json
CHANGED