🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

farjs-app

Package Overview
Dependencies
Maintainers
1
Versions
202
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

farjs-app - npm Package Compare versions

Comparing version
0.19.9
to
0.20.0
+109
app/FarjsApp.mjs
/**
* @typedef {import("@farjs/blessed").Widgets.Screen} BlessedScreen
* @typedef {import("@farjs/blessed").Widgets.IScreenOptions} ScreenOptions
* @typedef {import("./FarjsData.mjs").FarjsData} FarjsData
* @import { Database } from "@farjs/better-sqlite3-wrapper"
* @import { ReactComponent } from "@farjs/filelist/FileListData.mjs"
* @import FileListActions from "@farjs/filelist/FileListActions.mjs"
*/
import React from "react";
import ReactBlessed from "react-blessed";
import Blessed from "@farjs/blessed";
import AppRoot from "@farjs/ui/app/AppRoot.mjs";
import DevTool from "@farjs/ui/tool/DevTool.mjs";
import WithPortals from "@farjs/ui/portal/WithPortals.mjs";
import FileListTheme from "@farjs/filelist/theme/FileListTheme.mjs";
import FileListModule from "./filelist/FileListModule.mjs";
import FileListRoot from "./filelist/FileListRoot.mjs";
import FSFileListActions from "../fs/FSFileListActions.mjs";
import FarjsData from "./FarjsData.mjs";
import FarjsDBMigrations from "./FarjsDBMigrations.mjs";
const h = React.createElement;
const FarjsApp = {
/**
* @param {boolean} showDevTools
* @param {() => void} [onReady]
* @param {() => void} [onExit]
*/
start: (showDevTools, onReady, onExit) => {
const screen = FarjsApp.createScreen(onExit);
FarjsApp.render(showDevTools, screen, onReady);
},
/** @type {(onExit?: () => void) => BlessedScreen} */
createScreen: (onExit) => {
const screen = FarjsApp._blesseScreen({
autoPadding: true,
smartCSR: true,
tabSize: 1,
fullUnicode: true,
cursorShape: "underline",
});
const savedConsoleLog = console.log;
const savedConsoleError = console.error;
screen.key(["C-e"], () => {
// cleanup/unmount components
screen.destroy();
console.log = savedConsoleLog;
console.error = savedConsoleError;
if (onExit) onExit();
else process.exit(0);
});
return screen;
},
/** @type {(showDevTools: boolean, screen: BlessedScreen, onReady?: () => void) => void} */
render: (showDevTools, screen, onReady) => {
FarjsApp._renderer(
h(FarjsApp.appRootComp, {
loadMainUi: async (dispatch) => {
if (onReady) {
onReady();
}
const db = await FarjsApp._prepareDB(
FSFileListActions.instance,
FarjsData.instance,
);
const fileListModule = new FileListModule(db);
const mainUi = FileListRoot(
dispatch,
fileListModule,
FarjsApp._createPortals(screen),
);
const theme =
screen.terminal === "xterm-256color"
? FileListTheme.xterm256Theme
: FileListTheme.defaultTheme;
return { theme, mainUi };
},
initialDevTool: showDevTools ? DevTool.Logs : DevTool.Hidden,
defaultTheme: FileListTheme.defaultTheme,
}),
screen,
);
},
/** @type {(actions: FileListActions, appData: FarjsData) => Promise<Database>} */
_prepareDB: FarjsDBMigrations.prepareDB,
/** @type {(s: BlessedScreen) => ReactComponent} */
_createPortals: WithPortals.create,
/** @type {(options: ScreenOptions) => BlessedScreen} */
_blesseScreen: Blessed.screen,
/** @type {(c: React.ReactElement, s: BlessedScreen) => void} */
_renderer: ReactBlessed.createBlessedRenderer(Blessed),
appRootComp: AppRoot,
};
export default FarjsApp;
/**
* @import { Database } from "@farjs/better-sqlite3-wrapper"
* @import { HistoryProvider } from "@farjs/filelist/history/HistoryProvider.mjs"
* @import { FSServices } from "../../fs/FSServices.mjs"
*/
import HistoryKindDao from "../../dao/HistoryKindDao.mjs";
import FolderShortcutDao from "../../dao/FolderShortcutDao.mjs";
import FolderShortcutsService from "../../fs/popups/FolderShortcutsService.mjs";
import HistoryProviderImpl from "../service/HistoryProviderImpl.mjs";
class FileListModule {
/**
* @param {Database} db
*/
constructor(db) {
const historyKindDao = HistoryKindDao(db);
const folderShortcutDao = FolderShortcutDao(db);
const folderShortcuts = FolderShortcutsService(folderShortcutDao);
/** @readonly @type {HistoryProvider} */
this.historyProvider = HistoryProviderImpl(db, historyKindDao);
/** @readonly @type {FSServices} */
this.fsServices = {
folderShortcuts,
};
}
}
export default FileListModule;
/**
* @import { Dispatch, ReactComponent } from "@farjs/filelist/FileListData.mjs"
* @import FileListPlugin from "@farjs/filelist/FileListPlugin.mjs"
*/
import React from "react";
import HistoryProvider from "@farjs/filelist/history/HistoryProvider.mjs";
import ArchiverPlugin from "../../archiver/ArchiverPlugin.mjs";
import CopyMovePlugin from "../../copymove/CopyMovePlugin.mjs";
import ViewerPlugin from "../../viewer/ViewerPlugin.mjs";
import QuickViewPlugin from "../../viewer/quickview/QuickViewPlugin.mjs";
import FSPlugin from "../../fs/FSPlugin.mjs";
import FSServices from "../../fs/FSServices.mjs";
import FilePlugin from "../../file/FilePlugin.mjs";
import FileListUiPlugin from "../../filelist/FileListUiPlugin.mjs";
import FileListBrowser from "./FileListBrowser.mjs";
import FileListModule from "./FileListModule.mjs";
import FileListPluginHandler from "./FileListPluginHandler.mjs";
const h = React.createElement;
/**
* @param {Dispatch} dispatch
* @param {FileListModule} module
* @param {ReactComponent} withPortalsComp
*/
function FileListRoot(
dispatch,
{ historyProvider, fsServices },
withPortalsComp,
) {
/**
* @param {React.PropsWithChildren<any>} props
*/
const FileListRootComp = (props) => {
const { fileListComp } = FileListRoot;
return h(
HistoryProvider.Context.Provider,
{ value: historyProvider },
h(
FSServices.Context.Provider,
{ value: fsServices },
h(
withPortalsComp,
null,
h(fileListComp, { dispatch, isRightInitiallyActive: false }),
props.children,
),
),
);
};
FileListRootComp.displayName = "FileListRoot";
return FileListRootComp;
}
/** @type {readonly FileListPlugin[]} */
const plugins = [
QuickViewPlugin,
ArchiverPlugin.instance,
ViewerPlugin,
CopyMovePlugin.instance,
FSPlugin.instance,
FileListUiPlugin,
FilePlugin,
];
FileListRoot.fileListComp = FileListBrowser(FileListPluginHandler(plugins));
export default FileListRoot;
+1
-2
#!/usr/bin/env node
// @ts-ignore
import { FarjsApp } from "../build/farjs-app-opt.js";
import FarjsApp from "../app/FarjsApp.mjs";

