fix(dependencies): upgrade dependencies (#1015)
This commit is contained in:
parent
bf18c7374e
commit
9300cb4bd6
28 changed files with 3949 additions and 1651 deletions
|
|
@ -3,3 +3,4 @@ dist
|
|||
/examples
|
||||
build
|
||||
.cache
|
||||
.parcel-cache
|
||||
|
|
|
|||
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -5,6 +5,7 @@ node_modules/
|
|||
*.log
|
||||
coverage/
|
||||
.cache
|
||||
.parcel-cache
|
||||
|
||||
# Bundle build files
|
||||
dist/
|
||||
|
|
|
|||
|
|
@ -2,3 +2,4 @@ node_modules
|
|||
dist
|
||||
build
|
||||
.cache
|
||||
.parcel-cache
|
||||
|
|
@ -6,11 +6,11 @@
|
|||
},
|
||||
{
|
||||
"path": "packages/docsearch-react/dist/umd/index.js",
|
||||
"maxSize": "18.3 kB"
|
||||
"maxSize": "19 kB"
|
||||
},
|
||||
{
|
||||
"path": "packages/docsearch-js/dist/umd/index.js",
|
||||
"maxSize": "25.9 kB"
|
||||
"maxSize": "26.5 kB"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
BIN
examples/demo/favicon.png
Normal file
BIN
examples/demo/favicon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.4 KiB |
18
examples/demo/index.html
Normal file
18
examples/demo/index.html
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
|
||||
<link rel="shortcut icon" href="favicon.png" type="image/x-icon" />
|
||||
|
||||
<title>DocSearch v3 - React</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<noscript>You need to enable JavaScript to run this app.</noscript>
|
||||
<div id="root"></div>
|
||||
|
||||
<script src="src/index.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
20
examples/demo/package.json
Normal file
20
examples/demo/package.json
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"name": "@docsearch/react-example",
|
||||
"description": "DocSearch v3 React example",
|
||||
"version": "3.0.0-alpha.36",
|
||||
"private": true,
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"build": "parcel build index.html",
|
||||
"start": "parcel index.html"
|
||||
},
|
||||
"dependencies": {
|
||||
"@docsearch/react": "3.0.0-alpha.36",
|
||||
"@docsearch/css": "3.0.0-alpha.36",
|
||||
"react": "17.0.2",
|
||||
"react-dom": "17.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"parcel": "2.0.0-beta.2"
|
||||
}
|
||||
}
|
||||
19
examples/demo/src/App.js
Normal file
19
examples/demo/src/App.js
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
import React from 'react';
|
||||
import { DocSearch } from '@docsearch/react';
|
||||
|
||||
import './app.css';
|
||||
import '@docsearch/css';
|
||||
|
||||
function App() {
|
||||
return (
|
||||
<div>
|
||||
<h1>DocSearch v3 - React</h1>
|
||||
<DocSearch
|
||||
indexName="docsearch"
|
||||
apiKey="25626fae796133dc1e734c6bcaaeac3c"
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default App;
|
||||
4
examples/demo/src/app.css
Normal file
4
examples/demo/src/app.css
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
body {
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica,
|
||||
Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';
|
||||
}
|
||||
6
examples/demo/src/index.js
Normal file
6
examples/demo/src/index.js
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
|
||||
import App from './App';
|
||||
|
||||
ReactDOM.render(<App />, document.getElementById('root'));
|
||||
0
examples/js-demo/README.md
Normal file
0
examples/js-demo/README.md
Normal file
4
examples/js-demo/app.css
Normal file
4
examples/js-demo/app.css
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
body {
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica,
|
||||
Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';
|
||||
}
|
||||
10
examples/js-demo/app.js
Normal file
10
examples/js-demo/app.js
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
import docsearch from '@docsearch/js/dist/umd';
|
||||
|
||||
import './app.css';
|
||||
import '@docsearch/css';
|
||||
|
||||
docsearch({
|
||||
container: '#docsearch',
|
||||
indexName: 'docsearch',
|
||||
apiKey: '25626fae796133dc1e734c6bcaaeac3c',
|
||||
});
|
||||
BIN
examples/js-demo/favicon.png
Normal file
BIN
examples/js-demo/favicon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.4 KiB |
20
examples/js-demo/index.html
Normal file
20
examples/js-demo/index.html
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
|
||||
<link rel="shortcut icon" href="favicon.png" type="image/x-icon" />
|
||||
|
||||
<title>DocSearch v3 - Vanilla JavaScript</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1>DocSearch v3 - Vanilla JavaScript</h1>
|
||||
|
||||
<div id="docsearch"></div>
|
||||
</div>
|
||||
|
||||
<script src="app.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
18
examples/js-demo/package.json
Normal file
18
examples/js-demo/package.json
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"name": "@docsearch/js-example",
|
||||
"description": "DocSearch v3 Vanilla JavaScript example",
|
||||
"version": "3.0.0-alpha.36",
|
||||
"private": true,
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"build": "parcel build index.html",
|
||||
"start": "parcel index.html"
|
||||
},
|
||||
"dependencies": {
|
||||
"@docsearch/js": "3.0.0-alpha.36",
|
||||
"@docsearch/css": "3.0.0-alpha.36"
|
||||
},
|
||||
"devDependencies": {
|
||||
"parcel": "2.0.0-beta.2"
|
||||
}
|
||||
}
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="https://unpkg.com/tailwindcss@1/dist/tailwind.min.css"
|
||||
/>
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="https://cdn.jsdelivr.net/npm/@docsearch/css@alpha"
|
||||
/>
|
||||
|
||||
<title>DocSearch v3 – Sandbox</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<header
|
||||
class="flex items-center justify-between px-4 py-3 bg-gray-100 shadow-lg"
|
||||
>
|
||||
<div class="uppercase">Website</div>
|
||||
<div>
|
||||
<div id="docsearch"></div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/@docsearch/js@alpha"></script>
|
||||
<script>
|
||||
docsearch({
|
||||
container: '#docsearch',
|
||||
indexName: 'docsearch',
|
||||
apiKey: '25626fae796133dc1e734c6bcaaeac3c',
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
{
|
||||
"name": "@docsearch/js-example",
|
||||
"description": "DocSearch.js sandbox",
|
||||
"version": "1.0.0-alpha.28",
|
||||
"private": true,
|
||||
"license": "MIT",
|
||||
"main": "index.html",
|
||||
"scripts": {
|
||||
"build": "parcel build index.html",
|
||||
"start": "parcel index.html"
|
||||
},
|
||||
"devDependencies": {
|
||||
"parcel-bundler": "1.12.3"
|
||||
},
|
||||
"keywords": [
|
||||
"algolia",
|
||||
"docsearch",
|
||||
"documentation",
|
||||
"search"
|
||||
]
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"packages": ["packages/*"],
|
||||
"packages": ["packages/*", "examples/*"],
|
||||
"version": "3.0.0-alpha.36",
|
||||
"npmClient": "yarn"
|
||||
}
|
||||
|
|
|
|||
13
package.json
13
package.json
|
|
@ -3,7 +3,8 @@
|
|||
"private": true,
|
||||
"workspaces": {
|
||||
"packages": [
|
||||
"packages/*"
|
||||
"packages/*",
|
||||
"examples/*"
|
||||
],
|
||||
"nohoist": [
|
||||
"**/html-minifier-terser"
|
||||
|
|
@ -26,6 +27,8 @@
|
|||
"lint:css": "stylelint **/src/**/*.css",
|
||||
"lint": "eslint --ext .js,.ts,.tsx .",
|
||||
"prepare": "lerna run prepare",
|
||||
"playground:start": "yarn workspace @docsearch/react-example start",
|
||||
"playground-js:start": "yarn workspace @docsearch/js-example start",
|
||||
"release": "shipjs prepare",
|
||||
"start": "yarn run watch",
|
||||
"test:size": "bundlesize",
|
||||
|
|
@ -53,7 +56,7 @@
|
|||
"@types/react-dom": "^17.0.0",
|
||||
"@typescript-eslint/eslint-plugin": "2.19.0",
|
||||
"@typescript-eslint/parser": "2.19.0",
|
||||
"algoliasearch": "4.8.0",
|
||||
"algoliasearch": "4.10.3",
|
||||
"babel-eslint": "10.1.0",
|
||||
"babel-loader": "8.1.0",
|
||||
"babel-plugin-inline-replace-variables": "1.3.1",
|
||||
|
|
@ -76,11 +79,11 @@
|
|||
"eslint-plugin-react-hooks": "2.3.0",
|
||||
"jest": "26.4.2",
|
||||
"jest-watch-typeahead": "0.6.0",
|
||||
"lerna": "3.22.1",
|
||||
"lerna": "4.0.0",
|
||||
"postcss": "7.0.32",
|
||||
"prettier": "2.1.1",
|
||||
"react": "17.0.1",
|
||||
"react-dom": "17.0.1",
|
||||
"react": "17.0.2",
|
||||
"react-dom": "17.0.2",
|
||||
"rimraf": "3.0.2",
|
||||
"rollup": "1.31.0",
|
||||
"rollup-plugin-babel": "4.4.0",
|
||||
|
|
|
|||
|
|
@ -34,8 +34,8 @@
|
|||
"watch": "watch \"yarn on:change\" --ignoreDirectoryPattern \"/dist/\""
|
||||
},
|
||||
"dependencies": {
|
||||
"@algolia/autocomplete-core": "1.0.0-alpha.44",
|
||||
"@algolia/autocomplete-preset-algolia": "1.0.0-alpha.44",
|
||||
"@algolia/autocomplete-core": "1.2.1",
|
||||
"@algolia/autocomplete-preset-algolia": "1.2.1",
|
||||
"@docsearch/css": "3.0.0-alpha.36",
|
||||
"algoliasearch": "^4.0.0"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import {
|
|||
AutocompleteState,
|
||||
AutocompleteOptions,
|
||||
} from '@algolia/autocomplete-core';
|
||||
import { SearchClient } from 'algoliasearch/lite';
|
||||
import React from 'react';
|
||||
import { createPortal } from 'react-dom';
|
||||
|
||||
|
|
@ -11,7 +12,6 @@ import {
|
|||
DocSearchHit,
|
||||
InternalDocSearchHit,
|
||||
StoredDocSearchHit,
|
||||
SearchClient,
|
||||
} from './types';
|
||||
import { useDocSearchKeyboardEvents } from './useDocSearchKeyboardEvents';
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import {
|
|||
AutocompleteState,
|
||||
createAutocomplete,
|
||||
} from '@algolia/autocomplete-core';
|
||||
import { getAlgoliaResults } from '@algolia/autocomplete-preset-algolia';
|
||||
import React from 'react';
|
||||
|
||||
import { MAX_QUERY_SIZE } from './constants';
|
||||
|
|
@ -128,7 +127,7 @@ export function DocSearchModal({
|
|||
},
|
||||
navigator,
|
||||
onStateChange({ state }) {
|
||||
setState(state as any);
|
||||
setState(state);
|
||||
},
|
||||
// @ts-ignore Temporarily ignore bad typing in autocomplete-core.
|
||||
getSources({ query, state, setContext, setStatus }) {
|
||||
|
|
@ -173,43 +172,36 @@ export function DocSearchModal({
|
|||
];
|
||||
}
|
||||
|
||||
return getAlgoliaResults<DocSearchHit>({
|
||||
searchClient,
|
||||
queries: [
|
||||
{
|
||||
indexName,
|
||||
query,
|
||||
params: {
|
||||
attributesToRetrieve: [
|
||||
'hierarchy.lvl0',
|
||||
'hierarchy.lvl1',
|
||||
'hierarchy.lvl2',
|
||||
'hierarchy.lvl3',
|
||||
'hierarchy.lvl4',
|
||||
'hierarchy.lvl5',
|
||||
'hierarchy.lvl6',
|
||||
'content',
|
||||
'type',
|
||||
'url',
|
||||
],
|
||||
attributesToSnippet: [
|
||||
`hierarchy.lvl1:${snippetLength.current}`,
|
||||
`hierarchy.lvl2:${snippetLength.current}`,
|
||||
`hierarchy.lvl3:${snippetLength.current}`,
|
||||
`hierarchy.lvl4:${snippetLength.current}`,
|
||||
`hierarchy.lvl5:${snippetLength.current}`,
|
||||
`hierarchy.lvl6:${snippetLength.current}`,
|
||||
`content:${snippetLength.current}`,
|
||||
],
|
||||
snippetEllipsisText: '…',
|
||||
highlightPreTag: '<mark>',
|
||||
highlightPostTag: '</mark>',
|
||||
hitsPerPage: 20,
|
||||
...searchParameters,
|
||||
},
|
||||
},
|
||||
],
|
||||
})
|
||||
return searchClient
|
||||
.initIndex(indexName)
|
||||
.search<DocSearchHit>(query, {
|
||||
attributesToRetrieve: [
|
||||
'hierarchy.lvl0',
|
||||
'hierarchy.lvl1',
|
||||
'hierarchy.lvl2',
|
||||
'hierarchy.lvl3',
|
||||
'hierarchy.lvl4',
|
||||
'hierarchy.lvl5',
|
||||
'hierarchy.lvl6',
|
||||
'content',
|
||||
'type',
|
||||
'url',
|
||||
],
|
||||
attributesToSnippet: [
|
||||
`hierarchy.lvl1:${snippetLength.current}`,
|
||||
`hierarchy.lvl2:${snippetLength.current}`,
|
||||
`hierarchy.lvl3:${snippetLength.current}`,
|
||||
`hierarchy.lvl4:${snippetLength.current}`,
|
||||
`hierarchy.lvl5:${snippetLength.current}`,
|
||||
`hierarchy.lvl6:${snippetLength.current}`,
|
||||
`content:${snippetLength.current}`,
|
||||
],
|
||||
snippetEllipsisText: '…',
|
||||
highlightPreTag: '<mark>',
|
||||
highlightPostTag: '</mark>',
|
||||
hitsPerPage: 20,
|
||||
...searchParameters,
|
||||
})
|
||||
.catch((error) => {
|
||||
// The Algolia `RetryError` happens when all the servers have
|
||||
// failed, meaning that there's no chance the response comes
|
||||
|
|
@ -221,13 +213,11 @@ export function DocSearchModal({
|
|||
|
||||
throw error;
|
||||
})
|
||||
.then((results) => {
|
||||
const hits = results[0].hits;
|
||||
const nbHits: number = results[0].nbHits;
|
||||
.then(({ hits, nbHits }) => {
|
||||
const sources = groupBy(hits, (hit) => removeHighlightTags(hit));
|
||||
|
||||
// We store the `lvl0`s to display them as search suggestions
|
||||
// in the “no results“ screen.
|
||||
// in the "no results" screen.
|
||||
if (
|
||||
(state.context.searchSuggestions as any[]).length <
|
||||
Object.keys(sources).length
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
export type SearchClient = any;
|
||||
|
|
@ -1,4 +1,3 @@
|
|||
export * from './DocSearchHit';
|
||||
export * from './InternalDocSearchHit';
|
||||
export * from './SearchClient';
|
||||
export * from './StoredDocSearchHit';
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import algoliasearch from 'algoliasearch/dist/algoliasearch-lite.esm.browser';
|
||||
import { SearchClient } from 'algoliasearch/lite';
|
||||
import React from 'react';
|
||||
|
||||
import { SearchClient } from './types';
|
||||
import { version } from './version';
|
||||
|
||||
export function useSearchClient(
|
||||
|
|
|
|||
|
|
@ -13,11 +13,11 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"@algolia/ui-library": "2.35.0",
|
||||
"@docsearch/react": "1.0.0-alpha.28",
|
||||
"@docsearch/react": "3.0.0-alpha.36",
|
||||
"@docusaurus/core": "2.0.0-alpha.69",
|
||||
"@docusaurus/preset-classic": "2.0.0-alpha.69",
|
||||
"@docusaurus/theme-live-codeblock": "2.0.0-alpha.69",
|
||||
"algoliasearch": "4.1.0",
|
||||
"algoliasearch": "4.10.3",
|
||||
"classnames": "2.2.6",
|
||||
"docsearch.js": "2.6.3",
|
||||
"file-loader": "4.3.0",
|
||||
|
|
|
|||
Loading…
Reference in a new issue