Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: search packages with websocket #434

Merged
merged 24 commits into from
Dec 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
2a49ef2
feat: search packages with websocket
PierreDemailly Nov 11, 2024
a596d39
refactor: enhance searchnav styles
fraxken Nov 29, 2024
3d137ca
chore: finalize style
fraxken Nov 30, 2024
cf482ab
feat: add hint for min & max package length
PierreDemailly Nov 30, 2024
9587e9d
chore: enhance search view css
fraxken Nov 30, 2024
778a0e4
fix: use dataset to work with package name
PierreDemailly Nov 30, 2024
6ba5b71
refactor: hide network searchbar when not required
fraxken Nov 30, 2024
8a2e8a6
chore: improve logs
PierreDemailly Nov 30, 2024
5160493
fix: use template to render home view
fraxken Dec 7, 2024
3eda228
refactor: enhance initSearchBar
fraxken Dec 7, 2024
6b6fcc8
fix: bug with searchbar display: none
fraxken Dec 7, 2024
42f9374
fix(css): remove overflow-x: auto on .packages
fraxken Dec 7, 2024
d3ee0bd
chore: improve package close button css
fraxken Dec 7, 2024
6d7ae3f
chore: add i18n for searchbar placeholder
fraxken Dec 7, 2024
b9d5a4c
feat(search): allow to remove packages from cache
PierreDemailly Dec 7, 2024
09693d7
fix: make new current package active on reload
PierreDemailly Dec 7, 2024
63582d0
feat(search): add spinner while searching packages
PierreDemailly Dec 7, 2024
6be3c4a
feat(search): add spinner while searching package versions
PierreDemailly Dec 7, 2024
518a986
feat(search): move search spinner into input
PierreDemailly Dec 7, 2024
ff973a7
fix: init on reload when removed last active package only
PierreDemailly Dec 7, 2024
242b273
refactor: split interface init function
PierreDemailly Dec 7, 2024
6cae127
feat: highlight exact match package
PierreDemailly Dec 7, 2024
bd099fa
feat: close package info when switching network
PierreDemailly Dec 7, 2024
f3cf02a
fix: network searchbar
fraxken Dec 8, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 20 additions & 28 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,32 +1,24 @@
// Import Node.js Dependencies
import path from "node:path";
import { fileURLToPath } from "node:url";
import { ESLintConfig, globals } from "@openally/config.eslint";

// Import Third-party Dependencies
import { FlatCompat } from "@eslint/eslintrc";

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

const compat = new FlatCompat({
baseDirectory: __dirname
});

