From 01540ca9d24112e8b587c35150e2c9b7bbfdbdec Mon Sep 17 00:00:00 2001 From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> Date: Wed, 15 Jan 2025 12:53:42 +1100 Subject: Pass home and cache through bundler --- env.d.ts | 22 ++-------------------- modules/launcher.tsx | 1 - run.fish | 5 ++++- services/math.ts | 3 +-- services/players.ts | 3 +-- utils/constants.ts | 5 ----- 6 files changed, 8 insertions(+), 31 deletions(-) delete mode 100644 utils/constants.ts diff --git a/env.d.ts b/env.d.ts index 2e051ce..eca9fc8 100644 --- a/env.d.ts +++ b/env.d.ts @@ -1,21 +1,3 @@ +declare const HOME: string; +declare const CACHE: string; declare const SRC: string; - -declare module "inline:*" { - const content: string; - export default content; -} - -declare module "*.scss" { - const content: string; - export default content; -} - -declare module "*.blp" { - const content: string; - export default content; -} - -declare module "*.css" { - const content: string; - export default content; -} diff --git a/modules/launcher.tsx b/modules/launcher.tsx index 0768539..83245ca 100644 --- a/modules/launcher.tsx +++ b/modules/launcher.tsx @@ -6,7 +6,6 @@ import AstalHyprland from "gi://AstalHyprland"; import { launcher as config } from "../config"; import { Apps } from "../services/apps"; import Math, { type HistoryItem } from "../services/math"; -import { HOME } from "../utils/constants"; import { getAppCategoryIcon } from "../utils/icons"; import { launch } from "../utils/system"; import { PopupWindow, setupCustomTooltip, TransitionType } from "../utils/widgets"; diff --git a/run.fish b/run.fish index 66e23ef..5e2d48e 100755 --- a/run.fish +++ b/run.fish @@ -3,9 +3,12 @@ cd (dirname (status filename)) || exit 1 set -q XDG_RUNTIME_DIR && set bundle_dir $XDG_RUNTIME_DIR || set bundle_dir /tmp +set -q XDG_CACHE_HOME && set cache_dir $XDG_CACHE_HOME/caelestia || set cache_dir $HOME/.cache/caelestia + +mkdir -p $cache_dir ./node_modules/.bin/esbuild app.tsx --bundle --outfile=$bundle_dir/caelestia.js \ --external:console --external:system --external:cairo --external:gettext --external:'file://*' --external:'gi://*' --external:'resource://*' \ - --define:SRC=\"(pwd)\" --format=esm --platform=neutral --main-fields=module,main + --define:HOME=\"$HOME\" --define:CACHE=\"$cache_dir\" --define:SRC=\"(pwd)\" --format=esm --platform=neutral --main-fields=module,main gjs -m $bundle_dir/caelestia.js diff --git a/services/math.ts b/services/math.ts index 41e1488..2c7fabd 100644 --- a/services/math.ts +++ b/services/math.ts @@ -1,6 +1,5 @@ import { GLib, GObject, property, readFile, register, writeFileAsync } from "astal"; import { derivative, evaluate, rationalize, simplify } from "mathjs/number"; -import { CACHE_DIR } from "../utils/constants"; export interface HistoryItem { equation: string; @@ -18,7 +17,7 @@ export default class Math extends GObject.Object { } readonly #maxHistory = 20; - readonly #path = `${CACHE_DIR}/math-history.json`; + readonly #path = `${CACHE}/math-history.json`; readonly #history: HistoryItem[] = []; #variables: Record = {}; diff --git a/services/players.ts b/services/players.ts index 3313595..b81d4b5 100644 --- a/services/players.ts +++ b/services/players.ts @@ -1,6 +1,5 @@ import { GLib, GObject, property, readFile, register, writeFileAsync } from "astal"; import AstalMpris from "gi://AstalMpris"; -import { CACHE_DIR } from "../utils/constants"; import { isRealPlayer } from "../utils/mpris"; @register({ GTypeName: "Players" }) @@ -12,7 +11,7 @@ export default class Players extends GObject.Object { return this.instance; } - readonly #path = `${CACHE_DIR}/players.txt`; + readonly #path = `${CACHE}/players.txt`; readonly #players: AstalMpris.Player[] = []; readonly #subs = new Map< JSX.Element, diff --git a/utils/constants.ts b/utils/constants.ts deleted file mode 100644 index 2604c0e..0000000 --- a/utils/constants.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { exec, GLib } from "astal"; - -export const HOME = GLib.get_home_dir(); -export const CACHE_DIR = GLib.get_user_cache_dir() + "/caelestia"; -exec(`mkdir -p '${CACHE_DIR}'`); -- cgit v1.2.3-freya