mirror of
https://github.com/verdaccio/verdaccio.git
synced 2024-12-30 22:34:10 -05:00
parent
10057a4ff1
commit
6a1287bdab
3 changed files with 38 additions and 35 deletions
|
@ -2175,9 +2175,6 @@ importers:
|
||||||
'@emotion/styled':
|
'@emotion/styled':
|
||||||
specifier: 11.10.6
|
specifier: 11.10.6
|
||||||
version: 11.10.6(@emotion/react@11.10.6)(@types/react@18.0.26)(react@17.0.2)
|
version: 11.10.6(@emotion/react@11.10.6)(@types/react@18.0.26)(react@17.0.2)
|
||||||
'@lyrasearch/lyra':
|
|
||||||
specifier: 0.3.0
|
|
||||||
version: 0.3.0
|
|
||||||
'@mdx-js/react':
|
'@mdx-js/react':
|
||||||
specifier: ^1.6.22
|
specifier: ^1.6.22
|
||||||
version: 1.6.22(react@17.0.2)
|
version: 1.6.22(react@17.0.2)
|
||||||
|
@ -2190,6 +2187,9 @@ importers:
|
||||||
'@mui/styles':
|
'@mui/styles':
|
||||||
specifier: 5.13.7
|
specifier: 5.13.7
|
||||||
version: 5.13.7(@types/react@18.0.26)(react@17.0.2)
|
version: 5.13.7(@types/react@18.0.26)(react@17.0.2)
|
||||||
|
'@orama/orama':
|
||||||
|
specifier: 1.2.1
|
||||||
|
version: 1.2.1
|
||||||
'@verdaccio/ui-components':
|
'@verdaccio/ui-components':
|
||||||
specifier: workspace:3.0.0-next.1
|
specifier: workspace:3.0.0-next.1
|
||||||
version: link:../packages/ui-components
|
version: link:../packages/ui-components
|
||||||
|
@ -8495,11 +8495,6 @@ packages:
|
||||||
/@leichtgewicht/ip-codec@2.0.4:
|
/@leichtgewicht/ip-codec@2.0.4:
|
||||||
resolution: {integrity: sha512-Hcv+nVC0kZnQ3tD9GVu5xSMR4VVYOteQIr/hwFPVEvPdlXqgGEuRjiheChHgdM+JyqdgNcmzZOX/tnl0JOiI7A==}
|
resolution: {integrity: sha512-Hcv+nVC0kZnQ3tD9GVu5xSMR4VVYOteQIr/hwFPVEvPdlXqgGEuRjiheChHgdM+JyqdgNcmzZOX/tnl0JOiI7A==}
|
||||||
|
|
||||||
/@lyrasearch/lyra@0.3.0:
|
|
||||||
resolution: {integrity: sha512-HKACmENyo4EKloPWQawqX7lKt+qh8w+7r/orNtwzWZ67fJcw59pDd5IwzYw52S9oFg9Dablsw8cuJXk2vNvHkQ==}
|
|
||||||
deprecated: Lyra is now called Orama! Install the latest stable version via the @orama/orama package
|
|
||||||
dev: false
|
|
||||||
|
|
||||||
/@manypkg/find-root@1.1.0:
|
/@manypkg/find-root@1.1.0:
|
||||||
resolution: {integrity: sha512-mki5uBvhHzO8kYYix/WRy2WX8S3B5wdVSc9D6KcU5lQNglP2yt58/VfLuAK49glRXChosY8ap2oJ1qgma3GUVA==}
|
resolution: {integrity: sha512-mki5uBvhHzO8kYYix/WRy2WX8S3B5wdVSc9D6KcU5lQNglP2yt58/VfLuAK49glRXChosY8ap2oJ1qgma3GUVA==}
|
||||||
dependencies:
|
dependencies:
|
||||||
|
@ -9254,7 +9249,6 @@ packages:
|
||||||
/@orama/orama@1.2.1:
|
/@orama/orama@1.2.1:
|
||||||
resolution: {integrity: sha512-vq3ar9REofq7Q87riamQB5y1aJc068Qwbnd7uAboeSfRTDj2+KdNiwjTEk01SVjr8eAvCx8iRZl4rkEYo0ETYw==}
|
resolution: {integrity: sha512-vq3ar9REofq7Q87riamQB5y1aJc068Qwbnd7uAboeSfRTDj2+KdNiwjTEk01SVjr8eAvCx8iRZl4rkEYo0ETYw==}
|
||||||
engines: {node: '>= 16.0.0'}
|
engines: {node: '>= 16.0.0'}
|
||||||
dev: true
|
|
||||||
|
|
||||||
/@pmmmwh/react-refresh-webpack-plugin@0.5.10(@types/webpack@5.28.1)(react-refresh@0.11.0)(webpack@5.82.1):
|
/@pmmmwh/react-refresh-webpack-plugin@0.5.10(@types/webpack@5.28.1)(react-refresh@0.11.0)(webpack@5.82.1):
|
||||||
resolution: {integrity: sha512-j0Ya0hCFZPd4x40qLzbhGsh9TMtdb+CJQiso+WxLOPNasohq9cc5SNUcwsZaRH6++Xh91Xkm/xHCkuIiIu0LUA==}
|
resolution: {integrity: sha512-j0Ya0hCFZPd4x40qLzbhGsh9TMtdb+CJQiso+WxLOPNasohq9cc5SNUcwsZaRH6++Xh91Xkm/xHCkuIiIu0LUA==}
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
"@emotion/jest": "11.10.5",
|
"@emotion/jest": "11.10.5",
|
||||||
"@emotion/react": "11.10.6",
|
"@emotion/react": "11.10.6",
|
||||||
"@emotion/styled": "11.10.6",
|
"@emotion/styled": "11.10.6",
|
||||||
"@lyrasearch/lyra": "0.3.0",
|
"@orama/orama": "1.2.1",
|
||||||
"@mdx-js/react": "^1.6.22",
|
"@mdx-js/react": "^1.6.22",
|
||||||
"@mui/icons-material": "5.13.7",
|
"@mui/icons-material": "5.13.7",
|
||||||
"@mui/material": "5.13.7",
|
"@mui/material": "5.13.7",
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import Translate, { translate } from '@docusaurus/Translate';
|
import Translate, { translate } from '@docusaurus/Translate';
|
||||||
import { create, insertBatch, search } from '@lyrasearch/lyra';
|
|
||||||
import Typography from '@mui/material/Typography';
|
import Typography from '@mui/material/Typography';
|
||||||
import Grid from '@mui/material/Unstable_Grid2';
|
import Grid from '@mui/material/Unstable_Grid2';
|
||||||
import { useTheme } from '@mui/styles';
|
import { useTheme } from '@mui/styles';
|
||||||
|
import { Orama, ProvidedTypes, create, insertMultiple, search } from '@orama/orama';
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { useEffect } from 'react';
|
import { useEffect } from 'react';
|
||||||
|
@ -16,19 +16,6 @@ type Props = {
|
||||||
filters: Filters;
|
filters: Filters;
|
||||||
};
|
};
|
||||||
|
|
||||||
const db = create({
|
|
||||||
schema: {
|
|
||||||
name: 'string',
|
|
||||||
url: 'string',
|
|
||||||
category: 'string',
|
|
||||||
bundled: 'boolean',
|
|
||||||
origin: 'string',
|
|
||||||
latest: 'string',
|
|
||||||
downloads: 'number',
|
|
||||||
description: 'string',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const normalizeResults = (hits) => {
|
const normalizeResults = (hits) => {
|
||||||
return hits.reduce((acc, item) => {
|
return hits.reduce((acc, item) => {
|
||||||
acc.push(item.document);
|
acc.push(item.document);
|
||||||
|
@ -58,22 +45,44 @@ const filterByProperty = (addsOns: Addon[], filters: Filters) => {
|
||||||
|
|
||||||
const ToolList: FC<Props> = ({ addons = [], filters }): React.ReactElement => {
|
const ToolList: FC<Props> = ({ addons = [], filters }): React.ReactElement => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
|
const [db, setDb] = useState<Orama<ProvidedTypes>>();
|
||||||
const [filteredAddsOn, setFilteredAddsOn] = useState(addons);
|
const [filteredAddsOn, setFilteredAddsOn] = useState(addons);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
insertBatch(db, addons);
|
const createDb = async () => {
|
||||||
|
const db = await create({
|
||||||
|
schema: {
|
||||||
|
name: 'string',
|
||||||
|
url: 'string',
|
||||||
|
category: 'string',
|
||||||
|
bundled: 'boolean',
|
||||||
|
origin: 'string',
|
||||||
|
latest: 'string',
|
||||||
|
downloads: 'number',
|
||||||
|
description: 'string',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
console.log('===>', db);
|
||||||
|
setDb(db);
|
||||||
|
insertMultiple(db as Orama<ProvidedTypes>, addons);
|
||||||
|
};
|
||||||
|
|
||||||
|
createDb();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
let results: Addon[] = addons;
|
const searchKeyword = async () => {
|
||||||
if (filters.keyword !== '') {
|
let results: Addon[] = addons;
|
||||||
const dbResults = search(db, {
|
if (filters.keyword !== '') {
|
||||||
term: filters.keyword,
|
const dbResults = await search(db as Orama<ProvidedTypes>, {
|
||||||
});
|
term: filters.keyword,
|
||||||
results = [...normalizeResults(dbResults.hits)];
|
});
|
||||||
}
|
results = [...normalizeResults(dbResults.hits)];
|
||||||
// TODO: apply advanced filters later
|
}
|
||||||
// setFilteredAddsOn(filterByProperty(results, filters));
|
// TODO: apply advanced filters later
|
||||||
setFilteredAddsOn(results);
|
// setFilteredAddsOn(filterByProperty(results, filters));
|
||||||
|
setFilteredAddsOn(results);
|
||||||
|
};
|
||||||
|
searchKeyword();
|
||||||
}, [filters, addons]);
|
}, [filters, addons]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
Loading…
Reference in a new issue