@blocklet/pages-kit 0.2.351 → 0.2.353

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.
Files changed (22) hide show
  1. package/lib/cjs/builtin/async/ai-runtime/components/AgentErrorBoundary.js +5 -0
  2. package/lib/cjs/builtin/async/ai-runtime/runtime-components/PhotoGallery/index.js +2 -1
  3. package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimpleChat/MessageView.js +1 -1
  4. package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimplePage/index.js +1 -1
  5. package/lib/cjs/builtin/async/ai-runtime/runtime-components/V0/Output.js +3 -5
  6. package/lib/cjs/builtin/async/ai-runtime/runtime-components/V0/Page.js +2 -1
  7. package/lib/cjs/builtin/async/ai-runtime/runtime-components/V0/components/CodePreview.js +2 -3
  8. package/lib/cjs/components/CustomComponentRenderer/state.js +1 -1
  9. package/lib/cjs/tsconfig.tsbuildinfo +1 -1
  10. package/lib/esm/builtin/async/ai-runtime/components/AgentErrorBoundary.js +5 -0
  11. package/lib/esm/builtin/async/ai-runtime/runtime-components/PhotoGallery/index.js +2 -1
  12. package/lib/esm/builtin/async/ai-runtime/runtime-components/SimpleChat/MessageView.js +1 -1
  13. package/lib/esm/builtin/async/ai-runtime/runtime-components/SimplePage/index.js +1 -1
  14. package/lib/esm/builtin/async/ai-runtime/runtime-components/V0/Output.js +3 -5
  15. package/lib/esm/builtin/async/ai-runtime/runtime-components/V0/Page.js +2 -1
  16. package/lib/esm/builtin/async/ai-runtime/runtime-components/V0/components/CodePreview.js +2 -3
  17. package/lib/esm/components/CustomComponentRenderer/state.js +1 -1
  18. package/lib/esm/tsconfig.tsbuildinfo +1 -1
  19. package/lib/types/builtin/async/ai-runtime/runtime-components/V0/components/CodePreview.d.ts +1 -1
  20. package/lib/types/tsconfig.tsbuildinfo +1 -1
  21. package/package.json +2 -2
  22. package/tsconfig.json +2 -1
@@ -2,6 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AgentErrorView = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const api_1 = require("@blocklet/ai-kit/api");
6
+ const components_1 = require("@blocklet/ai-kit/components");
5
7
  const material_1 = require("@mui/material");
6
8
  const react_error_boundary_1 = require("react-error-boundary");
7
9
  const locale_1 = require("../../../locale");
@@ -16,6 +18,9 @@ function AgentErrorView({ error }) {
16
18
  if (error.type === 'MissingSecretError') {
17
19
  return (0, jsx_runtime_1.jsx)(MissingSecretErrorView, {});
18
20
  }
21
+ if (error.type === api_1.SubscriptionErrorType.UNSUBSCRIBED) {
22
+ return (0, jsx_runtime_1.jsx)(components_1.SubscribeErrorAlert, { error: error });
23
+ }
19
24
  return (0, jsx_runtime_1.jsx)(material_1.Alert, { severity: "error", children: String(error === null || error === void 0 ? void 0 : error.message) });
20
25
  }
21
26
  exports.AgentErrorView = AgentErrorView;
@@ -21,6 +21,7 @@ const react_1 = require("react");
21
21
  const react_wrap_balancer_1 = __importDefault(require("react-wrap-balancer"));
22
22
  const CustomComponentRenderer_1 = __importDefault(require("../../../../../components/CustomComponentRenderer"));
23
23
  const locale_1 = require("../../../../locale");
24
+ const AgentErrorBoundary_1 = require("../../components/AgentErrorBoundary");
24
25
  const SimpleHeader_1 = __importDefault(require("../../components/Header/SimpleHeader"));
25
26
  const LoadingButton_1 = __importDefault(require("../../components/LoadingButton"));
26
27
  const ActiveAgent_1 = require("../../contexts/ActiveAgent");
@@ -61,5 +62,5 @@ const OutputItemView = (0, react_1.memo)(({ message }) => {
61
62
  const { appearanceOutput } = (0, use_appearances_1.default)({ agentId: message.agentId });
62
63
  if (!(appearanceOutput === null || appearanceOutput === void 0 ? void 0 : appearanceOutput.componentId))
63
64
  return null;
64
- return ((0, jsx_runtime_1.jsx)(CurrentAgent_1.default, { agentId: message.agentId, children: (0, jsx_runtime_1.jsx)(CurrentMessage_1.default, { message: message, children: (0, jsx_runtime_1.jsx)(react_1.Suspense, { children: (0, jsx_runtime_1.jsx)(CustomComponentRenderer_1.default, { componentId: appearanceOutput.componentId, properties: appearanceOutput.componentProperties }) }) }) }, message.id));
65
+ return ((0, jsx_runtime_1.jsx)(CurrentAgent_1.default, { agentId: message.agentId, children: (0, jsx_runtime_1.jsx)(CurrentMessage_1.default, { message: message, children: (0, jsx_runtime_1.jsx)(react_1.Suspense, { children: (0, jsx_runtime_1.jsx)(CustomComponentRenderer_1.default, { componentId: appearanceOutput.componentId, properties: appearanceOutput.componentProperties, fallbackRender: AgentErrorBoundary_1.AgentErrorView }, message.id) }) }) }, message.id));
65
66
  });
