@blocklet/pages-kit 0.2.366 → 0.2.367
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/lib/cjs/builtin/async/ai-runtime/components/ShareActions/Community.js +6 -0
- package/lib/cjs/builtin/async/ai-runtime/components/ShareActions/index.js +37 -10
- package/lib/cjs/builtin/async/ai-runtime/contexts/Identity.js +36 -0
- package/lib/cjs/builtin/async/ai-runtime/contexts/Runtime.js +45 -25
- package/lib/cjs/builtin/async/ai-runtime/index.js +6 -3
- package/lib/cjs/builtin/async/ai-runtime/locales/index.js +2 -0
- package/lib/cjs/builtin/async/ai-runtime/runtime/ChatBotButton/index.js +1 -3
- package/lib/cjs/builtin/async/ai-runtime/runtime/Runtime/index.js +2 -4
- package/lib/cjs/builtin/async/ai-runtime/state/agent.js +3 -3
- package/lib/cjs/builtin/async/ai-runtime/state/runtime.js +2 -2
- package/lib/cjs/builtin/async/ai-runtime/state/session.js +3 -3
- package/lib/cjs/tsconfig.tsbuildinfo +1 -1
- package/lib/esm/builtin/async/ai-runtime/components/ShareActions/Community.js +4 -0
- package/lib/esm/builtin/async/ai-runtime/components/ShareActions/index.js +38 -11
- package/lib/esm/builtin/async/ai-runtime/contexts/Identity.js +28 -0
- package/lib/esm/builtin/async/ai-runtime/contexts/Runtime.js +19 -24
- package/lib/esm/builtin/async/ai-runtime/index.js +2 -0
- package/lib/esm/builtin/async/ai-runtime/locales/index.js +2 -0
- package/lib/esm/builtin/async/ai-runtime/runtime/ChatBotButton/index.js +1 -3
- package/lib/esm/builtin/async/ai-runtime/runtime/Runtime/index.js +2 -4
- package/lib/esm/builtin/async/ai-runtime/state/agent.js +3 -3
- package/lib/esm/builtin/async/ai-runtime/state/runtime.js +2 -2
- package/lib/esm/builtin/async/ai-runtime/state/session.js +3 -3
- package/lib/esm/tsconfig.tsbuildinfo +1 -1
- package/lib/types/builtin/async/ai-runtime/components/ShareActions/Community.d.ts +4 -0
- package/lib/types/builtin/async/ai-runtime/contexts/Identity.d.ts +16 -0
- package/lib/types/builtin/async/ai-runtime/contexts/Runtime.d.ts +4 -16
- package/lib/types/builtin/async/ai-runtime/index.d.ts +2 -0
- package/lib/types/builtin/async/ai-runtime/locales/index.d.ts +2 -0
- package/lib/types/builtin/async/ai-runtime/state/session.d.ts +1 -2
- package/lib/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,6 @@
|
|
|
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 CommunityIcon = (0, material_1.createSvgIcon)((0, jsx_runtime_1.jsxs)("svg", { style: { width: '15px', height: '15px' }, viewBox: "0 0 60 60", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [(0, jsx_runtime_1.jsx)("path", { opacity: "0.6", fillRule: "evenodd", clipRule: "evenodd", d: "M29.2518 28.4159V29.282L28.5018 29.715L6.89191 42.1915L7.64197 43.4906L30.0019 30.5811L52.3618 43.4906L53.1119 42.1915L31.502 29.715L30.752 29.282V28.4159V3.46293H29.2518V28.4159Z", stroke: "currentColor", fill: "white", strokeWidth: "2" }), (0, jsx_runtime_1.jsx)("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M30.0019 2L54.0038 15.8575V43.5725L30.0019 57.43L6 43.5725V15.8575L30.0019 2ZM8.25018 16.2905L23.1764 24.9082L30.0019 13.086L36.8274 24.9082L51.7536 16.2905L30.0019 3.73219L8.25018 16.2905ZM52.5037 17.5897L37.5775 26.2073L44.403 38.0295L30.752 45.911V55.2648L52.5037 42.7064V17.5897ZM29.2518 55.2648V45.911L15.6008 38.0295L22.4263 26.2073L7.50012 17.5897V42.7064L29.2518 55.2648ZM23.7254 26.9574L17.65 37.4804L29.2518 44.1788V31.0141V30.148L28.5018 29.715L23.7254 26.9574ZM30.752 44.1788L42.3538 37.4804L36.2784 26.9574L31.502 29.715L30.752 30.148V31.0141V44.1788ZM35.5283 25.6582L30.0019 16.0862L24.4755 25.6582L30.0019 28.8489L35.5283 25.6582Z", stroke: "currentColor", fill: "white", strokeWidth: "2" })] }), 'AIGNE');
|
|
6
|
+
exports.default = CommunityIcon;
|
|
@@ -52,7 +52,7 @@ const types_1 = require("@blocklet/ai-runtime/types");
|
|
|
52
52
|
const react_1 = require("@iconify/react");
|
|
53
53
|
const material_1 = require("@mui/material");
|
|
54
54
|
const file_saver_1 = require("file-saver");
|
|
55
|
-
const lodash_1 =
|
|
55
|
+
const lodash_1 = require("lodash");
|
|
56
56
|
const react_2 = require("react");
|
|
57
57
|
const ufo_1 = require("ufo");
|
|
58
58
|
const locale_1 = require("../../../../locale");
|
|
@@ -63,6 +63,7 @@ const runtime_1 = require("../../state/runtime");
|
|
|
63
63
|
const agent_inputs_1 = require("../../utils/agent-inputs");
|
|
64
64
|
const download_image_1 = require("../../utils/download-image");
|
|
65
65
|
const ActionButton_1 = __importDefault(require("../ActionButton"));
|
|
66
|
+
const Community_1 = __importDefault(require("./Community"));
|
|
66
67
|
function ShareActions(_a) {
|
|
67
68
|
var _b;
|
|
68
69
|
var props = __rest(_a, []);
|
|
@@ -81,7 +82,7 @@ function ShareActions(_a) {
|
|
|
81
82
|
const C = ShareActionsMap[item.to];
|
|
82
83
|
if (!C)
|
|
83
84
|
return null;
|
|
84
|
-
return ((0, jsx_runtime_1.jsx)(material_1.Box, { children: (0, jsx_runtime_1.jsx)(C, { inputs: JSON.stringify(lodash_1.
|
|
85
|
+
return ((0, jsx_runtime_1.jsx)(material_1.Box, { children: (0, jsx_runtime_1.jsx)(C, { inputs: JSON.stringify((0, lodash_1.fromPairs)(params), null, 2), shareAttach: {
|
|
85
86
|
shareAttachInputs: (_a = sharing === null || sharing === void 0 ? void 0 : sharing.shareAttachInputs) !== null && _a !== void 0 ? _a : false,
|
|
86
87
|
shareAttachUrl: (_b = sharing === null || sharing === void 0 ? void 0 : sharing.shareAttachUrl) !== null && _b !== void 0 ? _b : false,
|
|
87
88
|
} }) }));
|
|
@@ -95,11 +96,13 @@ const ShareActionsMap = {
|
|
|
95
96
|
copy: ShareCopy,
|
|
96
97
|
saveAs: ShareSave,
|
|
97
98
|
community: ShareCommunity,
|
|
99
|
+
link: ShareLink,
|
|
98
100
|
};
|
|
99
101
|
function ShareTwitter({ inputs, shareAttach, }) {
|
|
100
102
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
101
103
|
const { t } = (0, locale_1.useLocaleContext)();
|
|
102
104
|
const { message } = (0, CurrentMessage_1.useCurrentMessage)();
|
|
105
|
+
const { link } = useCurrentLink();
|
|
103
106
|
let content = ((_c = (_b = (_a = message.outputs) === null || _a === void 0 ? void 0 : _a.objects) === null || _b === void 0 ? void 0 : _b.find((i) => i === null || i === void 0 ? void 0 : i[types_1.RuntimeOutputVariable.text])) === null || _c === void 0 ? void 0 : _c[types_1.RuntimeOutputVariable.text]) ||
|
|
104
107
|
((_h = (_g = (_f = (_e = (_d = message.outputs) === null || _d === void 0 ? void 0 : _d.objects) === null || _e === void 0 ? void 0 : _e.find((i) => { var _a; return (_a = i === null || i === void 0 ? void 0 : i[types_1.RuntimeOutputVariable.images]) === null || _a === void 0 ? void 0 : _a.length; })) === null || _f === void 0 ? void 0 : _f[types_1.RuntimeOutputVariable.images]) === null || _g === void 0 ? void 0 : _g.at(0)) === null || _h === void 0 ? void 0 : _h.url);
|
|
105
108
|
if (!content)
|
|
@@ -107,15 +110,29 @@ function ShareTwitter({ inputs, shareAttach, }) {
|
|
|
107
110
|
if (shareAttach.shareAttachInputs) {
|
|
108
111
|
content += `\nInputs: ${inputs}`;
|
|
109
112
|
}
|
|
113
|
+
// 如果 content 长度超过 100,截断
|
|
114
|
+
if (content.length > 100) {
|
|
115
|
+
content = `${content.slice(0, 100)}...`;
|
|
116
|
+
}
|
|
110
117
|
return ((0, jsx_runtime_1.jsx)(StyledActionButton, { tip: t('socialShare.shareToX'), title: (0, jsx_runtime_1.jsx)(react_1.Icon, { icon: "tabler:brand-x" }), target: "_blank", href: (0, ufo_1.withQuery)('https://twitter.com/intent/tweet', {
|
|
111
118
|
text: content,
|
|
112
|
-
url:
|
|
119
|
+
url: link,
|
|
120
|
+
}) }));
|
|
121
|
+
}
|
|
122
|
+
function ShareLink() {
|
|
123
|
+
const { t } = (0, locale_1.useLocaleContext)();
|
|
124
|
+
const { link } = useCurrentLink();
|
|
125
|
+
return ((0, jsx_runtime_1.jsx)(StyledActionButton, { autoReset: true, tip: t('socialShare.copyLink'), tipSucceed: t('copied'), title: (0, jsx_runtime_1.jsx)(react_1.Icon, { icon: "tabler:link" }), titleSucceed: (0, jsx_runtime_1.jsx)(react_1.Icon, { icon: "tabler:link-plus" }), onClick: () => __awaiter(this, void 0, void 0, function* () {
|
|
126
|
+
if (link) {
|
|
127
|
+
window.navigator.clipboard.writeText(link);
|
|
128
|
+
}
|
|
113
129
|
}) }));
|
|
114
130
|
}
|
|
115
131
|
function ShareCopy({ inputs, shareAttach, }) {
|
|
116
132
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
117
133
|
const { t } = (0, locale_1.useLocaleContext)();
|
|
118
134
|
const { message } = (0, CurrentMessage_1.useCurrentMessage)();
|
|
135
|
+
const { link } = useCurrentLink();
|
|
119
136
|
let content = (_c = (_b = (_a = message.outputs) === null || _a === void 0 ? void 0 : _a.objects) === null || _b === void 0 ? void 0 : _b.find((i) => i === null || i === void 0 ? void 0 : i[types_1.RuntimeOutputVariable.text])) === null || _c === void 0 ? void 0 : _c[types_1.RuntimeOutputVariable.text];
|
|
120
137
|
const image = (_h = (_g = (_f = (_e = (_d = message.outputs) === null || _d === void 0 ? void 0 : _d.objects) === null || _e === void 0 ? void 0 : _e.find((i) => { var _a; return (_a = i === null || i === void 0 ? void 0 : i[types_1.RuntimeOutputVariable.images]) === null || _a === void 0 ? void 0 : _a.length; })) === null || _f === void 0 ? void 0 : _f[types_1.RuntimeOutputVariable.images]) === null || _g === void 0 ? void 0 : _g.at(0)) === null || _h === void 0 ? void 0 : _h.url;
|
|
121
138
|
if (!content && !image)
|
|
@@ -126,7 +143,7 @@ function ShareCopy({ inputs, shareAttach, }) {
|
|
|
126
143
|
content += `\nInputs: ${inputs}`;
|
|
127
144
|
}
|
|
128
145
|
if (shareAttach.shareAttachUrl) {
|
|
129
|
-
content += `\nURL: ${
|
|
146
|
+
content += `\nURL: ${link}`;
|
|
130
147
|
}
|
|
131
148
|
window.navigator.clipboard.writeText(content);
|
|
132
149
|
}
|
|
@@ -142,6 +159,7 @@ function ShareSave({ inputs, shareAttach, }) {
|
|
|
142
159
|
const { message } = (0, CurrentMessage_1.useCurrentMessage)();
|
|
143
160
|
const { aid, agent } = (0, runtime_1.useRuntimeState)();
|
|
144
161
|
const profile = (0, use_appearances_1.useProfile)({ aid });
|
|
162
|
+
const { link } = useCurrentLink();
|
|
145
163
|
const content = (_c = (_b = (_a = message.outputs) === null || _a === void 0 ? void 0 : _a.objects) === null || _b === void 0 ? void 0 : _b.find((i) => i === null || i === void 0 ? void 0 : i[types_1.RuntimeOutputVariable.text])) === null || _c === void 0 ? void 0 : _c[types_1.RuntimeOutputVariable.text];
|
|
146
164
|
const image = (_h = (_g = (_f = (_e = (_d = message.outputs) === null || _d === void 0 ? void 0 : _d.objects) === null || _e === void 0 ? void 0 : _e.find((i) => { var _a; return (_a = i === null || i === void 0 ? void 0 : i[types_1.RuntimeOutputVariable.images]) === null || _a === void 0 ? void 0 : _a.length; })) === null || _f === void 0 ? void 0 : _f[types_1.RuntimeOutputVariable.images]) === null || _g === void 0 ? void 0 : _g.at(0)) === null || _h === void 0 ? void 0 : _h.url;
|
|
147
165
|
if (!content && !image)
|
|
@@ -156,7 +174,7 @@ function ShareSave({ inputs, shareAttach, }) {
|
|
|
156
174
|
element.innerHTML += `<br/>Inputs: ${inputs}`;
|
|
157
175
|
}
|
|
158
176
|
if (shareAttach.shareAttachUrl) {
|
|
159
|
-
element.innerHTML += `<br/>URL: ${
|
|
177
|
+
element.innerHTML += `<br/>URL: ${link}`;
|
|
160
178
|
}
|
|
161
179
|
yield html2pdf()
|
|
162
180
|
.set({
|
|
@@ -175,25 +193,28 @@ function ShareSave({ inputs, shareAttach, }) {
|
|
|
175
193
|
}) }));
|
|
176
194
|
}
|
|
177
195
|
function ShareCommunity({ inputs, shareAttach, }) {
|
|
178
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
196
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
179
197
|
const { t } = (0, locale_1.useLocaleContext)();
|
|
180
198
|
const { message } = (0, CurrentMessage_1.useCurrentMessage)();
|
|
199
|
+
const { link } = useCurrentLink();
|
|
200
|
+
const { agent } = (0, CurrentAgent_1.useCurrentAgent)();
|
|
181
201
|
let content = (_d = (_c = (_b = (_a = message.outputs) === null || _a === void 0 ? void 0 : _a.objects) === null || _b === void 0 ? void 0 : _b.find((i) => i === null || i === void 0 ? void 0 : i[types_1.RuntimeOutputVariable.text])) === null || _c === void 0 ? void 0 : _c[types_1.RuntimeOutputVariable.text]) !== null && _d !== void 0 ? _d : '';
|
|
182
202
|
const image = ((_k = (_j = (_h = (_g = (_f = (_e = message.outputs) === null || _e === void 0 ? void 0 : _e.objects) === null || _f === void 0 ? void 0 : _f.find) === null || _g === void 0 ? void 0 : _g.call(_f, (i) => { var _a; return (_a = i === null || i === void 0 ? void 0 : i[types_1.RuntimeOutputVariable.images]) === null || _a === void 0 ? void 0 : _a.length; })) === null || _h === void 0 ? void 0 : _h[types_1.RuntimeOutputVariable.images]) === null || _j === void 0 ? void 0 : _j.map((i) => i.url)) !== null && _k !== void 0 ? _k : []).join(',');
|
|
203
|
+
content = `[Sharing from ${(_l = agent === null || agent === void 0 ? void 0 : agent.project) === null || _l === void 0 ? void 0 : _l.name}]: ${window.location.href}\n ${content}`;
|
|
183
204
|
if (!content && !image)
|
|
184
205
|
return null;
|
|
185
206
|
if (shareAttach.shareAttachInputs) {
|
|
186
207
|
content += `\nInputs: ${inputs}`;
|
|
187
208
|
}
|
|
188
209
|
if (shareAttach.shareAttachUrl) {
|
|
189
|
-
content += `\nURL: ${
|
|
210
|
+
content += `\nURL: ${link}`;
|
|
190
211
|
}
|
|
191
|
-
return ((0, jsx_runtime_1.jsx)(StyledActionButton, { tip: t('
|
|
212
|
+
return ((0, jsx_runtime_1.jsx)(StyledActionButton, { tip: t('socialShare.shareToCommunity'), title: (0, jsx_runtime_1.jsx)(Community_1.default, {}), target: "_blank", href: (0, ufo_1.withQuery)('https://community.arcblock.io/discussions/add?', (0, lodash_1.pickBy)({
|
|
192
213
|
boardId: 'aigne',
|
|
193
|
-
title:
|
|
214
|
+
title: `${((_m = message.inputs) === null || _m === void 0 ? void 0 : _m.question) || ''}`,
|
|
194
215
|
content,
|
|
195
216
|
images: image,
|
|
196
|
-
}) }));
|
|
217
|
+
}, lodash_1.identity)) }));
|
|
197
218
|
}
|
|
198
219
|
const StyledActionButton = (0, material_1.styled)(ActionButton_1.default)(({ theme }) => theme.unstable_sx({
|
|
199
220
|
fontSize: 'inherit',
|
|
@@ -201,3 +222,9 @@ const StyledActionButton = (0, material_1.styled)(ActionButton_1.default)(({ the
|
|
|
201
222
|
minWidth: '0 !important',
|
|
202
223
|
minHeight: '0 !important',
|
|
203
224
|
}));
|
|
225
|
+
const useCurrentLink = () => {
|
|
226
|
+
var _a;
|
|
227
|
+
const { message } = (0, CurrentMessage_1.useCurrentMessage)();
|
|
228
|
+
const link = (0, ufo_1.joinURL)(window.origin, ((_a = window.blocklet) === null || _a === void 0 ? void 0 : _a.prefix) || '/', '/messages', message.id);
|
|
229
|
+
return { link };
|
|
230
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
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
|
+
exports.useIdentityContext = useIdentityContext;
|
|
7
|
+
exports.default = IdentityProvider;
|
|
8
|
+
exports.IdentityProviderFromUrl = IdentityProviderFromUrl;
|
|
9
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
10
|
+
const react_1 = require("react");
|
|
11
|
+
const react_router_dom_1 = require("react-router-dom");
|
|
12
|
+
const RuntimeCommonProvider_1 = __importDefault(require("../components/RuntimeCommonProvider"));
|
|
13
|
+
const error_1 = require("../error");
|
|
14
|
+
const identityContext = (0, react_1.createContext)(undefined);
|
|
15
|
+
function useIdentityContext() {
|
|
16
|
+
const context = (0, react_1.useContext)(identityContext);
|
|
17
|
+
if (!context) {
|
|
18
|
+
throw new Error('No such runtime context. You should use `useRuntimeContext` within the `RuntimeProvider`');
|
|
19
|
+
}
|
|
20
|
+
return context;
|
|
21
|
+
}
|
|
22
|
+
function IdentityProvider({ blockletDid, aid, working, children, }) {
|
|
23
|
+
if (!aid)
|
|
24
|
+
throw new Error('Missing required props `aid`');
|
|
25
|
+
const value = (0, react_1.useMemo)(() => ({ blockletDid, aid, working }), [blockletDid, aid, working]);
|
|
26
|
+
return ((0, jsx_runtime_1.jsx)(RuntimeCommonProvider_1.default, { children: (0, jsx_runtime_1.jsx)(identityContext.Provider, { value: value, children: children }) }));
|
|
27
|
+
}
|
|
28
|
+
function IdentityProviderFromUrl({ children }) {
|
|
29
|
+
const [query] = (0, react_router_dom_1.useSearchParams)();
|
|
30
|
+
const aid = query.get('aid');
|
|
31
|
+
const blockletDid = query.get('blockletDid') || undefined;
|
|
32
|
+
const working = query.get('working') === 'true';
|
|
33
|
+
if (!aid)
|
|
34
|
+
throw new error_1.CustomError(404, 'Missing required query parameters `aid`');
|
|
35
|
+
return ((0, jsx_runtime_1.jsx)(IdentityProvider, { blockletDid: blockletDid, aid: aid, working: working, children: children }));
|
|
36
|
+
}
|
|
@@ -1,32 +1,52 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
26
|
+
var t = {};
|
|
27
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
28
|
+
t[p] = s[p];
|
|
29
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
30
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
31
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
32
|
+
t[p[i]] = s[p[i]];
|
|
33
|
+
}
|
|
34
|
+
return t;
|
|
35
|
+
};
|
|
36
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
|
+
};
|
|
2
39
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useRuntimeContext = useRuntimeContext;
|
|
4
40
|
exports.default = RuntimeProvider;
|
|
5
41
|
exports.RuntimeProviderFromUrl = RuntimeProviderFromUrl;
|
|
6
42
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const context = (0, react_1.useContext)(runtimeContext);
|
|
13
|
-
if (!context) {
|
|
14
|
-
throw new Error('No such runtime context. You should use `useRuntimeContext` within the `RuntimeProvider`');
|
|
15
|
-
}
|
|
16
|
-
return context;
|
|
17
|
-
}
|
|
18
|
-
function RuntimeProvider({ blockletDid, aid, working, children, }) {
|
|
19
|
-
if (!aid)
|
|
20
|
-
throw new Error('Missing required props `aid`');
|
|
21
|
-
const value = (0, react_1.useMemo)(() => ({ blockletDid, aid, working }), [blockletDid, aid, working]);
|
|
22
|
-
return (0, jsx_runtime_1.jsx)(runtimeContext.Provider, { value: value, children: children });
|
|
43
|
+
const ThemeProvider_1 = __importDefault(require("../components/ThemeProvider"));
|
|
44
|
+
const Identity_1 = __importStar(require("./Identity"));
|
|
45
|
+
function RuntimeProvider(_a) {
|
|
46
|
+
var props = __rest(_a, []);
|
|
47
|
+
return ((0, jsx_runtime_1.jsx)(Identity_1.default, Object.assign({}, props, { children: (0, jsx_runtime_1.jsx)(ThemeProvider_1.default, { children: props.children }) })));
|
|
23
48
|
}
|
|
24
|
-
function RuntimeProviderFromUrl(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const blockletDid = query.get('blockletDid') || undefined;
|
|
28
|
-
const working = query.get('working') === 'true';
|
|
29
|
-
if (!aid)
|
|
30
|
-
throw new error_1.CustomError(404, 'Missing required query parameters `aid`');
|
|
31
|
-
return ((0, jsx_runtime_1.jsx)(RuntimeProvider, { blockletDid: blockletDid, aid: aid, working: working, children: children }));
|
|
49
|
+
function RuntimeProviderFromUrl(_a) {
|
|
50
|
+
var props = __rest(_a, []);
|
|
51
|
+
return ((0, jsx_runtime_1.jsx)(Identity_1.IdentityProviderFromUrl, Object.assign({}, props, { children: (0, jsx_runtime_1.jsx)(ThemeProvider_1.default, { children: props.children }) })));
|
|
32
52
|
}
|
|
@@ -17,7 +17,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
17
17
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
18
|
};
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.MarkdownView = exports.GoogleSearchSourcesView = exports.GoogleSearchRelatedQuestionsView = exports.ImagesView = exports.OpeningQuestionsView = exports.ShareView = exports.ReferencedLinksView = exports.SuggestedQuestionsView = exports.PhotoGalleryItem = exports.ChatOutput = exports.SimpleOutput = exports.AutoForm = exports.PhotoGallery = exports.SimpleChat = exports.SimplePage = exports.ChatBotButton = exports.Runtime = exports.useAppearances = exports.ActiveAgentProvider = exports.CurrentMessageProvider = exports.CurrentAgentProvider = exports.ComponentPreferencesProvider = void 0;
|
|
20
|
+
exports.MarkdownView = exports.GoogleSearchSourcesView = exports.GoogleSearchRelatedQuestionsView = exports.ImagesView = exports.OpeningQuestionsView = exports.ShareView = exports.ReferencedLinksView = exports.SuggestedQuestionsView = exports.PhotoGalleryItem = exports.ChatOutput = exports.SimpleOutput = exports.AutoForm = exports.PhotoGallery = exports.SimpleChat = exports.SimplePage = exports.ChatBotButton = exports.Runtime = exports.useAppearances = exports.ActiveAgentProvider = exports.CurrentMessageProvider = exports.CurrentAgentProvider = exports.ComponentPreferencesProvider = exports.RuntimeProvider = void 0;
|
|
21
|
+
__exportStar(require("./contexts/Runtime"), exports);
|
|
22
|
+
var Runtime_1 = require("./contexts/Runtime");
|
|
23
|
+
Object.defineProperty(exports, "RuntimeProvider", { enumerable: true, get: function () { return __importDefault(Runtime_1).default; } });
|
|
21
24
|
__exportStar(require("./contexts/ComponentPreferences"), exports);
|
|
22
25
|
var ComponentPreferences_1 = require("./contexts/ComponentPreferences");
|
|
23
26
|
Object.defineProperty(exports, "ComponentPreferencesProvider", { enumerable: true, get: function () { return __importDefault(ComponentPreferences_1).default; } });
|
|
@@ -34,8 +37,8 @@ var use_appearances_1 = require("./hooks/use-appearances");
|
|
|
34
37
|
Object.defineProperty(exports, "useAppearances", { enumerable: true, get: function () { return __importDefault(use_appearances_1).default; } });
|
|
35
38
|
__exportStar(require("./state/runtime"), exports);
|
|
36
39
|
__exportStar(require("./state/session"), exports);
|
|
37
|
-
var
|
|
38
|
-
Object.defineProperty(exports, "Runtime", { enumerable: true, get: function () { return __importDefault(
|
|
40
|
+
var Runtime_2 = require("./runtime/Runtime");
|
|
41
|
+
Object.defineProperty(exports, "Runtime", { enumerable: true, get: function () { return __importDefault(Runtime_2).default; } });
|
|
39
42
|
var ChatBotButton_1 = require("./runtime/ChatBotButton");
|
|
40
43
|
Object.defineProperty(exports, "ChatBotButton", { enumerable: true, get: function () { return __importDefault(ChatBotButton_1).default; } });
|
|
41
44
|
var SimplePage_1 = require("./runtime-components/SimplePage");
|
|
@@ -13,6 +13,7 @@ exports.translations = {
|
|
|
13
13
|
shareToFacebook: 'Share to Facebook',
|
|
14
14
|
shareToLinkedin: 'Share to Linkedin',
|
|
15
15
|
copyLink: 'Copy Link',
|
|
16
|
+
shareToCommunity: 'Share to Community',
|
|
16
17
|
},
|
|
17
18
|
photoWall: {
|
|
18
19
|
dialog: {
|
|
@@ -127,6 +128,7 @@ exports.translations = {
|
|
|
127
128
|
shareToFacebook: '分享到 Facebook',
|
|
128
129
|
shareToLinkedin: '分享到 Linkedin',
|
|
129
130
|
copyLink: '复制链接',
|
|
131
|
+
shareToCommunity: '分享到社区',
|
|
130
132
|
},
|
|
131
133
|
photoWall: {
|
|
132
134
|
dialog: {
|
|
@@ -46,9 +46,7 @@ const ux_1 = require("../../../../arcblock/ux");
|
|
|
46
46
|
const locale_1 = require("../../../../locale");
|
|
47
47
|
const PopperMenuButton_1 = __importDefault(require("../../components/PopperMenuButton"));
|
|
48
48
|
const LoadingMenuItem_1 = __importDefault(require("../../components/PopperMenuButton/LoadingMenuItem"));
|
|
49
|
-
const RuntimeCommonProvider_1 = __importDefault(require("../../components/RuntimeCommonProvider"));
|
|
50
49
|
const ScrollView_1 = __importDefault(require("../../components/ScrollView"));
|
|
51
|
-
const ThemeProvider_1 = __importDefault(require("../../components/ThemeProvider"));
|
|
52
50
|
const constants_1 = require("../../constants");
|
|
53
51
|
const ActiveAgent_1 = __importDefault(require("../../contexts/ActiveAgent"));
|
|
54
52
|
const Runtime_1 = __importDefault(require("../../contexts/Runtime"));
|
|
@@ -56,7 +54,7 @@ const use_appearances_1 = __importStar(require("../../hooks/use-appearances"));
|
|
|
56
54
|
const runtime_1 = require("../../state/runtime");
|
|
57
55
|
const session_1 = require("../../state/session");
|
|
58
56
|
function ChatBotButton({ aid, working }) {
|
|
59
|
-
return ((0, jsx_runtime_1.jsx)(
|
|
57
|
+
return ((0, jsx_runtime_1.jsx)(Runtime_1.default, { aid: aid, working: working, children: (0, jsx_runtime_1.jsx)(ActiveAgent_1.default, { children: (0, jsx_runtime_1.jsx)(ChatBotContent, {}) }) }));
|
|
60
58
|
}
|
|
61
59
|
function ChatBotContent() {
|
|
62
60
|
var _a, _b;
|
|
@@ -31,16 +31,14 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
31
31
|
const react_helmet_1 = require("react-helmet");
|
|
32
32
|
const CustomComponentRenderer_1 = __importDefault(require("../../../../../components/CustomComponentRenderer"));
|
|
33
33
|
const AgentSettingsDialog_1 = __importDefault(require("../../components/AgentSettings/AgentSettingsDialog"));
|
|
34
|
-
const RuntimeCommonProvider_1 = __importDefault(require("../../components/RuntimeCommonProvider"));
|
|
35
|
-
const ThemeProvider_1 = __importDefault(require("../../components/ThemeProvider"));
|
|
36
34
|
const ActiveAgent_1 = __importDefault(require("../../contexts/ActiveAgent"));
|
|
37
35
|
const Runtime_1 = __importStar(require("../../contexts/Runtime"));
|
|
38
36
|
const use_appearances_1 = __importDefault(require("../../hooks/use-appearances"));
|
|
39
37
|
const use_header_menu_1 = require("../../hooks/use-header-menu");
|
|
40
38
|
const runtime_1 = require("../../state/runtime");
|
|
41
39
|
function Runtime({ blockletDid, aid, working, }) {
|
|
42
|
-
const children = ((0, jsx_runtime_1.jsx)(
|
|
43
|
-
return
|
|
40
|
+
const children = ((0, jsx_runtime_1.jsx)(ActiveAgent_1.default, { children: (0, jsx_runtime_1.jsx)(RuntimeView, {}) }));
|
|
41
|
+
return aid ? ((0, jsx_runtime_1.jsx)(Runtime_1.default, { blockletDid: blockletDid, aid: aid, working: working, children: children })) : ((0, jsx_runtime_1.jsx)(Runtime_1.RuntimeProviderFromUrl, { children: children }));
|
|
44
42
|
}
|
|
45
43
|
function RuntimeView() {
|
|
46
44
|
const { aid, agent } = (0, runtime_1.useRuntimeState)();
|
|
@@ -13,7 +13,7 @@ exports.useAgentState = useAgentState;
|
|
|
13
13
|
const zustand_1 = require("zustand");
|
|
14
14
|
const immer_1 = require("zustand/middleware/immer");
|
|
15
15
|
const agent_1 = require("../api/agent");
|
|
16
|
-
const
|
|
16
|
+
const Identity_1 = require("../contexts/Identity");
|
|
17
17
|
const zustand_2 = require("../utils/zustand");
|
|
18
18
|
const createAgentState = ({ blockletDid, aid, working, agent, }) => {
|
|
19
19
|
return (0, zustand_2.createCachedStore)(`agent-state-${blockletDid}-${aid}-${working}`, () => (0, zustand_1.create)()((0, immer_1.immer)((set) => ({
|
|
@@ -45,8 +45,8 @@ const createAgentState = ({ blockletDid, aid, working, agent, }) => {
|
|
|
45
45
|
const LOADING_TASKS = {};
|
|
46
46
|
function useAgentState({ blockletDid, aid, working, }) {
|
|
47
47
|
var _a;
|
|
48
|
-
const
|
|
49
|
-
const state = createAgentState({ blockletDid, aid, working: working !== null && working !== void 0 ? working :
|
|
48
|
+
const identity = (0, Identity_1.useIdentityContext)();
|
|
49
|
+
const state = createAgentState({ blockletDid, aid, working: working !== null && working !== void 0 ? working : identity.working })();
|
|
50
50
|
if (!state.agent) {
|
|
51
51
|
if (state.error)
|
|
52
52
|
throw state.error;
|
|
@@ -12,11 +12,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.useRuntimeState = useRuntimeState;
|
|
13
13
|
const react_1 = require("react");
|
|
14
14
|
const session_1 = require("../../../session");
|
|
15
|
-
const
|
|
15
|
+
const Identity_1 = require("../contexts/Identity");
|
|
16
16
|
const agent_1 = require("./agent");
|
|
17
17
|
const session_2 = require("./session");
|
|
18
18
|
function useRuntimeState() {
|
|
19
|
-
const { blockletDid, aid, working } = (0,
|
|
19
|
+
const { blockletDid, aid, working } = (0, Identity_1.useIdentityContext)();
|
|
20
20
|
const [agent] = (0, agent_1.useAgentState)({ blockletDid, aid, working });
|
|
21
21
|
const { session: authSession, events } = (0, session_1.useSessionContext)();
|
|
22
22
|
const sessionState = (0, react_1.useMemo)(() => (0, session_2.createSessionState)({ aid }), [aid]);
|
|
@@ -37,7 +37,7 @@ const zustand_1 = require("zustand");
|
|
|
37
37
|
const immer_1 = require("zustand/middleware/immer");
|
|
38
38
|
const message_1 = require("../api/message");
|
|
39
39
|
const session_1 = require("../api/session");
|
|
40
|
-
const
|
|
40
|
+
const Identity_1 = require("../contexts/Identity");
|
|
41
41
|
const zustand_2 = require("../utils/zustand");
|
|
42
42
|
const GET_MESSAGES_LIMIT = 100;
|
|
43
43
|
const GET_MESSAGES_ORDER_DIRECTION = 'desc';
|
|
@@ -377,7 +377,7 @@ const createSessionState = ({ aid }) => {
|
|
|
377
377
|
};
|
|
378
378
|
exports.createSessionState = createSessionState;
|
|
379
379
|
function useAutoLoadSessionState(...args) {
|
|
380
|
-
const { aid } = (0,
|
|
380
|
+
const { aid } = (0, Identity_1.useIdentityContext)();
|
|
381
381
|
const state = (0, react_1.useMemo)(() => (0, exports.createSessionState)({ aid }), [aid]);
|
|
382
382
|
const currentSessionId = state((s) => s.currentSessionId);
|
|
383
383
|
(0, react_1.useEffect)(() => {
|
|
@@ -385,7 +385,7 @@ function useAutoLoadSessionState(...args) {
|
|
|
385
385
|
}, [state, currentSessionId]);
|
|
386
386
|
}
|
|
387
387
|
function useSessionState(selector) {
|
|
388
|
-
const { aid } = (0,
|
|
388
|
+
const { aid } = (0, Identity_1.useIdentityContext)();
|
|
389
389
|
return (0, react_1.useMemo)(() => (0, exports.createSessionState)({ aid }), [aid])(selector);
|
|
390
390
|
}
|
|
391
391
|
function useCurrentSessionState(selector) {
|