@superinterface/react 3.9.6 → 3.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cloud.js DELETED
@@ -1,587 +0,0 @@
1
- // src/components/annotations/SourceAnnotation/index.tsx
2
- function _array_like_to_array(arr, len) {
3
- if (len == null || len > arr.length) len = arr.length;
4
- for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
5
- return arr2;
6
- }
7
- function _array_with_holes(arr) {
8
- if (Array.isArray(arr)) return arr;
9
- }
10
- function _iterable_to_array_limit(arr, i) {
11
- var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
12
- if (_i == null) return;
13
- var _arr = [];
14
- var _n = true;
15
- var _d = false;
16
- var _s, _e;
17
- try {
18
- for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
19
- _arr.push(_s.value);
20
- if (i && _arr.length === i) break;
21
- }
22
- } catch (err) {
23
- _d = true;
24
- _e = err;
25
- } finally{
26
- try {
27
- if (!_n && _i["return"] != null) _i["return"]();
28
- } finally{
29
- if (_d) throw _e;
30
- }
31
- }
32
- return _arr;
33
- }
34
- function _non_iterable_rest() {
35
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
36
- }
37
- function _sliced_to_array(arr, i) {
38
- return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
39
- }
40
- function _type_of(obj) {
41
- "@swc/helpers - typeof";
42
- return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
43
- }
44
- function _unsupported_iterable_to_array(o, minLen) {
45
- if (!o) return;
46
- if (typeof o === "string") return _array_like_to_array(o, minLen);
47
- var n = Object.prototype.toString.call(o).slice(8, -1);
48
- if (n === "Object" && o.constructor) n = o.constructor.name;
49
- if (n === "Map" || n === "Set") return Array.from(n);
50
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
51
- }
52
- import { c as _c4 } from "react-compiler-runtime";
53
- // src/components/annotations/FilePathAnnotation.tsx
54
- import { c as _c } from "react-compiler-runtime";
55
- // src/hooks/core/useSuperinterfaceContext/index.ts
56
- import { useContext } from "react";
57
- // src/contexts/core/SuperinterfaceContext/index.tsx
58
- import { createContext } from "react";
59
- // src/lib/superinterfaceCloud/baseUrl.ts
60
- var baseUrl = "https://superinterface.ai/api/cloud";
61
- // src/lib/threadIdStorage/cookieOptions/get.ts
62
- import Cookies from "js-cookie";
63
- // src/lib/threadIdStorage/key.ts
64
- var key = function(_ref) {
65
- var assistantId = _ref.assistantId;
66
- return "superinterface-".concat(assistantId, "-threadId");
67
- };
68
- // src/lib/threadIdStorage/cookieOptions/get.ts
69
- var get = function(_ref) {
70
- var _Cookies$get;
71
- var assistantId = _ref.assistantId;
72
- return (_Cookies$get = Cookies.get(key({
73
- assistantId: assistantId
74
- }))) !== null && _Cookies$get !== void 0 ? _Cookies$get : null;
75
- };
76
- // src/lib/threadIdStorage/cookieOptions/set.ts
77
- import Cookies2 from "js-cookie";
78
- var set = function(_ref) {
79
- var assistantId = _ref.assistantId, threadId = _ref.threadId;
80
- return Cookies2.set(key({
81
- assistantId: assistantId
82
- }), threadId);
83
- };
84
- // src/lib/threadIdStorage/cookieOptions/remove.ts
85
- import Cookies3 from "js-cookie";
86
- var remove = function(_ref) {
87
- var assistantId = _ref.assistantId;
88
- return Cookies3.remove(key({
89
- assistantId: assistantId
90
- }));
91
- };
92
- // src/lib/threadIdStorage/cookieOptions/index.ts
93
- var cookieOptions = {
94
- get: get,
95
- set: set,
96
- remove: remove
97
- };
98
- // src/lib/threadIdStorage/localStorageOptions/get.ts
99
- var get2 = function(_ref) {
100
- var assistantId = _ref.assistantId;
101
- return window.localStorage.getItem(key({
102
- assistantId: assistantId
103
- }));
104
- };
105
- // src/lib/threadIdStorage/localStorageOptions/set.ts
106
- var set2 = function(_ref) {
107
- var assistantId = _ref.assistantId, threadId = _ref.threadId;
108
- return window.localStorage.setItem(key({
109
- assistantId: assistantId
110
- }), threadId);
111
- };
112
- // src/lib/threadIdStorage/localStorageOptions/remove.ts
113
- var remove2 = function(_ref) {
114
- var assistantId = _ref.assistantId;
115
- return window.localStorage.removeItem(key({
116
- assistantId: assistantId
117
- }));
118
- };
119
- // src/lib/threadIdStorage/localStorageOptions/index.ts
120
- var localStorageOptions = {
121
- get: get2,
122
- set: set2,
123
- remove: remove2
124
- };
125
- // src/lib/iframes/isIframe.ts
126
- var isIframe = function() {
127
- if (typeof window === "undefined") return false;
128
- return window.self !== window.top;
129
- };
130
- // src/contexts/core/SuperinterfaceContext/index.tsx
131
- var SuperinterfaceContext = /* @__PURE__ */ createContext({
132
- baseUrl: baseUrl,
133
- variables: {},
134
- defaultOptions: {
135
- queries: {},
136
- mutations: {}
137
- },
138
- threadIdStorageOptions: isIframe() ? localStorageOptions : cookieOptions,
139
- createMessageAbortControllerRef: {
140
- current: null
141
- }
142
- });
143
- // src/hooks/core/useSuperinterfaceContext/index.ts
144
- var useSuperinterfaceContext = function() {
145
- return useContext(SuperinterfaceContext);
146
- };
147
- // src/contexts/markdown/MarkdownContext/lib/components/Link.tsx
148
- import { Link as RadixLink } from "@radix-ui/themes";
149
- import { jsx as _jsx } from "react/jsx-runtime";
150
- var Link = function(_ref) {
151
- var children = _ref.children, href = _ref.href, download = _ref.download, _ref_target = _ref.target, target = _ref_target === void 0 ? "_blank" : _ref_target;
152
- return /* @__PURE__ */ _jsx(RadixLink, {
153
- href: href,
154
- target: target,
155
- download: download,
156
- children: children
157
- });
158
- };
159
- // src/components/annotations/FilePathAnnotation.tsx
160
- import { jsx as _jsx2 } from "react/jsx-runtime";
161
- var FilePathAnnotation = function(t0) {
162
- var $ = _c(3);
163
- var annotation = t0.annotation, children = t0.children;
164
- var superinterfaceContext = useSuperinterfaceContext();
165
- var nextSearchParams = new URLSearchParams(superinterfaceContext.variables);
166
- var t1 = "".concat(superinterfaceContext.baseUrl, "/files/").concat(annotation.file_path.file_id, "/contents?").concat(nextSearchParams);
167
- var t2;
168
- if ($[0] !== children || $[1] !== t1) {
169
- t2 = /* @__PURE__ */ _jsx2(Link, {
170
- href: t1,
171
- target: "_self",
172
- download: true,
173
- children: children
174
- });
175
- $[0] = children;
176
- $[1] = t1;
177
- $[2] = t2;
178
- } else {
179
- t2 = $[2];
180
- }
181
- return t2;
182
- };
183
- // src/components/annotations/SourceAnnotation/FileCitation/index.tsx
184
- import { c as _c3 } from "react-compiler-runtime";
185
- import { useState } from "react";
186
- import { QuoteIcon } from "@radix-ui/react-icons";
187
- import { Dialog, VisuallyHidden, IconButton as IconButton2 } from "@radix-ui/themes";
188
- // src/components/annotations/SourceAnnotation/FileCitation/Content/index.tsx
189
- import { c as _c2 } from "react-compiler-runtime";
190
- import { Flex as Flex2, Card as Card2, Inset } from "@radix-ui/themes";
191
- import { usePDFSlick } from "@pdfslick/react";
192
- import "@pdfslick/react/dist/pdf_viewer.css";
193
- // src/components/annotations/SourceAnnotation/FileCitation/Content/Navigation.tsx
194
- import { Card, IconButton, Flex } from "@radix-ui/themes";
195
- import { ZoomInIcon, ZoomOutIcon } from "@radix-ui/react-icons";
196
- import { jsx as _jsx3, jsxs as _jsxs } from "react/jsx-runtime";
197
- var Navigation = function(_ref) {
198
- var usePDFSlickStore = _ref.usePDFSlickStore;
199
- var pdfSlick = usePDFSlickStore(function(s) {
200
- return s.pdfSlick;
201
- });
202
- return /* @__PURE__ */ _jsx3(Flex, {
203
- justify: "center",
204
- position: "absolute",
205
- bottom: "var(--space-2)",
206
- left: "0",
207
- right: "0",
208
- style: {
209
- zIndex: 99999
210
- },
211
- children: /* @__PURE__ */ _jsx3(Card, {
212
- children: /* @__PURE__ */ _jsxs(Flex, {
213
- gap: "2",
214
- children: [
215
- /* @__PURE__ */ _jsx3(IconButton, {
216
- variant: "soft",
217
- onClick: function() {
218
- var _pdfSlick$viewer;
219
- return pdfSlick === null || pdfSlick === void 0 || (_pdfSlick$viewer = pdfSlick.viewer) === null || _pdfSlick$viewer === void 0 ? void 0 : _pdfSlick$viewer.decreaseScale();
220
- },
221
- children: /* @__PURE__ */ _jsx3(ZoomOutIcon, {})
222
- }),
223
- /* @__PURE__ */ _jsx3(IconButton, {
224
- variant: "soft",
225
- onClick: function() {
226
- var _pdfSlick$viewer2;
227
- return pdfSlick === null || pdfSlick === void 0 || (_pdfSlick$viewer2 = pdfSlick.viewer) === null || _pdfSlick$viewer2 === void 0 ? void 0 : _pdfSlick$viewer2.increaseScale();
228
- },
229
- children: /* @__PURE__ */ _jsx3(ZoomInIcon, {})
230
- })
231
- ]
232
- })
233
- })
234
- });
235
- };
236
- // src/components/annotations/SourceAnnotation/FileCitation/Content/index.tsx
237
- import { jsx as _jsx4, jsxs as _jsxs2 } from "react/jsx-runtime";
238
- function ownKeys(e, r) {
239
- var t = Object.keys(e);
240
- if (Object.getOwnPropertySymbols) {
241
- var o = Object.getOwnPropertySymbols(e);
242
- r && (o = o.filter(function(r2) {
243
- return Object.getOwnPropertyDescriptor(e, r2).enumerable;
244
- })), t.push.apply(t, o);
245
- }
246
- return t;
247
- }
248
- function _objectSpread(e) {
249
- for(var r = 1; r < arguments.length; r++){
250
- var t = null != arguments[r] ? arguments[r] : {};
251
- r % 2 ? ownKeys(Object(t), true).forEach(function(r2) {
252
- _defineProperty(e, r2, t[r2]);
253
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r2) {
254
- Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
255
- });
256
- }
257
- return e;
258
- }
259
- function _defineProperty(e, r, t) {
260
- return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
261
- value: t,
262
- enumerable: true,
263
- configurable: true,
264
- writable: true
265
- }) : e[r] = t, e;
266
- }
267
- function _toPropertyKey(t) {
268
- var i = _toPrimitive(t, "string");
269
- return "symbol" == (typeof i === "undefined" ? "undefined" : _type_of(i)) ? i : i + "";
270
- }
271
- function _toPrimitive(t, r) {
272
- if ("object" != (typeof t === "undefined" ? "undefined" : _type_of(t)) || !t) return t;
273
- var e = t[Symbol.toPrimitive];
274
- if (void 0 !== e) {
275
- var i = e.call(t, r || "default");
276
- if ("object" != (typeof i === "undefined" ? "undefined" : _type_of(i))) return i;
277
- throw new TypeError("@@toPrimitive must return a primitive value.");
278
- }
279
- return ("string" === r ? String : Number)(t);
280
- }
281
- var Content = function(t0) {
282
- var $ = _c2(14);
283
- var fileId = t0.fileId;
284
- var superinterfaceContext = useSuperinterfaceContext();
285
- var nextSearchParams = new URLSearchParams(superinterfaceContext.variables);
286
- var t1;
287
- if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
288
- t1 = {
289
- scaleValue: "page-width",
290
- removePageBorders: true
291
- };
292
- $[0] = t1;
293
- } else {
294
- t1 = $[0];
295
- }
296
- var _usePDFSlick = usePDFSlick("".concat(superinterfaceContext.baseUrl, "/files/").concat(fileId, "/contents?").concat(nextSearchParams), t1), viewerRef = _usePDFSlick.viewerRef, usePDFSlickStore = _usePDFSlick.usePDFSlickStore, PDFSlickViewer = _usePDFSlick.PDFSlickViewer;
297
- var t2;
298
- if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
299
- t2 = {
300
- display: "flex",
301
- flexGrow: "1"
302
- };
303
- $[1] = t2;
304
- } else {
305
- t2 = $[1];
306
- }
307
- var t3;
308
- if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
309
- t3 = {
310
- display: "flex",
311
- flexGrow: "1"
312
- };
313
- $[2] = t3;
314
- } else {
315
- t3 = $[2];
316
- }
317
- var t4;
318
- if ($[3] !== usePDFSlickStore || $[4] !== viewerRef) {
319
- t4 = {
320
- viewerRef: viewerRef,
321
- usePDFSlickStore: usePDFSlickStore
322
- };
323
- $[3] = usePDFSlickStore;
324
- $[4] = viewerRef;
325
- $[5] = t4;
326
- } else {
327
- t4 = $[5];
328
- }
329
- var t5;
330
- if ($[6] !== PDFSlickViewer || $[7] !== t4) {
331
- t5 = /* @__PURE__ */ _jsx4(PDFSlickViewer, _objectSpread({}, t4));
332
- $[6] = PDFSlickViewer;
333
- $[7] = t4;
334
- $[8] = t5;
335
- } else {
336
- t5 = $[8];
337
- }
338
- var t6;
339
- if ($[9] !== usePDFSlickStore) {
340
- t6 = /* @__PURE__ */ _jsx4(Navigation, {
341
- usePDFSlickStore: usePDFSlickStore
342
- });
343
- $[9] = usePDFSlickStore;
344
- $[10] = t6;
345
- } else {
346
- t6 = $[10];
347
- }
348
- var t7;
349
- if ($[11] !== t5 || $[12] !== t6) {
350
- t7 = /* @__PURE__ */ _jsx4(Flex2, {
351
- direction: "column",
352
- flexGrow: "1",
353
- gap: "3",
354
- children: /* @__PURE__ */ _jsx4(Card2, {
355
- style: t2,
356
- children: /* @__PURE__ */ _jsx4(Inset, {
357
- clip: "padding-box",
358
- style: t3,
359
- children: /* @__PURE__ */ _jsxs2(Flex2, {
360
- flexGrow: "1",
361
- position: "relative",
362
- children: [
363
- t5,
364
- t6
365
- ]
366
- })
367
- })
368
- })
369
- });
370
- $[11] = t5;
371
- $[12] = t6;
372
- $[13] = t7;
373
- } else {
374
- t7 = $[13];
375
- }
376
- return t7;
377
- };
378
- // src/components/annotations/SourceAnnotation/FileCitation/index.tsx
379
- import { jsx as _jsx5, jsxs as _jsxs3, Fragment as _Fragment } from "react/jsx-runtime";
380
- var FileCitation = function(t0) {
381
- var $ = _c3(18);
382
- var annotation = t0.annotation;
383
- var _useState = _sliced_to_array(useState(null), 2), activeFileId = _useState[0], setActiveFileId = _useState[1];
384
- var t1;
385
- if ($[0] !== annotation.file_citation.file_id) {
386
- t1 = function() {
387
- setActiveFileId(annotation.file_citation.file_id);
388
- };
389
- $[0] = annotation.file_citation.file_id;
390
- $[1] = t1;
391
- } else {
392
- t1 = $[1];
393
- }
394
- var t2;
395
- if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
396
- t2 = /* @__PURE__ */ _jsx5(QuoteIcon, {});
397
- $[2] = t2;
398
- } else {
399
- t2 = $[2];
400
- }
401
- var t3;
402
- if ($[3] !== t1) {
403
- t3 = /* @__PURE__ */ _jsx5(IconButton2, {
404
- variant: "soft",
405
- color: "gray",
406
- size: "1",
407
- onClick: t1,
408
- children: t2
409
- });
410
- $[3] = t1;
411
- $[4] = t3;
412
- } else {
413
- t3 = $[4];
414
- }
415
- var t4 = !!activeFileId;
416
- var t5;
417
- if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
418
- t5 = function(open) {
419
- if (!open) {
420
- setActiveFileId(null);
421
- }
422
- };
423
- $[5] = t5;
424
- } else {
425
- t5 = $[5];
426
- }
427
- var t6;
428
- if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
429
- t6 = {
430
- display: "flex",
431
- flexDirection: "column"
432
- };
433
- $[6] = t6;
434
- } else {
435
- t6 = $[6];
436
- }
437
- var t7;
438
- if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
439
- t7 = /* @__PURE__ */ _jsx5(VisuallyHidden, {
440
- asChild: true,
441
- children: /* @__PURE__ */ _jsx5(Dialog.Title, {
442
- children: "Source"
443
- })
444
- });
445
- $[7] = t7;
446
- } else {
447
- t7 = $[7];
448
- }
449
- var t8;
450
- if ($[8] !== activeFileId) {
451
- t8 = activeFileId && /* @__PURE__ */ _jsx5(Content, {
452
- fileId: activeFileId
453
- });
454
- $[8] = activeFileId;
455
- $[9] = t8;
456
- } else {
457
- t8 = $[9];
458
- }
459
- var t9;
460
- if ($[10] !== t8) {
461
- t9 = /* @__PURE__ */ _jsxs3(Dialog.Content, {
462
- width: "1000px",
463
- height: "90vh",
464
- maxWidth: "calc(100vw - 2 * var(--space-4))",
465
- "aria-describedby": void 0,
466
- style: t6,
467
- children: [
468
- t7,
469
- t8
470
- ]
471
- });
472
- $[10] = t8;
473
- $[11] = t9;
474
- } else {
475
- t9 = $[11];
476
- }
477
- var t10;
478
- if ($[12] !== t4 || $[13] !== t9) {
479
- t10 = /* @__PURE__ */ _jsx5(Dialog.Root, {
480
- open: t4,
481
- onOpenChange: t5,
482
- children: t9
483
- });
484
- $[12] = t4;
485
- $[13] = t9;
486
- $[14] = t10;
487
- } else {
488
- t10 = $[14];
489
- }
490
- var t11;
491
- if ($[15] !== t10 || $[16] !== t3) {
492
- t11 = /* @__PURE__ */ _jsxs3(_Fragment, {
493
- children: [
494
- t3,
495
- t10
496
- ]
497
- });
498
- $[15] = t10;
499
- $[16] = t3;
500
- $[17] = t11;
501
- } else {
502
- t11 = $[17];
503
- }
504
- return t11;
505
- };
506
- // src/components/annotations/SourceAnnotation/index.tsx
507
- import { jsx as _jsx6 } from "react/jsx-runtime";
508
- var _excluded = [
509
- "children"
510
- ];
511
- function _objectWithoutProperties(e, t) {
512
- if (null == e) return {};
513
- var o, r, i = _objectWithoutPropertiesLoose(e, t);
514
- if (Object.getOwnPropertySymbols) {
515
- var s = Object.getOwnPropertySymbols(e);
516
- for(r = 0; r < s.length; r++)o = s[r], t.includes(o) || ({}).propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
517
- }
518
- return i;
519
- }
520
- function _objectWithoutPropertiesLoose(r, e) {
521
- if (null == r) return {};
522
- var t = {};
523
- for(var n in r)if (({}).hasOwnProperty.call(r, n)) {
524
- if (e.includes(n)) continue;
525
- t[n] = r[n];
526
- }
527
- return t;
528
- }
529
- var SourceAnnotation = function(t0) {
530
- var $ = _c4(10);
531
- var children;
532
- var rest;
533
- if ($[0] !== t0) {
534
- var _t = t0;
535
- children = _t.children;
536
- rest = _objectWithoutProperties(_t, _excluded);
537
- _t;
538
- $[0] = t0;
539
- $[1] = children;
540
- $[2] = rest;
541
- } else {
542
- children = $[1];
543
- rest = $[2];
544
- }
545
- var t1;
546
- if ($[3] !== rest) {
547
- var _rest$dataAnnotation;
548
- t1 = JSON.parse((_rest$dataAnnotation = rest["data-annotation"]) !== null && _rest$dataAnnotation !== void 0 ? _rest$dataAnnotation : "{}");
549
- $[3] = rest;
550
- $[4] = t1;
551
- } else {
552
- t1 = $[4];
553
- }
554
- var annotation = t1;
555
- if (annotation.type === "file_citation") {
556
- var t2;
557
- if ($[5] !== annotation) {
558
- t2 = /* @__PURE__ */ _jsx6(FileCitation, {
559
- annotation: annotation
560
- });
561
- $[5] = annotation;
562
- $[6] = t2;
563
- } else {
564
- t2 = $[6];
565
- }
566
- return t2;
567
- } else {
568
- if (annotation.type === "file_path") {
569
- var _t2;
570
- if ($[7] !== annotation || $[8] !== children) {
571
- _t2 = /* @__PURE__ */ _jsx6(FilePathAnnotation, {
572
- annotation: annotation,
573
- children: children
574
- });
575
- $[7] = annotation;
576
- $[8] = children;
577
- $[9] = _t2;
578
- } else {
579
- _t2 = $[9];
580
- }
581
- return _t2;
582
- }
583
- }
584
- return null;
585
- };
586
- export { SourceAnnotation };
587
- //# sourceMappingURL=cloud.js.map