@@ -60,7 +60,7 @@ const MessageView = (0, react_1.memo)(({ message }) => {
60
60
  const { hideAgentAvatar, hideUserInputs } = (_b = (0, ComponentPreferences_1.useComponentPreferences)()) !== null && _b !== void 0 ? _b : {};
61
61
  if (!(appearanceOutput === null || appearanceOutput === void 0 ? void 0 : appearanceOutput.componentId))
62
62
  return null;
63
- const agentMessage = ((0, jsx_runtime_1.jsx)(MessageBodyContainer, { messageRole: "assistant", children: (0, jsx_runtime_1.jsx)(CustomComponentRenderer_1.default, { componentId: appearanceOutput.componentId, properties: appearanceOutput.componentProperties, fallbackRender: AgentErrorBoundary_1.AgentErrorView }) }));
63
+ const agentMessage = ((0, jsx_runtime_1.jsx)(MessageBodyContainer, { messageRole: "assistant", children: (0, jsx_runtime_1.jsx)(CustomComponentRenderer_1.default, { componentId: appearanceOutput.componentId, properties: appearanceOutput.componentProperties, fallbackRender: AgentErrorBoundary_1.AgentErrorView }, message.id) }));
64
64
  return ((0, jsx_runtime_1.jsx)(CurrentAgent_1.default, { agentId: message.agentId, children: (0, jsx_runtime_1.jsx)(CurrentMessage_1.default, { message: message, children: (0, jsx_runtime_1.jsxs)(material_1.Stack, { gap: 2, children: [!hideUserInputs && ((0, jsx_runtime_1.jsx)(material_1.Box, { children: (0, jsx_runtime_1.jsx)(UserInfo_1.default, { name: (_c = authSession.user) === null || _c === void 0 ? void 0 : _c.fullName, did: (_d = authSession.user) === null || _d === void 0 ? void 0 : _d.did, avatar: (_e = authSession.user) === null || _e === void 0 ? void 0 : _e.avatar, time: message.createdAt, reverse: true, alignItems: "flex-start", UserNameProps: { sx: { color: hasBg ? 'white' : undefined } }, children: (0, jsx_runtime_1.jsx)(material_1.Stack, { sx: { alignItems: 'flex-end' }, children: (0, jsx_runtime_1.jsx)(MessageBodyContainer, { messageRole: "user", children: (0, jsx_runtime_1.jsx)(UserMessageView_1.default, {}) }) }) }) })), (0, jsx_runtime_1.jsx)(material_1.Box, { children: !hideAgentAvatar ? ((0, jsx_runtime_1.jsx)(UserInfo_1.default, { name: profile.name, did: (_f = globalThis.blocklet) === null || _f === void 0 ? void 0 : _f.appId, avatar: profile.avatar, time: message.createdAt, alignItems: "flex-start", UserNameProps: { sx: { color: hasBg ? 'white' : undefined } }, children: agentMessage })) : (agentMessage) })] }) }) }));
65
65
  });
66
66
  exports.default = MessageView;
@@ -49,5 +49,5 @@ const OutputItemView = (0, react_1.memo)(({ message }) => {
49
49
  const { appearanceOutput } = (0, use_appearances_1.default)({ agentId: message.agentId });
50
50
  if (!(appearanceOutput === null || appearanceOutput === void 0 ? void 0 : appearanceOutput.componentId))
51
51
  return null;
52
- return ((0, jsx_runtime_1.jsx)(CurrentAgent_1.default, { agentId: message.agentId, children: (0, jsx_runtime_1.jsx)(CurrentMessage_1.default, { message: message, children: (0, jsx_runtime_1.jsx)(react_1.Suspense, { children: (0, jsx_runtime_1.jsx)(CustomComponentRenderer_1.default, { componentId: appearanceOutput.componentId, properties: appearanceOutput.componentProperties, fallbackRender: AgentErrorBoundary_1.AgentErrorView }) }) }) }));
52
+ return ((0, jsx_runtime_1.jsx)(CurrentAgent_1.default, { agentId: message.agentId, children: (0, jsx_runtime_1.jsx)(CurrentMessage_1.default, { message: message, children: (0, jsx_runtime_1.jsx)(react_1.Suspense, { children: (0, jsx_runtime_1.jsx)(CustomComponentRenderer_1.default, { componentId: appearanceOutput.componentId, properties: appearanceOutput.componentProperties, fallbackRender: AgentErrorBoundary_1.AgentErrorView }, message.id) }) }) }));
53
53
  });
