@tensorpass/aiconnect-react 0.0.0-stage → 0.1.0
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/LICENSE +202 -0
- package/NOTICE +4 -0
- package/README.md +15 -2
- package/dist/AboutView.d.ts +1 -0
- package/dist/AboutView.js +8 -0
- package/dist/AboutView.js.map +1 -0
- package/dist/AiConnectProvider.d.ts +26 -0
- package/dist/AiConnectProvider.js +44 -0
- package/dist/AiConnectProvider.js.map +1 -0
- package/dist/BrandMark.d.ts +3 -0
- package/dist/BrandMark.js +8 -0
- package/dist/BrandMark.js.map +1 -0
- package/dist/ConnectButton.d.ts +4 -0
- package/dist/ConnectButton.js +15 -0
- package/dist/ConnectButton.js.map +1 -0
- package/dist/ConnectModal.d.ts +1 -0
- package/dist/ConnectModal.js +68 -0
- package/dist/ConnectModal.js.map +1 -0
- package/dist/ConnectRing.d.ts +3 -0
- package/dist/ConnectRing.js +8 -0
- package/dist/ConnectRing.js.map +1 -0
- package/dist/WebAccountStep.d.ts +13 -0
- package/dist/WebAccountStep.js +34 -0
- package/dist/WebAccountStep.js.map +1 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -0
- package/dist/launcher.d.ts +11 -0
- package/dist/launcher.js +46 -0
- package/dist/launcher.js.map +1 -0
- package/dist/launchers.css +150 -0
- package/dist/messages.d.ts +15 -0
- package/dist/messages.js +46 -0
- package/dist/messages.js.map +1 -0
- package/dist/moduleMessages.d.ts +29 -0
- package/dist/moduleMessages.js +147 -0
- package/dist/moduleMessages.js.map +1 -0
- package/dist/modules/AiChatInline.d.ts +3 -0
- package/dist/modules/AiChatInline.js +18 -0
- package/dist/modules/AiChatInline.js.map +1 -0
- package/dist/modules/AiChatPage.d.ts +4 -0
- package/dist/modules/AiChatPage.js +23 -0
- package/dist/modules/AiChatPage.js.map +1 -0
- package/dist/modules/AiChatPanel.d.ts +4 -0
- package/dist/modules/AiChatPanel.js +22 -0
- package/dist/modules/AiChatPanel.js.map +1 -0
- package/dist/modules/AiChatPopup.d.ts +4 -0
- package/dist/modules/AiChatPopup.js +21 -0
- package/dist/modules/AiChatPopup.js.map +1 -0
- package/dist/modules/AiSearch.d.ts +3 -0
- package/dist/modules/AiSearch.js +76 -0
- package/dist/modules/AiSearch.js.map +1 -0
- package/dist/modules/Launcher.d.ts +9 -0
- package/dist/modules/Launcher.js +8 -0
- package/dist/modules/Launcher.js.map +1 -0
- package/dist/modules/parts/AccountBadge.d.ts +3 -0
- package/dist/modules/parts/AccountBadge.js +15 -0
- package/dist/modules/parts/AccountBadge.js.map +1 -0
- package/dist/modules/parts/AnswerText.d.ts +8 -0
- package/dist/modules/parts/AnswerText.js +43 -0
- package/dist/modules/parts/AnswerText.js.map +1 -0
- package/dist/modules/parts/ChatFrame.d.ts +12 -0
- package/dist/modules/parts/ChatFrame.js +16 -0
- package/dist/modules/parts/ChatFrame.js.map +1 -0
- package/dist/modules/parts/Composer.d.ts +13 -0
- package/dist/modules/parts/Composer.js +64 -0
- package/dist/modules/parts/Composer.js.map +1 -0
- package/dist/modules/parts/ConnectNote.d.ts +4 -0
- package/dist/modules/parts/ConnectNote.js +51 -0
- package/dist/modules/parts/ConnectNote.js.map +1 -0
- package/dist/modules/parts/ConnectStep.d.ts +4 -0
- package/dist/modules/parts/ConnectStep.js +17 -0
- package/dist/modules/parts/ConnectStep.js.map +1 -0
- package/dist/modules/parts/Conversation.d.ts +22 -0
- package/dist/modules/parts/Conversation.js +69 -0
- package/dist/modules/parts/Conversation.js.map +1 -0
- package/dist/modules/parts/PlanOffer.d.ts +3 -0
- package/dist/modules/parts/PlanOffer.js +79 -0
- package/dist/modules/parts/PlanOffer.js.map +1 -0
- package/dist/modules/parts/ToolActivity.d.ts +5 -0
- package/dist/modules/parts/ToolActivity.js +33 -0
- package/dist/modules/parts/ToolActivity.js.map +1 -0
- package/dist/modules/parts/accountModel.d.ts +2 -0
- package/dist/modules/parts/accountModel.js +13 -0
- package/dist/modules/parts/accountModel.js.map +1 -0
- package/dist/modules/parts/answerMarkdown.d.ts +32 -0
- package/dist/modules/parts/answerMarkdown.js +105 -0
- package/dist/modules/parts/answerMarkdown.js.map +1 -0
- package/dist/modules/parts/icons.d.ts +10 -0
- package/dist/modules/parts/icons.js +15 -0
- package/dist/modules/parts/icons.js.map +1 -0
- package/dist/modules/parts/moduleAnalytics.d.ts +5 -0
- package/dist/modules/parts/moduleAnalytics.js +9 -0
- package/dist/modules/parts/moduleAnalytics.js.map +1 -0
- package/dist/modules/parts/moduleClass.d.ts +1 -0
- package/dist/modules/parts/moduleClass.js +6 -0
- package/dist/modules/parts/moduleClass.js.map +1 -0
- package/dist/modules/parts/planPrice.d.ts +2 -0
- package/dist/modules/parts/planPrice.js +8 -0
- package/dist/modules/parts/planPrice.js.map +1 -0
- package/dist/modules/parts/useModuleChat.d.ts +24 -0
- package/dist/modules/parts/useModuleChat.js +117 -0
- package/dist/modules/parts/useModuleChat.js.map +1 -0
- package/dist/modules/parts/useModuleHandle.d.ts +3 -0
- package/dist/modules/parts/useModuleHandle.js +12 -0
- package/dist/modules/parts/useModuleHandle.js.map +1 -0
- package/dist/modules/types.d.ts +28 -0
- package/dist/modules/types.js +5 -0
- package/dist/modules/types.js.map +1 -0
- package/dist/modules/useOverlay.d.ts +20 -0
- package/dist/modules/useOverlay.js +102 -0
- package/dist/modules/useOverlay.js.map +1 -0
- package/dist/pickerMessages.d.ts +35 -0
- package/dist/pickerMessages.js +222 -0
- package/dist/pickerMessages.js.map +1 -0
- package/dist/styles.css +1721 -0
- package/dist/useAiChat.d.ts +33 -0
- package/dist/useAiChat.js +143 -0
- package/dist/useAiChat.js.map +1 -0
- package/dist/webAccountMessages.d.ts +24 -0
- package/dist/webAccountMessages.js +130 -0
- package/dist/webAccountMessages.js.map +1 -0
- package/package.json +48 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/NOTICE
ADDED
package/README.md
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @tensorpass/aiconnect-react
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The React components and hooks of AI Connect: the connect window, a chat with your site's tools, and the interface modules (side panel, popup, inline chat, search bar, full page). Each visitor answers with their own AI account through the AI Wallet browser extension, or signs in with OpenRouter or the TensorPass plan without it.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npm install @tensorpass/aiconnect @tensorpass/aiconnect-react
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
```tsx
|
|
10
|
+
import { AiConnectProvider, AiChatPanel } from '@tensorpass/aiconnect-react';
|
|
11
|
+
import '@tensorpass/aiconnect-react/styles.css';
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
It needs React 19 or later. Docs: https://tensorpass.app/docs. React quickstart: https://tensorpass.app/docs/quickstart/react. Next.js quickstart: https://tensorpass.app/docs/quickstart/nextjs.
|
|
15
|
+
|
|
16
|
+
Apache License 2.0. The names AI Connect, AI Wallet and TensorPass and the TensorPass mark are not licensed.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function AboutView(): import("react").JSX.Element;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// The help screen: what connecting an AI account to this site means for the visitor.
|
|
3
|
+
import { useAiConnect } from "./AiConnectProvider.js";
|
|
4
|
+
export function AboutView() {
|
|
5
|
+
const { messages } = useAiConnect();
|
|
6
|
+
return (_jsxs("div", { className: "aic-about", children: [_jsx("p", { className: "aic-about-title", children: messages.aboutTitle }), _jsx("ul", { className: "aic-about-points", children: messages.aboutPoints.map((point) => _jsx("li", { children: point }, point)) })] }));
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=AboutView.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AboutView.js","sourceRoot":"","sources":["../src/AboutView.tsx"],"names":[],"mappings":";AAAA,qFAAqF;AAErF,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAyB,CAAC;AAEvD,MAAM,UAAU,SAAS;IACvB,MAAM,EAAE,QAAQ,EAAE,GAAG,YAAY,EAAE,CAAC;IACpC,OAAO,CACL,eAAK,SAAS,EAAC,WAAW,aACxB,YAAG,SAAS,EAAC,iBAAiB,YAAE,QAAQ,CAAC,UAAU,GAAK,EACxD,aAAI,SAAS,EAAC,kBAAkB,YAC7B,QAAQ,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,uBAAiB,KAAK,IAAb,KAAK,CAAc,CAAC,GAC/D,IACD,CACP,CAAC;AACJ,CAAC","sourcesContent":["// The help screen: what connecting an AI account to this site means for the visitor.\n\nimport { useAiConnect } from './AiConnectProvider.tsx';\n\nexport function AboutView() {\n const { messages } = useAiConnect();\n return (\n <div className=\"aic-about\">\n <p className=\"aic-about-title\">{messages.aboutTitle}</p>\n <ul className=\"aic-about-points\">\n {messages.aboutPoints.map((point) => <li key={point}>{point}</li>)}\n </ul>\n </div>\n );\n}\n"]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { AiConnect, ConnectionState } from '@tensorpass/aiconnect';
|
|
3
|
+
import type { Locale, ModuleMessages, PickerMessages } from './messages.ts';
|
|
4
|
+
import type { WebAccountMessages } from './webAccountMessages.ts';
|
|
5
|
+
interface AiConnectContextValue {
|
|
6
|
+
client: AiConnect;
|
|
7
|
+
state: ConnectionState;
|
|
8
|
+
locale: Locale;
|
|
9
|
+
messages: PickerMessages;
|
|
10
|
+
moduleMessages: ModuleMessages;
|
|
11
|
+
webMessages: WebAccountMessages;
|
|
12
|
+
isPickerOpen: boolean;
|
|
13
|
+
openPicker: () => void;
|
|
14
|
+
closePicker: () => void;
|
|
15
|
+
}
|
|
16
|
+
export interface AiConnectProviderProps {
|
|
17
|
+
client: AiConnect;
|
|
18
|
+
locale?: Locale;
|
|
19
|
+
messages?: PickerMessages;
|
|
20
|
+
moduleMessages?: ModuleMessages;
|
|
21
|
+
webMessages?: WebAccountMessages;
|
|
22
|
+
children: ReactNode;
|
|
23
|
+
}
|
|
24
|
+
export declare function AiConnectProvider(props: AiConnectProviderProps): import("react").JSX.Element;
|
|
25
|
+
export declare function useAiConnect(): AiConnectContextValue;
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// Holds the AiConnect client for a React tree, the copy of the connect window and of the interface
|
|
3
|
+
// modules in the page's language, and renders the connect window when it is open.
|
|
4
|
+
import { createContext, useCallback, useContext, useEffect, useMemo, useState, useSyncExternalStore } from 'react';
|
|
5
|
+
import { ConnectModal } from "./ConnectModal.js";
|
|
6
|
+
import { builtInMessages, builtInModuleMessages } from "./messages.js";
|
|
7
|
+
import { builtInWebMessages } from "./webAccountMessages.js";
|
|
8
|
+
const AiConnectContext = createContext(null);
|
|
9
|
+
// The server cannot see the visitor's wallet, so the page hydrates checking and shows the
|
|
10
|
+
// connection right after.
|
|
11
|
+
const SERVER_STATE = { status: 'checking' };
|
|
12
|
+
export function AiConnectProvider(props) {
|
|
13
|
+
const { client, locale = 'en', messages, moduleMessages, webMessages, children } = props;
|
|
14
|
+
const state = useSyncExternalStore((listener) => client.subscribe(listener), () => client.state, () => SERVER_STATE);
|
|
15
|
+
const [isPickerOpen, setPickerOpen] = useState(false);
|
|
16
|
+
const openPicker = useCallback(() => setPickerOpen(true), []);
|
|
17
|
+
const closePicker = useCallback(() => setPickerOpen(false), []);
|
|
18
|
+
// The window closes once the wallet connects the site.
|
|
19
|
+
useEffect(() => client.subscribe((next) => {
|
|
20
|
+
if (next.status === 'connected') {
|
|
21
|
+
setPickerOpen(false);
|
|
22
|
+
}
|
|
23
|
+
}), [client]);
|
|
24
|
+
const value = useMemo(() => ({
|
|
25
|
+
client,
|
|
26
|
+
state,
|
|
27
|
+
locale,
|
|
28
|
+
messages: messages ?? builtInMessages[locale],
|
|
29
|
+
moduleMessages: moduleMessages ?? builtInModuleMessages[locale],
|
|
30
|
+
webMessages: webMessages ?? builtInWebMessages[locale],
|
|
31
|
+
isPickerOpen,
|
|
32
|
+
openPicker,
|
|
33
|
+
closePicker,
|
|
34
|
+
}), [client, state, messages, moduleMessages, webMessages, locale, isPickerOpen, openPicker, closePicker]);
|
|
35
|
+
return (_jsxs(AiConnectContext.Provider, { value: value, children: [children, isPickerOpen ? _jsx(ConnectModal, {}) : null] }));
|
|
36
|
+
}
|
|
37
|
+
export function useAiConnect() {
|
|
38
|
+
const value = useContext(AiConnectContext);
|
|
39
|
+
if (!value) {
|
|
40
|
+
throw new Error('useAiConnect must be used inside AiConnectProvider');
|
|
41
|
+
}
|
|
42
|
+
return value;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=AiConnectProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AiConnectProvider.js","sourceRoot":"","sources":["../src/AiConnectProvider.tsx"],"names":[],"mappings":";AAAA,mGAAmG;AACnG,kFAAkF;AAElF,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAC;AAGnH,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAoB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,eAAe,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AI,eAAe,CAAC,MAAM,CAAC;QAC7C,cAAc,EAAE,cAAc,IAAI,qBAAqB,CAAC,MAAM,CAAC;QAC/D,WAAW,EAAE,WAAW,IAAI,kBAAkB,CAAC,MAAM,CAAC;QACtD,YAAY;QACZ,UAAU;QACV,WAAW;KACZ,CAAC,EAAE,CAAC,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,EAAE,YAAY,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC,CAAC;IAE3G,OAAO,CACL,MAAC,gBAAgB,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,aACpC,QAAQ,EACR,YAAY,CAAC,CAAC,CAAC,KAAC,YAAY,KAAG,CAAC,CAAC,CAAC,IAAI,IACb,CAC7B,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,YAAY;IAC1B,MAAM,KAAK,GAAG,UAAU,CAAC,gBAAgB,CAAC,CAAC;IAC3C,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAC;IACxE,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["// Holds the AiConnect client for a React tree, the copy of the connect window and of the interface\n// modules in the page's language, and renders the connect window when it is open.\n\nimport { createContext, useCallback, useContext, useEffect, useMemo, useState, useSyncExternalStore } from 'react';\nimport type { ReactNode } from 'react';\nimport type { AiConnect, ConnectionState } from '@tensorpass/aiconnect';\nimport { ConnectModal } from './ConnectModal.tsx';\nimport { builtInMessages, builtInModuleMessages } from './messages.ts';\nimport type { Locale, ModuleMessages, PickerMessages } from './messages.ts';\nimport { builtInWebMessages } from './webAccountMessages.ts';\nimport type { WebAccountMessages } from './webAccountMessages.ts';\n\ninterface AiConnectContextValue {\n client: AiConnect;\n state: ConnectionState;\n // The page's language, which also formats prices and numbers.\n locale: Locale;\n messages: PickerMessages;\n moduleMessages: ModuleMessages;\n webMessages: WebAccountMessages;\n isPickerOpen: boolean;\n openPicker: () => void;\n closePicker: () => void;\n}\n\nconst AiConnectContext = createContext<AiConnectContextValue | null>(null);\n\n// The server cannot see the visitor's wallet, so the page hydrates checking and shows the\n// connection right after.\nconst SERVER_STATE: ConnectionState = { status: 'checking' };\n\nexport interface AiConnectProviderProps {\n client: AiConnect;\n locale?: Locale;\n messages?: PickerMessages;\n moduleMessages?: ModuleMessages;\n webMessages?: WebAccountMessages;\n children: ReactNode;\n}\n\nexport function AiConnectProvider(props: AiConnectProviderProps) {\n const { client, locale = 'en', messages, moduleMessages, webMessages, children } = props;\n const state = useSyncExternalStore(\n (listener) => client.subscribe(listener),\n () => client.state,\n () => SERVER_STATE,\n );\n const [isPickerOpen, setPickerOpen] = useState(false);\n const openPicker = useCallback(() => setPickerOpen(true), []);\n const closePicker = useCallback(() => setPickerOpen(false), []);\n\n // The window closes once the wallet connects the site.\n useEffect(() => client.subscribe((next) => {\n if (next.status === 'connected') {\n setPickerOpen(false);\n }\n }), [client]);\n\n const value = useMemo(() => ({\n client,\n state,\n locale,\n messages: messages ?? builtInMessages[locale],\n moduleMessages: moduleMessages ?? builtInModuleMessages[locale],\n webMessages: webMessages ?? builtInWebMessages[locale],\n isPickerOpen,\n openPicker,\n closePicker,\n }), [client, state, messages, moduleMessages, webMessages, locale, isPickerOpen, openPicker, closePicker]);\n\n return (\n <AiConnectContext.Provider value={value}>\n {children}\n {isPickerOpen ? <ConnectModal /> : null}\n </AiConnectContext.Provider>\n );\n}\n\nexport function useAiConnect(): AiConnectContextValue {\n const value = useContext(AiConnectContext);\n if (!value) {\n throw new Error('useAiConnect must be used inside AiConnectProvider');\n }\n return value;\n}\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// The TensorPass mark: a matrix of cells crossed by a cyan path. Its cells take the colour of the text
|
|
3
|
+
// around it, so it follows the button or the chip it sits on, and its path stays cyan.
|
|
4
|
+
import { BRAND_CYAN, MARK_CELLS, MARK_GRID, MARK_PATH_CELLS, MARK_PATH_STROKE, MARK_PATH_WIDTH, } from '@tensorpass/aiconnect-design/brand-mark';
|
|
5
|
+
export function BrandMark({ className }) {
|
|
6
|
+
return (_jsxs("svg", { className: className, viewBox: `0 0 ${MARK_GRID} ${MARK_GRID}`, "aria-hidden": "true", focusable: "false", children: [_jsx("g", { fill: "currentColor", children: MARK_CELLS.map((d) => _jsx("path", { d: d }, d)) }), _jsx("g", { fill: BRAND_CYAN, children: MARK_PATH_CELLS.map((d) => _jsx("path", { d: d }, d)) }), _jsx("path", { d: MARK_PATH_STROKE, fill: "none", stroke: BRAND_CYAN, strokeWidth: MARK_PATH_WIDTH, strokeLinecap: "round", strokeLinejoin: "round" })] }));
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=BrandMark.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BrandMark.js","sourceRoot":"","sources":["../src/BrandMark.tsx"],"names":[],"mappings":";AAAA,uGAAuG;AACvG,uFAAuF;AAEvF,OAAO,EACL,UAAU,EACV,UAAU,EACV,SAAS,EACT,eAAe,EACf,gBAAgB,EAChB,eAAe,GAChB,MAAM,yCAAyC,CAAC;AAEjD,MAAM,UAAU,SAAS,CAAC,EAAE,SAAS,EAA0B;IAC7D,OAAO,CACL,eAAK,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,SAAS,IAAI,SAAS,EAAE,iBAAc,MAAM,EAAC,SAAS,EAAC,OAAO,aACvG,YAAG,IAAI,EAAC,cAAc,YAAE,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,eAAc,CAAC,EAAE,CAAC,IAAP,CAAC,CAAU,CAAC,GAAK,EAC1E,YAAG,IAAI,EAAE,UAAU,YAAG,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,eAAc,CAAC,EAAE,CAAC,IAAP,CAAC,CAAU,CAAC,GAAK,EAC7E,eAAM,CAAC,EAAE,gBAAgB,EAAE,IAAI,EAAC,MAAM,EAAC,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,eAAe,EAAE,aAAa,EAAC,OAAO,EAC5G,cAAc,EAAC,OAAO,GAAG,IACvB,CACP,CAAC;AACJ,CAAC","sourcesContent":["// The TensorPass mark: a matrix of cells crossed by a cyan path. Its cells take the colour of the text\n// around it, so it follows the button or the chip it sits on, and its path stays cyan.\n\nimport {\n BRAND_CYAN,\n MARK_CELLS,\n MARK_GRID,\n MARK_PATH_CELLS,\n MARK_PATH_STROKE,\n MARK_PATH_WIDTH,\n} from '@tensorpass/aiconnect-design/brand-mark';\n\nexport function BrandMark({ className }: { className?: string }) {\n return (\n <svg className={className} viewBox={`0 0 ${MARK_GRID} ${MARK_GRID}`} aria-hidden=\"true\" focusable=\"false\">\n <g fill=\"currentColor\">{MARK_CELLS.map((d) => <path key={d} d={d} />)}</g>\n <g fill={BRAND_CYAN}>{MARK_PATH_CELLS.map((d) => <path key={d} d={d} />)}</g>\n <path d={MARK_PATH_STROKE} fill=\"none\" stroke={BRAND_CYAN} strokeWidth={MARK_PATH_WIDTH} strokeLinecap=\"round\"\n strokeLinejoin=\"round\" />\n </svg>\n );\n}\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// The button a site embeds to connect the visitor's AI: the TensorPass mark and "Connect your AI" in the
|
|
3
|
+
// page's language. It opens the connect window, and it leaves the page once the visitor's AI is connected,
|
|
4
|
+
// when the site's AI features take its place.
|
|
5
|
+
import { useAiConnect } from "./AiConnectProvider.js";
|
|
6
|
+
import { BrandMark } from "./BrandMark.js";
|
|
7
|
+
export function ConnectButton({ className }) {
|
|
8
|
+
const { state, moduleMessages, messages, openPicker } = useAiConnect();
|
|
9
|
+
if (state.status === 'connected') {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
const classes = className ? `aic-connect-button ${className}` : 'aic-connect-button';
|
|
13
|
+
return (_jsxs("button", { type: "button", className: classes, dir: messages.dir, onClick: openPicker, children: [_jsx(BrandMark, { className: "aic-connect-mark" }), moduleMessages.connect] }));
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=ConnectButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConnectButton.js","sourceRoot":"","sources":["../src/ConnectButton.tsx"],"names":[],"mappings":";AAAA,yGAAyG;AACzG,2GAA2G;AAC3G,8CAA8C;AAE9C,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAyB,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAiB,CAAC;AAO5C,MAAM,UAAU,aAAa,CAAC,EAAE,SAAS,EAAsB;IAC7D,MAAM,EAAE,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,UAAU,EAAE,GAAG,YAAY,EAAE,CAAC;IACvE,IAAI,KAAK,CAAC,MAAM,KAAK,WAAW,EAAE,CAAC;QACjC,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,OAAO,GAAG,SAAS,CAAC,CAAC,CAAC,sBAAsB,SAAS,EAAE,CAAC,CAAC,CAAC,oBAAoB,CAAC;IACrF,OAAO,CACL,kBAAQ,IAAI,EAAC,QAAQ,EAAC,SAAS,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,CAAC,GAAG,EAAE,OAAO,EAAE,UAAU,aAC9E,KAAC,SAAS,IAAC,SAAS,EAAC,kBAAkB,GAAG,EACzC,cAAc,CAAC,OAAO,IAChB,CACV,CAAC;AACJ,CAAC","sourcesContent":["// The button a site embeds to connect the visitor's AI: the TensorPass mark and \"Connect your AI\" in the\n// page's language. It opens the connect window, and it leaves the page once the visitor's AI is connected,\n// when the site's AI features take its place.\n\nimport { useAiConnect } from './AiConnectProvider.tsx';\nimport { BrandMark } from './BrandMark.tsx';\n\nexport interface ConnectButtonProps {\n // A class added after `aic-connect-button`, for the site's own spacing or size.\n className?: string;\n}\n\nexport function ConnectButton({ className }: ConnectButtonProps) {\n const { state, moduleMessages, messages, openPicker } = useAiConnect();\n if (state.status === 'connected') {\n return null;\n }\n const classes = className ? `aic-connect-button ${className}` : 'aic-connect-button';\n return (\n <button type=\"button\" className={classes} dir={messages.dir} onClick={openPicker}>\n <BrandMark className=\"aic-connect-mark\" />\n {moduleMessages.connect}\n </button>\n );\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function ConnectModal(): import("react").JSX.Element;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
// The connect window a site shows: one card over the page that connects the visitor's AI through
|
|
3
|
+
// the AI Wallet. It says what happens, waits while the wallet asks the visitor, explains how to
|
|
4
|
+
// install the wallet when it is missing (and, in Safari, how to allow a wallet already added on every
|
|
5
|
+
// website), and lets the visitor try again after a refusal. The wallet's accounts stay in the extension.
|
|
6
|
+
// A visitor without the wallet can sign in to a web account on the page instead (WebAccountStep.tsx), whose
|
|
7
|
+
// credential the site keeps.
|
|
8
|
+
import { useEffect, useRef, useState } from 'react';
|
|
9
|
+
import { AboutView } from "./AboutView.js";
|
|
10
|
+
import { useAiConnect } from "./AiConnectProvider.js";
|
|
11
|
+
import { ConnectRing } from "./ConnectRing.js";
|
|
12
|
+
import { alreadyAddedLine, installLabel, installText, refusalStep } from "./messages.js";
|
|
13
|
+
import { WebAccountConnected, WebSignIns, WebSigningIn } from "./WebAccountStep.js";
|
|
14
|
+
function useEscapeToClose(onClose) {
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
const onKey = (event) => {
|
|
17
|
+
if (event.key === 'Escape') {
|
|
18
|
+
onClose();
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
document.addEventListener('keydown', onKey);
|
|
22
|
+
return () => document.removeEventListener('keydown', onKey);
|
|
23
|
+
}, [onClose]);
|
|
24
|
+
}
|
|
25
|
+
function Step({ live, title, text, children }) {
|
|
26
|
+
return (_jsxs("div", { className: "aic-step", children: [_jsx(ConnectRing, { live: live }), _jsx("p", { className: "aic-step-title", role: "status", children: title }), _jsx("p", { className: "aic-hint", children: text }), children] }));
|
|
27
|
+
}
|
|
28
|
+
function WalletStep() {
|
|
29
|
+
const { client, state, messages } = useAiConnect();
|
|
30
|
+
const connect = () => client.connect();
|
|
31
|
+
switch (state.status) {
|
|
32
|
+
case 'checking':
|
|
33
|
+
return _jsx(Step, { live: false, title: messages.checking, text: "" });
|
|
34
|
+
case 'connecting':
|
|
35
|
+
return _jsx(Step, { live: true, title: messages.waitingTitle, text: messages.waitingText });
|
|
36
|
+
case 'noWallet': {
|
|
37
|
+
const alreadyAdded = alreadyAddedLine(messages, client.browser);
|
|
38
|
+
return (_jsxs(Step, { live: false, title: messages.installTitle, text: installText(messages, client.browser), children: [_jsx("a", { className: "aic-primary", href: client.installUrl, target: "_blank", rel: "noreferrer", children: installLabel(messages, client.browser) }), alreadyAdded ? _jsx("p", { className: "aic-hint", children: alreadyAdded }) : null] }));
|
|
39
|
+
}
|
|
40
|
+
case 'error': {
|
|
41
|
+
const refusal = refusalStep(state, messages);
|
|
42
|
+
return (_jsx(Step, { live: false, title: refusal.title, text: refusal.text, children: _jsx("button", { type: "button", className: "aic-primary", onClick: connect, children: refusal.action }) }));
|
|
43
|
+
}
|
|
44
|
+
default:
|
|
45
|
+
return (_jsx(Step, { live: false, title: messages.connectTitle, text: messages.connectText, children: _jsx("button", { type: "button", className: "aic-primary", onClick: connect, children: messages.connectButton }) }));
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
// The card's body: the wallet's step, with the sign ins under it when the wallet is missing, the step of a
|
|
49
|
+
// sign in in progress, or the web account that answers.
|
|
50
|
+
function WindowBody() {
|
|
51
|
+
const { state } = useAiConnect();
|
|
52
|
+
if (state.status === 'signingIn') {
|
|
53
|
+
return _jsx(WebSigningIn, { account: state.account, placement: "window" });
|
|
54
|
+
}
|
|
55
|
+
if (state.status === 'connected' && state.account) {
|
|
56
|
+
return _jsx(WebAccountConnected, { account: state.account });
|
|
57
|
+
}
|
|
58
|
+
return (_jsxs(_Fragment, { children: [_jsx(WalletStep, {}), state.status === 'noWallet' ? _jsx(WebSignIns, { placement: "window" }) : null] }));
|
|
59
|
+
}
|
|
60
|
+
export function ConnectModal() {
|
|
61
|
+
const { messages, closePicker } = useAiConnect();
|
|
62
|
+
const [about, setAbout] = useState(false);
|
|
63
|
+
const cardRef = useRef(null);
|
|
64
|
+
useEscapeToClose(closePicker);
|
|
65
|
+
useEffect(() => cardRef.current?.focus(), [about]);
|
|
66
|
+
return (_jsx("div", { className: "aic-backdrop", dir: messages.dir, onClick: closePicker, children: _jsxs("div", { ref: cardRef, className: "aic-card", role: "dialog", "aria-modal": "true", "aria-labelledby": "aic-title", tabIndex: -1, onClick: (event) => event.stopPropagation(), children: [_jsxs("header", { className: "aic-header", children: [_jsx("h2", { id: "aic-title", className: "aic-title", children: about ? messages.help : messages.title }), _jsx("button", { type: "button", className: "aic-icon-button", "aria-label": messages.close, onClick: closePicker, children: "\u00D7" })] }), about ? _jsx(AboutView, {}) : _jsx(WindowBody, {}), _jsx("button", { type: "button", className: "aic-link", onClick: () => setAbout(!about), children: about ? messages.back : messages.help })] }) }));
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=ConnectModal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConnectModal.js","sourceRoot":"","sources":["../src/ConnectModal.tsx"],"names":[],"mappings":";AAAA,iGAAiG;AACjG,gGAAgG;AAChG,sGAAsG;AACtG,yGAAyG;AACzG,4GAA4G;AAC5G,6BAA6B;AAE7B,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEpD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAiB,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,wB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,CAAC,CAAC,CAAC;IACnD,OAAO,CACL,cAAK,SAAS,EAAC,cAAc,EAAC,GAAG,EAAE,QAAQ,CAAC,GAAG,EAAE,OAAO,EAAE,WAAW,YACnE,eAAK,GAAG,EAAE,OAAO,EAAE,SAAS,EAAC,UAAU,EAAC,IAAI,EAAC,QAAQ,gBAAY,MAAM,qBAAiB,WAAW,EAAC,QAAQ,EAAE,CAAC,CAAC,EAC9G,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,eAAe,EAAE,aAC3C,kBAAQ,SAAS,EAAC,YAAY,aAC5B,aAAI,EAAE,EAAC,WAAW,EAAC,SAAS,EAAC,WAAW,YAAE,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,GAAM,EACtF,iBAAQ,IAAI,EAAC,QAAQ,EAAC,SAAS,EAAC,iBAAiB,gBAAa,QAAQ,CAAC,KAAK,EAAE,OAAO,EAAE,WAAW,uBAAY,IACvG,EACR,KAAK,CAAC,CAAC,CAAC,KAAC,SAAS,KAAG,CAAC,CAAC,CAAC,KAAC,UAAU,KAAG,EACvC,iBAAQ,IAAI,EAAC,QAAQ,EAAC,SAAS,EAAC,UAAU,EAAC,OAAO,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,YACvE,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,GAC/B,IACL,GACF,CACP,CAAC;AACJ,CAAC","sourcesContent":["// The connect window a site shows: one card over the page that connects the visitor's AI through\n// the AI Wallet. It says what happens, waits while the wallet asks the visitor, explains how to\n// install the wallet when it is missing (and, in Safari, how to allow a wallet already added on every\n// website), and lets the visitor try again after a refusal. The wallet's accounts stay in the extension.\n// A visitor without the wallet can sign in to a web account on the page instead (WebAccountStep.tsx), whose\n// credential the site keeps.\n\nimport { useEffect, useRef, useState } from 'react';\nimport type { ReactNode } from 'react';\nimport { AboutView } from './AboutView.tsx';\nimport { useAiConnect } from './AiConnectProvider.tsx';\nimport { ConnectRing } from './ConnectRing.tsx';\nimport { alreadyAddedLine, installLabel, installText, refusalStep } from './messages.ts';\nimport { WebAccountConnected, WebSignIns, WebSigningIn } from './WebAccountStep.tsx';\n\nfunction useEscapeToClose(onClose: () => void) {\n useEffect(() => {\n const onKey = (event: KeyboardEvent) => {\n if (event.key === 'Escape') {\n onClose();\n }\n };\n document.addEventListener('keydown', onKey);\n return () => document.removeEventListener('keydown', onKey);\n }, [onClose]);\n}\n\nfunction Step({ live, title, text, children }: { live: boolean; title: string; text: string; children?: ReactNode }) {\n return (\n <div className=\"aic-step\">\n <ConnectRing live={live} />\n <p className=\"aic-step-title\" role=\"status\">{title}</p>\n <p className=\"aic-hint\">{text}</p>\n {children}\n </div>\n );\n}\n\nfunction WalletStep() {\n const { client, state, messages } = useAiConnect();\n const connect = () => client.connect();\n switch (state.status) {\n case 'checking':\n return <Step live={false} title={messages.checking} text=\"\" />;\n case 'connecting':\n return <Step live title={messages.waitingTitle} text={messages.waitingText} />;\n case 'noWallet': {\n const alreadyAdded = alreadyAddedLine(messages, client.browser);\n return (\n <Step live={false} title={messages.installTitle} text={installText(messages, client.browser)}>\n <a className=\"aic-primary\" href={client.installUrl} target=\"_blank\" rel=\"noreferrer\">\n {installLabel(messages, client.browser)}\n </a>\n {alreadyAdded ? <p className=\"aic-hint\">{alreadyAdded}</p> : null}\n </Step>\n );\n }\n case 'error': {\n const refusal = refusalStep(state, messages);\n return (\n <Step live={false} title={refusal.title} text={refusal.text}>\n <button type=\"button\" className=\"aic-primary\" onClick={connect}>{refusal.action}</button>\n </Step>\n );\n }\n default:\n return (\n <Step live={false} title={messages.connectTitle} text={messages.connectText}>\n <button type=\"button\" className=\"aic-primary\" onClick={connect}>{messages.connectButton}</button>\n </Step>\n );\n }\n}\n\n// The card's body: the wallet's step, with the sign ins under it when the wallet is missing, the step of a\n// sign in in progress, or the web account that answers.\nfunction WindowBody() {\n const { state } = useAiConnect();\n if (state.status === 'signingIn') {\n return <WebSigningIn account={state.account} placement=\"window\" />;\n }\n if (state.status === 'connected' && state.account) {\n return <WebAccountConnected account={state.account} />;\n }\n return (\n <>\n <WalletStep />\n {state.status === 'noWallet' ? <WebSignIns placement=\"window\" /> : null}\n </>\n );\n}\n\nexport function ConnectModal() {\n const { messages, closePicker } = useAiConnect();\n const [about, setAbout] = useState(false);\n const cardRef = useRef<HTMLDivElement>(null);\n useEscapeToClose(closePicker);\n useEffect(() => cardRef.current?.focus(), [about]);\n return (\n <div className=\"aic-backdrop\" dir={messages.dir} onClick={closePicker}>\n <div ref={cardRef} className=\"aic-card\" role=\"dialog\" aria-modal=\"true\" aria-labelledby=\"aic-title\" tabIndex={-1}\n onClick={(event) => event.stopPropagation()}>\n <header className=\"aic-header\">\n <h2 id=\"aic-title\" className=\"aic-title\">{about ? messages.help : messages.title}</h2>\n <button type=\"button\" className=\"aic-icon-button\" aria-label={messages.close} onClick={closePicker}>×</button>\n </header>\n {about ? <AboutView /> : <WindowBody />}\n <button type=\"button\" className=\"aic-link\" onClick={() => setAbout(!about)}>\n {about ? messages.back : messages.help}\n </button>\n </div>\n </div>\n );\n}\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// The TensorPass mark in the AI Wallet's ring: contactless arcs around a white disc, pulsing while the
|
|
3
|
+
// wallet asks the visitor.
|
|
4
|
+
import { BrandMark } from "./BrandMark.js";
|
|
5
|
+
export function ConnectRing({ live }) {
|
|
6
|
+
return (_jsxs("div", { className: "aic-ring", "data-live": live || undefined, "aria-hidden": "true", children: [_jsxs("svg", { className: "aic-arcs", viewBox: "0 0 300 150", children: [_jsx("path", { className: "aic-a1", d: "M86 50a40 40 0 0 0 0 50" }), _jsx("path", { className: "aic-a2", d: "M66 34a64 64 0 0 0 0 82" }), _jsx("path", { className: "aic-a3", d: "M46 18a88 88 0 0 0 0 114" }), _jsx("path", { className: "aic-a1", d: "M214 50a40 40 0 0 1 0 50" }), _jsx("path", { className: "aic-a2", d: "M234 34a64 64 0 0 1 0 82" }), _jsx("path", { className: "aic-a3", d: "M254 18a88 88 0 0 1 0 114" })] }), _jsx("span", { className: "aic-disc", children: _jsx(BrandMark, {}) })] }));
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=ConnectRing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConnectRing.js","sourceRoot":"","sources":["../src/ConnectRing.tsx"],"names":[],"mappings":";AAAA,uGAAuG;AACvG,2BAA2B;AAE3B,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAiB,CAAC;AAE5C,MAAM,UAAU,WAAW,CAAC,EAAE,IAAI,EAAqB;IACrD,OAAO,CACL,eAAK,SAAS,EAAC,UAAU,eAAY,IAAI,IAAI,SAAS,iBAAc,MAAM,aACxE,eAAK,SAAS,EAAC,UAAU,EAAC,OAAO,EAAC,aAAa,aAC7C,eAAM,SAAS,EAAC,QAAQ,EAAC,CAAC,EAAC,yBAAyB,GAAG,EACvD,eAAM,SAAS,EAAC,QAAQ,EAAC,CAAC,EAAC,yBAAyB,GAAG,EACvD,eAAM,SAAS,EAAC,QAAQ,EAAC,CAAC,EAAC,0BAA0B,GAAG,EACxD,eAAM,SAAS,EAAC,QAAQ,EAAC,CAAC,EAAC,0BAA0B,GAAG,EACxD,eAAM,SAAS,EAAC,QAAQ,EAAC,CAAC,EAAC,0BAA0B,GAAG,EACxD,eAAM,SAAS,EAAC,QAAQ,EAAC,CAAC,EAAC,2BAA2B,GAAG,IACrD,EACN,eAAM,SAAS,EAAC,UAAU,YAAC,KAAC,SAAS,KAAG,GAAO,IAC3C,CACP,CAAC;AACJ,CAAC","sourcesContent":["// The TensorPass mark in the AI Wallet's ring: contactless arcs around a white disc, pulsing while the\n// wallet asks the visitor.\n\nimport { BrandMark } from './BrandMark.tsx';\n\nexport function ConnectRing({ live }: { live: boolean }) {\n return (\n <div className=\"aic-ring\" data-live={live || undefined} aria-hidden=\"true\">\n <svg className=\"aic-arcs\" viewBox=\"0 0 300 150\">\n <path className=\"aic-a1\" d=\"M86 50a40 40 0 0 0 0 50\" />\n <path className=\"aic-a2\" d=\"M66 34a64 64 0 0 0 0 82\" />\n <path className=\"aic-a3\" d=\"M46 18a88 88 0 0 0 0 114\" />\n <path className=\"aic-a1\" d=\"M214 50a40 40 0 0 1 0 50\" />\n <path className=\"aic-a2\" d=\"M234 34a64 64 0 0 1 0 82\" />\n <path className=\"aic-a3\" d=\"M254 18a88 88 0 0 1 0 114\" />\n </svg>\n <span className=\"aic-disc\"><BrandMark /></span>\n </div>\n );\n}\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { WebAccountId } from '@tensorpass/aiconnect';
|
|
2
|
+
type Placement = 'window' | 'note';
|
|
3
|
+
export declare function WebSignIns({ placement }: {
|
|
4
|
+
placement: Placement;
|
|
5
|
+
}): import("react").JSX.Element;
|
|
6
|
+
export declare function WebSigningIn({ account, placement }: {
|
|
7
|
+
account: WebAccountId;
|
|
8
|
+
placement: Placement;
|
|
9
|
+
}): import("react").JSX.Element;
|
|
10
|
+
export declare function WebAccountConnected({ account }: {
|
|
11
|
+
account: WebAccountId;
|
|
12
|
+
}): import("react").JSX.Element;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// The web accounts in the connect window and in the modules' connection step: the sign ins offered to a
|
|
3
|
+
// visitor without the wallet, under the install step and a separator line, with why the last one did not go
|
|
4
|
+
// through; the step while the sign in window is open, with Cancel; and, once signed in, the account that
|
|
5
|
+
// answers, where its sign in lives, and Sign out.
|
|
6
|
+
import { WEB_ACCOUNT_NAMES } from '@tensorpass/aiconnect';
|
|
7
|
+
import { OPENROUTER_ICON } from '@tensorpass/aiconnect-design/provider-marks';
|
|
8
|
+
import { useAiConnect } from "./AiConnectProvider.js";
|
|
9
|
+
import { BrandMark } from "./BrandMark.js";
|
|
10
|
+
import { ConnectRing } from "./ConnectRing.js";
|
|
11
|
+
import { withAccount } from "./webAccountMessages.js";
|
|
12
|
+
// The account's mark, in the colour of the text around it. OpenRouter's mark is drawn as a mask, so it
|
|
13
|
+
// follows a dark theme as the TensorPass mark does.
|
|
14
|
+
function AccountMark({ account }) {
|
|
15
|
+
if (account === 'tensorpass') {
|
|
16
|
+
return _jsx(BrandMark, { className: "aic-web-mark" });
|
|
17
|
+
}
|
|
18
|
+
const mask = `url("${OPENROUTER_ICON}") center / contain no-repeat`;
|
|
19
|
+
return _jsx("span", { className: "aic-web-mark", "aria-hidden": "true", style: { mask, WebkitMask: mask } });
|
|
20
|
+
}
|
|
21
|
+
export function WebSignIns({ placement }) {
|
|
22
|
+
const { client, state, webMessages } = useAiConnect();
|
|
23
|
+
const failure = state.status === 'noWallet' ? state.signInFailure : undefined;
|
|
24
|
+
return (_jsxs("div", { className: "aic-web", "data-placement": placement, children: [_jsx("p", { className: "aic-web-separator", children: webMessages.offerTitle }), client.webAccounts.map((account) => (_jsxs("button", { type: "button", className: "aic-web-button", onClick: () => void client.signIn(account), children: [_jsx(AccountMark, { account: account }), withAccount(webMessages.signInWith, WEB_ACCOUNT_NAMES[account])] }, account))), failure ? (_jsx("p", { className: "aic-web-failure", role: "alert", children: withAccount(webMessages.failures[failure.reason], WEB_ACCOUNT_NAMES[failure.account]) })) : null] }));
|
|
25
|
+
}
|
|
26
|
+
export function WebSigningIn({ account, placement }) {
|
|
27
|
+
const { client, webMessages } = useAiConnect();
|
|
28
|
+
return (_jsxs("div", { className: "aic-web-step", "data-placement": placement, role: "status", children: [_jsx(ConnectRing, { live: true }), _jsx("p", { className: "aic-web-title", children: withAccount(webMessages.signingInTitle, WEB_ACCOUNT_NAMES[account]) }), _jsx("p", { className: "aic-web-text", children: webMessages.signingInText }), _jsx("button", { type: "button", className: "aic-web-button", onClick: () => client.cancelSignIn(), children: webMessages.cancel })] }));
|
|
29
|
+
}
|
|
30
|
+
export function WebAccountConnected({ account }) {
|
|
31
|
+
const { client, webMessages } = useAiConnect();
|
|
32
|
+
return (_jsxs("div", { className: "aic-web-step", "data-placement": "window", children: [_jsx(ConnectRing, { live: false }), _jsx("p", { className: "aic-web-title", role: "status", children: webMessages.answers[account] }), _jsx("p", { className: "aic-web-text", children: webMessages.storedText }), _jsxs("button", { type: "button", className: "aic-web-button", onClick: () => void client.signOut(), children: [_jsx(AccountMark, { account: account }), webMessages.signOut] })] }));
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=WebAccountStep.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WebAccountStep.js","sourceRoot":"","sources":["../src/WebAccountStep.tsx"],"names":[],"mappings":";AAAA,wGAAwG;AACxG,4GAA4G;AAC5G,yGAAyG;AACzG,kDAAkD;AAElD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE1D,OAAO,EAAE,eAAe,EAAE,MAAM,6CAA6C,CAAC;AAC9E,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAyB,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAiB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAmB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAKtD,uGAAuG;AACvG,oDAAoD;AACpD,SAAS,WAAW,CAAC,EAAE,OAAO,EAA6B;IACzD,IAAI,OAAO,KAAK,YAAY,EAAE,CAAC;QAC7B,OAAO,KAAC,SAAS,IAAC,SAAS,EAAC,cAAc,GAAG,CAAC;IAChD,CAAC;IACD,MAAM,IAAI,GAAG,QAAQ,eAAe,+BAA+B,CAAC;IACpE,OAAO,eAAM,SAAS,EAAC,cAAc,iBAAa,MAAM,EAAC,KAAK,EAAE,EAAE,IAAI,EAAE,U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IAAI,EAAC,QAAQ,aACpE,KAAC,WAAW,IAAC,IAAI,SAAG,EACpB,YAAG,SAAS,EAAC,eAAe,YAAE,WAAW,CAAC,WAAW,CAAC,cAAc,EAAE,iBAAiB,CAAC,OAAO,CAAC,CAAC,GAAK,EACtG,YAAG,SAAS,EAAC,cAAc,YAAE,WAAW,CAAC,aAAa,GAAK,EAC3D,iBAAQ,IAAI,EAAC,QAAQ,EAAC,SAAS,EAAC,gBAAgB,EAAC,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,YAAY,EAAE,YAClF,WAAW,CAAC,MAAM,GACZ,IACL,CACP,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,EAAE,OAAO,EAA6B;IACxE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,YAAY,EAAE,CAAC;IAC/C,OAAO,CACL,eAAK,SAAS,EAAC,cAAc,oBAAgB,QAAQ,aACnD,KAAC,WAAW,IAAC,IAAI,EAAE,KAAK,GAAI,EAC5B,YAAG,SAAS,EAAC,eAAe,EAAC,IAAI,EAAC,QAAQ,YAAE,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,GAAK,EAC7E,YAAG,SAAS,EAAC,cAAc,YAAE,WAAW,CAAC,UAAU,GAAK,EACxD,kBAAQ,IAAI,EAAC,QAAQ,EAAC,SAAS,EAAC,gBAAgB,EAAC,OAAO,EAAE,GAAG,EAAE,CAAC,KAAK,MAAM,CAAC,OAAO,EAAE,aACnF,KAAC,WAAW,IAAC,OAAO,EAAE,OAAO,GAAI,EAChC,WAAW,CAAC,OAAO,IACb,IACL,CACP,CAAC;AACJ,CAAC","sourcesContent":["// The web accounts in the connect window and in the modules' connection step: the sign ins offered to a\n// visitor without the wallet, under the install step and a separator line, with why the last one did not go\n// through; the step while the sign in window is open, with Cancel; and, once signed in, the account that\n// answers, where its sign in lives, and Sign out.\n\nimport { WEB_ACCOUNT_NAMES } from '@tensorpass/aiconnect';\nimport type { WebAccountId } from '@tensorpass/aiconnect';\nimport { OPENROUTER_ICON } from '@tensorpass/aiconnect-design/provider-marks';\nimport { useAiConnect } from './AiConnectProvider.tsx';\nimport { BrandMark } from './BrandMark.tsx';\nimport { ConnectRing } from './ConnectRing.tsx';\nimport { withAccount } from './webAccountMessages.ts';\n\n// Where the step stands: in the connect window's card, or in a module's connection note.\ntype Placement = 'window' | 'note';\n\n// The account's mark, in the colour of the text around it. OpenRouter's mark is drawn as a mask, so it\n// follows a dark theme as the TensorPass mark does.\nfunction AccountMark({ account }: { account: WebAccountId }) {\n if (account === 'tensorpass') {\n return <BrandMark className=\"aic-web-mark\" />;\n }\n const mask = `url(\"${OPENROUTER_ICON}\") center / contain no-repeat`;\n return <span className=\"aic-web-mark\" aria-hidden=\"true\" style={{ mask, WebkitMask: mask }} />;\n}\n\nexport function WebSignIns({ placement }: { placement: Placement }) {\n const { client, state, webMessages } = useAiConnect();\n const failure = state.status === 'noWallet' ? state.signInFailure : undefined;\n return (\n <div className=\"aic-web\" data-placement={placement}>\n <p className=\"aic-web-separator\">{webMessages.offerTitle}</p>\n {client.webAccounts.map((account) => (\n <button key={account} type=\"button\" className=\"aic-web-button\" onClick={() => void client.signIn(account)}>\n <AccountMark account={account} />\n {withAccount(webMessages.signInWith, WEB_ACCOUNT_NAMES[account])}\n </button>\n ))}\n {failure ? (\n <p className=\"aic-web-failure\" role=\"alert\">\n {withAccount(webMessages.failures[failure.reason], WEB_ACCOUNT_NAMES[failure.account])}\n </p>\n ) : null}\n </div>\n );\n}\n\nexport function WebSigningIn({ account, placement }: { account: WebAccountId; placement: Placement }) {\n const { client, webMessages } = useAiConnect();\n return (\n <div className=\"aic-web-step\" data-placement={placement} role=\"status\">\n <ConnectRing live />\n <p className=\"aic-web-title\">{withAccount(webMessages.signingInTitle, WEB_ACCOUNT_NAMES[account])}</p>\n <p className=\"aic-web-text\">{webMessages.signingInText}</p>\n <button type=\"button\" className=\"aic-web-button\" onClick={() => client.cancelSignIn()}>\n {webMessages.cancel}\n </button>\n </div>\n );\n}\n\nexport function WebAccountConnected({ account }: { account: WebAccountId }) {\n const { client, webMessages } = useAiConnect();\n return (\n <div className=\"aic-web-step\" data-placement=\"window\">\n <ConnectRing live={false} />\n <p className=\"aic-web-title\" role=\"status\">{webMessages.answers[account]}</p>\n <p className=\"aic-web-text\">{webMessages.storedText}</p>\n <button type=\"button\" className=\"aic-web-button\" onClick={() => void client.signOut()}>\n <AccountMark account={account} />\n {webMessages.signOut}\n </button>\n </div>\n );\n}\n"]}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export { AiConnectProvider, useAiConnect } from './AiConnectProvider.tsx';
|
|
2
|
+
export type { AiConnectProviderProps } from './AiConnectProvider.tsx';
|
|
3
|
+
export { ConnectButton } from './ConnectButton.tsx';
|
|
4
|
+
export type { ConnectButtonProps } from './ConnectButton.tsx';
|
|
5
|
+
export { useAiChat } from './useAiChat.ts';
|
|
6
|
+
export type { ChatTurn, ToolActivity, UseAiChatOptions } from './useAiChat.ts';
|
|
7
|
+
export { builtInLauncherMessages } from './launcher.ts';
|
|
8
|
+
export type { LauncherLocale, LauncherMessages } from './launcher.ts';
|
|
9
|
+
export { builtInMessages, builtInModuleMessages } from './messages.ts';
|
|
10
|
+
export type { Locale, ModuleMessages, PickerMessages, RefusalStep } from './messages.ts';
|
|
11
|
+
export { builtInWebMessages } from './webAccountMessages.ts';
|
|
12
|
+
export type { WebAccountMessages } from './webAccountMessages.ts';
|
|
13
|
+
export { AiChatInline } from './modules/AiChatInline.tsx';
|
|
14
|
+
export type { AiChatInlineProps } from './modules/AiChatInline.tsx';
|
|
15
|
+
export { AiChatPage } from './modules/AiChatPage.tsx';
|
|
16
|
+
export type { AiChatPageProps } from './modules/AiChatPage.tsx';
|
|
17
|
+
export { AiChatPanel } from './modules/AiChatPanel.tsx';
|
|
18
|
+
export type { AiChatPanelProps } from './modules/AiChatPanel.tsx';
|
|
19
|
+
export { AiChatPopup } from './modules/AiChatPopup.tsx';
|
|
20
|
+
export type { AiChatPopupProps } from './modules/AiChatPopup.tsx';
|
|
21
|
+
export { AiSearch } from './modules/AiSearch.tsx';
|
|
22
|
+
export type { AiSearchProps } from './modules/AiSearch.tsx';
|
|
23
|
+
export type { AiModuleHandle, AiModuleProps, AiOverlayProps } from './modules/types.ts';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { AiConnectProvider, useAiConnect } from "./AiConnectProvider.js";
|
|
2
|
+
export { ConnectButton } from "./ConnectButton.js";
|
|
3
|
+
export { useAiChat } from "./useAiChat.js";
|
|
4
|
+
export { builtInLauncherMessages } from "./launcher.js";
|
|
5
|
+
export { builtInMessages, builtInModuleMessages } from "./messages.js";
|
|
6
|
+
export { builtInWebMessages } from "./webAccountMessages.js";
|
|
7
|
+
export { AiChatInline } from "./modules/AiChatInline.js";
|
|
8
|
+
export { AiChatPage } from "./modules/AiChatPage.js";
|
|
9
|
+
export { AiChatPanel } from "./modules/AiChatPanel.js";
|
|
10
|
+
export { AiChatPopup } from "./modules/AiChatPopup.js";
|
|
11
|
+
export { AiSearch } from "./modules/AiSearch.js";
|
|
12
|
+
//# sourceMappingURL=index.js.map
|