export default [{
ignores: ["**/node_modules/", "**/tmp/", "**/dist/", "**/coverage/", "**/fixtures/"]
}, ...compat.extends("@nodesecure/eslint-config"), {
languageOptions: {
sourceType: "module",

parserOptions: {
requireConfigFile: false
export default [
...ESLintConfig,
{
rules: {
"func-style": "off",
"no-invalid-this": "off",
"no-inner-declarations": "off",
"no-case-declarations": "off",
// TODO: enable this rule when migrating to @topcli/cmder
"default-param-last": "off"
},
languageOptions: {
sourceType: "module",
globals: {
...globals.browser
}
}
},

rules: {
"func-style": "off",
"no-invalid-this": "off",
"no-inner-declarations": "off",
"no-case-declarations": "off"
{
ignores: ["**/node_modules/", "**/tmp/", "**/dist/", "**/coverage/", "**/fixtures/"]
}
}];
];
9 changes: 7 additions & 2 deletions i18n/english.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* eslint-disable max-len */
/* eslint-disable @stylistic/max-len */

// Import Third-party Dependencies
import { taggedString as tS } from "@nodesecure/i18n";

Expand Down Expand Up @@ -188,7 +189,11 @@ const ui = {
"Node.js core modules": "Node.js core modules",
"Available licenses": "Available licenses",
"Available flags": "Available flags",
default: "Search options"
default: "Search options",
packagesCache: "Packages available in the cache",
noPackageFound: "No package found",
packageLengthErr: "Package name must be between 2 and 64 characters.",
registryPlaceholder: "Search packages"
},
legend: {
default: "The package is fine.",
Expand Down
9 changes: 7 additions & 2 deletions i18n/french.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* eslint-disable max-len */
/* eslint-disable @stylistic/max-len */

// Import Third-party Dependencies
import { taggedString as tS } from "@nodesecure/i18n";

Expand Down Expand Up @@ -188,7 +189,11 @@ const ui = {
"Node.js core modules": "Modules de base de Node.js",
"Available licenses": "Licences disponibles",
"Available flags": "Drapeaux disponibles",
default: "Options de recherche"
default: "Options de recherche",
packagesCache: "Packages disponibles dans le cache",
noPackageFound: "Aucun package trouvé",
packageLengthErr: "Le nom du package doit être compris entre 2 et 64 caractères.",
registryPlaceholder: "Recherche de packages"
},
legend: {
default: "Rien à signaler.",
Expand Down
17 changes: 10 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@
"node": ">=18"
},
"scripts": {
"eslint": "eslint bin src test workspaces",
"eslint-fix": "npm run eslint -- --fix",
"lint": "eslint bin src test workspaces",
"lint-fix": "npm run lint -- --fix",
"prepublishOnly": "rimraf ./dist && npm run build && pkg-ok",
"build": "node ./esbuild.config.js",
"test": "npm run test-only && npm run eslint",
"test-only": "glob -c \"node --loader=esmock --no-warnings --test\" \"test/**/*.test.js\"",
"coverage": "c8 --reporter=lcov npm run test"
"test": "npm run test-only && npm run lint",
"test-only": "glob -c \"node --loader=esmock --no-warnings --test-concurrency 1 --test\" \"test/**/*.test.js\"",
"coverage": "c8 --reporter=lcov npm run test",
"clear:cache": "node ./scripts/clear-cache.js"
},
"files": [
"bin",
Expand Down Expand Up @@ -62,14 +63,13 @@
"homepage": "https://github.com/NodeSecure/cli#readme",
"devDependencies": {
"@myunisoft/httpie": "^5.0.0",
"@nodesecure/eslint-config": "2.0.0-beta.0",
"@nodesecure/size-satisfies": "^1.1.0",
"@nodesecure/vis-network": "^1.4.0",
"@openally/config.eslint": "^1.1.0",
"@types/node": "^22.2.0",
"c8": "^10.1.2",
"cross-env": "^7.0.3",
"esbuild": "^0.23.0",
"eslint": "^9.8.0",
"esmock": "^2.6.7",
"glob": "^11.0.0",
"http-server": "^14.1.1",
Expand Down Expand Up @@ -104,10 +104,13 @@
"kleur": "^4.1.5",
"ms": "^2.1.3",
"open": "^10.1.0",
"pino": "^9.3.2",
"pino-pretty": "^11.2.2",
"polka": "^0.5.2",
"sade": "^1.8.1",
"semver": "^7.6.3",
"sirv": "^2.0.4",
"ws": "^8.18.0",
"zup": "0.0.2"
}
}
12 changes: 12 additions & 0 deletions public/common/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,3 +250,15 @@ export function currentLang() {

return detectedLang in window.i18n ? detectedLang : "english";
}

export function debounce(callback, delay) {
let timer;

// eslint-disable-next-line func-names
return function() {
clearTimeout(timer);
timer = setTimeout(() => {
callback();
}, delay);
};
}
108 changes: 57 additions & 51 deletions public/components/navigation/navigation.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
nav {
nav#aside {
width: 70px;
flex-shrink: 0;
background: var(--primary);
Expand All @@ -8,60 +8,66 @@ nav {
flex-direction: column;
z-index: 40;
}
nav > .nsecure-logo {
margin-top: 20px;
}

nav > ul {
width: inherit;
display: flex;
margin-top: 10px;
flex-direction: column;
flex-grow: 1;
margin-bottom: 20px;
}
nav#aside>.nsecure-logo {
margin-top: 20px;
}

nav > ul li {
height: 70px;
display: flex;
position: relative;
justify-content: center;
align-items: center;
}
nav > ul li+li {
margin-top: 10px;
}
nav#aside>ul {
width: inherit;
display: flex;
margin-top: 10px;
flex-direction: column;
flex-grow: 1;
margin-bottom: 20px;
}

nav > ul li:not(.active):hover {
cursor: pointer;
background: rgba(50, 200, 255, 0.085);
}
nav#aside>ul li {
height: 70px;
display: flex;
position: relative;
justify-content: center;
align-items: center;
}

nav#aside>ul li+li {
margin-top: 10px;
}

nav > ul li.active:before {
background: var(--secondary);
position: absolute;
left: 0;
top: 17.5px;
height: 35px;
width: 4px;
border-radius: 0 4px 4px 0;
content: "";
}
nav#aside>ul li:not(.active):hover {
cursor: pointer;
background: rgba(50, 200, 255, 0.085);
}

nav#aside>ul li.active:before {
background: var(--secondary);
position: absolute;
left: 0;
top: 17.5px;
height: 35px;
width: 4px;
border-radius: 0 4px 4px 0;
content: "";
}

nav#aside>ul li>i {
font-size: 24px;
}

nav#aside>ul li.active,
nav#aside>ul li.active span {
color: var(--secondary);
}

nav#aside>ul li>span {
position: absolute;
left: 10px;
bottom: 5px;
font-size: 12px;
color: #FFF;
font-weight: bold;
}

nav > ul li > i {
font-size: 24px;
}
nav > ul li.active, nav > ul li.active span {
color: var(--secondary);
}
nav > ul li > span {
position: absolute;
left: 10px;
bottom: 5px;
font-size: 12px;
color: #FFF;
font-weight: bold;
}
.bottom-nav {
nav#aside>ul li.bottom-nav {
margin-top: auto;
}
10 changes: 10 additions & 0 deletions public/components/navigation/navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { PackageInfo } from "../package/package.js";
const kAvailableView = new Set([
"network--view",
"home--view",
"search--view",
"settings--view"
]);

Expand Down Expand Up @@ -50,6 +51,10 @@ export class ViewNavigation {
this.onNavigationSelected(this.menus.get("settings--view"));
break;
}
case hotkeys.search: {
this.onNavigationSelected(this.menus.get("search--view"));
break;
}
}
});
}
Expand All @@ -68,6 +73,11 @@ export class ViewNavigation {
selectedNav.classList.add("active");
this.setAnchor(menuName);

const searchbar = document.getElementById("searchbar");
if (searchbar) {
searchbar.style.display = menuName === "network--view" ? "flex" : "none";
}

this.activeMenu = selectedNav;
}

Expand Down
Loading
Loading