@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.cjs
CHANGED
|
@@ -461,12 +461,10 @@ var useSuperinterfaceContext = function() {
|
|
|
461
461
|
// src/components/core/SuperinterfaceProvider/index.tsx
|
|
462
462
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
463
463
|
var SuperinterfaceProvider = function(param) {
|
|
464
|
-
var children = param.children, baseUrl2 = param.baseUrl,
|
|
464
|
+
var children = param.children, baseUrl2 = param.baseUrl, variables = param.variables, defaultOptions = param.defaultOptions, threadIdCookieOptions = param.threadIdCookieOptions;
|
|
465
465
|
var superinterfaceContext = useSuperinterfaceContext();
|
|
466
466
|
var value = merge(superinterfaceContext, _object_spread({}, baseUrl2 ? {
|
|
467
467
|
baseUrl: baseUrl2
|
|
468
|
-
} : {}, publicApiKey ? {
|
|
469
|
-
publicApiKey: publicApiKey
|
|
470
468
|
} : {}, variables ? {
|
|
471
469
|
variables: variables
|
|
472
470
|
} : {}, defaultOptions ? {
|
|
@@ -492,21 +490,13 @@ var import_react_query = require("@tanstack/react-query");
|
|
|
492
490
|
var variableParams = function(param) {
|
|
493
491
|
var variables = param.variables, superinterfaceContext = param.superinterfaceContext;
|
|
494
492
|
var _superinterfaceContext_threadIdCookieOptions;
|
|
495
|
-
console.log({
|
|
496
|
-
variables: variables,
|
|
497
|
-
superinterfaceContext: superinterfaceContext
|
|
498
|
-
});
|
|
499
493
|
if (variables.threadId) return variables;
|
|
500
494
|
if (!variables.assistantId) return variables;
|
|
501
495
|
if (!((_superinterfaceContext_threadIdCookieOptions = superinterfaceContext.threadIdCookieOptions) === null || _superinterfaceContext_threadIdCookieOptions === void 0 ? void 0 : _superinterfaceContext_threadIdCookieOptions.get)) return variables;
|
|
502
|
-
console.log("using");
|
|
503
496
|
var threadId = superinterfaceContext.threadIdCookieOptions.get({
|
|
504
497
|
assistantId: variables.assistantId
|
|
505
498
|
});
|
|
506
499
|
if (!threadId) return variables;
|
|
507
|
-
console.log({
|
|
508
|
-
threadId: threadId
|
|
509
|
-
});
|
|
510
500
|
return _object_spread_props(_object_spread({}, variables), {
|
|
511
501
|
threadId: threadId
|
|
512
502
|
});
|
|
@@ -533,11 +523,7 @@ var queryOptions = function(param) {
|
|
|
533
523
|
})));
|
|
534
524
|
return [
|
|
535
525
|
2,
|
|
536
|
-
fetch("".concat(superinterfaceContext.baseUrl).concat(path, "?").concat(params)
|
|
537
|
-
headers: {
|
|
538
|
-
Authorization: "Bearer ".concat(superinterfaceContext.publicApiKey)
|
|
539
|
-
}
|
|
540
|
-
} : {})).then(function() {
|
|
526
|
+
fetch("".concat(superinterfaceContext.baseUrl).concat(path, "?").concat(params)).then(function() {
|
|
541
527
|
var _ref = _async_to_generator(function(response) {
|
|
542
528
|
var errorResponse, error;
|
|
543
529
|
return _ts_generator(this, function(_state) {
|
|
@@ -1768,16 +1754,10 @@ var import_json_whatwg = require("@streamparser/json-whatwg");
|
|
|
1768
1754
|
var ensure = function(param) {
|
|
1769
1755
|
var superinterfaceContext = param.superinterfaceContext, variables = param.variables, value = param.value;
|
|
1770
1756
|
var _superinterfaceContext_threadIdCookieOptions;
|
|
1771
|
-
console.log({
|
|
1772
|
-
value: value,
|
|
1773
|
-
variables: variables,
|
|
1774
|
-
superinterfaceContext: superinterfaceContext
|
|
1775
|
-
});
|
|
1776
1757
|
if (!((_superinterfaceContext_threadIdCookieOptions = superinterfaceContext.threadIdCookieOptions) === null || _superinterfaceContext_threadIdCookieOptions === void 0 ? void 0 : _superinterfaceContext_threadIdCookieOptions.set)) return;
|
|
1777
1758
|
if (value.value.event !== "thread.run.created") return;
|
|
1778
1759
|
if (variables.threadId) return;
|
|
1779
1760
|
if (!variables.assistantId) return;
|
|
1780
|
-
console.log("saving");
|
|
1781
1761
|
superinterfaceContext.threadIdCookieOptions.set({
|
|
1782
1762
|
assistantId: variables.assistantId,
|
|
1783
1763
|
threadId: value.value.data.thread_id
|
|
@@ -2140,21 +2120,13 @@ var handleResponse = function(param) {
|
|
|
2140
2120
|
var body = function(param) {
|
|
2141
2121
|
var variables = param.variables, superinterfaceContext = param.superinterfaceContext;
|
|
2142
2122
|
var _superinterfaceContext_threadIdCookieOptions;
|
|
2143
|
-
console.log({
|
|
2144
|
-
variables: variables,
|
|
2145
|
-
superinterfaceContext: superinterfaceContext
|
|
2146
|
-
});
|
|
2147
2123
|
if (variables.threadId) return variables;
|
|
2148
2124
|
if (!variables.assistantId) return variables;
|
|
2149
2125
|
if (!((_superinterfaceContext_threadIdCookieOptions = superinterfaceContext.threadIdCookieOptions) === null || _superinterfaceContext_threadIdCookieOptions === void 0 ? void 0 : _superinterfaceContext_threadIdCookieOptions.get)) return variables;
|
|
2150
|
-
console.log("using");
|
|
2151
2126
|
var threadId = superinterfaceContext.threadIdCookieOptions.get({
|
|
2152
2127
|
assistantId: variables.assistantId
|
|
2153
2128
|
});
|
|
2154
2129
|
if (!threadId) return variables;
|
|
2155
|
-
console.log({
|
|
2156
|
-
threadId: threadId
|
|
2157
|
-
});
|
|
2158
2130
|
return _object_spread_props(_object_spread({}, variables), {
|
|
2159
2131
|
threadId: threadId
|
|
2160
2132
|
});
|
|
@@ -2170,17 +2142,13 @@ var mutationFn = function(param) {
|
|
|
2170
2142
|
case 0:
|
|
2171
2143
|
return [
|
|
2172
2144
|
4,
|
|
2173
|
-
fetch("".concat(superinterfaceContext.baseUrl, "/messages"),
|
|
2145
|
+
fetch("".concat(superinterfaceContext.baseUrl, "/messages"), {
|
|
2174
2146
|
method: "POST",
|
|
2175
2147
|
body: JSON.stringify(body({
|
|
2176
2148
|
variables: variables,
|
|
2177
2149
|
superinterfaceContext: superinterfaceContext
|
|
2178
2150
|
}))
|
|
2179
|
-
}
|
|
2180
|
-
headers: {
|
|
2181
|
-
Authorization: "Bearer ".concat(superinterfaceContext.publicApiKey)
|
|
2182
|
-
}
|
|
2183
|
-
} : {}))
|
|
2151
|
+
})
|
|
2184
2152
|
];
|
|
2185
2153
|
case 1:
|
|
2186
2154
|
response = _state.sent();
|
|
@@ -3164,10 +3132,8 @@ var useMessageAudio = function(param) {
|
|
|
3164
3132
|
});
|
|
3165
3133
|
var searchParams = new URLSearchParams(_object_spread({
|
|
3166
3134
|
input: firstUnplayedMessageSentence.sentence
|
|
3167
|
-
},
|
|
3168
|
-
|
|
3169
|
-
} : {}));
|
|
3170
|
-
audioPlayer.load("".concat(superinterfaceContext.baseUrl, "/tts?").concat(searchParams), _object_spread({
|
|
3135
|
+
}, superinterfaceContext.variables));
|
|
3136
|
+
audioPlayer.load("".concat(superinterfaceContext.baseUrl, "/tts?").concat(searchParams), {
|
|
3171
3137
|
format: "mp3",
|
|
3172
3138
|
autoplay: true,
|
|
3173
3139
|
html5: isHtmlAudioSupported,
|
|
@@ -3177,13 +3143,7 @@ var useMessageAudio = function(param) {
|
|
|
3177
3143
|
onEnd();
|
|
3178
3144
|
}
|
|
3179
3145
|
}
|
|
3180
|
-
}
|
|
3181
|
-
xhr: _object_spread({}, superinterfaceContext.publicApiKey ? {
|
|
3182
|
-
headers: {
|
|
3183
|
-
Authorization: "Bearer ".concat(superinterfaceContext.publicApiKey)
|
|
3184
|
-
}
|
|
3185
|
-
} : {})
|
|
3186
|
-
}));
|
|
3146
|
+
});
|
|
3187
3147
|
}, [
|
|
3188
3148
|
unplayedMessageSentences,
|
|
3189
3149
|
isPlaying,
|