Pass home and cache through bundler

This commit is contained in:
2 * r + 2 * t 2025-01-15 12:53:42 +11:00
parent 2d7ad5977f
commit 01540ca9d2
6 changed files with 8 additions and 31 deletions

22
env.d.ts vendored
View file

@ -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;
}

View file

@ -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";

View file

@ -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

View file

@ -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<string, string> = {};

View file

@ -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,

View file

@ -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}'`);