@@ -116,7 +116,7 @@ function V0Output() {
116
116
  onClick: (e) => __awaiter(this, void 0, void 0, function* () {
117
117
  var _c;
118
118
  const { taskid: taskId } = ((_c = e === null || e === void 0 ? void 0 : e.currentTarget) === null || _c === void 0 ? void 0 : _c.dataset) || {};
119
- const currentCode = (0, CodePreview_1.getCurrentCodeByTaskId)(message, taskId);
119
+ const currentCode = (0, CodePreview_1.getCurrentCodeByTaskId)(message);
120
120
  try {
121
121
  yield (0, CustomComponentRenderer_1.transpileAndLoadScript)(currentCode).then((m) => {
122
122
  var _a, _b, _c;
@@ -183,10 +183,8 @@ function V0Output() {
183
183
  disabled,
184
184
  variant: 'contained',
185
185
  color: 'primary',
186
- onClick: (e) => {
187
- var _a;
188
- const { taskid: taskId } = ((_a = e === null || e === void 0 ? void 0 : e.currentTarget) === null || _a === void 0 ? void 0 : _a.dataset) || {};
189
- setCode((0, CodePreview_1.getCurrentCodeByTaskId)(message, taskId));
186
+ onClick: () => {
187
+ setCode((0, CodePreview_1.getCurrentCodeByTaskId)(message));
190
188
  },
191
189
  },
192
190
  group: 'codePreview',
@@ -21,6 +21,7 @@ const material_1 = require("@mui/material");
21
21
  const react_2 = require("react");
22
22
  const CustomComponentRenderer_1 = __importDefault(require("../../../../../components/CustomComponentRenderer"));
23
23
  const locale_1 = require("../../../../locale");
24
+ const AgentErrorBoundary_1 = require("../../components/AgentErrorBoundary");
24
25
  const ActiveAgent_1 = require("../../contexts/ActiveAgent");
25
26
  const CurrentAgent_1 = __importDefault(require("../../contexts/CurrentAgent"));
26
27
  const CurrentMessage_1 = __importDefault(require("../../contexts/CurrentMessage"));
@@ -298,5 +299,5 @@ function AgentOutputRender({ message }) {
298
299
  const { appearanceOutput } = (0, use_appearances_1.default)();
299
300
  if (!(appearanceOutput === null || appearanceOutput === void 0 ? void 0 : appearanceOutput.componentId) || !message)
300
301
  return null;
301
- return ((0, jsx_runtime_1.jsx)(CurrentAgent_1.default, { agentId: message.agentId, children: (0, jsx_runtime_1.jsx)(CurrentMessage_1.default, { message: message, children: (0, jsx_runtime_1.jsx)(react_2.Suspense, { children: (0, jsx_runtime_1.jsx)(CustomComponentRenderer_1.default, { componentId: appearanceOutput.componentId, properties: appearanceOutput.componentProperties }) }) }) }));
302
+ return ((0, jsx_runtime_1.jsx)(CurrentAgent_1.default, { agentId: message.agentId, children: (0, jsx_runtime_1.jsx)(CurrentMessage_1.default, { message: message, children: (0, jsx_runtime_1.jsx)(react_2.Suspense, { children: (0, jsx_runtime_1.jsx)(CustomComponentRenderer_1.default, { componentId: appearanceOutput.componentId, properties: appearanceOutput.componentProperties, fallbackRender: AgentErrorBoundary_1.AgentErrorView }, message.id) }) }) }));
302
303
  }
@@ -148,9 +148,8 @@ function CodeRenderByMessage({ zoom, message, minHeight = 200, sx, propertiesVal
148
148
  }
149
149
  exports.CodeRenderByMessage = CodeRenderByMessage;
150
150
  exports.CodeRenderByMessageMemo = (0, react_2.memo)(CodeRenderByMessage);
151
- function getCurrentCodeByTaskId(message, taskId) {
151
+ function getCurrentCodeByTaskId(message) {
152
152
  var _a, _b, _c;
153
- // @ts-ignore
154
- return (_c = (_b = (_a = message === null || message === void 0 ? void 0 : message.outputs) === null || _a === void 0 ? void 0 : _a.objects) === null || _b === void 0 ? void 0 : _b.find((item) => item.taskId === taskId)) === null || _c === void 0 ? void 0 : _c[codeField];
153
+ return (_c = (_b = (_a = message === null || message === void 0 ? void 0 : message.outputs) === null || _a === void 0 ? void 0 : _a.objects) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c[codeField];
155
154
  }
156
155
  exports.getCurrentCodeByTaskId = getCurrentCodeByTaskId;
@@ -239,7 +239,7 @@ function useTranspileComponent({ componentId, locale, properties, dev: { default
239
239
  function transpileAndLoadScript(script) {
240
240
  return __awaiter(this, void 0, void 0, function* () {
241
241
  const [ts, { createBuiltinModuleTransformer }] = yield Promise.all([
242
- Promise.resolve().then(() => __importStar(require('typescript'))),
242
+ Promise.resolve().then(() => __importStar(require('typescript'))).then((m) => m.default || m),
243
243
  Promise.resolve().then(() => __importStar(require('../../utils/typescript/builtin-module-transformer'))),
244
244
  ]);
245
245
  const compiled = ts.transpileModule(script, {