@puckeditor/plugin-ai 0.1.0-canary.f39908a2 → 0.1.0-canary.f56e596d
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 +204 -96
- package/dist/index.js +116 -89
- package/dist/index.mjs +104 -77
- 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, useRef as
|
|
20675
|
+
import { useMemo as useMemo3, useRef as useRef7, useState as useState10 } from "react";
|
|
20676
20676
|
import { ulid as ulid3 } from "ulid";
|
|
20677
20677
|
|
|
20678
20678
|
// ../utils/lib/get-class-name-factory.ts
|
|
@@ -20908,7 +20908,7 @@ init_react_import();
|
|
|
20908
20908
|
|
|
20909
20909
|
// css-module:/home/runner/work/puck-platform/puck-platform/packages/platform-client/components/Heading/Heading.module.css#css-module
|
|
20910
20910
|
init_react_import();
|
|
20911
|
-
var Heading_module_default = { "Heading": "
|
|
20911
|
+
var Heading_module_default = { "Heading": "_Heading_qkzg9_1", "Heading--xxxxl": "_Heading--xxxxl_qkzg9_11", "Heading--xxxl": "_Heading--xxxl_qkzg9_15", "Heading--xxl": "_Heading--xxl_qkzg9_19", "Heading--xl": "_Heading--xl_qkzg9_23", "Heading--l": "_Heading--l_qkzg9_27", "Heading--m": "_Heading--m_qkzg9_31", "Heading--s": "_Heading--s_qkzg9_35", "Heading--xs": "_Heading--xs_qkzg9_39", "Heading--xxs": "_Heading--xxs_qkzg9_43" };
|
|
20912
20912
|
|
|
20913
20913
|
// ../platform-client/components/Heading/Heading.tsx
|
|
20914
20914
|
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
@@ -21173,12 +21173,28 @@ 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_1ajs1_1", "Page-masthead": "_Page-masthead_1ajs1_8", "Page-crumbs": "_Page-crumbs_1ajs1_19", "Page-crumb": "_Page-crumb_1ajs1_19", "Page-crumbLink": "_Page-crumbLink_1ajs1_30", "Page-actions": "_Page-actions_1ajs1_62", "Page-footer": "_Page-footer_1ajs1_66" };
|
|
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
|
+
|
|
21182
21198
|
// ../platform-client/components/Section/index.ts
|
|
21183
21199
|
init_react_import();
|
|
21184
21200
|
|
|
@@ -21190,7 +21206,7 @@ init_react_import();
|
|
|
21190
21206
|
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" };
|
|
21191
21207
|
|
|
21192
21208
|
// ../platform-client/components/Section/Section.tsx
|
|
21193
|
-
import { jsx as
|
|
21209
|
+
import { jsx as jsx16 } from "react/jsx-runtime";
|
|
21194
21210
|
var getClassName12 = getClassNameFactory2("Section", Section_module_default);
|
|
21195
21211
|
|
|
21196
21212
|
// ../platform-client/components/StatusTag/index.ts
|
|
@@ -21210,25 +21226,25 @@ init_react_import();
|
|
|
21210
21226
|
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" };
|
|
21211
21227
|
|
|
21212
21228
|
// ../platform-client/components/Tag/Tag.tsx
|
|
21213
|
-
import { jsx as
|
|
21229
|
+
import { jsx as jsx17, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
21214
21230
|
var getClassName13 = getClassNameFactory2("Tag", Tag_module_default);
|
|
21215
21231
|
|
|
21216
21232
|
// ../platform-client/components/StatusTag/StatusTag.tsx
|
|
21217
|
-
import { jsx as
|
|
21233
|
+
import { jsx as jsx18 } from "react/jsx-runtime";
|
|
21218
21234
|
|
|
21219
21235
|
// ../platform-client/components/Table/index.ts
|
|
21220
21236
|
init_react_import();
|
|
21221
21237
|
|
|
21222
21238
|
// ../platform-client/components/Table/Table.tsx
|
|
21223
21239
|
init_react_import();
|
|
21224
|
-
import { useState as useState7 } from "react";
|
|
21240
|
+
import { useEffect as useEffect6, useMemo as useMemo2, useRef as useRef5, useState as useState7 } from "react";
|
|
21225
21241
|
|
|
21226
21242
|
// css-module:/home/runner/work/puck-platform/puck-platform/packages/platform-client/components/Table/Table.module.css#css-module
|
|
21227
21243
|
init_react_import();
|
|
21228
|
-
var Table_module_default = { "Table": "
|
|
21244
|
+
var Table_module_default = { "Table": "_Table_1w0os_1", "Table-filters": "_Table-filters_1w0os_9", "Table-inner": "_Table-inner_1w0os_13", "Table-table": "_Table-table_1w0os_17", "Table-footer": "_Table-footer_1w0os_85", "Table--clickableRows": "_Table--clickableRows_1w0os_89", "Table-placeholder": "_Table-placeholder_1w0os_94", "Table-loader": "_Table-loader_1w0os_105" };
|
|
21229
21245
|
|
|
21230
21246
|
// ../platform-client/components/Table/Table.tsx
|
|
21231
|
-
import { jsx as
|
|
21247
|
+
import { jsx as jsx19, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
21232
21248
|
var getClassName14 = get_class_name_factory_default("Table", Table_module_default);
|
|
21233
21249
|
|
|
21234
21250
|
// ../platform-client/components/Textarea/index.tsx
|
|
@@ -21246,34 +21262,45 @@ init_react_import();
|
|
|
21246
21262
|
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" };
|
|
21247
21263
|
|
|
21248
21264
|
// ../platform-client/components/VerticalSpace/VerticalSpace.tsx
|
|
21249
|
-
import { jsx as
|
|
21265
|
+
import { jsx as jsx20 } from "react/jsx-runtime";
|
|
21250
21266
|
var getClassName15 = get_class_name_factory_default("VerticalSpace", VerticalSpace_module_default);
|
|
21251
21267
|
|
|
21268
|
+
// ../platform-client/components/Viewport/index.tsx
|
|
21269
|
+
init_react_import();
|
|
21270
|
+
|
|
21271
|
+
// css-module:/home/runner/work/puck-platform/puck-platform/packages/platform-client/components/Viewport/styles.module.css#css-module
|
|
21272
|
+
init_react_import();
|
|
21273
|
+
var styles_module_default3 = { "Viewport": "_Viewport_1vvhm_3", "Viewport--standard": "_Viewport--standard_1vvhm_6", "Viewport--inline": "_Viewport--inline_1vvhm_7", "Viewport--narrow": "_Viewport--narrow_1vvhm_11", "Viewport--flex": "_Viewport--flex_1vvhm_19" };
|
|
21274
|
+
|
|
21275
|
+
// ../platform-client/components/Viewport/index.tsx
|
|
21276
|
+
import { jsx as jsx21 } from "react/jsx-runtime";
|
|
21277
|
+
var cx4 = getClassNameFactory("Viewport", styles_module_default3);
|
|
21278
|
+
|
|
21252
21279
|
// ../platform-client/context/editor.tsx
|
|
21253
21280
|
init_react_import();
|
|
21254
21281
|
import { createContext as createContext2, useContext as useContext2, useState as useState8 } from "react";
|
|
21255
|
-
import { jsx as
|
|
21282
|
+
import { jsx as jsx22 } from "react/jsx-runtime";
|
|
21256
21283
|
var ctx = createContext2({});
|
|
21257
21284
|
|
|
21258
21285
|
// css-module:/home/runner/work/puck-platform/puck-platform/packages/plugin-ai/src/components/ChatBody/styles.module.css#css-module
|
|
21259
21286
|
init_react_import();
|
|
21260
|
-
var
|
|
21287
|
+
var styles_module_default4 = { "Chat": "_Chat_150yz_1", "Chat-inner": "_Chat-inner_150yz_17", "Chat--hasMessages": "_Chat--hasMessages_150yz_25", "Chat--hasChildren": "_Chat--hasChildren_150yz_29", "Chat-messages": "_Chat-messages_150yz_34", "Chat-form": "_Chat-form_150yz_41", "Chat--hideInput": "_Chat--hideInput_150yz_46", "Chat-formHelper": "_Chat-formHelper_150yz_60", "Chat-examplePrompts": "_Chat-examplePrompts_150yz_75", "Chat-examplePrompt": "_Chat-examplePrompt_150yz_75", "Chat-examplePromptArrow": "_Chat-examplePromptArrow_150yz_103", "Chat-default": "_Chat-default_150yz_107", "ChatMessage": "_ChatMessage_150yz_124", "ChatMessage--userRole": "_ChatMessage--userRole_150yz_130", "ChatMessage-text": "_ChatMessage-text_150yz_130", "ChatMessage-data": "_ChatMessage-data_150yz_220", "ChatMessage-dataInner": "_ChatMessage-dataInner_150yz_231", "ChatMessage-dataIcon": "_ChatMessage-dataIcon_150yz_237", "Chat-loader": "_Chat-loader_150yz_241", "Chat-error": "_Chat-error_150yz_246", "Chat-errorLabel": "_Chat-errorLabel_150yz_255", "Chat-errorAction": "_Chat-errorAction_150yz_259" };
|
|
21261
21288
|
|
|
21262
21289
|
// src/components/PromptForm/index.tsx
|
|
21263
21290
|
init_react_import();
|
|
21264
21291
|
import {
|
|
21265
|
-
useEffect as
|
|
21266
|
-
useRef as
|
|
21292
|
+
useEffect as useEffect7,
|
|
21293
|
+
useRef as useRef6,
|
|
21267
21294
|
useState as useState9
|
|
21268
21295
|
} from "react";
|
|
21269
21296
|
|
|
21270
21297
|
// css-module:/home/runner/work/puck-platform/puck-platform/packages/plugin-ai/src/components/PromptForm/styles.module.css#css-module
|
|
21271
21298
|
init_react_import();
|
|
21272
|
-
var
|
|
21299
|
+
var styles_module_default5 = { "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" };
|
|
21273
21300
|
|
|
21274
21301
|
// src/components/PromptForm/index.tsx
|
|
21275
|
-
import { jsx as
|
|
21276
|
-
var
|
|
21302
|
+
import { jsx as jsx23, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
21303
|
+
var cx5 = getClassNameFactory2("PromptForm", styles_module_default5);
|
|
21277
21304
|
function PromptForm({
|
|
21278
21305
|
actions,
|
|
21279
21306
|
colorScheme = "light",
|
|
@@ -21285,7 +21312,7 @@ function PromptForm({
|
|
|
21285
21312
|
isLoading,
|
|
21286
21313
|
placeholder = "Create a page for..."
|
|
21287
21314
|
}) {
|
|
21288
|
-
const hasSetInitialPrompt =
|
|
21315
|
+
const hasSetInitialPrompt = useRef6(false);
|
|
21289
21316
|
const [prompt, setPrompt] = useState9("");
|
|
21290
21317
|
const sendPrompt = () => {
|
|
21291
21318
|
if (isLoading || isDisabled) return;
|
|
@@ -21294,7 +21321,7 @@ function PromptForm({
|
|
|
21294
21321
|
}
|
|
21295
21322
|
setPrompt("");
|
|
21296
21323
|
};
|
|
21297
|
-
|
|
21324
|
+
useEffect7(() => {
|
|
21298
21325
|
const currentUrl = new URL(location.href);
|
|
21299
21326
|
const initialPrompt = currentUrl.searchParams.get("initialPrompt");
|
|
21300
21327
|
if (!hasSetInitialPrompt.current && initialPrompt && prompt === "") {
|
|
@@ -21305,28 +21332,28 @@ function PromptForm({
|
|
|
21305
21332
|
return /* @__PURE__ */ jsxs11(
|
|
21306
21333
|
"div",
|
|
21307
21334
|
{
|
|
21308
|
-
className:
|
|
21335
|
+
className: cx5({
|
|
21309
21336
|
isDisabled,
|
|
21310
21337
|
isLoading,
|
|
21311
21338
|
dark: colorScheme === "dark",
|
|
21312
21339
|
glow
|
|
21313
21340
|
}),
|
|
21314
21341
|
children: [
|
|
21315
|
-
helperText ? /* @__PURE__ */
|
|
21316
|
-
/* @__PURE__ */ jsxs11("div", { className:
|
|
21317
|
-
/* @__PURE__ */
|
|
21318
|
-
/* @__PURE__ */
|
|
21342
|
+
helperText ? /* @__PURE__ */ jsx23("div", { className: cx5("helper"), children: helperText }) : null,
|
|
21343
|
+
/* @__PURE__ */ jsxs11("div", { className: cx5("inner"), children: [
|
|
21344
|
+
/* @__PURE__ */ jsx23("span", { className: cx5("glow") }),
|
|
21345
|
+
/* @__PURE__ */ jsx23(
|
|
21319
21346
|
"form",
|
|
21320
21347
|
{
|
|
21321
21348
|
onSubmit: (e) => {
|
|
21322
21349
|
e.preventDefault();
|
|
21323
21350
|
sendPrompt();
|
|
21324
21351
|
},
|
|
21325
|
-
children: /* @__PURE__ */ jsxs11("div", { className:
|
|
21326
|
-
/* @__PURE__ */
|
|
21352
|
+
children: /* @__PURE__ */ jsxs11("div", { className: cx5("formInner"), children: [
|
|
21353
|
+
/* @__PURE__ */ jsx23(
|
|
21327
21354
|
default2,
|
|
21328
21355
|
{
|
|
21329
|
-
className:
|
|
21356
|
+
className: cx5("input"),
|
|
21330
21357
|
name: "prompt",
|
|
21331
21358
|
minRows: 2,
|
|
21332
21359
|
placeholder,
|
|
@@ -21347,15 +21374,15 @@ function PromptForm({
|
|
|
21347
21374
|
}
|
|
21348
21375
|
}
|
|
21349
21376
|
),
|
|
21350
|
-
/* @__PURE__ */ jsxs11("div", { className:
|
|
21351
|
-
/* @__PURE__ */
|
|
21352
|
-
/* @__PURE__ */
|
|
21377
|
+
/* @__PURE__ */ jsxs11("div", { className: cx5("actions"), children: [
|
|
21378
|
+
/* @__PURE__ */ jsx23("div", { className: cx5("actionsLeft"), children: actions }),
|
|
21379
|
+
/* @__PURE__ */ jsx23("div", { className: cx5("actionsRight"), children: /* @__PURE__ */ jsx23(
|
|
21353
21380
|
"button",
|
|
21354
21381
|
{
|
|
21355
|
-
className:
|
|
21382
|
+
className: cx5("actionSubmit"),
|
|
21356
21383
|
type: "submit",
|
|
21357
21384
|
disabled: isLoading,
|
|
21358
|
-
children: /* @__PURE__ */
|
|
21385
|
+
children: /* @__PURE__ */ jsx23(ArrowUp, {})
|
|
21359
21386
|
}
|
|
21360
21387
|
) })
|
|
21361
21388
|
] })
|
|
@@ -21375,9 +21402,9 @@ var toolStatusContext = createContext3({});
|
|
|
21375
21402
|
var ToolStatusProvider = toolStatusContext.Provider;
|
|
21376
21403
|
|
|
21377
21404
|
// src/components/ChatBody/index.tsx
|
|
21378
|
-
import { jsx as
|
|
21379
|
-
var
|
|
21380
|
-
var cxMessage = getClassNameFactory2("ChatMessage",
|
|
21405
|
+
import { jsx as jsx24, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
21406
|
+
var cx6 = getClassNameFactory2("Chat", styles_module_default4);
|
|
21407
|
+
var cxMessage = getClassNameFactory2("ChatMessage", styles_module_default4);
|
|
21381
21408
|
function ChatBody({
|
|
21382
21409
|
children,
|
|
21383
21410
|
examplePrompts,
|
|
@@ -21391,17 +21418,17 @@ function ChatBody({
|
|
|
21391
21418
|
}) {
|
|
21392
21419
|
const { scrollRef, contentRef } = useStickToBottom();
|
|
21393
21420
|
const hasMessages = messages && messages.length > 0;
|
|
21394
|
-
return /* @__PURE__ */ jsxs12("div", { className:
|
|
21395
|
-
children ? /* @__PURE__ */
|
|
21396
|
-
/* @__PURE__ */ jsxs12("div", { className:
|
|
21397
|
-
/* @__PURE__ */
|
|
21398
|
-
status === "submitted" && /* @__PURE__ */
|
|
21399
|
-
error45 && /* @__PURE__ */ jsxs12("div", { className:
|
|
21400
|
-
/* @__PURE__ */
|
|
21401
|
-
handleRetry && /* @__PURE__ */
|
|
21421
|
+
return /* @__PURE__ */ jsxs12("div", { className: cx6({ hasMessages, hasChildren: !!children, hideInput }), children: [
|
|
21422
|
+
children ? /* @__PURE__ */ jsx24("div", { className: cx6("default"), children }) : null,
|
|
21423
|
+
/* @__PURE__ */ jsxs12("div", { className: cx6("inner"), ref: scrollRef, children: [
|
|
21424
|
+
/* @__PURE__ */ jsx24("div", { className: cx6("messages"), ref: contentRef, children: messages.toReversed().map((message) => /* @__PURE__ */ jsx24(ChatMessage, { message }, message.id)) }),
|
|
21425
|
+
status === "submitted" && /* @__PURE__ */ jsx24("div", { className: cx6("loader"), children: /* @__PURE__ */ jsx24(Loader, { size: 14 }) }),
|
|
21426
|
+
error45 && /* @__PURE__ */ jsxs12("div", { className: cx6("error"), children: [
|
|
21427
|
+
/* @__PURE__ */ jsx24("div", { className: cx6("errorLabel"), children: "Something went wrong." }),
|
|
21428
|
+
handleRetry && /* @__PURE__ */ jsx24("div", { className: cx6("errorAction"), children: /* @__PURE__ */ jsx24(IconButton, { title: "Retry", onClick: handleRetry, children: /* @__PURE__ */ jsx24(RotateCcw, { size: "14" }) }) })
|
|
21402
21429
|
] }),
|
|
21403
|
-
/* @__PURE__ */ jsxs12("div", { className:
|
|
21404
|
-
/* @__PURE__ */
|
|
21430
|
+
/* @__PURE__ */ jsxs12("div", { className: cx6("form"), children: [
|
|
21431
|
+
/* @__PURE__ */ jsx24(
|
|
21405
21432
|
PromptForm,
|
|
21406
21433
|
{
|
|
21407
21434
|
glow: !hasMessages,
|
|
@@ -21411,19 +21438,19 @@ function ChatBody({
|
|
|
21411
21438
|
placeholder: "What do you want to build?"
|
|
21412
21439
|
}
|
|
21413
21440
|
),
|
|
21414
|
-
examplePrompts ? /* @__PURE__ */
|
|
21441
|
+
examplePrompts ? /* @__PURE__ */ jsx24("div", { className: cx6("examplePrompts"), children: examplePrompts }) : null
|
|
21415
21442
|
] })
|
|
21416
21443
|
] })
|
|
21417
21444
|
] });
|
|
21418
21445
|
}
|
|
21419
21446
|
function ChatMessage({ message }) {
|
|
21420
21447
|
const { role, parts } = message;
|
|
21421
|
-
return /* @__PURE__ */
|
|
21448
|
+
return /* @__PURE__ */ jsx24(
|
|
21422
21449
|
"div",
|
|
21423
21450
|
{
|
|
21424
21451
|
className: cxMessage({ [`${role}Role`]: true }),
|
|
21425
21452
|
"data-message-id": message.id,
|
|
21426
|
-
children: parts.map((part, i) => /* @__PURE__ */
|
|
21453
|
+
children: parts.map((part, i) => /* @__PURE__ */ jsx24(
|
|
21427
21454
|
ChatMessagePart,
|
|
21428
21455
|
{
|
|
21429
21456
|
part,
|
|
@@ -21439,25 +21466,25 @@ function ChatMessageWrapper({
|
|
|
21439
21466
|
role
|
|
21440
21467
|
}) {
|
|
21441
21468
|
if (role === "assistant") {
|
|
21442
|
-
return /* @__PURE__ */
|
|
21469
|
+
return /* @__PURE__ */ jsx24(Markdown, { children });
|
|
21443
21470
|
}
|
|
21444
|
-
return /* @__PURE__ */
|
|
21471
|
+
return /* @__PURE__ */ jsx24("span", { children });
|
|
21445
21472
|
}
|
|
21446
21473
|
function ChatMessagePart({
|
|
21447
21474
|
part,
|
|
21448
21475
|
role
|
|
21449
21476
|
}) {
|
|
21450
21477
|
if (part.type === "text") {
|
|
21451
|
-
return /* @__PURE__ */
|
|
21478
|
+
return /* @__PURE__ */ jsx24("div", { className: cxMessage("text"), children: /* @__PURE__ */ jsx24(ChatMessageWrapper, { role, children: part.text }) });
|
|
21452
21479
|
}
|
|
21453
21480
|
if (part.type === "tool-createPage") {
|
|
21454
|
-
return /* @__PURE__ */
|
|
21481
|
+
return /* @__PURE__ */ jsx24(PuckTool, __spreadValues({}, part));
|
|
21455
21482
|
}
|
|
21456
21483
|
if (part.type === "tool-updatePage") {
|
|
21457
|
-
return /* @__PURE__ */
|
|
21484
|
+
return /* @__PURE__ */ jsx24(PuckTool, __spreadValues({}, part));
|
|
21458
21485
|
}
|
|
21459
21486
|
if (part.type === "tool-userTool") {
|
|
21460
|
-
return /* @__PURE__ */
|
|
21487
|
+
return /* @__PURE__ */ jsx24(PuckTool, __spreadValues({}, part));
|
|
21461
21488
|
}
|
|
21462
21489
|
return null;
|
|
21463
21490
|
}
|
|
@@ -21469,27 +21496,27 @@ function PuckTool({
|
|
|
21469
21496
|
const toolStatus = useContext3(toolStatusContext)[toolCallId];
|
|
21470
21497
|
const outputObj = output;
|
|
21471
21498
|
const status = outputObj && "status" in outputObj ? outputObj.status : toolStatus != null ? toolStatus : { loading: true, label: defaultLabel };
|
|
21472
|
-
return /* @__PURE__ */
|
|
21499
|
+
return /* @__PURE__ */ jsx24(ToolStatus, { status });
|
|
21473
21500
|
}
|
|
21474
21501
|
function ToolStatus({ status }) {
|
|
21475
|
-
return /* @__PURE__ */
|
|
21476
|
-
/* @__PURE__ */
|
|
21477
|
-
/* @__PURE__ */
|
|
21502
|
+
return /* @__PURE__ */ jsx24("div", { className: cxMessage("data"), children: /* @__PURE__ */ jsxs12("div", { className: cxMessage("dataInner"), children: [
|
|
21503
|
+
/* @__PURE__ */ jsx24("div", { className: cxMessage("dataIcon"), children: status.error ? /* @__PURE__ */ jsx24(TriangleAlert, { size: 18 }) : status.loading ? /* @__PURE__ */ jsx24(Loader, { size: 16 }) : /* @__PURE__ */ jsx24(Check, { size: 18 }) }),
|
|
21504
|
+
/* @__PURE__ */ jsx24("div", { children: status.label })
|
|
21478
21505
|
] }) });
|
|
21479
21506
|
}
|
|
21480
21507
|
function ExamplePrompt({
|
|
21481
21508
|
label,
|
|
21482
21509
|
href
|
|
21483
21510
|
}) {
|
|
21484
|
-
return /* @__PURE__ */ jsxs12("a", { className:
|
|
21485
|
-
/* @__PURE__ */
|
|
21486
|
-
/* @__PURE__ */
|
|
21511
|
+
return /* @__PURE__ */ jsxs12("a", { className: cx6("examplePrompt"), href, children: [
|
|
21512
|
+
/* @__PURE__ */ jsx24("div", { children: label }),
|
|
21513
|
+
/* @__PURE__ */ jsx24("div", { className: cx6("examplePromptArrow"), children: /* @__PURE__ */ jsx24(ArrowRight, { size: "16" }) })
|
|
21487
21514
|
] });
|
|
21488
21515
|
}
|
|
21489
21516
|
|
|
21490
21517
|
// src/components/Chat/index.tsx
|
|
21491
21518
|
import qler from "qler";
|
|
21492
|
-
import { jsx as
|
|
21519
|
+
import { jsx as jsx25, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
21493
21520
|
var q = qler();
|
|
21494
21521
|
var BENCHMARK = false;
|
|
21495
21522
|
var prefixedUlid = (prefix = "") => `${prefix ? `${prefix}_` : ""}${ulid3()}`;
|
|
@@ -21503,9 +21530,9 @@ function Chat2({
|
|
|
21503
21530
|
}) {
|
|
21504
21531
|
const puckDispatch = usePuck((s) => s.dispatch);
|
|
21505
21532
|
const getPuck = useGetPuck();
|
|
21506
|
-
const localChatId =
|
|
21507
|
-
const inputRef =
|
|
21508
|
-
const pluginRef =
|
|
21533
|
+
const localChatId = useRef7(chatId);
|
|
21534
|
+
const inputRef = useRef7(null);
|
|
21535
|
+
const pluginRef = useRef7(null);
|
|
21509
21536
|
const [error45, setError] = useState10();
|
|
21510
21537
|
const [toolStatus, setToolStatus] = useState10({});
|
|
21511
21538
|
const { messages, status, sendMessage, regenerate } = useChat({
|
|
@@ -21717,7 +21744,7 @@ function Chat2({
|
|
|
21717
21744
|
console.error(e);
|
|
21718
21745
|
});
|
|
21719
21746
|
};
|
|
21720
|
-
const messagesWithStatuses =
|
|
21747
|
+
const messagesWithStatuses = useMemo3(() => {
|
|
21721
21748
|
return messages.map((msg) => {
|
|
21722
21749
|
return __spreadProps(__spreadValues({}, msg), {
|
|
21723
21750
|
parts: msg.parts.map((part) => {
|
|
@@ -21730,21 +21757,21 @@ function Chat2({
|
|
|
21730
21757
|
});
|
|
21731
21758
|
}, [messages, toolStatus]);
|
|
21732
21759
|
return /* @__PURE__ */ jsxs13("div", { className: getClassName16(), ref: pluginRef, children: [
|
|
21733
|
-
/* @__PURE__ */
|
|
21734
|
-
/* @__PURE__ */
|
|
21760
|
+
/* @__PURE__ */ jsx25("div", { className: getClassName16("header"), children: "AI page builder" }),
|
|
21761
|
+
/* @__PURE__ */ jsx25(ToolStatusProvider, { value: toolStatus, children: /* @__PURE__ */ jsx25(
|
|
21735
21762
|
ChatBody,
|
|
21736
21763
|
{
|
|
21737
21764
|
messages: messagesWithStatuses,
|
|
21738
21765
|
handleSubmit,
|
|
21739
21766
|
inputRef,
|
|
21740
21767
|
status,
|
|
21741
|
-
examplePrompts: examplePrompts == null ? void 0 : examplePrompts.map(({ label, href }) => /* @__PURE__ */
|
|
21768
|
+
examplePrompts: examplePrompts == null ? void 0 : examplePrompts.map(({ label, href }) => /* @__PURE__ */ jsx25(ExamplePrompt, { label, href }, label)),
|
|
21742
21769
|
error: error45,
|
|
21743
21770
|
handleRetry: () => {
|
|
21744
21771
|
setError("");
|
|
21745
21772
|
regenerate();
|
|
21746
21773
|
},
|
|
21747
|
-
children: /* @__PURE__ */
|
|
21774
|
+
children: /* @__PURE__ */ jsx25(
|
|
21748
21775
|
Placeholder,
|
|
21749
21776
|
{
|
|
21750
21777
|
dispatch: puckDispatch,
|
|
@@ -21776,10 +21803,10 @@ function Placeholder({
|
|
|
21776
21803
|
}, 10);
|
|
21777
21804
|
};
|
|
21778
21805
|
return /* @__PURE__ */ jsxs13("div", { className: getClassName16("placeholder"), children: [
|
|
21779
|
-
/* @__PURE__ */
|
|
21780
|
-
/* @__PURE__ */
|
|
21806
|
+
/* @__PURE__ */ jsx25(Bot, { size: "24" }),
|
|
21807
|
+
/* @__PURE__ */ jsx25("div", { children: "Use AI to build a page using your own components" }),
|
|
21781
21808
|
/* @__PURE__ */ jsxs13("div", { className: getClassName16("actions"), children: [
|
|
21782
|
-
/* @__PURE__ */
|
|
21809
|
+
/* @__PURE__ */ jsx25(
|
|
21783
21810
|
"button",
|
|
21784
21811
|
{
|
|
21785
21812
|
className: getClassName16("action"),
|
|
@@ -21787,7 +21814,7 @@ function Placeholder({
|
|
|
21787
21814
|
children: "Enter prompt"
|
|
21788
21815
|
}
|
|
21789
21816
|
),
|
|
21790
|
-
/* @__PURE__ */
|
|
21817
|
+
/* @__PURE__ */ jsx25(
|
|
21791
21818
|
"button",
|
|
21792
21819
|
{
|
|
21793
21820
|
className: getClassName16("actionOutlined"),
|
|
@@ -21811,13 +21838,13 @@ function isScrolledIntoView(el) {
|
|
|
21811
21838
|
}
|
|
21812
21839
|
|
|
21813
21840
|
// src/index.tsx
|
|
21814
|
-
import { jsx as
|
|
21841
|
+
import { jsx as jsx26 } from "react/jsx-runtime";
|
|
21815
21842
|
function createAIPlugin(opts) {
|
|
21816
21843
|
return {
|
|
21817
21844
|
label: "AI",
|
|
21818
21845
|
name: "ai",
|
|
21819
|
-
render: () => /* @__PURE__ */
|
|
21820
|
-
icon: /* @__PURE__ */
|
|
21846
|
+
render: () => /* @__PURE__ */ jsx26(Chat2, __spreadValues({}, opts)),
|
|
21847
|
+
icon: /* @__PURE__ */ jsx26(Bot, {}),
|
|
21821
21848
|
mobilePanelHeight: "min-content"
|
|
21822
21849
|
};
|
|
21823
21850
|
}
|
package/package.json
CHANGED