@@ -6,0 +5,0 @@ process.title = "FAR.js";

The MIT License (MIT)
Copyright (c) 2023 FAR.js contributors
Copyright (c) 2026 FAR.js contributors

@@ -5,0 +5,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy

{
"author": "viktor-podzigun",
"name": "farjs-app",
"version": "0.19.9",
"version": "0.20.0",
"repository": {

@@ -55,3 +55,2 @@ "type": "git",

"archiver/**/*.mjs",
"build/farjs-app-opt.js",
"copymove/**/*.mjs",

@@ -68,4 +67,4 @@ "dao/migrations/bundle.json",

"type": "module",
"main": "./build/farjs-app-opt.js",
"exports": "./build/farjs-app-opt.js",
"main": "./app/FarjsApp.mjs",
"exports": "./app/FarjsApp.mjs",
"preferGlobal": true,

@@ -72,0 +71,0 @@ "browserslist": "maintained node versions",

Sorry, the diff of this file is too big to display

[
{
"file": "V001__add_history_folders_table.sql",
"content": "\n-- non-transactional\nPRAGMA foreign_keys = ON;\n\nCREATE TABLE history_folders (\n path text PRIMARY KEY,\n updated_at integer NOT NULL\n);\n\nCREATE INDEX idx_history_folders_updated_at ON history_folders (updated_at);\n"
},
{
"file": "V002__recreate_history_folders_table.sql",
"content": "\nDROP TABLE history_folders;\n\nCREATE TABLE history_folders (\n item text PRIMARY KEY,\n updated_at integer NOT NULL\n);\n\nCREATE INDEX idx_history_folders_updated_at ON history_folders (updated_at);\n"
},
{
"file": "V003__add_history_mkdirs_table.sql",
"content": "\nCREATE TABLE history_mkdirs (\n item text PRIMARY KEY,\n updated_at integer NOT NULL\n);\n\nCREATE INDEX idx_history_mkdirs_updated_at ON history_mkdirs (updated_at);\n"
},
{
"file": "V004__add_history_select_patterns_table.sql",
"content": "\nCREATE TABLE history_select_patterns (\n item text PRIMARY KEY,\n updated_at integer NOT NULL\n);\n\nCREATE INDEX idx_history_select_patterns_updated_at\n ON history_select_patterns (updated_at);\n"
},
{
"file": "V005__add_history_copy_items_table.sql",
"content": "\nCREATE TABLE history_copy_items (\n item text PRIMARY KEY,\n updated_at integer NOT NULL\n);\n\nCREATE INDEX idx_history_copy_items_updated_at\n ON history_copy_items (updated_at);\n"
},
{
"file": "V006__add_folder_shortcuts_table.sql",
"content": "\nCREATE TABLE folder_shortcuts (\n id integer PRIMARY KEY,\n path text NOT NULL\n);\n"
},
{
"file": "V007__add_history_file_views_table.sql",
"content": "\nCREATE TABLE history_file_views (\n path text NOT NULL,\n is_edit boolean NOT NULL,\n encoding text NOT NULL,\n position double NOT NULL,\n wrap boolean,\n column integer,\n updated_at integer NOT NULL,\n \n PRIMARY KEY (path, is_edit)\n);\n\nCREATE INDEX idx_history_file_views_updated_at ON history_file_views (updated_at);\n"
},
{
"file": "V008__new_history_tables.sql",
"content": "\nCREATE TABLE history_kinds (\n id integer PRIMARY KEY,\n name text NOT NULL,\n \n UNIQUE (name)\n);\n\nCREATE TABLE history (\n kind_id integer NOT NULL,\n item text NOT NULL,\n params text,\n updated_at integer NOT NULL,\n \n PRIMARY KEY (kind_id, item),\n FOREIGN KEY (kind_id) REFERENCES history_kinds (id)\n);\n\nCREATE INDEX idx_history_kind_id_updated_at ON history (kind_id, updated_at);\n"
},
{
"file": "V009__copy_to_history_table.sql",
"content": "\nINSERT INTO history_kinds (id, name) VALUES (1, 'farjs.mkdirs');\nINSERT INTO history_kinds (id, name) VALUES (2, 'farjs.folders');\nINSERT INTO history_kinds (id, name) VALUES (3, 'farjs.selectPatterns');\nINSERT INTO history_kinds (id, name) VALUES (4, 'farjs.copyItems');\n\nINSERT INTO history (kind_id, item, params, updated_at)\n SELECT 1, item, NULL, updated_at FROM history_mkdirs;\n\nINSERT INTO history (kind_id, item, params, updated_at)\n SELECT 2, item, NULL, updated_at FROM history_folders;\n\nINSERT INTO history (kind_id, item, params, updated_at)\n SELECT 3, item, NULL, updated_at FROM history_select_patterns;\n\nINSERT INTO history (kind_id, item, params, updated_at)\n SELECT 4, item, NULL, updated_at FROM history_copy_items;\n"
}
]