react-instantsearch-core 7.34.0 → 7.35.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/cjs/version.js
CHANGED
package/dist/es/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: "7.
|
|
1
|
+
declare const _default: "7.35.1";
|
|
2
2
|
export default _default;
|
package/dist/es/version.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! React InstantSearch Core 7.
|
|
1
|
+
/*! React InstantSearch Core 7.35.1 | © Algolia, Inc. and contributors; MIT License | https://github.com/algolia/instantsearch */
|
|
2
2
|
(function (global, factory) {
|
|
3
3
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react')) :
|
|
4
4
|
typeof define === 'function' && define.amd ? define(['exports', 'react'], factory) :
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
|
|
25
25
|
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
26
26
|
|
|
27
|
-
var version$2 = '7.
|
|
27
|
+
var version$2 = '7.35.1';
|
|
28
28
|
|
|
29
29
|
function _define_property(obj, key, value) {
|
|
30
30
|
if (key in obj) {
|
|
@@ -10853,7 +10853,7 @@
|
|
|
10853
10853
|
};
|
|
10854
10854
|
}
|
|
10855
10855
|
|
|
10856
|
-
var version = '4.
|
|
10856
|
+
var version = '4.101.1';
|
|
10857
10857
|
|
|
10858
10858
|
var withUsage$r = createDocumentationMessageGenerator({
|
|
10859
10859
|
name: 'instantsearch'
|
|
@@ -12262,16 +12262,21 @@
|
|
|
12262
12262
|
onDone();
|
|
12263
12263
|
return;
|
|
12264
12264
|
}
|
|
12265
|
-
|
|
12266
|
-
|
|
12267
|
-
result.then
|
|
12268
|
-
|
|
12269
|
-
|
|
12270
|
-
|
|
12271
|
-
|
|
12272
|
-
|
|
12273
|
-
|
|
12274
|
-
|
|
12265
|
+
try {
|
|
12266
|
+
var result = onChunk(value);
|
|
12267
|
+
if (result && typeof result.then === 'function') {
|
|
12268
|
+
result.then(function() {
|
|
12269
|
+
return read();
|
|
12270
|
+
}, function(error) {
|
|
12271
|
+
reader.releaseLock();
|
|
12272
|
+
onError(error);
|
|
12273
|
+
});
|
|
12274
|
+
} else {
|
|
12275
|
+
read();
|
|
12276
|
+
}
|
|
12277
|
+
} catch (error) {
|
|
12278
|
+
reader.releaseLock();
|
|
12279
|
+
onError(error);
|
|
12275
12280
|
}
|
|
12276
12281
|
}, function(error) {
|
|
12277
12282
|
reader.releaseLock();
|
|
@@ -12281,6 +12286,49 @@
|
|
|
12281
12286
|
read();
|
|
12282
12287
|
}
|
|
12283
12288
|
|
|
12289
|
+
function _construct(Parent, args, Class) {
|
|
12290
|
+
if (_is_native_reflect_construct()) _construct = Reflect.construct;
|
|
12291
|
+
else {
|
|
12292
|
+
_construct = function construct(Parent, args, Class) {
|
|
12293
|
+
var a = [null];
|
|
12294
|
+
a.push.apply(a, args);
|
|
12295
|
+
var Constructor = Function.bind.apply(Parent, a);
|
|
12296
|
+
var instance = new Constructor();
|
|
12297
|
+
|
|
12298
|
+
if (Class) _set_prototype_of(instance, Class.prototype);
|
|
12299
|
+
|
|
12300
|
+
return instance;
|
|
12301
|
+
};
|
|
12302
|
+
}
|
|
12303
|
+
|
|
12304
|
+
return _construct.apply(null, arguments);
|
|
12305
|
+
}
|
|
12306
|
+
|
|
12307
|
+
function _is_native_function(fn) {
|
|
12308
|
+
return Function.toString.call(fn).indexOf("[native code]") !== -1;
|
|
12309
|
+
}
|
|
12310
|
+
|
|
12311
|
+
function _wrap_native_super(Class) {
|
|
12312
|
+
var _cache = typeof Map === "function" ? new Map() : undefined;
|
|
12313
|
+
_wrap_native_super = function(Class) {
|
|
12314
|
+
if (Class === null || !_is_native_function(Class)) return Class;
|
|
12315
|
+
if (typeof Class !== "function") throw new TypeError("Super expression must either be null or a function");
|
|
12316
|
+
if (typeof _cache !== "undefined") {
|
|
12317
|
+
if (_cache.has(Class)) return _cache.get(Class);
|
|
12318
|
+
_cache.set(Class, Wrapper);
|
|
12319
|
+
}
|
|
12320
|
+
|
|
12321
|
+
function Wrapper() {
|
|
12322
|
+
return _construct(Class, arguments, _get_prototype_of(this).constructor);
|
|
12323
|
+
}
|
|
12324
|
+
Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } });
|
|
12325
|
+
|
|
12326
|
+
return _set_prototype_of(Wrapper, Class);
|
|
12327
|
+
};
|
|
12328
|
+
|
|
12329
|
+
return _wrap_native_super(Class);
|
|
12330
|
+
}
|
|
12331
|
+
|
|
12284
12332
|
function generateId() {
|
|
12285
12333
|
return Math.random().toString(36).substring(2, 9);
|
|
12286
12334
|
}
|
|
@@ -12353,6 +12401,49 @@
|
|
|
12353
12401
|
}
|
|
12354
12402
|
return Promise.resolve(value);
|
|
12355
12403
|
}
|
|
12404
|
+
/**
|
|
12405
|
+
* Error raised when the upstream stream emits a `data-guardrail-violation`
|
|
12406
|
+
* chunk. The `message` carries the service-provided `fallbackResponse`, which
|
|
12407
|
+
* is intentionally surfaced verbatim through the chat error UI (unlike
|
|
12408
|
+
* generic cost-control / 4xx errors, where the raw API message is hidden
|
|
12409
|
+
* behind a friendly default).
|
|
12410
|
+
*
|
|
12411
|
+
* Detection across package boundaries should rely on `error.name` rather than
|
|
12412
|
+
* `instanceof` to avoid issues with mixed module copies in bundled apps.
|
|
12413
|
+
*/ var GuardrailViolationError = /*#__PURE__*/ function(Error1) {
|
|
12414
|
+
_inherits(GuardrailViolationError, Error1);
|
|
12415
|
+
function GuardrailViolationError(message) {
|
|
12416
|
+
_class_call_check(this, GuardrailViolationError);
|
|
12417
|
+
var _this;
|
|
12418
|
+
_this = _call_super(this, GuardrailViolationError, [
|
|
12419
|
+
message
|
|
12420
|
+
]);
|
|
12421
|
+
_this.name = 'GuardrailViolationError';
|
|
12422
|
+
return _this;
|
|
12423
|
+
}
|
|
12424
|
+
return GuardrailViolationError;
|
|
12425
|
+
}(_wrap_native_super(Error));
|
|
12426
|
+
/**
|
|
12427
|
+
* Reads a non-empty `message` field off a JSON-serialized error envelope.
|
|
12428
|
+
*
|
|
12429
|
+
* Both transports backing `AbstractChat` (stream `error` chunks and HTTP error
|
|
12430
|
+
* responses) serialize errors as `{"message": "...", ...}` — the same shape as
|
|
12431
|
+
* the shared `ErrorResponse` on the API side. Returns the trimmed message if
|
|
12432
|
+
* the input is such a JSON object, otherwise `undefined`.
|
|
12433
|
+
*/ function tryParseErrorMessage(text) {
|
|
12434
|
+
try {
|
|
12435
|
+
var parsed = JSON.parse(text);
|
|
12436
|
+
if (parsed && (typeof parsed === "undefined" ? "undefined" : _type_of(parsed)) === 'object' && !Array.isArray(parsed) && typeof parsed.message === 'string') {
|
|
12437
|
+
var message = parsed.message.trim();
|
|
12438
|
+
if (message) {
|
|
12439
|
+
return message;
|
|
12440
|
+
}
|
|
12441
|
+
}
|
|
12442
|
+
} catch (unused) {
|
|
12443
|
+
// Not JSON — caller falls back to its own default.
|
|
12444
|
+
}
|
|
12445
|
+
return undefined;
|
|
12446
|
+
}
|
|
12356
12447
|
|
|
12357
12448
|
var tryParseJson = function tryParseJson(value) {
|
|
12358
12449
|
try {
|
|
@@ -12431,7 +12522,7 @@
|
|
|
12431
12522
|
var _param_generateId = param.generateId, generateId$1 = _param_generateId === void 0 ? generateId : _param_generateId, _param_id = param.id, id = _param_id === void 0 ? generateId$1() : _param_id, transport = param.transport, state = param.state, onError = param.onError, onToolCall = param.onToolCall, onFinish = param.onFinish, onData = param.onData, sendAutomaticallyWhen = param.sendAutomaticallyWhen, shouldRepairToolInput = param.shouldRepairToolInput;
|
|
12432
12523
|
var _this1 = this;
|
|
12433
12524
|
_class_call_check(this, AbstractChat);
|
|
12434
|
-
_define_property(this, "
|
|
12525
|
+
_define_property(this, "conversationId", void 0);
|
|
12435
12526
|
_define_property(this, "generateId", void 0);
|
|
12436
12527
|
_define_property(this, "state", void 0);
|
|
12437
12528
|
_define_property(this, "transport", void 0);
|
|
@@ -12587,12 +12678,6 @@
|
|
|
12587
12678
|
}
|
|
12588
12679
|
});
|
|
12589
12680
|
/**
|
|
12590
|
-
* Regenerate the chat id. Use this to start a fresh conversation on the
|
|
12591
|
-
* server while keeping the same Chat instance and its registered listeners.
|
|
12592
|
-
*/ _define_property(this, "regenerateId", function() {
|
|
12593
|
-
_this.id = _this.generateId();
|
|
12594
|
-
});
|
|
12595
|
-
/**
|
|
12596
12681
|
* Add a tool result for a tool call.
|
|
12597
12682
|
*/ _define_property(this, "addToolResult", function(param) {
|
|
12598
12683
|
var tool = param.tool, toolCallId = param.toolCallId, output = param.output;
|
|
@@ -12647,7 +12732,7 @@
|
|
|
12647
12732
|
});
|
|
12648
12733
|
return Promise.resolve();
|
|
12649
12734
|
});
|
|
12650
|
-
this.
|
|
12735
|
+
this.conversationId = id;
|
|
12651
12736
|
this.generateId = generateId$1;
|
|
12652
12737
|
this.state = state;
|
|
12653
12738
|
this.transport = transport;
|
|
@@ -12659,6 +12744,12 @@
|
|
|
12659
12744
|
this.shouldRepairToolInput = shouldRepairToolInput;
|
|
12660
12745
|
}
|
|
12661
12746
|
_create_class(AbstractChat, [
|
|
12747
|
+
{
|
|
12748
|
+
key: "id",
|
|
12749
|
+
get: function get() {
|
|
12750
|
+
return this.conversationId;
|
|
12751
|
+
}
|
|
12752
|
+
},
|
|
12662
12753
|
{
|
|
12663
12754
|
key: "status",
|
|
12664
12755
|
get: /**
|
|
@@ -12688,6 +12779,17 @@
|
|
|
12688
12779
|
return this.state.error;
|
|
12689
12780
|
}
|
|
12690
12781
|
},
|
|
12782
|
+
{
|
|
12783
|
+
/**
|
|
12784
|
+
* Starts a new server-side conversation thread by rotating the id sent as
|
|
12785
|
+
* `chatId` / `id` on the next request. The InstantSearch connector calls this
|
|
12786
|
+
* after the user clears the transcript so completions are not tied to prior
|
|
12787
|
+
* context.
|
|
12788
|
+
*/ key: "resetConversationId",
|
|
12789
|
+
value: function resetConversationId() {
|
|
12790
|
+
this.conversationId = this.generateId();
|
|
12791
|
+
}
|
|
12792
|
+
},
|
|
12691
12793
|
{
|
|
12692
12794
|
key: "messages",
|
|
12693
12795
|
get: function get() {
|
|
@@ -13056,8 +13158,7 @@
|
|
|
13056
13158
|
var updatedParts7 = _to_consumable_array(currentMessage.parts);
|
|
13057
13159
|
var existingPart2 = updatedParts7[toolIndex2];
|
|
13058
13160
|
// eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars
|
|
13059
|
-
existingPart2.rawOutput
|
|
13060
|
-
var rest = _object_without_properties(existingPart2, [
|
|
13161
|
+
var _ignored = existingPart2.rawOutput, rest = _object_without_properties(existingPart2, [
|
|
13061
13162
|
"rawOutput"
|
|
13062
13163
|
]);
|
|
13063
13164
|
updatedParts7[toolIndex2] = _object_spread_props(_object_spread({}, rest), {
|
|
@@ -13085,10 +13186,7 @@
|
|
|
13085
13186
|
delete toolRawOutputByCallId[chunk.toolCallId];
|
|
13086
13187
|
var updatedParts8 = _to_consumable_array(currentMessage.parts);
|
|
13087
13188
|
var existingPart3 = updatedParts8[toolIndex3];
|
|
13088
|
-
|
|
13089
|
-
existingPart3.rawOutput; // eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars
|
|
13090
|
-
existingPart3.preliminary;
|
|
13091
|
-
var rest1 = _object_without_properties(existingPart3, [
|
|
13189
|
+
var _ignoredRawOutput = existingPart3.rawOutput, _ignoredPreliminary = existingPart3.preliminary, rest1 = _object_without_properties(existingPart3, [
|
|
13092
13190
|
"rawOutput",
|
|
13093
13191
|
"preliminary"
|
|
13094
13192
|
]);
|
|
@@ -13183,7 +13281,8 @@
|
|
|
13183
13281
|
case 'error':
|
|
13184
13282
|
{
|
|
13185
13283
|
isError = true;
|
|
13186
|
-
|
|
13284
|
+
var text = chunk.errorText.trim();
|
|
13285
|
+
throw new Error(tryParseErrorMessage(text) || text || 'Unknown error');
|
|
13187
13286
|
}
|
|
13188
13287
|
case 'abort':
|
|
13189
13288
|
{
|
|
@@ -13200,9 +13299,32 @@
|
|
|
13200
13299
|
}
|
|
13201
13300
|
break;
|
|
13202
13301
|
}
|
|
13302
|
+
// Surface guardrail violations through the error state, but
|
|
13303
|
+
// distinct from generic cost-control / 4xx errors: throw a
|
|
13304
|
+
// `GuardrailViolationError` so the UI can render the
|
|
13305
|
+
// service-provided `fallbackResponse` verbatim (it's authored for
|
|
13306
|
+
// end-user display) instead of the friendly default used for
|
|
13307
|
+
// opaque transport errors. Also discard any in-progress assistant
|
|
13308
|
+
// message so no partial text lingers above the fallback, and
|
|
13309
|
+
// clear the local cursor so the `onFinish` callback doesn't
|
|
13310
|
+
// receive a `currentMessage` that no longer exists in state.
|
|
13311
|
+
case 'data-guardrail-violation':
|
|
13312
|
+
{
|
|
13313
|
+
isError = true;
|
|
13314
|
+
if (currentMessageIndex >= 0) {
|
|
13315
|
+
_this.state.messages = _this.state.messages.slice(0, currentMessageIndex);
|
|
13316
|
+
currentMessage = undefined;
|
|
13317
|
+
currentMessageIndex = -1;
|
|
13318
|
+
}
|
|
13319
|
+
// `chunk.data` widens to `unknown` here: the chunk union also
|
|
13320
|
+
// carries a generic `data-${string}` member, and the literal
|
|
13321
|
+
// matches both, so narrowing can't pick the specific shape.
|
|
13322
|
+
var fallbackResponse = chunk.data.fallbackResponse;
|
|
13323
|
+
throw new GuardrailViolationError(fallbackResponse || 'Sorry, we are not able to generate a response at the moment.');
|
|
13324
|
+
}
|
|
13203
13325
|
default:
|
|
13204
13326
|
{
|
|
13205
|
-
// Handle data parts (data-*)
|
|
13327
|
+
// Handle generic data parts (data-*)
|
|
13206
13328
|
var chunkType = chunk.type;
|
|
13207
13329
|
if ((chunkType === null || chunkType === void 0 ? void 0 : chunkType.startsWith('data-')) && currentMessage) {
|
|
13208
13330
|
var dataPart = {
|
|
@@ -13512,6 +13634,20 @@
|
|
|
13512
13634
|
}, []);
|
|
13513
13635
|
}
|
|
13514
13636
|
|
|
13637
|
+
/**
|
|
13638
|
+
* Reads a human-readable message from a failed HTTP response body when the
|
|
13639
|
+
* server returns JSON such as `{ "message": "..." }` (the shared
|
|
13640
|
+
* `ErrorResponse` shape used by every status code), falling back to the HTTP
|
|
13641
|
+
* status line when the body is empty or not parseable.
|
|
13642
|
+
*/ function getHttpErrorMessage(response) {
|
|
13643
|
+
var fallback = "HTTP error: ".concat(response.status, " ").concat(response.statusText);
|
|
13644
|
+
return response.text().then(function(text) {
|
|
13645
|
+
var _tryParseErrorMessage;
|
|
13646
|
+
return (_tryParseErrorMessage = tryParseErrorMessage(text)) !== null && _tryParseErrorMessage !== void 0 ? _tryParseErrorMessage : fallback;
|
|
13647
|
+
}).catch(function() {
|
|
13648
|
+
return fallback;
|
|
13649
|
+
});
|
|
13650
|
+
}
|
|
13515
13651
|
/**
|
|
13516
13652
|
* Abstract base class for HTTP-based chat transports.
|
|
13517
13653
|
*/ var HttpChatTransport = /*#__PURE__*/ function() {
|
|
@@ -13590,7 +13726,9 @@
|
|
|
13590
13726
|
credentials: credentials
|
|
13591
13727
|
}).then(function(response) {
|
|
13592
13728
|
if (!response.ok) {
|
|
13593
|
-
|
|
13729
|
+
return getHttpErrorMessage(response).then(function(message) {
|
|
13730
|
+
throw new Error(message);
|
|
13731
|
+
});
|
|
13594
13732
|
}
|
|
13595
13733
|
if (!response.body) {
|
|
13596
13734
|
throw new Error('Response body is empty');
|
|
@@ -13648,7 +13786,9 @@
|
|
|
13648
13786
|
if (response.status === 404) {
|
|
13649
13787
|
return null;
|
|
13650
13788
|
}
|
|
13651
|
-
|
|
13789
|
+
return getHttpErrorMessage(response).then(function(message) {
|
|
13790
|
+
throw new Error(message);
|
|
13791
|
+
});
|
|
13652
13792
|
}
|
|
13653
13793
|
if (!response.body) {
|
|
13654
13794
|
return null;
|
|
@@ -13796,7 +13936,7 @@
|
|
|
13796
13936
|
var onClearTransitionEnd = function onClearTransitionEnd() {
|
|
13797
13937
|
setMessages([]);
|
|
13798
13938
|
_chatInstance.clearError();
|
|
13799
|
-
_chatInstance.
|
|
13939
|
+
_chatInstance.resetConversationId();
|
|
13800
13940
|
feedbackState = {};
|
|
13801
13941
|
setIsClearing(false);
|
|
13802
13942
|
};
|