mirror of
https://github.com/DustinBrett/daedalOS.git
synced 2026-01-15 12:15:02 +00:00
Tweak constants/importing
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import type { FSModule } from "browserfs/dist/node/core/FS";
|
||||
import { Search } from "components/apps/FileExplorer/NavigationIcons";
|
||||
import StyledSearch from "components/apps/FileExplorer/StyledSearch";
|
||||
import { TEXT_EDITORS } from "components/system/Files/FileEntry/extensions";
|
||||
import { getInfoWithExtension } from "components/system/Files/FileEntry/functions";
|
||||
import type { FileInfo } from "components/system/Files/FileEntry/useFileInfo";
|
||||
import { useFileSystem } from "contexts/fileSystem";
|
||||
@@ -14,6 +13,7 @@ import {
|
||||
ICON_CACHE,
|
||||
ICON_CACHE_EXTENSION,
|
||||
SHORTCUT_EXTENSION,
|
||||
TEXT_EDITORS,
|
||||
YT_ICON_CACHE,
|
||||
} from "utils/constants";
|
||||
import {
|
||||
|
||||
70
components/system/Files/FileEntry/constants.ts
Normal file
70
components/system/Files/FileEntry/constants.ts
Normal file
@@ -0,0 +1,70 @@
|
||||
export const EXTRACTABLE_EXTENSIONS = new Set([
|
||||
".001",
|
||||
".7z",
|
||||
".ace",
|
||||
".apk",
|
||||
".appx",
|
||||
".arj",
|
||||
".bz2",
|
||||
".bzip2",
|
||||
".cab",
|
||||
".chm",
|
||||
".chw",
|
||||
".cpio",
|
||||
".deb",
|
||||
".dll",
|
||||
".dmg",
|
||||
".doc",
|
||||
".docx",
|
||||
".epub",
|
||||
".esd",
|
||||
".exe",
|
||||
".flv",
|
||||
".gz",
|
||||
".gzip",
|
||||
".hfs",
|
||||
".hxs",
|
||||
".img",
|
||||
".ipa",
|
||||
".jar",
|
||||
".lha",
|
||||
".lit",
|
||||
".lzh",
|
||||
".lzma",
|
||||
".mbr",
|
||||
".msi",
|
||||
".ntfs",
|
||||
".ods",
|
||||
".odt",
|
||||
".ova",
|
||||
".pages",
|
||||
".pkg",
|
||||
".ppt",
|
||||
".qcow",
|
||||
".qcow2",
|
||||
".r00",
|
||||
".rar",
|
||||
".rpm",
|
||||
".squashfs",
|
||||
".swf",
|
||||
".swm",
|
||||
".sys",
|
||||
".tar",
|
||||
".taz",
|
||||
".tgz",
|
||||
".txz",
|
||||
".udf",
|
||||
".vdi",
|
||||
".vhd",
|
||||
".vhdx",
|
||||
".vmdk",
|
||||
".wim",
|
||||
".xar",
|
||||
".xip",
|
||||
".xls",
|
||||
".xlsx",
|
||||
".xpi",
|
||||
".xz",
|
||||
".z",
|
||||
".zipx",
|
||||
]);
|
||||
@@ -1,5 +1,5 @@
|
||||
import { emulatorCores } from "components/apps/Emulator/config";
|
||||
import { EDITABLE_IMAGE_FILE_EXTENSIONS } from "utils/constants";
|
||||
import { EDITABLE_IMAGE_FILE_EXTENSIONS, TEXT_EDITORS } from "utils/constants";
|
||||
|
||||
type Extension = {
|
||||
command?: string;
|
||||
@@ -8,8 +8,6 @@ type Extension = {
|
||||
type?: string;
|
||||
};
|
||||
|
||||
export const TEXT_EDITORS = ["MonacoEditor", "Vim"];
|
||||
|
||||
const types = {
|
||||
Application: {
|
||||
icon: "executable",
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import extensions, {
|
||||
TEXT_EDITORS,
|
||||
} from "components/system/Files/FileEntry/extensions";
|
||||
import extensions from "components/system/Files/FileEntry/extensions";
|
||||
import { getProcessByFileExtension } from "components/system/Files/FileEntry/functions";
|
||||
import useFile from "components/system/Files/FileEntry/useFile";
|
||||
import type { FocusEntryFunctions } from "components/system/Files/FileManager/useFocusableEntries";
|
||||
@@ -23,7 +21,6 @@ import {
|
||||
CURSOR_FILE_EXTENSIONS,
|
||||
DESKTOP_PATH,
|
||||
EDITABLE_IMAGE_FILE_EXTENSIONS,
|
||||
EXTRACTABLE_EXTENSIONS,
|
||||
IMAGE_FILE_EXTENSIONS,
|
||||
MENU_SEPERATOR,
|
||||
MOUNTABLE_EXTENSIONS,
|
||||
@@ -32,6 +29,7 @@ import {
|
||||
ROOT_SHORTCUT,
|
||||
SHORTCUT_EXTENSION,
|
||||
SPREADSHEET_FORMATS,
|
||||
TEXT_EDITORS,
|
||||
UNSUPPORTED_BACKGROUND_EXTENSIONS,
|
||||
VIDEO_FILE_EXTENSIONS,
|
||||
} from "utils/constants";
|
||||
@@ -94,7 +92,7 @@ const useFileContextMenu = (
|
||||
const { contextMenu } = useMenu();
|
||||
const { onContextMenuCapture, ...contextMenuHandlers } = useMemo(
|
||||
() =>
|
||||
contextMenu?.(() => {
|
||||
contextMenu?.(async () => {
|
||||
const urlExtension = getExtension(url);
|
||||
const { process: extensionProcesses = [] } =
|
||||
urlExtension in extensions ? extensions[urlExtension] : {};
|
||||
@@ -410,6 +408,10 @@ const useFileContextMenu = (
|
||||
}
|
||||
}
|
||||
|
||||
const { EXTRACTABLE_EXTENSIONS } = await import(
|
||||
"components/system/Files/FileEntry/constants"
|
||||
);
|
||||
|
||||
menuItems.unshift(
|
||||
{
|
||||
action: () => archiveFiles(absoluteEntries()),
|
||||
|
||||
2
components/system/Files/FileManager/icons.ts
Normal file
2
components/system/Files/FileManager/icons.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export const UNKNOWN_ICON =
|
||||
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAB0ElEQVR42u2ZVWLbQBiEp/K6DOpb+LF4ip47oCuULpAYH3uAlcbMNOZpm0lsizWz+/3CgEc9aiuFHz9/YYVIcjAAkODcYYDoTyPQHZse7m0E49tLkid/8rz4BuD7RgFIYpW+fvmMXStJEvz+/RuvXr1KG41mVhT5RiECRMUYsUuF0Nv18+fPcXp6ktbrjSzPhRBCDxxUpVKpG+Ls7DSt1eprhwjYWwAdJQD9EGftELV2iCiHCAQMAvT04sVznJ+fpdVqNcuj1hOBJj0wCvECFxcXaeWhIuEUYFADAGZCXF5dpg/3DxmA99YIZVmGRXr58lVqi1CMER8+fOh+pkUS5XIZd7d3ylEIViI5M7wCITqa1wOAtDVPKD1A45andC1ES/N6DZCuzKsIWZr3RoikMK4jZGleD2BsntDOA74tT0gIOZrXEfJmXiti24KleBi1M09SThBIU/P6mZiW5qEXMW3NUzuMGrc8NYRssSE0hFyZVxFyLVgdIcOW51oIWZqHfj9ga15+rOLb8lIRg47m9RoQ/R+eeb0GaGleR8i15XWEqL5VFIIJ87V5u70nvrm+AUF0/8nx4ZlxgOj+9KeTk+Oz8/rrYnIYBAoWeNSj9qwWS/T9vUU9j2EAAAAASUVORK5CYII=";
|
||||
@@ -4,7 +4,7 @@ import { useSession } from "contexts/session";
|
||||
import { join } from "path";
|
||||
import { useCallback, useEffect, useRef, useState } from "react";
|
||||
import type { Position } from "react-rnd";
|
||||
import { MILLISECONDS_IN_SECOND, UNKNOWN_ICON } from "utils/constants";
|
||||
import { MILLISECONDS_IN_SECOND } from "utils/constants";
|
||||
import {
|
||||
getHtmlToImage,
|
||||
haltEvent,
|
||||
@@ -187,6 +187,10 @@ const useDraggableEntries = (
|
||||
let newDragImage: string | undefined;
|
||||
|
||||
try {
|
||||
const { UNKNOWN_ICON } = await import(
|
||||
"components/system/Files/FileManager/icons"
|
||||
);
|
||||
|
||||
newDragImage = await htmlToImage?.toPng(fileManagerRef.current, {
|
||||
filter: (element) => {
|
||||
return (
|
||||
|
||||
@@ -43,7 +43,7 @@ export type ContextMenuCapture = {
|
||||
|
||||
type MenuContextState = {
|
||||
contextMenu: (
|
||||
getItems: (event?: CaptureTriggerEvent) => MenuItem[]
|
||||
getItems: (event?: CaptureTriggerEvent) => MenuItem[] | Promise<MenuItem[]>
|
||||
) => ContextMenuCapture;
|
||||
menu: MenuState;
|
||||
setMenu: React.Dispatch<React.SetStateAction<MenuState>>;
|
||||
@@ -55,13 +55,15 @@ const useMenuContextState = (): MenuContextState => {
|
||||
const touchEvent = useRef<React.TouchEvent>();
|
||||
const contextMenu = useCallback(
|
||||
(
|
||||
getItems: (event?: CaptureTriggerEvent) => MenuItem[]
|
||||
getItems: (
|
||||
event?: CaptureTriggerEvent
|
||||
) => MenuItem[] | Promise<MenuItem[]>
|
||||
): ContextMenuCapture => {
|
||||
const onContextMenuCapture = (
|
||||
const onContextMenuCapture = async (
|
||||
event?: CaptureTriggerEvent,
|
||||
domRect?: DOMRect,
|
||||
options?: MenuOptions
|
||||
): void => {
|
||||
): Promise<void> => {
|
||||
const { staticX, staticY } = options || {};
|
||||
let x = 0;
|
||||
let y = 0;
|
||||
@@ -78,7 +80,7 @@ const useMenuContextState = (): MenuContextState => {
|
||||
y = inputY + height;
|
||||
}
|
||||
|
||||
const items = getItems(event);
|
||||
const items = await getItems(event);
|
||||
|
||||
setMenu({
|
||||
items: items.length > 0 ? items : undefined,
|
||||
|
||||
@@ -8,13 +8,6 @@ export const BASE_2D_CONTEXT_OPTIONS: CanvasRenderingContext2DSettings = {
|
||||
desynchronized: true,
|
||||
};
|
||||
|
||||
export const IPFS_GATEWAY_URLS = [
|
||||
"https://<CID>.ipfs.cf-ipfs.com/",
|
||||
"https://<CID>.ipfs.dweb.link/",
|
||||
"https://cloudflare-ipfs.com/ipfs/<CID>/",
|
||||
"https://gateway.ipfs.io/ipfs/<CID>/",
|
||||
];
|
||||
|
||||
export const IFRAME_CONFIG = {
|
||||
referrerPolicy: "no-referrer" as React.HTMLAttributeReferrerPolicy,
|
||||
sandbox:
|
||||
@@ -125,6 +118,8 @@ export const UNSUPPORTED_BACKGROUND_EXTENSIONS = new Set([
|
||||
".svg",
|
||||
]);
|
||||
|
||||
export const TEXT_EDITORS = ["MonacoEditor", "Vim"];
|
||||
|
||||
export const CURSOR_FILE_EXTENSIONS = new Set([".ani", ".cur"]);
|
||||
|
||||
export const EDITABLE_IMAGE_FILE_EXTENSIONS = new Set([
|
||||
@@ -153,77 +148,6 @@ export const MILLISECONDS_IN_MINUTE = 60000;
|
||||
|
||||
export const MILLISECONDS_IN_DAY = 86400000;
|
||||
|
||||
export const EXTRACTABLE_EXTENSIONS = new Set([
|
||||
".001",
|
||||
".7z",
|
||||
".ace",
|
||||
".apk",
|
||||
".appx",
|
||||
".arj",
|
||||
".bz2",
|
||||
".bzip2",
|
||||
".cab",
|
||||
".chm",
|
||||
".chw",
|
||||
".cpio",
|
||||
".deb",
|
||||
".dll",
|
||||
".dmg",
|
||||
".doc",
|
||||
".docx",
|
||||
".epub",
|
||||
".esd",
|
||||
".exe",
|
||||
".flv",
|
||||
".gz",
|
||||
".gzip",
|
||||
".hfs",
|
||||
".hxs",
|
||||
".img",
|
||||
".ipa",
|
||||
".jar",
|
||||
".lha",
|
||||
".lit",
|
||||
".lzh",
|
||||
".lzma",
|
||||
".mbr",
|
||||
".msi",
|
||||
".ntfs",
|
||||
".ods",
|
||||
".odt",
|
||||
".ova",
|
||||
".pages",
|
||||
".pkg",
|
||||
".ppt",
|
||||
".qcow",
|
||||
".qcow2",
|
||||
".r00",
|
||||
".rar",
|
||||
".rpm",
|
||||
".squashfs",
|
||||
".swf",
|
||||
".swm",
|
||||
".sys",
|
||||
".tar",
|
||||
".taz",
|
||||
".tgz",
|
||||
".txz",
|
||||
".udf",
|
||||
".vdi",
|
||||
".vhd",
|
||||
".vhdx",
|
||||
".vmdk",
|
||||
".wim",
|
||||
".xar",
|
||||
".xip",
|
||||
".xls",
|
||||
".xlsx",
|
||||
".xpi",
|
||||
".xz",
|
||||
".z",
|
||||
".zipx",
|
||||
]);
|
||||
|
||||
export const MOUNTABLE_EXTENSIONS = new Set([".iso", ".jsdos", ".wsz", ".zip"]);
|
||||
|
||||
export const SPREADSHEET_FORMATS = [
|
||||
@@ -347,9 +271,6 @@ export const MOUNTED_FOLDER_ICON = `${ICON_PATH}/mounted.webp`;
|
||||
|
||||
export const NEW_FOLDER_ICON = `${ICON_PATH}/new_folder.webp`;
|
||||
|
||||
export const UNKNOWN_ICON =
|
||||
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAB0ElEQVR42u2ZVWLbQBiEp/K6DOpb+LF4ip47oCuULpAYH3uAlcbMNOZpm0lsizWz+/3CgEc9aiuFHz9/YYVIcjAAkODcYYDoTyPQHZse7m0E49tLkid/8rz4BuD7RgFIYpW+fvmMXStJEvz+/RuvXr1KG41mVhT5RiECRMUYsUuF0Nv18+fPcXp6ktbrjSzPhRBCDxxUpVKpG+Ls7DSt1eprhwjYWwAdJQD9EGftELV2iCiHCAQMAvT04sVznJ+fpdVqNcuj1hOBJj0wCvECFxcXaeWhIuEUYFADAGZCXF5dpg/3DxmA99YIZVmGRXr58lVqi1CMER8+fOh+pkUS5XIZd7d3ylEIViI5M7wCITqa1wOAtDVPKD1A45andC1ES/N6DZCuzKsIWZr3RoikMK4jZGleD2BsntDOA74tT0gIOZrXEfJmXiti24KleBi1M09SThBIU/P6mZiW5qEXMW3NUzuMGrc8NYRssSE0hFyZVxFyLVgdIcOW51oIWZqHfj9ga15+rOLb8lIRg47m9RoQ/R+eeb0GaGleR8i15XWEqL5VFIIJ87V5u70nvrm+AUF0/8nx4ZlxgOj+9KeTk+Oz8/rrYnIYBAoWeNSj9qwWS/T9vUU9j2EAAAAASUVORK5CYII=";
|
||||
|
||||
export const SMALLEST_JXL_FILE =
|
||||
"data:image/jxl;base64,/woIAAAMABKIAgC4AF3lEgAAFSqjjBu8nOv58kOHxbSN6wxttW1hSaLIODZJJ3BIEkkaoCUzGM6qJAE=";
|
||||
|
||||
|
||||
@@ -1,12 +1,18 @@
|
||||
import {
|
||||
HIGH_PRIORITY_REQUEST,
|
||||
IPFS_GATEWAY_URLS,
|
||||
MILLISECONDS_IN_SECOND,
|
||||
ONE_TIME_PASSIVE_EVENT,
|
||||
} from "utils/constants";
|
||||
|
||||
let IPFS_GATEWAY_URL = "";
|
||||
|
||||
export const IPFS_GATEWAY_URLS = [
|
||||
"https://<CID>.ipfs.cf-ipfs.com/",
|
||||
"https://<CID>.ipfs.dweb.link/",
|
||||
"https://cloudflare-ipfs.com/ipfs/<CID>/",
|
||||
"https://gateway.ipfs.io/ipfs/<CID>/",
|
||||
];
|
||||
|
||||
const isIpfsGatewayAvailable = (gatewayUrl: string): Promise<boolean> =>
|
||||
new Promise((resolve) => {
|
||||
const timeoutId = window.setTimeout(
|
||||
@@ -34,7 +40,7 @@ const isIpfsGatewayAvailable = (gatewayUrl: string): Promise<boolean> =>
|
||||
|
||||
img.src = `${gatewayUrl.replace(
|
||||
"<CID>",
|
||||
// https://github.com/ipfs/public-gateway-checker/blob/master/src/constants.ts
|
||||
// https://github.com/ipfs/public-gateway-checker/blob/master/src/constants.ts (IMG_HASH)
|
||||
"bafybeibwzifw52ttrkqlikfzext5akxu7lz4xiwjgwzmqcpdzmp3n5vnbe"
|
||||
)}?now=${Date.now()}&filename=1x1.png#x-ipfs-companion-no-redirect`;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user