From bafd48d3df9b43a1d49ec015eff30619d595468b Mon Sep 17 00:00:00 2001 From: Aylur Date: Tue, 15 Oct 2024 13:25:45 +0000 Subject: update lua and gjs layout installing the gjs package through meson or npm now results in the same exposed structure lua: fix rockspec docs: aur package --- lang/gjs/src/file.ts | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 lang/gjs/src/file.ts (limited to 'lang/gjs/src/file.ts') diff --git a/lang/gjs/src/file.ts b/lang/gjs/src/file.ts new file mode 100644 index 0000000..7b9de3a --- /dev/null +++ b/lang/gjs/src/file.ts @@ -0,0 +1,45 @@ +import Astal from "gi://AstalIO" +import Gio from "gi://Gio" + +export function readFile(path: string): string { + return Astal.read_file(path) || "" +} + +export function readFileAsync(path: string): Promise { + return new Promise((resolve, reject) => { + Astal.read_file_async(path, (_, res) => { + try { + resolve(Astal.read_file_finish(res) || "") + } + catch (error) { + reject(error) + } + }) + }) +} + +export function writeFile(path: string, content: string): void { + Astal.write_file(path, content) +} + +export function writeFileAsync(path: string, content: string): Promise { + return new Promise((resolve, reject) => { + Astal.write_file_async(path, content, (_, res) => { + try { + resolve(Astal.write_file_finish(res)) + } + catch (error) { + reject(error) + } + }) + }) +} + +export function monitorFile( + path: string, + callback: (file: string, event: Gio.FileMonitorEvent) => void, +): Gio.FileMonitor { + return Astal.monitor_file(path, (file: string, event: Gio.FileMonitorEvent) => { + callback(file, event) + })! +} -- cgit v1.2.3 From e7762eb33a8d5d8c216a42fb6634b8cd87fa9f14 Mon Sep 17 00:00:00 2001 From: Aylur Date: Fri, 18 Oct 2024 12:07:13 +0000 Subject: reexport modules - Gio from file - GLib from gobject - AstalIO.Process from process - AstalIO.Time from time --- lang/gjs/src/file.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lang/gjs/src/file.ts') diff --git a/lang/gjs/src/file.ts b/lang/gjs/src/file.ts index 7b9de3a..6ad8be3 100644 --- a/lang/gjs/src/file.ts +++ b/lang/gjs/src/file.ts @@ -1,5 +1,7 @@ import Astal from "gi://AstalIO" -import Gio from "gi://Gio" +import Gio from "gi://Gio?version=2.0" + +export { Gio } export function readFile(path: string): string { return Astal.read_file(path) || "" -- cgit v1.2.3