@superinterface/react 2.6.0 → 2.7.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/dist/index.cjs +7 -47
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -3
- package/dist/index.d.ts +1 -3
- package/dist/index.js +7 -47
- package/dist/index.js.map +1 -1
- package/dist/server.cjs +0 -6
- package/dist/server.cjs.map +1 -1
- package/dist/server.js +0 -6
- package/dist/server.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -20,7 +20,6 @@ declare const options: {
|
|
|
20
20
|
type Args$6 = {
|
|
21
21
|
children: React.ReactNode;
|
|
22
22
|
baseUrl?: string;
|
|
23
|
-
publicApiKey?: string;
|
|
24
23
|
variables?: {
|
|
25
24
|
[key: string]: any;
|
|
26
25
|
};
|
|
@@ -30,7 +29,7 @@ type Args$6 = {
|
|
|
30
29
|
};
|
|
31
30
|
threadIdCookieOptions?: typeof options | null;
|
|
32
31
|
};
|
|
33
|
-
declare const SuperinterfaceProvider: ({ children, baseUrl,
|
|
32
|
+
declare const SuperinterfaceProvider: ({ children, baseUrl, variables, defaultOptions, threadIdCookieOptions, }: Args$6) => react_jsx_runtime.JSX.Element;
|
|
34
33
|
|
|
35
34
|
declare const useSuperinterfaceContext: () => {
|
|
36
35
|
baseUrl: string | null;
|
|
@@ -39,7 +38,6 @@ declare const useSuperinterfaceContext: () => {
|
|
|
39
38
|
queries: Record<string, any>;
|
|
40
39
|
mutations: Record<string, any>;
|
|
41
40
|
};
|
|
42
|
-
publicApiKey?: string | undefined;
|
|
43
41
|
threadIdCookieOptions: {
|
|
44
42
|
get: ({ assistantId, }: {
|
|
45
43
|
assistantId: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -20,7 +20,6 @@ declare const options: {
|
|
|
20
20
|
type Args$6 = {
|
|
21
21
|
children: React.ReactNode;
|
|
22
22
|
baseUrl?: string;
|
|
23
|
-
publicApiKey?: string;
|
|
24
23
|
variables?: {
|
|
25
24
|
[key: string]: any;
|
|
26
25
|
};
|
|
@@ -30,7 +29,7 @@ type Args$6 = {
|
|
|
30
29
|
};
|
|
31
30
|
threadIdCookieOptions?: typeof options | null;
|
|
32
31
|
};
|
|
33
|
-
declare const SuperinterfaceProvider: ({ children, baseUrl,
|
|
32
|
+
declare const SuperinterfaceProvider: ({ children, baseUrl, variables, defaultOptions, threadIdCookieOptions, }: Args$6) => react_jsx_runtime.JSX.Element;
|
|
34
33
|
|
|
35
34
|
declare const useSuperinterfaceContext: () => {
|
|
36
35
|
baseUrl: string | null;
|
|
@@ -39,7 +38,6 @@ declare const useSuperinterfaceContext: () => {
|
|
|
39
38
|
queries: Record<string, any>;
|
|
40
39
|
mutations: Record<string, any>;
|
|
41
40
|
};
|
|
42
|
-
publicApiKey?: string | undefined;
|
|
43
41
|
threadIdCookieOptions: {
|
|
44
42
|
get: ({ assistantId, }: {
|
|
45
43
|
assistantId: string;
|
package/dist/index.js
CHANGED
|
@@ -334,12 +334,10 @@ var useSuperinterfaceContext = function() {
|
|
|
334
334
|
// src/components/core/SuperinterfaceProvider/index.tsx
|
|
335
335
|
import { jsx } from "react/jsx-runtime";
|
|
336
336
|
var SuperinterfaceProvider = function(param) {
|
|
337
|
-
var children = param.children, baseUrl2 = param.baseUrl,
|
|
337
|
+
var children = param.children, baseUrl2 = param.baseUrl, variables = param.variables, defaultOptions = param.defaultOptions, threadIdCookieOptions = param.threadIdCookieOptions;
|
|
338
338
|
var superinterfaceContext = useSuperinterfaceContext();
|
|
339
339
|
var value = merge(superinterfaceContext, _object_spread({}, baseUrl2 ? {
|
|
340
340
|
baseUrl: baseUrl2
|
|
341
|
-
} : {}, publicApiKey ? {
|
|
342
|
-
publicApiKey: publicApiKey
|
|
343
341
|
} : {}, variables ? {
|
|
344
342
|
variables: variables
|
|
345
343
|
} : {}, defaultOptions ? {
|
|
@@ -365,21 +363,13 @@ import { infiniteQueryOptions } from "@tanstack/react-query";
|
|
|
365
363
|
var variableParams = function(param) {
|
|
366
364
|
var variables = param.variables, superinterfaceContext = param.superinterfaceContext;
|
|
367
365
|
var _superinterfaceContext_threadIdCookieOptions;
|
|
368
|
-
console.log({
|
|
369
|
-
variables: variables,
|
|
370
|
-
superinterfaceContext: superinterfaceContext
|
|
371
|
-
});
|
|
372
366
|
if (variables.threadId) return variables;
|
|
373
367
|
if (!variables.assistantId) return variables;
|
|
374
368
|
if (!((_superinterfaceContext_threadIdCookieOptions = superinterfaceContext.threadIdCookieOptions) === null || _superinterfaceContext_threadIdCookieOptions === void 0 ? void 0 : _superinterfaceContext_threadIdCookieOptions.get)) return variables;
|
|
375
|
-
console.log("using");
|
|
376
369
|
var threadId = superinterfaceContext.threadIdCookieOptions.get({
|
|
377
370
|
assistantId: variables.assistantId
|
|
378
371
|
});
|
|
379
372
|
if (!threadId) return variables;
|
|
380
|
-
console.log({
|
|
381
|
-
threadId: threadId
|
|
382
|
-
});
|
|
383
373
|
return _object_spread_props(_object_spread({}, variables), {
|
|
384
374
|
threadId: threadId
|
|
385
375
|
});
|
|
@@ -406,11 +396,7 @@ var queryOptions = function(param) {
|
|
|
406
396
|
})));
|
|
407
397
|
return [
|
|
408
398
|
2,
|
|
409
|
-
fetch("".concat(superinterfaceContext.baseUrl).concat(path, "?").concat(params)
|
|
410
|
-
headers: {
|
|
411
|
-
Authorization: "Bearer ".concat(superinterfaceContext.publicApiKey)
|
|
412
|
-
}
|
|
413
|
-
} : {})).then(function() {
|
|
399
|
+
fetch("".concat(superinterfaceContext.baseUrl).concat(path, "?").concat(params)).then(function() {
|
|
414
400
|
var _ref = _async_to_generator(function(response) {
|
|
415
401
|
var errorResponse, error;
|
|
416
402
|
return _ts_generator(this, function(_state) {
|
|
@@ -1641,16 +1627,10 @@ import { JSONParser } from "@streamparser/json-whatwg";
|
|
|
1641
1627
|
var ensure = function(param) {
|
|
1642
1628
|
var superinterfaceContext = param.superinterfaceContext, variables = param.variables, value = param.value;
|
|
1643
1629
|
var _superinterfaceContext_threadIdCookieOptions;
|
|
1644
|
-
console.log({
|
|
1645
|
-
value: value,
|
|
1646
|
-
variables: variables,
|
|
1647
|
-
superinterfaceContext: superinterfaceContext
|
|
1648
|
-
});
|
|
1649
1630
|
if (!((_superinterfaceContext_threadIdCookieOptions = superinterfaceContext.threadIdCookieOptions) === null || _superinterfaceContext_threadIdCookieOptions === void 0 ? void 0 : _superinterfaceContext_threadIdCookieOptions.set)) return;
|
|
1650
1631
|
if (value.value.event !== "thread.run.created") return;
|
|
1651
1632
|
if (variables.threadId) return;
|
|
1652
1633
|
if (!variables.assistantId) return;
|
|
1653
|
-
console.log("saving");
|
|
1654
1634
|
superinterfaceContext.threadIdCookieOptions.set({
|
|
1655
1635
|
assistantId: variables.assistantId,
|
|
1656
1636
|
threadId: value.value.data.thread_id
|
|
@@ -2013,21 +1993,13 @@ var handleResponse = function(param) {
|
|
|
2013
1993
|
var body = function(param) {
|
|
2014
1994
|
var variables = param.variables, superinterfaceContext = param.superinterfaceContext;
|
|
2015
1995
|
var _superinterfaceContext_threadIdCookieOptions;
|
|
2016
|
-
console.log({
|
|
2017
|
-
variables: variables,
|
|
2018
|
-
superinterfaceContext: superinterfaceContext
|
|
2019
|
-
});
|
|
2020
1996
|
if (variables.threadId) return variables;
|
|
2021
1997
|
if (!variables.assistantId) return variables;
|
|
2022
1998
|
if (!((_superinterfaceContext_threadIdCookieOptions = superinterfaceContext.threadIdCookieOptions) === null || _superinterfaceContext_threadIdCookieOptions === void 0 ? void 0 : _superinterfaceContext_threadIdCookieOptions.get)) return variables;
|
|
2023
|
-
console.log("using");
|
|
2024
1999
|
var threadId = superinterfaceContext.threadIdCookieOptions.get({
|
|
2025
2000
|
assistantId: variables.assistantId
|
|
2026
2001
|
});
|
|
2027
2002
|
if (!threadId) return variables;
|
|
2028
|
-
console.log({
|
|
2029
|
-
threadId: threadId
|
|
2030
|
-
});
|
|
2031
2003
|
return _object_spread_props(_object_spread({}, variables), {
|
|
2032
2004
|
threadId: threadId
|
|
2033
2005
|
});
|
|
@@ -2043,17 +2015,13 @@ var mutationFn = function(param) {
|
|
|
2043
2015
|
case 0:
|
|
2044
2016
|
return [
|
|
2045
2017
|
4,
|
|
2046
|
-
fetch("".concat(superinterfaceContext.baseUrl, "/messages"),
|
|
2018
|
+
fetch("".concat(superinterfaceContext.baseUrl, "/messages"), {
|
|
2047
2019
|
method: "POST",
|
|
2048
2020
|
body: JSON.stringify(body({
|
|
2049
2021
|
variables: variables,
|
|
2050
2022
|
superinterfaceContext: superinterfaceContext
|
|
2051
2023
|
}))
|
|
2052
|
-
}
|
|
2053
|
-
headers: {
|
|
2054
|
-
Authorization: "Bearer ".concat(superinterfaceContext.publicApiKey)
|
|
2055
|
-
}
|
|
2056
|
-
} : {}))
|
|
2024
|
+
})
|
|
2057
2025
|
];
|
|
2058
2026
|
case 1:
|
|
2059
2027
|
response = _state.sent();
|
|
@@ -3037,10 +3005,8 @@ var useMessageAudio = function(param) {
|
|
|
3037
3005
|
});
|
|
3038
3006
|
var searchParams = new URLSearchParams(_object_spread({
|
|
3039
3007
|
input: firstUnplayedMessageSentence.sentence
|
|
3040
|
-
},
|
|
3041
|
-
|
|
3042
|
-
} : {}));
|
|
3043
|
-
audioPlayer.load("".concat(superinterfaceContext.baseUrl, "/tts?").concat(searchParams), _object_spread({
|
|
3008
|
+
}, superinterfaceContext.variables));
|
|
3009
|
+
audioPlayer.load("".concat(superinterfaceContext.baseUrl, "/tts?").concat(searchParams), {
|
|
3044
3010
|
format: "mp3",
|
|
3045
3011
|
autoplay: true,
|
|
3046
3012
|
html5: isHtmlAudioSupported,
|
|
@@ -3050,13 +3016,7 @@ var useMessageAudio = function(param) {
|
|
|
3050
3016
|
onEnd();
|
|
3051
3017
|
}
|
|
3052
3018
|
}
|
|
3053
|
-
}
|
|
3054
|
-
xhr: _object_spread({}, superinterfaceContext.publicApiKey ? {
|
|
3055
|
-
headers: {
|
|
3056
|
-
Authorization: "Bearer ".concat(superinterfaceContext.publicApiKey)
|
|
3057
|
-
}
|
|
3058
|
-
} : {})
|
|
3059
|
-
}));
|
|
3019
|
+
});
|
|
3060
3020
|
}, [
|
|
3061
3021
|
unplayedMessageSentences,
|
|
3062
3022
|
isPlaying,
|