@puckeditor/plugin-ai 0.5.0-canary.989c664e → 0.5.0-canary.ba57e8ea
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 +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +51 -18
- package/dist/index.mjs +49 -16
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
3
|
import { LanguageModelUsage, UIMessage, CreateUIMessage, DataUIPart, ChatStatus } from 'ai';
|
|
4
|
-
import { PuckAction, Data } from '@
|
|
4
|
+
import { PuckAction, Data } from '@puckeditor/core';
|
|
5
5
|
|
|
6
6
|
type _JSONSchema = boolean | JSONSchema;
|
|
7
7
|
type JSONSchema = {
|
|
@@ -82,7 +82,7 @@ type FieldAiParams = {
|
|
|
82
82
|
schema?: JSONSchema;
|
|
83
83
|
};
|
|
84
84
|
|
|
85
|
-
declare module "@
|
|
85
|
+
declare module "@puckeditor/core" {
|
|
86
86
|
export interface ComponentMetadata {
|
|
87
87
|
ai?: ComponentAiParams;
|
|
88
88
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
3
|
import { LanguageModelUsage, UIMessage, CreateUIMessage, DataUIPart, ChatStatus } from 'ai';
|
|
4
|
-
import { PuckAction, Data } from '@
|
|
4
|
+
import { PuckAction, Data } from '@puckeditor/core';
|
|
5
5
|
|
|
6
6
|
type _JSONSchema = boolean | JSONSchema;
|
|
7
7
|
type JSONSchema = {
|
|
@@ -82,7 +82,7 @@ type FieldAiParams = {
|
|
|
82
82
|
schema?: JSONSchema;
|
|
83
83
|
};
|
|
84
84
|
|
|
85
|
-
declare module "@
|
|
85
|
+
declare module "@puckeditor/core" {
|
|
86
86
|
export interface ComponentMetadata {
|
|
87
87
|
ai?: ComponentAiParams;
|
|
88
88
|
}
|
package/dist/index.js
CHANGED
|
@@ -477,7 +477,7 @@ function useChat({
|
|
|
477
477
|
}
|
|
478
478
|
|
|
479
479
|
// src/components/Chat/index.tsx
|
|
480
|
-
var
|
|
480
|
+
var import_core2 = require("@puckeditor/core");
|
|
481
481
|
var import_ai4 = require("ai");
|
|
482
482
|
var import_react22 = require("react");
|
|
483
483
|
var import_ulid = require("ulid");
|
|
@@ -802,7 +802,7 @@ init_react_import();
|
|
|
802
802
|
|
|
803
803
|
// ../platform-client/components/AutoForm/AutoForm.tsx
|
|
804
804
|
init_react_import();
|
|
805
|
-
var
|
|
805
|
+
var import_core = require("@puckeditor/core");
|
|
806
806
|
var import_react11 = require("react");
|
|
807
807
|
|
|
808
808
|
// css-module:/home/runner/work/puck-platform/puck-platform/packages/platform-client/components/AutoForm/AutoForm.module.css#css-module
|
|
@@ -1419,6 +1419,35 @@ var getSelectorForId = (state, id) => {
|
|
|
1419
1419
|
return { zone: zoneCompound, index };
|
|
1420
1420
|
};
|
|
1421
1421
|
var getItemById = (state, id) => state.indexes.nodes[id].data;
|
|
1422
|
+
var applyArrayDefaults = (oldProps, newProps, fields) => {
|
|
1423
|
+
const updatedProps = {
|
|
1424
|
+
...oldProps,
|
|
1425
|
+
...newProps
|
|
1426
|
+
};
|
|
1427
|
+
for (const fieldName in fields) {
|
|
1428
|
+
const field = fields[fieldName];
|
|
1429
|
+
if (field.type === "array") {
|
|
1430
|
+
const arrayField = field;
|
|
1431
|
+
const arrayFields = arrayField.arrayFields;
|
|
1432
|
+
updatedProps[fieldName] = updatedProps[fieldName].map(
|
|
1433
|
+
(item, index) => {
|
|
1434
|
+
const newItem = {};
|
|
1435
|
+
const defaultValue = typeof arrayField.defaultItemProps === "function" ? arrayField.defaultItemProps(index) : arrayField.defaultItemProps;
|
|
1436
|
+
for (const arrayFieldName in arrayFields) {
|
|
1437
|
+
const subField = arrayFields[arrayFieldName];
|
|
1438
|
+
if (subField.type === "slot") {
|
|
1439
|
+
newItem[arrayFieldName] = item[arrayFieldName] ?? oldProps[fieldName]?.[index]?.[arrayFieldName] ?? defaultValue?.[arrayFieldName];
|
|
1440
|
+
} else {
|
|
1441
|
+
newItem[arrayFieldName] = item[arrayFieldName] ?? defaultValue?.[arrayFieldName];
|
|
1442
|
+
}
|
|
1443
|
+
}
|
|
1444
|
+
return newItem;
|
|
1445
|
+
}
|
|
1446
|
+
);
|
|
1447
|
+
}
|
|
1448
|
+
}
|
|
1449
|
+
return updatedProps;
|
|
1450
|
+
};
|
|
1422
1451
|
var dispatchOp = (operation, {
|
|
1423
1452
|
getState,
|
|
1424
1453
|
dispatchAction,
|
|
@@ -1442,17 +1471,19 @@ var dispatchOp = (operation, {
|
|
|
1442
1471
|
`Tried to update an item that doesn't exist: ${operation.id}`
|
|
1443
1472
|
);
|
|
1444
1473
|
}
|
|
1474
|
+
const newData = {
|
|
1475
|
+
...existing,
|
|
1476
|
+
props: applyArrayDefaults(
|
|
1477
|
+
existing.props,
|
|
1478
|
+
operation.props,
|
|
1479
|
+
config.components[existing.type].fields
|
|
1480
|
+
)
|
|
1481
|
+
};
|
|
1445
1482
|
dispatchAction({
|
|
1446
1483
|
type: "replace",
|
|
1447
1484
|
destinationIndex: operation.index,
|
|
1448
1485
|
destinationZone: operation.zone,
|
|
1449
|
-
data:
|
|
1450
|
-
...existing,
|
|
1451
|
-
props: {
|
|
1452
|
-
...existing.props,
|
|
1453
|
-
...operation.props
|
|
1454
|
-
}
|
|
1455
|
-
},
|
|
1486
|
+
data: newData,
|
|
1456
1487
|
recordHistory: false
|
|
1457
1488
|
});
|
|
1458
1489
|
}
|
|
@@ -1464,17 +1495,19 @@ var dispatchOp = (operation, {
|
|
|
1464
1495
|
`Tried to update an item that doesn't exist: ${operation.id}`
|
|
1465
1496
|
);
|
|
1466
1497
|
}
|
|
1498
|
+
const newData = {
|
|
1499
|
+
...existing,
|
|
1500
|
+
props: applyArrayDefaults(
|
|
1501
|
+
existing.props,
|
|
1502
|
+
operation.props,
|
|
1503
|
+
config.components[existing.type].fields
|
|
1504
|
+
)
|
|
1505
|
+
};
|
|
1467
1506
|
dispatchAction({
|
|
1468
1507
|
type: "replace",
|
|
1469
1508
|
destinationIndex: selector.index,
|
|
1470
1509
|
destinationZone: selector.zone,
|
|
1471
|
-
data:
|
|
1472
|
-
...existing,
|
|
1473
|
-
props: {
|
|
1474
|
-
...existing.props,
|
|
1475
|
-
...operation.props
|
|
1476
|
-
}
|
|
1477
|
-
},
|
|
1510
|
+
data: newData,
|
|
1478
1511
|
recordHistory: false
|
|
1479
1512
|
});
|
|
1480
1513
|
} else if (operation.op === "updateRoot") {
|
|
@@ -1555,11 +1588,11 @@ var q = (0, import_qler.default)();
|
|
|
1555
1588
|
var BENCHMARK = false;
|
|
1556
1589
|
var prefixedUlid = (prefix = "") => `${prefix ? `${prefix}_` : ""}${(0, import_ulid.ulid)()}`;
|
|
1557
1590
|
var getClassName17 = getClassNameFactory("Chat", styles_module_default);
|
|
1558
|
-
var usePuck = (0,
|
|
1591
|
+
var usePuck = (0, import_core2.createUsePuck)();
|
|
1559
1592
|
function Chat2({ chat, host = "/api/puck/chat" }) {
|
|
1560
1593
|
const { examplePrompts } = chat ?? {};
|
|
1561
1594
|
const puckDispatch = usePuck((s) => s.dispatch);
|
|
1562
|
-
const getPuck = (0,
|
|
1595
|
+
const getPuck = (0, import_core2.useGetPuck)();
|
|
1563
1596
|
const localChatId = (0, import_react22.useRef)("");
|
|
1564
1597
|
const inputRef = (0, import_react22.useRef)(null);
|
|
1565
1598
|
const pluginRef = (0, import_react22.useRef)(null);
|
package/dist/index.mjs
CHANGED
|
@@ -471,7 +471,7 @@ function useChat({
|
|
|
471
471
|
}
|
|
472
472
|
|
|
473
473
|
// src/components/Chat/index.tsx
|
|
474
|
-
import { createUsePuck, useGetPuck } from "@
|
|
474
|
+
import { createUsePuck, useGetPuck } from "@puckeditor/core";
|
|
475
475
|
import {
|
|
476
476
|
DefaultChatTransport
|
|
477
477
|
} from "ai";
|
|
@@ -800,7 +800,7 @@ init_react_import();
|
|
|
800
800
|
|
|
801
801
|
// ../platform-client/components/AutoForm/AutoForm.tsx
|
|
802
802
|
init_react_import();
|
|
803
|
-
import { AutoField, FieldLabel } from "@
|
|
803
|
+
import { AutoField, FieldLabel } from "@puckeditor/core";
|
|
804
804
|
import { useEffect as useEffect5, useState as useState5 } from "react";
|
|
805
805
|
|
|
806
806
|
// css-module:/home/runner/work/puck-platform/puck-platform/packages/platform-client/components/AutoForm/AutoForm.module.css#css-module
|
|
@@ -1421,6 +1421,35 @@ var getSelectorForId = (state, id) => {
|
|
|
1421
1421
|
return { zone: zoneCompound, index };
|
|
1422
1422
|
};
|
|
1423
1423
|
var getItemById = (state, id) => state.indexes.nodes[id].data;
|
|
1424
|
+
var applyArrayDefaults = (oldProps, newProps, fields) => {
|
|
1425
|
+
const updatedProps = {
|
|
1426
|
+
...oldProps,
|
|
1427
|
+
...newProps
|
|
1428
|
+
};
|
|
1429
|
+
for (const fieldName in fields) {
|
|
1430
|
+
const field = fields[fieldName];
|
|
1431
|
+
if (field.type === "array") {
|
|
1432
|
+
const arrayField = field;
|
|
1433
|
+
const arrayFields = arrayField.arrayFields;
|
|
1434
|
+
updatedProps[fieldName] = updatedProps[fieldName].map(
|
|
1435
|
+
(item, index) => {
|
|
1436
|
+
const newItem = {};
|
|
1437
|
+
const defaultValue = typeof arrayField.defaultItemProps === "function" ? arrayField.defaultItemProps(index) : arrayField.defaultItemProps;
|
|
1438
|
+
for (const arrayFieldName in arrayFields) {
|
|
1439
|
+
const subField = arrayFields[arrayFieldName];
|
|
1440
|
+
if (subField.type === "slot") {
|
|
1441
|
+
newItem[arrayFieldName] = item[arrayFieldName] ?? oldProps[fieldName]?.[index]?.[arrayFieldName] ?? defaultValue?.[arrayFieldName];
|
|
1442
|
+
} else {
|
|
1443
|
+
newItem[arrayFieldName] = item[arrayFieldName] ?? defaultValue?.[arrayFieldName];
|
|
1444
|
+
}
|
|
1445
|
+
}
|
|
1446
|
+
return newItem;
|
|
1447
|
+
}
|
|
1448
|
+
);
|
|
1449
|
+
}
|
|
1450
|
+
}
|
|
1451
|
+
return updatedProps;
|
|
1452
|
+
};
|
|
1424
1453
|
var dispatchOp = (operation, {
|
|
1425
1454
|
getState,
|
|
1426
1455
|
dispatchAction,
|
|
@@ -1444,17 +1473,19 @@ var dispatchOp = (operation, {
|
|
|
1444
1473
|
`Tried to update an item that doesn't exist: ${operation.id}`
|
|
1445
1474
|
);
|
|
1446
1475
|
}
|
|
1476
|
+
const newData = {
|
|
1477
|
+
...existing,
|
|
1478
|
+
props: applyArrayDefaults(
|
|
1479
|
+
existing.props,
|
|
1480
|
+
operation.props,
|
|
1481
|
+
config.components[existing.type].fields
|
|
1482
|
+
)
|
|
1483
|
+
};
|
|
1447
1484
|
dispatchAction({
|
|
1448
1485
|
type: "replace",
|
|
1449
1486
|
destinationIndex: operation.index,
|
|
1450
1487
|
destinationZone: operation.zone,
|
|
1451
|
-
data:
|
|
1452
|
-
...existing,
|
|
1453
|
-
props: {
|
|
1454
|
-
...existing.props,
|
|
1455
|
-
...operation.props
|
|
1456
|
-
}
|
|
1457
|
-
},
|
|
1488
|
+
data: newData,
|
|
1458
1489
|
recordHistory: false
|
|
1459
1490
|
});
|
|
1460
1491
|
}
|
|
@@ -1466,17 +1497,19 @@ var dispatchOp = (operation, {
|
|
|
1466
1497
|
`Tried to update an item that doesn't exist: ${operation.id}`
|
|
1467
1498
|
);
|
|
1468
1499
|
}
|
|
1500
|
+
const newData = {
|
|
1501
|
+
...existing,
|
|
1502
|
+
props: applyArrayDefaults(
|
|
1503
|
+
existing.props,
|
|
1504
|
+
operation.props,
|
|
1505
|
+
config.components[existing.type].fields
|
|
1506
|
+
)
|
|
1507
|
+
};
|
|
1469
1508
|
dispatchAction({
|
|
1470
1509
|
type: "replace",
|
|
1471
1510
|
destinationIndex: selector.index,
|
|
1472
1511
|
destinationZone: selector.zone,
|
|
1473
|
-
data:
|
|
1474
|
-
...existing,
|
|
1475
|
-
props: {
|
|
1476
|
-
...existing.props,
|
|
1477
|
-
...operation.props
|
|
1478
|
-
}
|
|
1479
|
-
},
|
|
1512
|
+
data: newData,
|
|
1480
1513
|
recordHistory: false
|
|
1481
1514
|
});
|
|
1482
1515
|
} else if (operation.op === "updateRoot") {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@puckeditor/plugin-ai",
|
|
3
|
-
"version": "0.5.0-canary.
|
|
3
|
+
"version": "0.5.0-canary.ba57e8ea",
|
|
4
4
|
"author": "Chris Villa <chris@puckeditor.com>",
|
|
5
5
|
"repository": "puckeditor/puck",
|
|
6
6
|
"bugs": "https://github.com/puckeditor/puck/issues",
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@ai-sdk/react": "^2.0.29",
|
|
40
|
-
"@measured/puck": "0.21.0-canary.ed351ce5",
|
|
41
40
|
"@puckeditor/ai-types": "workspace:*",
|
|
41
|
+
"@puckeditor/core": "0.21.0-canary.de0baf39",
|
|
42
42
|
"@puckeditor/platform-types": "workspace:*",
|
|
43
43
|
"@types/jest": "^30.0.0",
|
|
44
44
|
"@types/node": "^24.3.0",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"typescript": "^5.5.4"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
|
-
"@
|
|
57
|
+
"@puckeditor/core": "^0.21.0 | 0.21.0-canary.de0baf39",
|
|
58
58
|
"react": "^18.0.0 || ^19.0.0"
|
|
59
59
|
}
|
|
60
60
|
}
|