react-instantsearch-core 7.37.0 → 7.39.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/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.39.0";
|
|
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.39.0 | © 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.39.0';
|
|
28
28
|
|
|
29
29
|
function _define_property(obj, key, value) {
|
|
30
30
|
if (key in obj) {
|
|
@@ -571,10 +571,10 @@
|
|
|
571
571
|
return objectHasKeys_1;
|
|
572
572
|
}
|
|
573
573
|
|
|
574
|
-
var omit;
|
|
574
|
+
var omit$1;
|
|
575
575
|
var hasRequiredOmit;
|
|
576
576
|
function requireOmit() {
|
|
577
|
-
if (hasRequiredOmit) return omit;
|
|
577
|
+
if (hasRequiredOmit) return omit$1;
|
|
578
578
|
hasRequiredOmit = 1;
|
|
579
579
|
// https://github.com/babel/babel/blob/3aaafae053fa75febb3aa45d45b6f00646e30ba4/packages/babel-helpers/src/helpers.js#L604-L620
|
|
580
580
|
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
@@ -591,8 +591,8 @@
|
|
|
591
591
|
}
|
|
592
592
|
return target;
|
|
593
593
|
}
|
|
594
|
-
omit = _objectWithoutPropertiesLoose;
|
|
595
|
-
return omit;
|
|
594
|
+
omit$1 = _objectWithoutPropertiesLoose;
|
|
595
|
+
return omit$1;
|
|
596
596
|
}
|
|
597
597
|
|
|
598
598
|
var RecommendParameters_1;
|
|
@@ -3919,7 +3919,7 @@
|
|
|
3919
3919
|
function requireVersion() {
|
|
3920
3920
|
if (hasRequiredVersion) return version$1;
|
|
3921
3921
|
hasRequiredVersion = 1;
|
|
3922
|
-
version$1 = '3.29.
|
|
3922
|
+
version$1 = '3.29.2';
|
|
3923
3923
|
return version$1;
|
|
3924
3924
|
}
|
|
3925
3925
|
|
|
@@ -6903,10 +6903,11 @@
|
|
|
6903
6903
|
|
|
6904
6904
|
var hasAlphanumeric = new RegExp(/\w/i);
|
|
6905
6905
|
function getHighlightFromSiblings(parts, i) {
|
|
6906
|
+
var _ref, _ref1;
|
|
6906
6907
|
var _parts_, _parts_1;
|
|
6907
6908
|
var current = parts[i];
|
|
6908
|
-
var isNextHighlighted = ((_parts_ = parts[i + 1]) === null || _parts_ === void 0 ? void 0 : _parts_.isHighlighted)
|
|
6909
|
-
var isPreviousHighlighted = ((_parts_1 = parts[i - 1]) === null || _parts_1 === void 0 ? void 0 : _parts_1.isHighlighted)
|
|
6909
|
+
var isNextHighlighted = (_ref = (_parts_ = parts[i + 1]) === null || _parts_ === void 0 ? void 0 : _parts_.isHighlighted) !== null && _ref !== void 0 ? _ref : true;
|
|
6910
|
+
var isPreviousHighlighted = (_ref1 = (_parts_1 = parts[i - 1]) === null || _parts_1 === void 0 ? void 0 : _parts_1.isHighlighted) !== null && _ref1 !== void 0 ? _ref1 : true;
|
|
6910
6911
|
if (!hasAlphanumeric.test(unescape$1(current.value)) && isPreviousHighlighted === isNextHighlighted) {
|
|
6911
6912
|
return isPreviousHighlighted;
|
|
6912
6913
|
}
|
|
@@ -7266,19 +7267,23 @@
|
|
|
7266
7267
|
return widget.$$type === 'ais.dynamicWidgets' || widget.$$type === 'ais.feeds';
|
|
7267
7268
|
}
|
|
7268
7269
|
|
|
7269
|
-
|
|
7270
|
-
|
|
7271
|
-
|
|
7272
|
-
|
|
7273
|
-
|
|
7274
|
-
|
|
7275
|
-
|
|
7276
|
-
|
|
7277
|
-
|
|
7278
|
-
|
|
7279
|
-
|
|
7280
|
-
|
|
7281
|
-
|
|
7270
|
+
/**
|
|
7271
|
+
* Creates a new object with the same keys as the original object, but without the excluded keys.
|
|
7272
|
+
* @param source original object
|
|
7273
|
+
* @param excluded keys to remove from the original object
|
|
7274
|
+
* @returns the new object
|
|
7275
|
+
*/ function omit(source, excluded) {
|
|
7276
|
+
if (source === null || source === undefined) {
|
|
7277
|
+
return source;
|
|
7278
|
+
}
|
|
7279
|
+
return Object.keys(source).reduce(function(target, key) {
|
|
7280
|
+
if (excluded.indexOf(key) >= 0) {
|
|
7281
|
+
return target;
|
|
7282
|
+
}
|
|
7283
|
+
var validKey = key;
|
|
7284
|
+
target[validKey] = source[validKey];
|
|
7285
|
+
return target;
|
|
7286
|
+
}, {});
|
|
7282
7287
|
}
|
|
7283
7288
|
|
|
7284
7289
|
function createInitArgs(instantSearchInstance, parent, uiState) {
|
|
@@ -7326,6 +7331,132 @@
|
|
|
7326
7331
|
instantSearchInstance.renderState = _object_spread_props(_object_spread({}, instantSearchInstance.renderState), _define_property({}, parentIndexName, _object_spread({}, instantSearchInstance.renderState[parentIndexName], renderState)));
|
|
7327
7332
|
}
|
|
7328
7333
|
|
|
7334
|
+
function serializeParamValue(value) {
|
|
7335
|
+
if (value === undefined || value === null) {
|
|
7336
|
+
return null;
|
|
7337
|
+
}
|
|
7338
|
+
var t = typeof value === "undefined" ? "undefined" : _type_of(value);
|
|
7339
|
+
if (t === 'string' || t === 'number' || t === 'boolean') {
|
|
7340
|
+
return {
|
|
7341
|
+
value: String(value),
|
|
7342
|
+
type: t
|
|
7343
|
+
};
|
|
7344
|
+
}
|
|
7345
|
+
if (Array.isArray(value) || t === 'object') {
|
|
7346
|
+
var type = Array.isArray(value) ? 'array' : 'object';
|
|
7347
|
+
try {
|
|
7348
|
+
return {
|
|
7349
|
+
value: JSON.stringify(value),
|
|
7350
|
+
type: type
|
|
7351
|
+
};
|
|
7352
|
+
} catch (unused) {
|
|
7353
|
+
return {
|
|
7354
|
+
type: type
|
|
7355
|
+
};
|
|
7356
|
+
}
|
|
7357
|
+
}
|
|
7358
|
+
if (t === 'function') {
|
|
7359
|
+
return {
|
|
7360
|
+
value: value.name,
|
|
7361
|
+
type: 'function'
|
|
7362
|
+
};
|
|
7363
|
+
}
|
|
7364
|
+
// symbols, DOM elements: name only
|
|
7365
|
+
return null;
|
|
7366
|
+
}
|
|
7367
|
+
/**
|
|
7368
|
+
* Turns a `widgetParams`-style record into the serialized `WidgetTreeParam[]`
|
|
7369
|
+
* shape used throughout the usage events. Shared between the widget tree and
|
|
7370
|
+
* the root `ais.instantSearch` node so every node reports params identically.
|
|
7371
|
+
*/ function serializeWidgetParams(widgetParams) {
|
|
7372
|
+
var params = [];
|
|
7373
|
+
Object.keys(widgetParams).forEach(function(key) {
|
|
7374
|
+
var raw = widgetParams[key];
|
|
7375
|
+
if (raw === undefined) {
|
|
7376
|
+
return;
|
|
7377
|
+
}
|
|
7378
|
+
var serialized = serializeParamValue(raw);
|
|
7379
|
+
if (serialized) {
|
|
7380
|
+
params.push(_object_spread({
|
|
7381
|
+
name: key
|
|
7382
|
+
}, serialized));
|
|
7383
|
+
} else {
|
|
7384
|
+
params.push({
|
|
7385
|
+
name: key
|
|
7386
|
+
});
|
|
7387
|
+
}
|
|
7388
|
+
});
|
|
7389
|
+
return params;
|
|
7390
|
+
}
|
|
7391
|
+
function buildWidgetTree(widgets, instantSearchInstance) {
|
|
7392
|
+
var parent = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : instantSearchInstance.mainIndex;
|
|
7393
|
+
var initOptions = createInitArgs(instantSearchInstance, parent, instantSearchInstance._initialUiState);
|
|
7394
|
+
return widgets.map(function(widget) {
|
|
7395
|
+
var widgetParams = {};
|
|
7396
|
+
if (widget.getWidgetRenderState) {
|
|
7397
|
+
var renderState = widget.getWidgetRenderState(initOptions);
|
|
7398
|
+
if (renderState && renderState.widgetParams) {
|
|
7399
|
+
widgetParams = renderState.widgetParams;
|
|
7400
|
+
}
|
|
7401
|
+
}
|
|
7402
|
+
var params = serializeWidgetParams(widgetParams);
|
|
7403
|
+
var children = isIndexWidget(widget) ? buildWidgetTree(widget.getWidgets(), instantSearchInstance, widget) : [];
|
|
7404
|
+
return {
|
|
7405
|
+
type: widget.$$widgetType || widget.$$type || 'unknown',
|
|
7406
|
+
params: params,
|
|
7407
|
+
children: children
|
|
7408
|
+
};
|
|
7409
|
+
});
|
|
7410
|
+
}
|
|
7411
|
+
|
|
7412
|
+
function extractWidgetPayload(widgets, instantSearchInstance, payload) {
|
|
7413
|
+
var parent = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : instantSearchInstance.mainIndex;
|
|
7414
|
+
var initOptions = createInitArgs(instantSearchInstance, parent, instantSearchInstance._initialUiState);
|
|
7415
|
+
widgets.forEach(function(widget) {
|
|
7416
|
+
var widgetParams = {};
|
|
7417
|
+
if (widget.getWidgetRenderState) {
|
|
7418
|
+
var renderState = widget.getWidgetRenderState(initOptions);
|
|
7419
|
+
if (renderState && renderState.widgetParams) {
|
|
7420
|
+
// casting, as we just earlier checked widgetParams exists, and thus an object
|
|
7421
|
+
widgetParams = renderState.widgetParams;
|
|
7422
|
+
}
|
|
7423
|
+
}
|
|
7424
|
+
// since we destructure in all widgets, the parameters with defaults are set to "undefined"
|
|
7425
|
+
var params = Object.keys(widgetParams).filter(function(key) {
|
|
7426
|
+
return widgetParams[key] !== undefined;
|
|
7427
|
+
});
|
|
7428
|
+
payload.widgets.push({
|
|
7429
|
+
type: widget.$$type,
|
|
7430
|
+
widgetType: widget.$$widgetType,
|
|
7431
|
+
params: params
|
|
7432
|
+
});
|
|
7433
|
+
if (isIndexWidget(widget)) {
|
|
7434
|
+
extractWidgetPayload(widget.getWidgets(), instantSearchInstance, payload, widget);
|
|
7435
|
+
}
|
|
7436
|
+
});
|
|
7437
|
+
}
|
|
7438
|
+
|
|
7439
|
+
var now = typeof performance !== 'undefined' ? function() {
|
|
7440
|
+
return performance.now();
|
|
7441
|
+
} : function() {
|
|
7442
|
+
return Date.now();
|
|
7443
|
+
};
|
|
7444
|
+
|
|
7445
|
+
function range(param) {
|
|
7446
|
+
var _param_start = param.start, start = _param_start === void 0 ? 0 : _param_start, end = param.end, _param_step = param.step, step = _param_step === void 0 ? 1 : _param_step;
|
|
7447
|
+
// We can't divide by 0 so we re-assign the step to 1 if it happens.
|
|
7448
|
+
var limitStep = step === 0 ? 1 : step;
|
|
7449
|
+
// In some cases the array to create has a decimal length.
|
|
7450
|
+
// We therefore need to round the value.
|
|
7451
|
+
// Example:
|
|
7452
|
+
// { start: 1, end: 5000, step: 500 }
|
|
7453
|
+
// => Array length = (5000 - 1) / 500 = 9.998
|
|
7454
|
+
var arrayLength = Math.round((end - start) / limitStep);
|
|
7455
|
+
return _to_consumable_array(Array(arrayLength)).map(function(_, current) {
|
|
7456
|
+
return start + current * limitStep;
|
|
7457
|
+
});
|
|
7458
|
+
}
|
|
7459
|
+
|
|
7329
7460
|
function resolveSearchParameters(current) {
|
|
7330
7461
|
var parent = current.getParent();
|
|
7331
7462
|
var states = [
|
|
@@ -9061,6 +9192,8 @@
|
|
|
9061
9192
|
});
|
|
9062
9193
|
}
|
|
9063
9194
|
|
|
9195
|
+
var version = '4.105.0';
|
|
9196
|
+
|
|
9064
9197
|
var ANONYMOUS_TOKEN_COOKIE_KEY = '_ALGOLIA';
|
|
9065
9198
|
function getCookie(name) {
|
|
9066
9199
|
if ((typeof document === "undefined" ? "undefined" : _type_of(document)) !== 'object' || typeof document.cookie !== 'string') {
|
|
@@ -9083,8 +9216,61 @@
|
|
|
9083
9216
|
return getCookie(ANONYMOUS_TOKEN_COOKIE_KEY);
|
|
9084
9217
|
}
|
|
9085
9218
|
|
|
9219
|
+
var USAGE_SESSION_KEY = 'ais.usage.sessionId';
|
|
9220
|
+
// Cache the id for the lifetime of the runtime so repeated calls don't hit
|
|
9221
|
+
// `sessionStorage` again, and so we always return the same id even when
|
|
9222
|
+
// storage is unavailable (SSR, privacy mode) and we fall back to a fresh UUID.
|
|
9223
|
+
var usageSessionId = null;
|
|
9224
|
+
function getUsageSessionId() {
|
|
9225
|
+
if (usageSessionId) {
|
|
9226
|
+
return usageSessionId;
|
|
9227
|
+
}
|
|
9228
|
+
try {
|
|
9229
|
+
var existing = sessionStorage.getItem(USAGE_SESSION_KEY);
|
|
9230
|
+
if (existing) {
|
|
9231
|
+
usageSessionId = existing;
|
|
9232
|
+
return usageSessionId;
|
|
9233
|
+
}
|
|
9234
|
+
usageSessionId = createUUID();
|
|
9235
|
+
sessionStorage.setItem(USAGE_SESSION_KEY, usageSessionId);
|
|
9236
|
+
return usageSessionId;
|
|
9237
|
+
} catch (unused) {
|
|
9238
|
+
// sessionStorage unavailable (SSR, privacy mode, etc.)
|
|
9239
|
+
usageSessionId = createUUID();
|
|
9240
|
+
return usageSessionId;
|
|
9241
|
+
}
|
|
9242
|
+
}
|
|
9243
|
+
/** @deprecated use bindEvent instead */ function writeDataAttributes(param) {
|
|
9244
|
+
var method = param.method, payload = param.payload;
|
|
9245
|
+
if ((typeof payload === "undefined" ? "undefined" : _type_of(payload)) !== 'object') {
|
|
9246
|
+
throw new Error("The insights helper expects the payload to be an object.");
|
|
9247
|
+
}
|
|
9248
|
+
var serializedPayload;
|
|
9249
|
+
try {
|
|
9250
|
+
serializedPayload = serializePayload(payload);
|
|
9251
|
+
} catch (error) {
|
|
9252
|
+
throw new Error("Could not JSON serialize the payload object.");
|
|
9253
|
+
}
|
|
9254
|
+
return 'data-insights-method="'.concat(method, '" data-insights-payload="').concat(serializedPayload, '"');
|
|
9255
|
+
}
|
|
9256
|
+
/**
|
|
9257
|
+
* @deprecated This function will be still supported in 4.x releases, but not further. It is replaced by the `insights` middleware. For more information, visit https://www.algolia.com/doc/guides/getting-insights-and-analytics/search-analytics/click-through-and-conversions/how-to/send-click-and-conversion-events-with-instantsearch/js/
|
|
9258
|
+
*/ function insights(method, payload) {
|
|
9259
|
+
return writeDataAttributes({
|
|
9260
|
+
method: method,
|
|
9261
|
+
payload: payload
|
|
9262
|
+
});
|
|
9263
|
+
}
|
|
9264
|
+
|
|
9086
9265
|
var ALGOLIA_INSIGHTS_VERSION = '2.17.2';
|
|
9087
9266
|
var ALGOLIA_INSIGHTS_SRC = "https://cdn.jsdelivr.net/npm/search-insights@".concat(ALGOLIA_INSIGHTS_VERSION, "/dist/search-insights.min.js");
|
|
9267
|
+
// InstantSearch options that must never be sent in usage events because
|
|
9268
|
+
// they carry credentials or end-user data. Everything else is reported as-is.
|
|
9269
|
+
var SENSITIVE_OPTIONS = [
|
|
9270
|
+
'searchClient',
|
|
9271
|
+
'insightsClient',
|
|
9272
|
+
'initialUiState'
|
|
9273
|
+
];
|
|
9088
9274
|
function createInsightsMiddleware() {
|
|
9089
9275
|
var props = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
9090
9276
|
var _insightsClient = props.insightsClient, insightsInitParams = props.insightsInitParams, onEvent = props.onEvent, _props_$$internal = props.$$internal, $$internal = _props_$$internal === void 0 ? false : _props_$$internal, _props_$$automatic = props.$$automatic, $$automatic = _props_$$automatic === void 0 ? false : _props_$$automatic;
|
|
@@ -9174,6 +9360,7 @@
|
|
|
9174
9360
|
}
|
|
9175
9361
|
var initialParameters;
|
|
9176
9362
|
var helper;
|
|
9363
|
+
var removeStartEventListener = null;
|
|
9177
9364
|
return {
|
|
9178
9365
|
$$type: 'ais.insights',
|
|
9179
9366
|
$$internal: $$internal,
|
|
@@ -9348,8 +9535,65 @@
|
|
|
9348
9535
|
insightsClientWithLocalCredentials(event.insightsMethod, event.payload);
|
|
9349
9536
|
} else ;
|
|
9350
9537
|
};
|
|
9538
|
+
// usage tracking (browser-only)
|
|
9539
|
+
safelyRunOnBrowser(function() {
|
|
9540
|
+
var usageSessionId = getUsageSessionId();
|
|
9541
|
+
function sendUsageEvent(event) {
|
|
9542
|
+
var _helper_state;
|
|
9543
|
+
var userToken = (_helper_state = helper.state) === null || _helper_state === void 0 ? void 0 : _helper_state.userToken;
|
|
9544
|
+
insightsClientWithLocalCredentials('sendEvents', [
|
|
9545
|
+
_object_spread({
|
|
9546
|
+
eventType: 'instantsearch',
|
|
9547
|
+
timestamp: Date.now(),
|
|
9548
|
+
sessionID: usageSessionId,
|
|
9549
|
+
userToken: userToken ? String(userToken) : undefined
|
|
9550
|
+
}, event)
|
|
9551
|
+
]);
|
|
9552
|
+
}
|
|
9553
|
+
// Send the start event on the first `render`, by which point every
|
|
9554
|
+
// flavor has registered its widgets. `bootstrapMs` then measures the
|
|
9555
|
+
// time between the constructor running and that point, so for flavors
|
|
9556
|
+
// that register widgets right at start (e.g. React) it captures the
|
|
9557
|
+
// cost of adding them.
|
|
9558
|
+
var sendStartEvent = function sendStartEvent() {
|
|
9559
|
+
try {
|
|
9560
|
+
var bootstrapMs = Math.round(now() - instantSearchInstance._createdAt);
|
|
9561
|
+
sendUsageEvent({
|
|
9562
|
+
eventName: '__start__',
|
|
9563
|
+
algoliaAgent: getAlgoliaAgent(instantSearchInstance.client),
|
|
9564
|
+
version: version,
|
|
9565
|
+
applicationId: appId,
|
|
9566
|
+
performance: {
|
|
9567
|
+
bootstrapMs: bootstrapMs
|
|
9568
|
+
},
|
|
9569
|
+
widgets: [
|
|
9570
|
+
{
|
|
9571
|
+
type: 'ais.instantSearch',
|
|
9572
|
+
// The options the instance was created with, serialized the
|
|
9573
|
+
// same way every widget's params are. Derived dynamically from
|
|
9574
|
+
// `_initialOptions` so new options are reported automatically,
|
|
9575
|
+
// minus the keys that carry credentials or user data. Functions
|
|
9576
|
+
// (`onStateChange`, `searchFunction`) report their `fn.name`
|
|
9577
|
+
// when present, tagged `type: 'function'`.
|
|
9578
|
+
params: instantSearchInstance._initialOptions ? serializeWidgetParams(omit(instantSearchInstance._initialOptions, _to_consumable_array(SENSITIVE_OPTIONS))) : [],
|
|
9579
|
+
children: buildWidgetTree(instantSearchInstance.mainIndex.getWidgets(), instantSearchInstance)
|
|
9580
|
+
}
|
|
9581
|
+
]
|
|
9582
|
+
});
|
|
9583
|
+
} catch (unused) {
|
|
9584
|
+
// usage tracking must never crash the host app
|
|
9585
|
+
}
|
|
9586
|
+
};
|
|
9587
|
+
instantSearchInstance.once('render', sendStartEvent);
|
|
9588
|
+
removeStartEventListener = function removeStartEventListener() {
|
|
9589
|
+
return instantSearchInstance.removeListener('render', sendStartEvent);
|
|
9590
|
+
};
|
|
9591
|
+
});
|
|
9351
9592
|
},
|
|
9352
9593
|
unsubscribe: function unsubscribe() {
|
|
9594
|
+
if (removeStartEventListener) {
|
|
9595
|
+
removeStartEventListener();
|
|
9596
|
+
}
|
|
9353
9597
|
insightsClient('onUserTokenChange', undefined);
|
|
9354
9598
|
instantSearchInstance.sendEventToInsights = noop;
|
|
9355
9599
|
if (helper && initialParameters) {
|
|
@@ -9397,31 +9641,6 @@
|
|
|
9397
9641
|
return typeof userToken === 'number' ? userToken.toString() : userToken;
|
|
9398
9642
|
}
|
|
9399
9643
|
|
|
9400
|
-
function extractWidgetPayload(widgets, instantSearchInstance, payload) {
|
|
9401
|
-
var initOptions = createInitArgs(instantSearchInstance, instantSearchInstance.mainIndex, instantSearchInstance._initialUiState);
|
|
9402
|
-
widgets.forEach(function(widget) {
|
|
9403
|
-
var widgetParams = {};
|
|
9404
|
-
if (widget.getWidgetRenderState) {
|
|
9405
|
-
var renderState = widget.getWidgetRenderState(initOptions);
|
|
9406
|
-
if (renderState && renderState.widgetParams) {
|
|
9407
|
-
// casting, as we just earlier checked widgetParams exists, and thus an object
|
|
9408
|
-
widgetParams = renderState.widgetParams;
|
|
9409
|
-
}
|
|
9410
|
-
}
|
|
9411
|
-
// since we destructure in all widgets, the parameters with defaults are set to "undefined"
|
|
9412
|
-
var params = Object.keys(widgetParams).filter(function(key) {
|
|
9413
|
-
return widgetParams[key] !== undefined;
|
|
9414
|
-
});
|
|
9415
|
-
payload.widgets.push({
|
|
9416
|
-
type: widget.$$type,
|
|
9417
|
-
widgetType: widget.$$widgetType,
|
|
9418
|
-
params: params
|
|
9419
|
-
});
|
|
9420
|
-
if (isIndexWidget(widget)) {
|
|
9421
|
-
extractWidgetPayload(widget.getWidgets(), instantSearchInstance, payload);
|
|
9422
|
-
}
|
|
9423
|
-
});
|
|
9424
|
-
}
|
|
9425
9644
|
function isMetadataEnabled() {
|
|
9426
9645
|
return safelyRunOnBrowser(function(param) {
|
|
9427
9646
|
var window = param.window;
|
|
@@ -10770,28 +10989,6 @@
|
|
|
10770
10989
|
return reverseHighlightedValue.replace(new RegExp(TAG_REPLACEMENT.highlightPreTag, 'g'), "<".concat(highlightedTagName, ' class="').concat(className, '">')).replace(new RegExp(TAG_REPLACEMENT.highlightPostTag, 'g'), "</".concat(highlightedTagName, ">"));
|
|
10771
10990
|
}
|
|
10772
10991
|
|
|
10773
|
-
/** @deprecated use bindEvent instead */ function writeDataAttributes(param) {
|
|
10774
|
-
var method = param.method, payload = param.payload;
|
|
10775
|
-
if ((typeof payload === "undefined" ? "undefined" : _type_of(payload)) !== 'object') {
|
|
10776
|
-
throw new Error("The insights helper expects the payload to be an object.");
|
|
10777
|
-
}
|
|
10778
|
-
var serializedPayload;
|
|
10779
|
-
try {
|
|
10780
|
-
serializedPayload = serializePayload(payload);
|
|
10781
|
-
} catch (error) {
|
|
10782
|
-
throw new Error("Could not JSON serialize the payload object.");
|
|
10783
|
-
}
|
|
10784
|
-
return 'data-insights-method="'.concat(method, '" data-insights-payload="').concat(serializedPayload, '"');
|
|
10785
|
-
}
|
|
10786
|
-
/**
|
|
10787
|
-
* @deprecated This function will be still supported in 4.x releases, but not further. It is replaced by the `insights` middleware. For more information, visit https://www.algolia.com/doc/guides/getting-insights-and-analytics/search-analytics/click-through-and-conversions/how-to/send-click-and-conversion-events-with-instantsearch/js/
|
|
10788
|
-
*/ function insights(method, payload) {
|
|
10789
|
-
return writeDataAttributes({
|
|
10790
|
-
method: method,
|
|
10791
|
-
payload: payload
|
|
10792
|
-
});
|
|
10793
|
-
}
|
|
10794
|
-
|
|
10795
10992
|
function hoganHelpers(param) {
|
|
10796
10993
|
var numberLocale = param.numberLocale;
|
|
10797
10994
|
return {
|
|
@@ -10853,8 +11050,6 @@
|
|
|
10853
11050
|
};
|
|
10854
11051
|
}
|
|
10855
11052
|
|
|
10856
|
-
var version = '4.103.0';
|
|
10857
|
-
|
|
10858
11053
|
var withUsage$r = createDocumentationMessageGenerator({
|
|
10859
11054
|
name: 'instantsearch'
|
|
10860
11055
|
});
|
|
@@ -10874,7 +11069,14 @@
|
|
|
10874
11069
|
function InstantSearch(options) {
|
|
10875
11070
|
_class_call_check(this, InstantSearch);
|
|
10876
11071
|
var _this;
|
|
10877
|
-
_this = _call_super(this, InstantSearch), _define_property(_this, "client", void 0), _define_property(_this, "indexName", void 0), _define_property(_this, "compositionID", void 0), _define_property(_this, "insightsClient", void 0), _define_property(_this, "onStateChange", null), _define_property(_this, "future", void 0), _define_property(_this, "helper", void 0), _define_property(_this, "mainHelper", void 0), _define_property(_this, "mainIndex", void 0), _define_property(_this, "started", void 0), _define_property(_this, "templatesConfig", void 0), _define_property(_this, "renderState", {}), _define_property(_this, "_stalledSearchDelay", void 0), _define_property(_this, "_searchStalledTimer", void 0), _define_property(_this, "_initialUiState", void 0), _define_property(_this, "_initialResults", void 0), _define_property(_this, "_manuallyResetScheduleSearch", false), _define_property(_this, "_resetScheduleSearch", void 0), _define_property(_this, "_createURL", void 0), _define_property(_this, "_searchFunction", void 0), _define_property(_this, "_mainHelperSearch", void 0), _define_property(_this, "_hasSearchWidget", false), _define_property(_this, "_hasRecommendWidget", false), _define_property(_this, "_insights", void 0),
|
|
11072
|
+
_this = _call_super(this, InstantSearch), _define_property(_this, "client", void 0), _define_property(_this, "indexName", void 0), _define_property(_this, "compositionID", void 0), _define_property(_this, "insightsClient", void 0), _define_property(_this, "onStateChange", null), _define_property(_this, "future", void 0), _define_property(_this, "helper", void 0), _define_property(_this, "mainHelper", void 0), _define_property(_this, "mainIndex", void 0), _define_property(_this, "started", void 0), _define_property(_this, "templatesConfig", void 0), _define_property(_this, "renderState", {}), _define_property(_this, "_stalledSearchDelay", void 0), _define_property(_this, "_searchStalledTimer", void 0), _define_property(_this, "_initialUiState", void 0), _define_property(_this, "_initialResults", void 0), _define_property(_this, "_manuallyResetScheduleSearch", false), _define_property(_this, "_resetScheduleSearch", void 0), _define_property(_this, "_createURL", void 0), _define_property(_this, "_searchFunction", void 0), _define_property(_this, "_mainHelperSearch", void 0), _define_property(_this, "_hasSearchWidget", false), _define_property(_this, "_hasRecommendWidget", false), _define_property(_this, "_insights", void 0), /**
|
|
11073
|
+
* The options the instance was created with, kept verbatim so consumers
|
|
11074
|
+
* (e.g. usage events) can introspect the configuration without the class
|
|
11075
|
+
* having to enumerate every option by hand. Typed without the class generics
|
|
11076
|
+
* on purpose: referencing `TUiState`/`TRouteState` here (they sit in
|
|
11077
|
+
* contravariant positions inside `InstantSearchOptions`) would break the
|
|
11078
|
+
* assignability of `InstantSearch<SpecificUiState>` to `InstantSearch`.
|
|
11079
|
+
*/ _define_property(_this, "_initialOptions", void 0), _define_property(_this, "middleware", []), _define_property(_this, "sendEventToInsights", void 0), _define_property(_this, "_createdAt", now()), /**
|
|
10878
11080
|
* The status of the search. Can be "idle", "loading", "stalled", or "error".
|
|
10879
11081
|
*/ _define_property(_this, "status", 'idle'), /**
|
|
10880
11082
|
* The last returned error from the Search API.
|
|
@@ -10922,6 +11124,7 @@
|
|
|
10922
11124
|
if (insightsClient && typeof insightsClient !== 'function') {
|
|
10923
11125
|
throw new Error(withUsage$r('The `insightsClient` option should be a function.'));
|
|
10924
11126
|
}
|
|
11127
|
+
_this._initialOptions = options;
|
|
10925
11128
|
_this.client = searchClient;
|
|
10926
11129
|
_this.future = future;
|
|
10927
11130
|
_this.insightsClient = insightsClient;
|
|
@@ -11294,6 +11497,9 @@
|
|
|
11294
11497
|
var instance = param.instance;
|
|
11295
11498
|
instance.unsubscribe();
|
|
11296
11499
|
});
|
|
11500
|
+
// Cleared after unsubscribe so in-flight readers (e.g. the insights
|
|
11501
|
+
// start-event listener) have detached before the reference goes away.
|
|
11502
|
+
this._initialOptions = null;
|
|
11297
11503
|
}
|
|
11298
11504
|
},
|
|
11299
11505
|
{
|
|
@@ -13930,12 +14136,10 @@
|
|
|
13930
14136
|
var _chatInstance;
|
|
13931
14137
|
var input = '';
|
|
13932
14138
|
var open = false;
|
|
13933
|
-
var isClearing = false;
|
|
13934
14139
|
var sendEvent;
|
|
13935
14140
|
var setInput;
|
|
13936
14141
|
var setOpen;
|
|
13937
14142
|
var focusInput;
|
|
13938
|
-
var setIsClearing;
|
|
13939
14143
|
var setFeedbackState;
|
|
13940
14144
|
var hasValidatedEntryPoints = false;
|
|
13941
14145
|
var agentId = 'agentId' in options ? options.agentId : undefined;
|
|
@@ -13965,21 +14169,17 @@
|
|
|
13965
14169
|
_chatInstance.messages = messagesParam;
|
|
13966
14170
|
};
|
|
13967
14171
|
var clearMessages = function clearMessages() {
|
|
13968
|
-
if (!_chatInstance.messages || _chatInstance.messages.length === 0) {
|
|
13969
|
-
return;
|
|
13970
|
-
}
|
|
13971
14172
|
var status = _chatInstance.status;
|
|
13972
14173
|
if (status === 'submitted' || status === 'streaming') {
|
|
13973
14174
|
_chatInstance.stop();
|
|
13974
14175
|
}
|
|
13975
|
-
|
|
13976
|
-
|
|
13977
|
-
|
|
14176
|
+
// Reset the non-reactive state first: `setMessages` and `clearError` emit
|
|
14177
|
+
// ChatState callbacks that synchronously re-render, so they must run last
|
|
14178
|
+
// for that render to see the cleared feedback and rotated conversation id.
|
|
14179
|
+
feedbackState = {};
|
|
14180
|
+
_chatInstance.resetConversationId();
|
|
13978
14181
|
setMessages([]);
|
|
13979
14182
|
_chatInstance.clearError();
|
|
13980
|
-
_chatInstance.resetConversationId();
|
|
13981
|
-
feedbackState = {};
|
|
13982
|
-
setIsClearing(false);
|
|
13983
14183
|
};
|
|
13984
14184
|
var validateEntryPoints = function validateEntryPoints(instantSearchInstance) {
|
|
13985
14185
|
if (disableTriggerValidation || hasValidatedEntryPoints) {
|
|
@@ -14045,22 +14245,37 @@
|
|
|
14045
14245
|
}));
|
|
14046
14246
|
}
|
|
14047
14247
|
if ('agentId' in options && options.agentId) {
|
|
14248
|
+
var _options_requestOptions, _options_requestOptions1;
|
|
14048
14249
|
if (!appId || !apiKey) {
|
|
14049
14250
|
throw new Error(withUsage$o('Could not extract Algolia credentials from the search client.'));
|
|
14050
14251
|
}
|
|
14051
|
-
var
|
|
14252
|
+
var createApi = function createApi() {
|
|
14253
|
+
var bypassCache = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : false;
|
|
14254
|
+
var _options_requestOptions;
|
|
14255
|
+
var api = new URL("https://".concat(appId, ".algolia.net/agent-studio/1/agents/").concat(agentId, "/completions"));
|
|
14256
|
+
var queryParameters = _object_spread(_object_spread_props(_object_spread({}, (_options_requestOptions = options.requestOptions) === null || _options_requestOptions === void 0 ? void 0 : _options_requestOptions.queryParameters), {
|
|
14257
|
+
compatibilityMode: 'ai-sdk-5'
|
|
14258
|
+
}), bypassCache ? {
|
|
14259
|
+
cache: false
|
|
14260
|
+
} : {});
|
|
14261
|
+
api.search = new URLSearchParams(queryParameters).toString();
|
|
14262
|
+
return api.toString();
|
|
14263
|
+
};
|
|
14264
|
+
var baseApi = createApi();
|
|
14052
14265
|
transport = new DefaultChatTransport({
|
|
14053
14266
|
api: baseApi,
|
|
14054
|
-
headers: {
|
|
14267
|
+
headers: _object_spread_props(_object_spread({}, _instanceof((_options_requestOptions = options.requestOptions) === null || _options_requestOptions === void 0 ? void 0 : _options_requestOptions.headers, Headers) ? Object.fromEntries(options.requestOptions.headers.entries()) : (_options_requestOptions1 = options.requestOptions) === null || _options_requestOptions1 === void 0 ? void 0 : _options_requestOptions1.headers), {
|
|
14268
|
+
// Preserve the required Algolia identity headers and chat agent
|
|
14269
|
+
// marker, even when requestOptions.headers contains the same keys.
|
|
14055
14270
|
'x-algolia-application-id': appId,
|
|
14056
14271
|
'x-algolia-api-key': apiKey,
|
|
14057
14272
|
'x-algolia-agent': "".concat(getAlgoliaAgent(client), "; chat")
|
|
14058
|
-
},
|
|
14273
|
+
}),
|
|
14059
14274
|
prepareSendMessagesRequest: function prepareSendMessagesRequest(param) {
|
|
14060
14275
|
var id = param.id, messages = param.messages, trigger = param.trigger, messageId = param.messageId;
|
|
14061
14276
|
return {
|
|
14062
14277
|
// Bypass cache when regenerating to ensure fresh responses
|
|
14063
|
-
api: trigger === 'regenerate-message' ?
|
|
14278
|
+
api: trigger === 'regenerate-message' ? createApi(true) : baseApi,
|
|
14064
14279
|
body: {
|
|
14065
14280
|
id: id,
|
|
14066
14281
|
messageId: messageId,
|
|
@@ -14145,10 +14360,6 @@
|
|
|
14145
14360
|
input = i;
|
|
14146
14361
|
render();
|
|
14147
14362
|
};
|
|
14148
|
-
setIsClearing = function setIsClearing(value) {
|
|
14149
|
-
isClearing = value;
|
|
14150
|
-
render();
|
|
14151
|
-
};
|
|
14152
14363
|
setFeedbackState = function setFeedbackState(messageId, state) {
|
|
14153
14364
|
feedbackState = _object_spread_props(_object_spread({}, feedbackState), _define_property({}, messageId, state));
|
|
14154
14365
|
render();
|
|
@@ -14267,9 +14478,7 @@
|
|
|
14267
14478
|
focusInput: focusInput,
|
|
14268
14479
|
setMessages: setMessages,
|
|
14269
14480
|
suggestions: getSuggestionsFromMessages(_chatInstance.messages),
|
|
14270
|
-
isClearing: isClearing,
|
|
14271
14481
|
clearMessages: clearMessages,
|
|
14272
|
-
onClearTransitionEnd: onClearTransitionEnd,
|
|
14273
14482
|
tools: toolsWithAddToolResult,
|
|
14274
14483
|
sendChatMessageFeedback: _sendChatMessageFeedback,
|
|
14275
14484
|
feedbackState: feedbackState,
|