@blocklet/pages-kit 0.2.287 → 0.2.288

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 (77) hide show
  1. package/lib/cjs/builtin/async/ai-runtime/api/request.js +9 -1
  2. package/lib/cjs/builtin/async/ai-runtime/components/GlobalLoading.js +2 -38
  3. package/lib/cjs/builtin/async/ai-runtime/components/LoadingListItemButton.js +3 -5
  4. package/lib/cjs/builtin/async/ai-runtime/components/RuntimeProvider.js +7 -1
  5. package/lib/cjs/builtin/async/ai-runtime/components/common/ChatBot.js +10 -11
  6. package/lib/cjs/builtin/async/ai-runtime/components/common/MessageMetadataRenderer.js +1 -1
  7. package/lib/cjs/builtin/async/ai-runtime/components/form/ParameterForm.js +53 -12
  8. package/lib/cjs/builtin/async/ai-runtime/components/form/ParameterFormFields.js +19 -5
  9. package/lib/cjs/builtin/async/ai-runtime/components/form/QuestionField.js +2 -2
  10. package/lib/cjs/builtin/async/ai-runtime/components/form/SettingButton.js +9 -4
  11. package/lib/cjs/builtin/async/ai-runtime/components/message/MessageItemView.js +70 -75
  12. package/lib/cjs/builtin/async/ai-runtime/components/message/MessageListView.js +2 -3
  13. package/lib/cjs/builtin/async/ai-runtime/components/message/ReferenceLinks.js +1 -1
  14. package/lib/cjs/builtin/async/ai-runtime/components/parameters/index.js +1 -1
  15. package/lib/cjs/builtin/async/ai-runtime/components/runtime-chat/InitialForm.js +26 -9
  16. package/lib/cjs/builtin/async/ai-runtime/components/runtime-chat/RuntimeChatHeader.js +16 -4
  17. package/lib/cjs/builtin/async/ai-runtime/components/runtime-chat/RuntimeChatSession.js +8 -23
  18. package/lib/cjs/builtin/async/ai-runtime/components/runtime-chat/index.js +19 -6
  19. package/lib/cjs/builtin/async/ai-runtime/components/runtime-form/RuntimeFormForms.js +24 -7
  20. package/lib/cjs/builtin/async/ai-runtime/components/session/CheckSession.js +38 -35
  21. package/lib/cjs/builtin/async/ai-runtime/error.js +10 -0
  22. package/lib/cjs/builtin/async/ai-runtime/hooks/navigate.js +2 -1
  23. package/lib/cjs/builtin/async/ai-runtime/hooks/useAsync.js +32 -0
  24. package/lib/cjs/builtin/async/ai-runtime/index.js +22 -16
  25. package/lib/cjs/builtin/async/ai-runtime/locales/index.js +1 -1
  26. package/lib/cjs/builtin/async/ai-runtime/state/loading.js +39 -0
  27. package/lib/cjs/builtin/async/ai-runtime/state/session.js +1 -1
  28. package/lib/esm/builtin/async/ai-runtime/api/request.js +9 -1
  29. package/lib/esm/builtin/async/ai-runtime/components/GlobalLoading.js +1 -36
  30. package/lib/esm/builtin/async/ai-runtime/components/LoadingListItemButton.js +4 -6
  31. package/lib/esm/builtin/async/ai-runtime/components/RuntimeProvider.js +7 -1
  32. package/lib/esm/builtin/async/ai-runtime/components/common/ChatBot.js +13 -14
  33. package/lib/esm/builtin/async/ai-runtime/components/common/MessageMetadataRenderer.js +3 -3
  34. package/lib/esm/builtin/async/ai-runtime/components/form/ParameterForm.js +29 -11
  35. package/lib/esm/builtin/async/ai-runtime/components/form/ParameterFormFields.js +18 -5
  36. package/lib/esm/builtin/async/ai-runtime/components/form/QuestionField.js +2 -2
  37. package/lib/esm/builtin/async/ai-runtime/components/form/SettingButton.js +7 -5
  38. package/lib/esm/builtin/async/ai-runtime/components/message/MessageItemView.js +70 -75
  39. package/lib/esm/builtin/async/ai-runtime/components/message/MessageListView.js +2 -3
  40. package/lib/esm/builtin/async/ai-runtime/components/message/ReferenceLinks.js +3 -3
  41. package/lib/esm/builtin/async/ai-runtime/components/parameters/index.js +1 -1
  42. package/lib/esm/builtin/async/ai-runtime/components/runtime-chat/InitialForm.js +24 -9
  43. package/lib/esm/builtin/async/ai-runtime/components/runtime-chat/RuntimeChatHeader.js +16 -4
  44. package/lib/esm/builtin/async/ai-runtime/components/runtime-chat/RuntimeChatSession.js +7 -22
  45. package/lib/esm/builtin/async/ai-runtime/components/runtime-chat/index.js +20 -7
  46. package/lib/esm/builtin/async/ai-runtime/components/runtime-form/RuntimeFormForms.js +24 -7
  47. package/lib/esm/builtin/async/ai-runtime/components/session/CheckSession.js +34 -34
  48. package/lib/esm/builtin/async/ai-runtime/error.js +6 -0
  49. package/lib/esm/builtin/async/ai-runtime/hooks/navigate.js +2 -1
  50. package/lib/esm/builtin/async/ai-runtime/hooks/useAsync.js +29 -0
  51. package/lib/esm/builtin/async/ai-runtime/index.js +23 -17
  52. package/lib/esm/builtin/async/ai-runtime/locales/index.js +1 -1
  53. package/lib/esm/builtin/async/ai-runtime/state/loading.js +36 -0
  54. package/lib/esm/builtin/async/ai-runtime/state/session.js +1 -1
  55. package/lib/types/builtin/async/ai-runtime/components/GlobalLoading.d.ts +0 -31
  56. package/lib/types/builtin/async/ai-runtime/components/LoadingListItemButton.d.ts +4 -1
  57. package/lib/types/builtin/async/ai-runtime/components/form/ParameterFormDialog.d.ts +2 -2
  58. package/lib/types/builtin/async/ai-runtime/components/form/ParameterFormFields.d.ts +5 -2
  59. package/lib/types/builtin/async/ai-runtime/components/form/SettingButton.d.ts +4 -2
  60. package/lib/types/builtin/async/ai-runtime/components/message/MessageItemView.d.ts +1 -3
  61. package/lib/types/builtin/async/ai-runtime/components/runtime-chat/InitialForm.d.ts +6 -0
  62. package/lib/types/builtin/async/ai-runtime/components/runtime-chat/RuntimeChatHeader.d.ts +3 -2
  63. package/lib/types/builtin/async/ai-runtime/components/runtime-chat/index.d.ts +3 -2
  64. package/lib/types/builtin/async/ai-runtime/components/session/CheckSession.d.ts +4 -5
  65. package/lib/types/builtin/async/ai-runtime/error.d.ts +4 -0
  66. package/lib/types/builtin/async/ai-runtime/hooks/useAsync.d.ts +1 -0
  67. package/lib/types/builtin/async/ai-runtime/index.d.ts +1 -1
  68. package/lib/types/builtin/async/ai-runtime/state/loading.d.ts +10 -0
  69. package/lib/types/builtin/page/header.d.ts +1 -6
  70. package/lib/types/components/CustomComponentRenderer/state.d.ts +1 -116
  71. package/package.json +9 -9
  72. package/lib/cjs/builtin/async/ai-runtime/components/layout/index.js +0 -15
  73. package/lib/cjs/builtin/async/ai-runtime/components/runtime-chat/RuntimeChatHome.js +0 -21
  74. package/lib/esm/builtin/async/ai-runtime/components/layout/index.js +0 -12
  75. package/lib/esm/builtin/async/ai-runtime/components/runtime-chat/RuntimeChatHome.js +0 -15
  76. package/lib/types/builtin/async/ai-runtime/components/layout/index.d.ts +0 -7
  77. package/lib/types/builtin/async/ai-runtime/components/runtime-chat/RuntimeChatHome.d.ts +0 -4
