feat(ags): import fzf correctly with types
All checks were successful
Discord / discord commits (push) Has been skipped
All checks were successful
Discord / discord commits (push) Has been skipped
This commit is contained in:
parent
cea02da54c
commit
89c02b408d
3 changed files with 19 additions and 13 deletions
|
@ -29,13 +29,15 @@ export const transpileTypeScript = async(host) => {
|
||||||
// Create the dir if it doesn't exist
|
// Create the dir if it doesn't exist
|
||||||
`mkdir -p /tmp/ags-${host}; ` +
|
`mkdir -p /tmp/ags-${host}; ` +
|
||||||
|
|
||||||
|
// Let bun see tsconfig.json
|
||||||
|
`cd ${App.configDir};` +
|
||||||
|
|
||||||
`bun build ${App.configDir}/${host}.ts ` +
|
`bun build ${App.configDir}/${host}.ts ` +
|
||||||
'--external resource:///* ' +
|
'--external resource:///* ' +
|
||||||
'--external gi://* ' +
|
'--external gi://* ' +
|
||||||
'--external cairo ' +
|
'--external cairo ' +
|
||||||
'--external */fzf.es.js ' +
|
|
||||||
|
|
||||||
// Since bun wants to right in cwd, we just redirect stdin instead
|
// Since bun wants to write in cwd, we just redirect stdin instead
|
||||||
`> ${outPath}`,
|
`> ${outPath}`,
|
||||||
]).catch(print);
|
]).catch(print);
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
const Applications = await Service.import('applications');
|
const Applications = await Service.import('applications');
|
||||||
const { Box, Entry, Icon, Label, ListBox, Revealer, Scrollable } = Widget;
|
const { Box, Entry, Icon, Label, ListBox, Revealer, Scrollable } = Widget;
|
||||||
|
|
||||||
// @ts-expect-error find cleaner way to import this
|
import { Fzf, FzfResultItem } from 'fzf';
|
||||||
import { Fzf, FzfResultItem } from 'file:///home/matt/.nix/modules/ags/config/node_modules/fzf/dist/fzf.es.js';
|
|
||||||
|
|
||||||
import PopupWindow from '../misc/popup.ts';
|
import PopupWindow from '../misc/popup.ts';
|
||||||
import AppItem from './app-item.ts';
|
import AppItem from './app-item.ts';
|
||||||
|
@ -19,11 +18,10 @@ const Applauncher = (window_name = 'applauncher') => {
|
||||||
|
|
||||||
const setSort = (text: string) => {
|
const setSort = (text: string) => {
|
||||||
const fzf = new Fzf(Applications.list, {
|
const fzf = new Fzf(Applications.list, {
|
||||||
selector: (app: Application) => {
|
selector: (app) => app.name + app.executable,
|
||||||
return app.name + app.executable;
|
|
||||||
},
|
|
||||||
tiebreakers: [
|
tiebreakers: [
|
||||||
(a: Application, b: Application) => b.frequency - a.frequency,
|
(a, b) => b.item.frequency - a.item.frequency,
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -32,12 +30,14 @@ const Applauncher = (window_name = 'applauncher') => {
|
||||||
const row1 = (a.get_children()[0] as AgsAppItem).attribute.app.name;
|
const row1 = (a.get_children()[0] as AgsAppItem).attribute.app.name;
|
||||||
const row2 = (b.get_children()[0] as AgsAppItem).attribute.app.name;
|
const row2 = (b.get_children()[0] as AgsAppItem).attribute.app.name;
|
||||||
|
|
||||||
if (!row1 || !row2) {
|
const rowRes1 = fzfResults.find((r) => r.item.name === row1)?.score;
|
||||||
|
const rowRes2 = fzfResults.find((r) => r.item.name === row2)?.score;
|
||||||
|
|
||||||
|
if (!rowRes1 || !rowRes2) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return fzfResults.indexOf(row1) -
|
return rowRes1 - rowRes2;
|
||||||
fzfResults.indexOf(row1) || 0;
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ const Applauncher = (window_name = 'applauncher') => {
|
||||||
const item = (row.get_children()[0] as AgsAppItem);
|
const item = (row.get_children()[0] as AgsAppItem);
|
||||||
|
|
||||||
if (item.attribute.app) {
|
if (item.attribute.app) {
|
||||||
const isMatching = fzfResults.find((r) => {
|
const isMatching = fzfResults.some((r) => {
|
||||||
return r.item.name === item.attribute.app.name;
|
return r.item.name === item.attribute.app.name;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -10,9 +10,13 @@
|
||||||
"strict": true,
|
"strict": true,
|
||||||
"noImplicitAny": false,
|
"noImplicitAny": false,
|
||||||
"baseUrl": ".",
|
"baseUrl": ".",
|
||||||
|
"paths": {
|
||||||
|
"fzf": ["./node_modules/fzf/dist/types"],
|
||||||
|
},
|
||||||
"typeRoots": [
|
"typeRoots": [
|
||||||
"./types",
|
"./types",
|
||||||
"./global-types.d.ts"
|
"./global-types.d.ts",
|
||||||
|
"./node_modules",
|
||||||
],
|
],
|
||||||
"skipLibCheck": true,
|
"skipLibCheck": true,
|
||||||
"forceConsistentCasingInFileNames": true
|
"forceConsistentCasingInFileNames": true
|
||||||
|
|
Loading…
Reference in a new issue