@algolia/autocomplete-core 1.13.0 → 1.15.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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @algolia/autocomplete-core 1.
|
|
1
|
+
/*! @algolia/autocomplete-core 1.15.0 | MIT License | © Algolia, Inc. and contributors | https://github.com/algolia/autocomplete */
|
|
2
2
|
(function (global, factory) {
|
|
3
3
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
|
4
4
|
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
|
@@ -291,7 +291,7 @@
|
|
|
291
291
|
return undefined;
|
|
292
292
|
}
|
|
293
293
|
|
|
294
|
-
var version = '1.
|
|
294
|
+
var version = '1.15.0';
|
|
295
295
|
|
|
296
296
|
var userAgents = [{
|
|
297
297
|
segment: 'autocomplete-core',
|
|
@@ -564,6 +564,15 @@
|
|
|
564
564
|
apiKey: apiKey
|
|
565
565
|
});
|
|
566
566
|
},
|
|
567
|
+
/**
|
|
568
|
+
* Sets the authenticated user token to attach to events.
|
|
569
|
+
* Unsets the authenticated token by passing `undefined`.
|
|
570
|
+
*
|
|
571
|
+
* @link https://www.algolia.com/doc/api-reference/api-methods/set-authenticated-user-token/
|
|
572
|
+
*/
|
|
573
|
+
setAuthenticatedUserToken: function setAuthenticatedUserToken(authenticatedUserToken) {
|
|
574
|
+
searchInsights('setAuthenticatedUserToken', authenticatedUserToken);
|
|
575
|
+
},
|
|
567
576
|
/**
|
|
568
577
|
* Sets the user token to attach to events.
|
|
569
578
|
*/
|
|
@@ -822,6 +831,7 @@
|
|
|
822
831
|
function createAlgoliaInsightsPlugin(options) {
|
|
823
832
|
var _getOptions = getOptions(options),
|
|
824
833
|
providedInsightsClient = _getOptions.insightsClient,
|
|
834
|
+
insightsInitParams = _getOptions.insightsInitParams,
|
|
825
835
|
onItemsChange = _getOptions.onItemsChange,
|
|
826
836
|
onSelectEvent = _getOptions.onSelect,
|
|
827
837
|
onActiveEvent = _getOptions.onActive,
|
|
@@ -859,6 +869,11 @@
|
|
|
859
869
|
if (!insightsClient) {
|
|
860
870
|
return {};
|
|
861
871
|
}
|
|
872
|
+
if (insightsInitParams) {
|
|
873
|
+
insightsClient('init', _objectSpread({
|
|
874
|
+
partial: true
|
|
875
|
+
}, insightsInitParams));
|
|
876
|
+
}
|
|
862
877
|
var insights = createSearchInsightsApi(insightsClient);
|
|
863
878
|
var previousItems = createRef([]);
|
|
864
879
|
var debouncedOnStateChange = debounce(function (_ref3) {
|
|
@@ -905,10 +920,28 @@
|
|
|
905
920
|
}
|
|
906
921
|
insightsClient('addAlgoliaAgent', 'insights-plugin');
|
|
907
922
|
setInsightsContext();
|
|
923
|
+
|
|
924
|
+
// Handles user token changes
|
|
908
925
|
insightsClient('onUserTokenChange', setInsightsContext);
|
|
909
926
|
insightsClient('getUserToken', null, function (_error, userToken) {
|
|
910
927
|
setInsightsContext(userToken);
|
|
911
928
|
});
|
|
929
|
+
|
|
930
|
+
// Handles authenticated user token changes
|
|
931
|
+
insightsClient('onAuthenticatedUserTokenChange', function (authenticatedUserToken) {
|
|
932
|
+
if (authenticatedUserToken) {
|
|
933
|
+
setInsightsContext(authenticatedUserToken);
|
|
934
|
+
} else {
|
|
935
|
+
insightsClient('getUserToken', null, function (_error, userToken) {
|
|
936
|
+
return setInsightsContext(userToken);
|
|
937
|
+
});
|
|
938
|
+
}
|
|
939
|
+
});
|
|
940
|
+
insightsClient('getAuthenticatedUserToken', null, function (_error, authenticatedUserToken) {
|
|
941
|
+
if (authenticatedUserToken) {
|
|
942
|
+
setInsightsContext(authenticatedUserToken);
|
|
943
|
+
}
|
|
944
|
+
});
|
|
912
945
|
onSelect(function (_ref5) {
|
|
913
946
|
var item = _ref5.item,
|
|
914
947
|
state = _ref5.state,
|