@@ -1,4 +1,10 @@
1
+ import { StackProps } from '@mui/material';
2
+ import { Assistant } from '../../api/assistant';
1
3
  import { PageState } from '../../hooks/navigate';
2
4
  export default function InitialForm({ page }: {
3
5
  page: PageState;
4
6
  }): import("react/jsx-runtime").JSX.Element | null;
7
+ export declare function EntryListView({ assistant, onEntryClick, ...props }: {
8
+ assistant: Assistant;
9
+ onEntryClick?: (entry: NonNullable<Assistant['entries']>[number]) => void;
10
+ } & StackProps): import("react/jsx-runtime").JSX.Element;
@@ -1,4 +1,5 @@
1
+ import { BoxProps } from '@mui/material';
1
2
  import { Assistant } from '../../api/assistant';
2
- export default function RuntimeChatHeader({ assistant }: {
3
+ export default function RuntimeChatHeader({ assistant, ...props }: {
3
4
  assistant: Assistant;
4
- }): import("react/jsx-runtime").JSX.Element;
5
+ } & BoxProps): import("react/jsx-runtime").JSX.Element;
@@ -1,4 +1,5 @@
1
+ import { StackProps } from '@mui/material';
1
2
  import { PageState } from '../../hooks/navigate';
2
- export default function RuntimeChat({ page }: {
3
+ export default function RuntimeChat({ page, ...props }: {
3
4
  page: PageState;
4
- }): import("react/jsx-runtime").JSX.Element;
5
+ } & StackProps): import("react/jsx-runtime").JSX.Element;
@@ -1,9 +1,8 @@
1
1
  import { ReactNode } from 'react';
