@algolia/autocomplete-preset-algolia
Advanced tools
Comparing version 1.0.0-alpha.35 to 1.0.0-alpha.36
@@ -1,3 +0,1 @@ | ||
export * from './search/getAlgoliaHits'; | ||
export * from './search/getAlgoliaResults'; | ||
export * from './highlight/parseAlgoliaHitHighlight'; | ||
@@ -7,1 +5,3 @@ export * from './highlight/parseAlgoliaHitReverseHighlight'; | ||
export * from './highlight/parseAlgoliaHitSnippet'; | ||
export * from './search/getAlgoliaHits'; | ||
export * from './search/getAlgoliaResults'; |
@@ -1,6 +0,6 @@ | ||
export * from './search/getAlgoliaHits'; | ||
export * from './search/getAlgoliaResults'; | ||
export * from './highlight/parseAlgoliaHitHighlight'; | ||
export * from './highlight/parseAlgoliaHitReverseHighlight'; | ||
export * from './highlight/parseAlgoliaHitReverseSnippet'; | ||
export * from './highlight/parseAlgoliaHitSnippet'; | ||
export * from './highlight/parseAlgoliaHitSnippet'; | ||
export * from './search/getAlgoliaHits'; | ||
export * from './search/getAlgoliaResults'; |
@@ -0,1 +1,7 @@ | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
import { search } from './search'; | ||
@@ -11,5 +17,10 @@ export function getAlgoliaHits(_ref) { | ||
return results.map(function (result) { | ||
return result.hits; | ||
return result.hits.map(function (hit) { | ||
return _objectSpread(_objectSpread({}, hit), {}, { | ||
__autocomplete_indexName: result.index, | ||
__autocomplete_queryID: result.queryID | ||
}); | ||
}); | ||
}); | ||
}); | ||
} |
@@ -1,1 +0,1 @@ | ||
export declare const version = "1.0.0-alpha.35"; | ||
export declare const version = "1.0.0-alpha.36"; |
@@ -1,1 +0,1 @@ | ||
export var version = '1.0.0-alpha.35'; | ||
export var version = '1.0.0-alpha.36'; |
@@ -1,111 +0,8 @@ | ||
/*! @algolia/autocomplete-preset-algolia 1.0.0-alpha.35 | MIT License | © Algolia, Inc. and contributors | https://github.com/algolia/autocomplete.js */ | ||
/*! @algolia/autocomplete-preset-algolia 1.0.0-alpha.36 | MIT License | © Algolia, Inc. and contributors | https://github.com/algolia/autocomplete.js */ | ||
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : | ||
typeof define === 'function' && define.amd ? define(['exports'], factory) : | ||
(global = global || self, factory(global['@algolia/autocomplete-preset-algolia'] = {})); | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global['@algolia/autocomplete-preset-algolia'] = {})); | ||
}(this, (function (exports) { 'use strict'; | ||
function _defineProperty(obj, key, value) { | ||
if (key in obj) { | ||
Object.defineProperty(obj, key, { | ||
value: value, | ||
enumerable: true, | ||
configurable: true, | ||
writable: true | ||
}); | ||
} else { | ||
obj[key] = value; | ||
} | ||
return obj; | ||
} | ||
function ownKeys(object, enumerableOnly) { | ||
var keys = Object.keys(object); | ||
if (Object.getOwnPropertySymbols) { | ||
var symbols = Object.getOwnPropertySymbols(object); | ||
if (enumerableOnly) symbols = symbols.filter(function (sym) { | ||
return Object.getOwnPropertyDescriptor(object, sym).enumerable; | ||
}); | ||
keys.push.apply(keys, symbols); | ||
} | ||
return keys; | ||
} | ||
function _objectSpread2(target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i] != null ? arguments[i] : {}; | ||
if (i % 2) { | ||
ownKeys(Object(source), true).forEach(function (key) { | ||
_defineProperty(target, key, source[key]); | ||
}); | ||
} else if (Object.getOwnPropertyDescriptors) { | ||
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); | ||
} else { | ||
ownKeys(Object(source)).forEach(function (key) { | ||
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); | ||
}); | ||
} | ||
} | ||
return target; | ||
} | ||
var HIGHLIGHT_PRE_TAG = '__aa-highlight__'; | ||
var HIGHLIGHT_POST_TAG = '__/aa-highlight__'; | ||
var version = '1.0.0-alpha.35'; | ||
function search(_ref) { | ||
var searchClient = _ref.searchClient, | ||
queries = _ref.queries; | ||
if (typeof searchClient.addAlgoliaAgent === 'function') { | ||
searchClient.addAlgoliaAgent('autocomplete-core', version); | ||
} | ||
return searchClient.search(queries.map(function (searchParameters) { | ||
var indexName = searchParameters.indexName, | ||
query = searchParameters.query, | ||
params = searchParameters.params; | ||
return { | ||
indexName: indexName, | ||
query: query, | ||
params: _objectSpread2({ | ||
hitsPerPage: 5, | ||
highlightPreTag: HIGHLIGHT_PRE_TAG, | ||
highlightPostTag: HIGHLIGHT_POST_TAG | ||
}, params) | ||
}; | ||
})); | ||
} | ||
function getAlgoliaHits(_ref) { | ||
var searchClient = _ref.searchClient, | ||
queries = _ref.queries; | ||
return search({ | ||
searchClient: searchClient, | ||
queries: queries | ||
}).then(function (response) { | ||
var results = response.results; | ||
return results.map(function (result) { | ||
return result.hits; | ||
}); | ||
}); | ||
} | ||
function getAlgoliaResults(_ref) { | ||
var searchClient = _ref.searchClient, | ||
queries = _ref.queries; | ||
return search({ | ||
searchClient: searchClient, | ||
queries: queries | ||
}).then(function (response) { | ||
return response.results; | ||
}); | ||
} | ||
var warnCache = { | ||
@@ -143,2 +40,5 @@ current: {} | ||
var HIGHLIGHT_PRE_TAG = '__aa-highlight__'; | ||
var HIGHLIGHT_POST_TAG = '__/aa-highlight__'; | ||
var htmlEscapes = { | ||
@@ -207,2 +107,51 @@ '&': '&', | ||
function _defineProperty(obj, key, value) { | ||
if (key in obj) { | ||
Object.defineProperty(obj, key, { | ||
value: value, | ||
enumerable: true, | ||
configurable: true, | ||
writable: true | ||
}); | ||
} else { | ||
obj[key] = value; | ||
} | ||
return obj; | ||
} | ||
function ownKeys(object, enumerableOnly) { | ||
var keys = Object.keys(object); | ||
if (Object.getOwnPropertySymbols) { | ||
var symbols = Object.getOwnPropertySymbols(object); | ||
if (enumerableOnly) symbols = symbols.filter(function (sym) { | ||
return Object.getOwnPropertyDescriptor(object, sym).enumerable; | ||
}); | ||
keys.push.apply(keys, symbols); | ||
} | ||
return keys; | ||
} | ||
function _objectSpread2(target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i] != null ? arguments[i] : {}; | ||
if (i % 2) { | ||
ownKeys(Object(source), true).forEach(function (key) { | ||
_defineProperty(target, key, source[key]); | ||
}); | ||
} else if (Object.getOwnPropertyDescriptors) { | ||
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); | ||
} else { | ||
ownKeys(Object(source)).forEach(function (key) { | ||
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); | ||
}); | ||
} | ||
} | ||
return target; | ||
} | ||
function reverseHighlightedParts(parts) { | ||
@@ -253,2 +202,58 @@ // We don't want to highlight the whole word when no parts match. | ||
var version = '1.0.0-alpha.36'; | ||
function search(_ref) { | ||
var searchClient = _ref.searchClient, | ||
queries = _ref.queries; | ||
if (typeof searchClient.addAlgoliaAgent === 'function') { | ||
searchClient.addAlgoliaAgent('autocomplete-core', version); | ||
} | ||
return searchClient.search(queries.map(function (searchParameters) { | ||
var indexName = searchParameters.indexName, | ||
query = searchParameters.query, | ||
params = searchParameters.params; | ||
return { | ||
indexName: indexName, | ||
query: query, | ||
params: _objectSpread2({ | ||
hitsPerPage: 5, | ||
highlightPreTag: HIGHLIGHT_PRE_TAG, | ||
highlightPostTag: HIGHLIGHT_POST_TAG | ||
}, params) | ||
}; | ||
})); | ||
} | ||
function getAlgoliaHits(_ref) { | ||
var searchClient = _ref.searchClient, | ||
queries = _ref.queries; | ||
return search({ | ||
searchClient: searchClient, | ||
queries: queries | ||
}).then(function (response) { | ||
var results = response.results; | ||
return results.map(function (result) { | ||
return result.hits.map(function (hit) { | ||
return _objectSpread2(_objectSpread2({}, hit), {}, { | ||
__autocomplete_indexName: result.index, | ||
__autocomplete_queryID: result.queryID | ||
}); | ||
}); | ||
}); | ||
}); | ||
} | ||
function getAlgoliaResults(_ref) { | ||
var searchClient = _ref.searchClient, | ||
queries = _ref.queries; | ||
return search({ | ||
searchClient: searchClient, | ||
queries: queries | ||
}).then(function (response) { | ||
return response.results; | ||
}); | ||
} | ||
exports.getAlgoliaHits = getAlgoliaHits; | ||
@@ -255,0 +260,0 @@ exports.getAlgoliaResults = getAlgoliaResults; |
@@ -1,3 +0,3 @@ | ||
/*! @algolia/autocomplete-preset-algolia 1.0.0-alpha.35 | MIT License | © Algolia, Inc. and contributors | https://github.com/algolia/autocomplete.js */ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self)["@algolia/autocomplete-preset-algolia"]={})}(this,(function(e){"use strict";function t(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function i(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,r)}return i}function r(e){for(var r=1;r<arguments.length;r++){var n=null!=arguments[r]?arguments[r]:{};r%2?i(Object(n),!0).forEach((function(i){t(e,i,n[i])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):i(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function n(e){var t=e.searchClient,i=e.queries;return"function"==typeof t.addAlgoliaAgent&&t.addAlgoliaAgent("autocomplete-core","1.0.0-alpha.35"),t.search(i.map((function(e){return{indexName:e.indexName,query:e.query,params:r({hitsPerPage:5,highlightPreTag:"__aa-highlight__",highlightPostTag:"__/aa-highlight__"},e.params)}})))}function u(e,t){return t.split(".").reduce((function(e,t){return e&&e[t]}),e)}var o={"&":"&","<":"<",">":">",'"':""","'":"'"};function a(e){var t=e.highlightedValue,i=e.ignoreEscape,r=void 0===i?[]:i,n=new RegExp("[".concat(Object.keys(o).filter((function(e){return-1===r.indexOf(e)})).join(""),"]"),"g"),u=RegExp(n.source);function a(e){return u.test(e)?e.replace(n,(function(e){return o[e]})):e}var l=t.split("__aa-highlight__"),c=l.shift(),s=c?[{value:a(c),isHighlighted:!1}]:[];return l.forEach((function(e){var t=e.split("__/aa-highlight__");s.push({value:a(t[0]),isHighlighted:!0}),""!==t[1]&&s.push({value:a(t[1]),isHighlighted:!1})})),s}function l(e){var t=e.hit,i=e.attribute,r=e.ignoreEscape,n="_highlightResult.".concat(i,".value"),o=u(t,n);return"string"!=typeof o&&(o=u(t,i)||""),a({highlightedValue:o,ignoreEscape:r})}function c(e){return e.some((function(e){return e.isHighlighted}))?e.map((function(e){return r(r({},e),{},{isHighlighted:!e.isHighlighted})})):e.map((function(e){return r(r({},e),{},{isHighlighted:!1})}))}function s(e){var t=e.hit,i=e.attribute,r=e.ignoreEscape,n="_snippetResult.".concat(i,".value"),o=u(t,n);return"string"!=typeof o&&(o=u(t,i)||""),a({highlightedValue:o,ignoreEscape:r})}e.getAlgoliaHits=function(e){return n({searchClient:e.searchClient,queries:e.queries}).then((function(e){return e.results.map((function(e){return e.hits}))}))},e.getAlgoliaResults=function(e){return n({searchClient:e.searchClient,queries:e.queries}).then((function(e){return e.results}))},e.parseAlgoliaHitHighlight=l,e.parseAlgoliaHitReverseHighlight=function(e){return c(l(e))},e.parseAlgoliaHitReverseSnippet=function(e){return c(s(e))},e.parseAlgoliaHitSnippet=s,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
/*! @algolia/autocomplete-preset-algolia 1.0.0-alpha.36 | MIT License | © Algolia, Inc. and contributors | https://github.com/algolia/autocomplete.js */ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["@algolia/autocomplete-preset-algolia"]={})}(this,(function(e){"use strict";function t(e,t){return t.split(".").reduce((function(e,t){return e&&e[t]}),e)}var i="__aa-highlight__",r="__/aa-highlight__",n={"&":"&","<":"<",">":">",'"':""","'":"'"};function u(e){var t=e.highlightedValue,u=e.ignoreEscape,o=void 0===u?[]:u,a=new RegExp("[".concat(Object.keys(n).filter((function(e){return-1===o.indexOf(e)})).join(""),"]"),"g"),l=RegExp(a.source);function c(e){return l.test(e)?e.replace(a,(function(e){return n[e]})):e}var s=t.split(i),g=s.shift(),h=g?[{value:c(g),isHighlighted:!1}]:[];return s.forEach((function(e){var t=e.split(r);h.push({value:c(t[0]),isHighlighted:!0}),""!==t[1]&&h.push({value:c(t[1]),isHighlighted:!1})})),h}function o(e){var i=e.hit,r=e.attribute,n=e.ignoreEscape,o="_highlightResult.".concat(r,".value"),a=t(i,o);return"string"!=typeof a&&(a=t(i,r)||""),u({highlightedValue:a,ignoreEscape:n})}function a(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function l(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,r)}return i}function c(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?l(Object(i),!0).forEach((function(t){a(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):l(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function s(e){return e.some((function(e){return e.isHighlighted}))?e.map((function(e){return c(c({},e),{},{isHighlighted:!e.isHighlighted})})):e.map((function(e){return c(c({},e),{},{isHighlighted:!1})}))}function g(e){var i=e.hit,r=e.attribute,n=e.ignoreEscape,o="_snippetResult.".concat(r,".value"),a=t(i,o);return"string"!=typeof a&&(a=t(i,r)||""),u({highlightedValue:a,ignoreEscape:n})}function h(e){var t=e.searchClient,n=e.queries;return"function"==typeof t.addAlgoliaAgent&&t.addAlgoliaAgent("autocomplete-core","1.0.0-alpha.36"),t.search(n.map((function(e){var t=e.indexName,n=e.query,u=e.params;return{indexName:t,query:n,params:c({hitsPerPage:5,highlightPreTag:i,highlightPostTag:r},u)}})))}e.getAlgoliaHits=function(e){return h({searchClient:e.searchClient,queries:e.queries}).then((function(e){return e.results.map((function(e){return e.hits.map((function(t){return c(c({},t),{},{__autocomplete_indexName:e.index,__autocomplete_queryID:e.queryID})}))}))}))},e.getAlgoliaResults=function(e){return h({searchClient:e.searchClient,queries:e.queries}).then((function(e){return e.results}))},e.parseAlgoliaHitHighlight=o,e.parseAlgoliaHitReverseHighlight=function(e){return s(o(e))},e.parseAlgoliaHitReverseSnippet=function(e){return s(g(e))},e.parseAlgoliaHitSnippet=g,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=index.production.js.map |
{ | ||
"name": "@algolia/autocomplete-preset-algolia", | ||
"description": "Presets for building autocomplete experiences with Algolia.", | ||
"version": "1.0.0-alpha.35", | ||
"version": "1.0.0-alpha.36", | ||
"license": "MIT", | ||
@@ -34,7 +34,7 @@ "homepage": "https://github.com/algolia/autocomplete.js", | ||
"dependencies": { | ||
"@algolia/autocomplete-shared": "1.0.0-alpha.35" | ||
"@algolia/autocomplete-shared": "1.0.0-alpha.36" | ||
}, | ||
"devDependencies": { | ||
"@algolia/client-search": "4.5.1", | ||
"algoliasearch": "4.5.1" | ||
"@algolia/client-search": "4.6.0", | ||
"algoliasearch": "4.6.0" | ||
}, | ||
@@ -41,0 +41,0 @@ "peerDependencies": { |
@@ -15,2 +15,2 @@ # @algolia/autocomplete-preset-algolia | ||
[Read documentation →](https://algolia-autocomplete.netlify.app/docs/highlightAlgoliaHit) | ||
[Read documentation →](https://autocomplete.algolia.com/docs/highlightAlgoliaHit) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
52680
478
1
+ Added@algolia/autocomplete-shared@1.0.0-alpha.36(transitive)
- Removed@algolia/autocomplete-shared@1.0.0-alpha.35(transitive)