2
- import { RuntimeNavigate } from '../../hooks/navigate';
3
- export default function CheckSession({ assistantId, sessionId, autoCreateSession, children, navigate, }: {
4
- assistantId: string;
5
- sessionId?: string;
2
+ import { PageState } from '../../hooks/navigate';
3
+ export default function CheckSession({ cacheId, page, autoCreateSession, children, }: {
4
+ cacheId?: string;
5
+ page: PageState;
6
6
  autoCreateSession?: boolean;
7
7
  children?: ReactNode;
8
- navigate?: RuntimeNavigate;
9
8
  }): ReactNode;
@@ -0,0 +1,4 @@
1
+ export declare class CustomError extends Error {
2
+ status: string | number;
3
+ constructor(status: string | number, message: string);
4
+ }
@@ -0,0 +1 @@
1
+ export default function useAsync<T>(fn: () => T | Promise<T>, keys: (string | number | undefined | null)[]): T;
@@ -8,7 +8,7 @@ export declare function getServerSideProps(): Promise<{
8
8
  } | undefined;
9
9
  };
10
10
  }>;
11
- export default function AIRuntime({ preload }: {
11
+ export default function App(props: {
12
12
  preload?: {
13
13
  assistantId: string;
14
14
  assistant: Assistant;
@@ -0,0 +1,10 @@
1
+ export interface GlobalLoadingState {
2
+ loading: boolean;
3
+ count: number;
4
+ run: <T>(fn: Promise<T> | (() => Promise<T>)) => Promise<T>;
5
+ start: () => void;
6
+ end: () => void;
7
+ }
8
+ export declare const globalLoadingState: import("zustand").UseBoundStore<Omit<import("zustand").StoreApi<GlobalLoadingState>, "setState"> & {
9
+ setState(nextStateOrUpdater: GlobalLoadingState | Partial<GlobalLoadingState> | ((state: import("immer").WritableDraft<GlobalLoadingState>) => void), shouldReplace?: boolean | undefined): void;
10
+ }>;
@@ -5,10 +5,5 @@ export interface HeaderState {
5
5
  addons?: (...exists: any[]) => any[];
6
6
  }
7
7
  export declare const useHeaderState: import("zustand").UseBoundStore<Omit<import("zustand").StoreApi<HeaderState>, "setState"> & {
8
- setState(nextStateOrUpdater: HeaderState | Partial<HeaderState> | ((state: {
9
- logo?: any;
10
- brand?: any;
11
- description?: any;
12
- addons?: ((...exists: any[]) => any[]) | undefined;
13
- }) => void), shouldReplace?: boolean | undefined): void;
8
+ setState(nextStateOrUpdater: HeaderState | Partial<HeaderState> | ((state: import("immer").WritableDraft<HeaderState>) => void), shouldReplace?: boolean | undefined): void;
14
9
  }>;
@@ -18,122 +18,7 @@ export interface CustomComponentStates {
18
18
  loadComponents(input: Pick<PreloadComponentsInput, 'mode' | 'locale' | 'instances'>): Promise<void>;
19
19
  }
20
20
  export declare const customComponentStates: import("zustand").UseBoundStore<Omit<import("zustand").StoreApi<CustomComponentStates>, "setState"> & {
21
- setState(nextStateOrUpdater: CustomComponentStates | Partial<CustomComponentStates> | ((state: {
22
- state: {
23
- config: {
24
- defaultLocale?: string | undefined;
25
- supportedLocales?: {
26
- locale: string;
27
- }[] | undefined;
28
- };
29
- components: {
30
- [x: string]: {
31
- componentModuleGlobalVariable?: string | undefined;
32
- component: {
33
- id: string;
34
- createdAt: string;
35
- updatedAt: string;
36
- name?: string | undefined;
37
- renderer?: {
38
- type: "web-component";
39
- script?: string | undefined;
40
- } | {
41
- type: "react-component";
42
- script?: string | undefined;
43
- } | {
44
- type: "component";
45
- componentId?: string | undefined;
46
- properties?: {
47
- [x: string]: {
48
- locales?: {
49
- [x: string]: {
50
- value?: any;
51
- };
52
- } | undefined;
53
- };
54
- } | undefined;
55
- } | undefined;
56
- properties?: {
57
- [x: string]: {
58
- index: number;
59
- data: {
60
- type: "number" | "boolean" | "json" | "url";
61
- id: string;
62
- key?: string | undefined;
63
- locales?: {
64
- [x: string]: {
65
- name?: string | undefined;
66
- defaultValue?: any;
67
- };
68
- } | undefined;
69
- } | {
70
- type: "custom";
71
- componentId?: string | undefined;
72
- id: string;
73
- key?: string | undefined;
74
- locales?: {
75
- [x: string]: {
76
- name?: string | undefined;
77
- defaultValue?: any;
78
- };
79
- } | undefined;
80
- } | {
81
- type?: "string" | undefined;
82
- multiline?: boolean | undefined;
83
- id: string;
84
- key?: string | undefined;
85
- locales?: {
86
- [x: string]: {
87
- name?: string | undefined;
88
- defaultValue?: any;
89
- };
90
- } | undefined;
91
- } | {
92
- type: "component";
93
- locales?: {
94
- [x: string]: {
95
- name?: undefined;
96
- defaultValue?: {
97
- componentId?: string | undefined;
98
- properties: any;
99
- } | undefined;
100
- };
101
- } | undefined;
102
- id: string;
103
- key?: string | undefined;
104
- };
105
- };
106
- } | undefined;
107
- };
108
- Component?: ComponentType | undefined;
109
- };
110
- };
111
- instances: {
112
- [x: string]: {
113
- componentId: string;
114
- locales?: {
115
- [x: string]: {
116
- props?: {
117
- [x: string]: any;
118
- } | undefined;
119
- };
120
- } | undefined;
121
- };
122
- };
123
- };
124
- getComponent: (options: {
125
- locale: string;
126
- instanceId?: string;
127
- componentId: string;
128
- }) => {
129
- component: CustomComponent;
130
- Component: ComponentType;
131
- props?: {
132
- [key: string]: any;
133
- };
134
- } | null;
135
- loadComponents: (input: Pick<PreloadComponentsInput, 'mode' | 'locale' | 'instances'>) => Promise<void>;
136
- }) => void), shouldReplace?: boolean | undefined): void;
21
+ setState(nextStateOrUpdater: CustomComponentStates | Partial<CustomComponentStates> | ((state: import("immer").WritableDraft<CustomComponentStates>) => void), shouldReplace?: boolean | undefined): void;
137
22
  }>;
138
23
  export declare function useComponent({ instanceId, componentId, properties, locale, dev }: CustomComponentRendererProps): {
139
24
  error?: Error;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/pages-kit",
3
- "version": "0.2.287",
3
+ "version": "0.2.288",
4
4
  "description": "Pages Kit components and utils",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -93,17 +93,17 @@
93
93
  "prepare": "npm run build"
94
94
  },
95
95
  "dependencies": {
96
- "@arcblock/did-connect": "^2.9.71",
96
+ "@arcblock/did-connect": "^2.9.73",
97
97
  "@blocklet/ai-kit": "^0.1.27",
98
- "@blocklet/ai-runtime": "^0.1.346",
98
+ "@blocklet/ai-runtime": "^0.1.349",
99
99
  "@blocklet/js-sdk": "1.16.26-beta-cca12425",
100
- "@blocklet/sdk": "^1.16.25",
100
+ "@blocklet/sdk": "^1.16.26",
101
101
  "@iconify/react": "^4.1.1",
102
102
  "@lottiefiles/lottie-player": "^1.7.1",
103
103
  "axios": "^1.6.8",
104
104
  "dayjs": "^1.11.10",
105
105
  "eventsource-parser": "^1.1.2",
106
- "immer": "^10.0.4",
106
+ "immer": "^10.1.1",
107
107
  "js-base64": "^3.7.7",
108
108
  "lodash": "^4.17.21",
109
109
  "nanoid": "^3.3.7",
@@ -134,7 +134,7 @@
134
134
  "react-router-dom": "^6.16.0"
135
135
  },
136
136
  "devDependencies": {
137
- "@arcblock/ux": "^2.9.71",
137
+ "@arcblock/ux": "^2.9.73",
138
138
  "@emotion/cache": "^11.11.0",
139
139
  "@emotion/css": "^11.11.2",
140
140
  "@emotion/react": "^11.11.4",
@@ -144,13 +144,13 @@
144
144
  "@types/lodash": "^4.17.0",
145
145
  "@types/mustache": "^4.2.5",
146
146
  "@types/node-fetch": "^2.6.11",
147
- "@types/react": "^18.3.0",
147
+ "@types/react": "^18.3.1",
148
148
  "@types/react-scroll-to-bottom": "^4.2.5",
149
149
  "@types/react-syntax-highlighter": "^15.5.11",
150
150
  "axios": "^1.6.8",
151
151
  "npm-run-all": "^4.1.5",
152
- "react": "^18.3.0",
153
- "react-dom": "^18.3.0",
152
+ "react": "^18.3.1",
153
+ "react-dom": "^18.3.1",
154
154
  "react-router-dom": "^6.23.0",
155
155
  "rimraf": "^5.0.5"
156
156
  }
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const jsx_runtime_1 = require("react/jsx-runtime");
4
- const material_1 = require("@mui/material");
5
- const utils_1 = require("../../utils");
6
- function Layout({ children, disableBottomPadding, containerProps, }) {
7
- return ((0, jsx_runtime_1.jsx)(material_1.Stack, { className: "ai-chat-wrapper", mx: 2, flexGrow: 1, children: (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: "ai-chat-container" }, containerProps, { sx: (0, utils_1.mergeSx)({
8
- flexGrow: 1,
9
- maxWidth: 720,
10
- width: '100%',
11
- mx: 'auto',
12
- pb: disableBottomPadding ? 0 : 10,
13
- }, containerProps === null || containerProps === void 0 ? void 0 : containerProps.sx), children: children })) }));
14
- }
15
- exports.default = Layout;
@@ -1,21 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const jsx_runtime_1 = require("react/jsx-runtime");
7
- const assistant_1 = require("../../state/assistant");
8
- const layout_1 = __importDefault(require("../layout"));
9
- const InitialForm_1 = __importDefault(require("./InitialForm"));
10
- const RuntimeChatHeader_1 = __importDefault(require("./RuntimeChatHeader"));
11
- function RuntimeChatHome({ page }) {
12
- const [assistant] = (0, assistant_1.useAssistantState)({ assistantId: page.assistantId });
13
- return ((0, jsx_runtime_1.jsxs)(layout_1.default, { disableBottomPadding: true, containerProps: {
14
- sx: {
15
- display: 'flex',
16
- flexDirection: 'column',
17
- height: '100%',
18
- },
19
- }, children: [(0, jsx_runtime_1.jsx)(RuntimeChatHeader_1.default, { assistant: assistant }), (0, jsx_runtime_1.jsx)(InitialForm_1.default, { page: page })] }));
20
- }
21
- exports.default = RuntimeChatHome;
@@ -1,12 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { Box, Stack } from '@mui/material';
3
- import { mergeSx } from '../../utils';
4
- export default function Layout({ children, disableBottomPadding, containerProps, }) {
5
- return (_jsx(Stack, { className: "ai-chat-wrapper", mx: 2, flexGrow: 1, children: _jsx(Box, Object.assign({ className: "ai-chat-container" }, containerProps, { sx: mergeSx({
6
- flexGrow: 1,
7
- maxWidth: 720,
8
- width: '100%',
9
- mx: 'auto',
10
- pb: disableBottomPadding ? 0 : 10,
11
- }, containerProps === null || containerProps === void 0 ? void 0 : containerProps.sx), children: children })) }));
12
- }
@@ -1,15 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useAssistantState } from '../../state/assistant';
3
- import Layout from '../layout';
4
- import InitialForm from './InitialForm';
5
- import RuntimeChatHeader from './RuntimeChatHeader';
6
- export default function RuntimeChatHome({ page }) {
7
- const [assistant] = useAssistantState({ assistantId: page.assistantId });
8
- return (_jsxs(Layout, { disableBottomPadding: true, containerProps: {
9
- sx: {
10
- display: 'flex',
11
- flexDirection: 'column',
12
- height: '100%',
13
- },
14
- }, children: [_jsx(RuntimeChatHeader, { assistant: assistant }), _jsx(InitialForm, { page: page })] }));
15
- }
@@ -1,7 +0,0 @@
1
- import { BoxProps } from '@mui/material';
2
- import { ReactNode } from 'react';
3
- export default function Layout({ children, disableBottomPadding, containerProps, }: {
4
- children: ReactNode;
5
- disableBottomPadding?: boolean;
6
- containerProps?: BoxProps;
7
- }): import("react/jsx-runtime").JSX.Element;
@@ -1,4 +0,0 @@
1
- import { PageState } from '../../hooks/navigate';
2
- export default function RuntimeChatHome({ page }: {
3
- page: PageState;
4
- }): import("react/jsx-runtime").JSX.Element;